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

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 uf(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const ct=uf(p),hf="0.0.1-alpha.62",_o={name:"Criska"};var hr=function(){var r=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(++r%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";r=m}var i=(performance||Date).now(),o=i,a=0,c=t(new hr.Panel("FPS","#0ff","#002")),u=t(new hr.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=t(new hr.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:e,addPanel:t,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){a++;var m=(performance||Date).now();if(u.update(m-i,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(){i=this.end()},domElement:e,setMode:n}};hr.Panel=function(r,e,t){var n=1/0,i=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,v=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(r,d,m),x.fillRect(f,g,v,w),x.fillStyle=t,x.globalAlpha=.9,x.fillRect(f,g,v,w),{dom:b,update:function(L,M){n=Math.min(n,L),i=Math.max(i,L),x.fillStyle=t,x.globalAlpha=1,x.fillRect(0,0,c,g),x.fillStyle=e,x.fillText(o(L)+" "+r+" ("+o(n)+"-"+o(i)+")",d,m),x.drawImage(b,f+a,g,v-a,w,f,g,v-a,w),x.fillRect(f+v-a,g,a,w),x.fillStyle=t,x.globalAlpha=.9,x.fillRect(f+v-a,g,a,o((1-L/M)*w))}}};const qr=parseInt(p.REVISION.replace(/\D+/g,"")),wo=qr>=125?"uv1":"uv2";function Fl(r,e){if(e===p.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===p.TriangleFanDrawMode||e===p.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const a=[],c=r.getAttribute("position");if(c!==void 0){for(let u=0;u<c.count;u++)a.push(u);r.setIndex(a),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(t)if(e===p.TriangleFanDrawMode)for(let a=1;a<=n;a++)i.push(t.getX(0)),i.push(t.getX(a)),i.push(t.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(i.push(t.getX(a)),i.push(t.getX(a+1)),i.push(t.getX(a+2))):(i.push(t.getX(a+2)),i.push(t.getX(a+1)),i.push(t.getX(a)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=r.clone();return o.setIndex(i),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}var Ut=Uint8Array,Dn=Uint16Array,bo=Uint32Array,Ol=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]),Dl=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]),df=new Ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zl=function(r,e){for(var t=new Dn(31),n=0;n<31;++n)t[n]=e+=1<<r[n-1];for(var i=new bo(t[30]),n=1;n<30;++n)for(var o=t[n];o<t[n+1];++o)i[o]=o-t[n]<<5|n;return[t,i]},Xl=zl(Ol,2),Ul=Xl[0],ff=Xl[1];Ul[28]=258,ff[258]=28;for(var pf=zl(Dl,0),mf=pf[0],xo=new Dn(32768),Ze=0;Ze<32768;++Ze){var zn=(Ze&43690)>>>1|(Ze&21845)<<1;zn=(zn&52428)>>>2|(zn&13107)<<2,zn=(zn&61680)>>>4|(zn&3855)<<4,xo[Ze]=((zn&65280)>>>8|(zn&255)<<8)>>>1}for(var dr=function(r,e,t){for(var n=r.length,i=0,o=new Dn(e);i<n;++i)++o[r[i]-1];var a=new Dn(e);for(i=0;i<e;++i)a[i]=a[i-1]+o[i-1]<<1;var c;if(t){c=new Dn(1<<e);var u=15-e;for(i=0;i<n;++i)if(r[i])for(var d=i<<4|r[i],m=e-r[i],f=a[r[i]-1]++<<m,g=f|(1<<m)-1;f<=g;++f)c[xo[f]>>>u]=d}else for(c=new Dn(n),i=0;i<n;++i)r[i]&&(c[i]=xo[a[r[i]-1]++]>>>15-r[i]);return c},fr=new Ut(288),Ze=0;Ze<144;++Ze)fr[Ze]=8;for(var Ze=144;Ze<256;++Ze)fr[Ze]=9;for(var Ze=256;Ze<280;++Ze)fr[Ze]=7;for(var Ze=280;Ze<288;++Ze)fr[Ze]=8;for(var kl=new Ut(32),Ze=0;Ze<32;++Ze)kl[Ze]=5;var gf=dr(fr,9,1),yf=dr(kl,5,1),Mo=function(r){for(var e=r[0],t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},qt=function(r,e,t){var n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},So=function(r,e){var t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},vf=function(r){return(r/8|0)+(r&7&&1)},_f=function(r,e,t){(t==null||t>r.length)&&(t=r.length);var n=new(r instanceof Dn?Dn:r instanceof bo?bo:Ut)(t-e);return n.set(r.subarray(e,t)),n},wf=function(r,e,t){var n=r.length;if(!n||t&&!t.l&&n<5)return e||new Ut(0);var i=!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,v=t.n,w=n*8;do{if(!m){t.f=c=qt(r,u,1);var b=qt(r,u+1,3);if(u+=3,b)if(b==1)m=gf,f=yf,g=9,v=5;else if(b==2){var C=qt(r,u,31)+257,W=qt(r,u+10,15)+4,z=C+qt(r,u+5,31)+1;u+=14;for(var D=new Ut(z),X=new Ut(19),I=0;I<W;++I)X[df[I]]=qt(r,u+I*3,7);u+=W*3;for(var K=Mo(X),V=(1<<K)-1,G=dr(X,K,1),I=0;I<z;){var k=G[qt(r,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(r,u,3),u+=2,j=D[I-1]):x==17?(Y=3+qt(r,u,7),u+=3):x==18&&(Y=11+qt(r,u,127),u+=7);Y--;)D[I++]=j}}var H=D.subarray(0,C),Q=D.subarray(C);g=Mo(H),v=Mo(Q),m=dr(H,g,1),f=dr(Q,v,1)}else throw"invalid block type";else{var x=vf(u)+4,L=r[x-4]|r[x-3]<<8,M=x+L;if(M>n){if(o)throw"unexpected EOF";break}i&&a(d+L),e.set(r.subarray(x,M),d),t.b=d+=L,t.p=u=M*8;continue}if(u>w){if(o)throw"unexpected EOF";break}}i&&a(d+131072);for(var re=(1<<g)-1,ie=(1<<v)-1,le=u;;le=u){var j=m[So(r,u)&re],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=Ol[I];ge=qt(r,u,(1<<fe)-1)+Ul[I],u+=fe}var Se=f[So(r,u)&ie],it=Se>>>4;if(!Se)throw"invalid distance";u+=Se&15;var Q=mf[it];if(it>3){var fe=Dl[it];Q+=So(r,u)&(1<<fe)-1,u+=fe}if(u>w){if(o)throw"unexpected EOF";break}i&&a(d+131072);for(var rt=d+ge;d<rt;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=rt}}t.l=m,t.p=le,t.b=d,m&&(c=1,t.m=g,t.d=f,t.n=v)}while(!c);return d==e.length?e:_f(e,0,d)},bf=new Ut(0),xf=function(r){if((r[0]&15)!=8||r[0]>>>4>7||(r[0]<<8|r[1])%31)throw"invalid zlib data";if(r[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Mf(r,e){return wf((xf(r),r.subarray(2,-4)),e)}var Sf=typeof TextDecoder<"u"&&new TextDecoder,Lf=0;try{Sf.decode(bf,{stream:!0}),Lf=1}catch{}class Pf extends p.Mesh{constructor(e,t={}){super(e),this.isWater=!0;const n=this,i=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),v=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,W=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(i,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 <${qr>=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=v,n.material=H,n.onBeforeRender=function(Q,re,ie){if(C.setFromMatrixPosition(n.matrixWorld),W.setFromMatrixPosition(ie.matrixWorld),z.extractRotation(n.matrixWorld),M.set(0,0,1),M.applyMatrix4(z),I.subVectors(C,W),I.dot(M)>0)return;I.reflect(M).negate(),I.add(C),z.extractRotation(ie.matrixWorld),D.set(0,0,-1),D.applyMatrix4(z),D.add(W),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=ie.far,k.updateMatrixWorld(),k.projectionMatrix.copy(ie.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,v.setFromMatrixPosition(ie.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(re,k),n.visible=!0,Q.xr.enabled=ge,Q.shadowMap.autoUpdate=fe,Q.setRenderTarget(de);const Se=ie.viewport;Se!==void 0&&Q.state.viewport(Se)}}}var Cf=Object.defineProperty,Tf=(r,e,t)=>e in r?Cf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Gf=(r,e,t)=>(Tf(r,e+"",t),t);class Wf{constructor(){Gf(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 i=this._listeners[e];if(i!==void 0){const o=i.indexOf(t);o!==-1&&i.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 i=n.slice(0);for(let o=0,a=i.length;o<a;o++)i[o].call(this,e);e.target=null}}}var Zf=Object.defineProperty,Vf=(r,e,t)=>e in r?Zf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ne=(r,e,t)=>(Vf(r,typeof e!="symbol"?e+"":e,t),t);const es=new p.Ray,Kl=new p.Plane,If=Math.cos(70*(Math.PI/180)),Nl=(r,e)=>(r%e+e)%e;class Af extends Wf{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=Nl(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=Nl(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(i),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 Gs=n.object.position;ce.setFromUnitVectors(e.up,E),Me.copy(ce).invert(),O.copy(Gs).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(v,n.dampingFactor):n.target.add(v),n.zoomToCursor&&K||n.object.isOrthographicCamera?m.radius=Se(m.radius):m.radius=Se(m.radius*g),O.setFromSpherical(m),O.applyQuaternion(Me),Gs.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,v.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),v.set(0,0,0));let ni=!1;if(n.zoomToCursor&&K){let Pi=null;if(n.object instanceof p.PerspectiveCamera&&n.object.isPerspectiveCamera){const Ci=O.length();Pi=Se(Ci*g);const Qi=Ci-Pi;n.object.position.addScaledVector(X,Qi),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const Ci=new p.Vector3(I.x,I.y,0);Ci.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/g)),n.object.updateProjectionMatrix(),ni=!0;const Qi=new p.Vector3(I.x,I.y,0);Qi.unproject(n.object),n.object.position.sub(Qi).add(Ci),n.object.updateMatrixWorld(),Pi=O.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;Pi!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(Pi).add(n.object.position):(es.origin.copy(n.object.position),es.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(es.direction))<If?e.lookAt(n.target):(Kl.setFromNormalAndCoplanarPoint(n.object.up,n.target),es.intersectPlane(Kl,n.target))))}else n.object instanceof p.OrthographicCamera&&n.object.isOrthographicCamera&&(ni=g!==1,ni&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/g)),n.object.updateProjectionMatrix()));return g=1,K=!1,ni||Be.distanceToSquared(n.object.position)>d||8*(1-Bt.dot(n.object.quaternion))>d?(n.dispatchEvent(i),Be.copy(n.object.position),Bt.copy(n.object.quaternion),ni=!1,!0):!1}})(),this.connect=O=>{n.domElement=O,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",ji),n.domElement.addEventListener("pointerdown",qn),n.domElement.addEventListener("pointercancel",Mi),n.domElement.addEventListener("wheel",ti)},this.dispose=()=>{var O,E,ce,Me,Be,Bt;n.domElement&&(n.domElement.style.touchAction="auto"),(O=n.domElement)==null||O.removeEventListener("contextmenu",ji),(E=n.domElement)==null||E.removeEventListener("pointerdown",qn),(ce=n.domElement)==null||ce.removeEventListener("pointercancel",Mi),(Me=n.domElement)==null||Me.removeEventListener("wheel",ti),(Be=n.domElement)==null||Be.ownerDocument.removeEventListener("pointermove",ei),(Bt=n.domElement)==null||Bt.ownerDocument.removeEventListener("pointerup",Mi),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",wn)};const n=this,i={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 v=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,W=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),v.add(O)}})(),re=(()=>{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),v.add(O)}})(),ie=(()=>{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),re(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),re(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 it(O){w.set(O.clientX,O.clientY)}function rt(O){fe(O),W.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,W),D.y>0?de(j()):D.y<0&&ge(j()),W.copy(z),n.update()}function Re(O){M.set(O.clientX,O.clientY),C.subVectors(M,L).multiplyScalar(n.panSpeed),ie(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:ie(0,n.keyPanSpeed),E=!0;break;case n.keys.BOTTOM:ie(0,-n.keyPanSpeed),E=!0;break;case n.keys.LEFT:ie(n.keyPanSpeed,0),E=!0;break;case n.keys.RIGHT:ie(-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);W.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=Li(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 bi(O){if(V.length==1)M.set(O.pageX,O.pageY);else{const E=Li(O),ce=.5*(O.pageX+E.x),Me=.5*(O.pageY+E.y);M.set(ce,Me)}C.subVectors(M,L).multiplyScalar(n.panSpeed),ie(C.x,C.y),L.copy(M)}function Ri(O){const E=Li(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/W.y,n.zoomSpeed)),de(D.y),W.copy(z)}function xi(O){n.enableZoom&&Ri(O),n.enablePan&&bi(O)}function It(O){n.enableZoom&&Ri(O),n.enableRotate&&Lt(O)}function qn(O){var E,ce;n.enabled!==!1&&(V.length===0&&((E=n.domElement)==null||E.ownerDocument.addEventListener("pointermove",ei),(ce=n.domElement)==null||ce.ownerDocument.addEventListener("pointerup",Mi)),Fr(O),O.pointerType==="touch"?Ir(O):Si(O))}function ei(O){n.enabled!==!1&&(O.pointerType==="touch"?Ar(O):xa(O))}function Mi(O){var E,ce,Me;Or(O),V.length===0&&((E=n.domElement)==null||E.releasePointerCapture(O.pointerId),(ce=n.domElement)==null||ce.ownerDocument.removeEventListener("pointermove",ei),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",Mi)),n.dispatchEvent(a),u=c.NONE}function Si(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;rt(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;it(O),u=c.ROTATE}break;case p.MOUSE.PAN:if(O.ctrlKey||O.metaKey||O.shiftKey){if(n.enableRotate===!1)return;it(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 xa(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 ti(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 Ir(O){switch(Ji(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 Ar(O){switch(Ji(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;bi(O),n.update();break;case c.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;xi(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 ji(O){n.enabled!==!1&&O.preventDefault()}function Fr(O){V.push(O)}function Or(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 Ji(O){let E=G[O.pointerId];E===void 0&&(E=new p.Vector2,G[O.pointerId]=E),E.set(O.pageX,O.pageY)}function Li(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 Ff extends Af{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 Of=Object.defineProperty,Df=(r,e,t)=>e in r?Of(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,di=(r,e,t)=>(Df(r,typeof e!="symbol"?e+"":e,t),t);class pr{constructor(){di(this,"enabled",!0),di(this,"needsSwap",!0),di(this,"clear",!1),di(this,"renderToScreen",!1)}setSize(e,t){}render(e,t,n,i,o){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}class Bl{constructor(e){di(this,"camera",new p.OrthographicCamera(-1,1,1,-1,0,1)),di(this,"geometry",new p.PlaneGeometry(2,2)),di(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 zf=Object.defineProperty,Xf=(r,e,t)=>e in r?zf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ts=(r,e,t)=>(Xf(r,typeof e!="symbol"?e+"":e,t),t);class Yl extends pr{constructor(e,t="tDiffuse"){super(),ts(this,"textureID"),ts(this,"uniforms"),ts(this,"material"),ts(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 Bl(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 Lo={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
+ `},Uf={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 kf=Object.defineProperty,Kf=(r,e,t)=>e in r?kf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rl=(r,e,t)=>(Kf(r,typeof e!="symbol"?e+"":e,t),t);const Nf=(()=>{const r=class extends pr{constructor(t,n,i,o){super(),this.strength=n!==void 0?n:1,this.radius=i,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 v=new p.WebGLRenderTarget(a,c,{type:p.HalfFloatType});v.texture.name="UnrealBloomPass.h"+g,v.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(v);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=Uf;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=Lo;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 Bl(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 i=Math.round(t/2),o=Math.round(n/2);this.renderTargetBright.setSize(i,o);for(let a=0;a<this.nMips;a++)this.renderTargetsHorizontal[a].setSize(i,o),this.renderTargetsVertical[a].setSize(i,o),this.separableBlurMaterials[a].uniforms.texSize.value=new p.Vector2(i,o),i=Math.round(i/2),o=Math.round(o/2)}render(t,n,i,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=i.texture,t.setRenderTarget(null),t.clear(),this.fsQuad.render(t)),this.highPassUniforms.tDiffuse.value=i.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=r.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=r.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(i),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=r;return Rl(e,"BlurDirectionX",new p.Vector2(1,0)),Rl(e,"BlurDirectionY",new p.Vector2(0,1)),e})();var Bf=Object.defineProperty,Yf=(r,e,t)=>e in r?Bf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Po=(r,e,t)=>(Yf(r,typeof e!="symbol"?e+"":e,t),t);class jl extends pr{constructor(e,t){super(),Po(this,"scene"),Po(this,"camera"),Po(this,"inverse"),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=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(i.REPLACE,i.REPLACE,i.REPLACE),o.buffers.stencil.setFunc(i.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(i.EQUAL,1,4294967295),o.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),o.buffers.stencil.setLocked(!0)}}class Rf extends pr{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}var jf=Object.defineProperty,Jf=(r,e,t)=>e in r?jf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,kt=(r,e,t)=>(Jf(r,typeof e!="symbol"?e+"":e,t),t);class Qf{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},i=e.getSize(new p.Vector2);this._pixelRatio=e.getPixelRatio(),this._width=i.width,this._height=i.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,Lo===void 0&&console.error("THREE.EffectComposer relies on CopyShader"),Yl===void 0&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new Yl(Lo),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 i=this.passes.length;for(let o=0;o<i;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()}jl!==void 0&&(a instanceof jl?n=!0:a instanceof Rf&&(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,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let o=0;o<this.passes.length;o++)this.passes[o].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}var Hf=Object.defineProperty,Ef=(r,e,t)=>e in r?Hf(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fi=(r,e,t)=>(Ef(r,typeof e!="symbol"?e+"":e,t),t);class $f extends pr{constructor(e,t,n,i,o=0){super(),fi(this,"scene"),fi(this,"camera"),fi(this,"overrideMaterial"),fi(this,"clearColor"),fi(this,"clearAlpha"),fi(this,"clearDepth",!1),fi(this,"_oldClearColor",new p.Color),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=o,this.clear=!0,this.needsSwap=!1}render(e,t,n){let i=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=i}}function zi(r){if(typeof TextDecoder<"u")return new TextDecoder().decode(r);let e="";for(let t=0,n=r.length;t<n;t++)e+=String.fromCharCode(r[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const pi="srgb",Sn="srgb-linear",Jl=3001,qf=3e3;class ep extends p.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new sp(t)}),this.register(function(t){return new op(t)}),this.register(function(t){return new mp(t)}),this.register(function(t){return new gp(t)}),this.register(function(t){return new yp(t)}),this.register(function(t){return new lp(t)}),this.register(function(t){return new cp(t)}),this.register(function(t){return new up(t)}),this.register(function(t){return new hp(t)}),this.register(function(t){return new rp(t)}),this.register(function(t){return new dp(t)}),this.register(function(t){return new ap(t)}),this.register(function(t){return new pp(t)}),this.register(function(t){return new fp(t)}),this.register(function(t){return new np(t)}),this.register(function(t){return new vp(t)}),this.register(function(t){return new _p(t)})}load(e,t,n,i){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){i?i(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,i){let o;const a={},c={};if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(zi(new Uint8Array(e.slice(0,4)))===Ql){try{a[ve.KHR_BINARY_GLTF]=new wp(e)}catch(m){i&&i(m);return}o=JSON.parse(a[ve.KHR_BINARY_GLTF].content)}else o=JSON.parse(zi(new Uint8Array(e)));else o=e;if(o.asset===void 0||o.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new Ip(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 ve.KHR_MATERIALS_UNLIT:a[m]=new ip;break;case ve.KHR_DRACO_MESH_COMPRESSION:a[m]=new bp(o,this.dracoLoader);break;case ve.KHR_TEXTURE_TRANSFORM:a[m]=new xp;break;case ve.KHR_MESH_QUANTIZATION:a[m]=new Mp;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,i)}parseAsync(e,t){const n=this;return new Promise(function(i,o){n.parse(e,t,i,o)})}}function tp(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const ve={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 np{constructor(e){this.parser=e,this.name=ve.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;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 i=t.cache.get(n);if(i)return i;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),i=Promise.resolve(d),t.cache.add(n,i),i}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 ip{constructor(){this.name=ve.KHR_MATERIALS_UNLIT}getMaterialType(){return p.MeshBasicMaterial}extendParams(e,t,n){const i=[];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&&i.push(n.assignTexture(e,"map",o.baseColorTexture,pi))}return Promise.all(i)}}class rp{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class sp{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.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 op{constructor(e){this.parser=e,this.name=ve.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 i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class ap{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.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 lp{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new p.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const a=i.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,pi)),a.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",a.sheenRoughnessTexture)),Promise.all(o)}}class cp{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.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 up{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.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 hp{constructor(e){this.parser=e,this.name=ve.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 i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class dp{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.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,pi)),Promise.all(o)}}class fp{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.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 pp{constructor(e){this.parser=e,this.name=ve.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,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],a=i.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 mp{constructor(e){this.parser=e,this.name=ve.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const o=i.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 gp{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],c=i.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(i.extensionsRequired&&i.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 yp{constructor(e){this.parser=e,this.name=ve.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const a=o.extensions[t],c=i.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(i.extensionsRequired&&i.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 vp{constructor(e){this.name=ve.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 i=n.extensions[this.name],o=this.parser.getDependency("buffer",i.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=i.byteOffset||0,d=i.byteLength||0,m=i.count,f=i.byteStride,g=new Uint8Array(c,u,d);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(m,f,g,i.mode,i.filter).then(function(v){return v.buffer}):a.ready.then(function(){const v=new ArrayBuffer(m*f);return a.decodeGltfBuffer(new Uint8Array(v),m,f,g,i.mode,i.filter),v})})}else return null}}class _p{constructor(e){this.name=ve.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 i=t.meshes[n.mesh];for(const d of i.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,v=[];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 W=0;W<g;W++)u.TRANSLATION&&x.fromBufferAttribute(u.TRANSLATION,W),u.ROTATION&&L.fromBufferAttribute(u.ROTATION,W),u.SCALE&&M.fromBufferAttribute(u.SCALE,W),C.setMatrixAt(W,b.compose(x,L,M));for(const W in u)if(W==="_COLOR_0"){const z=u[W];C.instanceColor=new p.InstancedBufferAttribute(z.array,z.itemSize,z.normalized)}else W!=="TRANSLATION"&&W!=="ROTATION"&&W!=="SCALE"&&w.geometry.setAttribute(W,u[W]);p.Object3D.prototype.copy.call(C,w),this.parser.assignFinalMaterial(C),v.push(C)}return m.isGroup?(m.clear(),m.add(...v),m):v[0]}))}}const Ql="glTF",mr=12,Hl={JSON:1313821514,BIN:5130562};class wp{constructor(e){this.name=ve.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,mr);if(this.header={magic:zi(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ql)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-mr,i=new DataView(e,mr);let o=0;for(;o<n;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,c===Hl.JSON){const u=new Uint8Array(e,mr+o,a);this.content=zi(u)}else if(c===Hl.BIN){const u=mr+o;this.body=e.slice(u,u+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class bp{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ve.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,o=e.extensions[this.name].bufferView,a=e.extensions[this.name].attributes,c={},u={},d={};for(const m in a){const f=To[m]||m.toLowerCase();c[f]=a[m]}for(const m in e.attributes){const f=To[m]||m.toLowerCase();if(a[m]!==void 0){const g=n.accessors[e.attributes[m]],v=Xi[g.componentType];d[f]=v.name,u[f]=g.normalized===!0}}return t.getDependency("bufferView",o).then(function(m){return new Promise(function(f,g){i.decodeDracoFile(m,function(v){for(const w in v.attributes){const b=v.attributes[w],x=u[w];x!==void 0&&(b.normalized=x)}f(v)},c,d,Sn,g)})})}}class xp{constructor(){this.name=ve.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 Mp{constructor(){this.name=ve.KHR_MESH_QUANTIZATION}}class El extends p.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,o=e*i*3+i;for(let a=0;a!==i;a++)t[a]=n[o+a];return t}interpolate_(e,t,n,i){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=c*2,d=c*3,m=i-t,f=(n-t)/m,g=f*f,v=g*f,w=e*d,b=w-d,x=-2*v+3*g,L=v-g,M=1-x,C=L-g+f;for(let W=0;W!==c;W++){const z=a[b+W+c],D=a[b+W+u]*m,X=a[w+W+c],I=a[w+W]*m;o[W]=M*z+C*D+x*X+L*I}return o}}const Sp=new p.Quaternion;class Lp extends El{interpolate_(e,t,n,i){const o=super.interpolate_(e,t,n,i);return Sp.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},Xi={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},$l={9728:p.NearestFilter,9729:p.LinearFilter,9984:p.NearestMipmapNearestFilter,9985:p.LinearMipmapNearestFilter,9986:p.NearestMipmapLinearFilter,9987:p.LinearMipmapLinearFilter},ql={33071:p.ClampToEdgeWrapping,33648:p.MirroredRepeatWrapping,10497:p.RepeatWrapping},Co={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},To={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...qr>=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"},Pp={CUBICSPLINE:void 0,LINEAR:p.InterpolateLinear,STEP:p.InterpolateDiscrete},Go={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Cp(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new p.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:p.FrontSide})),r.DefaultMaterial}function mi(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Ln(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Tp(r,e,t){let n=!1,i=!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&&(i=!0),f.COLOR_0!==void 0&&(o=!0),n&&i&&o)break}if(!n&&!i&&!o)return Promise.resolve(r);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):r.attributes.position;a.push(g)}if(i){const g=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):r.attributes.normal;c.push(g)}if(o){const g=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):r.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&&(r.morphAttributes.position=m),i&&(r.morphAttributes.normal=f),o&&(r.morphAttributes.color=g),r.morphTargetsRelative=!0,r})}function Gp(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Wp(r){let e;const t=r.extensions&&r.extensions[ve.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Wo(t.attributes):e=r.indices+":"+Wo(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Wo(r.targets[n]);return e}function Wo(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function Zo(r){switch(r){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 Zp(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Vp=new p.Matrix4;class Ip{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new tp,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,o=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,i=navigator.userAgent.indexOf("Firefox")>-1,o=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||i&&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,i=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][i.scene||0],scenes:a[0],animations:a[1],cameras:a[2],asset:i.asset,parser:n,userData:{}};return mi(o,c,i),Ln(c,i),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 i=0,o=t.length;i<o;i++){const a=t[i].joints;for(let c=0,u=a.length;c<u;c++)e[a[c]].isBone=!0}for(let i=0,o=e.length;i<o;i++){const a=e[i];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 i=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,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const o=e(t[i]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":i=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.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[ve.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(o,a){n.load(p.LoaderUtils.resolveURL(t.uri,i.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 i=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const a=Co[i.type],c=Xi[i.componentType],u=i.normalized===!0,d=new c(i.count*a);return Promise.resolve(new p.BufferAttribute(d,a,u))}const o=[];return i.bufferView!==void 0?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),i.sparse!==void 0&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then(function(a){const c=a[0],u=Co[i.type],d=Xi[i.componentType],m=d.BYTES_PER_ELEMENT,f=m*u,g=i.byteOffset||0,v=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,w=i.normalized===!0;let b,x;if(v&&v!==f){const L=Math.floor(g/v),M="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+L+":"+i.count;let C=t.cache.get(M);C||(b=new d(c,L*v,i.count*v/m),C=new p.InterleavedBuffer(b,v/m),t.cache.add(M,C)),x=new p.InterleavedBufferAttribute(C,u,g%v/m,w)}else c===null?b=new d(i.count*u):b=new d(c,g,i.count*u),x=new p.BufferAttribute(b,u,w);if(i.sparse!==void 0){const L=Co.SCALAR,M=Xi[i.sparse.indices.componentType],C=i.sparse.indices.byteOffset||0,W=i.sparse.values.byteOffset||0,z=new M(a[1],C,i.sparse.count*L),D=new d(a[2],W,i.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 i=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=$l[g.magFilter]||p.LinearFilter,m.minFilter=$l[g.minFilter]||p.LinearMipmapLinearFilter,m.wrapS=ql[g.wrapS]||p.RepeatWrapping,m.wrapT=ql[g.wrapT]||p.RepeatWrapping,i.associations.set(m,{textures:e}),m}).catch(function(){return null});return this.textureCache[u]=d,d}loadImageSource(e,t){const n=this,i=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const a=i.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,v){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,v)})}).then(function(f){return d===!0&&c.revokeObjectURL(u),Ln(f,a),f.userData.mimeType=a.mimeType||Zp(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,i){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[ve.KHR_TEXTURE_TRANSFORM]){const c=n.extensions!==void 0?n.extensions[ve.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const u=o.associations.get(a);a=o.extensions[ve.KHR_TEXTURE_TRANSFORM].extendTexture(a,c),o.associations.set(a,u)}}return i!==void 0&&(typeof i=="number"&&(i=i===Jl?pi:Sn),"colorSpace"in a?a.colorSpace=i:a.encoding=i===pi?Jl:qf),e[t]=a,a})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=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(i||o||a){let c="ClonedMaterial:"+n.uuid+":";i&&(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),i&&(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,i=this.extensions,o=n.materials[e];let a;const c={},u=o.extensions||{},d=[];if(u[ve.KHR_MATERIALS_UNLIT]){const f=i[ve.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,pi)),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||Go.OPAQUE;if(m===Go.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,m===Go.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,pi)),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&&mi(i,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,i=this.primitiveCache;function o(c){return n[ve.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(u){return ec(u,c,t)})}const a=[];for(let c=0,u=e.length;c<u;c++){const d=e[c],m=Wp(d),f=i[m];if(f)a.push(f.promise);else{let g;d.extensions&&d.extensions[ve.KHR_DRACO_MESH_COMPRESSION]?g=o(d):g=ec(new p.BufferGeometry,d,t),i[m]={primitive:d,promise:g},a.push(g)}}return Promise.all(a)}loadMesh(e){const t=this,n=this.json,i=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?Cp(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 v=0,w=m.length;v<w;v++){const b=m[v],x=a[v];let L;const M=d[v];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=Fl(L.geometry,p.TriangleStripDrawMode):x.mode===Kt.TRIANGLE_FAN&&(L.geometry=Fl(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&&Gp(L,o),L.name=t.createUniqueName(o.name||"mesh_"+e),Ln(L,o),x.extensions&&mi(i,L,x),t.assignFinalMaterial(L),f.push(L)}for(let v=0,w=f.length;v<w;v++)t.associations.set(f[v],{meshes:e,primitives:v});if(f.length===1)return o.extensions&&mi(i,f[0],o),f[0];const g=new p.Group;o.extensions&&mi(i,g,o),t.associations.set(g,{meshes:e});for(let v=0,w=f.length;v<w;v++)g.add(f[v]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new p.PerspectiveCamera(p.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new p.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.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 i=0,o=t.joints.length;i<o;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const o=i.pop(),a=i,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,i=t.animations[e],o=i.name?i.name:"animation_"+e,a=[],c=[],u=[],d=[],m=[];for(let f=0,g=i.channels.length;f<g;f++){const v=i.channels[f],w=i.samplers[v.sampler],b=v.target,x=b.node,L=i.parameters!==void 0?i.parameters[w.input]:w.input,M=i.parameters!==void 0?i.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],v=f[1],w=f[2],b=f[3],x=f[4],L=[];for(let M=0,C=g.length;M<C;M++){const W=g[M],z=v[M],D=w[M],X=b[M],I=x[M];if(W===void 0)continue;W.updateMatrix&&W.updateMatrix();const K=n._createAnimationTracks(W,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,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(o){const a=n._getNodeRef(n.meshCache,i.mesh,o);return i.weights!==void 0&&a.traverse(function(c){if(c.isMesh)for(let u=0,d=i.weights.length;u<d;u++)c.morphTargetInfluences[u]=i.weights[u]}),a})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],o=n._loadNodeShallow(e),a=[],c=i.children||[];for(let d=0,m=c.length;d<m;d++)a.push(n.getDependency("node",c[d]));const u=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.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(v){v.isSkinnedMesh&&v.bind(g,Vp)});for(let v=0,w=f.length;v<w;v++)m.add(f[v]);return m})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],a=o.name?i.createUniqueName(o.name):"",c=[],u=i._invokeOne(function(d){return d.createNodeMesh&&d.createNodeMesh(e)});return u&&c.push(u),o.camera!==void 0&&c.push(i.getDependency("camera",o.camera).then(function(d){return i._getNodeRef(i.cameraCache,o.camera,d)})),i._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&&mi(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 i.associations.has(m)||i.associations.set(m,{}),i.associations.get(m).nodes=e,m}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,o=new p.Group;n.name&&(o.name=i.createUniqueName(n.name)),Ln(o,n),n.extensions&&mi(t,o,n);const a=n.nodes||[],c=[];for(let u=0,d=a.length;u<d;u++)c.push(i.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,v]of i.associations)(g instanceof p.Material||g instanceof p.Texture)&&f.set(g,v);return m.traverse(g=>{const v=i.associations.get(g);v!=null&&f.set(g,v)}),f};return i.associations=d(o),o})}_createAnimationTracks(e,t,n,i,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=i.interpolation!==void 0?Pp[i.interpolation]:p.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let g=0,v=u.length;g<v;g++){const w=new d(u[g]+"."+Xn[o.path],t.array,f,m);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(w),a.push(w)}return a}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Zo(t.constructor),i=new Float32Array(t.length);for(let o=0,a=t.length;o<a;o++)i[o]=t[o]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof p.QuaternionKeyframeTrack?Lp:El;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ap(r,e,t){const n=e.attributes,i=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(i.set(new p.Vector3(u[0],u[1],u[2]),new p.Vector3(d[0],d[1],d[2])),c.normalized){const m=Zo(Xi[c.componentType]);i.min.multiplyScalar(m),i.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],v=g.min,w=g.max;if(v!==void 0&&w!==void 0){if(u.setX(Math.max(Math.abs(v[0]),Math.abs(w[0]))),u.setY(Math.max(Math.abs(v[1]),Math.abs(w[1]))),u.setZ(Math.max(Math.abs(v[2]),Math.abs(w[2]))),g.normalized){const b=Zo(Xi[g.componentType]);u.multiplyScalar(b)}c.max(u)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(c)}r.boundingBox=i;const a=new p.Sphere;i.getCenter(a.center),a.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=a}function ec(r,e,t){const n=e.attributes,i=[];function o(a,c){return t.getDependency("accessor",a).then(function(u){r.setAttribute(c,u)})}for(const a in n){const c=To[a]||a.toLowerCase();c in r.attributes||i.push(o(n[a],c))}if(e.indices!==void 0&&!r.index){const a=t.getDependency("accessor",e.indices).then(function(c){r.setIndex(c)});i.push(a)}return Ln(r,e),Ap(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?Tp(r,e.targets,t):r})}function tc(r,e,t){const n=t.length-r-1;if(e>=t[n])return n-1;if(e<=t[r])return r;let i=r,o=n,a=Math.floor((i+o)/2);for(;e<t[a]||e>=t[a+1];)e<t[a]?o=a:i=a,a=Math.floor((i+o)/2);return a}function Fp(r,e,t,n){const i=[],o=[],a=[];i[0]=1;for(let c=1;c<=t;++c){o[c]=e-n[r+1-c],a[c]=n[r+c]-e;let u=0;for(let d=0;d<c;++d){const m=a[d+1],f=o[c-d],g=i[d]/(m+f);i[d]=u+m*g,u=f*g}i[c]=u}return i}function Op(r,e,t,n){const i=tc(r,n,e),o=Fp(i,n,r,e),a=new p.Vector4(0,0,0,0);for(let c=0;c<=r;++c){const u=t[i-r+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 Dp(r,e,t,n,i){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-i[r+1-f],d[f]=i[r+f]-e;let g=0;for(let v=0;v<f;++v){const w=d[v+1],b=u[f-v];c[f][v]=w+b;const x=c[v][f-1]/c[f][v];c[v][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,v=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[v][0]=w[g][0]/c[M+1][L],x=w[v][0]*c[L][M]);const C=L>=-1?1:-L,W=f-1<=M?b-1:t-f;for(let D=C;D<=W;++D)w[v][D]=(w[g][D]-w[g][D-1])/c[M+1][L+D],x+=w[v][D]*c[L+D][M];f<=M&&(w[v][b]=-w[g][b-1]/c[M+1][f],x+=w[v][b]*c[f][M]),a[b][f]=x;const z=g;g=v,v=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 zp(r,e,t,n,i){const o=i<r?i:r,a=[],c=tc(r,n,e),u=Dp(c,n,r,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-r].clone().multiplyScalar(u[m][0]);for(let g=1;g<=r;++g)f.add(d[c-r+g].clone().multiplyScalar(u[m][g]));a[m]=f}for(let m=o+1;m<=i+1;++m)a[m]=new p.Vector4(0,0,0);return a}function Xp(r,e){let t=1;for(let i=2;i<=r;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=r-e;++i)n*=i;return t/n}function Up(r){const e=r.length,t=[],n=[];for(let o=0;o<e;++o){const a=r[o];t[o]=new p.Vector3(a.x,a.y,a.z),n[o]=a.w}const i=[];for(let o=0;o<e;++o){const a=t[o].clone();for(let c=1;c<=o;++c)a.sub(i[o-c].clone().multiplyScalar(Xp(o,c)*n[c]));i[o]=a.divideScalar(n[0])}return i}function kp(r,e,t,n,i){const o=zp(r,e,t,n,i);return Up(o)}class nc extends p.Curve{constructor(e,t,n,i,o){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||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,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),o=Op(this.degree,this.knots,this.controlPoints,i);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,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),o=kp(this.degree,this.knots,this.controlPoints,i,1);return n.copy(o[1]).normalize(),n}}let _e,Ue,bt;class Kp extends p.Loader{constructor(e){super(e)}load(e,t,n,i){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){i?i(d):console.error(d),o.manager.itemError(e)}},n,i)}parse(e,t){if(Jp(e))_e=new jp().parse(e);else{const i=lc(e);if(!Qp(i))throw new Error("THREE.FBXLoader: Unknown format.");if(sc(i)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+sc(i));_e=new Rp().parse(i)}const n=new p.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Np(n,this.manager).parse(_e)}}class Np{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),i=this.parseDeformers(),o=new Bp().parse(i);return this.parseScene(i,o,n),bt}parseConnections(){const e=new Map;return"Connections"in _e&&_e.Connections.connections.forEach(function(n){const i=n[0],o=n[1],a=n[2];e.has(i)||e.set(i,{parents:[],children:[]});const c={ID:o,relationship:a};e.get(i).parents.push(c),e.has(o)||e.set(o,{parents:[],children:[]});const u={ID:i,relationship:a};e.get(o).children.push(u)}),e}parseImages(){const e={},t={};if("Video"in _e.Objects){const n=_e.Objects.Video;for(const i in n){const o=n[i],a=parseInt(i);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[i]);t[o.RelativeFilename||o.Filename]=d}}}}for(const n in e){const i=e[n];t[i]!==void 0?e[n]=t[i]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,i=n.slice(n.lastIndexOf(".")+1).toLowerCase();let o;switch(i){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 "'+i+'" 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 _e.Objects){const n=_e.Objects.Texture;for(const i in n){const o=this.parseTexture(n[i],e);t.set(parseInt(i),o)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const i=e.WrapModeU,o=e.WrapModeV,a=i!==void 0?i.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 i=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(i),a}parseMaterials(e){const t=new Map;if("Material"in _e.Objects){const n=_e.Objects.Material;for(const i in n){const o=this.parseMaterial(n[i],e);o!==null&&t.set(parseInt(i),o)}}return t}parseMaterial(e,t){const n=e.id,i=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=i,c}parseParameters(e,t,n){const i={};e.BumpFactor&&(i.bumpScale=e.BumpFactor.value),e.Diffuse?i.color=new p.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(i.color=new p.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(i.displacementScale=e.DisplacementFactor.value),e.Emissive?i.emissive=new p.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(i.emissive=new p.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(i.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(i.opacity=parseFloat(e.Opacity.value)),i.opacity<1&&(i.transparent=!0),e.ReflectionFactor&&(i.reflectivity=e.ReflectionFactor.value),e.Shininess&&(i.shininess=e.Shininess.value),e.Specular?i.specular=new p.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(i.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":i.bumpMap=o.getTexture(t,a.ID);break;case"Maya|TEX_ao_map":i.aoMap=o.getTexture(t,a.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":i.map=o.getTexture(t,a.ID),i.map!==void 0&&("colorSpace"in i.map?i.map.colorSpace="srgb":i.map.encoding=3001);break;case"DisplacementColor":i.displacementMap=o.getTexture(t,a.ID);break;case"EmissiveColor":i.emissiveMap=o.getTexture(t,a.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=o.getTexture(t,a.ID);break;case"ReflectionColor":i.envMap=o.getTexture(t,a.ID),i.envMap!==void 0&&(i.envMap.mapping=p.EquirectangularReflectionMapping,"colorSpace"in i.envMap?i.envMap.colorSpace="srgb":i.envMap.encoding=3001);break;case"SpecularColor":i.specularMap=o.getTexture(t,a.ID),i.specularMap!==void 0&&("colorSpace"in i.specularMap?i.specularMap.colorSpace="srgb":i.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":i.alphaMap=o.getTexture(t,a.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.",c);break}}),i}getTexture(e,t){return"LayeredTexture"in _e.Objects&&t in _e.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 _e.Objects){const n=_e.Objects.Deformer;for(const i in n){const o=n[i],a=Ue.get(parseInt(i));if(o.attrType==="Skin"){const c=this.parseSkeleton(a,n);c.ID=i,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[i]=c}else if(o.attrType==="BlendShape"){const c={id:i};c.rawTargets=this.parseMorphTargets(a,n),c.id=i,a.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[i]=c}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(i){const o=t[i.ID];if(o.attrType!=="Cluster")return;const a={ID:i.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 i=0;i<e.children.length;i++){const o=e.children[i],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 i=this.parseModels(e.skeletons,t,n),o=_e.Objects.Model,a=this;i.forEach(function(u){const d=o[u.ID];a.setLookAtProperties(u,d),Ue.get(u.ID).parents.forEach(function(f){const g=i.get(f.ID);g!==void 0&&g.add(u)}),u.parent===null&&bt.add(u)}),this.bindSkeleton(e.skeletons,t,i),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=oc(u.userData.transformData);u.applyMatrix4(d),u.updateWorldMatrix()}});const c=new Yp().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 i=new Map,o=_e.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),i.set(c,m)}return i}buildSkeleton(e,t,n,i){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=i?p.PropertyBinding.sanitizeNodeName(i):"",o.ID=n,u.bones[m]=o,f!==null&&o.add(f)}})}}),o}createCamera(e){let t,n;if(e.children.forEach(function(i){const o=_e.Objects.NodeAttribute[i.ID];o!==void 0&&(n=o)}),n===void 0)t=new p.Object3D;else{let i=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(i=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(i){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 "+i+"."),t=new p.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(i){const o=_e.Objects.NodeAttribute[i.ID];o!==void 0&&(n=o)}),n===void 0)t=new p.Object3D;else{let i;n.LightType===void 0?i=0:i=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(i){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 i,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?(i=new p.SkinnedMesh(o,a),i.normalizeSkinWeights()):i=new p.Mesh(o,a),i}createCurve(e,t){const n=e.children.reduce(function(o,a){return t.has(a.ID)&&(o=t.get(a.ID)),o},null),i=new p.LineBasicMaterial({color:3342591,linewidth:1});return new p.Line(n,i)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=ac(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(i){if(i.relationship==="LookAtProperty"){const o=_e.Objects.Model[i.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 i=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),i[f.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in _e.Objects){const t=_e.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const i=t[n].PoseNode;Array.isArray(i)?i.forEach(function(o){e[o.Node]=new p.Matrix4().fromArray(o.Matrix.a)}):e[i.Node]=new p.Matrix4().fromArray(i.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in _e&&"AmbientColor"in _e.GlobalSettings){const e=_e.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],i=e[2];if(t!==0||n!==0||i!==0){const o=new p.Color(t,n,i);bt.add(new p.AmbientLight(o,1))}}}}class Bp{parse(e){const t=new Map;if("Geometry"in _e.Objects){const n=_e.Objects.Geometry;for(const i in n){const o=Ue.get(parseInt(i)),a=this.parseGeometry(o,n[i],e);t.set(parseInt(i),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 i=n.skeletons,o=[],a=e.parents.map(function(f){return _e.Objects.Model[f.ID]});if(a.length===0)return;const c=e.children.reduce(function(f,g){return i[g.ID]!==void 0&&(f=i[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=ac(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=oc(d);return this.genGeometry(t,c,o,m)}genGeometry(e,t,n,i){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(i),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(i),m=new p.Float32BufferAttribute(c.normal,3);m.applyNormalMatrix(d),o.setAttribute("normal",m)}if(c.uvs.forEach(function(d,m){wo==="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,i),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 i=0;for(;e.LayerElementUV[i];)e.LayerElementUV[i].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[i])),i++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(i,o){i.indices.forEach(function(a,c){n.weightTable[a]===void 0&&(n.weightTable[a]=[]),n.weightTable[a].push({id:o,weight:i.weights[c]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,i=0,o=!1,a=[],c=[],u=[],d=[],m=[],f=[];const g=this;return e.vertexIndices.forEach(function(v,w){let b,x=!1;v<0&&(v=v^-1,x=!0);let L=[],M=[];if(a.push(v*3,v*3+1,v*3+2),e.color){const C=ns(w,n,v,e.color);u.push(C[0],C[1],C[2])}if(e.skeleton){if(e.weightTable[v]!==void 0&&e.weightTable[v].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],W=[0,0,0,0];M.forEach(function(z,D){let X=z,I=L[D];W.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=W}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=ns(w,n,v,e.normal);c.push(C[0],C[1],C[2])}e.material&&e.material.mappingType!=="AllSame"&&(b=ns(w,n,v,e.material)[0]),e.uv&&e.uv.forEach(function(C,W){const z=ns(w,n,v,C);d[W]===void 0&&(d[W]=[]),d[W].push(z[0]),d[W].push(z[1])}),i++,x&&(g.genFace(t,e,a,b,c,u,d,m,f,i),n++,i=0,a=[],c=[],u=[],d=[],m=[],f=[])}),t}genFace(e,t,n,i,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(i),e.materialIndex.push(i),e.materialIndex.push(i)),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,v){e.uvs[v]===void 0&&(e.uvs[v]=[]),e.uvs[v].push(c[v][0]),e.uvs[v].push(c[v][1]),e.uvs[v].push(c[v][(f-1)*2]),e.uvs[v].push(c[v][(f-1)*2+1]),e.uvs[v].push(c[v][f*2]),e.uvs[v].push(c[v][f*2+1])})}addMorphTargets(e,t,n,i){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=_e.Objects.Geometry[c.geoID];u!==void 0&&o.genMorphGeometry(e,t,u,i,c.name)})})}genMorphGeometry(e,t,n,i,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),v=new p.Float32BufferAttribute(g.vertex,3);v.name=o||n.attrName,v.applyMatrix4(i),e.morphAttributes.position.push(v)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=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:i,indices:o,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.UV.a;let o=[];return n==="IndexToDirect"&&(o=e.UVIndex.a),{dataSize:2,buffer:i,indices:o,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,i=e.Colors.a;let o=[];return n==="IndexToDirect"&&(o=e.ColorIndex.a),{dataSize:4,buffer:i,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 i=e.Materials.a,o=[];for(let a=0;a<i.length;++a)o.push(a);return{dataSize:1,buffer:i,indices:o,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(nc===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,i=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=i.length-1-c;for(let f=0;f<n;++f)o.push(o[f])}const m=new nc(n,i,o,c,u).getPoints(o.length*12);return new p.BufferGeometry().setFromPoints(m)}}class Yp{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const i=t[n],o=this.addClip(i);e.push(o)}return e}parseClips(){if(_e.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=_e.Objects.AnimationCurveNode,t=new Map;for(const n in e){const i=e[n];if(i.attrName.match(/S|R|T|DeformPercent/)!==null){const o={id:i.id,attr:i.attrName,curves:{}};t.set(o.id,o)}}return t}parseAnimationCurves(e){const t=_e.Objects.AnimationCurve;for(const n in t){const i={id:t[n].id,times:t[n].KeyTime.a.map(Hp),values:t[n].KeyValueFloat.a},o=Ue.get(i.id);if(o!==void 0){const a=o.parents[0].ID,c=o.parents[0].relationship;c.match(/X/)?e.get(a).curves.x=i:c.match(/Y/)?e.get(a).curves.y=i:c.match(/Z/)?e.get(a).curves.z=i:c.match(/d|DeformPercent/)&&e.has(a)&&(e.get(a).curves.morph=i)}}}parseAnimationLayers(e){const t=_e.Objects.AnimationLayer,n=new Map;for(const i in t){const o=[],a=Ue.get(parseInt(i));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=_e.Objects.Model[f.toString()];if(g===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",u);return}const v={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&&(v.transform=w.matrix,w.userData.transformData&&(v.eulerOrder=w.userData.transformData.eulerOrder))}),v.transform||(v.transform=new p.Matrix4),"PreRotation"in g&&(v.preRotation=g.PreRotation.value),"PostRotation"in g&&(v.postRotation=g.PostRotation.value),o[d]=v}}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,v=Ue.get(g).parents[0].ID,w=Ue.get(v).parents[0].ID,b=_e.Objects.Model[w],x={modelName:b.attrName?p.PropertyBinding.sanitizeNodeName(b.attrName):"",morphName:_e.Objects.Deformer[f].attrName};o[d]=x}o[d][m.attr]=m}}}),n.set(parseInt(i),o))}return n}parseAnimStacks(e){const t=_e.Objects.AnimationStack,n={};for(const i in t){const o=Ue.get(parseInt(i)).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[i]={name:t[i].attrName,layer:a}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(i){t=t.concat(n.generateTracks(i))}),new p.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new p.Vector3,i=new p.Quaternion,o=new p.Vector3;if(e.transform&&e.transform.decompose(n,i,o),n=n.toArray(),i=new p.Euler().setFromQuaternion(i,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,i,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,i){const o=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(o,t,n);return new p.VectorKeyframeTrack(e+"."+i,o,a)}generateRotationTrack(e,t,n,i,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);i!==void 0&&(i=i.map(p.MathUtils.degToRad),i.push(a),i=new p.Euler().fromArray(i),i=new p.Quaternion().setFromEuler(i)),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),i!==void 0&&d.premultiply(i),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}),i=bt.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new p.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+i+"]",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,i){return n-i}),t.length>1){let n=1,i=t[0];for(let o=1;o<t.length;o++){const a=t[o];a!==i&&(t[n]=a,i=a,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const i=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),i[0]=m}else o.push(i[0]);if(c!==-1){const m=t.y.values[c];o.push(m),i[1]=m}else o.push(i[1]);if(u!==-1){const m=t.z.values[u];o.push(m),i[2]=m}else o.push(i[2])}),o}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],i=e.values[t]-n,o=Math.abs(i);if(o>=180){const a=o/180,c=i/a;let u=n+c;const d=e.times[t-1],f=(e.times[t]-d)/a;let g=d+f;const v=[],w=[];for(;g<e.times[t];)v.push(g),g+=f,w.push(u),u+=c;e.times=cc(e.times,t,v),e.values=cc(e.values,t,w)}}}}class Rp{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 rc,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(i,o){const a=i.match(/^[\s\t]*;/),c=i.match(/^[\s\t]*$/);if(a||c)return;const u=i.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),d=i.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),m=i.match("^\\t{"+(t.currentIndent-1)+"}}");u?t.parseNodeBegin(i,u):d?t.parseNodeProperty(i,d,n[++o]):m?t.popStack():i.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(i)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),i=t[2].split(",").map(function(u){return u.trim().replace(/^"/,"").replace(/"$/,"")}),o={name:n},a=this.parseNodeAttr(i),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="",i="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),i=e[2]),{id:t,name:n,type:i}}parseNodeProperty(e,t,n){let i=t[1].replace(/^"/,"").replace(/"$/,"").trim(),o=t[2].replace(/^"/,"").replace(/"$/,"").trim();i==="Content"&&o===","&&(o=n.replace(/"/g,"").replace(/,$/,"").trim());const a=this.getCurrentNode();if(a.name==="Properties70"){this.parseNodeSpecialProperty(e,i,o);return}if(i==="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(/^"/,"")}),i="connections",o=[d,m],$p(o,f),a[i]===void 0&&(a[i]=[])}i==="Node"&&(a.id=o),i in a&&Array.isArray(a[i])?a[i].push(o):i!=="a"?a[i]=o:a.a=o,this.setCurrentProp(a,i),i==="a"&&o.slice(-1)!==","&&(a.a=Io(o))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=Io(t.a))}parseNodeSpecialProperty(e,t,n){const i=n.split('",').map(function(m){return m.trim().replace(/^\"/,"").replace(/\s/,"_")}),o=i[0],a=i[1],c=i[2],u=i[3];let d=i[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=Io(d);break}this.getPrevNode()[o]={type:a,type2:c,flag:u,value:d},this.setCurrentProp(this.getPrevNode(),o)}}class jp{parse(e){const t=new ic(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const i=new rc;for(;!this.endOfContent(t);){const o=this.parseNode(t,n);o!==null&&i.add(o.name,o)}return i}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={},i=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(i===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()===i;i>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 i=n.propertyList[0];Array.isArray(i)?(t[n.name]=n,n.a=i):t[n.name]=i}else if(e==="Connections"&&n.name==="C"){const i=[];n.propertyList.forEach(function(o,a){a!==0&&i.push(o)}),t.connections===void 0&&(t.connections=[]),t.connections.push(i)}else if(n.name==="Properties70")Object.keys(n).forEach(function(o){t[o]=n[o]});else if(e==="Properties70"&&n.name==="P"){let i=n.propertyList[0],o=n.propertyList[1];const a=n.propertyList[2],c=n.propertyList[3];let u;i.indexOf("Lcl ")===0&&(i=i.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[i]={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 i=e.getUint32(),o=e.getUint32(),a=e.getUint32();if(o===0)switch(t){case"b":case"c":return e.getBooleanArray(i);case"d":return e.getFloat64Array(i);case"f":return e.getFloat32Array(i);case"i":return e.getInt32Array(i);case"l":return e.getInt64Array(i)}const c=Mf(new Uint8Array(e.getArrayBuffer(a))),u=new ic(c.buffer);switch(t){case"b":case"c":return u.getBooleanArray(i);case"d":return u.getFloat64Array(i);case"f":return u.getFloat32Array(i);case"i":return u.getInt32Array(i);case"l":return u.getInt64Array(i)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class ic{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 i=0;i<e;i++)t[i]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),zi(new Uint8Array(t))}}class rc{add(e,t){this[e]=t}}function Jp(r){const e="Kaydara FBX Binary \0";return r.byteLength>=e.length&&e===lc(r,0,e.length)}function Qp(r){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(i){const o=r[i-1];return r=r.slice(t+i),t++,o}for(let i=0;i<e.length;++i)if(n(1)===e[i])return!1;return!0}function sc(r){const e=/FBXVersion: (\d+)/,t=r.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Hp(r){return r/46186158e3}const Ep=[];function ns(r,e,t,n){let i;switch(n.mappingType){case"ByPolygonVertex":i=r;break;case"ByPolygon":i=e;break;case"ByVertice":i=t;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 o=i*n.dataSize,a=o+n.dataSize;return qp(Ep,n.buffer,o,a)}const Vo=new p.Euler,Ui=new p.Vector3;function oc(r){const e=new p.Matrix4,t=new p.Matrix4,n=new p.Matrix4,i=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,v=r.inheritType?r.inheritType:0;if(r.translation&&e.setPosition(Ui.fromArray(r.translation)),r.preRotation){const V=r.preRotation.map(p.MathUtils.degToRad);V.push(r.eulerOrder),t.makeRotationFromEuler(Vo.fromArray(V))}if(r.rotation){const V=r.rotation.map(p.MathUtils.degToRad);V.push(r.eulerOrder),n.makeRotationFromEuler(Vo.fromArray(V))}if(r.postRotation){const V=r.postRotation.map(p.MathUtils.degToRad);V.push(r.eulerOrder),i.makeRotationFromEuler(Vo.fromArray(V)),i.invert()}r.scale&&o.scale(Ui.fromArray(r.scale)),r.scalingOffset&&c.setPosition(Ui.fromArray(r.scalingOffset)),r.scalingPivot&&a.setPosition(Ui.fromArray(r.scalingPivot)),r.rotationOffset&&u.setPosition(Ui.fromArray(r.rotationOffset)),r.rotationPivot&&d.setPosition(Ui.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(f.copy(r.parentMatrix),m.copy(r.parentMatrixWorld));const w=t.clone().multiply(n).multiply(i),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,W=new p.Matrix4;if(v===0)W.copy(b).multiply(w).multiply(M).multiply(C);else if(v===1)W.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);W.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(i).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(W),X.premultiply(m.invert()),X}function ac(r){r=r||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return r===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[r]}function Io(r){return r.split(",").map(function(t){return parseFloat(t)})}function lc(r,e,t){return e===void 0&&(e=0),t===void 0&&(t=r.byteLength),zi(new Uint8Array(r,e,t))}function $p(r,e){for(let t=0,n=r.length,i=e.length;t<i;t++,n++)r[n]=e[t]}function qp(r,e,t,n){for(let i=t,o=0;i<n;i++,o++)r[o]=e[i];return r}function cc(r,e,t){return r.slice(0,e).concat(t).concat(r.slice(e))}class em 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},v=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),re=new Uint8Array(H);let ie=V;for(;ie>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 it=0;it<de;it++)re[le++]=Se}else re.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]=re[fe+Se],Se+=G,k[j+1]=re[fe+Se],Se+=G,k[j+2]=re[fe+Se],Se+=G,k[j+3]=re[fe+Se],j+=4}ie--}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,W=v(x.subarray(x.pos),M,C);let z,D,X;switch(this.type){case p.FloatType:X=W.length/4;const I=new Float32Array(X*4);for(let V=0;V<X;V++)w(W,V*4,I,V*4);z=I,D=p.FloatType;break;case p.HalfFloatType:X=W.length/4;const K=new Uint16Array(X*4);for(let V=0;V<X;V++)b(W,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,i){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,i)}}const Ao=new WeakMap;class tm 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,i){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(i)},n,i)}decodeDracoFile(e,t,n,i){const o={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||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(Ao.has(e)){const u=Ao.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 i;const o=this.workerNextTaskID++,a=e.byteLength,c=this._getWorker(o,a).then(u=>(i=u,new Promise((d,m)=>{i._callbacks[o]={resolve:d,reject:m},i.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(u=>this._createGeometry(u.geometry));return c.catch(()=>!0).then(()=>{i&&o&&this._releaseTask(i,o)}),Ao.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 i=e.attributes[n],o=i.name,a=i.array,c=i.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((i,o)=>{n.load(e,i,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 i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=nm.toString(),a=["/* draco decoder */",i,"","/* 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 i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(o){const a=o.data;switch(a.type){case"decode":i._callbacks[a.id].resolve(a);break;case"error":i._callbacks[a.id].reject(a);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+a.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,o){return i._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 nm(){let r,e;onmessage=function(a){const c=a.data;switch(c.type){case"init":r=c.decoderConfig,e=new Promise(function(m){r.onModuleLoaded=function(f){m({draco:f})},DracoDecoderModule(r)});break;case"decode":const u=c.buffer,d=c.taskConfig;e.then(m=>{const f=m.draco,g=new f.Decoder,v=new f.DecoderBuffer;v.Init(new Int8Array(u),u.byteLength);try{const w=t(f,g,v,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(v),f.destroy(g)}});break}};function t(a,c,u,d){const m=d.attributeIDs,f=d.attributeTypes;let g,v;const w=c.GetEncodedGeometryType(u);if(w===a.TRIANGULAR_MESH)g=new a.Mesh,v=c.DecodeBufferToMesh(u,g);else if(w===a.POINT_CLOUD)g=new a.PointCloud,v=c.DecodeBufferToPointCloud(u,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!v.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+v.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(i(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 v=new Uint32Array(a.HEAPF32.buffer,g,m).slice();return a._free(g),{array:v,itemSize:1}}function i(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 uc=new p.Box3,is=new p.Vector3;class hc 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 i=new p.InstancedInterleavedBuffer(n,t*2,1);return this.setAttribute("instanceColorStart",new p.InterleavedBufferAttribute(i,t,0)),this.setAttribute("instanceColorEnd",new p.InterleavedBufferAttribute(i,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),uc.setFromBufferAttribute(t),this.boundingBox.union(uc))}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 i=0;for(let o=0,a=e.count;o<a;o++)is.fromBufferAttribute(e,o),i=Math.max(i,n.distanceToSquared(is)),is.fromBufferAttribute(t,o),i=Math.max(i,n.distanceToSquared(is));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(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}class rs extends hc{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let i=0;i<t;i+=3)n[2*i]=e[i],n[2*i+1]=e[i+1],n[2*i+2]=e[i+2],n[2*i+3]=e[i+3],n[2*i+4]=e[i+4],n[2*i+5]=e[i+5];return super.setPositions(n),this}setColors(e,t=3){const n=e.length-t,i=new Float32Array(2*n);if(t===3)for(let o=0;o<n;o+=t)i[2*o]=e[o],i[2*o+1]=e[o+1],i[2*o+2]=e[o+2],i[2*o+3]=e[o+3],i[2*o+4]=e[o+4],i[2*o+5]=e[o+5];else for(let o=0;o<n;o+=t)i[2*o]=e[o],i[2*o+1]=e[o+1],i[2*o+2]=e[o+2],i[2*o+3]=e[o+3],i[2*o+4]=e[o+4],i[2*o+5]=e[o+5],i[2*o+6]=e[o+6],i[2*o+7]=e[o+7];return super.setColors(i,t),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class gr 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,324 @@
502
612
  gl_FragColor = diffuseColor;
503
613
 
504
614
  #include <tonemapping_fragment>
505
- #include <${ot>=154?"colorspace_fragment":"encodings_fragment"}>
615
+ #include <${qr>=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+WiBpbiBqP2NlKGosWix7ZW51bWVyYWJsZTohMCxjb25maWd1cmFibGU6ITAsd3JpdGFibGU6ITAsdmFsdWU6cX0pOmpbWl09cTt2YXIgTj0oaixaLHEpPT5tZShqLHR5cGVvZiBaIT0ic3ltYm9sIj9aKyIiOloscSk7KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3Qi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VvbWV0cnlEYXRhKHQpfWZ1bmN0aW9uIGZlKEEscCl7ZnVuY3Rpb24gayhzLHQsbixoLGksbyxjLHUpe2NvbnN0IG09bmV3IEZsb2F0MzJBcnJheShpKm8pO2ZvcihsZXQgbD0wO2w8bztsKyspZm9yKGxldCBmPTA7ZjxpO2YrKyl7Y29uc3QgZz0obCtoKSp0KyhmK24pLE09bCppK2Y7bVtNXT1zW2ddfWNvbnN0IHc9bmV3IEZsb2F0MzJBcnJheSh1KmMpO2ZvcihsZXQgbD0wO2w8dTtsKyspZm9yKGxldCBmPTA7ZjxjO2YrKyl7Y29uc3QgZz1sKnUrZixNPU1hdGgucm91bmQoZipvL3UpLGQ9TWF0aC5yb3VuZChsKmkvYykqaStNO3dbZ109bVtkXX1yZXR1cm4gd31jb25zdCBVPW9lKHAsQS53aWR0aCksYT1VLnN3KzEsZT1VLnNoKzE7cmV0dXJue2FycmF5OmsoQS5hcnJheSxBLndpZHRoLFUuc3gsVS5zeSxVLnN3LFUuc2gsYSxlKSx3aWR0aDphLGhlaWdodDplfX1mdW5jdGlvbiBvZShBLHApe2NvbnN0IGs9TWF0aC5mbG9vcihBWzBdKnApLFU9TWF0aC5mbG9vcihBWzFdKnApLGE9TWF0aC5mbG9vcigoQVsyXS1BWzBdKSpwKSxlPU1hdGguZmxvb3IoKEFbM10tQVsxXSkqcCk7cmV0dXJue3N4Omssc3k6VSxzdzphLHNoOmV9fXNlbGYub25tZXNzYWdlPUE9Pntjb25zdCBwPUEuZGF0YSxrPXNlKHAuZGVtRGF0YSxwLnoscC5jbGlwQm91bmRzKTtzZWxmLnBvc3RNZXNzYWdlKGspfX0pKCk7Cg==",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 Fo=new p.Vector4,dc=new p.Vector3,fc=new p.Vector3,Ee=new p.Vector4,$e=new p.Vector4,dn=new p.Vector4,Oo=new p.Vector3,Do=new p.Matrix4,qe=new p.Line3,pc=new p.Vector3,ss=new p.Box3,os=new p.Sphere,fn=new p.Vector4;let pn,gi;function mc(r,e,t){return fn.set(0,0,-e,1).applyMatrix4(r.projectionMatrix),fn.multiplyScalar(1/fn.w),fn.x=gi/t.width,fn.y=gi/t.height,fn.applyMatrix4(r.projectionMatrixInverse),fn.multiplyScalar(1/fn.w),Math.abs(Math.max(fn.x,fn.y))}function im(r,e){const t=r.matrixWorld,n=r.geometry,i=n.attributes.instanceStart,o=n.attributes.instanceEnd,a=Math.min(n.instanceCount,i.count);for(let c=0,u=a;c<u;c++){qe.start.fromBufferAttribute(i,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)<gi*.5&&e.push({point:m,pointOnLine:d,distance:pn.origin.distanceTo(m),object:r,face:null,faceIndex:c,uv:null,[wo]:null})}}function rm(r,e,t){const n=e.projectionMatrix,o=r.material.resolution,a=r.matrixWorld,c=r.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,Oo.copy(dn),Do.multiplyMatrices(e.matrixWorldInverse,a);for(let g=0,v=m;g<v;g++){if(Ee.fromBufferAttribute(u,g),$e.fromBufferAttribute(d,g),Ee.w=1,$e.w=1,Ee.applyMatrix4(Do),$e.applyMatrix4(Do),Ee.z>f&&$e.z>f)continue;if(Ee.z>f){const C=Ee.z-$e.z,W=(Ee.z-f)/C;Ee.lerp($e,W)}else if($e.z>f){const C=$e.z-Ee.z,W=($e.z-f)/C;$e.lerp(Ee,W)}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(Oo,!0);qe.at(b,pc);const x=p.MathUtils.lerp(Ee.z,$e.z,b),L=x>=-1&&x<=1,M=Oo.distanceTo(pc)<gi*.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,W=new p.Vector3;pn.distanceSqToSegment(qe.start,qe.end,W,C),t.push({point:W,pointOnLine:C,distance:pn.origin.distanceTo(W),object:r,face:null,faceIndex:g,uv:null,[wo]:null})}}}class sm extends p.Mesh{constructor(e=new hc,t=new gr({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,i=new Float32Array(2*t.count);for(let a=0,c=0,u=t.count;a<u;a++,c+=2)dc.fromBufferAttribute(t,a),fc.fromBufferAttribute(n,a),i[c]=c===0?0:i[c-1],i[c+1]=i[c]+dc.distanceTo(fc);const o=new p.InstancedInterleavedBuffer(i,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,i=e.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 o=e.params.Line2!==void 0&&e.params.Line2.threshold||0;pn=e.ray;const a=this.matrixWorld,c=this.geometry,u=this.material;gi=u.linewidth+o,c.boundingSphere===null&&c.computeBoundingSphere(),os.copy(c.boundingSphere).applyMatrix4(a);let d;if(n)d=gi*.5;else{const f=Math.max(i.near,os.distanceToPoint(pn.origin));d=mc(i,f,u.resolution)}if(os.radius+=d,pn.intersectsSphere(os)===!1)return;c.boundingBox===null&&c.computeBoundingBox(),ss.copy(c.boundingBox).applyMatrix4(a);let m;if(n)m=gi*.5;else{const f=Math.max(i.near,ss.distanceToPoint(pn.origin));m=mc(i,f,u.resolution)}ss.expandByScalar(m),pn.intersectsBox(ss)!==!1&&(n?im(this,t):rm(this,i,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Fo),this.material.uniforms.resolution.value.set(Fo.z,Fo.w))}}class yr extends sm{constructor(e=new rs,t=new gr({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}var Un=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return this.None(r)},Out:function(r){return this.None(r)},InOut:function(r){return this.None(r)}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-Un.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?Un.Bounce.In(r*2)*.5:Un.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),vr=function(){return performance.now()},om=function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=vr()),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 i=0;i<n.length;i++){var o=this._tweens[n[i]],a=!t;o&&o.update(e,a)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},r}(),zo={Linear:function(r,e){var t=r.length-1,n=t*e,i=Math.floor(n),o=zo.Utils.Linear;return e<0?o(r[0],r[1],n):e>1?o(r[t],r[t-1],t-n):o(r[i],r[i+1>t?t:i+1],n-i)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},gc=function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r}(),Xo=new om,as=function(){function r(e,t){t===void 0&&(t=Xo),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=zo.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=gc.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.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},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=vr()),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 i={};for(var o in this._valuesEnd)i[o]=this._valuesEnd[o];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,n,i,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],v=0,w=f.length;v<w;v+=1){var b=this._handleRelativeValue(c,f[v]);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];i[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,i[a],o)}else(typeof t[a]>"u"||o)&&(t[a]=c),u||(t[a]*=1),m?i[a]=n[a].slice().reverse():i[a]=t[a]||0}}},r.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},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=vr()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=vr()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=Xo),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=Un.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=zo.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=vr()),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+((i=this._repeatDelayTime)!==null&&i!==void 0?i: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 v=Math.min(Math.trunc((c-this._duration)/u)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=v);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*v,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},r.prototype._updateProperties=function(e,t,n,i){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,i):typeof c=="object"&&c?this._updateProperties(e[o],a,c,i):(c=this._handleRelativeValue(a,c),typeof c=="number"&&(e[o]=a+(c-a)*i))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.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},r}();gc.nextId;var mn=Xo;mn.getAll.bind(mn),mn.removeAll.bind(mn),mn.add.bind(mn),mn.remove.bind(mn);var am=mn.update.bind(mn);function Uo(r,e,t){if(r==null||r==="")throw new Error(t||`Parameter "${e}" is required but received: ${r}`);return r}function yc(r,e,t){const n=e.split(".");let i=r;for(const o of n){if(i[o]===void 0||i[o]===null)throw new Error(`Property "${e}" is required but missing at path: "${o}"`);i=i[o]}return i}function lm(r,e,t,n=0,i=1){const o=(r-e)*(i-n)/(t-e)+n,a=Math.min(n,i),c=Math.max(n,i);return o<a?a:o>c?c:o||0}var cm=Object.defineProperty,um=(r,e,t)=>e in r?cm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,vc=(r,e,t)=>um(r,typeof e!="symbol"?e+"":e,t);class ko{constructor(){vc(this,"_dispatcher",new p.EventDispatcher),vc(this,"_listenerMap",new Map)}on(e,t){const n=i=>t(i.data||i);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=i=>{this.off(e,n),t(i.data||i)};return this.on(e,n)}off(e,t){const n=this._listenerMap.get(e);if(!n)return this;const i=n.get(t);return i&&(this._dispatcher.removeEventListener(e,i),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 hm(r,e){return r.replace(/\{(\w+)\}/g,(t,n)=>{if(e.hasOwnProperty(n)){const i=e[n];return i!==void 0?String(i):t}throw new Error(`缺少必要参数: ${n}`)})}function Ko(r,...e){for(let t=0;t<e.length;t++){const n=e[t];for(const i in n)r[i]=n[i]}return r}function ls(r){return r==null}function _r(r){return ls(r)?!1:typeof r=="function"||r.constructor!==null&&r.constructor===Function}function _c(r=new Date){const e=r.getFullYear().toString(),t=(r.getMonth()+1).toString().padStart(2,"0"),n=r.getDate().toString().padStart(2,"0"),i=r.getHours().toString().padStart(2,"0"),o=r.getMinutes().toString().padStart(2,"0"),a=r.getSeconds().toString().padStart(2,"0");return`${e}-${t}-${n} ${i}:${o}:${a}`}var dm=Object.defineProperty,fm=(r,e,t)=>e in r?dm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,No=(r,e,t)=>fm(r,typeof e!="symbol"?e+"":e,t);class pm{}class cs extends Kn(yi(pm)){constructor(e){super(),No(this,"target"),No(this,"dom"),No(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 wc=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]"&&!process.versions.electron&&!process.versions.nw&&!process.versions["node-webkit"];let wr={};function bc(){return window.devicePixelRatio||window.screen.deviceXDPI/window.screen.logicalXDPI}if(!wc){const r=navigator.userAgent.toLowerCase(),e=document.documentElement||{style:{}},t="ActiveXObject"in window,n=r.indexOf("webkit")!==-1,i=r.indexOf("phantom")!==-1,o=r.search("android [23]")!==-1,a=r.indexOf("chrome")!==-1,c=r.indexOf("gecko")!==-1&&!n&&!("opera"in window)&&!t,u=/iphone/i.test(r)&&/micromessenger/i.test(r),d=typeof orientation<"u"||r.indexOf("mobile")!==-1,m=!window.PointerEvent&&"MSPointerEvent"in window,f=window.PointerEvent&&navigator.pointerEnabled||m,g=t&&"transition"in e.style,v="WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix&&!o,w="MozPerspective"in e.style,b="OTransition"in e.style,x=(g||v||w)&&!b&&!i,L=typeof window<"u"&&_r(window.createImageBitmap),M=typeof window<"u"&&_r(window.ResizeObserver),C=typeof window<"u"&&_r(window.btoa),W=typeof window<"u"&&_r(window.Proxy),z=typeof window<"u"&&_r(window.requestIdleCallback);let D=0;if(a){const k=r.match(/chrome\/([\d.]+)/);D=k?k[1]:0}const X=!i&&(f||"ontouchstart"in window||"DocumentTouch"in window&&document instanceof window.DocumentTouch),I=typeof window<"u"&&"WebGLRenderingContext"in window,K=bc();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{}wr={IS_NODE:wc,isTest:!1,ie:t,ielt9:t&&!document.addEventListener,edge:"msLaunchUri"in navigator&&!("documentMode"in document),webkit:n,gecko:c,android:r.indexOf("android")!==-1,android23:o,chrome:a,chromeVersion:D,safari:!a&&r.indexOf("safari")!==-1,phantomjs:i,ie3d:g,webkit3d:v,gecko3d:w,opera12:b,any3d:x,iosWeixin:u,mobile:d,mobileWebkit:d&&n,mobileWebkit3d:d&&v,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:W,requestIdleCallback:z,checkDevicePixelRatio:()=>{if(typeof window<"u"&&wr.monitorDPRChange){const k=bc(),j=k!==wr.devicePixelRatio;return j&&(wr.devicePixelRatio=k),j}return!1}}}const mm=wr;var gm=Object.defineProperty,ym=(r,e,t)=>e in r?gm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,kn=(r,e,t)=>ym(r,typeof e!="symbol"?e+"":e,t);function Kn(r){return class extends r{constructor(...e){super(...e),kn(this,"eventClass",new ko),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 ko}}}function yi(r){return class extends r{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 mm.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 i={};return i[t]=n,this.config(i),!0}}),this):this}callInitHooks(){const e=Object.getPrototypeOf(this);return this._visitInitHooks(e),this}setOptions(e){if((!this.hasOwnProperty("options")||ls(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 cs&&(e[n]?this[n].enable():this[n].disable());this.onConfig(e),this._isUpdatingOptions=!1}else{const n={};for(const i in this.options)this.options.hasOwnProperty(i)&&(n[i]=this.options[i]);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 i=0;i<n.length;i++)n[i].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)},i=this.prototype,o=Object.getPrototypeOf(i);return(!i._initHooks||i._initHooks===o._initHooks)&&(i._initHooks=[]),i._initHooks.push(n),this}static include(...e){for(let t=0;t<e.length;t++)Ko(this.prototype,e[t]);return this}}}var vm=Object.defineProperty,_m=(r,e,t)=>e in r?vm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nn=(r,e,t)=>_m(r,typeof e!="symbol"?e+"":e,t);const Bo=`
621
+ varying vec2 vUv;
622
+ void main() {
623
+ vUv = uv;
624
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
625
+ }
626
+ `,wm=`
627
+ varying vec2 vUv;
628
+ uniform float iTime;
629
+ uniform float rainSpeed;
630
+ uniform float rainAngle;
631
+ uniform float rainIntensity;
632
+
633
+ float PI = 3.1415926;
634
+
635
+ float random(in vec2 uv) {
636
+ return fract(sin(dot(uv.xy, vec2(12.9898, 78.233))) * 43758.5453123);
637
+ }
638
+
639
+ float noise(in vec2 uv) {
640
+ vec2 i = floor(uv);
641
+ vec2 f = fract(uv);
642
+ f = f * f * (3.0 - 2.0 * f);
643
+ float lb = random(i + vec2(0.0, 0.0));
644
+ float rb = random(i + vec2(1.0, 0.0));
645
+ float lt = random(i + vec2(0.0, 1.0));
646
+ float rt = random(i + vec2(1.0, 1.0));
647
+ return mix(mix(lb, rb, f.x), mix(lt, rt, f.x), f.y);
648
+ }
649
+
650
+ float rain(vec2 uv) {
651
+ float travelTime = (iTime * 0.2) + 0.1;
652
+ vec2 tiling = vec2(1.0, 0.01);
653
+ // rainIntensity 越大 缩放系数越小 → 噪声格点越稀疏 → 屏幕上的雨纹越少(稀疏大雨)
654
+ // rainIntensity 越小 → 缩放系数越大 → 噪声格点越密 → 屏幕上的雨纹越多(密集小雨)
655
+ float scale = max(rainIntensity, 0.001);
656
+ vec2 offset = vec2(travelTime * 0.5 + uv.x * 0.2, travelTime * 0.2);
657
+ vec2 st = uv * tiling / scale + offset;
658
+ float rain = 0.1;
659
+ float f = fract(noise(st * 200.5) * noise(st * 125.5) * rainSpeed);
660
+ f = clamp(pow(abs(f), 15.0) * 1.5 * (rain * rain * 125.0), 0.0, 0.25 * rainIntensity);
661
+ return f;
662
+ }
663
+
664
+ mat2 rotate2d(float angle) {
665
+ return mat2(cos(angle), -sin(angle), sin(angle), cos(angle));
666
+ }
667
+
668
+ void main() {
669
+ mat2 a = rotate2d(rainAngle * PI);
670
+ float rain = rain(vUv * a);
671
+ if (rain <= 0.0) {
672
+ discard;
673
+ return;
674
+ }
675
+ vec3 col = vec3(1.0);
676
+ gl_FragColor = vec4(col, rain);
677
+ }
678
+ `,bm=`
679
+ varying vec2 vUv;
680
+ uniform float iTime;
681
+ uniform float aspectRatio; // 屏幕宽高比,修正非正方形屏幕上的椭圆问题
682
+
683
+ void main() {
684
+ float snow = 0.0;
685
+ for (int k = 0; k < 6; k++) {
686
+ for (int i = 0; i < 12; i++) {
687
+ float cellSize = 2.0 + (float(i) * 3.0);
688
+ float downSpeed = 0.3 + (sin(iTime * 0.4 + float(k + i * 20)) + 1.0) * 0.00008;
689
+ vec2 uv = vUv + vec2(
690
+ 0.01 * sin((iTime + float(k * 6185)) * 0.6 + float(i)) * (5.0 / float(i)),
691
+ downSpeed * (iTime + float(k * 1352)) * (1.0 / float(i))
692
+ );
693
+ vec2 uvStep = (ceil((uv) * cellSize - vec2(0.5, 0.5)) / cellSize);
694
+ float x = fract(sin(dot(uvStep.xy, vec2(12.9898 + float(k) * 12.0, 78.233 + float(k) * 315.156))) * 43758.5453 + float(k) * 12.0) - 0.5;
695
+ float y = fract(sin(dot(uvStep.xy, vec2(62.2364 + float(k) * 23.0, 94.674 + float(k) * 95.0))) * 62159.8432 + float(k) * 12.0) - 0.5;
696
+ float randomMagnitude = sin(iTime * 2.5 + float(k) * 1.618) * 0.5 / cellSize;
697
+ // 极坐标扰动:只对半径扰动,方向角保持不变,保证正圆
698
+ float angle = atan(y, x);
699
+ float r = length(vec2(x, y));
700
+ float offsetMag = r * randomMagnitude;
701
+ vec2 offset = vec2(cos(angle), sin(angle)) * offsetMag;
702
+ // 将 uv.x 按宽高比缩放,使 distance 计算在正方形空间中进行,保证圆点为正圆
703
+ vec2 uvCorrected = vec2(uv.x * aspectRatio, uv.y);
704
+ vec2 centerCorrected = vec2(uvStep.x * aspectRatio, uvStep.y);
705
+ float d = 5.0 * distance(centerCorrected + offset, uvCorrected);
706
+ float omiVal = fract(sin(dot(uvStep.xy, vec2(32.4691, 94.615))) * 31572.1684);
707
+ if (omiVal < 0.08 ? true : false) {
708
+ float newd = (x + 1.0) * 0.4 * clamp(1.9 - d * (15.0 + (x * 6.3)) * (cellSize / 1.4), 0.0, 1.0);
709
+ snow += newd;
710
+ }
711
+ }
712
+ }
713
+ gl_FragColor = vec4(1.0, 1.0, 1.0, snow);
714
+ }
715
+ `,xm=`
716
+ varying vec2 vUv;
717
+ uniform float iTime;
718
+ uniform float fogSpeed;
719
+ uniform float fogOpacity;
720
+
721
+ float cloudDensity = 1.0;
722
+ float noisiness = 0.35;
723
+ float speed = 0.1;
724
+ float cloudHeight = 0.5;
725
+
726
+ vec3 mod289(vec3 x) {
727
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
728
+ }
729
+
730
+ vec4 mod289(vec4 x) {
731
+ return x - floor(x * (1.0 / 289.0)) * 289.0;
732
+ }
733
+
734
+ vec4 permute(vec4 x) {
735
+ return mod289(((x * 34.0) + 1.0) * x);
736
+ }
737
+
738
+ vec4 taylorInvSqrt(vec4 r) {
739
+ return 1.79284291400159 - 0.85373472095314 * r;
740
+ }
741
+
742
+ float snoise(vec3 v) {
743
+ const vec2 C = vec2(1.0/6.0, 1.0/3.0);
744
+ const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
745
+ vec3 i = floor(v + dot(v, C.yyy));
746
+ vec3 x0 = v - i + dot(i, C.xxx);
747
+ vec3 g = step(x0.yzx, x0.xyz);
748
+ vec3 l = 1.0 - g;
749
+ vec3 i1 = min(g.xyz, l.zxy);
750
+ vec3 i2 = max(g.xyz, l.zxy);
751
+ vec3 x1 = x0 - i1 + C.xxx;
752
+ vec3 x2 = x0 - i2 + C.yyy;
753
+ vec3 x3 = x0 - D.yyy;
754
+ i = mod289(i);
755
+ vec4 p = permute(permute(permute(
756
+ i.z + vec4(0.0, i1.z, i2.z, 1.0)) +
757
+ i.y + vec4(0.0, i1.y, i2.y, 1.0)) +
758
+ i.x + vec4(0.0, i1.x, i2.x, 1.0));
759
+ float n_ = 0.142857142857;
760
+ vec3 ns = n_ * D.wyz - D.xzx;
761
+ vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
762
+ vec4 x_ = floor(j * ns.z);
763
+ vec4 y_ = floor(j - 7.0 * x_);
764
+ vec4 x = x_ * ns.x + ns.yyyy;
765
+ vec4 y = y_ * ns.x + ns.yyyy;
766
+ vec4 h = 1.0 - abs(x) - abs(y);
767
+ vec4 b0 = vec4(x.xy, y.xy);
768
+ vec4 b1 = vec4(x.zw, y.zw);
769
+ vec4 s0 = floor(b0) * 2.0 + 1.0;
770
+ vec4 s1 = floor(b1) * 2.0 + 1.0;
771
+ vec4 sh = -step(h, vec4(0.0));
772
+ vec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
773
+ vec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
774
+ vec3 p0 = vec3(a0.xy, h.x);
775
+ vec3 p1 = vec3(a0.zw, h.y);
776
+ vec3 p2 = vec3(a1.xy, h.z);
777
+ vec3 p3 = vec3(a1.zw, h.w);
778
+ vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2,p2), dot(p3,p3)));
779
+ p0 *= norm.x; p1 *= norm.y; p2 *= norm.z; p3 *= norm.w;
780
+ vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
781
+ m = m * m;
782
+ return 42.0 * dot(m*m, vec4(dot(p0,x0), dot(p1,x1), dot(p2,x2), dot(p3,x3)));
783
+ }
784
+
785
+ const float maximum = 1.0/1.0 + 1.0/2.0 + 1.0/3.0 + 1.0/4.0 + 1.0/5.0 + 1.0/6.0 + 1.0/7.0 + 1.0/8.0;
786
+
787
+ float fBm(vec3 uv) {
788
+ float sum = 0.0;
789
+ for (int i = 0; i < 8; ++i) {
790
+ float f = float(i+1);
791
+ sum += snoise(uv * f) / f;
792
+ }
793
+ return sum / maximum;
794
+ }
795
+
796
+ float gradient(vec2 uv) {
797
+ return (1.0 - uv.y * uv.y * cloudHeight);
798
+ }
799
+
800
+ void main() {
801
+ vec2 uv = vUv;
802
+ vec3 p = vec3(uv, iTime * speed);
803
+ vec3 offset = vec3(
804
+ sin(iTime * fogSpeed * 3.0),
805
+ sin(iTime * fogSpeed),
806
+ sin(iTime * fogSpeed * 2.0)
807
+ );
808
+ vec2 duv = vec2(fBm(p), fBm(p + offset)) * noisiness;
809
+ float q = gradient(uv + duv) * cloudDensity;
810
+ if (q <= 0.0) {
811
+ discard;
812
+ return;
813
+ }
814
+ gl_FragColor = vec4(vec3(1.0), q * fogOpacity);
815
+ }
816
+ `;class xc{constructor(e,t,n={}){Nn(this,"scene"),Nn(this,"camera"),Nn(this,"mesh"),Nn(this,"rainMaterial"),Nn(this,"snowMaterial"),Nn(this,"fogMaterial"),Nn(this,"_type",null),Nn(this,"_activeMaterial",null),this.scene=new p.Scene,this.scene.autoClear=!1;const i=e/2,o=t/2;this.camera=new p.OrthographicCamera(-i,i,o,-o,.1,10),this.camera.position.z=5;const a=new p.PlaneGeometry(e,t);this.mesh=new p.Mesh(a),this.mesh.position.z=1,this.scene.add(this.mesh),this.rainMaterial=new p.ShaderMaterial({vertexShader:Bo,fragmentShader:wm,transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{iTime:{value:0},rainSpeed:{value:n.speed??3},rainAngle:{value:n.rainAngle??-.1},rainIntensity:{value:n.rainIntensity??1}}}),this.snowMaterial=new p.ShaderMaterial({vertexShader:Bo,fragmentShader:bm,transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{iTime:{value:0},aspectRatio:{value:e/t}}}),this.fogMaterial=new p.ShaderMaterial({vertexShader:Bo,fragmentShader:xm,transparent:!0,depthTest:!1,depthWrite:!1,uniforms:{iTime:{value:0},fogSpeed:{value:n.speed??1},fogOpacity:{value:n.opacity??1}}}),n.type&&this.setWeather(n.type),n.speed!==void 0&&this.setSpeed(n.speed),n.opacity!==void 0&&this.setOpacity(n.opacity),n.rainIntensity!==void 0&&this.setRainIntensity(n.rainIntensity)}get type(){return this._type}setWeather(e){if(this._type=e,e===null)return this._activeMaterial=null,this.mesh.material=null,this;switch(e){case"rain":this._activeMaterial=this.rainMaterial;break;case"snow":this._activeMaterial=this.snowMaterial;break;case"fog":this._activeMaterial=this.fogMaterial;break}return this.mesh.material=this._activeMaterial,this}setSpeed(e){return this.rainMaterial.uniforms.rainSpeed&&(this.rainMaterial.uniforms.rainSpeed.value=e),this.fogMaterial.uniforms.fogSpeed&&(this.fogMaterial.uniforms.fogSpeed.value=e),this}setOpacity(e){return this.fogMaterial.uniforms.fogOpacity&&(this.fogMaterial.uniforms.fogOpacity.value=e),this}setRainAngle(e){return this.rainMaterial.uniforms.rainAngle&&(this.rainMaterial.uniforms.rainAngle.value=e),this}setRainIntensity(e){return this.rainMaterial.uniforms.rainIntensity&&(this.rainMaterial.uniforms.rainIntensity.value=e),this}update(e){if(!this._activeMaterial)return;const t=this._activeMaterial.uniforms.iTime.value+e;this._activeMaterial.uniforms.iTime.value=t}resize(e,t){const n=e/2,i=t/2;this.camera.left=-n,this.camera.right=n,this.camera.top=i,this.camera.bottom=-i,this.camera.updateProjectionMatrix(),this.snowMaterial.uniforms.aspectRatio&&(this.snowMaterial.uniforms.aspectRatio.value=e/t),this.mesh.geometry.dispose(),this.mesh.geometry=new p.PlaneGeometry(e,t)}dispose(){this.rainMaterial.dispose(),this.snowMaterial.dispose(),this.fogMaterial.dispose(),this.mesh.geometry.dispose()}}var Mm=Object.defineProperty,Sm=(r,e,t)=>e in r?Mm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ve=(r,e,t)=>Sm(r,typeof e!="symbol"?e+"":e,t);const Lm=Kn(yi(p.EventDispatcher));class Mc extends Lm{constructor(e,t={}){super(),Ve(this,"scene"),Ve(this,"renderer"),Ve(this,"camera"),Ve(this,"controls"),Ve(this,"ambLight"),Ve(this,"dirLight"),Ve(this,"auxDirLight"),Ve(this,"clouds",null),Ve(this,"container"),Ve(this,"_clock",new p.Clock),Ve(this,"stats"),Ve(this,"_animationCallbacks",new Set),Ve(this,"_fogFactor",1),Ve(this,"_sceneSize",5e4*2),Ve(this,"_weatherEffect",null),Ve(this,"gorund"),Ve(this,"map"),Ve(this,"centerPostion"),Ve(this,"_isInteracting",!1),Ve(this,"debug",!1),Ve(this,"flyTween",null),Ve(this,"composer"),Ve(this,"renderPass"),Ve(this,"bloomPass"),Ve(this,"calculateCameraPosition",(g,v,w,b)=>{const x=new p.Vector3(0,v*Math.cos(w),v*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:i=!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,i,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(),v=this.container?this.width:window.innerWidth,w=this.container?this.height:window.innerHeight,b=v*g,x=w*g,L=new p.WebGLRenderTarget(b,x,{format:p.RGBAFormat});L.samples=4,this.composer=new Qf(this.renderer,L),this.renderPass=new $f(this.scene,this.camera),this.composer.addPass(this.renderPass);const M=u?.strength??1.5,C=u?.radius??1,W=u?.threshold??.7;this.bloomPass=new Nf(new p.Vector2(b,x),M,C,W),this.composer.addPass(this.bloomPass)}this.renderer.setAnimationLoop(this.animate.bind(this)),this._initWeather(),this.debug=t.debug||!1,this.flyTween=null,this.debug&&(this.stats=new hr,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 i=new p.CubeTextureLoader;e.path&&i.setPath(e.path),i.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 i=await new em().setPath(t.path||"").setDataType(p.FloatType).loadAsync(t.hdr);i.colorSpace=this.renderer.outputColorSpace,i.mapping=303,i.needsUpdate=!0,e.background=i,e.environment=i}}catch(n){console.error("加载HDR失败:",n),e.background=new p.Color(t?.defaultColor||14414079)}}_createRenderer(e,t,n){const i=new p.WebGLRenderer({antialias:e,logarithmicDepthBuffer:n,stencil:t,alpha:!0,precision:"highp",powerPreference:"high-performance",failIfMajorPerformanceCaveat:!0});return i.debug.checkShaderErrors=!0,i.sortObjects=!0,i.setPixelRatio(window.devicePixelRatio),i.domElement.tabIndex=0,i.shadowMap.enabled=!0,i.shadowMap.needsUpdate=!0,i.shadowMap.type=p.PCFSoftShadowMap,i.toneMapping=p.ACESFilmicToneMapping,i.toneMappingExposure=1,i.outputColorSpace=p.SRGBColorSpace,i.autoClear=!1,i}_createCamera(){return new p.PerspectiveCamera(45,this.getAspect(),.1,this._sceneSize*2)}_createControls(e,t){const n=new Ff(this.camera,this.renderer.domElement),i=Math.PI/2.1;return n.screenSpacePanning=!1,n.minDistance=e??.1,n.maxDistance=t??6e4,n.maxPolarAngle=i,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=lm(n.getDistance(),0,7e4,i,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 v=new p.CameraHelper(f.shadow.camera);v.name="dirLightCameraHelper",this.scene.add(v)}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,i){const o=new p.DirectionalLight(16777215,i);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._weatherEffect&&this._weatherEffect.resize(e,t),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.renderer.clear(),this.composer?this.composer.render():this.renderer.render(this.scene,this.camera),this._weatherEffect?.type&&(this._weatherEffect.update(e),this.renderer.render(this._weatherEffect.scene,this._weatherEffect.camera)),am(),this.stats&&this.stats.update(),this.dispatchEvent({type:"update",delta:e})}flyTo(e,t,n=!0,i){if(this.controls.target.copy(e),n){const o=this.camera.position;new as(o).to({y:2e7,z:0},500).chain(new as(o).to(t,2e3).easing(Un.Quintic.Out).onComplete(a=>i&&i(a))).start()}else this.camera.position.copy(t)}flyToAdvanced(e){const t=this.camera,n=this.controls,i=e.center,o=e.cameraCoord,a=e.duration??2e3,c=e.delay??0,u=e.complete,d=!!e.curvePath;if(!i||!o)return;const m=this.map.geo2world(new p.Vector3(i[0],i[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(),v=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=[v,v.clone().lerp(b,.33),v.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 as(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),W=new p.Vector3(M.x,M.y,M.z);t.position.copy(C),t.lookAt(W),t.updateProjectionMatrix(),n.target.copy(W),n.update()})}else{const x={tx:g.x,ty:g.y,tz:g.z,px:v.x,py:v.y,pz:v.z};this.flyTween=new as(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,i=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),v=this.map.world2geo(g);this.flyToAdvanced({center:[n[0],n[1],0],cameraCoord:[v.x,v.y,v.z||0],duration:i,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),i=new p.Mesh(n,t);return i.name="地面",i.castShadow=!1,i.receiveShadow=!1,i.position.y=0,i.position.add(e),i.rotateX(-Math.PI/2),i.visible=!1,i}_initWeather(){const e=this.width,t=this.height;this._weatherEffect=new xc(e,t);const n=this.options;if(n.weather){const i=n.weather;i.type&&this._weatherEffect.setWeather(i.type),i.speed!==void 0&&this._weatherEffect.setSpeed(i.speed),i.opacity!==void 0&&this._weatherEffect.setOpacity(i.opacity),i.rainAngle!==void 0&&this._weatherEffect.setRainAngle(i.rainAngle),i.rainIntensity!==void 0&&this._weatherEffect.setRainIntensity(i.rainIntensity)}}setWeather(e,t={}){return this._weatherEffect?(this._weatherEffect.setWeather(e),t.speed!==void 0&&this._weatherEffect.setSpeed(t.speed),t.opacity!==void 0&&this._weatherEffect.setOpacity(t.opacity),t.rainAngle!==void 0&&this._weatherEffect.setRainAngle(t.rainAngle),t.rainIntensity!==void 0&&this._weatherEffect.setRainIntensity(t.rainIntensity),this):this}getWeatherEffect(){return this._weatherEffect}setWeatherSpeed(e){return this._weatherEffect?.setSpeed(e),this}setWeatherOpacity(e){return this._weatherEffect?.setOpacity(e),this}setWeatherRainAngle(e){return this._weatherEffect?.setRainAngle(e),this}setWeatherRainIntensity(e){return this._weatherEffect?.setRainIntensity(e),this}destroy(){try{this.renderer.setAnimationLoop(null),this._animationCallbacks.clear(),this._weatherEffect&&(this._weatherEffect.dispose(),this._weatherEffect=null),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 br=(r=>(r[r.none=0]="none",r[r.create=1]="create",r[r.remove=2]="remove",r))(br||{});function Pm(r,e){const t=r.position.clone().setZ(r.maxZ).applyMatrix4(r.matrixWorld);return e.distanceTo(t)}function Cm(r){const e=r.scale,t=new p.Vector3(-e.x,-e.y,0).applyMatrix4(r.matrixWorld),n=new p.Vector3(e.x,e.y,0).applyMatrix4(r.matrixWorld);return t.sub(n).length()}function Tm(r){return r.distToCamera/r.sizeInWorld*.8}function Gm(r,e,t,n){const i=Tm(r);if(r.isLeaf){if(r.inFrustum&&r.z<t&&(r.z<e||r.showing)&&(r.z<e||i<n))return 1}else if(r.z>=e&&(r.z>t||i>n))return 2;return 0}function Wm(r,e,t,n){const i=[],o=n+1,a=e*2,c=0,u=.25;{const d=t*2,m=new p.Vector3(.5,.5,1),f=new Bn(a,d,o),g=new Bn(a+1,d,o),v=new Bn(a,d+1,o),w=new Bn(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),v.position.set(-u,-u,c),v.scale.copy(m),w.position.set(u,-u,c),w.scale.copy(m),i.push(f,g,v,w)}return i}var Zm=Object.defineProperty,Vm=(r,e,t)=>e in r?Zm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,et=(r,e,t)=>Vm(r,typeof e!="symbol"?e+"":e,t);const Im=10,Am=new p.InstancedBufferGeometry,Fm=new p.Vector3,Om=new p.Matrix4,Dm=new p.Box3(new p.Vector3(-.5,-.5,0),new p.Vector3(.5,.5,1)),Sc=new p.Frustum,Lc=class $r extends p.Mesh{constructor(e=0,t=0,n=0){super(Am,[]),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 $r._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($r.downloadThreads>Im)return{action:br.none};let t=[];const{loader:n,minLevel:i,maxLevel:o,LODThreshold:a}=e,c=Gm(this,i,o,a);return c===br.create&&(t=Wm(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(i=>i.isTile),n=t.every(i=>i.loaded);e.showing=!n,t.forEach(i=>i.showing=n)}return this}async _load(e){$r._downloadThreads++;const{x:t,y:n,z:i}=this;if(this._dataOnlyMode)try{const o=await e.load({x:t,y:n,z:i,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(`数据模式加载失败 ${i}/${t}/${n}:`,o),this._loaded=!1}else{const o=await e.load({x:t,y:n,z:i,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 $r._downloadThreads--,this}_init(){this.updateMatrix(),this.updateMatrixWorld(),this.sizeInWorld=Cm(this)}update(e){if(console.assert(this.z===0),!this.parent)return this;Sc.setFromProjectionMatrix(Om.multiplyMatrices(e.camera.projectionMatrix,e.camera.matrixWorldInverse));const t=e.camera.getWorldPosition(Fm);return this.traverse(n=>{n.receiveShadow=this.receiveShadow,n.castShadow=this.castShadow;const i=Dm.clone().applyMatrix4(n.matrixWorld);i.max.setY(9e3),n.inFrustum=Sc.intersectsBox(i),n.distToCamera=Pm(n,t);const{action:o,newTiles:a}=n.LOD(e);this._doAction(n,o,a,e)}),this._checkReady(),this}_doAction(e,t,n,i){return t===br.create?n?.forEach(o=>{o._init(),o._isDummy=o.z<i.minLevel,this.dispatchEvent({type:"tile-created",tile:o}),o.isDummy||o._load(i.loader).then(()=>{o._checkVisible(),this.dispatchEvent({type:"tile-loaded",tile:o})})}):t===br.remove&&(e.showing=!0,e._unLoad(!1,i.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(Lc,"_downloadThreads",0);let Bn=Lc;var zm=Object.defineProperty,Xm=(r,e,t)=>e in r?zm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Um=(r,e,t)=>Xm(r,e+"",t);class Pc{constructor(e=0){Um(this,"_lon0",0),this._lon0=e}get lon0(){return this._lon0}getTileXWithCenterLon(e,t){const n=Math.pow(2,t);let i=e+Math.round(n/360*this._lon0);return i>=n?i-=n:i<0&&(i+=n),i}getTileXYZproj(e,t,n){const i=this.mapWidth,o=this.mapHeight/2,a=e/Math.pow(2,n)*i-i/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]),i=this.project(e[2]+(t?this._lon0:0),e[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(e,t,n){const i=this.getTileXYZproj(e,t,n),o=this.getTileXYZproj(e+1,t+1,n);return[Math.min(i.x,o.x),Math.min(i.y,o.y),Math.max(i.x,o.x),Math.max(i.y,o.y)]}getLonLatBoundsFromXYZ(e,t,n){const i=this.getProjBoundsFromXYZ(e,t,n),o=this.unProject(i[0],i[1]),a=this.unProject(i[2],i[3]);return[o.lon,o.lat,a.lon,a.lat]}}var km=Object.defineProperty,Km=(r,e,t)=>e in r?km(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,us=(r,e,t)=>Km(r,typeof e!="symbol"?e+"":e,t);const xr=6378e3;class Cc extends Pc{constructor(){super(...arguments),us(this,"ID","3857"),us(this,"mapWidth",2*Math.PI*xr),us(this,"mapHeight",this.mapWidth),us(this,"mapDepth",1)}project(e,t){const n=(e-this.lon0)*(Math.PI/180),i=t*(Math.PI/180),o=xr*n,a=xr*Math.log(Math.tan(Math.PI/4+i/2));return{x:o,y:a}}unProject(e,t){let n=e/xr*(180/Math.PI)+this.lon0;return n>180&&(n-=360),{lat:(2*Math.atan(Math.exp(t/xr))-Math.PI/2)*(180/Math.PI),lon:n}}}var Nm=Object.defineProperty,Bm=(r,e,t)=>e in r?Nm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,hs=(r,e,t)=>Bm(r,typeof e!="symbol"?e+"":e,t);class Ym extends Pc{constructor(){super(...arguments),hs(this,"ID","4326"),hs(this,"mapWidth",36e3),hs(this,"mapHeight",18e3),hs(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 Rm={createFromID:(r="3857",e)=>{let t;switch(r){case"3857":t=new Cc(e);break;case"4326":t=new Ym(e);break;default:throw new Error(`Projection ID: ${r} is not supported.`)}return t}};function Yo(r,e){const t=r.getLayers().find(i=>i.isBaseLayer===!0)?._rootTile,n=e.intersectObjects([t]);for(const i of n)if(i.object instanceof Bn){const o=r.worldToLocal(i.point.clone()),a=r.map2geo(o);return Object.assign(i,{location:a})}}function Ro(r,e){const t=new p.Vector3(0,-1,0),n=new p.Vector3(e.x,10*1e3,e.z),i=new p.Raycaster(n,t);return Yo(r,i)}function Tc(r,e,t){const n=new p.Raycaster;return n.setFromCamera(t,r),Yo(e,n)}function jm(r,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 i=e/2,o=e/2;return n.imageSmoothingEnabled=!1,n.fillStyle="#000022",n.strokeStyle="DarkGoldenrod",n.lineWidth=5,n.moveTo(i,3),n.lineTo(i,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(r,i,20),n.fillText(r,i,20),t}function Jm(r,e=128){const t=new p.CanvasTexture(jm(r,e)),n=new p.SpriteMaterial({map:t,sizeAttenuation:!1}),i=new p.Sprite(n);return i.visible=!1,i.center.set(.5,.3),i.scale.setScalar(.11),i.renderOrder=999,i}var Qm=Object.defineProperty,Hm=(r,e,t)=>e in r?Qm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gn=(r,e,t)=>Hm(r,typeof e!="symbol"?e+"":e,t);class ds 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 Cc(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 ds(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 Ro(this,t)}getLocalInfoFromWorld(e){return Ro(this,e)}getLocalInfoFromScreen(e,t){return Tc(e,this,t)}get downloading(){return Bn.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(i=>i.isBaseLayer===!0);return!t||!t._rootTile||t._rootTile.traverseVisible(i=>{i.showing&&i.inFrustum&&(e=Math.max(e,i.z))}),e}getDataZoom(){let e=this.minLevel;const t=this.getLayers().find(i=>i.isBaseLayer===!0);return!t||!t._rootTile||t._rootTile.traverseVisible(i=>{i.showing&&i.inFrustum&&(e=Math.max(e,i.z))}),e}}var Em=Object.defineProperty,$m=(r,e,t)=>e in r?Em(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qm=(r,e,t)=>$m(r,e+"",t);function jo(r){return class extends r{constructor(...t){super(...t),qm(this,"_handlers"),this._handlers=[]}addHandler(t,n){if(!n)return this;if(this._handlers||(this._handlers=[]),this[t])return this[t].enable(),this;const i=this[t]=new n(this);return this._handlers.push(i),this.options[t]&&i.enable(),this}removeHandler(t){if(!t)return this;const n=this[t];if(n&&this._handlers){const i=this._handlers.indexOf(n);i>=0&&this._handlers.splice(i,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 eg=Object.defineProperty,tg=(r,e,t)=>e in r?eg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,vi=(r,e,t)=>tg(r,typeof e!="symbol"?e+"":e,t);const ng={attribution:"",visible:!0,opacity:1,zIndex:0,isSceneLayer:!1,altitude:0};class fs extends jo(Kn(yi(p.Group))){constructor(e,t){super(),vi(this,"_id"),vi(this,"opacity",1),vi(this,"_animationCallbacks",new Set),vi(this,"isSceneLayer",!1),vi(this,"_altitude",0),vi(this,"depthOffset"),vi(this,"_regionOverlays",[]),Uo(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(i=>{"opacity"in i&&(i.transparent=e<1,i.opacity=e,i.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,i,o)=>{this.animate?.(n,i,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)}`}}fs.mergeOptions(ng);var ig=Object.defineProperty,rg=(r,e,t)=>e in r?ig(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Mr=(r,e,t)=>rg(r,typeof e!="symbol"?e+"":e,t);const Gc=class lf{constructor(e){Mr(this,"_cache",new Map),Mr(this,"_gltfLoader"),Mr(this,"_fbxLoader"),Mr(this,"_dracoLoader"),this._gltfLoader=new ep(e),this._fbxLoader=new Kp(e)}static init(e){return this._instance||(this._instance=new lf(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,i;try{if(e.type==="gltf"){const o=await this._gltfLoader.loadAsync(e.url);n=o.scene,i=o.animations}else n=await this._fbxLoader.loadAsync(e.url),i=n.animations;return this._cache.set(t,{model:n,animations:i}),{model:this._processModel(n.clone(),e),animations:i?.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 tm,this._dracoLoader.setDecoderPath(e),this._gltfLoader.setDRACOLoader(this._dracoLoader))}_cloneCachedModel(e,t){const n=this._cache.get(e),i=n.model.clone();return{model:this._processModel(i,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 i=t.materialOverrides[n.name];i&&(n.material=i)}}),e.traverse(n=>{n instanceof p.Mesh&&n.material}),e}clearCache(){this._cache.clear()}static clearCache(){this._instance&&this._instance.clearCache()}};Mr(Gc,"_instance");let Wc=Gc;const Jo=(r,e)=>{"updateRanges"in r?r.updateRanges[0]=e:r.updateRange=e},Zc=new p.Matrix4,ps=new p.Vector3,ms=new p.Quaternion,Vc=new p.Vector3,Ic=new p.Quaternion,Sr=new p.Vector3,sg=r=>class extends r{constructor(){super();const e=parseInt(p.REVISION.replace(/\D+/g,""))>=154?"opaque_fragment":"output_fragment";this.onBeforeCompile=t=>{t.vertexShader=`attribute float cloudOpacity;
566
817
  varying float vOpacity;
567
- `+e.vertexShader.replace("#include <fog_vertex>",`#include <fog_vertex>
818
+ `+t.vertexShader.replace("#include <fog_vertex>",`#include <fog_vertex>
568
819
  vOpacity = cloudOpacity;
569
- `),e.fragmentShader=`varying float vOpacity;
570
- `+e.fragmentShader.replace(`#include <${t}>`,`#include <${t}>
820
+ `),t.fragmentShader=`varying float vOpacity;
821
+ `+t.fragmentShader.replace(`#include <${e}>`,`#include <${e}>
571
822
  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:`
823
+ `)}}};class og extends p.Group{constructor({limit:e=200,range:t,material:n=p.MeshLambertMaterial,texture:i,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=sg(n),g=new f;g.map=i,g.transparent=!0,g.depthWrite=!1,g.needsUpdate=!0,this.cloudMaterial=g,this.instance=new p.InstancedMesh(c,g,e);const v=this.instance;v.matrixAutoUpdate=!1,v.frustumCulled=o,v.instanceColor=new p.InstancedBufferAttribute(d,3),v.instanceColor.setUsage(p.DynamicDrawUsage),a.add(v);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);v.count=X,Jo(v.instanceMatrix,{offset:0,count:X*16}),v.instanceColor&&Jo(v.instanceColor,{offset:0,count:X*3}),Jo(v.geometry.attributes.cloudOpacity,{offset:0,count:X})};let L=0,M=0,C;const W=new p.Quaternion,z=new p.Vector3(0,0,1),D=new p.Vector3;this.update=(X,I,K)=>{L=I,Zc.copy(v.matrixWorld).invert(),X.matrixWorld.decompose(Vc,Ic,Sr);const V=b();for(M=0;M<V.length;M++)C=V[M],C.ref.matrixWorld.decompose(ps,ms,Sr),ps.add(D.copy(C.position).applyQuaternion(ms).multiply(Sr)),ms.copy(Ic).multiply(W.setFromAxisAngle(z,C.rotation+=K*C.rotationFactor)),Sr.multiplyScalar(C.volume+(1+Math.sin(L*C.density*C.speed))/2*C.growth),C.matrix.compose(ps,ms,Sr).premultiply(Zc),C.dist=ps.distanceTo(Vc);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),v.setMatrixAt(M,C.matrix),v.setColorAt(M,C.color);v.geometry.attributes.cloudOpacity.needsUpdate=!0,v.instanceMatrix.needsUpdate=!0,v.instanceColor&&(v.instanceColor.needsUpdate=!0)}}}let ag=0;class lg extends p.Group{constructor({opacity:e=1,speed:t=0,bounds:n=new p.Vector3().fromArray([5,1,1]),segments:i=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_"+ag++,this.seed=g,this.segments=i,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:i,opacity:o,fade:a,bounds:c,seed:u,cloudStateArray:d,distribute:m,segments:f,concentrate:g,smallestVolume:v}=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=i,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 W=Math.abs(x.position.x),z=Math.abs(x.position.y),D=Math.abs(x.position.z),X=Math.max(W,z,D);x.length=1,W===X&&(x.length-=W/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,v),g==="random"?b():g==="inside"?x.length:1-x.length))*e})}}class Qo{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:i,msg:o,transfer:a}=this.queue.shift();this.workersResolve[e]=i,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 i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].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 Ac(r,e){const t=new p.BufferGeometry;t.setAttribute("position",new p.BufferAttribute(new Float32Array([0,0,0]),3));const n=r.sizeAttenuation??!0,i=n?r.size*.002:r.size,o=new p.PointsMaterial({size:i,color:r.color||16777215,sizeAttenuation:n,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!0});o.onBeforeCompile=c=>{c.fragmentShader=c.fragmentShader.replace("#include <clipping_planes_fragment>",`
824
+ #include <clipping_planes_fragment>
825
+ vec2 coord = gl_PointCoord - vec2(0.5);
826
+ if(length(coord) > 0.5) discard;
827
+ `)};const a=new p.Points(t,o);return a.position.copy(e),a}async function cg(r,e){let t=null;try{t=await xt._loadTexture(r.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:",r.url,d)}const n=new p.SpriteMaterial({map:t??null,color:r.color||16777215,transparent:r.transparent??!0,opacity:r.opacity??1,sizeAttenuation:r.sizeAttenuation??!0,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!0,premultipliedAlpha:!1,blending:p.NormalBlending}),i=new p.Sprite(n),o=.002,a=r.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 i.scale.set(c*o,u*o,1),r.rotation&&(i.rotation.z=r.rotation),r.anchor&&i.center.set(r.anchor[0],r.anchor[1]),i.position.copy(e),i}function Ho(r,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 i=new gr({color:new p.Color(r.color??16777215).getHex(),linewidth:r.width??2,transparent:r.transparent??!0,opacity:r.opacity??1,dashed:!!r.dashArray,dashScale:r.dashArray?.[0]??1,dashSize:r.dashArray?.[0]??1,gapSize:r.dashArray?.[1]??0,resolution:new p.Vector2(window.innerWidth,window.innerHeight),alphaToCoverage:!0,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!0});return window.addEventListener("resize",()=>{i.resolution.set(window.innerWidth,window.innerHeight)}),new yr(n,i)}function Fc(r,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,i=r.cornerRadius||5;if(t.length===2||i<=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],W=new p.Vector3().subVectors(M,L),z=new p.Vector3().subVectors(C,M),D=W.length(),X=z.length(),I=Math.min(D,X)*.4,K=Math.min(i,I);W.normalize().multiplyScalar(D-K),z.normalize().multiplyScalar(K);const V=new p.Vector3().addVectors(L,W),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=r.radius||2,a=r.radialSegments||8,c=r.tubularSegments||64,u=new p.TubeGeometry(n,c,o,a,!1),d=5,m=new p.MeshPhongMaterial({color:r.color||"#19bbd5",side:p.DoubleSide,emissive:new p.Color(r.color||"#19bbd5"),emissiveIntensity:.6*d,transparent:!0});m.defines={USE_UV:""};const g={totalLength:{value:n.getLength()},stripeOffset:{value:0},stripeWidth:{value:r.stripeWidth||10},stripeSpacing:{value:r.stripeSpacing||20},stripeColor:{value:new p.Color(r.stripeColor||"#096be3")},speedFactor:{value:r.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=`
828
+ uniform float totalLength;
829
+ uniform float stripeOffset;
830
+ uniform float stripeWidth;
831
+ uniform float stripeSpacing;
832
+ uniform vec3 stripeColor;
833
+ uniform float bloomBoost;
834
+ ${b.fragmentShader}
835
+ `.replace("#include <color_fragment>",`#include <color_fragment>
836
+ // 计算条纹模式(用于漫反射)
837
+ float pattern = mod((vUv.x - stripeOffset) * totalLength / (stripeWidth + stripeSpacing), 1.0);
838
+ float isStripe = step(pattern, stripeWidth / (stripeWidth + stripeSpacing));
839
+
840
+ // 混合条纹颜色
841
+ diffuseColor.rgb = mix(diffuseColor.rgb, stripeColor, isStripe);
842
+
843
+ // 条纹区域再额外提亮,让 bloom 更明显
844
+ if (isStripe > 0.5) {
845
+ diffuseColor.rgb += stripeColor * (3.0 * bloomBoost);
846
+ }
847
+ `).replace("#include <emissivemap_fragment>",`#include <emissivemap_fragment>
848
+ // 计算条纹模式(用于自发光)
849
+ float pattern_e = mod((vUv.x - stripeOffset) * totalLength / (stripeWidth + stripeSpacing), 1.0);
850
+ float isStripe_e = step(pattern_e, stripeWidth / (stripeWidth + stripeSpacing));
851
+
852
+ // 自发光通道也叠加一遍,进一步抬高亮度
853
+ totalEmissiveRadiance += stripeColor * isStripe_e * (3.0 * bloomBoost);
854
+ `)};const v=new p.Mesh(u,m);let w=0;return v.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},v}function Oc(r,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,i=r.cornerRadius||5;if(t.length===2||i<=0)for(let C=0;C<t.length-1;C++){const W=new p.LineCurve3(t[C],t[C+1]);n.curves.push(W)}else{let C=t[0];for(let W=1;W<t.length-1;W++){const z=C,D=t[W],X=t[W+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(i,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=r.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 W=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(W.x+D.x*X,W.y,W.z+D.z*X),K=new p.Vector3(W.x-D.x*X,W.y,W.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 v=new p.BufferGeometry;v.setAttribute("position",new p.BufferAttribute(new Float32Array(u),3)),v.setAttribute("uv",new p.BufferAttribute(new Float32Array(d),2)),v.setIndex(m),v.computeVertexNormals();const w=5,b=new p.MeshPhongMaterial({color:r.color||"#0ED5FD",side:p.DoubleSide,emissive:new p.Color(r.color||"#0ED5FD"),emissiveIntensity:5,transparent:!0});b.defines={USE_UV:""};const x={totalLength:{value:g},stripeOffset:{value:0},arrowLength:{value:r.arrowLength||20},arrowSpacing:{value:r.arrowSpacing||80},arrowColor:{value:new p.Color(r.color||"#0ED5FD")},speedFactor:{value:r.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;
855
+ uniform float totalLength;
856
+ uniform float stripeOffset;
857
+ uniform float arrowLength;
858
+ uniform float arrowSpacing;
859
+ uniform vec3 arrowColor;
860
+ uniform float bloomBoost;`),C.fragmentShader=C.fragmentShader.replace("#include <color_fragment>",`#include <color_fragment>
861
+ {
862
+ float tpat = arrowLength + arrowSpacing;
863
+ float posi = mod((vUv.x - stripeOffset) * totalLength, tpat);
864
+ float inArrow = step(posi, arrowLength);
865
+ float npos = posi / arrowLength;
866
+
867
+ float centerDist = abs(vUv.y - 0.5);
868
+
869
+ float h0 = step(npos, 0.5);
870
+ float headWidth = mix(0.0, 1.5, npos / 0.5);
871
+ float shaftWidth = 0.6;
872
+ float arrowWidth = mix(shaftWidth, headWidth, h0);
873
+ float arrowShape = step(centerDist, arrowWidth * 0.5);
874
+
875
+ float mask = inArrow * arrowShape;
876
+ mask = clamp(mask, 0.0, 1.0);
877
+
878
+ diffuseColor.rgb = arrowColor;
879
+ diffuseColor.a = mask;
880
+ }`),C.fragmentShader=C.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissivemap_fragment>
881
+ {
882
+ float tpat2 = arrowLength + arrowSpacing;
883
+ float posi2 = mod((vUv.x - stripeOffset) * totalLength, tpat2);
884
+ float inArrow2 = step(posi2, arrowLength);
885
+ float npos2 = posi2 / arrowLength;
886
+
887
+ float centerDist2 = abs(vUv.y - 0.5);
888
+
889
+ float h02 = step(npos2, 0.5);
890
+ float headWidth2 = mix(0.0, 1.5, npos2 / 0.5);
891
+ float shaftWidth2 = 0.6;
892
+ float arrowWidth2 = mix(shaftWidth2, headWidth2, h02);
893
+ float arrowShape2 = step(centerDist2, arrowWidth2 * 0.5);
894
+
895
+ float mask2 = inArrow2 * arrowShape2;
896
+ mask2 = clamp(mask2, 0.0, 1.0);
897
+
898
+ totalEmissiveRadiance += arrowColor * mask2 * 0.5;
899
+ }`)};const L=new p.Mesh(v,b);let M=0;return L.onBeforeRender=()=>{const C=performance.now(),W=M?(C-M)/1e3:.016;M=C;const z=x.speedFactor.value/x.totalLength.value*10;x.stripeOffset.value-=W*z,x.stripeOffset.value=x.stripeOffset.value%1},L}async function Dc(r,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=(r.width??10)*.5,i=[],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=r.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,v=0;for(let G=1;G<m.length;G++)g+=m[G].distanceTo(m[G-1]),v+=f[G].distanceTo(f[G-1]);if((g+v)/2===0)return new p.Mesh;for(let G=0;G<t.length;G++){i.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(i),3)),x.setAttribute("uv",new p.BufferAttribute(new Float32Array(o),2)),x.setIndex(a),x.computeBoundingBox(),x.computeVertexNormals();const L=await xt._loadTexture(r.flowTexture);L.wrapS=p.RepeatWrapping,L.wrapT=p.RepeatWrapping,L.anisotropy=4,L.needsUpdate=!0;const M=new p.Color(r.color??16777215),W={uMap:{value:L},uColor:{value:M},uOpacity:{value:r.opacity??1},uOffset:{value:0},uBloomBoost:{value:5}},z=r.depthOffset??1,D=z!==0,X=new p.ShaderMaterial({uniforms:W,vertexShader:`
900
+ varying vec2 vUv;
901
+ void main() {
902
+ vUv = uv;
903
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
904
+ }
905
+ `,fragmentShader:`
906
+ uniform sampler2D uMap;
907
+ uniform vec3 uColor;
908
+ uniform float uOpacity;
909
+ uniform float uOffset;
910
+ uniform float uBloomBoost;
911
+ varying vec2 vUv;
912
+
913
+ void main() {
914
+ // 关键修复:修正UV滚动计算,确保方向正确[3](@ref)
915
+ vec2 uv = vec2(fract(vUv.x + uOffset), vUv.y);
916
+ vec4 texColor = texture2D(uMap, uv);
917
+
918
+ // 添加alpha测试,完全透明的片元直接丢弃
919
+ if (texColor.a < 0.01) discard;
920
+
921
+ float alpha = texColor.a * uOpacity;
922
+ vec3 baseColor = texColor.rgb * uColor;
923
+ // 使用更自然的颜色增强公式
924
+ vec3 finalColor = baseColor * uBloomBoost;
925
+
926
+ gl_FragColor = vec4(finalColor, alpha);
927
+ }
928
+ `,transparent:r.transparent??!0,depthTest:r.depthTest??!0,depthWrite:r.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=r.speed??10;W.uOffset.value=V(W.uOffset.value-k*j/c)};function V(G){return G-Math.floor(G)}return I}async function ug(r,e){const t=r.type||(r.url.toLowerCase().endsWith(".fbx")?"fbx":"gltf");return await Wc.init().load({...r,type:t,position:e})}function hg(r,e){const{geometry:t,center:n,avgY:i}=Eo(e),o=r.depthOffset??0,a=o!==0,c=new p.MeshBasicMaterial({color:new p.Color(r.color??16777215),transparent:r.transparent??!0,opacity:r.opacity??1,wireframe:r.wireframe??!1,side:r.side==="back"?p.BackSide:r.side==="double"?p.DoubleSide:p.FrontSide,polygonOffset:a,polygonOffsetFactor:a?o:0,polygonOffsetUnits:a?o:0,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!0}),u=new p.Mesh(t,c);if(u.rotation.x=-Math.PI/2,u.position.set(n.x,i,n.z),(r.borderWidth??0)>0){const f={color:r.borderColor??r.color??0,width:r.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 v=Ho(f,g);v.position.z+=.1,u.add(v)}return u}function dg(r,e){const t=r.extrude?.height||2e3,n=[],i=[],o=[];for(let f=0;f<e.length;f+=3){const g=e[f],v=e[f+1],w=e[f+2];i.push(new p.Vector3(g,v,w)),o.push(new p.Vector3(g,v+t,w))}n.push(...i,...o);const a=new p.BufferGeometry;a.setFromPoints(n);const c=[],u=i.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(r.color??16777215)},uOpacity:{value:r.opacity??1},uBrightness:{value:1.2}},vertexShader:`
573
929
  varying vec3 vWorldPosition;
574
930
  varying vec3 vNormal;
575
931
  void main() {
576
- vNormal = normalize(normalMatrix * normal); // 法线转换到世界坐标
932
+ vNormal = normalize(normalMatrix * normal);
577
933
  vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;
578
934
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
579
935
  }
@@ -585,22 +941,36 @@
585
941
  varying vec3 vNormal;
586
942
 
587
943
  void main() {
588
- // 1. 计算菲涅尔效应(边缘高光)
589
944
  float fresnel = pow(1.0 - abs(dot(vNormal, vec3(0.0, 0.0, 1.0))), 2.0);
590
-
591
- // 2. 内部折角增亮(根据位置模拟凹陷效果)
592
945
  float innerGlow = smoothstep(0.3, 0.8, length(vWorldPosition - vec3(0.0))) * uBrightness;
593
-
594
- // 3. 混合颜色
595
946
  vec3 finalColor = uColor * (1.0 + fresnel * 0.5 + innerGlow);
596
-
597
- // 4. 强制透明度排序(深度测试后混合)
598
947
  gl_FragColor = vec4(finalColor, uOpacity);
599
-
600
- // 5. 深度写入控制(保持与不透明物体正确交互)
601
948
  if (uOpacity >= 0.99) gl_FragDepthEXT = gl_FragCoord.z;
602
949
  }
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=`
950
+ `,transparent:r.transparent??!0,side:p.DoubleSide,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!0});return new p.Mesh(a,d)}function fg(r,e,t){const{geometry:n,center:i,avgY:o}=Eo(t),a=new Pf(n,{textureWidth:512,textureHeight:512,waterNormals:new p.TextureLoader().load(r.normalMap,function(d){d.wrapS=d.wrapT=p.RepeatWrapping}),waterColor:r.color||"#19AAEE",sunColor:r.sunColor||"#05FFF8",distortionScale:1,alpha:r.opacity||.8}),c=a.onBeforeRender,u=a.onAfterRender;return a.onBeforeRender=(d,m,f,g,v,w)=>{e.tilemap.autoUpdate=!1,c.call(a,d,m,f,g,v,w)},a.onAfterRender=(d,m,f,g,v,w)=>{e.tilemap.autoUpdate=!0,u.call(a,d,m,f,g,v,w)},a.material.uniforms.size.value=.1,a.rotation.x=-Math.PI/2,a.position.set(i.x,o,i.z),e.viewer.addEventListener("update",()=>{a.material.uniforms.time.value+=1/60}),a}function Eo(r){let e=0;for(let a=1;a<r.length;a+=3)e+=r[a];e/=r.length/3;const t={x:0,z:0},n=[];for(let a=0;a<r.length;a+=3)t.x+=r[a],t.z+=r[a+2];t.x/=r.length/3,t.z/=r.length/3;for(let a=0;a<r.length;a+=3)n.push(new p.Vector2(r[a]-t.x,-(r[a+2]-t.z)));const i=new p.Shape(n);return{geometry:new p.ShapeGeometry(i),center:t,avgY:e}}async function pg(r,e){const{geometry:t,center:n,avgY:i}=Eo(e),o=await xt._loadTexture(r.normalMap),a=await xt._loadTexture(r.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(r.color).multiplyScalar(3.5),roughness:.1,metalness:.8,transparent:r.transparent??!0,opacity:.9,fog:!1,normalMap:o,normalScale:new p.Vector2(1.5,1.5),envMapIntensity:2,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!0}),u=new p.Mesh(t,c);u.rotation.x=-Math.PI/2,u.position.set(n.x,i+.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=i+.5+Math.sin(m*.02)*.02,d=m},u}function mg(r,e){r.color=new p.Color(r.hexcolor),r.boundstext&&(r.bounds=new p.Vector3(r.boundstext.x,r.boundstext.y,r.boundstext.z));const t=new lg(r);return t.castShadow=!0,t.scale.setScalar(50),t.position.copy(e),t}async function gg(r,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},...r};n.screenSpaceSize==null&&n.fixedSize!=null&&(n.screenSpaceSize=n.fixedSize);const o=(typeof window<"u"&&window.devicePixelRatio||1)*4,a=r.screenSpaceSize!=null||r.fixedSize!=null;if(r.fontSizeDpi==null&&a){const D=r.screenSpaceSize??r.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,v=u.measureText(n.text),w=Math.max(f,v.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(),zc(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(),Xc(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:r.transparent??!0,depthTest:r.depthTest??!0,depthWrite:r.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 W=r.anchor||[.5,.5],z=r.textOffset||{x:0,y:0};return M.center.set(W[0]-z.x/c.width,W[1]+z.y/c.height),e&&M.position.copy(e),M}async function yg(r,e,t){const i={...{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},...r};i.screenSpaceSize==null&&r.fixedSize!=null&&(i.screenSpaceSize=r.fixedSize);const a=(typeof window<"u"&&window.devicePixelRatio||1)*4;r.fontSizeDpi==null&&(i.fontSizeDpi=i.screenSpaceSize*a),i.fontSizeDpi=Math.max(i.fontSizeDpi,8);const c=document.createElement("canvas"),u=c.getContext("2d");if(!u)throw new Error("Failed to get canvas context");const d=`${i.fontStyle} ${i.fontWeight} ${i.fontSizeDpi}px ${i.fontFamily}`;u.font=d;const m=i.showBackground?20:0,f=100,g=50,v=u.measureText(i.text),w=Math.max(f,v.width+m*2),b=Math.max(g,i.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,i.showBackground&&(i.bgStyle===1?(u.fillStyle=i.bgColor,u.globalAlpha=i.bgOpacity,u.beginPath(),zc(u,m/2,m/2,c.width-m,c.height-m,i.roundRectRadius),u.fill(),u.globalAlpha=1,u.shadowColor=i.shadowColor,u.shadowBlur=i.shadowBlur,u.shadowOffsetX=i.shadowOffsetX,u.shadowOffsetY=i.shadowOffsetY):(u.fillStyle=i.bgColor,u.globalAlpha=i.bgOpacity,u.beginPath(),Xc(u,c.width/2,c.height/2,c.width*.8,c.height*.8,i.roundRectRadius,i.bubblePointerHeight,i.bubblePointerWidth),u.fill(),u.globalAlpha=1,u.strokeStyle=i.bubbleBorderColor,u.lineWidth=i.bubbleBorderWidth,u.stroke())),u.textAlign="center",u.textBaseline="middle",i.strokeWidth>0&&(u.strokeStyle=i.strokeColor,u.lineWidth=i.strokeWidth,u.lineJoin="round",u.strokeText(i.text,c.width/2,c.height/2)),u.fillStyle=i.textColor,u.fillText(i.text,c.width/2,c.height/2),u.shadowColor="transparent";const x=new p.CanvasTexture(c),L=new p.SpriteMaterial({map:x,transparent:r.transparent??!0,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!0,fog:!1}),M=new p.Sprite(L),C=r.anchor||[.5,.5],W=r.textOffset||{x:0,y:0},z=i.screenSpaceSize,D=z*(c.width/c.height);M.center.set(C[0]-W.x/D,C[1]+W.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>i.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=i.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 vg(r,e){const t=r.size??r.iconSize,n={text:r.text||"",iconSize:t,fontSize:r.fontSize??12,fontFamily:r.fontFamily||"微软雅黑",fontWeight:r.fontWeight??400,padding:{top:3,right:6,bottom:3,left:6,...r.padding},bgColor:r.bgColor||"#ffffff",bgOpacity:r.bgOpacity??1,textColor:r.textColor||"#000000",strokeColor:r.strokeColor||"#000000",strokeWidth:r.strokeWidth??0,iconScale:r.iconScale??1,renderbg:r.renderbg??!0,textOffset:r.textOffset??{x:-40,y:-19},depthTest:r.depthTest??!1,depthWrite:r.depthWrite??!1,transparent:r.transparent??!0,canvasScale:4};let i=null;if(r.url)try{i=await Lg(r.url)}catch{console.error("Label icon load failed:",r.url)}const{canvas:o,width:a,height:c,center:u}=await _g(n,i),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),r.anchor?f.center.set(r.anchor[0],r.anchor[1]):f.center.set(u[0],u[1]),e&&f.position.copy(e),f}async function _g(r,e){return new Promise(t=>{const{text:n,fontSize:i,fontFamily:o,padding:a,bgColor:c,textColor:u,strokeColor:d,strokeWidth:m,iconScale:f,canvasScale:g,renderbg:v,textOffset:w,iconSize:b,fontWeight:x,bgOpacity:L}=r,M=e!==null;let C=0,W=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],W=b[1]):typeof b=="number"?(W=b,C=b*ft):(C=Ce,W=ot)}else Array.isArray(b)?(C=b[0],W=b[1]):typeof b=="number"&&(C=b,W=b);const D=document.createElement("canvas").getContext("2d"),X=`${x} ${i}px ${o}`;D.font=X;const I=bg(D,n,i),{width:K,ascent:V,descent:G}=I,k=M?C/2:0,j=M?W/2:0,Y=k+w.x,H=j+w.y,Q=Y-a.left,re=Y+K+a.right,ie=H-V-a.top,le=H+G+a.bottom;let de,ge,fe,Se;M?(de=Math.min(0,Q),ge=Math.min(0,ie),fe=Math.max(C,re),Se=Math.max(W,le)):(de=Q,ge=ie,fe=re,Se=le);const it=Math.ceil(fe-de),rt=Math.ceil(Se-ge),{canvas:dt,ctx:Qe}=wg(it,rt,g),Ye=-de,Re=-ge;if(M&&e&&C>0&&W>0){const Ce=C*f,ot=W*f,ft=(C-Ce)/2,Lt=(W-ot)/2,bi=Ye+ft,Ri=Re+Lt;Qe.drawImage(e,bi,Ri,Ce,ot)}const st=Ye+Y,ze=Re+H;v&&c&&c!=="transparent"&&Mg(Qe,st,ze,K,V,G,a,c,L),Qe.font=X,Sg(Qe,n,st,ze,u,m,d);let Vt,Nt;M&&C>0&&W>0?(Vt=(Ye+k)/it,Nt=(Re+j)/rt):(Vt=.5,Nt=.5),t({canvas:dt,width:it,height:rt,center:[Vt,1-Nt]})})}function zc(r,e,t,n,i,o){r.beginPath(),r.moveTo(e+o,t),r.lineTo(e+n-o,t),r.quadraticCurveTo(e+n,t,e+n,t+o),r.lineTo(e+n,t+i-o),r.quadraticCurveTo(e+n,t+i,e+n-o,t+i),r.lineTo(e+o,t+i),r.quadraticCurveTo(e,t+i,e,t+i-o),r.lineTo(e,t+o),r.quadraticCurveTo(e,t,e+o,t),r.closePath()}function Xc(r,e,t,n,i,o,a,c){if(n<=0)throw new Error("Width must be positive");if(i<=0)throw new Error("Height must be positive");if(o<0)throw new Error("Radius cannot be negative");const u=n,d=i,m=Math.min(o,n/2,i/2),f=a??10,g=c??15;r.beginPath(),r.moveTo(e-u/2+m,t-d/2),r.lineTo(e+u/2-m,t-d/2),r.quadraticCurveTo(e+u/2,t-d/2,e+u/2,t-d/2+m),r.lineTo(e+u/2,t+d/2-m),r.quadraticCurveTo(e+u/2,t+d/2,e+u/2-m,t+d/2),r.lineTo(e+g/2,t+d/2),r.lineTo(e,t+d/2+f),r.lineTo(e-g/2,t+d/2),r.lineTo(e-u/2+m,t+d/2),r.quadraticCurveTo(e-u/2,t+d/2,e-u/2,t+d/2-m),r.lineTo(e-u/2,t-d/2+m),r.quadraticCurveTo(e-u/2,t-d/2,e-u/2+m,t-d/2),r.closePath()}function wg(r,e,t){const n=document.createElement("canvas");n.width=Math.ceil(r*t),n.height=Math.ceil(e*t);const i=n.getContext("2d",{alpha:!0});return i.scale(t,t),i.imageSmoothingEnabled=!1,{canvas:n,ctx:i}}function bg(r,e,t){const n=r.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 xg(r,e,t,n,i,o){r.beginPath(),r.moveTo(e+o,t),r.lineTo(e+n-o,t),r.arcTo(e+n,t,e+n,t+o,o),r.lineTo(e+n,t+i-o),r.arcTo(e+n,t+i,e+n-o,t+i,o),r.lineTo(e+o,t+i),r.arcTo(e,t+i,e,t+i-o,o),r.lineTo(e,t+o),r.arcTo(e,t,e+o,t,o),r.closePath()}function Mg(r,e,t,n,i,o,a,c,u=1){const d=e-a.left,m=t-i-a.top,f=n+a.left+a.right,g=i+o+a.top+a.bottom;r.save(),r.globalAlpha=u,r.fillStyle=c,xg(r,d,m,f,g,2),r.fill(),r.restore()}function Sg(r,e,t,n,i,o,a){r.save(),r.textBaseline="alphabetic",r.textAlign="left",o>0&&(r.strokeStyle=a,r.lineWidth=o,r.lineJoin="round",r.strokeText(e,t,n)),r.fillStyle=i,r.fillText(e,t,n),r.restore()}function Lg(r){return new Promise((e,t)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>e(n),n.onerror=i=>t(new Error(`Failed to load image: ${r} ${i}`)),n.src=r})}async function Pg(r,e,t){const i=new p.CylinderGeometry(.2,.2,24,12),o=new p.MeshBasicMaterial({color:r.color}),a=await xt._loadTexture(r.icon),c=new p.PointsMaterial({size:80*window.innerHeight/window.innerHeight,fog:!1,opacity:1,transparent:r.transparent??!0,toneMapped:!1,blending:p.AdditiveBlending,map:a,sizeAttenuation:!0,depthTest:r.depthTest??!0,depthWrite:r.depthWrite??!1}),u=new p.InstancedMesh(i,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 v=new p.Points(g,c);return v.position.add(t.prjcenter),v.position.y=1.5*10,v.renderOrder=99999999,v.visible=!0,{points:v,InstancedCol:u}}var Cg=Object.defineProperty,Tg=(r,e,t)=>e in r?Cg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Uc=(r,e,t)=>Tg(r,typeof e!="symbol"?e+"":e,t);const $o=class Di{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=Ac(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 i=n.material,o=t.sizeAttenuation;i.size=o?t.size*.002:t.size,t.color&&i.color.set(t.color),i.sizeAttenuation=o??!1,i.onBeforeCompile=a=>{a.fragmentShader=a.fragmentShader.replace("#include <clipping_planes_fragment>",`
951
+ #include <clipping_planes_fragment>
952
+ vec2 coord = gl_PointCoord - vec2(0.5);
953
+ if(length(coord) > 0.5) discard;
954
+ `)},i.needsUpdate=!0}_applyIconLabelPoint(e,t){return!0}_applyLineStyle(e){const t=this.config;if(e.isLine2){const i=e.material;return t.color!==void 0&&i.color.set(t.color),t.width!==void 0&&(i.linewidth=t.width),t.opacity!==void 0&&(i.opacity=t.opacity,i.transparent=t.opacity<1),i.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(Di._textureCache.has(e))return Di._textureCache.get(e);const t=await new Promise((n,i)=>{Di._textureLoader.load(e,n,void 0,i)});return t.needsUpdate=!0,Di._textureCache.set(e,t),t}static create(e){return e instanceof Di?e:new Di(e)}};Uc($o,"_textureCache",new Map),Uc($o,"_textureLoader",new p.TextureLoader);let xt=$o;const tt=[];for(let r=0;r<256;++r)tt.push((r+256).toString(16).slice(1));function Gg(r,e=0){return(tt[r[e+0]]+tt[r[e+1]]+tt[r[e+2]]+tt[r[e+3]]+"-"+tt[r[e+4]]+tt[r[e+5]]+"-"+tt[r[e+6]]+tt[r[e+7]]+"-"+tt[r[e+8]]+tt[r[e+9]]+"-"+tt[r[e+10]]+tt[r[e+11]]+tt[r[e+12]]+tt[r[e+13]]+tt[r[e+14]]+tt[r[e+15]]).toLowerCase()}let qo;const Wg=new Uint8Array(16);function Zg(){if(!qo){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");qo=crypto.getRandomValues.bind(crypto)}return qo(Wg)}const kc={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Vg(r,e,t){if(kc.randomUUID&&!r)return kc.randomUUID();r=r||{};const n=r.random??r.rng?.()??Zg();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,Gg(n)}var Kc=(r=>(r.POINT="point",r.LINE_VERTEX="line_vertex",r.POLYGON_CENTER="polygon_center",r.LABEL="label",r.ICON="icon",r.CLUSTER="cluster",r))(Kc||{}),yn=(r=>(r.NO_COLLISION="no_collision",r.PRIORITY_LOST="priority_lost",r.OUT_OF_VIEWPORT="out_of_viewport",r.ZOOM_FILTERED="zoom_filtered",r.MANUAL_HIDDEN="manual_hidden",r.GROUP_COLLISION="group_collision",r))(yn||{}),Ig=Object.defineProperty,Ag=(r,e,t)=>e in r?Ig(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Lr=(r,e,t)=>Ag(r,typeof e!="symbol"?e+"":e,t);class Fg extends cs{constructor(){super(...arguments),Lr(this,"_isDragging",!1),Lr(this,"_lastCoord",null),Lr(this,"_boundOnMouseDown",this._onMouseDown.bind(this)),Lr(this,"_boundOnMouseMove",this._onMouseMove.bind(this)),Lr(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],i=t[1]-this._lastCoord[1];Math.abs(n)<1e-8&&Math.abs(i)<1e-8||(this._translate(n,i),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 i=a=>Array.isArray(a[0])?a.map(i):[a[0]+e,a[1]+t],o=i(n.coordinates);n.coordinates=o,this.target._onPositionChanged(!0)}}var Og=Object.defineProperty,Dg=(r,e,t)=>e in r?Og(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Wt=(r,e,t)=>Dg(r,typeof e!="symbol"?e+"":e,t);class ut extends jo(Kn(yi(p.Object3D))){constructor(e){super(),Wt(this,"_position"),Wt(this,"_threeGeometry"),Wt(this,"_geometry"),Wt(this,"_layer"),Wt(this,"_style"),Wt(this,"_id"),Wt(this,"_styleQueue",[]),Wt(this,"_isApplyingStyle",!1),Wt(this,"_isGeometryInitializing",!1),Wt(this,"_bloomConfig"),Wt(this,"_collisionState",{visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:Date.now()}),Wt(this,"_collisionConfig",{enabled:!0,priority:50,padding:4,minZoom:0,maxZoom:24}),Wt(this,"_animationRef",null),Uo(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=Vg(),this.addHandler("draggable",Fg)}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:i}=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),i&&i!=="#ffffff"&&a.color.setStyle(i),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),i&&i!=="#ffffff"&&a.color.setStyle(i),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,i&&i!=="#ffffff"&&c.emissive.setStyle?c.emissive.setStyle(i):u.color&&c.emissive&&c.emissive.copy(u.color)):c.color&&(u.color&&c.color.copy(u.color),i&&i!=="#ffffff"?c.color.setStyle(i):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 i=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(i=a,o<t){const c=n*Math.pow(2,o-1);await new Promise(u=>setTimeout(u,c))}}throw i||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 Kc.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 i=n.clone().project(e);if(!(i.x>=-1.1&&i.x<=1.1&&i.y>=-1.1&&i.y<=1.1&&i.z>=-1&&i.z<=1))return null;const{width:a,height:c}=t.domElement,u=(i.x*.5+.5)*a,d=(-i.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 i=[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=[];i.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,v=f-m,w=4,b=Math.max(g,w),x=Math.max(v,w),L=new p.Vector3;n.getCenter(L);const M=L.clone().project(e),C=(M.x*.5+.5)*o,W=(-M.y*.5+.5)*a;return{width:b,height:x,offsetX:u-C,offsetY:m-W}}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,i){const{tileZ:o,tileX:a,tileY:c,extent:u,tileSize:d}=n,m=(e/u-.5)*d,f=(.5-t/u)*d;return i.tileIDToWorldCenter(o,a,c).clone().add(new p.Vector3(m,f,0)).sub(i.prjcenter)}}var zg=Object.defineProperty,Xg=(r,e,t)=>e in r?zg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Nc=(r,e,t)=>Xg(r,typeof e!="symbol"?e+"":e,t);class Yn extends fs{constructor(e,t){super(e,t),Nc(this,"_feaList"),Nc(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 i,o;for(let a=0,c=this._feaList.length;a<c;a++)i=this._feaList[a],t?o=e.call(t,i):o=e(i),o&&n.push(i);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,i=t-1,o;for(;n<=i;){if(o=Math.floor((n+i)/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 Ug=Object.defineProperty,kg=(r,e,t)=>e in r?Ug(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bc=(r,e,t)=>kg(r,typeof e!="symbol"?e+"":e,t);class Kg extends p.Group{constructor(){super(...arguments),Bc(this,"_layers",new Set),Bc(this,"_layerids",new Set)}add(...e){return e.forEach(t=>{if(!(t instanceof fs))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 Ng=Object.defineProperty,Bg=(r,e,t)=>e in r?Ng(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Yg=(r,e,t)=>Bg(r,e+"",t);class Rg{constructor(){Yg(this,"canvasDict",{})}getCanvas(e=40,t=30,n=1,i){const o=Math.ceil(e*n),a=Math.ceil(t*n),c=i?`${o}_${a}_${i}`:`${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 jg(r){const e=+this._x.call(null,r),t=+this._y.call(null,r);return Yc(this.cover(e,t),e,t,r)}function Yc(r,e,t,n){if(isNaN(e)||isNaN(t))return r;var i,o=r._root,a={data:n},c=r._x0,u=r._y0,d=r._x1,m=r._y1,f,g,v,w,b,x,L,M;if(!o)return r._root=a,r;for(;o.length;)if((b=e>=(f=(c+d)/2))?c=f:d=f,(x=t>=(g=(u+m)/2))?u=g:m=g,i=o,!(o=o[L=x<<1|b]))return i[L]=a,r;if(v=+r._x.call(null,o.data),w=+r._y.call(null,o.data),e===v&&t===w)return a.next=o,i?i[L]=a:r._root=a,r;do i=i?i[L]=new Array(4):r._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|v>=f));return i[M]=o,i[L]=a,r}function Jg(r){var e,t,n=r.length,i,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(i=+this._x.call(null,e=r[t]))||isNaN(o=+this._y.call(null,e))||(a[t]=i,c[t]=o,i<u&&(u=i),i>m&&(m=i),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)Yc(this,a[t],c[t],r[t]);return this}function Qg(r,e){if(isNaN(r=+r)||isNaN(e=+e))return this;var t=this._x0,n=this._y0,i=this._x1,o=this._y1;if(isNaN(t))i=(t=Math.floor(r))+1,o=(n=Math.floor(e))+1;else{for(var a=i-t||1,c=this._root,u,d;t>r||r>=i||n>e||e>=o;)switch(d=(e<n)<<1|r<t,u=new Array(4),u[d]=c,c=u,a*=2,d){case 0:i=t+a,o=n+a;break;case 1:t=i-a,o=n+a;break;case 2:i=t+a,n=o-a;break;case 3:t=i-a,n=o-a;break}this._root&&this._root.length&&(this._root=c)}return this._x0=t,this._y0=n,this._x1=i,this._y1=o,this}function Hg(){var r=[];return this.visit(function(e){if(!e.length)do r.push(e.data);while(e=e.next)}),r}function Eg(r){return arguments.length?this.cover(+r[0][0],+r[0][1]).cover(+r[1][0],+r[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function gt(r,e,t,n,i){this.node=r,this.x0=e,this.y0=t,this.x1=n,this.y1=i}function $g(r,e,t){var n,i=this._x0,o=this._y0,a,c,u,d,m=this._x1,f=this._y1,g=[],v=this._root,w,b;for(v&&g.push(new gt(v,i,o,m,f)),t==null?t=1/0:(i=r-t,o=e-t,m=r+t,f=e+t,t*=t);w=g.pop();)if(!(!(v=w.node)||(a=w.x0)>m||(c=w.y0)>f||(u=w.x1)<i||(d=w.y1)<o))if(v.length){var x=(a+u)/2,L=(c+d)/2;g.push(new gt(v[3],x,L,u,d),new gt(v[2],a,L,x,d),new gt(v[1],x,c,u,L),new gt(v[0],a,c,x,L)),(b=(e>=L)<<1|r>=x)&&(w=g[g.length-1],g[g.length-1]=g[g.length-1-b],g[g.length-1-b]=w)}else{var M=r-+this._x.call(null,v.data),C=e-+this._y.call(null,v.data),W=M*M+C*C;if(W<t){var z=Math.sqrt(t=W);i=r-z,o=e-z,m=r+z,f=e+z,n=v.data}}return n}function qg(r){if(isNaN(m=+this._x.call(null,r))||isNaN(f=+this._y.call(null,r)))return this;var e,t=this._root,n,i,o,a=this._x0,c=this._y0,u=this._x1,d=this._y1,m,f,g,v,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>=(v=(c+d)/2))?c=v:d=v,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!==r;)if(i=t,!(t=t.next))return this;return(o=t.next)&&delete t.next,i?(o?i.next=o:delete i.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 e0(r){for(var e=0,t=r.length;e<t;++e)this.remove(r[e]);return this}function t0(){return this._root}function n0(){var r=0;return this.visit(function(e){if(!e.length)do++r;while(e=e.next)}),r}function i0(r){var e=[],t,n=this._root,i,o,a,c,u;for(n&&e.push(new gt(n,this._x0,this._y0,this._x1,this._y1));t=e.pop();)if(!r(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;(i=n[3])&&e.push(new gt(i,d,m,c,u)),(i=n[2])&&e.push(new gt(i,o,m,d,u)),(i=n[1])&&e.push(new gt(i,d,a,c,m)),(i=n[0])&&e.push(new gt(i,o,a,d,m))}return this}function r0(r){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 i=n.node;if(i.length){var o,a=n.x0,c=n.y0,u=n.x1,d=n.y1,m=(a+u)/2,f=(c+d)/2;(o=i[0])&&e.push(new gt(o,a,c,m,f)),(o=i[1])&&e.push(new gt(o,m,c,u,f)),(o=i[2])&&e.push(new gt(o,a,f,m,d)),(o=i[3])&&e.push(new gt(o,m,f,u,d))}t.push(n)}for(;n=t.pop();)r(n.node,n.x0,n.y0,n.x1,n.y1);return this}function s0(r){return r[0]}function o0(r){return arguments.length?(this._x=r,this):this._x}function a0(r){return r[1]}function l0(r){return arguments.length?(this._y=r,this):this._y}function Rc(r,e,t){var n=new ea(e??s0,t??a0,NaN,NaN,NaN,NaN);return r==null?n:n.addAll(r)}function ea(r,e,t,n,i,o){this._x=r,this._y=e,this._x0=t,this._y0=n,this._x1=i,this._y1=o,this._root=void 0}function jc(r){for(var e={data:r.data},t=e;r=r.next;)t=t.next={data:r.data};return e}var yt=Rc.prototype=ea.prototype;yt.copy=function(){var r=new ea(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root,t,n;if(!e)return r;if(!e.length)return r._root=jc(e),r;for(t=[{source:e,target:r._root=new Array(4)}];e=t.pop();)for(var i=0;i<4;++i)(n=e.source[i])&&(n.length?t.push({source:n,target:e.target[i]=new Array(4)}):e.target[i]=jc(n));return r},yt.add=jg,yt.addAll=Jg,yt.cover=Qg,yt.data=Hg,yt.extent=Eg,yt.find=$g,yt.remove=qg,yt.removeAll=e0,yt.root=t0,yt.size=n0,yt.visit=i0,yt.visitAfter=r0,yt.x=o0,yt.y=l0;var c0=Object.defineProperty,u0=(r,e,t)=>e in r?c0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jc=(r,e,t)=>u0(r,typeof e!="symbol"?e+"":e,t);class Qc{constructor(e){Jc(this,"_quadtree"),Jc(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((i,o,a,c,u)=>this._checkNodeCollision(n,o,a,c,u)?(i.length||this._getNodeData(i).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=Rc().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,i,o){const a=(t+i)/2,c=(n+o)/2,u=i-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(i=>i.id!==e);this.clear(),n.length>0&&this.addBoxes(n)}}var h0=Object.defineProperty,d0=(r,e,t)=>e in r?h0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Hc=(r,e,t)=>d0(r,typeof e!="symbol"?e+"":e,t);class f0{constructor(){Hc(this,"_strategies",new Map),Hc(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(i=>{n.set(i._id,{featureId:i._id,visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:t.timestamp})});for(const i of this._executionOrder){const o=this._strategies.get(i);if(o?.enabled)try{const a=await o.execute(e,t,n);this._mergeResults(n,a)}catch(a){console.error(`Strategy ${i} execution failed: 策略 ${i} 执行失败:`,a)}}return n}_mergeResults(e,t){t.forEach(n=>{const i=e.get(n.featureId);i&&!i.visible||e.set(n.featureId,n)})}}var p0=Object.defineProperty,m0=(r,e,t)=>e in r?p0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_i=(r,e,t)=>m0(r,typeof e!="symbol"?e+"":e,t);class g0{constructor(){_i(this,"frameStats",new Map),_i(this,"summaryStats",{totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0}),_i(this,"sampleWindowSize",60),_i(this,"currentFrameId",0),_i(this,"lastReportTime",0),_i(this,"reportInterval",5e3),_i(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 i=performance.now();n.endTime=i,n.duration=i-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(i=>Math.pow(i.duration-t,2));return Math.sqrt(n.reduce((i,o)=>i+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((i,o)=>{t.has(o)||t.set(o,[]),t.get(o).push(i)})}),Array.from(t.entries()).map(([n,i])=>({name:n,averageTime:i.reduce((o,a)=>o+a,0)/i.length,maxTime:Math.max(...i),minTime:Math.min(...i),callCount:i.length}))}getPerformanceWarnings(e){const t=[],n=e.slice(-30);if(n.length===0)return t;const i=this.calculateAverageFrameTime(n);i>this.performanceThresholds.criticalFrameTime?t.push({type:"critical",message:`帧率过低: ${Math.round(1e3/i)}fps`,suggestion:"考虑减少要素数量或简化避让策略"}):i>this.performanceThresholds.warningFrameTime&&t.push({type:"warning",message:`帧率较低: ${Math.round(1e3/i)}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)),i=this.calculateAverageFrameTime(t),a=(this.calculateAverageFrameTime(n)-i)/i*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 y0=Object.defineProperty,v0=(r,e,t)=>e in r?y0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,gs=(r,e,t)=>v0(r,typeof e!="symbol"?e+"":e,t);class _0{constructor(){gs(this,"name","priority"),gs(this,"enabled",!0),gs(this,"weight",1),gs(this,"description","Priority-based avoidance strategy, smaller value means higher priority 基于优先级的避让策略,数值越小优先级越高")}async execute(e,t,n){const i=[],o=new Qc(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]),i.push({featureId:u.featureId,visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:t.timestamp})):d.some(f=>f.priority<u.priority)?i.push({featureId:u.featureId,visible:!1,reason:yn.PRIORITY_LOST,collidedWith:d.map(f=>f.featureId),timestamp:t.timestamp}):(o.addBoxes([u]),i.push({featureId:u.featureId,visible:!0,reason:yn.NO_COLLISION,collidedWith:[],timestamp:t.timestamp}),d.forEach(f=>{i.push({featureId:f.featureId,visible:!1,reason:yn.PRIORITY_LOST,collidedWith:[u.featureId],timestamp:t.timestamp})}))}),i}}var w0=Object.defineProperty,b0=(r,e,t)=>e in r?w0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rn=(r,e,t)=>b0(r,typeof e!="symbol"?e+"":e,t);class x0{constructor(e,t={}){this.renderer=e,Rn(this,"_quadTreeManager"),Rn(this,"_strategyOrchestrator"),Rn(this,"_performanceMonitor"),Rn(this,"_layers",new Set),Rn(this,"_config"),Rn(this,"_isUpdating",!1),Rn(this,"_lastUpdateTime",0),Rn(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),i=this._collectCollidableFeatures();if(i.length===0)return;this._performanceMonitor.startFrame(this._frameCount);const o=await this._strategyOrchestrator.executeStrategies(i,n);await this._applyCollisionResults(o,i),this._performanceMonitor.endFrame(this._frameCount,{featureCount:i.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 Qc(e),this._strategyOrchestrator=new f0,this._performanceMonitor=new g0,this._strategyOrchestrator.registerStrategy(new _0,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(i=>i.collidable&&i 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(i=>{const o=e.get(i._id);return o&&i.setCollisionVisibility(o.visible,o.reason),Promise.resolve()});await Promise.all(n)}_setupViewportResizeHandler(){new ResizeObserver(t=>{t.forEach(n=>{const{width:i,height:o}=n.contentRect;this._quadTreeManager.updateViewport({width:i,height:o})})}).observe(this.renderer.domElement)}_setupPerformanceMonitoring(){setInterval(()=>{const e=this.getPerformanceStats();e.frameRate<30&&console.warn("避让系统性能警告:",e)},5e3)}}var Pr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ys={exports:{}};ys.exports,function(r,e){(function(){var t,n="4.17.21",i=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,v=4,w=1,b=2,x=1,L=2,M=4,C=8,W=16,z=32,D=64,X=128,I=256,K=512,V=30,G="...",k=800,j=16,Y=1,H=2,Q=3,re=1/0,ie=9007199254740991,le=17976931348623157e292,de=NaN,ge=4294967295,fe=ge-1,Se=ge>>>1,it=[["ary",X],["bind",x],["bindKey",L],["curry",C],["curryRight",W],["flip",K],["partial",z],["partialRight",D],["rearg",I]],rt="[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]",bi="[object Promise]",Ri="[object Proxy]",xi="[object RegExp]",It="[object Set]",qn="[object String]",ei="[object Symbol]",Mi="[object Undefined]",Si="[object WeakMap]",xa="[object WeakSet]",ti="[object ArrayBuffer]",wn="[object DataView]",Ir="[object Float32Array]",Ar="[object Float64Array]",ji="[object Int8Array]",Fr="[object Int16Array]",Or="[object Int32Array]",Ji="[object Uint8Array]",Li="[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,Au=RegExp(Bt.source),Gs=RegExp(sn.source),on=/<%-([\s\S]+?)%>/g,an=/<%([\s\S]+?)%>/g,ni=/<%=([\s\S]+?)%>/g,Pi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ci=/^\w*$/,Qi=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ma=/[\\^$.*+?()[\]{}|]/g,fw=RegExp(Ma.source),Sa=/^\s+/,pw=/\s/,mw=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,gw=/\{\n\/\* \[wrapped with (.+)\] \*/,yw=/,? & /,vw=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,_w=/[()=,{}\[\]\/\s]/,ww=/\\(\\)?/g,bw=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Fu=/\w*$/,xw=/^[-+]0x[0-9a-f]+$/i,Mw=/^0b[01]+$/i,Sw=/^\[object .+?Constructor\]$/,Lw=/^0o[0-7]+$/i,Pw=/^(?:0|[1-9]\d*)$/,Cw=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ws=/($^)/,Tw=/['\n\r\u2028\u2029\\]/g,Zs="\\ud800-\\udfff",Gw="\\u0300-\\u036f",Ww="\\ufe20-\\ufe2f",Zw="\\u20d0-\\u20ff",Ou=Gw+Ww+Zw,Du="\\u2700-\\u27bf",zu="a-z\\xdf-\\xf6\\xf8-\\xff",Vw="\\xac\\xb1\\xd7\\xf7",Iw="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Aw="\\u2000-\\u206f",Fw=" \\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",Xu="A-Z\\xc0-\\xd6\\xd8-\\xde",Uu="\\ufe0e\\ufe0f",ku=Vw+Iw+Aw+Fw,La="['’]",Ow="["+Zs+"]",Ku="["+ku+"]",Vs="["+Ou+"]",Nu="\\d+",Dw="["+Du+"]",Bu="["+zu+"]",Yu="[^"+Zs+ku+Nu+Du+zu+Xu+"]",Pa="\\ud83c[\\udffb-\\udfff]",zw="(?:"+Vs+"|"+Pa+")",Ru="[^"+Zs+"]",Ca="(?:\\ud83c[\\udde6-\\uddff]){2}",Ta="[\\ud800-\\udbff][\\udc00-\\udfff]",Hi="["+Xu+"]",ju="\\u200d",Ju="(?:"+Bu+"|"+Yu+")",Xw="(?:"+Hi+"|"+Yu+")",Qu="(?:"+La+"(?:d|ll|m|re|s|t|ve))?",Hu="(?:"+La+"(?:D|LL|M|RE|S|T|VE))?",Eu=zw+"?",$u="["+Uu+"]?",Uw="(?:"+ju+"(?:"+[Ru,Ca,Ta].join("|")+")"+$u+Eu+")*",kw="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Kw="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",qu=$u+Eu+Uw,Nw="(?:"+[Dw,Ca,Ta].join("|")+")"+qu,Bw="(?:"+[Ru+Vs+"?",Vs,Ca,Ta,Ow].join("|")+")",Yw=RegExp(La,"g"),Rw=RegExp(Vs,"g"),Ga=RegExp(Pa+"(?="+Pa+")|"+Bw+qu,"g"),jw=RegExp([Hi+"?"+Bu+"+"+Qu+"(?="+[Ku,Hi,"$"].join("|")+")",Xw+"+"+Hu+"(?="+[Ku,Hi+Ju,"$"].join("|")+")",Hi+"?"+Ju+"+"+Qu,Hi+"+"+Hu,Kw,kw,Nu,Nw].join("|"),"g"),Jw=RegExp("["+ju+Zs+Ou+Uu+"]"),Qw=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Hw=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ew=-1,Ie={};Ie[Ir]=Ie[Ar]=Ie[ji]=Ie[Fr]=Ie[Or]=Ie[Ji]=Ie[Li]=Ie[O]=Ie[E]=!0,Ie[rt]=Ie[dt]=Ie[ti]=Ie[Ye]=Ie[wn]=Ie[Re]=Ie[ze]=Ie[Vt]=Ie[Ce]=Ie[ot]=Ie[Lt]=Ie[xi]=Ie[It]=Ie[qn]=Ie[Si]=!1;var We={};We[rt]=We[dt]=We[ti]=We[wn]=We[Ye]=We[Re]=We[Ir]=We[Ar]=We[ji]=We[Fr]=We[Or]=We[Ce]=We[ot]=We[Lt]=We[xi]=We[It]=We[qn]=We[ei]=We[Ji]=We[Li]=We[O]=We[E]=!0,We[ze]=We[Vt]=We[Si]=!1;var $w={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"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"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},qw={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},eb={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},tb={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},nb=parseFloat,ib=parseInt,eh=typeof Pr=="object"&&Pr&&Pr.Object===Object&&Pr,rb=typeof self=="object"&&self&&self.Object===Object&&self,at=eh||rb||Function("return this")(),Wa=e&&!e.nodeType&&e,Ti=Wa&&!0&&r&&!r.nodeType&&r,th=Ti&&Ti.exports===Wa,Za=th&&eh.process,Yt=function(){try{var A=Ti&&Ti.require&&Ti.require("util").types;return A||Za&&Za.binding&&Za.binding("util")}catch{}}(),nh=Yt&&Yt.isArrayBuffer,ih=Yt&&Yt.isDate,rh=Yt&&Yt.isMap,sh=Yt&&Yt.isRegExp,oh=Yt&&Yt.isSet,ah=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 sb(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 ob(A,N){for(var U=A==null?0:A.length;U--&&N(A[U],U,A)!==!1;);return A}function lh(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 ii(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 Is(A,N){var U=A==null?0:A.length;return!!U&&Ei(A,N,0)>-1}function Va(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 ri(A,N){for(var U=-1,ee=N.length,ue=A.length;++U<ee;)A[ue+U]=N[U];return A}function Ia(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 ab(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 Aa(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 lb=Fa("length");function cb(A){return A.split("")}function ub(A){return A.match(vw)||[]}function ch(A,N,U){var ee;return U(A,function(ue,Le,je){if(N(ue,Le,je))return ee=Le,!1}),ee}function As(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 Ei(A,N,U){return N===N?xb(A,N,U):As(A,uh,U)}function hb(A,N,U,ee){for(var ue=U-1,Le=A.length;++ue<Le;)if(ee(A[ue],N))return ue;return-1}function uh(A){return A!==A}function hh(A,N){var U=A==null?0:A.length;return U?Da(A,N)/U:de}function Fa(A){return function(N){return N==null?t:N[A]}}function Oa(A){return function(N){return A==null?t:A[N]}}function dh(A,N,U,ee,ue){return ue(A,function(Le,je,Ge){U=ee?(ee=!1,Le):N(U,Le,je,Ge)}),U}function db(A,N){var U=A.length;for(A.sort(N);U--;)A[U]=A[U].value;return A}function Da(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 za(A,N){for(var U=-1,ee=Array(A);++U<A;)ee[U]=N(U);return ee}function fb(A,N){return Ae(N,function(U){return[U,A[U]]})}function fh(A){return A&&A.slice(0,yh(A)+1).replace(Sa,"")}function Ft(A){return function(N){return A(N)}}function Xa(A,N){return Ae(N,function(U){return A[U]})}function Dr(A,N){return A.has(N)}function ph(A,N){for(var U=-1,ee=A.length;++U<ee&&Ei(N,A[U],0)>-1;);return U}function mh(A,N){for(var U=A.length;U--&&Ei(N,A[U],0)>-1;);return U}function pb(A,N){for(var U=A.length,ee=0;U--;)A[U]===N&&++ee;return ee}var mb=Oa($w),gb=Oa(qw);function yb(A){return"\\"+tb[A]}function vb(A,N){return A==null?t:A[N]}function $i(A){return Jw.test(A)}function _b(A){return Qw.test(A)}function wb(A){for(var N,U=[];!(N=A.next()).done;)U.push(N.value);return U}function Ua(A){var N=-1,U=Array(A.size);return A.forEach(function(ee,ue){U[++N]=[ue,ee]}),U}function gh(A,N){return function(U){return A(N(U))}}function si(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 Fs(A){var N=-1,U=Array(A.size);return A.forEach(function(ee){U[++N]=ee}),U}function bb(A){var N=-1,U=Array(A.size);return A.forEach(function(ee){U[++N]=[ee,ee]}),U}function xb(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 qi(A){return $i(A)?Lb(A):lb(A)}function ln(A){return $i(A)?Pb(A):cb(A)}function yh(A){for(var N=A.length;N--&&pw.test(A.charAt(N)););return N}var Sb=Oa(eb);function Lb(A){for(var N=Ga.lastIndex=0;Ga.test(A);)++N;return N}function Pb(A){return A.match(Ga)||[]}function Cb(A){return A.match(jw)||[]}var Tb=function A(N){N=N==null?at:er.defaults(at.Object(),N,er.pick(at,Hw));var U=N.Array,ee=N.Date,ue=N.Error,Le=N.Function,je=N.Math,Ge=N.Object,ka=N.RegExp,Gb=N.String,jt=N.TypeError,Os=U.prototype,Wb=Le.prototype,tr=Ge.prototype,Ds=N["__core-js_shared__"],zs=Wb.toString,Te=tr.hasOwnProperty,Zb=0,vh=function(){var s=/[^.]+$/.exec(Ds&&Ds.keys&&Ds.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}(),Xs=tr.toString,Vb=zs.call(Ge),Ib=at._,Ab=ka("^"+zs.call(Te).replace(Ma,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Us=th?N.Buffer:t,oi=N.Symbol,ks=N.Uint8Array,_h=Us?Us.allocUnsafe:t,Ks=gh(Ge.getPrototypeOf,Ge),wh=Ge.create,bh=tr.propertyIsEnumerable,Ns=Os.splice,xh=oi?oi.isConcatSpreadable:t,zr=oi?oi.iterator:t,Gi=oi?oi.toStringTag:t,Bs=function(){try{var s=Ai(Ge,"defineProperty");return s({},"",{}),s}catch{}}(),Fb=N.clearTimeout!==at.clearTimeout&&N.clearTimeout,Ob=ee&&ee.now!==at.Date.now&&ee.now,Db=N.setTimeout!==at.setTimeout&&N.setTimeout,Ys=je.ceil,Rs=je.floor,Ka=Ge.getOwnPropertySymbols,zb=Us?Us.isBuffer:t,Mh=N.isFinite,Xb=Os.join,Ub=gh(Ge.keys,Ge),Je=je.max,pt=je.min,kb=ee.now,Kb=N.parseInt,Sh=je.random,Nb=Os.reverse,Na=Ai(N,"DataView"),Xr=Ai(N,"Map"),Ba=Ai(N,"Promise"),nr=Ai(N,"Set"),Ur=Ai(N,"WeakMap"),kr=Ai(Ge,"create"),js=Ur&&new Ur,ir={},Bb=Fi(Na),Yb=Fi(Xr),Rb=Fi(Ba),jb=Fi(nr),Jb=Fi(Ur),Js=oi?oi.prototype:t,Kr=Js?Js.valueOf:t,Lh=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 Pd(s)}return new Jt(s)}var rr=function(){function s(){}return function(l){if(!Fe(l))return{};if(wh)return wh(l);s.prototype=l;var h=new s;return s.prototype=t,h}}();function Qs(){}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:ni,variable:"",imports:{_:S}},S.prototype=Qs.prototype,S.prototype.constructor=S,Jt.prototype=rr(Qs.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 Qb(){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 Hb(){if(this.__filtered__){var s=new be(this);s.__dir__=-1,s.__filtered__=!0}else s=this.clone(),s.__dir__*=-1;return s}function Eb(){var s=this.__wrapped__.value(),l=this.__dir__,h=he(s),y=l<0,_=h?s.length:0,P=cx(0,_,this.__views__),T=P.start,Z=P.end,F=Z-T,B=y?Z:T-1,R=this.__iteratees__,J=R.length,$=0,te=pt(F,this.__takeCount__);if(!h||!y&&_==F&&te==F)return Qh(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=rr(Qs.prototype),be.prototype.constructor=be;function Wi(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 $b(){this.__data__=kr?kr(null):{},this.size=0}function qb(s){var l=this.has(s)&&delete this.__data__[s];return this.size-=l?1:0,l}function e1(s){var l=this.__data__;if(kr){var h=l[s];return h===u?t:h}return Te.call(l,s)?l[s]:t}function t1(s){var l=this.__data__;return kr?l[s]!==t:Te.call(l,s)}function n1(s,l){var h=this.__data__;return this.size+=this.has(s)?0:1,h[s]=kr&&l===t?u:l,this}Wi.prototype.clear=$b,Wi.prototype.delete=qb,Wi.prototype.get=e1,Wi.prototype.has=t1,Wi.prototype.set=n1;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 i1(){this.__data__=[],this.size=0}function r1(s){var l=this.__data__,h=Hs(l,s);if(h<0)return!1;var y=l.length-1;return h==y?l.pop():Ns.call(l,h,1),--this.size,!0}function s1(s){var l=this.__data__,h=Hs(l,s);return h<0?t:l[h][1]}function o1(s){return Hs(this.__data__,s)>-1}function a1(s,l){var h=this.__data__,y=Hs(h,s);return y<0?(++this.size,h.push([s,l])):h[y][1]=l,this}Tn.prototype.clear=i1,Tn.prototype.delete=r1,Tn.prototype.get=s1,Tn.prototype.has=o1,Tn.prototype.set=a1;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 l1(){this.size=0,this.__data__={hash:new Wi,map:new(Xr||Tn),string:new Wi}}function c1(s){var l=lo(this,s).delete(s);return this.size-=l?1:0,l}function u1(s){return lo(this,s).get(s)}function h1(s){return lo(this,s).has(s)}function d1(s,l){var h=lo(this,s),y=h.size;return h.set(s,l),this.size+=h.size==y?0:1,this}Gn.prototype.clear=l1,Gn.prototype.delete=c1,Gn.prototype.get=u1,Gn.prototype.has=h1,Gn.prototype.set=d1;function Zi(s){var l=-1,h=s==null?0:s.length;for(this.__data__=new Gn;++l<h;)this.add(s[l])}function f1(s){return this.__data__.set(s,u),this}function p1(s){return this.__data__.has(s)}Zi.prototype.add=Zi.prototype.push=f1,Zi.prototype.has=p1;function cn(s){var l=this.__data__=new Tn(s);this.size=l.size}function m1(){this.__data__=new Tn,this.size=0}function g1(s){var l=this.__data__,h=l.delete(s);return this.size=l.size,h}function y1(s){return this.__data__.get(s)}function v1(s){return this.__data__.has(s)}function _1(s,l){var h=this.__data__;if(h instanceof Tn){var y=h.__data__;if(!Xr||y.length<i-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=m1,cn.prototype.delete=g1,cn.prototype.get=y1,cn.prototype.has=v1,cn.prototype.set=_1;function Ph(s,l){var h=he(s),y=!h&&Oi(s),_=!h&&!y&&hi(s),P=!h&&!y&&!_&&lr(s),T=h||y||_||P,Z=T?za(s.length,Gb):[],F=Z.length;for(var B in s)(l||Te.call(s,B))&&!(T&&(B=="length"||_&&(B=="offset"||B=="parent")||P&&(B=="buffer"||B=="byteLength"||B=="byteOffset")||In(B,F)))&&Z.push(B);return Z}function Ch(s){var l=s.length;return l?s[tl(0,l-1)]:t}function w1(s,l){return co(Pt(s),Vi(l,0,s.length))}function b1(s){return co(Pt(s))}function Ya(s,l,h){(h!==t&&!un(s[l],h)||h===t&&!(l in s))&&Wn(s,l,h)}function Nr(s,l,h){var y=s[l];(!(Te.call(s,l)&&un(y,h))||h===t&&!(l in s))&&Wn(s,l,h)}function Hs(s,l){for(var h=s.length;h--;)if(un(s[h][0],l))return h;return-1}function x1(s,l,h,y){return ai(s,function(_,P,T){l(y,_,h(_),T)}),y}function Th(s,l){return s&&xn(l,He(l),s)}function M1(s,l){return s&&xn(l,Tt(l),s)}function Wn(s,l,h){l=="__proto__"&&Bs?Bs(s,l,{configurable:!0,enumerable:!0,value:h,writable:!0}):s[l]=h}function Ra(s,l){for(var h=-1,y=l.length,_=U(y),P=s==null;++h<y;)_[h]=P?t:Pl(s,l[h]);return _}function Vi(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,_,P){var T,Z=l&f,F=l&g,B=l&v;if(h&&(T=_?h(s,y,_,P):h(s)),T!==t)return T;if(!Fe(s))return s;var R=he(s);if(R){if(T=hx(s),!Z)return Pt(s,T)}else{var J=mt(s),$=J==Vt||J==Nt;if(hi(s))return $h(s,Z);if(J==Lt||J==rt||$&&!_){if(T=F||$?{}:yd(s),!Z)return F?ex(s,M1(T,s)):q1(s,Th(T,s))}else{if(!We[J])return _?s:{};T=dx(s,J,Z)}}P||(P=new cn);var te=P.get(s);if(te)return te;P.set(s,T),Rd(s)?s.forEach(function(ae){T.add(Qt(ae,l,h,ae,s,P))}):Bd(s)&&s.forEach(function(ae,we){T.set(we,Qt(ae,l,h,we,s,P))});var oe=B?F?dl:hl:F?Tt:He,me=R?t:oe(s);return Rt(me||s,function(ae,we){me&&(we=ae,ae=s[we]),Nr(T,we,Qt(ae,l,h,we,s,P))}),T}function S1(s){var l=He(s);return function(h){return Gh(h,s,l)}}function Gh(s,l,h){var y=h.length;if(s==null)return!y;for(s=Ge(s);y--;){var _=h[y],P=l[_],T=s[_];if(T===t&&!(_ in s)||!P(T))return!1}return!0}function Wh(s,l,h){if(typeof s!="function")throw new jt(a);return Hr(function(){s.apply(t,h)},l)}function Br(s,l,h,y){var _=-1,P=Is,T=!0,Z=s.length,F=[],B=l.length;if(!Z)return F;h&&(l=Ae(l,Ft(h))),y?(P=Va,T=!1):l.length>=i&&(P=Dr,T=!1,l=new Zi(l));e:for(;++_<Z;){var R=s[_],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 ai=id(bn),Zh=id(Ja,!0);function L1(s,l){var h=!0;return ai(s,function(y,_,P){return h=!!l(y,_,P),h}),h}function Es(s,l,h){for(var y=-1,_=s.length;++y<_;){var P=s[y],T=l(P);if(T!=null&&(Z===t?T===T&&!Dt(T):h(T,Z)))var Z=T,F=P}return F}function P1(s,l,h,y){var _=s.length;for(h=pe(h),h<0&&(h=-h>_?0:_+h),y=y===t||y>_?_:pe(y),y<0&&(y+=_),y=h>y?0:Jd(y);h<y;)s[h++]=l;return s}function Vh(s,l){var h=[];return ai(s,function(y,_,P){l(y,_,P)&&h.push(y)}),h}function lt(s,l,h,y,_){var P=-1,T=s.length;for(h||(h=px),_||(_=[]);++P<T;){var Z=s[P];l>0&&h(Z)?l>1?lt(Z,l-1,h,y,_):ri(_,Z):y||(_[_.length]=Z)}return _}var ja=rd(),Ih=rd(!0);function bn(s,l){return s&&ja(s,l,He)}function Ja(s,l){return s&&Ih(s,l,He)}function $s(s,l){return ii(l,function(h){return An(s[h])})}function Ii(s,l){l=ci(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 Ah(s,l,h){var y=l(s);return he(s)?y:ri(y,h(s))}function vt(s){return s==null?s===t?Mi:ft:Gi&&Gi in Ge(s)?lx(s):bx(s)}function Qa(s,l){return s>l}function C1(s,l){return s!=null&&Te.call(s,l)}function T1(s,l){return s!=null&&l in Ge(s)}function G1(s,l,h){return s>=pt(l,h)&&s<Je(l,h)}function Ha(s,l,h){for(var y=h?Va:Is,_=s[0].length,P=s.length,T=P,Z=U(P),F=1/0,B=[];T--;){var R=s[T];T&&l&&(R=Ae(R,Ft(l))),F=pt(R.length,F),Z[T]=!h&&(l||_>=120&&R.length>=120)?new Zi(T&&R):t}R=s[0];var J=-1,$=Z[0];e:for(;++J<_&&B.length<F;){var te=R[J],oe=l?l(te):te;if(te=h||te!==0?te:0,!($?Dr($,oe):y(B,oe,h))){for(T=P;--T;){var me=Z[T];if(!(me?Dr(me,oe):y(s[T],oe,h)))continue e}$&&$.push(oe),B.push(te)}}return B}function W1(s,l,h,y){return bn(s,function(_,P,T){l(y,h(_),P,T)}),y}function Yr(s,l,h){l=ci(l,s),s=bd(s,l);var y=s==null?s:s[Mn(Et(l))];return y==null?t:At(y,s,h)}function Fh(s){return Xe(s)&&vt(s)==rt}function Z1(s){return Xe(s)&&vt(s)==ti}function V1(s){return Xe(s)&&vt(s)==Re}function Rr(s,l,h,y,_){return s===l?!0:s==null||l==null||!Xe(s)&&!Xe(l)?s!==s&&l!==l:I1(s,l,h,y,Rr,_)}function I1(s,l,h,y,_,P){var T=he(s),Z=he(l),F=T?dt:mt(s),B=Z?dt:mt(l);F=F==rt?Lt:F,B=B==rt?Lt:B;var R=F==Lt,J=B==Lt,$=F==B;if($&&hi(s)){if(!hi(l))return!1;T=!0,R=!1}if($&&!R)return P||(P=new cn),T||lr(s)?pd(s,l,h,y,_,P):ox(s,l,F,h,y,_,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),_(me,ae,h,y,P)}}return $?(P||(P=new cn),ax(s,l,h,y,_,P)):!1}function A1(s){return Xe(s)&&mt(s)==Ce}function Ea(s,l,h,y){var _=h.length,P=_,T=!y;if(s==null)return!P;for(s=Ge(s);_--;){var Z=h[_];if(T&&Z[2]?Z[1]!==s[Z[0]]:!(Z[0]in s))return!1}for(;++_<P;){Z=h[_];var F=Z[0],B=s[F],R=Z[1];if(T&&Z[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?Rr(R,B,w|b,y,J):$))return!1}}return!0}function Oh(s){if(!Fe(s)||gx(s))return!1;var l=An(s)?Ab:Sw;return l.test(Fi(s))}function F1(s){return Xe(s)&&vt(s)==xi}function O1(s){return Xe(s)&&mt(s)==It}function D1(s){return Xe(s)&&go(s.length)&&!!Ie[vt(s)]}function Dh(s){return typeof s=="function"?s:s==null?Gt:typeof s=="object"?he(s)?Uh(s[0],s[1]):Xh(s):of(s)}function $a(s){if(!Qr(s))return Ub(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 wx(s);var l=Qr(s),h=[];for(var y in s)y=="constructor"&&(l||!Te.call(s,y))||h.push(y);return h}function qa(s,l){return s<l}function zh(s,l){var h=-1,y=Ct(s)?U(s.length):[];return ai(s,function(_,P,T){y[++h]=l(_,P,T)}),y}function Xh(s){var l=pl(s);return l.length==1&&l[0][2]?_d(l[0][0],l[0][1]):function(h){return h===s||Ea(h,s,l)}}function Uh(s,l){return gl(s)&&vd(l)?_d(Mn(s),l):function(h){var y=Pl(h,s);return y===t&&y===l?Cl(h,s):Rr(l,y,w|b)}}function qs(s,l,h,y,_){s!==l&&ja(l,function(P,T){if(_||(_=new cn),Fe(P))X1(s,l,T,h,qs,y,_);else{var Z=y?y(vl(s,T),P,T+"",s,l,_):t;Z===t&&(Z=P),Ya(s,T,Z)}},Tt)}function X1(s,l,h,y,_,P,T){var Z=vl(s,h),F=vl(l,h),B=T.get(F);if(B){Ya(s,h,B);return}var R=P?P(Z,F,h+"",s,l,T):t,J=R===t;if(J){var $=he(F),te=!$&&hi(F),oe=!$&&!te&&lr(F);R=F,$||te||oe?he(Z)?R=Z:ke(Z)?R=Pt(Z):te?(J=!1,R=$h(F,!0)):oe?(J=!1,R=qh(F,!0)):R=[]:Er(F)||Oi(F)?(R=Z,Oi(Z)?R=Qd(Z):(!Fe(Z)||An(Z))&&(R=yd(F))):J=!1}J&&(T.set(F,R),_(R,F,y,P,T),T.delete(F)),Ya(s,h,R)}function kh(s,l){var h=s.length;if(h)return l+=l<0?h:0,In(l,h)?s[l]:t}function Kh(s,l,h){l.length?l=Ae(l,function(P){return he(P)?function(T){return Ii(T,P.length===1?P[0]:P)}:P}):l=[Gt];var y=-1;l=Ae(l,Ft(se()));var _=zh(s,function(P,T,Z){var F=Ae(l,function(B){return B(P)});return{criteria:F,index:++y,value:P}});return db(_,function(P,T){return $1(P,T,h)})}function U1(s,l){return Nh(s,l,function(h,y){return Cl(s,y)})}function Nh(s,l,h){for(var y=-1,_=l.length,P={};++y<_;){var T=l[y],Z=Ii(s,T);h(Z,T)&&jr(P,ci(T,s),Z)}return P}function k1(s){return function(l){return Ii(l,s)}}function el(s,l,h,y){var _=y?hb:Ei,P=-1,T=l.length,Z=s;for(s===l&&(l=Pt(l)),h&&(Z=Ae(s,Ft(h)));++P<T;)for(var F=0,B=l[P],R=h?h(B):B;(F=_(Z,R,F,y))>-1;)Z!==s&&Ns.call(Z,F,1),Ns.call(s,F,1);return s}function Bh(s,l){for(var h=s?l.length:0,y=h-1;h--;){var _=l[h];if(h==y||_!==P){var P=_;In(_)?Ns.call(s,_,1):rl(s,_)}}return s}function tl(s,l){return s+Rs(Sh()*(l-s+1))}function K1(s,l,h,y){for(var _=-1,P=Je(Ys((l-s)/(h||1)),0),T=U(P);P--;)T[y?P:++_]=s,s+=h;return T}function nl(s,l){var h="";if(!s||l<1||l>ie)return h;do l%2&&(h+=s),l=Rs(l/2),l&&(s+=s);while(l);return h}function ye(s,l){return _l(wd(s,l,Gt),s+"")}function N1(s){return Ch(cr(s))}function B1(s,l){var h=cr(s);return co(h,Vi(l,0,h.length))}function jr(s,l,h,y){if(!Fe(s))return s;l=ci(l,s);for(var _=-1,P=l.length,T=P-1,Z=s;Z!=null&&++_<P;){var F=Mn(l[_]),B=h;if(F==="__proto__"||F==="constructor"||F==="prototype")return s;if(_!=T){var R=Z[F];B=y?y(R,F,Z):t,B===t&&(B=Fe(R)?R:In(l[_+1])?[]:{})}Nr(Z,F,B),Z=Z[F]}return s}var Yh=js?function(s,l){return js.set(s,l),s}:Gt,Y1=Bs?function(s,l){return Bs(s,"toString",{configurable:!0,enumerable:!1,value:Gl(l),writable:!0})}:Gt;function R1(s){return co(cr(s))}function Ht(s,l,h){var y=-1,_=s.length;l<0&&(l=-l>_?0:_+l),h=h>_?_:h,h<0&&(h+=_),_=l>h?0:h-l>>>0,l>>>=0;for(var P=U(_);++y<_;)P[y]=s[y+l];return P}function j1(s,l){var h;return ai(s,function(y,_,P){return h=l(y,_,P),!h}),!!h}function eo(s,l,h){var y=0,_=s==null?y:s.length;if(typeof l=="number"&&l===l&&_<=Se){for(;y<_;){var P=y+_>>>1,T=s[P];T!==null&&!Dt(T)&&(h?T<=l:T<l)?y=P+1:_=P}return _}return il(s,l,Gt,h)}function il(s,l,h,y){var _=0,P=s==null?0:s.length;if(P===0)return 0;l=h(l);for(var T=l!==l,Z=l===null,F=Dt(l),B=l===t;_<P;){var R=Rs((_+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||$):Z?ae=oe&&$&&(y||!te):F?ae=oe&&$&&!te&&(y||!me):te||me?ae=!1:ae=y?J<=l:J<l;ae?_=R+1:P=R}return pt(P,fe)}function Rh(s,l){for(var h=-1,y=s.length,_=0,P=[];++h<y;){var T=s[h],Z=l?l(T):T;if(!h||!un(Z,F)){var F=Z;P[_++]=T===0?0:T}}return P}function jh(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 Lh?Lh.call(s):"";var l=s+"";return l=="0"&&1/s==-re?"-0":l}function li(s,l,h){var y=-1,_=Is,P=s.length,T=!0,Z=[],F=Z;if(h)T=!1,_=Va;else if(P>=i){var B=l?null:rx(s);if(B)return Fs(B);T=!1,_=Dr,F=new Zi}else F=l?[]:Z;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),Z.push(R)}else _(F,J,h)||(F!==Z&&F.push(J),Z.push(R))}return Z}function rl(s,l){return l=ci(l,s),s=bd(s,l),s==null||delete s[Mn(Et(l))]}function Jh(s,l,h,y){return jr(s,l,h(Ii(s,l)),y)}function to(s,l,h,y){for(var _=s.length,P=y?_:-1;(y?P--:++P<_)&&l(s[P],P,s););return h?Ht(s,y?0:P,y?P+1:_):Ht(s,y?P+1:0,y?_:P)}function Qh(s,l){var h=s;return h instanceof be&&(h=h.value()),Ia(l,function(y,_){return _.func.apply(_.thisArg,ri([y],_.args))},h)}function sl(s,l,h){var y=s.length;if(y<2)return y?li(s[0]):[];for(var _=-1,P=U(y);++_<y;)for(var T=s[_],Z=-1;++Z<y;)Z!=_&&(P[_]=Br(P[_]||T,s[Z],l,h));return li(lt(P,1),l,h)}function Hh(s,l,h){for(var y=-1,_=s.length,P=l.length,T={};++y<_;){var Z=y<P?l[y]:t;h(T,s[y],Z)}return T}function ol(s){return ke(s)?s:[]}function al(s){return typeof s=="function"?s:Gt}function ci(s,l){return he(s)?s:gl(s,l)?[s]:Ld(Pe(s))}var J1=ye;function ui(s,l,h){var y=s.length;return h=h===t?y:h,!l&&h>=y?s:Ht(s,l,h)}var Eh=Fb||function(s){return at.clearTimeout(s)};function $h(s,l){if(l)return s.slice();var h=s.length,y=_h?_h(h):new s.constructor(h);return s.copy(y),y}function ll(s){var l=new s.constructor(s.byteLength);return new ks(l).set(new ks(s)),l}function Q1(s,l){var h=l?ll(s.buffer):s.buffer;return new s.constructor(h,s.byteOffset,s.byteLength)}function H1(s){var l=new s.constructor(s.source,Fu.exec(s));return l.lastIndex=s.lastIndex,l}function E1(s){return Kr?Ge(Kr.call(s)):{}}function qh(s,l){var h=l?ll(s.buffer):s.buffer;return new s.constructor(h,s.byteOffset,s.length)}function ed(s,l){if(s!==l){var h=s!==t,y=s===null,_=s===s,P=Dt(s),T=l!==t,Z=l===null,F=l===l,B=Dt(l);if(!Z&&!B&&!P&&s>l||P&&T&&F&&!Z&&!B||y&&T&&F||!h&&F||!_)return 1;if(!y&&!P&&!B&&s<l||B&&h&&_&&!y&&!P||Z&&h&&_||!T&&_||!F)return-1}return 0}function $1(s,l,h){for(var y=-1,_=s.criteria,P=l.criteria,T=_.length,Z=h.length;++y<T;){var F=ed(_[y],P[y]);if(F){if(y>=Z)return F;var B=h[y];return F*(B=="desc"?-1:1)}}return s.index-l.index}function td(s,l,h,y){for(var _=-1,P=s.length,T=h.length,Z=-1,F=l.length,B=Je(P-T,0),R=U(F+B),J=!y;++Z<F;)R[Z]=l[Z];for(;++_<T;)(J||_<P)&&(R[h[_]]=s[_]);for(;B--;)R[Z++]=s[_++];return R}function nd(s,l,h,y){for(var _=-1,P=s.length,T=-1,Z=h.length,F=-1,B=l.length,R=Je(P-Z,0),J=U(R+B),$=!y;++_<R;)J[_]=s[_];for(var te=_;++F<B;)J[te+F]=l[F];for(;++T<Z;)($||_<P)&&(J[te+h[T]]=s[_++]);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 _=!h;h||(h={});for(var P=-1,T=l.length;++P<T;){var Z=l[P],F=y?y(h[Z],s[Z],Z,h,s):t;F===t&&(F=s[Z]),_?Wn(h,Z,F):Nr(h,Z,F)}return h}function q1(s,l){return xn(s,ml(s),l)}function ex(s,l){return xn(s,md(s),l)}function no(s,l){return function(h,y){var _=he(h)?sb:x1,P=l?l():{};return _(h,s,se(y,2),P)}}function sr(s){return ye(function(l,h){var y=-1,_=h.length,P=_>1?h[_-1]:t,T=_>2?h[2]:t;for(P=s.length>3&&typeof P=="function"?(_--,P):t,T&&_t(h[0],h[1],T)&&(P=_<3?t:P,_=1),l=Ge(l);++y<_;){var Z=h[y];Z&&s(l,Z,y,P)}return l})}function id(s,l){return function(h,y){if(h==null)return h;if(!Ct(h))return s(h,y);for(var _=h.length,P=l?_:-1,T=Ge(h);(l?P--:++P<_)&&y(T[P],P,T)!==!1;);return h}}function rd(s){return function(l,h,y){for(var _=-1,P=Ge(l),T=y(l),Z=T.length;Z--;){var F=T[s?Z:++_];if(h(P[F],F,P)===!1)break}return l}}function tx(s,l,h){var y=l&x,_=Jr(s);function P(){var T=this&&this!==at&&this instanceof P?_:s;return T.apply(y?h:this,arguments)}return P}function sd(s){return function(l){l=Pe(l);var h=$i(l)?ln(l):t,y=h?h[0]:l.charAt(0),_=h?ui(h,1).join(""):l.slice(1);return y[s]()+_}}function or(s){return function(l){return Ia(rf(nf(l).replace(Yw,"")),s,"")}}function Jr(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=rr(s.prototype),y=s.apply(h,l);return Fe(y)?y:h}}function nx(s,l,h){var y=Jr(s);function _(){for(var P=arguments.length,T=U(P),Z=P,F=ar(_);Z--;)T[Z]=arguments[Z];var B=P<3&&T[0]!==F&&T[P-1]!==F?[]:si(T,F);if(P-=B.length,P<h)return ud(s,l,io,_.placeholder,t,T,B,t,t,h-P);var R=this&&this!==at&&this instanceof _?y:s;return At(R,this,T)}return _}function od(s){return function(l,h,y){var _=Ge(l);if(!Ct(l)){var P=se(h,3);l=He(l),h=function(Z){return P(_[Z],Z,_)}}var T=s(l,h,y);return T>-1?_[P?l[T]:T]:t}}function ad(s){return Vn(function(l){var h=l.length,y=h,_=Jt.prototype.thru;for(s&&l.reverse();y--;){var P=l[y];if(typeof P!="function")throw new jt(a);if(_&&!T&&ao(P)=="wrapper")var T=new Jt([],!0)}for(y=T?y:h;++y<h;){P=l[y];var Z=ao(P),F=Z=="wrapper"?fl(P):t;F&&yl(F[0])&&F[1]==(X|C|z|I)&&!F[4].length&&F[9]==1?T=T[ao(F[0])].apply(T,F[3]):T=P.length==1&&yl(P)?T[Z]():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 io(s,l,h,y,_,P,T,Z,F,B){var R=l&X,J=l&x,$=l&L,te=l&(C|W),oe=l&K,me=$?t:Jr(s);function ae(){for(var we=arguments.length,xe=U(we),zt=we;zt--;)xe[zt]=arguments[zt];if(te)var wt=ar(ae),Xt=pb(xe,wt);if(y&&(xe=td(xe,y,_,te)),P&&(xe=nd(xe,P,T,te)),we-=Xt,te&&we<B){var Ke=si(xe,wt);return ud(s,l,io,ae.placeholder,h,xe,Ke,Z,F,B-we)}var hn=J?h:this,On=$?hn[s]:s;return we=xe.length,Z?xe=xx(xe,Z):oe&&we>1&&xe.reverse(),R&&F<we&&(xe.length=F),this&&this!==at&&this instanceof ae&&(On=me||Jr(On)),On.apply(hn,xe)}return ae}function ld(s,l){return function(h,y){return W1(h,s,l(y),{})}}function ro(s,l){return function(h,y){var _;if(h===t&&y===t)return l;if(h!==t&&(_=h),y!==t){if(_===t)return y;typeof h=="string"||typeof y=="string"?(h=Ot(h),y=Ot(y)):(h=jh(h),y=jh(y)),_=s(h,y)}return _}}function cl(s){return Vn(function(l){return l=Ae(l,Ft(se())),ye(function(h){var y=this;return s(l,function(_){return At(_,y,h)})})})}function so(s,l){l=l===t?" ":Ot(l);var h=l.length;if(h<2)return h?nl(l,s):l;var y=nl(l,Ys(s/qi(l)));return $i(l)?ui(ln(y),0,s).join(""):y.slice(0,s)}function ix(s,l,h,y){var _=l&x,P=Jr(s);function T(){for(var Z=-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[++Z];return At($,_?h:this,J)}return T}function cd(s){return function(l,h,y){return y&&typeof y!="number"&&_t(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),K1(l,h,y,s)}}function oo(s){return function(l,h){return typeof l=="string"&&typeof h=="string"||(l=$t(l),h=$t(h)),s(l,h)}}function ud(s,l,h,y,_,P,T,Z,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,_,te,J,oe,$,Z,F,B],ae=h.apply(t,me);return yl(s)&&xd(ae,me),ae.placeholder=y,Md(ae,s,l)}function ul(s){var l=je[s];return function(h,y){if(h=$t(h),y=y==null?0:pt(pe(y),292),y&&Mh(h)){var _=(Pe(h)+"e").split("e"),P=l(_[0]+"e"+(+_[1]+y));return _=(Pe(P)+"e").split("e"),+(_[0]+"e"+(+_[1]-y))}return l(h)}}var rx=nr&&1/Fs(new nr([,-0]))[1]==re?function(s){return new nr(s)}:Vl;function hd(s){return function(l){var h=mt(l);return h==Ce?Ua(l):h==It?bb(l):fb(l,s(l))}}function Zn(s,l,h,y,_,P,T,Z){var F=l&L;if(!F&&typeof s!="function")throw new jt(a);var B=y?y.length:0;if(B||(l&=-97,y=_=t),T=T===t?T:Je(pe(T),0),Z=Z===t?Z:pe(Z),B-=_?_.length:0,l&D){var R=y,J=_;y=_=t}var $=F?t:fl(s),te=[s,l,h,y,_,R,J,P,T,Z];if($&&_x(te,$),s=te[0],l=te[1],h=te[2],y=te[3],_=te[4],Z=te[9]=te[9]===t?F?0:s.length:Je(te[9]-B,0),!Z&&l&(C|W)&&(l&=-25),!l||l==x)var oe=tx(s,l,h);else l==C||l==W?oe=nx(s,l,Z):(l==z||l==(x|z))&&!_.length?oe=ix(s,l,h,y):oe=io.apply(t,te);var me=$?Yh:xd;return Md(me(oe,te),s,l)}function dd(s,l,h,y){return s===t||un(s,tr[h])&&!Te.call(y,h)?l:s}function fd(s,l,h,y,_,P){return Fe(s)&&Fe(l)&&(P.set(l,s),qs(s,l,t,fd,P),P.delete(l)),s}function sx(s){return Er(s)?t:s}function pd(s,l,h,y,_,P){var T=h&w,Z=s.length,F=l.length;if(Z!=F&&!(T&&F>Z))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 Zi:t;for(P.set(s,l),P.set(l,s);++J<Z;){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(!Aa(l,function(we,xe){if(!Dr(te,xe)&&(oe===we||_(oe,we,h,y,P)))return te.push(xe)})){$=!1;break}}else if(!(oe===me||_(oe,me,h,y,P))){$=!1;break}}return P.delete(s),P.delete(l),$}function ox(s,l,h,y,_,P,T){switch(h){case wn:if(s.byteLength!=l.byteLength||s.byteOffset!=l.byteOffset)return!1;s=s.buffer,l=l.buffer;case ti:return!(s.byteLength!=l.byteLength||!P(new ks(s),new ks(l)));case Ye:case Re:case ot:return un(+s,+l);case ze:return s.name==l.name&&s.message==l.message;case xi:case qn:return s==l+"";case Ce:var Z=Ua;case It:var F=y&w;if(Z||(Z=Fs),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=pd(Z(s),Z(l),y,_,P,T);return T.delete(s),R;case ei:if(Kr)return Kr.call(s)==Kr.call(l)}return!1}function ax(s,l,h,y,_,P){var T=h&w,Z=hl(s),F=Z.length,B=hl(l),R=B.length;if(F!=R&&!T)return!1;for(var J=F;J--;){var $=Z[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;){$=Z[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||_(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 _l(wd(s,t,Gd),s+"")}function hl(s){return Ah(s,He,ml)}function dl(s){return Ah(s,Tt,md)}var fl=js?function(s){return js.get(s)}:Vl;function ao(s){for(var l=s.name+"",h=ir[l],y=Te.call(ir,l)?h.length:0;y--;){var _=h[y],P=_.func;if(P==null||P==s)return _.name}return l}function ar(s){var l=Te.call(S,"placeholder")?S:s;return l.placeholder}function se(){var s=S.iteratee||Wl;return s=s===Wl?Dh:s,arguments.length?s(arguments[0],arguments[1]):s}function lo(s,l){var h=s.__data__;return mx(l)?h[typeof l=="string"?"string":"hash"]:h.map}function pl(s){for(var l=He(s),h=l.length;h--;){var y=l[h],_=s[y];l[h]=[y,_,vd(_)]}return l}function Ai(s,l){var h=vb(s,l);return Oh(h)?h:t}function lx(s){var l=Te.call(s,Gi),h=s[Gi];try{s[Gi]=t;var y=!0}catch{}var _=Xs.call(s);return y&&(l?s[Gi]=h:delete s[Gi]),_}var ml=Ka?function(s){return s==null?[]:(s=Ge(s),ii(Ka(s),function(l){return bh.call(s,l)}))}:Il,md=Ka?function(s){for(var l=[];s;)ri(l,ml(s)),s=Ks(s);return l}:Il,mt=vt;(Na&&mt(new Na(new ArrayBuffer(1)))!=wn||Xr&&mt(new Xr)!=Ce||Ba&&mt(Ba.resolve())!=bi||nr&&mt(new nr)!=It||Ur&&mt(new Ur)!=Si)&&(mt=function(s){var l=vt(s),h=l==Lt?s.constructor:t,y=h?Fi(h):"";if(y)switch(y){case Bb:return wn;case Yb:return Ce;case Rb:return bi;case jb:return It;case Jb:return Si}return l});function cx(s,l,h){for(var y=-1,_=h.length;++y<_;){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 ux(s){var l=s.match(gw);return l?l[1].split(yw):[]}function gd(s,l,h){l=ci(l,s);for(var y=-1,_=l.length,P=!1;++y<_;){var T=Mn(l[y]);if(!(P=s!=null&&h(s,T)))break;s=s[T]}return P||++y!=_?P:(_=s==null?0:s.length,!!_&&go(_)&&In(T,_)&&(he(s)||Oi(s)))}function hx(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 yd(s){return typeof s.constructor=="function"&&!Qr(s)?rr(Ks(s)):{}}function dx(s,l,h){var y=s.constructor;switch(l){case ti:return ll(s);case Ye:case Re:return new y(+s);case wn:return Q1(s,h);case Ir:case Ar:case ji:case Fr:case Or:case Ji:case Li:case O:case E:return qh(s,h);case Ce:return new y;case ot:case qn:return new y(s);case xi:return H1(s);case It:return new y;case ei:return E1(s)}}function fx(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(mw,`{
955
+ /* [wrapped with `+l+`] */
956
+ `)}function px(s){return he(s)||Oi(s)||!!(xh&&s&&s[xh])}function In(s,l){var h=typeof s;return l=l??ie,!!l&&(h=="number"||h!="symbol"&&Pw.test(s))&&s>-1&&s%1==0&&s<l}function _t(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 gl(s,l){if(he(s))return!1;var h=typeof s;return h=="number"||h=="symbol"||h=="boolean"||s==null||Dt(s)?!0:Ci.test(s)||!Pi.test(s)||l!=null&&s in Ge(l)}function mx(s){var l=typeof s;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?s!=="__proto__":s===null}function yl(s){var l=ao(s),h=S[l];if(typeof h!="function"||!(l in be.prototype))return!1;if(s===h)return!0;var y=fl(h);return!!y&&s===y[0]}function gx(s){return!!vh&&vh in s}var yx=Ds?An:Al;function Qr(s){var l=s&&s.constructor,h=typeof l=="function"&&l.prototype||tr;return s===h}function vd(s){return s===s&&!Fe(s)}function _d(s,l){return function(h){return h==null?!1:h[s]===l&&(l!==t||s in Ge(h))}}function vx(s){var l=po(s,function(y){return h.size===d&&h.clear(),y}),h=l.cache;return l}function _x(s,l){var h=s[1],y=l[1],_=h|y,P=_<(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],_|=h&x?0:M);var Z=l[3];if(Z){var F=s[3];s[3]=F?td(F,Z,l[4]):Z,s[4]=F?si(s[3],m):l[4]}return Z=l[5],Z&&(F=s[5],s[5]=F?nd(F,Z,l[6]):Z,s[6]=F?si(s[5],m):l[6]),Z=l[7],Z&&(s[7]=Z),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]=_,s}function wx(s){var l=[];if(s!=null)for(var h in Ge(s))l.push(h);return l}function bx(s){return Xs.call(s)}function wd(s,l,h){return l=Je(l===t?s.length-1:l,0),function(){for(var y=arguments,_=-1,P=Je(y.length-l,0),T=U(P);++_<P;)T[_]=y[l+_];_=-1;for(var Z=U(l+1);++_<l;)Z[_]=y[_];return Z[l]=h(T),At(s,this,Z)}}function bd(s,l){return l.length<2?s:Ii(s,Ht(l,0,-1))}function xx(s,l){for(var h=s.length,y=pt(l.length,h),_=Pt(s);y--;){var P=l[y];s[y]=In(P,h)?_[P]:t}return s}function vl(s,l){if(!(l==="constructor"&&typeof s[l]=="function")&&l!="__proto__")return s[l]}var xd=Sd(Yh),Hr=Db||function(s,l){return at.setTimeout(s,l)},_l=Sd(Y1);function Md(s,l,h){var y=l+"";return _l(s,fx(y,Mx(ux(y),h)))}function Sd(s){var l=0,h=0;return function(){var y=kb(),_=j-(y-h);if(h=y,_>0){if(++l>=k)return arguments[0]}else l=0;return s.apply(t,arguments)}}function co(s,l){var h=-1,y=s.length,_=y-1;for(l=l===t?y:l;++h<l;){var P=tl(h,_),T=s[P];s[P]=s[h],s[h]=T}return s.length=l,s}var Ld=vx(function(s){var l=[];return s.charCodeAt(0)===46&&l.push(""),s.replace(Qi,function(h,y,_,P){l.push(_?P.replace(ww,"$1"):y||h)}),l});function Mn(s){if(typeof s=="string"||Dt(s))return s;var l=s+"";return l=="0"&&1/s==-re?"-0":l}function Fi(s){if(s!=null){try{return zs.call(s)}catch{}try{return s+""}catch{}}return""}function Mx(s,l){return Rt(it,function(h){var y="_."+h[0];l&h[1]&&!Is(s,y)&&s.push(y)}),s.sort()}function Pd(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 Sx(s,l,h){(h?_t(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 _=0,P=0,T=U(Ys(y/l));_<y;)T[P++]=Ht(s,_,_+=l);return T}function Lx(s){for(var l=-1,h=s==null?0:s.length,y=0,_=[];++l<h;){var P=s[l];P&&(_[y++]=P)}return _}function Px(){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 ri(he(h)?Pt(h):[h],lt(l,1))}var Cx=ye(function(s,l){return ke(s)?Br(s,lt(l,1,ke,!0)):[]}),Tx=ye(function(s,l){var h=Et(l);return ke(h)&&(h=t),ke(s)?Br(s,lt(l,1,ke,!0),se(h,2)):[]}),Gx=ye(function(s,l){var h=Et(l);return ke(h)&&(h=t),ke(s)?Br(s,lt(l,1,ke,!0),t,h):[]});function Wx(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 Zx(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 Vx(s,l){return s&&s.length?to(s,se(l,3),!0,!0):[]}function Ix(s,l){return s&&s.length?to(s,se(l,3),!0):[]}function Ax(s,l,h,y){var _=s==null?0:s.length;return _?(h&&typeof h!="number"&&_t(s,l,h)&&(h=0,y=_),P1(s,l,h,y)):[]}function Cd(s,l,h){var y=s==null?0:s.length;if(!y)return-1;var _=h==null?0:pe(h);return _<0&&(_=Je(y+_,0)),As(s,se(l,3),_)}function Td(s,l,h){var y=s==null?0:s.length;if(!y)return-1;var _=y-1;return h!==t&&(_=pe(h),_=h<0?Je(y+_,0):pt(_,y-1)),As(s,se(l,3),_,!0)}function Gd(s){var l=s==null?0:s.length;return l?lt(s,1):[]}function Fx(s){var l=s==null?0:s.length;return l?lt(s,re):[]}function Ox(s,l){var h=s==null?0:s.length;return h?(l=l===t?1:pe(l),lt(s,l)):[]}function Dx(s){for(var l=-1,h=s==null?0:s.length,y={};++l<h;){var _=s[l];y[_[0]]=_[1]}return y}function Wd(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 _=h==null?0:pe(h);return _<0&&(_=Je(y+_,0)),Ei(s,l,_)}function Xx(s){var l=s==null?0:s.length;return l?Ht(s,0,-1):[]}var Ux=ye(function(s){var l=Ae(s,ol);return l.length&&l[0]===s[0]?Ha(l):[]}),kx=ye(function(s){var l=Et(s),h=Ae(s,ol);return l===Et(h)?l=t:h.pop(),h.length&&h[0]===s[0]?Ha(h,se(l,2)):[]}),Kx=ye(function(s){var l=Et(s),h=Ae(s,ol);return l=typeof l=="function"?l:t,l&&h.pop(),h.length&&h[0]===s[0]?Ha(h,t,l):[]});function Nx(s,l){return s==null?"":Xb.call(s,l)}function Et(s){var l=s==null?0:s.length;return l?s[l-1]:t}function Bx(s,l,h){var y=s==null?0:s.length;if(!y)return-1;var _=y;return h!==t&&(_=pe(h),_=_<0?Je(y+_,0):pt(_,y-1)),l===l?Mb(s,l,_):As(s,uh,_,!0)}function Yx(s,l){return s&&s.length?kh(s,pe(l)):t}var Rx=ye(Zd);function Zd(s,l){return s&&s.length&&l&&l.length?el(s,l):s}function jx(s,l,h){return s&&s.length&&l&&l.length?el(s,l,se(h,2)):s}function Jx(s,l,h){return s&&s.length&&l&&l.length?el(s,l,t,h):s}var Qx=Vn(function(s,l){var h=s==null?0:s.length,y=Ra(s,l);return Bh(s,Ae(l,function(_){return In(_,h)?+_:_}).sort(ed)),y});function Hx(s,l){var h=[];if(!(s&&s.length))return h;var y=-1,_=[],P=s.length;for(l=se(l,3);++y<P;){var T=s[y];l(T,y,s)&&(h.push(T),_.push(y))}return Bh(s,_),h}function wl(s){return s==null?s:Nb.call(s)}function Ex(s,l,h){var y=s==null?0:s.length;return y?(h&&typeof h!="number"&&_t(s,l,h)?(l=0,h=y):(l=l==null?0:pe(l),h=h===t?y:pe(h)),Ht(s,l,h)):[]}function $x(s,l){return eo(s,l)}function qx(s,l,h){return il(s,l,se(h,2))}function eM(s,l){var h=s==null?0:s.length;if(h){var y=eo(s,l);if(y<h&&un(s[y],l))return y}return-1}function tM(s,l){return eo(s,l,!0)}function nM(s,l,h){return il(s,l,se(h,2),!0)}function iM(s,l){var h=s==null?0:s.length;if(h){var y=eo(s,l,!0)-1;if(un(s[y],l))return y}return-1}function rM(s){return s&&s.length?Rh(s):[]}function sM(s,l){return s&&s.length?Rh(s,se(l,2)):[]}function oM(s){var l=s==null?0:s.length;return l?Ht(s,1,l):[]}function aM(s,l,h){return s&&s.length?(l=h||l===t?1:pe(l),Ht(s,0,l<0?0:l)):[]}function lM(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 cM(s,l){return s&&s.length?to(s,se(l,3),!1,!0):[]}function uM(s,l){return s&&s.length?to(s,se(l,3)):[]}var hM=ye(function(s){return li(lt(s,1,ke,!0))}),dM=ye(function(s){var l=Et(s);return ke(l)&&(l=t),li(lt(s,1,ke,!0),se(l,2))}),fM=ye(function(s){var l=Et(s);return l=typeof l=="function"?l:t,li(lt(s,1,ke,!0),t,l)});function pM(s){return s&&s.length?li(s):[]}function mM(s,l){return s&&s.length?li(s,se(l,2)):[]}function gM(s,l){return l=typeof l=="function"?l:t,s&&s.length?li(s,t,l):[]}function bl(s){if(!(s&&s.length))return[];var l=0;return s=ii(s,function(h){if(ke(h))return l=Je(h.length,l),!0}),za(l,function(h){return Ae(s,Fa(h))})}function Vd(s,l){if(!(s&&s.length))return[];var h=bl(s);return l==null?h:Ae(h,function(y){return At(l,t,y)})}var yM=ye(function(s,l){return ke(s)?Br(s,l):[]}),vM=ye(function(s){return sl(ii(s,ke))}),_M=ye(function(s){var l=Et(s);return ke(l)&&(l=t),sl(ii(s,ke),se(l,2))}),wM=ye(function(s){var l=Et(s);return l=typeof l=="function"?l:t,sl(ii(s,ke),t,l)}),bM=ye(bl);function xM(s,l){return Hh(s||[],l||[],Nr)}function MM(s,l){return Hh(s||[],l||[],jr)}var SM=ye(function(s){var l=s.length,h=l>1?s[l-1]:t;return h=typeof h=="function"?(s.pop(),h):t,Vd(s,h)});function Id(s){var l=S(s);return l.__chain__=!0,l}function LM(s,l){return l(s),s}function uo(s,l){return l(s)}var PM=Vn(function(s){var l=s.length,h=l?s[0]:0,y=this.__wrapped__,_=function(P){return Ra(P,s)};return l>1||this.__actions__.length||!(y instanceof be)||!In(h)?this.thru(_):(y=y.slice(h,+h+(l?1:0)),y.__actions__.push({func:uo,args:[_],thisArg:t}),new Jt(y,this.__chain__).thru(function(P){return l&&!P.length&&P.push(t),P}))});function CM(){return Id(this)}function TM(){return new Jt(this.value(),this.__chain__)}function GM(){this.__values__===t&&(this.__values__=jd(this.value()));var s=this.__index__>=this.__values__.length,l=s?t:this.__values__[this.__index__++];return{done:s,value:l}}function WM(){return this}function ZM(s){for(var l,h=this;h instanceof Qs;){var y=Pd(h);y.__index__=0,y.__values__=t,l?_.__wrapped__=y:l=y;var _=y;h=h.__wrapped__}return _.__wrapped__=s,l}function VM(){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:uo,args:[wl],thisArg:t}),new Jt(l,this.__chain__)}return this.thru(wl)}function IM(){return Qh(this.__wrapped__,this.__actions__)}var AM=no(function(s,l,h){Te.call(s,h)?++s[h]:Wn(s,h,1)});function FM(s,l,h){var y=he(s)?lh:L1;return h&&_t(s,l,h)&&(l=t),y(s,se(l,3))}function OM(s,l){var h=he(s)?ii:Vh;return h(s,se(l,3))}var DM=od(Cd),zM=od(Td);function XM(s,l){return lt(ho(s,l),1)}function UM(s,l){return lt(ho(s,l),re)}function kM(s,l,h){return h=h===t?1:pe(h),lt(ho(s,l),h)}function Ad(s,l){var h=he(s)?Rt:ai;return h(s,se(l,3))}function Fd(s,l){var h=he(s)?ob:Zh;return h(s,se(l,3))}var KM=no(function(s,l,h){Te.call(s,h)?s[h].push(l):Wn(s,h,[l])});function NM(s,l,h,y){s=Ct(s)?s:cr(s),h=h&&!y?pe(h):0;var _=s.length;return h<0&&(h=Je(_+h,0)),yo(s)?h<=_&&s.indexOf(l,h)>-1:!!_&&Ei(s,l,h)>-1}var BM=ye(function(s,l,h){var y=-1,_=typeof l=="function",P=Ct(s)?U(s.length):[];return ai(s,function(T){P[++y]=_?At(l,T,h):Yr(T,l,h)}),P}),YM=no(function(s,l,h){Wn(s,h,l)});function ho(s,l){var h=he(s)?Ae:zh;return h(s,se(l,3))}function RM(s,l,h,y){return s==null?[]:(he(l)||(l=l==null?[]:[l]),h=y?t:h,he(h)||(h=h==null?[]:[h]),Kh(s,l,h))}var jM=no(function(s,l,h){s[h?0:1].push(l)},function(){return[[],[]]});function JM(s,l,h){var y=he(s)?Ia:dh,_=arguments.length<3;return y(s,se(l,4),h,_,ai)}function QM(s,l,h){var y=he(s)?ab:dh,_=arguments.length<3;return y(s,se(l,4),h,_,Zh)}function HM(s,l){var h=he(s)?ii:Vh;return h(s,mo(se(l,3)))}function EM(s){var l=he(s)?Ch:N1;return l(s)}function $M(s,l,h){(h?_t(s,l,h):l===t)?l=1:l=pe(l);var y=he(s)?w1:B1;return y(s,l)}function qM(s){var l=he(s)?b1:R1;return l(s)}function eS(s){if(s==null)return 0;if(Ct(s))return yo(s)?qi(s):s.length;var l=mt(s);return l==Ce||l==It?s.size:$a(s).length}function tS(s,l,h){var y=he(s)?Aa:j1;return h&&_t(s,l,h)&&(l=t),y(s,se(l,3))}var nS=ye(function(s,l){if(s==null)return[];var h=l.length;return h>1&&_t(s,l[0],l[1])?l=[]:h>2&&_t(l[0],l[1],l[2])&&(l=[l[0]]),Kh(s,lt(l,1),[])}),fo=Ob||function(){return at.Date.now()};function iS(s,l){if(typeof l!="function")throw new jt(a);return s=pe(s),function(){if(--s<1)return l.apply(this,arguments)}}function Od(s,l,h){return l=h?t:l,l=s&&l==null?s.length:l,Zn(s,X,t,t,t,t,l)}function Dd(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 xl=ye(function(s,l,h){var y=x;if(h.length){var _=si(h,ar(xl));y|=z}return Zn(s,y,l,h,_)}),zd=ye(function(s,l,h){var y=x|L;if(h.length){var _=si(h,ar(zd));y|=z}return Zn(l,y,s,h,_)});function Xd(s,l,h){l=h?t:l;var y=Zn(s,C,t,t,t,t,t,l);return y.placeholder=Xd.placeholder,y}function Ud(s,l,h){l=h?t:l;var y=Zn(s,W,t,t,t,t,t,l);return y.placeholder=Ud.placeholder,y}function kd(s,l,h){var y,_,P,T,Z,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=_;return y=_=t,B=Ke,T=s.apply(On,hn),T}function oe(Ke){return B=Ke,Z=Hr(we,l),R?te(Ke):T}function me(Ke){var hn=Ke-F,On=Ke-B,af=l-hn;return J?pt(af,P-On):af}function ae(Ke){var hn=Ke-F,On=Ke-B;return F===t||hn>=l||hn<0||J&&On>=P}function we(){var Ke=fo();if(ae(Ke))return xe(Ke);Z=Hr(we,me(Ke))}function xe(Ke){return Z=t,$&&y?te(Ke):(y=_=t,T)}function zt(){Z!==t&&Eh(Z),B=0,y=F=_=Z=t}function wt(){return Z===t?T:xe(fo())}function Xt(){var Ke=fo(),hn=ae(Ke);if(y=arguments,_=this,F=Ke,hn){if(Z===t)return oe(F);if(J)return Eh(Z),Z=Hr(we,l),te(F)}return Z===t&&(Z=Hr(we,l)),T}return Xt.cancel=zt,Xt.flush=wt,Xt}var rS=ye(function(s,l){return Wh(s,1,l)}),sS=ye(function(s,l,h){return Wh(s,$t(l)||0,h)});function oS(s){return Zn(s,K)}function po(s,l){if(typeof s!="function"||l!=null&&typeof l!="function")throw new jt(a);var h=function(){var y=arguments,_=l?l.apply(this,y):y[0],P=h.cache;if(P.has(_))return P.get(_);var T=s.apply(this,y);return h.cache=P.set(_,T)||P,T};return h.cache=new(po.Cache||Gn),h}po.Cache=Gn;function mo(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 aS(s){return Dd(2,s)}var lS=J1(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 _=-1,P=pt(y.length,h);++_<P;)y[_]=l[_].call(this,y[_]);return At(s,this,y)})}),Ml=ye(function(s,l){var h=si(l,ar(Ml));return Zn(s,z,t,l,h)}),Kd=ye(function(s,l){var h=si(l,ar(Kd));return Zn(s,D,t,l,h)}),cS=Vn(function(s,l){return Zn(s,I,t,t,t,l)});function uS(s,l){if(typeof s!="function")throw new jt(a);return l=l===t?l:pe(l),ye(s,l)}function hS(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],_=ui(h,0,l);return y&&ri(_,y),At(s,this,_)})}function dS(s,l,h){var y=!0,_=!0;if(typeof s!="function")throw new jt(a);return Fe(h)&&(y="leading"in h?!!h.leading:y,_="trailing"in h?!!h.trailing:_),kd(s,l,{leading:y,maxWait:l,trailing:_})}function fS(s){return Od(s,1)}function pS(s,l){return Ml(al(l),s)}function mS(){if(!arguments.length)return[];var s=arguments[0];return he(s)?s:[s]}function gS(s){return Qt(s,v)}function yS(s,l){return l=typeof l=="function"?l:t,Qt(s,v,l)}function vS(s){return Qt(s,f|v)}function _S(s,l){return l=typeof l=="function"?l:t,Qt(s,f|v,l)}function wS(s,l){return l==null||Gh(s,l,He(l))}function un(s,l){return s===l||s!==s&&l!==l}var bS=oo(Qa),xS=oo(function(s,l){return s>=l}),Oi=Fh(function(){return arguments}())?Fh:function(s){return Xe(s)&&Te.call(s,"callee")&&!bh.call(s,"callee")},he=U.isArray,MS=nh?Ft(nh):Z1;function Ct(s){return s!=null&&go(s.length)&&!An(s)}function ke(s){return Xe(s)&&Ct(s)}function SS(s){return s===!0||s===!1||Xe(s)&&vt(s)==Ye}var hi=zb||Al,LS=ih?Ft(ih):V1;function PS(s){return Xe(s)&&s.nodeType===1&&!Er(s)}function CS(s){if(s==null)return!0;if(Ct(s)&&(he(s)||typeof s=="string"||typeof s.splice=="function"||hi(s)||lr(s)||Oi(s)))return!s.length;var l=mt(s);if(l==Ce||l==It)return!s.size;if(Qr(s))return!$a(s).length;for(var h in s)if(Te.call(s,h))return!1;return!0}function TS(s,l){return Rr(s,l)}function GS(s,l,h){h=typeof h=="function"?h:t;var y=h?h(s,l):t;return y===t?Rr(s,l,t,h):!!y}function Sl(s){if(!Xe(s))return!1;var l=vt(s);return l==ze||l==st||typeof s.message=="string"&&typeof s.name=="string"&&!Er(s)}function WS(s){return typeof s=="number"&&Mh(s)}function An(s){if(!Fe(s))return!1;var l=vt(s);return l==Vt||l==Nt||l==Qe||l==Ri}function Nd(s){return typeof s=="number"&&s==pe(s)}function go(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=ie}function Fe(s){var l=typeof s;return s!=null&&(l=="object"||l=="function")}function Xe(s){return s!=null&&typeof s=="object"}var Bd=rh?Ft(rh):A1;function ZS(s,l){return s===l||Ea(s,l,pl(l))}function VS(s,l,h){return h=typeof h=="function"?h:t,Ea(s,l,pl(l),h)}function IS(s){return Yd(s)&&s!=+s}function AS(s){if(yx(s))throw new ue(o);return Oh(s)}function FS(s){return s===null}function OS(s){return s==null}function Yd(s){return typeof s=="number"||Xe(s)&&vt(s)==ot}function Er(s){if(!Xe(s)||vt(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&&zs.call(h)==Vb}var Ll=sh?Ft(sh):F1;function DS(s){return Nd(s)&&s>=-ie&&s<=ie}var Rd=oh?Ft(oh):O1;function yo(s){return typeof s=="string"||!he(s)&&Xe(s)&&vt(s)==qn}function Dt(s){return typeof s=="symbol"||Xe(s)&&vt(s)==ei}var lr=ah?Ft(ah):D1;function zS(s){return s===t}function XS(s){return Xe(s)&&mt(s)==Si}function US(s){return Xe(s)&&vt(s)==xa}var kS=oo(qa),KS=oo(function(s,l){return s<=l});function jd(s){if(!s)return[];if(Ct(s))return yo(s)?ln(s):Pt(s);if(zr&&s[zr])return wb(s[zr]());var l=mt(s),h=l==Ce?Ua:l==It?Fs:cr;return h(s)}function Fn(s){if(!s)return s===0?s:0;if(s=$t(s),s===re||s===-re){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 Jd(s){return s?Vi(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=fh(s);var h=Mw.test(s);return h||Lw.test(s)?ib(s.slice(2),h?2:8):xw.test(s)?de:+s}function Qd(s){return xn(s,Tt(s))}function NS(s){return s?Vi(pe(s),-ie,ie):s===0?s:0}function Pe(s){return s==null?"":Ot(s)}var BS=sr(function(s,l){if(Qr(l)||Ct(l)){xn(l,He(l),s);return}for(var h in l)Te.call(l,h)&&Nr(s,h,l[h])}),Hd=sr(function(s,l){xn(l,Tt(l),s)}),vo=sr(function(s,l,h,y){xn(l,Tt(l),s,y)}),YS=sr(function(s,l,h,y){xn(l,He(l),s,y)}),RS=Vn(Ra);function jS(s,l){var h=rr(s);return l==null?h:Th(h,l)}var JS=ye(function(s,l){s=Ge(s);var h=-1,y=l.length,_=y>2?l[2]:t;for(_&&_t(l[0],l[1],_)&&(y=1);++h<y;)for(var P=l[h],T=Tt(P),Z=-1,F=T.length;++Z<F;){var B=T[Z],R=s[B];(R===t||un(R,tr[B])&&!Te.call(s,B))&&(s[B]=P[B])}return s}),QS=ye(function(s){return s.push(t,fd),At(Ed,t,s)});function HS(s,l){return ch(s,se(l,3),bn)}function ES(s,l){return ch(s,se(l,3),Ja)}function $S(s,l){return s==null?s:ja(s,se(l,3),Tt)}function qS(s,l){return s==null?s:Ih(s,se(l,3),Tt)}function e2(s,l){return s&&bn(s,se(l,3))}function t2(s,l){return s&&Ja(s,se(l,3))}function n2(s){return s==null?[]:$s(s,He(s))}function i2(s){return s==null?[]:$s(s,Tt(s))}function Pl(s,l,h){var y=s==null?t:Ii(s,l);return y===t?h:y}function r2(s,l){return s!=null&&gd(s,l,C1)}function Cl(s,l){return s!=null&&gd(s,l,T1)}var s2=ld(function(s,l,h){l!=null&&typeof l.toString!="function"&&(l=Xs.call(l)),s[l]=h},Gl(Gt)),o2=ld(function(s,l,h){l!=null&&typeof l.toString!="function"&&(l=Xs.call(l)),Te.call(s,l)?s[l].push(h):s[l]=[h]},se),a2=ye(Yr);function He(s){return Ct(s)?Ph(s):$a(s)}function Tt(s){return Ct(s)?Ph(s,!0):z1(s)}function l2(s,l){var h={};return l=se(l,3),bn(s,function(y,_,P){Wn(h,l(y,_,P),y)}),h}function c2(s,l){var h={};return l=se(l,3),bn(s,function(y,_,P){Wn(h,_,l(y,_,P))}),h}var u2=sr(function(s,l,h){qs(s,l,h)}),Ed=sr(function(s,l,h,y){qs(s,l,h,y)}),h2=Vn(function(s,l){var h={};if(s==null)return h;var y=!1;l=Ae(l,function(P){return P=ci(P,s),y||(y=P.length>1),P}),xn(s,dl(s),h),y&&(h=Qt(h,f|g|v,sx));for(var _=l.length;_--;)rl(h,l[_]);return h});function d2(s,l){return $d(s,mo(se(l)))}var f2=Vn(function(s,l){return s==null?{}:U1(s,l)});function $d(s,l){if(s==null)return{};var h=Ae(dl(s),function(y){return[y]});return l=se(l),Nh(s,h,function(y,_){return l(y,_[0])})}function p2(s,l,h){l=ci(l,s);var y=-1,_=l.length;for(_||(_=1,s=t);++y<_;){var P=s==null?t:s[Mn(l[y])];P===t&&(y=_,P=h),s=An(P)?P.call(s):P}return s}function m2(s,l,h){return s==null?s:jr(s,l,h)}function g2(s,l,h,y){return y=typeof y=="function"?y:t,s==null?s:jr(s,l,h,y)}var qd=hd(He),ef=hd(Tt);function y2(s,l,h){var y=he(s),_=y||hi(s)||lr(s);if(l=se(l,4),h==null){var P=s&&s.constructor;_?h=y?new P:[]:Fe(s)?h=An(P)?rr(Ks(s)):{}:h={}}return(_?Rt:bn)(s,function(T,Z,F){return l(h,T,Z,F)}),h}function v2(s,l){return s==null?!0:rl(s,l)}function _2(s,l,h){return s==null?s:Jh(s,l,al(h))}function w2(s,l,h,y){return y=typeof y=="function"?y:t,s==null?s:Jh(s,l,al(h),y)}function cr(s){return s==null?[]:Xa(s,He(s))}function b2(s){return s==null?[]:Xa(s,Tt(s))}function x2(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),Vi($t(s),l,h)}function M2(s,l,h){return l=Fn(l),h===t?(h=l,l=0):h=Fn(h),s=$t(s),G1(s,l,h)}function S2(s,l,h){if(h&&typeof h!="boolean"&&_t(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 _=Sh();return pt(s+_*(l-s+nb("1e-"+((_+"").length-1))),l)}return tl(s,l)}var L2=or(function(s,l,h){return l=l.toLowerCase(),s+(h?tf(l):l)});function tf(s){return Tl(Pe(s).toLowerCase())}function nf(s){return s=Pe(s),s&&s.replace(Cw,mb).replace(Rw,"")}function P2(s,l,h){s=Pe(s),l=Ot(l);var y=s.length;h=h===t?y:Vi(pe(h),0,y);var _=h;return h-=l.length,h>=0&&s.slice(h,_)==l}function C2(s){return s=Pe(s),s&&Gs.test(s)?s.replace(sn,gb):s}function T2(s){return s=Pe(s),s&&fw.test(s)?s.replace(Ma,"\\$&"):s}var G2=or(function(s,l,h){return s+(h?"-":"")+l.toLowerCase()}),W2=or(function(s,l,h){return s+(h?" ":"")+l.toLowerCase()}),Z2=sd("toLowerCase");function V2(s,l,h){s=Pe(s),l=pe(l);var y=l?qi(s):0;if(!l||y>=l)return s;var _=(l-y)/2;return so(Rs(_),h)+s+so(Ys(_),h)}function I2(s,l,h){s=Pe(s),l=pe(l);var y=l?qi(s):0;return l&&y<l?s+so(l-y,h):s}function A2(s,l,h){s=Pe(s),l=pe(l);var y=l?qi(s):0;return l&&y<l?so(l-y,h)+s:s}function F2(s,l,h){return h||l==null?l=0:l&&(l=+l),Kb(Pe(s).replace(Sa,""),l||0)}function O2(s,l,h){return(h?_t(s,l,h):l===t)?l=1:l=pe(l),nl(Pe(s),l)}function D2(){var s=arguments,l=Pe(s[0]);return s.length<3?l:l.replace(s[1],s[2])}var z2=or(function(s,l,h){return s+(h?"_":"")+l.toLowerCase()});function X2(s,l,h){return h&&typeof h!="number"&&_t(s,l,h)&&(l=h=t),h=h===t?ge:h>>>0,h?(s=Pe(s),s&&(typeof l=="string"||l!=null&&!Ll(l))&&(l=Ot(l),!l&&$i(s))?ui(ln(s),0,h):s.split(l,h)):[]}var U2=or(function(s,l,h){return s+(h?" ":"")+Tl(l)});function k2(s,l,h){return s=Pe(s),h=h==null?0:Vi(pe(h),0,s.length),l=Ot(l),s.slice(h,h+l.length)==l}function K2(s,l,h){var y=S.templateSettings;h&&_t(s,l,h)&&(l=t),s=Pe(s),l=vo({},l,y,dd);var _=vo({},l.imports,y.imports,dd),P=He(_),T=Xa(_,P),Z,F,B=0,R=l.interpolate||Ws,J="__p += '",$=ka((l.escape||Ws).source+"|"+R.source+"|"+(R===ni?bw:Ws).source+"|"+(l.evaluate||Ws).source+"|$","g"),te="//# sourceURL="+(Te.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ew+"]")+`
957
+ `;s.replace($,function(ae,we,xe,zt,wt,Xt){return xe||(xe=zt),J+=s.slice(B,Xt).replace(Tw,yb),we&&(Z=!0,J+=`' +
958
+ __e(`+we+`) +
959
+ '`),wt&&(F=!0,J+=`';
960
+ `+wt+`;
961
+ __p += '`),xe&&(J+=`' +
962
+ ((__t = (`+xe+`)) == null ? '' : __t) +
963
+ '`),B=Xt+ae.length,ae}),J+=`';
964
+ `;var oe=Te.call(l,"variable")&&l.variable;if(!oe)J=`with (obj) {
965
+ `+J+`
966
+ }
967
+ `;else if(_w.test(oe))throw new ue(c);J=(F?J.replace(ce,""):J).replace(Me,"$1").replace(Be,"$1;"),J="function("+(oe||"obj")+`) {
968
+ `+(oe?"":`obj || (obj = {});
969
+ `)+"var __t, __p = ''"+(Z?", __e = _.escape":"")+(F?`, __j = Array.prototype.join;
970
+ function print() { __p += __j.call(arguments, '') }
971
+ `:`;
972
+ `)+J+`return __p
973
+ }`;var me=sf(function(){return Le(P,te+"return "+J).apply(t,T)});if(me.source=J,Sl(me))throw me;return me}function N2(s){return Pe(s).toLowerCase()}function B2(s){return Pe(s).toUpperCase()}function Y2(s,l,h){if(s=Pe(s),s&&(h||l===t))return fh(s);if(!s||!(l=Ot(l)))return s;var y=ln(s),_=ln(l),P=ph(y,_),T=mh(y,_)+1;return ui(y,P,T).join("")}function R2(s,l,h){if(s=Pe(s),s&&(h||l===t))return s.slice(0,yh(s)+1);if(!s||!(l=Ot(l)))return s;var y=ln(s),_=mh(y,ln(l))+1;return ui(y,0,_).join("")}function j2(s,l,h){if(s=Pe(s),s&&(h||l===t))return s.replace(Sa,"");if(!s||!(l=Ot(l)))return s;var y=ln(s),_=ph(y,ln(l));return ui(y,_).join("")}function J2(s,l){var h=V,y=G;if(Fe(l)){var _="separator"in l?l.separator:_;h="length"in l?pe(l.length):h,y="omission"in l?Ot(l.omission):y}s=Pe(s);var P=s.length;if($i(s)){var T=ln(s);P=T.length}if(h>=P)return s;var Z=h-qi(y);if(Z<1)return y;var F=T?ui(T,0,Z).join(""):s.slice(0,Z);if(_===t)return F+y;if(T&&(Z+=F.length-Z),Ll(_)){if(s.slice(Z).search(_)){var B,R=F;for(_.global||(_=ka(_.source,Pe(Fu.exec(_))+"g")),_.lastIndex=0;B=_.exec(R);)var J=B.index;F=F.slice(0,J===t?Z:J)}}else if(s.indexOf(Ot(_),Z)!=Z){var $=F.lastIndexOf(_);$>-1&&(F=F.slice(0,$))}return F+y}function Q2(s){return s=Pe(s),s&&Au.test(s)?s.replace(Bt,Sb):s}var H2=or(function(s,l,h){return s+(h?" ":"")+l.toUpperCase()}),Tl=sd("toUpperCase");function rf(s,l,h){return s=Pe(s),l=h?t:l,l===t?_b(s)?Cb(s):ub(s):s.match(l)||[]}var sf=ye(function(s,l){try{return At(s,t,l)}catch(h){return Sl(h)?h:new ue(h)}}),E2=Vn(function(s,l){return Rt(l,function(h){h=Mn(h),Wn(s,h,xl(s[h],s))}),s});function $2(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 _=-1;++_<l;){var P=s[_];if(At(P[0],this,y))return At(P[1],this,y)}})}function q2(s){return S1(Qt(s,f))}function Gl(s){return function(){return s}}function eL(s,l){return s==null||s!==s?l:s}var tL=ad(),nL=ad(!0);function Gt(s){return s}function Wl(s){return Dh(typeof s=="function"?s:Qt(s,f))}function iL(s){return Xh(Qt(s,f))}function rL(s,l){return Uh(s,Qt(l,f))}var sL=ye(function(s,l){return function(h){return Yr(h,s,l)}}),oL=ye(function(s,l){return function(h){return Yr(s,h,l)}});function Zl(s,l,h){var y=He(l),_=$s(l,y);h==null&&!(Fe(l)&&(_.length||!y.length))&&(h=l,l=s,s=this,_=$s(l,He(l)));var P=!(Fe(h)&&"chain"in h)||!!h.chain,T=An(s);return Rt(_,function(Z){var F=l[Z];s[Z]=F,T&&(s.prototype[Z]=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,ri([this.value()],arguments))})}),s}function aL(){return at._===this&&(at._=Ib),this}function Vl(){}function lL(s){return s=pe(s),ye(function(l){return kh(l,s)})}var cL=cl(Ae),uL=cl(lh),hL=cl(Aa);function of(s){return gl(s)?Fa(Mn(s)):k1(s)}function dL(s){return function(l){return s==null?t:Ii(s,l)}}var fL=cd(),pL=cd(!0);function Il(){return[]}function Al(){return!1}function mL(){return{}}function gL(){return""}function yL(){return!0}function vL(s,l){if(s=pe(s),s<1||s>ie)return[];var h=ge,y=pt(s,ge);l=se(l),s-=ge;for(var _=za(y,l);++h<s;)l(h);return _}function _L(s){return he(s)?Ae(s,Mn):Dt(s)?[s]:Pt(Ld(Pe(s)))}function wL(s){var l=++Zb;return Pe(s)+l}var bL=ro(function(s,l){return s+l},0),xL=ul("ceil"),ML=ro(function(s,l){return s/l},1),SL=ul("floor");function LL(s){return s&&s.length?Es(s,Gt,Qa):t}function PL(s,l){return s&&s.length?Es(s,se(l,2),Qa):t}function CL(s){return hh(s,Gt)}function TL(s,l){return hh(s,se(l,2))}function GL(s){return s&&s.length?Es(s,Gt,qa):t}function WL(s,l){return s&&s.length?Es(s,se(l,2),qa):t}var ZL=ro(function(s,l){return s*l},1),VL=ul("round"),IL=ro(function(s,l){return s-l},0);function AL(s){return s&&s.length?Da(s,Gt):0}function FL(s,l){return s&&s.length?Da(s,se(l,2)):0}return S.after=iS,S.ary=Od,S.assign=BS,S.assignIn=Hd,S.assignInWith=vo,S.assignWith=YS,S.at=RS,S.before=Dd,S.bind=xl,S.bindAll=E2,S.bindKey=zd,S.castArray=mS,S.chain=Id,S.chunk=Sx,S.compact=Lx,S.concat=Px,S.cond=$2,S.conforms=q2,S.constant=Gl,S.countBy=AM,S.create=jS,S.curry=Xd,S.curryRight=Ud,S.debounce=kd,S.defaults=JS,S.defaultsDeep=QS,S.defer=rS,S.delay=sS,S.difference=Cx,S.differenceBy=Tx,S.differenceWith=Gx,S.drop=Wx,S.dropRight=Zx,S.dropRightWhile=Vx,S.dropWhile=Ix,S.fill=Ax,S.filter=OM,S.flatMap=XM,S.flatMapDeep=UM,S.flatMapDepth=kM,S.flatten=Gd,S.flattenDeep=Fx,S.flattenDepth=Ox,S.flip=oS,S.flow=tL,S.flowRight=nL,S.fromPairs=Dx,S.functions=n2,S.functionsIn=i2,S.groupBy=KM,S.initial=Xx,S.intersection=Ux,S.intersectionBy=kx,S.intersectionWith=Kx,S.invert=s2,S.invertBy=o2,S.invokeMap=BM,S.iteratee=Wl,S.keyBy=YM,S.keys=He,S.keysIn=Tt,S.map=ho,S.mapKeys=l2,S.mapValues=c2,S.matches=iL,S.matchesProperty=rL,S.memoize=po,S.merge=u2,S.mergeWith=Ed,S.method=sL,S.methodOf=oL,S.mixin=Zl,S.negate=mo,S.nthArg=lL,S.omit=h2,S.omitBy=d2,S.once=aS,S.orderBy=RM,S.over=cL,S.overArgs=lS,S.overEvery=uL,S.overSome=hL,S.partial=Ml,S.partialRight=Kd,S.partition=jM,S.pick=f2,S.pickBy=$d,S.property=of,S.propertyOf=dL,S.pull=Rx,S.pullAll=Zd,S.pullAllBy=jx,S.pullAllWith=Jx,S.pullAt=Qx,S.range=fL,S.rangeRight=pL,S.rearg=cS,S.reject=HM,S.remove=Hx,S.rest=uS,S.reverse=wl,S.sampleSize=$M,S.set=m2,S.setWith=g2,S.shuffle=qM,S.slice=Ex,S.sortBy=nS,S.sortedUniq=rM,S.sortedUniqBy=sM,S.split=X2,S.spread=hS,S.tail=oM,S.take=aM,S.takeRight=lM,S.takeRightWhile=cM,S.takeWhile=uM,S.tap=LM,S.throttle=dS,S.thru=uo,S.toArray=jd,S.toPairs=qd,S.toPairsIn=ef,S.toPath=_L,S.toPlainObject=Qd,S.transform=y2,S.unary=fS,S.union=hM,S.unionBy=dM,S.unionWith=fM,S.uniq=pM,S.uniqBy=mM,S.uniqWith=gM,S.unset=v2,S.unzip=bl,S.unzipWith=Vd,S.update=_2,S.updateWith=w2,S.values=cr,S.valuesIn=b2,S.without=yM,S.words=rf,S.wrap=pS,S.xor=vM,S.xorBy=_M,S.xorWith=wM,S.zip=bM,S.zipObject=xM,S.zipObjectDeep=MM,S.zipWith=SM,S.entries=qd,S.entriesIn=ef,S.extend=Hd,S.extendWith=vo,Zl(S,S),S.add=bL,S.attempt=sf,S.camelCase=L2,S.capitalize=tf,S.ceil=xL,S.clamp=x2,S.clone=gS,S.cloneDeep=vS,S.cloneDeepWith=_S,S.cloneWith=yS,S.conformsTo=wS,S.deburr=nf,S.defaultTo=eL,S.divide=ML,S.endsWith=P2,S.eq=un,S.escape=C2,S.escapeRegExp=T2,S.every=FM,S.find=DM,S.findIndex=Cd,S.findKey=HS,S.findLast=zM,S.findLastIndex=Td,S.findLastKey=ES,S.floor=SL,S.forEach=Ad,S.forEachRight=Fd,S.forIn=$S,S.forInRight=qS,S.forOwn=e2,S.forOwnRight=t2,S.get=Pl,S.gt=bS,S.gte=xS,S.has=r2,S.hasIn=Cl,S.head=Wd,S.identity=Gt,S.includes=NM,S.indexOf=zx,S.inRange=M2,S.invoke=a2,S.isArguments=Oi,S.isArray=he,S.isArrayBuffer=MS,S.isArrayLike=Ct,S.isArrayLikeObject=ke,S.isBoolean=SS,S.isBuffer=hi,S.isDate=LS,S.isElement=PS,S.isEmpty=CS,S.isEqual=TS,S.isEqualWith=GS,S.isError=Sl,S.isFinite=WS,S.isFunction=An,S.isInteger=Nd,S.isLength=go,S.isMap=Bd,S.isMatch=ZS,S.isMatchWith=VS,S.isNaN=IS,S.isNative=AS,S.isNil=OS,S.isNull=FS,S.isNumber=Yd,S.isObject=Fe,S.isObjectLike=Xe,S.isPlainObject=Er,S.isRegExp=Ll,S.isSafeInteger=DS,S.isSet=Rd,S.isString=yo,S.isSymbol=Dt,S.isTypedArray=lr,S.isUndefined=zS,S.isWeakMap=XS,S.isWeakSet=US,S.join=Nx,S.kebabCase=G2,S.last=Et,S.lastIndexOf=Bx,S.lowerCase=W2,S.lowerFirst=Z2,S.lt=kS,S.lte=KS,S.max=LL,S.maxBy=PL,S.mean=CL,S.meanBy=TL,S.min=GL,S.minBy=WL,S.stubArray=Il,S.stubFalse=Al,S.stubObject=mL,S.stubString=gL,S.stubTrue=yL,S.multiply=ZL,S.nth=Yx,S.noConflict=aL,S.noop=Vl,S.now=fo,S.pad=V2,S.padEnd=I2,S.padStart=A2,S.parseInt=F2,S.random=S2,S.reduce=JM,S.reduceRight=QM,S.repeat=O2,S.replace=D2,S.result=p2,S.round=VL,S.runInContext=A,S.sample=EM,S.size=eS,S.snakeCase=z2,S.some=tS,S.sortedIndex=$x,S.sortedIndexBy=qx,S.sortedIndexOf=eM,S.sortedLastIndex=tM,S.sortedLastIndexBy=nM,S.sortedLastIndexOf=iM,S.startCase=U2,S.startsWith=k2,S.subtract=IL,S.sum=AL,S.sumBy=FL,S.template=K2,S.times=vL,S.toFinite=Fn,S.toInteger=pe,S.toLength=Jd,S.toLower=N2,S.toNumber=$t,S.toSafeInteger=NS,S.toString=Pe,S.toUpper=B2,S.trim=Y2,S.trimEnd=R2,S.trimStart=j2,S.truncate=J2,S.unescape=Q2,S.uniqueId=wL,S.upperCase=H2,S.upperFirst=Tl,S.each=Ad,S.eachRight=Fd,S.first=Wd,Zl(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(_){var P=this.clone();return P.__iteratees__.push({iteratee:se(_,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 Yr(h,s,l)})}),be.prototype.reject=function(s){return this.filter(mo(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),_=S[y?"take"+(l=="last"?"Right":""):l],P=y||/^find/.test(l);_&&(S.prototype[l]=function(){var T=this.__wrapped__,Z=y?[1]:arguments,F=T instanceof be,B=Z[0],R=F||he(T),J=function(we){var xe=_.apply(S,ri([we],Z));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,Z);return ae.__actions__.push({func:uo,args:[J],thisArg:t}),new Jt(ae,$)}return oe&&me?s.apply(this,Z):(ae=this.thru(J),oe?y?ae.value()[0]:ae.value():ae)})}),Rt(["pop","push","shift","sort","splice","unshift"],function(s){var l=Os[s],h=/^(?:push|sort|unshift)$/.test(s)?"tap":"thru",y=/^(?:pop|shift)$/.test(s);S.prototype[s]=function(){var _=arguments;if(y&&!this.__chain__){var P=this.value();return l.apply(he(P)?P:[],_)}return this[h](function(T){return l.apply(he(T)?T:[],_)})}}),bn(be.prototype,function(s,l){var h=S[l];if(h){var y=h.name+"";Te.call(ir,y)||(ir[y]=[]),ir[y].push({name:l,func:h})}}),ir[io(t,L).name]=[{name:"wrapper",func:t}],be.prototype.clone=Qb,be.prototype.reverse=Hb,be.prototype.value=Eb,S.prototype.at=PM,S.prototype.chain=CM,S.prototype.commit=TM,S.prototype.next=GM,S.prototype.plant=ZM,S.prototype.reverse=VM,S.prototype.toJSON=S.prototype.valueOf=S.prototype.value=IM,S.prototype.first=S.prototype.head,zr&&(S.prototype[zr]=WM),S},er=Tb();Ti?((Ti.exports=er)._=er,Wa._=er):at._=er}).call(Pr)}(ys,ys.exports);var M0=ys.exports,S0=Object.defineProperty,L0=(r,e,t)=>e in r?S0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,P0=(r,e,t)=>L0(r,e+"",t);let en=class extends ut{constructor(e){super(e),P0(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 C0=Object.defineProperty,T0=(r,e,t)=>e in r?C0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,G0=(r,e,t)=>T0(r,e+"",t);const W0={};class Pn extends en{constructor(e){super(e),G0(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 Ac(e.config,new p.Vector3(0,0,0));case"icon-point":return cg(e.config,this._position);case"icon-label-point":return vg(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(W0);var Z0=Object.defineProperty,V0=(r,e,t)=>e in r?Z0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ec=(r,e,t)=>V0(r,typeof e!="symbol"?e+"":e,t);class $c extends ut{constructor(e){super(e),Ec(this,"_baseType","Line"),Ec(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 gr({color:8947848,linewidth:.1,dashed:!1,resolution:new p.Vector2(window.innerWidth,window.innerHeight)});return new yr(e,t)}}var I0=Object.defineProperty,A0=(r,e,t)=>e in r?I0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,F0=(r,e,t)=>A0(r,e+"",t);const O0={};class Mt extends $c{constructor(e){super(e),F0(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 yr)){const i=this._threeGeometry.geometry;i.setPositions(this._vertexPoints),i.computeBoundingSphere(),i.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 Ho(e.config,this._vertexPoints);case"flow-tube-line":return Fc(e.config,this._vertexPoints);case"arrow-line":return Oc(e.config,this._vertexPoints);case"flow-texture-line":return await Dc(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 yr){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(O0);var D0=Object.defineProperty,z0=(r,e,t)=>e in r?D0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qc=(r,e,t)=>z0(r,typeof e!="symbol"?e+"":e,t);class X0 extends ut{constructor(e){super(e),qc(this,"_baseType","Surface"),qc(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 i=n.coordinates;let o=[],a=[];return i.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 i=n.coordinates;let o=[],a=[];return i.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 gr({color:8947848,linewidth:.1,dashed:!1,resolution:new p.Vector2(window.innerWidth,window.innerHeight)});return new yr(e,t)}}var U0=Object.defineProperty,k0=(r,e,t)=>e in r?U0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,K0=(r,e,t)=>k0(r,e+"",t);const N0={};class vn extends X0{constructor(e){super(e),K0(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 hg(e.config,this._vertexPoints);case"extrude-polygon":return dg(e.config,this._vertexPoints);case"water":return fg(e.config,this.getMap(),this._vertexPoints);case"base-water":return pg(e.config,this._vertexPoints);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}_calculateCollisionBoundingBox(){return null}}vn.mergeOptions(N0);var B0=Object.defineProperty,Y0=(r,e,t)=>e in r?B0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ta=(r,e,t)=>Y0(r,typeof e!="symbol"?e+"":e,t);const R0={};class eu extends $c{constructor(e){super(e),ta(this,"_type","MultiLineString"),ta(this,"_lineObjects",[]),ta(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 i=n.flatMap(a=>[a.x,a.y,a.z]),o=await this._createLineObject(this._style,i);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 Ho(e.config,t);case"flow-tube-line":return Fc(e.config,t);case"arrow-line":return Oc(e.config,t);case"flow-texture-line":return await Dc(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(){}}eu.mergeOptions(R0);var j0=Object.defineProperty,J0=(r,e,t)=>e in r?j0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cr=(r,e,t)=>J0(r,typeof e!="symbol"?e+"":e,t);const na=64;class Q0 extends ct.MeshStandardMaterial{constructor(e={}){const{shaderOption:t,regionOverlay:n,...i}=e;if(super({color:"rgb(58,126,182)",roughness:.7,metalness:.1,transparent:!0,opacity:.9,envMapIntensity:.8,depthWrite:!0,depthTest:!0,...i}),Cr(this,"shaderOption"),Cr(this,"clock"),Cr(this,"time"),Cr(this,"startTime"),Cr(this,"regionOverlay"),n&&n.vertices&&n.vertices.length>0){const o=n.vertices.slice(0,na).map(c=>c.clone()),a=o.length;for(;o.length<na;)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:i,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:i},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(na).fill(0).map(()=>new ct.Vector2(0,0))}},e.vertexShader=`
604
974
  varying vec3 vWorldPosition;
605
975
  varying vec3 vPosition;
606
976
  varying float vHeight;
@@ -612,6 +982,7 @@
612
982
  vHeight = position.y;
613
983
  `),e.fragmentShader=`
614
984
  #define PI 3.141592653589793
985
+ #define REGION_OVERLAY_MAX_VERTS 64
615
986
  varying vec3 vWorldPosition;
616
987
  varying vec3 vPosition;
617
988
  varying float vHeight;
@@ -622,14 +993,12 @@
622
993
  uniform float uMaxRate;
623
994
  uniform float time;
624
995
  uniform float uStartTime;
625
- // 修改后的圆环扩散uniforms
626
996
  uniform int uDiffusionEnabled;
627
997
  uniform vec3 uDiffusionColor;
628
998
  uniform float uDiffusionWidth;
629
999
  uniform float uDiffusionSpeed;
630
1000
  uniform float uDiffusionMaxDistance;
631
1001
  uniform vec3 uDiffusionCenter;
632
- // 其他效果uniforms保持不变
633
1002
  uniform int uFlowEnabled;
634
1003
  uniform vec3 uFlowColor;
635
1004
  uniform float uFlowRange;
@@ -638,6 +1007,14 @@
638
1007
  uniform vec3 uSweepColor;
639
1008
  uniform float uSweepWidth;
640
1009
  uniform float uSweepSpeed;
1010
+
1011
+ // 区域多边形外衣相关 uniform 声明(之前缺少)
1012
+ uniform int uRegionOverlayEnabled;
1013
+ uniform vec3 uRegionOverlayColor;
1014
+ uniform float uRegionOverlayOpacity;
1015
+ uniform int uRegionOverlayVertexCount;
1016
+ uniform vec2 uRegionOverlayVertices[REGION_OVERLAY_MAX_VERTS];
1017
+
641
1018
 
642
1019
  float distanceTo(vec2 src, vec2 dst) {
643
1020
  return distance(src, dst);
@@ -647,42 +1024,35 @@
647
1024
  `.replace("#include <color_fragment>",`
648
1025
  #include <color_fragment>
649
1026
 
650
- // 保留高度渐变计算
1027
+ // 高度渐变计算
651
1028
  float normalizedHeight = clamp((vWorldPosition.y - uMinY) / uHeightRange, 0.0, 1.0);
652
1029
  float heightFactor = smoothstep(0.0, 1.0, normalizedHeight);
653
1030
  diffuseColor.rgb *= mix(uMinRate, uMaxRate, heightFactor);
654
1031
 
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
- );
672
-
673
- // 1. 增强亮度:颜色值乘以5倍(可根据需要调整)
674
- vec3 highBrightnessColor = uDiffusionColor * 5.0;
1032
+ // 圆环扩散效果
1033
+ if (uDiffusionEnabled == 1) {
1034
+ vec2 position2D = vec2(vWorldPosition.x, vWorldPosition.z);
1035
+ vec2 center2D = vec2(uDiffusionCenter.x, uDiffusionCenter.z);
1036
+ float distToCenter = distance(position2D, center2D);
675
1037
 
676
- // 2. 改用加法混合模式(更亮)
677
- diffuseColor.rgb += highBrightnessColor * (1.0 - ringFactor);
1038
+ float progress = mod(time * uDiffusionSpeed, 1.0);
1039
+ float currentRadius = progress * uDiffusionMaxDistance;
678
1040
 
679
- // 3. 防止过曝(可选)
680
- diffuseColor.rgb = min(diffuseColor.rgb, vec3(2.0));
681
- }
682
- }
1041
+ if (distToCenter > currentRadius - uDiffusionWidth &&
1042
+ distToCenter < currentRadius) {
1043
+ float ringFactor = smoothstep(
1044
+ currentRadius - uDiffusionWidth,
1045
+ currentRadius,
1046
+ distToCenter
1047
+ );
1048
+
1049
+ vec3 highBrightnessColor = uDiffusionColor * 5.0;
1050
+ diffuseColor.rgb += highBrightnessColor * (1.0 - ringFactor);
1051
+ diffuseColor.rgb = min(diffuseColor.rgb, vec3(2.0));
1052
+ }
1053
+ }
683
1054
 
684
- // ================= 保留原有其他效果 =================
685
- // 流光效果(保持不变)
1055
+ // 流光效果
686
1056
  if (uFlowEnabled == 1) {
687
1057
  float dTime = mod(time * uFlowSpeed, uFlowRange * 2.0);
688
1058
  if (vPosition.z > dTime - uFlowRange && vPosition.z < dTime) {
@@ -691,7 +1061,7 @@
691
1061
  }
692
1062
  }
693
1063
 
694
- // 扫光效果(保持不变)
1064
+ // 扫光效果
695
1065
  if (uSweepEnabled == 1) {
696
1066
  float sweepPos = mod(time * uSweepSpeed, 2.0);
697
1067
  if (vHeight > sweepPos - uSweepWidth && vHeight < sweepPos) {
@@ -699,4 +1069,101 @@
699
1069
  diffuseColor.rgb = mix(uSweepColor, diffuseColor.rgb, 1.0 - sweepFactor);
700
1070
  }
701
1071
  }
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"})});
1072
+ // 区域多边形外衣叠色(Ray casting 判定点是否在多边形内)
1073
+ if (uRegionOverlayEnabled == 1 && uRegionOverlayOpacity > 0.0 && uRegionOverlayVertexCount >= 3) {
1074
+ vec2 p = vec2(vWorldPosition.x, vWorldPosition.z);
1075
+ bool inside = false;
1076
+ int j = 0;
1077
+ for (int i = 0; i < REGION_OVERLAY_MAX_VERTS; i++) {
1078
+ if (i >= uRegionOverlayVertexCount) break;
1079
+ if (i == 0) {
1080
+ j = uRegionOverlayVertexCount - 1;
1081
+ }
1082
+ vec2 pi = uRegionOverlayVertices[i];
1083
+ vec2 pj = uRegionOverlayVertices[j];
1084
+
1085
+ bool intersect = ((pi.y > p.y) != (pj.y > p.y)) &&
1086
+ (p.x < (pj.x - pi.x) * (p.y - pi.y) / (pj.y - pi.y + 1e-6) + pi.x);
1087
+ if (intersect) {
1088
+ inside = !inside;
1089
+ }
1090
+ j = i;
1091
+ }
1092
+
1093
+ if (inside) {
1094
+ diffuseColor.rgb = mix(
1095
+ diffuseColor.rgb,
1096
+ uRegionOverlayColor,
1097
+ clamp(uRegionOverlayOpacity, 0.0, 1.0)
1098
+ );
1099
+ }
1100
+ }
1101
+ `)}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 i=[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;i.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 H0=Object.defineProperty,E0=(r,e,t)=>e in r?H0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tn=(r,e,t)=>E0(r,typeof e!="symbol"?e+"":e,t);const $0={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class tu 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:_c(),targrt:this})}}async _createObject(e){switch(e.config.type){case"fbx":case"gltf":return ug(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 v=m[g],w=m[g+2],b=d.x+v,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 i=e.geometry;let o;if(i.type==="Polygon")o=i.coordinates;else if(i.type==="MultiPolygon"){if(!i.coordinates.length)return null;o=i.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 i=n.filter(a=>(a.mode??"overlay")==="overlay").sort((a,c)=>(a.zIndex??0)-(c.zIndex??0)),o=i[i.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 i=new Q0({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);i.updateBoundingBox(o.min.y,o.max.y),i.setDiffusionFromObject(n),n.receiveShadow=!1,n.material=i,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(i=>{const o=n.material[i];o&&(o.wrapS=o.wrapT=p.RepeatWrapping,o.repeat.set(.3,.3),o.needsUpdate=!0)}),n.material.normalScale=new p.Vector2(3,3))}})}}tu.mergeOptions($0);var q0=Object.defineProperty,ey=(r,e,t)=>e in r?q0(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ty=(r,e,t)=>ey(r,e+"",t);const ny={};class nu extends en{constructor(e){super(e),ty(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 mg(e.config,this._position);default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}nu.mergeOptions(ny);var iy=Object.defineProperty,ry=(r,e,t)=>e in r?iy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,sy=(r,e,t)=>ry(r,e+"",t);const oy={};class iu extends en{constructor(e){super(e),sy(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 yg(e.config,new p.Vector3(0,0,0),this.getMap());case"canvas-label":return gg(e.config,new p.Vector3(0,0,0));default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}iu.mergeOptions(oy);var ay=Object.defineProperty,ly=(r,e,t)=>e in r?ay(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ru=(r,e,t)=>ly(r,typeof e!="symbol"?e+"":e,t);const cy={};class su extends en{constructor(e){super(e),ru(this,"_type","TPoints"),ru(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 Pg(e.config,this._geometries,this.getMap());default:throw new Error(`Unsupported style type: ${e.config.type}`)}}}su.mergeOptions(cy);var uy=Object.defineProperty,hy=(r,e,t)=>e in r?uy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jn=(r,e,t)=>hy(r,typeof e!="symbol"?e+"":e,t);class Tr extends Kn(Object){constructor(e,t){super(),jn(this,"options"),jn(this,"map"),jn(this,"_sprite",null),jn(this,"_isDragging",!1),jn(this,"_dragStartPosition",null),jn(this,"_lastCoordinate",null),jn(this,"_boundOnMouseMove",null),jn(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 i=64/2,o=64/2-2;n.clearRect(0,0,t.width,t.height),n.beginPath(),n.arc(i,i,o,0,2*Math.PI),n.fillStyle="#000000",n.fill(),n.beginPath(),n.arc(i,i,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 v=d.getPixelRatio(),w=this.options.size*v;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],i=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:i}})}_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 ia(r,e,t){const{currentTarget:n,clientX:i,clientY:o}=r;if(n instanceof HTMLElement){const a=n.clientWidth,c=n.clientHeight,u=new p.Vector2(i/a*2-1,-(o/c)*2+1);return e.getLocalInfoFromScreen(t,u)?.location}else return}var dy=Object.defineProperty,fy=(r,e,t)=>e in r?dy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ht=(r,e,t)=>fy(r,typeof e!="symbol"?e+"":e,t);class py extends cs{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 vn&&this._createPolygonHandles(e,t)}_createPointHandles(e,t){const n=e.coordinates,i=t.geo2world(new p.Vector3(n[0],n[1],n[2]||0)),o=new Tr({position:i,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((i,o)=>{const a=t.geo2world(new p.Vector3(i[0],i[1],i[2]||0)),c=new Tr({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 i=e.target.getPosition();if(!this._getMap())return;const a=this._fixHandlePointCoordinates(i,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 Tr({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 i=this.target._geometry,o=i.coordinates;this._addHistory(i.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,i=t.geo2world(new p.Vector3(n[0],n[1],n[2]||0));this._handles[0]&&this._handles[0].updatePosition(i)}else if(this.target instanceof Mt)e.coordinates.forEach((i,o)=>{const a=t.geo2world(new p.Vector3(i[0],i[1],i[2]||0));this._handles[o]&&this._handles[o].updatePosition(a)});else if(this.target instanceof vn){const n=e.coordinates;let i=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[i]&&this._handles[i].updatePosition(d),i++}})}}}_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 i=e.coordinates;for(let o=0;o<i.length-1&&!(n>=this._middleHandles.length);o++){const a=i[o],c=i[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 vn&&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 i=e,o=t.viewer.renderer.domElement,a=o.getBoundingClientRect(),c=new p.Vector2((i.clientX-a.left)/a.width*2-1,-((i.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=ia({currentTarget:o,clientX:i.clientX,clientY:i.clientY},t.tilemap,t.viewer.camera);m&&(d.startDrag([m.x,m.y]),i.stopPropagation&&i.stopPropagation(),i.stopImmediatePropagation&&i.stopImmediatePropagation(),i.preventDefault&&i.preventDefault());return}}_onMapMouseMove(e){}_onMapClick(e){if(!(e.type===this.options.removeVertexOn))return;const n=this._getMap();if(!n)return;const i=new p.Raycaster;i.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);i.setFromCamera(a,n.viewer.camera);for(let c=0;c<this._handles.length;c++)if(this._handles[c].intersect(i)){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(i=>{i.userData._originalOpacity||(i.userData._originalOpacity=i.opacity),i.opacity=Math.min(i.opacity*.6,.6),i.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(i=>{i.userData._originalOpacity!==void 0&&(i.opacity=i.userData._originalOpacity,delete i.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],i=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[i],c.splice(i,1)}else if(this.target instanceof vn){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[i],u.splice(i,1),d&&i===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:i,ringIndex:o,coordinate:a})}_createLineStringMiddleHandles(e,t){for(let n=0;n<e.length-1;n++){const i=e[n],o=e[n+1],a=[(i[0]+o[0])/2,(i[1]+o[1])/2,((i[2]||0)+(o[2]||0))/2],c=t.geo2world(new p.Vector3(a[0],a[1],a[2])),u=new Tr({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 i=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<i;o++){const a=(o+1)%i,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 Tr({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 i=this.target._geometry;if(this._getMap()){if(t==="LineString"){const a=i.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=i.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(i.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 vn){let e=0;this.target._geometry.coordinates.forEach((i,o)=>{const a=i[0][0]===i[i.length-1][0]&&i[0][1]===i[i.length-1][1]?i.length-1:i.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 i=this._getMap();if(!i)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 vn){const u=o.coordinates;u[n]&&u[n][t]&&(a=u[n][t])}if(!a||!a[2]||a[2]===0)return i.world2geo(e);const c=i.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(r){return this.options?.editable?(this._editor&&this.endEdit(),this._editor=new py(this,r),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 vs(r,e){if(!r||r===!0)return!0;if(!Array.isArray(r))return!!r;switch(r[0]){case"all":return r.slice(1).every(n=>vs(n,e));case"any":return r.slice(1).some(n=>vs(n,e));case"!":return!vs(r[1],e);case"==":{const n=Oe(r[1],e),i=Oe(r[2],e);return _s(n)==_s(i)}case"!=":{const n=Oe(r[1],e),i=Oe(r[2],e);return _s(n)!=_s(i)}case">":{const n=Oe(r[1],e),i=Oe(r[2],e);return Jn(n)>Jn(i)}case"<":{const n=Oe(r[1],e),i=Oe(r[2],e);return Jn(n)<Jn(i)}case">=":{const n=Oe(r[1],e),i=Oe(r[2],e);return Jn(n)>=Jn(i)}case"<=":{const n=Oe(r[1],e),i=Oe(r[2],e);return Jn(n)<=Jn(i)}case"in":{const n=Oe(r[1],e);return r.slice(2).map(o=>Oe(o,e)).includes(n)}case"!in":{const n=Oe(r[1],e);return!r.slice(2).map(o=>Oe(o,e)).includes(n)}case"has":{const n=r[1];return e!=null&&Object.prototype.hasOwnProperty.call(e,n)}case"!has":{const n=r[1];return!(e!=null&&Object.prototype.hasOwnProperty.call(e,n))}case"like":case"contains":{const n=Oe(r[1],e),i=Oe(r[2],e);return String(n).toLowerCase().includes(String(i).toLowerCase())}case"starts-with":{const n=Oe(r[1],e),i=Oe(r[2],e);return String(n).toLowerCase().startsWith(String(i).toLowerCase())}case"ends-with":{const n=Oe(r[1],e),i=Oe(r[2],e);return String(n).toLowerCase().endsWith(String(i).toLowerCase())}default:return!0}}function Oe(r,e){if(Array.isArray(r))switch(r[0]){case"get":return e?e[r[1]]:void 0;default:return r}return r}function _s(r){if(r==null)return null;if(typeof r=="string"){const e=Number(r);if(!isNaN(e)&&r.trim()!=="")return e}return typeof r=="boolean"?r?1:0:r}function Jn(r){if(r==null)return 0;if(typeof r=="number")return r;if(typeof r=="boolean")return r?1:0;if(typeof r=="string"){const e=Number(r);return isNaN(e)?0:e}return Number(r)}var my=Object.defineProperty,gy=(r,e,t)=>e in r?my(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ki=(r,e,t)=>gy(r,typeof e!="symbol"?e+"":e,t);class ws extends Yn{constructor(e,t){super(e,t),ki(this,"TILE_SIZE"),ki(this,"EXTENT"),ki(this,"style"),ki(this,"interactive",!1),ki(this,"_tileFeatureMap",new Map),ki(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(),i=`${e.z}-${e.x}-${e.y}`,o=this._tileFeatureMap.get(i);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],v=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:v,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(i,c)}_evaluateFilter(e,t,n,i){if(!e||e===!0)return!0;const o={...t,$layer:n,$type:i};return vs(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,i){const a={geometry:{ismvt:!0,...e},style:n,userData:i};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,i)=>{const o=t.get(i);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,v]of Object.entries(a.layers))if(v.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 yy=Object.defineProperty,vy=(r,e,t)=>e in r?yy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,St=(r,e,t)=>vy(r,typeof e!="symbol"?e+"":e,t);class ou extends fs{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 Bn,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 _y=Object.defineProperty,wy=(r,e,t)=>e in r?_y(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,by=(r,e,t)=>wy(r,e+"",t);class au extends p.LoadingManager{constructor(){super(...arguments),by(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const De={manager:new au,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(r){De.imgLoaderMap.set(r.dataType,r),r.info.author=r.info.author??_o.name},registerGeometryLoader(r){De.demLoaderMap.set(r.dataType,r),r.info.author=r.info.author??_o.name},registerMeshLoader(r){De.meshLoaderMap.set(r.dataType,r),r.info.author=r.info.author??_o.name},getMaterialLoader(r){const e=De.imgLoaderMap.get(r.dataType);if(e)return e;throw`Source dataType "${r.dataType}" is not support!`},getGeometryLoader(r){const e=De.demLoaderMap.get(r.dataType);if(e)return e;throw`Source dataType "${r.dataType}" is not support!`},getMeshLoader(r){const e=De.meshLoaderMap.get(r.dataType);if(e)return e;throw`Source dataType "${r.dataType}" is not support!`}};var xy=Object.defineProperty,My=(r,e,t)=>e in r?xy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Sy=(r,e,t)=>My(r,e+"",t);class Ly{constructor(e){Sy(this,"worker"),this.worker=e()}async run(e,t){return new Promise(n=>{this.worker.onmessage=i=>{n(i.data)},this.worker.postMessage(e,t)})}terminate(){this.worker.terminate()}}const Py=4096,lu=Math.PI;function ra(r,e){const t=Math.floor(r[0]*e),n=Math.floor(r[1]*e),i=Math.floor((r[2]-r[0])*e),o=Math.floor((r[3]-r[1])*e);return{sx:t,sy:n,sw:i,sh:o}}function sa(r,e,t,n){if(n<r.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=r.maxLevel)return{url:r._getUrl(e,t,n),clipBounds:[0,0,1,1]};const i=Cy(e,t,n,r.maxLevel),o=i.parentNO;return{url:r._getUrl(o.x,o.y,o.z),clipBounds:i.bounds}}function Cy(r,e,t,n){const i=t-n,o={x:r>>i,y:e>>i,z:t-i},a=Math.pow(2,i),c=Math.pow(.5,i),u=r%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 oa(r,e,t,n,i=Py){const{x:o,y:a}=r,c=(e+o/i)/Math.pow(2,n),u=(t+a/i)/Math.pow(2,n),d=c*360-180,f=Math.atan(Math.sinh(lu*(1-2*u)))*180/lu;return[parseFloat(d.toFixed(8)),parseFloat(f.toFixed(8))]}function Ty(r,e,t,n){if(!r||!r.coordinates)throw new Error("无效的geometry数据格式");const i={type:r.type,coordinates:null};function o(a){if(typeof a=="object"&&a.x!==void 0&&a.y!==void 0)return oa(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=>oa(u,e,t,n)):a.map(u=>o(u))}return a}return i.coordinates=o(r.coordinates),i}var Gy=Object.defineProperty,Wy=(r,e,t)=>e in r?Gy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,bs=(r,e,t)=>Wy(r,typeof e!="symbol"?e+"":e,t);class xs{constructor(){bs(this,"_imgSource",[]),bs(this,"_demSource"),bs(this,"_vtSource"),bs(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 i=0;i<n.length;i++)t.addGroup(0,1/0,i);return{materials:n,geometry:t}}unload(e){const t=e.material,n=e.geometry;for(let i=0;i<t.length;i++)t[i].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),i=this.demSource;t=await n.load({source:i,...e}).catch(o=>(console.error("Load material error",i.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),i=this.vtSource;t=await n.load({source:i,...e}).catch(o=>(console.error("Load geometry error",i.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(i=>e.z>=i.minLevel&&this._isBoundsInSourceBounds(i,e.bounds)).map(async i=>{const o=De.getMaterialLoader(i),a=await o.load({source:i,...e}).catch(u=>(console.error("Load material error",i.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 Gr(...r){const e=r,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),i=new t(n);let o=0;for(const a of e)i.set(a,o),o+=a.length;return i}function cu(r,e,t,n){const i=n?Vy(n,r.position.value):Zy(e),o=i.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++)Iy({edge:i[f],edgeIndex:f,attributes:r,skirtHeight:t,newPosition:a,newTexcoord0:c,newTriangles:u,newNormals:d});r.position.value=Gr(r.position.value,a),r.texcoord.value=Gr(r.texcoord.value,c),r.normal.value=Gr(r.normal.value,d);const m=Gr(e,u);return{attributes:r,indices:m}}function Zy(r){const e=[],t=Array.isArray(r)?r:Array.from(r);for(let i=0;i<t.length;i+=3){const o=t[i],a=t[i+1],c=t[i+2];e.push([o,a],[a,c],[c,o])}e.sort(([i,o],[a,c])=>{const u=Math.min(i,o),d=Math.min(a,c);return u!==d?u-d:Math.max(i,o)-Math.max(a,c)});const n=[];for(let i=0;i<e.length;i++)i+1<e.length&&e[i][0]===e[i+1][1]&&e[i][1]===e[i+1][0]?i++:n.push(e[i]);return n}function Vy(r,e){const t=(i,o)=>{i.sort(o)};t(r.westIndices,(i,o)=>e[3*i+1]-e[3*o+1]),t(r.eastIndices,(i,o)=>e[3*o+1]-e[3*i+1]),t(r.southIndices,(i,o)=>e[3*o]-e[3*i]),t(r.northIndices,(i,o)=>e[3*i]-e[3*o]);const n=[];return Object.values(r).forEach(i=>{if(i.length>1)for(let o=0;o<i.length-1;o++)n.push([i[o],i[o+1]])}),n}function Iy({edge:r,edgeIndex:e,attributes:t,skirtHeight:n,newPosition:i,newTexcoord0:o,newTriangles:a,newNormals:c}){const u=t.position.value.length,d=e*2,m=d+1;i.set(t.position.value.subarray(r[0]*3,r[0]*3+3),d*3),i[d*3+2]=i[d*3+2]-n,i.set(t.position.value.subarray(r[1]*3,r[1]*3+3),m*3),i[m*3+2]=i[m*3+2]-n,o.set(t.texcoord.value.subarray(r[0]*2,r[0]*2+2),d*2),o.set(t.texcoord.value.subarray(r[1]*2,r[1]*2+2),m*2);const f=e*2*3;a[f]=r[0],a[f+1]=u/3+m,a[f+2]=r[1],a[f+3]=u/3+m,a[f+4]=r[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 uu(r){if(r.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${r.length}!`);const e=Math.floor(Math.sqrt(r.length)),t=e,n=e,i=aa(n,t);return{attributes:Ay(r,n,t),indices:i}}function Ay(r,e,t){const n=t*e,i=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,i[a*3]=d-.5,i[a*3+1]=m-.5,i[a*3+2]=r[(e-c-1)*t+u],a++}return{position:{value:i,size:3},texcoord:{value:o,size:2},normal:{value:la(i,aa(e,t)),size:3}}}function aa(r,e){const t=6*(e-1)*(r-1),n=new Uint16Array(t);let i=0;for(let o=0;o<r-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=i*6;n[f]=c,n[f+1]=u,n[f+2]=d,n[f+3]=d,n[f+4]=u,n[f+5]=m,i++}return n}function la(r,e){const t=new Float32Array(r.length);for(let n=0;n<e.length;n+=3){const i=e[n]*3,o=e[n+1]*3,a=e[n+2]*3,c=r[i],u=r[i+1],d=r[i+2],m=r[o],f=r[o+1],g=r[o+2],v=r[a],w=r[a+1],b=r[a+2],x=m-c,L=f-u,M=g-d,C=v-c,W=w-u,z=b-d,D=L*z-M*W,X=M*C-x*z,I=x*W-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[i+G]=t[o+G]=t[a+G]=V[G]}return t}var Fy=Object.defineProperty,Oy=(r,e,t)=>e in r?Fy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Dy=(r,e,t)=>Oy(r,e+"",t);class Ki extends p.PlaneGeometry{constructor(){super(...arguments),Dy(this,"type","TileGeometry")}setData(e,t=1e3){let n=e instanceof Float32Array?uu(e):e;n=cu(n.attributes,n.indices,t);const{attributes:i,indices:o}=n;return this.setIndex(new p.BufferAttribute(o,1)),this.setAttribute("position",new p.BufferAttribute(i.position.value,i.position.size)),this.setAttribute("uv",new p.BufferAttribute(i.texcoord.value,i.texcoord.size)),this.setAttribute("normal",new p.BufferAttribute(i.normal.value,i.normal.size)),this.computeBoundingBox(),this.computeBoundingSphere(),this}}var zy=Object.defineProperty,Xy=(r,e,t)=>e in r?zy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Qn=(r,e,t)=>Xy(r,typeof e!="symbol"?e+"":e,t);class hu{constructor(e=257){Qn(this,"gridSize"),Qn(this,"numTriangles"),Qn(this,"numParentTriangles"),Qn(this,"indices"),Qn(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 i=n+2,o=0,a=0,c=0,u=0,d=0,m=0;for(i&1?c=u=d=t:o=a=m=t;(i>>=1)>1;){const g=o+c>>1,v=a+u>>1;i&1?(c=o,u=a,o=d,a=m):(o=c,a=u,c=d,u=m),d=g,m=v}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 Uy(e,this)}}class Uy{constructor(e,t){Qn(this,"martini"),Qn(this,"terrain"),Qn(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:i}=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],v=d+f>>1,w=m+g>>1,b=v+w-m,x=w+d-v,L=(o[m*i+d]+o[g*i+f])/2,M=w*i+v,C=Math.abs(L-o[M]);if(a[M]=Math.max(a[M],C),c<t){const W=(m+x>>1)*i+(d+b>>1),z=(g+x>>1)*i+(f+b>>1);a[M]=Math.max(a[M],a[W],a[z])}}}getGeometryData(e=0){const{gridSize:t,indices:n}=this.martini,{errors:i}=this;let o=0,a=0;const c=t-1;let u,d,m=0;n.fill(0);function f(M,C,W,z,D,X){const I=M+W>>1,K=C+z>>1;Math.abs(M-D)+Math.abs(C-X)>1&&i[K*t+I]>e?(f(D,X,M,C,I,K),f(W,z,D,X,I,K)):(u=C*t+M,d=z*t+W,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,v=a*3,w=new Uint16Array(g),b=new Uint32Array(v);let x=0;function L(M,C,W,z,D,X){const I=M+W>>1,K=C+z>>1;if(Math.abs(M-D)+Math.abs(C-X)>1&&i[K*t+I]>e)L(D,X,M,C,I,K),L(W,z,D,X,I,K);else{const V=n[C*t+M]-1,G=n[z*t+W]-1,k=n[X*t+D]-1;w[2*V]=M,w[2*V+1]=C,w[2*G]=W,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 i=Math.floor(Math.sqrt(e.length)),o=i-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],v=g*i+f;c[3*m+0]=f/o-.5,c[3*m+1]=.5-g/o,c[3*m+2]=e[v],u[2*m+0]=f/o,u[2*m+1]=1-g/o}const d=la(c,n);return{position:{value:c,size:3},texcoord:{value:u,size:2},normal:{value:d,size:3}}}}var ky=Object.defineProperty,Ky=(r,e,t)=>e in r?ky(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,du=(r,e,t)=>Ky(r,typeof e!="symbol"?e+"":e,t);class ca{constructor(){du(this,"info",{version:"0.10.0",description:"Terrain loader base class"}),du(this,"dataType","")}async load(e){const{source:t,x:n,y:i,z:o}=e,{url:a,clipBounds:c}=sa(t,n,i,o);if(!a)return new Ki;const u=await this.doLoad(a,{source:t,x:n,y:i,z:o,bounds:c});return De.manager.parseEnd(a),u}}class ua 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=(r=>(r[r.Unknown=0]="Unknown",r[r.Point=1]="Point",r[r.Linestring=2]="Linestring",r[r.Polygon=3]="Polygon",r))(nt||{});class fu{render(e,t,n,i,o=1){switch(e.lineCap="round",e.lineJoin="round",(i.shadowBlur??0)>0&&(e.shadowBlur=i.shadowBlur??2,e.shadowColor=i.shadowColor??"black",e.shadowOffsetX=i.shadowOffset?i.shadowOffset[0]:0,e.shadowOffsetY=i.shadowOffset?i.shadowOffset[1]:0),t){case nt.Point:e.textAlign="center",e.textBaseline="middle",e.font=i.font??"14px Arial",e.fillStyle=i.fontColor??"white",this._renderPointText(e,n,o,i.textField??"name",i.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}`)}(i.fill||t===nt.Point)&&(e.globalAlpha=i.fillOpacity||.5,e.fillStyle=i.fillColor||i.color||"#3388ff",e.fill(i.fillRule||"evenodd")),(i.stroke??!0)&&(i.weight??1)>0&&(e.globalAlpha=i.opacity||1,e.lineWidth=i.weight||1,e.strokeStyle=i.color||"#3388ff",e.setLineDash(i.dashArray||[]),e.stroke())}_renderPointText(e,t,n=1,i="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[i]&&e.fillText(c[i],a[0][0].x*n+o[0],a[0][0].y*n+o[1])}_renderLineString(e,t,n){const i=t.geometry;e.beginPath();for(const o of i)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 i=t.geometry;e.beginPath();for(let o=0;o<i.length;o++){const a=i[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 Ny=Object.defineProperty,By=(r,e,t)=>e in r?Ny(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pu=(r,e,t)=>By(r,typeof e!="symbol"?e+"":e,t);class ha{constructor(){pu(this,"info",{version:"0.10.0",description:"Image loader base class"}),pu(this,"dataType","")}async load(e){const{source:t,x:n,y:i,z:o}=e,a=new ua({}),{url:c,clipBounds:u}=sa(t,n,i,o);if(c){const d=await this.doLoad(c,{source:t,x:n,y:i,z:o,bounds:u});a.map=d,De.manager.parseEnd(c)}return a}}var Yy=Object.defineProperty,Ry=(r,e,t)=>e in r?Yy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mu=(r,e,t)=>Ry(r,typeof e!="symbol"?e+"":e,t);class jy{constructor(){mu(this,"info",{version:"0.10.0",description:"Canvas tile abstract loader"}),mu(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 ua({transparent:!0,map:n,opacity:e.source.opacity})}_creatCanvasContext(e,t){const i=new OffscreenCanvas(e,t).getContext("2d");if(!i)throw new Error("create canvas context failed");return i.scale(1,-1),i.translate(0,-t),i}}var Jy=Object.defineProperty,Qy=(r,e,t)=>e in r?Jy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e,t)=>Qy(r,typeof e!="symbol"?e+"":e,t);class Hy extends ha{constructor(){super(...arguments),da(this,"info",{version:"0.10.0",description:"Tile image loader. It can load xyz tile image."}),da(this,"dataType","image"),da(this,"loader",new p.ImageLoader(De.manager))}async doLoad(e,t){const n=await this.loader.loadAsync(e).catch(a=>new Image(1,1)),i=new p.Texture;i.colorSpace=p.SRGBColorSpace;const{bounds:o}=t;return o[2]-o[0]<1?i.image=Ey(n,o):i.image=n,i.needsUpdate=!0,i}}function Ey(r,e){const t=r.width,n=new OffscreenCanvas(t,t),i=n.getContext("2d"),{sx:o,sy:a,sw:c,sh:u}=ra(e,r.width);return i.drawImage(r,o,a,c,u,0,0,t,t),n}const $y=`{
1102
+ "name": "@terra.gl/core",
1103
+ "version": "0.0.1-alpha.62",
1104
+ "type": "module",
1105
+ "files": [
1106
+ "dist"
1107
+ ],
1108
+ "main": "./dist/index.umd.cjs",
1109
+ "module": "./dist/index.js",
1110
+ "types": "./dist/index.d.ts",
1111
+ "exports": {
1112
+ ".": {
1113
+ "import": "./dist/index.js",
1114
+ "require": "./dist/index.umd.cjs",
1115
+ "types": "./dist/index.d.ts"
1116
+ }
1117
+ },
1118
+ "author": {
1119
+ "name": "Criska"
1120
+ },
1121
+ "description": "a map using threejs",
1122
+ "license": "Apache-2.0",
1123
+ "keywords": [
1124
+ "three",
1125
+ "gis",
1126
+ "tile",
1127
+ "map",
1128
+ "3D",
1129
+ "cesium",
1130
+ "mapbox"
1131
+ ],
1132
+ "scripts": {
1133
+ "dev": "vite build --watch",
1134
+ "build": "tsc && vite build && node copy-extra-to-dist.cjs",
1135
+ "docs:build-plugin": "tsc --project docs/typedoc-plugins",
1136
+ "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",
1137
+ "docs:typedoc": "npx typedoc --options typedoc.json",
1138
+ "changelog": "npx conventional-changelog-cli -p angular -i CHANGELOG.md -s --commit-path ."
1139
+ },
1140
+ "peerDependencies": {
1141
+ "three": "^0.171.0"
1142
+ },
1143
+ "publishConfig": {
1144
+ "registry": "https://registry.npmjs.org/",
1145
+ "access": "public"
1146
+ },
1147
+ "dependencies": {
1148
+ "@mapbox/vector-tile": "^2.0.4",
1149
+ "@pmndrs/vanilla": "^1.20.4",
1150
+ "@types/earcut": "^3.0.0",
1151
+ "@types/geojson": "^7946.0.16",
1152
+ "d3-quadtree": "^3.0.1",
1153
+ "earcut": "^3.0.1",
1154
+ "lodash": "^4.17.21",
1155
+ "pbf": "^4.0.1",
1156
+ "postprocessing": "^6.37.3",
1157
+ "three-stdlib": "^2.36.0"
1158
+ },
1159
+ "devDependencies": {
1160
+ "@types/lodash": "^4.17.20",
1161
+ "@types/node": "^24.2.0",
1162
+ "jsdoc": "^4.0.5",
1163
+ "rimraf": "^6.1.2",
1164
+ "typedoc": "^0.28.8",
1165
+ "typedoc-vitepress-theme": "^1.1.2",
1166
+ "vue": "^3.5.18"
1167
+ }
1168
+ }
1169
+ `;var qy=Object.defineProperty,ev=(r,e,t)=>e in r?qy(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zt=(r,e,t)=>ev(r,typeof e!="symbol"?e+"":e,t);class nn{constructor(e){Zt(this,"dataType","image"),Zt(this,"attribution","isource"),Zt(this,"minLevel",0),Zt(this,"maxLevel",18),Zt(this,"projectionID","3857"),Zt(this,"url",""),Zt(this,"subdomains",[]),Zt(this,"s",""),Zt(this,"opacity",1),Zt(this,"isTMS",!1),Zt(this,"bounds",[-180,-85,180,85]),Zt(this,"_projectionBounds",[-1/0,-1/0,1/0,1/0]),Zt(this,"tileMaterial"),Object.assign(this,e)}getUrl(e,t,n){const i={...this,x:e,y:t,z:n};return tv(this.url,i)}_getUrl(e,t,n){const i=this.subdomains.length;if(i>0){const a=Math.floor(Math.random()*i);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 tv(r,e){const t=/\{ *([\w_-]+) *\}/g;return r.replace(t,(n,i)=>{const o=e[i]??(()=>{throw new Error(`source url template error, No value provided for variable: ${n}`)})();return typeof o=="function"?o(e):o})}const{version:nv,author:iv}=JSON.parse($y);function rv(r,e=100){return new Promise(t=>{const n=setInterval(()=>{r&&(clearInterval(n),t())},e)})}function fa(r){return De.registerMaterialLoader(r),r}function pa(r){return De.registerGeometryLoader(r),r}function gu(r){return De.registerMeshLoader(r),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KHQpfWZ1bmN0aW9uIGxlKGssZCl7ZnVuY3Rpb24geShzLHQsbixoLGksbyxjLHUpe2NvbnN0IG09bmV3IEZsb2F0MzJBcnJheShpKm8pO2ZvcihsZXQgbD0wO2w8bztsKyspZm9yKGxldCBmPTA7ZjxpO2YrKyl7Y29uc3QgZz0obCtoKSp0KyhmK24pLE09bCppK2Y7bVtNXT1zW2ddfWNvbnN0IHc9bmV3IEZsb2F0MzJBcnJheSh1KmMpO2ZvcihsZXQgbD0wO2w8dTtsKyspZm9yKGxldCBmPTA7ZjxjO2YrKyl7Y29uc3QgZz1sKnUrZixNPU1hdGgucm91bmQoZipvL3UpLHA9TWF0aC5yb3VuZChsKmkvYykqaStNO3dbZ109bVtwXX1yZXR1cm4gd31jb25zdCBWPXVlKGQsay53aWR0aCksYT1WLnN3KzEsZT1WLnNoKzE7cmV0dXJue2FycmF5Onkoay5hcnJheSxrLndpZHRoLFYuc3gsVi5zeSxWLnN3LFYuc2gsYSxlKSx3aWR0aDphLGhlaWdodDplfX1mdW5jdGlvbiB1ZShrLGQpe2NvbnN0IHk9TWF0aC5mbG9vcihrWzBdKmQpLFY9TWF0aC5mbG9vcihrWzFdKmQpLGE9TWF0aC5mbG9vcigoa1syXS1rWzBdKSpkKSxlPU1hdGguZmxvb3IoKGtbM10ta1sxXSkqZCk7cmV0dXJue3N4Onksc3k6VixzdzphLHNoOmV9fXNlbGYub25tZXNzYWdlPWs9Pntjb25zdCBkPWsuZGF0YSx5PW9lKGQuZGVtRGF0YSxkLnosZC5jbGlwQm91bmRzKTtzZWxmLnBvc3RNZXNzYWdlKHkpfX0pKCk7Cg==",sv=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),vu=typeof self<"u"&&self.Blob&&new Blob([sv(yu)],{type:"text/javascript;charset=utf-8"});function ov(r){let e;try{if(e=vu&&(self.URL||self.webkitURL).createObjectURL(vu),!e)throw"";const t=new Worker(e,{name:r?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+yu,{name:r?.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}const av=function(){var r={};r.defaultNoDataValue=-34027999387901484e22,r.decode=function(a,c){c=c||{};var u=c.encodedMaskData||c.encodedMaskData===null,d=i(a,c.inputOffset||0,u),m=c.noDataValue!==null?c.noDataValue:r.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,v=a.pixels.numBlocksY,w=Math.floor(a.width/g),b=Math.floor(a.height/v),x=2*a.maxZError,L=Number.MAX_VALUE,M;u=u||(a.mask?a.mask.bitset:null);var C,W;C=new c(a.width*a.height),m&&u&&(W=new Uint8Array(a.width*a.height));for(var z=new Float32Array(w*b),D,X,I=0;I<=v;I++){var K=I!==v?b:a.height%v;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,re;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?re=0:re=Y.offset;var ie;if(u)for(X=0;X<K;X++){for(k&7&&(ie=u[k>>3],ie<<=k&7),D=0;D<G;D++)k&7||(ie=u[k>>3]),ie&128?(W&&(W[k]=1),M=Y.encoding<2?H[Q++]:re,L=L>M?M:L,C[k++]=M):(W&&(W[k]=0),C[k++]=d),ie<<=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>re?re:L,X=0;X<K;X++){for(D=0;D<G;D++)C[k++]=re;k+=j}if(Y.encoding===1&&Q!==Y.numValidPixels)throw"Block and Mask do not match";f++}}}return{resultPixels:C,resultMask:W,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)},i=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 v=f.getInt16(0,!0),w=2,b=0;do{if(v>0)for(;v--;)g[b++]=f.getUint8(w++);else{var x=f.getUint8(w++);for(v=-v;v--;)g[b++]=x}v=f.getInt16(w,!0),w+=2}while(w<d.mask.numBytes);if(v!==-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),W=M+(d.height%M>0?1:0);d.pixels.blocks=new Array(C*W);for(var z=0,D=0;D<W;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),re=Math.ceil(Q/4);k=new ArrayBuffer(re*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 v=(1<<c)-1,w=0,b,x=0,L,M,C=Math.ceil((g-d)/m),W=a.length*4-Math.ceil(c*u/8);for(a[a.length-1]<<=8*W,b=0;b<u;b++){if(x===0&&(M=a[w++],x=32),x>=c)L=M>>>x-c&v,x-=c;else{var z=c-x;L=(M&v)<<z&v,M=a[w++],x=32-z,L+=M>>>x}f[b]=L<C?d+L*m:g}return f};return r}(),lv=function(){var r={unstuff:function(i,o,a,c,u,d,m,f){var g=(1<<a)-1,v=0,w,b=0,x,L,M,C,W=i.length*4-Math.ceil(a*c/8);if(i[i.length-1]<<=8*W,u)for(w=0;w<c;w++)b===0&&(L=i[v++],b=32),b>=a?(x=L>>>b-a&g,b-=a):(M=a-b,x=(L&g)<<M&g,L=i[v++],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=i[v++],b=32),b>=a?(x=L>>>b-a&g,b-=a):(M=a-b,x=(L&g)<<M&g,L=i[v++],b=32-M,x+=L>>>b),o[w]=x<C?d+x*m:f},unstuffLUT:function(i,o,a,c,u,d){var m=(1<<o)-1,f=0,g=0,v=0,w=0,b=0,x,L=[],M=i.length*4-Math.ceil(o*a/8);i[i.length-1]<<=8*M;var C=Math.ceil((d-c)/u);for(g=0;g<a;g++)w===0&&(x=i[f++],w=32),w>=o?(b=x>>>w-o&m,w-=o):(v=o-w,b=(x&m)<<v&m,x=i[f++],w=32-v,b+=x>>>w),L[g]=b<C?c+b*u:d;return L.unshift(c),L},unstuff2:function(i,o,a,c,u,d,m,f){var g=(1<<a)-1,v=0,w,b=0,x=0,L,M,C;if(u)for(w=0;w<c;w++)b===0&&(M=i[v++],b=32,x=0),b>=a?(L=M>>>x&g,b-=a,x+=a):(C=a-b,L=M>>>x&g,M=i[v++],b=32-C,L|=(M&(1<<C)-1)<<a-C,x=C),o[w]=u[L];else{var W=Math.ceil((f-d)/m);for(w=0;w<c;w++)b===0&&(M=i[v++],b=32,x=0),b>=a?(L=M>>>x&g,b-=a,x+=a):(C=a-b,L=M>>>x&g,M=i[v++],b=32-C,L|=(M&(1<<C)-1)<<a-C,x=C),o[w]=L<W?d+L*m:f}return o},unstuffLUT2:function(i,o,a,c,u,d){var m=(1<<o)-1,f=0,g=0,v=0,w=0,b=0,x=0,L,M=[],C=Math.ceil((d-c)/u);for(g=0;g<a;g++)w===0&&(L=i[f++],w=32,x=0),w>=o?(b=L>>>x&m,w-=o,x+=o):(v=o-w,b=L>>>x&m,L=i[f++],w=32-v,b|=(L&(1<<v)-1)<<o-v,x=v),M[g]=b<C?c+b*u:d;return M.unshift(c),M},originalUnstuff:function(i,o,a,c){var u=(1<<a)-1,d=0,m,f=0,g,v,w,b=i.length*4-Math.ceil(a*c/8);for(i[i.length-1]<<=8*b,m=0;m<c;m++)f===0&&(v=i[d++],f=32),f>=a?(g=v>>>f-a&u,f-=a):(w=a-f,g=(v&u)<<w&u,v=i[d++],f=32-w,g+=v>>>f),o[m]=g;return o},originalUnstuff2:function(i,o,a,c){var u=(1<<a)-1,d=0,m,f=0,g=0,v,w,b;for(m=0;m<c;m++)f===0&&(w=i[d++],f=32,g=0),f>=a?(v=w>>>g&u,f-=a,g+=a):(b=a-f,v=w>>>g&u,w=i[d++],f=32-b,v|=(w&(1<<b)-1)<<a-b,g=b),o[m]=v;return o}},e={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(i){for(var o=65535,a=65535,c=i.length,u=Math.floor(c/2),d=0;u;){var m=u>=359?359:u;u-=m;do o+=i[d++]<<8,a+=o+=i[d++];while(--m);o=(o&65535)+(o>>>16),a=(a&65535)+(a>>>16)}return c&1&&(a+=o+=i[d]<<8),o=(o&65535)+(o>>>16),a=(a&65535)+(a>>>16),(a<<16|o)>>>0},readHeaderInfo:function(i,o){var a=o.ptr,c=new Uint8Array(i,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(i,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(i,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(i,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(i,a-g,u.blobSize-14)),f!==u.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(i,o){var a=o.headerInfo,c=this.getDataTypeArray(a.imageType),u=a.numDims*this.getDataTypeSize(a.imageType),d=this.readSubArray(i,o.ptr,c,u),m=this.readSubArray(i,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(i,o,a,c){var u;if(a===Uint8Array)u=new Uint8Array(i,o,c);else{var d=new ArrayBuffer(c),m=new Uint8Array(d);m.set(new Uint8Array(i,o,c)),u=new a(d)}return u},readMask:function(i,o){var a=o.ptr,c=o.headerInfo,u=c.width*c.height,d=c.numValidPixel,m=new DataView(i,a,4),f={};if(f.numBytes=m.getUint32(0,!0),a+=4,(d===0||u===d)&&f.numBytes!==0)throw"invalid mask";var g,v;if(d===0)g=new Uint8Array(Math.ceil(u/8)),f.bitset=g,v=new Uint8Array(u),o.pixels.resultMask=v,a+=f.numBytes;else if(f.numBytes>0){g=new Uint8Array(Math.ceil(u/8)),m=new DataView(i,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";v=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&&(v[C]=1);o.pixels.resultMask=v,f.bitset=g,a+=f.numBytes}return o.ptr=a,o.mask=f,!0},readDataOneSweep:function(i,o,a,c){var u=o.ptr,d=o.headerInfo,m=d.numDims,f=d.width*d.height,g=d.imageType,v=d.numValidPixel*e.getDataTypeSize(g)*m,w,b=o.pixels.resultMask;if(a===Uint8Array)w=new Uint8Array(i,u,v);else{var x=new ArrayBuffer(v),L=new Uint8Array(x);L.set(new Uint8Array(i,u,v)),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,W=0,z=0;if(m>1){if(c){for(C=0;C<f;C++)if(b[C])for(z=C,W=0;W<m;W++,z+=f)o.pixels.resultPixels[z]=w[M++]}else for(C=0;C<f;C++)if(b[C])for(z=C*m,W=0;W<m;W++)o.pixels.resultPixels[z+W]=w[M++]}else for(C=0;C<f;C++)b[C]&&(o.pixels.resultPixels[C]=w[M++])}return u+=v,o.ptr=u,!0},readHuffmanTree:function(i,o){var a=this.HUFFMAN_LUT_BITS_MAX,c=new DataView(i,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(i,o,g);var v=[],w,b,x,L;for(w=m;w<f;w++)b=w-(w<d?0:d),v[b]={first:g[w-m],second:null};var M=i.byteLength-o.ptr,C=Math.ceil(M/4),W=new ArrayBuffer(C*4),z=new Uint8Array(W);z.set(new Uint8Array(i,o.ptr,M));var D=new Uint32Array(W),X=0,I,K=0;for(I=D[0],w=m;w<f;w++)b=w-(w<d?0:d),L=v[b].first,L>0&&(v[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],v[b].second|=I>>>32-X));var V=0,G=0,k=new t;for(w=0;w<v.length;w++)v[w]!==void 0&&(V=Math.max(V,v[w].first));V>=a?G=a:G=V;var j=[],Y,H,Q,re,ie,le;for(w=m;w<f;w++)if(b=w-(w<d?0:d),L=v[b].first,L>0)if(Y=[L,b],L<=G)for(H=v[b].second<<G-L,Q=1<<G-L,x=0;x<Q;x++)j[H|x]=Y;else for(H=v[b].second,le=k,re=L-1;re>=0;re--)ie=H>>>re&1,ie?(le.right||(le.right=new t),le=le.right):(le.left||(le.left=new t),le=le.left),re===0&&!le.val&&(le.val=Y[1]);return{decodeLut:j,numBitsLUTQick:G,numBitsLUT:V,tree:k,stuffedData:D,srcPtr:K,bitPos:X}},readHuffman:function(i,o,a,c){var u=o.headerInfo,d=u.numDims,m=o.headerInfo.height,f=o.headerInfo.width,g=f*m,v=this.readHuffmanTree(i,o),w=v.decodeLut,b=v.tree,x=v.stuffedData,L=v.srcPtr,M=v.bitPos,C=v.numBitsLUTQick,W=v.numBitsLUT,z=o.headerInfo.imageType===0?128:0,D,X,I,K=o.pixels.resultMask,V,G,k,j,Y,H,Q,re=0;M>0&&(L++,M=0);var ie=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),re=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=ie<<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=ie<<M>>>32-W,G=V,32-M<W&&(V|=x[L+1]>>>64-M-W,G=V),D=b,Q=0;Q<W;Q++)if(k=V>>>W-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++,ie=x[L]),I=X-z,le?(Y>0?I+=re:j>0?I+=ge[H-f]:I+=re,I&=255,ge[H]=I,re=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=ie<<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=ie<<M>>>32-W,G=V,32-M<W&&(V|=x[L+1]>>>64-M-W,G=V),D=b,Q=0;Q<W;Q++)if(k=V>>>W-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++,ie=x[L]),I=X-z,le?(Y>0&&K[H-1]?I+=re:j>0&&K[H-f]?I+=ge[H-f]:I+=re,I&=255,ge[H]=I,re=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=ie<<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=ie<<M>>>32-W,G=V,32-M<W&&(V|=x[L+1]>>>64-M-W,G=V),D=b,Q=0;Q<W;Q++)if(k=V>>>W-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++,ie=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(i,o,a,c,u){{var d=o.headerInfo,m=d.fileVersion,f=0,g=i.byteLength-o.ptr>=5?5:i.byteLength-o.ptr,v=new DataView(i,o.ptr,g),w=v.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=v.getUint8(f),f++;else if(x===2)C=v.getUint16(f,!0),f+=2;else if(x===4)C=v.getUint32(f,!0),f+=4;else throw"Invalid valid pixel count type";var W=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=v.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(i,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(i,o.ptr,I)),z=new Uint32Array(D),o.ptr+=I,m>=3?V=r.unstuffLUT2(G,M,k-1,c,W,Y):V=r.unstuffLUT(G,M,k-1,c,W,Y),m>=3?r.unstuff2(z,a,j,C,V):r.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(i,o.ptr,I)),z=new Uint32Array(D),o.ptr+=I,m>=3?c==null?r.originalUnstuff2(z,a,j,C):r.unstuff2(z,a,j,C,!1,c,W,Y):c==null?r.originalUnstuff(z,a,j,C):r.unstuff(z,a,j,C,!1,c,W,Y))}},readTiles:function(i,o,a,c){var u=o.headerInfo,d=u.width,m=u.height,f=d*m,g=u.microBlockSize,v=u.imageType,w=e.getDataTypeSize(v),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,W=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,re,ie,le,de,ge,fe,Se=new a(g*g),it=m%g||g,rt=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:it,W=0;W<b;W++)for(D=W!==b-1?g:rt,G=C*d*g+W*g,k=d-D,Re=0;Re<Ye;Re++){if(Ye>1?(ft=ze,G=C*d*g+W*g,ze=new a(o.pixels.resultPixels.buffer,f*Re*w,f),ot=u.maxValues[Re]):ft=null,X=i.byteLength-o.ptr,re=new DataView(i,o.ptr,Math.min(10,X)),ie={},Q=0,I=re.getUint8(0),Q++,Ce=u.fileVersion>=5?I&4:0,K=I>>6&255,V=I>>2&Nt,V!==(W*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=i.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(i,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&&v<6?4:v,K),Qe=e.getOnePixel(ie,Q,dt,re),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(i,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(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:e.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,o){var a=i.headerInfo.zMax,c=i.headerInfo.zMin,u=i.headerInfo.maxValues,d=i.headerInfo.numDims,m=i.headerInfo.height*i.headerInfo.width,f=0,g=0,v=0,w=i.pixels.resultMask,b=i.pixels.resultPixels;if(w)if(d>1){if(o)for(f=0;f<d;f++)for(v=f*m,a=u[f],g=0;g<m;g++)w[g]&&(b[v+g]=a);else for(g=0;g<m;g++)if(w[g])for(v=g*d,f=0;f<d;f++)b[v+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(v=f*m,a=u[f],g=0;g<m;g++)b[v+g]=a;else for(g=0;g<m;g++)for(v=g*d,f=0;f<d;f++)b[v+f]=u[f];else for(g=0;g<m*d;g++)b[g]=a},getDataTypeArray:function(i){var o;switch(i){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(i){var o;switch(i){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(i,o){if(o==null)return!1;var a;switch(i){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(i){var o=0;switch(i){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=i}return o},getDataTypeUsed:function(i,o){var a=i;switch(i){case 2:case 4:a=i-o;break;case 3:case 5:a=i-2*o;break;case 6:o===0?a=i:o===1?a=2:a=1;break;case 7:o===0?a=i:a=i-2*o+1;break;default:a=i;break}return a},getOnePixel:function(i,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(i,o,a,c,u){var d=0,m=0,f=0,g=0,v=i;if(a>1)if(v=new c(o*a),u)for(d=0;d<o;d++)for(g=d,f=0;f<a;f++,g+=o)v[g]=i[m++];else for(d=0;d<o;d++)for(g=d,f=0;f<a;f++,g+=o)v[m++]=i[g];return v}},t=function(i,o,a){this.val=i,this.left=o,this.right=a},n={decode:function(i,o){o=o||{};var a=o.noDataValue,c=0,u={};if(u.ptr=o.inputOffset||0,u.pixels={},!!e.readHeaderInfo(i,u)){var d=u.headerInfo,m=d.fileVersion,f=e.getDataTypeArray(d.imageType);if(m>5)throw"unsupported lerc version 2."+m;e.readMask(i,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 v=!o.returnPixelInterleavedDims;if(d.numValidPixel!==0)if(d.zMax===d.zMin)e.constructConstantSurface(u,v);else if(m>=4&&e.checkMinMaxRanges(i,u))e.constructConstantSurface(u,v);else{var w=new DataView(i,u.ptr,2),b=w.getUint8(0);if(u.ptr++,b)e.readDataOneSweep(i,u,f,v);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(i,u,f,v):e.readTiles(i,u,f,v)}else e.readTiles(i,u,f,v)}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(i){var o=0,a=0,c={};for(c.ptr=0,c.pixels={};a<i.byteLength-58;)e.readHeaderInfo(i,c),a+=c.headerInfo.blobSize,o++,c.ptr=a;return o}};return n}();var cv=function(){var r=new ArrayBuffer(4),e=new Uint8Array(r),t=new Uint32Array(r);return t[0]=1,e[0]===1}(),uv={decode:function(r,e){if(!cv)throw"Big endian system is not supported.";e=e||{};var t=e.inputOffset||0,n=new Uint8Array(r,t,10),i=String.fromCharCode.apply(null,n),o,a;if(i.trim()==="CntZImage")o=av,a=1;else if(i.substring(0,5)==="Lerc2")o=lv,a=2;else throw"Unexpected file identifier string: "+i;for(var c=0,u=r.byteLength-10,d,m=[],f,g,v={width:0,height:0,pixels:[],pixelType:e.pixelType,mask:null,statistics:[]},w=0;t<u;){var b=o.decode(r,{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,v.width=b.width,v.height=b.height,v.dimCount=b.dimCount||1,v.pixelType=b.pixelType||b.fileInfo.pixelType,v.mask=g),a>1&&(g&&m.push(g),b.fileInfo.mask&&b.fileInfo.mask.numBytes>0&&w++),c++,v.pixels.push(b.pixelData),v.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=v.width*v.height,v.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];v.maskData=g}return v}};const hv={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 dv(r){const{height:e,width:t,pixels:n}=uv.decode(r),i=new Float32Array(e*t);for(let o=0;o<i.length;o++)i[o]=n[0][o];return{array:i,width:t,height:e}}function fv(r,e,t){let n=dv(r);t[2]-t[0]<1&&(n=pv(n,t));const{array:i,width:o}=n,c=new hu(o).createTile(i),u=hv[e]||0;return c.getGeometryData(u)}function pv(r,e){function t(c,u,d,m,f,g,v,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),W=L*f+M;b[W]=c[C]}const x=new Float32Array(w*v);for(let L=0;L<w;L++)for(let M=0;M<v;M++){const C=L*w+M,W=Math.round(M*g/w),D=Math.round(L*f/v)*f+W;x[C]=b[D]}return x}const n=mv(e,r.width),i=n.sw+1,o=n.sh+1;return{array:t(r.array,r.width,n.sx,n.sy,n.sw,n.sh,i,o),width:i,height:o}}function mv(r,e){const t=Math.floor(r[0]*e),n=Math.floor(r[1]*e),i=Math.floor((r[2]-r[0])*e),o=Math.floor((r[3]-r[1])*e);return{sx:t,sy:n,sw:i,sh:o}}var gv=Object.defineProperty,yv=(r,e,t)=>e in r?gv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ms=(r,e,t)=>yv(r,typeof e!="symbol"?e+"":e,t);const vv=10;class _v extends ca{constructor(){super(),Ms(this,"info",{version:"0.10.0",description:"Tile LERC terrain loader. It can load ArcGis-lerc format terrain data."}),Ms(this,"dataType","lerc"),Ms(this,"fileLoader",new p.FileLoader(De.manager)),Ms(this,"_workerPool",new Qo(0)),this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new ov)}async doLoad(e,t){this._workerPool.pool===0&&this._workerPool.setWorkerLimit(vv);const{z:n,bounds:i}=t,o=await this.fileLoader.loadAsync(e).catch(()=>new Float32Array(256*256)),a=fv(o,n,i);return new Ki().setData(a)}}pa(new _v);const _u="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGModCl7cmV0dXJuIGEodC5kYXRhKX1mdW5jdGlvbiBhKHQpe2Z1bmN0aW9uIG4oZSx1KXtjb25zdCByPXUqNCxbaSxmLGcsbF09ZS5zbGljZShyLHIrNCk7cmV0dXJuIGw9PT0wPzA6LTFlNCsoaTw8MTZ8Zjw8OHxnKSouMX1jb25zdCBvPXQubGVuZ3RoPj4+MixzPW5ldyBGbG9hdDMyQXJyYXkobyk7Zm9yKGxldCBlPTA7ZTxvO2UrKylzW2VdPW4odCxlKTtyZXR1cm4gc31zZWxmLm9ubWVzc2FnZT10PT57Y29uc3Qgbj1jKHQuZGF0YS5pbWdEYXRhKTtzZWxmLnBvc3RNZXNzYWdlKG4pfX0pKCk7Cg==",wv=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),wu=typeof self<"u"&&self.Blob&&new Blob([wv(_u)],{type:"text/javascript;charset=utf-8"});function bv(r){let e;try{if(e=wu&&(self.URL||self.webkitURL).createObjectURL(wu),!e)throw"";const t=new Worker(e,{name:r?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+_u,{name:r?.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}var xv=Object.defineProperty,Mv=(r,e,t)=>e in r?xv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ss=(r,e,t)=>Mv(r,typeof e!="symbol"?e+"":e,t);const Sv=10;class Lv extends ca{constructor(){super(),Ss(this,"info",{version:"0.10.0",description:"Mapbox-RGB terrain loader, It can load Mapbox-RGB terrain data."}),Ss(this,"dataType","terrain-rgb"),Ss(this,"imageLoader",new p.ImageLoader(De.manager)),Ss(this,"_workerPool",new Qo(0)),this._workerPool.setWorkerCreator(()=>new bv)}async doLoad(e,t){const n=await this.imageLoader.loadAsync(e).catch(u=>new Image),i=p.MathUtils.clamp((t.z+2)*3,2,64),o=Pv(n,t.bounds,i);let a;this._workerPool.pool===0&&this._workerPool.setWorkerLimit(Sv),a=(await this._workerPool.postMessage({imgData:o},[o.data.buffer])).data;const c=new Ki;return c.setData(a),c}}function Pv(r,e,t){const n=ra(e,r.width);t=Math.min(t,n.sw);const o=new OffscreenCanvas(t,t).getContext("2d");return o.imageSmoothingEnabled=!1,o.drawImage(r,n.sx,n.sy,n.sw,n.sh,0,0,t,t),o.getImageData(0,0,t,t)}pa(new Lv);function Hn(r,e){this.x=r,this.y=e}Hn.prototype={clone(){return new Hn(this.x,this.y)},add(r){return this.clone()._add(r)},sub(r){return this.clone()._sub(r)},multByPoint(r){return this.clone()._multByPoint(r)},divByPoint(r){return this.clone()._divByPoint(r)},mult(r){return this.clone()._mult(r)},div(r){return this.clone()._div(r)},rotate(r){return this.clone()._rotate(r)},rotateAround(r,e){return this.clone()._rotateAround(r,e)},matMult(r){return this.clone()._matMult(r)},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(r){return this.x===r.x&&this.y===r.y},dist(r){return Math.sqrt(this.distSqr(r))},distSqr(r){const e=r.x-this.x,t=r.y-this.y;return e*e+t*t},angle(){return Math.atan2(this.y,this.x)},angleTo(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith(r){return this.angleWithSep(r.x,r.y)},angleWithSep(r,e){return Math.atan2(this.x*e-this.y*r,this.x*r+this.y*e)},_matMult(r){const e=r[0]*this.x+r[1]*this.y,t=r[2]*this.x+r[3]*this.y;return this.x=e,this.y=t,this},_add(r){return this.x+=r.x,this.y+=r.y,this},_sub(r){return this.x-=r.x,this.y-=r.y,this},_mult(r){return this.x*=r,this.y*=r,this},_div(r){return this.x/=r,this.y/=r,this},_multByPoint(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint(r){return this.x/=r.x,this.y/=r.y,this},_unit(){return this._div(this.mag()),this},_perp(){const r=this.y;return this.y=this.x,this.x=-r,this},_rotate(r){const e=Math.cos(r),t=Math.sin(r),n=e*this.x-t*this.y,i=t*this.x+e*this.y;return this.x=n,this.y=i,this},_rotateAround(r,e){const t=Math.cos(r),n=Math.sin(r),i=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=i,this.y=o,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:Hn},Hn.convert=function(r){if(r instanceof Hn)return r;if(Array.isArray(r))return new Hn(+r[0],+r[1]);if(r.x!==void 0&&r.y!==void 0)return new Hn(+r.x,+r.y);throw new Error("Expected [x, y] or {x, y} point format")};class bu{constructor(e,t,n,i,o){this.properties={},this.extent=n,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=i,this._values=o,e.readFields(Cv,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let i,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&&(i&&n.push(i),i=[]),i&&i.push(new Hn(c,u));else if(o===7)i&&i.push(i[0].clone());else throw new Error(`unknown command ${o}`)}return i&&n.push(i),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let n=1,i=0,o=0,a=0,c=1/0,u=-1/0,d=1/0,m=-1/0;for(;e.pos<t;){if(i<=0){const f=e.readVarint();n=f&7,i=f>>3}if(i--,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 i=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/i-180,360/Math.PI*Math.atan(Math.exp((1-(g.y+a)*2/i)*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 v=d(g);m=g.length===1?{type:"Point",coordinates:v[0]}:{type:"MultiPoint",coordinates:v}}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=Gv(c),v=[];for(const w of g)v.push(w.map(d));m=v.length===1?{type:"Polygon",coordinates:v[0]}:{type:"MultiPolygon",coordinates:v}}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}}bu.types=["Unknown","Point","LineString","Polygon"];function Cv(r,e,t){r===1?e.id=t.readVarint():r===2?Tv(t,e):r===3?e.type=t.readVarint():r===4&&(e._geometry=t.pos)}function Tv(r,e){const t=r.readVarint()+r.pos;for(;r.pos<t;){const n=e._keys[r.readVarint()],i=e._values[r.readVarint()];e.properties[n]=i}}function Gv(r){const e=r.length;if(e<=1)return[r];const t=[];let n,i;for(let o=0;o<e;o++){const a=Wv(r[o]);a!==0&&(i===void 0&&(i=a<0),i===a<0?(n&&t.push(n),n=[r[o]]):n&&n.push(r[o]))}return n&&t.push(n),t}function Wv(r){let e=0;for(let t=0,n=r.length,i=n-1,o,a;t<n;i=t++)o=r[t],a=r[i],e+=(a.x-o.x)*(o.y+a.y);return e}let Zv=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(Vv,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 bu(this._pbf,t,this.extent,this._keys,this._values)}};function Vv(r,e,t){r===15?e.version=t.readVarint():r===1?e.name=t.readString():r===5?e.extent=t.readVarint():r===2?e._features.push(t.pos):r===3?e._keys.push(t.readString()):r===4&&e._values.push(Iv(t))}function Iv(r){let e=null;const t=r.readVarint()+r.pos;for(;r.pos<t;){const n=r.readVarint()>>3;e=n===1?r.readString():n===2?r.readFloat():n===3?r.readDouble():n===4?r.readVarint64():n===5?r.readVarint():n===6?r.readSVarint():n===7?r.readBoolean():null}if(e==null)throw new Error("unknown feature value");return e}class Av{constructor(e,t){this.layers=e.readFields(Fv,{},t)}}function Fv(r,e,t){if(r===3){const n=new Zv(t,t.readVarint()+t.pos);n.length&&(e[n.name]=n)}}const ma=65536*65536,xu=1/ma,Ov=12,Mu=typeof TextDecoder>"u"?null:new TextDecoder("utf-8"),ga=0,Ls=1,Wr=2,Ps=5;class Dv{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 i=this.readVarint(),o=i>>3,a=this.pos;this.type=i&7,e(o,t,this),this.pos===a&&this.skip(i)}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)*ma;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ma;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,i;return i=t[this.pos++],n=i&127,i<128||(i=t[this.pos++],n|=(i&127)<<7,i<128)||(i=t[this.pos++],n|=(i&127)<<14,i<128)||(i=t[this.pos++],n|=(i&127)<<21,i<128)?n:(i=t[this.pos],n|=(i&15)<<28,zv(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>=Ov&&Mu?Mu.decode(this.buf.subarray(t,e)):Ev(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===Wr?this.readVarint()+this.pos:this.pos+1}skip(e){const t=e&7;if(t===ga)for(;this.buf[this.pos++]>127;);else if(t===Wr)this.pos=this.readVarint()+this.pos;else if(t===Ps)this.pos+=4;else if(t===Ls)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*xu),!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*xu),!0),this.pos+=8}writeVarint(e){if(e=+e||0,e>268435455||e<0){Xv(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=$v(this.buf,e,this.pos);const n=this.pos-t;n>=128&&Su(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 i=this.pos-n;i>=128&&Su(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i}writeMessage(e,t,n){this.writeTag(e,Wr),this.writeRawMessage(t,n)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Kv,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Nv,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Rv,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Bv,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Yv,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,jv,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Jv,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Qv,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Hv,t)}writeBytesField(e,t){this.writeTag(e,Wr),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,Ps),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,Ps),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,Ls),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,Ls),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,ga),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,ga),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,Wr),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,Ps),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,Ls),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function zv(r,e,t){const n=t.buf;let i,o;if(o=n[t.pos++],i=(o&112)>>4,o<128||(o=n[t.pos++],i|=(o&127)<<3,o<128)||(o=n[t.pos++],i|=(o&127)<<10,o<128)||(o=n[t.pos++],i|=(o&127)<<17,o<128)||(o=n[t.pos++],i|=(o&127)<<24,o<128)||(o=n[t.pos++],i|=(o&1)<<31,o<128))return Ni(r,i,e);throw new Error("Expected varint not more than 10 bytes")}function Ni(r,e,t){return t?e*4294967296+(r>>>0):(e>>>0)*4294967296+(r>>>0)}function Xv(r,e){let t,n;if(r>=0?(t=r%4294967296|0,n=r/4294967296|0):(t=~(-r%4294967296),n=~(-r/4294967296),t^4294967295?t=t+1|0:(t=0,n=n+1|0)),r>=18446744073709552e3||r<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),Uv(t,n,e),kv(n,e)}function Uv(r,e,t){t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos++]=r&127|128,r>>>=7,t.buf[t.pos]=r&127}function kv(r,e){const t=(r&7)<<4;e.buf[e.pos++]|=t|((r>>>=3)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127|((r>>>=7)?128:0),r&&(e.buf[e.pos++]=r&127)))))}function Su(r,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 i=t.pos-1;i>=r;i--)t.buf[i+n]=t.buf[i]}function Kv(r,e){for(let t=0;t<r.length;t++)e.writeVarint(r[t])}function Nv(r,e){for(let t=0;t<r.length;t++)e.writeSVarint(r[t])}function Bv(r,e){for(let t=0;t<r.length;t++)e.writeFloat(r[t])}function Yv(r,e){for(let t=0;t<r.length;t++)e.writeDouble(r[t])}function Rv(r,e){for(let t=0;t<r.length;t++)e.writeBoolean(r[t])}function jv(r,e){for(let t=0;t<r.length;t++)e.writeFixed32(r[t])}function Jv(r,e){for(let t=0;t<r.length;t++)e.writeSFixed32(r[t])}function Qv(r,e){for(let t=0;t<r.length;t++)e.writeFixed64(r[t])}function Hv(r,e){for(let t=0;t<r.length;t++)e.writeSFixed64(r[t])}function Ev(r,e,t){let n="",i=e;for(;i<t;){const o=r[i];let a=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c>t)break;let u,d,m;c===1?o<128&&(a=o):c===2?(u=r[i+1],(u&192)===128&&(a=(o&31)<<6|u&63,a<=127&&(a=null))):c===3?(u=r[i+1],d=r[i+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=r[i+1],d=r[i+2],m=r[i+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),i+=c}return n}function $v(r,e,t){for(let n=0,i,o;n<e.length;n++){if(i=e.charCodeAt(n),i>55295&&i<57344)if(o)if(i<56320){r[t++]=239,r[t++]=191,r[t++]=189,o=i;continue}else i=o-55296<<10|i-56320|65536,o=null;else{i>56319||n+1===e.length?(r[t++]=239,r[t++]=191,r[t++]=189):o=i;continue}else o&&(r[t++]=239,r[t++]=191,r[t++]=189,o=null);i<128?r[t++]=i:(i<2048?r[t++]=i>>6|192:(i<65536?r[t++]=i>>12|224:(r[t++]=i>>18|240,r[t++]=i>>12&63|128),r[t++]=i>>6&63|128),r[t++]=i&63|128)}return t}var qv=Object.defineProperty,e_=(r,e,t)=>e in r?qv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ya=(r,e,t)=>e_(r,typeof e!="symbol"?e+"":e,t);class t_ extends ha{constructor(){super(),ya(this,"dataType","mvt"),ya(this,"_loader",new p.FileLoader(De.manager)),ya(this,"_render",new fu),this._loader.setResponseType("arraybuffer")}async doLoad(e,t){const n=await this._loader.loadAsync(e),i=new Av(new Dv(n)),o=this.drawTile(i,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,i=1){e.save();for(let o=0;o<t.length;o++){const a=t.feature(o);this._renderFeature(e,a,n,i)}return e.restore(),this}_renderFeature(e,t,n={},i=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,i)}_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 i of n)t.push([i.x,i.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 i=[];for(const o of n)i.push([o.x,o.y]);i.length>=2&&t.push(i)}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 i of e){const o=[];for(const a of i)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[i,o]=e[n],[a,c]=e[n+1];t+=(a-i)*(c+o)}return t>0}convertVectorTileToGeoJSON(e){const t=[];for(const n in e.layers){const i=e.layers[n];for(let o=0;o<i.length;o++){const a=i.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}}}fa(new t_);const Lu="KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO2NvbnN0IF89MjMyODMwNjQzNjUzODY5NjNlLTI2LG09MTIsUD10eXBlb2YgVGV4dERlY29kZXI+InUiP251bGw6bmV3IFRleHREZWNvZGVyKCJ1dGYtOCIpLGc9MCx5PTEsRj0yLHA9NTtjbGFzcyBNe2NvbnN0cnVjdG9yKHQ9bmV3IFVpbnQ4QXJyYXkoMTYpKXt0aGlzLmJ1Zj1BcnJheUJ1ZmZlci5pc1ZpZXcodCk/dDpuZXcgVWludDhBcnJheSh0KSx0aGlzLmRhdGFWaWV3PW5ldyBEYXRhVmlldyh0aGlzLmJ1Zi5idWZmZXIpLHRoaXMucG9zPTAsdGhpcy50eXBlPTAsdGhpcy5sZW5ndGg9dGhpcy5idWYubGVuZ3RofXJlYWRGaWVsZHModCxlLHI9dGhpcy5sZW5ndGgpe2Zvcig7dGhpcy5wb3M8cjspe2NvbnN0IHM9dGhpcy5yZWFkVmFyaW50KCksbj1zPj4zLG89dGhpcy5wb3M7dGhpcy50eXBlPXMmNyx0KG4sZSx0aGlzKSx0aGlzLnBvcz09PW8mJnRoaXMuc2tpcChzKX1yZXR1cm4gZX1yZWFkTWVzc2FnZSh0LGUpe3JldHVybiB0aGlzLnJlYWRGaWVsZHModCxlLHRoaXMucmVhZFZhcmludCgpK3RoaXMucG9zKX1yZWFkRml4ZWQzMigpe2NvbnN0IHQ9dGhpcy5kYXRhVmlldy5nZXRVaW50MzIodGhpcy5wb3MsITApO3JldHVybiB0aGlzLnBvcys9NCx0fXJlYWRTRml4ZWQzMigpe2NvbnN0IHQ9dGhpcy5kYXRhVmlldy5nZXRJbnQzMih0aGlzLnBvcywhMCk7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SxlLnJlYWRWYXJpbnQoKStlLnBvcyk7ci5sZW5ndGgmJih0W3IubmFtZV09cil9fWFzeW5jIGZ1bmN0aW9uIEsoaSx0LGUscil7dHJ5e2NvbnN0IHM9UShpLHQsZSxyKTtyZXR1cm57eDp0LHk6ZSx6OnIsbGF5ZXJzOnMsdGltZXN0YW1wOkRhdGUubm93KCksZGF0YUZvcm1hdDoibXZ0In19Y2F0Y2gocyl7dGhyb3cgY29uc29sZS5lcnJvcigi6Kej5p6Q55+i6YeP55Om54mH5pWw5o2u5pe25Ye66ZSZOiIscyksc319ZnVuY3Rpb24gUShpLHQsZSxyKXtjb25zdCBzPW5ldyBNKGkpLG49bmV3IHoocyksbz17fTtmb3IoY29uc3QgaCBpbiBuLmxheWVycyl7Y29uc3QgYT1uLmxheWVyc1toXSxkPVtdO2ZvcihsZXQgdT0wO3U8YS5sZW5ndGg7dSsrKXtjb25zdCBsPWEuZmVhdHVyZSh1KS50b0dlb0pTT04odCxlLHIpO2QucHVzaChsKX1vW2hdPWR9cmV0dXJuIG99c2VsZi5vbm1lc3NhZ2U9YXN5bmMgaT0+e2NvbnN0IHQ9aS5kYXRhO3RyeXtjb25zdCBlPWF3YWl0IEsodC5hcnJheUJ1ZmZlcix0LngsdC55LHQueik7c2VsZi5wb3N0TWVzc2FnZShlKX1jYXRjaChlKXtjb25zb2xlLmVycm9yKCJXb3JrZXIgTVZUIOino+aekOWksei0pToiLGUpLHNlbGYucG9zdE1lc3NhZ2Uoe2Vycm9yOmUubWVzc2FnZX0pfX19KSgpOwo=",n_=r=>Uint8Array.from(atob(r),e=>e.charCodeAt(0)),Pu=typeof self<"u"&&self.Blob&&new Blob([n_(Lu)],{type:"text/javascript;charset=utf-8"});function i_(r){let e;try{if(e=Pu&&(self.URL||self.webkitURL).createObjectURL(Pu),!e)throw"";const t=new Worker(e,{name:r?.name});return t.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(e)}),t}catch{return new Worker("data:text/javascript;base64,"+Lu,{name:r?.name})}finally{e&&(self.URL||self.webkitURL).revokeObjectURL(e)}}var r_=Object.defineProperty,s_=(r,e,t)=>e in r?r_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cs=(r,e,t)=>s_(r,typeof e!="symbol"?e+"":e,t);const o_=10;class a_{constructor(){Cs(this,"info",{version:"1.0.0",description:"Vector Tile loader for Mapbox Vector Tile format. It can load and parse MVT data."}),Cs(this,"dataType","VectorTile"),Cs(this,"fileLoader",new p.FileLoader(De.manager)),Cs(this,"_workerPool",new Qo(0)),this.fileLoader.setResponseType("arraybuffer"),this._workerPool.setWorkerCreator(()=>new i_)}async load(e){const{source:t,x:n,y:i,z:o}=e,a=typeof t._getUrl=="function"?t._getUrl(n,i,o):this.buildTileUrl(t.url,n,i,o);if(!a)return this.createErrorGeometry(n,i,o,new Error("VectorTileLoader: source._getUrl 返回空 URL"));this._workerPool.pool===0&&this._workerPool.setWorkerLimit(o_);try{const c=await this.fetchVectorData(a),u={arrayBuffer:c,x:n,y:i,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,i,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 i=4007501668557849e-8/Math.pow(2,n),o=-20037508342789244e-9+e*i,a=o+i,c=20037508342789244e-9-(t+1)*i,u=c+i;return{min:new p.Vector2(o,c),max:new p.Vector2(a,u),world:new p.Vector2(i,i)}}buildTileUrl(e,t,n,i){return e.replace("{x}",t.toString()).replace("{y}",n.toString()).replace("{z}",i.toString()).replace("{-y}",(Math.pow(2,i)-1-n).toString())}createGeometryWithVectorData(e,t){const n=new Ki;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,i){const o=new Ki;return o.userData={vectorData:{x:e,y:t,z:n,layers:{},totalFeatures:0,bounds:this.calculateTileBounds(e,t,n),error:i.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:i.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||[]}}gu(new a_);var l_=Object.defineProperty,c_=(r,e,t)=>e in r?l_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,En=(r,e,t)=>c_(r,typeof e!="symbol"?e+"":e,t);class va extends ou{constructor(e,t){if(super(e,t),En(this,"layerType","vector"),En(this,"_tileDataMap",new Map),En(this,"_renderer"),En(this,"_style"),En(this,"_feaList",[]),En(this,"_collision",!1),En(this,"_renderAltitude",0),En(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 i=n.tile,o=`${i.z}-${i.x}-${i.y}`,a=!!this._renderer,c=this._tileDataMap.get(o);a&&c&&this._renderer.processTileData(i,c.data)};e.addEventListener("tile-shown",t)}_addUnloadListenerToTile(e){const t=n=>{const i=n.tile||n.target,o=`${i.z}-${i.x}-${i.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 i=n.tile,o=`${i.z}-${i.x}-${i.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}`,i=this.getVectorDataFromTile(t);if(!i){console.warn(`[VectorTileLayer] Tile ${n} loaded but has no vector data.`);return}if(i.vectorData?.dataFormat==="mvt"&&this._tileDataMap.set(n,{data:i,tile:t,timestamp:Date.now(),pending:!1}),t.showing&&this._renderer&&i.vectorData?.dataFormat==="mvt")try{this._renderer.processTileData(t,i)}catch{}})}getVectorDataFromTile(e){return!e.geometry||!e.getVectorData()?null:e.getVectorData()}createLoader(){const e=new xs;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}`,i=this._tileDataMap.get(n);i&&e.push({tileKey:n,data:i.data,tile:i.tile})}}),e}getAllVectorData(){return new Map(this._tileDataMap)}getVectorData(e,t,n){const i=`${n}-${e}-${t}`,o=this._tileDataMap.get(i);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 i="feature"+n;e.on(i,o=>{this.trigger(i,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,i)=>{this._renderer.removeFeaturesByTileKey(i)}),this.getVisibleVectorTiles().forEach(({tile:n,data:i})=>{this._renderer.processTileData(n,i)})),this}setSymbol(e){return this.setStyle(e)}}var u_=Object.defineProperty,h_=(r,e,t)=>e in r?u_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ne=(r,e,t)=>h_(r,typeof e!="symbol"?e+"":e,t);class d_{constructor(...e){}}const f_={};let wi=class cf extends jo(Kn(yi(d_))){constructor(e,t){Uo(e,"container","Map container element must be specified");const n=["center","basemap"];for(const W of n)yc(t,W);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 Rg),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 Mc(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 Kg,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(W=>W.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=ls(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 x0(this.viewer.renderer,{padding:8,updateInterval:16,animationDuration:200,maxFeaturesPerFrame:2e4,strategies:{priority:!0,grouping:!0,proximity:!0}}),this.on("control-change",M0.debounce(W=>{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(W.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)},i=this.prototype;return i._onLoadHooks=i._onLoadHooks||[],i._onLoadHooks.push(n),this}_callOnLoadHooks(){const e=cf.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(),i=e.getLayers().find(o=>o.isBaseLayer===!0)?.maxLevel??e.maxLevel;return t<i?t:i+this._overZoom}getDataZoom(){return this.tilemap.getDataZoom()}getMinZoom(){return this._minZoom}getMaxZoom(){return this._maxZoom}setZoomRange(e,t){if(e>t){const i=e;e=t,t=i}this._minZoom=e,this._maxZoom=t;const n=this.viewer.controls;if(n){const i=this._computeDistanceFromZoom(this._maxZoom),o=this._computeDistanceFromZoom(this._minZoom);n.minDistance=i,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(),i=Math.max(t,Math.min(n,e)),o=this.getZoom(),a=this._computeDistanceFromZoom(i),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=i,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,i=this._minZoomDistance,o=this._maxZoomDistance;if(i<=0||i>=o){const m=Math.max(t,Math.min(n,e)),f=(n-m)/(n-t);return i+f*(o-i)}const c=(Math.max(t,Math.min(n,e))-t)/(n-t),u=i/o;return o*Math.pow(u,c)}initTileMap(e){const t=new ds({...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:_c(),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,i=e.length;n<i;n++){const o=e[n],a=o.getId();if(ls(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 va){const o=n._getRenderer();o&&this._layerContainer.remove(o)}return this.tilemap.removeLayer(t),!0}const i=this._layerContainer.getLayerById(t);return i?(this._layerContainer.remove(i),i instanceof Yn&&i?._collision,!0):(console.warn(`⚠️ Layer does not exist 图层不存在: ${t}`),!1)}addRegularLayer(e){this._layerContainer.add(e),e._bindMap(this),e instanceof Yn&&e?._collision&&(this.collisionEngine.registerLayer(e),e.setCollisionEngine(this.collisionEngine))}addTileLayer(e){if(this.tilemap.addLayer(e),e._bindMap(this),e instanceof va){const t=e.options||{},n=new ws(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 ws)),t=this.tilemap.getLayers();return[...e,...t]}getLayerById(e){const t=this._layerContainer.getLayerById(e);return t?t instanceof ws?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(),i=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),i);const d=[...t.getLayers(),...t._layerContainer.getLayers().filter(g=>g instanceof ws&&g.interactive)].filter(g=>!g?.isSceneLayer&&g?.visible===!0),f=u.intersectObjects(d,!0).map(g=>{let v=g.object,w=null;for(;v;){if(v instanceof ut){w=v;break}v=v.parent}return!w||w.visible===!1?null:{feature:w,distance:g.distance,object:g.object}}).filter(g=>!!g);return f.length?f.sort((g,v)=>g.distance-v.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 i=this.getContainer();if(!i)return null;const o=i.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 i=n/t,o=Math.log2(i),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((i,o)=>{this.off(t,o)})}),this.clearLayers(),Wc.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)}}};wi.mergeOptions(f_);const p_=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout"];wi.prototype._removeDomEvents=function(){},wi.prototype._registerDomEvents=function(){const r=this.viewer.container;if(r){let t=null;p_.forEach(n=>{r.addEventListener(n,i=>{if(!this.viewer||!this.tilemap)return;if(n==="mousedown"&&(t={x:i.clientX,y:i.clientY}),n==="click"&&t){const c=i.clientX-t.x,u=i.clientY-t.y;if(Math.sqrt(c*c+u*u)>5)return}let o=ia(i,this.tilemap,this.viewer.camera),a={target:this,originEvent:i,eventName:n,screenXY:{X:i.screenX,Y:i.screenY}};if(o){let c=[o.x,o.y,o.z];a={target:this,originEvent:i,coordinate:c,eventName:n,screenXY:{X:i.screenX,Y:i.screenY}}}this.trigger(n,a)})})}},wi.addOnLoadHook("_registerDomEvents");var m_=Object.defineProperty,g_=(r,e,t)=>e in r?m_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_a=(r,e,t)=>g_(r,typeof e!="symbol"?e+"":e,t);const y_=["click","dblclick","mousedown","mouseup","mousemove","mouseenter","mouseleave","mouseover","mouseout","contextmenu","touchstart","touchmove","touchend"];class v_ extends cs{constructor(){super(...arguments),_a(this,"_registeredEvents",[]),_a(this,"_mouseDownTime",0),_a(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&&y_.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 i=n;t.removeEventListener(i,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 i=n._getEventPosition(e);if(!i)return;const o=n._findFeaturesAt(i);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 i=this.target;if(!i||!i.tilemap||!i.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=ia(o,i.tilemap,i.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}}wi.mergeOptions({FeatureEvents:!0,onlyVisibleFeatureEvents:!0}),wi.addOnLoadHook("addHandler","FeatureEvents",v_);var __=Object.defineProperty,w_=(r,e,t)=>e in r?__(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_n=(r,e,t)=>w_(r,typeof e!="symbol"?e+"":e,t);let b_=class{constructor(...e){}};const Cu=class ur extends Kn(yi(b_)){constructor(e={}){super(e),_n(this,"_owner"),_n(this,"_map"),_n(this,"_worldPosition"),_n(this,"_coordinate"),_n(this,"_dom"),_n(this,"_visible",!1),_n(this,"_boundMapHandlers",new Map),_n(this,"_viewerUpdateHandler"),_n(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&&(ur._singletons.forEach(n=>{n!==this&&n.options.single&&n._map===t&&n.hide()}),ur._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&&ur._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&&(ur._singletons.forEach(n=>{n!==this&&n.options.single&&n._map===t&&n.isVisible()&&n.hide()}),ur._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 i=t.getContainer();if(!i)return this;i.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,i=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[i]("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[i](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,i,o=0]=this._coordinate,a=new p.Vector3(n,i,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 i;if(n.type==="Point"?i=n.coordinates:n.type==="MultiPoint"&&Array.isArray(n.coordinates)&&n.coordinates.length>0&&(i=n.coordinates[0]),i&&i.length>=2){const o=new p.Vector3(i[0],i[1],i[2]??0);return e.geo2world(o)}}if(t._threeGeometry&&typeof t._threeGeometry.getWorldPosition=="function"){const i=new p.Vector3;if(t._threeGeometry.getWorldPosition(i),!(i.x===0&&i.y===0&&i.z===0))return i}if(t._position instanceof p.Vector3){const i=t._position;if(!(i.x===0&&i.y===0&&i.z===0))return i.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 i=this._worldPosition.clone().project(t);if(i.x<-1.1||i.x>1.1||i.y<-1.1||i.y>1.1||i.z<-1||i.z>1){this._dom.style.display="none",n&&(this._dom.style.visibility="");return}const o=(i.x*.5+.5)*e.width,a=(-i.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=""}};_n(Cu,"_singletons",new Set);let Tu=Cu;var x_=Object.defineProperty,M_=(r,e,t)=>e in r?x_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Gu=(r,e,t)=>M_(r,typeof e!="symbol"?e+"":e,t);class wa extends Tu{constructor(e){super({single:!0,...e}),Gu(this,"_titleEl"),Gu(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 i=document.createElement("div");i.className="terra-infowindow-title",this.options.title&&(i.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(i),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=i,this._contentEl=a,e}getOffset(){const e=super.getOffset(),t=this._dom;if(!t)return e;const n=t.offsetWidth,i=t.offsetHeight,o=10;let a=e.x-n/2,c=e.y-i-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 v=Array.isArray(f.anchor)?f.anchor:[.5,.5],w=typeof v[1]=="number"?v[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,i=t.renderer;if(!n||!i)return 0;const o=t.height||i.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 v=e.scale.y*(1-e.center.y),w=e.scale.y*e.center.y,b=u.clone().add(g.clone().multiplyScalar(v)),x=u.clone().sub(g.clone().multiplyScalar(w)),L=b.clone().project(n),M=x.clone().project(n),C=(-L.y*.5+.5)*o,W=(-M.y*.5+.5)*o;return Math.abs(W-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(r){this.removeInfoWindow();let e;return r instanceof wa?e=r:e=new wa(r),this._infoWindow=e,this.getMap()&&e.addTo(this),this},getInfoWindow(){return this._infoWindow},openInfoWindow(r){const e=this._infoWindow;return e?(e.getMap()||this.getMap()&&e.addTo(this),requestAnimationFrame(()=>{e.open(r)}),this):this},closeInfoWindow(){return this._infoWindow&&this._infoWindow.close(),this},removeInfoWindow(){return this._infoWindow&&(this._infoWindow.remove(),this._infoWindow=void 0),this}});var S_=Object.defineProperty,L_=(r,e,t)=>e in r?S_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ba=(r,e,t)=>L_(r,typeof e!="symbol"?e+"":e,t);class P_{constructor(...e){}}class Wu extends Kn(yi(P_)){constructor(e={}){super(e),ba(this,"_map"),ba(this,"_enabled",!1),ba(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 i=t[n];if(!i)return;const o=a=>i.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 C_=Object.defineProperty,T_=(r,e,t)=>e in r?C_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Zr=(r,e,t)=>T_(r,typeof e!="symbol"?e+"":e,t);class G_ extends Yn{constructor(e){super(e,{altitude:1})}validateFeature(e){return!!e}}const Zu={};class Bi extends Wu{constructor(e){super(e),Zr(this,"_modeDef"),Zr(this,"_clickCoords",[]),Zr(this,"_isDrawing",!1),Zr(this,"_geometry"),Zr(this,"_draftLayer"),this.options.once=this.options.once??!1,this._ensureMode()}static registerMode(e,t){Zu[e.toLowerCase()]=t}static getModeDefinition(e){return Zu[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=Bi.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,i={...e,drawTool:this};this._isDrawing?(this._clickCoords.push(t),n.update(this._clickCoords,this._geometry,i),this.trigger("drawvertex",{coordinate:t,geometry:this._geometry,coords:[...this._clickCoords],originEvent:i})):(this._isDrawing=!0,this._clickCoords=[t],this._geometry=n.create(t,i),this.trigger("drawstart",{coordinate:t,geometry:this._geometry,coords:[...this._clickCoords],originEvent:i})),n.clickLimit&&this._clickCoords.length>=n.clickLimit&&this._finishDrawing(i)}_handleMouseMove(e){if(!this._modeDef||!this._isDrawing||!e.coordinate)return;const t=this._modeDef,n=[...this._clickCoords,e.coordinate],i={...e,drawTool:this};t.update(n,this._geometry,i),this.trigger("drawing",{coordinate:e.coordinate,geometry:this._geometry,coords:n,originEvent:i})}_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 G_(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 W_={actions:["click","mousemove"],create(r,e){const t=e.drawTool,n=t._getOrCreateDraftLayer(),i=$n(t.options.geometryStyle,{type:"basic-point",size:10,color:"#00ffff"}),o={type:"Point",coordinates:r},a=new Pn({geometry:o,style:i});return a.addTo(n),a.initializeGeometry(),{tool:t,draftLayer:n,draftMarker:a}},update(r,e,t){const n=e?.draftMarker;if(!n)return;const i=r[r.length-1];n._geometry={type:"Point",coordinates:i},n._position=n._coordsTransform(),n._toThreeJSGeometry&&n._toThreeJSGeometry()},generate(r,e){const t=r.tool;if(!e.length)return null;r.draftMarker&&(r.draftMarker._remove(),r.draftMarker=null);const n=$n(t.options.geometryStyle,{type:"basic-point",size:10,color:"#00ffff"}),i=e[e.length-1];return new Pn({geometry:{type:"Point",coordinates:i},style:n})},clickLimit:1},Z_={actions:["click","mousemove","dblclick"],create(r,e){const t=e.drawTool,n=t._getOrCreateDraftLayer(),i=$n(t.options.geometryStyle,{type:"basic-line",color:"#ff0000",width:2}),o=t.options.vertexStyle===null?void 0:$n(t.options.vertexStyle,{type:"basic-point",size:8,color:"#00ffff"}),a={type:"LineString",coordinates:[r]},c=new Mt({geometry:a,style:i});c.addTo(n);const u=[];if(o){const d={type:"Point",coordinates:r},m=new Pn({geometry:d,style:o});m.addTo(n),u.push(m)}return{tool:t,draftLayer:n,draftLine:c,draftAnchors:u,lineStyle:i,vertexStyle:o}},update(r,e,t){if(!e)return;const n=e.draftLayer;if(!r||r.length<2)return;e.draftLine&&(e.draftLine._remove(),e.draftLine=null);const i={type:"LineString",coordinates:r},o=new Mt({geometry:i,style:e.lineStyle});if(o.addTo(n),e.draftLine=o,t.eventName==="click"&&e.vertexStyle){const c={type:"Point",coordinates:r[r.length-1]},u=new Pn({geometry:c,style:e.vertexStyle});u.addTo(n),e.draftAnchors.push(u)}},generate(r,e){const t=r.tool;if(!e.length)return null;if(r.draftLine&&(r.draftLine._remove(),r.draftLine=null),Array.isArray(r.draftAnchors)){for(const o of r.draftAnchors)o?._remove();r.draftAnchors=[]}const n=$n(t.options.geometryStyle,{type:"basic-line",color:"#ff0000",width:2});return new Mt({geometry:{type:"LineString",coordinates:e},style:n})}},V_={actions:["click","mousemove","dblclick"],create(r,e){const t=e.drawTool,n=t._getOrCreateDraftLayer(),i=$n(t.options.geometryStyle,{type:"basic-polygon",color:"#00ff00",opacity:.5}),o=t.options.vertexStyle===null?void 0:$n(t.options.vertexStyle,{type:"basic-point",size:8,color:"#00ffff"}),a=[];if(o){const c={type:"Point",coordinates:r},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:i,vertexStyle:o}},update(r,e,t){if(!e)return;const n=e.draftLayer;if(t.eventName==="click"&&e.vertexStyle){const m={type:"Point",coordinates:r[r.length-1]},f=new Pn({geometry:m,style:e.vertexStyle});f.addTo(n),f.initializeGeometry(),e.draftAnchors.push(f)}if(!r||r.length<2){e.draftEdgeLine&&(e.draftEdgeLine._remove(),e.draftEdgeLine=null),e.draftPolygon&&(e.draftPolygon._remove(),e.draftPolygon=null);return}if(r.length===2){e.draftPolygon&&(e.draftPolygon._remove(),e.draftPolygon=null),e.draftEdgeLine&&(e.draftEdgeLine._remove(),e.draftEdgeLine=null);const d={type:"LineString",coordinates:r},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 i=r.slice(),o=i[0],a=i[i.length-1];(o[0]!==a[0]||o[1]!==a[1]||(o[2]||0)!==(a[2]||0))&&i.push(o),e.draftPolygon&&(e.draftPolygon._remove(),e.draftPolygon=null);const c={type:"Polygon",coordinates:[i]},u=new vn({geometry:c,style:e.polygonStyle});u.addTo(n),e.draftPolygon=u},generate(r,e){const t=r.tool;if(e.length<3)return null;if(r.draftPolygon&&(r.draftPolygon._remove(),r.draftPolygon=null),r.draftEdgeLine&&(r.draftEdgeLine._remove(),r.draftEdgeLine=null),Array.isArray(r.draftAnchors)){for(const u of r.draftAnchors)u?._remove();r.draftAnchors=[]}const n=$n(t.options.geometryStyle,{type:"basic-polygon",color:"#00ff00",opacity:.5}),i=e.slice(),o=i[0],a=i[i.length-1];return(o[0]!==a[0]||o[1]!==a[1]||(o[2]||0)!==(a[2]||0))&&i.push(o),new vn({geometry:{type:"Polygon",coordinates:[i]},style:n})}};Bi.registerMode("point",W_),Bi.registerMode("line",Z_),Bi.registerMode("polygon",V_);function $n(r,e){return xt.create(r||e)}var I_=Object.defineProperty,A_=(r,e,t)=>e in r?I_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rn=(r,e,t)=>A_(r,typeof e!="symbol"?e+"":e,t);class F_ 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 O_ 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 D_=Object.defineProperty,z_=(r,e,t)=>e in r?D_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vu=(r,e,t)=>z_(r,typeof e!="symbol"?e+"":e,t);class X_ extends nn{constructor(e){super({...e,url:e.urlTemplate,isTMS:e.isTMS||!1}),Vu(this,"minLevel",2),Vu(this,"maxLevel",24)}getUrl(e,t,n){const i=this.isTMS?Math.pow(2,n)-1-t:t;return hm(this.url,{...this,x:e,y:i,z:n,tileMatrix:n,tileRow:i,tileCol:e})}}var U_=Object.defineProperty,k_=(r,e,t)=>e in r?U_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cn=(r,e,t)=>k_(r,typeof e!="symbol"?e+"":e,t);class K_ 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 N_ 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 B_=Object.defineProperty,Y_=(r,e,t)=>e in r?B_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Yi=(r,e,t)=>Y_(r,typeof e!="symbol"?e+"":e,t);class R_ extends nn{constructor(e){if(super(e),Yi(this,"token",""),Yi(this,"format","webp"),Yi(this,"style","cm2myr6qx001t01pi0sf7estf"),Yi(this,"attribution","MapBox"),Yi(this,"maxLevel",25),Yi(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 j_=Object.defineProperty,J_=(r,e,t)=>e in r?j_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Iu=(r,e,t)=>J_(r,typeof e!="symbol"?e+"":e,t);class Q_ extends nn{constructor(e){super(e),Iu(this,"dataType","mvt"),Iu(this,"style",{layer:[]}),Object.assign(this,e)}}var H_=Object.defineProperty,E_=(r,e,t)=>e in r?H_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vr=(r,e,t)=>E_(r,typeof e!="symbol"?e+"":e,t);class $_ extends nn{constructor(e){super(e),Vr(this,"dataType","VectorTile"),Vr(this,"attribution","ArcGIS"),Vr(this,"minLevel",1),Vr(this,"maxLevel",21),Vr(this,"url","https://api.maptiler.com/tiles/v3/{z}/{x}/{y}.pbf?key=uKYsZQZpm72WlbSgH9B7"),Object.assign(this,e)}}class q_ extends Yn{constructor(e,t){super(e,t)}validateFeature(e){return e._baseType==="Line"}}class ew extends Yn{constructor(e,t){super(e,t)}validateFeature(e){return e._baseType==="Point"}}class tw extends Yn{constructor(e,t){super(e,t)}validateFeature(e){return e._baseType==="Surface"}}var nw=Object.defineProperty,iw=(r,e,t)=>e in r?nw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,rw=(r,e,t)=>iw(r,e+"",t);class sw extends Yn{constructor(e,t){super(e,t),rw(this,"_clouds",null);const n=["texture"];for(const i of n)yc(t,i);this._createClouds(t.texture)}async _createClouds(e){const t=await xt._loadTexture(e),n=new og({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 ow=Object.defineProperty,aw=(r,e,t)=>e in r?ow(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,lw=(r,e,t)=>aw(r,e+"",t);class cw extends ou{constructor(e,t){super(e,t),lw(this,"layerType","raster")}createLoader(){const e=new xs;return Array.isArray(this.source)?e.imgSource=this.source:e.imgSource=[this.source],e}}var uw=Object.defineProperty,hw=(r,e,t)=>e in r?uw(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ts=(r,e,t)=>hw(r,typeof e!="symbol"?e+"":e,t);class dw extends cw{constructor(e,t){super(e,t),Ts(this,"layerType","wmts"),Ts(this,"_layerName"),Ts(this,"_style"),Ts(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 xs;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"+hf+" ","color:rgb(255, 255, 255); font-weight: bold; background: linear-gradient(90deg, #ffb6c1, #ff69b4); padding: 5px; border-radius: 5px;"),q.ArcGisDemSource=N_,q.ArcGisSource=K_,q.CloudsLayer=sw,q.DrawTool=Bi,q.EventClass=ko,q.Feature=ut,q.ICloud=nu,q.InfoWindow=wa,q.Label=iu,q.LineLayer=q_,q.LineString=Mt,q.LoaderFactory=De,q.MVTGeoSource=$_,q.MVTSource=Q_,q.Map=wi,q.MapBoxSource=R_,q.MapTool=Wu,q.Marker=Pn,q.Martini=hu,q.Model=tu,q.MultiLineString=eu,q.PointLayer=ew,q.Polygon=vn,q.PolygonLayer=tw,q.ProjectFactory=Rm,q.PromiseWorker=Ly,q.Style=xt,q.TDTQMSource=O_,q.TDTSource=F_,q.TPoints=su,q.Tile=Bn,q.TileCanvasLoader=jy,q.TileGeometry=Ki,q.TileGeometryLoader=ca,q.TileLoader=xs,q.TileLoadingManager=au,q.TileMap=ds,q.TileMaterial=ua,q.TileMaterialLoader=ha,q.TileSource=nn,q.UIComponent=Tu,q.VectorFeatureTypes=nt,q.VectorTileLayer=va,q.VectorTileRender=fu,q.Viewer=Mc,q.WMTSSource=X_,q.WMTSTileLayer=dw,q.WeatherEffect=xc,q.addSkirt=cu,q.author=iv,q.concatenateTypedArrays=Gr,q.convertGeometryToWGS84=Ty,q.createBillboards=Jm,q.getBoundsCoord=ra,q.getGeometryDataFromDem=uu,q.getGridIndices=aa,q.getLocalInfoFromRay=Yo,q.getLocalInfoFromScreen=Tc,q.getLocalInfoFromWorld=Ro,q.getNormals=la,q.getSafeTileUrlAndBounds=sa,q.registerDEMLoader=pa,q.registerImgLoader=fa,q.registerMeshLoader=gu,q.vector2ToWGS84=oa,q.version=nv,q.waitFor=rv,Object.defineProperty(q,Symbol.toStringTag,{value:"Module"})});