(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['loaders'] = factory(); else root['loaders'] = factory();})(globalThis, function () { "use strict";var __exports__=(()=>{var ar=Object.create;var Yt=Object.defineProperty;var hr=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var fr=Object.getPrototypeOf,mr=Object.prototype.hasOwnProperty;var pr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ct=(e,t)=>{for(var s in t)Yt(e,s,{get:t[s],enumerable:!0})},Bt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of lr(t))!mr.call(e,r)&&r!==s&&Yt(e,r,{get:()=>t[r],enumerable:!(n=hr(t,r))||n.enumerable});return e},Gt=(e,t,s)=>(Bt(e,t,"default"),s&&Bt(s,t,"default")),Oe=(e,t,s)=>(s=e!=null?ar(fr(e)):{},Bt(t||!e||!e.__esModule?Yt(s,"default",{value:e,enumerable:!0}):s,e)),dr=e=>Bt(Yt({},"__esModule",{value:!0}),e);var Zt=pr((ac,ys)=>{ys.exports=globalThis.loaders});var kt={};Ct(kt,{LOD_METRIC_TYPE:()=>xe,TILESET_TYPE:()=>W,TILE_CONTENT_STATE:()=>Y,TILE_REFINEMENT:()=>Z,TILE_TYPE:()=>ue,Tile3D:()=>it,Tileset3D:()=>we,TilesetCache:()=>Rt,TilesetTraverser:()=>K,calculateTransformProps:()=>he,createBoundingVolume:()=>At,getFrameState:()=>de,getLodStatus:()=>Me});Gt(kt,Oe(Zt(),1));var ur=1/Math.PI*180,xr=1/180*Math.PI,gr={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...gr}};var z=globalThis.mathgl.config;function Ae(e,{precision:t=z.precision}={}){return e=Mr(e),`${parseFloat(e.toPrecision(t))}`}function tt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ce(e){return _s(e)}function Pe(e){return j(e)}function _s(e,t){return Ss(e,s=>s*xr,t)}function j(e,t){return Ss(e,s=>s*ur,t)}function X(e,t,s){let n=z.EPSILON;s&&(z.EPSILON=s);try{if(e===t)return!0;if(tt(e)&&tt(t)){if(e.length!==t.length)return!1;for(let r=0;r0?", ":"")+Ae(this[n],t);return`${t.printTypes?this.constructor.name:""}[${s}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let s=0;s=0&&t=0&&t=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var Tc=Math.PI/180;function _r(){let e=new V(2);return V!=Float32Array&&(e[0]=0,e[1]=0),e}function Es(e,t,s){let n=t[0],r=t[1];return e[0]=s[0]*n+s[3]*r+s[6],e[1]=s[1]*n+s[4]*r+s[7],e}function ws(e,t,s){let n=t[0],r=t[1];return e[0]=s[0]*n+s[4]*r+s[12],e[1]=s[1]*n+s[5]*r+s[13],e}var yc=function(){let e=_r();return function(t,s,n,r,i,o){let c,a;for(s||(s=2),n||(n=0),r?a=Math.min(r*s+n,t.length):a=t.length,c=n;cRr,angle:()=>qe,bezier:()=>Dr,ceil:()=>Or,clone:()=>Sr,copy:()=>Er,create:()=>Xt,cross:()=>pt,dist:()=>$r,distance:()=>vs,div:()=>Zr,divide:()=>Ls,dot:()=>Nt,equals:()=>Br,exactEquals:()=>Wr,floor:()=>Ar,forEach:()=>Qr,fromValues:()=>Qt,hermite:()=>Vr,inverse:()=>qr,len:()=>be,length:()=>Cs,lerp:()=>br,max:()=>Pr,min:()=>Cr,mul:()=>Gr,multiply:()=>Ns,negate:()=>Ir,normalize:()=>Ne,random:()=>Ur,rotateX:()=>Le,rotateY:()=>ve,rotateZ:()=>Ie,round:()=>Nr,scale:()=>Lr,scaleAndAdd:()=>vr,set:()=>wr,slerp:()=>zr,sqrDist:()=>jr,sqrLen:()=>Xr,squaredDistance:()=>Is,squaredLength:()=>qs,str:()=>kr,sub:()=>Yr,subtract:()=>Ps,transformMat3:()=>Lt,transformMat4:()=>dt,transformQuat:()=>vt,zero:()=>Fr});function Xt(){let e=new V(3);return V!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Sr(e){let t=new V(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Cs(e){let t=e[0],s=e[1],n=e[2];return Math.sqrt(t*t+s*s+n*n)}function Qt(e,t,s){let n=new V(3);return n[0]=e,n[1]=t,n[2]=s,n}function Er(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function wr(e,t,s,n){return e[0]=t,e[1]=s,e[2]=n,e}function Rr(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e}function Ps(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e}function Ns(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e}function Ls(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e[2]=t[2]/s[2],e}function Or(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function Ar(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Cr(e,t,s){return e[0]=Math.min(t[0],s[0]),e[1]=Math.min(t[1],s[1]),e[2]=Math.min(t[2],s[2]),e}function Pr(e,t,s){return e[0]=Math.max(t[0],s[0]),e[1]=Math.max(t[1],s[1]),e[2]=Math.max(t[2],s[2]),e}function Nr(e,t){return e[0]=Tt(t[0]),e[1]=Tt(t[1]),e[2]=Tt(t[2]),e}function Lr(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function vr(e,t,s,n){return e[0]=t[0]+s[0]*n,e[1]=t[1]+s[1]*n,e[2]=t[2]+s[2]*n,e}function vs(e,t){let s=t[0]-e[0],n=t[1]-e[1],r=t[2]-e[2];return Math.sqrt(s*s+n*n+r*r)}function Is(e,t){let s=t[0]-e[0],n=t[1]-e[1],r=t[2]-e[2];return s*s+n*n+r*r}function qs(e){let t=e[0],s=e[1],n=e[2];return t*t+s*s+n*n}function Ir(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function qr(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Ne(e,t){let s=t[0],n=t[1],r=t[2],i=s*s+n*n+r*r;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Nt(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function pt(e,t,s){let n=t[0],r=t[1],i=t[2],o=s[0],c=s[1],a=s[2];return e[0]=r*a-i*c,e[1]=i*o-n*a,e[2]=n*c-r*o,e}function br(e,t,s,n){let r=t[0],i=t[1],o=t[2];return e[0]=r+n*(s[0]-r),e[1]=i+n*(s[1]-i),e[2]=o+n*(s[2]-o),e}function zr(e,t,s,n){let r=Math.acos(Math.min(Math.max(Nt(t,s),-1),1)),i=Math.sin(r),o=Math.sin((1-n)*r)/i,c=Math.sin(n*r)/i;return e[0]=o*t[0]+c*s[0],e[1]=o*t[1]+c*s[1],e[2]=o*t[2]+c*s[2],e}function Vr(e,t,s,n,r,i){let o=i*i,c=o*(2*i-3)+1,a=o*(i-2)+i,h=o*(i-1),l=o*(3-2*i);return e[0]=t[0]*c+s[0]*a+n[0]*h+r[0]*l,e[1]=t[1]*c+s[1]*a+n[1]*h+r[1]*l,e[2]=t[2]*c+s[2]*a+n[2]*h+r[2]*l,e}function Dr(e,t,s,n,r,i){let o=1-i,c=o*o,a=i*i,h=c*o,l=3*i*c,f=3*a*o,m=a*i;return e[0]=t[0]*h+s[0]*l+n[0]*f+r[0]*m,e[1]=t[1]*h+s[1]*l+n[1]*f+r[1]*m,e[2]=t[2]*h+s[2]*l+n[2]*f+r[2]*m,e}function Ur(e,t){t=t===void 0?1:t;let s=Pt()*2*Math.PI,n=Pt()*2-1,r=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(s)*r,e[1]=Math.sin(s)*r,e[2]=n*t,e}function dt(e,t,s){let n=t[0],r=t[1],i=t[2],o=s[3]*n+s[7]*r+s[11]*i+s[15];return o=o||1,e[0]=(s[0]*n+s[4]*r+s[8]*i+s[12])/o,e[1]=(s[1]*n+s[5]*r+s[9]*i+s[13])/o,e[2]=(s[2]*n+s[6]*r+s[10]*i+s[14])/o,e}function Lt(e,t,s){let n=t[0],r=t[1],i=t[2];return e[0]=n*s[0]+r*s[3]+i*s[6],e[1]=n*s[1]+r*s[4]+i*s[7],e[2]=n*s[2]+r*s[5]+i*s[8],e}function vt(e,t,s){let n=s[0],r=s[1],i=s[2],o=s[3],c=t[0],a=t[1],h=t[2],l=r*h-i*a,f=i*c-n*h,m=n*a-r*c,p=r*m-i*f,x=i*l-n*m,g=n*f-r*l,u=o*2;return l*=u,f*=u,m*=u,p*=2,x*=2,g*=2,e[0]=c+l+p,e[1]=a+f+x,e[2]=h+m+g,e}function Le(e,t,s,n){let r=[],i=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],i[0]=r[0],i[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),i[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=i[0]+s[0],e[1]=i[1]+s[1],e[2]=i[2]+s[2],e}function ve(e,t,s,n){let r=[],i=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],i[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),i[1]=r[1],i[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=i[0]+s[0],e[1]=i[1]+s[1],e[2]=i[2]+s[2],e}function Ie(e,t,s,n){let r=[],i=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],i[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),i[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),i[2]=r[2],e[0]=i[0]+s[0],e[1]=i[1]+s[1],e[2]=i[2]+s[2],e}function qe(e,t){let s=e[0],n=e[1],r=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((s*s+n*n+r*r)*(i*i+o*o+c*c)),h=a&&Nt(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}function Fr(e){return e[0]=0,e[1]=0,e[2]=0,e}function kr(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function Wr(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function Br(e,t){let s=e[0],n=e[1],r=e[2],i=t[0],o=t[1],c=t[2];return Math.abs(s-i)<=1e-6*Math.max(1,Math.abs(s),Math.abs(i))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-c)<=1e-6*Math.max(1,Math.abs(r),Math.abs(c))}var Yr=Ps,Gr=Ns,Zr=Ls,$r=vs,jr=Is,be=Cs,Xr=qs,Qr=function(){let e=Xt();return function(t,s,n,r,i,o){let c,a;for(s||(s=3),n||(n=0),r?a=Math.min(r*s+n,t.length):a=t.length,c=n;c0?this.copy([t,...s]):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}identity(){return this.copy(Hr)}fromObject(t){return this.check()}fromQuaternion(t){return ks(this,t),this.check()}set(t,s,n,r,i,o,c,a,h){return this[0]=t,this[1]=s,this[2]=n,this[3]=r,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this.check()}setRowMajor(t,s,n,r,i,o,c,a,h){return this[0]=t,this[1]=r,this[2]=c,this[3]=s,this[4]=i,this[5]=a,this[6]=n,this[7]=o,this[8]=h,this.check()}determinant(){return Ds(this)}transpose(){return zs(this,this),this.check()}invert(){return Vs(this,this),this.check()}multiplyLeft(t){return Ve(this,t,this),this.check()}multiplyRight(t){return Ve(this,this,t),this.check()}rotate(t){return Fs(this,this,t),this.check()}scale(t){return Array.isArray(t)?De(this,this,t):De(this,this,[t,t]),this.check()}translate(t){return Us(this,this,t),this.check()}transform(t,s){let n;switch(t.length){case 2:n=Es(s||[-0,-0],t,this);break;case 3:n=Lt(s||[-0,-0,-0],t,this);break;case 4:n=jt(s||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ct(n,t.length),n}transformVector(t,s){return this.transform(t,s)}transformVector2(t,s){return this.transform(t,s)}transformVector3(t,s){return this.transform(t,s)}},Jt,te=null;function Jr(){return Jt||(Jt=new D([0,0,0,0,0,0,0,0,0]),Object.freeze(Jt)),Jt}function ti(){return te||(te=new D,Object.freeze(te)),te}var qt={};Ct(qt,{add:()=>Ri,adjoint:()=>oi,clone:()=>si,copy:()=>ni,create:()=>ei,decompose:()=>xi,determinant:()=>We,equals:()=>Pi,exactEquals:()=>Ci,frob:()=>wi,fromQuat:()=>Xe,fromQuat2:()=>pi,fromRotation:()=>hi,fromRotationTranslation:()=>Bs,fromRotationTranslationScale:()=>gi,fromRotationTranslationScaleOrigin:()=>Mi,fromScaling:()=>ai,fromTranslation:()=>ci,fromValues:()=>ri,fromXRotation:()=>li,fromYRotation:()=>fi,fromZRotation:()=>mi,frustum:()=>Qe,getRotation:()=>ui,getScaling:()=>Ys,getTranslation:()=>di,identity:()=>Ws,invert:()=>ke,lookAt:()=>Je,mul:()=>Ni,multiply:()=>It,multiplyScalar:()=>Oi,multiplyScalarAndAdd:()=>Ai,ortho:()=>He,orthoNO:()=>Zs,orthoZO:()=>_i,perspective:()=>Ke,perspectiveFromFieldOfView:()=>yi,perspectiveNO:()=>Gs,perspectiveZO:()=>Ti,rotate:()=>Ge,rotateX:()=>Ze,rotateY:()=>$e,rotateZ:()=>je,scale:()=>Ye,set:()=>ii,str:()=>Ei,sub:()=>Li,subtract:()=>$s,targetTo:()=>Si,translate:()=>Be,transpose:()=>Fe});function ei(){let e=new V(16);return V!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function si(e){let t=new V(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ni(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ri(e,t,s,n,r,i,o,c,a,h,l,f,m,p,x,g){let u=new V(16);return u[0]=e,u[1]=t,u[2]=s,u[3]=n,u[4]=r,u[5]=i,u[6]=o,u[7]=c,u[8]=a,u[9]=h,u[10]=l,u[11]=f,u[12]=m,u[13]=p,u[14]=x,u[15]=g,u}function ii(e,t,s,n,r,i,o,c,a,h,l,f,m,p,x,g,u){return e[0]=t,e[1]=s,e[2]=n,e[3]=r,e[4]=i,e[5]=o,e[6]=c,e[7]=a,e[8]=h,e[9]=l,e[10]=f,e[11]=m,e[12]=p,e[13]=x,e[14]=g,e[15]=u,e}function Ws(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Fe(e,t){if(e===t){let s=t[1],n=t[2],r=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=s,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=i,e[11]=t[14],e[12]=r,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function ke(e,t){let s=t[0],n=t[1],r=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],m=t[10],p=t[11],x=t[12],g=t[13],u=t[14],M=t[15],E=s*c-n*o,y=s*a-r*o,T=s*h-i*o,S=n*a-r*c,_=n*h-i*c,P=r*h-i*a,R=l*g-f*x,O=l*u-m*x,w=l*M-p*x,I=f*u-m*g,q=f*M-p*g,b=m*M-p*u,A=E*b-y*q+T*I+S*w-_*O+P*R;return A?(A=1/A,e[0]=(c*b-a*q+h*I)*A,e[1]=(r*q-n*b-i*I)*A,e[2]=(g*P-u*_+M*S)*A,e[3]=(m*_-f*P-p*S)*A,e[4]=(a*w-o*b-h*O)*A,e[5]=(s*b-r*w+i*O)*A,e[6]=(u*T-x*P-M*y)*A,e[7]=(l*P-m*T+p*y)*A,e[8]=(o*q-c*w+h*R)*A,e[9]=(n*w-s*q-i*R)*A,e[10]=(x*_-g*T+M*E)*A,e[11]=(f*T-l*_-p*E)*A,e[12]=(c*O-o*I-a*R)*A,e[13]=(s*I-n*O+r*R)*A,e[14]=(g*y-x*S-u*E)*A,e[15]=(l*S-f*y+m*E)*A,e):null}function oi(e,t){let s=t[0],n=t[1],r=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],m=t[10],p=t[11],x=t[12],g=t[13],u=t[14],M=t[15],E=s*c-n*o,y=s*a-r*o,T=s*h-i*o,S=n*a-r*c,_=n*h-i*c,P=r*h-i*a,R=l*g-f*x,O=l*u-m*x,w=l*M-p*x,I=f*u-m*g,q=f*M-p*g,b=m*M-p*u;return e[0]=c*b-a*q+h*I,e[1]=r*q-n*b-i*I,e[2]=g*P-u*_+M*S,e[3]=m*_-f*P-p*S,e[4]=a*w-o*b-h*O,e[5]=s*b-r*w+i*O,e[6]=u*T-x*P-M*y,e[7]=l*P-m*T+p*y,e[8]=o*q-c*w+h*R,e[9]=n*w-s*q-i*R,e[10]=x*_-g*T+M*E,e[11]=f*T-l*_-p*E,e[12]=c*O-o*I-a*R,e[13]=s*I-n*O+r*R,e[14]=g*y-x*S-u*E,e[15]=l*S-f*y+m*E,e}function We(e){let t=e[0],s=e[1],n=e[2],r=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8],l=e[9],f=e[10],m=e[11],p=e[12],x=e[13],g=e[14],u=e[15],M=t*o-s*i,E=t*c-n*i,y=s*c-n*o,T=h*x-l*p,S=h*g-f*p,_=l*g-f*x,P=t*_-s*S+n*T,R=i*_-o*S+c*T,O=h*y-l*E+f*M,w=p*y-x*E+g*M;return a*P-r*R+u*O-m*w}function It(e,t,s){let n=t[0],r=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],m=t[9],p=t[10],x=t[11],g=t[12],u=t[13],M=t[14],E=t[15],y=s[0],T=s[1],S=s[2],_=s[3];return e[0]=y*n+T*c+S*f+_*g,e[1]=y*r+T*a+S*m+_*u,e[2]=y*i+T*h+S*p+_*M,e[3]=y*o+T*l+S*x+_*E,y=s[4],T=s[5],S=s[6],_=s[7],e[4]=y*n+T*c+S*f+_*g,e[5]=y*r+T*a+S*m+_*u,e[6]=y*i+T*h+S*p+_*M,e[7]=y*o+T*l+S*x+_*E,y=s[8],T=s[9],S=s[10],_=s[11],e[8]=y*n+T*c+S*f+_*g,e[9]=y*r+T*a+S*m+_*u,e[10]=y*i+T*h+S*p+_*M,e[11]=y*o+T*l+S*x+_*E,y=s[12],T=s[13],S=s[14],_=s[15],e[12]=y*n+T*c+S*f+_*g,e[13]=y*r+T*a+S*m+_*u,e[14]=y*i+T*h+S*p+_*M,e[15]=y*o+T*l+S*x+_*E,e}function Be(e,t,s){let n=s[0],r=s[1],i=s[2],o,c,a,h,l,f,m,p,x,g,u,M;return t===e?(e[12]=t[0]*n+t[4]*r+t[8]*i+t[12],e[13]=t[1]*n+t[5]*r+t[9]*i+t[13],e[14]=t[2]*n+t[6]*r+t[10]*i+t[14],e[15]=t[3]*n+t[7]*r+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],h=t[3],l=t[4],f=t[5],m=t[6],p=t[7],x=t[8],g=t[9],u=t[10],M=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=m,e[7]=p,e[8]=x,e[9]=g,e[10]=u,e[11]=M,e[12]=o*n+l*r+x*i+t[12],e[13]=c*n+f*r+g*i+t[13],e[14]=a*n+m*r+u*i+t[14],e[15]=h*n+p*r+M*i+t[15]),e}function Ye(e,t,s){let n=s[0],r=s[1],i=s[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ge(e,t,s,n){let r=n[0],i=n[1],o=n[2],c=Math.sqrt(r*r+i*i+o*o),a,h,l,f,m,p,x,g,u,M,E,y,T,S,_,P,R,O,w,I,q,b,A,$;return c<1e-6?null:(c=1/c,r*=c,i*=c,o*=c,h=Math.sin(s),a=Math.cos(s),l=1-a,f=t[0],m=t[1],p=t[2],x=t[3],g=t[4],u=t[5],M=t[6],E=t[7],y=t[8],T=t[9],S=t[10],_=t[11],P=r*r*l+a,R=i*r*l+o*h,O=o*r*l-i*h,w=r*i*l-o*h,I=i*i*l+a,q=o*i*l+r*h,b=r*o*l+i*h,A=i*o*l-r*h,$=o*o*l+a,e[0]=f*P+g*R+y*O,e[1]=m*P+u*R+T*O,e[2]=p*P+M*R+S*O,e[3]=x*P+E*R+_*O,e[4]=f*w+g*I+y*q,e[5]=m*w+u*I+T*q,e[6]=p*w+M*I+S*q,e[7]=x*w+E*I+_*q,e[8]=f*b+g*A+y*$,e[9]=m*b+u*A+T*$,e[10]=p*b+M*A+S*$,e[11]=x*b+E*A+_*$,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Ze(e,t,s){let n=Math.sin(s),r=Math.cos(s),i=t[4],o=t[5],c=t[6],a=t[7],h=t[8],l=t[9],f=t[10],m=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*r+h*n,e[5]=o*r+l*n,e[6]=c*r+f*n,e[7]=a*r+m*n,e[8]=h*r-i*n,e[9]=l*r-o*n,e[10]=f*r-c*n,e[11]=m*r-a*n,e}function $e(e,t,s){let n=Math.sin(s),r=Math.cos(s),i=t[0],o=t[1],c=t[2],a=t[3],h=t[8],l=t[9],f=t[10],m=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*r-h*n,e[1]=o*r-l*n,e[2]=c*r-f*n,e[3]=a*r-m*n,e[8]=i*n+h*r,e[9]=o*n+l*r,e[10]=c*n+f*r,e[11]=a*n+m*r,e}function je(e,t,s){let n=Math.sin(s),r=Math.cos(s),i=t[0],o=t[1],c=t[2],a=t[3],h=t[4],l=t[5],f=t[6],m=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*r+h*n,e[1]=o*r+l*n,e[2]=c*r+f*n,e[3]=a*r+m*n,e[4]=h*r-i*n,e[5]=l*r-o*n,e[6]=f*r-c*n,e[7]=m*r-a*n,e}function ci(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function ai(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function hi(e,t,s){let n=s[0],r=s[1],i=s[2],o=Math.sqrt(n*n+r*r+i*i),c,a,h;return o<1e-6?null:(o=1/o,n*=o,r*=o,i*=o,a=Math.sin(t),c=Math.cos(t),h=1-c,e[0]=n*n*h+c,e[1]=r*n*h+i*a,e[2]=i*n*h-r*a,e[3]=0,e[4]=n*r*h-i*a,e[5]=r*r*h+c,e[6]=i*r*h+n*a,e[7]=0,e[8]=n*i*h+r*a,e[9]=r*i*h-n*a,e[10]=i*i*h+c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function li(e,t){let s=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=s,e[7]=0,e[8]=0,e[9]=-s,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function fi(e,t){let s=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-s,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=s,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function mi(e,t){let s=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=s,e[2]=0,e[3]=0,e[4]=-s,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Bs(e,t,s){let n=t[0],r=t[1],i=t[2],o=t[3],c=n+n,a=r+r,h=i+i,l=n*c,f=n*a,m=n*h,p=r*a,x=r*h,g=i*h,u=o*c,M=o*a,E=o*h;return e[0]=1-(p+g),e[1]=f+E,e[2]=m-M,e[3]=0,e[4]=f-E,e[5]=1-(l+g),e[6]=x+u,e[7]=0,e[8]=m+M,e[9]=x-u,e[10]=1-(l+p),e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function pi(e,t){let s=new V(3),n=-t[0],r=-t[1],i=-t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=n*n+r*r+i*i+o*o;return f>0?(s[0]=(c*o+l*n+a*i-h*r)*2/f,s[1]=(a*o+l*r+h*n-c*i)*2/f,s[2]=(h*o+l*i+c*r-a*n)*2/f):(s[0]=(c*o+l*n+a*i-h*r)*2,s[1]=(a*o+l*r+h*n-c*i)*2,s[2]=(h*o+l*i+c*r-a*n)*2),Bs(e,t,s),e}function di(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Ys(e,t){let s=t[0],n=t[1],r=t[2],i=t[4],o=t[5],c=t[6],a=t[8],h=t[9],l=t[10];return e[0]=Math.sqrt(s*s+n*n+r*r),e[1]=Math.sqrt(i*i+o*o+c*c),e[2]=Math.sqrt(a*a+h*h+l*l),e}function ui(e,t){let s=new V(3);Ys(s,t);let n=1/s[0],r=1/s[1],i=1/s[2],o=t[0]*n,c=t[1]*r,a=t[2]*i,h=t[4]*n,l=t[5]*r,f=t[6]*i,m=t[8]*n,p=t[9]*r,x=t[10]*i,g=o+l+x,u=0;return g>0?(u=Math.sqrt(g+1)*2,e[3]=.25*u,e[0]=(f-p)/u,e[1]=(m-a)/u,e[2]=(c-h)/u):o>l&&o>x?(u=Math.sqrt(1+o-l-x)*2,e[3]=(f-p)/u,e[0]=.25*u,e[1]=(c+h)/u,e[2]=(m+a)/u):l>x?(u=Math.sqrt(1+l-o-x)*2,e[3]=(m-a)/u,e[0]=(c+h)/u,e[1]=.25*u,e[2]=(f+p)/u):(u=Math.sqrt(1+x-o-l)*2,e[3]=(c-h)/u,e[0]=(m+a)/u,e[1]=(f+p)/u,e[2]=.25*u),e}function xi(e,t,s,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];let r=n[0],i=n[1],o=n[2],c=n[4],a=n[5],h=n[6],l=n[8],f=n[9],m=n[10];s[0]=Math.sqrt(r*r+i*i+o*o),s[1]=Math.sqrt(c*c+a*a+h*h),s[2]=Math.sqrt(l*l+f*f+m*m);let p=1/s[0],x=1/s[1],g=1/s[2],u=r*p,M=i*x,E=o*g,y=c*p,T=a*x,S=h*g,_=l*p,P=f*x,R=m*g,O=u+T+R,w=0;return O>0?(w=Math.sqrt(O+1)*2,e[3]=.25*w,e[0]=(S-P)/w,e[1]=(_-E)/w,e[2]=(M-y)/w):u>T&&u>R?(w=Math.sqrt(1+u-T-R)*2,e[3]=(S-P)/w,e[0]=.25*w,e[1]=(M+y)/w,e[2]=(_+E)/w):T>R?(w=Math.sqrt(1+T-u-R)*2,e[3]=(_-E)/w,e[0]=(M+y)/w,e[1]=.25*w,e[2]=(S+P)/w):(w=Math.sqrt(1+R-u-T)*2,e[3]=(M-y)/w,e[0]=(_+E)/w,e[1]=(S+P)/w,e[2]=.25*w),e}function gi(e,t,s,n){let r=t[0],i=t[1],o=t[2],c=t[3],a=r+r,h=i+i,l=o+o,f=r*a,m=r*h,p=r*l,x=i*h,g=i*l,u=o*l,M=c*a,E=c*h,y=c*l,T=n[0],S=n[1],_=n[2];return e[0]=(1-(x+u))*T,e[1]=(m+y)*T,e[2]=(p-E)*T,e[3]=0,e[4]=(m-y)*S,e[5]=(1-(f+u))*S,e[6]=(g+M)*S,e[7]=0,e[8]=(p+E)*_,e[9]=(g-M)*_,e[10]=(1-(f+x))*_,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function Mi(e,t,s,n,r){let i=t[0],o=t[1],c=t[2],a=t[3],h=i+i,l=o+o,f=c+c,m=i*h,p=i*l,x=i*f,g=o*l,u=o*f,M=c*f,E=a*h,y=a*l,T=a*f,S=n[0],_=n[1],P=n[2],R=r[0],O=r[1],w=r[2],I=(1-(g+M))*S,q=(p+T)*S,b=(x-y)*S,A=(p-T)*_,$=(1-(m+M))*_,ft=(u+E)*_,mt=(x+y)*P,Re=(u-E)*P,Wt=(1-(m+g))*P;return e[0]=I,e[1]=q,e[2]=b,e[3]=0,e[4]=A,e[5]=$,e[6]=ft,e[7]=0,e[8]=mt,e[9]=Re,e[10]=Wt,e[11]=0,e[12]=s[0]+R-(I*R+A*O+mt*w),e[13]=s[1]+O-(q*R+$*O+Re*w),e[14]=s[2]+w-(b*R+ft*O+Wt*w),e[15]=1,e}function Xe(e,t){let s=t[0],n=t[1],r=t[2],i=t[3],o=s+s,c=n+n,a=r+r,h=s*o,l=n*o,f=n*c,m=r*o,p=r*c,x=r*a,g=i*o,u=i*c,M=i*a;return e[0]=1-f-x,e[1]=l+M,e[2]=m-u,e[3]=0,e[4]=l-M,e[5]=1-h-x,e[6]=p+g,e[7]=0,e[8]=m+u,e[9]=p-g,e[10]=1-h-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Qe(e,t,s,n,r,i,o){let c=1/(s-t),a=1/(r-n),h=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(s+t)*c,e[9]=(r+n)*a,e[10]=(o+i)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*h,e[15]=0,e}function Gs(e,t,s,n,r){let i=1/Math.tan(t/2);if(e[0]=i/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,r!=null&&r!==1/0){let o=1/(n-r);e[10]=(r+n)*o,e[14]=2*r*n*o}else e[10]=-1,e[14]=-2*n;return e}var Ke=Gs;function Ti(e,t,s,n,r){let i=1/Math.tan(t/2);if(e[0]=i/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,r!=null&&r!==1/0){let o=1/(n-r);e[10]=r*o,e[14]=r*n*o}else e[10]=-1,e[14]=-n;return e}function yi(e,t,s,n){let r=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),c=Math.tan(t.rightDegrees*Math.PI/180),a=2/(o+c),h=2/(r+i);return e[0]=a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=h,e[6]=0,e[7]=0,e[8]=-((o-c)*a*.5),e[9]=(r-i)*h*.5,e[10]=n/(s-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*s/(s-n),e[15]=0,e}function Zs(e,t,s,n,r,i,o){let c=1/(t-s),a=1/(n-r),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+s)*c,e[13]=(r+n)*a,e[14]=(o+i)*h,e[15]=1,e}var He=Zs;function _i(e,t,s,n,r,i,o){let c=1/(t-s),a=1/(n-r),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=h,e[11]=0,e[12]=(t+s)*c,e[13]=(r+n)*a,e[14]=i*h,e[15]=1,e}function Je(e,t,s,n){let r,i,o,c,a,h,l,f,m,p,x=t[0],g=t[1],u=t[2],M=n[0],E=n[1],y=n[2],T=s[0],S=s[1],_=s[2];return Math.abs(x-T)<1e-6&&Math.abs(g-S)<1e-6&&Math.abs(u-_)<1e-6?Ws(e):(f=x-T,m=g-S,p=u-_,r=1/Math.sqrt(f*f+m*m+p*p),f*=r,m*=r,p*=r,i=E*p-y*m,o=y*f-M*p,c=M*m-E*f,r=Math.sqrt(i*i+o*o+c*c),r?(r=1/r,i*=r,o*=r,c*=r):(i=0,o=0,c=0),a=m*c-p*o,h=p*i-f*c,l=f*o-m*i,r=Math.sqrt(a*a+h*h+l*l),r?(r=1/r,a*=r,h*=r,l*=r):(a=0,h=0,l=0),e[0]=i,e[1]=a,e[2]=f,e[3]=0,e[4]=o,e[5]=h,e[6]=m,e[7]=0,e[8]=c,e[9]=l,e[10]=p,e[11]=0,e[12]=-(i*x+o*g+c*u),e[13]=-(a*x+h*g+l*u),e[14]=-(f*x+m*g+p*u),e[15]=1,e)}function Si(e,t,s,n){let r=t[0],i=t[1],o=t[2],c=n[0],a=n[1],h=n[2],l=r-s[0],f=i-s[1],m=o-s[2],p=l*l+f*f+m*m;p>0&&(p=1/Math.sqrt(p),l*=p,f*=p,m*=p);let x=a*m-h*f,g=h*l-c*m,u=c*f-a*l;return p=x*x+g*g+u*u,p>0&&(p=1/Math.sqrt(p),x*=p,g*=p,u*=p),e[0]=x,e[1]=g,e[2]=u,e[3]=0,e[4]=f*u-m*g,e[5]=m*x-l*u,e[6]=l*g-f*x,e[7]=0,e[8]=l,e[9]=f,e[10]=m,e[11]=0,e[12]=r,e[13]=i,e[14]=o,e[15]=1,e}function Ei(e){return`mat4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]}, ${e[4]}, ${e[5]}, ${e[6]}, ${e[7]}, ${e[8]}, ${e[9]}, ${e[10]}, ${e[11]}, ${e[12]}, ${e[13]}, ${e[14]}, ${e[15]})`}function wi(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function Ri(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e[4]=t[4]+s[4],e[5]=t[5]+s[5],e[6]=t[6]+s[6],e[7]=t[7]+s[7],e[8]=t[8]+s[8],e[9]=t[9]+s[9],e[10]=t[10]+s[10],e[11]=t[11]+s[11],e[12]=t[12]+s[12],e[13]=t[13]+s[13],e[14]=t[14]+s[14],e[15]=t[15]+s[15],e}function $s(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e[3]=t[3]-s[3],e[4]=t[4]-s[4],e[5]=t[5]-s[5],e[6]=t[6]-s[6],e[7]=t[7]-s[7],e[8]=t[8]-s[8],e[9]=t[9]-s[9],e[10]=t[10]-s[10],e[11]=t[11]-s[11],e[12]=t[12]-s[12],e[13]=t[13]-s[13],e[14]=t[14]-s[14],e[15]=t[15]-s[15],e}function Oi(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12]*s,e[13]=t[13]*s,e[14]=t[14]*s,e[15]=t[15]*s,e}function Ai(e,t,s,n){return e[0]=t[0]+s[0]*n,e[1]=t[1]+s[1]*n,e[2]=t[2]+s[2]*n,e[3]=t[3]+s[3]*n,e[4]=t[4]+s[4]*n,e[5]=t[5]+s[5]*n,e[6]=t[6]+s[6]*n,e[7]=t[7]+s[7]*n,e[8]=t[8]+s[8]*n,e[9]=t[9]+s[9]*n,e[10]=t[10]+s[10]*n,e[11]=t[11]+s[11]*n,e[12]=t[12]+s[12]*n,e[13]=t[13]+s[13]*n,e[14]=t[14]+s[14]*n,e[15]=t[15]+s[15]*n,e}function Ci(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function Pi(e,t){let s=e[0],n=e[1],r=e[2],i=e[3],o=e[4],c=e[5],a=e[6],h=e[7],l=e[8],f=e[9],m=e[10],p=e[11],x=e[12],g=e[13],u=e[14],M=e[15],E=t[0],y=t[1],T=t[2],S=t[3],_=t[4],P=t[5],R=t[6],O=t[7],w=t[8],I=t[9],q=t[10],b=t[11],A=t[12],$=t[13],ft=t[14],mt=t[15];return Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(n-y)<=1e-6*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(r-T)<=1e-6*Math.max(1,Math.abs(r),Math.abs(T))&&Math.abs(i-S)<=1e-6*Math.max(1,Math.abs(i),Math.abs(S))&&Math.abs(o-_)<=1e-6*Math.max(1,Math.abs(o),Math.abs(_))&&Math.abs(c-P)<=1e-6*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(a-R)<=1e-6*Math.max(1,Math.abs(a),Math.abs(R))&&Math.abs(h-O)<=1e-6*Math.max(1,Math.abs(h),Math.abs(O))&&Math.abs(l-w)<=1e-6*Math.max(1,Math.abs(l),Math.abs(w))&&Math.abs(f-I)<=1e-6*Math.max(1,Math.abs(f),Math.abs(I))&&Math.abs(m-q)<=1e-6*Math.max(1,Math.abs(m),Math.abs(q))&&Math.abs(p-b)<=1e-6*Math.max(1,Math.abs(p),Math.abs(b))&&Math.abs(x-A)<=1e-6*Math.max(1,Math.abs(x),Math.abs(A))&&Math.abs(g-$)<=1e-6*Math.max(1,Math.abs(g),Math.abs($))&&Math.abs(u-ft)<=1e-6*Math.max(1,Math.abs(u),Math.abs(ft))&&Math.abs(M-mt)<=1e-6*Math.max(1,Math.abs(M),Math.abs(mt))}var Ni=It,Li=$s;function vi(){let e=new V(4);return V!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function js(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e}function Xs(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e}function Qs(e){let t=e[0],s=e[1],n=e[2],r=e[3];return Math.sqrt(t*t+s*s+n*n+r*r)}function Ks(e){let t=e[0],s=e[1],n=e[2],r=e[3];return t*t+s*s+n*n+r*r}function Hs(e,t){let s=t[0],n=t[1],r=t[2],i=t[3],o=s*s+n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=s*o,e[1]=n*o,e[2]=r*o,e[3]=i*o,e}function Js(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function tn(e,t,s,n){let r=t[0],i=t[1],o=t[2],c=t[3];return e[0]=r+n*(s[0]-r),e[1]=i+n*(s[1]-i),e[2]=o+n*(s[2]-o),e[3]=c+n*(s[3]-c),e}function en(e,t,s){let n=t[0],r=t[1],i=t[2],o=t[3];return e[0]=s[0]*n+s[4]*r+s[8]*i+s[12]*o,e[1]=s[1]*n+s[5]*r+s[9]*i+s[13]*o,e[2]=s[2]*n+s[6]*r+s[10]*i+s[14]*o,e[3]=s[3]*n+s[7]*r+s[11]*i+s[15]*o,e}function sn(e,t,s){let n=t[0],r=t[1],i=t[2],o=s[0],c=s[1],a=s[2],h=s[3],l=h*n+c*i-a*r,f=h*r+a*n-o*i,m=h*i+o*r-c*n,p=-o*n-c*r-a*i;return e[0]=l*h+p*-o+f*-a-m*-c,e[1]=f*h+p*-c+m*-o-l*-a,e[2]=m*h+p*-a+l*-c-f*-o,e[3]=t[3],e}var Zc=function(){let e=vi();return function(t,s,n,r,i,o){let c,a;for(s||(s=4),n||(n=0),r?a=Math.min(r*s+n,t.length):a=t.length,c=n;cMath.PI*2)throw Error("expected radians")}function Ui(e,t,s,n,r,i){let o=2*i/(s-t),c=2*i/(r-n),a=(s+t)/(s-t),h=(r+n)/(r-n),l=-1,f=-1,m=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=h,e[10]=l,e[11]=f,e[12]=0,e[13]=0,e[14]=m,e[15]=0,e}function rn(){let e=new V(4);return V!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function on(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ns(e,t,s){s=s*.5;let n=Math.sin(s);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(s),e}function rs(e,t,s){let n=t[0],r=t[1],i=t[2],o=t[3],c=s[0],a=s[1],h=s[2],l=s[3];return e[0]=n*l+o*c+r*h-i*a,e[1]=r*l+o*a+i*c-n*h,e[2]=i*l+o*h+n*a-r*c,e[3]=o*l-n*c-r*a-i*h,e}function cn(e,t,s){s*=.5;let n=t[0],r=t[1],i=t[2],o=t[3],c=Math.sin(s),a=Math.cos(s);return e[0]=n*a+o*c,e[1]=r*a+i*c,e[2]=i*a-r*c,e[3]=o*a-n*c,e}function an(e,t,s){s*=.5;let n=t[0],r=t[1],i=t[2],o=t[3],c=Math.sin(s),a=Math.cos(s);return e[0]=n*a-i*c,e[1]=r*a+o*c,e[2]=i*a+n*c,e[3]=o*a-r*c,e}function hn(e,t,s){s*=.5;let n=t[0],r=t[1],i=t[2],o=t[3],c=Math.sin(s),a=Math.cos(s);return e[0]=n*a+r*c,e[1]=r*a-n*c,e[2]=i*a+o*c,e[3]=o*a-i*c,e}function ln(e,t){let s=t[0],n=t[1],r=t[2];return e[0]=s,e[1]=n,e[2]=r,e[3]=Math.sqrt(Math.abs(1-s*s-n*n-r*r)),e}function bt(e,t,s,n){let r=t[0],i=t[1],o=t[2],c=t[3],a=s[0],h=s[1],l=s[2],f=s[3],m,p,x,g,u;return m=r*a+i*h+o*l+c*f,m<0&&(m=-m,a=-a,h=-h,l=-l,f=-f),1-m>1e-6?(p=Math.acos(m),u=Math.sin(p),x=Math.sin((1-n)*p)/u,g=Math.sin(n*p)/u):(x=1-n,g=n),e[0]=x*r+g*a,e[1]=x*i+g*h,e[2]=x*o+g*l,e[3]=x*c+g*f,e}function fn(e,t){let s=t[0],n=t[1],r=t[2],i=t[3],o=s*s+n*n+r*r+i*i,c=o?1/o:0;return e[0]=-s*c,e[1]=-n*c,e[2]=-r*c,e[3]=i*c,e}function mn(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function is(e,t){let s=t[0]+t[4]+t[8],n;if(s>0)n=Math.sqrt(s+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let r=0;t[4]>t[0]&&(r=1),t[8]>t[r*3+r]&&(r=2);let i=(r+1)%3,o=(r+2)%3;n=Math.sqrt(t[r*3+r]-t[i*3+i]-t[o*3+o]+1),e[r]=.5*n,n=.5/n,e[3]=(t[i*3+o]-t[o*3+i])*n,e[i]=(t[i*3+r]+t[r*3+i])*n,e[o]=(t[o*3+r]+t[r*3+o])*n}return e}var pn=js;var dn=Xs,un=Js,xn=tn,gn=Qs;var Mn=Ks;var Tn=Hs;var yn=function(){let e=Xt(),t=Qt(1,0,0),s=Qt(0,1,0);return function(n,r,i){let o=Nt(r,i);return o<-.999999?(pt(e,t,r),be(e)<1e-6&&pt(e,s,r),Ne(e,e),ns(n,e,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(pt(e,r,i),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+o,Tn(n,n))}}(),oa=function(){let e=rn(),t=rn();return function(s,n,r,i,o,c){return bt(e,n,o,c),bt(t,r,i,c),bt(s,e,t,2*c*(1-c)),s}}(),ca=function(){let e=bs();return function(t,s,n,r){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=r[0],e[4]=r[1],e[7]=r[2],e[2]=-s[0],e[5]=-s[1],e[8]=-s[2],Tn(t,is(t,e))}}();var Fi=[0,0,0,1],at=class extends ot{constructor(t=0,s=0,n=0,r=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,s,n,r)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,s,n,r){return this[0]=t,this[1]=s,this[2]=n,this[3]=r,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return is(this,t),this.check()}fromAxisRotation(t,s){return ns(this,t,s),this.check()}identity(){return on(this),this.check()}setAxisAngle(t,s){return this.fromAxisRotation(t,s)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=N(t)}get y(){return this[1]}set y(t){this[1]=N(t)}get z(){return this[2]}set z(t){this[2]=N(t)}get w(){return this[3]}set w(t){this[3]=N(t)}len(){return gn(this)}lengthSquared(){return Mn(this)}dot(t){return un(this,t)}rotationTo(t,s){return yn(this,t,s),this.check()}add(t){return pn(this,this,t),this.check()}calculateW(){return ln(this,this),this.check()}conjugate(){return mn(this,this),this.check()}invert(){return fn(this,this),this.check()}lerp(t,s,n){return n===void 0?this.lerp(this,t,s):(xn(this,t,s,n),this.check())}multiplyRight(t){return rs(this,this,t),this.check()}multiplyLeft(t){return rs(this,t,this),this.check()}normalize(){let t=this.len(),s=t>0?1/t:0;return this[0]=this[0]*s,this[1]=this[1]*s,this[2]=this[2]*s,this[3]=this[3]*s,t===0&&(this[3]=1),this.check()}rotateX(t){return cn(this,this,t),this.check()}rotateY(t){return an(this,this,t),this.check()}rotateZ(t){return hn(this,this,t),this.check()}scale(t){return dn(this,this,t),this.check()}slerp(t,s,n){let r,i,o;switch(arguments.length){case 1:({start:r=Fi,target:i,ratio:o}=t);break;case 2:r=this,i=t,o=s;break;default:r=t,i=s,o=n}return bt(this,r,i,o),this.check()}transformVector4(t,s=new _t){return sn(s,t,this),ct(s,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,s){return this.setAxisAngle(t,s)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var st={};Ct(st,{EPSILON1:()=>ki,EPSILON10:()=>Qi,EPSILON11:()=>Ki,EPSILON12:()=>Hi,EPSILON13:()=>Ji,EPSILON14:()=>to,EPSILON15:()=>eo,EPSILON16:()=>so,EPSILON17:()=>no,EPSILON18:()=>ro,EPSILON19:()=>io,EPSILON2:()=>Wi,EPSILON20:()=>oo,EPSILON3:()=>Bi,EPSILON4:()=>Yi,EPSILON5:()=>Gi,EPSILON6:()=>Zi,EPSILON7:()=>$i,EPSILON8:()=>ji,EPSILON9:()=>Xi,PI_OVER_FOUR:()=>ao,PI_OVER_SIX:()=>ho,PI_OVER_TWO:()=>co,TWO_PI:()=>lo});var ki=.1,Wi=.01,Bi=.001,Yi=1e-4,Gi=1e-5,Zi=1e-6,$i=1e-7,ji=1e-8,Xi=1e-9,Qi=1e-10,Ki=1e-11,Hi=1e-12,Ji=1e-13,to=1e-14,eo=1e-15,so=1e-16,no=1e-17,ro=1e-18,io=1e-19,oo=1e-20,co=Math.PI/2,ao=Math.PI/4,ho=Math.PI/6,lo=Math.PI*2;var nt=6356752314245179e-9,mo={radii:[6378137,6378137,nt],radiiSquared:[6378137*6378137,6378137*6378137,nt*nt],oneOverRadii:[1/6378137,1/6378137,1/nt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(nt*nt)],maximumRadius:Math.max(6378137,6378137,nt),centerToleranceSquared:.1};function ne(e){return e}var za=new d;function po(e,t=[],s=ne){return"longitude"in e?(t[0]=s(e.longitude),t[1]=s(e.latitude),t[2]=e.height):"x"in e?(t[0]=s(e.x),t[1]=s(e.y),t[2]=e.z):(t[0]=s(e[0]),t[1]=s(e[1]),t[2]=e[2]),t}function _n(e,t=[]){return po(e,t,z._cartographicRadians?ne:Ce)}function uo(e,t,s=ne){return"longitude"in t?(t.longitude=s(e[0]),t.latitude=s(e[1]),t.height=e[2]):"x"in t?(t.x=s(e[0]),t.y=s(e[1]),t.z=e[2]):(t[0]=s(e[0]),t[1]=s(e[1]),t[2]=e[2]),t}function Sn(e,t){return uo(e,t,z._cartographicRadians?ne:Pe)}var En=1e-14,xo=new d,wn={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},os={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},zt={east:new d,north:new d,up:new d,west:new d,south:new d,down:new d},go=new d,Mo=new d,To=new d;function cs(e,t,s,n,r,i){let o=wn[t]&&wn[t][s];U(o&&(!n||n===o));let c,a,h,l=xo.copy(r);if(X(l.x,0,En)&&X(l.y,0,En)){let m=Math.sign(l.z);c=go.fromArray(os[t]),t!=="east"&&t!=="west"&&c.scale(m),a=Mo.fromArray(os[s]),s!=="east"&&s!=="west"&&a.scale(m),h=To.fromArray(os[n]),n!=="east"&&n!=="west"&&h.scale(m)}else{let{up:m,east:p,north:x}=zt;p.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,m),x.copy(m).cross(p);let{down:g,west:u,south:M}=zt;g.copy(m).scale(-1),u.copy(p).scale(-1),M.copy(x).scale(-1),c=zt[t],a=zt[s],h=zt[n]}return i[0]=c.x,i[1]=c.y,i[2]=c.z,i[3]=0,i[4]=a.x,i[5]=a.y,i[6]=a.z,i[7]=0,i[8]=h.x,i[9]=h.y,i[10]=h.z,i[11]=0,i[12]=l.x,i[13]=l.y,i[14]=l.z,i[15]=1,i}var Et=new d,yo=new d,_o=new d;function Rn(e,t,s=[]){let{oneOverRadii:n,oneOverRadiiSquared:r,centerToleranceSquared:i}=t;Et.from(e);let o=Et.x,c=Et.y,a=Et.z,h=n.x,l=n.y,f=n.z,m=o*o*h*h,p=c*c*l*l,x=a*a*f*f,g=m+p+x,u=Math.sqrt(1/g);if(!Number.isFinite(u))return;let M=yo;if(M.copy(e).scale(u),gst.EPSILON12);return Et.scale([R,O,w]).to(s)}var re=new d,On=new d,wo=new d,H=new d,Ro=new d,ie=new d,C=class{constructor(t=0,s=0,n=0){this.centerToleranceSquared=st.EPSILON1,U(t>=0),U(s>=0),U(n>=0),this.radii=new d(t,s,n),this.radiiSquared=new d(t*t,s*s,n*n),this.radiiToTheFourth=new d(t*t*t*t,s*s*s*s,n*n*n*n),this.oneOverRadii=new d(t===0?0:1/t,s===0?0:1/s,n===0?0:1/n),this.oneOverRadiiSquared=new d(t===0?0:1/(t*t),s===0?0:1/(s*s),n===0?0:1/(n*n)),this.minimumRadius=Math.min(t,s,n),this.maximumRadius=Math.max(t,s,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,s=[0,0,0]){let n=On,r=wo,[,,i]=t;this.geodeticSurfaceNormalCartographic(t,n),r.copy(this.radiiSquared).scale(n);let o=Math.sqrt(n.dot(r));return r.scale(1/o),n.scale(i),r.add(n),r.to(s)}cartesianToCartographic(t,s=[0,0,0]){ie.from(t);let n=this.scaleToGeodeticSurface(ie,H);if(!n)return;let r=this.geodeticSurfaceNormal(n,On),i=Ro;i.copy(ie).subtract(n);let o=Math.atan2(r.y,r.x),c=Math.asin(r.z),a=Math.sign(ut.dot(i,ie))*ut.length(i);return Sn([o,c,a],s)}eastNorthUpToFixedFrame(t,s=new L){return cs(this,"east","north","up",t,s)}localFrameToFixedFrame(t,s,n,r,i=new L){return cs(this,t,s,n,r,i)}geocentricSurfaceNormal(t,s=[0,0,0]){return re.from(t).normalize().to(s)}geodeticSurfaceNormalCartographic(t,s=[0,0,0]){let n=_n(t),r=n[0],i=n[1],o=Math.cos(i);return re.set(o*Math.cos(r),o*Math.sin(r),Math.sin(i)).normalize(),re.to(s)}geodeticSurfaceNormal(t,s=[0,0,0]){return re.from(t).scale(this.oneOverRadiiSquared).normalize().to(s)}scaleToGeodeticSurface(t,s){return Rn(t,this,s)}scaleToGeocentricSurface(t,s=[0,0,0]){H.from(t);let n=H.x,r=H.y,i=H.z,o=this.oneOverRadiiSquared,c=1/Math.sqrt(n*n*o.x+r*r*o.y+i*i*o.z);return H.multiplyScalar(c).to(s)}transformPositionToScaledSpace(t,s=[0,0,0]){return H.from(t).scale(this.oneOverRadii).to(s)}transformPositionFromScaledSpace(t,s=[0,0,0]){return H.from(t).scale(this.radii).to(s)}getSurfaceNormalIntersectionWithZAxis(t,s=0,n=[0,0,0]){U(X(this.radii.x,this.radii.y,st.EPSILON15)),U(this.radii.z>0),H.from(t);let r=H.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(r)>=this.radii.z-s))return H.set(0,0,r).to(n)}};C.WGS84=new C(6378137,6378137,nt);function Vt(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var xt=class{constructor(t,s){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=s,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Vt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Vt()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var ht=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,s="count"){return this._getOrCreate({name:t,type:s})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let s of Object.values(this.stats))t(s)}getTable(){let t={};return this.forEach(s=>{t[s.name]={time:s.time||0,count:s.count||0,average:s.getAverageTime()||0,hz:s.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(s=>this._getOrCreate(s))}_getOrCreate(t){let{name:s,type:n}=t,r=this.stats[s];return r||(t instanceof xt?r=t:r=new xt(s,n),this.stats[s]=r),r}};function J(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var Oo="Queued Requests",Ao="Active Requests",Co="Cancelled Requests",Po="Queued Requests Ever",No="Active Requests Ever",Lo={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},wt=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...Lo,...t},this.stats=new ht({id:this.props.id}),this.stats.get(Oo),this.stats.get(Ao),this.stats.get(Co),this.stats.get(Po),this.stats.get(No)}scheduleRequest(t,s=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let n={handle:t,priority:0,getPriority:s},r=new Promise(i=>(n.resolve=i,n));return this.requestQueue.push(n),this.requestMap.set(t,r),this._issueNewRequests(),r}_issueRequest(t){let{handle:s,resolve:n}=t,r=!1,i=()=>{r||(r=!0,this.requestMap.delete(s),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:i}):Promise.resolve({done:i})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;let t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let s=0;ss.priority-n.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var oe={};Ct(oe,{dirname:()=>Io,filename:()=>vo,join:()=>qo,resolve:()=>bo});function An(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function vo(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function Io(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function qo(...e){let t="/";return e=e.map((s,n)=>(n&&(s=s.replace(new RegExp(`^${t}`),"")),n!==e.length-1&&(s=s.replace(new RegExp(`${t}$`),"")),s)),e.join(t)}function bo(...e){let t=[];for(let i=0;i=-1&&!n;i--){let o;i>=0?o=t[i]:(r===void 0&&(r=An()),o=r),o.length!==0&&(s=`${o}/${s}`,n=o.charCodeAt(0)===Dt)}return s=zo(s,!n),n?`/${s}`:s.length>0?s:"."}var Dt=47,as=46;function zo(e,t){let s="",n=-1,r=0,i,o=!1;for(let c=0;c<=e.length;++c){if(c2){let a=s.length-1,h=a;for(;h>=0&&s.charCodeAt(h)!==Dt;--h);if(h!==a){s=h===-1?"":s.slice(0,h),n=c,r=0,o=!1;continue}}else if(s.length===2||s.length===1){s="",n=c,r=0,o=!1;continue}}t&&(s.length>0?s+="/..":s="..",o=!0)}else{let a=e.slice(n+1,c);s.length>0?s+=`/${a}`:s=a,o=!1}n=c,r=0}else i===as&&r!==-1?++r:r=-1}return s}var ce=class{item;previous;next;constructor(t,s,n){this.item=t,this.previous=s,this.next=n}};var ae=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let s=new ce(t,this.tail,null);return this.tail?(this.tail.next=s,this.tail=s):(this.head=s,this.tail=s),++this._length,s}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,s){t!==s&&(this.remove(s),this._insert(t,s))}_insert(t,s){let n=t.next;t.next=s,this.tail===t?this.tail=s:n.previous=s,s.next=n,s.previous=t,++this._length}};var Rt=class{_list;_sentinel;_trimTiles;constructor(){this._list=new ae,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let s=t._cacheNode;s&&this._list.splice(this._sentinel,s)}add(t,s,n){s._cacheNode||(s._cacheNode=this._list.add(s),n&&n(t,s))}unloadTile(t,s,n){let r=s._cacheNode;r&&(this._list.remove(r),s._cacheNode=null,n&&n(t,s))}unloadTiles(t,s){let n=this._trimTiles;this._trimTiles=!1;let r=this._list,i=t.maximumMemoryUsage*1024*1024,o=this._sentinel,c=r.head;for(;c!==o&&(t.gpuMemoryUsageInBytes>i||n);){let a=c.item;c=c.next,this.unloadTile(t,a,s)}}trim(){this._trimTiles=!0}};function he(e,t){J(e),J(t);let{rtcCenter:s,gltfUpAxis:n}=t,{computedTransform:r,boundingVolume:{center:i}}=e,o=new L(r);switch(s&&o.translate(s),n){case"Z":break;case"Y":let f=new L().rotateX(Math.PI/2);o=o.multiplyRight(f);break;case"X":let m=new L().rotateY(-Math.PI/2);o=o.multiplyRight(m);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let c=new d(i);t.cartesianModelMatrix=o,t.cartesianOrigin=c;let a=C.WGS84.cartesianToCartographic(c,new d),l=C.WGS84.eastNorthUpToFixedFrame(c).invert();t.cartographicModelMatrix=l.multiplyRight(o),t.cartographicOrigin=a,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var F={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var Ah=new d,Ch=new d;var Ut=new d,Cn=new d,Q=class{constructor(t=[0,0,0],s=0){this.radius=-0,this.center=new d,this.fromCenterRadius(t,s)}fromCenterRadius(t,s){return this.center.from(t),this.radius=s,this}fromCornerPoints(t,s){return s=Ut.from(s),this.center=new d().from(t).add(s).scale(.5),this.radius=this.center.distance(s),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new Q(this.center,this.radius)}union(t){let s=this.center,n=this.radius,r=t.center,i=t.radius,o=Ut.copy(r).subtract(s),c=o.magnitude();if(n>=c+i)return this.clone();if(i>=c+n)return t.clone();let a=(n+c+i)*.5;return Cn.copy(o).scale((-n+a)/c).add(s),this.center.copy(Cn),this.radius=a,this}expand(t){let n=Ut.from(t).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(t){this.center.transform(t);let s=qt.getScaling(Ut,t);return this.radius=Math.max(s[0],Math.max(s[1],s[2]))*this.radius,this}distanceSquaredTo(t){let s=this.distanceTo(t);return s*s}distanceTo(t){let n=Ut.from(t).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(t){let s=this.center,n=this.radius,i=t.normal.dot(s)+t.distance;return i<-n?F.OUTSIDE:i=a?F.INSIDE:F.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let s=Do.from(t).subtract(this.center),n=this.halfAxes,r=n.getColumn(0,le),i=n.getColumn(1,fe),o=n.getColumn(2,me),c=r.magnitude(),a=i.magnitude(),h=o.magnitude();r.normalize(),i.normalize(),o.normalize();let l=0,f;return f=Math.abs(s.dot(r))-c,f>0&&(l+=f*f),f=Math.abs(s.dot(i))-a,f>0&&(l+=f*f),f=Math.abs(s.dot(o))-h,f>0&&(l+=f*f),l}computePlaneDistances(t,s,n=[-0,-0]){let r=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=this.center,c=this.halfAxes,a=c.getColumn(0,le),h=c.getColumn(1,fe),l=c.getColumn(2,me),f=Uo.copy(a).add(h).add(l).add(o),m=Fo.copy(f).subtract(t),p=s.dot(m);return r=Math.min(p,r),i=Math.max(p,i),f.copy(o).add(a).add(h).subtract(l),m.copy(f).subtract(t),p=s.dot(m),r=Math.min(p,r),i=Math.max(p,i),f.copy(o).add(a).subtract(h).add(l),m.copy(f).subtract(t),p=s.dot(m),r=Math.min(p,r),i=Math.max(p,i),f.copy(o).add(a).subtract(h).subtract(l),m.copy(f).subtract(t),p=s.dot(m),r=Math.min(p,r),i=Math.max(p,i),o.copy(f).subtract(a).add(h).add(l),m.copy(f).subtract(t),p=s.dot(m),r=Math.min(p,r),i=Math.max(p,i),o.copy(f).subtract(a).add(h).subtract(l),m.copy(f).subtract(t),p=s.dot(m),r=Math.min(p,r),i=Math.max(p,i),o.copy(f).subtract(a).subtract(h).add(l),m.copy(f).subtract(t),p=s.dot(m),r=Math.min(p,r),i=Math.max(p,i),o.copy(f).subtract(a).subtract(h).subtract(l),m.copy(f).subtract(t),p=s.dot(m),r=Math.min(p,r),i=Math.max(p,i),n[0]=r,n[1]=i,n}transform(t){this.center.transformAsPoint(t);let s=this.halfAxes.getColumn(0,le);s.transformAsPoint(t);let n=this.halfAxes.getColumn(1,fe);n.transformAsPoint(t);let r=this.halfAxes.getColumn(2,me);return r.transformAsPoint(t),this.halfAxes=new D([...s,...n,...r]),this}getTransform(){throw new Error("not implemented")}};var Pn=new d,Nn=new d,B=class{constructor(t=[0,0,1],s=0){this.normal=new d,this.distance=-0,this.fromNormalDistance(t,s)}fromNormalDistance(t,s){return U(Number.isFinite(s)),this.normal.from(t).normalize(),this.distance=s,this}fromPointNormal(t,s){t=Pn.from(t),this.normal.from(s).normalize();let n=-this.normal.dot(t);return this.distance=n,this}fromCoefficients(t,s,n,r){return this.normal.set(t,s,n),U(X(this.normal.len(),1)),this.distance=r,this}clone(){return new B(this.normal,this.distance)}equals(t){return X(this.distance,t.distance)&&X(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let s=Nn.copy(this.normal).transformAsVector(t).normalize(),n=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(n,s)}projectPointOntoPlane(t,s=[0,0,0]){let n=Pn.from(t),r=this.getPointDistance(n),i=Nn.copy(this.normal).scale(r);return n.subtract(i).to(s)}};var Ln=[new d([1,0,0]),new d([0,1,0]),new d([0,0,1])],vn=new d,ko=new d,k=class{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*Ln.length;let s=t.center,n=t.radius,r=0;for(let i of Ln){let o=this.planes[r],c=this.planes[r+1];o||(o=this.planes[r]=new B),c||(c=this.planes[r+1]=new B);let a=vn.copy(i).scale(-n).add(s);o.fromPointNormal(a,i);let h=vn.copy(i).scale(n).add(s),l=ko.copy(i).negate();c.fromPointNormal(h,l),r+=2}return this}computeVisibility(t){let s=F.INSIDE;for(let n of this.planes)switch(t.intersectPlane(n)){case F.OUTSIDE:return F.OUTSIDE;case F.INTERSECTING:s=F.INTERSECTING;break;default:}return s}computeVisibilityWithPlaneMask(t,s){if(U(Number.isFinite(s),"parentPlaneMask is required."),s===k.MASK_OUTSIDE||s===k.MASK_INSIDE)return s;let n=k.MASK_INSIDE,r=this.planes;for(let i=0;ih[1]-l[1]),c=[];for(let h=0;h0?o.normalize():o=new d(0,1,0);let c=o.clone().cross(i);for(let a of[o,c,i]){ge.copy(a).scale(n);for(let h=0;h<2;h++)G.copy(s),G.add(ge),Zn(t,G),ge.negate()}return t}function Gn(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Zn(e,t){C.WGS84.cartesianToCartographic(t,G),e[0][0]=Math.min(e[0][0],G[0]),e[0][1]=Math.min(e[0][1],G[1]),e[0][2]=Math.min(e[0][2],G[2]),e[1][0]=Math.max(e[1][0],G[0]),e[1][1]=Math.max(e[1][1],G[1]),e[1][2]=Math.max(e[1][2],G[2])}var f0=new d,m0=new d,p0=new L,d0=new d,u0=new d,x0=new d;function ec(e,t){let s=e*t;return 1-Math.exp(-(s*s))}function sc(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){let s=e.dynamicScreenSpaceErrorComputedDensity,n=e.dynamicScreenSpaceErrorFactor;return ec(t,s)*n}return 0}function $n(e,t,s){let n=e.tileset,r=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,i=s?r:e.lodMetricValue;if(i===0)return 0;let o=Math.max(e._distanceToCamera,1e-7),{height:c,sseDenominator:a}=t,{viewDistanceScale:h}=n.options,l=i*c*(h||1)/(o*a);return l-=sc(n,o),l}var ps=new d,jn=new d,lt=new d,Xn=new d,nc=new d,ds=new L,Qn=new L;function Me(e,t){if(e.lodMetricValue===0||isNaN(e.lodMetricValue))return"DIG";let s=2*us(e,t);return s<2?"OUT":!e.header.children||s<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}function us(e,t){let{topDownViewport:s}=t,n=e.header.mbs[1],r=e.header.mbs[0],i=e.header.mbs[2],o=e.header.mbs[3],c=[...e.boundingVolume.center],a=s.unprojectPosition(s.cameraPosition);C.WGS84.cartographicToCartesian(a,ps),jn.copy(ps).subtract(c).normalize(),C.WGS84.eastNorthUpToFixedFrame(c,ds),Qn.copy(ds).invert(),lt.copy(ps).transform(Qn);let h=Math.sqrt(lt[0]*lt[0]+lt[1]*lt[1]),l=h*h/lt[2];Xn.copy([lt[0],lt[1],l]);let m=Xn.transform(ds).subtract(c).normalize(),x=jn.cross(m).normalize().scale(o).add(c),g=C.WGS84.cartesianToCartographic(x),u=s.project([r,n,i]),M=s.project(g);return nc.copy(u).subtract(M).magnitude()}function Kn(e){return{assetGltfUpAxis:e.asset&&e.asset.gltfUpAxis||"Y"}}var Ft=class{_map=new Map;_array;_length;constructor(t=0){this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return J(t=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=s,this._map.set(s,t)}delete(t){let s=this._map.get(t);s>=0&&(this._array.splice(s,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){let s=this.length++;this._array[s]=t,this._map.set(t,s)}}pop(){let t=this._array[--this.length];return this._map.delete(t),t}reserve(t){J(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){J(t>=0),this.length=t}trim(t){t==null&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}};var rc={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},K=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new Ft;_emptyTraversalStack=new Ft;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...rc,...t}}traverse(t,s,n){this.root=t,this.options={...this.options,...n},this.reset(),this.updateTile(t,s),this._frameNumber=s.frameNumber,this.executeTraversal(t,s)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,s){let n=this._traversalStack;for(t._selectionDepth=1,n.push(t);n.length>0;){let i=n.pop(),o=!1;this.canTraverse(i,s)&&(this.updateChildTiles(i,s),o=this.updateAndPushChildren(i,s,n,i.hasRenderContent?i._selectionDepth+1:i._selectionDepth));let c=i.parent,a=Boolean(!c||c._shouldRefine),h=!o;i.hasRenderContent?i.refine===Z.ADD?(this.loadTile(i,s),this.selectTile(i,s)):i.refine===Z.REPLACE&&(this.loadTile(i,s),h&&this.selectTile(i,s)):(this.emptyTiles[i.id]=i,this.loadTile(i,s),h&&this.selectTile(i,s)),this.touchTile(i,s),i._shouldRefine=o&&a}let r=new Date().getTime();(this.traversalFinished(s)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(s))}updateChildTiles(t,s){let n=t.children;for(let r of n)this.updateTile(r,s)}updateAndPushChildren(t,s,n,r){let{loadSiblings:i,skipLevelOfDetail:o}=this.options,c=t.children;c.sort(this.compareDistanceToCamera.bind(this));let a=t.refine===Z.REPLACE&&t.hasRenderContent&&!o,h=!1,l=!0;for(let f of c)if(f._selectionDepth=r,f.isVisibleAndInRequestVolume?(n.find(f)&&n.delete(f),n.push(f),h=!0):(a||i)&&(this.loadTile(f,s),this.touchTile(f,s)),a){let m;if(f._inRequestVolume?f.hasRenderContent?m=f.contentAvailable:m=this.executeEmptyTraversal(f,s):m=!1,l=l&&m,!l)return!1}return h||(l=!1),l}updateTile(t,s){this.updateTileVisibility(t,s)}selectTile(t,s){this.shouldSelectTile(t)&&(t._selectedFrame=s.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,s){this.shouldLoadTile(t)&&(t._requestedFrame=s.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,s){t.tileset._cache.touch(t),t._touchedFrame=s.frameNumber}canTraverse(t,s){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:this.shouldRefine(t,s):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,s,n=!1){let r=t._screenSpaceError;return n&&(r=t.getScreenSpaceError(s,!0)),r>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,s){let n=[];if(this.options.viewportTraversersMap)for(let r in this.options.viewportTraversersMap)this.options.viewportTraversersMap[r]===s.viewport.id&&n.push(r);else n.push(s.viewport.id);t.updateVisibility(s,n)}compareDistanceToCamera(t,s){return t._distanceToCamera-s._distanceToCamera}anyChildrenVisible(t,s){let n=!1;for(let r of t.children)r.updateVisibility(s),n=n||r.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(t,s){let n=!0,r=this._emptyTraversalStack;for(r.push(t);r.length>0;){let i=r.pop(),o=!i.hasRenderContent&&this.canTraverse(i,s),c=!i.hasRenderContent&&i.children.length===0;if(!o&&!i.contentAvailable&&!c&&(n=!1),this.updateTile(i,s),i.isVisibleAndInRequestVolume||(this.loadTile(i,s),this.touchTile(i,s)),o){let a=i.children;for(let h of a)r.push(h)}}return n}};var Hn=new d;function ic(e){return e!=null}var it=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Y.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new L;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new K({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new L;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(t,s,n,r=""){this.header=s,this.tileset=t,this.id=r||s.id,this.url=s.url,this.parent=n,this.refine=this._getRefine(s.refine),this.type=s.type,this.contentUrl=s.contentUrl,this._initializeLodMetric(s),this._initializeTransforms(s),this._initializeBoundingVolumes(s),this._initializeContent(s),this._initializeRenderingState(s),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Y.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Y.UNLOADED}get contentExpired(){return this.contentState===Y.EXPIRED}get contentFailed(){return this.contentState===Y.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Bn(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,s){switch(this.tileset.type){case W.I3S:return us(this,t);case W.TILES3D:return $n(this,t,s);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let t=this.tileset._traverser,{skipLevelOfDetail:s}=t.options,n=this.refine===Z.ADD||s;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Y.UNLOADED)return-1;let r=this.parent,o=r&&(!n||this._screenSpaceError===0||r.hasTilesetContent)?r._screenSpaceError:this._screenSpaceError,c=t.root?t.root._screenSpaceError:0;return Math.max(c-o,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Y.LOADING;let s=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!s)return this.contentState=Y.UNLOADED,!1;try{let n=this.tileset.getTileUrl(this.contentUrl),r=this.tileset.loader,i={...this.tileset.loadOptions,[r.id]:{...this.tileset.loadOptions[r.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(r.id)}};return this.content=await(0,Jn.load)(n,r,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Y.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=Y.FAILED,n}finally{s.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Y.UNLOADED,!0}updateVisibility(t,s){if(this._frameNumber===t.frameNumber)return;let n=this.parent,r=n?n._visibilityPlaneMask:k.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let i=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(i)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,r),this._visible=this._visibilityPlaneMask!==k.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=s}visibility(t,s){let{cullingVolume:n}=t,{boundingVolume:r}=this;return n.computeVisibilityWithPlaneMask(r,s)}contentVisibility(){return!0}distanceToTile(t){let s=this.boundingVolume;return Math.sqrt(Math.max(s.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){let s=this.boundingVolume;return Hn.subVectors(s.center,t.position),t.direction.dot(Hn)}insideViewerRequestVolume(t){let s=this._viewerRequestVolume;return!s||s.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(ic(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=Y.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new L(t.transform):new L;let s=this.parent,n=this.tileset,r=s&&s.computedTransform?s.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new L(r).multiplyRight(this.transform);let i=s&&s._initialTransform?s._initialTransform.clone():new L;this._initialTransform=new L(i).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Y.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=k.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(t){return t||this.parent&&this.parent.refine||Z.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(t){this.boundingVolume=At(t.boundingVolume,this.computedTransform,this.boundingVolume);let s=t.content;s&&(s.boundingVolume&&(this._contentBoundingVolume=At(s.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=At(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new L){let s=t.clone().multiplyRight(this.transform);s.equals(this.computedTransform)||(this.computedTransform=s,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){switch(t){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return Kn(this.tileset.tileset)}}};var Te=class extends K{compareDistanceToCamera(t,s){return s._distanceToCamera===0&&t._distanceToCamera===0?s._centerZDepth-t._centerZDepth:s._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,s){if(super.updateTileVisibility(t,s),!t.isVisibleAndInRequestVolume)return;let n=t.children.length>0;if(t.hasTilesetContent&&n){let o=t.children[0];this.updateTileVisibility(o,s),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,s)){t._visible=!1;return}let r=t.refine===Z.REPLACE,i=t._optimChildrenWithinParent===Dn.USE_OPTIMIZATION;if(r&&i&&n&&!this.anyChildrenVisible(t,s)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,s){let{parent:n}=t;return!n||n.hasTilesetContent||n.refine!==Z.ADD?!1:!this.shouldRefine(t,s,!0)}};var tr=Oe(Zt(),1);var ye=class{frameNumberMap=new Map;register(t,s){let n=this.frameNumberMap.get(t)||new Map,r=n.get(s)||0;n.set(s,r+1),this.frameNumberMap.set(t,n)}deregister(t,s){let n=this.frameNumberMap.get(t);if(!n)return;let r=n.get(s)||1;n.set(s,r-1)}isZero(t,s){return(this.frameNumberMap.get(t)?.get(s)||0)===0}};var xs={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},_e=class{_statusMap;pendingTilesRegister=new ye;constructor(){this._statusMap={}}add(t,s,n,r){if(!this._statusMap[s]){let{frameNumber:i,viewport:{id:o}}=r;this._statusMap[s]={request:t,callback:n,key:s,frameState:r,status:xs.REQUESTED},this.pendingTilesRegister.register(o,i),t().then(c=>{this._statusMap[s].status=xs.COMPLETED;let{frameNumber:a,viewport:{id:h}}=this._statusMap[s].frameState;this.pendingTilesRegister.deregister(h,a),this._statusMap[s].callback(c,r)}).catch(c=>{this._statusMap[s].status=xs.ERROR;let{frameNumber:a,viewport:{id:h}}=this._statusMap[s].frameState;this.pendingTilesRegister.deregister(h,a),n(c)})}}update(t,s){if(this._statusMap[t]){let{frameNumber:n,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,n);let{frameNumber:i,viewport:{id:o}}=s;this.pendingTilesRegister.register(o,i),this._statusMap[t].frameState=s}}find(t){return this._statusMap[t]}hasPendingTiles(t,s){return!this.pendingTilesRegister.isZero(t,s)}};var Se=class extends K{_tileManager;constructor(t){super(t),this._tileManager=new _e}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,s){return t._lodJudge=Me(t,s),t._lodJudge==="DIG"}updateChildTiles(t,s){let n=t.header.children||[],r=t.children,i=t.tileset;for(let o of n){let c=`${o.id}-${s.viewport.id}`,a=r&&r.find(h=>h.id===c);if(a)a&&this.updateTile(a,s);else{let h=()=>this._loadTile(o.id,i);this._tileManager.find(c)?this._tileManager.update(c,s):(i.tileset.nodePages&&(h=()=>i.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(h,c,f=>this._onTileLoad(f,t,c),s))}}return!1}async _loadTile(t,s){let{loader:n}=s,r=s.getTileUrl(`${s.url}/nodes/${t}`),i={...s.loadOptions,i3s:{...s.loadOptions.i3s,isTileHeader:!0}};return await(0,tr.load)(r,n,i)}_onTileLoad(t,s,n){let r=new it(s.tileset,t,s,n);s.children.push(r);let i=this._tileManager.find(r.id).frameState;this.updateTile(r,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(r,i)}};var oc={description:"",ellipsoid:C.WGS84,modelMatrix:new L,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},Ee="Tiles In Tileset(s)",gs="Tiles In Memory",er="Tiles In View",sr="Tiles To Render",nr="Tiles Loaded",Ms="Tiles Loading",rr="Tiles Unloaded",ir="Failed Tile Loads",or="Points/Vertices",Ts="Tile Memory Use",cr="Maximum Screen Space Error",we=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Rt;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(t,s){this.options={...oc,...s},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||oe.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new wt({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new ht({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(t)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(t){this.options={...this.options,...t}}getTileUrl(t){if(t.startsWith("data:"))return t;let n=t;return this.queryParams.length&&(n=`${t}${t.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(t){return Boolean(this._extensionsUsed.indexOf(t)>-1)}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise(s=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),s(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytesthis._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let s=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=s.length;let n=[];for(let r of s){let i=r.id;this._needTraverse(i)?n.push(i):this.traverseCounter--}for(let r of s){let i=r.id;if(this.roots[i]||(this.roots[i]=this._initializeTileHeaders(this.tileset,null)),!n.includes(i))continue;let o=de(r,this._frameNumber);this._traverser.traverse(this.roots[i],o,this.options)}}_needTraverse(t){let s=t;return this.options.viewportTraversersMap&&(s=this.options.viewportTraversersMap[t]),s===t}_onTraversalEnd(t){let s=t.viewport.id;this.frameStateData[s]||(this.frameStateData[s]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[s],r=Object.values(this._traverser.selectedTiles),[i,o]=bn(r,t,this.options.maximumTilesSelected);n.selectedTiles=i;for(let c of o)c.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let t in this.frameStateData){let s=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(s.selectedTiles),this._requestedTiles=this._requestedTiles.concat(s._requestedTiles),this._emptyTiles=this._emptyTiles.concat(s._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(let t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,s){if(t.length!==s.length)return!0;let n=new Set(t.map(o=>o.id)),r=new Set(s.map(o=>o.id)),i=t.filter(o=>!r.has(o.id)).length>0;return i=i||s.filter(o=>!n.has(o.id)).length>0,i}_loadTiles(){for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,s)=>t._unloadTile(s))}_updateStats(){let t=0,s=0;for(let n of this.selectedTiles)n.contentAvailable&&n.content&&(t++,n.content.pointCount?s+=n.content.pointCount:s+=n.content.vertexCount);this.stats.get(er).count=this.selectedTiles.length,this.stats.get(sr).count=t,this.stats.get(or).count=s,this.stats.get(cr).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(t){this.type===W.I3S&&(this.calculateViewPropsI3S(),t.root=await t.root),this.root=this._initializeTileHeaders(t,null),this.type===W.TILES3D&&(this._initializeTiles3DTileset(t),this.calculateViewPropsTiles3D()),this.type===W.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let t=this.tileset.fullExtent;if(t){let{xmin:n,xmax:r,ymin:i,ymax:o,zmin:c,zmax:a}=t;this.cartographicCenter=new d(n+(r-n)/2,i+(o-i)/2,c+(a-c)/2),this.cartesianCenter=new d,C.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=ms(t,this.cartographicCenter,this.cartesianCenter);return}let s=this.tileset.store?.extent;if(s){let[n,r,i,o]=s;this.cartographicCenter=new d(n+(i-n)/2,r+(o-r)/2,0),this.cartesianCenter=new d,C.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Vn(s,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new d,this.zoom=1}calculateViewPropsTiles3D(){let t=this.root,{center:s}=t.boundingVolume;if(!s){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new d,this.zoom=1;return}s[0]!==0||s[1]!==0||s[2]!==0?(this.cartographicCenter=new d,C.WGS84.cartesianToCartographic(s,this.cartographicCenter)):this.cartographicCenter=new d(0,0,-C.WGS84.radii[0]),this.cartesianCenter=s,this.zoom=zn(t.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(Ee),this.stats.get(Ms),this.stats.get(gs),this.stats.get(er),this.stats.get(sr),this.stats.get(nr),this.stats.get(rr),this.stats.get(ir),this.stats.get(or),this.stats.get(Ts,"memory"),this.stats.get(cr)}_initializeTileHeaders(t,s){let n=new it(this,t.root,s);if(s&&(s.children.push(n),n.depth=s.depth+1),this.type===W.TILES3D){let r=[];for(r.push(n);r.length>0;){let i=r.pop();this.stats.get(Ee).incrementCount();let o=i.header.children||[];for(let c of o){let a=new it(this,c,i);if(a.contentUrl?.includes("?session=")){let l=new URL(a.contentUrl).searchParams.get("session");l&&(this._queryParams.session=l)}i.children.push(a),a.depth=i.depth+1,r.push(a)}}}return n}_initializeTraverser(){let t;switch(this.type){case W.TILES3D:t=Te;break;case W.I3S:t=Se;break;default:t=K}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let s;try{this._onStartTileLoading(),s=await t.loadContent()}catch(n){this._onTileLoadError(t,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(t,s)}}_onTileLoadError(t,s){this.stats.get(ir).incrementCount();let n=s.message||s.toString(),r=t.url;console.error(`A 3D tile failed to load: ${t.url} ${n}`),this.options.onTileError(t,n,r)}_onTileLoad(t,s){if(s){if(this.type===W.I3S){let n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(Ee).reset(),this.stats.get(Ee).addCount(n)}t&&t.content&&he(t,t.content),this.updateContentTypes(t),this._addTileToCache(t),this.options.onTileLoad(t)}}updateContentTypes(t){if(this.type===W.I3S)switch(t.header.isDracoGeometry&&(this.contentFormats.draco=!0),t.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===W.TILES3D){let{extensionsRemoved:s=[]}=t.content?.gltf||{};s.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),s.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),s.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(Ms).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Ms).decrementCount()}_addTileToCache(t){this._cache.add(this,t,s=>s._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(nr).incrementCount(),this.stats.get(gs).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Ts).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(gs).decrementCount(),this.stats.get(rr).incrementCount(),this.stats.get(Ts).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let s=t.pop();for(let n of s.children)t.push(n);this._destroyTile(s)}this.root=null}_destroySubtree(t){let s=t,n=[];for(n.push(s);n.length>0;){t=n.pop();for(let r of t.children)n.push(r);t!==s&&this._destroyTile(t)}s.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeTiles3DTileset(t){if(t.queryString){let s=new URLSearchParams(t.queryString),n=Object.fromEntries(s.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=t.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed||[],this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}};return dr(kt);})(); return __exports__; });