@loaders.gl/tiles 5.0.0-alpha.2 → 5.0.0-alpha.4
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.
- package/LICENSE +1 -1
- package/dist/dist.dev.js +17325 -5650
- package/dist/dist.min.js +4 -1
- package/dist/index.cjs +1924 -178
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/point-cloud/point-cloud-tileset.d.ts +4 -0
- package/dist/point-cloud/point-cloud-tileset.d.ts.map +1 -1
- package/dist/point-cloud/point-cloud-tileset.js +51 -12
- package/dist/point-cloud/point-cloud-tileset.js.map +1 -1
- package/dist/point-cloud/types.d.ts +17 -0
- package/dist/point-cloud/types.d.ts.map +1 -1
- package/dist/raster-set.d.ts +10 -8
- package/dist/raster-set.d.ts.map +1 -1
- package/dist/raster-set.js +18 -1
- package/dist/raster-set.js.map +1 -1
- package/dist/spatial/format-spatial-reference.d.ts +67 -0
- package/dist/spatial/format-spatial-reference.d.ts.map +1 -0
- package/dist/spatial/format-spatial-reference.js +233 -0
- package/dist/spatial/format-spatial-reference.js.map +1 -0
- package/dist/spatial/get-spatial-coordinate-frame.d.ts +9 -0
- package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +1 -0
- package/dist/spatial/get-spatial-coordinate-frame.js +58 -0
- package/dist/spatial/get-spatial-coordinate-frame.js.map +1 -0
- package/dist/spatial/i3s-elevation.d.ts +20 -0
- package/dist/spatial/i3s-elevation.d.ts.map +1 -0
- package/dist/spatial/i3s-elevation.js +90 -0
- package/dist/spatial/i3s-elevation.js.map +1 -0
- package/dist/spatial/i3s-spatial-transformer.d.ts +189 -0
- package/dist/spatial/i3s-spatial-transformer.d.ts.map +1 -0
- package/dist/spatial/i3s-spatial-transformer.js +686 -0
- package/dist/spatial/i3s-spatial-transformer.js.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts +48 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.js +211 -0
- package/dist/spatial/spatial-coordinate-transformer.js.map +1 -0
- package/dist/spatial/spatial-resource-registry.d.ts +44 -0
- package/dist/spatial/spatial-resource-registry.d.ts.map +1 -0
- package/dist/spatial/spatial-resource-registry.js +67 -0
- package/dist/spatial/spatial-resource-registry.js.map +1 -0
- package/dist/spatial/spatial-types.d.ts +190 -0
- package/dist/spatial/spatial-types.d.ts.map +1 -0
- package/dist/spatial/spatial-types.js +192 -0
- package/dist/spatial/spatial-types.js.map +1 -0
- package/dist/tileset-3d/common/tile-3d.d.ts +49 -1
- package/dist/tileset-3d/common/tile-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tile-3d.js +132 -64
- package/dist/tileset-3d/common/tile-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.d.ts +25 -0
- package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.js +49 -7
- package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-source.d.ts +14 -0
- package/dist/tileset-3d/common/tileset-source.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-source.js.map +1 -1
- package/dist/tileset-3d/common/tileset-traverser.d.ts +6 -1
- package/dist/tileset-3d/common/tileset-traverser.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-traverser.js +11 -6
- package/dist/tileset-3d/common/tileset-traverser.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +26 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +62 -18
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +1 -7
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +32 -55
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts +14 -1
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-source.js +107 -17
- package/dist/tileset-3d/format-i3s/i3s-source.js.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.js +3 -33
- package/dist/tileset-3d/helpers/bounding-volume.js.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts +3 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.js +1 -0
- package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
- package/dist/tileset-3d/helpers/i3s-lod.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/i3s-lod.js +20 -8
- package/dist/tileset-3d/helpers/i3s-lod.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -9
- package/src/index.ts +42 -1
- package/src/point-cloud/point-cloud-tileset.ts +66 -12
- package/src/point-cloud/types.ts +17 -0
- package/src/raster-set.ts +46 -11
- package/src/spatial/format-spatial-reference.ts +311 -0
- package/src/spatial/get-spatial-coordinate-frame.ts +74 -0
- package/src/spatial/i3s-elevation.ts +96 -0
- package/src/spatial/i3s-spatial-transformer.ts +957 -0
- package/src/spatial/spatial-coordinate-transformer.ts +276 -0
- package/src/spatial/spatial-resource-registry.ts +79 -0
- package/src/spatial/spatial-types.ts +422 -0
- package/src/tileset-3d/common/tile-3d.ts +156 -69
- package/src/tileset-3d/common/tileset-3d.ts +77 -6
- package/src/tileset-3d/common/tileset-source.ts +15 -0
- package/src/tileset-3d/common/tileset-traverser.ts +11 -6
- package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +100 -22
- package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +36 -56
- package/src/tileset-3d/format-i3s/i3s-source.ts +119 -18
- package/src/tileset-3d/helpers/bounding-volume.ts +3 -55
- package/src/tileset-3d/helpers/frame-state.ts +3 -0
- package/src/tileset-3d/helpers/i3s-lod.ts +22 -8
- package/src/types.ts +3 -0
package/dist/dist.min.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var Ni=Object.create;var oe=Object.defineProperty;var qi=Object.getOwnPropertyDescriptor;var zi=Object.getOwnPropertyNames;var Di=Object.getPrototypeOf,Bi=Object.prototype.hasOwnProperty;var Vi=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}},zt=(e,t)=>{for(var s in t)oe(e,s,{get:t[s],enumerable:!0})},ie=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of zi(t))!Bi.call(e,n)&&n!==s&&oe(e,n,{get:()=>t[n],enumerable:!(r=qi(t,n))||r.enumerable});return e},ae=(e,t,s)=>(ie(e,t,"default"),s&&ie(s,t,"default")),Fi=(e,t,s)=>(s=e!=null?Ni(Di(e)):{},ie(t||!e||!e.__esModule?oe(s,"default",{value:e,enumerable:!0}):s,e)),Ui=e=>ie(oe({},"__esModule",{value:!0}),e);var mr=Vi((qh,fr)=>{fr.exports=globalThis.loaders});var re={};zt(re,{I3SSource:()=>Qe,ImageSet:()=>Je,IndexedArchiveTilesetSource:()=>Ue,LOD_METRIC_TYPE:()=>Lt,PointCloudTile:()=>qt,PointCloudTileset:()=>ss,RasterSet:()=>ts,STRATEGY_DEFAULT:()=>ee,STRATEGY_NEVER:()=>ur,STRATEGY_REPLACE:()=>dr,SharedTile2DHeader:()=>Et,TILESET_TYPE:()=>j,TILE_CONTENT_STATE:()=>G,TILE_REFINEMENT:()=>Y,TILE_TYPE:()=>ot,Tile3D:()=>et,Tiles3DSource:()=>He,Tileset2D:()=>te,Tileset3D:()=>Fe,TilesetCache:()=>It,TilesetTraverser:()=>at,calculateTransformProps:()=>Le,createBoundingVolume:()=>Pt,createImplicitSubtreeReference:()=>hr,getFrameState:()=>ze,getLodStatus:()=>We,isTileset3DSource:()=>Ve,materializeImplicitSubtree:()=>Ge,replaceImplicitUrlTemplate:()=>$e});ae(re,Fi(mr(),1));var ki=1/Math.PI*180,Wi=1/180*Math.PI,Yi={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Yi}};var D=globalThis.mathgl.config;function ns(e,{precision:t=D.precision}={}){return e=Gi(e),`${parseFloat(e.toPrecision(t))}`}function nt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function is(e){return pr(e)}function os(e){return Q(e)}function pr(e,t){return as(e,s=>s*Wi,t)}function Q(e,t){return as(e,s=>s*ki,t)}function Dt(e,t,s){return as(e,r=>Math.max(t,Math.min(s,r)))}function K(e,t,s){let r=D.EPSILON;s&&(D.EPSILON=s);try{if(e===t)return!0;if(nt(e)&&nt(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!K(e[n],t[n]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=D.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{D.EPSILON=r}}function Gi(e){return Math.round(e/D.EPSILON)*D.EPSILON}function $i(e){return e.clone?e.clone():new Array(e.length)}function as(e,t,s){if(nt(e)){let r=e;s=s||$i(r);for(let n=0;n<s.length&&n<r.length;++n){let i=typeof e=="number"?e:e[n];s[n]=t(i,n,s)}return s}return t(e)}var ut=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,s=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+s];return this.check()}toArray(t=[],s=0){for(let r=0;r<this.ELEMENTS;++r)t[s+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:nt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(D)}formatString(t){let s="";for(let r=0;r<this.ELEMENTS;++r)s+=(r>0?", ":"")+ns(this[r],t);return`${t.printTypes?this.constructor.name:""}[${s}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let s=0;s<this.ELEMENTS;++s)if(!K(this[s],t[s]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let s=0;s<this.ELEMENTS;++s)if(this[s]!==t[s])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,s,r){if(r===void 0)return this.lerp(this,t,s);for(let n=0;n<this.ELEMENTS;++n){let i=t[n],o=typeof s=="number"?s:s[n];this[n]=i+r*(o-i)}return this.check()}min(t){for(let s=0;s<this.ELEMENTS;++s)this[s]=Math.min(t[s],this[s]);return this.check()}max(t){for(let s=0;s<this.ELEMENTS;++s)this[s]=Math.max(t[s],this[s]);return this.check()}clamp(t,s){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),s[r]);return this.check()}add(...t){for(let s of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=s[r];return this.check()}subtract(...t){for(let s of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=s[r];return this.check()}scale(t){if(typeof t=="number")for(let s=0;s<this.ELEMENTS;++s)this[s]*=t;else for(let s=0;s<this.ELEMENTS&&s<t.length;++s)this[s]*=t[s];return this.check()}multiplyByScalar(t){for(let s=0;s<this.ELEMENTS;++s)this[s]*=t;return this.check()}check(){if(D.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let s=0;s<this.ELEMENTS;++s)t=t&&Number.isFinite(this[s]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let s=0;s<this.ELEMENTS;++s)this[s]=t;return this.check()}addScalar(t){for(let s=0;s<this.ELEMENTS;++s)this[s]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let s=0;s<this.ELEMENTS;++s)this[s]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,s){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),s);return this.check()}get elements(){return this}};function Hi(e,t){if(e.length!==t)return!1;for(let s=0;s<e.length;++s)if(!Number.isFinite(e[s]))return!1;return!0}function I(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function dt(e,t,s=""){if(D.debug&&!Hi(e,t))throw new Error(`math.gl: ${s} some fields set to invalid numbers'`);return e}function F(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var bt=class extends ut{get x(){return this[0]}set x(t){this[0]=I(t)}get y(){return this[1]}set y(t){this[1]=I(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let s=0;s<this.ELEMENTS;++s)t+=this[s]*this[s];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let s=0;for(let r=0;r<this.ELEMENTS;++r){let n=this[r]-t[r];s+=n*n}return I(s)}dot(t){let s=0;for(let r=0;r<this.ELEMENTS;++r)s+=this[r]*t[r];return I(s)}normalize(){let t=this.magnitude();if(t!==0)for(let s=0;s<this.ELEMENTS;++s)this[s]/=t;return this.check()}multiply(...t){for(let s of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=s[r];return this.check()}divide(...t){for(let s of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=s[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return F(t>=0&&t<this.ELEMENTS,"index is out of range"),I(this[t])}setComponent(t,s){return F(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=s,this.check()}addVectors(t,s){return this.copy(t).add(s)}subVectors(t,s){return this.copy(t).subtract(s)}multiplyVectors(t,s){return this.copy(t).multiply(s)}addScaledVector(t,s){return this.add(new this.constructor(t).multiplyScalar(s))}};var B=typeof Float32Array<"u"?Float32Array:Array,Bt=Math.random;function Rt(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var $h=Math.PI/180;function Zi(){let e=new B(2);return B!=Float32Array&&(e[0]=0,e[1]=0),e}function gr(e,t,s){let r=t[0],n=t[1];return e[0]=s[0]*r+s[3]*n+s[6],e[1]=s[1]*r+s[4]*n+s[7],e}function xr(e,t,s){let r=t[0],n=t[1];return e[0]=s[0]*r+s[4]*n+s[12],e[1]=s[1]*r+s[5]*n+s[13],e}var Hh=(function(){let e=Zi();return function(t,s,r,n,i,o){let a,c;for(s||(s=2),r||(r=0),n?c=Math.min(n*s+r,t.length):c=t.length,a=r;a<c;a+=s)e[0]=t[a],e[1]=t[a+1],i(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();function yr(e,t,s){let r=t[0],n=t[1],i=s[3]*r+s[7]*n||1;return e[0]=(s[0]*r+s[4]*n)/i,e[1]=(s[1]*r+s[5]*n)/i,e}function ce(e,t,s){let r=t[0],n=t[1],i=t[2],o=s[3]*r+s[7]*n+s[11]*i||1;return e[0]=(s[0]*r+s[4]*n+s[8]*i)/o,e[1]=(s[1]*r+s[5]*n+s[9]*i)/o,e[2]=(s[2]*r+s[6]*n+s[10]*i)/o,e}function Tr(e,t,s){let r=t[0],n=t[1];return e[0]=s[0]*r+s[2]*n,e[1]=s[1]*r+s[3]*n,e[2]=t[2],e}function _r(e,t,s){let r=t[0],n=t[1];return e[0]=s[0]*r+s[2]*n,e[1]=s[1]*r+s[3]*n,e[2]=t[2],e[3]=t[3],e}function he(e,t,s){let r=t[0],n=t[1],i=t[2];return e[0]=s[0]*r+s[3]*n+s[6]*i,e[1]=s[1]*r+s[4]*n+s[7]*i,e[2]=s[2]*r+s[5]*n+s[8]*i,e[3]=t[3],e}var Ct={};zt(Ct,{add:()=>Ji,angle:()=>ds,bezier:()=>fo,ceil:()=>to,clone:()=>Xi,copy:()=>Qi,create:()=>le,cross:()=>yt,dist:()=>So,distance:()=>Rr,div:()=>Mo,divide:()=>br,dot:()=>Vt,equals:()=>yo,exactEquals:()=>xo,floor:()=>eo,forEach:()=>Ro,fromValues:()=>ue,hermite:()=>uo,inverse:()=>co,len:()=>fs,length:()=>Mr,lerp:()=>ho,max:()=>ro,min:()=>so,mul:()=>_o,multiply:()=>Er,negate:()=>ao,normalize:()=>cs,random:()=>mo,rotateX:()=>hs,rotateY:()=>ls,rotateZ:()=>us,round:()=>no,scale:()=>io,scaleAndAdd:()=>oo,set:()=>Ki,slerp:()=>lo,sqrDist:()=>Eo,sqrLen:()=>bo,squaredDistance:()=>wr,squaredLength:()=>Cr,str:()=>go,sub:()=>To,subtract:()=>Sr,transformMat3:()=>Ft,transformMat4:()=>Tt,transformQuat:()=>Ut,zero:()=>po});function le(){let e=new B(3);return B!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Xi(e){let t=new B(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Mr(e){let t=e[0],s=e[1],r=e[2];return Math.sqrt(t*t+s*s+r*r)}function ue(e,t,s){let r=new B(3);return r[0]=e,r[1]=t,r[2]=s,r}function Qi(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ki(e,t,s,r){return e[0]=t,e[1]=s,e[2]=r,e}function Ji(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e}function Sr(e,t,s){return e[0]=t[0]-s[0],e[1]=t[1]-s[1],e[2]=t[2]-s[2],e}function Er(e,t,s){return e[0]=t[0]*s[0],e[1]=t[1]*s[1],e[2]=t[2]*s[2],e}function br(e,t,s){return e[0]=t[0]/s[0],e[1]=t[1]/s[1],e[2]=t[2]/s[2],e}function to(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function eo(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function so(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 ro(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 no(e,t){return e[0]=Rt(t[0]),e[1]=Rt(t[1]),e[2]=Rt(t[2]),e}function io(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function oo(e,t,s,r){return e[0]=t[0]+s[0]*r,e[1]=t[1]+s[1]*r,e[2]=t[2]+s[2]*r,e}function Rr(e,t){let s=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return Math.sqrt(s*s+r*r+n*n)}function wr(e,t){let s=t[0]-e[0],r=t[1]-e[1],n=t[2]-e[2];return s*s+r*r+n*n}function Cr(e){let t=e[0],s=e[1],r=e[2];return t*t+s*s+r*r}function ao(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function co(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function cs(e,t){let s=t[0],r=t[1],n=t[2],i=s*s+r*r+n*n;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 Vt(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function yt(e,t,s){let r=t[0],n=t[1],i=t[2],o=s[0],a=s[1],c=s[2];return e[0]=n*c-i*a,e[1]=i*o-r*c,e[2]=r*a-n*o,e}function ho(e,t,s,r){let n=t[0],i=t[1],o=t[2];return e[0]=n+r*(s[0]-n),e[1]=i+r*(s[1]-i),e[2]=o+r*(s[2]-o),e}function lo(e,t,s,r){let n=Math.acos(Math.min(Math.max(Vt(t,s),-1),1)),i=Math.sin(n),o=Math.sin((1-r)*n)/i,a=Math.sin(r*n)/i;return e[0]=o*t[0]+a*s[0],e[1]=o*t[1]+a*s[1],e[2]=o*t[2]+a*s[2],e}function uo(e,t,s,r,n,i){let o=i*i,a=o*(2*i-3)+1,c=o*(i-2)+i,h=o*(i-1),l=o*(3-2*i);return e[0]=t[0]*a+s[0]*c+r[0]*h+n[0]*l,e[1]=t[1]*a+s[1]*c+r[1]*h+n[1]*l,e[2]=t[2]*a+s[2]*c+r[2]*h+n[2]*l,e}function fo(e,t,s,r,n,i){let o=1-i,a=o*o,c=i*i,h=a*o,l=3*i*a,u=3*c*o,d=c*i;return e[0]=t[0]*h+s[0]*l+r[0]*u+n[0]*d,e[1]=t[1]*h+s[1]*l+r[1]*u+n[1]*d,e[2]=t[2]*h+s[2]*l+r[2]*u+n[2]*d,e}function mo(e,t){t=t===void 0?1:t;let s=Bt()*2*Math.PI,r=Bt()*2-1,n=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(s)*n,e[1]=Math.sin(s)*n,e[2]=r*t,e}function Tt(e,t,s){let r=t[0],n=t[1],i=t[2],o=s[3]*r+s[7]*n+s[11]*i+s[15];return o=o||1,e[0]=(s[0]*r+s[4]*n+s[8]*i+s[12])/o,e[1]=(s[1]*r+s[5]*n+s[9]*i+s[13])/o,e[2]=(s[2]*r+s[6]*n+s[10]*i+s[14])/o,e}function Ft(e,t,s){let r=t[0],n=t[1],i=t[2];return e[0]=r*s[0]+n*s[3]+i*s[6],e[1]=r*s[1]+n*s[4]+i*s[7],e[2]=r*s[2]+n*s[5]+i*s[8],e}function Ut(e,t,s){let r=s[0],n=s[1],i=s[2],o=s[3],a=t[0],c=t[1],h=t[2],l=n*h-i*c,u=i*a-r*h,d=r*c-n*a,f=n*d-i*u,g=i*l-r*d,x=r*u-n*l,p=o*2;return l*=p,u*=p,d*=p,f*=2,g*=2,x*=2,e[0]=a+l+f,e[1]=c+u+g,e[2]=h+d+x,e}function hs(e,t,s,r){let n=[],i=[];return n[0]=t[0]-s[0],n[1]=t[1]-s[1],n[2]=t[2]-s[2],i[0]=n[0],i[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),i[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=i[0]+s[0],e[1]=i[1]+s[1],e[2]=i[2]+s[2],e}function ls(e,t,s,r){let n=[],i=[];return n[0]=t[0]-s[0],n[1]=t[1]-s[1],n[2]=t[2]-s[2],i[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),i[1]=n[1],i[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=i[0]+s[0],e[1]=i[1]+s[1],e[2]=i[2]+s[2],e}function us(e,t,s,r){let n=[],i=[];return n[0]=t[0]-s[0],n[1]=t[1]-s[1],n[2]=t[2]-s[2],i[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),i[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),i[2]=n[2],e[0]=i[0]+s[0],e[1]=i[1]+s[1],e[2]=i[2]+s[2],e}function ds(e,t){let s=e[0],r=e[1],n=e[2],i=t[0],o=t[1],a=t[2],c=Math.sqrt((s*s+r*r+n*n)*(i*i+o*o+a*a)),h=c&&Vt(e,t)/c;return Math.acos(Math.min(Math.max(h,-1),1))}function po(e){return e[0]=0,e[1]=0,e[2]=0,e}function go(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function xo(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function yo(e,t){let s=e[0],r=e[1],n=e[2],i=t[0],o=t[1],a=t[2];return Math.abs(s-i)<=1e-6*Math.max(1,Math.abs(s),Math.abs(i))&&Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))}var To=Sr,_o=Er,Mo=br,So=Rr,Eo=wr,fs=Mr,bo=Cr,Ro=(function(){let e=le();return function(t,s,r,n,i,o){let a,c;for(s||(s=3),r||(r=0),n?c=Math.min(n*s+r,t.length):c=t.length,a=r;a<c;a+=s)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],i(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();var ms=[0,0,0],de,m=class e extends bt{static get ZERO(){return de||(de=new e(0,0,0),Object.freeze(de)),de}constructor(t=0,s=0,r=0){super(-0,-0,-0),arguments.length===1&&nt(t)?this.copy(t):(D.debug&&(I(t),I(s),I(r)),this[0]=t,this[1]=s,this[2]=r)}set(t,s,r){return this[0]=t,this[1]=s,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return D.debug&&(I(t.x),I(t.y),I(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=I(t)}angle(t){return ds(this,t)}cross(t){return yt(this,this,t),this.check()}rotateX({radians:t,origin:s=ms}){return hs(this,this,s,t),this.check()}rotateY({radians:t,origin:s=ms}){return ls(this,this,s,t),this.check()}rotateZ({radians:t,origin:s=ms}){return us(this,this,s,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Tt(this,this,t),this.check()}transformAsVector(t){return ce(this,this,t),this.check()}transformByMatrix3(t){return Ft(this,this,t),this.check()}transformByMatrix2(t){return Tr(this,this,t),this.check()}transformByQuaternion(t){return Ut(this,this,t),this.check()}};var fe,me=class e extends bt{static get ZERO(){return fe||(fe=new e(0,0,0,0),Object.freeze(fe)),fe}constructor(t=0,s=0,r=0,n=0){super(-0,-0,-0,-0),nt(t)&&arguments.length===1?this.copy(t):(D.debug&&(I(t),I(s),I(r),I(n)),this[0]=t,this[1]=s,this[2]=r,this[3]=n)}set(t,s,r,n){return this[0]=t,this[1]=s,this[2]=r,this[3]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return D.debug&&(I(t.x),I(t.y),I(t.z),I(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=I(t)}get w(){return this[3]}set w(t){this[3]=I(t)}transform(t){return Tt(this,this,t),this.check()}transformByMatrix3(t){return he(this,this,t),this.check()}transformByMatrix2(t){return _r(this,this,t),this.check()}transformByQuaternion(t){return Ut(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var Ot=class extends ut{toString(){let t="[";if(D.printRowMajor){t+="row-major:";for(let s=0;s<this.RANK;++s)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+s]}`}else{t+="column-major:";for(let s=0;s<this.ELEMENTS;++s)t+=` ${this[s]}`}return t+="]",t}getElementIndex(t,s){return s*this.RANK+t}getElement(t,s){return this[s*this.RANK+t]}setElement(t,s,r){return this[s*this.RANK+t]=I(r),this}getColumn(t,s=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let n=0;n<this.RANK;++n)s[n]=this[r+n];return s}setColumn(t,s){let r=t*this.RANK;for(let n=0;n<this.RANK;++n)this[r+n]=s[n];return this}};function Or(){let e=new B(9);return B!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Ar(e,t){if(e===t){let s=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=s,e[5]=t[7],e[6]=r,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function vr(e,t){let s=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=l*o-a*h,d=-l*i+a*c,f=h*i-o*c,g=s*u+r*d+n*f;return g?(g=1/g,e[0]=u*g,e[1]=(-l*r+n*h)*g,e[2]=(a*r-n*o)*g,e[3]=d*g,e[4]=(l*s-n*c)*g,e[5]=(-a*s+n*i)*g,e[6]=f*g,e[7]=(-h*s+r*c)*g,e[8]=(o*s-r*i)*g,e):null}function Ir(e){let t=e[0],s=e[1],r=e[2],n=e[3],i=e[4],o=e[5],a=e[6],c=e[7],h=e[8];return t*(h*i-o*c)+s*(-h*n+o*a)+r*(c*n-i*a)}function ps(e,t,s){let r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=s[0],f=s[1],g=s[2],x=s[3],p=s[4],y=s[5],E=s[6],_=s[7],T=s[8];return e[0]=d*r+f*o+g*h,e[1]=d*n+f*a+g*l,e[2]=d*i+f*c+g*u,e[3]=x*r+p*o+y*h,e[4]=x*n+p*a+y*l,e[5]=x*i+p*c+y*u,e[6]=E*r+_*o+T*h,e[7]=E*n+_*a+T*l,e[8]=E*i+_*c+T*u,e}function Lr(e,t,s){let r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=s[0],f=s[1];return e[0]=r,e[1]=n,e[2]=i,e[3]=o,e[4]=a,e[5]=c,e[6]=d*r+f*o+h,e[7]=d*n+f*a+l,e[8]=d*i+f*c+u,e}function Pr(e,t,s){let r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=Math.sin(s),f=Math.cos(s);return e[0]=f*r+d*o,e[1]=f*n+d*a,e[2]=f*i+d*c,e[3]=f*o-d*r,e[4]=f*a-d*n,e[5]=f*c-d*i,e[6]=h,e[7]=l,e[8]=u,e}function gs(e,t,s){let r=s[0],n=s[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=n*t[3],e[4]=n*t[4],e[5]=n*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Nr(e,t){let s=t[0],r=t[1],n=t[2],i=t[3],o=s+s,a=r+r,c=n+n,h=s*o,l=r*o,u=r*a,d=n*o,f=n*a,g=n*c,x=i*o,p=i*a,y=i*c;return e[0]=1-u-g,e[3]=l-y,e[6]=d+p,e[1]=l+y,e[4]=1-h-g,e[7]=f-x,e[2]=d-p,e[5]=f+x,e[8]=1-h-u,e}var xs;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(xs||(xs={}));var wo=Object.freeze([1,0,0,0,1,0,0,0,1]),V=class extends Ot{static get IDENTITY(){return Oo()}static get ZERO(){return Co()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return xs}constructor(t,...s){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):s.length>0?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(wo)}fromObject(t){return this.check()}fromQuaternion(t){return Nr(this,t),this.check()}set(t,s,r,n,i,o,a,c,h){return this[0]=t,this[1]=s,this[2]=r,this[3]=n,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=h,this.check()}setRowMajor(t,s,r,n,i,o,a,c,h){return this[0]=t,this[1]=n,this[2]=a,this[3]=s,this[4]=i,this[5]=c,this[6]=r,this[7]=o,this[8]=h,this.check()}determinant(){return Ir(this)}transpose(){return Ar(this,this),this.check()}invert(){return vr(this,this),this.check()}multiplyLeft(t){return ps(this,t,this),this.check()}multiplyRight(t){return ps(this,this,t),this.check()}rotate(t){return Pr(this,this,t),this.check()}scale(t){return Array.isArray(t)?gs(this,this,t):gs(this,this,[t,t]),this.check()}translate(t){return Lr(this,this,t),this.check()}transform(t,s){let r;switch(t.length){case 2:r=gr(s||[-0,-0],t,this);break;case 3:r=Ft(s||[-0,-0,-0],t,this);break;case 4:r=he(s||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return dt(r,t.length),r}transformVector(t,s){return this.transform(t,s)}transformVector2(t,s){return this.transform(t,s)}transformVector3(t,s){return this.transform(t,s)}},pe,ge=null;function Co(){return pe||(pe=new V([0,0,0,0,0,0,0,0,0]),Object.freeze(pe)),pe}function Oo(){return ge||(ge=new V,Object.freeze(ge)),ge}var xe={};zt(xe,{add:()=>Jo,adjoint:()=>No,clone:()=>vo,copy:()=>Io,create:()=>Ao,decompose:()=>Yo,determinant:()=>_s,equals:()=>ra,exactEquals:()=>sa,frob:()=>Ko,fromQuat:()=>Cs,fromQuat2:()=>Uo,fromRotation:()=>Do,fromRotationTranslation:()=>Dr,fromRotationTranslationScale:()=>Go,fromRotationTranslationScaleOrigin:()=>$o,fromScaling:()=>zo,fromTranslation:()=>qo,fromValues:()=>Lo,fromXRotation:()=>Bo,fromYRotation:()=>Vo,fromZRotation:()=>Fo,frustum:()=>Os,getRotation:()=>Wo,getScaling:()=>Br,getTranslation:()=>ko,identity:()=>zr,invert:()=>Ts,lookAt:()=>Is,mul:()=>na,multiply:()=>kt,multiplyScalar:()=>ta,multiplyScalarAndAdd:()=>ea,ortho:()=>vs,orthoNO:()=>Fr,orthoZO:()=>jo,perspective:()=>As,perspectiveFromFieldOfView:()=>Zo,perspectiveNO:()=>Vr,perspectiveZO:()=>Ho,rotate:()=>Es,rotateX:()=>bs,rotateY:()=>Rs,rotateZ:()=>ws,scale:()=>Ss,set:()=>Po,str:()=>Qo,sub:()=>ia,subtract:()=>Ur,targetTo:()=>Xo,translate:()=>Ms,transpose:()=>ys});function Ao(){let e=new B(16);return B!=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 vo(e){let t=new B(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 Io(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 Lo(e,t,s,r,n,i,o,a,c,h,l,u,d,f,g,x){let p=new B(16);return p[0]=e,p[1]=t,p[2]=s,p[3]=r,p[4]=n,p[5]=i,p[6]=o,p[7]=a,p[8]=c,p[9]=h,p[10]=l,p[11]=u,p[12]=d,p[13]=f,p[14]=g,p[15]=x,p}function Po(e,t,s,r,n,i,o,a,c,h,l,u,d,f,g,x,p){return e[0]=t,e[1]=s,e[2]=r,e[3]=n,e[4]=i,e[5]=o,e[6]=a,e[7]=c,e[8]=h,e[9]=l,e[10]=u,e[11]=d,e[12]=f,e[13]=g,e[14]=x,e[15]=p,e}function zr(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 ys(e,t){if(e===t){let s=t[1],r=t[2],n=t[3],i=t[6],o=t[7],a=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]=r,e[9]=i,e[11]=t[14],e[12]=n,e[13]=o,e[14]=a}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 Ts(e,t){let s=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=t[9],d=t[10],f=t[11],g=t[12],x=t[13],p=t[14],y=t[15],E=s*a-r*o,_=s*c-n*o,T=s*h-i*o,S=r*c-n*a,M=r*h-i*a,A=n*h-i*c,R=l*x-u*g,C=l*p-d*g,b=l*y-f*g,P=u*p-d*x,q=u*y-f*x,z=d*y-f*p,O=E*z-_*q+T*P+S*b-M*C+A*R;return O?(O=1/O,e[0]=(a*z-c*q+h*P)*O,e[1]=(n*q-r*z-i*P)*O,e[2]=(x*A-p*M+y*S)*O,e[3]=(d*M-u*A-f*S)*O,e[4]=(c*b-o*z-h*C)*O,e[5]=(s*z-n*b+i*C)*O,e[6]=(p*T-g*A-y*_)*O,e[7]=(l*A-d*T+f*_)*O,e[8]=(o*q-a*b+h*R)*O,e[9]=(r*b-s*q-i*R)*O,e[10]=(g*M-x*T+y*E)*O,e[11]=(u*T-l*M-f*E)*O,e[12]=(a*C-o*P-c*R)*O,e[13]=(s*P-r*C+n*R)*O,e[14]=(x*_-g*S-p*E)*O,e[15]=(l*S-u*_+d*E)*O,e):null}function No(e,t){let s=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=t[9],d=t[10],f=t[11],g=t[12],x=t[13],p=t[14],y=t[15],E=s*a-r*o,_=s*c-n*o,T=s*h-i*o,S=r*c-n*a,M=r*h-i*a,A=n*h-i*c,R=l*x-u*g,C=l*p-d*g,b=l*y-f*g,P=u*p-d*x,q=u*y-f*x,z=d*y-f*p;return e[0]=a*z-c*q+h*P,e[1]=n*q-r*z-i*P,e[2]=x*A-p*M+y*S,e[3]=d*M-u*A-f*S,e[4]=c*b-o*z-h*C,e[5]=s*z-n*b+i*C,e[6]=p*T-g*A-y*_,e[7]=l*A-d*T+f*_,e[8]=o*q-a*b+h*R,e[9]=r*b-s*q-i*R,e[10]=g*M-x*T+y*E,e[11]=u*T-l*M-f*E,e[12]=a*C-o*P-c*R,e[13]=s*P-r*C+n*R,e[14]=x*_-g*S-p*E,e[15]=l*S-u*_+d*E,e}function _s(e){let t=e[0],s=e[1],r=e[2],n=e[3],i=e[4],o=e[5],a=e[6],c=e[7],h=e[8],l=e[9],u=e[10],d=e[11],f=e[12],g=e[13],x=e[14],p=e[15],y=t*o-s*i,E=t*a-r*i,_=s*a-r*o,T=h*g-l*f,S=h*x-u*f,M=l*x-u*g,A=t*M-s*S+r*T,R=i*M-o*S+a*T,C=h*_-l*E+u*y,b=f*_-g*E+x*y;return c*A-n*R+p*C-d*b}function kt(e,t,s){let r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=t[8],d=t[9],f=t[10],g=t[11],x=t[12],p=t[13],y=t[14],E=t[15],_=s[0],T=s[1],S=s[2],M=s[3];return e[0]=_*r+T*a+S*u+M*x,e[1]=_*n+T*c+S*d+M*p,e[2]=_*i+T*h+S*f+M*y,e[3]=_*o+T*l+S*g+M*E,_=s[4],T=s[5],S=s[6],M=s[7],e[4]=_*r+T*a+S*u+M*x,e[5]=_*n+T*c+S*d+M*p,e[6]=_*i+T*h+S*f+M*y,e[7]=_*o+T*l+S*g+M*E,_=s[8],T=s[9],S=s[10],M=s[11],e[8]=_*r+T*a+S*u+M*x,e[9]=_*n+T*c+S*d+M*p,e[10]=_*i+T*h+S*f+M*y,e[11]=_*o+T*l+S*g+M*E,_=s[12],T=s[13],S=s[14],M=s[15],e[12]=_*r+T*a+S*u+M*x,e[13]=_*n+T*c+S*d+M*p,e[14]=_*i+T*h+S*f+M*y,e[15]=_*o+T*l+S*g+M*E,e}function Ms(e,t,s){let r=s[0],n=s[1],i=s[2],o,a,c,h,l,u,d,f,g,x,p,y;return t===e?(e[12]=t[0]*r+t[4]*n+t[8]*i+t[12],e[13]=t[1]*r+t[5]*n+t[9]*i+t[13],e[14]=t[2]*r+t[6]*n+t[10]*i+t[14],e[15]=t[3]*r+t[7]*n+t[11]*i+t[15]):(o=t[0],a=t[1],c=t[2],h=t[3],l=t[4],u=t[5],d=t[6],f=t[7],g=t[8],x=t[9],p=t[10],y=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=h,e[4]=l,e[5]=u,e[6]=d,e[7]=f,e[8]=g,e[9]=x,e[10]=p,e[11]=y,e[12]=o*r+l*n+g*i+t[12],e[13]=a*r+u*n+x*i+t[13],e[14]=c*r+d*n+p*i+t[14],e[15]=h*r+f*n+y*i+t[15]),e}function Ss(e,t,s){let r=s[0],n=s[1],i=s[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,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 Es(e,t,s,r){let n=r[0],i=r[1],o=r[2],a=Math.sqrt(n*n+i*i+o*o),c,h,l,u,d,f,g,x,p,y,E,_,T,S,M,A,R,C,b,P,q,z,O,X;return a<1e-6?null:(a=1/a,n*=a,i*=a,o*=a,h=Math.sin(s),c=Math.cos(s),l=1-c,u=t[0],d=t[1],f=t[2],g=t[3],x=t[4],p=t[5],y=t[6],E=t[7],_=t[8],T=t[9],S=t[10],M=t[11],A=n*n*l+c,R=i*n*l+o*h,C=o*n*l-i*h,b=n*i*l-o*h,P=i*i*l+c,q=o*i*l+n*h,z=n*o*l+i*h,O=i*o*l-n*h,X=o*o*l+c,e[0]=u*A+x*R+_*C,e[1]=d*A+p*R+T*C,e[2]=f*A+y*R+S*C,e[3]=g*A+E*R+M*C,e[4]=u*b+x*P+_*q,e[5]=d*b+p*P+T*q,e[6]=f*b+y*P+S*q,e[7]=g*b+E*P+M*q,e[8]=u*z+x*O+_*X,e[9]=d*z+p*O+T*X,e[10]=f*z+y*O+S*X,e[11]=g*z+E*O+M*X,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function bs(e,t,s){let r=Math.sin(s),n=Math.cos(s),i=t[4],o=t[5],a=t[6],c=t[7],h=t[8],l=t[9],u=t[10],d=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*n+h*r,e[5]=o*n+l*r,e[6]=a*n+u*r,e[7]=c*n+d*r,e[8]=h*n-i*r,e[9]=l*n-o*r,e[10]=u*n-a*r,e[11]=d*n-c*r,e}function Rs(e,t,s){let r=Math.sin(s),n=Math.cos(s),i=t[0],o=t[1],a=t[2],c=t[3],h=t[8],l=t[9],u=t[10],d=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*n-h*r,e[1]=o*n-l*r,e[2]=a*n-u*r,e[3]=c*n-d*r,e[8]=i*r+h*n,e[9]=o*r+l*n,e[10]=a*r+u*n,e[11]=c*r+d*n,e}function ws(e,t,s){let r=Math.sin(s),n=Math.cos(s),i=t[0],o=t[1],a=t[2],c=t[3],h=t[4],l=t[5],u=t[6],d=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*n+h*r,e[1]=o*n+l*r,e[2]=a*n+u*r,e[3]=c*n+d*r,e[4]=h*n-i*r,e[5]=l*n-o*r,e[6]=u*n-a*r,e[7]=d*n-c*r,e}function qo(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 zo(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 Do(e,t,s){let r=s[0],n=s[1],i=s[2],o=Math.sqrt(r*r+n*n+i*i),a,c,h;return o<1e-6?null:(o=1/o,r*=o,n*=o,i*=o,c=Math.sin(t),a=Math.cos(t),h=1-a,e[0]=r*r*h+a,e[1]=n*r*h+i*c,e[2]=i*r*h-n*c,e[3]=0,e[4]=r*n*h-i*c,e[5]=n*n*h+a,e[6]=i*n*h+r*c,e[7]=0,e[8]=r*i*h+n*c,e[9]=n*i*h-r*c,e[10]=i*i*h+a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Bo(e,t){let s=Math.sin(t),r=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=s,e[7]=0,e[8]=0,e[9]=-s,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Vo(e,t){let s=Math.sin(t),r=Math.cos(t);return e[0]=r,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]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Fo(e,t){let s=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=s,e[2]=0,e[3]=0,e[4]=-s,e[5]=r,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 Dr(e,t,s){let r=t[0],n=t[1],i=t[2],o=t[3],a=r+r,c=n+n,h=i+i,l=r*a,u=r*c,d=r*h,f=n*c,g=n*h,x=i*h,p=o*a,y=o*c,E=o*h;return e[0]=1-(f+x),e[1]=u+E,e[2]=d-y,e[3]=0,e[4]=u-E,e[5]=1-(l+x),e[6]=g+p,e[7]=0,e[8]=d+y,e[9]=g-p,e[10]=1-(l+f),e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function Uo(e,t){let s=new B(3),r=-t[0],n=-t[1],i=-t[2],o=t[3],a=t[4],c=t[5],h=t[6],l=t[7],u=r*r+n*n+i*i+o*o;return u>0?(s[0]=(a*o+l*r+c*i-h*n)*2/u,s[1]=(c*o+l*n+h*r-a*i)*2/u,s[2]=(h*o+l*i+a*n-c*r)*2/u):(s[0]=(a*o+l*r+c*i-h*n)*2,s[1]=(c*o+l*n+h*r-a*i)*2,s[2]=(h*o+l*i+a*n-c*r)*2),Dr(e,t,s),e}function ko(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Br(e,t){let s=t[0],r=t[1],n=t[2],i=t[4],o=t[5],a=t[6],c=t[8],h=t[9],l=t[10];return e[0]=Math.sqrt(s*s+r*r+n*n),e[1]=Math.sqrt(i*i+o*o+a*a),e[2]=Math.sqrt(c*c+h*h+l*l),e}function Wo(e,t){let s=new B(3);Br(s,t);let r=1/s[0],n=1/s[1],i=1/s[2],o=t[0]*r,a=t[1]*n,c=t[2]*i,h=t[4]*r,l=t[5]*n,u=t[6]*i,d=t[8]*r,f=t[9]*n,g=t[10]*i,x=o+l+g,p=0;return x>0?(p=Math.sqrt(x+1)*2,e[3]=.25*p,e[0]=(u-f)/p,e[1]=(d-c)/p,e[2]=(a-h)/p):o>l&&o>g?(p=Math.sqrt(1+o-l-g)*2,e[3]=(u-f)/p,e[0]=.25*p,e[1]=(a+h)/p,e[2]=(d+c)/p):l>g?(p=Math.sqrt(1+l-o-g)*2,e[3]=(d-c)/p,e[0]=(a+h)/p,e[1]=.25*p,e[2]=(u+f)/p):(p=Math.sqrt(1+g-o-l)*2,e[3]=(a-h)/p,e[0]=(d+c)/p,e[1]=(u+f)/p,e[2]=.25*p),e}function Yo(e,t,s,r){t[0]=r[12],t[1]=r[13],t[2]=r[14];let n=r[0],i=r[1],o=r[2],a=r[4],c=r[5],h=r[6],l=r[8],u=r[9],d=r[10];s[0]=Math.sqrt(n*n+i*i+o*o),s[1]=Math.sqrt(a*a+c*c+h*h),s[2]=Math.sqrt(l*l+u*u+d*d);let f=1/s[0],g=1/s[1],x=1/s[2],p=n*f,y=i*g,E=o*x,_=a*f,T=c*g,S=h*x,M=l*f,A=u*g,R=d*x,C=p+T+R,b=0;return C>0?(b=Math.sqrt(C+1)*2,e[3]=.25*b,e[0]=(S-A)/b,e[1]=(M-E)/b,e[2]=(y-_)/b):p>T&&p>R?(b=Math.sqrt(1+p-T-R)*2,e[3]=(S-A)/b,e[0]=.25*b,e[1]=(y+_)/b,e[2]=(M+E)/b):T>R?(b=Math.sqrt(1+T-p-R)*2,e[3]=(M-E)/b,e[0]=(y+_)/b,e[1]=.25*b,e[2]=(S+A)/b):(b=Math.sqrt(1+R-p-T)*2,e[3]=(y-_)/b,e[0]=(M+E)/b,e[1]=(S+A)/b,e[2]=.25*b),e}function Go(e,t,s,r){let n=t[0],i=t[1],o=t[2],a=t[3],c=n+n,h=i+i,l=o+o,u=n*c,d=n*h,f=n*l,g=i*h,x=i*l,p=o*l,y=a*c,E=a*h,_=a*l,T=r[0],S=r[1],M=r[2];return e[0]=(1-(g+p))*T,e[1]=(d+_)*T,e[2]=(f-E)*T,e[3]=0,e[4]=(d-_)*S,e[5]=(1-(u+p))*S,e[6]=(x+y)*S,e[7]=0,e[8]=(f+E)*M,e[9]=(x-y)*M,e[10]=(1-(u+g))*M,e[11]=0,e[12]=s[0],e[13]=s[1],e[14]=s[2],e[15]=1,e}function $o(e,t,s,r,n){let i=t[0],o=t[1],a=t[2],c=t[3],h=i+i,l=o+o,u=a+a,d=i*h,f=i*l,g=i*u,x=o*l,p=o*u,y=a*u,E=c*h,_=c*l,T=c*u,S=r[0],M=r[1],A=r[2],R=n[0],C=n[1],b=n[2],P=(1-(x+y))*S,q=(f+T)*S,z=(g-_)*S,O=(f-T)*M,X=(1-(d+y))*M,gt=(p+E)*M,xt=(g+_)*A,rs=(p-E)*A,ne=(1-(d+x))*A;return e[0]=P,e[1]=q,e[2]=z,e[3]=0,e[4]=O,e[5]=X,e[6]=gt,e[7]=0,e[8]=xt,e[9]=rs,e[10]=ne,e[11]=0,e[12]=s[0]+R-(P*R+O*C+xt*b),e[13]=s[1]+C-(q*R+X*C+rs*b),e[14]=s[2]+b-(z*R+gt*C+ne*b),e[15]=1,e}function Cs(e,t){let s=t[0],r=t[1],n=t[2],i=t[3],o=s+s,a=r+r,c=n+n,h=s*o,l=r*o,u=r*a,d=n*o,f=n*a,g=n*c,x=i*o,p=i*a,y=i*c;return e[0]=1-u-g,e[1]=l+y,e[2]=d-p,e[3]=0,e[4]=l-y,e[5]=1-h-g,e[6]=f+x,e[7]=0,e[8]=d+p,e[9]=f-x,e[10]=1-h-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Os(e,t,s,r,n,i,o){let a=1/(s-t),c=1/(n-r),h=1/(i-o);return e[0]=i*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*c,e[6]=0,e[7]=0,e[8]=(s+t)*a,e[9]=(n+r)*c,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 Vr(e,t,s,r,n){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,n!=null&&n!==1/0){let o=1/(r-n);e[10]=(n+r)*o,e[14]=2*n*r*o}else e[10]=-1,e[14]=-2*r;return e}var As=Vr;function Ho(e,t,s,r,n){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,n!=null&&n!==1/0){let o=1/(r-n);e[10]=n*o,e[14]=n*r*o}else e[10]=-1,e[14]=-r;return e}function Zo(e,t,s,r){let n=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),c=2/(o+a),h=2/(n+i);return e[0]=c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=h,e[6]=0,e[7]=0,e[8]=-((o-a)*c*.5),e[9]=(n-i)*h*.5,e[10]=r/(s-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*s/(s-r),e[15]=0,e}function Fr(e,t,s,r,n,i,o){let a=1/(t-s),c=1/(r-n),h=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+s)*a,e[13]=(n+r)*c,e[14]=(o+i)*h,e[15]=1,e}var vs=Fr;function jo(e,t,s,r,n,i,o){let a=1/(t-s),c=1/(r-n),h=1/(i-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=h,e[11]=0,e[12]=(t+s)*a,e[13]=(n+r)*c,e[14]=i*h,e[15]=1,e}function Is(e,t,s,r){let n,i,o,a,c,h,l,u,d,f,g=t[0],x=t[1],p=t[2],y=r[0],E=r[1],_=r[2],T=s[0],S=s[1],M=s[2];return Math.abs(g-T)<1e-6&&Math.abs(x-S)<1e-6&&Math.abs(p-M)<1e-6?zr(e):(u=g-T,d=x-S,f=p-M,n=1/Math.sqrt(u*u+d*d+f*f),u*=n,d*=n,f*=n,i=E*f-_*d,o=_*u-y*f,a=y*d-E*u,n=Math.sqrt(i*i+o*o+a*a),n?(n=1/n,i*=n,o*=n,a*=n):(i=0,o=0,a=0),c=d*a-f*o,h=f*i-u*a,l=u*o-d*i,n=Math.sqrt(c*c+h*h+l*l),n?(n=1/n,c*=n,h*=n,l*=n):(c=0,h=0,l=0),e[0]=i,e[1]=c,e[2]=u,e[3]=0,e[4]=o,e[5]=h,e[6]=d,e[7]=0,e[8]=a,e[9]=l,e[10]=f,e[11]=0,e[12]=-(i*g+o*x+a*p),e[13]=-(c*g+h*x+l*p),e[14]=-(u*g+d*x+f*p),e[15]=1,e)}function Xo(e,t,s,r){let n=t[0],i=t[1],o=t[2],a=r[0],c=r[1],h=r[2],l=n-s[0],u=i-s[1],d=o-s[2],f=l*l+u*u+d*d;f>0&&(f=1/Math.sqrt(f),l*=f,u*=f,d*=f);let g=c*d-h*u,x=h*l-a*d,p=a*u-c*l;return f=g*g+x*x+p*p,f>0&&(f=1/Math.sqrt(f),g*=f,x*=f,p*=f),e[0]=g,e[1]=x,e[2]=p,e[3]=0,e[4]=u*p-d*x,e[5]=d*g-l*p,e[6]=l*x-u*g,e[7]=0,e[8]=l,e[9]=u,e[10]=d,e[11]=0,e[12]=n,e[13]=i,e[14]=o,e[15]=1,e}function Qo(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 Ko(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 Jo(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 Ur(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 ta(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 ea(e,t,s,r){return e[0]=t[0]+s[0]*r,e[1]=t[1]+s[1]*r,e[2]=t[2]+s[2]*r,e[3]=t[3]+s[3]*r,e[4]=t[4]+s[4]*r,e[5]=t[5]+s[5]*r,e[6]=t[6]+s[6]*r,e[7]=t[7]+s[7]*r,e[8]=t[8]+s[8]*r,e[9]=t[9]+s[9]*r,e[10]=t[10]+s[10]*r,e[11]=t[11]+s[11]*r,e[12]=t[12]+s[12]*r,e[13]=t[13]+s[13]*r,e[14]=t[14]+s[14]*r,e[15]=t[15]+s[15]*r,e}function sa(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 ra(e,t){let s=e[0],r=e[1],n=e[2],i=e[3],o=e[4],a=e[5],c=e[6],h=e[7],l=e[8],u=e[9],d=e[10],f=e[11],g=e[12],x=e[13],p=e[14],y=e[15],E=t[0],_=t[1],T=t[2],S=t[3],M=t[4],A=t[5],R=t[6],C=t[7],b=t[8],P=t[9],q=t[10],z=t[11],O=t[12],X=t[13],gt=t[14],xt=t[15];return Math.abs(s-E)<=1e-6*Math.max(1,Math.abs(s),Math.abs(E))&&Math.abs(r-_)<=1e-6*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(n-T)<=1e-6*Math.max(1,Math.abs(n),Math.abs(T))&&Math.abs(i-S)<=1e-6*Math.max(1,Math.abs(i),Math.abs(S))&&Math.abs(o-M)<=1e-6*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(a-A)<=1e-6*Math.max(1,Math.abs(a),Math.abs(A))&&Math.abs(c-R)<=1e-6*Math.max(1,Math.abs(c),Math.abs(R))&&Math.abs(h-C)<=1e-6*Math.max(1,Math.abs(h),Math.abs(C))&&Math.abs(l-b)<=1e-6*Math.max(1,Math.abs(l),Math.abs(b))&&Math.abs(u-P)<=1e-6*Math.max(1,Math.abs(u),Math.abs(P))&&Math.abs(d-q)<=1e-6*Math.max(1,Math.abs(d),Math.abs(q))&&Math.abs(f-z)<=1e-6*Math.max(1,Math.abs(f),Math.abs(z))&&Math.abs(g-O)<=1e-6*Math.max(1,Math.abs(g),Math.abs(O))&&Math.abs(x-X)<=1e-6*Math.max(1,Math.abs(x),Math.abs(X))&&Math.abs(p-gt)<=1e-6*Math.max(1,Math.abs(p),Math.abs(gt))&&Math.abs(y-xt)<=1e-6*Math.max(1,Math.abs(y),Math.abs(xt))}var na=kt,ia=Ur;function oa(){let e=new B(4);return B!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function kr(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 Wr(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 Yr(e){let t=e[0],s=e[1],r=e[2],n=e[3];return Math.sqrt(t*t+s*s+r*r+n*n)}function Gr(e){let t=e[0],s=e[1],r=e[2],n=e[3];return t*t+s*s+r*r+n*n}function $r(e,t){let s=t[0],r=t[1],n=t[2],i=t[3],o=s*s+r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=s*o,e[1]=r*o,e[2]=n*o,e[3]=i*o,e}function Hr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Zr(e,t,s,r){let n=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n+r*(s[0]-n),e[1]=i+r*(s[1]-i),e[2]=o+r*(s[2]-o),e[3]=a+r*(s[3]-a),e}function jr(e,t,s){let r=t[0],n=t[1],i=t[2],o=t[3];return e[0]=s[0]*r+s[4]*n+s[8]*i+s[12]*o,e[1]=s[1]*r+s[5]*n+s[9]*i+s[13]*o,e[2]=s[2]*r+s[6]*n+s[10]*i+s[14]*o,e[3]=s[3]*r+s[7]*n+s[11]*i+s[15]*o,e}function Xr(e,t,s){let r=t[0],n=t[1],i=t[2],o=s[0],a=s[1],c=s[2],h=s[3],l=h*r+a*i-c*n,u=h*n+c*r-o*i,d=h*i+o*n-a*r,f=-o*r-a*n-c*i;return e[0]=l*h+f*-o+u*-c-d*-a,e[1]=u*h+f*-a+d*-o-l*-c,e[2]=d*h+f*-c+l*-a-u*-o,e[3]=t[3],e}var yl=(function(){let e=oa();return function(t,s,r,n,i,o){let a,c;for(s||(s=4),r||(r=0),n?c=Math.min(n*s+r,t.length):c=t.length,a=r;a<c;a+=s)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],i(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();var Ns;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Ns||(Ns={}));var aa=45*Math.PI/180,ca=1,Ls=.1,Ps=500,ha=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),v=class extends Ot{static get IDENTITY(){return ua()}static get ZERO(){return la()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ns}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,s,r,n,i,o,a,c,h,l,u,d,f,g,x,p){return this[0]=t,this[1]=s,this[2]=r,this[3]=n,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=h,this[9]=l,this[10]=u,this[11]=d,this[12]=f,this[13]=g,this[14]=x,this[15]=p,this.check()}setRowMajor(t,s,r,n,i,o,a,c,h,l,u,d,f,g,x,p){return this[0]=t,this[1]=i,this[2]=h,this[3]=f,this[4]=s,this[5]=o,this[6]=l,this[7]=g,this[8]=r,this[9]=a,this[10]=u,this[11]=x,this[12]=n,this[13]=c,this[14]=d,this[15]=p,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(ha)}fromObject(t){return this.check()}fromQuaternion(t){return Cs(this,t),this.check()}frustum(t){let{left:s,right:r,bottom:n,top:i,near:o=Ls,far:a=Ps}=t;return a===1/0?da(this,s,r,n,i,o):Os(this,s,r,n,i,o,a),this.check()}lookAt(t){let{eye:s,center:r=[0,0,0],up:n=[0,1,0]}=t;return Is(this,s,r,n),this.check()}ortho(t){let{left:s,right:r,bottom:n,top:i,near:o=Ls,far:a=Ps}=t;return vs(this,s,r,n,i,o,a),this.check()}orthographic(t){let{fovy:s=aa,aspect:r=ca,focalDistance:n=1,near:i=Ls,far:o=Ps}=t;Kr(s);let a=s/2,c=n*Math.tan(a),h=c*r;return this.ortho({left:-h,right:h,bottom:-c,top:c,near:i,far:o})}perspective(t){let{fovy:s=45*Math.PI/180,aspect:r=1,near:n=.1,far:i=500}=t;return Kr(s),As(this,s,r,n,i),this.check()}determinant(){return _s(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,s){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],s=s||[-0,-0,-0];let r=this.getScale(s),n=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*n,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*n,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*n,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,s){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],s=s||[-0,-0,-0];let r=this.getScale(s),n=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*n,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*n,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*n,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return ys(this,this),this.check()}invert(){return Ts(this,this),this.check()}multiplyLeft(t){return kt(this,t,this),this.check()}multiplyRight(t){return kt(this,this,t),this.check()}rotateX(t){return bs(this,this,t),this.check()}rotateY(t){return Rs(this,this,t),this.check()}rotateZ(t){return ws(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,s){return Es(this,this,t,s),this.check()}scale(t){return Ss(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Ms(this,this,t),this.check()}transform(t,s){return t.length===4?(s=jr(s||[-0,-0,-0,-0],t,this),dt(s,4),s):this.transformAsPoint(t,s)}transformAsPoint(t,s){let{length:r}=t,n;switch(r){case 2:n=xr(s||[-0,-0],t,this);break;case 3:n=Tt(s||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return dt(n,t.length),n}transformAsVector(t,s){let r;switch(t.length){case 2:r=yr(s||[-0,-0],t,this);break;case 3:r=ce(s||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return dt(r,t.length),r}transformPoint(t,s){return this.transformAsPoint(t,s)}transformVector(t,s){return this.transformAsPoint(t,s)}transformDirection(t,s){return this.transformAsVector(t,s)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,s,r){return this.identity().translate([t,s,r])}},ye,Te;function la(){return ye||(ye=new v([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ye)),ye}function ua(){return Te||(Te=new v,Object.freeze(Te)),Te}function Kr(e){if(e>Math.PI*2)throw Error("expected radians")}function da(e,t,s,r,n,i){let o=2*i/(s-t),a=2*i/(n-r),c=(s+t)/(s-t),h=(n+r)/(n-r),l=-1,u=-1,d=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=h,e[10]=l,e[11]=u,e[12]=0,e[13]=0,e[14]=d,e[15]=0,e}function Jr(){let e=new B(4);return B!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function tn(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function qs(e,t,s){s=s*.5;let r=Math.sin(s);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(s),e}function zs(e,t,s){let r=t[0],n=t[1],i=t[2],o=t[3],a=s[0],c=s[1],h=s[2],l=s[3];return e[0]=r*l+o*a+n*h-i*c,e[1]=n*l+o*c+i*a-r*h,e[2]=i*l+o*h+r*c-n*a,e[3]=o*l-r*a-n*c-i*h,e}function en(e,t,s){s*=.5;let r=t[0],n=t[1],i=t[2],o=t[3],a=Math.sin(s),c=Math.cos(s);return e[0]=r*c+o*a,e[1]=n*c+i*a,e[2]=i*c-n*a,e[3]=o*c-r*a,e}function sn(e,t,s){s*=.5;let r=t[0],n=t[1],i=t[2],o=t[3],a=Math.sin(s),c=Math.cos(s);return e[0]=r*c-i*a,e[1]=n*c+o*a,e[2]=i*c+r*a,e[3]=o*c-n*a,e}function rn(e,t,s){s*=.5;let r=t[0],n=t[1],i=t[2],o=t[3],a=Math.sin(s),c=Math.cos(s);return e[0]=r*c+n*a,e[1]=n*c-r*a,e[2]=i*c+o*a,e[3]=o*c-i*a,e}function nn(e,t){let s=t[0],r=t[1],n=t[2];return e[0]=s,e[1]=r,e[2]=n,e[3]=Math.sqrt(Math.abs(1-s*s-r*r-n*n)),e}function Wt(e,t,s,r){let n=t[0],i=t[1],o=t[2],a=t[3],c=s[0],h=s[1],l=s[2],u=s[3],d,f,g,x,p;return d=n*c+i*h+o*l+a*u,d<0&&(d=-d,c=-c,h=-h,l=-l,u=-u),1-d>1e-6?(f=Math.acos(d),p=Math.sin(f),g=Math.sin((1-r)*f)/p,x=Math.sin(r*f)/p):(g=1-r,x=r),e[0]=g*n+x*c,e[1]=g*i+x*h,e[2]=g*o+x*l,e[3]=g*a+x*u,e}function on(e,t){let s=t[0],r=t[1],n=t[2],i=t[3],o=s*s+r*r+n*n+i*i,a=o?1/o:0;return e[0]=-s*a,e[1]=-r*a,e[2]=-n*a,e[3]=i*a,e}function an(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Ds(e,t){let s=t[0]+t[4]+t[8],r;if(s>0)r=Math.sqrt(s+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let n=0;t[4]>t[0]&&(n=1),t[8]>t[n*3+n]&&(n=2);let i=(n+1)%3,o=(n+2)%3;r=Math.sqrt(t[n*3+n]-t[i*3+i]-t[o*3+o]+1),e[n]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+n]+t[n*3+i])*r,e[o]=(t[o*3+n]+t[n*3+o])*r}return e}var cn=kr;var hn=Wr,ln=Hr,un=Zr,dn=Yr;var fn=Gr;var mn=$r;var pn=(function(){let e=le(),t=ue(1,0,0),s=ue(0,1,0);return function(r,n,i){let o=Vt(n,i);return o<-.999999?(yt(e,t,n),fs(e)<1e-6&&yt(e,s,n),cs(e,e),qs(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(yt(e,n,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,mn(r,r))}})(),Ll=(function(){let e=Jr(),t=Jr();return function(s,r,n,i,o,a){return Wt(e,r,o,a),Wt(t,n,i,a),Wt(s,e,t,2*a*(1-a)),s}})(),Pl=(function(){let e=Or();return function(t,s,r,n){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=n[0],e[4]=n[1],e[7]=n[2],e[2]=-s[0],e[5]=-s[1],e[8]=-s[2],mn(t,Ds(t,e))}})();var ma=[0,0,0,1],it=class extends ut{constructor(t=0,s=0,r=0,n=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,s,r,n)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,s,r,n){return this[0]=t,this[1]=s,this[2]=r,this[3]=n,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 Ds(this,t),this.check()}fromAxisRotation(t,s){return qs(this,t,s),this.check()}identity(){return tn(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]=I(t)}get y(){return this[1]}set y(t){this[1]=I(t)}get z(){return this[2]}set z(t){this[2]=I(t)}get w(){return this[3]}set w(t){this[3]=I(t)}len(){return dn(this)}lengthSquared(){return fn(this)}dot(t){return ln(this,t)}rotationTo(t,s){return pn(this,t,s),this.check()}add(t){return cn(this,this,t),this.check()}calculateW(){return nn(this,this),this.check()}conjugate(){return an(this,this),this.check()}invert(){return on(this,this),this.check()}lerp(t,s,r){return r===void 0?this.lerp(this,t,s):(un(this,t,s,r),this.check())}multiplyRight(t){return zs(this,this,t),this.check()}multiplyLeft(t){return zs(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 en(this,this,t),this.check()}rotateY(t){return sn(this,this,t),this.check()}rotateZ(t){return rn(this,this,t),this.check()}scale(t){return hn(this,this,t),this.check()}slerp(t,s,r){let n,i,o;switch(arguments.length){case 1:({start:n=ma,target:i,ratio:o}=t);break;case 2:n=this,i=t,o=s;break;default:n=t,i=s,o=r}return Wt(this,n,i,o),this.check()}transformVector4(t,s=new me){return Xr(s,t,this),dt(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 ft={};zt(ft,{EPSILON1:()=>pa,EPSILON10:()=>ba,EPSILON11:()=>Ra,EPSILON12:()=>wa,EPSILON13:()=>Ca,EPSILON14:()=>Oa,EPSILON15:()=>Aa,EPSILON16:()=>va,EPSILON17:()=>Ia,EPSILON18:()=>La,EPSILON19:()=>Pa,EPSILON2:()=>ga,EPSILON20:()=>Na,EPSILON3:()=>xa,EPSILON4:()=>ya,EPSILON5:()=>Ta,EPSILON6:()=>_a,EPSILON7:()=>Ma,EPSILON8:()=>Sa,EPSILON9:()=>Ea,PI_OVER_FOUR:()=>za,PI_OVER_SIX:()=>Da,PI_OVER_TWO:()=>qa,TWO_PI:()=>Ba});var pa=.1,ga=.01,xa=.001,ya=1e-4,Ta=1e-5,_a=1e-6,Ma=1e-7,Sa=1e-8,Ea=1e-9,ba=1e-10,Ra=1e-11,wa=1e-12,Ca=1e-13,Oa=1e-14,Aa=1e-15,va=1e-16,Ia=1e-17,La=1e-18,Pa=1e-19,Na=1e-20,qa=Math.PI/2,za=Math.PI/4,Da=Math.PI/6,Ba=Math.PI*2;var ct=6356752314245179e-9,Va={radii:[6378137,6378137,ct],radiiSquared:[6378137*6378137,6378137*6378137,ct*ct],oneOverRadii:[1/6378137,1/6378137,1/ct],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(ct*ct)],maximumRadius:Math.max(6378137,6378137,ct),centerToleranceSquared:.1};function _e(e){return e}var au=new m;function Fa(e,t=[],s=_e){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 gn(e,t=[]){return Fa(e,t,D._cartographicRadians?_e:is)}function Ua(e,t,s=_e){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 xn(e,t){return Ua(e,t,D._cartographicRadians?_e:os)}var yn=1e-14,ka=new m,Tn={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"}},Bs={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Yt={east:new m,north:new m,up:new m,west:new m,south:new m,down:new m},Wa=new m,Ya=new m,Ga=new m;function Vs(e,t,s,r,n,i){let o=Tn[t]&&Tn[t][s];F(o&&(!r||r===o));let a,c,h,l=ka.copy(n);if(K(l.x,0,yn)&&K(l.y,0,yn)){let d=Math.sign(l.z);a=Wa.fromArray(Bs[t]),t!=="east"&&t!=="west"&&a.scale(d),c=Ya.fromArray(Bs[s]),s!=="east"&&s!=="west"&&c.scale(d),h=Ga.fromArray(Bs[r]),r!=="east"&&r!=="west"&&h.scale(d)}else{let{up:d,east:f,north:g}=Yt;f.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,d),g.copy(d).cross(f);let{down:x,west:p,south:y}=Yt;x.copy(d).scale(-1),p.copy(f).scale(-1),y.copy(g).scale(-1),a=Yt[t],c=Yt[s],h=Yt[r]}return i[0]=a.x,i[1]=a.y,i[2]=a.z,i[3]=0,i[4]=c.x,i[5]=c.y,i[6]=c.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 At=new m,$a=new m,Ha=new m;function _n(e,t,s=[]){let{oneOverRadii:r,oneOverRadiiSquared:n,centerToleranceSquared:i}=t;At.from(e);let o=At.x,a=At.y,c=At.z,h=r.x,l=r.y,u=r.z,d=o*o*h*h,f=a*a*l*l,g=c*c*u*u,x=d+f+g,p=Math.sqrt(1/x);if(!Number.isFinite(p))return;let y=$a;if(y.copy(e).scale(p),x<i)return y.to(s);let E=n.x,_=n.y,T=n.z,S=Ha;S.set(y.x*E*2,y.y*_*2,y.z*T*2);let M=(1-p)*At.len()/(.5*S.len()),A=0,R,C,b,P;do{M-=A,R=1/(1+M*E),C=1/(1+M*_),b=1/(1+M*T);let q=R*R,z=C*C,O=b*b,X=q*R,gt=z*C,xt=O*b;P=d*q+f*z+g*O-1;let ne=-2*(d*X*E+f*gt*_+g*xt*T);A=P/ne}while(Math.abs(P)>ft.EPSILON12);return At.scale([R,C,b]).to(s)}var Me=new m,Mn=new m,Xa=new m,st=new m,Qa=new m,Se=new m,w=class{constructor(t=0,s=0,r=0){this.centerToleranceSquared=ft.EPSILON1,F(t>=0),F(s>=0),F(r>=0),this.radii=new m(t,s,r),this.radiiSquared=new m(t*t,s*s,r*r),this.radiiToTheFourth=new m(t*t*t*t,s*s*s*s,r*r*r*r),this.oneOverRadii=new m(t===0?0:1/t,s===0?0:1/s,r===0?0:1/r),this.oneOverRadiiSquared=new m(t===0?0:1/(t*t),s===0?0:1/(s*s),r===0?0:1/(r*r)),this.minimumRadius=Math.min(t,s,r),this.maximumRadius=Math.max(t,s,r),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||!!(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,s=[0,0,0]){let r=Mn,n=Xa,[,,i]=t;this.geodeticSurfaceNormalCartographic(t,r),n.copy(this.radiiSquared).scale(r);let o=Math.sqrt(r.dot(n));return n.scale(1/o),r.scale(i),n.add(r),n.to(s)}cartesianToCartographic(t,s=[0,0,0]){Se.from(t);let r=this.scaleToGeodeticSurface(Se,st);if(!r)return;let n=this.geodeticSurfaceNormal(r,Mn),i=Qa;i.copy(Se).subtract(r);let o=Math.atan2(n.y,n.x),a=Math.asin(n.z),c=Math.sign(Ct.dot(i,Se))*Ct.length(i);return xn([o,a,c],s)}eastNorthUpToFixedFrame(t,s=new v){return Vs(this,"east","north","up",t,s)}localFrameToFixedFrame(t,s,r,n,i=new v){return Vs(this,t,s,r,n,i)}geocentricSurfaceNormal(t,s=[0,0,0]){return Me.from(t).normalize().to(s)}geodeticSurfaceNormalCartographic(t,s=[0,0,0]){let r=gn(t),n=r[0],i=r[1],o=Math.cos(i);return Me.set(o*Math.cos(n),o*Math.sin(n),Math.sin(i)).normalize(),Me.to(s)}geodeticSurfaceNormal(t,s=[0,0,0]){return Me.from(t).scale(this.oneOverRadiiSquared).normalize().to(s)}scaleToGeodeticSurface(t,s){return _n(t,this,s)}scaleToGeocentricSurface(t,s=[0,0,0]){st.from(t);let r=st.x,n=st.y,i=st.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(r*r*o.x+n*n*o.y+i*i*o.z);return st.multiplyScalar(a).to(s)}transformPositionToScaledSpace(t,s=[0,0,0]){return st.from(t).scale(this.oneOverRadii).to(s)}transformPositionFromScaledSpace(t,s=[0,0,0]){return st.from(t).scale(this.radii).to(s)}getSurfaceNormalIntersectionWithZAxis(t,s=0,r=[0,0,0]){F(K(this.radii.x,this.radii.y,ft.EPSILON15)),F(this.radii.z>0),st.from(t);let n=st.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-s))return st.set(0,0,n).to(r)}};w.WGS84=new w(6378137,6378137,ct);function Gt(){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 _t=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=Gt(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Gt()-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 tt=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:r}=t,n=this.stats[s];return n||(t instanceof _t?n=t:n=new _t(s,r),this.stats[s]=n),n}};function rt(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var Ka="Queued Requests",Ja="Active Requests",tc="Cancelled Requests",ec="Queued Requests Ever",sc="Active Requests Ever",rc={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},ht=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...rc,...t},this.stats=new tt({id:this.props.id}),this.stats.get(Ka),this.stats.get(Ja),this.stats.get(tc),this.stats.get(ec),this.stats.get(sc)}setProps(t){t.throttleRequests!==void 0&&(this.props.throttleRequests=t.throttleRequests),t.maxRequests!==void 0&&(this.props.maxRequests=t.maxRequests),t.debounceTime!==void 0&&(this.props.debounceTime=t.debounceTime)}scheduleRequest(t,s=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let r={handle:t,priority:0,getPriority:s},n=new Promise(i=>(r.resolve=i,r));return this.requestQueue.push(r),this.requestMap.set(t,n),this._issueNewRequests(),n}_issueRequest(t){let{handle:s,resolve:r}=t,n=!1,i=()=>{n||(n=!0,this.requestMap.delete(s),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,r?r({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;s<t;++s){let r=this.requestQueue.shift();r&&this._issueRequest(r)}}}_updateAllRequests(){let t=this.requestQueue;for(let s=0;s<t.length;++s){let r=t[s];this._updateRequest(r)||(t.splice(s,1),this.requestMap.delete(r.handle),s--)}t.sort((s,r)=>s.priority-r.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var N={logicalRanges:"Logical Range Requests",rangeBatches:"Range Request Batches",transportRanges:"Transport Ranges Created",completedTransportRanges:"Range Transport Requests Completed",coalescedRanges:"Coalesced Logical Ranges",requestedBytes:"Logical Range Request Bytes",transportBytes:"Range Transport Bytes Requested",responseBytes:"Range Response Bytes",networkTimeMs:"Range Network Time",overfetchBytes:"Range Overfetch Bytes",failedTransportRanges:"Range Transport Requests Failed",abortedLogicalRanges:"Aborted Logical Range Requests",fullResponseFallbacks:"Full Response Fallbacks"},Fs={batchDelayMs:50,maxGapBytes:65536,rangeExpansionBytes:65536,maxMergedBytes:8388608,stats:bn("range-request-scheduler-default"),onEvent:()=>{}},Ee=class{props;stats;onEvent;pendingRequests=[];flushTimer=null;constructor(t={}){let s=t.rangeExpansionBytes??t.maxGapBytes??Fs.rangeExpansionBytes;this.props={batchDelayMs:t.batchDelayMs??Fs.batchDelayMs,maxGapBytes:t.maxGapBytes??s,rangeExpansionBytes:s,maxMergedBytes:t.maxMergedBytes??Fs.maxMergedBytes},this.stats=t.stats||bn("range-request-scheduler"),this.onEvent=t.onEvent,Rn(this.stats)}scheduleRequest(t){if(t.length<0)return Promise.reject(new Error("Byte range length cannot be negative"));if(t.signal?.aborted)return Promise.reject(En());if(t.length===0)return Promise.resolve(new ArrayBuffer(0));let s=new Promise((r,n)=>{let i={...t,resolve:r,reject:n,settled:!1};t.signal&&(i.abortListener=()=>{this.abortRequest(i),i.onAbort?.()},t.signal.addEventListener("abort",i.abortListener,{once:!0})),this.pendingRequests.push(i)});return this.trackEvent({type:"queued",sourceId:t.sourceId,offset:t.offset,length:t.length,logicalRequestCount:1,logicalBytes:t.length}),this.scheduleFlush(),s}fetch(t){let s=t.fetch||globalThis.fetch;return this.scheduleRequest({sourceId:t.sourceId||t.url,offset:t.offset,length:t.length,signal:t.signal,isolationKey:t.isolationKey??{},fetchRange:(r,n,i)=>ic({url:t.url,offset:r,length:n,signal:i,fetch:s,fetchOptions:t.fetchOptions})})}flush(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null);let t=this.pendingRequests;this.pendingRequests=[];let s=t.filter(n=>n.settled||n.signal?.aborted?(this.abortRequest(n),!1):!0),r=this.mergeRequests(s);s.length>0&&this.trackBatch(s,r);for(let n of r)this.fetchMergedRequest(n)}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>this.flush(),this.props.batchDelayMs))}mergeRequests(t){t.sort((r,n)=>r.sourceId!==n.sourceId?r.sourceId<n.sourceId?-1:1:r.offset-n.offset);let s=[];for(let r of t){let n=r.offset+r.length,i=s[s.length-1];i&&oc(i,r,this.props)?(i.endOffset=Math.max(i.endOffset,n),i.requests.push(r)):s.push({sourceId:r.sourceId,isolationKey:r.isolationKey??r.sourceId,offset:r.offset,endOffset:n,fetchRange:r.fetchRange,requests:[r]})}return s}async fetchMergedRequest(t){let{offset:s,endOffset:r,fetchRange:n,requests:i}=t,o=new AbortController,a=$t(),c=()=>{i.every(h=>h.signal?.aborted)&&o.abort()};try{for(let p of i)p.onAbort=c;if(c(),i.every(p=>p.settled))return;let h=Us(i),l=r-s;this.trackEvent({type:"request",sourceId:t.sourceId,offset:s,length:l,logicalRequestCount:i.length,logicalBytes:h,transportBytes:l,overfetchBytes:Math.max(l-h,0)});let u=ac(await n(s,l,o.signal)),{arrayBuffer:d}=u,f=u.fullResponse&&s===0&&d.byteLength<l,g=d.byteLength<l&&Number.isSafeInteger(u.sourceByteLength)&&s+d.byteLength===u.sourceByteLength;if(d.byteLength!==l&&!f&&!g)throw new Error(`Byte-range transport returned ${d.byteLength} bytes; expected ${l}`);let x=u.networkTimeMs??$t()-a;this.trackEvent({type:"response",sourceId:t.sourceId,offset:s,length:l,logicalRequestCount:i.length,logicalBytes:h,transportBytes:l,responseBytes:u.transportBytes??d.byteLength,networkTimeMs:x,overfetchBytes:Math.max(l-h,0),status:u.status,fullResponse:u.fullResponse});for(let p of i){if(p.settled)continue;let y=p.offset-s;p.settled=!0,p.resolve(d.slice(y,y+p.length))}}catch(h){this.trackEvent({type:"error",sourceId:t.sourceId,offset:s,length:r-s,logicalRequestCount:i.length,logicalBytes:Us(i),networkTimeMs:$t()-a,error:h});for(let l of i)l.settled||(l.signal?.aborted?this.abortRequest(l):(l.settled=!0,l.reject(h)))}finally{for(let h of i)h.abortListener&&h.signal?.removeEventListener("abort",h.abortListener),h.onAbort=void 0}}abortRequest(t){t.settled||(t.settled=!0,t.reject(En()),this.trackEvent({type:"abort",sourceId:t.sourceId,offset:t.offset,length:t.length,logicalRequestCount:1,logicalBytes:t.length}))}trackEvent(t){nc(this.stats,t);try{this.onEvent?.(t)}catch{}}trackBatch(t,s){let r=Us(t),n=s.reduce((i,o)=>i+o.endOffset-o.offset,0);this.trackEvent({type:"batch",logicalRequestCount:t.length,transportRequestCount:s.length,logicalBytes:r,transportBytes:n,overfetchBytes:Math.max(n-r,0)})}};function nc(e,t){switch((t.type==="response"||t.type==="error")&&t.networkTimeMs!==void 0&&e.get(N.networkTimeMs,"time").addTime(t.networkTimeMs),t.type){case"queued":e.get(N.logicalRanges,"count").incrementCount(),e.get(N.requestedBytes,"count").addCount(t.logicalBytes||0);break;case"batch":e.get(N.rangeBatches,"count").incrementCount(),e.get("Logical Ranges Batched","count").addCount(t.logicalRequestCount||0),e.get(N.transportRanges,"count").addCount(t.transportRequestCount||0),e.get(N.coalescedRanges,"count").addCount(Math.max((t.logicalRequestCount||0)-(t.transportRequestCount||0),0)),e.get(N.transportBytes,"count").addCount(t.transportBytes||0),e.get(N.overfetchBytes,"count").addCount(t.overfetchBytes||0);break;case"response":e.get(N.completedTransportRanges,"count").incrementCount(),e.get(N.responseBytes,"count").addCount(t.responseBytes||0),t.fullResponse&&e.get(N.fullResponseFallbacks,"count").incrementCount();break;case"error":e.get(N.failedTransportRanges,"count").incrementCount();break;case"abort":e.get(N.abortedLogicalRanges,"count").incrementCount();break;default:}}function bn(e="range-request-scheduler"){let t=new tt({id:e});return Rn(t),t}async function ic(e){let t=uc(e.signal),s=$t();try{let r=!1,n=await e.fetch(e.url,Sn(e.fetchOptions,e.offset,e.length,t.signal));if(n.status===416&&e.offset===0){let c=hc(n.headers.get("Content-Range"));if(!c)throw new Error("Missing content-length on 416 response");n=await e.fetch(e.url,Sn(e.fetchOptions,0,c,t.signal)),r=!0}if(n.status===200)throw t.abort(),await dc(n),new Error("Byte-range request failed: server returned 200 instead of 206");if(n.status!==206&&!n.ok)throw new Error(`Bad response code: ${n.status}`);let i=await n.arrayBuffer(),o=n.headers.get("Content-Range"),a=lc(o);if(o&&!a)throw new Error(`Invalid Content-Range header: ${o}`);if(a){let c=a.endOffset-a.offset+1,h=e.offset+e.length-1;if(a.offset!==e.offset||a.endOffset>h||c!==i.byteLength||a.sourceByteLength!==void 0&&a.endOffset>=a.sourceByteLength)throw new Error(`Content-Range does not match requested range: ${o}`)}return{arrayBuffer:i,status:n.status,sourceByteLength:a?.sourceByteLength,transportBytes:i.byteLength,networkTimeMs:$t()-s,fullResponse:r}}finally{t.removeAbortListener()}}function oc(e,t,s){if(e.sourceId!==t.sourceId||e.isolationKey!==(t.isolationKey??t.sourceId))return!1;let r=t.offset+t.length,n=t.offset-e.endOffset,i=Math.max(e.endOffset,r)-e.offset;return n<=s.rangeExpansionBytes&&i<=s.maxMergedBytes}function Rn(e){e.get(N.logicalRanges,"count"),e.get(N.requestedBytes,"count"),e.get(N.rangeBatches,"count"),e.get("Logical Ranges Batched","count"),e.get(N.transportRanges,"count"),e.get(N.coalescedRanges,"count"),e.get(N.transportBytes,"count"),e.get(N.completedTransportRanges,"count"),e.get(N.responseBytes,"count"),e.get(N.networkTimeMs,"time"),e.get(N.overfetchBytes,"count"),e.get(N.fullResponseFallbacks,"count"),e.get(N.failedTransportRanges,"count"),e.get(N.abortedLogicalRanges,"count")}function Us(e){return e.reduce((t,s)=>t+s.length,0)}function ac(e){return e instanceof ArrayBuffer?{arrayBuffer:e}:e}function Sn(e,t,s,r){return{...e,signal:r,headers:{...cc(e?.headers),Range:`bytes=${t}-${t+s-1}`}}}function cc(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):e:{}}function hc(e){let t=e?.match(/^bytes \*\/(\d+)$/);return t?Number(t[1]):null}function lc(e){let t=e?.match(/^bytes (\d+)-(\d+)\/(\d+|\*)$/);if(!t)return null;let s=Number(t[1]),r=Number(t[2]),n=t[3]==="*"?void 0:Number(t[3]);return!Number.isSafeInteger(s)||!Number.isSafeInteger(r)||s>r||n!==void 0&&!Number.isSafeInteger(n)?null:{offset:s,endOffset:r,sourceByteLength:n}}function uc(e){let t=new AbortController,s=()=>t.abort();return e?.aborted?t.abort():e?.addEventListener("abort",s,{once:!0}),{signal:t.signal,abort:()=>t.abort(),removeAbortListener:()=>e?.removeEventListener("abort",s)}}async function dc(e){await e.body?.cancel().catch(()=>{})}function $t(){return globalThis.performance?.now()??Date.now()}function En(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}var J={};zt(J,{dirname:()=>mc,filename:()=>fc,join:()=>pc,resolve:()=>gc});function wn(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function fc(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function mc(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function pc(...e){return e=e.map((s,r)=>(r&&(s=s.replace(new RegExp("^/"),"")),r!==e.length-1&&(s=s.replace(new RegExp("/$"),"")),s)),e.join("/")}function gc(...e){let t=[];for(let i=0;i<e.length;i++)t[i]=e[i];let s="",r=!1,n;for(let i=t.length-1;i>=-1&&!r;i--){let o;i>=0?o=t[i]:(n===void 0&&(n=wn()),o=n),o.length!==0&&(s=`${o}/${s}`,r=o.charCodeAt(0)===Ht)}return s=xc(s,!r),r?`/${s}`:s.length>0?s:"."}var Ht=47,ks=46;function xc(e,t){let s="",r=-1,n=0,i,o=!1;for(let a=0;a<=e.length;++a){if(a<e.length)i=e.charCodeAt(a);else{if(i===Ht)break;i=Ht}if(i===Ht){if(!(r===a-1||n===1))if(r!==a-1&&n===2){if(s.length<2||!o||s.charCodeAt(s.length-1)!==ks||s.charCodeAt(s.length-2)!==ks){if(s.length>2){let c=s.length-1,h=c;for(;h>=0&&s.charCodeAt(h)!==Ht;--h);if(h!==c){s=h===-1?"":s.slice(0,h),r=a,n=0,o=!1;continue}}else if(s.length===2||s.length===1){s="",r=a,n=0,o=!1;continue}}t&&(s.length>0?s+="/..":s="..",o=!0)}else{let c=e.slice(r+1,a);s.length>0?s+=`/${c}`:s=c,o=!1}r=a,n=0}else i===ks&&n!==-1?++n:n=-1}return s}var vt=class{handle;size;bigsize;url;constructor(t){this.handle=t instanceof ArrayBuffer?new Blob([t]):t,this.size=t instanceof ArrayBuffer?t.byteLength:t.size,this.bigsize=BigInt(this.size),this.url=t instanceof File?t.name:""}async close(){}async stat(){return{size:this.handle.size,bigsize:BigInt(this.handle.size),isDirectory:!1}}async read(t,s,r){if(r?.aborted)throw new Error("Request aborted");let n=await this.handle.slice(Number(t),Number(t)+Number(s)).arrayBuffer();if(r?.aborted)throw new Error("Request aborted");return n}};var we=class{url;fetchFunction;fetchOptions;consistency;identityHints;countedFailures=new WeakSet;telemetry={requestedBytes:0,downloadedBytes:0,requestCount:0,networkTimeMs:0,abortCount:0,errorCount:0};constructor(t,s){Ec(s.byteLength),this.url=t,this.fetchFunction=s.fetch||((r,n)=>globalThis.fetch(r,n)),this.fetchOptions=s.fetchOptions?{...s.fetchOptions,headers:new Headers(s.fetchOptions.headers)}:void 0,this.consistency=s.consistency||"best-effort",this.identityHints={byteLength:s.byteLength,etag:Oe(s.etag),lastModified:Oe(s.lastModified)}}getInitialIdentity(){let{byteLength:t,etag:s,lastModified:r}=this.identityHints;return t!==void 0&&(s!==void 0||r!==void 0)?Ce(t,s,r):t===0&&this.consistency==="best-effort"?Ce(0):null}getTelemetry(){return Object.freeze({...this.telemetry})}trackFailure(t){if(typeof t=="object"&&t!==null){if(this.countedFailures.has(t))return;this.countedFailures.add(t)}vn(t)?this.telemetry.abortCount++:this.telemetry.errorCount++}async requestRange(t,s,r,n){let i=be(),o=bc(r,this.fetchOptions?.signal);this.telemetry.requestCount++,this.telemetry.requestedBytes+=s;try{let a=await this.fetchFunction(this.url,yc(this.fetchOptions,t,s,o.signal));if(Tc(a,t,s,n))return await this.readEmptyIdentityProbe(a,i);if(a.status!==206)throw await Re(a),new Error(`HTTP byte-range request expected 206, received ${a.status}`);let c=await _c(a),h=Cn(a,c.byteLength),l=An(n,h,this.identityHints,this.consistency)||Sc(c,t,s);if(l)throw await Re(a),new Error(l);let u=await a.arrayBuffer();if(this.telemetry.downloadedBytes+=u.byteLength,u.byteLength!==s)throw new Error(`HTTP byte-range response contained ${u.byteLength} bytes; expected ${s}`);return{arrayBuffer:u,identity:On(n,h,this.identityHints),status:a.status,transportBytes:u.byteLength,networkTimeMs:be()-i}}catch(a){throw(n===null||!vn(a))&&this.trackFailure(a),a}finally{o.removeAbortListeners(),this.telemetry.networkTimeMs+=be()-i}}async readEmptyIdentityProbe(t,s){let r=Cn(t,0),n=An(null,r,this.identityHints,this.consistency);if(await Re(t),n)throw new Error(n);return{arrayBuffer:new ArrayBuffer(0),identity:On(null,r,this.identityHints),status:t.status,transportBytes:0,networkTimeMs:be()-s}}};function yc(e,t,s,r){let n=new Headers(e?.headers);return n.set("Range",`bytes=${t}-${t+s-1}`),{...e,method:"GET",body:void 0,headers:n,signal:r}}function Tc(e,t,s,r){return e.status===416&&r===null&&t===0&&s===1&&/^bytes \*\/0$/i.test(e.headers.get("Content-Range")||"")}async function _c(e){try{return Mc(e.headers.get("Content-Range"))}catch(t){throw await Re(e),t}}function Mc(e){let t=e?.match(/^bytes (\d+)-(\d+)\/(\d+)$/);if(!t)throw new Error("HTTP byte-range response has an invalid Content-Range header");return{offset:Number(t[1]),endOffset:Number(t[2]),byteLength:Number(t[3])}}function Cn(e,t){return Ce(t,Oe(e.headers.get("ETag")),Oe(e.headers.get("Last-Modified")))}function On(e,t,s){return e||Ce(t.byteLength,t.etag??s.etag,t.lastModified??s.lastModified)}function Sc(e,t,s){return!Number.isSafeInteger(e.offset)||!Number.isSafeInteger(e.endOffset)||!Number.isSafeInteger(e.byteLength)||e.offset<0||e.endOffset<e.offset||e.endOffset>=e.byteLength?"HTTP byte-range response has invalid range bounds":e.offset!==t||e.endOffset!==t+s-1?"HTTP byte-range response does not match the requested range":null}function An(e,t,s,r){let n=e?.byteLength??s.byteLength;if(n!==void 0&&t.byteLength!==n)return"HTTP file length changed while the file was open";let i=e?.etag??s.etag,o=e?.lastModified??s.lastModified;return i?t.etag?i===t.etag?null:"HTTP file ETag changed while the file was open":r==="strict"?"HTTP byte-range response is missing the pinned ETag":o&&t.lastModified&&o!==t.lastModified?"HTTP file Last-Modified value changed while the file was open":null:o?t.lastModified&&o!==t.lastModified?"HTTP file Last-Modified value changed while the file was open":r==="strict"&&!t.lastModified?"HTTP byte-range response is missing the pinned Last-Modified value":null:r==="strict"&&!t.etag&&!t.lastModified?"HTTP byte-range response does not provide an ETag or Last-Modified validator":null}function Ce(e,t,s){return Object.freeze({byteLength:e,etag:t,lastModified:s})}function Ec(e){if(e!==void 0&&(!Number.isSafeInteger(e)||e<0))throw new Error("HttpFile byteLength must be a non-negative safe integer")}async function Re(e){await e.body?.cancel().catch(()=>{})}function Oe(e){return e||void 0}function be(){return globalThis.performance?.now()??Date.now()}function vn(e){return e instanceof Error&&e.name==="AbortError"||e instanceof Error&&/aborted/i.test(e.message)}function bc(...e){let t=new AbortController,s=[...new Set(e.filter(n=>!!n))],r=()=>t.abort();for(let n of s)n.aborted?t.abort():n.addEventListener("abort",r,{once:!0});return{signal:t.signal,removeAbortListeners:()=>{for(let n of s)n.removeEventListener("abort",r)}}}var Zt=class e{handle;url;transport;rangeScheduler;schedulerIsolationKey={};suppliedByteLength;identity;openPromise=null;closed=!1;constructor(t,s={}){this.handle=t,this.url=t,this.transport=new we(t,s),this.rangeScheduler=s.rangeScheduler||new Ee({batchDelayMs:0,...s.rangeSchedulerProps}),this.suppliedByteLength=s.byteLength,this.identity=this.transport.getInitialIdentity()}static async open(t,s={},r){let n=new e(t,s);return await n.open(r),n}async open(t){if(this.assertOpen(),t?.aborted){let s=Ae();throw this.transport.trackFailure(s),s}return await this.getIdentity(t),this}get size(){return this.identity?.byteLength??this.suppliedByteLength??0}get bigsize(){return BigInt(this.size)}getIdentitySnapshot(){return this.identity}getTelemetry(){return this.transport.getTelemetry()}async close(){this.closed=!0}async stat(){this.assertOpen();let t=await this.getIdentity();return{size:t.byteLength,bigsize:BigInt(t.byteLength),isDirectory:!1}}async read(t=0,s=0,r){if(this.assertOpen(),r?.aborted){let o=Ae();throw this.transport.trackFailure(o),o}let n=await this.getIdentity(r),i=In(t);if(wc(i,s,n.byteLength),s===0)return new ArrayBuffer(0);try{return await this.rangeScheduler.scheduleRequest({sourceId:this.url,isolationKey:this.schedulerIsolationKey,offset:i,length:s,signal:r,fetchRange:this.fetchScheduledRange})}catch(o){throw this.transport.trackFailure(o),o}}async fetchRange(t,s,r){let n=In(t),i=await this.read(n,s,r),o=Rc(this.identity,n,s);return new Response(i,{status:206,headers:o})}fetchScheduledRange=async(t,s,r)=>{let n=await this.getIdentity(r),i=await this.transport.requestRange(t,s,r,n);return{arrayBuffer:i.arrayBuffer,status:i.status,transportBytes:i.transportBytes,networkTimeMs:i.networkTimeMs}};getIdentity(t){if(this.identity)return Promise.resolve(this.identity);if(!this.openPromise){let r=this.probeIdentity().catch(n=>{throw this.openPromise===r&&(this.openPromise=null),n});this.openPromise=r}return Cc(this.openPromise,t).catch(s=>{throw this.transport.trackFailure(s),s})}async probeIdentity(){try{let t=await this.transport.requestRange(0,1,void 0,null);return this.identity=t.identity,t.identity}catch(t){throw this.transport.trackFailure(t),t}}assertOpen(){if(this.closed)throw new Error("HttpFile is closed")}};function Rc(e,t,s){let r=new Headers;return s>0&&e&&r.set("Content-Range",`bytes ${t}-${t+s-1}/${e.byteLength}`),e?.etag&&r.set("ETag",e.etag),e?.lastModified&&r.set("Last-Modified",e.lastModified),r}function In(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<0)throw new Error("HTTP byte-range offset must be a non-negative safe integer");return t}function wc(e,t,s){if(!Number.isSafeInteger(t)||t<0)throw new Error("HTTP byte-range length must be a non-negative safe integer");if(e+t>s)throw new Error("HTTP byte range extends beyond the end of the file")}function Ae(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}function Cc(e,t){return t?t.aborted?Promise.reject(Ae()):new Promise((s,r)=>{let n=()=>{t.removeEventListener("abort",n),r(Ae())};t.addEventListener("abort",n,{once:!0}),e.then(i=>{t.removeEventListener("abort",n),s(i)},i=>{t.removeEventListener("abort",n),r(i)})}):e}var ve=class{item;previous;next;constructor(t,s,r){this.item=t,this.previous=s,this.next=r}};var Ie=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let s=new ve(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 r=t.next;t.next=s,this.tail===t?this.tail=s:r.previous=s,s.next=r,s.previous=t,++this._length}};var It=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Ie,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,r){s._cacheNode||(s._cacheNode=this._list.add(s),r&&r(t,s))}unloadTile(t,s,r){let n=s._cacheNode;n&&(this._list.remove(n),s._cacheNode=null,r&&r(t,s))}unloadTiles(t,s){let r=this._trimTiles;this._trimTiles=!1;let n=this._list,i=this._sentinel,o=n.head;for(;o!==i&&(t.gpuMemoryUsageInBytes>t.cacheBytes||r);){let a=o.item;o=o.next,this.unloadTile(t,a,s)}}trim(){this._trimTiles=!0}};function Le(e,t){rt(e),rt(t);let{rtcCenter:s,gltfUpAxis:r}=t,{computedTransform:n,boundingVolume:{center:i}}=e,o=new v(n);switch(s&&o.translate(s),r){case"Z":break;case"Y":let d=new v().rotateX(Math.PI/2);o=o.multiplyRight(d);break;case"X":let f=new v().rotateY(-Math.PI/2);o=o.multiplyRight(f);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new m(i);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let c=w.WGS84.cartesianToCartographic(a,new m),l=w.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=l.multiplyRight(o),t.cartographicOrigin=c;let u=Ac(t);u&&(t.cartesianModelMatrix=new v(o).multiplyRight(u.matrix),t.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=v.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Oc=1e6**2;function Ac(e){let t=e.gltf;if(!t)return null;let s=typeof t.scene=="number"?t.scene:0,n=t.scenes?.[s]?.nodes?.[0];if(!n?.matrix)return null;let i=n.matrix;return i[12]*i[12]+i[13]*i[13]+i[14]*i[14]<=Oc?null:n}var U={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var ad=new m,cd=new m;var jt=new m,Ln=new m,Z=class e{constructor(t=[0,0,0],s=0){this.radius=-0,this.center=new m,this.fromCenterRadius(t,s)}fromCenterRadius(t,s){return this.center.from(t),this.radius=s,this}fromCornerPoints(t,s){return s=jt.from(s),this.center=new m().from(t).add(s).scale(.5),this.radius=this.center.distance(s),this}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new e(this.center,this.radius)}union(t){let s=this.center,r=this.radius,n=t.center,i=t.radius,o=jt.copy(n).subtract(s),a=o.magnitude();if(r>=a+i)return this.clone();if(i>=a+r)return t.clone();let c=(r+a+i)*.5;return Ln.copy(o).scale((-r+c)/a).add(s),this.center.copy(Ln),this.radius=c,this}expand(t){let r=jt.from(t).subtract(this.center).magnitude();return r>this.radius&&(this.radius=r),this}transform(t){this.center.transform(t);let s=xe.getScaling(jt,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 r=jt.from(t).subtract(this.center);return Math.max(0,r.len()-this.radius)}intersectPlane(t){let s=this.center,r=this.radius,i=t.normal.dot(s)+t.distance;return i<-r?U.OUTSIDE:i<r?U.INTERSECTING:U.INSIDE}};var vc=new m,Ic=new m,Pe=new m,Ne=new m,qe=new m,Lc=new m,Pc=new m,lt={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},mt=class e{constructor(t=[0,0,0],s=[0,0,0,0,0,0,0,0,0]){this.center=new m().from(t),this.halfAxes=new V(s)}get halfSize(){let t=this.halfAxes.getColumn(0),s=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new m(t).len(),new m(s).len(),new m(r).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),s=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),n=new m(t).normalize(),i=new m(s).normalize(),o=new m(r).normalize();return new it().fromMatrix3(new V([...n,...i,...o]))}fromCenterHalfSizeQuaternion(t,s,r){let n=new it(r),i=new V().fromQuaternion(n);return i[0]=i[0]*s[0],i[1]=i[1]*s[0],i[2]=i[2]*s[0],i[3]=i[3]*s[1],i[4]=i[4]*s[1],i[5]=i[5]*s[1],i[6]=i[6]*s[2],i[7]=i[7]*s[2],i[8]=i[8]*s[2],this.center=new m().from(t),this.halfAxes=i,this}clone(){return new e(this.center,this.halfAxes)}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new Z){let s=this.halfAxes,r=s.getColumn(0,Pe),n=s.getColumn(1,Ne),i=s.getColumn(2,qe),o=vc.copy(r).add(n).add(i);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let s=this.center,r=t.normal,n=this.halfAxes,i=r.x,o=r.y,a=r.z,c=Math.abs(i*n[lt.COLUMN0ROW0]+o*n[lt.COLUMN0ROW1]+a*n[lt.COLUMN0ROW2])+Math.abs(i*n[lt.COLUMN1ROW0]+o*n[lt.COLUMN1ROW1]+a*n[lt.COLUMN1ROW2])+Math.abs(i*n[lt.COLUMN2ROW0]+o*n[lt.COLUMN2ROW1]+a*n[lt.COLUMN2ROW2]),h=r.dot(s)+t.distance;return h<=-c?U.OUTSIDE:h>=c?U.INSIDE:U.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let s=Ic.from(t).subtract(this.center),r=this.halfAxes,n=r.getColumn(0,Pe),i=r.getColumn(1,Ne),o=r.getColumn(2,qe),a=n.magnitude(),c=i.magnitude(),h=o.magnitude();n.normalize(),i.normalize(),o.normalize();let l=0,u;return u=Math.abs(s.dot(n))-a,u>0&&(l+=u*u),u=Math.abs(s.dot(i))-c,u>0&&(l+=u*u),u=Math.abs(s.dot(o))-h,u>0&&(l+=u*u),l}computePlaneDistances(t,s,r=[-0,-0]){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,c=a.getColumn(0,Pe),h=a.getColumn(1,Ne),l=a.getColumn(2,qe),u=Lc.copy(c).add(h).add(l).add(o),d=Pc.copy(u).subtract(t),f=s.dot(d);return n=Math.min(f,n),i=Math.max(f,i),u.copy(o).add(c).add(h).subtract(l),d.copy(u).subtract(t),f=s.dot(d),n=Math.min(f,n),i=Math.max(f,i),u.copy(o).add(c).subtract(h).add(l),d.copy(u).subtract(t),f=s.dot(d),n=Math.min(f,n),i=Math.max(f,i),u.copy(o).add(c).subtract(h).subtract(l),d.copy(u).subtract(t),f=s.dot(d),n=Math.min(f,n),i=Math.max(f,i),o.copy(u).subtract(c).add(h).add(l),d.copy(u).subtract(t),f=s.dot(d),n=Math.min(f,n),i=Math.max(f,i),o.copy(u).subtract(c).add(h).subtract(l),d.copy(u).subtract(t),f=s.dot(d),n=Math.min(f,n),i=Math.max(f,i),o.copy(u).subtract(c).subtract(h).add(l),d.copy(u).subtract(t),f=s.dot(d),n=Math.min(f,n),i=Math.max(f,i),o.copy(u).subtract(c).subtract(h).subtract(l),d.copy(u).subtract(t),f=s.dot(d),n=Math.min(f,n),i=Math.max(f,i),r[0]=n,r[1]=i,r}transform(t){this.center.transformAsPoint(t);let s=this.halfAxes.getColumn(0,Pe);s.transformAsPoint(t);let r=this.halfAxes.getColumn(1,Ne);r.transformAsPoint(t);let n=this.halfAxes.getColumn(2,qe);return n.transformAsPoint(t),this.halfAxes=new V([...s,...r,...n]),this}getTransform(){throw new Error("not implemented")}};var Pn=new m,Nn=new m,W=class e{constructor(t=[0,0,1],s=0){this.normal=new m,this.distance=-0,this.fromNormalDistance(t,s)}fromNormalDistance(t,s){return F(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 r=-this.normal.dot(t);return this.distance=r,this}fromCoefficients(t,s,r,n){return this.normal.set(t,s,r),F(K(this.normal.len(),1)),this.distance=n,this}clone(){return new e(this.normal,this.distance)}equals(t){return K(this.distance,t.distance)&&K(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let s=Nn.copy(this.normal).transformAsVector(t).normalize(),r=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(r,s)}projectPointOntoPlane(t,s=[0,0,0]){let r=Pn.from(t),n=this.getPointDistance(r),i=Nn.copy(this.normal).scale(n);return r.subtract(i).to(s)}};var qn=[new m([1,0,0]),new m([0,1,0]),new m([0,0,1])],zn=new m,Nc=new m,k=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*qn.length;let s=t.center,r=t.radius,n=0;for(let i of qn){let o=this.planes[n],a=this.planes[n+1];o||(o=this.planes[n]=new W),a||(a=this.planes[n+1]=new W);let c=zn.copy(i).scale(-r).add(s);o.fromPointNormal(c,i);let h=zn.copy(i).scale(r).add(s),l=Nc.copy(i).negate();a.fromPointNormal(h,l),n+=2}return this}computeVisibility(t){let s=U.INSIDE;for(let r of this.planes)switch(t.intersectPlane(r)){case U.OUTSIDE:return U.OUTSIDE;case U.INTERSECTING:s=U.INTERSECTING;break;default:}return s}computeVisibilityWithPlaneMask(t,s){if(F(Number.isFinite(s),"parentPlaneMask is required."),s===e.MASK_OUTSIDE||s===e.MASK_INSIDE)return s;let r=e.MASK_INSIDE,n=this.planes;for(let i=0;i<this.planes.length;++i){let o=i<31?1<<i:0;if(i<31&&(s&o)===0)continue;let a=n[i],c=t.intersectPlane(a);if(c===U.OUTSIDE)return e.MASK_OUTSIDE;c===U.INTERSECTING&&(r|=o)}return r}};k.MASK_OUTSIDE=4294967295;k.MASK_INSIDE=0;k.MASK_INDETERMINATE=2147483647;var wd=new m,Cd=new m,Od=new m,Ad=new m,vd=new m;var zd=new m,Dd=new m,Bd=new m,Vd=new m,Fd=new m,Ud=new m,kd=new m,Wd=new m,Yd=new m,Gd=new m,$d=new m,Hd=new m;var Xd=new V,Qd=new V,Kd=new V,Jd=new V,tf=new V;var af=new m,cf=new m,hf=new m,lf=new m,uf=new m,df=new V,ff={diagonal:new V,unitary:new V};var Dn=new m,Ws=new m,Bc=1e-5,Vc=1e-7,Ys=new k([new W,new W,new W,new W,new W,new W]);function ze(e,t,s={}){let{cameraUp:r,height:n}=e,i=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=Xt(e,e.center),c=w.WGS84.eastNorthUpToFixedFrame(a),h=e.unprojectPosition(e.cameraPosition),l=w.WGS84.cartographicToCartesian(h,new m),u;if(i)u=new m(c.transformAsVector(new m(i).scale(o))).normalize();else{let T=e.getFrustumPlanes().near,S=Gs(T,e.cameraPosition),M=Xt(e,S);u=new m(M).subtract(l).normalize()}let d=new m(c.transformAsVector(new m(r).scale(o))).normalize();Fc(e);let f=e.constructor,{longitude:g,latitude:x,width:p,bearing:y,zoom:E}=e,_=new f({longitude:g,latitude:x,height:n,width:p,bearing:y,zoom:E,pitch:0});return{camera:{position:l,direction:u,up:d,cartographicPosition:h,verticalFieldOfView:Number.isFinite(e.fovy)&&Number(e.fovy)>0?Number(e.fovy)*Math.PI/180:Math.PI/3,timeSinceMovement:s.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:e,topDownViewport:_,height:n,cullingVolume:Ys,frameNumber:t,sseDenominator:1.15,dynamicScreenSpaceErrorDensity:0}}function Bn(e,t,s,r){let n=Array.from(t),i=Array.from(s),o=e?n.length!==e.position.length||n.some((h,l)=>Math.abs(h-e.position[l])>Bc):!1,a=e?i.length!==e.direction.length||i.some((h,l)=>Math.abs(h-e.direction[l])>Vc):!1,c=o||a?r:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:n,direction:i,lastMovementTime:c},timeSinceMovement:Math.max((r-c)/1e3,0)}}function Vn(e,t,s){if(s===0||e.length<=s)return[e,[]];let r=[],{longitude:n,latitude:i}=t.viewport;for(let[h,l]of e.entries()){let[u,d]=l.header.mbs,f=Math.abs(n-u),g=Math.abs(i-d),x=Math.sqrt(g*g+f*f);r.push([h,x])}let o=r.sort((h,l)=>h[1]-l[1]),a=[];for(let h=0;h<s;h++)a.push(e[o[h][0]]);let c=[];for(let h=s;h<o.length;h++)c.push(e[o[h][0]]);return[a,c]}function Fc(e){let t=e.getFrustumPlanes(),s=Gs(t.near,e.cameraPosition),r=Xt(e,s),n=Xt(e,e.cameraPosition,Ws),i=0;Ys.planes[i++].fromPointNormal(r,Dn.copy(r).subtract(n));for(let o in t){if(o==="near")continue;let a=t[o],c=Gs(a,s,Ws),h=Xt(e,c,Ws);Ys.planes[i++].fromPointNormal(h,Dn.copy(r).subtract(h))}}function Gs(e,t,s=new m){let r=e.normal.dot(t);return s.copy(e.normal).scale(e.distance-r).add(t),s}function Xt(e,t,s=new m){let r=e.unprojectPosition(t);return w.WGS84.cartographicToCartesian(r,s)}var Yn=new m,Uc=new m,Mt=new m,Fn=new m,Qt=new m,Un=new m,kn=new m,Wn=new m,De=new it,kc=new m(0,0,1);function Gn(e,t){e._updateTransform(t)}function $n(e,t,s){if(!Number.isFinite(s.dynamicScreenSpaceErrorDensity)||s.dynamicScreenSpaceErrorDensity<=0)return 0;let r=$c(e),n=r.region?Hc(r.region,t):Zc(e,r,t);if(!n)return 0;let i=Dt(s.dynamicScreenSpaceErrorHeightFalloff,0,1),o=n.minimumHeight+(n.maximumHeight-n.minimumHeight)*i,a=n.maximumHeight-o,c=a>0?Dt((n.cameraHeight-o)/a,0,1):n.cameraHeight>=n.maximumHeight?1:0,l=(1-Dt(Math.abs(n.cameraDirection.dot(n.upDirection)),0,1))*(1-c);return s.dynamicScreenSpaceErrorDensity*l}function Wc(e,t){let s=e*t;return 1-Math.exp(-(s*s))}function Yc(e,t,s){return t<=0||s<=0||!Number.isFinite(t)||!Number.isFinite(s)?0:Wc(e,t)*s}function Hn(e,t,s,r=1){let n=e.tileset,i=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=s?i:e.lodMetricValue;if(o===0)return 0;let{viewDistanceScale:a}=n.options,c=a||1,h=Number.isFinite(r)?Math.max(r,0):1,l=Gc(o,t,c,h);if(l!==null)return l;let u=Math.max(e._distanceToCamera,1e-7),{height:d,sseDenominator:f}=t,g=o*d*h*c/(u*f);return n.options.dynamicScreenSpaceError&&!t.viewport.orthographic&&(g-=Yc(u,t.dynamicScreenSpaceErrorDensity,n.options.dynamicScreenSpaceErrorFactor)),g}function Gc(e,t,s,r){let n=t.viewport;if(!n?.orthographic)return null;let i=n.metersPerPixel;return!Number.isFinite(i)||!i||i<=0?null:e*s*r/i}function $c(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function Hc(e,t){let s=Yn.copy(t.camera.position).normalize(),r=Qt.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:r,upDirection:s}}function Zc(e,t,s){let r=jc(t,Mt);if(r===null)return null;let n=new v(e.computedTransform).invert(),i=e.tileset.ellipsoid;if(Math.hypot(Mt[0],Mt[1],Mt[2])>i.minimumRadius){let a=i.cartesianToCartographic(Mt,Uc),c=Yn.copy(s.camera.position).normalize(),h=Qt.copy(s.camera.direction).normalize();return{cameraHeight:s.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:h,upDirection:c}}return n.transformAsPoint(s.camera.position,Fn),n.transformAsVector(s.camera.direction,Qt),Qt.normalize(),{cameraHeight:Fn[2],minimumHeight:Mt[2]-r,maximumHeight:Mt[2]+r,cameraDirection:Qt,upDirection:kc}}function jc(e,t){if(e.box){let s=e.box;return t.set(s[0],s[1],s[2]),Xc(s)}if(e.sphere){let s=e.sphere;return t.set(s[0],s[1],s[2]),s[3]}return null}function Xc(e){return e.length===10?(De.fromArray(e,6),Un.set(e[3],0,0).transformByQuaternion(De),kn.set(0,e[4],0).transformByQuaternion(De),Wn.set(0,0,e[5]).transformByQuaternion(De),Math.abs(Un[2])+Math.abs(kn[2])+Math.abs(Wn[2])):Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11])}var G={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},Y;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(Y||(Y={}));var ot;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(ot||(ot={}));var j;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(j||(j={}));var Lt;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Lt||(Lt={}));var Zn={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};var jn=1e4,Qc=1e4,Kc=1e8,Jc=new Z,Xn=new m,Qn=new m,$s=new m,Be=new m;function Hs(e,t,s){return e+(t-e)*s}function Kn(e,t){let s=e instanceof Z?e:e.getBoundingSphere(Jc),{center:r,radius:n}=s;Xn.copy(r).subtract(t.position);let i=Math.max(Xn.dot(t.direction),0);return Qn.copy(t.direction).scale(i).add(t.position),$s.copy(Qn).subtract(r),$s.magnitude()<=n||(Be.copy($s).normalize().scale(n).add(r).subtract(t.position),Be.magnitude()===0)?0:(Be.normalize(),Math.min(Math.max(1-Be.dot(t.direction),0),1))}function Jn(e,t,s,r){return!Number.isFinite(r)||r<=0||r>.5?!1:e>s?!0:t!==void 0&&t>s}function ti(e){let t=Number.isFinite(e.foveatedConeSize)?Math.min(Math.max(e.foveatedConeSize,0),1):1,s=e.refinement===Y.REPLACE;if(s&&!e.skipLevelOfDetail||!e.foveatedScreenSpaceError||t>=1||s&&e.skipLevelOfDetail&&e.priorityProgressiveResolution)return!1;let r=Number.isFinite(e.verticalFieldOfView)&&e.verticalFieldOfView>0?e.verticalFieldOfView:Math.PI/3,n=1-Math.cos(r*.5),i=t*n;if(e.foveatedFactor<=i||n<=i)return!1;let o=Math.min(Math.max((e.foveatedFactor-i)/(n-i),0),1),c=(typeof e.interpolationCallback=="function"?e.interpolationCallback:Hs)(e.minimumScreenSpaceErrorRelaxation,e.maximumScreenSpaceError,o),h=Number.isFinite(c)?Math.min(Math.max(c,0),e.maximumScreenSpaceError):0,l=e.screenSpaceError===0&&e.parentScreenSpaceError!==void 0?e.parentScreenSpaceError*.5:e.screenSpaceError;return e.maximumScreenSpaceError-h<=l}function ei(e,t,s){return e&&Number.isFinite(t)&&Number.isFinite(s)&&s>0&&t<s}function si(e){let t=e.rootScreenSpaceError>0?Math.min(Math.max(e.reverseScreenSpaceError/e.rootScreenSpaceError,0),1):0,s=Math.floor(t*(jn-1)),r=Number.isFinite(e.foveatedFactor)?Math.min(Math.max(e.foveatedFactor,0),1):0,n=Math.floor(r*(jn-1))*Qc;return(e.priorityProgressiveResolution?0:Kc)+n+s}function Ve(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var $=1024*1024,Js=512*$,tr=512*$,th=32*$,eh=$;function Kt(e,t){if(!Number.isFinite(e)||e<0)throw new Error(`${t} must be a finite number greater than or equal to 0`);return e}function ri(e,t){let s=e.cacheBytes??(e.maximumMemoryUsage!==void 0?e.maximumMemoryUsage*$:t);return Kt(s,"cacheBytes")}function ni(e,t){let s=e.maximumCacheOverflowBytes??(e.memoryCacheOverflow!==void 0?e.memoryCacheOverflow*$:t);return Kt(s,"maximumCacheOverflowBytes")}var Zs={description:"",ellipsoid:w.WGS84,modelMatrix:new v,throttleRequests:!0,maxRequests:64,cacheBytes:Js,maximumCacheOverflowBytes:tr,maximumMemoryUsage:Js/$,memoryCacheOverflow:tr/$,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onSourceError:()=>{},onTilesetError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,progressiveResolutionHeightFraction:.3,foveatedScreenSpaceError:!0,foveatedConeSize:.1,foveatedMinimumScreenSpaceErrorRelaxation:0,foveatedInterpolationCallback:Hs,foveatedTimeDelay:.2,maximumScreenSpaceError:8,dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:2e-4,dynamicScreenSpaceErrorFactor:24,dynamicScreenSpaceErrorHeightFalloff:.25,memoryAdjustedScreenSpaceError:!0,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},js="Tiles In Tileset(s)",Xs="Tiles In Memory",ii="Tiles In View",oi="Tiles To Render",ai="Tiles Loaded",Qs="Tiles Loading",ci="Tiles Unloaded",hi="Failed Tile Loads",li="Points/Vertices",Ks="Tile Memory Use",ui="Maximum Screen Space Error",Fe=class{options;loadOptions;source;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=Js;_maximumCacheOverflowBytes=tr;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new It;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(t,s){if(!Ve(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let r=s||{},n=t.type===j.TILES3D,i=n?Zs.cacheBytes:th,o=n?Zs.maximumCacheOverflowBytes:eh,a=ri(r,i),c=ni(r,o);this.options={...Zs,...r,cacheBytes:a,maximumCacheOverflowBytes:c,maximumMemoryUsage:a/$,memoryCacheOverflow:c/$,memoryAdjustedScreenSpaceError:r.memoryAdjustedScreenSpaceError??n},this.loadOptions=this.options.loadOptions||{},this.source=t,this.tileset=null,this.loader=this.source.loader,this.type=this.source.type,this.url=this.source.url,this.basePath=this.source.basePath,this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType="",this.lodMetricValue=0,this.refine="",this.contentFormats=this.source.contentFormats,this._traverser=this._initializeTraverser(),this._requestScheduler=new ht({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=a,this._maximumCacheOverflowBytes=c,this.stats=new tt({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet()}destroy(){this._clearDeferredTraversal(),this.source.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 cacheBytes(){return this._cacheBytes}set cacheBytes(t){this._cacheBytes=Kt(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes,this.options.maximumMemoryUsage=this._cacheBytes/$}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=Kt(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes,this.options.memoryCacheOverflow=this._maximumCacheOverflowBytes/$}get maximumMemoryUsage(){return this.cacheBytes/$}set maximumMemoryUsage(t){this.cacheBytes=Kt(t*$,"maximumMemoryUsage")}get queryParams(){let t=this.source.getTileUrl(this.url),s=t.indexOf("?");return s>=0?t.slice(s+1):""}setProps(t){let s=ri(t,this.cacheBytes),r=ni(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:s,maximumCacheOverflowBytes:r,maximumMemoryUsage:s/$,memoryCacheOverflow:r/$},this._cacheBytes=s,this._maximumCacheOverflowBytes=r}getTileUrl(t){return this.source.getTileUrl(t)}hasExtension(t){return!!this.source.hasExtension?.(t)}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.gpuMemoryUsageInBytes<this.cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this.cacheBytes+this.maximumCacheOverflowBytes&&(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 r=Date.now(),n=Number.POSITIVE_INFINITY,i=[];for(let o of s){let a=o.id;this._needTraverse(a)?i.push(a):this.traverseCounter--}for(let o of s){let a=o.id;if(this.roots[a]||(this.roots[a]=this._initializeTileHeaders(this.tileset,null)),!i.includes(a))continue;let c=ze(o,this._frameNumber),h=this.roots[a],l=Bn(this._cameraMotionStates[a],c.camera.position,c.camera.direction,r);this._cameraMotionStates[a]=l.state,c.camera.timeSinceMovement=l.timeSinceMovement,Gn(h,this.modelMatrix),c.dynamicScreenSpaceErrorDensity=this.type===j.TILES3D&&this.options.dynamicScreenSpaceError&&!c.viewport.orthographic?$n(h,c,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=c.dynamicScreenSpaceErrorDensity,this._traverser.traverse(h,c,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(n=Math.min(n,Math.max(this.options.foveatedTimeDelay-l.timeSinceMovement,0)))}Number.isFinite(n)?this._scheduleDeferredTraversal(n):this._clearDeferredTraversal()}_scheduleDeferredTraversal(t){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(s=>{let r=s instanceof Error?s:new Error(String(s));this._onTilesetError(r)})},Math.max(t*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_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 r=this.frameStateData[s],n=Object.values(this._traverser.selectedTiles),[i,o]=Vn(n,t,this.options.maximumTilesSelected);r.selectedTiles=i;for(let a of o)a.unselect();r._requestedTiles=Object.values(this._traverser.requestedTiles),r._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let t=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let i in this.frameStateData){let o=this.frameStateData[i];this.selectedTiles=this.selectedTiles.concat(o.selectedTiles),this._requestedTiles=this._requestedTiles.concat(o._requestedTiles),this._emptyTiles=this._emptyTiles.concat(o._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let s=new Set(this.selectedTiles.map(i=>i.id)),r=this.selectedTiles.some(i=>!i.tileDrawn),n=0;if(r){for(let i of s)this._heldTiles.add(i);for(let i of this._heldTiles){if(s.has(i))continue;let o=this._tiles[i];o&&o.contentAvailable?(o._selectedFrame=this._frameNumber,this.selectedTiles.push(o),n++):this._heldTiles.delete(i)}}else this._heldTiles=s;n>0&&setTimeout(()=>{this.selectTiles()},0);for(let i of this.selectedTiles)this._tiles[i.id]=i;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(t,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(t,s){if(t.length!==s.length)return!0;let r=new Set(t.map(o=>o.id)),n=new Set(s.map(o=>o.id)),i=t.some(o=>!n.has(o.id));return i=i||s.some(o=>!r.has(o.id)),i}_loadTiles(){this._requestedTiles.sort((t,s)=>t._priority-s._priority);for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,s)=>t._unloadTile(s)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let t=0,s=0;for(let r of this.selectedTiles)r.contentAvailable&&r.content&&(t++,r.content.pointCount?s+=r.content.pointCount:s+=r.content.vertexCount);this.stats.get(ii).count=this.selectedTiles.length,this.stats.get(oi).count=t,this.stats.get(li).count=s,this.stats.get(ui).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let t=this.source.initialize(),s=this._getSourceMetadata();s&&this._syncSourceState(s),s?.tileset?.root&&typeof s.tileset.root.then!="function"&&(this.root=this._initializeTileHeaders(s.tileset,null),this._applyViewState()),await t;let r=this.source.getMetadata();this._syncSourceState(r),this.root||(this.root=this._initializeTileHeaders(r.tileset,null)),this._applyViewState()}catch(t){let s=t instanceof Error?t:new Error(String(t));throw this._onSourceError(s,this.root),this._onTilesetError(s),s}}_initializeStats(){this.stats.get(js),this.stats.get(Qs),this.stats.get(Xs),this.stats.get(ii),this.stats.get(oi),this.stats.get(ai),this.stats.get(ci),this.stats.get(hi),this.stats.get(li),this.stats.get(Ks,"memory"),this.stats.get(ui)}_initializeTileHeaders(t,s){return this.source.initializeTileHeaders(this,t,s)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let s=null;try{this._onStartTileLoading(),s=await t.loadContent()}catch(r){let n=r instanceof Error?r:new Error("load failed");this._onSourceError(n,t),this._onTileLoadError(t,n)}finally{this._onEndTileLoading(),this._onTileLoad(t,s)}}async _loadTileChildren(t,s){try{this._onStartTileLoading(),await t.loadChildren(s)}catch(r){let n=r instanceof Error?r:new Error("subtree load failed");this._onSourceError(n,t),this._onTileLoadError(t,n)}finally{this._onEndTileLoading()}}_onTileLoadError(t,s){this.stats.get(hi).incrementCount();let r=s.message||s.toString(),n=t.url;console.error(`A 3D tile failed to load: ${t.url} ${r}`),this.options.onTileError(t,r,n)}_onSourceError(t,s=null){this.options.onSourceError(t,this.source,s)}_onTilesetError(t){this.options.onTilesetError(t,this)}_onTileLoad(t,s){if(!s?.loaded)return;t.content&&Le(t,t.content),this.source.onTileLoaded?.(this,t,s),this._syncSourceState(this.source.getMetadata());let r=this.source.getTilesTotalCount?.();r&&(this.stats.get(js).reset(),this.stats.get(js).addCount(r)),this._addTileToCache(t),this.options.onTileLoad(t)}_onStartTileLoading(){this._pendingCount++,this.stats.get(Qs).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Qs).decrementCount()}_addTileToCache(t){this._cache.add(this,t,s=>s._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(ai).incrementCount(),this.stats.get(Xs).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Ks).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(Xs).decrementCount(),this.stats.get(ci).incrementCount(),this.stats.get(Ks).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 r of s.children)t.push(r);this._destroyTile(s)}this.root=null}_destroySubtree(t){let s=t,r=[s];for(;r.length>0;){t=r.pop();for(let n of t.children)r.push(n);t!==s&&this._destroyTile(t)}s.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_syncSourceState(t){this.tileset=t.tileset,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset,this.properties=this.source.properties??this.properties,this.extras=this.source.extras??this.extras,this.options.attributions?.length?this.credits={attributions:this.options.attributions}:this.credits=this.source.credits||this.credits}_applyViewState(){let t=this.source.getViewState(this.root);this.asset=t.asset||this.source.asset||{},this.properties=t.properties??this.source.properties,this.extras=t.extras??this.source.extras??null,this.credits=t.credits||this.source.credits||this.credits||{attributions:this.options.attributions||[]},this.description=t.description||this.options.description||"",this.boundingVolume=t.boundingVolume||this.root?.boundingVolume||null,this.cartographicCenter=t.cartographicCenter||new m,this.cartesianCenter=t.cartesianCenter||null,this.zoom=t.zoom||1,this.geometricError=this.tileset?.geometricError||0}_getSourceMetadata(){try{return this.source.getMetadata()}catch{return null}}};var Ue=class{sourceUrl;options;archivePromise;constructor(t){this.options=t,this.sourceUrl=sh(t.data,t.fallbackFilename)}async loadRoot(t,s,r){return await this.parseArchiveResource(t,this.options.rootPath,s,r,this.options.rootMode)}async loadResource(t,s,r){let n=this.resolveArchivePath(t,t);return await this.parseArchiveResource(t,n,s,r)}async parseArchiveResource(t,s,r,n,i){let o=this.options.getCoreApi();if(!o)throw new Error(this.options.missingCoreApiMessage);let a=await this.loadFile(s,i),c=this.createArchiveFetch(t);return await o.parse(a,r,{...n,fetch:c},{url:t,fetch:c,_parse:o.parse,loaders:[r],coreApi:o})}createArchiveFetch(t){return async s=>{let r=typeof s=="string"?s:s instanceof URL?s.toString():s.url,n=this.resolveArchivePath(r,t),i=await this.loadFile(n);return new Response(i,{status:200})}}async loadFile(t,s){this.archivePromise||=this.openArchiveReadableFile().then(n=>this.options.parseArchive(n));let r=await this.archivePromise;return await this.options.getFile(r,t,s)}async openArchiveReadableFile(){let{data:t}=this.options;if(typeof t!="string")return new vt(t);if(/^https?:\/\//i.test(t))return new Zt(t);let s=this.options.getCoreApi();if(!s)throw new Error(this.options.missingCoreApiMessage);let r=await s.fetchFile(t);return new vt(await r.arrayBuffer())}resolveArchivePath(t,s){let r=er(t),n=er(this.sourceUrl),i=er(s),o=i===n?n:J.dirname(i),a=new RegExp(`\\.${this.options.archiveExtension}/(.*)$`,"i"),c=r.match(a);if(c?.[1])return c[1];let h=/^[a-z][a-z0-9+.-]*:/i.test(r)||r.startsWith("/"),l=r.startsWith(n)?r:i===n&&!h?`${n}/${r}`:J.resolve(o,r);return l===n?"":l.startsWith(`${n}/`)?l.slice(n.length+1):l.replace(/^\/+/,"")}};function sh(e,t){return typeof e=="string"?e:`memory://${"name"in e&&typeof e.name=="string"&&e.name?e.name:t}`}function er(e){let t=e.indexOf("?");return t>=0?e.slice(0,t):e}function pi(e){return e!=null}var H=new m,ke=new m,rh=new m,nh=new m,St=new m,di=new m,fi=new m,mi=new m;function Pt(e,t,s){if(rt(e,"3D Tile: boundingVolume must be defined"),e.box)return xi(e.box,t,s);if(e.region)return oh(e.region);if(e.sphere)return ih(e.sphere,t,s);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function gi(e,t){if(e.box)return ah(t);if(e.region){let[s,r,n,i,o,a]=e.region;return[[Q(s),Q(r),o],[Q(n),Q(i),a]]}if(e.sphere)return ch(t);throw new Error("Unkown boundingVolume type")}function xi(e,t,s){let r=new m(e[0],e[1],e[2]);t.transform(r,r);let n=[];if(e.length===10){let h=e.slice(3,6),l=new it;l.fromArray(e,6);let u=new m([1,0,0]),d=new m([0,1,0]),f=new m([0,0,1]);u.transformByQuaternion(l),u.scale(h[0]),d.transformByQuaternion(l),d.scale(h[1]),f.transformByQuaternion(l),f.scale(h[2]),n=[...u.toArray(),...d.toArray(),...f.toArray()]}else n=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];let i=t.transformAsVector(n.slice(0,3)),o=t.transformAsVector(n.slice(3,6)),a=t.transformAsVector(n.slice(6,9)),c=new V([i[0],i[1],i[2],o[0],o[1],o[2],a[0],a[1],a[2]]);return pi(s)?(s.center=r,s.halfAxes=c,s):new mt(r,c)}function ih(e,t,s){let r=new m(e[0],e[1],e[2]);t.transform(r,r);let n=t.getScale(ke),i=Math.max(Math.max(n[0],n[1]),n[2]),o=e[3]*i;return pi(s)?(s.center=r,s.radius=o,s):new Z(r,o)}function oh(e){let[t,s,r,n,i,o]=e,a=w.WGS84.cartographicToCartesian([Q(t),Q(n),i],rh),c=w.WGS84.cartographicToCartesian([Q(r),Q(s),o],nh),h=new m().addVectors(a,c).multiplyByScalar(.5);return w.WGS84.cartesianToCartographic(h,St),w.WGS84.cartographicToCartesian([Q(r),St[1],St[2]],di),w.WGS84.cartographicToCartesian([St[0],Q(n),St[2]],fi),w.WGS84.cartographicToCartesian([St[0],St[1],o],mi),xi([...h,...di.subtract(h),...fi.subtract(h),...mi.subtract(h)],new v)}function ah(e){let t=yi(),{halfAxes:s}=e,r=new m(s.getColumn(0)),n=new m(s.getColumn(1)),i=new m(s.getColumn(2));for(let o=0;o<2;o++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)H.copy(e.center),H.add(r),H.add(n),H.add(i),Ti(t,H),i.negate();n.negate()}r.negate()}return t}function ch(e){let t=yi(),{center:s,radius:r}=e,n=w.WGS84.scaleToGeodeticSurface(s,H),i;n?i=w.WGS84.geodeticSurfaceNormal(n):i=new m(0,0,1);let o=new m(i[2],-i[1],0);o.len()>0?o.normalize():o=new m(0,1,0);let a=o.clone().cross(i);for(let c of[o,a,i]){ke.copy(c).scale(r);for(let h=0;h<2;h++)H.copy(s),H.add(ke),Ti(t,H),ke.negate()}return t}function yi(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Ti(e,t){w.WGS84.cartesianToCartographic(t,H),e[0][0]=Math.min(e[0][0],H[0]),e[0][1]=Math.min(e[0][1],H[1]),e[0][2]=Math.min(e[0][2],H[2]),e[1][0]=Math.max(e[1][0],H[0]),e[1][1]=Math.max(e[1][1],H[1]),e[1][2]=Math.max(e[1][2],H[2])}var sr=new m,_i=new m,pt=new m,Mi=new m,hh=new m,rr=new v,Si=new v;function We(e,t){if(e.lodMetricValue===0||Number.isNaN(e.lodMetricValue))return"DIG";let s=2*nr(e,t);return s<2?"OUT":!e.header.children||s<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}function nr(e,t){let{topDownViewport:s}=t,r=e.header.mbs[1],n=e.header.mbs[0],i=e.header.mbs[2],o=e.header.mbs[3],a=[...e.boundingVolume.center],c=s.unprojectPosition(s.cameraPosition);w.WGS84.cartographicToCartesian(c,sr),_i.copy(sr).subtract(a).normalize(),w.WGS84.eastNorthUpToFixedFrame(a,rr),Si.copy(rr).invert(),pt.copy(sr).transform(Si);let h=Math.sqrt(pt[0]*pt[0]+pt[1]*pt[1]),l=h*h/pt[2];Mi.copy([pt[0],pt[1],l]);let d=Mi.transform(rr).subtract(a).normalize(),g=_i.cross(d).normalize().scale(o).add(a),x=w.WGS84.cartesianToCartographic(g),p=s.project([n,r,i]),y=s.project(x);return hh.copy(p).subtract(y).magnitude()}var Jt=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 rt(t<this._array.length),this._array[t]}set(t,s){rt(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){rt(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){rt(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 lh={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},at=class{options;root=null;selectedTiles={};requestedTiles={};deferredTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new Jt;_emptyTraversalStack=new Jt;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...lh,...t}}traverse(t,s,r){this.root=t,this.options={...this.options,...r},this.reset(),this.updateTile(t,s),this._frameNumber=s.frameNumber,this.executeTraversal(t,s)}reset(){this.requestedTiles={},this.deferredTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,s){let r=this._traversalStack;for(t._selectionDepth=1,r.push(t);r.length>0;){let i=r.pop(),o=!1;this.canTraverse(i,s)&&(this.updateChildTiles(i,s),o=this.updateAndPushChildren(i,s,r,i.hasRenderContent?i._selectionDepth+1:i._selectionDepth));let a=i.parent,c=!!(!a||a._shouldRefine),h=!o;i.hasRenderContent?i.refine===Y.ADD?(this.loadTile(i,s),this.selectTile(i,s)):i.refine===Y.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&&c}let n=new Date().getTime();(this.traversalFinished(s)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(s))}updateChildTiles(t,s){let r=t.children;for(let n of r)this.updateTile(n,s)}updateAndPushChildren(t,s,r,n){let{loadSiblings:i,skipLevelOfDetail:o}=this.options,a=t.children;a.sort(this.compareDistanceToCamera.bind(this));let c=t.refine===Y.REPLACE&&t.hasRenderContent&&!o,h=!1,l=!0;for(let u of a)if(u._selectionDepth=n,u.isVisibleAndInRequestVolume?(r.find(u)&&r.delete(u),r.push(u),h=!0):(c||i)&&(this.loadTile(u,s),this.touchTile(u,s)),c){let d;if(u._inRequestVolume?u.hasRenderContent?d=u.contentAvailable:d=this.executeEmptyTraversal(u,s):d=!1,l=l&&d,!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){if(this.shouldLoadTile(t)){if(this.shouldDeferTileRequest(t)){this.deferredTiles[t.id]=t;return}t._requestedFrame=s.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t}}shouldDeferTileRequest(t){return t.priorityDeferred}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,r=!1){let n=t._screenSpaceError;return r&&(n=t.getScreenSpaceError(s,!0)),n>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,s){let r=[];if(this.options.viewportTraversersMap)for(let n in this.options.viewportTraversersMap)this.options.viewportTraversersMap[n]===s.viewport.id&&r.push(n);else r.push(s.viewport.id);t.updateVisibility(s,r)}compareDistanceToCamera(t,s){return t._distanceToCamera-s._distanceToCamera}anyChildrenVisible(t,s){let r=!1;for(let n of t.children)n.updateVisibility(s),r=r||n.isVisibleAndInRequestVolume;return r}executeEmptyTraversal(t,s){let r=!0,n=!1,i=this._emptyTraversalStack;for(i.push(t);i.length>0;){let o=i.pop(),a=!o.hasRenderContent&&this.canTraverse(o,s),c=!o.hasRenderContent&&o.children.length===0;if(o.header.implicitSubtree&&(n=!0,r=!1),!a&&!o.contentAvailable&&!c&&(r=!1),this.updateTile(o,s),o.isVisibleAndInRequestVolume||(this.loadTile(o,s),this.touchTile(o,s)),a){let h=o.children;for(let l of h)i.push(l)}}return t.hasEmptyContent&&!n||r}};var ir=new m;function uh(e){return e!=null}var et=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;_unscaledLodMetricValue=0;boundingVolume=null;content=null;contentState=G.UNLOADED;gpuMemoryUsageInBytes=0;children=[];childrenState="ready";depth=0;viewportIds=[];transform=new v;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new at({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_childrenPromise=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_screenSpaceErrorProgressiveResolution=0;_priorityProgressiveResolution=!1;_foveatedFactor=0;priorityDeferred=!1;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new v;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(t,s,r,n=""){this.header=s,this.tileset=t,this.id=n||s.id,this.url=s.url,this.parent=r,this.refine=this._getRefine(s.refine),this.type=s.type,this.contentUrl=s.contentUrl,this.childrenState=s.implicitSubtree?"unloaded":"ready",this._initializeLodMetric(s),this._initializeTransforms(s),this._updateLodMetricScale(),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||!!(this.header.implicitSubtree&&this.childrenState!=="ready")}get hasUnloadedChildren(){return!!(this.header.implicitSubtree&&(this.childrenState==="unloaded"||this.childrenState==="failed"))}get childrenLoading(){return this.childrenState==="loading"}get contentReady(){return this.contentState===G.READY||this.hasEmptyContent}get contentAvailable(){return!!(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===G.UNLOADED}get contentExpired(){return this.contentState===G.EXPIRED}get contentFailed(){return this.contentState===G.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=gi(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,s,r=1){switch(this.tileset.type){case j.I3S:return nr(this,t);case j.TILES3D:return Hn(this,t,s,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){return this._calculateRequestPriority(!1)}_getChildrenPriority(){return this._calculateRequestPriority(!0)}_calculateRequestPriority(t){let s=this.tileset._traverser,{skipLevelOfDetail:r}=s.options,n=this.refine===Y.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.priorityDeferred||!t&&this.contentState===G.UNLOADED)return-1;let i=this.parent,a=i&&(!n||this._screenSpaceError===0||i.hasTilesetContent)?i._screenSpaceError:this._screenSpaceError,c=s.root?s.root._screenSpaceError:0,h=Math.max(c-a,0);return si({priorityProgressiveResolution:this._priorityProgressiveResolution,foveatedFactor:this._foveatedFactor,reverseScreenSpaceError:h,rootScreenSpaceError:c})}async loadContent(){if(this.hasEmptyContent)return{loaded:!1};if(this.content)return{loaded:!0};this.contentExpired&&(this._expireDate=null),this.contentState=G.LOADING;let s=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!s)return this.contentState=G.UNLOADED,{loaded:!1};try{let r=await this.tileset.source.loadTileContent(this);return this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this.contentState=G.READY,this._onContentLoaded(),r}catch(r){throw this.contentState=G.FAILED,r}finally{s.done()}}async loadChildren(t){if(!this.header.implicitSubtree||this.childrenState==="ready")return{loaded:!1,tileCount:0,childSubtreeCount:0};if(this._childrenPromise)return await this._childrenPromise;if(!this.tileset.source.loadTileChildren)throw new Error("Tileset source does not support lazy tile children");this.childrenState="loading",this._childrenPromise=this._loadChildrenWithScheduler(t);try{return await this._childrenPromise}finally{this._childrenPromise=null}}async _loadChildrenWithScheduler(t){let s=await this.tileset._requestScheduler.scheduleRequest(`${this.id}:implicit-subtree`,this._getChildrenPriority.bind(this));if(!s)return this.childrenState="unloaded",{loaded:!1,tileCount:0,childSubtreeCount:0};try{let r=await this.tileset.source.loadTileChildren(this,t);return this.childrenState=r.loaded?"ready":"unloaded",r}catch(r){throw this.childrenState="failed",r}finally{s.done()}}applyImplicitSubtreeHeader(t){let s=this.header.transform,r=this.header.transformMatrix;this.header={...this.header,...t,transform:s,transformMatrix:r,implicitSubtree:void 0},this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this._initializeLodMetric(t),this._updateLodMetricScale(),this._initializeBoundingVolumes(this.header),this._initializeContent(this.header)}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=G.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(t,s){if(this._frameNumber===t.frameNumber)return;let r=this.parent,n=r?r._visibilityPlaneMask:k.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let i=r?r.computedTransform:this.tileset.modelMatrix;this._updateTransform(i)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._updateRequestPriorityMetrics(t),this._visibilityPlaneMask=this.visibility(t,n),this._visible=this._visibilityPlaneMask!==k.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=s}_updateRequestPriorityMetrics(t){if(this.tileset.type!==j.TILES3D){this._screenSpaceErrorProgressiveResolution=this._screenSpaceError,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1;return}let s=this.tileset.options,r=s.progressiveResolutionHeightFraction;if(this._screenSpaceErrorProgressiveResolution=this.getScreenSpaceError(t,!1,r),this._priorityProgressiveResolution=Jn(this._screenSpaceErrorProgressiveResolution,this.parent?._screenSpaceErrorProgressiveResolution,this.tileset.memoryAdjustedScreenSpaceError,r),!s.foveatedScreenSpaceError||t.viewport?.orthographic||!t.camera?.position||!t.camera?.direction){this._foveatedFactor=0,this.priorityDeferred=!1;return}this._foveatedFactor=Kn(this.boundingVolume,t.camera);let n=ti({refinement:this.refine,skipLevelOfDetail:this.tileset._traverser.options.skipLevelOfDetail,foveatedScreenSpaceError:s.foveatedScreenSpaceError,foveatedConeSize:s.foveatedConeSize,minimumScreenSpaceErrorRelaxation:s.foveatedMinimumScreenSpaceErrorRelaxation,interpolationCallback:s.foveatedInterpolationCallback,foveatedFactor:this._foveatedFactor,verticalFieldOfView:t.camera.verticalFieldOfView,screenSpaceError:this._screenSpaceError,parentScreenSpaceError:this.parent?._screenSpaceError,maximumScreenSpaceError:this.tileset.memoryAdjustedScreenSpaceError,priorityProgressiveResolution:this._priorityProgressiveResolution});this.priorityDeferred=ei(n,t.camera.timeSinceMovement,s.foveatedTimeDelay)}visibility(t,s){let{cullingVolume:r}=t,{boundingVolume:n}=this;return r.computeVisibilityWithPlaneMask(n,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 ir.subVectors(s.center,t.position),t.direction.dot(ir)}insideViewerRequestVolume(t){let s=this._viewerRequestVolume;return!s||s.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(uh(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=G.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._unscaledLodMetricValue=t.lodMetricValue:(this._unscaledLodMetricValue=this.parent?this.parent._unscaledLodMetricValue:this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue")),this.lodMetricValue=this._unscaledLodMetricValue}_initializeTransforms(t){this.transform=t.transform?new v(t.transform):new v;let s=this.parent,r=this.tileset,n=s&&s.computedTransform?s.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new v(n).multiplyRight(this.transform);let i=s&&s._initialTransform?s._initialTransform.clone():new v;this._initialTransform=new v(i).multiplyRight(this.transform)}_updateLodMetricScale(){if(this.lodMetricType!==Lt.GEOMETRIC_ERROR){this.lodMetricValue=this._unscaledLodMetricValue;return}let t=this.computedTransform.getScale(ir),s=Math.max(t[0],t[1],t[2]);this.lodMetricValue=this._unscaledLodMetricValue*s}_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=G.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._screenSpaceErrorProgressiveResolution=0,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1,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||Y.REPLACE}_isTileset(){return this.content?.shape==="tileset3d"}_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=Pt(t.boundingVolume,this.computedTransform,this.boundingVolume),t.viewerRequestVolume&&(this._viewerRequestVolume=Pt(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume));let s=t.content;s&&s.boundingVolume&&(this._contentBoundingVolume=Pt(s.boundingVolume,this.computedTransform,this._contentBoundingVolume))}_updateTransform(t=new v){let s=t.clone().multiplyRight(this.transform);s.equals(this.computedTransform)||(this.computedTransform=s,this._updateLodMetricScale(),this._updateBoundingVolume(this.header))}};var Ye=class extends at{pendingImplicitSubtrees=new Map;traversalFinished(t){let s=`${t.viewport.id}:`;for(let[r,n]of this.pendingImplicitSubtrees)if(r.startsWith(s)&&n===t.frameNumber)return!1;return!0}compareDistanceToCamera(t,s){return s._distanceToCamera===0&&t._distanceToCamera===0?s._centerZDepth-t._centerZDepth:s._distanceToCamera-t._distanceToCamera}updateChildTiles(t,s){if(t.hasUnloadedChildren&&t.isVisibleAndInRequestVolume&&this.shouldRefine(t,s)){let r=`${s.viewport.id}:${t.id}`;this.pendingImplicitSubtrees.has(r)||(this.pendingImplicitSubtrees.set(r,s.frameNumber),t.tileset._loadTileChildren(t,s).finally(()=>{this.handleImplicitSubtreeLoad(t,s,r)}))}super.updateChildTiles(t,s)}handleImplicitSubtreeLoad(t,s,r){this.pendingImplicitSubtrees.delete(r),this._frameNumber===s.frameNumber&&(t.childrenState==="ready"?this.executeTraversal(t,s):this.traversalFinished(s)&&this.options.onTraversalEnd(s))}updateTileVisibility(t,s){if(super.updateTileVisibility(t,s),!t.isVisibleAndInRequestVolume)return;let r=t.children.length>0;if(t.hasTilesetContent&&r){let o=t.children[0];this.updateTileVisibility(o,s),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,s)){t._visible=!1;return}let n=t.refine===Y.REPLACE,i=t._optimChildrenWithinParent===Zn.USE_OPTIMIZATION;if(n&&i&&r&&!this.anyChildrenVisible(t,s)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,s){let{parent:r}=t;return!r||r.hasTilesetContent||r.refine!==Y.ADD?!1:!this.shouldRefine(t,s,!0)}};var dh=6378137,fh=6378137,or=6356752314245179e-9,Nt=new m;function Ei(e,t){if(e instanceof mt){let{halfAxes:s}=e,r=mh(s);return Math.log2(or/(r+t[2]))}else if(e instanceof Z){let{radius:s}=e;return Math.log2(or/(s+t[2]))}else if(e.width&&e.height){let{width:s,height:r}=e,n=Math.log2(dh/s),i=Math.log2(fh/r);return(n+i)/2}return 1}function ar(e,t,s){w.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Nt);let r=Math.sqrt(Math.pow(Nt[0]-s[0],2)+Math.pow(Nt[1]-s[1],2)+Math.pow(Nt[2]-s[2],2));return Math.log2(or/(r+t[2]))}function bi(e,t,s){let[r,n,i,o]=e;return ar({xmin:r,xmax:i,ymin:n,ymax:o,zmin:0,zmax:0},t,s)}function mh(e){e.getColumn(0,Nt);let t=e.getColumn(1),s=e.getColumn(2);return Nt.add(t).add(s).len()}var ph=4,gh=8;function hr(e,t){return{coordinates:t,subtreeUrl:$e(e.subtreesUrlTemplate,t),descriptor:e}}function Ge(e,t){let{descriptor:s}=t;Eh(s);let r={tileCount:0,childSubtreeCount:0},n=wi(e,t,{localLevel:0,mortonIndex:0},t.coordinates,r);if(!n)throw new Error(`Invalid 3D Tiles subtree: root tile is unavailable at ${t.subtreeUrl}`);return{root:n,...r}}function $e(e,t){let s={level:t.level,x:t.x,y:t.y,z:t.z};return e.replace(/{(level|x|y|z)}/gi,(r,n)=>String(s[n.toLowerCase()]))}function wi(e,t,s,r,n){let{descriptor:i}=t,o=Mh(i.subdivisionScheme),a=_h(o,s.localLevel)+s.mortonIndex;if(!cr(e.tileAvailability,a))return null;n.tileCount++;let c=cr(Th(e.contentAvailability),a),h=[];if(r.level<i.maximumLevel)if(s.localLevel+1<i.subtreeLevels)for(let l=0;l<o;l++){let u=Ri(r,l,i.subdivisionScheme),d=wi(e,t,{localLevel:s.localLevel+1,mortonIndex:s.mortonIndex*o+l},u,n);d&&h.push(d)}else for(let l=0;l<o;l++){let u=s.mortonIndex*o+l;if(cr(e.childSubtreeAvailability,u)){let d=Ri(r,l,i.subdivisionScheme);h.push(xh(i,d)),n.childSubtreeCount++}}return yh(i,t,r,c,h)}function xh(e,t){let s=hr(e,t);return{id:Ci(s,t),children:[],implicitSubtree:s,boundingVolume:Oi(e.rootBoundingVolume,t,e.subdivisionScheme),geometricError:e.rootLodMetricValue/2**t.level,lodMetricType:e.lodMetricType,lodMetricValue:e.rootLodMetricValue/2**t.level,refine:e.refine,type:ot.EMPTY}}function yh(e,t,s,r,n){let i=r&&e.contentUrlTemplate?$e(e.contentUrlTemplate,s):void 0,o=e.rootLodMetricValue/2**s.level;return{id:Ci(t,s),children:n,contentUrl:i,content:i?{...e.contentHeader,uri:i}:void 0,refine:e.refine,type:Sh(i),lodMetricType:e.lodMetricType,lodMetricValue:o,geometricError:o,boundingVolume:Oi(e.rootBoundingVolume,s,e.subdivisionScheme)}}function Ci(e,t){return`${e.subtreeUrl}#implicit=${t.level}/${t.x}/${t.y}/${t.z}`}function cr(e,t){if(typeof e?.constant=="number")return!!e.constant;let s=e?.explicitBitstream;if(!s)return!1;let r=Math.floor(t/8),n=t%8;return!!(s[r]>>n&1)}function Th(e){return Array.isArray(e)?e[0]||{constant:0}:e||{constant:0}}function _h(e,t){return(e**t-1)/(e-1)}function Ri(e,t,s){return{level:e.level+1,x:e.x*2+(t&1),y:e.y*2+(t>>1&1),z:s==="OCTREE"?e.z*2+(t>>2&1):0}}function Mh(e){return e==="OCTREE"?gh:ph}function Oi(e,t,s){if(e.region){let[r,n,i,o,a,c]=e.region,h=2**t.level,l=(i-r)/h,u=(o-n)/h,d=r+l*t.x,f=n+u*t.y,g=a,x=c;if(s==="OCTREE"){let p=(c-a)/h;g=a+p*t.z,x=g+p}return{region:[d,f,d+l,f+u,g,x]}}if(e.box){if(e.s2VolumeInfo)return{box:[...e.box],s2VolumeInfo:e.s2VolumeInfo};let r=e.box,n=2**t.level,i=-1+(2*t.x+1)/n,o=-1+(2*t.y+1)/n,a=-1+(2*t.z+1)/n,c=s==="OCTREE";return{box:[...[r[0]+r[3]*i+r[6]*o+(c?r[9]*a:0),r[1]+r[4]*i+r[7]*o+(c?r[10]*a:0),r[2]+r[5]*i+r[8]*o+(c?r[11]*a:0)],r[3]/n,r[4]/n,r[5]/n,r[6]/n,r[7]/n,r[8]/n,c?r[9]/n:r[9],c?r[10]/n:r[10],c?r[11]/n:r[11]]}}throw new Error(`Unsupported implicit 3D Tiles bounding volume: ${JSON.stringify(e)}`)}function Sh(e){if(!e)return ot.EMPTY;let t=e.split("?")[0].split(".").pop()?.toLowerCase();switch(t){case"pnts":return ot.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return ot.SCENEGRAPH;default:return t||ot.EMPTY}}function Eh(e){if(e.subdivisionScheme!=="QUADTREE"&&e.subdivisionScheme!=="OCTREE")throw new Error(`Unsupported implicit subdivision scheme: ${e.subdivisionScheme}`);if(!Number.isInteger(e.subtreeLevels)||e.subtreeLevels<1)throw new Error("Implicit subtreeLevels must be a positive integer");if(!Number.isInteger(e.maximumLevel)||e.maximumLevel<0)throw new Error("Implicit availableLevels must describe at least the root level")}var bh={draco:!1,meshopt:!1,dds:!1,ktx2:!1},Rh=32,He=class{type=j.TILES3D;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...bh};asset;properties;extras;credits;metadata;queryParams={};tileUrlCache=new Map;implicitSubtreeCache=new Map;pendingImplicitSubtreeUrls=new Set;maximumCachedSubtrees;implicitTilingStats={requestedSubtrees:0,loadedSubtrees:0,cacheHits:0,materializedTiles:0};destroyed=!1;extensionsUsed=[];resolver;rootTileset;constructor(t,s={}){let r=wh(t);this.rootTileset=Ai(t)?null:t,this.tileset=this.rootTileset,this.loader=r.loader,this.url=r.url,this.basePath=r.basePath||J.dirname(r.url),this.resolver=r.resolver,this.coreApi=r.coreApi,this.loadOptions=s;let n=Number(s["3d-tiles"]?.maximumCachedSubtrees);this.maximumCachedSubtrees=Number.isFinite(n)?Math.max(0,Math.floor(n)):Rh}destroy(){this.destroyed=!0,this.tileUrlCache.clear(),this.implicitSubtreeCache.clear(),this.pendingImplicitSubtreeUrls.clear()}async initialize(){if(!this.rootTileset){let t=this.loadOptions[this.loader.id]||{};this.rootTileset=await this.loadRootData(this.url,{...this.loadOptions,[this.loader.id]:{...t,isTileset:!0}})}if(this.tileset=this.rootTileset,this.rootTileset.queryString){let t=new URLSearchParams(this.rootTileset.queryString);for(let[s,r]of t.entries())this.setQueryParameter(s,r)}if(this.asset=this.rootTileset.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.setQueryParameter("v",this.asset.tilesetVersion),this.properties=this.rootTileset.properties,this.extras=this.rootTileset.extras,this.credits={attributions:[]},this.extensionsUsed.splice(0,this.extensionsUsed.length,...this.rootTileset.extensionsUsed||[]),this.metadata={type:this.type,loader:this.loader,url:this.url,basePath:this.basePath,tileset:this.rootTileset,lodMetricType:this.rootTileset.lodMetricType,lodMetricValue:this.rootTileset.lodMetricValue,refine:this.rootTileset.root?.refine}}getMetadata(){if(!this.metadata)throw new Error("Tiles3DSource has not been initialized");return this.metadata}async getRootTileset(){return this.getMetadata().tileset}initializeTileHeaders(t,s,r){let n=new et(t,s.root,r||void 0);r&&(r.children.push(n),n.depth=r.depth+1);let i=[n];for(;i.length>0;){let o=i.pop();t.stats.get("Tiles In Tileset(s)").incrementCount();let a=o.header.children||[];for(let c of a){let h=new et(t,c,o);if(h.contentUrl?.includes("?session=")){let u=new URL(h.contentUrl).searchParams.get("session");u&&this.setQueryParameter("session",u)}o.children.push(h),h.depth=o.depth+1,i.push(h)}}return n}createTraverser(t){return new Ye(t)}async loadTileContent(t){let s=this.getTileUrl(t.contentUrl),r=this.loadOptions[this.loader.id]||{},n={...this.loadOptions,[this.loader.id]:{...r,isTileset:"auto",assetGltfUpAxis:this.asset&&this.asset.gltfUpAxis||"Y"}},i=await this.loadResourceData(s,n);return t.content=i,{loaded:!0,nestedTileset:i?.shape==="tileset3d"?i:void 0}}async loadTileChildren(t,s){let r=t.header.implicitSubtree;if(!r)return{loaded:!1,tileCount:0,childSubtreeCount:0};let n=this.getTileUrl(r.subtreeUrl),i=await this.loadImplicitSubtreeResource(n);if(this.destroyed||t.isDestroyed())return{loaded:!1,tileCount:0,childSubtreeCount:0};let o=Ge(i,{...r,subtreeUrl:n});t.applyImplicitSubtreeHeader(o.root);let a=this.initializeMaterializedChildren(t.tileset,t,o.root.children);return this.implicitTilingStats.loadedSubtrees++,this.implicitTilingStats.materializedTiles+=a,{loaded:!0,tileCount:o.tileCount,childSubtreeCount:o.childSubtreeCount}}getImplicitTilingStats(){return{...this.implicitTilingStats,cachedSubtrees:this.implicitSubtreeCache.size-this.pendingImplicitSubtreeUrls.size,pendingSubtrees:this.pendingImplicitSubtreeUrls.size}}getTileUrl(t){if(t.startsWith("data:"))return t;let s=this.tileUrlCache.get(t);if(s)return s;if(!Object.keys(this.queryParams).length)return this.tileUrlCache.set(t,t),t;let[r,n=""]=t.split("?"),i=new URLSearchParams(n);for(let[c,h]of Object.entries(this.queryParams))i.has(c)||i.set(c,h);let o=i.toString(),a=o?`${r}?${o}`:r;return this.tileUrlCache.set(t,a),a}setQueryParameter(t,s){this.queryParams[t]!==s&&(this.queryParams[t]=s,this.tileUrlCache.clear())}getViewState(t){if(!t)return{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits};let{center:s}=t.boundingVolume,r;return s&&(s[0]!==0||s[1]!==0||s[2]!==0)?(r=new m,w.WGS84.cartesianToCartographic(s,r)):r=new m(0,0,-w.WGS84.radii[0]),{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits,boundingVolume:t.boundingVolume,cartographicCenter:r,cartesianCenter:s,zoom:Ei(t.boundingVolume,r)}}hasExtension(t){return this.extensionsUsed.includes(t)}onTileLoaded(t,s,r){let{extensionsRemoved:n=[]}=s.content?.gltf||{};n.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),n.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),n.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0),r.nestedTileset&&t._initializeTileHeaders(r.nestedTileset,s)}async loadWithCoreApi(t,s,r=this.loader){if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to load tileset data");return await this.coreApi.load(t,r,s)}async loadRootData(t,s){return this.resolver?await this.resolver.loadRoot(t,this.loader,s):await this.loadWithCoreApi(t,s)}async loadResourceData(t,s,r=this.loader){return this.resolver?await this.resolver.loadResource(t,r,s):await this.loadWithCoreApi(t,s,r)}async loadImplicitSubtreeResource(t){let s=this.implicitSubtreeCache.get(t);if(s)return this.implicitTilingStats.cacheHits++,this.implicitSubtreeCache.delete(t),this.implicitSubtreeCache.set(t,s),await s;this.implicitTilingStats.requestedSubtrees++,this.pendingImplicitSubtreeUrls.add(t);let r=this.loadOptions[this.loader.id]||{},n=this.loadResourceData(t,{...this.loadOptions,[this.loader.id]:{...r,isTileset:!1,isSubtree:!0}});this.implicitSubtreeCache.set(t,n);try{return await n}catch(i){throw this.implicitSubtreeCache.delete(t),i}finally{this.pendingImplicitSubtreeUrls.delete(t),this.trimImplicitSubtreeCache()}}initializeMaterializedChildren(t,s,r){let n=0,i=[{parentTile:s,childHeaders:r}];for(;i.length>0;){let o=i.pop();for(let a of o.childHeaders){let c=new et(t,a,o.parentTile);o.parentTile.children.push(c),c.depth=o.parentTile.depth+1,t.stats.get("Tiles In Tileset(s)").incrementCount(),n++,a.children?.length&&i.push({parentTile:c,childHeaders:a.children})}}return n}trimImplicitSubtreeCache(){if(!(this.implicitSubtreeCache.size<=this.maximumCachedSubtrees)){for(let t of this.implicitSubtreeCache.keys())if(this.pendingImplicitSubtreeUrls.has(t)||this.implicitSubtreeCache.delete(t),this.implicitSubtreeCache.size<=this.maximumCachedSubtrees)break}}};function Ai(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function wh(e){return Ai(e)?{...e,basePath:e.basePath||J.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||J.dirname(e.url),resolver:e.resolver,coreApi:e.coreApi}}var Ze=class{frameNumberMap=new Map;register(t,s){let r=this.frameNumberMap.get(t)||new Map,n=r.get(s)||0;r.set(s,n+1),this.frameNumberMap.set(t,r)}deregister(t,s){let r=this.frameNumberMap.get(t);if(!r)return;let n=r.get(s)||1;r.set(s,n-1)}isZero(t,s){return(this.frameNumberMap.get(t)?.get(s)||0)===0}};var lr={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},je=class{_statusMap;pendingTilesRegister=new Ze;constructor(){this._statusMap={}}add(t,s,r,n){if(!this._statusMap[s]){let{frameNumber:i,viewport:{id:o}}=n;this._statusMap[s]={request:t,callback:r,key:s,frameState:n,status:lr.REQUESTED},this.pendingTilesRegister.register(o,i),t().then(a=>{this._statusMap[s].status=lr.COMPLETED;let{frameNumber:c,viewport:{id:h}}=this._statusMap[s].frameState;this.pendingTilesRegister.deregister(h,c),this._statusMap[s].callback(a,n)}).catch(a=>{this._statusMap[s].status=lr.ERROR;let{frameNumber:c,viewport:{id:h}}=this._statusMap[s].frameState;this.pendingTilesRegister.deregister(h,c),r(a)})}}update(t,s){if(this._statusMap[t]){let{frameNumber:r,viewport:{id:n}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(n,r);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 Xe=class extends at{_tileManager;constructor(t){super(t),this._tileManager=new je}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,s){return t._lodJudge=We(t,s),t._lodJudge==="DIG"}updateChildTiles(t,s){let r=t.header.children||[],n=t.children;for(let i of r){let o=`${i.id}-${s.viewport.id}`,a=n&&n.find(c=>c.id===o);if(a)a&&this.updateTile(a,s);else{let c=()=>this._loadTile(t,i.id,s);this._tileManager.find(o)?this._tileManager.update(o,s):this._tileManager.add(c,o,l=>this._onTileLoad(l,t,o),s)}}return!1}async _loadTile(t,s,r){if(!t.tileset.source.loadChildTileHeader)throw new Error("I3S source does not support child tile header loading");return await t.tileset.source.loadChildTileHeader(t,s,r)}_onTileLoad(t,s,r){if(t instanceof Error){s.tileset._onSourceError(t,s);return}let n=new et(s.tileset,t,s,r);s.children.push(n);let i=this._tileManager.find(n.id).frameState;this.updateTile(n,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,i)}};var Ch={draco:!1,meshopt:!1,dds:!1,ktx2:!1},Qe=class{type=j.I3S;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...Ch};asset;properties;extras;credits;metadata;queryParams={};resolver;rootTileset;constructor(t,s={}){let r=Oh(t);this.rootTileset=vi(t)?null:t,this.tileset=this.rootTileset,this.loader=r.loader,this.url=r.url,this.basePath=r.basePath||J.dirname(r.url),this.resolver=r.resolver,this.coreApi=r.coreApi,this.loadOptions=s}async initialize(){this.rootTileset||(this.rootTileset=await this.loadRootData(this.url,this.loadOptions)),this.tileset=this.rootTileset,this.rootTileset.root&&typeof this.rootTileset.root.then=="function"&&(this.rootTileset.root=await this.rootTileset.root);let t=this.loadOptions.i3s;if(t&&typeof t=="object"&&"token"in t){let s=t.token;typeof s=="string"&&(this.queryParams.token=s)}this.metadata={type:this.type,loader:this.loader,url:this.url,basePath:this.basePath,tileset:this.rootTileset,lodMetricType:this.rootTileset.lodMetricType,lodMetricValue:this.rootTileset.lodMetricValue,refine:this.rootTileset.root?.refine}}getMetadata(){if(!this.metadata)throw new Error("I3SSource has not been initialized");return this.metadata}async getRootTileset(){return this.getMetadata().tileset}initializeTileHeaders(t,s,r){let n=new et(t,s.root,r||void 0);return r&&(r.children.push(n),n.depth=r.depth+1),n}createTraverser(t){return new Xe(t)}async loadTileContent(t){let s=this.getTileUrl(t.contentUrl),r=this.loader.id,n=this.loadOptions[r]||{},i=this.getMetadata(),o={...this.loadOptions,[r]:{...n,...t.tileset.options.i3s,_tileOptions:{attributeUrls:t.header.attributeUrls,textureUrl:t.header.textureUrl,textureFormat:t.header.textureFormat,textureLoaderOptions:t.header.textureLoaderOptions,materialDefinition:t.header.materialDefinition,isDracoGeometry:t.header.isDracoGeometry,mbs:t.header.mbs},_tilesetOptions:{store:i.tileset.store,attributeStorageInfo:i.tileset.attributeStorageInfo,fields:i.tileset.fields},isTileHeader:!1}};return t.content=await this.loadResourceData(s,o),{loaded:!0}}async loadChildTileHeader(t,s,r){let n=this.getMetadata();if(n.tileset.nodePages)return await n.tileset.nodePagesTile.formTileFromNodePages(s);let i=this.getTileUrl(`${this.url}/nodes/${s}`),o=this.loadOptions.i3s&&typeof this.loadOptions.i3s=="object"?this.loadOptions.i3s:{},a={...this.loadOptions,i3s:{...o,isTileHeader:!0}};return await this.loadResourceData(i,a)}getTileUrl(t){if(t.startsWith("data:")||!Object.keys(this.queryParams).length)return t;let s=new URLSearchParams(this.queryParams).toString();return`${t}${t.includes("?")?"&":"?"}${s}`}getViewState(t){let s=this.getMetadata(),r=s.tileset.fullExtent;if(r){let{xmin:i,xmax:o,ymin:a,ymax:c,zmin:h,zmax:l}=r,u=new m(i+(o-i)/2,a+(c-a)/2,h+(l-h)/2),d=new m;return w.WGS84.cartographicToCartesian(u,d),{cartographicCenter:u,cartesianCenter:d,zoom:ar(r,u,d)}}let n=s.tileset.store?.extent;if(n){let[i,o,a,c]=n,h=new m(i+(a-i)/2,o+(c-o)/2,0),l=new m;return w.WGS84.cartographicToCartesian(h,l),{cartographicCenter:h,cartesianCenter:l,zoom:bi(n,h,l)}}return console.warn("Extent is not defined in the tileset header"),{cartographicCenter:new m,zoom:1}}onTileLoaded(t,s){switch(s.header.isDracoGeometry&&(this.contentFormats.draco=!0),s.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}}getTilesTotalCount(){return this.getMetadata().tileset?.nodePagesTile?.nodesInNodePages||null}async loadWithCoreApi(t,s){if(!this.coreApi)throw new Error("I3SSource requires an injected coreApi to load tileset data");return await this.coreApi.load(t,this.loader,s)}async loadRootData(t,s){return this.resolver?await this.resolver.loadRoot(t,this.loader,s):await this.loadWithCoreApi(t,s)}async loadResourceData(t,s){return this.resolver?await this.resolver.loadResource(t,this.loader,s):await this.loadWithCoreApi(t,s)}};function vi(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function Oh(e){return vi(e)?{...e,basePath:e.basePath||J.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||J.dirname(e.url),resolver:e.resolver,coreApi:e.coreApi}}var Et=class{index;parent;children;content;error;id;zoom;userData;boundingBox;_abortController;_loader;_loaderId;_isLoaded;_isCancelled;_needsReload;_bbox;constructor(t){this.index=t,this.parent=null,this.children=[],this.content=null,this.error=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(t){this._bbox||(this._bbox=t,"west"in t?this.boundingBox=[[t.west,t.south],[t.east,t.north]]:this.boundingBox=[[t.left,t.top],[t.right,t.bottom]])}get data(){let t=this._loader;return!this._isCancelled&&t!==void 0?t.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get hasError(){return!!this.error}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let t=this.content?this.content.byteLength:0;return Number.isFinite(t)?t:0}async _loadData({getData:t,requestScheduler:s,onLoad:r,onError:n}){let i=(p,y,E)=>{if(E===this._loaderId){if(this._loader=void 0,this.content=p,this.error=y?Ah(y):null,this._isCancelled&&!p){this._isLoaded=!1;return}if(this._isLoaded=!0,this._isCancelled=!1,y){n(y,this);return}r(this)}},{index:o,id:a,bbox:c,userData:h,zoom:l}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:d}=this._abortController,f=await s.scheduleRequest(this,()=>1);if(!f){this._isCancelled=!0;return}if(this._isCancelled){f.done();return}let g=null,x;try{g=await t({index:o,id:a,bbox:c,userData:h,zoom:l,signal:d})}catch(p){x=p||!0}finally{f.done()}i(g,x,u)}loadData(t){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this.error=null,this._loaderId++,this._loader=this._loadData(t),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};function Ah(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}var ur="never",dr="no-overlap",ee="best-available",Ii={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:ee,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},te=class e{stats;sourceMetadata=null;opts;_requestScheduler;_cache;_dirty;_tiles;_cacheByteSize;_unloadedTileCount;_listeners=new Set;_consumers=new Map;_explicitOptionKeys=new Set;_baseOpts={};_sourceMetadataOverrides={};_maxZoom;_minZoom;_lastTileContext=null;constructor(t){if(this.stats=new tt({id:"Tileset2D",stats:[{name:"Tiles In Cache"},{name:"Cache Size"},{name:"Visible Tiles"},{name:"Selected Tiles"},{name:"Loading Tiles"},{name:"Unloaded Tiles"},{name:"Consumers"}]}),this.opts={...Ii,...t,getTileData:t.getTileData||(()=>null),tileSource:t.tileSource},this._requestScheduler=new ht({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._unloadedTileCount=0,!this.opts.tileSource&&!t.getTileData)throw new Error("Tileset2D requires either `getTileData` or `tileSource`.");this.setOptions(t),this._updateStats(),this.opts.tileSource&&this._initializeTileSource(this.opts.tileSource).catch(()=>{})}static fromTileSource(t,s={}){return new e({...s,tileSource:t})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let t=this._getVisibleTilesUnion();for(let s of this._getSelectedTilesUnion())t.add(s);return Array.from(t)}get loadingTiles(){return Array.from(this._cache.values()).filter(t=>t.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(t=>!t.isLoaded)}get maxZoom(){return this._maxZoom}get minZoom(){return this._minZoom}get refinementStrategy(){return this.opts.refinementStrategy||ee}get adapter(){return this.opts.adapter}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}attachConsumer(t){this._consumers.set(t,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(t){this._consumers.delete(t),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(t){this._rememberExplicitOptions(t),this._baseOpts={...this._baseOpts,...t};let s=this.opts.maxRequests,r=this.opts.debounceTime;this._applyResolvedOptions(),(s!==this.opts.maxRequests||r!==this.opts.debounceTime)&&(this._requestScheduler=new ht({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}))}finalize(){for(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._consumers.clear(),this._cacheByteSize=0,this._unloadedTileCount=0,this._updateStats()}reloadAll(){let t=this._getSelectedTilesUnion();for(let s of this._cache.keys()){let r=this._cache.get(s);r&&!t.has(r)?(this._cache.delete(s),this._handleTileUnload(r),this._dirty=!0):r&&r.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,s,r){this._consumers.set(t,{selectedTiles:new Set(s),visibleTiles:new Set(r)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:s,minZoom:r,zRange:n,modelMatrix:i,modelMatrixInverse:o}){let{adapter:a,tileSize:c,extent:h,zoomOffset:l}=this.opts;if(!a)throw new Error("Tileset2D requires an adapter before tile traversal can be used.");return this._lastTileContext={viewState:t,tileSize:c},a.getTileIndices({viewState:t,maxZoom:s,minZoom:r,zRange:n,tileSize:c,extent:vh(h),modelMatrix:i,modelMatrixInverse:o,zoomOffset:l})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){if(!this._lastTileContext)throw new Error("Tileset2D metadata requested before traversal context was set.");if(!this.opts.adapter)throw new Error("Tileset2D requires an adapter before tile metadata can be derived.");return{bbox:this.opts.adapter.getTileBoundingBox(this._lastTileContext,t)}}getParentIndex(t){return{x:Math.floor(t.x/2),y:Math.floor(t.y/2),z:t.z-1}}getTile(t,s){let r=this.getTileId(t),n=this._cache.get(r),i=!1;return!n&&s?(n=new Et(t),Object.assign(n,this.getTileMetadata(n.index)),Object.assign(n,{id:r,zoom:this.getTileZoom(n.index)}),i=!0,this._cache.set(r,n),this._dirty=!0,this._updateStats()):n&&n.needsReload&&(i=!0),n&&this._touchTile(r,n),n&&i&&s&&(n.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),this._updateStats()),n}async _initializeTileSource(t){try{this.sourceMetadata=await t.getMetadata(),this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(s){let r=s instanceof Error?s:new Error(`TileSource metadata error: ${String(s)}`);this._notifyError(r)}}_rememberExplicitOptions(t){for(let s of Object.keys(t))this._explicitOptionKeys.add(s)}_applyResolvedOptions(){let t={...Ii,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let s=t.tileSource;t.getTileData=r=>s.getTileData(r)}this.opts=t,this._maxZoom=typeof this.opts.maxZoom=="number"&&Number.isFinite(this.opts.maxZoom)?Math.floor(this.opts.maxZoom):void 0,this._minZoom=typeof this.opts.minZoom=="number"&&Number.isFinite(this.opts.minZoom)?Math.ceil(this.opts.minZoom):void 0}_getMetadataOverrides(t){if(!t)return{};let s={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(t.minZoom)&&(s.minZoom=t.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(t.maxZoom)&&(s.maxZoom=t.maxZoom),!this._explicitOptionKeys.has("extent")&&t.boundingBox&&(s.extent=[t.boundingBox[0][0],t.boundingBox[0][1],t.boundingBox[1][0],t.boundingBox[1][1]]),s}_handleTileLoad(t){this.opts.onTileLoad?.(t),this._cacheByteSize=this._getCacheByteSize(),this._resizeCache();for(let s of this._listeners)s.onTileLoad?.(t);this._updateStats()}_handleTileError(t,s){this.opts.onTileError?.(t,s);for(let r of this._listeners)r.onTileError?.(t,s);this._updateStats()}_handleTileUnload(t){this._unloadedTileCount++,this.opts.onTileUnload?.(t);for(let s of this._listeners)s.onTileUnload?.(t);this._updateStats()}_notifyUpdate(){for(let t of this._listeners)t.onUpdate?.()}_notifyError(t){for(let s of this._listeners)s.onError?.(t)}_updateStats(){this._setStatCount("Tiles In Cache",this._cache.size),this._setStatCount("Cache Size",this.cacheByteSize),this._setStatCount("Visible Tiles",this.visibleTiles.length),this._setStatCount("Selected Tiles",this.selectedTiles.length),this._setStatCount("Loading Tiles",this.loadingTiles.length),this._setStatCount("Unloaded Tiles",this._unloadedTileCount),this._setStatCount("Consumers",this._consumers.size);for(let t of this._listeners)t.onStatsChange?.(this.stats)}_setStatCount(t,s){this.stats.get(t).reset().addCount(s)}_getSelectedTilesUnion(){let t=new Set;for(let s of this._consumers.values())for(let r of s.selectedTiles)t.add(r);return t}_getVisibleTilesUnion(){let t=new Set;for(let s of this._consumers.values())for(let r of s.visibleTiles)t.add(r);return t}_touchTile(t,s){this._cache.delete(t),this._cache.set(t,s)}_getCacheByteSize(){let t=0;for(let s of this._cache.values())t+=s.byteLength;return t}_pruneRequests(){let{maxRequests:t=0}=this.opts,s=this._getSelectedTilesUnion(),r=this._getVisibleTilesUnion(),n=[],i=0;for(let o of this._cache.values())o.isLoading&&(i++,!s.has(o)&&!r.has(o)&&n.push(o));for(;t>0&&i>t&&n.length>0;){let o=n.shift();o&&o.abort(),i--}}_rebuildTree(){for(let t of this._cache.values())t.parent=null,t.children&&(t.children.length=0);for(let t of this._cache.values()){let s=this._getNearestAncestor(t);t.parent=s,s?.children&&s.children.push(t)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((t,s)=>t.zoom-s.zoom)}_resizeCache(){let t=this.opts.maxCacheSize??100,s=this.opts.maxCacheByteSize??1/0,r=this._getVisibleTilesUnion(),n=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>s){for(let[o,a]of this._cache)if(!r.has(a)&&!n.has(a)&&(this._cache.delete(o),this._cacheByteSize=this._getCacheByteSize(),this._handleTileUnload(a)),this._cache.size<=t&&this._cacheByteSize<=s)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(t){let{_minZoom:s=0}=this,r=t.index;for(;this.getTileZoom(r)>s;){r=this.getParentIndex(r);let n=this.getTile(r);if(n)return n}return null}};function vh(e){return e&&e.length===4?e:void 0}var Ke={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},Je=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.imageSource&&(!t.getImage||!t.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(t,s={}){return new e({...s,imageSource:t})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get image(){return this._currentRequest?.image||null}get currentRequest(){return this._currentRequest}get imageSource(){return this._opts.imageSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let s=this._opts.imageSource,r=this._normalizeOptions({...this._opts,...t}),n=s!==r.imageSource||this._opts.getImage!==r.getImage||this._opts.getMetadata!==r.getMetadata;this._opts=r,n&&(this._cancelScheduledImage(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let t=await this._opts.getMetadata();if(this._finalized)return t;this.metadata=t;for(let s of this._listeners)s.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let s=Li(t,"Image metadata request failed");if(!this._finalized)for(let r of this._listeners)r.onMetadataLoadError?.(s);throw s}finally{this._finishLoading()}}requestImage(t,s=this._opts.debounceTime){let r=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),s>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(r,t)},s):this._loadImage(r,t),r}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,s){if(!this._finalized){this._startLoading();for(let r of this._listeners)r.onImageLoadStart?.(t,s);try{let r=new AbortController;this._abortController=r;let n=await this._opts.getImage({...s,signal:r.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:s,image:n};for(let i of this._listeners)i.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(r){if(Ih(r))return;let n=Li(r,"Image request failed");if(!this._finalized)for(let i of this._listeners)i.onImageLoadError?.(t,n,s)}finally{this._abortController?.signal===s.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let s=t.imageSource||null;return{...Ke,...t,imageSource:s,getMetadata:t.getMetadata||(()=>s?s.getMetadata():Ke.getMetadata()),getImage:t.getImage||(r=>s?s.getImage(r):Ke.getImage(r)),debounceTime:t.debounceTime??Ke.debounceTime}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(t){for(let s of this._listeners)s.onLoadingStateChange?.(t)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function Ih(e){return e instanceof Error&&e.name==="AbortError"}function Li(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}var se={getMetadata:async()=>({width:0,height:0,bandCount:0,dtype:"uint8"}),getRaster:async()=>({data:new Uint8Array(0),width:0,height:0,bandCount:0,dtype:"uint8"}),debounceTime:0,shouldRefetch:()=>!0},ts=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.rasterSource&&(!t.getRaster||!t.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(t,s={}){return new e({...s,rasterSource:t})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get raster(){return this._currentRequest?.raster||null}get currentRequest(){return this._currentRequest}get rasterSource(){return this._opts.rasterSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let s=this._opts.rasterSource,r=this._normalizeOptions({...this._opts,...t}),n=s!==r.rasterSource||this._opts.getRaster!==r.getRaster||this._opts.getMetadata!==r.getMetadata;this._opts=r,n&&(this._cancelScheduledRaster(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let t=await this._opts.getMetadata();if(this._finalized)return t;this.metadata=t;for(let s of this._listeners)s.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let s=Pi(t,"Raster metadata request failed");if(!this._finalized)for(let r of this._listeners)r.onMetadataLoadError?.(s);throw s}finally{this._finishLoading()}}requestRaster(t,s=this._opts.debounceTime){if(!this.shouldRefetchRaster(t))return this._currentRequest?.requestId??-1;let r=this._nextRequestId++;return this._cancelScheduledRaster(),s>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(r,t)},s):this._loadRaster(r,t),r}shouldRefetchRaster(t){return this._opts.shouldRefetch({currentRequest:this._currentRequest,metadata:this.metadata,nextParameters:t})}finalize(){this._finalized=!0,this._cancelScheduledRaster(),this._abortActiveRequest(),this._listeners.clear()}async _loadRaster(t,s){if(!this._finalized){this._startLoading();for(let r of this._listeners)r.onRasterLoadStart?.(t,s);try{let r=new AbortController;this._abortController=r;let n=await this._opts.getRaster({...s,signal:r.signal});if(this._finalized||r.signal.aborted||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:s,raster:n};for(let i of this._listeners)i.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(r){if(Lh(r))return;let n=Pi(r,"Raster request failed");if(!this._finalized)for(let i of this._listeners)i.onRasterLoadError?.(t,n,s)}finally{this._abortController=null,this._finishLoading()}}}_normalizeOptions(t){let s=t.rasterSource||null;return{...se,...t,rasterSource:s,getMetadata:t.getMetadata||(()=>s?s.getMetadata():se.getMetadata()),getRaster:t.getRaster||(r=>s?s.getRaster(r):se.getRaster(r)),debounceTime:t.debounceTime??se.debounceTime,shouldRefetch:t.shouldRefetch||(r=>se.shouldRefetch(r))}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_emitLoadingStateChange(t){for(let s of this._listeners)s.onLoadingStateChange?.(t)}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_cancelScheduledRaster(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function Pi(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function Lh(e){return e instanceof Error&&e.name==="AbortError"}var qt=class{header;parent;children=[];childrenLoaded=!1;childrenPromise=null;selected=!1;viewportIds=[];content=null;contentAvailable=!1;contentFailed=!1;isContentLoading=!1;constructor(t,s=null){this.header=t,this.parent=s}get id(){return this.header.id}get level(){return this.header.level}get pointCount(){return this.header.pointCount}get geometricError(){return this.header.geometricError}get boundingVolume(){return this.header.boundingVolume}setSelected(t){this.selected=!0,this.viewportIds.includes(t)||this.viewportIds.push(t)}clearSelection(){this.selected=!1,this.viewportIds=[]}};var Ph={debounceTime:0,minimumNodePixelSize:150,maximumScreenSpaceError:1,pointBudget:2e6,maxDepth:Number.POSITIVE_INFINITY,onTileLoad:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{}},es=64,ss=class{dataSource;options;root=null;cartographicCenter=null;zoom=1;boundingVolume=null;visibleTilesCount=0;frameNumberValue=0;pendingCount=0;lastUpdatedViewports=null;updatePromise=null;tilesMap=new Map;constructor(t,s={}){this.dataSource=t,this.options={...Ph,...s},this.tilesetInitializationPromise=this.initialize()}tilesetInitializationPromise;get isReady(){return this.dataSource.isReady}get frameNumber(){return this.frameNumberValue}get tiles(){return Array.from(this.tilesMap.values())}isLoaded(){return this.frameNumberValue>0&&this.pendingCount===0&&this.selectedTiles.every(t=>t.contentAvailable||t.contentFailed)}selectedTiles=[];update(t=null){this.selectTiles(t).catch(()=>{})}destroy(){this.selectedTiles=[],this.tilesMap.clear(),this.root=null,this.cartographicCenter=null,this.boundingVolume=null,this.visibleTilesCount=0,this.pendingCount=0,this.lastUpdatedViewports=null,this.updatePromise=null}async initialize(){await this.dataSource.initialize();let t=await this.dataSource.getRootTile();this.root=this.getOrCreateTile(t,null);let s=await this.dataSource.getViewState?.();this.boundingVolume=s?.boundingVolume||this.root.boundingVolume;let r=s?.cartographicCenter||this.root.boundingVolume.center;this.cartographicCenter=new m(r),this.zoom=s?.zoom||this.estimateZoom(this.boundingVolume)}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedViewports=t),this.updatePromise||(this.updatePromise=new Promise((s,r)=>{setTimeout(()=>{this.doSelectTiles().then(()=>s(this.frameNumberValue)).catch(r).finally(()=>{this.updatePromise=null})},this.options.debounceTime)})),this.updatePromise}async doSelectTiles(){if(!this.root||!this.lastUpdatedViewports)return;let t=new Set(this.selectedTiles.map(a=>a.id));for(let a of this.tilesMap.values())a.clearSelection();this.frameNumberValue++;let s=Array.isArray(this.lastUpdatedViewports)?this.lastUpdatedViewports:[this.lastUpdatedViewports],r=new Map,n=new Set,i=0;for(let a of s){let c=this.getTraversalContext(a);i=await this.traverseTiles(c,r,i,n)}this.visibleTilesCount=n.size,this.selectedTiles=this.options.onTraversalComplete(Array.from(r.values()));for(let a of this.selectedTiles)this.loadTile(a).catch(()=>{});let o=new Set(this.selectedTiles.map(a=>a.id));this.haveSameIds(t,o)||this.options.onUpdate()}async traverseTiles(t,s,r,n){if(!this.root)return r;let i=r,o=[{tile:this.root,weight:this.estimateScreenRadius(this.root,t.viewport)}];for(;o.length>0;){o.sort((u,d)=>d.weight-u.weight);let a=o.shift();if(!a)break;let{tile:c,weight:h}=a;if(!this.isVisible(c,t))continue;if(n.add(c.id),!s.has(c.id)&&c.pointCount>0){if(i>0&&i+c.pointCount>this.options.pointBudget)break;s.set(c.id,c),i+=c.pointCount}if(s.has(c.id)&&c.setSelected(t.viewport.id),!this.shouldRefine(c,h))continue;let l=await this.getVisibleChildren(c,t);l.length>0&&o.push(...l)}return i}shouldRefine(t,s){return t.level<this.options.maxDepth&&Number.isFinite(s)&&s>=this.options.minimumNodePixelSize}getTraversalContext(t){let s=this.getCullingVolume(t);return{viewport:t,cullingVolume:this.shouldUseCullingVolume(t,s)?s:null}}isVisible(t,s){if(s.cullingVolume){let n=this.getCommonSpaceBoundingSphere(t.boundingVolume,s.viewport);if(n)return this.isBoundingSphereInsideCullingVolume(n,s.cullingVolume)}let r=this.getProjectedFootprint(t.boundingVolume,s.viewport);return r?this.isProjectedFootprintVisible(r,s.viewport):!1}shouldUseCullingVolume(t,s){if(!this.root||!s)return!1;let r=this.getCommonSpaceBoundingSphere(this.root.boundingVolume,t);if(!r)return!1;if(this.isBoundingSphereInsideCullingVolume(r,s))return!0;let n=this.getProjectedFootprint(this.root.boundingVolume,t);return!n||!this.isProjectedFootprintVisible(n,t)}isBoundingSphereInsideCullingVolume(t,s){return s.computeVisibilityWithPlaneMask(t,k.MASK_INDETERMINATE)!==k.MASK_OUTSIDE}isProjectedFootprintVisible(t,s){return!(t.x+t.radius<-es||t.x-t.radius>s.width+es||t.y+t.radius<-es||t.y-t.radius>s.height+es)}estimateScreenRadius(t,s){let r=this.getProjectedFootprint(t.boundingVolume,s);return r?r.radius:0}projectBounds(t,s){let r=this.getBoundingVolumeCorners(t),n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;try{for(let c of r){let[h,l]=s.project(c);!Number.isFinite(h)||!Number.isFinite(l)||(n=Math.min(n,h),i=Math.min(i,l),o=Math.max(o,h),a=Math.max(a,l))}}catch{return null}return!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(a)?null:{minX:n,minY:i,maxX:o,maxY:a}}getProjectedFootprint(t,s){let r=Number.NaN,n=Number.NaN;try{[r,n]=s.project(t.center)}catch{return null}if(!Number.isFinite(r)||!Number.isFinite(n))return null;let i=this.getBoundingVolumeCorners(t),o=0;try{for(let a of i){let[c,h]=s.project(a);!Number.isFinite(c)||!Number.isFinite(h)||(o=Math.max(o,Math.hypot(c-r,h-n)))}}catch{return null}if(o===0){let a=this.projectBounds(t,s);a&&(o=Math.max(a.maxX-a.minX,a.maxY-a.minY)/2)}return{x:r,y:n,radius:o}}async getVisibleChildren(t,s){return t.level>=this.options.maxDepth?[]:(await this.getChildren(t)).map(n=>({tile:n,weight:this.estimateScreenRadius(n,s.viewport)})).filter(n=>this.isVisible(n.tile,s))}async getChildren(t){if(t.childrenLoaded)return t.children;if(!t.childrenPromise){let s=this.dataSource.getChildren(t.header).then(r=>r.map(n=>this.getOrCreateTile(n,t))).then(r=>(t.children=r,t.childrenLoaded=!0,r));t.childrenPromise=s.finally(()=>{t.childrenPromise===s&&(t.childrenPromise=null)})}return t.childrenPromise}getOrCreateTile(t,s){let r=this.tilesMap.get(t.id);if(r)return r.header=t,s&&r.parent!==s&&(r.parent=s),r;let n=new qt(t,s);return this.tilesMap.set(t.id,n),s&&!s.children.find(i=>i.id===n.id)&&s.children.push(n),n}async loadTile(t){if(!(t.contentAvailable||t.isContentLoading||t.contentFailed)){t.isContentLoading=!0,this.pendingCount++;try{let s=await this.dataSource.loadTileContent(t.header);t.content=s,t.contentAvailable=!0,s&&this.options.onTileLoad(t)}catch(s){t.contentFailed=!0,this.options.onTileError(t,s)}finally{t.isContentLoading=!1,this.pendingCount--}}}estimateZoom(t){if(!t)return 1;let[s,r]=t.cartographicBounds,n=Math.max(Math.abs(r[0]-s[0]),1e-6);return Math.max(1,Math.round(Math.log2(360/n)))}haveSameIds(t,s){if(t.size!==s.size)return!1;for(let r of t)if(!s.has(r))return!1;return!0}getBoundingVolumeCorners(t){let[s,r]=t.cartographicBounds;return[[s[0],s[1],s[2]||0],[s[0],s[1],r[2]||0],[s[0],r[1],s[2]||0],[s[0],r[1],r[2]||0],[r[0],s[1],s[2]||0],[r[0],s[1],r[2]||0],[r[0],r[1],s[2]||0],[r[0],r[1],r[2]||0]]}getCullingVolume(t){let s=t.getFrustumPlanes?.bind(t);if(!s)return null;let r=s(),n=["left","right","bottom","top","near","far"],i=[];for(let o of n){let a=r[o];if(!a)return null;i.push(new W(a.normal,-a.distance))}return new k(i)}getCommonSpaceBoundingSphere(t,s){let r=s.projectPosition?.bind(s);if(!r)return null;let n=this.getBoundingVolumeCorners(t),i=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;try{for(let u of n){let[d,f,g=0]=r(u);!Number.isFinite(d)||!Number.isFinite(f)||!Number.isFinite(g)||(i=Math.min(i,d),o=Math.min(o,f),a=Math.min(a,g),c=Math.max(c,d),h=Math.max(h,f),l=Math.max(l,g))}}catch{return null}return!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(h)||!Number.isFinite(l)?null:new Z().fromCornerPoints([i,o,a],[c,h,l])}};return Ui(re);})();
|
|
7
|
+
"use strict";var __exports__=(()=>{var A0=Object.create;var Wr=Object.defineProperty;var I0=Object.getOwnPropertyDescriptor;var O0=Object.getOwnPropertyNames;var N0=Object.getPrototypeOf,L0=Object.prototype.hasOwnProperty;var G0=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},$e=(e,t)=>{for(var r in t)Wr(e,r,{get:t[r],enumerable:!0})},jr=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of O0(t))!L0.call(e,i)&&i!==r&&Wr(e,i,{get:()=>t[i],enumerable:!(s=I0(t,i))||s.enumerable});return e},Hr=(e,t,r)=>(jr(e,t,"default"),r&&jr(r,t,"default")),z0=(e,t,r)=>(r=e!=null?A0(N0(e)):{},jr(t||!e||!e.__esModule?Wr(r,"default",{value:e,enumerable:!0}):r,e)),q0=e=>jr(Wr({},"__esModule",{value:!0}),e);var Ro=G0((D_,bo)=>{bo.exports=globalThis.loaders});var Vr={};$e(Vr,{I3SSource:()=>mi,I3SSpatialTransformer:()=>Ye,ImageSet:()=>pi,IndexedArchiveTilesetSource:()=>Ls,LOD_METRIC_TYPE:()=>Ce,PointCloudTile:()=>Ze,PointCloudTileset:()=>Mi,RasterSet:()=>gi,STRATEGY_DEFAULT:()=>Fr,STRATEGY_NEVER:()=>Eo,STRATEGY_REPLACE:()=>wo,SharedTile2DHeader:()=>Me,SpatialCoordinateTransformer:()=>te,TILESET_TYPE:()=>lt,TILE_CONTENT_STATE:()=>it,TILE_REFINEMENT:()=>st,TILE_TYPE:()=>qt,Tile3D:()=>bt,Tiles3DSource:()=>Vs,Tileset2D:()=>Dr,Tileset3D:()=>Ns,TilesetCache:()=>Re,TilesetTraverser:()=>Bt,applyTilesetSpatialOptions:()=>pr,calculateTransformProps:()=>bs,createBoundingVolume:()=>Ae,createImplicitSubtreeReference:()=>qn,createTilesetSpatialReference:()=>Pt,get3DTilesSpatialReference:()=>Ds,getFrameState:()=>Rs,getGeoidModel:()=>ui,getI3SSpatialReference:()=>Bs,getLodStatus:()=>zs,getSpatialCoordinateFrame:()=>Ht,isTileset3DSource:()=>Os,markTilesetSpatialReferenceTransformed:()=>Is,materializeImplicitSubtree:()=>Fs,registerGeoidModel:()=>_o,registerGeoidModelFromPgm:()=>n0,registerSpatialCrs:()=>s0,registerSpatialDatumGrid:()=>i0,replaceImplicitUrlTemplate:()=>Us});Hr(Vr,z0(Ro(),1));var U={};$e(U,{EPSILON1:()=>B0,EPSILON10:()=>Y0,EPSILON11:()=>Z0,EPSILON12:()=>$0,EPSILON13:()=>Q0,EPSILON14:()=>Yr,EPSILON15:()=>X0,EPSILON16:()=>K0,EPSILON17:()=>J0,EPSILON18:()=>tu,EPSILON19:()=>eu,EPSILON2:()=>D0,EPSILON20:()=>ru,EPSILON3:()=>F0,EPSILON4:()=>U0,EPSILON5:()=>V0,EPSILON6:()=>k0,EPSILON7:()=>j0,EPSILON8:()=>W0,EPSILON9:()=>H0,PI:()=>ye,PI_OVER_FOUR:()=>iu,PI_OVER_SIX:()=>nu,PI_OVER_TWO:()=>su,TWO_PI:()=>Qe});var B0=.1,D0=.01,F0=.001,U0=1e-4,V0=1e-5,k0=1e-6,j0=1e-7,W0=1e-8,H0=1e-9,Y0=1e-10,Z0=1e-11,$0=1e-12,Q0=1e-13,Yr=1e-14,X0=1e-15,K0=1e-16,J0=1e-17,tu=1e-18,eu=1e-19,ru=1e-20,su=Math.PI/2,iu=Math.PI/4,nu=Math.PI/6,ye=Math.PI,Qe=Math.PI*2;var ou=1/Math.PI*180,au=1/180*Math.PI,hu={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...hu}};var k=globalThis.mathgl.config;function wi(e,{precision:t=k.precision}={}){return e=lu(e),`${parseFloat(e.toPrecision(t))}`}function vt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ti(e){return Zr(e)}function Pi(e){return ct(e)}function Zr(e,t){return Ri(e,r=>r*au,t)}function ct(e,t){return Ri(e,r=>r*ou,t)}function Co(e,t){return Math.sign(e)===Math.sign(t)&&Math.abs(e)<Math.abs(t)?e:(e%t+t)%t}function bi(e,t){switch(t){case"negative-pi-to-pi":return cu(e);case"zero-to-two-pi":return Ao(e);default:return e}}function Ao(e){if(e>=0&&e<=Qe)return e;let t=Co(e,Qe);return Math.abs(t)<1e-14&&Math.abs(e)>1e-14?Qe:t}function cu(e){return e>=-ye&&e<=ye?e:Ao(e+ye)-ye}function Xe(e,t,r){return Ri(e,s=>Math.max(t,Math.min(r,s)))}function Mt(e,t,r){let s=k.EPSILON;r&&(k.EPSILON=r);try{if(e===t)return!0;if(vt(e)&&vt(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!Mt(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=k.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{k.EPSILON=s}}function lu(e){return Math.round(e/k.EPSILON)*k.EPSILON}function uu(e){return e.clone?e.clone():new Array(e.length)}function Ri(e,t,r){if(vt(e)){let s=e;r=r||uu(s);for(let i=0;i<r.length&&i<s.length;++i){let n=typeof e=="number"?e:e[i];r[i]=t(n,i,r)}return r}return t(e)}var ee=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let s=0;s<this.ELEMENTS;++s)this[s]=t[s+r];return this.check()}toArray(t=[],r=0){for(let s=0;s<this.ELEMENTS;++s)t[r+s]=this[s];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:vt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(k)}formatString(t){let r="";for(let s=0;s<this.ELEMENTS;++s)r+=(s>0?", ":"")+wi(this[s],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Mt(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,s){if(s===void 0)return this.lerp(this,t,r);for(let i=0;i<this.ELEMENTS;++i){let n=t[i],o=typeof r=="number"?r:r[i];this[i]=n+s*(o-n)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let s=0;s<this.ELEMENTS;++s)this[s]=Math.min(Math.max(this[s],t[s]),r[s]);return this.check()}add(...t){for(let r of t)for(let s=0;s<this.ELEMENTS;++s)this[s]+=r[s];return this.check()}subtract(...t){for(let r of t)for(let s=0;s<this.ELEMENTS;++s)this[s]-=r[s];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(k.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=t;return this.check()}addScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,r){for(let s=0;s<this.ELEMENTS;++s)this[s]=Math.min(Math.max(this[s],t),r);return this.check()}get elements(){return this}};function fu(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function G(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function re(e,t,r=""){if(k.debug&&!fu(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}var Se=class extends ee{toString(){let t="[";if(k.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let s=0;s<this.RANK;++s)t+=` ${this[s*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,s){return this[r*this.RANK+t]=G(s),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let s=t*this.RANK;for(let i=0;i<this.RANK;++i)r[i]=this[s+i];return r}setColumn(t,r){let s=t*this.RANK;for(let i=0;i<this.RANK;++i)this[s+i]=r[i];return this}};function J(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var se=class extends ee{get x(){return this[0]}set x(t){this[0]=G(t)}get y(){return this[1]}set y(t){this[1]=G(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let s=0;s<this.ELEMENTS;++s){let i=this[s]-t[s];r+=i*i}return G(r)}dot(t){let r=0;for(let s=0;s<this.ELEMENTS;++s)r+=this[s]*t[s];return G(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let s=0;s<this.ELEMENTS;++s)this[s]*=r[s];return this.check()}divide(...t){for(let r of t)for(let s=0;s<this.ELEMENTS;++s)this[s]/=r[s];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return J(t>=0&&t<this.ELEMENTS,"index is out of range"),G(this[t])}setComponent(t,r){return J(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){return this.add(new this.constructor(t).multiplyScalar(r))}};var H=typeof Float32Array<"u"?Float32Array:Array,Ke=Math.random;function ve(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var eM=Math.PI/180;function mu(){let e=new H(2);return H!==Float32Array&&(e[0]=0,e[1]=0),e}function Io(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[2]*i,e[1]=r[1]*s+r[3]*i,e}function Oo(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[2]*i+r[4],e[1]=r[1]*s+r[3]*i+r[5],e}function $r(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[3]*i+r[6],e[1]=r[1]*s+r[4]*i+r[7],e}function Qr(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[4]*i+r[12],e[1]=r[1]*s+r[5]*i+r[13],e}var rM=(function(){let e=mu();return function(t,r,s,i,n,o){let a,h;for(r||(r=2),s||(s=0),i?h=Math.min(i*r+s,t.length):h=t.length,a=s;a<h;a+=r)e[0]=t[a],e[1]=t[a+1],n(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();function Xr(e,t,r){let s=t[0],i=t[1],n=r[3]*s+r[7]*i||1;return e[0]=(r[0]*s+r[4]*i)/n,e[1]=(r[1]*s+r[5]*i)/n,e}function Kr(e,t,r){let s=t[0],i=t[1],n=t[2],o=r[3]*s+r[7]*i+r[11]*n||1;return e[0]=(r[0]*s+r[4]*i+r[8]*n)/o,e[1]=(r[1]*s+r[5]*i+r[9]*n)/o,e[2]=(r[2]*s+r[6]*i+r[10]*n)/o,e}function No(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[2]*i,e[1]=r[1]*s+r[3]*i,e[2]=t[2],e}function Lo(e,t,r){let s=t[0],i=t[1];return e[0]=r[0]*s+r[2]*i,e[1]=r[1]*s+r[3]*i,e[2]=t[2],e[3]=t[3],e}function Jr(e,t,r){let s=t[0],i=t[1],n=t[2];return e[0]=r[0]*s+r[3]*i+r[6]*n,e[1]=r[1]*s+r[4]*i+r[7]*n,e[2]=r[2]*s+r[5]*i+r[8]*n,e[3]=t[3],e}var Et=class extends se{constructor(t=0,r=0){super(2),vt(t)&&arguments.length===1?this.copy(t):(k.debug&&(G(t),G(r)),this[0]=t,this[1]=r)}set(t,r){return this[0]=t,this[1]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this.check()}fromObject(t){return k.debug&&(G(t.x),G(t.y)),this[0]=t.x,this[1]=t.y,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Qr(this,this,t),this.check()}transformAsVector(t){return Xr(this,this,t),this.check()}transformByMatrix3(t){return $r(this,this,t),this.check()}transformByMatrix2x3(t){return Oo(this,this,t),this.check()}transformByMatrix2(t){return Io(this,this,t),this.check()}};var we={};$e(we,{add:()=>Mu,angle:()=>Ni,bezier:()=>Iu,ceil:()=>xu,clone:()=>pu,copy:()=>gu,create:()=>ts,cross:()=>he,dist:()=>Fu,distance:()=>Do,div:()=>Du,divide:()=>Bo,dot:()=>Je,equals:()=>zu,exactEquals:()=>Gu,floor:()=>yu,forEach:()=>ku,fromValues:()=>es,hermite:()=>Au,inverse:()=>bu,len:()=>Li,length:()=>Go,lerp:()=>Ru,max:()=>vu,min:()=>Su,mul:()=>Bu,multiply:()=>qo,negate:()=>Pu,normalize:()=>Ci,random:()=>Ou,rotateX:()=>Ai,rotateY:()=>Ii,rotateZ:()=>Oi,round:()=>Eu,scale:()=>wu,scaleAndAdd:()=>Tu,set:()=>_u,slerp:()=>Cu,sqrDist:()=>Uu,sqrLen:()=>Vu,squaredDistance:()=>Fo,squaredLength:()=>Uo,str:()=>Lu,sub:()=>qu,subtract:()=>zo,transformMat3:()=>tr,transformMat4:()=>ce,transformQuat:()=>er,zero:()=>Nu});function ts(){let e=new H(3);return H!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function pu(e){let t=new H(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Go(e){let t=e[0],r=e[1],s=e[2];return Math.sqrt(t*t+r*r+s*s)}function es(e,t,r){let s=new H(3);return s[0]=e,s[1]=t,s[2]=r,s}function gu(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function _u(e,t,r,s){return e[0]=t,e[1]=r,e[2]=s,e}function Mu(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function zo(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function qo(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Bo(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function xu(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function yu(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Su(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function vu(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Eu(e,t){return e[0]=ve(t[0]),e[1]=ve(t[1]),e[2]=ve(t[2]),e}function wu(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Tu(e,t,r,s){return e[0]=t[0]+r[0]*s,e[1]=t[1]+r[1]*s,e[2]=t[2]+r[2]*s,e}function Do(e,t){let r=t[0]-e[0],s=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+s*s+i*i)}function Fo(e,t){let r=t[0]-e[0],s=t[1]-e[1],i=t[2]-e[2];return r*r+s*s+i*i}function Uo(e){let t=e[0],r=e[1],s=e[2];return t*t+r*r+s*s}function Pu(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function bu(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Ci(e,t){let r=t[0],s=t[1],i=t[2],n=r*r+s*s+i*i;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function Je(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function he(e,t,r){let s=t[0],i=t[1],n=t[2],o=r[0],a=r[1],h=r[2];return e[0]=i*h-n*a,e[1]=n*o-s*h,e[2]=s*a-i*o,e}function Ru(e,t,r,s){let i=t[0],n=t[1],o=t[2];return e[0]=i+s*(r[0]-i),e[1]=n+s*(r[1]-n),e[2]=o+s*(r[2]-o),e}function Cu(e,t,r,s){let i=Math.acos(Math.min(Math.max(Je(t,r),-1),1)),n=Math.sin(i),o=Math.sin((1-s)*i)/n,a=Math.sin(s*i)/n;return e[0]=o*t[0]+a*r[0],e[1]=o*t[1]+a*r[1],e[2]=o*t[2]+a*r[2],e}function Au(e,t,r,s,i,n){let o=n*n,a=o*(2*n-3)+1,h=o*(n-2)+n,c=o*(n-1),l=o*(3-2*n);return e[0]=t[0]*a+r[0]*h+s[0]*c+i[0]*l,e[1]=t[1]*a+r[1]*h+s[1]*c+i[1]*l,e[2]=t[2]*a+r[2]*h+s[2]*c+i[2]*l,e}function Iu(e,t,r,s,i,n){let o=1-n,a=o*o,h=n*n,c=a*o,l=3*n*a,u=3*h*o,f=h*n;return e[0]=t[0]*c+r[0]*l+s[0]*u+i[0]*f,e[1]=t[1]*c+r[1]*l+s[1]*u+i[1]*f,e[2]=t[2]*c+r[2]*l+s[2]*u+i[2]*f,e}function Ou(e,t){t=t===void 0?1:t;let r=Ke()*2*Math.PI,s=Ke()*2-1,i=Math.sqrt(1-s*s)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=s*t,e}function ce(e,t,r){let s=t[0],i=t[1],n=t[2],o=r[3]*s+r[7]*i+r[11]*n+r[15];return o=o||1,e[0]=(r[0]*s+r[4]*i+r[8]*n+r[12])/o,e[1]=(r[1]*s+r[5]*i+r[9]*n+r[13])/o,e[2]=(r[2]*s+r[6]*i+r[10]*n+r[14])/o,e}function tr(e,t,r){let s=t[0],i=t[1],n=t[2];return e[0]=s*r[0]+i*r[3]+n*r[6],e[1]=s*r[1]+i*r[4]+n*r[7],e[2]=s*r[2]+i*r[5]+n*r[8],e}function er(e,t,r){let s=r[0],i=r[1],n=r[2],o=r[3],a=t[0],h=t[1],c=t[2],l=i*c-n*h,u=n*a-s*c,f=s*h-i*a,d=i*f-n*u,m=n*l-s*f,g=s*u-i*l,p=o*2;return l*=p,u*=p,f*=p,d*=2,m*=2,g*=2,e[0]=a+l+d,e[1]=h+u+m,e[2]=c+f+g,e}function Ai(e,t,r,s){let i=[],n=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],n[0]=i[0],n[1]=i[1]*Math.cos(s)-i[2]*Math.sin(s),n[2]=i[1]*Math.sin(s)+i[2]*Math.cos(s),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Ii(e,t,r,s){let i=[],n=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],n[0]=i[2]*Math.sin(s)+i[0]*Math.cos(s),n[1]=i[1],n[2]=i[2]*Math.cos(s)-i[0]*Math.sin(s),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Oi(e,t,r,s){let i=[],n=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],n[0]=i[0]*Math.cos(s)-i[1]*Math.sin(s),n[1]=i[0]*Math.sin(s)+i[1]*Math.cos(s),n[2]=i[2],e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Ni(e,t){let r=e[0],s=e[1],i=e[2],n=t[0],o=t[1],a=t[2],h=Math.sqrt((r*r+s*s+i*i)*(n*n+o*o+a*a)),c=h&&Je(e,t)/h;return Math.acos(Math.min(Math.max(c,-1),1))}function Nu(e){return e[0]=0,e[1]=0,e[2]=0,e}function Lu(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function Gu(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function zu(e,t){let r=e[0],s=e[1],i=e[2],n=t[0],o=t[1],a=t[2];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(s-o)<=1e-6*Math.max(1,Math.abs(s),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}var qu=zo,Bu=qo,Du=Bo,Fu=Do,Uu=Fo,Li=Go,Vu=Uo,ku=(function(){let e=ts();return function(t,r,s,i,n,o){let a,h;for(r||(r=3),s||(s=0),i?h=Math.min(i*r+s,t.length):h=t.length,a=s;a<h;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],n(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();var Gi=[0,0,0],rs,_=class e extends se{static get ZERO(){return rs||(rs=new e(0,0,0),Object.freeze(rs)),rs}constructor(t=0,r=0,s=0){super(-0,-0,-0),arguments.length===1&&vt(t)?this.copy(t):(k.debug&&(G(t),G(r),G(s)),this[0]=t,this[1]=r,this[2]=s)}set(t,r,s){return this[0]=t,this[1]=r,this[2]=s,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return k.debug&&(G(t.x),G(t.y),G(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=G(t)}angle(t){return Ni(this,t)}cross(t){return he(this,this,t),this.check()}rotateX({radians:t,origin:r=Gi}){return Ai(this,this,r,t),this.check()}rotateY({radians:t,origin:r=Gi}){return Ii(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=Gi}){return Oi(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return ce(this,this,t),this.check()}transformAsVector(t){return Kr(this,this,t),this.check()}transformByMatrix3(t){return tr(this,this,t),this.check()}transformByMatrix2(t){return No(this,this,t),this.check()}transformByQuaternion(t){return er(this,this,t),this.check()}};var ss,is=class e extends se{static get ZERO(){return ss||(ss=new e(0,0,0,0),Object.freeze(ss)),ss}constructor(t=0,r=0,s=0,i=0){super(-0,-0,-0,-0),vt(t)&&arguments.length===1?this.copy(t):(k.debug&&(G(t),G(r),G(s),G(i)),this[0]=t,this[1]=r,this[2]=s,this[3]=i)}set(t,r,s,i){return this[0]=t,this[1]=r,this[2]=s,this[3]=i,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return k.debug&&(G(t.x),G(t.y),G(t.z),G(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=G(t)}get w(){return this[3]}set w(t){this[3]=G(t)}transform(t){return ce(this,this,t),this.check()}transformByMatrix3(t){return Jr(this,this,t),this.check()}transformByMatrix2(t){return Lo(this,this,t),this.check()}transformByQuaternion(t){return er(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};function Vo(){let e=new H(9);return H!==Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function ko(e,t){if(e===t){let r=t[1],s=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=s,e[7]=i}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function jo(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],h=t[6],c=t[7],l=t[8],u=l*o-a*c,f=-l*n+a*h,d=c*n-o*h,m=r*u+s*f+i*d;return m?(m=1/m,e[0]=u*m,e[1]=(-l*s+i*c)*m,e[2]=(a*s-i*o)*m,e[3]=f*m,e[4]=(l*r-i*h)*m,e[5]=(-a*r+i*n)*m,e[6]=d*m,e[7]=(-c*r+s*h)*m,e[8]=(o*r-s*n)*m,e):null}function Wo(e){let t=e[0],r=e[1],s=e[2],i=e[3],n=e[4],o=e[5],a=e[6],h=e[7],c=e[8];return t*(c*n-o*h)+r*(-c*i+o*a)+s*(h*i-n*a)}function zi(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=t[4],h=t[5],c=t[6],l=t[7],u=t[8],f=r[0],d=r[1],m=r[2],g=r[3],p=r[4],M=r[5],x=r[6],S=r[7],v=r[8];return e[0]=f*s+d*o+m*c,e[1]=f*i+d*a+m*l,e[2]=f*n+d*h+m*u,e[3]=g*s+p*o+M*c,e[4]=g*i+p*a+M*l,e[5]=g*n+p*h+M*u,e[6]=x*s+S*o+v*c,e[7]=x*i+S*a+v*l,e[8]=x*n+S*h+v*u,e}function Ho(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=t[4],h=t[5],c=t[6],l=t[7],u=t[8],f=r[0],d=r[1];return e[0]=s,e[1]=i,e[2]=n,e[3]=o,e[4]=a,e[5]=h,e[6]=f*s+d*o+c,e[7]=f*i+d*a+l,e[8]=f*n+d*h+u,e}function Yo(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=t[4],h=t[5],c=t[6],l=t[7],u=t[8],f=Math.sin(r),d=Math.cos(r);return e[0]=d*s+f*o,e[1]=d*i+f*a,e[2]=d*n+f*h,e[3]=d*o-f*s,e[4]=d*a-f*i,e[5]=d*h-f*n,e[6]=c,e[7]=l,e[8]=u,e}function qi(e,t,r){let s=r[0],i=r[1];return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Zo(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=r+r,a=s+s,h=i+i,c=r*o,l=s*o,u=s*a,f=i*o,d=i*a,m=i*h,g=n*o,p=n*a,M=n*h;return e[0]=1-u-m,e[3]=l-M,e[6]=f+p,e[1]=l+M,e[4]=1-c-m,e[7]=d-g,e[2]=f-p,e[5]=d+g,e[8]=1-c-u,e}var Bi;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(Bi||(Bi={}));var ju=Object.freeze([1,0,0,0,1,0,0,0,1]),j=class extends Se{static get IDENTITY(){return Hu()}static get ZERO(){return Wu()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Bi}constructor(t,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):r.length>0?this.copy([t,...r]):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(ju)}fromObject(t){return this.check()}fromQuaternion(t){return Zo(this,t),this.check()}set(t,r,s,i,n,o,a,h,c){return this[0]=t,this[1]=r,this[2]=s,this[3]=i,this[4]=n,this[5]=o,this[6]=a,this[7]=h,this[8]=c,this.check()}setRowMajor(t,r,s,i,n,o,a,h,c){return this[0]=t,this[1]=i,this[2]=a,this[3]=r,this[4]=n,this[5]=h,this[6]=s,this[7]=o,this[8]=c,this.check()}determinant(){return Wo(this)}transpose(){return ko(this,this),this.check()}invert(){return jo(this,this),this.check()}multiplyLeft(t){return zi(this,t,this),this.check()}multiplyRight(t){return zi(this,this,t),this.check()}rotate(t){return Yo(this,this,t),this.check()}scale(t){return Array.isArray(t)?qi(this,this,t):qi(this,this,[t,t]),this.check()}translate(t){return Ho(this,this,t),this.check()}transform(t,r){let s;switch(t.length){case 2:s=$r(r||[-0,-0],t,this);break;case 3:s=tr(r||[-0,-0,-0],t,this);break;case 4:s=Jr(r||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return re(s,t.length),s}transformVector(t,r){return this.transform(t,r)}transformVector2(t,r){return this.transform(t,r)}transformVector3(t,r){return this.transform(t,r)}},ns,os=null;function Wu(){return ns||(ns=new j([0,0,0,0,0,0,0,0,0]),Object.freeze(ns)),ns}function Hu(){return os||(os=new j,Object.freeze(os)),os}var as={};$e(as,{add:()=>Mf,adjoint:()=>Ku,clone:()=>Zu,copy:()=>$u,create:()=>Yu,decompose:()=>cf,determinant:()=>Ui,equals:()=>vf,exactEquals:()=>Sf,frob:()=>_f,fromQuat:()=>Zi,fromQuat2:()=>of,fromRotation:()=>ef,fromRotationTranslation:()=>Xo,fromRotationTranslationScale:()=>lf,fromRotationTranslationScaleOrigin:()=>uf,fromScaling:()=>tf,fromTranslation:()=>Ju,fromValues:()=>Qu,fromXRotation:()=>rf,fromYRotation:()=>sf,fromZRotation:()=>nf,frustum:()=>$i,getRotation:()=>hf,getScaling:()=>Ko,getTranslation:()=>af,identity:()=>Qo,invert:()=>Fi,lookAt:()=>Ki,mul:()=>Ef,multiply:()=>rr,multiplyScalar:()=>xf,multiplyScalarAndAdd:()=>yf,ortho:()=>Xi,orthoNO:()=>ta,orthoZO:()=>df,perspective:()=>Qi,perspectiveFromFieldOfView:()=>mf,perspectiveNO:()=>Jo,perspectiveZO:()=>ff,rotate:()=>ji,rotateX:()=>Wi,rotateY:()=>Hi,rotateZ:()=>Yi,scale:()=>ki,set:()=>Xu,str:()=>gf,sub:()=>wf,subtract:()=>ea,targetTo:()=>pf,translate:()=>Vi,transpose:()=>Di});function Yu(){let e=new H(16);return H!==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 Zu(e){let t=new H(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 $u(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 Qu(e,t,r,s,i,n,o,a,h,c,l,u,f,d,m,g){let p=new H(16);return p[0]=e,p[1]=t,p[2]=r,p[3]=s,p[4]=i,p[5]=n,p[6]=o,p[7]=a,p[8]=h,p[9]=c,p[10]=l,p[11]=u,p[12]=f,p[13]=d,p[14]=m,p[15]=g,p}function Xu(e,t,r,s,i,n,o,a,h,c,l,u,f,d,m,g,p){return e[0]=t,e[1]=r,e[2]=s,e[3]=i,e[4]=n,e[5]=o,e[6]=a,e[7]=h,e[8]=c,e[9]=l,e[10]=u,e[11]=f,e[12]=d,e[13]=m,e[14]=g,e[15]=p,e}function Qo(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 Di(e,t){if(e===t){let r=t[1],s=t[2],i=t[3],n=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=s,e[9]=n,e[11]=t[14],e[12]=i,e[13]=o,e[14]=a}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 Fi(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],h=t[6],c=t[7],l=t[8],u=t[9],f=t[10],d=t[11],m=t[12],g=t[13],p=t[14],M=t[15],x=r*a-s*o,S=r*h-i*o,v=r*c-n*o,w=s*h-i*a,P=s*c-n*a,R=i*c-n*h,C=l*g-u*m,A=l*p-f*m,b=l*M-d*m,O=u*p-f*g,N=u*M-d*g,B=f*M-d*p,L=x*B-S*N+v*O+w*b-P*A+R*C;return L?(L=1/L,e[0]=(a*B-h*N+c*O)*L,e[1]=(i*N-s*B-n*O)*L,e[2]=(g*R-p*P+M*w)*L,e[3]=(f*P-u*R-d*w)*L,e[4]=(h*b-o*B-c*A)*L,e[5]=(r*B-i*b+n*A)*L,e[6]=(p*v-m*R-M*S)*L,e[7]=(l*R-f*v+d*S)*L,e[8]=(o*N-a*b+c*C)*L,e[9]=(s*b-r*N-n*C)*L,e[10]=(m*P-g*v+M*x)*L,e[11]=(u*v-l*P-d*x)*L,e[12]=(a*A-o*O-h*C)*L,e[13]=(r*O-s*A+i*C)*L,e[14]=(g*S-m*w-p*x)*L,e[15]=(l*w-u*S+f*x)*L,e):null}function Ku(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=t[4],a=t[5],h=t[6],c=t[7],l=t[8],u=t[9],f=t[10],d=t[11],m=t[12],g=t[13],p=t[14],M=t[15],x=r*a-s*o,S=r*h-i*o,v=r*c-n*o,w=s*h-i*a,P=s*c-n*a,R=i*c-n*h,C=l*g-u*m,A=l*p-f*m,b=l*M-d*m,O=u*p-f*g,N=u*M-d*g,B=f*M-d*p;return e[0]=a*B-h*N+c*O,e[1]=i*N-s*B-n*O,e[2]=g*R-p*P+M*w,e[3]=f*P-u*R-d*w,e[4]=h*b-o*B-c*A,e[5]=r*B-i*b+n*A,e[6]=p*v-m*R-M*S,e[7]=l*R-f*v+d*S,e[8]=o*N-a*b+c*C,e[9]=s*b-r*N-n*C,e[10]=m*P-g*v+M*x,e[11]=u*v-l*P-d*x,e[12]=a*A-o*O-h*C,e[13]=r*O-s*A+i*C,e[14]=g*S-m*w-p*x,e[15]=l*w-u*S+f*x,e}function Ui(e){let t=e[0],r=e[1],s=e[2],i=e[3],n=e[4],o=e[5],a=e[6],h=e[7],c=e[8],l=e[9],u=e[10],f=e[11],d=e[12],m=e[13],g=e[14],p=e[15],M=t*o-r*n,x=t*a-s*n,S=r*a-s*o,v=c*m-l*d,w=c*g-u*d,P=l*g-u*m,R=t*P-r*w+s*v,C=n*P-o*w+a*v,A=c*S-l*x+u*M,b=d*S-m*x+g*M;return h*R-i*C+p*A-f*b}function rr(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=t[4],h=t[5],c=t[6],l=t[7],u=t[8],f=t[9],d=t[10],m=t[11],g=t[12],p=t[13],M=t[14],x=t[15],S=r[0],v=r[1],w=r[2],P=r[3];return e[0]=S*s+v*a+w*u+P*g,e[1]=S*i+v*h+w*f+P*p,e[2]=S*n+v*c+w*d+P*M,e[3]=S*o+v*l+w*m+P*x,S=r[4],v=r[5],w=r[6],P=r[7],e[4]=S*s+v*a+w*u+P*g,e[5]=S*i+v*h+w*f+P*p,e[6]=S*n+v*c+w*d+P*M,e[7]=S*o+v*l+w*m+P*x,S=r[8],v=r[9],w=r[10],P=r[11],e[8]=S*s+v*a+w*u+P*g,e[9]=S*i+v*h+w*f+P*p,e[10]=S*n+v*c+w*d+P*M,e[11]=S*o+v*l+w*m+P*x,S=r[12],v=r[13],w=r[14],P=r[15],e[12]=S*s+v*a+w*u+P*g,e[13]=S*i+v*h+w*f+P*p,e[14]=S*n+v*c+w*d+P*M,e[15]=S*o+v*l+w*m+P*x,e}function Vi(e,t,r){let s=r[0],i=r[1],n=r[2],o,a,h,c,l,u,f,d,m,g,p,M;return t===e?(e[12]=t[0]*s+t[4]*i+t[8]*n+t[12],e[13]=t[1]*s+t[5]*i+t[9]*n+t[13],e[14]=t[2]*s+t[6]*i+t[10]*n+t[14],e[15]=t[3]*s+t[7]*i+t[11]*n+t[15]):(o=t[0],a=t[1],h=t[2],c=t[3],l=t[4],u=t[5],f=t[6],d=t[7],m=t[8],g=t[9],p=t[10],M=t[11],e[0]=o,e[1]=a,e[2]=h,e[3]=c,e[4]=l,e[5]=u,e[6]=f,e[7]=d,e[8]=m,e[9]=g,e[10]=p,e[11]=M,e[12]=o*s+l*i+m*n+t[12],e[13]=a*s+u*i+g*n+t[13],e[14]=h*s+f*i+p*n+t[14],e[15]=c*s+d*i+M*n+t[15]),e}function ki(e,t,r){let s=r[0],i=r[1],n=r[2];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]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ji(e,t,r,s){let i=s[0],n=s[1],o=s[2],a=Math.sqrt(i*i+n*n+o*o),h,c,l,u,f,d,m,g,p,M,x,S,v,w,P,R,C,A,b,O,N,B,L,et;return a<1e-6?null:(a=1/a,i*=a,n*=a,o*=a,c=Math.sin(r),h=Math.cos(r),l=1-h,u=t[0],f=t[1],d=t[2],m=t[3],g=t[4],p=t[5],M=t[6],x=t[7],S=t[8],v=t[9],w=t[10],P=t[11],R=i*i*l+h,C=n*i*l+o*c,A=o*i*l-n*c,b=i*n*l-o*c,O=n*n*l+h,N=o*n*l+i*c,B=i*o*l+n*c,L=n*o*l-i*c,et=o*o*l+h,e[0]=u*R+g*C+S*A,e[1]=f*R+p*C+v*A,e[2]=d*R+M*C+w*A,e[3]=m*R+x*C+P*A,e[4]=u*b+g*O+S*N,e[5]=f*b+p*O+v*N,e[6]=d*b+M*O+w*N,e[7]=m*b+x*O+P*N,e[8]=u*B+g*L+S*et,e[9]=f*B+p*L+v*et,e[10]=d*B+M*L+w*et,e[11]=m*B+x*L+P*et,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Wi(e,t,r){let s=Math.sin(r),i=Math.cos(r),n=t[4],o=t[5],a=t[6],h=t[7],c=t[8],l=t[9],u=t[10],f=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]=n*i+c*s,e[5]=o*i+l*s,e[6]=a*i+u*s,e[7]=h*i+f*s,e[8]=c*i-n*s,e[9]=l*i-o*s,e[10]=u*i-a*s,e[11]=f*i-h*s,e}function Hi(e,t,r){let s=Math.sin(r),i=Math.cos(r),n=t[0],o=t[1],a=t[2],h=t[3],c=t[8],l=t[9],u=t[10],f=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]=n*i-c*s,e[1]=o*i-l*s,e[2]=a*i-u*s,e[3]=h*i-f*s,e[8]=n*s+c*i,e[9]=o*s+l*i,e[10]=a*s+u*i,e[11]=h*s+f*i,e}function Yi(e,t,r){let s=Math.sin(r),i=Math.cos(r),n=t[0],o=t[1],a=t[2],h=t[3],c=t[4],l=t[5],u=t[6],f=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]=n*i+c*s,e[1]=o*i+l*s,e[2]=a*i+u*s,e[3]=h*i+f*s,e[4]=c*i-n*s,e[5]=l*i-o*s,e[6]=u*i-a*s,e[7]=f*i-h*s,e}function Ju(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 tf(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 ef(e,t,r){let s=r[0],i=r[1],n=r[2],o=Math.sqrt(s*s+i*i+n*n),a,h,c;return o<1e-6?null:(o=1/o,s*=o,i*=o,n*=o,h=Math.sin(t),a=Math.cos(t),c=1-a,e[0]=s*s*c+a,e[1]=i*s*c+n*h,e[2]=n*s*c-i*h,e[3]=0,e[4]=s*i*c-n*h,e[5]=i*i*c+a,e[6]=n*i*c+s*h,e[7]=0,e[8]=s*n*c+i*h,e[9]=i*n*c-s*h,e[10]=n*n*c+a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function rf(e,t){let r=Math.sin(t),s=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function sf(e,t){let r=Math.sin(t),s=Math.cos(t);return e[0]=s,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function nf(e,t){let r=Math.sin(t),s=Math.cos(t);return e[0]=s,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=s,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 Xo(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=s+s,h=i+i,c=n+n,l=s*a,u=s*h,f=s*c,d=i*h,m=i*c,g=n*c,p=o*a,M=o*h,x=o*c;return e[0]=1-(d+g),e[1]=u+x,e[2]=f-M,e[3]=0,e[4]=u-x,e[5]=1-(l+g),e[6]=m+p,e[7]=0,e[8]=f+M,e[9]=m-p,e[10]=1-(l+d),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function of(e,t){let r=new H(3),s=-t[0],i=-t[1],n=-t[2],o=t[3],a=t[4],h=t[5],c=t[6],l=t[7],u=s*s+i*i+n*n+o*o;return u>0?(r[0]=(a*o+l*s+h*n-c*i)*2/u,r[1]=(h*o+l*i+c*s-a*n)*2/u,r[2]=(c*o+l*n+a*i-h*s)*2/u):(r[0]=(a*o+l*s+h*n-c*i)*2,r[1]=(h*o+l*i+c*s-a*n)*2,r[2]=(c*o+l*n+a*i-h*s)*2),Xo(e,t,r),e}function af(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Ko(e,t){let r=t[0],s=t[1],i=t[2],n=t[4],o=t[5],a=t[6],h=t[8],c=t[9],l=t[10];return e[0]=Math.sqrt(r*r+s*s+i*i),e[1]=Math.sqrt(n*n+o*o+a*a),e[2]=Math.sqrt(h*h+c*c+l*l),e}function hf(e,t){let r=new H(3);Ko(r,t);let s=1/r[0],i=1/r[1],n=1/r[2],o=t[0]*s,a=t[1]*i,h=t[2]*n,c=t[4]*s,l=t[5]*i,u=t[6]*n,f=t[8]*s,d=t[9]*i,m=t[10]*n,g=o+l+m,p=0;return g>0?(p=Math.sqrt(g+1)*2,e[3]=.25*p,e[0]=(u-d)/p,e[1]=(f-h)/p,e[2]=(a-c)/p):o>l&&o>m?(p=Math.sqrt(1+o-l-m)*2,e[3]=(u-d)/p,e[0]=.25*p,e[1]=(a+c)/p,e[2]=(f+h)/p):l>m?(p=Math.sqrt(1+l-o-m)*2,e[3]=(f-h)/p,e[0]=(a+c)/p,e[1]=.25*p,e[2]=(u+d)/p):(p=Math.sqrt(1+m-o-l)*2,e[3]=(a-c)/p,e[0]=(f+h)/p,e[1]=(u+d)/p,e[2]=.25*p),e}function cf(e,t,r,s){t[0]=s[12],t[1]=s[13],t[2]=s[14];let i=s[0],n=s[1],o=s[2],a=s[4],h=s[5],c=s[6],l=s[8],u=s[9],f=s[10];r[0]=Math.sqrt(i*i+n*n+o*o),r[1]=Math.sqrt(a*a+h*h+c*c),r[2]=Math.sqrt(l*l+u*u+f*f);let d=1/r[0],m=1/r[1],g=1/r[2],p=i*d,M=n*m,x=o*g,S=a*d,v=h*m,w=c*g,P=l*d,R=u*m,C=f*g,A=p+v+C,b=0;return A>0?(b=Math.sqrt(A+1)*2,e[3]=.25*b,e[0]=(w-R)/b,e[1]=(P-x)/b,e[2]=(M-S)/b):p>v&&p>C?(b=Math.sqrt(1+p-v-C)*2,e[3]=(w-R)/b,e[0]=.25*b,e[1]=(M+S)/b,e[2]=(P+x)/b):v>C?(b=Math.sqrt(1+v-p-C)*2,e[3]=(P-x)/b,e[0]=(M+S)/b,e[1]=.25*b,e[2]=(w+R)/b):(b=Math.sqrt(1+C-p-v)*2,e[3]=(M-S)/b,e[0]=(P+x)/b,e[1]=(w+R)/b,e[2]=.25*b),e}function lf(e,t,r,s){let i=t[0],n=t[1],o=t[2],a=t[3],h=i+i,c=n+n,l=o+o,u=i*h,f=i*c,d=i*l,m=n*c,g=n*l,p=o*l,M=a*h,x=a*c,S=a*l,v=s[0],w=s[1],P=s[2];return e[0]=(1-(m+p))*v,e[1]=(f+S)*v,e[2]=(d-x)*v,e[3]=0,e[4]=(f-S)*w,e[5]=(1-(u+p))*w,e[6]=(g+M)*w,e[7]=0,e[8]=(d+x)*P,e[9]=(g-M)*P,e[10]=(1-(u+m))*P,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function uf(e,t,r,s,i){let n=t[0],o=t[1],a=t[2],h=t[3],c=n+n,l=o+o,u=a+a,f=n*c,d=n*l,m=n*u,g=o*l,p=o*u,M=a*u,x=h*c,S=h*l,v=h*u,w=s[0],P=s[1],R=s[2],C=i[0],A=i[1],b=i[2],O=(1-(g+M))*w,N=(d+v)*w,B=(m-S)*w,L=(d-v)*P,et=(1-(f+M))*P,Lt=(p+x)*P,Vt=(m+S)*R,kr=(p-x)*R,xe=(1-(f+g))*R;return e[0]=O,e[1]=N,e[2]=B,e[3]=0,e[4]=L,e[5]=et,e[6]=Lt,e[7]=0,e[8]=Vt,e[9]=kr,e[10]=xe,e[11]=0,e[12]=r[0]+C-(O*C+L*A+Vt*b),e[13]=r[1]+A-(N*C+et*A+kr*b),e[14]=r[2]+b-(B*C+Lt*A+xe*b),e[15]=1,e}function Zi(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=r+r,a=s+s,h=i+i,c=r*o,l=s*o,u=s*a,f=i*o,d=i*a,m=i*h,g=n*o,p=n*a,M=n*h;return e[0]=1-u-m,e[1]=l+M,e[2]=f-p,e[3]=0,e[4]=l-M,e[5]=1-c-m,e[6]=d+g,e[7]=0,e[8]=f+p,e[9]=d-g,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function $i(e,t,r,s,i,n,o){let a=1/(r-t),h=1/(i-s),c=1/(n-o);return e[0]=n*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n*2*h,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(i+s)*h,e[10]=(o+n)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*n*2*c,e[15]=0,e}function Jo(e,t,r,s,i){let n=1/Math.tan(t/2);if(e[0]=n/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let o=1/(s-i);e[10]=(i+s)*o,e[14]=2*i*s*o}else e[10]=-1,e[14]=-2*s;return e}var Qi=Jo;function ff(e,t,r,s,i){let n=1/Math.tan(t/2);if(e[0]=n/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let o=1/(s-i);e[10]=i*o,e[14]=i*s*o}else e[10]=-1,e[14]=-s;return e}function mf(e,t,r,s){let i=Math.tan(t.upDegrees*Math.PI/180),n=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),h=2/(o+a),c=2/(i+n);return e[0]=h,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=-((o-a)*h*.5),e[9]=(i-n)*c*.5,e[10]=s/(r-s),e[11]=-1,e[12]=0,e[13]=0,e[14]=s*r/(r-s),e[15]=0,e}function ta(e,t,r,s,i,n,o){let a=1/(t-r),h=1/(s-i),c=1/(n-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+r)*a,e[13]=(i+s)*h,e[14]=(o+n)*c,e[15]=1,e}var Xi=ta;function df(e,t,r,s,i,n,o){let a=1/(t-r),h=1/(s-i),c=1/(n-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*h,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=c,e[11]=0,e[12]=(t+r)*a,e[13]=(i+s)*h,e[14]=n*c,e[15]=1,e}function Ki(e,t,r,s){let i,n,o,a,h,c,l,u,f,d,m=t[0],g=t[1],p=t[2],M=s[0],x=s[1],S=s[2],v=r[0],w=r[1],P=r[2];return Math.abs(m-v)<1e-6&&Math.abs(g-w)<1e-6&&Math.abs(p-P)<1e-6?Qo(e):(u=m-v,f=g-w,d=p-P,i=1/Math.sqrt(u*u+f*f+d*d),u*=i,f*=i,d*=i,n=x*d-S*f,o=S*u-M*d,a=M*f-x*u,i=Math.sqrt(n*n+o*o+a*a),i?(i=1/i,n*=i,o*=i,a*=i):(n=0,o=0,a=0),h=f*a-d*o,c=d*n-u*a,l=u*o-f*n,i=Math.sqrt(h*h+c*c+l*l),i?(i=1/i,h*=i,c*=i,l*=i):(h=0,c=0,l=0),e[0]=n,e[1]=h,e[2]=u,e[3]=0,e[4]=o,e[5]=c,e[6]=f,e[7]=0,e[8]=a,e[9]=l,e[10]=d,e[11]=0,e[12]=-(n*m+o*g+a*p),e[13]=-(h*m+c*g+l*p),e[14]=-(u*m+f*g+d*p),e[15]=1,e)}function pf(e,t,r,s){let i=t[0],n=t[1],o=t[2],a=s[0],h=s[1],c=s[2],l=i-r[0],u=n-r[1],f=o-r[2],d=l*l+u*u+f*f;d>0&&(d=1/Math.sqrt(d),l*=d,u*=d,f*=d);let m=h*f-c*u,g=c*l-a*f,p=a*u-h*l;return d=m*m+g*g+p*p,d>0&&(d=1/Math.sqrt(d),m*=d,g*=d,p*=d),e[0]=m,e[1]=g,e[2]=p,e[3]=0,e[4]=u*p-f*g,e[5]=f*m-l*p,e[6]=l*g-u*m,e[7]=0,e[8]=l,e[9]=u,e[10]=f,e[11]=0,e[12]=i,e[13]=n,e[14]=o,e[15]=1,e}function gf(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 _f(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 Mf(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function ea(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function xf(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function yf(e,t,r,s){return e[0]=t[0]+r[0]*s,e[1]=t[1]+r[1]*s,e[2]=t[2]+r[2]*s,e[3]=t[3]+r[3]*s,e[4]=t[4]+r[4]*s,e[5]=t[5]+r[5]*s,e[6]=t[6]+r[6]*s,e[7]=t[7]+r[7]*s,e[8]=t[8]+r[8]*s,e[9]=t[9]+r[9]*s,e[10]=t[10]+r[10]*s,e[11]=t[11]+r[11]*s,e[12]=t[12]+r[12]*s,e[13]=t[13]+r[13]*s,e[14]=t[14]+r[14]*s,e[15]=t[15]+r[15]*s,e}function Sf(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 vf(e,t){let r=e[0],s=e[1],i=e[2],n=e[3],o=e[4],a=e[5],h=e[6],c=e[7],l=e[8],u=e[9],f=e[10],d=e[11],m=e[12],g=e[13],p=e[14],M=e[15],x=t[0],S=t[1],v=t[2],w=t[3],P=t[4],R=t[5],C=t[6],A=t[7],b=t[8],O=t[9],N=t[10],B=t[11],L=t[12],et=t[13],Lt=t[14],Vt=t[15];return Math.abs(r-x)<=1e-6*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(s-S)<=1e-6*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(i-v)<=1e-6*Math.max(1,Math.abs(i),Math.abs(v))&&Math.abs(n-w)<=1e-6*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(o-P)<=1e-6*Math.max(1,Math.abs(o),Math.abs(P))&&Math.abs(a-R)<=1e-6*Math.max(1,Math.abs(a),Math.abs(R))&&Math.abs(h-C)<=1e-6*Math.max(1,Math.abs(h),Math.abs(C))&&Math.abs(c-A)<=1e-6*Math.max(1,Math.abs(c),Math.abs(A))&&Math.abs(l-b)<=1e-6*Math.max(1,Math.abs(l),Math.abs(b))&&Math.abs(u-O)<=1e-6*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(f-N)<=1e-6*Math.max(1,Math.abs(f),Math.abs(N))&&Math.abs(d-B)<=1e-6*Math.max(1,Math.abs(d),Math.abs(B))&&Math.abs(m-L)<=1e-6*Math.max(1,Math.abs(m),Math.abs(L))&&Math.abs(g-et)<=1e-6*Math.max(1,Math.abs(g),Math.abs(et))&&Math.abs(p-Lt)<=1e-6*Math.max(1,Math.abs(p),Math.abs(Lt))&&Math.abs(M-Vt)<=1e-6*Math.max(1,Math.abs(M),Math.abs(Vt))}var Ef=rr,wf=ea;function Tf(){let e=new H(4);return H!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ra(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function sa(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function ia(e){let t=e[0],r=e[1],s=e[2],i=e[3];return Math.sqrt(t*t+r*r+s*s+i*i)}function na(e){let t=e[0],r=e[1],s=e[2],i=e[3];return t*t+r*r+s*s+i*i}function oa(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=r*r+s*s+i*i+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=s*o,e[2]=i*o,e[3]=n*o,e}function aa(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function ha(e,t,r,s){let i=t[0],n=t[1],o=t[2],a=t[3];return e[0]=i+s*(r[0]-i),e[1]=n+s*(r[1]-n),e[2]=o+s*(r[2]-o),e[3]=a+s*(r[3]-a),e}function ca(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3];return e[0]=r[0]*s+r[4]*i+r[8]*n+r[12]*o,e[1]=r[1]*s+r[5]*i+r[9]*n+r[13]*o,e[2]=r[2]*s+r[6]*i+r[10]*n+r[14]*o,e[3]=r[3]*s+r[7]*i+r[11]*n+r[15]*o,e}function la(e,t,r){let s=t[0],i=t[1],n=t[2],o=r[0],a=r[1],h=r[2],c=r[3],l=c*s+a*n-h*i,u=c*i+h*s-o*n,f=c*n+o*i-a*s,d=-o*s-a*i-h*n;return e[0]=l*c+d*-o+u*-h-f*-a,e[1]=u*c+d*-a+f*-o-l*-h,e[2]=f*c+d*-h+l*-a-u*-o,e[3]=t[3],e}var CM=(function(){let e=Tf();return function(t,r,s,i,n,o){let a,h;for(r||(r=4),s||(s=0),i?h=Math.min(i*r+s,t.length):h=t.length,a=s;a<h;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],n(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();var en;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(en||(en={}));var Pf=45*Math.PI/180,bf=1,Ji=.1,tn=500,Rf=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),z=class extends Se{static get IDENTITY(){return Af()}static get ZERO(){return Cf()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return en}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,s,i,n,o,a,h,c,l,u,f,d,m,g,p){return this[0]=t,this[1]=r,this[2]=s,this[3]=i,this[4]=n,this[5]=o,this[6]=a,this[7]=h,this[8]=c,this[9]=l,this[10]=u,this[11]=f,this[12]=d,this[13]=m,this[14]=g,this[15]=p,this.check()}setRowMajor(t,r,s,i,n,o,a,h,c,l,u,f,d,m,g,p){return this[0]=t,this[1]=n,this[2]=c,this[3]=d,this[4]=r,this[5]=o,this[6]=l,this[7]=m,this[8]=s,this[9]=a,this[10]=u,this[11]=g,this[12]=i,this[13]=h,this[14]=f,this[15]=p,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Rf)}fromObject(t){return this.check()}fromQuaternion(t){return Zi(this,t),this.check()}frustum(t){let{left:r,right:s,bottom:i,top:n,near:o=Ji,far:a=tn}=t;return a===1/0?If(this,r,s,i,n,o):$i(this,r,s,i,n,o,a),this.check()}lookAt(t){let{eye:r,center:s=[0,0,0],up:i=[0,1,0]}=t;return Ki(this,r,s,i),this.check()}ortho(t){let{left:r,right:s,bottom:i,top:n,near:o=Ji,far:a=tn}=t;return Xi(this,r,s,i,n,o,a),this.check()}orthographic(t){let{fovy:r=Pf,aspect:s=bf,focalDistance:i=1,near:n=Ji,far:o=tn}=t;fa(r);let a=r/2,h=i*Math.tan(a),c=h*s;return this.ortho({left:-c,right:c,bottom:-h,top:h,near:n,far:o})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:s=1,near:i=.1,far:n=500}=t;return fa(r),Qi(this,r,s,i,n),this.check()}determinant(){return Ui(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let s=this.getScale(r),i=1/s[0],n=1/s[1],o=1/s[2];return t[0]=this[0]*i,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*n,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*n,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let s=this.getScale(r),i=1/s[0],n=1/s[1],o=1/s[2];return t[0]=this[0]*i,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=this[4]*i,t[4]=this[5]*n,t[5]=this[6]*o,t[6]=this[8]*i,t[7]=this[9]*n,t[8]=this[10]*o,t}transpose(){return Di(this,this),this.check()}invert(){return Fi(this,this),this.check()}multiplyLeft(t){return rr(this,t,this),this.check()}multiplyRight(t){return rr(this,this,t),this.check()}rotateX(t){return Wi(this,this,t),this.check()}rotateY(t){return Hi(this,this,t),this.check()}rotateZ(t){return Yi(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return ji(this,this,t,r),this.check()}scale(t){return ki(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Vi(this,this,t),this.check()}transform(t,r){return t.length===4?(r=ca(r||[-0,-0,-0,-0],t,this),re(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:s}=t,i;switch(s){case 2:i=Qr(r||[-0,-0],t,this);break;case 3:i=ce(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return re(i,t.length),i}transformAsVector(t,r){let s;switch(t.length){case 2:s=Xr(r||[-0,-0],t,this);break;case 3:s=Kr(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return re(s,t.length),s}transformPoint(t,r){return this.transformAsPoint(t,r)}transformVector(t,r){return this.transformAsPoint(t,r)}transformDirection(t,r){return this.transformAsVector(t,r)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,s){return this.identity().translate([t,r,s])}},hs,cs;function Cf(){return hs||(hs=new z([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(hs)),hs}function Af(){return cs||(cs=new z,Object.freeze(cs)),cs}function fa(e){if(e>Math.PI*2)throw Error("expected radians")}function If(e,t,r,s,i,n){let o=2*n/(r-t),a=2*n/(i-s),h=(r+t)/(r-t),c=(i+s)/(i-s),l=-1,u=-1,f=-2*n;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=h,e[9]=c,e[10]=l,e[11]=u,e[12]=0,e[13]=0,e[14]=f,e[15]=0,e}function ma(){let e=new H(4);return H!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function da(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function rn(e,t,r){r=r*.5;let s=Math.sin(r);return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=Math.cos(r),e}function sn(e,t,r){let s=t[0],i=t[1],n=t[2],o=t[3],a=r[0],h=r[1],c=r[2],l=r[3];return e[0]=s*l+o*a+i*c-n*h,e[1]=i*l+o*h+n*a-s*c,e[2]=n*l+o*c+s*h-i*a,e[3]=o*l-s*a-i*h-n*c,e}function pa(e,t,r){r*=.5;let s=t[0],i=t[1],n=t[2],o=t[3],a=Math.sin(r),h=Math.cos(r);return e[0]=s*h+o*a,e[1]=i*h+n*a,e[2]=n*h-i*a,e[3]=o*h-s*a,e}function ga(e,t,r){r*=.5;let s=t[0],i=t[1],n=t[2],o=t[3],a=Math.sin(r),h=Math.cos(r);return e[0]=s*h-n*a,e[1]=i*h+o*a,e[2]=n*h+s*a,e[3]=o*h-i*a,e}function _a(e,t,r){r*=.5;let s=t[0],i=t[1],n=t[2],o=t[3],a=Math.sin(r),h=Math.cos(r);return e[0]=s*h+i*a,e[1]=i*h-s*a,e[2]=n*h+o*a,e[3]=o*h-n*a,e}function Ma(e,t){let r=t[0],s=t[1],i=t[2];return e[0]=r,e[1]=s,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-s*s-i*i)),e}function sr(e,t,r,s){let i=t[0],n=t[1],o=t[2],a=t[3],h=r[0],c=r[1],l=r[2],u=r[3],f,d,m,g,p;return f=i*h+n*c+o*l+a*u,f<0&&(f=-f,h=-h,c=-c,l=-l,u=-u),1-f>1e-6?(d=Math.acos(f),p=Math.sin(d),m=Math.sin((1-s)*d)/p,g=Math.sin(s*d)/p):(m=1-s,g=s),e[0]=m*i+g*h,e[1]=m*n+g*c,e[2]=m*o+g*l,e[3]=m*a+g*u,e}function xa(e,t){let r=t[0],s=t[1],i=t[2],n=t[3],o=r*r+s*s+i*i+n*n,a=o?1/o:0;return e[0]=-r*a,e[1]=-s*a,e[2]=-i*a,e[3]=n*a,e}function ya(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function nn(e,t){let r=t[0]+t[4]+t[8],s;if(r>0)s=Math.sqrt(r+1),e[3]=.5*s,s=.5/s,e[0]=(t[5]-t[7])*s,e[1]=(t[6]-t[2])*s,e[2]=(t[1]-t[3])*s;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[i*3+i]&&(i=2);let n=(i+1)%3,o=(i+2)%3;s=Math.sqrt(t[i*3+i]-t[n*3+n]-t[o*3+o]+1),e[i]=.5*s,s=.5/s,e[3]=(t[n*3+o]-t[o*3+n])*s,e[n]=(t[n*3+i]+t[i*3+n])*s,e[o]=(t[o*3+i]+t[i*3+o])*s}return e}var Sa=ra;var va=sa,Ea=aa,wa=ha,Ta=ia;var Pa=na;var ba=oa;var Ra=(function(){let e=ts(),t=es(1,0,0),r=es(0,1,0);return function(s,i,n){let o=Je(i,n);return o<-.999999?(he(e,t,i),Li(e)<1e-6&&he(e,r,i),Ci(e,e),rn(s,e,Math.PI),s):o>.999999?(s[0]=0,s[1]=0,s[2]=0,s[3]=1,s):(he(e,i,n),s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=1+o,ba(s,s))}})(),kM=(function(){let e=ma(),t=ma();return function(r,s,i,n,o,a){return sr(e,s,o,a),sr(t,i,n,a),sr(r,e,t,2*a*(1-a)),r}})(),jM=(function(){let e=Vo();return function(t,r,s,i){return e[0]=s[0],e[3]=s[1],e[6]=s[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],ba(t,nn(t,e))}})();var Nf=[0,0,0,1],wt=class extends ee{constructor(t=0,r=0,s=0,i=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,r,s,i)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,r,s,i){return this[0]=t,this[1]=r,this[2]=s,this[3]=i,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 nn(this,t),this.check()}fromAxisRotation(t,r){return rn(this,t,r),this.check()}identity(){return da(this),this.check()}setAxisAngle(t,r){return this.fromAxisRotation(t,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=G(t)}get y(){return this[1]}set y(t){this[1]=G(t)}get z(){return this[2]}set z(t){this[2]=G(t)}get w(){return this[3]}set w(t){this[3]=G(t)}len(){return Ta(this)}lengthSquared(){return Pa(this)}dot(t){return Ea(this,t)}rotationTo(t,r){return Ra(this,t,r),this.check()}add(t){return Sa(this,this,t),this.check()}calculateW(){return Ma(this,this),this.check()}conjugate(){return ya(this,this),this.check()}invert(){return xa(this,this),this.check()}lerp(t,r,s){return s===void 0?this.lerp(this,t,r):(wa(this,t,r,s),this.check())}multiplyRight(t){return sn(this,this,t),this.check()}multiplyLeft(t){return sn(this,t,this),this.check()}normalize(){let t=this.len(),r=t>0?1/t:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,t===0&&(this[3]=1),this.check()}rotateX(t){return pa(this,this,t),this.check()}rotateY(t){return ga(this,this,t),this.check()}rotateZ(t){return _a(this,this,t),this.check()}scale(t){return va(this,this,t),this.check()}slerp(t,r,s){let i,n,o;switch(arguments.length){case 1:({start:i=Nf,target:n,ratio:o}=t);break;case 2:i=this,n=t,o=r;break;default:i=t,n=r,o=s}return sr(this,i,n,o),this.check()}transformVector4(t,r=new is){return la(r,t,this),re(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,r){return this.setAxisAngle(t,r)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var kt=6356752314245179e-9,Lf={radii:[6378137,6378137,kt],radiiSquared:[6378137*6378137,6378137*6378137,kt*kt],oneOverRadii:[1/6378137,1/6378137,1/kt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(kt*kt)],maximumRadius:Math.max(6378137,6378137,kt),centerToleranceSquared:.1};function ls(e){return e}var xx=new _;function Gf(e,t=[],r=ls){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function Ca(e,t=[]){return Gf(e,t,k._cartographicRadians?ls:Ti)}function zf(e,t,r=ls){return"longitude"in t?(t.longitude=r(e[0]),t.latitude=r(e[1]),t.height=e[2]):"x"in t?(t.x=r(e[0]),t.y=r(e[1]),t.z=e[2]):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function Aa(e,t){return zf(e,t,k._cartographicRadians?ls:Pi)}var Ia=1e-14,qf=new _,Oa={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"}},on={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},ir={east:new _,north:new _,up:new _,west:new _,south:new _,down:new _},Bf=new _,Df=new _,Ff=new _;function an(e,t,r,s,i,n){let o=Oa[t]&&Oa[t][r];J(o&&(!s||s===o));let a,h,c,l=qf.copy(i);if(Mt(l.x,0,Ia)&&Mt(l.y,0,Ia)){let f=Math.sign(l.z);a=Bf.fromArray(on[t]),t!=="east"&&t!=="west"&&a.scale(f),h=Df.fromArray(on[r]),r!=="east"&&r!=="west"&&h.scale(f),c=Ff.fromArray(on[s]),s!=="east"&&s!=="west"&&c.scale(f)}else{let{up:f,east:d,north:m}=ir;d.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,f),m.copy(f).cross(d);let{down:g,west:p,south:M}=ir;g.copy(f).scale(-1),p.copy(d).scale(-1),M.copy(m).scale(-1),a=ir[t],h=ir[r],c=ir[s]}return n[0]=a.x,n[1]=a.y,n[2]=a.z,n[3]=0,n[4]=h.x,n[5]=h.y,n[6]=h.z,n[7]=0,n[8]=c.x,n[9]=c.y,n[10]=c.z,n[11]=0,n[12]=l.x,n[13]=l.y,n[14]=l.z,n[15]=1,n}var Te=new _,Uf=new _,Vf=new _;function Na(e,t,r=[]){let{oneOverRadii:s,oneOverRadiiSquared:i,centerToleranceSquared:n}=t;Te.from(e);let o=Te.x,a=Te.y,h=Te.z,c=s.x,l=s.y,u=s.z,f=o*o*c*c,d=a*a*l*l,m=h*h*u*u,g=f+d+m,p=Math.sqrt(1/g);if(!Number.isFinite(p))return;let M=Uf;if(M.copy(e).scale(p),g<n)return M.to(r);let x=i.x,S=i.y,v=i.z,w=Vf;w.set(M.x*x*2,M.y*S*2,M.z*v*2);let P=(1-p)*Te.len()/(.5*w.len()),R=0,C,A,b,O;do{P-=R,C=1/(1+P*x),A=1/(1+P*S),b=1/(1+P*v);let N=C*C,B=A*A,L=b*b,et=N*C,Lt=B*A,Vt=L*b;O=f*N+d*B+m*L-1;let xe=-2*(f*et*x+d*Lt*S+m*Vt*v);R=O/xe}while(Math.abs(O)>U.EPSILON12);return Te.scale([C,A,b]).to(r)}var us=new _,La=new _,Wf=new _,Ct=new _,Hf=new _,fs=new _,I=class{constructor(t=0,r=0,s=0){this.centerToleranceSquared=U.EPSILON1,J(t>=0),J(r>=0),J(s>=0),this.radii=new _(t,r,s),this.radiiSquared=new _(t*t,r*r,s*s),this.radiiToTheFourth=new _(t*t*t*t,r*r*r*r,s*s*s*s),this.oneOverRadii=new _(t===0?0:1/t,r===0?0:1/r,s===0?0:1/s),this.oneOverRadiiSquared=new _(t===0?0:1/(t*t),r===0?0:1/(r*r),s===0?0:1/(s*s)),this.minimumRadius=Math.min(t,r,s),this.maximumRadius=Math.max(t,r,s),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||!!(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){let s=La,i=Wf,[,,n]=t;this.geodeticSurfaceNormalCartographic(t,s),i.copy(this.radiiSquared).scale(s);let o=Math.sqrt(s.dot(i));return i.scale(1/o),s.scale(n),i.add(s),i.to(r)}cartesianToCartographic(t,r=[0,0,0]){fs.from(t);let s=this.scaleToGeodeticSurface(fs,Ct);if(!s)return;let i=this.geodeticSurfaceNormal(s,La),n=Hf;n.copy(fs).subtract(s);let o=Math.atan2(i.y,i.x),a=Math.asin(i.z),h=Math.sign(we.dot(n,fs))*we.length(n);return Aa([o,a,h],r)}eastNorthUpToFixedFrame(t,r=new z){return an(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,s,i,n=new z){return an(this,t,r,s,i,n)}geocentricSurfaceNormal(t,r=[0,0,0]){return us.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){let s=Ca(t),i=s[0],n=s[1],o=Math.cos(n);return us.set(o*Math.cos(i),o*Math.sin(i),Math.sin(n)).normalize(),us.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return us.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return Na(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){Ct.from(t);let s=Ct.x,i=Ct.y,n=Ct.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(s*s*o.x+i*i*o.y+n*n*o.z);return Ct.multiplyScalar(a).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return Ct.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return Ct.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,s=[0,0,0]){J(Mt(this.radii.x,this.radii.y,U.EPSILON15)),J(this.radii.z>0),Ct.from(t);let i=Ct.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-r))return Ct.set(0,0,i).to(s)}};I.WGS84=new I(6378137,6378137,kt);var hn;(function(e){e.OUTSIDE="outside",e.INTERSECTING="intersecting",e.INSIDE="inside"})(hn||(hn={}));var Nx=new _,Lx=new _;var nr=new _,Ga=new _,rt=class e{constructor(t=[0,0,0],r=0){this.radius=-0,this.center=new _,this.fromCenterRadius(t,r)}fromCenterRadius(t,r){return this.center.from(t),this.radius=r,this}fromCornerPoints(t,r){return r=nr.from(r),this.center=new _().from(t).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new e(this.center,this.radius)}union(t){let r=this.center,s=this.radius,i=t.center,n=t.radius,o=nr.copy(i).subtract(r),a=o.magnitude();if(s>=a+n)return this.clone();if(n>=a+s)return t.clone();let h=(s+a+n)*.5;return Ga.copy(o).scale((-s+h)/a).add(r),this.center.copy(Ga),this.radius=h,this}expand(t){let s=nr.from(t).subtract(this.center).magnitude();return s>this.radius&&(this.radius=s),this}transform(t){this.center.transform(t);let r=as.getScaling(nr,t);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(t){let r=this.distanceTo(t);return r*r}distanceTo(t){let s=nr.from(t).subtract(this.center);return Math.max(0,s.len()-this.radius)}intersectPlane(t){let r=this.center,s=this.radius,n=t.normal.dot(r)+t.distance;return n<-s?"outside":n<s?"intersecting":"inside"}};var Yf=new _,Zf=new _,ms=new _,ds=new _,ps=new _,$f=new _,Qf=new _,jt={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},zt=class e{constructor(t=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new _().from(t),this.halfAxes=new j(r)}get halfSize(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),s=this.halfAxes.getColumn(2);return[new _(t).len(),new _(r).len(),new _(s).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),s=this.halfAxes.getColumn(2),i=new _(t).normalize(),n=new _(r).normalize(),o=new _(s).normalize();return new wt().fromMatrix3(new j([...i,...n,...o]))}fromCenterHalfSizeQuaternion(t,r,s){let i=new wt(s),n=new j().fromQuaternion(i);return n[0]=n[0]*r[0],n[1]=n[1]*r[0],n[2]=n[2]*r[0],n[3]=n[3]*r[1],n[4]=n[4]*r[1],n[5]=n[5]*r[1],n[6]=n[6]*r[2],n[7]=n[7]*r[2],n[8]=n[8]*r[2],this.center=new _().from(t),this.halfAxes=n,this}clone(){return new e(this.center,this.halfAxes)}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new rt){let r=this.halfAxes,s=r.getColumn(0,ms),i=r.getColumn(1,ds),n=r.getColumn(2,ps),o=Yf.copy(s).add(i).add(n);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let r=this.center,s=t.normal,i=this.halfAxes,n=s.x,o=s.y,a=s.z,h=Math.abs(n*i[jt.COLUMN0ROW0]+o*i[jt.COLUMN0ROW1]+a*i[jt.COLUMN0ROW2])+Math.abs(n*i[jt.COLUMN1ROW0]+o*i[jt.COLUMN1ROW1]+a*i[jt.COLUMN1ROW2])+Math.abs(n*i[jt.COLUMN2ROW0]+o*i[jt.COLUMN2ROW1]+a*i[jt.COLUMN2ROW2]),c=s.dot(r)+t.distance;return c<=-h?"outside":c>=h?"inside":"intersecting"}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let r=Zf.from(t).subtract(this.center),s=this.halfAxes,i=s.getColumn(0,ms),n=s.getColumn(1,ds),o=s.getColumn(2,ps),a=i.magnitude(),h=n.magnitude(),c=o.magnitude();i.normalize(),n.normalize(),o.normalize();let l=0,u;return u=Math.abs(r.dot(i))-a,u>0&&(l+=u*u),u=Math.abs(r.dot(n))-h,u>0&&(l+=u*u),u=Math.abs(r.dot(o))-c,u>0&&(l+=u*u),l}computePlaneDistances(t,r,s=[-0,-0]){let i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,h=a.getColumn(0,ms),c=a.getColumn(1,ds),l=a.getColumn(2,ps),u=$f.copy(h).add(c).add(l).add(o),f=Qf.copy(u).subtract(t),d=r.dot(f);return i=Math.min(d,i),n=Math.max(d,n),u.copy(o).add(h).add(c).subtract(l),f.copy(u).subtract(t),d=r.dot(f),i=Math.min(d,i),n=Math.max(d,n),u.copy(o).add(h).subtract(c).add(l),f.copy(u).subtract(t),d=r.dot(f),i=Math.min(d,i),n=Math.max(d,n),u.copy(o).add(h).subtract(c).subtract(l),f.copy(u).subtract(t),d=r.dot(f),i=Math.min(d,i),n=Math.max(d,n),o.copy(u).subtract(h).add(c).add(l),f.copy(u).subtract(t),d=r.dot(f),i=Math.min(d,i),n=Math.max(d,n),o.copy(u).subtract(h).add(c).subtract(l),f.copy(u).subtract(t),d=r.dot(f),i=Math.min(d,i),n=Math.max(d,n),o.copy(u).subtract(h).subtract(c).add(l),f.copy(u).subtract(t),d=r.dot(f),i=Math.min(d,i),n=Math.max(d,n),o.copy(u).subtract(h).subtract(c).subtract(l),f.copy(u).subtract(t),d=r.dot(f),i=Math.min(d,i),n=Math.max(d,n),s[0]=i,s[1]=n,s}transform(t){this.center.transformAsPoint(t);let r=this.halfAxes.getColumn(0,ms);r.transformAsPoint(t);let s=this.halfAxes.getColumn(1,ds);s.transformAsPoint(t);let i=this.halfAxes.getColumn(2,ps);return i.transformAsPoint(t),this.halfAxes=new j([...r,...s,...i]),this}getTransform(){throw new Error("not implemented")}};var za=new _,qa=new _,$=class e{constructor(t=[0,0,1],r=0){this.normal=new _,this.distance=-0,this.fromNormalDistance(t,r)}fromNormalDistance(t,r){return J(Number.isFinite(r)),this.normal.from(t).normalize(),this.distance=r,this}fromPointNormal(t,r){t=za.from(t),this.normal.from(r).normalize();let s=-this.normal.dot(t);return this.distance=s,this}fromCoefficients(t,r,s,i){return this.normal.set(t,r,s),J(Mt(this.normal.len(),1)),this.distance=i,this}clone(){return new e(this.normal,this.distance)}equals(t){return Mt(this.distance,t.distance)&&Mt(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let r=qa.copy(this.normal).transformAsVector(t).normalize(),s=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(s,r)}projectPointOntoPlane(t,r=[0,0,0]){let s=za.from(t),i=this.getPointDistance(s),n=qa.copy(this.normal).scale(i);return s.subtract(n).to(r)}intersectWithRay(t,r=new _){let s=t.origin,i=t.direction,n=this.normal,o=n.dot(i);if(Math.abs(o)<U.EPSILON15)return;let a=(-this.distance-n.dot(s))/o;if(!(a<0))return r.copy(i).multiplyByScalar(a).add(s)}};var Ba=[new _([1,0,0]),new _([0,1,0]),new _([0,0,1])],Da=new _,Xf=new _,tt=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*Ba.length;let r=t.center,s=t.radius,i=0;for(let n of Ba){let o=this.planes[i],a=this.planes[i+1];o||(o=this.planes[i]=new $),a||(a=this.planes[i+1]=new $);let h=Da.copy(n).scale(-s).add(r);o.fromPointNormal(h,n);let c=Da.copy(n).scale(s).add(r),l=Xf.copy(n).negate();a.fromPointNormal(c,l),i+=2}return this}computeVisibility(t){let r="inside";for(let s of this.planes)switch(t.intersectPlane(s)){case"outside":return"outside";case"intersecting":r="intersecting";break;default:}return r}computeVisibilityWithPlaneMask(t,r){if(J(Number.isFinite(r),"parentPlaneMask is required."),r===e.MASK_OUTSIDE||r===e.MASK_INSIDE)return r;let s=e.MASK_INSIDE,i=this.planes;for(let n=0;n<this.planes.length;++n){let o=n<31?1<<n:0;if(n<31&&(r&o)===0)continue;let a=i[n],h=t.intersectPlane(a);if(h==="outside")return e.MASK_OUTSIDE;h==="intersecting"&&(s|=o)}return s}};tt.MASK_OUTSIDE=4294967295;tt.MASK_INSIDE=0;tt.MASK_INDETERMINATE=2147483647;var ly=new _,uy=new _,fy=new _,my=new _,dy=new _;var yy=new _,Sy=new _,vy=new _,Ey=new _,wy=new _,Ty=new _,Py=new _,by=new _,Ry=new _,Cy=new _,Ay=new _,Iy=new _;var Ly=new j,Gy=new j,zy=new j,qy=new j,By=new j;var jy=new _,Wy=new _,Hy=new _,Yy=new _,Zy=new _,$y=new j,Qy={diagonal:new j,unitary:new j};var em=new _,cn=new _,rm=new z,sm=new _,or=class{constructor(t,r=I.WGS84){let s=r.scaleToGeodeticSurface(t,em),i=r.eastNorthUpToFixedFrame(s,rm);this._origin=new _(s),this._xAxis=new _(cn.from(i.getColumn(0))),this._yAxis=new _(cn.from(i.getColumn(1)));let n=new _(cn.from(i.getColumn(2)));this._plane=new $().fromPointNormal(this._origin,n)}projectPointToNearestOnPlane(t,r){r||(r=new Et);let i=this._plane.projectPointOntoPlane(t,sm).subtract(this._origin),n=this._xAxis.dot(i),o=this._yAxis.dot(i);return r.x=n,r.y=o,r}get plane(){return this._plane}get origin(){return this._origin}get xAxis(){return this._xAxis}get yAxis(){return this._yAxis}get zAxis(){return this._plane.normal}};var Pe=class{constructor(t,r,s,i){this.west=t,this.south=r,this.east=s,this.north=i}static center(t,r){r||(r=new _);let s=t.east,i=t.west;s<i&&(s+=U.TWO_PI);let n=bi((i+s)*.5,"negative-pi-to-pi"),o=(t.south+t.north)*.5;return r.x=n,r.y=o,r.z=0,r}get width(){let t=this.east,r=this.west;return t<r&&(t+=U.TWO_PI),t-r}};var im=new _,nm=new _,om=new _,am=new _,hm=new _,cm=new _,lm=new _,um=new _,Va=new _,fm=new _,ka=new _,mm=new _,dm=new Et,pm=new Et,gm=new Et,_m=new Et,Mm=new Et,xm=new $,ym=new _,Sm=new _,vm=new _,Em=new _,wm=new Et,Tm=new _,Pm=new _,bm=new _(1,0,0),Rm=new _(0,0,1);function ln(e,t=I.WGS84,r={}){if(!e||e.length!==6||e.some(x=>!Number.isFinite(x)))throw new Error("makeOBBFromRegion: region must contain exactly six finite numbers");let s=r.units==="degrees"?Zr(1):1,[i,n,o,a,h,c]=e;if(h>c)throw new Error("makeOBBFromRegion: minimumHeight must not exceed maximumHeight");let l=n*s,u=a*s,f=ja(i*s),d=ja(o*s);o*s-i*s>=U.TWO_PI-1e-12&&(d=f+U.TWO_PI);let g=1e-12;if(l>u||l<-U.PI_OVER_TWO-g||u>U.PI_OVER_TWO+g)throw new Error("makeOBBFromRegion: latitude must be within [-\u03C0/2, \u03C0/2] and south \u2264 north");let p=Math.max(-U.PI_OVER_TWO,Math.min(U.PI_OVER_TWO,l)),M=Math.max(-U.PI_OVER_TWO,Math.min(U.PI_OVER_TWO,u));return Cm([f,p,d,M,h,c],t,r.transform)}function ja(e){let t=((e+Math.PI)%U.TWO_PI+U.TWO_PI)%U.TWO_PI-Math.PI;return t===-Math.PI&&e>0?Math.PI:t}function Cm(e,t,r){let s=new zt,[i,n,o,a,h,c]=e,l=ct(a),u=ct(n),f,d,m,g,p,M,x,S=new Pe(i,n,o,a),v=Pe.center(S,nm),w=new _([ct(v.x),ct(v.y),0]),P=v.x,R=w.x;if(S.width<=U.PI){let xi=ct(i),x0=t.cartographicToCartesian(w),Gt=new or(x0,t),y0=u<0&&l>0?0:w.y,S0=om.copy([R,l,c]),yi=am.copy([xi,l,c]),v0=hm.copy([xi,y0,c]),Si=cm.copy([xi,u,c]),E0=lm.copy([R,u,c]),w0=t.cartographicToCartesian(S0,um),vi=t.cartographicToCartesian(yi,Va),T0=t.cartographicToCartesian(v0,fm),Ei=t.cartographicToCartesian(Si,ka),P0=t.cartographicToCartesian(E0,mm),b0=Gt.projectPointToNearestOnPlane(w0,dm),To=Gt.projectPointToNearestOnPlane(vi,pm),R0=Gt.projectPointToNearestOnPlane(T0,gm),Po=Gt.projectPointToNearestOnPlane(Ei,_m),C0=Gt.projectPointToNearestOnPlane(P0,Mm);return g=Math.min(To.x,R0.x,Po.x),f=-g,d=Math.max(To.y,b0.y),p=Math.min(Po.y,C0.y),yi.z=Si.z=h,vi=t.cartographicToCartesian(yi,Va),Ei=t.cartographicToCartesian(Si,ka),x=Gt.plane,M=Math.min(x.getPointDistance(vi),x.getPointDistance(Ei)),m=c,Wa(Ya(Gt.origin,Gt.xAxis,Gt.yAxis,Gt.zAxis,g,f,p,d,M,m,s),r)}let C=ct(o),A=n>0,b=a<0,O=A?u:b?l:0,N=t.cartographicToCartesian([R,O,c],ym);N.z=0;let L=Math.abs(N.x)<U.EPSILON10&&Math.abs(N.y)<U.EPSILON10?bm:Sm.copy(N).normalize(),et=Rm,Lt=vm.copy(L).cross(et);x=xm.fromPointNormal(N,L);let Vt=t.cartographicToCartesian([ct(P+U.PI_OVER_TWO),O,c],Em);f=x.projectPointOntoPlane(Vt,wm).dot(Lt),g=-f;let xe=b?h:c,_0=A?h:c;d=Ha(t,l,xe,!0),p=Ha(t,u,_0,!1);let M0=t.cartographicToCartesian([C,O,c],Pm);return M=x.getPointDistance(M0),m=0,Wa(Ya(N,Lt,et,L,g,f,p,d,M,m,s),r)}function Wa(e,t){if(!t)return e;let r=[0,1,2].map(a=>e.halfAxes.getColumn(a,new _)),s=t.transformAsPoint(e.center),i=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let a=0;a<8;a++){let h=new _(s);for(let c=0;c<3;c++){let l=t.transformAsVector(r[c]);h.add(new _(l).scale((a&1<<c)===0?-1:1))}for(let c=0;c<3;c++)i[c]=Math.min(i[c],h[c]),n[c]=Math.max(n[c],h[c])}e.center.copy(i).add(n).scale(.5);let o=new _(n).subtract(i).scale(.5);return e.halfAxes=new j().set(o.x,0,0,0,o.y,0,0,0,o.z),e}function Ha(e,t,r,s){let i=s?-1/0:1/0;for(let n of[0,90,180,270]){let o=e.cartographicToCartesian([n,t,r],Tm).z;i=s?Math.max(i,o):Math.min(i,o)}return i}function Ya(e,t,r,s,i,n,o,a,h,c,l){let u=l.center,f=l.halfAxes;f.setColumn(0,t),f.setColumn(1,r),f.setColumn(2,s);let d=im.set((i+n)/2,(o+a)/2,(h+c)/2).transformByMatrix3(f),m=(n-i)/2,g=(a-o)/2,p=(c-h)/2;return f[0]*=m,f[1]*=m,f[2]*=m,f[3]*=g,f[4]*=g,f[5]*=g,f[6]*=p,f[7]*=p,f[8]*=p,u.copy(e).add(d),l}function ar(){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 le=class{constructor(t,r){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=r,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=ar(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(ar()-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 Tt=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,r="count"){return this._getOrCreate({name:t,type:r})}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 r of Object.values(this.stats))t(r)}getTable(){let t={};return this.forEach(r=>{t[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(r=>this._getOrCreate(r))}_getOrCreate(t){let{name:r,type:s}=t,i=this.stats[r];return i||(t instanceof le?i=t:i=new le(r,s),this.stats[r]=i),i}};function At(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var Am="Queued Requests",Im="Active Requests",Om="Cancelled Requests",Nm="Queued Requests Ever",Lm="Active Requests Ever",Gm={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={...Gm,...t},this.stats=new Tt({id:this.props.id}),this.stats.get(Am),this.stats.get(Im),this.stats.get(Om),this.stats.get(Nm),this.stats.get(Lm)}setProps(t){t.throttleRequests!==void 0&&(this.props.throttleRequests=t.throttleRequests),t.maxRequests!==void 0&&(this.props.maxRequests=t.maxRequests),t.debounceTime!==void 0&&(this.props.debounceTime=t.debounceTime)}scheduleRequest(t,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let s={handle:t,priority:0,getPriority:r},i=new Promise(n=>(s.resolve=n,s));return this.requestQueue.push(s),this.requestMap.set(t,i),this._issueNewRequests(),i}_issueRequest(t){let{handle:r,resolve:s}=t,i=!1,n=()=>{i||(i=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,s?s({done:n}):Promise.resolve({done:n})}_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 r=0;r<t;++r){let s=this.requestQueue.shift();s&&this._issueRequest(s)}}}_updateAllRequests(){let t=this.requestQueue;for(let r=0;r<t.length;++r){let s=t[r];this._updateRequest(s)||(t.splice(r,1),this.requestMap.delete(s.handle),r--)}t.sort((r,s)=>r.priority-s.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var zm=Number.POSITIVE_INFINITY,qm=Number.POSITIVE_INFINITY,hr=class{maxEntries;maxBytes;getByteLength;onRemove;entries=new Map;retainedByteLength=0;constructor(t={}){this.maxEntries=Za(t.maxEntries,zm,"maxEntries"),this.maxBytes=Za(t.maxBytes,qm,"maxBytes"),this.getByteLength=t.getByteLength||(()=>0),this.onRemove=t.onRemove}get size(){return this.entries.size}get pendingSize(){let t=0;for(let r of this.entries.values())t+=r.pending?1:0;return t}get byteLength(){return this.retainedByteLength}get(t,r){let s=this.entries.get(t);if(s)return this.touch(t,s),this.waitForEntry(t,s,r)}has(t){return this.entries.has(t)}set(t,r){this.removeEntry(t,"replace");let s=$a(this.getByteLength(r)),i={promise:Promise.resolve(r),pending:!1,waiterCount:0,byteLength:s};return this.entries.set(t,i),this.retainedByteLength+=s,this.trim(),r}getOrLoad(t,r,s){let i=this.get(t,s);if(i)return i;if(s?.aborted)return Promise.reject(un());let n=new AbortController,o,a,c={promise:new Promise((l,u)=>{o=l,a=u}),controller:n,pending:!0,waiterCount:0,byteLength:0};this.entries.set(t,c),c.promise.then(l=>this.handleLoadedValue(t,c,l),()=>this.handleLoadError(t,c));try{Promise.resolve(r(n.signal)).then(o,a)}catch(l){a(l)}return this.waitForEntry(t,c,s)}delete(t){return this.removeEntry(t,"delete")}clear(){for(let t of Array.from(this.entries.keys()))this.removeEntry(t,"clear")}handleLoadedValue(t,r,s){if(this.entries.get(t)===r){r.pending=!1,r.controller=void 0;try{r.byteLength=$a(this.getByteLength(s))}catch{this.removeEntry(t,"error");return}this.retainedByteLength+=r.byteLength,this.trim()}}handleLoadError(t,r){this.entries.get(t)===r&&this.removeEntry(t,r.controller?.signal.aborted?"abort":"error")}waitForEntry(t,r,s){return s?.aborted?Promise.reject(un()):r.pending?(r.waiterCount++,new Promise((i,n)=>{let o=!0,a=()=>{o&&(o=!1,s?.removeEventListener("abort",h),r.waiterCount--)},h=()=>{o&&(a(),n(un()),r.pending&&r.waiterCount===0&&this.entries.get(t)===r&&this.removeEntry(t,"abort"))};s?.addEventListener("abort",h,{once:!0}),r.promise.then(c=>{o&&(a(),i(c))},c=>{o&&(a(),n(c))})})):r.promise}touch(t,r){this.entries.delete(t),this.entries.set(t,r)}trim(){let t=this.entries.size-this.pendingSize;if(!(t<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)){for(let[r,s]of this.entries)if(s.pending||(this.removeEntry(r,"evict"),t--),t<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)break}}removeEntry(t,r){let s=this.entries.get(t);return s?(this.entries.delete(t),this.retainedByteLength-=s.byteLength,s.pending&&s.controller?.abort(),this.onRemove?.(t,r),!0):!1}};function un(){let e=new Error("Request aborted");return e.name="AbortError",e}function Za(e,t,r){let s=e??t;if(s<0||Number.isNaN(s))throw new Error(`${r} must be a non-negative number`);return s}function $a(e){if(!Number.isFinite(e)||e<0)throw new Error("Request cache entry byte length must be a non-negative finite number");return e}var W={logicalRanges:"Logical Range Requests",rangeBatches:"Range Request Batches",transportRanges:"Transport Ranges Created",completedTransportRanges:"Range Transport Requests Completed",coalescedRanges:"Coalesced Logical Ranges",requestedBytes:"Logical Range Request Bytes",transportBytes:"Range Transport Bytes Requested",responseBytes:"Range Response Bytes",networkTimeMs:"Range Network Time",overfetchBytes:"Range Overfetch Bytes",failedTransportRanges:"Range Transport Requests Failed",abortedLogicalRanges:"Aborted Logical Range Requests",fullResponseFallbacks:"Full Response Fallbacks"},fn={batchDelayMs:50,maxGapBytes:65536,rangeExpansionBytes:65536,maxMergedBytes:8388608,stats:Ka("range-request-scheduler-default"),onEvent:()=>{}},_s=class{props;stats;onEvent;pendingRequests=[];flushTimer=null;constructor(t={}){let r=t.rangeExpansionBytes??t.maxGapBytes??fn.rangeExpansionBytes;this.props={batchDelayMs:t.batchDelayMs??fn.batchDelayMs,maxGapBytes:t.maxGapBytes??r,rangeExpansionBytes:r,maxMergedBytes:t.maxMergedBytes??fn.maxMergedBytes},this.stats=t.stats||Ka("range-request-scheduler"),this.onEvent=t.onEvent,Ja(this.stats)}scheduleRequest(t){if(t.length<0)return Promise.reject(new Error("Byte range length cannot be negative"));if(t.signal?.aborted)return Promise.reject(Xa());if(t.length===0)return Promise.resolve(new ArrayBuffer(0));let r=new Promise((s,i)=>{let n={...t,resolve:s,reject:i,settled:!1};t.signal&&(n.abortListener=()=>{this.abortRequest(n),n.onAbort?.()},t.signal.addEventListener("abort",n.abortListener,{once:!0})),this.pendingRequests.push(n)});return this.trackEvent({type:"queued",sourceId:t.sourceId,offset:t.offset,length:t.length,logicalRequestCount:1,logicalBytes:t.length}),this.scheduleFlush(),r}fetch(t){let r=t.fetch||globalThis.fetch;return this.scheduleRequest({sourceId:t.sourceId||t.url,offset:t.offset,length:t.length,signal:t.signal,isolationKey:t.isolationKey??{},fetchRange:(s,i,n)=>Dm({url:t.url,offset:s,length:i,signal:n,fetch:r,fetchOptions:t.fetchOptions})})}flush(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null);let t=this.pendingRequests;this.pendingRequests=[];let r=t.filter(i=>i.settled||i.signal?.aborted?(this.abortRequest(i),!1):!0),s=this.mergeRequests(r);r.length>0&&this.trackBatch(r,s);for(let i of s)this.fetchMergedRequest(i)}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>this.flush(),this.props.batchDelayMs))}mergeRequests(t){t.sort((s,i)=>s.sourceId!==i.sourceId?s.sourceId<i.sourceId?-1:1:s.offset-i.offset);let r=[];for(let s of t){let i=s.offset+s.length,n=r[r.length-1];n&&Fm(n,s,this.props)?(n.endOffset=Math.max(n.endOffset,i),n.requests.push(s)):r.push({sourceId:s.sourceId,isolationKey:s.isolationKey??s.sourceId,offset:s.offset,endOffset:i,fetchRange:s.fetchRange,requests:[s]})}return r}async fetchMergedRequest(t){let{offset:r,endOffset:s,fetchRange:i,requests:n}=t,o=new AbortController,a=cr(),h=()=>{n.every(c=>c.signal?.aborted)&&o.abort()};try{for(let p of n)p.onAbort=h;if(h(),n.every(p=>p.settled))return;let c=mn(n),l=s-r;this.trackEvent({type:"request",sourceId:t.sourceId,offset:r,length:l,logicalRequestCount:n.length,logicalBytes:c,transportBytes:l,overfetchBytes:Math.max(l-c,0)});let u=Um(await i(r,l,o.signal)),{arrayBuffer:f}=u,d=u.fullResponse&&r===0&&f.byteLength<l,m=f.byteLength<l&&Number.isSafeInteger(u.sourceByteLength)&&r+f.byteLength===u.sourceByteLength;if(f.byteLength!==l&&!d&&!m)throw new Error(`Byte-range transport returned ${f.byteLength} bytes; expected ${l}`);let g=u.networkTimeMs??cr()-a;this.trackEvent({type:"response",sourceId:t.sourceId,offset:r,length:l,logicalRequestCount:n.length,logicalBytes:c,transportBytes:l,responseBytes:u.transportBytes??f.byteLength,networkTimeMs:g,overfetchBytes:Math.max(l-c,0),status:u.status,fullResponse:u.fullResponse});for(let p of n){if(p.settled)continue;let M=p.offset-r;p.settled=!0,p.resolve(f.slice(M,M+p.length))}}catch(c){this.trackEvent({type:"error",sourceId:t.sourceId,offset:r,length:s-r,logicalRequestCount:n.length,logicalBytes:mn(n),networkTimeMs:cr()-a,error:c});for(let l of n)l.settled||(l.signal?.aborted?this.abortRequest(l):(l.settled=!0,l.reject(c)))}finally{for(let c of n)c.abortListener&&c.signal?.removeEventListener("abort",c.abortListener),c.onAbort=void 0}}abortRequest(t){t.settled||(t.settled=!0,t.reject(Xa()),this.trackEvent({type:"abort",sourceId:t.sourceId,offset:t.offset,length:t.length,logicalRequestCount:1,logicalBytes:t.length}))}trackEvent(t){Bm(this.stats,t);try{this.onEvent?.(t)}catch{}}trackBatch(t,r){let s=mn(t),i=r.reduce((n,o)=>n+o.endOffset-o.offset,0);this.trackEvent({type:"batch",logicalRequestCount:t.length,transportRequestCount:r.length,logicalBytes:s,transportBytes:i,overfetchBytes:Math.max(i-s,0)})}};function Bm(e,t){switch((t.type==="response"||t.type==="error")&&t.networkTimeMs!==void 0&&e.get(W.networkTimeMs,"time").addTime(t.networkTimeMs),t.type){case"queued":e.get(W.logicalRanges,"count").incrementCount(),e.get(W.requestedBytes,"count").addCount(t.logicalBytes||0);break;case"batch":e.get(W.rangeBatches,"count").incrementCount(),e.get("Logical Ranges Batched","count").addCount(t.logicalRequestCount||0),e.get(W.transportRanges,"count").addCount(t.transportRequestCount||0),e.get(W.coalescedRanges,"count").addCount(Math.max((t.logicalRequestCount||0)-(t.transportRequestCount||0),0)),e.get(W.transportBytes,"count").addCount(t.transportBytes||0),e.get(W.overfetchBytes,"count").addCount(t.overfetchBytes||0);break;case"response":e.get(W.completedTransportRanges,"count").incrementCount(),e.get(W.responseBytes,"count").addCount(t.responseBytes||0),t.fullResponse&&e.get(W.fullResponseFallbacks,"count").incrementCount();break;case"error":e.get(W.failedTransportRanges,"count").incrementCount();break;case"abort":e.get(W.abortedLogicalRanges,"count").incrementCount();break;default:}}function Ka(e="range-request-scheduler"){let t=new Tt({id:e});return Ja(t),t}async function Dm(e){let t=Wm(e.signal),r=cr();try{let s=!1,i=await e.fetch(e.url,Qa(e.fetchOptions,e.offset,e.length,t.signal));if(i.status===416&&e.offset===0){let h=km(i.headers.get("Content-Range"));if(!h)throw new Error("Missing content-length on 416 response");i=await e.fetch(e.url,Qa(e.fetchOptions,0,h,t.signal)),s=!0}if(i.status===200)throw t.abort(),await Hm(i),new Error("Byte-range request failed: server returned 200 instead of 206");if(i.status!==206&&!i.ok)throw new Error(`Bad response code: ${i.status}`);let n=await i.arrayBuffer(),o=i.headers.get("Content-Range"),a=jm(o);if(o&&!a)throw new Error(`Invalid Content-Range header: ${o}`);if(a){let h=a.endOffset-a.offset+1,c=e.offset+e.length-1;if(a.offset!==e.offset||a.endOffset>c||h!==n.byteLength||a.sourceByteLength!==void 0&&a.endOffset>=a.sourceByteLength)throw new Error(`Content-Range does not match requested range: ${o}`)}return{arrayBuffer:n,status:i.status,sourceByteLength:a?.sourceByteLength,transportBytes:n.byteLength,networkTimeMs:cr()-r,fullResponse:s}}finally{t.removeAbortListener()}}function Fm(e,t,r){if(e.sourceId!==t.sourceId||e.isolationKey!==(t.isolationKey??t.sourceId))return!1;let s=t.offset+t.length,i=t.offset-e.endOffset,n=Math.max(e.endOffset,s)-e.offset;return i<=r.rangeExpansionBytes&&n<=r.maxMergedBytes}function Ja(e){e.get(W.logicalRanges,"count"),e.get(W.requestedBytes,"count"),e.get(W.rangeBatches,"count"),e.get("Logical Ranges Batched","count"),e.get(W.transportRanges,"count"),e.get(W.coalescedRanges,"count"),e.get(W.transportBytes,"count"),e.get(W.completedTransportRanges,"count"),e.get(W.responseBytes,"count"),e.get(W.networkTimeMs,"time"),e.get(W.overfetchBytes,"count"),e.get(W.fullResponseFallbacks,"count"),e.get(W.failedTransportRanges,"count"),e.get(W.abortedLogicalRanges,"count")}function mn(e){return e.reduce((t,r)=>t+r.length,0)}function Um(e){return e instanceof ArrayBuffer?{arrayBuffer:e}:e}function Qa(e,t,r,s){return{...e,signal:s,headers:{...Vm(e?.headers),Range:`bytes=${t}-${t+r-1}`}}}function Vm(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):e:{}}function km(e){let t=e?.match(/^bytes \*\/(\d+)$/);return t?Number(t[1]):null}function jm(e){let t=e?.match(/^bytes (\d+)-(\d+)\/(\d+|\*)$/);if(!t)return null;let r=Number(t[1]),s=Number(t[2]),i=t[3]==="*"?void 0:Number(t[3]);return!Number.isSafeInteger(r)||!Number.isSafeInteger(s)||r>s||i!==void 0&&!Number.isSafeInteger(i)?null:{offset:r,endOffset:s,sourceByteLength:i}}function Wm(e){let t=new AbortController,r=()=>t.abort();return e?.aborted?t.abort():e?.addEventListener("abort",r,{once:!0}),{signal:t.signal,abort:()=>t.abort(),removeAbortListener:()=>e?.removeEventListener("abort",r)}}async function Hm(e){await e.body?.cancel().catch(()=>{})}function cr(){return globalThis.performance?.now()??Date.now()}function Xa(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}var xt={};$e(xt,{dirname:()=>Zm,filename:()=>Ym,join:()=>$m,resolve:()=>Qm});function th(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function Ym(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function Zm(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function $m(...e){return e=e.map((r,s)=>(s&&(r=r.replace(new RegExp("^/"),"")),s!==e.length-1&&(r=r.replace(new RegExp("/$"),"")),r)),e.join("/")}function Qm(...e){let t=[];for(let n=0;n<e.length;n++)t[n]=e[n];let r="",s=!1,i;for(let n=t.length-1;n>=-1&&!s;n--){let o;n>=0?o=t[n]:(i===void 0&&(i=th()),o=i),o.length!==0&&(r=`${o}/${r}`,s=o.charCodeAt(0)===lr)}return r=Xm(r,!s),s?`/${r}`:r.length>0?r:"."}var lr=47,dn=46;function Xm(e,t){let r="",s=-1,i=0,n,o=!1;for(let a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(n===lr)break;n=lr}if(n===lr){if(!(s===a-1||i===1))if(s!==a-1&&i===2){if(r.length<2||!o||r.charCodeAt(r.length-1)!==dn||r.charCodeAt(r.length-2)!==dn){if(r.length>2){let h=r.length-1,c=h;for(;c>=0&&r.charCodeAt(c)!==lr;--c);if(c!==h){r=c===-1?"":r.slice(0,c),s=a,i=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",s=a,i=0,o=!1;continue}}t&&(r.length>0?r+="/..":r="..",o=!0)}else{let h=e.slice(s+1,a);r.length>0?r+=`/${h}`:r=h,o=!1}s=a,i=0}else n===dn&&i!==-1?++i:i=-1}return r}var be=class{handle;size;bigsize;url;constructor(t){this.handle=t instanceof ArrayBuffer?new Blob([t]):t,this.size=t instanceof ArrayBuffer?t.byteLength:t.size,this.bigsize=BigInt(this.size),this.url=t instanceof File?t.name:""}async close(){}async stat(){return{size:this.handle.size,bigsize:BigInt(this.handle.size),isDirectory:!1}}async read(t,r,s){if(s?.aborted)throw new Error("Request aborted");let i=await this.handle.slice(Number(t),Number(t)+Number(r)).arrayBuffer();if(s?.aborted)throw new Error("Request aborted");return i}};var ys=class{url;fetchFunction;fetchOptions;consistency;identityHints;countedFailures=new WeakSet;telemetry={requestedBytes:0,downloadedBytes:0,requestCount:0,networkTimeMs:0,abortCount:0,errorCount:0};constructor(t,r){sd(r.byteLength),this.url=t,this.fetchFunction=r.fetch||((s,i)=>globalThis.fetch(s,i)),this.fetchOptions=r.fetchOptions?{...r.fetchOptions,headers:new Headers(r.fetchOptions.headers)}:void 0,this.consistency=r.consistency||"best-effort",this.identityHints={byteLength:r.byteLength,etag:vs(r.etag),lastModified:vs(r.lastModified)}}getInitialIdentity(){let{byteLength:t,etag:r,lastModified:s}=this.identityHints;return t!==void 0&&(r!==void 0||s!==void 0)?Ss(t,r,s):t===0&&this.consistency==="best-effort"?Ss(0):null}getTelemetry(){return Object.freeze({...this.telemetry})}trackFailure(t){if(typeof t=="object"&&t!==null){if(this.countedFailures.has(t))return;this.countedFailures.add(t)}ih(t)?this.telemetry.abortCount++:this.telemetry.errorCount++}async requestRange(t,r,s,i){let n=Ms(),o=id(s,this.fetchOptions?.signal);this.telemetry.requestCount++,this.telemetry.requestedBytes+=r;try{let a=await this.fetchFunction(this.url,Km(this.fetchOptions,t,r,o.signal));if(Jm(a,t,r,i))return await this.readEmptyIdentityProbe(a,n);if(a.status!==206)throw await xs(a),new Error(`HTTP byte-range request expected 206, received ${a.status}`);let h=await td(a),c=eh(a,h.byteLength),l=sh(i,c,this.identityHints,this.consistency)||rd(h,t,r);if(l)throw await xs(a),new Error(l);let u=await a.arrayBuffer();if(this.telemetry.downloadedBytes+=u.byteLength,u.byteLength!==r)throw new Error(`HTTP byte-range response contained ${u.byteLength} bytes; expected ${r}`);return{arrayBuffer:u,identity:rh(i,c,this.identityHints),status:a.status,transportBytes:u.byteLength,networkTimeMs:Ms()-n}}catch(a){throw(i===null||!ih(a))&&this.trackFailure(a),a}finally{o.removeAbortListeners(),this.telemetry.networkTimeMs+=Ms()-n}}async readEmptyIdentityProbe(t,r){let s=eh(t,0),i=sh(null,s,this.identityHints,this.consistency);if(await xs(t),i)throw new Error(i);return{arrayBuffer:new ArrayBuffer(0),identity:rh(null,s,this.identityHints),status:t.status,transportBytes:0,networkTimeMs:Ms()-r}}};function Km(e,t,r,s){let i=new Headers(e?.headers);return i.set("Range",`bytes=${t}-${t+r-1}`),{...e,method:"GET",body:void 0,headers:i,signal:s}}function Jm(e,t,r,s){return e.status===416&&s===null&&t===0&&r===1&&/^bytes \*\/0$/i.test(e.headers.get("Content-Range")||"")}async function td(e){try{return ed(e.headers.get("Content-Range"))}catch(t){throw await xs(e),t}}function ed(e){let t=e?.match(/^bytes (\d+)-(\d+)\/(\d+)$/);if(!t)throw new Error("HTTP byte-range response has an invalid Content-Range header");return{offset:Number(t[1]),endOffset:Number(t[2]),byteLength:Number(t[3])}}function eh(e,t){return Ss(t,vs(e.headers.get("ETag")),vs(e.headers.get("Last-Modified")))}function rh(e,t,r){return e||Ss(t.byteLength,t.etag??r.etag,t.lastModified??r.lastModified)}function rd(e,t,r){return!Number.isSafeInteger(e.offset)||!Number.isSafeInteger(e.endOffset)||!Number.isSafeInteger(e.byteLength)||e.offset<0||e.endOffset<e.offset||e.endOffset>=e.byteLength?"HTTP byte-range response has invalid range bounds":e.offset!==t||e.endOffset!==t+r-1?"HTTP byte-range response does not match the requested range":null}function sh(e,t,r,s){let i=e?.byteLength??r.byteLength;if(i!==void 0&&t.byteLength!==i)return"HTTP file length changed while the file was open";let n=e?.etag??r.etag,o=e?.lastModified??r.lastModified;return n?t.etag?n===t.etag?null:"HTTP file ETag changed while the file was open":s==="strict"?"HTTP byte-range response is missing the pinned ETag":o&&t.lastModified&&o!==t.lastModified?"HTTP file Last-Modified value changed while the file was open":null:o?t.lastModified&&o!==t.lastModified?"HTTP file Last-Modified value changed while the file was open":s==="strict"&&!t.lastModified?"HTTP byte-range response is missing the pinned Last-Modified value":null:s==="strict"&&!t.etag&&!t.lastModified?"HTTP byte-range response does not provide an ETag or Last-Modified validator":null}function Ss(e,t,r){return Object.freeze({byteLength:e,etag:t,lastModified:r})}function sd(e){if(e!==void 0&&(!Number.isSafeInteger(e)||e<0))throw new Error("HttpFile byteLength must be a non-negative safe integer")}async function xs(e){await e.body?.cancel().catch(()=>{})}function vs(e){return e||void 0}function Ms(){return globalThis.performance?.now()??Date.now()}function ih(e){return e instanceof Error&&e.name==="AbortError"||e instanceof Error&&/aborted/i.test(e.message)}function id(...e){let t=new AbortController,r=[...new Set(e.filter(i=>!!i))],s=()=>t.abort();for(let i of r)i.aborted?t.abort():i.addEventListener("abort",s,{once:!0});return{signal:t.signal,removeAbortListeners:()=>{for(let i of r)i.removeEventListener("abort",s)}}}var ur=class e{handle;url;transport;rangeScheduler;schedulerIsolationKey={};suppliedByteLength;identity;openPromise=null;closed=!1;constructor(t,r={}){this.handle=t,this.url=t,this.transport=new ys(t,r),this.rangeScheduler=r.rangeScheduler||new _s({batchDelayMs:0,...r.rangeSchedulerProps}),this.suppliedByteLength=r.byteLength,this.identity=this.transport.getInitialIdentity()}static async open(t,r={},s){let i=new e(t,r);return await i.open(s),i}async open(t){if(this.assertOpen(),t?.aborted){let r=Es();throw this.transport.trackFailure(r),r}return await this.getIdentity(t),this}get size(){return this.identity?.byteLength??this.suppliedByteLength??0}get bigsize(){return BigInt(this.size)}getIdentitySnapshot(){return this.identity}getTelemetry(){return this.transport.getTelemetry()}async close(){this.closed=!0}async stat(){this.assertOpen();let t=await this.getIdentity();return{size:t.byteLength,bigsize:BigInt(t.byteLength),isDirectory:!1}}async read(t=0,r=0,s){if(this.assertOpen(),s?.aborted){let o=Es();throw this.transport.trackFailure(o),o}let i=await this.getIdentity(s),n=nh(t);if(od(n,r,i.byteLength),r===0)return new ArrayBuffer(0);try{return await this.rangeScheduler.scheduleRequest({sourceId:this.url,isolationKey:this.schedulerIsolationKey,offset:n,length:r,signal:s,fetchRange:this.fetchScheduledRange})}catch(o){throw this.transport.trackFailure(o),o}}async fetchRange(t,r,s){let i=nh(t),n=await this.read(i,r,s),o=nd(this.identity,i,r);return new Response(n,{status:206,headers:o})}fetchScheduledRange=async(t,r,s)=>{let i=await this.getIdentity(s),n=await this.transport.requestRange(t,r,s,i);return{arrayBuffer:n.arrayBuffer,status:n.status,transportBytes:n.transportBytes,networkTimeMs:n.networkTimeMs}};getIdentity(t){if(this.identity)return Promise.resolve(this.identity);if(!this.openPromise){let s=this.probeIdentity().catch(i=>{throw this.openPromise===s&&(this.openPromise=null),i});this.openPromise=s}return ad(this.openPromise,t).catch(r=>{throw this.transport.trackFailure(r),r})}async probeIdentity(){try{let t=await this.transport.requestRange(0,1,void 0,null);return this.identity=t.identity,t.identity}catch(t){throw this.transport.trackFailure(t),t}}assertOpen(){if(this.closed)throw new Error("HttpFile is closed")}};function nd(e,t,r){let s=new Headers;return r>0&&e&&s.set("Content-Range",`bytes ${t}-${t+r-1}/${e.byteLength}`),e?.etag&&s.set("ETag",e.etag),e?.lastModified&&s.set("Last-Modified",e.lastModified),s}function nh(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<0)throw new Error("HTTP byte-range offset must be a non-negative safe integer");return t}function od(e,t,r){if(!Number.isSafeInteger(t)||t<0)throw new Error("HTTP byte-range length must be a non-negative safe integer");if(e+t>r)throw new Error("HTTP byte range extends beyond the end of the file")}function Es(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}function ad(e,t){return t?t.aborted?Promise.reject(Es()):new Promise((r,s)=>{let i=()=>{t.removeEventListener("abort",i),s(Es())};t.addEventListener("abort",i,{once:!0}),e.then(n=>{t.removeEventListener("abort",i),r(n)},n=>{t.removeEventListener("abort",i),s(n)})}):e}function ws(e={}){if(e.coordinateEpoch!==void 0&&!Number.isFinite(e.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:oh(e.crs||{state:"absent",provenance:"unknown"}),vertical:e.vertical?oh(e.vertical):void 0,coordinateEpoch:e.coordinateEpoch,coordinateFrame:e.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...e.coordinateOrder||[]]),units:e.units?Object.freeze([...e.units]):void 0})}function fr(e){if(typeof e=="object")return"projjson";let t=e.trim();return/^[A-Z][A-Z0-9_]*\s*[\[(]/i.test(t)?"wkt":/(?:^|\s)\+?proj=/i.test(t)?"proj-string":/^[A-Z][A-Z0-9._-]*(?::[A-Z0-9._-]+)+$/i.test(t)||/^urn:ogc:def:crs:/i.test(t)||/^https?:\/\//i.test(t)||/^[A-Z][A-Z0-9._-]*$/i.test(t)?"identifier":"opaque"}function oh(e){return e.state==="explicit"||e.state==="default"?Object.freeze({...e,definition:ah(e.definition),alternatives:e.alternatives?Object.freeze(e.alternatives.map(t=>Object.freeze({...t,definition:ah(t.definition)}))):void 0}):Object.freeze({...e})}function ah(e){return typeof e=="string"?e:pn(e)}function pn(e){return Array.isArray(e)?Object.freeze(e.map(t=>pn(t))):e&&typeof e=="object"?Object.freeze(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,pn(r)]))):e}var Ts=class{item;previous;next;constructor(t,r,s){this.item=t,this.previous=r,this.next=s}};var Ps=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let r=new Ts(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}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,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){let s=t.next;t.next=r,this.tail===t?this.tail=r:s.previous=r,r.next=s,r.previous=t,++this._length}};var Re=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Ps,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,s){r._cacheNode||(r._cacheNode=this._list.add(r),s&&s(t,r))}unloadTile(t,r,s){let i=r._cacheNode;i&&(this._list.remove(i),r._cacheNode=null,s&&s(t,r))}unloadTiles(t,r){let s=this._trimTiles;this._trimTiles=!1;let i=this._list,n=this._sentinel,o=i.head;for(;o!==n&&(t.gpuMemoryUsageInBytes>t.cacheBytes||s);){let a=o.item;o=o.next,this.unloadTile(t,a,r)}}trim(){this._trimTiles=!0}};function bs(e,t){At(e),At(t);let{rtcCenter:r,gltfUpAxis:s}=t,{computedTransform:i,boundingVolume:{center:n}}=e,o=new z(i);switch(r&&o.translate(r),s){case"Z":break;case"Y":let f=new z().rotateX(Math.PI/2);o=o.multiplyRight(f);break;case"X":let d=new z().rotateY(-Math.PI/2);o=o.multiplyRight(d);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new _(n);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let h=I.WGS84.cartesianToCartographic(a,new _),l=I.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=l.multiplyRight(o),t.cartographicOrigin=h;let u=cd(t);u&&(t.cartesianModelMatrix=new z(o).multiplyRight(u.matrix),t.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=z.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var hd=1e6**2;function cd(e){let t=e.gltf;if(!t)return null;let r=typeof t.scene=="number"?t.scene:0,i=t.scenes?.[r]?.nodes?.[0];if(!i?.matrix)return null;let n=i.matrix;return n[12]*n[12]+n[13]*n[13]+n[14]*n[14]<=hd?null:i}var hh=new _,gn=new _,ld=1e-5,ud=1e-7,_n=new tt([new $,new $,new $,new $,new $,new $]);function Rs(e,t,r={}){let{cameraUp:s,height:i}=e,n=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=mr(e,e.center),h=I.WGS84.eastNorthUpToFixedFrame(a),c=e.unprojectPosition(e.cameraPosition),l=I.WGS84.cartographicToCartesian(c,new _),u;if(n)u=new _(h.transformAsVector(new _(n).scale(o))).normalize();else{let v=e.getFrustumPlanes().near,w=Mn(v,e.cameraPosition),P=mr(e,w);u=new _(P).subtract(l).normalize()}let f=new _(h.transformAsVector(new _(s).scale(o))).normalize();fd(e);let d=e.constructor,{longitude:m,latitude:g,width:p,bearing:M,zoom:x}=e,S=new d({longitude:m,latitude:g,height:i,width:p,bearing:M,zoom:x,pitch:0});return{camera:{position:l,direction:u,up:f,cartographicPosition:c,verticalFieldOfView:Number.isFinite(e.fovy)&&Number(e.fovy)>0?Number(e.fovy)*Math.PI/180:Math.PI/3,timeSinceMovement:r.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:e,topDownViewport:S,height:i,cullingVolume:_n,clippingPlanes:e.clippingPlanes,frameNumber:t,sseDenominator:1.15,dynamicScreenSpaceErrorDensity:0}}function ch(e,t,r,s){let i=Array.from(t),n=Array.from(r),o=e?i.length!==e.position.length||i.some((c,l)=>Math.abs(c-e.position[l])>ld):!1,a=e?n.length!==e.direction.length||n.some((c,l)=>Math.abs(c-e.direction[l])>ud):!1,h=o||a?s:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:i,direction:n,lastMovementTime:h},timeSinceMovement:Math.max((s-h)/1e3,0)}}function lh(e,t,r){if(r===0||e.length<=r)return[e,[]];let s=[],{longitude:i,latitude:n}=t.viewport;for(let[c,l]of e.entries()){let[u,f]=l.header.mbs,d=Math.abs(i-u),m=Math.abs(n-f),g=Math.sqrt(m*m+d*d);s.push([c,g])}let o=s.sort((c,l)=>c[1]-l[1]),a=[];for(let c=0;c<r;c++)a.push(e[o[c][0]]);let h=[];for(let c=r;c<o.length;c++)h.push(e[o[c][0]]);return[a,h]}function fd(e){let t=e.getFrustumPlanes(),r=Mn(t.near,e.cameraPosition),s=mr(e,r),i=mr(e,e.cameraPosition,gn),n=0;_n.planes[n++].fromPointNormal(s,hh.copy(s).subtract(i));for(let o in t){if(o==="near")continue;let a=t[o],h=Mn(a,r,gn),c=mr(e,h,gn);_n.planes[n++].fromPointNormal(c,hh.copy(s).subtract(c))}}function Mn(e,t,r=new _){let s=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-s).add(t),r}function mr(e,t,r=new _){let s=e.unprojectPosition(t);return I.WGS84.cartographicToCartesian(s,r)}var ph=new _,md=new _,ue=new _,uh=new _,dr=new _,fh=new _,mh=new _,dh=new _,Cs=new wt,dd=new _(0,0,1);function gh(e,t){e._updateTransform(t)}function _h(e,t,r){if(!Number.isFinite(r.dynamicScreenSpaceErrorDensity)||r.dynamicScreenSpaceErrorDensity<=0)return 0;let s=Md(e),i=s.region?xd(s.region,t):yd(e,s,t);if(!i)return 0;let n=Xe(r.dynamicScreenSpaceErrorHeightFalloff,0,1),o=i.minimumHeight+(i.maximumHeight-i.minimumHeight)*n,a=i.maximumHeight-o,h=a>0?Xe((i.cameraHeight-o)/a,0,1):i.cameraHeight>=i.maximumHeight?1:0,l=(1-Xe(Math.abs(i.cameraDirection.dot(i.upDirection)),0,1))*(1-h);return r.dynamicScreenSpaceErrorDensity*l}function pd(e,t){let r=e*t;return 1-Math.exp(-(r*r))}function gd(e,t,r){return t<=0||r<=0||!Number.isFinite(t)||!Number.isFinite(r)?0:pd(e,t)*r}function Mh(e,t,r,s=1){let i=e.tileset,n=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=r?n:e.lodMetricValue;if(o===0)return 0;let{viewDistanceScale:a}=i.options,h=a||1,c=Number.isFinite(s)?Math.max(s,0):1,l=_d(o,t,h,c);if(l!==null)return l;let u=Math.max(e._distanceToCamera,1e-7),{height:f,sseDenominator:d}=t,m=o*f*c*h/(u*d);return i.options.dynamicScreenSpaceError&&!t.viewport.orthographic&&(m-=gd(u,t.dynamicScreenSpaceErrorDensity,i.options.dynamicScreenSpaceErrorFactor)),m}function _d(e,t,r,s){let i=t.viewport;if(!i?.orthographic)return null;let n=i.metersPerPixel;return!Number.isFinite(n)||!n||n<=0?null:e*r*s/n}function Md(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function xd(e,t){let r=ph.copy(t.camera.position).normalize(),s=dr.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:s,upDirection:r}}function yd(e,t,r){let s=Sd(t,ue);if(s===null)return null;let i=new z(e.computedTransform).invert(),n=e.tileset.ellipsoid;if(Math.hypot(ue[0],ue[1],ue[2])>n.minimumRadius){let a=n.cartesianToCartographic(ue,md),h=ph.copy(r.camera.position).normalize(),c=dr.copy(r.camera.direction).normalize();return{cameraHeight:r.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:c,upDirection:h}}return i.transformAsPoint(r.camera.position,uh),i.transformAsVector(r.camera.direction,dr),dr.normalize(),{cameraHeight:uh[2],minimumHeight:ue[2]-s,maximumHeight:ue[2]+s,cameraDirection:dr,upDirection:dd}}function Sd(e,t){if(e.box){let r=e.box;return t.set(r[0],r[1],r[2]),vd(r)}if(e.sphere){let r=e.sphere;return t.set(r[0],r[1],r[2]),r[3]}return null}function vd(e){return e.length===10?(Cs.fromArray(e,6),fh.set(e[3],0,0).transformByQuaternion(Cs),mh.set(0,e[4],0).transformByQuaternion(Cs),dh.set(0,0,e[5]).transformByQuaternion(Cs),Math.abs(fh[2])+Math.abs(mh[2])+Math.abs(dh[2])):Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11])}var it={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},st;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(st||(st={}));var qt;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(qt||(qt={}));var lt;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(lt||(lt={}));var Ce;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Ce||(Ce={}));var xh={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};var yh=1e4,Ed=1e4,wd=1e8,Td=new rt,Sh=new _,vh=new _,xn=new _,As=new _;function yn(e,t,r){return e+(t-e)*r}function Eh(e,t){let r=e instanceof rt?e:e.getBoundingSphere(Td),{center:s,radius:i}=r;Sh.copy(s).subtract(t.position);let n=Math.max(Sh.dot(t.direction),0);return vh.copy(t.direction).scale(n).add(t.position),xn.copy(vh).subtract(s),xn.magnitude()<=i||(As.copy(xn).normalize().scale(i).add(s).subtract(t.position),As.magnitude()===0)?0:(As.normalize(),Math.min(Math.max(1-As.dot(t.direction),0),1))}function wh(e,t,r,s){return!Number.isFinite(s)||s<=0||s>.5?!1:e>r?!0:t!==void 0&&t>r}function Th(e){let t=Number.isFinite(e.foveatedConeSize)?Math.min(Math.max(e.foveatedConeSize,0),1):1,r=e.refinement===st.REPLACE;if(r&&!e.skipLevelOfDetail||!e.foveatedScreenSpaceError||t>=1||r&&e.skipLevelOfDetail&&e.priorityProgressiveResolution)return!1;let s=Number.isFinite(e.verticalFieldOfView)&&e.verticalFieldOfView>0?e.verticalFieldOfView:Math.PI/3,i=1-Math.cos(s*.5),n=t*i;if(e.foveatedFactor<=n||i<=n)return!1;let o=Math.min(Math.max((e.foveatedFactor-n)/(i-n),0),1),h=(typeof e.interpolationCallback=="function"?e.interpolationCallback:yn)(e.minimumScreenSpaceErrorRelaxation,e.maximumScreenSpaceError,o),c=Number.isFinite(h)?Math.min(Math.max(h,0),e.maximumScreenSpaceError):0,l=e.screenSpaceError===0&&e.parentScreenSpaceError!==void 0?e.parentScreenSpaceError*.5:e.screenSpaceError;return e.maximumScreenSpaceError-c<=l}function Ph(e,t,r){return e&&Number.isFinite(t)&&Number.isFinite(r)&&r>0&&t<r}function bh(e){let t=e.rootScreenSpaceError>0?Math.min(Math.max(e.reverseScreenSpaceError/e.rootScreenSpaceError,0),1):0,r=Math.floor(t*(yh-1)),s=Number.isFinite(e.foveatedFactor)?Math.min(Math.max(e.foveatedFactor,0),1):0,i=Math.floor(s*(yh-1))*Ed;return(e.priorityProgressiveResolution?0:wd)+i+r}var Pd="EPSG:4326",bd="EPSG:4978";function Rd(e){let t=e.trim().toUpperCase(),r=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return r?`${r[1]}:${r[2]}`:t}function Ht(e){if(typeof e=="string"){let r=Rd(e);return r===bd||/^GEOCCS\s*[\[(]/.test(r)?"geocentric":r===Pd||r==="EPSG:4490"||r==="EPSG:4979"||r==="OGC:CRS84"||r.includes("+PROJ=LONGLAT")||r.includes("+PROJ=LATLONG")||/^(?:GEOGCS|GEOGCRS|GEOGRAPHICCRS|GEOGRAPHIC2DCRS|GEOGRAPHIC3DCRS)\s*[\[(]/.test(r)?"geographic":/^(?:GEODCRS|GEODETICCRS)\s*[\[(]/.test(r)?/CS\s*[\[(]\s*CARTESIAN/.test(r)?"geocentric":"geographic":"projected"}let t=e;return t.type==="BoundCRS"&&t.source_crs?Ht(t.source_crs):t.type==="CompoundCRS"&&t.components?.[0]?Ht(t.components[0]):String(t.type).includes("Projected")?"projected":String(t.type).includes("Geographic")?"geographic":String(t.type).includes("Geodetic")?t.coordinate_system?.subtype==="Cartesian"?"geocentric":"geographic":"projected"}function Pt(e,t={}){let r=t.sourceCrs!==void 0,s=t.sourceCrs||e.sourceCrs,i=t.outputCoordinates||"auto",n=t.targetCrs||(i==="ecef"?"EPSG:4978":void 0),o=t.targetHeightReference||"native",a=e.verticalUnitScale??1,h=e.elevationUnitScale??1,c=e.elevationOffset||0,l=e.elevationMode==="onTheGround"||e.elevationMode==="relativeToGround"||e.elevationMode==="relativeToScene",u=e.elevationMode==="relativeToScene"?!!t.sceneElevationProvider:!l||!!t.terrainElevationProvider,f=a!==1||h!==1||e.elevationMode!==void 0&&(l||e.elevationMode==="absoluteHeight"&&c!==0),d=o!=="native"&&o!==e.heightReference,m=!!n||o!=="native"||i!=="auto"||f,g=i!=="target-crs"||!!n,p=!d||(e.heightReference||"unknown")!=="unknown",M=Number.isFinite(a)&&a>0&&Number.isFinite(h)&&h>0,x=!!s&&m&&g&&p&&M&&u&&i!=="local-enu",S=r?"caller-override":e.provenance||"unknown",v=r&&s?Ht(s):e.coordinateFrame,w=r?"explicit":e.sourceCrsState||(s?S==="format-default"?"default":"explicit":"absent"),P=ws({crs:s?{state:w==="default"?"default":"explicit",definition:s,representation:!r&&e.sourceCrsRepresentation||fr(s),provenance:S,alternatives:r?void 0:e.sourceCrsAlternatives}:{state:w==="unknown"?"unknown":"absent",provenance:S},vertical:e.verticalCrs?{state:"explicit",definition:e.verticalCrs,representation:fr(e.verticalCrs),provenance:e.provenance||"metadata"}:void 0,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,coordinateFrame:v,coordinateOrder:Ad(e.axisOrder),units:r?void 0:e.units}),R=Sn(P.crs),C=P.vertical?Sn(P.vertical):void 0,A=n?Cd(n):void 0;return Object.freeze({...P,sourceCrs:R,verticalCrs:C,verticalUnitScale:a,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,heightReference:e.heightReference||"unknown",elevationMode:e.elevationMode,elevationOffset:e.elevationOffset,elevationUnit:e.elevationUnit,elevationUnitScale:h,coordinateFrame:v||"unknown",axisOrder:e.axisOrder||"unknown",provenance:S,targetCrs:A,targetHeightReference:o,outputCoordinates:i,status:m?x?"transformable":"unresolved":"native",warnings:Object.freeze([...e.warnings||[]])})}function pr(e,t={}){return Pt({sourceCrs:e?.sourceCrs,sourceCrsState:e?.crs.state,sourceCrsRepresentation:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.representation:void 0,sourceCrsAlternatives:e?.crs.state==="explicit"||e?.crs.state==="default"?e.crs.alternatives:void 0,verticalCrs:e?.verticalCrs,units:e?.units,verticalUnitScale:e?.verticalUnitScale,coordinateEpoch:e?.coordinateEpoch,heightReference:e?.heightReference,elevationMode:e?.elevationMode,elevationOffset:e?.elevationOffset,elevationUnit:e?.elevationUnit,elevationUnitScale:e?.elevationUnitScale,coordinateFrame:e?.coordinateFrame,axisOrder:e?.axisOrder,provenance:e?.provenance,warnings:e?.warnings},t)}function Sn(e){return e.state==="explicit"||e.state==="default"?e.definition:void 0}function Cd(e){let t=ws({crs:{state:"explicit",definition:e,representation:fr(e),provenance:"caller-override"}}),r=Sn(t.crs);if(!r)throw new Error("Failed to normalize a known target CRS definition");return r}function Ad(e){switch(e){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function Is(e){if(e.status!=="transformable"&&e.status!=="transformed")throw new Error("Only a transformable spatial reference can be marked as transformed");return Object.freeze({...e,status:"transformed"})}function Os(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var nt=1024*1024,bn=512*nt,Rn=512*nt,Id=32*nt,Od=nt;function gr(e,t){if(!Number.isFinite(e)||e<0)throw new Error(`${t} must be a finite number greater than or equal to 0`);return e}function Rh(e,t){let r=e.cacheBytes??(e.maximumMemoryUsage!==void 0?e.maximumMemoryUsage*nt:t);return gr(r,"cacheBytes")}function Ch(e,t){let r=e.maximumCacheOverflowBytes??(e.memoryCacheOverflow!==void 0?e.memoryCacheOverflow*nt:t);return gr(r,"maximumCacheOverflowBytes")}var vn={description:"",ellipsoid:I.WGS84,modelMatrix:new z,throttleRequests:!0,maxRequests:64,cacheBytes:bn,maximumCacheOverflowBytes:Rn,maximumMemoryUsage:bn/nt,memoryCacheOverflow:Rn/nt,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onSourceError:()=>{},onTilesetError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,progressiveResolutionHeightFraction:.3,foveatedScreenSpaceError:!0,foveatedConeSize:.1,foveatedMinimumScreenSpaceErrorRelaxation:0,foveatedInterpolationCallback:yn,foveatedTimeDelay:.2,maximumScreenSpaceError:8,skipLevelOfDetail:!1,dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:2e-4,dynamicScreenSpaceErrorFactor:24,dynamicScreenSpaceErrorHeightFalloff:.25,memoryAdjustedScreenSpaceError:!0,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{},spatial:{}},En="Tiles In Tileset(s)",wn="Tiles In Memory",Ah="Tiles In View",Ih="Tiles To Render",Oh="Tiles Loaded",Tn="Tiles Loading",Nh="Tiles Unloaded",Lh="Failed Tile Loads",Gh="Points/Vertices",Pn="Tile Memory Use",zh="Maximum Screen Space Error",Ns=class{options;loadOptions;source;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};schema=null;schemaUri=null;groups=[];metadata=null;statistics=null;spatialReference=Pt({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=bn;_maximumCacheOverflowBytes=Rn;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new Re;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(t,r){if(!Os(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let s=r||{},i=t.type===lt.TILES3D,n=i?vn.cacheBytes:Id,o=i?vn.maximumCacheOverflowBytes:Od,a=Rh(s,n),h=Ch(s,o);this.options={...vn,...s,cacheBytes:a,maximumCacheOverflowBytes:h,maximumMemoryUsage:a/nt,memoryCacheOverflow:h/nt,memoryAdjustedScreenSpaceError:s.memoryAdjustedScreenSpaceError??i},this.loadOptions=this.options.loadOptions||{},this.source=t,this.tileset=null,this.loader=this.source.loader,this.type=this.source.type,this.url=this.source.url,this.basePath=this.source.basePath,this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType="",this.lodMetricValue=0,this.refine="",this.contentFormats=this.source.contentFormats,this._traverser=this._initializeTraverser(),this._requestScheduler=new Wt({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=a,this._maximumCacheOverflowBytes=h;let c=this._getSourceMetadata();c&&(this.spatialReference=pr(c.spatialReference,this.options.spatial)),this.stats=new Tt({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet()}destroy(){this._clearDeferredTraversal(),this.source.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 cacheBytes(){return this._cacheBytes}set cacheBytes(t){this._cacheBytes=gr(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes,this.options.maximumMemoryUsage=this._cacheBytes/nt}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=gr(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes,this.options.memoryCacheOverflow=this._maximumCacheOverflowBytes/nt}get maximumMemoryUsage(){return this.cacheBytes/nt}set maximumMemoryUsage(t){this.cacheBytes=gr(t*nt,"maximumMemoryUsage")}get queryParams(){let t=this.source.getTileUrl(this.url),r=t.indexOf("?");return r>=0?t.slice(r+1):""}setProps(t){let r=Rh(t,this.cacheBytes),s=Ch(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:r,maximumCacheOverflowBytes:s,maximumMemoryUsage:r/nt,memoryCacheOverflow:s/nt},this._cacheBytes=r,this._maximumCacheOverflowBytes=s}getTileUrl(t){return this.source.getTileUrl(t)}hasExtension(t){return!!this.source.hasExtension?.(t)}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(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this.cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this.cacheBytes+this.maximumCacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let s=Date.now(),i=Number.POSITIVE_INFINITY,n=[];for(let o of r){let a=o.id;this._needTraverse(a)?n.push(a):this.traverseCounter--}for(let o of r){let a=o.id;if(this.roots[a]||(this.roots[a]=this._initializeTileHeaders(this.tileset,null)),!n.includes(a))continue;let h=Rs(o,this._frameNumber),c=this.roots[a],l=ch(this._cameraMotionStates[a],h.camera.position,h.camera.direction,s);this._cameraMotionStates[a]=l.state,h.camera.timeSinceMovement=l.timeSinceMovement,gh(c,this.modelMatrix),h.dynamicScreenSpaceErrorDensity=this.type===lt.TILES3D&&this.options.dynamicScreenSpaceError&&!h.viewport.orthographic?_h(c,h,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=h.dynamicScreenSpaceErrorDensity,this._traverser.traverse(c,h,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(i=Math.min(i,Math.max(this.options.foveatedTimeDelay-l.timeSinceMovement,0)))}Number.isFinite(i)?this._scheduleDeferredTraversal(i):this._clearDeferredTraversal()}_scheduleDeferredTraversal(t){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(r=>{let s=r instanceof Error?r:new Error(String(r));this._onTilesetError(s)})},Math.max(t*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){let r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let s=this.frameStateData[r],i=Object.values(this._traverser.selectedTiles),[n,o]=lh(i,t,this.options.maximumTilesSelected);s.selectedTiles=n;for(let a of o)a.unselect();s._requestedTiles=Object.values(this._traverser.requestedTiles),s._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let t=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let n in this.frameStateData){let o=this.frameStateData[n];this.selectedTiles=this.selectedTiles.concat(o.selectedTiles),this._requestedTiles=this._requestedTiles.concat(o._requestedTiles),this._emptyTiles=this._emptyTiles.concat(o._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(n=>n.id)),s=this.selectedTiles.some(n=>!n.tileDrawn),i=0;if(s){for(let n of r)this._heldTiles.add(n);for(let n of this._heldTiles){if(r.has(n))continue;let o=this._tiles[n];o&&o.contentAvailable?(o._selectedFrame=this._frameNumber,this.selectedTiles.push(o),i++):this._heldTiles.delete(n)}}else this._heldTiles=r;i>0&&setTimeout(()=>{this.selectTiles()},0);for(let n of this.selectedTiles)this._tiles[n.id]=n;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(t,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(t,r){if(t.length!==r.length)return!0;let s=new Set(t.map(o=>o.id)),i=new Set(r.map(o=>o.id)),n=t.some(o=>!i.has(o.id));return n=n||r.some(o=>!s.has(o.id)),n}_loadTiles(){this._requestedTiles.sort((t,r)=>t._priority-r._priority);for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let t=0,r=0;for(let s of this.selectedTiles)if(s.contentAvailable&&s.content){t++;let i=s.contents.length?s.contents:[s.content];for(let n of i)n.pointCount?r+=n.pointCount:r+=n.vertexCount||0}this.stats.get(Ah).count=this.selectedTiles.length,this.stats.get(Ih).count=t,this.stats.get(Gh).count=r,this.stats.get(zh).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let t=this.source.initialize(),r=this._getSourceMetadata();r&&this._syncSourceState(r),r?.tileset?.root&&typeof r.tileset.root.then!="function"&&!this.source.prepareTileset&&(this.root=this._initializeTileHeaders(r.tileset,null),this._applyViewState()),await t;let s=this.source.getMetadata();this._syncSourceState(s),await this.source.prepareTileset?.(this),this.root||(this.root=this._initializeTileHeaders(s.tileset,null)),this._applyViewState()}catch(t){let r=t instanceof Error?t:new Error(String(t));throw this._onSourceError(r,this.root),this._onTilesetError(r),r}}_initializeStats(){this.stats.get(En),this.stats.get(Tn),this.stats.get(wn),this.stats.get(Ah),this.stats.get(Ih),this.stats.get(Oh),this.stats.get(Nh),this.stats.get(Lh),this.stats.get(Gh),this.stats.get(Pn,"memory"),this.stats.get(zh)}_initializeTileHeaders(t,r){return this.source.initializeTileHeaders(this,t,r)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r=null;try{this._onStartTileLoading(),r=await t.loadContent()}catch(s){let i=s instanceof Error?s:new Error("load failed");this._onSourceError(i,t),this._onTileLoadError(t,i)}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}async _loadTileChildren(t,r){try{this._onStartTileLoading(),await t.loadChildren(r)}catch(s){let i=s instanceof Error?s:new Error("subtree load failed");this._onSourceError(i,t),this._onTileLoadError(t,i)}finally{this._onEndTileLoading()}}_onTileLoadError(t,r){this.stats.get(Lh).incrementCount();let s=r.message||r.toString(),i=t.url;console.error(`A 3D tile failed to load: ${t.url} ${s}`),this.options.onTileError(t,s,i)}_onSourceError(t,r=null){this.options.onSourceError(t,this.source,r)}_onTilesetError(t){this.options.onTilesetError(t,this)}_onTileLoad(t,r){if(!r?.loaded)return;t.content&&bs(t,t.content),this.source.onTileLoaded?.(this,t,r),this._syncSourceState(this.source.getMetadata());let s=this.source.getTilesTotalCount?.();s&&(this.stats.get(En).reset(),this.stats.get(En).addCount(s)),this._addTileToCache(t),this.options.onTileLoad(t)}_onStartTileLoading(){this._pendingCount++,this.stats.get(Tn).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Tn).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(Oh).incrementCount(),this.stats.get(wn).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Pn).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(wn).decrementCount(),this.stats.get(Nh).incrementCount(),this.stats.get(Pn).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let r=t.pop();for(let s of r.children)t.push(s);this._destroyTile(r)}this.root=null}_destroySubtree(t){let r=t,s=[r];for(;s.length>0;){t=s.pop();for(let i of t.children)s.push(i);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_syncSourceState(t){this.tileset=t.tileset,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset;let r=t.tileset;this.schema=r.schema||null,this.schemaUri=r.schemaUri||null,this.groups=r.groups||[],this.metadata=r.metadata||null,this.statistics=r.statistics??null;let s=pr(t.spatialReference,this.options.spatial);this.spatialReference=Nd(this.spatialReference,s),this.properties=this.source.properties??this.properties,this.extras=this.source.extras??this.extras,this.options.attributions?.length?this.credits={attributions:this.options.attributions}:this.credits=this.source.credits||this.credits}_applyViewState(){let t=this.source.getViewState(this.root);this.asset=t.asset||this.source.asset||{},this.properties=t.properties??this.source.properties,this.extras=t.extras??this.source.extras??null,this.credits=t.credits||this.source.credits||this.credits||{attributions:this.options.attributions||[]},this.description=t.description||this.options.description||"",this.boundingVolume=t.boundingVolume||this.root?.boundingVolume||null,this.cartographicCenter=t.cartographicCenter||new _,this.cartesianCenter=t.cartesianCenter||null,this.zoom=t.zoom||1,this.geometricError=this.tileset?.geometricError||0}_getSourceMetadata(){try{return this.source.getMetadata()}catch{return null}}};function Nd(e,t){return e?.status==="transformed"&&e.sourceCrs===t.sourceCrs&&e.targetCrs===t.targetCrs&&e.targetHeightReference===t.targetHeightReference&&e.outputCoordinates===t.outputCoordinates?e:t}var Ls=class{sourceUrl;options;archivePromise;constructor(t){this.options=t,this.sourceUrl=Ld(t.data,t.fallbackFilename)}async loadRoot(t,r,s){return await this.parseArchiveResource(t,this.options.rootPath,r,s,this.options.rootMode)}async loadResource(t,r,s){let i=this.resolveArchivePath(t,t);return await this.parseArchiveResource(t,i,r,s)}async parseArchiveResource(t,r,s,i,n){let o=this.options.getCoreApi();if(!o)throw new Error(this.options.missingCoreApiMessage);let a=await this.loadFile(r,n),h=this.createArchiveFetch(t);return await o.parse(a,s,{...i,fetch:h},{url:t,fetch:h,_parse:o.parse,loaders:[s],coreApi:o})}createArchiveFetch(t){return async r=>{let s=typeof r=="string"?r:r instanceof URL?r.toString():r.url,i=this.resolveArchivePath(s,t),n=await this.loadFile(i);return new Response(n,{status:200})}}async loadFile(t,r){this.archivePromise||=this.openArchiveReadableFile().then(i=>this.options.parseArchive(i));let s=await this.archivePromise;return await this.options.getFile(s,t,r)}async openArchiveReadableFile(){let{data:t}=this.options;if(typeof t!="string")return new be(t);if(/^https?:\/\//i.test(t))return new ur(t);let r=this.options.getCoreApi();if(!r)throw new Error(this.options.missingCoreApiMessage);let s=await r.fetchFile(t);return new be(await s.arrayBuffer())}resolveArchivePath(t,r){let s=Cn(t),i=Cn(this.sourceUrl),n=Cn(r),o=n===i?i:xt.dirname(n),a=new RegExp(`\\.${this.options.archiveExtension}/(.*)$`,"i"),h=s.match(a);if(h?.[1])return h[1];let c=/^[a-z][a-z0-9+.-]*:/i.test(s)||s.startsWith("/"),l=s.startsWith(i)?s:n===i&&!c?`${i}/${s}`:xt.resolve(o,s);return l===i?"":l.startsWith(`${i}/`)?l.slice(i.length+1):l.replace(/^\/+/,"")}};function Ld(e,t){return typeof e=="string"?e:`memory://${"name"in e&&typeof e.name=="string"&&e.name?e.name:t}`}function Cn(e){let t=e.indexOf("?");return t>=0?e.slice(0,t):e}function qh(e){return e!=null}var ot=new _,Gs=new _;function Ae(e,t,r){if(At(e,"3D Tile: boundingVolume must be defined"),e.box)return Gd(e.box,t,r);if(e.region)return ln(e.region);if(e.sphere)return zd(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Bh(e,t){if(e.box)return qd(t);if(e.region){let[r,s,i,n,o,a]=e.region;return[[ct(r),ct(s),o],[ct(i),ct(n),a]]}if(e.sphere)return Bd(t);throw new Error("Unkown boundingVolume type")}function Gd(e,t,r){let s=new _(e[0],e[1],e[2]);t.transform(s,s);let i=[];if(e.length===10){let c=e.slice(3,6),l=new wt;l.fromArray(e,6);let u=new _([1,0,0]),f=new _([0,1,0]),d=new _([0,0,1]);u.transformByQuaternion(l),u.scale(c[0]),f.transformByQuaternion(l),f.scale(c[1]),d.transformByQuaternion(l),d.scale(c[2]),i=[...u.toArray(),...f.toArray(),...d.toArray()]}else i=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];let n=t.transformAsVector(i.slice(0,3)),o=t.transformAsVector(i.slice(3,6)),a=t.transformAsVector(i.slice(6,9)),h=new j([n[0],n[1],n[2],o[0],o[1],o[2],a[0],a[1],a[2]]);return qh(r)?(r.center=s,r.halfAxes=h,r):new zt(s,h)}function zd(e,t,r){let s=new _(e[0],e[1],e[2]);t.transform(s,s);let i=t.getScale(Gs),n=Math.max(Math.max(i[0],i[1]),i[2]),o=e[3]*n;return qh(r)?(r.center=s,r.radius=o,r):new rt(s,o)}function qd(e){let t=Dh(),{halfAxes:r}=e,s=new _(r.getColumn(0)),i=new _(r.getColumn(1)),n=new _(r.getColumn(2));for(let o=0;o<2;o++){for(let a=0;a<2;a++){for(let h=0;h<2;h++)ot.copy(e.center),ot.add(s),ot.add(i),ot.add(n),Fh(t,ot),n.negate();i.negate()}s.negate()}return t}function Bd(e){let t=Dh(),{center:r,radius:s}=e,i=I.WGS84.scaleToGeodeticSurface(r,ot),n;i?n=I.WGS84.geodeticSurfaceNormal(i):n=new _(0,0,1);let o=new _(n[2],-n[1],0);o.len()>0?o.normalize():o=new _(0,1,0);let a=o.clone().cross(n);for(let h of[o,a,n]){Gs.copy(h).scale(s);for(let c=0;c<2;c++)ot.copy(r),ot.add(Gs),Fh(t,ot),Gs.negate()}return t}function Dh(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Fh(e,t){I.WGS84.cartesianToCartographic(t,ot),e[0][0]=Math.min(e[0][0],ot[0]),e[0][1]=Math.min(e[0][1],ot[1]),e[0][2]=Math.min(e[0][2],ot[2]),e[1][0]=Math.max(e[1][0],ot[0]),e[1][1]=Math.max(e[1][1],ot[1]),e[1][2]=Math.max(e[1][2],ot[2])}var An=new _,Uh=new _,ie=new _,Vh=new _,Dd=new _,In=new z,kh=new z;function zs(e,t){if(e.lodMetricValue===0||Number.isNaN(e.lodMetricValue))return"DIG";let r=2*On(e,t);if(r<2)return"OUT";if(!e.header.children)return"DRAW";switch(e.lodMetricType){case"screenSpaceRelative":{let s=t.topDownViewport.height||1;return r/s<=e.lodMetricValue?"DRAW":"DIG"}case"distanceRangeFromDefaultCamera":return e.distanceToTile(t)>=e.lodMetricValue?"DRAW":"DIG";case"maxScreenThresholdSQ":{let s=Math.sqrt(e.lodMetricValue/(Math.PI*.25));return r<=s?"DRAW":"DIG"}default:return r<=e.lodMetricValue?"DRAW":"DIG"}}function On(e,t){let{topDownViewport:r}=t,s=e.header.i3sLodMbs||e.header.mbs,i=s[1],n=s[0],o=s[2],a=s[3],h=[...e.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);I.WGS84.cartographicToCartesian(c,An),Uh.copy(An).subtract(h).normalize(),I.WGS84.eastNorthUpToFixedFrame(h,In),kh.copy(In).invert(),ie.copy(An).transform(kh);let l=Math.sqrt(ie[0]*ie[0]+ie[1]*ie[1]),u=l*l/ie[2];Vh.copy([ie[0],ie[1],u]);let d=Vh.transform(In).subtract(h).normalize(),g=Uh.cross(d).normalize().scale(a).add(h),p=I.WGS84.cartesianToCartographic(g),M=r.project([n,i,o]),x=r.project(p);return Dd.copy(M).subtract(x).magnitude()}var _r=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 At(t<this._array.length),this._array[t]}set(t,r){At(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=r,this._map.set(r,t)}delete(t){let r=this._map.get(t);r>=0&&(this._array.splice(r,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){let r=this.length++;this._array[r]=t,this._map.set(t,r)}}pop(){let t=this._array[--this.length];return this._map.delete(t),t}reserve(t){At(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){At(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 Fd={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Bt=class{options;root=null;selectedTiles={};requestedTiles={};deferredTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new _r;_emptyTraversalStack=new _r;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...Fd,...t}}traverse(t,r,s){this.root=t,this.options={...this.options,...s},this.reset(),this.updateTile(t,r),this._frameNumber=r.frameNumber,this.executeTraversal(t,r)}reset(){this.requestedTiles={},this.deferredTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,r){let s=this._traversalStack;for(t._selectionDepth=1,s.push(t);s.length>0;){let n=s.pop(),o=!1;this.canTraverse(n,r)&&(this.updateChildTiles(n,r),o=this.updateAndPushChildren(n,r,s,n.hasRenderContent?n._selectionDepth+1:n._selectionDepth));let a=n.parent,h=!!(!a||a._shouldRefine),c=!o;n.hasRenderContent?n.refine===st.ADD?(this.loadTile(n,r),this.selectTile(n,r)):n.refine===st.REPLACE&&(this.loadTile(n,r),(c||this.options.skipLevelOfDetail)&&this.selectTile(n,r)):(this.emptyTiles[n.id]=n,this.loadTile(n,r),c&&this.selectTile(n,r)),this.touchTile(n,r),n._shouldRefine=o&&h}let i=new Date().getTime();(this.traversalFinished(r)||i-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=i,this.options.onTraversalEnd(r))}updateChildTiles(t,r){let s=t.children;for(let i of s)this.updateTile(i,r)}updateAndPushChildren(t,r,s,i){let{loadSiblings:n,skipLevelOfDetail:o}=this.options,a=t.children;a.sort(this.compareDistanceToCamera.bind(this));let h=t.refine===st.REPLACE&&t.hasRenderContent&&!o,c=!1,l=!0;for(let u of a)if(u._selectionDepth=i,u.isVisibleAndInRequestVolume?(s.find(u)&&s.delete(u),s.push(u),c=!0):(h||n)&&(this.loadTile(u,r),this.touchTile(u,r)),h){let f;if(u._inRequestVolume?u.hasRenderContent?f=u.contentAvailable:f=this.executeEmptyTraversal(u,r):f=!1,l=l&&f,!l)return!1}return c||(l=!1),l}updateTile(t,r){this.updateTileVisibility(t,r)}selectTile(t,r){this.shouldSelectTile(t,r)&&(t._selectedFrame=r.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,r){if(this.shouldLoadTile(t)){if(this.shouldDeferTileRequest(t)){this.deferredTiles[t.id]=t;return}t._requestedFrame=r.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t}}shouldDeferTileRequest(t){return t.priorityDeferred}touchTile(t,r){t.tileset._cache.touch(t),t._touchedFrame=r.frameNumber}canTraverse(t,r){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:this.shouldRefine(t,r):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t,r){return t.contentAvailable&&t.contentVisibility(r)!=="outside"}shouldRefine(t,r,s=!1){let i=t._screenSpaceError;return s&&(i=t.getScreenSpaceError(r,!0)),i>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,r){let s=[];if(this.options.viewportTraversersMap)for(let i in this.options.viewportTraversersMap)this.options.viewportTraversersMap[i]===r.viewport.id&&s.push(i);else s.push(r.viewport.id);t.updateVisibility(r,s)}compareDistanceToCamera(t,r){return t._distanceToCamera-r._distanceToCamera}anyChildrenVisible(t,r){let s=!1;for(let i of t.children)i.updateVisibility(r),s=s||i.isVisibleAndInRequestVolume;return s}executeEmptyTraversal(t,r){let s=!0,i=!1,n=this._emptyTraversalStack;for(n.push(t);n.length>0;){let o=n.pop(),a=!o.hasRenderContent&&this.canTraverse(o,r),h=!o.hasRenderContent&&o.children.length===0;if(o.header.implicitSubtree&&(i=!0,s=!1),!a&&!o.contentAvailable&&!h&&(s=!1),this.updateTile(o,r),o.isVisibleAndInRequestVolume||(this.loadTile(o,r),this.touchTile(o,r)),a){let c=o.children;for(let l of c)n.push(l)}}return t.hasEmptyContent&&!i||s}};var Nn=new _;function Ud(e,t,r,s,i=[]){let n=e.length?e:[t],o=!1,a=!1;for(let h of n){let c="inside";if(s!==tt.MASK_INSIDE&&(c=r.computeVisibility(h),c==="outside"))continue;let l=!1;for(let u of i)if(h.intersectPlane(u)==="outside"){l=!0;break}l||(o=!0,a=a||c==="intersecting")}return o?a?"intersecting":"inside":"outside"}function Vd(e){return e!=null}var bt=class{tileset;header;id;url;parent;refine;type;contentUrl;contentUrls=[];lodMetricType="geometricError";lodMetricValue=0;_unscaledLodMetricValue=0;boundingVolume=null;content=null;contents=[];metadata=null;contentMetadata=[];contentState=it.UNLOADED;gpuMemoryUsageInBytes=0;children=[];childrenState="ready";depth=0;viewportIds=[];transform=new z;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Bt({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_childrenPromise=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_screenSpaceErrorProgressiveResolution=0;_priorityProgressiveResolution=!1;_foveatedFactor=0;priorityDeferred=!1;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_contentBoundingVolumes=[];_contentBoundingVolumeHeaders=[];_viewerRequestVolume;get contentBoundingVolume(){return this._contentBoundingVolume}get contentBoundingVolumes(){return this._contentBoundingVolumes}get viewerRequestVolume(){return this._viewerRequestVolume}_initialTransform=new z;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;tileDrawn=!0;constructor(t,r,s,i=""){this.header=r,this.tileset=t,this.id=i||r.id,this.url=r.url,this.parent=s,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this.contentUrls=r.contentUrls||(r.contentUrl?[r.contentUrl]:[]),this.metadata=r.metadata||null;let n=Array.isArray(r.content)?r.content:[r.content];this.contentMetadata=n.filter(Boolean).map(o=>o.metadata||null),this.childrenState=r.implicitSubtree?"unloaded":"ready",this._initializeLodMetric(r),this._initializeTransforms(r),this._updateLodMetricScale(),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),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||!!(this.header.implicitSubtree&&this.childrenState!=="ready")}get hasUnloadedChildren(){return!!(this.header.implicitSubtree&&(this.childrenState==="unloaded"||this.childrenState==="failed"))}get childrenLoading(){return this.childrenState==="loading"}get contentReady(){return this.contentState===it.READY||this.hasEmptyContent}get contentAvailable(){return!!(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===it.UNLOADED}get contentExpired(){return this.contentState===it.EXPIRED}get contentFailed(){return this.contentState===it.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Bh(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,r,s=1){switch(this.tileset.type){case lt.I3S:return On(this,t);case lt.TILES3D:return Mh(this,t,r,s);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return(this.contents.length?this.contents:[this.content]).reduce((r,s)=>r+(s?.gpuMemoryUsageInBytes||s?.byteLength||0),0)}_getPriority(){return this._calculateRequestPriority(!1)}_getChildrenPriority(){return this._calculateRequestPriority(!0)}_calculateRequestPriority(t){let r=this.tileset._traverser,{skipLevelOfDetail:s}=r.options,i=this.refine===st.ADD||s;if(i&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.priorityDeferred||!t&&this.contentState===it.UNLOADED)return-1;let n=this.parent,a=n&&(!i||this._screenSpaceError===0||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,h=r.root?r.root._screenSpaceError:0,c=Math.max(h-a,0);return bh({priorityProgressiveResolution:this._priorityProgressiveResolution,foveatedFactor:this._foveatedFactor,reverseScreenSpaceError:c,rootScreenSpaceError:h})}async loadContent(){if(this.hasEmptyContent)return{loaded:!1};if(this.content)return{loaded:!0};this.contentExpired&&(this._expireDate=null),this.contentState=it.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=it.UNLOADED,{loaded:!1};try{let s=await this.tileset.source.loadTileContent(this);return s.contents&&(this.contents=s.contents,this.content=this.contents[0]||null),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this.contentState=it.READY,this._onContentLoaded(),s}catch(s){throw this.contentState=it.FAILED,s}finally{r.done()}}async loadChildren(t){if(!this.header.implicitSubtree||this.childrenState==="ready")return{loaded:!1,tileCount:0,childSubtreeCount:0};if(this._childrenPromise)return await this._childrenPromise;if(!this.tileset.source.loadTileChildren)throw new Error("Tileset source does not support lazy tile children");this.childrenState="loading",this._childrenPromise=this._loadChildrenWithScheduler(t);try{return await this._childrenPromise}finally{this._childrenPromise=null}}async _loadChildrenWithScheduler(t){let r=await this.tileset._requestScheduler.scheduleRequest(`${this.id}:implicit-subtree`,this._getChildrenPriority.bind(this));if(!r)return this.childrenState="unloaded",{loaded:!1,tileCount:0,childSubtreeCount:0};try{let s=await this.tileset.source.loadTileChildren(this,t);return this.childrenState=s.loaded?"ready":"unloaded",s}catch(s){throw this.childrenState="failed",s}finally{r.done()}}applyImplicitSubtreeHeader(t){let r=this.header.transform,s=this.header.transformMatrix;this.header={...this.header,...t,transform:r,transformMatrix:s,implicitSubtree:void 0},this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this.contentUrls=t.contentUrls||(t.contentUrl?[t.contentUrl]:[]),this._initializeLodMetric(t),this._updateLodMetricScale(),this._initializeBoundingVolumes(this.header),this._initializeContent(this.header)}unloadContent(){for(let t of this.contents.length?this.contents:[this.content])t&&t.destroy&&t.destroy();return this.contents=[],this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=it.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(t,r){if(this._frameNumber===t.frameNumber)return;let s=this.parent,i=s?s._visibilityPlaneMask:tt.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let n=s?s.computedTransform:this.tileset.modelMatrix;this._updateTransform(n)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._updateRequestPriorityMetrics(t),this._visibilityPlaneMask=this.visibility(t,i),this._visible=this._visibilityPlaneMask!==tt.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=r}_updateRequestPriorityMetrics(t){if(this.tileset.type!==lt.TILES3D){this._screenSpaceErrorProgressiveResolution=this._screenSpaceError,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1;return}let r=this.tileset.options,s=r.progressiveResolutionHeightFraction;if(this._screenSpaceErrorProgressiveResolution=this.getScreenSpaceError(t,!1,s),this._priorityProgressiveResolution=wh(this._screenSpaceErrorProgressiveResolution,this.parent?._screenSpaceErrorProgressiveResolution,this.tileset.memoryAdjustedScreenSpaceError,s),!r.foveatedScreenSpaceError||t.viewport?.orthographic||!t.camera?.position||!t.camera?.direction){this._foveatedFactor=0,this.priorityDeferred=!1;return}this._foveatedFactor=Eh(this.boundingVolume,t.camera);let i=Th({refinement:this.refine,skipLevelOfDetail:this.tileset._traverser.options.skipLevelOfDetail,foveatedScreenSpaceError:r.foveatedScreenSpaceError,foveatedConeSize:r.foveatedConeSize,minimumScreenSpaceErrorRelaxation:r.foveatedMinimumScreenSpaceErrorRelaxation,interpolationCallback:r.foveatedInterpolationCallback,foveatedFactor:this._foveatedFactor,verticalFieldOfView:t.camera.verticalFieldOfView,screenSpaceError:this._screenSpaceError,parentScreenSpaceError:this.parent?._screenSpaceError,maximumScreenSpaceError:this.tileset.memoryAdjustedScreenSpaceError,priorityProgressiveResolution:this._priorityProgressiveResolution});this.priorityDeferred=Ph(i,t.camera.timeSinceMovement,r.foveatedTimeDelay)}visibility(t,r){let{cullingVolume:s}=t,{boundingVolume:i}=this;return s.computeVisibilityWithPlaneMask(i,r)}contentVisibility(t){return Ud(this._contentBoundingVolumes,this.boundingVolume,t.cullingVolume,this._visibilityPlaneMask,t.clippingPlanes)}distanceToTile(t){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){let r=this.boundingVolume;return Nn.subVectors(r.center,t.position),t.direction.dot(Nn)}insideViewerRequestVolume(t){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(Vd(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=it.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._unscaledLodMetricValue=t.lodMetricValue:(this._unscaledLodMetricValue=this.parent?this.parent._unscaledLodMetricValue:this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue")),this.lodMetricValue=this._unscaledLodMetricValue}_initializeTransforms(t){this.transform=t.transform?new z(t.transform):new z;let r=this.parent,s=this.tileset,i=r&&r.computedTransform?r.computedTransform.clone():s.modelMatrix.clone();this.computedTransform=new z(i).multiplyRight(this.transform);let n=r&&r._initialTransform?r._initialTransform.clone():new z;this._initialTransform=new z(n).multiplyRight(this.transform)}_updateLodMetricScale(){if(this.lodMetricType!==Ce.GEOMETRIC_ERROR){this.lodMetricValue=this._unscaledLodMetricValue;return}let t=this.computedTransform.getScale(Nn),r=Math.max(t[0],t[1],t[2]);this.lodMetricValue=this._unscaledLodMetricValue*r}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._contentBoundingVolumeHeaders=[],this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.contents=[],this.hasEmptyContent=!0,this.contentState=it.UNLOADED,this.hasTilesetContent=!1,(t.contentUrl||t.contentUrls?.length)&&(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._screenSpaceErrorProgressiveResolution=0,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1,this._visibilityPlaneMask=tt.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||st.REPLACE}_isTileset(){return(this.contents.length?this.contents:[this.content]).some(t=>t?.shape==="tileset3d")}_onContentLoaded(){let t=this.contents.length?this.contents:[this.content];for(let r of t)switch(r&&r.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=Ae(t.boundingVolume,this.computedTransform,this.boundingVolume),t.viewerRequestVolume&&(this._viewerRequestVolume=Ae(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume));let r=t.content;r&&(this._contentBoundingVolumeHeaders=Array.isArray(r)?r:[r]);let s=r?Array.isArray(r)?r:[r]:this._contentBoundingVolumeHeaders;this._contentBoundingVolumes=s.length?s.map(i=>i?.boundingVolume?Ae(i.boundingVolume,this.computedTransform):this.boundingVolume):[this.boundingVolume],this._contentBoundingVolume=this._contentBoundingVolumes[0]||null}_updateTransform(t=new z){let r=t.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateLodMetricScale(),this._updateBoundingVolume(this.header))}};var qs=class extends Bt{pendingImplicitSubtrees=new Map;traversalFinished(t){let r=`${t.viewport.id}:`;for(let[s,i]of this.pendingImplicitSubtrees)if(s.startsWith(r)&&i===t.frameNumber)return!1;return!0}compareDistanceToCamera(t,r){return r._distanceToCamera===0&&t._distanceToCamera===0?r._centerZDepth-t._centerZDepth:r._distanceToCamera-t._distanceToCamera}updateChildTiles(t,r){if(t.hasUnloadedChildren&&t.isVisibleAndInRequestVolume&&this.shouldRefine(t,r)){let s=`${r.viewport.id}:${t.id}`;this.pendingImplicitSubtrees.has(s)||(this.pendingImplicitSubtrees.set(s,r.frameNumber),t.tileset._loadTileChildren(t,r).finally(()=>{this.handleImplicitSubtreeLoad(t,r,s)}))}super.updateChildTiles(t,r)}handleImplicitSubtreeLoad(t,r,s){this.pendingImplicitSubtrees.delete(s),this._frameNumber===r.frameNumber&&(t.childrenState==="ready"?this.executeTraversal(t,r):this.traversalFinished(r)&&this.options.onTraversalEnd(r))}updateTileVisibility(t,r){if(super.updateTileVisibility(t,r),!t.isVisibleAndInRequestVolume)return;let s=t.children.length>0;if(t.hasTilesetContent&&s){let o=t.children[0];this.updateTileVisibility(o,r),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,r)){t._visible=!1;return}let i=t.refine===st.REPLACE,n=t._optimChildrenWithinParent===xh.USE_OPTIMIZATION;if(i&&n&&s&&!this.anyChildrenVisible(t,r)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,r){let{parent:s}=t;return!s||s.hasTilesetContent||s.refine!==st.ADD?!1:!this.shouldRefine(t,r,!0)}};var kd=6378137,jd=6378137,Ln=6356752314245179e-9,Ie=new _;function jh(e,t){if(e instanceof zt){let{halfAxes:r}=e,s=Wd(r);return Math.log2(Ln/(s+t[2]))}else if(e instanceof rt){let{radius:r}=e;return Math.log2(Ln/(r+t[2]))}else if(e.width&&e.height){let{width:r,height:s}=e,i=Math.log2(kd/r),n=Math.log2(jd/s);return(i+n)/2}return 1}function Gn(e,t,r){I.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Ie);let s=Math.sqrt(Math.pow(Ie[0]-r[0],2)+Math.pow(Ie[1]-r[1],2)+Math.pow(Ie[2]-r[2],2));return Math.log2(Ln/(s+t[2]))}function Wh(e,t,r){let[s,i,n,o]=e;return Gn({xmin:s,xmax:n,ymin:i,ymax:o,zmin:0,zmax:0},t,r)}function Wd(e){e.getColumn(0,Ie);let t=e.getColumn(1),r=e.getColumn(2);return Ie.add(t).add(r).len()}var Hd=Object.freeze({meter:1,millimeter:.001,centimeter:.01,decimeter:.1,kilometer:1e3,foot:.3048,yard:.9144,mile:1609.344,"us-foot":.3048006096012192,"us-inch":.0254000508001016,"us-yard":.9144018288036576,"us-mile":1609.3472186944373,"clarke-foot":.3047972654,"clarke-yard":.9143917962,"clarke-link":.201166195164,"sears-yard":.914398414616,"sears-foot":.304799471539,"sears-chain":20.1167651216,"sears-1922-truncated-chain":20.116756,"benoit-1895-b-chain":20.1167824944,"indian-yard":.914398530744,"indian-1937-yard":.91439523,"gold-coast-foot":.304799710181}),Yd=Object.freeze({m:"meter",metre:"meter",meters:"meter",metres:"meter",mm:"millimeter",millimetre:"millimeter",millimeters:"millimeter",millimetres:"millimeter",cm:"centimeter",centimetre:"centimeter",centimeters:"centimeter",centimetres:"centimeter",dm:"decimeter",decimetre:"decimeter",decimeters:"decimeter",decimetres:"decimeter",km:"kilometer",kilometre:"kilometer",kilometers:"kilometer",kilometres:"kilometer",ft:"foot",feet:"foot","us-survey-foot":"us-foot","us-survey-feet":"us-foot",yd:"yard",yards:"yard",mi:"mile",miles:"mile"});function Mr(e){if(!e)return;let t=e.trim().toLowerCase().replaceAll("_","-"),r=Yd[t]||t;return Hd[r]}function Hh(e,t){return t!==void 0?Number.isFinite(t)&&t>0?t:void 0:e?Mr(e):1}function Bs(e){let t=e.spatialReference||e.fullExtent?.spatialReference,r=Xd(t),s=e.heightModelInfo?.vertCRS||Kd(t),i=e.heightModelInfo?.heightModel,n=e.heightModelInfo?.heightUnit,o=Hh(n,e.ZFactor),a=i==="ellipsoidal"?"ellipsoidal":i==="gravity_related_height"?"orthometric":"unknown",h=Zh(t),c=h===void 0?t1(t?.wkt):Jd(h),l=Zd(c,n,e.ZFactor),u=[],f=$d(e.elevationInfo?.mode),d=e.elevationInfo?e.elevationInfo.unit||"meter":void 0,m=Mr(d);return o===void 0&&u.push(e.ZFactor!==void 0?`I3S ZFactor ${e.ZFactor} is not a positive finite conversion factor`:`Unsupported I3S vertical unit ${n}`),e.elevationInfo&&m===void 0&&u.push(`Unsupported I3S elevation unit ${d}`),e.elevationInfo?.mode&&!f&&u.push(`Unsupported I3S elevation mode ${e.elevationInfo.mode}`),f&&f!=="absoluteHeight"&&u.push(`I3S elevation mode ${f} requires a terrain or scene elevation provider`),Pt({sourceCrs:r,sourceCrsRepresentation:h!==void 0?"identifier":r?"wkt":void 0,sourceCrsAlternatives:h!==void 0&&t?.wkt?[{definition:t.wkt,representation:"wkt"}]:void 0,verticalCrs:s,units:l,verticalUnitScale:o??Number.NaN,heightReference:a,elevationMode:f,elevationOffset:e.elevationInfo?.offset,elevationUnit:d,elevationUnitScale:e.elevationInfo?.mode&&!f?Number.NaN:m??(e.elevationInfo?Number.NaN:1),coordinateFrame:c,axisOrder:r?"xyz":"unknown",provenance:r?"metadata":"unknown",warnings:u})}function Zd(e,t,r){if(e==="geocentric")return["meter","meter","meter"];if(e==="geographic"&&(t||r===void 0))return["degree","degree",t||"meter"]}function $d(e){switch(e){case"absoluteHeight":case"onTheGround":case"relativeToGround":case"relativeToScene":return e;default:return}}function Ds(e){let t=Yh(e,"TILESET_CRS_GEOCENTRIC"),r=Yh(e,"TILESET_CRS_COORDINATE_EPOCH"),s=[],i,n="unknown",o;typeof t=="string"&&t.toUpperCase()!=="UNKNOWN"?(i=t,n="metadata",o="explicit"):t!==void 0?(s.push("3D Tiles geocentric CRS is explicitly unknown"),n="metadata",o="unknown"):e.root?.boundingVolume?.region?(i="EPSG:4978",n="format-default",o="default"):e.schemaUri&&!e.schema&&s.push("External 3D Tiles metadata schema must be loaded before CRS semantics can resolve");let a=Qd(r);return r!==void 0&&a===void 0&&s.push("3D Tiles coordinate epoch is not a finite decimal year"),Pt({sourceCrs:i,sourceCrsState:o,sourceCrsRepresentation:i?"identifier":void 0,coordinateEpoch:a,heightReference:i?"ellipsoidal":"unknown",coordinateFrame:i?"geocentric":"unknown",axisOrder:i?"xyz":"unknown",provenance:n,warnings:s})}function Qd(e){if(typeof e!="string"&&typeof e!="number"||typeof e=="string"&&!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Xd(e){let t=Zh(e);return t!==void 0?`EPSG:${t}`:e?.wkt}function Kd(e){let t=e?.latestVcsWkid??e?.vcsWkid;return t===void 0?void 0:`EPSG:${t}`}function Zh(e){return e?.latestWkid??e?.wkid}function Jd(e){return e===4978?"geocentric":e===4326||e===4490||e===4979?"geographic":"projected"}function t1(e){if(!e)return"unknown";let t=e.trim().toUpperCase(),r=t.match(/^([A-Z][A-Z0-9_]*)\s*[\[(]/)?.[1];if(r==="GEOCCS")return"geocentric";if(r==="GEOGCS"||r==="GEOGRAPHICCRS"||r==="GEOGRAPHIC2DCRS"||r==="GEOGRAPHIC3DCRS")return"geographic";if(r==="PROJCS"||r==="PROJCRS"||r==="PROJECTEDCRS")return"projected";if(r==="GEODCRS"||r==="GEODETICCRS"){if(/\bCS\s*[\[(]\s*CARTESIAN\s*,\s*3\b/.test(t))return"geocentric";if(/\bCS\s*[\[(]\s*ELLIPSOIDAL\s*,\s*[23]\b/.test(t))return"geographic"}return"unknown"}function Yh(e,t){let r=e.metadata?.class;if(!r)return;let i=e.schema?.classes?.[r]?.properties,n=e.metadata?.properties;for(let[o,a]of Object.entries(i||{}))if(a.semantic===t)return n?.[o]}var e1=4,r1=8;function qn(e,t){return{coordinates:t,subtreeUrl:Us(e.subtreesUrlTemplate,t),descriptor:e}}function Fs(e,t){let{descriptor:r}=t;c1(r);let s={tileCount:0,childSubtreeCount:0},i=Qh(e,t,{localLevel:0,mortonIndex:0},t.coordinates,s);if(!i)throw new Error(`Invalid 3D Tiles subtree: root tile is unavailable at ${t.subtreeUrl}`);return{root:i,...s}}function Us(e,t){let r={level:t.level,x:t.x,y:t.y,z:t.z};return e.replace(/{(level|x|y|z)}/gi,(s,i)=>String(r[i.toLowerCase()]))}function Qh(e,t,r,s,i){let{descriptor:n}=t,o=a1(n.subdivisionScheme),a=o1(o,r.localLevel)+r.mortonIndex;if(!zn(e.tileAvailability,a))return null;i.tileCount++;let h=n1(e.contentAvailability,a),c=[];if(s.level<n.maximumLevel)if(r.localLevel+1<n.subtreeLevels)for(let l=0;l<o;l++){let u=$h(s,l,n.subdivisionScheme),f=Qh(e,t,{localLevel:r.localLevel+1,mortonIndex:r.mortonIndex*o+l},u,i);f&&c.push(f)}else for(let l=0;l<o;l++){let u=r.mortonIndex*o+l;if(zn(e.childSubtreeAvailability,u)){let f=$h(s,l,n.subdivisionScheme);c.push(s1(e,n,f)),i.childSubtreeCount++}}return i1(e,n,t,s,h,c)}function s1(e,t,r){let s=qn(t,r);return{id:Kh(s,r),children:[],implicitSubtree:s,boundingVolume:Jh(t.rootBoundingVolume,r,t.subdivisionScheme),geometricError:t.rootLodMetricValue/2**r.level,lodMetricType:t.lodMetricType,lodMetricValue:t.rootLodMetricValue/2**r.level,refine:t.refine,type:qt.EMPTY,implicitMetadata:Xh(e)}}function i1(e,t,r,s,i,n){let a=(t.contentUrlTemplates?.length?t.contentUrlTemplates:[t.contentUrlTemplate]).map((f,d)=>!i[d]||!f?null:{contentIndex:d,contentUrl:Us(f,s)}).filter(f=>!!f),h=a.map(f=>f.contentUrl),c=a.map(({contentIndex:f,contentUrl:d})=>({...t.contentHeaders?.[f]||(f===0?t.contentHeader:{})||{},uri:d})),l=h[0],u=t.rootLodMetricValue/2**s.level;return{id:Kh(r,s),children:n,contentUrl:l,content:c.length>1?c:c[0],contentUrls:h,refine:t.refine,type:h1(l),lodMetricType:t.lodMetricType,lodMetricValue:u,geometricError:u,boundingVolume:Jh(t.rootBoundingVolume,s,t.subdivisionScheme),implicitMetadata:Xh(e)}}function Xh(e){if(!(!e.propertyTables&&e.tileMetadata===void 0&&!e.contentMetadata&&e.subtreeMetadata===void 0))return{propertyTables:e.propertyTables,tileMetadata:e.tileMetadata,contentMetadata:e.contentMetadata,subtreeMetadata:e.subtreeMetadata}}function Kh(e,t){return`${e.subtreeUrl}#implicit=${t.level}/${t.x}/${t.y}/${t.z}`}function zn(e,t){if(typeof e?.constant=="number")return!!e.constant;let r=e?.explicitBitstream;if(!r)return!1;let s=Math.floor(t/8),i=t%8;return!!(r[s]>>i&1)}function n1(e,t){return(Array.isArray(e)?e:[e]).map(s=>zn(s||{constant:0},t))}function o1(e,t){return(e**t-1)/(e-1)}function $h(e,t,r){return{level:e.level+1,x:e.x*2+(t&1),y:e.y*2+(t>>1&1),z:r==="OCTREE"?e.z*2+(t>>2&1):0}}function a1(e){return e==="OCTREE"?r1:e1}function Jh(e,t,r){if(e.region){let[s,i,n,o,a,h]=e.region,c=2**t.level,l=(n-s)/c,u=(o-i)/c,f=s+l*t.x,d=i+u*t.y,m=a,g=h;if(r==="OCTREE"){let p=(h-a)/c;m=a+p*t.z,g=m+p}return{region:[f,d,f+l,d+u,m,g]}}if(e.box){if(e.s2VolumeInfo)return{box:[...e.box],s2VolumeInfo:e.s2VolumeInfo};let s=e.box,i=2**t.level,n=-1+(2*t.x+1)/i,o=-1+(2*t.y+1)/i,a=-1+(2*t.z+1)/i,h=r==="OCTREE";return{box:[...[s[0]+s[3]*n+s[6]*o+(h?s[9]*a:0),s[1]+s[4]*n+s[7]*o+(h?s[10]*a:0),s[2]+s[5]*n+s[8]*o+(h?s[11]*a:0)],s[3]/i,s[4]/i,s[5]/i,s[6]/i,s[7]/i,s[8]/i,h?s[9]/i:s[9],h?s[10]/i:s[10],h?s[11]/i:s[11]]}}throw new Error(`Unsupported implicit 3D Tiles bounding volume: ${JSON.stringify(e)}`)}function h1(e){if(!e)return qt.EMPTY;let t=e.split("?")[0].split(".").pop()?.toLowerCase();switch(t){case"pnts":return qt.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return qt.SCENEGRAPH;default:return t||qt.EMPTY}}function c1(e){if(e.subdivisionScheme!=="QUADTREE"&&e.subdivisionScheme!=="OCTREE")throw new Error(`Unsupported implicit subdivision scheme: ${e.subdivisionScheme}`);if(!Number.isInteger(e.subtreeLevels)||e.subtreeLevels<1)throw new Error("Implicit subtreeLevels must be a positive integer");if(!Number.isInteger(e.maximumLevel)||e.maximumLevel<0)throw new Error("Implicit availableLevels must describe at least the root level")}var l1={draco:!1,meshopt:!1,dds:!1,ktx2:!1},u1=32,Vs=class{type=lt.TILES3D;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...l1};asset;properties;extras;credits;metadata;queryParams={};tileUrlCache=new Map;implicitSubtreeCache;implicitTilingStats={requestedSubtrees:0,loadedSubtrees:0,cacheHits:0,materializedTiles:0};destroyed=!1;extensionsUsed=[];resolver;rootTileset;constructor(t,r={}){let s=f1(t);this.rootTileset=tc(t)?null:t,this.tileset=this.rootTileset,this.loader=s.loader,this.url=s.url,this.basePath=s.basePath||xt.dirname(s.url),this.resolver=s.resolver,this.coreApi=s.coreApi,this.loadOptions=r;let i=Number(r["3d-tiles"]?.maximumCachedSubtrees),n=Number.isFinite(i)?Math.max(0,Math.floor(i)):u1;this.implicitSubtreeCache=new hr({maxEntries:n})}destroy(){this.destroyed=!0,this.tileUrlCache.clear(),this.implicitSubtreeCache.clear()}async initialize(){if(!this.rootTileset){let t=this.loadOptions[this.loader.id]||{};this.rootTileset=await this.loadRootData(this.url,{...this.loadOptions,[this.loader.id]:{...t,isTileset:!0}})}if(this.tileset=this.rootTileset,this.rootTileset.queryString){let t=new URLSearchParams(this.rootTileset.queryString);for(let[r,s]of t.entries())this.setQueryParameter(r,s)}if(this.asset=this.rootTileset.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.setQueryParameter("v",this.asset.tilesetVersion),this.properties=this.rootTileset.properties,this.extras=this.rootTileset.extras,this.credits={attributions:[]},this.extensionsUsed.splice(0,this.extensionsUsed.length,...this.rootTileset.extensionsUsed||[]),this.metadata={type:this.type,loader:this.loader,url:this.url,basePath:this.basePath,tileset:this.rootTileset,lodMetricType:this.rootTileset.lodMetricType,lodMetricValue:this.rootTileset.lodMetricValue,refine:this.rootTileset.root?.refine,spatialReference:Ds(this.rootTileset)}}getMetadata(){if(!this.metadata)throw new Error("Tiles3DSource has not been initialized");return this.metadata}async getRootTileset(){return this.getMetadata().tileset}initializeTileHeaders(t,r,s){let i=new bt(t,r.root,s||void 0);s&&(s.children.push(i),i.depth=s.depth+1);let n=[i];for(;n.length>0;){let o=n.pop();t.stats.get("Tiles In Tileset(s)").incrementCount();let a=o.header.children||[];for(let h of a){let c=new bt(t,h,o);if(c.contentUrl?.includes("?session=")){let u=new URL(c.contentUrl).searchParams.get("session");u&&this.setQueryParameter("session",u)}o.children.push(c),c.depth=o.depth+1,n.push(c)}}return i}createTraverser(t){return new qs(t)}async loadTileContent(t){let r=(t.contentUrls||[t.contentUrl]).filter(Boolean),s=this.loadOptions[this.loader.id]||{},i={...this.loadOptions,[this.loader.id]:{...s,isTileset:"auto",assetGltfUpAxis:this.asset&&this.asset.gltfUpAxis||"Y"}},n=await Promise.all(r.map(a=>this.loadResourceData(this.getTileUrl(a),i)));t.contents=n,t.content=n[0]||null;let o=n.filter(a=>a?.shape==="tileset3d");return{loaded:!0,contents:n,nestedTileset:o[0],nestedTilesets:o}}async loadTileChildren(t,r){let s=t.header.implicitSubtree;if(!s)return{loaded:!1,tileCount:0,childSubtreeCount:0};let i=this.getTileUrl(s.subtreeUrl),n=await this.loadImplicitSubtreeResource(i);if(this.destroyed||t.isDestroyed())return{loaded:!1,tileCount:0,childSubtreeCount:0};let o=Fs(n,{...s,subtreeUrl:i});t.applyImplicitSubtreeHeader(o.root);let a=this.initializeMaterializedChildren(t.tileset,t,o.root.children);return this.implicitTilingStats.loadedSubtrees++,this.implicitTilingStats.materializedTiles+=a,{loaded:!0,tileCount:o.tileCount,childSubtreeCount:o.childSubtreeCount}}getImplicitTilingStats(){return{...this.implicitTilingStats,cachedSubtrees:this.implicitSubtreeCache.size-this.implicitSubtreeCache.pendingSize,pendingSubtrees:this.implicitSubtreeCache.pendingSize}}getTileUrl(t){if(t.startsWith("data:"))return t;let r=this.tileUrlCache.get(t);if(r)return r;if(!Object.keys(this.queryParams).length)return this.tileUrlCache.set(t,t),t;let[s,i=""]=t.split("?"),n=new URLSearchParams(i);for(let[h,c]of Object.entries(this.queryParams))n.has(h)||n.set(h,c);let o=n.toString(),a=o?`${s}?${o}`:s;return this.tileUrlCache.set(t,a),a}setQueryParameter(t,r){this.queryParams[t]!==r&&(this.queryParams[t]=r,this.tileUrlCache.clear())}getViewState(t){if(!t)return{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits};let{center:r}=t.boundingVolume,s;return r&&(r[0]!==0||r[1]!==0||r[2]!==0)?(s=new _,I.WGS84.cartesianToCartographic(r,s)):s=new _(0,0,-I.WGS84.radii[0]),{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits,boundingVolume:t.boundingVolume,cartographicCenter:s,cartesianCenter:r,zoom:jh(t.boundingVolume,s)}}hasExtension(t){return this.extensionsUsed.includes(t)}onTileLoaded(t,r,s){let n=(r.contents.length?r.contents:[r.content]).flatMap(a=>a?.gltf?.extensionsRemoved||[]);n.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),n.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),n.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0);let o=s.nestedTilesets||(s.nestedTileset?[s.nestedTileset]:[]);for(let a of o)t._initializeTileHeaders(a,r)}async loadWithCoreApi(t,r,s=this.loader){if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to load tileset data");return await this.coreApi.load(t,s,r)}async loadRootData(t,r){return this.resolver?await this.resolver.loadRoot(t,this.loader,r):await this.loadWithCoreApi(t,r)}async loadResourceData(t,r,s=this.loader){return this.resolver?await this.resolver.loadResource(t,s,r):await this.loadWithCoreApi(t,r,s)}async loadImplicitSubtreeResource(t){let r=this.implicitSubtreeCache.get(t);if(r)return this.implicitTilingStats.cacheHits++,await r;this.implicitTilingStats.requestedSubtrees++;let s=this.loadOptions[this.loader.id]||{};return await this.implicitSubtreeCache.getOrLoad(t,async()=>await this.loadResourceData(t,{...this.loadOptions,[this.loader.id]:{...s,isTileset:!1,isSubtree:!0}}))}initializeMaterializedChildren(t,r,s){let i=0,n=[{parentTile:r,childHeaders:s}];for(;n.length>0;){let o=n.pop();for(let a of o.childHeaders){let h=new bt(t,a,o.parentTile);o.parentTile.children.push(h),h.depth=o.parentTile.depth+1,t.stats.get("Tiles In Tileset(s)").incrementCount(),i++,a.children?.length&&n.push({parentTile:h,childHeaders:a.children})}}return i}};function tc(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function f1(e){return tc(e)?{...e,basePath:e.basePath||xt.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||xt.dirname(e.url),resolver:e.resolver,coreApi:e.coreApi}}var ks=class{frameNumberMap=new Map;register(t,r){let s=this.frameNumberMap.get(t)||new Map,i=s.get(r)||0;s.set(r,i+1),this.frameNumberMap.set(t,s)}deregister(t,r){let s=this.frameNumberMap.get(t);if(!s)return;let i=s.get(r)||1;s.set(r,i-1)}isZero(t,r){return(this.frameNumberMap.get(t)?.get(r)||0)===0}};var Bn={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},js=class{_statusMap;pendingTilesRegister=new ks;constructor(){this._statusMap={}}add(t,r,s,i){if(!this._statusMap[r]){let{frameNumber:n,viewport:{id:o}}=i;this._statusMap[r]={request:t,callback:s,key:r,frameState:i,status:Bn.REQUESTED},this.pendingTilesRegister.register(o,n),t().then(a=>{this._statusMap[r].status=Bn.COMPLETED;let{frameNumber:h,viewport:{id:c}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(c,h),this._statusMap[r].callback(a,i)}).catch(a=>{this._statusMap[r].status=Bn.ERROR;let{frameNumber:h,viewport:{id:c}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(c,h),s(a)})}}update(t,r){if(this._statusMap[t]){let{frameNumber:s,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,s);let{frameNumber:n,viewport:{id:o}}=r;this.pendingTilesRegister.register(o,n),this._statusMap[t].frameState=r}}find(t){return this._statusMap[t]}hasPendingTiles(t,r){return!this.pendingTilesRegister.isZero(t,r)}};var Ws=class extends Bt{_tileManager;constructor(t){super(t),this._tileManager=new js}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,r){return t._lodJudge=zs(t,r),t._lodJudge==="DIG"}updateChildTiles(t,r){let s=t.header.children||[],i=t.children;for(let n of s){let o=`${n.id}-${r.viewport.id}`,a=i&&i.find(h=>h.id===o);if(a)a&&this.updateTile(a,r);else{let h=()=>this._loadTile(t,n.id,r);this._tileManager.find(o)?this._tileManager.update(o,r):this._tileManager.add(h,o,l=>this._onTileLoad(l,t,o),r)}}return!1}async _loadTile(t,r,s){if(!t.tileset.source.loadChildTileHeader)throw new Error("I3S source does not support child tile header loading");return await t.tileset.source.loadChildTileHeader(t,r,s)}_onTileLoad(t,r,s){if(t instanceof Error){r.tileset._onSourceError(t,r);return}let i=new bt(r.tileset,t,r,s);r.children.push(i);let n=this._tileManager.find(i.id).frameState;this.updateTile(i,n),this._frameNumber===n.frameNumber&&(this.traversalFinished(n)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(i,n)}};function ec(e){e("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),e("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),e("EPSG:3857","+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs");for(var t=1;t<=60;++t)e("EPSG:"+(32600+t),"+proj=utm +zone="+t+" +datum=WGS84 +units=m"),e("EPSG:"+(32700+t),"+proj=utm +zone="+t+" +south +datum=WGS84 +units=m");e("EPSG:5041","+title=WGS 84 / UPS North (E,N) +proj=stere +lat_0=90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m"),e("EPSG:5042","+title=WGS 84 / UPS South (E,N) +proj=stere +lat_0=-90 +lon_0=0 +k=0.994 +x_0=2000000 +y_0=2000000 +datum=WGS84 +units=m"),e.WGS84=e["EPSG:4326"],e["EPSG:3785"]=e["EPSG:3857"],e.GOOGLE=e["EPSG:3857"],e["EPSG:900913"]=e["EPSG:3857"],e["EPSG:102113"]=e["EPSG:3857"]}var It=1,Ot=2,Yt=3,rc=4,xr=5,Dn=6378137,sc=6356752314e-3,Fn=.0066943799901413165,fe=484813681109536e-20,y=Math.PI/2,ic=.16666666666666666,nc=.04722222222222222,oc=.022156084656084655,T=1e-10,V=.017453292519943295,X=57.29577951308232,q=Math.PI/4,ne=Math.PI*2,Y=3.14159265359;var ft={};ft.greenwich=0;ft.lisbon=-9.131906111111;ft.paris=2.337229166667;ft.bogota=-74.080916666667;ft.madrid=-3.687938888889;ft.rome=12.452333333333;ft.bern=7.439583333333;ft.jakarta=106.807719444444;ft.ferro=-17.666666666667;ft.brussels=4.367975;ft.stockholm=18.058277777778;ft.athens=23.7163375;ft.oslo=10.722916666667;var ac=ft;var hc={mm:{to_meter:.001},cm:{to_meter:.01},ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937},fath:{to_meter:1.8288},kmi:{to_meter:1852},"us-ch":{to_meter:20.1168402336805},"us-mi":{to_meter:1609.34721869444},km:{to_meter:1e3},"ind-ft":{to_meter:.30479841},"ind-yd":{to_meter:.91439523},mi:{to_meter:1609.344},yd:{to_meter:.9144},ch:{to_meter:20.1168},link:{to_meter:.201168},dm:{to_meter:.1},in:{to_meter:.0254},"ind-ch":{to_meter:20.11669506},"us-in":{to_meter:.025400050800101},"us-yd":{to_meter:.914401828803658}};var cc=/[\s_\-\/\(\)]/g;function yt(e,t){if(e[t])return e[t];for(var r=Object.keys(e),s=t.toLowerCase().replace(cc,""),i=-1,n,o;++i<r.length;)if(n=r[i],o=n.toLowerCase().replace(cc,""),o===s)return e[n]}function yr(e){var t={},r=e.split("+").map(function(a){return a.trim()}).filter(function(a){return a}).reduce(function(a,h){var c=h.split("=");return c.push(!0),a[c[0].toLowerCase()]=c[1],a},{}),s,i,n,o={proj:"projName",datum:"datumCode",rf:function(a){t.rf=parseFloat(a)},lat_0:function(a){t.lat0=a*V},lat_1:function(a){t.lat1=a*V},lat_2:function(a){t.lat2=a*V},lat_ts:function(a){t.lat_ts=a*V},lon_0:function(a){t.long0=a*V},lon_1:function(a){t.long1=a*V},lon_2:function(a){t.long2=a*V},alpha:function(a){t.alpha=parseFloat(a)*V},gamma:function(a){t.rectified_grid_angle=parseFloat(a)*V},lonc:function(a){t.longc=a*V},x_0:function(a){t.x0=parseFloat(a)},y_0:function(a){t.y0=parseFloat(a)},k_0:function(a){t.k0=parseFloat(a)},k:function(a){t.k0=parseFloat(a)},a:function(a){t.a=parseFloat(a)},b:function(a){t.b=parseFloat(a)},r:function(a){t.a=t.b=parseFloat(a)},r_a:function(){t.R_A=!0},zone:function(a){t.zone=parseInt(a,10)},south:function(){t.utmSouth=!0},towgs84:function(a){t.datum_params=a.split(",").map(function(h){return parseFloat(h)})},to_meter:function(a){t.to_meter=parseFloat(a)},units:function(a){t.units=a;var h=yt(hc,a);h&&(t.to_meter=h.to_meter)},from_greenwich:function(a){t.from_greenwich=a*V},pm:function(a){var h=yt(ac,a);t.from_greenwich=(h||parseFloat(a))*V},nadgrids:function(a){a==="@null"?t.datumCode="none":t.nadgrids=a},axis:function(a){var h="ewnsud";a.length===3&&h.indexOf(a.substr(0,1))!==-1&&h.indexOf(a.substr(1,1))!==-1&&h.indexOf(a.substr(2,1))!==-1&&(t.axis=a)},approx:function(){t.approx=!0},over:function(){t.over=!0}};for(s in r)i=r[s],s in o?(n=o[s],typeof n=="function"?n(i):t[n]=i):t[s]=i;return typeof t.datumCode=="string"&&t.datumCode!=="WGS84"&&(t.datumCode=t.datumCode.toLowerCase()),t.projStr=e,t}var Un=class{static getId(t){let r=t.find(s=>Array.isArray(s)&&s[0]==="ID");return r&&r.length>=3?{authority:r[1],code:parseInt(r[2],10)}:null}static convertUnit(t,r="unit"){if(!t||t.length<3)return{type:r,name:"unknown",conversion_factor:null};let s=t[1],i=parseFloat(t[2])||null,n=t.find(a=>Array.isArray(a)&&a[0]==="ID"),o=n?{authority:n[1],code:parseInt(n[2],10)}:null;return{type:r,name:s,conversion_factor:i,id:o}}static convertAxis(t){let r=t[1]||"Unknown",s,i=r.match(/^\((.)\)$/);if(i){let c=i[1].toUpperCase();if(c==="E")s="east";else if(c==="N")s="north";else if(c==="U")s="up";else if(t[2])s=t[2];else throw new Error(`Unknown axis abbreviation: ${c}`)}else s=t[2]||"unknown";let n=t.find(c=>Array.isArray(c)&&c[0]==="ORDER"),o=n?parseInt(n[1],10):null,a=t.find(c=>Array.isArray(c)&&(c[0]==="LENGTHUNIT"||c[0]==="ANGLEUNIT"||c[0]==="SCALEUNIT")),h=this.convertUnit(a);return{name:r,direction:s,unit:h,order:o}}static extractAxes(t){return t.filter(r=>Array.isArray(r)&&r[0]==="AXIS").map(r=>this.convertAxis(r)).sort((r,s)=>(r.order||0)-(s.order||0))}static convert(t,r={}){switch(t[0]){case"PROJCRS":r.type="ProjectedCRS",r.name=t[1],r.base_crs=t.find(m=>Array.isArray(m)&&m[0]==="BASEGEOGCRS")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="BASEGEOGCRS")):null,r.conversion=t.find(m=>Array.isArray(m)&&m[0]==="CONVERSION")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="CONVERSION")):null;let s=t.find(m=>Array.isArray(m)&&m[0]==="CS");s&&(r.coordinate_system={subtype:s[1],axis:this.extractAxes(t)});let i=t.find(m=>Array.isArray(m)&&m[0]==="LENGTHUNIT");if(i){let m=this.convertUnit(i);r.coordinate_system.unit=m}r.id=this.getId(t);break;case"BASEGEOGCRS":case"GEOGCRS":case"GEODCRS":r.type=t[0]==="GEODCRS"?"GeodeticCRS":"GeographicCRS",r.name=t[1];let n=t.find(m=>Array.isArray(m)&&(m[0]==="DATUM"||m[0]==="ENSEMBLE"));if(n){let m=this.convert(n);n[0]==="ENSEMBLE"?r.datum_ensemble=m:r.datum=m;let g=t.find(p=>Array.isArray(p)&&p[0]==="PRIMEM");g&&g[1]!=="Greenwich"&&(m.prime_meridian={name:g[1],longitude:parseFloat(g[2])})}let o=t.find(m=>Array.isArray(m)&&m[0]==="CS");r.coordinate_system={subtype:o?o[1]:"ellipsoidal",axis:this.extractAxes(t)},r.id=this.getId(t);break;case"DATUM":r.type="GeodeticReferenceFrame",r.name=t[1],r.ellipsoid=t.find(m=>Array.isArray(m)&&m[0]==="ELLIPSOID")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="ELLIPSOID")):null;break;case"ENSEMBLE":r.type="DatumEnsemble",r.name=t[1],r.members=t.filter(m=>Array.isArray(m)&&m[0]==="MEMBER").map(m=>({type:"DatumEnsembleMember",name:m[1],id:this.getId(m)}));let a=t.find(m=>Array.isArray(m)&&m[0]==="ENSEMBLEACCURACY");a&&(r.accuracy=parseFloat(a[1]));let h=t.find(m=>Array.isArray(m)&&m[0]==="ELLIPSOID");h&&(r.ellipsoid=this.convert(h)),r.id=this.getId(t);break;case"ELLIPSOID":r.type="Ellipsoid",r.name=t[1],r.semi_major_axis=parseFloat(t[2]),r.inverse_flattening=parseFloat(t[3]);let c=t.find(m=>Array.isArray(m)&&m[0]==="LENGTHUNIT")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="LENGTHUNIT"),r):null;break;case"CONVERSION":r.type="Conversion",r.name=t[1],r.method=t.find(m=>Array.isArray(m)&&m[0]==="METHOD")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="METHOD")):null,r.parameters=t.filter(m=>Array.isArray(m)&&m[0]==="PARAMETER").map(m=>this.convert(m));break;case"METHOD":r.type="Method",r.name=t[1],r.id=this.getId(t);break;case"PARAMETER":r.type="Parameter",r.name=t[1],r.value=parseFloat(t[2]),r.unit=this.convertUnit(t.find(m=>Array.isArray(m)&&(m[0]==="LENGTHUNIT"||m[0]==="ANGLEUNIT"||m[0]==="SCALEUNIT"))),r.id=this.getId(t);break;case"BOUNDCRS":r.type="BoundCRS";let l=t.find(m=>Array.isArray(m)&&m[0]==="SOURCECRS");if(l){let m=l.find(g=>Array.isArray(g));r.source_crs=m?this.convert(m):null}let u=t.find(m=>Array.isArray(m)&&m[0]==="TARGETCRS");if(u){let m=u.find(g=>Array.isArray(g));r.target_crs=m?this.convert(m):null}let f=t.find(m=>Array.isArray(m)&&m[0]==="ABRIDGEDTRANSFORMATION");f?r.transformation=this.convert(f):r.transformation=null;break;case"ABRIDGEDTRANSFORMATION":if(r.type="Transformation",r.name=t[1],r.method=t.find(m=>Array.isArray(m)&&m[0]==="METHOD")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="METHOD")):null,r.parameters=t.filter(m=>Array.isArray(m)&&(m[0]==="PARAMETER"||m[0]==="PARAMETERFILE")).map(m=>{if(m[0]==="PARAMETER")return this.convert(m);if(m[0]==="PARAMETERFILE")return{name:m[1],value:m[2],id:{authority:"EPSG",code:8656}}}),r.parameters.length===7){let m=r.parameters[6];m.name==="Scale difference"&&(m.value=Math.round((m.value-1)*1e12)/1e6)}r.id=this.getId(t);break;case"AXIS":r.coordinate_system||(r.coordinate_system={type:"unspecified",axis:[]}),r.coordinate_system.axis.push(this.convertAxis(t));break;case"LENGTHUNIT":let d=this.convertUnit(t,"LinearUnit");r.coordinate_system&&r.coordinate_system.axis&&r.coordinate_system.axis.forEach(m=>{m.unit||(m.unit=d)}),d.conversion_factor&&d.conversion_factor!==1&&r.semi_major_axis&&(r.semi_major_axis={value:r.semi_major_axis,unit:d});break;default:r.keyword=t[0];break}return r}},lc=Un;function uc(e){return lc.convert(e)}function fc(e){let t=e.toUpperCase();return t.includes("PROJCRS")||t.includes("GEOGCRS")||t.includes("BOUNDCRS")||t.includes("VERTCRS")||t.includes("LENGTHUNIT")||t.includes("ANGLEUNIT")||t.includes("SCALEUNIT")?"WKT2":(t.includes("PROJCS")||t.includes("GEOGCS")||t.includes("LOCAL_CS")||t.includes("VERT_CS")||t.includes("UNIT"),"WKT1")}var mc=g1,Sr=1,dc=2,pc=3,Hs=4,gc=5,Vn=-1,m1=/\s/,d1=/[A-Za-z]/,p1=/[A-Za-z84_]/,Ys=/[,\]]/,_c=/[\d\.E\-\+]/;function Zt(e){if(typeof e!="string")throw new Error("not a string");this.text=e.trim(),this.level=0,this.place=0,this.root=null,this.stack=[],this.currentObject=null,this.state=Sr}Zt.prototype.readCharicter=function(){var e=this.text[this.place++];if(this.state!==Hs)for(;m1.test(e);){if(this.place>=this.text.length)return;e=this.text[this.place++]}switch(this.state){case Sr:return this.neutral(e);case dc:return this.keyword(e);case Hs:return this.quoted(e);case gc:return this.afterquote(e);case pc:return this.number(e);case Vn:return}};Zt.prototype.afterquote=function(e){if(e==='"'){this.word+='"',this.state=Hs;return}if(Ys.test(e)){this.word=this.word.trim(),this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in afterquote yet, index '+this.place)};Zt.prototype.afterItem=function(e){if(e===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=Sr;return}if(e==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=Sr,this.currentObject=this.stack.pop(),this.currentObject||(this.state=Vn);return}};Zt.prototype.number=function(e){if(_c.test(e)){this.word+=e;return}if(Ys.test(e)){this.word=parseFloat(this.word),this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in number yet, index '+this.place)};Zt.prototype.quoted=function(e){if(e==='"'){this.state=gc;return}this.word+=e};Zt.prototype.keyword=function(e){if(p1.test(e)){this.word+=e;return}if(e==="["){var t=[];t.push(this.word),this.level++,this.root===null?this.root=t:this.currentObject.push(t),this.stack.push(this.currentObject),this.currentObject=t,this.state=Sr;return}if(Ys.test(e)){this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in keyword yet, index '+this.place)};Zt.prototype.neutral=function(e){if(d1.test(e)){this.word=e,this.state=dc;return}if(e==='"'){this.word="",this.state=Hs;return}if(_c.test(e)){this.word=e,this.state=pc;return}if(Ys.test(e)){this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in neutral yet, index '+this.place)};Zt.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===Vn)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function g1(e){var t=new Zt(e);return t.output()}function kn(e,t,r){Array.isArray(t)&&(r.unshift(t),t=null);var s=t?{}:e,i=r.reduce(function(n,o){return me(o,n),n},s);t&&(e[t]=i)}function me(e,t){if(!Array.isArray(e)){t[e]=!0;return}var r=e.shift();if(r==="PARAMETER"&&(r=e.shift()),e.length===1){if(Array.isArray(e[0])){t[r]={},me(e[0],t[r]);return}t[r]=e[0];return}if(!e.length){t[r]=!0;return}if(r==="TOWGS84"){t[r]=e;return}if(r==="AXIS"){r in t||(t[r]=[]),t[r].push(e);return}Array.isArray(r)||(t[r]={});var s;switch(r){case"UNIT":case"PRIMEM":case"VERT_DATUM":t[r]={name:e[0].toLowerCase(),convert:e[1]},e.length===3&&me(e[2],t[r]);return;case"SPHEROID":case"ELLIPSOID":t[r]={name:e[0],a:e[1],rf:e[2]},e.length===4&&me(e[3],t[r]);return;case"EDATUM":case"ENGINEERINGDATUM":case"LOCAL_DATUM":case"DATUM":case"VERT_CS":case"VERTCRS":case"VERTICALCRS":e[0]=["name",e[0]],kn(t,r,e);return;case"COMPD_CS":case"COMPOUNDCRS":case"FITTED_CS":case"PROJECTEDCRS":case"PROJCRS":case"GEOGCS":case"GEOCCS":case"PROJCS":case"LOCAL_CS":case"GEODCRS":case"GEODETICCRS":case"GEODETICDATUM":case"ENGCRS":case"ENGINEERINGCRS":e[0]=["name",e[0]],kn(t,r,e),t[r].type=r;return;default:for(s=-1;++s<e.length;)if(!Array.isArray(e[s]))return me(e,t[r]);return kn(t,r,e)}}var _1=.017453292519943295;function St(e){return e*_1}function Zs(e){let t=(e.projName||"").toLowerCase().replace(/_/g," ");e.long0===void 0&&e.longc!==void 0&&(e.long0=e.longc),!e.lat_ts&&e.lat1&&(t==="stereographic south pole"||t==="polar stereographic (variant b)")?(e.lat0=St(e.lat1>0?90:-90),e.lat_ts=e.lat1,delete e.lat1):!e.lat_ts&&e.lat0&&(t==="polar stereographic"||t==="polar stereographic (variant a)")&&(e.lat_ts=e.lat0,e.lat0=St(e.lat0>0?90:-90),delete e.lat1)}function Mc(e){let t={units:null,to_meter:void 0};return typeof e=="string"?(t.units=e.toLowerCase(),t.units==="metre"&&(t.units="meter"),t.units==="meter"&&(t.to_meter=1)):e&&e.name&&(t.units=e.name.toLowerCase(),t.units==="metre"&&(t.units="meter"),t.to_meter=e.conversion_factor),t}function xc(e){return typeof e=="object"?e.value*e.unit.conversion_factor:e}function yc(e,t){e.ellipsoid.radius?(t.a=e.ellipsoid.radius,t.rf=0):(t.a=xc(e.ellipsoid.semi_major_axis),e.ellipsoid.inverse_flattening!==void 0?t.rf=e.ellipsoid.inverse_flattening:e.ellipsoid.semi_major_axis!==void 0&&e.ellipsoid.semi_minor_axis!==void 0&&(t.rf=t.a/(t.a-xc(e.ellipsoid.semi_minor_axis))))}function vr(e,t={}){return!e||typeof e!="object"?e:e.type==="BoundCRS"?(vr(e.source_crs,t),e.transformation&&(e.transformation.method&&e.transformation.method.name==="NTv2"?t.nadgrids=e.transformation.parameters[0].value:t.datum_params=e.transformation.parameters.map(r=>r.value)),t):(Object.keys(e).forEach(r=>{let s=e[r];if(s!==null)switch(r){case"name":if(t.srsCode)break;t.name=s,t.srsCode=s;break;case"type":s==="GeographicCRS"?t.projName="longlat":s==="GeodeticCRS"?e.coordinate_system&&e.coordinate_system.subtype==="Cartesian"?t.projName="geocent":t.projName="longlat":s==="ProjectedCRS"&&e.conversion&&e.conversion.method&&(t.projName=e.conversion.method.name);break;case"datum":case"datum_ensemble":s.ellipsoid&&(t.ellps=s.ellipsoid.name,yc(s,t)),s.prime_meridian&&(t.from_greenwich=s.prime_meridian.longitude*Math.PI/180);break;case"ellipsoid":t.ellps=s.name,yc(s,t);break;case"prime_meridian":t.long0=(s.longitude||0)*Math.PI/180;break;case"coordinate_system":if(s.axis){let i={east:"e",north:"n",west:"w",south:"s",up:"u",down:"d",geocentricx:"e",geocentricy:"n",geocentricz:"u"},n=s.axis.map(o=>i[o.direction.toLowerCase()]);if(n.every(Boolean)&&(t.axis=n.join(""),t.axis.length===2&&(t.axis+="u")),s.unit){let{units:o,to_meter:a}=Mc(s.unit);t.units=o,t.to_meter=a}else if(s.axis[0]&&s.axis[0].unit){let{units:o,to_meter:a}=Mc(s.axis[0].unit);t.units=o,t.to_meter=a}}break;case"id":s.authority&&s.code&&(t.title=s.authority+":"+s.code);break;case"conversion":s.method&&s.method.name&&(t.projName=s.method.name),s.parameters&&s.parameters.forEach(i=>{let n=i.name.toLowerCase().replace(/\s+/g,"_"),o=i.value;i.unit&&i.unit.conversion_factor?t[n]=o*i.unit.conversion_factor:i.unit==="degree"?t[n]=o*Math.PI/180:t[n]=o});break;case"unit":s.name&&(t.units=s.name.toLowerCase(),t.units==="metre"&&(t.units="meter")),s.conversion_factor&&(t.to_meter=s.conversion_factor);break;case"base_crs":vr(s,t),t.datumCode=s.id?s.id.authority+"_"+s.id.code:s.name;break;default:break}}),t.latitude_of_false_origin!==void 0&&(t.lat0=t.latitude_of_false_origin),t.longitude_of_false_origin!==void 0&&(t.long0=t.longitude_of_false_origin),t.latitude_of_standard_parallel!==void 0&&(t.lat0=t.latitude_of_standard_parallel,t.lat1=t.latitude_of_standard_parallel),t.latitude_of_1st_standard_parallel!==void 0&&(t.lat1=t.latitude_of_1st_standard_parallel),t.latitude_of_2nd_standard_parallel!==void 0&&(t.lat2=t.latitude_of_2nd_standard_parallel),t.latitude_of_projection_centre!==void 0&&(t.lat0=t.latitude_of_projection_centre),t.longitude_of_projection_centre!==void 0&&(t.longc=t.longitude_of_projection_centre),t.easting_at_false_origin!==void 0&&(t.x0=t.easting_at_false_origin),t.northing_at_false_origin!==void 0&&(t.y0=t.northing_at_false_origin),t.latitude_of_natural_origin!==void 0&&(t.lat0=t.latitude_of_natural_origin),t.longitude_of_natural_origin!==void 0&&(t.long0=t.longitude_of_natural_origin),t.longitude_of_origin!==void 0&&(t.long0=t.longitude_of_origin),t.false_easting!==void 0&&(t.x0=t.false_easting),t.easting_at_projection_centre&&(t.x0=t.easting_at_projection_centre),t.false_northing!==void 0&&(t.y0=t.false_northing),t.northing_at_projection_centre&&(t.y0=t.northing_at_projection_centre),t.standard_parallel_1!==void 0&&(t.lat1=t.standard_parallel_1),t.standard_parallel_2!==void 0&&(t.lat2=t.standard_parallel_2),t.scale_factor_at_natural_origin!==void 0&&(t.k0=t.scale_factor_at_natural_origin),t.scale_factor_at_projection_centre!==void 0&&(t.k0=t.scale_factor_at_projection_centre),t.scale_factor_on_pseudo_standard_parallel!==void 0&&(t.k0=t.scale_factor_on_pseudo_standard_parallel),t.azimuth!==void 0&&(t.alpha=t.azimuth),t.azimuth_at_projection_centre!==void 0&&(t.alpha=t.azimuth_at_projection_centre),t.angle_from_rectified_to_skew_grid&&(t.rectified_grid_angle=t.angle_from_rectified_to_skew_grid),Zs(t),t)}var M1=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function x1(e,t){var r=t[0],s=t[1];!(r in e)&&s in e&&(e[r]=e[s],t.length===3&&(e[r]=t[2](e[r])))}function Sc(e){for(var t=Object.keys(e),r=0,s=t.length;r<s;++r){var i=t[r];M1.indexOf(i)!==-1&&y1(e[i]),typeof e[i]=="object"&&Sc(e[i])}}function y1(e){if(e.AUTHORITY){var t=Object.keys(e.AUTHORITY)[0];t&&t in e.AUTHORITY&&(e.title=t+":"+e.AUTHORITY[t])}if(e.type==="GEOGCS"?e.projName="longlat":e.type==="LOCAL_CS"?(e.projName="identity",e.local=!0):typeof e.PROJECTION=="object"?e.projName=Object.keys(e.PROJECTION)[0]:e.projName=e.PROJECTION,e.AXIS){for(var r="",s=0,i=e.AXIS.length;s<i;++s){var n=[e.AXIS[s][0].toLowerCase(),e.AXIS[s][1].toLowerCase()];n[0].indexOf("north")!==-1||(n[0]==="y"||n[0]==="lat")&&n[1]==="north"?r+="n":n[0].indexOf("south")!==-1||(n[0]==="y"||n[0]==="lat")&&n[1]==="south"?r+="s":n[0].indexOf("east")!==-1||(n[0]==="x"||n[0]==="lon")&&n[1]==="east"?r+="e":(n[0].indexOf("west")!==-1||(n[0]==="x"||n[0]==="lon")&&n[1]==="west")&&(r+="w")}r.length===2&&(r+="u"),r.length===3&&(e.axis=r)}e.UNIT&&(e.units=e.UNIT.name.toLowerCase(),e.units==="metre"&&(e.units="meter"),e.UNIT.convert&&(e.type==="GEOGCS"?e.DATUM&&e.DATUM.SPHEROID&&(e.to_meter=e.UNIT.convert*e.DATUM.SPHEROID.a):e.to_meter=e.UNIT.convert));var o=e.GEOGCS;e.type==="GEOGCS"&&(o=e),o&&(o.PRIMEM&&o.PRIMEM.convert&&(e.from_greenwich=St(o.PRIMEM.convert)),o.DATUM?e.datumCode=o.DATUM.name.toLowerCase():e.datumCode=o.name.toLowerCase(),e.datumCode.slice(0,2)==="d_"&&(e.datumCode=e.datumCode.slice(2)),e.datumCode==="new_zealand_1949"&&(e.datumCode="nzgd49"),(e.datumCode==="wgs_1984"||e.datumCode==="world_geodetic_system_1984")&&(e.PROJECTION==="Mercator_Auxiliary_Sphere"&&(e.sphere=!0),e.datumCode="wgs84"),e.datumCode==="belge_1972"&&(e.datumCode="rnb72"),o.DATUM&&o.DATUM.SPHEROID&&(e.ellps=o.DATUM.SPHEROID.name.replace("_19","").replace(/[Cc]larke\_18/,"clrk"),e.ellps.toLowerCase().slice(0,13)==="international"&&(e.ellps="intl"),e.a=o.DATUM.SPHEROID.a,e.rf=parseFloat(o.DATUM.SPHEROID.rf)),o.DATUM&&o.DATUM.TOWGS84&&(e.datum_params=o.DATUM.TOWGS84),~e.datumCode.indexOf("osgb_1936")&&(e.datumCode="osgb36"),~e.datumCode.indexOf("osni_1952")&&(e.datumCode="osni52"),(~e.datumCode.indexOf("tm65")||~e.datumCode.indexOf("geodetic_datum_of_1965"))&&(e.datumCode="ire65"),e.datumCode==="ch1903+"&&(e.datumCode="ch1903"),~e.datumCode.indexOf("israel")&&(e.datumCode="isr93")),e.b&&!isFinite(e.b)&&(e.b=e.a),e.rectified_grid_angle&&(e.rectified_grid_angle=St(e.rectified_grid_angle));function a(l){var u=e.to_meter||1;return l*u}var h=function(l){return x1(e,l)},c=[["standard_parallel_1","Standard_Parallel_1"],["standard_parallel_1","Latitude of 1st standard parallel"],["standard_parallel_2","Standard_Parallel_2"],["standard_parallel_2","Latitude of 2nd standard parallel"],["false_easting","False_Easting"],["false_easting","False easting"],["false-easting","Easting at false origin"],["false_northing","False_Northing"],["false_northing","False northing"],["false_northing","Northing at false origin"],["central_meridian","Central_Meridian"],["central_meridian","Longitude of natural origin"],["central_meridian","Longitude of false origin"],["latitude_of_origin","Latitude_Of_Origin"],["latitude_of_origin","Central_Parallel"],["latitude_of_origin","Latitude of natural origin"],["latitude_of_origin","Latitude of false origin"],["scale_factor","Scale_Factor"],["k0","scale_factor"],["latitude_of_center","Latitude_Of_Center"],["latitude_of_center","Latitude_of_center"],["lat0","latitude_of_center",St],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",St],["x0","false_easting",a],["y0","false_northing",a],["long0","central_meridian",St],["lat0","latitude_of_origin",St],["lat0","standard_parallel_1",St],["lat1","standard_parallel_1",St],["lat2","standard_parallel_2",St],["azimuth","Azimuth"],["alpha","azimuth",St],["srsCode","name"]];c.forEach(h),Zs(e)}function Oe(e){if(typeof e=="object")return vr(e);let t=fc(e);var r=mc(e);if(t==="WKT2"){let n=uc(r);return vr(n)}var s=r[0],i={};return me(r,i),Sc(i),i[s]}function mt(e){var t=this;if(arguments.length===2){var r=arguments[1];typeof r=="string"?r.charAt(0)==="+"?mt[e]=yr(arguments[1]):mt[e]=Oe(arguments[1]):r&&typeof r=="object"&&!("projName"in r)?mt[e]=Oe(arguments[1]):(mt[e]=r,r||delete mt[e])}else if(arguments.length===1){if(Array.isArray(e))return e.map(function(s){return Array.isArray(s)?mt.apply(t,s):mt(s)});if(typeof e=="string"){if(e in mt)return mt[e]}else"EPSG"in e?mt["EPSG:"+e.EPSG]=e:"ESRI"in e?mt["ESRI:"+e.ESRI]=e:"IAU2000"in e?mt["IAU2000:"+e.IAU2000]=e:console.log(e);return}}ec(mt);var Ne=mt;function S1(e){return typeof e=="string"}function v1(e){return e in Ne}function E1(e){return e.indexOf("+")!==0&&e.indexOf("[")!==-1||typeof e=="object"&&!("srsCode"in e)}var vc=["3857","900913","3785","102113"];function w1(e){if(e.title)return e.title.toLowerCase().indexOf("epsg:")===0&&vc.indexOf(e.title.substr(5))>-1;var t=yt(e,"authority");if(t){var r=yt(t,"epsg");return r&&vc.indexOf(r)>-1}}function T1(e){var t=yt(e,"extension");if(t)return yt(t,"proj4")}function P1(e){return e[0]==="+"}function b1(e){let t;if(S1(e))if(v1(e))t=Ne[e];else if(E1(e)){t=Oe(e);var r=T1(t);r&&(t=yr(r))}else P1(e)&&(t=yr(e));else"projName"in e?t=e:t=Oe(e);return t&&w1(t)?Ne["EPSG:3857"]:t}var Ec=b1;function jn(e,t){e=e||{};var r,s;if(!t)return e;for(s in t)r=t[s],r!==void 0&&(e[s]=r);return e}function at(e,t,r){var s=e*t;return r/Math.sqrt(1-s*s)}function Dt(e){return e<0?-1:1}function E(e,t){return t||Math.abs(e)<=Y?e:e-Dt(e)*ne}function ut(e,t,r){var s=e*r,i=.5*e;return s=Math.pow((1-s)/(1+s),i),Math.tan(.5*(y-t))/s}function $t(e,t){for(var r=.5*e,s,i,n=y-2*Math.atan(t),o=0;o<=15;o++)if(s=e*Math.sin(n),i=y-2*Math.atan(t*Math.pow((1-s)/(1+s),r))-n,n+=i,Math.abs(i)<=1e-10)return n;return-9999}function R1(){var e=this.b/this.a;this.es=1-e*e,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=at(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function C1(e){var t=e.x,r=e.y;if(r*X>90&&r*X<-90&&t*X>180&&t*X<-180)return null;var s,i;if(Math.abs(Math.abs(r)-y)<=T)return null;if(this.sphere)s=this.x0+this.a*this.k0*E(t-this.long0,this.over),i=this.y0+this.a*this.k0*Math.log(Math.tan(q+.5*r));else{var n=Math.sin(r),o=ut(this.e,r,n);s=this.x0+this.a*this.k0*E(t-this.long0,this.over),i=this.y0-this.a*this.k0*Math.log(o)}return e.x=s,e.y=i,e}function A1(e){var t=e.x-this.x0,r=e.y-this.y0,s,i;if(this.sphere)i=y-2*Math.atan(Math.exp(-r/(this.a*this.k0)));else{var n=Math.exp(-r/(this.a*this.k0));if(i=$t(this.e,n),i===-9999)return null}return s=E(this.long0+t/(this.a*this.k0),this.over),e.x=s,e.y=i,e}var I1=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","Mercator_Variant_A","merc"],wc={init:R1,forward:C1,inverse:A1,names:I1};function O1(){}function Tc(e){return e}var Wn=["longlat","identity"],Pc={init:O1,forward:Tc,inverse:Tc,names:Wn};var N1=[wc,Pc],de={},Le=[];function bc(e,t){var r=Le.length;return e.names?(Le[r]=e,e.names.forEach(function(s){de[s.toLowerCase()]=r}),this):(console.log(t),!0)}function Hn(e){return e.replace(/[-\(\)\s]+/g," ").trim().replace(/ /g,"_")}function L1(e){if(!e)return!1;var t=e.toLowerCase();if(typeof de[t]<"u"&&Le[de[t]]||(t=Hn(t),t in de&&Le[de[t]]))return Le[de[t]]}function G1(){N1.forEach(bc)}var Rc={start:G1,add:bc,get:L1};var z1={MERIT:{a:6378137,rf:298.257,ellipseName:"MERIT 1983"},SGS85:{a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"},GRS80:{a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"},IAU76:{a:6378140,rf:298.257,ellipseName:"IAU 1976"},airy:{a:6377563396e-3,b:635625691e-2,ellipseName:"Airy 1830"},APL4:{a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"},NWL9D:{a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"},mod_airy:{a:6377340189e-3,b:6356034446e-3,ellipseName:"Modified Airy"},andrae:{a:637710443e-2,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"},aust_SA:{a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"},GRS67:{a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"},bessel:{a:6377397155e-3,rf:299.1528128,ellipseName:"Bessel 1841"},bess_nam:{a:6377483865e-3,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"},clrk66:{a:63782064e-1,b:63565838e-1,ellipseName:"Clarke 1866"},clrk80:{a:6378249145e-3,rf:293.4663,ellipseName:"Clarke 1880 mod."},clrk80ign:{a:63782492e-1,b:6356515,rf:293.4660213,ellipseName:"Clarke 1880 (IGN)"},clrk58:{a:6378293645208759e-9,rf:294.2606763692654,ellipseName:"Clarke 1858"},CPM:{a:63757387e-1,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"},delmbr:{a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"},engelis:{a:637813605e-2,rf:298.2566,ellipseName:"Engelis 1985"},evrst30:{a:6377276345e-3,rf:300.8017,ellipseName:"Everest 1830"},evrst48:{a:6377304063e-3,rf:300.8017,ellipseName:"Everest 1948"},evrst56:{a:6377301243e-3,rf:300.8017,ellipseName:"Everest 1956"},evrst69:{a:6377295664e-3,rf:300.8017,ellipseName:"Everest 1969"},evrstSS:{a:6377298556e-3,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"},fschr60:{a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"},fschr60m:{a:6378155,rf:298.3,ellipseName:"Fischer 1960"},fschr68:{a:6378150,rf:298.3,ellipseName:"Fischer 1968"},helmert:{a:6378200,rf:298.3,ellipseName:"Helmert 1906"},hough:{a:6378270,rf:297,ellipseName:"Hough"},intl:{a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"},kaula:{a:6378163,rf:298.24,ellipseName:"Kaula 1961"},lerch:{a:6378139,rf:298.257,ellipseName:"Lerch 1979"},mprts:{a:6397300,rf:191,ellipseName:"Maupertius 1738"},new_intl:{a:63781575e-1,b:63567722e-1,ellipseName:"New International 1967"},plessis:{a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"},krass:{a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"},SEasia:{a:6378155,b:63567733205e-4,ellipseName:"Southeast Asia"},walbeck:{a:6376896,b:63558348467e-4,ellipseName:"Walbeck"},WGS60:{a:6378165,rf:298.3,ellipseName:"WGS 60"},WGS66:{a:6378145,rf:298.25,ellipseName:"WGS 66"},WGS7:{a:6378135,rf:298.26,ellipseName:"WGS 72"},WGS84:{a:6378137,rf:298.257223563,ellipseName:"WGS 84"},sphere:{a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"}},Yn=z1;var q1=Yn.WGS84;function Cc(e,t,r,s){var i=e*e,n=t*t,o=(i-n)/i,a=0;s?(e*=1-o*(ic+o*(nc+o*oc)),i=e*e,o=0):a=Math.sqrt(o);var h=(i-n)/n;return{es:o,e:a,ep2:h}}function Ac(e,t,r,s,i){if(!e){var n=yt(Yn,s);n||(n=q1),e=n.a,t=n.b,r=n.rf}return r&&!t&&(t=(1-1/r)*e),(r===0||Math.abs(e-t)<T)&&(i=!0,t=e),{a:e,b:t,rf:r,sphere:i}}var Qs={wgs84:{towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},ch1903:{towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},ggrs87:{towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},nad83:{towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},nad27:{nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},potsdam:{towgs84:"598.1,73.7,418.2,0.202,0.045,-2.455,6.7",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},carthage:{towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},hermannskogel:{towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Hermannskogel"},mgi:{towgs84:"577.326,90.129,463.919,5.137,1.474,5.297,2.4232",ellipse:"bessel",datumName:"Militar-Geographische Institut"},osni52:{towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"},ire65:{towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},rassadiran:{towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},nzgd49:{towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},osgb36:{towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Ordnance Survey of Great Britain 1936"},s_jtsk:{towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},beduaram:{towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},gunung_segara:{towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},rnb72:{towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"},EPSG_5451:{towgs84:"6.41,-49.05,-11.28,1.5657,0.5242,6.9718,-5.7649"},IGNF_LURESG:{towgs84:"-192.986,13.673,-39.309,-0.4099,-2.9332,2.6881,0.43"},EPSG_4614:{towgs84:"-119.4248,-303.65872,-11.00061,1.164298,0.174458,1.096259,3.657065"},EPSG_4615:{towgs84:"-494.088,-312.129,279.877,-1.423,-1.013,1.59,-0.748"},ESRI_37241:{towgs84:"-76.822,257.457,-12.817,2.136,-0.033,-2.392,-0.031"},ESRI_37249:{towgs84:"-440.296,58.548,296.265,1.128,10.202,4.559,-0.438"},ESRI_37245:{towgs84:"-511.151,-181.269,139.609,1.05,2.703,1.798,3.071"},EPSG_4178:{towgs84:"24.9,-126.4,-93.2,-0.063,-0.247,-0.041,1.01"},EPSG_4622:{towgs84:"-472.29,-5.63,-304.12,0.4362,-0.8374,0.2563,1.8984"},EPSG_4625:{towgs84:"126.93,547.94,130.41,-2.7867,5.1612,-0.8584,13.8227"},EPSG_5252:{towgs84:"0.023,0.036,-0.068,0.00176,0.00912,-0.01136,0.00439"},EPSG_4314:{towgs84:"597.1,71.4,412.1,0.894,0.068,-1.563,7.58"},EPSG_4282:{towgs84:"-178.3,-316.7,-131.5,5.278,6.077,10.979,19.166"},EPSG_4231:{towgs84:"-83.11,-97.38,-117.22,0.005693,-0.044698,0.044285,0.1218"},EPSG_4274:{towgs84:"-230.994,102.591,25.199,0.633,-0.239,0.9,1.95"},EPSG_4134:{towgs84:"-180.624,-225.516,173.919,-0.81,-1.898,8.336,16.71006"},EPSG_4254:{towgs84:"18.38,192.45,96.82,0.056,-0.142,-0.2,-0.0013"},EPSG_4159:{towgs84:"-194.513,-63.978,-25.759,-3.4027,3.756,-3.352,-0.9175"},EPSG_4687:{towgs84:"0.072,-0.507,-0.245,0.0183,-0.0003,0.007,-0.0093"},EPSG_4227:{towgs84:"-83.58,-397.54,458.78,-17.595,-2.847,4.256,3.225"},EPSG_4746:{towgs84:"599.4,72.4,419.2,-0.062,-0.022,-2.723,6.46"},EPSG_4745:{towgs84:"612.4,77,440.2,-0.054,0.057,-2.797,2.55"},EPSG_6311:{towgs84:"8.846,-4.394,-1.122,-0.00237,-0.146528,0.130428,0.783926"},EPSG_4289:{towgs84:"565.7381,50.4018,465.2904,-0.395026,0.330772,-1.876073,4.07244"},EPSG_4230:{towgs84:"-68.863,-134.888,-111.49,-0.53,-0.14,0.57,-3.4"},EPSG_4154:{towgs84:"-123.02,-158.95,-168.47"},EPSG_4156:{towgs84:"570.8,85.7,462.8,4.998,1.587,5.261,3.56"},EPSG_4299:{towgs84:"482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15"},EPSG_4179:{towgs84:"33.4,-146.6,-76.3,-0.359,-0.053,0.844,-0.84"},EPSG_4313:{towgs84:"-106.8686,52.2978,-103.7239,0.3366,-0.457,1.8422,-1.2747"},EPSG_4194:{towgs84:"163.511,127.533,-159.789"},EPSG_4195:{towgs84:"105,326,-102.5"},EPSG_4196:{towgs84:"-45,417,-3.5"},EPSG_4611:{towgs84:"-162.619,-276.959,-161.764,0.067753,-2.243648,-1.158828,-1.094246"},EPSG_4633:{towgs84:"137.092,131.66,91.475,-1.9436,-11.5993,-4.3321,-7.4824"},EPSG_4641:{towgs84:"-408.809,366.856,-412.987,1.8842,-0.5308,2.1655,-121.0993"},EPSG_4643:{towgs84:"-480.26,-438.32,-643.429,16.3119,20.1721,-4.0349,-111.7002"},EPSG_4300:{towgs84:"482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15"},EPSG_4188:{towgs84:"482.5,-130.6,564.6,-1.042,-0.214,-0.631,8.15"},EPSG_4660:{towgs84:"982.6087,552.753,-540.873,6.681627,-31.611492,-19.848161,16.805"},EPSG_4662:{towgs84:"97.295,-263.247,310.882,-1.5999,0.8386,3.1409,13.3259"},EPSG_3906:{towgs84:"577.88891,165.22205,391.18289,4.9145,-0.94729,-13.05098,7.78664"},EPSG_4307:{towgs84:"-209.3622,-87.8162,404.6198,0.0046,3.4784,0.5805,-1.4547"},EPSG_6892:{towgs84:"-76.269,-16.683,68.562,-6.275,10.536,-4.286,-13.686"},EPSG_4690:{towgs84:"221.597,152.441,176.523,2.403,1.3893,0.884,11.4648"},EPSG_4691:{towgs84:"218.769,150.75,176.75,3.5231,2.0037,1.288,10.9817"},EPSG_4629:{towgs84:"72.51,345.411,79.241,-1.5862,-0.8826,-0.5495,1.3653"},EPSG_4630:{towgs84:"165.804,216.213,180.26,-0.6251,-0.4515,-0.0721,7.4111"},EPSG_4692:{towgs84:"217.109,86.452,23.711,0.0183,-0.0003,0.007,-0.0093"},EPSG_9333:{towgs84:"0,0,0,-0.008393,0.000749,-0.010276,0"},EPSG_9059:{towgs84:"0,0,0"},EPSG_4312:{towgs84:"601.705,84.263,485.227,4.7354,1.3145,5.393,-2.3887"},EPSG_4123:{towgs84:"-96.062,-82.428,-121.753,4.801,0.345,-1.376,1.496"},EPSG_4309:{towgs84:"-124.45,183.74,44.64,-0.4384,0.5446,-0.9706,-2.1365"},ESRI_104106:{towgs84:"-283.088,-70.693,117.445,-1.157,0.059,-0.652,-4.058"},EPSG_4281:{towgs84:"-219.247,-73.802,269.529"},EPSG_4322:{towgs84:"0,0,4.5"},EPSG_4324:{towgs84:"0,0,1.9"},EPSG_4284:{towgs84:"43.822,-108.842,-119.585,1.455,-0.761,0.737,0.549"},EPSG_4277:{towgs84:"446.448,-125.157,542.06,0.15,0.247,0.842,-20.489"},EPSG_4207:{towgs84:"-282.1,-72.2,120,-1.529,0.145,-0.89,-4.46"},EPSG_4688:{towgs84:"347.175,1077.618,2623.677,33.9058,-70.6776,9.4013,186.0647"},EPSG_4689:{towgs84:"410.793,54.542,80.501,-2.5596,-2.3517,-0.6594,17.3218"},EPSG_4720:{towgs84:"0,0,4.5"},EPSG_4273:{towgs84:"278.3,93,474.5,7.889,0.05,-6.61,6.21"},EPSG_4240:{towgs84:"204.64,834.74,293.8"},EPSG_4817:{towgs84:"278.3,93,474.5,7.889,0.05,-6.61,6.21"},ESRI_104131:{towgs84:"426.62,142.62,460.09,4.98,4.49,-12.42,-17.1"},EPSG_4265:{towgs84:"-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68"},EPSG_4263:{towgs84:"-111.92,-87.85,114.5,1.875,0.202,0.219,0.032"},EPSG_4298:{towgs84:"-689.5937,623.84046,-65.93566,-0.02331,1.17094,-0.80054,5.88536"},EPSG_4270:{towgs84:"-253.4392,-148.452,386.5267,0.15605,0.43,-0.1013,-0.0424"},EPSG_4229:{towgs84:"-121.8,98.1,-10.7"},EPSG_4220:{towgs84:"-55.5,-348,-229.2"},EPSG_4214:{towgs84:"12.646,-155.176,-80.863"},EPSG_4232:{towgs84:"-345,3,223"},EPSG_4238:{towgs84:"-1.977,-13.06,-9.993,0.364,0.254,0.689,-1.037"},EPSG_4168:{towgs84:"-170,33,326"},EPSG_4131:{towgs84:"199,931,318.9"},EPSG_4152:{towgs84:"-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0"},EPSG_5228:{towgs84:"572.213,85.334,461.94,4.9732,1.529,5.2484,3.5378"},EPSG_8351:{towgs84:"485.021,169.465,483.839,7.786342,4.397554,4.102655,0"},EPSG_4683:{towgs84:"-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06"},EPSG_4133:{towgs84:"0,0,0"},EPSG_7373:{towgs84:"0.819,-0.5762,-1.6446,-0.00378,-0.03317,0.00318,0.0693"},EPSG_9075:{towgs84:"-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0"},EPSG_9072:{towgs84:"-0.9102,2.0141,0.5602,0.029039,0.010065,0.010101,0"},EPSG_9294:{towgs84:"1.16835,-1.42001,-2.24431,-0.00822,-0.05508,0.01818,0.23388"},EPSG_4212:{towgs84:"-267.434,173.496,181.814,-13.4704,8.7154,7.3926,14.7492"},EPSG_4191:{towgs84:"-44.183,-0.58,-38.489,2.3867,2.7072,-3.5196,-8.2703"},EPSG_4237:{towgs84:"52.684,-71.194,-13.975,-0.312,-0.1063,-0.3729,1.0191"},EPSG_4740:{towgs84:"-1.08,-0.27,-0.9"},EPSG_4124:{towgs84:"419.3836,99.3335,591.3451,0.850389,1.817277,-7.862238,-0.99496"},EPSG_5681:{towgs84:"584.9636,107.7175,413.8067,1.1155,0.2824,-3.1384,7.9922"},EPSG_4141:{towgs84:"23.772,17.49,17.859,-0.3132,-1.85274,1.67299,-5.4262"},EPSG_4204:{towgs84:"-85.645,-273.077,-79.708,2.289,-1.421,2.532,3.194"},EPSG_4319:{towgs84:"226.702,-193.337,-35.371,-2.229,-4.391,9.238,0.9798"},EPSG_4200:{towgs84:"24.82,-131.21,-82.66"},EPSG_4130:{towgs84:"0,0,0"},EPSG_4127:{towgs84:"-82.875,-57.097,-156.768,-2.158,1.524,-0.982,-0.359"},EPSG_4149:{towgs84:"674.374,15.056,405.346"},EPSG_4617:{towgs84:"-0.991,1.9072,0.5129,0.02579,0.00965,0.01166,0"},EPSG_4663:{towgs84:"-210.502,-66.902,-48.476,2.094,-15.067,-5.817,0.485"},EPSG_4664:{towgs84:"-211.939,137.626,58.3,-0.089,0.251,0.079,0.384"},EPSG_4665:{towgs84:"-105.854,165.589,-38.312,-0.003,-0.026,0.024,-0.048"},EPSG_4666:{towgs84:"631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43"},EPSG_4756:{towgs84:"-192.873,-39.382,-111.202,-0.00205,-0.0005,0.00335,0.0188"},EPSG_4723:{towgs84:"-179.483,-69.379,-27.584,-7.862,8.163,6.042,-13.925"},EPSG_4726:{towgs84:"8.853,-52.644,180.304,-0.393,-2.323,2.96,-24.081"},EPSG_4267:{towgs84:"-8.0,160.0,176.0"},EPSG_5365:{towgs84:"-0.16959,0.35312,0.51846,0.03385,-0.16325,0.03446,0.03693"},EPSG_4218:{towgs84:"304.5,306.5,-318.1"},EPSG_4242:{towgs84:"-33.722,153.789,94.959,-8.581,-4.478,4.54,8.95"},EPSG_4216:{towgs84:"-292.295,248.758,429.447,4.9971,2.99,6.6906,1.0289"},ESRI_104105:{towgs84:"631.392,-66.551,481.442,1.09,-4.445,-4.487,-4.43"},ESRI_104129:{towgs84:"0,0,0"},EPSG_4673:{towgs84:"174.05,-25.49,112.57"},EPSG_4202:{towgs84:"-124,-60,154"},EPSG_4203:{towgs84:"-117.763,-51.51,139.061,0.292,0.443,0.277,-0.191"},EPSG_3819:{towgs84:"595.48,121.69,515.35,4.115,-2.9383,0.853,-3.408"},EPSG_8694:{towgs84:"-93.799,-132.737,-219.073,-1.844,0.648,-6.37,-0.169"},EPSG_4145:{towgs84:"275.57,676.78,229.6"},EPSG_4283:{towgs84:"0.06155,-0.01087,-0.04019,0.039492,0.032722,0.032898,-0.009994"},EPSG_4317:{towgs84:"2.3287,-147.0425,-92.0802,-0.309248,0.324822,0.497299,5.689063"},EPSG_4272:{towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993"},EPSG_4248:{towgs84:"-307.7,265.3,-363.5"},EPSG_5561:{towgs84:"24,-121,-76"},EPSG_5233:{towgs84:"-0.293,766.95,87.713,0.195704,1.695068,3.473016,-0.039338"},ESRI_104130:{towgs84:"-86,-98,-119"},ESRI_104102:{towgs84:"682,-203,480"},ESRI_37207:{towgs84:"7,-10,-26"},EPSG_4675:{towgs84:"59.935,118.4,-10.871"},ESRI_104109:{towgs84:"-89.121,-348.182,260.871"},ESRI_104112:{towgs84:"-185.583,-230.096,281.361"},ESRI_104113:{towgs84:"25.1,-275.6,222.6"},IGNF_WGS72G:{towgs84:"0,12,6"},IGNF_NTFG:{towgs84:"-168,-60,320"},IGNF_EFATE57G:{towgs84:"-127,-769,472"},IGNF_PGP50G:{towgs84:"324.8,153.6,172.1"},IGNF_REUN47G:{towgs84:"94,-948,-1262"},IGNF_CSG67G:{towgs84:"-186,230,110"},IGNF_GUAD48G:{towgs84:"-467,-16,-300"},IGNF_TAHI51G:{towgs84:"162,117,154"},IGNF_TAHAAG:{towgs84:"65,342,77"},IGNF_NUKU72G:{towgs84:"84,274,65"},IGNF_PETRELS72G:{towgs84:"365,194,166"},IGNF_WALL78G:{towgs84:"253,-133,-127"},IGNF_MAYO50G:{towgs84:"-382,-59,-262"},IGNF_TANNAG:{towgs84:"-139,-967,436"},IGNF_IGN72G:{towgs84:"-13,-348,292"},IGNF_ATIGG:{towgs84:"1118,23,66"},IGNF_FANGA84G:{towgs84:"150.57,158.33,118.32"},IGNF_RUSAT84G:{towgs84:"202.13,174.6,-15.74"},IGNF_KAUE70G:{towgs84:"126.74,300.1,-75.49"},IGNF_MOP90G:{towgs84:"-10.8,-1.8,12.77"},IGNF_MHPF67G:{towgs84:"338.08,212.58,-296.17"},IGNF_TAHI79G:{towgs84:"160.61,116.05,153.69"},IGNF_ANAA92G:{towgs84:"1.5,3.84,4.81"},IGNF_MARQUI72G:{towgs84:"330.91,-13.92,58.56"},IGNF_APAT86G:{towgs84:"143.6,197.82,74.05"},IGNF_TUBU69G:{towgs84:"237.17,171.61,-77.84"},IGNF_STPM50G:{towgs84:"11.363,424.148,373.13"},EPSG_4150:{towgs84:"674.374,15.056,405.346"},EPSG_4754:{towgs84:"-208.4058,-109.8777,-2.5764"},ESRI_104101:{towgs84:"372.87,149.23,585.29"},EPSG_4693:{towgs84:"0,-0.15,0.68"},EPSG_6207:{towgs84:"293.17,726.18,245.36"},EPSG_4153:{towgs84:"-133.63,-157.5,-158.62"},EPSG_4132:{towgs84:"-241.54,-163.64,396.06"},EPSG_4221:{towgs84:"-154.5,150.7,100.4"},EPSG_4266:{towgs84:"-80.7,-132.5,41.1"},EPSG_4193:{towgs84:"-70.9,-151.8,-41.4"},EPSG_5340:{towgs84:"-0.41,0.46,-0.35"},EPSG_4246:{towgs84:"-294.7,-200.1,525.5"},EPSG_4318:{towgs84:"-3.2,-5.7,2.8"},EPSG_4121:{towgs84:"-199.87,74.79,246.62"},EPSG_4223:{towgs84:"-260.1,5.5,432.2"},EPSG_4158:{towgs84:"-0.465,372.095,171.736"},EPSG_4285:{towgs84:"-128.16,-282.42,21.93"},EPSG_4613:{towgs84:"-404.78,685.68,45.47"},EPSG_4607:{towgs84:"195.671,332.517,274.607"},EPSG_4475:{towgs84:"-381.788,-57.501,-256.673"},EPSG_4208:{towgs84:"-157.84,308.54,-146.6"},EPSG_4743:{towgs84:"70.995,-335.916,262.898"},EPSG_4710:{towgs84:"-323.65,551.39,-491.22"},EPSG_7881:{towgs84:"-0.077,0.079,0.086"},EPSG_4682:{towgs84:"283.729,735.942,261.143"},EPSG_4739:{towgs84:"-156,-271,-189"},EPSG_4679:{towgs84:"-80.01,253.26,291.19"},EPSG_4750:{towgs84:"-56.263,16.136,-22.856"},EPSG_4644:{towgs84:"-10.18,-350.43,291.37"},EPSG_4695:{towgs84:"-103.746,-9.614,-255.95"},EPSG_4292:{towgs84:"-355,21,72"},EPSG_4302:{towgs84:"-61.702,284.488,472.052"},EPSG_4143:{towgs84:"-124.76,53,466.79"},EPSG_4606:{towgs84:"-153,153,307"},EPSG_4699:{towgs84:"-770.1,158.4,-498.2"},EPSG_4247:{towgs84:"-273.5,110.6,-357.9"},EPSG_4160:{towgs84:"8.88,184.86,106.69"},EPSG_4161:{towgs84:"-233.43,6.65,173.64"},EPSG_9251:{towgs84:"-9.5,122.9,138.2"},EPSG_9253:{towgs84:"-78.1,101.6,133.3"},EPSG_4297:{towgs84:"-198.383,-240.517,-107.909"},EPSG_4269:{towgs84:"0,0,0"},EPSG_4301:{towgs84:"-147,506,687"},EPSG_4618:{towgs84:"-59,-11,-52"},EPSG_4612:{towgs84:"0,0,0"},EPSG_4678:{towgs84:"44.585,-131.212,-39.544"},EPSG_4250:{towgs84:"-130,29,364"},EPSG_4144:{towgs84:"214,804,268"},EPSG_4147:{towgs84:"-17.51,-108.32,-62.39"},EPSG_4259:{towgs84:"-254.1,-5.36,-100.29"},EPSG_4164:{towgs84:"-76,-138,67"},EPSG_4211:{towgs84:"-378.873,676.002,-46.255"},EPSG_4182:{towgs84:"-422.651,-172.995,84.02"},EPSG_4224:{towgs84:"-143.87,243.37,-33.52"},EPSG_4225:{towgs84:"-205.57,168.77,-4.12"},EPSG_5527:{towgs84:"-67.35,3.88,-38.22"},EPSG_4752:{towgs84:"98,390,-22"},EPSG_4310:{towgs84:"-30,190,89"},EPSG_9248:{towgs84:"-192.26,65.72,132.08"},EPSG_4680:{towgs84:"124.5,-63.5,-281"},EPSG_4701:{towgs84:"-79.9,-158,-168.9"},EPSG_4706:{towgs84:"-146.21,112.63,4.05"},EPSG_4805:{towgs84:"682,-203,480"},EPSG_4201:{towgs84:"-165,-11,206"},EPSG_4210:{towgs84:"-157,-2,-299"},EPSG_4183:{towgs84:"-104,167,-38"},EPSG_4139:{towgs84:"11,72,-101"},EPSG_4668:{towgs84:"-86,-98,-119"},EPSG_4717:{towgs84:"-2,151,181"},EPSG_4732:{towgs84:"102,52,-38"},EPSG_4280:{towgs84:"-377,681,-50"},EPSG_4209:{towgs84:"-138,-105,-289"},EPSG_4261:{towgs84:"31,146,47"},EPSG_4658:{towgs84:"-73,46,-86"},EPSG_4721:{towgs84:"265.025,384.929,-194.046"},EPSG_4222:{towgs84:"-136,-108,-292"},EPSG_4601:{towgs84:"-255,-15,71"},EPSG_4602:{towgs84:"725,685,536"},EPSG_4603:{towgs84:"72,213.7,93"},EPSG_4605:{towgs84:"9,183,236"},EPSG_4621:{towgs84:"137,248,-430"},EPSG_4657:{towgs84:"-28,199,5"},EPSG_4316:{towgs84:"103.25,-100.4,-307.19"},EPSG_4642:{towgs84:"-13,-348,292"},EPSG_4698:{towgs84:"145,-187,103"},EPSG_4192:{towgs84:"-206.1,-174.7,-87.7"},EPSG_4311:{towgs84:"-265,120,-358"},EPSG_4135:{towgs84:"58,-283,-182"},ESRI_104138:{towgs84:"198,-226,-347"},EPSG_4245:{towgs84:"-11,851,5"},EPSG_4142:{towgs84:"-125,53,467"},EPSG_4213:{towgs84:"-106,-87,188"},EPSG_4253:{towgs84:"-133,-77,-51"},EPSG_4129:{towgs84:"-132,-110,-335"},EPSG_4713:{towgs84:"-77,-128,142"},EPSG_4239:{towgs84:"217,823,299"},EPSG_4146:{towgs84:"295,736,257"},EPSG_4155:{towgs84:"-83,37,124"},EPSG_4165:{towgs84:"-173,253,27"},EPSG_4672:{towgs84:"175,-38,113"},EPSG_4236:{towgs84:"-637,-549,-203"},EPSG_4251:{towgs84:"-90,40,88"},EPSG_4271:{towgs84:"-2,374,172"},EPSG_4175:{towgs84:"-88,4,101"},EPSG_4716:{towgs84:"298,-304,-375"},EPSG_4315:{towgs84:"-23,259,-9"},EPSG_4744:{towgs84:"-242.2,-144.9,370.3"},EPSG_4244:{towgs84:"-97,787,86"},EPSG_4293:{towgs84:"616,97,-251"},EPSG_4714:{towgs84:"-127,-769,472"},EPSG_4736:{towgs84:"260,12,-147"},EPSG_6883:{towgs84:"-235,-110,393"},EPSG_6894:{towgs84:"-63,176,185"},EPSG_4205:{towgs84:"-43,-163,45"},EPSG_4256:{towgs84:"41,-220,-134"},EPSG_4262:{towgs84:"639,405,60"},EPSG_4604:{towgs84:"174,359,365"},EPSG_4169:{towgs84:"-115,118,426"},EPSG_4620:{towgs84:"-106,-129,165"},EPSG_4184:{towgs84:"-203,141,53"},EPSG_4616:{towgs84:"-289,-124,60"},EPSG_9403:{towgs84:"-307,-92,127"},EPSG_4684:{towgs84:"-133,-321,50"},EPSG_4708:{towgs84:"-491,-22,435"},EPSG_4707:{towgs84:"114,-116,-333"},EPSG_4709:{towgs84:"145,75,-272"},EPSG_4712:{towgs84:"-205,107,53"},EPSG_4711:{towgs84:"124,-234,-25"},EPSG_4718:{towgs84:"230,-199,-752"},EPSG_4719:{towgs84:"211,147,111"},EPSG_4724:{towgs84:"208,-435,-229"},EPSG_4725:{towgs84:"189,-79,-202"},EPSG_4735:{towgs84:"647,1777,-1124"},EPSG_4722:{towgs84:"-794,119,-298"},EPSG_4728:{towgs84:"-307,-92,127"},EPSG_4734:{towgs84:"-632,438,-609"},EPSG_4727:{towgs84:"912,-58,1227"},EPSG_4729:{towgs84:"185,165,42"},EPSG_4730:{towgs84:"170,42,84"},EPSG_4733:{towgs84:"276,-57,149"},ESRI_37218:{towgs84:"230,-199,-752"},ESRI_37240:{towgs84:"-7,215,225"},ESRI_37221:{towgs84:"252,-209,-751"},ESRI_4305:{towgs84:"-123,-206,219"},ESRI_104139:{towgs84:"-73,-247,227"},EPSG_4748:{towgs84:"51,391,-36"},EPSG_4219:{towgs84:"-384,664,-48"},EPSG_4255:{towgs84:"-333,-222,114"},EPSG_4257:{towgs84:"-587.8,519.75,145.76"},EPSG_4646:{towgs84:"-963,510,-359"},EPSG_6881:{towgs84:"-24,-203,268"},EPSG_6882:{towgs84:"-183,-15,273"},EPSG_4715:{towgs84:"-104,-129,239"},IGNF_RGF93GDD:{towgs84:"0,0,0"},IGNF_RGM04GDD:{towgs84:"0,0,0"},IGNF_RGSPM06GDD:{towgs84:"0,0,0"},IGNF_RGTAAF07GDD:{towgs84:"0,0,0"},IGNF_RGFG95GDD:{towgs84:"0,0,0"},IGNF_RGNCG:{towgs84:"0,0,0"},IGNF_RGPFGDD:{towgs84:"0,0,0"},IGNF_ETRS89G:{towgs84:"0,0,0"},IGNF_RGR92GDD:{towgs84:"0,0,0"},EPSG_4173:{towgs84:"0,0,0"},EPSG_4180:{towgs84:"0,0,0"},EPSG_4619:{towgs84:"0,0,0"},EPSG_4667:{towgs84:"0,0,0"},EPSG_4075:{towgs84:"0,0,0"},EPSG_6706:{towgs84:"0,0,0"},EPSG_7798:{towgs84:"0,0,0"},EPSG_4661:{towgs84:"0,0,0"},EPSG_4669:{towgs84:"0,0,0"},EPSG_8685:{towgs84:"0,0,0"},EPSG_4151:{towgs84:"0,0,0"},EPSG_9702:{towgs84:"0,0,0"},EPSG_4758:{towgs84:"0,0,0"},EPSG_4761:{towgs84:"0,0,0"},EPSG_4765:{towgs84:"0,0,0"},EPSG_8997:{towgs84:"0,0,0"},EPSG_4023:{towgs84:"0,0,0"},EPSG_4670:{towgs84:"0,0,0"},EPSG_4694:{towgs84:"0,0,0"},EPSG_4148:{towgs84:"0,0,0"},EPSG_4163:{towgs84:"0,0,0"},EPSG_4167:{towgs84:"0,0,0"},EPSG_4189:{towgs84:"0,0,0"},EPSG_4190:{towgs84:"0,0,0"},EPSG_4176:{towgs84:"0,0,0"},EPSG_4659:{towgs84:"0,0,0"},EPSG_3824:{towgs84:"0,0,0"},EPSG_3889:{towgs84:"0,0,0"},EPSG_4046:{towgs84:"0,0,0"},EPSG_4081:{towgs84:"0,0,0"},EPSG_4558:{towgs84:"0,0,0"},EPSG_4483:{towgs84:"0,0,0"},EPSG_5013:{towgs84:"0,0,0"},EPSG_5264:{towgs84:"0,0,0"},EPSG_5324:{towgs84:"0,0,0"},EPSG_5354:{towgs84:"0,0,0"},EPSG_5371:{towgs84:"0,0,0"},EPSG_5373:{towgs84:"0,0,0"},EPSG_5381:{towgs84:"0,0,0"},EPSG_5393:{towgs84:"0,0,0"},EPSG_5489:{towgs84:"0,0,0"},EPSG_5593:{towgs84:"0,0,0"},EPSG_6135:{towgs84:"0,0,0"},EPSG_6365:{towgs84:"0,0,0"},EPSG_5246:{towgs84:"0,0,0"},EPSG_7886:{towgs84:"0,0,0"},EPSG_8431:{towgs84:"0,0,0"},EPSG_8427:{towgs84:"0,0,0"},EPSG_8699:{towgs84:"0,0,0"},EPSG_8818:{towgs84:"0,0,0"},EPSG_4757:{towgs84:"0,0,0"},EPSG_9140:{towgs84:"0,0,0"},EPSG_8086:{towgs84:"0,0,0"},EPSG_4686:{towgs84:"0,0,0"},EPSG_4737:{towgs84:"0,0,0"},EPSG_4702:{towgs84:"0,0,0"},EPSG_4747:{towgs84:"0,0,0"},EPSG_4749:{towgs84:"0,0,0"},EPSG_4674:{towgs84:"0,0,0"},EPSG_4755:{towgs84:"0,0,0"},EPSG_4759:{towgs84:"0,0,0"},EPSG_4762:{towgs84:"0,0,0"},EPSG_4763:{towgs84:"0,0,0"},EPSG_4764:{towgs84:"0,0,0"},EPSG_4166:{towgs84:"0,0,0"},EPSG_4170:{towgs84:"0,0,0"},EPSG_5546:{towgs84:"0,0,0"},EPSG_7844:{towgs84:"0,0,0"},EPSG_4818:{towgs84:"589,76,480"},EPSG_10328:{towgs84:"0,0,0"},EPSG_9782:{towgs84:"0,0,0"},EPSG_9777:{towgs84:"0,0,0"},EPSG_10690:{towgs84:"0,0,0"},EPSG_10639:{towgs84:"0,0,0"},EPSG_10739:{towgs84:"0,0,0"},EPSG_7686:{towgs84:"0,0,0"},EPSG_8900:{towgs84:"0,0,0"},EPSG_5886:{towgs84:"0,0,0"},EPSG_7683:{towgs84:"0,0,0"},EPSG_6668:{towgs84:"0,0,0"},EPSG_20046:{towgs84:"0,0,0"},EPSG_10299:{towgs84:"0,0,0"},EPSG_10310:{towgs84:"0,0,0"},EPSG_10475:{towgs84:"0,0,0"},EPSG_4742:{towgs84:"0,0,0"},EPSG_10671:{towgs84:"0,0,0"},EPSG_10762:{towgs84:"0,0,0"},EPSG_10725:{towgs84:"0,0,0"},EPSG_10791:{towgs84:"0,0,0"},EPSG_10800:{towgs84:"0,0,0"},EPSG_10305:{towgs84:"0,0,0"},EPSG_10941:{towgs84:"0,0,0"},EPSG_10968:{towgs84:"0,0,0"},EPSG_10875:{towgs84:"0,0,0"},EPSG_6318:{towgs84:"0,0,0"},EPSG_10910:{towgs84:"0,0,0"}};for(Ic in Qs)$s=Qs[Ic],$s.datumName&&(Qs[$s.datumName]=$s);var $s,Ic,Oc=Qs;function B1(e,t,r,s,i,n,o){var a={};return a.datum_type=xr,t&&(a.datum_type=rc,a.datum_params=t.map(parseFloat),(a.datum_params[0]!==0||a.datum_params[1]!==0||a.datum_params[2]!==0)&&(a.datum_type=It),a.datum_params.length>3&&(a.datum_params[3]!==0||a.datum_params[4]!==0||a.datum_params[5]!==0||a.datum_params[6]!==0)&&(a.datum_type=Ot,a.datum_params[3]*=fe,a.datum_params[4]*=fe,a.datum_params[5]*=fe,a.datum_params[6]=a.datum_params[6]/1e6+1)),o&&(a.datum_type=Yt,a.grids=o),a.a=r,a.b=s,a.es=i,a.ep2=n,a}var Nc=B1;var $n={};function Qn(e,t,r){return t instanceof ArrayBuffer?D1(e,t,r):{ready:F1(e,t)}}function D1(e,t,r){var s=!0;r!==void 0&&r.includeErrorFields===!1&&(s=!1);var i=new DataView(t),n=V1(i),o=k1(i,n),a=j1(i,o,n,s),h={header:o,subgrids:a};return $n[e]=h,h}async function F1(e,t){for(var r=[],s=await t.getImageCount(),i=s-1;i>=0;i--){var n=await t.getImage(i),o=await n.readRasters(),a=o,h=[n.getWidth(),n.getHeight()],c=n.getBoundingBox().map(Lc),l=typeof n.fileDirectory.getValue=="function"?n.fileDirectory.getValue("ModelPixelScale"):n.fileDirectory.ModelPixelScale,u=[l[0],l[1]].map(Lc),f=c[0]+(h[0]-1)*u[0],d=c[3]-(h[1]-1)*u[1],m=a[0],g=a[1],p=[];for(let S=h[1]-1;S>=0;S--)for(let v=h[0]-1;v>=0;v--){var M=S*h[0]+v;p.push([-oe(g[M]),oe(m[M])])}r.push({del:u,lim:h,ll:[-f,d],cvs:p})}var x={header:{nSubgrids:s},subgrids:r};return $n[e]=x,x}function Gc(e){if(e===void 0)return null;var t=e.split(",");return t.map(U1)}function U1(e){if(e.length===0)return null;var t=e[0]==="@";return t&&(e=e.slice(1)),e==="null"?{name:"null",mandatory:!t,grid:null,isNull:!0}:{name:e,mandatory:!t,grid:$n[e]||null,isNull:!1}}function Lc(e){return e*Math.PI/180}function oe(e){return e/3600*Math.PI/180}function V1(e){var t=e.getInt32(8,!1);return t===11?!1:(t=e.getInt32(8,!0),t!==11&&console.warn("Failed to detect nadgrid endian-ness, defaulting to little-endian"),!0)}function k1(e,t){return{nFields:e.getInt32(8,t),nSubgridFields:e.getInt32(24,t),nSubgrids:e.getInt32(40,t),shiftType:Zn(e,56,64).trim(),fromSemiMajorAxis:e.getFloat64(120,t),fromSemiMinorAxis:e.getFloat64(136,t),toSemiMajorAxis:e.getFloat64(152,t),toSemiMinorAxis:e.getFloat64(168,t)}}function Zn(e,t,r){return String.fromCharCode.apply(null,new Uint8Array(e.buffer.slice(t,r)))}function j1(e,t,r,s){for(var i=176,n=[],o=0;o<t.nSubgrids;o++){var a=H1(e,i,r),h=Y1(e,i,a,r,s),c=Math.round(1+(a.upperLongitude-a.lowerLongitude)/a.longitudeInterval),l=Math.round(1+(a.upperLatitude-a.lowerLatitude)/a.latitudeInterval);n.push({ll:[oe(a.lowerLongitude),oe(a.lowerLatitude)],del:[oe(a.longitudeInterval),oe(a.latitudeInterval)],lim:[c,l],count:a.gridNodeCount,cvs:W1(h)});var u=16;s===!1&&(u=8),i+=176+a.gridNodeCount*u}return n}function W1(e){return e.map(function(t){return[oe(t.longitudeShift),oe(t.latitudeShift)]})}function H1(e,t,r){return{name:Zn(e,t+8,t+16).trim(),parent:Zn(e,t+24,t+24+8).trim(),lowerLatitude:e.getFloat64(t+72,r),upperLatitude:e.getFloat64(t+88,r),lowerLongitude:e.getFloat64(t+104,r),upperLongitude:e.getFloat64(t+120,r),latitudeInterval:e.getFloat64(t+136,r),longitudeInterval:e.getFloat64(t+152,r),gridNodeCount:e.getInt32(t+168,r)}}function Y1(e,t,r,s,i){var n=t+176,o=16;i===!1&&(o=8);for(var a=[],h=0;h<r.gridNodeCount;h++){var c={latitudeShift:e.getFloat32(n+h*o,s),longitudeShift:e.getFloat32(n+h*o+4,s)};i!==!1&&(c.latitudeAccuracy=e.getFloat32(n+h*o+8,s),c.longitudeAccuracy=e.getFloat32(n+h*o+12,s)),a.push(c)}return a}function Ge(e,t){if(!(this instanceof Ge))return new Ge(e);this.forward=null,this.inverse=null,this.init=null,this.name,this.axis,this.names=null,this.title,t=t||function(c){if(c)throw c};var r=Ec(e);if(typeof r!="object"){t("Could not parse to valid json: "+e);return}var s=Ge.projections.get(r.projName);if(!s){t("Could not get projection name from: "+e);return}if(r.datumCode&&r.datumCode!=="none"){var i=yt(Oc,r.datumCode);i&&(r.datum_params=r.datum_params||(i.towgs84?i.towgs84.split(","):null),r.ellps=i.ellipse,r.datumName=i.datumName?i.datumName:r.datumCode)}r.k0=r.k0||1,r.axis=r.axis||"enu",r.ellps=r.ellps||"wgs84",r.lat1=r.lat1||r.lat0;var n=Ac(r.a,r.b,r.rf,r.ellps,r.sphere),o=Cc(n.a,n.b,n.rf,r.R_A),a=Gc(r.nadgrids),h=r.datum||Nc(r.datumCode,r.datum_params,n.a,n.b,o.es,o.ep2,a);jn(this,r),jn(this,s),this.a=n.a,this.b=n.b,this.rf=n.rf,this.sphere=n.sphere,this.es=o.es,this.e=o.e,this.ep2=o.ep2,this.datum=h,"init"in this&&typeof this.init=="function"&&this.init(),t(null,this)}Ge.projections=Rc;Ge.projections.start();var Nt=Ge;function zc(e,t){return e.datum_type!==t.datum_type||e.a!==t.a||Math.abs(e.es-t.es)>5e-11?!1:e.datum_type===It?e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]:e.datum_type===Ot?e.datum_params[0]===t.datum_params[0]&&e.datum_params[1]===t.datum_params[1]&&e.datum_params[2]===t.datum_params[2]&&e.datum_params[3]===t.datum_params[3]&&e.datum_params[4]===t.datum_params[4]&&e.datum_params[5]===t.datum_params[5]&&e.datum_params[6]===t.datum_params[6]:!0}function Xs(e,t,r){var s=e.x,i=e.y,n=e.z?e.z:0,o,a,h,c;if(i<-y&&i>-1.001*y)i=-y;else if(i>y&&i<1.001*y)i=y;else{if(i<-y)return{x:-1/0,y:-1/0,z:e.z};if(i>y)return{x:1/0,y:1/0,z:e.z}}return s>Math.PI&&(s-=2*Math.PI),a=Math.sin(i),c=Math.cos(i),h=a*a,o=r/Math.sqrt(1-t*h),{x:(o+n)*c*Math.cos(s),y:(o+n)*c*Math.sin(s),z:(o*(1-t)+n)*a}}function Ks(e,t,r,s){var i=1e-12,n=i*i,o=30,a,h,c,l,u,f,d,m,g,p,M,x,S,v=e.x,w=e.y,P=e.z?e.z:0,R,C,A;if(a=Math.sqrt(v*v+w*w),h=Math.sqrt(v*v+w*w+P*P),a/r<i){if(R=0,h/r<i)return C=y,A=-s,{x:e.x,y:e.y,z:e.z}}else R=Math.atan2(w,v);c=P/h,l=a/h,u=1/Math.sqrt(1-t*(2-t)*l*l),m=l*(1-t)*u,g=c*u,S=0;do S++,d=r/Math.sqrt(1-t*g*g),A=a*m+P*g-d*(1-t*g*g),f=t*d/(d+A),u=1/Math.sqrt(1-f*(2-f)*l*l),p=l*(1-f)*u,M=c*u,x=M*m-p*g,m=p,g=M;while(x*x>n&&S<o);return C=Math.atan(M/Math.abs(p)),{x:R,y:C,z:A}}function qc(e,t,r){if(t===It)return{x:e.x+r[0],y:e.y+r[1],z:e.z+r[2]};if(t===Ot){var s=r[0],i=r[1],n=r[2],o=r[3],a=r[4],h=r[5],c=r[6];return{x:c*(e.x-h*e.y+a*e.z)+s,y:c*(h*e.x+e.y-o*e.z)+i,z:c*(-a*e.x+o*e.y+e.z)+n}}}function Bc(e,t,r){if(t===It)return{x:e.x-r[0],y:e.y-r[1],z:e.z-r[2]};if(t===Ot){var s=r[0],i=r[1],n=r[2],o=r[3],a=r[4],h=r[5],c=r[6],l=(e.x-s)/c,u=(e.y-i)/c,f=(e.z-n)/c;return{x:l+h*u-a*f,y:-h*l+u+o*f,z:a*l-o*u+f}}}function Js(e){return e===It||e===Ot}function Uc(e,t,r){if(zc(e,t)||e.datum_type===xr||t.datum_type===xr)return r;var s=e.a,i=e.es;if(e.datum_type===Yt){var n=Dc(e,!1,r);if(n!==0)return;s=Dn,i=Fn}var o=t.a,a=t.b,h=t.es;if(t.datum_type===Yt&&(o=Dn,a=sc,h=Fn),i===h&&s===o&&!Js(e.datum_type)&&!Js(t.datum_type))return r;if(r=Xs(r,i,s),Js(e.datum_type)&&(r=qc(r,e.datum_type,e.datum_params)),Js(t.datum_type)&&(r=Bc(r,t.datum_type,t.datum_params)),r=Ks(r,h,o,a),t.datum_type===Yt){var c=Dc(t,!0,r);if(c!==0)return}return r}function Dc(e,t,r){if(e.grids===null||e.grids.length===0)return console.log("Grid shift grids not found"),-1;var s={x:-r.x,y:r.y},i={x:Number.NaN,y:Number.NaN},n=[];t:for(var o=0;o<e.grids.length;o++){var a=e.grids[o];if(n.push(a.name),a.isNull){i=s;break}if(a.grid===null){if(a.mandatory)return console.log("Unable to find mandatory grid '"+a.name+"'"),-1;continue}for(var h=a.grid.subgrids,c=0,l=h.length;c<l;c++){var u=h[c],f=(Math.abs(u.del[1])+Math.abs(u.del[0]))/1e4,d=u.ll[0]-f,m=u.ll[1]-f,g=u.ll[0]+(u.lim[0]-1)*u.del[0]+f,p=u.ll[1]+(u.lim[1]-1)*u.del[1]+f;if(!(m>s.y||d>s.x||p<s.y||g<s.x)&&(i=Z1(s,t,u),!isNaN(i.x)))break t}}return isNaN(i.x)?(console.log("Failed to find a grid shift table for location '"+-s.x*X+" "+s.y*X+" tried: '"+n+"'"),-1):(r.x=-i.x,r.y=i.y,0)}function Z1(e,t,r){var s={x:Number.NaN,y:Number.NaN};if(isNaN(e.x))return s;var i={x:e.x,y:e.y};i.x-=r.ll[0],i.y-=r.ll[1],i.x=E(i.x-Math.PI)+Math.PI;var n=Fc(i,r);if(t){if(isNaN(n.x))return s;n.x=i.x-n.x,n.y=i.y-n.y;var o=9,a=1e-12,h,c;do{if(c=Fc(n,r),isNaN(c.x)){console.log("Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.");break}h={x:i.x-(c.x+n.x),y:i.y-(c.y+n.y)},n.x+=h.x,n.y+=h.y}while(o--&&Math.abs(h.x)>a&&Math.abs(h.y)>a);if(o<0)return console.log("Inverse grid shift iterator failed to converge."),s;s.x=E(n.x+r.ll[0]),s.y=n.y+r.ll[1]}else isNaN(n.x)||(s.x=e.x+n.x,s.y=e.y+n.y);return s}function Fc(e,t){var r={x:e.x/t.del[0],y:e.y/t.del[1]},s={x:Math.floor(r.x),y:Math.floor(r.y)},i={x:r.x-1*s.x,y:r.y-1*s.y},n={x:Number.NaN,y:Number.NaN},o;if(s.x<0||s.x>=t.lim[0]||s.y<0||s.y>=t.lim[1])return n;o=s.y*t.lim[0]+s.x;var a={x:t.cvs[o][0],y:t.cvs[o][1]};o++;var h={x:t.cvs[o][0],y:t.cvs[o][1]};o+=t.lim[0];var c={x:t.cvs[o][0],y:t.cvs[o][1]};o--;var l={x:t.cvs[o][0],y:t.cvs[o][1]},u=i.x*i.y,f=i.x*(1-i.y),d=(1-i.x)*(1-i.y),m=(1-i.x)*i.y;return n.x=d*a.x+f*h.x+m*l.x+u*c.x,n.y=d*a.y+f*h.y+m*l.y+u*c.y,n}var pe=["x","y","z"];function Vc(e,t){let r={};for(let s=0,i=e.axis.length;s<i;s++){if(s===2&&t.z===void 0)continue;let n=t[pe[s]];switch(e.axis[s]){case"e":r.x=n;break;case"w":r.x=-n;break;case"n":r.y=n;break;case"s":r.y=-n;break;case"u":r.z=n;break;case"d":r.z=-n;break;default:return null}}return r}function kc(e,t){let r={};for(let s=0,i=e.axis.length;s<i;s++)if(!(s===2&&t.z===void 0))switch(e.axis[s]){case"e":r[pe[s]]=t.x;break;case"w":r[pe[s]]=-t.x;break;case"n":r[pe[s]]=t.y;break;case"s":r[pe[s]]=-t.y;break;case"u":r[pe[s]]=t.z;break;case"d":r[pe[s]]=-t.z;break;default:return null}return r}function ze(e){var t={x:e[0],y:e[1]};return e.length>2&&(t.z=e[2]),e.length>3&&(t.m=e[3]),t}function Wc(e){jc(e.x),jc(e.y)}function jc(e){if(typeof Number.isFinite=="function"){if(Number.isFinite(e))return;throw new TypeError("coordinates must be finite numbers")}if(typeof e!="number"||e!==e||!isFinite(e))throw new TypeError("coordinates must be finite numbers")}function $1(e,t){return(e.datum.datum_type===It||e.datum.datum_type===Ot||e.datum.datum_type===Yt)&&t.datumCode!=="WGS84"||(t.datum.datum_type===It||t.datum.datum_type===Ot||t.datum.datum_type===Yt)&&e.datumCode!=="WGS84"}function Er(e,t,r,s){var i,n=r.z!==void 0;if(Wc(r),e.datum&&t.datum&&$1(e,t)&&(i=new Nt("WGS84"),r=Er(e,i,r,s),e=i),s&&e.axis!=="enu"&&(r=Vc(e,r)),e.projName==="longlat")r={x:r.x*V,y:r.y*V,z:r.z||0};else if(e.to_meter&&(r={x:r.x*e.to_meter,y:r.y*e.to_meter,z:r.z||0}),r=e.inverse(r),!r)return;if(e.from_greenwich&&(r.x+=e.from_greenwich),r=Uc(e.datum,t.datum,r),!!r)return r=r,t.from_greenwich&&(r={x:r.x-t.from_greenwich,y:r.y,z:r.z||0}),t.projName==="longlat"?r={x:r.x*X,y:r.y*X,z:r.z||0}:(r=t.forward(r),t.to_meter&&(r={x:r.x/t.to_meter,y:r.y/t.to_meter,z:r.z||0})),s&&t.axis!=="enu"?kc(t,r):(r&&!n&&t.projName!=="geocent"&&delete r.z,r)}function Xn(e,t,r,s){var i;return Array.isArray(r)?i=ze(r):i={x:r.x,y:r.y,z:r.z,m:r.m},Er(e,t,i,s)}var Hc=Nt("WGS84");function Kn(e,t,r,s){var i,n,o;return Array.isArray(r)?(i=Er(e,t,ze(r),s)||{x:NaN,y:NaN},r.length>2?(n=typeof e.name<"u"&&e.name==="geocent"||typeof t.name<"u"&&t.name==="geocent",n?typeof i.z=="number"?[i.x,i.y,i.z].concat(r.slice(3)):[i.x,i.y,r[2]].concat(r.slice(3)):s&&typeof i.z=="number"?[i.x,i.y,i.z].concat(r.slice(3)):[i.x,i.y].concat(r.slice(2))):[i.x,i.y]):(i=Er(e,t,{x:r.x,y:r.y,z:r.z,m:r.m},s)||{x:NaN,y:NaN},o=Object.keys(r),o.length===2||(n=typeof e.name<"u"&&e.name==="geocent"||typeof t.name<"u"&&t.name==="geocent",o.forEach(function(a){a==="x"||a==="y"||a==="z"&&(n||s)||(i[a]=r[a])})),i)}function ti(e){return e instanceof Nt?e:typeof e=="object"&&"oProj"in e?e.oProj:Nt(e)}function Q1(e,t,r){var s,i,n=!1,o;return typeof t>"u"?(i=ti(e),s=Hc,n=!0):(typeof t.x<"u"||Array.isArray(t))&&(r=t,i=ti(e),s=Hc,n=!0),s||(s=ti(e)),i||(i=ti(t)),r?Kn(s,i,r):(o={forward:function(a,h){return Kn(s,i,a,h)},inverse:function(a,h){return Kn(i,s,a,h)}},n&&(o.oProj=i),o)}var Yc=Q1;var Zc=6,Qc="AJSAJS",Xc="AFAFAF",qe=65,dt=73,Rt=79,wr=86,Tr=90,Kc={forward:to,inverse:X1,toPoint:eo};function to(e,t){return t=t||5,tp(K1({lat:e[1],lon:e[0]}),t)}function X1(e){var t=ro(tl(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat,t.lon,t.lat]:[t.left,t.bottom,t.right,t.top]}function eo(e){var t=ro(tl(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}function Jn(e){return e*(Math.PI/180)}function $c(e){return 180*(e/Math.PI)}function K1(e){var t=e.lat,r=e.lon,s=6378137,i=.00669438,n=.9996,o,a,h,c,l,u,f,d=Jn(t),m=Jn(r),g,p;p=Math.floor((r+180)/6)+1,r===180&&(p=60),t>=56&&t<64&&r>=3&&r<12&&(p=32),t>=72&&t<84&&(r>=0&&r<9?p=31:r>=9&&r<21?p=33:r>=21&&r<33?p=35:r>=33&&r<42&&(p=37)),o=(p-1)*6-180+3,g=Jn(o),a=i/(1-i),h=s/Math.sqrt(1-i*Math.sin(d)*Math.sin(d)),c=Math.tan(d)*Math.tan(d),l=a*Math.cos(d)*Math.cos(d),u=Math.cos(d)*(m-g),f=s*((1-i/4-3*i*i/64-5*i*i*i/256)*d-(3*i/8+3*i*i/32+45*i*i*i/1024)*Math.sin(2*d)+(15*i*i/256+45*i*i*i/1024)*Math.sin(4*d)-35*i*i*i/3072*Math.sin(6*d));var M=n*h*(u+(1-c+l)*u*u*u/6+(5-18*c+c*c+72*l-58*a)*u*u*u*u*u/120)+5e5,x=n*(f+h*Math.tan(d)*(u*u/2+(5-c+9*l+4*l*l)*u*u*u*u/24+(61-58*c+c*c+600*l-330*a)*u*u*u*u*u*u/720));return t<0&&(x+=1e7),{northing:Math.round(x),easting:Math.round(M),zoneNumber:p,zoneLetter:J1(t)}}function ro(e){var t=e.northing,r=e.easting,s=e.zoneLetter,i=e.zoneNumber;if(i<0||i>60)return null;var n=.9996,o=6378137,a=.00669438,h,c=(1-Math.sqrt(1-a))/(1+Math.sqrt(1-a)),l,u,f,d,m,g,p,M,x,S=r-5e5,v=t;s<"N"&&(v-=1e7),p=(i-1)*6-180+3,h=a/(1-a),g=v/n,M=g/(o*(1-a/4-3*a*a/64-5*a*a*a/256)),x=M+(3*c/2-27*c*c*c/32)*Math.sin(2*M)+(21*c*c/16-55*c*c*c*c/32)*Math.sin(4*M)+151*c*c*c/96*Math.sin(6*M),l=o/Math.sqrt(1-a*Math.sin(x)*Math.sin(x)),u=Math.tan(x)*Math.tan(x),f=h*Math.cos(x)*Math.cos(x),d=o*(1-a)/Math.pow(1-a*Math.sin(x)*Math.sin(x),1.5),m=S/(l*n);var w=x-l*Math.tan(x)/d*(m*m/2-(5+3*u+10*f-4*f*f-9*h)*m*m*m*m/24+(61+90*u+298*f+45*u*u-252*h-3*f*f)*m*m*m*m*m*m/720);w=$c(w);var P=(m-(1+2*u+f)*m*m*m/6+(5-2*f+28*u-3*f*f+8*h+24*u*u)*m*m*m*m*m/120)/Math.cos(x);P=p+$c(P);var R;if(e.accuracy){var C=ro({northing:e.northing+e.accuracy,easting:e.easting+e.accuracy,zoneLetter:e.zoneLetter,zoneNumber:e.zoneNumber});R={top:C.lat,right:C.lon,bottom:w,left:P}}else R={lat:w,lon:P};return R}function J1(e){var t="Z";return 84>=e&&e>=72?t="X":72>e&&e>=64?t="W":64>e&&e>=56?t="V":56>e&&e>=48?t="U":48>e&&e>=40?t="T":40>e&&e>=32?t="S":32>e&&e>=24?t="R":24>e&&e>=16?t="Q":16>e&&e>=8?t="P":8>e&&e>=0?t="N":0>e&&e>=-8?t="M":-8>e&&e>=-16?t="L":-16>e&&e>=-24?t="K":-24>e&&e>=-32?t="J":-32>e&&e>=-40?t="H":-40>e&&e>=-48?t="G":-48>e&&e>=-56?t="F":-56>e&&e>=-64?t="E":-64>e&&e>=-72?t="D":-72>e&&e>=-80&&(t="C"),t}function tp(e,t){var r="00000"+e.easting,s="00000"+e.northing;return e.zoneNumber+e.zoneLetter+ep(e.easting,e.northing,e.zoneNumber)+r.substr(r.length-5,t)+s.substr(s.length-5,t)}function ep(e,t,r){var s=Jc(r),i=Math.floor(e/1e5),n=Math.floor(t/1e5)%20;return rp(i,n,s)}function Jc(e){var t=e%Zc;return t===0&&(t=Zc),t}function rp(e,t,r){var s=r-1,i=Qc.charCodeAt(s),n=Xc.charCodeAt(s),o=i+e-1,a=n+t,h=!1;o>Tr&&(o=o-Tr+qe-1,h=!0),(o===dt||i<dt&&o>dt||(o>dt||i<dt)&&h)&&o++,(o===Rt||i<Rt&&o>Rt||(o>Rt||i<Rt)&&h)&&(o++,o===dt&&o++),o>Tr&&(o=o-Tr+qe-1),a>wr?(a=a-wr+qe-1,h=!0):h=!1,(a===dt||n<dt&&a>dt||(a>dt||n<dt)&&h)&&a++,(a===Rt||n<Rt&&a>Rt||(a>Rt||n<Rt)&&h)&&(a++,a===dt&&a++),a>wr&&(a=a-wr+qe-1);var c=String.fromCharCode(o)+String.fromCharCode(a);return c}function tl(e){if(e&&e.length===0)throw"MGRSPoint coverting from nothing";for(var t=e.length,r=null,s="",i,n=0;!/[A-Z]/.test(i=e.charAt(n));){if(n>=2)throw"MGRSPoint bad conversion from: "+e;s+=i,n++}var o=parseInt(s,10);if(n===0||n+3>t)throw"MGRSPoint bad conversion from: "+e;var a=e.charAt(n++);if(a<="A"||a==="B"||a==="Y"||a>="Z"||a==="I"||a==="O")throw"MGRSPoint zone letter "+a+" not handled: "+e;r=e.substring(n,n+=2);for(var h=Jc(o),c=sp(r.charAt(0),h),l=ip(r.charAt(1),h);l<np(a);)l+=2e6;var u=t-n;if(u%2!==0)throw`MGRSPoint has to have an even number
|
|
8
|
+
of digits after the zone letter and two 100km letters - front
|
|
9
|
+
half for easting meters, second half for
|
|
10
|
+
northing meters`+e;var f=u/2,d=0,m=0,g,p,M,x,S;return f>0&&(g=1e5/Math.pow(10,f),p=e.substring(n,n+f),d=parseFloat(p)*g,M=e.substring(n+f),m=parseFloat(M)*g),x=d+c,S=m+l,{easting:x,northing:S,zoneLetter:a,zoneNumber:o,accuracy:g}}function sp(e,t){for(var r=Qc.charCodeAt(t-1),s=1e5,i=!1;r!==e.charCodeAt(0);){if(r++,r===dt&&r++,r===Rt&&r++,r>Tr){if(i)throw"Bad character: "+e;r=qe,i=!0}s+=1e5}return s}function ip(e,t){if(e>"V")throw"MGRSPoint given invalid Northing "+e;for(var r=Xc.charCodeAt(t-1),s=0,i=!1;r!==e.charCodeAt(0);){if(r++,r===dt&&r++,r===Rt&&r++,r>wr){if(i)throw"Bad character: "+e;r=qe,i=!0}s+=1e5}return s}function np(e){var t;switch(e){case"C":t=11e5;break;case"D":t=2e6;break;case"E":t=28e5;break;case"F":t=37e5;break;case"G":t=46e5;break;case"H":t=55e5;break;case"J":t=64e5;break;case"K":t=73e5;break;case"L":t=82e5;break;case"M":t=91e5;break;case"N":t=0;break;case"P":t=8e5;break;case"Q":t=17e5;break;case"R":t=26e5;break;case"S":t=35e5;break;case"T":t=44e5;break;case"U":t=53e5;break;case"V":t=62e5;break;case"W":t=7e6;break;case"X":t=79e5;break;default:t=-1}if(t>=0)return t;throw"Invalid zone letter: "+e}function Be(e,t,r){if(!(this instanceof Be))return new Be(e,t,r);if(Array.isArray(e))this.x=e[0],this.y=e[1],this.z=e[2]||0;else if(typeof e=="object")this.x=e.x,this.y=e.y,this.z=e.z||0;else if(typeof e=="string"&&typeof t>"u"){var s=e.split(",");this.x=parseFloat(s[0]),this.y=parseFloat(s[1]),this.z=parseFloat(s[2])||0}else this.x=e,this.y=t,this.z=r||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}Be.fromMGRS=function(e){return new Be(eo(e))};Be.prototype.toMGRS=function(e){return to([this.x,this.y],e)};var el=Be;var op=1,ap=.25,rl=.046875,sl=.01953125,il=.01068115234375,hp=.75,cp=.46875,lp=.013020833333333334,up=.007120768229166667,fp=.3645833333333333,mp=.005696614583333333,dp=.3076171875;function De(e){var t=[];t[0]=op-e*(ap+e*(rl+e*(sl+e*il))),t[1]=e*(hp-e*(rl+e*(sl+e*il)));var r=e*e;return t[2]=r*(cp-e*(lp+e*up)),r*=e,t[3]=r*(fp-e*mp),t[4]=r*e*dp,t}function Ft(e,t,r,s){return r*=t,t*=t,s[0]*e-r*(s[1]+t*(s[2]+t*(s[3]+t*s[4])))}var pp=20;function Fe(e,t,r){for(var s=1/(1-t),i=e,n=pp;n;--n){var o=Math.sin(i),a=1-t*o*o;if(a=(Ft(i,o,Math.cos(i),r)-e)*(a*Math.sqrt(a))*s,i-=a,Math.abs(a)<T)return i}return i}function gp(){this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.es&&(this.en=De(this.es),this.ml0=Ft(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function _p(e){var t=e.x,r=e.y,s=E(t-this.long0,this.over),i,n,o,a=Math.sin(r),h=Math.cos(r);if(this.es){var l=h*s,u=Math.pow(l,2),f=this.ep2*Math.pow(h,2),d=Math.pow(f,2),m=Math.abs(h)>T?Math.tan(r):0,g=Math.pow(m,2),p=Math.pow(g,2);i=1-this.es*Math.pow(a,2),l=l/Math.sqrt(i);var M=Ft(r,a,h,this.en);n=this.a*(this.k0*l*(1+u/6*(1-g+f+u/20*(5-18*g+p+14*f-58*g*f+u/42*(61+179*p-p*g-479*g)))))+this.x0,o=this.a*(this.k0*(M-this.ml0+a*s*l/2*(1+u/12*(5-g+9*f+4*d+u/30*(61+p-58*g+270*f-330*g*f+u/56*(1385+543*p-p*g-3111*g))))))+this.y0}else{var c=h*Math.sin(s);if(Math.abs(Math.abs(c)-1)<T)return 93;if(n=.5*this.a*this.k0*Math.log((1+c)/(1-c))+this.x0,o=h*Math.cos(s)/Math.sqrt(1-Math.pow(c,2)),c=Math.abs(o),c>=1){if(c-1>T)return 93;o=0}else o=Math.acos(o);r<0&&(o=-o),o=this.a*this.k0*(o-this.lat0)+this.y0}return e.x=n,e.y=o,e}function Mp(e){var t,r,s,i,n=(e.x-this.x0)*(1/this.a),o=(e.y-this.y0)*(1/this.a);if(this.es)if(t=this.ml0+o/this.k0,r=Fe(t,this.es,this.en),Math.abs(r)<y){var u=Math.sin(r),f=Math.cos(r),d=Math.abs(f)>T?Math.tan(r):0,m=this.ep2*Math.pow(f,2),g=Math.pow(m,2),p=Math.pow(d,2),M=Math.pow(p,2);t=1-this.es*Math.pow(u,2);var x=n*Math.sqrt(t)/this.k0,S=Math.pow(x,2);t=t*d,s=r-t*S/(1-this.es)*.5*(1-S/12*(5+3*p-9*m*p+m-4*g-S/30*(61+90*p-252*m*p+45*M+46*m-S/56*(1385+3633*p+4095*M+1574*M*p)))),i=E(this.long0+x*(1-S/6*(1+2*p+m-S/20*(5+28*p+24*M+8*m*p+6*m-S/42*(61+662*p+1320*M+720*M*p))))/f,this.over)}else s=y*Dt(o),i=0;else{var a=Math.exp(n/this.k0),h=.5*(a-1/a),c=this.lat0+o/this.k0,l=Math.cos(c);t=Math.sqrt((1-Math.pow(l,2))/(1+Math.pow(h,2))),s=Math.asin(t),o<0&&(s=-s),h===0&&l===0?i=0:i=E(Math.atan2(h,l)+this.long0,this.over)}return e.x=i,e.y=s,e}var xp=["Fast_Transverse_Mercator","Fast Transverse Mercator"],Ue={init:gp,forward:_p,inverse:Mp,names:xp};function ei(e){var t=Math.exp(e);return t=(t-1/t)/2,t}function Q(e,t){e=Math.abs(e),t=Math.abs(t);var r=Math.max(e,t),s=Math.min(e,t)/(r||1);return r*Math.sqrt(1+Math.pow(s,2))}function nl(e){var t=1+e,r=t-1;return r===0?e:e*Math.log(t)/r}function ol(e){var t=Math.abs(e);return t=nl(t*(1+t/(Q(1,t)+1))),e<0?-t:t}function ri(e,t){for(var r=2*Math.cos(2*t),s=e.length-1,i=e[s],n=0,o;--s>=0;)o=-n+r*i+e[s],n=i,i=o;return t+o*Math.sin(2*t)}function al(e,t){for(var r=2*Math.cos(t),s=e.length-1,i=e[s],n=0,o;--s>=0;)o=-n+r*i+e[s],n=i,i=o;return Math.sin(t)*o}function hl(e){var t=Math.exp(e);return t=(t+1/t)/2,t}function so(e,t,r){for(var s=Math.sin(t),i=Math.cos(t),n=ei(r),o=hl(r),a=2*i*o,h=-2*s*n,c=e.length-1,l=e[c],u=0,f=0,d=0,m,g;--c>=0;)m=f,g=u,f=l,u=d,l=-m+a*f-h*u+e[c],d=-g+h*f+a*u;return a=s*o,h=i*n,[a*l-h*d,a*d+h*l]}function yp(){if(!this.approx&&(isNaN(this.es)||this.es<=0))throw new Error('Incorrect elliptical usage. Try using the +approx option in the proj string, or PROJECTION["Fast_Transverse_Mercator"] in the WKT.');this.approx&&(Ue.init.apply(this),this.forward=Ue.forward,this.inverse=Ue.inverse),this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var e=this.es/(1+Math.sqrt(1-this.es)),t=e/(2-e),r=t;this.cgb[0]=t*(2+t*(-2/3+t*(-2+t*(116/45+t*(26/45+t*(-2854/675)))))),this.cbg[0]=t*(-2+t*(2/3+t*(4/3+t*(-82/45+t*(32/45+t*(4642/4725)))))),r=r*t,this.cgb[1]=r*(7/3+t*(-8/5+t*(-227/45+t*(2704/315+t*(2323/945))))),this.cbg[1]=r*(5/3+t*(-16/15+t*(-13/9+t*(904/315+t*(-1522/945))))),r=r*t,this.cgb[2]=r*(56/15+t*(-136/35+t*(-1262/105+t*(73814/2835)))),this.cbg[2]=r*(-26/15+t*(34/21+t*(8/5+t*(-12686/2835)))),r=r*t,this.cgb[3]=r*(4279/630+t*(-332/35+t*(-399572/14175))),this.cbg[3]=r*(1237/630+t*(-12/5+t*(-24832/14175))),r=r*t,this.cgb[4]=r*(4174/315+t*(-144838/6237)),this.cbg[4]=r*(-734/315+t*(109598/31185)),r=r*t,this.cgb[5]=r*(601676/22275),this.cbg[5]=r*(444337/155925),r=Math.pow(t,2),this.Qn=this.k0/(1+t)*(1+r*(1/4+r*(1/64+r/256))),this.utg[0]=t*(-.5+t*(2/3+t*(-37/96+t*(1/360+t*(81/512+t*(-96199/604800)))))),this.gtu[0]=t*(.5+t*(-2/3+t*(5/16+t*(41/180+t*(-127/288+t*(7891/37800)))))),this.utg[1]=r*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+t*(1118711/3870720))))),this.gtu[1]=r*(13/48+t*(-3/5+t*(557/1440+t*(281/630+t*(-1983433/1935360))))),r=r*t,this.utg[2]=r*(-17/480+t*(37/840+t*(209/4480+t*(-5569/90720)))),this.gtu[2]=r*(61/240+t*(-103/140+t*(15061/26880+t*(167603/181440)))),r=r*t,this.utg[3]=r*(-4397/161280+t*(11/504+t*(830251/7257600))),this.gtu[3]=r*(49561/161280+t*(-179/168+t*(6601661/7257600))),r=r*t,this.utg[4]=r*(-4583/161280+t*(108847/3991680)),this.gtu[4]=r*(34729/80640+t*(-3418889/1995840)),r=r*t,this.utg[5]=r*(-20648693/638668800),this.gtu[5]=r*(212378941/319334400);var s=ri(this.cbg,this.lat0);this.Zb=-this.Qn*(s+al(this.gtu,2*s))}function Sp(e){var t=E(e.x-this.long0,this.over),r=e.y;r=ri(this.cbg,r);var s=Math.sin(r),i=Math.cos(r),n=Math.sin(t),o=Math.cos(t);r=Math.atan2(s,o*i),t=Math.atan2(n*i,Q(s,i*o)),t=ol(Math.tan(t));var a=so(this.gtu,2*r,2*t);r=r+a[0],t=t+a[1];var h,c;return Math.abs(t)<=2.623395162778?(h=this.a*(this.Qn*t)+this.x0,c=this.a*(this.Qn*r+this.Zb)+this.y0):(h=1/0,c=1/0),e.x=h,e.y=c,e}function vp(e){var t=(e.x-this.x0)*(1/this.a),r=(e.y-this.y0)*(1/this.a);r=(r-this.Zb)/this.Qn,t=t/this.Qn;var s,i;if(Math.abs(t)<=2.623395162778){var n=so(this.utg,2*r,2*t);r=r+n[0],t=t+n[1],t=Math.atan(ei(t));var o=Math.sin(r),a=Math.cos(r),h=Math.sin(t),c=Math.cos(t);r=Math.atan2(o*c,Q(h,c*a)),t=Math.atan2(h,c*a),s=E(t+this.long0,this.over),i=ri(this.cgb,r)}else s=1/0,i=1/0;return e.x=s,e.y=i,e}var Ep=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","Gauss Kruger","Gauss_Kruger","tmerc"],Ve={init:yp,forward:Sp,inverse:vp,names:Ep};function cl(e,t){if(e===void 0){if(e=Math.floor((E(t)+Math.PI)*30/Math.PI)+1,e<0)return 0;if(e>60)return 60}return e}var wp="etmerc";function Tp(){var e=cl(this.zone,this.long0);if(e===void 0)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(e)-183)*V,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,Ve.init.apply(this),this.forward=Ve.forward,this.inverse=Ve.inverse}var Pp=["Universal Transverse Mercator System","utm"],ll={init:Tp,names:Pp,dependsOn:wp};function si(e,t){return Math.pow((1-e)/(1+e),t)}var bp=20;function Rp(){var e=Math.sin(this.lat0),t=Math.cos(this.lat0);t*=t,this.rc=Math.sqrt(1-this.es)/(1-this.es*e*e),this.C=Math.sqrt(1+this.es*t*t/(1-this.es)),this.phic0=Math.asin(e/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+q)/(Math.pow(Math.tan(.5*this.lat0+q),this.C)*si(this.e*e,this.ratexp))}function Cp(e){var t=e.x,r=e.y;return e.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*r+q),this.C)*si(this.e*Math.sin(r),this.ratexp))-y,e.x=this.C*t,e}function Ap(e){for(var t=1e-14,r=e.x/this.C,s=e.y,i=Math.pow(Math.tan(.5*s+q)/this.K,1/this.C),n=bp;n>0&&(s=2*Math.atan(i*si(this.e*Math.sin(e.y),-.5*this.e))-y,!(Math.abs(s-e.y)<t));--n)e.y=s;return n?(e.x=r,e.y=s,e):null}var Ip=["gauss"],ii={init:Rp,forward:Cp,inverse:Ap,names:Ip};function Op(){ii.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))}function Np(e){var t,r,s,i;return e.x=E(e.x-this.long0,this.over),ii.forward.apply(this,[e]),t=Math.sin(e.y),r=Math.cos(e.y),s=Math.cos(e.x),i=this.k0*this.R2/(1+this.sinc0*t+this.cosc0*r*s),e.x=i*r*Math.sin(e.x),e.y=i*(this.cosc0*t-this.sinc0*r*s),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function Lp(e){var t,r,s,i,n;if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,n=Q(e.x,e.y)){var o=2*Math.atan2(n,this.R2);t=Math.sin(o),r=Math.cos(o),i=Math.asin(r*this.sinc0+e.y*t*this.cosc0/n),s=Math.atan2(e.x*t,n*this.cosc0*r-e.y*this.sinc0*t)}else i=this.phic0,s=0;return e.x=s,e.y=i,ii.inverse.apply(this,[e]),e.x=E(e.x+this.long0,this.over),e}var Gp=["Stereographic_North_Pole","Oblique_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],ul={init:Op,forward:Np,inverse:Lp,names:Gp};function io(e,t,r){return t*=r,Math.tan(.5*(y+e))*Math.pow((1-t)/(1+t),.5*r)}function zp(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=T&&(this.k0=.5*(1+Dt(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=T&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=T&&Math.abs(Math.cos(this.lat_ts))>T&&(this.k0=.5*this.cons*at(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/ut(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=at(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(io(this.lat0,this.sinlat0,this.e))-y,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function qp(e){var t=e.x,r=e.y,s=Math.sin(r),i=Math.cos(r),n,o,a,h,c,l,u=E(t-this.long0,this.over);return Math.abs(Math.abs(t-this.long0)-Math.PI)<=T&&Math.abs(r+this.lat0)<=T?(e.x=NaN,e.y=NaN,e):this.sphere?(n=2*this.k0/(1+this.sinlat0*s+this.coslat0*i*Math.cos(u)),e.x=this.a*n*i*Math.sin(u)+this.x0,e.y=this.a*n*(this.coslat0*s-this.sinlat0*i*Math.cos(u))+this.y0,e):(o=2*Math.atan(io(r,s,this.e))-y,h=Math.cos(o),a=Math.sin(o),Math.abs(this.coslat0)<=T?(c=ut(this.e,r*this.con,this.con*s),l=2*this.a*this.k0*c/this.cons,e.x=this.x0+l*Math.sin(t-this.long0),e.y=this.y0-this.con*l*Math.cos(t-this.long0),e):(Math.abs(this.sinlat0)<T?(n=2*this.a*this.k0/(1+h*Math.cos(u)),e.y=n*a):(n=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*a+this.cosX0*h*Math.cos(u))),e.y=n*(this.cosX0*a-this.sinX0*h*Math.cos(u))+this.y0),e.x=n*h*Math.sin(u)+this.x0,e))}function Bp(e){e.x-=this.x0,e.y-=this.y0;var t,r,s,i,n,o=Math.sqrt(e.x*e.x+e.y*e.y);if(this.sphere){var a=2*Math.atan(o/(2*this.a*this.k0));return t=this.long0,r=this.lat0,o<=T?(e.x=t,e.y=r,e):(r=Math.asin(Math.cos(a)*this.sinlat0+e.y*Math.sin(a)*this.coslat0/o),Math.abs(this.coslat0)<T?this.lat0>0?t=E(this.long0+Math.atan2(e.x,-1*e.y),this.over):t=E(this.long0+Math.atan2(e.x,e.y),this.over):t=E(this.long0+Math.atan2(e.x*Math.sin(a),o*this.coslat0*Math.cos(a)-e.y*this.sinlat0*Math.sin(a)),this.over),e.x=t,e.y=r,e)}else if(Math.abs(this.coslat0)<=T){if(o<=T)return r=this.lat0,t=this.long0,e.x=t,e.y=r,e;e.x*=this.con,e.y*=this.con,s=o*this.cons/(2*this.a*this.k0),r=this.con*$t(this.e,s),t=this.con*E(this.con*this.long0+Math.atan2(e.x,-1*e.y),this.over)}else i=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),t=this.long0,o<=T?n=this.X0:(n=Math.asin(Math.cos(i)*this.sinX0+e.y*Math.sin(i)*this.cosX0/o),t=E(this.long0+Math.atan2(e.x*Math.sin(i),o*this.cosX0*Math.cos(i)-e.y*this.sinX0*Math.sin(i)),this.over)),r=-1*$t(this.e,Math.tan(.5*(y+n)));return e.x=t,e.y=r,e}var Dp=["stere","Stereographic_South_Pole","Polar_Stereographic_variant_A","Polar_Stereographic_variant_B","Polar_Stereographic"],fl={init:zp,forward:qp,inverse:Bp,names:Dp,ssfn_:io};function Fp(){var e=this.lat0;this.lambda0=this.long0;var t=Math.sin(e),r=this.a,s=this.rf,i=1/s,n=2*i-Math.pow(i,2),o=this.e=Math.sqrt(n);this.R=this.k0*r*Math.sqrt(1-n)/(1-n*Math.pow(t,2)),this.alpha=Math.sqrt(1+n/(1-n)*Math.pow(Math.cos(e),4)),this.b0=Math.asin(t/this.alpha);var a=Math.log(Math.tan(Math.PI/4+this.b0/2)),h=Math.log(Math.tan(Math.PI/4+e/2)),c=Math.log((1+o*t)/(1-o*t));this.K=a-this.alpha*h+this.alpha*o/2*c}function Up(e){var t=Math.log(Math.tan(Math.PI/4-e.y/2)),r=this.e/2*Math.log((1+this.e*Math.sin(e.y))/(1-this.e*Math.sin(e.y))),s=-this.alpha*(t+r)+this.K,i=2*(Math.atan(Math.exp(s))-Math.PI/4),n=this.alpha*(e.x-this.lambda0),o=Math.atan(Math.sin(n)/(Math.sin(this.b0)*Math.tan(i)+Math.cos(this.b0)*Math.cos(n))),a=Math.asin(Math.cos(this.b0)*Math.sin(i)-Math.sin(this.b0)*Math.cos(i)*Math.cos(n));return e.y=this.R/2*Math.log((1+Math.sin(a))/(1-Math.sin(a)))+this.y0,e.x=this.R*o+this.x0,e}function Vp(e){for(var t=e.x-this.x0,r=e.y-this.y0,s=t/this.R,i=2*(Math.atan(Math.exp(r/this.R))-Math.PI/4),n=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(s)),o=Math.atan(Math.sin(s)/(Math.cos(this.b0)*Math.cos(s)-Math.sin(this.b0)*Math.tan(i))),a=this.lambda0+o/this.alpha,h=0,c=n,l=-1e3,u=0;Math.abs(c-l)>1e-7;){if(++u>20)return;h=1/this.alpha*(Math.log(Math.tan(Math.PI/4+n/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(c))/2)),l=c,c=2*Math.atan(Math.exp(h))-Math.PI/2}return e.x=a,e.y=c,e}var kp=["somerc"],ml={init:Fp,forward:Up,inverse:Vp,names:kp};var ke=1e-7;function jp(e){var t=["Hotine_Oblique_Mercator","Hotine_Oblique_Mercator_variant_A","Hotine_Oblique_Mercator_Azimuth_Natural_Origin"],r=typeof e.projName=="object"?Object.keys(e.projName)[0]:e.projName;return"no_uoff"in e||"no_off"in e||t.indexOf(r)!==-1||t.indexOf(Hn(r))!==-1}function Wp(){var e,t,r,s,i,n,o,a,h,c,l=0,u,f=0,d=0,m=0,g=0,p=0,M=0;this.no_off=jp(this),this.no_rot="no_rot"in this;var x=!1;"alpha"in this&&(x=!0);var S=!1;if("rectified_grid_angle"in this&&(S=!0),x&&(M=this.alpha),S&&(l=this.rectified_grid_angle,x||(M=0,x=!0)),x||S)f=this.longc;else if(d=this.long1,g=this.lat1,m=this.long2,p=this.lat2,Math.abs(g-p)<=ke||(e=Math.abs(g))<=ke||Math.abs(e-y)<=ke||Math.abs(Math.abs(this.lat0)-y)<=ke||Math.abs(Math.abs(p)-y)<=ke)throw new Error;var v=1-this.es;t=Math.sqrt(v),Math.abs(this.lat0)>T?(a=Math.sin(this.lat0),r=Math.cos(this.lat0),e=1-this.es*a*a,this.B=r*r,this.B=Math.sqrt(1+this.es*this.B*this.B/v),this.A=this.B*this.k0*t/e,s=this.B*t/(r*Math.sqrt(e)),i=s*s-1,i<=0?i=0:(i=Math.sqrt(i),this.lat0<0&&(i=-i)),this.E=i+=s,this.E*=Math.pow(ut(this.e,this.lat0,a),this.B)):(this.B=1/t,this.A=this.k0,this.E=s=i=1),x||S?(x?(u=Math.asin(Math.sin(M)/s),S||(l=M)):(u=l,M=Math.asin(s*Math.sin(u))),this.lam0=f-Math.asin(.5*(i-1/i)*Math.tan(u))/this.B):(n=Math.pow(ut(this.e,g,Math.sin(g)),this.B),o=Math.pow(ut(this.e,p,Math.sin(p)),this.B),i=this.E/n,h=(o-n)/(o+n),c=this.E*this.E,c=(c-o*n)/(c+o*n),e=d-m,e<-Math.PI?m-=ne:e>Math.PI&&(m+=ne),this.lam0=E(.5*(d+m)-Math.atan(c*Math.tan(.5*this.B*(d-m))/h)/this.B,this.over),u=Math.atan(2*Math.sin(this.B*E(d-this.lam0,this.over))/(i-1/i)),l=M=Math.asin(s*Math.sin(u))),this.singam=Math.sin(u),this.cosgam=Math.cos(u),this.sinrot=Math.sin(l),this.cosrot=Math.cos(l),this.rB=1/this.B,this.ArB=this.A*this.rB,this.BrA=1/this.ArB,this.no_off?this.u_0=0:(this.u_0=Math.abs(this.ArB*Math.atan(Math.sqrt(s*s-1)/Math.cos(M))),this.lat0<0&&(this.u_0=-this.u_0)),i=.5*u,this.v_pole_n=this.ArB*Math.log(Math.tan(q-i)),this.v_pole_s=this.ArB*Math.log(Math.tan(q+i))}function Hp(e){var t={},r,s,i,n,o,a,h,c;if(e.x=e.x-this.lam0,Math.abs(Math.abs(e.y)-y)>T){if(o=this.E/Math.pow(ut(this.e,e.y,Math.sin(e.y)),this.B),a=1/o,r=.5*(o-a),s=.5*(o+a),n=Math.sin(this.B*e.x),i=(r*this.singam-n*this.cosgam)/s,Math.abs(Math.abs(i)-1)<T)throw new Error;c=.5*this.ArB*Math.log((1-i)/(1+i)),a=Math.cos(this.B*e.x),Math.abs(a)<ke?h=this.A*e.x:h=this.ArB*Math.atan2(r*this.cosgam+n*this.singam,a)}else c=e.y>0?this.v_pole_n:this.v_pole_s,h=this.ArB*e.y;return this.no_rot?(t.x=h,t.y=c):(h-=this.u_0,t.x=c*this.cosrot+h*this.sinrot,t.y=h*this.cosrot-c*this.sinrot),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function Yp(e){var t,r,s,i,n,o,a,h={};if(e.x=(e.x-this.x0)*(1/this.a),e.y=(e.y-this.y0)*(1/this.a),this.no_rot?(r=e.y,t=e.x):(r=e.x*this.cosrot-e.y*this.sinrot,t=e.y*this.cosrot+e.x*this.sinrot+this.u_0),s=Math.exp(-this.BrA*r),i=.5*(s-1/s),n=.5*(s+1/s),o=Math.sin(this.BrA*t),a=(o*this.cosgam+i*this.singam)/n,Math.abs(Math.abs(a)-1)<T)h.x=0,h.y=a<0?-y:y;else{if(h.y=this.E/Math.sqrt((1+a)/(1-a)),h.y=$t(this.e,Math.pow(h.y,1/this.B)),h.y===1/0)throw new Error;h.x=-this.rB*Math.atan2(i*this.cosgam-o*this.singam,Math.cos(this.BrA*t))}return h.x+=this.lam0,h}var Zp=["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_variant_A","Hotine_Oblique_Mercator_Variant_B","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Two_Point_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","Oblique_Mercator","omerc"],dl={init:Wp,forward:Hp,inverse:Yp,names:Zp};function $p(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<T)){var e=this.b/this.a;this.e=Math.sqrt(1-e*e);var t=Math.sin(this.lat1),r=Math.cos(this.lat1),s=at(this.e,t,r),i=ut(this.e,this.lat1,t),n=Math.sin(this.lat2),o=Math.cos(this.lat2),a=at(this.e,n,o),h=ut(this.e,this.lat2,n),c=Math.abs(Math.abs(this.lat0)-y)<T?0:ut(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>T?this.ns=Math.log(s/a)/Math.log(i/h):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=s/(this.ns*Math.pow(i,this.ns)),this.rh=this.a*this.f0*Math.pow(c,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function Qp(e){var t=e.x,r=e.y;Math.abs(2*Math.abs(r)-Math.PI)<=T&&(r=Dt(r)*(y-2*T));var s=Math.abs(Math.abs(r)-y),i,n;if(s>T)i=ut(this.e,r,Math.sin(r)),n=this.a*this.f0*Math.pow(i,this.ns);else{if(s=r*this.ns,s<=0)return null;n=0}var o=this.ns*E(t-this.long0,this.over);return e.x=this.k0*(n*Math.sin(o))+this.x0,e.y=this.k0*(this.rh-n*Math.cos(o))+this.y0,e}function Xp(e){var t,r,s,i,n,o=(e.x-this.x0)/this.k0,a=this.rh-(e.y-this.y0)/this.k0;this.ns>0?(t=Math.sqrt(o*o+a*a),r=1):(t=-Math.sqrt(o*o+a*a),r=-1);var h=0;if(t!==0&&(h=Math.atan2(r*o,r*a)),t!==0||this.ns>0){if(r=1/this.ns,s=Math.pow(t/(this.a*this.f0),r),i=$t(this.e,s),i===-9999)return null}else i=-y;return n=E(h/this.ns+this.long0,this.over),e.x=n,e.y=i,e}var Kp=["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_1SP","Lambert_Conformal_Conic_2SP","lcc","Lambert Conic Conformal (1SP)","Lambert Conic Conformal (2SP)"],pl={init:$p,forward:Qp,inverse:Xp,names:Kp};function Jp(){this.a=6377397155e-3,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.7417649320975901-.308341501185665),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq}function tg(e){var t,r,s,i,n,o,a,h=e.x,c=e.y,l=E(h-this.long0,this.over);return t=Math.pow((1+this.e*Math.sin(c))/(1-this.e*Math.sin(c)),this.alfa*this.e/2),r=2*(Math.atan(this.k*Math.pow(Math.tan(c/2+this.s45),this.alfa)/t)-this.s45),s=-l*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(r)+Math.sin(this.ad)*Math.cos(r)*Math.cos(s)),n=Math.asin(Math.cos(r)*Math.sin(s)/Math.cos(i)),o=this.n*n,a=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(i/2+this.s45),this.n),e.y=a*Math.cos(o)/1,e.x=a*Math.sin(o)/1,this.czech||(e.y*=-1,e.x*=-1),e}function eg(e){var t,r,s,i,n,o,a,h,c=e.x;e.x=e.y,e.y=c,this.czech||(e.y*=-1,e.x*=-1),o=Math.sqrt(e.x*e.x+e.y*e.y),n=Math.atan2(e.y,e.x),i=n/Math.sin(this.s0),s=2*(Math.atan(Math.pow(this.ro0/o,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),t=Math.asin(Math.cos(this.ad)*Math.sin(s)-Math.sin(this.ad)*Math.cos(s)*Math.cos(i)),r=Math.asin(Math.cos(s)*Math.sin(i)/Math.cos(t)),e.x=this.long0-r/this.alfa,a=t,h=0;var l=0;do e.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(t/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(a))/(1-this.e*Math.sin(a)),this.e/2))-this.s45),Math.abs(a-e.y)<1e-10&&(h=1),a=e.y,l+=1;while(h===0&&l<15);return l>=15?null:e}var rg=["Krovak","Krovak Modified","Krovak (North Orientated)","Krovak Modified (North Orientated)","krovak"],gl={init:Jp,forward:tg,inverse:eg,names:rg};function K(e,t,r,s,i){return e*i-t*Math.sin(2*i)+r*Math.sin(4*i)-s*Math.sin(6*i)}function Qt(e){return 1-.25*e*(1+e/16*(3+1.25*e))}function Xt(e){return .375*e*(1+.25*e*(1+.46875*e))}function Kt(e){return .05859375*e*e*(1+.75*e)}function Jt(e){return e*e*e*(35/3072)}function Pr(e,t,r){var s=t*r;return e/Math.sqrt(1-s*s)}function pt(e){return Math.abs(e)<y?e:e-Dt(e)*Math.PI}function ge(e,t,r,s,i){var n,o;n=e/t;for(var a=0;a<15;a++)if(o=(e-(t*n-r*Math.sin(2*n)+s*Math.sin(4*n)-i*Math.sin(6*n)))/(t-2*r*Math.cos(2*n)+4*s*Math.cos(4*n)-6*i*Math.cos(6*n)),n+=o,Math.abs(o)<=1e-10)return n;return NaN}function sg(){this.sphere||(this.e0=Qt(this.es),this.e1=Xt(this.es),this.e2=Kt(this.es),this.e3=Jt(this.es),this.ml0=this.a*K(this.e0,this.e1,this.e2,this.e3,this.lat0))}function ig(e){var t,r,s=e.x,i=e.y;if(s=E(s-this.long0,this.over),this.sphere)t=this.a*Math.asin(Math.cos(i)*Math.sin(s)),r=this.a*(Math.atan2(Math.tan(i),Math.cos(s))-this.lat0);else{var n=Math.sin(i),o=Math.cos(i),a=Pr(this.a,this.e,n),h=Math.tan(i)*Math.tan(i),c=s*Math.cos(i),l=c*c,u=this.es*o*o/(1-this.es),f=this.a*K(this.e0,this.e1,this.e2,this.e3,i);t=a*c*(1-l*h*(1/6-(8-h+8*u)*l/120)),r=f-this.ml0+a*n/o*l*(.5+(5-h+6*u)*l/24)}return e.x=t+this.x0,e.y=r+this.y0,e}function ng(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,r=e.y/this.a,s,i;if(this.sphere){var n=r+this.lat0;s=Math.asin(Math.sin(n)*Math.cos(t)),i=Math.atan2(Math.tan(t),Math.cos(n))}else{var o=this.ml0/this.a+r,a=ge(o,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(a)-y)<=T)return e.x=this.long0,e.y=y,r<0&&(e.y*=-1),e;var h=Pr(this.a,this.e,Math.sin(a)),c=h*h*h/this.a/this.a*(1-this.es),l=Math.pow(Math.tan(a),2),u=t*this.a/h,f=u*u;s=a-h*Math.tan(a)/c*u*u*(.5-(1+3*l)*u*u/24),i=u*(1-f*(l/3+(1+3*l)*l*f/15))/Math.cos(a)}return e.x=E(i+this.long0,this.over),e.y=pt(s),e}var og=["Cassini","Cassini_Soldner","cass"],_l={init:sg,forward:ig,inverse:ng,names:og};function gt(e,t){var r;return e>1e-7?(r=e*t,(1-e*e)*(t/(1-r*r)-.5/e*Math.log((1-r)/(1+r)))):2*t}var ag=.3333333333333333,hg=.17222222222222222,cg=.10257936507936508,lg=.06388888888888888,ug=.0664021164021164,fg=.016415012942191543;function br(e){var t,r=[];return r[0]=e*ag,t=e*e,r[0]+=t*hg,r[1]=t*lg,t*=e,r[0]+=t*cg,r[1]+=t*ug,r[2]=t*fg,r}function Rr(e,t){var r=e+e;return e+t[0]*Math.sin(r)+t[1]*Math.sin(r+r)+t[2]*Math.sin(r+r+r)}var no=1,oo=2,ao=3,ni=4;function mg(){var e=Math.abs(this.lat0);if(Math.abs(e-y)<T?this.mode=this.lat0<0?no:oo:Math.abs(e)<T?this.mode=ao:this.mode=ni,this.es>0){var t;switch(this.qp=gt(this.e,1),this.mmf=.5/(1-this.es),this.apa=br(this.es),this.mode){case oo:this.dd=1;break;case no:this.dd=1;break;case ao:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case ni:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=gt(this.e,t)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*t*t)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd;break}}else this.mode===ni&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function dg(e){var t,r,s,i,n,o,a,h,c,l,u=e.x,f=e.y;if(u=E(u-this.long0,this.over),this.sphere){if(n=Math.sin(f),l=Math.cos(f),s=Math.cos(u),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(r=this.mode===this.EQUIT?1+l*s:1+this.sinph0*n+this.cosph0*l*s,r<=T)return null;r=Math.sqrt(2/r),t=r*l*Math.sin(u),r*=this.mode===this.EQUIT?n:this.cosph0*n-this.sinph0*l*s}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(s=-s),Math.abs(f+this.lat0)<T)return null;r=q-f*.5,r=2*(this.mode===this.S_POLE?Math.cos(r):Math.sin(r)),t=r*Math.sin(u),r*=s}}else{switch(a=0,h=0,c=0,s=Math.cos(u),i=Math.sin(u),n=Math.sin(f),o=gt(this.e,n),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(a=o/this.qp,h=Math.sqrt(1-a*a)),this.mode){case this.OBLIQ:c=1+this.sinb1*a+this.cosb1*h*s;break;case this.EQUIT:c=1+h*s;break;case this.N_POLE:c=y+f,o=this.qp-o;break;case this.S_POLE:c=f-y,o=this.qp+o;break}if(Math.abs(c)<T)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:c=Math.sqrt(2/c),this.mode===this.OBLIQ?r=this.ymf*c*(this.cosb1*a-this.sinb1*h*s):r=(c=Math.sqrt(2/(1+h*s)))*a*this.ymf,t=this.xmf*c*h*i;break;case this.N_POLE:case this.S_POLE:o>=0?(t=(c=Math.sqrt(o))*i,r=s*(this.mode===this.S_POLE?c:-c)):t=r=0;break}}return e.x=this.a*t+this.x0,e.y=this.a*r+this.y0,e}function pg(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,r=e.y/this.a,s,i,n,o,a,h,c;if(this.sphere){var l=0,u,f=0;if(u=Math.sqrt(t*t+r*r),i=u*.5,i>1)return null;switch(i=2*Math.asin(i),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(f=Math.sin(i),l=Math.cos(i)),this.mode){case this.EQUIT:i=Math.abs(u)<=T?0:Math.asin(r*f/u),t*=f,r=l*u;break;case this.OBLIQ:i=Math.abs(u)<=T?this.lat0:Math.asin(l*this.sinph0+r*f*this.cosph0/u),t*=f*this.cosph0,r=(l-Math.sin(i)*this.sinph0)*u;break;case this.N_POLE:r=-r,i=y-i;break;case this.S_POLE:i-=y;break}s=r===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(t,r)}else{if(c=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(t/=this.dd,r*=this.dd,h=Math.sqrt(t*t+r*r),h<T)return e.x=this.long0,e.y=this.lat0,e;o=2*Math.asin(.5*h/this.rq),n=Math.cos(o),t*=o=Math.sin(o),this.mode===this.OBLIQ?(c=n*this.sinb1+r*o*this.cosb1/h,a=this.qp*c,r=h*this.cosb1*n-r*this.sinb1*o):(c=r*o/h,a=this.qp*c,r=h*n)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(r=-r),a=t*t+r*r,!a)return e.x=this.long0,e.y=this.lat0,e;c=1-a/this.qp,this.mode===this.S_POLE&&(c=-c)}s=Math.atan2(t,r),i=Rr(Math.asin(c),this.apa)}return e.x=E(this.long0+s,this.over),e.y=i,e}var gg=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],Ml={init:mg,forward:dg,inverse:pg,names:gg,S_POLE:no,N_POLE:oo,EQUIT:ao,OBLIQ:ni};function _t(e){return Math.abs(e)>1&&(e=e>1?1:-1),Math.asin(e)}function _g(){Math.abs(this.lat1+this.lat2)<T||(this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=at(this.e3,this.sin_po,this.cos_po),this.qs1=gt(this.e3,this.sin_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=at(this.e3,this.sin_po,this.cos_po),this.qs2=gt(this.e3,this.sin_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=gt(this.e3,this.sin_po),Math.abs(this.lat1-this.lat2)>T?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)}function Mg(e){var t=e.x,r=e.y;this.sin_phi=Math.sin(r),this.cos_phi=Math.cos(r);var s=gt(this.e3,this.sin_phi),i=this.a*Math.sqrt(this.c-this.ns0*s)/this.ns0,n=this.ns0*E(t-this.long0,this.over),o=i*Math.sin(n)+this.x0,a=this.rh-i*Math.cos(n)+this.y0;return e.x=o,e.y=a,e}function xg(e){var t,r,s,i,n,o;return e.x-=this.x0,e.y=this.rh-e.y+this.y0,this.ns0>=0?(t=Math.sqrt(e.x*e.x+e.y*e.y),s=1):(t=-Math.sqrt(e.x*e.x+e.y*e.y),s=-1),i=0,t!==0&&(i=Math.atan2(s*e.x,s*e.y)),s=t*this.ns0/this.a,this.sphere?o=Math.asin((this.c-s*s)/(2*this.ns0)):(r=(this.c-s*s)/this.ns0,o=this.phi1z(this.e3,r)),n=E(i/this.ns0+this.long0,this.over),e.x=n,e.y=o,e}function yg(e,t){var r,s,i,n,o,a=_t(.5*t);if(e<T)return a;for(var h=e*e,c=1;c<=25;c++)if(r=Math.sin(a),s=Math.cos(a),i=e*r,n=1-i*i,o=.5*n*n/s*(t/(1-h)-r/n+.5/e*Math.log((1-i)/(1+i))),a=a+o,Math.abs(o)<=1e-7)return a;return null}var Sg=["Albers_Conic_Equal_Area","Albers_Equal_Area","Albers","aea"],xl={init:_g,forward:Mg,inverse:xg,names:Sg,phi1z:yg};function vg(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function Eg(e){var t,r,s,i,n,o,a,h,c=e.x,l=e.y;return s=E(c-this.long0,this.over),t=Math.sin(l),r=Math.cos(l),i=Math.cos(s),o=this.sin_p14*t+this.cos_p14*r*i,n=1,o>0||Math.abs(o)<=T?(a=this.x0+this.a*n*r*Math.sin(s)/o,h=this.y0+this.a*n*(this.cos_p14*t-this.sin_p14*r*i)/o):(a=this.x0+this.infinity_dist*r*Math.sin(s),h=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*r*i)),e.x=a,e.y=h,e}function wg(e){var t,r,s,i,n,o;return e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,e.x/=this.k0,e.y/=this.k0,(t=Math.sqrt(e.x*e.x+e.y*e.y))?(i=Math.atan2(t,this.rc),r=Math.sin(i),s=Math.cos(i),o=_t(s*this.sin_p14+e.y*r*this.cos_p14/t),n=Math.atan2(e.x*r,t*this.cos_p14*s-e.y*this.sin_p14*r),n=E(this.long0+n,this.over)):(o=this.phic0,n=0),e.x=n,e.y=o,e}var Tg=["gnom"],yl={init:vg,forward:Eg,inverse:wg,names:Tg};function Sl(e,t){var r=1-(1-e*e)/(2*e)*Math.log((1-e)/(1+e));if(Math.abs(Math.abs(t)-r)<1e-6)return t<0?-1*y:y;for(var s=Math.asin(.5*t),i,n,o,a,h=0;h<30;h++)if(n=Math.sin(s),o=Math.cos(s),a=e*n,i=Math.pow(1-a*a,2)/(2*o)*(t/(1-e*e)-n/(1-a*a)+.5/e*Math.log((1-a)/(1+a))),s+=i,Math.abs(i)<=1e-10)return s;return NaN}function Pg(){this.sphere||(this.k0=at(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function bg(e){var t=e.x,r=e.y,s,i,n=E(t-this.long0,this.over);if(this.sphere)s=this.x0+this.a*n*Math.cos(this.lat_ts),i=this.y0+this.a*Math.sin(r)/Math.cos(this.lat_ts);else{var o=gt(this.e,Math.sin(r));s=this.x0+this.a*this.k0*n,i=this.y0+this.a*o*.5/this.k0}return e.x=s,e.y=i,e}function Rg(e){e.x-=this.x0,e.y-=this.y0;var t,r;return this.sphere?(t=E(this.long0+e.x/this.a/Math.cos(this.lat_ts),this.over),r=Math.asin(e.y/this.a*Math.cos(this.lat_ts))):(r=Sl(this.e,2*e.y*this.k0/this.a),t=E(this.long0+e.x/(this.a*this.k0),this.over)),e.x=t,e.y=r,e}var Cg=["cea"],vl={init:Pg,forward:bg,inverse:Rg,names:Cg};function Ag(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)}function Ig(e){var t=e.x,r=e.y,s=E(t-this.long0,this.over),i=pt(r-this.lat0);return e.x=this.x0+this.a*s*this.rc,e.y=this.y0+this.a*i,e}function Og(e){var t=e.x,r=e.y;return e.x=E(this.long0+(t-this.x0)/(this.a*this.rc),this.over),e.y=pt(this.lat0+(r-this.y0)/this.a),e}var Ng=["Equirectangular","Equidistant_Cylindrical","Equidistant_Cylindrical_Spherical","eqc"],El={init:Ag,forward:Ig,inverse:Og,names:Ng};var wl=20;function Lg(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Qt(this.es),this.e1=Xt(this.es),this.e2=Kt(this.es),this.e3=Jt(this.es),this.ml0=this.a*K(this.e0,this.e1,this.e2,this.e3,this.lat0)}function Gg(e){var t=e.x,r=e.y,s,i,n,o=E(t-this.long0,this.over);if(n=o*Math.sin(r),this.sphere)Math.abs(r)<=T?(s=this.a*o,i=-1*this.a*this.lat0):(s=this.a*Math.sin(n)/Math.tan(r),i=this.a*(pt(r-this.lat0)+(1-Math.cos(n))/Math.tan(r)));else if(Math.abs(r)<=T)s=this.a*o,i=-1*this.ml0;else{var a=Pr(this.a,this.e,Math.sin(r))/Math.tan(r);s=a*Math.sin(n),i=this.a*K(this.e0,this.e1,this.e2,this.e3,r)-this.ml0+a*(1-Math.cos(n))}return e.x=s+this.x0,e.y=i+this.y0,e}function zg(e){var t,r,s,i,n,o,a,h,c;if(s=e.x-this.x0,i=e.y-this.y0,this.sphere)if(Math.abs(i+this.a*this.lat0)<=T)t=E(s/this.a+this.long0,this.over),r=0;else{o=this.lat0+i/this.a,a=s*s/this.a/this.a+o*o,h=o;var l;for(n=wl;n;--n)if(l=Math.tan(h),c=-1*(o*(h*l+1)-h-.5*(h*h+a)*l)/((h-o)/l-1),h+=c,Math.abs(c)<=T){r=h;break}t=E(this.long0+Math.asin(s*Math.tan(h)/this.a)/Math.sin(r),this.over)}else if(Math.abs(i+this.ml0)<=T)r=0,t=E(this.long0+s/this.a,this.over);else{o=(this.ml0+i)/this.a,a=s*s/this.a/this.a+o*o,h=o;var u,f,d,m,g;for(n=wl;n;--n)if(g=this.e*Math.sin(h),u=Math.sqrt(1-g*g)*Math.tan(h),f=this.a*K(this.e0,this.e1,this.e2,this.e3,h),d=this.e0-2*this.e1*Math.cos(2*h)+4*this.e2*Math.cos(4*h)-6*this.e3*Math.cos(6*h),m=f/this.a,c=(o*(u*m+1)-m-.5*u*(m*m+a))/(this.es*Math.sin(2*h)*(m*m+a-2*o*m)/(4*u)+(o-m)*(u*d-2/Math.sin(2*h))-d),h-=c,Math.abs(c)<=T){r=h;break}u=Math.sqrt(1-this.es*Math.pow(Math.sin(r),2))*Math.tan(r),t=E(this.long0+Math.asin(s*u/this.a)/Math.sin(r),this.over)}return e.x=t,e.y=r,e}var qg=["Polyconic","American_Polyconic","poly"],Tl={init:Lg,forward:Gg,inverse:zg,names:qg};function Bg(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013}function Dg(e){var t,r=e.x,s=e.y,i=s-this.lat0,n=r-this.long0,o=i/fe*1e-5,a=n,h=1,c=0;for(t=1;t<=10;t++)h=h*o,c=c+this.A[t]*h;var l=c,u=a,f=1,d=0,m,g,p=0,M=0;for(t=1;t<=6;t++)m=f*l-d*u,g=d*l+f*u,f=m,d=g,p=p+this.B_re[t]*f-this.B_im[t]*d,M=M+this.B_im[t]*f+this.B_re[t]*d;return e.x=M*this.a+this.x0,e.y=p*this.a+this.y0,e}function Fg(e){var t,r=e.x,s=e.y,i=r-this.x0,n=s-this.y0,o=n/this.a,a=i/this.a,h=1,c=0,l,u,f=0,d=0;for(t=1;t<=6;t++)l=h*o-c*a,u=c*o+h*a,h=l,c=u,f=f+this.C_re[t]*h-this.C_im[t]*c,d=d+this.C_im[t]*h+this.C_re[t]*c;for(var m=0;m<this.iterations;m++){var g=f,p=d,M,x,S=o,v=a;for(t=2;t<=6;t++)M=g*f-p*d,x=p*f+g*d,g=M,p=x,S=S+(t-1)*(this.B_re[t]*g-this.B_im[t]*p),v=v+(t-1)*(this.B_im[t]*g+this.B_re[t]*p);g=1,p=0;var w=this.B_re[1],P=this.B_im[1];for(t=2;t<=6;t++)M=g*f-p*d,x=p*f+g*d,g=M,p=x,w=w+t*(this.B_re[t]*g-this.B_im[t]*p),P=P+t*(this.B_im[t]*g+this.B_re[t]*p);var R=w*w+P*P;f=(S*w+v*P)/R,d=(v*w-S*P)/R}var C=f,A=d,b=1,O=0;for(t=1;t<=9;t++)b=b*C,O=O+this.D[t]*b;var N=this.lat0+O*fe*1e5,B=this.long0+A;return e.x=B,e.y=N,e}var Ug=["New_Zealand_Map_Grid","nzmg"],Pl={init:Bg,forward:Dg,inverse:Fg,names:Ug};function Vg(){}function kg(e){var t=e.x,r=e.y,s=E(t-this.long0,this.over),i=this.x0+this.a*s,n=this.y0+this.a*Math.log(Math.tan(Math.PI/4+r/2.5))*1.25;return e.x=i,e.y=n,e}function jg(e){e.x-=this.x0,e.y-=this.y0;var t=E(this.long0+e.x/this.a,this.over),r=2.5*(Math.atan(Math.exp(.8*e.y/this.a))-Math.PI/4);return e.x=t,e.y=r,e}var Wg=["Miller_Cylindrical","mill"],bl={init:Vg,forward:kg,inverse:jg,names:Wg};var Hg=20;function Yg(){this.long0=this.long0||0,this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=De(this.es)}function ho(e){var t,r,s=e.x,i=e.y;if(s=E(s-this.long0,this.over),this.sphere){if(!this.m)i=this.n!==1?Math.asin(this.n*Math.sin(i)):i;else for(var n=this.n*Math.sin(i),o=Hg;o;--o){var a=(this.m*i+Math.sin(i)-n)/(this.m+Math.cos(i));if(i-=a,Math.abs(a)<T)break}t=this.a*this.C_x*s*(this.m+Math.cos(i)),r=this.a*this.C_y*i}else{var h=Math.sin(i),c=Math.cos(i);r=this.a*Ft(i,h,c,this.en),t=this.a*s*c/Math.sqrt(1-this.es*h*h)}return e.x=t,e.y=r,e}function co(e){var t,r,s,i;return e.x-=this.x0,s=e.x/this.a,e.y-=this.y0,t=e.y/this.a,this.sphere?(t/=this.C_y,s=s/(this.C_x*(this.m+Math.cos(t))),this.m?t=_t((this.m*t+Math.sin(t))/this.n):this.n!==1&&(t=_t(Math.sin(t)/this.n)),s=E(s+this.long0,this.over),t=pt(t)):(t=Fe(e.y/this.a,this.es,this.en),i=Math.abs(t),i<y?(i=Math.sin(t),r=this.long0+e.x*Math.sqrt(1-this.es*i*i)/(this.a*Math.cos(t)),s=E(r,this.over)):i-T<y&&(s=this.long0)),e.x=s,e.y=t,e}var Zg=["Sinusoidal","sinu"],Rl={init:Yg,forward:ho,inverse:co,names:Zg};function $g(){this.sphere=!0,this.b=this.a,this.m=1,this.n=2.5707963267948966,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)}var Qg=ho,Xg=co,Kg=["Eckert_VI","eck6"],Cl={init:$g,forward:Qg,inverse:Xg,names:Kg};function Jg(){this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0}function t2(e){for(var t=e.x,r=e.y,s=E(t-this.long0,this.over),i=r,n=Math.PI*Math.sin(r);;){var o=-(i+Math.sin(i)-n)/(1+Math.cos(i));if(i+=o,Math.abs(o)<T)break}i/=2,Math.PI/2-Math.abs(r)<T&&(s=0);var a=.900316316158*this.a*s*Math.cos(i)+this.x0,h=1.4142135623731*this.a*Math.sin(i)+this.y0;return e.x=a,e.y=h,e}function e2(e){var t,r;e.x-=this.x0,e.y-=this.y0,r=e.y/(1.4142135623731*this.a),Math.abs(r)>.999999999999&&(r=.999999999999),t=Math.asin(r);var s=E(this.long0+e.x/(.900316316158*this.a*Math.cos(t)),this.over);s<-Math.PI&&(s=-Math.PI),s>Math.PI&&(s=Math.PI),r=(2*t+Math.sin(2*t))/Math.PI,Math.abs(r)>1&&(r=1);var i=Math.asin(r);return e.x=s,e.y=i,e}var r2=["Mollweide","moll"],Al={init:Jg,forward:t2,inverse:e2,names:r2};function s2(){Math.abs(this.lat1+this.lat2)<T||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Qt(this.es),this.e1=Xt(this.es),this.e2=Kt(this.es),this.e3=Jt(this.es),this.sin_phi=Math.sin(this.lat1),this.cos_phi=Math.cos(this.lat1),this.ms1=at(this.e,this.sin_phi,this.cos_phi),this.ml1=K(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<T?this.ns=this.sin_phi:(this.sin_phi=Math.sin(this.lat2),this.cos_phi=Math.cos(this.lat2),this.ms2=at(this.e,this.sin_phi,this.cos_phi),this.ml2=K(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=K(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))}function i2(e){var t=e.x,r=e.y,s;if(this.sphere)s=this.a*(this.g-r);else{var i=K(this.e0,this.e1,this.e2,this.e3,r);s=this.a*(this.g-i)}var n=this.ns*E(t-this.long0,this.over),o=this.x0+s*Math.sin(n),a=this.y0+this.rh-s*Math.cos(n);return e.x=o,e.y=a,e}function n2(e){e.x-=this.x0,e.y=this.rh-e.y+this.y0;var t,r,s,i;this.ns>=0?(r=Math.sqrt(e.x*e.x+e.y*e.y),t=1):(r=-Math.sqrt(e.x*e.x+e.y*e.y),t=-1);var n=0;if(r!==0&&(n=Math.atan2(t*e.x,t*e.y)),this.sphere)return i=E(this.long0+n/this.ns,this.over),s=pt(this.g-r/this.a),e.x=i,e.y=s,e;var o=this.g-r/this.a;return s=ge(o,this.e0,this.e1,this.e2,this.e3),i=E(this.long0+n/this.ns,this.over),e.x=i,e.y=s,e}var o2=["Equidistant_Conic","eqdc"],Il={init:s2,forward:i2,inverse:n2,names:o2};function a2(){this.R=this.a}function h2(e){var t=e.x,r=e.y,s=E(t-this.long0,this.over),i,n;Math.abs(r)<=T&&(i=this.x0+this.R*s,n=this.y0);var o=_t(2*Math.abs(r/Math.PI));(Math.abs(s)<=T||Math.abs(Math.abs(r)-y)<=T)&&(i=this.x0,r>=0?n=this.y0+Math.PI*this.R*Math.tan(.5*o):n=this.y0+Math.PI*this.R*-Math.tan(.5*o));var a=.5*Math.abs(Math.PI/s-s/Math.PI),h=a*a,c=Math.sin(o),l=Math.cos(o),u=l/(c+l-1),f=u*u,d=u*(2/c-1),m=d*d,g=Math.PI*this.R*(a*(u-m)+Math.sqrt(h*(u-m)*(u-m)-(m+h)*(f-m)))/(m+h);s<0&&(g=-g),i=this.x0+g;var p=h+u;return g=Math.PI*this.R*(d*p-a*Math.sqrt((m+h)*(h+1)-p*p))/(m+h),r>=0?n=this.y0+g:n=this.y0-g,e.x=i,e.y=n,e}function c2(e){var t,r,s,i,n,o,a,h,c,l,u,f,d;return e.x-=this.x0,e.y-=this.y0,u=Math.PI*this.R,s=e.x/u,i=e.y/u,n=s*s+i*i,o=-Math.abs(i)*(1+n),a=o-2*i*i+s*s,h=-2*o+1+2*i*i+n*n,d=i*i/h+(2*a*a*a/h/h/h-9*o*a/h/h)/27,c=(o-a*a/3/h)/h,l=2*Math.sqrt(-c/3),u=3*d/c/l,Math.abs(u)>1&&(u>=0?u=1:u=-1),f=Math.acos(u)/3,e.y>=0?r=(-l*Math.cos(f+Math.PI/3)-a/3/h)*Math.PI:r=-(-l*Math.cos(f+Math.PI/3)-a/3/h)*Math.PI,Math.abs(s)<T?t=this.long0:t=E(this.long0+Math.PI*(n-1+Math.sqrt(1+2*(s*s-i*i)+n*n))/2/s,this.over),e.x=t,e.y=r,e}var l2=["Van_der_Grinten_I","VanDerGrinten","Van_der_Grinten","vandg"],Ol={init:a2,forward:h2,inverse:c2,names:l2};function Nl(e,t,r,s,i,n){let o=s-t,a=Math.atan((1-n)*Math.tan(e)),h=Math.atan((1-n)*Math.tan(r)),c=Math.sin(a),l=Math.cos(a),u=Math.sin(h),f=Math.cos(h),d=o,m,g=100,p,M,x,S,v,w,P,R,C,A,b,O,N,B;do{if(p=Math.sin(d),M=Math.cos(d),x=Math.sqrt(f*p*(f*p)+(l*u-c*f*M)*(l*u-c*f*M)),x===0)return{azi1:0,s12:0};S=c*u+l*f*M,v=Math.atan2(x,S),w=l*f*p/x,P=1-w*w,R=P!==0?S-2*c*u/P:0,C=n/16*P*(4+n*(4-3*P)),m=d,d=o+(1-C)*n*w*(v+C*x*(R+C*S*(-1+2*R*R)))}while(Math.abs(d-m)>1e-12&&--g>0);return g===0?{azi1:NaN,s12:NaN}:(A=P*(i*i-i*(1-n)*(i*(1-n)))/(i*(1-n)*(i*(1-n))),b=1+A/16384*(4096+A*(-768+A*(320-175*A))),O=A/1024*(256+A*(-128+A*(74-47*A))),N=O*x*(R+O/4*(S*(-1+2*R*R)-O/6*R*(-3+4*x*x)*(-3+4*R*R))),B=i*(1-n)*b*(v-N),{azi1:Math.atan2(f*p,l*u-c*f*M),s12:B})}function Ll(e,t,r,s,i,n){let o=Math.atan((1-n)*Math.tan(e)),a=Math.sin(o),h=Math.cos(o),c=Math.sin(r),l=Math.cos(r),u=Math.atan2(a,h*l),f=h*c,d=1-f*f,m=d*(i*i-i*(1-n)*(i*(1-n)))/(i*(1-n)*(i*(1-n))),g=1+m/16384*(4096+m*(-768+m*(320-175*m))),p=m/1024*(256+m*(-128+m*(74-47*m))),M=s/(i*(1-n)*g),x,S=100,v,w,P,R;do v=Math.cos(2*u+M),w=Math.sin(M),P=Math.cos(M),R=p*w*(v+p/4*(P*(-1+2*v*v)-p/6*v*(-3+4*w*w)*(-3+4*v*v))),x=M,M=s/(i*(1-n)*g)+R;while(Math.abs(M-x)>1e-12&&--S>0);if(S===0)return{lat2:NaN,lon2:NaN};let C=a*w-h*P*l,A=Math.atan2(a*P+h*w*l,(1-n)*Math.sqrt(f*f+C*C)),b=Math.atan2(w*c,h*P-a*w*l),O=n/16*d*(4+n*(4-3*d)),N=b-(1-O)*n*f*(M+O*w*(v+O*P*(-1+2*v*v))),B=t+N;return{lat2:A,lon2:B}}function u2(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0),this.f=this.es/(1+Math.sqrt(1-this.es))}function f2(e){var t=e.x,r=e.y,s=Math.sin(e.y),i=Math.cos(e.y),n=E(t-this.long0,this.over),o,a,h,c,l,u,f,d,m,g,p;return this.sphere?Math.abs(this.sin_p12-1)<=T?(e.x=this.x0+this.a*(y-r)*Math.sin(n),e.y=this.y0-this.a*(y-r)*Math.cos(n),e):Math.abs(this.sin_p12+1)<=T?(e.x=this.x0+this.a*(y+r)*Math.sin(n),e.y=this.y0+this.a*(y+r)*Math.cos(n),e):(m=this.sin_p12*s+this.cos_p12*i*Math.cos(n),f=Math.acos(m),d=f?f/Math.sin(f):1,e.x=this.x0+this.a*d*i*Math.sin(n),e.y=this.y0+this.a*d*(this.cos_p12*s-this.sin_p12*i*Math.cos(n)),e):(o=Qt(this.es),a=Xt(this.es),h=Kt(this.es),c=Jt(this.es),Math.abs(this.sin_p12-1)<=T?(l=this.a*K(o,a,h,c,y),u=this.a*K(o,a,h,c,r),e.x=this.x0+(l-u)*Math.sin(n),e.y=this.y0-(l-u)*Math.cos(n),e):Math.abs(this.sin_p12+1)<=T?(l=this.a*K(o,a,h,c,y),u=this.a*K(o,a,h,c,r),e.x=this.x0+(l+u)*Math.sin(n),e.y=this.y0+(l+u)*Math.cos(n),e):Math.abs(t)<T&&Math.abs(r-this.lat0)<T?(e.x=e.y=0,e):(g=Nl(this.lat0,this.long0,r,t,this.a,this.f),p=g.azi1,e.x=g.s12*Math.sin(p),e.y=g.s12*Math.cos(p),e))}function m2(e){e.x-=this.x0,e.y-=this.y0;var t,r,s,i,n,o,a,h,c,l,u,f,d,m,g,p;return this.sphere?(t=Math.sqrt(e.x*e.x+e.y*e.y),t>2*y*this.a?void 0:(r=t/this.a,s=Math.sin(r),i=Math.cos(r),n=this.long0,Math.abs(t)<=T?o=this.lat0:(o=_t(i*this.sin_p12+e.y*s*this.cos_p12/t),a=Math.abs(this.lat0)-y,Math.abs(a)<=T?this.lat0>=0?n=E(this.long0+Math.atan2(e.x,-e.y),this.over):n=E(this.long0-Math.atan2(-e.x,e.y),this.over):n=E(this.long0+Math.atan2(e.x*s,t*this.cos_p12*i-e.y*this.sin_p12*s),this.over)),e.x=n,e.y=o,e)):(h=Qt(this.es),c=Xt(this.es),l=Kt(this.es),u=Jt(this.es),Math.abs(this.sin_p12-1)<=T?(f=this.a*K(h,c,l,u,y),t=Math.sqrt(e.x*e.x+e.y*e.y),d=f-t,o=ge(d/this.a,h,c,l,u),n=E(this.long0+Math.atan2(e.x,-1*e.y),this.over),e.x=n,e.y=o,e):Math.abs(this.sin_p12+1)<=T?(f=this.a*K(h,c,l,u,y),t=Math.sqrt(e.x*e.x+e.y*e.y),d=t-f,o=ge(d/this.a,h,c,l,u),n=E(this.long0+Math.atan2(e.x,e.y),this.over),e.x=n,e.y=o,e):(m=Math.atan2(e.x,e.y),g=Math.sqrt(e.x*e.x+e.y*e.y),p=Ll(this.lat0,this.long0,m,g,this.a,this.f),e.x=p.lon2,e.y=p.lat2,e))}var d2=["Azimuthal_Equidistant","aeqd"],Gl={init:u2,forward:f2,inverse:m2,names:d2};function p2(){this.sin_p14=Math.sin(this.lat0||0),this.cos_p14=Math.cos(this.lat0||0)}function g2(e){var t,r,s,i,n,o,a,h,c=e.x,l=e.y;return s=E(c-(this.long0||0),this.over),t=Math.sin(l),r=Math.cos(l),i=Math.cos(s),o=this.sin_p14*t+this.cos_p14*r*i,n=1,(o>0||Math.abs(o)<=T)&&(a=this.a*n*r*Math.sin(s),h=(this.y0||0)+this.a*n*(this.cos_p14*t-this.sin_p14*r*i)),e.x=a,e.y=h,e}function _2(e){var t,r,s,i,n,o,a,h,c;return e.x-=this.x0||0,e.y-=this.y0||0,t=Math.sqrt(e.x*e.x+e.y*e.y),r=_t(t/this.a),s=Math.sin(r),i=Math.cos(r),h=this.long0||0,c=this.lat0||0,o=h,Math.abs(t)<=T?(a=c,e.x=o,e.y=a,e):(a=_t(i*this.sin_p14+e.y*s*this.cos_p14/t),n=Math.abs(c)-y,Math.abs(n)<=T?(c>=0?o=E(h+Math.atan2(e.x,-e.y),this.over):o=E(h-Math.atan2(-e.x,e.y),this.over),e.x=o,e.y=a,e):(o=E(h+Math.atan2(e.x*s,t*this.cos_p14*i-e.y*this.sin_p14*s),this.over),e.x=o,e.y=a,e))}var M2=["ortho"],zl={init:p2,forward:g2,inverse:_2,names:M2};var Z={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},F={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function x2(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.lat0>=y-q/2?this.face=Z.TOP:this.lat0<=-(y-q/2)?this.face=Z.BOTTOM:Math.abs(this.long0)<=q?this.face=Z.FRONT:Math.abs(this.long0)<=y+q?this.face=this.long0>0?Z.RIGHT:Z.LEFT:this.face=Z.BACK,this.es!==0&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)}function y2(e){var t={x:0,y:0},r,s,i,n,o,a,h={value:0};if(e.x-=this.long0,this.es!==0?r=Math.atan(this.one_minus_f_squared*Math.tan(e.y)):r=e.y,s=e.x,this.face===Z.TOP)n=y-r,s>=q&&s<=y+q?(h.value=F.AREA_0,i=s-y):s>y+q||s<=-(y+q)?(h.value=F.AREA_1,i=s>0?s-Y:s+Y):s>-(y+q)&&s<=-q?(h.value=F.AREA_2,i=s+y):(h.value=F.AREA_3,i=s);else if(this.face===Z.BOTTOM)n=y+r,s>=q&&s<=y+q?(h.value=F.AREA_0,i=-s+y):s<q&&s>=-q?(h.value=F.AREA_1,i=-s):s<-q&&s>=-(y+q)?(h.value=F.AREA_2,i=-s-y):(h.value=F.AREA_3,i=s>0?-s+Y:-s-Y);else{var c,l,u,f,d,m,g;this.face===Z.RIGHT?s=je(s,+y):this.face===Z.BACK?s=je(s,+Y):this.face===Z.LEFT&&(s=je(s,-y)),f=Math.sin(r),d=Math.cos(r),m=Math.sin(s),g=Math.cos(s),c=d*g,l=d*m,u=f,this.face===Z.FRONT?(n=Math.acos(c),i=oi(n,u,l,h)):this.face===Z.RIGHT?(n=Math.acos(l),i=oi(n,u,-c,h)):this.face===Z.BACK?(n=Math.acos(-c),i=oi(n,u,-l,h)):this.face===Z.LEFT?(n=Math.acos(-l),i=oi(n,u,c,h)):(n=i=0,h.value=F.AREA_0)}return a=Math.atan(12/Y*(i+Math.acos(Math.sin(i)*Math.cos(q))-y)),o=Math.sqrt((1-Math.cos(n))/(Math.cos(a)*Math.cos(a))/(1-Math.cos(Math.atan(1/Math.cos(i))))),h.value===F.AREA_1?a+=y:h.value===F.AREA_2?a+=Y:h.value===F.AREA_3&&(a+=1.5*Y),t.x=o*Math.cos(a),t.y=o*Math.sin(a),t.x=t.x*this.a+this.x0,t.y=t.y*this.a+this.y0,e.x=t.x,e.y=t.y,e}function S2(e){var t={lam:0,phi:0},r,s,i,n,o,a,h,c,l,u={value:0};if(e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,s=Math.atan(Math.sqrt(e.x*e.x+e.y*e.y)),r=Math.atan2(e.y,e.x),e.x>=0&&e.x>=Math.abs(e.y)?u.value=F.AREA_0:e.y>=0&&e.y>=Math.abs(e.x)?(u.value=F.AREA_1,r-=y):e.x<0&&-e.x>=Math.abs(e.y)?(u.value=F.AREA_2,r=r<0?r+Y:r-Y):(u.value=F.AREA_3,r+=y),l=Y/12*Math.tan(r),o=Math.sin(l)/(Math.cos(l)-1/Math.sqrt(2)),a=Math.atan(o),i=Math.cos(r),n=Math.tan(s),h=1-i*i*n*n*(1-Math.cos(Math.atan(1/Math.cos(a)))),h<-1?h=-1:h>1&&(h=1),this.face===Z.TOP)c=Math.acos(h),t.phi=y-c,u.value===F.AREA_0?t.lam=a+y:u.value===F.AREA_1?t.lam=a<0?a+Y:a-Y:u.value===F.AREA_2?t.lam=a-y:t.lam=a;else if(this.face===Z.BOTTOM)c=Math.acos(h),t.phi=c-y,u.value===F.AREA_0?t.lam=-a+y:u.value===F.AREA_1?t.lam=-a:u.value===F.AREA_2?t.lam=-a-y:t.lam=a<0?-a-Y:-a+Y;else{var f,d,m;f=h,l=f*f,l>=1?m=0:m=Math.sqrt(1-l)*Math.sin(a),l+=m*m,l>=1?d=0:d=Math.sqrt(1-l),u.value===F.AREA_1?(l=d,d=-m,m=l):u.value===F.AREA_2?(d=-d,m=-m):u.value===F.AREA_3&&(l=d,d=m,m=-l),this.face===Z.RIGHT?(l=f,f=-d,d=l):this.face===Z.BACK?(f=-f,d=-d):this.face===Z.LEFT&&(l=f,f=d,d=-l),t.phi=Math.acos(-m)-y,t.lam=Math.atan2(d,f),this.face===Z.RIGHT?t.lam=je(t.lam,-y):this.face===Z.BACK?t.lam=je(t.lam,-Y):this.face===Z.LEFT&&(t.lam=je(t.lam,+y))}if(this.es!==0){var g,p,M;g=t.phi<0?1:0,p=Math.tan(t.phi),M=this.b/Math.sqrt(p*p+this.one_minus_f_squared),t.phi=Math.atan(Math.sqrt(this.a*this.a-M*M)/(this.one_minus_f*M)),g&&(t.phi=-t.phi)}return t.lam+=this.long0,e.x=t.lam,e.y=t.phi,e}function oi(e,t,r,s){var i;return e<T?(s.value=F.AREA_0,i=0):(i=Math.atan2(t,r),Math.abs(i)<=q?s.value=F.AREA_0:i>q&&i<=y+q?(s.value=F.AREA_1,i-=y):i>y+q||i<=-(y+q)?(s.value=F.AREA_2,i=i>=0?i-Y:i+Y):(s.value=F.AREA_3,i+=y)),i}function je(e,t){var r=e+t;return r<-Y?r+=ne:r>+Y&&(r-=ne),r}var v2=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],ql={init:x2,forward:y2,inverse:S2,names:v2};var lo=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-986701e-12],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,18736e-12],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,934959e-12],[.7986,-.00755338,-500009e-10,935324e-12],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],Cr=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-126793e-14,422642e-15],[.124,.0124,507171e-14,-160604e-14],[.186,.0123999,-190189e-13,600152e-14],[.248,.0124002,710039e-13,-224e-10],[.31,.0123992,-264997e-12,835986e-13],[.372,.0124029,988983e-12,-311994e-12],[.434,.0123893,-369093e-11,-435621e-12],[.4958,.0123198,-102252e-10,-345523e-12],[.5571,.0121916,-154081e-10,-582288e-12],[.6176,.0119938,-241424e-10,-525327e-12],[.6769,.011713,-320223e-10,-516405e-12],[.7346,.0113541,-397684e-10,-609052e-12],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-140374e-14],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],Bl=.8487,Dl=1.3523,Fl=X/5,E2=1/Fl,We=18,ai=function(e,t){return e[0]+t*(e[1]+t*(e[2]+t*e[3]))},w2=function(e,t){return e[1]+t*(2*e[2]+t*3*e[3])};function T2(e,t,r,s){for(var i=t;s;--s){var n=e(i);if(i-=n,Math.abs(n)<r)break}return i}function P2(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function b2(e){var t=E(e.x-this.long0,this.over),r=Math.abs(e.y),s=Math.floor(r*Fl);s<0?s=0:s>=We&&(s=We-1),r=X*(r-E2*s);var i={x:ai(lo[s],r)*t,y:ai(Cr[s],r)};return e.y<0&&(i.y=-i.y),i.x=i.x*this.a*Bl+this.x0,i.y=i.y*this.a*Dl+this.y0,i}function R2(e){var t={x:(e.x-this.x0)/(this.a*Bl),y:Math.abs(e.y-this.y0)/(this.a*Dl)};if(t.y>=1)t.x/=lo[We][0],t.y=e.y<0?-y:y;else{var r=Math.floor(t.y*We);for(r<0?r=0:r>=We&&(r=We-1);;)if(Cr[r][0]>t.y)--r;else if(Cr[r+1][0]<=t.y)++r;else break;var s=Cr[r],i=5*(t.y-s[0])/(Cr[r+1][0]-s[0]);i=T2(function(n){return(ai(s,n)-t.y)/w2(s,n)},i,T,100),t.x/=ai(lo[r],i),t.y=(5*r+i)*V,e.y<0&&(t.y=-t.y)}return t.x=E(t.x+this.long0,this.over),t}var C2=["Robinson","robin"],Ul={init:P2,forward:b2,inverse:R2,names:C2};function A2(){this.name="geocent"}function I2(e){var t=Xs(e,this.es,this.a);return t}function O2(e){var t=Ks(e,this.es,this.a,this.b);return t}var N2=["Geocentric","geocentric","geocent","Geocent"],Vl={init:A2,forward:I2,inverse:O2,names:N2};var ht={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3},Ar={h:{def:1e5,num:!0},azi:{def:0,num:!0,degrees:!0},tilt:{def:0,num:!0,degrees:!0},long0:{def:0,num:!0},lat0:{def:0,num:!0}};function L2(){if(Object.keys(Ar).forEach((function(r){if(typeof this[r]>"u")this[r]=Ar[r].def;else{if(Ar[r].num&&isNaN(this[r]))throw new Error("Invalid parameter value, must be numeric "+r+" = "+this[r]);Ar[r].num&&(this[r]=parseFloat(this[r]))}Ar[r].degrees&&(this[r]=this[r]*V)}).bind(this)),Math.abs(Math.abs(this.lat0)-y)<T?this.mode=this.lat0<0?ht.S_POLE:ht.N_POLE:Math.abs(this.lat0)<T?this.mode=ht.EQUIT:(this.mode=ht.OBLIQ,this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0)),this.pn1=this.h/this.a,this.pn1<=0||this.pn1>1e10)throw new Error("Invalid height");this.p=1+this.pn1,this.rp=1/this.p,this.h1=1/this.pn1,this.pfact=(this.p+1)*this.h1,this.es=0;var e=this.tilt,t=this.azi;this.cg=Math.cos(t),this.sg=Math.sin(t),this.cw=Math.cos(e),this.sw=Math.sin(e)}function G2(e){e.x-=this.long0;var t=Math.sin(e.y),r=Math.cos(e.y),s=Math.cos(e.x),i,n;switch(this.mode){case ht.OBLIQ:n=this.sinph0*t+this.cosph0*r*s;break;case ht.EQUIT:n=r*s;break;case ht.S_POLE:n=-t;break;case ht.N_POLE:n=t;break}switch(n=this.pn1/(this.p-n),i=n*r*Math.sin(e.x),this.mode){case ht.OBLIQ:n*=this.cosph0*t-this.sinph0*r*s;break;case ht.EQUIT:n*=t;break;case ht.N_POLE:n*=-(r*s);break;case ht.S_POLE:n*=r*s;break}var o,a;return o=n*this.cg+i*this.sg,a=1/(o*this.sw*this.h1+this.cw),i=(i*this.cg-n*this.sg)*this.cw*a,n=o*a,e.x=i*this.a,e.y=n*this.a,e}function z2(e){e.x/=this.a,e.y/=this.a;var t={x:e.x,y:e.y},r,s,i;i=1/(this.pn1-e.y*this.sw),r=this.pn1*e.x*i,s=this.pn1*e.y*this.cw*i,e.x=r*this.cg+s*this.sg,e.y=s*this.cg-r*this.sg;var n=Q(e.x,e.y);if(Math.abs(n)<T)t.x=0,t.y=e.y;else{var o,a;switch(a=1-n*n*this.pfact,a=(this.p-Math.sqrt(a))/(this.pn1/n+n/this.pn1),o=Math.sqrt(1-a*a),this.mode){case ht.OBLIQ:t.y=Math.asin(o*this.sinph0+e.y*a*this.cosph0/n),e.y=(o-this.sinph0*Math.sin(t.y))*n,e.x*=a*this.cosph0;break;case ht.EQUIT:t.y=Math.asin(e.y*a/n),e.y=o*n,e.x*=a;break;case ht.N_POLE:t.y=Math.asin(o),e.y=-e.y;break;case ht.S_POLE:t.y=-Math.asin(o);break}t.x=Math.atan2(e.x,e.y)}return e.x=t.x+this.long0,e.y=t.y,e}var q2=["Tilted_Perspective","tpers"],kl={init:L2,forward:G2,inverse:z2,names:q2};function B2(){if(this.flip_axis=this.sweep==="x"?1:0,this.h=Number(this.h),this.radius_g_1=this.h/this.a,this.radius_g_1<=0||this.radius_g_1>1e10)throw new Error;if(this.radius_g=1+this.radius_g_1,this.C=this.radius_g*this.radius_g-1,this.es!==0){var e=1-this.es,t=1/e;this.radius_p=Math.sqrt(e),this.radius_p2=e,this.radius_p_inv2=t,this.shape="ellipse"}else this.radius_p=1,this.radius_p2=1,this.radius_p_inv2=1,this.shape="sphere";this.title||(this.title="Geostationary Satellite View")}function D2(e){var t=e.x,r=e.y,s,i,n,o;if(t=t-this.long0,this.shape==="ellipse"){r=Math.atan(this.radius_p2*Math.tan(r));var a=this.radius_p/Q(this.radius_p*Math.cos(r),Math.sin(r));if(i=a*Math.cos(t)*Math.cos(r),n=a*Math.sin(t)*Math.cos(r),o=a*Math.sin(r),(this.radius_g-i)*i-n*n-o*o*this.radius_p_inv2<0)return e.x=Number.NaN,e.y=Number.NaN,e;s=this.radius_g-i,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/Q(o,s)),e.y=this.radius_g_1*Math.atan(o/s)):(e.x=this.radius_g_1*Math.atan(n/s),e.y=this.radius_g_1*Math.atan(o/Q(n,s)))}else this.shape==="sphere"&&(s=Math.cos(r),i=Math.cos(t)*s,n=Math.sin(t)*s,o=Math.sin(r),s=this.radius_g-i,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/Q(o,s)),e.y=this.radius_g_1*Math.atan(o/s)):(e.x=this.radius_g_1*Math.atan(n/s),e.y=this.radius_g_1*Math.atan(o/Q(n,s))));return e.x=e.x*this.a,e.y=e.y*this.a,e}function F2(e){var t=-1,r=0,s=0,i,n,o,a;if(e.x=e.x/this.a,e.y=e.y/this.a,this.shape==="ellipse"){this.flip_axis?(s=Math.tan(e.y/this.radius_g_1),r=Math.tan(e.x/this.radius_g_1)*Q(1,s)):(r=Math.tan(e.x/this.radius_g_1),s=Math.tan(e.y/this.radius_g_1)*Q(1,r));var h=s/this.radius_p;if(i=r*r+h*h+t*t,n=2*this.radius_g*t,o=n*n-4*i*this.C,o<0)return e.x=Number.NaN,e.y=Number.NaN,e;a=(-n-Math.sqrt(o))/(2*i),t=this.radius_g+a*t,r*=a,s*=a,e.x=Math.atan2(r,t),e.y=Math.atan(s*Math.cos(e.x)/t),e.y=Math.atan(this.radius_p_inv2*Math.tan(e.y))}else if(this.shape==="sphere"){if(this.flip_axis?(s=Math.tan(e.y/this.radius_g_1),r=Math.tan(e.x/this.radius_g_1)*Math.sqrt(1+s*s)):(r=Math.tan(e.x/this.radius_g_1),s=Math.tan(e.y/this.radius_g_1)*Math.sqrt(1+r*r)),i=r*r+s*s+t*t,n=2*this.radius_g*t,o=n*n-4*i*this.C,o<0)return e.x=Number.NaN,e.y=Number.NaN,e;a=(-n-Math.sqrt(o))/(2*i),t=this.radius_g+a*t,r*=a,s*=a,e.x=Math.atan2(r,t),e.y=Math.atan(s*Math.cos(e.x)/t)}return e.x=e.x+this.long0,e}var U2=["Geostationary Satellite View","Geostationary_Satellite","geos"],jl={init:B2,forward:D2,inverse:F2,names:U2};var Ir=1.340264,Or=-.081106,Nr=893e-6,Lr=.003796,hi=Math.sqrt(3)/2;function V2(){this.long0=this.long0!==void 0?this.long0:0,this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.es!==0&&(this.apa=br(this.es),this.qp=gt(this.e,1),this.rqda=Math.sqrt(.5*this.qp))}function k2(e){var t=E(e.x-this.long0,this.over),r=e.y,s=Math.sin(r);this.es!==0&&(s=gt(this.e,s)/this.qp);var i=Math.asin(hi*s),n=i*i,o=n*n*n;return e.x=t*Math.cos(i)/(hi*(Ir+3*Or*n+o*(7*Nr+9*Lr*n))),e.y=i*(Ir+Or*n+o*(Nr+Lr*n)),this.es!==0&&(e.x*=this.rqda,e.y*=this.rqda),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function j2(e){e.x=(e.x-this.x0)/this.a,e.y=(e.y-this.y0)/this.a,this.es!==0&&(e.x/=this.rqda,e.y/=this.rqda);var t=1e-9,r=12,s=e.y,i,n,o,a,h,c;for(c=0;c<r&&(i=s*s,n=i*i*i,o=s*(Ir+Or*i+n*(Nr+Lr*i))-e.y,a=Ir+3*Or*i+n*(7*Nr+9*Lr*i),s-=h=o/a,!(Math.abs(h)<t));++c);return i=s*s,n=i*i*i,e.x=hi*e.x*(Ir+3*Or*i+n*(7*Nr+9*Lr*i))/Math.cos(s),e.y=Math.asin(Math.sin(s)/hi),this.es!==0&&(e.y=Rr(e.y,this.apa)),e.x=E(e.x+this.long0,this.over),e}var W2=["eqearth","Equal Earth","Equal_Earth"],Wl={init:V2,forward:k2,inverse:j2,names:W2};var Gr=1e-10;function H2(){var e;if(this.phi1=this.lat1,Math.abs(this.phi1)<Gr)throw new Error;this.es?(this.en=De(this.es),this.m1=Ft(this.phi1,this.am1=Math.sin(this.phi1),e=Math.cos(this.phi1),this.en),this.am1=e/(Math.sqrt(1-this.es*this.am1*this.am1)*this.am1),this.inverse=Z2,this.forward=Y2):(Math.abs(this.phi1)+Gr>=y?this.cphi1=0:this.cphi1=1/Math.tan(this.phi1),this.inverse=Q2,this.forward=$2)}function Y2(e){var t=E(e.x-(this.long0||0),this.over),r=e.y,s,i,n;return s=this.am1+this.m1-Ft(r,i=Math.sin(r),n=Math.cos(r),this.en),i=n*t/(s*Math.sqrt(1-this.es*i*i)),e.x=s*Math.sin(i),e.y=this.am1-s*Math.cos(i),e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function Z2(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,r,s,i;if(r=Q(e.x,e.y=this.am1-e.y),i=Fe(this.am1+this.m1-r,this.es,this.en),(t=Math.abs(i))<y)t=Math.sin(i),s=r*Math.atan2(e.x,e.y)*Math.sqrt(1-this.es*t*t)/Math.cos(i);else if(Math.abs(t-y)<=Gr)s=0;else throw new Error;return e.x=E(s+(this.long0||0),this.over),e.y=pt(i),e}function $2(e){var t=E(e.x-(this.long0||0),this.over),r=e.y,s,i;return i=this.cphi1+this.phi1-r,Math.abs(i)>Gr?(e.x=i*Math.sin(s=t*Math.cos(r)/i),e.y=this.cphi1-i*Math.cos(s)):e.x=e.y=0,e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function Q2(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,r,s=Q(e.x,e.y=this.cphi1-e.y);if(r=this.cphi1+this.phi1-s,Math.abs(r)>y)throw new Error;return Math.abs(Math.abs(r)-y)<=Gr?t=0:t=s*Math.atan2(e.x,e.y)/Math.cos(r),e.x=E(t+(this.long0||0),this.over),e.y=pt(r),e}var X2=["bonne","Bonne (Werner lat_1=90)"],Hl={init:H2,names:X2};var Yl={OBLIQUE:{forward:r_,inverse:i_},TRANSVERSE:{forward:s_,inverse:n_}},ci={ROTATE:{o_alpha:"oAlpha",o_lon_c:"oLongC",o_lat_c:"oLatC"},NEW_POLE:{o_lat_p:"oLatP",o_lon_p:"oLongP"},NEW_EQUATOR:{o_lon_1:"oLong1",o_lat_1:"oLat1",o_lon_2:"oLong2",o_lat_2:"oLat2"}};function K2(){if(this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.title=this.title||"General Oblique Transformation",this.isIdentity=Wn.includes(this.o_proj),!this.o_proj)throw new Error("Missing parameter: o_proj");if(this.o_proj==="ob_tran")throw new Error("Invalid value for o_proj: "+this.o_proj);let e=this.projStr.replace("+proj=ob_tran","").replace("+o_proj=","+proj=").trim(),t=Nt(e);if(!t)throw new Error("Invalid parameter: o_proj. Unknown projection "+this.o_proj);t.long0=0,this.obliqueProjection=t;let r,s=Object.keys(ci),i=a=>{if(typeof this[a]>"u")return;let h=parseFloat(this[a])*V;if(isNaN(h))throw new Error("Invalid value for "+a+": "+this[a]);return h};for(let a=0;a<s.length;a++){let h=s[a],c=ci[h],l=Object.entries(c);if(l.some(([f])=>typeof this[f]<"u")){r=c;for(let f=0;f<l.length;f++){let[d,m]=l[f],g=i(d);if(typeof g>"u")throw new Error("Missing parameter: "+d+".");this[m]=g}break}}if(!r)throw new Error("No valid parameters provided for ob_tran projection.");let{lamp:n,phip:o}=e_(this,r);this.lamp=n,Math.abs(o)>T?(this.cphip=Math.cos(o),this.sphip=Math.sin(o),this.projectionType=Yl.OBLIQUE):this.projectionType=Yl.TRANSVERSE}function J2(e){return this.projectionType.forward(this,e)}function t_(e){return this.projectionType.inverse(this,e)}function e_(e,t){let r,s;if(t===ci.ROTATE){let i=e.oLongC,n=e.oLatC,o=e.oAlpha;if(Math.abs(Math.abs(n)-y)<=T)throw new Error("Invalid value for o_lat_c: "+e.o_lat_c+" should be < 90\xB0");s=i+Math.atan2(-1*Math.cos(o),-1*Math.sin(o)*Math.sin(n)),r=Math.asin(Math.cos(n)*Math.sin(o))}else if(t===ci.NEW_POLE)s=e.oLongP,r=e.oLatP;else{let i=e.oLong1,n=e.oLat1,o=e.oLong2,a=e.oLat2,h=Math.abs(n);if(Math.abs(n)>y-T)throw new Error("Invalid value for o_lat_1: "+e.o_lat_1+" should be < 90\xB0");if(Math.abs(a)>y-T)throw new Error("Invalid value for o_lat_2: "+e.o_lat_2+" should be < 90\xB0");if(Math.abs(n-a)<T)throw new Error("Invalid value for o_lat_1 and o_lat_2: o_lat_1 should be different from o_lat_2");if(h<T)throw new Error("Invalid value for o_lat_1: o_lat_1 should be different from zero");s=Math.atan2(Math.cos(n)*Math.sin(a)*Math.cos(i)-Math.sin(n)*Math.cos(a)*Math.cos(o),Math.sin(n)*Math.cos(a)*Math.sin(o)-Math.cos(n)*Math.sin(a)*Math.sin(i)),r=Math.atan(-1*Math.cos(s-i)/Math.tan(n))}return{lamp:s,phip:r}}function r_(e,t){let{x:r,y:s}=t;r=E(r-e.long0,e.over);let i=Math.cos(r),n=Math.sin(s),o=Math.cos(s);t.x=E(Math.atan2(o*Math.sin(r),e.sphip*o*i+e.cphip*n)+e.lamp),t.y=Math.asin(e.sphip*n-e.cphip*o*i);let a=e.obliqueProjection.forward(t);return e.isIdentity&&(a.x*=X,a.y*=X),a}function s_(e,t){let{x:r,y:s}=t;r=E(r-e.long0,e.over);let i=Math.cos(s),n=Math.cos(r);t.x=E(Math.atan2(i*Math.sin(r),Math.sin(s))+e.lamp),t.y=Math.asin(-1*i*n);let o=e.obliqueProjection.forward(t);return e.isIdentity&&(o.x*=X,o.y*=X),o}function i_(e,t){e.isIdentity&&(t.x*=V,t.y*=V);let r=e.obliqueProjection.inverse(t),{x:s,y:i}=r;if(s<Number.MAX_VALUE){s-=e.lamp;let n=Math.cos(s),o=Math.sin(i),a=Math.cos(i);t.x=Math.atan2(a*Math.sin(s),e.sphip*a*n-e.cphip*o),t.y=Math.asin(e.sphip*o+e.cphip*a*n)}return t.x=E(t.x+e.long0),t}function n_(e,t){e.isIdentity&&(t.x*=V,t.y*=V);let r=e.obliqueProjection.inverse(t),{x:s,y:i}=r;if(s<Number.MAX_VALUE){let n=Math.cos(i);s-=e.lamp,t.x=Math.atan2(n*Math.sin(s),-1*Math.sin(i)),t.y=Math.asin(n*Math.cos(s))}return t.x=E(t.x+e.long0),t}var o_=["General Oblique Transformation","General_Oblique_Transformation","ob_tran"],Zl={init:K2,forward:J2,inverse:t_,names:o_};function $l(e){e.Proj.projections.add(Ue),e.Proj.projections.add(Ve),e.Proj.projections.add(ll),e.Proj.projections.add(ul),e.Proj.projections.add(fl),e.Proj.projections.add(ml),e.Proj.projections.add(dl),e.Proj.projections.add(pl),e.Proj.projections.add(gl),e.Proj.projections.add(_l),e.Proj.projections.add(Ml),e.Proj.projections.add(xl),e.Proj.projections.add(yl),e.Proj.projections.add(vl),e.Proj.projections.add(El),e.Proj.projections.add(Tl),e.Proj.projections.add(Pl),e.Proj.projections.add(bl),e.Proj.projections.add(Rl),e.Proj.projections.add(Cl),e.Proj.projections.add(Al),e.Proj.projections.add(Il),e.Proj.projections.add(Ol),e.Proj.projections.add(Gl),e.Proj.projections.add(zl),e.Proj.projections.add(ql),e.Proj.projections.add(Ul),e.Proj.projections.add(Vl),e.Proj.projections.add(kl),e.Proj.projections.add(jl),e.Proj.projections.add(Wl),e.Proj.projections.add(Hl),e.Proj.projections.add(Zl)}var Ql=Object.assign(Yc,{defaultDatum:"WGS84",Proj:Nt,WGS84:new Nt("WGS84"),Point:el,toPoint:ze,defs:Ne,nadgrid:Qn,transform:Xn,mgrs:Kc,version:"__VERSION__"});$l(Ql);var uo=Ql;var fo=uo,Ut=class{static defineProjectionAliases(t){for(let r in t)fo.defs(r,t[r])}static registerDatumGrid(t,r,s){fo.nadgrid(t,r,s)}constructor({from:t="WGS84",to:r="WGS84",enforceAxis:s=!1}){if(this._projection=fo(t,r),this._enforceAxis=s,!this._projection)throw new Error("Invalid projection");this.project=this.project.bind(this),this.unproject=this.unproject.bind(this)}project(t){return this._projection.forward(t,this._enforceAxis)}unproject(t){return this._projection.inverse(t,this._enforceAxis)}};var zr=class extends Error{constructor(t){super(t.message||"CRS is not compatible with proj4js"),this.name="Proj4CRSCompatibilityError",this.compatibility=t}};var a_=new Set(["GeographicCRS","GeodeticCRS","ProjectedCRS","BoundCRS"]);function h_(e){return typeof e=="object"&&e!==null}function li(e){return typeof e.type=="string"?e.type:void 0}function Kl(e){return a_.has(e.type)}function Jl(e){return Kl(e)?e.type!=="BoundCRS"||Jl(e.source_crs):!1}function Xl(e,t,r,s=!1){return{status:"unsupported",checked:!1,lossy:s,type:e,reason:t,message:r}}function c_(e){if(e.type!=="CompoundCRS"||!Array.isArray(e.components))return{reason:"missing-horizontal-crs",message:"CompoundCRS does not contain a components array"};let t=e.components.filter(r=>Jl(r));return t.length===0?{reason:"missing-horizontal-crs",message:"CompoundCRS does not contain a Proj4-compatible horizontal CRS"}:t.length>1?{reason:"ambiguous-horizontal-crs",message:"CompoundCRS contains more than one Proj4-compatible horizontal CRS"}:{definition:t[0]}}function l_(e,t){if(!h_(e))return{definition:e,lossy:!1};if(Kl(e))return{definition:e,lossy:!1,type:li(e)};if(t==="horizontal"&&e.type==="CompoundCRS"){let s=c_(e);if("reason"in s)throw new zr(Xl(li(e),s.reason,s.message,!0));return{definition:s.definition,lossy:!0,type:li(e)}}let r=li(e);throw new zr(Xl(r,"unsupported-crs-type",r?`${r} is not supported by proj4js`:"CRS object has no supported type"))}function mo(e,t){return l_(e,t?.mode||"strict").definition}var u_=[9,-18,-88,0,96,90,0,0,-60,-20,-9,18,8,0,-96,30,0,0,60,-20,9,-88,-18,90,96,0,-20,-60,0,0,186,-42,-42,-150,-96,-150,60,60,60,60,54,162,-78,30,-24,-90,-60,60,-60,60,-9,-32,18,30,24,0,20,-60,0,0,-9,8,18,30,-96,0,-20,60,0,0,54,-78,162,-90,-24,30,60,-60,60,-60,-54,78,78,90,144,90,-60,-60,-60,-60,9,-8,-18,-30,-24,0,20,60,0,0,-9,18,-32,0,24,30,0,0,-60,20,9,-18,-8,0,-24,-30,0,0,60,20],f_=372,m_=[0,0,-131,0,138,144,0,0,-102,-31,0,0,7,0,-138,42,0,0,102,-31,62,0,-31,0,0,-62,0,0,0,31,124,0,-62,0,0,-124,0,0,0,62,124,0,-62,0,0,-124,0,0,0,62,62,0,-31,0,0,-62,0,0,0,31,0,0,45,0,-183,-9,0,93,18,0,0,0,216,0,33,87,0,-93,12,-93,0,0,156,0,153,99,0,-93,-12,-93,0,0,-45,0,-3,9,0,93,-18,0,0,0,-55,0,48,42,0,0,-84,31,0,0,-7,0,-48,-42,0,0,84,31],d_=372,p_=[18,-36,-122,0,120,135,0,0,-84,-31,-18,36,-2,0,-120,51,0,0,84,-31,36,-165,-27,93,147,-9,0,-93,18,0,210,45,-111,-93,-57,-192,0,93,12,93,162,141,-75,-93,-129,-180,0,93,-12,93,-36,-21,27,93,39,9,0,-93,-18,0,0,0,62,0,0,31,0,0,0,-31,0,0,124,0,0,62,0,0,0,-62,0,0,124,0,0,62,0,0,0,-62,0,0,62,0,0,31,0,0,0,-31,-18,36,-64,0,66,51,0,0,-102,31,18,-36,2,0,-66,-51,0,0,102,31],g_=12,po=20/2,__=2,qr=class{constructor(t){this._v00=0,this._v01=0,this._v10=0,this._v11=0,this._t=[],this.options=t,this._ix=this.options._width,this._iy=this.options._height}getHeight(t,r){if(t=Math.abs(t)>90?NaN:t,Number.isNaN(t)||Number.isNaN(r))return NaN;let s=M_(r,360);r=s!==-180?s:180;let i=r*this.options._rlonres,n=-t*this.options._rlatres,o=Math.floor(i),a=Math.min(Math.round((this.options._height-1)/2-1),Math.floor(n));i-=o,n-=a,a+=(this.options._height-1)/2,o+=o<0?this.options._width:o>=this.options._width?-this.options._width:0;let h=0,c=0,l=0,u=0,f=new Array(po);if(o===this._ix&&a===this._iy)this.options.cubic?f=this._t:(h=this._v00,c=this._v01,l=this._v10,u=this._v11);else if(!this.options.cubic)h=this._rawval(o,a),c=this._rawval(o+1,a),l=this._rawval(o,a+1),u=this._rawval(o+1,a+1);else{let m=[this._rawval(o,a-1),this._rawval(o+1,a-1),this._rawval(o-1,a),this._rawval(o,a),this._rawval(o+1,a),this._rawval(o+2,a),this._rawval(o-1,a+1),this._rawval(o,a+1),this._rawval(o+1,a+1),this._rawval(o+2,a+1),this._rawval(o,a+2),this._rawval(o+1,a+2)],g=m_;a!==0&&(g=a===this.options._height-2?p_:u_);let p=f_;a!==0&&(p=a===this.options._height-2?d_:240);for(let M=0;M<po;++M){f[M]=0;for(let x=0;x<g_;++x)f[M]+=m[x]*g[po*x+M];f[M]/=p}}if(!this.options.cubic){let m=(1-i)*h+i*c,g=(1-i)*l+i*u,p=(1-n)*m+n*g,M=this.options._offset+this.options._scale*p;return this._ix=o,this._iy=a,this._v00=h,this._v01=c,this._v10=l,this._v11=u,M}let d=f[0]+i*(f[1]+i*(f[3]+i*f[6]))+n*(f[2]+i*(f[4]+i*f[7])+n*(f[5]+i*f[8]+n*f[9]));return d=this.options._offset+this.options._scale*d,this._ix=o,this._iy=a,this._t=f,d}_rawval(t,r){t<0?t+=this.options._width:t>=this.options._width&&(t-=this.options._width),(r<0||r>=this.options._height)&&(r=r<0?-r:2*(this.options._height-1)-r,t+=(t<this.options._width/2?1:-1)*this.options._width/2);let s=this.options._datastart+__*(r*this.options._swidth+t),i=this.options.data[s],n=this.options.data[s+1];return i<<8|n}};function M_(e,t){t=Math.abs(t);let r=t0(e,t);return 2*Math.abs(r)===t?r-=t0(e,2*t)-r:2*Math.abs(r)>t&&(r+=r<0?t:-t),r}function t0(e,t){return e-Math.floor(e/t)*t}var x_=10,y_=65535;function go(e,t){let r=S_(e),s=r.next();if(s.done||s.value.line!=="P5")throw new Error("Geoid model file: File not in PGM format");let i=Number.MAX_VALUE,n=0,o=-1,a=-1,h="NONE",c="UNKNOWN",l=0,u=0,f=null,d=null;do{s=r.next();let M=s.value.line;if(M.length)if(M[0]==="#"){let x=M.split(" "),S=x[0],v=x[1];if(S!=="#"||!v)continue;let w=x.length>2?x.slice(2):[];if(v==="Description")h=w.join(" ");else if(v==="DateTime")c=w.join(" ");else if(v==="Offset"){if(!x[2])throw new Error("Geoid model file: Error reading offset");i=parseInt(x[2],10)}else if(v==="Scale"){if(!x[2])throw new Error("Geoid model file: Error reading scale");n=parseFloat(x[2])}else v===(t.cubic?"MaxCubicError":"MaxBilinearError")?isFinite(parseFloat(x[2]))&&(o=parseFloat(x[2])):v===(t.cubic?"RMSCubicError":"RMSBilinearError")&&isFinite(parseFloat(x[2]))&&(a=parseFloat(x[2]))}else{let x=M.split(" ");if(x=x.filter(S=>S!==""),l=parseInt(x[0],10),u=parseInt(x[1],10),!(l&&u))throw new Error("Geoid model file: Error reading raster size");break}}while(!s.done);s=r.next();let m=parseInt(s.value.line,10);if(s.done)throw new Error("Geoid model file: Error reading maxval");if(m!==y_)throw new Error("Geoid model file: Incorrect value of maxval");if(f=s.value.offset,d=l,i===Number.MAX_VALUE)throw new Error("Geoid model file: Offset not set");if(n===0)throw new Error("Geoid model file: Scale not set");if(n<0)throw new Error("Geoid model file: Scale must be positive");if(u<2||l<2)throw new Error("Geoid model file: Raster size too small");if(l&1)throw new Error("Geoid model file: Raster width is odd");if(!(u&1))throw new Error("Geoid model file: Raster height is even");let g=l/360,p=(u-1)/180;return new qr({cubic:t.cubic,_width:l,_height:u,_rlonres:g,_rlatres:p,_offset:i,_scale:n,_swidth:d,_datastart:f,_maxerror:o,_rmserror:a,_description:h,_datetime:c,data:e})}function*S_(e){let t=0;do{let r=e.indexOf(x_,t);if(r!==-1){let s=e.subarray(t,r);t=r+1,yield{offset:t,line:e0(s)}}else{let s=e.subarray(t,e.length);t=e.length,yield{offset:t,line:e0(s)}}}while(t<e.length);return{offset:t,line:""}}function e0(e){let t="";for(let r of e)t+=String.fromCharCode(r);return t}var r0=new Map;function s0(e,t){Mo(e,"CRS"),Ut.defineProjectionAliases({[e]:t})}function i0(e,t){Mo(e,"datum grid"),Ut.registerDatumGrid(e,t)}function _o(e,t){Mo(e,"geoid model"),r0.set(e,t)}function n0(e,t,r={}){let s=go(t,r);return _o(e,s),s}function ui(e){return r0.get(e)}function Mo(e,t){if(!e.trim())throw new Error(`${t} name must not be empty`)}var xo="EPSG:4326",v_="EPSG:4978",te=class{spatialReference;horizontalProjection;geographicProjection;heightOutputProjection;sourceIsGeocentric;outputIsGeocentric;sourceIsGeographic;outputIsGeographic;geoid;constructor(t,r={}){this.spatialReference=t,E_(t);let s=t.targetCrs||t.sourceCrs;if(this.sourceIsGeocentric=yo(t.sourceCrs),this.outputIsGeocentric=yo(s),this.sourceIsGeographic=o0(t.sourceCrs),this.outputIsGeographic=o0(s),t.sourceCrs&&t.targetCrs&&!this.sourceIsGeocentric&&!this.outputIsGeocentric&&(this.horizontalProjection=new Ut({from:fi(t.sourceCrs),to:fi(t.targetCrs),enforceAxis:!1})),(Br(t)||this.sourceIsGeocentric||this.outputIsGeocentric)&&(!this.sourceIsGeographic&&!this.sourceIsGeocentric&&(this.geographicProjection=new Ut({from:fi(t.sourceCrs),to:xo,enforceAxis:!1})),!this.outputIsGeographic&&!this.outputIsGeocentric&&(this.heightOutputProjection=new Ut({from:xo,to:fi(s),enforceAxis:!1}))),Br(t)&&(this.geoid=w_(r.geoidModel),!this.geoid)){let i=typeof r.geoidModel=="string"?` "${r.geoidModel}"`:"";throw new Error(`Height conversion requires a registered geoid model${i}; call registerGeoidModel() or pass a parsed Geoid instance`)}}transformPosition(t){if(t.length<2)throw new Error("A spatial coordinate must contain at least x and y components");let r=[...t];if(Br(this.spatialReference)||this.sourceIsGeocentric||this.outputIsGeocentric){if(r.length<3||!Number.isFinite(r[2]))throw new Error("Three-dimensional CRS conversion requires a finite z coordinate");let s=this.toGeographic(r);if(Br(this.spatialReference)){let n=this.geoid.getHeight(s[1],s[0]);s[2]=T_(s[2],n,this.spatialReference.heightReference,this.spatialReference.targetHeightReference)}let i=this.fromGeographic(s);return r.splice(0,i.length,...i),r}if(this.horizontalProjection){let s=this.horizontalProjection.project(r.slice(0,3));r.splice(0,s.length,...s)}return r}toGeographic(t){return this.sourceIsGeocentric?Array.from(I.WGS84.cartesianToCartographic(new _(t))):this.sourceIsGeographic?t.slice(0,3):this.geographicProjection.project(t.slice(0,3))}fromGeographic(t){return this.outputIsGeocentric?Array.from(I.WGS84.cartographicToCartesian(new _(t))):this.outputIsGeographic?t.slice(0,3):this.heightOutputProjection.project(t.slice(0,3))}};function fi(e){if(!e)throw new Error("Cannot construct a projection because the CRS is unknown");return mo(e,{mode:"horizontal"})}function E_(e){if(e.outputCoordinates==="local-enu")throw new Error("local-enu output requires a dataset-derived local origin and must be created by a tileset source");if(e.outputCoordinates==="target-crs"&&!e.targetCrs)throw new Error("target-crs output requires targetCrs");if(!e.sourceCrs&&e.status==="unresolved")throw new Error("Cannot transform coordinates because the source CRS is unknown");if(Br(e)&&e.heightReference==="unknown")throw new Error("Cannot convert heights because the source height reference is unknown");if(e.coordinateFrame==="geocentric"&&!yo(e.sourceCrs))throw new Error("Only EPSG:4978 geocentric coordinates are supported by the current spatial transformer");if(e.status==="unresolved")throw new Error("The requested spatial output cannot be resolved from the available metadata")}function yo(e){return typeof e=="string"&&a0(e)===v_}function o0(e){if(typeof e!="string")return!1;let t=a0(e);return t===xo||t==="EPSG:4979"||t==="OGC:CRS84"}function a0(e){let t=e.trim().toUpperCase(),r=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return r?`${r[1]}:${r[2]}`:t}function Br(e){let t=e.targetHeightReference;return t!=="native"&&t!==e.heightReference}function w_(e){return typeof e=="string"?ui(e):e}function T_(e,t,r,s){if(r===s||s==="native")return e;if(r==="orthometric"&&s==="ellipsoidal")return e+t;if(r==="ellipsoidal"&&s==="orthometric")return e-t;throw new Error(`Unsupported height conversion from ${r} to ${s}`)}var Ye=class{spatialReference;targetCoordinateFrame;positionTransformer;sourceToGeographicTransformer;geographicToTargetTransformer;sourceCoordinateFrame;sourceVerticalUnitScale;elevationMode;elevationOffset;elevationProvider;providerUnitScale;providerHeightTransformer;constructor(t,r={}){if(t.status!=="transformable"&&t.status!=="transformed")throw new Error("I3SSpatialTransformer requires a requested, transformable spatial output");let s=t.targetCrs||t.sourceCrs;if(!s)throw new Error("I3S spatial transformation requires a target CRS");if(this.positionTransformer=new te(t,r),this.sourceCoordinateFrame=t.coordinateFrame,this.sourceVerticalUnitScale=t.verticalUnitScale,this.elevationMode=t.elevationMode,this.elevationOffset=(t.elevationOffset||0)*t.elevationUnitScale,this.elevationProvider=P_(this.elevationMode,r),this.elevationProvider&&(typeof this.elevationProvider.sampleElevations!="function"||typeof this.elevationProvider.getElevationRange!="function"))throw new Error("An I3S elevation provider must implement sampleElevations() and getElevationRange()");let i=Mr(this.elevationProvider?.unit||"meter");if(this.elevationProvider&&i===void 0)throw new Error(`Unsupported elevation-provider unit ${this.elevationProvider.unit}`);this.providerUnitScale=i||1,this.targetCoordinateFrame=Ht(s),this.spatialReference=Is(t);let n=Pt({sourceCrs:t.sourceCrs,heightReference:t.heightReference,coordinateFrame:t.coordinateFrame,axisOrder:t.axisOrder,provenance:t.provenance},{targetCrs:"EPSG:4326"});if(this.sourceToGeographicTransformer=new te(n),He(this.elevationMode)){if(!this.elevationProvider){let h=this.elevationMode==="relativeToScene"?"scene":"terrain";throw new Error(`I3S elevation mode ${this.elevationMode} requires a ${h} elevation provider`)}if(t.heightReference==="unknown")throw new Error(`I3S elevation mode ${this.elevationMode} requires a known source height reference`);let a=this.elevationProvider.heightReference||t.heightReference;if(a!==t.heightReference){if(t.heightReference!=="ellipsoidal"&&t.heightReference!=="orthometric")throw new Error("Converting elevation-provider heights requires an ellipsoidal or orthometric source height reference");let h=Pt({sourceCrs:"EPSG:4326",heightReference:a,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"caller-override"},{targetCrs:"EPSG:4326",targetHeightReference:t.heightReference,geoidModel:r.geoidModel});this.providerHeightTransformer=new te(h,r)}}let o=Pt({sourceCrs:"EPSG:4326",heightReference:t.heightReference,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"format-default"},{targetCrs:s,targetHeightReference:t.targetHeightReference,geoidModel:r.geoidModel});this.geographicToTargetTransformer=new te(o,r)}transformPosition(t){let r=this.placeSourcePositionsSync(t),s=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[s[0],s[1],s[2]]}async transformPositionAsync(t){let r=await this.placeSourcePositions(t),s=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[s[0],s[1],s[2]]}transformPlacedPosition(t){let r=this.positionTransformer.transformPosition([t[0],t[1],t[2]]);return[r[0],r[1],r[2]]}transformSourcePositionToGeographic(t){let r=this.placeSourcePositionsSync(t),s=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[s[0],s[1],s[2]]}async transformSourcePositionToGeographicAsync(t){let r=await this.placeSourcePositions(t),s=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[s[0],s[1],s[2]]}transformPositions(t,r){let s=this.placeSourcePositionsSync(t),i=this.placeSourcePositionsSync(r);return this.transformPlacedPositions(s,i)}async transformPositionsAsync(t,r){let s=new Float64Array(t.length+3);s.set(Array.from(t),0),s.set(Array.from(r).slice(0,3),t.length);let i=await this.placeSourcePositions(s);return this.transformPlacedPositions(i.subarray(0,t.length),i.subarray(t.length))}transformPlacedPositions(t,r){let s=this.transformPlacedPosition(r),i=new Float32Array(t.length),n=Float64Array.from(t);for(let h=0;h<t.length;h+=3){let c=this.transformPlacedPosition([t[h],t[h+1],t[h+2]]);i[h]=c[0]-s[0],i[h+1]=c[1]-s[1],i[h+2]=c[2]-s[2]}let o=this.targetCoordinateFrame==="geographic",a=o?new z:new z().translate(s);return{positions:i,sourcePositions:n,origin:s,cartographicOrigin:o?s:[0,0,0],coordinateSystem:o?"lnglat-offsets":"cartesian",modelMatrix:a}}transformNormals(t,r,s="earth-centered"){let i=new Float32Array(t.length);for(let n=0;n<t.length;n+=3){let o=this.sourceToGeographicTransformer.transformPosition([r[n],r[n+1],r[n+2]]),a=new _([t[n],t[n+1],t[n+2]]).normalize(),h=s==="earth-centered"?a:f0(a,o),c=this.transformEcefNormal(h,o);i.set(c,n)}return i}transformBoundingVolume(t){let s=this.getGeographicBoundSamples(t).map(i=>this.geographicToTargetTransformer.transformPosition(i));return this.targetCoordinateFrame==="geographic"?{region:ae(s)}:{box:_e(s)}}async transformBoundingVolumeAsync(t){let s=(await this.getGeographicBoundSamplesAsync(t)).map(i=>this.geographicToTargetTransformer.transformPosition(i));return this.targetCoordinateFrame==="geographic"?{region:ae(s)}:{box:_e(s)}}transformBoundingVolumeToGeographic(t){return{region:ae(this.getGeographicBoundSamples(t))}}async transformBoundingVolumeToGeographicAsync(t){return{region:ae(await this.getGeographicBoundSamplesAsync(t))}}transformBoundingVolumeToGeocentric(t){let r=this.getGeographicBoundSamples(t).map(s=>Array.from(I.WGS84.cartographicToCartesian(new _(s))));return{box:_e(r)}}async transformBoundingVolumeToGeocentricAsync(t){let r=(await this.getGeographicBoundSamplesAsync(t)).map(s=>Array.from(I.WGS84.cartographicToCartesian(new _(s))));return{box:_e(r)}}transformBoundingSphereToGeographic(t){let r=t.mbs?.length?Array.from(t.mbs).slice(0,3):t.obb?Array.from(t.obb.center).slice(0,3):null;if(!r)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let s=this.placeSourcePositionsSync(r),i=this.sourceToGeographicTransformer.transformPosition(Array.from(s)),n=t.mbs?.length?t.mbs[3]:Math.hypot(...Array.from(t.obb.halfSize).slice(0,3));return[i[0],i[1],i[2],n]}async transformBoundingSphereToGeographicAsync(t){return h0(await this.getGeographicBoundSamplesAsync(t))}async transformBoundsAsync(t){let r=await this.getGeographicBoundSamplesAsync(t),s=r.map(n=>Array.from(I.WGS84.cartographicToCartesian(new _(n)))),i=r.map(n=>this.geographicToTargetTransformer.transformPosition(n));return{boundingVolume:{box:_e(s)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ae(i)}:{box:_e(i)},i3sLodMbs:He(this.elevationMode)?h0(r):this.transformBoundingSphereToGeographic(t)}}async transformPointCloudBoundsAsync(t){let r=await this.getGeographicBoundSamplesAsync(t),s=r.map(i=>this.geographicToTargetTransformer.transformPosition(i));return{boundingVolume:{region:ae(r)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ae(s)}:{box:_e(s)}}}getGeographicBoundSamples(t){let r=c0(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let s=this.placeSourcePositionsSync(r.flat(),!0),i=So(s);return this.sourceCoordinateFrame==="geographic"?i:i.map(n=>this.sourceToGeographicTransformer.transformPosition(n))}async getGeographicBoundSamplesAsync(t){let r=c0(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");if(He(this.elevationMode)){let i=this.sourceCoordinateFrame==="geographic"?r:r.map(n=>this.sourceToGeographicTransformer.transformPosition(n));return await this.placeGeographicBoundSamples(i)}let s=So(await this.placeSourcePositions(r.flat(),!0));return this.sourceCoordinateFrame==="geographic"?s:s.map(i=>this.sourceToGeographicTransformer.transformPosition(i))}async placeGeographicBoundSamples(t){let s=await this.elevationProvider.getElevationRange(b_(t)),i=s.minimum*this.providerUnitScale,n=s.maximum*this.providerUnitScale;if(!Number.isFinite(i)||!Number.isFinite(n)||i>n)throw new Error("Elevation provider returned an invalid range; minimum and maximum must be finite and ordered");let o=t.map(l=>l[2]),a=Math.min(...o),h=Math.max(...o),c=[];for(let[l,u]of t){let f=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([l,u,i])[2]:i,d=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([l,u,n])[2]:n,m=Math.min(f,d),g=Math.max(f,d),p=this.elevationMode==="onTheGround"?m:m+a+this.elevationOffset,M=this.elevationMode==="onTheGround"?g:g+h+this.elevationOffset;c.push([l,u,p],[l,u,M])}return c}placeSourcePositionsSync(t,r=!1){if(He(this.elevationMode))throw new Error(`I3S elevation mode ${this.elevationMode} requires asynchronous surface placement`);let s=Float64Array.from(t),i=this.elevationMode==="absoluteHeight"?this.elevationOffset:0;for(let n=2;n<s.length;n+=3)s[n]=s[n]*(r?1:this.sourceVerticalUnitScale)+i;return s}async placeSourcePositions(t,r=!1){if(!He(this.elevationMode))return this.placeSourcePositionsSync(t,r);let s=Float64Array.from(t),i=So(s).map(o=>{let a=this.sourceToGeographicTransformer.transformPosition(o);return[a[0],a[1]]}),n=await this.elevationProvider.sampleElevations(i);if(n.length!==i.length)throw new Error(`Elevation provider returned ${n.length} heights for ${i.length} positions`);for(let o=0;o<i.length;o++){let a=n[o]*this.providerUnitScale;if(!Number.isFinite(a))throw new Error(`Elevation provider returned a non-finite height at index ${o}`);let[h,c]=i[o],l=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([h,c,a])[2]:a,u=s[o*3+2]*(r?1:this.sourceVerticalUnitScale);s[o*3+2]=this.elevationMode==="onTheGround"?l:l+u+this.elevationOffset}return s}transformEcefNormal(t,r){if(this.targetCoordinateFrame==="geocentric")return t.normalize();if(this.targetCoordinateFrame==="geographic")return C_(t,r).normalize();let s=I.WGS84.cartographicToCartesian(new _(r)),i=[];for(let o of R_()){let a=I.WGS84.cartesianToCartographic(new _(s).add(o)),h=I.WGS84.cartesianToCartographic(new _(s).subtract(o)),c=this.geographicToTargetTransformer.transformPosition(a),l=this.geographicToTargetTransformer.transformPosition(h);i.push((c[0]-l[0])/2,(c[1]-l[1])/2,(c[2]-l[2])/2)}let n=new j(i);if(Math.abs(n.determinant())<1e-12)throw new Error("Cannot transform an I3S normal through a singular local projection");return n.invert().transpose(),new _(t).transformByMatrix3(n).normalize()}};function P_(e,t){return e==="relativeToScene"?t.sceneElevationProvider:He(e)?t.terrainElevationProvider:void 0}function He(e){return e==="onTheGround"||e==="relativeToGround"||e==="relativeToScene"}function So(e){if(e.length%3!==0)throw new Error("I3S position arrays must contain complete XYZ tuples");let t=[];for(let r=0;r<e.length;r+=3)t.push([e[r],e[r+1],e[r+2]]);return t}function b_(e){let t=ae(e);return{west:t[0]*180/Math.PI,south:t[1]*180/Math.PI,east:t[2]*180/Math.PI,north:t[3]*180/Math.PI}}function h0(e){if(!e.length)throw new Error("I3S spatial transformation requires at least one bound sample");let t=e.map(n=>I.WGS84.cartographicToCartesian(new _(n))),r=new _;for(let n of t)r.add(n);r.scale(1/t.length);let s=0;for(let n of t)s=Math.max(s,new _(n).subtract(r).magnitude());let i=I.WGS84.cartesianToCartographic(r);return[i[0],i[1],i[2],s]}function c0(e,t,r,s){let i=e.obb;if(i){let h=Array.from(i.center).slice(0,3);h[2]*=s;let c=Array.from(i.halfSize).slice(0,3),l=new wt().fromArray(Array.from(i.quaternion)),u=[new _([c[0],0,0]).transformByQuaternion(l),new _([0,c[1],0]).transformByQuaternion(l),new _([0,0,c[2]]).transformByQuaternion(l)];if(t==="geographic"){let f=r.transformPosition(h),d=I.WGS84.cartographicToCartesian(new _(f)),m=e.normalReferenceFrame==="vertex-reference-frame"?u.map(g=>f0(g,f)):u;return l0().map(g=>{let p=new _(d);for(let M=0;M<3;M++)p.add(new _(m[M]).scale(g[M]));return Array.from(I.WGS84.cartesianToCartographic(p))})}return l0().map(f=>{let d=new _(h);for(let m=0;m<3;m++)d.add(new _(u[m]).scale(f[m]));return Array.from(d)})}let n=e.mbs?Array.from(e.mbs):[];if(n.length<4)return[];let o=n.slice(0,3);o[2]*=s;let a=n[3];if(t==="geographic"){let h=r.transformPosition(o),c=I.WGS84.cartographicToCartesian(new _(h));return u0().map(l=>Array.from(I.WGS84.cartesianToCartographic(new _(c).add(new _(l).scale(a)))))}return u0().map(h=>Array.from(new _(o).add(new _(h).scale(a))))}function l0(){return[-1,1].flatMap(e=>[-1,1].flatMap(t=>[-1,1].map(r=>[e,t,r])))}function u0(){return[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]]}function R_(){return[new _([1,0,0]),new _([0,1,0]),new _([0,0,1])]}function f0(e,t){let r=t[0]*Math.PI/180,s=t[1]*Math.PI/180,i=new _([-Math.sin(r),Math.cos(r),0]),n=new _([-Math.sin(s)*Math.cos(r),-Math.sin(s)*Math.sin(r),Math.cos(s)]),o=new _([Math.cos(s)*Math.cos(r),Math.cos(s)*Math.sin(r),Math.sin(s)]);return i.scale(e[0]).add(n.scale(e[1])).add(o.scale(e[2]))}function C_(e,t){let r=t[0]*Math.PI/180,s=t[1]*Math.PI/180,i=new _([-Math.sin(r),Math.cos(r),0]),n=new _([-Math.sin(s)*Math.cos(r),-Math.sin(s)*Math.sin(r),Math.cos(s)]),o=new _([Math.cos(s)*Math.cos(r),Math.cos(s)*Math.sin(r),Math.sin(s)]);return new _([i.dot(e),n.dot(e),o.dot(e)])}function _e(e){let t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let n of e)for(let o=0;o<3;o++)t[o]=Math.min(t[o],n[o]),r[o]=Math.max(r[o],n[o]);let s=t.map((n,o)=>(n+r[o])/2),i=t.map((n,o)=>(r[o]-n)/2);return[s[0],s[1],s[2],i[0],0,0,0,i[1],0,0,0,i[2]]}function ae(e){let t=e[0][0],r=1/0,s=-1/0,i=1/0,n=-1/0,o=1/0,a=-1/0;for(let h of e){let c=t+vo(h[0]-t);r=Math.min(r,c),s=Math.max(s,c),i=Math.min(i,h[1]),n=Math.max(n,h[1]),o=Math.min(o,h[2]),a=Math.max(a,h[2])}return[vo(r)*Math.PI/180,i*Math.PI/180,vo(s)*Math.PI/180,n*Math.PI/180,o,a]}function vo(e){return((e+180)%360+360)%360-180}var A_={draco:!1,meshopt:!1,dds:!1,ktx2:!1},mi=class{type=lt.I3S;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...A_};asset;properties;extras;credits;metadata;queryParams={};resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(t,r={}){let s=I_(t);this.rootTileset=m0(t)?null:t,this.tileset=this.rootTileset,this.loader=s.loader,this.url=s.url,this.basePath=s.basePath||xt.dirname(s.url),this.resolver=s.resolver,this.coreApi=s.coreApi,this.loadOptions=r,this.initializeQueryParams(r)}async initialize(){this.rootTileset||(this.rootTileset=await this.loadRootData(this.getTileUrl(this.url),this.loadOptions)),this.tileset=this.rootTileset,this.rootTileset.root&&typeof this.rootTileset.root.then=="function"&&(this.rootTileset.root=await this.rootTileset.root),this.metadata={type:this.type,loader:this.loader,url:this.url,basePath:this.basePath,tileset:this.rootTileset,lodMetricType:this.rootTileset.lodMetricType,lodMetricValue:this.rootTileset.lodMetricValue,refine:this.rootTileset.root?.refine,spatialReference:Bs(this.rootTileset)}}getMetadata(){if(!this.metadata)throw new Error("I3SSource has not been initialized");return this.metadata}async getRootTileset(){return this.getMetadata().tileset}async prepareTileset(t){let r=t.spatialReference;if(r.status==="unresolved")throw new Error(r.warnings[0]||"I3S spatial operations cannot be resolved from the supplied metadata and options");r.status!=="transformable"&&r.status!=="transformed"||(this.spatialTransformer||=new Ye(r,t.options.spatial),t.spatialReference=this.spatialTransformer.spatialReference,this.preparedRootHeader=await this.transformTileHeader(this.getMetadata().tileset.root))}initializeTileHeaders(t,r,s){let i=s?r.root:this.preparedRootHeader||r.root;if(this.spatialTransformer&&!this.preparedRootHeader)throw new Error("I3S spatial root header was not prepared before tile initialization");let n=new bt(t,i,s||void 0);return s&&(s.children.push(n),n.depth=s.depth+1),n}createTraverser(t){return new Ws(t)}async loadTileContent(t){let r=this.getTileUrl(t.contentUrl),s=this.loader.id,i=this.loadOptions[s]||{},n=this.getMetadata(),o={...this.loadOptions,[s]:{...i,...t.tileset.options.i3s,_tileOptions:{attributeUrls:t.header.attributeUrls,textureUrl:t.header.textureUrl,textureUrls:t.header.textureUrls,textureFormat:t.header.textureFormat,textureLoaderOptions:t.header.textureLoaderOptions,materialDefinition:t.header.materialDefinition,layerType:t.header.layerType,pointRenderer:t.header.pointRenderer,pointSymbol:t.header.pointSymbol,isDracoGeometry:t.header.isDracoGeometry,mbs:t.header.mbs},_tilesetOptions:{store:n.tileset.store,attributeStorageInfo:n.tileset.attributeStorageInfo,fields:n.tileset.fields,spatialReference:t.tileset.spatialReference,spatialOptions:t.tileset.options.spatial},isTileHeader:!1}};return t.content=await this.loadResourceData(r,o),{loaded:!0}}async loadChildTileHeader(t,r,s){let i=this.getMetadata();if(i.tileset.nodePages||i.tileset.pointNodePages){let c=await i.tileset.nodePagesTile.formTileFromNodePages(r);return await this.transformTileHeader(c)}let n=this.getTileUrl(`${this.url}/nodes/${r}`),o=this.loadOptions.i3s&&typeof this.loadOptions.i3s=="object"?this.loadOptions.i3s:{},a={...this.loadOptions,i3s:{...o,isTileHeader:!0}},h=await this.loadResourceData(n,a);return await this.transformTileHeader(h)}getTileUrl(t){if(t.startsWith("data:")||!Object.keys(this.queryParams).length)return t;let r=t.indexOf("?");if(r===-1)return`${t}?${new URLSearchParams(this.queryParams).toString()}`;let s=t.slice(r+1),i=new Set(s.split("&").map(a=>a.split("=",1)[0])),n=new URLSearchParams;for(let[a,h]of Object.entries(this.queryParams))i.has(a)||n.set(a,h);let o=n.toString();return o?`${t}${s?"&":""}${o}`:t}getViewState(t){if(this.spatialTransformer&&t){let n=new _(t.boundingVolume.center),o=new _(t.header.i3sLodMbs.slice(0,3));return this.spatialTransformer.targetCoordinateFrame==="geographic"?{boundingVolume:t.boundingVolume,cartographicCenter:o,cartesianCenter:n,zoom:1}:{boundingVolume:t.boundingVolume,cartographicCenter:o,cartesianCenter:n,zoom:1}}let r=this.getMetadata(),s=r.tileset.fullExtent;if(s){let{xmin:n,xmax:o,ymin:a,ymax:h,zmin:c,zmax:l}=s,u=new _(n+(o-n)/2,a+(h-a)/2,c+(l-c)/2),f=new _;return I.WGS84.cartographicToCartesian(u,f),{cartographicCenter:u,cartesianCenter:f,zoom:Gn(s,u,f)}}let i=r.tileset.store?.extent;if(i){let[n,o,a,h]=i,c=new _(n+(a-n)/2,o+(h-o)/2,0),l=new _;return I.WGS84.cartographicToCartesian(c,l),{cartographicCenter:c,cartesianCenter:l,zoom:Wh(i,c,l)}}return console.warn("Extent is not defined in the tileset header"),{cartographicCenter:new _,zoom:1}}onTileLoaded(t,r){switch(r.header.isDracoGeometry&&(this.contentFormats.draco=!0),r.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}}getTilesTotalCount(){return this.getMetadata().tileset?.nodePagesTile?.nodesInNodePages||null}async loadWithCoreApi(t,r){if(!this.coreApi)throw new Error("I3SSource requires an injected coreApi to load tileset data");return await this.coreApi.load(t,this.loader,r)}async loadRootData(t,r){return this.resolver?await this.resolver.loadRoot(t,this.loader,r):await this.loadWithCoreApi(t,r)}initializeQueryParams(t){let r=t.i3s;if(r&&typeof r=="object"&&"token"in r){let s=r.token;typeof s=="string"&&(this.queryParams.token=s)}}async loadResourceData(t,r){return this.resolver?await this.resolver.loadResource(t,this.loader,r):await this.loadWithCoreApi(t,r)}async transformTileHeader(t){if(!this.spatialTransformer)return t;let r={mbs:t.mbs,obb:t.obb,normalReferenceFrame:this.getMetadata().tileset.store?.normalReferenceFrame},s=await this.spatialTransformer.transformBoundsAsync(r);return{...t,boundingVolume:s.boundingVolume,spatialBoundingVolume:s.spatialBoundingVolume,i3sLodMbs:s.i3sLodMbs}}};function m0(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function I_(e){return m0(e)?{...e,basePath:e.basePath||xt.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||xt.dirname(e.url),resolver:e.resolver,coreApi:e.coreApi}}var Me=class{index;parent;children;content;error;id;zoom;userData;boundingBox;_abortController;_loader;_loaderId;_isLoaded;_isCancelled;_needsReload;_bbox;constructor(t){this.index=t,this.parent=null,this.children=[],this.content=null,this.error=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(t){this._bbox||(this._bbox=t,"west"in t?this.boundingBox=[[t.west,t.south],[t.east,t.north]]:this.boundingBox=[[t.left,t.top],[t.right,t.bottom]])}get data(){let t=this._loader;return!this._isCancelled&&t!==void 0?t.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get hasError(){return!!this.error}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let t=this.content?this.content.byteLength:0;return Number.isFinite(t)?t:0}async _loadData({getData:t,requestScheduler:r,onLoad:s,onError:i}){let n=(p,M,x)=>{if(x===this._loaderId){if(this._loader=void 0,this.content=p,this.error=M?O_(M):null,this._isCancelled&&!p){this._isLoaded=!1;return}if(this._isLoaded=!0,this._isCancelled=!1,M){i(M,this);return}s(this)}},{index:o,id:a,bbox:h,userData:c,zoom:l}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:f}=this._abortController,d=await r.scheduleRequest(this,()=>1);if(!d){this._isCancelled=!0;return}if(this._isCancelled){d.done();return}let m=null,g;try{m=await t({index:o,id:a,bbox:h,userData:c,zoom:l,signal:f})}catch(p){g=p||!0}finally{d.done()}n(m,g,u)}loadData(t){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this.error=null,this._loaderId++,this._loader=this._loadData(t),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};function O_(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}var Eo="never",wo="no-overlap",Fr="best-available",d0={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:Fr,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},Dr=class e{stats;sourceMetadata=null;opts;_requestScheduler;_cache;_dirty;_tiles;_cacheByteSize;_unloadedTileCount;_listeners=new Set;_consumers=new Map;_explicitOptionKeys=new Set;_baseOpts={};_sourceMetadataOverrides={};_maxZoom;_minZoom;_lastTileContext=null;constructor(t){if(this.stats=new Tt({id:"Tileset2D",stats:[{name:"Tiles In Cache"},{name:"Cache Size"},{name:"Visible Tiles"},{name:"Selected Tiles"},{name:"Loading Tiles"},{name:"Unloaded Tiles"},{name:"Consumers"}]}),this.opts={...d0,...t,getTileData:t.getTileData||(()=>null),tileSource:t.tileSource},this._requestScheduler=new Wt({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._unloadedTileCount=0,!this.opts.tileSource&&!t.getTileData)throw new Error("Tileset2D requires either `getTileData` or `tileSource`.");this.setOptions(t),this._updateStats(),this.opts.tileSource&&this._initializeTileSource(this.opts.tileSource).catch(()=>{})}static fromTileSource(t,r={}){return new e({...r,tileSource:t})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let t=this._getVisibleTilesUnion();for(let r of this._getSelectedTilesUnion())t.add(r);return Array.from(t)}get loadingTiles(){return Array.from(this._cache.values()).filter(t=>t.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(t=>!t.isLoaded)}get maxZoom(){return this._maxZoom}get minZoom(){return this._minZoom}get refinementStrategy(){return this.opts.refinementStrategy||Fr}get adapter(){return this.opts.adapter}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}attachConsumer(t){this._consumers.set(t,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(t){this._consumers.delete(t),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(t){this._rememberExplicitOptions(t),this._baseOpts={...this._baseOpts,...t};let r=this.opts.maxRequests,s=this.opts.debounceTime;this._applyResolvedOptions(),(r!==this.opts.maxRequests||s!==this.opts.debounceTime)&&(this._requestScheduler=new Wt({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}))}finalize(){for(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._consumers.clear(),this._cacheByteSize=0,this._unloadedTileCount=0,this._updateStats()}reloadAll(){let t=this._getSelectedTilesUnion();for(let r of this._cache.keys()){let s=this._cache.get(r);s&&!t.has(s)?(this._cache.delete(r),this._handleTileUnload(s),this._dirty=!0):s&&s.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,r,s){this._consumers.set(t,{selectedTiles:new Set(r),visibleTiles:new Set(s)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:r,minZoom:s,zRange:i,modelMatrix:n,modelMatrixInverse:o}){let{adapter:a,tileSize:h,extent:c,zoomOffset:l}=this.opts;if(!a)throw new Error("Tileset2D requires an adapter before tile traversal can be used.");return this._lastTileContext={viewState:t,tileSize:h},a.getTileIndices({viewState:t,maxZoom:r,minZoom:s,zRange:i,tileSize:h,extent:N_(c),modelMatrix:n,modelMatrixInverse:o,zoomOffset:l})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){if(!this._lastTileContext)throw new Error("Tileset2D metadata requested before traversal context was set.");if(!this.opts.adapter)throw new Error("Tileset2D requires an adapter before tile metadata can be derived.");return{bbox:this.opts.adapter.getTileBoundingBox(this._lastTileContext,t)}}getParentIndex(t){return{x:Math.floor(t.x/2),y:Math.floor(t.y/2),z:t.z-1}}getTile(t,r){let s=this.getTileId(t),i=this._cache.get(s),n=!1;return!i&&r?(i=new Me(t),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:s,zoom:this.getTileZoom(i.index)}),n=!0,this._cache.set(s,i),this._dirty=!0,this._updateStats()):i&&i.needsReload&&(n=!0),i&&this._touchTile(s,i),i&&n&&r&&(i.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),this._updateStats()),i}async _initializeTileSource(t){try{this.sourceMetadata=await t.getMetadata(),this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(r){let s=r instanceof Error?r:new Error(`TileSource metadata error: ${String(r)}`);this._notifyError(s)}}_rememberExplicitOptions(t){for(let r of Object.keys(t))this._explicitOptionKeys.add(r)}_applyResolvedOptions(){let t={...d0,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let r=t.tileSource;t.getTileData=s=>r.getTileData(s)}this.opts=t,this._maxZoom=typeof this.opts.maxZoom=="number"&&Number.isFinite(this.opts.maxZoom)?Math.floor(this.opts.maxZoom):void 0,this._minZoom=typeof this.opts.minZoom=="number"&&Number.isFinite(this.opts.minZoom)?Math.ceil(this.opts.minZoom):void 0}_getMetadataOverrides(t){if(!t)return{};let r={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(t.minZoom)&&(r.minZoom=t.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(t.maxZoom)&&(r.maxZoom=t.maxZoom),!this._explicitOptionKeys.has("extent")&&t.boundingBox&&(r.extent=[t.boundingBox[0][0],t.boundingBox[0][1],t.boundingBox[1][0],t.boundingBox[1][1]]),r}_handleTileLoad(t){this.opts.onTileLoad?.(t),this._cacheByteSize=this._getCacheByteSize(),this._resizeCache();for(let r of this._listeners)r.onTileLoad?.(t);this._updateStats()}_handleTileError(t,r){this.opts.onTileError?.(t,r);for(let s of this._listeners)s.onTileError?.(t,r);this._updateStats()}_handleTileUnload(t){this._unloadedTileCount++,this.opts.onTileUnload?.(t);for(let r of this._listeners)r.onTileUnload?.(t);this._updateStats()}_notifyUpdate(){for(let t of this._listeners)t.onUpdate?.()}_notifyError(t){for(let r of this._listeners)r.onError?.(t)}_updateStats(){this._setStatCount("Tiles In Cache",this._cache.size),this._setStatCount("Cache Size",this.cacheByteSize),this._setStatCount("Visible Tiles",this.visibleTiles.length),this._setStatCount("Selected Tiles",this.selectedTiles.length),this._setStatCount("Loading Tiles",this.loadingTiles.length),this._setStatCount("Unloaded Tiles",this._unloadedTileCount),this._setStatCount("Consumers",this._consumers.size);for(let t of this._listeners)t.onStatsChange?.(this.stats)}_setStatCount(t,r){this.stats.get(t).reset().addCount(r)}_getSelectedTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let s of r.selectedTiles)t.add(s);return t}_getVisibleTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let s of r.visibleTiles)t.add(s);return t}_touchTile(t,r){this._cache.delete(t),this._cache.set(t,r)}_getCacheByteSize(){let t=0;for(let r of this._cache.values())t+=r.byteLength;return t}_pruneRequests(){let{maxRequests:t=0}=this.opts,r=this._getSelectedTilesUnion(),s=this._getVisibleTilesUnion(),i=[],n=0;for(let o of this._cache.values())o.isLoading&&(n++,!r.has(o)&&!s.has(o)&&i.push(o));for(;t>0&&n>t&&i.length>0;){let o=i.shift();o&&o.abort(),n--}}_rebuildTree(){for(let t of this._cache.values())t.parent=null,t.children&&(t.children.length=0);for(let t of this._cache.values()){let r=this._getNearestAncestor(t);t.parent=r,r?.children&&r.children.push(t)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((t,r)=>t.zoom-r.zoom)}_resizeCache(){let t=this.opts.maxCacheSize??100,r=this.opts.maxCacheByteSize??1/0,s=this._getVisibleTilesUnion(),i=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>r){for(let[o,a]of this._cache)if(!s.has(a)&&!i.has(a)&&(this._cache.delete(o),this._cacheByteSize=this._getCacheByteSize(),this._handleTileUnload(a)),this._cache.size<=t&&this._cacheByteSize<=r)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(t){let{_minZoom:r=0}=this,s=t.index;for(;this.getTileZoom(s)>r;){s=this.getParentIndex(s);let i=this.getTile(s);if(i)return i}return null}};function N_(e){return e&&e.length===4?e:void 0}var di={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},pi=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.imageSource&&(!t.getImage||!t.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(t,r={}){return new e({...r,imageSource:t})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get image(){return this._currentRequest?.image||null}get currentRequest(){return this._currentRequest}get imageSource(){return this._opts.imageSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.imageSource,s=this._normalizeOptions({...this._opts,...t}),i=r!==s.imageSource||this._opts.getImage!==s.getImage||this._opts.getMetadata!==s.getMetadata;this._opts=s,i&&(this._cancelScheduledImage(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let t=await this._opts.getMetadata();if(this._finalized)return t;this.metadata=t;for(let r of this._listeners)r.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let r=p0(t,"Image metadata request failed");if(!this._finalized)for(let s of this._listeners)s.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestImage(t,r=this._opts.debounceTime){let s=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(s,t)},r):this._loadImage(s,t),s}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,r){if(!this._finalized){this._startLoading();for(let s of this._listeners)s.onImageLoadStart?.(t,r);try{let s=new AbortController;this._abortController=s;let i=await this._opts.getImage({...r,signal:s.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:r,image:i};for(let n of this._listeners)n.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(s){if(L_(s))return;let i=p0(s,"Image request failed");if(!this._finalized)for(let n of this._listeners)n.onImageLoadError?.(t,i,r)}finally{this._abortController?.signal===r.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let r=t.imageSource||null;return{...di,...t,imageSource:r,getMetadata:t.getMetadata||(()=>r?r.getMetadata():di.getMetadata()),getImage:t.getImage||(s=>r?r.getImage(s):di.getImage(s)),debounceTime:t.debounceTime??di.debounceTime}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(t){for(let r of this._listeners)r.onLoadingStateChange?.(t)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function L_(e){return e instanceof Error&&e.name==="AbortError"}function p0(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}var Ur={getMetadata:async()=>({width:0,height:0,bandCount:0,dtype:"uint8"}),getRaster:async()=>({data:new Uint8Array(0),width:0,height:0,bandCount:0,dtype:"uint8"}),debounceTime:0,shouldRefetch:()=>!0},gi=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.rasterSource&&(!t.getRaster||!t.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(t,r={}){return new e({...r,rasterSource:t})}static fromCallbacks(t){return new e(t)}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get raster(){return this._currentRequest?.raster||null}get currentRequest(){return this._currentRequest}get rasterSource(){return this._opts.rasterSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let r=this._opts.rasterSource,s=this._normalizeOptions({...this._opts,...t}),i=r!==s.rasterSource||this._opts.getRaster!==s.getRaster||this._opts.getMetadata!==s.getMetadata;this._opts=s,i&&(this._cancelScheduledRaster(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let t=await this._opts.getMetadata();if(this._finalized)return t;this.metadata=t;for(let r of this._listeners)r.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let r=g0(t,"Raster metadata request failed");if(!this._finalized)for(let s of this._listeners)s.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestRaster(t,r=this._opts.debounceTime){if(!this.shouldRefetchRaster(t))return this._currentRequest?.requestId??-1;let s=this._nextRequestId++;return this._cancelScheduledRaster(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(s,t)},r):this._loadRaster(s,t),s}shouldRefetchRaster(t){return this._opts.shouldRefetch({currentRequest:this._currentRequest,metadata:this.metadata,nextParameters:t})}finalize(){this._finalized=!0,this._cancelScheduledRaster(),this._abortActiveRequest(),this._listeners.clear()}async _loadRaster(t,r){if(!this._finalized){this._startLoading();for(let s of this._listeners)s.onRasterLoadStart?.(t,r);try{let s=new AbortController;this._abortController=s;let i=await this._opts.getRaster(G_(r,s.signal));if(this._finalized||s.signal.aborted||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:r,raster:i};for(let n of this._listeners)n.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(s){if(z_(s))return;let i=g0(s,"Raster request failed");if(!this._finalized)for(let n of this._listeners)n.onRasterLoadError?.(t,i,r)}finally{this._abortController=null,this._finishLoading()}}}_normalizeOptions(t){let r=t.rasterSource||null;return{...Ur,...t,rasterSource:r,getMetadata:t.getMetadata||(()=>r?r.getMetadata():Ur.getMetadata()),getRaster:t.getRaster||(s=>r?r.getRaster(s):Ur.getRaster(s)),debounceTime:t.debounceTime??Ur.debounceTime,shouldRefetch:t.shouldRefetch||(s=>Ur.shouldRefetch(s))}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_emitLoadingStateChange(t){for(let r of this._listeners)r.onLoadingStateChange?.(t)}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_cancelScheduledRaster(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function G_(e,t){let r=Array.isArray(e)?e.slice():Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e));return Object.defineProperty(r,"signal",{configurable:!0,enumerable:!0,value:t,writable:!0}),r}function g0(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function z_(e){return e instanceof Error&&e.name==="AbortError"}var Ze=class{header;parent;children=[];childrenLoaded=!1;childrenPromise=null;selected=!1;viewportIds=[];content=null;contentAvailable=!1;contentFailed=!1;isContentLoading=!1;constructor(t,r=null){this.header=t,this.parent=r}get id(){return this.header.id}get level(){return this.header.level}get pointCount(){return this.header.pointCount}get geometricError(){return this.header.geometricError}get boundingVolume(){return this.header.boundingVolume}setSelected(t){this.selected=!0,this.viewportIds.includes(t)||this.viewportIds.push(t)}clearSelection(){this.selected=!1,this.viewportIds=[]}};var q_={debounceTime:0,minimumNodePixelSize:150,maximumScreenSpaceError:1,lodSelectionMetricType:"maxScreenThresholdSQ",densityThreshold:1,pointBudget:2e6,maxDepth:Number.POSITIVE_INFINITY,onTileLoad:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{}},_i=64,Mi=class{dataSource;options;root=null;cartographicCenter=null;zoom=1;boundingVolume=null;visibleTilesCount=0;frameNumberValue=0;pendingCount=0;lastUpdatedViewports=null;updatePromise=null;tilesMap=new Map;constructor(t,r={}){this.dataSource=t,this.options={...q_,...r},this.tilesetInitializationPromise=this.initialize()}tilesetInitializationPromise;get isReady(){return this.dataSource.isReady}get frameNumber(){return this.frameNumberValue}get tiles(){return Array.from(this.tilesMap.values())}isLoaded(){return this.frameNumberValue>0&&this.pendingCount===0&&this.selectedTiles.every(t=>t.contentAvailable||t.contentFailed)}selectedTiles=[];update(t=null){this.selectTiles(t).catch(()=>{})}destroy(){this.selectedTiles=[],this.tilesMap.clear(),this.root=null,this.cartographicCenter=null,this.boundingVolume=null,this.visibleTilesCount=0,this.pendingCount=0,this.lastUpdatedViewports=null,this.updatePromise=null}async initialize(){await this.dataSource.initialize();let t=await this.dataSource.getRootTile();this.root=this.getOrCreateTile(t,null);let r=await this.dataSource.getViewState?.();this.boundingVolume=r?.boundingVolume||this.root.boundingVolume;let s=r?.cartographicCenter||this.root.boundingVolume.center;this.cartographicCenter=new _(s),this.zoom=r?.zoom||this.estimateZoom(this.boundingVolume)}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedViewports=t),this.updatePromise||(this.updatePromise=new Promise((r,s)=>{setTimeout(()=>{this.doSelectTiles().then(()=>r(this.frameNumberValue)).catch(s).finally(()=>{this.updatePromise=null})},this.options.debounceTime)})),this.updatePromise}async doSelectTiles(){if(!this.root||!this.lastUpdatedViewports)return;let t=new Set(this.selectedTiles.map(a=>a.id));for(let a of this.tilesMap.values())a.clearSelection();this.frameNumberValue++;let r=Array.isArray(this.lastUpdatedViewports)?this.lastUpdatedViewports:[this.lastUpdatedViewports],s=new Map,i=new Set,n=0;for(let a of r){let h=this.getTraversalContext(a);n=await this.traverseTiles(h,s,n,i)}this.visibleTilesCount=i.size,this.selectedTiles=this.options.onTraversalComplete(Array.from(s.values()));for(let a of this.selectedTiles)this.loadTile(a).catch(()=>{});let o=new Set(this.selectedTiles.map(a=>a.id));this.haveSameIds(t,o)||this.options.onUpdate()}async traverseTiles(t,r,s,i){if(!this.root)return s;let n=s,o=[{tile:this.root,weight:this.estimateScreenRadius(this.root,t.viewport)}];for(;o.length>0;){o.sort((u,f)=>f.weight-u.weight);let a=o.shift();if(!a)break;let{tile:h,weight:c}=a;if(!this.isVisible(h,t))continue;if(i.add(h.id),!r.has(h.id)&&h.pointCount>0){if(n>0&&n+h.pointCount>this.options.pointBudget)break;r.set(h.id,h),n+=h.pointCount}if(r.has(h.id)&&h.setSelected(t.viewport.id),!this.shouldRefine(h,c))continue;let l=await this.getVisibleChildren(h,t);l.length>0&&o.push(...l)}return n}shouldRefine(t,r){if(t.level<this.options.maxDepth&&Number.isFinite(r)&&(t.header.lodSelectionMetricType||this.options.lodSelectionMetricType)==="density-threshold"){let s=Math.max(1,Math.PI*r*r),i=t.pointCount/s,n=t.header.lodThreshold||this.options.densityThreshold;return i<n}return t.level<this.options.maxDepth&&Number.isFinite(r)&&r>=this.options.minimumNodePixelSize}getTraversalContext(t){let r=this.getCullingVolume(t);return{viewport:t,cullingVolume:this.shouldUseCullingVolume(t,r)?r:null}}isVisible(t,r){if(r.cullingVolume){let i=this.getCommonSpaceBoundingSphere(t.boundingVolume,r.viewport);if(i)return this.isBoundingSphereInsideCullingVolume(i,r.cullingVolume)}let s=this.getProjectedFootprint(t.boundingVolume,r.viewport);return s?this.isProjectedFootprintVisible(s,r.viewport):!1}shouldUseCullingVolume(t,r){if(!this.root||!r)return!1;let s=this.getCommonSpaceBoundingSphere(this.root.boundingVolume,t);if(!s)return!1;if(this.isBoundingSphereInsideCullingVolume(s,r))return!0;let i=this.getProjectedFootprint(this.root.boundingVolume,t);return!i||!this.isProjectedFootprintVisible(i,t)}isBoundingSphereInsideCullingVolume(t,r){return r.computeVisibilityWithPlaneMask(t,tt.MASK_INDETERMINATE)!==tt.MASK_OUTSIDE}isProjectedFootprintVisible(t,r){return!(t.x+t.radius<-_i||t.x-t.radius>r.width+_i||t.y+t.radius<-_i||t.y-t.radius>r.height+_i)}estimateScreenRadius(t,r){let s=this.getProjectedFootprint(t.boundingVolume,r);return s?s.radius:0}projectBounds(t,r){let s=this.getBoundingVolumeCorners(t),i=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;try{for(let h of s){let[c,l]=r.project(h);!Number.isFinite(c)||!Number.isFinite(l)||(i=Math.min(i,c),n=Math.min(n,l),o=Math.max(o,c),a=Math.max(a,l))}}catch{return null}return!Number.isFinite(i)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(a)?null:{minX:i,minY:n,maxX:o,maxY:a}}getProjectedFootprint(t,r){let s=Number.NaN,i=Number.NaN;try{[s,i]=r.project(t.center)}catch{return null}if(!Number.isFinite(s)||!Number.isFinite(i))return null;let n=this.getBoundingVolumeCorners(t),o=0;try{for(let a of n){let[h,c]=r.project(a);!Number.isFinite(h)||!Number.isFinite(c)||(o=Math.max(o,Math.hypot(h-s,c-i)))}}catch{return null}if(o===0){let a=this.projectBounds(t,r);a&&(o=Math.max(a.maxX-a.minX,a.maxY-a.minY)/2)}return{x:s,y:i,radius:o}}async getVisibleChildren(t,r){return t.level>=this.options.maxDepth?[]:(await this.getChildren(t)).map(i=>({tile:i,weight:this.estimateScreenRadius(i,r.viewport)})).filter(i=>this.isVisible(i.tile,r))}async getChildren(t){if(t.childrenLoaded)return t.children;if(!t.childrenPromise){let r=this.dataSource.getChildren(t.header).then(s=>s.map(i=>this.getOrCreateTile(i,t))).then(s=>(t.children=s,t.childrenLoaded=!0,s));t.childrenPromise=r.finally(()=>{t.childrenPromise===r&&(t.childrenPromise=null)})}return t.childrenPromise}getOrCreateTile(t,r){let s=this.tilesMap.get(t.id);if(s)return s.header=t,r&&s.parent!==r&&(s.parent=r),s;let i=new Ze(t,r);return this.tilesMap.set(t.id,i),r&&!r.children.find(n=>n.id===i.id)&&r.children.push(i),i}async loadTile(t){if(!(t.contentAvailable||t.isContentLoading||t.contentFailed)){t.isContentLoading=!0,this.pendingCount++;try{let r=await this.dataSource.loadTileContent(t.header);t.content=r,t.contentAvailable=!0,r&&this.options.onTileLoad(t)}catch(r){t.contentFailed=!0,this.options.onTileError(t,r)}finally{t.isContentLoading=!1,this.pendingCount--}}}estimateZoom(t){if(!t||t.coordinateFrame==="cartesian")return 1;let[r,s]=t.cartographicBounds,i=t.coversFullLongitude?360:t.wrapsDateline?360-Math.abs(s[0]-r[0]):Math.abs(s[0]-r[0]),n=Math.max(i,1e-6);return Math.max(1,Math.round(Math.log2(360/n)))}haveSameIds(t,r){if(t.size!==r.size)return!1;for(let s of t)if(!r.has(s))return!1;return!0}getBoundingVolumeCorners(t){let[r,s]=t.cartographicBounds,i=t.coversFullLongitude?[[-180,180]]:t.wrapsDateline?[[r[0],180],[-180,s[0]]]:[[r[0],s[0]]],n=[],o=360-Math.abs(s[0]-r[0]),a=r[0]+o/2;for(let[h,c]of i){let l=d=>{if(!t.wrapsDateline)return d;let m=d;for(;m-a>180;)m-=360;for(;m-a<-180;)m+=360;return m},u=l(h),f=l(c);n.push([u,r[1],r[2]||0],[u,r[1],s[2]||0],[u,s[1],r[2]||0],[u,s[1],s[2]||0],[f,r[1],r[2]||0],[f,r[1],s[2]||0],[f,s[1],r[2]||0],[f,s[1],s[2]||0])}return n}getCullingVolume(t){let r=t.getFrustumPlanes?.bind(t);if(!r)return null;let s=r(),i=["left","right","bottom","top","near","far"],n=[];for(let o of i){let a=s[o];if(!a)return null;n.push(new $(a.normal,-a.distance))}return new tt(n)}getCommonSpaceBoundingSphere(t,r){let s=r.projectPosition?.bind(r);if(!s)return null;let i=this.getBoundingVolumeCorners(t),n=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;try{for(let u of i){let[f,d,m=0]=s(u);!Number.isFinite(f)||!Number.isFinite(d)||!Number.isFinite(m)||(n=Math.min(n,f),o=Math.min(o,d),a=Math.min(a,m),h=Math.max(h,f),c=Math.max(c,d),l=Math.max(l,m))}}catch{return null}return!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(h)||!Number.isFinite(c)||!Number.isFinite(l)?null:new rt().fromCornerPoints([n,o,a],[h,c,l])}};return q0(Vr);})();
|
|
8
11
|
return __exports__;
|
|
9
12
|
});
|