@maptalks/3dtiles 0.124.0 → 0.124.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * @maptalks/3dtiles v0.124.0
2
+ * @maptalks/3dtiles v0.124.2
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2026 maptalks.org
5
5
  */
6
- import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,HighlightUtil as s,ContextUtil as i,quat as o,vec3 as a,mat3 as c,getWGSLSource as l,vec4 as h,MaskRendererMixin as u,CanvasCompatible as f,MaskLayerMixin as d,ClipOutsideMask as m,vec2 as p}from"@maptalks/gl";import{intersectsBox as y,intersectsOrientedBox as b,intersectsSphere as g}from"frustum-intersects";import{quat as w,mat4 as v,vec3 as T,mat3 as _}from"gl-matrix";const M="${",O=`function(t){\n/*!\n * @maptalks/gl v0.124.0\n * LICENSE : UNLICENSED\n * (c) 2016-2026 maptalks.com\n */\nconst e=function(){if("undefined"!=typeof undefinedThis)return globalThis;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")},n=e(),r=n.gl_trans__coders=n.gl_trans__coders||{};function a(){return e().maptalks_gltf_loader}r.inject=function(t){const r=t.toString(),a=r.indexOf("{")+1,o=r.substring(0,a),i=n.gl_trans__coders=n.gl_trans__coders||{};let s=\`${M}o}\\n const _____getGlobal = ${M}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 i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\\n;");return s+="\\n("+e().maptalks_gltf_loader_bundle.toString()+")({});\\n",s+="\\n"+r.substring(o.length),s},r.registerTranscoder=function(t,e){r[t]=e},r.getTranscoder=function(t){return r[t]};var o="undefined"!=typeof Float32Array?Float32Array:Array;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 s(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],s=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],y=e[10],d=e[11],b=e[12],m=e[13],p=e[14],g=e[15],v=n[0],w=n[1],M=n[2],T=n[3];return t[0]=v*r+w*s+M*f+T*b,t[1]=v*a+w*c+M*h+T*m,t[2]=v*o+w*u+M*y+T*p,t[3]=v*i+w*l+M*d+T*g,v=n[4],w=n[5],M=n[6],T=n[7],t[4]=v*r+w*s+M*f+T*b,t[5]=v*a+w*c+M*h+T*m,t[6]=v*o+w*u+M*y+T*p,t[7]=v*i+w*l+M*d+T*g,v=n[8],w=n[9],M=n[10],T=n[11],t[8]=v*r+w*s+M*f+T*b,t[9]=v*a+w*c+M*h+T*m,t[10]=v*o+w*u+M*y+T*p,t[11]=v*i+w*l+M*d+T*g,v=n[12],w=n[13],M=n[14],T=n[15],t[12]=v*r+w*s+M*f+T*b,t[13]=v*a+w*c+M*h+T*m,t[14]=v*o+w*u+M*y+T*p,t[15]=v*i+w*l+M*d+T*g,t}function c(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 u(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function l(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function f(t,e,n){var r=new o(3);return r[0]=t,r[1]=e,r[2]=n,r}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function y(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function d(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function b(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function m(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function p(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[3]*r+n[7]*a+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*a+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*a+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*a+n[10]*o+n[14])/i,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var g=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},v=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},w=l;function M(){var t=new o(4);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}u(),function(){var t,e=(t=new o(4),o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var T;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}u(),f(1,0,0),f(0,1,0),M(),M(),T=new o(9),o!=Float32Array&&(T[1]=0,T[2]=0,T[3]=0,T[5]=0,T[6]=0,T[7]=0),T[0]=1,T[4]=1,T[8]=1;var k={exports:{}},_={exports:{}},O=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},S=Array.prototype.concat,x=Array.prototype.slice,F=_.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var a=t[n];O(a)?e=S.call(e,x.call(a)):e.push(a)}return e};F.wrap=function(t){return function(){return t(F(arguments))}};var I=_.exports,C={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},E=I,U=Object.hasOwnProperty,N=Object.create(null);for(var z in C)U.call(C,z)&&(N[C[z]]=z);var L=k.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}L.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=L.get.hsl(t),n="hsl";break;case"hwb":e=L.get.hwb(t),n="hwb";break;default:e=L.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},L.get.rgb=function(t){if(!t)return null;var e,n,r,a=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;a[n]=parseInt(e.slice(o,o+2),16)}r&&(a[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)a[n]=parseInt(e[n]+e[n],16);r&&(a[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)a[n]=parseInt(e[n+1],0);e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:U.call(C,e[1])?((a=C[e[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}for(n=0;n<3;n++)a[n]=j(a[n],0,255);return a[3]=j(a[3],0,1),a},L.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.to.hex=function(){var t=E(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},L.to.rgb=function(){var t=E(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},L.to.rgb.percent=function(){var t=E(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},L.to.hsl=function(){var t=E(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},L.to.hwb=function(){var t=E(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},L.to.keyword=function(t){return N[t.slice(0,3)]};var P=k.exports,B={exports:{}},q={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R={};for(var V in q)q.hasOwnProperty(V)&&(R[q[V]]=V);var G=B.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $ in G)if(G.hasOwnProperty($)){if(!("channels"in G[$]))throw new Error("missing channels property: "+$);if(!("labels"in G[$]))throw new Error("missing channel labels property: "+$);if(G[$].labels.length!==G[$].channels)throw new Error("channel and label counts mismatch: "+$);var X=G[$].channels,H=G[$].labels;delete G[$].channels,delete G[$].labels,Object.defineProperty(G[$],"channels",{value:X}),Object.defineProperty(G[$],"labels",{value:H})}G.rgb.hsl=function(t){var e,n,r=t[0]/255,a=t[1]/255,o=t[2]/255,i=Math.min(r,a,o),s=Math.max(r,a,o),c=s-i;return s===i?e=0:r===s?e=(a-o)/c:a===s?e=2+(o-r)/c:o===s&&(e=4+(r-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(i+s)/2,[e,100*(s===i?0:n<=.5?c/(s+i):c/(2-s-i)),100*n]},G.rgb.hsv=function(t){var e,n,r,a,o,i=t[0]/255,s=t[1]/255,c=t[2]/255,u=Math.max(i,s,c),l=u-Math.min(i,s,c),f=function(t){return(u-t)/6/l+.5};return 0===l?a=o=0:(o=l/u,e=f(i),n=f(s),r=f(c),i===u?a=r-n:s===u?a=1/3+e-r:c===u&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*u]},G.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[G.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},G.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-a)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-a-e)/(1-e)||0),100*e]},G.rgb.keyword=function(t){var e=R[t];if(e)return e;var n,r,a,o=1/0;for(var i in q)if(q.hasOwnProperty(i)){var s=q[i],c=(r=t,a=s,Math.pow(r[0]-a[0],2)+Math.pow(r[1]-a[1],2)+Math.pow(r[2]-a[2],2));c<o&&(o=c,n=i)}return n},G.keyword.rgb=function(t){return q[t]},G.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},G.rgb.lab=function(t){var e=G.rgb.xyz(t),n=e[0],r=e[1],a=e[2];return r/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},G.hsl.rgb=function(t){var e,n,r,a,o,i=t[0]/360,s=t[1]/100,c=t[2]/100;if(0===s)return[o=255*c,o,o];e=2*c-(n=c<.5?c*(1+s):c+s-c*s),a=[0,0,0];for(var u=0;u<3;u++)(r=i+1/3*-(u-1))<0&&r++,r>1&&r--,o=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[u]=255*o;return a},G.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,a=n,o=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,a*=o<=1?o:2-o,[e,100*(0===r?2*a/(o+a):2*n/(r+n)),100*((r+n)/2)]},G.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),i=255*r*(1-n),s=255*r*(1-n*o),c=255*r*(1-n*(1-o));switch(r*=255,a){case 0:return[r,c,i];case 1:return[s,r,i];case 2:return[i,r,c];case 3:return[i,s,r];case 4:return[c,i,r];case 5:return[r,i,s]}},G.hsv.hsl=function(t){var e,n,r,a=t[0],o=t[1]/100,i=t[2]/100,s=Math.max(i,.01);return r=(2-o)*i,n=o*s,[a,100*(n=(n/=(e=(2-o)*s)<=1?e:2-e)||0),100*(r/=2)]},G.hwb.rgb=function(t){var e,n,r,a,o,i,s,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),a=u+r*((n=1-l)-u),e){default:case 6:case 0:o=n,i=a,s=u;break;case 1:o=a,i=n,s=u;break;case 2:o=u,i=n,s=a;break;case 3:o=u,i=a,s=n;break;case 4:o=a,i=u,s=n;break;case 5:o=n,i=u,s=a}return[255*o,255*i,255*s]},G.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,a=t[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},G.xyz.rgb=function(t){var e,n,r,a=t[0]/100,o=t[1]/100,i=t[2]/100;return n=-.9689*a+1.8758*o+.0415*i,r=.0557*a+-.204*o+1.057*i,e=(e=3.2406*a+-1.5372*o+-.4986*i)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},G.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},G.lab.xyz=function(t){var e,n,r,a=t[0];e=t[1]/500+(n=(a+16)/116),r=n-t[2]/200;var o=Math.pow(n,3),i=Math.pow(e,3),s=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,e=i>.008856?i:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},G.lab.lch=function(t){var e,n=t[0],r=t[1],a=t[2];return(e=360*Math.atan2(a,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+a*a),e]},G.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},G.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:G.rgb.hsv(t)[2];if(0===(a=Math.round(a/50)))return 30;var o=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(o+=60),o},G.hsv.ansi16=function(t){return G.rgb.ansi16(G.hsv.rgb(t),t[2])},G.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},G.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},G.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},G.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},G.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},G.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.max(Math.max(n,r),a),i=Math.min(Math.min(n,r),a),s=o-i;return e=s<=0?0:o===n?(r-a)/s%6:o===r?2+(a-n)/s:4+(n-r)/s+4,e/=6,[360*(e%=1),100*s,100*(s<1?i/(1-s):0)]},G.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},G.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a,o=[0,0,0],i=e%1*6,s=i%1,c=1-s;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=c,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=c,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=c}return a=(1-n)*r,[255*(n*o[0]+a),255*(n*o[1]+a),255*(n*o[2]+a)]},G.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},G.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},G.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},G.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},G.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},G.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},G.gray.hsl=G.gray.hsv=function(t){return[0,0,t[0]]},G.gray.hwb=function(t){return[0,100,t[0]]},G.gray.cmyk=function(t){return[0,0,0,t[0]]},G.gray.lab=function(t){return[t[0],0,0]},G.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},G.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var J=B.exports,Y=J;function K(t){var e=function(){for(var t={},e=Object.keys(Y),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),a=Object.keys(Y[r]),o=a.length,i=0;i<o;i++){var s=a[i],c=e[s];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(s))}return e}function Q(t,e){return function(n){return e(t(n))}}function Z(t,e){for(var n=[e[t].parent,t],r=Y[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=Q(Y[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}var W=J,tt=function(t){for(var e=K(t),n={},r=Object.keys(e),a=r.length,o=0;o<a;o++){var i=r[o];null!==e[i].parent&&(n[i]=Z(i,e))}return n},et={};Object.keys(W).forEach((function(t){et[t]={},Object.defineProperty(et[t],"channels",{value:W[t].channels}),Object.defineProperty(et[t],"labels",{value:W[t].labels});var e=tt(t);Object.keys(e).forEach((function(n){var r=e[n];et[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),et[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var nt=P,rt=et,at=[].slice,ot=["keyword","gray","hex"],it={};Object.keys(rt).forEach((function(t){it[at.call(rt[t].labels).sort().join("")]=t}));var st={};function ct(t,e){if(!(this instanceof ct))return new ct(t,e);if(e&&e in ot&&(e=null),e&&!(e in rt))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ct)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var a=nt.get(t);if(null===a)throw new Error("Unable to parse color from string: "+t);this.model=a.model,r=rt[this.model].channels,this.color=a.value.slice(0,r),this.valpha="number"==typeof a.value[r]?a.value[r]:1}else if(t.length){this.model=e||"rgb",r=rt[this.model].channels;var o=at.call(t,0,r);this.color=ft(o,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var s=i.sort().join("");if(!(s in it))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=it[s];var c=rt[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ft(u)}if(st[this.model])for(r=rt[this.model].channels,n=0;n<r;n++){var l=st[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ut(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(st[t]||(st[t]=[]))[e]=n})),t=t[0],function(r){var a;return arguments.length?(n&&(r=n(r)),(a=this[t]()).color[e]=r,a):(a=this[t]().color[e],n&&(a=n(a)),a)}}function lt(t){return function(e){return Math.max(0,Math.min(t,e))}}function ft(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function ht(t){return null==t}function yt(t){return"object"==typeof t&&!!t}function dt(t){return t/Math.PI*180}ct.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in nt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return nt.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return nt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=rt[this.model].channels,n=rt[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ct(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ct(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ut("rgb",0,lt(255)),green:ut("rgb",1,lt(255)),blue:ut("rgb",2,lt(255)),hue:ut(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ut("hsl",1,lt(100)),lightness:ut("hsl",2,lt(100)),saturationv:ut("hsv",1,lt(100)),value:ut("hsv",2,lt(100)),chroma:ut("hcg",1,lt(100)),gray:ut("hcg",2,lt(100)),white:ut("hwb",1,lt(100)),wblack:ut("hwb",2,lt(100)),cyan:ut("cmyk",0,lt(100)),magenta:ut("cmyk",1,lt(100)),yellow:ut("cmyk",2,lt(100)),black:ut("cmyk",3,lt(100)),x:ut("xyz",0,lt(100)),y:ut("xyz",1,lt(100)),z:ut("xyz",2,lt(100)),l:ut("lab",0,lt(100)),a:ut("lab",1),b:ut("lab",2),keyword:function(t){return arguments.length?new ct(t):rt[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ct(t):nt.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ct.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),a=void 0===e?.5:e,o=2*a-1,i=n.alpha()-r.alpha(),s=((o*i==-1?o:(o+i)/(1+o*i))+1)/2,c=1-s;return ct.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*a+r.alpha()*(1-a))}},Object.keys(rt).forEach((function(t){if(-1===ot.indexOf(t)){var e=rt[t].channels;ct.prototype[t]=function(){if(this.model===t)return new ct(this);if(arguments.length)return new ct(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ct((n=rt[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ct[t]=function(n){return"number"==typeof n&&(n=ft(at.call(arguments),e)),new ct(n,t)}}}));const bt=[1,1,1,1,2,2,3,0];function mt(t){const e=t.length;let n="";for(let r=0;r<e;){let a=t[r++];if(128&a){let n=bt[a>>3&7];if(!(64&a)||!n||r+n>e)return null;for(a&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;a=a<<6|63&e}}n+=String.fromCharCode(a)}return n}new Array(3),new Array(3);const pt=[1/6378137,1/6378137,1/6356752.314245179],gt=[1/40680631590769,1/40680631590769,1/40408299984661.445],vt=new Array(3),wt=new Array(3),Mt=new Array(3);function Tt(t,e){const n=gt,r=function(t,e,n,r,a){const o=e[0],i=e[1],s=e[2],c=n[0],u=n[1],l=n[2],f=o*o*c*c,h=i*i*u*u,y=s*s*l*l,d=f+h+y,b=Math.sqrt(1/d),m=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(At,e,b);if(d<a)return isFinite(b)?m:void 0;const p=r[0],g=r[1],v=r[2],w=kt;w[0]=m[0]*p*2,w[1]=m[1]*g*2,w[2]=m[2]*v*2;let M,T,A,k,_,O,S,x,F,I,C,E=(1-b)*Ot(e)/(.5*Ot(w)),U=0;do{E-=U,A=1/(1+E*p),k=1/(1+E*g),_=1/(1+E*v),O=A*A,S=k*k,x=_*_,F=O*A,I=S*k,C=x*_,M=f*O+h*S+y*x-1,T=f*F*p+h*I*g+y*C*v;U=M/(-2*T)}while(Math.abs(M)>_t);return t[0]=o*A,t[1]=i*k,t[2]=s*_,t}(vt,e,pt,n,.1);let a=v(wt,r,n);a=function(t,e){const n=e[0],r=e[1],a=e[2];let o=n*n+r*r+a*a;o>0&&(o=Math.sqrt(o),t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o);return t}(a,a);const o=g(Mt,e,r),i=Math.atan2(a[1],a[0]),s=Math.asin(a[2]),c=(u=m(o,e),(Math.sign?Math.sign(u):0==(u=+u)||isNaN(u)?Number(u):u>0?1:-1)*Ot(o));var u;return t[0]=dt(i),t[1]=dt(s),t[2]=c,t}const At=new Array(3),kt=new Array(3),_t=1e-12;function Ot(t){return l(t)}function St(t,e){let n="";for(let r=0;r<4;r++){const a=t.getUint8(e+r);n+=String.fromCharCode(a)}return n}const xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ft(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function It(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function Ct(t,e,n){return{offset:e,byteLength:n}}function Et(t,e,n,r){const{byteOffset:a,componentType:o,type:i}=t,{ctor:s,type:c}=function(t){return zt[t]}(o||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Nt[t]}(i);return{byteStride:0,byteOffset:a+n,itemSize:u,count:r*u,componentType:c,array:new s(e,n+a,r*u)}}function Ut(t,e,n,r){const a=Et(t,e,n,r);return a.array.buffer.byteLength!==e.byteLength&&(a.array=a.array.slice()),a}const Nt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const zt={"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 Lt(t){for(const e in zt)if(t===zt[e].ctor)return zt[e].type;throw new Error("unrecognized ctor:"+t)}function jt(t,e,n,r){const a=t,o=e.length/3;for(let t=0;t<o;t++)a[3*t]=e[3*t]/65535*r[0]+n[0],a[3*t+1]=e[3*t+1]/65535*r[1]+n[1],a[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return a}function Dt(t,e,n){const r=t.getUint32(12,!0),a=t.getUint32(16,!0),o=t.getUint32(20,!0),i=t.getUint32(24,!0),s=t.buffer;let c,u={},l={},f=null;r>0&&(u=Ft(s,e,r),e+=r),a>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,a),e+=a),o>0&&(l=It(s,e,o),e+=o);const h=Ct(0,e,i);return f=s.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const Pt={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Bt(t){for(const e in Pt)if(t===Pt[e])return+e;throw new Error("unrecognized ctor:"+t)}let qt=null;function Rt(){return qt||(qt={"image/crn":r.crn&&r.crn(),"image/ktx2":r.ktx2&&r.ktx2(),"image/cttf":r.ktx2&&r.ktx2(),"draco":r.draco&&r.draco()}),qt}const{Ajax:Vt,GLTFLoader:Gt}=a();class $t{constructor(t,e,n){this.o=t,this.i=e||Gt,this.u=n,this.h=Rt()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Vt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){const o=a&&a.maxTextureSize,i=this.p(e,n,r,t);if(i.error)return Promise.resolve(i);const s=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.i(s,i.glb,{transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${M}t}-${M}n}-${M}r}\`;const a=c.transferables;for(let t=0;t<i.transferables.length;t++)a.indexOf(i.transferables[t])<0&&a.push(i.transferables[t]);return{magic:"b3dm",count:i.count,transferables:a,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,gltf:e}}))}p(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported b3dm version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let i,s=a.getUint32(12,!0),c=a.getUint32(16,!0),u=a.getUint32(20,!0),l=a.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,i=s,u=c,l=0,s=0,c=0):l>=570425344&&(f-=4,i=u,u=s,l=c,s=0,c=0);const h=[t];let y,d,b;if(s>0?(y=Ft(t,f,s),f+=s,i=y.BATCH_LENGTH):y={"BATCH_LENGTH":i},c>0&&(f+=c),u>0&&(d=It(t,f,u),f+=u,l>0)){const e=Ct(0,f,l);b=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(b)}const m=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Ut(y.BATCH_ID,t,undefined.offset,m);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:i,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}v(){return null}}const{Ajax:Xt,GLTFLoader:Ht}=a();class Jt{constructor(t,e,n,r){this.o=t,this.i=e||Ht,this.u=n,this.h=Rt(),this.M=r}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Xt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){return this.T(t,e,n,r,a).then((({gltf:a,transferables:o})=>{const i=this.A(e,n,r,t);if(i.error)return Promise.resolve(i);for(let t=0;t<o.length;t++)-1===i.transferables.indexOf(o[t])&&i.transferables.push(o[t]);return delete a.transferables,Promise.resolve({magic:"i3dm",count:i.count,transferables:i.transferables,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,i3dm:i.i3dm,gltf:a})}))}T(t,e,n,r,a){const o=a&&a.maxTextureSize,i={transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o},s=new DataView(e,n,r),c=32+s.getUint32(12,!0)+s.getUint32(16,!0)+s.getUint32(20,!0)+s.getUint32(24,!0);if(0===s.getUint32(28,!0)){let r=mt(new Uint8Array(e,c+n,s.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Xt.getArrayBuffer(r,{}).then((t=>this.k(r,{buffer:t.data,byteOffset:0},i))):Xt.getJSON(r,{}).then((t=>this.k(r,t,i)))}{const r={buffer:e,byteOffset:c+n,byteLength:s.byteLength-c};return this.k(t,r,i)}}k(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),a=new this.i(r,e,n);return a.load({skipAttributeTransform:!0}).then((n=>{let r=0,o=0;return e.buffer&&(r=e.byteOffset||0,o=e.byteLength||0),n.url=\`${M}t}-${M}r}-${M}o}\`,{transferables:a.transferables,gltf:n}}))}A(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,32+e,i),f={},h=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,n=s.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=s.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._(new Uint16Array(t,r+c.offset,3*h),e,n)},i.push(f.POSITION.array.buffer)}if(s.BATCH_ID){f.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},i.push(f.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:s,i3dm:f,transferables:i}}O(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let a=0;a<e;a++)Yt(r,t[2*a],t[2*a+1],65535),n[3*a]=r[0],n[3*a+1]=r[1],n[3*a+2]=r[2];return n}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function Yt(t,e,n,r){if(t[0]=Kt(e,r),t[1]=Kt(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Qt(e),t[1]=(1-Math.abs(e))*Qt(t[1])}return b(t,t)}function Kt(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Qt(t){return t<0?-1:1}const{Ajax:Zt}=a();class Wt{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.m(t,e,n,r)):Zt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r){return this.S(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}S(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,e+28,i),f=s.QUANTIZED_VOLUME_OFFSET,h=s.QUANTIZED_VOLUME_SCALE,y=s.POINTS_LENGTH;let d,b={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){b=s.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.F||(this.F=Rt().draco),this.F(d,e).then((e=>{const n=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=s.POSITION,n.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=s.RGB,n.RGBA=s.RGBA,n.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=s.NORMAL,n.NORMAL_OCT16P=s.NORMAL_OCT16P);const r=this.I(t,e.attributes,c.offset,y,i,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Lt(t.constructor),array:t},i.push(t.buffer)}else if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?r.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):r.BATCH_ID=te(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return{count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:r,transferables:i}}))}const m=this.I(t,s,c.offset,y,i,f,h);if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?m.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):m.BATCH_ID=te(y);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:m,transferables:i})}I(t,e,n,r,a,o,i){const s={};if(e.POSITION){let{byteOffset:o,array:i}=e.POSITION;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this._(u||new Uint16Array(t,c+l,3*r),o,i)},a.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:o,array:i}=e.RGBA;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+4*r);i=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB){let{byteOffset:o,array:i}=e.RGB;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r);i=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB565){let{byteOffset:o,array:i}=e.RGB565;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:i},a.push(i.buffer)}if(e.NORMAL){let{byteOffset:o,array:i}=e.NORMAL;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:o,array:i}=e.NORMAL_OCT16P;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:i},a.push(i.buffer)}return s}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function te(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Lt(e),array:r}}const{Ajax:ee,GLTFLoader:ne}=a();class re{constructor(t,e,n,r){this.u=n,this.o=t,this.i=e||ne,this.M=r}load(t,e,n=0,r=0,a){return e?this.m(t,e,n,r,a):ee.getArrayBuffer(t,{}).then((e=>{const a=e.data;return this.m(t,a,n,r)}))}m(t,e,n,r,a){r||(r=e.byteLength);const o=this.C(e,t,n,r),i=[];for(let n=0;n<o.length;n++){let r;if("b3dm"===o[n].magic)r=new $t(this.o,this.i,this.u);else if("i3dm"===o[n].magic)r=new Jt(this.o,this.i,this.u,this.M);else if("pnts"===o[n].magic)r=new Wt;else{if("cmpt"!==o[n].magic){console.warn("Unsupported magic in CMPT tile:",o[n].magic);continue}r=new re(this.o,this.i,this.u,this.M)}i.push(r.load(t,e,o[n].offset,o[n].byteLength,a).then((t=>t)))}return Promise.all(i).then((t=>({magic:"cmpt",tiles:t})))}C(t,e,n,r){const a=new DataView(t,n,r),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported cmpt version: "+o+", url:"+e;return console.warn(t),{error:t}}if(16===a.byteLength)return[];const i=[],s=a.getUint32(12,!0);let c=16;for(let e=0;e<s;e++){const e=St(a,c),r=a.getUint32(c+8,!0);i.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return i}}const{GLTFLoader:ae}=a();function oe(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,a=r.length;n<a;n++){const a=[];he(r[n],a,t,e)}}}const ie=[],se=[],ce=[],ue=[0,0,0],le=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),fe=[1,1,1];function he(t,e,n,r){const a=e.slice(0);if(t.matrix)a.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(ie,t.translation||ue),n=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,s=r+r,c=a+a,u=n*i,l=r*i,f=r*s,h=a*i,y=a*s,d=a*c,b=o*i,m=o*s,p=o*c;return t[0]=1-f-d,t[1]=l+p,t[2]=h-m,t[3]=0,t[4]=l-p,t[5]=1-u-d,t[6]=y+b,t[7]=0,t[8]=h+m,t[9]=y-b,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(se,t.rotation||le),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ce,t.scale||fe);s(r,n,r);const o=s([],e,r);a.push(o)}if(t.children&&t.children.length)for(let e=0,o=t.children.length;e<o;e++)he(t.children[e],a,n,r);if(void 0!==t.mesh){const e=t.mesh,o=n.meshes[e];if(o){const t=a.slice(0),i=o.primitives;for(let a=0,o=i.length;a<o;a++){const o=i[a];o&&(o.matrices=t,r(o,e,a,n))}}}}function ye(t,e){let{byteOffset:n,byteStride:r,count:a}=t;const{componentType:o,itemSize:i}=t,s=t.array.buffer,c=o?ae.getTypedArrayCtor(o):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,a=a||t.array.length/i,(!r||r===i*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(s,n,a*i);for(let r=0;r<a*i;r+=i){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,i),r/i)}return}const u=new Uint8Array(i*c.BYTES_PER_ELEMENT);r||(r=i*c.BYTES_PER_ELEMENT);for(let t=0;t<a;t++){const a=new Uint8Array(s,r*t+n,i*c.BYTES_PER_ELEMENT);u.set(a);e(new c(u.buffer),t),a.set(u)}}var de=ge("DXT1"),be=ge("DXT3"),me=ge("DXT5"),pe=ge("DX10");function ge(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var ve=A((function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var a=r[21];switch(a){case de:e=8,n="dxt1";break;case be:e=16,n="dxt3";break;case me:e=16,n="dxt5";break;case 116:n="rgba32f";break;case pe:var o=new Uint32Array(t.slice(128,148));n=o[0];var i=o[1];if(o[2],o[3],o[4],3!==i||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=a,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],y=r[3],d=r[1]+4,b=h,m=y,p=[];a===pe&&(d+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=b,y=m;for(var v=Math.log(h)/Math.log(2)+1,w=0;w<v;w++)f=h*y*16,p.push({offset:d,length:f,shape:[h,y]}),w<u&&(d+=f),h=Math.floor(h/2),y=Math.floor(y/2)}else for(w=0;w<u;w++)f=Math.max(4,h)/4*Math.max(4,y)/4*e,p.push({offset:d,length:f,shape:[h,y]}),d+=f,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[b,m],images:p,format:n,flags:c,cubemap:l}})),we=Math.abs,Me=Math.sin,Te=Math.cos,Ae=Math.tan,ke=Math.atan,_e=Math.atan2,Oe=Math.sqrt,Se=Math.log,xe=Math.hypot,Fe=Math.sinh,Ie=Math.cosh,Ce=1/0;function Ee(t){var e,n,r,a,o,i,s=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*Te(2*e),a=t.length-1,o=t[a],i=0;--a>=0;)n=r*o-i+t[a],i=o,o=n;return e+n*Me(2*e)}function h(t,e,n){for(var r,a,o=Me(e),i=Te(e),s=Fe(n),c=Ie(n),u=2*i*c,l=-2*o*s,f=t.length-1,h=t[f],y=0,d=0,b=0;--f>=0;)r=d,a=y,h=u*(d=h)-r-l*(y=b)+t[f],b=l*d-a+u*y;return[(u=o*c)*h-(l=i*s)*b,u*b+l*h]}t.es,o=a=(r=t.es/(1+Oe(1-t.es)))/(2-r),s[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),o*=a,s[1]=o*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=o*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),o*=a,s[2]=o*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=o*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),o*=a,s[3]=o*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=o*(1237/630+a*(a*(-24832/14175)-2.4)),o*=a,s[4]=o*(4174/315+a*(-144838/6237)),c[4]=o*(-734/315+a*(109598/31185)),o*=a,s[5]=o*(601676/22275),c[5]=o*(444337/155925),o=a*a,e=t.k0/(1+a)*(1+o*(1/4+o*(1/64+o/256))),u[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),l[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),u[1]=o*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),l[1]=o*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),o*=a,u[2]=o*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),l[2]=o*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),o*=a,u[3]=o*(-4397/161280+a*(11/504+a*(830251/7257600))),l[3]=o*(49561/161280+a*(-179/168+a*(6601661/7257600))),o*=a,u[4]=o*(-4583/161280+a*(108847/3991680)),l[4]=o*(34729/80640+a*(-3418889/1995840)),o*=a,u[5]=o*(-20648693/638668800),l[5]=.6650675310896665*o,i=f(c,t.phi0),n=-e*(i+function(t,e){var n,r=2*Te(e),a=t.length-1,o=t[a],i=0;for(;--a>=0;)n=r*o-i+t[a],i=o,o=n;return Me(e)*n}(l,2*i)),t.fwd=function(t,r){var a,o,i,s,u,y=t.phi,d=t.lam;y=f(c,y),a=Me(y),o=Te(y),s=Me(d),i=Te(d),y=_e(a,i*o),d=_e(s*o,xe(a,o*i)),d=function(t){var e=we(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*Se(e)/n}(e*(1+e/(xe(1,e)+1))),t<0?-e:e}(Ae(d)),u=h(l,2*y,2*d),y+=u[0],d+=u[1],we(d)<=2.623395162778?(r.y=e*y+n,r.x=e*d):r.x=r.y=Ce},t.inv=function(t,r){var a,o,i,c,l,y=t.y,d=t.x;y=(y-n)/e,we(d/=e)<=2.623395162778?(y+=(l=h(u,2*y,2*d))[0],d+=l[1],d=ke(Fe(d)),a=Me(y),o=Te(y),c=Me(d),i=Te(d),d=_e(c,i*o),y=_e(a*i,xe(c,i*o)),r.phi=f(s,y),r.lam=d):r.phi=r.lam=Ce}}const Ue=Math.PI/180,Ne=6378137*Math.PI/180,ze=85.0511287798,Le={};function je(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=ze,r=e[0],a=Math.max(Math.min(n,e[1]),-n);let o;o=0===a?0:Math.log(Math.tan((90+a)*Ue/2))/Ue;return t[0]=r*Ne,t[1]=o*Ne,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return De(t,e);if("baidu"===n)return De(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const a=JSON.stringify(n);let o=Le[a];return o||(o=Le[a]=function(t){const e={a:Be,es:qe,x0:ht(t.falseEasting)?5e5:t.falseEasting,y0:ht(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Pe,phi0:(t.latitudeOfOrigin||0)*Pe,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Ee(e);const n={lam:0,phi:0},r={};let a=0,o=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Pe-e.lam0,n.phi=e.originPhi0*Pe,e.fwd(n,r),a=e.a*r.x+e.x0,o=e.a*r.y+e.y0);return{project:function(t,i){n.lam=t[0]*Pe-e.lam0,n.phi=t[1]*Pe,e.fwd(n,r);const s=e.a*r.x+e.x0-a,c=e.a*r.y+e.y0-o;return i[0]=s,i[1]=c,i}}}(n)),o.project(e,t)}}function De(t,e){return t[0]=e[0],t[1]=e[1],t}const Pe=.017453292519943295,Be=6378137,qe=.0066943799901413165;const{Ajax:Re}=a(),Ve=i([]),Ge=Rt().draco,$e=Rt().ktx2,Xe={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},He={"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 Je(t,e,n,r,a,o){const s=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],a=Re.getArrayBuffer(n.url,o);a.xhr.url=n.url,u.push(a.xhr);const i=a.then((t=>({buffer:t})));s.push(i);const l=[];if(nn(r,l),l.length){const t=l.map((t=>{const e=Re.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));s.push(...t)}c[e]=l.length}const l=Promise.all(s).then((o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const s=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];s.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),u+=1+e}const l=function(t,e,n,r,a,o){const s={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const y=e[u].geoBuffer.data;if(!y)continue;h=un(y)?Ke(s,u,f,y,t.transform,t.center,a,o):Ze(s,u,f,y,t.transform,t.center,a,o),c.push(h),s.nodes[u]={mesh:u,nodeIndex:u,matrix:i([])},s.scenes[0].nodes[u]=s.nodes[u],l||(l=Xe);const d=tn(u,s,l,e[u].textureBuffers,n,r);c.push(d)}return Promise.all(c).then((()=>({gltf:s,featureTable:{BATCH_LENGTH:0},transferables:s.transferables})))}(t,s,e,a,n,r);return l}));return l.xhr=u,l}const Ye={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Ke(t,e,n,r,a,o,i,s){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=He[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ge(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>We(n,t,e,a,o,i,s)))}const Qe={position:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.position={array:a,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.normal={array:a,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,a=new Float32Array(e,n,r);return t.uv0={array:a,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,a=new Uint8Array(e,n,r);return t.color={array:a,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,a=new Uint32Array(e,n,r);return t.faceRange={array:a,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Ze(t,e,n,r,a,o,i,s){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Qe[n[e]]?t=Qe[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let a=e.ordering,o=e.featureAttributeOrder;const i=null;i&&i.geometryData&&i.geometryData[0]&&i.geometryData[0].params;for(let e=0;e<a.length;e++){const n=Qe[a[e]];n||console.log(a[e]),t=n(c,r,t)}for(let e=0;e<o.length;e++){const n=Qe[o[e]];n||console.log(o[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=He[t]&&He[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,a=t[e],o=t[e+1];for(let t=a;t<=o;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:Bt(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return We({attributes:l},t,e,a,o,i,s)}function We(t,e,n,r,a,o,i){const s={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,a){let o,i=[0,0,0,1];const s=[0,0],u=je([],n,r,a);u[2]=n[2];const l=e&&c(Ve,e);return ye(t,(t=>(i[0]=t[0],i[1]=t[1],i[2]=t[2],l||(i=p(i,i,e)),n&&d(i,i,n),je(s,i,r,a),o=i[2],t[0]=s[0]-u[0],t[1]=s[1]-u[1],t[2]=o-u[2],t))),u}(t.attributes.POSITION,r,a,o,i);e.meshes[n]={primitives:[s],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:a};for(const n in t.attributes)cn(e.transferables,t.attributes[n].array.buffer);return t.indices&&cn(e.transferables,t.indices.array.buffer),s}function tn(t,e,n,r,a,o){const i=r.map((t=>function(t,e,n,r,a){if("dds"===e){const e=ve(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),a="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Ye,format:a})}if("png"===e||"jpg"===e)return function(t,e){rn||(rn=new OffscreenCanvas(2,2),an=rn.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;on(n)||(n=sn(n)),on(r)||(r=sn(r));const a=e;a&&(n=Math.min(a,n),r=Math.min(a,r)),rn.width=n,rn.height=r,an.drawImage(t,0,0,n,r),t.close();const o=an.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(o.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,a).then((t=>{t.mimeType=n;return{image:t,sampler:Ye,format:6408}}));if("ktx2"===e)return $e(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Ye,format:t.format})));return null}(t.data,t.format,t.mimeType,a,o).then((t=>{if(t.image)if(t.image.array)cn(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cn(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(i).then((r=>{en(t,e,n,r)}))}function en(t,e,n,r){const a=JSON.parse(JSON.stringify(n)),o=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(o.push(r[r.ptr++]),a[t]={index:o.length-1},void 0!==n[t].factor&&(a[t].scale=n[t].factor)):yt(n[t])&&(a[t]=en(-1,e,n[t],r));return t>=0&&(e.materials[t]=a),a}function nn(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):yt(t[n])&&nn(t[n],e)}let rn,an;function on(t){return!(t&t-1)&&0!==t}function sn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cn(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function un(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}var ln="undefined"!=typeof Float32Array?Float32Array:Array;function fn(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hn=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new ln(3);return ln!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const yn=[];const dn=[],bn=[],mn=[],pn=[],gn=[],vn=[],wn=[];function Mn(t,e,n,r,a,o){fn(pn,t[3*e],t[3*e+1],t[3*e+2]),fn(gn,t[3*n],t[3*n+1],t[3*n+2]),fn(vn,t[3*r],t[3*r+1],t[3*r+2]);const i=hn(dn,vn,gn),s=hn(bn,pn,gn),c=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],s=n[1],c=n[2];return t[0]=a*c-o*s,t[1]=o*i-r*c,t[2]=r*s-a*i,t}(mn,i,s);!function(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o)}(wn,c),a[3*e]=a[3*e]||0,a[3*n]=a[3*n]||0,a[3*r]=a[3*r]||0,a[3*e+1]=a[3*e+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*e+2]=a[3*e+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*e]+=wn[0],a[3*n]+=wn[0],a[3*r]+=wn[0],a[3*e+1]+=wn[1],a[3*n+1]+=wn[1],a[3*r+1]+=wn[1],a[3*e+2]+=wn[2],a[3*n+2]+=wn[2],a[3*r+2]+=wn[2],o[e]+=1,o[n]+=1,o[r]+=1}const{Ajax:Tn,GLTFLoader:An}=a(),kn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],_n=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],On=2*Math.PI*6378137/360,Sn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let xn,Fn,In=!1;if("undefined"!=typeof OffscreenCanvas){try{Fn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Fn&&"undefined"!=typeof createImageBitmap&&(In=!0)}const Cn=i([]),En=[0,0,0],Un=[],Nn=[],zn=[],Ln=[],jn={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Dn={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Pn;class Bn{constructor(t,e,n,r){this.id=t,this.options=e,this.U=(...t)=>this.requestImage.call(this,...t),this.N=n,this.L={},r(null,{},[])}j(t){this.D||(this.u=t,this.P=new Wt,this.D=new $t(this.U,An,t),this.B=new Jt(this.U,An,t))}requestImage(t,e){In?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{xn.width=t.width,xn.height=t.height,Fn.drawImage(t,0,0);const n=Fn.getImageData(0,0,xn.width,xn.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.N("requestImage",{url:t},null,e)}loadTile(t,e){this.j(t.supportedFormats);const{service:n,url:r,arraybuffer:a}=t,o=n.fetchOptions||{};if(o.referrer=t.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const a=t.i3sInfo,i=n.maxTextureSize||0,s=Je(a,t.supportedFormats,this.options.projection,t.projection,i,o);return s.then((t=>{if(delete this.L[r],!t)return void e({status:404,url:r,i3sInfo:a});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:a});t.gltf.url=r;const{transferables:o}=t;t.magic="b3dm",n.createNormalIfMissed&&this.q(t.gltf),Yn(n)&&this.R(t.gltf),e(null,t,o)})),void(this.L[r]=s.xhr)}if(a){delete this.L[r];const n=St(new DataView(a),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Sn){const r=new Uint8Array(t,e,n);return Sn.decode(r)}return mt(new Uint8Array(t,e,n))}(a,0,a.byteLength),o=JSON.parse(n);o.accessors?this.V(o,r,t,"gltf",e):this.G(t.rootIdx,o,a,r,e)}else this.V(a,r,t,n,e)}else{let a=n.urlParams;a&&(a=(r.indexOf("?")>0?"&":"?")+a);const i=r.replace(/\\+/g,"%2B");let s=Tn.getArrayBuffer(i+(a||""),o);const c=s.xhr;s=s.then((n=>{delete this.L[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.L[r],e(t)})),this.L[r]=c}}V(t,e,n,r,a){r=r&&r.toLowerCase();const{service:o}=n;if("b3dm"===r){this.D.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{if(t.error)return void a(t);const{content:e,transferables:r}=this.$(t,n);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,r)})).catch((t=>{a(t)}))}else if("pnts"===r){const r=n.transform||Cn;this.P.load(e,t).then((t=>{const{content:e,transferables:o}=this.X(t,r,n.rootIdx);this.H(e),a(null,e,o)}))}else if("i3dm"===r){const r=n.transform||Cn;this.B.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:i}=this.J(t,r,n.rootIdx);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,i)}))}else if("cmpt"===r){new re(this.U,An,this.u,o.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Y(t,n);this.K(e,o),Yn(o)&&this.Z(e),a(null,e,r)})).catch((t=>{a(t)}))}else if("gltf"===r){this.h||(this.h=Rt());const r=e.substring(0,e.lastIndexOf("/")),i=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let s;try{s=new An(r,i,{transferable:!0,requestImage:this.U,decoders:this.h,supportedFormats:this.u,maxTextureSize:o.maxTextureSize||0})}catch(t){a(t)}s.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.W(t,null,n),o.createNormalIfMissed&&this.q(t),Yn(o)&&this.R(t),a(null,{magic:"gltf",gltf:t},s.transferables)}))}else a(new Error("unsupported tile format: "+r))}K(t,e){t.content?t.content.forEach((t=>{this.K(t,e)})):e.createNormalIfMissed&&this.q(t.gltf)}Z(t){t.content?t.content.forEach((t=>{this.Z(t)})):this.R(t.gltf)}tt(t,e){if(this.et(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.nt()?Pn.subarray(0,n):e,a=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const a=yn;a.length<t.length/3&&(a.length=t.length/3),a.fill(0,0,t.length/3);const o=void 0===e.length?e:e.length;for(let n=0;n<o/3;n++)void 0===e.length?Mn(t,3*n,3*n+1,3*n+2,r,a):Mn(t,e[3*n],e[3*n+1],e[3*n+2],r,a);for(let t=0;t<r.length;t+=3){const e=a[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}R(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const a=Xn(e[n].array,r,e[n].min,e[n].max,n);if(!a)continue;const{array:o,range:i}=a;e[n].componentType=5124,e[n].array=o,t.compressed_int16_params[n]=i}}))}}q(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.tt(e,t)}))}}H(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const{array:a,range:o}=Xn(e[n].array,r,e[n].min,e[n].max,n);e[n].array=a,t.compressed_int16_params[n]=o}}rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const a={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(a)}return e}G(t,e,n,r,a){return e.capabilities,void a(null,e)}Y(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},a=[];for(let t=0;t<n.length;t++){const{magic:o}=n[t];if("b3dm"===o){const{content:o,transferables:i}=this.$(n[t],e);Gn(a,i),r.content.push(o)}else if("i3dm"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.J(n[t],o,i);Gn(a,c),r.content.push(s)}else if("pnts"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.X(n[t],o,i);Gn(a,c),r.content.push(s)}else if("cmpt"===o){const{content:o,transferables:i}=this.Y(n[t],e);Gn(a,i),r.content.push(o)}}return{content:r,transferables:a}}$(t,e){const{gltf:n,transferables:r,featureTable:a}=t;return this.W(n,a,e),delete t.transferables,{content:t,transferables:r}}W(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;if(t.extensions&&t.extensions.KHR_techniques_webgl)return!0;const e="visited";let n=1;const r=[];for(const a in t.meshes){const o=t.meshes[a],{primitives:i}=o;if(i)for(let t=0;t<i.length;t++){const a=i[t].attributes&&i[t].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[e]||(a.array.buffer[e]=n++);const o=n-1+"-"+(a.byteOffset||0);if(r.indexOf(o)>=0)return!0;r.push(o)}}return!1}(t);this.ot(t);n.service.createNormalIfMissed||this.it(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.st(t,e,n.upAxis,n.transform)):this.ct(t,e,n.upAxis,n.transform)}J(t,e,n){const{featureTable:r}=t,a=t.i3dm,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,Cn,u);const l=Vn(u);e&&!s&&p(l,l,e);const f=this.ut(l),d=[];je(d,f,i),d[2]=f[2];const b=h([],l),m=[0,0,0],g=[0,0,0],v=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];ye(a.POSITION,(t=>{m[0]=t[0]+o[0],m[1]=t[1]+o[1],m[2]=t[2]+o[2],e&&!s&&p(m,m,e),0===w(m)?y(g,0,0,-6378137):Tt(g,m),je(v,g,i),t[0]=v[0]-d[0],t[1]=v[1]-d[1],t[2]=g[2]-d[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),a.POSITION.min=M,a.POSITION.max=T,e&&p(l,l,e),t.rtcCenter=b,t.rtcCoord=f,t.projCenter=d,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}X(t,e,n){const{featureTable:r}=t,a=t.pnts,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,e,u);const l=Vn(u),f=this.lt(l),d=h([],l),b=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];let g=[0,0,0,1];const v=[0,0,0],M=[0,0];ye(a.POSITION,(t=>(g[0]=t[0]+o[0],g[1]=t[1]+o[1],g[2]=t[2]+o[2],e&&!s&&(g=p(g,g,e)),0===w(g)?y(v,0,0,-6378137):Tt(v,g),je(M,v,i),t[0]=M[0]-f[0],t[1]=M[1]-f[1],t[2]=v[2]-f[2],t[0]<b[0]&&(b[0]=t[0]),t[1]<b[1]&&(b[1]=t[1]),t[2]<b[2]&&(b[2]=t[2]),t[0]>m[0]&&(m[0]=t[0]),t[1]>m[1]&&(m[1]=t[1]),t[2]>m[2]&&(m[2]=t[2]),t))),a.POSITION.min=b,a.POSITION.max=m,e&&p(l,l,e);const T=this.ut(l);t.rtcCenter=d,t.projCenter=f,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}ot(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],a=n[1],o=n[2],i=n[3];let s=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==a||n[t+2]!==o||n[t+3]!==i){s=!1;break}s&&(e[t].image.color=[r/255,a/255,o/255,i/255],delete e[t].image.array)}}}it(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const a=r.primitives;if(a)for(let e=0;e<a.length;e++){if(!a[e])continue;if(!a[e].attributes||a[e].attributes.NORMAL)continue;const n=a[e].material;if(!ht(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}abortTileLoading(t,e){const n=this.L[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.L[t.url],e(null)}ft(t,e,n,r){const a=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let o=kn;"X"===(n=n&&n.toUpperCase())?o=_n:"Z"===n&&(o=Cn),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),a&&(t.extensions.CESIUM_RTC.center=a),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};oe(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=i(Un);t.matrices&&$n(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,o,e),r&&s(e,r,e),Rn(n,u,a||En,e,c,t.compressUniforms)}));const u=Vn(c);return{rtcCenter:a,modelCenter:u,upAxisTransform:o}}st(t,e,n,r){const{modelCenter:a,upAxisTransform:o,rtcCenter:c}=this.ft(t,e,n),u=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a);const l=h([],a);r&&p(a,a,r),t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),c||(oe(t,(t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const n=i(Un);t.matrices&&$n(n,t.matrices),s(n,o,n);const r=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],y=e[11],d=e[12],b=e[13],m=e[14],p=e[15],g=n*s-r*i,v=n*c-a*i,w=n*u-o*i,M=r*c-a*s,T=r*u-o*s,A=a*u-o*c,k=l*b-f*d,_=l*m-h*d,O=l*p-y*d,S=f*m-h*b,x=f*p-y*b,F=h*p-y*m,I=g*F-v*x+w*S+M*O-T*_+A*k;return I?(I=1/I,t[0]=(s*F-c*x+u*S)*I,t[1]=(a*x-r*F-o*S)*I,t[2]=(b*A-m*T+p*M)*I,t[3]=(h*T-f*A-y*M)*I,t[4]=(c*O-i*F-u*_)*I,t[5]=(n*F-a*O+o*_)*I,t[6]=(m*w-d*A-p*v)*I,t[7]=(l*A-h*w+y*v)*I,t[8]=(i*x-s*O+u*k)*I,t[9]=(r*O-n*x-o*k)*I,t[10]=(d*T-b*w+p*g)*I,t[11]=(f*w-l*T-y*g)*I,t[12]=(s*_-i*S-c*k)*I,t[13]=(n*S-r*_+a*k)*I,t[14]=(b*v-d*M-m*g)*I,t[15]=(l*M-f*v+h*g)*I,t):null}(Nn,n),a=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ye(e,(t=>{p(t,t,n),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],p(t,t,r),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]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=a,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}ct(t,e,n,r){const{modelCenter:a,rtcCenter:o}=this.ft(t,e,n,r),i=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=i,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),oe(t,(e=>{if(e.attributes&&e.attributes.POSITION){const a=this.et(e,t);if(a){const t=e.attributes.POSITION.array.length;(!Pn||Pn.length<t)&&(Pn=new Float32Array(t))}e.attributes.NORMAL&&this.ht(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.ht(e.attributes.TANGENT,e.matrices,n);const{newPositions:i}=this.yt(e.attributes.POSITION,e.matrices,o,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,a),{componentType:s}=e.attributes.POSITION;5126!==s&&(e.attributes.POSITION.array=new Float32Array(i))}}));for(const e in t.nodes){t.nodes[e].matrix=Cn}}lt(t){const e=this.options.projection;"identity"===e?h(zn,t):0===w(t)?y(zn,0,0,-6378137):Tt(zn,t),je(Ln,zn,e);const n=zn[2],r=[];return r[0]=Ln[0],r[1]=Ln[1],r[2]=n,r}ht(t,e,n){let r;r="Y"===n?kn:"X"===n?_n:Cn;const a=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],r);if($n(a,e),c(a,Cn))return;const o=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}([],a),i=[];ye(t,(t=>(function(t,e,n){var r=e[0],a=e[1],o=e[2];t[0]=r*n[0]+a*n[3]+o*n[6],t[1]=r*n[1]+a*n[4]+o*n[7],t[2]=r*n[2]+a*n[5]+o*n[8]}(i,t,o),b(i,i),h(t,i),i)))}yt(t,e,n,r,a,o,s,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=i([]);$n(l,e);const f=this.options.projection;a=a&&a.toUpperCase();const h=n;let b=null;"Y"===a?b=kn:"X"===a&&(b=_n);let m=[0,0,0,1];const g=[0,0,0],v=[0,0],M=r.projCenter,T=je([],r.rtcCoord,"EPSG:3857"),A=o&&c(Cn,o),k=t.min=t.min||[],_=t.max=t.max||[];y(k,1/0,1/0,1/0),y(_,-1/0,-1/0,-1/0);const O=s||{},{decode_position_min:S,decode_position_normConstant:x}=O;let F=[0,0,0,0],I=1;S&&(F=S),x&&(I=x);const C=[];return ye(t,((e,n)=>{if(m[0]=e[0]*I+F[0],m[1]=e[1]*I+F[1],m[2]=e[2]*I+F[2],m=p(m,m,l),b&&(m=p(m,m,b)),h&&d(m,m,h),o&&!A&&(m=p(m,m,o)),0===w(m)?y(g,0,0,-6378137):Tt(g,m),u){const t=Pn;je(v,g,f),t[3*n]=v[0]-T[0],t[3*n+1]=v[0]-T[1],t[3*n+2]=v[0]-T[2]}if(je(v,g,f),e instanceof Float32Array)e[0]=v[0]-M[0],e[1]=v[1]-M[1],e[2]=g[2]-M[2];else{const n=v[0]-M[0],r=v[1]-M[1],a=g[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(a),C.push(e[3]))}return e[0]<k[0]&&(k[0]=e[0]),e[1]<k[1]&&(k[1]=e[1]),e[2]<k[2]&&(k[2]=e[2]),e[0]>_[0]&&(_[0]=e[0]),e[1]>_[1]&&(_[1]=e[1]),e[2]>_[2]&&(_[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}ut(t){return 0===w(t)?y([],0,0,-6378137):Tt([],t)}onRemove(){}nt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}et(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;return!t.attributes.TANGENT}}const qn=[];function Rn(t,e,n,r,a,o){const i=o||{},{decode_position_min:s,decode_position_normConstant:c}=i;let u=[0,0,0,0],l=1;s&&(u=s),c&&(l=c);for(let o=0,i=t.length;o<i;o+=e){const{xmin:i,ymin:s,xmax:c,ymax:f,hmin:h,hmax:b}=a;y(qn,t[o]*l+u[0],t[o+1]*l+u[1],t[o+2]*l+u[2]),p(qn,qn,r);const m=d(qn,n,qn);m[0]<i&&(a.xmin=m[0]),m[0]>c&&(a.xmax=m[0]),m[1]<s&&(a.ymin=m[1]),m[1]>f&&(a.ymax=m[1]),e>2&&(m[2]<h&&(a.hmin=m[2]),m[2]>b&&(a.hmax=m[2]))}}function Vn(t){const{xmax:e,ymax:n,xmin:r,ymin:a,hmin:o,hmax:i}=t,s=[(r+e)/2,(a+n)/2,(o+i)/2];return e===-1/0&&(s[0]=0),n===-1/0&&(s[1]=0),i===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Gn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function $n(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}function Xn(t,e,n,r,a){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let o,i;if(n&&r&&1===e)o=Math.min(...n),i=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);o=e,i=n}return!function(t,e,n,r){for(let a=0;a<t.length;a++){const o=Hn(Jn(t[a],e,n),e,n);if(Math.abs(o-t[a])>Dn[r])return!1}return!0}(t,o,i,a)&&Dn[a]?null:function(t,e,n){const r=new Int16Array(t.length);for(let a=0;a<t.length;a++)r[a]=Jn(t[a],e,n);return{array:r,range:[e,n]}}(t,o,i)}function Hn(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Jn(t,e,n){const r=2*(t-e)/(n-e)-1,a=Math.max(-1,Math.min(1,r));return a<0?32768*a:32767*a}function Yn(t){return void 0===t.compressGeometry||t.compressGeometry}let Kn=0;class Qn{constructor(t){this.workerId=t,this.workers={},this.dt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},a){if(this.bt(e,n))return;const o=this.gt(e,n),i=r.options;this.workers[o]=new Bn(n,i,((...e)=>this.send.call(this,t,...e)),a)}removeLayer({mapId:t,layerId:e},n){const r=this.bt(t,e),a=this.gt(t,e);delete this.workers[a],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.dt[e];delete this.dt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,a){const o=a?\`${M}t}-${M}Kn++}\`:null;a&&(this.dt[o]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}gt(t,e){return\`${M}t}-${M}e}\`}bt(t,e){const n=this.gt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Qn(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var x={exports:{}},I={exports:{}},S=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},C=Array.prototype.concat,k=Array.prototype.slice,N=I.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];S(s)?e=C.call(e,k.call(s)):e.push(s)}return e};N.wrap=function(t){return function(){return t(N(arguments))}};var L=I.exports,E={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R=L,P=Object.hasOwnProperty,U=Object.create(null);for(var B in E)P.call(E,B)&&(U[E[B]]=B);var G=x.exports={to:{},get:{}};function D(t,e,n){return Math.min(Math.max(e,t),n)}function F(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}G.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=G.get.hsl(t),n="hsl";break;case"hwb":e=G.get.hwb(t),n="hwb";break;default:e=G.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},G.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:P.call(E,e[1])?((s=E[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=D(s[n],0,255);return s[3]=D(s[3],0,1),s},G.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,D(parseFloat(e[2]),0,100),D(parseFloat(e[3]),0,100),D(isNaN(n)?1:n,0,1)]}return null},G.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,D(parseFloat(e[2]),0,100),D(parseFloat(e[3]),0,100),D(isNaN(n)?1:n,0,1)]}return null},G.to.hex=function(){var t=R(arguments);return"#"+F(t[0])+F(t[1])+F(t[2])+(t[3]<1?F(Math.round(255*t[3])):"")},G.to.rgb=function(){var t=R(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},G.to.rgb.percent=function(){var t=R(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},G.to.hsl=function(){var t=R(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},G.to.hwb=function(){var t=R(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},G.to.keyword=function(t){return U[t.slice(0,3)]};var j=x.exports,z={exports:{}},H={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},q={};for(var $ in H)H.hasOwnProperty($)&&(q[H[$]]=$);var V=z.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var J in V)if(V.hasOwnProperty(J)){if(!("channels"in V[J]))throw new Error("missing channels property: "+J);if(!("labels"in V[J]))throw new Error("missing channel labels property: "+J);if(V[J].labels.length!==V[J].channels)throw new Error("channel and label counts mismatch: "+J);var Y=V[J].channels,Z=V[J].labels;delete V[J].channels,delete V[J].labels,Object.defineProperty(V[J],"channels",{value:Y}),Object.defineProperty(V[J],"labels",{value:Z})}V.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},V.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,l=Math.max(o,a,c),h=l-Math.min(o,a,c),u=function(t){return(l-t)/6/h+.5};return 0===h?s=i=0:(i=h/l,e=u(o),n=u(a),r=u(c),o===l?s=r-n:a===l?s=1/3+e-r:c===l&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*l]},V.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[V.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},V.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},V.rgb.keyword=function(t){var e=q[t];if(e)return e;var n,r,s,i=1/0;for(var o in H)if(H.hasOwnProperty(o)){var a=H[o],c=(r=t,s=a,Math.pow(r[0]-s[0],2)+Math.pow(r[1]-s[1],2)+Math.pow(r[2]-s[2],2));c<i&&(i=c,n=o)}return n},V.keyword.rgb=function(t){return H[t]},V.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},V.rgb.lab=function(t){var e=V.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},V.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var l=0;l<3;l++)(r=o+1/3*-(l-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[l]=255*i;return s},V.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},V.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},V.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},V.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,l=t[1]/100,h=t[2]/100,u=l+h;switch(u>1&&(l/=u,h/=u),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),s=l+r*((n=1-h)-l),e){default:case 6:case 0:i=n,o=s,a=l;break;case 1:i=s,o=n,a=l;break;case 2:i=l,o=n,a=s;break;case 3:i=l,o=s,a=n;break;case 4:i=s,o=l,a=n;break;case 5:i=n,o=l,a=s}return[255*i,255*o,255*a]},V.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},V.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},V.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},V.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},V.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},V.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},V.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:V.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},V.hsv.ansi16=function(t){return V.rgb.ansi16(V.hsv.rgb(t),t[2])},V.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},V.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},V.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},V.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},V.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},V.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},V.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},V.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},V.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},V.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},V.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},V.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},V.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},V.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},V.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},V.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},V.gray.hsl=V.gray.hsv=function(t){return[0,0,t[0]]},V.gray.hwb=function(t){return[0,100,t[0]]},V.gray.cmyk=function(t){return[0,0,0,t[0]]},V.gray.lab=function(t){return[t[0],0,0]},V.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},V.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var K=z.exports,X=K;function W(t){var e=function(){for(var t={},e=Object.keys(X),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(X[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Q(t,e){return function(n){return e(t(n))}}function tt(t,e){for(var n=[e[t].parent,t],r=X[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=Q(X[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var et=K,nt=function(t){for(var e=W(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=tt(o,e))}return n},rt={};Object.keys(et).forEach((function(t){rt[t]={},Object.defineProperty(rt[t],"channels",{value:et[t].channels}),Object.defineProperty(rt[t],"labels",{value:et[t].labels});var e=nt(t);Object.keys(e).forEach((function(n){var r=e[n];rt[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),rt[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var st=j,it=rt,ot=[].slice,at=["keyword","gray","hex"],ct={};Object.keys(it).forEach((function(t){ct[ot.call(it[t].labels).sort().join("")]=t}));var lt={};function ht(t,e){if(!(this instanceof ht))return new ht(t,e);if(e&&e in at&&(e=null),e&&!(e in it))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ht)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=st.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=it[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=it[this.model].channels;var i=ot.call(t,0,r);this.color=dt(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ct))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ct[a];var c=it[this.model].labels,l=[];for(n=0;n<c.length;n++)l.push(t[c[n]]);this.color=dt(l)}if(lt[this.model])for(r=it[this.model].channels,n=0;n<r;n++){var h=lt[this.model][n];h&&(this.color[n]=h(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ut(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function ft(t){return function(e){return Math.max(0,Math.min(t,e))}}function dt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ht.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in st.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return st.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return st.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=it[this.model].channels,n=it[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ht(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ht(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ut("rgb",0,ft(255)),green:ut("rgb",1,ft(255)),blue:ut("rgb",2,ft(255)),hue:ut(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ut("hsl",1,ft(100)),lightness:ut("hsl",2,ft(100)),saturationv:ut("hsv",1,ft(100)),value:ut("hsv",2,ft(100)),chroma:ut("hcg",1,ft(100)),gray:ut("hcg",2,ft(100)),white:ut("hwb",1,ft(100)),wblack:ut("hwb",2,ft(100)),cyan:ut("cmyk",0,ft(100)),magenta:ut("cmyk",1,ft(100)),yellow:ut("cmyk",2,ft(100)),black:ut("cmyk",3,ft(100)),x:ut("xyz",0,ft(100)),y:ut("xyz",1,ft(100)),z:ut("xyz",2,ft(100)),l:ut("lab",0,ft(100)),a:ut("lab",1),b:ut("lab",2),keyword:function(t){return arguments.length?new ht(t):it[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ht(t):st.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ht.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return ht.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(it).forEach((function(t){if(-1===at.indexOf(t)){var e=it[t].channels;ht.prototype[t]=function(){if(this.model===t)return new ht(this);if(arguments.length)return new ht(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ht((n=it[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ht[t]=function(n){return"number"==typeof n&&(n=dt(ot.call(arguments),e)),new ht(n,t)}}}));var mt=A(ht);function pt(t){return null==t}function yt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function bt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function gt(t){return"object"==typeof t&&!!t}function wt(t){return"number"==typeof t&&!isNaN(t)}function vt(t){return t*Math.PI/180}function Tt(t){return t/Math.PI*180}function _t(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function Mt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const Ot=[1,1,1,1,2,2,3,0];function At(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=Ot[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}function xt(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function It(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function St(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function kt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),s=r.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=r.charCodeAt(t);return i.buffer}function Nt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const Lt={};function Et(t,e){if(!Array.isArray(e)){const t=e;e=Lt[t]=Lt[t]||mt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Rt=Object.freeze({__proto__:null,base64URLToArrayBuffer:kt,extend:yt,flatArr:It,getAbsoluteURL:_t,getBatchIdArrayType:St,isBase64:Ct,isFunction:bt,isNil:pt,isNumber:wt,isObject:gt,normalizeColor:Et,pushIn:Nt,setColumn3:xt,sign:Mt,stringFromUTF8Array:At,toDegree:Tt,toRadian:vt});function Pt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Bt=function(){if("undefined"!=typeof globalThis)return globalThis;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")},Gt=Bt(),Dt=Gt.gl_trans__coders=Gt.gl_trans__coders||{};
6
+ import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,HighlightUtil as s,ContextUtil as i,quat as o,vec3 as a,mat3 as c,getWGSLSource as l,vec4 as h,MaskRendererMixin as u,CanvasCompatible as f,MaskLayerMixin as d,ClipOutsideMask as m,vec2 as p}from"@maptalks/gl";import{intersectsBox as y,intersectsOrientedBox as b,intersectsSphere as g}from"frustum-intersects";import{quat as w,mat4 as v,vec3 as T,mat3 as _}from"gl-matrix";const M="${",O=`function(t){\n/*!\n * @maptalks/gl v0.124.2\n * LICENSE : UNLICENSED\n * (c) 2016-2026 maptalks.com\n */\nconst e=function(){if("undefined"!=typeof undefinedThis)return globalThis;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")},n=e(),r=n.gl_trans__coders=n.gl_trans__coders||{};function a(){return e().maptalks_gltf_loader}r.inject=function(t){const r=t.toString(),a=r.indexOf("{")+1,o=r.substring(0,a),i=n.gl_trans__coders=n.gl_trans__coders||{};let s=\`${M}o}\\n const _____getGlobal = ${M}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 i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\\n;");return s+="\\n("+e().maptalks_gltf_loader_bundle.toString()+")({});\\n",s+="\\n"+r.substring(o.length),s},r.registerTranscoder=function(t,e){r[t]=e},r.getTranscoder=function(t){return r[t]};var o="undefined"!=typeof Float32Array?Float32Array:Array;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 s(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],s=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],y=e[10],d=e[11],b=e[12],m=e[13],p=e[14],g=e[15],v=n[0],w=n[1],M=n[2],T=n[3];return t[0]=v*r+w*s+M*f+T*b,t[1]=v*a+w*c+M*h+T*m,t[2]=v*o+w*u+M*y+T*p,t[3]=v*i+w*l+M*d+T*g,v=n[4],w=n[5],M=n[6],T=n[7],t[4]=v*r+w*s+M*f+T*b,t[5]=v*a+w*c+M*h+T*m,t[6]=v*o+w*u+M*y+T*p,t[7]=v*i+w*l+M*d+T*g,v=n[8],w=n[9],M=n[10],T=n[11],t[8]=v*r+w*s+M*f+T*b,t[9]=v*a+w*c+M*h+T*m,t[10]=v*o+w*u+M*y+T*p,t[11]=v*i+w*l+M*d+T*g,v=n[12],w=n[13],M=n[14],T=n[15],t[12]=v*r+w*s+M*f+T*b,t[13]=v*a+w*c+M*h+T*m,t[14]=v*o+w*u+M*y+T*p,t[15]=v*i+w*l+M*d+T*g,t}function c(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 u(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function l(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function f(t,e,n){var r=new o(3);return r[0]=t,r[1]=e,r[2]=n,r}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function y(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function d(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function b(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function m(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function p(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[3]*r+n[7]*a+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*a+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*a+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*a+n[10]*o+n[14])/i,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var g=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},v=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},w=l;function M(){var t=new o(4);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}u(),function(){var t,e=(t=new o(4),o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var T;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}u(),f(1,0,0),f(0,1,0),M(),M(),T=new o(9),o!=Float32Array&&(T[1]=0,T[2]=0,T[3]=0,T[5]=0,T[6]=0,T[7]=0),T[0]=1,T[4]=1,T[8]=1;var k={exports:{}},_={exports:{}},O=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},S=Array.prototype.concat,x=Array.prototype.slice,F=_.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var a=t[n];O(a)?e=S.call(e,x.call(a)):e.push(a)}return e};F.wrap=function(t){return function(){return t(F(arguments))}};var I=_.exports,C={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},E=I,U=Object.hasOwnProperty,N=Object.create(null);for(var z in C)U.call(C,z)&&(N[C[z]]=z);var L=k.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}L.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=L.get.hsl(t),n="hsl";break;case"hwb":e=L.get.hwb(t),n="hwb";break;default:e=L.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},L.get.rgb=function(t){if(!t)return null;var e,n,r,a=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;a[n]=parseInt(e.slice(o,o+2),16)}r&&(a[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)a[n]=parseInt(e[n]+e[n],16);r&&(a[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)a[n]=parseInt(e[n+1],0);e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:U.call(C,e[1])?((a=C[e[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}for(n=0;n<3;n++)a[n]=j(a[n],0,255);return a[3]=j(a[3],0,1),a},L.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.to.hex=function(){var t=E(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},L.to.rgb=function(){var t=E(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},L.to.rgb.percent=function(){var t=E(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},L.to.hsl=function(){var t=E(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},L.to.hwb=function(){var t=E(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},L.to.keyword=function(t){return N[t.slice(0,3)]};var P=k.exports,B={exports:{}},q={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R={};for(var V in q)q.hasOwnProperty(V)&&(R[q[V]]=V);var G=B.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $ in G)if(G.hasOwnProperty($)){if(!("channels"in G[$]))throw new Error("missing channels property: "+$);if(!("labels"in G[$]))throw new Error("missing channel labels property: "+$);if(G[$].labels.length!==G[$].channels)throw new Error("channel and label counts mismatch: "+$);var X=G[$].channels,H=G[$].labels;delete G[$].channels,delete G[$].labels,Object.defineProperty(G[$],"channels",{value:X}),Object.defineProperty(G[$],"labels",{value:H})}G.rgb.hsl=function(t){var e,n,r=t[0]/255,a=t[1]/255,o=t[2]/255,i=Math.min(r,a,o),s=Math.max(r,a,o),c=s-i;return s===i?e=0:r===s?e=(a-o)/c:a===s?e=2+(o-r)/c:o===s&&(e=4+(r-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(i+s)/2,[e,100*(s===i?0:n<=.5?c/(s+i):c/(2-s-i)),100*n]},G.rgb.hsv=function(t){var e,n,r,a,o,i=t[0]/255,s=t[1]/255,c=t[2]/255,u=Math.max(i,s,c),l=u-Math.min(i,s,c),f=function(t){return(u-t)/6/l+.5};return 0===l?a=o=0:(o=l/u,e=f(i),n=f(s),r=f(c),i===u?a=r-n:s===u?a=1/3+e-r:c===u&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*u]},G.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[G.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},G.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-a)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-a-e)/(1-e)||0),100*e]},G.rgb.keyword=function(t){var e=R[t];if(e)return e;var n,r,a,o=1/0;for(var i in q)if(q.hasOwnProperty(i)){var s=q[i],c=(r=t,a=s,Math.pow(r[0]-a[0],2)+Math.pow(r[1]-a[1],2)+Math.pow(r[2]-a[2],2));c<o&&(o=c,n=i)}return n},G.keyword.rgb=function(t){return q[t]},G.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},G.rgb.lab=function(t){var e=G.rgb.xyz(t),n=e[0],r=e[1],a=e[2];return r/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},G.hsl.rgb=function(t){var e,n,r,a,o,i=t[0]/360,s=t[1]/100,c=t[2]/100;if(0===s)return[o=255*c,o,o];e=2*c-(n=c<.5?c*(1+s):c+s-c*s),a=[0,0,0];for(var u=0;u<3;u++)(r=i+1/3*-(u-1))<0&&r++,r>1&&r--,o=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[u]=255*o;return a},G.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,a=n,o=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,a*=o<=1?o:2-o,[e,100*(0===r?2*a/(o+a):2*n/(r+n)),100*((r+n)/2)]},G.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),i=255*r*(1-n),s=255*r*(1-n*o),c=255*r*(1-n*(1-o));switch(r*=255,a){case 0:return[r,c,i];case 1:return[s,r,i];case 2:return[i,r,c];case 3:return[i,s,r];case 4:return[c,i,r];case 5:return[r,i,s]}},G.hsv.hsl=function(t){var e,n,r,a=t[0],o=t[1]/100,i=t[2]/100,s=Math.max(i,.01);return r=(2-o)*i,n=o*s,[a,100*(n=(n/=(e=(2-o)*s)<=1?e:2-e)||0),100*(r/=2)]},G.hwb.rgb=function(t){var e,n,r,a,o,i,s,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),a=u+r*((n=1-l)-u),e){default:case 6:case 0:o=n,i=a,s=u;break;case 1:o=a,i=n,s=u;break;case 2:o=u,i=n,s=a;break;case 3:o=u,i=a,s=n;break;case 4:o=a,i=u,s=n;break;case 5:o=n,i=u,s=a}return[255*o,255*i,255*s]},G.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,a=t[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},G.xyz.rgb=function(t){var e,n,r,a=t[0]/100,o=t[1]/100,i=t[2]/100;return n=-.9689*a+1.8758*o+.0415*i,r=.0557*a+-.204*o+1.057*i,e=(e=3.2406*a+-1.5372*o+-.4986*i)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},G.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},G.lab.xyz=function(t){var e,n,r,a=t[0];e=t[1]/500+(n=(a+16)/116),r=n-t[2]/200;var o=Math.pow(n,3),i=Math.pow(e,3),s=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,e=i>.008856?i:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},G.lab.lch=function(t){var e,n=t[0],r=t[1],a=t[2];return(e=360*Math.atan2(a,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+a*a),e]},G.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},G.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:G.rgb.hsv(t)[2];if(0===(a=Math.round(a/50)))return 30;var o=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(o+=60),o},G.hsv.ansi16=function(t){return G.rgb.ansi16(G.hsv.rgb(t),t[2])},G.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},G.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},G.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},G.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},G.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},G.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.max(Math.max(n,r),a),i=Math.min(Math.min(n,r),a),s=o-i;return e=s<=0?0:o===n?(r-a)/s%6:o===r?2+(a-n)/s:4+(n-r)/s+4,e/=6,[360*(e%=1),100*s,100*(s<1?i/(1-s):0)]},G.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},G.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a,o=[0,0,0],i=e%1*6,s=i%1,c=1-s;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=c,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=c,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=c}return a=(1-n)*r,[255*(n*o[0]+a),255*(n*o[1]+a),255*(n*o[2]+a)]},G.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},G.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},G.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},G.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},G.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},G.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},G.gray.hsl=G.gray.hsv=function(t){return[0,0,t[0]]},G.gray.hwb=function(t){return[0,100,t[0]]},G.gray.cmyk=function(t){return[0,0,0,t[0]]},G.gray.lab=function(t){return[t[0],0,0]},G.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},G.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var J=B.exports,Y=J;function K(t){var e=function(){for(var t={},e=Object.keys(Y),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),a=Object.keys(Y[r]),o=a.length,i=0;i<o;i++){var s=a[i],c=e[s];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(s))}return e}function Q(t,e){return function(n){return e(t(n))}}function Z(t,e){for(var n=[e[t].parent,t],r=Y[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=Q(Y[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}var W=J,tt=function(t){for(var e=K(t),n={},r=Object.keys(e),a=r.length,o=0;o<a;o++){var i=r[o];null!==e[i].parent&&(n[i]=Z(i,e))}return n},et={};Object.keys(W).forEach((function(t){et[t]={},Object.defineProperty(et[t],"channels",{value:W[t].channels}),Object.defineProperty(et[t],"labels",{value:W[t].labels});var e=tt(t);Object.keys(e).forEach((function(n){var r=e[n];et[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),et[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var nt=P,rt=et,at=[].slice,ot=["keyword","gray","hex"],it={};Object.keys(rt).forEach((function(t){it[at.call(rt[t].labels).sort().join("")]=t}));var st={};function ct(t,e){if(!(this instanceof ct))return new ct(t,e);if(e&&e in ot&&(e=null),e&&!(e in rt))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ct)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var a=nt.get(t);if(null===a)throw new Error("Unable to parse color from string: "+t);this.model=a.model,r=rt[this.model].channels,this.color=a.value.slice(0,r),this.valpha="number"==typeof a.value[r]?a.value[r]:1}else if(t.length){this.model=e||"rgb",r=rt[this.model].channels;var o=at.call(t,0,r);this.color=ft(o,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var s=i.sort().join("");if(!(s in it))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=it[s];var c=rt[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ft(u)}if(st[this.model])for(r=rt[this.model].channels,n=0;n<r;n++){var l=st[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ut(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(st[t]||(st[t]=[]))[e]=n})),t=t[0],function(r){var a;return arguments.length?(n&&(r=n(r)),(a=this[t]()).color[e]=r,a):(a=this[t]().color[e],n&&(a=n(a)),a)}}function lt(t){return function(e){return Math.max(0,Math.min(t,e))}}function ft(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function ht(t){return null==t}function yt(t){return"object"==typeof t&&!!t}function dt(t){return t/Math.PI*180}ct.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in nt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return nt.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return nt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=rt[this.model].channels,n=rt[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ct(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ct(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ut("rgb",0,lt(255)),green:ut("rgb",1,lt(255)),blue:ut("rgb",2,lt(255)),hue:ut(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ut("hsl",1,lt(100)),lightness:ut("hsl",2,lt(100)),saturationv:ut("hsv",1,lt(100)),value:ut("hsv",2,lt(100)),chroma:ut("hcg",1,lt(100)),gray:ut("hcg",2,lt(100)),white:ut("hwb",1,lt(100)),wblack:ut("hwb",2,lt(100)),cyan:ut("cmyk",0,lt(100)),magenta:ut("cmyk",1,lt(100)),yellow:ut("cmyk",2,lt(100)),black:ut("cmyk",3,lt(100)),x:ut("xyz",0,lt(100)),y:ut("xyz",1,lt(100)),z:ut("xyz",2,lt(100)),l:ut("lab",0,lt(100)),a:ut("lab",1),b:ut("lab",2),keyword:function(t){return arguments.length?new ct(t):rt[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ct(t):nt.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ct.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),a=void 0===e?.5:e,o=2*a-1,i=n.alpha()-r.alpha(),s=((o*i==-1?o:(o+i)/(1+o*i))+1)/2,c=1-s;return ct.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*a+r.alpha()*(1-a))}},Object.keys(rt).forEach((function(t){if(-1===ot.indexOf(t)){var e=rt[t].channels;ct.prototype[t]=function(){if(this.model===t)return new ct(this);if(arguments.length)return new ct(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ct((n=rt[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ct[t]=function(n){return"number"==typeof n&&(n=ft(at.call(arguments),e)),new ct(n,t)}}}));const bt=[1,1,1,1,2,2,3,0];function mt(t){const e=t.length;let n="";for(let r=0;r<e;){let a=t[r++];if(128&a){let n=bt[a>>3&7];if(!(64&a)||!n||r+n>e)return null;for(a&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;a=a<<6|63&e}}n+=String.fromCharCode(a)}return n}new Array(3),new Array(3);const pt=[1/6378137,1/6378137,1/6356752.314245179],gt=[1/40680631590769,1/40680631590769,1/40408299984661.445],vt=new Array(3),wt=new Array(3),Mt=new Array(3);function Tt(t,e){const n=gt,r=function(t,e,n,r,a){const o=e[0],i=e[1],s=e[2],c=n[0],u=n[1],l=n[2],f=o*o*c*c,h=i*i*u*u,y=s*s*l*l,d=f+h+y,b=Math.sqrt(1/d),m=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(At,e,b);if(d<a)return isFinite(b)?m:void 0;const p=r[0],g=r[1],v=r[2],w=kt;w[0]=m[0]*p*2,w[1]=m[1]*g*2,w[2]=m[2]*v*2;let M,T,A,k,_,O,S,x,F,I,C,E=(1-b)*Ot(e)/(.5*Ot(w)),U=0;do{E-=U,A=1/(1+E*p),k=1/(1+E*g),_=1/(1+E*v),O=A*A,S=k*k,x=_*_,F=O*A,I=S*k,C=x*_,M=f*O+h*S+y*x-1,T=f*F*p+h*I*g+y*C*v;U=M/(-2*T)}while(Math.abs(M)>_t);return t[0]=o*A,t[1]=i*k,t[2]=s*_,t}(vt,e,pt,n,.1);let a=v(wt,r,n);a=function(t,e){const n=e[0],r=e[1],a=e[2];let o=n*n+r*r+a*a;o>0&&(o=Math.sqrt(o),t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o);return t}(a,a);const o=g(Mt,e,r),i=Math.atan2(a[1],a[0]),s=Math.asin(a[2]),c=(u=m(o,e),(Math.sign?Math.sign(u):0==(u=+u)||isNaN(u)?Number(u):u>0?1:-1)*Ot(o));var u;return t[0]=dt(i),t[1]=dt(s),t[2]=c,t}const At=new Array(3),kt=new Array(3),_t=1e-12;function Ot(t){return l(t)}function St(t,e){let n="";for(let r=0;r<4;r++){const a=t.getUint8(e+r);n+=String.fromCharCode(a)}return n}const xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ft(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function It(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function Ct(t,e,n){return{offset:e,byteLength:n}}function Et(t,e,n,r){const{byteOffset:a,componentType:o,type:i}=t,{ctor:s,type:c}=function(t){return zt[t]}(o||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Nt[t]}(i);return{byteStride:0,byteOffset:a+n,itemSize:u,count:r*u,componentType:c,array:new s(e,n+a,r*u)}}function Ut(t,e,n,r){const a=Et(t,e,n,r);return a.array.buffer.byteLength!==e.byteLength&&(a.array=a.array.slice()),a}const Nt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const zt={"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 Lt(t){for(const e in zt)if(t===zt[e].ctor)return zt[e].type;throw new Error("unrecognized ctor:"+t)}function jt(t,e,n,r){const a=t,o=e.length/3;for(let t=0;t<o;t++)a[3*t]=e[3*t]/65535*r[0]+n[0],a[3*t+1]=e[3*t+1]/65535*r[1]+n[1],a[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return a}function Dt(t,e,n){const r=t.getUint32(12,!0),a=t.getUint32(16,!0),o=t.getUint32(20,!0),i=t.getUint32(24,!0),s=t.buffer;let c,u={},l={},f=null;r>0&&(u=Ft(s,e,r),e+=r),a>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,a),e+=a),o>0&&(l=It(s,e,o),e+=o);const h=Ct(0,e,i);return f=s.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const Pt={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Bt(t){for(const e in Pt)if(t===Pt[e])return+e;throw new Error("unrecognized ctor:"+t)}let qt=null;function Rt(){return qt||(qt={"image/crn":r.crn&&r.crn(),"image/ktx2":r.ktx2&&r.ktx2(),"image/cttf":r.ktx2&&r.ktx2(),"draco":r.draco&&r.draco()}),qt}const{Ajax:Vt,GLTFLoader:Gt}=a();class $t{constructor(t,e,n){this.o=t,this.i=e||Gt,this.u=n,this.h=Rt()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Vt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){const o=a&&a.maxTextureSize,i=this.p(e,n,r,t);if(i.error)return Promise.resolve(i);const s=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.i(s,i.glb,{transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${M}t}-${M}n}-${M}r}\`;const a=c.transferables;for(let t=0;t<i.transferables.length;t++)a.indexOf(i.transferables[t])<0&&a.push(i.transferables[t]);return{magic:"b3dm",count:i.count,transferables:a,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,gltf:e}}))}p(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported b3dm version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let i,s=a.getUint32(12,!0),c=a.getUint32(16,!0),u=a.getUint32(20,!0),l=a.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,i=s,u=c,l=0,s=0,c=0):l>=570425344&&(f-=4,i=u,u=s,l=c,s=0,c=0);const h=[t];let y,d,b;if(s>0?(y=Ft(t,f,s),f+=s,i=y.BATCH_LENGTH):y={"BATCH_LENGTH":i},c>0&&(f+=c),u>0&&(d=It(t,f,u),f+=u,l>0)){const e=Ct(0,f,l);b=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(b)}const m=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Ut(y.BATCH_ID,t,undefined.offset,m);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:i,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}v(){return null}}const{Ajax:Xt,GLTFLoader:Ht}=a();class Jt{constructor(t,e,n,r){this.o=t,this.i=e||Ht,this.u=n,this.h=Rt(),this.M=r}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Xt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){return this.T(t,e,n,r,a).then((({gltf:a,transferables:o})=>{const i=this.A(e,n,r,t);if(i.error)return Promise.resolve(i);for(let t=0;t<o.length;t++)-1===i.transferables.indexOf(o[t])&&i.transferables.push(o[t]);return delete a.transferables,Promise.resolve({magic:"i3dm",count:i.count,transferables:i.transferables,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,i3dm:i.i3dm,gltf:a})}))}T(t,e,n,r,a){const o=a&&a.maxTextureSize,i={transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o},s=new DataView(e,n,r),c=32+s.getUint32(12,!0)+s.getUint32(16,!0)+s.getUint32(20,!0)+s.getUint32(24,!0);if(0===s.getUint32(28,!0)){let r=mt(new Uint8Array(e,c+n,s.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Xt.getArrayBuffer(r,{}).then((t=>this.k(r,{buffer:t.data,byteOffset:0},i))):Xt.getJSON(r,{}).then((t=>this.k(r,t,i)))}{const r={buffer:e,byteOffset:c+n,byteLength:s.byteLength-c};return this.k(t,r,i)}}k(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),a=new this.i(r,e,n);return a.load({skipAttributeTransform:!0}).then((n=>{let r=0,o=0;return e.buffer&&(r=e.byteOffset||0,o=e.byteLength||0),n.url=\`${M}t}-${M}r}-${M}o}\`,{transferables:a.transferables,gltf:n}}))}A(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,32+e,i),f={},h=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,n=s.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=s.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._(new Uint16Array(t,r+c.offset,3*h),e,n)},i.push(f.POSITION.array.buffer)}if(s.BATCH_ID){f.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},i.push(f.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:s,i3dm:f,transferables:i}}O(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let a=0;a<e;a++)Yt(r,t[2*a],t[2*a+1],65535),n[3*a]=r[0],n[3*a+1]=r[1],n[3*a+2]=r[2];return n}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function Yt(t,e,n,r){if(t[0]=Kt(e,r),t[1]=Kt(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Qt(e),t[1]=(1-Math.abs(e))*Qt(t[1])}return b(t,t)}function Kt(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Qt(t){return t<0?-1:1}const{Ajax:Zt}=a();class Wt{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.m(t,e,n,r)):Zt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r){return this.S(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}S(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,e+28,i),f=s.QUANTIZED_VOLUME_OFFSET,h=s.QUANTIZED_VOLUME_SCALE,y=s.POINTS_LENGTH;let d,b={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){b=s.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.F||(this.F=Rt().draco),this.F(d,e).then((e=>{const n=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=s.POSITION,n.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=s.RGB,n.RGBA=s.RGBA,n.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=s.NORMAL,n.NORMAL_OCT16P=s.NORMAL_OCT16P);const r=this.I(t,e.attributes,c.offset,y,i,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Lt(t.constructor),array:t},i.push(t.buffer)}else if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?r.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):r.BATCH_ID=te(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return{count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:r,transferables:i}}))}const m=this.I(t,s,c.offset,y,i,f,h);if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?m.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):m.BATCH_ID=te(y);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:m,transferables:i})}I(t,e,n,r,a,o,i){const s={};if(e.POSITION){let{byteOffset:o,array:i}=e.POSITION;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this._(u||new Uint16Array(t,c+l,3*r),o,i)},a.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:o,array:i}=e.RGBA;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+4*r);i=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB){let{byteOffset:o,array:i}=e.RGB;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r);i=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB565){let{byteOffset:o,array:i}=e.RGB565;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:i},a.push(i.buffer)}if(e.NORMAL){let{byteOffset:o,array:i}=e.NORMAL;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:o,array:i}=e.NORMAL_OCT16P;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:i},a.push(i.buffer)}return s}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function te(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Lt(e),array:r}}const{Ajax:ee,GLTFLoader:ne}=a();class re{constructor(t,e,n,r){this.u=n,this.o=t,this.i=e||ne,this.M=r}load(t,e,n=0,r=0,a){return e?this.m(t,e,n,r,a):ee.getArrayBuffer(t,{}).then((e=>{const a=e.data;return this.m(t,a,n,r)}))}m(t,e,n,r,a){r||(r=e.byteLength);const o=this.C(e,t,n,r),i=[];for(let n=0;n<o.length;n++){let r;if("b3dm"===o[n].magic)r=new $t(this.o,this.i,this.u);else if("i3dm"===o[n].magic)r=new Jt(this.o,this.i,this.u,this.M);else if("pnts"===o[n].magic)r=new Wt;else{if("cmpt"!==o[n].magic){console.warn("Unsupported magic in CMPT tile:",o[n].magic);continue}r=new re(this.o,this.i,this.u,this.M)}i.push(r.load(t,e,o[n].offset,o[n].byteLength,a).then((t=>t)))}return Promise.all(i).then((t=>({magic:"cmpt",tiles:t})))}C(t,e,n,r){const a=new DataView(t,n,r),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported cmpt version: "+o+", url:"+e;return console.warn(t),{error:t}}if(16===a.byteLength)return[];const i=[],s=a.getUint32(12,!0);let c=16;for(let e=0;e<s;e++){const e=St(a,c),r=a.getUint32(c+8,!0);i.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return i}}const{GLTFLoader:ae}=a();function oe(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,a=r.length;n<a;n++){const a=[];he(r[n],a,t,e)}}}const ie=[],se=[],ce=[],ue=[0,0,0],le=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),fe=[1,1,1];function he(t,e,n,r){const a=e.slice(0);if(t.matrix)a.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(ie,t.translation||ue),n=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,s=r+r,c=a+a,u=n*i,l=r*i,f=r*s,h=a*i,y=a*s,d=a*c,b=o*i,m=o*s,p=o*c;return t[0]=1-f-d,t[1]=l+p,t[2]=h-m,t[3]=0,t[4]=l-p,t[5]=1-u-d,t[6]=y+b,t[7]=0,t[8]=h+m,t[9]=y-b,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(se,t.rotation||le),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ce,t.scale||fe);s(r,n,r);const o=s([],e,r);a.push(o)}if(t.children&&t.children.length)for(let e=0,o=t.children.length;e<o;e++)he(t.children[e],a,n,r);if(void 0!==t.mesh){const e=t.mesh,o=n.meshes[e];if(o){const t=a.slice(0),i=o.primitives;for(let a=0,o=i.length;a<o;a++){const o=i[a];o&&(o.matrices=t,r(o,e,a,n))}}}}function ye(t,e){let{byteOffset:n,byteStride:r,count:a}=t;const{componentType:o,itemSize:i}=t,s=t.array.buffer,c=o?ae.getTypedArrayCtor(o):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,a=a||t.array.length/i,(!r||r===i*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(s,n,a*i);for(let r=0;r<a*i;r+=i){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,i),r/i)}return}const u=new Uint8Array(i*c.BYTES_PER_ELEMENT);r||(r=i*c.BYTES_PER_ELEMENT);for(let t=0;t<a;t++){const a=new Uint8Array(s,r*t+n,i*c.BYTES_PER_ELEMENT);u.set(a);e(new c(u.buffer),t),a.set(u)}}var de=ge("DXT1"),be=ge("DXT3"),me=ge("DXT5"),pe=ge("DX10");function ge(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var ve=A((function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var a=r[21];switch(a){case de:e=8,n="dxt1";break;case be:e=16,n="dxt3";break;case me:e=16,n="dxt5";break;case 116:n="rgba32f";break;case pe:var o=new Uint32Array(t.slice(128,148));n=o[0];var i=o[1];if(o[2],o[3],o[4],3!==i||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=a,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],y=r[3],d=r[1]+4,b=h,m=y,p=[];a===pe&&(d+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=b,y=m;for(var v=Math.log(h)/Math.log(2)+1,w=0;w<v;w++)f=h*y*16,p.push({offset:d,length:f,shape:[h,y]}),w<u&&(d+=f),h=Math.floor(h/2),y=Math.floor(y/2)}else for(w=0;w<u;w++)f=Math.max(4,h)/4*Math.max(4,y)/4*e,p.push({offset:d,length:f,shape:[h,y]}),d+=f,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[b,m],images:p,format:n,flags:c,cubemap:l}})),we=Math.abs,Me=Math.sin,Te=Math.cos,Ae=Math.tan,ke=Math.atan,_e=Math.atan2,Oe=Math.sqrt,Se=Math.log,xe=Math.hypot,Fe=Math.sinh,Ie=Math.cosh,Ce=1/0;function Ee(t){var e,n,r,a,o,i,s=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*Te(2*e),a=t.length-1,o=t[a],i=0;--a>=0;)n=r*o-i+t[a],i=o,o=n;return e+n*Me(2*e)}function h(t,e,n){for(var r,a,o=Me(e),i=Te(e),s=Fe(n),c=Ie(n),u=2*i*c,l=-2*o*s,f=t.length-1,h=t[f],y=0,d=0,b=0;--f>=0;)r=d,a=y,h=u*(d=h)-r-l*(y=b)+t[f],b=l*d-a+u*y;return[(u=o*c)*h-(l=i*s)*b,u*b+l*h]}t.es,o=a=(r=t.es/(1+Oe(1-t.es)))/(2-r),s[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),o*=a,s[1]=o*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=o*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),o*=a,s[2]=o*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=o*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),o*=a,s[3]=o*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=o*(1237/630+a*(a*(-24832/14175)-2.4)),o*=a,s[4]=o*(4174/315+a*(-144838/6237)),c[4]=o*(-734/315+a*(109598/31185)),o*=a,s[5]=o*(601676/22275),c[5]=o*(444337/155925),o=a*a,e=t.k0/(1+a)*(1+o*(1/4+o*(1/64+o/256))),u[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),l[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),u[1]=o*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),l[1]=o*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),o*=a,u[2]=o*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),l[2]=o*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),o*=a,u[3]=o*(-4397/161280+a*(11/504+a*(830251/7257600))),l[3]=o*(49561/161280+a*(-179/168+a*(6601661/7257600))),o*=a,u[4]=o*(-4583/161280+a*(108847/3991680)),l[4]=o*(34729/80640+a*(-3418889/1995840)),o*=a,u[5]=o*(-20648693/638668800),l[5]=.6650675310896665*o,i=f(c,t.phi0),n=-e*(i+function(t,e){var n,r=2*Te(e),a=t.length-1,o=t[a],i=0;for(;--a>=0;)n=r*o-i+t[a],i=o,o=n;return Me(e)*n}(l,2*i)),t.fwd=function(t,r){var a,o,i,s,u,y=t.phi,d=t.lam;y=f(c,y),a=Me(y),o=Te(y),s=Me(d),i=Te(d),y=_e(a,i*o),d=_e(s*o,xe(a,o*i)),d=function(t){var e=we(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*Se(e)/n}(e*(1+e/(xe(1,e)+1))),t<0?-e:e}(Ae(d)),u=h(l,2*y,2*d),y+=u[0],d+=u[1],we(d)<=2.623395162778?(r.y=e*y+n,r.x=e*d):r.x=r.y=Ce},t.inv=function(t,r){var a,o,i,c,l,y=t.y,d=t.x;y=(y-n)/e,we(d/=e)<=2.623395162778?(y+=(l=h(u,2*y,2*d))[0],d+=l[1],d=ke(Fe(d)),a=Me(y),o=Te(y),c=Me(d),i=Te(d),d=_e(c,i*o),y=_e(a*i,xe(c,i*o)),r.phi=f(s,y),r.lam=d):r.phi=r.lam=Ce}}const Ue=Math.PI/180,Ne=6378137*Math.PI/180,ze=85.0511287798,Le={};function je(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=ze,r=e[0],a=Math.max(Math.min(n,e[1]),-n);let o;o=0===a?0:Math.log(Math.tan((90+a)*Ue/2))/Ue;return t[0]=r*Ne,t[1]=o*Ne,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return De(t,e);if("baidu"===n)return De(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const a=JSON.stringify(n);let o=Le[a];return o||(o=Le[a]=function(t){const e={a:Be,es:qe,x0:ht(t.falseEasting)?5e5:t.falseEasting,y0:ht(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Pe,phi0:(t.latitudeOfOrigin||0)*Pe,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Ee(e);const n={lam:0,phi:0},r={};let a=0,o=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Pe-e.lam0,n.phi=e.originPhi0*Pe,e.fwd(n,r),a=e.a*r.x+e.x0,o=e.a*r.y+e.y0);return{project:function(t,i){n.lam=t[0]*Pe-e.lam0,n.phi=t[1]*Pe,e.fwd(n,r);const s=e.a*r.x+e.x0-a,c=e.a*r.y+e.y0-o;return i[0]=s,i[1]=c,i}}}(n)),o.project(e,t)}}function De(t,e){return t[0]=e[0],t[1]=e[1],t}const Pe=.017453292519943295,Be=6378137,qe=.0066943799901413165;const{Ajax:Re}=a(),Ve=i([]),Ge=Rt().draco,$e=Rt().ktx2,Xe={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},He={"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 Je(t,e,n,r,a,o){const s=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],a=Re.getArrayBuffer(n.url,o);a.xhr.url=n.url,u.push(a.xhr);const i=a.then((t=>({buffer:t})));s.push(i);const l=[];if(nn(r,l),l.length){const t=l.map((t=>{const e=Re.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));s.push(...t)}c[e]=l.length}const l=Promise.all(s).then((o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const s=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];s.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),u+=1+e}const l=function(t,e,n,r,a,o){const s={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const y=e[u].geoBuffer.data;if(!y)continue;h=un(y)?Ke(s,u,f,y,t.transform,t.center,a,o):Ze(s,u,f,y,t.transform,t.center,a,o),c.push(h),s.nodes[u]={mesh:u,nodeIndex:u,matrix:i([])},s.scenes[0].nodes[u]=s.nodes[u],l||(l=Xe);const d=tn(u,s,l,e[u].textureBuffers,n,r);c.push(d)}return Promise.all(c).then((()=>({gltf:s,featureTable:{BATCH_LENGTH:0},transferables:s.transferables})))}(t,s,e,a,n,r);return l}));return l.xhr=u,l}const Ye={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Ke(t,e,n,r,a,o,i,s){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=He[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ge(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>We(n,t,e,a,o,i,s)))}const Qe={position:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.position={array:a,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.normal={array:a,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,a=new Float32Array(e,n,r);return t.uv0={array:a,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,a=new Uint8Array(e,n,r);return t.color={array:a,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,a=new Uint32Array(e,n,r);return t.faceRange={array:a,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Ze(t,e,n,r,a,o,i,s){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Qe[n[e]]?t=Qe[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let a=e.ordering,o=e.featureAttributeOrder;const i=null;i&&i.geometryData&&i.geometryData[0]&&i.geometryData[0].params;for(let e=0;e<a.length;e++){const n=Qe[a[e]];n||console.log(a[e]),t=n(c,r,t)}for(let e=0;e<o.length;e++){const n=Qe[o[e]];n||console.log(o[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=He[t]&&He[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,a=t[e],o=t[e+1];for(let t=a;t<=o;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:Bt(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return We({attributes:l},t,e,a,o,i,s)}function We(t,e,n,r,a,o,i){const s={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,a){let o,i=[0,0,0,1];const s=[0,0],u=je([],n,r,a);u[2]=n[2];const l=e&&c(Ve,e);return ye(t,(t=>(i[0]=t[0],i[1]=t[1],i[2]=t[2],l||(i=p(i,i,e)),n&&d(i,i,n),je(s,i,r,a),o=i[2],t[0]=s[0]-u[0],t[1]=s[1]-u[1],t[2]=o-u[2],t))),u}(t.attributes.POSITION,r,a,o,i);e.meshes[n]={primitives:[s],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:a};for(const n in t.attributes)cn(e.transferables,t.attributes[n].array.buffer);return t.indices&&cn(e.transferables,t.indices.array.buffer),s}function tn(t,e,n,r,a,o){const i=r.map((t=>function(t,e,n,r,a){if("dds"===e){const e=ve(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),a="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Ye,format:a})}if("png"===e||"jpg"===e)return function(t,e){rn||(rn=new OffscreenCanvas(2,2),an=rn.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;on(n)||(n=sn(n)),on(r)||(r=sn(r));const a=e;a&&(n=Math.min(a,n),r=Math.min(a,r)),rn.width=n,rn.height=r,an.drawImage(t,0,0,n,r),t.close();const o=an.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(o.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,a).then((t=>{t.mimeType=n;return{image:t,sampler:Ye,format:6408}}));if("ktx2"===e)return $e(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Ye,format:t.format})));return null}(t.data,t.format,t.mimeType,a,o).then((t=>{if(t.image)if(t.image.array)cn(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cn(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(i).then((r=>{en(t,e,n,r)}))}function en(t,e,n,r){const a=JSON.parse(JSON.stringify(n)),o=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(o.push(r[r.ptr++]),a[t]={index:o.length-1},void 0!==n[t].factor&&(a[t].scale=n[t].factor)):yt(n[t])&&(a[t]=en(-1,e,n[t],r));return t>=0&&(e.materials[t]=a),a}function nn(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):yt(t[n])&&nn(t[n],e)}let rn,an;function on(t){return!(t&t-1)&&0!==t}function sn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cn(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function un(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}var ln="undefined"!=typeof Float32Array?Float32Array:Array;function fn(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hn=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new ln(3);return ln!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const yn=[];const dn=[],bn=[],mn=[],pn=[],gn=[],vn=[],wn=[];function Mn(t,e,n,r,a,o){fn(pn,t[3*e],t[3*e+1],t[3*e+2]),fn(gn,t[3*n],t[3*n+1],t[3*n+2]),fn(vn,t[3*r],t[3*r+1],t[3*r+2]);const i=hn(dn,vn,gn),s=hn(bn,pn,gn),c=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],s=n[1],c=n[2];return t[0]=a*c-o*s,t[1]=o*i-r*c,t[2]=r*s-a*i,t}(mn,i,s);!function(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o)}(wn,c),a[3*e]=a[3*e]||0,a[3*n]=a[3*n]||0,a[3*r]=a[3*r]||0,a[3*e+1]=a[3*e+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*e+2]=a[3*e+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*e]+=wn[0],a[3*n]+=wn[0],a[3*r]+=wn[0],a[3*e+1]+=wn[1],a[3*n+1]+=wn[1],a[3*r+1]+=wn[1],a[3*e+2]+=wn[2],a[3*n+2]+=wn[2],a[3*r+2]+=wn[2],o[e]+=1,o[n]+=1,o[r]+=1}const{Ajax:Tn,GLTFLoader:An}=a(),kn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],_n=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],On=2*Math.PI*6378137/360,Sn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let xn,Fn,In=!1;if("undefined"!=typeof OffscreenCanvas){try{Fn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Fn&&"undefined"!=typeof createImageBitmap&&(In=!0)}const Cn=i([]),En=[0,0,0],Un=[],Nn=[],zn=[],Ln=[],jn={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Dn={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Pn;class Bn{constructor(t,e,n,r){this.id=t,this.options=e,this.U=(...t)=>this.requestImage.call(this,...t),this.N=n,this.L={},r(null,{},[])}j(t){this.D||(this.u=t,this.P=new Wt,this.D=new $t(this.U,An,t),this.B=new Jt(this.U,An,t))}requestImage(t,e){In?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{xn.width=t.width,xn.height=t.height,Fn.drawImage(t,0,0);const n=Fn.getImageData(0,0,xn.width,xn.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.N("requestImage",{url:t},null,e)}loadTile(t,e){this.j(t.supportedFormats);const{service:n,url:r,arraybuffer:a}=t,o=n.fetchOptions||{};if(o.referrer=t.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const a=t.i3sInfo,i=n.maxTextureSize||0,s=Je(a,t.supportedFormats,this.options.projection,t.projection,i,o);return s.then((t=>{if(delete this.L[r],!t)return void e({status:404,url:r,i3sInfo:a});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:a});t.gltf.url=r;const{transferables:o}=t;t.magic="b3dm",n.createNormalIfMissed&&this.q(t.gltf),Yn(n)&&this.R(t.gltf),e(null,t,o)})),void(this.L[r]=s.xhr)}if(a){delete this.L[r];const n=St(new DataView(a),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Sn){const r=new Uint8Array(t,e,n);return Sn.decode(r)}return mt(new Uint8Array(t,e,n))}(a,0,a.byteLength),o=JSON.parse(n);o.accessors?this.V(o,r,t,"gltf",e):this.G(t.rootIdx,o,a,r,e)}else this.V(a,r,t,n,e)}else{let a=n.urlParams;a&&(a=(r.indexOf("?")>0?"&":"?")+a);const i=r.replace(/\\+/g,"%2B");let s=Tn.getArrayBuffer(i+(a||""),o);const c=s.xhr;s=s.then((n=>{delete this.L[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.L[r],e(t)})),this.L[r]=c}}V(t,e,n,r,a){r=r&&r.toLowerCase();const{service:o}=n;if("b3dm"===r){this.D.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{if(t.error)return void a(t);const{content:e,transferables:r}=this.$(t,n);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,r)})).catch((t=>{a(t)}))}else if("pnts"===r){const r=n.transform||Cn;this.P.load(e,t).then((t=>{const{content:e,transferables:o}=this.X(t,r,n.rootIdx);this.H(e),a(null,e,o)}))}else if("i3dm"===r){const r=n.transform||Cn;this.B.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:i}=this.J(t,r,n.rootIdx);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,i)}))}else if("cmpt"===r){new re(this.U,An,this.u,o.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Y(t,n);this.K(e,o),Yn(o)&&this.Z(e),a(null,e,r)})).catch((t=>{a(t)}))}else if("gltf"===r){this.h||(this.h=Rt());const r=e.substring(0,e.lastIndexOf("/")),i=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let s;try{s=new An(r,i,{transferable:!0,requestImage:this.U,decoders:this.h,supportedFormats:this.u,maxTextureSize:o.maxTextureSize||0})}catch(t){a(t)}s.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.W(t,null,n),o.createNormalIfMissed&&this.q(t),Yn(o)&&this.R(t),a(null,{magic:"gltf",gltf:t},s.transferables)}))}else a(new Error("unsupported tile format: "+r))}K(t,e){t.content?t.content.forEach((t=>{this.K(t,e)})):e.createNormalIfMissed&&this.q(t.gltf)}Z(t){t.content?t.content.forEach((t=>{this.Z(t)})):this.R(t.gltf)}tt(t,e){if(this.et(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.nt()?Pn.subarray(0,n):e,a=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const a=yn;a.length<t.length/3&&(a.length=t.length/3),a.fill(0,0,t.length/3);const o=void 0===e.length?e:e.length;for(let n=0;n<o/3;n++)void 0===e.length?Mn(t,3*n,3*n+1,3*n+2,r,a):Mn(t,e[3*n],e[3*n+1],e[3*n+2],r,a);for(let t=0;t<r.length;t+=3){const e=a[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}R(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const a=Xn(e[n].array,r,e[n].min,e[n].max,n);if(!a)continue;const{array:o,range:i}=a;e[n].componentType=5124,e[n].array=o,t.compressed_int16_params[n]=i}}))}}q(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.tt(e,t)}))}}H(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const{array:a,range:o}=Xn(e[n].array,r,e[n].min,e[n].max,n);e[n].array=a,t.compressed_int16_params[n]=o}}rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const a={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(a)}return e}G(t,e,n,r,a){return e.capabilities,void a(null,e)}Y(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},a=[];for(let t=0;t<n.length;t++){const{magic:o}=n[t];if("b3dm"===o){const{content:o,transferables:i}=this.$(n[t],e);Gn(a,i),r.content.push(o)}else if("i3dm"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.J(n[t],o,i);Gn(a,c),r.content.push(s)}else if("pnts"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.X(n[t],o,i);Gn(a,c),r.content.push(s)}else if("cmpt"===o){const{content:o,transferables:i}=this.Y(n[t],e);Gn(a,i),r.content.push(o)}}return{content:r,transferables:a}}$(t,e){const{gltf:n,transferables:r,featureTable:a}=t;return this.W(n,a,e),delete t.transferables,{content:t,transferables:r}}W(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;if(t.extensions&&t.extensions.KHR_techniques_webgl)return!0;const e="visited";let n=1;const r=[];for(const a in t.meshes){const o=t.meshes[a],{primitives:i}=o;if(i)for(let t=0;t<i.length;t++){const a=i[t].attributes&&i[t].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[e]||(a.array.buffer[e]=n++);const o=n-1+"-"+(a.byteOffset||0);if(r.indexOf(o)>=0)return!0;r.push(o)}}return!1}(t);this.ot(t);n.service.createNormalIfMissed||this.it(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.st(t,e,n.upAxis,n.transform)):this.ct(t,e,n.upAxis,n.transform)}J(t,e,n){const{featureTable:r}=t,a=t.i3dm,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,Cn,u);const l=Vn(u);e&&!s&&p(l,l,e);const f=this.ut(l),d=[];je(d,f,i),d[2]=f[2];const b=h([],l),m=[0,0,0],g=[0,0,0],v=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];ye(a.POSITION,(t=>{m[0]=t[0]+o[0],m[1]=t[1]+o[1],m[2]=t[2]+o[2],e&&!s&&p(m,m,e),0===w(m)?y(g,0,0,-6378137):Tt(g,m),je(v,g,i),t[0]=v[0]-d[0],t[1]=v[1]-d[1],t[2]=g[2]-d[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),a.POSITION.min=M,a.POSITION.max=T,e&&p(l,l,e),t.rtcCenter=b,t.rtcCoord=f,t.projCenter=d,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}X(t,e,n){const{featureTable:r}=t,a=t.pnts,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,e,u);const l=Vn(u),f=this.lt(l),d=h([],l),b=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];let g=[0,0,0,1];const v=[0,0,0],M=[0,0];ye(a.POSITION,(t=>(g[0]=t[0]+o[0],g[1]=t[1]+o[1],g[2]=t[2]+o[2],e&&!s&&(g=p(g,g,e)),0===w(g)?y(v,0,0,-6378137):Tt(v,g),je(M,v,i),t[0]=M[0]-f[0],t[1]=M[1]-f[1],t[2]=v[2]-f[2],t[0]<b[0]&&(b[0]=t[0]),t[1]<b[1]&&(b[1]=t[1]),t[2]<b[2]&&(b[2]=t[2]),t[0]>m[0]&&(m[0]=t[0]),t[1]>m[1]&&(m[1]=t[1]),t[2]>m[2]&&(m[2]=t[2]),t))),a.POSITION.min=b,a.POSITION.max=m,e&&p(l,l,e);const T=this.ut(l);t.rtcCenter=d,t.projCenter=f,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}ot(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],a=n[1],o=n[2],i=n[3];let s=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==a||n[t+2]!==o||n[t+3]!==i){s=!1;break}s&&(e[t].image.color=[r/255,a/255,o/255,i/255],delete e[t].image.array)}}}it(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const a=r.primitives;if(a)for(let e=0;e<a.length;e++){if(!a[e])continue;if(!a[e].attributes||a[e].attributes.NORMAL)continue;const n=a[e].material;if(!ht(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}abortTileLoading(t,e){const n=this.L[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.L[t.url],e(null)}ft(t,e,n,r){const a=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let o=kn;"X"===(n=n&&n.toUpperCase())?o=_n:"Z"===n&&(o=Cn),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),a&&(t.extensions.CESIUM_RTC.center=a),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};oe(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=i(Un);t.matrices&&$n(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,o,e),r&&s(e,r,e),Rn(n,u,a||En,e,c,t.compressUniforms)}));const u=Vn(c);return{rtcCenter:a,modelCenter:u,upAxisTransform:o}}st(t,e,n,r){const{modelCenter:a,upAxisTransform:o,rtcCenter:c}=this.ft(t,e,n),u=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a);const l=h([],a);r&&p(a,a,r),t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),c||(oe(t,(t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const n=i(Un);t.matrices&&$n(n,t.matrices),s(n,o,n);const r=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],y=e[11],d=e[12],b=e[13],m=e[14],p=e[15],g=n*s-r*i,v=n*c-a*i,w=n*u-o*i,M=r*c-a*s,T=r*u-o*s,A=a*u-o*c,k=l*b-f*d,_=l*m-h*d,O=l*p-y*d,S=f*m-h*b,x=f*p-y*b,F=h*p-y*m,I=g*F-v*x+w*S+M*O-T*_+A*k;return I?(I=1/I,t[0]=(s*F-c*x+u*S)*I,t[1]=(a*x-r*F-o*S)*I,t[2]=(b*A-m*T+p*M)*I,t[3]=(h*T-f*A-y*M)*I,t[4]=(c*O-i*F-u*_)*I,t[5]=(n*F-a*O+o*_)*I,t[6]=(m*w-d*A-p*v)*I,t[7]=(l*A-h*w+y*v)*I,t[8]=(i*x-s*O+u*k)*I,t[9]=(r*O-n*x-o*k)*I,t[10]=(d*T-b*w+p*g)*I,t[11]=(f*w-l*T-y*g)*I,t[12]=(s*_-i*S-c*k)*I,t[13]=(n*S-r*_+a*k)*I,t[14]=(b*v-d*M-m*g)*I,t[15]=(l*M-f*v+h*g)*I,t):null}(Nn,n),a=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ye(e,(t=>{p(t,t,n),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],p(t,t,r),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]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=a,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}ct(t,e,n,r){const{modelCenter:a,rtcCenter:o}=this.ft(t,e,n,r),i=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=i,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),oe(t,(e=>{if(e.attributes&&e.attributes.POSITION){const a=this.et(e,t);if(a){const t=e.attributes.POSITION.array.length;(!Pn||Pn.length<t)&&(Pn=new Float32Array(t))}e.attributes.NORMAL&&this.ht(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.ht(e.attributes.TANGENT,e.matrices,n);const{newPositions:i}=this.yt(e.attributes.POSITION,e.matrices,o,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,a),{componentType:s}=e.attributes.POSITION;5126!==s&&(e.attributes.POSITION.array=new Float32Array(i))}}));for(const e in t.nodes){t.nodes[e].matrix=Cn}}lt(t){const e=this.options.projection;"identity"===e?h(zn,t):0===w(t)?y(zn,0,0,-6378137):Tt(zn,t),je(Ln,zn,e);const n=zn[2],r=[];return r[0]=Ln[0],r[1]=Ln[1],r[2]=n,r}ht(t,e,n){let r;r="Y"===n?kn:"X"===n?_n:Cn;const a=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],r);if($n(a,e),c(a,Cn))return;const o=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}([],a),i=[];ye(t,(t=>(function(t,e,n){var r=e[0],a=e[1],o=e[2];t[0]=r*n[0]+a*n[3]+o*n[6],t[1]=r*n[1]+a*n[4]+o*n[7],t[2]=r*n[2]+a*n[5]+o*n[8]}(i,t,o),b(i,i),h(t,i),i)))}yt(t,e,n,r,a,o,s,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=i([]);$n(l,e);const f=this.options.projection;a=a&&a.toUpperCase();const h=n;let b=null;"Y"===a?b=kn:"X"===a&&(b=_n);let m=[0,0,0,1];const g=[0,0,0],v=[0,0],M=r.projCenter,T=je([],r.rtcCoord,"EPSG:3857"),A=o&&c(Cn,o),k=t.min=t.min||[],_=t.max=t.max||[];y(k,1/0,1/0,1/0),y(_,-1/0,-1/0,-1/0);const O=s||{},{decode_position_min:S,decode_position_normConstant:x}=O;let F=[0,0,0,0],I=1;S&&(F=S),x&&(I=x);const C=[];return ye(t,((e,n)=>{if(m[0]=e[0]*I+F[0],m[1]=e[1]*I+F[1],m[2]=e[2]*I+F[2],m=p(m,m,l),b&&(m=p(m,m,b)),h&&d(m,m,h),o&&!A&&(m=p(m,m,o)),0===w(m)?y(g,0,0,-6378137):Tt(g,m),u){const t=Pn;je(v,g,f),t[3*n]=v[0]-T[0],t[3*n+1]=v[0]-T[1],t[3*n+2]=v[0]-T[2]}if(je(v,g,f),e instanceof Float32Array)e[0]=v[0]-M[0],e[1]=v[1]-M[1],e[2]=g[2]-M[2];else{const n=v[0]-M[0],r=v[1]-M[1],a=g[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(a),C.push(e[3]))}return e[0]<k[0]&&(k[0]=e[0]),e[1]<k[1]&&(k[1]=e[1]),e[2]<k[2]&&(k[2]=e[2]),e[0]>_[0]&&(_[0]=e[0]),e[1]>_[1]&&(_[1]=e[1]),e[2]>_[2]&&(_[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}ut(t){return 0===w(t)?y([],0,0,-6378137):Tt([],t)}onRemove(){}nt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}et(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;return!t.attributes.TANGENT}}const qn=[];function Rn(t,e,n,r,a,o){const i=o||{},{decode_position_min:s,decode_position_normConstant:c}=i;let u=[0,0,0,0],l=1;s&&(u=s),c&&(l=c);for(let o=0,i=t.length;o<i;o+=e){const{xmin:i,ymin:s,xmax:c,ymax:f,hmin:h,hmax:b}=a;y(qn,t[o]*l+u[0],t[o+1]*l+u[1],t[o+2]*l+u[2]),p(qn,qn,r);const m=d(qn,n,qn);m[0]<i&&(a.xmin=m[0]),m[0]>c&&(a.xmax=m[0]),m[1]<s&&(a.ymin=m[1]),m[1]>f&&(a.ymax=m[1]),e>2&&(m[2]<h&&(a.hmin=m[2]),m[2]>b&&(a.hmax=m[2]))}}function Vn(t){const{xmax:e,ymax:n,xmin:r,ymin:a,hmin:o,hmax:i}=t,s=[(r+e)/2,(a+n)/2,(o+i)/2];return e===-1/0&&(s[0]=0),n===-1/0&&(s[1]=0),i===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Gn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function $n(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}function Xn(t,e,n,r,a){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let o,i;if(n&&r&&1===e)o=Math.min(...n),i=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);o=e,i=n}return!function(t,e,n,r){for(let a=0;a<t.length;a++){const o=Hn(Jn(t[a],e,n),e,n);if(Math.abs(o-t[a])>Dn[r])return!1}return!0}(t,o,i,a)&&Dn[a]?null:function(t,e,n){const r=new Int16Array(t.length);for(let a=0;a<t.length;a++)r[a]=Jn(t[a],e,n);return{array:r,range:[e,n]}}(t,o,i)}function Hn(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Jn(t,e,n){const r=2*(t-e)/(n-e)-1,a=Math.max(-1,Math.min(1,r));return a<0?32768*a:32767*a}function Yn(t){return void 0===t.compressGeometry||t.compressGeometry}let Kn=0;class Qn{constructor(t){this.workerId=t,this.workers={},this.dt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},a){if(this.bt(e,n))return;const o=this.gt(e,n),i=r.options;this.workers[o]=new Bn(n,i,((...e)=>this.send.call(this,t,...e)),a)}removeLayer({mapId:t,layerId:e},n){const r=this.bt(t,e),a=this.gt(t,e);delete this.workers[a],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.dt[e];delete this.dt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,a){const o=a?\`${M}t}-${M}Kn++}\`:null;a&&(this.dt[o]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}gt(t,e){return\`${M}t}-${M}e}\`}bt(t,e){const n=this.gt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Qn(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var x={exports:{}},I={exports:{}},S=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},C=Array.prototype.concat,k=Array.prototype.slice,N=I.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];S(s)?e=C.call(e,k.call(s)):e.push(s)}return e};N.wrap=function(t){return function(){return t(N(arguments))}};var L=I.exports,E={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R=L,P=Object.hasOwnProperty,U=Object.create(null);for(var B in E)P.call(E,B)&&(U[E[B]]=B);var G=x.exports={to:{},get:{}};function D(t,e,n){return Math.min(Math.max(e,t),n)}function F(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}G.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=G.get.hsl(t),n="hsl";break;case"hwb":e=G.get.hwb(t),n="hwb";break;default:e=G.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},G.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:P.call(E,e[1])?((s=E[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=D(s[n],0,255);return s[3]=D(s[3],0,1),s},G.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,D(parseFloat(e[2]),0,100),D(parseFloat(e[3]),0,100),D(isNaN(n)?1:n,0,1)]}return null},G.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,D(parseFloat(e[2]),0,100),D(parseFloat(e[3]),0,100),D(isNaN(n)?1:n,0,1)]}return null},G.to.hex=function(){var t=R(arguments);return"#"+F(t[0])+F(t[1])+F(t[2])+(t[3]<1?F(Math.round(255*t[3])):"")},G.to.rgb=function(){var t=R(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},G.to.rgb.percent=function(){var t=R(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},G.to.hsl=function(){var t=R(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},G.to.hwb=function(){var t=R(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},G.to.keyword=function(t){return U[t.slice(0,3)]};var j=x.exports,z={exports:{}},H={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},q={};for(var $ in H)H.hasOwnProperty($)&&(q[H[$]]=$);var V=z.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var J in V)if(V.hasOwnProperty(J)){if(!("channels"in V[J]))throw new Error("missing channels property: "+J);if(!("labels"in V[J]))throw new Error("missing channel labels property: "+J);if(V[J].labels.length!==V[J].channels)throw new Error("channel and label counts mismatch: "+J);var Y=V[J].channels,Z=V[J].labels;delete V[J].channels,delete V[J].labels,Object.defineProperty(V[J],"channels",{value:Y}),Object.defineProperty(V[J],"labels",{value:Z})}V.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},V.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,l=Math.max(o,a,c),h=l-Math.min(o,a,c),u=function(t){return(l-t)/6/h+.5};return 0===h?s=i=0:(i=h/l,e=u(o),n=u(a),r=u(c),o===l?s=r-n:a===l?s=1/3+e-r:c===l&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*l]},V.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[V.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},V.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},V.rgb.keyword=function(t){var e=q[t];if(e)return e;var n,r,s,i=1/0;for(var o in H)if(H.hasOwnProperty(o)){var a=H[o],c=(r=t,s=a,Math.pow(r[0]-s[0],2)+Math.pow(r[1]-s[1],2)+Math.pow(r[2]-s[2],2));c<i&&(i=c,n=o)}return n},V.keyword.rgb=function(t){return H[t]},V.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},V.rgb.lab=function(t){var e=V.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},V.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var l=0;l<3;l++)(r=o+1/3*-(l-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[l]=255*i;return s},V.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},V.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},V.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},V.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,l=t[1]/100,h=t[2]/100,u=l+h;switch(u>1&&(l/=u,h/=u),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),s=l+r*((n=1-h)-l),e){default:case 6:case 0:i=n,o=s,a=l;break;case 1:i=s,o=n,a=l;break;case 2:i=l,o=n,a=s;break;case 3:i=l,o=s,a=n;break;case 4:i=s,o=l,a=n;break;case 5:i=n,o=l,a=s}return[255*i,255*o,255*a]},V.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},V.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},V.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},V.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},V.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},V.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},V.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:V.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},V.hsv.ansi16=function(t){return V.rgb.ansi16(V.hsv.rgb(t),t[2])},V.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},V.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},V.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},V.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},V.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},V.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},V.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},V.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},V.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},V.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},V.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},V.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},V.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},V.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},V.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},V.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},V.gray.hsl=V.gray.hsv=function(t){return[0,0,t[0]]},V.gray.hwb=function(t){return[0,100,t[0]]},V.gray.cmyk=function(t){return[0,0,0,t[0]]},V.gray.lab=function(t){return[t[0],0,0]},V.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},V.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var K=z.exports,X=K;function W(t){var e=function(){for(var t={},e=Object.keys(X),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(X[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Q(t,e){return function(n){return e(t(n))}}function tt(t,e){for(var n=[e[t].parent,t],r=X[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=Q(X[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var et=K,nt=function(t){for(var e=W(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=tt(o,e))}return n},rt={};Object.keys(et).forEach((function(t){rt[t]={},Object.defineProperty(rt[t],"channels",{value:et[t].channels}),Object.defineProperty(rt[t],"labels",{value:et[t].labels});var e=nt(t);Object.keys(e).forEach((function(n){var r=e[n];rt[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),rt[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var st=j,it=rt,ot=[].slice,at=["keyword","gray","hex"],ct={};Object.keys(it).forEach((function(t){ct[ot.call(it[t].labels).sort().join("")]=t}));var lt={};function ht(t,e){if(!(this instanceof ht))return new ht(t,e);if(e&&e in at&&(e=null),e&&!(e in it))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ht)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=st.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=it[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=it[this.model].channels;var i=ot.call(t,0,r);this.color=dt(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ct))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ct[a];var c=it[this.model].labels,l=[];for(n=0;n<c.length;n++)l.push(t[c[n]]);this.color=dt(l)}if(lt[this.model])for(r=it[this.model].channels,n=0;n<r;n++){var h=lt[this.model][n];h&&(this.color[n]=h(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ut(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function ft(t){return function(e){return Math.max(0,Math.min(t,e))}}function dt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ht.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in st.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return st.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return st.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=it[this.model].channels,n=it[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ht(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ht(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ut("rgb",0,ft(255)),green:ut("rgb",1,ft(255)),blue:ut("rgb",2,ft(255)),hue:ut(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ut("hsl",1,ft(100)),lightness:ut("hsl",2,ft(100)),saturationv:ut("hsv",1,ft(100)),value:ut("hsv",2,ft(100)),chroma:ut("hcg",1,ft(100)),gray:ut("hcg",2,ft(100)),white:ut("hwb",1,ft(100)),wblack:ut("hwb",2,ft(100)),cyan:ut("cmyk",0,ft(100)),magenta:ut("cmyk",1,ft(100)),yellow:ut("cmyk",2,ft(100)),black:ut("cmyk",3,ft(100)),x:ut("xyz",0,ft(100)),y:ut("xyz",1,ft(100)),z:ut("xyz",2,ft(100)),l:ut("lab",0,ft(100)),a:ut("lab",1),b:ut("lab",2),keyword:function(t){return arguments.length?new ht(t):it[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ht(t):st.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ht.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return ht.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(it).forEach((function(t){if(-1===at.indexOf(t)){var e=it[t].channels;ht.prototype[t]=function(){if(this.model===t)return new ht(this);if(arguments.length)return new ht(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ht((n=it[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ht[t]=function(n){return"number"==typeof n&&(n=dt(ot.call(arguments),e)),new ht(n,t)}}}));var mt=A(ht);function pt(t){return null==t}function yt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function bt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function gt(t){return"object"==typeof t&&!!t}function wt(t){return"number"==typeof t&&!isNaN(t)}function vt(t){return t*Math.PI/180}function Tt(t){return t/Math.PI*180}function _t(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function Mt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const Ot=[1,1,1,1,2,2,3,0];function At(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=Ot[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}function xt(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function It(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function St(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function kt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),s=r.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=r.charCodeAt(t);return i.buffer}function Nt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const Lt={};function Et(t,e){if(!Array.isArray(e)){const t=e;e=Lt[t]=Lt[t]||mt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Rt=Object.freeze({__proto__:null,base64URLToArrayBuffer:kt,extend:yt,flatArr:It,getAbsoluteURL:_t,getBatchIdArrayType:St,isBase64:Ct,isFunction:bt,isNil:pt,isNumber:wt,isObject:gt,normalizeColor:Et,pushIn:Nt,setColumn3:xt,sign:Mt,stringFromUTF8Array:At,toDegree:Tt,toRadian:vt});function Pt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Bt=function(){if("undefined"!=typeof globalThis)return globalThis;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")},Gt=Bt(),Dt=Gt.gl_trans__coders=Gt.gl_trans__coders||{};
7
7
  /*!
8
- * @maptalks/gl v0.124.0
8
+ * @maptalks/gl v0.124.2
9
9
  * LICENSE : UNLICENSED
10
10
  * (c) 2016-2026 maptalks.com
11
- */function Ft(){return Bt().maptalks_gltf_loader}Dt.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Gt.gl_trans__coders=Gt.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${Bt.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\n;");return i+="\n("+Bt().maptalks_gltf_loader_bundle.toString()+")({});\n",i+="\n"+e.substring(r.length),i},Dt.registerTranscoder=function(t,e){Dt[t]=e},Dt.getTranscoder=function(t){return Dt[t]};const jt="undefined"==typeof document?null:document.createElement("canvas");class zt extends t.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.i=n}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const s={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(s,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!jt)return void e(new Error("There is no canvas to draw image!"));const t=this.i?n:function(t){if(Ht(t.width)&&Ht(t.height))return t;let e=t.width,n=t.height;Ht(e)||(e=qt(e));Ht(n)||(n=qt(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const s=t.src,i=s.lastIndexOf("/")+1,o=s.substring(i);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);jt.width=t.width,jt.height=t.height;const r=jt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const s=r.getImageData(0,0,t.width,t.height),i={width:t.width,height:t.height,data:new Uint8Array(s.data)};e(null,i,[i.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function Ht(t){return!(t&t-1)&&0!==t}function qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const{GLTFLoader:$t}=Ft();function Vt(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];Qt(r[n],s,t,e)}}}const Jt=[],Yt=[],Zt=[],Kt=[0,0,0],Xt=w.identity([]),Wt=[1,1,1];function Qt(t,e,n,r){const s=e.slice(0);if(t.matrix)s.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=v.fromTranslation(Jt,t.translation||Kt),n=v.fromQuat(Yt,t.rotation||Xt),r=v.fromScaling(Zt,t.scale||Wt);v.multiply(r,n,r);const i=v.multiply([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)Qt(t.children[e],s,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=s.slice(0),o=i.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function te(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?$t.getTypedArrayCtor(i):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,s*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function ee(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var ne="#include <gl2_vert>\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\nconst float SHIFT_LEFT_11 = 2048.0;\nconst float SHIFT_LEFT_5 = 32.0;\nconst float NORMALIZE_6 = 1.0 / 64.0;\nconst float NORMALIZE_5 = 1.0 / 32.0;\n#ifdef HAS_POSITION\n attribute vec3 POSITION;\n#endif\n#if defined(HAS_RGB)\n attribute vec3 RGB;\n#elif defined(HAS_RGBA)\n attribute vec4 RGBA;\n#elif defined(HAS_RGB565)\n attribute float RGB565;\n#endif\nuniform vec4 pointColor;\nuniform float pointSize;\nuniform mat4 projViewModelMatrix;\nuniform float pointOpacity;\nvarying vec4 vColor;\n#ifdef HAS_NORMAL\n #ifdef HAS_NORMAL_OCT16P\n attribute vec2 NORMAL_OCT16P;\n float signNotZero(float value) {\n return value >= 0.0 ? 1.0 : -1.0;\n }\n vec2 signNotZero(vec2 value) {\n return vec2(signNotZero(value.x), signNotZero(value.y));\n }\n vec3 octDecode(vec2 encoded, float range) {\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n return vec3(0.0, 0.0, 0.0);\n }\n encoded = encoded / range * 2.0 - 1.0;\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n if (v.z < 0.0) {\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n }\n return normalize(v);\n }\n vec3 octDecode(vec2 encoded) {\n return octDecode(encoded, 255.0);\n }\n #else\n attribute vec3 NORMAL;\n #endif\n uniform vec3 lightDir;\n uniform mat3 modelNormalMatrix;\n uniform mat4 positionMatrix;\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n return max(dot(-lightDir, normal), 0.0);\n }\n#endif\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <draco_decode_vert>\nvoid main() {\n #ifdef HAS_POSITION\n vec3 localPos = decode_getPosition(POSITION);\n #endif\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n gl_PointSize = pointSize;\n #ifdef PICKING_MODE\n fbo_picking_setData(gl_Position.w, true);\n #else\n #if defined(HAS_RGB)\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n #elif defined(HAS_RGBA)\n vColor = RGBA / 255.0 * pointOpacity;\n #elif defined(HAS_RGB565)\n float compressed = RGB565;\n float r = floor(compressed * SHIFT_RIGHT_11);\n compressed -= r * SHIFT_LEFT_11;\n float g = floor(compressed * SHIFT_RIGHT_5);\n compressed -= g * SHIFT_LEFT_5;\n float b = compressed;\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n vColor = vec4(rgb, 1.0);\n #else\n vColor = pointColor;\n #endif\n #ifdef HAS_NORMAL\n mat3 positionNormalMatrix = mat3(positionMatrix);\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n #ifdef HAS_NORMAL_OCT16P\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n #else\n vec3 localNormal = NORMAL;\n #endif\n vec3 normal = normalize(normalMatrix * localNormal);\n float colorStrength = getLambertDiffuse(lightDir, normal);\n colorStrength = max(colorStrength, 0.5);\n vColor *= colorStrength;\n #endif\n #endif\n}\n";const re=new Array(3),se=new Array(3),ie=[40680631590769,40680631590769,40408299984661.445];function oe(t,e,n,r){const s=ie,i=Math.cos(n);re[0]=i*Math.cos(e),re[1]=i*Math.sin(e),re[2]=Math.sin(n),be(re,re),T.multiply(se,s,re);const o=Math.sqrt(T.dot(re,se));var a,c,l;return c=se,l=o,(a=se)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,T.scale(re,re,r),T.add(t,se,re)}const ae=[1/6378137,1/6378137,1/6356752.314245179],ce=[1/40680631590769,1/40680631590769,1/40408299984661.445],le=new Array(3),he=new Array(3),ue=new Array(3);function fe(t,e){const n=ce,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],l=n[1],h=n[2],u=i*i*c*c,f=o*o*l*l,d=a*a*h*h,m=u+f+d,p=Math.sqrt(1/m),y=T.scale(de,e,p);if(m<s)return isFinite(p)?y:void 0;const b=r[0],g=r[1],w=r[2],v=me;v[0]=y[0]*b*2,v[1]=y[1]*g*2,v[2]=y[2]*w*2;let _,M,O,A,x,I,S,C,k,N,L,E=(1-p)*ye(e)/(.5*ye(v)),R=0;do{E-=R,O=1/(1+E*b),A=1/(1+E*g),x=1/(1+E*w),I=O*O,S=A*A,C=x*x,k=I*O,N=S*A,L=C*x,_=u*I+f*S+d*C-1,M=u*k*b+f*N*g+d*L*w;R=_/(-2*M)}while(Math.abs(_)>pe);return t[0]=i*O,t[1]=o*A,t[2]=a*x,t}(le,e,ae,n,.1);let s=T.mul(he,r,n);s=be(s,s);const i=T.sub(ue,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=Mt(T.dot(i,e))*ye(i);return t[0]=Tt(o),t[1]=Tt(a),t[2]=c,t}const de=new Array(3),me=new Array(3),pe=1e-12;function ye(t){return T.length(t)}function be(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function ge(t,e){return T.multiply(e,t,ce),T.normalize(e,e)}function we(t,e){const n=t[0],r=t[1],s=Math.cos(r),i=s*Math.cos(n),o=s*Math.sin(n),a=Math.sin(r);return e.x=i,e.y=o,e.z=a,T.normalize(e,e)}var ve=Object.freeze({__proto__:null,cartesian3ToDegree:fe,geodeticSurfaceNormal:ge,geodeticSurfaceNormalCartographic:we,normalizeCartesian:be,radianToCartesian3:oe});function Te(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function _e(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Me="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Oe(t,e,n){const r=new Uint8Array(t,e,n);return Me?JSON.parse(Me.decode(r)):JSON.parse(At(r))}function Ae(t,e,n){const r=new Uint8Array(t,e,n);return Me?JSON.parse(Me.decode(r)):JSON.parse(At(r))}function xe(t,e,n){return{offset:e,byteLength:n}}function Ie(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=Ee(i||"UNSIGNED_SHORT"),l=Ne(o);return{byteStride:0,byteOffset:s+n,itemSize:l,count:r*l,componentType:c,array:new a(e,n+s,r*l)}}function Se(t,e,n,r){const s=Ie(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function Ce(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=Ee(i||"UNSIGNED_SHORT"),c=Ne(o),l=new a(e,s,n*c);return 1===c?l[r]:l.subarray(r*c,r*c+c)}const ke={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ne(t){return t?ke[t]:1}const Le={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Ee(t){return Le[t]}function Re(t){for(const e in Le)if(t===Le[e].ctor)return Le[e].type;throw new Error("unrecognized ctor:"+t)}function Pe(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function Ue(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,l={},h={},u=null;r>0&&(l=Oe(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(h=Ae(a,e,i),e+=i);const f=xe(0,e,o);return u=a.slice(f.offset,f.offset+f.byteLength),n.push(u),{featureTable:l,featureTableBin:c,batchTable:h,batchTableBin:u}}const Be={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"}},Ge={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},De={},Fe={east:[],north:[],up:[],west:[],south:[],down:[]};let je=[],ze=[],He=[];const qe=[0,0,0];function $e(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const Ve=function(t,e){const n=Be[t][e];let r;const s=t+e;return De[s]?r=De[s]:(r=function(r,s,i){if(T.equals(r,qe))T.copy(je,Ge[t]),T.copy(ze,Ge[e]),T.copy(He,Ge[n]);else if(Te(r[0],0,1e-14)&&Te(r[1],0,1e-14)){const s=Mt(r[2]);T.copy(je,Ge[t]),T.copy(ze,Ge[e]),T.scale(ze,ze,s),T.copy(He,Ge[n]),T.scale(He,He,s)}else{ge(r,Fe.up);const s=Fe.up,i=Fe.east;i[0]=-r[1],i[1]=r[0],i[2]=0,T.normalize(Fe.east,i),T.cross(Fe.north,s,i),T.scale(Fe.down,Fe.up,-1),T.scale(Fe.west,Fe.east,-1),T.scale(Fe.south,Fe.north,-1),je=Fe[t],ze=Fe[e],He=Fe[n]}return i[0]=je[0],i[1]=je[1],i[2]=je[2],i[3]=0,i[4]=ze[0],i[5]=ze[1],i[6]=ze[2],i[7]=0,i[8]=He[0],i[9]=He[1],i[10]=He[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},De[s]=r),r}("east","north"),Je=[],Ye=[],Ze=[],Ke=[],Xe=[],We=[],Qe=[],tn={x:0,y:0},en={x:0,y:0},nn=Math.PI/180;let rn;const sn={width:100,height:10};let on=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),on=!0}catch(t){on=!1}function an(){if(!rn){const{width:t,height:e}=sn;on?rn=new OffscreenCanvas(t,e):(rn=document.createElement("canvas"),rn.width=t,rn.height=e)}return rn}class cn{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,s=t.length;e<s;e++){const s=t[e][0];n=Math.min(s,n),r=Math.max(s,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},sn,e),this.o()}getImageData(){return this.imgData}o(){const t=an(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const s=r.createLinearGradient(0,0,t.width,0),{colors:i,valueOffset:o}=this;for(let t=0,e=i.length;t<e;t++){const[e,n]=i[t],r=(e-this.min)/o;s.addColorStop(r,n)}r.fillStyle=s,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var ln;function hn(t){return null==t}function un(t){return!hn(t)}function fn(t){return""===t}function dn(t,e){var n,r,s;if(Mn(t)){var i,o=t.stops&&"object"==typeof t.stops[0][0],a=o||un(t.property),c=o||!a,l=t.type||e||"exponential";if("exponential"===l)i=yn;else if("interval"===l)i=pn;else if("categorical"===l)i=mn;else if("identity"===l)i=wn;else if("color-interpolate"===l)i=gn;else{if("calculate-expression"!==l)throw new Error('Unknown function type "'+l+'"');i=vn}if(o){var h={},u=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===h[f[0].zoom]&&(h[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),h[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in h)u.push([h[t].zoom,dn(h[t])]);n=function(e,n){const r=yn({stops:u,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,s=!1}else c?(n=function(e){const n=i(t,e);return"function"==typeof n?n(e):n},r=!0,s=!1):(n=function(e,n){const r=i(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,s=!0)}else n=function(){return t},r=!0,s=!0;return n.isZoomConstant=s,n.isFeatureConstant=r,n}function mn(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function pn(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function yn(t,e){for(var n=un(t.base)&&!fn(t.base)?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:Tn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(ln=new Map);const bn={width:100,height:1};function gn(t,e){const n=t.stops;if(n&&n.length>1){let t;if(ln){const e=JSON.stringify(n);if(!ln.has(e)){const t=new cn(n,bn);ln.set(e,t)}t=ln.get(e)}else t=new cn(n,bn);const[r,s,i,o]=t.getColor(e);return[r/255,s/255,i/255,o/255]}return n&&1===n.length?n[0][1]:null}function wn(t,e){return n=e,r=t.default,un(n)?n:un(r)?r:un(s)?s:null;var n,r,s}function vn(t,e){const n=String(t.property),r=t.expression,s=e;function i(e){return hn(e)||fn(e)||isNaN(e)?t.default:e}if(!un(e)||fn(e)||isNaN(e)||e<0)return i(t.default);{const e=function t(e,n,r){const s=Number(r),i=String(n);return Array.isArray(e)?e.map((e=>t(e,i,s))):e===i?s:e}(r,n,s);return i(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const s=n.slice(1).map((t=>e(t)));switch(r){case"+":return s.reduce(((t,e)=>t+e),0);case"-":return s.reduce(((t,e)=>t-e));case"*":return s.reduce(((t,e)=>t*e),1);case"/":return s.some((t=>0===t))?t.default:s.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function Tn(t,e,n,r,s,i){return"function"==typeof s?function(){var o=s.apply(void 0,arguments),a=i.apply(void 0,arguments);return Tn(t,e,n,r,o,a)}:s.length?function(t,e,n,r,s,i){var o=[];for(let a=0;a<s.length;a++)o[a]=_n(t,e,n,r,s[a],i[a]);return o}(t,e,n,r,s,i):_n(t,e,n,r,s,i)}function _n(t,e,n,r,s,i){var o,a=r-n,c=t-n;return s*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+i*o}function Mn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function On(t){return An(t,"exponential")}function An(t,e){if(!Mn(t))return function(){return t};let n=!0,r=!0;const s=(t=JSON.parse(JSON.stringify(t))).stops;if(s)for(let t=0;t<s.length;t++)if(Mn(s[t][1])){const i=An(s[t][1],e);n=n&&i.isZoomConstant,r=r&&i.isFeatureConstant,s[t]=[s[t][0],i]}const i=dn(t,e);return i.isZoomConstant=n&&i.isZoomConstant,i.isFeatureConstant=r&&i.isFeatureConstant,i}const{getTextureMagFilter:xn,getTextureMinFilter:In,getTextureWrap:Sn,getMaterialType:Cn,getMaterialFormat:kn,getPrimitive:Nn,getUniqueREGLBuffer:Ln,getArrayType:En}=n.REGLHelper,Rn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Pn=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Un,logoutIBLResOnCanvas:Bn,getIBLResOnCanvas:Gn,getPBRUniforms:Dn}=n.pbr.PBRUtils,Fn={factor:0,units:0},jn=[1,1,1,1],zn=[0,0,0],Hn={specularStrength:0,materialShininess:1},qn=[1,1,1],$n=r.identity([]),Vn=[0,0,0],Jn=[0,0],Yn=[],Zn=t=>t.material instanceof n.PhongMaterial,Kn=t=>t.material instanceof n.pbr.StandardMaterial,Xn=[],Wn=new t.Coordinate(0,0),Qn=new t.Point(0,0),tr=new t.Point(0,0),er=new t.Point(0,0),nr=[],rr=[],sr=[],ir=[],or=[],ar=[],cr=[],lr=[],hr=[],ur=[],fr=[],dr=[],mr=[],pr=[],yr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},br=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],gr=function(t,e){const n=2*Math.PI/t,r=[],s=[];for(let s=0;s<=t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=i,r[3*s+2]=o}for(let s=t;s<=2*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=o,r[3*s+1]=t,r[3*s+2]=i}for(let s=2*t;s<=3*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=o,r[3*s+2]=i}const i=r.length/3-1;for(let e=0;e<i;e++)e!==t-1&&e!==2*t-1&&(s[2*e]=e,s[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),s.push(i+1,i+2),s.push(i+1,i+3),s.push(i+1,i+4),{vertices:r,indices:s}}(100,1),wr=[0,0,0,1],vr=[1,1,1];class Tr{constructor(t,e){this.h=e,this.u=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.m=t,this.p=new n.Renderer(t),this.v={},this.T={},this._={},this.M={},this.O={},this.A={},this.I=new n.Scene,this.S=new n.Scene,this.C=new n.Scene,this.k=new n.Scene,this.N=new n.ResourceLoader(t.texture(2)),this.L=(...t)=>this.R.call(this,...t),this.P=new n.KHRTechniquesWebglManager(this.m,this.U(),this.N);const r=this.getMap();this.B=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.M}getPNTSMeshes(){return this._}getB3DMMeshes(){return this.T}getPaintedMeshes(){return this.G}getMap(){return this.h.getMap()}paint(t,e,n){const o=n&&n.renderTarget,a=n&&n.sceneFilter,c=this.getMap();if(!t.length||!c)return null;const l=this.D(),h=c.projViewMatrix,u=[],f=[],d=[],m=[],p=[];for(let e=0,i=t.length;e<i;e++){const i=t[e].data.node;let o=this.F(i);if(!o)continue;const a=this.h.j(i.H),c=a.debugNodes,l=a.heightOffset||0,b=a.coordOffset||Jn;this.O[i.id]&&(o=this.O[i.id],o=It(o));let g=a.polygonOffset||Fn;bt(g)&&(g=g()),Array.isArray(o)||(u[0]=o,o=u);for(let u=0,w=o.length;u<w;u++){if(!o[u]||!o[u].isValid||!o[u].isValid())continue;const w=o[u].properties.magic;if(o[u].properties.heightOffset===l&&o[u].properties.coordOffset[0]===b[0]&&o[u].properties.coordOffset[1]===b[1]||(this.q(o[u]),o[u].$=r.copy([],o[u].localTransform)),o[u].V=i,"b3dm"===w){if(o[u].getBoundingBox&&!y(h,o[u].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=o[u].geometry.properties;if(t&&e){const t=o[u].properties.node.H;this.J&&this.J[t]?s.highlightMesh(this.m,o[u],this.J[t],this.Y,e):this.J&&this.J[t]||s.highlightMesh(this.m,o[u],null,this.Y,e),s.showOnly(this.m,o[u],this.Z&&this.Z[t],this.K,e)}if(c&&c.length&&c.indexOf(o[u].V.id)<0)continue;n&&n.bloom&&o[u].properties.hlBloomMesh&&(o[u].properties.hlBloomMesh.properties.depthFunc="always",d.push(o[u].properties.hlBloomMesh)),d.push(o[u])}else"pnts"===w?m.push(o[u]):"i3dm"===w&&p.push(o[u]);o[u].properties.isLeaf=t[e].leave,o[u].properties.branchRootId=t[e].branchRootId;const v=255-t[e].selectionDepth;o[u].properties.selectionDepth=v,o[u].properties.polygonOffset=g;const T=void 0===a.cullFace||!!a.cullFace;o[u].properties.cullFace=T;const _=o[u].properties.hlBloomMesh;if(_){const n=_.properties;n.branchRootId=t[e].branchRootId,n.selectionDepth=v,n.polygonOffset=g,n.cullFace=T}t[e].leave||f.push(o[u]),this.X(o[u]),this.W(o[u],i)}}let b=0;const g=this.P.getExcludeFilter();i.setIncludeUniformValues(l,n),b+=this.tt(this.et,l,[a,Zn,g],o,f,d,p),b+=this.tt(this.nt,l,[a,Kn,g],o,f,d,p),this.P.forEachShader(((t,e,n)=>{const r=this.D(n);b+=this.tt(t,r,[a,e],o,f,d,p)})),this.S.setMeshes(m);const w=this.rt();return b+=this.p.render(this.st,w,this.S,o&&o.fbo),this.G={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},this.k.setMeshes(e),this.p.render(this.it,l,this.k,o&&o.fbo),b}prepareRender(t){this.ot(t)}ot(t){t&&t.states&&t.states.includesChanged&&(this.nt.dispose(),delete this.nt,this.et.dispose(),delete this.et),this.ct(t)}tt(t,e,n,r,s,i,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1,e.cullFace="back";const a=r&&r.fbo;let c=0;const l=[],h=[];let u=!1,f=i[0]&&i[0].properties.branchRootId;for(let n=0;n<i.length;n++){const{branchRootId:r}=i[n].properties;r!==f&&(u?(h.length&&(c+=this.lt(t,e,a,!1,h),h.length=0),c+=this.lt(t,e,a,u,l)):Nt(h,l),f=r,u=!1,l.length=0),l.push(i[n]),i[n].properties.selectionDepth<255&&(u=!0),n===i.length-1&&(u||(Nt(h,l),l.length=0),h.length&&(c+=this.lt(t,e,a,!1,h)),c+=this.lt(t,e,a,u,l))}return this.I.setMeshes(i.filter((t=>t.properties.isLeaf))),this.C.setMeshes(o),c+=this.p.render(t,e,this.C,r&&r.fbo),c}lt(t,e,n,r,s){return s.length?(this.I.setMeshes(s),e.stencilEnable=!1,r&&(this.ht(n),e.stencilEnable=!1,e.cullFace="front",this.p.render(t,e,this.I,n),e.cullFace="back",e.stencilEnable=!0),this.p.render(t,e,this.I,n)):0}ht(t){this.m.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.I.getMeshes()}getCurrentI3DMMeshes(){return this.C.getMeshes()}ut(t,e){return e.V.ft-t.V.ft}deleteTile(t){const e=t.node;e.dt&&(e.dt.geometry.dispose(),e.dt.dispose(),delete e.dt);const n=e.id;this.yt(n)}yt(t){const e=this.T[t]||this._[t]||this.M[t]||this.O[t]||this.v[t];this.O[t]?this.bt(t):e&&(this.gt(e),delete this.T[t],delete this._[t],delete this.M[t],delete this.v[t])}bt(t){let e=this.O[t];e=It(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.yt(n)}delete this.O[t]}gt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.gt(t[e]);else{s.showOnly(this.m,t),s.highlightMesh(this.m,t);const e=t.geometry.properties.url;if(e){const n=this.A[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.A[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.h;Bn(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.bt(t);this.O={};for(const t in this.T)this.yt(t);this.T={};for(const t in this._)this.yt(t);this._={};for(const t in this.M)this.yt(t);this.M={};for(const t in this.v)this.yt(t);this.v={},this.et&&(this.et.dispose(),delete this.et),this.nt&&(this.nt.dispose(),delete this.nt),this.st&&(this.st.dispose(),delete this.st),this.it&&(this.it.dispose(),delete this.it),this.P.dispose(),this.picking&&this.picking.dispose()}F(t){return this.T[t.id]||this._[t.id]||this.M[t.id]||this.O[t.id]}has(t){return this.F(t)||this.v[t.id]}q(t){const e=t.properties.magic;"b3dm"===e?this.wt(t):"i3dm"===e?this.vt(t):"pnts"===e&&this.Tt(t)}createPntsMesh(t,e,s,i){if(this._[e]){const t=this._[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c,compressed_int16_params:l}=t,h=a.POINTS_LENGTH;o.BATCH_ID||(o.BATCH_ID=new Uint8Array(h),o.BATCH_ID.fill(0));const u=new n.Geometry(o,null,h,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.m);const f={};o.POSITION?f.HAS_POSITION=1:o.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),o.RGB?f.HAS_RGB=1:o.RGBA?f.HAS_RGBA=1:o.RGB565&&(f.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,o.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),this._t(f,l),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:d,rtcCoord:m,projCenter:p}=t,y=this.h.j(c),b=new n.Mesh(u);b.properties.magic="pnts",b.properties.id=e,b.properties.node=s,b.properties.count=h,b.properties.batchTable=t.batchTable,b.properties.batchTableBin=t.batchTableBin,b.properties.serviceIndex=c,b.properties.rtcCoord=m,b.properties.rtcCenter=d,b.properties.projCenter=p,b.setDefines(f),b.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:y&&y.pointColor||[1,1,1,1]}));const g=this.getMap();let w=null,v=null;b.setFunctionUniform("pointSize",(function(){if(!y)return 2;if(Mn(y.pointSize)){const t=JSON.stringify(y.pointSize);t!==w&&(v=On(y.pointSize),w=t);return v(g.getZoom())}return y.pointSize||2}));let T=null,_=null;return b.setFunctionUniform("pointOpacity",(function(){if(!y)return 1;if(Mn(y.pointOpacity)){const t=JSON.stringify(y.pointOpacity);t!==T&&(_=On(y.pointOpacity),T=t);return _(g.getZoom())}return y.pointOpacity||1})),this.Mt(b,l),this.Tt(b),b.$=r.copy([],b.localTransform),this._[e]=b,i(null,{id:e,mesh:[b]}),[b]}Tt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.Ot(e,n,s,r.H),t.setLocalTransform(e)}createI3DMMesh(t,e,s,i){if(this.M[e]){const t=this.M[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.v[e]||i(null,{id:e,mesh:t}),t}const c=this.h.j(s.H),l=this.At(s.xt),{i3dm:h,featureTable:u,gltf:f,batchTable:d,batchTableBin:m,count:p}=t,y=u.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:g,projCenter:w}=t,v=this.It(ir,s,b,g);$e(v,Vn,v);const T=r.getRotation(or,v);o.normalize(T,T);const _=r.getScaling(ar,v),M=r.fromScaling(cr,_),O=this.St(lr,w,s),A=this.Ct(fr),x=this.kt(dr,g),I=a.div(mr,x,A),S=r.fromScaling(pr,I),{POSITION:C,NORMAL_UP:k,NORMAL_RIGHT:N,SCALE:L,SCALE_NON_UNIFORM:E}=h,R=this.getMap().getRenderer().isWebGPU()?Float32Array:Uint16Array,P={"instance_vectorA":new Float32Array(4*y),"instance_vectorB":new Float32Array(4*y),"instance_vectorC":new Float32Array(4*y),"aPickingId":new R(y)};for(let t=0;t<y;t++)P.aPickingId[t]=t;const U=new Float32Array(3),B=new Float32Array(3),G=[],D=new Float32Array(1),F=new Float32Array(3),j=[],z=[],H=[],q=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?$t.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);l.set(s),e(new c(l.buffer),t),s.set(l)}}(C,((t,e)=>{k?(te(B,N,e),te(U,k,e),a.cross(G,B,U),a.normalize(G,G),xt(j,B,0),xt(j,U,1),xt(j,G,2),o.fromMat3(z,j),o.normalize(z,z),o.multiply(z,T,z)):o.identity(z),L?(te(D,L,e),a.set(H,D[0],D[0],D[0])):E?(te(F,E,e),a.set(H,...F)):a.set(H,1,1,1),r.fromRotationTranslationScale(q,z,t,H),ee(P.instance_vectorA,e,q,0),ee(P.instance_vectorB,e,q,1),ee(P.instance_vectorC,e,q,2)}));const $={};for(const t in P)$[t]={buffer:this.m.buffer({dimension:P[t].length/y,data:P[t],name:t}),divisor:1};const V=c.shader||"pbr";let J=0,Y=!0;const Z=[],K=[];return Vt(f,((t,i,o,a)=>{const c=this.Nt(t,i,o,a,s,!0,V,K),{geometry:h,material:f}=c;f&&!f.isReady()&&(Y=!1,J++);const T=new n.InstancedMesh($,y,h,f);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(T.uuid)),T.properties.magic="i3dm",T.properties.id=e,T.properties.count=p,T.properties.batchTable=d,T.properties.batchTableBin=m,T.properties.serviceIndex=s.H,T.properties.rtcCoord=g,T.properties.rtcCenter=b,T.properties.projCenter=w,T.properties.node=s;const _=this.Lt(t,h,f,s.H,a);_.MESH_ENV_EXPO=1,t.compressed_int16_params&&this.Mt(T,t.compressed_int16_params),this.Et(T,t.attributes);const A=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(A,A,t.matrices[e]);r.multiply(A,l,A),r.multiply(A,S,A),u.EAST_NORTH_UP||k?r.multiply(A,M,A):r.multiply(A,v,A),T.setPositionMatrix(A),this.vt(T,O),T.setDefines(_),T.properties.polygonOffset={offset:0,factor:0},Z.push(T),delete t.attributes,T.$=r.copy([],T.localTransform)})),_r(K),Y?(this.M[e]=Z,i(null,{id:e,mesh:Z})):(this.v[e]={meshes:Z,count:J},Z.Rt=i),Z}vt(t,e){const{rtcCoord:n,node:s,projCenter:i}=t.properties;e||(e=this.St(lr,i,s));const o=this.h.j(s.H),a=t.localTransform||[];if(o.coordOffset){const t=this.Pt(ir,s.H,n);r.multiply(a,t,e)}else r.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||Jn}St(t,e,n){r.fromScaling(t,this.Ct(fr));const s=this.Ut(rr,e,n.H);return r.multiply(t,r.fromTranslation(hr,s),t),t}createB3DMMesh(e,s,i,o){if(e.gltf&&(e.gltf.transferables=null),this.T[s]||this.v[s]){const t=this.T[s];return console.warn(`mesh with id(${s}) was already created.`),this.v[s]||o(null,{id:s,mesh:t}),t}let a;if(i.maxExtent){const e=new t.Extent(i.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:l}=c.extensions.MAPTALKS_RTC,{rtcCoord:h,center:u}=c.extensions.CESIUM_RTC,f=c.asset.sharePosition,d=this.At(i.xt),m=this.Bt(lr,f,h,u,l,i),p=this.h.j(i.H);let y=p.shader||"pbr";if(p.unlit)y="phong";else if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){y="phong";break}const b=[],g=[];let w=0,v=!0;return Vt(c,((t,o,c,T)=>{const _=this.Nt(t,o,c,T,i,!1,y,b),{geometry:M,material:O}=_;O&&!O.isReady()&&(v=!1,w++);const A=new n.Mesh(M,O);_.refMeshes||(_.refMeshes=new Set,_.refMeshes.add(A.uuid)),A.properties.magic="b3dm",A.properties.id=s,A.properties.node=i,e.batchTable&&(A.properties.batchTable=e.batchTable,A.properties.batchTableBin=e.batchTableBin),A.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,A.properties.serviceIndex=i.H;const x=this.Lt(t,M,O,i.H,T);A.setDefines(x);const I=t.compressUniforms;if(I)for(const t in I)A.setUniform(t,I[t]);t.compressed_int16_params&&this.Mt(A,t.compressed_int16_params),this.Et(A,t.attributes),a&&(x.USE_MAX_EXTENT=1,A.setUniform("maxPrjExtent",a)),A.hasFunctionUniform("polygonOpacity")||A.setFunctionUniform("polygonOpacity",(function(){return wt(p.opacity)?p.opacity:1})),A.hasFunctionUniform("polygonFill")||A.setFunctionUniform("polygonFill",(function(){return Et([],p.polygonFill||jn)})),A.material.hasFunctionUniform("hsv")||A.material.setFunctionUniform("hsv",(function(){return p.hsv||zn}));const S=r.identity([]);if(f&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(S,S,t.matrices[e]);f&&r.multiply(S,d,S),A.properties.node=i,A.properties.projCenter=l,A.properties.nodeMatrix=S,A.properties.isSharedPosition=f,A.properties.rtcCoord=h,A.properties.rtcCenter=u,this.wt(A,m),g.push(A),delete t.attributes,A.$=r.copy([],A.localTransform)})),_r(b),v?(this.T[s]=g,o(null,{id:s,mesh:g})):(this.v[s]={meshes:g,count:w},g.Rt=o),g}Gt(t){const e=this.h.Dt(t.id);if(!e||t.dt)return;let s,i,o,a;if(e.obbox)s=e.boxPosition,i=br,o=e.boxCenter,a=vr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];s=gr.vertices,i=gr.indices,o=t,a=[n,n,n]}const c=new n.Geometry({POSITION:s},i,0,{primitive:"lines",positionAttribute:"POSITION"}),l=new n.Mesh(c,new n.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),h=[];r.fromRotationTranslationScale(h,wr,o,a),l.localTransform=h,l.$=r.copy([],h),l.properties.node=t,t.dt=l}Ft(t){t.dt&&(t.dt.geometry.dispose(),t.dt.dispose(),delete t.dt)}Mt(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}wt(t,e){const{isSharedPosition:n,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Bt(e||lr,n,s,i,o,c));const l=t.localTransform||r.identity([]);r.multiply(l,e,a);const h=this.h.j(c.H);if(h.coordOffset){const t=this.Pt(ir,c.H,s);r.multiply(l,t,l)}t.setLocalTransform(l),t.properties.heightOffset=h.heightOffset||0,t.properties.coordOffset=h.coordOffset&&h.coordOffset.slice(0)||Jn}Bt(t,e,n,s,i,o){if(e){const e=this.kt(dr,n),i=r.fromScaling(sr,e),a=this.It(ir,o,s,n);r.multiply(t,a,i)}else this.Ot(t,n,i,o.H);return t}Et(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}It(t,e,n,s){const i=this.getMap(),o=this.h.j(e.H).heightOffset||0,c=e.matrix?r.copy(t,e.matrix):r.identity(t);if(n){$e(c,a.transformMat4(Xn,n,c),c)}const l=function(t,e,n,r,s,i,o){e=T.copy(Je,e);const a=oe(Je,e[0]*nn,e[1]*nn,e[2]),c=v.getTranslation(Ye,n),l=r.ellipsoid;let h;h=0===T.len(c)?T.set(Ze,0,0,-6378137):fe(Ze,c),tn.x=h[0],tn.y=h[1];const u=r.project(tn,en);Ke[0]=u.x/s,Ke[1]=u.y/s,Ke[2]=(h[2]+o)*i;const f=Ve(a,l,Xe);return $e(function(t,e,n){const r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],l=t[8],h=t[9],u=t[10],f=e[0],d=e[1],m=e[2],p=e[3],y=e[4],b=e[5],g=e[6],w=e[7],v=e[8],T=r*f+o*d+l*m,_=s*f+a*d+h*m,M=i*f+c*d+u*m,O=r*p+o*y+l*b,A=s*p+a*y+h*b,x=i*p+c*y+u*b,I=r*g+o*w+l*v,S=s*g+a*w+h*v,C=i*g+c*w+u*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=C,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(v.invert(We,f),_.fromMat4(Qe,n),t),Ke,t),t}(c,s,c,i.getProjection(),i.getGLRes(),this.B,o),h=function(t,e){return T.set(t,e[12],e[13],e[14]),t}(rr,l);let u=this.h.options.offset;if(bt(u)){const t=this.h.Dt(e.id).boxCoord;u=u.call(this.h,t)}return a.set(nr,u[0],u[1],0),a.sub(h,h,nr),$e(l,h,l),l}Pt(t,e,n){const s=this.h.j(e);if(!s.coordOffset)return null;const i=this.getMap(),o=i.getGLRes();Wn.set(n[0],n[1]);const c=i.coordToPointAtRes(Wn,o,tr),l=s.coordOffset,h=Wn.set(n[0]+l[0],n[1]+l[1]),u=i.coordToPointAtRes(h,o,er),f=u.x-c.x,d=u.y-c.y,m=this.B,p=a.set(nr,f,d,(l[2]||0)*m);return r.fromTranslation(t,p)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:s}=t,i=[];for(let t=0;t<s.length;t++){const{magic:r}=s[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"i3dm"===r?this.createI3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"pnts"===r?this.createPntsMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"cmpt"===r&&this.createCMPTMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)}))}return this.O[e]=i,r(null,{id:e,mesh:i}),i}Lt(t,e,n,r,s){const i=("phong"===(this.h.j(r).shader||"pbr")?this.et:this.nt).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.jt(i,e),e.data.uvRegion&&(i.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(i.VertexNormal=1),e.data[e.desc.color0Attribute]&&(i.VertexColor=1),e.data[e.desc.uv0Attribute]&&(i.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(i.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(i.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(i.TexCoord2=1),"MESHOPT"===this.h.zt&&(i.MeshOPT_Compress=1),this.hasIBL()&&(i.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(i.HAS_WEB3D_quantized_attributes_TEXCOORD=1),i.HAS_MIN_ALTITUDE=1,this._t(i,t.compressed_int16_params);return yt(i,t.compressDefines),i}_t(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}X(t){const e=this.h.getRenderer();e&&e.updateMaskDefines(t)}jt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Nt(t,e,r,s,i,o,a,c){let l=!1;s.asset&&"S3M"===s.asset.generator&&(l=!0,s.extensions=s.extensions||{});const h=s.url+"-"+e+"-"+r;if(this.A[h])return this.A[h];let u,f;c.push(t);const d=s.materials&&s.materials[t.material],m=s.extensions&&s.extensions.KHR_techniques_webgl,p=this.h.j(i.H);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){if(this.getMap().getRenderer().isWebGPU())throw new Error("3dtiles with KHR_techniques_webgl extension is not supported in webgpu");const e=this.Ht(t,s,o,l);u=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.qt(t,o,yr);const e=p.material;u=this.$t(t.material,s,a,e||Hn,c,p)}u&&(u.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return pt(t)?.1:t})),u.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),u&&!u.isReady()?u.Vt=i.id:u||(u=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const y={geometry:f,material:u};return f.properties.url=h,this.A[h]=y,y}Ht(t,e,n,r){const{geometry:s,material:i}=this.P.createMesh(t,e,n,r);return{geometry:s,material:i}}qt(t,e,r){const s=this.getMap().getRenderer().isWebGPU(),i=t.attributes,o="COLOR_0";let a=i._BATCHID&&i._BATCHID.array;if(a&&a.byteOffset&&(a=new a.constructor(a),!s||a instanceof Float32Array||(a=new Float32Array(a))),i[o]){const t=i[o].array||i[o];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);i[o].array?(i[o].array=e,i[o].componentType=5121):i[o]=e}}const c={};let l=0,h=0;for(const t in i){const e=r[t]||t,o=e===r.POSITION;s&&n.Geometry.padGPUGLTFAttribute(i[t]),o&&(l=i[t].itemSize);const a=Ln(this.m,i[t],{dimension:i[t].itemSize,name:t});c[e]=yt({},i[t]),c[e].buffer=a,c[e].type=En(c[e].array),delete c[e].array,e===r.POSITION&&(c[e].array=i[t].array,h=i[t].array.length/3)}const u=r._BATCHID;if(!c[u]&&!e){const t=new(s?Float32Array:Uint8Array)(h);c[u]=t}const f=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,d=new n.Geometry(c,f,0,{positionSize:l,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":Nn(t.mode)});return a&&f&&(d.properties.batchIdData=a,d.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],i=t[s];let o=n.get(i);o||(o=[],n.set(i,o)),o.push(s)}return n}(a,f)),d.generateBuffers(this.m,{excludeElementsInVAO:e}),d}Ot(t,e,n,s){const i=r.identity(t),o=this.Ct(qn);return this.Ut(rr,n,s),r.translate(i,i,rr),r.scale(i,i,o),i}Ut(t,e,n){const r=this.B;Wn.x=e[0],Wn.y=e[1];const s=this._prjToPoint(Wn);let i=this.h.options.offset;bt(i)&&(i=i.call(this.h,Wn));const o=this.h.j(n).heightOffset||0;return a.set(t,s.x-i[0],s.y-i[1],r*e[2]+r*o),t}W(t,e){const n=this.h.Jt(ur,e);t.localTransform=r.multiply(t.localTransform,n,t.$)}kt(t,e){const n=this.getMap();Wn.x=e[0],Wn.y=e[1];const r=n.distanceToPointAtRes(100,100,n.getGLRes(),Wn),s=this.B;return a.set(t,r.x/100,r.y/100,s),t}ct(t){if(this.nt)return;const e={x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},s=[],o=[];this.st=new n.MeshShader({vert:ne,frag:"#define SHADER_NAME PNTS\nprecision mediump float;\nuniform float layerOpacity;\nvarying vec4 vColor;\nvoid main() {\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n if (dot(circCoord, circCoord) > 1.0) {\n discard;\n } else {\n gl_FragColor = vColor;\n }\n #ifdef HAS_LAYER_OPACITY\n gl_FragColor *= layerOpacity;\n #endif\n}\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(o,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>c.fromMat4(s,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const a={},h=[];i.fillIncludes(a,h,t);const u=this.U();this.et=new n.PhongShader({uniforms:h,defines:a,extraCommandProps:u}),this.nt=new n.pbr.StandardShader({uniforms:h,defines:a,extraCommandProps:u}),this.it=new n.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const f=this.h;Un(f.getRenderer().canvas,this.m,f.getMap()),this.picking=new n.FBORayPicking(this.p,{vert:"#include <gl2_vert>\n#define SHADER_NAME GEO_3DTILES_PICKING\nattribute vec3 aPosition;\n#if defined(HAS_COLOR)\n attribute vec4 aColor;\n#endif\n#if defined(HAS_COLOR0)\n #if COLOR0_SIZE == 3\n attribute vec3 aColor0;\n varying vec3 vColor0;\n #else\n attribute vec4 aColor0;\n varying vec4 vColor0;\n #endif\n#endif\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\n#include <line_extrusion_vert>\n#include <get_output>\n#include <fbo_picking_vert>\nvoid main() {\n mat4 localPositionMatrix = getPositionMatrix();\n vec4 localVertex = getPosition(aPosition);\n vec4 position = localPositionMatrix * localVertex;\n vec4 viewVertex = modelViewMatrix * position;\n #ifdef HAS_MASK_EXTENT\n gl_Position = projMatrix * getMaskPosition(position, modelMatrix);\n #else\n gl_Position = projMatrix * viewVertex;\n #endif\n float alpha = 1.0;\n #if defined(HAS_COLOR)\n alpha *= aColor.a;\n #endif\n #if defined(HAS_COLOR0) && COLOR0_SIZE == 4\n alpha *= aColor0.a;\n #endif\n fbo_picking_setData(gl_Position.w, alpha != 0.0);\n}\n",wgslVert:l("layer_3dtiles_picking_vert"),extraCommandProps:u,uniforms:this.nt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Yt=new n.FBORayPicking(this.p,{vert:ne,extraCommandProps:u,uniforms:this.st.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}U(){return{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},cull:{enable:(t,e)=>e.meshProperties.cullFace,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:"<=",ref:(t,e)=>e.meshProperties.selectionDepth},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,func:(t,e)=>e.meshProperties.depthFunc||"<="},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}rt(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;let i=this.h.options.opacity;return i=pt(i)?1:i,{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:a.normalize(Yn,r),layerOpacity:i}}D(){const t=this.getMap(),e=this.h,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=Gn(n),i=Dn(t,r,s),o=this.h.getRenderer().getMaskUniforms();i.minAltitude=e.options.altitude||0;let a=e.options.opacity;return a=pt(a)?1:a,i.layerOpacity=a,yt(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),i.ambientColor||(i.ambientColor=[.2,.2,.2]),yt(i,o),i}$t(t,e,r,s,i,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=yt({},s);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Zt(t,i)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Zt(e.textures[a.normalTexture.index],i);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Zt(e.textures[a.occlusionTexture.index],i);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Zt(e.textures[a.emissiveTexture.index],i);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];if(n&&n.image&&n.image.color)c.baseColorFactor=c.baseColorFactor?h.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color;else{const t=this.Zt(n,i);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.m))}}if(pt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),pt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Zt(e.textures[a.metallicRoughnessTexture.index],i);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){const t=new n.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.pbr.StandardMaterial(c);"phong"===r&&(l=n.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,f=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(l.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",f.KHR_texture_transform.rotation||0),l.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.L),l}Zt(t,e){if(!t)return null;const r={type:t.type?Cn(t.type):"uint8",format:t.format?kn(t.format):"rgba",flipY:!!t.flipY},s=t.image;if(e.push(s),s.array?r.data=s.array:s.mipmap&&(r.mipmap=s.mipmap),!r.data&&!r.mipmap)return null;if(r.width=s.width,r.height=s.height,r.mipmap&&(r.width<4||r.height<4))return null;const i=t.sampler||t.texture&&t.texture.sampler;return i&&(i.magFilter&&(r.mag=xn(i.magFilter)),i.minFilter&&(r.min=In(i.minFilter)),i.wrapS&&(r.wrapS=Sn(i.wrapS)),i.wrapT&&(r.wrapT=Sn(i.wrapT))),new n.Texture2D(r,this.N)}R({target:t}){const e=t.Vt,n=this.v[e];if(n.count--,!n.count){const t=n.meshes;this.T[e]=t,delete this.v[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}Ct(t){const e=1/this.getMap().getGLRes(),n=this.B;return t[0]=t[1]=e,t[2]=n,t}Kt(t){return this.h.Kt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),Qn)}At(t){return"Y"===t?Rn:"X"===t?Pn:$n}pick(t,e,n=3){const r=this.h;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.D(),o=this.Xt(this.picking,i,this.I,t,e,n);o&&s.push(o);const a=this.Xt(this.picking,i,this.C,t,e,n);a&&s.push(a);const c=this.rt(),l=this.Xt(this.Yt,c,this.S,t,e,n);return l&&s.push(l),s}Xt(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.h,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,s,i,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:l,pickingId:h,point:u,coordinate:f}=c,d=(0===l||l)&&t.getMeshAt(l);if(!d||!d.geometry)return null;const m=d.properties;u&&u.length&&(u[0]=Math.round(1e5*u[0])/1e5,u[1]=Math.round(1e5*u[1])/1e5,u[2]=Math.round(1e5*u[2])/1e5);const p={batchId:h},y=o.options.services,b=y&&y[d.properties.serviceIndex];if(b&&b.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=h;for(const s in t)void 0!==t[s].byteOffset?p[s]=Ce(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:u,coordinate:f}}highlight(t){this.J=t;const e=this.h.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.J=null;const t=this.h.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Z=t;const e=this.h.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Z=null;const t=this.h.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}Wt(){if(!this.G)return[];const t={},e=[];for(const n in this.G){const r=this.G[n];if(r)for(let n=0;n<r.length;n++){const s=r[n],i=s&&s.geometry;if(!s||!i)continue;const o=s.properties.serviceIndex;t[o]||(t[o]=new Set);const a=i.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function _r(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}function Mr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}const Or=[];class Ar{constructor(t,e,n,r,s){this.h=r,this.Qt=t,this.H=e,this.te=s,this.ee=n.version,t.indexOf("i3s:tileset:")<0?(this.ee<=1.6?this.ne="root":this.ne=0,n.version=this.ee):(this.ne=t.substring(12),this.ee>1.6&&(this.ne=parseInt(this.ne))),this.Qt=t,this.re=n}load(){const t=this.re,e=t.layerScene.baseUrl;if(this.ee<=1.6)return t[this.ne]&&t[this.ne].lodSelection?(this.se=t[this.ne],this.ie()):new Promise((n=>{let r=e+"/nodes/"+this.ne;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{this.se=t[this.ne],n(this.ie())}))}));if(this.ee>=1.7){if(t[this.ne])return this.se=t[this.ne],this.ie();const n=Math.floor(this.ne/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.te(this.H,s,(()=>{this.se=t[this.ne],r(this.ie())}))}))}return null}getTileset(){return this.oe}getChildrenURL(){return this.ae}ie(){const t=this.re,e=t.layerScene.baseUrl,n=this.se.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.ee<=1.6){const o=n[i].id;if(t[o])continue;const a=o;s[a]||(s[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{n()}))})),r.push(s[a]))}else{const o=n[i];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);s[a]||(s[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.te(this.H,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.ce())):this.ce()}ce(){return Promise.resolve(this.le())}he(t){Mr(this.re,t)}le(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.ue(this.se,!0)}}ue(t){const e=this.h.getRenderer(),n=this.re.projection,r=!n||n&&4326===n.wkid,s=this.ee,i=this.re,o=t,a=o.obb,c=o.mbs,l={};let h;if(c)h=T.set([],c[0],c[1],c[2]),r||(h=e.fe(h,h)),h=xr([],h[0],h[1],h[2]),l.sphere=[...h,c[3]];else if(a){h=T.set([],a.center[0],a.center[1],a.center[2]),r||(h=e.fe(h,h)),h=xr([],h[0],h[1],h[2]);const t=function(t,e,n){const r=_.fromQuat([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(h,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],s=t[4]+t[7]+t[10],i=t[5]+t[8]+t[11];T.set(Or,n,s,i);const o=T.len(Or);l.sphere=[...h,o]}let u=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===i.lodSelectionMetricType){u=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(u=f/o.lodSelection[t].maxError);(u===1/0||isNaN(u))&&(u=1e5);const d=16*u,m=v.identity([]),p=o.children;let y;if(p){y=[];const t=this.re;for(let e=0;e<p.length;e++){const n=s<=1.6?p[e].id:p[e];if(!t[n]){y=null;break}y.push(this.ue(t[n]))}}const b={refine:"REPLACE",boundingVolume:l,transform:m,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!y?b.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}),y&&y.length&&(b.children=y),b}getJSON(){return this.se}}function xr(t,e,n,r){return oe(t,vt(e),vt(n),r)}const Ir=!!Dt.ktx2,Sr=r.identity([]),Cr=(()=>{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 kr(t){return t.indexOf("i3s:mesh")>=0}const Nr=9;function Lr(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Nr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let h=!1;const u=Sr;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;i&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let s=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(s){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",i&&(s+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+s,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}l.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions,o=(e.layerScene.store||{}).textureEncoding,u=t[f.definition],{geometryBuffers:m}=u;h=r&&2===m.length;const p=Dt.draco&&h?m[1]:m[0],y=Dt.draco&&h?1:0;let b=c+`/nodes/${f.resource}/geometries/`+y;i&&(b+=".bin");const g={geometry:{url:b,info:p}};if(s&&Cr&&h&&!Dt.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const w=e.layerScene.materialDefinitions,v=e.layerScene.textureSetDefinitions;let T,_=0;if(d&&(_=w[d.definition]),w){T=function(t,e,n,r,s,i,o){const a=JSON.parse(JSON.stringify(e));return Er(t,a,n,r,s,i,o),a}(o,_,v,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};g.material=T,l.push(g)}return{dracoCompression:h,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function Er(t,e,n,r,s,i,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],l="images/"+c.formats[0].format,h=Pr(c.formats,i,t),u={url:r+`/nodes/${s}/textures/${h.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:h.format,mimeType:l};if(o){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}u.url+="."+t}e[a]=u}else gt(e[a])&&Er(t,e[a],n,r,s,i,o)}const Rr={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function Pr(t,e,n){if(n&&n.length){const e=n[n.length-1],r=Rr[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",Rr,"current textureEncoding:",e)}for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&Ir)return t[n]}return null}const{Ajax:Ur}=Ft(),Br=new t.Coordinate(0,0),Gr=new t.Coordinate(0,0),Dr=new Set,Fr=[],jr=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.de(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){this.data.get(n.value).current&&t.Util.warnOnce(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`);const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.de(t,e),this}de(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(t.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let zr=0;class Hr extends(u(f(t.renderer.LayerAbstractRenderer))){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>jr.max&&jr.setMaxSize(e),this.tileCache=jr,zr++,this.tilesLoading={},this.me={},this.pe=[],this.te=(...t)=>this.ye.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return Fr;const t=this.painter.getPaintedMeshes();if(!t)return Fr;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&Nt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&Nt(e,r.filter((t=>!(!t||!t.geometry)))),s.length&&Nt(e,s.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.pe.length||super.needToRedraw())}getFrameTimestamp(){return this.be}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.be=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:s}=this.layer.getTiles(),i=s.length;if(!s||!i)return void this.completeRender();this.painter.prepareRender(e),this.ge(),this.we(e);const{selectedTiles:o,requests:a}=this.ve(r,s);a.length&&this.loadTiles(a),this.Te(o,e),this._e(),a.length||this.completeRender()}ve(t,e){let n=[];this.Me();let r=0;const s=this.Oe(),i={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const s=e[t],c=s.node;if(i[c.id])continue;i[c.id]=1;let l=!1;const h=this.getCachedTile(c.id);if(this.Ae(c.id)?(r++,l=a=!0,this.tilesLoading[c.id].current=!0):h?(this.getTileOpacity(h)<1&&(l=a=!0),o=!0,s.selected=!0,s.data=h):this.painter.has(c)||(l=a=!0,n.push(c)),!l)continue;if(this.xe(s))o=!0;else{this.Ie(s).length&&(o=!0)}}const c=o?this.Se(t):[];if(n.length>1&&(n.sort(qr),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c}}Se(t){const e=[];let n,r;const s=[t],i=[];for(;s.length>0||i.length>0;){if(i.length>0){const t=i[i.length-1];if(t.Ce===s.length){i.pop(),t===n&&(t.leave=!0),t.branchRootId=r,e.push(t),0===i.length&&(r=null);continue}}const t=s.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)t.leave=!0,t.selectionDepth=i.length,t.branchRootId=r,e.push(t);else{if(t.selectionDepth=i.length,n=t,0===o.length){t.leave=!0,t.branchRootId=r,e.push(t);continue}0===i.length&&(r=t.node.id),i.push(t),t.Ce=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return e}xe(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}Ie(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.ke+1,r=[t.node];for(;r.length>0;){const s=r.pop().children;for(let i=0,o=s.length;i<o;i++){if((!s[i].content||!s[i].content.url)&&s[i].children&&s[i].children.length){r.push(s[i]);continue}const o=s[i].id;if(this.tileCache.has(o)){const n=this.layer.Ne(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].ke<=n&&r.push(s[i])}}return e}Te(t,e){this.tileCache.markAll(this,!1);const n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,r.renderer=this,this.tileCache.add(t[e].node.id,r);const s=r.node,i=this.layer.j(s.H);s.dt&&i.debug&&!Array.isArray(i.debug)&&n.push(s.dt)}const r=this.layer.options.services;for(let t=0;t<r.length;t++){const e=r[t],s=Array.isArray(e.debug)&&e.debug;if(s)for(const t of s){const e=this.layer.Dt(t),r=e&&e.node;r&&r.dt&&n.push(r.dt)}}const s={tiles:t};this.onDrawTileStart(s);const i=this.painter.paint(t,n,e);this.layer.fire("drawtiles",{count:i}),this.onDrawTileEnd(s),i&&this.layer.fire("canvasisdirty",{renderCount:i}),this.tileCache.shrink()}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(Ct(e)){const n=kt(e);return this.Le(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.H,r=this.Ee[n];return new Ar(e,n,r,this.layer,this.te).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Pt(e)&&!kr(e)&&(e=t.baseUrl+e),this.Le(e,null,t),null}Le(t,e,r){let s=this.Re;s||(s=n.Util.getSupportedFormats(this.gl||this.device&&this.device.wgpu),this.Re=s);const i=this.layer.j(r.H);i.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),s=[];for(let t=0;t<r.length;t++)s.push(encodeURIComponent(r[t]));return e+s.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Pe[r.H]),arraybuffer:e,rootIdx:r.H,upAxis:r.xt,transform:r.matrix,supportedFormats:s};if(kr(t)){const e=this.Ee[r.H];if(o.projection=e.projection,o.i3sInfo=Lr(t,e,this.regl||this.device,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=yt({},i),i.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s||"gltf"===s?this.pe.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Gt(t){this.painter&&this.painter.Gt(t)}Ft(t){this.painter&&this.painter.Ft(t)}we(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.pe.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.pe.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})),n++}}Ue(t,e,n,r){if(this.Be(r),n)this.onTileError(n,e);else{const n=this.Ge(r);e.memorySize=n,this.onTileLoad(t,e)}}Be(t){if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(t[e])if(Array.isArray(t[e]))this.Be(t[e]);else{const n=t[e].defines||{};n.HAS_LAYER_OPACITY=1,t[e].setDefines(n)}}else if(t)if(Array.isArray(t))this.Be(t);else{const e=t.defines||{};e.HAS_LAYER_OPACITY=1,t.setDefines(e)}}Ge(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Ge(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.De(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.Fe(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(e,n,r){if(!this.layer)return;const s=r||n.content.url,i=e&&e.message||e;e&&(404===e.status||204===e.status)||Dr.has(i)||(console.warn("failed to load 3d tile: "+s),console.warn(e),Dr.add(i)),delete this.tilesLoading[n.id],(!this.layer.options.onlyCacheNoContentTileWhenError||e&&!t.Util.isNoContentHttpCode(e.status))&&this.je(n,e),this.layer.fire("tileerror",{node:n,error:e})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return[];const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}je(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};r.renderer=this,this.tileCache.add(e.id,r)}De(e){const n={loadTime:t.Util.now(),current:!0,node:e};n.renderer=this,this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.me[e]}Me(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}initContext(){super.initContext();const t=this.layer,{regl:e,reglGL:n,device:r}=this.context;this.regl=e,this.device=r,this.gl=n;const s=e||r;this.prepareWorker(),this.canvas.pickingFBO=this.canvas.pickingFBO||s.framebuffer(this.canvas.width,this.canvas.height),this.pickingFBO=this.canvas.pickingFBO||s.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Tr(s,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:e,device:r})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new zt("@maptalks/3dtiles",t.id,n.Util.supportNPOT(this.regl||this.device)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=yt({},r),delete r.offset;const s=t.options.spatialReference;r.projection=s&&s.coordType||s&&s.projection||t.getSpatialReference().getProjection().code;const i=this.layer.getId();e.addLayer(i,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),zr--,zr||jr.reset(),this.clear(),delete this.tileCache,delete this.gl,delete this.regl,super.onRemove()}clear(){this._e(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}getTileOpacity(){return 1}getStencilValue(){return 0}_e(t){this.He||(this.He=Date.now());const e=Date.now();if(!t&&e-this.He<this.layer.options.retireInterval)return;this.He=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Oe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}qe(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let s=0;s<n.length;++s){try{r=t.getContext(n[s],e)}catch(t){}if(r)break}return r}Ae(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Ie(t,e,0,n)}ge(){if(!this.$e)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.$e){const s=this.$e[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Ut(this.layer.j(i).fetchOptions);if(n.push(Ur.getJSON(r,o).then((t=>{delete this.$e[r];const e=this.Ee[i];if(e){t.nodes?Mr(e,t.nodes):(e[t.id]=t,Mr(e,t.children));for(let t=0;t<s.length;t++)s[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}ye(t,e,n){this.$e||(this.$e={}),this.$e[e]=this.$e[e]||[],this.$e[e].rootIdx=t,this.$e[e].push(n),this.setToRedraw()}Fe(t,e,n){this.Ee||(this.Ee=[]);const r=e.H;this.Ee[r]||(this.Ee[r]={});const s=this.Ee[r],i=this.layer.j(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),s.version=+(i.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),s.projection=t.spatialReference,function(t,e,n,r,s,i,o){if(!i.layerScene){i.layerScene=e,i.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,i.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=s;if(i.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=s.lastIndexOf("/");t=e<0?"./":s.substring(0,e)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new Ar(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.te).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:s,height:i}=this.canvas;return!this.pickingFBO||r.width===s&&r.height===i||r.resize(s,i),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.J||(this.J=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.J[n];r||(r=this.J[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.J[e];n||(n=this.J[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.J)}cancelHighlight(t,e){if(!this.J)return;const n=this.J[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.J[t]=null),this.painter.highlight(this.J)}}cancelAllHighlight(){delete this.J,this.painter.cancelAllHighlight()}showOnly(t){if(this.Z||(this.Z=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Z[n];r||(r=this.Z[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Z[e];n||(n=this.Z[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Z)}cancelShowOnly(){delete this.Z,this.painter.cancelShowOnly()}Wt(){return this.painter?this.painter.Wt():[]}fe(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.Ve();return Br.set(e[0],e[1]),n.unproject(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}return Br.set(e[0],e[1]),n.getProjection().unproject(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}Je(t,e){const n=this.Ve();return Br.set(e[0],e[1]),n.project(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}Ye(t,e){const n=this.Ve();return Br.set(e[0],e[1]),n.unproject(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}Ve(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this.Ze||(this.Ze=t.SpatialReference.getProjectionInstance(e)),this.Ze}}function qr(t,e){return t.ft-e.ft}function $r(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function Vr(t,e,n){return Math.sqrt(function(t,e,n){const r=T.subtract(Jr,n,t),s=$r(Yr,e,0),i=$r(Zr,e,1),o=$r(Kr,e,2),a=T.len(s),c=T.len(i),l=T.len(o);T.normalize(s,s),T.normalize(i,i),T.normalize(o,o);const h=Xr;h[0]=T.dot(r,s),h[1]=T.dot(r,i),h[2]=T.dot(r,o);let u,f=0;h[0]<-a?(u=h[0]+a,f+=u*u):h[0]>a&&(u=h[0]-a,f+=u*u);h[1]<-c?(u=h[1]+c,f+=u*u):h[1]>c&&(u=h[1]-c,f+=u*u);h[2]<-l?(u=h[2]+l,f+=u*u):h[2]>l&&(u=h[2]-l,f+=u*u);return f}(t,e,n))}const Jr=[],Yr=[],Zr=[],Kr=[],Xr=[];const Wr=2*Math.PI;class Qr{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],s=t.west;let i=t.east;return i<s&&(i+=Wr,n<0&&(n+=Wr)),(n>s||Te(n,s,1e-14))&&(n<i||Te(n,i,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const ts=[0,0,1];function es(t,e){return oe(e,t[0],t[1],t[2])}class ns{constructor(t,e){this.normal=a.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-a.dot(e,t);return a.copy(n.normal,e),n.distance=r,n}}const rs=[],ss=[],is=[],os=[],as=[],cs=[],ls=[],hs=[],us=[],fs=[],ds=new ns([1,0,0],0),ms=[];class ps{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new Qr(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!Qr.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,s=this.westNormal,i=this.southNormal,o=this.eastNormal,c=this.northNormal,l=a.subtract(ms,t,e),h=a.dot(l,s),u=a.dot(l,i),f=a.subtract(ms,t,r),d=a.dot(f,o),m=a.dot(f,c);h>0?n+=h*h:d>0&&(n+=d*d),u>0?n+=u*u:m>0&&(n+=m*m)}const r=e[2],s=this.minimumHeight,i=this.maximumHeight;if(r>i){const t=r-i;n+=t*t}else if(r<s){const t=s-r;n+=t*t}return Math.sqrt(n)}computeBox(t){const e=this;es(Qr.southwest(t,ss),e.southwestCornerCartesian),es(Qr.northeast(t,ss),e.northeastCornerCartesian),rs[0]=t.west,rs[1]=.5*(t.south+t.north),rs[2]=0;const n=es(rs,is),r=a.cross(as,n,ts);a.normalize(e.westNormal,r),rs[0]=t.east;const s=es(rs,hs),i=a.cross(as,ts,s);a.normalize(e.eastNormal,i);const o=a.subtract(as,n,s),c=a.normalize(os,o),l=t.south;let h;if(l>0){rs[0]=.5*(t.west+t.east),rs[1]=l;const n=es(rs,us);a.copy(fs,c);const r=ns.fromPointNormal(e.southwestCornerCartesian,e.westNormal,ds);ys(us,fs,r,e.southwestCornerCartesian),h=ge(n,cs)}else h=we(Qr.southeast(t,ss),cs);const u=a.cross(ls,h,o);a.normalize(e.southNormal,u);const f=t.north;let d;if(f<0){rs[0]=.5*(t.west+t.east),rs[1]=f;const n=es(rs,us);a.scale(fs,c,-1);const r=ns.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,ds);ys(us,fs,r,e.northeastCornerCartesian),d=ge(n,cs)}else d=we(Qr.northwest(t,ss),cs);const m=a.cross(ls,o,d);a.normalize(e.northNormal,m)}}function ys(t,e,n,r){const s=t,i=e,o=n.normal,c=a.dot(o,i);if(Math.abs(c)<1e-15)return;const l=(-n.distance-a.dot(o,s))/c;return l<0?void 0:(r=a.scale(r,i,l),a.add(r,s,r))}function bs(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const gs=t.BBOXUtil,ws={"services":[],"maxGPUMemory":t.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":2,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},vs=[0,0,0],Ts=[0,0,0],_s=[0,0,0],Ms=[0,0,0],Os=[0,0,0],As=[0,0,0],xs=[0,0,0],Is=[1,1,1],Ss=[1,1,1],Cs=[0,0,0,0],ks=[],Ns=new t.Coordinate(0,0),Ls=new t.Point(0,0),Es=[0,0,0,0,0,0,0,0,0],Rs=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ps=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Bs=new t.Point(0,0),Gs=r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Ds=[0,0],Fs=[0,0,0],js=[1,1,1],zs=[0,0,0],Hs=[0,0,0],qs=[0,0,0,0],$s=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class Vs extends(d(t.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new Vs(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],n=[0,0,0]){const s=oe([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),i=Ve(s,null,[]),a=o.fromEuler([0,0,0,0],...n),c=r.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,[0,0,0],e);return r.multiply(c,i,c)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Ke(),this.Xe=new Map}Ke(){const t=this.options.services.map((t=>t.url));this.We=this.We||{},this.Pe=this.Pe||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.We[n];void 0===r&&(r=this.We[n]=this.Pe.length),this.Pe[r]=Zs(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Pe.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Qe(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Ke(),this.Qe(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(Ws(n[t].coordOffset,e.coordOffset)&&Ws(n[t].heightOffset,e.heightOffset)&&Ws(n[t].scale,e.scale)&&Ws(n[t].rotation,e.rotation)),yt(n[t],e));const s=n[t].url,i=this.We[s],o=this.Pe&&this.Pe[i];return o&&(pt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Qe(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.We[n];this.Pe[r]&&(this.Pe[r]=null),delete this.We[n],e.splice(t,1)}return this.Qe(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const s=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[s])}}return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Pe.length;t++){const n=this.Pe[t];if(n&&n.boundingVolume){const t=this.boundingVolumeToExtent(n);e._combine(t)}}return e}const n=this.Pe[e];return n&&n.boundingVolume?this.boundingVolumeToExtent(n):null}boundingVolumeToExtent(e){const n=e.boundingVolume.tn?Gs:e.matrix,r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),i=this.getRenderer();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(Tt(n[0]),Tt(n[1]),Tt(n[2]),Tt(n[3]))}if(e.boundingVolume.sphere){const o=e.boundingVolume.sphere,c=fe([],a.transformMat4([0,0,0],o,n));s&&i.Je(c,c);const l=o[3],h=r.locate(c,-l,l),u=r.locate(c,l,-l);return new t.Extent(h,u)}if(e.boundingVolume.box){const o=e.boundingVolume.box,l=a.transformMat4([0,0,0],o,n),h=new t.Coordinate(fe([],l));s&&i.Je(h,h);const u=o.slice(3);c.multiply(u,c.fromMat4([0,0,0,0,0,0,0,0,0],e.matrix),u);const f=a.length(u.slice(0,3)),d=a.length(u.slice(3,6)),m=a.length(u.slice(6,9)),p=Math.max(f,d,m),y=r.locate(h,-p,p),b=r.locate(h,p,-p);return new t.Extent(y,b)}return null}getRootTiles(){return this.Pe}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Qe(),{tiles:ks};const e=this.getMap(),n=e.cameraPosition,r=e.pointAtResToDistance(n[2],0,e.getGLRes()),s=this.nn(n);this.rn=this.rn||[0,0,0],a.set(this.rn,vt(s.x),vt(s.y),r),this.sn=oe(this.sn||[],this.rn[0],this.rn[1],this.rn[2]),this.an=2*Math.tan(.5*vt(e.getFov()));const i=e.projViewMatrix;let o;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,o=bs(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof m));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=bs(e)}catch(t){console.error(t)}}));const l={children:[],level:-1};let h=l;const u=[];for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(!n||!n.visible)continue;const r=n.service,s=[n],a=this.cn(e);for(;s.length>0;){const e=s.pop();for(e.id||this.ln(e);h.level>=e.ke;)h=h.parent;const n=this.hn(e,a,i,o,c);if(e.service=r,!(n===Qs.VISIBLE||n!==Qs.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&Xs(e))){let t=h;for(;t&&!t.content;)t=t.parent;n===Qs.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.un(u,t);continue}e.ft<1/0&&this.dn(e);const l=this.Ne(e,h);h.children.push(l);const f=e.children,d=f&&f.length,m=l.content;if(m&&(!d||n===Qs.SCREEN_ERROR_TOO_SMALL)&&this.un(u,l),n!==Qs.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.un(u,l),h=l;const n=f[0].parent;let r=!1;for(let i=0,o=f.length;i<o;i++){if(n){const e=t.getCachedTile(f[i].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[i].parent=e,f[i].xt=e.xt,f[i].baseUrl=e.baseUrl;const t=f[i].content&&(f[i].content.url||f[i].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[i].baseUrl=e.baseUrl:Pt(t)?f[i].content.url=e.baseUrl+t:f[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}s.push(f[i])}!r&&m&&this.un(u,l)}}}return{root:l,tiles:u}}un(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return Js(n,e,r)<=0;if(n.box)return 0===Ys(n,e,r)}return!1}(this.rn,this.sn,n,r)||t.push(e)}Ne(t,e){return{id:t.id,node:t,children:[],level:t.ke,parent:e,content:t.content&&t.content.url}}ln(e){const n=this.getId();e.id=n+":"+t.Util.GUID(),e.matrix=e.transform||r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e.mn=this.pn(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=r.multiply(e.matrix,e.parent.matrix,e.matrix)),e.H=e.parent.H,void 0===e.ke&&(e.ke=e.parent.ke+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri)}j(t){return this.Pe[t].service}yn(t){const e=t.boundingVolume;if(!e||e.tn&&!this.bn(t))return;const n=this.j(t.H),s=n.heightOffset||0,i=this.options.offset,o=bt(i)||i[0]||i[1],c=n.coordOffset||Ds;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!e.tn&&(!t.boundingVolume||!s&&0!==s&&r.exactEquals(t.matrix,Gs)&&!o&&c===Ds))return;e.box&&e.region&&delete e.region;const{region:l,box:h,sphere:u}=e;if(e.coordOffset=[c[0],c[1]],e.heightOffset=s,l){e.originalVolume||(e.originalVolume=l.slice(0));const t=e.originalVolume,n=this.gn([Tt(t[0]),Tt(t[1])]);l[0]=vt(n.x+c[0]),l[1]=vt(n.y+c[1]);const r=this.gn([Tt(t[2]),Tt(t[3])]);l[2]=vt(r.x+c[0]),l[3]=vt(r.y+c[1]),l[4]=t[4]+s+(c[2]||0),l[5]=t[5]+s+(c[2]||0)}else if(h||u){e.originalVolume||(e.originalVolume=(h||u).slice(0));const n=h||u,r=e.originalVolume,i=a.transformMat4(vs,r,t.matrix),o=fe(Ts,i),l=this.gn([o[0]+c[0],o[1]+c[1]]);o[0]=l.x,o[1]=l.y,o[2]+=s+(c[2]||0),oe(n,vt(o[0]),vt(o[1]),o[2])}e.tn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}bn(t){const e=t.boundingVolume,n=this.j(t.H),r=n.heightOffset||0,s=n.coordOffset||Ds;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}pn(t){return void 0===t.geometricError||!t.boundingVolume}dn(t){let e=t.parent;for(;e&&e.mn&&!(e.ft<=t.ft);)e.ft=t.ft,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.Qe()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const s=(t.asset&&t.asset.gltfUpAxis||e&&e.xt||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const i=n.indexOf("realspace/")>-1;0===e.ke&&t.asset&&t.asset.s3mType&&i&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.xt=s,e){const n=e.boundingVolume,s=e.wn;s&&delete e.wn,yt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);let i=t.root.transform;if(s){const t=this.j(e.H);t.ecefTransform&&(i=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,i||Gs))}i&&(e.parent?o||(e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,i)):e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.matrix,i)),delete e.content,t.root.content&&(e.content=t.root.content),e.mn=this.pn(e);const a=e.content&&(e.content.url||e.content.uri);a&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&a&&!Ct(a)&&Pt(a)&&(e.content.url=e.baseUrl+a),t.root&&!e.parent&&this.vn(e)}this.Qe(),this.fire("loadtileset",{tileset:t,index:e&&e.H,url:n})}Tn(t,e,n){if(!t.extent||!gs)return!0;const r=t.extent;if(qs[0]=r.xmin,qs[1]=r.ymin,qs[2]=r.xmax,qs[3]=r.ymax,e){if(!gs.bboxIntersect(qs,e))return!1}if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||gs.bboxInMask(qs,e))return!0}return!1}return!0}hn(t,e,n,r,s){if(!this.Tn(t,r,s))return Qs.OUT_OF_FRUSTUM;if(t.ft=1/0,0===t.ke||t.mn)return this.vn(t),Qs.VISIBLE;if(this.yn(t),!this._n(t,e,n))return Qs.OUT_OF_FRUSTUM;if(0===t.geometricError)return Qs.VISIBLE;let i=this.j(t.H).maximumScreenSpaceError;null==i&&(i=16);let o=this.Mn(t);return 0===o&&t.parent&&(o=.5*(t.parent.On||0)),o>=i?Qs.VISIBLE:Qs.SCREEN_ERROR_TOO_SMALL}Kt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.coordToPointAtRes(e,r.getGLRes(),n)}_n(t,e,n){const r=t.id;let s=this.Xe.get(r);const{boundingVolume:i}=t,o=i.region,a=i.box,c=i.sphere,l=this.An(t.H),h=this.getRenderer();s&&s.version===l.version||(o?s=this.xn(t):a?s=this.In(t):c&&(s=this.Sn(t)),s&&this.Xe.set(r,s),s.version=l.version,t.dt&&(h.Ft(t.dt),delete t.dt));this.j(t.H).debug&&(this.Xe.get(r).node=t,h.Gt(t));const u=s.obbox;return u?b(n,u):!!c&&g(n,s.sphereBox)}xn(e){const n=this.getMap(),s=n.getGLRes(),i=e.boundingVolume.region;let{ws:o,en:c}=function(t){const e=t[0],n=t[1],r=t[2],s=t[3],i=t[4],o=t[5],a=oe([],e,n,i),c=oe([],r,s,o),l=fe(a,a),h=fe(c,c);return{ws:l,en:h}}(i);o=new t.Coordinate(o),c=new t.Coordinate(c);const l=n.coordToPointAtRes(o,s);l.z=n.altitudeToPoint(o.z,s);const h=n.coordToPointAtRes(c,s);h.z=n.altitudeToPoint(c.z,s);const u=[h.x,l.y,h.z,h.x,h.y,h.z,l.x,h.y,h.z,l.x,l.y,h.z,h.x,l.y,l.z,h.x,h.y,l.z,l.x,h.y,l.z,l.x,l.y,l.z],f=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],d=this.An(e.H);e!==d||d.Cn||(d.Cn=f);const m=this.Jt([],e),p=r.exactEquals(Gs,m);if(!p){a.transformMat4(f,f,m);const t=vs;for(let e=0;e<u.length;e+=3){let n=a.set(t,u[e],u[e+1],u[e+2]);p||(n=a.transformMat4(n,n,m)),u[e]=n[0],u[e+1]=n[1],u[e+2]=n[2]}}const y=n.pointAtResToCoord(new t.Point(f),s);y.z=(o.z+c.z)/2;const b=this.kn(u,f);for(let t=0;t<u.length;t++)u[t]-=f[t%3];return{obbox:b,boxPosition:u,boxCenter:f,boxCoord:y}}In(t){const e=this.getRenderer(),n=this.getMap(),s="identity"===n.getProjection().code.toLowerCase(),i=n.getGLRes(),{boxCenter:o,boxCoord:c}=this.Nn(t),l=t.boundingVolume.box,h=this.Ln(l,t.matrix),u=(d=l,function(t,e,n,r,s,i,o,a,c,l,h,u,f,d,m,p,y){return t[0]=e||0,t[1]=i||0,t[2]=l||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=h||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=u||0,t[11]=0,t[12]=s||0,t[13]=c||0,t[14]=f||0,t[15]=y,t}([],(f=h)[0],f[3],f[6],d[0],f[1],f[4],f[7],d[1],f[2],f[5],f[8],d[2],0,0,0,1));var f,d;const m=this.Jt([],t),p=r.exactEquals(Gs,m);p||a.transformMat4(o,o,m);const y=[],b=vs;for(let t=0;t<$s.length;t+=3){b[0]=$s[t],b[1]=$s[t+1],b[2]=$s[t+2],a.transformMat4(b,b,u),fe(b,b),s&&e.Je(b,b);const r=Ns.set(b[0],b[1],b[2]);n.coordToPointAtRes(r,i,Ls);let o=a.set(b,Ls.x,Ls.y,n.altitudeToPoint(r.z,i));p||(o=a.transformMat4(o,o,m)),y[t]=o[0],y[t+1]=o[1],y[t+2]=o[2]}const g=this.kn(y,o);for(let t=0;t<y.length;t++)y[t]-=o[t%3];return{obbox:g,boxPosition:y,boxCenter:o,boxCoord:c}}Sn(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=e.boundingVolume.sphere,o=i;let a=vs;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:fe(a,o),s&&r.Je(a,a);const c=new t.Coordinate(a),l=this.Kt(c,Ls).toArray();l[2]=n.altitudeToPoint(c.z,n.getGLRes());const h=this.En(c);return{boxCenter:l,boxCoord:c,sphereBox:[l,i[3]*h[2]]}}kn(t,e){const n=Ks(Os,t,0,1,4,5),r=Ks(As,t,0,3,4,7),s=Ks(xs,t,0,1,2,3);return[...e,...a.sub(vs,n,e),...a.sub(Ts,r,e),...a.sub(_s,s,e)]}Nn(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=n.getGLRes(),o=e.boundingVolume.box.slice(0,3);fe(o,o),s&&r.Je(o,o);const a=new t.Coordinate(o),c=n.coordToPointAtRes(a,i);return{boxCenter:[c.x,c.y,n.altitudeToPoint(a.z,i)],boxCoord:a}}Jt(t,e){const n=this.An(e.H),s=this.j(e.H),i=n.Cn,c=r.fromTranslation(Rs,a.set(vs,-i[0],-i[1],-i[2])),l=r.fromTranslation(Ps,i),h=s.rotation||Fs,u=o.fromEuler(Cs,...h),f=s.scale;let d;d=Array.isArray(f)?a.set(zs,f[0],f[1],f[2]):f&&a.set(zs,f,f,f)||js;const m=r.fromRotationTranslationScale(Us,u,Hs,d);return t=r.multiply(t,m,c),r.multiply(t,l,t)}vn(t){const e=this.j(t.H);if(!t.boundingVolume||this.Rn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;n?i=this.Pn(t).boxCenter:r?i=this.Un(t).boxCenter:s&&(i=this.Sn(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Bn=[a[0]||0,a[1]||0],t.Gn=o,t.Cn=i}Rn(t,e){if(!t.Bn)return!1;const n=e.coordOffset||Ds;return t.Bn[0]===n[0]&&t.Bn[1]===n[1]&&t.Gn===(e.heightOffset||0)}Un(t){return this.yn(t),this.xn(t)}Pn(t){return this.yn(t),this.Nn(t)}Ln(t,e){let n=t.slice(3,12);const r=c.fromMat4(Es,e);return n=c.multiply(n,r,n),n}En(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let r;return r=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:n.y/100,a.set(Is,n.x/100*1.01,n.y/100*1.01,r),Is}gn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(bt(n)&&(n=n.call(this,Array.isArray(e)?new t.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),s=t.coordToPointAtRes(e,r);return Ls.set(n[0],n[1]),s._sub(Ls),t.pointAtResToCoord(s,r)}return e}An(t){return this.Pe[t]}cn(e){const n=this.j(e).maxExtent;if(!n)return null;const r=this.Pe[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo((t=>this.Kt(t)))),r.maxExtent}Mn(t){const e=this.an,n=t.geometricError;if(0===n)return t.On=0,0;const s=this.j(t.H);let i=s.scale||1;if(Array.isArray(i)&&(i=a.length(i)),s.ecefTransform){const t=r.getScaling(Ss,s.ecefTransform);i*=a.len(t)}const o=this.getMap();let c;t.boundingVolume.region?c=function(t,e,n){t.Dn||(t.Dn=new ps(t.boundingVolume.region));return t.Dn.distanceToCamera(e,n)}(t,this.sn,this.rn):t.boundingVolume.sphere?c=Js(t.boundingVolume,this.sn):t.boundingVolume.box&&(c=Ys(t.boundingVolume,this.sn));const l=Math.max(Math.abs(c),1e-7),h=n*i*o.height/(l*e);return t.ft=c,t.On=h,h}Qe(){const t=this.getRenderer();t&&t.setToRedraw()}Dt(t){return this.Xe.get(t)}identify(e,n={}){const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];Array.isArray(e)&&(e=new t.Coordinate(e));const i=r.coordToContainerPoint(e);return this.identifyAtPoint(i,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&Nt(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return Nt(n,s.pick(t.x*i,t.y*i,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Wt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.J||(this.J=[]),this.J.push(t),this)}ze(){if(this.J){for(let t=0;t<this.J.length;t++)this.highlight(this.J[t]);delete this.J}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Z||(this.Z=[]),this.Z.push(t),this)}Fn(){if(this.Z){for(let t=0;t<this.Z.length;t++)this.showOnly(this.Z[t]);delete this.Z}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.Qe(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Qe(),this):this}nn(t){const e=this.getMap(),n=e.getGLRes();Bs.set(t[0],t[1]);const r=e.pointAtResToCoord(Bs,n);return"identity"===e.getProjection().code.toLowerCase()?(Ts[0]=r.x,Ts[1]=r.y,this.getRenderer().Ye(vs,Ts),r.set(vs[0],vs[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function Js(t,e,n){let r=t.sphere;n&&(r=a.transformMat4([0,0,0],r,n));const s=a.dist(r,e),i=t.sphere[3];return s<i?0:s-i}function Ys(t,e,n){const r=t.box;let s=a.set(vs,r[0],r[1],r[2]);n&&(s=a.transformMat4([0,0,0],s,n));return Vr(s,c.set(Es,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Zs(t,e,n){const s=(t=_t(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,mn:!0,service:n,visible:!!pt(n.visible)||n.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),H:e,ke:0,wn:!0,domainKey:s}}function Ks(t,e,n,r,s,i){const o=a.set(vs,e[3*n],e[3*n+1],e[3*n+2]),c=a.set(Ts,e[3*r],e[3*r+1],e[3*r+2]),l=a.set(_s,e[3*s],e[3*s+1],e[3*s+2]),h=a.set(Ms,e[3*i],e[3*i+1],e[3*i+2]);return t[0]=(o[0]+c[0]+l[0]+h[0])/4,t[1]=(o[1]+c[1]+l[1]+h[1])/4,t[2]=(o[2]+c[2]+l[2]+h[2])/4,t}function Xs(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function Ws(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?p.exactEquals(t,e):a.exactEquals(t,e):t===e}var Qs;Vs.mergeOptions(ws),Vs.registerRenderer("gl",Hr),Vs.registerRenderer("gpu",Hr),Vs.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(Qs||(Qs={}));let ti=null;function ei(){return ti||(ti={"image/crn":Dt.crn&&Dt.crn(),"image/ktx2":Dt.ktx2&&Dt.ktx2(),"image/cttf":Dt.ktx2&&Dt.ktx2(),"draco":Dt.draco&&Dt.draco()}),ti}const{Ajax:ni,GLTFLoader:ri}=Ft();class si{constructor(t,e,n){this.jn=t,this.zn=e||ri,this.Re=n,this.Hn=ei()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,s)):ni.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.qn(t,s,n,r)}))}qn(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.$n(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.zn(a,o.glb,{transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:i})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}$n(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),l=s.getUint32(20,!0),h=s.getUint32(24,!0),u=28+e;l>=570425344?(u-=8,o=a,l=c,h=0,a=0,c=0):h>=570425344&&(u-=4,o=l,l=a,h=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=Oe(t,u,a),u+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(u+=c),l>0&&(m=Ae(t,u,l),u+=l,h>0)){const e=xe(0,u,h);p=t.slice(e.offset,e.offset+e.byteLength),u+=h,f.push(p)}const y=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Se(d.BATCH_ID,t,undefined.offset,y);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:u,byteLength:s.byteLength+s.byteOffset-u}}}Vn(){return null}}const{Ajax:ii,GLTFLoader:oi}=Ft();class ai{constructor(t,e,n,r){this.jn=t,this.zn=e||oi,this.Re=n,this.Hn=ei(),this.Jn=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,s)):ii.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.qn(t,s,n,r)}))}qn(t,e,n,r,s){return this.Yn(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.Zn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})}))}Yn(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:i},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=At(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?ii.getArrayBuffer(r,{}).then((t=>this.Kn(r,{buffer:t.data,byteOffset:0},o))):ii.getJSON(r,{}).then((t=>this.Kn(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Kn(t,r,o)}}Kn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.zn(r,e,n);return s.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}}))}Zn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:h}=Ue(s,32+e,o),u={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Xn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Se(a.BATCH_ID,t,c.offset,f);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:l,batchTableBin:h,featureTable:a,i3dm:u,transferables:o}}Wn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)ci(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}Xn(t,e,n){return Pe(new Float32Array(t.length),t,e,n)}Vn(){return null}}function ci(t,e,n,r){if(t[0]=li(e,r),t[1]=li(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*hi(e),t[1]=(1-Math.abs(e))*hi(t[1])}return T.normalize(t,t)}function li(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function hi(t){return t<0?-1:1}const{Ajax:ui}=Ft();class fi{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.qn(t,e,n,r)):ui.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.qn(t,s,n,r)}))}qn(t,e,n,r){return this.Qn(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}Qn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:h}=Ue(s,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.tr||(this.tr=ei().draco),this.tr(m,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.er(t,e.attributes,c.offset,d,o,u,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Re(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?r.BATCH_ID=Se(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=di(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:l,batchTableBin:h,featureTable:a,pnts:r,transferables:o}}))}const y=this.er(t,a,c.offset,d,o,u,f);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?y.BATCH_ID=Se(a.BATCH_ID,t,c.offset,d):y.BATCH_ID=di(d);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:l,batchTableBin:h,featureTable:a,pnts:y,transferables:o})}er(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:l}=e.POSITION_QUANTIZED;c=c||0;const h=l?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Xn(l||new Uint16Array(t,c+h,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}Xn(t,e,n){return Pe(new Float32Array(t.length),t,e,n)}Vn(){return null}}function di(t){const e=St(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Re(e),array:n}}const{Ajax:mi,GLTFLoader:pi}=Ft();class yi{constructor(t,e,n,r){this.Re=n,this.jn=t,this.zn=e||pi,this.Jn=r}load(t,e,n=0,r=0,s){return e?this.qn(t,e,n,r,s):mi.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.qn(t,s,n,r)}))}qn(t,e,n,r,s){r||(r=e.byteLength);const i=this.nr(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new si(this.jn,this.zn,this.Re);else if("i3dm"===i[n].magic)r=new ai(this.jn,this.zn,this.Re,this.Jn);else if("pnts"===i[n].magic)r=new fi;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new yi(this.jn,this.zn,this.Re,this.Jn)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}nr(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=_e(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(e.transcoders){const n=t.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=e.transcoders.inject(O);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(O)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",O);export{si as B3DMLoader,yi as CMPTLoader,Vs as Geo3DTilesLayer,Rt as Geo3DTilesUtil,ve as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.124.0");
11
+ */function Ft(){return Bt().maptalks_gltf_loader}Dt.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Gt.gl_trans__coders=Gt.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${Bt.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\n;");return i+="\n("+Bt().maptalks_gltf_loader_bundle.toString()+")({});\n",i+="\n"+e.substring(r.length),i},Dt.registerTranscoder=function(t,e){Dt[t]=e},Dt.getTranscoder=function(t){return Dt[t]};const jt="undefined"==typeof document?null:document.createElement("canvas");class zt extends t.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.i=n}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const s={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(s,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!jt)return void e(new Error("There is no canvas to draw image!"));const t=this.i?n:function(t){if(Ht(t.width)&&Ht(t.height))return t;let e=t.width,n=t.height;Ht(e)||(e=qt(e));Ht(n)||(n=qt(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const s=t.src,i=s.lastIndexOf("/")+1,o=s.substring(i);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);jt.width=t.width,jt.height=t.height;const r=jt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const s=r.getImageData(0,0,t.width,t.height),i={width:t.width,height:t.height,data:new Uint8Array(s.data)};e(null,i,[i.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function Ht(t){return!(t&t-1)&&0!==t}function qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const{GLTFLoader:$t}=Ft();function Vt(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];Qt(r[n],s,t,e)}}}const Jt=[],Yt=[],Zt=[],Kt=[0,0,0],Xt=w.identity([]),Wt=[1,1,1];function Qt(t,e,n,r){const s=e.slice(0);if(t.matrix)s.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=v.fromTranslation(Jt,t.translation||Kt),n=v.fromQuat(Yt,t.rotation||Xt),r=v.fromScaling(Zt,t.scale||Wt);v.multiply(r,n,r);const i=v.multiply([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)Qt(t.children[e],s,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=s.slice(0),o=i.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function te(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?$t.getTypedArrayCtor(i):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,s*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function ee(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var ne="#include <gl2_vert>\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\nconst float SHIFT_LEFT_11 = 2048.0;\nconst float SHIFT_LEFT_5 = 32.0;\nconst float NORMALIZE_6 = 1.0 / 64.0;\nconst float NORMALIZE_5 = 1.0 / 32.0;\n#ifdef HAS_POSITION\n attribute vec3 POSITION;\n#endif\n#if defined(HAS_RGB)\n attribute vec3 RGB;\n#elif defined(HAS_RGBA)\n attribute vec4 RGBA;\n#elif defined(HAS_RGB565)\n attribute float RGB565;\n#endif\nuniform vec4 pointColor;\nuniform float pointSize;\nuniform mat4 projViewModelMatrix;\nuniform float pointOpacity;\nvarying vec4 vColor;\n#ifdef HAS_NORMAL\n #ifdef HAS_NORMAL_OCT16P\n attribute vec2 NORMAL_OCT16P;\n float signNotZero(float value) {\n return value >= 0.0 ? 1.0 : -1.0;\n }\n vec2 signNotZero(vec2 value) {\n return vec2(signNotZero(value.x), signNotZero(value.y));\n }\n vec3 octDecode(vec2 encoded, float range) {\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n return vec3(0.0, 0.0, 0.0);\n }\n encoded = encoded / range * 2.0 - 1.0;\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n if (v.z < 0.0) {\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n }\n return normalize(v);\n }\n vec3 octDecode(vec2 encoded) {\n return octDecode(encoded, 255.0);\n }\n #else\n attribute vec3 NORMAL;\n #endif\n uniform vec3 lightDir;\n uniform mat3 modelNormalMatrix;\n uniform mat4 positionMatrix;\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n return max(dot(-lightDir, normal), 0.0);\n }\n#endif\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <draco_decode_vert>\nvoid main() {\n #ifdef HAS_POSITION\n vec3 localPos = decode_getPosition(POSITION);\n #endif\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n gl_PointSize = pointSize;\n #ifdef PICKING_MODE\n fbo_picking_setData(gl_Position.w, true);\n #else\n #if defined(HAS_RGB)\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n #elif defined(HAS_RGBA)\n vColor = RGBA / 255.0 * pointOpacity;\n #elif defined(HAS_RGB565)\n float compressed = RGB565;\n float r = floor(compressed * SHIFT_RIGHT_11);\n compressed -= r * SHIFT_LEFT_11;\n float g = floor(compressed * SHIFT_RIGHT_5);\n compressed -= g * SHIFT_LEFT_5;\n float b = compressed;\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n vColor = vec4(rgb, 1.0);\n #else\n vColor = pointColor;\n #endif\n #ifdef HAS_NORMAL\n mat3 positionNormalMatrix = mat3(positionMatrix);\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n #ifdef HAS_NORMAL_OCT16P\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n #else\n vec3 localNormal = NORMAL;\n #endif\n vec3 normal = normalize(normalMatrix * localNormal);\n float colorStrength = getLambertDiffuse(lightDir, normal);\n colorStrength = max(colorStrength, 0.5);\n vColor *= colorStrength;\n #endif\n #endif\n}\n";const re=new Array(3),se=new Array(3),ie=[40680631590769,40680631590769,40408299984661.445];function oe(t,e,n,r){const s=ie,i=Math.cos(n);re[0]=i*Math.cos(e),re[1]=i*Math.sin(e),re[2]=Math.sin(n),be(re,re),T.multiply(se,s,re);const o=Math.sqrt(T.dot(re,se));var a,c,l;return c=se,l=o,(a=se)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,T.scale(re,re,r),T.add(t,se,re)}const ae=[1/6378137,1/6378137,1/6356752.314245179],ce=[1/40680631590769,1/40680631590769,1/40408299984661.445],le=new Array(3),he=new Array(3),ue=new Array(3);function fe(t,e){const n=ce,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],l=n[1],h=n[2],u=i*i*c*c,f=o*o*l*l,d=a*a*h*h,m=u+f+d,p=Math.sqrt(1/m),y=T.scale(de,e,p);if(m<s)return isFinite(p)?y:void 0;const b=r[0],g=r[1],w=r[2],v=me;v[0]=y[0]*b*2,v[1]=y[1]*g*2,v[2]=y[2]*w*2;let _,M,O,A,x,I,S,C,k,N,L,E=(1-p)*ye(e)/(.5*ye(v)),R=0;do{E-=R,O=1/(1+E*b),A=1/(1+E*g),x=1/(1+E*w),I=O*O,S=A*A,C=x*x,k=I*O,N=S*A,L=C*x,_=u*I+f*S+d*C-1,M=u*k*b+f*N*g+d*L*w;R=_/(-2*M)}while(Math.abs(_)>pe);return t[0]=i*O,t[1]=o*A,t[2]=a*x,t}(le,e,ae,n,.1);let s=T.mul(he,r,n);s=be(s,s);const i=T.sub(ue,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=Mt(T.dot(i,e))*ye(i);return t[0]=Tt(o),t[1]=Tt(a),t[2]=c,t}const de=new Array(3),me=new Array(3),pe=1e-12;function ye(t){return T.length(t)}function be(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function ge(t,e){return T.multiply(e,t,ce),T.normalize(e,e)}function we(t,e){const n=t[0],r=t[1],s=Math.cos(r),i=s*Math.cos(n),o=s*Math.sin(n),a=Math.sin(r);return e.x=i,e.y=o,e.z=a,T.normalize(e,e)}var ve=Object.freeze({__proto__:null,cartesian3ToDegree:fe,geodeticSurfaceNormal:ge,geodeticSurfaceNormalCartographic:we,normalizeCartesian:be,radianToCartesian3:oe});function Te(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function _e(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Me="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Oe(t,e,n){const r=new Uint8Array(t,e,n);return Me?JSON.parse(Me.decode(r)):JSON.parse(At(r))}function Ae(t,e,n){const r=new Uint8Array(t,e,n);return Me?JSON.parse(Me.decode(r)):JSON.parse(At(r))}function xe(t,e,n){return{offset:e,byteLength:n}}function Ie(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=Ee(i||"UNSIGNED_SHORT"),l=Ne(o);return{byteStride:0,byteOffset:s+n,itemSize:l,count:r*l,componentType:c,array:new a(e,n+s,r*l)}}function Se(t,e,n,r){const s=Ie(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function Ce(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=Ee(i||"UNSIGNED_SHORT"),c=Ne(o),l=new a(e,s,n*c);return 1===c?l[r]:l.subarray(r*c,r*c+c)}const ke={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ne(t){return t?ke[t]:1}const Le={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Ee(t){return Le[t]}function Re(t){for(const e in Le)if(t===Le[e].ctor)return Le[e].type;throw new Error("unrecognized ctor:"+t)}function Pe(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function Ue(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,l={},h={},u=null;r>0&&(l=Oe(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(h=Ae(a,e,i),e+=i);const f=xe(0,e,o);return u=a.slice(f.offset,f.offset+f.byteLength),n.push(u),{featureTable:l,featureTableBin:c,batchTable:h,batchTableBin:u}}const Be={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"}},Ge={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},De={},Fe={east:[],north:[],up:[],west:[],south:[],down:[]};let je=[],ze=[],He=[];const qe=[0,0,0];function $e(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const Ve=function(t,e){const n=Be[t][e];let r;const s=t+e;return De[s]?r=De[s]:(r=function(r,s,i){if(T.equals(r,qe))T.copy(je,Ge[t]),T.copy(ze,Ge[e]),T.copy(He,Ge[n]);else if(Te(r[0],0,1e-14)&&Te(r[1],0,1e-14)){const s=Mt(r[2]);T.copy(je,Ge[t]),T.copy(ze,Ge[e]),T.scale(ze,ze,s),T.copy(He,Ge[n]),T.scale(He,He,s)}else{ge(r,Fe.up);const s=Fe.up,i=Fe.east;i[0]=-r[1],i[1]=r[0],i[2]=0,T.normalize(Fe.east,i),T.cross(Fe.north,s,i),T.scale(Fe.down,Fe.up,-1),T.scale(Fe.west,Fe.east,-1),T.scale(Fe.south,Fe.north,-1),je=Fe[t],ze=Fe[e],He=Fe[n]}return i[0]=je[0],i[1]=je[1],i[2]=je[2],i[3]=0,i[4]=ze[0],i[5]=ze[1],i[6]=ze[2],i[7]=0,i[8]=He[0],i[9]=He[1],i[10]=He[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},De[s]=r),r}("east","north"),Je=[],Ye=[],Ze=[],Ke=[],Xe=[],We=[],Qe=[],tn={x:0,y:0},en={x:0,y:0},nn=Math.PI/180;let rn;const sn={width:100,height:10};let on=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),on=!0}catch(t){on=!1}function an(){if(!rn){const{width:t,height:e}=sn;on?rn=new OffscreenCanvas(t,e):(rn=document.createElement("canvas"),rn.width=t,rn.height=e)}return rn}class cn{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,s=t.length;e<s;e++){const s=t[e][0];n=Math.min(s,n),r=Math.max(s,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},sn,e),this.o()}getImageData(){return this.imgData}o(){const t=an(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const s=r.createLinearGradient(0,0,t.width,0),{colors:i,valueOffset:o}=this;for(let t=0,e=i.length;t<e;t++){const[e,n]=i[t],r=(e-this.min)/o;s.addColorStop(r,n)}r.fillStyle=s,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var ln;function hn(t){return null==t}function un(t){return!hn(t)}function fn(t){return""===t}function dn(t,e){var n,r,s;if(Mn(t)){var i,o=t.stops&&"object"==typeof t.stops[0][0],a=o||un(t.property),c=o||!a,l=t.type||e||"exponential";if("exponential"===l)i=yn;else if("interval"===l)i=pn;else if("categorical"===l)i=mn;else if("identity"===l)i=wn;else if("color-interpolate"===l)i=gn;else{if("calculate-expression"!==l)throw new Error('Unknown function type "'+l+'"');i=vn}if(o){var h={},u=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===h[f[0].zoom]&&(h[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),h[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in h)u.push([h[t].zoom,dn(h[t])]);n=function(e,n){const r=yn({stops:u,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,s=!1}else c?(n=function(e){const n=i(t,e);return"function"==typeof n?n(e):n},r=!0,s=!1):(n=function(e,n){const r=i(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,s=!0)}else n=function(){return t},r=!0,s=!0;return n.isZoomConstant=s,n.isFeatureConstant=r,n}function mn(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function pn(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function yn(t,e){for(var n=un(t.base)&&!fn(t.base)?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:Tn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(ln=new Map);const bn={width:100,height:1};function gn(t,e){const n=t.stops;if(n&&n.length>1){let t;if(ln){const e=JSON.stringify(n);if(!ln.has(e)){const t=new cn(n,bn);ln.set(e,t)}t=ln.get(e)}else t=new cn(n,bn);const[r,s,i,o]=t.getColor(e);return[r/255,s/255,i/255,o/255]}return n&&1===n.length?n[0][1]:null}function wn(t,e){return n=e,r=t.default,un(n)?n:un(r)?r:un(s)?s:null;var n,r,s}function vn(t,e){const n=String(t.property),r=t.expression,s=e;function i(e){return hn(e)||fn(e)||isNaN(e)?t.default:e}if(!un(e)||fn(e)||isNaN(e)||e<0)return i(t.default);{const e=function t(e,n,r){const s=Number(r),i=String(n);return Array.isArray(e)?e.map((e=>t(e,i,s))):e===i?s:e}(r,n,s);return i(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const s=n.slice(1).map((t=>e(t)));switch(r){case"+":return s.reduce(((t,e)=>t+e),0);case"-":return s.reduce(((t,e)=>t-e));case"*":return s.reduce(((t,e)=>t*e),1);case"/":return s.some((t=>0===t))?t.default:s.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function Tn(t,e,n,r,s,i){return"function"==typeof s?function(){var o=s.apply(void 0,arguments),a=i.apply(void 0,arguments);return Tn(t,e,n,r,o,a)}:s.length?function(t,e,n,r,s,i){var o=[];for(let a=0;a<s.length;a++)o[a]=_n(t,e,n,r,s[a],i[a]);return o}(t,e,n,r,s,i):_n(t,e,n,r,s,i)}function _n(t,e,n,r,s,i){var o,a=r-n,c=t-n;return s*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+i*o}function Mn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function On(t){return An(t,"exponential")}function An(t,e){if(!Mn(t))return function(){return t};let n=!0,r=!0;const s=(t=JSON.parse(JSON.stringify(t))).stops;if(s)for(let t=0;t<s.length;t++)if(Mn(s[t][1])){const i=An(s[t][1],e);n=n&&i.isZoomConstant,r=r&&i.isFeatureConstant,s[t]=[s[t][0],i]}const i=dn(t,e);return i.isZoomConstant=n&&i.isZoomConstant,i.isFeatureConstant=r&&i.isFeatureConstant,i}const{getTextureMagFilter:xn,getTextureMinFilter:In,getTextureWrap:Sn,getMaterialType:Cn,getMaterialFormat:kn,getPrimitive:Nn,getUniqueREGLBuffer:Ln,getArrayType:En}=n.REGLHelper,Rn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Pn=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Un,logoutIBLResOnCanvas:Bn,getIBLResOnCanvas:Gn,getPBRUniforms:Dn}=n.pbr.PBRUtils,Fn={factor:0,units:0},jn=[1,1,1,1],zn=[0,0,0],Hn={specularStrength:0,materialShininess:1},qn=[1,1,1],$n=r.identity([]),Vn=[0,0,0],Jn=[0,0],Yn=[],Zn=t=>t.material instanceof n.PhongMaterial,Kn=t=>t.material instanceof n.pbr.StandardMaterial,Xn=[],Wn=new t.Coordinate(0,0),Qn=new t.Point(0,0),tr=new t.Point(0,0),er=new t.Point(0,0),nr=[],rr=[],sr=[],ir=[],or=[],ar=[],cr=[],lr=[],hr=[],ur=[],fr=[],dr=[],mr=[],pr=[],yr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},br=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],gr=function(t,e){const n=2*Math.PI/t,r=[],s=[];for(let s=0;s<=t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=i,r[3*s+2]=o}for(let s=t;s<=2*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=o,r[3*s+1]=t,r[3*s+2]=i}for(let s=2*t;s<=3*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=o,r[3*s+2]=i}const i=r.length/3-1;for(let e=0;e<i;e++)e!==t-1&&e!==2*t-1&&(s[2*e]=e,s[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),s.push(i+1,i+2),s.push(i+1,i+3),s.push(i+1,i+4),{vertices:r,indices:s}}(100,1),wr=[0,0,0,1],vr=[1,1,1];class Tr{constructor(t,e){this.h=e,this.u=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.m=t,this.p=new n.Renderer(t),this.v={},this.T={},this._={},this.M={},this.O={},this.A={},this.I=new n.Scene,this.S=new n.Scene,this.C=new n.Scene,this.k=new n.Scene,this.N=new n.ResourceLoader(t.texture(2)),this.L=(...t)=>this.R.call(this,...t),this.P=new n.KHRTechniquesWebglManager(this.m,this.U(),this.N);const r=this.getMap();this.B=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.M}getPNTSMeshes(){return this._}getB3DMMeshes(){return this.T}getPaintedMeshes(){return this.G}getMap(){return this.h.getMap()}paint(t,e,n){const o=n&&n.renderTarget,a=n&&n.sceneFilter,c=this.getMap();if(!t.length||!c)return null;const l=this.D(),h=c.projViewMatrix,u=[],f=[],d=[],m=[],p=[];for(let e=0,i=t.length;e<i;e++){const i=t[e].data.node;let o=this.F(i);if(!o)continue;const a=this.h.j(i.H),c=a.debugNodes,l=a.heightOffset||0,b=a.coordOffset||Jn;this.O[i.id]&&(o=this.O[i.id],o=It(o));let g=a.polygonOffset||Fn;bt(g)&&(g=g()),Array.isArray(o)||(u[0]=o,o=u);for(let u=0,w=o.length;u<w;u++){if(!o[u]||!o[u].isValid||!o[u].isValid())continue;const w=o[u].properties.magic;if(o[u].properties.heightOffset===l&&o[u].properties.coordOffset[0]===b[0]&&o[u].properties.coordOffset[1]===b[1]||(this.q(o[u]),o[u].$=r.copy([],o[u].localTransform)),o[u].V=i,"b3dm"===w){if(o[u].getBoundingBox&&!y(h,o[u].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=o[u].geometry.properties;if(t&&e){const t=o[u].properties.node.H;this.J&&this.J[t]?s.highlightMesh(this.m,o[u],this.J[t],this.Y,e):this.J&&this.J[t]||s.highlightMesh(this.m,o[u],null,this.Y,e),s.showOnly(this.m,o[u],this.Z&&this.Z[t],this.K,e)}if(c&&c.length&&c.indexOf(o[u].V.id)<0)continue;n&&n.bloom&&o[u].properties.hlBloomMesh&&(o[u].properties.hlBloomMesh.properties.depthFunc="always",d.push(o[u].properties.hlBloomMesh)),d.push(o[u])}else"pnts"===w?m.push(o[u]):"i3dm"===w&&p.push(o[u]);o[u].properties.isLeaf=t[e].leave,o[u].properties.branchRootId=t[e].branchRootId;const v=255-t[e].selectionDepth;o[u].properties.selectionDepth=v,o[u].properties.polygonOffset=g;const T=void 0===a.cullFace||!!a.cullFace;o[u].properties.cullFace=T;const _=o[u].properties.hlBloomMesh;if(_){const n=_.properties;n.branchRootId=t[e].branchRootId,n.selectionDepth=v,n.polygonOffset=g,n.cullFace=T}t[e].leave||f.push(o[u]),this.X(o[u]),this.W(o[u],i)}}let b=0;const g=this.P.getExcludeFilter();i.setIncludeUniformValues(l,n),b+=this.tt(this.et,l,[a,Zn,g],o,f,d,p),b+=this.tt(this.nt,l,[a,Kn,g],o,f,d,p),this.P.forEachShader(((t,e,n)=>{const r=this.D(n);b+=this.tt(t,r,[a,e],o,f,d,p)})),this.S.setMeshes(m);const w=this.rt();return b+=this.p.render(this.st,w,this.S,o&&o.fbo),this.G={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},this.k.setMeshes(e),this.p.render(this.it,l,this.k,o&&o.fbo),b}prepareRender(t){this.ot(t)}ot(t){t&&t.states&&t.states.includesChanged&&(this.nt.dispose(),delete this.nt,this.et.dispose(),delete this.et),this.ct(t)}tt(t,e,n,r,s,i,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1,e.cullFace="back";const a=r&&r.fbo;let c=0;const l=[],h=[];let u=!1,f=i[0]&&i[0].properties.branchRootId;for(let n=0;n<i.length;n++){const{branchRootId:r}=i[n].properties;r!==f&&(u?(h.length&&(c+=this.lt(t,e,a,!1,h),h.length=0),c+=this.lt(t,e,a,u,l)):Nt(h,l),f=r,u=!1,l.length=0),l.push(i[n]),i[n].properties.selectionDepth<255&&(u=!0),n===i.length-1&&(u||(Nt(h,l),l.length=0),h.length&&(c+=this.lt(t,e,a,!1,h)),c+=this.lt(t,e,a,u,l))}return this.I.setMeshes(i.filter((t=>t.properties.isLeaf))),this.C.setMeshes(o),c+=this.p.render(t,e,this.C,r&&r.fbo),c}lt(t,e,n,r,s){return s.length?(this.I.setMeshes(s),e.stencilEnable=!1,r&&(this.ht(n),e.stencilEnable=!1,e.cullFace="front",this.p.render(t,e,this.I,n),e.cullFace="back",e.stencilEnable=!0),this.p.render(t,e,this.I,n)):0}ht(t){this.m.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.I.getMeshes()}getCurrentI3DMMeshes(){return this.C.getMeshes()}ut(t,e){return e.V.ft-t.V.ft}deleteTile(t){const e=t.node;e.dt&&(e.dt.geometry.dispose(),e.dt.dispose(),delete e.dt);const n=e.id;this.yt(n)}yt(t){const e=this.T[t]||this._[t]||this.M[t]||this.O[t]||this.v[t];this.O[t]?this.bt(t):e&&(this.gt(e),delete this.T[t],delete this._[t],delete this.M[t],delete this.v[t])}bt(t){let e=this.O[t];e=It(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.yt(n)}delete this.O[t]}gt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.gt(t[e]);else{s.showOnly(this.m,t),s.highlightMesh(this.m,t);const e=t.geometry.properties.url;if(e){const n=this.A[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.A[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.h;Bn(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.bt(t);this.O={};for(const t in this.T)this.yt(t);this.T={};for(const t in this._)this.yt(t);this._={};for(const t in this.M)this.yt(t);this.M={};for(const t in this.v)this.yt(t);this.v={},this.et&&(this.et.dispose(),delete this.et),this.nt&&(this.nt.dispose(),delete this.nt),this.st&&(this.st.dispose(),delete this.st),this.it&&(this.it.dispose(),delete this.it),this.P.dispose(),this.picking&&this.picking.dispose()}F(t){return this.T[t.id]||this._[t.id]||this.M[t.id]||this.O[t.id]}has(t){return this.F(t)||this.v[t.id]}q(t){const e=t.properties.magic;"b3dm"===e?this.wt(t):"i3dm"===e?this.vt(t):"pnts"===e&&this.Tt(t)}createPntsMesh(t,e,s,i){if(this._[e]){const t=this._[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c,compressed_int16_params:l}=t,h=a.POINTS_LENGTH;o.BATCH_ID||(o.BATCH_ID=new Uint8Array(h),o.BATCH_ID.fill(0));const u=new n.Geometry(o,null,h,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.m);const f={};o.POSITION?f.HAS_POSITION=1:o.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),o.RGB?f.HAS_RGB=1:o.RGBA?f.HAS_RGBA=1:o.RGB565&&(f.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,o.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),this._t(f,l),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:d,rtcCoord:m,projCenter:p}=t,y=this.h.j(c),b=new n.Mesh(u);b.properties.magic="pnts",b.properties.id=e,b.properties.node=s,b.properties.count=h,b.properties.batchTable=t.batchTable,b.properties.batchTableBin=t.batchTableBin,b.properties.serviceIndex=c,b.properties.rtcCoord=m,b.properties.rtcCenter=d,b.properties.projCenter=p,b.setDefines(f),b.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:y&&y.pointColor||[1,1,1,1]}));const g=this.getMap();let w=null,v=null;b.setFunctionUniform("pointSize",(function(){if(!y)return 2;if(Mn(y.pointSize)){const t=JSON.stringify(y.pointSize);t!==w&&(v=On(y.pointSize),w=t);return v(g.getZoom())}return y.pointSize||2}));let T=null,_=null;return b.setFunctionUniform("pointOpacity",(function(){if(!y)return 1;if(Mn(y.pointOpacity)){const t=JSON.stringify(y.pointOpacity);t!==T&&(_=On(y.pointOpacity),T=t);return _(g.getZoom())}return y.pointOpacity||1})),this.Mt(b,l),this.Tt(b),b.$=r.copy([],b.localTransform),this._[e]=b,i(null,{id:e,mesh:[b]}),[b]}Tt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.Ot(e,n,s,r.H),t.setLocalTransform(e)}createI3DMMesh(t,e,s,i){if(this.M[e]){const t=this.M[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.v[e]||i(null,{id:e,mesh:t}),t}const c=this.h.j(s.H),l=this.At(s.xt),{i3dm:h,featureTable:u,gltf:f,batchTable:d,batchTableBin:m,count:p}=t,y=u.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:g,projCenter:w}=t,v=this.It(ir,s,b,g);$e(v,Vn,v);const T=r.getRotation(or,v);o.normalize(T,T);const _=r.getScaling(ar,v),M=r.fromScaling(cr,_),O=this.St(lr,w,s),A=this.Ct(fr),x=this.kt(dr,g),I=a.div(mr,x,A),S=r.fromScaling(pr,I),{POSITION:C,NORMAL_UP:k,NORMAL_RIGHT:N,SCALE:L,SCALE_NON_UNIFORM:E}=h,R=this.getMap().getRenderer().isWebGPU()?Float32Array:Uint16Array,P={"instance_vectorA":new Float32Array(4*y),"instance_vectorB":new Float32Array(4*y),"instance_vectorC":new Float32Array(4*y),"aPickingId":new R(y)};for(let t=0;t<y;t++)P.aPickingId[t]=t;const U=new Float32Array(3),B=new Float32Array(3),G=[],D=new Float32Array(1),F=new Float32Array(3),j=[],z=[],H=[],q=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?$t.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);l.set(s),e(new c(l.buffer),t),s.set(l)}}(C,((t,e)=>{k?(te(B,N,e),te(U,k,e),a.cross(G,B,U),a.normalize(G,G),xt(j,B,0),xt(j,U,1),xt(j,G,2),o.fromMat3(z,j),o.normalize(z,z),o.multiply(z,T,z)):o.identity(z),L?(te(D,L,e),a.set(H,D[0],D[0],D[0])):E?(te(F,E,e),a.set(H,...F)):a.set(H,1,1,1),r.fromRotationTranslationScale(q,z,t,H),ee(P.instance_vectorA,e,q,0),ee(P.instance_vectorB,e,q,1),ee(P.instance_vectorC,e,q,2)}));const $={};for(const t in P)$[t]={buffer:this.m.buffer({dimension:P[t].length/y,data:P[t],name:t}),divisor:1};const V=c.shader||"pbr";let J=0,Y=!0;const Z=[],K=[];return Vt(f,((t,i,o,a)=>{const c=this.Nt(t,i,o,a,s,!0,V,K),{geometry:h,material:f}=c;f&&!f.isReady()&&(Y=!1,J++);const T=new n.InstancedMesh($,y,h,f);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(T.uuid)),T.properties.magic="i3dm",T.properties.id=e,T.properties.count=p,T.properties.batchTable=d,T.properties.batchTableBin=m,T.properties.serviceIndex=s.H,T.properties.rtcCoord=g,T.properties.rtcCenter=b,T.properties.projCenter=w,T.properties.node=s;const _=this.Lt(t,h,f,s.H,a);_.MESH_ENV_EXPO=1,t.compressed_int16_params&&this.Mt(T,t.compressed_int16_params),this.Et(T,t.attributes);const A=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(A,A,t.matrices[e]);r.multiply(A,l,A),r.multiply(A,S,A),u.EAST_NORTH_UP||k?r.multiply(A,M,A):r.multiply(A,v,A),T.setPositionMatrix(A),this.vt(T,O),T.setDefines(_),T.properties.polygonOffset={offset:0,factor:0},Z.push(T),delete t.attributes,T.$=r.copy([],T.localTransform)})),_r(K),Y?(this.M[e]=Z,i(null,{id:e,mesh:Z})):(this.v[e]={meshes:Z,count:J},Z.Rt=i),Z}vt(t,e){const{rtcCoord:n,node:s,projCenter:i}=t.properties;e||(e=this.St(lr,i,s));const o=this.h.j(s.H),a=t.localTransform||[];if(o.coordOffset){const t=this.Pt(ir,s.H,n);r.multiply(a,t,e)}else r.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||Jn}St(t,e,n){r.fromScaling(t,this.Ct(fr));const s=this.Ut(rr,e,n.H);return r.multiply(t,r.fromTranslation(hr,s),t),t}createB3DMMesh(e,s,i,o){if(e.gltf&&(e.gltf.transferables=null),this.T[s]||this.v[s]){const t=this.T[s];return console.warn(`mesh with id(${s}) was already created.`),this.v[s]||o(null,{id:s,mesh:t}),t}let a;if(i.maxExtent){const e=new t.Extent(i.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:l}=c.extensions.MAPTALKS_RTC,{rtcCoord:h,center:u}=c.extensions.CESIUM_RTC,f=c.asset.sharePosition,d=this.At(i.xt),m=this.Bt(lr,f,h,u,l,i),p=this.h.j(i.H);let y=p.shader||"pbr";if(p.unlit)y="phong";else if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){y="phong";break}const b=[],g=[];let w=0,v=!0;return Vt(c,((t,o,c,T)=>{const _=this.Nt(t,o,c,T,i,!1,y,b),{geometry:M,material:O}=_;O&&!O.isReady()&&(v=!1,w++);const A=new n.Mesh(M,O);_.refMeshes||(_.refMeshes=new Set,_.refMeshes.add(A.uuid)),A.properties.magic="b3dm",A.properties.id=s,A.properties.node=i,e.batchTable&&(A.properties.batchTable=e.batchTable,A.properties.batchTableBin=e.batchTableBin),A.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,A.properties.serviceIndex=i.H;const x=this.Lt(t,M,O,i.H,T);A.setDefines(x);const I=t.compressUniforms;if(I)for(const t in I)A.setUniform(t,I[t]);t.compressed_int16_params&&this.Mt(A,t.compressed_int16_params),this.Et(A,t.attributes),a&&(x.USE_MAX_EXTENT=1,A.setUniform("maxPrjExtent",a)),A.hasFunctionUniform("polygonOpacity")||A.setFunctionUniform("polygonOpacity",(function(){return wt(p.opacity)?p.opacity:1})),A.hasFunctionUniform("polygonFill")||A.setFunctionUniform("polygonFill",(function(){return Et([],p.polygonFill||jn)})),A.material.hasFunctionUniform("hsv")||A.material.setFunctionUniform("hsv",(function(){return p.hsv||zn}));const S=r.identity([]);if(f&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(S,S,t.matrices[e]);f&&r.multiply(S,d,S),A.properties.node=i,A.properties.projCenter=l,A.properties.nodeMatrix=S,A.properties.isSharedPosition=f,A.properties.rtcCoord=h,A.properties.rtcCenter=u,this.wt(A,m),g.push(A),delete t.attributes,A.$=r.copy([],A.localTransform)})),_r(b),v?(this.T[s]=g,o(null,{id:s,mesh:g})):(this.v[s]={meshes:g,count:w},g.Rt=o),g}Gt(t){const e=this.h.Dt(t.id);if(!e||t.dt)return;let s,i,o,a;if(e.obbox)s=e.boxPosition,i=br,o=e.boxCenter,a=vr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];s=gr.vertices,i=gr.indices,o=t,a=[n,n,n]}const c=new n.Geometry({POSITION:s},i,0,{primitive:"lines",positionAttribute:"POSITION"}),l=new n.Mesh(c,new n.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),h=[];r.fromRotationTranslationScale(h,wr,o,a),l.localTransform=h,l.$=r.copy([],h),l.properties.node=t,t.dt=l}Ft(t){t.dt&&(t.dt.geometry.dispose(),t.dt.dispose(),delete t.dt)}Mt(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}wt(t,e){const{isSharedPosition:n,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Bt(e||lr,n,s,i,o,c));const l=t.localTransform||r.identity([]);r.multiply(l,e,a);const h=this.h.j(c.H);if(h.coordOffset){const t=this.Pt(ir,c.H,s);r.multiply(l,t,l)}t.setLocalTransform(l),t.properties.heightOffset=h.heightOffset||0,t.properties.coordOffset=h.coordOffset&&h.coordOffset.slice(0)||Jn}Bt(t,e,n,s,i,o){if(e){const e=this.kt(dr,n),i=r.fromScaling(sr,e),a=this.It(ir,o,s,n);r.multiply(t,a,i)}else this.Ot(t,n,i,o.H);return t}Et(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}It(t,e,n,s){const i=this.getMap(),o=this.h.j(e.H).heightOffset||0,c=e.matrix?r.copy(t,e.matrix):r.identity(t);if(n){$e(c,a.transformMat4(Xn,n,c),c)}const l=function(t,e,n,r,s,i,o){e=T.copy(Je,e);const a=oe(Je,e[0]*nn,e[1]*nn,e[2]),c=v.getTranslation(Ye,n),l=r.ellipsoid;let h;h=0===T.len(c)?T.set(Ze,0,0,-6378137):fe(Ze,c),tn.x=h[0],tn.y=h[1];const u=r.project(tn,en);Ke[0]=u.x/s,Ke[1]=u.y/s,Ke[2]=(h[2]+o)*i;const f=Ve(a,l,Xe);return $e(function(t,e,n){const r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],l=t[8],h=t[9],u=t[10],f=e[0],d=e[1],m=e[2],p=e[3],y=e[4],b=e[5],g=e[6],w=e[7],v=e[8],T=r*f+o*d+l*m,_=s*f+a*d+h*m,M=i*f+c*d+u*m,O=r*p+o*y+l*b,A=s*p+a*y+h*b,x=i*p+c*y+u*b,I=r*g+o*w+l*v,S=s*g+a*w+h*v,C=i*g+c*w+u*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=C,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(v.invert(We,f),_.fromMat4(Qe,n),t),Ke,t),t}(c,s,c,i.getProjection(),i.getGLRes(),this.B,o),h=function(t,e){return T.set(t,e[12],e[13],e[14]),t}(rr,l);let u=this.h.options.offset;if(bt(u)){const t=this.h.Dt(e.id).boxCoord;u=u.call(this.h,t)}return a.set(nr,u[0],u[1],0),a.sub(h,h,nr),$e(l,h,l),l}Pt(t,e,n){const s=this.h.j(e);if(!s.coordOffset)return null;const i=this.getMap(),o=i.getGLRes();Wn.set(n[0],n[1]);const c=i.coordToPointAtRes(Wn,o,tr),l=s.coordOffset,h=Wn.set(n[0]+l[0],n[1]+l[1]),u=i.coordToPointAtRes(h,o,er),f=u.x-c.x,d=u.y-c.y,m=this.B,p=a.set(nr,f,d,(l[2]||0)*m);return r.fromTranslation(t,p)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:s}=t,i=[];for(let t=0;t<s.length;t++){const{magic:r}=s[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"i3dm"===r?this.createI3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"pnts"===r?this.createPntsMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"cmpt"===r&&this.createCMPTMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)}))}return this.O[e]=i,r(null,{id:e,mesh:i}),i}Lt(t,e,n,r,s){const i=("phong"===(this.h.j(r).shader||"pbr")?this.et:this.nt).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.jt(i,e),e.data.uvRegion&&(i.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(i.VertexNormal=1),e.data[e.desc.color0Attribute]&&(i.VertexColor=1),e.data[e.desc.uv0Attribute]&&(i.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(i.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(i.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(i.TexCoord2=1),"MESHOPT"===this.h.zt&&(i.MeshOPT_Compress=1),this.hasIBL()&&(i.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(i.HAS_WEB3D_quantized_attributes_TEXCOORD=1),i.HAS_MIN_ALTITUDE=1,this._t(i,t.compressed_int16_params);return yt(i,t.compressDefines),i}_t(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}X(t){const e=this.h.getRenderer();e&&e.updateMaskDefines(t)}jt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Nt(t,e,r,s,i,o,a,c){let l=!1;s.asset&&"S3M"===s.asset.generator&&(l=!0,s.extensions=s.extensions||{});const h=s.url+"-"+e+"-"+r;if(this.A[h])return this.A[h];let u,f;c.push(t);const d=s.materials&&s.materials[t.material],m=s.extensions&&s.extensions.KHR_techniques_webgl,p=this.h.j(i.H);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){if(this.getMap().getRenderer().isWebGPU())throw new Error("3dtiles with KHR_techniques_webgl extension is not supported in webgpu");const e=this.Ht(t,s,o,l);u=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.qt(t,o,yr);const e=p.material;u=this.$t(t.material,s,a,e||Hn,c,p)}u&&(u.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return pt(t)?.1:t})),u.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),u&&!u.isReady()?u.Vt=i.id:u||(u=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const y={geometry:f,material:u};return f.properties.url=h,this.A[h]=y,y}Ht(t,e,n,r){const{geometry:s,material:i}=this.P.createMesh(t,e,n,r);return{geometry:s,material:i}}qt(t,e,r){const s=this.getMap().getRenderer().isWebGPU(),i=t.attributes,o="COLOR_0";let a=i._BATCHID&&i._BATCHID.array;if(a&&a.byteOffset&&(a=new a.constructor(a),!s||a instanceof Float32Array||(a=new Float32Array(a))),i[o]){const t=i[o].array||i[o];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);i[o].array?(i[o].array=e,i[o].componentType=5121):i[o]=e}}const c={};let l=0,h=0;for(const t in i){const e=r[t]||t,o=e===r.POSITION;s&&n.Geometry.padGPUGLTFAttribute(i[t]),o&&(l=i[t].itemSize);const a=Ln(this.m,i[t],{dimension:i[t].itemSize,name:t});c[e]=yt({},i[t]),c[e].buffer=a,c[e].type=En(c[e].array),delete c[e].array,e===r.POSITION&&(c[e].array=i[t].array,h=i[t].array.length/3)}const u=r._BATCHID;if(!c[u]&&!e){const t=new(s?Float32Array:Uint8Array)(h);c[u]=t}const f=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,d=new n.Geometry(c,f,0,{positionSize:l,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":Nn(t.mode)});return a&&f&&(d.properties.batchIdData=a,d.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],i=t[s];let o=n.get(i);o||(o=[],n.set(i,o)),o.push(s)}return n}(a,f)),d.generateBuffers(this.m,{excludeElementsInVAO:e}),d}Ot(t,e,n,s){const i=r.identity(t),o=this.Ct(qn);return this.Ut(rr,n,s),r.translate(i,i,rr),r.scale(i,i,o),i}Ut(t,e,n){const r=this.B;Wn.x=e[0],Wn.y=e[1];const s=this._prjToPoint(Wn);let i=this.h.options.offset;bt(i)&&(i=i.call(this.h,Wn));const o=this.h.j(n).heightOffset||0;return a.set(t,s.x-i[0],s.y-i[1],r*e[2]+r*o),t}W(t,e){const n=this.h.Jt(ur,e);t.localTransform=r.multiply(t.localTransform,n,t.$)}kt(t,e){const n=this.getMap();Wn.x=e[0],Wn.y=e[1];const r=n.distanceToPointAtRes(100,100,n.getGLRes(),Wn),s=this.B;return a.set(t,r.x/100,r.y/100,s),t}ct(t){if(this.nt)return;const e={x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},s=[],o=[];this.st=new n.MeshShader({vert:ne,frag:"#define SHADER_NAME PNTS\nprecision mediump float;\nuniform float layerOpacity;\nvarying vec4 vColor;\nvoid main() {\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n if (dot(circCoord, circCoord) > 1.0) {\n discard;\n } else {\n gl_FragColor = vColor;\n }\n #ifdef HAS_LAYER_OPACITY\n gl_FragColor *= layerOpacity;\n #endif\n}\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(o,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>c.fromMat4(s,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const a={},h=[];i.fillIncludes(a,h,t);const u=this.U();this.et=new n.PhongShader({uniforms:h,defines:a,extraCommandProps:u}),this.nt=new n.pbr.StandardShader({uniforms:h,defines:a,extraCommandProps:u}),this.it=new n.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const f=this.h;Un(f.getRenderer().canvas,this.m,f.getMap()),this.picking=new n.FBORayPicking(this.p,{vert:"#include <gl2_vert>\n#define SHADER_NAME GEO_3DTILES_PICKING\nattribute vec3 aPosition;\n#if defined(HAS_COLOR)\n attribute vec4 aColor;\n#endif\n#if defined(HAS_COLOR0)\n #if COLOR0_SIZE == 3\n attribute vec3 aColor0;\n varying vec3 vColor0;\n #else\n attribute vec4 aColor0;\n varying vec4 vColor0;\n #endif\n#endif\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\n#include <line_extrusion_vert>\n#include <get_output>\n#include <fbo_picking_vert>\nvoid main() {\n mat4 localPositionMatrix = getPositionMatrix();\n vec4 localVertex = getPosition(aPosition);\n vec4 position = localPositionMatrix * localVertex;\n vec4 viewVertex = modelViewMatrix * position;\n #ifdef HAS_MASK_EXTENT\n gl_Position = projMatrix * getMaskPosition(position, modelMatrix);\n #else\n gl_Position = projMatrix * viewVertex;\n #endif\n float alpha = 1.0;\n #if defined(HAS_COLOR)\n alpha *= aColor.a;\n #endif\n #if defined(HAS_COLOR0) && COLOR0_SIZE == 4\n alpha *= aColor0.a;\n #endif\n fbo_picking_setData(gl_Position.w, alpha != 0.0);\n}\n",wgslVert:l("layer_3dtiles_picking_vert"),extraCommandProps:u,uniforms:this.nt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Yt=new n.FBORayPicking(this.p,{vert:ne,extraCommandProps:u,uniforms:this.st.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}U(){return{viewport:{x:0,y:0,width:()=>this.u?this.u.width:1,height:()=>this.u?this.u.height:1},cull:{enable:(t,e)=>e.meshProperties.cullFace,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:"<=",ref:(t,e)=>e.meshProperties.selectionDepth},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,func:(t,e)=>e.meshProperties.depthFunc||"<="},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}rt(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;let i=this.h.options.opacity;return i=pt(i)?1:i,{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:a.normalize(Yn,r),layerOpacity:i}}D(){const t=this.getMap(),e=this.h,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=Gn(n),i=Dn(t,r,s),o=this.h.getRenderer().getMaskUniforms();i.minAltitude=e.options.altitude||0;let a=e.options.opacity;return a=pt(a)?1:a,i.layerOpacity=a,yt(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),i.ambientColor||(i.ambientColor=[.2,.2,.2]),yt(i,o),i}$t(t,e,r,s,i,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=yt({},s);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Zt(t,i)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Zt(e.textures[a.normalTexture.index],i);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Zt(e.textures[a.occlusionTexture.index],i);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Zt(e.textures[a.emissiveTexture.index],i);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];if(n&&n.image&&n.image.color)c.baseColorFactor=c.baseColorFactor?h.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color;else{const t=this.Zt(n,i);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.m))}}if(pt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),pt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Zt(e.textures[a.metallicRoughnessTexture.index],i);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){const t=new n.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.pbr.StandardMaterial(c);"phong"===r&&(l=n.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,f=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(l.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",f.KHR_texture_transform.rotation||0),l.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.L),l}Zt(t,e){if(!t)return null;const r={type:t.type?Cn(t.type):"uint8",format:t.format?kn(t.format):"rgba",flipY:!!t.flipY},s=t.image;if(e.push(s),s.array?r.data=s.array:s.mipmap&&(r.mipmap=s.mipmap),!r.data&&!r.mipmap)return null;if(r.width=s.width,r.height=s.height,r.mipmap&&(r.width<4||r.height<4))return null;const i=t.sampler||t.texture&&t.texture.sampler;return i&&(i.magFilter&&(r.mag=xn(i.magFilter)),i.minFilter&&(r.min=In(i.minFilter)),i.wrapS&&(r.wrapS=Sn(i.wrapS)),i.wrapT&&(r.wrapT=Sn(i.wrapT))),new n.Texture2D(r,this.N)}R({target:t}){const e=t.Vt,n=this.v[e];if(n.count--,!n.count){const t=n.meshes;this.T[e]=t,delete this.v[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}Ct(t){const e=1/this.getMap().getGLRes(),n=this.B;return t[0]=t[1]=e,t[2]=n,t}Kt(t){return this.h.Kt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),Qn)}At(t){return"Y"===t?Rn:"X"===t?Pn:$n}pick(t,e,n=3){const r=this.h;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.D(),o=this.Xt(this.picking,i,this.I,t,e,n);o&&s.push(o);const a=this.Xt(this.picking,i,this.C,t,e,n);a&&s.push(a);const c=this.rt(),l=this.Xt(this.Yt,c,this.S,t,e,n);return l&&s.push(l),s}Xt(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.h,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,s,i,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:l,pickingId:h,point:u,coordinate:f}=c,d=(0===l||l)&&t.getMeshAt(l);if(!d||!d.geometry)return null;const m=d.properties;u&&u.length&&(u[0]=Math.round(1e5*u[0])/1e5,u[1]=Math.round(1e5*u[1])/1e5,u[2]=Math.round(1e5*u[2])/1e5);const p={batchId:h},y=o.options.services,b=y&&y[d.properties.serviceIndex];if(b&&b.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=h;for(const s in t)void 0!==t[s].byteOffset?p[s]=Ce(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:u,coordinate:f}}highlight(t){this.J=t;const e=this.h.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.J=null;const t=this.h.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Z=t;const e=this.h.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Z=null;const t=this.h.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}Wt(){if(!this.G)return[];const t={},e=[];for(const n in this.G){const r=this.G[n];if(r)for(let n=0;n<r.length;n++){const s=r[n],i=s&&s.geometry;if(!s||!i)continue;const o=s.properties.serviceIndex;t[o]||(t[o]=new Set);const a=i.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function _r(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}function Mr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}const Or=[];class Ar{constructor(t,e,n,r,s){this.h=r,this.Qt=t,this.H=e,this.te=s,this.ee=n.version,t.indexOf("i3s:tileset:")<0?(this.ee<=1.6?this.ne="root":this.ne=0,n.version=this.ee):(this.ne=t.substring(12),this.ee>1.6&&(this.ne=parseInt(this.ne))),this.Qt=t,this.re=n}load(){const t=this.re,e=t.layerScene.baseUrl;if(this.ee<=1.6)return t[this.ne]&&t[this.ne].lodSelection?(this.se=t[this.ne],this.ie()):new Promise((n=>{let r=e+"/nodes/"+this.ne;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{this.se=t[this.ne],n(this.ie())}))}));if(this.ee>=1.7){if(t[this.ne])return this.se=t[this.ne],this.ie();const n=Math.floor(this.ne/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.te(this.H,s,(()=>{this.se=t[this.ne],r(this.ie())}))}))}return null}getTileset(){return this.oe}getChildrenURL(){return this.ae}ie(){const t=this.re,e=t.layerScene.baseUrl,n=this.se.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.ee<=1.6){const o=n[i].id;if(t[o])continue;const a=o;s[a]||(s[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{n()}))})),r.push(s[a]))}else{const o=n[i];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);s[a]||(s[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.te(this.H,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.ce())):this.ce()}ce(){return Promise.resolve(this.le())}he(t){Mr(this.re,t)}le(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.ue(this.se,!0)}}ue(t){const e=this.h.getRenderer(),n=this.re.projection,r=!n||n&&4326===n.wkid,s=this.ee,i=this.re,o=t,a=o.obb,c=o.mbs,l={};let h;if(c)h=T.set([],c[0],c[1],c[2]),r||(h=e.fe(h,h)),h=xr([],h[0],h[1],h[2]),l.sphere=[...h,c[3]];else if(a){h=T.set([],a.center[0],a.center[1],a.center[2]),r||(h=e.fe(h,h)),h=xr([],h[0],h[1],h[2]);const t=function(t,e,n){const r=_.fromQuat([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(h,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],s=t[4]+t[7]+t[10],i=t[5]+t[8]+t[11];T.set(Or,n,s,i);const o=T.len(Or);l.sphere=[...h,o]}let u=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===i.lodSelectionMetricType){u=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(u=f/o.lodSelection[t].maxError);(u===1/0||isNaN(u))&&(u=1e5);const d=16*u,m=v.identity([]),p=o.children;let y;if(p){y=[];const t=this.re;for(let e=0;e<p.length;e++){const n=s<=1.6?p[e].id:p[e];if(!t[n]){y=null;break}y.push(this.ue(t[n]))}}const b={refine:"REPLACE",boundingVolume:l,transform:m,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!y?b.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}),y&&y.length&&(b.children=y),b}getJSON(){return this.se}}function xr(t,e,n,r){return oe(t,vt(e),vt(n),r)}const Ir=!!Dt.ktx2,Sr=r.identity([]),Cr=(()=>{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 kr(t){return t.indexOf("i3s:mesh")>=0}const Nr=9;function Lr(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Nr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let h=!1;const u=Sr;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;i&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let s=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(s){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",i&&(s+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+s,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}l.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions,o=(e.layerScene.store||{}).textureEncoding,u=t[f.definition],{geometryBuffers:m}=u;h=r&&2===m.length;const p=Dt.draco&&h?m[1]:m[0],y=Dt.draco&&h?1:0;let b=c+`/nodes/${f.resource}/geometries/`+y;i&&(b+=".bin");const g={geometry:{url:b,info:p}};if(s&&Cr&&h&&!Dt.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const w=e.layerScene.materialDefinitions,v=e.layerScene.textureSetDefinitions;let T,_=0;if(d&&(_=w[d.definition]),w){T=function(t,e,n,r,s,i,o){const a=JSON.parse(JSON.stringify(e));return Er(t,a,n,r,s,i,o),a}(o,_,v,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};g.material=T,l.push(g)}return{dracoCompression:h,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function Er(t,e,n,r,s,i,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],l="images/"+c.formats[0].format,h=Pr(c.formats,i,t),u={url:r+`/nodes/${s}/textures/${h.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:h.format,mimeType:l};if(o){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}u.url+="."+t}e[a]=u}else gt(e[a])&&Er(t,e[a],n,r,s,i,o)}const Rr={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function Pr(t,e,n){if(n&&n.length){const e=n[n.length-1],r=Rr[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",Rr,"current textureEncoding:",e)}for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&Ir)return t[n]}return null}const{Ajax:Ur}=Ft(),Br=new t.Coordinate(0,0),Gr=new t.Coordinate(0,0),Dr=new Set,Fr=[],jr=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.de(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){this.data.get(n.value).current&&t.Util.warnOnce(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`);const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.de(t,e),this}de(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(t.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let zr=0;class Hr extends(u(f(t.renderer.LayerAbstractRenderer))){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>jr.max&&jr.setMaxSize(e),this.tileCache=jr,zr++,this.tilesLoading={},this.me={},this.pe=[],this.te=(...t)=>this.ye.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return Fr;const t=this.painter.getPaintedMeshes();if(!t)return Fr;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&Nt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&Nt(e,r.filter((t=>!(!t||!t.geometry)))),s.length&&Nt(e,s.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.pe.length||super.needToRedraw())}getFrameTimestamp(){return this.be}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.be=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:s}=this.layer.getTiles(),i=s.length;if(!s||!i)return void this.completeRender();this.painter.prepareRender(e),this.ge(),this.we(e);const{selectedTiles:o,requests:a}=this.ve(r,s);a.length&&this.loadTiles(a),this.Te(o,e),this._e(),a.length||this.completeRender()}ve(t,e){let n=[];this.Me();let r=0;const s=this.Oe(),i={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const s=e[t],c=s.node;if(i[c.id])continue;i[c.id]=1;let l=!1;const h=this.getCachedTile(c.id);if(this.Ae(c.id)?(r++,l=a=!0,this.tilesLoading[c.id].current=!0):h?(this.getTileOpacity(h)<1&&(l=a=!0),o=!0,s.selected=!0,s.data=h):this.painter.has(c)||(l=a=!0,n.push(c)),!l)continue;if(this.xe(s))o=!0;else{this.Ie(s).length&&(o=!0)}}const c=o?this.Se(t):[];if(n.length>1&&(n.sort(qr),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c}}Se(t){const e=[];let n,r;const s=[t],i=[];for(;s.length>0||i.length>0;){if(i.length>0){const t=i[i.length-1];if(t.Ce===s.length){i.pop(),t===n&&(t.leave=!0),t.branchRootId=r,e.push(t),0===i.length&&(r=null);continue}}const t=s.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)t.leave=!0,t.selectionDepth=i.length,t.branchRootId=r,e.push(t);else{if(t.selectionDepth=i.length,n=t,0===o.length){t.leave=!0,t.branchRootId=r,e.push(t);continue}0===i.length&&(r=t.node.id),i.push(t),t.Ce=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return e}xe(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}Ie(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.ke+1,r=[t.node];for(;r.length>0;){const s=r.pop().children;for(let i=0,o=s.length;i<o;i++){if((!s[i].content||!s[i].content.url)&&s[i].children&&s[i].children.length){r.push(s[i]);continue}const o=s[i].id;if(this.tileCache.has(o)){const n=this.layer.Ne(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].ke<=n&&r.push(s[i])}}return e}Te(t,e){this.tileCache.markAll(this,!1);const n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,r.renderer=this,this.tileCache.add(t[e].node.id,r);const s=r.node,i=this.layer.j(s.H);s.dt&&i.debug&&!Array.isArray(i.debug)&&n.push(s.dt)}const r=this.layer.options.services;for(let t=0;t<r.length;t++){const e=r[t],s=Array.isArray(e.debug)&&e.debug;if(s)for(const t of s){const e=this.layer.Dt(t),r=e&&e.node;r&&r.dt&&n.push(r.dt)}}const s={tiles:t};this.onDrawTileStart(s);const i=this.painter.paint(t,n,e);this.layer.fire("drawtiles",{count:i}),this.onDrawTileEnd(s),i&&this.layer.fire("canvasisdirty",{renderCount:i}),this.tileCache.shrink()}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(Ct(e)){const n=kt(e);return this.Le(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.H,r=this.Ee[n];return new Ar(e,n,r,this.layer,this.te).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Pt(e)&&!kr(e)&&(e=t.baseUrl+e),this.Le(e,null,t),null}Le(t,e,r){let s=this.Re;s||(s=n.Util.getSupportedFormats(this.gl||this.device&&this.device.wgpu),this.Re=s);const i=this.layer.j(r.H);i.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),s=[];for(let t=0;t<r.length;t++)s.push(encodeURIComponent(r[t]));return e+s.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Pe[r.H]),arraybuffer:e,rootIdx:r.H,upAxis:r.xt,transform:r.matrix,supportedFormats:s};if(kr(t)){const e=this.Ee[r.H];if(o.projection=e.projection,o.i3sInfo=Lr(t,e,this.regl||this.device,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=yt({},i),i.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s||"gltf"===s?this.pe.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Gt(t){this.painter&&this.painter.Gt(t)}Ft(t){this.painter&&this.painter.Ft(t)}we(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.pe.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.pe.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})),n++}}Ue(t,e,n,r){if(this.Be(r),n)this.onTileError(n,e);else{const n=this.Ge(r);e.memorySize=n,this.onTileLoad(t,e)}}Be(t){if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(t[e])if(Array.isArray(t[e]))this.Be(t[e]);else{const n=t[e].defines||{};n.HAS_LAYER_OPACITY=1,t[e].setDefines(n)}}else if(t)if(Array.isArray(t))this.Be(t);else{const e=t.defines||{};e.HAS_LAYER_OPACITY=1,t.setDefines(e)}}Ge(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Ge(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.De(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.Fe(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(e,n,r){if(!this.layer)return;const s=r||n.content.url,i=e&&e.message||e;e&&(404===e.status||204===e.status)||Dr.has(i)||(console.warn("failed to load 3d tile: "+s),console.warn(e),Dr.add(i)),delete this.tilesLoading[n.id],(!this.layer.options.onlyCacheNoContentTileWhenError||e&&!t.Util.isNoContentHttpCode(e.status))&&this.je(n,e),this.layer.fire("tileerror",{node:n,error:e})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return[];const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}je(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};r.renderer=this,this.tileCache.add(e.id,r)}De(e){const n={loadTime:t.Util.now(),current:!0,node:e};n.renderer=this,this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.me[e]}Me(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}initContext(){super.initContext();const t=this.layer,{regl:e,reglGL:n,device:r}=this.context;this.regl=e,this.device=r,this.gl=n;const s=e||r;this.prepareWorker(),this.canvas.pickingFBO=this.canvas.pickingFBO||s.framebuffer(this.canvas.width,this.canvas.height),this.pickingFBO=this.canvas.pickingFBO||s.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Tr(s,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:e,device:r})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new zt("@maptalks/3dtiles",t.id,n.Util.supportNPOT(this.regl||this.device)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=yt({},r),delete r.offset;const s=t.options.spatialReference;r.projection=s&&s.coordType||s&&s.projection||t.getSpatialReference().getProjection().code;const i=this.layer.getId();e.addLayer(i,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),zr--,zr||jr.reset(),this.clear(),delete this.tileCache,delete this.gl,delete this.regl,super.onRemove()}clear(){this._e(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}getTileOpacity(){return 1}getStencilValue(){return 0}_e(t){this.He||(this.He=Date.now());const e=Date.now();if(!t&&e-this.He<this.layer.options.retireInterval)return;this.He=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Oe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}qe(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let s=0;s<n.length;++s){try{r=t.getContext(n[s],e)}catch(t){}if(r)break}return r}Ae(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Ie(t,e,0,n)}ge(){if(!this.$e)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.$e){const s=this.$e[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Ut(this.layer.j(i).fetchOptions);if(n.push(Ur.getJSON(r,o).then((t=>{delete this.$e[r];const e=this.Ee[i];if(e){t.nodes?Mr(e,t.nodes):(e[t.id]=t,Mr(e,t.children));for(let t=0;t<s.length;t++)s[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}ye(t,e,n){this.$e||(this.$e={}),this.$e[e]=this.$e[e]||[],this.$e[e].rootIdx=t,this.$e[e].push(n),this.setToRedraw()}Fe(t,e,n){this.Ee||(this.Ee=[]);const r=e.H;this.Ee[r]||(this.Ee[r]={});const s=this.Ee[r],i=this.layer.j(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),s.version=+(i.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),s.projection=t.spatialReference,function(t,e,n,r,s,i,o){if(!i.layerScene){i.layerScene=e,i.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,i.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=s;if(i.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=s.lastIndexOf("/");t=e<0?"./":s.substring(0,e)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new Ar(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.te).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:s,height:i}=this.canvas;return!this.pickingFBO||r.width===s&&r.height===i||r.resize(s,i),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.J||(this.J=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.J[n];r||(r=this.J[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.J[e];n||(n=this.J[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.J)}cancelHighlight(t,e){if(!this.J)return;const n=this.J[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.J[t]=null),this.painter.highlight(this.J)}}cancelAllHighlight(){delete this.J,this.painter.cancelAllHighlight()}showOnly(t){if(this.Z||(this.Z=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Z[n];r||(r=this.Z[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Z[e];n||(n=this.Z[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Z)}cancelShowOnly(){delete this.Z,this.painter.cancelShowOnly()}Wt(){return this.painter?this.painter.Wt():[]}fe(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.Ve();return Br.set(e[0],e[1]),n.unproject(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}return Br.set(e[0],e[1]),n.getProjection().unproject(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}Je(t,e){const n=this.Ve();return Br.set(e[0],e[1]),n.project(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}Ye(t,e){const n=this.Ve();return Br.set(e[0],e[1]),n.unproject(Br,Gr),t[0]=Gr.x,t[1]=Gr.y,t}Ve(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this.Ze||(this.Ze=t.SpatialReference.getProjectionInstance(e)),this.Ze}}function qr(t,e){return t.ft-e.ft}function $r(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function Vr(t,e,n){return Math.sqrt(function(t,e,n){const r=T.subtract(Jr,n,t),s=$r(Yr,e,0),i=$r(Zr,e,1),o=$r(Kr,e,2),a=T.len(s),c=T.len(i),l=T.len(o);T.normalize(s,s),T.normalize(i,i),T.normalize(o,o);const h=Xr;h[0]=T.dot(r,s),h[1]=T.dot(r,i),h[2]=T.dot(r,o);let u,f=0;h[0]<-a?(u=h[0]+a,f+=u*u):h[0]>a&&(u=h[0]-a,f+=u*u);h[1]<-c?(u=h[1]+c,f+=u*u):h[1]>c&&(u=h[1]-c,f+=u*u);h[2]<-l?(u=h[2]+l,f+=u*u):h[2]>l&&(u=h[2]-l,f+=u*u);return f}(t,e,n))}const Jr=[],Yr=[],Zr=[],Kr=[],Xr=[];const Wr=2*Math.PI;class Qr{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],s=t.west;let i=t.east;return i<s&&(i+=Wr,n<0&&(n+=Wr)),(n>s||Te(n,s,1e-14))&&(n<i||Te(n,i,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const ts=[0,0,1];function es(t,e){return oe(e,t[0],t[1],t[2])}class ns{constructor(t,e){this.normal=a.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-a.dot(e,t);return a.copy(n.normal,e),n.distance=r,n}}const rs=[],ss=[],is=[],os=[],as=[],cs=[],ls=[],hs=[],us=[],fs=[],ds=new ns([1,0,0],0),ms=[];class ps{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new Qr(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!Qr.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,s=this.westNormal,i=this.southNormal,o=this.eastNormal,c=this.northNormal,l=a.subtract(ms,t,e),h=a.dot(l,s),u=a.dot(l,i),f=a.subtract(ms,t,r),d=a.dot(f,o),m=a.dot(f,c);h>0?n+=h*h:d>0&&(n+=d*d),u>0?n+=u*u:m>0&&(n+=m*m)}const r=e[2],s=this.minimumHeight,i=this.maximumHeight;if(r>i){const t=r-i;n+=t*t}else if(r<s){const t=s-r;n+=t*t}return Math.sqrt(n)}computeBox(t){const e=this;es(Qr.southwest(t,ss),e.southwestCornerCartesian),es(Qr.northeast(t,ss),e.northeastCornerCartesian),rs[0]=t.west,rs[1]=.5*(t.south+t.north),rs[2]=0;const n=es(rs,is),r=a.cross(as,n,ts);a.normalize(e.westNormal,r),rs[0]=t.east;const s=es(rs,hs),i=a.cross(as,ts,s);a.normalize(e.eastNormal,i);const o=a.subtract(as,n,s),c=a.normalize(os,o),l=t.south;let h;if(l>0){rs[0]=.5*(t.west+t.east),rs[1]=l;const n=es(rs,us);a.copy(fs,c);const r=ns.fromPointNormal(e.southwestCornerCartesian,e.westNormal,ds);ys(us,fs,r,e.southwestCornerCartesian),h=ge(n,cs)}else h=we(Qr.southeast(t,ss),cs);const u=a.cross(ls,h,o);a.normalize(e.southNormal,u);const f=t.north;let d;if(f<0){rs[0]=.5*(t.west+t.east),rs[1]=f;const n=es(rs,us);a.scale(fs,c,-1);const r=ns.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,ds);ys(us,fs,r,e.northeastCornerCartesian),d=ge(n,cs)}else d=we(Qr.northwest(t,ss),cs);const m=a.cross(ls,o,d);a.normalize(e.northNormal,m)}}function ys(t,e,n,r){const s=t,i=e,o=n.normal,c=a.dot(o,i);if(Math.abs(c)<1e-15)return;const l=(-n.distance-a.dot(o,s))/c;return l<0?void 0:(r=a.scale(r,i,l),a.add(r,s,r))}function bs(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const gs=t.BBOXUtil,ws={"services":[],"maxGPUMemory":t.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":2,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},vs=[0,0,0],Ts=[0,0,0],_s=[0,0,0],Ms=[0,0,0],Os=[0,0,0],As=[0,0,0],xs=[0,0,0],Is=[1,1,1],Ss=[1,1,1],Cs=[0,0,0,0],ks=[],Ns=new t.Coordinate(0,0),Ls=new t.Point(0,0),Es=[0,0,0,0,0,0,0,0,0],Rs=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ps=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Us=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Bs=new t.Point(0,0),Gs=r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Ds=[0,0],Fs=[0,0,0],js=[1,1,1],zs=[0,0,0],Hs=[0,0,0],qs=[0,0,0,0],$s=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class Vs extends(d(t.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new Vs(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],n=[0,0,0]){const s=oe([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),i=Ve(s,null,[]),a=o.fromEuler([0,0,0,0],...n),c=r.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,[0,0,0],e);return r.multiply(c,i,c)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Ke(),this.Xe=new Map}Ke(){const t=this.options.services.map((t=>t.url));this.We=this.We||{},this.Pe=this.Pe||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.We[n];void 0===r&&(r=this.We[n]=this.Pe.length),this.Pe[r]=Zs(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Pe.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Qe(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Ke(),this.Qe(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(Ws(n[t].coordOffset,e.coordOffset)&&Ws(n[t].heightOffset,e.heightOffset)&&Ws(n[t].scale,e.scale)&&Ws(n[t].rotation,e.rotation)),yt(n[t],e));const s=n[t].url,i=this.We[s],o=this.Pe&&this.Pe[i];return o&&(pt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Qe(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.We[n];this.Pe[r]&&(this.Pe[r]=null),delete this.We[n],e.splice(t,1)}return this.Qe(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const s=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[s])}}return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Pe.length;t++){const n=this.Pe[t];if(n&&n.boundingVolume){const t=this.boundingVolumeToExtent(n);e._combine(t)}}return e}const n=this.Pe[e];return n&&n.boundingVolume?this.boundingVolumeToExtent(n):null}boundingVolumeToExtent(e){const n=e.boundingVolume.tn?Gs:e.matrix,r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),i=this.getRenderer();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(Tt(n[0]),Tt(n[1]),Tt(n[2]),Tt(n[3]))}if(e.boundingVolume.sphere){const o=e.boundingVolume.sphere,c=fe([],a.transformMat4([0,0,0],o,n));s&&i.Je(c,c);const l=o[3],h=r.locate(c,-l,l),u=r.locate(c,l,-l);return new t.Extent(h,u)}if(e.boundingVolume.box){const o=e.boundingVolume.box,l=a.transformMat4([0,0,0],o,n),h=new t.Coordinate(fe([],l));s&&i.Je(h,h);const u=o.slice(3);c.multiply(u,c.fromMat4([0,0,0,0,0,0,0,0,0],e.matrix),u);const f=a.length(u.slice(0,3)),d=a.length(u.slice(3,6)),m=a.length(u.slice(6,9)),p=Math.max(f,d,m),y=r.locate(h,-p,p),b=r.locate(h,p,-p);return new t.Extent(y,b)}return null}getRootTiles(){return this.Pe}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Qe(),{tiles:ks};const e=this.getMap(),n=e.cameraPosition,r=e.pointAtResToDistance(n[2],0,e.getGLRes()),s=this.nn(n);this.rn=this.rn||[0,0,0],a.set(this.rn,vt(s.x),vt(s.y),r),this.sn=oe(this.sn||[],this.rn[0],this.rn[1],this.rn[2]),this.an=2*Math.tan(.5*vt(e.getFov()));const i=e.projViewMatrix;let o;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,o=bs(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof m));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=bs(e)}catch(t){console.error(t)}}));const l={children:[],level:-1};let h=l;const u=[];for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(!n||!n.visible)continue;const r=n.service,s=[n],a=this.cn(e);for(;s.length>0;){const e=s.pop();for(e.id||this.ln(e);h.level>=e.ke;)h=h.parent;const n=this.hn(e,a,i,o,c);if(e.service=r,!(n===Qs.VISIBLE||n!==Qs.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&Xs(e))){let t=h;for(;t&&!t.content;)t=t.parent;n===Qs.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.un(u,t);continue}e.ft<1/0&&this.dn(e);const l=this.Ne(e,h);h.children.push(l);const f=e.children,d=f&&f.length,m=l.content;if(m&&(!d||n===Qs.SCREEN_ERROR_TOO_SMALL)&&this.un(u,l),n!==Qs.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.un(u,l),h=l;const n=f[0].parent;let r=!1;for(let i=0,o=f.length;i<o;i++){if(n){const e=t.getCachedTile(f[i].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[i].parent=e,f[i].xt=e.xt,f[i].baseUrl=e.baseUrl;const t=f[i].content&&(f[i].content.url||f[i].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[i].baseUrl=e.baseUrl:Pt(t)?f[i].content.url=e.baseUrl+t:f[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}s.push(f[i])}!r&&m&&this.un(u,l)}}}return{root:l,tiles:u}}un(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return Js(n,e,r)<=0;if(n.box)return 0===Ys(n,e,r)}return!1}(this.rn,this.sn,n,r)||t.push(e)}Ne(t,e){return{id:t.id,node:t,children:[],level:t.ke,parent:e,content:t.content&&t.content.url}}ln(e){const n=this.getId();e.id=n+":"+t.Util.GUID(),e.matrix=e.transform||r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e.mn=this.pn(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=r.multiply(e.matrix,e.parent.matrix,e.matrix)),e.H=e.parent.H,void 0===e.ke&&(e.ke=e.parent.ke+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri)}j(t){return this.Pe[t].service}yn(t){const e=t.boundingVolume;if(!e||e.tn&&!this.bn(t))return;const n=this.j(t.H),s=n.heightOffset||0,i=this.options.offset,o=bt(i)||i[0]||i[1],c=n.coordOffset||Ds;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!e.tn&&(!t.boundingVolume||!s&&0!==s&&r.exactEquals(t.matrix,Gs)&&!o&&c===Ds))return;e.box&&e.region&&delete e.region;const{region:l,box:h,sphere:u}=e;if(e.coordOffset=[c[0],c[1]],e.heightOffset=s,l){e.originalVolume||(e.originalVolume=l.slice(0));const t=e.originalVolume,n=this.gn([Tt(t[0]),Tt(t[1])]);l[0]=vt(n.x+c[0]),l[1]=vt(n.y+c[1]);const r=this.gn([Tt(t[2]),Tt(t[3])]);l[2]=vt(r.x+c[0]),l[3]=vt(r.y+c[1]),l[4]=t[4]+s+(c[2]||0),l[5]=t[5]+s+(c[2]||0)}else if(h||u){e.originalVolume||(e.originalVolume=(h||u).slice(0));const n=h||u,r=e.originalVolume,i=a.transformMat4(vs,r,t.matrix),o=fe(Ts,i),l=this.gn([o[0]+c[0],o[1]+c[1]]);o[0]=l.x,o[1]=l.y,o[2]+=s+(c[2]||0),oe(n,vt(o[0]),vt(o[1]),o[2])}e.tn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}bn(t){const e=t.boundingVolume,n=this.j(t.H),r=n.heightOffset||0,s=n.coordOffset||Ds;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}pn(t){return void 0===t.geometricError||!t.boundingVolume}dn(t){let e=t.parent;for(;e&&e.mn&&!(e.ft<=t.ft);)e.ft=t.ft,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.Qe()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const s=(t.asset&&t.asset.gltfUpAxis||e&&e.xt||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const i=n.indexOf("realspace/")>-1;0===e.ke&&t.asset&&t.asset.s3mType&&i&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.xt=s,e){const n=e.boundingVolume,s=e.wn;s&&delete e.wn,yt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);let i=t.root.transform;if(s){const t=this.j(e.H);t.ecefTransform&&(i=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,i||Gs))}i&&(e.parent?o||(e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,i)):e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.matrix,i)),delete e.content,t.root.content&&(e.content=t.root.content),e.mn=this.pn(e);const a=e.content&&(e.content.url||e.content.uri);a&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&a&&!Ct(a)&&Pt(a)&&(e.content.url=e.baseUrl+a),t.root&&!e.parent&&this.vn(e)}this.Qe(),this.fire("loadtileset",{tileset:t,index:e&&e.H,url:n})}Tn(t,e,n){if(!t.extent||!gs)return!0;const r=t.extent;if(qs[0]=r.xmin,qs[1]=r.ymin,qs[2]=r.xmax,qs[3]=r.ymax,e){if(!gs.bboxIntersect(qs,e))return!1}if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||gs.bboxInMask(qs,e))return!0}return!1}return!0}hn(t,e,n,r,s){if(!this.Tn(t,r,s))return Qs.OUT_OF_FRUSTUM;if(t.ft=1/0,0===t.ke||t.mn)return this.vn(t),Qs.VISIBLE;if(this.yn(t),!this._n(t,e,n))return Qs.OUT_OF_FRUSTUM;if(0===t.geometricError)return Qs.VISIBLE;let i=this.j(t.H).maximumScreenSpaceError;null==i&&(i=16);let o=this.Mn(t);return 0===o&&t.parent&&(o=.5*(t.parent.On||0)),o>=i?Qs.VISIBLE:Qs.SCREEN_ERROR_TOO_SMALL}Kt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.coordToPointAtRes(e,r.getGLRes(),n)}_n(t,e,n){const r=t.id;let s=this.Xe.get(r);const{boundingVolume:i}=t,o=i.region,a=i.box,c=i.sphere,l=this.An(t.H),h=this.getRenderer();s&&s.version===l.version||(o?s=this.xn(t):a?s=this.In(t):c&&(s=this.Sn(t)),s&&this.Xe.set(r,s),s.version=l.version,t.dt&&(h.Ft(t.dt),delete t.dt));this.j(t.H).debug&&(this.Xe.get(r).node=t,h.Gt(t));const u=s.obbox;return u?b(n,u):!!c&&g(n,s.sphereBox)}xn(e){const n=this.getMap(),s=n.getGLRes(),i=e.boundingVolume.region;let{ws:o,en:c}=function(t){const e=t[0],n=t[1],r=t[2],s=t[3],i=t[4],o=t[5],a=oe([],e,n,i),c=oe([],r,s,o),l=fe(a,a),h=fe(c,c);return{ws:l,en:h}}(i);o=new t.Coordinate(o),c=new t.Coordinate(c);const l=n.coordToPointAtRes(o,s);l.z=n.altitudeToPoint(o.z,s);const h=n.coordToPointAtRes(c,s);h.z=n.altitudeToPoint(c.z,s);const u=[h.x,l.y,h.z,h.x,h.y,h.z,l.x,h.y,h.z,l.x,l.y,h.z,h.x,l.y,l.z,h.x,h.y,l.z,l.x,h.y,l.z,l.x,l.y,l.z],f=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],d=this.An(e.H);e!==d||d.Cn||(d.Cn=f);const m=this.Jt([],e),p=r.exactEquals(Gs,m);if(!p){a.transformMat4(f,f,m);const t=vs;for(let e=0;e<u.length;e+=3){let n=a.set(t,u[e],u[e+1],u[e+2]);p||(n=a.transformMat4(n,n,m)),u[e]=n[0],u[e+1]=n[1],u[e+2]=n[2]}}const y=n.pointAtResToCoord(new t.Point(f),s);y.z=(o.z+c.z)/2;const b=this.kn(u,f);for(let t=0;t<u.length;t++)u[t]-=f[t%3];return{obbox:b,boxPosition:u,boxCenter:f,boxCoord:y}}In(t){const e=this.getRenderer(),n=this.getMap(),s="identity"===n.getProjection().code.toLowerCase(),i=n.getGLRes(),{boxCenter:o,boxCoord:c}=this.Nn(t),l=t.boundingVolume.box,h=this.Ln(l,t.matrix),u=(d=l,function(t,e,n,r,s,i,o,a,c,l,h,u,f,d,m,p,y){return t[0]=e||0,t[1]=i||0,t[2]=l||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=h||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=u||0,t[11]=0,t[12]=s||0,t[13]=c||0,t[14]=f||0,t[15]=y,t}([],(f=h)[0],f[3],f[6],d[0],f[1],f[4],f[7],d[1],f[2],f[5],f[8],d[2],0,0,0,1));var f,d;const m=this.Jt([],t),p=r.exactEquals(Gs,m);p||a.transformMat4(o,o,m);const y=[],b=vs;for(let t=0;t<$s.length;t+=3){b[0]=$s[t],b[1]=$s[t+1],b[2]=$s[t+2],a.transformMat4(b,b,u),fe(b,b),s&&e.Je(b,b);const r=Ns.set(b[0],b[1],b[2]);n.coordToPointAtRes(r,i,Ls);let o=a.set(b,Ls.x,Ls.y,n.altitudeToPoint(r.z,i));p||(o=a.transformMat4(o,o,m)),y[t]=o[0],y[t+1]=o[1],y[t+2]=o[2]}const g=this.kn(y,o);for(let t=0;t<y.length;t++)y[t]-=o[t%3];return{obbox:g,boxPosition:y,boxCenter:o,boxCoord:c}}Sn(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=e.boundingVolume.sphere,o=i;let a=vs;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:fe(a,o),s&&r.Je(a,a);const c=new t.Coordinate(a),l=this.Kt(c,Ls).toArray();l[2]=n.altitudeToPoint(c.z,n.getGLRes());const h=this.En(c);return{boxCenter:l,boxCoord:c,sphereBox:[l,i[3]*h[2]]}}kn(t,e){const n=Ks(Os,t,0,1,4,5),r=Ks(As,t,0,3,4,7),s=Ks(xs,t,0,1,2,3);return[...e,...a.sub(vs,n,e),...a.sub(Ts,r,e),...a.sub(_s,s,e)]}Nn(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=n.getGLRes(),o=e.boundingVolume.box.slice(0,3);fe(o,o),s&&r.Je(o,o);const a=new t.Coordinate(o),c=n.coordToPointAtRes(a,i);return{boxCenter:[c.x,c.y,n.altitudeToPoint(a.z,i)],boxCoord:a}}Jt(t,e){const n=this.An(e.H),s=this.j(e.H),i=n.Cn,c=r.fromTranslation(Rs,a.set(vs,-i[0],-i[1],-i[2])),l=r.fromTranslation(Ps,i),h=s.rotation||Fs,u=o.fromEuler(Cs,...h),f=s.scale;let d;d=Array.isArray(f)?a.set(zs,f[0],f[1],f[2]):f&&a.set(zs,f,f,f)||js;const m=r.fromRotationTranslationScale(Us,u,Hs,d);return t=r.multiply(t,m,c),r.multiply(t,l,t)}vn(t){const e=this.j(t.H);if(!t.boundingVolume||this.Rn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;n?i=this.Pn(t).boxCenter:r?i=this.Un(t).boxCenter:s&&(i=this.Sn(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Bn=[a[0]||0,a[1]||0],t.Gn=o,t.Cn=i}Rn(t,e){if(!t.Bn)return!1;const n=e.coordOffset||Ds;return t.Bn[0]===n[0]&&t.Bn[1]===n[1]&&t.Gn===(e.heightOffset||0)}Un(t){return this.yn(t),this.xn(t)}Pn(t){return this.yn(t),this.Nn(t)}Ln(t,e){let n=t.slice(3,12);const r=c.fromMat4(Es,e);return n=c.multiply(n,r,n),n}En(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let r;return r=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:n.y/100,a.set(Is,n.x/100*1.01,n.y/100*1.01,r),Is}gn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(bt(n)&&(n=n.call(this,Array.isArray(e)?new t.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),s=t.coordToPointAtRes(e,r);return Ls.set(n[0],n[1]),s._sub(Ls),t.pointAtResToCoord(s,r)}return e}An(t){return this.Pe[t]}cn(e){const n=this.j(e).maxExtent;if(!n)return null;const r=this.Pe[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo((t=>this.Kt(t)))),r.maxExtent}Mn(t){const e=this.an,n=t.geometricError;if(0===n)return t.On=0,0;const s=this.j(t.H);let i=s.scale||1;if(Array.isArray(i)&&(i=a.length(i)),s.ecefTransform){const t=r.getScaling(Ss,s.ecefTransform);i*=a.len(t)}const o=this.getMap();let c;t.boundingVolume.region?c=function(t,e,n){t.Dn||(t.Dn=new ps(t.boundingVolume.region));return t.Dn.distanceToCamera(e,n)}(t,this.sn,this.rn):t.boundingVolume.sphere?c=Js(t.boundingVolume,this.sn):t.boundingVolume.box&&(c=Ys(t.boundingVolume,this.sn));const l=Math.max(Math.abs(c),1e-7),h=n*i*o.height/(l*e);return t.ft=c,t.On=h,h}Qe(){const t=this.getRenderer();t&&t.setToRedraw()}Dt(t){return this.Xe.get(t)}identify(e,n={}){const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];Array.isArray(e)&&(e=new t.Coordinate(e));const i=r.coordToContainerPoint(e);return this.identifyAtPoint(i,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&Nt(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return Nt(n,s.pick(t.x*i,t.y*i,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Wt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.J||(this.J=[]),this.J.push(t),this)}ze(){if(this.J){for(let t=0;t<this.J.length;t++)this.highlight(this.J[t]);delete this.J}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Z||(this.Z=[]),this.Z.push(t),this)}Fn(){if(this.Z){for(let t=0;t<this.Z.length;t++)this.showOnly(this.Z[t]);delete this.Z}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.Qe(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Qe(),this):this}nn(t){const e=this.getMap(),n=e.getGLRes();Bs.set(t[0],t[1]);const r=e.pointAtResToCoord(Bs,n);return"identity"===e.getProjection().code.toLowerCase()?(Ts[0]=r.x,Ts[1]=r.y,this.getRenderer().Ye(vs,Ts),r.set(vs[0],vs[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function Js(t,e,n){let r=t.sphere;n&&(r=a.transformMat4([0,0,0],r,n));const s=a.dist(r,e),i=t.sphere[3];return s<i?0:s-i}function Ys(t,e,n){const r=t.box;let s=a.set(vs,r[0],r[1],r[2]);n&&(s=a.transformMat4([0,0,0],s,n));return Vr(s,c.set(Es,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Zs(t,e,n){const s=(t=_t(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,mn:!0,service:n,visible:!!pt(n.visible)||n.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),H:e,ke:0,wn:!0,domainKey:s}}function Ks(t,e,n,r,s,i){const o=a.set(vs,e[3*n],e[3*n+1],e[3*n+2]),c=a.set(Ts,e[3*r],e[3*r+1],e[3*r+2]),l=a.set(_s,e[3*s],e[3*s+1],e[3*s+2]),h=a.set(Ms,e[3*i],e[3*i+1],e[3*i+2]);return t[0]=(o[0]+c[0]+l[0]+h[0])/4,t[1]=(o[1]+c[1]+l[1]+h[1])/4,t[2]=(o[2]+c[2]+l[2]+h[2])/4,t}function Xs(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function Ws(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?p.exactEquals(t,e):a.exactEquals(t,e):t===e}var Qs;Vs.mergeOptions(ws),Vs.registerRenderer("gl",Hr),Vs.registerRenderer("gpu",Hr),Vs.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(Qs||(Qs={}));let ti=null;function ei(){return ti||(ti={"image/crn":Dt.crn&&Dt.crn(),"image/ktx2":Dt.ktx2&&Dt.ktx2(),"image/cttf":Dt.ktx2&&Dt.ktx2(),"draco":Dt.draco&&Dt.draco()}),ti}const{Ajax:ni,GLTFLoader:ri}=Ft();class si{constructor(t,e,n){this.jn=t,this.zn=e||ri,this.Re=n,this.Hn=ei()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,s)):ni.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.qn(t,s,n,r)}))}qn(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.$n(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.zn(a,o.glb,{transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:i})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}$n(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),l=s.getUint32(20,!0),h=s.getUint32(24,!0),u=28+e;l>=570425344?(u-=8,o=a,l=c,h=0,a=0,c=0):h>=570425344&&(u-=4,o=l,l=a,h=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=Oe(t,u,a),u+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(u+=c),l>0&&(m=Ae(t,u,l),u+=l,h>0)){const e=xe(0,u,h);p=t.slice(e.offset,e.offset+e.byteLength),u+=h,f.push(p)}const y=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Se(d.BATCH_ID,t,undefined.offset,y);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:u,byteLength:s.byteLength+s.byteOffset-u}}}Vn(){return null}}const{Ajax:ii,GLTFLoader:oi}=Ft();class ai{constructor(t,e,n,r){this.jn=t,this.zn=e||oi,this.Re=n,this.Hn=ei(),this.Jn=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.qn(t,e,n,r,s)):ii.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.qn(t,s,n,r)}))}qn(t,e,n,r,s){return this.Yn(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.Zn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})}))}Yn(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.jn,decoders:this.Hn,supportedFormats:this.Re,maxTextureSize:i},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=At(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?ii.getArrayBuffer(r,{}).then((t=>this.Kn(r,{buffer:t.data,byteOffset:0},o))):ii.getJSON(r,{}).then((t=>this.Kn(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Kn(t,r,o)}}Kn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.zn(r,e,n);return s.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}}))}Zn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:h}=Ue(s,32+e,o),u={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Xn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Se(a.BATCH_ID,t,c.offset,f);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Wn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:l,batchTableBin:h,featureTable:a,i3dm:u,transferables:o}}Wn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)ci(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}Xn(t,e,n){return Pe(new Float32Array(t.length),t,e,n)}Vn(){return null}}function ci(t,e,n,r){if(t[0]=li(e,r),t[1]=li(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*hi(e),t[1]=(1-Math.abs(e))*hi(t[1])}return T.normalize(t,t)}function li(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function hi(t){return t<0?-1:1}const{Ajax:ui}=Ft();class fi{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.qn(t,e,n,r)):ui.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.qn(t,s,n,r)}))}qn(t,e,n,r){return this.Qn(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}Qn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:h}=Ue(s,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.tr||(this.tr=ei().draco),this.tr(m,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.er(t,e.attributes,c.offset,d,o,u,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Re(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?r.BATCH_ID=Se(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=di(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:l,batchTableBin:h,featureTable:a,pnts:r,transferables:o}}))}const y=this.er(t,a,c.offset,d,o,u,f);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?y.BATCH_ID=Se(a.BATCH_ID,t,c.offset,d):y.BATCH_ID=di(d);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:l,batchTableBin:h,featureTable:a,pnts:y,transferables:o})}er(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:l}=e.POSITION_QUANTIZED;c=c||0;const h=l?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Xn(l||new Uint16Array(t,c+h,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}Xn(t,e,n){return Pe(new Float32Array(t.length),t,e,n)}Vn(){return null}}function di(t){const e=St(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Re(e),array:n}}const{Ajax:mi,GLTFLoader:pi}=Ft();class yi{constructor(t,e,n,r){this.Re=n,this.jn=t,this.zn=e||pi,this.Jn=r}load(t,e,n=0,r=0,s){return e?this.qn(t,e,n,r,s):mi.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.qn(t,s,n,r)}))}qn(t,e,n,r,s){r||(r=e.byteLength);const i=this.nr(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new si(this.jn,this.zn,this.Re);else if("i3dm"===i[n].magic)r=new ai(this.jn,this.zn,this.Re,this.Jn);else if("pnts"===i[n].magic)r=new fi;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new yi(this.jn,this.zn,this.Re,this.Jn)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}nr(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=_e(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(e.transcoders){const n=t.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=e.transcoders.inject(O);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(O)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",O);export{si as B3DMLoader,yi as CMPTLoader,Vs as Geo3DTilesLayer,Rt as Geo3DTilesUtil,ve as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.124.2");
12
12
  //# sourceMappingURL=maptalks.3dtiles.es.js.map