@terra.gl/core 0.0.1-alpha.6 → 0.0.1-alpha.61

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,4 +1,4 @@
1
- (function(N,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],h):(N=typeof globalThis<"u"?globalThis:N||self,h(N["terra-gl"]={},N.THREE))})(this,function(N,h){"use strict";var $o=Object.defineProperty;var ea=(N,h,Oe)=>h in N?$o(N,h,{enumerable:!0,configurable:!0,writable:!0,value:Oe}):N[h]=Oe;var x=(N,h,Oe)=>ea(N,typeof h!="symbol"?h+"":h,Oe);function Oe(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const se=Oe(h),Zi="0.0.1-alpha.6",$t={name:"criska"};var Be=function(){var o=0,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",function(d){d.preventDefault(),n(++o%t.children.length)},!1);function e(d){return t.appendChild(d.dom),d}function n(d){for(var c=0;c<t.children.length;c++)t.children[c].style.display=c===d?"block":"none";o=d}var i=(performance||Date).now(),r=i,s=0,a=e(new Be.Panel("FPS","#0ff","#002")),l=e(new Be.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=e(new Be.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:e,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){s++;var d=(performance||Date).now();if(l.update(d-i,200),d>=r+1e3&&(a.update(s*1e3/(d-r),100),r=d,s=0,u)){var c=performance.memory;u.update(c.usedJSHeapSize/1048576,c.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:t,setMode:n}};Be.Panel=function(o,t,e){var n=1/0,i=0,r=Math.round,s=r(window.devicePixelRatio||1),a=80*s,l=48*s,u=3*s,d=2*s,c=3*s,p=15*s,f=74*s,m=30*s,v=document.createElement("canvas");v.width=a,v.height=l,v.style.cssText="width:80px;height:48px";var g=v.getContext("2d");return g.font="bold "+9*s+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=e,g.fillRect(0,0,a,l),g.fillStyle=t,g.fillText(o,u,d),g.fillRect(c,p,f,m),g.fillStyle=e,g.globalAlpha=.9,g.fillRect(c,p,f,m),{dom:v,update:function(b,y){n=Math.min(n,b),i=Math.max(i,b),g.fillStyle=e,g.globalAlpha=1,g.fillRect(0,0,a,p),g.fillStyle=t,g.fillText(r(b)+" "+o+" ("+r(n)+"-"+r(i)+")",u,d),g.drawImage(v,c+s,p,f-s,m,c,p,f-s,m),g.fillRect(c+f-s,p,s,m),g.fillStyle=e,g.globalAlpha=.9,g.fillRect(c+f-s,p,s,r((1-b/y)*m))}}};const ot=parseInt(h.REVISION.replace(/\D+/g,"")),Lt=ot>=125?"uv1":"uv2";function en(o,t){if(t===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(t===h.TriangleFanDrawMode||t===h.TriangleStripDrawMode){let e=o.getIndex();if(e===null){const s=[],a=o.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)s.push(l);o.setIndex(s),e=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=e.count-2,i=[];if(e)if(t===h.TriangleFanDrawMode)for(let s=1;s<=n;s++)i.push(e.getX(0)),i.push(e.getX(s)),i.push(e.getX(s+1));else for(let s=0;s<n;s++)s%2===0?(i.push(e.getX(s)),i.push(e.getX(s+1)),i.push(e.getX(s+2))):(i.push(e.getX(s+2)),i.push(e.getX(s+1)),i.push(e.getX(s)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=o.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),o}var oe=Uint8Array,Te=Uint16Array,St=Uint32Array,tn=new oe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),nn=new oe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ii=new oe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rn=function(o,t){for(var e=new Te(31),n=0;n<31;++n)e[n]=t+=1<<o[n-1];for(var i=new St(e[30]),n=1;n<30;++n)for(var r=e[n];r<e[n+1];++r)i[r]=r-e[n]<<5|n;return[e,i]},sn=rn(tn,2),on=sn[0],Ti=sn[1];on[28]=258,Ti[258]=28;for(var Pi=rn(nn,0),Ai=Pi[0],Mt=new Te(32768),Q=0;Q<32768;++Q){var Pe=(Q&43690)>>>1|(Q&21845)<<1;Pe=(Pe&52428)>>>2|(Pe&13107)<<2,Pe=(Pe&61680)>>>4|(Pe&3855)<<4,Mt[Q]=((Pe&65280)>>>8|(Pe&255)<<8)>>>1}for(var Ne=function(o,t,e){for(var n=o.length,i=0,r=new Te(t);i<n;++i)++r[o[i]-1];var s=new Te(t);for(i=0;i<t;++i)s[i]=s[i-1]+r[i-1]<<1;var a;if(e){a=new Te(1<<t);var l=15-t;for(i=0;i<n;++i)if(o[i])for(var u=i<<4|o[i],d=t-o[i],c=s[o[i]-1]++<<d,p=c|(1<<d)-1;c<=p;++c)a[Mt[c]>>>l]=u}else for(a=new Te(n),i=0;i<n;++i)o[i]&&(a[i]=Mt[s[o[i]-1]++]>>>15-o[i]);return a},je=new oe(288),Q=0;Q<144;++Q)je[Q]=8;for(var Q=144;Q<256;++Q)je[Q]=9;for(var Q=256;Q<280;++Q)je[Q]=7;for(var Q=280;Q<288;++Q)je[Q]=8;for(var an=new oe(32),Q=0;Q<32;++Q)an[Q]=5;var Wi=Ne(je,9,1),Gi=Ne(an,5,1),_t=function(o){for(var t=o[0],e=1;e<o.length;++e)o[e]>t&&(t=o[e]);return t},ue=function(o,t,e){var n=t/8|0;return(o[n]|o[n+1]<<8)>>(t&7)&e},Zt=function(o,t){var e=t/8|0;return(o[e]|o[e+1]<<8|o[e+2]<<16)>>(t&7)},Vi=function(o){return(o/8|0)+(o&7&&1)},Ci=function(o,t,e){(e==null||e>o.length)&&(e=o.length);var n=new(o instanceof Te?Te:o instanceof St?St:oe)(e-t);return n.set(o.subarray(t,e)),n},ki=function(o,t,e){var n=o.length;if(!n||e&&!e.l&&n<5)return t||new oe(0);var i=!t||e,r=!e||e.i;e||(e={}),t||(t=new oe(n*3));var s=function(Le){var pe=t.length;if(Le>pe){var Se=new oe(Math.max(pe*2,Le));Se.set(t),t=Se}},a=e.f||0,l=e.p||0,u=e.b||0,d=e.l,c=e.d,p=e.m,f=e.n,m=n*8;do{if(!d){e.f=a=ue(o,l,1);var v=ue(o,l+1,3);if(l+=3,v)if(v==1)d=Wi,c=Gi,p=9,f=5;else if(v==2){var w=ue(o,l,31)+257,S=ue(o,l+10,15)+4,P=w+ue(o,l+5,31)+1;l+=14;for(var I=new oe(P),T=new oe(19),M=0;M<S;++M)T[Ii[M]]=ue(o,l+M*3,7);l+=S*3;for(var A=_t(T),L=(1<<A)-1,Z=Ne(T,A,1),M=0;M<P;){var W=Z[ue(o,l,L)];l+=W&15;var g=W>>>4;if(g<16)I[M++]=g;else{var C=0,V=0;for(g==16?(V=3+ue(o,l,3),l+=2,C=I[M-1]):g==17?(V=3+ue(o,l,7),l+=3):g==18&&(V=11+ue(o,l,127),l+=7);V--;)I[M++]=C}}var D=I.subarray(0,w),G=I.subarray(w);p=_t(D),f=_t(G),d=Ne(D,p,1),c=Ne(G,f,1)}else throw"invalid block type";else{var g=Vi(l)+4,b=o[g-4]|o[g-3]<<8,y=g+b;if(y>n){if(r)throw"unexpected EOF";break}i&&s(u+b),t.set(o.subarray(g,y),u),e.b=u+=b,e.p=l=y*8;continue}if(l>m){if(r)throw"unexpected EOF";break}}i&&s(u+131072);for(var X=(1<<p)-1,U=(1<<f)-1,z=l;;z=l){var C=d[Zt(o,l)&X],j=C>>>4;if(l+=C&15,l>m){if(r)throw"unexpected EOF";break}if(!C)throw"invalid length/literal";if(j<256)t[u++]=j;else if(j==256){z=l,d=null;break}else{var H=j-254;if(j>264){var M=j-257,B=tn[M];H=ue(o,l,(1<<B)-1)+on[M],l+=B}var J=c[Zt(o,l)&U],de=J>>>4;if(!J)throw"invalid distance";l+=J&15;var G=Ai[de];if(de>3){var B=nn[de];G+=Zt(o,l)&(1<<B)-1,l+=B}if(l>m){if(r)throw"unexpected EOF";break}i&&s(u+131072);for(var Ke=u+H;u<Ke;u+=4)t[u]=t[u-G],t[u+1]=t[u+1-G],t[u+2]=t[u+2-G],t[u+3]=t[u+3-G];u=Ke}}e.l=d,e.p=z,e.b=u,d&&(a=1,e.m=p,e.d=c,e.n=f)}while(!a);return u==t.length?t:Ci(t,0,u)},Di=new oe(0),Fi=function(o){if((o[0]&15)!=8||o[0]>>>4>7||(o[0]<<8|o[1])%31)throw"invalid zlib data";if(o[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Oi(o,t){return ki((Fi(o),o.subarray(2,-4)),t)}var zi=typeof TextDecoder<"u"&&new TextDecoder,Xi=0;try{zi.decode(Di,{stream:!0}),Xi=1}catch{}class Ui extends h.Mesh{constructor(t,e={}){super(t),this.isWater=!0;const n=this,i=e.textureWidth!==void 0?e.textureWidth:512,r=e.textureHeight!==void 0?e.textureHeight:512,s=e.clipBias!==void 0?e.clipBias:0,a=e.alpha!==void 0?e.alpha:1,l=e.time!==void 0?e.time:0,u=e.waterNormals!==void 0?e.waterNormals:null,d=e.sunDirection!==void 0?e.sunDirection:new h.Vector3(.70707,.70707,0),c=new h.Color(e.sunColor!==void 0?e.sunColor:16777215),p=new h.Color(e.waterColor!==void 0?e.waterColor:8355711),f=e.eye!==void 0?e.eye:new h.Vector3(0,0,0),m=e.distortionScale!==void 0?e.distortionScale:20,v=e.side!==void 0?e.side:h.FrontSide,g=e.fog!==void 0?e.fog:!1,b=new h.Plane,y=new h.Vector3,w=new h.Vector3,S=new h.Vector3,P=new h.Matrix4,I=new h.Vector3(0,0,-1),T=new h.Vector4,M=new h.Vector3,A=new h.Vector3,L=new h.Vector4,Z=new h.Matrix4,W=new h.PerspectiveCamera,C=new h.WebGLRenderTarget(i,r),V={uniforms:h.UniformsUtils.merge([h.UniformsLib.fog,h.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new h.Matrix4},sunColor:{value:new h.Color(8355711)},sunDirection:{value:new h.Vector3(.70707,.70707,0)},eye:{value:new h.Vector3},waterColor:{value:new h.Color(5592405)}}]),vertexShader:`
1
+ (function(q,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],p):(q=typeof globalThis<"u"?globalThis:q||self,p(q["terra-gl"]={},q.THREE))})(this,function(q,p){"use strict";function af(i){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const t in i)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(i,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>i[t]})}}return e.default=i,Object.freeze(e)}const ct=af(p),lf="0.0.1-alpha.61",_o={name:"Criska"};var ui=function(){var i=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(m){m.preventDefault(),n(++i%e.children.length)},!1);function t(m){return e.appendChild(m.dom),m}function n(m){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===m?"block":"none";i=m}var r=(performance||Date).now(),o=r,a=0,c=t(new ui.Panel("FPS","#0ff","#002")),u=t(new ui.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=t(new ui.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:e,addPanel:t,showPanel:n,begin:function(){r=(performance||Date).now()},end:function(){a++;var m=(performance||Date).now();if(u.update(m-r,200),m>=o+1e3&&(c.update(a*1e3/(m-o),100),o=m,a=0,d)){var f=performance.memory;d.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return m},update:function(){r=this.end()},domElement:e,setMode:n}};ui.Panel=function(i,e,t){var n=1/0,r=0,o=Math.round,a=o(window.devicePixelRatio||1),c=80*a,u=48*a,d=3*a,m=2*a,f=3*a,g=15*a,_=74*a,w=30*a,b=document.createElement("canvas");b.width=c,b.height=u,b.style.cssText="width:80px;height:48px";var x=b.getContext("2d");return x.font="bold "+9*a+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=t,x.fillRect(0,0,c,u),x.fillStyle=e,x.fillText(i,d,m),x.fillRect(f,g,_,w),x.fillStyle=t,x.globalAlpha=.9,x.fillRect(f,g,_,w),{dom:b,update:function(L,M){n=Math.min(n,L),r=Math.max(r,L),x.fillStyle=t,x.globalAlpha=1,x.fillRect(0,0,c,g),x.fillStyle=e,x.fillText(o(L)+" "+i+" ("+o(n)+"-"+o(r)+")",d,m),x.drawImage(b,f+a,g,_-a,w,f,g,_-a,w),x.fillRect(f+_-a,g,a,w),x.fillStyle=t,x.globalAlpha=.9,x.fillRect(f+_-a,g,a,o((1-L/M)*w))}}};const $i=parseInt(p.REVISION.replace(/\D+/g,"")),vo=$i>=125?"uv1":"uv2";function Il(i,e){if(e===p.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),i;if(e===p.TriangleFanDrawMode||e===p.TriangleStripDrawMode){let t=i.getIndex();if(t===null){const a=[],c=i.getAttribute("position");if(c!==void 0){for(let u=0;u<c.count;u++)a.push(u);i.setIndex(a),t=i.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),i}const n=t.count-2,r=[];if(t)if(e===p.TriangleFanDrawMode)for(let a=1;a<=n;a++)r.push(t.getX(0)),r.push(t.getX(a)),r.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(r.push(t.getX(a)),r.push(t.getX(a+1)),r.push(t.getX(a+2))):(r.push(t.getX(a+2)),r.push(t.getX(a+1)),r.push(t.getX(a)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=i.clone();return o.setIndex(r),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),i}var Ut=Uint8Array,Dn=Uint16Array,wo=Uint32Array,Al=new Ut([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Fl=new Ut([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),cf=new Ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ol=function(i,e){for(var t=new Dn(31),n=0;n<31;++n)t[n]=e+=1<<i[n-1];for(var r=new wo(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)r[o]=o-t[n]<<5|n;return[t,r]},Dl=Ol(Al,2),zl=Dl[0],uf=Dl[1];zl[28]=258,uf[258]=28;for(var hf=Ol(Fl,0),df=hf[0],bo=new Dn(32768),We=0;We<32768;++We){var zn=(We&43690)>>>1|(We&21845)<<1;zn=(zn&52428)>>>2|(zn&13107)<<2,zn=(zn&61680)>>>4|(zn&3855)<<4,bo[We]=((zn&65280)>>>8|(zn&255)<<8)>>>1}for(var hi=function(i,e,t){for(var n=i.length,r=0,o=new Dn(e);r<n;++r)++o[i[r]-1];var a=new Dn(e);for(r=0;r<e;++r)a[r]=a[r-1]+o[r-1]<<1;var c;if(t){c=new Dn(1<<e);var u=15-e;for(r=0;r<n;++r)if(i[r])for(var d=r<<4|i[r],m=e-i[r],f=a[i[r]-1]++<<m,g=f|(1<<m)-1;f<=g;++f)c[bo[f]>>>u]=d}else for(c=new Dn(n),r=0;r<n;++r)i[r]&&(c[r]=bo[a[i[r]-1]++]>>>15-i[r]);return c},di=new Ut(288),We=0;We<144;++We)di[We]=8;for(var We=144;We<256;++We)di[We]=9;for(var We=256;We<280;++We)di[We]=7;for(var We=280;We<288;++We)di[We]=8;for(var Xl=new Ut(32),We=0;We<32;++We)Xl[We]=5;var ff=hi(di,9,1),pf=hi(Xl,5,1),xo=function(i){for(var e=i[0],t=1;t<i.length;++t)i[t]>e&&(e=i[t]);return e},qt=function(i,e,t){var n=e/8|0;return(i[n]|i[n+1]<<8)>>(e&7)&t},Mo=function(i,e){var t=e/8|0;return(i[t]|i[t+1]<<8|i[t+2]<<16)>>(e&7)},mf=function(i){return(i/8|0)+(i&7&&1)},gf=function(i,e,t){(t==null||t>i.length)&&(t=i.length);var n=new(i instanceof Dn?Dn:i instanceof wo?wo:Ut)(t-e);return n.set(i.subarray(e,t)),n},yf=function(i,e,t){var n=i.length;if(!n||t&&!t.l&&n<5)return e||new Ut(0);var r=!e||t,o=!t||t.i;t||(t={}),e||(e=new Ut(n*3));var a=function(dt){var Qe=e.length;if(dt>Qe){var Ye=new Ut(Math.max(Qe*2,dt));Ye.set(e),e=Ye}},c=t.f||0,u=t.p||0,d=t.b||0,m=t.l,f=t.d,g=t.m,_=t.n,w=n*8;do{if(!m){t.f=c=qt(i,u,1);var b=qt(i,u+1,3);if(u+=3,b)if(b==1)m=ff,f=pf,g=9,_=5;else if(b==2){var C=qt(i,u,31)+257,Z=qt(i,u+10,15)+4,z=C+qt(i,u+5,31)+1;u+=14;for(var D=new Ut(z),X=new Ut(19),I=0;I<Z;++I)X[cf[I]]=qt(i,u+I*3,7);u+=Z*3;for(var K=xo(X),V=(1<<K)-1,G=hi(X,K,1),I=0;I<z;){var k=G[qt(i,u,V)];u+=k&15;var x=k>>>4;if(x<16)D[I++]=x;else{var j=0,Y=0;for(x==16?(Y=3+qt(i,u,3),u+=2,j=D[I-1]):x==17?(Y=3+qt(i,u,7),u+=3):x==18&&(Y=11+qt(i,u,127),u+=7);Y--;)D[I++]=j}}var H=D.subarray(0,C),Q=D.subarray(C);g=xo(H),_=xo(Q),m=hi(H,g,1),f=hi(Q,_,1)}else throw"invalid block type";else{var x=mf(u)+4,L=i[x-4]|i[x-3]<<8,M=x+L;if(M>n){if(o)throw"unexpected EOF";break}r&&a(d+L),e.set(i.subarray(x,M),d),t.b=d+=L,t.p=u=M*8;continue}if(u>w){if(o)throw"unexpected EOF";break}}r&&a(d+131072);for(var ie=(1<<g)-1,re=(1<<_)-1,le=u;;le=u){var j=m[Mo(i,u)&ie],de=j>>>4;if(u+=j&15,u>w){if(o)throw"unexpected EOF";break}if(!j)throw"invalid length/literal";if(de<256)e[d++]=de;else if(de==256){le=u,m=null;break}else{var ge=de-254;if(de>264){var I=de-257,fe=Al[I];ge=qt(i,u,(1<<fe)-1)+zl[I],u+=fe}var Se=f[Mo(i,u)&re],rt=Se>>>4;if(!Se)throw"invalid distance";u+=Se&15;var Q=df[rt];if(rt>3){var fe=Fl[rt];Q+=Mo(i,u)&(1<<fe)-1,u+=fe}if(u>w){if(o)throw"unexpected EOF";break}r&&a(d+131072);for(var it=d+ge;d<it;d+=4)e[d]=e[d-Q],e[d+1]=e[d+1-Q],e[d+2]=e[d+2-Q],e[d+3]=e[d+3-Q];d=it}}t.l=m,t.p=le,t.b=d,m&&(c=1,t.m=g,t.d=f,t.n=_)}while(!c);return d==e.length?e:gf(e,0,d)},_f=new Ut(0),vf=function(i){if((i[0]&15)!=8||i[0]>>>4>7||(i[0]<<8|i[1])%31)throw"invalid zlib data";if(i[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function wf(i,e){return yf((vf(i),i.subarray(2,-4)),e)}var bf=typeof TextDecoder<"u"&&new TextDecoder,xf=0;try{bf.decode(_f,{stream:!0}),xf=1}catch{}class Mf extends p.Mesh{constructor(e,t={}){super(e),this.isWater=!0;const n=this,r=t.textureWidth!==void 0?t.textureWidth:512,o=t.textureHeight!==void 0?t.textureHeight:512,a=t.clipBias!==void 0?t.clipBias:0,c=t.alpha!==void 0?t.alpha:1,u=t.time!==void 0?t.time:0,d=t.waterNormals!==void 0?t.waterNormals:null,m=t.sunDirection!==void 0?t.sunDirection:new p.Vector3(.70707,.70707,0),f=new p.Color(t.sunColor!==void 0?t.sunColor:16777215),g=new p.Color(t.waterColor!==void 0?t.waterColor:8355711),_=t.eye!==void 0?t.eye:new p.Vector3(0,0,0),w=t.distortionScale!==void 0?t.distortionScale:20,b=t.side!==void 0?t.side:p.FrontSide,x=t.fog!==void 0?t.fog:!1,L=new p.Plane,M=new p.Vector3,C=new p.Vector3,Z=new p.Vector3,z=new p.Matrix4,D=new p.Vector3(0,0,-1),X=new p.Vector4,I=new p.Vector3,K=new p.Vector3,V=new p.Vector4,G=new p.Matrix4,k=new p.PerspectiveCamera,j=new p.WebGLRenderTarget(r,o),Y={uniforms:p.UniformsUtils.merge([p.UniformsLib.fog,p.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new p.Matrix4},sunColor:{value:new p.Color(8355711)},sunDirection:{value:new p.Vector3(.70707,.70707,0)},eye:{value:new p.Vector3},waterColor:{value:new p.Color(5592405)}}]),vertexShader:`
2
2
  uniform mat4 textureMatrix;
3
3
  uniform float time;
4
4
 
@@ -92,14 +92,124 @@
92
92
  gl_FragColor = vec4( outgoingLight, alpha );
93
93
 
94
94
  #include <tonemapping_fragment>
95
- #include <${ot>=154?"colorspace_fragment":"encodings_fragment"}>
95
+ #include <${$i>=154?"colorspace_fragment":"encodings_fragment"}>
96
96
  #include <fog_fragment>
97
- }`},D=new h.ShaderMaterial({fragmentShader:V.fragmentShader,vertexShader:V.vertexShader,uniforms:h.UniformsUtils.clone(V.uniforms),lights:!0,side:v,fog:g});D.uniforms.mirrorSampler.value=C.texture,D.uniforms.textureMatrix.value=Z,D.uniforms.alpha.value=a,D.uniforms.time.value=l,D.uniforms.normalSampler.value=u,D.uniforms.sunColor.value=c,D.uniforms.waterColor.value=p,D.uniforms.sunDirection.value=d,D.uniforms.distortionScale.value=m,D.uniforms.eye.value=f,n.material=D,n.onBeforeRender=function(G,X,U){if(w.setFromMatrixPosition(n.matrixWorld),S.setFromMatrixPosition(U.matrixWorld),P.extractRotation(n.matrixWorld),y.set(0,0,1),y.applyMatrix4(P),M.subVectors(w,S),M.dot(y)>0)return;M.reflect(y).negate(),M.add(w),P.extractRotation(U.matrixWorld),I.set(0,0,-1),I.applyMatrix4(P),I.add(S),A.subVectors(w,I),A.reflect(y).negate(),A.add(w),W.position.copy(M),W.up.set(0,1,0),W.up.applyMatrix4(P),W.up.reflect(y),W.lookAt(A),W.far=U.far,W.updateMatrixWorld(),W.projectionMatrix.copy(U.projectionMatrix),Z.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),Z.multiply(W.projectionMatrix),Z.multiply(W.matrixWorldInverse),b.setFromNormalAndCoplanarPoint(y,w),b.applyMatrix4(W.matrixWorldInverse),T.set(b.normal.x,b.normal.y,b.normal.z,b.constant);const z=W.projectionMatrix;L.x=(Math.sign(T.x)+z.elements[8])/z.elements[0],L.y=(Math.sign(T.y)+z.elements[9])/z.elements[5],L.z=-1,L.w=(1+z.elements[10])/z.elements[14],T.multiplyScalar(2/T.dot(L)),z.elements[2]=T.x,z.elements[6]=T.y,z.elements[10]=T.z+1-s,z.elements[14]=T.w,f.setFromMatrixPosition(U.matrixWorld);const j=G.getRenderTarget(),H=G.xr.enabled,B=G.shadowMap.autoUpdate;n.visible=!1,G.xr.enabled=!1,G.shadowMap.autoUpdate=!1,G.setRenderTarget(C),G.state.buffers.depth.setMask(!0),G.autoClear===!1&&G.clear(),G.render(X,W),n.visible=!0,G.xr.enabled=H,G.shadowMap.autoUpdate=B,G.setRenderTarget(j);const J=U.viewport;J!==void 0&&G.state.viewport(J)}}}var Yi=Object.defineProperty,Ki=(o,t,e)=>t in o?Yi(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,Bi=(o,t,e)=>(Ki(o,t+"",e),e);class Ni{constructor(){Bi(this,"_listeners")}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let r=0,s=i.length;r<s;r++)i[r].call(this,t);t.target=null}}}var ji=Object.defineProperty,Ri=(o,t,e)=>t in o?ji(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,F=(o,t,e)=>(Ri(o,typeof t!="symbol"?t+"":t,e),e);const at=new h.Ray,ln=new h.Plane,Ji=Math.cos(70*(Math.PI/180)),cn=(o,t)=>(o%t+t)%t;class Qi extends Ni{constructor(t,e){super(),F(this,"object"),F(this,"domElement"),F(this,"enabled",!0),F(this,"target",new h.Vector3),F(this,"minDistance",0),F(this,"maxDistance",1/0),F(this,"minZoom",0),F(this,"maxZoom",1/0),F(this,"minPolarAngle",0),F(this,"maxPolarAngle",Math.PI),F(this,"minAzimuthAngle",-1/0),F(this,"maxAzimuthAngle",1/0),F(this,"enableDamping",!1),F(this,"dampingFactor",.05),F(this,"enableZoom",!0),F(this,"zoomSpeed",1),F(this,"enableRotate",!0),F(this,"rotateSpeed",1),F(this,"enablePan",!0),F(this,"panSpeed",1),F(this,"screenSpacePanning",!0),F(this,"keyPanSpeed",7),F(this,"zoomToCursor",!1),F(this,"autoRotate",!1),F(this,"autoRotateSpeed",2),F(this,"reverseOrbit",!1),F(this,"reverseHorizontalOrbit",!1),F(this,"reverseVerticalOrbit",!1),F(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),F(this,"mouseButtons",{LEFT:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN}),F(this,"touches",{ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN}),F(this,"target0"),F(this,"position0"),F(this,"zoom0"),F(this,"_domElementKeyEvents",null),F(this,"getPolarAngle"),F(this,"getAzimuthalAngle"),F(this,"setPolarAngle"),F(this,"setAzimuthalAngle"),F(this,"getDistance"),F(this,"getZoomScale"),F(this,"listenToKeyEvents"),F(this,"stopListenToKeyEvents"),F(this,"saveState"),F(this,"reset"),F(this,"update"),F(this,"connect"),F(this,"dispose"),F(this,"dollyIn"),F(this,"dollyOut"),F(this,"getScale"),F(this,"setScale"),this.object=t,this.domElement=e,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>d.phi,this.getAzimuthalAngle=()=>d.theta,this.setPolarAngle=_=>{let k=cn(_,2*Math.PI),O=d.phi;O<0&&(O+=2*Math.PI),k<0&&(k+=2*Math.PI);let R=Math.abs(k-O);2*Math.PI-R<R&&(k<O?k+=2*Math.PI:O+=2*Math.PI),c.phi=k-O,n.update()},this.setAzimuthalAngle=_=>{let k=cn(_,2*Math.PI),O=d.theta;O<0&&(O+=2*Math.PI),k<0&&(k+=2*Math.PI);let R=Math.abs(k-O);2*Math.PI-R<R&&(k<O?k+=2*Math.PI:O+=2*Math.PI),c.theta=k-O,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=_=>{_.addEventListener("keydown",Et),this._domElementKeyEvents=_},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Et),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(i),n.update(),l=a.NONE},this.update=(()=>{const _=new h.Vector3,k=new h.Vector3(0,1,0),O=new h.Quaternion().setFromUnitVectors(t.up,k),R=O.clone().invert(),q=new h.Vector3,_e=new h.Quaternion,Ve=2*Math.PI;return function(){const Mi=n.object.position;O.setFromUnitVectors(t.up,k),R.copy(O).invert(),_.copy(Mi).sub(n.target),_.applyQuaternion(O),d.setFromVector3(_),n.autoRotate&&l===a.NONE&&V(W()),n.enableDamping?(d.theta+=c.theta*n.dampingFactor,d.phi+=c.phi*n.dampingFactor):(d.theta+=c.theta,d.phi+=c.phi);let Ze=n.minAzimuthAngle,Ie=n.maxAzimuthAngle;isFinite(Ze)&&isFinite(Ie)&&(Ze<-Math.PI?Ze+=Ve:Ze>Math.PI&&(Ze-=Ve),Ie<-Math.PI?Ie+=Ve:Ie>Math.PI&&(Ie-=Ve),Ze<=Ie?d.theta=Math.max(Ze,Math.min(Ie,d.theta)):d.theta=d.theta>(Ze+Ie)/2?Math.max(Ze,d.theta):Math.min(Ie,d.theta)),d.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,d.phi)),d.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(f,n.dampingFactor):n.target.add(f),n.zoomToCursor&&A||n.object.isOrthographicCamera?d.radius=J(d.radius):d.radius=J(d.radius*p),_.setFromSpherical(d),_.applyQuaternion(R),Mi.copy(n.target).add(_),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(c.theta*=1-n.dampingFactor,c.phi*=1-n.dampingFactor,f.multiplyScalar(1-n.dampingFactor)):(c.set(0,0,0),f.set(0,0,0));let it=!1;if(n.zoomToCursor&&A){let rt=null;if(n.object instanceof h.PerspectiveCamera&&n.object.isPerspectiveCamera){const st=_.length();rt=J(st*p);const xt=st-rt;n.object.position.addScaledVector(T,xt),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const st=new h.Vector3(M.x,M.y,0);st.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix(),it=!0;const xt=new h.Vector3(M.x,M.y,0);xt.unproject(n.object),n.object.position.sub(xt).add(st),n.object.updateMatrixWorld(),rt=_.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;rt!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(rt).add(n.object.position):(at.origin.copy(n.object.position),at.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(at.direction))<Ji?t.lookAt(n.target):(ln.setFromNormalAndCoplanarPoint(n.object.up,n.target),at.intersectPlane(ln,n.target))))}else n.object instanceof h.OrthographicCamera&&n.object.isOrthographicCamera&&(it=p!==1,it&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix()));return p=1,A=!1,it||q.distanceToSquared(n.object.position)>u||8*(1-_e.dot(n.object.quaternion))>u?(n.dispatchEvent(i),q.copy(n.object.position),_e.copy(n.object.quaternion),it=!1,!0):!1}})(),this.connect=_=>{n.domElement=_,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Li),n.domElement.addEventListener("pointerdown",wi),n.domElement.addEventListener("pointercancel",nt),n.domElement.addEventListener("wheel",xi)},this.dispose=()=>{var _,k,O,R,q,_e;n.domElement&&(n.domElement.style.touchAction="auto"),(_=n.domElement)==null||_.removeEventListener("contextmenu",Li),(k=n.domElement)==null||k.removeEventListener("pointerdown",wi),(O=n.domElement)==null||O.removeEventListener("pointercancel",nt),(R=n.domElement)==null||R.removeEventListener("wheel",xi),(q=n.domElement)==null||q.ownerDocument.removeEventListener("pointermove",Ht),(_e=n.domElement)==null||_e.ownerDocument.removeEventListener("pointerup",nt),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Et)};const n=this,i={type:"change"},r={type:"start"},s={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=a.NONE;const u=1e-6,d=new h.Spherical,c=new h.Spherical;let p=1;const f=new h.Vector3,m=new h.Vector2,v=new h.Vector2,g=new h.Vector2,b=new h.Vector2,y=new h.Vector2,w=new h.Vector2,S=new h.Vector2,P=new h.Vector2,I=new h.Vector2,T=new h.Vector3,M=new h.Vector2;let A=!1;const L=[],Z={};function W(){return 2*Math.PI/60/60*n.autoRotateSpeed}function C(){return Math.pow(.95,n.zoomSpeed)}function V(_){n.reverseOrbit||n.reverseHorizontalOrbit?c.theta+=_:c.theta-=_}function D(_){n.reverseOrbit||n.reverseVerticalOrbit?c.phi+=_:c.phi-=_}const G=(()=>{const _=new h.Vector3;return function(O,R){_.setFromMatrixColumn(R,0),_.multiplyScalar(-O),f.add(_)}})(),X=(()=>{const _=new h.Vector3;return function(O,R){n.screenSpacePanning===!0?_.setFromMatrixColumn(R,1):(_.setFromMatrixColumn(R,0),_.crossVectors(n.object.up,_)),_.multiplyScalar(O),f.add(_)}})(),U=(()=>{const _=new h.Vector3;return function(O,R){const q=n.domElement;if(q&&n.object instanceof h.PerspectiveCamera&&n.object.isPerspectiveCamera){const _e=n.object.position;_.copy(_e).sub(n.target);let Ve=_.length();Ve*=Math.tan(n.object.fov/2*Math.PI/180),G(2*O*Ve/q.clientHeight,n.object.matrix),X(2*R*Ve/q.clientHeight,n.object.matrix)}else q&&n.object instanceof h.OrthographicCamera&&n.object.isOrthographicCamera?(G(O*(n.object.right-n.object.left)/n.object.zoom/q.clientWidth,n.object.matrix),X(R*(n.object.top-n.object.bottom)/n.object.zoom/q.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function z(_){n.object instanceof h.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof h.OrthographicCamera&&n.object.isOrthographicCamera?p=_:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function j(_){z(p/_)}function H(_){z(p*_)}function B(_){if(!n.zoomToCursor||!n.domElement)return;A=!0;const k=n.domElement.getBoundingClientRect(),O=_.clientX-k.left,R=_.clientY-k.top,q=k.width,_e=k.height;M.x=O/q*2-1,M.y=-(R/_e)*2+1,T.set(M.x,M.y,1).unproject(n.object).sub(n.object.position).normalize()}function J(_){return Math.max(n.minDistance,Math.min(n.maxDistance,_))}function de(_){m.set(_.clientX,_.clientY)}function Ke(_){B(_),S.set(_.clientX,_.clientY)}function Le(_){b.set(_.clientX,_.clientY)}function pe(_){v.set(_.clientX,_.clientY),g.subVectors(v,m).multiplyScalar(n.rotateSpeed);const k=n.domElement;k&&(V(2*Math.PI*g.x/k.clientHeight),D(2*Math.PI*g.y/k.clientHeight)),m.copy(v),n.update()}function Se(_){P.set(_.clientX,_.clientY),I.subVectors(P,S),I.y>0?j(C()):I.y<0&&H(C()),S.copy(P),n.update()}function Me(_){y.set(_.clientX,_.clientY),w.subVectors(y,b).multiplyScalar(n.panSpeed),U(w.x,w.y),b.copy(y),n.update()}function ce(_){B(_),_.deltaY<0?H(C()):_.deltaY>0&&j(C()),n.update()}function re(_){let k=!1;switch(_.code){case n.keys.UP:U(0,n.keyPanSpeed),k=!0;break;case n.keys.BOTTOM:U(0,-n.keyPanSpeed),k=!0;break;case n.keys.LEFT:U(n.keyPanSpeed,0),k=!0;break;case n.keys.RIGHT:U(-n.keyPanSpeed,0),k=!0;break}k&&(_.preventDefault(),n.update())}function wt(){if(L.length==1)m.set(L[0].pageX,L[0].pageY);else{const _=.5*(L[0].pageX+L[1].pageX),k=.5*(L[0].pageY+L[1].pageY);m.set(_,k)}}function et(){if(L.length==1)b.set(L[0].pageX,L[0].pageY);else{const _=.5*(L[0].pageX+L[1].pageX),k=.5*(L[0].pageY+L[1].pageY);b.set(_,k)}}function fe(){const _=L[0].pageX-L[1].pageX,k=L[0].pageY-L[1].pageY,O=Math.sqrt(_*_+k*k);S.set(0,O)}function tt(){n.enableZoom&&fe(),n.enablePan&&et()}function ve(){n.enableZoom&&fe(),n.enableRotate&&wt()}function gi(_){if(L.length==1)v.set(_.pageX,_.pageY);else{const O=qt(_),R=.5*(_.pageX+O.x),q=.5*(_.pageY+O.y);v.set(R,q)}g.subVectors(v,m).multiplyScalar(n.rotateSpeed);const k=n.domElement;k&&(V(2*Math.PI*g.x/k.clientHeight),D(2*Math.PI*g.y/k.clientHeight)),m.copy(v)}function bi(_){if(L.length==1)y.set(_.pageX,_.pageY);else{const k=qt(_),O=.5*(_.pageX+k.x),R=.5*(_.pageY+k.y);y.set(O,R)}w.subVectors(y,b).multiplyScalar(n.panSpeed),U(w.x,w.y),b.copy(y)}function vi(_){const k=qt(_),O=_.pageX-k.x,R=_.pageY-k.y,q=Math.sqrt(O*O+R*R);P.set(0,q),I.set(0,Math.pow(P.y/S.y,n.zoomSpeed)),j(I.y),S.copy(P)}function No(_){n.enableZoom&&vi(_),n.enablePan&&bi(_)}function jo(_){n.enableZoom&&vi(_),n.enableRotate&&gi(_)}function wi(_){var k,O;n.enabled!==!1&&(L.length===0&&((k=n.domElement)==null||k.ownerDocument.addEventListener("pointermove",Ht),(O=n.domElement)==null||O.ownerDocument.addEventListener("pointerup",nt)),Eo(_),_.pointerType==="touch"?Qo(_):Ro(_))}function Ht(_){n.enabled!==!1&&(_.pointerType==="touch"?Ho(_):Jo(_))}function nt(_){var k,O,R;qo(_),L.length===0&&((k=n.domElement)==null||k.releasePointerCapture(_.pointerId),(O=n.domElement)==null||O.ownerDocument.removeEventListener("pointermove",Ht),(R=n.domElement)==null||R.ownerDocument.removeEventListener("pointerup",nt)),n.dispatchEvent(s),l=a.NONE}function Ro(_){let k;switch(_.button){case 0:k=n.mouseButtons.LEFT;break;case 1:k=n.mouseButtons.MIDDLE;break;case 2:k=n.mouseButtons.RIGHT;break;default:k=-1}switch(k){case h.MOUSE.DOLLY:if(n.enableZoom===!1)return;Ke(_),l=a.DOLLY;break;case h.MOUSE.ROTATE:if(_.ctrlKey||_.metaKey||_.shiftKey){if(n.enablePan===!1)return;Le(_),l=a.PAN}else{if(n.enableRotate===!1)return;de(_),l=a.ROTATE}break;case h.MOUSE.PAN:if(_.ctrlKey||_.metaKey||_.shiftKey){if(n.enableRotate===!1)return;de(_),l=a.ROTATE}else{if(n.enablePan===!1)return;Le(_),l=a.PAN}break;default:l=a.NONE}l!==a.NONE&&n.dispatchEvent(r)}function Jo(_){if(n.enabled!==!1)switch(l){case a.ROTATE:if(n.enableRotate===!1)return;pe(_);break;case a.DOLLY:if(n.enableZoom===!1)return;Se(_);break;case a.PAN:if(n.enablePan===!1)return;Me(_);break}}function xi(_){n.enabled===!1||n.enableZoom===!1||l!==a.NONE&&l!==a.ROTATE||(_.preventDefault(),n.dispatchEvent(r),ce(_),n.dispatchEvent(s))}function Et(_){n.enabled===!1||n.enablePan===!1||re(_)}function Qo(_){switch(Si(_),L.length){case 1:switch(n.touches.ONE){case h.TOUCH.ROTATE:if(n.enableRotate===!1)return;wt(),l=a.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(n.enablePan===!1)return;et(),l=a.TOUCH_PAN;break;default:l=a.NONE}break;case 2:switch(n.touches.TWO){case h.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;tt(),l=a.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ve(),l=a.TOUCH_DOLLY_ROTATE;break;default:l=a.NONE}break;default:l=a.NONE}l!==a.NONE&&n.dispatchEvent(r)}function Ho(_){switch(Si(_),l){case a.TOUCH_ROTATE:if(n.enableRotate===!1)return;gi(_),n.update();break;case a.TOUCH_PAN:if(n.enablePan===!1)return;bi(_),n.update();break;case a.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;No(_),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;jo(_),n.update();break;default:l=a.NONE}}function Li(_){n.enabled!==!1&&_.preventDefault()}function Eo(_){L.push(_)}function qo(_){delete Z[_.pointerId];for(let k=0;k<L.length;k++)if(L[k].pointerId==_.pointerId){L.splice(k,1);return}}function Si(_){let k=Z[_.pointerId];k===void 0&&(k=new h.Vector2,Z[_.pointerId]=k),k.set(_.pageX,_.pageY)}function qt(_){const k=_.pointerId===L[0].pointerId?L[1]:L[0];return Z[k.pointerId]}this.dollyIn=(_=C())=>{H(_),n.update()},this.dollyOut=(_=C())=>{j(_),n.update()},this.getScale=()=>p,this.setScale=_=>{z(_),n.update()},this.getZoomScale=()=>C(),e!==void 0&&this.connect(e),this.update()}}class Hi extends Qi{constructor(t,e){super(t,e),this.screenSpacePanning=!1,this.mouseButtons.LEFT=h.MOUSE.PAN,this.mouseButtons.RIGHT=h.MOUSE.ROTATE,this.touches.ONE=h.TOUCH.PAN,this.touches.TWO=h.TOUCH.DOLLY_ROTATE}}function ze(o){if(typeof TextDecoder<"u")return new TextDecoder().decode(o);let t="";for(let e=0,n=o.length;e<n;e++)t+=String.fromCharCode(o[e]);try{return decodeURIComponent(escape(t))}catch{return t}}const Ce="srgb",we="srgb-linear",un=3001,Ei=3e3;class qi extends h.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new ir(e)}),this.register(function(e){return new rr(e)}),this.register(function(e){return new pr(e)}),this.register(function(e){return new fr(e)}),this.register(function(e){return new mr(e)}),this.register(function(e){return new or(e)}),this.register(function(e){return new ar(e)}),this.register(function(e){return new lr(e)}),this.register(function(e){return new cr(e)}),this.register(function(e){return new nr(e)}),this.register(function(e){return new ur(e)}),this.register(function(e){return new sr(e)}),this.register(function(e){return new dr(e)}),this.register(function(e){return new hr(e)}),this.register(function(e){return new er(e)}),this.register(function(e){return new yr(e)}),this.register(function(e){return new gr(e)})}load(t,e,n,i){const r=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const u=h.LoaderUtils.extractUrlBase(t);s=h.LoaderUtils.resolveURL(u,this.path)}else s=h.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(u){i?i(u):console.error(u),r.manager.itemError(t),r.manager.itemEnd(t)},l=new h.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(t,function(u){try{r.parse(u,s,function(d){e(d),r.manager.itemEnd(t)},a)}catch(d){a(d)}},n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,i){let r;const s={},a={};if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(ze(new Uint8Array(t.slice(0,4)))===hn){try{s[Y.KHR_BINARY_GLTF]=new br(t)}catch(d){i&&i(d);return}r=JSON.parse(s[Y.KHR_BINARY_GLTF].content)}else r=JSON.parse(ze(new Uint8Array(t)));else r=t;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Wr(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](l);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,s[d.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const d=r.extensionsUsed[u],c=r.extensionsRequired||[];switch(d){case Y.KHR_MATERIALS_UNLIT:s[d]=new tr;break;case Y.KHR_DRACO_MESH_COMPRESSION:s[d]=new vr(r,this.dracoLoader);break;case Y.KHR_TEXTURE_TRANSFORM:s[d]=new wr;break;case Y.KHR_MESH_QUANTIZATION:s[d]=new xr;break;default:c.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(t,e){const n=this;return new Promise(function(i,r){n.parse(t,e,i,r)})}}function $i(){let o={};return{get:function(t){return o[t]},add:function(t,e){o[t]=e},remove:function(t){delete o[t]},removeAll:function(){o={}}}}const Y={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class er{constructor(t){this.parser=t,this.name=Y.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,i=e.length;n<i;n++){const r=e[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let i=e.cache.get(n);if(i)return i;const r=e.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let u;const d=new h.Color(16777215);l.color!==void 0&&d.setRGB(l.color[0],l.color[1],l.color[2],we);const c=l.range!==void 0?l.range:0;switch(l.type){case"directional":u=new h.DirectionalLight(d),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new h.PointLight(d),u.distance=c;break;case"spot":u=new h.SpotLight(d),u.distance=c,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,u.angle=l.spot.outerConeAngle,u.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return u.position.set(0,0,0),u.decay=2,xe(u,l),l.intensity!==void 0&&(u.intensity=l.intensity),u.name=e.createUniqueName(l.name||"light_"+t),i=Promise.resolve(u),e.cache.add(n,i),i}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,r=n.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(e.cache,a,l)})}}class tr{constructor(){this.name=Y.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(t,e,n){const i=[];t.color=new h.Color(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const s=r.baseColorFactor;t.color.setRGB(s[0],s[1],s[2],we),t.opacity=s[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(t,"map",r.baseColorTexture,Ce))}return Promise.all(i)}}class nr{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name].emissiveStrength;return r!==void 0&&(e.emissiveIntensity=r),Promise.resolve()}}class ir{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];if(s.clearcoatFactor!==void 0&&(e.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&r.push(n.assignTexture(e,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(e,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(e,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const a=s.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new h.Vector2(a,a)}return Promise.all(r)}}class rr{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_DISPERSION}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return e.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class sr{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return s.iridescenceFactor!==void 0&&(e.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&r.push(n.assignTexture(e,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(e.iridescenceIOR=s.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(e,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(r)}}class or{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_SHEEN}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[];e.sheenColor=new h.Color(0,0,0),e.sheenRoughness=0,e.sheen=1;const s=i.extensions[this.name];if(s.sheenColorFactor!==void 0){const a=s.sheenColorFactor;e.sheenColor.setRGB(a[0],a[1],a[2],we)}return s.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&r.push(n.assignTexture(e,"sheenColorMap",s.sheenColorTexture,Ce)),s.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(e,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(r)}}class ar{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return s.transmissionFactor!==void 0&&(e.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&r.push(n.assignTexture(e,"transmissionMap",s.transmissionTexture)),Promise.all(r)}}class lr{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_VOLUME}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&r.push(n.assignTexture(e,"thicknessMap",s.thicknessTexture)),e.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return e.attenuationColor=new h.Color().setRGB(a[0],a[1],a[2],we),Promise.all(r)}}class cr{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_IOR}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const i=this.parser.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=i.extensions[this.name];return e.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class ur{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_SPECULAR}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];e.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&r.push(n.assignTexture(e,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return e.specularColor=new h.Color().setRGB(a[0],a[1],a[2],we),s.specularColorTexture!==void 0&&r.push(n.assignTexture(e,"specularColorMap",s.specularColorTexture,Ce)),Promise.all(r)}}class hr{constructor(t){this.parser=t,this.name=Y.EXT_MATERIALS_BUMP}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return e.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&r.push(n.assignTexture(e,"bumpMap",s.bumpTexture)),Promise.all(r)}}class dr{constructor(t){this.parser=t,this.name=Y.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){const n=this.parser.json.materials[t];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(t,e){const n=this.parser,i=n.json.materials[t];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const r=[],s=i.extensions[this.name];return s.anisotropyStrength!==void 0&&(e.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(e.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&r.push(n.assignTexture(e,"anisotropyMap",s.anisotropyTexture)),Promise.all(r)}}class pr{constructor(t){this.parser=t,this.name=Y.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,i=n.textures[t];if(!i.extensions||!i.extensions[this.name])return null;const r=i.extensions[this.name],s=e.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class fr{constructor(t){this.parser=t,this.name=Y.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let l=n.textureLoader;if(a.uri){const u=n.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(t,s.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class mr{constructor(t){this.parser=t,this.name=Y.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,n=this.parser,i=n.json,r=i.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=i.images[s.source];let l=n.textureLoader;if(a.uri){const u=n.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(t,s.source,l);if(i.extensionsRequired&&i.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class yr{constructor(t){this.name=Y.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],r=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=i.byteOffset||0,u=i.byteLength||0,d=i.count,c=i.byteStride,p=new Uint8Array(a,l,u);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(d,c,p,i.mode,i.filter).then(function(f){return f.buffer}):s.ready.then(function(){const f=new ArrayBuffer(d*c);return s.decodeGltfBuffer(new Uint8Array(f),d,c,p,i.mode,i.filter),f})})}else return null}}class gr{constructor(t){this.name=Y.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=e.meshes[n.mesh];for(const u of i.primitives)if(u.mode!==ae.TRIANGLES&&u.mode!==ae.TRIANGLE_STRIP&&u.mode!==ae.TRIANGLE_FAN&&u.mode!==void 0)return null;const s=n.extensions[this.name].attributes,a=[],l={};for(const u in s)a.push(this.parser.getDependency("accessor",s[u]).then(d=>(l[u]=d,l[u])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(u=>{const d=u.pop(),c=d.isGroup?d.children:[d],p=u[0].count,f=[];for(const m of c){const v=new h.Matrix4,g=new h.Vector3,b=new h.Quaternion,y=new h.Vector3(1,1,1),w=new h.InstancedMesh(m.geometry,m.material,p);for(let S=0;S<p;S++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,S),l.ROTATION&&b.fromBufferAttribute(l.ROTATION,S),l.SCALE&&y.fromBufferAttribute(l.SCALE,S),w.setMatrixAt(S,v.compose(g,b,y));for(const S in l)if(S==="_COLOR_0"){const P=l[S];w.instanceColor=new h.InstancedBufferAttribute(P.array,P.itemSize,P.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&m.geometry.setAttribute(S,l[S]);h.Object3D.prototype.copy.call(w,m),this.parser.assignFinalMaterial(w),f.push(w)}return d.isGroup?(d.clear(),d.add(...f),d):f[0]}))}}const hn="glTF",Re=12,dn={JSON:1313821514,BIN:5130562};class br{constructor(t){this.name=Y.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,Re);if(this.header={magic:ze(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==hn)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Re,i=new DataView(t,Re);let r=0;for(;r<n;){const s=i.getUint32(r,!0);r+=4;const a=i.getUint32(r,!0);if(r+=4,a===dn.JSON){const l=new Uint8Array(t,Re+r,s);this.content=ze(l)}else if(a===dn.BIN){const l=Re+r;this.body=t.slice(l,l+s)}r+=s}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class vr{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Y.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,i=this.dracoLoader,r=t.extensions[this.name].bufferView,s=t.extensions[this.name].attributes,a={},l={},u={};for(const d in s){const c=Tt[d]||d.toLowerCase();a[c]=s[d]}for(const d in t.attributes){const c=Tt[d]||d.toLowerCase();if(s[d]!==void 0){const p=n.accessors[t.attributes[d]],f=Xe[p.componentType];u[c]=f.name,l[c]=p.normalized===!0}}return e.getDependency("bufferView",r).then(function(d){return new Promise(function(c,p){i.decodeDracoFile(d,function(f){for(const m in f.attributes){const v=f.attributes[m],g=l[m];g!==void 0&&(v.normalized=g)}c(f)},a,u,we,p)})})}}class wr{constructor(){this.name=Y.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class xr{constructor(){this.name=Y.KHR_MESH_QUANTIZATION}}class pn extends h.Interpolant{constructor(t,e,n,i){super(t,e,n,i)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i*3+i;for(let s=0;s!==i;s++)e[s]=n[r+s];return e}interpolate_(t,e,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,l=a*2,u=a*3,d=i-e,c=(n-e)/d,p=c*c,f=p*c,m=t*u,v=m-u,g=-2*f+3*p,b=f-p,y=1-g,w=b-p+c;for(let S=0;S!==a;S++){const P=s[v+S+a],I=s[v+S+l]*d,T=s[m+S+a],M=s[m+S]*d;r[S]=y*P+w*I+g*T+b*M}return r}}const Lr=new h.Quaternion;class Sr extends pn{interpolate_(t,e,n,i){const r=super.interpolate_(t,e,n,i);return Lr.fromArray(r).normalize().toArray(r),r}}const ae={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Xe={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},fn={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},mn={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},It={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Tt={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...ot>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Ae={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Mr={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},Pt={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function _r(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),o.DefaultMaterial}function ke(o,t,e){for(const n in e.extensions)o[n]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=e.extensions[n])}function xe(o,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(o.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Zr(o,t,e){let n=!1,i=!1,r=!1;for(let u=0,d=t.length;u<d;u++){const c=t[u];if(c.POSITION!==void 0&&(n=!0),c.NORMAL!==void 0&&(i=!0),c.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(o);const s=[],a=[],l=[];for(let u=0,d=t.length;u<d;u++){const c=t[u];if(n){const p=c.POSITION!==void 0?e.getDependency("accessor",c.POSITION):o.attributes.position;s.push(p)}if(i){const p=c.NORMAL!==void 0?e.getDependency("accessor",c.NORMAL):o.attributes.normal;a.push(p)}if(r){const p=c.COLOR_0!==void 0?e.getDependency("accessor",c.COLOR_0):o.attributes.color;l.push(p)}}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(l)]).then(function(u){const d=u[0],c=u[1],p=u[2];return n&&(o.morphAttributes.position=d),i&&(o.morphAttributes.normal=c),r&&(o.morphAttributes.color=p),o.morphTargetsRelative=!0,o})}function Ir(o,t){if(o.updateMorphTargets(),t.weights!==void 0)for(let e=0,n=t.weights.length;e<n;e++)o.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(o.morphTargetInfluences.length===e.length){o.morphTargetDictionary={};for(let n=0,i=e.length;n<i;n++)o.morphTargetDictionary[e[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Tr(o){let t;const e=o.extensions&&o.extensions[Y.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+At(e.attributes):t=o.indices+":"+At(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)t+=":"+At(o.targets[n]);return t}function At(o){let t="";const e=Object.keys(o).sort();for(let n=0,i=e.length;n<i;n++)t+=e[n]+":"+o[e[n]]+";";return t}function Wt(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Pr(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Ar=new h.Matrix4;class Wr{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new $i,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&r<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){const a={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return ke(r,a,i),xe(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let i=0,r=e.length;i<r;i++){const s=e[i].joints;for(let a=0,l=s.length;a<l;a++)t[s[a]].isBone=!0}for(let i=0,r=t.length;i<r;i++){const s=t[i];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(n[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const i=n.clone(),r=(s,a)=>{const l=this.associations.get(s);l!=null&&this.associations.set(a,l);for(const[u,d]of s.children.entries())r(d,a.children[u])};return r(n,i),i.name+="_instance_"+t.uses[e]++,i}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const i=t(e[n]);if(i)return i}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let i=0;i<e.length;i++){const r=t(e[i]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let i=this.cache.get(n);if(!i){switch(t){case"scene":i=this.loadScene(e);break;case"node":i=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":i=this.loadAccessor(e);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":i=this.loadBuffer(e);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":i=this.loadSkin(e);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":i=this.loadCamera(e);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!i)throw new Error("Unknown type: "+t);break}this.cache.add(n,i)}return i}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,i=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(i.map(function(r,s){return n.getDependency(t,s)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[Y.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,s){n.load(h.LoaderUtils.resolveURL(e.uri,i.path),r,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(n){const i=e.byteLength||0,r=e.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(t){const e=this,n=this.json,i=this.json.accessors[t];if(i.bufferView===void 0&&i.sparse===void 0){const s=It[i.type],a=Xe[i.componentType],l=i.normalized===!0,u=new a(i.count*s);return Promise.resolve(new h.BufferAttribute(u,s,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(s){const a=s[0],l=It[i.type],u=Xe[i.componentType],d=u.BYTES_PER_ELEMENT,c=d*l,p=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let v,g;if(f&&f!==c){const b=Math.floor(p/f),y="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+b+":"+i.count;let w=e.cache.get(y);w||(v=new u(a,b*f,i.count*f/d),w=new h.InterleavedBuffer(v,f/d),e.cache.add(y,w)),g=new h.InterleavedBufferAttribute(w,l,p%f/d,m)}else a===null?v=new u(i.count*l):v=new u(a,p,i.count*l),g=new h.BufferAttribute(v,l,m);if(i.sparse!==void 0){const b=It.SCALAR,y=Xe[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,S=i.sparse.values.byteOffset||0,P=new y(s[1],w,i.sparse.count*b),I=new u(s[2],S,i.sparse.count*l);a!==null&&(g=new h.BufferAttribute(g.array.slice(),g.itemSize,g.normalized));for(let T=0,M=P.length;T<M;T++){const A=P[T];if(g.setX(A,I[T*l]),l>=2&&g.setY(A,I[T*l+1]),l>=3&&g.setZ(A,I[T*l+2]),l>=4&&g.setW(A,I[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return g})}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t].source,s=e.images[r];let a=this.textureLoader;if(s.uri){const l=n.manager.getHandler(s.uri);l!==null&&(a=l)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,n){const i=this,r=this.json,s=r.textures[t],a=r.images[e],l=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];const u=this.loadImageSource(e,n).then(function(d){d.flipY=!1,d.name=s.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const p=(r.samplers||{})[s.sampler]||{};return d.magFilter=fn[p.magFilter]||h.LinearFilter,d.minFilter=fn[p.minFilter]||h.LinearMipmapLinearFilter,d.wrapS=mn[p.wrapS]||h.RepeatWrapping,d.wrapT=mn[p.wrapT]||h.RepeatWrapping,i.associations.set(d,{textures:t}),d}).catch(function(){return null});return this.textureCache[l]=u,u}loadImageSource(t,e){const n=this,i=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(c=>c.clone());const s=i.images[t],a=self.URL||self.webkitURL;let l=s.uri||"",u=!1;if(s.bufferView!==void 0)l=n.getDependency("bufferView",s.bufferView).then(function(c){u=!0;const p=new Blob([c],{type:s.mimeType});return l=a.createObjectURL(p),l});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const d=Promise.resolve(l).then(function(c){return new Promise(function(p,f){let m=p;e.isImageBitmapLoader===!0&&(m=function(v){const g=new h.Texture(v);g.needsUpdate=!0,p(g)}),e.load(h.LoaderUtils.resolveURL(c,r.path),m,void 0,f)})}).then(function(c){return u===!0&&a.revokeObjectURL(l),xe(c,s),c.userData.mimeType=s.mimeType||Pr(s.uri),c}).catch(function(c){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),c});return this.sourceCache[t]=d,d}assignTexture(t,e,n,i){const r=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(s=s.clone(),s.channel=n.texCoord),r.extensions[Y.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[Y.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(s);s=r.extensions[Y.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,l)}}return i!==void 0&&(typeof i=="number"&&(i=i===un?Ce:we),"colorSpace"in s?s.colorSpace=i:s.encoding=i===Ce?un:Ei),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const i=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,s=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new h.PointsMaterial,h.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(t.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new h.LineBasicMaterial,h.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||r||s){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),s&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}t.material=n}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,i=this.extensions,r=n.materials[t];let s;const a={},l=r.extensions||{},u=[];if(l[Y.KHR_MATERIALS_UNLIT]){const c=i[Y.KHR_MATERIALS_UNLIT];s=c.getMaterialType(),u.push(c.extendParams(a,r,e))}else{const c=r.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(c.baseColorFactor)){const p=c.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],we),a.opacity=p[3]}c.baseColorTexture!==void 0&&u.push(e.assignTexture(a,"map",c.baseColorTexture,Ce)),a.metalness=c.metallicFactor!==void 0?c.metallicFactor:1,a.roughness=c.roughnessFactor!==void 0?c.roughnessFactor:1,c.metallicRoughnessTexture!==void 0&&(u.push(e.assignTexture(a,"metalnessMap",c.metallicRoughnessTexture)),u.push(e.assignTexture(a,"roughnessMap",c.metallicRoughnessTexture))),s=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(t)}),u.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=h.DoubleSide);const d=r.alphaMode||Pt.OPAQUE;if(d===Pt.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===Pt.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==h.MeshBasicMaterial&&(u.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new h.Vector2(1,1),r.normalTexture.scale!==void 0)){const c=r.normalTexture.scale;a.normalScale.set(c,c)}if(r.occlusionTexture!==void 0&&s!==h.MeshBasicMaterial&&(u.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==h.MeshBasicMaterial){const c=r.emissiveFactor;a.emissive=new h.Color().setRGB(c[0],c[1],c[2],we)}return r.emissiveTexture!==void 0&&s!==h.MeshBasicMaterial&&u.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,Ce)),Promise.all(u).then(function(){const c=new s(a);return r.name&&(c.name=r.name),xe(c,r),e.associations.set(c,{materials:t}),r.extensions&&ke(i,c,r),c})}createUniqueName(t){const e=h.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,i=this.primitiveCache;function r(a){return n[Y.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(l){return yn(l,a,e)})}const s=[];for(let a=0,l=t.length;a<l;a++){const u=t[a],d=Tr(u),c=i[d];if(c)s.push(c.promise);else{let p;u.extensions&&u.extensions[Y.KHR_DRACO_MESH_COMPRESSION]?p=r(u):p=yn(new h.BufferGeometry,u,e),i[d]={primitive:u,promise:p},s.push(p)}}return Promise.all(s)}loadMesh(t){const e=this,n=this.json,i=this.extensions,r=n.meshes[t],s=r.primitives,a=[];for(let l=0,u=s.length;l<u;l++){const d=s[l].material===void 0?_r(this.cache):this.getDependency("material",s[l].material);a.push(d)}return a.push(e.loadGeometries(s)),Promise.all(a).then(function(l){const u=l.slice(0,l.length-1),d=l[l.length-1],c=[];for(let f=0,m=d.length;f<m;f++){const v=d[f],g=s[f];let b;const y=u[f];if(g.mode===ae.TRIANGLES||g.mode===ae.TRIANGLE_STRIP||g.mode===ae.TRIANGLE_FAN||g.mode===void 0)b=r.isSkinnedMesh===!0?new h.SkinnedMesh(v,y):new h.Mesh(v,y),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),g.mode===ae.TRIANGLE_STRIP?b.geometry=en(b.geometry,h.TriangleStripDrawMode):g.mode===ae.TRIANGLE_FAN&&(b.geometry=en(b.geometry,h.TriangleFanDrawMode));else if(g.mode===ae.LINES)b=new h.LineSegments(v,y);else if(g.mode===ae.LINE_STRIP)b=new h.Line(v,y);else if(g.mode===ae.LINE_LOOP)b=new h.LineLoop(v,y);else if(g.mode===ae.POINTS)b=new h.Points(v,y);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(b.geometry.morphAttributes).length>0&&Ir(b,r),b.name=e.createUniqueName(r.name||"mesh_"+t),xe(b,r),g.extensions&&ke(i,b,g),e.assignFinalMaterial(b),c.push(b)}for(let f=0,m=c.length;f<m;f++)e.associations.set(c[f],{meshes:t,primitives:f});if(c.length===1)return r.extensions&&ke(i,c[0],r),c[0];const p=new h.Group;r.extensions&&ke(i,p,r),e.associations.set(p,{meshes:t});for(let f=0,m=c.length;f<m;f++)p.add(c[f]);return p})}loadCamera(t){let e;const n=this.json.cameras[t],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?e=new h.PerspectiveCamera(h.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(e=new h.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),xe(e,n),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],n=[];for(let i=0,r=e.joints.length;i<r;i++)n.push(this._loadNodeShallow(e.joints[i]));return e.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const r=i.pop(),s=i,a=[],l=[];for(let u=0,d=s.length;u<d;u++){const c=s[u];if(c){a.push(c);const p=new h.Matrix4;r!==null&&p.fromArray(r.array,u*16),l.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[u])}return new h.Skeleton(a,l)})}loadAnimation(t){const e=this.json,n=this,i=e.animations[t],r=i.name?i.name:"animation_"+t,s=[],a=[],l=[],u=[],d=[];for(let c=0,p=i.channels.length;c<p;c++){const f=i.channels[c],m=i.samplers[f.sampler],v=f.target,g=v.node,b=i.parameters!==void 0?i.parameters[m.input]:m.input,y=i.parameters!==void 0?i.parameters[m.output]:m.output;v.node!==void 0&&(s.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",b)),l.push(this.getDependency("accessor",y)),u.push(m),d.push(v))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(l),Promise.all(u),Promise.all(d)]).then(function(c){const p=c[0],f=c[1],m=c[2],v=c[3],g=c[4],b=[];for(let y=0,w=p.length;y<w;y++){const S=p[y],P=f[y],I=m[y],T=v[y],M=g[y];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const A=n._createAnimationTracks(S,P,I,T,M);if(A)for(let L=0;L<A.length;L++)b.push(A[L])}return new h.AnimationClip(r,void 0,b)})}createNodeMesh(t){const e=this.json,n=this,i=e.nodes[t];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(r){const s=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&s.traverse(function(a){if(a.isMesh)for(let l=0,u=i.weights.length;l<u;l++)a.morphTargetInfluences[l]=i.weights[l]}),s})}loadNode(t){const e=this.json,n=this,i=e.nodes[t],r=n._loadNodeShallow(t),s=[],a=i.children||[];for(let u=0,d=a.length;u<d;u++)s.push(n.getDependency("node",a[u]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(s),l]).then(function(u){const d=u[0],c=u[1],p=u[2];p!==null&&d.traverse(function(f){f.isSkinnedMesh&&f.bind(p,Ar)});for(let f=0,m=c.length;f<m;f++)d.add(c[f]);return d})}_loadNodeShallow(t){const e=this.json,n=this.extensions,i=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const r=e.nodes[t],s=r.name?i.createUniqueName(r.name):"",a=[],l=i._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(t)});return l&&a.push(l),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(u){return i._getNodeRef(i.cameraCache,r.camera,u)})),i._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(t)}).forEach(function(u){a.push(u)}),this.nodeCache[t]=Promise.all(a).then(function(u){let d;if(r.isBone===!0?d=new h.Bone:u.length>1?d=new h.Group:u.length===1?d=u[0]:d=new h.Object3D,d!==u[0])for(let c=0,p=u.length;c<p;c++)d.add(u[c]);if(r.name&&(d.userData.name=r.name,d.name=s),xe(d,r),r.extensions&&ke(n,d,r),r.matrix!==void 0){const c=new h.Matrix4;c.fromArray(r.matrix),d.applyMatrix4(c)}else r.translation!==void 0&&d.position.fromArray(r.translation),r.rotation!==void 0&&d.quaternion.fromArray(r.rotation),r.scale!==void 0&&d.scale.fromArray(r.scale);return i.associations.has(d)||i.associations.set(d,{}),i.associations.get(d).nodes=t,d}),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],i=this,r=new h.Group;n.name&&(r.name=i.createUniqueName(n.name)),xe(r,n),n.extensions&&ke(e,r,n);const s=n.nodes||[],a=[];for(let l=0,u=s.length;l<u;l++)a.push(i.getDependency("node",s[l]));return Promise.all(a).then(function(l){for(let d=0,c=l.length;d<c;d++)r.add(l[d]);const u=d=>{const c=new Map;for(const[p,f]of i.associations)(p instanceof h.Material||p instanceof h.Texture)&&c.set(p,f);return d.traverse(p=>{const f=i.associations.get(p);f!=null&&c.set(p,f)}),c};return i.associations=u(r),r})}_createAnimationTracks(t,e,n,i,r){const s=[],a=t.name?t.name:t.uuid,l=[];Ae[r.path]===Ae.weights?t.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(a);let u;switch(Ae[r.path]){case Ae.weights:u=h.NumberKeyframeTrack;break;case Ae.rotation:u=h.QuaternionKeyframeTrack;break;case Ae.position:case Ae.scale:u=h.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:u=h.NumberKeyframeTrack;break;case 2:case 3:default:u=h.VectorKeyframeTrack;break}break}const d=i.interpolation!==void 0?Mr[i.interpolation]:h.InterpolateLinear,c=this._getArrayFromAccessor(n);for(let p=0,f=l.length;p<f;p++){const m=new u(l[p]+"."+Ae[r.path],e.array,c,d);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),s.push(m)}return s}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const n=Wt(e.constructor),i=new Float32Array(e.length);for(let r=0,s=e.length;r<s;r++)i[r]=e[r]*n;e=i}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(n){const i=this instanceof h.QuaternionKeyframeTrack?Sr:pn;return new i(this.times,this.values,this.getValueSize()/3,n)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Gr(o,t,e){const n=t.attributes,i=new h.Box3;if(n.POSITION!==void 0){const a=e.json.accessors[n.POSITION],l=a.min,u=a.max;if(l!==void 0&&u!==void 0){if(i.set(new h.Vector3(l[0],l[1],l[2]),new h.Vector3(u[0],u[1],u[2])),a.normalized){const d=Wt(Xe[a.componentType]);i.min.multiplyScalar(d),i.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=t.targets;if(r!==void 0){const a=new h.Vector3,l=new h.Vector3;for(let u=0,d=r.length;u<d;u++){const c=r[u];if(c.POSITION!==void 0){const p=e.json.accessors[c.POSITION],f=p.min,m=p.max;if(f!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),p.normalized){const v=Wt(Xe[p.componentType]);l.multiplyScalar(v)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const s=new h.Sphere;i.getCenter(s.center),s.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=s}function yn(o,t,e){const n=t.attributes,i=[];function r(s,a){return e.getDependency("accessor",s).then(function(l){o.setAttribute(a,l)})}for(const s in n){const a=Tt[s]||s.toLowerCase();a in o.attributes||i.push(r(n[s],a))}if(t.indices!==void 0&&!o.index){const s=e.getDependency("accessor",t.indices).then(function(a){o.setIndex(a)});i.push(s)}return xe(o,t),Gr(o,t,e),Promise.all(i).then(function(){return t.targets!==void 0?Zr(o,t.targets,e):o})}function gn(o,t,e){const n=e.length-o-1;if(t>=e[n])return n-1;if(t<=e[o])return o;let i=o,r=n,s=Math.floor((i+r)/2);for(;t<e[s]||t>=e[s+1];)t<e[s]?r=s:i=s,s=Math.floor((i+r)/2);return s}function Vr(o,t,e,n){const i=[],r=[],s=[];i[0]=1;for(let a=1;a<=e;++a){r[a]=t-n[o+1-a],s[a]=n[o+a]-t;let l=0;for(let u=0;u<a;++u){const d=s[u+1],c=r[a-u],p=i[u]/(d+c);i[u]=l+d*p,l=c*p}i[a]=l}return i}function Cr(o,t,e,n){const i=gn(o,n,t),r=Vr(i,n,o,t),s=new h.Vector4(0,0,0,0);for(let a=0;a<=o;++a){const l=e[i-o+a],u=r[a],d=l.w*u;s.x+=l.x*d,s.y+=l.y*d,s.z+=l.z*d,s.w+=l.w*u}return s}function kr(o,t,e,n,i){const r=[];for(let c=0;c<=e;++c)r[c]=0;const s=[];for(let c=0;c<=n;++c)s[c]=r.slice(0);const a=[];for(let c=0;c<=e;++c)a[c]=r.slice(0);a[0][0]=1;const l=r.slice(0),u=r.slice(0);for(let c=1;c<=e;++c){l[c]=t-i[o+1-c],u[c]=i[o+c]-t;let p=0;for(let f=0;f<c;++f){const m=u[f+1],v=l[c-f];a[c][f]=m+v;const g=a[f][c-1]/a[c][f];a[f][c]=p+m*g,p=v*g}a[c][c]=p}for(let c=0;c<=e;++c)s[0][c]=a[c][e];for(let c=0;c<=e;++c){let p=0,f=1;const m=[];for(let v=0;v<=e;++v)m[v]=r.slice(0);m[0][0]=1;for(let v=1;v<=n;++v){let g=0;const b=c-v,y=e-v;c>=v&&(m[f][0]=m[p][0]/a[y+1][b],g=m[f][0]*a[b][y]);const w=b>=-1?1:-b,S=c-1<=y?v-1:e-c;for(let I=w;I<=S;++I)m[f][I]=(m[p][I]-m[p][I-1])/a[y+1][b+I],g+=m[f][I]*a[b+I][y];c<=y&&(m[f][v]=-m[p][v-1]/a[y+1][c],g+=m[f][v]*a[c][y]),s[v][c]=g;const P=p;p=f,f=P}}let d=e;for(let c=1;c<=n;++c){for(let p=0;p<=e;++p)s[c][p]*=d;d*=e-c}return s}function Dr(o,t,e,n,i){const r=i<o?i:o,s=[],a=gn(o,n,t),l=kr(a,n,o,r,t),u=[];for(let d=0;d<e.length;++d){const c=e[d].clone(),p=c.w;c.x*=p,c.y*=p,c.z*=p,u[d]=c}for(let d=0;d<=r;++d){const c=u[a-o].clone().multiplyScalar(l[d][0]);for(let p=1;p<=o;++p)c.add(u[a-o+p].clone().multiplyScalar(l[d][p]));s[d]=c}for(let d=r+1;d<=i+1;++d)s[d]=new h.Vector4(0,0,0);return s}function Fr(o,t){let e=1;for(let i=2;i<=o;++i)e*=i;let n=1;for(let i=2;i<=t;++i)n*=i;for(let i=2;i<=o-t;++i)n*=i;return e/n}function Or(o){const t=o.length,e=[],n=[];for(let r=0;r<t;++r){const s=o[r];e[r]=new h.Vector3(s.x,s.y,s.z),n[r]=s.w}const i=[];for(let r=0;r<t;++r){const s=e[r].clone();for(let a=1;a<=r;++a)s.sub(i[r-a].clone().multiplyScalar(Fr(r,a)*n[a]));i[r]=s.divideScalar(n[0])}return i}function zr(o,t,e,n,i){const r=Dr(o,t,e,n,i);return Or(r)}class bn extends h.Curve{constructor(t,e,n,i,r){super(),this.degree=t,this.knots=e,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||this.knots.length-1;for(let s=0;s<n.length;++s){const a=n[s];this.controlPoints[s]=new h.Vector4(a.x,a.y,a.z,a.w)}}getPoint(t,e){const n=e||new h.Vector3,i=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=Cr(this.degree,this.knots,this.controlPoints,i);return r.w!=1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(t,e){const n=e||new h.Vector3,i=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),r=zr(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}}let K,E,ne;class Xr extends h.Loader{constructor(t){super(t)}load(t,e,n,i){const r=this,s=r.path===""?h.LoaderUtils.extractUrlBase(t):r.path,a=new h.FileLoader(this.manager);a.setPath(r.path),a.setResponseType("arraybuffer"),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(t,function(l){try{e(r.parse(l,s))}catch(u){i?i(u):console.error(u),r.manager.itemError(t)}},n,i)}parse(t,e){if(jr(t))K=new Nr().parse(t);else{const i=Mn(t);if(!Rr(i))throw new Error("THREE.FBXLoader: Unknown format.");if(xn(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+xn(i));K=new Br().parse(i)}const n=new h.TextureLoader(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new Ur(n,this.manager).parse(K)}}class Ur{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){E=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),n=this.parseMaterials(e),i=this.parseDeformers(),r=new Yr().parse(i);return this.parseScene(i,r,n),ne}parseConnections(){const t=new Map;return"Connections"in K&&K.Connections.connections.forEach(function(n){const i=n[0],r=n[1],s=n[2];t.has(i)||t.set(i,{parents:[],children:[]});const a={ID:r,relationship:s};t.get(i).parents.push(a),t.has(r)||t.set(r,{parents:[],children:[]});const l={ID:i,relationship:s};t.get(r).children.push(l)}),t}parseImages(){const t={},e={};if("Video"in K.Objects){const n=K.Objects.Video;for(const i in n){const r=n[i],s=parseInt(i);if(t[s]=r.RelativeFilename||r.Filename,"Content"in r){const a=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,l=typeof r.Content=="string"&&r.Content!=="";if(a||l){const u=this.parseImage(n[i]);e[r.RelativeFilename||r.Filename]=u}}}}for(const n in t){const i=t[n];e[i]!==void 0?t[n]=e[i]:t[n]=t[n].split("\\").pop()}return t}parseImage(t){const e=t.Content,n=t.RelativeFilename||t.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(i){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:console.warn('FBXLoader: Image type "'+i+'" is not supported.');return}if(typeof e=="string")return"data:"+r+";base64,"+e;{const s=new Uint8Array(e);return window.URL.createObjectURL(new Blob([s],{type:r}))}}parseTextures(t){const e=new Map;if("Texture"in K.Objects){const n=K.Objects.Texture;for(const i in n){const r=this.parseTexture(n[i],t);e.set(parseInt(i),r)}}return e}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const i=t.WrapModeU,r=t.WrapModeV,s=i!==void 0?i.value:0,a=r!==void 0?r.value:0;if(n.wrapS=s===0?h.RepeatWrapping:h.ClampToEdgeWrapping,n.wrapT=a===0?h.RepeatWrapping:h.ClampToEdgeWrapping,"Scaling"in t){const l=t.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}return n}loadTexture(t,e){let n;const i=this.textureLoader.path,r=E.get(t.id).children;r!==void 0&&r.length>0&&e[r[0].ID]!==void 0&&(n=e[r[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let s;const a=t.FileName.slice(-3).toLowerCase();if(a==="tga"){const l=this.manager.getHandler(".tga");l===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),s=new h.Texture):(l.setPath(this.textureLoader.path),s=l.load(n))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),s=new h.Texture):s=this.textureLoader.load(n);return this.textureLoader.setPath(i),s}parseMaterials(t){const e=new Map;if("Material"in K.Objects){const n=K.Objects.Material;for(const i in n){const r=this.parseMaterial(n[i],t);r!==null&&e.set(parseInt(i),r)}}return e}parseMaterial(t,e){const n=t.id,i=t.attrName;let r=t.ShadingModel;if(typeof r=="object"&&(r=r.value),!E.has(n))return null;const s=this.parseParameters(t,e,n);let a;switch(r.toLowerCase()){case"phong":a=new h.MeshPhongMaterial;break;case"lambert":a=new h.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new h.MeshPhongMaterial;break}return a.setValues(s),a.name=i,a}parseParameters(t,e,n){const i={};t.BumpFactor&&(i.bumpScale=t.BumpFactor.value),t.Diffuse?i.color=new h.Color().fromArray(t.Diffuse.value):t.DiffuseColor&&(t.DiffuseColor.type==="Color"||t.DiffuseColor.type==="ColorRGB")&&(i.color=new h.Color().fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(i.displacementScale=t.DisplacementFactor.value),t.Emissive?i.emissive=new h.Color().fromArray(t.Emissive.value):t.EmissiveColor&&(t.EmissiveColor.type==="Color"||t.EmissiveColor.type==="ColorRGB")&&(i.emissive=new h.Color().fromArray(t.EmissiveColor.value)),t.EmissiveFactor&&(i.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(i.opacity=parseFloat(t.Opacity.value)),i.opacity<1&&(i.transparent=!0),t.ReflectionFactor&&(i.reflectivity=t.ReflectionFactor.value),t.Shininess&&(i.shininess=t.Shininess.value),t.Specular?i.specular=new h.Color().fromArray(t.Specular.value):t.SpecularColor&&t.SpecularColor.type==="Color"&&(i.specular=new h.Color().fromArray(t.SpecularColor.value));const r=this;return E.get(n).children.forEach(function(s){const a=s.relationship;switch(a){case"Bump":i.bumpMap=r.getTexture(e,s.ID);break;case"Maya|TEX_ao_map":i.aoMap=r.getTexture(e,s.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=r.getTexture(e,s.ID),i.map!==void 0&&("colorSpace"in i.map?i.map.colorSpace="srgb":i.map.encoding=3001);break;case"DisplacementColor":i.displacementMap=r.getTexture(e,s.ID);break;case"EmissiveColor":i.emissiveMap=r.getTexture(e,s.ID),i.emissiveMap!==void 0&&("colorSpace"in i.emissiveMap?i.emissiveMap.colorSpace="srgb":i.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":i.normalMap=r.getTexture(e,s.ID);break;case"ReflectionColor":i.envMap=r.getTexture(e,s.ID),i.envMap!==void 0&&(i.envMap.mapping=h.EquirectangularReflectionMapping,"colorSpace"in i.envMap?i.envMap.colorSpace="srgb":i.envMap.encoding=3001);break;case"SpecularColor":i.specularMap=r.getTexture(e,s.ID),i.specularMap!==void 0&&("colorSpace"in i.specularMap?i.specularMap.colorSpace="srgb":i.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=r.getTexture(e,s.ID),i.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),i}getTexture(t,e){return"LayeredTexture"in K.Objects&&e in K.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=E.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in K.Objects){const n=K.Objects.Deformer;for(const i in n){const r=n[i],s=E.get(parseInt(i));if(r.attrType==="Skin"){const a=this.parseSkeleton(s,n);a.ID=i,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=s.parents[0].ID,t[i]=a}else if(r.attrType==="BlendShape"){const a={id:i};a.rawTargets=this.parseMorphTargets(s,n),a.id=i,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[i]=a}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const n=[];return t.children.forEach(function(i){const r=e[i.ID];if(r.attrType!=="Cluster")return;const s={ID:i.ID,indices:[],weights:[],transformLink:new h.Matrix4().fromArray(r.TransformLink.a)};"Indexes"in r&&(s.indices=r.Indexes.a,s.weights=r.Weights.a),n.push(s)}),{rawBones:n,bones:[]}}parseMorphTargets(t,e){const n=[];for(let i=0;i<t.children.length;i++){const r=t.children[i],s=e[r.ID],a={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if(s.attrType!=="BlendShapeChannel")return;a.geoID=E.get(parseInt(r.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(t,e,n){ne=new h.Group;const i=this.parseModels(t.skeletons,e,n),r=K.Objects.Model,s=this;i.forEach(function(l){const u=r[l.ID];s.setLookAtProperties(l,u),E.get(l.ID).parents.forEach(function(c){const p=i.get(c.ID);p!==void 0&&p.add(l)}),l.parent===null&&ne.add(l)}),this.bindSkeleton(t.skeletons,e,i),this.createAmbientLight(),ne.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const u=Ln(l.userData.transformData);l.applyMatrix4(u),l.updateWorldMatrix()}});const a=new Kr().parse();ne.children.length===1&&ne.children[0].isGroup&&(ne.children[0].animations=a,ne=ne.children[0]),ne.animations=a}parseModels(t,e,n){const i=new Map,r=K.Objects.Model;for(const s in r){const a=parseInt(s),l=r[s],u=E.get(a);let d=this.buildSkeleton(u,t,a,l.attrName);if(!d){switch(l.attrType){case"Camera":d=this.createCamera(u);break;case"Light":d=this.createLight(u);break;case"Mesh":d=this.createMesh(u,e,n);break;case"NurbsCurve":d=this.createCurve(u,e);break;case"LimbNode":case"Root":d=new h.Bone;break;case"Null":default:d=new h.Group;break}d.name=l.attrName?h.PropertyBinding.sanitizeNodeName(l.attrName):"",d.ID=a}this.getTransformData(d,l),i.set(a,d)}return i}buildSkeleton(t,e,n,i){let r=null;return t.parents.forEach(function(s){for(const a in e){const l=e[a];l.rawBones.forEach(function(u,d){if(u.ID===s.ID){const c=r;r=new h.Bone,r.matrixWorld.copy(u.transformLink),r.name=i?h.PropertyBinding.sanitizeNodeName(i):"",r.ID=n,l.bones[d]=r,c!==null&&r.add(c)}})}}),r}createCamera(t){let e,n;if(t.children.forEach(function(i){const r=K.Objects.NodeAttribute[i.ID];r!==void 0&&(n=r)}),n===void 0)e=new h.Object3D;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let s=1e3;n.FarPlane!==void 0&&(s=n.FarPlane.value/1e3);let a=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,l=n.AspectHeight.value);const u=a/l;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(i){case 0:e=new h.PerspectiveCamera(d,u,r,s),c!==null&&e.setFocalLength(c);break;case 1:e=new h.OrthographicCamera(-a/2,a/2,l/2,-l/2,r,s);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+i+"."),e=new h.Object3D;break}}return e}createLight(t){let e,n;if(t.children.forEach(function(i){const r=K.Objects.NodeAttribute[i.ID];r!==void 0&&(n=r)}),n===void 0)e=new h.Object3D;else{let i;n.LightType===void 0?i=0:i=n.LightType.value;let r=16777215;n.Color!==void 0&&(r=new h.Color().fromArray(n.Color.value));let s=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(s=0);let a=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?a=0:a=n.FarAttenuationEnd.value);const l=1;switch(i){case 0:e=new h.PointLight(r,s,a,l);break;case 1:e=new h.DirectionalLight(r,s);break;case 2:let u=Math.PI/3;n.InnerAngle!==void 0&&(u=h.MathUtils.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=h.MathUtils.degToRad(n.OuterAngle.value),d=Math.max(d,1)),e=new h.SpotLight(r,s,a,u,d,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),e=new h.PointLight(r,s);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(e.castShadow=!0)}return e}createMesh(t,e,n){let i,r=null,s=null;const a=[];return t.children.forEach(function(l){e.has(l.ID)&&(r=e.get(l.ID)),n.has(l.ID)&&a.push(n.get(l.ID))}),a.length>1?s=a:a.length>0?s=a[0]:(s=new h.MeshPhongMaterial({color:13421772}),a.push(s)),"color"in r.attributes&&a.forEach(function(l){l.vertexColors=!0}),r.FBX_Deformer?(i=new h.SkinnedMesh(r,s),i.normalizeSkinWeights()):i=new h.Mesh(r,s),i}createCurve(t,e){const n=t.children.reduce(function(r,s){return e.has(s.ID)&&(r=e.get(s.ID)),r},null),i=new h.LineBasicMaterial({color:3342591,linewidth:1});return new h.Line(n,i)}getTransformData(t,e){const n={};"InheritType"in e&&(n.inheritType=parseInt(e.InheritType.value)),"RotationOrder"in e?n.eulerOrder=Sn(e.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in e&&(n.translation=e.Lcl_Translation.value),"PreRotation"in e&&(n.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(n.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(n.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(n.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(n.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(n.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(n.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(n.rotationPivot=e.RotationPivot.value),t.userData.transformData=n}setLookAtProperties(t,e){"LookAtProperty"in e&&E.get(t.ID).children.forEach(function(i){if(i.relationship==="LookAtProperty"){const r=K.Objects.Model[i.ID];if("Lcl_Translation"in r){const s=r.Lcl_Translation.value;t.target!==void 0?(t.target.position.fromArray(s),ne.add(t.target)):t.lookAt(new h.Vector3().fromArray(s))}}})}bindSkeleton(t,e,n){const i=this.parsePoseNodes();for(const r in t){const s=t[r];E.get(parseInt(s.ID)).parents.forEach(function(l){if(e.has(l.ID)){const u=l.ID;E.get(u).parents.forEach(function(c){n.has(c.ID)&&n.get(c.ID).bind(new h.Skeleton(s.bones),i[c.ID])})}})}}parsePoseNodes(){const t={};if("Pose"in K.Objects){const e=K.Objects.Pose;for(const n in e)if(e[n].attrType==="BindPose"&&e[n].NbPoseNodes>0){const i=e[n].PoseNode;Array.isArray(i)?i.forEach(function(r){t[r.Node]=new h.Matrix4().fromArray(r.Matrix.a)}):t[i.Node]=new h.Matrix4().fromArray(i.Matrix.a)}}return t}createAmbientLight(){if("GlobalSettings"in K&&"AmbientColor"in K.GlobalSettings){const t=K.GlobalSettings.AmbientColor.value,e=t[0],n=t[1],i=t[2];if(e!==0||n!==0||i!==0){const r=new h.Color(e,n,i);ne.add(new h.AmbientLight(r,1))}}}}class Yr{parse(t){const e=new Map;if("Geometry"in K.Objects){const n=K.Objects.Geometry;for(const i in n){const r=E.get(parseInt(i)),s=this.parseGeometry(r,n[i],t);e.set(parseInt(i),s)}}return e}parseGeometry(t,e,n){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,n);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,n){const i=n.skeletons,r=[],s=t.parents.map(function(c){return K.Objects.Model[c.ID]});if(s.length===0)return;const a=t.children.reduce(function(c,p){return i[p.ID]!==void 0&&(c=i[p.ID]),c},null);t.children.forEach(function(c){n.morphTargets[c.ID]!==void 0&&r.push(n.morphTargets[c.ID])});const l=s[0],u={};"RotationOrder"in l&&(u.eulerOrder=Sn(l.RotationOrder.value)),"InheritType"in l&&(u.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(u.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(u.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(u.scale=l.GeometricScaling.value);const d=Ln(u);return this.genGeometry(e,a,r,d)}genGeometry(t,e,n,i){const r=new h.BufferGeometry;t.attrName&&(r.name=t.attrName);const s=this.parseGeoNode(t,e),a=this.genBuffers(s),l=new h.Float32BufferAttribute(a.vertex,3);if(l.applyMatrix4(i),r.setAttribute("position",l),a.colors.length>0&&r.setAttribute("color",new h.Float32BufferAttribute(a.colors,3)),e&&(r.setAttribute("skinIndex",new h.Uint16BufferAttribute(a.weightsIndices,4)),r.setAttribute("skinWeight",new h.Float32BufferAttribute(a.vertexWeights,4)),r.FBX_Deformer=e),a.normal.length>0){const u=new h.Matrix3().getNormalMatrix(i),d=new h.Float32BufferAttribute(a.normal,3);d.applyNormalMatrix(u),r.setAttribute("normal",d)}if(a.uvs.forEach(function(u,d){Lt==="uv2"&&d++;const c=d===0?"uv":`uv${d}`;r.setAttribute(c,new h.Float32BufferAttribute(a.uvs[d],2))}),s.material&&s.material.mappingType!=="AllSame"){let u=a.materialIndex[0],d=0;if(a.materialIndex.forEach(function(c,p){c!==u&&(r.addGroup(d,p-d,u),u=c,d=p)}),r.groups.length>0){const c=r.groups[r.groups.length-1],p=c.start+c.count;p!==a.materialIndex.length&&r.addGroup(p,a.materialIndex.length-p,u)}r.groups.length===0&&r.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(r,t,n,i),r}parseGeoNode(t,e){const n={};if(n.vertexPositions=t.Vertices!==void 0?t.Vertices.a:[],n.vertexIndices=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(n.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(n.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(n.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){n.uv=[];let i=0;for(;t.LayerElementUV[i];)t.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(t.LayerElementUV[i])),i++}return n.weightTable={},e!==null&&(n.skeleton=e,e.rawBones.forEach(function(i,r){i.indices.forEach(function(s,a){n.weightTable[s]===void 0&&(n.weightTable[s]=[]),n.weightTable[s].push({id:r,weight:i.weights[a]})})})),n}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,r=!1,s=[],a=[],l=[],u=[],d=[],c=[];const p=this;return t.vertexIndices.forEach(function(f,m){let v,g=!1;f<0&&(f=f^-1,g=!0);let b=[],y=[];if(s.push(f*3,f*3+1,f*3+2),t.color){const w=lt(m,n,f,t.color);l.push(w[0],w[1],w[2])}if(t.skeleton){if(t.weightTable[f]!==void 0&&t.weightTable[f].forEach(function(w){y.push(w.weight),b.push(w.id)}),y.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const w=[0,0,0,0],S=[0,0,0,0];y.forEach(function(P,I){let T=P,M=b[I];S.forEach(function(A,L,Z){if(T>A){Z[L]=T,T=A;const W=w[L];w[L]=M,M=W}})}),b=w,y=S}for(;y.length<4;)y.push(0),b.push(0);for(let w=0;w<4;++w)d.push(y[w]),c.push(b[w])}if(t.normal){const w=lt(m,n,f,t.normal);a.push(w[0],w[1],w[2])}t.material&&t.material.mappingType!=="AllSame"&&(v=lt(m,n,f,t.material)[0]),t.uv&&t.uv.forEach(function(w,S){const P=lt(m,n,f,w);u[S]===void 0&&(u[S]=[]),u[S].push(P[0]),u[S].push(P[1])}),i++,g&&(p.genFace(e,t,s,v,a,l,u,d,c,i),n++,i=0,s=[],a=[],l=[],u=[],d=[],c=[])}),e}genFace(t,e,n,i,r,s,a,l,u,d){for(let c=2;c<d;c++)t.vertex.push(e.vertexPositions[n[0]]),t.vertex.push(e.vertexPositions[n[1]]),t.vertex.push(e.vertexPositions[n[2]]),t.vertex.push(e.vertexPositions[n[(c-1)*3]]),t.vertex.push(e.vertexPositions[n[(c-1)*3+1]]),t.vertex.push(e.vertexPositions[n[(c-1)*3+2]]),t.vertex.push(e.vertexPositions[n[c*3]]),t.vertex.push(e.vertexPositions[n[c*3+1]]),t.vertex.push(e.vertexPositions[n[c*3+2]]),e.skeleton&&(t.vertexWeights.push(l[0]),t.vertexWeights.push(l[1]),t.vertexWeights.push(l[2]),t.vertexWeights.push(l[3]),t.vertexWeights.push(l[(c-1)*4]),t.vertexWeights.push(l[(c-1)*4+1]),t.vertexWeights.push(l[(c-1)*4+2]),t.vertexWeights.push(l[(c-1)*4+3]),t.vertexWeights.push(l[c*4]),t.vertexWeights.push(l[c*4+1]),t.vertexWeights.push(l[c*4+2]),t.vertexWeights.push(l[c*4+3]),t.weightsIndices.push(u[0]),t.weightsIndices.push(u[1]),t.weightsIndices.push(u[2]),t.weightsIndices.push(u[3]),t.weightsIndices.push(u[(c-1)*4]),t.weightsIndices.push(u[(c-1)*4+1]),t.weightsIndices.push(u[(c-1)*4+2]),t.weightsIndices.push(u[(c-1)*4+3]),t.weightsIndices.push(u[c*4]),t.weightsIndices.push(u[c*4+1]),t.weightsIndices.push(u[c*4+2]),t.weightsIndices.push(u[c*4+3])),e.color&&(t.colors.push(s[0]),t.colors.push(s[1]),t.colors.push(s[2]),t.colors.push(s[(c-1)*3]),t.colors.push(s[(c-1)*3+1]),t.colors.push(s[(c-1)*3+2]),t.colors.push(s[c*3]),t.colors.push(s[c*3+1]),t.colors.push(s[c*3+2])),e.material&&e.material.mappingType!=="AllSame"&&(t.materialIndex.push(i),t.materialIndex.push(i),t.materialIndex.push(i)),e.normal&&(t.normal.push(r[0]),t.normal.push(r[1]),t.normal.push(r[2]),t.normal.push(r[(c-1)*3]),t.normal.push(r[(c-1)*3+1]),t.normal.push(r[(c-1)*3+2]),t.normal.push(r[c*3]),t.normal.push(r[c*3+1]),t.normal.push(r[c*3+2])),e.uv&&e.uv.forEach(function(p,f){t.uvs[f]===void 0&&(t.uvs[f]=[]),t.uvs[f].push(a[f][0]),t.uvs[f].push(a[f][1]),t.uvs[f].push(a[f][(c-1)*2]),t.uvs[f].push(a[f][(c-1)*2+1]),t.uvs[f].push(a[f][c*2]),t.uvs[f].push(a[f][c*2+1])})}addMorphTargets(t,e,n,i){if(n.length===0)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const r=this;n.forEach(function(s){s.rawTargets.forEach(function(a){const l=K.Objects.Geometry[a.geoID];l!==void 0&&r.genMorphGeometry(t,e,l,i,a.name)})})}genMorphGeometry(t,e,n,i,r){const s=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],a=n.Vertices!==void 0?n.Vertices.a:[],l=n.Indexes!==void 0?n.Indexes.a:[],u=t.attributes.position.count*3,d=new Float32Array(u);for(let m=0;m<l.length;m++){const v=l[m]*3;d[v]=a[m*3],d[v+1]=a[m*3+1],d[v+2]=a[m*3+2]}const c={vertexIndices:s,vertexPositions:d},p=this.genBuffers(c),f=new h.Float32BufferAttribute(p.vertex,3);f.name=r||n.attrName,f.applyMatrix4(i),t.morphAttributes.position.push(f)}parseNormals(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,i=t.Normals.a;let r=[];return n==="IndexToDirect"&&("NormalIndex"in t?r=t.NormalIndex.a:"NormalsIndex"in t&&(r=t.NormalsIndex.a)),{dataSize:3,buffer:i,indices:r,mappingType:e,referenceType:n}}parseUVs(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,i=t.UV.a;let r=[];return n==="IndexToDirect"&&(r=t.UVIndex.a),{dataSize:2,buffer:i,indices:r,mappingType:e,referenceType:n}}parseVertexColors(t){const e=t.MappingInformationType,n=t.ReferenceInformationType,i=t.Colors.a;let r=[];return n==="IndexToDirect"&&(r=t.ColorIndex.a),{dataSize:4,buffer:i,indices:r,mappingType:e,referenceType:n}}parseMaterialIndices(t){const e=t.MappingInformationType,n=t.ReferenceInformationType;if(e==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const i=t.Materials.a,r=[];for(let s=0;s<i.length;++s)r.push(s);return{dataSize:1,buffer:i,indices:r,mappingType:e,referenceType:n}}parseNurbsGeometry(t){if(bn===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new h.BufferGeometry;const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new h.BufferGeometry;const n=e-1,i=t.KnotVector.a,r=[],s=t.Points.a;for(let c=0,p=s.length;c<p;c+=4)r.push(new h.Vector4().fromArray(s,c));let a,l;if(t.Form==="Closed")r.push(r[0]);else if(t.Form==="Periodic"){a=n,l=i.length-1-a;for(let c=0;c<n;++c)r.push(r[c])}const d=new bn(n,i,r,a,l).getPoints(r.length*12);return new h.BufferGeometry().setFromPoints(d)}}class Kr{parse(){const t=[],e=this.parseClips();if(e!==void 0)for(const n in e){const i=e[n],r=this.addClip(i);t.push(r)}return t}parseClips(){if(K.Objects.AnimationCurve===void 0)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=K.Objects.AnimationCurveNode,e=new Map;for(const n in t){const i=t[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const r={id:i.id,attr:i.attrName,curves:{}};e.set(r.id,r)}}return e}parseAnimationCurves(t){const e=K.Objects.AnimationCurve;for(const n in e){const i={id:e[n].id,times:e[n].KeyTime.a.map(Jr),values:e[n].KeyValueFloat.a},r=E.get(i.id);if(r!==void 0){const s=r.parents[0].ID,a=r.parents[0].relationship;a.match(/X/)?t.get(s).curves.x=i:a.match(/Y/)?t.get(s).curves.y=i:a.match(/Z/)?t.get(s).curves.z=i:a.match(/d|DeformPercent/)&&t.has(s)&&(t.get(s).curves.morph=i)}}}parseAnimationLayers(t){const e=K.Objects.AnimationLayer,n=new Map;for(const i in e){const r=[],s=E.get(parseInt(i));s!==void 0&&(s.children.forEach(function(l,u){if(t.has(l.ID)){const d=t.get(l.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(r[u]===void 0){const c=E.get(l.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID;if(c!==void 0){const p=K.Objects.Model[c.toString()];if(p===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const f={modelName:p.attrName?h.PropertyBinding.sanitizeNodeName(p.attrName):"",ID:p.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};ne.traverse(function(m){m.ID===p.id&&(f.transform=m.matrix,m.userData.transformData&&(f.eulerOrder=m.userData.transformData.eulerOrder))}),f.transform||(f.transform=new h.Matrix4),"PreRotation"in p&&(f.preRotation=p.PreRotation.value),"PostRotation"in p&&(f.postRotation=p.PostRotation.value),r[u]=f}}r[u]&&(r[u][d.attr]=d)}else if(d.curves.morph!==void 0){if(r[u]===void 0){const c=E.get(l.ID).parents.filter(function(b){return b.relationship!==void 0})[0].ID,p=E.get(c).parents[0].ID,f=E.get(p).parents[0].ID,m=E.get(f).parents[0].ID,v=K.Objects.Model[m],g={modelName:v.attrName?h.PropertyBinding.sanitizeNodeName(v.attrName):"",morphName:K.Objects.Deformer[c].attrName};r[u]=g}r[u][d.attr]=d}}}),n.set(parseInt(i),r))}return n}parseAnimStacks(t){const e=K.Objects.AnimationStack,n={};for(const i in e){const r=E.get(parseInt(i)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=t.get(r[0].ID);n[i]={name:e[i].attrName,layer:s}}return n}addClip(t){let e=[];const n=this;return t.layer.forEach(function(i){e=e.concat(n.generateTracks(i))}),new h.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let n=new h.Vector3,i=new h.Quaternion,r=new h.Vector3;if(t.transform&&t.transform.decompose(n,i,r),n=n.toArray(),i=new h.Euler().setFromQuaternion(i,t.eulerOrder).toArray(),r=r.toArray(),t.T!==void 0&&Object.keys(t.T.curves).length>0){const s=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");s!==void 0&&e.push(s)}if(t.R!==void 0&&Object.keys(t.R.curves).length>0){const s=this.generateRotationTrack(t.modelName,t.R.curves,i,t.preRotation,t.postRotation,t.eulerOrder);s!==void 0&&e.push(s)}if(t.S!==void 0&&Object.keys(t.S.curves).length>0){const s=this.generateVectorTrack(t.modelName,t.S.curves,r,"scale");s!==void 0&&e.push(s)}if(t.DeformPercent!==void 0){const s=this.generateMorphTrack(t);s!==void 0&&e.push(s)}return e}generateVectorTrack(t,e,n,i){const r=this.getTimesForAllAxes(e),s=this.getKeyframeTrackValues(r,e,n);return new h.VectorKeyframeTrack(t+"."+i,r,s)}generateRotationTrack(t,e,n,i,r,s){e.x!==void 0&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(h.MathUtils.degToRad)),e.y!==void 0&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(h.MathUtils.degToRad)),e.z!==void 0&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(h.MathUtils.degToRad));const a=this.getTimesForAllAxes(e),l=this.getKeyframeTrackValues(a,e,n);i!==void 0&&(i=i.map(h.MathUtils.degToRad),i.push(s),i=new h.Euler().fromArray(i),i=new h.Quaternion().setFromEuler(i)),r!==void 0&&(r=r.map(h.MathUtils.degToRad),r.push(s),r=new h.Euler().fromArray(r),r=new h.Quaternion().setFromEuler(r).invert());const u=new h.Quaternion,d=new h.Euler,c=[];for(let p=0;p<l.length;p+=3)d.set(l[p],l[p+1],l[p+2],s),u.setFromEuler(d),i!==void 0&&u.premultiply(i),r!==void 0&&u.multiply(r),u.toArray(c,p/3*4);return new h.QuaternionKeyframeTrack(t+".quaternion",a,c)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,n=e.values.map(function(r){return r/100}),i=ne.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new h.NumberKeyframeTrack(t.modelName+".morphTargetInfluences["+i+"]",e.times,n)}getTimesForAllAxes(t){let e=[];if(t.x!==void 0&&(e=e.concat(t.x.times)),t.y!==void 0&&(e=e.concat(t.y.times)),t.z!==void 0&&(e=e.concat(t.z.times)),e=e.sort(function(n,i){return n-i}),e.length>1){let n=1,i=e[0];for(let r=1;r<e.length;r++){const s=e[r];s!==i&&(e[n]=s,i=s,n++)}e=e.slice(0,n)}return e}getKeyframeTrackValues(t,e,n){const i=n,r=[];let s=-1,a=-1,l=-1;return t.forEach(function(u){if(e.x&&(s=e.x.times.indexOf(u)),e.y&&(a=e.y.times.indexOf(u)),e.z&&(l=e.z.times.indexOf(u)),s!==-1){const d=e.x.values[s];r.push(d),i[0]=d}else r.push(i[0]);if(a!==-1){const d=e.y.values[a];r.push(d),i[1]=d}else r.push(i[1]);if(l!==-1){const d=e.z.values[l];r.push(d),i[2]=d}else r.push(i[2])}),r}interpolateRotations(t){for(let e=1;e<t.values.length;e++){const n=t.values[e-1],i=t.values[e]-n,r=Math.abs(i);if(r>=180){const s=r/180,a=i/s;let l=n+a;const u=t.times[e-1],c=(t.times[e]-u)/s;let p=u+c;const f=[],m=[];for(;p<t.times[e];)f.push(p),p+=c,m.push(l),l+=a;t.times=_n(t.times,e,f),t.values=_n(t.values,e,m)}}}}class Br{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new wn,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,n=t.split(/[\r\n]+/);return n.forEach(function(i,r){const s=i.match(/^[\s\t]*;/),a=i.match(/^[\s\t]*$/);if(s||a)return;const l=i.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),u=i.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=i.match("^\\t{"+(e.currentIndent-1)+"}}");l?e.parseNodeBegin(i,l):u?e.parseNodeProperty(i,u,n[++r]):d?e.popStack():i.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(t,e){const n=e[1].trim().replace(/^"/,"").replace(/"$/,""),i=e[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),r={name:n},s=this.parseNodeAttr(i),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,r):n in a?(n==="PoseNode"?a.PoseNode.push(r):a[n].id!==void 0&&(a[n]={},a[n][a[n].id]=a[n]),s.id!==""&&(a[n][s.id]=r)):typeof s.id=="number"?(a[n]={},a[n][s.id]=r):n!=="Properties70"&&(n==="PoseNode"?a[n]=[r]:a[n]=r),typeof s.id=="number"&&(r.id=s.id),s.name!==""&&(r.attrName=s.name),s.type!==""&&(r.attrType=s.type),this.pushStack(r)}parseNodeAttr(t){let e=t[0];t[0]!==""&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let n="",i="";return t.length>1&&(n=t[1].replace(/^(\w+)::/,""),i=t[2]),{id:e,name:n,type:i}}parseNodeProperty(t,e,n){let i=e[1].replace(/^"/,"").replace(/"$/,"").trim(),r=e[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&r===","&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if(s.name==="Properties70"){this.parseNodeSpecialProperty(t,i,r);return}if(i==="C"){const l=r.split(",").slice(1),u=parseInt(l[0]),d=parseInt(l[1]);let c=r.split(",").slice(3);c=c.map(function(p){return p.trim().replace(/^"/,"")}),i="connections",r=[u,d],Hr(r,c),s[i]===void 0&&(s[i]=[])}i==="Node"&&(s.id=r),i in s&&Array.isArray(s[i])?s[i].push(r):i!=="a"?s[i]=r:s.a=r,this.setCurrentProp(s,i),i==="a"&&r.slice(-1)!==","&&(s.a=Vt(r))}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,t.slice(-1)!==","&&(e.a=Vt(e.a))}parseNodeSpecialProperty(t,e,n){const i=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),r=i[0],s=i[1],a=i[2],l=i[3];let u=i[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":u=parseFloat(u);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":u=Vt(u);break}this.getPrevNode()[r]={type:s,type2:a,flag:l,value:u},this.setCurrentProp(this.getPrevNode(),r)}}class Nr{parse(t){const e=new vn(t);e.skip(23);const n=e.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new wn;for(;!this.endOfContent(e);){const r=this.parseNode(e,n);r!==null&&i.add(r.name,r)}return i}endOfContent(t){return t.size()%16===0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const n={},i=e>=7500?t.getUint64():t.getUint32(),r=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const s=t.getUint8(),a=t.getString(s);if(i===0)return null;const l=[];for(let p=0;p<r;p++)l.push(this.parseProperty(t));const u=l.length>0?l[0]:"",d=l.length>1?l[1]:"",c=l.length>2?l[2]:"";for(n.singleProperty=r===1&&t.getOffset()===i;i>t.getOffset();){const p=this.parseNode(t,e);p!==null&&this.parseSubNode(a,n,p)}return n.propertyList=l,typeof u=="number"&&(n.id=u),d!==""&&(n.attrName=d),c!==""&&(n.attrType=c),a!==""&&(n.name=a),n}parseSubNode(t,e,n){if(n.singleProperty===!0){const i=n.propertyList[0];Array.isArray(i)?(e[n.name]=n,n.a=i):e[n.name]=i}else if(t==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(r,s){s!==0&&i.push(r)}),e.connections===void 0&&(e.connections=[]),e.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(r){e[r]=n[r]});else if(t==="Properties70"&&n.name==="P"){let i=n.propertyList[0],r=n.propertyList[1];const s=n.propertyList[2],a=n.propertyList[3];let l;i.indexOf("Lcl ")===0&&(i=i.replace("Lcl ","Lcl_")),r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),r==="Color"||r==="ColorRGB"||r==="Vector"||r==="Vector3D"||r.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],e[i]={type:r,type2:s,flag:a,value:l}}else e[n.name]===void 0?typeof n.id=="number"?(e[n.name]={},e[n.name][n.id]=n):e[n.name]=n:n.name==="PoseNode"?(Array.isArray(e[n.name])||(e[n.name]=[e[n.name]]),e[n.name].push(n)):e[n.name][n.id]===void 0&&(e[n.name][n.id]=n)}parseProperty(t){const e=t.getString(1);let n;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return n=t.getUint32(),t.getArrayBuffer(n);case"S":return n=t.getUint32(),t.getString(n);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const i=t.getUint32(),r=t.getUint32(),s=t.getUint32();if(r===0)switch(e){case"b":case"c":return t.getBooleanArray(i);case"d":return t.getFloat64Array(i);case"f":return t.getFloat32Array(i);case"i":return t.getInt32Array(i);case"l":return t.getInt64Array(i)}const a=Oi(new Uint8Array(t.getArrayBuffer(s))),l=new vn(a.buffer);switch(e){case"b":case"c":return l.getBooleanArray(i);case"d":return l.getFloat64Array(i);case"f":return l.getFloat32Array(i);case"i":return l.getInt32Array(i);case"l":return l.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class vn{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=e!==void 0?e:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(t){const e=[];for(let n=0;n<t;n++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e&2147483648?(e=~e&4294967295,t=~t&4294967295,t===4294967295&&(e=e+1&4294967295),t=t+1&4294967295,-(e*4294967296+t)):e*4294967296+t}getInt64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e*4294967296+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let n=0;n<t;n++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){let e=[];for(let i=0;i<t;i++)e[i]=this.getUint8();const n=e.indexOf(0);return n>=0&&(e=e.slice(0,n)),ze(new Uint8Array(e))}}class wn{add(t,e){this[t]=e}}function jr(o){const t="Kaydara FBX Binary \0";return o.byteLength>=t.length&&t===Mn(o,0,t.length)}function Rr(o){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let e=0;function n(i){const r=o[i-1];return o=o.slice(e+i),e++,r}for(let i=0;i<t.length;++i)if(n(1)===t[i])return!1;return!0}function xn(o){const t=/FBXVersion: (\d+)/,e=o.match(t);if(e)return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Jr(o){return o/46186158e3}const Qr=[];function lt(o,t,e,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=o;break;case"ByPolygon":i=t;break;case"ByVertice":i=e;break;case"AllSame":i=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(i=n.indices[i]);const r=i*n.dataSize,s=r+n.dataSize;return Er(Qr,n.buffer,r,s)}const Gt=new h.Euler,Ue=new h.Vector3;function Ln(o){const t=new h.Matrix4,e=new h.Matrix4,n=new h.Matrix4,i=new h.Matrix4,r=new h.Matrix4,s=new h.Matrix4,a=new h.Matrix4,l=new h.Matrix4,u=new h.Matrix4,d=new h.Matrix4,c=new h.Matrix4,p=new h.Matrix4,f=o.inheritType?o.inheritType:0;if(o.translation&&t.setPosition(Ue.fromArray(o.translation)),o.preRotation){const L=o.preRotation.map(h.MathUtils.degToRad);L.push(o.eulerOrder),e.makeRotationFromEuler(Gt.fromArray(L))}if(o.rotation){const L=o.rotation.map(h.MathUtils.degToRad);L.push(o.eulerOrder),n.makeRotationFromEuler(Gt.fromArray(L))}if(o.postRotation){const L=o.postRotation.map(h.MathUtils.degToRad);L.push(o.eulerOrder),i.makeRotationFromEuler(Gt.fromArray(L)),i.invert()}o.scale&&r.scale(Ue.fromArray(o.scale)),o.scalingOffset&&a.setPosition(Ue.fromArray(o.scalingOffset)),o.scalingPivot&&s.setPosition(Ue.fromArray(o.scalingPivot)),o.rotationOffset&&l.setPosition(Ue.fromArray(o.rotationOffset)),o.rotationPivot&&u.setPosition(Ue.fromArray(o.rotationPivot)),o.parentMatrixWorld&&(c.copy(o.parentMatrix),d.copy(o.parentMatrixWorld));const m=e.clone().multiply(n).multiply(i),v=new h.Matrix4;v.extractRotation(d);const g=new h.Matrix4;g.copyPosition(d);const b=g.clone().invert().multiply(d),y=v.clone().invert().multiply(b),w=r,S=new h.Matrix4;if(f===0)S.copy(v).multiply(m).multiply(y).multiply(w);else if(f===1)S.copy(v).multiply(y).multiply(m).multiply(w);else{const Z=new h.Matrix4().scale(new h.Vector3().setFromMatrixScale(c)).clone().invert(),W=y.clone().multiply(Z);S.copy(v).multiply(m).multiply(W).multiply(w)}const P=u.clone().invert(),I=s.clone().invert();let T=t.clone().multiply(l).multiply(u).multiply(e).multiply(n).multiply(i).multiply(P).multiply(a).multiply(s).multiply(r).multiply(I);const M=new h.Matrix4().copyPosition(T),A=d.clone().multiply(M);return p.copyPosition(A),T=p.clone().multiply(S),T.premultiply(d.invert()),T}function Sn(o){o=o||0;const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return o===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[o]}function Vt(o){return o.split(",").map(function(e){return parseFloat(e)})}function Mn(o,t,e){return t===void 0&&(t=0),e===void 0&&(e=o.byteLength),ze(new Uint8Array(o,t,e))}function Hr(o,t){for(let e=0,n=o.length,i=t.length;e<i;e++,n++)o[n]=t[e]}function Er(o,t,e,n){for(let i=e,r=0;i<n;i++,r++)o[r]=t[i];return o}function _n(o,t,e){return o.slice(0,t).concat(e).concat(o.slice(t))}class qr extends h.DataTextureLoader{constructor(t){super(t),this.type=h.HalfFloatType}parse(t){const s=function(M,A){switch(M){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(A||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(A||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(A||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(A||""))}},d=`
98
- `,c=function(M,A,L){A=A||1024;let W=M.pos,C=-1,V=0,D="",G=String.fromCharCode.apply(null,new Uint16Array(M.subarray(W,W+128)));for(;0>(C=G.indexOf(d))&&V<A&&W<M.byteLength;)D+=G,V+=G.length,W+=128,G+=String.fromCharCode.apply(null,new Uint16Array(M.subarray(W,W+128)));return-1<C?(M.pos+=V+C+1,D+G.slice(0,C)):!1},p=function(M){const A=/^#\?(\S+)/,L=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,Z=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,W=/^\s*FORMAT=(\S+)\s*$/,C=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,V={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let D,G;for((M.pos>=M.byteLength||!(D=c(M)))&&s(1,"no header found"),(G=D.match(A))||s(3,"bad initial token"),V.valid|=1,V.programtype=G[1],V.string+=D+`
99
- `;D=c(M),D!==!1;){if(V.string+=D+`
100
- `,D.charAt(0)==="#"){V.comments+=D+`
101
- `;continue}if((G=D.match(L))&&(V.gamma=parseFloat(G[1])),(G=D.match(Z))&&(V.exposure=parseFloat(G[1])),(G=D.match(W))&&(V.valid|=2,V.format=G[1]),(G=D.match(C))&&(V.valid|=4,V.height=parseInt(G[1],10),V.width=parseInt(G[2],10)),V.valid&2&&V.valid&4)break}return V.valid&2||s(3,"missing format specifier"),V.valid&4||s(3,"missing image size specifier"),V},f=function(M,A,L){const Z=A;if(Z<8||Z>32767||M[0]!==2||M[1]!==2||M[2]&128)return new Uint8Array(M);Z!==(M[2]<<8|M[3])&&s(3,"wrong scanline width");const W=new Uint8Array(4*A*L);W.length||s(4,"unable to allocate buffer space");let C=0,V=0;const D=4*Z,G=new Uint8Array(4),X=new Uint8Array(D);let U=L;for(;U>0&&V<M.byteLength;){V+4>M.byteLength&&s(1),G[0]=M[V++],G[1]=M[V++],G[2]=M[V++],G[3]=M[V++],(G[0]!=2||G[1]!=2||(G[2]<<8|G[3])!=Z)&&s(3,"bad rgbe scanline format");let z=0,j;for(;z<D&&V<M.byteLength;){j=M[V++];const B=j>128;if(B&&(j-=128),(j===0||z+j>D)&&s(3,"bad scanline data"),B){const J=M[V++];for(let de=0;de<j;de++)X[z++]=J}else X.set(M.subarray(V,V+j),z),z+=j,V+=j}const H=Z;for(let B=0;B<H;B++){let J=0;W[C]=X[B+J],J+=Z,W[C+1]=X[B+J],J+=Z,W[C+2]=X[B+J],J+=Z,W[C+3]=X[B+J],C+=4}U--}return W},m=function(M,A,L,Z){const W=M[A+3],C=Math.pow(2,W-128)/255;L[Z+0]=M[A+0]*C,L[Z+1]=M[A+1]*C,L[Z+2]=M[A+2]*C,L[Z+3]=1},v=function(M,A,L,Z){const W=M[A+3],C=Math.pow(2,W-128)/255;L[Z+0]=h.DataUtils.toHalfFloat(Math.min(M[A+0]*C,65504)),L[Z+1]=h.DataUtils.toHalfFloat(Math.min(M[A+1]*C,65504)),L[Z+2]=h.DataUtils.toHalfFloat(Math.min(M[A+2]*C,65504)),L[Z+3]=h.DataUtils.toHalfFloat(1)},g=new Uint8Array(t);g.pos=0;const b=p(g),y=b.width,w=b.height,S=f(g.subarray(g.pos),y,w);let P,I,T;switch(this.type){case h.FloatType:T=S.length/4;const M=new Float32Array(T*4);for(let L=0;L<T;L++)m(S,L*4,M,L*4);P=M,I=h.FloatType;break;case h.HalfFloatType:T=S.length/4;const A=new Uint16Array(T*4);for(let L=0;L<T;L++)v(S,L*4,A,L*4);P=A,I=h.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:y,height:w,data:P,header:b.string,gamma:b.gamma,exposure:b.exposure,type:I}}setDataType(t){return this.type=t,this}load(t,e,n,i){function r(s,a){switch(s.type){case h.FloatType:case h.HalfFloatType:"colorSpace"in s?s.colorSpace="srgb-linear":s.encoding=3e3,s.minFilter=h.LinearFilter,s.magFilter=h.LinearFilter,s.generateMipmaps=!1,s.flipY=!0;break}e&&e(s,a)}return super.load(t,r,n,i)}}const Ct=new WeakMap;class $r extends h.Loader{constructor(t){super(t),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(t){return this.decoderPath=t,this}setDecoderConfig(t){return this.decoderConfig=t,this}setWorkerLimit(t){return this.workerLimit=t,this}load(t,e,n,i){const r=new h.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(t,s=>{const a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(s,a).then(e).catch(i)},n,i)}decodeDracoFile(t,e,n,i){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(t,r).then(e)}decodeGeometry(t,e){for(const l in e.attributeTypes){const u=e.attributeTypes[l];u.BYTES_PER_ELEMENT!==void 0&&(e.attributeTypes[l]=u.name)}const n=JSON.stringify(e);if(Ct.has(t)){const l=Ct.get(t);if(l.key===n)return l.promise;if(t.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const r=this.workerNextTaskID++,s=t.byteLength,a=this._getWorker(r,s).then(l=>(i=l,new Promise((u,d)=>{i._callbacks[r]={resolve:u,reject:d},i.postMessage({type:"decode",id:r,taskConfig:e,buffer:t},[t])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&r&&this._releaseTask(i,r)}),Ct.set(t,{key:n,promise:a}),a}_createGeometry(t){const e=new h.BufferGeometry;t.index&&e.setIndex(new h.BufferAttribute(t.index.array,1));for(let n=0;n<t.attributes.length;n++){const i=t.attributes[n],r=i.name,s=i.array,a=i.itemSize;e.setAttribute(r,new h.BufferAttribute(s,a))}return e}_loadLibrary(t,e){const n=new h.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(e),n.setWithCredentials(this.withCredentials),new Promise((i,r)=>{n.load(t,i,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const t=typeof WebAssembly!="object"||this.decoderConfig.type==="js",e=[];return t?e.push(this._loadLibrary("draco_decoder.js","text")):(e.push(this._loadLibrary("draco_wasm_wrapper.js","text")),e.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(e).then(n=>{const i=n[0];t||(this.decoderConfig.wasmBinary=n[1]);const r=es.toString(),s=["/* draco decoder */",i,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
102
- `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),this.decoderPending}_getWorker(t,e){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(r){const s=r.data;switch(s.type){case"decode":i._callbacks[s.id].resolve(s);break;case"error":i._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,r){return i._taskLoad>r._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[t]=e,n._taskLoad+=e,n})}_releaseTask(t,e){t._taskLoad-=t._taskCosts[e],delete t._callbacks[e],delete t._taskCosts[e]}debug(){console.log("Task load: ",this.workerPool.map(t=>t._taskLoad))}dispose(){for(let t=0;t<this.workerPool.length;++t)this.workerPool[t].terminate();return this.workerPool.length=0,this}}function es(){let o,t;onmessage=function(s){const a=s.data;switch(a.type){case"init":o=a.decoderConfig,t=new Promise(function(d){o.onModuleLoaded=function(c){d({draco:c})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,u=a.taskConfig;t.then(d=>{const c=d.draco,p=new c.Decoder,f=new c.DecoderBuffer;f.Init(new Int8Array(l),l.byteLength);try{const m=e(c,p,f,u),v=m.attributes.map(g=>g.array.buffer);m.index&&v.push(m.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:m},v)}catch(m){console.error(m),self.postMessage({type:"error",id:a.id,error:m.message})}finally{c.destroy(f),c.destroy(p)}});break}};function e(s,a,l,u){const d=u.attributeIDs,c=u.attributeTypes;let p,f;const m=a.GetEncodedGeometryType(l);if(m===s.TRIANGULAR_MESH)p=new s.Mesh,f=a.DecodeBufferToMesh(l,p);else if(m===s.POINT_CLOUD)p=new s.PointCloud,f=a.DecodeBufferToPointCloud(l,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const v={index:null,attributes:[]};for(const g in d){const b=self[c[g]];let y,w;if(u.useUniqueIDs)w=d[g],y=a.GetAttributeByUniqueId(p,w);else{if(w=a.GetAttributeId(p,s[d[g]]),w===-1)continue;y=a.GetAttribute(p,w)}v.attributes.push(i(s,a,p,g,b,y))}return m===s.TRIANGULAR_MESH&&(v.index=n(s,a,p)),s.destroy(p),v}function n(s,a,l){const d=l.num_faces()*3,c=d*4,p=s._malloc(c);a.GetTrianglesUInt32Array(l,c,p);const f=new Uint32Array(s.HEAPF32.buffer,p,d).slice();return s._free(p),{array:f,itemSize:1}}function i(s,a,l,u,d,c){const p=c.num_components(),m=l.num_points()*p,v=m*d.BYTES_PER_ELEMENT,g=r(s,d),b=s._malloc(v);a.GetAttributeDataArrayForAllPoints(l,c,g,v,b);const y=new d(s.HEAPF32.buffer,b,m).slice();return s._free(b),{name:u,array:y,itemSize:p}}function r(s,a){switch(a){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}const Zn=new h.Box3,ct=new h.Vector3;class In extends h.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const t=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],e=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new h.Float32BufferAttribute(t,3)),this.setAttribute("uv",new h.Float32BufferAttribute(e,2))}applyMatrix4(t){const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return e!==void 0&&(e.applyMatrix4(t),n.applyMatrix4(t),e.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));const n=new h.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new h.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new h.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t,e=3){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));const i=new h.InstancedInterleavedBuffer(n,e*2,1);return this.setAttribute("instanceColorStart",new h.InterleavedBufferAttribute(i,e,0)),this.setAttribute("instanceColorEnd",new h.InterleavedBufferAttribute(i,e,e)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new h.WireframeGeometry(t.geometry)),this}fromLineSegments(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new h.Box3);const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;t!==void 0&&e!==void 0&&(this.boundingBox.setFromBufferAttribute(t),Zn.setFromBufferAttribute(e),this.boundingBox.union(Zn))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new h.Sphere),this.boundingBox===null&&this.computeBoundingBox();const t=this.attributes.instanceStart,e=this.attributes.instanceEnd;if(t!==void 0&&e!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let i=0;for(let r=0,s=t.count;r<s;r++)ct.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(ct)),ct.fromBufferAttribute(e,r),i=Math.max(i,n.distanceToSquared(ct));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(t){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(t)}}class ut extends In{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(t){const e=t.length-3,n=new Float32Array(2*e);for(let i=0;i<e;i+=3)n[2*i]=t[i],n[2*i+1]=t[i+1],n[2*i+2]=t[i+2],n[2*i+3]=t[i+3],n[2*i+4]=t[i+4],n[2*i+5]=t[i+5];return super.setPositions(n),this}setColors(t,e=3){const n=t.length-e,i=new Float32Array(2*n);if(e===3)for(let r=0;r<n;r+=e)i[2*r]=t[r],i[2*r+1]=t[r+1],i[2*r+2]=t[r+2],i[2*r+3]=t[r+3],i[2*r+4]=t[r+4],i[2*r+5]=t[r+5];else for(let r=0;r<n;r+=e)i[2*r]=t[r],i[2*r+1]=t[r+1],i[2*r+2]=t[r+2],i[2*r+3]=t[r+3],i[2*r+4]=t[r+4],i[2*r+5]=t[r+5],i[2*r+6]=t[r+6],i[2*r+7]=t[r+7];return super.setColors(i,e),this}fromLine(t){const e=t.geometry;return this.setPositions(e.attributes.position.array),this}}class Je extends h.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:h.UniformsUtils.clone(h.UniformsUtils.merge([h.UniformsLib.common,h.UniformsLib.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new h.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:`
97
+ }`},H=new p.ShaderMaterial({fragmentShader:Y.fragmentShader,vertexShader:Y.vertexShader,uniforms:p.UniformsUtils.clone(Y.uniforms),lights:!0,side:b,fog:x});H.uniforms.mirrorSampler.value=j.texture,H.uniforms.textureMatrix.value=G,H.uniforms.alpha.value=c,H.uniforms.time.value=u,H.uniforms.normalSampler.value=d,H.uniforms.sunColor.value=f,H.uniforms.waterColor.value=g,H.uniforms.sunDirection.value=m,H.uniforms.distortionScale.value=w,H.uniforms.eye.value=_,n.material=H,n.onBeforeRender=function(Q,ie,re){if(C.setFromMatrixPosition(n.matrixWorld),Z.setFromMatrixPosition(re.matrixWorld),z.extractRotation(n.matrixWorld),M.set(0,0,1),M.applyMatrix4(z),I.subVectors(C,Z),I.dot(M)>0)return;I.reflect(M).negate(),I.add(C),z.extractRotation(re.matrixWorld),D.set(0,0,-1),D.applyMatrix4(z),D.add(Z),K.subVectors(C,D),K.reflect(M).negate(),K.add(C),k.position.copy(I),k.up.set(0,1,0),k.up.applyMatrix4(z),k.up.reflect(M),k.lookAt(K),k.far=re.far,k.updateMatrixWorld(),k.projectionMatrix.copy(re.projectionMatrix),G.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),G.multiply(k.projectionMatrix),G.multiply(k.matrixWorldInverse),L.setFromNormalAndCoplanarPoint(M,C),L.applyMatrix4(k.matrixWorldInverse),X.set(L.normal.x,L.normal.y,L.normal.z,L.constant);const le=k.projectionMatrix;V.x=(Math.sign(X.x)+le.elements[8])/le.elements[0],V.y=(Math.sign(X.y)+le.elements[9])/le.elements[5],V.z=-1,V.w=(1+le.elements[10])/le.elements[14],X.multiplyScalar(2/X.dot(V)),le.elements[2]=X.x,le.elements[6]=X.y,le.elements[10]=X.z+1-a,le.elements[14]=X.w,_.setFromMatrixPosition(re.matrixWorld);const de=Q.getRenderTarget(),ge=Q.xr.enabled,fe=Q.shadowMap.autoUpdate;n.visible=!1,Q.xr.enabled=!1,Q.shadowMap.autoUpdate=!1,Q.setRenderTarget(j),Q.state.buffers.depth.setMask(!0),Q.autoClear===!1&&Q.clear(),Q.render(ie,k),n.visible=!0,Q.xr.enabled=ge,Q.shadowMap.autoUpdate=fe,Q.setRenderTarget(de);const Se=re.viewport;Se!==void 0&&Q.state.viewport(Se)}}}var Sf=Object.defineProperty,Lf=(i,e,t)=>e in i?Sf(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Pf=(i,e,t)=>(Lf(i,e+"",t),t);class Cf{constructor(){Pf(this,"_listeners")}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const r=this._listeners[e];if(r!==void 0){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let o=0,a=r.length;o<a;o++)r[o].call(this,e);e.target=null}}}var Tf=Object.defineProperty,Gf=(i,e,t)=>e in i?Tf(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ne=(i,e,t)=>(Gf(i,typeof e!="symbol"?e+"":e,t),t);const qi=new p.Ray,Ul=new p.Plane,Zf=Math.cos(70*(Math.PI/180)),kl=(i,e)=>(i%e+e)%e;class Wf extends Cf{constructor(e,t){super(),ne(this,"object"),ne(this,"domElement"),ne(this,"enabled",!0),ne(this,"target",new p.Vector3),ne(this,"minDistance",0),ne(this,"maxDistance",1/0),ne(this,"minZoom",0),ne(this,"maxZoom",1/0),ne(this,"minPolarAngle",0),ne(this,"maxPolarAngle",Math.PI),ne(this,"minAzimuthAngle",-1/0),ne(this,"maxAzimuthAngle",1/0),ne(this,"enableDamping",!1),ne(this,"dampingFactor",.05),ne(this,"enableZoom",!0),ne(this,"zoomSpeed",1),ne(this,"enableRotate",!0),ne(this,"rotateSpeed",1),ne(this,"enablePan",!0),ne(this,"panSpeed",1),ne(this,"screenSpacePanning",!0),ne(this,"keyPanSpeed",7),ne(this,"zoomToCursor",!1),ne(this,"autoRotate",!1),ne(this,"autoRotateSpeed",2),ne(this,"reverseOrbit",!1),ne(this,"reverseHorizontalOrbit",!1),ne(this,"reverseVerticalOrbit",!1),ne(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),ne(this,"mouseButtons",{LEFT:p.MOUSE.ROTATE,MIDDLE:p.MOUSE.DOLLY,RIGHT:p.MOUSE.PAN}),ne(this,"touches",{ONE:p.TOUCH.ROTATE,TWO:p.TOUCH.DOLLY_PAN}),ne(this,"target0"),ne(this,"position0"),ne(this,"zoom0"),ne(this,"_domElementKeyEvents",null),ne(this,"getPolarAngle"),ne(this,"getAzimuthalAngle"),ne(this,"setPolarAngle"),ne(this,"setAzimuthalAngle"),ne(this,"getDistance"),ne(this,"getZoomScale"),ne(this,"listenToKeyEvents"),ne(this,"stopListenToKeyEvents"),ne(this,"saveState"),ne(this,"reset"),ne(this,"update"),ne(this,"connect"),ne(this,"dispose"),ne(this,"dollyIn"),ne(this,"dollyOut"),ne(this,"getScale"),ne(this,"setScale"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>m.phi,this.getAzimuthalAngle=()=>m.theta,this.setPolarAngle=O=>{let E=kl(O,2*Math.PI),ce=m.phi;ce<0&&(ce+=2*Math.PI),E<0&&(E+=2*Math.PI);let Me=Math.abs(E-ce);2*Math.PI-Me<Me&&(E<ce?E+=2*Math.PI:ce+=2*Math.PI),f.phi=E-ce,n.update()},this.setAzimuthalAngle=O=>{let E=kl(O,2*Math.PI),ce=m.theta;ce<0&&(ce+=2*Math.PI),E<0&&(E+=2*Math.PI);let Me=Math.abs(E-ce);2*Math.PI-Me<Me&&(E<ce?E+=2*Math.PI:ce+=2*Math.PI),f.theta=E-ce,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=O=>{O.addEventListener("keydown",wn),this._domElementKeyEvents=O},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",wn),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),u=c.NONE},this.update=(()=>{const O=new p.Vector3,E=new p.Vector3(0,1,0),ce=new p.Quaternion().setFromUnitVectors(e.up,E),Me=ce.clone().invert(),Be=new p.Vector3,Bt=new p.Quaternion,sn=2*Math.PI;return function(){const Ts=n.object.position;ce.setFromUnitVectors(e.up,E),Me.copy(ce).invert(),O.copy(Ts).sub(n.target),O.applyQuaternion(ce),m.setFromVector3(O),n.autoRotate&&u===c.NONE&&Y(k()),n.enableDamping?(m.theta+=f.theta*n.dampingFactor,m.phi+=f.phi*n.dampingFactor):(m.theta+=f.theta,m.phi+=f.phi);let on=n.minAzimuthAngle,an=n.maxAzimuthAngle;isFinite(on)&&isFinite(an)&&(on<-Math.PI?on+=sn:on>Math.PI&&(on-=sn),an<-Math.PI?an+=sn:an>Math.PI&&(an-=sn),on<=an?m.theta=Math.max(on,Math.min(an,m.theta)):m.theta=m.theta>(on+an)/2?Math.max(on,m.theta):Math.min(an,m.theta)),m.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,m.phi)),m.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(_,n.dampingFactor):n.target.add(_),n.zoomToCursor&&K||n.object.isOrthographicCamera?m.radius=Se(m.radius):m.radius=Se(m.radius*g),O.setFromSpherical(m),O.applyQuaternion(Me),Ts.copy(n.target).add(O),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,_.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),_.set(0,0,0));let tr=!1;if(n.zoomToCursor&&K){let Lr=null;if(n.object instanceof p.PerspectiveCamera&&n.object.isPerspectiveCamera){const Pr=O.length();Lr=Se(Pr*g);const Jr=Pr-Lr;n.object.position.addScaledVector(X,Jr),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Pr=new p.Vector3(I.x,I.y,0);Pr.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/g)),n.object.updateProjectionMatrix(),tr=!0;const Jr=new p.Vector3(I.x,I.y,0);Jr.unproject(n.object),n.object.position.sub(Jr).add(Pr),n.object.updateMatrixWorld(),Lr=O.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;Lr!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(Lr).add(n.object.position):(qi.origin.copy(n.object.position),qi.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(qi.direction))<Zf?e.lookAt(n.target):(Ul.setFromNormalAndCoplanarPoint(n.object.up,n.target),qi.intersectPlane(Ul,n.target))))}else n.object instanceof p.OrthographicCamera&&n.object.isOrthographicCamera&&(tr=g!==1,tr&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/g)),n.object.updateProjectionMatrix()));return g=1,K=!1,tr||Be.distanceToSquared(n.object.position)>d||8*(1-Bt.dot(n.object.quaternion))>d?(n.dispatchEvent(r),Be.copy(n.object.position),Bt.copy(n.object.quaternion),tr=!1,!0):!1}})(),this.connect=O=>{n.domElement=O,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Rr),n.domElement.addEventListener("pointerdown",$n),n.domElement.addEventListener("pointercancel",xr),n.domElement.addEventListener("wheel",er)},this.dispose=()=>{var O,E,ce,Me,Be,Bt;n.domElement&&(n.domElement.style.touchAction="auto"),(O=n.domElement)==null||O.removeEventListener("contextmenu",Rr),(E=n.domElement)==null||E.removeEventListener("pointerdown",$n),(ce=n.domElement)==null||ce.removeEventListener("pointercancel",xr),(Me=n.domElement)==null||Me.removeEventListener("wheel",er),(Be=n.domElement)==null||Be.ownerDocument.removeEventListener("pointermove",qn),(Bt=n.domElement)==null||Bt.ownerDocument.removeEventListener("pointerup",xr),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",wn)};const n=this,r={type:"change"},o={type:"start"},a={type:"end"},c={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let u=c.NONE;const d=1e-6,m=new p.Spherical,f=new p.Spherical;let g=1;const _=new p.Vector3,w=new p.Vector2,b=new p.Vector2,x=new p.Vector2,L=new p.Vector2,M=new p.Vector2,C=new p.Vector2,Z=new p.Vector2,z=new p.Vector2,D=new p.Vector2,X=new p.Vector3,I=new p.Vector2;let K=!1;const V=[],G={};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function j(){return Math.pow(.95,n.zoomSpeed)}function Y(O){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=O:f.theta-=O}function H(O){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=O:f.phi-=O}const Q=(()=>{const O=new p.Vector3;return function(ce,Me){O.setFromMatrixColumn(Me,0),O.multiplyScalar(-ce),_.add(O)}})(),ie=(()=>{const O=new p.Vector3;return function(ce,Me){n.screenSpacePanning===!0?O.setFromMatrixColumn(Me,1):(O.setFromMatrixColumn(Me,0),O.crossVectors(n.object.up,O)),O.multiplyScalar(ce),_.add(O)}})(),re=(()=>{const O=new p.Vector3;return function(ce,Me){const Be=n.domElement;if(Be&&n.object instanceof p.PerspectiveCamera&&n.object.isPerspectiveCamera){const Bt=n.object.position;O.copy(Bt).sub(n.target);let sn=O.length();sn*=Math.tan(n.object.fov/2*Math.PI/180),Q(2*ce*sn/Be.clientHeight,n.object.matrix),ie(2*Me*sn/Be.clientHeight,n.object.matrix)}else Be&&n.object instanceof p.OrthographicCamera&&n.object.isOrthographicCamera?(Q(ce*(n.object.right-n.object.left)/n.object.zoom/Be.clientWidth,n.object.matrix),ie(Me*(n.object.top-n.object.bottom)/n.object.zoom/Be.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function le(O){n.object instanceof p.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof p.OrthographicCamera&&n.object.isOrthographicCamera?g=O:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function de(O){le(g/O)}function ge(O){le(g*O)}function fe(O){if(!n.zoomToCursor||!n.domElement)return;K=!0;const E=n.domElement.getBoundingClientRect(),ce=O.clientX-E.left,Me=O.clientY-E.top,Be=E.width,Bt=E.height;I.x=ce/Be*2-1,I.y=-(Me/Bt)*2+1,X.set(I.x,I.y,1).unproject(n.object).sub(n.object.position).normalize()}function Se(O){return Math.max(n.minDistance,Math.min(n.maxDistance,O))}function rt(O){w.set(O.clientX,O.clientY)}function it(O){fe(O),Z.set(O.clientX,O.clientY)}function dt(O){L.set(O.clientX,O.clientY)}function Qe(O){b.set(O.clientX,O.clientY),x.subVectors(b,w).multiplyScalar(n.rotateSpeed);const E=n.domElement;E&&(Y(2*Math.PI*x.x/E.clientHeight),H(2*Math.PI*x.y/E.clientHeight)),w.copy(b),n.update()}function Ye(O){z.set(O.clientX,O.clientY),D.subVectors(z,Z),D.y>0?de(j()):D.y<0&&ge(j()),Z.copy(z),n.update()}function Re(O){M.set(O.clientX,O.clientY),C.subVectors(M,L).multiplyScalar(n.panSpeed),re(C.x,C.y),L.copy(M),n.update()}function st(O){fe(O),O.deltaY<0?ge(j()):O.deltaY>0&&de(j()),n.update()}function ze(O){let E=!1;switch(O.code){case n.keys.UP:re(0,n.keyPanSpeed),E=!0;break;case n.keys.BOTTOM:re(0,-n.keyPanSpeed),E=!0;break;case n.keys.LEFT:re(n.keyPanSpeed,0),E=!0;break;case n.keys.RIGHT:re(-n.keyPanSpeed,0),E=!0;break}E&&(O.preventDefault(),n.update())}function Vt(){if(V.length==1)w.set(V[0].pageX,V[0].pageY);else{const O=.5*(V[0].pageX+V[1].pageX),E=.5*(V[0].pageY+V[1].pageY);w.set(O,E)}}function Nt(){if(V.length==1)L.set(V[0].pageX,V[0].pageY);else{const O=.5*(V[0].pageX+V[1].pageX),E=.5*(V[0].pageY+V[1].pageY);L.set(O,E)}}function Ce(){const O=V[0].pageX-V[1].pageX,E=V[0].pageY-V[1].pageY,ce=Math.sqrt(O*O+E*E);Z.set(0,ce)}function ot(){n.enableZoom&&Ce(),n.enablePan&&Nt()}function ft(){n.enableZoom&&Ce(),n.enableRotate&&Vt()}function Lt(O){if(V.length==1)b.set(O.pageX,O.pageY);else{const ce=Sr(O),Me=.5*(O.pageX+ce.x),Be=.5*(O.pageY+ce.y);b.set(Me,Be)}x.subVectors(b,w).multiplyScalar(n.rotateSpeed);const E=n.domElement;E&&(Y(2*Math.PI*x.x/E.clientHeight),H(2*Math.PI*x.y/E.clientHeight)),w.copy(b)}function wr(O){if(V.length==1)M.set(O.pageX,O.pageY);else{const E=Sr(O),ce=.5*(O.pageX+E.x),Me=.5*(O.pageY+E.y);M.set(ce,Me)}C.subVectors(M,L).multiplyScalar(n.panSpeed),re(C.x,C.y),L.copy(M)}function Yr(O){const E=Sr(O),ce=O.pageX-E.x,Me=O.pageY-E.y,Be=Math.sqrt(ce*ce+Me*Me);z.set(0,Be),D.set(0,Math.pow(z.y/Z.y,n.zoomSpeed)),de(D.y),Z.copy(z)}function br(O){n.enableZoom&&Yr(O),n.enablePan&&wr(O)}function It(O){n.enableZoom&&Yr(O),n.enableRotate&&Lt(O)}function $n(O){var E,ce;n.enabled!==!1&&(V.length===0&&((E=n.domElement)==null||E.ownerDocument.addEventListener("pointermove",qn),(ce=n.domElement)==null||ce.ownerDocument.addEventListener("pointerup",xr)),Ai(O),O.pointerType==="touch"?Vi(O):Mr(O))}function qn(O){n.enabled!==!1&&(O.pointerType==="touch"?Ii(O):wa(O))}function xr(O){var E,ce,Me;Fi(O),V.length===0&&((E=n.domElement)==null||E.releasePointerCapture(O.pointerId),(ce=n.domElement)==null||ce.ownerDocument.removeEventListener("pointermove",qn),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",xr)),n.dispatchEvent(a),u=c.NONE}function Mr(O){let E;switch(O.button){case 0:E=n.mouseButtons.LEFT;break;case 1:E=n.mouseButtons.MIDDLE;break;case 2:E=n.mouseButtons.RIGHT;break;default:E=-1}switch(E){case p.MOUSE.DOLLY:if(n.enableZoom===!1)return;it(O),u=c.DOLLY;break;case p.MOUSE.ROTATE:if(O.ctrlKey||O.metaKey||O.shiftKey){if(n.enablePan===!1)return;dt(O),u=c.PAN}else{if(n.enableRotate===!1)return;rt(O),u=c.ROTATE}break;case p.MOUSE.PAN:if(O.ctrlKey||O.metaKey||O.shiftKey){if(n.enableRotate===!1)return;rt(O),u=c.ROTATE}else{if(n.enablePan===!1)return;dt(O),u=c.PAN}break;default:u=c.NONE}u!==c.NONE&&n.dispatchEvent(o)}function wa(O){if(n.enabled!==!1)switch(u){case c.ROTATE:if(n.enableRotate===!1)return;Qe(O);break;case c.DOLLY:if(n.enableZoom===!1)return;Ye(O);break;case c.PAN:if(n.enablePan===!1)return;Re(O);break}}function er(O){n.enabled===!1||n.enableZoom===!1||u!==c.NONE&&u!==c.ROTATE||(O.preventDefault(),n.dispatchEvent(o),st(O),n.dispatchEvent(a))}function wn(O){n.enabled===!1||n.enablePan===!1||ze(O)}function Vi(O){switch(jr(O),V.length){case 1:switch(n.touches.ONE){case p.TOUCH.ROTATE:if(n.enableRotate===!1)return;Vt(),u=c.TOUCH_ROTATE;break;case p.TOUCH.PAN:if(n.enablePan===!1)return;Nt(),u=c.TOUCH_PAN;break;default:u=c.NONE}break;case 2:switch(n.touches.TWO){case p.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ot(),u=c.TOUCH_DOLLY_PAN;break;case p.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ft(),u=c.TOUCH_DOLLY_ROTATE;break;default:u=c.NONE}break;default:u=c.NONE}u!==c.NONE&&n.dispatchEvent(o)}function Ii(O){switch(jr(O),u){case c.TOUCH_ROTATE:if(n.enableRotate===!1)return;Lt(O),n.update();break;case c.TOUCH_PAN:if(n.enablePan===!1)return;wr(O),n.update();break;case c.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;br(O),n.update();break;case c.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;It(O),n.update();break;default:u=c.NONE}}function Rr(O){n.enabled!==!1&&O.preventDefault()}function Ai(O){V.push(O)}function Fi(O){delete G[O.pointerId];for(let E=0;E<V.length;E++)if(V[E].pointerId==O.pointerId){V.splice(E,1);return}}function jr(O){let E=G[O.pointerId];E===void 0&&(E=new p.Vector2,G[O.pointerId]=E),E.set(O.pageX,O.pageY)}function Sr(O){const E=O.pointerId===V[0].pointerId?V[1]:V[0];return G[E.pointerId]}this.dollyIn=(O=j())=>{ge(O),n.update()},this.dollyOut=(O=j())=>{de(O),n.update()},this.getScale=()=>g,this.setScale=O=>{le(O),n.update()},this.getZoomScale=()=>j(),t!==void 0&&this.connect(t),this.update()}}class Vf extends Wf{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=p.MOUSE.PAN,this.mouseButtons.RIGHT=p.MOUSE.ROTATE,this.touches.ONE=p.TOUCH.PAN,this.touches.TWO=p.TOUCH.DOLLY_ROTATE}}var If=Object.defineProperty,Af=(i,e,t)=>e in i?If(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,hr=(i,e,t)=>(Af(i,typeof e!="symbol"?e+"":e,t),t);class fi{constructor(){hr(this,"enabled",!0),hr(this,"needsSwap",!0),hr(this,"clear",!1),hr(this,"renderToScreen",!1)}setSize(e,t){}render(e,t,n,r,o){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}class Kl{constructor(e){hr(this,"camera",new p.OrthographicCamera(-1,1,1,-1,0,1)),hr(this,"geometry",new p.PlaneGeometry(2,2)),hr(this,"mesh"),this.mesh=new p.Mesh(this.geometry,e)}get material(){return this.mesh.material}set material(e){this.mesh.material=e}dispose(){this.mesh.geometry.dispose()}render(e){e.render(this.mesh,this.camera)}}var Ff=Object.defineProperty,Of=(i,e,t)=>e in i?Ff(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,es=(i,e,t)=>(Of(i,typeof e!="symbol"?e+"":e,t),t);class Nl extends fi{constructor(e,t="tDiffuse"){super(),es(this,"textureID"),es(this,"uniforms"),es(this,"material"),es(this,"fsQuad"),this.textureID=t,e instanceof p.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):(this.uniforms=p.UniformsUtils.clone(e.uniforms),this.material=new p.ShaderMaterial({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Kl(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.fsQuad.dispose(),this.material.dispose()}}const So={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
98
+ varying vec2 vUv;
99
+
100
+ void main() {
101
+
102
+ vUv = uv;
103
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
104
+
105
+ }
106
+ `,fragmentShader:`
107
+ uniform float opacity;
108
+
109
+ uniform sampler2D tDiffuse;
110
+
111
+ varying vec2 vUv;
112
+
113
+ void main() {
114
+
115
+ vec4 texel = texture2D( tDiffuse, vUv );
116
+ gl_FragColor = opacity * texel;
117
+
118
+ }
119
+ `},Df={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new p.Color(0)},defaultOpacity:{value:0}},vertexShader:`
120
+ varying vec2 vUv;
121
+
122
+ void main() {
123
+
124
+ vUv = uv;
125
+
126
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
127
+
128
+ }
129
+ `,fragmentShader:`
130
+ uniform sampler2D tDiffuse;
131
+ uniform vec3 defaultColor;
132
+ uniform float defaultOpacity;
133
+ uniform float luminosityThreshold;
134
+ uniform float smoothWidth;
135
+
136
+ varying vec2 vUv;
137
+
138
+ void main() {
139
+
140
+ vec4 texel = texture2D( tDiffuse, vUv );
141
+
142
+ vec3 luma = vec3( 0.299, 0.587, 0.114 );
143
+
144
+ float v = dot( texel.xyz, luma );
145
+
146
+ vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
147
+
148
+ float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
149
+
150
+ gl_FragColor = mix( outputColor, texel, alpha );
151
+
152
+ }
153
+ `};var zf=Object.defineProperty,Xf=(i,e,t)=>e in i?zf(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Bl=(i,e,t)=>(Xf(i,typeof e!="symbol"?e+"":e,t),t);const Uf=(()=>{const i=class extends fi{constructor(t,n,r,o){super(),this.strength=n!==void 0?n:1,this.radius=r,this.threshold=o,this.resolution=t!==void 0?new p.Vector2(t.x,t.y):new p.Vector2(256,256),this.clearColor=new p.Color(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let a=Math.round(this.resolution.x/2),c=Math.round(this.resolution.y/2);this.renderTargetBright=new p.WebGLRenderTarget(a,c,{type:p.HalfFloatType}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let g=0;g<this.nMips;g++){const _=new p.WebGLRenderTarget(a,c,{type:p.HalfFloatType});_.texture.name="UnrealBloomPass.h"+g,_.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(_);const w=new p.WebGLRenderTarget(a,c,{type:p.HalfFloatType});w.texture.name="UnrealBloomPass.v"+g,w.texture.generateMipmaps=!1,this.renderTargetsVertical.push(w),a=Math.round(a/2),c=Math.round(c/2)}const u=Df;this.highPassUniforms=p.UniformsUtils.clone(u.uniforms),this.highPassUniforms.luminosityThreshold.value=o,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new p.ShaderMaterial({uniforms:this.highPassUniforms,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader,defines:{}}),this.separableBlurMaterials=[];const d=[3,5,7,9,11];a=Math.round(this.resolution.x/2),c=Math.round(this.resolution.y/2);for(let g=0;g<this.nMips;g++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(d[g])),this.separableBlurMaterials[g].uniforms.texSize.value=new p.Vector2(a,c),a=Math.round(a/2),c=Math.round(c/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=n,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;const m=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=m,this.bloomTintColors=[new p.Vector3(1,1,1),new p.Vector3(1,1,1),new p.Vector3(1,1,1),new p.Vector3(1,1,1),new p.Vector3(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;const f=So;this.copyUniforms=p.UniformsUtils.clone(f.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new p.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:f.vertexShader,fragmentShader:f.fragmentShader,blending:p.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new p.Color,this.oldClearAlpha=1,this.basic=new p.MeshBasicMaterial,this.fsQuad=new Kl(null)}dispose(){for(let t=0;t<this.renderTargetsHorizontal.length;t++)this.renderTargetsHorizontal[t].dispose();for(let t=0;t<this.renderTargetsVertical.length;t++)this.renderTargetsVertical[t].dispose();this.renderTargetBright.dispose();for(let t=0;t<this.separableBlurMaterials.length;t++)this.separableBlurMaterials[t].dispose();this.compositeMaterial.dispose(),this.materialCopy.dispose(),this.basic.dispose(),this.fsQuad.dispose()}setSize(t,n){let r=Math.round(t/2),o=Math.round(n/2);this.renderTargetBright.setSize(r,o);for(let a=0;a<this.nMips;a++)this.renderTargetsHorizontal[a].setSize(r,o),this.renderTargetsVertical[a].setSize(r,o),this.separableBlurMaterials[a].uniforms.texSize.value=new p.Vector2(r,o),r=Math.round(r/2),o=Math.round(o/2)}render(t,n,r,o,a){t.getClearColor(this._oldClearColor),this.oldClearAlpha=t.getClearAlpha();const c=t.autoClear;t.autoClear=!1,t.setClearColor(this.clearColor,0),a&&t.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=r.texture,t.setRenderTarget(null),t.clear(),this.fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=r.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,t.setRenderTarget(this.renderTargetBright),t.clear(),this.fsQuad.render(t);let u=this.renderTargetBright;for(let d=0;d<this.nMips;d++)this.fsQuad.material=this.separableBlurMaterials[d],this.separableBlurMaterials[d].uniforms.colorTexture.value=u.texture,this.separableBlurMaterials[d].uniforms.direction.value=i.BlurDirectionX,t.setRenderTarget(this.renderTargetsHorizontal[d]),t.clear(),this.fsQuad.render(t),this.separableBlurMaterials[d].uniforms.colorTexture.value=this.renderTargetsHorizontal[d].texture,this.separableBlurMaterials[d].uniforms.direction.value=i.BlurDirectionY,t.setRenderTarget(this.renderTargetsVertical[d]),t.clear(),this.fsQuad.render(t),u=this.renderTargetsVertical[d];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,t.setRenderTarget(this.renderTargetsHorizontal[0]),t.clear(),this.fsQuad.render(t),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,a&&t.state.buffers.stencil.setTest(!0),this.renderToScreen?(t.setRenderTarget(null),this.fsQuad.render(t)):(t.setRenderTarget(r),this.fsQuad.render(t)),t.setClearColor(this._oldClearColor,this.oldClearAlpha),t.autoClear=c}getSeperableBlurMaterial(t){return new p.ShaderMaterial({defines:{KERNEL_RADIUS:t,SIGMA:t},uniforms:{colorTexture:{value:null},texSize:{value:new p.Vector2(.5,.5)},direction:{value:new p.Vector2(.5,.5)}},vertexShader:`varying vec2 vUv;
154
+ void main() {
155
+ vUv = uv;
156
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
157
+ }`,fragmentShader:`#include <common>
158
+ varying vec2 vUv;
159
+ uniform sampler2D colorTexture;
160
+ uniform vec2 texSize;
161
+ uniform vec2 direction;
162
+
163
+ float gaussianPdf(in float x, in float sigma) {
164
+ return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;
165
+ }
166
+ void main() {
167
+ vec2 invSize = 1.0 / texSize;
168
+ float fSigma = float(SIGMA);
169
+ float weightSum = gaussianPdf(0.0, fSigma);
170
+ vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;
171
+ for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
172
+ float x = float(i);
173
+ float w = gaussianPdf(x, fSigma);
174
+ vec2 uvOffset = direction * invSize * x;
175
+ vec3 sample1 = texture2D( colorTexture, vUv + uvOffset).rgb;
176
+ vec3 sample2 = texture2D( colorTexture, vUv - uvOffset).rgb;
177
+ diffuseSum += (sample1 + sample2) * w;
178
+ weightSum += 2.0 * w;
179
+ }
180
+ gl_FragColor = vec4(diffuseSum/weightSum, 1.0);
181
+ }`})}getCompositeMaterial(t){return new p.ShaderMaterial({defines:{NUM_MIPS:t},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv;
182
+ void main() {
183
+ vUv = uv;
184
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
185
+ }`,fragmentShader:`varying vec2 vUv;
186
+ uniform sampler2D blurTexture1;
187
+ uniform sampler2D blurTexture2;
188
+ uniform sampler2D blurTexture3;
189
+ uniform sampler2D blurTexture4;
190
+ uniform sampler2D blurTexture5;
191
+ uniform float bloomStrength;
192
+ uniform float bloomRadius;
193
+ uniform float bloomFactors[NUM_MIPS];
194
+ uniform vec3 bloomTintColors[NUM_MIPS];
195
+
196
+ float lerpBloomFactor(const in float factor) {
197
+ float mirrorFactor = 1.2 - factor;
198
+ return mix(factor, mirrorFactor, bloomRadius);
199
+ }
200
+
201
+ void main() {
202
+ gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
203
+ lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
204
+ lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
205
+ lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
206
+ lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
207
+ }`})}};let e=i;return Bl(e,"BlurDirectionX",new p.Vector2(1,0)),Bl(e,"BlurDirectionY",new p.Vector2(0,1)),e})();var kf=Object.defineProperty,Kf=(i,e,t)=>e in i?kf(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Lo=(i,e,t)=>(Kf(i,typeof e!="symbol"?e+"":e,t),t);class Yl extends fi{constructor(e,t){super(),Lo(this,"scene"),Lo(this,"camera"),Lo(this,"inverse"),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);let a,c;this.inverse?(a=0,c=1):(a=1,c=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),o.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),o.buffers.stencil.setClear(c),o.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(r.EQUAL,1,4294967295),o.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),o.buffers.stencil.setLocked(!0)}}class Nf extends fi{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}var Bf=Object.defineProperty,Yf=(i,e,t)=>e in i?Bf(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,kt=(i,e,t)=>(Yf(i,typeof e!="symbol"?e+"":e,t),t);class Rf{constructor(e,t){if(kt(this,"renderer"),kt(this,"_pixelRatio"),kt(this,"_width"),kt(this,"_height"),kt(this,"renderTarget1"),kt(this,"renderTarget2"),kt(this,"writeBuffer"),kt(this,"readBuffer"),kt(this,"renderToScreen"),kt(this,"passes",[]),kt(this,"copyPass"),kt(this,"clock"),this.renderer=e,t===void 0){const n={minFilter:p.LinearFilter,magFilter:p.LinearFilter,format:p.RGBAFormat},r=e.getSize(new p.Vector2);this._pixelRatio=e.getPixelRatio(),this._width=r.width,this._height=r.height,t=new p.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,n),t.texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,So===void 0&&console.error("THREE.EffectComposer relies on CopyShader"),Nl===void 0&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Nl(So),this.copyPass.material.blending=p.NoBlending,this.clock=new p.Clock}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;const r=this.passes.length;for(let o=0;o<r;o++){const a=this.passes[o];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(o),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){const c=this.renderer.getContext(),u=this.renderer.state.buffers.stencil;u.setFunc(c.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),u.setFunc(c.EQUAL,1,4294967295)}this.swapBuffers()}Yl!==void 0&&(a instanceof Yl?n=!0:a instanceof Nf&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new p.Vector2);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let o=0;o<this.passes.length;o++)this.passes[o].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}var jf=Object.defineProperty,Jf=(i,e,t)=>e in i?jf(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,dr=(i,e,t)=>(Jf(i,typeof e!="symbol"?e+"":e,t),t);class Qf extends fi{constructor(e,t,n,r,o=0){super(),dr(this,"scene"),dr(this,"camera"),dr(this,"overrideMaterial"),dr(this,"clearColor"),dr(this,"clearAlpha"),dr(this,"clearDepth",!1),dr(this,"_oldClearColor",new p.Color),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=o,this.clear=!0,this.needsSwap=!1}render(e,t,n){let r=e.autoClear;e.autoClear=!1;let o,a=null;this.overrideMaterial!==void 0&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),o=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,o),this.overrideMaterial!==void 0&&(this.scene.overrideMaterial=a),e.autoClear=r}}function Dr(i){if(typeof TextDecoder<"u")return new TextDecoder().decode(i);let e="";for(let t=0,n=i.length;t<n;t++)e+=String.fromCharCode(i[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const fr="srgb",Sn="srgb-linear",Rl=3001,Hf=3e3;class Ef extends p.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new np(t)}),this.register(function(t){return new rp(t)}),this.register(function(t){return new dp(t)}),this.register(function(t){return new fp(t)}),this.register(function(t){return new pp(t)}),this.register(function(t){return new sp(t)}),this.register(function(t){return new op(t)}),this.register(function(t){return new ap(t)}),this.register(function(t){return new lp(t)}),this.register(function(t){return new tp(t)}),this.register(function(t){return new cp(t)}),this.register(function(t){return new ip(t)}),this.register(function(t){return new hp(t)}),this.register(function(t){return new up(t)}),this.register(function(t){return new qf(t)}),this.register(function(t){return new mp(t)}),this.register(function(t){return new gp(t)})}load(e,t,n,r){const o=this;let a;if(this.resourcePath!=="")a=this.resourcePath;else if(this.path!==""){const d=p.LoaderUtils.extractUrlBase(e);a=p.LoaderUtils.resolveURL(d,this.path)}else a=p.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const c=function(d){r?r(d):console.error(d),o.manager.itemError(e),o.manager.itemEnd(e)},u=new p.FileLoader(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(this.withCredentials),u.load(e,function(d){try{o.parse(d,a,function(m){t(m),o.manager.itemEnd(e)},c)}catch(m){c(m)}},n,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let o;const a={},c={};if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(Dr(new Uint8Array(e.slice(0,4)))===jl){try{a[_e.KHR_BINARY_GLTF]=new yp(e)}catch(m){r&&r(m);return}o=JSON.parse(a[_e.KHR_BINARY_GLTF].content)}else o=JSON.parse(Dr(new Uint8Array(e)));else o=e;if(o.asset===void 0||o.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new Zp(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const m=this.pluginCallbacks[d](u);m.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[m.name]=m,a[m.name]=!0}if(o.extensionsUsed)for(let d=0;d<o.extensionsUsed.length;++d){const m=o.extensionsUsed[d],f=o.extensionsRequired||[];switch(m){case _e.KHR_MATERIALS_UNLIT:a[m]=new ep;break;case _e.KHR_DRACO_MESH_COMPRESSION:a[m]=new _p(o,this.dracoLoader);break;case _e.KHR_TEXTURE_TRANSFORM:a[m]=new vp;break;case _e.KHR_MESH_QUANTIZATION:a[m]=new wp;break;default:f.indexOf(m)>=0&&c[m]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+m+'".')}}u.setExtensions(a),u.setPlugins(c),u.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,o){n.parse(e,t,r,o)})}}function $f(){let i={};return{get:function(e){return i[e]},add:function(e,t){i[e]=t},remove:function(e){delete i[e]},removeAll:function(){i={}}}}const _e={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class qf{constructor(e){this.parser=e,this.name=_e.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const o=t.json,u=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let d;const m=new p.Color(16777215);u.color!==void 0&&m.setRGB(u.color[0],u.color[1],u.color[2],Sn);const f=u.range!==void 0?u.range:0;switch(u.type){case"directional":d=new p.DirectionalLight(m),d.target.position.set(0,0,-1),d.add(d.target);break;case"point":d=new p.PointLight(m),d.distance=f;break;case"spot":d=new p.SpotLight(m),d.distance=f,u.spot=u.spot||{},u.spot.innerConeAngle=u.spot.innerConeAngle!==void 0?u.spot.innerConeAngle:0,u.spot.outerConeAngle=u.spot.outerConeAngle!==void 0?u.spot.outerConeAngle:Math.PI/4,d.angle=u.spot.outerConeAngle,d.penumbra=1-u.spot.innerConeAngle/u.spot.outerConeAngle,d.target.position.set(0,0,-1),d.add(d.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+u.type)}return d.position.set(0,0,0),d.decay=2,Ln(d,u),u.intensity!==void 0&&(d.intensity=u.intensity),d.name=t.createUniqueName(u.name||"light_"+e),r=Promise.resolve(d),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],c=(o.extensions&&o.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(u){return n._getNodeRef(t.cache,c,u)})}}class ep{constructor(){this.name=_e.KHR_MATERIALS_UNLIT}getMaterialType(){return p.MeshBasicMaterial}extendParams(e,t,n){const r=[];e.color=new p.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const a=o.baseColorFactor;e.color.setRGB(a[0],a[1],a[2],Sn),e.opacity=a[3]}o.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",o.baseColorTexture,fr))}return Promise.all(r)}}class tp{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class np{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];if(a.clearcoatFactor!==void 0&&(t.clearcoat=a.clearcoatFactor),a.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",a.clearcoatTexture)),a.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=a.clearcoatRoughnessFactor),a.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",a.clearcoatRoughnessTexture)),a.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",a.clearcoatNormalTexture)),a.clearcoatNormalTexture.scale!==void 0)){const c=a.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new p.Vector2(c,c)}return Promise.all(o)}}class rp{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class ip{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.iridescenceFactor!==void 0&&(t.iridescence=a.iridescenceFactor),a.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",a.iridescenceTexture)),a.iridescenceIor!==void 0&&(t.iridescenceIOR=a.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),a.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=a.iridescenceThicknessMaximum),a.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",a.iridescenceThicknessTexture)),Promise.all(o)}}class sp{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new p.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=r.extensions[this.name];if(a.sheenColorFactor!==void 0){const c=a.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],Sn)}return a.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=a.sheenRoughnessFactor),a.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",a.sheenColorTexture,fr)),a.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(o)}}class op{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.transmissionFactor!==void 0&&(t.transmission=a.transmissionFactor),a.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",a.transmissionTexture)),Promise.all(o)}}class ap{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];t.thickness=a.thicknessFactor!==void 0?a.thicknessFactor:0,a.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",a.thicknessTexture)),t.attenuationDistance=a.attenuationDistance||1/0;const c=a.attenuationColor||[1,1,1];return t.attenuationColor=new p.Color().setRGB(c[0],c[1],c[2],Sn),Promise.all(o)}}class lp{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=r.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class cp{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];t.specularIntensity=a.specularFactor!==void 0?a.specularFactor:1,a.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",a.specularTexture));const c=a.specularColorFactor||[1,1,1];return t.specularColor=new p.Color().setRGB(c[0],c[1],c[2],Sn),a.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",a.specularColorTexture,fr)),Promise.all(o)}}class up{constructor(e){this.parser=e,this.name=_e.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return t.bumpScale=a.bumpFactor!==void 0?a.bumpFactor:1,a.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",a.bumpTexture)),Promise.all(o)}}class hp{constructor(e){this.parser=e,this.name=_e.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:p.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const o=[],a=r.extensions[this.name];return a.anisotropyStrength!==void 0&&(t.anisotropy=a.anisotropyStrength),a.anisotropyRotation!==void 0&&(t.anisotropyRotation=a.anisotropyRotation),a.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",a.anisotropyTexture)),Promise.all(o)}}class dp{constructor(e){this.parser=e,this.name=_e.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const o=r.extensions[this.name],a=t.options.ktx2Loader;if(!a){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,a)}}class fp{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],c=r.images[a.source];let u=n.textureLoader;if(c.uri){const d=n.options.manager.getHandler(c.uri);d!==null&&(u=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(e,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class pp{constructor(e){this.parser=e,this.name=_e.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,o=r.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],c=r.images[a.source];let u=n.textureLoader;if(c.uri){const d=n.options.manager.getHandler(c.uri);d!==null&&(u=d)}return this.detectSupport().then(function(d){if(d)return n.loadTextureImage(e,a.source,u);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class mp{constructor(e){this.name=_e.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const r=n.extensions[this.name],o=this.parser.getDependency("buffer",r.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(c){const u=r.byteOffset||0,d=r.byteLength||0,m=r.count,f=r.byteStride,g=new Uint8Array(c,u,d);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(m,f,g,r.mode,r.filter).then(function(_){return _.buffer}):a.ready.then(function(){const _=new ArrayBuffer(m*f);return a.decodeGltfBuffer(new Uint8Array(_),m,f,g,r.mode,r.filter),_})})}else return null}}class gp{constructor(e){this.name=_e.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const r=t.meshes[n.mesh];for(const d of r.primitives)if(d.mode!==Kt.TRIANGLES&&d.mode!==Kt.TRIANGLE_STRIP&&d.mode!==Kt.TRIANGLE_FAN&&d.mode!==void 0)return null;const a=n.extensions[this.name].attributes,c=[],u={};for(const d in a)c.push(this.parser.getDependency("accessor",a[d]).then(m=>(u[d]=m,u[d])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(d=>{const m=d.pop(),f=m.isGroup?m.children:[m],g=d[0].count,_=[];for(const w of f){const b=new p.Matrix4,x=new p.Vector3,L=new p.Quaternion,M=new p.Vector3(1,1,1),C=new p.InstancedMesh(w.geometry,w.material,g);for(let Z=0;Z<g;Z++)u.TRANSLATION&&x.fromBufferAttribute(u.TRANSLATION,Z),u.ROTATION&&L.fromBufferAttribute(u.ROTATION,Z),u.SCALE&&M.fromBufferAttribute(u.SCALE,Z),C.setMatrixAt(Z,b.compose(x,L,M));for(const Z in u)if(Z==="_COLOR_0"){const z=u[Z];C.instanceColor=new p.InstancedBufferAttribute(z.array,z.itemSize,z.normalized)}else Z!=="TRANSLATION"&&Z!=="ROTATION"&&Z!=="SCALE"&&w.geometry.setAttribute(Z,u[Z]);p.Object3D.prototype.copy.call(C,w),this.parser.assignFinalMaterial(C),_.push(C)}return m.isGroup?(m.clear(),m.add(..._),m):_[0]}))}}const jl="glTF",pi=12,Jl={JSON:1313821514,BIN:5130562};class yp{constructor(e){this.name=_e.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,pi);if(this.header={magic:Dr(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==jl)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-pi,r=new DataView(e,pi);let o=0;for(;o<n;){const a=r.getUint32(o,!0);o+=4;const c=r.getUint32(o,!0);if(o+=4,c===Jl.JSON){const u=new Uint8Array(e,pi+o,a);this.content=Dr(u)}else if(c===Jl.BIN){const u=pi+o;this.body=e.slice(u,u+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class _p{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_e.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,o=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,c={},u={},d={};for(const m in a){const f=Co[m]||m.toLowerCase();c[f]=a[m]}for(const m in e.attributes){const f=Co[m]||m.toLowerCase();if(a[m]!==void 0){const g=n.accessors[e.attributes[m]],_=zr[g.componentType];d[f]=_.name,u[f]=g.normalized===!0}}return t.getDependency("bufferView",o).then(function(m){return new Promise(function(f,g){r.decodeDracoFile(m,function(_){for(const w in _.attributes){const b=_.attributes[w],x=u[w];x!==void 0&&(b.normalized=x)}f(_)},c,d,Sn,g)})})}}class vp{constructor(){this.name=_e.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class wp{constructor(){this.name=_e.KHR_MESH_QUANTIZATION}}class Ql extends p.Interpolant{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r*3+r;for(let a=0;a!==r;a++)t[a]=n[o+a];return t}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=c*2,d=c*3,m=r-t,f=(n-t)/m,g=f*f,_=g*f,w=e*d,b=w-d,x=-2*_+3*g,L=_-g,M=1-x,C=L-g+f;for(let Z=0;Z!==c;Z++){const z=a[b+Z+c],D=a[b+Z+u]*m,X=a[w+Z+c],I=a[w+Z]*m;o[Z]=M*z+C*D+x*X+L*I}return o}}const bp=new p.Quaternion;class xp extends Ql{interpolate_(e,t,n,r){const o=super.interpolate_(e,t,n,r);return bp.fromArray(o).normalize().toArray(o),o}}const Kt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},zr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Hl={9728:p.NearestFilter,9729:p.LinearFilter,9984:p.NearestMipmapNearestFilter,9985:p.LinearMipmapNearestFilter,9986:p.NearestMipmapLinearFilter,9987:p.LinearMipmapLinearFilter},El={33071:p.ClampToEdgeWrapping,33648:p.MirroredRepeatWrapping,10497:p.RepeatWrapping},Po={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Co={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...$i>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Mp={CUBICSPLINE:void 0,LINEAR:p.InterpolateLinear,STEP:p.InterpolateDiscrete},To={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Sp(i){return i.DefaultMaterial===void 0&&(i.DefaultMaterial=new p.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:p.FrontSide})),i.DefaultMaterial}function pr(i,e,t){for(const n in t.extensions)i[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Ln(i,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(i.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Lp(i,e,t){let n=!1,r=!1,o=!1;for(let d=0,m=e.length;d<m;d++){const f=e[d];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(r=!0),f.COLOR_0!==void 0&&(o=!0),n&&r&&o)break}if(!n&&!r&&!o)return Promise.resolve(i);const a=[],c=[],u=[];for(let d=0,m=e.length;d<m;d++){const f=e[d];if(n){const g=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):i.attributes.position;a.push(g)}if(r){const g=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):i.attributes.normal;c.push(g)}if(o){const g=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):i.attributes.color;u.push(g)}}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(u)]).then(function(d){const m=d[0],f=d[1],g=d[2];return n&&(i.morphAttributes.position=m),r&&(i.morphAttributes.normal=f),o&&(i.morphAttributes.color=g),i.morphTargetsRelative=!0,i})}function Pp(i,e){if(i.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)i.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(i.morphTargetInfluences.length===t.length){i.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)i.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Cp(i){let e;const t=i.extensions&&i.extensions[_e.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Go(t.attributes):e=i.indices+":"+Go(i.attributes)+":"+i.mode,i.targets!==void 0)for(let n=0,r=i.targets.length;n<r;n++)e+=":"+Go(i.targets[n]);return e}function Go(i){let e="";const t=Object.keys(i).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+i[t[n]]+";";return e}function Zo(i){switch(i){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Tp(i){return i.search(/\.jpe?g($|\?)/i)>0||i.search(/^data\:image\/jpeg/)===0?"image/jpeg":i.search(/\.webp($|\?)/i)>0||i.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Gp=new p.Matrix4;class Zp{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new $f,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,o=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,o=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||r&&o<98?this.textureLoader=new p.TextureLoader(this.options.manager):this.textureLoader=new p.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new p.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(a){return a._markDefs&&a._markDefs()}),Promise.all(this._invokeAll(function(a){return a.beforeRoot&&a.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(a){const c={scene:a[0][r.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:r.asset,parser:n,userData:{}};return pr(o,c,r),Ln(c,r),Promise.all(n._invokeAll(function(u){return u.afterRoot&&u.afterRoot(c)})).then(function(){for(const u of c.scenes)u.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,o=t.length;r<o;r++){const a=t[r].joints;for(let c=0,u=a.length;c<u;c++)e[a[c]].isBone=!0}for(let r=0,o=e.length;r<o;r++){const a=e[r];a.mesh!==void 0&&(this._addNodeRef(this.meshCache,a.mesh),a.skin!==void 0&&(n[a.mesh].isSkinnedMesh=!0)),a.camera!==void 0&&this._addNodeRef(this.cameraCache,a.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),o=(a,c)=>{const u=this.associations.get(a);u!=null&&this.associations.set(c,u);for(const[d,m]of a.children.entries())o(m,c.children[d])};return o(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const o=e(t[r]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":r=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(o,a){return n.getDependency(e,a)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[_e.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(o,a){n.load(p.LoaderUtils.resolveURL(t.uri,r.path),o,void 0,function(){a(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const r=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+r)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const a=Po[r.type],c=zr[r.componentType],u=r.normalized===!0,d=new c(r.count*a);return Promise.resolve(new p.BufferAttribute(d,a,u))}const o=[];return r.bufferView!==void 0?o.push(this.getDependency("bufferView",r.bufferView)):o.push(null),r.sparse!==void 0&&(o.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(o).then(function(a){const c=a[0],u=Po[r.type],d=zr[r.componentType],m=d.BYTES_PER_ELEMENT,f=m*u,g=r.byteOffset||0,_=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,w=r.normalized===!0;let b,x;if(_&&_!==f){const L=Math.floor(g/_),M="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+L+":"+r.count;let C=t.cache.get(M);C||(b=new d(c,L*_,r.count*_/m),C=new p.InterleavedBuffer(b,_/m),t.cache.add(M,C)),x=new p.InterleavedBufferAttribute(C,u,g%_/m,w)}else c===null?b=new d(r.count*u):b=new d(c,g,r.count*u),x=new p.BufferAttribute(b,u,w);if(r.sparse!==void 0){const L=Po.SCALAR,M=zr[r.sparse.indices.componentType],C=r.sparse.indices.byteOffset||0,Z=r.sparse.values.byteOffset||0,z=new M(a[1],C,r.sparse.count*L),D=new d(a[2],Z,r.sparse.count*u);c!==null&&(x=new p.BufferAttribute(x.array.slice(),x.itemSize,x.normalized));for(let X=0,I=z.length;X<I;X++){const K=z[X];if(x.setX(K,D[X*u]),u>=2&&x.setY(K,D[X*u+1]),u>=3&&x.setZ(K,D[X*u+2]),u>=4&&x.setW(K,D[X*u+3]),u>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return x})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,a=t.images[o];let c=this.textureLoader;if(a.uri){const u=n.manager.getHandler(a.uri);u!==null&&(c=u)}return this.loadTextureImage(e,o,c)}loadTextureImage(e,t,n){const r=this,o=this.json,a=o.textures[e],c=o.images[t],u=(c.uri||c.bufferView)+":"+a.sampler;if(this.textureCache[u])return this.textureCache[u];const d=this.loadImageSource(t,n).then(function(m){m.flipY=!1,m.name=a.name||c.name||"",m.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(m.name=c.uri);const g=(o.samplers||{})[a.sampler]||{};return m.magFilter=Hl[g.magFilter]||p.LinearFilter,m.minFilter=Hl[g.minFilter]||p.LinearMipmapLinearFilter,m.wrapS=El[g.wrapS]||p.RepeatWrapping,m.wrapT=El[g.wrapT]||p.RepeatWrapping,r.associations.set(m,{textures:e}),m}).catch(function(){return null});return this.textureCache[u]=d,d}loadImageSource(e,t){const n=this,r=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const a=r.images[e],c=self.URL||self.webkitURL;let u=a.uri||"",d=!1;if(a.bufferView!==void 0)u=n.getDependency("bufferView",a.bufferView).then(function(f){d=!0;const g=new Blob([f],{type:a.mimeType});return u=c.createObjectURL(g),u});else if(a.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const m=Promise.resolve(u).then(function(f){return new Promise(function(g,_){let w=g;t.isImageBitmapLoader===!0&&(w=function(b){const x=new p.Texture(b);x.needsUpdate=!0,g(x)}),t.load(p.LoaderUtils.resolveURL(f,o.path),w,void 0,_)})}).then(function(f){return d===!0&&c.revokeObjectURL(u),Ln(f,a),f.userData.mimeType=a.mimeType||Tp(a.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",u),f});return this.sourceCache[e]=m,m}assignTexture(e,t,n,r){const o=this;return this.getDependency("texture",n.index).then(function(a){if(!a)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(a=a.clone(),a.channel=n.texCoord),o.extensions[_e.KHR_TEXTURE_TRANSFORM]){const c=n.extensions!==void 0?n.extensions[_e.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const u=o.associations.get(a);a=o.extensions[_e.KHR_TEXTURE_TRANSFORM].extendTexture(a,c),o.associations.set(a,u)}}return r!==void 0&&(typeof r=="number"&&(r=r===Rl?fr:Sn),"colorSpace"in a?a.colorSpace=r:a.encoding=r===fr?Rl:Hf),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,a=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+n.uuid;let u=this.cache.get(c);u||(u=new p.PointsMaterial,p.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,u.sizeAttenuation=!1,this.cache.add(c,u)),n=u}else if(e.isLine){const c="LineBasicMaterial:"+n.uuid;let u=this.cache.get(c);u||(u=new p.LineBasicMaterial,p.Material.prototype.copy.call(u,n),u.color.copy(n.color),u.map=n.map,this.cache.add(c,u)),n=u}if(r||o||a){let c="ClonedMaterial:"+n.uuid+":";r&&(c+="derivative-tangents:"),o&&(c+="vertex-colors:"),a&&(c+="flat-shading:");let u=this.cache.get(c);u||(u=n.clone(),o&&(u.vertexColors=!0),a&&(u.flatShading=!0),r&&(u.normalScale&&(u.normalScale.y*=-1),u.clearcoatNormalScale&&(u.clearcoatNormalScale.y*=-1)),this.cache.add(c,u),this.associations.set(u,this.associations.get(n))),n=u}e.material=n}getMaterialType(){return p.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,o=n.materials[e];let a;const c={},u=o.extensions||{},d=[];if(u[_e.KHR_MATERIALS_UNLIT]){const f=r[_e.KHR_MATERIALS_UNLIT];a=f.getMaterialType(),d.push(f.extendParams(c,o,t))}else{const f=o.pbrMetallicRoughness||{};if(c.color=new p.Color(1,1,1),c.opacity=1,Array.isArray(f.baseColorFactor)){const g=f.baseColorFactor;c.color.setRGB(g[0],g[1],g[2],Sn),c.opacity=g[3]}f.baseColorTexture!==void 0&&d.push(t.assignTexture(c,"map",f.baseColorTexture,fr)),c.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,c.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(d.push(t.assignTexture(c,"metalnessMap",f.metallicRoughnessTexture)),d.push(t.assignTexture(c,"roughnessMap",f.metallicRoughnessTexture))),a=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),d.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,c)})))}o.doubleSided===!0&&(c.side=p.DoubleSide);const m=o.alphaMode||To.OPAQUE;if(m===To.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,m===To.MASK&&(c.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&a!==p.MeshBasicMaterial&&(d.push(t.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new p.Vector2(1,1),o.normalTexture.scale!==void 0)){const f=o.normalTexture.scale;c.normalScale.set(f,f)}if(o.occlusionTexture!==void 0&&a!==p.MeshBasicMaterial&&(d.push(t.assignTexture(c,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&a!==p.MeshBasicMaterial){const f=o.emissiveFactor;c.emissive=new p.Color().setRGB(f[0],f[1],f[2],Sn)}return o.emissiveTexture!==void 0&&a!==p.MeshBasicMaterial&&d.push(t.assignTexture(c,"emissiveMap",o.emissiveTexture,fr)),Promise.all(d).then(function(){const f=new a(c);return o.name&&(f.name=o.name),Ln(f,o),t.associations.set(f,{materials:e}),o.extensions&&pr(r,f,o),f})}createUniqueName(e){const t=p.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function o(c){return n[_e.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(u){return $l(u,c,t)})}const a=[];for(let c=0,u=e.length;c<u;c++){const d=e[c],m=Cp(d),f=r[m];if(f)a.push(f.promise);else{let g;d.extensions&&d.extensions[_e.KHR_DRACO_MESH_COMPRESSION]?g=o(d):g=$l(new p.BufferGeometry,d,t),r[m]={primitive:d,promise:g},a.push(g)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,r=this.extensions,o=n.meshes[e],a=o.primitives,c=[];for(let u=0,d=a.length;u<d;u++){const m=a[u].material===void 0?Sp(this.cache):this.getDependency("material",a[u].material);c.push(m)}return c.push(t.loadGeometries(a)),Promise.all(c).then(function(u){const d=u.slice(0,u.length-1),m=u[u.length-1],f=[];for(let _=0,w=m.length;_<w;_++){const b=m[_],x=a[_];let L;const M=d[_];if(x.mode===Kt.TRIANGLES||x.mode===Kt.TRIANGLE_STRIP||x.mode===Kt.TRIANGLE_FAN||x.mode===void 0)L=o.isSkinnedMesh===!0?new p.SkinnedMesh(b,M):new p.Mesh(b,M),L.isSkinnedMesh===!0&&L.normalizeSkinWeights(),x.mode===Kt.TRIANGLE_STRIP?L.geometry=Il(L.geometry,p.TriangleStripDrawMode):x.mode===Kt.TRIANGLE_FAN&&(L.geometry=Il(L.geometry,p.TriangleFanDrawMode));else if(x.mode===Kt.LINES)L=new p.LineSegments(b,M);else if(x.mode===Kt.LINE_STRIP)L=new p.Line(b,M);else if(x.mode===Kt.LINE_LOOP)L=new p.LineLoop(b,M);else if(x.mode===Kt.POINTS)L=new p.Points(b,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+x.mode);Object.keys(L.geometry.morphAttributes).length>0&&Pp(L,o),L.name=t.createUniqueName(o.name||"mesh_"+e),Ln(L,o),x.extensions&&pr(r,L,x),t.assignFinalMaterial(L),f.push(L)}for(let _=0,w=f.length;_<w;_++)t.associations.set(f[_],{meshes:e,primitives:_});if(f.length===1)return o.extensions&&pr(r,f[0],o),f[0];const g=new p.Group;o.extensions&&pr(r,g,o),t.associations.set(g,{meshes:e});for(let _=0,w=f.length;_<w;_++)g.add(f[_]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new p.PerspectiveCamera(p.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new p.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Ln(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,o=t.joints.length;r<o;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){const o=r.pop(),a=r,c=[],u=[];for(let d=0,m=a.length;d<m;d++){const f=a[d];if(f){c.push(f);const g=new p.Matrix4;o!==null&&g.fromArray(o.array,d*16),u.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[d])}return new p.Skeleton(c,u)})}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],o=r.name?r.name:"animation_"+e,a=[],c=[],u=[],d=[],m=[];for(let f=0,g=r.channels.length;f<g;f++){const _=r.channels[f],w=r.samplers[_.sampler],b=_.target,x=b.node,L=r.parameters!==void 0?r.parameters[w.input]:w.input,M=r.parameters!==void 0?r.parameters[w.output]:w.output;b.node!==void 0&&(a.push(this.getDependency("node",x)),c.push(this.getDependency("accessor",L)),u.push(this.getDependency("accessor",M)),d.push(w),m.push(b))}return Promise.all([Promise.all(a),Promise.all(c),Promise.all(u),Promise.all(d),Promise.all(m)]).then(function(f){const g=f[0],_=f[1],w=f[2],b=f[3],x=f[4],L=[];for(let M=0,C=g.length;M<C;M++){const Z=g[M],z=_[M],D=w[M],X=b[M],I=x[M];if(Z===void 0)continue;Z.updateMatrix&&Z.updateMatrix();const K=n._createAnimationTracks(Z,z,D,X,I);if(K)for(let V=0;V<K.length;V++)L.push(K[V])}return new p.AnimationClip(o,void 0,L)})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(o){const a=n._getNodeRef(n.meshCache,r.mesh,o);return r.weights!==void 0&&a.traverse(function(c){if(c.isMesh)for(let u=0,d=r.weights.length;u<d;u++)c.morphTargetInfluences[u]=r.weights[u]}),a})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],o=n._loadNodeShallow(e),a=[],c=r.children||[];for(let d=0,m=c.length;d<m;d++)a.push(n.getDependency("node",c[d]));const u=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([o,Promise.all(a),u]).then(function(d){const m=d[0],f=d[1],g=d[2];g!==null&&m.traverse(function(_){_.isSkinnedMesh&&_.bind(g,Gp)});for(let _=0,w=f.length;_<w;_++)m.add(f[_]);return m})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],a=o.name?r.createUniqueName(o.name):"",c=[],u=r._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(e)});return u&&c.push(u),o.camera!==void 0&&c.push(r.getDependency("camera",o.camera).then(function(d){return r._getNodeRef(r.cameraCache,o.camera,d)})),r._invokeAll(function(d){return d.createNodeAttachment&&d.createNodeAttachment(e)}).forEach(function(d){c.push(d)}),this.nodeCache[e]=Promise.all(c).then(function(d){let m;if(o.isBone===!0?m=new p.Bone:d.length>1?m=new p.Group:d.length===1?m=d[0]:m=new p.Object3D,m!==d[0])for(let f=0,g=d.length;f<g;f++)m.add(d[f]);if(o.name&&(m.userData.name=o.name,m.name=a),Ln(m,o),o.extensions&&pr(n,m,o),o.matrix!==void 0){const f=new p.Matrix4;f.fromArray(o.matrix),m.applyMatrix4(f)}else o.translation!==void 0&&m.position.fromArray(o.translation),o.rotation!==void 0&&m.quaternion.fromArray(o.rotation),o.scale!==void 0&&m.scale.fromArray(o.scale);return r.associations.has(m)||r.associations.set(m,{}),r.associations.get(m).nodes=e,m}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,o=new p.Group;n.name&&(o.name=r.createUniqueName(n.name)),Ln(o,n),n.extensions&&pr(t,o,n);const a=n.nodes||[],c=[];for(let u=0,d=a.length;u<d;u++)c.push(r.getDependency("node",a[u]));return Promise.all(c).then(function(u){for(let m=0,f=u.length;m<f;m++)o.add(u[m]);const d=m=>{const f=new Map;for(const[g,_]of r.associations)(g instanceof p.Material||g instanceof p.Texture)&&f.set(g,_);return m.traverse(g=>{const _=r.associations.get(g);_!=null&&f.set(g,_)}),f};return r.associations=d(o),o})}_createAnimationTracks(e,t,n,r,o){const a=[],c=e.name?e.name:e.uuid,u=[];Xn[o.path]===Xn.weights?e.traverse(function(g){g.morphTargetInfluences&&u.push(g.name?g.name:g.uuid)}):u.push(c);let d;switch(Xn[o.path]){case Xn.weights:d=p.NumberKeyframeTrack;break;case Xn.rotation:d=p.QuaternionKeyframeTrack;break;case Xn.position:case Xn.scale:d=p.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:d=p.NumberKeyframeTrack;break;case 2:case 3:default:d=p.VectorKeyframeTrack;break}break}const m=r.interpolation!==void 0?Mp[r.interpolation]:p.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let g=0,_=u.length;g<_;g++){const w=new d(u[g]+"."+Xn[o.path],t.array,f,m);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(w),a.push(w)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Zo(t.constructor),r=new Float32Array(t.length);for(let o=0,a=t.length;o<a;o++)r[o]=t[o]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const r=this instanceof p.QuaternionKeyframeTrack?xp:Ql;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Wp(i,e,t){const n=e.attributes,r=new p.Box3;if(n.POSITION!==void 0){const c=t.json.accessors[n.POSITION],u=c.min,d=c.max;if(u!==void 0&&d!==void 0){if(r.set(new p.Vector3(u[0],u[1],u[2]),new p.Vector3(d[0],d[1],d[2])),c.normalized){const m=Zo(zr[c.componentType]);r.min.multiplyScalar(m),r.max.multiplyScalar(m)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const c=new p.Vector3,u=new p.Vector3;for(let d=0,m=o.length;d<m;d++){const f=o[d];if(f.POSITION!==void 0){const g=t.json.accessors[f.POSITION],_=g.min,w=g.max;if(_!==void 0&&w!==void 0){if(u.setX(Math.max(Math.abs(_[0]),Math.abs(w[0]))),u.setY(Math.max(Math.abs(_[1]),Math.abs(w[1]))),u.setZ(Math.max(Math.abs(_[2]),Math.abs(w[2]))),g.normalized){const b=Zo(zr[g.componentType]);u.multiplyScalar(b)}c.max(u)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(c)}i.boundingBox=r;const a=new p.Sphere;r.getCenter(a.center),a.radius=r.min.distanceTo(r.max)/2,i.boundingSphere=a}function $l(i,e,t){const n=e.attributes,r=[];function o(a,c){return t.getDependency("accessor",a).then(function(u){i.setAttribute(c,u)})}for(const a in n){const c=Co[a]||a.toLowerCase();c in i.attributes||r.push(o(n[a],c))}if(e.indices!==void 0&&!i.index){const a=t.getDependency("accessor",e.indices).then(function(c){i.setIndex(c)});r.push(a)}return Ln(i,e),Wp(i,e,t),Promise.all(r).then(function(){return e.targets!==void 0?Lp(i,e.targets,t):i})}function ql(i,e,t){const n=t.length-i-1;if(e>=t[n])return n-1;if(e<=t[i])return i;let r=i,o=n,a=Math.floor((r+o)/2);for(;e<t[a]||e>=t[a+1];)e<t[a]?o=a:r=a,a=Math.floor((r+o)/2);return a}function Vp(i,e,t,n){const r=[],o=[],a=[];r[0]=1;for(let c=1;c<=t;++c){o[c]=e-n[i+1-c],a[c]=n[i+c]-e;let u=0;for(let d=0;d<c;++d){const m=a[d+1],f=o[c-d],g=r[d]/(m+f);r[d]=u+m*g,u=f*g}r[c]=u}return r}function Ip(i,e,t,n){const r=ql(i,n,e),o=Vp(r,n,i,e),a=new p.Vector4(0,0,0,0);for(let c=0;c<=i;++c){const u=t[r-i+c],d=o[c],m=u.w*d;a.x+=u.x*m,a.y+=u.y*m,a.z+=u.z*m,a.w+=u.w*d}return a}function Ap(i,e,t,n,r){const o=[];for(let f=0;f<=t;++f)o[f]=0;const a=[];for(let f=0;f<=n;++f)a[f]=o.slice(0);const c=[];for(let f=0;f<=t;++f)c[f]=o.slice(0);c[0][0]=1;const u=o.slice(0),d=o.slice(0);for(let f=1;f<=t;++f){u[f]=e-r[i+1-f],d[f]=r[i+f]-e;let g=0;for(let _=0;_<f;++_){const w=d[_+1],b=u[f-_];c[f][_]=w+b;const x=c[_][f-1]/c[f][_];c[_][f]=g+w*x,g=b*x}c[f][f]=g}for(let f=0;f<=t;++f)a[0][f]=c[f][t];for(let f=0;f<=t;++f){let g=0,_=1;const w=[];for(let b=0;b<=t;++b)w[b]=o.slice(0);w[0][0]=1;for(let b=1;b<=n;++b){let x=0;const L=f-b,M=t-b;f>=b&&(w[_][0]=w[g][0]/c[M+1][L],x=w[_][0]*c[L][M]);const C=L>=-1?1:-L,Z=f-1<=M?b-1:t-f;for(let D=C;D<=Z;++D)w[_][D]=(w[g][D]-w[g][D-1])/c[M+1][L+D],x+=w[_][D]*c[L+D][M];f<=M&&(w[_][b]=-w[g][b-1]/c[M+1][f],x+=w[_][b]*c[f][M]),a[b][f]=x;const z=g;g=_,_=z}}let m=t;for(let f=1;f<=n;++f){for(let g=0;g<=t;++g)a[f][g]*=m;m*=t-f}return a}function Fp(i,e,t,n,r){const o=r<i?r:i,a=[],c=ql(i,n,e),u=Ap(c,n,i,o,e),d=[];for(let m=0;m<t.length;++m){const f=t[m].clone(),g=f.w;f.x*=g,f.y*=g,f.z*=g,d[m]=f}for(let m=0;m<=o;++m){const f=d[c-i].clone().multiplyScalar(u[m][0]);for(let g=1;g<=i;++g)f.add(d[c-i+g].clone().multiplyScalar(u[m][g]));a[m]=f}for(let m=o+1;m<=r+1;++m)a[m]=new p.Vector4(0,0,0);return a}function Op(i,e){let t=1;for(let r=2;r<=i;++r)t*=r;let n=1;for(let r=2;r<=e;++r)n*=r;for(let r=2;r<=i-e;++r)n*=r;return t/n}function Dp(i){const e=i.length,t=[],n=[];for(let o=0;o<e;++o){const a=i[o];t[o]=new p.Vector3(a.x,a.y,a.z),n[o]=a.w}const r=[];for(let o=0;o<e;++o){const a=t[o].clone();for(let c=1;c<=o;++c)a.sub(r[o-c].clone().multiplyScalar(Op(o,c)*n[c]));r[o]=a.divideScalar(n[0])}return r}function zp(i,e,t,n,r){const o=Fp(i,e,t,n,r);return Dp(o)}class ec extends p.Curve{constructor(e,t,n,r,o){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=o||this.knots.length-1;for(let a=0;a<n.length;++a){const c=n[a];this.controlPoints[a]=new p.Vector4(c.x,c.y,c.z,c.w)}}getPoint(e,t){const n=t||new p.Vector3,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),o=Ip(this.degree,this.knots,this.controlPoints,r);return o.w!=1&&o.divideScalar(o.w),n.set(o.x,o.y,o.z)}getTangent(e,t){const n=t||new p.Vector3,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),o=zp(this.degree,this.knots,this.controlPoints,r,1);return n.copy(o[1]).normalize(),n}}let ve,Ue,bt;class Xp extends p.Loader{constructor(e){super(e)}load(e,t,n,r){const o=this,a=o.path===""?p.LoaderUtils.extractUrlBase(e):o.path,c=new p.FileLoader(this.manager);c.setPath(o.path),c.setResponseType("arraybuffer"),c.setRequestHeader(o.requestHeader),c.setWithCredentials(o.withCredentials),c.load(e,function(u){try{t(o.parse(u,a))}catch(d){r?r(d):console.error(d),o.manager.itemError(e)}},n,r)}parse(e,t){if(Yp(e))ve=new Bp().parse(e);else{const r=oc(e);if(!Rp(r))throw new Error("THREE.FBXLoader: Unknown format.");if(rc(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+rc(r));ve=new Np().parse(r)}const n=new p.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Up(n,this.manager).parse(ve)}}class Up{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Ue=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),o=new kp().parse(r);return this.parseScene(r,o,n),bt}parseConnections(){const e=new Map;return"Connections"in ve&&ve.Connections.connections.forEach(function(n){const r=n[0],o=n[1],a=n[2];e.has(r)||e.set(r,{parents:[],children:[]});const c={ID:o,relationship:a};e.get(r).parents.push(c),e.has(o)||e.set(o,{parents:[],children:[]});const u={ID:r,relationship:a};e.get(o).children.push(u)}),e}parseImages(){const e={},t={};if("Video"in ve.Objects){const n=ve.Objects.Video;for(const r in n){const o=n[r],a=parseInt(r);if(e[a]=o.RelativeFilename||o.Filename,"Content"in o){const c=o.Content instanceof ArrayBuffer&&o.Content.byteLength>0,u=typeof o.Content=="string"&&o.Content!=="";if(c||u){const d=this.parseImage(n[r]);t[o.RelativeFilename||o.Filename]=d}}}}for(const n in e){const r=e[n];t[r]!==void 0?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let o;switch(r){case"bmp":o="image/bmp";break;case"jpg":case"jpeg":o="image/jpeg";break;case"png":o="image/png";break;case"tif":o="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),o="image/tga";break;default:console.warn('FBXLoader: Image type "'+r+'" is not supported.');return}if(typeof t=="string")return"data:"+o+";base64,"+t;{const a=new Uint8Array(t);return window.URL.createObjectURL(new Blob([a],{type:o}))}}parseTextures(e){const t=new Map;if("Texture"in ve.Objects){const n=ve.Objects.Texture;for(const r in n){const o=this.parseTexture(n[r],e);t.set(parseInt(r),o)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,o=e.WrapModeV,a=r!==void 0?r.value:0,c=o!==void 0?o.value:0;if(n.wrapS=a===0?p.RepeatWrapping:p.ClampToEdgeWrapping,n.wrapT=c===0?p.RepeatWrapping:p.ClampToEdgeWrapping,"Scaling"in e){const u=e.Scaling.value;n.repeat.x=u[0],n.repeat.y=u[1]}return n}loadTexture(e,t){let n;const r=this.textureLoader.path,o=Ue.get(e.id).children;o!==void 0&&o.length>0&&t[o[0].ID]!==void 0&&(n=t[o[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let a;const c=e.FileName.slice(-3).toLowerCase();if(c==="tga"){const u=this.manager.getHandler(".tga");u===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),a=new p.Texture):(u.setPath(this.textureLoader.path),a=u.load(n))}else c==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),a=new p.Texture):a=this.textureLoader.load(n);return this.textureLoader.setPath(r),a}parseMaterials(e){const t=new Map;if("Material"in ve.Objects){const n=ve.Objects.Material;for(const r in n){const o=this.parseMaterial(n[r],e);o!==null&&t.set(parseInt(r),o)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let o=e.ShadingModel;if(typeof o=="object"&&(o=o.value),!Ue.has(n))return null;const a=this.parseParameters(e,t,n);let c;switch(o.toLowerCase()){case"phong":c=new p.MeshPhongMaterial;break;case"lambert":c=new p.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',o),c=new p.MeshPhongMaterial;break}return c.setValues(a),c.name=r,c}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=new p.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(r.color=new p.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=new p.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(r.emissive=new p.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(r.opacity=parseFloat(e.Opacity.value)),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=new p.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(r.specular=new p.Color().fromArray(e.SpecularColor.value));const o=this;return Ue.get(n).children.forEach(function(a){const c=a.relationship;switch(c){case"Bump":r.bumpMap=o.getTexture(t,a.ID);break;case"Maya|TEX_ao_map":r.aoMap=o.getTexture(t,a.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=o.getTexture(t,a.ID),r.map!==void 0&&("colorSpace"in r.map?r.map.colorSpace="srgb":r.map.encoding=3001);break;case"DisplacementColor":r.displacementMap=o.getTexture(t,a.ID);break;case"EmissiveColor":r.emissiveMap=o.getTexture(t,a.ID),r.emissiveMap!==void 0&&("colorSpace"in r.emissiveMap?r.emissiveMap.colorSpace="srgb":r.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=o.getTexture(t,a.ID);break;case"ReflectionColor":r.envMap=o.getTexture(t,a.ID),r.envMap!==void 0&&(r.envMap.mapping=p.EquirectangularReflectionMapping,"colorSpace"in r.envMap?r.envMap.colorSpace="srgb":r.envMap.encoding=3001);break;case"SpecularColor":r.specularMap=o.getTexture(t,a.ID),r.specularMap!==void 0&&("colorSpace"in r.specularMap?r.specularMap.colorSpace="srgb":r.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=o.getTexture(t,a.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",c);break}}),r}getTexture(e,t){return"LayeredTexture"in ve.Objects&&t in ve.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ue.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in ve.Objects){const n=ve.Objects.Deformer;for(const r in n){const o=n[r],a=Ue.get(parseInt(r));if(o.attrType==="Skin"){const c=this.parseSkeleton(a,n);c.ID=r,a.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),c.geometryID=a.parents[0].ID,e[r]=c}else if(o.attrType==="BlendShape"){const c={id:r};c.rawTargets=this.parseMorphTargets(a,n),c.id=r,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=c}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(r){const o=t[r.ID];if(o.attrType!=="Cluster")return;const a={ID:r.ID,indices:[],weights:[],transformLink:new p.Matrix4().fromArray(o.TransformLink.a)};"Indexes"in o&&(a.indices=o.Indexes.a,a.weights=o.Weights.a),n.push(a)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const o=e.children[r],a=t[o.ID],c={name:a.attrName,initialWeight:a.DeformPercent,id:a.id,fullWeights:a.FullWeights.a};if(a.attrType!=="BlendShapeChannel")return;c.geoID=Ue.get(parseInt(o.ID)).children.filter(function(u){return u.relationship===void 0})[0].ID,n.push(c)}return n}parseScene(e,t,n){bt=new p.Group;const r=this.parseModels(e.skeletons,t,n),o=ve.Objects.Model,a=this;r.forEach(function(u){const d=o[u.ID];a.setLookAtProperties(u,d),Ue.get(u.ID).parents.forEach(function(f){const g=r.get(f.ID);g!==void 0&&g.add(u)}),u.parent===null&&bt.add(u)}),this.bindSkeleton(e.skeletons,t,r),this.createAmbientLight(),bt.traverse(function(u){if(u.userData.transformData){u.parent&&(u.userData.transformData.parentMatrix=u.parent.matrix,u.userData.transformData.parentMatrixWorld=u.parent.matrixWorld);const d=ic(u.userData.transformData);u.applyMatrix4(d),u.updateWorldMatrix()}});const c=new Kp().parse();bt.children.length===1&&bt.children[0].isGroup&&(bt.children[0].animations=c,bt=bt.children[0]),bt.animations=c}parseModels(e,t,n){const r=new Map,o=ve.Objects.Model;for(const a in o){const c=parseInt(a),u=o[a],d=Ue.get(c);let m=this.buildSkeleton(d,e,c,u.attrName);if(!m){switch(u.attrType){case"Camera":m=this.createCamera(d);break;case"Light":m=this.createLight(d);break;case"Mesh":m=this.createMesh(d,t,n);break;case"NurbsCurve":m=this.createCurve(d,t);break;case"LimbNode":case"Root":m=new p.Bone;break;case"Null":default:m=new p.Group;break}m.name=u.attrName?p.PropertyBinding.sanitizeNodeName(u.attrName):"",m.ID=c}this.getTransformData(m,u),r.set(c,m)}return r}buildSkeleton(e,t,n,r){let o=null;return e.parents.forEach(function(a){for(const c in t){const u=t[c];u.rawBones.forEach(function(d,m){if(d.ID===a.ID){const f=o;o=new p.Bone,o.matrixWorld.copy(d.transformLink),o.name=r?p.PropertyBinding.sanitizeNodeName(r):"",o.ID=n,u.bones[m]=o,f!==null&&o.add(f)}})}}),o}createCamera(e){let t,n;if(e.children.forEach(function(r){const o=ve.Objects.NodeAttribute[r.ID];o!==void 0&&(n=o)}),n===void 0)t=new p.Object3D;else{let r=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(r=1);let o=1;n.NearPlane!==void 0&&(o=n.NearPlane.value/1e3);let a=1e3;n.FarPlane!==void 0&&(a=n.FarPlane.value/1e3);let c=window.innerWidth,u=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(c=n.AspectWidth.value,u=n.AspectHeight.value);const d=c/u;let m=45;n.FieldOfView!==void 0&&(m=n.FieldOfView.value);const f=n.FocalLength?n.FocalLength.value:null;switch(r){case 0:t=new p.PerspectiveCamera(m,d,o,a),f!==null&&t.setFocalLength(f);break;case 1:t=new p.OrthographicCamera(-c/2,c/2,u/2,-u/2,o,a);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+r+"."),t=new p.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(r){const o=ve.Objects.NodeAttribute[r.ID];o!==void 0&&(n=o)}),n===void 0)t=new p.Object3D;else{let r;n.LightType===void 0?r=0:r=n.LightType.value;let o=16777215;n.Color!==void 0&&(o=new p.Color().fromArray(n.Color.value));let a=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(a=0);let c=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?c=0:c=n.FarAttenuationEnd.value);const u=1;switch(r){case 0:t=new p.PointLight(o,a,c,u);break;case 1:t=new p.DirectionalLight(o,a);break;case 2:let d=Math.PI/3;n.InnerAngle!==void 0&&(d=p.MathUtils.degToRad(n.InnerAngle.value));let m=0;n.OuterAngle!==void 0&&(m=p.MathUtils.degToRad(n.OuterAngle.value),m=Math.max(m,1)),t=new p.SpotLight(o,a,c,d,m,u);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new p.PointLight(o,a);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,o=null,a=null;const c=[];return e.children.forEach(function(u){t.has(u.ID)&&(o=t.get(u.ID)),n.has(u.ID)&&c.push(n.get(u.ID))}),c.length>1?a=c:c.length>0?a=c[0]:(a=new p.MeshPhongMaterial({color:13421772}),c.push(a)),"color"in o.attributes&&c.forEach(function(u){u.vertexColors=!0}),o.FBX_Deformer?(r=new p.SkinnedMesh(o,a),r.normalizeSkinWeights()):r=new p.Mesh(o,a),r}createCurve(e,t){const n=e.children.reduce(function(o,a){return t.has(a.ID)&&(o=t.get(a.ID)),o},null),r=new p.LineBasicMaterial({color:3342591,linewidth:1});return new p.Line(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=sc(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Ue.get(e.ID).children.forEach(function(r){if(r.relationship==="LookAtProperty"){const o=ve.Objects.Model[r.ID];if("Lcl_Translation"in o){const a=o.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(a),bt.add(e.target)):e.lookAt(new p.Vector3().fromArray(a))}}})}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const o in e){const a=e[o];Ue.get(parseInt(a.ID)).parents.forEach(function(u){if(t.has(u.ID)){const d=u.ID;Ue.get(d).parents.forEach(function(f){n.has(f.ID)&&n.get(f.ID).bind(new p.Skeleton(a.bones),r[f.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in ve.Objects){const t=ve.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach(function(o){e[o.Node]=new p.Matrix4().fromArray(o.Matrix.a)}):e[r.Node]=new p.Matrix4().fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in ve&&"AmbientColor"in ve.GlobalSettings){const e=ve.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(t!==0||n!==0||r!==0){const o=new p.Color(t,n,r);bt.add(new p.AmbientLight(o,1))}}}}class kp{parse(e){const t=new Map;if("Geometry"in ve.Objects){const n=ve.Objects.Geometry;for(const r in n){const o=Ue.get(parseInt(r)),a=this.parseGeometry(o,n[r],e);t.set(parseInt(r),a)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,o=[],a=e.parents.map(function(f){return ve.Objects.Model[f.ID]});if(a.length===0)return;const c=e.children.reduce(function(f,g){return r[g.ID]!==void 0&&(f=r[g.ID]),f},null);e.children.forEach(function(f){n.morphTargets[f.ID]!==void 0&&o.push(n.morphTargets[f.ID])});const u=a[0],d={};"RotationOrder"in u&&(d.eulerOrder=sc(u.RotationOrder.value)),"InheritType"in u&&(d.inheritType=parseInt(u.InheritType.value)),"GeometricTranslation"in u&&(d.translation=u.GeometricTranslation.value),"GeometricRotation"in u&&(d.rotation=u.GeometricRotation.value),"GeometricScaling"in u&&(d.scale=u.GeometricScaling.value);const m=ic(d);return this.genGeometry(t,c,o,m)}genGeometry(e,t,n,r){const o=new p.BufferGeometry;e.attrName&&(o.name=e.attrName);const a=this.parseGeoNode(e,t),c=this.genBuffers(a),u=new p.Float32BufferAttribute(c.vertex,3);if(u.applyMatrix4(r),o.setAttribute("position",u),c.colors.length>0&&o.setAttribute("color",new p.Float32BufferAttribute(c.colors,3)),t&&(o.setAttribute("skinIndex",new p.Uint16BufferAttribute(c.weightsIndices,4)),o.setAttribute("skinWeight",new p.Float32BufferAttribute(c.vertexWeights,4)),o.FBX_Deformer=t),c.normal.length>0){const d=new p.Matrix3().getNormalMatrix(r),m=new p.Float32BufferAttribute(c.normal,3);m.applyNormalMatrix(d),o.setAttribute("normal",m)}if(c.uvs.forEach(function(d,m){vo==="uv2"&&m++;const f=m===0?"uv":`uv${m}`;o.setAttribute(f,new p.Float32BufferAttribute(c.uvs[m],2))}),a.material&&a.material.mappingType!=="AllSame"){let d=c.materialIndex[0],m=0;if(c.materialIndex.forEach(function(f,g){f!==d&&(o.addGroup(m,g-m,d),d=f,m=g)}),o.groups.length>0){const f=o.groups[o.groups.length-1],g=f.start+f.count;g!==c.materialIndex.length&&o.addGroup(g,c.materialIndex.length-g,d)}o.groups.length===0&&o.addGroup(0,c.materialIndex.length,c.materialIndex[0])}return this.addMorphTargets(o,e,n,r),o}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let r=0;for(;e.LayerElementUV[r];)e.LayerElementUV[r].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[r])),r++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(r,o){r.indices.forEach(function(a,c){n.weightTable[a]===void 0&&(n.weightTable[a]=[]),n.weightTable[a].push({id:o,weight:r.weights[c]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,o=!1,a=[],c=[],u=[],d=[],m=[],f=[];const g=this;return e.vertexIndices.forEach(function(_,w){let b,x=!1;_<0&&(_=_^-1,x=!0);let L=[],M=[];if(a.push(_*3,_*3+1,_*3+2),e.color){const C=ts(w,n,_,e.color);u.push(C[0],C[1],C[2])}if(e.skeleton){if(e.weightTable[_]!==void 0&&e.weightTable[_].forEach(function(C){M.push(C.weight),L.push(C.id)}),M.length>4){o||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),o=!0);const C=[0,0,0,0],Z=[0,0,0,0];M.forEach(function(z,D){let X=z,I=L[D];Z.forEach(function(K,V,G){if(X>K){G[V]=X,X=K;const k=C[V];C[V]=I,I=k}})}),L=C,M=Z}for(;M.length<4;)M.push(0),L.push(0);for(let C=0;C<4;++C)m.push(M[C]),f.push(L[C])}if(e.normal){const C=ts(w,n,_,e.normal);c.push(C[0],C[1],C[2])}e.material&&e.material.mappingType!=="AllSame"&&(b=ts(w,n,_,e.material)[0]),e.uv&&e.uv.forEach(function(C,Z){const z=ts(w,n,_,C);d[Z]===void 0&&(d[Z]=[]),d[Z].push(z[0]),d[Z].push(z[1])}),r++,x&&(g.genFace(t,e,a,b,c,u,d,m,f,r),n++,r=0,a=[],c=[],u=[],d=[],m=[],f=[])}),t}genFace(e,t,n,r,o,a,c,u,d,m){for(let f=2;f<m;f++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(f-1)*3]]),e.vertex.push(t.vertexPositions[n[(f-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(f-1)*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),t.skeleton&&(e.vertexWeights.push(u[0]),e.vertexWeights.push(u[1]),e.vertexWeights.push(u[2]),e.vertexWeights.push(u[3]),e.vertexWeights.push(u[(f-1)*4]),e.vertexWeights.push(u[(f-1)*4+1]),e.vertexWeights.push(u[(f-1)*4+2]),e.vertexWeights.push(u[(f-1)*4+3]),e.vertexWeights.push(u[f*4]),e.vertexWeights.push(u[f*4+1]),e.vertexWeights.push(u[f*4+2]),e.vertexWeights.push(u[f*4+3]),e.weightsIndices.push(d[0]),e.weightsIndices.push(d[1]),e.weightsIndices.push(d[2]),e.weightsIndices.push(d[3]),e.weightsIndices.push(d[(f-1)*4]),e.weightsIndices.push(d[(f-1)*4+1]),e.weightsIndices.push(d[(f-1)*4+2]),e.weightsIndices.push(d[(f-1)*4+3]),e.weightsIndices.push(d[f*4]),e.weightsIndices.push(d[f*4+1]),e.weightsIndices.push(d[f*4+2]),e.weightsIndices.push(d[f*4+3])),t.color&&(e.colors.push(a[0]),e.colors.push(a[1]),e.colors.push(a[2]),e.colors.push(a[(f-1)*3]),e.colors.push(a[(f-1)*3+1]),e.colors.push(a[(f-1)*3+2]),e.colors.push(a[f*3]),e.colors.push(a[f*3+1]),e.colors.push(a[f*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(o[0]),e.normal.push(o[1]),e.normal.push(o[2]),e.normal.push(o[(f-1)*3]),e.normal.push(o[(f-1)*3+1]),e.normal.push(o[(f-1)*3+2]),e.normal.push(o[f*3]),e.normal.push(o[f*3+1]),e.normal.push(o[f*3+2])),t.uv&&t.uv.forEach(function(g,_){e.uvs[_]===void 0&&(e.uvs[_]=[]),e.uvs[_].push(c[_][0]),e.uvs[_].push(c[_][1]),e.uvs[_].push(c[_][(f-1)*2]),e.uvs[_].push(c[_][(f-1)*2+1]),e.uvs[_].push(c[_][f*2]),e.uvs[_].push(c[_][f*2+1])})}addMorphTargets(e,t,n,r){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const o=this;n.forEach(function(a){a.rawTargets.forEach(function(c){const u=ve.Objects.Geometry[c.geoID];u!==void 0&&o.genMorphGeometry(e,t,u,r,c.name)})})}genMorphGeometry(e,t,n,r,o){const a=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],c=n.Vertices!==void 0?n.Vertices.a:[],u=n.Indexes!==void 0?n.Indexes.a:[],d=e.attributes.position.count*3,m=new Float32Array(d);for(let w=0;w<u.length;w++){const b=u[w]*3;m[b]=c[w*3],m[b+1]=c[w*3+1],m[b+2]=c[w*3+2]}const f={vertexIndices:a,vertexPositions:m},g=this.genBuffers(f),_=new p.Float32BufferAttribute(g.vertex,3);_.name=o||n.attrName,_.applyMatrix4(r),e.morphAttributes.position.push(_)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let o=[];return n==="IndexToDirect"&&("NormalIndex"in e?o=e.NormalIndex.a:"NormalsIndex"in e&&(o=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:o,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let o=[];return n==="IndexToDirect"&&(o=e.UVIndex.a),{dataSize:2,buffer:r,indices:o,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let o=[];return n==="IndexToDirect"&&(o=e.ColorIndex.a),{dataSize:4,buffer:r,indices:o,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,o=[];for(let a=0;a<r.length;++a)o.push(a);return{dataSize:1,buffer:r,indices:o,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(ec===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new p.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new p.BufferGeometry;const n=t-1,r=e.KnotVector.a,o=[],a=e.Points.a;for(let f=0,g=a.length;f<g;f+=4)o.push(new p.Vector4().fromArray(a,f));let c,u;if(e.Form==="Closed")o.push(o[0]);else if(e.Form==="Periodic"){c=n,u=r.length-1-c;for(let f=0;f<n;++f)o.push(o[f])}const m=new ec(n,r,o,c,u).getPoints(o.length*12);return new p.BufferGeometry().setFromPoints(m)}}class Kp{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const r=t[n],o=this.addClip(r);e.push(o)}return e}parseClips(){if(ve.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=ve.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){const o={id:r.id,attr:r.attrName,curves:{}};t.set(o.id,o)}}return t}parseAnimationCurves(e){const t=ve.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(jp),values:t[n].KeyValueFloat.a},o=Ue.get(r.id);if(o!==void 0){const a=o.parents[0].ID,c=o.parents[0].relationship;c.match(/X/)?e.get(a).curves.x=r:c.match(/Y/)?e.get(a).curves.y=r:c.match(/Z/)?e.get(a).curves.z=r:c.match(/d|DeformPercent/)&&e.has(a)&&(e.get(a).curves.morph=r)}}}parseAnimationLayers(e){const t=ve.Objects.AnimationLayer,n=new Map;for(const r in t){const o=[],a=Ue.get(parseInt(r));a!==void 0&&(a.children.forEach(function(u,d){if(e.has(u.ID)){const m=e.get(u.ID);if(m.curves.x!==void 0||m.curves.y!==void 0||m.curves.z!==void 0){if(o[d]===void 0){const f=Ue.get(u.ID).parents.filter(function(g){return g.relationship!==void 0})[0].ID;if(f!==void 0){const g=ve.Objects.Model[f.toString()];if(g===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",u);return}const _={modelName:g.attrName?p.PropertyBinding.sanitizeNodeName(g.attrName):"",ID:g.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};bt.traverse(function(w){w.ID===g.id&&(_.transform=w.matrix,w.userData.transformData&&(_.eulerOrder=w.userData.transformData.eulerOrder))}),_.transform||(_.transform=new p.Matrix4),"PreRotation"in g&&(_.preRotation=g.PreRotation.value),"PostRotation"in g&&(_.postRotation=g.PostRotation.value),o[d]=_}}o[d]&&(o[d][m.attr]=m)}else if(m.curves.morph!==void 0){if(o[d]===void 0){const f=Ue.get(u.ID).parents.filter(function(L){return L.relationship!==void 0})[0].ID,g=Ue.get(f).parents[0].ID,_=Ue.get(g).parents[0].ID,w=Ue.get(_).parents[0].ID,b=ve.Objects.Model[w],x={modelName:b.attrName?p.PropertyBinding.sanitizeNodeName(b.attrName):"",morphName:ve.Objects.Deformer[f].attrName};o[d]=x}o[d][m.attr]=m}}}),n.set(parseInt(r),o))}return n}parseAnimStacks(e){const t=ve.Objects.AnimationStack,n={};for(const r in t){const o=Ue.get(parseInt(r)).children;o.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const a=e.get(o[0].ID);n[r]={name:t[r].attrName,layer:a}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(r){t=t.concat(n.generateTracks(r))}),new p.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new p.Vector3,r=new p.Quaternion,o=new p.Vector3;if(e.transform&&e.transform.decompose(n,r,o),n=n.toArray(),r=new p.Euler().setFromQuaternion(r,e.eulerOrder).toArray(),o=o.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const a=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");a!==void 0&&t.push(a)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const a=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);a!==void 0&&t.push(a)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const a=this.generateVectorTrack(e.modelName,e.S.curves,o,"scale");a!==void 0&&t.push(a)}if(e.DeformPercent!==void 0){const a=this.generateMorphTrack(e);a!==void 0&&t.push(a)}return t}generateVectorTrack(e,t,n,r){const o=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(o,t,n);return new p.VectorKeyframeTrack(e+"."+r,o,a)}generateRotationTrack(e,t,n,r,o,a){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(p.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(p.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(p.MathUtils.degToRad));const c=this.getTimesForAllAxes(t),u=this.getKeyframeTrackValues(c,t,n);r!==void 0&&(r=r.map(p.MathUtils.degToRad),r.push(a),r=new p.Euler().fromArray(r),r=new p.Quaternion().setFromEuler(r)),o!==void 0&&(o=o.map(p.MathUtils.degToRad),o.push(a),o=new p.Euler().fromArray(o),o=new p.Quaternion().setFromEuler(o).invert());const d=new p.Quaternion,m=new p.Euler,f=[];for(let g=0;g<u.length;g+=3)m.set(u[g],u[g+1],u[g+2],a),d.setFromEuler(m),r!==void 0&&d.premultiply(r),o!==void 0&&d.multiply(o),d.toArray(f,g/3*4);return new p.QuaternionKeyframeTrack(e+".quaternion",c,f)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(o){return o/100}),r=bt.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new p.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,r){return n-r}),t.length>1){let n=1,r=t[0];for(let o=1;o<t.length;o++){const a=t[o];a!==r&&(t[n]=a,r=a,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const r=n,o=[];let a=-1,c=-1,u=-1;return e.forEach(function(d){if(t.x&&(a=t.x.times.indexOf(d)),t.y&&(c=t.y.times.indexOf(d)),t.z&&(u=t.z.times.indexOf(d)),a!==-1){const m=t.x.values[a];o.push(m),r[0]=m}else o.push(r[0]);if(c!==-1){const m=t.y.values[c];o.push(m),r[1]=m}else o.push(r[1]);if(u!==-1){const m=t.z.values[u];o.push(m),r[2]=m}else o.push(r[2])}),o}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],r=e.values[t]-n,o=Math.abs(r);if(o>=180){const a=o/180,c=r/a;let u=n+c;const d=e.times[t-1],f=(e.times[t]-d)/a;let g=d+f;const _=[],w=[];for(;g<e.times[t];)_.push(g),g+=f,w.push(u),u+=c;e.times=ac(e.times,t,_),e.values=ac(e.values,t,w)}}}}class Np{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new nc,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(r,o){const a=r.match(/^[\s\t]*;/),c=r.match(/^[\s\t]*$/);if(a||c)return;const u=r.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),d=r.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),m=r.match("^\\t{"+(t.currentIndent-1)+"}}");u?t.parseNodeBegin(r,u):d?t.parseNodeProperty(r,d,n[++o]):m?t.popStack():r.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(r)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map(function(u){return u.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:n},a=this.parseNodeAttr(r),c=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,o):n in c?(n==="PoseNode"?c.PoseNode.push(o):c[n].id!==void 0&&(c[n]={},c[n][c[n].id]=c[n]),a.id!==""&&(c[n][a.id]=o)):typeof a.id=="number"?(c[n]={},c[n][a.id]=o):n!=="Properties70"&&(n==="PoseNode"?c[n]=[o]:c[n]=o),typeof a.id=="number"&&(o.id=a.id),a.name!==""&&(o.attrName=a.name),a.type!==""&&(o.attrType=a.type),this.pushStack(o)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();r==="Content"&&o===","&&(o=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if(a.name==="Properties70"){this.parseNodeSpecialProperty(e,r,o);return}if(r==="C"){const u=o.split(",").slice(1),d=parseInt(u[0]),m=parseInt(u[1]);let f=o.split(",").slice(3);f=f.map(function(g){return g.trim().replace(/^"/,"")}),r="connections",o=[d,m],Qp(o,f),a[r]===void 0&&(a[r]=[])}r==="Node"&&(a.id=o),r in a&&Array.isArray(a[r])?a[r].push(o):r!=="a"?a[r]=o:a.a=o,this.setCurrentProp(a,r),r==="a"&&o.slice(-1)!==","&&(a.a=Vo(o))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Vo(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(m){return m.trim().replace(/^\"/,"").replace(/\s/,"_")}),o=r[0],a=r[1],c=r[2],u=r[3];let d=r[4];switch(a){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":d=parseFloat(d);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":d=Vo(d);break}this.getPrevNode()[o]={type:a,type2:c,flag:u,value:d},this.setCurrentProp(this.getPrevNode(),o)}}class Bp{parse(e){const t=new tc(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new nc;for(;!this.endOfContent(t);){const o=this.parseNode(t,n);o!==null&&r.add(o.name,o)}return r}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),o=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const a=e.getUint8(),c=e.getString(a);if(r===0)return null;const u=[];for(let g=0;g<o;g++)u.push(this.parseProperty(e));const d=u.length>0?u[0]:"",m=u.length>1?u[1]:"",f=u.length>2?u[2]:"";for(n.singleProperty=o===1&&e.getOffset()===r;r>e.getOffset();){const g=this.parseNode(e,t);g!==null&&this.parseSubNode(c,n,g)}return n.propertyList=u,typeof d=="number"&&(n.id=d),m!==""&&(n.attrName=m),f!==""&&(n.attrType=f),c!==""&&(n.name=c),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const r=n.propertyList[0];Array.isArray(r)?(t[n.name]=n,n.a=r):t[n.name]=r}else if(e==="Connections"&&n.name==="C"){const r=[];n.propertyList.forEach(function(o,a){a!==0&&r.push(o)}),t.connections===void 0&&(t.connections=[]),t.connections.push(r)}else if(n.name==="Properties70")Object.keys(n).forEach(function(o){t[o]=n[o]});else if(e==="Properties70"&&n.name==="P"){let r=n.propertyList[0],o=n.propertyList[1];const a=n.propertyList[2],c=n.propertyList[3];let u;r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),o.indexOf("Lcl ")===0&&(o=o.replace("Lcl ","Lcl_")),o==="Color"||o==="ColorRGB"||o==="Vector"||o==="Vector3D"||o.indexOf("Lcl_")===0?u=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:u=n.propertyList[4],t[r]={type:o,type2:a,flag:c,value:u}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),o=e.getUint32(),a=e.getUint32();if(o===0)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}const c=wf(new Uint8Array(e.getArrayBuffer(a))),u=new tc(c.buffer);switch(t){case"b":case"c":return u.getBooleanArray(r);case"d":return u.getFloat64Array(r);case"f":return u.getFloat32Array(r);case"i":return u.getInt32Array(r);case"l":return u.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class tc{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let r=0;r<e;r++)t[r]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Dr(new Uint8Array(t))}}class nc{add(e,t){this[e]=t}}function Yp(i){const e="Kaydara FBX Binary \0";return i.byteLength>=e.length&&e===oc(i,0,e.length)}function Rp(i){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(r){const o=i[r-1];return i=i.slice(t+r),t++,o}for(let r=0;r<e.length;++r)if(n(1)===e[r])return!1;return!0}function rc(i){const e=/FBXVersion: (\d+)/,t=i.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function jp(i){return i/46186158e3}const Jp=[];function ts(i,e,t,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=i;break;case"ByPolygon":r=e;break;case"ByVertice":r=t;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(r=n.indices[r]);const o=r*n.dataSize,a=o+n.dataSize;return Hp(Jp,n.buffer,o,a)}const Wo=new p.Euler,Xr=new p.Vector3;function ic(i){const e=new p.Matrix4,t=new p.Matrix4,n=new p.Matrix4,r=new p.Matrix4,o=new p.Matrix4,a=new p.Matrix4,c=new p.Matrix4,u=new p.Matrix4,d=new p.Matrix4,m=new p.Matrix4,f=new p.Matrix4,g=new p.Matrix4,_=i.inheritType?i.inheritType:0;if(i.translation&&e.setPosition(Xr.fromArray(i.translation)),i.preRotation){const V=i.preRotation.map(p.MathUtils.degToRad);V.push(i.eulerOrder),t.makeRotationFromEuler(Wo.fromArray(V))}if(i.rotation){const V=i.rotation.map(p.MathUtils.degToRad);V.push(i.eulerOrder),n.makeRotationFromEuler(Wo.fromArray(V))}if(i.postRotation){const V=i.postRotation.map(p.MathUtils.degToRad);V.push(i.eulerOrder),r.makeRotationFromEuler(Wo.fromArray(V)),r.invert()}i.scale&&o.scale(Xr.fromArray(i.scale)),i.scalingOffset&&c.setPosition(Xr.fromArray(i.scalingOffset)),i.scalingPivot&&a.setPosition(Xr.fromArray(i.scalingPivot)),i.rotationOffset&&u.setPosition(Xr.fromArray(i.rotationOffset)),i.rotationPivot&&d.setPosition(Xr.fromArray(i.rotationPivot)),i.parentMatrixWorld&&(f.copy(i.parentMatrix),m.copy(i.parentMatrixWorld));const w=t.clone().multiply(n).multiply(r),b=new p.Matrix4;b.extractRotation(m);const x=new p.Matrix4;x.copyPosition(m);const L=x.clone().invert().multiply(m),M=b.clone().invert().multiply(L),C=o,Z=new p.Matrix4;if(_===0)Z.copy(b).multiply(w).multiply(M).multiply(C);else if(_===1)Z.copy(b).multiply(M).multiply(w).multiply(C);else{const G=new p.Matrix4().scale(new p.Vector3().setFromMatrixScale(f)).clone().invert(),k=M.clone().multiply(G);Z.copy(b).multiply(w).multiply(k).multiply(C)}const z=d.clone().invert(),D=a.clone().invert();let X=e.clone().multiply(u).multiply(d).multiply(t).multiply(n).multiply(r).multiply(z).multiply(c).multiply(a).multiply(o).multiply(D);const I=new p.Matrix4().copyPosition(X),K=m.clone().multiply(I);return g.copyPosition(K),X=g.clone().multiply(Z),X.premultiply(m.invert()),X}function sc(i){i=i||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return i===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[i]}function Vo(i){return i.split(",").map(function(t){return parseFloat(t)})}function oc(i,e,t){return e===void 0&&(e=0),t===void 0&&(t=i.byteLength),Dr(new Uint8Array(i,e,t))}function Qp(i,e){for(let t=0,n=i.length,r=e.length;t<r;t++,n++)i[n]=e[t]}function Hp(i,e,t,n){for(let r=t,o=0;r<n;r++,o++)i[o]=e[r];return i}function ac(i,e,t){return i.slice(0,e).concat(t).concat(i.slice(e))}class Ep extends p.DataTextureLoader{constructor(e){super(e),this.type=p.HalfFloatType}parse(e){const a=function(I,K){switch(I){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(K||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(K||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(K||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(K||""))}},m=`
208
+ `,f=function(I,K,V){K=K||1024;let k=I.pos,j=-1,Y=0,H="",Q=String.fromCharCode.apply(null,new Uint16Array(I.subarray(k,k+128)));for(;0>(j=Q.indexOf(m))&&Y<K&&k<I.byteLength;)H+=Q,Y+=Q.length,k+=128,Q+=String.fromCharCode.apply(null,new Uint16Array(I.subarray(k,k+128)));return-1<j?(I.pos+=Y+j+1,H+Q.slice(0,j)):!1},g=function(I){const K=/^#\?(\S+)/,V=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,G=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,k=/^\s*FORMAT=(\S+)\s*$/,j=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,Y={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let H,Q;for((I.pos>=I.byteLength||!(H=f(I)))&&a(1,"no header found"),(Q=H.match(K))||a(3,"bad initial token"),Y.valid|=1,Y.programtype=Q[1],Y.string+=H+`
209
+ `;H=f(I),H!==!1;){if(Y.string+=H+`
210
+ `,H.charAt(0)==="#"){Y.comments+=H+`
211
+ `;continue}if((Q=H.match(V))&&(Y.gamma=parseFloat(Q[1])),(Q=H.match(G))&&(Y.exposure=parseFloat(Q[1])),(Q=H.match(k))&&(Y.valid|=2,Y.format=Q[1]),(Q=H.match(j))&&(Y.valid|=4,Y.height=parseInt(Q[1],10),Y.width=parseInt(Q[2],10)),Y.valid&2&&Y.valid&4)break}return Y.valid&2||a(3,"missing format specifier"),Y.valid&4||a(3,"missing image size specifier"),Y},_=function(I,K,V){const G=K;if(G<8||G>32767||I[0]!==2||I[1]!==2||I[2]&128)return new Uint8Array(I);G!==(I[2]<<8|I[3])&&a(3,"wrong scanline width");const k=new Uint8Array(4*K*V);k.length||a(4,"unable to allocate buffer space");let j=0,Y=0;const H=4*G,Q=new Uint8Array(4),ie=new Uint8Array(H);let re=V;for(;re>0&&Y<I.byteLength;){Y+4>I.byteLength&&a(1),Q[0]=I[Y++],Q[1]=I[Y++],Q[2]=I[Y++],Q[3]=I[Y++],(Q[0]!=2||Q[1]!=2||(Q[2]<<8|Q[3])!=G)&&a(3,"bad rgbe scanline format");let le=0,de;for(;le<H&&Y<I.byteLength;){de=I[Y++];const fe=de>128;if(fe&&(de-=128),(de===0||le+de>H)&&a(3,"bad scanline data"),fe){const Se=I[Y++];for(let rt=0;rt<de;rt++)ie[le++]=Se}else ie.set(I.subarray(Y,Y+de),le),le+=de,Y+=de}const ge=G;for(let fe=0;fe<ge;fe++){let Se=0;k[j]=ie[fe+Se],Se+=G,k[j+1]=ie[fe+Se],Se+=G,k[j+2]=ie[fe+Se],Se+=G,k[j+3]=ie[fe+Se],j+=4}re--}return k},w=function(I,K,V,G){const k=I[K+3],j=Math.pow(2,k-128)/255;V[G+0]=I[K+0]*j,V[G+1]=I[K+1]*j,V[G+2]=I[K+2]*j,V[G+3]=1},b=function(I,K,V,G){const k=I[K+3],j=Math.pow(2,k-128)/255;V[G+0]=p.DataUtils.toHalfFloat(Math.min(I[K+0]*j,65504)),V[G+1]=p.DataUtils.toHalfFloat(Math.min(I[K+1]*j,65504)),V[G+2]=p.DataUtils.toHalfFloat(Math.min(I[K+2]*j,65504)),V[G+3]=p.DataUtils.toHalfFloat(1)},x=new Uint8Array(e);x.pos=0;const L=g(x),M=L.width,C=L.height,Z=_(x.subarray(x.pos),M,C);let z,D,X;switch(this.type){case p.FloatType:X=Z.length/4;const I=new Float32Array(X*4);for(let V=0;V<X;V++)w(Z,V*4,I,V*4);z=I,D=p.FloatType;break;case p.HalfFloatType:X=Z.length/4;const K=new Uint16Array(X*4);for(let V=0;V<X;V++)b(Z,V*4,K,V*4);z=K,D=p.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:M,height:C,data:z,header:L.string,gamma:L.gamma,exposure:L.exposure,type:D}}setDataType(e){return this.type=e,this}load(e,t,n,r){function o(a,c){switch(a.type){case p.FloatType:case p.HalfFloatType:"colorSpace"in a?a.colorSpace="srgb-linear":a.encoding=3e3,a.minFilter=p.LinearFilter,a.magFilter=p.LinearFilter,a.generateMipmaps=!1,a.flipY=!0;break}t&&t(a,c)}return super.load(e,o,n,r)}}const Io=new WeakMap;class $p extends p.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const o=new p.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,a=>{const c={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(a,c).then(t).catch(r)},n,r)}decodeDracoFile(e,t,n,r){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,o).then(t)}decodeGeometry(e,t){for(const u in t.attributeTypes){const d=t.attributeTypes[u];d.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[u]=d.name)}const n=JSON.stringify(t);if(Io.has(e)){const u=Io.get(e);if(u.key===n)return u.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const o=this.workerNextTaskID++,a=e.byteLength,c=this._getWorker(o,a).then(u=>(r=u,new Promise((d,m)=>{r._callbacks[o]={resolve:d,reject:m},r.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(u=>this._createGeometry(u.geometry));return c.catch(()=>!0).then(()=>{r&&o&&this._releaseTask(r,o)}),Io.set(e,{key:n,promise:c}),c}_createGeometry(e){const t=new p.BufferGeometry;e.index&&t.setIndex(new p.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],o=r.name,a=r.array,c=r.itemSize;t.setAttribute(o,new p.BufferAttribute(a,c))}return t}_loadLibrary(e,t){const n=new p.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((r,o)=>{n.load(e,r,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const r=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=qp.toString(),a=["/* draco decoder */",r,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
212
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(o){const a=o.data;switch(a.type){case"decode":r._callbacks[a.id].resolve(a);break;case"error":r._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,o){return r._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function qp(){let i,e;onmessage=function(a){const c=a.data;switch(c.type){case"init":i=c.decoderConfig,e=new Promise(function(m){i.onModuleLoaded=function(f){m({draco:f})},DracoDecoderModule(i)});break;case"decode":const u=c.buffer,d=c.taskConfig;e.then(m=>{const f=m.draco,g=new f.Decoder,_=new f.DecoderBuffer;_.Init(new Int8Array(u),u.byteLength);try{const w=t(f,g,_,d),b=w.attributes.map(x=>x.array.buffer);w.index&&b.push(w.index.array.buffer),self.postMessage({type:"decode",id:c.id,geometry:w},b)}catch(w){console.error(w),self.postMessage({type:"error",id:c.id,error:w.message})}finally{f.destroy(_),f.destroy(g)}});break}};function t(a,c,u,d){const m=d.attributeIDs,f=d.attributeTypes;let g,_;const w=c.GetEncodedGeometryType(u);if(w===a.TRIANGULAR_MESH)g=new a.Mesh,_=c.DecodeBufferToMesh(u,g);else if(w===a.POINT_CLOUD)g=new a.PointCloud,_=c.DecodeBufferToPointCloud(u,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!_.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+_.error_msg());const b={index:null,attributes:[]};for(const x in m){const L=self[f[x]];let M,C;if(d.useUniqueIDs)C=m[x],M=c.GetAttributeByUniqueId(g,C);else{if(C=c.GetAttributeId(g,a[m[x]]),C===-1)continue;M=c.GetAttribute(g,C)}b.attributes.push(r(a,c,g,x,L,M))}return w===a.TRIANGULAR_MESH&&(b.index=n(a,c,g)),a.destroy(g),b}function n(a,c,u){const m=u.num_faces()*3,f=m*4,g=a._malloc(f);c.GetTrianglesUInt32Array(u,f,g);const _=new Uint32Array(a.HEAPF32.buffer,g,m).slice();return a._free(g),{array:_,itemSize:1}}function r(a,c,u,d,m,f){const g=f.num_components(),w=u.num_points()*g,b=w*m.BYTES_PER_ELEMENT,x=o(a,m),L=a._malloc(b);c.GetAttributeDataArrayForAllPoints(u,f,x,b,L);const M=new m(a.HEAPF32.buffer,L,w).slice();return a._free(L),{name:d,array:M,itemSize:g}}function o(a,c){switch(c){case Float32Array:return a.DT_FLOAT32;case Int8Array:return a.DT_INT8;case Int16Array:return a.DT_INT16;case Int32Array:return a.DT_INT32;case Uint8Array:return a.DT_UINT8;case Uint16Array:return a.DT_UINT16;case Uint32Array:return a.DT_UINT32}}}const lc=new p.Box3,ns=new p.Vector3;class cc extends p.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new p.Float32BufferAttribute(e,3)),this.setAttribute("uv",new p.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new p.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new p.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new p.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e,t=3){let n;e instanceof Float32Array?n=e:Array.isArray(e)&&(n=new Float32Array(e));const r=new p.InstancedInterleavedBuffer(n,t*2,1);return this.setAttribute("instanceColorStart",new p.InterleavedBufferAttribute(r,t,0)),this.setAttribute("instanceColorEnd",new p.InterleavedBufferAttribute(r,t,t)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new p.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new p.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),lc.setFromBufferAttribute(t),this.boundingBox.union(lc))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new p.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let o=0,a=e.count;o<a;o++)ns.fromBufferAttribute(e,o),r=Math.max(r,n.distanceToSquared(ns)),ns.fromBufferAttribute(t,o),r=Math.max(r,n.distanceToSquared(ns));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}class rs extends cc{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e,t=3){const n=e.length-t,r=new Float32Array(2*n);if(t===3)for(let o=0;o<n;o+=t)r[2*o]=e[o],r[2*o+1]=e[o+1],r[2*o+2]=e[o+2],r[2*o+3]=e[o+3],r[2*o+4]=e[o+4],r[2*o+5]=e[o+5];else for(let o=0;o<n;o+=t)r[2*o]=e[o],r[2*o+1]=e[o+1],r[2*o+2]=e[o+2],r[2*o+3]=e[o+3],r[2*o+4]=e[o+4],r[2*o+5]=e[o+5],r[2*o+6]=e[o+6],r[2*o+7]=e[o+7];return super.setColors(r,t),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class mi extends p.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:p.UniformsUtils.clone(p.UniformsUtils.merge([p.UniformsLib.common,p.UniformsLib.fog,{worldUnits:{value:1},linewidth:{value:1},resolution:{value:new p.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}}])),vertexShader:`
103
213
  #include <common>
104
214
  #include <fog_pars_vertex>
105
215
  #include <logdepthbuf_pars_vertex>
@@ -502,78 +612,128 @@
502
612
  gl_FragColor = diffuseColor;
503
613
 
504
614
  #include <tonemapping_fragment>
505
- #include <${ot>=154?"colorspace_fragment":"encodings_fragment"}>
615
+ #include <${$i>=154?"colorspace_fragment":"encodings_fragment"}>
506
616
  #include <fog_fragment>
507
617
  #include <premultiplied_alpha_fragment>
508
618
 
509
619
  }
510
- `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(e){!!e!="USE_DASH"in this.defines&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(e){!!e!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}}const kt=new h.Vector4,Tn=new h.Vector3,Pn=new h.Vector3,$=new h.Vector4,ee=new h.Vector4,me=new h.Vector4,Dt=new h.Vector3,Ft=new h.Matrix4,te=new h.Line3,An=new h.Vector3,ht=new h.Box3,dt=new h.Sphere,ye=new h.Vector4;let ge,De;function Wn(o,t,e){return ye.set(0,0,-t,1).applyMatrix4(o.projectionMatrix),ye.multiplyScalar(1/ye.w),ye.x=De/e.width,ye.y=De/e.height,ye.applyMatrix4(o.projectionMatrixInverse),ye.multiplyScalar(1/ye.w),Math.abs(Math.max(ye.x,ye.y))}function ts(o,t){const e=o.matrixWorld,n=o.geometry,i=n.attributes.instanceStart,r=n.attributes.instanceEnd,s=Math.min(n.instanceCount,i.count);for(let a=0,l=s;a<l;a++){te.start.fromBufferAttribute(i,a),te.end.fromBufferAttribute(r,a),te.applyMatrix4(e);const u=new h.Vector3,d=new h.Vector3;ge.distanceSqToSegment(te.start,te.end,d,u),d.distanceTo(u)<De*.5&&t.push({point:d,pointOnLine:u,distance:ge.origin.distanceTo(d),object:o,face:null,faceIndex:a,uv:null,[Lt]:null})}}function ns(o,t,e){const n=t.projectionMatrix,r=o.material.resolution,s=o.matrixWorld,a=o.geometry,l=a.attributes.instanceStart,u=a.attributes.instanceEnd,d=Math.min(a.instanceCount,l.count),c=-t.near;ge.at(1,me),me.w=1,me.applyMatrix4(t.matrixWorldInverse),me.applyMatrix4(n),me.multiplyScalar(1/me.w),me.x*=r.x/2,me.y*=r.y/2,me.z=0,Dt.copy(me),Ft.multiplyMatrices(t.matrixWorldInverse,s);for(let p=0,f=d;p<f;p++){if($.fromBufferAttribute(l,p),ee.fromBufferAttribute(u,p),$.w=1,ee.w=1,$.applyMatrix4(Ft),ee.applyMatrix4(Ft),$.z>c&&ee.z>c)continue;if($.z>c){const w=$.z-ee.z,S=($.z-c)/w;$.lerp(ee,S)}else if(ee.z>c){const w=ee.z-$.z,S=(ee.z-c)/w;ee.lerp($,S)}$.applyMatrix4(n),ee.applyMatrix4(n),$.multiplyScalar(1/$.w),ee.multiplyScalar(1/ee.w),$.x*=r.x/2,$.y*=r.y/2,ee.x*=r.x/2,ee.y*=r.y/2,te.start.copy($),te.start.z=0,te.end.copy(ee),te.end.z=0;const v=te.closestPointToPointParameter(Dt,!0);te.at(v,An);const g=h.MathUtils.lerp($.z,ee.z,v),b=g>=-1&&g<=1,y=Dt.distanceTo(An)<De*.5;if(b&&y){te.start.fromBufferAttribute(l,p),te.end.fromBufferAttribute(u,p),te.start.applyMatrix4(s),te.end.applyMatrix4(s);const w=new h.Vector3,S=new h.Vector3;ge.distanceSqToSegment(te.start,te.end,S,w),e.push({point:S,pointOnLine:w,distance:ge.origin.distanceTo(S),object:o,face:null,faceIndex:p,uv:null,[Lt]:null})}}}class is extends h.Mesh{constructor(t=new In,e=new Je({color:Math.random()*16777215})){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const t=this.geometry,e=t.attributes.instanceStart,n=t.attributes.instanceEnd,i=new Float32Array(2*e.count);for(let s=0,a=0,l=e.count;s<l;s++,a+=2)Tn.fromBufferAttribute(e,s),Pn.fromBufferAttribute(n,s),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+Tn.distanceTo(Pn);const r=new h.InstancedInterleavedBuffer(i,2,1);return t.setAttribute("instanceDistanceStart",new h.InterleavedBufferAttribute(r,1,0)),t.setAttribute("instanceDistanceEnd",new h.InterleavedBufferAttribute(r,1,1)),this}raycast(t,e){const n=this.material.worldUnits,i=t.camera;i===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=t.params.Line2!==void 0&&t.params.Line2.threshold||0;ge=t.ray;const s=this.matrixWorld,a=this.geometry,l=this.material;De=l.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),dt.copy(a.boundingSphere).applyMatrix4(s);let u;if(n)u=De*.5;else{const c=Math.max(i.near,dt.distanceToPoint(ge.origin));u=Wn(i,c,l.resolution)}if(dt.radius+=u,ge.intersectsSphere(dt)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),ht.copy(a.boundingBox).applyMatrix4(s);let d;if(n)d=De*.5;else{const c=Math.max(i.near,ht.distanceToPoint(ge.origin));d=Wn(i,c,l.resolution)}ht.expandByScalar(d),ge.intersectsBox(ht)!==!1&&(n?ts(this,e):ns(this,i,e))}onBeforeRender(t){const e=this.material.uniforms;e&&e.resolution&&(t.getViewport(kt),this.material.uniforms.resolution.value.set(kt.z,kt.w))}}class Ot extends is{constructor(t=new ut,e=new Je({color:Math.random()*16777215})){super(t,e),this.isLine2=!0,this.type="Line2"}}var Ye=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return this.None(o)},Out:function(o){return this.None(o)},InOut:function(o){return this.None(o)}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var t=1.70158;return o===1?1:o*o*((t+1)*o-t)},Out:function(o){var t=1.70158;return o===0?0:--o*o*((t+1)*o+t)+1},InOut:function(o){var t=2.5949095;return(o*=2)<1?.5*(o*o*((t+1)*o-t)):.5*((o-=2)*o*((t+1)*o+t)+2)}}),Bounce:Object.freeze({In:function(o){return 1-Ye.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?Ye.Bounce.In(o*2)*.5:Ye.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(t){return Math.pow(t,o)},Out:function(t){return 1-Math.pow(1-t,o)},InOut:function(t){return t<.5?Math.pow(t*2,o)/2:(1-Math.pow(2-t*2,o))/2+.5}}}}),Qe=function(){return performance.now()},rs=function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map(function(e){return t._tweens[e]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},o.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},o.prototype.update=function(t,e){t===void 0&&(t=Qe()),e===void 0&&(e=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var r=this._tweens[n[i]],s=!e;r&&r.update(t,s)===!1&&!e&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},o}(),zt={Linear:function(o,t){var e=o.length-1,n=e*t,i=Math.floor(n),r=zt.Utils.Linear;return t<0?r(o[0],o[1],n):t>1?r(o[e],o[e-1],e-n):r(o[i],o[i+1>e?e:i+1],n-i)},Utils:{Linear:function(o,t,e){return(t-o)*e+o}}},Gn=function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o}(),Xt=new rs,Vn=function(){function o(t,e){e===void 0&&(e=Xt),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Ye.Linear.None,this._interpolationFunction=zt.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Gn.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.prototype.to=function(t,e){if(e===void 0&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e<0?0:e,this},o.prototype.duration=function(t){return t===void 0&&(t=1e3),this._duration=t<0?0:t,this},o.prototype.dynamic=function(t){return t===void 0&&(t=!1),this._isDynamic=t,this},o.prototype.start=function(t,e){if(t===void 0&&(t=Qe()),e===void 0&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var r in this._valuesEnd)i[r]=this._valuesEnd[r];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},o.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},o.prototype._setupProperties=function(t,e,n,i,r){for(var s in n){var a=t[s],l=Array.isArray(a),u=l?"array":typeof a,d=!l&&Array.isArray(n[s]);if(!(u==="undefined"||u==="function")){if(d){var c=n[s];if(c.length===0)continue;for(var p=[a],f=0,m=c.length;f<m;f+=1){var v=this._handleRelativeValue(a,c[f]);if(isNaN(v)){d=!1,console.warn("Found invalid interpolation list. Skipping.");break}p.push(v)}d&&(n[s]=p)}if((u==="object"||l)&&a&&!d){e[s]=l?[]:{};var g=a;for(var b in g)e[s][b]=g[b];i[s]=l?[]:{};var c=n[s];if(!this._isDynamic){var y={};for(var b in c)y[b]=c[b];n[s]=c=y}this._setupProperties(g,e[s],c,i[s],r)}else(typeof e[s]>"u"||r)&&(e[s]=a),l||(e[s]*=1),d?i[s]=n[s].slice().reverse():i[s]=e[s]||0}}},o.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(t){return t===void 0&&(t=Qe()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=t,this._group&&this._group.remove(this),this)},o.prototype.resume=function(t){return t===void 0&&(t=Qe()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=t-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var t=0,e=this._chainedTweens.length;t<e;t++)this._chainedTweens[t].stop();return this},o.prototype.group=function(t){return t===void 0&&(t=Xt),this._group=t,this},o.prototype.delay=function(t){return t===void 0&&(t=0),this._delayTime=t,this},o.prototype.repeat=function(t){return t===void 0&&(t=0),this._initialRepeat=t,this._repeat=t,this},o.prototype.repeatDelay=function(t){return this._repeatDelayTime=t,this},o.prototype.yoyo=function(t){return t===void 0&&(t=!1),this._yoyo=t,this},o.prototype.easing=function(t){return t===void 0&&(t=Ye.Linear.None),this._easingFunction=t,this},o.prototype.interpolation=function(t){return t===void 0&&(t=zt.Linear),this._interpolationFunction=t,this},o.prototype.chain=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return this._chainedTweens=t,this},o.prototype.onStart=function(t){return this._onStartCallback=t,this},o.prototype.onEveryStart=function(t){return this._onEveryStartCallback=t,this},o.prototype.onUpdate=function(t){return this._onUpdateCallback=t,this},o.prototype.onRepeat=function(t){return this._onRepeatCallback=t,this},o.prototype.onComplete=function(t){return this._onCompleteCallback=t,this},o.prototype.onStop=function(t){return this._onStopCallback=t,this},o.prototype.update=function(t,e){var n=this,i;if(t===void 0&&(t=Qe()),e===void 0&&(e=!0),this._isPaused)return!0;var r,s=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(t>s)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=t-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),u=this._duration+this._repeat*l,d=function(){if(n._duration===0||a>u)return 1;var g=Math.trunc(a/l),b=a-g*l,y=Math.min(b/n._duration,1);return y===0&&a===n._duration?1:y},c=d(),p=this._easingFunction(c);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,p),this._onUpdateCallback&&this._onUpdateCallback(this._object,c),this._duration===0||a>=this._duration)if(this._repeat>0){var f=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=f);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*f,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var m=0,v=this._chainedTweens.length;m<v;m++)this._chainedTweens[m].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(t,e,n,i){for(var r in n)if(e[r]!==void 0){var s=e[r]||0,a=n[r],l=Array.isArray(t[r]),u=Array.isArray(a),d=!l&&u;d?t[r]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(t[r],s,a,i):(a=this._handleRelativeValue(s,a),typeof a=="number"&&(t[r]=s+(a-s)*i))}},o.prototype._handleRelativeValue=function(t,e){return typeof e!="string"?e:e.charAt(0)==="+"||e.charAt(0)==="-"?t+parseFloat(e):parseFloat(e)},o.prototype._swapEndStartRepeatValues=function(t){var e=this._valuesStartRepeat[t],n=this._valuesEnd[t];typeof n=="string"?this._valuesStartRepeat[t]=this._valuesStartRepeat[t]+parseFloat(n):this._valuesStartRepeat[t]=this._valuesEnd[t],this._valuesEnd[t]=e},o}();Gn.nextId;var be=Xt;be.getAll.bind(be),be.removeAll.bind(be),be.add.bind(be),be.remove.bind(be);var ss=be.update.bind(be);class Cn extends h.EventDispatcher{constructor(e,n={}){super();x(this,"scene");x(this,"renderer");x(this,"camera");x(this,"controls");x(this,"ambLight");x(this,"dirLight");x(this,"clouds",null);x(this,"container");x(this,"_clock",new h.Clock);x(this,"stats");x(this,"_animationCallbacks",new Set);x(this,"_fogFactor",1);const{antialias:i=!1,stencil:r=!0,logarithmicDepthBuffer:s=!0,skybox:a}=n;this.renderer=this._createRenderer(i,r,s),this.scene=this._createScene(a),this.camera=this._createCamera(),e&&this.addTo(e),this.controls=this._createControls(),this.ambLight=this._createAmbLight(),this.scene.add(this.ambLight),this.dirLight=this._createDirLight(),this.scene.add(this.dirLight),this.scene.add(this.dirLight.target),this.renderer.setAnimationLoop(this.animate.bind(this)),n.debug&&(this.stats=new Be,document.body.appendChild(this.stats.dom))}get fogFactor(){return this._fogFactor}set fogFactor(e){this._fogFactor=e,this.controls.dispatchEvent({type:"change",target:this.controls})}get width(){return this.container?.clientWidth||0}get height(){return this.container?.clientHeight||0}addTo(e){const n=typeof e=="string"?document.querySelector(e):e;if(n instanceof HTMLElement)this.container=n,n.appendChild(this.renderer.domElement),new ResizeObserver(this.resize.bind(this)).observe(n);else throw`${e} not found!}`;return this}_createScene(e){const n=new h.Scene,i=e?.defaultColor||14414079;if(n.background=new h.Color(i),n.fog=new h.FogExp2(i,0),e?.files){const r=new h.CubeTextureLoader;e.path&&r.setPath(e.path),r.load(e.files,s=>{n.background=s},void 0,s=>{console.error("Error loading skybox:",s),n.background=new h.Color(i)})}else e?.hdr&&this._loadHDRWithPMREM(n,e);return n}async _loadHDRWithPMREM(e,n){try{if(n){const r=await new qr().setPath(n.path||"").setDataType(h.FloatType).loadAsync(n.hdr);r.colorSpace=h.LinearSRGBColorSpace;const s=new h.PMREMGenerator(this.renderer),a=s.fromEquirectangular(r).texture;console.log("HDR加载完成:",r,"环境贴图:",a),e.background=a,e.environment=a,this.dirLight.intensity=5,n?.hdrExposure!==void 0&&(this.renderer.toneMappingExposure=n.hdrExposure),r.dispose(),s.dispose()}}catch(i){console.error("加载HDR失败:",i),e.background=new h.Color(n?.defaultColor||14414079)}}_createRenderer(e,n,i){const r=new h.WebGLRenderer({antialias:e,logarithmicDepthBuffer:i,stencil:n,alpha:!0,precision:"highp",powerPreference:"high-performance",failIfMajorPerformanceCaveat:!0});if(r.sortObjects=!0,r.setPixelRatio(window.devicePixelRatio),r.domElement.tabIndex=0,r.shadowMap.enabled=!0,r.shadowMap.type=h.PCFSoftShadowMap,r.toneMapping=h.ACESFilmicToneMapping,r.toneMappingExposure=2,r.outputColorSpace="srgb-linear",r.capabilities.isWebGL2){const s=r.getContext();s.getExtension("EXT_color_buffer_float"),s.getExtension("OES_texture_float_linear")}return r}_createCamera(){const e=new h.PerspectiveCamera(70,1,100,5e4);return e.position.set(0,3e4*1e3,0),e}_createControls(){const e=new Hi(this.camera,this.renderer.domElement),n=1.52;return e.target.set(0,0,-3e3),e.screenSpacePanning=!1,e.minDistance=100/2,e.maxDistance=3e7,e.maxPolarAngle=n,e.enableDamping=!0,e.dampingFactor=.05,e.keyPanSpeed=5,e.listenToKeyEvents(this.renderer.domElement),e.addEventListener("change",()=>{const i=Math.max(e.getPolarAngle(),.1),r=Math.max(e.getDistance(),100);e.zoomSpeed=Math.max(Math.log(r/1e3),0)+.5,this.camera.far=h.MathUtils.clamp(r/i*8,100,5e4*1e3),this.camera.near=this.camera.far/1e4,this.camera.updateProjectionMatrix(),this.scene.fog instanceof h.FogExp2&&(this.scene.fog.density=i/(r+5)*this.fogFactor*.25);const a=r>8e6;e.minAzimuthAngle=a?0:-1/0,e.maxAzimuthAngle=a?0:1/0;const l=1e7,u=4;e.maxPolarAngle=Math.min(Math.pow(l/r,u),n)}),e}_createAmbLight(){return new h.AmbientLight(16777215,.1)}_createDirLight(){const e=new h.DirectionalLight(16777215,3);return e.position.set(0,2e3,1e3),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=100,e.shadow.camera.far=1e6,e.shadow.camera.left=-1e4,e.shadow.camera.right=1e4,e.shadow.camera.top=1e4,e.shadow.camera.bottom=-1e4,e}resize(){const e=this.width,n=this.height;return this.renderer.setSize(e,n),this.camera.aspect=e/n,this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera),this}addAnimationCallback(e){return this._animationCallbacks.add(e),()=>this._animationCallbacks.delete(e)}animate(){const e=this._clock.getDelta(),n=this._clock.getElapsedTime();this._animationCallbacks.forEach(i=>i(e,n)),this.controls.update(),this.renderer.render(this.scene,this.camera),ss(),this.stats&&this.stats.update(),this.dispatchEvent({type:"update",delta:e})}flyTo(e,n,i=!0,r){if(this.controls.target.copy(e),i){const s=this.camera.position;new Vn(s).to({y:2e7,z:0},500).chain(new Vn(s).to(n,2e3).easing(Ye.Quintic.Out).onComplete(a=>r&&r(a))).start()}else this.camera.position.copy(n)}getState(){return{centerPosition:this.controls.target,cameraPosition:this.camera.position}}}class os extends h.LoadingManager{constructor(){super(...arguments);x(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const ie={manager:new os,demLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(o){ie.imgLoaderMap.set(o.dataType,o),o.info.author=o.info.author??$t.name},registerGeometryLoader(o){ie.demLoaderMap.set(o.dataType,o),o.info.author=o.info.author??$t.name},getMaterialLoader(o){const t=ie.imgLoaderMap.get(o.dataType);if(t)return t;throw`Source dataType "${o.dataType}" is not support!`},getGeometryLoader(o){const t=ie.demLoaderMap.get(o.dataType);if(t)return t;throw`Source dataType "${o.dataType}" is not support!`}};function kn(o,t){const e=Math.floor(o[0]*t),n=Math.floor(o[1]*t),i=Math.floor((o[2]-o[0])*t),r=Math.floor((o[3]-o[1])*t);return{sx:e,sy:n,sw:i,sh:r}}function Dn(o,t,e,n){if(n<o.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=o.maxLevel)return{url:o._getUrl(t,e,n),clipBounds:[0,0,1,1]};const i=as(t,e,n,o.maxLevel),r=i.parentNO;return{url:o._getUrl(r.x,r.y,r.z),clipBounds:i.bounds}}function as(o,t,e,n){const i=e-n,r={x:o>>i,y:t>>i,z:e-i},s=Math.pow(2,i),a=Math.pow(.5,i),l=o%s/s-.5+a/2,u=t%s/s-.5+a/2,d=new h.Vector2(l,u),c=new h.Box2().setFromCenterAndSize(d,new h.Vector2(a,a)),p=[c.min.x+.5,c.min.y+.5,c.max.x+.5,c.max.y+.5];return{parentNO:r,bounds:p}}class Fn{constructor(){x(this,"_imgSource",[]);x(this,"_demSource");x(this,"manager",ie.manager)}get imgSource(){return this._imgSource}set imgSource(t){this._imgSource=t}get demSource(){return this._demSource}set demSource(t){this._demSource=t}async load(t){const e=await this.loadGeometry(t),n=await this.loadMaterial(t);console.assert(!!n&&!!e);for(let i=0;i<n.length;i++)e.addGroup(0,1/0,i);return{materials:n,geometry:e}}unload(t){const e=t.material,n=t.geometry;for(let i=0;i<e.length;i++)e[i].dispose();n.dispose()}async loadGeometry(t){let e;if(this.demSource&&t.z>=this.demSource.minLevel&&this._isBoundsInSourceBounds(this.demSource,t.bounds)){const n=ie.getGeometryLoader(this.demSource),i=this.demSource;e=await n.load({source:i,...t}).catch(r=>(console.error("Load material error",i.dataType,t.x,t.y,t.z),new h.PlaneGeometry)),e.addEventListener("dispose",()=>{n.unload&&n.unload(e)})}else e=new h.PlaneGeometry;return e}async loadMaterial(t){const n=this.imgSource.filter(i=>t.z>=i.minLevel&&this._isBoundsInSourceBounds(i,t.bounds)).map(async i=>{const r=ie.getMaterialLoader(i),s=await r.load({source:i,...t}).catch(l=>(console.error("Load material error",i.dataType,t.x,t.y,t.z),new h.MeshBasicMaterial)),a=l=>{r.unload&&r.unload(l.target),l.target.removeEventListener("dispose",a)};return s instanceof h.MeshBasicMaterial||s.addEventListener("dispose",a),s});return Promise.all(n)}_isBoundsInSourceBounds(t,e){const n=t._projectionBounds;return!(e[2]<n[0]||e[3]<n[1]||e[0]>n[2]||e[1]>n[3])}}function pt(...o){const t=o,e=t&&t.length>1&&t[0].constructor||null;if(!e)throw new Error("concatenateTypedArrays - incorrect quantity of arguments or arguments have incompatible data types");const n=t.reduce((s,a)=>s+a.length,0),i=new e(n);let r=0;for(const s of t)i.set(s,r),r+=s.length;return i}function ls(o,t,e,n){const i=cs(t),r=i.length,s=new Float32Array(r*6),a=new Float32Array(r*4),l=new t.constructor(r*6),u=new Float32Array(r*6);for(let c=0;c<r;c++)us({edge:i[c],edgeIndex:c,attributes:o,skirtHeight:e,newPosition:s,newTexcoord0:a,newTriangles:l,newNormals:u});o.position.value=pt(o.position.value,s),o.texcoord.value=pt(o.texcoord.value,a),o.normal.value=pt(o.normal.value,u);const d=pt(t,l);return{attributes:o,indices:d}}function cs(o){const t=[],e=Array.isArray(o)?o:Array.from(o);for(let i=0;i<e.length;i+=3){const r=e[i],s=e[i+1],a=e[i+2];t.push([r,s],[s,a],[a,r])}t.sort(([i,r],[s,a])=>{const l=Math.min(i,r),u=Math.min(s,a);return l!==u?l-u:Math.max(i,r)-Math.max(s,a)});const n=[];for(let i=0;i<t.length;i++)i+1<t.length&&t[i][0]===t[i+1][1]&&t[i][1]===t[i+1][0]?i++:n.push(t[i]);return n}function us({edge:o,edgeIndex:t,attributes:e,skirtHeight:n,newPosition:i,newTexcoord0:r,newTriangles:s,newNormals:a}){const l=e.position.value.length,u=t*2,d=u+1;i.set(e.position.value.subarray(o[0]*3,o[0]*3+3),u*3),i[u*3+2]=i[u*3+2]-n,i.set(e.position.value.subarray(o[1]*3,o[1]*3+3),d*3),i[d*3+2]=i[d*3+2]-n,r.set(e.texcoord.value.subarray(o[0]*2,o[0]*2+2),u*2),r.set(e.texcoord.value.subarray(o[1]*2,o[1]*2+2),d*2);const c=t*2*3;s[c]=o[0],s[c+1]=l/3+d,s[c+2]=o[1],s[c+3]=l/3+d,s[c+4]=o[0],s[c+5]=l/3+u,a[c]=0,a[c+1]=0,a[c+2]=1,a[c+3]=0,a[c+4]=0,a[c+5]=1}function hs(o){if(o.length<4)throw new Error(`DEM array must > 4, got ${o.length}!`);const t=Math.floor(Math.sqrt(o.length)),e=t,n=t,i=On(n,e);return{attributes:ds(o,n,e),indices:i}}function ds(o,t,e){const n=e*t,i=new Float32Array(n*3),r=new Float32Array(n*2);let s=0;for(let a=0;a<t;a++)for(let l=0;l<e;l++){const u=l/(e-1),d=a/(t-1);r[s*2]=u,r[s*2+1]=d,i[s*3]=u-.5,i[s*3+1]=d-.5,i[s*3+2]=o[(t-a-1)*e+l],s++}return{position:{value:i,size:3},texcoord:{value:r,size:2},normal:{value:zn(i,On(t,e)),size:3}}}function On(o,t){const e=6*(t-1)*(o-1),n=new Uint16Array(e);let i=0;for(let r=0;r<o-1;r++)for(let s=0;s<t-1;s++){const a=r*t+s,l=a+1,u=a+t,d=u+1,c=i*6;n[c]=a,n[c+1]=l,n[c+2]=u,n[c+3]=u,n[c+4]=l,n[c+5]=d,i++}return n}function zn(o,t){const e=new Float32Array(o.length);for(let n=0;n<t.length;n+=3){const i=t[n]*3,r=t[n+1]*3,s=t[n+2]*3,a=o[i],l=o[i+1],u=o[i+2],d=o[r],c=o[r+1],p=o[r+2],f=o[s],m=o[s+1],v=o[s+2],g=d-a,b=c-l,y=p-u,w=f-a,S=m-l,P=v-u,I=b*P-y*S,T=y*w-g*P,M=g*S-b*w,A=Math.sqrt(I*I+T*T+M*M),L=[0,0,1];if(A>0){const Z=1/A;L[0]=I*Z,L[1]=T*Z,L[2]=M*Z}for(let Z=0;Z<3;Z++)e[i+Z]=e[r+Z]=e[s+Z]=L[Z]}return e}class Ut extends h.PlaneGeometry{constructor(){super(...arguments);x(this,"type","TileGeometry")}setData(e,n=1e3){let i=e instanceof Float32Array?hs(e):e;i=ls(i.attributes,i.indices,n);const{attributes:r,indices:s}=i;return this.setIndex(new h.BufferAttribute(s,1)),this.setAttribute("position",new h.BufferAttribute(r.position.value,r.position.size)),this.setAttribute("uv",new h.BufferAttribute(r.texcoord.value,r.texcoord.size)),this.setAttribute("normal",new h.BufferAttribute(r.normal.value,r.normal.size)),this.computeBoundingBox(),this.computeBoundingSphere(),this}}class ps{constructor(t=257){x(this,"gridSize");x(this,"numTriangles");x(this,"numParentTriangles");x(this,"indices");x(this,"coords");this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let i=n+2,r=0,s=0,a=0,l=0,u=0,d=0;for(i&1?a=l=u=e:r=s=d=e;(i>>=1)>1;){const p=r+a>>1,f=s+l>>1;i&1?(a=r,l=s,r=u,s=d):(r=a,s=l,a=u,l=d),u=p,d=f}const c=n*4;this.coords[c+0]=r,this.coords[c+1]=s,this.coords[c+2]=a,this.coords[c+3]=l}}createTile(t){return new fs(t,this)}}class fs{constructor(t,e){x(this,"martini");x(this,"terrain");x(this,"errors");const n=e.gridSize;if(t.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${t.length}.`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:n,gridSize:i}=this.martini,{terrain:r,errors:s}=this;for(let a=t-1;a>=0;a--){const l=a*4,u=n[l+0],d=n[l+1],c=n[l+2],p=n[l+3],f=u+c>>1,m=d+p>>1,v=f+m-d,g=m+u-f,b=(r[d*i+u]+r[p*i+c])/2,y=m*i+f,w=Math.abs(b-r[y]);if(s[y]=Math.max(s[y],w),a<e){const S=(d+g>>1)*i+(u+v>>1),P=(p+g>>1)*i+(c+v>>1);s[y]=Math.max(s[y],s[S],s[P])}}}getGeometryData(t=0){const{gridSize:e,indices:n}=this.martini,{errors:i}=this;let r=0,s=0;const a=e-1;let l,u,d=0;n.fill(0);function c(y,w,S,P,I,T){const M=y+S>>1,A=w+P>>1;Math.abs(y-I)+Math.abs(w-T)>1&&i[A*e+M]>t?(c(I,T,y,w,M,A),c(S,P,I,T,M,A)):(l=w*e+y,u=P*e+S,d=T*e+I,n[l]===0&&(n[l]=++r),n[u]===0&&(n[u]=++r),n[d]===0&&(n[d]=++r),s++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);const p=r*2,f=s*3,m=new Uint16Array(p),v=new Uint32Array(f);let g=0;function b(y,w,S,P,I,T){const M=y+S>>1,A=w+P>>1;if(Math.abs(y-I)+Math.abs(w-T)>1&&i[A*e+M]>t)b(I,T,y,w,M,A),b(S,P,I,T,M,A);else{const L=n[w*e+y]-1,Z=n[P*e+S]-1,W=n[T*e+I]-1;m[2*L]=y,m[2*L+1]=w,m[2*Z]=S,m[2*Z+1]=P,m[2*W]=I,m[2*W+1]=T,v[g++]=L,v[g++]=Z,v[g++]=W}}return b(0,0,a,a,a,0),b(a,a,0,0,0,a),{attributes:this._getMeshAttributes(this.terrain,m,v),indices:v}}_getMeshAttributes(t,e,n){const i=Math.floor(Math.sqrt(t.length)),r=i-1,s=e.length/2,a=new Float32Array(s*3),l=new Float32Array(s*2);for(let d=0;d<s;d++){const c=e[d*2],p=e[d*2+1],f=p*i+c;a[3*d+0]=c/r-.5,a[3*d+1]=.5-p/r,a[3*d+2]=t[f],l[2*d+0]=c/r,l[2*d+1]=1-p/r}const u=zn(a,n);return{position:{value:a,size:3},texcoord:{value:l,size:2},normal:{value:u,size:3}}}}class Xn{constructor(){x(this,"info",{version:"0.10.0",description:"Terrain loader base class"});x(this,"dataType","")}async load(t){const{source:e,x:n,y:i,z:r}=t,{url:s,clipBounds:a}=Dn(e,n,i,r);if(!s)return new Ut;const l=await this.doLoad(s,{source:e,x:n,y:i,z:r,bounds:a});return ie.manager.parseEnd(s),l}}class ms extends h.MeshStandardMaterial{constructor(t={}){super({transparent:!0,side:h.FrontSide,...t})}setTexture(t){this.map=t,this.needsUpdate=!0}dispose(){const t=this.map;t&&(t.image instanceof ImageBitmap&&t.image.close(),t.dispose())}}class ys{constructor(){x(this,"info",{version:"0.10.0",description:"Image loader base class"});x(this,"dataType","")}async load(t){const{source:e,x:n,y:i,z:r}=t,s=new ms,{url:a,clipBounds:l}=Dn(e,n,i,r);if(a){const u=await this.doLoad(a,{source:e,x:n,y:i,z:r,bounds:l});s.map=u,ie.manager.parseEnd(a)}return s}}class gs extends ys{constructor(){super(...arguments);x(this,"info",{version:"0.10.0",description:"Tile image loader. It can load xyz tile image."});x(this,"dataType","image");x(this,"loader",new h.ImageLoader(ie.manager))}async doLoad(e,n){const i=await this.loader.loadAsync(e).catch(a=>new Image(1,1)),r=new h.Texture;r.colorSpace=h.SRGBColorSpace;const{bounds:s}=n;return s[2]-s[0]<1?r.image=bs(i,s):r.image=i,r.needsUpdate=!0,r}}function bs(o,t){const e=o.width,n=new OffscreenCanvas(e,e),i=n.getContext("2d"),{sx:r,sy:s,sw:a,sh:l}=kn(t,o.width);return i.drawImage(o,r,s,a,l,0,0,e,e),n}const vs=`{
511
- "name": "@terra.gl/core",
512
- "version": "0.0.1-alpha.6",
513
- "type": "module",
514
- "files": [
515
- "dist"
516
- ],
517
- "main": "./dist/index.umd.cjs",
518
- "module": "./dist/index.js",
519
- "types": "./dist/index.d.ts",
520
- "exports": {
521
- ".": {
522
- "import": "./dist/index.js",
523
- "require": "./dist/index.umd.cjs",
524
- "types": "./dist/index.d.ts"
525
- }
526
- },
527
- "author": {
528
- "name": "criska"
529
- },
530
- "description": "a map using threejs",
531
- "license": "MIT",
532
- "keywords": [
533
- "three",
534
- "gis",
535
- "tile",
536
- "map",
537
- "3D",
538
- "cesium",
539
- "mapbox"
540
- ],
541
- "scripts": {
542
- "dev": "vite build --watch",
543
- "build": "tsc && vite build"
544
- },
545
- "peerDependencies": {
546
- "three": "^0.171.0"
547
- },
548
- "publishConfig": {
549
- "registry": "https://registry.npmjs.org/",
550
- "access": "public"
551
- },
552
- "dependencies": {
553
- "@pmndrs/vanilla": "^1.20.4",
554
- "@takram/three-atmosphere": "^0.11.2",
555
- "@takram/three-clouds": "^0.2.2",
556
- "@takram/three-geospatial": "^0.2.1",
557
- "@takram/three-geospatial-effects": "^0.3.1",
558
- "@types/earcut": "^3.0.0",
559
- "@types/geojson": "^7946.0.16",
560
- "earcut": "^3.0.1",
561
- "postprocessing": "^6.37.3",
562
- "three-stdlib": "^2.36.0"
563
- }
564
- }
565
- `;var He=(o=>(o[o.none=0]="none",o[o.create=1]="create",o[o.remove=2]="remove",o))(He||{});function ws(o,t){const e=o.position.clone().setZ(o.maxZ).applyMatrix4(o.matrixWorld);return t.distanceTo(e)}function xs(o){const t=o.scale,e=new h.Vector3(-t.x,-t.y,0).applyMatrix4(o.matrixWorld),n=new h.Vector3(t.x,t.y,0).applyMatrix4(o.matrixWorld);return e.sub(n).length()}function Ls(o){return o.distToCamera/o.sizeInWorld*.8}function Ss(o,t,e,n){const i=Ls(o);if(o.isLeaf){if(o.inFrustum&&o.z<e&&(o.z<t||o.showing)&&(o.z<t||i<n))return 1}else if(o.z>=t&&(o.z>e||i>n))return 2;return 0}function Ms(o,t,e,n){const i=[],r=n+1,s=t*2,a=0,l=.25,u=o.imgSource[0].projectionID==="4326";if(n===0&&u){const d=e,c=new h.Vector3(.5,1,1),p=new le(s,d,r),f=new le(s,d,r);p.position.set(-.25,0,a),p.scale.copy(c),f.position.set(l,0,a),f.scale.copy(c),i.push(p,f)}else{const d=e*2,c=new h.Vector3(.5,.5,1),p=new le(s,d,r),f=new le(s+1,d,r),m=new le(s,d+1,r),v=new le(s+1,d+1,r);p.position.set(-.25,l,a),p.scale.copy(c),f.position.set(l,l,a),f.scale.copy(c),m.position.set(-.25,-.25,a),m.scale.copy(c),v.position.set(l,-.25,a),v.scale.copy(c),i.push(p,f,m,v)}return i}const _s=10,Zs=new h.InstancedBufferGeometry,Is=new h.Vector3,Ts=new h.Matrix4,Ps=new h.Box3(new h.Vector3(-.5,-.5,0),new h.Vector3(.5,.5,1)),Un=new h.Frustum,Fe=class Fe extends h.Mesh{constructor(e=0,n=0,i=0){super(Zs,[]);x(this,"x");x(this,"y");x(this,"z");x(this,"isTile",!0);x(this,"parent",null);x(this,"children",[]);x(this,"_ready",!1);x(this,"_isDummy",!1);x(this,"_showing",!1);x(this,"_maxZ",0);x(this,"distToCamera",0);x(this,"sizeInWorld",0);x(this,"_loaded",!1);x(this,"_inFrustum",!1);this.x=e,this.y=n,this.z=i,this.name=`Tile ${i}-${e}-${n}`,this.up.set(0,0,1),this.matrixAutoUpdate=!1}static get downloadThreads(){return Fe._downloadThreads}get isDummy(){return this._isDummy}get showing(){return this._showing}set showing(e){this._showing=e,this.material.forEach(n=>n.visible=e)}get maxZ(){return this._maxZ}set maxZ(e){this._maxZ=e}get index(){return this.parent?this.parent.children.indexOf(this):-1}get loaded(){return this._loaded}get inFrustum(){return this._inFrustum}set inFrustum(e){this._inFrustum=e}get isLeaf(){return this.children.filter(e=>e.isTile).length===0}traverse(e){e(this),this.children.forEach(n=>{n.isTile&&n.traverse(e)})}traverseVisible(e){this.visible&&(e(this),this.children.forEach(n=>{n.isTile&&n.traverseVisible(e)}))}raycast(e,n){this.showing&&this.loaded&&this.isTile&&super.raycast(e,n)}LOD(e){if(Fe.downloadThreads>_s)return{action:He.none};let n=[];const{loader:i,minLevel:r,maxLevel:s,LODThreshold:a}=e,l=Ss(this,r,s,a);return l===He.create&&(n=Ms(i,this.x,this.y,this.z),this.add(...n)),{action:l,newTiles:n}}_checkVisible(){const e=this.parent;if(e&&e.isTile){const n=e.children.filter(r=>r.isTile),i=n.every(r=>r.loaded);e.showing=!i,n.forEach(r=>r.showing=i)}return this}async _load(e){Fe._downloadThreads++;const{x:n,y:i,z:r}=this,s=await e.load({x:n,y:i,z:r,bounds:[-1/0,-1/0,1/0,1/0]});return this.material=s.materials,this.geometry=s.geometry,this.maxZ=this.geometry.boundingBox?.max.z||0,this._loaded=!0,Fe._downloadThreads--,this}_init(){this.updateMatrix(),this.updateMatrixWorld(),this.sizeInWorld=xs(this)}update(e){if(console.assert(this.z===0),!this.parent)return this;Un.setFromProjectionMatrix(Ts.multiplyMatrices(e.camera.projectionMatrix,e.camera.matrixWorldInverse));const n=e.camera.getWorldPosition(Is);return this.traverse(i=>{i.receiveShadow=this.receiveShadow,i.castShadow=this.castShadow;const r=Ps.clone().applyMatrix4(i.matrixWorld);r.max.setY(9e3),i.inFrustum=Un.intersectsBox(r),i.distToCamera=ws(i,n);const{action:s,newTiles:a}=i.LOD(e);this._doAction(i,s,a,e)}),this._checkReady(),this}_doAction(e,n,i,r){return n===He.create?i?.forEach(s=>{s._init(),s._isDummy=s.z<r.minLevel,this.dispatchEvent({type:"tile-created",tile:s}),s.isDummy||s._load(r.loader).then(()=>{s._checkVisible(),this.dispatchEvent({type:"tile-loaded",tile:s})})}):n===He.remove&&(e.showing=!0,e._unLoad(!1,r.loader),this.dispatchEvent({type:"tile-unload",tile:e})),this}reload(e){return this._unLoad(!0,e),this}_checkReady(){return this._ready||(this._ready=!0,this.traverse(e=>{if(e.isLeaf&&e.loaded&&!e.isDummy){this._ready=!1;return}}),this._ready&&this.dispatchEvent({type:"ready"})),this}_unLoad(e,n){return e&&this.isTile&&!this.isDummy&&(this.dispatchEvent({type:"unload"}),n?.unload?.(this)),this.children.forEach(i=>i._unLoad(!0,n)),this.clear(),this}};x(Fe,"_downloadThreads",0);let le=Fe;class We{constructor(t){x(this,"dataType","image");x(this,"attribution","isource");x(this,"minLevel",0);x(this,"maxLevel",18);x(this,"projectionID","3857");x(this,"url","");x(this,"subdomains",[]);x(this,"s","");x(this,"opacity",1);x(this,"isTMS",!1);x(this,"bounds",[-180,-85,180,85]);x(this,"_projectionBounds",[-1/0,-1/0,1/0,1/0]);Object.assign(this,t)}getUrl(t,e,n){const i={...this,x:t,y:e,z:n};return As(this.url,i)}_getUrl(t,e,n){const i=this.subdomains.length;if(i>0){const s=Math.floor(Math.random()*i);this.s=this.subdomains[s]}const r=this.isTMS?Math.pow(2,n)-1-e:e;return this.getUrl(t,r,n)}static create(t){return new We(t)}}function As(o,t){const e=/\{ *([\w_-]+) *\}/g;return o.replace(e,(n,i)=>{const r=t[i]??(()=>{throw new Error(`source url template error, No value provided for variable: ${n}`)})();return typeof r=="function"?r(t):r})}const{version:ta,author:na}=JSON.parse(vs);function Ws(o){return ie.registerMaterialLoader(o),o}function Yn(o){return ie.registerGeometryLoader(o),o}Ws(new gs);class Kn{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t<this.pool;t++)if(!(this.workerStatus&1<<t))return t;return-1}_onMessage(t,e){const n=this.workersResolve[t];if(n&&n(e),this.queue.length){const{resolve:i,msg:r,transfer:s}=this.queue.shift();this.workersResolve[t]=i,this.workers[t].postMessage(r,s)}else this.workerStatus^=1<<t}setWorkerCreator(t){this.workerCreator=t}setWorkerLimit(t){this.pool=t}postMessage(t,e){return new Promise(n=>{const i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(t,e)):this.queue.push({resolve:n,msg:t,transfer:e})})}dispose(){this.workers.forEach(t=>t.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const Bn="dmFyIGNlPU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgbWU9KGosWixxKT0+WiBpbiBqP2NlKGosWix7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6cX0pOmpbWl09cTt2YXIgTj0oaixaLHEpPT5tZShqLHR5cGVvZiBaIT0ic3ltYm9sIj9aKyIiOloscSk7KGZ1bmN0aW9uKCl7InVzZSBz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uZ2V0R2VvbWV0cnlEYXRhKHQpfWZ1bmN0aW9uIGZlKEEscCl7ZnVuY3Rpb24gayhzLHQsbixoLGksbyxjLHUpe2NvbnN0IG09bmV3IEZsb2F0MzJBcnJheShpKm8pO2ZvcihsZXQgbD0wO2w8bztsKyspZm9yKGxldCBmPTA7ZjxpO2YrKyl7Y29uc3QgZz0obCtoKSp0KyhmK24pLE09bCppK2Y7bVtNXT1zW2ddfWNvbnN0IHc9bmV3IEZsb2F0MzJBcnJheSh1KmMpO2ZvcihsZXQgbD0wO2w8dTtsKyspZm9yKGxldCBmPTA7ZjxjO2YrKyl7Y29uc3QgZz1sKnUrZixNPU1hdGgucm91bmQoZipvL3UpLGQ9TWF0aC5yb3VuZChsKmkvYykqaStNO3dbZ109bVtkXX1yZXR1cm4gd31jb25zdCBVPW9lKHAsQS53aWR0aCksYT1VLnN3KzEsZT1VLnNoKzE7cmV0dXJue2FycmF5OmsoQS5hcnJheSxBLndpZHRoLFUuc3gsVS5zeSxVLnN3LFUuc2gsYSxlKSx3aWR0aDphLGhlaWdodDplfX1mdW5jdGlvbiBvZShBLHApe2NvbnN0IGs9TWF0aC5mbG9vcihBWzBdKnApLFU9TWF0aC5mbG9vcihBWzFdKnApLGE9TWF0aC5mbG9vcigoQVsyXS1BWzBdKSpwKSxlPU1hdGguZmxvb3IoKEFbM10tQVsxXSkqcCk7cmV0dXJue3N4Omssc3k6VSxzdzphLHNoOmV9fXNlbGYub25tZXNzYWdlPUE9Pntjb25zdCBwPUEuZGF0YSxrPXNlKHAuZGVtRGF0YSxwLnoscC5jbGlwQm91bmRzKTtzZWxmLnBvc3RNZXNzYWdlKGspfX0pKCk7Cg==",Gs=o=>Uint8Array.from(atob(o),t=>t.charCodeAt(0)),Nn=typeof self<"u"&&self.Blob&&new Blob([Gs(Bn)],{type:"text/javascript;charset=utf-8"});function Vs(o){let t;try{if(t=Nn&&(self.URL||self.webkitURL).createObjectURL(Nn),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+Bn,{name:o?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}/* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */const Cs=function(){var o={};o.defaultNoDataValue=-34027999387901484e22,o.decode=function(s,a){a=a||{};var l=a.encodedMaskData||a.encodedMaskData===null,u=i(s,a.inputOffset||0,l),d=a.noDataValue!==null?a.noDataValue:o.defaultNoDataValue,c=t(u,a.pixelType||Float32Array,a.encodedMaskData,d,a.returnMask),p={width:u.width,height:u.height,pixelData:c.resultPixels,minValue:c.minValue,maxValue:u.pixels.maxValue,noDataValue:d};return c.resultMask&&(p.maskData=c.resultMask),a.returnEncodedMask&&u.mask&&(p.encodedMaskData=u.mask.bitset?u.mask.bitset:null),a.returnFileInfo&&(p.fileInfo=e(u),a.computeUsedBitDepths&&(p.fileInfo.bitDepths=n(u))),p};var t=function(s,a,l,u,d){var c=0,p=s.pixels.numBlocksX,f=s.pixels.numBlocksY,m=Math.floor(s.width/p),v=Math.floor(s.height/f),g=2*s.maxZError,b=Number.MAX_VALUE,y;l=l||(s.mask?s.mask.bitset:null);var w,S;w=new a(s.width*s.height),d&&l&&(S=new Uint8Array(s.width*s.height));for(var P=new Float32Array(m*v),I,T,M=0;M<=f;M++){var A=M!==f?v:s.height%f;if(A!==0)for(var L=0;L<=p;L++){var Z=L!==p?m:s.width%p;if(Z!==0){var W=M*s.width*v+L*m,C=s.width-Z,V=s.pixels.blocks[c],D,G,X;V.encoding<2?(V.encoding===0?D=V.rawData:(r(V.stuffedData,V.bitsPerPixel,V.numValidPixels,V.offset,g,P,s.pixels.maxValue),D=P),G=0):V.encoding===2?X=0:X=V.offset;var U;if(l)for(T=0;T<A;T++){for(W&7&&(U=l[W>>3],U<<=W&7),I=0;I<Z;I++)W&7||(U=l[W>>3]),U&128?(S&&(S[W]=1),y=V.encoding<2?D[G++]:X,b=b>y?y:b,w[W++]=y):(S&&(S[W]=0),w[W++]=u),U<<=1;W+=C}else if(V.encoding<2)for(T=0;T<A;T++){for(I=0;I<Z;I++)y=D[G++],b=b>y?y:b,w[W++]=y;W+=C}else for(b=b>X?X:b,T=0;T<A;T++){for(I=0;I<Z;I++)w[W++]=X;W+=C}if(V.encoding===1&&G!==V.numValidPixels)throw"Block and Mask do not match";c++}}}return{resultPixels:w,resultMask:S,minValue:b}},e=function(s){return{fileIdentifierString:s.fileIdentifierString,fileVersion:s.fileVersion,imageType:s.imageType,height:s.height,width:s.width,maxZError:s.maxZError,eofOffset:s.eofOffset,mask:s.mask?{numBlocksX:s.mask.numBlocksX,numBlocksY:s.mask.numBlocksY,numBytes:s.mask.numBytes,maxValue:s.mask.maxValue}:null,pixels:{numBlocksX:s.pixels.numBlocksX,numBlocksY:s.pixels.numBlocksY,numBytes:s.pixels.numBytes,maxValue:s.pixels.maxValue,noDataValue:s.noDataValue}}},n=function(s){for(var a=s.pixels.numBlocksX*s.pixels.numBlocksY,l={},u=0;u<a;u++){var d=s.pixels.blocks[u];d.encoding===0?l.float32=!0:d.encoding===1?l[d.bitsPerPixel]=!0:l[0]=!0}return Object.keys(l)},i=function(s,a,l){var u={},d=new Uint8Array(s,a,10);if(u.fileIdentifierString=String.fromCharCode.apply(null,d),u.fileIdentifierString.trim()!=="CntZImage")throw"Unexpected file identifier string: "+u.fileIdentifierString;a+=10;var c=new DataView(s,a,24);if(u.fileVersion=c.getInt32(0,!0),u.imageType=c.getInt32(4,!0),u.height=c.getUint32(8,!0),u.width=c.getUint32(12,!0),u.maxZError=c.getFloat64(16,!0),a+=24,!l)if(c=new DataView(s,a,16),u.mask={},u.mask.numBlocksY=c.getUint32(0,!0),u.mask.numBlocksX=c.getUint32(4,!0),u.mask.numBytes=c.getUint32(8,!0),u.mask.maxValue=c.getFloat32(12,!0),a+=16,u.mask.numBytes>0){var p=new Uint8Array(Math.ceil(u.width*u.height/8));c=new DataView(s,a,u.mask.numBytes);var f=c.getInt16(0,!0),m=2,v=0;do{if(f>0)for(;f--;)p[v++]=c.getUint8(m++);else{var g=c.getUint8(m++);for(f=-f;f--;)p[v++]=g}f=c.getInt16(m,!0),m+=2}while(m<u.mask.numBytes);if(f!==-32768||v<p.length)throw"Unexpected end of mask RLE encoding";u.mask.bitset=p,a+=u.mask.numBytes}else u.mask.numBytes|u.mask.numBlocksY|u.mask.maxValue||(u.mask.bitset=new Uint8Array(Math.ceil(u.width*u.height/8)));c=new DataView(s,a,16),u.pixels={},u.pixels.numBlocksY=c.getUint32(0,!0),u.pixels.numBlocksX=c.getUint32(4,!0),u.pixels.numBytes=c.getUint32(8,!0),u.pixels.maxValue=c.getFloat32(12,!0),a+=16;var b=u.pixels.numBlocksX,y=u.pixels.numBlocksY,w=b+(u.width%b>0?1:0),S=y+(u.height%y>0?1:0);u.pixels.blocks=new Array(w*S);for(var P=0,I=0;I<S;I++)for(var T=0;T<w;T++){var M=0,A=s.byteLength-a;c=new DataView(s,a,Math.min(10,A));var L={};u.pixels.blocks[P++]=L;var Z=c.getUint8(0);if(M++,L.encoding=Z&63,L.encoding>3)throw"Invalid block encoding ("+L.encoding+")";if(L.encoding===2){a++;continue}if(Z!==0&&Z!==2){if(Z>>=6,L.offsetType=Z,Z===2)L.offset=c.getInt8(1),M++;else if(Z===1)L.offset=c.getInt16(1,!0),M+=2;else if(Z===0)L.offset=c.getFloat32(1,!0),M+=4;else throw"Invalid block offset type";if(L.encoding===1)if(Z=c.getUint8(M),M++,L.bitsPerPixel=Z&63,Z>>=6,L.numValidPixelsType=Z,Z===2)L.numValidPixels=c.getUint8(M),M++;else if(Z===1)L.numValidPixels=c.getUint16(M,!0),M+=2;else if(Z===0)L.numValidPixels=c.getUint32(M,!0),M+=4;else throw"Invalid valid pixel count type"}if(a+=M,L.encoding!==3){var W,C;if(L.encoding===0){var V=(u.pixels.numBytes-1)/4;if(V!==Math.floor(V))throw"uncompressed block has invalid length";W=new ArrayBuffer(V*4),C=new Uint8Array(W),C.set(new Uint8Array(s,a,V*4));var D=new Float32Array(W);L.rawData=D,a+=V*4}else if(L.encoding===1){var G=Math.ceil(L.numValidPixels*L.bitsPerPixel/8),X=Math.ceil(G/4);W=new ArrayBuffer(X*4),C=new Uint8Array(W),C.set(new Uint8Array(s,a,G)),L.stuffedData=new Uint32Array(W),a+=G}}}return u.eofOffset=a,u},r=function(s,a,l,u,d,c,p){var f=(1<<a)-1,m=0,v,g=0,b,y,w=Math.ceil((p-u)/d),S=s.length*4-Math.ceil(a*l/8);for(s[s.length-1]<<=8*S,v=0;v<l;v++){if(g===0&&(y=s[m++],g=32),g>=a)b=y>>>g-a&f,g-=a;else{var P=a-g;b=(y&f)<<P&f,y=s[m++],g=32-P,b+=y>>>g}c[v]=b<w?u+b*d:p}return c};return o}(),ks=function(){var o={unstuff:function(i,r,s,a,l,u,d,c){var p=(1<<s)-1,f=0,m,v=0,g,b,y,w,S=i.length*4-Math.ceil(s*a/8);if(i[i.length-1]<<=8*S,l)for(m=0;m<a;m++)v===0&&(b=i[f++],v=32),v>=s?(g=b>>>v-s&p,v-=s):(y=s-v,g=(b&p)<<y&p,b=i[f++],v=32-y,g+=b>>>v),r[m]=l[g];else for(w=Math.ceil((c-u)/d),m=0;m<a;m++)v===0&&(b=i[f++],v=32),v>=s?(g=b>>>v-s&p,v-=s):(y=s-v,g=(b&p)<<y&p,b=i[f++],v=32-y,g+=b>>>v),r[m]=g<w?u+g*d:c},unstuffLUT:function(i,r,s,a,l,u){var d=(1<<r)-1,c=0,p=0,f=0,m=0,v=0,g,b=[],y=i.length*4-Math.ceil(r*s/8);i[i.length-1]<<=8*y;var w=Math.ceil((u-a)/l);for(p=0;p<s;p++)m===0&&(g=i[c++],m=32),m>=r?(v=g>>>m-r&d,m-=r):(f=r-m,v=(g&d)<<f&d,g=i[c++],m=32-f,v+=g>>>m),b[p]=v<w?a+v*l:u;return b.unshift(a),b},unstuff2:function(i,r,s,a,l,u,d,c){var p=(1<<s)-1,f=0,m,v=0,g=0,b,y,w;if(l)for(m=0;m<a;m++)v===0&&(y=i[f++],v=32,g=0),v>=s?(b=y>>>g&p,v-=s,g+=s):(w=s-v,b=y>>>g&p,y=i[f++],v=32-w,b|=(y&(1<<w)-1)<<s-w,g=w),r[m]=l[b];else{var S=Math.ceil((c-u)/d);for(m=0;m<a;m++)v===0&&(y=i[f++],v=32,g=0),v>=s?(b=y>>>g&p,v-=s,g+=s):(w=s-v,b=y>>>g&p,y=i[f++],v=32-w,b|=(y&(1<<w)-1)<<s-w,g=w),r[m]=b<S?u+b*d:c}return r},unstuffLUT2:function(i,r,s,a,l,u){var d=(1<<r)-1,c=0,p=0,f=0,m=0,v=0,g=0,b,y=[],w=Math.ceil((u-a)/l);for(p=0;p<s;p++)m===0&&(b=i[c++],m=32,g=0),m>=r?(v=b>>>g&d,m-=r,g+=r):(f=r-m,v=b>>>g&d,b=i[c++],m=32-f,v|=(b&(1<<f)-1)<<r-f,g=f),y[p]=v<w?a+v*l:u;return y.unshift(a),y},originalUnstuff:function(i,r,s,a){var l=(1<<s)-1,u=0,d,c=0,p,f,m,v=i.length*4-Math.ceil(s*a/8);for(i[i.length-1]<<=8*v,d=0;d<a;d++)c===0&&(f=i[u++],c=32),c>=s?(p=f>>>c-s&l,c-=s):(m=s-c,p=(f&l)<<m&l,f=i[u++],c=32-m,p+=f>>>c),r[d]=p;return r},originalUnstuff2:function(i,r,s,a){var l=(1<<s)-1,u=0,d,c=0,p=0,f,m,v;for(d=0;d<a;d++)c===0&&(m=i[u++],c=32,p=0),c>=s?(f=m>>>p&l,c-=s,p+=s):(v=s-c,f=m>>>p&l,m=i[u++],c=32-v,f|=(m&(1<<v)-1)<<s-v,p=v),r[d]=f;return r}},t={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(i){for(var r=65535,s=65535,a=i.length,l=Math.floor(a/2),u=0;l;){var d=l>=359?359:l;l-=d;do r+=i[u++]<<8,s+=r+=i[u++];while(--d);r=(r&65535)+(r>>>16),s=(s&65535)+(s>>>16)}return a&1&&(s+=r+=i[u]<<8),r=(r&65535)+(r>>>16),s=(s&65535)+(s>>>16),(s<<16|r)>>>0},readHeaderInfo:function(i,r){var s=r.ptr,a=new Uint8Array(i,s,6),l={};if(l.fileIdentifierString=String.fromCharCode.apply(null,a),l.fileIdentifierString.lastIndexOf("Lerc2",0)!==0)throw"Unexpected file identifier string (expect Lerc2 ): "+l.fileIdentifierString;s+=6;var u=new DataView(i,s,8),d=u.getInt32(0,!0);l.fileVersion=d,s+=4,d>=3&&(l.checksum=u.getUint32(4,!0),s+=4),u=new DataView(i,s,12),l.height=u.getUint32(0,!0),l.width=u.getUint32(4,!0),s+=8,d>=4?(l.numDims=u.getUint32(8,!0),s+=4):l.numDims=1,u=new DataView(i,s,40),l.numValidPixel=u.getUint32(0,!0),l.microBlockSize=u.getInt32(4,!0),l.blobSize=u.getInt32(8,!0),l.imageType=u.getInt32(12,!0),l.maxZError=u.getFloat64(16,!0),l.zMin=u.getFloat64(24,!0),l.zMax=u.getFloat64(32,!0),s+=40,r.headerInfo=l,r.ptr=s;var c,p;if(d>=3&&(p=d>=4?52:48,c=this.computeChecksumFletcher32(new Uint8Array(i,s-p,l.blobSize-14)),c!==l.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(i,r){var s=r.headerInfo,a=this.getDataTypeArray(s.imageType),l=s.numDims*this.getDataTypeSize(s.imageType),u=this.readSubArray(i,r.ptr,a,l),d=this.readSubArray(i,r.ptr+l,a,l);r.ptr+=2*l;var c,p=!0;for(c=0;c<s.numDims;c++)if(u[c]!==d[c]){p=!1;break}return s.minValues=u,s.maxValues=d,p},readSubArray:function(i,r,s,a){var l;if(s===Uint8Array)l=new Uint8Array(i,r,a);else{var u=new ArrayBuffer(a),d=new Uint8Array(u);d.set(new Uint8Array(i,r,a)),l=new s(u)}return l},readMask:function(i,r){var s=r.ptr,a=r.headerInfo,l=a.width*a.height,u=a.numValidPixel,d=new DataView(i,s,4),c={};if(c.numBytes=d.getUint32(0,!0),s+=4,(u===0||l===u)&&c.numBytes!==0)throw"invalid mask";var p,f;if(u===0)p=new Uint8Array(Math.ceil(l/8)),c.bitset=p,f=new Uint8Array(l),r.pixels.resultMask=f,s+=c.numBytes;else if(c.numBytes>0){p=new Uint8Array(Math.ceil(l/8)),d=new DataView(i,s,c.numBytes);var m=d.getInt16(0,!0),v=2,g=0,b=0;do{if(m>0)for(;m--;)p[g++]=d.getUint8(v++);else for(b=d.getUint8(v++),m=-m;m--;)p[g++]=b;m=d.getInt16(v,!0),v+=2}while(v<c.numBytes);if(m!==-32768||g<p.length)throw"Unexpected end of mask RLE encoding";f=new Uint8Array(l);var y=0,w=0;for(w=0;w<l;w++)w&7?(y=p[w>>3],y<<=w&7):y=p[w>>3],y&128&&(f[w]=1);r.pixels.resultMask=f,c.bitset=p,s+=c.numBytes}return r.ptr=s,r.mask=c,!0},readDataOneSweep:function(i,r,s,a){var l=r.ptr,u=r.headerInfo,d=u.numDims,c=u.width*u.height,p=u.imageType,f=u.numValidPixel*t.getDataTypeSize(p)*d,m,v=r.pixels.resultMask;if(s===Uint8Array)m=new Uint8Array(i,l,f);else{var g=new ArrayBuffer(f),b=new Uint8Array(g);b.set(new Uint8Array(i,l,f)),m=new s(g)}if(m.length===c*d)a?r.pixels.resultPixels=t.swapDimensionOrder(m,c,d,s,!0):r.pixels.resultPixels=m;else{r.pixels.resultPixels=new s(c*d);var y=0,w=0,S=0,P=0;if(d>1){if(a){for(w=0;w<c;w++)if(v[w])for(P=w,S=0;S<d;S++,P+=c)r.pixels.resultPixels[P]=m[y++]}else for(w=0;w<c;w++)if(v[w])for(P=w*d,S=0;S<d;S++)r.pixels.resultPixels[P+S]=m[y++]}else for(w=0;w<c;w++)v[w]&&(r.pixels.resultPixels[w]=m[y++])}return l+=f,r.ptr=l,!0},readHuffmanTree:function(i,r){var s=this.HUFFMAN_LUT_BITS_MAX,a=new DataView(i,r.ptr,16);r.ptr+=16;var l=a.getInt32(0,!0);if(l<2)throw"unsupported Huffman version";var u=a.getInt32(4,!0),d=a.getInt32(8,!0),c=a.getInt32(12,!0);if(d>=c)return!1;var p=new Uint32Array(c-d);t.decodeBits(i,r,p);var f=[],m,v,g,b;for(m=d;m<c;m++)v=m-(m<u?0:u),f[v]={first:p[m-d],second:null};var y=i.byteLength-r.ptr,w=Math.ceil(y/4),S=new ArrayBuffer(w*4),P=new Uint8Array(S);P.set(new Uint8Array(i,r.ptr,y));var I=new Uint32Array(S),T=0,M,A=0;for(M=I[0],m=d;m<c;m++)v=m-(m<u?0:u),b=f[v].first,b>0&&(f[v].second=M<<T>>>32-b,32-T>=b?(T+=b,T===32&&(T=0,A++,M=I[A])):(T+=b-32,A++,M=I[A],f[v].second|=M>>>32-T));var L=0,Z=0,W=new e;for(m=0;m<f.length;m++)f[m]!==void 0&&(L=Math.max(L,f[m].first));L>=s?Z=s:Z=L;var C=[],V,D,G,X,U,z;for(m=d;m<c;m++)if(v=m-(m<u?0:u),b=f[v].first,b>0)if(V=[b,v],b<=Z)for(D=f[v].second<<Z-b,G=1<<Z-b,g=0;g<G;g++)C[D|g]=V;else for(D=f[v].second,z=W,X=b-1;X>=0;X--)U=D>>>X&1,U?(z.right||(z.right=new e),z=z.right):(z.left||(z.left=new e),z=z.left),X===0&&!z.val&&(z.val=V[1]);return{decodeLut:C,numBitsLUTQick:Z,numBitsLUT:L,tree:W,stuffedData:I,srcPtr:A,bitPos:T}},readHuffman:function(i,r,s,a){var l=r.headerInfo,u=l.numDims,d=r.headerInfo.height,c=r.headerInfo.width,p=c*d,f=this.readHuffmanTree(i,r),m=f.decodeLut,v=f.tree,g=f.stuffedData,b=f.srcPtr,y=f.bitPos,w=f.numBitsLUTQick,S=f.numBitsLUT,P=r.headerInfo.imageType===0?128:0,I,T,M,A=r.pixels.resultMask,L,Z,W,C,V,D,G,X=0;y>0&&(b++,y=0);var U=g[b],z=r.encodeMode===1,j=new s(p*u),H=j,B;if(u<2||z){for(B=0;B<u;B++)if(u>1&&(H=new s(j.buffer,p*B,p),X=0),r.headerInfo.numValidPixel===c*d)for(D=0,C=0;C<d;C++)for(V=0;V<c;V++,D++){if(T=0,L=U<<y>>>32-w,Z=L,32-y<w&&(L|=g[b+1]>>>64-y-w,Z=L),m[Z])T=m[Z][1],y+=m[Z][0];else for(L=U<<y>>>32-S,Z=L,32-y<S&&(L|=g[b+1]>>>64-y-S,Z=L),I=v,G=0;G<S;G++)if(W=L>>>S-G-1&1,I=W?I.right:I.left,!(I.left||I.right)){T=I.val,y=y+G+1;break}y>=32&&(y-=32,b++,U=g[b]),M=T-P,z?(V>0?M+=X:C>0?M+=H[D-c]:M+=X,M&=255,H[D]=M,X=M):H[D]=M}else for(D=0,C=0;C<d;C++)for(V=0;V<c;V++,D++)if(A[D]){if(T=0,L=U<<y>>>32-w,Z=L,32-y<w&&(L|=g[b+1]>>>64-y-w,Z=L),m[Z])T=m[Z][1],y+=m[Z][0];else for(L=U<<y>>>32-S,Z=L,32-y<S&&(L|=g[b+1]>>>64-y-S,Z=L),I=v,G=0;G<S;G++)if(W=L>>>S-G-1&1,I=W?I.right:I.left,!(I.left||I.right)){T=I.val,y=y+G+1;break}y>=32&&(y-=32,b++,U=g[b]),M=T-P,z?(V>0&&A[D-1]?M+=X:C>0&&A[D-c]?M+=H[D-c]:M+=X,M&=255,H[D]=M,X=M):H[D]=M}}else for(D=0,C=0;C<d;C++)for(V=0;V<c;V++)if(D=C*c+V,!A||A[D])for(B=0;B<u;B++,D+=p){if(T=0,L=U<<y>>>32-w,Z=L,32-y<w&&(L|=g[b+1]>>>64-y-w,Z=L),m[Z])T=m[Z][1],y+=m[Z][0];else for(L=U<<y>>>32-S,Z=L,32-y<S&&(L|=g[b+1]>>>64-y-S,Z=L),I=v,G=0;G<S;G++)if(W=L>>>S-G-1&1,I=W?I.right:I.left,!(I.left||I.right)){T=I.val,y=y+G+1;break}y>=32&&(y-=32,b++,U=g[b]),M=T-P,H[D]=M}r.ptr=r.ptr+(b+1)*4+(y>0?4:0),r.pixels.resultPixels=j,u>1&&!a&&(r.pixels.resultPixels=t.swapDimensionOrder(j,p,u,s))},decodeBits:function(i,r,s,a,l){{var u=r.headerInfo,d=u.fileVersion,c=0,p=i.byteLength-r.ptr>=5?5:i.byteLength-r.ptr,f=new DataView(i,r.ptr,p),m=f.getUint8(0);c++;var v=m>>6,g=v===0?4:3-v,b=(m&32)>0,y=m&31,w=0;if(g===1)w=f.getUint8(c),c++;else if(g===2)w=f.getUint16(c,!0),c+=2;else if(g===4)w=f.getUint32(c,!0),c+=4;else throw"Invalid valid pixel count type";var S=2*u.maxZError,P,I,T,M,A,L,Z,W,C,V=u.numDims>1?u.maxValues[l]:u.zMax;if(b){for(r.counter.lut++,W=f.getUint8(c),c++,M=Math.ceil((W-1)*y/8),A=Math.ceil(M/4),I=new ArrayBuffer(A*4),T=new Uint8Array(I),r.ptr+=c,T.set(new Uint8Array(i,r.ptr,M)),Z=new Uint32Array(I),r.ptr+=M,C=0;W-1>>>C;)C++;M=Math.ceil(w*C/8),A=Math.ceil(M/4),I=new ArrayBuffer(A*4),T=new Uint8Array(I),T.set(new Uint8Array(i,r.ptr,M)),P=new Uint32Array(I),r.ptr+=M,d>=3?L=o.unstuffLUT2(Z,y,W-1,a,S,V):L=o.unstuffLUT(Z,y,W-1,a,S,V),d>=3?o.unstuff2(P,s,C,w,L):o.unstuff(P,s,C,w,L)}else r.counter.bitstuffer++,C=y,r.ptr+=c,C>0&&(M=Math.ceil(w*C/8),A=Math.ceil(M/4),I=new ArrayBuffer(A*4),T=new Uint8Array(I),T.set(new Uint8Array(i,r.ptr,M)),P=new Uint32Array(I),r.ptr+=M,d>=3?a==null?o.originalUnstuff2(P,s,C,w):o.unstuff2(P,s,C,w,!1,a,S,V):a==null?o.originalUnstuff(P,s,C,w):o.unstuff(P,s,C,w,!1,a,S,V))}},readTiles:function(i,r,s,a){var l=r.headerInfo,u=l.width,d=l.height,c=u*d,p=l.microBlockSize,f=l.imageType,m=t.getDataTypeSize(f),v=Math.ceil(u/p),g=Math.ceil(d/p);r.pixels.numBlocksY=g,r.pixels.numBlocksX=v,r.pixels.ptr=0;var b=0,y=0,w=0,S=0,P=0,I=0,T=0,M=0,A=0,L=0,Z=0,W=0,C=0,V=0,D=0,G=0,X,U,z,j,H,B,J=new s(p*p),de=d%p||p,Ke=u%p||p,Le,pe,Se=l.numDims,Me,ce=r.pixels.resultMask,re=r.pixels.resultPixels,wt=l.fileVersion,et=wt>=5?14:15,fe,tt=l.zMax,ve;for(w=0;w<g;w++)for(P=w!==g-1?p:de,S=0;S<v;S++)for(I=S!==v-1?p:Ke,Z=w*u*p+S*p,W=u-I,Me=0;Me<Se;Me++){if(Se>1?(ve=re,Z=w*u*p+S*p,re=new s(r.pixels.resultPixels.buffer,c*Me*m,c),tt=l.maxValues[Me]):ve=null,T=i.byteLength-r.ptr,X=new DataView(i,r.ptr,Math.min(10,T)),U={},G=0,M=X.getUint8(0),G++,fe=l.fileVersion>=5?M&4:0,A=M>>6&255,L=M>>2&et,L!==(S*p>>3&et)||fe&&Me===0)throw"integrity issue";if(B=M&3,B>3)throw r.ptr+=G,"Invalid block encoding ("+B+")";if(B===2){if(fe)if(ce)for(b=0;b<P;b++)for(y=0;y<I;y++)ce[Z]&&(re[Z]=ve[Z]),Z++;else for(b=0;b<P;b++)for(y=0;y<I;y++)re[Z]=ve[Z],Z++;r.counter.constant++,r.ptr+=G;continue}else if(B===0){if(fe)throw"integrity issue";if(r.counter.uncompressed++,r.ptr+=G,C=P*I*m,V=i.byteLength-r.ptr,C=C<V?C:V,z=new ArrayBuffer(C%m===0?C:C+m-C%m),j=new Uint8Array(z),j.set(new Uint8Array(i,r.ptr,C)),H=new s(z),D=0,ce)for(b=0;b<P;b++){for(y=0;y<I;y++)ce[Z]&&(re[Z]=H[D++]),Z++;Z+=W}else for(b=0;b<P;b++){for(y=0;y<I;y++)re[Z++]=H[D++];Z+=W}r.ptr+=D*m}else if(Le=t.getDataTypeUsed(fe&&f<6?4:f,A),pe=t.getOnePixel(U,G,Le,X),G+=t.getDataTypeSize(Le),B===3)if(r.ptr+=G,r.counter.constantoffset++,ce)for(b=0;b<P;b++){for(y=0;y<I;y++)ce[Z]&&(re[Z]=fe?Math.min(tt,ve[Z]+pe):pe),Z++;Z+=W}else for(b=0;b<P;b++){for(y=0;y<I;y++)re[Z]=fe?Math.min(tt,ve[Z]+pe):pe,Z++;Z+=W}else if(r.ptr+=G,t.decodeBits(i,r,J,pe,Me),G=0,fe)if(ce)for(b=0;b<P;b++){for(y=0;y<I;y++)ce[Z]&&(re[Z]=J[G++]+ve[Z]),Z++;Z+=W}else for(b=0;b<P;b++){for(y=0;y<I;y++)re[Z]=J[G++]+ve[Z],Z++;Z+=W}else if(ce)for(b=0;b<P;b++){for(y=0;y<I;y++)ce[Z]&&(re[Z]=J[G++]),Z++;Z+=W}else for(b=0;b<P;b++){for(y=0;y<I;y++)re[Z++]=J[G++];Z+=W}}Se>1&&!a&&(r.pixels.resultPixels=t.swapDimensionOrder(r.pixels.resultPixels,c,Se,s))},formatFileInfo:function(i){return{fileIdentifierString:i.headerInfo.fileIdentifierString,fileVersion:i.headerInfo.fileVersion,imageType:i.headerInfo.imageType,height:i.headerInfo.height,width:i.headerInfo.width,numValidPixel:i.headerInfo.numValidPixel,microBlockSize:i.headerInfo.microBlockSize,blobSize:i.headerInfo.blobSize,maxZError:i.headerInfo.maxZError,pixelType:t.getPixelType(i.headerInfo.imageType),eofOffset:i.eofOffset,mask:i.mask?{numBytes:i.mask.numBytes}:null,pixels:{numBlocksX:i.pixels.numBlocksX,numBlocksY:i.pixels.numBlocksY,maxValue:i.headerInfo.zMax,minValue:i.headerInfo.zMin,noDataValue:i.noDataValue}}},constructConstantSurface:function(i,r){var s=i.headerInfo.zMax,a=i.headerInfo.zMin,l=i.headerInfo.maxValues,u=i.headerInfo.numDims,d=i.headerInfo.height*i.headerInfo.width,c=0,p=0,f=0,m=i.pixels.resultMask,v=i.pixels.resultPixels;if(m)if(u>1){if(r)for(c=0;c<u;c++)for(f=c*d,s=l[c],p=0;p<d;p++)m[p]&&(v[f+p]=s);else for(p=0;p<d;p++)if(m[p])for(f=p*u,c=0;c<u;c++)v[f+u]=l[c]}else for(p=0;p<d;p++)m[p]&&(v[p]=s);else if(u>1&&a!==s)if(r)for(c=0;c<u;c++)for(f=c*d,s=l[c],p=0;p<d;p++)v[f+p]=s;else for(p=0;p<d;p++)for(f=p*u,c=0;c<u;c++)v[f+c]=l[c];else for(p=0;p<d*u;p++)v[p]=s},getDataTypeArray:function(i){var r;switch(i){case 0:r=Int8Array;break;case 1:r=Uint8Array;break;case 2:r=Int16Array;break;case 3:r=Uint16Array;break;case 4:r=Int32Array;break;case 5:r=Uint32Array;break;case 6:r=Float32Array;break;case 7:r=Float64Array;break;default:r=Float32Array}return r},getPixelType:function(i){var r;switch(i){case 0:r="S8";break;case 1:r="U8";break;case 2:r="S16";break;case 3:r="U16";break;case 4:r="S32";break;case 5:r="U32";break;case 6:r="F32";break;case 7:r="F64";break;default:r="F32"}return r},isValidPixelValue:function(i,r){if(r==null)return!1;var s;switch(i){case 0:s=r>=-128&&r<=127;break;case 1:s=r>=0&&r<=255;break;case 2:s=r>=-32768&&r<=32767;break;case 3:s=r>=0&&r<=65536;break;case 4:s=r>=-2147483648&&r<=2147483647;break;case 5:s=r>=0&&r<=4294967296;break;case 6:s=r>=-34027999387901484e22&&r<=34027999387901484e22;break;case 7:s=r>=-17976931348623157e292&&r<=17976931348623157e292;break;default:s=!1}return s},getDataTypeSize:function(i){var r=0;switch(i){case 0:case 1:r=1;break;case 2:case 3:r=2;break;case 4:case 5:case 6:r=4;break;case 7:r=8;break;default:r=i}return r},getDataTypeUsed:function(i,r){var s=i;switch(i){case 2:case 4:s=i-r;break;case 3:case 5:s=i-2*r;break;case 6:r===0?s=i:r===1?s=2:s=1;break;case 7:r===0?s=i:s=i-2*r+1;break;default:s=i;break}return s},getOnePixel:function(i,r,s,a){var l=0;switch(s){case 0:l=a.getInt8(r);break;case 1:l=a.getUint8(r);break;case 2:l=a.getInt16(r,!0);break;case 3:l=a.getUint16(r,!0);break;case 4:l=a.getInt32(r,!0);break;case 5:l=a.getUInt32(r,!0);break;case 6:l=a.getFloat32(r,!0);break;case 7:l=a.getFloat64(r,!0);break;default:throw"the decoder does not understand this pixel type"}return l},swapDimensionOrder:function(i,r,s,a,l){var u=0,d=0,c=0,p=0,f=i;if(s>1)if(f=new a(r*s),l)for(u=0;u<r;u++)for(p=u,c=0;c<s;c++,p+=r)f[p]=i[d++];else for(u=0;u<r;u++)for(p=u,c=0;c<s;c++,p+=r)f[d++]=i[p];return f}},e=function(i,r,s){this.val=i,this.left=r,this.right=s},n={decode:function(i,r){r=r||{};var s=r.noDataValue,a=0,l={};if(l.ptr=r.inputOffset||0,l.pixels={},!!t.readHeaderInfo(i,l)){var u=l.headerInfo,d=u.fileVersion,c=t.getDataTypeArray(u.imageType);if(d>5)throw"unsupported lerc version 2."+d;t.readMask(i,l),u.numValidPixel!==u.width*u.height&&!l.pixels.resultMask&&(l.pixels.resultMask=r.maskData);var p=u.width*u.height;l.pixels.resultPixels=new c(p*u.numDims),l.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var f=!r.returnPixelInterleavedDims;if(u.numValidPixel!==0)if(u.zMax===u.zMin)t.constructConstantSurface(l,f);else if(d>=4&&t.checkMinMaxRanges(i,l))t.constructConstantSurface(l,f);else{var m=new DataView(i,l.ptr,2),v=m.getUint8(0);if(l.ptr++,v)t.readDataOneSweep(i,l,c,f);else if(d>1&&u.imageType<=1&&Math.abs(u.maxZError-.5)<1e-5){var g=m.getUint8(1);if(l.ptr++,l.encodeMode=g,g>2||d<4&&g>1)throw"Invalid Huffman flag "+g;g?t.readHuffman(i,l,c,f):t.readTiles(i,l,c,f)}else t.readTiles(i,l,c,f)}l.eofOffset=l.ptr;var b;r.inputOffset?(b=l.headerInfo.blobSize+r.inputOffset-l.ptr,Math.abs(b)>=1&&(l.eofOffset=r.inputOffset+l.headerInfo.blobSize)):(b=l.headerInfo.blobSize-l.ptr,Math.abs(b)>=1&&(l.eofOffset=l.headerInfo.blobSize));var y={width:u.width,height:u.height,pixelData:l.pixels.resultPixels,minValue:u.zMin,maxValue:u.zMax,validPixelCount:u.numValidPixel,dimCount:u.numDims,dimStats:{minValues:u.minValues,maxValues:u.maxValues},maskData:l.pixels.resultMask};if(l.pixels.resultMask&&t.isValidPixelValue(u.imageType,s)){var w=l.pixels.resultMask;for(a=0;a<p;a++)w[a]||(y.pixelData[a]=s);y.noDataValue=s}return l.noDataValue=s,r.returnFileInfo&&(y.fileInfo=t.formatFileInfo(l)),y}},getBandCount:function(i){var r=0,s=0,a={};for(a.ptr=0,a.pixels={};s<i.byteLength-58;)t.readHeaderInfo(i,a),s+=a.headerInfo.blobSize,r++,a.ptr=s;return r}};return n}();var Ds=function(){var o=new ArrayBuffer(4),t=new Uint8Array(o),e=new Uint32Array(o);return e[0]=1,t[0]===1}(),Fs={decode:function(o,t){if(!Ds)throw"Big endian system is not supported.";t=t||{};var e=t.inputOffset||0,n=new Uint8Array(o,e,10),i=String.fromCharCode.apply(null,n),r,s;if(i.trim()==="CntZImage")r=Cs,s=1;else if(i.substring(0,5)==="Lerc2")r=ks,s=2;else throw"Unexpected file identifier string: "+i;for(var a=0,l=o.byteLength-10,u,d=[],c,p,f={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]},m=0;e<l;){var v=r.decode(o,{inputOffset:e,encodedMaskData:u,maskData:p,returnMask:a===0,returnEncodedMask:a===0,returnFileInfo:!0,returnPixelInterleavedDims:t.returnPixelInterleavedDims,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});e=v.fileInfo.eofOffset,p=v.maskData,a===0&&(u=v.encodedMaskData,f.width=v.width,f.height=v.height,f.dimCount=v.dimCount||1,f.pixelType=v.pixelType||v.fileInfo.pixelType,f.mask=p),s>1&&(p&&d.push(p),v.fileInfo.mask&&v.fileInfo.mask.numBytes>0&&m++),a++,f.pixels.push(v.pixelData),f.statistics.push({minValue:v.minValue,maxValue:v.maxValue,noDataValue:v.noDataValue,dimStats:v.dimStats})}var g,b,y;if(s>1&&m>1){for(y=f.width*f.height,f.bandMasks=d,p=new Uint8Array(y),p.set(d[0]),g=1;g<d.length;g++)for(c=d[g],b=0;b<y;b++)p[b]=p[b]&c[b];f.maskData=p}return f}};const Os={0:7e3,1:6e3,2:5e3,3:4e3,4:3e3,5:2500,6:2e3,7:1500,8:800,9:500,10:200,11:100,12:40,13:12,14:5,15:2,16:1,17:.5,18:.2,19:.1,20:.01};function zs(o){const{height:t,width:e,pixels:n}=Fs.decode(o),i=new Float32Array(t*e);for(let r=0;r<i.length;r++)i[r]=n[0][r];return{array:i,width:e,height:t}}function Xs(o,t,e){let n=zs(o);e[2]-e[0]<1&&(n=Us(n,e));const{array:i,width:r}=n,a=new ps(r).createTile(i),l=Os[t]||0;return a.getGeometryData(l)}function Us(o,t){function e(a,l,u,d,c,p,f,m){const v=new Float32Array(c*p);for(let b=0;b<p;b++)for(let y=0;y<c;y++){const w=(b+d)*l+(y+u),S=b*c+y;v[S]=a[w]}const g=new Float32Array(m*f);for(let b=0;b<m;b++)for(let y=0;y<f;y++){const w=b*m+y,S=Math.round(y*p/m),I=Math.round(b*c/f)*c+S;g[w]=v[I]}return g}const n=Ys(t,o.width),i=n.sw+1,r=n.sh+1;return{array:e(o.array,o.width,n.sx,n.sy,n.sw,n.sh,i,r),width:i,height:r}}function Ys(o,t){const e=Math.floor(o[0]*t),n=Math.floor(o[1]*t),i=Math.floor((o[2]-o[0])*t),r=Math.floor((o[3]-o[1])*t);return{sx:e,sy:n,sw:i,sh:r}}const Ks=10;class Bs extends Xn{constructor(){super();x(this,"info",{version:"0.10.0",description:"Tile LERC terrain loader. It can load ArcGis-lerc format terrain data."});x(this,"dataType","lerc");x(this,"fileLoader",new h.FileLoader(ie.manager));x(this,"_workerPool",new Kn(0));this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new Vs)}async doLoad(e,n){this._workerPool.pool===0&&this._workerPool.setWorkerLimit(Ks);const{z:i,bounds:r}=n,s=await this.fileLoader.loadAsync(e).catch(()=>new Float32Array(256*256)),a=Xs(s,i,r);return new Ut().setData(a)}}Yn(new Bs);const jn="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGModCl7cmV0dXJuIGEodC5kYXRhKX1mdW5jdGlvbiBhKHQpe2Z1bmN0aW9uIG4oZSx1KXtjb25zdCByPXUqNCxbaSxmLGcsbF09ZS5zbGljZShyLHIrNCk7cmV0dXJuIGw9PT0wPzA6LTFlNCsoaTw8MTZ8Zjw8OHxnKSouMX1jb25zdCBvPXQubGVuZ3RoPj4+MixzPW5ldyBGbG9hdDMyQXJyYXkobyk7Zm9yKGxldCBlPTA7ZTxvO2UrKylzW2VdPW4odCxlKTtyZXR1cm4gc31zZWxmLm9ubWVzc2FnZT10PT57Y29uc3Qgbj1jKHQuZGF0YS5pbWdEYXRhKTtzZWxmLnBvc3RNZXNzYWdlKG4pfX0pKCk7Cg==",Ns=o=>Uint8Array.from(atob(o),t=>t.charCodeAt(0)),Rn=typeof self<"u"&&self.Blob&&new Blob([Ns(jn)],{type:"text/javascript;charset=utf-8"});function js(o){let t;try{if(t=Rn&&(self.URL||self.webkitURL).createObjectURL(Rn),!t)throw"";const e=new Worker(t,{name:o?.name});return e.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),e}catch{return new Worker("data:text/javascript;base64,"+jn,{name:o?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const Rs=10;class Js extends Xn{constructor(){super();x(this,"info",{version:"0.10.0",description:"Mapbox-RGB terrain loader, It can load Mapbox-RGB terrain data."});x(this,"dataType","terrain-rgb");x(this,"imageLoader",new h.ImageLoader(ie.manager));x(this,"_workerPool",new Kn(0));this._workerPool.setWorkerCreator(()=>new js)}async doLoad(e,n){const i=await this.imageLoader.loadAsync(e).catch(u=>new Image),r=h.MathUtils.clamp((n.z+2)*3,2,64),s=Qs(i,n.bounds,r);let a;this._workerPool.pool===0&&this._workerPool.setWorkerLimit(Rs),a=(await this._workerPool.postMessage({imgData:s},[s.data.buffer])).data;const l=new Ut;return l.setData(a),l}}function Qs(o,t,e){const n=kn(t,o.width);e=Math.min(e,n.sw);const r=new OffscreenCanvas(e,e).getContext("2d");return r.imageSmoothingEnabled=!1,r.drawImage(o,n.sx,n.sy,n.sw,n.sh,0,0,e,e),r.getImageData(0,0,e,e)}Yn(new Js);class Jn{constructor(t=0){x(this,"_lon0",0);this._lon0=t}get lon0(){return this._lon0}getTileXWithCenterLon(t,e){const n=Math.pow(2,e);let i=t+Math.round(n/360*this._lon0);return i>=n?i-=n:i<0&&(i+=n),i}getTileXYZproj(t,e,n){const i=this.mapWidth,r=this.mapHeight/2,s=t/Math.pow(2,n)*i-i/2,a=r-e/Math.pow(2,n)*r*2;return{x:s,y:a}}getProjBoundsFromLonLat(t){const e=t[0]===-180&&t[2]===180,n=this.project(t[0]+(e?this._lon0:0),t[1]),i=this.project(t[2]+(e?this._lon0:0),t[3]);return[Math.min(n.x,i.x),Math.min(n.y,i.y),Math.max(n.x,i.x),Math.max(n.y,i.y)]}getProjBoundsFromXYZ(t,e,n){const i=this.getTileXYZproj(t,e,n),r=this.getTileXYZproj(t+1,e+1,n);return[Math.min(i.x,r.x),Math.min(i.y,r.y),Math.max(i.x,r.x),Math.max(i.y,r.y)]}getLonLatBoundsFromXYZ(t,e,n){const i=this.getProjBoundsFromXYZ(t,e,n),r=this.unProject(i[0],i[1]),s=this.unProject(i[2],i[3]);return[r.lon,r.lat,s.lon,s.lat]}}const Ee=6378e3;class Qn extends Jn{constructor(){super(...arguments);x(this,"ID","3857");x(this,"mapWidth",2*Math.PI*Ee);x(this,"mapHeight",this.mapWidth);x(this,"mapDepth",1)}project(e,n){const i=(e-this.lon0)*(Math.PI/180),r=n*(Math.PI/180),s=Ee*i,a=Ee*Math.log(Math.tan(Math.PI/4+r/2));return{x:s,y:a}}unProject(e,n){let i=e/Ee*(180/Math.PI)+this.lon0;return i>180&&(i-=360),{lat:(2*Math.atan(Math.exp(n/Ee))-Math.PI/2)*(180/Math.PI),lon:i}}}class Hs extends Jn{constructor(){super(...arguments);x(this,"ID","4326");x(this,"mapWidth",36e3);x(this,"mapHeight",18e3);x(this,"mapDepth",1)}project(e,n){return{x:(e-this.lon0)*100,y:n*100}}unProject(e,n){return{lon:e/100+this.lon0,lat:n/100}}}const Hn={createFromID:(o="3857",t)=>{let e;switch(o){case"3857":e=new Qn(t);break;case"4326":e=new Hs(t);break;default:throw new Error(`Projection ID: ${o} is not supported.`)}return e}};class Es extends Fn{constructor(){super(...arguments);x(this,"_projection")}attcth(e,n){Object.assign(this,e),this._projection=n;const i=e.imgSource,r=e.demSource;i.forEach(s=>{s._projectionBounds=n.getProjBoundsFromLonLat(s.bounds)}),r&&(r._projectionBounds=n.getProjBoundsFromLonLat(r.bounds))}async load(e){if(!this._projection)throw new Error("projection is undefined");const{x:n,y:i,z:r}=e,s=this._projection.getTileXWithCenterLon(n,r),a=this._projection.getProjBoundsFromXYZ(n,i,r),l=this._projection.getLonLatBoundsFromXYZ(n,i,r);return super.load({x:s,y:i,z:r,bounds:a,lonLatBounds:l})}}function En(o,t){const e=t.intersectObjects([o.rootTile]);for(const n of e)if(n.object instanceof le){const i=o.worldToLocal(n.point.clone()),r=o.map2geo(i);return Object.assign(n,{location:r})}}function qn(o,t){const e=new h.Vector3(0,-1,0),n=new h.Vector3(t.x,10*1e3,t.z),i=new h.Raycaster(n,e);return En(o,i)}function qs(o,t,e){const n=new h.Raycaster;return n.setFromCamera(e,o),En(t,n)}function $s(o){const t=o.loader.manager,e=(n,i)=>{o.dispatchEvent({type:n,...i})};t.onStart=(n,i,r)=>{e("loading-start",{url:n,itemsLoaded:i,itemsTotal:r})},t.onError=n=>{e("loading-error",{url:n})},t.onLoad=()=>{e("loading-complete")},t.onProgress=(n,i,r)=>{e("loading-progress",{url:n,itemsLoaded:i,itemsTotal:r})},t.onParseEnd=n=>{e("parsing-end",{url:n})},o.rootTile.addEventListener("ready",()=>e("ready")),o.rootTile.addEventListener("tile-created",n=>{e("tile-created",{tile:n.tile})}),o.rootTile.addEventListener("tile-loaded",n=>{e("tile-loaded",{tile:n.tile})}),o.rootTile.addEventListener("tile-unload",n=>{e("tile-unload",{tile:n.tile})})}class Yt extends h.Mesh{constructor(e){super();x(this,"name","map");x(this,"_clock",new h.Clock);x(this,"isLOD",!0);x(this,"autoUpdate",!0);x(this,"updateInterval",100);x(this,"rootTile");x(this,"loader");x(this,"_loader",new Es);x(this,"_minLevel",2);x(this,"_maxLevel",19);x(this,"_projection",new Qn(0));x(this,"_imgSource",[]);x(this,"_demSource");x(this,"_LODThreshold",1);this.up.set(0,0,1);const{loader:n=new Fn,rootTile:i=new le,minLevel:r=2,maxLevel:s=19,imgSource:a,demSource:l,lon0:u=0}=e;this.loader=n,i.matrixAutoUpdate=!0,i.scale.set(this.projection.mapWidth,this.projection.mapHeight,this.projection.mapDepth),this.rootTile=i,this.minLevel=r,this.maxLevel=s,this.imgSource=a,this.demSource=l,this.lon0=u,this.add(i),i.updateMatrix(),$s(this)}get minLevel(){return this._minLevel}set minLevel(e){this._minLevel=e}get maxLevel(){return this._maxLevel}set maxLevel(e){this._maxLevel=e}get lon0(){return this.projection.lon0}set lon0(e){this.projection.lon0!==e&&(e!=0&&this.minLevel<1&&console.warn(`Map centralMeridian is ${this.lon0}, minLevel must > 0`),this.projection=Hn.createFromID(this.projection.ID,e),this.reload())}get projection(){return this._projection}set projection(e){(e.ID!=this.projection.ID||e.lon0!=this.lon0)&&(this.rootTile.scale.set(e.mapWidth,e.mapHeight,e.mapDepth),this._projection=e,this.reload(),this.dispatchEvent({type:"projection-changed",projection:e}))}get imgSource(){return this._imgSource}set imgSource(e){const n=Array.isArray(e)?e:[e];if(n.length===0)throw new Error("imgSource can not be empty");this.projection=Hn.createFromID(n[0].projectionID,this.projection.lon0),this._imgSource=n,this.loader.imgSource=n,this.dispatchEvent({type:"source-changed",source:e})}get demSource(){return this._demSource}set demSource(e){this._demSource=e,this.loader.demSource=this._demSource,this.dispatchEvent({type:"source-changed",source:e})}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}static create(e){return new Yt(e)}update(e){const n=this._clock.getElapsedTime();if(n>this.updateInterval/1e3){this._loader.attcth(this.loader,this.projection);try{this.rootTile.update({camera:e,loader:this._loader,minLevel:this.minLevel,maxLevel:this.maxLevel,LODThreshold:this.LODThreshold}),this.rootTile.castShadow=this.castShadow,this.rootTile.receiveShadow=this.receiveShadow}catch(i){console.error("Error on loading tile data.",i)}this._clock.start(),this.dispatchEvent({type:"update",delta:n})}}reload(){this.rootTile.reload(this.loader)}dispose(){this.removeFromParent(),this.reload()}geo2pos(e){return this.geo2map(e)}geo2map(e){const n=this.projection.project(e.x,e.y);return new h.Vector3(n.x,n.y,e.z)}geo2world(e){return this.localToWorld(this.geo2map(e))}pos2geo(e){return this.map2geo(e)}map2geo(e){const n=this.projection.unProject(e.x,e.y);return new h.Vector3(n.lon,n.lat,e.z)}world2geo(e){return this.pos2geo(this.worldToLocal(e.clone()))}getLocalInfoFromGeo(e){const n=this.geo2world(e);return qn(this,n)}getLocalInfoFromWorld(e){return qn(this,e)}getLocalInfoFromScreen(e,n){return qs(e,this,n)}get downloading(){return le.downloadThreads}getTileCount(){let e=0,n=0,i=0,r=0,s=0;return this.rootTile.traverse(a=>{a.isTile&&(e++,a.isLeaf&&(r++,a.inFrustum&&n++),i=Math.max(i,a.z),s=le.downloadThreads)}),{total:e,visible:n,leaf:r,maxLevel:i,downloading:s}}}function Kt(o,t,e){if(o==null||o==="")throw new Error(e||`Parameter "${t}" is required but received: ${o}`);return o}function $n(o,t,e){const n=t.split(".");let i=o;for(const r of n){if(i[r]===void 0||i[r]===null)throw new Error(`Property "${t}" is required but missing at path: "${r}"`);i=i[r]}return i}class ei{constructor(){x(this,"_dispatcher",new h.EventDispatcher);x(this,"_listenerMap",new Map)}on(t,e){const n=i=>e(i.data||i);return this._listenerMap.has(t)||this._listenerMap.set(t,new Map),this._listenerMap.get(t).set(e,n),this._dispatcher.addEventListener(t,n),this}once(t,e){const n=i=>{this.off(t,n),e(i.data||i)};return this.on(t,n)}off(t,e){const n=this._listenerMap.get(t);if(!n)return this;const i=n.get(e);return i&&(this._dispatcher.removeEventListener(t,i),n.delete(e),n.size===0&&this._listenerMap.delete(t)),this}trigger(t,e){const n={type:t,data:e};return this._dispatcher.dispatchEvent(n),this}get threeEventDispatcher(){return this._dispatcher}}function eo(o,t){return o.replace(/\{(\w+)\}/g,(e,n)=>{if(t.hasOwnProperty(n)){const i=t[n];return i!==void 0?String(i):e}throw new Error(`缺少必要参数: ${n}`)})}function to(o,...t){for(let e=0;e<t.length;e++){const n=t[e];for(const i in n)o[i]=n[i]}return o}function no(o){return o==null}function io(o=new Date){const t=o.getFullYear().toString(),e=(o.getMonth()+1).toString().padStart(2,"0"),n=o.getDate().toString().padStart(2,"0"),i=o.getHours().toString().padStart(2,"0"),r=o.getMinutes().toString().padStart(2,"0"),s=o.getSeconds().toString().padStart(2,"0");return`${t}-${e}-${n} ${i}:${r}:${s}`}function Bt(o){return class extends o{constructor(){super(...arguments);x(this,"eventClass",new ei);x(this,"on",this.eventClass.on.bind(this.eventClass));x(this,"trigger",this.eventClass.trigger.bind(this.eventClass));x(this,"off",this.eventClass.off.bind(this.eventClass))}}}function Nt(o){return class extends o{constructor(...e){super(...e);x(this,"options");this.options={}}static mergeOptions(e){const n=this.prototype,i=Object.getPrototypeOf(n);return(!n.options||n.options===i.options)&&(n.options=n.options?Object.create(n.options):{}),to(n.options,e),this}}}const ro={attribution:"",visible:!0,opacity:1};class jt extends Bt(Nt(h.Group)){constructor(e,n){super();x(this,"_id");x(this,"opacity",1);x(this,"_animationCallbacks",new Set);Kt(e,"id","Layer id must be specified"),n&&(this.opacity=n.opacity||1),this._id=e,typeof this.animate=="function"&&this._registerAnimate()}getId(){return this._id}addTo(e){return e.addLayer(this),this}getZIndex(){return 0}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e,this.traverse(n=>{"material"in n&&(Array.isArray(n.material)?n.material:[n.material]).forEach(r=>{"opacity"in r&&(r.transparent=e<1,r.opacity=e,r.needsUpdate=!0)}),n instanceof h.Sprite&&(n.material.opacity=e,n.material.transparent=e<1,n.material.needsUpdate=!0)})}getMap(){return this.map?this.map:null}show(){return this.visible||(this.visible=!0,this.options.visible=!0,this.getMap()),this}hide(){return this.visible&&(this.visible=!1,this.options.visible=!1,this.getMap()),this}_bindMap(e){e&&(this.map=e,typeof this.animate=="function"&&this._registerAnimate())}_registerAnimate(){const e=this.getMap();if(!e?.viewer)return;const n=e.viewer.addAnimationCallback((i,r)=>{this.animate?.(i,r)});this._animationCallbacks.add(n)}_clearAnimationCallbacks(){this._animationCallbacks.forEach(e=>e()),this._animationCallbacks.clear()}}jt.mergeOptions(ro);class so extends h.Group{constructor(){super(...arguments);x(this,"_layers",new Set);x(this,"_layerids",new Set)}add(...e){return e.forEach(n=>{if(!(n instanceof jt))throw new Error("LayerContainer can only contain Layer instances!");const i=n.getId();if(this._layerids.has(i))throw new Error(`Layer with ID '${i}' already exists in the container!`);this._layers.add(n),this._layerids.add(i),super.add(n)}),this}remove(...e){return e.forEach(n=>{this._layers.delete(n),super.remove(n)}),this}getLayers(){return Array.from(this._layers)}getLayerById(e){for(const n of this._layers)if(n.getId()===e)return n}clearLayers(){return this._layers.clear(),super.clear(),this}}class oo{constructor(){x(this,"canvasDict",{})}getCanvas(t=40,e=30,n){const i=n?`${t}_${e}_${n}`:`${t}_${e}`;if(!this.canvasDict[i])this.canvasDict[i]=document.createElement("canvas"),this.canvasDict[i].width=t,this.canvasDict[i].height=e;else{const r=this.canvasDict[i],s=r.getContext("2d");r.width=t,r.height=e,s.clearRect(0,0,t,e)}return this.canvasDict[i]}clearCache(t,e,n){const i=n?`${t}_${e}_${n}`:`${t}_${e}`;delete this.canvasDict[i]}}class ao{}let ft=class _i extends Bt(Nt(ao)){constructor(e,n){super();x(this,"viewer");x(this,"tilemap");x(this,"center");x(this,"options");x(this,"_layerContainer");x(this,"_EventMap",{loaded:{listened:!1}});x(this,"_canvasManager",new oo);x(this,"_onLoadHooks");Kt(e,"container","Map container element must be specified");const i=["center","meshmap"];for(const b of i)$n(n,b);const r={viewer:{antialias:!0,stencil:!0,logarithmicDepthBuffer:!0}};this.options={...n,viewer:{...r.viewer,...n.viewer}},this.center=this.options.center,this.viewer=new Cn(e,this.options.viewer),this.tilemap=this.initTileMap(this.options.meshmap),this.tilemap.receiveShadow=!0,this.viewer.scene.add(this.tilemap);const s=this.tilemap.geo2world(new h.Vector3(this.center[0],this.center[1],0)),a=this.tilemap.geo2world(new h.Vector3(this.center[0],this.center[1]-.01,this.center[2]||1e3));this.viewer.camera.position.copy(a),this.viewer.controls.target.copy(s),this._layerContainer=new so,this.viewer.scene.add(this._layerContainer);const l=2,u=1,d=.5,c=3e3,p=5,f=1,m=c*3.5,v=3,g=-1e-4;this.viewer.dirLight.position.set(s.x+c*l,c*u*2,s.z+c*d),this.viewer.dirLight.target.position.copy(s),this.viewer.dirLight.castShadow=!0,this.viewer.dirLight.shadow.mapSize.width=1024*p,this.viewer.dirLight.shadow.mapSize.height=1024*p,this.viewer.dirLight.shadow.camera.near=f,this.viewer.dirLight.shadow.camera.far=m,this.viewer.dirLight.shadow.camera.left=-3e3,this.viewer.dirLight.shadow.camera.bottom=-3e3,this.viewer.dirLight.shadow.camera.top=c,this.viewer.dirLight.shadow.camera.right=c,this.viewer.dirLight.shadow.radius=v,this.viewer.dirLight.shadow.bias=g,this.viewer.dirLight.name="平行光",this.viewer.dirLight.intensity=3,this._callOnLoadHooks()}static addOnLoadHook(e,...n){const i=typeof e=="function"?e:function(){this[e].apply(this,n)},r=this.prototype;return r._onLoadHooks=r._onLoadHooks||[],r._onLoadHooks.push(i),this}_callOnLoadHooks(){const e=_i.prototype;if(e._onLoadHooks)for(let n=0,i=e._onLoadHooks.length;n<i;n++)e._onLoadHooks[n].call(this)}initTileMap(e){const n=new Yt({...e});return n.rotateX(-Math.PI/2),n.receiveShadow=!0,n.addEventListener("ready",()=>{const i={timestamp:io(),targrt:this};this._EventMap.loaded={listened:!0},this.trigger("loaded",i)}),n}addLayer(e,...n){if(!e)return this;Array.isArray(e)||(e=[e]),n?.length&&(e=e.concat(n));const i=this._layerContainer;for(let r=0,s=e.length;r<s;r++){const a=e[r],l=a.getId();if(no(l))throw new Error("Invalid id for the layer: "+l);a._bindMap(this),i.add(a)}return this}clearLayers(){return this._layerContainer.clear(),this._layerContainer}getLayers(){return this._layerContainer.getLayers()}getLayerById(e){return this._layerContainer.getLayerById(e)}geo2world(e){return this.tilemap.geo2world(e)}world2geo(e){return this.tilemap.world2geo(e)}_getCanvas(e=40,n=30,i){return this._canvasManager.getCanvas(e,n,i)}};function lo(o,t,e){const{currentTarget:n,clientX:i,clientY:r}=o;if(n instanceof HTMLElement){const s=n.clientWidth,a=n.clientHeight,l=new h.Vector2(i/s*2-1,-(r/a)*2+1);return t.getLocalInfoFromScreen(e,l)?.location}else return}const co=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout"];ft.prototype._removeDomEvents=function(){console.log("removeDomEvents",this)},ft.prototype._registerDomEvents=function(){const o=this.viewer.container;o&&co.forEach(t=>{o.addEventListener(t,e=>{let n=lo(e,this.tilemap,this.viewer.camera),i={targrt:this,originEvent:e,eventName:t,screenXY:{X:e.screenX,Y:e.screenY}};if(n){let r=[n.x,n.y,n.z];i={targrt:this,originEvent:e,coordiante:r,eventName:t,screenXY:{X:e.screenX,Y:e.screenY}}}this.trigger(t,i)})})},ft.addOnLoadHook("_registerDomEvents");class uo extends We{constructor(e){super(e);x(this,"dataType","image");x(this,"attribution","天地图");x(this,"token","");x(this,"style","img_w");x(this,"subdomains","01234");x(this,"url","https://t{s}.tianditu.gov.cn/DataServer?T={style}&x={x}&y={y}&l={z}&tk={token}");Object.assign(this,e)}}class ho extends We{constructor(e){super(e);x(this,"dataType","quantized-mesh");x(this,"attribution","天地图");x(this,"token","");x(this,"subdomains","01234");x(this,"url","https://t{s}.tianditu.gov.cn/mapservice/swdx?T=elv_c&tk={token}&x={x}&y={y}&l={z}");Object.assign(this,e)}}class po extends We{constructor(e){super({...e,url:e.urlTemplate,isTMS:e.isTMS||!1});x(this,"minLevel",2);x(this,"maxLevel",24)}getUrl(e,n,i){const r=this.isTMS?Math.pow(2,i)-1-n:n;return eo(this.url,{...this,x:e,y:r,z:i,tileMatrix:i,tileRow:r,tileCol:e})}}class fo extends We{constructor(e){super(e);x(this,"dataType","image");x(this,"attribution","ArcGIS");x(this,"style","World_Imagery");x(this,"url","https://services.arcgisonline.com/arcgis/rest/services/{style}/MapServer/tile/{z}/{y}/{x}");Object.assign(this,e)}}class mo extends We{constructor(e){super(e);x(this,"dataType","lerc");x(this,"attribution","ArcGIS");x(this,"minLevel",6);x(this,"maxLevel",13);x(this,"url","https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer/tile/{z}/{y}/{x}");Object.assign(this,e)}}class yo extends We{constructor(e){super(e);x(this,"token","");x(this,"format","webp");x(this,"style","cm2myr6qx001t01pi0sf7estf");x(this,"attribution","MapBox");x(this,"maxLevel",25);x(this,"url","https://api.mapbox.com/styles/v1/criska/cm2myr6qx001t01pi0sf7estf/tiles/256/{z}/{x}/{y}?access_token={token}&format={format}");Object.assign(this,e)}}const vt=class vt{constructor(t){x(this,"_cache",new Map);x(this,"_gltfLoader");x(this,"_fbxLoader");x(this,"_dracoLoader");this._gltfLoader=new qi(t),this._fbxLoader=new Xr(t)}static init(t){return this._instance||(this._instance=new vt(t)),this._instance}async load(t){const e=`${t.type}:${t.url}`;if(this._cache.has(e))return this._cloneCachedModel(e,t);t.type==="gltf"&&t.dracoOptions?.enable&&this._initDracoLoader(t.dracoOptions.decoderPath);let n,i;try{if(t.type==="gltf"){const r=await this._gltfLoader.loadAsync(t.url);n=r.scene,i=r.animations}else n=await this._fbxLoader.loadAsync(t.url),i=n.animations;return this._cache.set(e,{model:n,animations:i}),{model:this._processModel(n.clone(),t),animations:i?.map(r=>({...r,name:r.name||"unnamed"}))||[]}}catch(r){throw console.error(`Failed to load ${t.type} model:`,t.url,r),r}}_initDracoLoader(t="/draco/"){this._dracoLoader||(this._dracoLoader=new $r,this._dracoLoader.setDecoderPath(t),this._gltfLoader.setDRACOLoader(this._dracoLoader))}_cloneCachedModel(t,e){const i=this._cache.get(t).model.clone();return this._processModel(i,e)}_processModel(t,e){return e.position&&t.position.copy(e.position),e.scale&&(typeof e.scale=="number"?t.scale.setScalar(e.scale):e.scale.x!==void 0||e.scale.y!==void 0||e.scale.z!==void 0?(e.scale.x!==void 0&&(t.scale.x=e.scale.x),e.scale.y!==void 0&&(t.scale.y=e.scale.y),e.scale.z!==void 0&&(t.scale.z=e.scale.z)):t.scale.copy(e.scale)),e.rotation&&t.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.materialOverrides&&t.traverse(n=>{if(n instanceof h.Mesh&&n.material){const i=e.materialOverrides[n.name];i&&(n.material=i)}}),t.traverse(n=>{n instanceof h.Mesh&&n.material}),t}};x(vt,"_instance");let Rt=vt;const Jt=(o,t)=>{"updateRanges"in o?o.updateRanges[0]=t:o.updateRange=t},ti=new h.Matrix4,mt=new h.Vector3,yt=new h.Quaternion,ni=new h.Vector3,ii=new h.Quaternion,qe=new h.Vector3,go=o=>class extends o{constructor(){super();const t=parseInt(h.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=e=>{e.vertexShader=`attribute float cloudOpacity;
620
+ `,clipping:!0}),this.isLineMaterial=!0,this.onBeforeCompile=function(){this.transparent?this.defines.USE_LINE_COLOR_ALPHA="1":delete this.defines.USE_LINE_COLOR_ALPHA},Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},worldUnits:{enumerable:!0,get:function(){return"WORLD_UNITS"in this.defines},set:function(t){t===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(t){!!t!="USE_DASH"in this.defines&&(this.needsUpdate=!0),t===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return"USE_ALPHA_TO_COVERAGE"in this.defines},set:function(t){!!t!="USE_ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),t===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}const Ao=new p.Vector4,uc=new p.Vector3,hc=new p.Vector3,Ee=new p.Vector4,$e=new p.Vector4,dn=new p.Vector4,Fo=new p.Vector3,Oo=new p.Matrix4,qe=new p.Line3,dc=new p.Vector3,is=new p.Box3,ss=new p.Sphere,fn=new p.Vector4;let pn,mr;function fc(i,e,t){return fn.set(0,0,-e,1).applyMatrix4(i.projectionMatrix),fn.multiplyScalar(1/fn.w),fn.x=mr/t.width,fn.y=mr/t.height,fn.applyMatrix4(i.projectionMatrixInverse),fn.multiplyScalar(1/fn.w),Math.abs(Math.max(fn.x,fn.y))}function em(i,e){const t=i.matrixWorld,n=i.geometry,r=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=Math.min(n.instanceCount,r.count);for(let c=0,u=a;c<u;c++){qe.start.fromBufferAttribute(r,c),qe.end.fromBufferAttribute(o,c),qe.applyMatrix4(t);const d=new p.Vector3,m=new p.Vector3;pn.distanceSqToSegment(qe.start,qe.end,m,d),m.distanceTo(d)<mr*.5&&e.push({point:m,pointOnLine:d,distance:pn.origin.distanceTo(m),object:i,face:null,faceIndex:c,uv:null,[vo]:null})}}function tm(i,e,t){const n=e.projectionMatrix,o=i.material.resolution,a=i.matrixWorld,c=i.geometry,u=c.attributes.instanceStart,d=c.attributes.instanceEnd,m=Math.min(c.instanceCount,u.count),f=-e.near;pn.at(1,dn),dn.w=1,dn.applyMatrix4(e.matrixWorldInverse),dn.applyMatrix4(n),dn.multiplyScalar(1/dn.w),dn.x*=o.x/2,dn.y*=o.y/2,dn.z=0,Fo.copy(dn),Oo.multiplyMatrices(e.matrixWorldInverse,a);for(let g=0,_=m;g<_;g++){if(Ee.fromBufferAttribute(u,g),$e.fromBufferAttribute(d,g),Ee.w=1,$e.w=1,Ee.applyMatrix4(Oo),$e.applyMatrix4(Oo),Ee.z>f&&$e.z>f)continue;if(Ee.z>f){const C=Ee.z-$e.z,Z=(Ee.z-f)/C;Ee.lerp($e,Z)}else if($e.z>f){const C=$e.z-Ee.z,Z=($e.z-f)/C;$e.lerp(Ee,Z)}Ee.applyMatrix4(n),$e.applyMatrix4(n),Ee.multiplyScalar(1/Ee.w),$e.multiplyScalar(1/$e.w),Ee.x*=o.x/2,Ee.y*=o.y/2,$e.x*=o.x/2,$e.y*=o.y/2,qe.start.copy(Ee),qe.start.z=0,qe.end.copy($e),qe.end.z=0;const b=qe.closestPointToPointParameter(Fo,!0);qe.at(b,dc);const x=p.MathUtils.lerp(Ee.z,$e.z,b),L=x>=-1&&x<=1,M=Fo.distanceTo(dc)<mr*.5;if(L&&M){qe.start.fromBufferAttribute(u,g),qe.end.fromBufferAttribute(d,g),qe.start.applyMatrix4(a),qe.end.applyMatrix4(a);const C=new p.Vector3,Z=new p.Vector3;pn.distanceSqToSegment(qe.start,qe.end,Z,C),t.push({point:Z,pointOnLine:C,distance:pn.origin.distanceTo(Z),object:i,face:null,faceIndex:g,uv:null,[vo]:null})}}}class nm extends p.Mesh{constructor(e=new cc,t=new mi({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let a=0,c=0,u=t.count;a<u;a++,c+=2)uc.fromBufferAttribute(t,a),hc.fromBufferAttribute(n,a),r[c]=c===0?0:r[c-1],r[c+1]=r[c]+uc.distanceTo(hc);const o=new p.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new p.InterleavedBufferAttribute(o,1,0)),e.setAttribute("instanceDistanceEnd",new p.InterleavedBufferAttribute(o,1,1)),this}raycast(e,t){const n=this.material.worldUnits,r=e.camera;r===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;pn=e.ray;const a=this.matrixWorld,c=this.geometry,u=this.material;mr=u.linewidth+o,c.boundingSphere===null&&c.computeBoundingSphere(),ss.copy(c.boundingSphere).applyMatrix4(a);let d;if(n)d=mr*.5;else{const f=Math.max(r.near,ss.distanceToPoint(pn.origin));d=fc(r,f,u.resolution)}if(ss.radius+=d,pn.intersectsSphere(ss)===!1)return;c.boundingBox===null&&c.computeBoundingBox(),is.copy(c.boundingBox).applyMatrix4(a);let m;if(n)m=mr*.5;else{const f=Math.max(r.near,is.distanceToPoint(pn.origin));m=fc(r,f,u.resolution)}is.expandByScalar(m),pn.intersectsBox(is)!==!1&&(n?em(this,t):tm(this,r,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Ao),this.material.uniforms.resolution.value.set(Ao.z,Ao.w))}}class gi extends nm{constructor(e=new rs,t=new mi({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}var Un=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return this.None(i)},Out:function(i){return this.None(i)},InOut:function(i){return this.None(i)}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i+e)+2)}}),Bounce:Object.freeze({In:function(i){return 1-Un.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?Un.Bounce.In(i*2)*.5:Un.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),yi=function(){return performance.now()},rm=function(){function i(){this._tweens={},this._tweensAddedDuringUpdate={}}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},i.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},i.prototype.update=function(e,t){e===void 0&&(e=yi()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var o=this._tweens[n[r]],a=!t;o&&o.update(e,a)===!1&&!t&&delete this._tweens[n[r]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},i}(),Do={Linear:function(i,e){var t=i.length-1,n=t*e,r=Math.floor(n),o=Do.Utils.Linear;return e<0?o(i[0],i[1],n):e>1?o(i[t],i[t-1],t-n):o(i[r],i[r+1>t?t:r+1],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i}}},pc=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),zo=new rm,os=function(){function i(e,t){t===void 0&&(t=zo),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Un.Linear.None,this._interpolationFunction=Do.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=pc.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=yi()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var r={};for(var o in this._valuesEnd)r[o]=this._valuesEnd[o];this._valuesEnd=r}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,n,r,o){for(var a in n){var c=e[a],u=Array.isArray(c),d=u?"array":typeof c,m=!u&&Array.isArray(n[a]);if(!(d==="undefined"||d==="function")){if(m){var f=n[a];if(f.length===0)continue;for(var g=[c],_=0,w=f.length;_<w;_+=1){var b=this._handleRelativeValue(c,f[_]);if(isNaN(b)){m=!1,console.warn("Found invalid interpolation list. Skipping.");break}g.push(b)}m&&(n[a]=g)}if((d==="object"||u)&&c&&!m){t[a]=u?[]:{};var x=c;for(var L in x)t[a][L]=x[L];r[a]=u?[]:{};var f=n[a];if(!this._isDynamic){var M={};for(var L in f)M[L]=f[L];n[a]=f=M}this._setupProperties(x,t[a],f,r[a],o)}else(typeof t[a]>"u"||o)&&(t[a]=c),u||(t[a]*=1),m?r[a]=n[a].slice().reverse():r[a]=t[a]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},i.prototype.pause=function(e){return e===void 0&&(e=yi()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},i.prototype.resume=function(e){return e===void 0&&(e=yi()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},i.prototype.group=function(e){return e===void 0&&(e=zo),this._group=e,this},i.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},i.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},i.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},i.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},i.prototype.easing=function(e){return e===void 0&&(e=Un.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=Do.Linear),this._interpolationFunction=e,this},i.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},i.prototype.onStart=function(e){return this._onStartCallback=e,this},i.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},i.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},i.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},i.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},i.prototype.onStop=function(e){return this._onStopCallback=e,this},i.prototype.update=function(e,t){var n=this,r;if(e===void 0&&(e=yi()),t===void 0&&(t=!0),this._isPaused)return!0;var o,a=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>a)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var c=e-this._startTime,u=this._duration+((r=this._repeatDelayTime)!==null&&r!==void 0?r:this._delayTime),d=this._duration+this._repeat*u,m=function(){if(n._duration===0||c>d)return 1;var x=Math.trunc(c/u),L=c-x*u,M=Math.min(L/n._duration,1);return M===0&&c===n._duration?1:M},f=m(),g=this._easingFunction(f);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,g),this._onUpdateCallback&&this._onUpdateCallback(this._object,f),this._duration===0||c>=this._duration)if(this._repeat>0){var _=Math.min(Math.trunc((c-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=_);for(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=u*_,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var w=0,b=this._chainedTweens.length;w<b;w++)this._chainedTweens[w].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},i.prototype._updateProperties=function(e,t,n,r){for(var o in n)if(t[o]!==void 0){var a=t[o]||0,c=n[o],u=Array.isArray(e[o]),d=Array.isArray(c),m=!u&&d;m?e[o]=this._interpolationFunction(c,r):typeof c=="object"&&c?this._updateProperties(e[o],a,c,r):(c=this._handleRelativeValue(a,c),typeof c=="number"&&(e[o]=a+(c-a)*r))}},i.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},i.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i}();pc.nextId;var mn=zo;mn.getAll.bind(mn),mn.removeAll.bind(mn),mn.add.bind(mn),mn.remove.bind(mn);var im=mn.update.bind(mn);function Xo(i,e,t){if(i==null||i==="")throw new Error(t||`Parameter "${e}" is required but received: ${i}`);return i}function mc(i,e,t){const n=e.split(".");let r=i;for(const o of n){if(r[o]===void 0||r[o]===null)throw new Error(`Property "${e}" is required but missing at path: "${o}"`);r=r[o]}return r}function sm(i,e,t,n=0,r=1){const o=(i-e)*(r-n)/(t-e)+n,a=Math.min(n,r),c=Math.max(n,r);return o<a?a:o>c?c:o||0}var om=Object.defineProperty,am=(i,e,t)=>e in i?om(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,gc=(i,e,t)=>am(i,typeof e!="symbol"?e+"":e,t);class Uo{constructor(){gc(this,"_dispatcher",new p.EventDispatcher),gc(this,"_listenerMap",new Map)}on(e,t){const n=r=>t(r.data||r);return this._listenerMap.has(e)||this._listenerMap.set(e,new Map),this._listenerMap.get(e).set(t,n),this._dispatcher.addEventListener(e,n),this}once(e,t){const n=r=>{this.off(e,n),t(r.data||r)};return this.on(e,n)}off(e,t){const n=this._listenerMap.get(e);if(!n)return this;const r=n.get(t);return r&&(this._dispatcher.removeEventListener(e,r),n.delete(t),n.size===0&&this._listenerMap.delete(e)),this}trigger(e,t){const n={type:e,data:t};return this._dispatcher.dispatchEvent(n),this}get threeEventDispatcher(){return this._dispatcher}}function lm(i,e){return i.replace(/\{(\w+)\}/g,(t,n)=>{if(e.hasOwnProperty(n)){const r=e[n];return r!==void 0?String(r):t}throw new Error(`缺少必要参数: ${n}`)})}function ko(i,...e){for(let t=0;t<e.length;t++){const n=e[t];for(const r in n)i[r]=n[r]}return i}function as(i){return i==null}function _i(i){return as(i)?!1:typeof i=="function"||i.constructor!==null&&i.constructor===Function}function yc(i=new Date){const e=i.getFullYear().toString(),t=(i.getMonth()+1).toString().padStart(2,"0"),n=i.getDate().toString().padStart(2,"0"),r=i.getHours().toString().padStart(2,"0"),o=i.getMinutes().toString().padStart(2,"0"),a=i.getSeconds().toString().padStart(2,"0");return`${e}-${t}-${n} ${r}:${o}:${a}`}var cm=Object.defineProperty,um=(i,e,t)=>e in i?cm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ko=(i,e,t)=>um(i,typeof e!="symbol"?e+"":e,t);class hm{}class ls extends Kn(gr(hm)){constructor(e){super(),Ko(this,"target"),Ko(this,"dom"),Ko(this,"_enabled",!1),this.target=e}enable(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)}disable(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this}enabled(){return!!this._enabled}remove(){this.disable(),delete this.target,delete this.dom}}const _c=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]"&&!process.versions.electron&&!process.versions.nw&&!process.versions["node-webkit"];let vi={};function vc(){return window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI}if(!_c){const i=navigator.userAgent.toLowerCase(),e=document.documentElement||{style:{}},t="ActiveXObject"in window,n=i.indexOf("webkit")!==-1,r=i.indexOf("phantom")!==-1,o=i.search("android [23]")!==-1,a=i.indexOf("chrome")!==-1,c=i.indexOf("gecko")!==-1&&!n&&!("opera"in window)&&!t,u=/iphone/i.test(i)&&/micromessenger/i.test(i),d=typeof orientation<"u"||i.indexOf("mobile")!==-1,m=!window.PointerEvent&&"MSPointerEvent"in window,f=window.PointerEvent&&navigator.pointerEnabled||m,g=t&&"transition"in e.style,_="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!o,w="MozPerspective"in e.style,b="OTransition"in e.style,x=(g||_||w)&&!b&&!r,L=typeof window<"u"&&_i(window.createImageBitmap),M=typeof window<"u"&&_i(window.ResizeObserver),C=typeof window<"u"&&_i(window.btoa),Z=typeof window<"u"&&_i(window.Proxy),z=typeof window<"u"&&_i(window.requestIdleCallback);let D=0;if(a){const k=i.match(/chrome\/([\d.]+)/);D=k?k[1]:0}const X=!r&&(f||"ontouchstart"in window||"DocumentTouch"in window&&document instanceof window.DocumentTouch),I=typeof window<"u"&&"WebGLRenderingContext"in window,K=vc();let V=!1;try{new OffscreenCanvas(2,2).getContext("2d"),V=!0}catch{V=!1}let G=!1;try{window.addEventListener("testPassive",()=>{},{get passive(){return G=!0,!0}})}catch{}vi={IS_NODE:_c,isTest:!1,ie:t,ielt9:t&&!document.addEventListener,edge:"msLaunchUri"in navigator&&!("documentMode"in document),webkit:n,gecko:c,android:i.indexOf("android")!==-1,android23:o,chrome:a,chromeVersion:D,safari:!a&&i.indexOf("safari")!==-1,phantomjs:r,ie3d:g,webkit3d:_,gecko3d:w,opera12:b,any3d:x,iosWeixin:u,mobile:d,mobileWebkit:d&&n,mobileWebkit3d:d&&_,mobileOpera:d&&"opera"in window,mobileGecko:d&&c,touch:!!X,msPointer:!!m,pointer:!!f,retina:K>1,devicePixelRatio:K,language:navigator.browserLanguage?navigator.browserLanguage:navigator.language,ie9:t&&document.documentMode===9,ie10:t&&document.documentMode===10,webgl:I,imageBitMap:L,resizeObserver:M,btoa:C,decodeImageInWorker:V,monitorDPRChange:!0,supportsPassive:G,proxy:Z,requestIdleCallback:z,checkDevicePixelRatio:()=>{if(typeof window<"u"&&vi.monitorDPRChange){const k=vc(),j=k!==vi.devicePixelRatio;return j&&(vi.devicePixelRatio=k),j}return!1}}}const dm=vi;var fm=Object.defineProperty,pm=(i,e,t)=>e in i?fm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,kn=(i,e,t)=>pm(i,typeof e!="symbol"?e+"":e,t);function Kn(i){return class extends i{constructor(...e){super(...e),kn(this,"eventClass",new Uo),kn(this,"on",this.eventClass.on.bind(this.eventClass)),kn(this,"trigger",this.eventClass.trigger.bind(this.eventClass)),kn(this,"off",this.eventClass.off.bind(this.eventClass)),this.eventClass=new Uo}}}function gr(i){return class extends i{constructor(...e){super(...e),kn(this,"options"),kn(this,"_isUpdatingOptions"),kn(this,"_initHooksCalled"),kn(this,"_initHooks");const t=Object.getPrototypeOf(this).options||{},n=ko({},t,e[0]||{});this.setOptions(n),this.callInitHooks(),this._isUpdatingOptions=!1}proxyOptions(){return dm.proxy?(this.options=new Proxy(this.options,{set:(e,t,n)=>{if(t=t,e[t]===n||(e[t]=n,this._isUpdatingOptions))return!0;const r={};return r[t]=n,this.config(r),!0}}),this):this}callInitHooks(){const e=Object.getPrototypeOf(this);return this._visitInitHooks(e),this}setOptions(e){if((!this.hasOwnProperty("options")||as(this.options))&&(this.options=this.options?Object.create(this.options):{}),!e)return this;for(const t in e)this.options[t]=e[t];return this}config(e,t){if(this._isUpdatingOptions=!0,e){if(arguments.length===2&&typeof e=="string"){const n={};n[e]=t,e=n}e=e;for(const n in e)this.options[n]=e[n],this[n]&&this[n]instanceof ls&&(e[n]?this[n].enable():this[n].disable());this.onConfig(e),this._isUpdatingOptions=!1}else{const n={};for(const r in this.options)this.options.hasOwnProperty(r)&&(n[r]=this.options[r]);return this._isUpdatingOptions=!1,n}return this}onConfig(e){}_visitInitHooks(e){if(this._initHooksCalled)return;const t=Object.getPrototypeOf(e);t._visitInitHooks&&t._visitInitHooks.call(this,t),this._initHooksCalled=!0;const n=e._initHooks;if(n&&n!==t._initHooks)for(let r=0;r<n.length;r++)n[r].call(this)}static mergeOptions(e){const t=this.prototype,n=Object.getPrototypeOf(t);return t.hasOwnProperty("options")?t.options===n.options&&(t.options=Object.create(t.options)):t.options={},ko(t.options,e),this}static addInitHook(e,...t){const n=typeof e=="function"?e:function(){this[e].apply(this,t)},r=this.prototype,o=Object.getPrototypeOf(r);return(!r._initHooks||r._initHooks===o._initHooks)&&(r._initHooks=[]),r._initHooks.push(n),this}static include(...e){for(let t=0;t<e.length;t++)ko(this.prototype,e[t]);return this}}}var mm=Object.defineProperty,gm=(i,e,t)=>e in i?mm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ie=(i,e,t)=>gm(i,typeof e!="symbol"?e+"":e,t);const ym=Kn(gr(p.EventDispatcher));class wc extends ym{constructor(e,t={}){super(),Ie(this,"scene"),Ie(this,"renderer"),Ie(this,"camera"),Ie(this,"controls"),Ie(this,"ambLight"),Ie(this,"dirLight"),Ie(this,"auxDirLight"),Ie(this,"clouds",null),Ie(this,"container"),Ie(this,"_clock",new p.Clock),Ie(this,"stats"),Ie(this,"_animationCallbacks",new Set),Ie(this,"_fogFactor",1),Ie(this,"_sceneSize",5e4*2),Ie(this,"gorund"),Ie(this,"map"),Ie(this,"centerPostion"),Ie(this,"_isInteracting",!1),Ie(this,"debug",!1),Ie(this,"flyTween",null),Ie(this,"composer"),Ie(this,"renderPass"),Ie(this,"bloomPass"),Ie(this,"calculateCameraPosition",(g,_,w,b)=>{const x=new p.Vector3(0,_*Math.cos(w),_*Math.sin(w));return x.applyAxisAngle(new p.Vector3(0,1,0),b),new p.Vector3(g.x+x.x,g.y+x.y,g.z+x.z)}),this.setOptions(t);const{antialias:n=!1,stencil:r=!0,logarithmicDepthBuffer:o=!0,skybox:a,map:c,bloom:u,minDistance:d,maxDistance:m,draggable:f=!0}=t;if(this.map=c,this.centerPostion=this.map.geo2world(new p.Vector3(this.map.center[0],this.map.center[1],0)),this.renderer=this._createRenderer(n,r,o),this.scene=this._createScene(a),this.camera=this._createCamera(),e&&this.addTo(e),this.controls=this._createControls(d,m),this.controls.enabled=f!==!1,this.ambLight=this._createAmbLight(),this.scene.add(this.ambLight),this.dirLight=this._createDirLight(),this.scene.add(this.dirLight),this.scene.add(this.dirLight.target),this.auxDirLight=this._createAuxDirLight(),this.gorund=this._createGorund(),this.scene.add(this.gorund),u&&u.enabled){const g=this.renderer.getPixelRatio(),_=this.container?this.width:window.innerWidth,w=this.container?this.height:window.innerHeight,b=_*g,x=w*g,L=new p.WebGLRenderTarget(b,x,{format:p.RGBAFormat});L.samples=4,this.composer=new Rf(this.renderer,L),this.renderPass=new Qf(this.scene,this.camera),this.composer.addPass(this.renderPass);const M=u?.strength??1.5,C=u?.radius??1,Z=u?.threshold??.7;this.bloomPass=new Uf(new p.Vector2(b,x),M,C,Z),this.composer.addPass(this.bloomPass)}this.renderer.setAnimationLoop(this.animate.bind(this)),this.debug=t.debug||!1,this.flyTween=null,this.debug&&(this.stats=new ui,document.body.appendChild(this.stats.dom))}get fogFactor(){return this._fogFactor}get isInteracting(){return this._isInteracting}set fogFactor(e){this._fogFactor=e,this.controls.dispatchEvent({type:"change",target:this.controls})}get width(){return this.container?.clientWidth||0}get height(){return this.container?.clientHeight||0}addTo(e){const t=typeof e=="string"?document.querySelector(e):e;if(t instanceof HTMLElement)this.container=t,t.appendChild(this.renderer.domElement),new ResizeObserver(this.resize.bind(this)).observe(t);else throw`${e} not found!}`;return this}_createScene(e){const t=new p.Scene,n=e?.defaultColor||"rgb(21,48,94)";if(t.background=new p.Color(n),t.fog=new p.FogExp2(n,2e-4),e?.files){const r=new p.CubeTextureLoader;e.path&&r.setPath(e.path),r.load(e.files,o=>{t.background=o},void 0,o=>{console.error("Error loading skybox:",o),t.background=new p.Color(n)})}else e?.hdr&&this._loadHDRWithPMREM(t,e);return t}async _loadHDRWithPMREM(e,t){try{if(t){const r=await new Ep().setPath(t.path||"").setDataType(p.FloatType).loadAsync(t.hdr);r.colorSpace=this.renderer.outputColorSpace,r.mapping=303,r.needsUpdate=!0,e.background=r,e.environment=r}}catch(n){console.error("加载HDR失败:",n),e.background=new p.Color(t?.defaultColor||14414079)}}_createRenderer(e,t,n){const r=new p.WebGLRenderer({antialias:e,logarithmicDepthBuffer:n,stencil:t,alpha:!0,precision:"highp",powerPreference:"high-performance",failIfMajorPerformanceCaveat:!0});return r.debug.checkShaderErrors=!0,r.sortObjects=!0,r.setPixelRatio(window.devicePixelRatio),r.domElement.tabIndex=0,r.shadowMap.enabled=!0,r.shadowMap.needsUpdate=!0,r.shadowMap.type=p.PCFSoftShadowMap,r.toneMapping=p.ACESFilmicToneMapping,r.toneMappingExposure=1,r.outputColorSpace=p.SRGBColorSpace,r}_createCamera(){return new p.PerspectiveCamera(45,this.getAspect(),.1,this._sceneSize*2)}_createControls(e,t){const n=new Vf(this.camera,this.renderer.domElement),r=Math.PI/2.1;return n.screenSpacePanning=!1,n.minDistance=e??.1,n.maxDistance=t??6e4,n.maxPolarAngle=r,n.enableDamping=!0,n.dampingFactor=.08,n.keyPanSpeed=1,n.listenToKeyEvents(this.renderer.domElement),n.addEventListener("change",()=>{const o=Math.max(n.getPolarAngle(),.1),a=Math.max(n.getDistance(),100);n.zoomSpeed=Math.max(Math.log(a/1e3),1)+3;const c=3e5*2;n.maxDistance>c*.95&&(n.maxDistance=c*.95),this.camera.far=p.MathUtils.clamp(a/o*8,100,c),this.camera.near=p.MathUtils.clamp(this.camera.far/1e3,.001,1),this.camera.updateProjectionMatrix(),this.scene.fog instanceof p.FogExp2&&(this.scene.fog.density=o/(a+5)*this.fogFactor*.1);const d=a>6e4;n.minAzimuthAngle=d?0:-1/0,n.maxAzimuthAngle=d?0:1/0,n.maxPolarAngle=sm(n.getDistance(),0,7e4,r,0),this.map?.trigger("control-change",{type:"control-change",control:n,camera:this.camera,target:this.map})}),n.addEventListener("start",()=>{this._isInteracting=!0,this.map?.trigger("control-start",{type:"control-start",control:n,camera:this.camera,target:this.map})}),n.addEventListener("end",()=>{this._isInteracting=!1,this.map?.trigger("control-end",{type:"control-end",control:n,camera:this.camera,target:this.map})}),n}_createAmbLight(){return new p.AmbientLight(16777215,.1)}_createDirLight(){const f=new p.DirectionalLight("rgb(255, 255, 255)",3);f.position.set(this.centerPostion.x+55e3*1.2,55e3*2,this.centerPostion.z+55e3*1);const g=new p.Object3D;if(g.position.copy(this.centerPostion),this.scene.add(g),f.target=g,f.castShadow=!0,f.shadow.mapSize.width=1024*10,f.shadow.mapSize.height=1024*10,f.shadow.camera.near=1,f.shadow.camera.far=192500,f.shadow.camera.left=-55e3,f.shadow.camera.bottom=-55e3,f.shadow.camera.top=55e3,f.shadow.camera.right=55e3,f.shadow.radius=1,f.shadow.bias=-0,this.debug){const _=new p.CameraHelper(f.shadow.camera);_.name="dirLightCameraHelper",this.scene.add(_)}return f}_createAuxDirLight(){const a=this._createAuxLightInstance(this.centerPostion.x+-66e3,82500,this.centerPostion.z+-55e3,.5);a.name="AuxDirLight_BackFill",this.scene.add(a),this.scene.add(a.target);const m=this._createAuxLightInstance(this.centerPostion.x+55e3*-1,55e3*1.5,this.centerPostion.z+55e3*1.2,.5);m.name="AuxDirLight_LeftRim",this.scene.add(m),this.scene.add(m.target);const w=this._createAuxLightInstance(this.centerPostion.x+55e3*1,55e3*1.5,this.centerPostion.z+55e3*-1.2,.5);return w.name="AuxDirLight_RightRim",this.scene.add(w),this.scene.add(w.target),a}_createAuxLightInstance(e,t,n,r){const o=new p.DirectionalLight(16777215,r);o.position.set(e,t,n);const a=new p.Object3D;return a.position.copy(this.centerPostion),this.scene.add(a),o.target=a,o.castShadow=!1,o}resize(){const e=this.width,t=this.height;if(this.renderer.setSize(e,t),this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.composer){const n=this.renderer.getPixelRatio();this.composer.setSize(e*n,t*n),this.composer.render()}else this.renderer.render(this.scene,this.camera);return this}addAnimationCallback(e){return this._animationCallbacks.add(e),()=>this._animationCallbacks.delete(e)}animate(){const e=this._clock.getDelta(),t=this._clock.getElapsedTime();this._animationCallbacks.forEach(n=>n(e,t,this)),this.controls.update(),this.composer?this.composer.render():this.renderer.render(this.scene,this.camera),im(),this.stats&&this.stats.update(),this.dispatchEvent({type:"update",delta:e})}flyTo(e,t,n=!0,r){if(this.controls.target.copy(e),n){const o=this.camera.position;new os(o).to({y:2e7,z:0},500).chain(new os(o).to(t,2e3).easing(Un.Quintic.Out).onComplete(a=>r&&r(a))).start()}else this.camera.position.copy(t)}flyToAdvanced(e){const t=this.camera,n=this.controls,r=e.center,o=e.cameraCoord,a=e.duration??2e3,c=e.delay??0,u=e.complete,d=!!e.curvePath;if(!r||!o)return;const m=this.map.geo2world(new p.Vector3(r[0],r[1],0)),f=this.map.geo2world(new p.Vector3(o[0],o[1],o[2]));if(!t||!n||!m||!f)return;const g=n.target.clone(),_=t.position.clone(),w=new p.Vector3(m.x,m.y,m.z),b=new p.Vector3(f.x,f.y,f.z);if(this.flyTween&&(this.flyTween.stop(),this.flyTween=null),d){const x=[_,_.clone().lerp(b,.33),_.clone().lerp(b,.67),b],L=new p.CubicBezierCurve3(...x),M={t:0,x:g.x,y:g.y,z:g.z};this.flyTween=new os(M).to({t:1,x:w.x,y:w.y,z:w.z},a).easing(Un.Quadratic.InOut).onUpdate(()=>{const C=L.getPoint(M.t),Z=new p.Vector3(M.x,M.y,M.z);t.position.copy(C),t.lookAt(Z),t.updateProjectionMatrix(),n.target.copy(Z),n.update()})}else{const x={tx:g.x,ty:g.y,tz:g.z,px:_.x,py:_.y,pz:_.z};this.flyTween=new os(x).to({tx:w.x,ty:w.y,tz:w.z,px:b.x,py:b.y,pz:b.z},a).easing(Un.Quadratic.InOut).onUpdate(()=>{const L=new p.Vector3(x.tx,x.ty,x.tz),M=new p.Vector3(x.px,x.py,x.pz);t.position.copy(M),t.lookAt(L),n.target.copy(L),n.update()})}this.flyTween&&(this.flyTween.onComplete(()=>{this.flyTween&&(this.flyTween.stop(),this.flyTween=null),u&&u()}),c>0?setTimeout(()=>{this.flyTween&&this.flyTween.start()},c):this.flyTween.start())}onConfig(e){if("draggable"in e){const t=e.draggable;this.controls&&(this.controls.enabled=t!==!1)}}flyToPoint(e){const{controls:t}=this,n=e.center,r=e.duration??2e3,o=typeof e.distance=="number"?e.distance:typeof e.altitude=="number"?e.altitude:t.getDistance(),a=w=>w*Math.PI/180;let c;if(typeof e.polarDeg=="number"){const w=e.polarDeg<=0?.1:e.polarDeg;c=a(w)}else typeof e.polarAngle=="number"?c=e.polarAngle<=0?a(.1):e.polarAngle:c=t.getPolarAngle();const u=typeof e.azimuthDeg=="number"?a(e.azimuthDeg):e.azimuthAngle||t.getAzimuthalAngle(),d=e.complete,m=!!e.curvePath,f=this.map.geo2world(new p.Vector3(n[0],n[1],0)),g=this.calculateCameraPosition(f,o,c,u),_=this.map.world2geo(g);this.flyToAdvanced({center:[n[0],n[1],0],cameraCoord:[_.x,_.y,_.z||0],duration:r,complete:d,curvePath:m})}getState(){return{centerPosition:this.controls.target,cameraPosition:this.camera.position}}_bindMap(e){e&&(this.map=e)}getMap(){return this.map?this.map:null}getAspect(){const[e,t]=this.getWidthHeight();return e/t}getWidthHeight(){let e=window.innerWidth,t=window.innerHeight;return[e,t]}_createGorund(){const e=this.centerPostion,t=new p.MeshStandardMaterial({transparent:!1,color:new p.Color("rgb(45,52,60)").multiplyScalar(.7),metalness:.2,roughness:1}),n=new p.PlaneGeometry(this._sceneSize*2,this._sceneSize*2),r=new p.Mesh(n,t);return r.name="地面",r.castShadow=!1,r.receiveShadow=!1,r.position.y=0,r.position.add(e),r.rotateX(-Math.PI/2),r.visible=!1,r}destroy(){try{this.renderer.setAnimationLoop(null),this._animationCallbacks.clear(),this.map=null,this.controls&&this.controls.dispose(),this.scene&&(this.scene.traverse(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>{this._disposeMaterial(t)}):this._disposeMaterial(e.material))}),this.scene.clear()),this.composer&&(this.bloomPass&&this.bloomPass.dispose?.(),this.renderPass&&this.renderPass.dispose?.(),this.composer=null,this.renderPass=null,this.bloomPass=null),this.renderer&&(this.renderer.dispose(),this.container&&this.renderer.domElement.parentNode===this.container&&this.container.removeChild(this.renderer.domElement)),this.stats&&this.stats.dom.parentNode&&this.stats.dom.parentNode.removeChild(this.stats.dom)}catch(e){console.error("❌ 销毁Viewer时出错:",e)}}_disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap"].forEach(n=>{e[n]&&e[n].dispose()}),e.dispose()}}var wi=(i=>(i[i.none=0]="none",i[i.create=1]="create",i[i.remove=2]="remove",i))(wi||{});function _m(i,e){const t=i.position.clone().setZ(i.maxZ).applyMatrix4(i.matrixWorld);return e.distanceTo(t)}function vm(i){const e=i.scale,t=new p.Vector3(-e.x,-e.y,0).applyMatrix4(i.matrixWorld),n=new p.Vector3(e.x,e.y,0).applyMatrix4(i.matrixWorld);return t.sub(n).length()}function wm(i){return i.distToCamera/i.sizeInWorld*.8}function bm(i,e,t,n){const r=wm(i);if(i.isLeaf){if(i.inFrustum&&i.z<t&&(i.z<e||i.showing)&&(i.z<e||r<n))return 1}else if(i.z>=e&&(i.z>t||r>n))return 2;return 0}function xm(i,e,t,n){const r=[],o=n+1,a=e*2,c=0,u=.25;{const d=t*2,m=new p.Vector3(.5,.5,1),f=new Nn(a,d,o),g=new Nn(a+1,d,o),_=new Nn(a,d+1,o),w=new Nn(a+1,d+1,o);f.position.set(-u,u,c),f.scale.copy(m),g.position.set(u,u,c),g.scale.copy(m),_.position.set(-u,-u,c),_.scale.copy(m),w.position.set(u,-u,c),w.scale.copy(m),r.push(f,g,_,w)}return r}var Mm=Object.defineProperty,Sm=(i,e,t)=>e in i?Mm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,et=(i,e,t)=>Sm(i,typeof e!="symbol"?e+"":e,t);const Lm=10,Pm=new p.InstancedBufferGeometry,Cm=new p.Vector3,Tm=new p.Matrix4,Gm=new p.Box3(new p.Vector3(-.5,-.5,0),new p.Vector3(.5,.5,1)),bc=new p.Frustum,xc=class Ei extends p.Mesh{constructor(e=0,t=0,n=0){super(Pm,[]),et(this,"_dataOnlyMode",!1),et(this,"vectorData",null),et(this,"x"),et(this,"y"),et(this,"z"),et(this,"isTile",!0),et(this,"parent",null),et(this,"children",[]),et(this,"_ready",!1),et(this,"_isDummy",!1),et(this,"_showing",!1),et(this,"_maxZ",0),et(this,"distToCamera",0),et(this,"sizeInWorld",0),et(this,"_loaded",!1),et(this,"_inFrustum",!1),this.x=e,this.y=t,this.z=n,this.name=`Tile ${n}-${e}-${t}`,this.up.set(0,0,1),this.matrixAutoUpdate=!1}setDataOnlyMode(e){return this._dataOnlyMode=e,e&&(this.visible=!1),this}isDataOnlyMode(){return this._dataOnlyMode}getVectorData(){return this.vectorData}static get downloadThreads(){return Ei._downloadThreads}get isDummy(){return this._isDummy}get showing(){return this._showing}set showing(e){const t=this._showing;this._showing=e,this.material.forEach(n=>n.visible=e),t===!1&&this._showing===!0&&this._loaded&&this.dispatchEvent({type:"tile-shown",tile:this}),t===!0&&this._showing===!1&&this.dispatchEvent({type:"tile-hidden",tile:this})}get maxZ(){return this._maxZ}set maxZ(e){this._maxZ=e}get index(){return this.parent?this.parent.children.indexOf(this):-1}get loaded(){return this._loaded}get inFrustum(){return this._inFrustum}set inFrustum(e){this._inFrustum=e}get isLeaf(){return this.children.filter(e=>e.isTile).length===0}traverse(e){e(this),this.children.forEach(t=>{t.isTile&&t.traverse(e)})}traverseVisible(e){this.visible&&(e(this),this.children.forEach(t=>{t.isTile&&t.traverseVisible(e)}))}raycast(e,t){this.showing&&this.loaded&&this.isTile&&super.raycast(e,t)}LOD(e){if(Ei.downloadThreads>Lm)return{action:wi.none};let t=[];const{loader:n,minLevel:r,maxLevel:o,LODThreshold:a}=e,c=bm(this,r,o,a);return c===wi.create&&(t=xm(n,this.x,this.y,this.z),this.add(...t)),{action:c,newTiles:t}}_checkVisible(){const e=this.parent;if(e&&e.isTile){const t=e.children.filter(r=>r.isTile),n=t.every(r=>r.loaded);e.showing=!n,t.forEach(r=>r.showing=n)}return this}async _load(e){Ei._downloadThreads++;const{x:t,y:n,z:r}=this;if(this._dataOnlyMode)try{const o=await e.load({x:t,y:n,z:r,bounds:[-1/0,-1/0,1/0,1/0]});this.vectorData=o.geometry?.userData||{},this._loaded=!0,this.dispatchEvent({type:"vector-data-loaded",data:this.vectorData,tile:this})}catch(o){console.error(`数据模式加载失败 ${r}/${t}/${n}:`,o),this._loaded=!1}else{const o=await e.load({x:t,y:n,z:r,bounds:[-1/0,-1/0,1/0,1/0]});this.material=o.materials,this.geometry=o.geometry,this.maxZ=this.geometry.boundingBox?.max.z||0,this._loaded=!0}return Ei._downloadThreads--,this}_init(){this.updateMatrix(),this.updateMatrixWorld(),this.sizeInWorld=vm(this)}update(e){if(console.assert(this.z===0),!this.parent)return this;bc.setFromProjectionMatrix(Tm.multiplyMatrices(e.camera.projectionMatrix,e.camera.matrixWorldInverse));const t=e.camera.getWorldPosition(Cm);return this.traverse(n=>{n.receiveShadow=this.receiveShadow,n.castShadow=this.castShadow;const r=Gm.clone().applyMatrix4(n.matrixWorld);r.max.setY(9e3),n.inFrustum=bc.intersectsBox(r),n.distToCamera=_m(n,t);const{action:o,newTiles:a}=n.LOD(e);this._doAction(n,o,a,e)}),this._checkReady(),this}_doAction(e,t,n,r){return t===wi.create?n?.forEach(o=>{o._init(),o._isDummy=o.z<r.minLevel,this.dispatchEvent({type:"tile-created",tile:o}),o.isDummy||o._load(r.loader).then(()=>{o._checkVisible(),this.dispatchEvent({type:"tile-loaded",tile:o})})}):t===wi.remove&&(e.showing=!0,e._unLoad(!1,r.loader),this.dispatchEvent({type:"tile-unload",tile:e})),this}reload(e){return this._unLoad(!0,e),this}_checkReady(){return this._ready||(this._ready=!0,this.traverse(e=>{if(e.isLeaf&&e.loaded&&!e.isDummy){this._ready=!1;return}}),this._ready&&this.dispatchEvent({type:"ready"})),this}_unLoad(e,t){return e&&this.isTile&&!this.isDummy&&(this.dispatchEvent({type:"unload"}),t?.unload?.(this)),this.children.forEach(n=>n._unLoad(!0,t)),this.clear(),this}};et(xc,"_downloadThreads",0);let Nn=xc;var Zm=Object.defineProperty,Wm=(i,e,t)=>e in i?Zm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Vm=(i,e,t)=>Wm(i,e+"",t);class Mc{constructor(e=0){Vm(this,"_lon0",0),this._lon0=e}get lon0(){return this._lon0}getTileXWithCenterLon(e,t){const n=Math.pow(2,t);let r=e+Math.round(n/360*this._lon0);return r>=n?r-=n:r<0&&(r+=n),r}getTileXYZproj(e,t,n){const r=this.mapWidth,o=this.mapHeight/2,a=e/Math.pow(2,n)*r-r/2,c=o-t/Math.pow(2,n)*o*2;return{x:a,y:c}}getProjBoundsFromLonLat(e){const t=e[0]===-180&&e[2]===180,n=this.project(e[0]+(t?this._lon0:0),e[1]),r=this.project(e[2]+(t?this._lon0:0),e[3]);return[Math.min(n.x,r.x),Math.min(n.y,r.y),Math.max(n.x,r.x),Math.max(n.y,r.y)]}getProjBoundsFromXYZ(e,t,n){const r=this.getTileXYZproj(e,t,n),o=this.getTileXYZproj(e+1,t+1,n);return[Math.min(r.x,o.x),Math.min(r.y,o.y),Math.max(r.x,o.x),Math.max(r.y,o.y)]}getLonLatBoundsFromXYZ(e,t,n){const r=this.getProjBoundsFromXYZ(e,t,n),o=this.unProject(r[0],r[1]),a=this.unProject(r[2],r[3]);return[o.lon,o.lat,a.lon,a.lat]}}var Im=Object.defineProperty,Am=(i,e,t)=>e in i?Im(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,cs=(i,e,t)=>Am(i,typeof e!="symbol"?e+"":e,t);const bi=6378e3;class Sc extends Mc{constructor(){super(...arguments),cs(this,"ID","3857"),cs(this,"mapWidth",2*Math.PI*bi),cs(this,"mapHeight",this.mapWidth),cs(this,"mapDepth",1)}project(e,t){const n=(e-this.lon0)*(Math.PI/180),r=t*(Math.PI/180),o=bi*n,a=bi*Math.log(Math.tan(Math.PI/4+r/2));return{x:o,y:a}}unProject(e,t){let n=e/bi*(180/Math.PI)+this.lon0;return n>180&&(n-=360),{lat:(2*Math.atan(Math.exp(t/bi))-Math.PI/2)*(180/Math.PI),lon:n}}}var Fm=Object.defineProperty,Om=(i,e,t)=>e in i?Fm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,us=(i,e,t)=>Om(i,typeof e!="symbol"?e+"":e,t);class Dm extends Mc{constructor(){super(...arguments),us(this,"ID","4326"),us(this,"mapWidth",36e3),us(this,"mapHeight",18e3),us(this,"mapDepth",1)}project(e,t){return{x:(e-this.lon0)*100,y:t*100}}unProject(e,t){return{lon:e/100+this.lon0,lat:t/100}}}const zm={createFromID:(i="3857",e)=>{let t;switch(i){case"3857":t=new Sc(e);break;case"4326":t=new Dm(e);break;default:throw new Error(`Projection ID: ${i} is not supported.`)}return t}};function No(i,e){const t=i.getLayers().find(r=>r.isBaseLayer===!0)?._rootTile,n=e.intersectObjects([t]);for(const r of n)if(r.object instanceof Nn){const o=i.worldToLocal(r.point.clone()),a=i.map2geo(o);return Object.assign(r,{location:a})}}function Bo(i,e){const t=new p.Vector3(0,-1,0),n=new p.Vector3(e.x,10*1e3,e.z),r=new p.Raycaster(n,t);return No(i,r)}function Lc(i,e,t){const n=new p.Raycaster;return n.setFromCamera(t,i),No(e,n)}function Xm(i,e=128){const t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("Failed to get canvas context");t.width=e,t.height=e;const r=e/2,o=e/2;return n.imageSmoothingEnabled=!1,n.fillStyle="#000022",n.strokeStyle="DarkGoldenrod",n.lineWidth=5,n.moveTo(r,3),n.lineTo(r,e),n.stroke(),n.closePath(),n.lineWidth=2,n.beginPath(),n.roundRect(2,2,e-4,o-8,10),n.closePath(),n.fill(),n.stroke(),n.font="24px Arial",n.fillStyle="Goldenrod",n.strokeStyle="black",n.textAlign="center",n.textBaseline="top",n.strokeText(i,r,20),n.fillText(i,r,20),t}function Um(i,e=128){const t=new p.CanvasTexture(Xm(i,e)),n=new p.SpriteMaterial({map:t,sizeAttenuation:!1}),r=new p.Sprite(n);return r.visible=!1,r.center.set(.5,.3),r.scale.setScalar(.11),r.renderOrder=999,r}var km=Object.defineProperty,Km=(i,e,t)=>e in i?km(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,gn=(i,e,t)=>Km(i,typeof e!="symbol"?e+"":e,t);class hs extends p.Mesh{constructor(e){super(),gn(this,"name","map"),gn(this,"_clock",new p.Clock),gn(this,"isLOD",!0),gn(this,"autoUpdate",!0),gn(this,"updateInterval",100),gn(this,"_minLevel",2),gn(this,"_layers",new Map),gn(this,"_maxLevel",24),gn(this,"_projection",new Sc(0)),gn(this,"_LODThreshold",1),this.up.set(0,0,1);const{minLevel:t=2,maxLevel:n=19}=e;this.minLevel=t,this.maxLevel=n}get minLevel(){return this._minLevel}set minLevel(e){this._minLevel=e}get maxLevel(){return this._maxLevel}set maxLevel(e){this._maxLevel=e}get lon0(){return this.projection.lon0}get projection(){return this._projection}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}static create(e){return new hs(e)}update(e){if(!this.autoUpdate)return;const t=this._clock.getElapsedTime();t>this.updateInterval/1e3&&(this._layers.forEach(n=>{n.enabled&&n.visible&&n.update(e)}),this._clock.start(),this.dispatchEvent({type:"update",delta:t}))}dispose(){this.removeFromParent()}geo2pos(e){return this.geo2map(e)}geo2map(e){const t=this.projection.project(e.x,e.y);return new p.Vector3(t.x,t.y,e.z)}geo2world(e){return this.localToWorld(this.geo2map(e))}pos2geo(e){return this.map2geo(e)}map2geo(e){const t=this.projection.unProject(e.x,e.y);return new p.Vector3(t.lon,t.lat,e.z)}world2geo(e){return this.pos2geo(this.worldToLocal(e.clone()))}getLocalInfoFromGeo(e){const t=this.geo2world(e);return Bo(this,t)}getLocalInfoFromWorld(e){return Bo(this,e)}getLocalInfoFromScreen(e,t){return Lc(e,this,t)}get downloading(){return Nn.downloadThreads}addLayer(e){return this._layers.has(e.layerId)&&console.warn(`Layer ${e.layerid} already exists, will be replaced 图层 ${e.layerid} 已存在,将被替换`),this._layers.set(e.layerId,e),this.add(e),this}removeLayer(e){const t=this._layers.get(e);return t?(this._layers.delete(e),this.remove(t),t.dispose(),!0):(console.warn(`⚠️ Layer ${e} does not exist 图层 ${e} 不存在`),!1)}getLayer(e){return this._layers.get(e)}getLayerIds(){return Array.from(this._layers.keys())}clearLayers(){return this._layers.forEach(e=>{this.remove(e),e.dispose()}),this._layers.clear(),this}getLayers(){return Array.from(this._layers.values())}getApproxZoomLevel(){let e=this.minLevel;const t=this.getLayers().find(r=>r.isBaseLayer===!0);return!t||!t._rootTile||t._rootTile.traverseVisible(r=>{r.showing&&r.inFrustum&&(e=Math.max(e,r.z))}),e}getDataZoom(){let e=this.minLevel;const t=this.getLayers().find(r=>r.isBaseLayer===!0);return!t||!t._rootTile||t._rootTile.traverseVisible(r=>{r.showing&&r.inFrustum&&(e=Math.max(e,r.z))}),e}}var Nm=Object.defineProperty,Bm=(i,e,t)=>e in i?Nm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ym=(i,e,t)=>Bm(i,e+"",t);function Yo(i){return class extends i{constructor(...t){super(...t),Ym(this,"_handlers"),this._handlers=[]}addHandler(t,n){if(!n)return this;if(this._handlers||(this._handlers=[]),this[t])return this[t].enable(),this;const r=this[t]=new n(this);return this._handlers.push(r),this.options[t]&&r.enable(),this}removeHandler(t){if(!t)return this;const n=this[t];if(n&&this._handlers){const r=this._handlers.indexOf(n);r>=0&&this._handlers.splice(r,1),this[t].remove(),delete this[t]}return this}_clearHandlers(){if(this._handlers){for(let t=0,n=this._handlers.length;t<n;t++)this._handlers[t].remove();this._handlers=[]}}}}var Rm=Object.defineProperty,jm=(i,e,t)=>e in i?Rm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,yr=(i,e,t)=>jm(i,typeof e!="symbol"?e+"":e,t);const Jm={attribution:"",visible:!0,opacity:1,zIndex:0,isSceneLayer:!1,altitude:0};class ds extends Yo(Kn(gr(p.Group))){constructor(e,t){super(),yr(this,"_id"),yr(this,"opacity",1),yr(this,"_animationCallbacks",new Set),yr(this,"isSceneLayer",!1),yr(this,"_altitude",0),yr(this,"depthOffset"),yr(this,"_regionOverlays",[]),Xo(e,"id","Layer ID must be specified 图层ID必须指定"),t&&(this.setOptions(t),this.opacity=t.opacity||1,this.isSceneLayer=t.isSceneLayer??!1,t.altitude!==void 0&&this.setAltitude(t.altitude)),this._id=e,typeof this.animate=="function"&&this._registerAnimate()}getId(){return this._id}addTo(e){return e.addLayer(this),this}getZIndex(){const e=this.options||{};return typeof e.zIndex=="number"?e.zIndex:0}getDepthOffset(){const e=this.options||{};return typeof e.depthOffset=="number"?e.depthOffset:0}getOpacity(){return this.opacity}setOpacity(e){this.opacity=e,this.traverse(t=>{"material"in t&&(Array.isArray(t.material)?t.material:[t.material]).forEach(r=>{"opacity"in r&&(r.transparent=e<1,r.opacity=e,r.needsUpdate=!0)}),t instanceof p.Sprite&&(t.material.opacity=e,t.material.transparent=e<1,t.material.needsUpdate=!0)})}getMap(){return this.map?this.map:null}show(){return this.visible||(this.visible=!0,this.options.visible=!0,this.getMap()),this}hide(){return this.visible&&(this.visible=!1,this.options.visible=!1,this.getMap()),this}setAltitude(e){return this.position.y=e,this.updateMatrix(),this.updateMatrixWorld(!0),this}getAltitude(){return this.position.y}_bindMap(e){e&&(this.map=e,typeof this.animate=="function"&&this._registerAnimate())}_registerAnimate(){const e=this.getMap();if(!e?.viewer)return;const t=e.viewer.addAnimationCallback((n,r,o)=>{this.animate?.(n,r,o)});this._animationCallbacks.add(t)}_clearAnimationCallbacks(){this._animationCallbacks.forEach(e=>e()),this._animationCallbacks.clear()}getOptions(){return{...this.options}}setRegionOverlays(e){return this._regionOverlays=(e||[]).map(t=>({id:t.id??this._generateRegionOverlayId(),color:t.color??"#00FF88",opacity:t.opacity??.3,mode:t.mode??"overlay",zIndex:t.zIndex??0,geometry:t.geometry,feature:t.feature})),this}addRegionOverlay(e){const t=e.id??this._generateRegionOverlayId(),n={id:t,color:e.color??"#00FF88",opacity:e.opacity??.3,mode:e.mode??"overlay",zIndex:e.zIndex??0,geometry:e.geometry,feature:e.feature};return this._regionOverlays.push(n),t}removeRegionOverlay(e){return this._regionOverlays=this._regionOverlays.filter(t=>t.id!==e),this}clearRegionOverlays(){return this._regionOverlays=[],this}getRegionOverlays(){return this._regionOverlays.slice()}_generateRegionOverlayId(){return`region-overlay-${Date.now()}-${Math.random().toString(16).slice(2)}`}}ds.mergeOptions(Jm);var Qm=Object.defineProperty,Hm=(i,e,t)=>e in i?Qm(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,xi=(i,e,t)=>Hm(i,typeof e!="symbol"?e+"":e,t);const Pc=class sf{constructor(e){xi(this,"_cache",new Map),xi(this,"_gltfLoader"),xi(this,"_fbxLoader"),xi(this,"_dracoLoader"),this._gltfLoader=new Ef(e),this._fbxLoader=new Xp(e)}static init(e){return this._instance||(this._instance=new sf(e)),this._instance}async load(e){const t=`${e.type}:${e.url}`;if(this._cache.has(t))return this._cloneCachedModel(t,e);e.type==="gltf"&&e.dracoOptions?.enable&&this._initDracoLoader(e.dracoOptions.decoderPath);let n,r;try{if(e.type==="gltf"){const o=await this._gltfLoader.loadAsync(e.url);n=o.scene,r=o.animations}else n=await this._fbxLoader.loadAsync(e.url),r=n.animations;return this._cache.set(t,{model:n,animations:r}),{model:this._processModel(n.clone(),e),animations:r?.map(o=>({...o,name:o.name||"unnamed"}))||[]}}catch(o){throw console.error(`Failed to load ${e.type} model 加载${e.type}模型失败:`,e.url,o),o}}_initDracoLoader(e="/draco/"){this._dracoLoader||(this._dracoLoader=new $p,this._dracoLoader.setDecoderPath(e),this._gltfLoader.setDRACOLoader(this._dracoLoader))}_cloneCachedModel(e,t){const n=this._cache.get(e),r=n.model.clone();return{model:this._processModel(r,t),animations:n.animations?.map(o=>({...o,name:o.name||"unnamed"}))||[]}}_processModel(e,t){return t.position&&e.position.copy(t.position),t.scale&&(typeof t.scale=="number"?e.scale.setScalar(t.scale):t.scale.x!==void 0||t.scale.y!==void 0||t.scale.z!==void 0?(t.scale.x!==void 0&&(e.scale.x=t.scale.x),t.scale.y!==void 0&&(e.scale.y=t.scale.y),t.scale.z!==void 0&&(e.scale.z=t.scale.z)):e.scale.copy(t.scale)),t.rotation&&e.rotation.set(t.rotation.x,t.rotation.y,t.rotation.z),t.materialOverrides&&e.traverse(n=>{if(n instanceof p.Mesh&&n.material){const r=t.materialOverrides[n.name];r&&(n.material=r)}}),e.traverse(n=>{n instanceof p.Mesh&&n.material}),e}clearCache(){this._cache.clear()}static clearCache(){this._instance&&this._instance.clearCache()}};xi(Pc,"_instance");let Cc=Pc;const Ro=(i,e)=>{"updateRanges"in i?i.updateRanges[0]=e:i.updateRange=e},Tc=new p.Matrix4,fs=new p.Vector3,ps=new p.Quaternion,Gc=new p.Vector3,Zc=new p.Quaternion,Mi=new p.Vector3,Em=i=>class extends i{constructor(){super();const e=parseInt(p.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=t=>{t.vertexShader=`attribute float cloudOpacity;
566
621
  varying float vOpacity;
567
- `+e.vertexShader.replace("#include <fog_vertex>",`#include <fog_vertex>
622
+ `+t.vertexShader.replace("#include <fog_vertex>",`#include <fog_vertex>
568
623
  vOpacity = cloudOpacity;
569
- `),e.fragmentShader=`varying float vOpacity;
570
- `+e.fragmentShader.replace(`#include <${t}>`,`#include <${t}>
624
+ `),t.fragmentShader=`varying float vOpacity;
625
+ `+t.fragmentShader.replace(`#include <${e}>`,`#include <${e}>
571
626
  gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);
572
- `)}}};class bo extends h.Group{constructor({limit:t=200,range:e,material:n=h.MeshLambertMaterial,texture:i,frustumCulled:r=!0}={}){super(),this.name="Clouds",this.ref=this;const s=this,a=new h.PlaneGeometry(1,1),l=new Float32Array(Array.from({length:t},()=>1)),u=new Float32Array(Array.from({length:t},()=>[1,1,1]).flat()),d=new h.InstancedBufferAttribute(l,1);d.setUsage(h.DynamicDrawUsage),a.setAttribute("cloudOpacity",d);const c=go(n),p=new c;p.map=i,p.transparent=!0,p.depthWrite=!1,p.needsUpdate=!0,this.cloudMaterial=p,this.instance=new h.InstancedMesh(a,p,t);const f=this.instance;f.matrixAutoUpdate=!1,f.frustumCulled=r,f.instanceColor=new h.InstancedBufferAttribute(u,3),f.instanceColor.setUsage(h.DynamicDrawUsage),s.add(f);const m=[],v=()=>{const T=m.length;let M=0;for(let A=0;A<this.ref.children.length;A++){const L=this.ref.children[A];L.cloudStateArray&&(M+=L.cloudStateArray.length)}if(T===M)return m;m.length=0;for(let A=0;A<this.ref.children.length;A++){const L=this.ref.children[A];L.cloudStateArray&&m.push(...L.cloudStateArray)}return g(),m},g=()=>{const T=Math.min(t,e!==void 0?e:t,m.length);f.count=T,Jt(f.instanceMatrix,{offset:0,count:T*16}),f.instanceColor&&Jt(f.instanceColor,{offset:0,count:T*3}),Jt(f.geometry.attributes.cloudOpacity,{offset:0,count:T})};let b=0,y=0,w;const S=new h.Quaternion,P=new h.Vector3(0,0,1),I=new h.Vector3;this.update=(T,M,A)=>{b=M,ti.copy(f.matrixWorld).invert(),T.matrixWorld.decompose(ni,ii,qe);const L=v();for(y=0;y<L.length;y++)w=L[y],w.ref.matrixWorld.decompose(mt,yt,qe),mt.add(I.copy(w.position).applyQuaternion(yt).multiply(qe)),yt.copy(ii).multiply(S.setFromAxisAngle(P,w.rotation+=A*w.rotationFactor)),qe.multiplyScalar(w.volume+(1+Math.sin(b*w.density*w.speed))/2*w.growth),w.matrix.compose(mt,yt,qe).premultiply(ti),w.dist=mt.distanceTo(ni);for(L.sort((Z,W)=>W.dist-Z.dist),y=0;y<L.length;y++)w=L[y],l[y]=w.opacity*(w.dist<w.fade-1?w.dist/w.fade:1),f.setMatrixAt(y,w.matrix),f.setColorAt(y,w.color);f.geometry.attributes.cloudOpacity.needsUpdate=!0,f.instanceMatrix.needsUpdate=!0,f.instanceColor&&(f.instanceColor.needsUpdate=!0)}}}let vo=0;class wo extends h.Group{constructor({opacity:t=1,speed:e=0,bounds:n=new h.Vector3().fromArray([5,1,1]),segments:i=20,color:r=new h.Color("#ffffff"),fade:s=10,volume:a=6,smallestVolume:l=.25,distribute:u=null,growth:d=4,concentrate:c="inside",seed:p=Math.random()}={}){super(),this.name="cloud_"+vo++,this.seed=p,this.segments=i,this.bounds=n,this.concentrate=c,this.volume=a,this.smallestVolume=l,this.distribute=u,this.growth=d,this.speed=e,this.fade=s,this.opacity=t,this.color=r,this.ref=this,this.cloudStateArray=[],this.updateCloud()}updateCloudStateArray(){if(this.cloudStateArray.length===this.segments)return;const{segments:t,uuid:e}=this;if(this.cloudStateArray.length>this.segments)this.cloudStateArray.splice(0,this.cloudStateArray.length-this.segments);else for(let n=this.cloudStateArray.length;n<t;n++)this.cloudStateArray.push({segments:t,bounds:new h.Vector3(1,1,1),position:new h.Vector3,uuid:e,index:n,ref:this,dist:0,matrix:new h.Matrix4,volume:0,length:0,speed:0,growth:0,opacity:1,fade:0,density:0,rotation:n*(Math.PI/t),rotationFactor:0,color:new h.Color})}updateCloud(){const{volume:t,color:e,speed:n,growth:i,opacity:r,fade:s,bounds:a,seed:l,cloudStateArray:u,distribute:d,segments:c,concentrate:p,smallestVolume:f}=this;this.updateCloudStateArray();let m=0;function v(){const g=Math.sin(l+m)*1e4;return m++,g-Math.floor(g)}u.forEach((g,b)=>{g.segments=c,g.volume=t,g.color=e,g.speed=n,g.growth=i,g.opacity=r,g.fade=s,g.bounds.copy(a),g.density=Math.max(.5,v()),g.rotationFactor=Math.max(.2,.5*v())*n;const y=d?.(g,b);if(y||c>1){var w;g.position.copy(g.bounds).multiply((w=y?.point)!==null&&w!==void 0?w:{x:v()*2-1,y:v()*2-1,z:v()*2-1})}const S=Math.abs(g.position.x),P=Math.abs(g.position.y),I=Math.abs(g.position.z),T=Math.max(S,P,I);g.length=1,S===T&&(g.length-=S/g.bounds.x),P===T&&(g.length-=P/g.bounds.y),I===T&&(g.length-=I/g.bounds.z),g.volume=(y?.volume!==void 0?y.volume:Math.max(Math.max(0,f),p==="random"?v():p==="inside"?g.length:1-g.length))*t})}}function ri(o,t){const e=new h.BufferGeometry;e.setAttribute("position",new h.BufferAttribute(new Float32Array([0,0,0]),3));const n=new h.Points(e,new h.PointsMaterial({size:o.size,color:o.color||16777215,sizeAttenuation:!o.glow}));return n.position.copy(t),n}async function si(o,t){const e=await Ge._loadTexture(o.url),n=new h.Sprite(new h.SpriteMaterial({map:e,color:o.color||16777215,transparent:!0,opacity:o.opacity??1,sizeAttenuation:o.sizeAttenuation??!0}));return n.scale.set(o.size[0],o.size[1],1),o.rotation&&(n.rotation.z=o.rotation),o.anchor&&n.center.set(o.anchor[0],o.anchor[1]),n.position.copy(t),n}function Qt(o,t){let e;t instanceof Float32Array?e=Array.from(t):Array.isArray(t)&&typeof t[0]=="number"?e=t:e=t.flatMap(r=>[r.x,r.y,r.z]);const n=new ut;n.setPositions(e);const i=new Je({color:new h.Color(o.color??16777215).getHex(),linewidth:o.width??2,transparent:o.opacity!==void 0&&o.opacity<1,opacity:o.opacity??1,dashed:!!o.dashArray,dashScale:o.dashArray?.[0]??1,dashSize:o.dashArray?.[0]??1,gapSize:o.dashArray?.[1]??0,resolution:new h.Vector2(window.innerWidth,window.innerHeight),alphaToCoverage:!0});return window.addEventListener("resize",()=>{i.resolution.set(window.innerWidth,window.innerHeight)}),new Ot(n,i)}async function xo(o,t){const e=o.type||(o.url.toLowerCase().endsWith(".fbx")?"fbx":"gltf");return await Rt.init().load({...o,type:e,position:t})}function Lo(o,t){const e=new h.BufferGeometry;e.setAttribute("position",new h.BufferAttribute(new Float32Array(t),3));const n=[],i=t.length/3;for(let s=1;s<i-1;s++)n.push(0,s,s+1);e.setIndex(n),e.computeVertexNormals();const r=new h.MeshBasicMaterial({color:new h.Color(o.color??16777215),transparent:o.opacity!==void 0&&o.opacity<1,opacity:o.opacity??1,wireframe:o.wireframe??!1,side:o.side==="back"?h.BackSide:o.side==="double"?h.DoubleSide:h.FrontSide,depthWrite:!0,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1});return new h.Mesh(e,r)}function So(o,t){const e=o.extrude?.height||2e3,n=[],i=[],r=[];for(let c=0;c<t.length;c+=3){const p=t[c],f=t[c+1],m=t[c+2];i.push(new h.Vector3(p,f,m)),r.push(new h.Vector3(p,f+e,m))}n.push(...i,...r);const s=new h.BufferGeometry;s.setFromPoints(n);const a=[],l=i.length;for(let c=0;c<l;c++){const p=(c+1)%l;a.push(c,c+l,p),a.push(p,c+l,p+l)}for(let c=2;c<l;c++)a.push(0,c-1,c),a.push(l,l+c-1,l+c);s.setIndex(a),s.computeVertexNormals(),s.attributes.normal||s.computeVertexNormals();const u=new h.ShaderMaterial({uniforms:{uColor:{value:new h.Color(o.color??16777215)},uOpacity:{value:o.opacity??1},uBrightness:{value:1.2}},vertexShader:`
627
+ `)}}};class $m extends p.Group{constructor({limit:e=200,range:t,material:n=p.MeshLambertMaterial,texture:r,frustumCulled:o=!0}={}){super(),this.name="Clouds",this.ref=this;const a=this,c=new p.PlaneGeometry(1,1),u=new Float32Array(Array.from({length:e},()=>1)),d=new Float32Array(Array.from({length:e},()=>[1,1,1]).flat()),m=new p.InstancedBufferAttribute(u,1);m.setUsage(p.DynamicDrawUsage),c.setAttribute("cloudOpacity",m);const f=Em(n),g=new f;g.map=r,g.transparent=!0,g.depthWrite=!1,g.needsUpdate=!0,this.cloudMaterial=g,this.instance=new p.InstancedMesh(c,g,e);const _=this.instance;_.matrixAutoUpdate=!1,_.frustumCulled=o,_.instanceColor=new p.InstancedBufferAttribute(d,3),_.instanceColor.setUsage(p.DynamicDrawUsage),a.add(_);const w=[],b=()=>{const X=w.length;let I=0;for(let K=0;K<this.ref.children.length;K++){const V=this.ref.children[K];V.cloudStateArray&&(I+=V.cloudStateArray.length)}if(X===I)return w;w.length=0;for(let K=0;K<this.ref.children.length;K++){const V=this.ref.children[K];V.cloudStateArray&&w.push(...V.cloudStateArray)}return x(),w},x=()=>{const X=Math.min(e,t!==void 0?t:e,w.length);_.count=X,Ro(_.instanceMatrix,{offset:0,count:X*16}),_.instanceColor&&Ro(_.instanceColor,{offset:0,count:X*3}),Ro(_.geometry.attributes.cloudOpacity,{offset:0,count:X})};let L=0,M=0,C;const Z=new p.Quaternion,z=new p.Vector3(0,0,1),D=new p.Vector3;this.update=(X,I,K)=>{L=I,Tc.copy(_.matrixWorld).invert(),X.matrixWorld.decompose(Gc,Zc,Mi);const V=b();for(M=0;M<V.length;M++)C=V[M],C.ref.matrixWorld.decompose(fs,ps,Mi),fs.add(D.copy(C.position).applyQuaternion(ps).multiply(Mi)),ps.copy(Zc).multiply(Z.setFromAxisAngle(z,C.rotation+=K*C.rotationFactor)),Mi.multiplyScalar(C.volume+(1+Math.sin(L*C.density*C.speed))/2*C.growth),C.matrix.compose(fs,ps,Mi).premultiply(Tc),C.dist=fs.distanceTo(Gc);for(V.sort((G,k)=>k.dist-G.dist),M=0;M<V.length;M++)C=V[M],u[M]=C.opacity*(C.dist<C.fade-1?C.dist/C.fade:1),_.setMatrixAt(M,C.matrix),_.setColorAt(M,C.color);_.geometry.attributes.cloudOpacity.needsUpdate=!0,_.instanceMatrix.needsUpdate=!0,_.instanceColor&&(_.instanceColor.needsUpdate=!0)}}}let qm=0;class eg extends p.Group{constructor({opacity:e=1,speed:t=0,bounds:n=new p.Vector3().fromArray([5,1,1]),segments:r=20,color:o=new p.Color("#ffffff"),fade:a=10,volume:c=6,smallestVolume:u=.25,distribute:d=null,growth:m=4,concentrate:f="inside",seed:g=Math.random()}={}){super(),this.name="cloud_"+qm++,this.seed=g,this.segments=r,this.bounds=n,this.concentrate=f,this.volume=c,this.smallestVolume=u,this.distribute=d,this.growth=m,this.speed=t,this.fade=a,this.opacity=e,this.color=o,this.ref=this,this.cloudStateArray=[],this.updateCloud()}updateCloudStateArray(){if(this.cloudStateArray.length===this.segments)return;const{segments:e,uuid:t}=this;if(this.cloudStateArray.length>this.segments)this.cloudStateArray.splice(0,this.cloudStateArray.length-this.segments);else for(let n=this.cloudStateArray.length;n<e;n++)this.cloudStateArray.push({segments:e,bounds:new p.Vector3(1,1,1),position:new p.Vector3,uuid:t,index:n,ref:this,dist:0,matrix:new p.Matrix4,volume:0,length:0,speed:0,growth:0,opacity:1,fade:0,density:0,rotation:n*(Math.PI/e),rotationFactor:0,color:new p.Color})}updateCloud(){const{volume:e,color:t,speed:n,growth:r,opacity:o,fade:a,bounds:c,seed:u,cloudStateArray:d,distribute:m,segments:f,concentrate:g,smallestVolume:_}=this;this.updateCloudStateArray();let w=0;function b(){const x=Math.sin(u+w)*1e4;return w++,x-Math.floor(x)}d.forEach((x,L)=>{x.segments=f,x.volume=e,x.color=t,x.speed=n,x.growth=r,x.opacity=o,x.fade=a,x.bounds.copy(c),x.density=Math.max(.5,b()),x.rotationFactor=Math.max(.2,.5*b())*n;const M=m?.(x,L);if(M||f>1){var C;x.position.copy(x.bounds).multiply((C=M?.point)!==null&&C!==void 0?C:{x:b()*2-1,y:b()*2-1,z:b()*2-1})}const Z=Math.abs(x.position.x),z=Math.abs(x.position.y),D=Math.abs(x.position.z),X=Math.max(Z,z,D);x.length=1,Z===X&&(x.length-=Z/x.bounds.x),z===X&&(x.length-=z/x.bounds.y),D===X&&(x.length-=D/x.bounds.z),x.volume=(M?.volume!==void 0?M.volume:Math.max(Math.max(0,_),g==="random"?b():g==="inside"?x.length:1-x.length))*e})}}class jo{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:r,msg:o,transfer:a}=this.queue.shift();this.workersResolve[e]=r,this.workers[e].postMessage(o,a)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(n=>{const r=this._getIdleWorker();r!==-1?(this._initWorker(r),this.workerStatus|=1<<r,this.workersResolve[r]=n,this.workers[r].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}function Wc(i,e){const t=new p.BufferGeometry;t.setAttribute("position",new p.BufferAttribute(new Float32Array([0,0,0]),3));const n=i.sizeAttenuation??!0,r=n?i.size*.002:i.size,o=new p.PointsMaterial({size:r,color:i.color||16777215,sizeAttenuation:n,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0});o.onBeforeCompile=c=>{c.fragmentShader=c.fragmentShader.replace("#include <clipping_planes_fragment>",`
628
+ #include <clipping_planes_fragment>
629
+ vec2 coord = gl_PointCoord - vec2(0.5);
630
+ if(length(coord) > 0.5) discard;
631
+ `)};const a=new p.Points(t,o);return a.position.copy(e),a}async function tg(i,e){let t=null;try{t=await xt._loadTexture(i.url),t.magFilter=p.LinearFilter,t.minFilter=p.LinearMipmapLinearFilter,t.colorSpace=p.SRGBColorSpace,t.generateMipmaps=!0,t.premultiplyAlpha=!1,t.needsUpdate=!0}catch(d){console.error("IconPoint texture load failed:",i.url,d)}const n=new p.SpriteMaterial({map:t??null,color:i.color||16777215,transparent:i.transparent??!0,opacity:i.opacity??1,sizeAttenuation:i.sizeAttenuation??!0,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0,premultipliedAlpha:!1,blending:p.NormalBlending}),r=new p.Sprite(n),o=.002,a=i.size;let c,u;if(Array.isArray(a))[c,u]=a;else{const d=typeof a=="number"?a:32;if(t&&t.image?.width&&t.image?.height){const m=t.image,f=m.width/m.height||1;u=d,c=d*f}else c=d,u=d}return r.scale.set(c*o,u*o,1),i.rotation&&(r.rotation.z=i.rotation),i.anchor&&r.center.set(i.anchor[0],i.anchor[1]),r.position.copy(e),r}function Jo(i,e){let t;e instanceof Float32Array?t=Array.from(e):Array.isArray(e)&&typeof e[0]=="number"?t=e:t=e.flatMap(o=>[o.x,o.y,o.z]);const n=new rs;n.setPositions(t);const r=new mi({color:new p.Color(i.color??16777215).getHex(),linewidth:i.width??2,transparent:i.transparent??!0,opacity:i.opacity??1,dashed:!!i.dashArray,dashScale:i.dashArray?.[0]??1,dashSize:i.dashArray?.[0]??1,gapSize:i.dashArray?.[1]??0,resolution:new p.Vector2(window.innerWidth,window.innerHeight),alphaToCoverage:!0,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0});return window.addEventListener("resize",()=>{r.resolution.set(window.innerWidth,window.innerHeight)}),new gi(n,r)}function Vc(i,e){let t=[];if(Array.isArray(e)&&typeof e[0]=="number")for(let b=0;b<e.length;b+=3)t.push(new p.Vector3(e[b],e[b+1],e[b+2]));else if(e instanceof Float32Array)for(let b=0;b<e.length;b+=3)t.push(new p.Vector3(e[b],e[b+1],e[b+2]));else t=e;if(t.length<2)return new p.Mesh;const n=new p.CurvePath,r=i.cornerRadius||5;if(t.length===2||r<=0)for(let b=0;b<t.length-1;b++){const x=new p.LineCurve3(t[b],t[b+1]);n.curves.push(x)}else{let b=t[0];for(let x=1;x<t.length-1;x++){const L=b,M=t[x],C=t[x+1],Z=new p.Vector3().subVectors(M,L),z=new p.Vector3().subVectors(C,M),D=Z.length(),X=z.length(),I=Math.min(D,X)*.4,K=Math.min(r,I);Z.normalize().multiplyScalar(D-K),z.normalize().multiplyScalar(K);const V=new p.Vector3().addVectors(L,Z),G=new p.Vector3().addVectors(M,z);n.curves.push(new p.LineCurve3(L,V)),n.curves.push(new p.QuadraticBezierCurve3(V,M,G)),b=G}n.curves.push(new p.LineCurve3(b,t[t.length-1]))}const o=i.radius||2,a=i.radialSegments||8,c=i.tubularSegments||64,u=new p.TubeGeometry(n,c,o,a,!1),d=5,m=new p.MeshPhongMaterial({color:i.color||"#19bbd5",side:p.DoubleSide,emissive:new p.Color(i.color||"#19bbd5"),emissiveIntensity:.6*d,transparent:!0});m.defines={USE_UV:""};const g={totalLength:{value:n.getLength()},stripeOffset:{value:0},stripeWidth:{value:i.stripeWidth||10},stripeSpacing:{value:i.stripeSpacing||20},stripeColor:{value:new p.Color(i.stripeColor||"#096be3")},speedFactor:{value:i.speed||10},bloomBoost:{value:d}};m.onBeforeCompile=b=>{b.uniforms.totalLength=g.totalLength,b.uniforms.stripeOffset=g.stripeOffset,b.uniforms.stripeWidth=g.stripeWidth,b.uniforms.stripeSpacing=g.stripeSpacing,b.uniforms.stripeColor=g.stripeColor,b.uniforms.bloomBoost=g.bloomBoost,b.fragmentShader=`
632
+ uniform float totalLength;
633
+ uniform float stripeOffset;
634
+ uniform float stripeWidth;
635
+ uniform float stripeSpacing;
636
+ uniform vec3 stripeColor;
637
+ uniform float bloomBoost;
638
+ ${b.fragmentShader}
639
+ `.replace("#include <color_fragment>",`#include <color_fragment>
640
+ // 计算条纹模式(用于漫反射)
641
+ float pattern = mod((vUv.x - stripeOffset) * totalLength / (stripeWidth + stripeSpacing), 1.0);
642
+ float isStripe = step(pattern, stripeWidth / (stripeWidth + stripeSpacing));
643
+
644
+ // 混合条纹颜色
645
+ diffuseColor.rgb = mix(diffuseColor.rgb, stripeColor, isStripe);
646
+
647
+ // 条纹区域再额外提亮,让 bloom 更明显
648
+ if (isStripe > 0.5) {
649
+ diffuseColor.rgb += stripeColor * (3.0 * bloomBoost);
650
+ }
651
+ `).replace("#include <emissivemap_fragment>",`#include <emissivemap_fragment>
652
+ // 计算条纹模式(用于自发光)
653
+ float pattern_e = mod((vUv.x - stripeOffset) * totalLength / (stripeWidth + stripeSpacing), 1.0);
654
+ float isStripe_e = step(pattern_e, stripeWidth / (stripeWidth + stripeSpacing));
655
+
656
+ // 自发光通道也叠加一遍,进一步抬高亮度
657
+ totalEmissiveRadiance += stripeColor * isStripe_e * (3.0 * bloomBoost);
658
+ `)};const _=new p.Mesh(u,m);let w=0;return _.onBeforeRender=()=>{const b=performance.now(),x=w?(b-w)/1e3:.016;w=b;const L=g.speedFactor.value/g.totalLength.value*10;g.stripeOffset.value-=x*L,g.stripeOffset.value=g.stripeOffset.value%1},_}function Ic(i,e){let t=[];if(Array.isArray(e)&&typeof e[0]=="number")for(let C=0;C<e.length;C+=3)t.push(new p.Vector3(e[C],e[C+1],e[C+2]));else if(e instanceof Float32Array)for(let C=0;C<e.length;C+=3)t.push(new p.Vector3(e[C],e[C+1],e[C+2]));else t=e;if(t.length<2)return new p.Mesh;const n=new p.CurvePath,r=i.cornerRadius||5;if(t.length===2||r<=0)for(let C=0;C<t.length-1;C++){const Z=new p.LineCurve3(t[C],t[C+1]);n.curves.push(Z)}else{let C=t[0];for(let Z=1;Z<t.length-1;Z++){const z=C,D=t[Z],X=t[Z+1],I=new p.Vector3().subVectors(D,z),K=new p.Vector3().subVectors(X,D),V=I.length(),G=K.length(),k=Math.min(V,G)*.4,j=Math.min(r,k);I.normalize().multiplyScalar(V-j),K.normalize().multiplyScalar(j);const Y=new p.Vector3().addVectors(z,I),H=new p.Vector3().addVectors(D,K);n.curves.push(new p.LineCurve3(z,Y)),n.curves.push(new p.QuadraticBezierCurve3(Y,D,H)),C=H}n.curves.push(new p.LineCurve3(C,t[t.length-1]))}const o=i.width||4,c=n.getPoints(128),u=[],d=[],m=[];let f=0;const g=n.getLength();for(let C=0;C<c.length;C++){const Z=c[C];let z;C===0?z=new p.Vector3().subVectors(c[1],c[0]):C===c.length-1?z=new p.Vector3().subVectors(c[C],c[C-1]):z=new p.Vector3().subVectors(c[C+1],c[C-1]),z.y=0,z.normalize();const D=new p.Vector3(-z.z,0,z.x),X=o/2,I=new p.Vector3(Z.x+D.x*X,Z.y,Z.z+D.z*X),K=new p.Vector3(Z.x-D.x*X,Z.y,Z.z-D.z*X);u.push(I.x,I.y,I.z),u.push(K.x,K.y,K.z),C>0&&(f+=c[C].distanceTo(c[C-1]));const V=f/g;if(d.push(V,0),d.push(V,1),C<c.length-1){const G=C*2;m.push(G,G+1,G+2),m.push(G+1,G+3,G+2)}}const _=new p.BufferGeometry;_.setAttribute("position",new p.BufferAttribute(new Float32Array(u),3)),_.setAttribute("uv",new p.BufferAttribute(new Float32Array(d),2)),_.setIndex(m),_.computeVertexNormals();const w=5,b=new p.MeshPhongMaterial({color:i.color||"#0ED5FD",side:p.DoubleSide,emissive:new p.Color(i.color||"#0ED5FD"),emissiveIntensity:5,transparent:!0});b.defines={USE_UV:""};const x={totalLength:{value:g},stripeOffset:{value:0},arrowLength:{value:i.arrowLength||20},arrowSpacing:{value:i.arrowSpacing||80},arrowColor:{value:new p.Color(i.color||"#0ED5FD")},speedFactor:{value:i.speed||10},bloomBoost:{value:w}};b.onBeforeCompile=C=>{C.uniforms.totalLength=x.totalLength,C.uniforms.stripeOffset=x.stripeOffset,C.uniforms.arrowLength=x.arrowLength,C.uniforms.arrowSpacing=x.arrowSpacing,C.uniforms.arrowColor=x.arrowColor,C.uniforms.bloomBoost=x.bloomBoost,C.fragmentShader=C.fragmentShader.replace("uniform vec3 diffuse;",`uniform vec3 diffuse;
659
+ uniform float totalLength;
660
+ uniform float stripeOffset;
661
+ uniform float arrowLength;
662
+ uniform float arrowSpacing;
663
+ uniform vec3 arrowColor;
664
+ uniform float bloomBoost;`),C.fragmentShader=C.fragmentShader.replace("#include <color_fragment>",`#include <color_fragment>
665
+ {
666
+ float tpat = arrowLength + arrowSpacing;
667
+ float posi = mod((vUv.x - stripeOffset) * totalLength, tpat);
668
+ float inArrow = step(posi, arrowLength);
669
+ float npos = posi / arrowLength;
670
+
671
+ float centerDist = abs(vUv.y - 0.5);
672
+
673
+ float h0 = step(npos, 0.5);
674
+ float headWidth = mix(0.0, 1.5, npos / 0.5);
675
+ float shaftWidth = 0.6;
676
+ float arrowWidth = mix(shaftWidth, headWidth, h0);
677
+ float arrowShape = step(centerDist, arrowWidth * 0.5);
678
+
679
+ float mask = inArrow * arrowShape;
680
+ mask = clamp(mask, 0.0, 1.0);
681
+
682
+ diffuseColor.rgb = arrowColor;
683
+ diffuseColor.a = mask;
684
+ }`),C.fragmentShader=C.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissivemap_fragment>
685
+ {
686
+ float tpat2 = arrowLength + arrowSpacing;
687
+ float posi2 = mod((vUv.x - stripeOffset) * totalLength, tpat2);
688
+ float inArrow2 = step(posi2, arrowLength);
689
+ float npos2 = posi2 / arrowLength;
690
+
691
+ float centerDist2 = abs(vUv.y - 0.5);
692
+
693
+ float h02 = step(npos2, 0.5);
694
+ float headWidth2 = mix(0.0, 1.5, npos2 / 0.5);
695
+ float shaftWidth2 = 0.6;
696
+ float arrowWidth2 = mix(shaftWidth2, headWidth2, h02);
697
+ float arrowShape2 = step(centerDist2, arrowWidth2 * 0.5);
698
+
699
+ float mask2 = inArrow2 * arrowShape2;
700
+ mask2 = clamp(mask2, 0.0, 1.0);
701
+
702
+ totalEmissiveRadiance += arrowColor * mask2 * 0.5;
703
+ }`)};const L=new p.Mesh(_,b);let M=0;return L.onBeforeRender=()=>{const C=performance.now(),Z=M?(C-M)/1e3:.016;M=C;const z=x.speedFactor.value/x.totalLength.value*10;x.stripeOffset.value-=Z*z,x.stripeOffset.value=x.stripeOffset.value%1},L}async function Ac(i,e){let t=[];if(Array.isArray(e)&&typeof e[0]=="number"){const G=e;for(let k=0;k<G.length;k+=3)t.push(new p.Vector3(G[k],G[k+1],G[k+2]))}else if(e instanceof Float32Array)for(let G=0;G<e.length;G+=3)t.push(new p.Vector3(e[G],e[G+1],e[G+2]));else t=e;if(t.length<2)return new p.Mesh;const n=(i.width??10)*.5,r=[],o=[],a=[];let c=0;const u=[0];for(let G=1;G<t.length;G++){const k=t[G].distanceTo(t[G-1]);c+=k,u.push(c)}if(c===0)return new p.Mesh;const d=i.repeat??1,m=[],f=[];for(let G=0;G<t.length;G++){let k=new p.Vector3;G===0?k.subVectors(t[G+1],t[G]):G===t.length-1?k.subVectors(t[G],t[G-1]):k.subVectors(t[G+1],t[G-1]),k.normalize();const j=new p.Vector3(0,1,0);let Y=new p.Vector3().crossVectors(k,j);Y.lengthSq()<1e-10?Y.set(1,0,0):Y.normalize(),m.push(t[G].clone().add(Y.clone().multiplyScalar(-n))),f.push(t[G].clone().add(Y.clone().multiplyScalar(n)))}let g=0,_=0;for(let G=1;G<m.length;G++)g+=m[G].distanceTo(m[G-1]),_+=f[G].distanceTo(f[G-1]);if((g+_)/2===0)return new p.Mesh;for(let G=0;G<t.length;G++){r.push(m[G].x,m[G].y,m[G].z,f[G].x,f[G].y,f[G].z);const k=u[G]/c*d;o.push(k,0,k,1)}const b=t.length-1;for(let G=0;G<b;G++){const k=G*2,j=G*2+1,Y=(G+1)*2,H=(G+1)*2+1;a.push(k,Y,j),a.push(Y,H,j)}const x=new p.BufferGeometry;x.setAttribute("position",new p.BufferAttribute(new Float32Array(r),3)),x.setAttribute("uv",new p.BufferAttribute(new Float32Array(o),2)),x.setIndex(a),x.computeBoundingBox(),x.computeVertexNormals();const L=await xt._loadTexture(i.flowTexture);L.wrapS=p.RepeatWrapping,L.wrapT=p.RepeatWrapping,L.anisotropy=4,L.needsUpdate=!0;const M=new p.Color(i.color??16777215),Z={uMap:{value:L},uColor:{value:M},uOpacity:{value:i.opacity??1},uOffset:{value:0},uBloomBoost:{value:5}},z=i.depthOffset??1,D=z!==0,X=new p.ShaderMaterial({uniforms:Z,vertexShader:`
704
+ varying vec2 vUv;
705
+ void main() {
706
+ vUv = uv;
707
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
708
+ }
709
+ `,fragmentShader:`
710
+ uniform sampler2D uMap;
711
+ uniform vec3 uColor;
712
+ uniform float uOpacity;
713
+ uniform float uOffset;
714
+ uniform float uBloomBoost;
715
+ varying vec2 vUv;
716
+
717
+ void main() {
718
+ // 关键修复:修正UV滚动计算,确保方向正确[3](@ref)
719
+ vec2 uv = vec2(fract(vUv.x + uOffset), vUv.y);
720
+ vec4 texColor = texture2D(uMap, uv);
721
+
722
+ // 添加alpha测试,完全透明的片元直接丢弃
723
+ if (texColor.a < 0.01) discard;
724
+
725
+ float alpha = texColor.a * uOpacity;
726
+ vec3 baseColor = texColor.rgb * uColor;
727
+ // 使用更自然的颜色增强公式
728
+ vec3 finalColor = baseColor * uBloomBoost;
729
+
730
+ gl_FragColor = vec4(finalColor, alpha);
731
+ }
732
+ `,transparent:i.transparent??!0,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!1,blending:p.AdditiveBlending,side:p.DoubleSide,polygonOffset:D,polygonOffsetFactor:-z,polygonOffsetUnits:-z}),I=new p.Mesh(x,X);let K=0;I.onBeforeRender=()=>{const G=performance.now(),k=K?(G-K)/1e3:.016;K=G;const j=i.speed??10;Z.uOffset.value=V(Z.uOffset.value-k*j/c)};function V(G){return G-Math.floor(G)}return I}async function ng(i,e){const t=i.type||(i.url.toLowerCase().endsWith(".fbx")?"fbx":"gltf");return await Cc.init().load({...i,type:t,position:e})}function rg(i,e){const{geometry:t,center:n,avgY:r}=Qo(e),o=i.depthOffset??0,a=o!==0,c=new p.MeshBasicMaterial({color:new p.Color(i.color??16777215),transparent:i.transparent??!0,opacity:i.opacity??1,wireframe:i.wireframe??!1,side:i.side==="back"?p.BackSide:i.side==="double"?p.DoubleSide:p.FrontSide,polygonOffset:a,polygonOffsetFactor:a?o:0,polygonOffsetUnits:a?o:0,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0}),u=new p.Mesh(t,c);if(u.rotation.x=-Math.PI/2,u.position.set(n.x,r,n.z),(i.borderWidth??0)>0){const f={color:i.borderColor??i.color??0,width:i.borderWidth},g=[];for(let w=0;w<e.length;w+=3){const b=e[w],x=e[w+2];g.push(b-n.x,-(x-n.z),0)}const _=Jo(f,g);_.position.z+=.1,u.add(_)}return u}function ig(i,e){const t=i.extrude?.height||2e3,n=[],r=[],o=[];for(let f=0;f<e.length;f+=3){const g=e[f],_=e[f+1],w=e[f+2];r.push(new p.Vector3(g,_,w)),o.push(new p.Vector3(g,_+t,w))}n.push(...r,...o);const a=new p.BufferGeometry;a.setFromPoints(n);const c=[],u=r.length;for(let f=0;f<u;f++){const g=(f+1)%u;c.push(f,f+u,g),c.push(g,f+u,g+u)}for(let f=2;f<u;f++)c.push(0,f-1,f),c.push(u,u+f-1,u+f);a.setIndex(c),a.computeVertexNormals();const d=new p.ShaderMaterial({uniforms:{uColor:{value:new p.Color(i.color??16777215)},uOpacity:{value:i.opacity??1},uBrightness:{value:1.2}},vertexShader:`
573
733
  varying vec3 vWorldPosition;
574
734
  varying vec3 vNormal;
575
735
  void main() {
576
- vNormal = normalize(normalMatrix * normal); // 法线转换到世界坐标
736
+ vNormal = normalize(normalMatrix * normal);
577
737
  vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
578
738
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
579
739
  }
@@ -585,22 +745,36 @@
585
745
  varying vec3 vNormal;
586
746
 
587
747
  void main() {
588
- // 1. 计算菲涅尔效应(边缘高光)
589
748
  float fresnel = pow(1.0 - abs(dot(vNormal, vec3(0.0, 0.0, 1.0))), 2.0);
590
-
591
- // 2. 内部折角增亮(根据位置模拟凹陷效果)
592
749
  float innerGlow = smoothstep(0.3, 0.8, length(vWorldPosition - vec3(0.0))) * uBrightness;
593
-
594
- // 3. 混合颜色
595
750
  vec3 finalColor = uColor * (1.0 + fresnel * 0.5 + innerGlow);
596
-
597
- // 4. 强制透明度排序(深度测试后混合)
598
751
  gl_FragColor = vec4(finalColor, uOpacity);
599
-
600
- // 5. 深度写入控制(保持与不透明物体正确交互)
601
752
  if (uOpacity >= 0.99) gl_FragDepthEXT = gl_FragCoord.z;
602
753
  }
603
- `,transparent:!0,side:h.DoubleSide,depthWrite:!0}),d=new h.Mesh(s,u);return d.renderOrder=5e3,d}function Mo(o,t,e){const{geometry:n,center:i,avgY:r}=oi(e),s=new Ui(n,{textureWidth:512,textureHeight:512,waterNormals:new h.TextureLoader().load(o.normalMap,function(u){u.wrapS=u.wrapT=h.RepeatWrapping}),waterColor:o.color||"#19AAEE",sunColor:o.sunColor||"#05FFF8",distortionScale:1,alpha:o.opacity||.8}),a=s.onBeforeRender,l=s.onAfterRender;return s.onBeforeRender=(u,d,c,p,f,m)=>{t.tilemap.autoUpdate=!1,a.call(s,u,d,c,p,f,m)},s.onAfterRender=(u,d,c,p,f,m)=>{t.tilemap.autoUpdate=!0,l.call(s,u,d,c,p,f,m)},s.material.uniforms.size.value=.1,s.rotation.x=-Math.PI/2,s.position.set(i.x,r,i.z),t.viewer.addEventListener("update",()=>{s.material.uniforms.time.value+=1/60}),s}function oi(o){let t=0;for(let s=1;s<o.length;s+=3)t+=o[s];t/=o.length/3;const e={x:0,z:0},n=[];for(let s=0;s<o.length;s+=3)e.x+=o[s],e.z+=o[s+2];e.x/=o.length/3,e.z/=o.length/3;for(let s=0;s<o.length;s+=3)n.push(new h.Vector2(o[s]-e.x,-(o[s+2]-e.z)));const i=new h.Shape(n);return{geometry:new h.ShapeGeometry(i),center:e,avgY:t}}async function _o(o,t){const{geometry:e,center:n,avgY:i}=oi(t),r=await Ge._loadTexture(o.normalMap);r.wrapS=r.wrapT=h.RepeatWrapping,r.repeat.set(.01,.01),r.needsUpdate=!0;const s=new h.MeshStandardMaterial({color:new h.Color(o.color).multiplyScalar(2),roughness:0,metalness:.6,transparent:!0,opacity:.9,fog:!1,bumpMap:r,bumpScale:.6}),a=new h.Mesh(e,s);a.rotation.x=-Math.PI/2,a.position.set(n.x,i,n.z),a.castShadow=!1,a.receiveShadow=!0;let l=0;const u=2.5;return a.onBeforeRender=()=>{const d=performance.now(),c=l?(d-l)/1e3:.016;r.offset.x+=c*u*.1,r.offset.y+=c*u*.05,l=d},a}function Zo(o,t){o.color=new h.Color(o.hexcolor),o.boundstext&&(o.bounds=new h.Vector3(o.boundstext.x,o.boundstext.y,o.boundstext.z));const e=new wo(o);return e.castShadow=!0,e.scale.setScalar(50),e.position.copy(t),e}async function Io(o,t){const n={...{fontSize:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,fixedSize:50},...o};n.fontSize=Math.min(Math.max(n.fontSize,8),128);const i=document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("canvas context is null");const s=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`;r.font=s;const a=n.showBackground?20:0,l=100,u=50,d=r.measureText(n.text),c=Math.max(l,d.width+a*2),p=Math.max(u,n.fontSize*1.5+a*2);i.width=Math.min(c,2048),i.height=Math.min(p,2048),r.clearRect(0,0,i.width,i.height),r.font=s,n.showBackground&&(n.bgStyle===1?(r.fillStyle=n.bgColor,r.globalAlpha=n.bgOpacity,r.beginPath(),ai(r,a/2,a/2,i.width-a,i.height-a,n.roundRectRadius),r.fill(),r.globalAlpha=1,r.shadowColor=n.shadowColor,r.shadowBlur=n.shadowBlur,r.shadowOffsetX=n.shadowOffsetX,r.shadowOffsetY=n.shadowOffsetY):(r.fillStyle=n.bgColor,r.globalAlpha=n.bgOpacity,r.beginPath(),li(r,i.width/2,i.height/2,i.width*.8,i.height*.8,n.roundRectRadius,n.bubblePointerHeight,n.bubblePointerWidth),r.fill(),r.globalAlpha=1,r.strokeStyle=n.bubbleBorderColor,r.lineWidth=n.bubbleBorderWidth,r.stroke())),r.textAlign="center",r.textBaseline="middle",n.strokeWidth>0&&(r.strokeStyle=n.strokeColor,r.lineWidth=n.strokeWidth,r.lineJoin="round",r.strokeText(n.text,i.width/2,i.height/2)),r.fillStyle=n.textColor,r.fillText(n.text,i.width/2,i.height/2),r.shadowColor="transparent";const f=new h.CanvasTexture(i);f.magFilter=h.NearestFilter,f.minFilter=h.LinearMipmapLinearFilter,f.anisotropy=16;const m=new h.SpriteMaterial({map:f,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1}),v=new h.Sprite(m),g=n.fixedSize;return v.scale.set(i.width*g/100,i.height*g/100,1),t&&v.position.copy(t),v.renderOrder=9999,v}async function To(o,t,e){const i={...{fontSize:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,maxVisibleDistance:1/0},...o};i.fontSize=Math.min(Math.max(i.fontSize,8),128);const r=document.createElement("canvas"),s=r.getContext("2d");if(!s)throw new Error("Failed to get canvas context");const a=`${i.fontStyle} ${i.fontWeight} ${i.fontSize}px ${i.fontFamily}`;s.font=a;const l=i.showBackground?20:0,u=100,d=50,c=s.measureText(i.text),p=Math.max(u,c.width+l*2),f=Math.max(d,i.fontSize*1.5+l*2);r.width=Math.min(p,2048),r.height=Math.min(f,2048),s.clearRect(0,0,r.width,r.height),s.font=a,i.showBackground&&(i.bgStyle===1?(s.fillStyle=i.bgColor,s.globalAlpha=i.bgOpacity,s.beginPath(),ai(s,l/2,l/2,r.width-l,r.height-l,i.roundRectRadius),s.fill(),s.globalAlpha=1,s.shadowColor=i.shadowColor,s.shadowBlur=i.shadowBlur,s.shadowOffsetX=i.shadowOffsetX,s.shadowOffsetY=i.shadowOffsetY):(s.fillStyle=i.bgColor,s.globalAlpha=i.bgOpacity,s.beginPath(),li(s,r.width/2,r.height/2,r.width*.8,r.height*.8,i.roundRectRadius,i.bubblePointerHeight,i.bubblePointerWidth),s.fill(),s.globalAlpha=1,s.strokeStyle=i.bubbleBorderColor,s.lineWidth=i.bubbleBorderWidth,s.stroke())),s.textAlign="center",s.textBaseline="middle",i.strokeWidth>0&&(s.strokeStyle=i.strokeColor,s.lineWidth=i.strokeWidth,s.lineJoin="round",s.strokeText(i.text,r.width/2,r.height/2)),s.fillStyle=i.textColor,s.fillText(i.text,r.width/2,r.height/2),s.shadowColor="transparent";const m=new h.CanvasTexture(r),v=new h.SpriteMaterial({map:m,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1}),g=new h.Sprite(v);g.position.copy(t),g.renderOrder=9999,g.userData.isLabel=!0;const b=()=>{if(!g.visible)return;const w=e.viewer.camera.position.distanceTo(g.position);if(w>i.maxVisibleDistance){g.visible=!1;return}g.visible=!0;const S=new h.Vector2;e.viewer.renderer.getSize(S);const P=S.height,I=i.screenSpaceSize/r.height*(w/Math.tan(h.MathUtils.degToRad(e.viewer.camera.fov)/2))*(2/P);g.scale.set(I*r.width,I*r.height,1),g.lookAt(e.viewer.camera.position)};b();const y=()=>b();return g.addEventListener("dispose",()=>{e.viewer.renderer.domElement.removeEventListener("resize",b)}),e.viewer.renderer.domElement.addEventListener("resize",b),e.viewer.camera.addEventListener("change",b),g.onBeforeRender=y,g}function ai(o,t,e,n,i,r){o.beginPath(),o.moveTo(t+r,e),o.lineTo(t+n-r,e),o.quadraticCurveTo(t+n,e,t+n,e+r),o.lineTo(t+n,e+i-r),o.quadraticCurveTo(t+n,e+i,t+n-r,e+i),o.lineTo(t+r,e+i),o.quadraticCurveTo(t,e+i,t,e+i-r),o.lineTo(t,e+r),o.quadraticCurveTo(t,e,t+r,e),o.closePath()}function li(o,t,e,n,i,r,s,a){if(n<=0)throw new Error("Width must be positive");if(i<=0)throw new Error("Height must be positive");if(r<0)throw new Error("Radius cannot be negative");const l=n,u=i,d=Math.min(r,n/2,i/2),c=s??10,p=a??15;o.beginPath(),o.moveTo(t-l/2+d,e-u/2),o.lineTo(t+l/2-d,e-u/2),o.quadraticCurveTo(t+l/2,e-u/2,t+l/2,e-u/2+d),o.lineTo(t+l/2,e+u/2-d),o.quadraticCurveTo(t+l/2,e+u/2,t+l/2-d,e+u/2),o.lineTo(t+p/2,e+u/2),o.lineTo(t,e+u/2+c),o.lineTo(t-p/2,e+u/2),o.lineTo(t-l/2+d,e+u/2),o.quadraticCurveTo(t-l/2,e+u/2,t-l/2,e+u/2-d),o.lineTo(t-l/2,e-u/2+d),o.quadraticCurveTo(t-l/2,e-u/2,t-l/2+d,e-u/2),o.closePath()}async function Po(o,t,e){const{text:n,iconUrl:i,fontSize:r=30,iconSize:s=60,fontFamily:a="Arial",padding:l={},bgColor:u="rgba(0,0,0,0.0)",textColor:d="rgb(255,255,255)",strokeColor:c="rgb(0,0,0)",strokeWidth:p=r/9,iconScale:f=.8,canvasScale:m=1,renderbg:v=!0}=o,g={top:0,right:1,bottom:0,left:0,...l};let b=null;i&&(b=await Wo(i));const{canvas:y,width:w,height:S,center:P}=await Ao({text:n,iconImage:b,fontSize:r,iconSize:s,fontFamily:a,padding:g,bgColor:u,textColor:d,strokeColor:c,strokeWidth:p,iconScale:f,canvasScale:m,renderbg:v},t),I=new h.Texture(y);I.needsUpdate=!0;const T=new h.SpriteMaterial({map:I,transparent:!0,depthTest:!0,depthWrite:!0,blending:h.NormalBlending}),M=new h.Sprite(T);return M.scale.set(w,S,1),M.center.set(P[0],P[1]),e&&M.position.copy(e),M.renderOrder=999,M}async function Ao(o,t){return new Promise(e=>{const{text:n,iconImage:i,fontSize:r,iconSize:s,fontFamily:a,padding:l,bgColor:u,textColor:d,strokeColor:c,strokeWidth:p,iconScale:f,canvasScale:m,renderbg:v}=o,g=n.length*r,b=l.left+s+g+l.right,y=Math.max(s,r)+l.top+l.bottom,w=t._getCanvas(b,y,n);w.width=b,w.height=y;const S=w.getContext("2d");if(!S)throw new Error("Could not get canvas context");if(v&&(S.fillStyle=u,S.fillRect(0,0,b,y)),i){const T=l.left+s*(1-f)*.5,M=l.top+s*(1-f)*.5,A=s*f,L=s*f;S.drawImage(i,T,M,A,L)}S.font=`500 ${r}px ${a}`,S.textBaseline="middle",S.imageSmoothingEnabled=!1;const P=l.left+(i?s+2:0),I=y/2;p>0&&(S.lineWidth=p,S.strokeStyle=c,S.strokeText(n,P,I)),S.fillStyle=d,S.fillText(n,P,I),e({canvas:w,width:b/m,height:y/m,center:[s*.5/b,(1-f)*.5]})})}function Wo(o){return new Promise((t,e)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>t(n),n.onerror=i=>e(new Error(`Failed to load image: ${o} ${i}`)),n.src=o})}const he=class he{constructor(t){this.config=t}async applyTo(t){if(!t)return!1;try{switch(t.visible=this.config.visible!==!1,this.config.zIndex&&(t.renderOrder=this.config.zIndex),this.config.type){case"basic-point":case"icon-point":case"icon-label-point":return this._applyPointStyle(t);case"basic-line":return this._applyLineStyle(t);case"gltf":case"fbx":return this._applyModelStyle(t);case"basic-polygon":return this._applyPolygonStyle(t);case"extrude-polygon":return this._applyExtrudeStyle(t);case"water":case"base-water":return this._applyWaterStyle(t);case"cloud":return this._applyCloudStyle(t);case"canvas-label":case"canvas-label-fixed":return this._applyTextSpriteStyle(t);case"custom":return this._applyCustomStyle(t);default:throw new Error("Unknown style type")}}catch(e){return console.error("Style apply failed:",e),t.visible=!1,!1}}async _applyPointStyle(t){const e=this.config;return e.type==="icon-point"?await this._applyIconPoint(t,e):e.type==="basic-point"?this._applyBasicPoint(t,e):e.type==="icon-label-point"&&this._applyIconLabelPoint(t,e),!0}async _applyIconPoint(t,e){let n;if(t instanceof h.Sprite)n=t;else if(n=await si(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.renderOrder=999,t.parent){let a=t.parent;a._threeGeometry=n,a._updateGeometry()}const[i,r]=e.size;if(i<=0||r<=0){console.error("Invalid sprite size:",e.size),n.visible=!1;return}const s=n.material;try{if(s.map=await he._loadTexture(e.url),!s.map)throw new Error("Texture failed to load");s.needsUpdate=!0,n.scale.set(i,r,1),e.rotation!==void 0&&(n.rotation.z=e.rotation)}catch(a){console.error("Failed to load texture:",e.url,a),n.visible=!1}}_applyBasicPoint(t,e){let n;if(t instanceof h.Points)n=t;else if(n=ri(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),n.renderOrder=999,t.parent){let r=t.parent;r._threeGeometry=n,r._updateGeometry()}const i=n.material;i.size=e.size,e.color&&i.color.set(e.color),e.glow&&(i.sizeAttenuation=!1)}_applyIconLabelPoint(t,e){return!0}_applyLineStyle(t){const e=this.config;if(t.parent){let n=t.parent;n._threeGeometry=Qt(e,n._vertexPoints),n._updateGeometry()}return!0}_applyPolygonStyle(t){return this.config,!0}_applyExtrudeStyle(t){return this.config,!0}_applyWaterStyle(t){return this.config.type,!0}_applyCloudStyle(t){return this.config,!0}_applyTextSpriteStyle(t){return this.config,!0}async _applyModelStyle(t){return this.config,!0}async _applyCustomStyle(t){const n=await this.config.build();return t instanceof h.Group&&(t.clear(),t.add(n)),!0}static async _loadTexture(t){if(he._textureCache.has(t))return he._textureCache.get(t);const e=await new Promise((n,i)=>{he._textureLoader.load(t,n,void 0,i)});return e.premultiplyAlpha=!0,he._textureCache.set(t,e),e.premultiplyAlpha=!0,e}static create(t){return t instanceof he?t:new he(t)}};x(he,"_textureCache",new Map),x(he,"_textureLoader",new h.TextureLoader);let Ge=he;class $e extends Bt(Nt(h.Object3D)){constructor(e){super();x(this,"_position");x(this,"_threeGeometry");x(this,"_geometry");x(this,"_layer");x(this,"_style");x(this,"_styleQueue",[]);x(this,"_isApplyingStyle",!1);x(this,"_isGeometryInitializing",!1);Kt(e.geometry,"geometry","geometry must be specified"),this._geometry=e.geometry,this._position=new h.Vector3(0,0,0),this._threeGeometry=new h.Object3D,e.userData&&(this.userData=Object.assign({},JSON.parse(JSON.stringify(e.userData)))),e.style&&this.setStyle(e.style)}async initializeGeometry(){if(!(this._isGeometryInitializing||this._threeGeometry)){this._isGeometryInitializing=!0;try{await this._toThreeJSGeometry(),this._processStyleQueue()}finally{this._isGeometryInitializing=!1}}}setStyle(e){const n=e instanceof Ge?e:new Ge(e);this._style=n;const i=JSON.parse(JSON.stringify(n.config));return this._styleQueue.push(i),this._tryProcessQueue(),this}getStyle(){return this._style}async _applyStyleWithRetry(e,n=3,i=100){let r=null;for(let s=1;s<=n;s++)try{this._threeGeometry.parent||(this.add(this._threeGeometry),await new Promise(a=>requestAnimationFrame(a))),await e.applyTo(this._threeGeometry);return}catch(a){if(r=a,s<n){const l=i*Math.pow(2,s-1);console.warn(`[Feature] 重试中... (${s}/${n})`,{delay:l,error:a}),await new Promise(u=>setTimeout(u,l))}}throw r||new Error("样式应用失败,重试次数耗尽")}async _processStyleQueue(){if(!this._threeGeometry||this._isApplyingStyle||this._styleQueue.length===0){console.warn("[Feature] 取消处理:不满足运行时条件");return}this._isApplyingStyle=!0;const e=this._styleQueue[0];try{if(!e)throw new Error(`无效样式配置: ${JSON.stringify(e)}`);const n=new Ge(JSON.parse(JSON.stringify(e)));await this._applyStyleWithRetry(n),this._styleQueue.shift(),this._styleQueue.length>0&&await this._processStyleQueue()}catch(n){throw console.error("[Feature] 样式应用失败:",{error:n,remainingQueue:this._styleQueue.length}),n}finally{this._isApplyingStyle=!1,this._styleQueue.length>0&&this._tryProcessQueue()}}_tryProcessQueue(){this._threeGeometry&&!this._isApplyingStyle&&this._styleQueue.length>0?this._processStyleQueue().then(()=>{}).catch(n=>{console.error("[Feature] 队列处理失败:",n),this._isApplyingStyle=!1,this._tryProcessQueue()}):!this._threeGeometry&&!this._isGeometryInitializing&&(console.debug("[Feature] 触发延迟初始化"),this.initializeGeometry())}addTo(e){return e.addFeature(this),this}getLayer(){return this._layer||null}getMap(){return this._layer?.getMap()||null}_bindLayer(e){if(this._layer&&this._layer!==e)throw new Error("Feature cannot be added to multiple layers");this._layer=e}_updateGeometry(){this._disposeGeometry(),this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry.renderOrder=999,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue())}_remove(){return this.getLayer()?(this._unbind(),this):this}_unbind(){const e=this.getLayer();e&&(e.onRemoveFeature&&e.onRemoveFeature(this),delete this._layer)}_disposeGeometry(){this._threeGeometry&&(this.clear(),"traverse"in this&&this._threeGeometry.traverse(e=>{e instanceof h.Mesh?(e.geometry?.dispose(),Array.isArray(e.material)?e.material.forEach(n=>n.dispose()):e.material?.dispose()):"isLine"in e&&e.isLine&&(e.geometry?.dispose(),e.material?.dispose())}))}}class gt extends jt{constructor(e,n){super(e,n);x(this,"_feaList");this._feaList=[]}addFeature(e){const n=Array.isArray(e)?e:[e];for(const i of n)if(!(!i||!(i instanceof $e))&&!i.getLayer()){if(!this.validateFeature(i)){console.error(`Feature ${i.id} does not match the layer's type requirements`);continue}i._bindLayer(this),this._feaList.push(i),i.getMap()&&i._toThreeJSGeometry(),this._clouds&&(this.map.viewer.scene.add(this._clouds),console.log("我是云朵被添加cloud",this.map.viewer.scene)),this.add(i)}return this}getFeatures(e,n){if(!e)return this._feaList.slice(0);const i=[];let r,s;for(let a=0,l=this._feaList.length;a<l;a++)r=this._feaList[a],n?s=e.call(n,r):s=e(r),s&&i.push(r);return i}getCount(){return this._feaList.length}isEmpty(){return!this._feaList.length}removeFeature(e){if(!Array.isArray(e))return this.removeFeature([e]);for(let n=e.length-1;n>=0;n--)e[n]instanceof $e||(e[n]=this.removeFeature(e[n])),!(!e[n]||this!==e[n].getLayer())&&e[n]._remove();return this}onRemoveFeature(e){if(!e||this!==e.getLayer())return;const n=this._findInList(e);n>=0&&this._feaList.splice(n,1),e.parent&&e.parent===this?this.remove(e):console.warn("Feature parent mismatch:",e.parent),this._disposeFeatureResources(e)}_findInList(e){const n=this._feaList.length;if(n===0)return-1;let i=0,r=n-1,s;for(;i<=r;){if(s=Math.floor((i+r)/2),this._feaList[s]===e)return s;i=s+1}return-1}_disposeFeatureResources(e){try{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>n.dispose?.()):e.material.dispose&&e.material.dispose()),e instanceof h.Object3D&&e.traverse(n=>{n!==e&&this._disposeFeatureResources(n)})}catch(n){console.error("Error disposing feature resources:",n)}}}class Go extends gt{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Line"}}class Vo extends gt{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Point"}}class Co extends gt{constructor(t,e){super(t,e)}validateFeature(t){return t._baseType==="Surface"}}class ko extends gt{constructor(e,n){super(e,n);x(this,"_clouds",null);const i=["texture"];for(const r of i)$n(n,r);this._createClouds(n.texture)}async _createClouds(e){const n=await Ge._loadTexture(e),i=new bo({texture:n,material:h.MeshBasicMaterial});i.castShadow=!0,i.renderOrder=99999,this._clouds=i}validateFeature(e){return e._type==="Cloud"}animate(e,n){this._clouds&&this._clouds.update(this.map.viewer.camera,n,e)}}class bt extends $e{constructor(e){super(e);x(this,"_baseType","Point");this._threeGeometry=this._createThreeGeometry(),this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=new h.Vector3(this._geometry.coordinates[0],this._geometry.coordinates[1],this._geometry.coordinates[2]||500);return e?e.geo2world(n):n}_toThreeJSGeometry(){}_createThreeGeometry(){return new h.Points(new h.BufferGeometry,new h.PointsMaterial({size:1,color:8947848}))}}const Do={};class ci extends bt{constructor(e){super(e);x(this,"_type","Maker")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-point":return ri(e.config,new h.Vector3(0,0,0));case"icon-point":return si(e.config,this._position);case"icon-label-point":return Po(e.config,this.getMap(),this._position);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}ci.mergeOptions(Do);class ui extends $e{constructor(e){super(e);x(this,"_baseType","Line");x(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=this._geometry;if(this._geometry.type==="LineString"){let r=n.coordinates.map(a=>{const l=new h.Vector3(a[0],a[1],a[2]||0);return e?e.geo2world(l):l}),s=r.flatMap(a=>[a.x,a.y,a.z]);return{_position:r,_vertexPoints:s}}}_toThreeJSGeometry(){}_createThreeGeometry(){const e=new ut,n=new Je({color:8947848,linewidth:.1,dashed:!1,resolution:new h.Vector2(window.innerWidth,window.innerHeight)});return new Ot(e,n)}}const Fo={};class hi extends ui{constructor(e){super(e);x(this,"_type","LineString")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-line":return Qt(e.config,this._vertexPoints);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}_updateGeometry(){if(this._disposeGeometry(),this._threeGeometry){const n=this._threeGeometry.geometry;n.setPositions(this._vertexPoints),n.computeBoundingSphere(),n.computeBoundingBox(),this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue()}}}hi.mergeOptions(Fo);class Oo extends $e{constructor(e){super(e);x(this,"_baseType","Surface");x(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=this._geometry;if(!n)throw new Error("Geometry is not defined");if(this._geometry.type==="Polygon"){const i=n.coordinates;let r=[],s=[];return i.forEach(a=>{const l=a.map(u=>{const d=new h.Vector3(u[0],u[1],u[2]||0);return e?e.geo2world(d):d});r.push(l),s.push(...l.flatMap(u=>[u.x,u.y,u.z]))}),{_positions:r,_vertexPoints:s}}else if(this._geometry.type==="MultiPolygon"){const i=n.coordinates;let r=[],s=[];return i.forEach(a=>{const l=[];a.forEach(u=>{const d=u.map(c=>{const p=new h.Vector3(c[0],c[1],c[2]||0);return e?e.geo2world(p):p});l.push(d),s.push(...d.flatMap(c=>[c.x,c.y,c.z]))}),r.push(l)}),{_positions:r,_vertexPoints:s}}else throw new Error(`Unsupported geometry type: ${n.type}`)}_updateGeometry(){let e=this._style?.config.type;if(this.clear(),!this._threeGeometry||!this._vertexPoints?.length){console.warn("Cannot update geometry: missing geometry or vertex data");return}const n=this._threeGeometry,i=n.geometry;try{if(e==="basic-polygon"){const r=i.getAttribute("position");if(r.count*3!==this._vertexPoints.length)throw new Error(`Vertex count mismatch: ${r.count} expected, got ${this._vertexPoints.length/3}`);r.array.set(this._vertexPoints),r.needsUpdate=!0,this._threeGeometry.renderOrder=999,i.computeBoundingSphere(),i.computeBoundingBox(),this.add(this._threeGeometry),n.updateMatrix(),this.updateMatrixWorld(!0)}else e==="extrude-polygon"?(this._threeGeometry.renderOrder=999,this._threeGeometry.updateMatrix(),this.add(this._threeGeometry)):e?.includes("water")&&(this._threeGeometry.updateMatrix(),this.add(this._threeGeometry))}catch(r){throw console.error("Failed to update polygon positions:",r),r}}_createThreeGeometry(){const e=new ut,n=new Je({color:8947848,linewidth:.1,dashed:!1,resolution:new h.Vector2(window.innerWidth,window.innerHeight)});return new Ot(e,n)}}const zo={};class di extends Oo{constructor(e){super(e);x(this,"_type","Polygon")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this.remove(this._threeGeometry),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-polygon":return Lo(e.config,this._vertexPoints);case"extrude-polygon":return So(e.config,this._vertexPoints);case"water":return Mo(e.config,this.getMap(),this._vertexPoints);case"base-water":return _o(e.config,this._vertexPoints);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}di.mergeOptions(zo);const Xo={};class pi extends ui{constructor(e){super(e);x(this,"_type","MultiLineString");x(this,"_lineObjects",[]);x(this,"_linesContainer");this._linesContainer=new h.Group}async _toThreeJSGeometry(){const{_position:e}=this._coordsTransform();if(this.clearLines(),this._disposeGeometry(),this._style){for(const n of e){const i=n.flatMap(s=>[s.x,s.y,s.z]),r=await this._createLineObject(this._style,i);this._lineObjects.push(r),this._linesContainer.add(r),this._threeGeometry=this._linesContainer}this.add(this._threeGeometry),this._updateContainer(),this.updateMatrixWorld(!0),this._tryProcessQueue()}}async _createLineObject(e,n){switch(e.config.type){case"basic-line":return Qt(e.config,n);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}_coordsTransform(){const e=this.getMap(),n=this._geometry;if(this._geometry.type==="MultiLineString")return{_position:n.coordinates.map(r=>r.map(s=>{const a=new h.Vector3(s[0],s[1],s[2]||0);return e?e.geo2world(a):a}))}}_updateContainer(){this._linesContainer.updateMatrixWorld(!0)}clearLines(){this._lineObjects.forEach(e=>{this._linesContainer.remove(e),e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this._lineObjects=[]}_updateGeometry(){this._toThreeJSGeometry()}_disposeObject(){}}pi.mergeOptions(Xo);class Uo extends se.MeshStandardMaterial{constructor(e={}){const{shaderOption:n,...i}=e;super({color:"rgb(58,126,182)",roughness:.7,metalness:.1,transparent:!0,opacity:.9,envMapIntensity:.8,...i});x(this,"shaderOption");x(this,"clock");x(this,"time");x(this,"startTime");this.shaderOption={minY:0,maxY:100,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!1,color:new se.Color("#9ECDEC"),width:20,speed:1,maxDistance:100,center:void 0},flow:{enabled:!1,color:new se.Color("#00E4FF"),range:10,speed:20},sweep:{enabled:!1,color:new se.Color("#FFFFFF"),width:1.5,speed:10}},...n},this.clock=new se.Clock,this.time={value:0},this.startTime={value:0},this.animate()}onBeforeCompile(e){const{minY:n,maxY:i,minRate:r,maxRate:s,effects:a}=this.shaderOption,l=i-n;e.uniforms={...e.uniforms,time:this.time,uStartTime:this.startTime,uMinY:{value:n},uMaxY:{value:i},uHeightRange:{value:l},uMinRate:{value:r},uMaxRate:{value:s},uDiffusionEnabled:{value:a?.diffusion?.enabled?1:0},uDiffusionColor:{value:a?.diffusion?.color||new se.Color("#9ECDEC")},uDiffusionWidth:{value:a?.diffusion?.width||20},uDiffusionSpeed:{value:a?.diffusion?.speed||1},uDiffusionMaxDistance:{value:a?.diffusion?.maxDistance||100},uDiffusionCenter:{value:a?.diffusion?.center||new se.Vector3(0,0,0)},uFlowEnabled:{value:a?.flow?.enabled?1:0},uFlowColor:{value:a?.flow?.color||new se.Color("#00E4FF")},uFlowRange:{value:a?.flow?.range||10},uFlowSpeed:{value:a?.flow?.speed||20},uSweepEnabled:{value:a?.sweep?.enabled?1:0},uSweepColor:{value:a?.sweep?.color||new se.Color("#FFFFFF")},uSweepWidth:{value:a?.sweep?.width||1.5},uSweepSpeed:{value:a?.sweep?.speed||10}},e.vertexShader=`
754
+ `,transparent:i.transparent??!0,side:p.DoubleSide,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0});return new p.Mesh(a,d)}function sg(i,e,t){const{geometry:n,center:r,avgY:o}=Qo(t),a=new Mf(n,{textureWidth:512,textureHeight:512,waterNormals:new p.TextureLoader().load(i.normalMap,function(d){d.wrapS=d.wrapT=p.RepeatWrapping}),waterColor:i.color||"#19AAEE",sunColor:i.sunColor||"#05FFF8",distortionScale:1,alpha:i.opacity||.8}),c=a.onBeforeRender,u=a.onAfterRender;return a.onBeforeRender=(d,m,f,g,_,w)=>{e.tilemap.autoUpdate=!1,c.call(a,d,m,f,g,_,w)},a.onAfterRender=(d,m,f,g,_,w)=>{e.tilemap.autoUpdate=!0,u.call(a,d,m,f,g,_,w)},a.material.uniforms.size.value=.1,a.rotation.x=-Math.PI/2,a.position.set(r.x,o,r.z),e.viewer.addEventListener("update",()=>{a.material.uniforms.time.value+=1/60}),a}function Qo(i){let e=0;for(let a=1;a<i.length;a+=3)e+=i[a];e/=i.length/3;const t={x:0,z:0},n=[];for(let a=0;a<i.length;a+=3)t.x+=i[a],t.z+=i[a+2];t.x/=i.length/3,t.z/=i.length/3;for(let a=0;a<i.length;a+=3)n.push(new p.Vector2(i[a]-t.x,-(i[a+2]-t.z)));const r=new p.Shape(n);return{geometry:new p.ShapeGeometry(r),center:t,avgY:e}}async function og(i,e){const{geometry:t,center:n,avgY:r}=Qo(e),o=await xt._loadTexture(i.normalMap),a=await xt._loadTexture(i.normalMap);o.wrapS=o.wrapT=p.RepeatWrapping,a.wrapS=a.wrapT=p.RepeatWrapping,o.repeat.set(.015,.015),a.repeat.set(.005,.005);const c=new p.MeshStandardMaterial({color:new p.Color(i.color).multiplyScalar(3.5),roughness:.1,metalness:.8,transparent:i.transparent??!0,opacity:.9,fog:!1,normalMap:o,normalScale:new p.Vector2(1.5,1.5),envMapIntensity:2,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0}),u=new p.Mesh(t,c);u.rotation.x=-Math.PI/2,u.position.set(n.x,r+.15,n.z),u.castShadow=!1,u.receiveShadow=!0;let d=0;return u.onBeforeRender=()=>{const m=performance.now(),f=d?(m-d)/1e3:.016;o.offset.x+=f*.08,o.offset.y+=f*.03,a.offset.x-=f*.12,a.offset.y+=f*.02,u.position.y=r+.5+Math.sin(m*.02)*.02,d=m},u}function ag(i,e){i.color=new p.Color(i.hexcolor),i.boundstext&&(i.bounds=new p.Vector3(i.boundstext.x,i.boundstext.y,i.boundstext.z));const t=new eg(i);return t.castShadow=!0,t.scale.setScalar(50),t.position.copy(e),t}async function lg(i,e){const n={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,fixedSize:50},...i};n.screenSpaceSize==null&&n.fixedSize!=null&&(n.screenSpaceSize=n.fixedSize);const o=(typeof window<"u"&&window.devicePixelRatio||1)*4,a=i.screenSpaceSize!=null||i.fixedSize!=null;if(i.fontSizeDpi==null&&a){const D=i.screenSpaceSize??i.fixedSize??n.screenSpaceSize;n.fontSizeDpi=D*o}n.fontSizeDpi=Math.min(Math.max(n.fontSizeDpi,8),128);const c=document.createElement("canvas"),u=c.getContext("2d");if(!u)throw new Error("canvas context is null");const d=`${n.fontStyle} ${n.fontWeight} ${n.fontSizeDpi}px ${n.fontFamily}`;u.font=d;const m=n.showBackground?20:0,f=100,g=50,_=u.measureText(n.text),w=Math.max(f,_.width+m*2),b=Math.max(g,n.fontSizeDpi*1.5+m*2);c.width=Math.min(w,2048),c.height=Math.min(b,2048),u.clearRect(0,0,c.width,c.height),u.font=d,n.showBackground&&(n.bgStyle===1?(u.fillStyle=n.bgColor,u.globalAlpha=n.bgOpacity,u.beginPath(),Fc(u,m/2,m/2,c.width-m,c.height-m,n.roundRectRadius),u.fill(),u.globalAlpha=1,u.shadowColor=n.shadowColor,u.shadowBlur=n.shadowBlur,u.shadowOffsetX=n.shadowOffsetX,u.shadowOffsetY=n.shadowOffsetY):(u.fillStyle=n.bgColor,u.globalAlpha=n.bgOpacity,u.beginPath(),Oc(u,c.width/2,c.height/2,c.width*.8,c.height*.8,n.roundRectRadius,n.bubblePointerHeight,n.bubblePointerWidth),u.fill(),u.globalAlpha=1,u.strokeStyle=n.bubbleBorderColor,u.lineWidth=n.bubbleBorderWidth,u.stroke())),u.textAlign="center",u.textBaseline="middle",n.strokeWidth>0&&(u.strokeStyle=n.strokeColor,u.lineWidth=n.strokeWidth,u.lineJoin="round",u.strokeText(n.text,c.width/2,c.height/2)),u.fillStyle=n.textColor,u.fillText(n.text,c.width/2,c.height/2),u.shadowColor="transparent";const x=new p.CanvasTexture(c);x.magFilter=p.NearestFilter,x.minFilter=p.LinearMipmapLinearFilter,x.anisotropy=16;const L=new p.SpriteMaterial({map:x,transparent:i.transparent??!0,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0,fog:!1}),M=new p.Sprite(L),C=n.screenSpaceSize??n.fixedSize;M.scale.set(c.width*C/100,c.height*C/100,1);const Z=i.anchor||[.5,.5],z=i.textOffset||{x:0,y:0};return M.center.set(Z[0]-z.x/c.width,Z[1]+z.y/c.height),e&&M.position.copy(e),M}async function cg(i,e,t){const r={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,maxVisibleDistance:1/0},...i};r.screenSpaceSize==null&&i.fixedSize!=null&&(r.screenSpaceSize=i.fixedSize);const a=(typeof window<"u"&&window.devicePixelRatio||1)*4;i.fontSizeDpi==null&&(r.fontSizeDpi=r.screenSpaceSize*a),r.fontSizeDpi=Math.max(r.fontSizeDpi,8);const c=document.createElement("canvas"),u=c.getContext("2d");if(!u)throw new Error("Failed to get canvas context");const d=`${r.fontStyle} ${r.fontWeight} ${r.fontSizeDpi}px ${r.fontFamily}`;u.font=d;const m=r.showBackground?20:0,f=100,g=50,_=u.measureText(r.text),w=Math.max(f,_.width+m*2),b=Math.max(g,r.fontSizeDpi*1.5+m*2);c.width=Math.min(w,2048),c.height=Math.min(b,2048),u.clearRect(0,0,c.width,c.height),u.font=d,r.showBackground&&(r.bgStyle===1?(u.fillStyle=r.bgColor,u.globalAlpha=r.bgOpacity,u.beginPath(),Fc(u,m/2,m/2,c.width-m,c.height-m,r.roundRectRadius),u.fill(),u.globalAlpha=1,u.shadowColor=r.shadowColor,u.shadowBlur=r.shadowBlur,u.shadowOffsetX=r.shadowOffsetX,u.shadowOffsetY=r.shadowOffsetY):(u.fillStyle=r.bgColor,u.globalAlpha=r.bgOpacity,u.beginPath(),Oc(u,c.width/2,c.height/2,c.width*.8,c.height*.8,r.roundRectRadius,r.bubblePointerHeight,r.bubblePointerWidth),u.fill(),u.globalAlpha=1,u.strokeStyle=r.bubbleBorderColor,u.lineWidth=r.bubbleBorderWidth,u.stroke())),u.textAlign="center",u.textBaseline="middle",r.strokeWidth>0&&(u.strokeStyle=r.strokeColor,u.lineWidth=r.strokeWidth,u.lineJoin="round",u.strokeText(r.text,c.width/2,c.height/2)),u.fillStyle=r.textColor,u.fillText(r.text,c.width/2,c.height/2),u.shadowColor="transparent";const x=new p.CanvasTexture(c),L=new p.SpriteMaterial({map:x,transparent:i.transparent??!0,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!0,fog:!1}),M=new p.Sprite(L),C=i.anchor||[.5,.5],Z=i.textOffset||{x:0,y:0},z=r.screenSpaceSize,D=z*(c.width/c.height);M.center.set(C[0]-Z.x/D,C[1]+Z.y/z),M.position.copy(e),M.userData.isLabel=!0;const X=()=>{if(!M.visible)return;const K=t.viewer.camera.position.distanceTo(M.position);if(K>r.maxVisibleDistance){M.visible=!1;return}M.visible=!0;const V=new p.Vector2;t.viewer.renderer.getSize(V);const G=V.height,k=p.MathUtils.degToRad(t.viewer.camera.fov),j=typeof window<"u"&&window.devicePixelRatio||1,H=r.screenSpaceSize*j/c.height*(2*K*Math.tan(k/2)/G);M.scale.set(H*c.width,H*c.height,1),M.lookAt(t.viewer.camera.position)};X();const I=()=>X();return M.addEventListener("dispose",()=>{t.viewer.renderer.domElement.removeEventListener("resize",X)}),t.viewer.renderer.domElement.addEventListener("resize",X),t.viewer.camera.addEventListener("change",X),M.onBeforeRender=I,M}async function ug(i,e){const t=i.size??i.iconSize,n={text:i.text||"",iconSize:t,fontSize:i.fontSize??12,fontFamily:i.fontFamily||"微软雅黑",fontWeight:i.fontWeight??400,padding:{top:3,right:6,bottom:3,left:6,...i.padding},bgColor:i.bgColor||"#ffffff",bgOpacity:i.bgOpacity??1,textColor:i.textColor||"#000000",strokeColor:i.strokeColor||"#000000",strokeWidth:i.strokeWidth??0,iconScale:i.iconScale??1,renderbg:i.renderbg??!0,textOffset:i.textOffset??{x:-40,y:-19},depthTest:i.depthTest??!1,depthWrite:i.depthWrite??!1,transparent:i.transparent??!0,canvasScale:4};let r=null;if(i.url)try{r=await yg(i.url)}catch{console.error("Label icon load failed:",i.url)}const{canvas:o,width:a,height:c,center:u}=await hg(n,r),d=new p.Texture(o);d.generateMipmaps=!0,d.minFilter=p.LinearMipmapLinearFilter,d.magFilter=p.LinearFilter,d.colorSpace=p.SRGBColorSpace,d.premultiplyAlpha=!1,d.needsUpdate=!0;const m=new p.SpriteMaterial({map:d,transparent:n.transparent??!0,depthTest:n.depthTest??!0,depthWrite:n.depthWrite??!0,blending:p.NormalBlending,sizeAttenuation:!1,premultipliedAlpha:!1,alphaTest:.05}),f=new p.Sprite(m),g=.002;return f.scale.set(a*g,c*g,1),i.anchor?f.center.set(i.anchor[0],i.anchor[1]):f.center.set(u[0],u[1]),e&&f.position.copy(e),f}async function hg(i,e){return new Promise(t=>{const{text:n,fontSize:r,fontFamily:o,padding:a,bgColor:c,textColor:u,strokeColor:d,strokeWidth:m,iconScale:f,canvasScale:g,renderbg:_,textOffset:w,iconSize:b,fontWeight:x,bgOpacity:L}=i,M=e!==null;let C=0,Z=0;if(M&&e){const Ce=e.naturalWidth||e.width||1,ot=e.naturalHeight||e.height||1,ft=Ce/ot||1;Array.isArray(b)?(C=b[0],Z=b[1]):typeof b=="number"?(Z=b,C=b*ft):(C=Ce,Z=ot)}else Array.isArray(b)?(C=b[0],Z=b[1]):typeof b=="number"&&(C=b,Z=b);const D=document.createElement("canvas").getContext("2d"),X=`${x} ${r}px ${o}`;D.font=X;const I=fg(D,n,r),{width:K,ascent:V,descent:G}=I,k=M?C/2:0,j=M?Z/2:0,Y=k+w.x,H=j+w.y,Q=Y-a.left,ie=Y+K+a.right,re=H-V-a.top,le=H+G+a.bottom;let de,ge,fe,Se;M?(de=Math.min(0,Q),ge=Math.min(0,re),fe=Math.max(C,ie),Se=Math.max(Z,le)):(de=Q,ge=re,fe=ie,Se=le);const rt=Math.ceil(fe-de),it=Math.ceil(Se-ge),{canvas:dt,ctx:Qe}=dg(rt,it,g),Ye=-de,Re=-ge;if(M&&e&&C>0&&Z>0){const Ce=C*f,ot=Z*f,ft=(C-Ce)/2,Lt=(Z-ot)/2,wr=Ye+ft,Yr=Re+Lt;Qe.drawImage(e,wr,Yr,Ce,ot)}const st=Ye+Y,ze=Re+H;_&&c&&c!=="transparent"&&mg(Qe,st,ze,K,V,G,a,c,L),Qe.font=X,gg(Qe,n,st,ze,u,m,d);let Vt,Nt;M&&C>0&&Z>0?(Vt=(Ye+k)/rt,Nt=(Re+j)/it):(Vt=.5,Nt=.5),t({canvas:dt,width:rt,height:it,center:[Vt,1-Nt]})})}function Fc(i,e,t,n,r,o){i.beginPath(),i.moveTo(e+o,t),i.lineTo(e+n-o,t),i.quadraticCurveTo(e+n,t,e+n,t+o),i.lineTo(e+n,t+r-o),i.quadraticCurveTo(e+n,t+r,e+n-o,t+r),i.lineTo(e+o,t+r),i.quadraticCurveTo(e,t+r,e,t+r-o),i.lineTo(e,t+o),i.quadraticCurveTo(e,t,e+o,t),i.closePath()}function Oc(i,e,t,n,r,o,a,c){if(n<=0)throw new Error("Width must be positive");if(r<=0)throw new Error("Height must be positive");if(o<0)throw new Error("Radius cannot be negative");const u=n,d=r,m=Math.min(o,n/2,r/2),f=a??10,g=c??15;i.beginPath(),i.moveTo(e-u/2+m,t-d/2),i.lineTo(e+u/2-m,t-d/2),i.quadraticCurveTo(e+u/2,t-d/2,e+u/2,t-d/2+m),i.lineTo(e+u/2,t+d/2-m),i.quadraticCurveTo(e+u/2,t+d/2,e+u/2-m,t+d/2),i.lineTo(e+g/2,t+d/2),i.lineTo(e,t+d/2+f),i.lineTo(e-g/2,t+d/2),i.lineTo(e-u/2+m,t+d/2),i.quadraticCurveTo(e-u/2,t+d/2,e-u/2,t+d/2-m),i.lineTo(e-u/2,t-d/2+m),i.quadraticCurveTo(e-u/2,t-d/2,e-u/2+m,t-d/2),i.closePath()}function dg(i,e,t){const n=document.createElement("canvas");n.width=Math.ceil(i*t),n.height=Math.ceil(e*t);const r=n.getContext("2d",{alpha:!0});return r.scale(t,t),r.imageSmoothingEnabled=!1,{canvas:n,ctx:r}}function fg(i,e,t){const n=i.measureText(e);return{width:n.width,ascent:n.actualBoundingBoxAscent||t*.8,descent:n.actualBoundingBoxDescent||t*.2,totalHeight:(n.actualBoundingBoxAscent||t*.8)+(n.actualBoundingBoxDescent||t*.2)}}function pg(i,e,t,n,r,o){i.beginPath(),i.moveTo(e+o,t),i.lineTo(e+n-o,t),i.arcTo(e+n,t,e+n,t+o,o),i.lineTo(e+n,t+r-o),i.arcTo(e+n,t+r,e+n-o,t+r,o),i.lineTo(e+o,t+r),i.arcTo(e,t+r,e,t+r-o,o),i.lineTo(e,t+o),i.arcTo(e,t,e+o,t,o),i.closePath()}function mg(i,e,t,n,r,o,a,c,u=1){const d=e-a.left,m=t-r-a.top,f=n+a.left+a.right,g=r+o+a.top+a.bottom;i.save(),i.globalAlpha=u,i.fillStyle=c,pg(i,d,m,f,g,2),i.fill(),i.restore()}function gg(i,e,t,n,r,o,a){i.save(),i.textBaseline="alphabetic",i.textAlign="left",o>0&&(i.strokeStyle=a,i.lineWidth=o,i.lineJoin="round",i.strokeText(e,t,n)),i.fillStyle=r,i.fillText(e,t,n),i.restore()}function yg(i){return new Promise((e,t)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>e(n),n.onerror=r=>t(new Error(`Failed to load image: ${i} ${r}`)),n.src=i})}async function _g(i,e,t){const r=new p.CylinderGeometry(.2,.2,24,12),o=new p.MeshBasicMaterial({color:i.color}),a=await xt._loadTexture(i.icon),c=new p.PointsMaterial({size:80*window.innerHeight/window.innerHeight,fog:!1,opacity:1,transparent:i.transparent??!0,toneMapped:!1,blending:p.AdditiveBlending,map:a,sizeAttenuation:!0,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!1}),u=new p.InstancedMesh(r,o,e.length);u.position.add(t.prjcenter),u.castShadow=!0;const d=new p.Object3D,m=[];for(let w=0;w<e.length;w++){const b=e[w],x=new p.Vector3(b.coordinates[0],b.coordinates[1],b.coordinates[2]||0),M=t.geo2world(x).sub(t.prjcenter);d.position.copy(M),d.updateMatrix(),u.setMatrixAt(w,d.matrix),m.push(M.x,0,M.z)}const f=new Float32Array(m),g=new p.BufferGeometry;g.setAttribute("position",new p.BufferAttribute(f,3));const _=new p.Points(g,c);return _.position.add(t.prjcenter),_.position.y=1.5*10,_.renderOrder=99999999,_.visible=!0,{points:_,InstancedCol:u}}var vg=Object.defineProperty,wg=(i,e,t)=>e in i?vg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Dc=(i,e,t)=>wg(i,typeof e!="symbol"?e+"":e,t);const Ho=class Or{constructor(e){this.config=e}async applyTo(e){if(!e)return!1;try{switch(e.visible=this.config.visible!==!1,this.config.type){case"basic-point":case"icon-point":case"icon-label-point":return this._applyPointStyle(e);case"basic-line":return this._applyLineStyle(e);case"flow-tube-line":return this._applyFlowLineStyle(e);case"arrow-line":return this._applyArrowLineStyle(e);case"flow-texture-line":return this._applyFlowTextureLineStyle(e);case"gltf":case"fbx":return this._applyModelStyle(e);case"basic-polygon":return this._applyPolygonStyle(e);case"extrude-polygon":return this._applyExtrudeStyle(e);case"water":case"base-water":return this._applyWaterStyle(e);case"cloud":return this._applyCloudStyle(e);case"canvas-label":case"canvas-label-fixed":return this._applyTextSpriteStyle(e);case"light":return this._applyLightStyle(e);case"custom":return this._applyCustomStyle(e);default:throw new Error("Unknown style type")}}catch(t){return console.error("Style apply failed:",t),e.visible=!1,!1}}async _applyPointStyle(e){const t=this.config;return t.type==="icon-point"?await this._applyIconPoint(e,t):t.type==="basic-point"?this._applyBasicPoint(e,t):t.type==="icon-label-point"&&this._applyIconLabelPoint(e,t),!0}async _applyIconPoint(e,t){return!0}_applyBasicPoint(e,t){let n;if(e instanceof p.Points)n=e;else if(n=Wc(t,e.position),n.position.copy(e.position),n.rotation.copy(e.rotation),n.scale.copy(e.scale),e.parent){let a=e.parent;a._threeGeometry=n,a._updateGeometry()}const r=n.material,o=t.sizeAttenuation;r.size=o?t.size*.002:t.size,t.color&&r.color.set(t.color),r.sizeAttenuation=o??!1,r.onBeforeCompile=a=>{a.fragmentShader=a.fragmentShader.replace("#include <clipping_planes_fragment>",`
755
+ #include <clipping_planes_fragment>
756
+ vec2 coord = gl_PointCoord - vec2(0.5);
757
+ if(length(coord) > 0.5) discard;
758
+ `)},r.needsUpdate=!0}_applyIconLabelPoint(e,t){return!0}_applyLineStyle(e){const t=this.config;if(e.isLine2){const r=e.material;return t.color!==void 0&&r.color.set(t.color),t.width!==void 0&&(r.linewidth=t.width),t.opacity!==void 0&&(r.opacity=t.opacity,r.transparent=t.opacity<1),r.needsUpdate=!0,!0}if(e.parent){let n=e.parent;n._toThreeJSGeometry&&n._toThreeJSGeometry()}return!0}_applyFlowLineStyle(e){return!0}_applyArrowLineStyle(e){return!0}_applyFlowTextureLineStyle(e){return!0}_applyPolygonStyle(e){const t=this.config;return e.traverse(n=>{n instanceof p.Mesh&&(Array.isArray(n.material)?n.material:[n.material]).forEach(o=>{t.color!==void 0&&o.color.set(t.color),t.opacity!==void 0&&(o.opacity=t.opacity,o.transparent=t.opacity<1),t.wireframe!==void 0&&(o.wireframe=t.wireframe),o.needsUpdate=!0})}),!0}_applyExtrudeStyle(e){return!0}_applyWaterStyle(e){return!0}_applyCloudStyle(e){return!0}_applyTextSpriteStyle(e){return!0}_applyLightStyle(e){return!0}async _applyModelStyle(e){return!0}async _applyCustomStyle(e){const n=await this.config.build();return e instanceof p.Group&&(e.clear(),e.add(n)),!0}static async _loadTexture(e){if(Or._textureCache.has(e))return Or._textureCache.get(e);const t=await new Promise((n,r)=>{Or._textureLoader.load(e,n,void 0,r)});return t.needsUpdate=!0,Or._textureCache.set(e,t),t}static create(e){return e instanceof Or?e:new Or(e)}};Dc(Ho,"_textureCache",new Map),Dc(Ho,"_textureLoader",new p.TextureLoader);let xt=Ho;const tt=[];for(let i=0;i<256;++i)tt.push((i+256).toString(16).slice(1));function bg(i,e=0){return(tt[i[e+0]]+tt[i[e+1]]+tt[i[e+2]]+tt[i[e+3]]+"-"+tt[i[e+4]]+tt[i[e+5]]+"-"+tt[i[e+6]]+tt[i[e+7]]+"-"+tt[i[e+8]]+tt[i[e+9]]+"-"+tt[i[e+10]]+tt[i[e+11]]+tt[i[e+12]]+tt[i[e+13]]+tt[i[e+14]]+tt[i[e+15]]).toLowerCase()}let Eo;const xg=new Uint8Array(16);function Mg(){if(!Eo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Eo=crypto.getRandomValues.bind(crypto)}return Eo(xg)}const zc={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Sg(i,e,t){if(zc.randomUUID&&!i)return zc.randomUUID();i=i||{};const n=i.random??i.rng?.()??Mg();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,bg(n)}var Xc=(i=>(i.POINT="point",i.LINE_VERTEX="line_vertex",i.POLYGON_CENTER="polygon_center",i.LABEL="label",i.ICON="icon",i.CLUSTER="cluster",i))(Xc||{}),yn=(i=>(i.NO_COLLISION="no_collision",i.PRIORITY_LOST="priority_lost",i.OUT_OF_VIEWPORT="out_of_viewport",i.ZOOM_FILTERED="zoom_filtered",i.MANUAL_HIDDEN="manual_hidden",i.GROUP_COLLISION="group_collision",i))(yn||{}),Lg=Object.defineProperty,Pg=(i,e,t)=>e in i?Lg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Si=(i,e,t)=>Pg(i,typeof e!="symbol"?e+"":e,t);class Cg extends ls{constructor(){super(...arguments),Si(this,"_isDragging",!1),Si(this,"_lastCoord",null),Si(this,"_boundOnMouseDown",this._onMouseDown.bind(this)),Si(this,"_boundOnMouseMove",this._onMouseMove.bind(this)),Si(this,"_boundOnMouseUp",this._onMouseUp.bind(this))}addHooks(){this.target.on("mousedown",this._boundOnMouseDown)}removeHooks(){this.target.off("mousedown",this._boundOnMouseDown),this._stopDrag()}_onMouseDown(e){const t=this.target.getMap();!t||!this.target.options.draggable||(this._isDragging=!0,this._lastCoord=e.coordinate,t.viewer.config("draggable",!1),t.on("mousemove",this._boundOnMouseMove),t.on("mouseup",this._boundOnMouseUp),this.target.trigger("dragstart",e))}_onMouseMove(e){if(!this._isDragging||!this._lastCoord||!e.coordinate)return;const t=e.coordinate,n=t[0]-this._lastCoord[0],r=t[1]-this._lastCoord[1];Math.abs(n)<1e-8&&Math.abs(r)<1e-8||(this._translate(n,r),this._lastCoord=t,this.target.trigger("dragging",e))}_onMouseUp(e){this._stopDrag(),this.target.trigger("dragend",e)}_stopDrag(){this._isDragging=!1;const e=this.target.getMap();e&&(e.viewer.config("draggable",!0),e.off("mousemove",this._boundOnMouseMove),e.off("mouseup",this._boundOnMouseUp))}_translate(e,t){const n=this.target._geometry;if(!n||!n.coordinates)return;const r=a=>Array.isArray(a[0])?a.map(r):[a[0]+e,a[1]+t],o=r(n.coordinates);n.coordinates=o,this.target._onPositionChanged(!0)}}var Tg=Object.defineProperty,Gg=(i,e,t)=>e in i?Tg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Zt=(i,e,t)=>Gg(i,typeof e!="symbol"?e+"":e,t);class ut extends Yo(Kn(gr(p.Object3D))){constructor(e){super(),Zt(this,"_position"),Zt(this,"_threeGeometry"),Zt(this,"_geometry"),Zt(this,"_layer"),Zt(this,"_style"),Zt(this,"_id"),Zt(this,"_styleQueue",[]),Zt(this,"_isApplyingStyle",!1),Zt(this,"_isGeometryInitializing",!1),Zt(this,"_bloomConfig"),Zt(this,"_collisionState",{visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:Date.now()}),Zt(this,"_collisionConfig",{enabled:!0,priority:50,padding:4,minZoom:0,maxZoom:24}),Zt(this,"_animationRef",null),Xo(e.geometry,"geometry","geometry must be specified"),this._geometry=e.geometry,this._position=new p.Vector3(0,0,0),this._threeGeometry=new p.Object3D,this.options={draggable:e.draggable||!1,editable:e.editable||!1},e.userData&&(this.userData=Object.assign({},JSON.parse(JSON.stringify(e.userData)))),e.style&&this.setStyle(e.style),e.id?this._id=e.id:this._id=Sg(),this.addHandler("draggable",Cg)}async initializeGeometry(){if(!(this._isGeometryInitializing||this._threeGeometry)){this._isGeometryInitializing=!0;try{await this._toThreeJSGeometry(),this._processStyleQueue()}finally{this._isGeometryInitializing=!1}}}_updateGeometryPositions(){this._toThreeJSGeometry()}setStyle(e){const t=e instanceof xt?e:new xt(e);this._style=t;const n=JSON.parse(JSON.stringify(t.config));return this._styleQueue.push(n),this._tryProcessQueue(),this}getStyle(){return this._style}setBloom(e,t){const n=this._bloomConfig||{intensity:1,color:"#ffffff"};return this._bloomConfig={enabled:e,intensity:t?.intensity??n.intensity,color:t?.color??n.color},this._threeGeometry&&this._applyBloomToObject(this._threeGeometry),this}getBloom(){return this._bloomConfig}_applyBloomToObject(e){if(!this._bloomConfig)return;const{enabled:t,intensity:n,color:r}=this._bloomConfig;e.traverse(o=>{if(o instanceof p.Points&&o.material){const a=o.material;o.userData=o.userData||{},o.userData.__bloomBackup||(o.userData.__bloomBackup={size:a.size,sizeAttenuation:a.sizeAttenuation});const c=o.userData.__bloomBackup;t?(a.size=c.size*(1+n),a.sizeAttenuation=!1):(a.size=c.size,a.sizeAttenuation=c.sizeAttenuation),a.needsUpdate=!0;return}if(o.type==="Sprite"&&o.material){const a=o.material;o.userData=o.userData||{},o.userData.__bloomBackup||(o.userData.__bloomBackup={color:a.color?a.color.clone():null,opacity:a.opacity??1});const c=o.userData.__bloomBackup;t?(a.color&&c.color&&(a.color.copy(c.color),r&&r!=="#ffffff"&&a.color.setStyle(r),a.color.multiplyScalar(1+n*2)),a.opacity=Math.min(1,(c.opacity??1)*(1+n*.3))):(c.color&&a.color&&a.color.copy(c.color),a.opacity=c.opacity),a.needsUpdate=!0;return}if(o.isLine2&&o.material){const a=o.material;o.userData=o.userData||{},o.userData.__bloomBackup||(o.userData.__bloomBackup={color:a.color?a.color.clone():null,opacity:a.opacity??1});const c=o.userData.__bloomBackup;t?(a.color&&c.color&&(a.color.copy(c.color),r&&r!=="#ffffff"&&a.color.setStyle(r),a.color.multiplyScalar(1+n*2)),a.opacity=Math.min(1,(c.opacity??1)*(1+n*.3))):(c.color&&a.color&&a.color.copy(c.color),a.opacity=c.opacity),a.needsUpdate=!0;return}o instanceof p.Mesh&&o.material&&(Array.isArray(o.material)?o.material:[o.material]).forEach(c=>{o.userData=o.userData||{},o.userData.__bloomBackup||(o.userData.__bloomBackup={emissiveIntensity:c.emissiveIntensity??0,emissiveColor:c.emissive?c.emissive.clone():null,color:c.color?c.color.clone():null});const u=o.userData.__bloomBackup;t?"emissive"in c&&c.emissive?(c.emissiveIntensity=n,r&&r!=="#ffffff"&&c.emissive.setStyle?c.emissive.setStyle(r):u.color&&c.emissive&&c.emissive.copy(u.color)):c.color&&(u.color&&c.color.copy(u.color),r&&r!=="#ffffff"?c.color.setStyle(r):c.color.multiplyScalar(1+n*.3)):("emissiveIntensity"in c&&(c.emissiveIntensity=u.emissiveIntensity!==void 0?u.emissiveIntensity:0),u.emissiveColor&&c.emissive&&c.emissive.copy(u.emissiveColor),u.color&&c.color&&c.color.copy(u.color)),c.needsUpdate=!0})})}async _applyStyleWithRetry(e,t=3,n=100){let r=null;for(let o=1;o<=t;o++)try{this._threeGeometry.parent||(this.add(this._threeGeometry),await new Promise(c=>requestAnimationFrame(c))),await e.applyTo(this._threeGeometry);const a=e.config;if(a.bloom!==void 0){const c=a.bloom;typeof c=="boolean"?this._bloomConfig={enabled:c,intensity:1,color:"#ffffff"}:this._bloomConfig={enabled:c.enabled??!0,intensity:c.intensity??1,color:c.color??"#ffffff"}}this._bloomConfig&&this._threeGeometry&&this._applyBloomToObject(this._threeGeometry);return}catch(a){if(r=a,o<t){const c=n*Math.pow(2,o-1);await new Promise(u=>setTimeout(u,c))}}throw r||new Error("样式应用失败,重试次数耗尽")}async _processStyleQueue(){if(!this._threeGeometry||this._isApplyingStyle||this._styleQueue.length===0)return;this._isApplyingStyle=!0;const e=this._styleQueue[0];try{const t=new xt(JSON.parse(JSON.stringify(e)));await this._applyStyleWithRetry(t),this._styleQueue.shift(),this._styleQueue.length>0&&await this._processStyleQueue()}catch(t){throw t}finally{this._isApplyingStyle=!1,this._styleQueue.length>0&&this._tryProcessQueue()}}_tryProcessQueue(){this._threeGeometry&&!this._isApplyingStyle&&this._styleQueue.length>0?this._processStyleQueue().catch(t=>{this._isApplyingStyle=!1,this._tryProcessQueue(),console.warn(t)}):!this._threeGeometry&&!this._isGeometryInitializing&&this.initializeGeometry()}addTo(e){return e.addFeature(this),this}getLayer(){return this._layer||null}getMap(){return this._layer?this._layer.getMap():null}setCoordinates(e){return this._geometry.coordinates=e,this._onPositionChanged(),this}_onPositionChanged(e=!1){e&&this._threeGeometry?this._updateGeometryPositions():this._toThreeJSGeometry(),this.trigger("positionchange")}getCenter(){return this._geometry.type==="Point"?this._geometry.coordinates:[0,0]}_bindLayer(e){if(this._layer&&this._layer!==e)throw new Error("Feature cannot be added to multiple layers");this._layer=e}_updateGeometry(){this._disposeGeometry(),this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry?.userData?._type==="Model"?this._threeGeometry.renderOrder=0:this._threeGeometry.renderOrder=99,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue())}_remove(){return this.getLayer()?(this._unbind(),this):this}_unbind(){const e=this.getLayer();e&&(e.onRemoveFeature&&e.onRemoveFeature(this),delete this._layer)}_disposeGeometry(){this._threeGeometry&&(this.clear(),"traverse"in this&&this._threeGeometry.traverse(e=>{e instanceof p.Mesh?(e.geometry?.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material?.dispose()):"isLine"in e&&e.isLine&&(e.geometry?.dispose(),e.material?.dispose())}))}get collidable(){return this._collisionConfig.enabled}get collisionType(){return Xc.POINT}getCollisionPriority(){return this.userData.collisionPriority??this._style?.config.collisionPriority??this._collisionConfig.priority}getScreenBoundingBox(e,t){if(!this.collidable)return null;try{const n=new p.Vector3;this._threeGeometry.getWorldPosition(n);const r=n.clone().project(e);if(!(r.x>=-1.1&&r.x<=1.1&&r.y>=-1.1&&r.y<=1.1&&r.z>=-1&&r.z<=1))return null;const{width:a,height:c}=t.domElement,u=(r.x*.5+.5)*a,d=(-r.y*.5+.5)*c,m=this._calculateCollisionBoundingBox(e,t);return m?{id:this._id,x:u+m.offsetX,y:d+m.offsetY,width:20+this._collisionConfig.padding*2,height:20+this._collisionConfig.padding*2,priority:this.getCollisionPriority(),featureId:this._id,layerId:this._layer?.getId()||"unknown",type:this.collisionType,data:this.getCollisionData()}:null}catch(n){return console.warn(`Feature ${this._id} 包围盒计算失败:`,n),null}}setCollisionVisibility(e,t=yn.MANUAL_HIDDEN){this._collisionState.visible!==e&&(this._animationRef!==null&&(cancelAnimationFrame(this._animationRef),this._animationRef=null),this.visible=e,this._applyFinalAlpha(e?1:0),this._collisionState={visible:e,reason:t,collidedWith:e?[]:this._collisionState.collidedWith,timestamp:Date.now()})}getCollisionVisibility(){return this._collisionState.visible}setCollisionConfig(e){return Object.assign(this._collisionConfig,e),this}enableCollision(){return this._collisionConfig.enabled=!0,this}disableCollision(){return this._collisionConfig.enabled=!1,this.setCollisionVisibility(!0,yn.MANUAL_HIDDEN),this}_applyVisibilityAlpha(e){this.traverse(t=>{t instanceof p.Mesh&&(Array.isArray(t.material)?t.material.forEach(n=>{n.opacity!==void 0&&(n.opacity=e)}):t.material.opacity!==void 0&&(t.material.opacity=e))})}_applyFinalAlpha(e){this._applyVisibilityAlpha(e),this.traverse(t=>{t instanceof p.Mesh&&(t.material.needsUpdate=!0)})}getCollisionData(){return{featureType:this.constructor.name,userData:this.userData,styleConfig:this._style?.config}}_calculateCollisionBoundingBox(e,t){if(!this.visible||!this._threeGeometry||!e||!t)return null;try{const n=new p.Box3().setFromObject(this._threeGeometry);if(n.isEmpty())return this._getFallbackBoundingBox();const r=[new p.Vector3(n.min.x,n.min.y,n.min.z),new p.Vector3(n.max.x,n.min.y,n.min.z),new p.Vector3(n.min.x,n.max.y,n.min.z),new p.Vector3(n.max.x,n.max.y,n.min.z),new p.Vector3(n.min.x,n.min.y,n.max.z),new p.Vector3(n.max.x,n.min.y,n.max.z),new p.Vector3(n.min.x,n.max.y,n.max.z),new p.Vector3(n.max.x,n.max.y,n.max.z)],{width:o,height:a}=t.domElement,c=[];r.forEach(z=>{const D=z.clone().project(e),X=(D.x*.5+.5)*o,I=(-D.y*.5+.5)*a;c.push(new p.Vector2(X,I))});let u=1/0,d=-1/0,m=1/0,f=-1/0;c.forEach(z=>{u=Math.min(u,z.x),d=Math.max(d,z.x),m=Math.min(m,z.y),f=Math.max(f,z.y)});const g=d-u,_=f-m,w=4,b=Math.max(g,w),x=Math.max(_,w),L=new p.Vector3;n.getCenter(L);const M=L.clone().project(e),C=(M.x*.5+.5)*o,Z=(-M.y*.5+.5)*a;return{width:b,height:x,offsetX:u-C,offsetY:m-Z}}catch(n){return console.warn("Bounding box calculation failed 包围盒计算失败:",n),this._getFallbackBoundingBox()}}_getFallbackBoundingBox(){return{width:20,height:20,offsetX:-10,offsetY:-10}}_tileCoordToLocalWorld(e,t,n,r){const{tileZ:o,tileX:a,tileY:c,extent:u,tileSize:d}=n,m=(e/u-.5)*d,f=(.5-t/u)*d;return r.tileIDToWorldCenter(o,a,c).clone().add(new p.Vector3(m,f,0)).sub(r.prjcenter)}}var Zg=Object.defineProperty,Wg=(i,e,t)=>e in i?Zg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Uc=(i,e,t)=>Wg(i,typeof e!="symbol"?e+"":e,t);class Bn extends ds{constructor(e,t){super(e,t),Uc(this,"_feaList"),Uc(this,"_collision",!1),this._feaList=[],t?.collision&&(this._collision=!0)}addFeature(e){const t=Array.isArray(e)?e:[e];for(const n of t)if(!(!n||!(n instanceof ut))&&!n.getLayer()){if(!this.validateFeature(n)){console.error(`Feature ${n.id} does not match the layer's type requirements`);continue}n._bindLayer(this),this._feaList.push(n),n.getMap()&&n._toThreeJSGeometry(),this._clouds&&(this.map.viewer.scene.add(this._clouds),console.log("我是云朵被添加cloud",this.map.viewer.scene)),this.add(n)}return this}getFeatures(e,t){if(!e)return this._feaList.slice(0);const n=[];let r,o;for(let a=0,c=this._feaList.length;a<c;a++)r=this._feaList[a],t?o=e.call(t,r):o=e(r),o&&n.push(r);return n}getCount(){return this._feaList.length}isEmpty(){return!this._feaList.length}removeFeature(e){if(!Array.isArray(e))return this.removeFeature([e]);for(let t=e.length-1;t>=0;t--)e[t]instanceof ut||(e[t]=this.removeFeature(e[t])),!(!e[t]||this!==e[t].getLayer())&&e[t]._remove();return this}clear(){const e=this._feaList.slice();for(const t of e)t._remove();return this}onRemoveFeature(e){if(!e)return;const t=e.getLayer();if(!t||t!==this)return;const n=this._findInList(e);n>=0&&this._feaList.splice(n,1),e.parent&&e.parent===this?this.remove(e):console.warn("Feature parent mismatch:",e.parent),this._disposeFeatureResources(e)}_findInList(e){const t=this._feaList.length;if(t===0)return-1;let n=0,r=t-1,o;for(;n<=r;){if(o=Math.floor((n+r)/2),this._feaList[o]===e)return o;n=o+1}return-1}_disposeFeatureResources(e){try{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose?.()):e.material.dispose&&e.material.dispose()),e instanceof p.Object3D&&e.traverse(t=>{t!==e&&this._disposeFeatureResources(t)})}catch(t){console.error("Error disposing feature resources:",t)}}_mergedGeometry(){this.traverse(e=>{e.isMesh&&e.geometry&&e.material&&console.log("Merging geometry 几何体合并中",e)})}setCollisionEngine(e){return this._collisionEngine=e,this}}var Vg=Object.defineProperty,Ig=(i,e,t)=>e in i?Vg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,kc=(i,e,t)=>Ig(i,typeof e!="symbol"?e+"":e,t);class Ag extends p.Group{constructor(){super(...arguments),kc(this,"_layers",new Set),kc(this,"_layerids",new Set)}add(...e){return e.forEach(t=>{if(!(t instanceof ds))throw new Error("LayerContainer can only contain Layer instances! LayerContainer只能包含Layer实例!");const n=t.getId();if(this._layerids.has(n))throw new Error(`Layer with ID '${n}' already exists in the container! ID为'${n}'的图层已存在于容器中!`);this._layers.add(t),this._layerids.add(n),super.add(t)}),this}remove(...e){return e.forEach(t=>{this._layers.delete(t),this._layerids.delete(t.getId()),super.remove(t)}),this}getLayers(){return Array.from(this._layers)}getLayerById(e){for(const t of this._layers)if(t.getId()===e)return t}clearLayers(){return this._layers.clear(),this._layerids.clear(),super.clear(),this}}var Fg=Object.defineProperty,Og=(i,e,t)=>e in i?Fg(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Dg=(i,e,t)=>Og(i,e+"",t);class zg{constructor(){Dg(this,"canvasDict",{})}getCanvas(e=40,t=30,n=1,r){const o=Math.ceil(e*n),a=Math.ceil(t*n),c=r?`${o}_${a}_${r}`:`${o}_${a}`;if(!this.canvasDict[c]){const m=document.createElement("canvas");m.width=o,m.height=a,this.canvasDict[c]=m}const u=this.canvasDict[c],d=u.getContext("2d");return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,u.width,u.height),d.scale(n,n),u}}function Xg(i){const e=+this._x.call(null,i),t=+this._y.call(null,i);return Kc(this.cover(e,t),e,t,i)}function Kc(i,e,t,n){if(isNaN(e)||isNaN(t))return i;var r,o=i._root,a={data:n},c=i._x0,u=i._y0,d=i._x1,m=i._y1,f,g,_,w,b,x,L,M;if(!o)return i._root=a,i;for(;o.length;)if((b=e>=(f=(c+d)/2))?c=f:d=f,(x=t>=(g=(u+m)/2))?u=g:m=g,r=o,!(o=o[L=x<<1|b]))return r[L]=a,i;if(_=+i._x.call(null,o.data),w=+i._y.call(null,o.data),e===_&&t===w)return a.next=o,r?r[L]=a:i._root=a,i;do r=r?r[L]=new Array(4):i._root=new Array(4),(b=e>=(f=(c+d)/2))?c=f:d=f,(x=t>=(g=(u+m)/2))?u=g:m=g;while((L=x<<1|b)===(M=(w>=g)<<1|_>=f));return r[M]=o,r[L]=a,i}function Ug(i){var e,t,n=i.length,r,o,a=new Array(n),c=new Array(n),u=1/0,d=1/0,m=-1/0,f=-1/0;for(t=0;t<n;++t)isNaN(r=+this._x.call(null,e=i[t]))||isNaN(o=+this._y.call(null,e))||(a[t]=r,c[t]=o,r<u&&(u=r),r>m&&(m=r),o<d&&(d=o),o>f&&(f=o));if(u>m||d>f)return this;for(this.cover(u,d).cover(m,f),t=0;t<n;++t)Kc(this,a[t],c[t],i[t]);return this}function kg(i,e){if(isNaN(i=+i)||isNaN(e=+e))return this;var t=this._x0,n=this._y0,r=this._x1,o=this._y1;if(isNaN(t))r=(t=Math.floor(i))+1,o=(n=Math.floor(e))+1;else{for(var a=r-t||1,c=this._root,u,d;t>i||i>=r||n>e||e>=o;)switch(d=(e<n)<<1|i<t,u=new Array(4),u[d]=c,c=u,a*=2,d){case 0:r=t+a,o=n+a;break;case 1:t=r-a,o=n+a;break;case 2:r=t+a,n=o-a;break;case 3:t=r-a,n=o-a;break}this._root&&this._root.length&&(this._root=c)}return this._x0=t,this._y0=n,this._x1=r,this._y1=o,this}function Kg(){var i=[];return this.visit(function(e){if(!e.length)do i.push(e.data);while(e=e.next)}),i}function Ng(i){return arguments.length?this.cover(+i[0][0],+i[0][1]).cover(+i[1][0],+i[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function gt(i,e,t,n,r){this.node=i,this.x0=e,this.y0=t,this.x1=n,this.y1=r}function Bg(i,e,t){var n,r=this._x0,o=this._y0,a,c,u,d,m=this._x1,f=this._y1,g=[],_=this._root,w,b;for(_&&g.push(new gt(_,r,o,m,f)),t==null?t=1/0:(r=i-t,o=e-t,m=i+t,f=e+t,t*=t);w=g.pop();)if(!(!(_=w.node)||(a=w.x0)>m||(c=w.y0)>f||(u=w.x1)<r||(d=w.y1)<o))if(_.length){var x=(a+u)/2,L=(c+d)/2;g.push(new gt(_[3],x,L,u,d),new gt(_[2],a,L,x,d),new gt(_[1],x,c,u,L),new gt(_[0],a,c,x,L)),(b=(e>=L)<<1|i>=x)&&(w=g[g.length-1],g[g.length-1]=g[g.length-1-b],g[g.length-1-b]=w)}else{var M=i-+this._x.call(null,_.data),C=e-+this._y.call(null,_.data),Z=M*M+C*C;if(Z<t){var z=Math.sqrt(t=Z);r=i-z,o=e-z,m=i+z,f=e+z,n=_.data}}return n}function Yg(i){if(isNaN(m=+this._x.call(null,i))||isNaN(f=+this._y.call(null,i)))return this;var e,t=this._root,n,r,o,a=this._x0,c=this._y0,u=this._x1,d=this._y1,m,f,g,_,w,b,x,L;if(!t)return this;if(t.length)for(;;){if((w=m>=(g=(a+u)/2))?a=g:u=g,(b=f>=(_=(c+d)/2))?c=_:d=_,e=t,!(t=t[x=b<<1|w]))return this;if(!t.length)break;(e[x+1&3]||e[x+2&3]||e[x+3&3])&&(n=e,L=x)}for(;t.data!==i;)if(r=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,r?(o?r.next=o:delete r.next,this):e?(o?e[x]=o:delete e[x],(t=e[0]||e[1]||e[2]||e[3])&&t===(e[3]||e[2]||e[1]||e[0])&&!t.length&&(n?n[L]=t:this._root=t),this):(this._root=o,this)}function Rg(i){for(var e=0,t=i.length;e<t;++e)this.remove(i[e]);return this}function jg(){return this._root}function Jg(){var i=0;return this.visit(function(e){if(!e.length)do++i;while(e=e.next)}),i}function Qg(i){var e=[],t,n=this._root,r,o,a,c,u;for(n&&e.push(new gt(n,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!i(n=t.node,o=t.x0,a=t.y0,c=t.x1,u=t.y1)&&n.length){var d=(o+c)/2,m=(a+u)/2;(r=n[3])&&e.push(new gt(r,d,m,c,u)),(r=n[2])&&e.push(new gt(r,o,m,d,u)),(r=n[1])&&e.push(new gt(r,d,a,c,m)),(r=n[0])&&e.push(new gt(r,o,a,d,m))}return this}function Hg(i){var e=[],t=[],n;for(this._root&&e.push(new gt(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var r=n.node;if(r.length){var o,a=n.x0,c=n.y0,u=n.x1,d=n.y1,m=(a+u)/2,f=(c+d)/2;(o=r[0])&&e.push(new gt(o,a,c,m,f)),(o=r[1])&&e.push(new gt(o,m,c,u,f)),(o=r[2])&&e.push(new gt(o,a,f,m,d)),(o=r[3])&&e.push(new gt(o,m,f,u,d))}t.push(n)}for(;n=t.pop();)i(n.node,n.x0,n.y0,n.x1,n.y1);return this}function Eg(i){return i[0]}function $g(i){return arguments.length?(this._x=i,this):this._x}function qg(i){return i[1]}function e0(i){return arguments.length?(this._y=i,this):this._y}function Nc(i,e,t){var n=new $o(e??Eg,t??qg,NaN,NaN,NaN,NaN);return i==null?n:n.addAll(i)}function $o(i,e,t,n,r,o){this._x=i,this._y=e,this._x0=t,this._y0=n,this._x1=r,this._y1=o,this._root=void 0}function Bc(i){for(var e={data:i.data},t=e;i=i.next;)t=t.next={data:i.data};return e}var yt=Nc.prototype=$o.prototype;yt.copy=function(){var i=new $o(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,n;if(!e)return i;if(!e.length)return i._root=Bc(e),i;for(t=[{source:e,target:i._root=new Array(4)}];e=t.pop();)for(var r=0;r<4;++r)(n=e.source[r])&&(n.length?t.push({source:n,target:e.target[r]=new Array(4)}):e.target[r]=Bc(n));return i},yt.add=Xg,yt.addAll=Ug,yt.cover=kg,yt.data=Kg,yt.extent=Ng,yt.find=Bg,yt.remove=Yg,yt.removeAll=Rg,yt.root=jg,yt.size=Jg,yt.visit=Qg,yt.visitAfter=Hg,yt.x=$g,yt.y=e0;var t0=Object.defineProperty,n0=(i,e,t)=>e in i?t0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Yc=(i,e,t)=>n0(i,typeof e!="symbol"?e+"":e,t);class Rc{constructor(e){Yc(this,"_quadtree"),Yc(this,"_viewport"),this._viewport=e,this._rebuildQuadTree()}updateViewport(e){(e.width!==this._viewport.width||e.height!==this._viewport.height)&&(this._viewport=e,this._rebuildQuadTree())}addBoxes(e){e.forEach(t=>{this._isBoxInViewport(t)&&this._quadtree.add(t)})}findCollisions(e){const t=[],n=this._getSearchBounds(e);return this._quadtree.visit((r,o,a,c,u)=>this._checkNodeCollision(n,o,a,c,u)?(r.length||this._getNodeData(r).forEach(m=>{m.id!==e.id&&this._checkBoxCollision(e,m)&&t.push(m)}),!1):void 0),t}clear(){this._rebuildQuadTree()}getAllBoxes(){const e=[];return this._quadtree.visit(t=>{if(!t.length){const n=this._getNodeData(t);e.push(...n)}return!1}),e}_rebuildQuadTree(){this._quadtree=Nc().x(e=>e.x).y(e=>e.y).extent([[0,0],[this._viewport.width,this._viewport.height]])}_isBoxInViewport(e){const t=e.width/2,n=e.height/2;return e.x+t>=0&&e.x-t<=this._viewport.width&&e.y+n>=0&&e.y-n<=this._viewport.height}_getSearchBounds(e){return{x:e.x,y:e.y,width:e.width*2,height:e.height*2}}_checkNodeCollision(e,t,n,r,o){const a=(t+r)/2,c=(n+o)/2,u=r-t,d=o-n;return Math.abs(e.x-a)*2<e.width+u&&Math.abs(e.y-c)*2<e.height+d}_checkBoxCollision(e,t){return Math.abs(e.x-t.x)*2<e.width+t.width&&Math.abs(e.y-t.y)*2<e.height+t.height}_getNodeData(e){return e?Array.isArray(e.data)?e.data:e.data?[e.data]:[]:[]}removeBox(e){const n=this.getAllBoxes().filter(r=>r.id!==e);this.clear(),n.length>0&&this.addBoxes(n)}}var r0=Object.defineProperty,i0=(i,e,t)=>e in i?r0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,jc=(i,e,t)=>i0(i,typeof e!="symbol"?e+"":e,t);class s0{constructor(){jc(this,"_strategies",new Map),jc(this,"_executionOrder",[])}registerStrategy(e,t){return this._strategies.set(e.name,e),t!==void 0?this._executionOrder.splice(t,0,e.name):this._executionOrder.push(e.name),this}async executeStrategies(e,t){const n=new Map;e.forEach(r=>{n.set(r._id,{featureId:r._id,visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:t.timestamp})});for(const r of this._executionOrder){const o=this._strategies.get(r);if(o?.enabled)try{const a=await o.execute(e,t,n);this._mergeResults(n,a)}catch(a){console.error(`Strategy ${r} execution failed: 策略 ${r} 执行失败:`,a)}}return n}_mergeResults(e,t){t.forEach(n=>{const r=e.get(n.featureId);r&&!r.visible||e.set(n.featureId,n)})}}var o0=Object.defineProperty,a0=(i,e,t)=>e in i?o0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_r=(i,e,t)=>a0(i,typeof e!="symbol"?e+"":e,t);class l0{constructor(){_r(this,"frameStats",new Map),_r(this,"summaryStats",{totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0}),_r(this,"sampleWindowSize",60),_r(this,"currentFrameId",0),_r(this,"lastReportTime",0),_r(this,"reportInterval",5e3),_r(this,"performanceThresholds",{criticalFrameTime:33,warningFrameTime:16,idealFrameTime:8}),this.lastReportTime=Date.now()}startFrame(e){this.currentFrameId=e;const t={frameId:e,startTime:performance.now(),endTime:0,duration:0,featureCount:0,visibleCount:0,hiddenCount:0,collisionChecks:0,memoryUsage:0,strategyTimes:new Map};this.frameStats.set(e,t),this.cleanupOldFrames()}endFrame(e,t){const n=this.frameStats.get(e);if(!n)return;const r=performance.now();n.endTime=r,n.duration=r-n.startTime,t&&Object.assign(n,t),"memory"in performance&&(n.memoryUsage=performance.memory.usedJSHeapSize),this.updateSummaryStats(n),this.maybeOutputReport()}recordStrategyTime(e,t){const n=this.frameStats.get(this.currentFrameId);n&&n.strategyTimes.set(e,t)}recordCollisionChecks(e){const t=this.frameStats.get(this.currentFrameId);t&&(t.collisionChecks+=e)}getStats(){const e=this.getRecentFrames(this.sampleWindowSize),t=this.calculateFPS(e),n=this.calculateAverageFrameTime(e);return{summary:{...this.summaryStats},recent:{fps:t,frameTime:n,frameTimeStdDev:this.calculateFrameTimeStdDev(e),averageFeaturesPerFrame:this.calculateAverageFeatures(e),performanceLevel:this.getPerformanceLevel(n)},currentFrame:this.frameStats.get(this.currentFrameId)||null,strategies:this.getStrategyPerformance(e),warnings:this.getPerformanceWarnings(e)}}getDetailedReport(){const e=this.getRecentFrames(this.sampleWindowSize),t=this.getStats();return{...t,frameHistory:Array.from(e.values()),trends:this.calculateTrends(e),recommendations:this.getPerformanceRecommendations(t)}}reset(){this.frameStats.clear(),this.summaryStats={totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0},this.currentFrameId=0,this.lastReportTime=Date.now()}cleanupOldFrames(){this.frameStats.size>this.sampleWindowSize*2&&Array.from(this.frameStats.keys()).sort((t,n)=>t-n).slice(0,this.frameStats.size-this.sampleWindowSize).forEach(t=>{this.frameStats.delete(t)})}updateSummaryStats(e){this.summaryStats.totalFrames++,this.summaryStats.totalFeaturesProcessed+=e.featureCount||0,this.summaryStats.averageFrameTime=(this.summaryStats.averageFrameTime*(this.summaryStats.totalFrames-1)+e.duration)/this.summaryStats.totalFrames,this.summaryStats.minFrameTime=Math.min(this.summaryStats.minFrameTime,e.duration),this.summaryStats.maxFrameTime=Math.max(this.summaryStats.maxFrameTime,e.duration),this.summaryStats.averageFPS=1e3/this.summaryStats.averageFrameTime}maybeOutputReport(){const e=Date.now();if(e-this.lastReportTime>=this.reportInterval){const t=this.getStats();t.warnings.length>0?console.warn("避让系统性能报告:",t):console.log("避让系统性能正常:",t),this.lastReportTime=e}}getRecentFrames(e){return Array.from(this.frameStats.values()).slice(-e).filter(n=>n.duration>0)}calculateFPS(e){if(e.length===0)return 0;const t=this.calculateAverageFrameTime(e);return t>0?1e3/t:0}calculateAverageFrameTime(e){return e.length===0?0:e.reduce((t,n)=>t+n.duration,0)/e.length}calculateFrameTimeStdDev(e){if(e.length===0)return 0;const t=this.calculateAverageFrameTime(e),n=e.map(r=>Math.pow(r.duration-t,2));return Math.sqrt(n.reduce((r,o)=>r+o,0)/e.length)}calculateAverageFeatures(e){return e.length===0?0:e.reduce((t,n)=>t+(n.featureCount||0),0)/e.length}getPerformanceLevel(e){return e>this.performanceThresholds.criticalFrameTime?"critical":e>this.performanceThresholds.warningFrameTime?"warning":e>this.performanceThresholds.idealFrameTime?"good":"excellent"}getStrategyPerformance(e){const t=new Map;return e.forEach(n=>{n.strategyTimes.forEach((r,o)=>{t.has(o)||t.set(o,[]),t.get(o).push(r)})}),Array.from(t.entries()).map(([n,r])=>({name:n,averageTime:r.reduce((o,a)=>o+a,0)/r.length,maxTime:Math.max(...r),minTime:Math.min(...r),callCount:r.length}))}getPerformanceWarnings(e){const t=[],n=e.slice(-30);if(n.length===0)return t;const r=this.calculateAverageFrameTime(n);r>this.performanceThresholds.criticalFrameTime?t.push({type:"critical",message:`帧率过低: ${Math.round(1e3/r)}fps`,suggestion:"考虑减少要素数量或简化避让策略"}):r>this.performanceThresholds.warningFrameTime&&t.push({type:"warning",message:`帧率较低: ${Math.round(1e3/r)}fps`,suggestion:"建议优化避让算法或增加更新间隔"});const o=n.map(a=>a.memoryUsage).filter(a=>a>0);if(o.length>0){const a=o.reduce((c,u)=>c+u,0)/o.length;a>100*1024*1024&&t.push({type:"warning",message:`内存使用较高: ${(a/1024/1024).toFixed(1)}MB`,suggestion:"检查内存泄漏,及时清理无用资源"})}return t}calculateTrends(e){if(e.length<2)return{frameTime:"stable",fps:"stable",features:"stable"};const t=e.slice(0,Math.floor(e.length/2)),n=e.slice(Math.floor(e.length/2)),r=this.calculateAverageFrameTime(t),a=(this.calculateAverageFrameTime(n)-r)/r*100;return{frameTime:Math.abs(a)<5?"stable":a>0?"worsening":"improving",fps:Math.abs(a)<5?"stable":a>0?"improving":"worsening",features:"stable"}}getPerformanceRecommendations(e){const t=[];return e.recent.performanceLevel==="critical"&&(t.push("建议启用要素抽样或聚合显示"),t.push("考虑增加避让更新间隔时间"),t.push("检查是否有不必要的避让策略")),e.recent.averageFeaturesPerFrame>5e3&&t.push("要素数量过多,建议启用LOD分级"),e.strategies.forEach(n=>{n.averageTime>10&&t.push(`策略 "${n.name}" 执行时间较长,考虑优化`)}),t}}var c0=Object.defineProperty,u0=(i,e,t)=>e in i?c0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ms=(i,e,t)=>u0(i,typeof e!="symbol"?e+"":e,t);class h0{constructor(){ms(this,"name","priority"),ms(this,"enabled",!0),ms(this,"weight",1),ms(this,"description","Priority-based avoidance strategy, smaller value means higher priority 基于优先级的避让策略,数值越小优先级越高")}async execute(e,t,n){const r=[],o=new Rc(t.viewport),a=[],c=new Map;return e.forEach(u=>{if(!u.collidable)return;const d=u.getScreenBoundingBox(t.camera,t.renderer);d&&(a.push(d),c.set(u._id,u),n?.get(u._id)?.visible)}),a.sort((u,d)=>u.priority-d.priority),a.forEach(u=>{const d=o.findCollisions(u);d.length===0?(o.addBoxes([u]),r.push({featureId:u.featureId,visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:t.timestamp})):d.some(f=>f.priority<u.priority)?r.push({featureId:u.featureId,visible:!1,reason:yn.PRIORITY_LOST,collidedWith:d.map(f=>f.featureId),timestamp:t.timestamp}):(o.addBoxes([u]),r.push({featureId:u.featureId,visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:t.timestamp}),d.forEach(f=>{r.push({featureId:f.featureId,visible:!1,reason:yn.PRIORITY_LOST,collidedWith:[u.featureId],timestamp:t.timestamp})}))}),r}}var d0=Object.defineProperty,f0=(i,e,t)=>e in i?d0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Yn=(i,e,t)=>f0(i,typeof e!="symbol"?e+"":e,t);class p0{constructor(e,t={}){this.renderer=e,Yn(this,"_quadTreeManager"),Yn(this,"_strategyOrchestrator"),Yn(this,"_performanceMonitor"),Yn(this,"_layers",new Set),Yn(this,"_config"),Yn(this,"_isUpdating",!1),Yn(this,"_lastUpdateTime",0),Yn(this,"_frameCount",0),this._config={enabled:!0,padding:4,updateInterval:0,animationDuration:300,maxFeaturesPerFrame:2e3,viewportMargin:50,strategies:{priority:!0,grouping:!1,proximity:!1},...t},this._initializeComponents(),this._setupPerformanceMonitoring()}async update(e){if(!this._config.enabled||this._isUpdating)return;const t=Date.now();if(!(this._config.updateInterval>0&&t-this._lastUpdateTime<this._config.updateInterval)){this._isUpdating=!0,this._frameCount++;try{this._resetAllFeaturesVisibility();const n=this._createCollisionContext(e,t),r=this._collectCollidableFeatures();if(r.length===0)return;this._performanceMonitor.startFrame(this._frameCount);const o=await this._strategyOrchestrator.executeStrategies(r,n);await this._applyCollisionResults(o,r),this._performanceMonitor.endFrame(this._frameCount,{featureCount:r.length,visibleCount:Array.from(o.values()).filter(a=>a.visible).length,hiddenCount:Array.from(o.values()).filter(a=>!a.visible).length}),this._lastUpdateTime=t}catch(n){console.error("避让引擎更新失败:",n)}finally{this._isUpdating=!1}}}_resetAllFeaturesVisibility(){this._layers.forEach(e=>{e.getFeatures().filter(n=>n.collidable).forEach(n=>{n.setCollisionVisibility(!0,yn.NO_COLLISION)})})}registerLayer(e){return this._layers.add(e),this}unregisterLayer(e){return this._layers.delete(e),this}setConfig(e){return Object.assign(this._config,e),this}getPerformanceStats(){return this._performanceMonitor.getStats()}_initializeComponents(){const e={width:this.renderer.domElement.width,height:this.renderer.domElement.height};this._quadTreeManager=new Rc(e),this._strategyOrchestrator=new s0,this._performanceMonitor=new l0,this._strategyOrchestrator.registerStrategy(new h0,0),this._setupViewportResizeHandler()}_createCollisionContext(e,t){return{camera:e,renderer:this.renderer,viewport:{width:this.renderer.domElement.width,height:this.renderer.domElement.height},zoomLevel:e.position.z,timestamp:t,frameNumber:this._frameCount}}_collectCollidableFeatures(){const e=[];return this._layers.forEach(t=>{const n=t.getFeatures().filter(r=>r.collidable&&r instanceof ut);if(e.length+n.length>this._config.maxFeaturesPerFrame){console.warn(`达到每帧最大要素处理限制: ${this._config.maxFeaturesPerFrame}`);return}e.push(...n)}),e}async _applyCollisionResults(e,t){const n=t.map(r=>{const o=e.get(r._id);return o&&r.setCollisionVisibility(o.visible,o.reason),Promise.resolve()});await Promise.all(n)}_setupViewportResizeHandler(){new ResizeObserver(t=>{t.forEach(n=>{const{width:r,height:o}=n.contentRect;this._quadTreeManager.updateViewport({width:r,height:o})})}).observe(this.renderer.domElement)}_setupPerformanceMonitoring(){setInterval(()=>{const e=this.getPerformanceStats();e.frameRate<30&&console.warn("避让系统性能警告:",e)},5e3)}}var Li=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},gs={exports:{}};gs.exports,function(i,e){(function(){var t,n="4.17.21",r=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",c="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,m="__lodash_placeholder__",f=1,g=2,_=4,w=1,b=2,x=1,L=2,M=4,C=8,Z=16,z=32,D=64,X=128,I=256,K=512,V=30,G="...",k=800,j=16,Y=1,H=2,Q=3,ie=1/0,re=9007199254740991,le=17976931348623157e292,de=NaN,ge=4294967295,fe=ge-1,Se=ge>>>1,rt=[["ary",X],["bind",x],["bindKey",L],["curry",C],["curryRight",Z],["flip",K],["partial",z],["partialRight",D],["rearg",I]],it="[object Arguments]",dt="[object Array]",Qe="[object AsyncFunction]",Ye="[object Boolean]",Re="[object Date]",st="[object DOMException]",ze="[object Error]",Vt="[object Function]",Nt="[object GeneratorFunction]",Ce="[object Map]",ot="[object Number]",ft="[object Null]",Lt="[object Object]",wr="[object Promise]",Yr="[object Proxy]",br="[object RegExp]",It="[object Set]",$n="[object String]",qn="[object Symbol]",xr="[object Undefined]",Mr="[object WeakMap]",wa="[object WeakSet]",er="[object ArrayBuffer]",wn="[object DataView]",Vi="[object Float32Array]",Ii="[object Float64Array]",Rr="[object Int8Array]",Ai="[object Int16Array]",Fi="[object Int32Array]",jr="[object Uint8Array]",Sr="[object Uint8ClampedArray]",O="[object Uint16Array]",E="[object Uint32Array]",ce=/\b__p \+= '';/g,Me=/\b(__p \+=) '' \+/g,Be=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Bt=/&(?:amp|lt|gt|quot|#39);/g,sn=/[&<>"']/g,Wu=RegExp(Bt.source),Ts=RegExp(sn.source),on=/<%-([\s\S]+?)%>/g,an=/<%([\s\S]+?)%>/g,tr=/<%=([\s\S]+?)%>/g,Lr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pr=/^\w*$/,Jr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ba=/[\\^$.*+?()[\]{}|]/g,sw=RegExp(ba.source),xa=/^\s+/,ow=/\s/,aw=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,lw=/\{\n\/\* \[wrapped with (.+)\] \*/,cw=/,? & /,uw=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,hw=/[()=,{}\[\]\/\s]/,dw=/\\(\\)?/g,fw=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Vu=/\w*$/,pw=/^[-+]0x[0-9a-f]+$/i,mw=/^0b[01]+$/i,gw=/^\[object .+?Constructor\]$/,yw=/^0o[0-7]+$/i,_w=/^(?:0|[1-9]\d*)$/,vw=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Gs=/($^)/,ww=/['\n\r\u2028\u2029\\]/g,Zs="\\ud800-\\udfff",bw="\\u0300-\\u036f",xw="\\ufe20-\\ufe2f",Mw="\\u20d0-\\u20ff",Iu=bw+xw+Mw,Au="\\u2700-\\u27bf",Fu="a-z\\xdf-\\xf6\\xf8-\\xff",Sw="\\xac\\xb1\\xd7\\xf7",Lw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Pw="\\u2000-\\u206f",Cw=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ou="A-Z\\xc0-\\xd6\\xd8-\\xde",Du="\\ufe0e\\ufe0f",zu=Sw+Lw+Pw+Cw,Ma="['’]",Tw="["+Zs+"]",Xu="["+zu+"]",Ws="["+Iu+"]",Uu="\\d+",Gw="["+Au+"]",ku="["+Fu+"]",Ku="[^"+Zs+zu+Uu+Au+Fu+Ou+"]",Sa="\\ud83c[\\udffb-\\udfff]",Zw="(?:"+Ws+"|"+Sa+")",Nu="[^"+Zs+"]",La="(?:\\ud83c[\\udde6-\\uddff]){2}",Pa="[\\ud800-\\udbff][\\udc00-\\udfff]",Qr="["+Ou+"]",Bu="\\u200d",Yu="(?:"+ku+"|"+Ku+")",Ww="(?:"+Qr+"|"+Ku+")",Ru="(?:"+Ma+"(?:d|ll|m|re|s|t|ve))?",ju="(?:"+Ma+"(?:D|LL|M|RE|S|T|VE))?",Ju=Zw+"?",Qu="["+Du+"]?",Vw="(?:"+Bu+"(?:"+[Nu,La,Pa].join("|")+")"+Qu+Ju+")*",Iw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Aw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Hu=Qu+Ju+Vw,Fw="(?:"+[Gw,La,Pa].join("|")+")"+Hu,Ow="(?:"+[Nu+Ws+"?",Ws,La,Pa,Tw].join("|")+")",Dw=RegExp(Ma,"g"),zw=RegExp(Ws,"g"),Ca=RegExp(Sa+"(?="+Sa+")|"+Ow+Hu,"g"),Xw=RegExp([Qr+"?"+ku+"+"+Ru+"(?="+[Xu,Qr,"$"].join("|")+")",Ww+"+"+ju+"(?="+[Xu,Qr+Yu,"$"].join("|")+")",Qr+"?"+Yu+"+"+Ru,Qr+"+"+ju,Aw,Iw,Uu,Fw].join("|"),"g"),Uw=RegExp("["+Bu+Zs+Iu+Du+"]"),kw=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Kw=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","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&self,at=Eu||Hw||Function("return this")(),Ta=e&&!e.nodeType&&e,Cr=Ta&&!0&&i&&!i.nodeType&&i,$u=Cr&&Cr.exports===Ta,Ga=$u&&Eu.process,Yt=function(){try{var A=Cr&&Cr.require&&Cr.require("util").types;return A||Ga&&Ga.binding&&Ga.binding("util")}catch{}}(),qu=Yt&&Yt.isArrayBuffer,eh=Yt&&Yt.isDate,th=Yt&&Yt.isMap,nh=Yt&&Yt.isRegExp,rh=Yt&&Yt.isSet,ih=Yt&&Yt.isTypedArray;function At(A,N,U){switch(U.length){case 0:return A.call(N);case 1:return A.call(N,U[0]);case 2:return A.call(N,U[0],U[1]);case 3:return A.call(N,U[0],U[1],U[2])}return A.apply(N,U)}function Ew(A,N,U,ee){for(var ue=-1,Le=A==null?0:A.length;++ue<Le;){var je=A[ue];N(ee,je,U(je),A)}return ee}function Rt(A,N){for(var U=-1,ee=A==null?0:A.length;++U<ee&&N(A[U],U,A)!==!1;);return A}function $w(A,N){for(var U=A==null?0:A.length;U--&&N(A[U],U,A)!==!1;);return A}function sh(A,N){for(var U=-1,ee=A==null?0:A.length;++U<ee;)if(!N(A[U],U,A))return!1;return!0}function nr(A,N){for(var U=-1,ee=A==null?0:A.length,ue=0,Le=[];++U<ee;){var je=A[U];N(je,U,A)&&(Le[ue++]=je)}return Le}function Vs(A,N){var U=A==null?0:A.length;return!!U&&Hr(A,N,0)>-1}function Za(A,N,U){for(var ee=-1,ue=A==null?0:A.length;++ee<ue;)if(U(N,A[ee]))return!0;return!1}function Ae(A,N){for(var U=-1,ee=A==null?0:A.length,ue=Array(ee);++U<ee;)ue[U]=N(A[U],U,A);return ue}function rr(A,N){for(var U=-1,ee=N.length,ue=A.length;++U<ee;)A[ue+U]=N[U];return A}function Wa(A,N,U,ee){var ue=-1,Le=A==null?0:A.length;for(ee&&Le&&(U=A[++ue]);++ue<Le;)U=N(U,A[ue],ue,A);return U}function qw(A,N,U,ee){var ue=A==null?0:A.length;for(ee&&ue&&(U=A[--ue]);ue--;)U=N(U,A[ue],ue,A);return U}function Va(A,N){for(var U=-1,ee=A==null?0:A.length;++U<ee;)if(N(A[U],U,A))return!0;return!1}var eb=Ia("length");function tb(A){return A.split("")}function nb(A){return A.match(uw)||[]}function oh(A,N,U){var ee;return U(A,function(ue,Le,je){if(N(ue,Le,je))return ee=Le,!1}),ee}function Is(A,N,U,ee){for(var ue=A.length,Le=U+(ee?1:-1);ee?Le--:++Le<ue;)if(N(A[Le],Le,A))return Le;return-1}function Hr(A,N,U){return N===N?pb(A,N,U):Is(A,ah,U)}function rb(A,N,U,ee){for(var ue=U-1,Le=A.length;++ue<Le;)if(ee(A[ue],N))return ue;return-1}function ah(A){return A!==A}function lh(A,N){var U=A==null?0:A.length;return U?Fa(A,N)/U:de}function Ia(A){return function(N){return N==null?t:N[A]}}function Aa(A){return function(N){return A==null?t:A[N]}}function ch(A,N,U,ee,ue){return ue(A,function(Le,je,Ge){U=ee?(ee=!1,Le):N(U,Le,je,Ge)}),U}function ib(A,N){var U=A.length;for(A.sort(N);U--;)A[U]=A[U].value;return A}function Fa(A,N){for(var U,ee=-1,ue=A.length;++ee<ue;){var Le=N(A[ee]);Le!==t&&(U=U===t?Le:U+Le)}return U}function Oa(A,N){for(var U=-1,ee=Array(A);++U<A;)ee[U]=N(U);return ee}function sb(A,N){return Ae(N,function(U){return[U,A[U]]})}function uh(A){return A&&A.slice(0,ph(A)+1).replace(xa,"")}function Ft(A){return function(N){return A(N)}}function Da(A,N){return Ae(N,function(U){return A[U]})}function Oi(A,N){return A.has(N)}function hh(A,N){for(var U=-1,ee=A.length;++U<ee&&Hr(N,A[U],0)>-1;);return U}function dh(A,N){for(var U=A.length;U--&&Hr(N,A[U],0)>-1;);return U}function ob(A,N){for(var U=A.length,ee=0;U--;)A[U]===N&&++ee;return ee}var ab=Aa(Bw),lb=Aa(Yw);function cb(A){return"\\"+jw[A]}function ub(A,N){return A==null?t:A[N]}function Er(A){return Uw.test(A)}function hb(A){return kw.test(A)}function db(A){for(var N,U=[];!(N=A.next()).done;)U.push(N.value);return U}function za(A){var N=-1,U=Array(A.size);return A.forEach(function(ee,ue){U[++N]=[ue,ee]}),U}function fh(A,N){return function(U){return A(N(U))}}function ir(A,N){for(var U=-1,ee=A.length,ue=0,Le=[];++U<ee;){var je=A[U];(je===N||je===m)&&(A[U]=m,Le[ue++]=U)}return Le}function As(A){var N=-1,U=Array(A.size);return A.forEach(function(ee){U[++N]=ee}),U}function fb(A){var N=-1,U=Array(A.size);return A.forEach(function(ee){U[++N]=[ee,ee]}),U}function pb(A,N,U){for(var ee=U-1,ue=A.length;++ee<ue;)if(A[ee]===N)return ee;return-1}function mb(A,N,U){for(var ee=U+1;ee--;)if(A[ee]===N)return ee;return ee}function $r(A){return Er(A)?yb(A):eb(A)}function ln(A){return Er(A)?_b(A):tb(A)}function ph(A){for(var N=A.length;N--&&ow.test(A.charAt(N)););return N}var gb=Aa(Rw);function yb(A){for(var N=Ca.lastIndex=0;Ca.test(A);)++N;return N}function _b(A){return A.match(Ca)||[]}function vb(A){return A.match(Xw)||[]}var wb=function A(N){N=N==null?at:qr.defaults(at.Object(),N,qr.pick(at,Kw));var U=N.Array,ee=N.Date,ue=N.Error,Le=N.Function,je=N.Math,Ge=N.Object,Xa=N.RegExp,bb=N.String,jt=N.TypeError,Fs=U.prototype,xb=Le.prototype,ei=Ge.prototype,Os=N["__core-js_shared__"],Ds=xb.toString,Te=ei.hasOwnProperty,Mb=0,mh=function(){var s=/[^.]+$/.exec(Os&&Os.keys&&Os.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),zs=ei.toString,Sb=Ds.call(Ge),Lb=at._,Pb=Xa("^"+Ds.call(Te).replace(ba,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Xs=$u?N.Buffer:t,sr=N.Symbol,Us=N.Uint8Array,gh=Xs?Xs.allocUnsafe:t,ks=fh(Ge.getPrototypeOf,Ge),yh=Ge.create,_h=ei.propertyIsEnumerable,Ks=Fs.splice,vh=sr?sr.isConcatSpreadable:t,Di=sr?sr.iterator:t,Tr=sr?sr.toStringTag:t,Ns=function(){try{var s=Ir(Ge,"defineProperty");return s({},"",{}),s}catch{}}(),Cb=N.clearTimeout!==at.clearTimeout&&N.clearTimeout,Tb=ee&&ee.now!==at.Date.now&&ee.now,Gb=N.setTimeout!==at.setTimeout&&N.setTimeout,Bs=je.ceil,Ys=je.floor,Ua=Ge.getOwnPropertySymbols,Zb=Xs?Xs.isBuffer:t,wh=N.isFinite,Wb=Fs.join,Vb=fh(Ge.keys,Ge),Je=je.max,pt=je.min,Ib=ee.now,Ab=N.parseInt,bh=je.random,Fb=Fs.reverse,ka=Ir(N,"DataView"),zi=Ir(N,"Map"),Ka=Ir(N,"Promise"),ti=Ir(N,"Set"),Xi=Ir(N,"WeakMap"),Ui=Ir(Ge,"create"),Rs=Xi&&new Xi,ni={},Ob=Ar(ka),Db=Ar(zi),zb=Ar(Ka),Xb=Ar(ti),Ub=Ar(Xi),js=sr?sr.prototype:t,ki=js?js.valueOf:t,xh=js?js.toString:t;function S(s){if(Xe(s)&&!he(s)&&!(s instanceof be)){if(s instanceof Jt)return s;if(Te.call(s,"__wrapped__"))return Md(s)}return new Jt(s)}var ri=function(){function s(){}return function(l){if(!Fe(l))return{};if(yh)return yh(l);s.prototype=l;var h=new s;return s.prototype=t,h}}();function Js(){}function Jt(s,l){this.__wrapped__=s,this.__actions__=[],this.__chain__=!!l,this.__index__=0,this.__values__=t}S.templateSettings={escape:on,evaluate:an,interpolate:tr,variable:"",imports:{_:S}},S.prototype=Js.prototype,S.prototype.constructor=S,Jt.prototype=ri(Js.prototype),Jt.prototype.constructor=Jt;function be(s){this.__wrapped__=s,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ge,this.__views__=[]}function kb(){var s=new be(this.__wrapped__);return s.__actions__=Pt(this.__actions__),s.__dir__=this.__dir__,s.__filtered__=this.__filtered__,s.__iteratees__=Pt(this.__iteratees__),s.__takeCount__=this.__takeCount__,s.__views__=Pt(this.__views__),s}function Kb(){if(this.__filtered__){var s=new be(this);s.__dir__=-1,s.__filtered__=!0}else s=this.clone(),s.__dir__*=-1;return s}function Nb(){var s=this.__wrapped__.value(),l=this.__dir__,h=he(s),y=l<0,v=h?s.length:0,P=tx(0,v,this.__views__),T=P.start,W=P.end,F=W-T,B=y?W:T-1,R=this.__iteratees__,J=R.length,$=0,te=pt(F,this.__takeCount__);if(!h||!y&&v==F&&te==F)return Rh(s,this.__actions__);var oe=[];e:for(;F--&&$<te;){B+=l;for(var me=-1,ae=s[B];++me<J;){var we=R[me],xe=we.iteratee,zt=we.type,wt=xe(ae);if(zt==H)ae=wt;else if(!wt){if(zt==Y)continue e;break e}}oe[$++]=ae}return oe}be.prototype=ri(Js.prototype),be.prototype.constructor=be;function Gr(s){var l=-1,h=s==null?0:s.length;for(this.clear();++l<h;){var y=s[l];this.set(y[0],y[1])}}function Bb(){this.__data__=Ui?Ui(null):{},this.size=0}function Yb(s){var l=this.has(s)&&delete this.__data__[s];return this.size-=l?1:0,l}function Rb(s){var l=this.__data__;if(Ui){var h=l[s];return h===u?t:h}return Te.call(l,s)?l[s]:t}function jb(s){var l=this.__data__;return Ui?l[s]!==t:Te.call(l,s)}function Jb(s,l){var h=this.__data__;return this.size+=this.has(s)?0:1,h[s]=Ui&&l===t?u:l,this}Gr.prototype.clear=Bb,Gr.prototype.delete=Yb,Gr.prototype.get=Rb,Gr.prototype.has=jb,Gr.prototype.set=Jb;function Tn(s){var l=-1,h=s==null?0:s.length;for(this.clear();++l<h;){var y=s[l];this.set(y[0],y[1])}}function Qb(){this.__data__=[],this.size=0}function Hb(s){var l=this.__data__,h=Qs(l,s);if(h<0)return!1;var y=l.length-1;return h==y?l.pop():Ks.call(l,h,1),--this.size,!0}function Eb(s){var l=this.__data__,h=Qs(l,s);return h<0?t:l[h][1]}function $b(s){return Qs(this.__data__,s)>-1}function qb(s,l){var h=this.__data__,y=Qs(h,s);return y<0?(++this.size,h.push([s,l])):h[y][1]=l,this}Tn.prototype.clear=Qb,Tn.prototype.delete=Hb,Tn.prototype.get=Eb,Tn.prototype.has=$b,Tn.prototype.set=qb;function Gn(s){var l=-1,h=s==null?0:s.length;for(this.clear();++l<h;){var y=s[l];this.set(y[0],y[1])}}function e1(){this.size=0,this.__data__={hash:new Gr,map:new(zi||Tn),string:new Gr}}function t1(s){var l=ao(this,s).delete(s);return this.size-=l?1:0,l}function n1(s){return ao(this,s).get(s)}function r1(s){return ao(this,s).has(s)}function i1(s,l){var h=ao(this,s),y=h.size;return h.set(s,l),this.size+=h.size==y?0:1,this}Gn.prototype.clear=e1,Gn.prototype.delete=t1,Gn.prototype.get=n1,Gn.prototype.has=r1,Gn.prototype.set=i1;function Zr(s){var l=-1,h=s==null?0:s.length;for(this.__data__=new Gn;++l<h;)this.add(s[l])}function s1(s){return this.__data__.set(s,u),this}function o1(s){return this.__data__.has(s)}Zr.prototype.add=Zr.prototype.push=s1,Zr.prototype.has=o1;function cn(s){var l=this.__data__=new Tn(s);this.size=l.size}function a1(){this.__data__=new Tn,this.size=0}function l1(s){var l=this.__data__,h=l.delete(s);return this.size=l.size,h}function c1(s){return this.__data__.get(s)}function u1(s){return this.__data__.has(s)}function h1(s,l){var h=this.__data__;if(h instanceof Tn){var y=h.__data__;if(!zi||y.length<r-1)return y.push([s,l]),this.size=++h.size,this;h=this.__data__=new Gn(y)}return h.set(s,l),this.size=h.size,this}cn.prototype.clear=a1,cn.prototype.delete=l1,cn.prototype.get=c1,cn.prototype.has=u1,cn.prototype.set=h1;function Mh(s,l){var h=he(s),y=!h&&Fr(s),v=!h&&!y&&ur(s),P=!h&&!y&&!v&&ai(s),T=h||y||v||P,W=T?Oa(s.length,bb):[],F=W.length;for(var B in s)(l||Te.call(s,B))&&!(T&&(B=="length"||v&&(B=="offset"||B=="parent")||P&&(B=="buffer"||B=="byteLength"||B=="byteOffset")||In(B,F)))&&W.push(B);return W}function Sh(s){var l=s.length;return l?s[qa(0,l-1)]:t}function d1(s,l){return lo(Pt(s),Wr(l,0,s.length))}function f1(s){return lo(Pt(s))}function Na(s,l,h){(h!==t&&!un(s[l],h)||h===t&&!(l in s))&&Zn(s,l,h)}function Ki(s,l,h){var y=s[l];(!(Te.call(s,l)&&un(y,h))||h===t&&!(l in s))&&Zn(s,l,h)}function Qs(s,l){for(var h=s.length;h--;)if(un(s[h][0],l))return h;return-1}function p1(s,l,h,y){return or(s,function(v,P,T){l(y,v,h(v),T)}),y}function Lh(s,l){return s&&xn(l,He(l),s)}function m1(s,l){return s&&xn(l,Tt(l),s)}function Zn(s,l,h){l=="__proto__"&&Ns?Ns(s,l,{configurable:!0,enumerable:!0,value:h,writable:!0}):s[l]=h}function Ba(s,l){for(var h=-1,y=l.length,v=U(y),P=s==null;++h<y;)v[h]=P?t:Sl(s,l[h]);return v}function Wr(s,l,h){return s===s&&(h!==t&&(s=s<=h?s:h),l!==t&&(s=s>=l?s:l)),s}function Qt(s,l,h,y,v,P){var T,W=l&f,F=l&g,B=l&_;if(h&&(T=v?h(s,y,v,P):h(s)),T!==t)return T;if(!Fe(s))return s;var R=he(s);if(R){if(T=rx(s),!W)return Pt(s,T)}else{var J=mt(s),$=J==Vt||J==Nt;if(ur(s))return Qh(s,W);if(J==Lt||J==it||$&&!v){if(T=F||$?{}:pd(s),!W)return F?R1(s,m1(T,s)):Y1(s,Lh(T,s))}else{if(!Ze[J])return v?s:{};T=ix(s,J,W)}}P||(P=new cn);var te=P.get(s);if(te)return te;P.set(s,T),Nd(s)?s.forEach(function(ae){T.add(Qt(ae,l,h,ae,s,P))}):kd(s)&&s.forEach(function(ae,we){T.set(we,Qt(ae,l,h,we,s,P))});var oe=B?F?ul:cl:F?Tt:He,me=R?t:oe(s);return Rt(me||s,function(ae,we){me&&(we=ae,ae=s[we]),Ki(T,we,Qt(ae,l,h,we,s,P))}),T}function g1(s){var l=He(s);return function(h){return Ph(h,s,l)}}function Ph(s,l,h){var y=h.length;if(s==null)return!y;for(s=Ge(s);y--;){var v=h[y],P=l[v],T=s[v];if(T===t&&!(v in s)||!P(T))return!1}return!0}function Ch(s,l,h){if(typeof s!="function")throw new jt(a);return Qi(function(){s.apply(t,h)},l)}function Ni(s,l,h,y){var v=-1,P=Vs,T=!0,W=s.length,F=[],B=l.length;if(!W)return F;h&&(l=Ae(l,Ft(h))),y?(P=Za,T=!1):l.length>=r&&(P=Oi,T=!1,l=new Zr(l));e:for(;++v<W;){var R=s[v],J=h==null?R:h(R);if(R=y||R!==0?R:0,T&&J===J){for(var $=B;$--;)if(l[$]===J)continue e;F.push(R)}else P(l,J,y)||F.push(R)}return F}var or=ed(bn),Th=ed(Ra,!0);function y1(s,l){var h=!0;return or(s,function(y,v,P){return h=!!l(y,v,P),h}),h}function Hs(s,l,h){for(var y=-1,v=s.length;++y<v;){var P=s[y],T=l(P);if(T!=null&&(W===t?T===T&&!Dt(T):h(T,W)))var W=T,F=P}return F}function _1(s,l,h,y){var v=s.length;for(h=pe(h),h<0&&(h=-h>v?0:v+h),y=y===t||y>v?v:pe(y),y<0&&(y+=v),y=h>y?0:Yd(y);h<y;)s[h++]=l;return s}function Gh(s,l){var h=[];return or(s,function(y,v,P){l(y,v,P)&&h.push(y)}),h}function lt(s,l,h,y,v){var P=-1,T=s.length;for(h||(h=ox),v||(v=[]);++P<T;){var W=s[P];l>0&&h(W)?l>1?lt(W,l-1,h,y,v):rr(v,W):y||(v[v.length]=W)}return v}var Ya=td(),Zh=td(!0);function bn(s,l){return s&&Ya(s,l,He)}function Ra(s,l){return s&&Zh(s,l,He)}function Es(s,l){return nr(l,function(h){return An(s[h])})}function Vr(s,l){l=lr(l,s);for(var h=0,y=l.length;s!=null&&h<y;)s=s[Mn(l[h++])];return h&&h==y?s:t}function Wh(s,l,h){var y=l(s);return he(s)?y:rr(y,h(s))}function _t(s){return s==null?s===t?xr:ft:Tr&&Tr in Ge(s)?ex(s):fx(s)}function ja(s,l){return s>l}function v1(s,l){return s!=null&&Te.call(s,l)}function w1(s,l){return s!=null&&l in Ge(s)}function b1(s,l,h){return s>=pt(l,h)&&s<Je(l,h)}function Ja(s,l,h){for(var y=h?Za:Vs,v=s[0].length,P=s.length,T=P,W=U(P),F=1/0,B=[];T--;){var R=s[T];T&&l&&(R=Ae(R,Ft(l))),F=pt(R.length,F),W[T]=!h&&(l||v>=120&&R.length>=120)?new Zr(T&&R):t}R=s[0];var J=-1,$=W[0];e:for(;++J<v&&B.length<F;){var te=R[J],oe=l?l(te):te;if(te=h||te!==0?te:0,!($?Oi($,oe):y(B,oe,h))){for(T=P;--T;){var me=W[T];if(!(me?Oi(me,oe):y(s[T],oe,h)))continue e}$&&$.push(oe),B.push(te)}}return B}function x1(s,l,h,y){return bn(s,function(v,P,T){l(y,h(v),P,T)}),y}function Bi(s,l,h){l=lr(l,s),s=_d(s,l);var y=s==null?s:s[Mn(Et(l))];return y==null?t:At(y,s,h)}function Vh(s){return Xe(s)&&_t(s)==it}function M1(s){return Xe(s)&&_t(s)==er}function S1(s){return Xe(s)&&_t(s)==Re}function Yi(s,l,h,y,v){return s===l?!0:s==null||l==null||!Xe(s)&&!Xe(l)?s!==s&&l!==l:L1(s,l,h,y,Yi,v)}function L1(s,l,h,y,v,P){var T=he(s),W=he(l),F=T?dt:mt(s),B=W?dt:mt(l);F=F==it?Lt:F,B=B==it?Lt:B;var R=F==Lt,J=B==Lt,$=F==B;if($&&ur(s)){if(!ur(l))return!1;T=!0,R=!1}if($&&!R)return P||(P=new cn),T||ai(s)?hd(s,l,h,y,v,P):$1(s,l,F,h,y,v,P);if(!(h&w)){var te=R&&Te.call(s,"__wrapped__"),oe=J&&Te.call(l,"__wrapped__");if(te||oe){var me=te?s.value():s,ae=oe?l.value():l;return P||(P=new cn),v(me,ae,h,y,P)}}return $?(P||(P=new cn),q1(s,l,h,y,v,P)):!1}function P1(s){return Xe(s)&&mt(s)==Ce}function Qa(s,l,h,y){var v=h.length,P=v,T=!y;if(s==null)return!P;for(s=Ge(s);v--;){var W=h[v];if(T&&W[2]?W[1]!==s[W[0]]:!(W[0]in s))return!1}for(;++v<P;){W=h[v];var F=W[0],B=s[F],R=W[1];if(T&&W[2]){if(B===t&&!(F in s))return!1}else{var J=new cn;if(y)var $=y(B,R,F,s,l,J);if(!($===t?Yi(R,B,w|b,y,J):$))return!1}}return!0}function Ih(s){if(!Fe(s)||lx(s))return!1;var l=An(s)?Pb:gw;return l.test(Ar(s))}function C1(s){return Xe(s)&&_t(s)==br}function T1(s){return Xe(s)&&mt(s)==It}function G1(s){return Xe(s)&&mo(s.length)&&!!Ve[_t(s)]}function Ah(s){return typeof s=="function"?s:s==null?Gt:typeof s=="object"?he(s)?Dh(s[0],s[1]):Oh(s):nf(s)}function Ha(s){if(!Ji(s))return Vb(s);var l=[];for(var h in Ge(s))Te.call(s,h)&&h!="constructor"&&l.push(h);return l}function Z1(s){if(!Fe(s))return dx(s);var l=Ji(s),h=[];for(var y in s)y=="constructor"&&(l||!Te.call(s,y))||h.push(y);return h}function Ea(s,l){return s<l}function Fh(s,l){var h=-1,y=Ct(s)?U(s.length):[];return or(s,function(v,P,T){y[++h]=l(v,P,T)}),y}function Oh(s){var l=dl(s);return l.length==1&&l[0][2]?gd(l[0][0],l[0][1]):function(h){return h===s||Qa(h,s,l)}}function Dh(s,l){return pl(s)&&md(l)?gd(Mn(s),l):function(h){var y=Sl(h,s);return y===t&&y===l?Ll(h,s):Yi(l,y,w|b)}}function $s(s,l,h,y,v){s!==l&&Ya(l,function(P,T){if(v||(v=new cn),Fe(P))W1(s,l,T,h,$s,y,v);else{var W=y?y(gl(s,T),P,T+"",s,l,v):t;W===t&&(W=P),Na(s,T,W)}},Tt)}function W1(s,l,h,y,v,P,T){var W=gl(s,h),F=gl(l,h),B=T.get(F);if(B){Na(s,h,B);return}var R=P?P(W,F,h+"",s,l,T):t,J=R===t;if(J){var $=he(F),te=!$&&ur(F),oe=!$&&!te&&ai(F);R=F,$||te||oe?he(W)?R=W:ke(W)?R=Pt(W):te?(J=!1,R=Qh(F,!0)):oe?(J=!1,R=Hh(F,!0)):R=[]:Hi(F)||Fr(F)?(R=W,Fr(W)?R=Rd(W):(!Fe(W)||An(W))&&(R=pd(F))):J=!1}J&&(T.set(F,R),v(R,F,y,P,T),T.delete(F)),Na(s,h,R)}function zh(s,l){var h=s.length;if(h)return l+=l<0?h:0,In(l,h)?s[l]:t}function Xh(s,l,h){l.length?l=Ae(l,function(P){return he(P)?function(T){return Vr(T,P.length===1?P[0]:P)}:P}):l=[Gt];var y=-1;l=Ae(l,Ft(se()));var v=Fh(s,function(P,T,W){var F=Ae(l,function(B){return B(P)});return{criteria:F,index:++y,value:P}});return ib(v,function(P,T){return B1(P,T,h)})}function V1(s,l){return Uh(s,l,function(h,y){return Ll(s,y)})}function Uh(s,l,h){for(var y=-1,v=l.length,P={};++y<v;){var T=l[y],W=Vr(s,T);h(W,T)&&Ri(P,lr(T,s),W)}return P}function I1(s){return function(l){return Vr(l,s)}}function $a(s,l,h,y){var v=y?rb:Hr,P=-1,T=l.length,W=s;for(s===l&&(l=Pt(l)),h&&(W=Ae(s,Ft(h)));++P<T;)for(var F=0,B=l[P],R=h?h(B):B;(F=v(W,R,F,y))>-1;)W!==s&&Ks.call(W,F,1),Ks.call(s,F,1);return s}function kh(s,l){for(var h=s?l.length:0,y=h-1;h--;){var v=l[h];if(h==y||v!==P){var P=v;In(v)?Ks.call(s,v,1):nl(s,v)}}return s}function qa(s,l){return s+Ys(bh()*(l-s+1))}function A1(s,l,h,y){for(var v=-1,P=Je(Bs((l-s)/(h||1)),0),T=U(P);P--;)T[y?P:++v]=s,s+=h;return T}function el(s,l){var h="";if(!s||l<1||l>re)return h;do l%2&&(h+=s),l=Ys(l/2),l&&(s+=s);while(l);return h}function ye(s,l){return yl(yd(s,l,Gt),s+"")}function F1(s){return Sh(li(s))}function O1(s,l){var h=li(s);return lo(h,Wr(l,0,h.length))}function Ri(s,l,h,y){if(!Fe(s))return s;l=lr(l,s);for(var v=-1,P=l.length,T=P-1,W=s;W!=null&&++v<P;){var F=Mn(l[v]),B=h;if(F==="__proto__"||F==="constructor"||F==="prototype")return s;if(v!=T){var R=W[F];B=y?y(R,F,W):t,B===t&&(B=Fe(R)?R:In(l[v+1])?[]:{})}Ki(W,F,B),W=W[F]}return s}var Kh=Rs?function(s,l){return Rs.set(s,l),s}:Gt,D1=Ns?function(s,l){return Ns(s,"toString",{configurable:!0,enumerable:!1,value:Cl(l),writable:!0})}:Gt;function z1(s){return lo(li(s))}function Ht(s,l,h){var y=-1,v=s.length;l<0&&(l=-l>v?0:v+l),h=h>v?v:h,h<0&&(h+=v),v=l>h?0:h-l>>>0,l>>>=0;for(var P=U(v);++y<v;)P[y]=s[y+l];return P}function X1(s,l){var h;return or(s,function(y,v,P){return h=l(y,v,P),!h}),!!h}function qs(s,l,h){var y=0,v=s==null?y:s.length;if(typeof l=="number"&&l===l&&v<=Se){for(;y<v;){var P=y+v>>>1,T=s[P];T!==null&&!Dt(T)&&(h?T<=l:T<l)?y=P+1:v=P}return v}return tl(s,l,Gt,h)}function tl(s,l,h,y){var v=0,P=s==null?0:s.length;if(P===0)return 0;l=h(l);for(var T=l!==l,W=l===null,F=Dt(l),B=l===t;v<P;){var R=Ys((v+P)/2),J=h(s[R]),$=J!==t,te=J===null,oe=J===J,me=Dt(J);if(T)var ae=y||oe;else B?ae=oe&&(y||$):W?ae=oe&&$&&(y||!te):F?ae=oe&&$&&!te&&(y||!me):te||me?ae=!1:ae=y?J<=l:J<l;ae?v=R+1:P=R}return pt(P,fe)}function Nh(s,l){for(var h=-1,y=s.length,v=0,P=[];++h<y;){var T=s[h],W=l?l(T):T;if(!h||!un(W,F)){var F=W;P[v++]=T===0?0:T}}return P}function Bh(s){return typeof s=="number"?s:Dt(s)?de:+s}function Ot(s){if(typeof s=="string")return s;if(he(s))return Ae(s,Ot)+"";if(Dt(s))return xh?xh.call(s):"";var l=s+"";return l=="0"&&1/s==-ie?"-0":l}function ar(s,l,h){var y=-1,v=Vs,P=s.length,T=!0,W=[],F=W;if(h)T=!1,v=Za;else if(P>=r){var B=l?null:H1(s);if(B)return As(B);T=!1,v=Oi,F=new Zr}else F=l?[]:W;e:for(;++y<P;){var R=s[y],J=l?l(R):R;if(R=h||R!==0?R:0,T&&J===J){for(var $=F.length;$--;)if(F[$]===J)continue e;l&&F.push(J),W.push(R)}else v(F,J,h)||(F!==W&&F.push(J),W.push(R))}return W}function nl(s,l){return l=lr(l,s),s=_d(s,l),s==null||delete s[Mn(Et(l))]}function Yh(s,l,h,y){return Ri(s,l,h(Vr(s,l)),y)}function eo(s,l,h,y){for(var v=s.length,P=y?v:-1;(y?P--:++P<v)&&l(s[P],P,s););return h?Ht(s,y?0:P,y?P+1:v):Ht(s,y?P+1:0,y?v:P)}function Rh(s,l){var h=s;return h instanceof be&&(h=h.value()),Wa(l,function(y,v){return v.func.apply(v.thisArg,rr([y],v.args))},h)}function rl(s,l,h){var y=s.length;if(y<2)return y?ar(s[0]):[];for(var v=-1,P=U(y);++v<y;)for(var T=s[v],W=-1;++W<y;)W!=v&&(P[v]=Ni(P[v]||T,s[W],l,h));return ar(lt(P,1),l,h)}function jh(s,l,h){for(var y=-1,v=s.length,P=l.length,T={};++y<v;){var W=y<P?l[y]:t;h(T,s[y],W)}return T}function il(s){return ke(s)?s:[]}function sl(s){return typeof s=="function"?s:Gt}function lr(s,l){return he(s)?s:pl(s,l)?[s]:xd(Pe(s))}var U1=ye;function cr(s,l,h){var y=s.length;return h=h===t?y:h,!l&&h>=y?s:Ht(s,l,h)}var Jh=Cb||function(s){return at.clearTimeout(s)};function Qh(s,l){if(l)return s.slice();var h=s.length,y=gh?gh(h):new s.constructor(h);return s.copy(y),y}function ol(s){var l=new s.constructor(s.byteLength);return new Us(l).set(new Us(s)),l}function k1(s,l){var h=l?ol(s.buffer):s.buffer;return new s.constructor(h,s.byteOffset,s.byteLength)}function K1(s){var l=new s.constructor(s.source,Vu.exec(s));return l.lastIndex=s.lastIndex,l}function N1(s){return ki?Ge(ki.call(s)):{}}function Hh(s,l){var h=l?ol(s.buffer):s.buffer;return new s.constructor(h,s.byteOffset,s.length)}function Eh(s,l){if(s!==l){var h=s!==t,y=s===null,v=s===s,P=Dt(s),T=l!==t,W=l===null,F=l===l,B=Dt(l);if(!W&&!B&&!P&&s>l||P&&T&&F&&!W&&!B||y&&T&&F||!h&&F||!v)return 1;if(!y&&!P&&!B&&s<l||B&&h&&v&&!y&&!P||W&&h&&v||!T&&v||!F)return-1}return 0}function B1(s,l,h){for(var y=-1,v=s.criteria,P=l.criteria,T=v.length,W=h.length;++y<T;){var F=Eh(v[y],P[y]);if(F){if(y>=W)return F;var B=h[y];return F*(B=="desc"?-1:1)}}return s.index-l.index}function $h(s,l,h,y){for(var v=-1,P=s.length,T=h.length,W=-1,F=l.length,B=Je(P-T,0),R=U(F+B),J=!y;++W<F;)R[W]=l[W];for(;++v<T;)(J||v<P)&&(R[h[v]]=s[v]);for(;B--;)R[W++]=s[v++];return R}function qh(s,l,h,y){for(var v=-1,P=s.length,T=-1,W=h.length,F=-1,B=l.length,R=Je(P-W,0),J=U(R+B),$=!y;++v<R;)J[v]=s[v];for(var te=v;++F<B;)J[te+F]=l[F];for(;++T<W;)($||v<P)&&(J[te+h[T]]=s[v++]);return J}function Pt(s,l){var h=-1,y=s.length;for(l||(l=U(y));++h<y;)l[h]=s[h];return l}function xn(s,l,h,y){var v=!h;h||(h={});for(var P=-1,T=l.length;++P<T;){var W=l[P],F=y?y(h[W],s[W],W,h,s):t;F===t&&(F=s[W]),v?Zn(h,W,F):Ki(h,W,F)}return h}function Y1(s,l){return xn(s,fl(s),l)}function R1(s,l){return xn(s,dd(s),l)}function to(s,l){return function(h,y){var v=he(h)?Ew:p1,P=l?l():{};return v(h,s,se(y,2),P)}}function ii(s){return ye(function(l,h){var y=-1,v=h.length,P=v>1?h[v-1]:t,T=v>2?h[2]:t;for(P=s.length>3&&typeof P=="function"?(v--,P):t,T&&vt(h[0],h[1],T)&&(P=v<3?t:P,v=1),l=Ge(l);++y<v;){var W=h[y];W&&s(l,W,y,P)}return l})}function ed(s,l){return function(h,y){if(h==null)return h;if(!Ct(h))return s(h,y);for(var v=h.length,P=l?v:-1,T=Ge(h);(l?P--:++P<v)&&y(T[P],P,T)!==!1;);return h}}function td(s){return function(l,h,y){for(var v=-1,P=Ge(l),T=y(l),W=T.length;W--;){var F=T[s?W:++v];if(h(P[F],F,P)===!1)break}return l}}function j1(s,l,h){var y=l&x,v=ji(s);function P(){var T=this&&this!==at&&this instanceof P?v:s;return T.apply(y?h:this,arguments)}return P}function nd(s){return function(l){l=Pe(l);var h=Er(l)?ln(l):t,y=h?h[0]:l.charAt(0),v=h?cr(h,1).join(""):l.slice(1);return y[s]()+v}}function si(s){return function(l){return Wa(ef(qd(l).replace(Dw,"")),s,"")}}function ji(s){return function(){var l=arguments;switch(l.length){case 0:return new s;case 1:return new s(l[0]);case 2:return new s(l[0],l[1]);case 3:return new s(l[0],l[1],l[2]);case 4:return new s(l[0],l[1],l[2],l[3]);case 5:return new s(l[0],l[1],l[2],l[3],l[4]);case 6:return new s(l[0],l[1],l[2],l[3],l[4],l[5]);case 7:return new s(l[0],l[1],l[2],l[3],l[4],l[5],l[6])}var h=ri(s.prototype),y=s.apply(h,l);return Fe(y)?y:h}}function J1(s,l,h){var y=ji(s);function v(){for(var P=arguments.length,T=U(P),W=P,F=oi(v);W--;)T[W]=arguments[W];var B=P<3&&T[0]!==F&&T[P-1]!==F?[]:ir(T,F);if(P-=B.length,P<h)return ad(s,l,no,v.placeholder,t,T,B,t,t,h-P);var R=this&&this!==at&&this instanceof v?y:s;return At(R,this,T)}return v}function rd(s){return function(l,h,y){var v=Ge(l);if(!Ct(l)){var P=se(h,3);l=He(l),h=function(W){return P(v[W],W,v)}}var T=s(l,h,y);return T>-1?v[P?l[T]:T]:t}}function id(s){return Vn(function(l){var h=l.length,y=h,v=Jt.prototype.thru;for(s&&l.reverse();y--;){var P=l[y];if(typeof P!="function")throw new jt(a);if(v&&!T&&oo(P)=="wrapper")var T=new Jt([],!0)}for(y=T?y:h;++y<h;){P=l[y];var W=oo(P),F=W=="wrapper"?hl(P):t;F&&ml(F[0])&&F[1]==(X|C|z|I)&&!F[4].length&&F[9]==1?T=T[oo(F[0])].apply(T,F[3]):T=P.length==1&&ml(P)?T[W]():T.thru(P)}return function(){var B=arguments,R=B[0];if(T&&B.length==1&&he(R))return T.plant(R).value();for(var J=0,$=h?l[J].apply(this,B):R;++J<h;)$=l[J].call(this,$);return $}})}function no(s,l,h,y,v,P,T,W,F,B){var R=l&X,J=l&x,$=l&L,te=l&(C|Z),oe=l&K,me=$?t:ji(s);function ae(){for(var we=arguments.length,xe=U(we),zt=we;zt--;)xe[zt]=arguments[zt];if(te)var wt=oi(ae),Xt=ob(xe,wt);if(y&&(xe=$h(xe,y,v,te)),P&&(xe=qh(xe,P,T,te)),we-=Xt,te&&we<B){var Ke=ir(xe,wt);return ad(s,l,no,ae.placeholder,h,xe,Ke,W,F,B-we)}var hn=J?h:this,On=$?hn[s]:s;return we=xe.length,W?xe=px(xe,W):oe&&we>1&&xe.reverse(),R&&F<we&&(xe.length=F),this&&this!==at&&this instanceof ae&&(On=me||ji(On)),On.apply(hn,xe)}return ae}function sd(s,l){return function(h,y){return x1(h,s,l(y),{})}}function ro(s,l){return function(h,y){var v;if(h===t&&y===t)return l;if(h!==t&&(v=h),y!==t){if(v===t)return y;typeof h=="string"||typeof y=="string"?(h=Ot(h),y=Ot(y)):(h=Bh(h),y=Bh(y)),v=s(h,y)}return v}}function al(s){return Vn(function(l){return l=Ae(l,Ft(se())),ye(function(h){var y=this;return s(l,function(v){return At(v,y,h)})})})}function io(s,l){l=l===t?" ":Ot(l);var h=l.length;if(h<2)return h?el(l,s):l;var y=el(l,Bs(s/$r(l)));return Er(l)?cr(ln(y),0,s).join(""):y.slice(0,s)}function Q1(s,l,h,y){var v=l&x,P=ji(s);function T(){for(var W=-1,F=arguments.length,B=-1,R=y.length,J=U(R+F),$=this&&this!==at&&this instanceof T?P:s;++B<R;)J[B]=y[B];for(;F--;)J[B++]=arguments[++W];return At($,v?h:this,J)}return T}function od(s){return function(l,h,y){return y&&typeof y!="number"&&vt(l,h,y)&&(h=y=t),l=Fn(l),h===t?(h=l,l=0):h=Fn(h),y=y===t?l<h?1:-1:Fn(y),A1(l,h,y,s)}}function so(s){return function(l,h){return typeof l=="string"&&typeof h=="string"||(l=$t(l),h=$t(h)),s(l,h)}}function ad(s,l,h,y,v,P,T,W,F,B){var R=l&C,J=R?T:t,$=R?t:T,te=R?P:t,oe=R?t:P;l|=R?z:D,l&=~(R?D:z),l&M||(l&=-4);var me=[s,l,v,te,J,oe,$,W,F,B],ae=h.apply(t,me);return ml(s)&&vd(ae,me),ae.placeholder=y,wd(ae,s,l)}function ll(s){var l=je[s];return function(h,y){if(h=$t(h),y=y==null?0:pt(pe(y),292),y&&wh(h)){var v=(Pe(h)+"e").split("e"),P=l(v[0]+"e"+(+v[1]+y));return v=(Pe(P)+"e").split("e"),+(v[0]+"e"+(+v[1]-y))}return l(h)}}var H1=ti&&1/As(new ti([,-0]))[1]==ie?function(s){return new ti(s)}:Zl;function ld(s){return function(l){var h=mt(l);return h==Ce?za(l):h==It?fb(l):sb(l,s(l))}}function Wn(s,l,h,y,v,P,T,W){var F=l&L;if(!F&&typeof s!="function")throw new jt(a);var B=y?y.length:0;if(B||(l&=-97,y=v=t),T=T===t?T:Je(pe(T),0),W=W===t?W:pe(W),B-=v?v.length:0,l&D){var R=y,J=v;y=v=t}var $=F?t:hl(s),te=[s,l,h,y,v,R,J,P,T,W];if($&&hx(te,$),s=te[0],l=te[1],h=te[2],y=te[3],v=te[4],W=te[9]=te[9]===t?F?0:s.length:Je(te[9]-B,0),!W&&l&(C|Z)&&(l&=-25),!l||l==x)var oe=j1(s,l,h);else l==C||l==Z?oe=J1(s,l,W):(l==z||l==(x|z))&&!v.length?oe=Q1(s,l,h,y):oe=no.apply(t,te);var me=$?Kh:vd;return wd(me(oe,te),s,l)}function cd(s,l,h,y){return s===t||un(s,ei[h])&&!Te.call(y,h)?l:s}function ud(s,l,h,y,v,P){return Fe(s)&&Fe(l)&&(P.set(l,s),$s(s,l,t,ud,P),P.delete(l)),s}function E1(s){return Hi(s)?t:s}function hd(s,l,h,y,v,P){var T=h&w,W=s.length,F=l.length;if(W!=F&&!(T&&F>W))return!1;var B=P.get(s),R=P.get(l);if(B&&R)return B==l&&R==s;var J=-1,$=!0,te=h&b?new Zr:t;for(P.set(s,l),P.set(l,s);++J<W;){var oe=s[J],me=l[J];if(y)var ae=T?y(me,oe,J,l,s,P):y(oe,me,J,s,l,P);if(ae!==t){if(ae)continue;$=!1;break}if(te){if(!Va(l,function(we,xe){if(!Oi(te,xe)&&(oe===we||v(oe,we,h,y,P)))return te.push(xe)})){$=!1;break}}else if(!(oe===me||v(oe,me,h,y,P))){$=!1;break}}return P.delete(s),P.delete(l),$}function $1(s,l,h,y,v,P,T){switch(h){case wn:if(s.byteLength!=l.byteLength||s.byteOffset!=l.byteOffset)return!1;s=s.buffer,l=l.buffer;case er:return!(s.byteLength!=l.byteLength||!P(new Us(s),new Us(l)));case Ye:case Re:case ot:return un(+s,+l);case ze:return s.name==l.name&&s.message==l.message;case br:case $n:return s==l+"";case Ce:var W=za;case It:var F=y&w;if(W||(W=As),s.size!=l.size&&!F)return!1;var B=T.get(s);if(B)return B==l;y|=b,T.set(s,l);var R=hd(W(s),W(l),y,v,P,T);return T.delete(s),R;case qn:if(ki)return ki.call(s)==ki.call(l)}return!1}function q1(s,l,h,y,v,P){var T=h&w,W=cl(s),F=W.length,B=cl(l),R=B.length;if(F!=R&&!T)return!1;for(var J=F;J--;){var $=W[J];if(!(T?$ in l:Te.call(l,$)))return!1}var te=P.get(s),oe=P.get(l);if(te&&oe)return te==l&&oe==s;var me=!0;P.set(s,l),P.set(l,s);for(var ae=T;++J<F;){$=W[J];var we=s[$],xe=l[$];if(y)var zt=T?y(xe,we,$,l,s,P):y(we,xe,$,s,l,P);if(!(zt===t?we===xe||v(we,xe,h,y,P):zt)){me=!1;break}ae||(ae=$=="constructor")}if(me&&!ae){var wt=s.constructor,Xt=l.constructor;wt!=Xt&&"constructor"in s&&"constructor"in l&&!(typeof wt=="function"&&wt instanceof wt&&typeof Xt=="function"&&Xt instanceof Xt)&&(me=!1)}return P.delete(s),P.delete(l),me}function Vn(s){return yl(yd(s,t,Pd),s+"")}function cl(s){return Wh(s,He,fl)}function ul(s){return Wh(s,Tt,dd)}var hl=Rs?function(s){return Rs.get(s)}:Zl;function oo(s){for(var l=s.name+"",h=ni[l],y=Te.call(ni,l)?h.length:0;y--;){var v=h[y],P=v.func;if(P==null||P==s)return v.name}return l}function oi(s){var l=Te.call(S,"placeholder")?S:s;return l.placeholder}function se(){var s=S.iteratee||Tl;return s=s===Tl?Ah:s,arguments.length?s(arguments[0],arguments[1]):s}function ao(s,l){var h=s.__data__;return ax(l)?h[typeof l=="string"?"string":"hash"]:h.map}function dl(s){for(var l=He(s),h=l.length;h--;){var y=l[h],v=s[y];l[h]=[y,v,md(v)]}return l}function Ir(s,l){var h=ub(s,l);return Ih(h)?h:t}function ex(s){var l=Te.call(s,Tr),h=s[Tr];try{s[Tr]=t;var y=!0}catch{}var v=zs.call(s);return y&&(l?s[Tr]=h:delete s[Tr]),v}var fl=Ua?function(s){return s==null?[]:(s=Ge(s),nr(Ua(s),function(l){return _h.call(s,l)}))}:Wl,dd=Ua?function(s){for(var l=[];s;)rr(l,fl(s)),s=ks(s);return l}:Wl,mt=_t;(ka&&mt(new ka(new ArrayBuffer(1)))!=wn||zi&&mt(new zi)!=Ce||Ka&&mt(Ka.resolve())!=wr||ti&&mt(new ti)!=It||Xi&&mt(new Xi)!=Mr)&&(mt=function(s){var l=_t(s),h=l==Lt?s.constructor:t,y=h?Ar(h):"";if(y)switch(y){case Ob:return wn;case Db:return Ce;case zb:return wr;case Xb:return It;case Ub:return Mr}return l});function tx(s,l,h){for(var y=-1,v=h.length;++y<v;){var P=h[y],T=P.size;switch(P.type){case"drop":s+=T;break;case"dropRight":l-=T;break;case"take":l=pt(l,s+T);break;case"takeRight":s=Je(s,l-T);break}}return{start:s,end:l}}function nx(s){var l=s.match(lw);return l?l[1].split(cw):[]}function fd(s,l,h){l=lr(l,s);for(var y=-1,v=l.length,P=!1;++y<v;){var T=Mn(l[y]);if(!(P=s!=null&&h(s,T)))break;s=s[T]}return P||++y!=v?P:(v=s==null?0:s.length,!!v&&mo(v)&&In(T,v)&&(he(s)||Fr(s)))}function rx(s){var l=s.length,h=new s.constructor(l);return l&&typeof s[0]=="string"&&Te.call(s,"index")&&(h.index=s.index,h.input=s.input),h}function pd(s){return typeof s.constructor=="function"&&!Ji(s)?ri(ks(s)):{}}function ix(s,l,h){var y=s.constructor;switch(l){case er:return ol(s);case Ye:case Re:return new y(+s);case wn:return k1(s,h);case Vi:case Ii:case Rr:case Ai:case Fi:case jr:case Sr:case O:case E:return Hh(s,h);case Ce:return new y;case ot:case $n:return new y(s);case br:return K1(s);case It:return new y;case qn:return N1(s)}}function sx(s,l){var h=l.length;if(!h)return s;var y=h-1;return l[y]=(h>1?"& ":"")+l[y],l=l.join(h>2?", ":" "),s.replace(aw,`{
759
+ /* [wrapped with `+l+`] */
760
+ `)}function ox(s){return he(s)||Fr(s)||!!(vh&&s&&s[vh])}function In(s,l){var h=typeof s;return l=l??re,!!l&&(h=="number"||h!="symbol"&&_w.test(s))&&s>-1&&s%1==0&&s<l}function vt(s,l,h){if(!Fe(h))return!1;var y=typeof l;return(y=="number"?Ct(h)&&In(l,h.length):y=="string"&&l in h)?un(h[l],s):!1}function pl(s,l){if(he(s))return!1;var h=typeof s;return h=="number"||h=="symbol"||h=="boolean"||s==null||Dt(s)?!0:Pr.test(s)||!Lr.test(s)||l!=null&&s in Ge(l)}function ax(s){var l=typeof s;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?s!=="__proto__":s===null}function ml(s){var l=oo(s),h=S[l];if(typeof h!="function"||!(l in be.prototype))return!1;if(s===h)return!0;var y=hl(h);return!!y&&s===y[0]}function lx(s){return!!mh&&mh in s}var cx=Os?An:Vl;function Ji(s){var l=s&&s.constructor,h=typeof l=="function"&&l.prototype||ei;return s===h}function md(s){return s===s&&!Fe(s)}function gd(s,l){return function(h){return h==null?!1:h[s]===l&&(l!==t||s in Ge(h))}}function ux(s){var l=fo(s,function(y){return h.size===d&&h.clear(),y}),h=l.cache;return l}function hx(s,l){var h=s[1],y=l[1],v=h|y,P=v<(x|L|X),T=y==X&&h==C||y==X&&h==I&&s[7].length<=l[8]||y==(X|I)&&l[7].length<=l[8]&&h==C;if(!(P||T))return s;y&x&&(s[2]=l[2],v|=h&x?0:M);var W=l[3];if(W){var F=s[3];s[3]=F?$h(F,W,l[4]):W,s[4]=F?ir(s[3],m):l[4]}return W=l[5],W&&(F=s[5],s[5]=F?qh(F,W,l[6]):W,s[6]=F?ir(s[5],m):l[6]),W=l[7],W&&(s[7]=W),y&X&&(s[8]=s[8]==null?l[8]:pt(s[8],l[8])),s[9]==null&&(s[9]=l[9]),s[0]=l[0],s[1]=v,s}function dx(s){var l=[];if(s!=null)for(var h in Ge(s))l.push(h);return l}function fx(s){return zs.call(s)}function yd(s,l,h){return l=Je(l===t?s.length-1:l,0),function(){for(var y=arguments,v=-1,P=Je(y.length-l,0),T=U(P);++v<P;)T[v]=y[l+v];v=-1;for(var W=U(l+1);++v<l;)W[v]=y[v];return W[l]=h(T),At(s,this,W)}}function _d(s,l){return l.length<2?s:Vr(s,Ht(l,0,-1))}function px(s,l){for(var h=s.length,y=pt(l.length,h),v=Pt(s);y--;){var P=l[y];s[y]=In(P,h)?v[P]:t}return s}function gl(s,l){if(!(l==="constructor"&&typeof s[l]=="function")&&l!="__proto__")return s[l]}var vd=bd(Kh),Qi=Gb||function(s,l){return at.setTimeout(s,l)},yl=bd(D1);function wd(s,l,h){var y=l+"";return yl(s,sx(y,mx(nx(y),h)))}function bd(s){var l=0,h=0;return function(){var y=Ib(),v=j-(y-h);if(h=y,v>0){if(++l>=k)return arguments[0]}else l=0;return s.apply(t,arguments)}}function lo(s,l){var h=-1,y=s.length,v=y-1;for(l=l===t?y:l;++h<l;){var P=qa(h,v),T=s[P];s[P]=s[h],s[h]=T}return s.length=l,s}var xd=ux(function(s){var l=[];return s.charCodeAt(0)===46&&l.push(""),s.replace(Jr,function(h,y,v,P){l.push(v?P.replace(dw,"$1"):y||h)}),l});function Mn(s){if(typeof s=="string"||Dt(s))return s;var l=s+"";return l=="0"&&1/s==-ie?"-0":l}function Ar(s){if(s!=null){try{return Ds.call(s)}catch{}try{return s+""}catch{}}return""}function mx(s,l){return Rt(rt,function(h){var y="_."+h[0];l&h[1]&&!Vs(s,y)&&s.push(y)}),s.sort()}function Md(s){if(s instanceof be)return s.clone();var l=new Jt(s.__wrapped__,s.__chain__);return l.__actions__=Pt(s.__actions__),l.__index__=s.__index__,l.__values__=s.__values__,l}function gx(s,l,h){(h?vt(s,l,h):l===t)?l=1:l=Je(pe(l),0);var y=s==null?0:s.length;if(!y||l<1)return[];for(var v=0,P=0,T=U(Bs(y/l));v<y;)T[P++]=Ht(s,v,v+=l);return T}function yx(s){for(var l=-1,h=s==null?0:s.length,y=0,v=[];++l<h;){var P=s[l];P&&(v[y++]=P)}return v}function _x(){var s=arguments.length;if(!s)return[];for(var l=U(s-1),h=arguments[0],y=s;y--;)l[y-1]=arguments[y];return rr(he(h)?Pt(h):[h],lt(l,1))}var vx=ye(function(s,l){return ke(s)?Ni(s,lt(l,1,ke,!0)):[]}),wx=ye(function(s,l){var h=Et(l);return ke(h)&&(h=t),ke(s)?Ni(s,lt(l,1,ke,!0),se(h,2)):[]}),bx=ye(function(s,l){var h=Et(l);return ke(h)&&(h=t),ke(s)?Ni(s,lt(l,1,ke,!0),t,h):[]});function xx(s,l,h){var y=s==null?0:s.length;return y?(l=h||l===t?1:pe(l),Ht(s,l<0?0:l,y)):[]}function Mx(s,l,h){var y=s==null?0:s.length;return y?(l=h||l===t?1:pe(l),l=y-l,Ht(s,0,l<0?0:l)):[]}function Sx(s,l){return s&&s.length?eo(s,se(l,3),!0,!0):[]}function Lx(s,l){return s&&s.length?eo(s,se(l,3),!0):[]}function Px(s,l,h,y){var v=s==null?0:s.length;return v?(h&&typeof h!="number"&&vt(s,l,h)&&(h=0,y=v),_1(s,l,h,y)):[]}function Sd(s,l,h){var y=s==null?0:s.length;if(!y)return-1;var v=h==null?0:pe(h);return v<0&&(v=Je(y+v,0)),Is(s,se(l,3),v)}function Ld(s,l,h){var y=s==null?0:s.length;if(!y)return-1;var v=y-1;return h!==t&&(v=pe(h),v=h<0?Je(y+v,0):pt(v,y-1)),Is(s,se(l,3),v,!0)}function Pd(s){var l=s==null?0:s.length;return l?lt(s,1):[]}function Cx(s){var l=s==null?0:s.length;return l?lt(s,ie):[]}function Tx(s,l){var h=s==null?0:s.length;return h?(l=l===t?1:pe(l),lt(s,l)):[]}function Gx(s){for(var l=-1,h=s==null?0:s.length,y={};++l<h;){var v=s[l];y[v[0]]=v[1]}return y}function Cd(s){return s&&s.length?s[0]:t}function Zx(s,l,h){var y=s==null?0:s.length;if(!y)return-1;var v=h==null?0:pe(h);return v<0&&(v=Je(y+v,0)),Hr(s,l,v)}function Wx(s){var l=s==null?0:s.length;return l?Ht(s,0,-1):[]}var Vx=ye(function(s){var l=Ae(s,il);return l.length&&l[0]===s[0]?Ja(l):[]}),Ix=ye(function(s){var l=Et(s),h=Ae(s,il);return l===Et(h)?l=t:h.pop(),h.length&&h[0]===s[0]?Ja(h,se(l,2)):[]}),Ax=ye(function(s){var l=Et(s),h=Ae(s,il);return l=typeof l=="function"?l:t,l&&h.pop(),h.length&&h[0]===s[0]?Ja(h,t,l):[]});function Fx(s,l){return s==null?"":Wb.call(s,l)}function Et(s){var l=s==null?0:s.length;return l?s[l-1]:t}function Ox(s,l,h){var y=s==null?0:s.length;if(!y)return-1;var v=y;return h!==t&&(v=pe(h),v=v<0?Je(y+v,0):pt(v,y-1)),l===l?mb(s,l,v):Is(s,ah,v,!0)}function Dx(s,l){return s&&s.length?zh(s,pe(l)):t}var zx=ye(Td);function Td(s,l){return s&&s.length&&l&&l.length?$a(s,l):s}function Xx(s,l,h){return s&&s.length&&l&&l.length?$a(s,l,se(h,2)):s}function Ux(s,l,h){return s&&s.length&&l&&l.length?$a(s,l,t,h):s}var kx=Vn(function(s,l){var h=s==null?0:s.length,y=Ba(s,l);return kh(s,Ae(l,function(v){return In(v,h)?+v:v}).sort(Eh)),y});function Kx(s,l){var h=[];if(!(s&&s.length))return h;var y=-1,v=[],P=s.length;for(l=se(l,3);++y<P;){var T=s[y];l(T,y,s)&&(h.push(T),v.push(y))}return kh(s,v),h}function _l(s){return s==null?s:Fb.call(s)}function Nx(s,l,h){var y=s==null?0:s.length;return y?(h&&typeof h!="number"&&vt(s,l,h)?(l=0,h=y):(l=l==null?0:pe(l),h=h===t?y:pe(h)),Ht(s,l,h)):[]}function Bx(s,l){return qs(s,l)}function Yx(s,l,h){return tl(s,l,se(h,2))}function Rx(s,l){var h=s==null?0:s.length;if(h){var y=qs(s,l);if(y<h&&un(s[y],l))return y}return-1}function jx(s,l){return qs(s,l,!0)}function Jx(s,l,h){return tl(s,l,se(h,2),!0)}function Qx(s,l){var h=s==null?0:s.length;if(h){var y=qs(s,l,!0)-1;if(un(s[y],l))return y}return-1}function Hx(s){return s&&s.length?Nh(s):[]}function Ex(s,l){return s&&s.length?Nh(s,se(l,2)):[]}function $x(s){var l=s==null?0:s.length;return l?Ht(s,1,l):[]}function qx(s,l,h){return s&&s.length?(l=h||l===t?1:pe(l),Ht(s,0,l<0?0:l)):[]}function eM(s,l,h){var y=s==null?0:s.length;return y?(l=h||l===t?1:pe(l),l=y-l,Ht(s,l<0?0:l,y)):[]}function tM(s,l){return s&&s.length?eo(s,se(l,3),!1,!0):[]}function nM(s,l){return s&&s.length?eo(s,se(l,3)):[]}var rM=ye(function(s){return ar(lt(s,1,ke,!0))}),iM=ye(function(s){var l=Et(s);return ke(l)&&(l=t),ar(lt(s,1,ke,!0),se(l,2))}),sM=ye(function(s){var l=Et(s);return l=typeof l=="function"?l:t,ar(lt(s,1,ke,!0),t,l)});function oM(s){return s&&s.length?ar(s):[]}function aM(s,l){return s&&s.length?ar(s,se(l,2)):[]}function lM(s,l){return l=typeof l=="function"?l:t,s&&s.length?ar(s,t,l):[]}function vl(s){if(!(s&&s.length))return[];var l=0;return s=nr(s,function(h){if(ke(h))return l=Je(h.length,l),!0}),Oa(l,function(h){return Ae(s,Ia(h))})}function Gd(s,l){if(!(s&&s.length))return[];var h=vl(s);return l==null?h:Ae(h,function(y){return At(l,t,y)})}var cM=ye(function(s,l){return ke(s)?Ni(s,l):[]}),uM=ye(function(s){return rl(nr(s,ke))}),hM=ye(function(s){var l=Et(s);return ke(l)&&(l=t),rl(nr(s,ke),se(l,2))}),dM=ye(function(s){var l=Et(s);return l=typeof l=="function"?l:t,rl(nr(s,ke),t,l)}),fM=ye(vl);function pM(s,l){return jh(s||[],l||[],Ki)}function mM(s,l){return jh(s||[],l||[],Ri)}var gM=ye(function(s){var l=s.length,h=l>1?s[l-1]:t;return h=typeof h=="function"?(s.pop(),h):t,Gd(s,h)});function Zd(s){var l=S(s);return l.__chain__=!0,l}function yM(s,l){return l(s),s}function co(s,l){return l(s)}var _M=Vn(function(s){var l=s.length,h=l?s[0]:0,y=this.__wrapped__,v=function(P){return Ba(P,s)};return l>1||this.__actions__.length||!(y instanceof be)||!In(h)?this.thru(v):(y=y.slice(h,+h+(l?1:0)),y.__actions__.push({func:co,args:[v],thisArg:t}),new Jt(y,this.__chain__).thru(function(P){return l&&!P.length&&P.push(t),P}))});function vM(){return Zd(this)}function wM(){return new Jt(this.value(),this.__chain__)}function bM(){this.__values__===t&&(this.__values__=Bd(this.value()));var s=this.__index__>=this.__values__.length,l=s?t:this.__values__[this.__index__++];return{done:s,value:l}}function xM(){return this}function MM(s){for(var l,h=this;h instanceof Js;){var y=Md(h);y.__index__=0,y.__values__=t,l?v.__wrapped__=y:l=y;var v=y;h=h.__wrapped__}return v.__wrapped__=s,l}function SM(){var s=this.__wrapped__;if(s instanceof be){var l=s;return this.__actions__.length&&(l=new be(this)),l=l.reverse(),l.__actions__.push({func:co,args:[_l],thisArg:t}),new Jt(l,this.__chain__)}return this.thru(_l)}function LM(){return Rh(this.__wrapped__,this.__actions__)}var PM=to(function(s,l,h){Te.call(s,h)?++s[h]:Zn(s,h,1)});function CM(s,l,h){var y=he(s)?sh:y1;return h&&vt(s,l,h)&&(l=t),y(s,se(l,3))}function TM(s,l){var h=he(s)?nr:Gh;return h(s,se(l,3))}var GM=rd(Sd),ZM=rd(Ld);function WM(s,l){return lt(uo(s,l),1)}function VM(s,l){return lt(uo(s,l),ie)}function IM(s,l,h){return h=h===t?1:pe(h),lt(uo(s,l),h)}function Wd(s,l){var h=he(s)?Rt:or;return h(s,se(l,3))}function Vd(s,l){var h=he(s)?$w:Th;return h(s,se(l,3))}var AM=to(function(s,l,h){Te.call(s,h)?s[h].push(l):Zn(s,h,[l])});function FM(s,l,h,y){s=Ct(s)?s:li(s),h=h&&!y?pe(h):0;var v=s.length;return h<0&&(h=Je(v+h,0)),go(s)?h<=v&&s.indexOf(l,h)>-1:!!v&&Hr(s,l,h)>-1}var OM=ye(function(s,l,h){var y=-1,v=typeof l=="function",P=Ct(s)?U(s.length):[];return or(s,function(T){P[++y]=v?At(l,T,h):Bi(T,l,h)}),P}),DM=to(function(s,l,h){Zn(s,h,l)});function uo(s,l){var h=he(s)?Ae:Fh;return h(s,se(l,3))}function zM(s,l,h,y){return s==null?[]:(he(l)||(l=l==null?[]:[l]),h=y?t:h,he(h)||(h=h==null?[]:[h]),Xh(s,l,h))}var XM=to(function(s,l,h){s[h?0:1].push(l)},function(){return[[],[]]});function UM(s,l,h){var y=he(s)?Wa:ch,v=arguments.length<3;return y(s,se(l,4),h,v,or)}function kM(s,l,h){var y=he(s)?qw:ch,v=arguments.length<3;return y(s,se(l,4),h,v,Th)}function KM(s,l){var h=he(s)?nr:Gh;return h(s,po(se(l,3)))}function NM(s){var l=he(s)?Sh:F1;return l(s)}function BM(s,l,h){(h?vt(s,l,h):l===t)?l=1:l=pe(l);var y=he(s)?d1:O1;return y(s,l)}function YM(s){var l=he(s)?f1:z1;return l(s)}function RM(s){if(s==null)return 0;if(Ct(s))return go(s)?$r(s):s.length;var l=mt(s);return l==Ce||l==It?s.size:Ha(s).length}function jM(s,l,h){var y=he(s)?Va:X1;return h&&vt(s,l,h)&&(l=t),y(s,se(l,3))}var JM=ye(function(s,l){if(s==null)return[];var h=l.length;return h>1&&vt(s,l[0],l[1])?l=[]:h>2&&vt(l[0],l[1],l[2])&&(l=[l[0]]),Xh(s,lt(l,1),[])}),ho=Tb||function(){return at.Date.now()};function QM(s,l){if(typeof l!="function")throw new jt(a);return s=pe(s),function(){if(--s<1)return l.apply(this,arguments)}}function Id(s,l,h){return l=h?t:l,l=s&&l==null?s.length:l,Wn(s,X,t,t,t,t,l)}function Ad(s,l){var h;if(typeof l!="function")throw new jt(a);return s=pe(s),function(){return--s>0&&(h=l.apply(this,arguments)),s<=1&&(l=t),h}}var wl=ye(function(s,l,h){var y=x;if(h.length){var v=ir(h,oi(wl));y|=z}return Wn(s,y,l,h,v)}),Fd=ye(function(s,l,h){var y=x|L;if(h.length){var v=ir(h,oi(Fd));y|=z}return Wn(l,y,s,h,v)});function Od(s,l,h){l=h?t:l;var y=Wn(s,C,t,t,t,t,t,l);return y.placeholder=Od.placeholder,y}function Dd(s,l,h){l=h?t:l;var y=Wn(s,Z,t,t,t,t,t,l);return y.placeholder=Dd.placeholder,y}function zd(s,l,h){var y,v,P,T,W,F,B=0,R=!1,J=!1,$=!0;if(typeof s!="function")throw new jt(a);l=$t(l)||0,Fe(h)&&(R=!!h.leading,J="maxWait"in h,P=J?Je($t(h.maxWait)||0,l):P,$="trailing"in h?!!h.trailing:$);function te(Ke){var hn=y,On=v;return y=v=t,B=Ke,T=s.apply(On,hn),T}function oe(Ke){return B=Ke,W=Qi(we,l),R?te(Ke):T}function me(Ke){var hn=Ke-F,On=Ke-B,rf=l-hn;return J?pt(rf,P-On):rf}function ae(Ke){var hn=Ke-F,On=Ke-B;return F===t||hn>=l||hn<0||J&&On>=P}function we(){var Ke=ho();if(ae(Ke))return xe(Ke);W=Qi(we,me(Ke))}function xe(Ke){return W=t,$&&y?te(Ke):(y=v=t,T)}function zt(){W!==t&&Jh(W),B=0,y=F=v=W=t}function wt(){return W===t?T:xe(ho())}function Xt(){var Ke=ho(),hn=ae(Ke);if(y=arguments,v=this,F=Ke,hn){if(W===t)return oe(F);if(J)return Jh(W),W=Qi(we,l),te(F)}return W===t&&(W=Qi(we,l)),T}return Xt.cancel=zt,Xt.flush=wt,Xt}var HM=ye(function(s,l){return Ch(s,1,l)}),EM=ye(function(s,l,h){return Ch(s,$t(l)||0,h)});function $M(s){return Wn(s,K)}function fo(s,l){if(typeof s!="function"||l!=null&&typeof l!="function")throw new jt(a);var h=function(){var y=arguments,v=l?l.apply(this,y):y[0],P=h.cache;if(P.has(v))return P.get(v);var T=s.apply(this,y);return h.cache=P.set(v,T)||P,T};return h.cache=new(fo.Cache||Gn),h}fo.Cache=Gn;function po(s){if(typeof s!="function")throw new jt(a);return function(){var l=arguments;switch(l.length){case 0:return!s.call(this);case 1:return!s.call(this,l[0]);case 2:return!s.call(this,l[0],l[1]);case 3:return!s.call(this,l[0],l[1],l[2])}return!s.apply(this,l)}}function qM(s){return Ad(2,s)}var eS=U1(function(s,l){l=l.length==1&&he(l[0])?Ae(l[0],Ft(se())):Ae(lt(l,1),Ft(se()));var h=l.length;return ye(function(y){for(var v=-1,P=pt(y.length,h);++v<P;)y[v]=l[v].call(this,y[v]);return At(s,this,y)})}),bl=ye(function(s,l){var h=ir(l,oi(bl));return Wn(s,z,t,l,h)}),Xd=ye(function(s,l){var h=ir(l,oi(Xd));return Wn(s,D,t,l,h)}),tS=Vn(function(s,l){return Wn(s,I,t,t,t,l)});function nS(s,l){if(typeof s!="function")throw new jt(a);return l=l===t?l:pe(l),ye(s,l)}function rS(s,l){if(typeof s!="function")throw new jt(a);return l=l==null?0:Je(pe(l),0),ye(function(h){var y=h[l],v=cr(h,0,l);return y&&rr(v,y),At(s,this,v)})}function iS(s,l,h){var y=!0,v=!0;if(typeof s!="function")throw new jt(a);return Fe(h)&&(y="leading"in h?!!h.leading:y,v="trailing"in h?!!h.trailing:v),zd(s,l,{leading:y,maxWait:l,trailing:v})}function sS(s){return Id(s,1)}function oS(s,l){return bl(sl(l),s)}function aS(){if(!arguments.length)return[];var s=arguments[0];return he(s)?s:[s]}function lS(s){return Qt(s,_)}function cS(s,l){return l=typeof l=="function"?l:t,Qt(s,_,l)}function uS(s){return Qt(s,f|_)}function hS(s,l){return l=typeof l=="function"?l:t,Qt(s,f|_,l)}function dS(s,l){return l==null||Ph(s,l,He(l))}function un(s,l){return s===l||s!==s&&l!==l}var fS=so(ja),pS=so(function(s,l){return s>=l}),Fr=Vh(function(){return arguments}())?Vh:function(s){return Xe(s)&&Te.call(s,"callee")&&!_h.call(s,"callee")},he=U.isArray,mS=qu?Ft(qu):M1;function Ct(s){return s!=null&&mo(s.length)&&!An(s)}function ke(s){return Xe(s)&&Ct(s)}function gS(s){return s===!0||s===!1||Xe(s)&&_t(s)==Ye}var ur=Zb||Vl,yS=eh?Ft(eh):S1;function _S(s){return Xe(s)&&s.nodeType===1&&!Hi(s)}function vS(s){if(s==null)return!0;if(Ct(s)&&(he(s)||typeof s=="string"||typeof s.splice=="function"||ur(s)||ai(s)||Fr(s)))return!s.length;var l=mt(s);if(l==Ce||l==It)return!s.size;if(Ji(s))return!Ha(s).length;for(var h in s)if(Te.call(s,h))return!1;return!0}function wS(s,l){return Yi(s,l)}function bS(s,l,h){h=typeof h=="function"?h:t;var y=h?h(s,l):t;return y===t?Yi(s,l,t,h):!!y}function xl(s){if(!Xe(s))return!1;var l=_t(s);return l==ze||l==st||typeof s.message=="string"&&typeof s.name=="string"&&!Hi(s)}function xS(s){return typeof s=="number"&&wh(s)}function An(s){if(!Fe(s))return!1;var l=_t(s);return l==Vt||l==Nt||l==Qe||l==Yr}function Ud(s){return typeof s=="number"&&s==pe(s)}function mo(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=re}function Fe(s){var l=typeof s;return s!=null&&(l=="object"||l=="function")}function Xe(s){return s!=null&&typeof s=="object"}var kd=th?Ft(th):P1;function MS(s,l){return s===l||Qa(s,l,dl(l))}function SS(s,l,h){return h=typeof h=="function"?h:t,Qa(s,l,dl(l),h)}function LS(s){return Kd(s)&&s!=+s}function PS(s){if(cx(s))throw new ue(o);return Ih(s)}function CS(s){return s===null}function TS(s){return s==null}function Kd(s){return typeof s=="number"||Xe(s)&&_t(s)==ot}function Hi(s){if(!Xe(s)||_t(s)!=Lt)return!1;var l=ks(s);if(l===null)return!0;var h=Te.call(l,"constructor")&&l.constructor;return typeof h=="function"&&h instanceof h&&Ds.call(h)==Sb}var Ml=nh?Ft(nh):C1;function GS(s){return Ud(s)&&s>=-re&&s<=re}var Nd=rh?Ft(rh):T1;function go(s){return typeof s=="string"||!he(s)&&Xe(s)&&_t(s)==$n}function Dt(s){return typeof s=="symbol"||Xe(s)&&_t(s)==qn}var ai=ih?Ft(ih):G1;function ZS(s){return s===t}function WS(s){return Xe(s)&&mt(s)==Mr}function VS(s){return Xe(s)&&_t(s)==wa}var IS=so(Ea),AS=so(function(s,l){return s<=l});function Bd(s){if(!s)return[];if(Ct(s))return go(s)?ln(s):Pt(s);if(Di&&s[Di])return db(s[Di]());var l=mt(s),h=l==Ce?za:l==It?As:li;return h(s)}function Fn(s){if(!s)return s===0?s:0;if(s=$t(s),s===ie||s===-ie){var l=s<0?-1:1;return l*le}return s===s?s:0}function pe(s){var l=Fn(s),h=l%1;return l===l?h?l-h:l:0}function Yd(s){return s?Wr(pe(s),0,ge):0}function $t(s){if(typeof s=="number")return s;if(Dt(s))return de;if(Fe(s)){var l=typeof s.valueOf=="function"?s.valueOf():s;s=Fe(l)?l+"":l}if(typeof s!="string")return s===0?s:+s;s=uh(s);var h=mw.test(s);return h||yw.test(s)?Qw(s.slice(2),h?2:8):pw.test(s)?de:+s}function Rd(s){return xn(s,Tt(s))}function FS(s){return s?Wr(pe(s),-re,re):s===0?s:0}function Pe(s){return s==null?"":Ot(s)}var OS=ii(function(s,l){if(Ji(l)||Ct(l)){xn(l,He(l),s);return}for(var h in l)Te.call(l,h)&&Ki(s,h,l[h])}),jd=ii(function(s,l){xn(l,Tt(l),s)}),yo=ii(function(s,l,h,y){xn(l,Tt(l),s,y)}),DS=ii(function(s,l,h,y){xn(l,He(l),s,y)}),zS=Vn(Ba);function XS(s,l){var h=ri(s);return l==null?h:Lh(h,l)}var US=ye(function(s,l){s=Ge(s);var h=-1,y=l.length,v=y>2?l[2]:t;for(v&&vt(l[0],l[1],v)&&(y=1);++h<y;)for(var P=l[h],T=Tt(P),W=-1,F=T.length;++W<F;){var B=T[W],R=s[B];(R===t||un(R,ei[B])&&!Te.call(s,B))&&(s[B]=P[B])}return s}),kS=ye(function(s){return s.push(t,ud),At(Jd,t,s)});function KS(s,l){return oh(s,se(l,3),bn)}function NS(s,l){return oh(s,se(l,3),Ra)}function BS(s,l){return s==null?s:Ya(s,se(l,3),Tt)}function YS(s,l){return s==null?s:Zh(s,se(l,3),Tt)}function RS(s,l){return s&&bn(s,se(l,3))}function jS(s,l){return s&&Ra(s,se(l,3))}function JS(s){return s==null?[]:Es(s,He(s))}function QS(s){return s==null?[]:Es(s,Tt(s))}function Sl(s,l,h){var y=s==null?t:Vr(s,l);return y===t?h:y}function HS(s,l){return s!=null&&fd(s,l,v1)}function Ll(s,l){return s!=null&&fd(s,l,w1)}var ES=sd(function(s,l,h){l!=null&&typeof l.toString!="function"&&(l=zs.call(l)),s[l]=h},Cl(Gt)),$S=sd(function(s,l,h){l!=null&&typeof l.toString!="function"&&(l=zs.call(l)),Te.call(s,l)?s[l].push(h):s[l]=[h]},se),qS=ye(Bi);function He(s){return Ct(s)?Mh(s):Ha(s)}function Tt(s){return Ct(s)?Mh(s,!0):Z1(s)}function eL(s,l){var h={};return l=se(l,3),bn(s,function(y,v,P){Zn(h,l(y,v,P),y)}),h}function tL(s,l){var h={};return l=se(l,3),bn(s,function(y,v,P){Zn(h,v,l(y,v,P))}),h}var nL=ii(function(s,l,h){$s(s,l,h)}),Jd=ii(function(s,l,h,y){$s(s,l,h,y)}),rL=Vn(function(s,l){var h={};if(s==null)return h;var y=!1;l=Ae(l,function(P){return P=lr(P,s),y||(y=P.length>1),P}),xn(s,ul(s),h),y&&(h=Qt(h,f|g|_,E1));for(var v=l.length;v--;)nl(h,l[v]);return h});function iL(s,l){return Qd(s,po(se(l)))}var sL=Vn(function(s,l){return s==null?{}:V1(s,l)});function Qd(s,l){if(s==null)return{};var h=Ae(ul(s),function(y){return[y]});return l=se(l),Uh(s,h,function(y,v){return l(y,v[0])})}function oL(s,l,h){l=lr(l,s);var y=-1,v=l.length;for(v||(v=1,s=t);++y<v;){var P=s==null?t:s[Mn(l[y])];P===t&&(y=v,P=h),s=An(P)?P.call(s):P}return s}function aL(s,l,h){return s==null?s:Ri(s,l,h)}function lL(s,l,h,y){return y=typeof y=="function"?y:t,s==null?s:Ri(s,l,h,y)}var Hd=ld(He),Ed=ld(Tt);function cL(s,l,h){var y=he(s),v=y||ur(s)||ai(s);if(l=se(l,4),h==null){var P=s&&s.constructor;v?h=y?new P:[]:Fe(s)?h=An(P)?ri(ks(s)):{}:h={}}return(v?Rt:bn)(s,function(T,W,F){return l(h,T,W,F)}),h}function uL(s,l){return s==null?!0:nl(s,l)}function hL(s,l,h){return s==null?s:Yh(s,l,sl(h))}function dL(s,l,h,y){return y=typeof y=="function"?y:t,s==null?s:Yh(s,l,sl(h),y)}function li(s){return s==null?[]:Da(s,He(s))}function fL(s){return s==null?[]:Da(s,Tt(s))}function pL(s,l,h){return h===t&&(h=l,l=t),h!==t&&(h=$t(h),h=h===h?h:0),l!==t&&(l=$t(l),l=l===l?l:0),Wr($t(s),l,h)}function mL(s,l,h){return l=Fn(l),h===t?(h=l,l=0):h=Fn(h),s=$t(s),b1(s,l,h)}function gL(s,l,h){if(h&&typeof h!="boolean"&&vt(s,l,h)&&(l=h=t),h===t&&(typeof l=="boolean"?(h=l,l=t):typeof s=="boolean"&&(h=s,s=t)),s===t&&l===t?(s=0,l=1):(s=Fn(s),l===t?(l=s,s=0):l=Fn(l)),s>l){var y=s;s=l,l=y}if(h||s%1||l%1){var v=bh();return pt(s+v*(l-s+Jw("1e-"+((v+"").length-1))),l)}return qa(s,l)}var yL=si(function(s,l,h){return l=l.toLowerCase(),s+(h?$d(l):l)});function $d(s){return Pl(Pe(s).toLowerCase())}function qd(s){return s=Pe(s),s&&s.replace(vw,ab).replace(zw,"")}function _L(s,l,h){s=Pe(s),l=Ot(l);var y=s.length;h=h===t?y:Wr(pe(h),0,y);var v=h;return h-=l.length,h>=0&&s.slice(h,v)==l}function vL(s){return s=Pe(s),s&&Ts.test(s)?s.replace(sn,lb):s}function wL(s){return s=Pe(s),s&&sw.test(s)?s.replace(ba,"\\$&"):s}var bL=si(function(s,l,h){return s+(h?"-":"")+l.toLowerCase()}),xL=si(function(s,l,h){return s+(h?" ":"")+l.toLowerCase()}),ML=nd("toLowerCase");function SL(s,l,h){s=Pe(s),l=pe(l);var y=l?$r(s):0;if(!l||y>=l)return s;var v=(l-y)/2;return io(Ys(v),h)+s+io(Bs(v),h)}function LL(s,l,h){s=Pe(s),l=pe(l);var y=l?$r(s):0;return l&&y<l?s+io(l-y,h):s}function PL(s,l,h){s=Pe(s),l=pe(l);var y=l?$r(s):0;return l&&y<l?io(l-y,h)+s:s}function CL(s,l,h){return h||l==null?l=0:l&&(l=+l),Ab(Pe(s).replace(xa,""),l||0)}function TL(s,l,h){return(h?vt(s,l,h):l===t)?l=1:l=pe(l),el(Pe(s),l)}function GL(){var s=arguments,l=Pe(s[0]);return s.length<3?l:l.replace(s[1],s[2])}var ZL=si(function(s,l,h){return s+(h?"_":"")+l.toLowerCase()});function WL(s,l,h){return h&&typeof h!="number"&&vt(s,l,h)&&(l=h=t),h=h===t?ge:h>>>0,h?(s=Pe(s),s&&(typeof l=="string"||l!=null&&!Ml(l))&&(l=Ot(l),!l&&Er(s))?cr(ln(s),0,h):s.split(l,h)):[]}var VL=si(function(s,l,h){return s+(h?" ":"")+Pl(l)});function IL(s,l,h){return s=Pe(s),h=h==null?0:Wr(pe(h),0,s.length),l=Ot(l),s.slice(h,h+l.length)==l}function AL(s,l,h){var y=S.templateSettings;h&&vt(s,l,h)&&(l=t),s=Pe(s),l=yo({},l,y,cd);var v=yo({},l.imports,y.imports,cd),P=He(v),T=Da(v,P),W,F,B=0,R=l.interpolate||Gs,J="__p += '",$=Xa((l.escape||Gs).source+"|"+R.source+"|"+(R===tr?fw:Gs).source+"|"+(l.evaluate||Gs).source+"|$","g"),te="//# sourceURL="+(Te.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Nw+"]")+`
761
+ `;s.replace($,function(ae,we,xe,zt,wt,Xt){return xe||(xe=zt),J+=s.slice(B,Xt).replace(ww,cb),we&&(W=!0,J+=`' +
762
+ __e(`+we+`) +
763
+ '`),wt&&(F=!0,J+=`';
764
+ `+wt+`;
765
+ __p += '`),xe&&(J+=`' +
766
+ ((__t = (`+xe+`)) == null ? '' : __t) +
767
+ '`),B=Xt+ae.length,ae}),J+=`';
768
+ `;var oe=Te.call(l,"variable")&&l.variable;if(!oe)J=`with (obj) {
769
+ `+J+`
770
+ }
771
+ `;else if(hw.test(oe))throw new ue(c);J=(F?J.replace(ce,""):J).replace(Me,"$1").replace(Be,"$1;"),J="function("+(oe||"obj")+`) {
772
+ `+(oe?"":`obj || (obj = {});
773
+ `)+"var __t, __p = ''"+(W?", __e = _.escape":"")+(F?`, __j = Array.prototype.join;
774
+ function print() { __p += __j.call(arguments, '') }
775
+ `:`;
776
+ `)+J+`return __p
777
+ }`;var me=tf(function(){return Le(P,te+"return "+J).apply(t,T)});if(me.source=J,xl(me))throw me;return me}function FL(s){return Pe(s).toLowerCase()}function OL(s){return Pe(s).toUpperCase()}function DL(s,l,h){if(s=Pe(s),s&&(h||l===t))return uh(s);if(!s||!(l=Ot(l)))return s;var y=ln(s),v=ln(l),P=hh(y,v),T=dh(y,v)+1;return cr(y,P,T).join("")}function zL(s,l,h){if(s=Pe(s),s&&(h||l===t))return s.slice(0,ph(s)+1);if(!s||!(l=Ot(l)))return s;var y=ln(s),v=dh(y,ln(l))+1;return cr(y,0,v).join("")}function XL(s,l,h){if(s=Pe(s),s&&(h||l===t))return s.replace(xa,"");if(!s||!(l=Ot(l)))return s;var y=ln(s),v=hh(y,ln(l));return cr(y,v).join("")}function UL(s,l){var h=V,y=G;if(Fe(l)){var v="separator"in l?l.separator:v;h="length"in l?pe(l.length):h,y="omission"in l?Ot(l.omission):y}s=Pe(s);var P=s.length;if(Er(s)){var T=ln(s);P=T.length}if(h>=P)return s;var W=h-$r(y);if(W<1)return y;var F=T?cr(T,0,W).join(""):s.slice(0,W);if(v===t)return F+y;if(T&&(W+=F.length-W),Ml(v)){if(s.slice(W).search(v)){var B,R=F;for(v.global||(v=Xa(v.source,Pe(Vu.exec(v))+"g")),v.lastIndex=0;B=v.exec(R);)var J=B.index;F=F.slice(0,J===t?W:J)}}else if(s.indexOf(Ot(v),W)!=W){var $=F.lastIndexOf(v);$>-1&&(F=F.slice(0,$))}return F+y}function kL(s){return s=Pe(s),s&&Wu.test(s)?s.replace(Bt,gb):s}var KL=si(function(s,l,h){return s+(h?" ":"")+l.toUpperCase()}),Pl=nd("toUpperCase");function ef(s,l,h){return s=Pe(s),l=h?t:l,l===t?hb(s)?vb(s):nb(s):s.match(l)||[]}var tf=ye(function(s,l){try{return At(s,t,l)}catch(h){return xl(h)?h:new ue(h)}}),NL=Vn(function(s,l){return Rt(l,function(h){h=Mn(h),Zn(s,h,wl(s[h],s))}),s});function BL(s){var l=s==null?0:s.length,h=se();return s=l?Ae(s,function(y){if(typeof y[1]!="function")throw new jt(a);return[h(y[0]),y[1]]}):[],ye(function(y){for(var v=-1;++v<l;){var P=s[v];if(At(P[0],this,y))return At(P[1],this,y)}})}function YL(s){return g1(Qt(s,f))}function Cl(s){return function(){return s}}function RL(s,l){return s==null||s!==s?l:s}var jL=id(),JL=id(!0);function Gt(s){return s}function Tl(s){return Ah(typeof s=="function"?s:Qt(s,f))}function QL(s){return Oh(Qt(s,f))}function HL(s,l){return Dh(s,Qt(l,f))}var EL=ye(function(s,l){return function(h){return Bi(h,s,l)}}),$L=ye(function(s,l){return function(h){return Bi(s,h,l)}});function Gl(s,l,h){var y=He(l),v=Es(l,y);h==null&&!(Fe(l)&&(v.length||!y.length))&&(h=l,l=s,s=this,v=Es(l,He(l)));var P=!(Fe(h)&&"chain"in h)||!!h.chain,T=An(s);return Rt(v,function(W){var F=l[W];s[W]=F,T&&(s.prototype[W]=function(){var B=this.__chain__;if(P||B){var R=s(this.__wrapped__),J=R.__actions__=Pt(this.__actions__);return J.push({func:F,args:arguments,thisArg:s}),R.__chain__=B,R}return F.apply(s,rr([this.value()],arguments))})}),s}function qL(){return at._===this&&(at._=Lb),this}function Zl(){}function e2(s){return s=pe(s),ye(function(l){return zh(l,s)})}var t2=al(Ae),n2=al(sh),r2=al(Va);function nf(s){return pl(s)?Ia(Mn(s)):I1(s)}function i2(s){return function(l){return s==null?t:Vr(s,l)}}var s2=od(),o2=od(!0);function Wl(){return[]}function Vl(){return!1}function a2(){return{}}function l2(){return""}function c2(){return!0}function u2(s,l){if(s=pe(s),s<1||s>re)return[];var h=ge,y=pt(s,ge);l=se(l),s-=ge;for(var v=Oa(y,l);++h<s;)l(h);return v}function h2(s){return he(s)?Ae(s,Mn):Dt(s)?[s]:Pt(xd(Pe(s)))}function d2(s){var l=++Mb;return Pe(s)+l}var f2=ro(function(s,l){return s+l},0),p2=ll("ceil"),m2=ro(function(s,l){return s/l},1),g2=ll("floor");function y2(s){return s&&s.length?Hs(s,Gt,ja):t}function _2(s,l){return s&&s.length?Hs(s,se(l,2),ja):t}function v2(s){return lh(s,Gt)}function w2(s,l){return lh(s,se(l,2))}function b2(s){return s&&s.length?Hs(s,Gt,Ea):t}function x2(s,l){return s&&s.length?Hs(s,se(l,2),Ea):t}var M2=ro(function(s,l){return s*l},1),S2=ll("round"),L2=ro(function(s,l){return s-l},0);function P2(s){return s&&s.length?Fa(s,Gt):0}function C2(s,l){return s&&s.length?Fa(s,se(l,2)):0}return S.after=QM,S.ary=Id,S.assign=OS,S.assignIn=jd,S.assignInWith=yo,S.assignWith=DS,S.at=zS,S.before=Ad,S.bind=wl,S.bindAll=NL,S.bindKey=Fd,S.castArray=aS,S.chain=Zd,S.chunk=gx,S.compact=yx,S.concat=_x,S.cond=BL,S.conforms=YL,S.constant=Cl,S.countBy=PM,S.create=XS,S.curry=Od,S.curryRight=Dd,S.debounce=zd,S.defaults=US,S.defaultsDeep=kS,S.defer=HM,S.delay=EM,S.difference=vx,S.differenceBy=wx,S.differenceWith=bx,S.drop=xx,S.dropRight=Mx,S.dropRightWhile=Sx,S.dropWhile=Lx,S.fill=Px,S.filter=TM,S.flatMap=WM,S.flatMapDeep=VM,S.flatMapDepth=IM,S.flatten=Pd,S.flattenDeep=Cx,S.flattenDepth=Tx,S.flip=$M,S.flow=jL,S.flowRight=JL,S.fromPairs=Gx,S.functions=JS,S.functionsIn=QS,S.groupBy=AM,S.initial=Wx,S.intersection=Vx,S.intersectionBy=Ix,S.intersectionWith=Ax,S.invert=ES,S.invertBy=$S,S.invokeMap=OM,S.iteratee=Tl,S.keyBy=DM,S.keys=He,S.keysIn=Tt,S.map=uo,S.mapKeys=eL,S.mapValues=tL,S.matches=QL,S.matchesProperty=HL,S.memoize=fo,S.merge=nL,S.mergeWith=Jd,S.method=EL,S.methodOf=$L,S.mixin=Gl,S.negate=po,S.nthArg=e2,S.omit=rL,S.omitBy=iL,S.once=qM,S.orderBy=zM,S.over=t2,S.overArgs=eS,S.overEvery=n2,S.overSome=r2,S.partial=bl,S.partialRight=Xd,S.partition=XM,S.pick=sL,S.pickBy=Qd,S.property=nf,S.propertyOf=i2,S.pull=zx,S.pullAll=Td,S.pullAllBy=Xx,S.pullAllWith=Ux,S.pullAt=kx,S.range=s2,S.rangeRight=o2,S.rearg=tS,S.reject=KM,S.remove=Kx,S.rest=nS,S.reverse=_l,S.sampleSize=BM,S.set=aL,S.setWith=lL,S.shuffle=YM,S.slice=Nx,S.sortBy=JM,S.sortedUniq=Hx,S.sortedUniqBy=Ex,S.split=WL,S.spread=rS,S.tail=$x,S.take=qx,S.takeRight=eM,S.takeRightWhile=tM,S.takeWhile=nM,S.tap=yM,S.throttle=iS,S.thru=co,S.toArray=Bd,S.toPairs=Hd,S.toPairsIn=Ed,S.toPath=h2,S.toPlainObject=Rd,S.transform=cL,S.unary=sS,S.union=rM,S.unionBy=iM,S.unionWith=sM,S.uniq=oM,S.uniqBy=aM,S.uniqWith=lM,S.unset=uL,S.unzip=vl,S.unzipWith=Gd,S.update=hL,S.updateWith=dL,S.values=li,S.valuesIn=fL,S.without=cM,S.words=ef,S.wrap=oS,S.xor=uM,S.xorBy=hM,S.xorWith=dM,S.zip=fM,S.zipObject=pM,S.zipObjectDeep=mM,S.zipWith=gM,S.entries=Hd,S.entriesIn=Ed,S.extend=jd,S.extendWith=yo,Gl(S,S),S.add=f2,S.attempt=tf,S.camelCase=yL,S.capitalize=$d,S.ceil=p2,S.clamp=pL,S.clone=lS,S.cloneDeep=uS,S.cloneDeepWith=hS,S.cloneWith=cS,S.conformsTo=dS,S.deburr=qd,S.defaultTo=RL,S.divide=m2,S.endsWith=_L,S.eq=un,S.escape=vL,S.escapeRegExp=wL,S.every=CM,S.find=GM,S.findIndex=Sd,S.findKey=KS,S.findLast=ZM,S.findLastIndex=Ld,S.findLastKey=NS,S.floor=g2,S.forEach=Wd,S.forEachRight=Vd,S.forIn=BS,S.forInRight=YS,S.forOwn=RS,S.forOwnRight=jS,S.get=Sl,S.gt=fS,S.gte=pS,S.has=HS,S.hasIn=Ll,S.head=Cd,S.identity=Gt,S.includes=FM,S.indexOf=Zx,S.inRange=mL,S.invoke=qS,S.isArguments=Fr,S.isArray=he,S.isArrayBuffer=mS,S.isArrayLike=Ct,S.isArrayLikeObject=ke,S.isBoolean=gS,S.isBuffer=ur,S.isDate=yS,S.isElement=_S,S.isEmpty=vS,S.isEqual=wS,S.isEqualWith=bS,S.isError=xl,S.isFinite=xS,S.isFunction=An,S.isInteger=Ud,S.isLength=mo,S.isMap=kd,S.isMatch=MS,S.isMatchWith=SS,S.isNaN=LS,S.isNative=PS,S.isNil=TS,S.isNull=CS,S.isNumber=Kd,S.isObject=Fe,S.isObjectLike=Xe,S.isPlainObject=Hi,S.isRegExp=Ml,S.isSafeInteger=GS,S.isSet=Nd,S.isString=go,S.isSymbol=Dt,S.isTypedArray=ai,S.isUndefined=ZS,S.isWeakMap=WS,S.isWeakSet=VS,S.join=Fx,S.kebabCase=bL,S.last=Et,S.lastIndexOf=Ox,S.lowerCase=xL,S.lowerFirst=ML,S.lt=IS,S.lte=AS,S.max=y2,S.maxBy=_2,S.mean=v2,S.meanBy=w2,S.min=b2,S.minBy=x2,S.stubArray=Wl,S.stubFalse=Vl,S.stubObject=a2,S.stubString=l2,S.stubTrue=c2,S.multiply=M2,S.nth=Dx,S.noConflict=qL,S.noop=Zl,S.now=ho,S.pad=SL,S.padEnd=LL,S.padStart=PL,S.parseInt=CL,S.random=gL,S.reduce=UM,S.reduceRight=kM,S.repeat=TL,S.replace=GL,S.result=oL,S.round=S2,S.runInContext=A,S.sample=NM,S.size=RM,S.snakeCase=ZL,S.some=jM,S.sortedIndex=Bx,S.sortedIndexBy=Yx,S.sortedIndexOf=Rx,S.sortedLastIndex=jx,S.sortedLastIndexBy=Jx,S.sortedLastIndexOf=Qx,S.startCase=VL,S.startsWith=IL,S.subtract=L2,S.sum=P2,S.sumBy=C2,S.template=AL,S.times=u2,S.toFinite=Fn,S.toInteger=pe,S.toLength=Yd,S.toLower=FL,S.toNumber=$t,S.toSafeInteger=FS,S.toString=Pe,S.toUpper=OL,S.trim=DL,S.trimEnd=zL,S.trimStart=XL,S.truncate=UL,S.unescape=kL,S.uniqueId=d2,S.upperCase=KL,S.upperFirst=Pl,S.each=Wd,S.eachRight=Vd,S.first=Cd,Gl(S,function(){var s={};return bn(S,function(l,h){Te.call(S.prototype,h)||(s[h]=l)}),s}(),{chain:!1}),S.VERSION=n,Rt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(s){S[s].placeholder=S}),Rt(["drop","take"],function(s,l){be.prototype[s]=function(h){h=h===t?1:Je(pe(h),0);var y=this.__filtered__&&!l?new be(this):this.clone();return y.__filtered__?y.__takeCount__=pt(h,y.__takeCount__):y.__views__.push({size:pt(h,ge),type:s+(y.__dir__<0?"Right":"")}),y},be.prototype[s+"Right"]=function(h){return this.reverse()[s](h).reverse()}}),Rt(["filter","map","takeWhile"],function(s,l){var h=l+1,y=h==Y||h==Q;be.prototype[s]=function(v){var P=this.clone();return P.__iteratees__.push({iteratee:se(v,3),type:h}),P.__filtered__=P.__filtered__||y,P}}),Rt(["head","last"],function(s,l){var h="take"+(l?"Right":"");be.prototype[s]=function(){return this[h](1).value()[0]}}),Rt(["initial","tail"],function(s,l){var h="drop"+(l?"":"Right");be.prototype[s]=function(){return this.__filtered__?new be(this):this[h](1)}}),be.prototype.compact=function(){return this.filter(Gt)},be.prototype.find=function(s){return this.filter(s).head()},be.prototype.findLast=function(s){return this.reverse().find(s)},be.prototype.invokeMap=ye(function(s,l){return typeof s=="function"?new be(this):this.map(function(h){return Bi(h,s,l)})}),be.prototype.reject=function(s){return this.filter(po(se(s)))},be.prototype.slice=function(s,l){s=pe(s);var h=this;return h.__filtered__&&(s>0||l<0)?new be(h):(s<0?h=h.takeRight(-s):s&&(h=h.drop(s)),l!==t&&(l=pe(l),h=l<0?h.dropRight(-l):h.take(l-s)),h)},be.prototype.takeRightWhile=function(s){return this.reverse().takeWhile(s).reverse()},be.prototype.toArray=function(){return this.take(ge)},bn(be.prototype,function(s,l){var h=/^(?:filter|find|map|reject)|While$/.test(l),y=/^(?:head|last)$/.test(l),v=S[y?"take"+(l=="last"?"Right":""):l],P=y||/^find/.test(l);v&&(S.prototype[l]=function(){var T=this.__wrapped__,W=y?[1]:arguments,F=T instanceof be,B=W[0],R=F||he(T),J=function(we){var xe=v.apply(S,rr([we],W));return y&&$?xe[0]:xe};R&&h&&typeof B=="function"&&B.length!=1&&(F=R=!1);var $=this.__chain__,te=!!this.__actions__.length,oe=P&&!$,me=F&&!te;if(!P&&R){T=me?T:new be(this);var ae=s.apply(T,W);return ae.__actions__.push({func:co,args:[J],thisArg:t}),new Jt(ae,$)}return oe&&me?s.apply(this,W):(ae=this.thru(J),oe?y?ae.value()[0]:ae.value():ae)})}),Rt(["pop","push","shift","sort","splice","unshift"],function(s){var l=Fs[s],h=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",y=/^(?:pop|shift)$/.test(s);S.prototype[s]=function(){var v=arguments;if(y&&!this.__chain__){var P=this.value();return l.apply(he(P)?P:[],v)}return this[h](function(T){return l.apply(he(T)?T:[],v)})}}),bn(be.prototype,function(s,l){var h=S[l];if(h){var y=h.name+"";Te.call(ni,y)||(ni[y]=[]),ni[y].push({name:l,func:h})}}),ni[no(t,L).name]=[{name:"wrapper",func:t}],be.prototype.clone=kb,be.prototype.reverse=Kb,be.prototype.value=Nb,S.prototype.at=_M,S.prototype.chain=vM,S.prototype.commit=wM,S.prototype.next=bM,S.prototype.plant=MM,S.prototype.reverse=SM,S.prototype.toJSON=S.prototype.valueOf=S.prototype.value=LM,S.prototype.first=S.prototype.head,Di&&(S.prototype[Di]=xM),S},qr=wb();Cr?((Cr.exports=qr)._=qr,Ta._=qr):at._=qr}).call(Li)}(gs,gs.exports);var m0=gs.exports,g0=Object.defineProperty,y0=(i,e,t)=>e in i?g0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,_0=(i,e,t)=>y0(i,e+"",t);let en=class extends ut{constructor(e){super(e),_0(this,"_baseType","Point"),this._threeGeometry=this._createThreeGeometry(),this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),t=new p.Vector3(this._geometry.coordinates[0],this._geometry.coordinates[1],this._geometry.coordinates[2]||0);return e?e.geo2world(t):t}_toThreeJSGeometry(){}_updateGeometryPositions(){const e=this._coordsTransform();if(this._position=e,this._threeGeometry){const t=this.getMap();t?.prjcenter?this._threeGeometry.position.copy(e).sub(t.prjcenter):this._threeGeometry.position.copy(e),this.children.includes(this._threeGeometry)||this.add(this._threeGeometry),this.updateMatrixWorld(!0)}else this._toThreeJSGeometry()}_createThreeGeometry(){return new p.Points(new p.BufferGeometry,new p.PointsMaterial({size:1,color:8947848}))}};var v0=Object.defineProperty,w0=(i,e,t)=>e in i?v0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,b0=(i,e,t)=>w0(i,e+"",t);const x0={};class Pn extends en{constructor(e){super(e),b0(this,"_type","Marker")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometryPositions(){this._position=this._coordsTransform(),this._threeGeometry?(this._threeGeometry.position.copy(this._position),this.children.includes(this._threeGeometry)||this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0)):this._toThreeJSGeometry()}async _createObject(e){switch(e.config.type){case"basic-point":return Wc(e.config,new p.Vector3(0,0,0));case"icon-point":return tg(e.config,this._position);case"icon-label-point":return ug(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(e,t){if(!this.visible||!this._threeGeometry||!e||!t)return null;try{switch(this._style?.config.type){case"icon-point":return this._calculateSpriteBoundingBox(this._threeGeometry);default:return this._getFallbackBoundingBox()}}catch(n){return console.warn(`Marker ${this._id} bounding box calculation failed:`,n),console.warn(`Marker ${this._id} 包围盒计算失败:`,n),this._getFallbackBoundingBox()}}_calculateSpriteBoundingBox(e){try{const n=Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))/.002;return{width:n,height:n,offsetX:-n/2,offsetY:-n/2}}catch{return{width:20,height:20,offsetX:-10,offsetY:-10}}}_getFallbackBoundingBox(){switch(this.getStyle()?.config.type){case"icon-point":case"icon-label-point":return{width:20,height:20,offsetX:-10,offsetY:-10};case"basic-point":return{width:10,height:10,offsetX:-5,offsetY:-5};default:return{width:15,height:15,offsetX:-7.5,offsetY:-7.5}}}}Pn.mergeOptions(x0);var M0=Object.defineProperty,S0=(i,e,t)=>e in i?M0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Jc=(i,e,t)=>S0(i,typeof e!="symbol"?e+"":e,t);class Qc extends ut{constructor(e){super(e),Jc(this,"_baseType","Line"),Jc(this,"_vertexPoints"),this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),t=this._geometry,n=e?.prjcenter;if(this._geometry.type==="LineString"){let o=t.coordinates.map(c=>{const u=new p.Vector3(c[0],c[1],c[2]||0);return(e?e.geo2world(u):u).sub(n)}),a=o.flatMap(c=>[c.x,c.y,c.z]);return{_position:o,_vertexPoints:a}}}_toThreeJSGeometry(){}_createThreeGeometry(){const e=new rs,t=new mi({color:8947848,linewidth:.1,dashed:!1,resolution:new p.Vector2(window.innerWidth,window.innerHeight)});return new gi(e,t)}}var L0=Object.defineProperty,P0=(i,e,t)=>e in i?L0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,C0=(i,e,t)=>P0(i,e+"",t);const T0={};class Mt extends Qc{constructor(e){super(e),C0(this,"_type","LineString")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometryPositions(){let{_vertexPoints:e}=this._coordsTransform();if(this._vertexPoints=e,this._threeGeometry&&(this._threeGeometry.isLine2||this._threeGeometry instanceof gi)){const r=this._threeGeometry.geometry;r.setPositions(this._vertexPoints),r.computeBoundingSphere(),r.computeBoundingBox();const o=this.getMap();o?.prjcenter&&this._threeGeometry.position.set(o.prjcenter.x,o.prjcenter.y,o.prjcenter.z),this.children.includes(this._threeGeometry)||this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0)}else console.warn("[LineString] _updateGeometryPositions: Geometry type mismatch, fallback to full rebuild",{hasGeometry:!!this._threeGeometry,geometryType:this._threeGeometry?.constructor?.name,isLine2:this._threeGeometry?.isLine2}),this._toThreeJSGeometry()}async _createObject(e){switch(e.config.type){case"basic-line":return Jo(e.config,this._vertexPoints);case"flow-tube-line":return Vc(e.config,this._vertexPoints);case"arrow-line":return Ic(e.config,this._vertexPoints);case"flow-texture-line":return await Ac(e.config,this._vertexPoints);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}_updateGeometry(){const e=this.getMap();if(this._threeGeometry){if(this._threeGeometry instanceof gi){const n=this._threeGeometry.geometry;n.setPositions(this._vertexPoints),n.computeBoundingSphere(),n.computeBoundingBox()}this._threeGeometry.position.add(e?.prjcenter),this._threeGeometry.renderOrder=99,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue()}}}Mt.mergeOptions(T0);var G0=Object.defineProperty,Z0=(i,e,t)=>e in i?G0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Hc=(i,e,t)=>Z0(i,typeof e!="symbol"?e+"":e,t);class W0 extends ut{constructor(e){super(e),Hc(this,"_baseType","Surface"),Hc(this,"_vertexPoints"),this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),t=e?.prjcenter,n=this._geometry;if(!n)throw new Error("Geometry data undefined");if(n.type==="Polygon"){const r=n.coordinates;let o=[],a=[];return r.forEach(c=>{const u=c.map(d=>{const m=new p.Vector3(d[0],d[1],d[2]||0);return(e?e.geo2world(m):m).sub(t)});o.push(u),a.push(...u.flatMap(d=>[d.x,d.y,d.z]))}),{_positions:o,_vertexPoints:a}}else if(n.type==="MultiPolygon"){const r=n.coordinates;let o=[],a=[];return r.forEach(c=>{const u=[];c.forEach(d=>{const m=d.map(f=>{const g=new p.Vector3(f[0],f[1],f[2]||0);return(e?e.geo2world(g):g).sub(t)});u.push(m),a.push(...m.flatMap(f=>[f.x,f.y,f.z]))}),o.push(u)}),{_positions:o,_vertexPoints:a}}else throw new Error(`Unsupported geometry type: ${n.type}`)}_updateGeometry(){const e=this._style?.config.type;if(this.clear(),!this._threeGeometry||!this._vertexPoints?.length){console.warn("Cannot update geometry: missing geometry or vertex data");return}const t=this.getMap();try{e==="basic-polygon"?(this._threeGeometry.renderOrder=90,this._threeGeometry.position.add(t?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry)):(e==="extrude-polygon"||e?.includes("water"))&&(this._threeGeometry.renderOrder=90,this._threeGeometry.position.add(t?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry))}catch(n){throw console.error("Failed to update polygon position:",n),n}}_createThreeGeometry(){const e=new rs,t=new mi({color:8947848,linewidth:.1,dashed:!1,resolution:new p.Vector2(window.innerWidth,window.innerHeight)});return new gi(e,t)}}var V0=Object.defineProperty,I0=(i,e,t)=>e in i?V0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,A0=(i,e,t)=>I0(i,e+"",t);const F0={};class _n extends W0{constructor(e){super(e),A0(this,"_type","Polygon")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this.remove(this._threeGeometry),this._threeGeometry=await this._createObject(this._style),this._updateGeometry(),await this._style.applyTo(this._threeGeometry))}_updateGeometryPositions(){const e=this._style?.config.type;console.warn("[Polygon] _updateGeometryPositions: Fallback to full rebuild",{styleType:e,hasGeometry:!!this._threeGeometry}),this._toThreeJSGeometry()}async _createObject(e){switch(e.config.type){case"basic-polygon":return rg(e.config,this._vertexPoints);case"extrude-polygon":return ig(e.config,this._vertexPoints);case"water":return sg(e.config,this.getMap(),this._vertexPoints);case"base-water":return og(e.config,this._vertexPoints);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}_calculateCollisionBoundingBox(){return null}}_n.mergeOptions(F0);var O0=Object.defineProperty,D0=(i,e,t)=>e in i?O0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,qo=(i,e,t)=>D0(i,typeof e!="symbol"?e+"":e,t);const z0={};class Ec extends Qc{constructor(e){super(e),qo(this,"_type","MultiLineString"),qo(this,"_lineObjects",[]),qo(this,"_linesContainer"),this._linesContainer=new p.Group}async _toThreeJSGeometry(){const{_position:e}=this._coordsTransform(),t=this.getMap();if(this.clearLines(),this._disposeGeometry(),this._style){for(const n of e){const r=n.flatMap(a=>[a.x,a.y,a.z]),o=await this._createLineObject(this._style,r);o.position.add(t?.prjcenter),o.updateMatrixWorld(!0),o.renderOrder=99,this._lineObjects.push(o),this._linesContainer.add(o)}this._linesContainer.renderOrder=99,this._threeGeometry=this._linesContainer,this.add(this._threeGeometry),this._updateContainer(),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0),this._tryProcessQueue()}}async _createLineObject(e,t){switch(e.config.type){case"basic-line":return Jo(e.config,t);case"flow-tube-line":return Vc(e.config,t);case"arrow-line":return Ic(e.config,t);case"flow-texture-line":return await Ac(e.config,t);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}_coordsTransform(){const e=this.getMap(),t=this._geometry;if(this._geometry.type==="MultiLineString"){const n=e?.prjcenter;return{_position:t.coordinates.map(o=>o.map(a=>{const c=new p.Vector3(a[0],a[1],a[2]||0);return(e?e.geo2world(c):c).sub(n)}))}}}_updateContainer(){this._linesContainer.updateMatrixWorld(!0)}clearLines(){this._lineObjects.forEach(e=>{this._linesContainer.remove(e),e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this._lineObjects=[]}_updateGeometry(){this._toThreeJSGeometry()}_disposeObject(){}}Ec.mergeOptions(z0);var X0=Object.defineProperty,U0=(i,e,t)=>e in i?X0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Pi=(i,e,t)=>U0(i,typeof e!="symbol"?e+"":e,t);const ea=64;class k0 extends ct.MeshStandardMaterial{constructor(e={}){const{shaderOption:t,regionOverlay:n,...r}=e;if(super({color:"rgb(58,126,182)",roughness:.7,metalness:.1,transparent:!0,opacity:.9,envMapIntensity:.8,depthWrite:!0,depthTest:!0,...r}),Pi(this,"shaderOption"),Pi(this,"clock"),Pi(this,"time"),Pi(this,"startTime"),Pi(this,"regionOverlay"),n&&n.vertices&&n.vertices.length>0){const o=n.vertices.slice(0,ea).map(c=>c.clone()),a=o.length;for(;o.length<ea;)o.push(new ct.Vector2(0,0));this.regionOverlay={color:n.color,opacity:n.opacity,vertices:o,vertexCount:a}}this.shaderOption={minY:0,maxY:100,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!1,color:new ct.Color("#9ECDEC"),width:20,speed:1,maxDistance:100,center:void 0},flow:{enabled:!1,color:new ct.Color("#00E4FF"),range:10,speed:20},sweep:{enabled:!1,color:new ct.Color("#FFFFFF"),width:1.5,speed:10}},...t},this.clock=new ct.Clock,this.time={value:0},this.startTime={value:0},this.animate()}onBeforeCompile(e){const{minY:t,maxY:n,minRate:r,maxRate:o,effects:a}=this.shaderOption,c=n-t,u=!!this.regionOverlay;e.uniforms={...e.uniforms,time:this.time,uStartTime:this.startTime,uMinY:{value:t},uMaxY:{value:n},uHeightRange:{value:c},uMinRate:{value:r},uMaxRate:{value:o},uDiffusionEnabled:{value:a?.diffusion?.enabled?1:0},uDiffusionColor:{value:a?.diffusion?.color||new ct.Color("#9ECDEC")},uDiffusionWidth:{value:a?.diffusion?.width||20},uDiffusionSpeed:{value:a?.diffusion?.speed||1},uDiffusionMaxDistance:{value:a?.diffusion?.maxDistance||100},uDiffusionCenter:{value:a?.diffusion?.center||new ct.Vector3(0,0,0)},uFlowEnabled:{value:a?.flow?.enabled?1:0},uFlowColor:{value:a?.flow?.color||new ct.Color("#00E4FF")},uFlowRange:{value:a?.flow?.range||10},uFlowSpeed:{value:a?.flow?.speed||20},uSweepEnabled:{value:a?.sweep?.enabled?1:0},uSweepColor:{value:a?.sweep?.color||new ct.Color("#FFFFFF")},uSweepWidth:{value:a?.sweep?.width||1.5},uSweepSpeed:{value:a?.sweep?.speed||10},uRegionOverlayEnabled:{value:u?1:0},uRegionOverlayColor:{value:this.regionOverlay?.color||new ct.Color("#00FF88")},uRegionOverlayOpacity:{value:this.regionOverlay?.opacity??0},uRegionOverlayVertexCount:{value:this.regionOverlay?.vertexCount??0},uRegionOverlayVertices:{value:this.regionOverlay?.vertices||new Array(ea).fill(0).map(()=>new ct.Vector2(0,0))}},e.vertexShader=`
604
778
  varying vec3 vWorldPosition;
605
779
  varying vec3 vPosition;
606
780
  varying float vHeight;
@@ -612,6 +786,7 @@
612
786
  vHeight = position.y;
613
787
  `),e.fragmentShader=`
614
788
  #define PI 3.141592653589793
789
+ #define REGION_OVERLAY_MAX_VERTS 64
615
790
  varying vec3 vWorldPosition;
616
791
  varying vec3 vPosition;
617
792
  varying float vHeight;
@@ -622,14 +797,12 @@
622
797
  uniform float uMaxRate;
623
798
  uniform float time;
624
799
  uniform float uStartTime;
625
- // 修改后的圆环扩散uniforms
626
800
  uniform int uDiffusionEnabled;
627
801
  uniform vec3 uDiffusionColor;
628
802
  uniform float uDiffusionWidth;
629
803
  uniform float uDiffusionSpeed;
630
804
  uniform float uDiffusionMaxDistance;
631
805
  uniform vec3 uDiffusionCenter;
632
- // 其他效果uniforms保持不变
633
806
  uniform int uFlowEnabled;
634
807
  uniform vec3 uFlowColor;
635
808
  uniform float uFlowRange;
@@ -638,6 +811,14 @@
638
811
  uniform vec3 uSweepColor;
639
812
  uniform float uSweepWidth;
640
813
  uniform float uSweepSpeed;
814
+
815
+ // 区域多边形外衣相关 uniform 声明(之前缺少)
816
+ uniform int uRegionOverlayEnabled;
817
+ uniform vec3 uRegionOverlayColor;
818
+ uniform float uRegionOverlayOpacity;
819
+ uniform int uRegionOverlayVertexCount;
820
+ uniform vec2 uRegionOverlayVertices[REGION_OVERLAY_MAX_VERTS];
821
+
641
822
 
642
823
  float distanceTo(vec2 src, vec2 dst) {
643
824
  return distance(src, dst);
@@ -647,42 +828,35 @@
647
828
  `.replace("#include <color_fragment>",`
648
829
  #include <color_fragment>
649
830
 
650
- // 保留高度渐变计算
831
+ // 高度渐变计算
651
832
  float normalizedHeight = clamp((vWorldPosition.y - uMinY) / uHeightRange, 0.0, 1.0);
652
833
  float heightFactor = smoothstep(0.0, 1.0, normalizedHeight);
653
834
  diffuseColor.rgb *= mix(uMinRate, uMaxRate, heightFactor);
654
835
 
655
- // ================= 修改为圆环扩散效果 =================
656
- if (uDiffusionEnabled == 1) {
657
- vec2 position2D = vec2(vWorldPosition.x, vWorldPosition.z);
658
- vec2 center2D = vec2(uDiffusionCenter.x, uDiffusionCenter.z);
659
- float distToCenter = distance(position2D, center2D);
660
-
661
- float progress = mod(time * uDiffusionSpeed, 1.0);
662
- float currentRadius = progress * uDiffusionMaxDistance;
663
-
664
- if (distToCenter > currentRadius - uDiffusionWidth &&
665
- distToCenter < currentRadius) {
666
- // 核心亮度增强修改:
667
- float ringFactor = smoothstep(
668
- currentRadius - uDiffusionWidth,
669
- currentRadius,
670
- distToCenter
671
- );
836
+ // 圆环扩散效果
837
+ if (uDiffusionEnabled == 1) {
838
+ vec2 position2D = vec2(vWorldPosition.x, vWorldPosition.z);
839
+ vec2 center2D = vec2(uDiffusionCenter.x, uDiffusionCenter.z);
840
+ float distToCenter = distance(position2D, center2D);
672
841
 
673
- // 1. 增强亮度:颜色值乘以5倍(可根据需要调整)
674
- vec3 highBrightnessColor = uDiffusionColor * 5.0;
842
+ float progress = mod(time * uDiffusionSpeed, 1.0);
843
+ float currentRadius = progress * uDiffusionMaxDistance;
675
844
 
676
- // 2. 改用加法混合模式(更亮)
677
- diffuseColor.rgb += highBrightnessColor * (1.0 - ringFactor);
678
-
679
- // 3. 防止过曝(可选)
680
- diffuseColor.rgb = min(diffuseColor.rgb, vec3(2.0));
681
- }
682
- }
845
+ if (distToCenter > currentRadius - uDiffusionWidth &&
846
+ distToCenter < currentRadius) {
847
+ float ringFactor = smoothstep(
848
+ currentRadius - uDiffusionWidth,
849
+ currentRadius,
850
+ distToCenter
851
+ );
852
+
853
+ vec3 highBrightnessColor = uDiffusionColor * 5.0;
854
+ diffuseColor.rgb += highBrightnessColor * (1.0 - ringFactor);
855
+ diffuseColor.rgb = min(diffuseColor.rgb, vec3(2.0));
856
+ }
857
+ }
683
858
 
684
- // ================= 保留原有其他效果 =================
685
- // 流光效果(保持不变)
859
+ // 流光效果
686
860
  if (uFlowEnabled == 1) {
687
861
  float dTime = mod(time * uFlowSpeed, uFlowRange * 2.0);
688
862
  if (vPosition.z > dTime - uFlowRange && vPosition.z < dTime) {
@@ -691,7 +865,7 @@
691
865
  }
692
866
  }
693
867
 
694
- // 扫光效果(保持不变)
868
+ // 扫光效果
695
869
  if (uSweepEnabled == 1) {
696
870
  float sweepPos = mod(time * uSweepSpeed, 2.0);
697
871
  if (vHeight > sweepPos - uSweepWidth && vHeight < sweepPos) {
@@ -699,4 +873,101 @@
699
873
  diffuseColor.rgb = mix(uSweepColor, diffuseColor.rgb, 1.0 - sweepFactor);
700
874
  }
701
875
  }
702
- `)}setDiffusionFromObject(e){if(!this.shaderOption.effects?.diffusion)return;const n=new se.Box3().setFromObject(e);if(n.isEmpty())return;const i=new se.Vector3;n.getCenter(i);const r=[new se.Vector3(n.min.x,n.min.y,n.min.z),new se.Vector3(n.max.x,n.max.y,n.max.z)];let s=0;r.forEach(a=>{const l=i.distanceTo(a);l>s&&(s=l)}),this.shaderOption.effects.diffusion={...this.shaderOption.effects.diffusion,center:i,maxDistance:s},this.needsUpdate=!0}updateBoundingBox(e,n){this.shaderOption.minY=e,this.shaderOption.maxY=n,this.needsUpdate=!0}updateEffects(e){this.shaderOption.effects={...this.shaderOption.effects,...e},this.needsUpdate=!0}animate(){requestAnimationFrame(()=>this.animate()),this.time.value=this.clock.getElapsedTime(),this.startTime.value<1&&(this.startTime.value+=.01)}}const Yo={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class fi extends bt{constructor(e){super(e);x(this,"_type","Model");x(this,"_emissive",!1);x(this,"_emissiveIntensity",1);x(this,"_emissiveColor","#ffffff");x(this,"_mixer",null);x(this,"_currentAction",null);x(this,"_animations",[]);x(this,"_clock",new h.Clock);x(this,"_autoUpdate",!0);x(this,"_animationRequestId",null);x(this,"_iscity",!1);this._emissive=e.emissive||!1,this._emissiveIntensity=e.emissiveIntensity||1,this._emissiveColor=e.emissiveColor||"#ffffff",this.castShadow=e.castShadow||!1,this.receiveShadow=e.receiveShadow||!1,this._iscity=e.iscity||!1}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this.modelunino=await this._createObject(this._style),this._threeGeometry=this.modelunino.model,this.modelunino.animations&&this.modelunino.animations.length>0&&(this._animations=this.modelunino.animations,this._mixer=new h.AnimationMixer(this._threeGeometry),this._startAnimationLoop(),this.playAnimation({name:this._animations[0].name,loop:!0,speed:1.5,fadeInDuration:.5,fadeOutDuration:.3})),this._updateGeometry(),this.setShadows({cast:this.castShadow,receive:this.receiveShadow}),this._applyEmissionProperties(),this._iscity&&this._rendercity())}async _createObject(e){switch(e.config.type){case"fbx":case"gltf":return xo(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_applyEmissionProperties(){this._threeGeometry&&this._threeGeometry.traverse(e=>{if("material"in e){const n=e.material;n&&(n.emissiveIntensity=this._emissive?this._emissiveIntensity:0,n.emissive&&n.emissive.setStyle(this._emissiveColor))}})}get emissive(){return this._emissive}set emissive(e){this._emissive=e,this._applyEmissionProperties()}get emissiveIntensity(){return this._emissiveIntensity}set emissiveIntensity(e){this._emissiveIntensity=e,this._applyEmissionProperties()}get emissiveColor(){return this._emissiveColor}set emissiveColor(e){this._emissiveColor=e,this._applyEmissionProperties()}setEmission(e,n,i){this._emissive=e,n!==void 0&&(this._emissiveIntensity=n),i!==void 0&&(this._emissiveColor=i),this._applyEmissionProperties()}async setShadows(e){this.castShadow=e.cast,this.receiveShadow=e.receive,this._threeGeometry&&this._threeGeometry.traverse(n=>{n.isMesh&&n.material&&(n.castShadow=e.cast,n.receiveShadow=e.receive)})}playAnimation(e){if(!this._mixer||this._animations.length===0){console.warn("模型没有可用的动画");return}this._currentAction&&(e.fadeOutDuration&&e.fadeOutDuration>0?this._currentAction.fadeOut(e.fadeOutDuration):this._currentAction.stop());const n=typeof e.name=="number"?this._animations[e.name]:this._animations.find(i=>i.name===e.name);if(!n){console.warn(`找不到动画: ${e.name}`);return}this._currentAction=this._mixer.clipAction(n),this._currentAction.setLoop(e.loop?h.LoopRepeat:h.LoopOnce,e.loop?1/0:1),this._currentAction.timeScale=e.speed||1,this._currentAction.time=e.startAt||0,this._currentAction.setEffectiveWeight(e.weight||1),e.fadeInDuration&&e.fadeInDuration>0&&this._currentAction.fadeIn(e.fadeInDuration),this._currentAction.play(),this._autoUpdate&&this._animationRequestId===null&&this._startAnimationLoop()}stopAnimation(e={}){this._currentAction&&(e.fadeDuration&&e.fadeDuration>0?(this._currentAction.fadeOut(e.fadeDuration),setTimeout(()=>{this._currentAction&&(this._currentAction.stop(),this._currentAction=null)},e.fadeDuration*1e3)):(this._currentAction.stop(),this._currentAction=null))}setAnimationPaused(e){this._currentAction&&(this._currentAction.paused=e.paused)}setAnimationSpeed(e){this._currentAction&&(this._currentAction.timeScale=e.speed)}updateAnimation(e){this._mixer&&this._mixer.update(e.deltaTime)}getAnimationNames(){return this._animations.map(e=>e.name)}getCurrentAnimationName(){return this._currentAction?this._currentAction.getClip().name:null}getAnimationDuration(e){let n;return typeof e.name=="number"?n=this._animations[e.name]:n=this._animations.find(i=>i.name===e.name),n?n.duration:null}dispose(){this._stopAnimationLoop(),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._threeGeometry)),super.dispose()}_startAnimationLoop(){if(!this._autoUpdate||this._animationRequestId!==null)return;const e=()=>{if(this._mixer){const n=this._clock.getDelta();this._mixer.update(n)}this._animationRequestId=requestAnimationFrame(e)};this._clock.start(),this._animationRequestId=requestAnimationFrame(e)}_stopAnimationLoop(){this._animationRequestId!==null&&(cancelAnimationFrame(this._animationRequestId),this._animationRequestId=null),this._clock.stop()}setAutoUpdate(e){this._autoUpdate=e,e?this._startAnimationLoop():this._stopAnimationLoop()}_rendercity(){this.traverse(e=>{if(e instanceof h.Mesh&&e.material){if(e.castShadow=!0,e.castShadow=!0,e.name==="building"){const n=new Uo({color:new h.Color("#6BA7EC").multiplyScalar(1.4),opacity:.8,shaderOption:{minY:0,maxY:50,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!0,color:new h.Color("#FFFFF"),width:80,speed:.16666666666666666},flow:{enabled:!1,color:new h.Color("#FFFFF"),range:1e3,speed:3e3},sweep:{enabled:!0,color:new h.Color("#ffffff"),width:3,speed:5}}}}),i=new h.Box3().setFromObject(e);n.updateBoundingBox(i.min.y,i.max.y),n.setDiffusionFromObject(e),e.material=n,e.material.needsUpdate=!0}e.name==="grass"&&(e.castShadow=!1,e.material.emissiveIntensity=.1,e.material.emissive=new h.Color("#3FD3BD"),e.material.needsUpdate=!0)}})}}fi.mergeOptions(Yo);const Ko={};class mi extends bt{constructor(e){super(e);x(this,"_type","Cloud")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._disposeGeometry();const e=this.getLayer();this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry.renderOrder=1e3,e&&(e._clouds.add(this._threeGeometry),e._clouds.updateMatrixWorld()))}async _createObject(e){switch(e.config.type){case"cloud":return Zo(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}mi.mergeOptions(Ko);const Bo={};class yi extends bt{constructor(e){super(e);x(this,"_type","Label")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),console.log(this._threeGeometry," this._threeGeometry this._threeGeometry this._threeGeometry this._threeGeometry this._threeGeometry this._threeGeometry this._threeGeometry "),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"canvas-label-fixed":return To(e.config,new h.Vector3(0,0,0),this.getMap());case"canvas-label":return Io(e.config,new h.Vector3(0,0,0));default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}yi.mergeOptions(Bo),console.log("%c✨ terra.gl V"+Zi+" ","color:rgb(255, 255, 255); font-weight: bold; background: linear-gradient(90deg, #ffb6c1, #ff69b4); padding: 5px; border-radius: 5px;"),N.ArcGisDemSource=mo,N.ArcGisSource=fo,N.CloudsLayer=ko,N.EventClass=ei,N.ICloud=mi,N.Label=yi,N.LineLayer=Go,N.LineString=hi,N.Maker=ci,N.Map=ft,N.MapBoxSource=yo,N.Model=fi,N.MultiLineString=pi,N.PointLayer=Vo,N.Polygon=di,N.PolygonLayer=Co,N.TDTQMSource=ho,N.TDTSource=uo,N.Viewer=Cn,N.WMTSSource=po,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
876
+ // 区域多边形外衣叠色(Ray casting 判定点是否在多边形内)
877
+ if (uRegionOverlayEnabled == 1 && uRegionOverlayOpacity > 0.0 && uRegionOverlayVertexCount >= 3) {
878
+ vec2 p = vec2(vWorldPosition.x, vWorldPosition.z);
879
+ bool inside = false;
880
+ int j = 0;
881
+ for (int i = 0; i < REGION_OVERLAY_MAX_VERTS; i++) {
882
+ if (i >= uRegionOverlayVertexCount) break;
883
+ if (i == 0) {
884
+ j = uRegionOverlayVertexCount - 1;
885
+ }
886
+ vec2 pi = uRegionOverlayVertices[i];
887
+ vec2 pj = uRegionOverlayVertices[j];
888
+
889
+ bool intersect = ((pi.y > p.y) != (pj.y > p.y)) &&
890
+ (p.x < (pj.x - pi.x) * (p.y - pi.y) / (pj.y - pi.y + 1e-6) + pi.x);
891
+ if (intersect) {
892
+ inside = !inside;
893
+ }
894
+ j = i;
895
+ }
896
+
897
+ if (inside) {
898
+ diffuseColor.rgb = mix(
899
+ diffuseColor.rgb,
900
+ uRegionOverlayColor,
901
+ clamp(uRegionOverlayOpacity, 0.0, 1.0)
902
+ );
903
+ }
904
+ }
905
+ `)}setDiffusionFromObject(e){if(!this.shaderOption.effects?.diffusion)return;const t=new ct.Box3().setFromObject(e);if(t.isEmpty())return;const n=new ct.Vector3;t.getCenter(n);const r=[new ct.Vector3(t.min.x,t.min.y,t.min.z),new ct.Vector3(t.max.x,t.max.y,t.max.z)];let o=0;r.forEach(a=>{const c=n.distanceTo(a);c>o&&(o=c)}),this.shaderOption.effects.diffusion={...this.shaderOption.effects.diffusion,center:n,maxDistance:o},this.needsUpdate=!0}updateBoundingBox(e,t){this.shaderOption.minY=e,this.shaderOption.maxY=t,this.needsUpdate=!0}updateEffects(e){this.shaderOption.effects={...this.shaderOption.effects,...e},this.needsUpdate=!0}animate(){requestAnimationFrame(()=>this.animate()),this.time.value=this.clock.getElapsedTime(),this.startTime.value<1&&(this.startTime.value+=.01)}}var K0=Object.defineProperty,N0=(i,e,t)=>e in i?K0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,tn=(i,e,t)=>N0(i,typeof e!="symbol"?e+"":e,t);const B0={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class $c extends en{constructor(e){super(e),tn(this,"_type","Model"),tn(this,"_emissive",!1),tn(this,"_emissiveIntensity",1),tn(this,"_emissiveColor","#ffffff"),tn(this,"_mixer",null),tn(this,"_currentAction",null),tn(this,"_animations",[]),tn(this,"_clock",new p.Clock),tn(this,"_autoUpdate",!0),tn(this,"_animationRequestId",null),tn(this,"_iscity",!1),this._emissive=e.emissive||!1,this._emissiveIntensity=e.emissiveIntensity||1,this._emissiveColor=e.emissiveColor||"#ffffff",this.castShadow=e.castShadow||!1,this.receiveShadow=e.receiveShadow||!1,this._iscity=e.iscity||!1}async _toThreeJSGeometry(){if(this._position=this._coordsTransform(),this._style){if(this._threeGeometry&&this._disposeGeometry(),this.modelunino=await this._createObject(this._style),this._threeGeometry=this.modelunino.model,!this._threeGeometry){console.error("Model load failed: model returned by _createObject is undefined"),console.error("模型加载失败:_createObject返回的model为undefined");return}this._threeGeometry.userData._type="Model",this.modelunino.animations&&this.modelunino.animations.length>0&&(this._animations=this.modelunino.animations,this._mixer=new p.AnimationMixer(this._threeGeometry),this._startAnimationLoop(),this.playAnimation({name:this._animations[0].name,loop:!0,speed:1.5,fadeInDuration:.5,fadeOutDuration:.3})),this._updateGeometry(),this.setShadows({cast:this.castShadow,receive:this.receiveShadow}),this._applyEmissionProperties(),this._iscity&&this._rendercity(),this.trigger("loaded",{timestamp:yc(),targrt:this})}}async _createObject(e){switch(e.config.type){case"fbx":case"gltf":return ng(e.config,this._position);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}_applyEmissionProperties(){this._threeGeometry&&this._threeGeometry.traverse(e=>{if("material"in e){const t=e.material;t&&(t.emissiveIntensity=this._emissive?this._emissiveIntensity:0,t.emissive&&t.emissive.setStyle(this._emissiveColor))}})}get emissive(){return this._emissive}set emissive(e){this._emissive=e,this._applyEmissionProperties()}get emissiveIntensity(){return this._emissiveIntensity}set emissiveIntensity(e){this._emissiveIntensity=e,this._applyEmissionProperties()}get emissiveColor(){return this._emissiveColor}set emissiveColor(e){this._emissiveColor=e,this._applyEmissionProperties()}setEmission(e,t,n){this._emissive=e,t!==void 0&&(this._emissiveIntensity=t),n!==void 0&&(this._emissiveColor=n),this._applyEmissionProperties()}async setShadows(e){this.castShadow=e.cast,this.receiveShadow=e.receive,this._threeGeometry&&this._threeGeometry.traverse(t=>{t.isMesh&&t.material&&(t.castShadow=e.cast,t.receiveShadow=e.receive)})}playAnimation(e){if(!this._mixer||this._animations.length===0){console.warn("No available animations for model"),console.warn("模型没有可用的动画");return}this._currentAction&&(e.fadeOutDuration&&e.fadeOutDuration>0?this._currentAction.fadeOut(e.fadeOutDuration):this._currentAction.stop());const t=typeof e.name=="number"?this._animations[e.name]:this._animations.find(n=>n.name===e.name);if(!t){console.warn(`Animation not found: ${e.name}`),console.warn(`找不到动画: ${e.name}`);return}this._currentAction=this._mixer.clipAction(t),this._currentAction.setLoop(e.loop?p.LoopRepeat:p.LoopOnce,e.loop?1/0:1),this._currentAction.timeScale=e.speed||1,this._currentAction.time=e.startAt||0,this._currentAction.setEffectiveWeight(e.weight||1),e.fadeInDuration&&e.fadeInDuration>0&&this._currentAction.fadeIn(e.fadeInDuration),this._currentAction.play(),this._autoUpdate&&this._animationRequestId===null&&this._startAnimationLoop()}stopAnimation(e={}){this._currentAction&&(e.fadeDuration&&e.fadeDuration>0?(this._currentAction.fadeOut(e.fadeDuration),setTimeout(()=>{this._currentAction&&(this._currentAction.stop(),this._currentAction=null)},e.fadeDuration*1e3)):(this._currentAction.stop(),this._currentAction=null))}setAnimationPaused(e){this._currentAction&&(this._currentAction.paused=e.paused)}setAnimationSpeed(e){this._currentAction&&(this._currentAction.timeScale=e.speed)}updateAnimation(e){this._mixer&&this._mixer.update(e.deltaTime)}getAnimationNames(){return this._animations.map(e=>e.name)}getCurrentAnimationName(){return this._currentAction?this._currentAction.getClip().name:null}getAnimationDuration(e){let t;return typeof e.name=="number"?t=this._animations[e.name]:t=this._animations.find(n=>n.name===e.name),t?t.duration:null}dispose(){this._stopAnimationLoop(),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._threeGeometry)),super.dispose()}_startAnimationLoop(){if(!this._autoUpdate||this._animationRequestId!==null)return;const e=()=>{if(this._mixer){const t=this._clock.getDelta();this._mixer.update(t)}this._animationRequestId=requestAnimationFrame(e)};this._clock.start(),this._animationRequestId=requestAnimationFrame(e)}_stopAnimationLoop(){this._animationRequestId!==null&&(cancelAnimationFrame(this._animationRequestId),this._animationRequestId=null),this._clock.stop()}setAutoUpdate(e){this._autoUpdate=e,e?this._startAnimationLoop():this._stopAnimationLoop()}_computeOverlayVertices(e){const t=e.feature;if(t&&Array.isArray(t._vertexPoints)&&t._vertexPoints.length>=6){const u=t.getMap?.()||this.getMap();if(u&&u.prjcenter){const d=u.prjcenter,m=t._vertexPoints,f=[];for(let g=0;g+2<m.length;g+=3){const _=m[g],w=m[g+2],b=d.x+_,x=d.z+w;f.push(new p.Vector2(b,x))}if(f.length>=3)return f}}const n=this.getMap();if(!n||!e.geometry)return null;const r=e.geometry;let o;if(r.type==="Polygon")o=r.coordinates;else if(r.type==="MultiPolygon"){if(!r.coordinates.length)return null;o=r.coordinates[0]}else return null;if(!o.length||!o[0].length)return null;const a=o[0],c=[];for(const u of a){const d=u[0],m=u[1],f=n.geo2world(new p.Vector3(d,m,0));c.push(new p.Vector2(f.x,f.z))}return c.length<3?null:c}_rendercity(){const e=this.getLayer();let t=null;if(e&&e.getRegionOverlays){const n=e.getRegionOverlays()||[];if(n.length){const r=n.filter(a=>(a.mode??"overlay")==="overlay").sort((a,c)=>(a.zIndex??0)-(c.zIndex??0)),o=r[r.length-1];if(o&&(o.geometry||o.feature)){const a=this._computeOverlayVertices(o);a&&a.length>=3&&(t={color:new p.Color(o.color??"#00FF88"),opacity:o.opacity??.3,vertices:a})}}}this.traverse(async n=>{if(n instanceof p.Mesh&&n.material){if(n.castShadow=!0,n.name==="building"){const r=new k0({color:new p.Color("#6BA7EC").multiplyScalar(1.8),opacity:.9,shaderOption:{minY:0,maxY:50,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!0,color:new p.Color("#FFFFF"),width:300,speed:.05},flow:{enabled:!1,color:new p.Color("#FFFFF"),range:1e3,speed:3e3},sweep:{enabled:!0,color:new p.Color("#ffffff"),width:3,speed:5}}},regionOverlay:t||void 0}),o=new p.Box3().setFromObject(n);r.updateBoundingBox(o.min.y,o.max.y),r.setDiffusionFromObject(n),n.receiveShadow=!1,n.material=r,n.material.needsUpdate=!0}n.name==="grass"&&(n.castShadow=!1,n.receiveShadow=!0,n.material.color=new p.Color("#81e4d8ff)").multiplyScalar(.7),n.material.metalness=.2,n.material.roughness=.8,["metalnessMap","normalMap","roughnessMap","specularColorMap"].forEach(r=>{const o=n.material[r];o&&(o.wrapS=o.wrapT=p.RepeatWrapping,o.repeat.set(.3,.3),o.needsUpdate=!0)}),n.material.normalScale=new p.Vector2(3,3))}})}}$c.mergeOptions(B0);var Y0=Object.defineProperty,R0=(i,e,t)=>e in i?Y0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,j0=(i,e,t)=>R0(i,e+"",t);const J0={};class qc extends en{constructor(e){super(e),j0(this,"_type","Cloud")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._disposeGeometry();const e=this.getLayer();this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry.renderOrder=99,e&&(e._clouds.add(this._threeGeometry),e._clouds.updateMatrixWorld()))}async _createObject(e){switch(e.config.type){case"cloud":return ag(e.config,this._position);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}qc.mergeOptions(J0);var Q0=Object.defineProperty,H0=(i,e,t)=>e in i?Q0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,E0=(i,e,t)=>H0(i,e+"",t);const $0={};class eu extends en{constructor(e){super(e),E0(this,"_type","Label")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometryPositions(){this._position=this._coordsTransform(),this._threeGeometry?(this._threeGeometry.position.copy(this._position),this.children.includes(this._threeGeometry)||this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0)):this._toThreeJSGeometry()}async _createObject(e){switch(e.config.type){case"canvas-label-fixed":return cg(e.config,new p.Vector3(0,0,0),this.getMap());case"canvas-label":return lg(e.config,new p.Vector3(0,0,0));default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}eu.mergeOptions($0);var q0=Object.defineProperty,ey=(i,e,t)=>e in i?q0(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,tu=(i,e,t)=>ey(i,typeof e!="symbol"?e+"":e,t);const ty={};class nu extends en{constructor(e){super(e),tu(this,"_type","TPoints"),tu(this,"_geometries"),this._geometries=e.geometries}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._threeGeometry&&(this._threeGeometry.points&&this.add(this._threeGeometry.points),this._threeGeometry.InstancedCol&&this.add(this._threeGeometry.InstancedCol),this.updateMatrixWorld(!0))}async _createObject(e){switch(e.config.type){case"light":return _g(e.config,this._geometries,this.getMap());default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}nu.mergeOptions(ty);var ny=Object.defineProperty,ry=(i,e,t)=>e in i?ny(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Rn=(i,e,t)=>ry(i,typeof e!="symbol"?e+"":e,t);class Ci extends Kn(Object){constructor(e,t){super(),Rn(this,"options"),Rn(this,"map"),Rn(this,"_sprite",null),Rn(this,"_isDragging",!1),Rn(this,"_dragStartPosition",null),Rn(this,"_lastCoordinate",null),Rn(this,"_boundOnMouseMove",null),Rn(this,"_boundOnMouseUp",null),this.map=t,this.options={position:e.position,index:e.index,symbol:e.symbol??0,size:e.size??8,color:e.color??"#ffffff",opacity:e.opacity??.9,draggable:e.draggable??!0},this._createSprite(),this._boundOnMouseMove=this._onMouseMove.bind(this),this._boundOnMouseUp=this._onMouseUp.bind(this)}_createSprite(){const t=document.createElement("canvas"),n=t.getContext("2d");t.width=64,t.height=64;const r=64/2,o=64/2-2;n.clearRect(0,0,t.width,t.height),n.beginPath(),n.arc(r,r,o,0,2*Math.PI),n.fillStyle="#000000",n.fill(),n.beginPath(),n.arc(r,r,o-2,0,2*Math.PI),n.fillStyle=this.options.color,n.fill();const a=new p.CanvasTexture(t);a.needsUpdate=!0;const c=new p.SpriteMaterial({map:a,opacity:this.options.opacity,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!0});this._sprite=new p.Sprite(c),this._sprite.position.copy(this.options.position),this._sprite.renderOrder=999999;const u=new p.Vector2;this._sprite.onBeforeRender=(d,m,f)=>{if(!this._sprite||!f)return;const g=f.position.distanceTo(this._sprite.position);d.getSize(u);const _=d.getPixelRatio(),w=this.options.size*_;let b=1;if(f.isPerspectiveCamera){const x=f.fov*Math.PI/180,L=2*Math.tan(x/2)*g;b=w/u.y*L}else if(f.isOrthographicCamera){const x=f.top,L=f.bottom,M=Math.abs(x-L)/f.zoom;b=w/u.y*M}this._sprite.scale.set(b,b,1)},this._sprite._editHandle=this,this.map.viewer.scene.add(this._sprite)}updatePosition(e){this.options.position=e,this._sprite&&this._sprite.position.copy(e)}getPosition(){return this.options.position.clone()}getIndex(){return this.options.index}getSymbol(){return this.options.symbol}getSprite(){return this._sprite}intersect(e){return!this._sprite||!this.options.draggable?!1:e.intersectObject(this._sprite).length>0}startDrag(e){this.options.draggable&&(this._isDragging=!0,this._dragStartPosition=this.options.position.clone(),this._lastCoordinate=e,this.map.viewer.config("draggable",!1),this.map.on("mousemove",this._boundOnMouseMove),this.map.on("mouseup",this._boundOnMouseUp),this.trigger("dragstart",{target:this,coordinate:e,position:this.options.position.clone()}))}_onMouseMove(e){if(!this._isDragging||!this._lastCoordinate)return;const t=e.coordinate,n=t[0]-this._lastCoordinate[0],r=t[1]-this._lastCoordinate[1],o=this.map.world2geo(this.options.position),a=this.map.geo2world(new p.Vector3(t[0],t[1],o.z));this.updatePosition(a),this._lastCoordinate=t,this.trigger("dragging",{target:this,coordinate:t,position:this.options.position.clone(),offset:{dx:n,dy:r}})}_onMouseUp(e){this._isDragging&&(this._isDragging=!1,this.map.viewer.config("draggable",!0),this.map.off("mousemove",this._boundOnMouseMove),this.map.off("mouseup",this._boundOnMouseUp),this.trigger("dragend",{target:this,coordinate:e.coordinate,position:this.options.position.clone(),startPosition:this._dragStartPosition}),this._dragStartPosition=null,this._lastCoordinate=null)}show(){this._sprite&&(this._sprite.visible=!0)}hide(){this._sprite&&(this._sprite.visible=!1)}remove(){if(this._isDragging&&(this._isDragging=!1,this.map.viewer.config("draggable",!0),this.map.off("mousemove",this._boundOnMouseMove),this.map.off("mouseup",this._boundOnMouseUp)),this._sprite){this.map.viewer.scene.remove(this._sprite);const e=this._sprite.material;e.map&&e.map.dispose(),e.dispose(),this._sprite=null}this._dragStartPosition=null,this._lastCoordinate=null,this._boundOnMouseMove=null,this._boundOnMouseUp=null}}function ta(i,e,t){const{currentTarget:n,clientX:r,clientY:o}=i;if(n instanceof HTMLElement){const a=n.clientWidth,c=n.clientHeight,u=new p.Vector2(r/a*2-1,-(o/c)*2+1);return e.getLocalInfoFromScreen(t,u)?.location}else return}var iy=Object.defineProperty,sy=(i,e,t)=>e in i?iy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ht=(i,e,t)=>sy(i,typeof e!="symbol"?e+"":e,t);class oy extends ls{constructor(e,t){super(e),ht(this,"options"),ht(this,"_handles",[]),ht(this,"_middleHandles",[]),ht(this,"_middleHandleColor","rgba(255, 255, 255, 0.6)"),ht(this,"_editing",!1),ht(this,"_shadow",null),ht(this,"_shadowSnapshot",null),ht(this,"_updating",!1),ht(this,"_history",[]),ht(this,"_historyIndex",-1),ht(this,"_draggableOriginalState",!1),ht(this,"_boundOnMapMouseMove",null),ht(this,"_boundOnMapClick",null),ht(this,"_boundOnMapMouseDown",null),ht(this,"_boundOnFeatureDragging",null),ht(this,"_boundOnFeatureDragEnd",null),this.options={handleSize:t?.handleSize??8,handleColor:t?.handleColor??"#ffffff",showMiddleHandles:t?.showMiddleHandles??!1,maxHistorySize:t?.maxHistorySize??20,removeVertexOn:t?.removeVertexOn??"contextmenu"},this._boundOnMapMouseMove=this._onMapMouseMove.bind(this),this._boundOnMapClick=this._onMapClick.bind(this),this._boundOnMapMouseDown=this._onMapMouseDown.bind(this),this._boundOnFeatureDragging=this._onFeatureDragging.bind(this),this._boundOnFeatureDragEnd=this._onFeatureDragEnd.bind(this)}enable(){return this._editing?this:(super.enable(),this._editing=!0,this._createShadow(),this._saveSnapshot(),this._setFeatureEditingStyle(!0),this._createHandles(),this.target.trigger("editstart"),this._draggableOriginalState=this.target.options.draggable||!1,this._draggableOriginalState||(this.target.options.draggable=!0,this.target.draggable&&this.target.draggable.enable()),this)}disable(){return this._editing?(super.disable(),this._editing=!1,this._clearHandles(),this._setFeatureEditingStyle(!1),this._draggableOriginalState||(this.target.options.draggable=!1,this.target.draggable&&this.target.draggable.disable()),this._draggableOriginalState=!1,this._updateCoordFromShadow(),this._removeShadow(),this.target.trigger("editend"),this):this}addHooks(){const e=this._getMap();e&&(e.on("mousemove",this._boundOnMapMouseMove),e.on("click",this._boundOnMapClick),e.viewer.container&&e.viewer.container.addEventListener("mousedown",this._boundOnMapMouseDown,!0),this.options.removeVertexOn==="contextmenu"&&e.on("contextmenu",this._boundOnMapClick)),this.target.on("dragging",this._boundOnFeatureDragging),this.target.on("dragend",this._boundOnFeatureDragEnd)}removeHooks(){const e=this._getMap();e&&(e.off("mousemove",this._boundOnMapMouseMove),e.off("click",this._boundOnMapClick),e.viewer.container&&e.viewer.container.removeEventListener("mousedown",this._boundOnMapMouseDown,!0),this.options.removeVertexOn==="contextmenu"&&e.off("contextmenu",this._boundOnMapClick)),this.target.off("dragging",this._boundOnFeatureDragging),this.target.off("dragend",this._boundOnFeatureDragEnd)}isEditing(){return this._editing}_createShadow(){this._shadow=null}_removeShadow(){this._shadow&&(this._shadow=null),this._shadowSnapshot=null}_updateCoordFromShadow(e=!1){e&&!this._updating&&this.target._onPositionChanged(!0)}_saveSnapshot(){const e=this.target._geometry;this._shadowSnapshot={type:e.type,coordinates:JSON.parse(JSON.stringify(e.coordinates))},this._addHistory(e.coordinates)}_addHistory(e){this._historyIndex<this._history.length-1&&(this._history=this._history.slice(0,this._historyIndex+1)),this._history.push({coordinates:JSON.parse(JSON.stringify(e)),timestamp:Date.now()}),this._history.length>this.options.maxHistorySize?this._history.shift():this._historyIndex++}undo(){if(this._historyIndex>0){this._historyIndex--;const e=this._history[this._historyIndex];this._restoreCoordinates(e.coordinates),this.target.trigger("editundo")}return this}redo(){if(this._historyIndex<this._history.length-1){this._historyIndex++;const e=this._history[this._historyIndex];this._restoreCoordinates(e.coordinates),this.target.trigger("editredo")}return this}_restoreCoordinates(e){const t=this.target._geometry;t.coordinates=JSON.parse(JSON.stringify(e)),this.target._onPositionChanged(!0),this._updateHandlePositions()}cancel(){return this._shadowSnapshot&&this._restoreCoordinates(this._shadowSnapshot.coordinates),this.disable(),this}_createHandles(){const e=this.target._geometry,t=this._getMap();if(!t){console.warn("[FeatureEditHandler] No map found, cannot create handles");return}this.target instanceof en?this._createPointHandles(e,t):this.target instanceof Mt?this._createLineStringHandles(e,t):this.target instanceof _n&&this._createPolygonHandles(e,t)}_createPointHandles(e,t){const n=e.coordinates,r=t.geo2world(new p.Vector3(n[0],n[1],n[2]||0)),o=new Ci({position:r,index:0,symbol:0,size:this.options.handleSize,color:this.options.handleColor},t);o.on("dragstart",a=>{this._onHandleDragStart(a,0)}),o.on("dragging",a=>{this._onHandleDragging(a,0)}),o.on("dragend",a=>{this._onHandleDragEnd(a,0)}),this._handles.push(o)}_createLineStringHandles(e,t){const n=e.coordinates;n.forEach((r,o)=>{const a=t.geo2world(new p.Vector3(r[0],r[1],r[2]||0)),c=new Ci({position:a,index:o,symbol:0,size:this.options.handleSize,color:this.options.handleColor},t);c.on("dragstart",u=>{this._onHandleDragStart(u,o)}),c.on("dragging",u=>{this._onHandleDragging(u,o)}),c.on("dragend",u=>{this._onHandleDragEnd(u,o)}),this._handles.push(c)}),this.options.showMiddleHandles&&this._createLineStringMiddleHandles(n,t)}_onHandleDragging(e,t){this._updating=!0;const r=e.target.getPosition();if(!this._getMap())return;const a=this._fixHandlePointCoordinates(r,t),c=this.target._geometry;this.target instanceof en?c.coordinates=[a.x,a.y,a.z]:this.target instanceof Mt&&(c.coordinates[t]=[a.x,a.y,a.z]),this.target._onPositionChanged(!0),this.target.trigger("handledragging",{index:t,coordinate:[a.x,a.y,a.z]}),this.target.trigger("editing",{index:t,coordinate:[a.x,a.y,a.z]}),this._updating=!1}_onHandleDragStart(e,t){this._updating=!0,this.target.trigger("handledragstart",{index:t,coordinate:e.coordinate})}_onHandleDragEnd(e,t){this._updating=!1;const n=this.target._geometry;this._addHistory(n.coordinates),this.target.trigger("handledragend",{index:t,coordinate:this.target instanceof en?n.coordinates:n.coordinates[t]}),this.target.trigger("editvertex",{index:t,coordinate:this.target instanceof en?n.coordinates:n.coordinates[t]})}_createPolygonHandles(e,t){const n=e.coordinates;if(!n||!Array.isArray(n)||n.length===0){console.warn("[FeatureEditHandler] Invalid polygon coordinates");return}n.forEach((o,a)=>{if(!o||o.length<3)return;const c=o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]?o.length-1:o.length;for(let u=0;u<c;u++){const d=o[u],m=t.geo2world(new p.Vector3(d[0],d[1],d[2]||0)),f=new Ci({position:m,index:u,symbol:0,size:this.options.handleSize,color:this.options.handleColor},t);f._ringIndex=a,f.on("dragstart",g=>{this._onPolygonHandleDragStart(g,u,a)}),f.on("dragging",g=>{this._onPolygonHandleDragging(g,u,a)}),f.on("dragend",g=>{this._onPolygonHandleDragEnd(g,u,a)}),this._handles.push(f)}this.options.showMiddleHandles&&this._createPolygonMiddleHandles(o,a,t)})}_onPolygonHandleDragStart(e,t,n){this._updating=!0,this.target.trigger("handledragstart",{index:t,ringIndex:n,coordinate:e.coordinate})}_onPolygonHandleDragging(e,t,n){const o=e.target.getPosition();if(!this._getMap())return;const c=this._fixHandlePointCoordinates(o,t,n),d=this.target._geometry.coordinates;if(d[n]&&d[n][t]&&(d[n][t]=[c.x,c.y,c.z],t===0&&d[n].length>1)){const m=d[n].length-1;d[n][m]=[c.x,c.y,c.z]}this.target._onPositionChanged(!0),this.target.trigger("handledragging",{index:t,ringIndex:n,coordinate:[c.x,c.y,c.z]}),this.target.trigger("editing",{index:t,ringIndex:n,coordinate:[c.x,c.y,c.z]})}_onPolygonHandleDragEnd(e,t,n){this._updating=!1;const r=this.target._geometry,o=r.coordinates;this._addHistory(r.coordinates),this.target.trigger("handledragend",{index:t,ringIndex:n,coordinate:o[n]?.[t]||null}),this.target.trigger("editvertex",{index:t,ringIndex:n,coordinate:o[n]?.[t]||null})}_updateHandlePositions(){const e=this.target._geometry,t=this._getMap();if(t){if(this.target instanceof en){const n=e.coordinates,r=t.geo2world(new p.Vector3(n[0],n[1],n[2]||0));this._handles[0]&&this._handles[0].updatePosition(r)}else if(this.target instanceof Mt)e.coordinates.forEach((r,o)=>{const a=t.geo2world(new p.Vector3(r[0],r[1],r[2]||0));this._handles[o]&&this._handles[o].updatePosition(a)});else if(this.target instanceof _n){const n=e.coordinates;let r=0;n.forEach(o=>{const a=o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]?o.length-1:o.length;for(let c=0;c<a;c++){const u=o[c],d=t.geo2world(new p.Vector3(u[0],u[1],u[2]||0));this._handles[r]&&this._handles[r].updatePosition(d),r++}})}}}_clearHandles(){this._handles.forEach(e=>e.remove()),this._handles=[],this._middleHandles.forEach(e=>e.remove()),this._middleHandles=[]}_onFeatureDragging(e){this._updateHandlePositions(),this.options.showMiddleHandles&&this._updateMiddleHandlePositions()}_onFeatureDragEnd(e){const t=this.target._geometry;this._addHistory(t.coordinates),this._updateHandlePositions(),this.options.showMiddleHandles&&this._updateMiddleHandlePositions()}_updateMiddleHandlePositions(){const e=this.target._geometry,t=this._getMap();if(!t)return;let n=0;if(this.target instanceof Mt){const r=e.coordinates;for(let o=0;o<r.length-1&&!(n>=this._middleHandles.length);o++){const a=r[o],c=r[o+1],u=[(a[0]+c[0])/2,(a[1]+c[1])/2,((a[2]||0)+(c[2]||0))/2],d=t.geo2world(new p.Vector3(u[0],u[1],u[2]));this._middleHandles[n].updatePosition(d),n++}}else this.target instanceof _n&&e.coordinates.forEach(o=>{const a=o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]?o.length-1:o.length;for(let c=0;c<a&&!(n>=this._middleHandles.length);c++){const u=(c+1)%a,d=o[c],m=o[u],f=[(d[0]+m[0])/2,(d[1]+m[1])/2,((d[2]||0)+(m[2]||0))/2],g=t.geo2world(new p.Vector3(f[0],f[1],f[2]));this._middleHandles[n].updatePosition(g),n++}})}_onMapMouseDown(e){const t=this._getMap();if(!t)return;const n=new p.Raycaster;n.params.Points={threshold:.5};const r=e,o=t.viewer.renderer.domElement,a=o.getBoundingClientRect(),c=new p.Vector2((r.clientX-a.left)/a.width*2-1,-((r.clientY-a.top)/a.height)*2+1);n.setFromCamera(c,t.viewer.camera);const u=[...this._handles,...this._middleHandles];for(const d of u)if(d.intersect(n)){const m=ta({currentTarget:o,clientX:r.clientX,clientY:r.clientY},t.tilemap,t.viewer.camera);m&&(d.startDrag([m.x,m.y]),r.stopPropagation&&r.stopPropagation(),r.stopImmediatePropagation&&r.stopImmediatePropagation(),r.preventDefault&&r.preventDefault());return}}_onMapMouseMove(e){}_onMapClick(e){if(!(e.type===this.options.removeVertexOn))return;const n=this._getMap();if(!n)return;const r=new p.Raycaster;r.params.Points={threshold:.5};const o=e.originEvent;if(!o)return;const a=new p.Vector2(o.offsetX/n.viewer.renderer.domElement.clientWidth*2-1,-(o.offsetY/n.viewer.renderer.domElement.clientHeight)*2+1);r.setFromCamera(a,n.viewer.camera);for(let c=0;c<this._handles.length;c++)if(this._handles[c].intersect(r)){this._removeVertex(c),o.stopPropagation&&o.stopPropagation(),o.preventDefault&&o.preventDefault();return}}_setFeatureEditingStyle(e){const t=this.target._threeGeometry;t&&t.traverse(n=>{n.material&&(e?Array.isArray(n.material)?n.material.forEach(r=>{r.userData._originalOpacity||(r.userData._originalOpacity=r.opacity),r.opacity=Math.min(r.opacity*.6,.6),r.transparent=!0}):(n.material.userData._originalOpacity||(n.material.userData._originalOpacity=n.material.opacity),n.material.opacity=Math.min(n.material.opacity*.6,.6),n.material.transparent=!0):Array.isArray(n.material)?n.material.forEach(r=>{r.userData._originalOpacity!==void 0&&(r.opacity=r.userData._originalOpacity,delete r.userData._originalOpacity)}):n.material.userData._originalOpacity!==void 0&&(n.material.opacity=n.material.userData._originalOpacity,delete n.material.userData._originalOpacity))})}_removeVertex(e){const t=this.target._geometry,n=this._handles[e],r=n.getIndex(),o=n._ringIndex||0;let a=null;if(this.target instanceof Mt){const c=t.coordinates;if(c.length<=2){console.warn("[FeatureEditHandler] LineString requires at least 2 vertices");return}a=c[r],c.splice(r,1)}else if(this.target instanceof _n){const u=t.coordinates[o];if(!u)return;const d=u.length>1&&u[0][0]===u[u.length-1][0]&&u[0][1]===u[u.length-1][1],m=d?4:3;if(u.length<=m){console.warn("[FeatureEditHandler] Polygon ring requires at least 3 vertices");return}a=u[r],u.splice(r,1),d&&r===0&&u.length>0&&(u[u.length-1]=[...u[0]])}else return;this.target._onPositionChanged(!0),n.remove(),this._handles.splice(e,1),this._updateHandleIndices(),this._addHistory(t.coordinates),this.target.trigger("handleremove",{index:r,ringIndex:o,coordinate:a})}_createLineStringMiddleHandles(e,t){for(let n=0;n<e.length-1;n++){const r=e[n],o=e[n+1],a=[(r[0]+o[0])/2,(r[1]+o[1])/2,((r[2]||0)+(o[2]||0))/2],c=t.geo2world(new p.Vector3(a[0],a[1],a[2])),u=new Ci({position:c,index:n,symbol:1,size:this.options.handleSize,color:this._middleHandleColor,opacity:.6},t);u.on("dragstart",d=>{this._onMiddleHandleClick(n,"LineString",0)}),this._middleHandles.push(u)}}_createPolygonMiddleHandles(e,t,n){const r=e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]?e.length-1:e.length;for(let o=0;o<r;o++){const a=(o+1)%r,c=e[o],u=e[a],d=[(c[0]+u[0])/2,(c[1]+u[1])/2,((c[2]||0)+(u[2]||0))/2],m=n.geo2world(new p.Vector3(d[0],d[1],d[2])),f=new Ci({position:m,index:o,symbol:1,size:this.options.handleSize,color:this._middleHandleColor,opacity:.6},n);f._ringIndex=t,f.on("dragstart",g=>{this._onMiddleHandleClick(o,"Polygon",t)}),this._middleHandles.push(f)}}_onMiddleHandleClick(e,t,n){const r=this.target._geometry;if(this._getMap()){if(t==="LineString"){const a=r.coordinates,c=a[e],u=a[e+1],d=[(c[0]+u[0])/2,(c[1]+u[1])/2,((c[2]||0)+(u[2]||0))/2];a.splice(e+1,0,d)}else if(t==="Polygon"){const c=r.coordinates[n];if(!c)return;const u=c[0][0]===c[c.length-1][0]&&c[0][1]===c[c.length-1][1]?c.length-1:c.length,d=(e+1)%u,m=c[e],f=c[d],g=[(m[0]+f[0])/2,(m[1]+f[1])/2,((m[2]||0)+(f[2]||0))/2];c.splice(e+1,0,g),c.length>1&&c[0][0]===c[c.length-1][0]&&c[0][1]===c[c.length-1][1]&&e===u-1&&(c[c.length-1]=[...c[0]])}this.target._onPositionChanged(!0),this._clearHandles(),this._createHandles(),this._addHistory(r.coordinates),this.target.trigger("vertexinsert",{index:e+1,ringIndex:n})}}_updateHandleIndices(){if(this.target instanceof Mt)this._handles.forEach((e,t)=>{e._index=t});else if(this.target instanceof _n){let e=0;this.target._geometry.coordinates.forEach((r,o)=>{const a=r[0][0]===r[r.length-1][0]&&r[0][1]===r[r.length-1][1]?r.length-1:r.length;for(let c=0;c<a;c++)this._handles[e]&&(this._handles[e]._index=c,this._handles[e]._ringIndex=o),e++})}}_fixHandlePointCoordinates(e,t,n=0){const r=this._getMap();if(!r)return e;const o=this.target._geometry;let a=null;if(this.target instanceof en)a=o.coordinates;else if(this.target instanceof Mt)a=o.coordinates[t];else if(this.target instanceof _n){const u=o.coordinates;u[n]&&u[n][t]&&(a=u[n][t])}if(!a||!a[2]||a[2]===0)return r.world2geo(e);const c=r.world2geo(e);return c.z=a[2],c}_getMap(){return this.target.getMap()}remove(){this.disable(),this._history=[],this._historyIndex=-1,this._shadow=null,this._shadowSnapshot=null,this._boundOnMapMouseMove=null,this._boundOnMapClick=null,this._boundOnMapMouseDown=null}}ut.prototype.startEdit=function(i){return this.options?.editable?(this._editor&&this.endEdit(),this._editor=new oy(this,i),this._editor.enable(),this):(console.warn("Feature is not editable. Set editable option to true."),this)},ut.prototype.endEdit=function(){return this._editor&&(this._editor.disable(),this._editor.remove(),delete this._editor),this},ut.prototype.isEditing=function(){return this._editor?this._editor.isEditing():!1},ut.prototype.cancelEdit=function(){return this._editor&&this._editor.cancel(),this},ut.prototype.undoEdit=function(){return this._editor&&this._editor.undo(),this},ut.prototype.redoEdit=function(){return this._editor&&this._editor.redo(),this};function ys(i,e){if(!i||i===!0)return!0;if(!Array.isArray(i))return!!i;switch(i[0]){case"all":return i.slice(1).every(n=>ys(n,e));case"any":return i.slice(1).some(n=>ys(n,e));case"!":return!ys(i[1],e);case"==":{const n=Oe(i[1],e),r=Oe(i[2],e);return _s(n)==_s(r)}case"!=":{const n=Oe(i[1],e),r=Oe(i[2],e);return _s(n)!=_s(r)}case">":{const n=Oe(i[1],e),r=Oe(i[2],e);return jn(n)>jn(r)}case"<":{const n=Oe(i[1],e),r=Oe(i[2],e);return jn(n)<jn(r)}case">=":{const n=Oe(i[1],e),r=Oe(i[2],e);return jn(n)>=jn(r)}case"<=":{const n=Oe(i[1],e),r=Oe(i[2],e);return jn(n)<=jn(r)}case"in":{const n=Oe(i[1],e);return i.slice(2).map(o=>Oe(o,e)).includes(n)}case"!in":{const n=Oe(i[1],e);return!i.slice(2).map(o=>Oe(o,e)).includes(n)}case"has":{const n=i[1];return e!=null&&Object.prototype.hasOwnProperty.call(e,n)}case"!has":{const n=i[1];return!(e!=null&&Object.prototype.hasOwnProperty.call(e,n))}case"like":case"contains":{const n=Oe(i[1],e),r=Oe(i[2],e);return String(n).toLowerCase().includes(String(r).toLowerCase())}case"starts-with":{const n=Oe(i[1],e),r=Oe(i[2],e);return String(n).toLowerCase().startsWith(String(r).toLowerCase())}case"ends-with":{const n=Oe(i[1],e),r=Oe(i[2],e);return String(n).toLowerCase().endsWith(String(r).toLowerCase())}default:return!0}}function Oe(i,e){if(Array.isArray(i))switch(i[0]){case"get":return e?e[i[1]]:void 0;default:return i}return i}function _s(i){if(i==null)return null;if(typeof i=="string"){const e=Number(i);if(!isNaN(e)&&i.trim()!=="")return e}return typeof i=="boolean"?i?1:0:i}function jn(i){if(i==null)return 0;if(typeof i=="number")return i;if(typeof i=="boolean")return i?1:0;if(typeof i=="string"){const e=Number(i);return isNaN(e)?0:e}return Number(i)}var ay=Object.defineProperty,ly=(i,e,t)=>e in i?ay(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ur=(i,e,t)=>ly(i,typeof e!="symbol"?e+"":e,t);class vs extends Bn{constructor(e,t){super(e,t),Ur(this,"TILE_SIZE"),Ur(this,"EXTENT"),Ur(this,"style"),Ur(this,"interactive",!1),Ur(this,"_tileFeatureMap",new Map),Ur(this,"_activeFeatureFilter"),this.TILE_SIZE=t.tileSize??256,this.EXTENT=t.extent??4096,this.style=t.style||[],this._onMapUpdate=this._onMapUpdate.bind(this)}processTileData(e,t){const n=this.getMap(),r=`${e.z}-${e.x}-${e.y}`,o=this._tileFeatureMap.get(r);if(o&&o.length>0){o.forEach(d=>{d.visible=!0,this.children.some(m=>m&&d&&m.uuid===d.uuid)||d.addTo(this)});return}const a=t.vectorData;if(!a||!a.layers||!n||this.style.length===0)return;const c=[],u=this.style;Object.keys(a.layers).forEach(d=>{const m=a.layers[d];for(let f=0;f<m.length;f++){const g=m[f],_=g.geometry;if(this._activeFeatureFilter&&!this._activeFeatureFilter(g.properties))continue;let w=null;for(const b of u)if(this._evaluateFilter(b.filter,g.properties,d,g.geometry.type)){w=b.style;break}if(w){const b={isVectorTile:!0,tileZ:e.z,tileX:e.x,tileY:e.y,rawCoordinates:_,extent:this.EXTENT,tileSize:this.TILE_SIZE},x=this._createFeatureInstance(g.geometry,g.geometry.type,w,{layerName:d,...g.properties});x&&(x.userData.tileData=b,x.style=xt.create(w),x.addTo(this),x.initializeGeometry(),c.push(x))}}}),this._tileFeatureMap.set(r,c)}_evaluateFilter(e,t,n,r){if(!e||e===!0)return!0;const o={...t,$layer:n,$type:r};return ys(e,o)}hideFeaturesByTileKey(e){const t=this._tileFeatureMap.get(e);t&&t.forEach(n=>{n.visible=!1})}removeFeaturesByTileKey(e){this._removeFeaturesByTileKey(e)}_removeFeaturesByTileKey(e){const t=this._tileFeatureMap.get(e);t&&(t.forEach(n=>{n._remove()}),this._tileFeatureMap.delete(e))}_createFeatureInstance(e,t,n,r){const a={geometry:{ismvt:!0,...e},style:n,userData:r};switch(t){case"Point":return new Pn(a);case"LineString":return new Mt(a);default:return null}}setFeatureFilter(e){this._activeFeatureFilter=e}clearFeatureFilter(){this._activeFeatureFilter=void 0}setOpacity(e){this.opacity=e,this._tileFeatureMap.forEach(t=>{t.forEach(n=>{n.material&&(n.material.opacity=e,n.material.transparent=e<1)})})}_onMapUpdate(){}updateStyle(e,t){if(!e||!Array.isArray(e)){console.warn("[VectorTileRenderLayer] updateStyle called with invalid style rules.");return}this.style=e,this._tileFeatureMap.forEach((n,r)=>{const o=t.get(r);if(!o||!o.data||!o.data.vectorData)return;const a=o.data.vectorData;n.forEach(c=>{const u=c.userData,d=c.userData.tileData?.rawCoordinates?.type;let m="";if(a&&a.layers){for(const[g,_]of Object.entries(a.layers))if(_.some(b=>b.properties===u||JSON.stringify(b.properties)===JSON.stringify(u))){m=g;break}}if(this._activeFeatureFilter&&!this._activeFeatureFilter(u)){c.visible=!1;return}let f=null;for(const g of e)if(this._evaluateFilter(g.filter,u,m,d)){f=g.style;break}f?(this._applyStyleToFeature(c,f),c.visible=!0):c.visible=!1})})}_applyStyleToFeature(e,t){e.style=xt.create(t),e.initializeGeometry()}validateFeature(e){return e instanceof ut}dispose(){this._tileFeatureMap.forEach((e,t)=>{this._removeFeaturesByTileKey(t)})}}var cy=Object.defineProperty,uy=(i,e,t)=>e in i?cy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,St=(i,e,t)=>uy(i,typeof e!="symbol"?e+"":e,t);class ru extends ds{constructor(e,t){super(e,t),this.layerId=e,St(this,"isTileLayer",!0),St(this,"layerType","base"),St(this,"isBaseLayer",!1),St(this,"_enabled",!0),St(this,"_visible",!0),St(this,"_rootTile"),St(this,"_loader"),St(this,"_LODThreshold",1),St(this,"isSceneLayer",!1),St(this,"opacity",1),St(this,"source"),St(this,"projection"),St(this,"minLevel",2),St(this,"maxLevel",19),this.source=t.source,this.projection=t.projection,this.minLevel=t.minLevel??2,this.maxLevel=t.maxLevel??19,this._LODThreshold=t.LODThreshold??1,this.opacity=t.opacity??1,this.name=`Layer-${e}`,this._loader=this.createLoader(),this._rootTile=new Nn,this._rootTile.matrixAutoUpdate=!0,this._rootTile.scale.set(this.projection.mapWidth,this.projection.mapHeight,1),this.add(this._rootTile),this._rootTile.updateMatrix(),this.layerId=e,this.name==="Layer-label-layer"&&this.position.set(0,0,1)}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}get loader(){return this._loader}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._rootTile&&(this._rootTile.visible=e&&this._visible)}get ivisible(){return this._visible&&super._visible}set ivisible(e){this._visible=e,this._rootTile&&(this._rootTile.visible=e&&this._enabled)}update(e){if(!(!this._enabled||!this._visible)){try{this._rootTile.update({camera:e,loader:this._loader,minLevel:this.minLevel,maxLevel:this.maxLevel,LODThreshold:this.LODThreshold})}catch{}console.groupEnd()}}_debugTileTree(){this._rootTile.traverse(e=>{e.isTile&&(e.loaded,e.visible,e.inFrustum,e.loaded)})}_getLODThreshold(){return 1}_getCurrentTileLevel(){let e=0;return this._rootTile.traverse(t=>{t.isTile&&t.loaded&&(e=Math.max(e,t.z))}),`最大层级: ${e}`}dispose(){this.remove(this._rootTile),this._rootTile.reload(this._loader)}reload(){this._rootTile.reload(this._loader)}setElevation(e){this.position.y=e,this.updateMatrix(),this.updateMatrixWorld(!0)}raiseElevation(e){this.position.z+=e,this.updateMatrix(),this.updateMatrixWorld(!0)}getElevation(){return this.position.y}}var hy=Object.defineProperty,dy=(i,e,t)=>e in i?hy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,fy=(i,e,t)=>dy(i,e+"",t);class iu extends p.LoadingManager{constructor(){super(...arguments),fy(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const De={manager:new iu,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(i){De.imgLoaderMap.set(i.dataType,i),i.info.author=i.info.author??_o.name},registerGeometryLoader(i){De.demLoaderMap.set(i.dataType,i),i.info.author=i.info.author??_o.name},registerMeshLoader(i){De.meshLoaderMap.set(i.dataType,i),i.info.author=i.info.author??_o.name},getMaterialLoader(i){const e=De.imgLoaderMap.get(i.dataType);if(e)return e;throw`Source dataType "${i.dataType}" is not support!`},getGeometryLoader(i){const e=De.demLoaderMap.get(i.dataType);if(e)return e;throw`Source dataType "${i.dataType}" is not support!`},getMeshLoader(i){const e=De.meshLoaderMap.get(i.dataType);if(e)return e;throw`Source dataType "${i.dataType}" is not support!`}};var py=Object.defineProperty,my=(i,e,t)=>e in i?py(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,gy=(i,e,t)=>my(i,e+"",t);class yy{constructor(e){gy(this,"worker"),this.worker=e()}async run(e,t){return new Promise(n=>{this.worker.onmessage=r=>{n(r.data)},this.worker.postMessage(e,t)})}terminate(){this.worker.terminate()}}const _y=4096,su=Math.PI;function na(i,e){const t=Math.floor(i[0]*e),n=Math.floor(i[1]*e),r=Math.floor((i[2]-i[0])*e),o=Math.floor((i[3]-i[1])*e);return{sx:t,sy:n,sw:r,sh:o}}function ra(i,e,t,n){if(n<i.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=i.maxLevel)return{url:i._getUrl(e,t,n),clipBounds:[0,0,1,1]};const r=vy(e,t,n,i.maxLevel),o=r.parentNO;return{url:i._getUrl(o.x,o.y,o.z),clipBounds:r.bounds}}function vy(i,e,t,n){const r=t-n,o={x:i>>r,y:e>>r,z:t-r},a=Math.pow(2,r),c=Math.pow(.5,r),u=i%a/a-.5+c/2,d=e%a/a-.5+c/2,m=new p.Vector2(u,d),f=new p.Box2().setFromCenterAndSize(m,new p.Vector2(c,c)),g=[f.min.x+.5,f.min.y+.5,f.max.x+.5,f.max.y+.5];return{parentNO:o,bounds:g}}function ia(i,e,t,n,r=_y){const{x:o,y:a}=i,c=(e+o/r)/Math.pow(2,n),u=(t+a/r)/Math.pow(2,n),d=c*360-180,f=Math.atan(Math.sinh(su*(1-2*u)))*180/su;return[parseFloat(d.toFixed(8)),parseFloat(f.toFixed(8))]}function wy(i,e,t,n){if(!i||!i.coordinates)throw new Error("无效的geometry数据格式");const r={type:i.type,coordinates:null};function o(a){if(typeof a=="object"&&a.x!==void 0&&a.y!==void 0)return ia(a,e,t,n);if(Array.isArray(a)&&a.length>0){const c=a[0];return typeof c=="object"&&c.x!==void 0&&c.y!==void 0?a.map(u=>ia(u,e,t,n)):a.map(u=>o(u))}return a}return r.coordinates=o(i.coordinates),r}var by=Object.defineProperty,xy=(i,e,t)=>e in i?by(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ws=(i,e,t)=>xy(i,typeof e!="symbol"?e+"":e,t);class bs{constructor(){ws(this,"_imgSource",[]),ws(this,"_demSource"),ws(this,"_vtSource"),ws(this,"manager",De.manager)}get imgSource(){return this._imgSource}set imgSource(e){this._imgSource=e}get demSource(){return this._demSource}set demSource(e){this._demSource=e}get vtSource(){return this._vtSource}set vtSource(e){this._vtSource=e}async load(e){const t=await this.loadGeometry(e),n=await this.loadMaterial(e);console.assert(!!n&&!!t);for(let r=0;r<n.length;r++)t.addGroup(0,1/0,r);return{materials:n,geometry:t}}unload(e){const t=e.material,n=e.geometry;for(let r=0;r<t.length;r++)t[r].dispose();n.dispose()}async loadGeometry(e){let t;if(this.demSource&&e.z>=this.demSource.minLevel&&this._isBoundsInSourceBounds(this.demSource,e.bounds)){const n=De.getGeometryLoader(this.demSource),r=this.demSource;t=await n.load({source:r,...e}).catch(o=>(console.error("Load material error",r.dataType,e.x,e.y,e.z),new p.PlaneGeometry)),t.addEventListener("dispose",()=>{n.unload&&n.unload(t)})}else if(this.vtSource&&e.z>=this.vtSource.minLevel&&this._isBoundsInSourceBounds(this.vtSource,e.bounds)){const n=De.getMeshLoader(this.vtSource),r=this.vtSource;t=await n.load({source:r,...e}).catch(o=>(console.error("Load geometry error",r.dataType,e.x,e.y,e.z),new p.PlaneGeometry)),t.addEventListener("dispose",()=>{n.unload&&n.unload(t)})}else t=new p.PlaneGeometry;return t}async loadMaterial(e){const n=this.imgSource.filter(r=>e.z>=r.minLevel&&this._isBoundsInSourceBounds(r,e.bounds)).map(async r=>{const o=De.getMaterialLoader(r),a=await o.load({source:r,...e}).catch(u=>(console.error("Load material error",r.dataType,e.x,e.y,e.z),new p.MeshBasicMaterial)),c=u=>{o.unload&&o.unload(u.target),u.target.removeEventListener("dispose",c)};return a instanceof p.MeshBasicMaterial||a.addEventListener("dispose",c),a});return Promise.all(n)}_isBoundsInSourceBounds(e,t){const n=e._projectionBounds;return!(t[2]<n[0]||t[3]<n[1]||t[0]>n[2]||t[1]>n[3])}}function Ti(...i){const e=i,t=e&&e.length>1&&e[0].constructor||null;if(!t)throw new Error("concatenateTypedArrays - incorrect quantity of arguments or arguments have incompatible data types");const n=e.reduce((a,c)=>a+c.length,0),r=new t(n);let o=0;for(const a of e)r.set(a,o),o+=a.length;return r}function ou(i,e,t,n){const r=n?Sy(n,i.position.value):My(e),o=r.length,a=new Float32Array(o*6),c=new Float32Array(o*4),u=new e.constructor(o*6),d=new Float32Array(o*6);for(let f=0;f<o;f++)Ly({edge:r[f],edgeIndex:f,attributes:i,skirtHeight:t,newPosition:a,newTexcoord0:c,newTriangles:u,newNormals:d});i.position.value=Ti(i.position.value,a),i.texcoord.value=Ti(i.texcoord.value,c),i.normal.value=Ti(i.normal.value,d);const m=Ti(e,u);return{attributes:i,indices:m}}function My(i){const e=[],t=Array.isArray(i)?i:Array.from(i);for(let r=0;r<t.length;r+=3){const o=t[r],a=t[r+1],c=t[r+2];e.push([o,a],[a,c],[c,o])}e.sort(([r,o],[a,c])=>{const u=Math.min(r,o),d=Math.min(a,c);return u!==d?u-d:Math.max(r,o)-Math.max(a,c)});const n=[];for(let r=0;r<e.length;r++)r+1<e.length&&e[r][0]===e[r+1][1]&&e[r][1]===e[r+1][0]?r++:n.push(e[r]);return n}function Sy(i,e){const t=(r,o)=>{r.sort(o)};t(i.westIndices,(r,o)=>e[3*r+1]-e[3*o+1]),t(i.eastIndices,(r,o)=>e[3*o+1]-e[3*r+1]),t(i.southIndices,(r,o)=>e[3*o]-e[3*r]),t(i.northIndices,(r,o)=>e[3*r]-e[3*o]);const n=[];return Object.values(i).forEach(r=>{if(r.length>1)for(let o=0;o<r.length-1;o++)n.push([r[o],r[o+1]])}),n}function Ly({edge:i,edgeIndex:e,attributes:t,skirtHeight:n,newPosition:r,newTexcoord0:o,newTriangles:a,newNormals:c}){const u=t.position.value.length,d=e*2,m=d+1;r.set(t.position.value.subarray(i[0]*3,i[0]*3+3),d*3),r[d*3+2]=r[d*3+2]-n,r.set(t.position.value.subarray(i[1]*3,i[1]*3+3),m*3),r[m*3+2]=r[m*3+2]-n,o.set(t.texcoord.value.subarray(i[0]*2,i[0]*2+2),d*2),o.set(t.texcoord.value.subarray(i[1]*2,i[1]*2+2),m*2);const f=e*2*3;a[f]=i[0],a[f+1]=u/3+m,a[f+2]=i[1],a[f+3]=u/3+m,a[f+4]=i[0],a[f+5]=u/3+d,c[f]=0,c[f+1]=0,c[f+2]=1,c[f+3]=0,c[f+4]=0,c[f+5]=1}function au(i){if(i.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${i.length}!`);const e=Math.floor(Math.sqrt(i.length)),t=e,n=e,r=sa(n,t);return{attributes:Py(i,n,t),indices:r}}function Py(i,e,t){const n=t*e,r=new Float32Array(n*3),o=new Float32Array(n*2);let a=0;for(let c=0;c<e;c++)for(let u=0;u<t;u++){const d=u/(t-1),m=c/(e-1);o[a*2]=d,o[a*2+1]=m,r[a*3]=d-.5,r[a*3+1]=m-.5,r[a*3+2]=i[(e-c-1)*t+u],a++}return{position:{value:r,size:3},texcoord:{value:o,size:2},normal:{value:oa(r,sa(e,t)),size:3}}}function sa(i,e){const t=6*(e-1)*(i-1),n=new Uint16Array(t);let r=0;for(let o=0;o<i-1;o++)for(let a=0;a<e-1;a++){const c=o*e+a,u=c+1,d=c+e,m=d+1,f=r*6;n[f]=c,n[f+1]=u,n[f+2]=d,n[f+3]=d,n[f+4]=u,n[f+5]=m,r++}return n}function oa(i,e){const t=new Float32Array(i.length);for(let n=0;n<e.length;n+=3){const r=e[n]*3,o=e[n+1]*3,a=e[n+2]*3,c=i[r],u=i[r+1],d=i[r+2],m=i[o],f=i[o+1],g=i[o+2],_=i[a],w=i[a+1],b=i[a+2],x=m-c,L=f-u,M=g-d,C=_-c,Z=w-u,z=b-d,D=L*z-M*Z,X=M*C-x*z,I=x*Z-L*C,K=Math.sqrt(D*D+X*X+I*I),V=[0,0,1];if(K>0){const G=1/K;V[0]=D*G,V[1]=X*G,V[2]=I*G}for(let G=0;G<3;G++)t[r+G]=t[o+G]=t[a+G]=V[G]}return t}var Cy=Object.defineProperty,Ty=(i,e,t)=>e in i?Cy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Gy=(i,e,t)=>Ty(i,e+"",t);class kr extends p.PlaneGeometry{constructor(){super(...arguments),Gy(this,"type","TileGeometry")}setData(e,t=1e3){let n=e instanceof Float32Array?au(e):e;n=ou(n.attributes,n.indices,t);const{attributes:r,indices:o}=n;return this.setIndex(new p.BufferAttribute(o,1)),this.setAttribute("position",new p.BufferAttribute(r.position.value,r.position.size)),this.setAttribute("uv",new p.BufferAttribute(r.texcoord.value,r.texcoord.size)),this.setAttribute("normal",new p.BufferAttribute(r.normal.value,r.normal.size)),this.computeBoundingBox(),this.computeBoundingSphere(),this}}var Zy=Object.defineProperty,Wy=(i,e,t)=>e in i?Zy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Jn=(i,e,t)=>Wy(i,typeof e!="symbol"?e+"":e,t);class lu{constructor(e=257){Jn(this,"gridSize"),Jn(this,"numTriangles"),Jn(this,"numParentTriangles"),Jn(this,"indices"),Jn(this,"coords"),this.gridSize=e;const t=e-1;if(t&t-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=t*t*2-2,this.numParentTriangles=this.numTriangles-t*t,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let r=n+2,o=0,a=0,c=0,u=0,d=0,m=0;for(r&1?c=u=d=t:o=a=m=t;(r>>=1)>1;){const g=o+c>>1,_=a+u>>1;r&1?(c=o,u=a,o=d,a=m):(o=c,a=u,c=d,u=m),d=g,m=_}const f=n*4;this.coords[f+0]=o,this.coords[f+1]=a,this.coords[f+2]=c,this.coords[f+3]=u}}createTile(e){return new Vy(e,this)}}class Vy{constructor(e,t){Jn(this,"martini"),Jn(this,"terrain"),Jn(this,"errors");const n=t.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=t,this.errors=new Float32Array(e.length),this.update()}update(){const{numTriangles:e,numParentTriangles:t,coords:n,gridSize:r}=this.martini,{terrain:o,errors:a}=this;for(let c=e-1;c>=0;c--){const u=c*4,d=n[u+0],m=n[u+1],f=n[u+2],g=n[u+3],_=d+f>>1,w=m+g>>1,b=_+w-m,x=w+d-_,L=(o[m*r+d]+o[g*r+f])/2,M=w*r+_,C=Math.abs(L-o[M]);if(a[M]=Math.max(a[M],C),c<t){const Z=(m+x>>1)*r+(d+b>>1),z=(g+x>>1)*r+(f+b>>1);a[M]=Math.max(a[M],a[Z],a[z])}}}getGeometryData(e=0){const{gridSize:t,indices:n}=this.martini,{errors:r}=this;let o=0,a=0;const c=t-1;let u,d,m=0;n.fill(0);function f(M,C,Z,z,D,X){const I=M+Z>>1,K=C+z>>1;Math.abs(M-D)+Math.abs(C-X)>1&&r[K*t+I]>e?(f(D,X,M,C,I,K),f(Z,z,D,X,I,K)):(u=C*t+M,d=z*t+Z,m=X*t+D,n[u]===0&&(n[u]=++o),n[d]===0&&(n[d]=++o),n[m]===0&&(n[m]=++o),a++)}f(0,0,c,c,c,0),f(c,c,0,0,0,c);const g=o*2,_=a*3,w=new Uint16Array(g),b=new Uint32Array(_);let x=0;function L(M,C,Z,z,D,X){const I=M+Z>>1,K=C+z>>1;if(Math.abs(M-D)+Math.abs(C-X)>1&&r[K*t+I]>e)L(D,X,M,C,I,K),L(Z,z,D,X,I,K);else{const V=n[C*t+M]-1,G=n[z*t+Z]-1,k=n[X*t+D]-1;w[2*V]=M,w[2*V+1]=C,w[2*G]=Z,w[2*G+1]=z,w[2*k]=D,w[2*k+1]=X,b[x++]=V,b[x++]=G,b[x++]=k}}return L(0,0,c,c,c,0),L(c,c,0,0,0,c),{attributes:this._getMeshAttributes(this.terrain,w,b),indices:b}}_getMeshAttributes(e,t,n){const r=Math.floor(Math.sqrt(e.length)),o=r-1,a=t.length/2,c=new Float32Array(a*3),u=new Float32Array(a*2);for(let m=0;m<a;m++){const f=t[m*2],g=t[m*2+1],_=g*r+f;c[3*m+0]=f/o-.5,c[3*m+1]=.5-g/o,c[3*m+2]=e[_],u[2*m+0]=f/o,u[2*m+1]=1-g/o}const d=oa(c,n);return{position:{value:c,size:3},texcoord:{value:u,size:2},normal:{value:d,size:3}}}}var Iy=Object.defineProperty,Ay=(i,e,t)=>e in i?Iy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,cu=(i,e,t)=>Ay(i,typeof e!="symbol"?e+"":e,t);class aa{constructor(){cu(this,"info",{version:"0.10.0",description:"Terrain loader base class"}),cu(this,"dataType","")}async load(e){const{source:t,x:n,y:r,z:o}=e,{url:a,clipBounds:c}=ra(t,n,r,o);if(!a)return new kr;const u=await this.doLoad(a,{source:t,x:n,y:r,z:o,bounds:c});return De.manager.parseEnd(a),u}}class la extends p.MeshStandardMaterial{constructor(e={}){super({transparent:!0,side:p.FrontSide,...e})}setTexture(e){this.map=e,this.needsUpdate=!0}dispose(){const e=this.map;e&&(e.image instanceof ImageBitmap&&e.image.close(),e.dispose())}}var nt=(i=>(i[i.Unknown=0]="Unknown",i[i.Point=1]="Point",i[i.Linestring=2]="Linestring",i[i.Polygon=3]="Polygon",i))(nt||{});class uu{render(e,t,n,r,o=1){switch(e.lineCap="round",e.lineJoin="round",(r.shadowBlur??0)>0&&(e.shadowBlur=r.shadowBlur??2,e.shadowColor=r.shadowColor??"black",e.shadowOffsetX=r.shadowOffset?r.shadowOffset[0]:0,e.shadowOffsetY=r.shadowOffset?r.shadowOffset[1]:0),t){case nt.Point:e.textAlign="center",e.textBaseline="middle",e.font=r.font??"14px Arial",e.fillStyle=r.fontColor??"white",this._renderPointText(e,n,o,r.textField??"name",r.fontOffset??[0,-8]);break;case nt.Linestring:this._renderLineString(e,n,o);break;case nt.Polygon:this._renderPolygon(e,n,o);break;default:console.warn(`Unknown feature type: ${t}`)}(r.fill||t===nt.Point)&&(e.globalAlpha=r.fillOpacity||.5,e.fillStyle=r.fillColor||r.color||"#3388ff",e.fill(r.fillRule||"evenodd")),(r.stroke??!0)&&(r.weight??1)>0&&(e.globalAlpha=r.opacity||1,e.lineWidth=r.weight||1,e.strokeStyle=r.color||"#3388ff",e.setLineDash(r.dashArray||[]),e.stroke())}_renderPointText(e,t,n=1,r="name",o=[0,0]){const a=t.geometry;e.beginPath();for(const u of a)for(let d=0;d<u.length;d++){const m=u[d];e.arc(m.x*n,m.y*n,2,0,2*Math.PI)}const c=t.properties;c&&c[r]&&e.fillText(c[r],a[0][0].x*n+o[0],a[0][0].y*n+o[1])}_renderLineString(e,t,n){const r=t.geometry;e.beginPath();for(const o of r)for(let a=0;a<o.length;a++){const{x:c,y:u}=o[a];a===0?e.moveTo(c*n,u*n):e.lineTo(c*n,u*n)}}_renderPolygon(e,t,n){const r=t.geometry;e.beginPath();for(let o=0;o<r.length;o++){const a=r[o];for(let c=0;c<a.length;c++){const{x:u,y:d}=a[c];c===0?e.moveTo(u*n,d*n):e.lineTo(u*n,d*n)}e.closePath()}}}var Fy=Object.defineProperty,Oy=(i,e,t)=>e in i?Fy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,hu=(i,e,t)=>Oy(i,typeof e!="symbol"?e+"":e,t);class ca{constructor(){hu(this,"info",{version:"0.10.0",description:"Image loader base class"}),hu(this,"dataType","")}async load(e){const{source:t,x:n,y:r,z:o}=e,a=new la({}),{url:c,clipBounds:u}=ra(t,n,r,o);if(c){const d=await this.doLoad(c,{source:t,x:n,y:r,z:o,bounds:u});a.map=d,De.manager.parseEnd(c)}return a}}var Dy=Object.defineProperty,zy=(i,e,t)=>e in i?Dy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,du=(i,e,t)=>zy(i,typeof e!="symbol"?e+"":e,t);class Xy{constructor(){du(this,"info",{version:"0.10.0",description:"Canvas tile abstract loader"}),du(this,"dataType","")}async load(e){const t=this._creatCanvasContext(256,256);this.drawTile(t,e);const n=new p.CanvasTexture(t.canvas.transferToImageBitmap());return new la({transparent:!0,map:n,opacity:e.source.opacity})}_creatCanvasContext(e,t){const r=new OffscreenCanvas(e,t).getContext("2d");if(!r)throw new Error("create canvas context failed");return r.scale(1,-1),r.translate(0,-t),r}}var Uy=Object.defineProperty,ky=(i,e,t)=>e in i?Uy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ua=(i,e,t)=>ky(i,typeof e!="symbol"?e+"":e,t);class Ky extends ca{constructor(){super(...arguments),ua(this,"info",{version:"0.10.0",description:"Tile image loader. It can load xyz tile image."}),ua(this,"dataType","image"),ua(this,"loader",new p.ImageLoader(De.manager))}async doLoad(e,t){const n=await this.loader.loadAsync(e).catch(a=>new Image(1,1)),r=new p.Texture;r.colorSpace=p.SRGBColorSpace;const{bounds:o}=t;return o[2]-o[0]<1?r.image=Ny(n,o):r.image=n,r.needsUpdate=!0,r}}function Ny(i,e){const t=i.width,n=new OffscreenCanvas(t,t),r=n.getContext("2d"),{sx:o,sy:a,sw:c,sh:u}=na(e,i.width);return r.drawImage(i,o,a,c,u,0,0,t,t),n}const By=`{
906
+ "name": "@terra.gl/core",
907
+ "version": "0.0.1-alpha.61",
908
+ "type": "module",
909
+ "files": [
910
+ "dist"
911
+ ],
912
+ "main": "./dist/index.umd.cjs",
913
+ "module": "./dist/index.js",
914
+ "types": "./dist/index.d.ts",
915
+ "exports": {
916
+ ".": {
917
+ "import": "./dist/index.js",
918
+ "require": "./dist/index.umd.cjs",
919
+ "types": "./dist/index.d.ts"
920
+ }
921
+ },
922
+ "author": {
923
+ "name": "Criska"
924
+ },
925
+ "description": "a map using threejs",
926
+ "license": "Apache-2.0",
927
+ "keywords": [
928
+ "three",
929
+ "gis",
930
+ "tile",
931
+ "map",
932
+ "3D",
933
+ "cesium",
934
+ "mapbox"
935
+ ],
936
+ "scripts": {
937
+ "dev": "vite build --watch",
938
+ "build": "tsc && vite build && node copy-extra-to-dist.cjs",
939
+ "docs:build-plugin": "tsc --project docs/typedoc-plugins",
940
+ "docs:generate": "npx rimraf docs/jsdoc && npx tsc --noEmit false --declaration false --outDir dist-docs-temp --removeComments false && npx jsdoc -c jsdoc.json && npx rimraf dist-docs-temp",
941
+ "docs:typedoc": "npx typedoc --options typedoc.json",
942
+ "changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s --commit-path ."
943
+ },
944
+ "peerDependencies": {
945
+ "three": "^0.171.0"
946
+ },
947
+ "publishConfig": {
948
+ "registry": "https://registry.npmjs.org/",
949
+ "access": "public"
950
+ },
951
+ "dependencies": {
952
+ "@mapbox/vector-tile": "^2.0.4",
953
+ "@pmndrs/vanilla": "^1.20.4",
954
+ "@types/earcut": "^3.0.0",
955
+ "@types/geojson": "^7946.0.16",
956
+ "d3-quadtree": "^3.0.1",
957
+ "earcut": "^3.0.1",
958
+ "lodash": "^4.17.21",
959
+ "pbf": "^4.0.1",
960
+ "postprocessing": "^6.37.3",
961
+ "three-stdlib": "^2.36.0"
962
+ },
963
+ "devDependencies": {
964
+ "@types/lodash": "^4.17.20",
965
+ "@types/node": "^24.2.0",
966
+ "jsdoc": "^4.0.5",
967
+ "rimraf": "^6.1.2",
968
+ "typedoc": "^0.28.8",
969
+ "typedoc-vitepress-theme": "^1.1.2",
970
+ "vue": "^3.5.18"
971
+ }
972
+ }
973
+ `;var Yy=Object.defineProperty,Ry=(i,e,t)=>e in i?Yy(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Wt=(i,e,t)=>Ry(i,typeof e!="symbol"?e+"":e,t);class nn{constructor(e){Wt(this,"dataType","image"),Wt(this,"attribution","isource"),Wt(this,"minLevel",0),Wt(this,"maxLevel",18),Wt(this,"projectionID","3857"),Wt(this,"url",""),Wt(this,"subdomains",[]),Wt(this,"s",""),Wt(this,"opacity",1),Wt(this,"isTMS",!1),Wt(this,"bounds",[-180,-85,180,85]),Wt(this,"_projectionBounds",[-1/0,-1/0,1/0,1/0]),Wt(this,"tileMaterial"),Object.assign(this,e)}getUrl(e,t,n){const r={...this,x:e,y:t,z:n};return jy(this.url,r)}_getUrl(e,t,n){const r=this.subdomains.length;if(r>0){const a=Math.floor(Math.random()*r);this.s=this.subdomains[a]}const o=this.isTMS?Math.pow(2,n)-1-t:t;return this.getUrl(e,o,n)}static create(e){return new nn(e)}}function jy(i,e){const t=/\{ *([\w_-]+) *\}/g;return i.replace(t,(n,r)=>{const o=e[r]??(()=>{throw new Error(`source url template error, No value provided for variable: ${n}`)})();return typeof o=="function"?o(e):o})}const{version:Jy,author:Qy}=JSON.parse(By);function Hy(i,e=100){return new Promise(t=>{const n=setInterval(()=>{i&&(clearInterval(n),t())},e)})}function ha(i){return De.registerMaterialLoader(i),i}function da(i){return De.registerGeometryLoader(i),i}function fu(i){return De.registerMeshLoader(i),i}ha(new Ky);const pu="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIEsoayxkKXtjb25zdCB5PW5ldyBGbG9hdDMyQXJyYXkoay5sZW5ndGgpO2ZvcihsZXQgVj0wO1Y8ZC5sZW5ndGg7Vis9Myl7Y29uc3QgYT1kW1ZdKjMsZT1kW1YrMV0qMyxyPWRbVisyXSozLHM9a1thXSx0PWtbYSsxXSxuPWtbYSsyXSxoPWtbZV0saT1rW2UrMV0sbz1rW2UrMl0sYz1rW3JdLHU9a1tyKzFdLG09a1tyKzJdLHc9aC1zLGw9aS10LGY9by1uLGc9Yy1zLE09dS10LEQ9bS1uLHA9bCpELWYqTSxVPWYqZy13KkQsST13Kk0tbCpnLHo9TWF0aC5zcXJ0KHAqcCtVKlUrSSpJKSx4PVswLDAsMV07aWYoej4wKXtjb25zdCB2PTEvejt4WzBdPXAqdix4WzFdPVUqdix4WzJdPUkqdn1mb3IobGV0IHY9MDt2PDM7disrKXlbYSt2XT15W2Urdl09eVtyK3ZdPXhbdl19cmV0dXJuIHl9dmFyIFc9T2JqZWN0LmRlZmluZVByb3BlcnR5LFA9KGssZCx5KT0+ZCBpbiBrP1coayxkLHtlbnVtZXJhYmxlOiEwLGNvbmZpZ3VyYWJsZTohMCx3cml0YWJsZTohMCx2YWx1ZTp5fSk6a1tkXT15LF89KGssZCx5KT0+UChrLHR5cGVvZiBkIT0ic3ltYm9sIj9kKyIiOmQseSk7Y2xhc3MgZWV7Y29u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ZGVtRGF0YSxkLnosZC5jbGlwQm91bmRzKTtzZWxmLnBvc3RNZXNzYWdlKHkpfX0pKCk7Cg==",Ey=i=>Uint8Array.from(atob(i),e=>e.charCodeAt(0)),mu=typeof self<"u"&&self.Blob&&new Blob([Ey(pu)],{type:"text/javascript;charset=utf-8"});function $y(i){let e;try{if(e=mu&&(self.URL||self.webkitURL).createObjectURL(mu),!e)throw"";const t=new Worker(e,{name:i?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+pu,{name:i?.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}const qy=function(){var i={};i.defaultNoDataValue=-34027999387901484e22,i.decode=function(a,c){c=c||{};var u=c.encodedMaskData||c.encodedMaskData===null,d=r(a,c.inputOffset||0,u),m=c.noDataValue!==null?c.noDataValue:i.defaultNoDataValue,f=e(d,c.pixelType||Float32Array,c.encodedMaskData,m,c.returnMask),g={width:d.width,height:d.height,pixelData:f.resultPixels,minValue:f.minValue,maxValue:d.pixels.maxValue,noDataValue:m};return f.resultMask&&(g.maskData=f.resultMask),c.returnEncodedMask&&d.mask&&(g.encodedMaskData=d.mask.bitset?d.mask.bitset:null),c.returnFileInfo&&(g.fileInfo=t(d),c.computeUsedBitDepths&&(g.fileInfo.bitDepths=n(d))),g};var e=function(a,c,u,d,m){var f=0,g=a.pixels.numBlocksX,_=a.pixels.numBlocksY,w=Math.floor(a.width/g),b=Math.floor(a.height/_),x=2*a.maxZError,L=Number.MAX_VALUE,M;u=u||(a.mask?a.mask.bitset:null);var C,Z;C=new c(a.width*a.height),m&&u&&(Z=new Uint8Array(a.width*a.height));for(var z=new Float32Array(w*b),D,X,I=0;I<=_;I++){var K=I!==_?b:a.height%_;if(K!==0)for(var V=0;V<=g;V++){var G=V!==g?w:a.width%g;if(G!==0){var k=I*a.width*b+V*w,j=a.width-G,Y=a.pixels.blocks[f],H,Q,ie;Y.encoding<2?(Y.encoding===0?H=Y.rawData:(o(Y.stuffedData,Y.bitsPerPixel,Y.numValidPixels,Y.offset,x,z,a.pixels.maxValue),H=z),Q=0):Y.encoding===2?ie=0:ie=Y.offset;var re;if(u)for(X=0;X<K;X++){for(k&7&&(re=u[k>>3],re<<=k&7),D=0;D<G;D++)k&7||(re=u[k>>3]),re&128?(Z&&(Z[k]=1),M=Y.encoding<2?H[Q++]:ie,L=L>M?M:L,C[k++]=M):(Z&&(Z[k]=0),C[k++]=d),re<<=1;k+=j}else if(Y.encoding<2)for(X=0;X<K;X++){for(D=0;D<G;D++)M=H[Q++],L=L>M?M:L,C[k++]=M;k+=j}else for(L=L>ie?ie:L,X=0;X<K;X++){for(D=0;D<G;D++)C[k++]=ie;k+=j}if(Y.encoding===1&&Q!==Y.numValidPixels)throw"Block and Mask do not match";f++}}}return{resultPixels:C,resultMask:Z,minValue:L}},t=function(a){return{fileIdentifierString:a.fileIdentifierString,fileVersion:a.fileVersion,imageType:a.imageType,height:a.height,width:a.width,maxZError:a.maxZError,eofOffset:a.eofOffset,mask:a.mask?{numBlocksX:a.mask.numBlocksX,numBlocksY:a.mask.numBlocksY,numBytes:a.mask.numBytes,maxValue:a.mask.maxValue}:null,pixels:{numBlocksX:a.pixels.numBlocksX,numBlocksY:a.pixels.numBlocksY,numBytes:a.pixels.numBytes,maxValue:a.pixels.maxValue,noDataValue:a.noDataValue}}},n=function(a){for(var c=a.pixels.numBlocksX*a.pixels.numBlocksY,u={},d=0;d<c;d++){var m=a.pixels.blocks[d];m.encoding===0?u.float32=!0:m.encoding===1?u[m.bitsPerPixel]=!0:u[0]=!0}return Object.keys(u)},r=function(a,c,u){var d={},m=new Uint8Array(a,c,10);if(d.fileIdentifierString=String.fromCharCode.apply(null,m),d.fileIdentifierString.trim()!=="CntZImage")throw"Unexpected file identifier string: "+d.fileIdentifierString;c+=10;var f=new DataView(a,c,24);if(d.fileVersion=f.getInt32(0,!0),d.imageType=f.getInt32(4,!0),d.height=f.getUint32(8,!0),d.width=f.getUint32(12,!0),d.maxZError=f.getFloat64(16,!0),c+=24,!u)if(f=new DataView(a,c,16),d.mask={},d.mask.numBlocksY=f.getUint32(0,!0),d.mask.numBlocksX=f.getUint32(4,!0),d.mask.numBytes=f.getUint32(8,!0),d.mask.maxValue=f.getFloat32(12,!0),c+=16,d.mask.numBytes>0){var g=new Uint8Array(Math.ceil(d.width*d.height/8));f=new DataView(a,c,d.mask.numBytes);var _=f.getInt16(0,!0),w=2,b=0;do{if(_>0)for(;_--;)g[b++]=f.getUint8(w++);else{var x=f.getUint8(w++);for(_=-_;_--;)g[b++]=x}_=f.getInt16(w,!0),w+=2}while(w<d.mask.numBytes);if(_!==-32768||b<g.length)throw"Unexpected end of mask RLE encoding";d.mask.bitset=g,c+=d.mask.numBytes}else d.mask.numBytes|d.mask.numBlocksY|d.mask.maxValue||(d.mask.bitset=new Uint8Array(Math.ceil(d.width*d.height/8)));f=new DataView(a,c,16),d.pixels={},d.pixels.numBlocksY=f.getUint32(0,!0),d.pixels.numBlocksX=f.getUint32(4,!0),d.pixels.numBytes=f.getUint32(8,!0),d.pixels.maxValue=f.getFloat32(12,!0),c+=16;var L=d.pixels.numBlocksX,M=d.pixels.numBlocksY,C=L+(d.width%L>0?1:0),Z=M+(d.height%M>0?1:0);d.pixels.blocks=new Array(C*Z);for(var z=0,D=0;D<Z;D++)for(var X=0;X<C;X++){var I=0,K=a.byteLength-c;f=new DataView(a,c,Math.min(10,K));var V={};d.pixels.blocks[z++]=V;var G=f.getUint8(0);if(I++,V.encoding=G&63,V.encoding>3)throw"Invalid block encoding ("+V.encoding+")";if(V.encoding===2){c++;continue}if(G!==0&&G!==2){if(G>>=6,V.offsetType=G,G===2)V.offset=f.getInt8(1),I++;else if(G===1)V.offset=f.getInt16(1,!0),I+=2;else if(G===0)V.offset=f.getFloat32(1,!0),I+=4;else throw"Invalid block offset type";if(V.encoding===1)if(G=f.getUint8(I),I++,V.bitsPerPixel=G&63,G>>=6,V.numValidPixelsType=G,G===2)V.numValidPixels=f.getUint8(I),I++;else if(G===1)V.numValidPixels=f.getUint16(I,!0),I+=2;else if(G===0)V.numValidPixels=f.getUint32(I,!0),I+=4;else throw"Invalid valid pixel count type"}if(c+=I,V.encoding!==3){var k,j;if(V.encoding===0){var Y=(d.pixels.numBytes-1)/4;if(Y!==Math.floor(Y))throw"uncompressed block has invalid length";k=new ArrayBuffer(Y*4),j=new Uint8Array(k),j.set(new Uint8Array(a,c,Y*4));var H=new Float32Array(k);V.rawData=H,c+=Y*4}else if(V.encoding===1){var Q=Math.ceil(V.numValidPixels*V.bitsPerPixel/8),ie=Math.ceil(Q/4);k=new ArrayBuffer(ie*4),j=new Uint8Array(k),j.set(new Uint8Array(a,c,Q)),V.stuffedData=new Uint32Array(k),c+=Q}}}return d.eofOffset=c,d},o=function(a,c,u,d,m,f,g){var _=(1<<c)-1,w=0,b,x=0,L,M,C=Math.ceil((g-d)/m),Z=a.length*4-Math.ceil(c*u/8);for(a[a.length-1]<<=8*Z,b=0;b<u;b++){if(x===0&&(M=a[w++],x=32),x>=c)L=M>>>x-c&_,x-=c;else{var z=c-x;L=(M&_)<<z&_,M=a[w++],x=32-z,L+=M>>>x}f[b]=L<C?d+L*m:g}return f};return i}(),e_=function(){var i={unstuff:function(r,o,a,c,u,d,m,f){var g=(1<<a)-1,_=0,w,b=0,x,L,M,C,Z=r.length*4-Math.ceil(a*c/8);if(r[r.length-1]<<=8*Z,u)for(w=0;w<c;w++)b===0&&(L=r[_++],b=32),b>=a?(x=L>>>b-a&g,b-=a):(M=a-b,x=(L&g)<<M&g,L=r[_++],b=32-M,x+=L>>>b),o[w]=u[x];else for(C=Math.ceil((f-d)/m),w=0;w<c;w++)b===0&&(L=r[_++],b=32),b>=a?(x=L>>>b-a&g,b-=a):(M=a-b,x=(L&g)<<M&g,L=r[_++],b=32-M,x+=L>>>b),o[w]=x<C?d+x*m:f},unstuffLUT:function(r,o,a,c,u,d){var m=(1<<o)-1,f=0,g=0,_=0,w=0,b=0,x,L=[],M=r.length*4-Math.ceil(o*a/8);r[r.length-1]<<=8*M;var C=Math.ceil((d-c)/u);for(g=0;g<a;g++)w===0&&(x=r[f++],w=32),w>=o?(b=x>>>w-o&m,w-=o):(_=o-w,b=(x&m)<<_&m,x=r[f++],w=32-_,b+=x>>>w),L[g]=b<C?c+b*u:d;return L.unshift(c),L},unstuff2:function(r,o,a,c,u,d,m,f){var g=(1<<a)-1,_=0,w,b=0,x=0,L,M,C;if(u)for(w=0;w<c;w++)b===0&&(M=r[_++],b=32,x=0),b>=a?(L=M>>>x&g,b-=a,x+=a):(C=a-b,L=M>>>x&g,M=r[_++],b=32-C,L|=(M&(1<<C)-1)<<a-C,x=C),o[w]=u[L];else{var Z=Math.ceil((f-d)/m);for(w=0;w<c;w++)b===0&&(M=r[_++],b=32,x=0),b>=a?(L=M>>>x&g,b-=a,x+=a):(C=a-b,L=M>>>x&g,M=r[_++],b=32-C,L|=(M&(1<<C)-1)<<a-C,x=C),o[w]=L<Z?d+L*m:f}return o},unstuffLUT2:function(r,o,a,c,u,d){var m=(1<<o)-1,f=0,g=0,_=0,w=0,b=0,x=0,L,M=[],C=Math.ceil((d-c)/u);for(g=0;g<a;g++)w===0&&(L=r[f++],w=32,x=0),w>=o?(b=L>>>x&m,w-=o,x+=o):(_=o-w,b=L>>>x&m,L=r[f++],w=32-_,b|=(L&(1<<_)-1)<<o-_,x=_),M[g]=b<C?c+b*u:d;return M.unshift(c),M},originalUnstuff:function(r,o,a,c){var u=(1<<a)-1,d=0,m,f=0,g,_,w,b=r.length*4-Math.ceil(a*c/8);for(r[r.length-1]<<=8*b,m=0;m<c;m++)f===0&&(_=r[d++],f=32),f>=a?(g=_>>>f-a&u,f-=a):(w=a-f,g=(_&u)<<w&u,_=r[d++],f=32-w,g+=_>>>f),o[m]=g;return o},originalUnstuff2:function(r,o,a,c){var u=(1<<a)-1,d=0,m,f=0,g=0,_,w,b;for(m=0;m<c;m++)f===0&&(w=r[d++],f=32,g=0),f>=a?(_=w>>>g&u,f-=a,g+=a):(b=a-f,_=w>>>g&u,w=r[d++],f=32-b,_|=(w&(1<<b)-1)<<a-b,g=b),o[m]=_;return o}},e={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(r){for(var o=65535,a=65535,c=r.length,u=Math.floor(c/2),d=0;u;){var m=u>=359?359:u;u-=m;do o+=r[d++]<<8,a+=o+=r[d++];while(--m);o=(o&65535)+(o>>>16),a=(a&65535)+(a>>>16)}return c&1&&(a+=o+=r[d]<<8),o=(o&65535)+(o>>>16),a=(a&65535)+(a>>>16),(a<<16|o)>>>0},readHeaderInfo:function(r,o){var a=o.ptr,c=new Uint8Array(r,a,6),u={};if(u.fileIdentifierString=String.fromCharCode.apply(null,c),u.fileIdentifierString.lastIndexOf("Lerc2",0)!==0)throw"Unexpected file identifier string (expect Lerc2 ): "+u.fileIdentifierString;a+=6;var d=new DataView(r,a,8),m=d.getInt32(0,!0);u.fileVersion=m,a+=4,m>=3&&(u.checksum=d.getUint32(4,!0),a+=4),d=new DataView(r,a,12),u.height=d.getUint32(0,!0),u.width=d.getUint32(4,!0),a+=8,m>=4?(u.numDims=d.getUint32(8,!0),a+=4):u.numDims=1,d=new DataView(r,a,40),u.numValidPixel=d.getUint32(0,!0),u.microBlockSize=d.getInt32(4,!0),u.blobSize=d.getInt32(8,!0),u.imageType=d.getInt32(12,!0),u.maxZError=d.getFloat64(16,!0),u.zMin=d.getFloat64(24,!0),u.zMax=d.getFloat64(32,!0),a+=40,o.headerInfo=u,o.ptr=a;var f,g;if(m>=3&&(g=m>=4?52:48,f=this.computeChecksumFletcher32(new Uint8Array(r,a-g,u.blobSize-14)),f!==u.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(r,o){var a=o.headerInfo,c=this.getDataTypeArray(a.imageType),u=a.numDims*this.getDataTypeSize(a.imageType),d=this.readSubArray(r,o.ptr,c,u),m=this.readSubArray(r,o.ptr+u,c,u);o.ptr+=2*u;var f,g=!0;for(f=0;f<a.numDims;f++)if(d[f]!==m[f]){g=!1;break}return a.minValues=d,a.maxValues=m,g},readSubArray:function(r,o,a,c){var u;if(a===Uint8Array)u=new Uint8Array(r,o,c);else{var d=new ArrayBuffer(c),m=new Uint8Array(d);m.set(new Uint8Array(r,o,c)),u=new a(d)}return u},readMask:function(r,o){var a=o.ptr,c=o.headerInfo,u=c.width*c.height,d=c.numValidPixel,m=new DataView(r,a,4),f={};if(f.numBytes=m.getUint32(0,!0),a+=4,(d===0||u===d)&&f.numBytes!==0)throw"invalid mask";var g,_;if(d===0)g=new Uint8Array(Math.ceil(u/8)),f.bitset=g,_=new Uint8Array(u),o.pixels.resultMask=_,a+=f.numBytes;else if(f.numBytes>0){g=new Uint8Array(Math.ceil(u/8)),m=new DataView(r,a,f.numBytes);var w=m.getInt16(0,!0),b=2,x=0,L=0;do{if(w>0)for(;w--;)g[x++]=m.getUint8(b++);else for(L=m.getUint8(b++),w=-w;w--;)g[x++]=L;w=m.getInt16(b,!0),b+=2}while(b<f.numBytes);if(w!==-32768||x<g.length)throw"Unexpected end of mask RLE encoding";_=new Uint8Array(u);var M=0,C=0;for(C=0;C<u;C++)C&7?(M=g[C>>3],M<<=C&7):M=g[C>>3],M&128&&(_[C]=1);o.pixels.resultMask=_,f.bitset=g,a+=f.numBytes}return o.ptr=a,o.mask=f,!0},readDataOneSweep:function(r,o,a,c){var u=o.ptr,d=o.headerInfo,m=d.numDims,f=d.width*d.height,g=d.imageType,_=d.numValidPixel*e.getDataTypeSize(g)*m,w,b=o.pixels.resultMask;if(a===Uint8Array)w=new Uint8Array(r,u,_);else{var x=new ArrayBuffer(_),L=new Uint8Array(x);L.set(new Uint8Array(r,u,_)),w=new a(x)}if(w.length===f*m)c?o.pixels.resultPixels=e.swapDimensionOrder(w,f,m,a,!0):o.pixels.resultPixels=w;else{o.pixels.resultPixels=new a(f*m);var M=0,C=0,Z=0,z=0;if(m>1){if(c){for(C=0;C<f;C++)if(b[C])for(z=C,Z=0;Z<m;Z++,z+=f)o.pixels.resultPixels[z]=w[M++]}else for(C=0;C<f;C++)if(b[C])for(z=C*m,Z=0;Z<m;Z++)o.pixels.resultPixels[z+Z]=w[M++]}else for(C=0;C<f;C++)b[C]&&(o.pixels.resultPixels[C]=w[M++])}return u+=_,o.ptr=u,!0},readHuffmanTree:function(r,o){var a=this.HUFFMAN_LUT_BITS_MAX,c=new DataView(r,o.ptr,16);o.ptr+=16;var u=c.getInt32(0,!0);if(u<2)throw"unsupported Huffman version";var d=c.getInt32(4,!0),m=c.getInt32(8,!0),f=c.getInt32(12,!0);if(m>=f)return!1;var g=new Uint32Array(f-m);e.decodeBits(r,o,g);var _=[],w,b,x,L;for(w=m;w<f;w++)b=w-(w<d?0:d),_[b]={first:g[w-m],second:null};var M=r.byteLength-o.ptr,C=Math.ceil(M/4),Z=new ArrayBuffer(C*4),z=new Uint8Array(Z);z.set(new Uint8Array(r,o.ptr,M));var D=new Uint32Array(Z),X=0,I,K=0;for(I=D[0],w=m;w<f;w++)b=w-(w<d?0:d),L=_[b].first,L>0&&(_[b].second=I<<X>>>32-L,32-X>=L?(X+=L,X===32&&(X=0,K++,I=D[K])):(X+=L-32,K++,I=D[K],_[b].second|=I>>>32-X));var V=0,G=0,k=new t;for(w=0;w<_.length;w++)_[w]!==void 0&&(V=Math.max(V,_[w].first));V>=a?G=a:G=V;var j=[],Y,H,Q,ie,re,le;for(w=m;w<f;w++)if(b=w-(w<d?0:d),L=_[b].first,L>0)if(Y=[L,b],L<=G)for(H=_[b].second<<G-L,Q=1<<G-L,x=0;x<Q;x++)j[H|x]=Y;else for(H=_[b].second,le=k,ie=L-1;ie>=0;ie--)re=H>>>ie&1,re?(le.right||(le.right=new t),le=le.right):(le.left||(le.left=new t),le=le.left),ie===0&&!le.val&&(le.val=Y[1]);return{decodeLut:j,numBitsLUTQick:G,numBitsLUT:V,tree:k,stuffedData:D,srcPtr:K,bitPos:X}},readHuffman:function(r,o,a,c){var u=o.headerInfo,d=u.numDims,m=o.headerInfo.height,f=o.headerInfo.width,g=f*m,_=this.readHuffmanTree(r,o),w=_.decodeLut,b=_.tree,x=_.stuffedData,L=_.srcPtr,M=_.bitPos,C=_.numBitsLUTQick,Z=_.numBitsLUT,z=o.headerInfo.imageType===0?128:0,D,X,I,K=o.pixels.resultMask,V,G,k,j,Y,H,Q,ie=0;M>0&&(L++,M=0);var re=x[L],le=o.encodeMode===1,de=new a(g*d),ge=de,fe;if(d<2||le){for(fe=0;fe<d;fe++)if(d>1&&(ge=new a(de.buffer,g*fe,g),ie=0),o.headerInfo.numValidPixel===f*m)for(H=0,j=0;j<m;j++)for(Y=0;Y<f;Y++,H++){if(X=0,V=re<<M>>>32-C,G=V,32-M<C&&(V|=x[L+1]>>>64-M-C,G=V),w[G])X=w[G][1],M+=w[G][0];else for(V=re<<M>>>32-Z,G=V,32-M<Z&&(V|=x[L+1]>>>64-M-Z,G=V),D=b,Q=0;Q<Z;Q++)if(k=V>>>Z-Q-1&1,D=k?D.right:D.left,!(D.left||D.right)){X=D.val,M=M+Q+1;break}M>=32&&(M-=32,L++,re=x[L]),I=X-z,le?(Y>0?I+=ie:j>0?I+=ge[H-f]:I+=ie,I&=255,ge[H]=I,ie=I):ge[H]=I}else for(H=0,j=0;j<m;j++)for(Y=0;Y<f;Y++,H++)if(K[H]){if(X=0,V=re<<M>>>32-C,G=V,32-M<C&&(V|=x[L+1]>>>64-M-C,G=V),w[G])X=w[G][1],M+=w[G][0];else for(V=re<<M>>>32-Z,G=V,32-M<Z&&(V|=x[L+1]>>>64-M-Z,G=V),D=b,Q=0;Q<Z;Q++)if(k=V>>>Z-Q-1&1,D=k?D.right:D.left,!(D.left||D.right)){X=D.val,M=M+Q+1;break}M>=32&&(M-=32,L++,re=x[L]),I=X-z,le?(Y>0&&K[H-1]?I+=ie:j>0&&K[H-f]?I+=ge[H-f]:I+=ie,I&=255,ge[H]=I,ie=I):ge[H]=I}}else for(H=0,j=0;j<m;j++)for(Y=0;Y<f;Y++)if(H=j*f+Y,!K||K[H])for(fe=0;fe<d;fe++,H+=g){if(X=0,V=re<<M>>>32-C,G=V,32-M<C&&(V|=x[L+1]>>>64-M-C,G=V),w[G])X=w[G][1],M+=w[G][0];else for(V=re<<M>>>32-Z,G=V,32-M<Z&&(V|=x[L+1]>>>64-M-Z,G=V),D=b,Q=0;Q<Z;Q++)if(k=V>>>Z-Q-1&1,D=k?D.right:D.left,!(D.left||D.right)){X=D.val,M=M+Q+1;break}M>=32&&(M-=32,L++,re=x[L]),I=X-z,ge[H]=I}o.ptr=o.ptr+(L+1)*4+(M>0?4:0),o.pixels.resultPixels=de,d>1&&!c&&(o.pixels.resultPixels=e.swapDimensionOrder(de,g,d,a))},decodeBits:function(r,o,a,c,u){{var d=o.headerInfo,m=d.fileVersion,f=0,g=r.byteLength-o.ptr>=5?5:r.byteLength-o.ptr,_=new DataView(r,o.ptr,g),w=_.getUint8(0);f++;var b=w>>6,x=b===0?4:3-b,L=(w&32)>0,M=w&31,C=0;if(x===1)C=_.getUint8(f),f++;else if(x===2)C=_.getUint16(f,!0),f+=2;else if(x===4)C=_.getUint32(f,!0),f+=4;else throw"Invalid valid pixel count type";var Z=2*d.maxZError,z,D,X,I,K,V,G,k,j,Y=d.numDims>1?d.maxValues[u]:d.zMax;if(L){for(o.counter.lut++,k=_.getUint8(f),f++,I=Math.ceil((k-1)*M/8),K=Math.ceil(I/4),D=new ArrayBuffer(K*4),X=new Uint8Array(D),o.ptr+=f,X.set(new Uint8Array(r,o.ptr,I)),G=new Uint32Array(D),o.ptr+=I,j=0;k-1>>>j;)j++;I=Math.ceil(C*j/8),K=Math.ceil(I/4),D=new ArrayBuffer(K*4),X=new Uint8Array(D),X.set(new Uint8Array(r,o.ptr,I)),z=new Uint32Array(D),o.ptr+=I,m>=3?V=i.unstuffLUT2(G,M,k-1,c,Z,Y):V=i.unstuffLUT(G,M,k-1,c,Z,Y),m>=3?i.unstuff2(z,a,j,C,V):i.unstuff(z,a,j,C,V)}else o.counter.bitstuffer++,j=M,o.ptr+=f,j>0&&(I=Math.ceil(C*j/8),K=Math.ceil(I/4),D=new ArrayBuffer(K*4),X=new Uint8Array(D),X.set(new Uint8Array(r,o.ptr,I)),z=new Uint32Array(D),o.ptr+=I,m>=3?c==null?i.originalUnstuff2(z,a,j,C):i.unstuff2(z,a,j,C,!1,c,Z,Y):c==null?i.originalUnstuff(z,a,j,C):i.unstuff(z,a,j,C,!1,c,Z,Y))}},readTiles:function(r,o,a,c){var u=o.headerInfo,d=u.width,m=u.height,f=d*m,g=u.microBlockSize,_=u.imageType,w=e.getDataTypeSize(_),b=Math.ceil(d/g),x=Math.ceil(m/g);o.pixels.numBlocksY=x,o.pixels.numBlocksX=b,o.pixels.ptr=0;var L=0,M=0,C=0,Z=0,z=0,D=0,X=0,I=0,K=0,V=0,G=0,k=0,j=0,Y=0,H=0,Q=0,ie,re,le,de,ge,fe,Se=new a(g*g),rt=m%g||g,it=d%g||g,dt,Qe,Ye=u.numDims,Re,st=o.pixels.resultMask,ze=o.pixels.resultPixels,Vt=u.fileVersion,Nt=Vt>=5?14:15,Ce,ot=u.zMax,ft;for(C=0;C<x;C++)for(z=C!==x-1?g:rt,Z=0;Z<b;Z++)for(D=Z!==b-1?g:it,G=C*d*g+Z*g,k=d-D,Re=0;Re<Ye;Re++){if(Ye>1?(ft=ze,G=C*d*g+Z*g,ze=new a(o.pixels.resultPixels.buffer,f*Re*w,f),ot=u.maxValues[Re]):ft=null,X=r.byteLength-o.ptr,ie=new DataView(r,o.ptr,Math.min(10,X)),re={},Q=0,I=ie.getUint8(0),Q++,Ce=u.fileVersion>=5?I&4:0,K=I>>6&255,V=I>>2&Nt,V!==(Z*g>>3&Nt)||Ce&&Re===0)throw"integrity issue";if(fe=I&3,fe>3)throw o.ptr+=Q,"Invalid block encoding ("+fe+")";if(fe===2){if(Ce)if(st)for(L=0;L<z;L++)for(M=0;M<D;M++)st[G]&&(ze[G]=ft[G]),G++;else for(L=0;L<z;L++)for(M=0;M<D;M++)ze[G]=ft[G],G++;o.counter.constant++,o.ptr+=Q;continue}else if(fe===0){if(Ce)throw"integrity issue";if(o.counter.uncompressed++,o.ptr+=Q,j=z*D*w,Y=r.byteLength-o.ptr,j=j<Y?j:Y,le=new ArrayBuffer(j%w===0?j:j+w-j%w),de=new Uint8Array(le),de.set(new Uint8Array(r,o.ptr,j)),ge=new a(le),H=0,st)for(L=0;L<z;L++){for(M=0;M<D;M++)st[G]&&(ze[G]=ge[H++]),G++;G+=k}else for(L=0;L<z;L++){for(M=0;M<D;M++)ze[G++]=ge[H++];G+=k}o.ptr+=H*w}else if(dt=e.getDataTypeUsed(Ce&&_<6?4:_,K),Qe=e.getOnePixel(re,Q,dt,ie),Q+=e.getDataTypeSize(dt),fe===3)if(o.ptr+=Q,o.counter.constantoffset++,st)for(L=0;L<z;L++){for(M=0;M<D;M++)st[G]&&(ze[G]=Ce?Math.min(ot,ft[G]+Qe):Qe),G++;G+=k}else for(L=0;L<z;L++){for(M=0;M<D;M++)ze[G]=Ce?Math.min(ot,ft[G]+Qe):Qe,G++;G+=k}else if(o.ptr+=Q,e.decodeBits(r,o,Se,Qe,Re),Q=0,Ce)if(st)for(L=0;L<z;L++){for(M=0;M<D;M++)st[G]&&(ze[G]=Se[Q++]+ft[G]),G++;G+=k}else for(L=0;L<z;L++){for(M=0;M<D;M++)ze[G]=Se[Q++]+ft[G],G++;G+=k}else if(st)for(L=0;L<z;L++){for(M=0;M<D;M++)st[G]&&(ze[G]=Se[Q++]),G++;G+=k}else for(L=0;L<z;L++){for(M=0;M<D;M++)ze[G++]=Se[Q++];G+=k}}Ye>1&&!c&&(o.pixels.resultPixels=e.swapDimensionOrder(o.pixels.resultPixels,f,Ye,a))},formatFileInfo:function(r){return{fileIdentifierString:r.headerInfo.fileIdentifierString,fileVersion:r.headerInfo.fileVersion,imageType:r.headerInfo.imageType,height:r.headerInfo.height,width:r.headerInfo.width,numValidPixel:r.headerInfo.numValidPixel,microBlockSize:r.headerInfo.microBlockSize,blobSize:r.headerInfo.blobSize,maxZError:r.headerInfo.maxZError,pixelType:e.getPixelType(r.headerInfo.imageType),eofOffset:r.eofOffset,mask:r.mask?{numBytes:r.mask.numBytes}:null,pixels:{numBlocksX:r.pixels.numBlocksX,numBlocksY:r.pixels.numBlocksY,maxValue:r.headerInfo.zMax,minValue:r.headerInfo.zMin,noDataValue:r.noDataValue}}},constructConstantSurface:function(r,o){var a=r.headerInfo.zMax,c=r.headerInfo.zMin,u=r.headerInfo.maxValues,d=r.headerInfo.numDims,m=r.headerInfo.height*r.headerInfo.width,f=0,g=0,_=0,w=r.pixels.resultMask,b=r.pixels.resultPixels;if(w)if(d>1){if(o)for(f=0;f<d;f++)for(_=f*m,a=u[f],g=0;g<m;g++)w[g]&&(b[_+g]=a);else for(g=0;g<m;g++)if(w[g])for(_=g*d,f=0;f<d;f++)b[_+d]=u[f]}else for(g=0;g<m;g++)w[g]&&(b[g]=a);else if(d>1&&c!==a)if(o)for(f=0;f<d;f++)for(_=f*m,a=u[f],g=0;g<m;g++)b[_+g]=a;else for(g=0;g<m;g++)for(_=g*d,f=0;f<d;f++)b[_+f]=u[f];else for(g=0;g<m*d;g++)b[g]=a},getDataTypeArray:function(r){var o;switch(r){case 0:o=Int8Array;break;case 1:o=Uint8Array;break;case 2:o=Int16Array;break;case 3:o=Uint16Array;break;case 4:o=Int32Array;break;case 5:o=Uint32Array;break;case 6:o=Float32Array;break;case 7:o=Float64Array;break;default:o=Float32Array}return o},getPixelType:function(r){var o;switch(r){case 0:o="S8";break;case 1:o="U8";break;case 2:o="S16";break;case 3:o="U16";break;case 4:o="S32";break;case 5:o="U32";break;case 6:o="F32";break;case 7:o="F64";break;default:o="F32"}return o},isValidPixelValue:function(r,o){if(o==null)return!1;var a;switch(r){case 0:a=o>=-128&&o<=127;break;case 1:a=o>=0&&o<=255;break;case 2:a=o>=-32768&&o<=32767;break;case 3:a=o>=0&&o<=65536;break;case 4:a=o>=-2147483648&&o<=2147483647;break;case 5:a=o>=0&&o<=4294967296;break;case 6:a=o>=-34027999387901484e22&&o<=34027999387901484e22;break;case 7:a=o>=-17976931348623157e292&&o<=17976931348623157e292;break;default:a=!1}return a},getDataTypeSize:function(r){var o=0;switch(r){case 0:case 1:o=1;break;case 2:case 3:o=2;break;case 4:case 5:case 6:o=4;break;case 7:o=8;break;default:o=r}return o},getDataTypeUsed:function(r,o){var a=r;switch(r){case 2:case 4:a=r-o;break;case 3:case 5:a=r-2*o;break;case 6:o===0?a=r:o===1?a=2:a=1;break;case 7:o===0?a=r:a=r-2*o+1;break;default:a=r;break}return a},getOnePixel:function(r,o,a,c){var u=0;switch(a){case 0:u=c.getInt8(o);break;case 1:u=c.getUint8(o);break;case 2:u=c.getInt16(o,!0);break;case 3:u=c.getUint16(o,!0);break;case 4:u=c.getInt32(o,!0);break;case 5:u=c.getUInt32(o,!0);break;case 6:u=c.getFloat32(o,!0);break;case 7:u=c.getFloat64(o,!0);break;default:throw"the decoder does not understand this pixel type"}return u},swapDimensionOrder:function(r,o,a,c,u){var d=0,m=0,f=0,g=0,_=r;if(a>1)if(_=new c(o*a),u)for(d=0;d<o;d++)for(g=d,f=0;f<a;f++,g+=o)_[g]=r[m++];else for(d=0;d<o;d++)for(g=d,f=0;f<a;f++,g+=o)_[m++]=r[g];return _}},t=function(r,o,a){this.val=r,this.left=o,this.right=a},n={decode:function(r,o){o=o||{};var a=o.noDataValue,c=0,u={};if(u.ptr=o.inputOffset||0,u.pixels={},!!e.readHeaderInfo(r,u)){var d=u.headerInfo,m=d.fileVersion,f=e.getDataTypeArray(d.imageType);if(m>5)throw"unsupported lerc version 2."+m;e.readMask(r,u),d.numValidPixel!==d.width*d.height&&!u.pixels.resultMask&&(u.pixels.resultMask=o.maskData);var g=d.width*d.height;u.pixels.resultPixels=new f(g*d.numDims),u.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var _=!o.returnPixelInterleavedDims;if(d.numValidPixel!==0)if(d.zMax===d.zMin)e.constructConstantSurface(u,_);else if(m>=4&&e.checkMinMaxRanges(r,u))e.constructConstantSurface(u,_);else{var w=new DataView(r,u.ptr,2),b=w.getUint8(0);if(u.ptr++,b)e.readDataOneSweep(r,u,f,_);else if(m>1&&d.imageType<=1&&Math.abs(d.maxZError-.5)<1e-5){var x=w.getUint8(1);if(u.ptr++,u.encodeMode=x,x>2||m<4&&x>1)throw"Invalid Huffman flag "+x;x?e.readHuffman(r,u,f,_):e.readTiles(r,u,f,_)}else e.readTiles(r,u,f,_)}u.eofOffset=u.ptr;var L;o.inputOffset?(L=u.headerInfo.blobSize+o.inputOffset-u.ptr,Math.abs(L)>=1&&(u.eofOffset=o.inputOffset+u.headerInfo.blobSize)):(L=u.headerInfo.blobSize-u.ptr,Math.abs(L)>=1&&(u.eofOffset=u.headerInfo.blobSize));var M={width:d.width,height:d.height,pixelData:u.pixels.resultPixels,minValue:d.zMin,maxValue:d.zMax,validPixelCount:d.numValidPixel,dimCount:d.numDims,dimStats:{minValues:d.minValues,maxValues:d.maxValues},maskData:u.pixels.resultMask};if(u.pixels.resultMask&&e.isValidPixelValue(d.imageType,a)){var C=u.pixels.resultMask;for(c=0;c<g;c++)C[c]||(M.pixelData[c]=a);M.noDataValue=a}return u.noDataValue=a,o.returnFileInfo&&(M.fileInfo=e.formatFileInfo(u)),M}},getBandCount:function(r){var o=0,a=0,c={};for(c.ptr=0,c.pixels={};a<r.byteLength-58;)e.readHeaderInfo(r,c),a+=c.headerInfo.blobSize,o++,c.ptr=a;return o}};return n}();var t_=function(){var i=new ArrayBuffer(4),e=new Uint8Array(i),t=new Uint32Array(i);return t[0]=1,e[0]===1}(),n_={decode:function(i,e){if(!t_)throw"Big endian system is not supported.";e=e||{};var t=e.inputOffset||0,n=new Uint8Array(i,t,10),r=String.fromCharCode.apply(null,n),o,a;if(r.trim()==="CntZImage")o=qy,a=1;else if(r.substring(0,5)==="Lerc2")o=e_,a=2;else throw"Unexpected file identifier string: "+r;for(var c=0,u=i.byteLength-10,d,m=[],f,g,_={width:0,height:0,pixels:[],pixelType:e.pixelType,mask:null,statistics:[]},w=0;t<u;){var b=o.decode(i,{inputOffset:t,encodedMaskData:d,maskData:g,returnMask:c===0,returnEncodedMask:c===0,returnFileInfo:!0,returnPixelInterleavedDims:e.returnPixelInterleavedDims,pixelType:e.pixelType||null,noDataValue:e.noDataValue||null});t=b.fileInfo.eofOffset,g=b.maskData,c===0&&(d=b.encodedMaskData,_.width=b.width,_.height=b.height,_.dimCount=b.dimCount||1,_.pixelType=b.pixelType||b.fileInfo.pixelType,_.mask=g),a>1&&(g&&m.push(g),b.fileInfo.mask&&b.fileInfo.mask.numBytes>0&&w++),c++,_.pixels.push(b.pixelData),_.statistics.push({minValue:b.minValue,maxValue:b.maxValue,noDataValue:b.noDataValue,dimStats:b.dimStats})}var x,L,M;if(a>1&&w>1){for(M=_.width*_.height,_.bandMasks=m,g=new Uint8Array(M),g.set(m[0]),x=1;x<m.length;x++)for(f=m[x],L=0;L<M;L++)g[L]=g[L]&f[L];_.maskData=g}return _}};const r_={0:7e3,1:6e3,2:5e3,3:4e3,4:3e3,5:2500,6:2e3,7:1500,8:800,9:500,10:200,11:100,12:40,13:12,14:5,15:2,16:1,17:.5,18:.2,19:.1,20:.01};function i_(i){const{height:e,width:t,pixels:n}=n_.decode(i),r=new Float32Array(e*t);for(let o=0;o<r.length;o++)r[o]=n[0][o];return{array:r,width:t,height:e}}function s_(i,e,t){let n=i_(i);t[2]-t[0]<1&&(n=o_(n,t));const{array:r,width:o}=n,c=new lu(o).createTile(r),u=r_[e]||0;return c.getGeometryData(u)}function o_(i,e){function t(c,u,d,m,f,g,_,w){const b=new Float32Array(f*g);for(let L=0;L<g;L++)for(let M=0;M<f;M++){const C=(L+m)*u+(M+d),Z=L*f+M;b[Z]=c[C]}const x=new Float32Array(w*_);for(let L=0;L<w;L++)for(let M=0;M<_;M++){const C=L*w+M,Z=Math.round(M*g/w),D=Math.round(L*f/_)*f+Z;x[C]=b[D]}return x}const n=a_(e,i.width),r=n.sw+1,o=n.sh+1;return{array:t(i.array,i.width,n.sx,n.sy,n.sw,n.sh,r,o),width:r,height:o}}function a_(i,e){const t=Math.floor(i[0]*e),n=Math.floor(i[1]*e),r=Math.floor((i[2]-i[0])*e),o=Math.floor((i[3]-i[1])*e);return{sx:t,sy:n,sw:r,sh:o}}var l_=Object.defineProperty,c_=(i,e,t)=>e in i?l_(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,xs=(i,e,t)=>c_(i,typeof e!="symbol"?e+"":e,t);const u_=10;class h_ extends aa{constructor(){super(),xs(this,"info",{version:"0.10.0",description:"Tile LERC terrain loader. It can load ArcGis-lerc format terrain data."}),xs(this,"dataType","lerc"),xs(this,"fileLoader",new p.FileLoader(De.manager)),xs(this,"_workerPool",new jo(0)),this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new $y)}async doLoad(e,t){this._workerPool.pool===0&&this._workerPool.setWorkerLimit(u_);const{z:n,bounds:r}=t,o=await this.fileLoader.loadAsync(e).catch(()=>new Float32Array(256*256)),a=s_(o,n,r);return new kr().setData(a)}}da(new h_);const gu="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGModCl7cmV0dXJuIGEodC5kYXRhKX1mdW5jdGlvbiBhKHQpe2Z1bmN0aW9uIG4oZSx1KXtjb25zdCByPXUqNCxbaSxmLGcsbF09ZS5zbGljZShyLHIrNCk7cmV0dXJuIGw9PT0wPzA6LTFlNCsoaTw8MTZ8Zjw8OHxnKSouMX1jb25zdCBvPXQubGVuZ3RoPj4+MixzPW5ldyBGbG9hdDMyQXJyYXkobyk7Zm9yKGxldCBlPTA7ZTxvO2UrKylzW2VdPW4odCxlKTtyZXR1cm4gc31zZWxmLm9ubWVzc2FnZT10PT57Y29uc3Qgbj1jKHQuZGF0YS5pbWdEYXRhKTtzZWxmLnBvc3RNZXNzYWdlKG4pfX0pKCk7Cg==",d_=i=>Uint8Array.from(atob(i),e=>e.charCodeAt(0)),yu=typeof self<"u"&&self.Blob&&new Blob([d_(gu)],{type:"text/javascript;charset=utf-8"});function f_(i){let e;try{if(e=yu&&(self.URL||self.webkitURL).createObjectURL(yu),!e)throw"";const t=new Worker(e,{name:i?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+gu,{name:i?.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}var p_=Object.defineProperty,m_=(i,e,t)=>e in i?p_(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ms=(i,e,t)=>m_(i,typeof e!="symbol"?e+"":e,t);const g_=10;class y_ extends aa{constructor(){super(),Ms(this,"info",{version:"0.10.0",description:"Mapbox-RGB terrain loader, It can load Mapbox-RGB terrain data."}),Ms(this,"dataType","terrain-rgb"),Ms(this,"imageLoader",new p.ImageLoader(De.manager)),Ms(this,"_workerPool",new jo(0)),this._workerPool.setWorkerCreator(()=>new f_)}async doLoad(e,t){const n=await this.imageLoader.loadAsync(e).catch(u=>new Image),r=p.MathUtils.clamp((t.z+2)*3,2,64),o=__(n,t.bounds,r);let a;this._workerPool.pool===0&&this._workerPool.setWorkerLimit(g_),a=(await this._workerPool.postMessage({imgData:o},[o.data.buffer])).data;const c=new kr;return c.setData(a),c}}function __(i,e,t){const n=na(e,i.width);t=Math.min(t,n.sw);const o=new OffscreenCanvas(t,t).getContext("2d");return o.imageSmoothingEnabled=!1,o.drawImage(i,n.sx,n.sy,n.sw,n.sh,0,0,t,t),o.getImageData(0,0,t,t)}da(new y_);function Qn(i,e){this.x=i,this.y=e}Qn.prototype={clone(){return new Qn(this.x,this.y)},add(i){return this.clone()._add(i)},sub(i){return this.clone()._sub(i)},multByPoint(i){return this.clone()._multByPoint(i)},divByPoint(i){return this.clone()._divByPoint(i)},mult(i){return this.clone()._mult(i)},div(i){return this.clone()._div(i)},rotate(i){return this.clone()._rotate(i)},rotateAround(i,e){return this.clone()._rotateAround(i,e)},matMult(i){return this.clone()._matMult(i)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(i){return this.x===i.x&&this.y===i.y},dist(i){return Math.sqrt(this.distSqr(i))},distSqr(i){const e=i.x-this.x,t=i.y-this.y;return e*e+t*t},angle(){return Math.atan2(this.y,this.x)},angleTo(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith(i){return this.angleWithSep(i.x,i.y)},angleWithSep(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult(i){const e=i[0]*this.x+i[1]*this.y,t=i[2]*this.x+i[3]*this.y;return this.x=e,this.y=t,this},_add(i){return this.x+=i.x,this.y+=i.y,this},_sub(i){return this.x-=i.x,this.y-=i.y,this},_mult(i){return this.x*=i,this.y*=i,this},_div(i){return this.x/=i,this.y/=i,this},_multByPoint(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint(i){return this.x/=i.x,this.y/=i.y,this},_unit(){return this._div(this.mag()),this},_perp(){const i=this.y;return this.y=this.x,this.x=-i,this},_rotate(i){const e=Math.cos(i),t=Math.sin(i),n=e*this.x-t*this.y,r=t*this.x+e*this.y;return this.x=n,this.y=r,this},_rotateAround(i,e){const t=Math.cos(i),n=Math.sin(i),r=e.x+t*(this.x-e.x)-n*(this.y-e.y),o=e.y+n*(this.x-e.x)+t*(this.y-e.y);return this.x=r,this.y=o,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Qn},Qn.convert=function(i){if(i instanceof Qn)return i;if(Array.isArray(i))return new Qn(+i[0],+i[1]);if(i.x!==void 0&&i.y!==void 0)return new Qn(+i.x,+i.y);throw new Error("Expected [x, y] or {x, y} point format")};class _u{constructor(e,t,n,r,o){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=o,e.readFields(v_,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let r,o=1,a=0,c=0,u=0;for(;e.pos<t;){if(a<=0){const d=e.readVarint();o=d&7,a=d>>3}if(a--,o===1||o===2)c+=e.readSVarint(),u+=e.readSVarint(),o===1&&(r&&n.push(r),r=[]),r&&r.push(new Qn(c,u));else if(o===7)r&&r.push(r[0].clone());else throw new Error(`unknown command ${o}`)}return r&&n.push(r),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n=1,r=0,o=0,a=0,c=1/0,u=-1/0,d=1/0,m=-1/0;for(;e.pos<t;){if(r<=0){const f=e.readVarint();n=f&7,r=f>>3}if(r--,n===1||n===2)o+=e.readSVarint(),a+=e.readSVarint(),o<c&&(c=o),o>u&&(u=o),a<d&&(d=a),a>m&&(m=a);else if(n!==7)throw new Error(`unknown command ${n}`)}return[c,d,u,m]}toGeoJSON(e,t,n){const r=this.extent*Math.pow(2,n),o=this.extent*e,a=this.extent*t,c=this.loadGeometry();function u(g){return[(g.x+o)*360/r-180,360/Math.PI*Math.atan(Math.exp((1-(g.y+a)*2/r)*Math.PI))-90]}function d(g){return g.map(u)}let m;if(this.type===1){const g=[];for(const w of c)g.push(w[0]);const _=d(g);m=g.length===1?{type:"Point",coordinates:_[0]}:{type:"MultiPoint",coordinates:_}}else if(this.type===2){const g=c.map(d);m=g.length===1?{type:"LineString",coordinates:g[0]}:{type:"MultiLineString",coordinates:g}}else if(this.type===3){const g=b_(c),_=[];for(const w of g)_.push(w.map(d));m=_.length===1?{type:"Polygon",coordinates:_[0]}:{type:"MultiPolygon",coordinates:_}}else throw new Error("unknown feature type");const f={type:"Feature",geometry:m,properties:this.properties};return this.id!=null&&(f.id=this.id),f}}_u.types=["Unknown","Point","LineString","Polygon"];function v_(i,e,t){i===1?e.id=t.readVarint():i===2?w_(t,e):i===3?e.type=t.readVarint():i===4&&(e._geometry=t.pos)}function w_(i,e){const t=i.readVarint()+i.pos;for(;i.pos<t;){const n=e._keys[i.readVarint()],r=e._values[i.readVarint()];e.properties[n]=r}}function b_(i){const e=i.length;if(e<=1)return[i];const t=[];let n,r;for(let o=0;o<e;o++){const a=x_(i[o]);a!==0&&(r===void 0&&(r=a<0),r===a<0?(n&&t.push(n),n=[i[o]]):n&&n.push(i[o]))}return n&&t.push(n),t}function x_(i){let e=0;for(let t=0,n=i.length,r=n-1,o,a;t<n;r=t++)o=i[t],a=i[r],e+=(a.x-o.x)*(o.y+a.y);return e}let M_=class{constructor(e,t){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(S_,this,t),this.length=this._features.length}feature(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];const t=this._pbf.readVarint()+this._pbf.pos;return new _u(this._pbf,t,this.extent,this._keys,this._values)}};function S_(i,e,t){i===15?e.version=t.readVarint():i===1?e.name=t.readString():i===5?e.extent=t.readVarint():i===2?e._features.push(t.pos):i===3?e._keys.push(t.readString()):i===4&&e._values.push(L_(t))}function L_(i){let e=null;const t=i.readVarint()+i.pos;for(;i.pos<t;){const n=i.readVarint()>>3;e=n===1?i.readString():n===2?i.readFloat():n===3?i.readDouble():n===4?i.readVarint64():n===5?i.readVarint():n===6?i.readSVarint():n===7?i.readBoolean():null}if(e==null)throw new Error("unknown feature value");return e}class P_{constructor(e,t){this.layers=e.readFields(C_,{},t)}}function C_(i,e,t){if(i===3){const n=new M_(t,t.readVarint()+t.pos);n.length&&(e[n.name]=n)}}const fa=65536*65536,vu=1/fa,T_=12,wu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),pa=0,Ss=1,Gi=2,Ls=5;class G_{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,n=this.length){for(;this.pos<n;){const r=this.readVarint(),o=r>>3,a=this.pos;this.type=r&7,e(o,t,this),this.pos===a&&this.skip(r)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*fa;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*fa;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let n,r;return r=t[this.pos++],n=r&127,r<128||(r=t[this.pos++],n|=(r&127)<<7,r<128)||(r=t[this.pos++],n|=(r&127)<<14,r<128)||(r=t[this.pos++],n|=(r&127)<<21,r<128)?n:(r=t[this.pos],n|=(r&15)<<28,Z_(n,e,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2===1?(e+1)/-2:e/2}readBoolean(){return!!this.readVarint()}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=T_&&wu?wu.decode(this.buf.subarray(t,e)):N_(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const n=this.readPackedEnd();for(;this.pos<n;)e.push(this.readVarint(t));return e}readPackedSVarint(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSVarint());return e}readPackedBoolean(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readBoolean());return e}readPackedFloat(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFloat());return e}readPackedDouble(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readDouble());return e}readPackedFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed32());return e}readPackedSFixed32(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed32());return e}readPackedFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readFixed64());return e}readPackedSFixed64(e=[]){const t=this.readPackedEnd();for(;this.pos<t;)e.push(this.readSFixed64());return e}readPackedEnd(){return this.type===Gi?this.readVarint()+this.pos:this.pos+1}skip(e){const t=e&7;if(t===pa)for(;this.buf[this.pos++]>127;);else if(t===Gi)this.pos=this.readVarint()+this.pos;else if(t===Ls)this.pos+=4;else if(t===Ss)this.pos+=8;else throw new Error(`Unimplemented type: ${t}`)}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t<this.pos+e;)t*=2;if(t!==this.length){const n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.dataView=new DataView(n.buffer),this.length=t}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeSFixed32(e){this.realloc(4),this.dataView.setInt32(this.pos,e,!0),this.pos+=4}writeFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,e&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*vu),!0),this.pos+=8}writeSFixed64(e){this.realloc(8),this.dataView.setInt32(this.pos,e&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(e*vu),!0),this.pos+=8}writeVarint(e){if(e=+e||0,e>268435455||e<0){W_(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))}writeSVarint(e){this.writeVarint(e<0?-e*2-1:e*2)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(e.length*4),this.pos++;const t=this.pos;this.pos=B_(this.buf,e,this.pos);const n=this.pos-t;n>=128&&bu(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let n=0;n<t;n++)this.buf[this.pos++]=e[n]}writeRawMessage(e,t){this.pos++;const n=this.pos;e(t,this);const r=this.pos-n;r>=128&&bu(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,n){this.writeTag(e,Gi),this.writeRawMessage(t,n)}writePackedVarint(e,t){t.length&&this.writeMessage(e,A_,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,F_,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,z_,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,O_,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,D_,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,X_,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,U_,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,k_,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,K_,t)}writeBytesField(e,t){this.writeTag(e,Gi),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,Ls),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,Ls),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,Ss),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,Ss),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,pa),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,pa),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,Gi),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,Ls),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,Ss),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function Z_(i,e,t){const n=t.buf;let r,o;if(o=n[t.pos++],r=(o&112)>>4,o<128||(o=n[t.pos++],r|=(o&127)<<3,o<128)||(o=n[t.pos++],r|=(o&127)<<10,o<128)||(o=n[t.pos++],r|=(o&127)<<17,o<128)||(o=n[t.pos++],r|=(o&127)<<24,o<128)||(o=n[t.pos++],r|=(o&1)<<31,o<128))return Kr(i,r,e);throw new Error("Expected varint not more than 10 bytes")}function Kr(i,e,t){return t?e*4294967296+(i>>>0):(e>>>0)*4294967296+(i>>>0)}function W_(i,e){let t,n;if(i>=0?(t=i%4294967296|0,n=i/4294967296|0):(t=~(-i%4294967296),n=~(-i/4294967296),t^4294967295?t=t+1|0:(t=0,n=n+1|0)),i>=18446744073709552e3||i<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),V_(t,n,e),I_(n,e)}function V_(i,e,t){t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos++]=i&127|128,i>>>=7,t.buf[t.pos]=i&127}function I_(i,e){const t=(i&7)<<4;e.buf[e.pos++]|=t|((i>>>=3)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127|((i>>>=7)?128:0),i&&(e.buf[e.pos++]=i&127)))))}function bu(i,e,t){const n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));t.realloc(n);for(let r=t.pos-1;r>=i;r--)t.buf[r+n]=t.buf[r]}function A_(i,e){for(let t=0;t<i.length;t++)e.writeVarint(i[t])}function F_(i,e){for(let t=0;t<i.length;t++)e.writeSVarint(i[t])}function O_(i,e){for(let t=0;t<i.length;t++)e.writeFloat(i[t])}function D_(i,e){for(let t=0;t<i.length;t++)e.writeDouble(i[t])}function z_(i,e){for(let t=0;t<i.length;t++)e.writeBoolean(i[t])}function X_(i,e){for(let t=0;t<i.length;t++)e.writeFixed32(i[t])}function U_(i,e){for(let t=0;t<i.length;t++)e.writeSFixed32(i[t])}function k_(i,e){for(let t=0;t<i.length;t++)e.writeFixed64(i[t])}function K_(i,e){for(let t=0;t<i.length;t++)e.writeSFixed64(i[t])}function N_(i,e,t){let n="",r=e;for(;r<t;){const o=i[r];let a=null,c=o>239?4:o>223?3:o>191?2:1;if(r+c>t)break;let u,d,m;c===1?o<128&&(a=o):c===2?(u=i[r+1],(u&192)===128&&(a=(o&31)<<6|u&63,a<=127&&(a=null))):c===3?(u=i[r+1],d=i[r+2],(u&192)===128&&(d&192)===128&&(a=(o&15)<<12|(u&63)<<6|d&63,(a<=2047||a>=55296&&a<=57343)&&(a=null))):c===4&&(u=i[r+1],d=i[r+2],m=i[r+3],(u&192)===128&&(d&192)===128&&(m&192)===128&&(a=(o&15)<<18|(u&63)<<12|(d&63)<<6|m&63,(a<=65535||a>=1114112)&&(a=null))),a===null?(a=65533,c=1):a>65535&&(a-=65536,n+=String.fromCharCode(a>>>10&1023|55296),a=56320|a&1023),n+=String.fromCharCode(a),r+=c}return n}function B_(i,e,t){for(let n=0,r,o;n<e.length;n++){if(r=e.charCodeAt(n),r>55295&&r<57344)if(o)if(r<56320){i[t++]=239,i[t++]=191,i[t++]=189,o=r;continue}else r=o-55296<<10|r-56320|65536,o=null;else{r>56319||n+1===e.length?(i[t++]=239,i[t++]=191,i[t++]=189):o=r;continue}else o&&(i[t++]=239,i[t++]=191,i[t++]=189,o=null);r<128?i[t++]=r:(r<2048?i[t++]=r>>6|192:(r<65536?i[t++]=r>>12|224:(i[t++]=r>>18|240,i[t++]=r>>12&63|128),i[t++]=r>>6&63|128),i[t++]=r&63|128)}return t}var Y_=Object.defineProperty,R_=(i,e,t)=>e in i?Y_(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ma=(i,e,t)=>R_(i,typeof e!="symbol"?e+"":e,t);class j_ extends ca{constructor(){super(),ma(this,"dataType","mvt"),ma(this,"_loader",new p.FileLoader(De.manager)),ma(this,"_render",new uu),this._loader.setResponseType("arraybuffer")}async doLoad(e,t){const n=await this._loader.loadAsync(e),r=new P_(new G_(n)),o=this.drawTile(r,t.source.style,t.z);return new p.CanvasTexture(o)}drawTile(e,t,n){const c=new OffscreenCanvas(256,256).getContext("2d");if(c){if(t)for(const u in t.layer){const d=t.layer[u];if(t&&(n<(d.minLevel??1)||n>(d.maxLevel??20)))continue;const m=e.layers[u];if(m){const f=256/m.extent;this._renderLayer(c,m,d,f)}}else for(const u in e.layers){const d=e.layers[u],m=256/d.extent;this._renderLayer(c,d,void 0,m)}return c.canvas}else throw new Error("Canvas context is not available")}_renderLayer(e,t,n,r=1){e.save();for(let o=0;o<t.length;o++){const a=t.feature(o);this._renderFeature(e,a,n,r)}return e.restore(),this}_renderFeature(e,t,n={},r=1){const o=[nt.Unknown,nt.Point,nt.Linestring,nt.Polygon][t.type],a={geometry:t.loadGeometry(),properties:t.properties};this._render.render(e,o,a,n,r)}_convertToGeoJSONFeature(e,t){const n=this._convertGeometryToGeoJSON(e.geometry,t);return n?{type:"Feature",geometry:n,properties:e.properties||{},id:e.id}:null}_convertGeometryToGeoJSON(e,t){switch(t){case nt.Point:return this._convertPointGeometry(e);case nt.Linestring:return this._convertLineGeometry(e);case nt.Polygon:return this._convertPolygonGeometry(e);default:return console.warn("未知的几何类型:",t),null}}_convertPointGeometry(e){const t=[];for(const n of e)for(const r of n)t.push([r.x,r.y]);return t.length===0?null:t.length===1?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}_convertLineGeometry(e){const t=[];for(const n of e){const r=[];for(const o of n)r.push([o.x,o.y]);r.length>=2&&t.push(r)}return t.length===0?null:t.length===1?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}}_convertPolygonGeometry(e){const t=[];let n=[];for(const r of e){const o=[];for(const a of r)o.push([a.x,a.y]);o.length>=4&&(this._isRingClockwise(o)||n.length===0?(n.length>0&&t.push(n),n=[o]):n.push(o))}return n.length>0&&t.push(n),t.length===0?null:t.length===1?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t}}_isRingClockwise(e){let t=0;for(let n=0;n<e.length-1;n++){const[r,o]=e[n],[a,c]=e[n+1];t+=(a-r)*(c+o)}return t>0}convertVectorTileToGeoJSON(e){const t=[];for(const n in e.layers){const r=e.layers[n];for(let o=0;o<r.length;o++){const a=r.feature(o),c=[nt.Unknown,nt.Point,nt.Linestring,nt.Polygon][a.type],u={geometry:a.loadGeometry(),properties:a.properties},d=this._convertToGeoJSONFeature(u,c);d&&(d.properties._layer=n,t.push(d))}}return{type:"FeatureCollection",features:t}}}ha(new j_);const xu="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IF89MjMyODMwNjQzNjUzODY5NjNlLTI2LG09MTIsUD10eXBlb2YgVGV4dERlY29kZXI+InUiP251bGw6bmV3IFRleHREZWNvZGVyKCJ1dGYtOCIpLGc9MCx5PTEsRj0yLHA9NTtjbGFzcyBNe2NvbnN0cnVjdG9yKHQ9bmV3IFVpbnQ4QXJyYXkoMTYpKXt0aGlzLmJ1Zj1BcnJheUJ1ZmZlci5pc1ZpZXcodCk/dDpuZXcgVWludDhBcnJheSh0KSx0aGlzLmRhdGFWaWV3PW5ldyBEYXRhVmlldyh0aGlzLmJ1Zi5idWZmZXIpLHRoaXMucG9zPTAsdGhpcy50eXBlPTAsdGhpcy5sZW5ndGg9dGhpcy5idWYubGVuZ3RofXJlYWRGaWVsZHModCxlLHI9dGhpcy5sZW5ndGgpe2Zvcig7dGhpcy5wb3M8cjspe2NvbnN0IHM9dGhpcy5yZWFkVmFyaW50KCksbj1zPj4zLG89dGhpcy5wb3M7dGhpcy50eXBlPXMmNyx0KG4sZSx0aGlzKSx0aGlzLnBvcz09PW8mJnRoaXMuc2tpcChzKX1yZXR1cm4gZX1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e2Vycm9yOmUubWVzc2FnZX0pfX19KSgpOwo=",J_=i=>Uint8Array.from(atob(i),e=>e.charCodeAt(0)),Mu=typeof self<"u"&&self.Blob&&new Blob([J_(xu)],{type:"text/javascript;charset=utf-8"});function Q_(i){let e;try{if(e=Mu&&(self.URL||self.webkitURL).createObjectURL(Mu),!e)throw"";const t=new Worker(e,{name:i?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+xu,{name:i?.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}var H_=Object.defineProperty,E_=(i,e,t)=>e in i?H_(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ps=(i,e,t)=>E_(i,typeof e!="symbol"?e+"":e,t);const $_=10;class q_{constructor(){Ps(this,"info",{version:"1.0.0",description:"Vector Tile loader for Mapbox Vector Tile format. It can load and parse MVT data."}),Ps(this,"dataType","VectorTile"),Ps(this,"fileLoader",new p.FileLoader(De.manager)),Ps(this,"_workerPool",new jo(0)),this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new Q_)}async load(e){const{source:t,x:n,y:r,z:o}=e,a=typeof t._getUrl=="function"?t._getUrl(n,r,o):this.buildTileUrl(t.url,n,r,o);if(!a)return this.createErrorGeometry(n,r,o,new Error("VectorTileLoader: source._getUrl 返回空 URL"));this._workerPool.pool===0&&this._workerPool.setWorkerLimit($_);try{const c=await this.fetchVectorData(a),u={arrayBuffer:c,x:n,y:r,z:o},m=(await this._workerPool.postMessage(u,[c])).data;if(m.error)throw new Error(m.error);const f=this.createGeometryWithVectorData(m,e);return De.manager.parseEnd(a),f}catch(c){return this.createErrorGeometry(n,r,o,c)}}async fetchVectorData(e){try{const t=await this.fileLoader.loadAsync(e);if(!t||t.byteLength===0)throw new Error("Empty response");return t}catch(t){throw new Error(`Failed to fetch vector tile: ${t.message}`)}}calculateTileBounds(e,t,n){const r=4007501668557849e-8/Math.pow(2,n),o=-20037508342789244e-9+e*r,a=o+r,c=20037508342789244e-9-(t+1)*r,u=c+r;return{min:new p.Vector2(o,c),max:new p.Vector2(a,u),world:new p.Vector2(r,r)}}buildTileUrl(e,t,n,r){return e.replace("{x}",t.toString()).replace("{y}",n.toString()).replace("{z}",r.toString()).replace("{-y}",(Math.pow(2,r)-1-n).toString())}createGeometryWithVectorData(e,t){const n=new kr;return n.userData={vectorData:e,tileInfo:{x:t.x,y:t.y,z:t.z,bounds:t.bounds},metadata:{dataType:"vector-tile",version:"1.0.0",loadedAt:Date.now()}},n}createErrorGeometry(e,t,n,r){const o=new kr;return o.userData={vectorData:{x:e,y:t,z:n,layers:{},totalFeatures:0,bounds:this.calculateTileBounds(e,t,n),error:r.message,timestamp:Date.now(),dataFormat:"error"},tileInfo:{x:e,y:t,z:n,bounds:[0,0,0,0]},metadata:{dataType:"vector-tile-error",error:!0,errorMessage:r.message}},o}unload(e){e.userData?.vectorData&&(e.userData.vectorData=null),e.dispose&&e.dispose()}static getVectorData(e){return e.userData?.vectorData||null}static hasValidVectorData(e){const t=this.getVectorData(e);return t&&!t.error&&t.totalFeatures>0}static getLayerNames(e){const t=this.getVectorData(e);return t?Object.keys(t.layers||{}):[]}static getFeaturesByLayer(e,t){return this.getVectorData(e)?.layers?.[t]?.convertedFeatures||[]}}fu(new q_);var ev=Object.defineProperty,tv=(i,e,t)=>e in i?ev(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Hn=(i,e,t)=>tv(i,typeof e!="symbol"?e+"":e,t);class ga extends ru{constructor(e,t){if(super(e,t),Hn(this,"layerType","vector"),Hn(this,"_tileDataMap",new Map),Hn(this,"_renderer"),Hn(this,"_style"),Hn(this,"_feaList",[]),Hn(this,"_collision",!1),Hn(this,"_renderAltitude",0),Hn(this,"_eventsBound",!1),!t.style)throw new Error("VectorTileLayer must provide style configuration! VectorTileLayer 必须提供样式配置");this._style=t.style,this._collision=t.collision||!1,this._featureFilter=t.featureFilter,this._renderAltitude=t.altitude||0,this._rootTile.setDataOnlyMode(!0),this._setupDataModeAndListenersForChildren(),this._setupLifeCycleListeners()}_setupDataModeAndListenersForChildren(){const e=t=>{t!==this._rootTile&&t.setDataOnlyMode(!0),this._addShownListenerToTile(t),this._addUnloadListenerToTile(t)};this._rootTile.addEventListener("tile-created",t=>{const n=t.tile;e(n)}),this._rootTile.traverse(t=>{t.isTile&&e(t)})}_addShownListenerToTile(e){const t=n=>{const r=n.tile,o=`${r.z}-${r.x}-${r.y}`,a=!!this._renderer,c=this._tileDataMap.get(o);a&&c&&this._renderer.processTileData(r,c.data)};e.addEventListener("tile-shown",t)}_addUnloadListenerToTile(e){const t=n=>{const r=n.tile||n.target,o=`${r.z}-${r.x}-${r.y}`;if(this._renderer)try{this._renderer.removeFeaturesByTileKey(o)}catch{}this._tileDataMap.delete(o)};e.addEventListener("unload",t)}setAltitude(e){return super.setAltitude(0),this._renderAltitude=e,this._renderer&&this._renderer.setAltitude(e),this}getAltitude(){return this._renderAltitude}_addHiddenListenerToTile(e){const t=n=>{const r=n.tile,o=`${r.z}-${r.x}-${r.y}`;if(this._renderer)try{this._renderer.hideFeaturesByTileKey(o)}catch{}};e.addEventListener("tile-hidden",t)}_setupLifeCycleListeners(){this._rootTile.addEventListener("tile-loaded",e=>{const t=e.tile,n=`${t.z}-${t.x}-${t.y}`,r=this.getVectorDataFromTile(t);if(!r){console.warn(`[VectorTileLayer] Tile ${n} loaded but has no vector data.`);return}if(r.vectorData?.dataFormat==="mvt"&&this._tileDataMap.set(n,{data:r,tile:t,timestamp:Date.now(),pending:!1}),t.showing&&this._renderer&&r.vectorData?.dataFormat==="mvt")try{this._renderer.processTileData(t,r)}catch{}})}getVectorDataFromTile(e){return!e.geometry||!e.getVectorData()?null:e.getVectorData()}createLoader(){const e=new bs;return e.vtSource=this.source,e}getVisibleVectorTiles(){const e=[];return this._rootTile.traverse(t=>{if(t.isTile&&t.loaded&&t.inFrustum){const n=`${t.z}-${t.x}-${t.y}`,r=this._tileDataMap.get(n);r&&e.push({tileKey:n,data:r.data,tile:r.tile})}}),e}getAllVectorData(){return new Map(this._tileDataMap)}getVectorData(e,t,n){const r=`${n}-${e}-${t}`,o=this._tileDataMap.get(r);return o?o.data:null}setFeatureFilter(e){this._featureFilter=e,this._renderer&&this._renderer.setFeatureFilter(e)}clearFeatureFilter(){this._featureFilter=void 0,this._renderer&&this._renderer.clearFeatureFilter()}setOpacity(e){this.opacity=e,this._renderer&&this._renderer.setOpacity(e)}hide(){return super.hide(),this._renderer&&this._renderer.hide(),this}show(){return super.show(),this._renderer&&this._renderer.show(),this}update(e){!this.enabled||!this.visible||super.update(e)}dispose(){this._renderer&&this._renderer.dispose(),super.dispose()}setFeaturePickingEnabled(e){this.options.enableFeaturePicking=e,this._renderer&&(this._renderer.interactive=e,e&&!this._eventsBound&&this._bindRendererEvents(this._renderer))}_bindRendererEvents(e){if(this._eventsBound)return;["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu"].forEach(n=>{const r="feature"+n;e.on(r,o=>{this.trigger(r,o)})}),this._eventsBound=!0}_setRenderer(e){this._renderer=e,this._eventsBound=!1,this.options.enableFeaturePicking&&this._bindRendererEvents(e)}_getRenderer(){return this._renderer||null}getStyle(){return this._style}setStyle(e){return this._style=e,this._renderer&&(this._renderer.style=e,this._tileDataMap.forEach((n,r)=>{this._renderer.removeFeaturesByTileKey(r)}),this.getVisibleVectorTiles().forEach(({tile:n,data:r})=>{this._renderer.processTileData(n,r)})),this}setSymbol(e){return this.setStyle(e)}}var nv=Object.defineProperty,rv=(i,e,t)=>e in i?nv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ne=(i,e,t)=>rv(i,typeof e!="symbol"?e+"":e,t);class iv{constructor(...e){}}const sv={};let vr=class of extends Yo(Kn(gr(iv))){constructor(e,t){Xo(e,"container","Map container element must be specified");const n=["center","basemap"];for(const Z of n)mc(t,Z);const o={...t,viewer:{...{viewer:{antialias:!0,stencil:!0,logarithmicDepthBuffer:!0}}.viewer,...t.viewer}};super(o),Ne(this,"viewer"),Ne(this,"tilemap"),Ne(this,"center"),Ne(this,"prjcenter"),Ne(this,"_layerContainer"),Ne(this,"_EventMap",{loaded:{listened:!1}}),Ne(this,"_canvasManager",new zg),Ne(this,"collisionEngine"),Ne(this,"_onLoadHooks"),Ne(this,"_minZoom",0),Ne(this,"_maxZoom",22),Ne(this,"_ZOOM_MIN_CONST",0),Ne(this,"_ZOOM_MAX_CONST",22),Ne(this,"_minZoomDistance",500),Ne(this,"_maxZoomDistance",8e4),Ne(this,"_isZooming",!1),Ne(this,"_zoomStartValue",0),Ne(this,"_lastZoomForControls",0),Ne(this,"_overZoom",0),Ne(this,"_lastCameraDistance",0),this.tilemap=this.initTileMap(o.basemap),this.center=this.options.center,this.viewer=new wc(e,{...o.viewer,map:this}),this.tilemap.receiveShadow=!0,this.viewer.scene.add(this.tilemap);const a=this.tilemap.geo2world(new p.Vector3(this.center[0],this.center[1],0));this.prjcenter=a;const c=this.options.viewer??{};this.viewer.flyToPoint({center:this.center,distance:typeof this.center[2]=="number"?this.center[2]:void 0,polarDeg:typeof c.polarDeg=="number"?c.polarDeg:void 0,azimuthDeg:typeof c.azimuthDeg=="number"?c.azimuthDeg:void 0,polarAngle:c.polarAngle,azimuthAngle:c.azimuthAngle,duration:0,curvePath:!1}),this._minZoomDistance=this.viewer.controls.minDistance,this._maxZoomDistance=this.viewer.controls.maxDistance;const u=this._getCameraDistance();this._lastCameraDistance=u,this._layerContainer=new Ag,this.viewer.scene.add(this._layerContainer);const d=this.viewer.controls;this._minZoomDistance=typeof d?.minDistance=="number"?d.minDistance:500,this._maxZoomDistance=typeof d?.maxDistance=="number"?d.maxDistance:8e4;const f=this.tilemap.getLayers().find(Z=>Z.isBaseLayer===!0)?.minLevel??this.tilemap.minLevel;this._minZoom=Math.max(this._ZOOM_MIN_CONST,Math.min(this._ZOOM_MAX_CONST,f)),this._maxZoom=this._ZOOM_MAX_CONST;const g=this.prjcenter,w=this.viewer.camera.position.clone().clone().sub(g).normalize(),x=as(t.zoom)?13:t.zoom,L=Math.max(this._minZoom,Math.min(this._maxZoom,x)),M=this._computeDistanceFromZoom(L);a.clone().addScaledVector(w,M);const C=this.getZoom();this._lastZoomForControls=C,this._zoomStartValue=C,this.collisionEngine=new p0(this.viewer.renderer,{padding:8,updateInterval:16,animationDuration:200,maxFeaturesPerFrame:2e4,strategies:{priority:!0,grouping:!0,proximity:!0}}),this.on("control-change",m0.debounce(Z=>{if(!this.tilemap||!this.collisionEngine)return;const z=this.tilemap,D=z.getDataZoom(),I=z.getLayers().find(H=>H.isBaseLayer===!0)?.maxLevel??z.maxLevel,K=this._getCameraDistance(),V=K-this._lastCameraDistance;this._lastCameraDistance=K;const{max:G}=this._getViewZoomRange(),k=Math.max(0,G-I);D<I?this._overZoom=0:V<-.001?this._overZoom=Math.min(this._overZoom+1,k):V>.001&&(this._overZoom=Math.max(this._overZoom-1,0));const j=this.getZoom();Math.abs(j-this._lastZoomForControls)>.001&&(this._isZooming?this.trigger("zooming",{from:this._zoomStartValue,to:j}):(this._isZooming=!0,this._zoomStartValue=this._lastZoomForControls,this.trigger("zoomstart",{from:this._zoomStartValue,to:j})),this._lastZoomForControls=j),this.collisionEngine.update(Z.camera)},10,{leading:!1,trailing:!0})),this.on("control-end",()=>{this._isZooming&&(this._isZooming=!1,this.trigger("zoomend",{from:this._zoomStartValue,to:this.getZoom()}))}),this._callOnLoadHooks()}static addOnLoadHook(e,...t){const n=typeof e=="function"?e:function(){this[e].apply(this,t)},r=this.prototype;return r._onLoadHooks=r._onLoadHooks||[],r._onLoadHooks.push(n),this}_callOnLoadHooks(){const e=of.prototype;if(e._onLoadHooks)for(let t=0,n=e._onLoadHooks.length;t<n;t++)e._onLoadHooks[t].call(this)}getZoom(){const e=this.tilemap,t=e.getDataZoom(),r=e.getLayers().find(o=>o.isBaseLayer===!0)?.maxLevel??e.maxLevel;return t<r?t:r+this._overZoom}getDataZoom(){return this.tilemap.getDataZoom()}getMinZoom(){return this._minZoom}getMaxZoom(){return this._maxZoom}setZoomRange(e,t){if(e>t){const r=e;e=t,t=r}this._minZoom=e,this._maxZoom=t;const n=this.viewer.controls;if(n){const r=this._computeDistanceFromZoom(this._maxZoom),o=this._computeDistanceFromZoom(this._minZoom);n.minDistance=r,n.maxDistance=o}return this}setMinZoom(e){return this.setZoomRange(e,this._maxZoom)}setMaxZoom(e){return this.setZoomRange(this._minZoom,e)}setZoom(e){const t=this.getMinZoom(),n=this.getMaxZoom(),r=Math.max(t,Math.min(n,e)),o=this.getZoom(),a=this._computeDistanceFromZoom(r),c=this.viewer.controls,u=c?.target??this.prjcenter,d=this.viewer.camera,m=d.position.clone().sub(u).normalize();return d.position.copy(u).addScaledVector(m,a),d.updateProjectionMatrix(),typeof c?.update=="function"&&c.update(),this._lastZoomForControls=r,this.trigger("zoomend",{from:o,to:this.getZoom()}),this}zoomIn(e=1){return this.setZoom(this.getZoom()+e)}zoomOut(e=1){return this.setZoom(this.getZoom()-e)}_computeDistanceFromZoom(e){const t=this._ZOOM_MIN_CONST,n=this._ZOOM_MAX_CONST,r=this._minZoomDistance,o=this._maxZoomDistance;if(r<=0||r>=o){const m=Math.max(t,Math.min(n,e)),f=(n-m)/(n-t);return r+f*(o-r)}const c=(Math.max(t,Math.min(n,e))-t)/(n-t),u=r/o;return o*Math.pow(u,c)}initTileMap(e){const t=new hs({...e});try{if(e.Baselayers?.length)for(const n of e.Baselayers)n.isBaseLayer=!0,t.addLayer(n)}catch(n){console.error("💥 Diagnostic failed 诊断失败:",n)}return t.rotateX(-Math.PI/2),t.receiveShadow=!0,setTimeout(()=>{const n={timestamp:yc(),targrt:this};this._EventMap.loaded={listened:!0},this.trigger("loaded",n)},0),t}addLayer(e,...t){if(!e)return this;Array.isArray(e)||(e=[e]),t?.length&&(e=e.concat(t)),t?.length&&(e=e.concat(t));for(let n=0,r=e.length;n<r;n++){const o=e[n],a=o.getId();if(as(a))throw new Error("Invalid id for the layer: "+a);o.isTileLayer?this.addTileLayer(o):this.addRegularLayer(o)}return this}removeLayer(e){const t=typeof e=="string"?e:e.getId(),n=this.tilemap.getLayer(t);if(n){if(n instanceof ga){const o=n._getRenderer();o&&this._layerContainer.remove(o)}return this.tilemap.removeLayer(t),!0}const r=this._layerContainer.getLayerById(t);return r?(this._layerContainer.remove(r),r instanceof Bn&&r?._collision,!0):(console.warn(`⚠️ Layer does not exist 图层不存在: ${t}`),!1)}addRegularLayer(e){this._layerContainer.add(e),e._bindMap(this),e instanceof Bn&&e?._collision&&(this.collisionEngine.registerLayer(e),e.setCollisionEngine(this.collisionEngine))}addTileLayer(e){if(this.tilemap.addLayer(e),e._bindMap(this),e instanceof ga){const t=e.options||{},n=new vs(e.getId()+"-vtrender",{altitude:e.getAltitude(),style:e.getStyle(),collision:e._collision,zIndex:typeof t.zIndex=="number"?t.zIndex:void 0,depthOffset:typeof t.depthOffset=="number"?t.depthOffset:void 0});t.enableFeaturePicking&&(n.interactive=!0),e._setRenderer(n),this.addRegularLayer(n)}return this}clearLayers(){return this._layerContainer.clear(),this.tilemap.clearLayers(),this}getLayers(){const e=this._layerContainer.getLayers().filter(n=>!(n instanceof vs)),t=this.tilemap.getLayers();return[...e,...t]}getLayerById(e){const t=this._layerContainer.getLayerById(e);return t?t instanceof vs?void 0:t:this.tilemap.getLayer(e)}geo2world(e){return this.tilemap.geo2world(e)}world2geo(e){return this.tilemap.world2geo(e)}geo2map(e){return this.tilemap.geo2map(e)}_getCanvas(e=40,t=30,n){return this._canvasManager.getCanvas(e,t,1,n)}getContainer(){return this.viewer.container}getRenderer(){return this.viewer.renderer}getCamera(){return this.viewer.camera}_findFeaturesAt(e){const t=this,n=t.getRenderer(),r=t.getCamera(),o=n.domElement.getBoundingClientRect(),a=e.x/o.width*2-1,c=-(e.y/o.height)*2+1,u=new p.Raycaster;u.setFromCamera(new p.Vector2(a,c),r);const d=[...t.getLayers(),...t._layerContainer.getLayers().filter(g=>g instanceof vs&&g.interactive)].filter(g=>!g?.isSceneLayer&&g?.visible===!0),f=u.intersectObjects(d,!0).map(g=>{let _=g.object,w=null;for(;_;){if(_ instanceof ut){w=_;break}_=_.parent}return!w||w.visible===!1?null:{feature:w,distance:g.distance,object:g.object}}).filter(g=>!!g);return f.length?f.sort((g,_)=>g.distance-_.distance):[]}getCenter(){const e=this.viewer.controls.target.clone(),t=this.world2geo(e);return[t.x,t.y,t.z]}_getEventPosition(e){let t,n;if("touches"in e){if(e.touches.length===0)return null;t=e.touches[0].clientX,n=e.touches[0].clientY}else t=e.clientX,n=e.clientY;const r=this.getContainer();if(!r)return null;const o=r.getBoundingClientRect();return{x:t-o.left,y:n-o.top}}get isInteracting(){return this.viewer?this.viewer.isInteracting:!1}_getCameraDistance(){const e=this.viewer.controls,t=this.viewer.camera,n=e?.target??this.prjcenter;return e&&typeof e.getDistance=="function"?e.getDistance():t.position.distanceTo(n)}_getViewZoomRange(){const e=this.viewer.controls,t=typeof e?.minDistance=="number"?e.minDistance:this._minZoomDistance,n=typeof e?.maxDistance=="number"?e.maxDistance:this._maxZoomDistance;if(t<=0||t>=n){const f=this.tilemap.getDataZoom();return{min:f,max:f}}const r=n/t,o=Math.log2(r),a=this.tilemap.getLayers().find(f=>f.isBaseLayer===!0),c=a?.minLevel??this.tilemap.minLevel,u=a?.maxLevel??this.tilemap.maxLevel,d=c,m=u+o;return{min:d,max:m}}flyTo(e){this.viewer.flyToAdvanced(e)}flyToPoint(e){this.viewer.flyToPoint(e)}destroy(){try{this._clearHandlers(),["control-change","control-start","control-end","zoomstart","zooming","zoomend","loaded"].forEach(t=>{const n=this._listenerMap?.get(t);n&&n.forEach((r,o)=>{this.off(t,o)})}),this.clearLayers(),Cc.clearCache(),this.collisionEngine&&(this.collisionEngine=null),this._layerContainer&&(this._layerContainer.clear(),this._layerContainer=null),this.tilemap&&(this.tilemap.dispose(),this.tilemap=null),this._canvasManager&&(this._canvasManager=null),this.viewer&&(this.viewer.destroy(),this.viewer=null),this._EventMap={loaded:{listened:!1}}}catch(e){console.error("Error destroying map 销毁地图时出错:",e)}}};vr.mergeOptions(sv);const ov=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout"];vr.prototype._removeDomEvents=function(){},vr.prototype._registerDomEvents=function(){const i=this.viewer.container;if(i){let t=null;ov.forEach(n=>{i.addEventListener(n,r=>{if(!this.viewer||!this.tilemap)return;if(n==="mousedown"&&(t={x:r.clientX,y:r.clientY}),n==="click"&&t){const c=r.clientX-t.x,u=r.clientY-t.y;if(Math.sqrt(c*c+u*u)>5)return}let o=ta(r,this.tilemap,this.viewer.camera),a={target:this,originEvent:r,eventName:n,screenXY:{X:r.screenX,Y:r.screenY}};if(o){let c=[o.x,o.y,o.z];a={target:this,originEvent:r,coordinate:c,eventName:n,screenXY:{X:r.screenX,Y:r.screenY}}}this.trigger(n,a)})})}},vr.addOnLoadHook("_registerDomEvents");var av=Object.defineProperty,lv=(i,e,t)=>e in i?av(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ya=(i,e,t)=>lv(i,typeof e!="symbol"?e+"":e,t);const cv=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchmove","touchend"];class uv extends ls{constructor(){super(...arguments),ya(this,"_registeredEvents",[]),ya(this,"_mouseDownTime",0),ya(this,"_eventCommon",e=>{(e.type==="mousedown"||e.type==="touchstart")&&(this._mouseDownTime=Date.now()),!(e.type==="click"&&Date.now()-this._mouseDownTime>300)&&this._handleEvent(e,e.type)})}addHooks(){const t=this.target.getContainer();t&&cv.forEach(n=>{t.addEventListener(n,this._eventCommon),this._registeredEvents.push(n)})}removeHooks(){const t=this.target.getContainer();t&&this._registeredEvents.length>0&&(this._registeredEvents.forEach(n=>{const r=n;t.removeEventListener(r,this._eventCommon)}),this._registeredEvents=[])}_handleEvent(e,t){const n=this.target;if(!n||!n.viewer||this._shouldIgnoreEvent(t)||(t==="mousemove"||t==="mouseenter"||t==="mouseleave"||t==="mouseover"||t==="mouseout"||t==="touchmove")&&!n.getLayers().some(u=>!u.isSceneLayer&&u._feaList?.length>0))return;const r=n._getEventPosition(e);if(!r)return;const o=n._findFeaturesAt(r);if(o.length===0)return;const a=o[0].feature;switch(t){case"click":this._handleClickEvent(a,e);break;case"mousemove":case"mouseenter":case"mouseleave":case"mouseover":case"mouseout":case"touchmove":this.handleMoveEvent(a,e);break;default:if(a){this._fireFeatureEvent(a,t,e);const c=a.getLayer();c&&c.trigger("feature"+t,{feature:a,domEvent:e,type:"feature"+t})}}}_handleClickEvent(e,t){if(!e)return;this._fireFeatureEvent(e,"click",t);const n=e.getLayer();n&&n.trigger("featureclick",{feature:e,domEvent:t,type:"featureclick"})}handleMoveEvent(e,t){if(!e)return;this._fireFeatureEvent(e,t.type,t);const n=e.getLayer();n&&n.trigger("feature"+t.type,{feature:e,domEvent:t,type:"feature"+t.type})}_fireFeatureEvent(e,t,n){const r=this.target;if(!r||!r.tilemap||!r.viewer)return;let o=n,a,c;if("touches"in n){const f=n.touches[0]||n.changedTouches[0];if(!f)return;o={currentTarget:n.currentTarget,clientX:f.clientX,clientY:f.clientY},a=f.screenX,c=f.screenY}else{const f=n;o=f,a=f.screenX,c=f.screenY}const u=ta(o,r.tilemap,r.viewer.camera);if(!u)return;const d=[u.x,u.y,u.z],m={target:e,originEvent:n,coordinate:d,eventName:t,screenXY:{X:a,Y:c}};e.trigger(t,m)}_shouldIgnoreEvent(e){const t=this.target;return t.viewer?e==="mousedown"||e==="touchstart"?!1:!!t.isInteracting:!0}}vr.mergeOptions({FeatureEvents:!0,onlyVisibleFeatureEvents:!0}),vr.addOnLoadHook("addHandler","FeatureEvents",uv);var hv=Object.defineProperty,dv=(i,e,t)=>e in i?hv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,vn=(i,e,t)=>dv(i,typeof e!="symbol"?e+"":e,t);let fv=class{constructor(...e){}};const Su=class ci extends Kn(gr(fv)){constructor(e={}){super(e),vn(this,"_owner"),vn(this,"_map"),vn(this,"_worldPosition"),vn(this,"_coordinate"),vn(this,"_dom"),vn(this,"_visible",!1),vn(this,"_boundMapHandlers",new Map),vn(this,"_viewerUpdateHandler"),vn(this,"_positionedOnce",!1)}_getClassName(){return"UIComponent"}getOffset(){return{x:this.options.dx??0,y:this.options.dy??0}}addTo(e){if(!e)return this;this._owner=e;const t=typeof e.getMap=="function"?e.getMap():e;return t?(this._map=t,this._bindMapEvents(!0),this.options.single&&(ci._singletons.forEach(n=>{n!==this&&n.options.single&&n._map===t&&n.hide()}),ci._singletons.add(this)),this.onAdd&&this.onAdd(),this.trigger("add",{owner:e,map:t}),this):this}remove(){const e=this._map;return this.hideDom(),this._bindMapEvents(!1),this.options.single&&ci._singletons.delete(this),this.onRemove&&this.onRemove(),this.trigger("remove",{owner:this._owner,map:e}),this._owner=void 0,this._map=void 0,this}show(e){const t=this._map??(this._owner&&typeof this._owner.getMap=="function"?this._owner.getMap():void 0);if(!t)return this;if(this._map=t,this.options.single&&(ci._singletons.forEach(n=>{n!==this&&n.options.single&&n._map===t&&n.isVisible()&&n.hide()}),ci._singletons.add(this)),!this._dom){const n=this.buildOn();this._dom=n,n.style.position="absolute",typeof this.options.zIndex=="number"&&(n.style.zIndex=String(this.options.zIndex));const r=t.getContainer();if(!r)return this;r.appendChild(n)}return this._coordinate=e?[...e]:void 0,this._visible=!0,this._positionedOnce=!1,this._dom&&(this._dom.style.display="none"),this.trigger("show",{owner:this._owner,map:t}),this}hide(){return this._visible=!1,this._dom&&(this._dom.style.display="none"),this._coordinate=void 0,this.trigger("hide",{owner:this._owner,map:this._map}),this}hideDom(){return this._dom&&this._dom.parentElement&&(this._dom.parentElement.removeChild(this._dom),this.onDomRemove&&this.onDomRemove()),this._dom=void 0,this._visible=!1,this._coordinate=void 0,this}getMap(){return this._map}isVisible(){return this._visible}_bindMapEvents(e){const t=this._map;if(!t)return;const n=t,r=e?"on":"off",o=(a,c)=>{e?this._boundMapHandlers.set(a,c):this._boundMapHandlers.delete(a)};if(e){const a=()=>{this._visible&&this._updatePosition()};n[r]("control-change",a),o("control-change",a);const c=t.viewer;if(c&&!this._viewerUpdateHandler){const u=()=>{this._visible&&this._updatePosition()};this._viewerUpdateHandler=u,c.addEventListener("update",u)}}else{this._boundMapHandlers.forEach((c,u)=>{n[r](u,c)}),this._boundMapHandlers.clear();const a=t.viewer;a&&this._viewerUpdateHandler&&(a.removeEventListener("update",this._viewerUpdateHandler),this._viewerUpdateHandler=void 0)}}_resolveWorldPosition(){const e=this._map;if(!e)return;if(this._coordinate){const[n,r,o=0]=this._coordinate,a=new p.Vector3(n,r,o);return e.geo2world(a)}const t=this._owner;if(t&&t._geometry){const n=t._geometry;if(n&&(n.type==="Point"||n.type==="MultiPoint")){let r;if(n.type==="Point"?r=n.coordinates:n.type==="MultiPoint"&&Array.isArray(n.coordinates)&&n.coordinates.length>0&&(r=n.coordinates[0]),r&&r.length>=2){const o=new p.Vector3(r[0],r[1],r[2]??0);return e.geo2world(o)}}if(t._threeGeometry&&typeof t._threeGeometry.getWorldPosition=="function"){const r=new p.Vector3;if(t._threeGeometry.getWorldPosition(r),!(r.x===0&&r.y===0&&r.z===0))return r}if(t._position instanceof p.Vector3){const r=t._position;if(!(r.x===0&&r.y===0&&r.z===0))return r.clone()}}if(t&&typeof t.getWorldPosition=="function"){const n=new p.Vector3;return t.getWorldPosition(n),n}return e.prjcenter?.clone?.()??void 0}_updatePosition(){if(!this._dom||!this._map)return;if(this._visible){const u=this._resolveWorldPosition();if(!u){this._dom.style.display="none";return}this._worldPosition=u}if(!this._worldPosition)return;const e=this._map.viewer,t=e.camera,n=this._dom.style.display==="none";n&&(this._dom.style.visibility="hidden",this._dom.style.display=""),t.updateMatrixWorld();const r=this._worldPosition.clone().project(t);if(r.x<-1.1||r.x>1.1||r.y<-1.1||r.y>1.1||r.z<-1||r.z>1){this._dom.style.display="none",n&&(this._dom.style.visibility="");return}const o=(r.x*.5+.5)*e.width,a=(-r.y*.5+.5)*e.height,c=this.getOffset();if(this._dom.style.left=`${o+c.x}px`,this._dom.style.top=`${a+c.y}px`,n&&(this._dom.style.visibility=""),!this._positionedOnce){this._positionedOnce=!0,this._dom.style.display="none";return}this._dom.style.display=""}};vn(Su,"_singletons",new Set);let Lu=Su;var pv=Object.defineProperty,mv=(i,e,t)=>e in i?pv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Pu=(i,e,t)=>mv(i,typeof e!="symbol"?e+"":e,t);class _a extends Lu{constructor(e){super({single:!0,...e}),Pu(this,"_titleEl"),Pu(this,"_contentEl")}_getClassName(){return"InfoWindow"}buildOn(){if(this.options.custom){let c;this.options.content instanceof HTMLElement?c=this.options.content:(c=document.createElement("div"),typeof this.options.content=="string"&&(c.innerHTML=this.options.content));const u=this.options.containerClass;return u&&(Array.isArray(u)?u:[u]).forEach(m=>{c.classList.add(m)}),this.options.minWidth&&(c.style.minWidth=`${this.options.minWidth}px`),this.options.minHeight&&(c.style.minHeight=`${this.options.minHeight}px`),this._titleEl=void 0,this._contentEl=c,c}const e=document.createElement("div");e.className="terra-infowindow";const t=this.options.containerClass;t&&(Array.isArray(t)?t:[t]).forEach(u=>{e.classList.add(u)}),typeof this.options.zIndex=="number"&&(e.style.zIndex=String(this.options.zIndex)),this.options.minWidth&&(e.style.minWidth=`${this.options.minWidth}px`),this.options.minHeight&&(e.style.minHeight=`${this.options.minHeight}px`);const n=document.createElement("div");n.className="terra-infowindow-header";const r=document.createElement("div");r.className="terra-infowindow-title",this.options.title&&(r.innerText=this.options.title);const o=document.createElement("span");o.className="terra-infowindow-close",o.innerHTML="×",o.title="关闭",o.addEventListener("click",c=>{c.stopPropagation(),c.preventDefault(),this.close()}),o.addEventListener("mousedown",c=>{c.preventDefault()}),o.style.cursor="pointer",o.style.userSelect="none",n.appendChild(r),n.appendChild(o);const a=document.createElement("div");return a.className="terra-infowindow-content",this.options.content instanceof HTMLElement?a.appendChild(this.options.content):typeof this.options.content=="string"&&(a.innerHTML=this.options.content),e.appendChild(n),e.appendChild(a),this._titleEl=r,this._contentEl=a,e}getOffset(){const e=super.getOffset(),t=this._dom;if(!t)return e;const n=t.offsetWidth,r=t.offsetHeight,o=10;let a=e.x-n/2,c=e.y-r-o;const u=this._owner,d=this.getMap();if(u&&typeof u.getStyle=="function"&&d?.viewer){const f=u.getStyle?.()?.config,g=f?.type;if(f&&(g==="icon-point"||g==="icon-label-point")){const _=Array.isArray(f.anchor)?f.anchor:[.5,.5],w=typeof _[1]=="number"?_[1]:.5;let b=0;const x=u._threeGeometry;if(x&&x instanceof p.Sprite&&(b=this._getSpriteScreenHeight(x,d.viewer)),b<=0){let L=0;if(g==="icon-point"){const M=f.size;Array.isArray(M)?L=M[1]:typeof M=="number"&&(L=M)}else if(g==="icon-label-point"){const M=f.size??f.iconSize;Array.isArray(M)?L=M[1]:typeof M=="number"&&(L=M)}b=L*(1-w)}else b=b*(1-w);b>0&&(c-=b)}}return{x:a,y:c}}_getSpriteScreenHeight(e,t){try{const n=t.camera,r=t.renderer;if(!n||!r)return 0;const o=t.height||r.domElement.clientHeight;if(!(e.material.sizeAttenuation!==!1)){const z=n.projectionMatrix.elements[5];return e.scale.y*z*o/2}const u=new p.Vector3;e.getWorldPosition(u);const d=n.position.clone(),m=u.clone().sub(d).normalize(),f=new p.Vector3;f.crossVectors(n.up,m).normalize();const g=new p.Vector3;g.crossVectors(m,f).normalize();const _=e.scale.y*(1-e.center.y),w=e.scale.y*e.center.y,b=u.clone().add(g.clone().multiplyScalar(_)),x=u.clone().sub(g.clone().multiplyScalar(w)),L=b.clone().project(n),M=x.clone().project(n),C=(-L.y*.5+.5)*o,Z=(-M.y*.5+.5)*o;return Math.abs(Z-C)}catch(n){return console.warn("Failed to calculate sprite screen height: // 计算 sprite 屏幕高度失败:",n),0}}setTitle(e){return this.options.title=e,this._titleEl&&(this._titleEl.innerText=e??""),this}setContent(e){return this.options.content=e,this._contentEl?(this._contentEl.innerHTML="",e instanceof HTMLElement?this._contentEl.appendChild(e):this._contentEl.innerHTML=e,this):this}open(e){super.show(e);const t=this,n=()=>{!t._dom||!t._map||!t._visible||(t._positionedOnce=!0,t._updatePosition())},o=this.getMap()?.viewer;if(o&&typeof o.addEventListener=="function"){const a=()=>{o.removeEventListener("update",a),n()};o.addEventListener("update",a)}else requestAnimationFrame(n);return this}close(){return this.hide()}}ut.include({setInfoWindow(i){this.removeInfoWindow();let e;return i instanceof _a?e=i:e=new _a(i),this._infoWindow=e,this.getMap()&&e.addTo(this),this},getInfoWindow(){return this._infoWindow},openInfoWindow(i){const e=this._infoWindow;return e?(e.getMap()||this.getMap()&&e.addTo(this),requestAnimationFrame(()=>{e.open(i)}),this):this},closeInfoWindow(){return this._infoWindow&&this._infoWindow.close(),this},removeInfoWindow(){return this._infoWindow&&(this._infoWindow.remove(),this._infoWindow=void 0),this}});var gv=Object.defineProperty,yv=(i,e,t)=>e in i?gv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,va=(i,e,t)=>yv(i,typeof e!="symbol"?e+"":e,t);class _v{constructor(...e){}}class Cu extends Kn(gr(_v)){constructor(e={}){super(e),va(this,"_map"),va(this,"_enabled",!1),va(this,"_boundHandlers",new Map)}addTo(e){if(!e)return this;const t=e;return t._activeMapTool&&t._activeMapTool!==this&&t._activeMapTool.disable(),t._activeMapTool=this,this._map=e,this.onAdd&&this.onAdd(),this.enable(),this.trigger("add",{map:e}),this}getMap(){return this._map}enable(){return!this._map||this._enabled?this:(this._enabled=!0,this._bindEvents(),this.onEnable&&this.onEnable(),this.trigger("enable",{map:this._map}),this)}disable(){return!this._map||!this._enabled?this:(this._enabled=!1,this._unbindEvents(),this.onDisable&&this.onDisable(),this.trigger("disable",{map:this._map}),this)}isEnabled(){return!!this._enabled}remove(){if(!this._map)return this;this.disable();const e=this._map;return e._activeMapTool===this&&delete e._activeMapTool,this._map=void 0,this.trigger("remove"),this}_bindEvents(){const e=this._map;if(!e)return;const t=this.getEvents()||{};Object.keys(t).forEach(n=>{const r=t[n];if(!r)return;const o=a=>r.call(this,a);this._boundHandlers.set(n,o),e.on(n,o)})}_unbindEvents(){const e=this._map;e&&(this._boundHandlers.forEach((t,n)=>{e.off(n,t)}),this._boundHandlers.clear())}}var vv=Object.defineProperty,wv=(i,e,t)=>e in i?vv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Zi=(i,e,t)=>wv(i,typeof e!="symbol"?e+"":e,t);class bv extends Bn{constructor(e){super(e,{altitude:1})}validateFeature(e){return!!e}}const Tu={};class Nr extends Cu{constructor(e){super(e),Zi(this,"_modeDef"),Zi(this,"_clickCoords",[]),Zi(this,"_isDrawing",!1),Zi(this,"_geometry"),Zi(this,"_draftLayer"),this.options.once=this.options.once??!1,this._ensureMode()}static registerMode(e,t){Tu[e.toLowerCase()]=t}static getModeDefinition(e){return Tu[e.toLowerCase()]}getMode(){return(this.options.mode||"").toLowerCase()}setMode(e){return this._finishDrawingSilently(),this.options.mode=e,this._ensureMode(),this}setStyle(e){return e.geometryStyle!==void 0&&(this.options.geometryStyle=e.geometryStyle),Object.prototype.hasOwnProperty.call(e,"vertexStyle")&&(this.options.vertexStyle=e.vertexStyle??null),this}getEvents(){return{click:this._handleClick.bind(this),mousemove:this._handleMouseMove.bind(this),dblclick:this._handleDblClick.bind(this)}}onEnable(){this._ensureMode()}onDisable(){this._finishDrawingSilently(),this._destroyDraftLayer()}_ensureMode(){const e=this.getMode(),t=Nr.getModeDefinition(e);if(!t)throw new Error(`DrawTool: mode "${e}" 未注册,请先调用 DrawTool.registerMode`);this._modeDef=t}_handleClick(e){if(!this._modeDef||!e.coordinate)return;const t=e.coordinate,n=this._modeDef,r={...e,drawTool:this};this._isDrawing?(this._clickCoords.push(t),n.update(this._clickCoords,this._geometry,r),this.trigger("drawvertex",{coordinate:t,geometry:this._geometry,coords:[...this._clickCoords],originEvent:r})):(this._isDrawing=!0,this._clickCoords=[t],this._geometry=n.create(t,r),this.trigger("drawstart",{coordinate:t,geometry:this._geometry,coords:[...this._clickCoords],originEvent:r})),n.clickLimit&&this._clickCoords.length>=n.clickLimit&&this._finishDrawing(r)}_handleMouseMove(e){if(!this._modeDef||!this._isDrawing||!e.coordinate)return;const t=this._modeDef,n=[...this._clickCoords,e.coordinate],r={...e,drawTool:this};t.update(n,this._geometry,r),this.trigger("drawing",{coordinate:e.coordinate,geometry:this._geometry,coords:n,originEvent:r})}_handleDblClick(e){if(!this._modeDef||!this._isDrawing)return;const t={...e,drawTool:this};this._finishDrawing(t)}_finishDrawing(e){if(!this._modeDef||!this._isDrawing)return;const n=this._modeDef.generate(this._geometry,[...this._clickCoords]);this.trigger("drawend",{geometry:n,coords:[...this._clickCoords],originEvent:e}),this._isDrawing=!1,this._clickCoords=[],this._geometry=void 0,this.options.once&&this.disable()}_finishDrawingSilently(){this._isDrawing=!1,this._clickCoords=[],this._geometry=void 0}_getOrCreateDraftLayer(){if(this._draftLayer)return this._draftLayer;const e=this.getMap();if(!e)throw new Error("DrawTool: 尚未绑定地图,请先调用 addTo(map)");const t=`__draw_draft_${Date.now().toString(36)}`,n=new bv(t);return e.addLayer(n),this._draftLayer=n,n}_destroyDraftLayer(){const e=this.getMap();e&&this._draftLayer&&e.removeLayer(this._draftLayer.getId()),this._draftLayer=void 0}}const xv={actions:["click","mousemove"],create(i,e){const t=e.drawTool,n=t._getOrCreateDraftLayer(),r=En(t.options.geometryStyle,{type:"basic-point",size:10,color:"#00ffff"}),o={type:"Point",coordinates:i},a=new Pn({geometry:o,style:r});return a.addTo(n),a.initializeGeometry(),{tool:t,draftLayer:n,draftMarker:a}},update(i,e,t){const n=e?.draftMarker;if(!n)return;const r=i[i.length-1];n._geometry={type:"Point",coordinates:r},n._position=n._coordsTransform(),n._toThreeJSGeometry&&n._toThreeJSGeometry()},generate(i,e){const t=i.tool;if(!e.length)return null;i.draftMarker&&(i.draftMarker._remove(),i.draftMarker=null);const n=En(t.options.geometryStyle,{type:"basic-point",size:10,color:"#00ffff"}),r=e[e.length-1];return new Pn({geometry:{type:"Point",coordinates:r},style:n})},clickLimit:1},Mv={actions:["click","mousemove","dblclick"],create(i,e){const t=e.drawTool,n=t._getOrCreateDraftLayer(),r=En(t.options.geometryStyle,{type:"basic-line",color:"#ff0000",width:2}),o=t.options.vertexStyle===null?void 0:En(t.options.vertexStyle,{type:"basic-point",size:8,color:"#00ffff"}),a={type:"LineString",coordinates:[i]},c=new Mt({geometry:a,style:r});c.addTo(n);const u=[];if(o){const d={type:"Point",coordinates:i},m=new Pn({geometry:d,style:o});m.addTo(n),u.push(m)}return{tool:t,draftLayer:n,draftLine:c,draftAnchors:u,lineStyle:r,vertexStyle:o}},update(i,e,t){if(!e)return;const n=e.draftLayer;if(!i||i.length<2)return;e.draftLine&&(e.draftLine._remove(),e.draftLine=null);const r={type:"LineString",coordinates:i},o=new Mt({geometry:r,style:e.lineStyle});if(o.addTo(n),e.draftLine=o,t.eventName==="click"&&e.vertexStyle){const c={type:"Point",coordinates:i[i.length-1]},u=new Pn({geometry:c,style:e.vertexStyle});u.addTo(n),e.draftAnchors.push(u)}},generate(i,e){const t=i.tool;if(!e.length)return null;if(i.draftLine&&(i.draftLine._remove(),i.draftLine=null),Array.isArray(i.draftAnchors)){for(const o of i.draftAnchors)o?._remove();i.draftAnchors=[]}const n=En(t.options.geometryStyle,{type:"basic-line",color:"#ff0000",width:2});return new Mt({geometry:{type:"LineString",coordinates:e},style:n})}},Sv={actions:["click","mousemove","dblclick"],create(i,e){const t=e.drawTool,n=t._getOrCreateDraftLayer(),r=En(t.options.geometryStyle,{type:"basic-polygon",color:"#00ff00",opacity:.5}),o=t.options.vertexStyle===null?void 0:En(t.options.vertexStyle,{type:"basic-point",size:8,color:"#00ffff"}),a=[];if(o){const c={type:"Point",coordinates:i},u=new Pn({geometry:c,style:o});u.addTo(n),u.initializeGeometry(),a.push(u)}return{tool:t,draftLayer:n,draftPolygon:null,draftEdgeLine:null,draftAnchors:a,polygonStyle:r,vertexStyle:o}},update(i,e,t){if(!e)return;const n=e.draftLayer;if(t.eventName==="click"&&e.vertexStyle){const m={type:"Point",coordinates:i[i.length-1]},f=new Pn({geometry:m,style:e.vertexStyle});f.addTo(n),f.initializeGeometry(),e.draftAnchors.push(f)}if(!i||i.length<2){e.draftEdgeLine&&(e.draftEdgeLine._remove(),e.draftEdgeLine=null),e.draftPolygon&&(e.draftPolygon._remove(),e.draftPolygon=null);return}if(i.length===2){e.draftPolygon&&(e.draftPolygon._remove(),e.draftPolygon=null),e.draftEdgeLine&&(e.draftEdgeLine._remove(),e.draftEdgeLine=null);const d={type:"LineString",coordinates:i},m=e.polygonStyle?.config&&e.polygonStyle.config.color||"#00ff00",f=new xt({type:"basic-line",color:m,width:2}),g=new Mt({geometry:d,style:f});g.addTo(n),e.draftEdgeLine=g;return}e.draftEdgeLine&&(e.draftEdgeLine._remove(),e.draftEdgeLine=null);const r=i.slice(),o=r[0],a=r[r.length-1];(o[0]!==a[0]||o[1]!==a[1]||(o[2]||0)!==(a[2]||0))&&r.push(o),e.draftPolygon&&(e.draftPolygon._remove(),e.draftPolygon=null);const c={type:"Polygon",coordinates:[r]},u=new _n({geometry:c,style:e.polygonStyle});u.addTo(n),e.draftPolygon=u},generate(i,e){const t=i.tool;if(e.length<3)return null;if(i.draftPolygon&&(i.draftPolygon._remove(),i.draftPolygon=null),i.draftEdgeLine&&(i.draftEdgeLine._remove(),i.draftEdgeLine=null),Array.isArray(i.draftAnchors)){for(const u of i.draftAnchors)u?._remove();i.draftAnchors=[]}const n=En(t.options.geometryStyle,{type:"basic-polygon",color:"#00ff00",opacity:.5}),r=e.slice(),o=r[0],a=r[r.length-1];return(o[0]!==a[0]||o[1]!==a[1]||(o[2]||0)!==(a[2]||0))&&r.push(o),new _n({geometry:{type:"Polygon",coordinates:[r]},style:n})}};Nr.registerMode("point",xv),Nr.registerMode("line",Mv),Nr.registerMode("polygon",Sv);function En(i,e){return xt.create(i||e)}var Lv=Object.defineProperty,Pv=(i,e,t)=>e in i?Lv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,rn=(i,e,t)=>Pv(i,typeof e!="symbol"?e+"":e,t);class Cv extends nn{constructor(e){if(super(e),rn(this,"dataType","image"),rn(this,"attribution","天地图"),rn(this,"token",""),rn(this,"style","img_w"),rn(this,"subdomains","01234"),rn(this,"url","https://t{s}.tianditu.gov.cn/DataServer?T={style}&x={x}&y={y}&l={z}&tk={token}"),Object.assign(this,e),!this.token)throw new Error("天地图访问令牌(token)是必填参数")}}class Tv extends nn{constructor(e){if(super(e),rn(this,"dataType","quantized-mesh"),rn(this,"attribution","天地图"),rn(this,"token",""),rn(this,"subdomains","01234"),rn(this,"url","https://t{s}.tianditu.gov.cn/mapservice/swdx?T=elv_c&tk={token}&x={x}&y={y}&l={z}"),Object.assign(this,e),!this.token)throw new Error("天地图访问令牌(token)是必填参数")}}var Gv=Object.defineProperty,Zv=(i,e,t)=>e in i?Gv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Gu=(i,e,t)=>Zv(i,typeof e!="symbol"?e+"":e,t);class Wv extends nn{constructor(e){super({...e,url:e.urlTemplate,isTMS:e.isTMS||!1}),Gu(this,"minLevel",2),Gu(this,"maxLevel",24)}getUrl(e,t,n){const r=this.isTMS?Math.pow(2,n)-1-t:t;return lm(this.url,{...this,x:e,y:r,z:n,tileMatrix:n,tileRow:r,tileCol:e})}}var Vv=Object.defineProperty,Iv=(i,e,t)=>e in i?Vv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Cn=(i,e,t)=>Iv(i,typeof e!="symbol"?e+"":e,t);class Av extends nn{constructor(e){super(e),Cn(this,"dataType","image"),Cn(this,"attribution","ArcGIS"),Cn(this,"style","World_Imagery"),Cn(this,"url","https://services.arcgisonline.com/arcgis/rest/services/{style}/MapServer/tile/{z}/{y}/{x}"),Object.assign(this,e)}}class Fv extends nn{constructor(e){super(e),Cn(this,"dataType","lerc"),Cn(this,"attribution","ArcGIS"),Cn(this,"minLevel",6),Cn(this,"maxLevel",13),Cn(this,"url","https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer/tile/{z}/{y}/{x}"),Object.assign(this,e)}}var Ov=Object.defineProperty,Dv=(i,e,t)=>e in i?Ov(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Br=(i,e,t)=>Dv(i,typeof e!="symbol"?e+"":e,t);class zv extends nn{constructor(e){if(super(e),Br(this,"token",""),Br(this,"format","webp"),Br(this,"style","cm2myr6qx001t01pi0sf7estf"),Br(this,"attribution","MapBox"),Br(this,"maxLevel",25),Br(this,"url","https://api.mapbox.com/styles/v1/criska/cm2myr6qx001t01pi0sf7estf/tiles/256/{z}/{x}/{y}?access_token={token}&format={format}"),Object.assign(this,e),!this.token)throw new Error("MapBox访问令牌(token)是必填参数")}}var Xv=Object.defineProperty,Uv=(i,e,t)=>e in i?Xv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Zu=(i,e,t)=>Uv(i,typeof e!="symbol"?e+"":e,t);class kv extends nn{constructor(e){super(e),Zu(this,"dataType","mvt"),Zu(this,"style",{layer:[]}),Object.assign(this,e)}}var Kv=Object.defineProperty,Nv=(i,e,t)=>e in i?Kv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Wi=(i,e,t)=>Nv(i,typeof e!="symbol"?e+"":e,t);class Bv extends nn{constructor(e){super(e),Wi(this,"dataType","VectorTile"),Wi(this,"attribution","ArcGIS"),Wi(this,"minLevel",1),Wi(this,"maxLevel",21),Wi(this,"url","https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key=uKYsZQZpm72WlbSgH9B7"),Object.assign(this,e)}}class Yv extends Bn{constructor(e,t){super(e,t)}validateFeature(e){return e._baseType==="Line"}}class Rv extends Bn{constructor(e,t){super(e,t)}validateFeature(e){return e._baseType==="Point"}}class jv extends Bn{constructor(e,t){super(e,t)}validateFeature(e){return e._baseType==="Surface"}}var Jv=Object.defineProperty,Qv=(i,e,t)=>e in i?Jv(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Hv=(i,e,t)=>Qv(i,e+"",t);class Ev extends Bn{constructor(e,t){super(e,t),Hv(this,"_clouds",null);const n=["texture"];for(const r of n)mc(t,r);this._createClouds(t.texture)}async _createClouds(e){const t=await xt._loadTexture(e),n=new $m({texture:t,material:p.MeshBasicMaterial});n.castShadow=!0,this._clouds=n}validateFeature(e){return e._type==="Cloud"}animate(e,t){this._clouds&&this._clouds.update(this.map.viewer.camera,t,e)}}var $v=Object.defineProperty,qv=(i,e,t)=>e in i?$v(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ew=(i,e,t)=>qv(i,e+"",t);class tw extends ru{constructor(e,t){super(e,t),ew(this,"layerType","raster")}createLoader(){const e=new bs;return Array.isArray(this.source)?e.imgSource=this.source:e.imgSource=[this.source],e}}var nw=Object.defineProperty,rw=(i,e,t)=>e in i?nw(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Cs=(i,e,t)=>rw(i,typeof e!="symbol"?e+"":e,t);class iw extends tw{constructor(e,t){super(e,t),Cs(this,"layerType","wmts"),Cs(this,"_layerName"),Cs(this,"_style"),Cs(this,"_matrixSet"),this._layerName=t.layerName,this._style=t.style||"default",this._matrixSet=t.matrixSet||"GoogleMapsCompatible"}get layerName(){return this._layerName}get style(){return this._style}get matrixSet(){return this._matrixSet}createLoader(){const e=new bs;return Array.isArray(this.source)?e.imgSource=this.source:e.imgSource=[this.source],e}update(e){this.loader&&super.update(e)}}console.log("%c✨ terra.gl V"+lf+" ","color:rgb(255, 255, 255); font-weight: bold; background: linear-gradient(90deg, #ffb6c1, #ff69b4); padding: 5px; border-radius: 5px;"),q.ArcGisDemSource=Fv,q.ArcGisSource=Av,q.CloudsLayer=Ev,q.DrawTool=Nr,q.EventClass=Uo,q.Feature=ut,q.ICloud=qc,q.InfoWindow=_a,q.Label=eu,q.LineLayer=Yv,q.LineString=Mt,q.LoaderFactory=De,q.MVTGeoSource=Bv,q.MVTSource=kv,q.Map=vr,q.MapBoxSource=zv,q.MapTool=Cu,q.Marker=Pn,q.Martini=lu,q.Model=$c,q.MultiLineString=Ec,q.PointLayer=Rv,q.Polygon=_n,q.PolygonLayer=jv,q.ProjectFactory=zm,q.PromiseWorker=yy,q.Style=xt,q.TDTQMSource=Tv,q.TDTSource=Cv,q.TPoints=nu,q.Tile=Nn,q.TileCanvasLoader=Xy,q.TileGeometry=kr,q.TileGeometryLoader=aa,q.TileLoader=bs,q.TileLoadingManager=iu,q.TileMap=hs,q.TileMaterial=la,q.TileMaterialLoader=ca,q.TileSource=nn,q.UIComponent=Lu,q.VectorFeatureTypes=nt,q.VectorTileLayer=ga,q.VectorTileRender=uu,q.Viewer=wc,q.WMTSSource=Wv,q.WMTSTileLayer=iw,q.addSkirt=ou,q.author=Qy,q.concatenateTypedArrays=Ti,q.convertGeometryToWGS84=wy,q.createBillboards=Um,q.getBoundsCoord=na,q.getGeometryDataFromDem=au,q.getGridIndices=sa,q.getLocalInfoFromRay=No,q.getLocalInfoFromScreen=Lc,q.getLocalInfoFromWorld=Bo,q.getNormals=oa,q.getSafeTileUrlAndBounds=ra,q.registerDEMLoader=da,q.registerImgLoader=ha,q.registerMeshLoader=fu,q.vector2ToWGS84=ia,q.version=Jy,q.waitFor=Hy,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});