@loaders.gl/tiles 5.0.0-alpha.5 → 5.0.0-alpha.7

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.
Files changed (106) hide show
  1. package/dist/dist.dev.js +5122 -2641
  2. package/dist/dist.min.js +4 -2
  3. package/dist/index.cjs +1670 -403
  4. package/dist/index.cjs.map +3 -3
  5. package/dist/index.d.ts +8 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/spatial/format-spatial-reference.d.ts +1 -0
  10. package/dist/spatial/format-spatial-reference.d.ts.map +1 -1
  11. package/dist/spatial/format-spatial-reference.js +104 -46
  12. package/dist/spatial/format-spatial-reference.js.map +1 -1
  13. package/dist/spatial/get-spatial-coordinate-frame.d.ts +12 -1
  14. package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +1 -1
  15. package/dist/spatial/get-spatial-coordinate-frame.js +105 -24
  16. package/dist/spatial/get-spatial-coordinate-frame.js.map +1 -1
  17. package/dist/spatial/normalize-crs-identifier.d.ts +15 -0
  18. package/dist/spatial/normalize-crs-identifier.d.ts.map +1 -0
  19. package/dist/spatial/normalize-crs-identifier.js +22 -0
  20. package/dist/spatial/normalize-crs-identifier.js.map +1 -0
  21. package/dist/spatial/spatial-coordinate-transformer.d.ts +4 -0
  22. package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -1
  23. package/dist/spatial/spatial-coordinate-transformer.js +89 -12
  24. package/dist/spatial/spatial-coordinate-transformer.js.map +1 -1
  25. package/dist/spatial/tiles-3d-spatial-transformer.d.ts +32 -0
  26. package/dist/spatial/tiles-3d-spatial-transformer.d.ts.map +1 -0
  27. package/dist/spatial/tiles-3d-spatial-transformer.js +175 -0
  28. package/dist/spatial/tiles-3d-spatial-transformer.js.map +1 -0
  29. package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts +3 -3
  30. package/dist/tileset-3d/common/indexed-archive-tileset-source.d.ts.map +1 -1
  31. package/dist/tileset-3d/common/indexed-archive-tileset-source.js.map +1 -1
  32. package/dist/tileset-3d/common/tile-3d-contracts.d.ts +63 -0
  33. package/dist/tileset-3d/common/tile-3d-contracts.d.ts.map +1 -0
  34. package/dist/tileset-3d/common/tile-3d-contracts.js +51 -0
  35. package/dist/tileset-3d/common/tile-3d-contracts.js.map +1 -0
  36. package/dist/tileset-3d/common/tile-3d.d.ts +29 -5
  37. package/dist/tileset-3d/common/tile-3d.d.ts.map +1 -1
  38. package/dist/tileset-3d/common/tile-3d.js +151 -20
  39. package/dist/tileset-3d/common/tile-3d.js.map +1 -1
  40. package/dist/tileset-3d/common/tileset-3d.d.ts +44 -2
  41. package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
  42. package/dist/tileset-3d/common/tileset-3d.js +31 -1
  43. package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
  44. package/dist/tileset-3d/common/tileset-observability.d.ts +60 -0
  45. package/dist/tileset-3d/common/tileset-observability.d.ts.map +1 -0
  46. package/dist/tileset-3d/common/tileset-observability.js +39 -0
  47. package/dist/tileset-3d/common/tileset-observability.js.map +1 -0
  48. package/dist/tileset-3d/common/tileset-source.d.ts +11 -8
  49. package/dist/tileset-3d/common/tileset-source.d.ts.map +1 -1
  50. package/dist/tileset-3d/common/tileset-source.js.map +1 -1
  51. package/dist/tileset-3d/common/tileset-traverser.d.ts +14 -0
  52. package/dist/tileset-3d/common/tileset-traverser.d.ts.map +1 -1
  53. package/dist/tileset-3d/common/tileset-traverser.js +21 -5
  54. package/dist/tileset-3d/common/tileset-traverser.js.map +1 -1
  55. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +47 -1
  56. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -1
  57. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +327 -30
  58. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -1
  59. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +34 -2
  60. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +1 -1
  61. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +265 -14
  62. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +1 -1
  63. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts +70 -3
  64. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -1
  65. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js +216 -4
  66. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js.map +1 -1
  67. package/dist/tileset-3d/format-i3s/i3s-source.d.ts +5 -3
  68. package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +1 -1
  69. package/dist/tileset-3d/format-i3s/i3s-source.js +14 -7
  70. package/dist/tileset-3d/format-i3s/i3s-source.js.map +1 -1
  71. package/dist/tileset-3d/helpers/bounding-volume.d.ts +7 -3
  72. package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +1 -1
  73. package/dist/tileset-3d/helpers/bounding-volume.js +19 -61
  74. package/dist/tileset-3d/helpers/bounding-volume.js.map +1 -1
  75. package/dist/tileset-3d/helpers/frame-state.d.ts +4 -0
  76. package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
  77. package/dist/tileset-3d/helpers/frame-state.js +6 -1
  78. package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
  79. package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts +17 -0
  80. package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +1 -0
  81. package/dist/tileset-3d/helpers/s2-bounding-volume.js +20 -0
  82. package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +1 -0
  83. package/dist/types.d.ts +2 -0
  84. package/dist/types.d.ts.map +1 -1
  85. package/package.json +14 -13
  86. package/src/index.ts +13 -1
  87. package/src/spatial/format-spatial-reference.ts +127 -53
  88. package/src/spatial/get-spatial-coordinate-frame.ts +126 -31
  89. package/src/spatial/normalize-crs-identifier.ts +26 -0
  90. package/src/spatial/spatial-coordinate-transformer.ts +106 -15
  91. package/src/spatial/tiles-3d-spatial-transformer.ts +206 -0
  92. package/src/tileset-3d/common/indexed-archive-tileset-source.ts +4 -9
  93. package/src/tileset-3d/common/tile-3d-contracts.ts +115 -0
  94. package/src/tileset-3d/common/tile-3d.ts +178 -20
  95. package/src/tileset-3d/common/tileset-3d.ts +63 -3
  96. package/src/tileset-3d/common/tileset-observability.ts +100 -0
  97. package/src/tileset-3d/common/tileset-source.ts +11 -12
  98. package/src/tileset-3d/common/tileset-traverser.ts +32 -5
  99. package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +481 -34
  100. package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +390 -17
  101. package/src/tileset-3d/format-3d-tiles/tileset-3d-traverser.ts +243 -4
  102. package/src/tileset-3d/format-i3s/i3s-source.ts +25 -9
  103. package/src/tileset-3d/helpers/bounding-volume.ts +29 -62
  104. package/src/tileset-3d/helpers/frame-state.ts +6 -1
  105. package/src/tileset-3d/helpers/s2-bounding-volume.ts +35 -0
  106. package/src/types.ts +2 -0
package/dist/dist.min.js CHANGED
@@ -4,9 +4,11 @@
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 n0=Object.create;var Ii=Object.defineProperty;var o0=Object.getOwnPropertyDescriptor;var a0=Object.getOwnPropertyNames;var h0=Object.getPrototypeOf,c0=Object.prototype.hasOwnProperty;var l0=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(i){throw t=0,i}},cr=(e,t)=>{for(var i in t)Ii(e,i,{get:t[i],enumerable:!0})},Ai=(e,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of a0(t))!c0.call(e,r)&&r!==i&&Ii(e,r,{get:()=>t[r],enumerable:!(s=o0(t,r))||s.enumerable});return e},Oi=(e,t,i)=>(Ai(e,t,"default"),i&&Ai(i,t,"default")),u0=(e,t,i)=>(i=e!=null?n0(h0(e)):{},Ai(t||!e||!e.__esModule?Ii(i,"default",{value:e,enumerable:!0}):i,e)),f0=e=>Ai(Ii({},"__esModule",{value:!0}),e);var Xn=l0((u2,Zn)=>{Zn.exports=globalThis.loaders});var Ri={};cr(Ri,{I3SSource:()=>$s,I3SSpatialTransformer:()=>Be,ImageSet:()=>Ks,IndexedArchiveTilesetSource:()=>_s,LOD_METRIC_TYPE:()=>ye,PointCloudTile:()=>De,PointCloudTileset:()=>er,RasterSet:()=>Js,STRATEGY_DEFAULT:()=>Pi,STRATEGY_NEVER:()=>jn,STRATEGY_REPLACE:()=>Wn,SharedTile2DHeader:()=>le,SpatialCoordinateTransformer:()=>$t,TILESET_TYPE:()=>at,TILE_CONTENT_STATE:()=>et,TILE_REFINEMENT:()=>tt,TILE_TYPE:()=>Lt,Tile3D:()=>Et,Tiles3DSource:()=>Ts,Tileset2D:()=>Ti,Tileset3D:()=>gs,TilesetCache:()=>xe,TilesetTraverser:()=>Gt,applyTilesetSpatialOptions:()=>ei,calculateTransformProps:()=>ls,createBoundingVolume:()=>Se,createImplicitSubtreeReference:()=>nn,createTilesetSpatialReference:()=>vt,get3DTilesSpatialReference:()=>vs,getFrameState:()=>us,getGeoidModel:()=>Zs,getI3SSpatialReference:()=>Ss,getLodStatus:()=>xs,getSpatialCoordinateFrame:()=>Vt,isTileset3DSource:()=>ps,markTilesetSpatialReferenceTransformed:()=>ds,materializeImplicitSubtree:()=>Es,registerGeoidModel:()=>Bn,registerGeoidModelFromPgm:()=>Nl,registerSpatialCrs:()=>Il,registerSpatialDatumGrid:()=>Ol,replaceImplicitUrlTemplate:()=>ws});Oi(Ri,u0(Xn(),1));var q={};cr(q,{EPSILON1:()=>m0,EPSILON10:()=>v0,EPSILON11:()=>E0,EPSILON12:()=>w0,EPSILON13:()=>T0,EPSILON14:()=>Ni,EPSILON15:()=>P0,EPSILON16:()=>b0,EPSILON17:()=>R0,EPSILON18:()=>C0,EPSILON19:()=>A0,EPSILON2:()=>d0,EPSILON20:()=>I0,EPSILON3:()=>p0,EPSILON4:()=>g0,EPSILON5:()=>_0,EPSILON6:()=>M0,EPSILON7:()=>x0,EPSILON8:()=>y0,EPSILON9:()=>S0,PI:()=>ue,PI_OVER_FOUR:()=>N0,PI_OVER_SIX:()=>L0,PI_OVER_TWO:()=>O0,TWO_PI:()=>Fe});var m0=.1,d0=.01,p0=.001,g0=1e-4,_0=1e-5,M0=1e-6,x0=1e-7,y0=1e-8,S0=1e-9,v0=1e-10,E0=1e-11,w0=1e-12,T0=1e-13,Ni=1e-14,P0=1e-15,b0=1e-16,R0=1e-17,C0=1e-18,A0=1e-19,I0=1e-20,O0=Math.PI/2,N0=Math.PI/4,L0=Math.PI/6,ue=Math.PI,Fe=Math.PI*2;var G0=1/Math.PI*180,z0=1/180*Math.PI,q0={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...q0}};var k=globalThis.mathgl.config;function lr(e,{precision:t=k.precision}={}){return e=D0(e),`${parseFloat(e.toPrecision(t))}`}function Ot(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ur(e){return Li(e)}function fr(e){return ot(e)}function Li(e,t){return dr(e,i=>i*z0,t)}function ot(e,t){return dr(e,i=>i*G0,t)}function $n(e,t){return Math.sign(e)===Math.sign(t)&&Math.abs(e)<Math.abs(t)?e:(e%t+t)%t}function mr(e,t){switch(t){case"negative-pi-to-pi":return B0(e);case"zero-to-two-pi":return Qn(e);default:return e}}function Qn(e){if(e>=0&&e<=Fe)return e;let t=$n(e,Fe);return Math.abs(t)<1e-14&&Math.abs(e)>1e-14?Fe:t}function B0(e){return e>=-ue&&e<=ue?e:Qn(e+ue)-ue}function Ue(e,t,i){return dr(e,s=>Math.max(t,Math.min(i,s)))}function pt(e,t,i){let s=k.EPSILON;i&&(k.EPSILON=i);try{if(e===t)return!0;if(Ot(e)&&Ot(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!pt(e[r],t[r]))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 D0(e){return Math.round(e/k.EPSILON)*k.EPSILON}function F0(e){return e.clone?e.clone():new Array(e.length)}function dr(e,t,i){if(Ot(e)){let s=e;i=i||F0(s);for(let r=0;r<i.length&&r<s.length;++r){let n=typeof e=="number"?e:e[r];i[r]=t(n,r,i)}return i}return t(e)}var Qt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,i=0){for(let s=0;s<this.ELEMENTS;++s)this[s]=t[s+i];return this.check()}toArray(t=[],i=0){for(let s=0;s<this.ELEMENTS;++s)t[i+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:Ot(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(k)}formatString(t){let i="";for(let s=0;s<this.ELEMENTS;++s)i+=(s>0?", ":"")+lr(this[s],t);return`${t.printTypes?this.constructor.name:""}[${i}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(!pt(this[i],t[i]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(this[i]!==t[i])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,i,s){if(s===void 0)return this.lerp(this,t,i);for(let r=0;r<this.ELEMENTS;++r){let n=t[r],o=typeof i=="number"?i:i[r];this[r]=n+s*(o-n)}return this.check()}min(t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(t[i],this[i]);return this.check()}max(t){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.max(t[i],this[i]);return this.check()}clamp(t,i){for(let s=0;s<this.ELEMENTS;++s)this[s]=Math.min(Math.max(this[s],t[s]),i[s]);return this.check()}add(...t){for(let i of t)for(let s=0;s<this.ELEMENTS;++s)this[s]+=i[s];return this.check()}subtract(...t){for(let i of t)for(let s=0;s<this.ELEMENTS;++s)this[s]-=i[s];return this.check()}scale(t){if(typeof t=="number")for(let i=0;i<this.ELEMENTS;++i)this[i]*=t;else for(let i=0;i<this.ELEMENTS&&i<t.length;++i)this[i]*=t[i];return this.check()}multiplyByScalar(t){for(let i=0;i<this.ELEMENTS;++i)this[i]*=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 i=0;i<this.ELEMENTS;++i)t=t&&Number.isFinite(this[i]);return t}};function U0(e,t){if(e.length!==t)return!1;for(let i=0;i<e.length;++i)if(!Number.isFinite(e[i]))return!1;return!0}function F(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function fe(e,t,i=""){if(k.debug&&!U0(e,t))throw new Error(`math.gl: ${i} some fields set to invalid numbers'`);return e}var me=class extends Qt{toString(){let t="[";if(k.printRowMajor){t+="row-major:";for(let i=0;i<this.RANK;++i)for(let s=0;s<this.RANK;++s)t+=` ${this[s*this.RANK+i]}`}else{t+="column-major:";for(let i=0;i<this.ELEMENTS;++i)t+=` ${this[i]}`}return t+="]",t}getElementIndex(t,i){return i*this.RANK+t}getElement(t,i){return this[i*this.RANK+t]}setElement(t,i,s){return this[i*this.RANK+t]=F(s),this}getColumn(t,i=new Array(this.RANK).fill(-0)){let s=t*this.RANK;for(let r=0;r<this.RANK;++r)i[r]=this[s+r];return i}setColumn(t,i){let s=t*this.RANK;for(let r=0;r<this.RANK;++r)this[s+r]=i[r];return this}};function Q(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var de=class extends Qt{get x(){return this[0]}set x(t){this[0]=F(t)}get y(){return this[1]}set y(t){this[1]=F(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let i=0;i<this.ELEMENTS;++i)t+=this[i]*this[i];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let i=0;for(let s=0;s<this.ELEMENTS;++s){let r=this[s]-t[s];i+=r*r}return F(i)}dot(t){let i=0;for(let s=0;s<this.ELEMENTS;++s)i+=this[s]*t[s];return F(i)}normalize(){let t=this.magnitude();if(t!==0)for(let i=0;i<this.ELEMENTS;++i)this[i]/=t;return this.check()}multiply(...t){for(let i of t)for(let s=0;s<this.ELEMENTS;++s)this[s]*=i[s];return this.check()}divide(...t){for(let i of t)for(let s=0;s<this.ELEMENTS;++s)this[s]/=i[s];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Q(t>=0&&t<this.ELEMENTS,"index is out of range"),F(this[t])}setComponent(t,i){return Q(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=i,this.check()}addVectors(t,i){return this.copy(t).add(i)}subVectors(t,i){return this.copy(t).subtract(i)}multiplyVectors(t,i){return this.copy(t).multiply(i)}addScaledVector(t,i){for(let s=0;s<this.ELEMENTS;++s)this[s]+=t[s]*i;return this.check()}};var Gi=typeof Float32Array<"u"?Float32Array:Array;var b2=Math.PI/180;function Kn(e,t,i){let s=t[0],r=t[1];return e[0]=i[0]*s+i[2]*r,e[1]=i[1]*s+i[3]*r,e}function Jn(e,t,i){let s=t[0],r=t[1];return e[0]=i[0]*s+i[2]*r+i[4],e[1]=i[1]*s+i[3]*r+i[5],e}function zi(e,t,i){let s=t[0],r=t[1];return e[0]=i[0]*s+i[3]*r+i[6],e[1]=i[1]*s+i[4]*r+i[7],e}function qi(e,t,i){let s=t[0],r=t[1];return e[0]=i[0]*s+i[4]*r+i[12],e[1]=i[1]*s+i[5]*r+i[13],e}function Bi(e,t,i){let s=t[0],r=t[1],n=i[3]*s+i[7]*r||1;return e[0]=(i[0]*s+i[4]*r)/n,e[1]=(i[1]*s+i[5]*r)/n,e}function Di(e,t,i){let s=t[0],r=t[1],n=t[2],o=i[3]*s+i[7]*r+i[11]*n||1;return e[0]=(i[0]*s+i[4]*r+i[8]*n)/o,e[1]=(i[1]*s+i[5]*r+i[9]*n)/o,e[2]=(i[2]*s+i[6]*r+i[10]*n)/o,e}function to(e,t,i){let s=t[0],r=t[1];return e[0]=i[0]*s+i[2]*r,e[1]=i[1]*s+i[3]*r,e[2]=t[2],e}function eo(e,t,i){let s=t[0],r=t[1],n=t[2];return e[0]=i[0]*s+i[3]*r+i[6]*n,e[1]=i[1]*s+i[4]*r+i[7]*n,e[2]=i[2]*s+i[5]*r+i[8]*n,e[3]=t[3],e}var xt=class extends de{constructor(t=0,i=0){super(2),Ot(t)&&arguments.length===1?this.copy(t):(k.debug&&(F(t),F(i)),this[0]=t,this[1]=i)}set(t,i){return this[0]=t,this[1]=i,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this.check()}fromObject(t){return k.debug&&(F(t.x),F(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 qi(this,this,t),this.check()}transformAsVector(t){return Bi(this,this,t),this.check()}transformByMatrix3(t){return zi(this,this,t),this.check()}transformByMatrix2x3(t){return Jn(this,this,t),this.check()}transformByMatrix2(t){return Kn(this,this,t),this.check()}};function io(){let e=new Gi(3);return Gi!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function pr(e){let t=e[0],i=e[1],s=e[2];return Math.sqrt(t*t+i*i+s*s)}function gr(e,t,i){let s=new Gi(3);return s[0]=e,s[1]=t,s[2]=i,s}function so(e,t){let i=t[0],s=t[1],r=t[2],n=i*i+s*s+r*r;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 ke(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function pe(e,t,i){let s=t[0],r=t[1],n=t[2],o=i[0],a=i[1],h=i[2];return e[0]=r*h-n*a,e[1]=n*o-s*h,e[2]=s*a-r*o,e}function Fi(e,t,i){let s=t[0],r=t[1],n=t[2],o=i[3]*s+i[7]*r+i[11]*n+i[15];return o=o||1,e[0]=(i[0]*s+i[4]*r+i[8]*n+i[12])/o,e[1]=(i[1]*s+i[5]*r+i[9]*n+i[13])/o,e[2]=(i[2]*s+i[6]*r+i[10]*n+i[14])/o,e}function Ui(e,t,i){let s=t[0],r=t[1],n=t[2];return e[0]=s*i[0]+r*i[3]+n*i[6],e[1]=s*i[1]+r*i[4]+n*i[7],e[2]=s*i[2]+r*i[5]+n*i[8],e}function ro(e,t,i){let s=i[0],r=i[1],n=i[2],o=i[3],a=t[0],h=t[1],c=t[2],l=r*c-n*h,u=n*a-s*c,f=s*h-r*a,d=r*f-n*u,m=n*l-s*f,g=s*u-r*l,_=o*2;return l*=_,u*=_,f*=_,d*=2,m*=2,g*=2,e[0]=a+l+d,e[1]=h+u+m,e[2]=c+f+g,e}function no(e,t,i,s){let r=[],n=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],n[0]=r[0],n[1]=r[1]*Math.cos(s)-r[2]*Math.sin(s),n[2]=r[1]*Math.sin(s)+r[2]*Math.cos(s),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function oo(e,t,i,s){let r=[],n=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],n[0]=r[2]*Math.sin(s)+r[0]*Math.cos(s),n[1]=r[1],n[2]=r[2]*Math.cos(s)-r[0]*Math.sin(s),e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function ao(e,t,i,s){let r=[],n=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],n[0]=r[0]*Math.cos(s)-r[1]*Math.sin(s),n[1]=r[0]*Math.sin(s)+r[1]*Math.cos(s),n[2]=r[2],e[0]=n[0]+i[0],e[1]=n[1]+i[1],e[2]=n[2]+i[2],e}function ho(e,t){let i=e[0],s=e[1],r=e[2],n=t[0],o=t[1],a=t[2],h=Math.sqrt((i*i+s*s+r*r)*(n*n+o*o+a*a)),c=h&&ke(e,t)/h;return Math.acos(Math.min(Math.max(c,-1),1))}var co=pr;var _r=[0,0,0],Vi,p=class e extends de{static get ZERO(){return Vi||(Vi=new e(0,0,0),Object.freeze(Vi)),Vi}constructor(t=0,i=0,s=0){super(-0,-0,-0),arguments.length===1&&Ot(t)?this.copy(t):(k.debug&&(F(t),F(i),F(s)),this[0]=t,this[1]=i,this[2]=s)}set(t,i,s){return this[0]=t,this[1]=i,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&&(F(t.x),F(t.y),F(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]=F(t)}angle(t){return ho(this,t)}cross(t){return pe(this,this,t),this.check()}rotateX({radians:t,origin:i=_r}){return no(this,this,i,t),this.check()}rotateY({radians:t,origin:i=_r}){return oo(this,this,i,t),this.check()}rotateZ({radians:t,origin:i=_r}){return ao(this,this,i,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Fi(this,this,t),this.check()}transformAsVector(t){return Di(this,this,t),this.check()}transformByMatrix3(t){return Ui(this,this,t),this.check()}transformByMatrix2(t){return to(this,this,t),this.check()}transformByQuaternion(t){return ro(this,this,t),this.check()}};function lo(e,t){if(e===t){let i=t[1],s=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=s,e[7]=r}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 uo(e,t){let i=t[0],s=t[1],r=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=i*u+s*f+r*d;return m?(m=1/m,e[0]=u*m,e[1]=(-l*s+r*c)*m,e[2]=(a*s-r*o)*m,e[3]=f*m,e[4]=(l*i-r*h)*m,e[5]=(-a*i+r*n)*m,e[6]=d*m,e[7]=(-c*i+s*h)*m,e[8]=(o*i-s*n)*m,e):null}function fo(e){let t=e[0],i=e[1],s=e[2],r=e[3],n=e[4],o=e[5],a=e[6],h=e[7],c=e[8];return t*(c*n-o*h)+i*(-c*r+o*a)+s*(h*r-n*a)}function Mr(e,t,i){let s=t[0],r=t[1],n=t[2],o=t[3],a=t[4],h=t[5],c=t[6],l=t[7],u=t[8],f=i[0],d=i[1],m=i[2],g=i[3],_=i[4],M=i[5],y=i[6],E=i[7],w=i[8];return e[0]=f*s+d*o+m*c,e[1]=f*r+d*a+m*l,e[2]=f*n+d*h+m*u,e[3]=g*s+_*o+M*c,e[4]=g*r+_*a+M*l,e[5]=g*n+_*h+M*u,e[6]=y*s+E*o+w*c,e[7]=y*r+E*a+w*l,e[8]=y*n+E*h+w*u,e}function mo(e,t,i){let s=t[0],r=t[1],n=t[2],o=t[3],a=t[4],h=t[5],c=t[6],l=t[7],u=t[8],f=i[0],d=i[1];return e[0]=s,e[1]=r,e[2]=n,e[3]=o,e[4]=a,e[5]=h,e[6]=f*s+d*o+c,e[7]=f*r+d*a+l,e[8]=f*n+d*h+u,e}function po(e,t,i){let s=t[0],r=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(i),d=Math.cos(i);return e[0]=d*s+f*o,e[1]=d*r+f*a,e[2]=d*n+f*h,e[3]=d*o-f*s,e[4]=d*a-f*r,e[5]=d*h-f*n,e[6]=c,e[7]=l,e[8]=u,e}function xr(e,t,i){let s=i[0],r=i[1];return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=r*t[3],e[4]=r*t[4],e[5]=r*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function go(e,t){let i=t[0],s=t[1],r=t[2],n=t[3],o=i+i,a=s+s,h=r+r,c=i*o,l=s*o,u=s*a,f=r*o,d=r*a,m=r*h,g=n*o,_=n*a,M=n*h;return e[0]=1-u-m,e[3]=l-M,e[6]=f+_,e[1]=l+M,e[4]=1-c-m,e[7]=d-g,e[2]=f-_,e[5]=d+g,e[8]=1-c-u,e}var yr;(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"})(yr||(yr={}));var j0=Object.freeze([1,0,0,0,1,0,0,0,1]),U=class extends me{static get IDENTITY(){return H0()}static get ZERO(){return W0()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return yr}constructor(t){super(-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.check()}identity(){return this.copy(j0)}fromObject(t){return this.check()}fromQuaternion(t){return go(this,t),this.check()}fromMatrix4(t){return this.set(t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10])}set(t,i,s,r,n,o,a,h,c){return this[0]=t,this[1]=i,this[2]=s,this[3]=r,this[4]=n,this[5]=o,this[6]=a,this[7]=h,this[8]=c,this.check()}setRowMajor(t,i,s,r,n,o,a,h,c){return this[0]=t,this[1]=r,this[2]=a,this[3]=i,this[4]=n,this[5]=h,this[6]=s,this[7]=o,this[8]=c,this.check()}determinant(){return fo(this)}transpose(){return lo(this,this),this.check()}invert(){return uo(this,this),this.check()}multiplyLeft(t){return Mr(this,t,this),this.check()}multiplyRight(t){return Mr(this,this,t),this.check()}rotate(t){return po(this,this,t),this.check()}scale(t){return Array.isArray(t)?xr(this,this,t):xr(this,this,[t,t]),this.check()}translate(t){return mo(this,this,t),this.check()}transform(t,i){let s;switch(t.length){case 2:s=zi(i||[-0,-0],t,this);break;case 3:s=Ui(i||[-0,-0,-0],t,this);break;case 4:s=eo(i||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return fe(s,t.length),s}},ki,ji=null;function W0(){return ki||(ki=new U([0,0,0,0,0,0,0,0,0]),Object.freeze(ki)),ki}function H0(){return ji||(ji=new U,Object.freeze(ji)),ji}function Y0(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 _o(e,t){if(e===t){let i=t[1],s=t[2],r=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]=i,e[6]=t[9],e[7]=t[13],e[8]=s,e[9]=n,e[11]=t[14],e[12]=r,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 Mo(e,t){let i=t[0],s=t[1],r=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],_=t[14],M=t[15],y=i*a-s*o,E=i*h-r*o,w=i*c-n*o,T=s*h-r*a,P=s*c-n*a,R=r*c-n*h,A=l*g-u*m,C=l*_-f*m,G=l*M-d*m,L=u*_-f*g,D=u*M-d*g,H=f*M-d*_,N=y*H-E*D+w*L+T*G-P*C+R*A;return N?(N=1/N,e[0]=(a*H-h*D+c*L)*N,e[1]=(r*D-s*H-n*L)*N,e[2]=(g*R-_*P+M*T)*N,e[3]=(f*P-u*R-d*T)*N,e[4]=(h*G-o*H-c*C)*N,e[5]=(i*H-r*G+n*C)*N,e[6]=(_*w-m*R-M*E)*N,e[7]=(l*R-f*w+d*E)*N,e[8]=(o*D-a*G+c*A)*N,e[9]=(s*G-i*D-n*A)*N,e[10]=(m*P-g*w+M*y)*N,e[11]=(u*w-l*P-d*y)*N,e[12]=(a*C-o*L-h*A)*N,e[13]=(i*L-s*C+r*A)*N,e[14]=(g*E-m*T-_*y)*N,e[15]=(l*T-u*E+f*y)*N,e):null}function xo(e){let t=e[0],i=e[1],s=e[2],r=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],_=e[15],M=t*o-i*n,y=t*a-s*n,E=i*a-s*o,w=c*m-l*d,T=c*g-u*d,P=l*g-u*m,R=t*P-i*T+s*w,A=n*P-o*T+a*w,C=c*E-l*y+u*M,G=d*E-m*y+g*M;return h*R-r*A+_*C-f*G}function Sr(e,t,i){let s=t[0],r=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],_=t[13],M=t[14],y=t[15],E=i[0],w=i[1],T=i[2],P=i[3];return e[0]=E*s+w*a+T*u+P*g,e[1]=E*r+w*h+T*f+P*_,e[2]=E*n+w*c+T*d+P*M,e[3]=E*o+w*l+T*m+P*y,E=i[4],w=i[5],T=i[6],P=i[7],e[4]=E*s+w*a+T*u+P*g,e[5]=E*r+w*h+T*f+P*_,e[6]=E*n+w*c+T*d+P*M,e[7]=E*o+w*l+T*m+P*y,E=i[8],w=i[9],T=i[10],P=i[11],e[8]=E*s+w*a+T*u+P*g,e[9]=E*r+w*h+T*f+P*_,e[10]=E*n+w*c+T*d+P*M,e[11]=E*o+w*l+T*m+P*y,E=i[12],w=i[13],T=i[14],P=i[15],e[12]=E*s+w*a+T*u+P*g,e[13]=E*r+w*h+T*f+P*_,e[14]=E*n+w*c+T*d+P*M,e[15]=E*o+w*l+T*m+P*y,e}function yo(e,t,i){let s=i[0],r=i[1],n=i[2],o,a,h,c,l,u,f,d,m,g,_,M;return t===e?(e[12]=t[0]*s+t[4]*r+t[8]*n+t[12],e[13]=t[1]*s+t[5]*r+t[9]*n+t[13],e[14]=t[2]*s+t[6]*r+t[10]*n+t[14],e[15]=t[3]*s+t[7]*r+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],_=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]=_,e[11]=M,e[12]=o*s+l*r+m*n+t[12],e[13]=a*s+u*r+g*n+t[13],e[14]=h*s+f*r+_*n+t[14],e[15]=c*s+d*r+M*n+t[15]),e}function So(e,t,i){let s=i[0],r=i[1],n=i[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]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,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 vo(e,t,i,s){let r=s[0],n=s[1],o=s[2],a=Math.sqrt(r*r+n*n+o*o),h,c,l,u,f,d,m,g,_,M,y,E,w,T,P,R,A,C,G,L,D,H,N,At;return a<1e-6?null:(a=1/a,r*=a,n*=a,o*=a,c=Math.sin(i),h=Math.cos(i),l=1-h,u=t[0],f=t[1],d=t[2],m=t[3],g=t[4],_=t[5],M=t[6],y=t[7],E=t[8],w=t[9],T=t[10],P=t[11],R=r*r*l+h,A=n*r*l+o*c,C=o*r*l-n*c,G=r*n*l-o*c,L=n*n*l+h,D=o*n*l+r*c,H=r*o*l+n*c,N=n*o*l-r*c,At=o*o*l+h,e[0]=u*R+g*A+E*C,e[1]=f*R+_*A+w*C,e[2]=d*R+M*A+T*C,e[3]=m*R+y*A+P*C,e[4]=u*G+g*L+E*D,e[5]=f*G+_*L+w*D,e[6]=d*G+M*L+T*D,e[7]=m*G+y*L+P*D,e[8]=u*H+g*N+E*At,e[9]=f*H+_*N+w*At,e[10]=d*H+M*N+T*At,e[11]=m*H+y*N+P*At,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Eo(e,t,i){let s=Math.sin(i),r=Math.cos(i),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*r+c*s,e[5]=o*r+l*s,e[6]=a*r+u*s,e[7]=h*r+f*s,e[8]=c*r-n*s,e[9]=l*r-o*s,e[10]=u*r-a*s,e[11]=f*r-h*s,e}function wo(e,t,i){let s=Math.sin(i),r=Math.cos(i),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*r-c*s,e[1]=o*r-l*s,e[2]=a*r-u*s,e[3]=h*r-f*s,e[8]=n*s+c*r,e[9]=o*s+l*r,e[10]=a*s+u*r,e[11]=h*s+f*r,e}function To(e,t,i){let s=Math.sin(i),r=Math.cos(i),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*r+c*s,e[1]=o*r+l*s,e[2]=a*r+u*s,e[3]=h*r+f*s,e[4]=c*r-n*s,e[5]=l*r-o*s,e[6]=u*r-a*s,e[7]=f*r-h*s,e}function Po(e,t){let i=t[0],s=t[1],r=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(i*i+s*s+r*r),e[1]=Math.sqrt(n*n+o*o+a*a),e[2]=Math.sqrt(h*h+c*c+l*l),e}function bo(e,t){let i=t[0],s=t[1],r=t[2],n=t[3],o=i+i,a=s+s,h=r+r,c=i*o,l=s*o,u=s*a,f=r*o,d=r*a,m=r*h,g=n*o,_=n*a,M=n*h;return e[0]=1-u-m,e[1]=l+M,e[2]=f-_,e[3]=0,e[4]=l-M,e[5]=1-c-m,e[6]=d+g,e[7]=0,e[8]=f+_,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 Ro(e,t,i,s,r,n,o){let a=1/(i-t),h=1/(r-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]=(i+t)*a,e[9]=(r+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 Z0(e,t,i,s,r){let n=1/Math.tan(t/2);if(e[0]=n/i,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,r!=null&&r!==1/0){let o=1/(s-r);e[10]=(r+s)*o,e[14]=2*r*s*o}else e[10]=-1,e[14]=-2*s;return e}var Co=Z0;function X0(e,t,i,s,r,n,o){let a=1/(t-i),h=1/(s-r),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+i)*a,e[13]=(r+s)*h,e[14]=(o+n)*c,e[15]=1,e}var Ao=X0;function Io(e,t,i,s){let r,n,o,a,h,c,l,u,f,d,m=t[0],g=t[1],_=t[2],M=s[0],y=s[1],E=s[2],w=i[0],T=i[1],P=i[2];return Math.abs(m-w)<1e-6&&Math.abs(g-T)<1e-6&&Math.abs(_-P)<1e-6?Y0(e):(u=m-w,f=g-T,d=_-P,r=1/Math.sqrt(u*u+f*f+d*d),u*=r,f*=r,d*=r,n=y*d-E*f,o=E*u-M*d,a=M*f-y*u,r=Math.sqrt(n*n+o*o+a*a),r?(r=1/r,n*=r,o*=r,a*=r):(n=0,o=0,a=0),h=f*a-d*o,c=d*n-u*a,l=u*o-f*n,r=Math.sqrt(h*h+c*c+l*l),r?(r=1/r,h*=r,c*=r,l*=r):(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*_),e[13]=-(h*m+c*g+l*_),e[14]=-(u*m+f*g+d*_),e[15]=1,e)}function Oo(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e}function No(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function Lo(e){let t=e[0],i=e[1],s=e[2],r=e[3];return Math.sqrt(t*t+i*i+s*s+r*r)}function Go(e){let t=e[0],i=e[1],s=e[2],r=e[3];return t*t+i*i+s*s+r*r}function zo(e,t){let i=t[0],s=t[1],r=t[2],n=t[3],o=i*i+s*s+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=i*o,e[1]=s*o,e[2]=r*o,e[3]=n*o,e}function qo(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Bo(e,t,i,s){let r=t[0],n=t[1],o=t[2],a=t[3];return e[0]=r+s*(i[0]-r),e[1]=n+s*(i[1]-n),e[2]=o+s*(i[2]-o),e[3]=a+s*(i[3]-a),e}function Do(e,t,i){let s=t[0],r=t[1],n=t[2],o=t[3];return e[0]=i[0]*s+i[4]*r+i[8]*n+i[12]*o,e[1]=i[1]*s+i[5]*r+i[9]*n+i[13]*o,e[2]=i[2]*s+i[6]*r+i[10]*n+i[14]*o,e[3]=i[3]*s+i[7]*r+i[11]*n+i[15]*o,e}var wr;(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"})(wr||(wr={}));var Q0=45*Math.PI/180,K0=1,vr=.1,Er=500,J0=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),I=class extends me{static get IDENTITY(){return eu()}static get ZERO(){return tu()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return wr}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,i,s,r,n,o,a,h,c,l,u,f,d,m,g,_){return this[0]=t,this[1]=i,this[2]=s,this[3]=r,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]=_,this.check()}setRowMajor(t,i,s,r,n,o,a,h,c,l,u,f,d,m,g,_){return this[0]=t,this[1]=n,this[2]=c,this[3]=d,this[4]=i,this[5]=o,this[6]=l,this[7]=m,this[8]=s,this[9]=a,this[10]=u,this[11]=g,this[12]=r,this[13]=h,this[14]=f,this[15]=_,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(J0)}fromObject(t){return this.check()}fromQuaternion(t){return bo(this,t),this.check()}fromMatrix3(t){return this.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1)}frustum(t){let{left:i,right:s,bottom:r,top:n,near:o=vr,far:a=Er}=t;return a===1/0?iu(this,i,s,r,n,o):Ro(this,i,s,r,n,o,a),this.check()}lookAt(t){let{eye:i,center:s=[0,0,0],up:r=[0,1,0]}=t;return Io(this,i,s,r),this.check()}ortho(t){let{left:i,right:s,bottom:r,top:n,near:o=vr,far:a=Er}=t;return Ao(this,i,s,r,n,o,a),this.check()}orthographic(t){let{fovy:i=Q0,aspect:s=K0,focalDistance:r=1,near:n=vr,far:o=Er}=t;Fo(i);let a=i/2,h=r*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:i=45*Math.PI/180,aspect:s=1,near:r=.1,far:n=500}=t;return Fo(i),Co(this,i,s,r,n),this.check()}determinant(){return xo(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,i){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];let s=this.getScale(i),r=1/s[0],n=1/s[1],o=1/s[2];return t[0]=this[0]*r,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*r,t[5]=this[5]*n,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*r,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,i){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];let s=this.getScale(i),r=1/s[0],n=1/s[1],o=1/s[2];return t[0]=this[0]*r,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=this[4]*r,t[4]=this[5]*n,t[5]=this[6]*o,t[6]=this[8]*r,t[7]=this[9]*n,t[8]=this[10]*o,t}transpose(){return _o(this,this),this.check()}invert(){return Mo(this,this),this.check()}multiplyLeft(t){return Sr(this,t,this),this.check()}multiplyRight(t){return Sr(this,this,t),this.check()}rotateX(t){return Eo(this,this,t),this.check()}rotateY(t){return wo(this,this,t),this.check()}rotateZ(t){return To(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,i){return vo(this,this,t,i),this.check()}scale(t){return So(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return yo(this,this,t),this.check()}transform(t,i){return t.length===4?(i=Do(i||[-0,-0,-0,-0],t,this),fe(i,4),i):this.transformAsPoint(t,i)}transformAsPoint(t,i){let{length:s}=t,r;switch(s){case 2:r=qi(i||[-0,-0],t,this);break;case 3:r=Fi(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return fe(r,t.length),r}transformAsVector(t,i){let s;switch(t.length){case 2:s=Bi(i||[-0,-0],t,this);break;case 3:s=Di(i||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return fe(s,t.length),s}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,i,s){return this.identity().translate([t,i,s])}},Wi,Hi;function tu(){return Wi||(Wi=new I([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Wi)),Wi}function eu(){return Hi||(Hi=new I,Object.freeze(Hi)),Hi}function Fo(e){if(e>Math.PI*2)throw Error("expected radians")}function iu(e,t,i,s,r,n){let o=2*n/(i-t),a=2*n/(r-s),h=(i+t)/(i-t),c=(r+s)/(r-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 Uo(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Tr(e,t,i){i=i*.5;let s=Math.sin(i);return e[0]=s*t[0],e[1]=s*t[1],e[2]=s*t[2],e[3]=Math.cos(i),e}function Pr(e,t,i){let s=t[0],r=t[1],n=t[2],o=t[3],a=i[0],h=i[1],c=i[2],l=i[3];return e[0]=s*l+o*a+r*c-n*h,e[1]=r*l+o*h+n*a-s*c,e[2]=n*l+o*c+s*h-r*a,e[3]=o*l-s*a-r*h-n*c,e}function Vo(e,t,i){i*=.5;let s=t[0],r=t[1],n=t[2],o=t[3],a=Math.sin(i),h=Math.cos(i);return e[0]=s*h+o*a,e[1]=r*h+n*a,e[2]=n*h-r*a,e[3]=o*h-s*a,e}function ko(e,t,i){i*=.5;let s=t[0],r=t[1],n=t[2],o=t[3],a=Math.sin(i),h=Math.cos(i);return e[0]=s*h-n*a,e[1]=r*h+o*a,e[2]=n*h+s*a,e[3]=o*h-r*a,e}function jo(e,t,i){i*=.5;let s=t[0],r=t[1],n=t[2],o=t[3],a=Math.sin(i),h=Math.cos(i);return e[0]=s*h+r*a,e[1]=r*h-s*a,e[2]=n*h+o*a,e[3]=o*h-n*a,e}function Wo(e,t){let i=t[0],s=t[1],r=t[2];return e[0]=i,e[1]=s,e[2]=r,e[3]=Math.sqrt(Math.abs(1-i*i-s*s-r*r)),e}function Ho(e,t,i,s){let r=t[0],n=t[1],o=t[2],a=t[3],h=i[0],c=i[1],l=i[2],u=i[3],f,d,m,g,_;return f=r*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),_=Math.sin(d),m=Math.sin((1-s)*d)/_,g=Math.sin(s*d)/_):(m=1-s,g=s),e[0]=m*r+g*h,e[1]=m*n+g*c,e[2]=m*o+g*l,e[3]=m*a+g*u,e}function Yo(e,t){let i=t[0],s=t[1],r=t[2],n=t[3],o=i*i+s*s+r*r+n*n,a=o?1/o:0;return e[0]=-i*a,e[1]=-s*a,e[2]=-r*a,e[3]=n*a,e}function Zo(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Xo(e,t){let i=t[0]+t[4]+t[8],s;if(i>0)s=Math.sqrt(i+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 r=0;t[4]>t[0]&&(r=1),t[8]>t[r*3+r]&&(r=2);let n=(r+1)%3,o=(r+2)%3;s=Math.sqrt(t[r*3+r]-t[n*3+n]-t[o*3+o]+1),e[r]=.5*s,s=.5/s,e[3]=(t[n*3+o]-t[o*3+n])*s,e[n]=(t[n*3+r]+t[r*3+n])*s,e[o]=(t[o*3+r]+t[r*3+o])*s}return e}var $o=Oo;var Qo=No,Ko=qo,Jo=Bo,ta=Lo;var ea=Go;var su=zo;var ia=(function(){let e=io(),t=gr(1,0,0),i=gr(0,1,0);return function(s,r,n){let o=ke(r,n);return o<-.999999?(pe(e,t,r),co(e)<1e-6&&pe(e,i,r),so(e,e),Tr(s,e,Math.PI),s):o>.999999?(s[0]=0,s[1]=0,s[2]=0,s[3]=1,s):(pe(e,r,n),s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=1+o,su(s,s))}})();var yt=class extends Qt{constructor(t=0,i=0,s=0,r=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,i,s,r)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,i,s,r){return this[0]=t,this[1]=i,this[2]=s,this[3]=r,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return Xo(this,t),this.check()}fromEuler(t){switch(this.identity(),t.order){case"xyz":return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z);case"yxz":return this.rotateY(t.y).rotateX(t.x).rotateZ(t.z);case"zxy":return this.rotateZ(t.z).rotateX(t.x).rotateY(t.y);case"zyx":return this.rotateZ(t.z).rotateY(t.y).rotateX(t.x);case"yzx":return this.rotateY(t.y).rotateZ(t.z).rotateX(t.x);case"xzy":return this.rotateX(t.x).rotateZ(t.z).rotateY(t.y);default:throw new Error("Unknown Euler angle order")}}fromAxisRotation(t,i){return Tr(this,t,i),this.check()}identity(){return Uo(this),this.check()}setAxisAngle(t,i){return this.fromAxisRotation(t,i)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=F(t)}get y(){return this[1]}set y(t){this[1]=F(t)}get z(){return this[2]}set z(t){this[2]=F(t)}get w(){return this[3]}set w(t){this[3]=F(t)}len(){return ta(this)}lengthSquared(){return ea(this)}dot(t){return Ko(this,t)}rotationTo(t,i){return ia(this,t,i),this.check()}add(t){return $o(this,this,t),this.check()}calculateW(){return Wo(this,this),this.check()}conjugate(){return Zo(this,this),this.check()}invert(){return Yo(this,this),this.check()}lerp(t,i,s){return s===void 0?this.lerp(this,t,i):(Jo(this,t,i,s),this.check())}multiplyRight(t){return Pr(this,this,t),this.check()}multiplyLeft(t){return Pr(this,t,this),this.check()}normalize(){let t=this.len(),i=t>0?1/t:0;return this[0]=this[0]*i,this[1]=this[1]*i,this[2]=this[2]*i,this[3]=this[3]*i,t===0&&(this[3]=1),this.check()}rotateX(t){return Vo(this,this,t),this.check()}rotateY(t){return ko(this,this,t),this.check()}rotateZ(t){return jo(this,this,t),this.check()}scale(t){return Qo(this,this,t),this.check()}slerp(t,i,s){let r,n,o;return arguments.length===2?(r=this,n=t,o=i):(r=t,n=i,o=s),Ho(this,r,n,o),this.check()}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,i){return this.setAxisAngle(t,i)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var Dt=6356752314245179e-9,ru={radii:[6378137,6378137,Dt],radiiSquared:[6378137*6378137,6378137*6378137,Dt*Dt],oneOverRadii:[1/6378137,1/6378137,1/Dt],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(Dt*Dt)],maximumRadius:Math.max(6378137,6378137,Dt),centerToleranceSquared:.1};function Yi(e){return e}var N_=new p;function nu(e,t=[],i=Yi){return"longitude"in e?(t[0]=i(e.longitude),t[1]=i(e.latitude),t[2]=e.height):"x"in e?(t[0]=i(e.x),t[1]=i(e.y),t[2]=e.z):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}function sa(e,t=[]){return nu(e,t,k._cartographicRadians?Yi:ur)}function ou(e,t,i=Yi){return"longitude"in t?(t.longitude=i(e[0]),t.latitude=i(e[1]),t.height=e[2]):"x"in t?(t.x=i(e[0]),t.y=i(e[1]),t.z=e[2]):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}function ra(e,t){return ou(e,t,k._cartographicRadians?Yi:fr)}var na=1e-14,au=new p,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"}},br={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},je={east:new p,north:new p,up:new p,west:new p,south:new p,down:new p},hu=new p,cu=new p,lu=new p;function Rr(e,t,i,s,r,n){let o=oa[t]&&oa[t][i];Q(o&&(!s||s===o));let a,h,c,l=au.copy(r);if(pt(l.x,0,na)&&pt(l.y,0,na)){let f=Math.sign(l.z);a=hu.fromArray(br[t]),t!=="east"&&t!=="west"&&a.scale(f),h=cu.fromArray(br[i]),i!=="east"&&i!=="west"&&h.scale(f),c=lu.fromArray(br[s]),s!=="east"&&s!=="west"&&c.scale(f)}else{let{up:f,east:d,north:m}=je;d.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,f),m.copy(f).cross(d);let{down:g,west:_,south:M}=je;g.copy(f).scale(-1),_.copy(d).scale(-1),M.copy(m).scale(-1),a=je[t],h=je[i],c=je[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 ge=new p,uu=new p,fu=new p;function aa(e,t,i=[]){let{oneOverRadii:s,oneOverRadiiSquared:r,centerToleranceSquared:n}=t;ge.from(e);let o=ge.x,a=ge.y,h=ge.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,_=Math.sqrt(1/g);if(!Number.isFinite(_))return;let M=uu;if(M.copy(e).scale(_),g<n)return M.to(i);let y=r.x,E=r.y,w=r.z,T=fu;T.set(M.x*y*2,M.y*E*2,M.z*w*2);let P=(1-_)*ge.len()/(.5*T.len()),R=0,A,C,G,L;do{P-=R,A=1/(1+P*y),C=1/(1+P*E),G=1/(1+P*w);let D=A*A,H=C*C,N=G*G,At=D*A,Ci=H*C,ir=N*G;L=f*D+d*H+m*N-1;let sr=-2*(f*At*y+d*Ci*E+m*ir*w);R=L/sr}while(Math.abs(L)>q.EPSILON12);return ge.scale([A,C,G]).to(i)}var Zi=new p,ha=new p,pu=new p,Tt=new p,gu=new p,Xi=new p,b=class{constructor(t=0,i=0,s=0){this.centerToleranceSquared=q.EPSILON1,Q(t>=0),Q(i>=0),Q(s>=0),this.radii=new p(t,i,s),this.radiiSquared=new p(t*t,i*i,s*s),this.radiiToTheFourth=new p(t*t*t*t,i*i*i*i,s*s*s*s),this.oneOverRadii=new p(t===0?0:1/t,i===0?0:1/i,s===0?0:1/s),this.oneOverRadiiSquared=new p(t===0?0:1/(t*t),i===0?0:1/(i*i),s===0?0:1/(s*s)),this.minimumRadius=Math.min(t,i,s),this.maximumRadius=Math.max(t,i,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,i=[0,0,0]){let s=ha,r=pu,[,,n]=t;this.geodeticSurfaceNormalCartographic(t,s),r.copy(this.radiiSquared).scale(s);let o=Math.sqrt(s.dot(r));return r.scale(1/o),s.scale(n),r.add(s),r.to(i)}cartesianToCartographic(t,i=[0,0,0]){Xi.from(t);let s=this.scaleToGeodeticSurface(Xi,Tt);if(!s)return;let r=this.geodeticSurfaceNormal(s,ha),n=gu;n.copy(Xi).subtract(s);let o=Math.atan2(r.y,r.x),a=Math.asin(r.z),h=Math.sign(ke(n,Xi))*pr(n);return ra([o,a,h],i)}eastNorthUpToFixedFrame(t,i=new I){return Rr(this,"east","north","up",t,i)}localFrameToFixedFrame(t,i,s,r,n=new I){return Rr(this,t,i,s,r,n)}geocentricSurfaceNormal(t,i=[0,0,0]){return Zi.from(t).normalize().to(i)}geodeticSurfaceNormalCartographic(t,i=[0,0,0]){let s=sa(t),r=s[0],n=s[1],o=Math.cos(n);return Zi.set(o*Math.cos(r),o*Math.sin(r),Math.sin(n)).normalize(),Zi.to(i)}geodeticSurfaceNormal(t,i=[0,0,0]){return Zi.from(t).scale(this.oneOverRadiiSquared).normalize().to(i)}scaleToGeodeticSurface(t,i){return aa(t,this,i)}scaleToGeocentricSurface(t,i=[0,0,0]){Tt.from(t);let s=Tt.x,r=Tt.y,n=Tt.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(s*s*o.x+r*r*o.y+n*n*o.z);return Tt.multiplyByScalar(a).to(i)}transformPositionToScaledSpace(t,i=[0,0,0]){return Tt.from(t).scale(this.oneOverRadii).to(i)}transformPositionFromScaledSpace(t,i=[0,0,0]){return Tt.from(t).scale(this.radii).to(i)}getSurfaceNormalIntersectionWithZAxis(t,i=0,s=[0,0,0]){Q(pt(this.radii.x,this.radii.y,q.EPSILON15)),Q(this.radii.z>0),Tt.from(t);let r=Tt.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(r)>=this.radii.z-i))return Tt.set(0,0,r).to(s)}};b.WGS84=new b(6378137,6378137,Dt);var Cr;(function(e){e.OUTSIDE="outside",e.INTERSECTING="intersecting",e.INSIDE="inside"})(Cr||(Cr={}));var Z_=new p,X_=new p;var We=new p,ca=new p,J=class e{constructor(t=[0,0,0],i=0){this.radius=-0,this.center=new p,this.fromCenterRadius(t,i)}fromCenterRadius(t,i){return this.center.from(t),this.radius=i,this}fromCornerPoints(t,i){return i=We.from(i),this.center=new p().from(t).add(i).scale(.5),this.radius=this.center.distance(i),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 i=this.center,s=this.radius,r=t.center,n=t.radius,o=We.copy(r).subtract(i),a=o.magnitude();if(s>=a+n)return this.clone();if(n>=a+s)return t.clone();let h=(s+a+n)*.5;return ca.copy(o).scale((-s+h)/a).add(i),this.center.copy(ca),this.radius=h,this}expand(t){let s=We.from(t).subtract(this.center).magnitude();return s>this.radius&&(this.radius=s),this}transform(t){this.center.transform(t);let i=Po(We,t);return this.radius=Math.max(i[0],Math.max(i[1],i[2]))*this.radius,this}distanceSquaredTo(t){let i=this.distanceTo(t);return i*i}distanceTo(t){let s=We.from(t).subtract(this.center);return Math.max(0,s.len()-this.radius)}intersectPlane(t){let i=this.center,s=this.radius,n=t.normal.dot(i)+t.distance;return n<-s?"outside":n<s?"intersecting":"inside"}};var _u=new p,Mu=new p,$i=new p,Qi=new p,Ki=new p,xu=new p,yu=new p,Ft={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Nt=class e{constructor(t=[0,0,0],i=[0,0,0,0,0,0,0,0,0]){this.center=new p().from(t),this.halfAxes=new U(i)}get halfSize(){let t=this.halfAxes.getColumn(0),i=this.halfAxes.getColumn(1),s=this.halfAxes.getColumn(2);return[new p(t).len(),new p(i).len(),new p(s).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),i=this.halfAxes.getColumn(1),s=this.halfAxes.getColumn(2),r=new p(t).normalize(),n=new p(i).normalize(),o=new p(s).normalize();return new yt().fromMatrix3(new U([...r,...n,...o]))}fromCenterHalfSizeQuaternion(t,i,s){let r=new yt(s),n=new U().fromQuaternion(r);return n[0]=n[0]*i[0],n[1]=n[1]*i[0],n[2]=n[2]*i[0],n[3]=n[3]*i[1],n[4]=n[4]*i[1],n[5]=n[5]*i[1],n[6]=n[6]*i[2],n[7]=n[7]*i[2],n[8]=n[8]*i[2],this.center=new p().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 J){let i=this.halfAxes,s=i.getColumn(0,$i),r=i.getColumn(1,Qi),n=i.getColumn(2,Ki),o=_u.copy(s).add(r).add(n);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let i=this.center,s=t.normal,r=this.halfAxes,n=s.x,o=s.y,a=s.z,h=Math.abs(n*r[Ft.COLUMN0ROW0]+o*r[Ft.COLUMN0ROW1]+a*r[Ft.COLUMN0ROW2])+Math.abs(n*r[Ft.COLUMN1ROW0]+o*r[Ft.COLUMN1ROW1]+a*r[Ft.COLUMN1ROW2])+Math.abs(n*r[Ft.COLUMN2ROW0]+o*r[Ft.COLUMN2ROW1]+a*r[Ft.COLUMN2ROW2]),c=s.dot(i)+t.distance;return c<=-h?"outside":c>=h?"inside":"intersecting"}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let i=Mu.from(t).subtract(this.center),s=this.halfAxes,r=s.getColumn(0,$i),n=s.getColumn(1,Qi),o=s.getColumn(2,Ki),a=r.magnitude(),h=n.magnitude(),c=o.magnitude();r.normalize(),n.normalize(),o.normalize();let l=0,u;return u=Math.abs(i.dot(r))-a,u>0&&(l+=u*u),u=Math.abs(i.dot(n))-h,u>0&&(l+=u*u),u=Math.abs(i.dot(o))-c,u>0&&(l+=u*u),l}computePlaneDistances(t,i,s=[-0,-0]){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,h=a.getColumn(0,$i),c=a.getColumn(1,Qi),l=a.getColumn(2,Ki),u=xu.copy(h).add(c).add(l).add(o),f=yu.copy(u).subtract(t),d=i.dot(f);return r=Math.min(d,r),n=Math.max(d,n),u.copy(o).add(h).add(c).subtract(l),f.copy(u).subtract(t),d=i.dot(f),r=Math.min(d,r),n=Math.max(d,n),u.copy(o).add(h).subtract(c).add(l),f.copy(u).subtract(t),d=i.dot(f),r=Math.min(d,r),n=Math.max(d,n),u.copy(o).add(h).subtract(c).subtract(l),f.copy(u).subtract(t),d=i.dot(f),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(h).add(c).add(l),f.copy(u).subtract(t),d=i.dot(f),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(h).add(c).subtract(l),f.copy(u).subtract(t),d=i.dot(f),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(h).subtract(c).add(l),f.copy(u).subtract(t),d=i.dot(f),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(h).subtract(c).subtract(l),f.copy(u).subtract(t),d=i.dot(f),r=Math.min(d,r),n=Math.max(d,n),s[0]=r,s[1]=n,s}transform(t){this.center.transformAsPoint(t);let i=this.halfAxes.getColumn(0,$i);i.transformAsPoint(t);let s=this.halfAxes.getColumn(1,Qi);s.transformAsPoint(t);let r=this.halfAxes.getColumn(2,Ki);return r.transformAsPoint(t),this.halfAxes=new U([...i,...s,...r]),this}getTransform(){throw new Error("not implemented")}};var la=new p,ua=new p,Y=class e{constructor(t=[0,0,1],i=0){this.normal=new p,this.distance=-0,this.fromNormalDistance(t,i)}fromNormalDistance(t,i){return Q(Number.isFinite(i)),this.normal.from(t).normalize(),this.distance=i,this}fromPointNormal(t,i){t=la.from(t),this.normal.from(i).normalize();let s=-this.normal.dot(t);return this.distance=s,this}fromCoefficients(t,i,s,r){return this.normal.set(t,i,s),Q(pt(this.normal.len(),1)),this.distance=r,this}clone(){return new e(this.normal,this.distance)}equals(t){return pt(this.distance,t.distance)&&pt(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let i=ua.copy(this.normal).transformAsVector(t).normalize(),s=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(s,i)}projectPointOntoPlane(t,i=[0,0,0]){let s=la.from(t),r=this.getPointDistance(s),n=ua.copy(this.normal).scale(r);return s.subtract(n).to(i)}intersectWithRay(t,i=new p){let s=t.origin,r=t.direction,n=this.normal,o=n.dot(r);if(Math.abs(o)<q.EPSILON15)return;let a=(-this.distance-n.dot(s))/o;if(!(a<0))return i.copy(r).multiplyByScalar(a).add(s)}};var fa=[new p([1,0,0]),new p([0,1,0]),new p([0,0,1])],ma=new p,Su=new p,K=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*fa.length;let i=t.center,s=t.radius,r=0;for(let n of fa){let o=this.planes[r],a=this.planes[r+1];o||(o=this.planes[r]=new Y),a||(a=this.planes[r+1]=new Y);let h=ma.copy(n).scale(-s).add(i);o.fromPointNormal(h,n);let c=ma.copy(n).scale(s).add(i),l=Su.copy(n).negate();a.fromPointNormal(c,l),r+=2}return this}computeVisibility(t){let i="inside";for(let s of this.planes)switch(t.intersectPlane(s)){case"outside":return"outside";case"intersecting":i="intersecting";break;default:}return i}computeVisibilityWithPlaneMask(t,i){if(Q(Number.isFinite(i),"parentPlaneMask is required."),i===e.MASK_OUTSIDE||i===e.MASK_INSIDE)return i;let s=e.MASK_INSIDE,r=this.planes;for(let n=0;n<this.planes.length;++n){let o=n<31?1<<n:0;if(n<31&&(i&o)===0)continue;let a=r[n],h=t.intersectPlane(a);if(h==="outside")return e.MASK_OUTSIDE;h==="intersecting"&&(s|=o)}return s}};K.MASK_OUTSIDE=4294967295;K.MASK_INSIDE=0;K.MASK_INDETERMINATE=2147483647;var PM=new p,bM=new p,RM=new p,CM=new p,AM=new p;var zM=new p,qM=new p,BM=new p,DM=new p,FM=new p,UM=new p,VM=new p,kM=new p,jM=new p,WM=new p,HM=new p,YM=new p;var $M=new U,QM=new U,KM=new U,JM=new U,tx=new U;var ox=new p,ax=new p,hx=new p,cx=new p,lx=new p,ux=new U,fx={diagonal:new U,unitary:new U};var Tu=new p,Ar=new p,Pu=new I,bu=new p,He=class{constructor(t,i=b.WGS84){let s=i.scaleToGeodeticSurface(t,Tu),r=i.eastNorthUpToFixedFrame(s,Pu);this._origin=new p(s),this._xAxis=new p(Ar.from(r.getColumn(0))),this._yAxis=new p(Ar.from(r.getColumn(1)));let n=new p(Ar.from(r.getColumn(2)));this._plane=new Y().fromPointNormal(this._origin,n)}projectPointToNearestOnPlane(t,i){i||(i=new xt);let r=this._plane.projectPointOntoPlane(t,bu).subtract(this._origin),n=this._xAxis.dot(r),o=this._yAxis.dot(r);return i.x=n,i.y=o,i}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 _e=class{constructor(t,i,s,r){this.west=t,this.south=i,this.east=s,this.north=r}static center(t,i){i||(i=new p);let s=t.east,r=t.west;s<r&&(s+=q.TWO_PI);let n=mr((r+s)*.5,"negative-pi-to-pi"),o=(t.south+t.north)*.5;return i.x=n,i.y=o,i.z=0,i}get width(){let t=this.east,i=this.west;return t<i&&(t+=q.TWO_PI),t-i}};var Ru=new p,Cu=new p,Au=new p,Iu=new p,Ou=new p,Nu=new p,Lu=new p,Gu=new p,ga=new p,zu=new p,_a=new p,qu=new p,Bu=new xt,Du=new xt,Fu=new xt,Uu=new xt,Vu=new xt,ku=new Y,ju=new p,Wu=new p,Hu=new p,Yu=new p,Zu=new xt,Xu=new p,$u=new p,Qu=new p(1,0,0),Ku=new p(0,0,1);function Ir(e,t=b.WGS84,i={}){if(!e||e.length!==6||e.some(y=>!Number.isFinite(y)))throw new Error("makeOBBFromRegion: region must contain exactly six finite numbers");let s=i.units==="degrees"?Li(1):1,[r,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=Ma(r*s),d=Ma(o*s);o*s-r*s>=q.TWO_PI-1e-12&&(d=f+q.TWO_PI);let g=1e-12;if(l>u||l<-q.PI_OVER_TWO-g||u>q.PI_OVER_TWO+g)throw new Error("makeOBBFromRegion: latitude must be within [-\u03C0/2, \u03C0/2] and south \u2264 north");let _=Math.max(-q.PI_OVER_TWO,Math.min(q.PI_OVER_TWO,l)),M=Math.max(-q.PI_OVER_TWO,Math.min(q.PI_OVER_TWO,u));return Ju([f,_,d,M,h,c],t,i.transform)}function Ma(e){let t=((e+Math.PI)%q.TWO_PI+q.TWO_PI)%q.TWO_PI-Math.PI;return t===-Math.PI&&e>0?Math.PI:t}function Ju(e,t,i){let s=new Nt,[r,n,o,a,h,c]=e,l=ot(a),u=ot(n),f,d,m,g,_,M,y,E=new _e(r,n,o,a),w=_e.center(E,Cu),T=new p([ot(w.x),ot(w.y),0]),P=w.x,R=T.x;if(E.width<=q.PI){let rr=ot(r),Zl=t.cartographicToCartesian(T),It=new He(Zl,t),Xl=u<0&&l>0?0:T.y,$l=Au.copy([R,l,c]),nr=Iu.copy([rr,l,c]),Ql=Ou.copy([rr,Xl,c]),or=Nu.copy([rr,u,c]),Kl=Lu.copy([R,u,c]),Jl=t.cartographicToCartesian($l,Gu),ar=t.cartographicToCartesian(nr,ga),t0=t.cartographicToCartesian(Ql,zu),hr=t.cartographicToCartesian(or,_a),e0=t.cartographicToCartesian(Kl,qu),i0=It.projectPointToNearestOnPlane(Jl,Bu),Hn=It.projectPointToNearestOnPlane(ar,Du),s0=It.projectPointToNearestOnPlane(t0,Fu),Yn=It.projectPointToNearestOnPlane(hr,Uu),r0=It.projectPointToNearestOnPlane(e0,Vu);return g=Math.min(Hn.x,s0.x,Yn.x),f=-g,d=Math.max(Hn.y,i0.y),_=Math.min(Yn.y,r0.y),nr.z=or.z=h,ar=t.cartographicToCartesian(nr,ga),hr=t.cartographicToCartesian(or,_a),y=It.plane,M=Math.min(y.getPointDistance(ar),y.getPointDistance(hr)),m=c,xa(Sa(It.origin,It.xAxis,It.yAxis,It.zAxis,g,f,_,d,M,m,s),i)}let A=ot(o),C=n>0,G=a<0,L=C?u:G?l:0,D=t.cartographicToCartesian([R,L,c],ju);D.z=0;let N=Math.abs(D.x)<q.EPSILON10&&Math.abs(D.y)<q.EPSILON10?Qu:Wu.copy(D).normalize(),At=Ku,Ci=Hu.copy(N).cross(At);y=ku.fromPointNormal(D,N);let ir=t.cartographicToCartesian([ot(P+q.PI_OVER_TWO),L,c],Yu);f=y.projectPointOntoPlane(ir,Zu).dot(Ci),g=-f;let sr=G?h:c,Hl=C?h:c;d=ya(t,l,sr,!0),_=ya(t,u,Hl,!1);let Yl=t.cartographicToCartesian([A,L,c],$u);return M=y.getPointDistance(Yl),m=0,xa(Sa(D,Ci,At,N,g,f,_,d,M,m,s),i)}function xa(e,t){if(!t)return e;let i=[0,1,2].map(a=>e.halfAxes.getColumn(a,new p)),s=t.transformAsPoint(e.center),r=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let a=0;a<8;a++){let h=new p(s);for(let c=0;c<3;c++){let l=t.transformAsVector(i[c]);h.add(new p(l).scale((a&1<<c)===0?-1:1))}for(let c=0;c<3;c++)r[c]=Math.min(r[c],h[c]),n[c]=Math.max(n[c],h[c])}e.center.copy(r).add(n).scale(.5);let o=new p(n).subtract(r).scale(.5);return e.halfAxes=new U().set(o.x,0,0,0,o.y,0,0,0,o.z),e}function ya(e,t,i,s){let r=s?-1/0:1/0;for(let n of[0,90,180,270]){let o=e.cartographicToCartesian([n,t,i],Xu).z;r=s?Math.max(r,o):Math.min(r,o)}return r}function Sa(e,t,i,s,r,n,o,a,h,c,l){let u=l.center,f=l.halfAxes;f.setColumn(0,t),f.setColumn(1,i),f.setColumn(2,s);let d=Ru.set((r+n)/2,(o+a)/2,(h+c)/2).transformByMatrix3(f),m=(n-r)/2,g=(a-o)/2,_=(c-h)/2;return f[0]*=m,f[1]*=m,f[2]*=m,f[3]*=g,f[4]*=g,f[5]*=g,f[6]*=_,f[7]*=_,f[8]*=_,u.copy(e).add(d),l}function Ye(){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 ie=class{constructor(t,i){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=i,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=Ye(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Ye()-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 St=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,i="count"){return this._getOrCreate({name:t,type:i})}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 i of Object.values(this.stats))t(i)}getTable(){let t={};return this.forEach(i=>{t[i.name]={time:i.time||0,count:i.count||0,average:i.getAverageTime()||0,hz:i.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(i=>this._getOrCreate(i))}_getOrCreate(t){let{name:i,type:s}=t,r=this.stats[i];return r||(t instanceof ie?r=t:r=new ie(i,s),this.stats[i]=r),r}};function Pt(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var tf="Queued Requests",ef="Active Requests",sf="Cancelled Requests",rf="Queued Requests Ever",nf="Active Requests Ever",of={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Ut=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...of,...t},this.stats=new St({id:this.props.id}),this.stats.get(tf),this.stats.get(ef),this.stats.get(sf),this.stats.get(rf),this.stats.get(nf)}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,i=()=>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:i},r=new Promise(n=>(s.resolve=n,s));return this.requestQueue.push(s),this.requestMap.set(t,r),this._issueNewRequests(),r}_issueRequest(t){let{handle:i,resolve:s}=t,r=!1,n=()=>{r||(r=!0,this.requestMap.delete(i),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 i=0;i<t;++i){let s=this.requestQueue.shift();s&&this._issueRequest(s)}}}_updateAllRequests(){let t=this.requestQueue;for(let i=0;i<t.length;++i){let s=t[i];this._updateRequest(s)||(t.splice(i,1),this.requestMap.delete(s.handle),i--)}t.sort((i,s)=>i.priority-s.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var af=Number.POSITIVE_INFINITY,hf=Number.POSITIVE_INFINITY,Ze=class{maxEntries;maxBytes;getByteLength;onRemove;entries=new Map;retainedByteLength=0;constructor(t={}){this.maxEntries=va(t.maxEntries,af,"maxEntries"),this.maxBytes=va(t.maxBytes,hf,"maxBytes"),this.getByteLength=t.getByteLength||(()=>0),this.onRemove=t.onRemove}get size(){return this.entries.size}get pendingSize(){let t=0;for(let i of this.entries.values())t+=i.pending?1:0;return t}get byteLength(){return this.retainedByteLength}get(t,i){let s=this.entries.get(t);if(s)return this.touch(t,s),this.waitForEntry(t,s,i)}has(t){return this.entries.has(t)}set(t,i){this.removeEntry(t,"replace");let s=Ea(this.getByteLength(i)),r={promise:Promise.resolve(i),pending:!1,waiterCount:0,byteLength:s};return this.entries.set(t,r),this.retainedByteLength+=s,this.trim(),i}getOrLoad(t,i,s){let r=this.get(t,s);if(r)return r;if(s?.aborted)return Promise.reject(Or());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(i(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,i,s){if(this.entries.get(t)===i){i.pending=!1,i.controller=void 0;try{i.byteLength=Ea(this.getByteLength(s))}catch{this.removeEntry(t,"error");return}this.retainedByteLength+=i.byteLength,this.trim()}}handleLoadError(t,i){this.entries.get(t)===i&&this.removeEntry(t,i.controller?.signal.aborted?"abort":"error")}waitForEntry(t,i,s){return s?.aborted?Promise.reject(Or()):i.pending?(i.waiterCount++,new Promise((r,n)=>{let o=!0,a=()=>{o&&(o=!1,s?.removeEventListener("abort",h),i.waiterCount--)},h=()=>{o&&(a(),n(Or()),i.pending&&i.waiterCount===0&&this.entries.get(t)===i&&this.removeEntry(t,"abort"))};s?.addEventListener("abort",h,{once:!0}),i.promise.then(c=>{o&&(a(),r(c))},c=>{o&&(a(),n(c))})})):i.promise}touch(t,i){this.entries.delete(t),this.entries.set(t,i)}trim(){let t=this.entries.size-this.pendingSize;if(!(t<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)){for(let[i,s]of this.entries)if(s.pending||(this.removeEntry(i,"evict"),t--),t<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)break}}removeEntry(t,i){let s=this.entries.get(t);return s?(this.entries.delete(t),this.retainedByteLength-=s.byteLength,s.pending&&s.controller?.abort(),this.onRemove?.(t,i),!0):!1}};function Or(){let e=new Error("Request aborted");return e.name="AbortError",e}function va(e,t,i){let s=e??t;if(s<0||Number.isNaN(s))throw new Error(`${i} must be a non-negative number`);return s}function Ea(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 V={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"},Nr={batchDelayMs:50,maxGapBytes:65536,rangeExpansionBytes:65536,maxMergedBytes:8388608,stats:Pa("range-request-scheduler-default"),onEvent:()=>{}},ts=class{props;stats;onEvent;pendingRequests=[];flushTimer=null;constructor(t={}){let i=t.rangeExpansionBytes??t.maxGapBytes??Nr.rangeExpansionBytes;this.props={batchDelayMs:t.batchDelayMs??Nr.batchDelayMs,maxGapBytes:t.maxGapBytes??i,rangeExpansionBytes:i,maxMergedBytes:t.maxMergedBytes??Nr.maxMergedBytes},this.stats=t.stats||Pa("range-request-scheduler"),this.onEvent=t.onEvent,ba(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(Ta());if(t.length===0)return Promise.resolve(new ArrayBuffer(0));let i=new Promise((s,r)=>{let n={...t,resolve:s,reject:r,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(),i}fetch(t){let i=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,r,n)=>lf({url:t.url,offset:s,length:r,signal:n,fetch:i,fetchOptions:t.fetchOptions})})}flush(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null);let t=this.pendingRequests;this.pendingRequests=[];let i=t.filter(r=>r.settled||r.signal?.aborted?(this.abortRequest(r),!1):!0),s=this.mergeRequests(i);i.length>0&&this.trackBatch(i,s);for(let r of s)this.fetchMergedRequest(r)}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>this.flush(),this.props.batchDelayMs))}mergeRequests(t){t.sort((s,r)=>s.sourceId!==r.sourceId?s.sourceId<r.sourceId?-1:1:s.offset-r.offset);let i=[];for(let s of t){let r=s.offset+s.length,n=i[i.length-1];n&&uf(n,s,this.props)?(n.endOffset=Math.max(n.endOffset,r),n.requests.push(s)):i.push({sourceId:s.sourceId,isolationKey:s.isolationKey??s.sourceId,offset:s.offset,endOffset:r,fetchRange:s.fetchRange,requests:[s]})}return i}async fetchMergedRequest(t){let{offset:i,endOffset:s,fetchRange:r,requests:n}=t,o=new AbortController,a=Xe(),h=()=>{n.every(c=>c.signal?.aborted)&&o.abort()};try{for(let _ of n)_.onAbort=h;if(h(),n.every(_=>_.settled))return;let c=Lr(n),l=s-i;this.trackEvent({type:"request",sourceId:t.sourceId,offset:i,length:l,logicalRequestCount:n.length,logicalBytes:c,transportBytes:l,overfetchBytes:Math.max(l-c,0)});let u=ff(await r(i,l,o.signal)),{arrayBuffer:f}=u,d=u.fullResponse&&i===0&&f.byteLength<l,m=f.byteLength<l&&Number.isSafeInteger(u.sourceByteLength)&&i+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??Xe()-a;this.trackEvent({type:"response",sourceId:t.sourceId,offset:i,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 _ of n){if(_.settled)continue;let M=_.offset-i;_.settled=!0,_.resolve(f.slice(M,M+_.length))}}catch(c){this.trackEvent({type:"error",sourceId:t.sourceId,offset:i,length:s-i,logicalRequestCount:n.length,logicalBytes:Lr(n),networkTimeMs:Xe()-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(Ta()),this.trackEvent({type:"abort",sourceId:t.sourceId,offset:t.offset,length:t.length,logicalRequestCount:1,logicalBytes:t.length}))}trackEvent(t){cf(this.stats,t);try{this.onEvent?.(t)}catch{}}trackBatch(t,i){let s=Lr(t),r=i.reduce((n,o)=>n+o.endOffset-o.offset,0);this.trackEvent({type:"batch",logicalRequestCount:t.length,transportRequestCount:i.length,logicalBytes:s,transportBytes:r,overfetchBytes:Math.max(r-s,0)})}};function cf(e,t){switch((t.type==="response"||t.type==="error")&&t.networkTimeMs!==void 0&&e.get(V.networkTimeMs,"time").addTime(t.networkTimeMs),t.type){case"queued":e.get(V.logicalRanges,"count").incrementCount(),e.get(V.requestedBytes,"count").addCount(t.logicalBytes||0);break;case"batch":e.get(V.rangeBatches,"count").incrementCount(),e.get("Logical Ranges Batched","count").addCount(t.logicalRequestCount||0),e.get(V.transportRanges,"count").addCount(t.transportRequestCount||0),e.get(V.coalescedRanges,"count").addCount(Math.max((t.logicalRequestCount||0)-(t.transportRequestCount||0),0)),e.get(V.transportBytes,"count").addCount(t.transportBytes||0),e.get(V.overfetchBytes,"count").addCount(t.overfetchBytes||0);break;case"response":e.get(V.completedTransportRanges,"count").incrementCount(),e.get(V.responseBytes,"count").addCount(t.responseBytes||0),t.fullResponse&&e.get(V.fullResponseFallbacks,"count").incrementCount();break;case"error":e.get(V.failedTransportRanges,"count").incrementCount();break;case"abort":e.get(V.abortedLogicalRanges,"count").incrementCount();break;default:}}function Pa(e="range-request-scheduler"){let t=new St({id:e});return ba(t),t}async function lf(e){let t=gf(e.signal),i=Xe();try{let s=!1,r=await e.fetch(e.url,wa(e.fetchOptions,e.offset,e.length,t.signal));if(r.status===416&&e.offset===0){let h=df(r.headers.get("Content-Range"));if(!h)throw new Error("Missing content-length on 416 response");r=await e.fetch(e.url,wa(e.fetchOptions,0,h,t.signal)),s=!0}if(r.status===200)throw t.abort(),await _f(r),new Error("Byte-range request failed: server returned 200 instead of 206");if(r.status!==206&&!r.ok)throw new Error(`Bad response code: ${r.status}`);let n=await r.arrayBuffer(),o=r.headers.get("Content-Range"),a=pf(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:r.status,sourceByteLength:a?.sourceByteLength,transportBytes:n.byteLength,networkTimeMs:Xe()-i,fullResponse:s}}finally{t.removeAbortListener()}}function uf(e,t,i){if(e.sourceId!==t.sourceId||e.isolationKey!==(t.isolationKey??t.sourceId))return!1;let s=t.offset+t.length,r=t.offset-e.endOffset,n=Math.max(e.endOffset,s)-e.offset;return r<=i.rangeExpansionBytes&&n<=i.maxMergedBytes}function ba(e){e.get(V.logicalRanges,"count"),e.get(V.requestedBytes,"count"),e.get(V.rangeBatches,"count"),e.get("Logical Ranges Batched","count"),e.get(V.transportRanges,"count"),e.get(V.coalescedRanges,"count"),e.get(V.transportBytes,"count"),e.get(V.completedTransportRanges,"count"),e.get(V.responseBytes,"count"),e.get(V.networkTimeMs,"time"),e.get(V.overfetchBytes,"count"),e.get(V.fullResponseFallbacks,"count"),e.get(V.failedTransportRanges,"count"),e.get(V.abortedLogicalRanges,"count")}function Lr(e){return e.reduce((t,i)=>t+i.length,0)}function ff(e){return e instanceof ArrayBuffer?{arrayBuffer:e}:e}function wa(e,t,i,s){return{...e,signal:s,headers:{...mf(e?.headers),Range:`bytes=${t}-${t+i-1}`}}}function mf(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):e:{}}function df(e){let t=e?.match(/^bytes \*\/(\d+)$/);return t?Number(t[1]):null}function pf(e){let t=e?.match(/^bytes (\d+)-(\d+)\/(\d+|\*)$/);if(!t)return null;let i=Number(t[1]),s=Number(t[2]),r=t[3]==="*"?void 0:Number(t[3]);return!Number.isSafeInteger(i)||!Number.isSafeInteger(s)||i>s||r!==void 0&&!Number.isSafeInteger(r)?null:{offset:i,endOffset:s,sourceByteLength:r}}function gf(e){let t=new AbortController,i=()=>t.abort();return e?.aborted?t.abort():e?.addEventListener("abort",i,{once:!0}),{signal:t.signal,abort:()=>t.abort(),removeAbortListener:()=>e?.removeEventListener("abort",i)}}async function _f(e){await e.body?.cancel().catch(()=>{})}function Xe(){return globalThis.performance?.now()??Date.now()}function Ta(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}var gt={};cr(gt,{dirname:()=>xf,filename:()=>Mf,join:()=>yf,resolve:()=>Sf});function Ra(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function Mf(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function xf(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function yf(...e){return e=e.map((i,s)=>(s&&(i=i.replace(new RegExp("^/"),"")),s!==e.length-1&&(i=i.replace(new RegExp("/$"),"")),i)),e.join("/")}function Sf(...e){let t=[];for(let n=0;n<e.length;n++)t[n]=e[n];let i="",s=!1,r;for(let n=t.length-1;n>=-1&&!s;n--){let o;n>=0?o=t[n]:(r===void 0&&(r=Ra()),o=r),o.length!==0&&(i=`${o}/${i}`,s=o.charCodeAt(0)===$e)}return i=vf(i,!s),s?`/${i}`:i.length>0?i:"."}var $e=47,Gr=46;function vf(e,t){let i="",s=-1,r=0,n,o=!1;for(let a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(n===$e)break;n=$e}if(n===$e){if(!(s===a-1||r===1))if(s!==a-1&&r===2){if(i.length<2||!o||i.charCodeAt(i.length-1)!==Gr||i.charCodeAt(i.length-2)!==Gr){if(i.length>2){let h=i.length-1,c=h;for(;c>=0&&i.charCodeAt(c)!==$e;--c);if(c!==h){i=c===-1?"":i.slice(0,c),s=a,r=0,o=!1;continue}}else if(i.length===2||i.length===1){i="",s=a,r=0,o=!1;continue}}t&&(i.length>0?i+="/..":i="..",o=!0)}else{let h=e.slice(s+1,a);i.length>0?i+=`/${h}`:i=h,o=!1}s=a,r=0}else n===Gr&&r!==-1?++r:r=-1}return i}var Me=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,i,s){if(s?.aborted)throw new Error("Request aborted");let r=await this.handle.slice(Number(t),Number(t)+Number(i)).arrayBuffer();if(s?.aborted)throw new Error("Request aborted");return r}};var ss=class{url;fetchFunction;fetchOptions;consistency;identityHints;countedFailures=new WeakSet;telemetry={requestedBytes:0,downloadedBytes:0,requestCount:0,networkTimeMs:0,abortCount:0,errorCount:0};constructor(t,i){Rf(i.byteLength),this.url=t,this.fetchFunction=i.fetch||((s,r)=>globalThis.fetch(s,r)),this.fetchOptions=i.fetchOptions?{...i.fetchOptions,headers:new Headers(i.fetchOptions.headers)}:void 0,this.consistency=i.consistency||"best-effort",this.identityHints={byteLength:i.byteLength,etag:ns(i.etag),lastModified:ns(i.lastModified)}}getInitialIdentity(){let{byteLength:t,etag:i,lastModified:s}=this.identityHints;return t!==void 0&&(i!==void 0||s!==void 0)?rs(t,i,s):t===0&&this.consistency==="best-effort"?rs(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)}Oa(t)?this.telemetry.abortCount++:this.telemetry.errorCount++}async requestRange(t,i,s,r){let n=es(),o=Cf(s,this.fetchOptions?.signal);this.telemetry.requestCount++,this.telemetry.requestedBytes+=i;try{let a=await this.fetchFunction(this.url,Ef(this.fetchOptions,t,i,o.signal));if(wf(a,t,i,r))return await this.readEmptyIdentityProbe(a,n);if(a.status!==206)throw await is(a),new Error(`HTTP byte-range request expected 206, received ${a.status}`);let h=await Tf(a),c=Ca(a,h.byteLength),l=Ia(r,c,this.identityHints,this.consistency)||bf(h,t,i);if(l)throw await is(a),new Error(l);let u=await a.arrayBuffer();if(this.telemetry.downloadedBytes+=u.byteLength,u.byteLength!==i)throw new Error(`HTTP byte-range response contained ${u.byteLength} bytes; expected ${i}`);return{arrayBuffer:u,identity:Aa(r,c,this.identityHints),status:a.status,transportBytes:u.byteLength,networkTimeMs:es()-n}}catch(a){throw(r===null||!Oa(a))&&this.trackFailure(a),a}finally{o.removeAbortListeners(),this.telemetry.networkTimeMs+=es()-n}}async readEmptyIdentityProbe(t,i){let s=Ca(t,0),r=Ia(null,s,this.identityHints,this.consistency);if(await is(t),r)throw new Error(r);return{arrayBuffer:new ArrayBuffer(0),identity:Aa(null,s,this.identityHints),status:t.status,transportBytes:0,networkTimeMs:es()-i}}};function Ef(e,t,i,s){let r=new Headers(e?.headers);return r.set("Range",`bytes=${t}-${t+i-1}`),{...e,method:"GET",body:void 0,headers:r,signal:s}}function wf(e,t,i,s){return e.status===416&&s===null&&t===0&&i===1&&/^bytes \*\/0$/i.test(e.headers.get("Content-Range")||"")}async function Tf(e){try{return Pf(e.headers.get("Content-Range"))}catch(t){throw await is(e),t}}function Pf(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 Ca(e,t){return rs(t,ns(e.headers.get("ETag")),ns(e.headers.get("Last-Modified")))}function Aa(e,t,i){return e||rs(t.byteLength,t.etag??i.etag,t.lastModified??i.lastModified)}function bf(e,t,i){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+i-1?"HTTP byte-range response does not match the requested range":null}function Ia(e,t,i,s){let r=e?.byteLength??i.byteLength;if(r!==void 0&&t.byteLength!==r)return"HTTP file length changed while the file was open";let n=e?.etag??i.etag,o=e?.lastModified??i.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 rs(e,t,i){return Object.freeze({byteLength:e,etag:t,lastModified:i})}function Rf(e){if(e!==void 0&&(!Number.isSafeInteger(e)||e<0))throw new Error("HttpFile byteLength must be a non-negative safe integer")}async function is(e){await e.body?.cancel().catch(()=>{})}function ns(e){return e||void 0}function es(){return globalThis.performance?.now()??Date.now()}function Oa(e){return e instanceof Error&&e.name==="AbortError"||e instanceof Error&&/aborted/i.test(e.message)}function Cf(...e){let t=new AbortController,i=[...new Set(e.filter(r=>!!r))],s=()=>t.abort();for(let r of i)r.aborted?t.abort():r.addEventListener("abort",s,{once:!0});return{signal:t.signal,removeAbortListeners:()=>{for(let r of i)r.removeEventListener("abort",s)}}}var Qe=class e{handle;url;transport;rangeScheduler;schedulerIsolationKey={};suppliedByteLength;identity;openPromise=null;closed=!1;constructor(t,i={}){this.handle=t,this.url=t,this.transport=new ss(t,i),this.rangeScheduler=i.rangeScheduler||new ts({batchDelayMs:0,...i.rangeSchedulerProps}),this.suppliedByteLength=i.byteLength,this.identity=this.transport.getInitialIdentity()}static async open(t,i={},s){let r=new e(t,i);return await r.open(s),r}async open(t){if(this.assertOpen(),t?.aborted){let i=os();throw this.transport.trackFailure(i),i}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,i=0,s){if(this.assertOpen(),s?.aborted){let o=os();throw this.transport.trackFailure(o),o}let r=await this.getIdentity(s),n=Na(t);if(If(n,i,r.byteLength),i===0)return new ArrayBuffer(0);try{return await this.rangeScheduler.scheduleRequest({sourceId:this.url,isolationKey:this.schedulerIsolationKey,offset:n,length:i,signal:s,fetchRange:this.fetchScheduledRange})}catch(o){throw this.transport.trackFailure(o),o}}async fetchRange(t,i,s){let r=Na(t),n=await this.read(r,i,s),o=Af(this.identity,r,i);return new Response(n,{status:206,headers:o})}fetchScheduledRange=async(t,i,s)=>{let r=await this.getIdentity(s),n=await this.transport.requestRange(t,i,s,r);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(r=>{throw this.openPromise===s&&(this.openPromise=null),r});this.openPromise=s}return Of(this.openPromise,t).catch(i=>{throw this.transport.trackFailure(i),i})}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 Af(e,t,i){let s=new Headers;return i>0&&e&&s.set("Content-Range",`bytes ${t}-${t+i-1}/${e.byteLength}`),e?.etag&&s.set("ETag",e.etag),e?.lastModified&&s.set("Last-Modified",e.lastModified),s}function Na(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 If(e,t,i){if(!Number.isSafeInteger(t)||t<0)throw new Error("HTTP byte-range length must be a non-negative safe integer");if(e+t>i)throw new Error("HTTP byte range extends beyond the end of the file")}function os(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}function Of(e,t){return t?t.aborted?Promise.reject(os()):new Promise((i,s)=>{let r=()=>{t.removeEventListener("abort",r),s(os())};t.addEventListener("abort",r,{once:!0}),e.then(n=>{t.removeEventListener("abort",r),i(n)},n=>{t.removeEventListener("abort",r),s(n)})}):e}function as(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:La(e.crs||{state:"absent",provenance:"unknown"}),vertical:e.vertical?La(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 Ke(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 La(e){return e.state==="explicit"||e.state==="default"?Object.freeze({...e,definition:Ga(e.definition),alternatives:e.alternatives?Object.freeze(e.alternatives.map(t=>Object.freeze({...t,definition:Ga(t.definition)}))):void 0}):Object.freeze({...e})}function Ga(e){return typeof e=="string"?e:zr(e)}function zr(e){return Array.isArray(e)?Object.freeze(e.map(t=>zr(t))):e&&typeof e=="object"?Object.freeze(Object.fromEntries(Object.entries(e).map(([t,i])=>[t,zr(i)]))):e}var hs=class{item;previous;next;constructor(t,i,s){this.item=t,this.previous=i,this.next=s}};var cs=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let i=new hs(t,this.tail,null);return this.tail?(this.tail.next=i,this.tail=i):(this.head=i,this.tail=i),++this._length,i}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,i){t!==i&&(this.remove(i),this._insert(t,i))}_insert(t,i){let s=t.next;t.next=i,this.tail===t?this.tail=i:s.previous=i,i.next=s,i.previous=t,++this._length}};var xe=class{_list;_sentinel;_trimTiles;constructor(){this._list=new cs,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let i=t._cacheNode;i&&this._list.splice(this._sentinel,i)}add(t,i,s){i._cacheNode||(i._cacheNode=this._list.add(i),s&&s(t,i))}unloadTile(t,i,s){let r=i._cacheNode;r&&(this._list.remove(r),i._cacheNode=null,s&&s(t,i))}unloadTiles(t,i){let s=this._trimTiles;this._trimTiles=!1;let r=this._list,n=this._sentinel,o=r.head;for(;o!==n&&(t.gpuMemoryUsageInBytes>t.cacheBytes||s);){let a=o.item;o=o.next,this.unloadTile(t,a,i)}}trim(){this._trimTiles=!0}};function ls(e,t){Pt(e),Pt(t);let{rtcCenter:i,gltfUpAxis:s}=t,{computedTransform:r,boundingVolume:{center:n}}=e,o=new I(r);switch(i&&o.translate(i),s){case"Z":break;case"Y":let f=new I().rotateX(Math.PI/2);o=o.multiplyRight(f);break;case"X":let d=new I().rotateY(-Math.PI/2);o=o.multiplyRight(d);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new p(n);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let h=b.WGS84.cartesianToCartographic(a,new p),l=b.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=l.multiplyRight(o),t.cartographicOrigin=h;let u=Lf(t);u&&(t.cartesianModelMatrix=new I(o).multiplyRight(u.matrix),t.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=I.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Nf=1e6**2;function Lf(e){let t=e.gltf;if(!t)return null;let i=typeof t.scene=="number"?t.scene:0,r=t.scenes?.[i]?.nodes?.[0];if(!r?.matrix)return null;let n=r.matrix;return n[12]*n[12]+n[13]*n[13]+n[14]*n[14]<=Nf?null:r}var za=new p,qr=new p,Gf=1e-5,zf=1e-7,Br=new K([new Y,new Y,new Y,new Y,new Y,new Y]);function us(e,t,i={}){let{cameraUp:s,height:r}=e,n=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=Je(e,e.center),h=b.WGS84.eastNorthUpToFixedFrame(a),c=e.unprojectPosition(e.cameraPosition),l=b.WGS84.cartographicToCartesian(c,new p),u;if(n)u=new p(h.transformAsVector(new p(n).scale(o))).normalize();else{let w=e.getFrustumPlanes().near,T=Dr(w,e.cameraPosition),P=Je(e,T);u=new p(P).subtract(l).normalize()}let f=new p(h.transformAsVector(new p(s).scale(o))).normalize();qf(e);let d=e.constructor,{longitude:m,latitude:g,width:_,bearing:M,zoom:y}=e,E=new d({longitude:m,latitude:g,height:r,width:_,bearing:M,zoom:y,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:i.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:e,topDownViewport:E,height:r,cullingVolume:Br,clippingPlanes:e.clippingPlanes,frameNumber:t,sseDenominator:1.15,dynamicScreenSpaceErrorDensity:0}}function qa(e,t,i,s){let r=Array.from(t),n=Array.from(i),o=e?r.length!==e.position.length||r.some((c,l)=>Math.abs(c-e.position[l])>Gf):!1,a=e?n.length!==e.direction.length||n.some((c,l)=>Math.abs(c-e.direction[l])>zf):!1,h=o||a?s:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:r,direction:n,lastMovementTime:h},timeSinceMovement:Math.max((s-h)/1e3,0)}}function Ba(e,t,i){if(i===0||e.length<=i)return[e,[]];let s=[],{longitude:r,latitude:n}=t.viewport;for(let[c,l]of e.entries()){let[u,f]=l.header.mbs,d=Math.abs(r-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<i;c++)a.push(e[o[c][0]]);let h=[];for(let c=i;c<o.length;c++)h.push(e[o[c][0]]);return[a,h]}function qf(e){let t=e.getFrustumPlanes(),i=Dr(t.near,e.cameraPosition),s=Je(e,i),r=Je(e,e.cameraPosition,qr),n=0;Br.planes[n++].fromPointNormal(s,za.copy(s).subtract(r));for(let o in t){if(o==="near")continue;let a=t[o],h=Dr(a,i,qr),c=Je(e,h,qr);Br.planes[n++].fromPointNormal(c,za.copy(s).subtract(c))}}function Dr(e,t,i=new p){let s=e.normal.dot(t);return i.copy(e.normal).scale(e.distance-s).add(t),i}function Je(e,t,i=new p){let s=e.unprojectPosition(t);return b.WGS84.cartographicToCartesian(s,i)}var ka=new p,Bf=new p,se=new p,Da=new p,ti=new p,Fa=new p,Ua=new p,Va=new p,fs=new yt,Df=new p(0,0,1);function ja(e,t){e._updateTransform(t)}function Wa(e,t,i){if(!Number.isFinite(i.dynamicScreenSpaceErrorDensity)||i.dynamicScreenSpaceErrorDensity<=0)return 0;let s=kf(e),r=s.region?jf(s.region,t):Wf(e,s,t);if(!r)return 0;let n=Ue(i.dynamicScreenSpaceErrorHeightFalloff,0,1),o=r.minimumHeight+(r.maximumHeight-r.minimumHeight)*n,a=r.maximumHeight-o,h=a>0?Ue((r.cameraHeight-o)/a,0,1):r.cameraHeight>=r.maximumHeight?1:0,l=(1-Ue(Math.abs(r.cameraDirection.dot(r.upDirection)),0,1))*(1-h);return i.dynamicScreenSpaceErrorDensity*l}function Ff(e,t){let i=e*t;return 1-Math.exp(-(i*i))}function Uf(e,t,i){return t<=0||i<=0||!Number.isFinite(t)||!Number.isFinite(i)?0:Ff(e,t)*i}function Ha(e,t,i,s=1){let r=e.tileset,n=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=i?n:e.lodMetricValue;if(o===0)return 0;let{viewDistanceScale:a}=r.options,h=a||1,c=Number.isFinite(s)?Math.max(s,0):1,l=Vf(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 r.options.dynamicScreenSpaceError&&!t.viewport.orthographic&&(m-=Uf(u,t.dynamicScreenSpaceErrorDensity,r.options.dynamicScreenSpaceErrorFactor)),m}function Vf(e,t,i,s){let r=t.viewport;if(!r?.orthographic)return null;let n=r.metersPerPixel;return!Number.isFinite(n)||!n||n<=0?null:e*i*s/n}function kf(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function jf(e,t){let i=ka.copy(t.camera.position).normalize(),s=ti.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:s,upDirection:i}}function Wf(e,t,i){let s=Hf(t,se);if(s===null)return null;let r=new I(e.computedTransform).invert(),n=e.tileset.ellipsoid;if(Math.hypot(se[0],se[1],se[2])>n.minimumRadius){let a=n.cartesianToCartographic(se,Bf),h=ka.copy(i.camera.position).normalize(),c=ti.copy(i.camera.direction).normalize();return{cameraHeight:i.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:c,upDirection:h}}return r.transformAsPoint(i.camera.position,Da),r.transformAsVector(i.camera.direction,ti),ti.normalize(),{cameraHeight:Da[2],minimumHeight:se[2]-s,maximumHeight:se[2]+s,cameraDirection:ti,upDirection:Df}}function Hf(e,t){if(e.box){let i=e.box;return t.set(i[0],i[1],i[2]),Yf(i)}if(e.sphere){let i=e.sphere;return t.set(i[0],i[1],i[2]),i[3]}return null}function Yf(e){return e.length===10?(fs.fromArray(e,6),Fa.set(e[3],0,0).transformByQuaternion(fs),Ua.set(0,e[4],0).transformByQuaternion(fs),Va.set(0,0,e[5]).transformByQuaternion(fs),Math.abs(Fa[2])+Math.abs(Ua[2])+Math.abs(Va[2])):Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11])}var et={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},tt;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(tt||(tt={}));var Lt;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Lt||(Lt={}));var at;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(at||(at={}));var ye;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(ye||(ye={}));var Ya={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};var Za=1e4,Zf=1e4,Xf=1e8,$f=new J,Xa=new p,$a=new p,Fr=new p,ms=new p;function Ur(e,t,i){return e+(t-e)*i}function Qa(e,t){let i=e instanceof J?e:e.getBoundingSphere($f),{center:s,radius:r}=i;Xa.copy(s).subtract(t.position);let n=Math.max(Xa.dot(t.direction),0);return $a.copy(t.direction).scale(n).add(t.position),Fr.copy($a).subtract(s),Fr.magnitude()<=r||(ms.copy(Fr).normalize().scale(r).add(s).subtract(t.position),ms.magnitude()===0)?0:(ms.normalize(),Math.min(Math.max(1-ms.dot(t.direction),0),1))}function Ka(e,t,i,s){return!Number.isFinite(s)||s<=0||s>.5?!1:e>i?!0:t!==void 0&&t>i}function Ja(e){let t=Number.isFinite(e.foveatedConeSize)?Math.min(Math.max(e.foveatedConeSize,0),1):1,i=e.refinement===tt.REPLACE;if(i&&!e.skipLevelOfDetail||!e.foveatedScreenSpaceError||t>=1||i&&e.skipLevelOfDetail&&e.priorityProgressiveResolution)return!1;let s=Number.isFinite(e.verticalFieldOfView)&&e.verticalFieldOfView>0?e.verticalFieldOfView:Math.PI/3,r=1-Math.cos(s*.5),n=t*r;if(e.foveatedFactor<=n||r<=n)return!1;let o=Math.min(Math.max((e.foveatedFactor-n)/(r-n),0),1),h=(typeof e.interpolationCallback=="function"?e.interpolationCallback:Ur)(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 th(e,t,i){return e&&Number.isFinite(t)&&Number.isFinite(i)&&i>0&&t<i}function eh(e){let t=e.rootScreenSpaceError>0?Math.min(Math.max(e.reverseScreenSpaceError/e.rootScreenSpaceError,0),1):0,i=Math.floor(t*(Za-1)),s=Number.isFinite(e.foveatedFactor)?Math.min(Math.max(e.foveatedFactor,0),1):0,r=Math.floor(s*(Za-1))*Zf;return(e.priorityProgressiveResolution?0:Xf)+r+i}var Qf="EPSG:4326",Kf="EPSG:4978";function Jf(e){let t=e.trim().toUpperCase(),i=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return i?`${i[1]}:${i[2]}`:t}function Vt(e){if(typeof e=="string"){let i=Jf(e);return i===Kf||/^GEOCCS\s*[\[(]/.test(i)?"geocentric":i===Qf||i==="EPSG:4490"||i==="EPSG:4979"||i==="OGC:CRS84"||i.includes("+PROJ=LONGLAT")||i.includes("+PROJ=LATLONG")||/^(?:GEOGCS|GEOGCRS|GEOGRAPHICCRS|GEOGRAPHIC2DCRS|GEOGRAPHIC3DCRS)\s*[\[(]/.test(i)?"geographic":/^(?:GEODCRS|GEODETICCRS)\s*[\[(]/.test(i)?/CS\s*[\[(]\s*CARTESIAN/.test(i)?"geocentric":"geographic":"projected"}let t=e;return t.type==="BoundCRS"&&t.source_crs?Vt(t.source_crs):t.type==="CompoundCRS"&&t.components?.[0]?Vt(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 vt(e,t={}){let i=t.sourceCrs!==void 0,s=t.sourceCrs||e.sourceCrs,r=t.outputCoordinates||"auto",n=t.targetCrs||(r==="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"||r!=="auto"||f,g=r!=="target-crs"||!!n,_=!d||(e.heightReference||"unknown")!=="unknown",M=Number.isFinite(a)&&a>0&&Number.isFinite(h)&&h>0,y=!!s&&m&&g&&_&&M&&u&&r!=="local-enu",E=i?"caller-override":e.provenance||"unknown",w=i&&s?Vt(s):e.coordinateFrame,T=i?"explicit":e.sourceCrsState||(s?E==="format-default"?"default":"explicit":"absent"),P=as({crs:s?{state:T==="default"?"default":"explicit",definition:s,representation:!i&&e.sourceCrsRepresentation||Ke(s),provenance:E,alternatives:i?void 0:e.sourceCrsAlternatives}:{state:T==="unknown"?"unknown":"absent",provenance:E},vertical:e.verticalCrs?{state:"explicit",definition:e.verticalCrs,representation:Ke(e.verticalCrs),provenance:e.provenance||"metadata"}:void 0,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,coordinateFrame:w,coordinateOrder:em(e.axisOrder),units:i?void 0:e.units}),R=Vr(P.crs),A=P.vertical?Vr(P.vertical):void 0,C=n?tm(n):void 0;return Object.freeze({...P,sourceCrs:R,verticalCrs:A,verticalUnitScale:a,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,heightReference:e.heightReference||"unknown",elevationMode:e.elevationMode,elevationOffset:e.elevationOffset,elevationUnit:e.elevationUnit,elevationUnitScale:h,coordinateFrame:w||"unknown",axisOrder:e.axisOrder||"unknown",provenance:E,targetCrs:C,targetHeightReference:o,outputCoordinates:r,status:m?y?"transformable":"unresolved":"native",warnings:Object.freeze([...e.warnings||[]])})}function ei(e,t={}){return vt({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 Vr(e){return e.state==="explicit"||e.state==="default"?e.definition:void 0}function tm(e){let t=as({crs:{state:"explicit",definition:e,representation:Ke(e),provenance:"caller-override"}}),i=Vr(t.crs);if(!i)throw new Error("Failed to normalize a known target CRS definition");return i}function em(e){switch(e){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function ds(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 ps(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var it=1024*1024,Zr=512*it,Xr=512*it,im=32*it,sm=it;function ii(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 ih(e,t){let i=e.cacheBytes??(e.maximumMemoryUsage!==void 0?e.maximumMemoryUsage*it:t);return ii(i,"cacheBytes")}function sh(e,t){let i=e.maximumCacheOverflowBytes??(e.memoryCacheOverflow!==void 0?e.memoryCacheOverflow*it:t);return ii(i,"maximumCacheOverflowBytes")}var kr={description:"",ellipsoid:b.WGS84,modelMatrix:new I,throttleRequests:!0,maxRequests:64,cacheBytes:Zr,maximumCacheOverflowBytes:Xr,maximumMemoryUsage:Zr/it,memoryCacheOverflow:Xr/it,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:Ur,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:{}},jr="Tiles In Tileset(s)",Wr="Tiles In Memory",rh="Tiles In View",nh="Tiles To Render",oh="Tiles Loaded",Hr="Tiles Loading",ah="Tiles Unloaded",hh="Failed Tile Loads",ch="Points/Vertices",Yr="Tile Memory Use",lh="Maximum Screen Space Error",gs=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=vt({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=Zr;_maximumCacheOverflowBytes=Xr;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new xe;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(t,i){if(!ps(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let s=i||{},r=t.type===at.TILES3D,n=r?kr.cacheBytes:im,o=r?kr.maximumCacheOverflowBytes:sm,a=ih(s,n),h=sh(s,o);this.options={...kr,...s,cacheBytes:a,maximumCacheOverflowBytes:h,maximumMemoryUsage:a/it,memoryCacheOverflow:h/it,memoryAdjustedScreenSpaceError:s.memoryAdjustedScreenSpaceError??r},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 Ut({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=ei(c.spatialReference,this.options.spatial)),this.stats=new St({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=ii(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes,this.options.maximumMemoryUsage=this._cacheBytes/it}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=ii(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes,this.options.memoryCacheOverflow=this._maximumCacheOverflowBytes/it}get maximumMemoryUsage(){return this.cacheBytes/it}set maximumMemoryUsage(t){this.cacheBytes=ii(t*it,"maximumMemoryUsage")}get queryParams(){let t=this.source.getTileUrl(this.url),i=t.indexOf("?");return i>=0?t.slice(i+1):""}setProps(t){let i=ih(t,this.cacheBytes),s=sh(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:i,maximumCacheOverflowBytes:s,maximumMemoryUsage:i/it,memoryCacheOverflow:s/it},this._cacheBytes=i,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(i=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),i(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 i=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=i.length;let s=Date.now(),r=Number.POSITIVE_INFINITY,n=[];for(let o of i){let a=o.id;this._needTraverse(a)?n.push(a):this.traverseCounter--}for(let o of i){let a=o.id;if(this.roots[a]||(this.roots[a]=this._initializeTileHeaders(this.tileset,null)),!n.includes(a))continue;let h=us(o,this._frameNumber),c=this.roots[a],l=qa(this._cameraMotionStates[a],h.camera.position,h.camera.direction,s);this._cameraMotionStates[a]=l.state,h.camera.timeSinceMovement=l.timeSinceMovement,ja(c,this.modelMatrix),h.dynamicScreenSpaceErrorDensity=this.type===at.TILES3D&&this.options.dynamicScreenSpaceError&&!h.viewport.orthographic?Wa(c,h,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=h.dynamicScreenSpaceErrorDensity,this._traverser.traverse(c,h,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(r=Math.min(r,Math.max(this.options.foveatedTimeDelay-l.timeSinceMovement,0)))}Number.isFinite(r)?this._scheduleDeferredTraversal(r):this._clearDeferredTraversal()}_scheduleDeferredTraversal(t){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(i=>{let s=i instanceof Error?i:new Error(String(i));this._onTilesetError(s)})},Math.max(t*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(t){let i=t;return this.options.viewportTraversersMap&&(i=this.options.viewportTraversersMap[t]),i===t}_onTraversalEnd(t){let i=t.viewport.id;this.frameStateData[i]||(this.frameStateData[i]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let s=this.frameStateData[i],r=Object.values(this._traverser.selectedTiles),[n,o]=Ba(r,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 i=new Set(this.selectedTiles.map(n=>n.id)),s=this.selectedTiles.some(n=>!n.tileDrawn),r=0;if(s){for(let n of i)this._heldTiles.add(n);for(let n of this._heldTiles){if(i.has(n))continue;let o=this._tiles[n];o&&o.contentAvailable?(o._selectedFrame=this._frameNumber,this.selectedTiles.push(o),r++):this._heldTiles.delete(n)}}else this._heldTiles=i;r>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,i){if(t.length!==i.length)return!0;let s=new Set(t.map(o=>o.id)),r=new Set(i.map(o=>o.id)),n=t.some(o=>!r.has(o.id));return n=n||i.some(o=>!s.has(o.id)),n}_loadTiles(){this._requestedTiles.sort((t,i)=>t._priority-i._priority);for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,i)=>t._unloadTile(i)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let t=0,i=0;for(let s of this.selectedTiles)if(s.contentAvailable&&s.content){t++;let r=s.contents.length?s.contents:[s.content];for(let n of r)n.pointCount?i+=n.pointCount:i+=n.vertexCount||0}this.stats.get(rh).count=this.selectedTiles.length,this.stats.get(nh).count=t,this.stats.get(ch).count=i,this.stats.get(lh).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let t=this.source.initialize(),i=this._getSourceMetadata();i&&this._syncSourceState(i),i?.tileset?.root&&typeof i.tileset.root.then!="function"&&!this.source.prepareTileset&&(this.root=this._initializeTileHeaders(i.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 i=t instanceof Error?t:new Error(String(t));throw this._onSourceError(i,this.root),this._onTilesetError(i),i}}_initializeStats(){this.stats.get(jr),this.stats.get(Hr),this.stats.get(Wr),this.stats.get(rh),this.stats.get(nh),this.stats.get(oh),this.stats.get(ah),this.stats.get(hh),this.stats.get(ch),this.stats.get(Yr,"memory"),this.stats.get(lh)}_initializeTileHeaders(t,i){return this.source.initializeTileHeaders(this,t,i)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let i=null;try{this._onStartTileLoading(),i=await t.loadContent()}catch(s){let r=s instanceof Error?s:new Error("load failed");this._onSourceError(r,t),this._onTileLoadError(t,r)}finally{this._onEndTileLoading(),this._onTileLoad(t,i)}}async _loadTileChildren(t,i){try{this._onStartTileLoading(),await t.loadChildren(i)}catch(s){let r=s instanceof Error?s:new Error("subtree load failed");this._onSourceError(r,t),this._onTileLoadError(t,r)}finally{this._onEndTileLoading()}}_onTileLoadError(t,i){this.stats.get(hh).incrementCount();let s=i.message||i.toString(),r=t.url;console.error(`A 3D tile failed to load: ${t.url} ${s}`),this.options.onTileError(t,s,r)}_onSourceError(t,i=null){this.options.onSourceError(t,this.source,i)}_onTilesetError(t){this.options.onTilesetError(t,this)}_onTileLoad(t,i){if(!i?.loaded)return;t.content&&ls(t,t.content),this.source.onTileLoaded?.(this,t,i),this._syncSourceState(this.source.getMetadata());let s=this.source.getTilesTotalCount?.();s&&(this.stats.get(jr).reset(),this.stats.get(jr).addCount(s)),this._addTileToCache(t),this.options.onTileLoad(t)}_onStartTileLoading(){this._pendingCount++,this.stats.get(Hr).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Hr).decrementCount()}_addTileToCache(t){this._cache.add(this,t,i=>i._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(oh).incrementCount(),this.stats.get(Wr).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Yr).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(Wr).decrementCount(),this.stats.get(ah).incrementCount(),this.stats.get(Yr).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let i=t.pop();for(let s of i.children)t.push(s);this._destroyTile(i)}this.root=null}_destroySubtree(t){let i=t,s=[i];for(;s.length>0;){t=s.pop();for(let r of t.children)s.push(r);t!==i&&this._destroyTile(t)}i.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 i=t.tileset;this.schema=i.schema||null,this.schemaUri=i.schemaUri||null,this.groups=i.groups||[],this.metadata=i.metadata||null,this.statistics=i.statistics??null;let s=ei(t.spatialReference,this.options.spatial);this.spatialReference=rm(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 p,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 rm(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 _s=class{sourceUrl;options;archivePromise;constructor(t){this.options=t,this.sourceUrl=nm(t.data,t.fallbackFilename)}async loadRoot(t,i,s){return await this.parseArchiveResource(t,this.options.rootPath,i,s,this.options.rootMode)}async loadResource(t,i,s){let r=this.resolveArchivePath(t,t);return await this.parseArchiveResource(t,r,i,s)}async parseArchiveResource(t,i,s,r,n){let o=this.options.getCoreApi();if(!o)throw new Error(this.options.missingCoreApiMessage);let a=await this.loadFile(i,n),h=this.createArchiveFetch(t);return await o.parse(a,s,{...r,fetch:h},{url:t,fetch:h,_parse:o.parse,loaders:[s],coreApi:o})}createArchiveFetch(t){return async i=>{let s=typeof i=="string"?i:i instanceof URL?i.toString():i.url,r=this.resolveArchivePath(s,t),n=await this.loadFile(r);return new Response(n,{status:200})}}async loadFile(t,i){this.archivePromise||=this.openArchiveReadableFile().then(r=>this.options.parseArchive(r));let s=await this.archivePromise;return await this.options.getFile(s,t,i)}async openArchiveReadableFile(){let{data:t}=this.options;if(typeof t!="string")return new Me(t);if(/^https?:\/\//i.test(t))return new Qe(t);let i=this.options.getCoreApi();if(!i)throw new Error(this.options.missingCoreApiMessage);let s=await i.fetchFile(t);return new Me(await s.arrayBuffer())}resolveArchivePath(t,i){let s=$r(t),r=$r(this.sourceUrl),n=$r(i),o=n===r?r:gt.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(r)?s:n===r&&!c?`${r}/${s}`:gt.resolve(o,s);return l===r?"":l.startsWith(`${r}/`)?l.slice(r.length+1):l.replace(/^\/+/,"")}};function nm(e,t){return typeof e=="string"?e:`memory://${"name"in e&&typeof e.name=="string"&&e.name?e.name:t}`}function $r(e){let t=e.indexOf("?");return t>=0?e.slice(0,t):e}function uh(e){return e!=null}var st=new p,Ms=new p;function Se(e,t,i){if(Pt(e,"3D Tile: boundingVolume must be defined"),e.box)return om(e.box,t,i);if(e.region)return Ir(e.region);if(e.sphere)return am(e.sphere,t,i);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function fh(e,t){if(e.box)return hm(t);if(e.region){let[i,s,r,n,o,a]=e.region;return[[ot(i),ot(s),o],[ot(r),ot(n),a]]}if(e.sphere)return cm(t);throw new Error("Unkown boundingVolume type")}function om(e,t,i){let s=new p(e[0],e[1],e[2]);t.transform(s,s);let r=[];if(e.length===10){let c=e.slice(3,6),l=new yt;l.fromArray(e,6);let u=new p([1,0,0]),f=new p([0,1,0]),d=new p([0,0,1]);u.transformByQuaternion(l),u.scale(c[0]),f.transformByQuaternion(l),f.scale(c[1]),d.transformByQuaternion(l),d.scale(c[2]),r=[...u.toArray(),...f.toArray(),...d.toArray()]}else r=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];let n=t.transformAsVector(r.slice(0,3)),o=t.transformAsVector(r.slice(3,6)),a=t.transformAsVector(r.slice(6,9)),h=new U([n[0],n[1],n[2],o[0],o[1],o[2],a[0],a[1],a[2]]);return uh(i)?(i.center=s,i.halfAxes=h,i):new Nt(s,h)}function am(e,t,i){let s=new p(e[0],e[1],e[2]);t.transform(s,s);let r=t.getScale(Ms),n=Math.max(Math.max(r[0],r[1]),r[2]),o=e[3]*n;return uh(i)?(i.center=s,i.radius=o,i):new J(s,o)}function hm(e){let t=mh(),{halfAxes:i}=e,s=new p(i.getColumn(0)),r=new p(i.getColumn(1)),n=new p(i.getColumn(2));for(let o=0;o<2;o++){for(let a=0;a<2;a++){for(let h=0;h<2;h++)st.copy(e.center),st.add(s),st.add(r),st.add(n),dh(t,st),n.negate();r.negate()}s.negate()}return t}function cm(e){let t=mh(),{center:i,radius:s}=e,r=b.WGS84.scaleToGeodeticSurface(i,st),n;r?n=b.WGS84.geodeticSurfaceNormal(r):n=new p(0,0,1);let o=new p(n[2],-n[1],0);o.len()>0?o.normalize():o=new p(0,1,0);let a=o.clone().cross(n);for(let h of[o,a,n]){Ms.copy(h).scale(s);for(let c=0;c<2;c++)st.copy(i),st.add(Ms),dh(t,st),Ms.negate()}return t}function mh(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function dh(e,t){b.WGS84.cartesianToCartographic(t,st),e[0][0]=Math.min(e[0][0],st[0]),e[0][1]=Math.min(e[0][1],st[1]),e[0][2]=Math.min(e[0][2],st[2]),e[1][0]=Math.max(e[1][0],st[0]),e[1][1]=Math.max(e[1][1],st[1]),e[1][2]=Math.max(e[1][2],st[2])}var Qr=new p,ph=new p,Kt=new p,gh=new p,lm=new p,Kr=new I,_h=new I;function xs(e,t){if(e.lodMetricValue===0||Number.isNaN(e.lodMetricValue))return"DIG";let i=2*Jr(e,t);if(i<2)return"OUT";if(!e.header.children)return"DRAW";switch(e.lodMetricType){case"screenSpaceRelative":{let s=t.topDownViewport.height||1;return i/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 i<=s?"DRAW":"DIG"}default:return i<=e.lodMetricValue?"DRAW":"DIG"}}function Jr(e,t){let{topDownViewport:i}=t,s=e.header.i3sLodMbs||e.header.mbs,r=s[1],n=s[0],o=s[2],a=s[3],h=[...e.boundingVolume.center],c=i.unprojectPosition(i.cameraPosition);b.WGS84.cartographicToCartesian(c,Qr),ph.copy(Qr).subtract(h).normalize(),b.WGS84.eastNorthUpToFixedFrame(h,Kr),_h.copy(Kr).invert(),Kt.copy(Qr).transform(_h);let l=Math.sqrt(Kt[0]*Kt[0]+Kt[1]*Kt[1]),u=l*l/Kt[2];gh.copy([Kt[0],Kt[1],u]);let d=gh.transform(Kr).subtract(h).normalize(),g=ph.cross(d).normalize().scale(a).add(h),_=b.WGS84.cartesianToCartographic(g),M=i.project([n,r,o]),y=i.project(_);return lm.copy(M).subtract(y).magnitude()}var si=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 Pt(t<this._array.length),this._array[t]}set(t,i){Pt(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=i,this._map.set(i,t)}delete(t){let i=this._map.get(t);i>=0&&(this._array.splice(i,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){let i=this.length++;this._array[i]=t,this._map.set(t,i)}}pop(){let t=this._array[--this.length];return this._map.delete(t),t}reserve(t){Pt(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){Pt(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 um={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Gt=class{options;root=null;selectedTiles={};requestedTiles={};deferredTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new si;_emptyTraversalStack=new si;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...um,...t}}traverse(t,i,s){this.root=t,this.options={...this.options,...s},this.reset(),this.updateTile(t,i),this._frameNumber=i.frameNumber,this.executeTraversal(t,i)}reset(){this.requestedTiles={},this.deferredTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,i){let s=this._traversalStack;for(t._selectionDepth=1,s.push(t);s.length>0;){let n=s.pop(),o=!1;this.canTraverse(n,i)&&(this.updateChildTiles(n,i),o=this.updateAndPushChildren(n,i,s,n.hasRenderContent?n._selectionDepth+1:n._selectionDepth));let a=n.parent,h=!!(!a||a._shouldRefine),c=!o;n.hasRenderContent?n.refine===tt.ADD?(this.loadTile(n,i),this.selectTile(n,i)):n.refine===tt.REPLACE&&(this.loadTile(n,i),(c||this.options.skipLevelOfDetail)&&this.selectTile(n,i)):(this.emptyTiles[n.id]=n,this.loadTile(n,i),c&&this.selectTile(n,i)),this.touchTile(n,i),n._shouldRefine=o&&h}let r=new Date().getTime();(this.traversalFinished(i)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(i))}updateChildTiles(t,i){let s=t.children;for(let r of s)this.updateTile(r,i)}updateAndPushChildren(t,i,s,r){let{loadSiblings:n,skipLevelOfDetail:o}=this.options,a=t.children;a.sort(this.compareDistanceToCamera.bind(this));let h=t.refine===tt.REPLACE&&t.hasRenderContent&&!o,c=!1,l=!0;for(let u of a)if(u._selectionDepth=r,u.isVisibleAndInRequestVolume?(s.find(u)&&s.delete(u),s.push(u),c=!0):(h||n)&&(this.loadTile(u,i),this.touchTile(u,i)),h){let f;if(u._inRequestVolume?u.hasRenderContent?f=u.contentAvailable:f=this.executeEmptyTraversal(u,i):f=!1,l=l&&f,!l)return!1}return c||(l=!1),l}updateTile(t,i){this.updateTileVisibility(t,i)}selectTile(t,i){this.shouldSelectTile(t,i)&&(t._selectedFrame=i.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,i){if(this.shouldLoadTile(t)){if(this.shouldDeferTileRequest(t)){this.deferredTiles[t.id]=t;return}t._requestedFrame=i.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t}}shouldDeferTileRequest(t){return t.priorityDeferred}touchTile(t,i){t.tileset._cache.touch(t),t._touchedFrame=i.frameNumber}canTraverse(t,i){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:this.shouldRefine(t,i):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t,i){return t.contentAvailable&&t.contentVisibility(i)!=="outside"}shouldRefine(t,i,s=!1){let r=t._screenSpaceError;return s&&(r=t.getScreenSpaceError(i,!0)),r>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,i){let s=[];if(this.options.viewportTraversersMap)for(let r in this.options.viewportTraversersMap)this.options.viewportTraversersMap[r]===i.viewport.id&&s.push(r);else s.push(i.viewport.id);t.updateVisibility(i,s)}compareDistanceToCamera(t,i){return t._distanceToCamera-i._distanceToCamera}anyChildrenVisible(t,i){let s=!1;for(let r of t.children)r.updateVisibility(i),s=s||r.isVisibleAndInRequestVolume;return s}executeEmptyTraversal(t,i){let s=!0,r=!1,n=this._emptyTraversalStack;for(n.push(t);n.length>0;){let o=n.pop(),a=!o.hasRenderContent&&this.canTraverse(o,i),h=!o.hasRenderContent&&o.children.length===0;if(o.header.implicitSubtree&&(r=!0,s=!1),!a&&!o.contentAvailable&&!h&&(s=!1),this.updateTile(o,i),o.isVisibleAndInRequestVolume||(this.loadTile(o,i),this.touchTile(o,i)),a){let c=o.children;for(let l of c)n.push(l)}}return t.hasEmptyContent&&!r||s}};var tn=new p;function fm(e,t,i,s,r=[]){let n=e.length?e:[t],o=!1,a=!1;for(let h of n){let c="inside";if(s!==K.MASK_INSIDE&&(c=i.computeVisibility(h),c==="outside"))continue;let l=!1;for(let u of r)if(h.intersectPlane(u)==="outside"){l=!0;break}l||(o=!0,a=a||c==="intersecting")}return o?a?"intersecting":"inside":"outside"}function mm(e){return e!=null}var Et=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=et.UNLOADED;gpuMemoryUsageInBytes=0;children=[];childrenState="ready";depth=0;viewportIds=[];transform=new I;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Gt({});_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 I;_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,i,s,r=""){this.header=i,this.tileset=t,this.id=r||i.id,this.url=i.url,this.parent=s,this.refine=this._getRefine(i.refine),this.type=i.type,this.contentUrl=i.contentUrl,this.contentUrls=i.contentUrls||(i.contentUrl?[i.contentUrl]:[]),this.metadata=i.metadata||null;let n=Array.isArray(i.content)?i.content:[i.content];this.contentMetadata=n.filter(Boolean).map(o=>o.metadata||null),this.childrenState=i.implicitSubtree?"unloaded":"ready",this._initializeLodMetric(i),this._initializeTransforms(i),this._updateLodMetricScale(),this._initializeBoundingVolumes(i),this._initializeContent(i),this._initializeRenderingState(i),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===et.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===et.UNLOADED}get contentExpired(){return this.contentState===et.EXPIRED}get contentFailed(){return this.contentState===et.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=fh(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,i,s=1){switch(this.tileset.type){case at.I3S:return Jr(this,t);case at.TILES3D:return Ha(this,t,i,s);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return(this.contents.length?this.contents:[this.content]).reduce((i,s)=>i+(s?.gpuMemoryUsageInBytes||s?.byteLength||0),0)}_getPriority(){return this._calculateRequestPriority(!1)}_getChildrenPriority(){return this._calculateRequestPriority(!0)}_calculateRequestPriority(t){let i=this.tileset._traverser,{skipLevelOfDetail:s}=i.options,r=this.refine===tt.ADD||s;if(r&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.priorityDeferred||!t&&this.contentState===et.UNLOADED)return-1;let n=this.parent,a=n&&(!r||this._screenSpaceError===0||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,h=i.root?i.root._screenSpaceError:0,c=Math.max(h-a,0);return eh({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=et.LOADING;let i=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!i)return this.contentState=et.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=et.READY,this._onContentLoaded(),s}catch(s){throw this.contentState=et.FAILED,s}finally{i.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 i=await this.tileset._requestScheduler.scheduleRequest(`${this.id}:implicit-subtree`,this._getChildrenPriority.bind(this));if(!i)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{i.done()}}applyImplicitSubtreeHeader(t){let i=this.header.transform,s=this.header.transformMatrix;this.header={...this.header,...t,transform:i,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=et.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(t,i){if(this._frameNumber===t.frameNumber)return;let s=this.parent,r=s?s._visibilityPlaneMask:K.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,r),this._visible=this._visibilityPlaneMask!==K.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=i}_updateRequestPriorityMetrics(t){if(this.tileset.type!==at.TILES3D){this._screenSpaceErrorProgressiveResolution=this._screenSpaceError,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1;return}let i=this.tileset.options,s=i.progressiveResolutionHeightFraction;if(this._screenSpaceErrorProgressiveResolution=this.getScreenSpaceError(t,!1,s),this._priorityProgressiveResolution=Ka(this._screenSpaceErrorProgressiveResolution,this.parent?._screenSpaceErrorProgressiveResolution,this.tileset.memoryAdjustedScreenSpaceError,s),!i.foveatedScreenSpaceError||t.viewport?.orthographic||!t.camera?.position||!t.camera?.direction){this._foveatedFactor=0,this.priorityDeferred=!1;return}this._foveatedFactor=Qa(this.boundingVolume,t.camera);let r=Ja({refinement:this.refine,skipLevelOfDetail:this.tileset._traverser.options.skipLevelOfDetail,foveatedScreenSpaceError:i.foveatedScreenSpaceError,foveatedConeSize:i.foveatedConeSize,minimumScreenSpaceErrorRelaxation:i.foveatedMinimumScreenSpaceErrorRelaxation,interpolationCallback:i.foveatedInterpolationCallback,foveatedFactor:this._foveatedFactor,verticalFieldOfView:t.camera.verticalFieldOfView,screenSpaceError:this._screenSpaceError,parentScreenSpaceError:this.parent?._screenSpaceError,maximumScreenSpaceError:this.tileset.memoryAdjustedScreenSpaceError,priorityProgressiveResolution:this._priorityProgressiveResolution});this.priorityDeferred=th(r,t.camera.timeSinceMovement,i.foveatedTimeDelay)}visibility(t,i){let{cullingVolume:s}=t,{boundingVolume:r}=this;return s.computeVisibilityWithPlaneMask(r,i)}contentVisibility(t){return fm(this._contentBoundingVolumes,this.boundingVolume,t.cullingVolume,this._visibilityPlaneMask,t.clippingPlanes)}distanceToTile(t){let i=this.boundingVolume;return Math.sqrt(Math.max(i.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){let i=this.boundingVolume;return tn.subVectors(i.center,t.position),t.direction.dot(tn)}insideViewerRequestVolume(t){let i=this._viewerRequestVolume;return!i||i.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(mm(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=et.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 I(t.transform):new I;let i=this.parent,s=this.tileset,r=i&&i.computedTransform?i.computedTransform.clone():s.modelMatrix.clone();this.computedTransform=new I(r).multiplyRight(this.transform);let n=i&&i._initialTransform?i._initialTransform.clone():new I;this._initialTransform=new I(n).multiplyRight(this.transform)}_updateLodMetricScale(){if(this.lodMetricType!==ye.GEOMETRIC_ERROR){this.lodMetricValue=this._unscaledLodMetricValue;return}let t=this.computedTransform.getScale(tn),i=Math.max(t[0],t[1],t[2]);this.lodMetricValue=this._unscaledLodMetricValue*i}_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=et.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=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||tt.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 i of t)switch(i&&i.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=Se(t.boundingVolume,this.computedTransform,this.boundingVolume),t.viewerRequestVolume&&(this._viewerRequestVolume=Se(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume));let i=t.content;i&&(this._contentBoundingVolumeHeaders=Array.isArray(i)?i:[i]);let s=i?Array.isArray(i)?i:[i]:this._contentBoundingVolumeHeaders;this._contentBoundingVolumes=s.length?s.map(r=>r?.boundingVolume?Se(r.boundingVolume,this.computedTransform):this.boundingVolume):[this.boundingVolume],this._contentBoundingVolume=this._contentBoundingVolumes[0]||null}_updateTransform(t=new I){let i=t.clone().multiplyRight(this.transform);i.equals(this.computedTransform)||(this.computedTransform=i,this._updateLodMetricScale(),this._updateBoundingVolume(this.header))}};var ys=class extends Gt{pendingImplicitSubtrees=new Map;traversalFinished(t){let i=`${t.viewport.id}:`;for(let[s,r]of this.pendingImplicitSubtrees)if(s.startsWith(i)&&r===t.frameNumber)return!1;return!0}compareDistanceToCamera(t,i){return i._distanceToCamera===0&&t._distanceToCamera===0?i._centerZDepth-t._centerZDepth:i._distanceToCamera-t._distanceToCamera}updateChildTiles(t,i){if(t.hasUnloadedChildren&&t.isVisibleAndInRequestVolume&&this.shouldRefine(t,i)){let s=`${i.viewport.id}:${t.id}`;this.pendingImplicitSubtrees.has(s)||(this.pendingImplicitSubtrees.set(s,i.frameNumber),t.tileset._loadTileChildren(t,i).finally(()=>{this.handleImplicitSubtreeLoad(t,i,s)}))}super.updateChildTiles(t,i)}handleImplicitSubtreeLoad(t,i,s){this.pendingImplicitSubtrees.delete(s),this._frameNumber===i.frameNumber&&(t.childrenState==="ready"?this.executeTraversal(t,i):this.traversalFinished(i)&&this.options.onTraversalEnd(i))}updateTileVisibility(t,i){if(super.updateTileVisibility(t,i),!t.isVisibleAndInRequestVolume)return;let s=t.children.length>0;if(t.hasTilesetContent&&s){let o=t.children[0];this.updateTileVisibility(o,i),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,i)){t._visible=!1;return}let r=t.refine===tt.REPLACE,n=t._optimChildrenWithinParent===Ya.USE_OPTIMIZATION;if(r&&n&&s&&!this.anyChildrenVisible(t,i)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,i){let{parent:s}=t;return!s||s.hasTilesetContent||s.refine!==tt.ADD?!1:!this.shouldRefine(t,i,!0)}};var dm=6378137,pm=6378137,en=6356752314245179e-9,ve=new p;function Mh(e,t){if(e instanceof Nt){let{halfAxes:i}=e,s=gm(i);return Math.log2(en/(s+t[2]))}else if(e instanceof J){let{radius:i}=e;return Math.log2(en/(i+t[2]))}else if(e.width&&e.height){let{width:i,height:s}=e,r=Math.log2(dm/i),n=Math.log2(pm/s);return(r+n)/2}return 1}function sn(e,t,i){b.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],ve);let s=Math.sqrt(Math.pow(ve[0]-i[0],2)+Math.pow(ve[1]-i[1],2)+Math.pow(ve[2]-i[2],2));return Math.log2(en/(s+t[2]))}function xh(e,t,i){let[s,r,n,o]=e;return sn({xmin:s,xmax:n,ymin:r,ymax:o,zmin:0,zmax:0},t,i)}function gm(e){e.getColumn(0,ve);let t=e.getColumn(1),i=e.getColumn(2);return ve.add(t).add(i).len()}var _m=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}),Mm=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 ri(e){if(!e)return;let t=e.trim().toLowerCase().replaceAll("_","-"),i=Mm[t]||t;return _m[i]}function yh(e,t){return t!==void 0?Number.isFinite(t)&&t>0?t:void 0:e?ri(e):1}function Ss(e){let t=e.spatialReference||e.fullExtent?.spatialReference,i=vm(t),s=e.heightModelInfo?.vertCRS||Em(t),r=e.heightModelInfo?.heightModel,n=e.heightModelInfo?.heightUnit,o=yh(n,e.ZFactor),a=r==="ellipsoidal"?"ellipsoidal":r==="gravity_related_height"?"orthometric":"unknown",h=vh(t),c=h===void 0?Tm(t?.wkt):wm(h),l=xm(c,n,e.ZFactor),u=[],f=ym(e.elevationInfo?.mode),d=e.elevationInfo?e.elevationInfo.unit||"meter":void 0,m=ri(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`),vt({sourceCrs:i,sourceCrsRepresentation:h!==void 0?"identifier":i?"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:i?"xyz":"unknown",provenance:i?"metadata":"unknown",warnings:u})}function xm(e,t,i){if(e==="geocentric")return["meter","meter","meter"];if(e==="geographic"&&(t||i===void 0))return["degree","degree",t||"meter"]}function ym(e){switch(e){case"absoluteHeight":case"onTheGround":case"relativeToGround":case"relativeToScene":return e;default:return}}function vs(e){let t=Sh(e,"TILESET_CRS_GEOCENTRIC"),i=Sh(e,"TILESET_CRS_COORDINATE_EPOCH"),s=[],r,n="unknown",o;typeof t=="string"&&t.toUpperCase()!=="UNKNOWN"?(r=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?(r="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=Sm(i);return i!==void 0&&a===void 0&&s.push("3D Tiles coordinate epoch is not a finite decimal year"),vt({sourceCrs:r,sourceCrsState:o,sourceCrsRepresentation:r?"identifier":void 0,coordinateEpoch:a,heightReference:r?"ellipsoidal":"unknown",coordinateFrame:r?"geocentric":"unknown",axisOrder:r?"xyz":"unknown",provenance:n,warnings:s})}function Sm(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 vm(e){let t=vh(e);return t!==void 0?`EPSG:${t}`:e?.wkt}function Em(e){let t=e?.latestVcsWkid??e?.vcsWkid;return t===void 0?void 0:`EPSG:${t}`}function vh(e){return e?.latestWkid??e?.wkid}function wm(e){return e===4978?"geocentric":e===4326||e===4490||e===4979?"geographic":"projected"}function Tm(e){if(!e)return"unknown";let t=e.trim().toUpperCase(),i=t.match(/^([A-Z][A-Z0-9_]*)\s*[\[(]/)?.[1];if(i==="GEOCCS")return"geocentric";if(i==="GEOGCS"||i==="GEOGRAPHICCRS"||i==="GEOGRAPHIC2DCRS"||i==="GEOGRAPHIC3DCRS")return"geographic";if(i==="PROJCS"||i==="PROJCRS"||i==="PROJECTEDCRS")return"projected";if(i==="GEODCRS"||i==="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 Sh(e,t){let i=e.metadata?.class;if(!i)return;let r=e.schema?.classes?.[i]?.properties,n=e.metadata?.properties;for(let[o,a]of Object.entries(r||{}))if(a.semantic===t)return n?.[o]}var Pm=4,bm=8;function nn(e,t){return{coordinates:t,subtreeUrl:ws(e.subtreesUrlTemplate,t),descriptor:e}}function Es(e,t){let{descriptor:i}=t;Lm(i);let s={tileCount:0,childSubtreeCount:0},r=wh(e,t,{localLevel:0,mortonIndex:0},t.coordinates,s);if(!r)throw new Error(`Invalid 3D Tiles subtree: root tile is unavailable at ${t.subtreeUrl}`);return{root:r,...s}}function ws(e,t){let i={level:t.level,x:t.x,y:t.y,z:t.z};return e.replace(/{(level|x|y|z)}/gi,(s,r)=>String(i[r.toLowerCase()]))}function wh(e,t,i,s,r){let{descriptor:n}=t,o=Om(n.subdivisionScheme),a=Im(o,i.localLevel)+i.mortonIndex;if(!rn(e.tileAvailability,a))return null;r.tileCount++;let h=Am(e.contentAvailability,a),c=[];if(s.level<n.maximumLevel)if(i.localLevel+1<n.subtreeLevels)for(let l=0;l<o;l++){let u=Eh(s,l,n.subdivisionScheme),f=wh(e,t,{localLevel:i.localLevel+1,mortonIndex:i.mortonIndex*o+l},u,r);f&&c.push(f)}else for(let l=0;l<o;l++){let u=i.mortonIndex*o+l;if(rn(e.childSubtreeAvailability,u)){let f=Eh(s,l,n.subdivisionScheme);c.push(Rm(e,n,f)),r.childSubtreeCount++}}return Cm(e,n,t,s,h,c)}function Rm(e,t,i){let s=nn(t,i);return{id:Ph(s,i),children:[],implicitSubtree:s,boundingVolume:bh(t.rootBoundingVolume,i,t.subdivisionScheme),geometricError:t.rootLodMetricValue/2**i.level,lodMetricType:t.lodMetricType,lodMetricValue:t.rootLodMetricValue/2**i.level,refine:t.refine,type:Lt.EMPTY,implicitMetadata:Th(e)}}function Cm(e,t,i,s,r,n){let a=(t.contentUrlTemplates?.length?t.contentUrlTemplates:[t.contentUrlTemplate]).map((f,d)=>!r[d]||!f?null:{contentIndex:d,contentUrl:ws(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:Ph(i,s),children:n,contentUrl:l,content:c.length>1?c:c[0],contentUrls:h,refine:t.refine,type:Nm(l),lodMetricType:t.lodMetricType,lodMetricValue:u,geometricError:u,boundingVolume:bh(t.rootBoundingVolume,s,t.subdivisionScheme),implicitMetadata:Th(e)}}function Th(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 Ph(e,t){return`${e.subtreeUrl}#implicit=${t.level}/${t.x}/${t.y}/${t.z}`}function rn(e,t){if(typeof e?.constant=="number")return!!e.constant;let i=e?.explicitBitstream;if(!i)return!1;let s=Math.floor(t/8),r=t%8;return!!(i[s]>>r&1)}function Am(e,t){return(Array.isArray(e)?e:[e]).map(s=>rn(s||{constant:0},t))}function Im(e,t){return(e**t-1)/(e-1)}function Eh(e,t,i){return{level:e.level+1,x:e.x*2+(t&1),y:e.y*2+(t>>1&1),z:i==="OCTREE"?e.z*2+(t>>2&1):0}}function Om(e){return e==="OCTREE"?bm:Pm}function bh(e,t,i){if(e.region){let[s,r,n,o,a,h]=e.region,c=2**t.level,l=(n-s)/c,u=(o-r)/c,f=s+l*t.x,d=r+u*t.y,m=a,g=h;if(i==="OCTREE"){let _=(h-a)/c;m=a+_*t.z,g=m+_}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,r=2**t.level,n=-1+(2*t.x+1)/r,o=-1+(2*t.y+1)/r,a=-1+(2*t.z+1)/r,h=i==="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]/r,s[4]/r,s[5]/r,s[6]/r,s[7]/r,s[8]/r,h?s[9]/r:s[9],h?s[10]/r:s[10],h?s[11]/r:s[11]]}}throw new Error(`Unsupported implicit 3D Tiles bounding volume: ${JSON.stringify(e)}`)}function Nm(e){if(!e)return Lt.EMPTY;let t=e.split("?")[0].split(".").pop()?.toLowerCase();switch(t){case"pnts":return Lt.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Lt.SCENEGRAPH;default:return t||Lt.EMPTY}}function Lm(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 Gm={draco:!1,meshopt:!1,dds:!1,ktx2:!1},zm=32,Ts=class{type=at.TILES3D;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...Gm};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,i={}){let s=qm(t);this.rootTileset=Rh(t)?null:t,this.tileset=this.rootTileset,this.loader=s.loader,this.url=s.url,this.basePath=s.basePath||gt.dirname(s.url),this.resolver=s.resolver,this.coreApi=s.coreApi,this.loadOptions=i;let r=Number(i["3d-tiles"]?.maximumCachedSubtrees),n=Number.isFinite(r)?Math.max(0,Math.floor(r)):zm;this.implicitSubtreeCache=new Ze({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[i,s]of t.entries())this.setQueryParameter(i,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:vs(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,i,s){let r=new Et(t,i.root,s||void 0);s&&(s.children.push(r),r.depth=s.depth+1);let n=[r];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 Et(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 r}createTraverser(t){return new ys(t)}async loadTileContent(t){let i=(t.contentUrls||[t.contentUrl]).filter(Boolean),s=this.loadOptions[this.loader.id]||{},r={...this.loadOptions,[this.loader.id]:{...s,isTileset:"auto",assetGltfUpAxis:this.asset&&this.asset.gltfUpAxis||"Y"}},n=await Promise.all(i.map(a=>this.loadResourceData(this.getTileUrl(a),r)));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,i){let s=t.header.implicitSubtree;if(!s)return{loaded:!1,tileCount:0,childSubtreeCount:0};let r=this.getTileUrl(s.subtreeUrl),n=await this.loadImplicitSubtreeResource(r);if(this.destroyed||t.isDestroyed())return{loaded:!1,tileCount:0,childSubtreeCount:0};let o=Es(n,{...s,subtreeUrl:r});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 i=this.tileUrlCache.get(t);if(i)return i;if(!Object.keys(this.queryParams).length)return this.tileUrlCache.set(t,t),t;let[s,r=""]=t.split("?"),n=new URLSearchParams(r);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,i){this.queryParams[t]!==i&&(this.queryParams[t]=i,this.tileUrlCache.clear())}getViewState(t){if(!t)return{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits};let{center:i}=t.boundingVolume,s;return i&&(i[0]!==0||i[1]!==0||i[2]!==0)?(s=new p,b.WGS84.cartesianToCartographic(i,s)):s=new p(0,0,-b.WGS84.radii[0]),{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits,boundingVolume:t.boundingVolume,cartographicCenter:s,cartesianCenter:i,zoom:Mh(t.boundingVolume,s)}}hasExtension(t){return this.extensionsUsed.includes(t)}onTileLoaded(t,i,s){let n=(i.contents.length?i.contents:[i.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,i)}async loadWithCoreApi(t,i,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,i)}async loadRootData(t,i){return this.resolver?await this.resolver.loadRoot(t,this.loader,i):await this.loadWithCoreApi(t,i)}async loadResourceData(t,i,s=this.loader){return this.resolver?await this.resolver.loadResource(t,s,i):await this.loadWithCoreApi(t,i,s)}async loadImplicitSubtreeResource(t){let i=this.implicitSubtreeCache.get(t);if(i)return this.implicitTilingStats.cacheHits++,await i;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,i,s){let r=0,n=[{parentTile:i,childHeaders:s}];for(;n.length>0;){let o=n.pop();for(let a of o.childHeaders){let h=new Et(t,a,o.parentTile);o.parentTile.children.push(h),h.depth=o.parentTile.depth+1,t.stats.get("Tiles In Tileset(s)").incrementCount(),r++,a.children?.length&&n.push({parentTile:h,childHeaders:a.children})}}return r}};function Rh(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function qm(e){return Rh(e)?{...e,basePath:e.basePath||gt.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||gt.dirname(e.url),resolver:e.resolver,coreApi:e.coreApi}}var Ps=class{frameNumberMap=new Map;register(t,i){let s=this.frameNumberMap.get(t)||new Map,r=s.get(i)||0;s.set(i,r+1),this.frameNumberMap.set(t,s)}deregister(t,i){let s=this.frameNumberMap.get(t);if(!s)return;let r=s.get(i)||1;s.set(i,r-1)}isZero(t,i){return(this.frameNumberMap.get(t)?.get(i)||0)===0}};var on={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},bs=class{_statusMap;pendingTilesRegister=new Ps;constructor(){this._statusMap={}}add(t,i,s,r){if(!this._statusMap[i]){let{frameNumber:n,viewport:{id:o}}=r;this._statusMap[i]={request:t,callback:s,key:i,frameState:r,status:on.REQUESTED},this.pendingTilesRegister.register(o,n),t().then(a=>{this._statusMap[i].status=on.COMPLETED;let{frameNumber:h,viewport:{id:c}}=this._statusMap[i].frameState;this.pendingTilesRegister.deregister(c,h),this._statusMap[i].callback(a,r)}).catch(a=>{this._statusMap[i].status=on.ERROR;let{frameNumber:h,viewport:{id:c}}=this._statusMap[i].frameState;this.pendingTilesRegister.deregister(c,h),s(a)})}}update(t,i){if(this._statusMap[t]){let{frameNumber:s,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,s);let{frameNumber:n,viewport:{id:o}}=i;this.pendingTilesRegister.register(o,n),this._statusMap[t].frameState=i}}find(t){return this._statusMap[t]}hasPendingTiles(t,i){return!this.pendingTilesRegister.isZero(t,i)}};var Rs=class extends Gt{_tileManager;constructor(t){super(t),this._tileManager=new bs}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,i){return t._lodJudge=xs(t,i),t._lodJudge==="DIG"}updateChildTiles(t,i){let s=t.header.children||[],r=t.children;for(let n of s){let o=`${n.id}-${i.viewport.id}`,a=r&&r.find(h=>h.id===o);if(a)a&&this.updateTile(a,i);else{let h=()=>this._loadTile(t,n.id,i);this._tileManager.find(o)?this._tileManager.update(o,i):this._tileManager.add(h,o,l=>this._onTileLoad(l,t,o),i)}}return!1}async _loadTile(t,i,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,i,s)}_onTileLoad(t,i,s){if(t instanceof Error){i.tileset._onSourceError(t,i);return}let r=new Et(i.tileset,t,i,s);i.children.push(r);let n=this._tileManager.find(r.id).frameState;this.updateTile(r,n),this._frameNumber===n.frameNumber&&(this.traversalFinished(n)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(r,n)}};function Ch(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 bt=1,Rt=2,kt=3,Ah=4,ni=5,an=6378137,Ih=6356752314e-3,hn=.0066943799901413165,re=484813681109536e-20,x=Math.PI/2,Oh=.16666666666666666,Nh=.04722222222222222,Lh=.022156084656084655,v=1e-10,B=.017453292519943295,X=57.29577951308232,O=Math.PI/4,Jt=Math.PI*2,j=3.14159265359;var ct={};ct.greenwich=0;ct.lisbon=-9.131906111111;ct.paris=2.337229166667;ct.bogota=-74.080916666667;ct.madrid=-3.687938888889;ct.rome=12.452333333333;ct.bern=7.439583333333;ct.jakarta=106.807719444444;ct.ferro=-17.666666666667;ct.brussels=4.367975;ct.stockholm=18.058277777778;ct.athens=23.7163375;ct.oslo=10.722916666667;var Gh=ct;var zh={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 qh=/[\s_\-\/\(\)]/g;function _t(e,t){if(e[t])return e[t];for(var i=Object.keys(e),s=t.toLowerCase().replace(qh,""),r=-1,n,o;++r<i.length;)if(n=i[r],o=n.toLowerCase().replace(qh,""),o===s)return e[n]}function oi(e){var t={},i=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,r,n,o={proj:"projName",datum:"datumCode",rf:function(a){t.rf=parseFloat(a)},lat_0:function(a){t.lat0=a*B},lat_1:function(a){t.lat1=a*B},lat_2:function(a){t.lat2=a*B},lat_ts:function(a){t.lat_ts=a*B},lon_0:function(a){t.long0=a*B},lon_wrap:function(a){t.long_wrap=parseFloat(a)*B},lon_1:function(a){t.long1=a*B},lon_2:function(a){t.long2=a*B},alpha:function(a){t.alpha=parseFloat(a)*B},gamma:function(a){t.rectified_grid_angle=parseFloat(a)*B},lonc:function(a){t.longc=a*B},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=_t(zh,a);h&&(t.to_meter=h.to_meter)},from_greenwich:function(a){t.from_greenwich=a*B},pm:function(a){var h=_t(Gh,a);t.from_greenwich=(h||parseFloat(a))*B},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 i)r=i[s],s in o?(n=o[s],typeof n=="function"?n(r):t[n]=r):t[s]=r;return typeof t.datumCode=="string"&&t.datumCode!=="WGS84"&&(t.datumCode=t.datumCode.toLowerCase()),t.projStr=e,t}var cn=class{static getId(t){let i=t.find(s=>Array.isArray(s)&&s[0]==="ID");return i&&i.length>=3?{authority:i[1],code:parseInt(i[2],10)}:null}static convertUnit(t,i="unit"){if(!t||t.length<3)return{type:i,name:"unknown",conversion_factor:null};let s=t[1],r=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:i,name:s,conversion_factor:r,id:o}}static convertAxis(t){let i=t[1]||"Unknown",s,r=i.match(/^\((.)\)$/);if(r){let c=r[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:i,direction:s,unit:h,order:o}}static extractAxes(t){return t.filter(i=>Array.isArray(i)&&i[0]==="AXIS").map(i=>this.convertAxis(i)).sort((i,s)=>(i.order||0)-(s.order||0))}static convert(t,i={}){switch(t[0]){case"PROJCRS":i.type="ProjectedCRS",i.name=t[1],i.base_crs=t.find(m=>Array.isArray(m)&&m[0]==="BASEGEOGCRS")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="BASEGEOGCRS")):null,i.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&&(i.coordinate_system={subtype:s[1],axis:this.extractAxes(t)});let r=t.find(m=>Array.isArray(m)&&m[0]==="LENGTHUNIT");if(r){let m=this.convertUnit(r);i.coordinate_system.unit=m}i.id=this.getId(t);break;case"BASEGEOGCRS":case"GEOGCRS":case"GEODCRS":i.type=t[0]==="GEODCRS"?"GeodeticCRS":"GeographicCRS",i.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"?i.datum_ensemble=m:i.datum=m;let g=t.find(_=>Array.isArray(_)&&_[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");i.coordinate_system={subtype:o?o[1]:"ellipsoidal",axis:this.extractAxes(t)},i.id=this.getId(t);break;case"DATUM":i.type="GeodeticReferenceFrame",i.name=t[1],i.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":i.type="DatumEnsemble",i.name=t[1],i.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&&(i.accuracy=parseFloat(a[1]));let h=t.find(m=>Array.isArray(m)&&m[0]==="ELLIPSOID");h&&(i.ellipsoid=this.convert(h)),i.id=this.getId(t);break;case"ELLIPSOID":i.type="Ellipsoid",i.name=t[1],i.semi_major_axis=parseFloat(t[2]),i.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"),i):null;break;case"CONVERSION":i.type="Conversion",i.name=t[1],i.method=t.find(m=>Array.isArray(m)&&m[0]==="METHOD")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="METHOD")):null,i.parameters=t.filter(m=>Array.isArray(m)&&m[0]==="PARAMETER").map(m=>this.convert(m));break;case"METHOD":i.type="Method",i.name=t[1],i.id=this.getId(t);break;case"PARAMETER":i.type="Parameter",i.name=t[1],i.value=parseFloat(t[2]),i.unit=this.convertUnit(t.find(m=>Array.isArray(m)&&(m[0]==="LENGTHUNIT"||m[0]==="ANGLEUNIT"||m[0]==="SCALEUNIT"))),i.id=this.getId(t);break;case"BOUNDCRS":i.type="BoundCRS";let l=t.find(m=>Array.isArray(m)&&m[0]==="SOURCECRS");if(l){let m=l.find(g=>Array.isArray(g));i.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));i.target_crs=m?this.convert(m):null}let f=t.find(m=>Array.isArray(m)&&m[0]==="ABRIDGEDTRANSFORMATION");f?i.transformation=this.convert(f):i.transformation=null;break;case"ABRIDGEDTRANSFORMATION":if(i.type="Transformation",i.name=t[1],i.method=t.find(m=>Array.isArray(m)&&m[0]==="METHOD")?this.convert(t.find(m=>Array.isArray(m)&&m[0]==="METHOD")):null,i.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}}}),i.parameters.length===7){let m=i.parameters[6];m.name==="Scale difference"&&(m.value=Math.round((m.value-1)*1e12)/1e6)}i.id=this.getId(t);break;case"AXIS":i.coordinate_system||(i.coordinate_system={type:"unspecified",axis:[]}),i.coordinate_system.axis.push(this.convertAxis(t));break;case"LENGTHUNIT":let d=this.convertUnit(t,"LinearUnit");i.coordinate_system&&i.coordinate_system.axis&&i.coordinate_system.axis.forEach(m=>{m.unit||(m.unit=d)}),d.conversion_factor&&d.conversion_factor!==1&&i.semi_major_axis&&(i.semi_major_axis={value:i.semi_major_axis,unit:d});break;default:i.keyword=t[0];break}return i}},Bh=cn;function Dh(e){return Bh.convert(e)}function Fh(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 Uh=Um,ai=1,Vh=2,kh=3,Cs=4,jh=5,ln=-1,Bm=/\s/,Dm=/[A-Za-z]/,Fm=/[A-Za-z84_]/,As=/[,\]]/,Wh=/[\d\.E\-\+]/;function jt(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=ai}jt.prototype.readCharicter=function(){var e=this.text[this.place++];if(this.state!==Cs)for(;Bm.test(e);){if(this.place>=this.text.length)return;e=this.text[this.place++]}switch(this.state){case ai:return this.neutral(e);case Vh:return this.keyword(e);case Cs:return this.quoted(e);case jh:return this.afterquote(e);case kh:return this.number(e);case ln:return}};jt.prototype.afterquote=function(e){if(e==='"'){this.word+='"',this.state=Cs;return}if(As.test(e)){this.word=this.word.trim(),this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in afterquote yet, index '+this.place)};jt.prototype.afterItem=function(e){if(e===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=ai;return}if(e==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=ai,this.currentObject=this.stack.pop(),this.currentObject||(this.state=ln);return}};jt.prototype.number=function(e){if(Wh.test(e)){this.word+=e;return}if(As.test(e)){this.word=parseFloat(this.word),this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in number yet, index '+this.place)};jt.prototype.quoted=function(e){if(e==='"'){this.state=jh;return}this.word+=e};jt.prototype.keyword=function(e){if(Fm.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=ai;return}if(As.test(e)){this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in keyword yet, index '+this.place)};jt.prototype.neutral=function(e){if(Dm.test(e)){this.word=e,this.state=Vh;return}if(e==='"'){this.word="",this.state=Cs;return}if(Wh.test(e)){this.word=e,this.state=kh;return}if(As.test(e)){this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in neutral yet, index '+this.place)};jt.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===ln)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function Um(e){var t=new jt(e);return t.output()}function un(e,t,i){Array.isArray(t)&&(i.unshift(t),t=null);var s=t?{}:e,r=i.reduce(function(n,o){return ne(o,n),n},s);t&&(e[t]=r)}function ne(e,t){if(!Array.isArray(e)){t[e]=!0;return}var i=e.shift();if(i==="PARAMETER"&&(i=e.shift()),e.length===1){if(Array.isArray(e[0])){t[i]={},ne(e[0],t[i]);return}t[i]=e[0];return}if(!e.length){t[i]=!0;return}if(i==="TOWGS84"){t[i]=e;return}if(i==="AXIS"){i in t||(t[i]=[]),t[i].push(e);return}Array.isArray(i)||(t[i]={});var s;switch(i){case"UNIT":case"PRIMEM":case"VERT_DATUM":t[i]={name:e[0].toLowerCase(),convert:e[1]},e.length===3&&ne(e[2],t[i]);return;case"SPHEROID":case"ELLIPSOID":t[i]={name:e[0],a:e[1],rf:e[2]},e.length===4&&ne(e[3],t[i]);return;case"EDATUM":case"ENGINEERINGDATUM":case"LOCAL_DATUM":case"DATUM":case"VERT_CS":case"VERTCRS":case"VERTICALCRS":e[0]=["name",e[0]],un(t,i,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]],un(t,i,e),t[i].type=i;return;default:for(s=-1;++s<e.length;)if(!Array.isArray(e[s]))return ne(e,t[i]);return un(t,i,e)}}var Vm=.017453292519943295;function Mt(e){return e*Vm}function Is(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=Mt(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=Mt(e.lat0>0?90:-90),delete e.lat1)}function Hh(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 Yh(e){return typeof e=="object"?e.value*e.unit.conversion_factor:e}function Zh(e,t){e.ellipsoid.radius?(t.a=e.ellipsoid.radius,t.rf=0):(t.a=Yh(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-Yh(e.ellipsoid.semi_minor_axis))))}function hi(e,t={}){return!e||typeof e!="object"?e:e.type==="BoundCRS"?(hi(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(i=>i.value)),t):(Object.keys(e).forEach(i=>{let s=e[i];if(s!==null)switch(i){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,Zh(s,t)),s.prime_meridian&&(t.from_greenwich=s.prime_meridian.longitude*Math.PI/180);break;case"ellipsoid":t.ellps=s.name,Zh(s,t);break;case"prime_meridian":t.long0=(s.longitude||0)*Math.PI/180;break;case"coordinate_system":if(s.axis){let r={east:"e",north:"n",west:"w",south:"s",up:"u",down:"d",geocentricx:"e",geocentricy:"n",geocentricz:"u"},n=s.axis.map(o=>r[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}=Hh(s.unit);t.units=o,t.to_meter=a}else if(s.axis[0]&&s.axis[0].unit){let{units:o,to_meter:a}=Hh(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(r=>{let n=r.name.toLowerCase().replace(/\s+/g,"_"),o=r.value;r.unit&&r.unit.conversion_factor?t[n]=o*r.unit.conversion_factor:r.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":hi(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),Is(t),t)}var km=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function jm(e,t){var i=t[0],s=t[1];!(i in e)&&s in e&&(e[i]=e[s],t.length===3&&(e[i]=t[2](e[i])))}function Xh(e){for(var t=Object.keys(e),i=0,s=t.length;i<s;++i){var r=t[i];km.indexOf(r)!==-1&&Wm(e[r]),typeof e[r]=="object"&&Xh(e[r])}}function Wm(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 i="",s=0,r=e.AXIS.length;s<r;++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"?i+="n":n[0].indexOf("south")!==-1||(n[0]==="y"||n[0]==="lat")&&n[1]==="south"?i+="s":n[0].indexOf("east")!==-1||(n[0]==="x"||n[0]==="lon")&&n[1]==="east"?i+="e":(n[0].indexOf("west")!==-1||(n[0]==="x"||n[0]==="lon")&&n[1]==="west")&&(i+="w")}i.length===2&&(i+="u"),i.length===3&&(e.axis=i)}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=Mt(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=Mt(e.rectified_grid_angle));function a(l){var u=e.to_meter||1;return l*u}var h=function(l){return jm(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",Mt],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",Mt],["x0","false_easting",a],["y0","false_northing",a],["long0","central_meridian",Mt],["lat0","latitude_of_origin",Mt],["lat0","standard_parallel_1",Mt],["lat1","standard_parallel_1",Mt],["lat2","standard_parallel_2",Mt],["azimuth","Azimuth"],["alpha","azimuth",Mt],["srsCode","name"]];c.forEach(h),Is(e)}function Ee(e){if(typeof e=="object")return hi(e);let t=Fh(e);var i=Uh(e);if(t==="WKT2"){let n=Dh(i);return hi(n)}var s=i[0],r={};return ne(i,r),Xh(r),r[s]}function lt(e){var t=this;if(arguments.length===2){var i=arguments[1];typeof i=="string"?i.charAt(0)==="+"?lt[e]=oi(arguments[1]):lt[e]=Ee(arguments[1]):i&&typeof i=="object"&&!("projName"in i)?lt[e]=Ee(arguments[1]):(lt[e]=i,i||delete lt[e])}else if(arguments.length===1){if(Array.isArray(e))return e.map(function(s){return Array.isArray(s)?lt.apply(t,s):lt(s)});if(typeof e=="string"){if(e in lt)return lt[e]}else"EPSG"in e?lt["EPSG:"+e.EPSG]=e:"ESRI"in e?lt["ESRI:"+e.ESRI]=e:"IAU2000"in e?lt["IAU2000:"+e.IAU2000]=e:console.log(e);return}}Ch(lt);var we=lt;function Hm(e){return typeof e=="string"}function Ym(e){return e in we}function Zm(e){return e.indexOf("+")!==0&&e.indexOf("[")!==-1||typeof e=="object"&&!("srsCode"in e)}var $h=["3857","900913","3785","102113"];function Xm(e){if(e.title)return e.title.toLowerCase().indexOf("epsg:")===0&&$h.indexOf(e.title.substr(5))>-1;var t=_t(e,"authority");if(t){var i=_t(t,"epsg");return i&&$h.indexOf(i)>-1}}function $m(e){var t=_t(e,"extension");if(t)return _t(t,"proj4")}function Qm(e){return e[0]==="+"}function Km(e){let t;if(Hm(e))if(Ym(e))t=we[e];else if(Zm(e)){t=Ee(e);var i=$m(t);i&&(t=oi(i))}else Qm(e)&&(t=oi(e));else"projName"in e?t=e:t=Ee(e);return t&&Xm(t)?we["EPSG:3857"]:t}var Qh=Km;function fn(e,t){e=e||{};var i,s;if(!t)return e;for(s in t)i=t[s],i!==void 0&&(e[s]=i);return e}function rt(e,t,i){var s=e*t;return i/Math.sqrt(1-s*s)}function zt(e){return e<0?-1:1}function S(e,t){return t||Math.abs(e)<=j?e:e-zt(e)*Jt}function ht(e,t,i){var s=e*i,r=.5*e;return s=Math.pow((1-s)/(1+s),r),Math.tan(.5*(x-t))/s}function Wt(e,t){for(var i=.5*e,s,r,n=x-2*Math.atan(t),o=0;o<=15;o++)if(s=e*Math.sin(n),r=x-2*Math.atan(t*Math.pow((1-s)/(1+s),i))-n,n+=r,Math.abs(r)<=1e-10)return n;return-9999}function Jm(){var e=this.b/this.a;this.es=1-e*e,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.long0=this.long0||0,this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=rt(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function td(e){var t=e.x,i=e.y;if(i*X>90&&i*X<-90&&t*X>180&&t*X<-180)return null;var s,r;if(Math.abs(Math.abs(i)-x)<=v)return null;if(this.sphere)s=this.x0+this.a*this.k0*S(t-this.long0,this.over),r=this.y0+this.a*this.k0*Math.log(Math.tan(O+.5*i));else{var n=Math.sin(i),o=ht(this.e,i,n);s=this.x0+this.a*this.k0*S(t-this.long0,this.over),r=this.y0-this.a*this.k0*Math.log(o)}return e.x=s,e.y=r,e}function ed(e){var t=e.x-this.x0,i=e.y-this.y0,s,r;if(this.sphere)r=x-2*Math.atan(Math.exp(-i/(this.a*this.k0)));else{var n=Math.exp(-i/(this.a*this.k0));if(r=Wt(this.e,n),r===-9999)return null}return s=S(this.long0+t/(this.a*this.k0),this.over),e.x=s,e.y=r,e}var id=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","Mercator_Variant_A","merc"],Kh={init:Jm,forward:td,inverse:ed,names:id};function sd(){}function Jh(e){return e}var mn=["longlat","identity"],tc={init:sd,forward:Jh,inverse:Jh,names:mn};var rd=[Kh,tc],oe={},Te=[];function ec(e,t){var i=Te.length;return e.names?(Te[i]=e,e.names.forEach(function(s){oe[s.toLowerCase()]=i}),this):(console.log(t),!0)}function dn(e){return e.replace(/[-\(\)\s]+/g," ").trim().replace(/ /g,"_")}function nd(e){if(!e)return!1;var t=e.toLowerCase();if(typeof oe[t]<"u"&&Te[oe[t]]||(t=dn(t),t in oe&&Te[oe[t]]))return Te[oe[t]]}function od(){rd.forEach(ec)}var ic={start:od,add:ec,get:nd};var ad={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,b: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)"}},pn=ad;var hd=pn.WGS84;function sc(e,t,i,s){var r=e*e,n=t*t,o=(r-n)/r,a=0;s?(e*=1-o*(Oh+o*(Nh+o*Lh)),r=e*e,o=0):a=Math.sqrt(o);var h=(r-n)/n;return{es:o,e:a,ep2:h}}function rc(e,t,i,s,r){if(!e){var n=_t(pn,s);n||(n=hd),e=n.a,t=n.b,i=n.rf}return i&&!t&&(t=(1-1/i)*e),(i===0||Math.abs(e-t)<v)&&(r=!0,t=e),{a:e,b:t,rf:i,sphere:r}}var Ns={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:"clrk80ign",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(nc in Ns)Os=Ns[nc],Os.datumName&&(Ns[Os.datumName]=Os);var Os,nc,oc=Ns;function cd(e,t,i,s,r,n,o){var a={};return a.datum_type=ni,t&&(a.datum_type=Ah,a.datum_params=t.map(parseFloat),(a.datum_params[0]!==0||a.datum_params[1]!==0||a.datum_params[2]!==0)&&(a.datum_type=bt),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=Rt,a.datum_params[3]*=re,a.datum_params[4]*=re,a.datum_params[5]*=re,a.datum_params[6]=a.datum_params[6]/1e6+1)),o&&(a.datum_type=kt,a.grids=o),a.a=i,a.b=s,a.es=r,a.ep2=n,a}var ac=cd;var _n={};function Mn(e,t,i){return t instanceof ArrayBuffer?ld(e,t,i):{ready:ud(e,t)}}function ld(e,t,i){var s=!0;i!==void 0&&i.includeErrorFields===!1&&(s=!1);var r=new DataView(t),n=md(r),o=dd(r,n),a=pd(r,o,n,s),h={header:o,subgrids:a};return _n[e]=h,h}async function ud(e,t){for(var i=[],s=await t.getImageCount(),r=s-1;r>=0;r--){var n=await t.getImage(r),o=await n.readRasters(),a=o,h=[n.getWidth(),n.getHeight()],c=n.getBoundingBox().map(hc),l=typeof n.fileDirectory.getValue=="function"?n.fileDirectory.getValue("ModelPixelScale"):n.fileDirectory.ModelPixelScale,u=[l[0],l[1]].map(hc),f=c[0]+(h[0]-1)*u[0],d=c[3]-(h[1]-1)*u[1],m=a[0],g=a[1],_=[];for(let E=h[1]-1;E>=0;E--)for(let w=h[0]-1;w>=0;w--){var M=E*h[0]+w;_.push([-te(g[M]),te(m[M])])}i.push({del:u,lim:h,ll:[-f,d],cvs:_})}var y={header:{nSubgrids:s},subgrids:i};return _n[e]=y,y}function cc(e){if(e===void 0)return null;var t=e.split(",");return t.map(fd)}function fd(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 hc(e){return e*Math.PI/180}function te(e){return e/3600*Math.PI/180}function md(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 dd(e,t){return{nFields:e.getInt32(8,t),nSubgridFields:e.getInt32(24,t),nSubgrids:e.getInt32(40,t),shiftType:gn(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 gn(e,t,i){return String.fromCharCode.apply(null,new Uint8Array(e.buffer.slice(t,i)))}function pd(e,t,i,s){for(var r=176,n=[],o=0;o<t.nSubgrids;o++){var a=_d(e,r,i),h=Md(e,r,a,i,s),c=Math.round(1+(a.upperLongitude-a.lowerLongitude)/a.longitudeInterval),l=Math.round(1+(a.upperLatitude-a.lowerLatitude)/a.latitudeInterval);n.push({ll:[te(a.lowerLongitude),te(a.lowerLatitude)],del:[te(a.longitudeInterval),te(a.latitudeInterval)],lim:[c,l],count:a.gridNodeCount,cvs:gd(h)});var u=16;s===!1&&(u=8),r+=176+a.gridNodeCount*u}return n}function gd(e){return e.map(function(t){return[te(t.longitudeShift),te(t.latitudeShift)]})}function _d(e,t,i){return{name:gn(e,t+8,t+16).trim(),parent:gn(e,t+24,t+24+8).trim(),lowerLatitude:e.getFloat64(t+72,i),upperLatitude:e.getFloat64(t+88,i),lowerLongitude:e.getFloat64(t+104,i),upperLongitude:e.getFloat64(t+120,i),latitudeInterval:e.getFloat64(t+136,i),longitudeInterval:e.getFloat64(t+152,i),gridNodeCount:e.getInt32(t+168,i)}}function Md(e,t,i,s,r){var n=t+176,o=16;r===!1&&(o=8);for(var a=[],h=0;h<i.gridNodeCount;h++){var c={latitudeShift:e.getFloat32(n+h*o,s),longitudeShift:e.getFloat32(n+h*o+4,s)};r!==!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 Pe(e,t){if(!(this instanceof Pe))return new Pe(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 i=Qh(e);if(typeof i!="object"){t("Could not parse to valid json: "+e);return}var s=Pe.projections.get(i.projName);if(!s){t("Could not get projection name from: "+e);return}if(i.datumCode&&i.datumCode!=="none"){var r=_t(oc,i.datumCode);r&&(i.datum_params=i.datum_params||(r.towgs84?r.towgs84.split(","):null),i.ellps=r.ellipse,i.datumName=r.datumName?r.datumName:i.datumCode)}i.axis=i.axis||"enu",i.ellps=i.ellps||"wgs84",i.lat1=i.lat1||i.lat0;var n=rc(i.a,i.b,i.rf,i.ellps,i.sphere),o=sc(n.a,n.b,n.rf,i.R_A),a=cc(i.nadgrids),h=i.datum||ac(i.datumCode,i.datum_params,n.a,n.b,o.es,o.ep2,a);fn(this,i),fn(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(),this.k0||(this.k0=1),t(null,this)}Pe.projections=ic;Pe.projections.start();var Ct=Pe;function lc(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===bt?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===Rt?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 Ls(e,t,i){var s=e.x,r=e.y,n=e.z?e.z:0,o,a,h,c;if(r<-x&&r>-1.001*x)r=-x;else if(r>x&&r<1.001*x)r=x;else{if(r<-x)return{x:-1/0,y:-1/0,z:e.z};if(r>x)return{x:1/0,y:1/0,z:e.z}}return s>Math.PI&&(s-=2*Math.PI),a=Math.sin(r),c=Math.cos(r),h=a*a,o=i/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 Gs(e,t,i,s){var r=1e-12,n=r*r,o=30,a,h,c,l,u,f,d,m,g,_,M,y,E,w=e.x,T=e.y,P=e.z?e.z:0,R,A,C;if(a=Math.sqrt(w*w+T*T),h=Math.sqrt(w*w+T*T+P*P),a/i<r){if(R=0,h/i<r)return A=x,C=-s,{x:e.x,y:e.y,z:e.z}}else R=Math.atan2(T,w);c=P/h,l=a/h,u=1/Math.sqrt(1-t*(2-t)*l*l),m=l*(1-t)*u,g=c*u,E=0;do E++,d=i/Math.sqrt(1-t*g*g),C=a*m+P*g-d*(1-t*g*g),f=t*d/(d+C),u=1/Math.sqrt(1-f*(2-f)*l*l),_=l*(1-f)*u,M=c*u,y=M*m-_*g,m=_,g=M;while(y*y>n&&E<o);return A=Math.atan(M/Math.abs(_)),{x:R,y:A,z:C}}function uc(e,t,i){if(t===bt)return{x:e.x+i[0],y:e.y+i[1],z:e.z+i[2]};if(t===Rt){var s=i[0],r=i[1],n=i[2],o=i[3],a=i[4],h=i[5],c=i[6];return{x:c*(e.x-h*e.y+a*e.z)+s,y:c*(h*e.x+e.y-o*e.z)+r,z:c*(-a*e.x+o*e.y+e.z)+n}}}function fc(e,t,i){if(t===bt)return{x:e.x-i[0],y:e.y-i[1],z:e.z-i[2]};if(t===Rt){var s=i[0],r=i[1],n=i[2],o=i[3],a=i[4],h=i[5],c=i[6],l=(e.x-s)/c,u=(e.y-r)/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 zs(e){return e===bt||e===Rt}function pc(e,t,i){if(lc(e,t)||e.datum_type===ni||t.datum_type===ni)return i;var s=e.a,r=e.es;if(e.datum_type===kt){var n=mc(e,!1,i);if(n!==0)return;s=an,r=hn}var o=t.a,a=t.b,h=t.es;if(t.datum_type===kt&&(o=an,a=Ih,h=hn),r===h&&s===o&&!zs(e.datum_type)&&!zs(t.datum_type))return i;if(i=Ls(i,r,s),zs(e.datum_type)&&(i=uc(i,e.datum_type,e.datum_params)),zs(t.datum_type)&&(i=fc(i,t.datum_type,t.datum_params)),i=Gs(i,h,o,a),t.datum_type===kt){var c=mc(t,!0,i);if(c!==0)return}return i}function mc(e,t,i){if(e.grids===null||e.grids.length===0)return console.log("Grid shift grids not found"),-1;var s={x:-i.x,y:i.y},r={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){r=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,_=u.ll[1]+(u.lim[1]-1)*u.del[1]+f;if(!(m>s.y||d>s.x||_<s.y||g<s.x)&&(r=xd(s,t,u),!isNaN(r.x)))break t}}return isNaN(r.x)?(console.log("Failed to find a grid shift table for location '"+-s.x*X+" "+s.y*X+" tried: '"+n+"'"),-1):(i.x=-r.x,i.y=r.y,0)}function xd(e,t,i){var s={x:Number.NaN,y:Number.NaN};if(isNaN(e.x))return s;var r={x:e.x,y:e.y};r.x-=i.ll[0],r.y-=i.ll[1],r.x=S(r.x-Math.PI)+Math.PI;var n=dc(r,i);if(t){if(isNaN(n.x))return s;n.x=r.x-n.x,n.y=r.y-n.y;var o=9,a=1e-12,h,c;do{if(c=dc(n,i),isNaN(c.x)){console.log("Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.");break}h={x:r.x-(c.x+n.x),y:r.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=S(n.x+i.ll[0]),s.y=n.y+i.ll[1]}else isNaN(n.x)||(s.x=e.x+n.x,s.y=e.y+n.y);return s}function dc(e,t){var i={x:e.x/t.del[0],y:e.y/t.del[1]},s={x:Math.floor(i.x),y:Math.floor(i.y)},r={x:i.x-1*s.x,y:i.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=r.x*r.y,f=r.x*(1-r.y),d=(1-r.x)*(1-r.y),m=(1-r.x)*r.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 ae=["x","y","z"];function gc(e,t){let i={};for(let s=0,r=e.axis.length;s<r;s++){if(s===2&&t.z===void 0)continue;let n=t[ae[s]];switch(e.axis[s]){case"e":i.x=n;break;case"w":i.x=-n;break;case"n":i.y=n;break;case"s":i.y=-n;break;case"u":i.z=n;break;case"d":i.z=-n;break;default:return null}}return i}function _c(e,t){let i={};for(let s=0,r=e.axis.length;s<r;s++)if(!(s===2&&t.z===void 0))switch(e.axis[s]){case"e":i[ae[s]]=t.x;break;case"w":i[ae[s]]=-t.x;break;case"n":i[ae[s]]=t.y;break;case"s":i[ae[s]]=-t.y;break;case"u":i[ae[s]]=t.z;break;case"d":i[ae[s]]=-t.z;break;default:return null}return i}function be(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 xc(e){Mc(e.x),Mc(e.y)}function Mc(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 yd(e,t){return(e.datum.datum_type===bt||e.datum.datum_type===Rt||e.datum.datum_type===kt)&&t.datumCode!=="WGS84"||(t.datum.datum_type===bt||t.datum.datum_type===Rt||t.datum.datum_type===kt)&&e.datumCode!=="WGS84"}function ci(e,t,i,s){var r,n=i.z!==void 0;if(xc(i),e.datum&&t.datum&&yd(e,t)&&(r=new Ct("WGS84"),i=ci(e,r,i,s),e=r),s&&e.axis!=="enu"&&(i=gc(e,i)),e.projName==="longlat")i={x:i.x*B,y:i.y*B,z:i.z||0};else if(e.to_meter&&(i={x:i.x*e.to_meter,y:i.y*e.to_meter,z:i.z||0}),i=e.inverse(i),!i)return;if(e.from_greenwich&&(i.x+=e.from_greenwich),i=pc(e.datum,t.datum,i),!!i)return i=i,t.from_greenwich&&(i={x:i.x-t.from_greenwich,y:i.y,z:i.z||0}),t.projName==="longlat"?(t.long_wrap!==void 0&&(i.x=t.long_wrap+S(i.x-t.long_wrap)),i={x:i.x*X,y:i.y*X,z:i.z||0}):(i=t.forward(i),t.to_meter&&(i={x:i.x/t.to_meter,y:i.y/t.to_meter,z:i.z||0})),s&&t.axis!=="enu"?_c(t,i):(i&&!n&&t.projName!=="geocent"&&delete i.z,i)}function xn(e,t,i,s){var r;return Array.isArray(i)?r=be(i):r={x:i.x,y:i.y,z:i.z,m:i.m},ci(e,t,r,s)}var yc=Ct("WGS84");function yn(e,t,i,s){var r,n,o;return Array.isArray(i)?(r=ci(e,t,be(i),s)||{x:NaN,y:NaN},i.length>2?(n=typeof e.name<"u"&&e.name==="geocent"||typeof t.name<"u"&&t.name==="geocent",n?typeof r.z=="number"?[r.x,r.y,r.z].concat(i.slice(3)):[r.x,r.y,i[2]].concat(i.slice(3)):s&&typeof r.z=="number"?[r.x,r.y,r.z].concat(i.slice(3)):[r.x,r.y].concat(i.slice(2))):[r.x,r.y]):(r=ci(e,t,{x:i.x,y:i.y,z:i.z,m:i.m},s)||{x:NaN,y:NaN},o=Object.keys(i),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)||(r[a]=i[a])})),r)}function qs(e){return e instanceof Ct?e:typeof e=="object"&&"oProj"in e?e.oProj:Ct(e)}function Sd(e,t,i){var s,r,n=!1,o;return typeof t>"u"?(r=qs(e),s=yc,n=!0):(typeof t.x<"u"||Array.isArray(t))&&(i=t,r=qs(e),s=yc,n=!0),s||(s=qs(e)),r||(r=qs(t)),i?yn(s,r,i):(o={forward:function(a,h){return yn(s,r,a,h)},inverse:function(a,h){return yn(r,s,a,h)}},n&&(o.oProj=r),o)}var Sc=Sd;var vc=6,wc="AJSAJS",Tc="AFAFAF",Re=65,ut=73,wt=79,li=86,ui=90,Pc={forward:vn,inverse:vd,toPoint:En};function vn(e,t){return t=t||5,Td(Ed({lat:e[1],lon:e[0]}),t)}function vd(e){var t=wn(Rc(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat,t.lon,t.lat]:[t.left,t.bottom,t.right,t.top]}function En(e){var t=wn(Rc(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}function Sn(e){return e*(Math.PI/180)}function Ec(e){return 180*(e/Math.PI)}function Ed(e){var t=e.lat,i=e.lon,s=6378137,r=.00669438,n=.9996,o,a,h,c,l,u,f,d=Sn(t),m=Sn(i),g,_;_=Math.floor((i+180)/6)+1,i===180&&(_=60),t>=56&&t<64&&i>=3&&i<12&&(_=32),t>=72&&t<84&&(i>=0&&i<9?_=31:i>=9&&i<21?_=33:i>=21&&i<33?_=35:i>=33&&i<42&&(_=37)),o=(_-1)*6-180+3,g=Sn(o),a=r/(1-r),h=s/Math.sqrt(1-r*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-r/4-3*r*r/64-5*r*r*r/256)*d-(3*r/8+3*r*r/32+45*r*r*r/1024)*Math.sin(2*d)+(15*r*r/256+45*r*r*r/1024)*Math.sin(4*d)-35*r*r*r/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,y=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&&(y+=1e7),{northing:Math.round(y),easting:Math.round(M),zoneNumber:_,zoneLetter:wd(t)}}function wn(e){var t=e.northing,i=e.easting,s=e.zoneLetter,r=e.zoneNumber;if(r<0||r>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,_,M,y,E=i-5e5,w=t;s<"N"&&(w-=1e7),_=(r-1)*6-180+3,h=a/(1-a),g=w/n,M=g/(o*(1-a/4-3*a*a/64-5*a*a*a/256)),y=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(y)*Math.sin(y)),u=Math.tan(y)*Math.tan(y),f=h*Math.cos(y)*Math.cos(y),d=o*(1-a)/Math.pow(1-a*Math.sin(y)*Math.sin(y),1.5),m=E/(l*n);var T=y-l*Math.tan(y)/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);T=Ec(T);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(y);P=_+Ec(P);var R;if(e.accuracy){var A=wn({northing:e.northing+e.accuracy,easting:e.easting+e.accuracy,zoneLetter:e.zoneLetter,zoneNumber:e.zoneNumber});R={top:A.lat,right:A.lon,bottom:T,left:P}}else R={lat:T,lon:P};return R}function wd(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 Td(e,t){var i="00000"+e.easting,s="00000"+e.northing;return e.zoneNumber+e.zoneLetter+Pd(e.easting,e.northing,e.zoneNumber)+i.substr(i.length-5,t)+s.substr(s.length-5,t)}function Pd(e,t,i){var s=bc(i),r=Math.floor(e/1e5),n=Math.floor(t/1e5)%20;return bd(r,n,s)}function bc(e){var t=e%vc;return t===0&&(t=vc),t}function bd(e,t,i){var s=i-1,r=wc.charCodeAt(s),n=Tc.charCodeAt(s),o=r+e-1,a=n+t,h=!1;o>ui&&(o=o-ui+Re-1,h=!0),(o===ut||r<ut&&o>ut||(o>ut||r<ut)&&h)&&o++,(o===wt||r<wt&&o>wt||(o>wt||r<wt)&&h)&&(o++,o===ut&&o++),o>ui&&(o=o-ui+Re-1),a>li?(a=a-li+Re-1,h=!0):h=!1,(a===ut||n<ut&&a>ut||(a>ut||n<ut)&&h)&&a++,(a===wt||n<wt&&a>wt||(a>wt||n<wt)&&h)&&(a++,a===ut&&a++),a>li&&(a=a-li+Re-1);var c=String.fromCharCode(o)+String.fromCharCode(a);return c}function Rc(e){if(e&&e.length===0)throw"MGRSPoint coverting from nothing";for(var t=e.length,i=null,s="",r,n=0;!/[A-Z]/.test(r=e.charAt(n));){if(n>=2)throw"MGRSPoint bad conversion from: "+e;s+=r,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;i=e.substring(n,n+=2);for(var h=bc(o),c=Rd(i.charAt(0),h),l=Cd(i.charAt(1),h);l<Ad(a);)l+=2e6;var u=t-n;if(u%2!==0)throw`MGRSPoint has to have an even number
7
+ "use strict";var __exports__=(()=>{var c0=Object.create;var Xr=Object.defineProperty;var l0=Object.getOwnPropertyDescriptor;var u0=Object.getOwnPropertyNames;var f0=Object.getPrototypeOf,d0=Object.prototype.hasOwnProperty;var m0=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Ns=(e,t)=>{for(var r in t)Xr(e,r,{get:t[r],enumerable:!0})},Yr=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of u0(t))!d0.call(e,s)&&s!==r&&Xr(e,s,{get:()=>t[s],enumerable:!(i=l0(t,s))||i.enumerable});return e},Zr=(e,t,r)=>(Yr(e,t,"default"),r&&Yr(r,t,"default")),p0=(e,t,r)=>(r=e!=null?c0(f0(e)):{},Yr(t||!e||!e.__esModule?Xr(r,"default",{value:e,enumerable:!0}):r,e)),g0=e=>Yr(Xr({},"__esModule",{value:!0}),e);var Po=m0((K_,bo)=>{bo.exports=globalThis.loaders});var Hr={};Ns(Hr,{I3SSource:()=>xs,I3SSpatialTransformer:()=>Ye,ImageSet:()=>Es,IndexedArchiveTilesetSource:()=>zi,LOD_METRIC_TYPE:()=>ve,PointCloudTile:()=>Xe,PointCloudTileset:()=>ws,RasterSet:()=>Ts,STRATEGY_DEFAULT:()=>jr,STRATEGY_NEVER:()=>Eo,STRATEGY_REPLACE:()=>To,SharedTile2DHeader:()=>me,SpatialCoordinateTransformer:()=>bt,TILESET_TYPE:()=>at,TILE_CONTENT_STATE:()=>et,TILE_REFINEMENT:()=>$,TILE_TYPE:()=>Dt,Tile3D:()=>vt,Tiles3DSource:()=>gs,Tiles3DSpatialTransformer:()=>re,Tileset2D:()=>Vr,Tileset3D:()=>Bi,TilesetCache:()=>Te,TilesetTraverser:()=>Bt,applyTilesetSpatialOptions:()=>ae,calculateTransformProps:()=>Ii,convertS2BoundingVolumeToOBB:()=>ms,createBoundingVolume:()=>Pe,createImplicitSubtreeReference:()=>_o,createTilesetSpatialReference:()=>yt,get3DTilesSpatialReference:()=>ji,getFrameState:()=>Oi,getGeoidModel:()=>ls,getI3SSpatialReference:()=>Vi,getLodStatus:()=>ki,getSpatialCoordinateFrame:()=>ht,getTileset3DTraversalSnapshot:()=>$h,isTileset3DSource:()=>Di,markTilesetSpatialReferenceTransformed:()=>be,materializeImplicitSubtree:()=>ps,registerGeoidModel:()=>co,registerGeoidModelFromPgm:()=>mu,registerSpatialCrs:()=>fu,registerSpatialDatumGrid:()=>du,replaceImplicitUrlTemplate:()=>Ur});Zr(Hr,p0(Po(),1));var z={};Ns(z,{EPSILON1:()=>_0,EPSILON10:()=>b0,EPSILON11:()=>P0,EPSILON12:()=>R0,EPSILON13:()=>C0,EPSILON14:()=>Kr,EPSILON15:()=>A0,EPSILON16:()=>I0,EPSILON17:()=>O0,EPSILON18:()=>N0,EPSILON19:()=>L0,EPSILON2:()=>y0,EPSILON20:()=>G0,EPSILON3:()=>M0,EPSILON4:()=>x0,EPSILON5:()=>S0,EPSILON6:()=>E0,EPSILON7:()=>T0,EPSILON8:()=>v0,EPSILON9:()=>w0,PI:()=>pe,PI_OVER_FOUR:()=>B0,PI_OVER_SIX:()=>z0,PI_OVER_TWO:()=>D0,TWO_PI:()=>Ze});var _0=.1,y0=.01,M0=.001,x0=1e-4,S0=1e-5,E0=1e-6,T0=1e-7,v0=1e-8,w0=1e-9,b0=1e-10,P0=1e-11,R0=1e-12,C0=1e-13,Kr=1e-14,A0=1e-15,I0=1e-16,O0=1e-17,N0=1e-18,L0=1e-19,G0=1e-20,D0=Math.PI/2,B0=Math.PI/4,z0=Math.PI/6,pe=Math.PI,Ze=Math.PI*2;var q0=1/Math.PI*180,F0=1/180*Math.PI,k0={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...k0}};var V=globalThis.mathgl.config;function Ls(e,{precision:t=V.precision}={}){return e=V0(e),`${parseFloat(e.toPrecision(t))}`}function Lt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Gs(e){return Qr(e)}function Ds(e){return ot(e)}function Qr(e,t){return zs(e,r=>r*F0,t)}function ot(e,t){return zs(e,r=>r*q0,t)}function Ro(e,t){return Math.sign(e)===Math.sign(t)&&Math.abs(e)<Math.abs(t)?e:(e%t+t)%t}function Bs(e,t){switch(t){case"negative-pi-to-pi":return U0(e);case"zero-to-two-pi":return Co(e);default:return e}}function Co(e){if(e>=0&&e<=Ze)return e;let t=Ro(e,Ze);return Math.abs(t)<1e-14&&Math.abs(e)>1e-14?Ze:t}function U0(e){return e>=-pe&&e<=pe?e:Co(e+pe)-pe}function Ke(e,t,r){return zs(e,i=>Math.max(t,Math.min(r,i)))}function gt(e,t,r){let i=V.EPSILON;r&&(V.EPSILON=r);try{if(e===t)return!0;if(Lt(e)&&Lt(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!gt(e[s],t[s]))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)<=V.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{V.EPSILON=i}}function V0(e){return Math.round(e/V.EPSILON)*V.EPSILON}function j0(e){return e.clone?e.clone():new Array(e.length)}function zs(e,t,r){if(Lt(e)){let i=e;r=r||j0(i);for(let s=0;s<r.length&&s<i.length;++s){let n=typeof e=="number"?e:e[s];r[s]=t(n,s,r)}return r}return t(e)}var Qt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=t[i+r];return this.check()}toArray(t=[],r=0){for(let i=0;i<this.ELEMENTS;++i)t[r+i]=this[i];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Lt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(V)}formatString(t){let r="";for(let i=0;i<this.ELEMENTS;++i)r+=(i>0?", ":"")+Ls(this[i],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(!gt(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,i){if(i===void 0)return this.lerp(this,t,r);for(let s=0;s<this.ELEMENTS;++s){let n=t[s],o=typeof r=="number"?r:r[s];this[s]=n+i*(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 i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],t[i]),r[i]);return this.check()}add(...t){for(let r of t)for(let i=0;i<this.ELEMENTS;++i)this[i]+=r[i];return this.check()}subtract(...t){for(let r of t)for(let i=0;i<this.ELEMENTS;++i)this[i]-=r[i];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(V.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}};function W0(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 F(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function ge(e,t,r=""){if(V.debug&&!W0(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}var _e=class extends Qt{toString(){let t="[";if(V.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let i=0;i<this.RANK;++i)t+=` ${this[i*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,i){return this[r*this.RANK+t]=F(i),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let i=t*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[i+s];return r}setColumn(t,r){let i=t*this.RANK;for(let s=0;s<this.RANK;++s)this[i+s]=r[s];return this}};function Q(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var ye=class extends Qt{get x(){return this[0]}set x(t){this[0]=F(t)}get y(){return this[1]}set y(t){this[1]=F(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 i=0;i<this.ELEMENTS;++i){let s=this[i]-t[i];r+=s*s}return F(r)}dot(t){let r=0;for(let i=0;i<this.ELEMENTS;++i)r+=this[i]*t[i];return F(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 i=0;i<this.ELEMENTS;++i)this[i]*=r[i];return this.check()}divide(...t){for(let r of t)for(let i=0;i<this.ELEMENTS;++i)this[i]/=r[i];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Q(t>=0&&t<this.ELEMENTS,"index is out of range"),F(this[t])}setComponent(t,r){return Q(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){for(let i=0;i<this.ELEMENTS;++i)this[i]+=t[i]*r;return this.check()}};var Jr=typeof Float32Array<"u"?Float32Array:Array;var dy=Math.PI/180;function Ao(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s,e[1]=r[1]*i+r[3]*s,e}function Io(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s+r[4],e[1]=r[1]*i+r[3]*s+r[5],e}function ti(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[3]*s+r[6],e[1]=r[1]*i+r[4]*s+r[7],e}function ei(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[4]*s+r[12],e[1]=r[1]*i+r[5]*s+r[13],e}function ri(e,t,r){let i=t[0],s=t[1],n=r[3]*i+r[7]*s||1;return e[0]=(r[0]*i+r[4]*s)/n,e[1]=(r[1]*i+r[5]*s)/n,e}function ii(e,t,r){let i=t[0],s=t[1],n=t[2],o=r[3]*i+r[7]*s+r[11]*n||1;return e[0]=(r[0]*i+r[4]*s+r[8]*n)/o,e[1]=(r[1]*i+r[5]*s+r[9]*n)/o,e[2]=(r[2]*i+r[6]*s+r[10]*n)/o,e}function Oo(e,t,r){let i=t[0],s=t[1];return e[0]=r[0]*i+r[2]*s,e[1]=r[1]*i+r[3]*s,e[2]=t[2],e}function No(e,t,r){let i=t[0],s=t[1],n=t[2];return e[0]=r[0]*i+r[3]*s+r[6]*n,e[1]=r[1]*i+r[4]*s+r[7]*n,e[2]=r[2]*i+r[5]*s+r[8]*n,e[3]=t[3],e}var St=class extends ye{constructor(t=0,r=0){super(2),Lt(t)&&arguments.length===1?this.copy(t):(V.debug&&(F(t),F(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 V.debug&&(F(t.x),F(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 ei(this,this,t),this.check()}transformAsVector(t){return ri(this,this,t),this.check()}transformByMatrix3(t){return ti(this,this,t),this.check()}transformByMatrix2x3(t){return Io(this,this,t),this.check()}transformByMatrix2(t){return Ao(this,this,t),this.check()}};function Lo(){let e=new Jr(3);return Jr!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function qs(e){let t=e[0],r=e[1],i=e[2];return Math.sqrt(t*t+r*r+i*i)}function Fs(e,t,r){let i=new Jr(3);return i[0]=e,i[1]=t,i[2]=r,i}function Go(e,t){let r=t[0],i=t[1],s=t[2],n=r*r+i*i+s*s;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 Me(e,t,r){let i=t[0],s=t[1],n=t[2],o=r[0],a=r[1],h=r[2];return e[0]=s*h-n*a,e[1]=n*o-i*h,e[2]=i*a-s*o,e}function si(e,t,r){let i=t[0],s=t[1],n=t[2],o=r[3]*i+r[7]*s+r[11]*n+r[15];return o=o||1,e[0]=(r[0]*i+r[4]*s+r[8]*n+r[12])/o,e[1]=(r[1]*i+r[5]*s+r[9]*n+r[13])/o,e[2]=(r[2]*i+r[6]*s+r[10]*n+r[14])/o,e}function ni(e,t,r){let i=t[0],s=t[1],n=t[2];return e[0]=i*r[0]+s*r[3]+n*r[6],e[1]=i*r[1]+s*r[4]+n*r[7],e[2]=i*r[2]+s*r[5]+n*r[8],e}function Do(e,t,r){let i=r[0],s=r[1],n=r[2],o=r[3],a=t[0],h=t[1],c=t[2],l=s*c-n*h,u=n*a-i*c,f=i*h-s*a,m=s*f-n*u,d=n*l-i*f,g=i*u-s*l,_=o*2;return l*=_,u*=_,f*=_,m*=2,d*=2,g*=2,e[0]=a+l+m,e[1]=h+u+d,e[2]=c+f+g,e}function Bo(e,t,r,i){let s=[],n=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],n[0]=s[0],n[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),n[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function zo(e,t,r,i){let s=[],n=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],n[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),n[1]=s[1],n[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function qo(e,t,r,i){let s=[],n=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],n[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),n[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),n[2]=s[2],e[0]=n[0]+r[0],e[1]=n[1]+r[1],e[2]=n[2]+r[2],e}function Fo(e,t){let r=e[0],i=e[1],s=e[2],n=t[0],o=t[1],a=t[2],h=Math.sqrt((r*r+i*i+s*s)*(n*n+o*o+a*a)),c=h&&Je(e,t)/h;return Math.acos(Math.min(Math.max(c,-1),1))}var ko=qs;var ks=[0,0,0],oi,p=class e extends ye{static get ZERO(){return oi||(oi=new e(0,0,0),Object.freeze(oi)),oi}constructor(t=0,r=0,i=0){super(-0,-0,-0),arguments.length===1&&Lt(t)?this.copy(t):(V.debug&&(F(t),F(r),F(i)),this[0]=t,this[1]=r,this[2]=i)}set(t,r,i){return this[0]=t,this[1]=r,this[2]=i,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return V.debug&&(F(t.x),F(t.y),F(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]=F(t)}angle(t){return Fo(this,t)}cross(t){return Me(this,this,t),this.check()}rotateX({radians:t,origin:r=ks}){return Bo(this,this,r,t),this.check()}rotateY({radians:t,origin:r=ks}){return zo(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=ks}){return qo(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return si(this,this,t),this.check()}transformAsVector(t){return ii(this,this,t),this.check()}transformByMatrix3(t){return ni(this,this,t),this.check()}transformByMatrix2(t){return Oo(this,this,t),this.check()}transformByQuaternion(t){return Do(this,this,t),this.check()}};function Uo(e,t){if(e===t){let r=t[1],i=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=i,e[7]=s}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 Vo(e,t){let r=t[0],i=t[1],s=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,m=c*n-o*h,d=r*u+i*f+s*m;return d?(d=1/d,e[0]=u*d,e[1]=(-l*i+s*c)*d,e[2]=(a*i-s*o)*d,e[3]=f*d,e[4]=(l*r-s*h)*d,e[5]=(-a*r+s*n)*d,e[6]=m*d,e[7]=(-c*r+i*h)*d,e[8]=(o*r-i*n)*d,e):null}function jo(e){let t=e[0],r=e[1],i=e[2],s=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*s+o*a)+i*(h*s-n*a)}function Us(e,t,r){let i=t[0],s=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],m=r[1],d=r[2],g=r[3],_=r[4],y=r[5],M=r[6],T=r[7],v=r[8];return e[0]=f*i+m*o+d*c,e[1]=f*s+m*a+d*l,e[2]=f*n+m*h+d*u,e[3]=g*i+_*o+y*c,e[4]=g*s+_*a+y*l,e[5]=g*n+_*h+y*u,e[6]=M*i+T*o+v*c,e[7]=M*s+T*a+v*l,e[8]=M*n+T*h+v*u,e}function Wo(e,t,r){let i=t[0],s=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],m=r[1];return e[0]=i,e[1]=s,e[2]=n,e[3]=o,e[4]=a,e[5]=h,e[6]=f*i+m*o+c,e[7]=f*s+m*a+l,e[8]=f*n+m*h+u,e}function Ho(e,t,r){let i=t[0],s=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),m=Math.cos(r);return e[0]=m*i+f*o,e[1]=m*s+f*a,e[2]=m*n+f*h,e[3]=m*o-f*i,e[4]=m*a-f*s,e[5]=m*h-f*n,e[6]=c,e[7]=l,e[8]=u,e}function Vs(e,t,r){let i=r[0],s=r[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function $o(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r+r,a=i+i,h=s+s,c=r*o,l=i*o,u=i*a,f=s*o,m=s*a,d=s*h,g=n*o,_=n*a,y=n*h;return e[0]=1-u-d,e[3]=l-y,e[6]=f+_,e[1]=l+y,e[4]=1-c-d,e[7]=m-g,e[2]=f-_,e[5]=m+g,e[8]=1-c-u,e}var js;(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"})(js||(js={}));var Y0=Object.freeze([1,0,0,0,1,0,0,0,1]),k=class extends _e{static get IDENTITY(){return Z0()}static get ZERO(){return X0()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return js}constructor(t){super(-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.check()}identity(){return this.copy(Y0)}fromObject(t){return this.check()}fromQuaternion(t){return $o(this,t),this.check()}fromMatrix4(t){return this.set(t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10])}set(t,r,i,s,n,o,a,h,c){return this[0]=t,this[1]=r,this[2]=i,this[3]=s,this[4]=n,this[5]=o,this[6]=a,this[7]=h,this[8]=c,this.check()}setRowMajor(t,r,i,s,n,o,a,h,c){return this[0]=t,this[1]=s,this[2]=a,this[3]=r,this[4]=n,this[5]=h,this[6]=i,this[7]=o,this[8]=c,this.check()}determinant(){return jo(this)}transpose(){return Uo(this,this),this.check()}invert(){return Vo(this,this),this.check()}multiplyLeft(t){return Us(this,t,this),this.check()}multiplyRight(t){return Us(this,this,t),this.check()}rotate(t){return Ho(this,this,t),this.check()}scale(t){return Array.isArray(t)?Vs(this,this,t):Vs(this,this,[t,t]),this.check()}translate(t){return Wo(this,this,t),this.check()}transform(t,r){let i;switch(t.length){case 2:i=ti(r||[-0,-0],t,this);break;case 3:i=ni(r||[-0,-0,-0],t,this);break;case 4:i=No(r||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ge(i,t.length),i}},ai,hi=null;function X0(){return ai||(ai=new k([0,0,0,0,0,0,0,0,0]),Object.freeze(ai)),ai}function Z0(){return hi||(hi=new k,Object.freeze(hi)),hi}function K0(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 Yo(e,t){if(e===t){let r=t[1],i=t[2],s=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]=i,e[9]=n,e[11]=t[14],e[12]=s,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 Xo(e,t){let r=t[0],i=t[1],s=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],m=t[11],d=t[12],g=t[13],_=t[14],y=t[15],M=r*a-i*o,T=r*h-s*o,v=r*c-n*o,w=i*h-s*a,b=i*c-n*a,R=s*c-n*h,I=l*g-u*d,A=l*_-f*d,O=l*y-m*d,N=u*_-f*g,L=u*y-m*g,H=f*y-m*_,D=M*H-T*L+v*N+w*O-b*A+R*I;return D?(D=1/D,e[0]=(a*H-h*L+c*N)*D,e[1]=(s*L-i*H-n*N)*D,e[2]=(g*R-_*b+y*w)*D,e[3]=(f*b-u*R-m*w)*D,e[4]=(h*O-o*H-c*A)*D,e[5]=(r*H-s*O+n*A)*D,e[6]=(_*v-d*R-y*T)*D,e[7]=(l*R-f*v+m*T)*D,e[8]=(o*L-a*O+c*I)*D,e[9]=(i*O-r*L-n*I)*D,e[10]=(d*b-g*v+y*M)*D,e[11]=(u*v-l*b-m*M)*D,e[12]=(a*A-o*N-h*I)*D,e[13]=(r*N-i*A+s*I)*D,e[14]=(g*T-d*w-_*M)*D,e[15]=(l*w-u*T+f*M)*D,e):null}function Zo(e){let t=e[0],r=e[1],i=e[2],s=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],m=e[12],d=e[13],g=e[14],_=e[15],y=t*o-r*n,M=t*a-i*n,T=r*a-i*o,v=c*d-l*m,w=c*g-u*m,b=l*g-u*d,R=t*b-r*w+i*v,I=n*b-o*w+a*v,A=c*T-l*M+u*y,O=m*T-d*M+g*y;return h*R-s*I+_*A-f*O}function Ws(e,t,r){let i=t[0],s=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],m=t[10],d=t[11],g=t[12],_=t[13],y=t[14],M=t[15],T=r[0],v=r[1],w=r[2],b=r[3];return e[0]=T*i+v*a+w*u+b*g,e[1]=T*s+v*h+w*f+b*_,e[2]=T*n+v*c+w*m+b*y,e[3]=T*o+v*l+w*d+b*M,T=r[4],v=r[5],w=r[6],b=r[7],e[4]=T*i+v*a+w*u+b*g,e[5]=T*s+v*h+w*f+b*_,e[6]=T*n+v*c+w*m+b*y,e[7]=T*o+v*l+w*d+b*M,T=r[8],v=r[9],w=r[10],b=r[11],e[8]=T*i+v*a+w*u+b*g,e[9]=T*s+v*h+w*f+b*_,e[10]=T*n+v*c+w*m+b*y,e[11]=T*o+v*l+w*d+b*M,T=r[12],v=r[13],w=r[14],b=r[15],e[12]=T*i+v*a+w*u+b*g,e[13]=T*s+v*h+w*f+b*_,e[14]=T*n+v*c+w*m+b*y,e[15]=T*o+v*l+w*d+b*M,e}function Ko(e,t,r){let i=r[0],s=r[1],n=r[2],o,a,h,c,l,u,f,m,d,g,_,y;return t===e?(e[12]=t[0]*i+t[4]*s+t[8]*n+t[12],e[13]=t[1]*i+t[5]*s+t[9]*n+t[13],e[14]=t[2]*i+t[6]*s+t[10]*n+t[14],e[15]=t[3]*i+t[7]*s+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],m=t[7],d=t[8],g=t[9],_=t[10],y=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]=m,e[8]=d,e[9]=g,e[10]=_,e[11]=y,e[12]=o*i+l*s+d*n+t[12],e[13]=a*i+u*s+g*n+t[13],e[14]=h*i+f*s+_*n+t[14],e[15]=c*i+m*s+y*n+t[15]),e}function Qo(e,t,r){let i=r[0],s=r[1],n=r[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,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 Jo(e,t,r,i){let s=i[0],n=i[1],o=i[2],a=Math.sqrt(s*s+n*n+o*o),h,c,l,u,f,m,d,g,_,y,M,T,v,w,b,R,I,A,O,N,L,H,D,Ot;return a<1e-6?null:(a=1/a,s*=a,n*=a,o*=a,c=Math.sin(r),h=Math.cos(r),l=1-h,u=t[0],f=t[1],m=t[2],d=t[3],g=t[4],_=t[5],y=t[6],M=t[7],T=t[8],v=t[9],w=t[10],b=t[11],R=s*s*l+h,I=n*s*l+o*c,A=o*s*l-n*c,O=s*n*l-o*c,N=n*n*l+h,L=o*n*l+s*c,H=s*o*l+n*c,D=n*o*l-s*c,Ot=o*o*l+h,e[0]=u*R+g*I+T*A,e[1]=f*R+_*I+v*A,e[2]=m*R+y*I+w*A,e[3]=d*R+M*I+b*A,e[4]=u*O+g*N+T*L,e[5]=f*O+_*N+v*L,e[6]=m*O+y*N+w*L,e[7]=d*O+M*N+b*L,e[8]=u*H+g*D+T*Ot,e[9]=f*H+_*D+v*Ot,e[10]=m*H+y*D+w*Ot,e[11]=d*H+M*D+b*Ot,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function ta(e,t,r){let i=Math.sin(r),s=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*s+c*i,e[5]=o*s+l*i,e[6]=a*s+u*i,e[7]=h*s+f*i,e[8]=c*s-n*i,e[9]=l*s-o*i,e[10]=u*s-a*i,e[11]=f*s-h*i,e}function ea(e,t,r){let i=Math.sin(r),s=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*s-c*i,e[1]=o*s-l*i,e[2]=a*s-u*i,e[3]=h*s-f*i,e[8]=n*i+c*s,e[9]=o*i+l*s,e[10]=a*i+u*s,e[11]=h*i+f*s,e}function ra(e,t,r){let i=Math.sin(r),s=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*s+c*i,e[1]=o*s+l*i,e[2]=a*s+u*i,e[3]=h*s+f*i,e[4]=c*s-n*i,e[5]=l*s-o*i,e[6]=u*s-a*i,e[7]=f*s-h*i,e}function ia(e,t){let r=t[0],i=t[1],s=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+i*i+s*s),e[1]=Math.sqrt(n*n+o*o+a*a),e[2]=Math.sqrt(h*h+c*c+l*l),e}function sa(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r+r,a=i+i,h=s+s,c=r*o,l=i*o,u=i*a,f=s*o,m=s*a,d=s*h,g=n*o,_=n*a,y=n*h;return e[0]=1-u-d,e[1]=l+y,e[2]=f-_,e[3]=0,e[4]=l-y,e[5]=1-c-d,e[6]=m+g,e[7]=0,e[8]=f+_,e[9]=m-g,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function na(e,t,r,i,s,n,o){let a=1/(r-t),h=1/(s-i),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]=(s+i)*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 Q0(e,t,r,i,s){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,s!=null&&s!==1/0){let o=1/(i-s);e[10]=(s+i)*o,e[14]=2*s*i*o}else e[10]=-1,e[14]=-2*i;return e}var oa=Q0;function J0(e,t,r,i,s,n,o){let a=1/(t-r),h=1/(i-s),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]=(s+i)*h,e[14]=(o+n)*c,e[15]=1,e}var aa=J0;function ha(e,t,r,i){let s,n,o,a,h,c,l,u,f,m,d=t[0],g=t[1],_=t[2],y=i[0],M=i[1],T=i[2],v=r[0],w=r[1],b=r[2];return Math.abs(d-v)<1e-6&&Math.abs(g-w)<1e-6&&Math.abs(_-b)<1e-6?K0(e):(u=d-v,f=g-w,m=_-b,s=1/Math.sqrt(u*u+f*f+m*m),u*=s,f*=s,m*=s,n=M*m-T*f,o=T*u-y*m,a=y*f-M*u,s=Math.sqrt(n*n+o*o+a*a),s?(s=1/s,n*=s,o*=s,a*=s):(n=0,o=0,a=0),h=f*a-m*o,c=m*n-u*a,l=u*o-f*n,s=Math.sqrt(h*h+c*c+l*l),s?(s=1/s,h*=s,c*=s,l*=s):(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]=m,e[11]=0,e[12]=-(n*d+o*g+a*_),e[13]=-(h*d+c*g+l*_),e[14]=-(u*d+f*g+m*_),e[15]=1,e)}function ca(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 la(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 ua(e){let t=e[0],r=e[1],i=e[2],s=e[3];return Math.sqrt(t*t+r*r+i*i+s*s)}function fa(e){let t=e[0],r=e[1],i=e[2],s=e[3];return t*t+r*r+i*i+s*s}function da(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r*r+i*i+s*s+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=i*o,e[2]=s*o,e[3]=n*o,e}function ma(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function pa(e,t,r,i){let s=t[0],n=t[1],o=t[2],a=t[3];return e[0]=s+i*(r[0]-s),e[1]=n+i*(r[1]-n),e[2]=o+i*(r[2]-o),e[3]=a+i*(r[3]-a),e}function ga(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3];return e[0]=r[0]*i+r[4]*s+r[8]*n+r[12]*o,e[1]=r[1]*i+r[5]*s+r[9]*n+r[13]*o,e[2]=r[2]*i+r[6]*s+r[10]*n+r[14]*o,e[3]=r[3]*i+r[7]*s+r[11]*n+r[15]*o,e}var Ys;(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"})(Ys||(Ys={}));var ef=45*Math.PI/180,rf=1,Hs=.1,$s=500,sf=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),C=class extends _e{static get IDENTITY(){return of()}static get ZERO(){return nf()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ys}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,i,s,n,o,a,h,c,l,u,f,m,d,g,_){return this[0]=t,this[1]=r,this[2]=i,this[3]=s,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]=m,this[13]=d,this[14]=g,this[15]=_,this.check()}setRowMajor(t,r,i,s,n,o,a,h,c,l,u,f,m,d,g,_){return this[0]=t,this[1]=n,this[2]=c,this[3]=m,this[4]=r,this[5]=o,this[6]=l,this[7]=d,this[8]=i,this[9]=a,this[10]=u,this[11]=g,this[12]=s,this[13]=h,this[14]=f,this[15]=_,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(sf)}fromObject(t){return this.check()}fromQuaternion(t){return sa(this,t),this.check()}fromMatrix3(t){return this.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,1)}frustum(t){let{left:r,right:i,bottom:s,top:n,near:o=Hs,far:a=$s}=t;return a===1/0?af(this,r,i,s,n,o):na(this,r,i,s,n,o,a),this.check()}lookAt(t){let{eye:r,center:i=[0,0,0],up:s=[0,1,0]}=t;return ha(this,r,i,s),this.check()}ortho(t){let{left:r,right:i,bottom:s,top:n,near:o=Hs,far:a=$s}=t;return aa(this,r,i,s,n,o,a),this.check()}orthographic(t){let{fovy:r=ef,aspect:i=rf,focalDistance:s=1,near:n=Hs,far:o=$s}=t;_a(r);let a=r/2,h=s*Math.tan(a),c=h*i;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:i=1,near:s=.1,far:n=500}=t;return _a(r),oa(this,r,i,s,n),this.check()}determinant(){return Zo(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 i=this.getScale(r),s=1/i[0],n=1/i[1],o=1/i[2];return t[0]=this[0]*s,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*n,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,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 i=this.getScale(r),s=1/i[0],n=1/i[1],o=1/i[2];return t[0]=this[0]*s,t[1]=this[1]*n,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*n,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*n,t[8]=this[10]*o,t}transpose(){return Yo(this,this),this.check()}invert(){return Xo(this,this),this.check()}multiplyLeft(t){return Ws(this,t,this),this.check()}multiplyRight(t){return Ws(this,this,t),this.check()}rotateX(t){return ta(this,this,t),this.check()}rotateY(t){return ea(this,this,t),this.check()}rotateZ(t){return ra(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return Jo(this,this,t,r),this.check()}scale(t){return Qo(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Ko(this,this,t),this.check()}transform(t,r){return t.length===4?(r=ga(r||[-0,-0,-0,-0],t,this),ge(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:i}=t,s;switch(i){case 2:s=ei(r||[-0,-0],t,this);break;case 3:s=si(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ge(s,t.length),s}transformAsVector(t,r){let i;switch(t.length){case 2:i=ri(r||[-0,-0],t,this);break;case 3:i=ii(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ge(i,t.length),i}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,i){return this.identity().translate([t,r,i])}},ci,li;function nf(){return ci||(ci=new C([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(ci)),ci}function of(){return li||(li=new C,Object.freeze(li)),li}function _a(e){if(e>Math.PI*2)throw Error("expected radians")}function af(e,t,r,i,s,n){let o=2*n/(r-t),a=2*n/(s-i),h=(r+t)/(r-t),c=(s+i)/(s-i),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 ya(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Xs(e,t,r){r=r*.5;let i=Math.sin(r);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(r),e}function Zs(e,t,r){let i=t[0],s=t[1],n=t[2],o=t[3],a=r[0],h=r[1],c=r[2],l=r[3];return e[0]=i*l+o*a+s*c-n*h,e[1]=s*l+o*h+n*a-i*c,e[2]=n*l+o*c+i*h-s*a,e[3]=o*l-i*a-s*h-n*c,e}function Ma(e,t,r){r*=.5;let i=t[0],s=t[1],n=t[2],o=t[3],a=Math.sin(r),h=Math.cos(r);return e[0]=i*h+o*a,e[1]=s*h+n*a,e[2]=n*h-s*a,e[3]=o*h-i*a,e}function xa(e,t,r){r*=.5;let i=t[0],s=t[1],n=t[2],o=t[3],a=Math.sin(r),h=Math.cos(r);return e[0]=i*h-n*a,e[1]=s*h+o*a,e[2]=n*h+i*a,e[3]=o*h-s*a,e}function Sa(e,t,r){r*=.5;let i=t[0],s=t[1],n=t[2],o=t[3],a=Math.sin(r),h=Math.cos(r);return e[0]=i*h+s*a,e[1]=s*h-i*a,e[2]=n*h+o*a,e[3]=o*h-n*a,e}function Ea(e,t){let r=t[0],i=t[1],s=t[2];return e[0]=r,e[1]=i,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-i*i-s*s)),e}function Ta(e,t,r,i){let s=t[0],n=t[1],o=t[2],a=t[3],h=r[0],c=r[1],l=r[2],u=r[3],f,m,d,g,_;return f=s*h+n*c+o*l+a*u,f<0&&(f=-f,h=-h,c=-c,l=-l,u=-u),1-f>1e-6?(m=Math.acos(f),_=Math.sin(m),d=Math.sin((1-i)*m)/_,g=Math.sin(i*m)/_):(d=1-i,g=i),e[0]=d*s+g*h,e[1]=d*n+g*c,e[2]=d*o+g*l,e[3]=d*a+g*u,e}function va(e,t){let r=t[0],i=t[1],s=t[2],n=t[3],o=r*r+i*i+s*s+n*n,a=o?1/o:0;return e[0]=-r*a,e[1]=-i*a,e[2]=-s*a,e[3]=n*a,e}function wa(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function ba(e,t){let r=t[0]+t[4]+t[8],i;if(r>0)i=Math.sqrt(r+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let n=(s+1)%3,o=(s+2)%3;i=Math.sqrt(t[s*3+s]-t[n*3+n]-t[o*3+o]+1),e[s]=.5*i,i=.5/i,e[3]=(t[n*3+o]-t[o*3+n])*i,e[n]=(t[n*3+s]+t[s*3+n])*i,e[o]=(t[o*3+s]+t[s*3+o])*i}return e}var Pa=ca;var Ra=la,Ca=ma,Aa=pa,Ia=ua;var Oa=fa;var hf=da;var Na=(function(){let e=Lo(),t=Fs(1,0,0),r=Fs(0,1,0);return function(i,s,n){let o=Je(s,n);return o<-.999999?(Me(e,t,s),ko(e)<1e-6&&Me(e,r,s),Go(e,e),Xs(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(Me(e,s,n),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+o,hf(i,i))}})();var Et=class extends Qt{constructor(t=0,r=0,i=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,r,i,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,r,i,s){return this[0]=t,this[1]=r,this[2]=i,this[3]=s,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 ba(this,t),this.check()}fromEuler(t){switch(this.identity(),t.order){case"xyz":return this.rotateX(t.x).rotateY(t.y).rotateZ(t.z);case"yxz":return this.rotateY(t.y).rotateX(t.x).rotateZ(t.z);case"zxy":return this.rotateZ(t.z).rotateX(t.x).rotateY(t.y);case"zyx":return this.rotateZ(t.z).rotateY(t.y).rotateX(t.x);case"yzx":return this.rotateY(t.y).rotateZ(t.z).rotateX(t.x);case"xzy":return this.rotateX(t.x).rotateZ(t.z).rotateY(t.y);default:throw new Error("Unknown Euler angle order")}}fromAxisRotation(t,r){return Xs(this,t,r),this.check()}identity(){return ya(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]=F(t)}get y(){return this[1]}set y(t){this[1]=F(t)}get z(){return this[2]}set z(t){this[2]=F(t)}get w(){return this[3]}set w(t){this[3]=F(t)}len(){return Ia(this)}lengthSquared(){return Oa(this)}dot(t){return Ca(this,t)}rotationTo(t,r){return Na(this,t,r),this.check()}add(t){return Pa(this,this,t),this.check()}calculateW(){return Ea(this,this),this.check()}conjugate(){return wa(this,this),this.check()}invert(){return va(this,this),this.check()}lerp(t,r,i){return i===void 0?this.lerp(this,t,r):(Aa(this,t,r,i),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(),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 Ma(this,this,t),this.check()}rotateY(t){return xa(this,this,t),this.check()}rotateZ(t){return Sa(this,this,t),this.check()}scale(t){return Ra(this,this,t),this.check()}slerp(t,r,i){let s,n,o;return arguments.length===2?(s=this,n=t,o=r):(s=t,n=r,o=i),Ta(this,s,n,o),this.check()}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,cf={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 ui(e){return e}var MM=new p;function lf(e,t=[],r=ui){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 La(e,t=[]){return lf(e,t,V._cartographicRadians?ui:Gs)}function uf(e,t,r=ui){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 Ga(e,t){return uf(e,t,V._cartographicRadians?ui:Ds)}var Da=1e-14,ff=new p,Ba={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"}},Ks={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},tr={east:new p,north:new p,up:new p,west:new p,south:new p,down:new p},df=new p,mf=new p,pf=new p;function Qs(e,t,r,i,s,n){let o=Ba[t]&&Ba[t][r];Q(o&&(!i||i===o));let a,h,c,l=ff.copy(s);if(gt(l.x,0,Da)&&gt(l.y,0,Da)){let f=Math.sign(l.z);a=df.fromArray(Ks[t]),t!=="east"&&t!=="west"&&a.scale(f),h=mf.fromArray(Ks[r]),r!=="east"&&r!=="west"&&h.scale(f),c=pf.fromArray(Ks[i]),i!=="east"&&i!=="west"&&c.scale(f)}else{let{up:f,east:m,north:d}=tr;m.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,f),d.copy(f).cross(m);let{down:g,west:_,south:y}=tr;g.copy(f).scale(-1),_.copy(m).scale(-1),y.copy(d).scale(-1),a=tr[t],h=tr[r],c=tr[i]}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 xe=new p,gf=new p,_f=new p;function za(e,t,r=[]){let{oneOverRadii:i,oneOverRadiiSquared:s,centerToleranceSquared:n}=t;xe.from(e);let o=xe.x,a=xe.y,h=xe.z,c=i.x,l=i.y,u=i.z,f=o*o*c*c,m=a*a*l*l,d=h*h*u*u,g=f+m+d,_=Math.sqrt(1/g);if(!Number.isFinite(_))return;let y=gf;if(y.copy(e).scale(_),g<n)return y.to(r);let M=s.x,T=s.y,v=s.z,w=_f;w.set(y.x*M*2,y.y*T*2,y.z*v*2);let b=(1-_)*xe.len()/(.5*w.len()),R=0,I,A,O,N;do{b-=R,I=1/(1+b*M),A=1/(1+b*T),O=1/(1+b*v);let L=I*I,H=A*A,D=O*O,Ot=L*I,$r=H*A,bs=D*O;N=f*L+m*H+d*D-1;let Ps=-2*(f*Ot*M+m*$r*T+d*bs*v);R=N/Ps}while(Math.abs(N)>z.EPSILON12);return xe.scale([I,A,O]).to(r)}var fi=new p,qa=new p,xf=new p,Pt=new p,Sf=new p,di=new p,P=class{constructor(t=0,r=0,i=0){this.centerToleranceSquared=z.EPSILON1,Q(t>=0),Q(r>=0),Q(i>=0),this.radii=new p(t,r,i),this.radiiSquared=new p(t*t,r*r,i*i),this.radiiToTheFourth=new p(t*t*t*t,r*r*r*r,i*i*i*i),this.oneOverRadii=new p(t===0?0:1/t,r===0?0:1/r,i===0?0:1/i),this.oneOverRadiiSquared=new p(t===0?0:1/(t*t),r===0?0:1/(r*r),i===0?0:1/(i*i)),this.minimumRadius=Math.min(t,r,i),this.maximumRadius=Math.max(t,r,i),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 i=qa,s=xf,[,,n]=t;this.geodeticSurfaceNormalCartographic(t,i),s.copy(this.radiiSquared).scale(i);let o=Math.sqrt(i.dot(s));return s.scale(1/o),i.scale(n),s.add(i),s.to(r)}cartesianToCartographic(t,r=[0,0,0]){di.from(t);let i=this.scaleToGeodeticSurface(di,Pt);if(!i)return;let s=this.geodeticSurfaceNormal(i,qa),n=Sf;n.copy(di).subtract(i);let o=Math.atan2(s.y,s.x),a=Math.asin(s.z),h=Math.sign(Je(n,di))*qs(n);return Ga([o,a,h],r)}eastNorthUpToFixedFrame(t,r=new C){return Qs(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,i,s,n=new C){return Qs(this,t,r,i,s,n)}geocentricSurfaceNormal(t,r=[0,0,0]){return fi.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){let i=La(t),s=i[0],n=i[1],o=Math.cos(n);return fi.set(o*Math.cos(s),o*Math.sin(s),Math.sin(n)).normalize(),fi.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return fi.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return za(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){Pt.from(t);let i=Pt.x,s=Pt.y,n=Pt.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(i*i*o.x+s*s*o.y+n*n*o.z);return Pt.multiplyByScalar(a).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return Pt.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return Pt.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,i=[0,0,0]){Q(gt(this.radii.x,this.radii.y,z.EPSILON15)),Q(this.radii.z>0),Pt.from(t);let s=Pt.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-r))return Pt.set(0,0,s).to(i)}};P.WGS84=new P(6378137,6378137,kt);var Js;(function(e){e.OUTSIDE="outside",e.INTERSECTING="intersecting",e.INSIDE="inside"})(Js||(Js={}));var LM=new p,GM=new p;var er=new p,Fa=new p,tt=class e{constructor(t=[0,0,0],r=0){this.radius=-0,this.center=new p,this.fromCenterRadius(t,r)}fromCenterRadius(t,r){return this.center.from(t),this.radius=r,this}fromCornerPoints(t,r){return r=er.from(r),this.center=new p().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,i=this.radius,s=t.center,n=t.radius,o=er.copy(s).subtract(r),a=o.magnitude();if(i>=a+n)return this.clone();if(n>=a+i)return t.clone();let h=(i+a+n)*.5;return Fa.copy(o).scale((-i+h)/a).add(r),this.center.copy(Fa),this.radius=h,this}expand(t){let i=er.from(t).subtract(this.center).magnitude();return i>this.radius&&(this.radius=i),this}transform(t){this.center.transform(t);let r=ia(er,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 i=er.from(t).subtract(this.center);return Math.max(0,i.len()-this.radius)}intersectPlane(t){let r=this.center,i=this.radius,n=t.normal.dot(r)+t.distance;return n<-i?"outside":n<i?"intersecting":"inside"}};var Ef=new p,Tf=new p,mi=new p,pi=new p,gi=new p,vf=new p,wf=new p,Ut={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Gt=class e{constructor(t=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new p().from(t),this.halfAxes=new k(r)}get halfSize(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2);return[new p(t).len(),new p(r).len(),new p(i).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2),s=new p(t).normalize(),n=new p(r).normalize(),o=new p(i).normalize();return new Et().fromMatrix3(new k([...s,...n,...o]))}fromCenterHalfSizeQuaternion(t,r,i){let s=new Et(i),n=new k().fromQuaternion(s);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 p().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 tt){let r=this.halfAxes,i=r.getColumn(0,mi),s=r.getColumn(1,pi),n=r.getColumn(2,gi),o=Ef.copy(i).add(s).add(n);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let r=this.center,i=t.normal,s=this.halfAxes,n=i.x,o=i.y,a=i.z,h=Math.abs(n*s[Ut.COLUMN0ROW0]+o*s[Ut.COLUMN0ROW1]+a*s[Ut.COLUMN0ROW2])+Math.abs(n*s[Ut.COLUMN1ROW0]+o*s[Ut.COLUMN1ROW1]+a*s[Ut.COLUMN1ROW2])+Math.abs(n*s[Ut.COLUMN2ROW0]+o*s[Ut.COLUMN2ROW1]+a*s[Ut.COLUMN2ROW2]),c=i.dot(r)+t.distance;return c<=-h?"outside":c>=h?"inside":"intersecting"}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let r=Tf.from(t).subtract(this.center),i=this.halfAxes,s=i.getColumn(0,mi),n=i.getColumn(1,pi),o=i.getColumn(2,gi),a=s.magnitude(),h=n.magnitude(),c=o.magnitude();s.normalize(),n.normalize(),o.normalize();let l=0,u;return u=Math.abs(r.dot(s))-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,i=[-0,-0]){let s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,h=a.getColumn(0,mi),c=a.getColumn(1,pi),l=a.getColumn(2,gi),u=vf.copy(h).add(c).add(l).add(o),f=wf.copy(u).subtract(t),m=r.dot(f);return s=Math.min(m,s),n=Math.max(m,n),u.copy(o).add(h).add(c).subtract(l),f.copy(u).subtract(t),m=r.dot(f),s=Math.min(m,s),n=Math.max(m,n),u.copy(o).add(h).subtract(c).add(l),f.copy(u).subtract(t),m=r.dot(f),s=Math.min(m,s),n=Math.max(m,n),u.copy(o).add(h).subtract(c).subtract(l),f.copy(u).subtract(t),m=r.dot(f),s=Math.min(m,s),n=Math.max(m,n),o.copy(u).subtract(h).add(c).add(l),f.copy(u).subtract(t),m=r.dot(f),s=Math.min(m,s),n=Math.max(m,n),o.copy(u).subtract(h).add(c).subtract(l),f.copy(u).subtract(t),m=r.dot(f),s=Math.min(m,s),n=Math.max(m,n),o.copy(u).subtract(h).subtract(c).add(l),f.copy(u).subtract(t),m=r.dot(f),s=Math.min(m,s),n=Math.max(m,n),o.copy(u).subtract(h).subtract(c).subtract(l),f.copy(u).subtract(t),m=r.dot(f),s=Math.min(m,s),n=Math.max(m,n),i[0]=s,i[1]=n,i}transform(t){this.center.transformAsPoint(t);let r=this.halfAxes.getColumn(0,mi);r.transformAsPoint(t);let i=this.halfAxes.getColumn(1,pi);i.transformAsPoint(t);let s=this.halfAxes.getColumn(2,gi);return s.transformAsPoint(t),this.halfAxes=new k([...r,...i,...s]),this}getTransform(){throw new Error("not implemented")}};var ka=new p,Ua=new p,Y=class e{constructor(t=[0,0,1],r=0){this.normal=new p,this.distance=-0,this.fromNormalDistance(t,r)}fromNormalDistance(t,r){return Q(Number.isFinite(r)),this.normal.from(t).normalize(),this.distance=r,this}fromPointNormal(t,r){t=ka.from(t),this.normal.from(r).normalize();let i=-this.normal.dot(t);return this.distance=i,this}fromCoefficients(t,r,i,s){return this.normal.set(t,r,i),Q(gt(this.normal.len(),1)),this.distance=s,this}clone(){return new e(this.normal,this.distance)}equals(t){return gt(this.distance,t.distance)&&gt(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let r=Ua.copy(this.normal).transformAsVector(t).normalize(),i=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(i,r)}projectPointOntoPlane(t,r=[0,0,0]){let i=ka.from(t),s=this.getPointDistance(i),n=Ua.copy(this.normal).scale(s);return i.subtract(n).to(r)}intersectWithRay(t,r=new p){let i=t.origin,s=t.direction,n=this.normal,o=n.dot(s);if(Math.abs(o)<z.EPSILON15)return;let a=(-this.distance-n.dot(i))/o;if(!(a<0))return r.copy(s).multiplyByScalar(a).add(i)}};var Va=[new p([1,0,0]),new p([0,1,0]),new p([0,0,1])],ja=new p,bf=new p,J=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*Va.length;let r=t.center,i=t.radius,s=0;for(let n of Va){let o=this.planes[s],a=this.planes[s+1];o||(o=this.planes[s]=new Y),a||(a=this.planes[s+1]=new Y);let h=ja.copy(n).scale(-i).add(r);o.fromPointNormal(h,n);let c=ja.copy(n).scale(i).add(r),l=bf.copy(n).negate();a.fromPointNormal(c,l),s+=2}return this}computeVisibility(t){let r="inside";for(let i of this.planes)switch(t.intersectPlane(i)){case"outside":return"outside";case"intersecting":r="intersecting";break;default:}return r}computeVisibilityWithPlaneMask(t,r){if(Q(Number.isFinite(r),"parentPlaneMask is required."),r===e.MASK_OUTSIDE||r===e.MASK_INSIDE)return r;let i=e.MASK_INSIDE,s=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=s[n],h=t.intersectPlane(a);if(h==="outside")return e.MASK_OUTSIDE;h==="intersecting"&&(i|=o)}return i}};J.MASK_OUTSIDE=4294967295;J.MASK_INSIDE=0;J.MASK_INDETERMINATE=2147483647;var fx=new p,dx=new p,mx=new p,px=new p,gx=new p;var Ex=new p,Tx=new p,vx=new p,wx=new p,bx=new p,Px=new p,Rx=new p,Cx=new p,Ax=new p,Ix=new p,Ox=new p,Nx=new p;var Dx=new k,Bx=new k,zx=new k,qx=new k,Fx=new k;var Hx=new p,$x=new p,Yx=new p,Xx=new p,Zx=new p,Kx=new k,Qx={diagonal:new k,unitary:new k};var Af=new p,tn=new p,If=new C,Of=new p,rr=class{constructor(t,r=P.WGS84){let i=r.scaleToGeodeticSurface(t,Af),s=r.eastNorthUpToFixedFrame(i,If);this._origin=new p(i),this._xAxis=new p(tn.from(s.getColumn(0))),this._yAxis=new p(tn.from(s.getColumn(1)));let n=new p(tn.from(s.getColumn(2)));this._plane=new Y().fromPointNormal(this._origin,n)}projectPointToNearestOnPlane(t,r){r||(r=new St);let s=this._plane.projectPointOntoPlane(t,Of).subtract(this._origin),n=this._xAxis.dot(s),o=this._yAxis.dot(s);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 Se=class{constructor(t,r,i,s){this.west=t,this.south=r,this.east=i,this.north=s}static center(t,r){r||(r=new p);let i=t.east,s=t.west;i<s&&(i+=z.TWO_PI);let n=Bs((s+i)*.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+=z.TWO_PI),t-r}};var Nf=new p,Lf=new p,Gf=new p,Df=new p,Bf=new p,zf=new p,qf=new p,Ff=new p,$a=new p,kf=new p,Ya=new p,Uf=new p,Vf=new St,jf=new St,Wf=new St,Hf=new St,$f=new St,Yf=new Y,Xf=new p,Zf=new p,Kf=new p,Qf=new p,Jf=new St,td=new p,ed=new p,rd=new p(1,0,0),id=new p(0,0,1);function ir(e,t=P.WGS84,r={}){if(!e||e.length!==6||e.some(M=>!Number.isFinite(M)))throw new Error("makeOBBFromRegion: region must contain exactly six finite numbers");let i=r.units==="degrees"?Qr(1):1,[s,n,o,a,h,c]=e;if(h>c)throw new Error("makeOBBFromRegion: minimumHeight must not exceed maximumHeight");let l=n*i,u=a*i,f=Xa(s*i),m=Xa(o*i);o*i-s*i>=z.TWO_PI-1e-12&&(m=f+z.TWO_PI);let g=1e-12;if(l>u||l<-z.PI_OVER_TWO-g||u>z.PI_OVER_TWO+g)throw new Error("makeOBBFromRegion: latitude must be within [-\u03C0/2, \u03C0/2] and south \u2264 north");let _=Math.max(-z.PI_OVER_TWO,Math.min(z.PI_OVER_TWO,l)),y=Math.max(-z.PI_OVER_TWO,Math.min(z.PI_OVER_TWO,u));return sd([f,_,m,y,h,c],t,r.transform)}function Xa(e){let t=((e+Math.PI)%z.TWO_PI+z.TWO_PI)%z.TWO_PI-Math.PI;return t===-Math.PI&&e>0?Math.PI:t}function sd(e,t,r){let i=new Gt,[s,n,o,a,h,c]=e,l=ot(a),u=ot(n),f,m,d,g,_,y,M,T=new Se(s,n,o,a),v=Se.center(T,Lf),w=new p([ot(v.x),ot(v.y),0]),b=v.x,R=w.x;if(T.width<=z.PI){let Rs=ot(s),Qu=t.cartographicToCartesian(w),Nt=new rr(Qu,t),Ju=u<0&&l>0?0:w.y,t0=Gf.copy([R,l,c]),Cs=Df.copy([Rs,l,c]),e0=Bf.copy([Rs,Ju,c]),As=zf.copy([Rs,u,c]),r0=qf.copy([R,u,c]),i0=t.cartographicToCartesian(t0,Ff),Is=t.cartographicToCartesian(Cs,$a),s0=t.cartographicToCartesian(e0,kf),Os=t.cartographicToCartesian(As,Ya),n0=t.cartographicToCartesian(r0,Uf),o0=Nt.projectPointToNearestOnPlane(i0,Vf),vo=Nt.projectPointToNearestOnPlane(Is,jf),a0=Nt.projectPointToNearestOnPlane(s0,Wf),wo=Nt.projectPointToNearestOnPlane(Os,Hf),h0=Nt.projectPointToNearestOnPlane(n0,$f);return g=Math.min(vo.x,a0.x,wo.x),f=-g,m=Math.max(vo.y,o0.y),_=Math.min(wo.y,h0.y),Cs.z=As.z=h,Is=t.cartographicToCartesian(Cs,$a),Os=t.cartographicToCartesian(As,Ya),M=Nt.plane,y=Math.min(M.getPointDistance(Is),M.getPointDistance(Os)),d=c,Za(Qa(Nt.origin,Nt.xAxis,Nt.yAxis,Nt.zAxis,g,f,_,m,y,d,i),r)}let I=ot(o),A=n>0,O=a<0,N=A?u:O?l:0,L=t.cartographicToCartesian([R,N,c],Xf);L.z=0;let D=Math.abs(L.x)<z.EPSILON10&&Math.abs(L.y)<z.EPSILON10?rd:Zf.copy(L).normalize(),Ot=id,$r=Kf.copy(D).cross(Ot);M=Yf.fromPointNormal(L,D);let bs=t.cartographicToCartesian([ot(b+z.PI_OVER_TWO),N,c],Qf);f=M.projectPointOntoPlane(bs,Jf).dot($r),g=-f;let Ps=O?h:c,Zu=A?h:c;m=Ka(t,l,Ps,!0),_=Ka(t,u,Zu,!1);let Ku=t.cartographicToCartesian([I,N,c],ed);return y=M.getPointDistance(Ku),d=0,Za(Qa(L,$r,Ot,D,g,f,_,m,y,d,i),r)}function Za(e,t){if(!t)return e;let r=[0,1,2].map(a=>e.halfAxes.getColumn(a,new p)),i=t.transformAsPoint(e.center),s=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(let a=0;a<8;a++){let h=new p(i);for(let c=0;c<3;c++){let l=t.transformAsVector(r[c]);h.add(new p(l).scale((a&1<<c)===0?-1:1))}for(let c=0;c<3;c++)s[c]=Math.min(s[c],h[c]),n[c]=Math.max(n[c],h[c])}e.center.copy(s).add(n).scale(.5);let o=new p(n).subtract(s).scale(.5);return e.halfAxes=new k().set(o.x,0,0,0,o.y,0,0,0,o.z),e}function Ka(e,t,r,i){let s=i?-1/0:1/0;for(let n of[0,90,180,270]){let o=e.cartographicToCartesian([n,t,r],td).z;s=i?Math.max(s,o):Math.min(s,o)}return s}function Qa(e,t,r,i,s,n,o,a,h,c,l){let u=l.center,f=l.halfAxes;f.setColumn(0,t),f.setColumn(1,r),f.setColumn(2,i);let m=Nf.set((s+n)/2,(o+a)/2,(h+c)/2).transformByMatrix3(f),d=(n-s)/2,g=(a-o)/2,_=(c-h)/2;return f[0]*=d,f[1]*=d,f[2]*=d,f[3]*=g,f[4]*=g,f[5]*=g,f[6]*=_,f[7]*=_,f[8]*=_,u.copy(e).add(m),l}function sr(){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 se=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=sr(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(sr()-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:i}=t,s=this.stats[r];return s||(t instanceof se?s=t:s=new se(r,i),this.stats[r]=s),s}};function Rt(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function yi(e,t,r){let i=r!==void 0?new Uint8Array(e).subarray(t,t+r):new Uint8Array(e).subarray(t);return new Uint8Array(i).buffer}var nd="Queued Requests",od="Active Requests",ad="Cancelled Requests",hd="Queued Requests Ever",cd="Active Requests Ever",ld={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Vt=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...ld,...t},this.stats=new Tt({id:this.props.id}),this.stats.get(nd),this.stats.get(od),this.stats.get(ad),this.stats.get(hd),this.stats.get(cd)}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 i={handle:t,priority:0,getPriority:r},s=new Promise(n=>(i.resolve=n,i));return this.requestQueue.push(i),this.requestMap.set(t,s),this._issueNewRequests(),s}_issueRequest(t){let{handle:r,resolve:i}=t,s=!1,n=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({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 i=this.requestQueue.shift();i&&this._issueRequest(i)}}}_updateAllRequests(){let t=this.requestQueue;for(let r=0;r<t.length;++r){let i=t[r];this._updateRequest(i)||(t.splice(r,1),this.requestMap.delete(i.handle),r--)}t.sort((r,i)=>r.priority-i.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var ud=Number.POSITIVE_INFINITY,fd=Number.POSITIVE_INFINITY,nr=class{maxEntries;maxBytes;getByteLength;onRemove;entries=new Map;retainedByteLength=0;constructor(t={}){this.maxEntries=Ja(t.maxEntries,ud,"maxEntries"),this.maxBytes=Ja(t.maxBytes,fd,"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 i=this.entries.get(t);if(i)return this.touch(t,i),this.waitForEntry(t,i,r)}has(t){return this.entries.has(t)}set(t,r){this.removeEntry(t,"replace");let i=th(this.getByteLength(r)),s={promise:Promise.resolve(r),pending:!1,waiterCount:0,byteLength:i};return this.entries.set(t,s),this.retainedByteLength+=i,this.trim(),r}getOrLoad(t,r,i){let s=this.get(t,i);if(s)return s;if(i?.aborted)return Promise.reject(en());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,i)}delete(t){return this.removeEntry(t,"delete")}clear(){for(let t of Array.from(this.entries.keys()))this.removeEntry(t,"clear")}handleLoadedValue(t,r,i){if(this.entries.get(t)===r){r.pending=!1,r.controller=void 0;try{r.byteLength=th(this.getByteLength(i))}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,i){return i?.aborted?Promise.reject(en()):r.pending?(r.waiterCount++,new Promise((s,n)=>{let o=!0,a=()=>{o&&(o=!1,i?.removeEventListener("abort",h),r.waiterCount--)},h=()=>{o&&(a(),n(en()),r.pending&&r.waiterCount===0&&this.entries.get(t)===r&&this.removeEntry(t,"abort"))};i?.addEventListener("abort",h,{once:!0}),r.promise.then(c=>{o&&(a(),s(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,i]of this.entries)if(i.pending||(this.removeEntry(r,"evict"),t--),t<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)break}}removeEntry(t,r){let i=this.entries.get(t);return i?(this.entries.delete(t),this.retainedByteLength-=i.byteLength,i.pending&&i.controller?.abort(),this.onRemove?.(t,r),!0):!1}};function en(){let e=new Error("Request aborted");return e.name="AbortError",e}function Ja(e,t,r){let i=e??t;if(i<0||Number.isNaN(i))throw new Error(`${r} must be a non-negative number`);return i}function th(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 U={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"},rn={batchDelayMs:50,maxGapBytes:65536,rangeExpansionBytes:65536,maxMergedBytes:8388608,stats:ih("range-request-scheduler-default"),onEvent:()=>{}},Mi=class{props;stats;onEvent;pendingRequests=[];flushTimer=null;constructor(t={}){let r=t.rangeExpansionBytes??t.maxGapBytes??rn.rangeExpansionBytes;this.props={batchDelayMs:t.batchDelayMs??rn.batchDelayMs,maxGapBytes:t.maxGapBytes??r,rangeExpansionBytes:r,maxMergedBytes:t.maxMergedBytes??rn.maxMergedBytes},this.stats=t.stats||ih("range-request-scheduler"),this.onEvent=t.onEvent,sh(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(rh());if(t.length===0)return Promise.resolve(new ArrayBuffer(0));let r=new Promise((i,s)=>{let n={...t,resolve:i,reject:s,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:(i,s,n)=>md({url:t.url,offset:i,length:s,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(s=>s.settled||s.signal?.aborted?(this.abortRequest(s),!1):!0),i=this.mergeRequests(r);r.length>0&&this.trackBatch(r,i);for(let s of i)this.fetchMergedRequest(s)}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>this.flush(),this.props.batchDelayMs))}mergeRequests(t){t.sort((i,s)=>i.sourceId!==s.sourceId?i.sourceId<s.sourceId?-1:1:i.offset-s.offset);let r=[];for(let i of t){let s=i.offset+i.length,n=r[r.length-1];n&&pd(n,i,this.props)?(n.endOffset=Math.max(n.endOffset,s),n.requests.push(i)):r.push({sourceId:i.sourceId,isolationKey:i.isolationKey??i.sourceId,offset:i.offset,endOffset:s,fetchRange:i.fetchRange,requests:[i]})}return r}async fetchMergedRequest(t){let{offset:r,endOffset:i,fetchRange:s,requests:n}=t,o=new AbortController,a=or(),h=()=>{n.every(c=>c.signal?.aborted)&&o.abort()};try{for(let _ of n)_.onAbort=h;if(h(),n.every(_=>_.settled))return;let c=sn(n),l=i-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=gd(await s(r,l,o.signal)),{arrayBuffer:f}=u,m=u.fullResponse&&r===0&&f.byteLength<l,d=f.byteLength<l&&Number.isSafeInteger(u.sourceByteLength)&&r+f.byteLength===u.sourceByteLength;if(f.byteLength!==l&&!m&&!d)throw new Error(`Byte-range transport returned ${f.byteLength} bytes; expected ${l}`);let g=u.networkTimeMs??or()-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 _ of n){if(_.settled)continue;let y=_.offset-r;_.settled=!0,_.resolve(f.slice(y,y+_.length))}}catch(c){this.trackEvent({type:"error",sourceId:t.sourceId,offset:r,length:i-r,logicalRequestCount:n.length,logicalBytes:sn(n),networkTimeMs:or()-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(rh()),this.trackEvent({type:"abort",sourceId:t.sourceId,offset:t.offset,length:t.length,logicalRequestCount:1,logicalBytes:t.length}))}trackEvent(t){dd(this.stats,t);try{this.onEvent?.(t)}catch{}}trackBatch(t,r){let i=sn(t),s=r.reduce((n,o)=>n+o.endOffset-o.offset,0);this.trackEvent({type:"batch",logicalRequestCount:t.length,transportRequestCount:r.length,logicalBytes:i,transportBytes:s,overfetchBytes:Math.max(s-i,0)})}};function dd(e,t){switch((t.type==="response"||t.type==="error")&&t.networkTimeMs!==void 0&&e.get(U.networkTimeMs,"time").addTime(t.networkTimeMs),t.type){case"queued":e.get(U.logicalRanges,"count").incrementCount(),e.get(U.requestedBytes,"count").addCount(t.logicalBytes||0);break;case"batch":e.get(U.rangeBatches,"count").incrementCount(),e.get("Logical Ranges Batched","count").addCount(t.logicalRequestCount||0),e.get(U.transportRanges,"count").addCount(t.transportRequestCount||0),e.get(U.coalescedRanges,"count").addCount(Math.max((t.logicalRequestCount||0)-(t.transportRequestCount||0),0)),e.get(U.transportBytes,"count").addCount(t.transportBytes||0),e.get(U.overfetchBytes,"count").addCount(t.overfetchBytes||0);break;case"response":e.get(U.completedTransportRanges,"count").incrementCount(),e.get(U.responseBytes,"count").addCount(t.responseBytes||0),t.fullResponse&&e.get(U.fullResponseFallbacks,"count").incrementCount();break;case"error":e.get(U.failedTransportRanges,"count").incrementCount();break;case"abort":e.get(U.abortedLogicalRanges,"count").incrementCount();break;default:}}function ih(e="range-request-scheduler"){let t=new Tt({id:e});return sh(t),t}async function md(e){let t=xd(e.signal),r=or();try{let i=!1,s=await e.fetch(e.url,eh(e.fetchOptions,e.offset,e.length,t.signal));if(s.status===416&&e.offset===0){let h=yd(s.headers.get("Content-Range"));if(!h)throw new Error("Missing content-length on 416 response");s=await e.fetch(e.url,eh(e.fetchOptions,0,h,t.signal)),i=!0}if(s.status===200)throw t.abort(),await Sd(s),new Error("Byte-range request failed: server returned 200 instead of 206");if(s.status!==206&&!s.ok)throw new Error(`Bad response code: ${s.status}`);let n=await s.arrayBuffer(),o=s.headers.get("Content-Range"),a=Md(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:s.status,sourceByteLength:a?.sourceByteLength,transportBytes:n.byteLength,networkTimeMs:or()-r,fullResponse:i}}finally{t.removeAbortListener()}}function pd(e,t,r){if(e.sourceId!==t.sourceId||e.isolationKey!==(t.isolationKey??t.sourceId))return!1;let i=t.offset+t.length,s=t.offset-e.endOffset,n=Math.max(e.endOffset,i)-e.offset;return s<=r.rangeExpansionBytes&&n<=r.maxMergedBytes}function sh(e){e.get(U.logicalRanges,"count"),e.get(U.requestedBytes,"count"),e.get(U.rangeBatches,"count"),e.get("Logical Ranges Batched","count"),e.get(U.transportRanges,"count"),e.get(U.coalescedRanges,"count"),e.get(U.transportBytes,"count"),e.get(U.completedTransportRanges,"count"),e.get(U.responseBytes,"count"),e.get(U.networkTimeMs,"time"),e.get(U.overfetchBytes,"count"),e.get(U.fullResponseFallbacks,"count"),e.get(U.failedTransportRanges,"count"),e.get(U.abortedLogicalRanges,"count")}function sn(e){return e.reduce((t,r)=>t+r.length,0)}function gd(e){return e instanceof ArrayBuffer?{arrayBuffer:e}:e}function eh(e,t,r,i){return{...e,signal:i,headers:{..._d(e?.headers),Range:`bytes=${t}-${t+r-1}`}}}function _d(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):e:{}}function yd(e){let t=e?.match(/^bytes \*\/(\d+)$/);return t?Number(t[1]):null}function Md(e){let t=e?.match(/^bytes (\d+)-(\d+)\/(\d+|\*)$/);if(!t)return null;let r=Number(t[1]),i=Number(t[2]),s=t[3]==="*"?void 0:Number(t[3]);return!Number.isSafeInteger(r)||!Number.isSafeInteger(i)||r>i||s!==void 0&&!Number.isSafeInteger(s)?null:{offset:r,endOffset:i,sourceByteLength:s}}function xd(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 Sd(e){await e.body?.cancel().catch(()=>{})}function or(){return globalThis.performance?.now()??Date.now()}function rh(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}var _t={};Ns(_t,{dirname:()=>Td,filename:()=>Ed,join:()=>vd,resolve:()=>wd});function nh(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function Ed(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):e}function Td(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function vd(...e){return e=e.map((r,i)=>(i&&(r=r.replace(new RegExp("^/"),"")),i!==e.length-1&&(r=r.replace(new RegExp("/$"),"")),r)),e.join("/")}function wd(...e){let t=[];for(let n=0;n<e.length;n++)t[n]=e[n];let r="",i=!1,s;for(let n=t.length-1;n>=-1&&!i;n--){let o;n>=0?o=t[n]:(s===void 0&&(s=nh()),o=s),o.length!==0&&(r=`${o}/${r}`,i=o.charCodeAt(0)===ar)}return r=bd(r,!i),i?`/${r}`:r.length>0?r:"."}var ar=47,nn=46;function bd(e,t){let r="",i=-1,s=0,n,o=!1;for(let a=0;a<=e.length;++a){if(a<e.length)n=e.charCodeAt(a);else{if(n===ar)break;n=ar}if(n===ar){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(r.length<2||!o||r.charCodeAt(r.length-1)!==nn||r.charCodeAt(r.length-2)!==nn){if(r.length>2){let h=r.length-1,c=h;for(;c>=0&&r.charCodeAt(c)!==ar;--c);if(c!==h){r=c===-1?"":r.slice(0,c),i=a,s=0,o=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,s=0,o=!1;continue}}t&&(r.length>0?r+="/..":r="..",o=!0)}else{let h=e.slice(i+1,a);r.length>0?r+=`/${h}`:r=h,o=!1}i=a,s=0}else n===nn&&s!==-1?++s:s=-1}return r}var Ee=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,i){if(i?.aborted)throw new Error("Request aborted");let s=await this.handle.slice(Number(t),Number(t)+Number(r)).arrayBuffer();if(i?.aborted)throw new Error("Request aborted");return s}};var Ei=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){Od(r.byteLength),this.url=t,this.fetchFunction=r.fetch||((i,s)=>globalThis.fetch(i,s)),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:vi(r.etag),lastModified:vi(r.lastModified)}}getInitialIdentity(){let{byteLength:t,etag:r,lastModified:i}=this.identityHints;return t!==void 0&&(r!==void 0||i!==void 0)?Ti(t,r,i):t===0&&this.consistency==="best-effort"?Ti(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)}ch(t)?this.telemetry.abortCount++:this.telemetry.errorCount++}async requestRange(t,r,i,s){let n=xi(),o=Nd(i,this.fetchOptions?.signal);this.telemetry.requestCount++,this.telemetry.requestedBytes+=r;try{let a=await this.fetchFunction(this.url,Pd(this.fetchOptions,t,r,o.signal));if(Rd(a,t,r,s))return await this.readEmptyIdentityProbe(a,n);if(a.status!==206)throw await Si(a),new Error(`HTTP byte-range request expected 206, received ${a.status}`);let h=await Cd(a),c=oh(a,h.byteLength),l=hh(s,c,this.identityHints,this.consistency)||Id(h,t,r);if(l)throw await Si(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:ah(s,c,this.identityHints),status:a.status,transportBytes:u.byteLength,networkTimeMs:xi()-n}}catch(a){throw(s===null||!ch(a))&&this.trackFailure(a),a}finally{o.removeAbortListeners(),this.telemetry.networkTimeMs+=xi()-n}}async readEmptyIdentityProbe(t,r){let i=oh(t,0),s=hh(null,i,this.identityHints,this.consistency);if(await Si(t),s)throw new Error(s);return{arrayBuffer:new ArrayBuffer(0),identity:ah(null,i,this.identityHints),status:t.status,transportBytes:0,networkTimeMs:xi()-r}}};function Pd(e,t,r,i){let s=new Headers(e?.headers);return s.set("Range",`bytes=${t}-${t+r-1}`),{...e,method:"GET",body:void 0,headers:s,signal:i}}function Rd(e,t,r,i){return e.status===416&&i===null&&t===0&&r===1&&/^bytes \*\/0$/i.test(e.headers.get("Content-Range")||"")}async function Cd(e){try{return Ad(e.headers.get("Content-Range"))}catch(t){throw await Si(e),t}}function Ad(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 oh(e,t){return Ti(t,vi(e.headers.get("ETag")),vi(e.headers.get("Last-Modified")))}function ah(e,t,r){return e||Ti(t.byteLength,t.etag??r.etag,t.lastModified??r.lastModified)}function Id(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 hh(e,t,r,i){let s=e?.byteLength??r.byteLength;if(s!==void 0&&t.byteLength!==s)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":i==="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":i==="strict"&&!t.lastModified?"HTTP byte-range response is missing the pinned Last-Modified value":null:i==="strict"&&!t.etag&&!t.lastModified?"HTTP byte-range response does not provide an ETag or Last-Modified validator":null}function Ti(e,t,r){return Object.freeze({byteLength:e,etag:t,lastModified:r})}function Od(e){if(e!==void 0&&(!Number.isSafeInteger(e)||e<0))throw new Error("HttpFile byteLength must be a non-negative safe integer")}async function Si(e){await e.body?.cancel().catch(()=>{})}function vi(e){return e||void 0}function xi(){return globalThis.performance?.now()??Date.now()}function ch(e){return e instanceof Error&&e.name==="AbortError"||e instanceof Error&&/aborted/i.test(e.message)}function Nd(...e){let t=new AbortController,r=[...new Set(e.filter(s=>!!s))],i=()=>t.abort();for(let s of r)s.aborted?t.abort():s.addEventListener("abort",i,{once:!0});return{signal:t.signal,removeAbortListeners:()=>{for(let s of r)s.removeEventListener("abort",i)}}}var hr=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 Ei(t,r),this.rangeScheduler=r.rangeScheduler||new Mi({batchDelayMs:0,...r.rangeSchedulerProps}),this.suppliedByteLength=r.byteLength,this.identity=this.transport.getInitialIdentity()}static async open(t,r={},i){let s=new e(t,r);return await s.open(i),s}async open(t){if(this.assertOpen(),t?.aborted){let r=wi();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,i){if(this.assertOpen(),i?.aborted){let o=wi();throw this.transport.trackFailure(o),o}let s=await this.getIdentity(i),n=lh(t);if(Gd(n,r,s.byteLength),r===0)return new ArrayBuffer(0);try{return await this.rangeScheduler.scheduleRequest({sourceId:this.url,isolationKey:this.schedulerIsolationKey,offset:n,length:r,signal:i,fetchRange:this.fetchScheduledRange})}catch(o){throw this.transport.trackFailure(o),o}}async fetchRange(t,r,i){let s=lh(t),n=await this.read(s,r,i),o=Ld(this.identity,s,r);return new Response(n,{status:206,headers:o})}fetchScheduledRange=async(t,r,i)=>{let s=await this.getIdentity(i),n=await this.transport.requestRange(t,r,i,s);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 i=this.probeIdentity().catch(s=>{throw this.openPromise===i&&(this.openPromise=null),s});this.openPromise=i}return Dd(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 Ld(e,t,r){let i=new Headers;return r>0&&e&&i.set("Content-Range",`bytes ${t}-${t+r-1}/${e.byteLength}`),e?.etag&&i.set("ETag",e.etag),e?.lastModified&&i.set("Last-Modified",e.lastModified),i}function lh(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 Gd(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 wi(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let e=new Error("Request aborted");return e.name="AbortError",e}function Dd(e,t){return t?t.aborted?Promise.reject(wi()):new Promise((r,i)=>{let s=()=>{t.removeEventListener("abort",s),i(wi())};t.addEventListener("abort",s,{once:!0}),e.then(n=>{t.removeEventListener("abort",s),r(n)},n=>{t.removeEventListener("abort",s),i(n)})}):e}function bi(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:uh(e.crs||{state:"absent",provenance:"unknown"}),vertical:e.vertical?uh(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 ne(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 uh(e){return e.state==="explicit"||e.state==="default"?Object.freeze({...e,definition:fh(e.definition),alternatives:e.alternatives?Object.freeze(e.alternatives.map(t=>Object.freeze({...t,definition:fh(t.definition)}))):void 0}):Object.freeze({...e})}function fh(e){return typeof e=="string"?e:on(e)}function on(e){return Array.isArray(e)?Object.freeze(e.map(t=>on(t))):e&&typeof e=="object"?Object.freeze(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,on(r)]))):e}var Pi=class extends SyntaxError{constructor(t,r,i){let s=Xd(r,i);super(`${t} at ${s.line}:${s.column}`),this.name="WKTCRSSyntaxError",this.offset=i,this.line=s.line,this.column=s.column}},Ri=class extends Error{constructor(t){super(t[0]?.message||"WKT validation failed"),this.name="WKTCRSValidationError",this.issues=t}},Bd=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?$/,zd=/^[A-Za-z][A-Za-z0-9_]*/,cr=new Set(["COMPD_CS","CONCAT_MT","FITTED_CS","GEOCCS","GEOGCS","INVERSE_MT","LOCAL_CS","PARAM_MT","PASSTHROUGH_MT","PROJCS","VERT_CS"]),hn=new Set([...cr,"AUTHORITY","AXIS","CONCAT_MT","DATUM","INVERSE_MT","LOCAL_DATUM","PARAMETER","PARAM_MT","PASSTHROUGH_MT","PRIMEM","PROJECTION","SPHEROID","TOWGS84","UNIT","VERT_DATUM"]),qd=new Set(cr),Fd=new Set([...hn,"EXTENSION"]),kd=new Set([...cr,"COMPDCS","LOCALCS","VERTCS"]),Ud=new Set([...hn,"COMPDCS","LOCALCS","VDATUM","VERTCS"]),dh=new Set(["BOUNDCRS","COMPOUNDCRS","COORDINATEOPERATION","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","PARAMETRICCRS","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"]),mh=new Set([...dh,"CONCATENATEDOPERATION","COORDINATEMETADATA","DERIVEDPROJCRS","GEOGCRS","GEOGRAPHICCRS","POINTMOTIONOPERATION"]),ph=new Set([...mh,"ABRIDGEDTRANSFORMATION","ANCHOR","ANGLEUNIT","AREA","AXIS","BASEENGCRS","BASEGEODCRS","BASEGEOGCRS","BASEPARAMCRS","BASEPROJCRS","BASETIMECRS","BASEVERTCRS","BBOX","BEARING","CALENDAR","CITATION","CONVERSION","COORDEPOCH","CS","DATUM","DERIVINGCONVERSION","DYNAMIC","EDATUM","ELLIPSOID","ENGINEERINGDATUM","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEODETICDATUM","GEOIDMODEL","ID","INTERPOLATIONCRS","LENGTHUNIT","MEMBER","MERIDIAN","METHOD","MODEL","OPERATIONACCURACY","ORDER","PARAMETER","PARAMETERFILE","PARAMETRICDATUM","PARAMETRICUNIT","PDATUM","PRIMEM","PRIMEMERIDIAN","REMARK","SCALEUNIT","SCOPE","SOURCECRS","STEP","TARGETCRS","TDATUM","TEMPORALQUANTITY","TIMEEXTENT","TIMEORIGIN","TIMEUNIT","TIMEDATUM","TRIAXIAL","TRF","URI","USAGE","VDATUM","VERSION","VERTICALDATUM","VERTICALEXTENT","VELOCITYGRID","VRF"]),Vd=new Set(["BASEGEOGCRS","CALENDAR","CONCATENATEDOPERATION","COORDEPOCH","COORDINATEMETADATA","DERIVEDPROJCRS","DYNAMIC","ENSEMBLE","ENSEMBLEACCURACY","EPOCH","FRAMEEPOCH","GEOGCRS","GEOGRAPHICCRS","GEOIDMODEL","MEMBER","MODEL","POINTMOTIONOPERATION","STEP","TEMPORALQUANTITY","TRF","TRIAXIAL","VELOCITYGRID","VRF"]),jd=new Set([...ph].filter(e=>!Vd.has(e))),Wd={wkt1:cr,gdal:qd,esri:kd,"wkt2:2015":dh,"wkt2:2019":mh},Hd={wkt1:hn,gdal:Fd,esri:Ud,"wkt2:2015":jd,"wkt2:2019":ph};function cn(e,t){let i={type:"wkt-crs",root:new an(e).parse()};if(t?.strict){let s=gh(i,{profile:t.profile,allowExtensions:!1});if(s.length>0)throw new Ri(s)}return i}function gh(e,t){if(!e||e.type!=="wkt-crs"||e.root?.type!=="node")throw new TypeError("validateWKTCRS expects a WKTCRSAst");let r=$d(e.root.keyword,t?.profile||"auto"),i=Wd[r],s=Hd[r],n=[],o=e.root.keyword.toUpperCase();return i.has(o)||n.push({code:"invalid-root",message:`${e.root.keyword} is not a ${r} root keyword`,path:[],keyword:e.root.keyword}),_h(e.root,[],a=>{let h=a.node.keyword.toUpperCase();!t?.allowExtensions&&!s.has(h)&&n.push({code:"unknown-keyword",message:`${a.node.keyword} is not defined by the ${r} profile`,path:a.path,keyword:a.node.keyword}),a.node.values.length===0&&n.push({code:"empty-node",message:`${a.node.keyword} must contain at least one value`,path:a.path,keyword:a.node.keyword});let c=Yd(a.node);c&&n.push({code:"invalid-value",message:c,path:a.path,keyword:a.node.keyword})}),n}var an=class{constructor(t){this.offset=0,this.source=t}parse(){this.skipWhitespace();let t=this.parseNode();return this.skipWhitespace(),this.offset!==this.source.length&&this.fail("Unexpected content after WKT root"),t}parseNode(){let t=this.parseKeyword();return this.parseNodeAfterKeyword(t)}parseNodeAfterKeyword(t){this.skipWhitespace();let r=this.source[this.offset];r!=="["&&r!=="("&&this.fail(`Expected '[' or '(' after ${t}`),this.offset++;let i=r==="["?"bracket":"parenthesis",s=r==="["?"]":")",n=[];if(this.skipWhitespace(),this.source[this.offset]===s)return this.offset++,{type:"node",keyword:t,delimiter:i,values:n};for(;this.offset<this.source.length;){n.push(this.parseValue()),this.skipWhitespace();let o=this.source[this.offset];if(o===","){this.offset++,this.skipWhitespace(),this.source[this.offset]===s&&this.fail("Expected a WKT value after comma");continue}if(o===s)return this.offset++,{type:"node",keyword:t,delimiter:i,values:n};(o==="]"||o===")")&&this.fail(`Expected '${s}' to close ${t}`),this.fail(`Expected ',' or '${s}' in ${t}`)}this.fail(`Unterminated ${t} node`)}parseValue(){if(this.skipWhitespace(),this.source[this.offset]==='"')return this.parseString();let r=this.offset;for(;this.offset<this.source.length&&!/[\s,\[\]()"]/.test(this.source[this.offset]);)this.offset++;r===this.offset&&this.fail("Expected a WKT value");let i=this.source.slice(r,this.offset);return this.source[this.offset]==='"'&&this.fail("Unexpected quote in unquoted WKT value"),this.skipWhitespace(),this.source[this.offset]==="["||this.source[this.offset]==="("?(/^[A-Za-z][A-Za-z0-9_]*$/.test(i)||this.fail(`Invalid WKT keyword '${i}'`),this.parseNodeAfterKeyword(i)):Bd.test(i)?{type:"number",value:Number(i),raw:i}:{type:"enumeration",value:i}}parseKeyword(){let t=this.source.slice(this.offset).match(zd);return t||this.fail("Expected a WKT keyword"),this.offset+=t[0].length,t[0]}parseString(){this.offset++;let t="";for(;this.offset<this.source.length;){let r=this.source[this.offset++];if(r==='"'){if(this.source[this.offset]==='"'){t+='"',this.offset++;continue}return{type:"string",value:t}}t+=r}this.fail("Unterminated WKT string")}skipWhitespace(){for(;this.offset<this.source.length&&/\s/.test(this.source[this.offset]);)this.offset++}fail(t){throw new Pi(t,this.source,this.offset)}};function $d(e,t){return t!=="auto"?t:cr.has(e.toUpperCase())?"wkt1":"wkt2:2019"}function Yd(e){let t=e.keyword.toUpperCase(),r=e.values,i=(n,...o)=>!!(r[n]&&o.includes(r[n].type)),s=(n,...o)=>r.length===n&&o.every((a,h)=>i(h,a));if(["ANGLEUNIT","LENGTHUNIT","PARAMETRICUNIT","SCALEUNIT","TIMEUNIT","TEMPORALQUANTITY","UNIT"].includes(t)&&!(r.length>=2&&i(0,"string")&&i(1,"number")))return`${e.keyword} must start with a quoted name and numeric conversion factor`;if(t==="CS"&&!s(2,"enumeration","number"))return`${e.keyword} must contain a coordinate-system type and dimension`;if(t==="BBOX"&&!s(4,"number","number","number","number"))return`${e.keyword} must contain four numeric bounds`;if(["ENSEMBLEACCURACY","EPOCH","COORDEPOCH","FRAMEEPOCH","OPERATIONACCURACY","ORDER"].includes(t)&&!s(1,"number"))return`${e.keyword} must contain one number`;if(["ANCHOR","AREA","CALENDAR","CITATION","REMARK","SCOPE","URI","VERSION"].includes(t)&&!s(1,"string"))return`${e.keyword} must contain one quoted string`;if(["ELLIPSOID","SPHEROID","TRIAXIAL"].includes(t)&&!(r.length>=3&&i(0,"string")&&i(1,"number")&&i(2,"number")))return`${e.keyword} must start with a quoted name and numeric ellipsoid axes`;if(["PARAMETER"].includes(t)&&!(r.length>=2&&i(0,"string")&&i(1,"number")))return`${e.keyword} must start with a quoted name and numeric value`;if(t==="PARAMETERFILE"&&!s(2,"string","string"))return`${e.keyword} must contain a quoted name and file name`;if(["AUTHORITY","ID"].includes(t)&&!(r.length>=2&&i(0,"string")&&i(1,"string","number")))return`${e.keyword} must start with a quoted authority and identifier`;if(["AXIS"].includes(t)&&!(r.length>=2&&i(0,"string")&&i(1,"enumeration")))return`${e.keyword} must start with a quoted name and axis direction`;if(["METHOD","PROJECTION"].includes(t)&&!(r.length>=1&&i(0,"string")))return`${e.keyword} must start with a quoted name`;if(t==="TIMEEXTENT"){let n=o=>i(o,"enumeration","string");if(r.length!==2||!n(0)||!n(1))return`${e.keyword} must contain two date-time or quoted values`}if(t==="VERTICALEXTENT"&&(r.length<2||r.length>3||!i(0,"number")||!i(1,"number")||r.length===3&&!i(2,"node")))return`${e.keyword} must contain two numeric bounds and an optional unit`;if(t==="COORDINATEMETADATA"&&(r.length<1||r.length>2||!i(0,"node")||r.length===2&&(!i(1,"node")||!["EPOCH","COORDEPOCH"].includes(r[1].keyword.toUpperCase()))))return`${e.keyword} must contain a CRS and an optional coordinate epoch`;if(t==="BOUNDCRS"){let n=r.slice(0,3).map(o=>o.type==="node"?o.keyword.toUpperCase():"");if(n[0]!=="SOURCECRS"||n[1]!=="TARGETCRS"||n[2]!=="ABRIDGEDTRANSFORMATION")return`${e.keyword} must start with SOURCECRS, TARGETCRS, and ABRIDGEDTRANSFORMATION`}return["COMPOUNDCRS","CONCATENATEDOPERATION","COORDINATEOPERATION","DERIVEDPROJCRS","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","GEOGCRS","GEOGRAPHICCRS","PARAMETRICCRS","POINTMOTIONOPERATION","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"].includes(t)&&!i(0,"string")?`${e.keyword} must start with a quoted name`:null}function _h(e,t,r){r({node:e,path:t});for(let i=0;i<e.values.length;i++){let s=e.values[i];s.type==="node"&&_h(s,[...t,i],r)}}function Xd(e,t){let r=1,i=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
8
+ `?(r++,i=1):i++;return{line:r,column:i}}var jt=class extends SyntaxError{constructor(t,r,i){let s=Jd(r,i);super(`${t} at ${s.line}:${s.column}`),this.name="PROJStringSyntaxError",this.offset=i,this.line=s.line,this.column=s.column}};function ln(e){let t=Kd(e);if(t.length===0)throw new jt("PROJ string is empty",e,0);return{type:"proj-string",parameters:t.map(i=>Zd(i.raw,i.offset,e))}}function Zd(e,t,r){let i=e.startsWith("+")?e.slice(1):e;if(!i)throw new jt("Expected a parameter after '+'",r,t);let s=i.indexOf("="),n=s<0?i:i.slice(0,s);if(!n||/[\s+=]/.test(n))throw new jt(`Invalid PROJ parameter name '${n}'`,r,t);if(s<0)return{type:"parameter",name:n};let o=i.slice(s+1),a=Qd(o,r,t+s+1);return{type:"parameter",name:n,value:a,rawValue:o}}function Kd(e){let t=[],r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;let i=r,s=null,n=!1;for(;r<e.length;){let o=e[r];if(n){n=!1,r++;continue}if(o==="\\"&&s){n=!0,r++;continue}if(s){o===s&&(s=null),r++;continue}if(o==='"'||o==="'"){s=o,r++;continue}if(/\s/.test(o))break;r++}if(s)throw new jt("Unterminated quoted PROJ value",e,i);t.push({raw:e.slice(i,r),offset:i})}return t}function Qd(e,t,r){if(!e)return"";let i=e[0];if(i!=='"'&&i!=="'"){if(e.includes('"')||e.includes("'"))throw new jt("Quote must begin a PROJ parameter value",t,r);return e}if(e[e.length-1]!==i)throw new jt("Unterminated quoted PROJ value",t,r);let s="";for(let n=1;n<e.length-1;n++){let o=e[n];o==="\\"&&n+1<e.length-1?s+=e[++n]:s+=o}return s}function Jd(e,t){let r=1,i=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
9
+ `?(r++,i=1):i++;return{line:r,column:i}}var Ci=class{item;previous;next;constructor(t,r,i){this.item=t,this.previous=r,this.next=i}};var Ai=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let r=new Ci(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 i=t.next;t.next=r,this.tail===t?this.tail=r:i.previous=r,r.next=i,r.previous=t,++this._length}};var Te=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Ai,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,i){r._cacheNode||(r._cacheNode=this._list.add(r),i&&i(t,r))}unloadTile(t,r,i){let s=r._cacheNode;s&&(this._list.remove(s),r._cacheNode=null,i&&i(t,r))}unloadTiles(t,r){let i=this._trimTiles;this._trimTiles=!1;let s=this._list,n=this._sentinel,o=s.head;for(;o!==n&&(t.gpuMemoryUsageInBytes>t.cacheBytes||i);){let a=o.item;o=o.next,this.unloadTile(t,a,r)}}trim(){this._trimTiles=!0}};function Ii(e,t){Rt(e),Rt(t);let{rtcCenter:r,gltfUpAxis:i}=t,{computedTransform:s,boundingVolume:{center:n}}=e,o=new C(s);switch(r&&o.translate(r),i){case"Z":break;case"Y":let f=new C().rotateX(Math.PI/2);o=o.multiplyRight(f);break;case"X":let m=new C().rotateY(-Math.PI/2);o=o.multiplyRight(m);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new p(n);t.cartesianModelMatrix=o,t.cartesianOrigin=a;let h=P.WGS84.cartesianToCartographic(a,new p),l=P.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=l.multiplyRight(o),t.cartographicOrigin=h;let u=em(t);u&&(t.cartesianModelMatrix=new C(o).multiplyRight(u.matrix),t.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=C.IDENTITY),t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var tm=1e6**2;function em(e){let t=e.gltf;if(!t)return null;let r=typeof t.scene=="number"?t.scene:0,s=t.scenes?.[r]?.nodes?.[0];if(!s?.matrix)return null;let n=s.matrix;return n[12]*n[12]+n[13]*n[13]+n[14]*n[14]<=tm?null:s}var yh=new p,un=new p,rm=1e-5,im=1e-7,fn=new J([new Y,new Y,new Y,new Y,new Y,new Y]);function Oi(e,t,r={}){let{cameraUp:i,height:s}=e,n=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=lr(e,e.center),h=P.WGS84.eastNorthUpToFixedFrame(a),c=e.unprojectPosition(e.cameraPosition),l=P.WGS84.cartographicToCartesian(c,new p),u;if(n)u=new p(h.transformAsVector(new p(n).scale(o))).normalize();else{let w=e.getFrustumPlanes().near,b=dn(w,e.cameraPosition),R=lr(e,b);u=new p(R).subtract(l).normalize()}let f=new p(h.transformAsVector(new p(i).scale(o))).normalize();sm(e);let m=e.constructor,{longitude:d,latitude:g,width:_,bearing:y,zoom:M,position:T}=e,v=new m({longitude:d,latitude:g,height:s,width:_,bearing:y,zoom:M,position:T,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:v,height:s,cullingVolume:fn,clippingPlanes:e.clippingPlanes,frameNumber:t,sseDenominator:1.15,dynamicScreenSpaceErrorDensity:0}}function Mh(e,t,r,i){let s=Array.from(t),n=Array.from(r),o=e?s.length!==e.position.length||s.some((c,l)=>Math.abs(c-e.position[l])>rm):!1,a=e?n.length!==e.direction.length||n.some((c,l)=>Math.abs(c-e.direction[l])>im):!1,h=o||a?i:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:s,direction:n,lastMovementTime:h},timeSinceMovement:Math.max((i-h)/1e3,0)}}function xh(e,t,r){if(r===0||e.length<=r)return[e,[]];let i=[],{longitude:s,latitude:n}=t.viewport;for(let[c,l]of e.entries()){let[u,f]=l.header.mbs,m=Math.abs(s-u),d=Math.abs(n-f),g=Math.sqrt(d*d+m*m);i.push([c,g])}let o=i.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 sm(e){let t=e.getFrustumPlanes(),r=dn(t.near,e.cameraPosition),i=lr(e,r),s=lr(e,e.cameraPosition,un),n=0;fn.planes[n++].fromPointNormal(i,yh.copy(i).subtract(s));for(let o in t){if(o==="near")continue;let a=t[o],h=dn(a,r,un),c=lr(e,h,un);fn.planes[n++].fromPointNormal(c,yh.copy(i).subtract(c))}}function dn(e,t,r=new p){let i=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-i).add(t),r}function lr(e,t,r=new p){let i=e.unprojectPosition(t);return P.WGS84.cartographicToCartesian(i,r)}var wh=new p,nm=new p,oe=new p,Sh=new p,ur=new p,Eh=new p,Th=new p,vh=new p,Ni=new Et,om=new p(0,0,1);function bh(e,t){e._updateTransform(t)}function Ph(e,t,r){if(!Number.isFinite(r.dynamicScreenSpaceErrorDensity)||r.dynamicScreenSpaceErrorDensity<=0)return 0;let i=lm(e),s=i.region?um(i.region,t):fm(e,i,t);if(!s)return 0;let n=Ke(r.dynamicScreenSpaceErrorHeightFalloff,0,1),o=s.minimumHeight+(s.maximumHeight-s.minimumHeight)*n,a=s.maximumHeight-o,h=a>0?Ke((s.cameraHeight-o)/a,0,1):s.cameraHeight>=s.maximumHeight?1:0,l=(1-Ke(Math.abs(s.cameraDirection.dot(s.upDirection)),0,1))*(1-h);return r.dynamicScreenSpaceErrorDensity*l}function am(e,t){let r=e*t;return 1-Math.exp(-(r*r))}function hm(e,t,r){return t<=0||r<=0||!Number.isFinite(t)||!Number.isFinite(r)?0:am(e,t)*r}function Rh(e,t,r,i=1){let s=e.tileset,n=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=r?n:e.lodMetricValue;if(o===0)return 0;let{viewDistanceScale:a}=s.options,h=a||1,c=Number.isFinite(i)?Math.max(i,0):1,l=cm(o,t,h,c);if(l!==null)return l;let u=Math.max(e._distanceToCamera,1e-7),{height:f,sseDenominator:m}=t,d=o*f*c*h/(u*m);return s.options.dynamicScreenSpaceError&&!t.viewport.orthographic&&(d-=hm(u,t.dynamicScreenSpaceErrorDensity,s.options.dynamicScreenSpaceErrorFactor)),d}function cm(e,t,r,i){let s=t.viewport;if(!s?.orthographic)return null;let n=s.metersPerPixel;return!Number.isFinite(n)||!n||n<=0?null:e*r*i/n}function lm(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function um(e,t){let r=wh.copy(t.camera.position).normalize(),i=ur.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:i,upDirection:r}}function fm(e,t,r){let i=dm(t,oe);if(i===null)return null;let s=new C(e.computedTransform).invert(),n=e.tileset.ellipsoid;if(Math.hypot(oe[0],oe[1],oe[2])>n.minimumRadius){let a=n.cartesianToCartographic(oe,nm),h=wh.copy(r.camera.position).normalize(),c=ur.copy(r.camera.direction).normalize();return{cameraHeight:r.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:c,upDirection:h}}return s.transformAsPoint(r.camera.position,Sh),s.transformAsVector(r.camera.direction,ur),ur.normalize(),{cameraHeight:Sh[2],minimumHeight:oe[2]-i,maximumHeight:oe[2]+i,cameraDirection:ur,upDirection:om}}function dm(e,t){if(e.box){let r=e.box;return t.set(r[0],r[1],r[2]),mm(r)}if(e.sphere){let r=e.sphere;return t.set(r[0],r[1],r[2]),r[3]}return null}function mm(e){return e.length===10?(Ni.fromArray(e,6),Eh.set(e[3],0,0).transformByQuaternion(Ni),Th.set(0,e[4],0).transformByQuaternion(Ni),vh.set(0,0,e[5]).transformByQuaternion(Ni),Math.abs(Eh[2])+Math.abs(Th[2])+Math.abs(vh[2])):Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11])}var et={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},$;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})($||($={}));var Dt;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Dt||(Dt={}));var at;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(at||(at={}));var ve;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(ve||(ve={}));var Ch={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};var Ah=1e4,pm=1e4,gm=1e8,_m=new tt,Ih=new p,Oh=new p,mn=new p,Li=new p;function pn(e,t,r){return e+(t-e)*r}function Nh(e,t){let r=e instanceof tt?e:e.getBoundingSphere(_m),{center:i,radius:s}=r;Ih.copy(i).subtract(t.position);let n=Math.max(Ih.dot(t.direction),0);return Oh.copy(t.direction).scale(n).add(t.position),mn.copy(Oh).subtract(i),mn.magnitude()<=s||(Li.copy(mn).normalize().scale(s).add(i).subtract(t.position),Li.magnitude()===0)?0:(Li.normalize(),Math.min(Math.max(1-Li.dot(t.direction),0),1))}function Lh(e,t,r,i){return!Number.isFinite(i)||i<=0||i>.5?!1:e>r?!0:t!==void 0&&t>r}function Gh(e){let t=Number.isFinite(e.foveatedConeSize)?Math.min(Math.max(e.foveatedConeSize,0),1):1,r=e.refinement===$.REPLACE;if(r&&!e.skipLevelOfDetail||!e.foveatedScreenSpaceError||t>=1||r&&e.skipLevelOfDetail&&e.priorityProgressiveResolution)return!1;let i=Number.isFinite(e.verticalFieldOfView)&&e.verticalFieldOfView>0?e.verticalFieldOfView:Math.PI/3,s=1-Math.cos(i*.5),n=t*s;if(e.foveatedFactor<=n||s<=n)return!1;let o=Math.min(Math.max((e.foveatedFactor-n)/(s-n),0),1),h=(typeof e.interpolationCallback=="function"?e.interpolationCallback:pn)(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 Dh(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*(Ah-1)),i=Number.isFinite(e.foveatedFactor)?Math.min(Math.max(e.foveatedFactor,0),1):0,s=Math.floor(i*(Ah-1))*pm;return(e.priorityProgressiveResolution?0:gm)+s+r}var we="EPSG:4326",Gi="EPSG:4978";function fr(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=ne(e);return r==="wkt"?ym(e):r==="proj-string"?Mm(e):gn(e)||"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":"unknown"}function gn(e){if(typeof e!="string")return;let t=fr(e);if(t===Gi)return"geocentric";if(t===we||t==="OGC:CRS84")return"geographic";let r=/^EPSG:(\d+)$/.exec(t);if(!r)return;let i=Number(r[1]);if(i===7789)return"geocentric";if(i===4490||i===4979)return"geographic";if(i===3857||i>=32601&&i<=32660||i>=32701&&i<=32760)return"projected"}function ym(e){let t;try{t=cn(e).root}catch{return"unknown"}switch(t.keyword.toUpperCase()){case"GEOCCS":return"geocentric";case"GEOGCS":case"GEOGCRS":case"GEOGRAPHICCRS":case"GEOGRAPHIC2DCRS":case"GEOGRAPHIC3DCRS":return"geographic";case"PROJCS":case"PROJCRS":case"PROJECTEDCRS":return"projected";case"GEODCRS":case"GEODETICCRS":{let i=t.values.find(s=>s.type==="node"&&s.keyword.toUpperCase()==="CS")?.values[0];return i?.type!=="enumeration"&&i?.type!=="string"?"unknown":i.value.toUpperCase()==="CARTESIAN"?"geocentric":i.value.toUpperCase()==="ELLIPSOIDAL"?"geographic":"unknown"}default:return"unknown"}}function Mm(e){try{let t=ln(e).parameters.find(r=>r.name.toLowerCase()==="proj")?.value;switch(t?.toLowerCase()){case"longlat":case"latlong":return"geographic";case"geocent":return"geocentric";default:return t?"projected":"unknown"}}catch{return"unknown"}}function yt(e,t={}){let r=t.sourceCrs!==void 0,i=t.sourceCrs||e.sourceCrs,s=t.outputCoordinates||"auto",n=t.targetCrs||(s==="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),m=o!=="native"&&o!==e.heightReference,d=!!n||o!=="native"||s!=="auto"||f,g=s!=="target-crs"||!!n,_=!m||(e.heightReference||"unknown")!=="unknown",y=Number.isFinite(a)&&a>0&&Number.isFinite(h)&&h>0,M=!!i&&d&&g&&_&&y&&u&&s!=="local-enu",T=r?"caller-override":e.provenance||"unknown",v=r&&i?ht(i):e.coordinateFrame,w=r?"explicit":e.sourceCrsState||(i?T==="format-default"?"default":"explicit":"absent"),b=bi({crs:i?{state:w==="default"?"default":"explicit",definition:i,representation:!r&&e.sourceCrsRepresentation||ne(i),provenance:T,alternatives:r?void 0:e.sourceCrsAlternatives}:{state:w==="unknown"?"unknown":"absent",provenance:T},vertical:e.verticalCrs?{state:"explicit",definition:e.verticalCrs,representation:ne(e.verticalCrs),provenance:e.provenance||"metadata"}:void 0,coordinateEpoch:t.coordinateEpoch??e.coordinateEpoch,coordinateFrame:v,coordinateOrder:Sm(e.axisOrder),units:r?void 0:e.units}),R=_n(b.crs),I=b.vertical?_n(b.vertical):void 0,A=n?xm(n):void 0;return Object.freeze({...b,sourceCrs:R,verticalCrs:I,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:T,targetCrs:A,targetHeightReference:o,outputCoordinates:s,status:d?M?"transformable":"unresolved":"native",warnings:Object.freeze([...e.warnings||[]])})}function ae(e,t={}){return yt({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 _n(e){return e.state==="explicit"||e.state==="default"?e.definition:void 0}function xm(e){let t=bi({crs:{state:"explicit",definition:e,representation:ne(e),provenance:"caller-override"}}),r=_n(t.crs);if(!r)throw new Error("Failed to normalize a known target CRS definition");return r}function Sm(e){switch(e){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function be(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 Di(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var rt=1024*1024,Tn=512*rt,vn=512*rt,Em=32*rt,Tm=rt;function dr(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 zh(e,t){let r=e.cacheBytes??(e.maximumMemoryUsage!==void 0?e.maximumMemoryUsage*rt:t);return dr(r,"cacheBytes")}function qh(e,t){let r=e.maximumCacheOverflowBytes??(e.memoryCacheOverflow!==void 0?e.memoryCacheOverflow*rt:t);return dr(r,"maximumCacheOverflowBytes")}var yn={description:"",ellipsoid:P.WGS84,modelMatrix:new C,throttleRequests:!0,maxRequests:64,cacheBytes:Tn,maximumCacheOverflowBytes:vn,maximumMemoryUsage:Tn/rt,memoryCacheOverflow:vn/rt,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:pn,foveatedTimeDelay:.2,maximumScreenSpaceError:8,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,dynamicScreenSpaceError:!0,dynamicScreenSpaceErrorDensity:2e-4,dynamicScreenSpaceErrorFactor:24,dynamicScreenSpaceErrorHeightFalloff:.25,memoryAdjustedScreenSpaceError:!0,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{},spatial:{}},Mn="Tiles In Tileset(s)",xn="Tiles In Memory",Fh="Tiles In View",kh="Tiles To Render",Uh="Tiles Loaded",Sn="Tiles Loading",Vh="Tiles Unloaded",jh="Failed Tile Loads",Wh="Points/Vertices",En="Tile Memory Use",Hh="Maximum Screen Space Error",Bi=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=yt({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=Tn;_maximumCacheOverflowBytes=vn;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new Te;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(t,r){if(!Di(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let i=r||{},s=t.type===at.TILES3D,n=s?yn.cacheBytes:Em,o=s?yn.maximumCacheOverflowBytes:Tm,a=zh(i,n),h=qh(i,o);this.options={...yn,...i,cacheBytes:a,maximumCacheOverflowBytes:h,maximumMemoryUsage:a/rt,memoryCacheOverflow:h/rt,memoryAdjustedScreenSpaceError:i.memoryAdjustedScreenSpaceError??s},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 Vt({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=ae(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 requestedTiles(){return this._requestedTiles.slice()}get emptyTiles(){return this._emptyTiles.slice()}get cacheBytes(){return this._cacheBytes}set cacheBytes(t){this._cacheBytes=dr(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes,this.options.maximumMemoryUsage=this._cacheBytes/rt}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=dr(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes,this.options.memoryCacheOverflow=this._maximumCacheOverflowBytes/rt}get maximumMemoryUsage(){return this.cacheBytes/rt}set maximumMemoryUsage(t){this.cacheBytes=dr(t*rt,"maximumMemoryUsage")}get queryParams(){let t=this.source.getTileUrl(this.url),r=t.indexOf("?");return r>=0?t.slice(r+1):""}setProps(t){let r=zh(t,this.cacheBytes),i=qh(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:r,maximumCacheOverflowBytes:i,maximumMemoryUsage:r/rt,memoryCacheOverflow:i/rt},this._cacheBytes=r,this._maximumCacheOverflowBytes=i}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],i=new Set(r.map(a=>a.id));for(let a of Object.keys(this.frameStateData))i.has(a)||delete this.frameStateData[a];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let s=Date.now(),n=Number.POSITIVE_INFINITY,o=[];for(let a of r){let h=a.id;this._needTraverse(h)?o.push(h):this.traverseCounter--}for(let a of r){let h=a.id;if(this.roots[h]||(this.roots[h]=this._initializeTileHeaders(this.tileset,null)),!o.includes(h))continue;let c=Oi(a,this._frameNumber),l=this.roots[h],u=Mh(this._cameraMotionStates[h],c.camera.position,c.camera.direction,s);this._cameraMotionStates[h]=u.state,c.camera.timeSinceMovement=u.timeSinceMovement,bh(l,this.modelMatrix),c.dynamicScreenSpaceErrorDensity=this.type===at.TILES3D&&this.options.dynamicScreenSpaceError&&!c.viewport.orthographic?Ph(l,c,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=c.dynamicScreenSpaceErrorDensity,this._traverser.traverse(l,c,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(n=Math.min(n,Math.max(this.options.foveatedTimeDelay-u.timeSinceMovement,0)))}Number.isFinite(n)?this._scheduleDeferredTraversal(n):this._clearDeferredTraversal()}_scheduleDeferredTraversal(t){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(r=>{let i=r instanceof Error?r:new Error(String(r));this._onTilesetError(i)})},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 i=this.frameStateData[r],s=Object.values(this._traverser.selectedTiles),[n,o]=xh(s,t,this.options.maximumTilesSelected);i.selectedTiles=n;for(let a of o)a.unselect();i._requestedTiles=Object.values(this._traverser.requestedTiles),i._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)),i=this.selectedTiles.some(n=>!n.tileDrawn),s=0;if(i){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),s++):this._heldTiles.delete(n)}}else this._heldTiles=r;s>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 i=new Set(t.map(o=>o.id)),s=new Set(r.map(o=>o.id)),n=t.some(o=>!s.has(o.id));return n=n||r.some(o=>!i.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 i of this.selectedTiles)if(i.contentAvailable&&i.content){t++;let s=i.contents.length?i.contents:[i.content];for(let n of s)n.pointCount?r+=n.pointCount:r+=n.vertexCount||0}this.stats.get(Fh).count=this.selectedTiles.length,this.stats.get(kh).count=t,this.stats.get(Wh).count=r,this.stats.get(Hh).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.spatialReference?.status==="native")&&(this.root=this._initializeTileHeaders(r.tileset,null),this._applyViewState()),await t;let i=this.source.getMetadata();this._syncSourceState(i),await this.source.prepareTileset?.(this),this.root||(this.root=this._initializeTileHeaders(i.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(Mn),this.stats.get(Sn),this.stats.get(xn),this.stats.get(Fh),this.stats.get(kh),this.stats.get(Uh),this.stats.get(Vh),this.stats.get(jh),this.stats.get(Wh),this.stats.get(En,"memory"),this.stats.get(Hh)}_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(i){let s=i instanceof Error?i:new Error("load failed");this._onSourceError(s,t),this._onTileLoadError(t,s)}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}async _loadTileChildren(t,r){try{this._onStartTileLoading(),await t.loadChildren(r)}catch(i){let s=i instanceof Error?i:new Error("subtree load failed");this._onSourceError(s,t),this._onTileLoadError(t,s)}finally{this._onEndTileLoading()}}_onTileLoadError(t,r){this.stats.get(jh).incrementCount();let i=r.message||r.toString(),s=t.url;console.error(`A 3D tile failed to load: ${t.url} ${i}`),this.options.onTileError(t,i,s)}_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&&Ii(t,t.content),this.source.onTileLoaded?.(this,t,r),this._syncSourceState(this.source.getMetadata());let i=this.source.getTilesTotalCount?.();i&&(this.stats.get(Mn).reset(),this.stats.get(Mn).addCount(i)),this._addTileToCache(t),this.options.onTileLoad(t)}_onStartTileLoading(){this._pendingCount++,this.stats.get(Sn).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Sn).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(Uh).incrementCount(),this.stats.get(xn).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(En).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(xn).decrementCount(),this.stats.get(Vh).incrementCount(),this.stats.get(En).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 i of r.children)t.push(i);this._destroyTile(r)}this.root=null}_destroySubtree(t){let r=t,i=[r];for(;i.length>0;){t=i.pop();for(let s of t.children)i.push(s);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 i=ae(t.spatialReference,this.options.spatial);this.spatialReference=vm(this.spatialReference,i),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 p,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 vm(e,t){return e?.status==="transformed"&&e.sourceCrs===t.sourceCrs&&e.targetCrs===t.targetCrs&&e.targetHeightReference===t.targetHeightReference&&e.outputCoordinates===t.outputCoordinates?e:t}function $h(e){let t=e.selectedTiles.slice(),r=e.requestedTiles.slice(),i=e.emptyTiles.slice(),s=h=>h.map(c=>String(c.id)).sort(),n=h=>{let c=e.stats.get(h).count;return typeof c=="number"&&Number.isFinite(c)?c:0},a=e.source.getImplicitTilingStats?.();return{frameNumber:e.frameNumber,selectedTileIds:s(t),requestedTileIds:s(r),emptyTileIds:s(i),visibleTileCount:t.length,renderableTileCount:t.filter(h=>h.contentAvailable&&!!h.content).length,loadingTileCount:n("Tiles Loading"),loadedTileCount:n("Tiles Loaded"),failedTileCount:n("Failed Tile Loads"),cachedTileCount:n("Tiles In Memory"),cacheBytes:e.gpuMemoryUsageInBytes,maximumScreenSpaceError:e.memoryAdjustedScreenSpaceError,...a?{implicitTiling:a}:{}}}var zi=class{sourceUrl;options;archivePromise;constructor(t){this.options=t,this.sourceUrl=wm(t.data,t.fallbackFilename)}async loadRoot(t,r,i){return await this.parseArchiveResource(t,this.options.rootPath,r,i,this.options.rootMode)}async loadResource(t,r,i){let s=this.resolveArchivePath(t,t);return await this.parseArchiveResource(t,s,r,i)}async parseArchiveResource(t,r,i,s,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,i,{...s,fetch:h},{url:t,fetch:h,_parse:o.parse,loaders:[i],coreApi:o})}createArchiveFetch(t){return async r=>{let i=typeof r=="string"?r:r instanceof URL?r.toString():r.url,s=this.resolveArchivePath(i,t),n=await this.loadFile(s);return new Response(n,{status:200})}}async loadFile(t,r){this.archivePromise||=this.openArchiveReadableFile().then(s=>this.options.parseArchive(s));let i=await this.archivePromise;return await this.options.getFile(i,t,r)}async openArchiveReadableFile(){let{data:t}=this.options;if(typeof t!="string")return new Ee(t);if(/^https?:\/\//i.test(t))return new hr(t);let r=this.options.getCoreApi();if(!r)throw new Error(this.options.missingCoreApiMessage);let i=await r.fetchFile(t);return new Ee(await i.arrayBuffer())}resolveArchivePath(t,r){let i=wn(t),s=wn(this.sourceUrl),n=wn(r),o=n===s?s:_t.dirname(n),a=new RegExp(`\\.${this.options.archiveExtension}/(.*)$`,"i"),h=i.match(a);if(h?.[1])return h[1];let c=/^[a-z][a-z0-9+.-]*:/i.test(i)||i.startsWith("/"),l=i.startsWith(s)?i:n===s&&!c?`${s}/${i}`:_t.resolve(o,i);return l===s?"":l.startsWith(`${s}/`)?l.slice(s.length+1):l.replace(/^\/+/,"")}};function wm(e,t){return typeof e=="string"?e:`memory://${"name"in e&&typeof e.name=="string"&&e.name?e.name:t}`}function wn(e){let t=e.indexOf("?");return t>=0?e.slice(0,t):e}function qi(e){let t=[],r=new Set,i=s=>{if(!s||typeof s!="object"||r.has(s))return;r.add(s);let n=s,o=n.extensions?.EXT_mesh_features?.featureIds;if(Array.isArray(o))for(let a of o){if(!a||typeof a!="object")continue;let h=a.texture?"texture":a.implicit?"implicit":a.attribute!==void 0?"attribute":a.propertyTable!==void 0?"property-table":"constant";t.push({source:h,attribute:a.attribute,propertyTable:a.propertyTable,constant:a.constant,texture:a.texture,implicit:a.implicit,values:a.values,details:a})}for(let a of Object.values(n))i(a)};return i(e),t}function Zh(e){return e!=null}var it=new p,Fi=new p,Yh=new C;function Pe(e,t,r,i=t){if(Rt(e,"3D Tile: boundingVolume must be defined"),e.box){let s=e.s2VolumeInfo?Yh:t;return Xh(e.box,s,r)}if(e.region){let s=ir(e.region),n=t.equals(i)?Yh:t.clone().multiplyRight(i.clone().invert());return Xh([...s.center,...s.halfAxes],n,r)}if(e.sphere)return bm(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Kh(e,t,r=!1){if(e.box||e.region&&r)return Pm(t);if(e.region){let[i,s,n,o,a,h]=e.region;return[[ot(i),ot(s),a],[ot(n),ot(o),h]]}if(e.sphere)return Rm(t);throw new Error("Unkown boundingVolume type")}function Xh(e,t,r){let i=new p(e[0],e[1],e[2]);t.transform(i,i);let s=[];if(e.length===10){let c=e.slice(3,6),l=new Et;l.fromArray(e,6);let u=new p([1,0,0]),f=new p([0,1,0]),m=new p([0,0,1]);u.transformByQuaternion(l),u.scale(c[0]),f.transformByQuaternion(l),f.scale(c[1]),m.transformByQuaternion(l),m.scale(c[2]),s=[...u.toArray(),...f.toArray(),...m.toArray()]}else s=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];let n=t.transformAsVector(s.slice(0,3)),o=t.transformAsVector(s.slice(3,6)),a=t.transformAsVector(s.slice(6,9)),h=new k([n[0],n[1],n[2],o[0],o[1],o[2],a[0],a[1],a[2]]);return Zh(r)?(r.center=i,r.halfAxes=h,r):new Gt(i,h)}function bm(e,t,r){let i=new p(e[0],e[1],e[2]);t.transform(i,i);let s=t.getScale(Fi),n=Math.max(Math.max(s[0],s[1]),s[2]),o=e[3]*n;return Zh(r)?(r.center=i,r.radius=o,r):new tt(i,o)}function Pm(e){let t=Qh(),{halfAxes:r}=e,i=new p(r.getColumn(0)),s=new p(r.getColumn(1)),n=new p(r.getColumn(2));for(let o=0;o<2;o++){for(let a=0;a<2;a++){for(let h=0;h<2;h++)it.copy(e.center),it.add(i),it.add(s),it.add(n),Jh(t,it),n.negate();s.negate()}i.negate()}return t}function Rm(e){let t=Qh(),{center:r,radius:i}=e,s=P.WGS84.scaleToGeodeticSurface(r,it),n;s?n=P.WGS84.geodeticSurfaceNormal(s):n=new p(0,0,1);let o=new p(n[2],-n[1],0);o.len()>0?o.normalize():o=new p(0,1,0);let a=o.clone().cross(n);for(let h of[o,a,n]){Fi.copy(h).scale(i);for(let c=0;c<2;c++)it.copy(r),it.add(Fi),Jh(t,it),Fi.negate()}return t}function Qh(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Jh(e,t){P.WGS84.cartesianToCartographic(t,it),e[0][0]=Math.min(e[0][0],it[0]),e[0][1]=Math.min(e[0][1],it[1]),e[0][2]=Math.min(e[0][2],it[2]),e[1][0]=Math.max(e[1][0],it[0]),e[1][1]=Math.max(e[1][1],it[1]),e[1][2]=Math.max(e[1][2],it[2])}var bn=new p,tc=new p,Jt=new p,ec=new p,Cm=new p,Pn=new C,rc=new C;function ki(e,t){if(e.lodMetricValue===0||Number.isNaN(e.lodMetricValue))return"DIG";let r=2*Rn(e,t);if(r<2)return"OUT";if(!e.header.children)return"DRAW";switch(e.lodMetricType){case"screenSpaceRelative":{let i=t.topDownViewport.height||1;return r/i<=e.lodMetricValue?"DRAW":"DIG"}case"distanceRangeFromDefaultCamera":return e.distanceToTile(t)>=e.lodMetricValue?"DRAW":"DIG";case"maxScreenThresholdSQ":{let i=Math.sqrt(e.lodMetricValue/(Math.PI*.25));return r<=i?"DRAW":"DIG"}default:return r<=e.lodMetricValue?"DRAW":"DIG"}}function Rn(e,t){let{topDownViewport:r}=t,i=e.header.i3sLodMbs||e.header.mbs,s=i[1],n=i[0],o=i[2],a=i[3],h=[...e.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);P.WGS84.cartographicToCartesian(c,bn),tc.copy(bn).subtract(h).normalize(),P.WGS84.eastNorthUpToFixedFrame(h,Pn),rc.copy(Pn).invert(),Jt.copy(bn).transform(rc);let l=Math.sqrt(Jt[0]*Jt[0]+Jt[1]*Jt[1]),u=l*l/Jt[2];ec.copy([Jt[0],Jt[1],u]);let m=ec.transform(Pn).subtract(h).normalize(),g=tc.cross(m).normalize().scale(a).add(h),_=P.WGS84.cartesianToCartographic(g),y=r.project([n,s,o]),M=r.project(_);return Cm.copy(y).subtract(M).magnitude()}var mr=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,r){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]=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){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 Am={loadSiblings:!1,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Bt=class{options;disableSkipLevelOfDetail=!1;root=null;selectedTiles={};requestedTiles={};deferredTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new mr;_emptyTraversalStack=new mr;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...Am,...t}}isSkipLevelOfDetailEnabled(){return this.options.skipLevelOfDetail&&!this.disableSkipLevelOfDetail}traverse(t,r,i){this.root=t,this.options={...this.options,...i},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 i=this._traversalStack;for(t._selectionDepth=1,i.push(t);i.length>0;){let s=i.pop(),n=!1;this.canTraverse(s,r)&&(this.updateChildTiles(s,r),n=this.updateAndPushChildren(s,r,i,s.hasRenderContent?s._selectionDepth+1:s._selectionDepth));let o=s.parent,a=!!(!o||o._shouldRefine),h=!n;s.hasRenderContent?s.refine===$.ADD?(this.loadTile(s,r),this.selectTile(s,r)):s.refine===$.REPLACE&&(this.loadTile(s,r),(h||this.isSkipLevelOfDetailEnabled())&&this.selectTile(s,r)):(this.emptyTiles[s.id]=s,this.loadTile(s,r),h&&this.selectTile(s,r)),this.touchTile(s,r),s._shouldRefine=n&&a}this.completeTraversal(r)}completeTraversal(t){let r=new Date().getTime();(this.traversalFinished(t)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(t))}updateChildTiles(t,r){let i=t.children;for(let s of i)this.updateTile(s,r)}updateAndPushChildren(t,r,i,s){let{loadSiblings:n}=this.options,o=this.isSkipLevelOfDetailEnabled(),a=t.children;a.sort(this.compareDistanceToCamera.bind(this));let h=t.refine===$.REPLACE&&t.hasRenderContent&&!o,c=!1,l=!0;for(let u of a)if(u._selectionDepth=s,u.isVisibleAndInRequestVolume?(i.find(u)&&i.delete(u),i.push(u),c=!0):(h||n)&&u._inRequestVolume&&(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,i=!1){let s=t._screenSpaceError;return i&&(s=t.getScreenSpaceError(r,!0)),s>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,r){let i=[];if(this.options.viewportTraversersMap)for(let s in this.options.viewportTraversersMap)this.options.viewportTraversersMap[s]===r.viewport.id&&i.push(s);else i.push(r.viewport.id);t.updateVisibility(r,i)}compareDistanceToCamera(t,r){return t._distanceToCamera-r._distanceToCamera}anyChildrenVisible(t,r){let i=!1;for(let s of t.children)s.updateVisibility(r),i=i||s.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(t,r){let i=!0,s=!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&&(s=!0,i=!1),!a&&!o.contentAvailable&&!h&&(i=!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&&!s||i}};var Cn=new p;function Im(e,t,r,i,s=[]){let n=e.length?e:[t],o=!1,a=!1;for(let h of n){let c="inside";if(i!==J.MASK_INSIDE&&(c=r.computeVisibility(h),c==="outside"))continue;let l=!1;for(let u of s)if(h.intersectPlane(u)==="outside"){l=!0;break}l||(o=!0,a=a||c==="intersecting")}return o?a?"intersecting":"inside":"outside"}function ic(e){if(!e||typeof e!="object")return!1;let t=e;return t.shape==="tileset3d"||t.type==="tileset3d"||!!t.tileset}function Om(e){return e!=null}var vt=class{tileset;header;id;url;parent;refine;type;contentUrl;contentUrls=[];lodMetricType="geometricError";lodMetricValue=0;_unscaledLodMetricValue=0;_scaleGeometricError=!0;boundingVolume=null;content=null;contents=[];contentEntries=[];metadataContext={};featureIdSets=[];vectorContent=null;metadata=null;contentMetadata=[];contentState=et.UNLOADED;gpuMemoryUsageInBytes=0;children=[];childrenState="ready";depth=0;viewportIds=[];transform=new C;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 C;_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,i,s=""){this.header=r,this.tileset=t,this.id=s||r.id,this.url=r.url,this.parent=i,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this.contentUrls=r.contentUrls||(r.contentUrl?[r.contentUrl]:[]),this._initializeMetadata(r),this.childrenState=r.implicitSubtree?"unloaded":"ready",this._initializeLodMetric(r),this._initializeTransforms(r),this._updateLodMetricScale(),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeContentEntries(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===et.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===et.UNLOADED}get contentExpired(){return this.contentState===et.EXPIRED}get contentFailed(){return this.contentState===et.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Kh(this.header.boundingVolume,this.boundingVolume,!this.computedTransform.equals(this._initialTransform))),this._boundingBox}getScreenSpaceError(t,r,i=1){switch(this.tileset.type){case at.I3S:return Rn(this,t);case at.TILES3D:return Rh(this,t,r,i);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return(this.contents.length?this.contents:[this.content]).reduce((r,i)=>r+(i?.gpuMemoryUsageInBytes||i?.byteLength||0),0)}_getPriority(){return this._calculateRequestPriority(!1)}_getChildrenPriority(){return this._calculateRequestPriority(!0)}_calculateRequestPriority(t){let r=this.tileset._traverser,i=r.options.skipLevelOfDetail&&!r.disableSkipLevelOfDetail,s=this.refine===$.ADD||i;if(s&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.priorityDeferred||!t&&this.contentState===et.UNLOADED)return-1;let n=this.parent,a=n&&(!s||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=et.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=et.UNLOADED,{loaded:!1};try{let i=await this.tileset.source.loadTileContent(this);return i.contents&&(this.contents=i.contents,this.content=this.contents[0]||null),this.vectorContent=this.contents.find(s=>!!s?.vectorContent)?.vectorContent||null,this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this.contentState=et.READY,this._onContentLoaded(),this._updateContentEntriesAfterLoad(i),i}catch(i){throw this.contentState=et.FAILED,i}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 i=await this.tileset.source.loadTileChildren(this,t);return this.childrenState=i.loaded?"ready":"unloaded",i}catch(i){throw this.childrenState="failed",i}finally{r.done()}}applyImplicitSubtreeHeader(t){let r=this.header.transform,i=this.header.transformMatrix,s=t.transform!==void 0;this.header={...this.header,...t,transform:s?t.transform:r,transformMatrix:s?t.transformMatrix:i,implicitSubtree:void 0},s&&this._initializeTransforms(this.header),this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this.contentUrls=t.contentUrls||(t.contentUrl?[t.contentUrl]:[]),this._initializeMetadata(this.header),this._initializeLodMetric(t),this._updateLodMetricScale(),this._initializeBoundingVolumes(this.header),this._boundingBox=void 0,this._initializeContent(this.header),this._initializeContentEntries(this.header)}_initializeMetadata(t){this.metadata=t.metadata||null;let r=Array.isArray(t.content)?t.content:[t.content];this.contentMetadata=r.filter(Boolean).map(a=>a.metadata||null);let s=(r.find(Boolean)||{}).group,n=typeof s=="number"?this.tileset.groups?.[s]||null:s||null,o={tileset:this.tileset.metadata||null,group:n,tile:this.metadata,content:this.contentMetadata[0]||null,subtree:t.implicitMetadata||null};this.tileset.groups&&(o.groups=this.tileset.groups),this.metadataContext=o}_updateContentEntriesAfterLoad(t){if(t.contentEntries){this.contentEntries=t.contentEntries.map((r,i)=>({...r,index:i,boundingVolume:r.boundingVolume||this._contentBoundingVolumes[i]||this.boundingVolume,payload:r.payload??this.contents[i]??null,featureIds:r.featureIds?.length?r.featureIds:qi(r.payload??this.contents[i]),renderable:!!(r.renderable!==!1&&(r.payload??this.contents[i])&&!ic(r.payload??this.contents[i]))})),this.featureIdSets=this.contentEntries.flatMap(r=>r.featureIds);return}this.contentEntries=this.contentEntries.map((r,i)=>({...r,payload:this.contents[i]??null,featureIds:qi(this.contents[i]),renderable:!!this.contents[i]&&!ic(this.contents[i])})),this.featureIdSets=this.contentEntries.flatMap(r=>r.featureIds)}getContentEntry(t){return this.contentEntries[t]||null}isContentRenderable(t){return!!this.contentEntries[t]?.renderable}_initializeContentEntries(t){let r=Array.isArray(t.content)?t.content:t.content?[t.content]:[];this.contentEntries=r.map((i,s)=>{let n=i||{};return{index:s,uri:this.contentUrls[s]||n.uri||n.url,group:n.group,type:n.type,payload:null,metadata:n.metadata||null,boundingVolume:this._contentBoundingVolumes[s]||this.boundingVolume,featureIds:this._getFeatureIdSets(n),renderable:!1}})}_getFeatureIdSets(t){return qi(t)}unloadContent(){for(let t of this.contents.length?this.contents:[this.content])t&&t.destroy&&t.destroy();return this.contents=[],this.content=null,this.vectorContent=null,this.contentEntries=this.contentEntries.map(t=>({...t,payload:null,renderable:!1})),this.featureIdSets=this.contentEntries.flatMap(t=>t.featureIds),this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=et.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(t,r){if(this._frameNumber===t.frameNumber)return;let i=this.parent,s=i?i._visibilityPlaneMask:J.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let n=i?i.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,s),this._visible=this._visibilityPlaneMask!==J.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=r}_updateRequestPriorityMetrics(t){if(this.tileset.type!==at.TILES3D){this._screenSpaceErrorProgressiveResolution=this._screenSpaceError,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1;return}let r=this.tileset.options,i=r.progressiveResolutionHeightFraction;if(this._screenSpaceErrorProgressiveResolution=this.getScreenSpaceError(t,!1,i),this._priorityProgressiveResolution=Lh(this._screenSpaceErrorProgressiveResolution,this.parent?._screenSpaceErrorProgressiveResolution,this.tileset.memoryAdjustedScreenSpaceError,i),!r.foveatedScreenSpaceError||t.viewport?.orthographic||!t.camera?.position||!t.camera?.direction){this._foveatedFactor=0,this.priorityDeferred=!1;return}this._foveatedFactor=Nh(this.boundingVolume,t.camera);let s=this.tileset._traverser,n=s.options.skipLevelOfDetail&&!s.disableSkipLevelOfDetail,o=Gh({refinement:this.refine,skipLevelOfDetail:n,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=Dh(o,t.camera.timeSinceMovement,r.foveatedTimeDelay)}visibility(t,r){let{cullingVolume:i}=t,{boundingVolume:s}=this;return i.computeVisibilityWithPlaneMask(s,r)}contentVisibility(t,r){let i=r===void 0?this._contentBoundingVolumes:this._contentBoundingVolumes[r]?[this._contentBoundingVolumes[r]]:[];return Im(i,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 Cn.subVectors(r.center,t.position),t.direction.dot(Cn)}insideViewerRequestVolume(t){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(Om(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=et.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){this._scaleGeometricError=typeof t._scaleGeometricError=="boolean"?t._scaleGeometricError:this.parent?._scaleGeometricError??!0,"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 C(t.transform):new C;let r=this.parent,i=this.tileset,s=r&&r.computedTransform?r.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new C(s).multiplyRight(this.transform);let n=r&&r._initialTransform?r._initialTransform.clone():new C;this._initialTransform=new C(n).multiplyRight(this.transform)}_updateLodMetricScale(){if(this.lodMetricType!==ve.GEOMETRIC_ERROR||!this._scaleGeometricError){this.lodMetricValue=this._unscaledLodMetricValue;return}let t=this.computedTransform.getScale(Cn),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=et.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=J.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||$.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._boundingBox=void 0,this.boundingVolume=Pe(t.boundingVolume,this.computedTransform,this.boundingVolume,this._initialTransform),t.viewerRequestVolume&&(this._viewerRequestVolume=Pe(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume,this._initialTransform));let r=t.content;r&&(this._contentBoundingVolumeHeaders=Array.isArray(r)?r:[r]);let i=r?Array.isArray(r)?r:[r]:this._contentBoundingVolumeHeaders;this._contentBoundingVolumes=i.length?i.map(s=>s?.boundingVolume?Pe(s.boundingVolume,this.computedTransform,void 0,this._initialTransform):this.boundingVolume):[this.boundingVolume],this._contentBoundingVolume=this._contentBoundingVolumes[0]||null}_updateTransform(t=new C){let r=t.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateLodMetricScale(),this._updateBoundingVolume(this.header))}};var Ui=class extends Bt{pendingImplicitSubtrees=new Map;traversalFinished(t){let r=`${t.viewport.id}:`;for(let[i,s]of this.pendingImplicitSubtrees)if(i.startsWith(r)&&s===t.frameNumber)return!1;return!0}executeTraversal(t,r){if(!this.isSkipLevelOfDetailEnabled()){super.executeTraversal(t,r);return}this.executeSkipTraversal(t,r)}executeSkipTraversal(t,r){let i=[t];for(t._selectionDepth=t.parent?t.parent._selectionDepth:1;i.length>0;){let s=i.pop(),n=!s.parent||s.parent._shouldRefine,o=this.canTraverse(s,r)&&this.updateAndPushSkipChildren(s,r,i)&&n,a=!o&&n;s.hasRenderContent?s.refine===$.ADD?(this.loadTile(s,r),this.selectDesiredTile(s,r)):s.refine===$.REPLACE&&(this.isInBaseTraversal(s,r)?(this.loadTile(s,r),a&&this.selectDesiredTile(s,r)):a?(this.loadTile(s,r),this.selectDesiredTile(s,r)):this.hasReachedSkippingThreshold(s,r)&&this.loadTile(s,r)):(this.emptyTiles[s.id]=s,this.loadTile(s,r),a&&this.selectDesiredTile(s,r)),this.touchTile(s,r),s._shouldRefine=o}this.completeTraversal(r)}updateAndPushSkipChildren(t,r,i){this.updateChildTiles(t,r),t.children.sort(this.compareDistanceToCamera.bind(this));let s=!1;for(let n of t.children)n._selectionDepth=t.hasRenderContent?t._selectionDepth+1:t._selectionDepth,n.isVisibleAndInRequestVolume?(i.push(n),s=!0):this.options.loadSiblings&&(this.loadTile(n,r),this.touchTile(n,r));return s}isInBaseTraversal(t,r){if(this.options.immediatelyLoadDesiredLevelOfDetail)return!1;if(!this.findNearestRequestedOrLoadedAncestor(t,r))return!0;let i=Number.isFinite(this.options.baseScreenSpaceError)?Math.max(this.options.baseScreenSpaceError,0):1024,s=Math.max(i,t.tileset.memoryAdjustedScreenSpaceError);return t._screenSpaceError===0&&t.parent?t.parent._screenSpaceError>s:t._screenSpaceError>s}hasReachedSkippingThreshold(t,r){if(this.options.immediatelyLoadDesiredLevelOfDetail)return!1;if(t._priorityProgressiveResolution&&t._screenSpaceErrorProgressiveResolution<=t.tileset.memoryAdjustedScreenSpaceError&&!!(t.parent&&t.parent._screenSpaceErrorProgressiveResolution>t.tileset.memoryAdjustedScreenSpaceError))return!0;let s=this.findNearestRequestedOrLoadedAncestor(t,r);if(!s)return!1;let n=Number.isFinite(this.options.skipScreenSpaceErrorFactor)&&this.options.skipScreenSpaceErrorFactor>0?this.options.skipScreenSpaceErrorFactor:16,o=Number.isFinite(this.options.skipLevels)?Math.max(Math.floor(this.options.skipLevels),0):1;return t._screenSpaceError<s._screenSpaceError/n&&t.depth>s.depth+o}findNearestRequestedOrLoadedAncestor(t,r){let i=t.parent;for(;i;){if(i.hasRenderContent&&!i.contentFailed&&(!i.hasUnloadedContent||i._requestedFrame===r.frameNumber))return i;i=i.parent}return null}selectDesiredTile(t,r){let i=t;for(;i;){if(this.shouldSelectTile(i,r)){this.selectTile(i,r);return}i=i.parent}this.selectLoadedDescendants(t,r)}selectLoadedDescendants(t,r){let i=[{tile:t,depth:0}];for(;i.length>0;){let{tile:s,depth:n}=i.pop();for(let o of s.children)this.updateTile(o,r),o.isVisibleAndInRequestVolume&&(o.contentAvailable?(this.selectTile(o,r),this.touchTile(o,r)):n<1&&i.push({tile:o,depth:n+1}))}}compareDistanceToCamera(t,r){return r._distanceToCamera===0&&t._distanceToCamera===0?r._centerZDepth-t._centerZDepth:r._distanceToCamera-t._distanceToCamera}updateChildTiles(t,r){let i=t.header.implicitSubtree?.coordinates.level===0;if(t.hasUnloadedChildren&&t.isVisibleAndInRequestVolume&&(i||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,i){this.pendingImplicitSubtrees.delete(i),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 i=t.children.length>0;if(t.hasTilesetContent&&i){let o=t.children[0];this.updateTileVisibility(o,r),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,r)){t._visible=!1;return}let s=t.refine===$.REPLACE,n=t._optimChildrenWithinParent===Ch.USE_OPTIMIZATION;if(s&&n&&i&&!this.anyChildrenVisible(t,r)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,r){let{parent:i}=t;return!i||i.hasTilesetContent||i.refine!==$.ADD?!1:!this.shouldRefine(t,r,!0)}};var Nm=6378137,Lm=6378137,An=6356752314245179e-9,Re=new p;function sc(e,t){if(e instanceof Gt){let{halfAxes:r}=e,i=Gm(r);return Math.log2(An/(i+t[2]))}else if(e instanceof tt){let{radius:r}=e;return Math.log2(An/(r+t[2]))}else if(e.width&&e.height){let{width:r,height:i}=e,s=Math.log2(Nm/r),n=Math.log2(Lm/i);return(s+n)/2}return 1}function In(e,t,r){P.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],Re);let i=Math.sqrt(Math.pow(Re[0]-r[0],2)+Math.pow(Re[1]-r[1],2)+Math.pow(Re[2]-r[2],2));return Math.log2(An/(i+t[2]))}function nc(e,t,r){let[i,s,n,o]=e;return In({xmin:i,xmax:n,ymin:s,ymax:o,zmin:0,zmax:0},t,r)}function Gm(e){e.getColumn(0,Re);let t=e.getColumn(1),r=e.getColumn(2);return Re.add(t).add(r).len()}var Dm=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}),Bm=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 pr(e){if(!e)return;let t=e.trim().toLowerCase().replaceAll("_","-"),r=Bm[t]||t;return Dm[r]}function oc(e,t){return t!==void 0?Number.isFinite(t)&&t>0?t:void 0:e?pr(e):1}function Vi(e){let t=e.spatialReference||e.fullExtent?.spatialReference,r=Um(t),i=e.heightModelInfo?.vertCRS||Vm(t),s=e.heightModelInfo?.heightModel,n=e.heightModelInfo?.heightUnit,o=oc(n,e.ZFactor),a=s==="ellipsoidal"?"ellipsoidal":s==="gravity_related_height"?"orthometric":"unknown",h=cc(t),c=h===void 0?r?ht(r):"unknown":ht(`EPSG:${h}`),l=zm(c,n,e.ZFactor),u=[],f=qm(e.elevationInfo?.mode),m=e.elevationInfo?e.elevationInfo.unit||"meter":void 0,d=pr(m);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&&d===void 0&&u.push(`Unsupported I3S elevation unit ${m}`),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`),yt({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:i,units:l,verticalUnitScale:o??Number.NaN,heightReference:a,elevationMode:f,elevationOffset:e.elevationInfo?.offset,elevationUnit:m,elevationUnitScale:e.elevationInfo?.mode&&!f?Number.NaN:d??(e.elevationInfo?Number.NaN:1),coordinateFrame:c,axisOrder:r?"xyz":"unknown",provenance:r?"metadata":"unknown",warnings:u})}function zm(e,t,r){if(e==="geocentric")return["meter","meter","meter"];if(e==="geographic"&&(t||r===void 0))return["degree","degree",t||"meter"]}function qm(e){switch(e){case"absoluteHeight":case"onTheGround":case"relativeToGround":case"relativeToScene":return e;default:return}}function ji(e){let t=Fm(e);if(t)return t;let r=ac(e,"TILESET_CRS_GEOCENTRIC"),i=ac(e,"TILESET_CRS_COORDINATE_EPOCH"),s=[],n,o="unknown",a;typeof r=="string"&&r.toUpperCase()!=="UNKNOWN"?(n=r,o="metadata",a="explicit"):r!==void 0?(s.push("3D Tiles geocentric CRS is explicitly unknown"),o="metadata",a="unknown"):e.root?.boundingVolume?.region?(n="EPSG:4978",o="format-default",a="default"):e.schemaUri&&!e.schema&&s.push("External 3D Tiles metadata schema must be loaded before CRS semantics can resolve");let h=hc(i);return i!==void 0&&h===void 0&&s.push("3D Tiles coordinate epoch is not a finite decimal year"),yt({sourceCrs:n,sourceCrsState:a,sourceCrsRepresentation:n?"identifier":void 0,coordinateEpoch:h,heightReference:n?"ellipsoidal":"unknown",coordinateFrame:n?"geocentric":"unknown",axisOrder:n?"xyz":"unknown",provenance:o,warnings:s})}function Fm(e){let t=e.extensions?.EXT_geospatial_crs;if(!t)return;let r=[],i,s,n,o;if(t.format==="wkid"){let l=t.extensions?.EXT_geospatial_crs_wkid;typeof l?.authority=="string"&&Number.isInteger(l.wkid)?(i=`${l.authority}:${l.wkid}`,o="identifier",Number.isInteger(l.vcsWkid)&&(s=`${l.authority}:${l.vcsWkid}`),n=hc(l.epoch),l.epoch!==void 0&&n===void 0&&r.push("EXT_geospatial_crs_wkid epoch is not a finite decimal year")):r.push("EXT_geospatial_crs_wkid requires string authority and integer wkid")}else if(t.format==="wkt2"){let l=t.extensions?.EXT_geospatial_crs_wkt2;typeof l?.wkt2=="string"&&l.wkt2.trim()?(i=l.wkt2,o="wkt"):r.push("EXT_geospatial_crs_wkt2 requires a nonempty wkt2 string")}else r.push(`Unsupported EXT_geospatial_crs format ${String(t.format)}`);let a=o==="wkt"?ht(i):gn(i)||"unknown",h=km(s);s&&!h&&r.push(`Unsupported vertical CRS ${String(s)}; vertical unit and height reference are unknown`);let c=s?h?.unit:"meter";return yt({sourceCrs:i,sourceCrsState:i?"explicit":"unknown",sourceCrsRepresentation:o,verticalCrs:s,coordinateEpoch:n,units:a==="geocentric"?["meter","meter","meter"]:a==="geographic"&&c?["degree","degree",c]:void 0,verticalUnitScale:s?h?.verticalUnitScale??Number.NaN:1,heightReference:s?h?.heightReference??"unknown":i?"ellipsoidal":"unknown",coordinateFrame:a,axisOrder:i?"xyz":"unknown",provenance:"metadata",warnings:r})}function km(e){if(typeof e!="string")return;let t=/^EPSG:(\d+)$/i.exec(e);if(t)switch(Number(t[1])){case 5702:case 6360:return{unit:"us-foot",verticalUnitScale:1200/3937,heightReference:"orthometric"};case 5703:return{unit:"meter",verticalUnitScale:1,heightReference:"orthometric"};default:return}}function hc(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 Um(e){let t=cc(e);return t!==void 0?`EPSG:${t}`:e?.wkt}function Vm(e){let t=e?.latestVcsWkid??e?.vcsWkid;return t===void 0?void 0:`EPSG:${t}`}function cc(e){return e?.latestWkid??e?.wkid}function ac(e,t){let r=e.metadata?.class;if(!r)return;let s=e.schema?.classes?.[r]?.properties,n=e.metadata?.properties;for(let[o,a]of Object.entries(s||{}))if(a.semantic===t)return n?.[o]}function lc(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 Ct=1,At=2,Wt=3,uc=4,gr=5,On=6378137,fc=6356752314e-3,Nn=.0066943799901413165,he=484813681109536e-20,x=Math.PI/2,dc=.16666666666666666,mc=.04722222222222222,pc=.022156084656084655,E=1e-10,q=.017453292519943295,Z=57.29577951308232,G=Math.PI/4,te=Math.PI*2,j=3.14159265359;var lt={};lt.greenwich=0;lt.lisbon=-9.131906111111;lt.paris=2.337229166667;lt.bogota=-74.080916666667;lt.madrid=-3.687938888889;lt.rome=12.452333333333;lt.bern=7.439583333333;lt.jakarta=106.807719444444;lt.ferro=-17.666666666667;lt.brussels=4.367975;lt.stockholm=18.058277777778;lt.athens=23.7163375;lt.oslo=10.722916666667;var gc=lt;var _c={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 yc=/[\s_\-\/\(\)]/g;function Mt(e,t){if(e[t])return e[t];for(var r=Object.keys(e),i=t.toLowerCase().replace(yc,""),s=-1,n,o;++s<r.length;)if(n=r[s],o=n.toLowerCase().replace(yc,""),o===i)return e[n]}function _r(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},{}),i,s,n,o={proj:"projName",datum:"datumCode",rf:function(a){t.rf=parseFloat(a)},lat_0:function(a){t.lat0=a*q},lat_1:function(a){t.lat1=a*q},lat_2:function(a){t.lat2=a*q},lat_ts:function(a){t.lat_ts=a*q},lon_0:function(a){t.long0=a*q},lon_wrap:function(a){t.long_wrap=parseFloat(a)*q},lon_1:function(a){t.long1=a*q},lon_2:function(a){t.long2=a*q},alpha:function(a){t.alpha=parseFloat(a)*q},gamma:function(a){t.rectified_grid_angle=parseFloat(a)*q},lonc:function(a){t.longc=a*q},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=Mt(_c,a);h&&(t.to_meter=h.to_meter)},from_greenwich:function(a){t.from_greenwich=a*q},pm:function(a){var h=Mt(gc,a);t.from_greenwich=(h||parseFloat(a))*q},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(i in r)s=r[i],i in o?(n=o[i],typeof n=="function"?n(s):t[n]=s):t[i]=s;return typeof t.datumCode=="string"&&t.datumCode!=="WGS84"&&(t.datumCode=t.datumCode.toLowerCase()),t.projStr=e,t}var Ln=class{static getId(t){let r=t.find(i=>Array.isArray(i)&&i[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 i=t[1],s=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:i,conversion_factor:s,id:o}}static convertAxis(t){let r=t[1]||"Unknown",i,s=r.match(/^\((.)\)$/);if(s){let c=s[1].toUpperCase();if(c==="E")i="east";else if(c==="N")i="north";else if(c==="U")i="up";else if(t[2])i=t[2];else throw new Error(`Unknown axis abbreviation: ${c}`)}else i=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:i,unit:h,order:o}}static extractAxes(t){return t.filter(r=>Array.isArray(r)&&r[0]==="AXIS").map(r=>this.convertAxis(r)).sort((r,i)=>(r.order||0)-(i.order||0))}static convert(t,r={}){switch(t[0]){case"PROJCRS":r.type="ProjectedCRS",r.name=t[1],r.base_crs=t.find(d=>Array.isArray(d)&&d[0]==="BASEGEOGCRS")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="BASEGEOGCRS")):null,r.conversion=t.find(d=>Array.isArray(d)&&d[0]==="CONVERSION")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="CONVERSION")):null;let i=t.find(d=>Array.isArray(d)&&d[0]==="CS");i&&(r.coordinate_system={subtype:i[1],axis:this.extractAxes(t)});let s=t.find(d=>Array.isArray(d)&&d[0]==="LENGTHUNIT");if(s){let d=this.convertUnit(s);r.coordinate_system.unit=d}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(d=>Array.isArray(d)&&(d[0]==="DATUM"||d[0]==="ENSEMBLE"));if(n){let d=this.convert(n);n[0]==="ENSEMBLE"?r.datum_ensemble=d:r.datum=d;let g=t.find(_=>Array.isArray(_)&&_[0]==="PRIMEM");g&&g[1]!=="Greenwich"&&(d.prime_meridian={name:g[1],longitude:parseFloat(g[2])})}let o=t.find(d=>Array.isArray(d)&&d[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(d=>Array.isArray(d)&&d[0]==="ELLIPSOID")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="ELLIPSOID")):null;break;case"ENSEMBLE":r.type="DatumEnsemble",r.name=t[1],r.members=t.filter(d=>Array.isArray(d)&&d[0]==="MEMBER").map(d=>({type:"DatumEnsembleMember",name:d[1],id:this.getId(d)}));let a=t.find(d=>Array.isArray(d)&&d[0]==="ENSEMBLEACCURACY");a&&(r.accuracy=parseFloat(a[1]));let h=t.find(d=>Array.isArray(d)&&d[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(d=>Array.isArray(d)&&d[0]==="LENGTHUNIT")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="LENGTHUNIT"),r):null;break;case"CONVERSION":r.type="Conversion",r.name=t[1],r.method=t.find(d=>Array.isArray(d)&&d[0]==="METHOD")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="METHOD")):null,r.parameters=t.filter(d=>Array.isArray(d)&&d[0]==="PARAMETER").map(d=>this.convert(d));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(d=>Array.isArray(d)&&(d[0]==="LENGTHUNIT"||d[0]==="ANGLEUNIT"||d[0]==="SCALEUNIT"))),r.id=this.getId(t);break;case"BOUNDCRS":r.type="BoundCRS";let l=t.find(d=>Array.isArray(d)&&d[0]==="SOURCECRS");if(l){let d=l.find(g=>Array.isArray(g));r.source_crs=d?this.convert(d):null}let u=t.find(d=>Array.isArray(d)&&d[0]==="TARGETCRS");if(u){let d=u.find(g=>Array.isArray(g));r.target_crs=d?this.convert(d):null}let f=t.find(d=>Array.isArray(d)&&d[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(d=>Array.isArray(d)&&d[0]==="METHOD")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="METHOD")):null,r.parameters=t.filter(d=>Array.isArray(d)&&(d[0]==="PARAMETER"||d[0]==="PARAMETERFILE")).map(d=>{if(d[0]==="PARAMETER")return this.convert(d);if(d[0]==="PARAMETERFILE")return{name:d[1],value:d[2],id:{authority:"EPSG",code:8656}}}),r.parameters.length===7){let d=r.parameters[6];d.name==="Scale difference"&&(d.value=Math.round((d.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 m=this.convertUnit(t,"LinearUnit");r.coordinate_system&&r.coordinate_system.axis&&r.coordinate_system.axis.forEach(d=>{d.unit||(d.unit=m)}),m.conversion_factor&&m.conversion_factor!==1&&r.semi_major_axis&&(r.semi_major_axis={value:r.semi_major_axis,unit:m});break;default:r.keyword=t[0];break}return r}},Mc=Ln;function xc(e){return Mc.convert(e)}function Sc(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 Ec=$m,yr=1,Tc=2,vc=3,Wi=4,wc=5,Gn=-1,jm=/\s/,Wm=/[A-Za-z]/,Hm=/[A-Za-z84_]/,Hi=/[,\]]/,bc=/[\d\.E\-\+]/;function Ht(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=yr}Ht.prototype.readCharicter=function(){var e=this.text[this.place++];if(this.state!==Wi)for(;jm.test(e);){if(this.place>=this.text.length)return;e=this.text[this.place++]}switch(this.state){case yr:return this.neutral(e);case Tc:return this.keyword(e);case Wi:return this.quoted(e);case wc:return this.afterquote(e);case vc:return this.number(e);case Gn:return}};Ht.prototype.afterquote=function(e){if(e==='"'){this.word+='"',this.state=Wi;return}if(Hi.test(e)){this.word=this.word.trim(),this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in afterquote yet, index '+this.place)};Ht.prototype.afterItem=function(e){if(e===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=yr;return}if(e==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=yr,this.currentObject=this.stack.pop(),this.currentObject||(this.state=Gn);return}};Ht.prototype.number=function(e){if(bc.test(e)){this.word+=e;return}if(Hi.test(e)){this.word=parseFloat(this.word),this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in number yet, index '+this.place)};Ht.prototype.quoted=function(e){if(e==='"'){this.state=wc;return}this.word+=e};Ht.prototype.keyword=function(e){if(Hm.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=yr;return}if(Hi.test(e)){this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in keyword yet, index '+this.place)};Ht.prototype.neutral=function(e){if(Wm.test(e)){this.word=e,this.state=Tc;return}if(e==='"'){this.word="",this.state=Wi;return}if(bc.test(e)){this.word=e,this.state=vc;return}if(Hi.test(e)){this.afterItem(e);return}throw new Error(`havn't handled "`+e+'" in neutral yet, index '+this.place)};Ht.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===Gn)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function $m(e){var t=new Ht(e);return t.output()}function Dn(e,t,r){Array.isArray(t)&&(r.unshift(t),t=null);var i=t?{}:e,s=r.reduce(function(n,o){return ce(o,n),n},i);t&&(e[t]=s)}function ce(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]={},ce(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 i;switch(r){case"UNIT":case"PRIMEM":case"VERT_DATUM":t[r]={name:e[0].toLowerCase(),convert:e[1]},e.length===3&&ce(e[2],t[r]);return;case"SPHEROID":case"ELLIPSOID":t[r]={name:e[0],a:e[1],rf:e[2]},e.length===4&&ce(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]],Dn(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]],Dn(t,r,e),t[r].type=r;return;default:for(i=-1;++i<e.length;)if(!Array.isArray(e[i]))return ce(e,t[r]);return Dn(t,r,e)}}var Ym=.017453292519943295;function xt(e){return e*Ym}function $i(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=xt(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=xt(e.lat0>0?90:-90),delete e.lat1)}function Pc(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 Rc(e){return typeof e=="object"?e.value*e.unit.conversion_factor:e}function Cc(e,t){e.ellipsoid.radius?(t.a=e.ellipsoid.radius,t.rf=0):(t.a=Rc(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-Rc(e.ellipsoid.semi_minor_axis))))}function Mr(e,t={}){return!e||typeof e!="object"?e:e.type==="BoundCRS"?(Mr(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 i=e[r];if(i!==null)switch(r){case"name":if(t.srsCode)break;t.name=i,t.srsCode=i;break;case"type":i==="GeographicCRS"?t.projName="longlat":i==="GeodeticCRS"?e.coordinate_system&&e.coordinate_system.subtype==="Cartesian"?t.projName="geocent":t.projName="longlat":i==="ProjectedCRS"&&e.conversion&&e.conversion.method&&(t.projName=e.conversion.method.name);break;case"datum":case"datum_ensemble":i.ellipsoid&&(t.ellps=i.ellipsoid.name,Cc(i,t)),i.prime_meridian&&(t.from_greenwich=i.prime_meridian.longitude*Math.PI/180);break;case"ellipsoid":t.ellps=i.name,Cc(i,t);break;case"prime_meridian":t.long0=(i.longitude||0)*Math.PI/180;break;case"coordinate_system":if(i.axis){let s={east:"e",north:"n",west:"w",south:"s",up:"u",down:"d",geocentricx:"e",geocentricy:"n",geocentricz:"u"},n=i.axis.map(o=>s[o.direction.toLowerCase()]);if(n.every(Boolean)&&(t.axis=n.join(""),t.axis.length===2&&(t.axis+="u")),i.unit){let{units:o,to_meter:a}=Pc(i.unit);t.units=o,t.to_meter=a}else if(i.axis[0]&&i.axis[0].unit){let{units:o,to_meter:a}=Pc(i.axis[0].unit);t.units=o,t.to_meter=a}}break;case"id":i.authority&&i.code&&(t.title=i.authority+":"+i.code);break;case"conversion":i.method&&i.method.name&&(t.projName=i.method.name),i.parameters&&i.parameters.forEach(s=>{let n=s.name.toLowerCase().replace(/\s+/g,"_"),o=s.value;s.unit&&s.unit.conversion_factor?t[n]=o*s.unit.conversion_factor:s.unit==="degree"?t[n]=o*Math.PI/180:t[n]=o});break;case"unit":i.name&&(t.units=i.name.toLowerCase(),t.units==="metre"&&(t.units="meter")),i.conversion_factor&&(t.to_meter=i.conversion_factor);break;case"base_crs":Mr(i,t),t.datumCode=i.id?i.id.authority+"_"+i.id.code:i.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),$i(t),t)}var Xm=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function Zm(e,t){var r=t[0],i=t[1];!(r in e)&&i in e&&(e[r]=e[i],t.length===3&&(e[r]=t[2](e[r])))}function Ac(e){for(var t=Object.keys(e),r=0,i=t.length;r<i;++r){var s=t[r];Xm.indexOf(s)!==-1&&Km(e[s]),typeof e[s]=="object"&&Ac(e[s])}}function Km(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="",i=0,s=e.AXIS.length;i<s;++i){var n=[e.AXIS[i][0].toLowerCase(),e.AXIS[i][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=xt(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=xt(e.rectified_grid_angle));function a(l){var u=e.to_meter||1;return l*u}var h=function(l){return Zm(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",xt],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",xt],["x0","false_easting",a],["y0","false_northing",a],["long0","central_meridian",xt],["lat0","latitude_of_origin",xt],["lat0","standard_parallel_1",xt],["lat1","standard_parallel_1",xt],["lat2","standard_parallel_2",xt],["azimuth","Azimuth"],["alpha","azimuth",xt],["srsCode","name"]];c.forEach(h),$i(e)}function Ce(e){if(typeof e=="object")return Mr(e);let t=Sc(e);var r=Ec(e);if(t==="WKT2"){let n=xc(r);return Mr(n)}var i=r[0],s={};return ce(r,s),Ac(s),s[i]}function ut(e){var t=this;if(arguments.length===2){var r=arguments[1];typeof r=="string"?r.charAt(0)==="+"?ut[e]=_r(arguments[1]):ut[e]=Ce(arguments[1]):r&&typeof r=="object"&&!("projName"in r)?ut[e]=Ce(arguments[1]):(ut[e]=r,r||delete ut[e])}else if(arguments.length===1){if(Array.isArray(e))return e.map(function(i){return Array.isArray(i)?ut.apply(t,i):ut(i)});if(typeof e=="string"){if(e in ut)return ut[e]}else"EPSG"in e?ut["EPSG:"+e.EPSG]=e:"ESRI"in e?ut["ESRI:"+e.ESRI]=e:"IAU2000"in e?ut["IAU2000:"+e.IAU2000]=e:console.log(e);return}}lc(ut);var Ae=ut;function Qm(e){return typeof e=="string"}function Jm(e){return e in Ae}function t1(e){return e.indexOf("+")!==0&&e.indexOf("[")!==-1||typeof e=="object"&&!("srsCode"in e)}var Ic=["3857","900913","3785","102113"];function e1(e){if(e.title)return e.title.toLowerCase().indexOf("epsg:")===0&&Ic.indexOf(e.title.substr(5))>-1;var t=Mt(e,"authority");if(t){var r=Mt(t,"epsg");return r&&Ic.indexOf(r)>-1}}function r1(e){var t=Mt(e,"extension");if(t)return Mt(t,"proj4")}function i1(e){return e[0]==="+"}function s1(e){let t;if(Qm(e))if(Jm(e))t=Ae[e];else if(t1(e)){t=Ce(e);var r=r1(t);r&&(t=_r(r))}else i1(e)&&(t=_r(e));else"projName"in e?t=e:t=Ce(e);return t&&e1(t)?Ae["EPSG:3857"]:t}var Oc=s1;function Bn(e,t){e=e||{};var r,i;if(!t)return e;for(i in t)r=t[i],r!==void 0&&(e[i]=r);return e}function st(e,t,r){var i=e*t;return r/Math.sqrt(1-i*i)}function zt(e){return e<0?-1:1}function S(e,t){return t||Math.abs(e)<=j?e:e-zt(e)*te}function ct(e,t,r){var i=e*r,s=.5*e;return i=Math.pow((1-i)/(1+i),s),Math.tan(.5*(x-t))/i}function $t(e,t){for(var r=.5*e,i,s,n=x-2*Math.atan(t),o=0;o<=15;o++)if(i=e*Math.sin(n),s=x-2*Math.atan(t*Math.pow((1-i)/(1+i),r))-n,n+=s,Math.abs(s)<=1e-10)return n;return-9999}function n1(){var e=this.b/this.a;this.es=1-e*e,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.long0=this.long0||0,this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=st(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function o1(e){var t=e.x,r=e.y;if(r*Z>90&&r*Z<-90&&t*Z>180&&t*Z<-180)return null;var i,s;if(Math.abs(Math.abs(r)-x)<=E)return null;if(this.sphere)i=this.x0+this.a*this.k0*S(t-this.long0,this.over),s=this.y0+this.a*this.k0*Math.log(Math.tan(G+.5*r));else{var n=Math.sin(r),o=ct(this.e,r,n);i=this.x0+this.a*this.k0*S(t-this.long0,this.over),s=this.y0-this.a*this.k0*Math.log(o)}return e.x=i,e.y=s,e}function a1(e){var t=e.x-this.x0,r=e.y-this.y0,i,s;if(this.sphere)s=x-2*Math.atan(Math.exp(-r/(this.a*this.k0)));else{var n=Math.exp(-r/(this.a*this.k0));if(s=$t(this.e,n),s===-9999)return null}return i=S(this.long0+t/(this.a*this.k0),this.over),e.x=i,e.y=s,e}var h1=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","Mercator_Variant_A","merc"],Nc={init:n1,forward:o1,inverse:a1,names:h1};function c1(){}function Lc(e){return e}var zn=["longlat","identity"],Gc={init:c1,forward:Lc,inverse:Lc,names:zn};var l1=[Nc,Gc],le={},Ie=[];function Dc(e,t){var r=Ie.length;return e.names?(Ie[r]=e,e.names.forEach(function(i){le[i.toLowerCase()]=r}),this):(console.log(t),!0)}function qn(e){return e.replace(/[-\(\)\s]+/g," ").trim().replace(/ /g,"_")}function u1(e){if(!e)return!1;var t=e.toLowerCase();if(typeof le[t]<"u"&&Ie[le[t]]||(t=qn(t),t in le&&Ie[le[t]]))return Ie[le[t]]}function f1(){l1.forEach(Dc)}var Bc={start:f1,add:Dc,get:u1};var d1={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,b: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)"}},Fn=d1;var m1=Fn.WGS84;function zc(e,t,r,i){var s=e*e,n=t*t,o=(s-n)/s,a=0;i?(e*=1-o*(dc+o*(mc+o*pc)),s=e*e,o=0):a=Math.sqrt(o);var h=(s-n)/n;return{es:o,e:a,ep2:h}}function qc(e,t,r,i,s){if(!e){var n=Mt(Fn,i);n||(n=m1),e=n.a,t=n.b,r=n.rf}return r&&!t&&(t=(1-1/r)*e),(r===0||Math.abs(e-t)<E)&&(s=!0,t=e),{a:e,b:t,rf:r,sphere:s}}var Xi={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:"clrk80ign",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(Fc in Xi)Yi=Xi[Fc],Yi.datumName&&(Xi[Yi.datumName]=Yi);var Yi,Fc,kc=Xi;function p1(e,t,r,i,s,n,o){var a={};return a.datum_type=gr,t&&(a.datum_type=uc,a.datum_params=t.map(parseFloat),(a.datum_params[0]!==0||a.datum_params[1]!==0||a.datum_params[2]!==0)&&(a.datum_type=Ct),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=At,a.datum_params[3]*=he,a.datum_params[4]*=he,a.datum_params[5]*=he,a.datum_params[6]=a.datum_params[6]/1e6+1)),o&&(a.datum_type=Wt,a.grids=o),a.a=r,a.b=i,a.es=s,a.ep2=n,a}var Uc=p1;var Un={};function Vn(e,t,r){return t instanceof ArrayBuffer?g1(e,t,r):{ready:_1(e,t)}}function g1(e,t,r){var i=!0;r!==void 0&&r.includeErrorFields===!1&&(i=!1);var s=new DataView(t),n=M1(s),o=x1(s,n),a=S1(s,o,n,i),h={header:o,subgrids:a};return Un[e]=h,h}async function _1(e,t){for(var r=[],i=await t.getImageCount(),s=i-1;s>=0;s--){var n=await t.getImage(s),o=await n.readRasters(),a=o,h=[n.getWidth(),n.getHeight()],c=n.getBoundingBox().map(Vc),l=typeof n.fileDirectory.getValue=="function"?n.fileDirectory.getValue("ModelPixelScale"):n.fileDirectory.ModelPixelScale,u=[l[0],l[1]].map(Vc),f=c[0]+(h[0]-1)*u[0],m=c[3]-(h[1]-1)*u[1],d=a[0],g=a[1],_=[];for(let T=h[1]-1;T>=0;T--)for(let v=h[0]-1;v>=0;v--){var y=T*h[0]+v;_.push([-ee(g[y]),ee(d[y])])}r.push({del:u,lim:h,ll:[-f,m],cvs:_})}var M={header:{nSubgrids:i},subgrids:r};return Un[e]=M,M}function jc(e){if(e===void 0)return null;var t=e.split(",");return t.map(y1)}function y1(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:Un[e]||null,isNull:!1}}function Vc(e){return e*Math.PI/180}function ee(e){return e/3600*Math.PI/180}function M1(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 x1(e,t){return{nFields:e.getInt32(8,t),nSubgridFields:e.getInt32(24,t),nSubgrids:e.getInt32(40,t),shiftType:kn(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 kn(e,t,r){return String.fromCharCode.apply(null,new Uint8Array(e.buffer.slice(t,r)))}function S1(e,t,r,i){for(var s=176,n=[],o=0;o<t.nSubgrids;o++){var a=T1(e,s,r),h=v1(e,s,a,r,i),c=Math.round(1+(a.upperLongitude-a.lowerLongitude)/a.longitudeInterval),l=Math.round(1+(a.upperLatitude-a.lowerLatitude)/a.latitudeInterval);n.push({ll:[ee(a.lowerLongitude),ee(a.lowerLatitude)],del:[ee(a.longitudeInterval),ee(a.latitudeInterval)],lim:[c,l],count:a.gridNodeCount,cvs:E1(h)});var u=16;i===!1&&(u=8),s+=176+a.gridNodeCount*u}return n}function E1(e){return e.map(function(t){return[ee(t.longitudeShift),ee(t.latitudeShift)]})}function T1(e,t,r){return{name:kn(e,t+8,t+16).trim(),parent:kn(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 v1(e,t,r,i,s){var n=t+176,o=16;s===!1&&(o=8);for(var a=[],h=0;h<r.gridNodeCount;h++){var c={latitudeShift:e.getFloat32(n+h*o,i),longitudeShift:e.getFloat32(n+h*o+4,i)};s!==!1&&(c.latitudeAccuracy=e.getFloat32(n+h*o+8,i),c.longitudeAccuracy=e.getFloat32(n+h*o+12,i)),a.push(c)}return a}function Oe(e,t){if(!(this instanceof Oe))return new Oe(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=Oc(e);if(typeof r!="object"){t("Could not parse to valid json: "+e);return}var i=Oe.projections.get(r.projName);if(!i){t("Could not get projection name from: "+e);return}if(r.datumCode&&r.datumCode!=="none"){var s=Mt(kc,r.datumCode);s&&(r.datum_params=r.datum_params||(s.towgs84?s.towgs84.split(","):null),r.ellps=s.ellipse,r.datumName=s.datumName?s.datumName:r.datumCode)}r.axis=r.axis||"enu",r.ellps=r.ellps||"wgs84",r.lat1=r.lat1||r.lat0;var n=qc(r.a,r.b,r.rf,r.ellps,r.sphere),o=zc(n.a,n.b,n.rf,r.R_A),a=jc(r.nadgrids),h=r.datum||Uc(r.datumCode,r.datum_params,n.a,n.b,o.es,o.ep2,a);Bn(this,r),Bn(this,i),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(),this.k0||(this.k0=1),t(null,this)}Oe.projections=Bc;Oe.projections.start();var It=Oe;function Wc(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===Ct?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===At?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 Zi(e,t,r){var i=e.x,s=e.y,n=e.z?e.z:0,o,a,h,c;if(s<-x&&s>-1.001*x)s=-x;else if(s>x&&s<1.001*x)s=x;else{if(s<-x)return{x:-1/0,y:-1/0,z:e.z};if(s>x)return{x:1/0,y:1/0,z:e.z}}return i>Math.PI&&(i-=2*Math.PI),a=Math.sin(s),c=Math.cos(s),h=a*a,o=r/Math.sqrt(1-t*h),{x:(o+n)*c*Math.cos(i),y:(o+n)*c*Math.sin(i),z:(o*(1-t)+n)*a}}function Ki(e,t,r,i){var s=1e-12,n=s*s,o=30,a,h,c,l,u,f,m,d,g,_,y,M,T,v=e.x,w=e.y,b=e.z?e.z:0,R,I,A;if(a=Math.sqrt(v*v+w*w),h=Math.sqrt(v*v+w*w+b*b),a/r<s){if(R=0,h/r<s)return I=x,A=-i,{x:e.x,y:e.y,z:e.z}}else R=Math.atan2(w,v);c=b/h,l=a/h,u=1/Math.sqrt(1-t*(2-t)*l*l),d=l*(1-t)*u,g=c*u,T=0;do T++,m=r/Math.sqrt(1-t*g*g),A=a*d+b*g-m*(1-t*g*g),f=t*m/(m+A),u=1/Math.sqrt(1-f*(2-f)*l*l),_=l*(1-f)*u,y=c*u,M=y*d-_*g,d=_,g=y;while(M*M>n&&T<o);return I=Math.atan(y/Math.abs(_)),{x:R,y:I,z:A}}function Hc(e,t,r){if(t===Ct)return{x:e.x+r[0],y:e.y+r[1],z:e.z+r[2]};if(t===At){var i=r[0],s=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)+i,y:c*(h*e.x+e.y-o*e.z)+s,z:c*(-a*e.x+o*e.y+e.z)+n}}}function $c(e,t,r){if(t===Ct)return{x:e.x-r[0],y:e.y-r[1],z:e.z-r[2]};if(t===At){var i=r[0],s=r[1],n=r[2],o=r[3],a=r[4],h=r[5],c=r[6],l=(e.x-i)/c,u=(e.y-s)/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 Qi(e){return e===Ct||e===At}function Zc(e,t,r){if(Wc(e,t)||e.datum_type===gr||t.datum_type===gr)return r;var i=e.a,s=e.es;if(e.datum_type===Wt){var n=Yc(e,!1,r);if(n!==0)return;i=On,s=Nn}var o=t.a,a=t.b,h=t.es;if(t.datum_type===Wt&&(o=On,a=fc,h=Nn),s===h&&i===o&&!Qi(e.datum_type)&&!Qi(t.datum_type))return r;if(r=Zi(r,s,i),Qi(e.datum_type)&&(r=Hc(r,e.datum_type,e.datum_params)),Qi(t.datum_type)&&(r=$c(r,t.datum_type,t.datum_params)),r=Ki(r,h,o,a),t.datum_type===Wt){var c=Yc(t,!0,r);if(c!==0)return}return r}function Yc(e,t,r){if(e.grids===null||e.grids.length===0)return console.log("Grid shift grids not found"),-1;var i={x:-r.x,y:r.y},s={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){s=i;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,m=u.ll[0]-f,d=u.ll[1]-f,g=u.ll[0]+(u.lim[0]-1)*u.del[0]+f,_=u.ll[1]+(u.lim[1]-1)*u.del[1]+f;if(!(d>i.y||m>i.x||_<i.y||g<i.x)&&(s=w1(i,t,u),!isNaN(s.x)))break t}}return isNaN(s.x)?(console.log("Failed to find a grid shift table for location '"+-i.x*Z+" "+i.y*Z+" tried: '"+n+"'"),-1):(r.x=-s.x,r.y=s.y,0)}function w1(e,t,r){var i={x:Number.NaN,y:Number.NaN};if(isNaN(e.x))return i;var s={x:e.x,y:e.y};s.x-=r.ll[0],s.y-=r.ll[1],s.x=S(s.x-Math.PI)+Math.PI;var n=Xc(s,r);if(t){if(isNaN(n.x))return i;n.x=s.x-n.x,n.y=s.y-n.y;var o=9,a=1e-12,h,c;do{if(c=Xc(n,r),isNaN(c.x)){console.log("Inverse grid shift iteration failed, presumably at grid edge. Using first approximation.");break}h={x:s.x-(c.x+n.x),y:s.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."),i;i.x=S(n.x+r.ll[0]),i.y=n.y+r.ll[1]}else isNaN(n.x)||(i.x=e.x+n.x,i.y=e.y+n.y);return i}function Xc(e,t){var r={x:e.x/t.del[0],y:e.y/t.del[1]},i={x:Math.floor(r.x),y:Math.floor(r.y)},s={x:r.x-1*i.x,y:r.y-1*i.y},n={x:Number.NaN,y:Number.NaN},o;if(i.x<0||i.x>=t.lim[0]||i.y<0||i.y>=t.lim[1])return n;o=i.y*t.lim[0]+i.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=s.x*s.y,f=s.x*(1-s.y),m=(1-s.x)*(1-s.y),d=(1-s.x)*s.y;return n.x=m*a.x+f*h.x+d*l.x+u*c.x,n.y=m*a.y+f*h.y+d*l.y+u*c.y,n}var ue=["x","y","z"];function Kc(e,t){let r={};for(let i=0,s=e.axis.length;i<s;i++){if(i===2&&t.z===void 0)continue;let n=t[ue[i]];switch(e.axis[i]){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 Qc(e,t){let r={};for(let i=0,s=e.axis.length;i<s;i++)if(!(i===2&&t.z===void 0))switch(e.axis[i]){case"e":r[ue[i]]=t.x;break;case"w":r[ue[i]]=-t.x;break;case"n":r[ue[i]]=t.y;break;case"s":r[ue[i]]=-t.y;break;case"u":r[ue[i]]=t.z;break;case"d":r[ue[i]]=-t.z;break;default:return null}return r}function Ne(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 tl(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 b1(e,t){return(e.datum.datum_type===Ct||e.datum.datum_type===At||e.datum.datum_type===Wt)&&t.datumCode!=="WGS84"||(t.datum.datum_type===Ct||t.datum.datum_type===At||t.datum.datum_type===Wt)&&e.datumCode!=="WGS84"}function xr(e,t,r,i){var s,n=r.z!==void 0;if(tl(r),e.datum&&t.datum&&b1(e,t)&&(s=new It("WGS84"),r=xr(e,s,r,i),e=s),i&&e.axis!=="enu"&&(r=Kc(e,r)),e.projName==="longlat")r={x:r.x*q,y:r.y*q,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=Zc(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"?(t.long_wrap!==void 0&&(r.x=t.long_wrap+S(r.x-t.long_wrap)),r={x:r.x*Z,y:r.y*Z,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})),i&&t.axis!=="enu"?Qc(t,r):(r&&!n&&t.projName!=="geocent"&&delete r.z,r)}function jn(e,t,r,i){var s;return Array.isArray(r)?s=Ne(r):s={x:r.x,y:r.y,z:r.z,m:r.m},xr(e,t,s,i)}var el=It("WGS84");function Wn(e,t,r,i){var s,n,o;return Array.isArray(r)?(s=xr(e,t,Ne(r),i)||{x:NaN,y:NaN},r.length>2?(n=typeof e.name<"u"&&e.name==="geocent"||typeof t.name<"u"&&t.name==="geocent",n?typeof s.z=="number"?[s.x,s.y,s.z].concat(r.slice(3)):[s.x,s.y,r[2]].concat(r.slice(3)):i&&typeof s.z=="number"?[s.x,s.y,s.z].concat(r.slice(3)):[s.x,s.y].concat(r.slice(2))):[s.x,s.y]):(s=xr(e,t,{x:r.x,y:r.y,z:r.z,m:r.m},i)||{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||i)||(s[a]=r[a])})),s)}function Ji(e){return e instanceof It?e:typeof e=="object"&&"oProj"in e?e.oProj:It(e)}function P1(e,t,r){var i,s,n=!1,o;return typeof t>"u"?(s=Ji(e),i=el,n=!0):(typeof t.x<"u"||Array.isArray(t))&&(r=t,s=Ji(e),i=el,n=!0),i||(i=Ji(e)),s||(s=Ji(t)),r?Wn(i,s,r):(o={forward:function(a,h){return Wn(i,s,a,h)},inverse:function(a,h){return Wn(s,i,a,h)}},n&&(o.oProj=s),o)}var rl=P1;var il=6,nl="AJSAJS",ol="AFAFAF",Le=65,ft=73,wt=79,Sr=86,Er=90,al={forward:$n,inverse:R1,toPoint:Yn};function $n(e,t){return t=t||5,I1(C1({lat:e[1],lon:e[0]}),t)}function R1(e){var t=Xn(cl(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat,t.lon,t.lat]:[t.left,t.bottom,t.right,t.top]}function Yn(e){var t=Xn(cl(e.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}function Hn(e){return e*(Math.PI/180)}function sl(e){return 180*(e/Math.PI)}function C1(e){var t=e.lat,r=e.lon,i=6378137,s=.00669438,n=.9996,o,a,h,c,l,u,f,m=Hn(t),d=Hn(r),g,_;_=Math.floor((r+180)/6)+1,r===180&&(_=60),t>=56&&t<64&&r>=3&&r<12&&(_=32),t>=72&&t<84&&(r>=0&&r<9?_=31:r>=9&&r<21?_=33:r>=21&&r<33?_=35:r>=33&&r<42&&(_=37)),o=(_-1)*6-180+3,g=Hn(o),a=s/(1-s),h=i/Math.sqrt(1-s*Math.sin(m)*Math.sin(m)),c=Math.tan(m)*Math.tan(m),l=a*Math.cos(m)*Math.cos(m),u=Math.cos(m)*(d-g),f=i*((1-s/4-3*s*s/64-5*s*s*s/256)*m-(3*s/8+3*s*s/32+45*s*s*s/1024)*Math.sin(2*m)+(15*s*s/256+45*s*s*s/1024)*Math.sin(4*m)-35*s*s*s/3072*Math.sin(6*m));var y=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,M=n*(f+h*Math.tan(m)*(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&&(M+=1e7),{northing:Math.round(M),easting:Math.round(y),zoneNumber:_,zoneLetter:A1(t)}}function Xn(e){var t=e.northing,r=e.easting,i=e.zoneLetter,s=e.zoneNumber;if(s<0||s>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,m,d,g,_,y,M,T=r-5e5,v=t;i<"N"&&(v-=1e7),_=(s-1)*6-180+3,h=a/(1-a),g=v/n,y=g/(o*(1-a/4-3*a*a/64-5*a*a*a/256)),M=y+(3*c/2-27*c*c*c/32)*Math.sin(2*y)+(21*c*c/16-55*c*c*c*c/32)*Math.sin(4*y)+151*c*c*c/96*Math.sin(6*y),l=o/Math.sqrt(1-a*Math.sin(M)*Math.sin(M)),u=Math.tan(M)*Math.tan(M),f=h*Math.cos(M)*Math.cos(M),m=o*(1-a)/Math.pow(1-a*Math.sin(M)*Math.sin(M),1.5),d=T/(l*n);var w=M-l*Math.tan(M)/m*(d*d/2-(5+3*u+10*f-4*f*f-9*h)*d*d*d*d/24+(61+90*u+298*f+45*u*u-252*h-3*f*f)*d*d*d*d*d*d/720);w=sl(w);var b=(d-(1+2*u+f)*d*d*d/6+(5-2*f+28*u-3*f*f+8*h+24*u*u)*d*d*d*d*d/120)/Math.cos(M);b=_+sl(b);var R;if(e.accuracy){var I=Xn({northing:e.northing+e.accuracy,easting:e.easting+e.accuracy,zoneLetter:e.zoneLetter,zoneNumber:e.zoneNumber});R={top:I.lat,right:I.lon,bottom:w,left:b}}else R={lat:w,lon:b};return R}function A1(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 I1(e,t){var r="00000"+e.easting,i="00000"+e.northing;return e.zoneNumber+e.zoneLetter+O1(e.easting,e.northing,e.zoneNumber)+r.substr(r.length-5,t)+i.substr(i.length-5,t)}function O1(e,t,r){var i=hl(r),s=Math.floor(e/1e5),n=Math.floor(t/1e5)%20;return N1(s,n,i)}function hl(e){var t=e%il;return t===0&&(t=il),t}function N1(e,t,r){var i=r-1,s=nl.charCodeAt(i),n=ol.charCodeAt(i),o=s+e-1,a=n+t,h=!1;o>Er&&(o=o-Er+Le-1,h=!0),(o===ft||s<ft&&o>ft||(o>ft||s<ft)&&h)&&o++,(o===wt||s<wt&&o>wt||(o>wt||s<wt)&&h)&&(o++,o===ft&&o++),o>Er&&(o=o-Er+Le-1),a>Sr?(a=a-Sr+Le-1,h=!0):h=!1,(a===ft||n<ft&&a>ft||(a>ft||n<ft)&&h)&&a++,(a===wt||n<wt&&a>wt||(a>wt||n<wt)&&h)&&(a++,a===ft&&a++),a>Sr&&(a=a-Sr+Le-1);var c=String.fromCharCode(o)+String.fromCharCode(a);return c}function cl(e){if(e&&e.length===0)throw"MGRSPoint coverting from nothing";for(var t=e.length,r=null,i="",s,n=0;!/[A-Z]/.test(s=e.charAt(n));){if(n>=2)throw"MGRSPoint bad conversion from: "+e;i+=s,n++}var o=parseInt(i,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=hl(o),c=L1(r.charAt(0),h),l=G1(r.charAt(1),h);l<D1(a);)l+=2e6;var u=t-n;if(u%2!==0)throw`MGRSPoint has to have an even number
8
10
  of digits after the zone letter and two 100km letters - front
9
11
  half for easting meters, second half for
10
- northing meters`+e;var f=u/2,d=0,m=0,g,_,M,y,E;return f>0&&(g=1e5/Math.pow(10,f),_=e.substring(n,n+f),d=parseFloat(_)*g,M=e.substring(n+f),m=parseFloat(M)*g),y=d+c,E=m+l,{easting:y,northing:E,zoneLetter:a,zoneNumber:o,accuracy:g}}function Rd(e,t){for(var i=wc.charCodeAt(t-1),s=1e5,r=!1;i!==e.charCodeAt(0);){if(i++,i===ut&&i++,i===wt&&i++,i>ui){if(r)throw"Bad character: "+e;i=Re,r=!0}s+=1e5}return s}function Cd(e,t){if(e>"V")throw"MGRSPoint given invalid Northing "+e;for(var i=Tc.charCodeAt(t-1),s=0,r=!1;i!==e.charCodeAt(0);){if(i++,i===ut&&i++,i===wt&&i++,i>li){if(r)throw"Bad character: "+e;i=Re,r=!0}s+=1e5}return s}function Ad(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 Ce(e,t,i){if(!(this instanceof Ce))return new Ce(e,t,i);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=i||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}Ce.fromMGRS=function(e){return new Ce(En(e))};Ce.prototype.toMGRS=function(e){return vn([this.x,this.y],e)};var Cc=Ce;var Id=1,Od=.25,Ac=.046875,Ic=.01953125,Oc=.01068115234375,Nd=.75,Ld=.46875,Gd=.013020833333333334,zd=.007120768229166667,qd=.3645833333333333,Bd=.005696614583333333,Dd=.3076171875;function Ae(e){var t=[];t[0]=Id-e*(Od+e*(Ac+e*(Ic+e*Oc))),t[1]=e*(Nd-e*(Ac+e*(Ic+e*Oc)));var i=e*e;return t[2]=i*(Ld-e*(Gd+e*zd)),i*=e,t[3]=i*(qd-e*Bd),t[4]=i*e*Dd,t}function qt(e,t,i,s){return i*=t,t*=t,s[0]*e-i*(s[1]+t*(s[2]+t*(s[3]+t*s[4])))}var Fd=20;function Ie(e,t,i){for(var s=1/(1-t),r=e,n=Fd;n;--n){var o=Math.sin(r),a=1-t*o*o;if(a=(qt(r,o,Math.cos(r),i)-e)*(a*Math.sqrt(a))*s,r-=a,Math.abs(a)<v)return r}return r}function Ud(){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=Ae(this.es),this.ml0=qt(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Vd(e){var t=e.x,i=e.y,s=S(t-this.long0,this.over),r,n,o,a=Math.sin(i),h=Math.cos(i);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)>v?Math.tan(i):0,g=Math.pow(m,2),_=Math.pow(g,2);r=1-this.es*Math.pow(a,2),l=l/Math.sqrt(r);var M=qt(i,a,h,this.en);n=this.a*(this.k0*l*(1+u/6*(1-g+f+u/20*(5-18*g+_+14*f-58*g*f+u/42*(61+179*_-_*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+_-58*g+270*f-330*g*f+u/56*(1385+543*_-_*g-3111*g))))))+this.y0}else{var c=h*Math.sin(s);if(Math.abs(Math.abs(c)-1)<v)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>v)return 93;o=0}else o=Math.acos(o);i<0&&(o=-o),o=this.a*this.k0*(o-this.lat0)+this.y0}return e.x=n,e.y=o,e}function kd(e){var t,i,s,r,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,i=Ie(t,this.es,this.en),Math.abs(i)<x){var u=Math.sin(i),f=Math.cos(i),d=Math.abs(f)>v?Math.tan(i):0,m=this.ep2*Math.pow(f,2),g=Math.pow(m,2),_=Math.pow(d,2),M=Math.pow(_,2);t=1-this.es*Math.pow(u,2);var y=n*Math.sqrt(t)/this.k0,E=Math.pow(y,2);t=t*d,s=i-t*E/(1-this.es)*.5*(1-E/12*(5+3*_-9*m*_+m-4*g-E/30*(61+90*_-252*m*_+45*M+46*m-E/56*(1385+3633*_+4095*M+1574*M*_)))),r=S(this.long0+y*(1-E/6*(1+2*_+m-E/20*(5+28*_+24*M+8*m*_+6*m-E/42*(61+662*_+1320*M+720*M*_))))/f,this.over)}else s=x*zt(o),r=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?r=0:r=S(Math.atan2(h,l)+this.long0,this.over)}return e.x=r,e.y=s,e}var jd=["Fast_Transverse_Mercator","Fast Transverse Mercator"],Oe={init:Ud,forward:Vd,inverse:kd,names:jd};function Bs(e){var t=Math.exp(e);return t=(t-1/t)/2,t}function Z(e,t){e=Math.abs(e),t=Math.abs(t);var i=Math.max(e,t),s=Math.min(e,t)/(i||1);return i*Math.sqrt(1+Math.pow(s,2))}function Nc(e){var t=1+e,i=t-1;return i===0?e:e*Math.log(t)/i}function Lc(e){var t=Math.abs(e);return t=Nc(t*(1+t/(Z(1,t)+1))),e<0?-t:t}function Ds(e,t){for(var i=2*Math.cos(2*t),s=e.length-1,r=e[s],n=0,o;--s>=0;)o=-n+i*r+e[s],n=r,r=o;return t+o*Math.sin(2*t)}function Gc(e,t){for(var i=2*Math.cos(t),s=e.length-1,r=e[s],n=0,o;--s>=0;)o=-n+i*r+e[s],n=r,r=o;return Math.sin(t)*o}function zc(e){var t=Math.exp(e);return t=(t+1/t)/2,t}function Tn(e,t,i){for(var s=Math.sin(t),r=Math.cos(t),n=Bs(i),o=zc(i),a=2*r*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=r*n,[a*l-h*d,a*d+h*l]}function Wd(){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&&(Oe.init.apply(this),this.forward=Oe.forward,this.inverse=Oe.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.k0=this.k0!==void 0?this.k0:1,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var e=this.es/(1+Math.sqrt(1-this.es)),t=e/(2-e),i=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)))))),i=i*t,this.cgb[1]=i*(7/3+t*(-8/5+t*(-227/45+t*(2704/315+t*(2323/945))))),this.cbg[1]=i*(5/3+t*(-16/15+t*(-13/9+t*(904/315+t*(-1522/945))))),i=i*t,this.cgb[2]=i*(56/15+t*(-136/35+t*(-1262/105+t*(73814/2835)))),this.cbg[2]=i*(-26/15+t*(34/21+t*(8/5+t*(-12686/2835)))),i=i*t,this.cgb[3]=i*(4279/630+t*(-332/35+t*(-399572/14175))),this.cbg[3]=i*(1237/630+t*(-12/5+t*(-24832/14175))),i=i*t,this.cgb[4]=i*(4174/315+t*(-144838/6237)),this.cbg[4]=i*(-734/315+t*(109598/31185)),i=i*t,this.cgb[5]=i*(601676/22275),this.cbg[5]=i*(444337/155925),i=Math.pow(t,2),this.Qn=this.k0/(1+t)*(1+i*(1/4+i*(1/64+i/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]=i*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+t*(1118711/3870720))))),this.gtu[1]=i*(13/48+t*(-3/5+t*(557/1440+t*(281/630+t*(-1983433/1935360))))),i=i*t,this.utg[2]=i*(-17/480+t*(37/840+t*(209/4480+t*(-5569/90720)))),this.gtu[2]=i*(61/240+t*(-103/140+t*(15061/26880+t*(167603/181440)))),i=i*t,this.utg[3]=i*(-4397/161280+t*(11/504+t*(830251/7257600))),this.gtu[3]=i*(49561/161280+t*(-179/168+t*(6601661/7257600))),i=i*t,this.utg[4]=i*(-4583/161280+t*(108847/3991680)),this.gtu[4]=i*(34729/80640+t*(-3418889/1995840)),i=i*t,this.utg[5]=i*(-20648693/638668800),this.gtu[5]=i*(212378941/319334400);var s=Ds(this.cbg,this.lat0);this.Zb=-this.Qn*(s+Gc(this.gtu,2*s))}function Hd(e){var t=S(e.x-this.long0,this.over),i=e.y;i=Ds(this.cbg,i);var s=Math.sin(i),r=Math.cos(i),n=Math.sin(t),o=Math.cos(t);i=Math.atan2(s,o*r),t=Math.atan2(n*r,Z(s,r*o)),t=Lc(Math.tan(t));var a=Tn(this.gtu,2*i,2*t);i=i+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*i+this.Zb)+this.y0):(h=1/0,c=1/0),e.x=h,e.y=c,e}function Yd(e){var t=(e.x-this.x0)*(1/this.a),i=(e.y-this.y0)*(1/this.a);i=(i-this.Zb)/this.Qn,t=t/this.Qn;var s,r;if(Math.abs(t)<=2.623395162778){var n=Tn(this.utg,2*i,2*t);i=i+n[0],t=t+n[1],t=Math.atan(Bs(t));var o=Math.sin(i),a=Math.cos(i),h=Math.sin(t),c=Math.cos(t);i=Math.atan2(o*c,Z(h,c*a)),t=Math.atan2(h,c*a),s=S(t+this.long0,this.over),r=Ds(this.cgb,i)}else s=1/0,r=1/0;return e.x=s,e.y=r,e}var Zd=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","Gauss Kruger","Gauss_Kruger","tmerc"],Ne={init:Wd,forward:Hd,inverse:Yd,names:Zd};function qc(e,t){if(e===void 0){if(e=Math.floor((S(t)+Math.PI)*30/Math.PI)+1,e<0)return 0;if(e>60)return 60}return e}var Xd="etmerc";function $d(){var e=qc(this.zone,this.long0);if(e===void 0)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(e)-183)*B,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,Ne.init.apply(this),this.forward=Ne.forward,this.inverse=Ne.inverse}var Qd=["Universal Transverse Mercator System","utm"],Bc={init:$d,names:Qd,dependsOn:Xd};function Fs(e,t){return Math.pow((1-e)/(1+e),t)}var Kd=20;function Jd(){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+O)/(Math.pow(Math.tan(.5*this.lat0+O),this.C)*Fs(this.e*e,this.ratexp))}function t1(e){var t=e.x,i=e.y;return e.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*i+O),this.C)*Fs(this.e*Math.sin(i),this.ratexp))-x,e.x=this.C*t,e}function e1(e){for(var t=1e-14,i=e.x/this.C,s=e.y,r=Math.pow(Math.tan(.5*s+O)/this.K,1/this.C),n=Kd;n>0&&(s=2*Math.atan(r*Fs(this.e*Math.sin(e.y),-.5*this.e))-x,!(Math.abs(s-e.y)<t));--n)e.y=s;return n?(e.x=i,e.y=s,e):null}var i1=["gauss"],Us={init:Jd,forward:t1,inverse:e1,names:i1};function s1(){Us.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 r1(e){var t,i,s,r;return e.x=S(e.x-this.long0,this.over),Us.forward.apply(this,[e]),t=Math.sin(e.y),i=Math.cos(e.y),s=Math.cos(e.x),r=this.k0*this.R2/(1+this.sinc0*t+this.cosc0*i*s),e.x=r*i*Math.sin(e.x),e.y=r*(this.cosc0*t-this.sinc0*i*s),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function n1(e){var t,i,s,r,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=Z(e.x,e.y)){var o=2*Math.atan2(n,this.R2);t=Math.sin(o),i=Math.cos(o),r=Math.asin(i*this.sinc0+e.y*t*this.cosc0/n),s=Math.atan2(e.x*t,n*this.cosc0*i-e.y*this.sinc0*t)}else r=this.phic0,s=0;return e.x=s,e.y=r,Us.inverse.apply(this,[e]),e.x=S(e.x+this.long0,this.over),e}var o1=["Stereographic_North_Pole","Oblique_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],Dc={init:s1,forward:r1,inverse:n1,names:o1};function Pn(e,t,i){return t*=i,Math.tan(.5*(x+e))*Math.pow((1-t)/(1+t),.5*i)}function a1(){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?!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=v&&(this.k0=.5*(1+zt(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=v&&(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)),!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=v&&Math.abs(Math.cos(this.lat_ts))>v&&(this.k0=.5*this.cons*rt(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/ht(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=rt(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(Pn(this.lat0,this.sinlat0,this.e))-x,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function h1(e){var t=e.x,i=e.y,s=Math.sin(i),r=Math.cos(i),n,o,a,h,c,l,u=S(t-this.long0,this.over);return Math.abs(Math.abs(t-this.long0)-Math.PI)<=v&&Math.abs(i+this.lat0)<=v?(e.x=NaN,e.y=NaN,e):this.sphere?(n=2*this.k0/(1+this.sinlat0*s+this.coslat0*r*Math.cos(u)),e.x=this.a*n*r*Math.sin(u)+this.x0,e.y=this.a*n*(this.coslat0*s-this.sinlat0*r*Math.cos(u))+this.y0,e):(o=2*Math.atan(Pn(i,s,this.e))-x,h=Math.cos(o),a=Math.sin(o),Math.abs(this.coslat0)<=v?(c=ht(this.e,i*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)<v?(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 c1(e){e.x-=this.x0,e.y-=this.y0;var t,i,s,r,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,i=this.lat0,o<=v?(e.x=t,e.y=i,e):(i=Math.asin(Math.cos(a)*this.sinlat0+e.y*Math.sin(a)*this.coslat0/o),Math.abs(this.coslat0)<v?this.lat0>0?t=S(this.long0+Math.atan2(e.x,-1*e.y),this.over):t=S(this.long0+Math.atan2(e.x,e.y),this.over):t=S(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=i,e)}else if(Math.abs(this.coslat0)<=v){if(o<=v)return i=this.lat0,t=this.long0,e.x=t,e.y=i,e;e.x*=this.con,e.y*=this.con,s=o*this.cons/(2*this.a*this.k0),i=this.con*Wt(this.e,s),t=this.con*S(this.con*this.long0+Math.atan2(e.x,-1*e.y),this.over)}else r=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),t=this.long0,o<=v?n=this.X0:(n=Math.asin(Math.cos(r)*this.sinX0+e.y*Math.sin(r)*this.cosX0/o),t=S(this.long0+Math.atan2(e.x*Math.sin(r),o*this.cosX0*Math.cos(r)-e.y*this.sinX0*Math.sin(r)),this.over)),i=-1*Wt(this.e,Math.tan(.5*(x+n)));return e.x=t,e.y=i,e}var l1=["stere","Stereographic_South_Pole","Polar_Stereographic_variant_A","Polar_Stereographic_variant_B","Polar_Stereographic"],Fc={init:a1,forward:h1,inverse:c1,names:l1,ssfn_:Pn};function u1(){this.k0||(this.k0=1);var e=this.lat0;this.lambda0=this.long0;var t=Math.sin(e),i=this.a,s=this.rf,r=1/s,n=2*r-Math.pow(r,2),o=this.e=Math.sqrt(n);this.R=this.k0*i*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 f1(e){var t=Math.log(Math.tan(Math.PI/4-e.y/2)),i=this.e/2*Math.log((1+this.e*Math.sin(e.y))/(1-this.e*Math.sin(e.y))),s=-this.alpha*(t+i)+this.K,r=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(r)+Math.cos(this.b0)*Math.cos(n))),a=Math.asin(Math.cos(this.b0)*Math.sin(r)-Math.sin(this.b0)*Math.cos(r)*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 m1(e){for(var t=e.x-this.x0,i=e.y-this.y0,s=t/this.R,r=2*(Math.atan(Math.exp(i/this.R))-Math.PI/4),n=Math.asin(Math.cos(this.b0)*Math.sin(r)+Math.sin(this.b0)*Math.cos(r)*Math.cos(s)),o=Math.atan(Math.sin(s)/(Math.cos(this.b0)*Math.cos(s)-Math.sin(this.b0)*Math.tan(r))),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 d1=["somerc"],Uc={init:u1,forward:f1,inverse:m1,names:d1};var Le=1e-7;function p1(e){var t=["Hotine_Oblique_Mercator","Hotine_Oblique_Mercator_variant_A","Hotine_Oblique_Mercator_Azimuth_Natural_Origin"],i=typeof e.projName=="object"?Object.keys(e.projName)[0]:e.projName;return"no_uoff"in e||"no_off"in e||t.indexOf(i)!==-1||t.indexOf(dn(i))!==-1}function g1(){var e,t,i,s,r,n,o,a,h,c,l=0,u,f=0,d=0,m=0,g=0,_=0,M=0;this.k0||(this.k0=1),this.no_off=p1(this),this.no_rot="no_rot"in this;var y=!1;"alpha"in this&&(y=!0);var E=!1;if("rectified_grid_angle"in this&&(E=!0),y&&(M=this.alpha),E&&(l=this.rectified_grid_angle,y||(M=0,y=!0)),y||E)f=this.longc;else if(d=this.long1,g=this.lat1,m=this.long2,_=this.lat2,Math.abs(g-_)<=Le||(e=Math.abs(g))<=Le||Math.abs(e-x)<=Le||Math.abs(Math.abs(this.lat0)-x)<=Le||Math.abs(Math.abs(_)-x)<=Le)throw new Error;var w=1-this.es;t=Math.sqrt(w),Math.abs(this.lat0)>v?(a=Math.sin(this.lat0),i=Math.cos(this.lat0),e=1-this.es*a*a,this.B=i*i,this.B=Math.sqrt(1+this.es*this.B*this.B/w),this.A=this.B*this.k0*t/e,s=this.B*t/(i*Math.sqrt(e)),r=s*s-1,r<=0?r=0:(r=Math.sqrt(r),this.lat0<0&&(r=-r)),this.E=r+=s,this.E*=Math.pow(ht(this.e,this.lat0,a),this.B)):(this.B=1/t,this.A=this.k0,this.E=s=r=1),y||E?(y?(u=Math.asin(Math.sin(M)/s),E||(l=M)):(u=l,M=Math.asin(s*Math.sin(u))),this.lam0=f-Math.asin(.5*(r-1/r)*Math.tan(u))/this.B):(n=Math.pow(ht(this.e,g,Math.sin(g)),this.B),o=Math.pow(ht(this.e,_,Math.sin(_)),this.B),r=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-=Jt:e>Math.PI&&(m+=Jt),this.lam0=S(.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*S(d-this.lam0,this.over))/(r-1/r)),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)),r=.5*u,this.v_pole_n=this.ArB*Math.log(Math.tan(O-r)),this.v_pole_s=this.ArB*Math.log(Math.tan(O+r))}function _1(e){var t={},i,s,r,n,o,a,h,c;if(e.x=e.x-this.lam0,Math.abs(Math.abs(e.y)-x)>v){if(o=this.E/Math.pow(ht(this.e,e.y,Math.sin(e.y)),this.B),a=1/o,i=.5*(o-a),s=.5*(o+a),n=Math.sin(this.B*e.x),r=(i*this.singam-n*this.cosgam)/s,Math.abs(Math.abs(r)-1)<v)throw new Error;c=.5*this.ArB*Math.log((1-r)/(1+r)),a=Math.cos(this.B*e.x),Math.abs(a)<Le?h=this.A*e.x:h=this.ArB*Math.atan2(i*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 M1(e){var t,i,s,r,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?(i=e.y,t=e.x):(i=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*i),r=.5*(s-1/s),n=.5*(s+1/s),o=Math.sin(this.BrA*t),a=(o*this.cosgam+r*this.singam)/n,Math.abs(Math.abs(a)-1)<v)h.x=0,h.y=a<0?-x:x;else{if(h.y=this.E/Math.sqrt((1+a)/(1-a)),h.y=Wt(this.e,Math.pow(h.y,1/this.B)),h.y===1/0)throw new Error;h.x=-this.rB*Math.atan2(r*this.cosgam-o*this.singam,Math.cos(this.BrA*t))}return h.x+=this.lam0,h}var x1=["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"],Vc={init:g1,forward:_1,inverse:M1,names:x1};function y1(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,!(Math.abs(this.lat1+this.lat2)<v)){var e=this.b/this.a;this.e=Math.sqrt(1-e*e);var t=Math.sin(this.lat1),i=Math.cos(this.lat1),s=rt(this.e,t,i),r=ht(this.e,this.lat1,t),n=Math.sin(this.lat2),o=Math.cos(this.lat2),a=rt(this.e,n,o),h=ht(this.e,this.lat2,n),c=ht(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>v?this.ns=Math.log(s/a)/Math.log(r/h):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=s/(this.ns*Math.pow(r,this.ns)),this.rh=Math.abs(Math.abs(this.lat0)-x)<v?0:this.a*this.f0*Math.pow(c,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function S1(e){var t=e.x,i=e.y;Math.abs(2*Math.abs(i)-Math.PI)<=v&&(i=zt(i)*(x-2*v));var s=Math.abs(Math.abs(i)-x),r,n;if(s>v)r=ht(this.e,i,Math.sin(i)),n=this.a*this.f0*Math.pow(r,this.ns);else{if(s=i*this.ns,s<=0)return null;n=0}var o=this.ns*S(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 v1(e){var t,i,s,r,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),i=1):(t=-Math.sqrt(o*o+a*a),i=-1);var h=0;if(t!==0&&(h=Math.atan2(i*o,i*a)),t!==0||this.ns>0){if(i=1/this.ns,s=Math.pow(t/(this.a*this.f0),i),r=Wt(this.e,s),r===-9999)return null}else r=-x;return n=S(h/this.ns+this.long0,this.over),e.x=n,e.y=r,e}var E1=["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)"],kc={init:y1,forward:S1,inverse:v1,names:E1};function w1(){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 T1(e){var t,i,s,r,n,o,a,h=e.x,c=e.y,l=S(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),i=2*(Math.atan(this.k*Math.pow(Math.tan(c/2+this.s45),this.alfa)/t)-this.s45),s=-l*this.alfa,r=Math.asin(Math.cos(this.ad)*Math.sin(i)+Math.sin(this.ad)*Math.cos(i)*Math.cos(s)),n=Math.asin(Math.cos(i)*Math.sin(s)/Math.cos(r)),o=this.n*n,a=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(r/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 P1(e){var t,i,s,r,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),r=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(r)),i=Math.asin(Math.cos(s)*Math.sin(r)/Math.cos(t)),e.x=this.long0-i/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 b1=["Krovak","Krovak Modified","Krovak (North Orientated)","Krovak Modified (North Orientated)","krovak"],jc={init:w1,forward:T1,inverse:P1,names:b1};function $(e,t,i,s,r){return e*r-t*Math.sin(2*r)+i*Math.sin(4*r)-s*Math.sin(6*r)}function Ht(e){return 1-.25*e*(1+e/16*(3+1.25*e))}function Yt(e){return .375*e*(1+.25*e*(1+.46875*e))}function Zt(e){return .05859375*e*e*(1+.75*e)}function Xt(e){return e*e*e*(35/3072)}function fi(e,t,i){var s=t*i;return e/Math.sqrt(1-s*s)}function ft(e){return Math.abs(e)<x?e:e-zt(e)*Math.PI}function he(e,t,i,s,r){var n,o;n=e/t;for(var a=0;a<15;a++)if(o=(e-(t*n-i*Math.sin(2*n)+s*Math.sin(4*n)-r*Math.sin(6*n)))/(t-2*i*Math.cos(2*n)+4*s*Math.cos(4*n)-6*r*Math.cos(6*n)),n+=o,Math.abs(o)<=1e-10)return n;return NaN}function R1(){this.sphere||(this.e0=Ht(this.es),this.e1=Yt(this.es),this.e2=Zt(this.es),this.e3=Xt(this.es),this.ml0=this.a*$(this.e0,this.e1,this.e2,this.e3,this.lat0))}function C1(e){var t,i,s=e.x,r=e.y;if(s=S(s-this.long0,this.over),this.sphere)t=this.a*Math.asin(Math.cos(r)*Math.sin(s)),i=this.a*(Math.atan2(Math.tan(r),Math.cos(s))-this.lat0);else{var n=Math.sin(r),o=Math.cos(r),a=fi(this.a,this.e,n),h=Math.tan(r)*Math.tan(r),c=s*Math.cos(r),l=c*c,u=this.es*o*o/(1-this.es),f=this.a*$(this.e0,this.e1,this.e2,this.e3,r);t=a*c*(1-l*h*(1/6-(8-h+8*u)*l/120)),i=f-this.ml0+a*n/o*l*(.5+(5-h+6*u)*l/24)}return e.x=t+this.x0,e.y=i+this.y0,e}function A1(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,i=e.y/this.a,s,r;if(this.sphere){var n=i+this.lat0;s=Math.asin(Math.sin(n)*Math.cos(t)),r=Math.atan2(Math.tan(t),Math.cos(n))}else{var o=this.ml0/this.a+i,a=he(o,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(a)-x)<=v)return e.x=this.long0,e.y=x,i<0&&(e.y*=-1),e;var h=fi(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),r=u*(1-f*(l/3+(1+3*l)*l*f/15))/Math.cos(a)}return e.x=S(r+this.long0,this.over),e.y=ft(s),e}var I1=["Cassini","Cassini_Soldner","cass"],Wc={init:R1,forward:C1,inverse:A1,names:I1};function mt(e,t){var i;return e>1e-7?(i=e*t,(1-e*e)*(t/(1-i*i)-.5/e*Math.log((1-i)/(1+i)))):2*t}var O1=.3333333333333333,N1=.17222222222222222,L1=.10257936507936508,G1=.06388888888888888,z1=.0664021164021164,q1=.016415012942191543;function mi(e){var t,i=[];return i[0]=e*O1,t=e*e,i[0]+=t*N1,i[1]=t*G1,t*=e,i[0]+=t*L1,i[1]+=t*z1,i[2]=t*q1,i}function di(e,t){var i=e+e;return e+t[0]*Math.sin(i)+t[1]*Math.sin(i+i)+t[2]*Math.sin(i+i+i)}var bn=1,Rn=2,Cn=3,Vs=4;function B1(){var e=Math.abs(this.lat0);if(Math.abs(e-x)<v?this.mode=this.lat0<0?bn:Rn:Math.abs(e)<v?this.mode=Cn:this.mode=Vs,this.es>0){var t;switch(this.qp=mt(this.e,1),this.mmf=.5/(1-this.es),this.apa=mi(this.es),this.mode){case Rn:this.dd=1;break;case bn:this.dd=1;break;case Cn:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case Vs:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=mt(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===Vs&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function D1(e){var t,i,s,r,n,o,a,h,c,l,u=e.x,f=e.y;if(u=S(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(i=this.mode===this.EQUIT?1+l*s:1+this.sinph0*n+this.cosph0*l*s,i<=v)return null;i=Math.sqrt(2/i),t=i*l*Math.sin(u),i*=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)<v)return null;i=O-f*.5,i=2*(this.mode===this.S_POLE?Math.cos(i):Math.sin(i)),t=i*Math.sin(u),i*=s}}else{switch(a=0,h=0,c=0,s=Math.cos(u),r=Math.sin(u),n=Math.sin(f),o=mt(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=x+f,o=this.qp-o;break;case this.S_POLE:c=f-x,o=this.qp+o;break}if(Math.abs(c)<v)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:c=Math.sqrt(2/c),this.mode===this.OBLIQ?i=this.ymf*c*(this.cosb1*a-this.sinb1*h*s):i=(c=Math.sqrt(2/(1+h*s)))*a*this.ymf,t=this.xmf*c*h*r;break;case this.N_POLE:case this.S_POLE:o>=0?(t=(c=Math.sqrt(o))*r,i=s*(this.mode===this.S_POLE?c:-c)):t=i=0;break}}return e.x=this.a*t+this.x0,e.y=this.a*i+this.y0,e}function F1(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,i=e.y/this.a,s,r,n,o,a,h,c;if(this.sphere){var l=0,u,f=0;if(u=Math.sqrt(t*t+i*i),r=u*.5,r>1)return null;switch(r=2*Math.asin(r),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(f=Math.sin(r),l=Math.cos(r)),this.mode){case this.EQUIT:r=Math.abs(u)<=v?0:Math.asin(i*f/u),t*=f,i=l*u;break;case this.OBLIQ:r=Math.abs(u)<=v?this.lat0:Math.asin(l*this.sinph0+i*f*this.cosph0/u),t*=f*this.cosph0,i=(l-Math.sin(r)*this.sinph0)*u;break;case this.N_POLE:i=-i,r=x-r;break;case this.S_POLE:r-=x;break}s=i===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(t,i)}else{if(c=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(t/=this.dd,i*=this.dd,h=Math.sqrt(t*t+i*i),h<v)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+i*o*this.cosb1/h,a=this.qp*c,i=h*this.cosb1*n-i*this.sinb1*o):(c=i*o/h,a=this.qp*c,i=h*n)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(i=-i),a=t*t+i*i,!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,i),r=di(Math.asin(c),this.apa)}return e.x=S(this.long0+s,this.over),e.y=r,e}var U1=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],Hc={init:B1,forward:D1,inverse:F1,names:U1,S_POLE:bn,N_POLE:Rn,EQUIT:Cn,OBLIQ:Vs};function dt(e){return Math.abs(e)>1&&(e=e>1?1:-1),Math.asin(e)}function V1(){Math.abs(this.lat1+this.lat2)<v||(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=rt(this.e3,this.sin_po,this.cos_po),this.qs1=mt(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=rt(this.e3,this.sin_po,this.cos_po),this.qs2=mt(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=mt(this.e3,this.sin_po),Math.abs(this.lat1-this.lat2)>v?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 k1(e){var t=e.x,i=e.y;this.sin_phi=Math.sin(i),this.cos_phi=Math.cos(i);var s=mt(this.e3,this.sin_phi),r=this.a*Math.sqrt(this.c-this.ns0*s)/this.ns0,n=this.ns0*S(t-this.long0,this.over),o=r*Math.sin(n)+this.x0,a=this.rh-r*Math.cos(n)+this.y0;return e.x=o,e.y=a,e}function j1(e){var t,i,s,r,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),r=0,t!==0&&(r=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)):(i=(this.c-s*s)/this.ns0,o=this.phi1z(this.e3,i)),n=S(r/this.ns0+this.long0,this.over),e.x=n,e.y=o,e}function W1(e,t){var i,s,r,n,o,a=dt(.5*t);if(e<v)return a;for(var h=e*e,c=1;c<=25;c++)if(i=Math.sin(a),s=Math.cos(a),r=e*i,n=1-r*r,o=.5*n*n/s*(t/(1-h)-i/n+.5/e*Math.log((1-r)/(1+r))),a=a+o,Math.abs(o)<=1e-7)return a;return null}var H1=["Albers_Conic_Equal_Area","Albers_Equal_Area","Albers","aea"],Yc={init:V1,forward:k1,inverse:j1,names:H1,phi1z:W1};function Y1(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function Z1(e){var t,i,s,r,n,o,a,h,c=e.x,l=e.y;return s=S(c-this.long0,this.over),t=Math.sin(l),i=Math.cos(l),r=Math.cos(s),o=this.sin_p14*t+this.cos_p14*i*r,n=1,o>0||Math.abs(o)<=v?(a=this.x0+this.a*n*i*Math.sin(s)/o,h=this.y0+this.a*n*(this.cos_p14*t-this.sin_p14*i*r)/o):(a=this.x0+this.infinity_dist*i*Math.sin(s),h=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*i*r)),e.x=a,e.y=h,e}function X1(e){var t,i,s,r,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))?(r=Math.atan2(t,this.rc),i=Math.sin(r),s=Math.cos(r),o=dt(s*this.sin_p14+e.y*i*this.cos_p14/t),n=Math.atan2(e.x*i,t*this.cos_p14*s-e.y*this.sin_p14*i),n=S(this.long0+n,this.over)):(o=this.phic0,n=0),e.x=n,e.y=o,e}var $1=["gnom"],Zc={init:Y1,forward:Z1,inverse:X1,names:$1};function Xc(e,t){var i=1-(1-e*e)/(2*e)*Math.log((1-e)/(1+e));if(Math.abs(Math.abs(t)-i)<1e-6)return t<0?-1*x:x;for(var s=Math.asin(.5*t),r,n,o,a,h=0;h<30;h++)if(n=Math.sin(s),o=Math.cos(s),a=e*n,r=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+=r,Math.abs(r)<=1e-10)return s;return NaN}function Q1(){this.sphere||(this.k0=rt(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function K1(e){var t=e.x,i=e.y,s,r,n=S(t-this.long0,this.over);if(this.sphere)s=this.x0+this.a*n*Math.cos(this.lat_ts),r=this.y0+this.a*Math.sin(i)/Math.cos(this.lat_ts);else{var o=mt(this.e,Math.sin(i));s=this.x0+this.a*this.k0*n,r=this.y0+this.a*o*.5/this.k0}return e.x=s,e.y=r,e}function J1(e){e.x-=this.x0,e.y-=this.y0;var t,i;return this.sphere?(t=S(this.long0+e.x/this.a/Math.cos(this.lat_ts),this.over),i=Math.asin(e.y/this.a*Math.cos(this.lat_ts))):(i=Xc(this.e,2*e.y*this.k0/this.a),t=S(this.long0+e.x/(this.a*this.k0),this.over)),e.x=t,e.y=i,e}var tp=["cea"],$c={init:Q1,forward:K1,inverse:J1,names:tp};function ep(){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 ip(e){var t=e.x,i=e.y,s=S(t-this.long0,this.over),r=ft(i-this.lat0);return e.x=this.x0+this.a*s*this.rc,e.y=this.y0+this.a*r,e}function sp(e){var t=e.x,i=e.y;return e.x=S(this.long0+(t-this.x0)/(this.a*this.rc),this.over),e.y=ft(this.lat0+(i-this.y0)/this.a),e}var rp=["Equirectangular","Equidistant_Cylindrical","Equidistant_Cylindrical_Spherical","eqc"],Qc={init:ep,forward:ip,inverse:sp,names:rp};var Kc=20;function np(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Ht(this.es),this.e1=Yt(this.es),this.e2=Zt(this.es),this.e3=Xt(this.es),this.ml0=this.a*$(this.e0,this.e1,this.e2,this.e3,this.lat0)}function op(e){var t=e.x,i=e.y,s,r,n,o=S(t-this.long0,this.over);if(n=o*Math.sin(i),this.sphere)Math.abs(i)<=v?(s=this.a*o,r=-1*this.a*this.lat0):(s=this.a*Math.sin(n)/Math.tan(i),r=this.a*(ft(i-this.lat0)+(1-Math.cos(n))/Math.tan(i)));else if(Math.abs(i)<=v)s=this.a*o,r=-1*this.ml0;else{var a=fi(this.a,this.e,Math.sin(i))/Math.tan(i);s=a*Math.sin(n),r=this.a*$(this.e0,this.e1,this.e2,this.e3,i)-this.ml0+a*(1-Math.cos(n))}return e.x=s+this.x0,e.y=r+this.y0,e}function ap(e){var t,i,s,r,n,o,a,h,c;if(s=e.x-this.x0,r=e.y-this.y0,this.sphere)if(Math.abs(r+this.a*this.lat0)<=v)t=S(s/this.a+this.long0,this.over),i=0;else{o=this.lat0+r/this.a,a=s*s/this.a/this.a+o*o,h=o;var l;for(n=Kc;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)<=v){i=h;break}t=S(this.long0+Math.asin(s*Math.tan(h)/this.a)/Math.sin(i),this.over)}else if(Math.abs(r+this.ml0)<=v)i=0,t=S(this.long0+s/this.a,this.over);else{o=(this.ml0+r)/this.a,a=s*s/this.a/this.a+o*o,h=o;var u,f,d,m,g;for(n=Kc;n;--n)if(g=this.e*Math.sin(h),u=Math.sqrt(1-g*g)*Math.tan(h),f=this.a*$(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)<=v){i=h;break}u=Math.sqrt(1-this.es*Math.pow(Math.sin(i),2))*Math.tan(i),t=S(this.long0+Math.asin(s*u/this.a)/Math.sin(i),this.over)}return e.x=t,e.y=i,e}var hp=["Polyconic","American_Polyconic","poly"],Jc={init:np,forward:op,inverse:ap,names:hp};var cp=1;function lp(){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 up(e){var t,i=e.x,s=e.y,r=s-this.lat0,n=i-this.long0,o=r/re*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,_=0,M=0;for(t=1;t<=6;t++)m=f*l-d*u,g=d*l+f*u,f=m,d=g,_=_+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=_*this.a+this.y0,e}function fp(e){var t,i=e.x,s=e.y,r=i-this.x0,n=s-this.y0,o=n/this.a,a=r/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,_=d,M,y,E=o,w=a;for(t=2;t<=6;t++)M=g*f-_*d,y=_*f+g*d,g=M,_=y,E=E+(t-1)*(this.B_re[t]*g-this.B_im[t]*_),w=w+(t-1)*(this.B_im[t]*g+this.B_re[t]*_);g=1,_=0;var T=this.B_re[1],P=this.B_im[1];for(t=2;t<=6;t++)M=g*f-_*d,y=_*f+g*d,g=M,_=y,T=T+t*(this.B_re[t]*g-this.B_im[t]*_),P=P+t*(this.B_im[t]*g+this.B_re[t]*_);var R=T*T+P*P;f=(E*T+w*P)/R,d=(w*T-E*P)/R}var A=f,C=d,G=1,L=0;for(t=1;t<=9;t++)G=G*A,L=L+this.D[t]*G;var D=this.lat0+L*re*1e5,H=this.long0+C;return e.x=H,e.y=D,e}var mp=["New_Zealand_Map_Grid","nzmg"],tl={init:lp,forward:up,inverse:fp,names:mp,iterations:cp};function dp(){}function pp(e){var t=e.x,i=e.y,s=S(t-this.long0,this.over),r=this.x0+this.a*s,n=this.y0+this.a*Math.log(Math.tan(Math.PI/4+i/2.5))*1.25;return e.x=r,e.y=n,e}function gp(e){e.x-=this.x0,e.y-=this.y0;var t=S(this.long0+e.x/this.a,this.over),i=2.5*(Math.atan(Math.exp(.8*e.y/this.a))-Math.PI/4);return e.x=t,e.y=i,e}var _p=["Miller_Cylindrical","mill"],el={init:dp,forward:pp,inverse:gp,names:_p};var Mp=20;function xp(){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=Ae(this.es)}function An(e){var t,i,s=e.x,r=e.y;if(s=S(s-this.long0,this.over),this.sphere){if(!this.m)r=this.n!==1?Math.asin(this.n*Math.sin(r)):r;else for(var n=this.n*Math.sin(r),o=Mp;o;--o){var a=(this.m*r+Math.sin(r)-n)/(this.m+Math.cos(r));if(r-=a,Math.abs(a)<v)break}t=this.a*this.C_x*s*(this.m+Math.cos(r)),i=this.a*this.C_y*r}else{var h=Math.sin(r),c=Math.cos(r);i=this.a*qt(r,h,c,this.en),t=this.a*s*c/Math.sqrt(1-this.es*h*h)}return e.x=t,e.y=i,e}function In(e){var t,i,s,r;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=dt((this.m*t+Math.sin(t))/this.n):this.n!==1&&(t=dt(Math.sin(t)/this.n)),s=S(s+this.long0,this.over),t=ft(t)):(t=Ie(e.y/this.a,this.es,this.en),r=Math.abs(t),r<x?(r=Math.sin(t),i=this.long0+e.x*Math.sqrt(1-this.es*r*r)/(this.a*Math.cos(t)),s=S(i,this.over)):r-v<x&&(s=this.long0)),e.x=s,e.y=t,e}var yp=["Sinusoidal","sinu"],il={init:xp,forward:An,inverse:In,names:yp};function Sp(){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 vp=An,Ep=In,wp=["Eckert_VI","eck6"],sl={init:Sp,forward:vp,inverse:Ep,names:wp};function Tp(){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 Pp(e){for(var t=e.x,i=e.y,s=S(t-this.long0,this.over),r=i,n=Math.PI*Math.sin(i);;){var o=-(r+Math.sin(r)-n)/(1+Math.cos(r));if(r+=o,Math.abs(o)<v)break}r/=2,Math.PI/2-Math.abs(i)<v&&(s=0);var a=.900316316158*this.a*s*Math.cos(r)+this.x0,h=1.4142135623731*this.a*Math.sin(r)+this.y0;return e.x=a,e.y=h,e}function bp(e){var t,i;e.x-=this.x0,e.y-=this.y0,i=e.y/(1.4142135623731*this.a),Math.abs(i)>.999999999999&&(i=.999999999999),t=Math.asin(i);var s=S(this.long0+e.x/(.900316316158*this.a*Math.cos(t)),this.over);s<-Math.PI&&(s=-Math.PI),s>Math.PI&&(s=Math.PI),i=(2*t+Math.sin(2*t))/Math.PI,Math.abs(i)>1&&(i=1);var r=Math.asin(i);return e.x=s,e.y=r,e}var Rp=["Mollweide","moll"],rl={init:Tp,forward:Pp,inverse:bp,names:Rp};function Cp(){Math.abs(this.lat1+this.lat2)<v||(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=Ht(this.es),this.e1=Yt(this.es),this.e2=Zt(this.es),this.e3=Xt(this.es),this.sin_phi=Math.sin(this.lat1),this.cos_phi=Math.cos(this.lat1),this.ms1=rt(this.e,this.sin_phi,this.cos_phi),this.ml1=$(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<v?this.ns=this.sin_phi:(this.sin_phi=Math.sin(this.lat2),this.cos_phi=Math.cos(this.lat2),this.ms2=rt(this.e,this.sin_phi,this.cos_phi),this.ml2=$(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=$(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))}function Ap(e){var t=e.x,i=e.y,s;if(this.sphere)s=this.a*(this.g-i);else{var r=$(this.e0,this.e1,this.e2,this.e3,i);s=this.a*(this.g-r)}var n=this.ns*S(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 Ip(e){e.x-=this.x0,e.y=this.rh-e.y+this.y0;var t,i,s,r;this.ns>=0?(i=Math.sqrt(e.x*e.x+e.y*e.y),t=1):(i=-Math.sqrt(e.x*e.x+e.y*e.y),t=-1);var n=0;if(i!==0&&(n=Math.atan2(t*e.x,t*e.y)),this.sphere)return r=S(this.long0+n/this.ns,this.over),s=ft(this.g-i/this.a),e.x=r,e.y=s,e;var o=this.g-i/this.a;return s=he(o,this.e0,this.e1,this.e2,this.e3),r=S(this.long0+n/this.ns,this.over),e.x=r,e.y=s,e}var Op=["Equidistant_Conic","eqdc"],nl={init:Cp,forward:Ap,inverse:Ip,names:Op};function Np(){this.R=this.a}function Lp(e){var t=e.x,i=e.y,s=S(t-this.long0,this.over),r,n;if(Math.abs(i)<=v)return r=this.x0+this.R*s,n=this.y0,e.x=r,e.y=n,e;var o=dt(2*Math.abs(i/Math.PI));if(Math.abs(s)<=v||Math.abs(Math.abs(i)-x)<=v)return r=this.x0,i>=0?n=this.y0+Math.PI*this.R*Math.tan(.5*o):n=this.y0+Math.PI*this.R*-Math.tan(.5*o),e.x=r,e.y=n,e;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),r=this.x0+g;var _=h+u;return g=Math.PI*this.R*(d*_-a*Math.sqrt((m+h)*(h+1)-_*_))/(m+h),i>=0?n=this.y0+g:n=this.y0-g,e.x=r,e.y=n,e}function Gp(e){var t,i,s,r,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,r=e.y/u,n=s*s+r*r,o=-Math.abs(r)*(1+n),a=o-2*r*r+s*s,h=-2*o+1+2*r*r+n*n,d=r*r/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?i=(-l*Math.cos(f+Math.PI/3)-a/3/h)*Math.PI:i=-(-l*Math.cos(f+Math.PI/3)-a/3/h)*Math.PI,Math.abs(s)<v?t=this.long0:t=S(this.long0+Math.PI*(n-1+Math.sqrt(1+2*(s*s-r*r)+n*n))/2/s,this.over),e.x=t,e.y=i,e}var zp=["Van_der_Grinten_I","VanDerGrinten","Van_der_Grinten","vandg"],ol={init:Np,forward:Lp,inverse:Gp,names:zp};function al(e,t,i,s,r,n){let o=s-t,a=Math.atan((1-n)*Math.tan(e)),h=Math.atan((1-n)*Math.tan(i)),c=Math.sin(a),l=Math.cos(a),u=Math.sin(h),f=Math.cos(h),d=o,m,g=100,_,M,y,E,w,T,P,R,A,C,G,L,D,H;do{if(_=Math.sin(d),M=Math.cos(d),y=Math.sqrt(f*_*(f*_)+(l*u-c*f*M)*(l*u-c*f*M)),y===0)return{azi1:0,s12:0};E=c*u+l*f*M,w=Math.atan2(y,E),T=l*f*_/y,P=1-T*T,R=P!==0?E-2*c*u/P:0,A=n/16*P*(4+n*(4-3*P)),m=d,d=o+(1-A)*n*T*(w+A*y*(R+A*E*(-1+2*R*R)))}while(Math.abs(d-m)>1e-12&&--g>0);return g===0?{azi1:NaN,s12:NaN}:(C=P*(r*r-r*(1-n)*(r*(1-n)))/(r*(1-n)*(r*(1-n))),G=1+C/16384*(4096+C*(-768+C*(320-175*C))),L=C/1024*(256+C*(-128+C*(74-47*C))),D=L*y*(R+L/4*(E*(-1+2*R*R)-L/6*R*(-3+4*y*y)*(-3+4*R*R))),H=r*(1-n)*G*(w-D),{azi1:Math.atan2(f*_,l*u-c*f*M),s12:H})}function hl(e,t,i,s,r,n){let o=Math.atan((1-n)*Math.tan(e)),a=Math.sin(o),h=Math.cos(o),c=Math.sin(i),l=Math.cos(i),u=Math.atan2(a,h*l),f=h*c,d=1-f*f,m=d*(r*r-r*(1-n)*(r*(1-n)))/(r*(1-n)*(r*(1-n))),g=1+m/16384*(4096+m*(-768+m*(320-175*m))),_=m/1024*(256+m*(-128+m*(74-47*m))),M=s/(r*(1-n)*g),y,E=100,w,T,P,R;do w=Math.cos(2*u+M),T=Math.sin(M),P=Math.cos(M),R=_*T*(w+_/4*(P*(-1+2*w*w)-_/6*w*(-3+4*T*T)*(-3+4*w*w))),y=M,M=s/(r*(1-n)*g)+R;while(Math.abs(M-y)>1e-12&&--E>0);if(E===0)return{lat2:NaN,lon2:NaN};let A=a*T-h*P*l,C=Math.atan2(a*P+h*T*l,(1-n)*Math.sqrt(f*f+A*A)),G=Math.atan2(T*c,h*P-a*T*l),L=n/16*d*(4+n*(4-3*d)),D=G-(1-L)*n*f*(M+L*T*(w+L*P*(-1+2*w*w))),H=t+D;return{lat2:C,lon2:H}}function qp(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0),this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.f=this.es/(1+Math.sqrt(1-this.es))}function Bp(e){var t=e.x,i=e.y,s=Math.sin(e.y),r=Math.cos(e.y),n=S(t-this.long0,this.over),o,a,h,c,l,u,f,d,m,g,_;return this.sphere?Math.abs(this.sin_p12-1)<=v?(e.x=this.x0+this.a*(x-i)*Math.sin(n),e.y=this.y0-this.a*(x-i)*Math.cos(n),e):Math.abs(this.sin_p12+1)<=v?(e.x=this.x0+this.a*(x+i)*Math.sin(n),e.y=this.y0+this.a*(x+i)*Math.cos(n),e):(m=this.sin_p12*s+this.cos_p12*r*Math.cos(n),f=Math.acos(m),d=f?f/Math.sin(f):1,e.x=this.x0+this.a*d*r*Math.sin(n),e.y=this.y0+this.a*d*(this.cos_p12*s-this.sin_p12*r*Math.cos(n)),e):(o=Ht(this.es),a=Yt(this.es),h=Zt(this.es),c=Xt(this.es),Math.abs(this.sin_p12-1)<=v?(l=this.a*$(o,a,h,c,x),u=this.a*$(o,a,h,c,i),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)<=v?(l=this.a*$(o,a,h,c,x),u=this.a*$(o,a,h,c,i),e.x=this.x0+(l+u)*Math.sin(n),e.y=this.y0+(l+u)*Math.cos(n),e):Math.abs(t)<v&&Math.abs(i-this.lat0)<v?(e.x=this.x0,e.y=this.y0,e):(g=al(this.lat0,this.long0,i,t,this.a,this.f),_=g.azi1,e.x=this.x0+g.s12*Math.sin(_),e.y=this.y0+g.s12*Math.cos(_),e))}function Dp(e){e.x-=this.x0,e.y-=this.y0;var t,i,s,r,n,o,a,h,c,l,u,f,d,m,g,_;return this.sphere?(t=Math.sqrt(e.x*e.x+e.y*e.y),t>2*x*this.a?void 0:(i=t/this.a,s=Math.sin(i),r=Math.cos(i),n=this.long0,Math.abs(t)<=v?o=this.lat0:(o=dt(r*this.sin_p12+e.y*s*this.cos_p12/t),a=Math.abs(this.lat0)-x,Math.abs(a)<=v?this.lat0>=0?n=S(this.long0+Math.atan2(e.x,-e.y),this.over):n=S(this.long0-Math.atan2(-e.x,e.y),this.over):n=S(this.long0+Math.atan2(e.x*s,t*this.cos_p12*r-e.y*this.sin_p12*s),this.over)),e.x=n,e.y=o,e)):(h=Ht(this.es),c=Yt(this.es),l=Zt(this.es),u=Xt(this.es),Math.abs(this.sin_p12-1)<=v?(f=this.a*$(h,c,l,u,x),t=Math.sqrt(e.x*e.x+e.y*e.y),d=f-t,o=he(d/this.a,h,c,l,u),n=S(this.long0+Math.atan2(e.x,-1*e.y),this.over),e.x=n,e.y=o,e):Math.abs(this.sin_p12+1)<=v?(f=this.a*$(h,c,l,u,x),t=Math.sqrt(e.x*e.x+e.y*e.y),d=t-f,o=he(d/this.a,h,c,l,u),n=S(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),_=hl(this.lat0,this.long0,m,g,this.a,this.f),e.x=_.lon2,e.y=_.lat2,e))}var Fp=["Azimuthal_Equidistant","aeqd"],cl={init:qp,forward:Bp,inverse:Dp,names:Fp};function Up(){this.sin_p14=Math.sin(this.lat0||0),this.cos_p14=Math.cos(this.lat0||0)}function Vp(e){var t,i,s,r,n,o,a,h,c=e.x,l=e.y;return s=S(c-(this.long0||0),this.over),t=Math.sin(l),i=Math.cos(l),r=Math.cos(s),o=this.sin_p14*t+this.cos_p14*i*r,n=1,(o>0||Math.abs(o)<=v)&&(a=this.a*n*i*Math.sin(s),h=(this.y0||0)+this.a*n*(this.cos_p14*t-this.sin_p14*i*r)),e.x=a,e.y=h,e}function kp(e){var t,i,s,r,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),i=dt(t/this.a),s=Math.sin(i),r=Math.cos(i),h=this.long0||0,c=this.lat0||0,o=h,Math.abs(t)<=v?(a=c,e.x=o,e.y=a,e):(a=dt(r*this.sin_p14+e.y*s*this.cos_p14/t),n=Math.abs(c)-x,Math.abs(n)<=v?(c>=0?o=S(h+Math.atan2(e.x,-e.y),this.over):o=S(h-Math.atan2(-e.x,e.y),this.over),e.x=o,e.y=a,e):(o=S(h+Math.atan2(e.x*s,t*this.cos_p14*r-e.y*this.sin_p14*s),this.over),e.x=o,e.y=a,e))}var jp=["ortho"],ll={init:Up,forward:Vp,inverse:kp,names:jp};var W={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},z={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function Wp(){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>=x-O/2?this.face=W.TOP:this.lat0<=-(x-O/2)?this.face=W.BOTTOM:Math.abs(this.long0)<=O?this.face=W.FRONT:Math.abs(this.long0)<=x+O?this.face=this.long0>0?W.RIGHT:W.LEFT:this.face=W.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 Hp(e){var t={x:0,y:0},i,s,r,n,o,a,h={value:0};if(e.x-=this.long0,this.es!==0?i=Math.atan(this.one_minus_f_squared*Math.tan(e.y)):i=e.y,s=e.x,this.face===W.TOP)n=x-i,s>=O&&s<=x+O?(h.value=z.AREA_0,r=s-x):s>x+O||s<=-(x+O)?(h.value=z.AREA_1,r=s>0?s-j:s+j):s>-(x+O)&&s<=-O?(h.value=z.AREA_2,r=s+x):(h.value=z.AREA_3,r=s);else if(this.face===W.BOTTOM)n=x+i,s>=O&&s<=x+O?(h.value=z.AREA_0,r=-s+x):s<O&&s>=-O?(h.value=z.AREA_1,r=-s):s<-O&&s>=-(x+O)?(h.value=z.AREA_2,r=-s-x):(h.value=z.AREA_3,r=s>0?-s+j:-s-j);else{var c,l,u,f,d,m,g;this.face===W.RIGHT?s=Ge(s,+x):this.face===W.BACK?s=Ge(s,+j):this.face===W.LEFT&&(s=Ge(s,-x)),f=Math.sin(i),d=Math.cos(i),m=Math.sin(s),g=Math.cos(s),c=d*g,l=d*m,u=f,this.face===W.FRONT?(n=Math.acos(c),r=ks(n,u,l,h)):this.face===W.RIGHT?(n=Math.acos(l),r=ks(n,u,-c,h)):this.face===W.BACK?(n=Math.acos(-c),r=ks(n,u,-l,h)):this.face===W.LEFT?(n=Math.acos(-l),r=ks(n,u,c,h)):(n=r=0,h.value=z.AREA_0)}return a=Math.atan(12/j*(r+Math.acos(Math.sin(r)*Math.cos(O))-x)),o=Math.sqrt((1-Math.cos(n))/(Math.cos(a)*Math.cos(a))/(1-Math.cos(Math.atan(1/Math.cos(r))))),h.value===z.AREA_1?a+=x:h.value===z.AREA_2?a+=j:h.value===z.AREA_3&&(a+=1.5*j),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 Yp(e){var t={lam:0,phi:0},i,s,r,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)),i=Math.atan2(e.y,e.x),e.x>=0&&e.x>=Math.abs(e.y)?u.value=z.AREA_0:e.y>=0&&e.y>=Math.abs(e.x)?(u.value=z.AREA_1,i-=x):e.x<0&&-e.x>=Math.abs(e.y)?(u.value=z.AREA_2,i=i<0?i+j:i-j):(u.value=z.AREA_3,i+=x),l=j/12*Math.tan(i),o=Math.sin(l)/(Math.cos(l)-1/Math.sqrt(2)),a=Math.atan(o),r=Math.cos(i),n=Math.tan(s),h=1-r*r*n*n*(1-Math.cos(Math.atan(1/Math.cos(a)))),h<-1?h=-1:h>1&&(h=1),this.face===W.TOP)c=Math.acos(h),t.phi=x-c,u.value===z.AREA_0?t.lam=a+x:u.value===z.AREA_1?t.lam=a<0?a+j:a-j:u.value===z.AREA_2?t.lam=a-x:t.lam=a;else if(this.face===W.BOTTOM)c=Math.acos(h),t.phi=c-x,u.value===z.AREA_0?t.lam=-a+x:u.value===z.AREA_1?t.lam=-a:u.value===z.AREA_2?t.lam=-a-x:t.lam=a<0?-a-j:-a+j;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===z.AREA_1?(l=d,d=-m,m=l):u.value===z.AREA_2?(d=-d,m=-m):u.value===z.AREA_3&&(l=d,d=m,m=-l),this.face===W.RIGHT?(l=f,f=-d,d=l):this.face===W.BACK?(f=-f,d=-d):this.face===W.LEFT&&(l=f,f=d,d=-l),t.phi=Math.acos(-m)-x,t.lam=Math.atan2(d,f),this.face===W.RIGHT?t.lam=Ge(t.lam,-x):this.face===W.BACK?t.lam=Ge(t.lam,-j):this.face===W.LEFT&&(t.lam=Ge(t.lam,+x))}if(this.es!==0){var g,_,M;g=t.phi<0?1:0,_=Math.tan(t.phi),M=this.b/Math.sqrt(_*_+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 ks(e,t,i,s){var r;return e<v?(s.value=z.AREA_0,r=0):(r=Math.atan2(t,i),Math.abs(r)<=O?s.value=z.AREA_0:r>O&&r<=x+O?(s.value=z.AREA_1,r-=x):r>x+O||r<=-(x+O)?(s.value=z.AREA_2,r=r>=0?r-j:r+j):(s.value=z.AREA_3,r+=x)),r}function Ge(e,t){var i=e+t;return i<-j?i+=Jt:i>+j&&(i-=Jt),i}var Zp=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],ul={init:Wp,forward:Hp,inverse:Yp,names:Zp};var On=[[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]],pi=[[-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]],fl=.8487,ml=1.3523,dl=X/5,Xp=1/dl,ze=18,js=function(e,t){return e[0]+t*(e[1]+t*(e[2]+t*e[3]))},$p=function(e,t){return e[1]+t*(2*e[2]+t*3*e[3])};function Qp(e,t,i,s){for(var r=t;s;--s){var n=e(r);if(r-=n,Math.abs(n)<i)break}return r}function Kp(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function Jp(e){var t=S(e.x-this.long0,this.over),i=Math.abs(e.y),s=Math.floor(i*dl);s<0?s=0:s>=ze&&(s=ze-1),i=X*(i-Xp*s);var r={x:js(On[s],i)*t,y:js(pi[s],i)};return e.y<0&&(r.y=-r.y),r.x=r.x*this.a*fl+this.x0,r.y=r.y*this.a*ml+this.y0,r}function tg(e){var t={x:(e.x-this.x0)/(this.a*fl),y:Math.abs(e.y-this.y0)/(this.a*ml)};if(t.y>=1)t.x/=On[ze][0],t.y=e.y<0?-x:x;else{var i=Math.floor(t.y*ze);for(i<0?i=0:i>=ze&&(i=ze-1);;)if(pi[i][0]>t.y)--i;else if(pi[i+1][0]<=t.y)++i;else break;var s=pi[i],r=5*(t.y-s[0])/(pi[i+1][0]-s[0]);r=Qp(function(n){return(js(s,n)-t.y)/$p(s,n)},r,v,100),t.x/=js(On[i],r),t.y=(5*i+r)*B,e.y<0&&(t.y=-t.y)}return t.x=S(t.x+this.long0,this.over),t}var eg=["Robinson","robin"],pl={init:Kp,forward:Jp,inverse:tg,names:eg};function ig(){this.name="geocent"}function sg(e){var t=Ls(e,this.es,this.a);return t}function rg(e){var t=Gs(e,this.es,this.a,this.b);return t}var ng=["Geocentric","geocentric","geocent","Geocent"],gl={init:ig,forward:sg,inverse:rg,names:ng};var nt={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3},gi={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 og(){if(Object.keys(gi).forEach((function(i){if(typeof this[i]>"u")this[i]=gi[i].def;else{if(gi[i].num&&isNaN(this[i]))throw new Error("Invalid parameter value, must be numeric "+i+" = "+this[i]);gi[i].num&&(this[i]=parseFloat(this[i]))}gi[i].degrees&&(this[i]=this[i]*B)}).bind(this)),Math.abs(Math.abs(this.lat0)-x)<v?this.mode=this.lat0<0?nt.S_POLE:nt.N_POLE:Math.abs(this.lat0)<v?this.mode=nt.EQUIT:(this.mode=nt.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 ag(e){e.x-=this.long0;var t=Math.sin(e.y),i=Math.cos(e.y),s=Math.cos(e.x),r,n;switch(this.mode){case nt.OBLIQ:n=this.sinph0*t+this.cosph0*i*s;break;case nt.EQUIT:n=i*s;break;case nt.S_POLE:n=-t;break;case nt.N_POLE:n=t;break}switch(n=this.pn1/(this.p-n),r=n*i*Math.sin(e.x),this.mode){case nt.OBLIQ:n*=this.cosph0*t-this.sinph0*i*s;break;case nt.EQUIT:n*=t;break;case nt.N_POLE:n*=-(i*s);break;case nt.S_POLE:n*=i*s;break}var o,a;return o=n*this.cg+r*this.sg,a=1/(o*this.sw*this.h1+this.cw),r=(r*this.cg-n*this.sg)*this.cw*a,n=o*a,e.x=r*this.a,e.y=n*this.a,e}function hg(e){e.x/=this.a,e.y/=this.a;var t={x:e.x,y:e.y},i,s,r;r=1/(this.pn1-e.y*this.sw),i=this.pn1*e.x*r,s=this.pn1*e.y*this.cw*r,e.x=i*this.cg+s*this.sg,e.y=s*this.cg-i*this.sg;var n=Z(e.x,e.y);if(Math.abs(n)<v)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 nt.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 nt.EQUIT:t.y=Math.asin(e.y*a/n),e.y=o*n,e.x*=a;break;case nt.N_POLE:t.y=Math.asin(o),e.y=-e.y;break;case nt.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 cg=["Tilted_Perspective","tpers"],_l={init:og,forward:ag,inverse:hg,names:cg};function lg(){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 ug(e){var t=e.x,i=e.y,s,r,n,o;if(t=t-this.long0,this.shape==="ellipse"){i=Math.atan(this.radius_p2*Math.tan(i));var a=this.radius_p/Z(this.radius_p*Math.cos(i),Math.sin(i));if(r=a*Math.cos(t)*Math.cos(i),n=a*Math.sin(t)*Math.cos(i),o=a*Math.sin(i),(this.radius_g-r)*r-n*n-o*o*this.radius_p_inv2<0)return e.x=Number.NaN,e.y=Number.NaN,e;s=this.radius_g-r,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/Z(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/Z(n,s)))}else this.shape==="sphere"&&(s=Math.cos(i),r=Math.cos(t)*s,n=Math.sin(t)*s,o=Math.sin(i),s=this.radius_g-r,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/Z(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/Z(n,s))));return e.x=e.x*this.a,e.y=e.y*this.a,e}function fg(e){var t=-1,i=0,s=0,r,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),i=Math.tan(e.x/this.radius_g_1)*Z(1,s)):(i=Math.tan(e.x/this.radius_g_1),s=Math.tan(e.y/this.radius_g_1)*Z(1,i));var h=s/this.radius_p;if(r=i*i+h*h+t*t,n=2*this.radius_g*t,o=n*n-4*r*this.C,o<0)return e.x=Number.NaN,e.y=Number.NaN,e;a=(-n-Math.sqrt(o))/(2*r),t=this.radius_g+a*t,i*=a,s*=a,e.x=Math.atan2(i,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),i=Math.tan(e.x/this.radius_g_1)*Math.sqrt(1+s*s)):(i=Math.tan(e.x/this.radius_g_1),s=Math.tan(e.y/this.radius_g_1)*Math.sqrt(1+i*i)),r=i*i+s*s+t*t,n=2*this.radius_g*t,o=n*n-4*r*this.C,o<0)return e.x=Number.NaN,e.y=Number.NaN,e;a=(-n-Math.sqrt(o))/(2*r),t=this.radius_g+a*t,i*=a,s*=a,e.x=Math.atan2(i,t),e.y=Math.atan(s*Math.cos(e.x)/t)}return e.x=e.x+this.long0,e}var mg=["Geostationary Satellite View","Geostationary_Satellite","geos"],Ml={init:lg,forward:ug,inverse:fg,names:mg};var _i=1.340264,Mi=-.081106,xi=893e-6,yi=.003796,Ws=Math.sqrt(3)/2;function dg(){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=mi(this.es),this.qp=mt(this.e,1),this.rqda=Math.sqrt(.5*this.qp))}function pg(e){var t=S(e.x-this.long0,this.over),i=e.y,s=Math.sin(i);this.es!==0&&(s=mt(this.e,s)/this.qp);var r=Math.asin(Ws*s),n=r*r,o=n*n*n;return e.x=t*Math.cos(r)/(Ws*(_i+3*Mi*n+o*(7*xi+9*yi*n))),e.y=r*(_i+Mi*n+o*(xi+yi*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 gg(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,i=12,s=e.y,r,n,o,a,h,c;for(c=0;c<i&&(r=s*s,n=r*r*r,o=s*(_i+Mi*r+n*(xi+yi*r))-e.y,a=_i+3*Mi*r+n*(7*xi+9*yi*r),s-=h=o/a,!(Math.abs(h)<t));++c);return r=s*s,n=r*r*r,e.x=Ws*e.x*(_i+3*Mi*r+n*(7*xi+9*yi*r))/Math.cos(s),e.y=Math.asin(Math.sin(s)/Ws),this.es!==0&&(e.y=di(e.y,this.apa)),e.x=S(e.x+this.long0,this.over),e}var _g=["eqearth","Equal Earth","Equal_Earth"],xl={init:dg,forward:pg,inverse:gg,names:_g};var Si=1e-10;function Mg(){var e;if(this.phi1=this.lat1,Math.abs(this.phi1)<Si)throw new Error;this.es?(this.en=Ae(this.es),this.m1=qt(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=yg,this.forward=xg):(Math.abs(this.phi1)+Si>=x?this.cphi1=0:this.cphi1=1/Math.tan(this.phi1),this.inverse=vg,this.forward=Sg)}function xg(e){var t=S(e.x-(this.long0||0),this.over),i=e.y,s,r,n;return s=this.am1+this.m1-qt(i,r=Math.sin(i),n=Math.cos(i),this.en),r=n*t/(s*Math.sqrt(1-this.es*r*r)),e.x=s*Math.sin(r),e.y=this.am1-s*Math.cos(r),e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function yg(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,i,s,r;if(i=Z(e.x,e.y=this.am1-e.y),r=Ie(this.am1+this.m1-i,this.es,this.en),(t=Math.abs(r))<x)t=Math.sin(r),s=i*Math.atan2(e.x,e.y)*Math.sqrt(1-this.es*t*t)/Math.cos(r);else if(Math.abs(t-x)<=Si)s=0;else throw new Error;return e.x=S(s+(this.long0||0),this.over),e.y=ft(r),e}function Sg(e){var t=S(e.x-(this.long0||0),this.over),i=e.y,s,r;return r=this.cphi1+this.phi1-i,Math.abs(r)>Si?(e.x=r*Math.sin(s=t*Math.cos(i)/r),e.y=this.cphi1-r*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 vg(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,i,s=Z(e.x,e.y=this.cphi1-e.y);if(i=this.cphi1+this.phi1-s,Math.abs(i)>x)throw new Error;return Math.abs(Math.abs(i)-x)<=Si?t=0:t=s*Math.atan2(e.x,e.y)/Math.cos(i),e.x=S(t+(this.long0||0),this.over),e.y=ft(i),e}var Eg=["bonne","Bonne (Werner lat_1=90)"],yl={init:Mg,names:Eg};var Sl={OBLIQUE:{forward:Rg,inverse:Ag},TRANSVERSE:{forward:Cg,inverse:Ig}},Hs={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 wg(){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=mn.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=Ct(e);if(!t)throw new Error("Invalid parameter: o_proj. Unknown projection "+this.o_proj);t.long0=0,this.obliqueProjection=t;let i,s=Object.keys(Hs),r=a=>{if(typeof this[a]>"u")return;let h=parseFloat(this[a])*B;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=Hs[h],l=Object.entries(c);if(l.some(([f])=>typeof this[f]<"u")){i=c;for(let f=0;f<l.length;f++){let[d,m]=l[f],g=r(d);if(typeof g>"u")throw new Error("Missing parameter: "+d+".");this[m]=g}break}}if(!i)throw new Error("No valid parameters provided for ob_tran projection.");let{lamp:n,phip:o}=bg(this,i);this.lamp=n,Math.abs(o)>v?(this.cphip=Math.cos(o),this.sphip=Math.sin(o),this.projectionType=Sl.OBLIQUE):this.projectionType=Sl.TRANSVERSE}function Tg(e){return this.projectionType.forward(this,e)}function Pg(e){return this.projectionType.inverse(this,e)}function bg(e,t){let i,s;if(t===Hs.ROTATE){let r=e.oLongC,n=e.oLatC,o=e.oAlpha;if(Math.abs(Math.abs(n)-x)<=v)throw new Error("Invalid value for o_lat_c: "+e.o_lat_c+" should be < 90\xB0");s=r+Math.atan2(-1*Math.cos(o),-1*Math.sin(o)*Math.sin(n)),i=Math.asin(Math.cos(n)*Math.sin(o))}else if(t===Hs.NEW_POLE)s=e.oLongP,i=e.oLatP;else{let r=e.oLong1,n=e.oLat1,o=e.oLong2,a=e.oLat2,h=Math.abs(n);if(Math.abs(n)>x-v)throw new Error("Invalid value for o_lat_1: "+e.o_lat_1+" should be < 90\xB0");if(Math.abs(a)>x-v)throw new Error("Invalid value for o_lat_2: "+e.o_lat_2+" should be < 90\xB0");if(Math.abs(n-a)<v)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<v)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(r)-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(r)),i=Math.atan(-1*Math.cos(s-r)/Math.tan(n))}return{lamp:s,phip:i}}function Rg(e,t){let{x:i,y:s}=t;i=S(i-e.long0,e.over);let r=Math.cos(i),n=Math.sin(s),o=Math.cos(s);t.x=S(Math.atan2(o*Math.sin(i),e.sphip*o*r+e.cphip*n)+e.lamp),t.y=Math.asin(e.sphip*n-e.cphip*o*r);let a=e.obliqueProjection.forward(t);return e.isIdentity&&(a.x*=X,a.y*=X),a}function Cg(e,t){let{x:i,y:s}=t;i=S(i-e.long0,e.over);let r=Math.cos(s),n=Math.cos(i);t.x=S(Math.atan2(r*Math.sin(i),Math.sin(s))+e.lamp),t.y=Math.asin(-1*r*n);let o=e.obliqueProjection.forward(t);return e.isIdentity&&(o.x*=X,o.y*=X),o}function Ag(e,t){e.isIdentity&&(t.x*=B,t.y*=B);let i=e.obliqueProjection.inverse(t),{x:s,y:r}=i;if(s<Number.MAX_VALUE){s-=e.lamp;let n=Math.cos(s),o=Math.sin(r),a=Math.cos(r);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=S(t.x+e.long0),t}function Ig(e,t){e.isIdentity&&(t.x*=B,t.y*=B);let i=e.obliqueProjection.inverse(t),{x:s,y:r}=i;if(s<Number.MAX_VALUE){let n=Math.cos(r);s-=e.lamp,t.x=Math.atan2(n*Math.sin(s),-1*Math.sin(r)),t.y=Math.asin(n*Math.cos(s))}return t.x=S(t.x+e.long0),t}var Og=["General Oblique Transformation","General_Oblique_Transformation","ob_tran"],vl={init:wg,forward:Tg,inverse:Pg,names:Og};function El(e){e.Proj.projections.add(Oe),e.Proj.projections.add(Ne),e.Proj.projections.add(Bc),e.Proj.projections.add(Dc),e.Proj.projections.add(Fc),e.Proj.projections.add(Uc),e.Proj.projections.add(Vc),e.Proj.projections.add(kc),e.Proj.projections.add(jc),e.Proj.projections.add(Wc),e.Proj.projections.add(Hc),e.Proj.projections.add(Yc),e.Proj.projections.add(Zc),e.Proj.projections.add($c),e.Proj.projections.add(Qc),e.Proj.projections.add(Jc),e.Proj.projections.add(tl),e.Proj.projections.add(el),e.Proj.projections.add(il),e.Proj.projections.add(sl),e.Proj.projections.add(rl),e.Proj.projections.add(nl),e.Proj.projections.add(ol),e.Proj.projections.add(cl),e.Proj.projections.add(ll),e.Proj.projections.add(ul),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)}var wl=Object.assign(Sc,{defaultDatum:"WGS84",Proj:Ct,WGS84:new Ct("WGS84"),Point:Cc,toPoint:be,defs:we,nadgrid:Mn,transform:xn,mgrs:Pc,version:"__VERSION__"});El(wl);var Nn=wl;var Ln=Nn,Bt=class{static defineProjectionAliases(t){for(let i in t)Ln.defs(i,t[i])}static registerDatumGrid(t,i,s){Ln.nadgrid(t,i,s)}constructor({from:t="WGS84",to:i="WGS84",enforceAxis:s=!1}){if(this._projection=Ln(t,i),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 vi=class extends Error{constructor(t){super(t.message||"CRS is not compatible with proj4js"),this.name="Proj4CRSCompatibilityError",this.compatibility=t}};var Ng=new Set(["GeographicCRS","GeodeticCRS","ProjectedCRS","BoundCRS"]);function Lg(e){return typeof e=="object"&&e!==null}function Ys(e){return typeof e.type=="string"?e.type:void 0}function Pl(e){return Ng.has(e.type)}function bl(e){return Pl(e)?e.type!=="BoundCRS"||bl(e.source_crs):!1}function Tl(e,t,i,s=!1){return{status:"unsupported",checked:!1,lossy:s,type:e,reason:t,message:i}}function Gg(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(i=>bl(i));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 zg(e,t){if(!Lg(e))return{definition:e,lossy:!1};if(Pl(e))return{definition:e,lossy:!1,type:Ys(e)};if(t==="horizontal"&&e.type==="CompoundCRS"){let s=Gg(e);if("reason"in s)throw new vi(Tl(Ys(e),s.reason,s.message,!0));return{definition:s.definition,lossy:!0,type:Ys(e)}}let i=Ys(e);throw new vi(Tl(i,"unsupported-crs-type",i?`${i} is not supported by proj4js`:"CRS object has no supported type"))}function Gn(e,t){return zg(e,t?.mode||"strict").definition}var qg=[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],Bg=372,Dg=[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],Fg=372,Ug=[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],Vg=12,zn=20/2,kg=2,Ei=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,i){if(t=Math.abs(t)>90?NaN:t,Number.isNaN(t)||Number.isNaN(i))return NaN;let s=jg(i,360);i=s!==-180?s:180;let r=i*this.options._rlonres,n=-t*this.options._rlatres,o=Math.floor(r),a=Math.min(Math.round((this.options._height-1)/2-1),Math.floor(n));r-=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(zn);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=Dg;a!==0&&(g=a===this.options._height-2?Ug:qg);let _=Bg;a!==0&&(_=a===this.options._height-2?Fg:240);for(let M=0;M<zn;++M){f[M]=0;for(let y=0;y<Vg;++y)f[M]+=m[y]*g[zn*y+M];f[M]/=_}}if(!this.options.cubic){let m=(1-r)*h+r*c,g=(1-r)*l+r*u,_=(1-n)*m+n*g,M=this.options._offset+this.options._scale*_;return this._ix=o,this._iy=a,this._v00=h,this._v01=c,this._v10=l,this._v11=u,M}let d=f[0]+r*(f[1]+r*(f[3]+r*f[6]))+n*(f[2]+r*(f[4]+r*f[7])+n*(f[5]+r*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,i){t<0?t+=this.options._width:t>=this.options._width&&(t-=this.options._width),(i<0||i>=this.options._height)&&(i=i<0?-i:2*(this.options._height-1)-i,t+=(t<this.options._width/2?1:-1)*this.options._width/2);let s=this.options._datastart+kg*(i*this.options._swidth+t),r=this.options.data[s],n=this.options.data[s+1];return r<<8|n}};function jg(e,t){t=Math.abs(t);let i=Rl(e,t);return 2*Math.abs(i)===t?i-=Rl(e,2*t)-i:2*Math.abs(i)>t&&(i+=i<0?t:-t),i}function Rl(e,t){return e-Math.floor(e/t)*t}var Wg=10,Hg=65535;function qn(e,t){let i=Yg(e),s=i.next();if(s.done||s.value.line!=="P5")throw new Error("Geoid model file: File not in PGM format");let r=Number.MAX_VALUE,n=0,o=-1,a=-1,h="NONE",c="UNKNOWN",l=0,u=0,f=null,d=null;do{s=i.next();let M=s.value.line;if(M.length)if(M[0]==="#"){let y=M.split(" "),E=y[0],w=y[1];if(E!=="#"||!w)continue;let T=y.length>2?y.slice(2):[];if(w==="Description")h=T.join(" ");else if(w==="DateTime")c=T.join(" ");else if(w==="Offset"){if(!y[2])throw new Error("Geoid model file: Error reading offset");r=parseInt(y[2],10)}else if(w==="Scale"){if(!y[2])throw new Error("Geoid model file: Error reading scale");n=parseFloat(y[2])}else w===(t.cubic?"MaxCubicError":"MaxBilinearError")?isFinite(parseFloat(y[2]))&&(o=parseFloat(y[2])):w===(t.cubic?"RMSCubicError":"RMSBilinearError")&&isFinite(parseFloat(y[2]))&&(a=parseFloat(y[2]))}else{let y=M.split(" ");if(y=y.filter(E=>E!==""),l=parseInt(y[0],10),u=parseInt(y[1],10),!(l&&u))throw new Error("Geoid model file: Error reading raster size");break}}while(!s.done);s=i.next();let m=parseInt(s.value.line,10);if(s.done)throw new Error("Geoid model file: Error reading maxval");if(m!==Hg)throw new Error("Geoid model file: Incorrect value of maxval");if(f=s.value.offset,d=l,r===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,_=(u-1)/180;return new Ei({cubic:t.cubic,_width:l,_height:u,_rlonres:g,_rlatres:_,_offset:r,_scale:n,_swidth:d,_datastart:f,_maxerror:o,_rmserror:a,_description:h,_datetime:c,data:e})}function*Yg(e){let t=0;do{let i=e.indexOf(Wg,t);if(i!==-1){let s=e.subarray(t,i);t=i+1,yield{offset:t,line:Cl(s)}}else{let s=e.subarray(t,e.length);t=e.length,yield{offset:t,line:Cl(s)}}}while(t<e.length);return{offset:t,line:""}}function Cl(e){let t="";for(let i of e)t+=String.fromCharCode(i);return t}var Al=new Map;function Il(e,t){Dn(e,"CRS"),Bt.defineProjectionAliases({[e]:t})}function Ol(e,t){Dn(e,"datum grid"),Bt.registerDatumGrid(e,t)}function Bn(e,t){Dn(e,"geoid model"),Al.set(e,t)}function Nl(e,t,i={}){let s=qn(t,i);return Bn(e,s),s}function Zs(e){return Al.get(e)}function Dn(e,t){if(!e.trim())throw new Error(`${t} name must not be empty`)}var Fn="EPSG:4326",Zg="EPSG:4978",$t=class{spatialReference;horizontalProjection;geographicProjection;heightOutputProjection;sourceIsGeocentric;outputIsGeocentric;sourceIsGeographic;outputIsGeographic;geoid;constructor(t,i={}){this.spatialReference=t,Xg(t);let s=t.targetCrs||t.sourceCrs;if(this.sourceIsGeocentric=Un(t.sourceCrs),this.outputIsGeocentric=Un(s),this.sourceIsGeographic=Ll(t.sourceCrs),this.outputIsGeographic=Ll(s),t.sourceCrs&&t.targetCrs&&!this.sourceIsGeocentric&&!this.outputIsGeocentric&&(this.horizontalProjection=new Bt({from:Xs(t.sourceCrs),to:Xs(t.targetCrs),enforceAxis:!1})),(wi(t)||this.sourceIsGeocentric||this.outputIsGeocentric)&&(!this.sourceIsGeographic&&!this.sourceIsGeocentric&&(this.geographicProjection=new Bt({from:Xs(t.sourceCrs),to:Fn,enforceAxis:!1})),!this.outputIsGeographic&&!this.outputIsGeocentric&&(this.heightOutputProjection=new Bt({from:Fn,to:Xs(s),enforceAxis:!1}))),wi(t)&&(this.geoid=$g(i.geoidModel),!this.geoid)){let r=typeof i.geoidModel=="string"?` "${i.geoidModel}"`:"";throw new Error(`Height conversion requires a registered geoid model${r}; 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 i=[...t];if(wi(this.spatialReference)||this.sourceIsGeocentric||this.outputIsGeocentric){if(i.length<3||!Number.isFinite(i[2]))throw new Error("Three-dimensional CRS conversion requires a finite z coordinate");let s=this.toGeographic(i);if(wi(this.spatialReference)){let n=this.geoid.getHeight(s[1],s[0]);s[2]=Qg(s[2],n,this.spatialReference.heightReference,this.spatialReference.targetHeightReference)}let r=this.fromGeographic(s);return i.splice(0,r.length,...r),i}if(this.horizontalProjection){let s=this.horizontalProjection.project(i.slice(0,3));i.splice(0,s.length,...s)}return i}toGeographic(t){return this.sourceIsGeocentric?Array.from(b.WGS84.cartesianToCartographic(new p(t))):this.sourceIsGeographic?t.slice(0,3):this.geographicProjection.project(t.slice(0,3))}fromGeographic(t){return this.outputIsGeocentric?Array.from(b.WGS84.cartographicToCartesian(new p(t))):this.outputIsGeographic?t.slice(0,3):this.heightOutputProjection.project(t.slice(0,3))}};function Xs(e){if(!e)throw new Error("Cannot construct a projection because the CRS is unknown");return Gn(e,{mode:"horizontal"})}function Xg(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(wi(e)&&e.heightReference==="unknown")throw new Error("Cannot convert heights because the source height reference is unknown");if(e.coordinateFrame==="geocentric"&&!Un(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 Un(e){return typeof e=="string"&&Gl(e)===Zg}function Ll(e){if(typeof e!="string")return!1;let t=Gl(e);return t===Fn||t==="EPSG:4979"||t==="OGC:CRS84"}function Gl(e){let t=e.trim().toUpperCase(),i=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return i?`${i[1]}:${i[2]}`:t}function wi(e){let t=e.targetHeightReference;return t!=="native"&&t!==e.heightReference}function $g(e){return typeof e=="string"?Zs(e):e}function Qg(e,t,i,s){if(i===s||s==="native")return e;if(i==="orthometric"&&s==="ellipsoidal")return e+t;if(i==="ellipsoidal"&&s==="orthometric")return e-t;throw new Error(`Unsupported height conversion from ${i} to ${s}`)}var Be=class{spatialReference;targetCoordinateFrame;positionTransformer;sourceToGeographicTransformer;geographicToTargetTransformer;sourceCoordinateFrame;sourceVerticalUnitScale;elevationMode;elevationOffset;elevationProvider;providerUnitScale;providerHeightTransformer;constructor(t,i={}){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 $t(t,i),this.sourceCoordinateFrame=t.coordinateFrame,this.sourceVerticalUnitScale=t.verticalUnitScale,this.elevationMode=t.elevationMode,this.elevationOffset=(t.elevationOffset||0)*t.elevationUnitScale,this.elevationProvider=Kg(this.elevationMode,i),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 r=ri(this.elevationProvider?.unit||"meter");if(this.elevationProvider&&r===void 0)throw new Error(`Unsupported elevation-provider unit ${this.elevationProvider.unit}`);this.providerUnitScale=r||1,this.targetCoordinateFrame=Vt(s),this.spatialReference=ds(t);let n=vt({sourceCrs:t.sourceCrs,heightReference:t.heightReference,coordinateFrame:t.coordinateFrame,axisOrder:t.axisOrder,provenance:t.provenance},{targetCrs:"EPSG:4326"});if(this.sourceToGeographicTransformer=new $t(n),qe(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=vt({sourceCrs:"EPSG:4326",heightReference:a,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"caller-override"},{targetCrs:"EPSG:4326",targetHeightReference:t.heightReference,geoidModel:i.geoidModel});this.providerHeightTransformer=new $t(h,i)}}let o=vt({sourceCrs:"EPSG:4326",heightReference:t.heightReference,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"format-default"},{targetCrs:s,targetHeightReference:t.targetHeightReference,geoidModel:i.geoidModel});this.geographicToTargetTransformer=new $t(o,i)}transformPosition(t){let i=this.placeSourcePositionsSync(t),s=this.positionTransformer.transformPosition([i[0],i[1],i[2]]);return[s[0],s[1],s[2]]}async transformPositionAsync(t){let i=await this.placeSourcePositions(t),s=this.positionTransformer.transformPosition([i[0],i[1],i[2]]);return[s[0],s[1],s[2]]}transformPlacedPosition(t){let i=this.positionTransformer.transformPosition([t[0],t[1],t[2]]);return[i[0],i[1],i[2]]}transformSourcePositionToGeographic(t){let i=this.placeSourcePositionsSync(t),s=this.sourceToGeographicTransformer.transformPosition([i[0],i[1],i[2]]);return[s[0],s[1],s[2]]}async transformSourcePositionToGeographicAsync(t){let i=await this.placeSourcePositions(t),s=this.sourceToGeographicTransformer.transformPosition([i[0],i[1],i[2]]);return[s[0],s[1],s[2]]}transformPositions(t,i){let s=this.placeSourcePositionsSync(t),r=this.placeSourcePositionsSync(i);return this.transformPlacedPositions(s,r)}async transformPositionsAsync(t,i){let s=new Float64Array(t.length+3);s.set(Array.from(t),0),s.set(Array.from(i).slice(0,3),t.length);let r=await this.placeSourcePositions(s);return this.transformPlacedPositions(r.subarray(0,t.length),r.subarray(t.length))}transformPlacedPositions(t,i){let s=this.transformPlacedPosition(i),r=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]]);r[h]=c[0]-s[0],r[h+1]=c[1]-s[1],r[h+2]=c[2]-s[2]}let o=this.targetCoordinateFrame==="geographic",a=o?new I:new I().translate(s);return{positions:r,sourcePositions:n,origin:s,cartographicOrigin:o?s:[0,0,0],coordinateSystem:o?"lnglat-offsets":"cartesian",modelMatrix:a}}transformNormals(t,i,s="earth-centered"){let r=new Float32Array(t.length);for(let n=0;n<t.length;n+=3){let o=this.sourceToGeographicTransformer.transformPosition([i[n],i[n+1],i[n+2]]),a=new p([t[n],t[n+1],t[n+2]]).normalize(),h=s==="earth-centered"?a:Fl(a,o),c=this.transformEcefNormal(h,o);r.set(c,n)}return r}transformBoundingVolume(t){let s=this.getGeographicBoundSamples(t).map(r=>this.geographicToTargetTransformer.transformPosition(r));return this.targetCoordinateFrame==="geographic"?{region:ee(s)}:{box:ce(s)}}async transformBoundingVolumeAsync(t){let s=(await this.getGeographicBoundSamplesAsync(t)).map(r=>this.geographicToTargetTransformer.transformPosition(r));return this.targetCoordinateFrame==="geographic"?{region:ee(s)}:{box:ce(s)}}transformBoundingVolumeToGeographic(t){return{region:ee(this.getGeographicBoundSamples(t))}}async transformBoundingVolumeToGeographicAsync(t){return{region:ee(await this.getGeographicBoundSamplesAsync(t))}}transformBoundingVolumeToGeocentric(t){let i=this.getGeographicBoundSamples(t).map(s=>Array.from(b.WGS84.cartographicToCartesian(new p(s))));return{box:ce(i)}}async transformBoundingVolumeToGeocentricAsync(t){let i=(await this.getGeographicBoundSamplesAsync(t)).map(s=>Array.from(b.WGS84.cartographicToCartesian(new p(s))));return{box:ce(i)}}transformBoundingSphereToGeographic(t){let i=t.mbs?.length?Array.from(t.mbs).slice(0,3):t.obb?Array.from(t.obb.center).slice(0,3):null;if(!i)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let s=this.placeSourcePositionsSync(i),r=this.sourceToGeographicTransformer.transformPosition(Array.from(s)),n=t.mbs?.length?t.mbs[3]:Math.hypot(...Array.from(t.obb.halfSize).slice(0,3));return[r[0],r[1],r[2],n]}async transformBoundingSphereToGeographicAsync(t){return zl(await this.getGeographicBoundSamplesAsync(t))}async transformBoundsAsync(t){let i=await this.getGeographicBoundSamplesAsync(t),s=i.map(n=>Array.from(b.WGS84.cartographicToCartesian(new p(n)))),r=i.map(n=>this.geographicToTargetTransformer.transformPosition(n));return{boundingVolume:{box:ce(s)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ee(r)}:{box:ce(r)},i3sLodMbs:qe(this.elevationMode)?zl(i):this.transformBoundingSphereToGeographic(t)}}async transformPointCloudBoundsAsync(t){let i=await this.getGeographicBoundSamplesAsync(t),s=i.map(r=>this.geographicToTargetTransformer.transformPosition(r));return{boundingVolume:{region:ee(i)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ee(s)}:{box:ce(s)}}}getGeographicBoundSamples(t){let i=ql(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!i.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let s=this.placeSourcePositionsSync(i.flat(),!0),r=Vn(s);return this.sourceCoordinateFrame==="geographic"?r:r.map(n=>this.sourceToGeographicTransformer.transformPosition(n))}async getGeographicBoundSamplesAsync(t){let i=ql(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!i.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");if(qe(this.elevationMode)){let r=this.sourceCoordinateFrame==="geographic"?i:i.map(n=>this.sourceToGeographicTransformer.transformPosition(n));return await this.placeGeographicBoundSamples(r)}let s=Vn(await this.placeSourcePositions(i.flat(),!0));return this.sourceCoordinateFrame==="geographic"?s:s.map(r=>this.sourceToGeographicTransformer.transformPosition(r))}async placeGeographicBoundSamples(t){let s=await this.elevationProvider.getElevationRange(Jg(t)),r=s.minimum*this.providerUnitScale,n=s.maximum*this.providerUnitScale;if(!Number.isFinite(r)||!Number.isFinite(n)||r>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,r])[2]:r,d=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([l,u,n])[2]:n,m=Math.min(f,d),g=Math.max(f,d),_=this.elevationMode==="onTheGround"?m:m+a+this.elevationOffset,M=this.elevationMode==="onTheGround"?g:g+h+this.elevationOffset;c.push([l,u,_],[l,u,M])}return c}placeSourcePositionsSync(t,i=!1){if(qe(this.elevationMode))throw new Error(`I3S elevation mode ${this.elevationMode} requires asynchronous surface placement`);let s=Float64Array.from(t),r=this.elevationMode==="absoluteHeight"?this.elevationOffset:0;for(let n=2;n<s.length;n+=3)s[n]=s[n]*(i?1:this.sourceVerticalUnitScale)+r;return s}async placeSourcePositions(t,i=!1){if(!qe(this.elevationMode))return this.placeSourcePositionsSync(t,i);let s=Float64Array.from(t),r=Vn(s).map(o=>{let a=this.sourceToGeographicTransformer.transformPosition(o);return[a[0],a[1]]}),n=await this.elevationProvider.sampleElevations(r);if(n.length!==r.length)throw new Error(`Elevation provider returned ${n.length} heights for ${r.length} positions`);for(let o=0;o<r.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]=r[o],l=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([h,c,a])[2]:a,u=s[o*3+2]*(i?1:this.sourceVerticalUnitScale);s[o*3+2]=this.elevationMode==="onTheGround"?l:l+u+this.elevationOffset}return s}transformEcefNormal(t,i){if(this.targetCoordinateFrame==="geocentric")return t.normalize();if(this.targetCoordinateFrame==="geographic")return e2(t,i).normalize();let s=b.WGS84.cartographicToCartesian(new p(i)),r=[];for(let o of t2()){let a=b.WGS84.cartesianToCartographic(new p(s).add(o)),h=b.WGS84.cartesianToCartographic(new p(s).subtract(o)),c=this.geographicToTargetTransformer.transformPosition(a),l=this.geographicToTargetTransformer.transformPosition(h);r.push((c[0]-l[0])/2,(c[1]-l[1])/2,(c[2]-l[2])/2)}let n=new U(r);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 p(t).transformByMatrix3(n).normalize()}};function Kg(e,t){return e==="relativeToScene"?t.sceneElevationProvider:qe(e)?t.terrainElevationProvider:void 0}function qe(e){return e==="onTheGround"||e==="relativeToGround"||e==="relativeToScene"}function Vn(e){if(e.length%3!==0)throw new Error("I3S position arrays must contain complete XYZ tuples");let t=[];for(let i=0;i<e.length;i+=3)t.push([e[i],e[i+1],e[i+2]]);return t}function Jg(e){let t=ee(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 zl(e){if(!e.length)throw new Error("I3S spatial transformation requires at least one bound sample");let t=e.map(n=>b.WGS84.cartographicToCartesian(new p(n))),i=new p;for(let n of t)i.add(n);i.scale(1/t.length);let s=0;for(let n of t)s=Math.max(s,new p(n).subtract(i).magnitude());let r=b.WGS84.cartesianToCartographic(i);return[r[0],r[1],r[2],s]}function ql(e,t,i,s){let r=e.obb;if(r){let h=Array.from(r.center).slice(0,3);h[2]*=s;let c=Array.from(r.halfSize).slice(0,3),l=new yt().fromArray(Array.from(r.quaternion)),u=[new p([c[0],0,0]).transformByQuaternion(l),new p([0,c[1],0]).transformByQuaternion(l),new p([0,0,c[2]]).transformByQuaternion(l)];if(t==="geographic"){let f=i.transformPosition(h),d=b.WGS84.cartographicToCartesian(new p(f)),m=e.normalReferenceFrame==="vertex-reference-frame"?u.map(g=>Fl(g,f)):u;return Bl().map(g=>{let _=new p(d);for(let M=0;M<3;M++)_.add(new p(m[M]).scale(g[M]));return Array.from(b.WGS84.cartesianToCartographic(_))})}return Bl().map(f=>{let d=new p(h);for(let m=0;m<3;m++)d.add(new p(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=i.transformPosition(o),c=b.WGS84.cartographicToCartesian(new p(h));return Dl().map(l=>Array.from(b.WGS84.cartesianToCartographic(new p(c).add(new p(l).scale(a)))))}return Dl().map(h=>Array.from(new p(o).add(new p(h).scale(a))))}function Bl(){return[-1,1].flatMap(e=>[-1,1].flatMap(t=>[-1,1].map(i=>[e,t,i])))}function Dl(){return[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]]}function t2(){return[new p([1,0,0]),new p([0,1,0]),new p([0,0,1])]}function Fl(e,t){let i=t[0]*Math.PI/180,s=t[1]*Math.PI/180,r=new p([-Math.sin(i),Math.cos(i),0]),n=new p([-Math.sin(s)*Math.cos(i),-Math.sin(s)*Math.sin(i),Math.cos(s)]),o=new p([Math.cos(s)*Math.cos(i),Math.cos(s)*Math.sin(i),Math.sin(s)]);return r.scale(e[0]).add(n.scale(e[1])).add(o.scale(e[2]))}function e2(e,t){let i=t[0]*Math.PI/180,s=t[1]*Math.PI/180,r=new p([-Math.sin(i),Math.cos(i),0]),n=new p([-Math.sin(s)*Math.cos(i),-Math.sin(s)*Math.sin(i),Math.cos(s)]),o=new p([Math.cos(s)*Math.cos(i),Math.cos(s)*Math.sin(i),Math.sin(s)]);return new p([r.dot(e),n.dot(e),o.dot(e)])}function ce(e){let t=[1/0,1/0,1/0],i=[-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]),i[o]=Math.max(i[o],n[o]);let s=t.map((n,o)=>(n+i[o])/2),r=t.map((n,o)=>(i[o]-n)/2);return[s[0],s[1],s[2],r[0],0,0,0,r[1],0,0,0,r[2]]}function ee(e){let t=e[0][0],i=1/0,s=-1/0,r=1/0,n=-1/0,o=1/0,a=-1/0;for(let h of e){let c=t+kn(h[0]-t);i=Math.min(i,c),s=Math.max(s,c),r=Math.min(r,h[1]),n=Math.max(n,h[1]),o=Math.min(o,h[2]),a=Math.max(a,h[2])}return[kn(i)*Math.PI/180,r*Math.PI/180,kn(s)*Math.PI/180,n*Math.PI/180,o,a]}function kn(e){return((e+180)%360+360)%360-180}var i2={draco:!1,meshopt:!1,dds:!1,ktx2:!1},$s=class{type=at.I3S;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...i2};asset;properties;extras;credits;metadata;queryParams={};resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(t,i={}){let s=s2(t);this.rootTileset=Ul(t)?null:t,this.tileset=this.rootTileset,this.loader=s.loader,this.url=s.url,this.basePath=s.basePath||gt.dirname(s.url),this.resolver=s.resolver,this.coreApi=s.coreApi,this.loadOptions=i,this.initializeQueryParams(i)}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:Ss(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 i=t.spatialReference;if(i.status==="unresolved")throw new Error(i.warnings[0]||"I3S spatial operations cannot be resolved from the supplied metadata and options");i.status!=="transformable"&&i.status!=="transformed"||(this.spatialTransformer||=new Be(i,t.options.spatial),t.spatialReference=this.spatialTransformer.spatialReference,this.preparedRootHeader=await this.transformTileHeader(this.getMetadata().tileset.root))}initializeTileHeaders(t,i,s){let r=s?i.root:this.preparedRootHeader||i.root;if(this.spatialTransformer&&!this.preparedRootHeader)throw new Error("I3S spatial root header was not prepared before tile initialization");let n=new Et(t,r,s||void 0);return s&&(s.children.push(n),n.depth=s.depth+1),n}createTraverser(t){return new Rs(t)}async loadTileContent(t){let i=this.getTileUrl(t.contentUrl),s=this.loader.id,r=this.loadOptions[s]||{},n=this.getMetadata(),o={...this.loadOptions,[s]:{...r,...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(i,o),{loaded:!0}}async loadChildTileHeader(t,i,s){let r=this.getMetadata();if(r.tileset.nodePages||r.tileset.pointNodePages){let c=await r.tileset.nodePagesTile.formTileFromNodePages(i);return await this.transformTileHeader(c)}let n=this.getTileUrl(`${this.url}/nodes/${i}`),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 i=t.indexOf("?");if(i===-1)return`${t}?${new URLSearchParams(this.queryParams).toString()}`;let s=t.slice(i+1),r=new Set(s.split("&").map(a=>a.split("=",1)[0])),n=new URLSearchParams;for(let[a,h]of Object.entries(this.queryParams))r.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 p(t.boundingVolume.center),o=new p(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 i=this.getMetadata(),s=i.tileset.fullExtent;if(s){let{xmin:n,xmax:o,ymin:a,ymax:h,zmin:c,zmax:l}=s,u=new p(n+(o-n)/2,a+(h-a)/2,c+(l-c)/2),f=new p;return b.WGS84.cartographicToCartesian(u,f),{cartographicCenter:u,cartesianCenter:f,zoom:sn(s,u,f)}}let r=i.tileset.store?.extent;if(r){let[n,o,a,h]=r,c=new p(n+(a-n)/2,o+(h-o)/2,0),l=new p;return b.WGS84.cartographicToCartesian(c,l),{cartographicCenter:c,cartesianCenter:l,zoom:xh(r,c,l)}}return console.warn("Extent is not defined in the tileset header"),{cartographicCenter:new p,zoom:1}}onTileLoaded(t,i){switch(i.header.isDracoGeometry&&(this.contentFormats.draco=!0),i.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,i){if(!this.coreApi)throw new Error("I3SSource requires an injected coreApi to load tileset data");return await this.coreApi.load(t,this.loader,i)}async loadRootData(t,i){return this.resolver?await this.resolver.loadRoot(t,this.loader,i):await this.loadWithCoreApi(t,i)}initializeQueryParams(t){let i=t.i3s;if(i&&typeof i=="object"&&"token"in i){let s=i.token;typeof s=="string"&&(this.queryParams.token=s)}}async loadResourceData(t,i){return this.resolver?await this.resolver.loadResource(t,this.loader,i):await this.loadWithCoreApi(t,i)}async transformTileHeader(t){if(!this.spatialTransformer)return t;let i={mbs:t.mbs,obb:t.obb,normalReferenceFrame:this.getMetadata().tileset.store?.normalReferenceFrame},s=await this.spatialTransformer.transformBoundsAsync(i);return{...t,boundingVolume:s.boundingVolume,spatialBoundingVolume:s.spatialBoundingVolume,i3sLodMbs:s.i3sLodMbs}}};function Ul(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function s2(e){return Ul(e)?{...e,basePath:e.basePath||gt.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||gt.dirname(e.url),resolver:e.resolver,coreApi:e.coreApi}}var le=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:i,onLoad:s,onError:r}){let n=(_,M,y)=>{if(y===this._loaderId){if(this._loader=void 0,this.content=_,this.error=M?r2(M):null,this._isCancelled&&!_){this._isLoaded=!1;return}if(this._isLoaded=!0,this._isCancelled=!1,M){r(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 i.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(_){g=_||!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 r2(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}var jn="never",Wn="no-overlap",Pi="best-available",Vl={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:Pi,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},Ti=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 St({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={...Vl,...t,getTileData:t.getTileData||(()=>null),tileSource:t.tileSource},this._requestScheduler=new Ut({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,i={}){return new e({...i,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 i of this._getSelectedTilesUnion())t.add(i);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||Pi}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 i=this.opts.maxRequests,s=this.opts.debounceTime;this._applyResolvedOptions(),(i!==this.opts.maxRequests||s!==this.opts.debounceTime)&&(this._requestScheduler=new Ut({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 i of this._cache.keys()){let s=this._cache.get(i);s&&!t.has(s)?(this._cache.delete(i),this._handleTileUnload(s),this._dirty=!0):s&&s.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,i,s){this._consumers.set(t,{selectedTiles:new Set(i),visibleTiles:new Set(s)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:i,minZoom:s,zRange:r,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:i,minZoom:s,zRange:r,tileSize:h,extent:n2(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,i){let s=this.getTileId(t),r=this._cache.get(s),n=!1;return!r&&i?(r=new le(t),Object.assign(r,this.getTileMetadata(r.index)),Object.assign(r,{id:s,zoom:this.getTileZoom(r.index)}),n=!0,this._cache.set(s,r),this._dirty=!0,this._updateStats()):r&&r.needsReload&&(n=!0),r&&this._touchTile(s,r),r&&n&&i&&(r.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),this._updateStats()),r}async _initializeTileSource(t){try{this.sourceMetadata=await t.getMetadata(),this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(i){let s=i instanceof Error?i:new Error(`TileSource metadata error: ${String(i)}`);this._notifyError(s)}}_rememberExplicitOptions(t){for(let i of Object.keys(t))this._explicitOptionKeys.add(i)}_applyResolvedOptions(){let t={...Vl,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let i=t.tileSource;t.getTileData=s=>i.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 i={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(t.minZoom)&&(i.minZoom=t.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(t.maxZoom)&&(i.maxZoom=t.maxZoom),!this._explicitOptionKeys.has("extent")&&t.boundingBox&&(i.extent=[t.boundingBox[0][0],t.boundingBox[0][1],t.boundingBox[1][0],t.boundingBox[1][1]]),i}_handleTileLoad(t){this.opts.onTileLoad?.(t),this._cacheByteSize=this._getCacheByteSize(),this._resizeCache();for(let i of this._listeners)i.onTileLoad?.(t);this._updateStats()}_handleTileError(t,i){this.opts.onTileError?.(t,i);for(let s of this._listeners)s.onTileError?.(t,i);this._updateStats()}_handleTileUnload(t){this._unloadedTileCount++,this.opts.onTileUnload?.(t);for(let i of this._listeners)i.onTileUnload?.(t);this._updateStats()}_notifyUpdate(){for(let t of this._listeners)t.onUpdate?.()}_notifyError(t){for(let i of this._listeners)i.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,i){this.stats.get(t).reset().addCount(i)}_getSelectedTilesUnion(){let t=new Set;for(let i of this._consumers.values())for(let s of i.selectedTiles)t.add(s);return t}_getVisibleTilesUnion(){let t=new Set;for(let i of this._consumers.values())for(let s of i.visibleTiles)t.add(s);return t}_touchTile(t,i){this._cache.delete(t),this._cache.set(t,i)}_getCacheByteSize(){let t=0;for(let i of this._cache.values())t+=i.byteLength;return t}_pruneRequests(){let{maxRequests:t=0}=this.opts,i=this._getSelectedTilesUnion(),s=this._getVisibleTilesUnion(),r=[],n=0;for(let o of this._cache.values())o.isLoading&&(n++,!i.has(o)&&!s.has(o)&&r.push(o));for(;t>0&&n>t&&r.length>0;){let o=r.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 i=this._getNearestAncestor(t);t.parent=i,i?.children&&i.children.push(t)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((t,i)=>t.zoom-i.zoom)}_resizeCache(){let t=this.opts.maxCacheSize??100,i=this.opts.maxCacheByteSize??1/0,s=this._getVisibleTilesUnion(),r=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>i){for(let[o,a]of this._cache)if(!s.has(a)&&!r.has(a)&&(this._cache.delete(o),this._cacheByteSize=this._getCacheByteSize(),this._handleTileUnload(a)),this._cache.size<=t&&this._cacheByteSize<=i)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(t){let{_minZoom:i=0}=this,s=t.index;for(;this.getTileZoom(s)>i;){s=this.getParentIndex(s);let r=this.getTile(s);if(r)return r}return null}};function n2(e){return e&&e.length===4?e:void 0}var Qs={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},Ks=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,i={}){return new e({...i,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 i=this._opts.imageSource,s=this._normalizeOptions({...this._opts,...t}),r=i!==s.imageSource||this._opts.getImage!==s.getImage||this._opts.getMetadata!==s.getMetadata;this._opts=s,r&&(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 i of this._listeners)i.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let i=kl(t,"Image metadata request failed");if(!this._finalized)for(let s of this._listeners)s.onMetadataLoadError?.(i);throw i}finally{this._finishLoading()}}requestImage(t,i=this._opts.debounceTime){let s=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),i>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(s,t)},i):this._loadImage(s,t),s}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,i){if(!this._finalized){this._startLoading();for(let s of this._listeners)s.onImageLoadStart?.(t,i);try{let s=new AbortController;this._abortController=s;let r=await this._opts.getImage({...i,signal:s.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:i,image:r};for(let n of this._listeners)n.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(s){if(o2(s))return;let r=kl(s,"Image request failed");if(!this._finalized)for(let n of this._listeners)n.onImageLoadError?.(t,r,i)}finally{this._abortController?.signal===i.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let i=t.imageSource||null;return{...Qs,...t,imageSource:i,getMetadata:t.getMetadata||(()=>i?i.getMetadata():Qs.getMetadata()),getImage:t.getImage||(s=>i?i.getImage(s):Qs.getImage(s)),debounceTime:t.debounceTime??Qs.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 i of this._listeners)i.onLoadingStateChange?.(t)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function o2(e){return e instanceof Error&&e.name==="AbortError"}function kl(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}var bi={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},Js=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,i={}){return new e({...i,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 i=this._opts.rasterSource,s=this._normalizeOptions({...this._opts,...t}),r=i!==s.rasterSource||this._opts.getRaster!==s.getRaster||this._opts.getMetadata!==s.getMetadata;this._opts=s,r&&(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 i of this._listeners)i.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let i=jl(t,"Raster metadata request failed");if(!this._finalized)for(let s of this._listeners)s.onMetadataLoadError?.(i);throw i}finally{this._finishLoading()}}requestRaster(t,i=this._opts.debounceTime){if(!this.shouldRefetchRaster(t))return this._currentRequest?.requestId??-1;let s=this._nextRequestId++;return this._cancelScheduledRaster(),i>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(s,t)},i):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,i){if(!this._finalized){this._startLoading();for(let s of this._listeners)s.onRasterLoadStart?.(t,i);try{let s=new AbortController;this._abortController=s;let r=await this._opts.getRaster(a2(i,s.signal));if(this._finalized||s.signal.aborted||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:i,raster:r};for(let n of this._listeners)n.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(s){if(h2(s))return;let r=jl(s,"Raster request failed");if(!this._finalized)for(let n of this._listeners)n.onRasterLoadError?.(t,r,i)}finally{this._abortController=null,this._finishLoading()}}}_normalizeOptions(t){let i=t.rasterSource||null;return{...bi,...t,rasterSource:i,getMetadata:t.getMetadata||(()=>i?i.getMetadata():bi.getMetadata()),getRaster:t.getRaster||(s=>i?i.getRaster(s):bi.getRaster(s)),debounceTime:t.debounceTime??bi.debounceTime,shouldRefetch:t.shouldRefetch||(s=>bi.shouldRefetch(s))}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_emitLoadingStateChange(t){for(let i of this._listeners)i.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 a2(e,t){let i=Array.isArray(e)?e.slice():Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e));return Object.defineProperty(i,"signal",{configurable:!0,enumerable:!0,value:t,writable:!0}),i}function jl(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function h2(e){return e instanceof Error&&e.name==="AbortError"}var De=class{header;parent;children=[];childrenLoaded=!1;childrenPromise=null;selected=!1;viewportIds=[];content=null;contentAvailable=!1;contentFailed=!1;isContentLoading=!1;constructor(t,i=null){this.header=t,this.parent=i}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 c2={debounceTime:0,minimumNodePixelSize:150,maximumScreenSpaceError:1,lodSelectionMetricType:"maxScreenThresholdSQ",densityThreshold:1,pointBudget:2e6,maxDepth:Number.POSITIVE_INFINITY,onTileLoad:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{}},tr=64,er=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,i={}){this.dataSource=t,this.options={...c2,...i},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 i=await this.dataSource.getViewState?.();this.boundingVolume=i?.boundingVolume||this.root.boundingVolume;let s=i?.cartographicCenter||this.root.boundingVolume.center;this.cartographicCenter=new p(s),this.zoom=i?.zoom||this.estimateZoom(this.boundingVolume)}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedViewports=t),this.updatePromise||(this.updatePromise=new Promise((i,s)=>{setTimeout(()=>{this.doSelectTiles().then(()=>i(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 i=Array.isArray(this.lastUpdatedViewports)?this.lastUpdatedViewports:[this.lastUpdatedViewports],s=new Map,r=new Set,n=0;for(let a of i){let h=this.getTraversalContext(a);n=await this.traverseTiles(h,s,n,r)}this.visibleTilesCount=r.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,i,s,r){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(r.add(h.id),!i.has(h.id)&&h.pointCount>0){if(n>0&&n+h.pointCount>this.options.pointBudget)break;i.set(h.id,h),n+=h.pointCount}if(i.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,i){if(t.level<this.options.maxDepth&&Number.isFinite(i)&&(t.header.lodSelectionMetricType||this.options.lodSelectionMetricType)==="density-threshold"){let s=Math.max(1,Math.PI*i*i),r=t.pointCount/s,n=t.header.lodThreshold||this.options.densityThreshold;return r<n}return t.level<this.options.maxDepth&&Number.isFinite(i)&&i>=this.options.minimumNodePixelSize}getTraversalContext(t){let i=this.getCullingVolume(t);return{viewport:t,cullingVolume:this.shouldUseCullingVolume(t,i)?i:null}}isVisible(t,i){if(i.cullingVolume){let r=this.getCommonSpaceBoundingSphere(t.boundingVolume,i.viewport);if(r)return this.isBoundingSphereInsideCullingVolume(r,i.cullingVolume)}let s=this.getProjectedFootprint(t.boundingVolume,i.viewport);return s?this.isProjectedFootprintVisible(s,i.viewport):!1}shouldUseCullingVolume(t,i){if(!this.root||!i)return!1;let s=this.getCommonSpaceBoundingSphere(this.root.boundingVolume,t);if(!s)return!1;if(this.isBoundingSphereInsideCullingVolume(s,i))return!0;let r=this.getProjectedFootprint(this.root.boundingVolume,t);return!r||!this.isProjectedFootprintVisible(r,t)}isBoundingSphereInsideCullingVolume(t,i){return i.computeVisibilityWithPlaneMask(t,K.MASK_INDETERMINATE)!==K.MASK_OUTSIDE}isProjectedFootprintVisible(t,i){return!(t.x+t.radius<-tr||t.x-t.radius>i.width+tr||t.y+t.radius<-tr||t.y-t.radius>i.height+tr)}estimateScreenRadius(t,i){let s=this.getProjectedFootprint(t.boundingVolume,i);return s?s.radius:0}projectBounds(t,i){let s=this.getBoundingVolumeCorners(t),r=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;try{for(let h of s){let[c,l]=i.project(h);!Number.isFinite(c)||!Number.isFinite(l)||(r=Math.min(r,c),n=Math.min(n,l),o=Math.max(o,c),a=Math.max(a,l))}}catch{return null}return!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(a)?null:{minX:r,minY:n,maxX:o,maxY:a}}getProjectedFootprint(t,i){let s=Number.NaN,r=Number.NaN;try{[s,r]=i.project(t.center)}catch{return null}if(!Number.isFinite(s)||!Number.isFinite(r))return null;let n=this.getBoundingVolumeCorners(t),o=0;try{for(let a of n){let[h,c]=i.project(a);!Number.isFinite(h)||!Number.isFinite(c)||(o=Math.max(o,Math.hypot(h-s,c-r)))}}catch{return null}if(o===0){let a=this.projectBounds(t,i);a&&(o=Math.max(a.maxX-a.minX,a.maxY-a.minY)/2)}return{x:s,y:r,radius:o}}async getVisibleChildren(t,i){return t.level>=this.options.maxDepth?[]:(await this.getChildren(t)).map(r=>({tile:r,weight:this.estimateScreenRadius(r,i.viewport)})).filter(r=>this.isVisible(r.tile,i))}async getChildren(t){if(t.childrenLoaded)return t.children;if(!t.childrenPromise){let i=this.dataSource.getChildren(t.header).then(s=>s.map(r=>this.getOrCreateTile(r,t))).then(s=>(t.children=s,t.childrenLoaded=!0,s));t.childrenPromise=i.finally(()=>{t.childrenPromise===i&&(t.childrenPromise=null)})}return t.childrenPromise}getOrCreateTile(t,i){let s=this.tilesMap.get(t.id);if(s)return s.header=t,i&&s.parent!==i&&(s.parent=i),s;let r=new De(t,i);return this.tilesMap.set(t.id,r),i&&!i.children.find(n=>n.id===r.id)&&i.children.push(r),r}async loadTile(t){if(!(t.contentAvailable||t.isContentLoading||t.contentFailed)){t.isContentLoading=!0,this.pendingCount++;try{let i=await this.dataSource.loadTileContent(t.header);t.content=i,t.contentAvailable=!0,i&&this.options.onTileLoad(t)}catch(i){t.contentFailed=!0,this.options.onTileError(t,i)}finally{t.isContentLoading=!1,this.pendingCount--}}}estimateZoom(t){if(!t||t.coordinateFrame==="cartesian")return 1;let[i,s]=t.cartographicBounds,r=t.coversFullLongitude?360:t.wrapsDateline?360-Math.abs(s[0]-i[0]):Math.abs(s[0]-i[0]),n=Math.max(r,1e-6);return Math.max(1,Math.round(Math.log2(360/n)))}haveSameIds(t,i){if(t.size!==i.size)return!1;for(let s of t)if(!i.has(s))return!1;return!0}getBoundingVolumeCorners(t){let[i,s]=t.cartographicBounds,r=t.coversFullLongitude?[[-180,180]]:t.wrapsDateline?[[i[0],180],[-180,s[0]]]:[[i[0],s[0]]],n=[],o=360-Math.abs(s[0]-i[0]),a=i[0]+o/2;for(let[h,c]of r){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,i[1],i[2]||0],[u,i[1],s[2]||0],[u,s[1],i[2]||0],[u,s[1],s[2]||0],[f,i[1],i[2]||0],[f,i[1],s[2]||0],[f,s[1],i[2]||0],[f,s[1],s[2]||0])}return n}getCullingVolume(t){let i=t.getFrustumPlanes?.bind(t);if(!i)return null;let s=i(),r=["left","right","bottom","top","near","far"],n=[];for(let o of r){let a=s[o];if(!a)return null;n.push(new Y(a.normal,-a.distance))}return new K(n)}getCommonSpaceBoundingSphere(t,i){let s=i.projectPosition?.bind(i);if(!s)return null;let r=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 r){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 J().fromCornerPoints([n,o,a],[h,c,l])}};return f0(Ri);})();
12
+ northing meters`+e;var f=u/2,m=0,d=0,g,_,y,M,T;return f>0&&(g=1e5/Math.pow(10,f),_=e.substring(n,n+f),m=parseFloat(_)*g,y=e.substring(n+f),d=parseFloat(y)*g),M=m+c,T=d+l,{easting:M,northing:T,zoneLetter:a,zoneNumber:o,accuracy:g}}function L1(e,t){for(var r=nl.charCodeAt(t-1),i=1e5,s=!1;r!==e.charCodeAt(0);){if(r++,r===ft&&r++,r===wt&&r++,r>Er){if(s)throw"Bad character: "+e;r=Le,s=!0}i+=1e5}return i}function G1(e,t){if(e>"V")throw"MGRSPoint given invalid Northing "+e;for(var r=ol.charCodeAt(t-1),i=0,s=!1;r!==e.charCodeAt(0);){if(r++,r===ft&&r++,r===wt&&r++,r>Sr){if(s)throw"Bad character: "+e;r=Le,s=!0}i+=1e5}return i}function D1(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 Ge(e,t,r){if(!(this instanceof Ge))return new Ge(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 i=e.split(",");this.x=parseFloat(i[0]),this.y=parseFloat(i[1]),this.z=parseFloat(i[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")}Ge.fromMGRS=function(e){return new Ge(Yn(e))};Ge.prototype.toMGRS=function(e){return $n([this.x,this.y],e)};var ll=Ge;var B1=1,z1=.25,ul=.046875,fl=.01953125,dl=.01068115234375,q1=.75,F1=.46875,k1=.013020833333333334,U1=.007120768229166667,V1=.3645833333333333,j1=.005696614583333333,W1=.3076171875;function De(e){var t=[];t[0]=B1-e*(z1+e*(ul+e*(fl+e*dl))),t[1]=e*(q1-e*(ul+e*(fl+e*dl)));var r=e*e;return t[2]=r*(F1-e*(k1+e*U1)),r*=e,t[3]=r*(V1-e*j1),t[4]=r*e*W1,t}function qt(e,t,r,i){return r*=t,t*=t,i[0]*e-r*(i[1]+t*(i[2]+t*(i[3]+t*i[4])))}var H1=20;function Be(e,t,r){for(var i=1/(1-t),s=e,n=H1;n;--n){var o=Math.sin(s),a=1-t*o*o;if(a=(qt(s,o,Math.cos(s),r)-e)*(a*Math.sqrt(a))*i,s-=a,Math.abs(a)<E)return s}return s}function $1(){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=qt(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Y1(e){var t=e.x,r=e.y,i=S(t-this.long0,this.over),s,n,o,a=Math.sin(r),h=Math.cos(r);if(this.es){var l=h*i,u=Math.pow(l,2),f=this.ep2*Math.pow(h,2),m=Math.pow(f,2),d=Math.abs(h)>E?Math.tan(r):0,g=Math.pow(d,2),_=Math.pow(g,2);s=1-this.es*Math.pow(a,2),l=l/Math.sqrt(s);var y=qt(r,a,h,this.en);n=this.a*(this.k0*l*(1+u/6*(1-g+f+u/20*(5-18*g+_+14*f-58*g*f+u/42*(61+179*_-_*g-479*g)))))+this.x0,o=this.a*(this.k0*(y-this.ml0+a*i*l/2*(1+u/12*(5-g+9*f+4*m+u/30*(61+_-58*g+270*f-330*g*f+u/56*(1385+543*_-_*g-3111*g))))))+this.y0}else{var c=h*Math.sin(i);if(Math.abs(Math.abs(c)-1)<E)return 93;if(n=.5*this.a*this.k0*Math.log((1+c)/(1-c))+this.x0,o=h*Math.cos(i)/Math.sqrt(1-Math.pow(c,2)),c=Math.abs(o),c>=1){if(c-1>E)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 X1(e){var t,r,i,s,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=Be(t,this.es,this.en),Math.abs(r)<x){var u=Math.sin(r),f=Math.cos(r),m=Math.abs(f)>E?Math.tan(r):0,d=this.ep2*Math.pow(f,2),g=Math.pow(d,2),_=Math.pow(m,2),y=Math.pow(_,2);t=1-this.es*Math.pow(u,2);var M=n*Math.sqrt(t)/this.k0,T=Math.pow(M,2);t=t*m,i=r-t*T/(1-this.es)*.5*(1-T/12*(5+3*_-9*d*_+d-4*g-T/30*(61+90*_-252*d*_+45*y+46*d-T/56*(1385+3633*_+4095*y+1574*y*_)))),s=S(this.long0+M*(1-T/6*(1+2*_+d-T/20*(5+28*_+24*y+8*d*_+6*d-T/42*(61+662*_+1320*y+720*y*_))))/f,this.over)}else i=x*zt(o),s=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))),i=Math.asin(t),o<0&&(i=-i),h===0&&l===0?s=0:s=S(Math.atan2(h,l)+this.long0,this.over)}return e.x=s,e.y=i,e}var Z1=["Fast_Transverse_Mercator","Fast Transverse Mercator"],ze={init:$1,forward:Y1,inverse:X1,names:Z1};function ts(e){var t=Math.exp(e);return t=(t-1/t)/2,t}function X(e,t){e=Math.abs(e),t=Math.abs(t);var r=Math.max(e,t),i=Math.min(e,t)/(r||1);return r*Math.sqrt(1+Math.pow(i,2))}function ml(e){var t=1+e,r=t-1;return r===0?e:e*Math.log(t)/r}function pl(e){var t=Math.abs(e);return t=ml(t*(1+t/(X(1,t)+1))),e<0?-t:t}function es(e,t){for(var r=2*Math.cos(2*t),i=e.length-1,s=e[i],n=0,o;--i>=0;)o=-n+r*s+e[i],n=s,s=o;return t+o*Math.sin(2*t)}function gl(e,t){for(var r=2*Math.cos(t),i=e.length-1,s=e[i],n=0,o;--i>=0;)o=-n+r*s+e[i],n=s,s=o;return Math.sin(t)*o}function _l(e){var t=Math.exp(e);return t=(t+1/t)/2,t}function Zn(e,t,r){for(var i=Math.sin(t),s=Math.cos(t),n=ts(r),o=_l(r),a=2*s*o,h=-2*i*n,c=e.length-1,l=e[c],u=0,f=0,m=0,d,g;--c>=0;)d=f,g=u,f=l,u=m,l=-d+a*f-h*u+e[c],m=-g+h*f+a*u;return a=i*o,h=s*n,[a*l-h*m,a*m+h*l]}function K1(){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&&(ze.init.apply(this),this.forward=ze.forward,this.inverse=ze.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.k0=this.k0!==void 0?this.k0:1,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 i=es(this.cbg,this.lat0);this.Zb=-this.Qn*(i+gl(this.gtu,2*i))}function Q1(e){var t=S(e.x-this.long0,this.over),r=e.y;r=es(this.cbg,r);var i=Math.sin(r),s=Math.cos(r),n=Math.sin(t),o=Math.cos(t);r=Math.atan2(i,o*s),t=Math.atan2(n*s,X(i,s*o)),t=pl(Math.tan(t));var a=Zn(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 J1(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 i,s;if(Math.abs(t)<=2.623395162778){var n=Zn(this.utg,2*r,2*t);r=r+n[0],t=t+n[1],t=Math.atan(ts(t));var o=Math.sin(r),a=Math.cos(r),h=Math.sin(t),c=Math.cos(t);r=Math.atan2(o*c,X(h,c*a)),t=Math.atan2(h,c*a),i=S(t+this.long0,this.over),s=es(this.cgb,r)}else i=1/0,s=1/0;return e.x=i,e.y=s,e}var tp=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","Gauss Kruger","Gauss_Kruger","tmerc"],qe={init:K1,forward:Q1,inverse:J1,names:tp};function yl(e,t){if(e===void 0){if(e=Math.floor((S(t)+Math.PI)*30/Math.PI)+1,e<0)return 0;if(e>60)return 60}return e}var ep="etmerc";function rp(){var e=yl(this.zone,this.long0);if(e===void 0)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(e)-183)*q,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,qe.init.apply(this),this.forward=qe.forward,this.inverse=qe.inverse}var ip=["Universal Transverse Mercator System","utm"],Ml={init:rp,names:ip,dependsOn:ep};function rs(e,t){return Math.pow((1-e)/(1+e),t)}var sp=20;function np(){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+G)/(Math.pow(Math.tan(.5*this.lat0+G),this.C)*rs(this.e*e,this.ratexp))}function op(e){var t=e.x,r=e.y;return e.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*r+G),this.C)*rs(this.e*Math.sin(r),this.ratexp))-x,e.x=this.C*t,e}function ap(e){for(var t=1e-14,r=e.x/this.C,i=e.y,s=Math.pow(Math.tan(.5*i+G)/this.K,1/this.C),n=sp;n>0&&(i=2*Math.atan(s*rs(this.e*Math.sin(e.y),-.5*this.e))-x,!(Math.abs(i-e.y)<t));--n)e.y=i;return n?(e.x=r,e.y=i,e):null}var hp=["gauss"],is={init:np,forward:op,inverse:ap,names:hp};function cp(){is.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 lp(e){var t,r,i,s;return e.x=S(e.x-this.long0,this.over),is.forward.apply(this,[e]),t=Math.sin(e.y),r=Math.cos(e.y),i=Math.cos(e.x),s=this.k0*this.R2/(1+this.sinc0*t+this.cosc0*r*i),e.x=s*r*Math.sin(e.x),e.y=s*(this.cosc0*t-this.sinc0*r*i),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function up(e){var t,r,i,s,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=X(e.x,e.y)){var o=2*Math.atan2(n,this.R2);t=Math.sin(o),r=Math.cos(o),s=Math.asin(r*this.sinc0+e.y*t*this.cosc0/n),i=Math.atan2(e.x*t,n*this.cosc0*r-e.y*this.sinc0*t)}else s=this.phic0,i=0;return e.x=i,e.y=s,is.inverse.apply(this,[e]),e.x=S(e.x+this.long0,this.over),e}var fp=["Stereographic_North_Pole","Oblique_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],xl={init:cp,forward:lp,inverse:up,names:fp};function Kn(e,t,r){return t*=r,Math.tan(.5*(x+e))*Math.pow((1-t)/(1+t),.5*r)}function dp(){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?!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=E&&(this.k0=.5*(1+zt(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=E&&(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)),!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=E&&Math.abs(Math.cos(this.lat_ts))>E&&(this.k0=.5*this.cons*st(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/ct(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=st(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(Kn(this.lat0,this.sinlat0,this.e))-x,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function mp(e){var t=e.x,r=e.y,i=Math.sin(r),s=Math.cos(r),n,o,a,h,c,l,u=S(t-this.long0,this.over);return Math.abs(Math.abs(t-this.long0)-Math.PI)<=E&&Math.abs(r+this.lat0)<=E?(e.x=NaN,e.y=NaN,e):this.sphere?(n=2*this.k0/(1+this.sinlat0*i+this.coslat0*s*Math.cos(u)),e.x=this.a*n*s*Math.sin(u)+this.x0,e.y=this.a*n*(this.coslat0*i-this.sinlat0*s*Math.cos(u))+this.y0,e):(o=2*Math.atan(Kn(r,i,this.e))-x,h=Math.cos(o),a=Math.sin(o),Math.abs(this.coslat0)<=E?(c=ct(this.e,r*this.con,this.con*i),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)<E?(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 pp(e){e.x-=this.x0,e.y-=this.y0;var t,r,i,s,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<=E?(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)<E?this.lat0>0?t=S(this.long0+Math.atan2(e.x,-1*e.y),this.over):t=S(this.long0+Math.atan2(e.x,e.y),this.over):t=S(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)<=E){if(o<=E)return r=this.lat0,t=this.long0,e.x=t,e.y=r,e;e.x*=this.con,e.y*=this.con,i=o*this.cons/(2*this.a*this.k0),r=this.con*$t(this.e,i),t=this.con*S(this.con*this.long0+Math.atan2(e.x,-1*e.y),this.over)}else s=2*Math.atan(o*this.cosX0/(2*this.a*this.k0*this.ms1)),t=this.long0,o<=E?n=this.X0:(n=Math.asin(Math.cos(s)*this.sinX0+e.y*Math.sin(s)*this.cosX0/o),t=S(this.long0+Math.atan2(e.x*Math.sin(s),o*this.cosX0*Math.cos(s)-e.y*this.sinX0*Math.sin(s)),this.over)),r=-1*$t(this.e,Math.tan(.5*(x+n)));return e.x=t,e.y=r,e}var gp=["stere","Stereographic_South_Pole","Polar_Stereographic_variant_A","Polar_Stereographic_variant_B","Polar_Stereographic"],Sl={init:dp,forward:mp,inverse:pp,names:gp,ssfn_:Kn};function _p(){this.k0||(this.k0=1);var e=this.lat0;this.lambda0=this.long0;var t=Math.sin(e),r=this.a,i=this.rf,s=1/i,n=2*s-Math.pow(s,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 yp(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))),i=-this.alpha*(t+r)+this.K,s=2*(Math.atan(Math.exp(i))-Math.PI/4),n=this.alpha*(e.x-this.lambda0),o=Math.atan(Math.sin(n)/(Math.sin(this.b0)*Math.tan(s)+Math.cos(this.b0)*Math.cos(n))),a=Math.asin(Math.cos(this.b0)*Math.sin(s)-Math.sin(this.b0)*Math.cos(s)*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 Mp(e){for(var t=e.x-this.x0,r=e.y-this.y0,i=t/this.R,s=2*(Math.atan(Math.exp(r/this.R))-Math.PI/4),n=Math.asin(Math.cos(this.b0)*Math.sin(s)+Math.sin(this.b0)*Math.cos(s)*Math.cos(i)),o=Math.atan(Math.sin(i)/(Math.cos(this.b0)*Math.cos(i)-Math.sin(this.b0)*Math.tan(s))),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 xp=["somerc"],El={init:_p,forward:yp,inverse:Mp,names:xp};var Fe=1e-7;function Sp(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(qn(r))!==-1}function Ep(){var e,t,r,i,s,n,o,a,h,c,l=0,u,f=0,m=0,d=0,g=0,_=0,y=0;this.k0||(this.k0=1),this.no_off=Sp(this),this.no_rot="no_rot"in this;var M=!1;"alpha"in this&&(M=!0);var T=!1;if("rectified_grid_angle"in this&&(T=!0),M&&(y=this.alpha),T&&(l=this.rectified_grid_angle,M||(y=0,M=!0)),M||T)f=this.longc;else if(m=this.long1,g=this.lat1,d=this.long2,_=this.lat2,Math.abs(g-_)<=Fe||(e=Math.abs(g))<=Fe||Math.abs(e-x)<=Fe||Math.abs(Math.abs(this.lat0)-x)<=Fe||Math.abs(Math.abs(_)-x)<=Fe)throw new Error;var v=1-this.es;t=Math.sqrt(v),Math.abs(this.lat0)>E?(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,i=this.B*t/(r*Math.sqrt(e)),s=i*i-1,s<=0?s=0:(s=Math.sqrt(s),this.lat0<0&&(s=-s)),this.E=s+=i,this.E*=Math.pow(ct(this.e,this.lat0,a),this.B)):(this.B=1/t,this.A=this.k0,this.E=i=s=1),M||T?(M?(u=Math.asin(Math.sin(y)/i),T||(l=y)):(u=l,y=Math.asin(i*Math.sin(u))),this.lam0=f-Math.asin(.5*(s-1/s)*Math.tan(u))/this.B):(n=Math.pow(ct(this.e,g,Math.sin(g)),this.B),o=Math.pow(ct(this.e,_,Math.sin(_)),this.B),s=this.E/n,h=(o-n)/(o+n),c=this.E*this.E,c=(c-o*n)/(c+o*n),e=m-d,e<-Math.PI?d-=te:e>Math.PI&&(d+=te),this.lam0=S(.5*(m+d)-Math.atan(c*Math.tan(.5*this.B*(m-d))/h)/this.B,this.over),u=Math.atan(2*Math.sin(this.B*S(m-this.lam0,this.over))/(s-1/s)),l=y=Math.asin(i*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(i*i-1)/Math.cos(y))),this.lat0<0&&(this.u_0=-this.u_0)),s=.5*u,this.v_pole_n=this.ArB*Math.log(Math.tan(G-s)),this.v_pole_s=this.ArB*Math.log(Math.tan(G+s))}function Tp(e){var t={},r,i,s,n,o,a,h,c;if(e.x=e.x-this.lam0,Math.abs(Math.abs(e.y)-x)>E){if(o=this.E/Math.pow(ct(this.e,e.y,Math.sin(e.y)),this.B),a=1/o,r=.5*(o-a),i=.5*(o+a),n=Math.sin(this.B*e.x),s=(r*this.singam-n*this.cosgam)/i,Math.abs(Math.abs(s)-1)<E)throw new Error;c=.5*this.ArB*Math.log((1-s)/(1+s)),a=Math.cos(this.B*e.x),Math.abs(a)<Fe?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 vp(e){var t,r,i,s,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),i=Math.exp(-this.BrA*r),s=.5*(i-1/i),n=.5*(i+1/i),o=Math.sin(this.BrA*t),a=(o*this.cosgam+s*this.singam)/n,Math.abs(Math.abs(a)-1)<E)h.x=0,h.y=a<0?-x:x;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(s*this.cosgam-o*this.singam,Math.cos(this.BrA*t))}return h.x+=this.lam0,h}var wp=["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"],Tl={init:Ep,forward:Tp,inverse:vp,names:wp};function bp(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,!(Math.abs(this.lat1+this.lat2)<E)){var e=this.b/this.a;this.e=Math.sqrt(1-e*e);var t=Math.sin(this.lat1),r=Math.cos(this.lat1),i=st(this.e,t,r),s=ct(this.e,this.lat1,t),n=Math.sin(this.lat2),o=Math.cos(this.lat2),a=st(this.e,n,o),h=ct(this.e,this.lat2,n),c=ct(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>E?this.ns=Math.log(i/a)/Math.log(s/h):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=i/(this.ns*Math.pow(s,this.ns)),this.rh=Math.abs(Math.abs(this.lat0)-x)<E?0:this.a*this.f0*Math.pow(c,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function Pp(e){var t=e.x,r=e.y;Math.abs(2*Math.abs(r)-Math.PI)<=E&&(r=zt(r)*(x-2*E));var i=Math.abs(Math.abs(r)-x),s,n;if(i>E)s=ct(this.e,r,Math.sin(r)),n=this.a*this.f0*Math.pow(s,this.ns);else{if(i=r*this.ns,i<=0)return null;n=0}var o=this.ns*S(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 Rp(e){var t,r,i,s,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,i=Math.pow(t/(this.a*this.f0),r),s=$t(this.e,i),s===-9999)return null}else s=-x;return n=S(h/this.ns+this.long0,this.over),e.x=n,e.y=s,e}var Cp=["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)"],vl={init:bp,forward:Pp,inverse:Rp,names:Cp};function Ap(){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 Ip(e){var t,r,i,s,n,o,a,h=e.x,c=e.y,l=S(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),i=-l*this.alfa,s=Math.asin(Math.cos(this.ad)*Math.sin(r)+Math.sin(this.ad)*Math.cos(r)*Math.cos(i)),n=Math.asin(Math.cos(r)*Math.sin(i)/Math.cos(s)),o=this.n*n,a=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(s/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 Op(e){var t,r,i,s,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),s=n/Math.sin(this.s0),i=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(i)-Math.sin(this.ad)*Math.cos(i)*Math.cos(s)),r=Math.asin(Math.cos(i)*Math.sin(s)/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 Np=["Krovak","Krovak Modified","Krovak (North Orientated)","Krovak Modified (North Orientated)","krovak"],wl={init:Ap,forward:Ip,inverse:Op,names:Np};function K(e,t,r,i,s){return e*s-t*Math.sin(2*s)+r*Math.sin(4*s)-i*Math.sin(6*s)}function Yt(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 Zt(e){return .05859375*e*e*(1+.75*e)}function Kt(e){return e*e*e*(35/3072)}function Tr(e,t,r){var i=t*r;return e/Math.sqrt(1-i*i)}function dt(e){return Math.abs(e)<x?e:e-zt(e)*Math.PI}function fe(e,t,r,i,s){var n,o;n=e/t;for(var a=0;a<15;a++)if(o=(e-(t*n-r*Math.sin(2*n)+i*Math.sin(4*n)-s*Math.sin(6*n)))/(t-2*r*Math.cos(2*n)+4*i*Math.cos(4*n)-6*s*Math.cos(6*n)),n+=o,Math.abs(o)<=1e-10)return n;return NaN}function Lp(){this.sphere||(this.e0=Yt(this.es),this.e1=Xt(this.es),this.e2=Zt(this.es),this.e3=Kt(this.es),this.ml0=this.a*K(this.e0,this.e1,this.e2,this.e3,this.lat0))}function Gp(e){var t,r,i=e.x,s=e.y;if(i=S(i-this.long0,this.over),this.sphere)t=this.a*Math.asin(Math.cos(s)*Math.sin(i)),r=this.a*(Math.atan2(Math.tan(s),Math.cos(i))-this.lat0);else{var n=Math.sin(s),o=Math.cos(s),a=Tr(this.a,this.e,n),h=Math.tan(s)*Math.tan(s),c=i*Math.cos(s),l=c*c,u=this.es*o*o/(1-this.es),f=this.a*K(this.e0,this.e1,this.e2,this.e3,s);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 Dp(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,r=e.y/this.a,i,s;if(this.sphere){var n=r+this.lat0;i=Math.asin(Math.sin(n)*Math.cos(t)),s=Math.atan2(Math.tan(t),Math.cos(n))}else{var o=this.ml0/this.a+r,a=fe(o,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(a)-x)<=E)return e.x=this.long0,e.y=x,r<0&&(e.y*=-1),e;var h=Tr(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;i=a-h*Math.tan(a)/c*u*u*(.5-(1+3*l)*u*u/24),s=u*(1-f*(l/3+(1+3*l)*l*f/15))/Math.cos(a)}return e.x=S(s+this.long0,this.over),e.y=dt(i),e}var Bp=["Cassini","Cassini_Soldner","cass"],bl={init:Lp,forward:Gp,inverse:Dp,names:Bp};function mt(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 zp=.3333333333333333,qp=.17222222222222222,Fp=.10257936507936508,kp=.06388888888888888,Up=.0664021164021164,Vp=.016415012942191543;function vr(e){var t,r=[];return r[0]=e*zp,t=e*e,r[0]+=t*qp,r[1]=t*kp,t*=e,r[0]+=t*Fp,r[1]+=t*Up,r[2]=t*Vp,r}function wr(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 Qn=1,Jn=2,to=3,ss=4;function jp(){var e=Math.abs(this.lat0);if(Math.abs(e-x)<E?this.mode=this.lat0<0?Qn:Jn:Math.abs(e)<E?this.mode=to:this.mode=ss,this.es>0){var t;switch(this.qp=mt(this.e,1),this.mmf=.5/(1-this.es),this.apa=vr(this.es),this.mode){case Jn:this.dd=1;break;case Qn:this.dd=1;break;case to:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case ss:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=mt(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===ss&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function Wp(e){var t,r,i,s,n,o,a,h,c,l,u=e.x,f=e.y;if(u=S(u-this.long0,this.over),this.sphere){if(n=Math.sin(f),l=Math.cos(f),i=Math.cos(u),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(r=this.mode===this.EQUIT?1+l*i:1+this.sinph0*n+this.cosph0*l*i,r<=E)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*i}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(i=-i),Math.abs(f+this.lat0)<E)return null;r=G-f*.5,r=2*(this.mode===this.S_POLE?Math.cos(r):Math.sin(r)),t=r*Math.sin(u),r*=i}}else{switch(a=0,h=0,c=0,i=Math.cos(u),s=Math.sin(u),n=Math.sin(f),o=mt(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*i;break;case this.EQUIT:c=1+h*i;break;case this.N_POLE:c=x+f,o=this.qp-o;break;case this.S_POLE:c=f-x,o=this.qp+o;break}if(Math.abs(c)<E)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*i):r=(c=Math.sqrt(2/(1+h*i)))*a*this.ymf,t=this.xmf*c*h*s;break;case this.N_POLE:case this.S_POLE:o>=0?(t=(c=Math.sqrt(o))*s,r=i*(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 Hp(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,r=e.y/this.a,i,s,n,o,a,h,c;if(this.sphere){var l=0,u,f=0;if(u=Math.sqrt(t*t+r*r),s=u*.5,s>1)return null;switch(s=2*Math.asin(s),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(f=Math.sin(s),l=Math.cos(s)),this.mode){case this.EQUIT:s=Math.abs(u)<=E?0:Math.asin(r*f/u),t*=f,r=l*u;break;case this.OBLIQ:s=Math.abs(u)<=E?this.lat0:Math.asin(l*this.sinph0+r*f*this.cosph0/u),t*=f*this.cosph0,r=(l-Math.sin(s)*this.sinph0)*u;break;case this.N_POLE:r=-r,s=x-s;break;case this.S_POLE:s-=x;break}i=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<E)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)}i=Math.atan2(t,r),s=wr(Math.asin(c),this.apa)}return e.x=S(this.long0+i,this.over),e.y=s,e}var $p=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],Pl={init:jp,forward:Wp,inverse:Hp,names:$p,S_POLE:Qn,N_POLE:Jn,EQUIT:to,OBLIQ:ss};function pt(e){return Math.abs(e)>1&&(e=e>1?1:-1),Math.asin(e)}function Yp(){Math.abs(this.lat1+this.lat2)<E||(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=st(this.e3,this.sin_po,this.cos_po),this.qs1=mt(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=st(this.e3,this.sin_po,this.cos_po),this.qs2=mt(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=mt(this.e3,this.sin_po),Math.abs(this.lat1-this.lat2)>E?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 Xp(e){var t=e.x,r=e.y;this.sin_phi=Math.sin(r),this.cos_phi=Math.cos(r);var i=mt(this.e3,this.sin_phi),s=this.a*Math.sqrt(this.c-this.ns0*i)/this.ns0,n=this.ns0*S(t-this.long0,this.over),o=s*Math.sin(n)+this.x0,a=this.rh-s*Math.cos(n)+this.y0;return e.x=o,e.y=a,e}function Zp(e){var t,r,i,s,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),i=1):(t=-Math.sqrt(e.x*e.x+e.y*e.y),i=-1),s=0,t!==0&&(s=Math.atan2(i*e.x,i*e.y)),i=t*this.ns0/this.a,this.sphere?o=Math.asin((this.c-i*i)/(2*this.ns0)):(r=(this.c-i*i)/this.ns0,o=this.phi1z(this.e3,r)),n=S(s/this.ns0+this.long0,this.over),e.x=n,e.y=o,e}function Kp(e,t){var r,i,s,n,o,a=pt(.5*t);if(e<E)return a;for(var h=e*e,c=1;c<=25;c++)if(r=Math.sin(a),i=Math.cos(a),s=e*r,n=1-s*s,o=.5*n*n/i*(t/(1-h)-r/n+.5/e*Math.log((1-s)/(1+s))),a=a+o,Math.abs(o)<=1e-7)return a;return null}var Qp=["Albers_Conic_Equal_Area","Albers_Equal_Area","Albers","aea"],Rl={init:Yp,forward:Xp,inverse:Zp,names:Qp,phi1z:Kp};function Jp(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function tg(e){var t,r,i,s,n,o,a,h,c=e.x,l=e.y;return i=S(c-this.long0,this.over),t=Math.sin(l),r=Math.cos(l),s=Math.cos(i),o=this.sin_p14*t+this.cos_p14*r*s,n=1,o>0||Math.abs(o)<=E?(a=this.x0+this.a*n*r*Math.sin(i)/o,h=this.y0+this.a*n*(this.cos_p14*t-this.sin_p14*r*s)/o):(a=this.x0+this.infinity_dist*r*Math.sin(i),h=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*r*s)),e.x=a,e.y=h,e}function eg(e){var t,r,i,s,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))?(s=Math.atan2(t,this.rc),r=Math.sin(s),i=Math.cos(s),o=pt(i*this.sin_p14+e.y*r*this.cos_p14/t),n=Math.atan2(e.x*r,t*this.cos_p14*i-e.y*this.sin_p14*r),n=S(this.long0+n,this.over)):(o=this.phic0,n=0),e.x=n,e.y=o,e}var rg=["gnom"],Cl={init:Jp,forward:tg,inverse:eg,names:rg};function Al(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*x:x;for(var i=Math.asin(.5*t),s,n,o,a,h=0;h<30;h++)if(n=Math.sin(i),o=Math.cos(i),a=e*n,s=Math.pow(1-a*a,2)/(2*o)*(t/(1-e*e)-n/(1-a*a)+.5/e*Math.log((1-a)/(1+a))),i+=s,Math.abs(s)<=1e-10)return i;return NaN}function ig(){this.sphere||(this.k0=st(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function sg(e){var t=e.x,r=e.y,i,s,n=S(t-this.long0,this.over);if(this.sphere)i=this.x0+this.a*n*Math.cos(this.lat_ts),s=this.y0+this.a*Math.sin(r)/Math.cos(this.lat_ts);else{var o=mt(this.e,Math.sin(r));i=this.x0+this.a*this.k0*n,s=this.y0+this.a*o*.5/this.k0}return e.x=i,e.y=s,e}function ng(e){e.x-=this.x0,e.y-=this.y0;var t,r;return this.sphere?(t=S(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=Al(this.e,2*e.y*this.k0/this.a),t=S(this.long0+e.x/(this.a*this.k0),this.over)),e.x=t,e.y=r,e}var og=["cea"],Il={init:ig,forward:sg,inverse:ng,names:og};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 hg(e){var t=e.x,r=e.y,i=S(t-this.long0,this.over),s=dt(r-this.lat0);return e.x=this.x0+this.a*i*this.rc,e.y=this.y0+this.a*s,e}function cg(e){var t=e.x,r=e.y;return e.x=S(this.long0+(t-this.x0)/(this.a*this.rc),this.over),e.y=dt(this.lat0+(r-this.y0)/this.a),e}var lg=["Equirectangular","Equidistant_Cylindrical","Equidistant_Cylindrical_Spherical","eqc"],Ol={init:ag,forward:hg,inverse:cg,names:lg};var Nl=20;function ug(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=Yt(this.es),this.e1=Xt(this.es),this.e2=Zt(this.es),this.e3=Kt(this.es),this.ml0=this.a*K(this.e0,this.e1,this.e2,this.e3,this.lat0)}function fg(e){var t=e.x,r=e.y,i,s,n,o=S(t-this.long0,this.over);if(n=o*Math.sin(r),this.sphere)Math.abs(r)<=E?(i=this.a*o,s=-1*this.a*this.lat0):(i=this.a*Math.sin(n)/Math.tan(r),s=this.a*(dt(r-this.lat0)+(1-Math.cos(n))/Math.tan(r)));else if(Math.abs(r)<=E)i=this.a*o,s=-1*this.ml0;else{var a=Tr(this.a,this.e,Math.sin(r))/Math.tan(r);i=a*Math.sin(n),s=this.a*K(this.e0,this.e1,this.e2,this.e3,r)-this.ml0+a*(1-Math.cos(n))}return e.x=i+this.x0,e.y=s+this.y0,e}function dg(e){var t,r,i,s,n,o,a,h,c;if(i=e.x-this.x0,s=e.y-this.y0,this.sphere)if(Math.abs(s+this.a*this.lat0)<=E)t=S(i/this.a+this.long0,this.over),r=0;else{o=this.lat0+s/this.a,a=i*i/this.a/this.a+o*o,h=o;var l;for(n=Nl;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)<=E){r=h;break}t=S(this.long0+Math.asin(i*Math.tan(h)/this.a)/Math.sin(r),this.over)}else if(Math.abs(s+this.ml0)<=E)r=0,t=S(this.long0+i/this.a,this.over);else{o=(this.ml0+s)/this.a,a=i*i/this.a/this.a+o*o,h=o;var u,f,m,d,g;for(n=Nl;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),m=this.e0-2*this.e1*Math.cos(2*h)+4*this.e2*Math.cos(4*h)-6*this.e3*Math.cos(6*h),d=f/this.a,c=(o*(u*d+1)-d-.5*u*(d*d+a))/(this.es*Math.sin(2*h)*(d*d+a-2*o*d)/(4*u)+(o-d)*(u*m-2/Math.sin(2*h))-m),h-=c,Math.abs(c)<=E){r=h;break}u=Math.sqrt(1-this.es*Math.pow(Math.sin(r),2))*Math.tan(r),t=S(this.long0+Math.asin(i*u/this.a)/Math.sin(r),this.over)}return e.x=t,e.y=r,e}var mg=["Polyconic","American_Polyconic","poly"],Ll={init:ug,forward:fg,inverse:dg,names:mg};var pg=1;function gg(){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 _g(e){var t,r=e.x,i=e.y,s=i-this.lat0,n=r-this.long0,o=s/he*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,m=0,d,g,_=0,y=0;for(t=1;t<=6;t++)d=f*l-m*u,g=m*l+f*u,f=d,m=g,_=_+this.B_re[t]*f-this.B_im[t]*m,y=y+this.B_im[t]*f+this.B_re[t]*m;return e.x=y*this.a+this.x0,e.y=_*this.a+this.y0,e}function yg(e){var t,r=e.x,i=e.y,s=r-this.x0,n=i-this.y0,o=n/this.a,a=s/this.a,h=1,c=0,l,u,f=0,m=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,m=m+this.C_im[t]*h+this.C_re[t]*c;for(var d=0;d<this.iterations;d++){var g=f,_=m,y,M,T=o,v=a;for(t=2;t<=6;t++)y=g*f-_*m,M=_*f+g*m,g=y,_=M,T=T+(t-1)*(this.B_re[t]*g-this.B_im[t]*_),v=v+(t-1)*(this.B_im[t]*g+this.B_re[t]*_);g=1,_=0;var w=this.B_re[1],b=this.B_im[1];for(t=2;t<=6;t++)y=g*f-_*m,M=_*f+g*m,g=y,_=M,w=w+t*(this.B_re[t]*g-this.B_im[t]*_),b=b+t*(this.B_im[t]*g+this.B_re[t]*_);var R=w*w+b*b;f=(T*w+v*b)/R,m=(v*w-T*b)/R}var I=f,A=m,O=1,N=0;for(t=1;t<=9;t++)O=O*I,N=N+this.D[t]*O;var L=this.lat0+N*he*1e5,H=this.long0+A;return e.x=H,e.y=L,e}var Mg=["New_Zealand_Map_Grid","nzmg"],Gl={init:gg,forward:_g,inverse:yg,names:Mg,iterations:pg};function xg(){}function Sg(e){var t=e.x,r=e.y,i=S(t-this.long0,this.over),s=this.x0+this.a*i,n=this.y0+this.a*Math.log(Math.tan(Math.PI/4+r/2.5))*1.25;return e.x=s,e.y=n,e}function Eg(e){e.x-=this.x0,e.y-=this.y0;var t=S(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 Tg=["Miller_Cylindrical","mill"],Dl={init:xg,forward:Sg,inverse:Eg,names:Tg};var vg=20;function wg(){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 eo(e){var t,r,i=e.x,s=e.y;if(i=S(i-this.long0,this.over),this.sphere){if(!this.m)s=this.n!==1?Math.asin(this.n*Math.sin(s)):s;else for(var n=this.n*Math.sin(s),o=vg;o;--o){var a=(this.m*s+Math.sin(s)-n)/(this.m+Math.cos(s));if(s-=a,Math.abs(a)<E)break}t=this.a*this.C_x*i*(this.m+Math.cos(s)),r=this.a*this.C_y*s}else{var h=Math.sin(s),c=Math.cos(s);r=this.a*qt(s,h,c,this.en),t=this.a*i*c/Math.sqrt(1-this.es*h*h)}return e.x=t,e.y=r,e}function ro(e){var t,r,i,s;return e.x-=this.x0,i=e.x/this.a,e.y-=this.y0,t=e.y/this.a,this.sphere?(t/=this.C_y,i=i/(this.C_x*(this.m+Math.cos(t))),this.m?t=pt((this.m*t+Math.sin(t))/this.n):this.n!==1&&(t=pt(Math.sin(t)/this.n)),i=S(i+this.long0,this.over),t=dt(t)):(t=Be(e.y/this.a,this.es,this.en),s=Math.abs(t),s<x?(s=Math.sin(t),r=this.long0+e.x*Math.sqrt(1-this.es*s*s)/(this.a*Math.cos(t)),i=S(r,this.over)):s-E<x&&(i=this.long0)),e.x=i,e.y=t,e}var bg=["Sinusoidal","sinu"],Bl={init:wg,forward:eo,inverse:ro,names:bg};function Pg(){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 Rg=eo,Cg=ro,Ag=["Eckert_VI","eck6"],zl={init:Pg,forward:Rg,inverse:Cg,names:Ag};function Ig(){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 Og(e){for(var t=e.x,r=e.y,i=S(t-this.long0,this.over),s=r,n=Math.PI*Math.sin(r);;){var o=-(s+Math.sin(s)-n)/(1+Math.cos(s));if(s+=o,Math.abs(o)<E)break}s/=2,Math.PI/2-Math.abs(r)<E&&(i=0);var a=.900316316158*this.a*i*Math.cos(s)+this.x0,h=1.4142135623731*this.a*Math.sin(s)+this.y0;return e.x=a,e.y=h,e}function Ng(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 i=S(this.long0+e.x/(.900316316158*this.a*Math.cos(t)),this.over);i<-Math.PI&&(i=-Math.PI),i>Math.PI&&(i=Math.PI),r=(2*t+Math.sin(2*t))/Math.PI,Math.abs(r)>1&&(r=1);var s=Math.asin(r);return e.x=i,e.y=s,e}var Lg=["Mollweide","moll"],ql={init:Ig,forward:Og,inverse:Ng,names:Lg};function Gg(){Math.abs(this.lat1+this.lat2)<E||(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=Yt(this.es),this.e1=Xt(this.es),this.e2=Zt(this.es),this.e3=Kt(this.es),this.sin_phi=Math.sin(this.lat1),this.cos_phi=Math.cos(this.lat1),this.ms1=st(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)<E?this.ns=this.sin_phi:(this.sin_phi=Math.sin(this.lat2),this.cos_phi=Math.cos(this.lat2),this.ms2=st(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 Dg(e){var t=e.x,r=e.y,i;if(this.sphere)i=this.a*(this.g-r);else{var s=K(this.e0,this.e1,this.e2,this.e3,r);i=this.a*(this.g-s)}var n=this.ns*S(t-this.long0,this.over),o=this.x0+i*Math.sin(n),a=this.y0+this.rh-i*Math.cos(n);return e.x=o,e.y=a,e}function Bg(e){e.x-=this.x0,e.y=this.rh-e.y+this.y0;var t,r,i,s;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 s=S(this.long0+n/this.ns,this.over),i=dt(this.g-r/this.a),e.x=s,e.y=i,e;var o=this.g-r/this.a;return i=fe(o,this.e0,this.e1,this.e2,this.e3),s=S(this.long0+n/this.ns,this.over),e.x=s,e.y=i,e}var zg=["Equidistant_Conic","eqdc"],Fl={init:Gg,forward:Dg,inverse:Bg,names:zg};function qg(){this.R=this.a}function Fg(e){var t=e.x,r=e.y,i=S(t-this.long0,this.over),s,n;if(Math.abs(r)<=E)return s=this.x0+this.R*i,n=this.y0,e.x=s,e.y=n,e;var o=pt(2*Math.abs(r/Math.PI));if(Math.abs(i)<=E||Math.abs(Math.abs(r)-x)<=E)return s=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),e.x=s,e.y=n,e;var a=.5*Math.abs(Math.PI/i-i/Math.PI),h=a*a,c=Math.sin(o),l=Math.cos(o),u=l/(c+l-1),f=u*u,m=u*(2/c-1),d=m*m,g=Math.PI*this.R*(a*(u-d)+Math.sqrt(h*(u-d)*(u-d)-(d+h)*(f-d)))/(d+h);i<0&&(g=-g),s=this.x0+g;var _=h+u;return g=Math.PI*this.R*(m*_-a*Math.sqrt((d+h)*(h+1)-_*_))/(d+h),r>=0?n=this.y0+g:n=this.y0-g,e.x=s,e.y=n,e}function kg(e){var t,r,i,s,n,o,a,h,c,l,u,f,m;return e.x-=this.x0,e.y-=this.y0,u=Math.PI*this.R,i=e.x/u,s=e.y/u,n=i*i+s*s,o=-Math.abs(s)*(1+n),a=o-2*s*s+i*i,h=-2*o+1+2*s*s+n*n,m=s*s/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*m/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(i)<E?t=this.long0:t=S(this.long0+Math.PI*(n-1+Math.sqrt(1+2*(i*i-s*s)+n*n))/2/i,this.over),e.x=t,e.y=r,e}var Ug=["Van_der_Grinten_I","VanDerGrinten","Van_der_Grinten","vandg"],kl={init:qg,forward:Fg,inverse:kg,names:Ug};function Ul(e,t,r,i,s,n){let o=i-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),m=o,d,g=100,_,y,M,T,v,w,b,R,I,A,O,N,L,H;do{if(_=Math.sin(m),y=Math.cos(m),M=Math.sqrt(f*_*(f*_)+(l*u-c*f*y)*(l*u-c*f*y)),M===0)return{azi1:0,s12:0};T=c*u+l*f*y,v=Math.atan2(M,T),w=l*f*_/M,b=1-w*w,R=b!==0?T-2*c*u/b:0,I=n/16*b*(4+n*(4-3*b)),d=m,m=o+(1-I)*n*w*(v+I*M*(R+I*T*(-1+2*R*R)))}while(Math.abs(m-d)>1e-12&&--g>0);return g===0?{azi1:NaN,s12:NaN}:(A=b*(s*s-s*(1-n)*(s*(1-n)))/(s*(1-n)*(s*(1-n))),O=1+A/16384*(4096+A*(-768+A*(320-175*A))),N=A/1024*(256+A*(-128+A*(74-47*A))),L=N*M*(R+N/4*(T*(-1+2*R*R)-N/6*R*(-3+4*M*M)*(-3+4*R*R))),H=s*(1-n)*O*(v-L),{azi1:Math.atan2(f*_,l*u-c*f*y),s12:H})}function Vl(e,t,r,i,s,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,m=1-f*f,d=m*(s*s-s*(1-n)*(s*(1-n)))/(s*(1-n)*(s*(1-n))),g=1+d/16384*(4096+d*(-768+d*(320-175*d))),_=d/1024*(256+d*(-128+d*(74-47*d))),y=i/(s*(1-n)*g),M,T=100,v,w,b,R;do v=Math.cos(2*u+y),w=Math.sin(y),b=Math.cos(y),R=_*w*(v+_/4*(b*(-1+2*v*v)-_/6*v*(-3+4*w*w)*(-3+4*v*v))),M=y,y=i/(s*(1-n)*g)+R;while(Math.abs(y-M)>1e-12&&--T>0);if(T===0)return{lat2:NaN,lon2:NaN};let I=a*w-h*b*l,A=Math.atan2(a*b+h*w*l,(1-n)*Math.sqrt(f*f+I*I)),O=Math.atan2(w*c,h*b-a*w*l),N=n/16*m*(4+n*(4-3*m)),L=O-(1-N)*n*f*(y+N*w*(v+N*b*(-1+2*v*v))),H=t+L;return{lat2:A,lon2:H}}function Vg(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0),this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.f=this.es/(1+Math.sqrt(1-this.es))}function jg(e){var t=e.x,r=e.y,i=Math.sin(e.y),s=Math.cos(e.y),n=S(t-this.long0,this.over),o,a,h,c,l,u,f,m,d,g,_;return this.sphere?Math.abs(this.sin_p12-1)<=E?(e.x=this.x0+this.a*(x-r)*Math.sin(n),e.y=this.y0-this.a*(x-r)*Math.cos(n),e):Math.abs(this.sin_p12+1)<=E?(e.x=this.x0+this.a*(x+r)*Math.sin(n),e.y=this.y0+this.a*(x+r)*Math.cos(n),e):(d=this.sin_p12*i+this.cos_p12*s*Math.cos(n),f=Math.acos(d),m=f?f/Math.sin(f):1,e.x=this.x0+this.a*m*s*Math.sin(n),e.y=this.y0+this.a*m*(this.cos_p12*i-this.sin_p12*s*Math.cos(n)),e):(o=Yt(this.es),a=Xt(this.es),h=Zt(this.es),c=Kt(this.es),Math.abs(this.sin_p12-1)<=E?(l=this.a*K(o,a,h,c,x),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)<=E?(l=this.a*K(o,a,h,c,x),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)<E&&Math.abs(r-this.lat0)<E?(e.x=this.x0,e.y=this.y0,e):(g=Ul(this.lat0,this.long0,r,t,this.a,this.f),_=g.azi1,e.x=this.x0+g.s12*Math.sin(_),e.y=this.y0+g.s12*Math.cos(_),e))}function Wg(e){e.x-=this.x0,e.y-=this.y0;var t,r,i,s,n,o,a,h,c,l,u,f,m,d,g,_;return this.sphere?(t=Math.sqrt(e.x*e.x+e.y*e.y),t>2*x*this.a?void 0:(r=t/this.a,i=Math.sin(r),s=Math.cos(r),n=this.long0,Math.abs(t)<=E?o=this.lat0:(o=pt(s*this.sin_p12+e.y*i*this.cos_p12/t),a=Math.abs(this.lat0)-x,Math.abs(a)<=E?this.lat0>=0?n=S(this.long0+Math.atan2(e.x,-e.y),this.over):n=S(this.long0-Math.atan2(-e.x,e.y),this.over):n=S(this.long0+Math.atan2(e.x*i,t*this.cos_p12*s-e.y*this.sin_p12*i),this.over)),e.x=n,e.y=o,e)):(h=Yt(this.es),c=Xt(this.es),l=Zt(this.es),u=Kt(this.es),Math.abs(this.sin_p12-1)<=E?(f=this.a*K(h,c,l,u,x),t=Math.sqrt(e.x*e.x+e.y*e.y),m=f-t,o=fe(m/this.a,h,c,l,u),n=S(this.long0+Math.atan2(e.x,-1*e.y),this.over),e.x=n,e.y=o,e):Math.abs(this.sin_p12+1)<=E?(f=this.a*K(h,c,l,u,x),t=Math.sqrt(e.x*e.x+e.y*e.y),m=t-f,o=fe(m/this.a,h,c,l,u),n=S(this.long0+Math.atan2(e.x,e.y),this.over),e.x=n,e.y=o,e):(d=Math.atan2(e.x,e.y),g=Math.sqrt(e.x*e.x+e.y*e.y),_=Vl(this.lat0,this.long0,d,g,this.a,this.f),e.x=_.lon2,e.y=_.lat2,e))}var Hg=["Azimuthal_Equidistant","aeqd"],jl={init:Vg,forward:jg,inverse:Wg,names:Hg};function $g(){this.sin_p14=Math.sin(this.lat0||0),this.cos_p14=Math.cos(this.lat0||0)}function Yg(e){var t,r,i,s,n,o,a,h,c=e.x,l=e.y;return i=S(c-(this.long0||0),this.over),t=Math.sin(l),r=Math.cos(l),s=Math.cos(i),o=this.sin_p14*t+this.cos_p14*r*s,n=1,(o>0||Math.abs(o)<=E)&&(a=this.a*n*r*Math.sin(i),h=(this.y0||0)+this.a*n*(this.cos_p14*t-this.sin_p14*r*s)),e.x=a,e.y=h,e}function Xg(e){var t,r,i,s,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=pt(t/this.a),i=Math.sin(r),s=Math.cos(r),h=this.long0||0,c=this.lat0||0,o=h,Math.abs(t)<=E?(a=c,e.x=o,e.y=a,e):(a=pt(s*this.sin_p14+e.y*i*this.cos_p14/t),n=Math.abs(c)-x,Math.abs(n)<=E?(c>=0?o=S(h+Math.atan2(e.x,-e.y),this.over):o=S(h-Math.atan2(-e.x,e.y),this.over),e.x=o,e.y=a,e):(o=S(h+Math.atan2(e.x*i,t*this.cos_p14*s-e.y*this.sin_p14*i),this.over),e.x=o,e.y=a,e))}var Zg=["ortho"],Wl={init:$g,forward:Yg,inverse:Xg,names:Zg};var W={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},B={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function Kg(){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>=x-G/2?this.face=W.TOP:this.lat0<=-(x-G/2)?this.face=W.BOTTOM:Math.abs(this.long0)<=G?this.face=W.FRONT:Math.abs(this.long0)<=x+G?this.face=this.long0>0?W.RIGHT:W.LEFT:this.face=W.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 Qg(e){var t={x:0,y:0},r,i,s,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,i=e.x,this.face===W.TOP)n=x-r,i>=G&&i<=x+G?(h.value=B.AREA_0,s=i-x):i>x+G||i<=-(x+G)?(h.value=B.AREA_1,s=i>0?i-j:i+j):i>-(x+G)&&i<=-G?(h.value=B.AREA_2,s=i+x):(h.value=B.AREA_3,s=i);else if(this.face===W.BOTTOM)n=x+r,i>=G&&i<=x+G?(h.value=B.AREA_0,s=-i+x):i<G&&i>=-G?(h.value=B.AREA_1,s=-i):i<-G&&i>=-(x+G)?(h.value=B.AREA_2,s=-i-x):(h.value=B.AREA_3,s=i>0?-i+j:-i-j);else{var c,l,u,f,m,d,g;this.face===W.RIGHT?i=ke(i,+x):this.face===W.BACK?i=ke(i,+j):this.face===W.LEFT&&(i=ke(i,-x)),f=Math.sin(r),m=Math.cos(r),d=Math.sin(i),g=Math.cos(i),c=m*g,l=m*d,u=f,this.face===W.FRONT?(n=Math.acos(c),s=ns(n,u,l,h)):this.face===W.RIGHT?(n=Math.acos(l),s=ns(n,u,-c,h)):this.face===W.BACK?(n=Math.acos(-c),s=ns(n,u,-l,h)):this.face===W.LEFT?(n=Math.acos(-l),s=ns(n,u,c,h)):(n=s=0,h.value=B.AREA_0)}return a=Math.atan(12/j*(s+Math.acos(Math.sin(s)*Math.cos(G))-x)),o=Math.sqrt((1-Math.cos(n))/(Math.cos(a)*Math.cos(a))/(1-Math.cos(Math.atan(1/Math.cos(s))))),h.value===B.AREA_1?a+=x:h.value===B.AREA_2?a+=j:h.value===B.AREA_3&&(a+=1.5*j),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 Jg(e){var t={lam:0,phi:0},r,i,s,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,i=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=B.AREA_0:e.y>=0&&e.y>=Math.abs(e.x)?(u.value=B.AREA_1,r-=x):e.x<0&&-e.x>=Math.abs(e.y)?(u.value=B.AREA_2,r=r<0?r+j:r-j):(u.value=B.AREA_3,r+=x),l=j/12*Math.tan(r),o=Math.sin(l)/(Math.cos(l)-1/Math.sqrt(2)),a=Math.atan(o),s=Math.cos(r),n=Math.tan(i),h=1-s*s*n*n*(1-Math.cos(Math.atan(1/Math.cos(a)))),h<-1?h=-1:h>1&&(h=1),this.face===W.TOP)c=Math.acos(h),t.phi=x-c,u.value===B.AREA_0?t.lam=a+x:u.value===B.AREA_1?t.lam=a<0?a+j:a-j:u.value===B.AREA_2?t.lam=a-x:t.lam=a;else if(this.face===W.BOTTOM)c=Math.acos(h),t.phi=c-x,u.value===B.AREA_0?t.lam=-a+x:u.value===B.AREA_1?t.lam=-a:u.value===B.AREA_2?t.lam=-a-x:t.lam=a<0?-a-j:-a+j;else{var f,m,d;f=h,l=f*f,l>=1?d=0:d=Math.sqrt(1-l)*Math.sin(a),l+=d*d,l>=1?m=0:m=Math.sqrt(1-l),u.value===B.AREA_1?(l=m,m=-d,d=l):u.value===B.AREA_2?(m=-m,d=-d):u.value===B.AREA_3&&(l=m,m=d,d=-l),this.face===W.RIGHT?(l=f,f=-m,m=l):this.face===W.BACK?(f=-f,m=-m):this.face===W.LEFT&&(l=f,f=m,m=-l),t.phi=Math.acos(-d)-x,t.lam=Math.atan2(m,f),this.face===W.RIGHT?t.lam=ke(t.lam,-x):this.face===W.BACK?t.lam=ke(t.lam,-j):this.face===W.LEFT&&(t.lam=ke(t.lam,+x))}if(this.es!==0){var g,_,y;g=t.phi<0?1:0,_=Math.tan(t.phi),y=this.b/Math.sqrt(_*_+this.one_minus_f_squared),t.phi=Math.atan(Math.sqrt(this.a*this.a-y*y)/(this.one_minus_f*y)),g&&(t.phi=-t.phi)}return t.lam+=this.long0,e.x=t.lam,e.y=t.phi,e}function ns(e,t,r,i){var s;return e<E?(i.value=B.AREA_0,s=0):(s=Math.atan2(t,r),Math.abs(s)<=G?i.value=B.AREA_0:s>G&&s<=x+G?(i.value=B.AREA_1,s-=x):s>x+G||s<=-(x+G)?(i.value=B.AREA_2,s=s>=0?s-j:s+j):(i.value=B.AREA_3,s+=x)),s}function ke(e,t){var r=e+t;return r<-j?r+=te:r>+j&&(r-=te),r}var t2=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],Hl={init:Kg,forward:Qg,inverse:Jg,names:t2};var io=[[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]],br=[[-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]],$l=.8487,Yl=1.3523,Xl=Z/5,e2=1/Xl,Ue=18,os=function(e,t){return e[0]+t*(e[1]+t*(e[2]+t*e[3]))},r2=function(e,t){return e[1]+t*(2*e[2]+t*3*e[3])};function i2(e,t,r,i){for(var s=t;i;--i){var n=e(s);if(s-=n,Math.abs(n)<r)break}return s}function s2(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function n2(e){var t=S(e.x-this.long0,this.over),r=Math.abs(e.y),i=Math.floor(r*Xl);i<0?i=0:i>=Ue&&(i=Ue-1),r=Z*(r-e2*i);var s={x:os(io[i],r)*t,y:os(br[i],r)};return e.y<0&&(s.y=-s.y),s.x=s.x*this.a*$l+this.x0,s.y=s.y*this.a*Yl+this.y0,s}function o2(e){var t={x:(e.x-this.x0)/(this.a*$l),y:Math.abs(e.y-this.y0)/(this.a*Yl)};if(t.y>=1)t.x/=io[Ue][0],t.y=e.y<0?-x:x;else{var r=Math.floor(t.y*Ue);for(r<0?r=0:r>=Ue&&(r=Ue-1);;)if(br[r][0]>t.y)--r;else if(br[r+1][0]<=t.y)++r;else break;var i=br[r],s=5*(t.y-i[0])/(br[r+1][0]-i[0]);s=i2(function(n){return(os(i,n)-t.y)/r2(i,n)},s,E,100),t.x/=os(io[r],s),t.y=(5*r+s)*q,e.y<0&&(t.y=-t.y)}return t.x=S(t.x+this.long0,this.over),t}var a2=["Robinson","robin"],Zl={init:s2,forward:n2,inverse:o2,names:a2};function h2(){this.name="geocent"}function c2(e){var t=Zi(e,this.es,this.a);return t}function l2(e){var t=Ki(e,this.es,this.a,this.b);return t}var u2=["Geocentric","geocentric","geocent","Geocent"],Kl={init:h2,forward:c2,inverse:l2,names:u2};var nt={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3},Pr={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 f2(){if(Object.keys(Pr).forEach((function(r){if(typeof this[r]>"u")this[r]=Pr[r].def;else{if(Pr[r].num&&isNaN(this[r]))throw new Error("Invalid parameter value, must be numeric "+r+" = "+this[r]);Pr[r].num&&(this[r]=parseFloat(this[r]))}Pr[r].degrees&&(this[r]=this[r]*q)}).bind(this)),Math.abs(Math.abs(this.lat0)-x)<E?this.mode=this.lat0<0?nt.S_POLE:nt.N_POLE:Math.abs(this.lat0)<E?this.mode=nt.EQUIT:(this.mode=nt.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 d2(e){e.x-=this.long0;var t=Math.sin(e.y),r=Math.cos(e.y),i=Math.cos(e.x),s,n;switch(this.mode){case nt.OBLIQ:n=this.sinph0*t+this.cosph0*r*i;break;case nt.EQUIT:n=r*i;break;case nt.S_POLE:n=-t;break;case nt.N_POLE:n=t;break}switch(n=this.pn1/(this.p-n),s=n*r*Math.sin(e.x),this.mode){case nt.OBLIQ:n*=this.cosph0*t-this.sinph0*r*i;break;case nt.EQUIT:n*=t;break;case nt.N_POLE:n*=-(r*i);break;case nt.S_POLE:n*=r*i;break}var o,a;return o=n*this.cg+s*this.sg,a=1/(o*this.sw*this.h1+this.cw),s=(s*this.cg-n*this.sg)*this.cw*a,n=o*a,e.x=s*this.a,e.y=n*this.a,e}function m2(e){e.x/=this.a,e.y/=this.a;var t={x:e.x,y:e.y},r,i,s;s=1/(this.pn1-e.y*this.sw),r=this.pn1*e.x*s,i=this.pn1*e.y*this.cw*s,e.x=r*this.cg+i*this.sg,e.y=i*this.cg-r*this.sg;var n=X(e.x,e.y);if(Math.abs(n)<E)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 nt.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 nt.EQUIT:t.y=Math.asin(e.y*a/n),e.y=o*n,e.x*=a;break;case nt.N_POLE:t.y=Math.asin(o),e.y=-e.y;break;case nt.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 p2=["Tilted_Perspective","tpers"],Ql={init:f2,forward:d2,inverse:m2,names:p2};function g2(){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 _2(e){var t=e.x,r=e.y,i,s,n,o;if(t=t-this.long0,this.shape==="ellipse"){r=Math.atan(this.radius_p2*Math.tan(r));var a=this.radius_p/X(this.radius_p*Math.cos(r),Math.sin(r));if(s=a*Math.cos(t)*Math.cos(r),n=a*Math.sin(t)*Math.cos(r),o=a*Math.sin(r),(this.radius_g-s)*s-n*n-o*o*this.radius_p_inv2<0)return e.x=Number.NaN,e.y=Number.NaN,e;i=this.radius_g-s,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/X(o,i)),e.y=this.radius_g_1*Math.atan(o/i)):(e.x=this.radius_g_1*Math.atan(n/i),e.y=this.radius_g_1*Math.atan(o/X(n,i)))}else this.shape==="sphere"&&(i=Math.cos(r),s=Math.cos(t)*i,n=Math.sin(t)*i,o=Math.sin(r),i=this.radius_g-s,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/X(o,i)),e.y=this.radius_g_1*Math.atan(o/i)):(e.x=this.radius_g_1*Math.atan(n/i),e.y=this.radius_g_1*Math.atan(o/X(n,i))));return e.x=e.x*this.a,e.y=e.y*this.a,e}function y2(e){var t=-1,r=0,i=0,s,n,o,a;if(e.x=e.x/this.a,e.y=e.y/this.a,this.shape==="ellipse"){this.flip_axis?(i=Math.tan(e.y/this.radius_g_1),r=Math.tan(e.x/this.radius_g_1)*X(1,i)):(r=Math.tan(e.x/this.radius_g_1),i=Math.tan(e.y/this.radius_g_1)*X(1,r));var h=i/this.radius_p;if(s=r*r+h*h+t*t,n=2*this.radius_g*t,o=n*n-4*s*this.C,o<0)return e.x=Number.NaN,e.y=Number.NaN,e;a=(-n-Math.sqrt(o))/(2*s),t=this.radius_g+a*t,r*=a,i*=a,e.x=Math.atan2(r,t),e.y=Math.atan(i*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?(i=Math.tan(e.y/this.radius_g_1),r=Math.tan(e.x/this.radius_g_1)*Math.sqrt(1+i*i)):(r=Math.tan(e.x/this.radius_g_1),i=Math.tan(e.y/this.radius_g_1)*Math.sqrt(1+r*r)),s=r*r+i*i+t*t,n=2*this.radius_g*t,o=n*n-4*s*this.C,o<0)return e.x=Number.NaN,e.y=Number.NaN,e;a=(-n-Math.sqrt(o))/(2*s),t=this.radius_g+a*t,r*=a,i*=a,e.x=Math.atan2(r,t),e.y=Math.atan(i*Math.cos(e.x)/t)}return e.x=e.x+this.long0,e}var M2=["Geostationary Satellite View","Geostationary_Satellite","geos"],Jl={init:g2,forward:_2,inverse:y2,names:M2};var Rr=1.340264,Cr=-.081106,Ar=893e-6,Ir=.003796,as=Math.sqrt(3)/2;function x2(){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=vr(this.es),this.qp=mt(this.e,1),this.rqda=Math.sqrt(.5*this.qp))}function S2(e){var t=S(e.x-this.long0,this.over),r=e.y,i=Math.sin(r);this.es!==0&&(i=mt(this.e,i)/this.qp);var s=Math.asin(as*i),n=s*s,o=n*n*n;return e.x=t*Math.cos(s)/(as*(Rr+3*Cr*n+o*(7*Ar+9*Ir*n))),e.y=s*(Rr+Cr*n+o*(Ar+Ir*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 E2(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,i=e.y,s,n,o,a,h,c;for(c=0;c<r&&(s=i*i,n=s*s*s,o=i*(Rr+Cr*s+n*(Ar+Ir*s))-e.y,a=Rr+3*Cr*s+n*(7*Ar+9*Ir*s),i-=h=o/a,!(Math.abs(h)<t));++c);return s=i*i,n=s*s*s,e.x=as*e.x*(Rr+3*Cr*s+n*(7*Ar+9*Ir*s))/Math.cos(i),e.y=Math.asin(Math.sin(i)/as),this.es!==0&&(e.y=wr(e.y,this.apa)),e.x=S(e.x+this.long0,this.over),e}var T2=["eqearth","Equal Earth","Equal_Earth"],tu={init:x2,forward:S2,inverse:E2,names:T2};var Or=1e-10;function v2(){var e;if(this.phi1=this.lat1,Math.abs(this.phi1)<Or)throw new Error;this.es?(this.en=De(this.es),this.m1=qt(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=b2,this.forward=w2):(Math.abs(this.phi1)+Or>=x?this.cphi1=0:this.cphi1=1/Math.tan(this.phi1),this.inverse=R2,this.forward=P2)}function w2(e){var t=S(e.x-(this.long0||0),this.over),r=e.y,i,s,n;return i=this.am1+this.m1-qt(r,s=Math.sin(r),n=Math.cos(r),this.en),s=n*t/(i*Math.sqrt(1-this.es*s*s)),e.x=i*Math.sin(s),e.y=this.am1-i*Math.cos(s),e.x=this.a*e.x+(this.x0||0),e.y=this.a*e.y+(this.y0||0),e}function b2(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,r,i,s;if(r=X(e.x,e.y=this.am1-e.y),s=Be(this.am1+this.m1-r,this.es,this.en),(t=Math.abs(s))<x)t=Math.sin(s),i=r*Math.atan2(e.x,e.y)*Math.sqrt(1-this.es*t*t)/Math.cos(s);else if(Math.abs(t-x)<=Or)i=0;else throw new Error;return e.x=S(i+(this.long0||0),this.over),e.y=dt(s),e}function P2(e){var t=S(e.x-(this.long0||0),this.over),r=e.y,i,s;return s=this.cphi1+this.phi1-r,Math.abs(s)>Or?(e.x=s*Math.sin(i=t*Math.cos(r)/s),e.y=this.cphi1-s*Math.cos(i)):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 R2(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,r,i=X(e.x,e.y=this.cphi1-e.y);if(r=this.cphi1+this.phi1-i,Math.abs(r)>x)throw new Error;return Math.abs(Math.abs(r)-x)<=Or?t=0:t=i*Math.atan2(e.x,e.y)/Math.cos(r),e.x=S(t+(this.long0||0),this.over),e.y=dt(r),e}var C2=["bonne","Bonne (Werner lat_1=90)"],eu={init:v2,names:C2};var ru={OBLIQUE:{forward:L2,inverse:D2},TRANSVERSE:{forward:G2,inverse:B2}},hs={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 A2(){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=zn.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=It(e);if(!t)throw new Error("Invalid parameter: o_proj. Unknown projection "+this.o_proj);t.long0=0,this.obliqueProjection=t;let r,i=Object.keys(hs),s=a=>{if(typeof this[a]>"u")return;let h=parseFloat(this[a])*q;if(isNaN(h))throw new Error("Invalid value for "+a+": "+this[a]);return h};for(let a=0;a<i.length;a++){let h=i[a],c=hs[h],l=Object.entries(c);if(l.some(([f])=>typeof this[f]<"u")){r=c;for(let f=0;f<l.length;f++){let[m,d]=l[f],g=s(m);if(typeof g>"u")throw new Error("Missing parameter: "+m+".");this[d]=g}break}}if(!r)throw new Error("No valid parameters provided for ob_tran projection.");let{lamp:n,phip:o}=N2(this,r);this.lamp=n,Math.abs(o)>E?(this.cphip=Math.cos(o),this.sphip=Math.sin(o),this.projectionType=ru.OBLIQUE):this.projectionType=ru.TRANSVERSE}function I2(e){return this.projectionType.forward(this,e)}function O2(e){return this.projectionType.inverse(this,e)}function N2(e,t){let r,i;if(t===hs.ROTATE){let s=e.oLongC,n=e.oLatC,o=e.oAlpha;if(Math.abs(Math.abs(n)-x)<=E)throw new Error("Invalid value for o_lat_c: "+e.o_lat_c+" should be < 90\xB0");i=s+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===hs.NEW_POLE)i=e.oLongP,r=e.oLatP;else{let s=e.oLong1,n=e.oLat1,o=e.oLong2,a=e.oLat2,h=Math.abs(n);if(Math.abs(n)>x-E)throw new Error("Invalid value for o_lat_1: "+e.o_lat_1+" should be < 90\xB0");if(Math.abs(a)>x-E)throw new Error("Invalid value for o_lat_2: "+e.o_lat_2+" should be < 90\xB0");if(Math.abs(n-a)<E)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<E)throw new Error("Invalid value for o_lat_1: o_lat_1 should be different from zero");i=Math.atan2(Math.cos(n)*Math.sin(a)*Math.cos(s)-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(s)),r=Math.atan(-1*Math.cos(i-s)/Math.tan(n))}return{lamp:i,phip:r}}function L2(e,t){let{x:r,y:i}=t;r=S(r-e.long0,e.over);let s=Math.cos(r),n=Math.sin(i),o=Math.cos(i);t.x=S(Math.atan2(o*Math.sin(r),e.sphip*o*s+e.cphip*n)+e.lamp),t.y=Math.asin(e.sphip*n-e.cphip*o*s);let a=e.obliqueProjection.forward(t);return e.isIdentity&&(a.x*=Z,a.y*=Z),a}function G2(e,t){let{x:r,y:i}=t;r=S(r-e.long0,e.over);let s=Math.cos(i),n=Math.cos(r);t.x=S(Math.atan2(s*Math.sin(r),Math.sin(i))+e.lamp),t.y=Math.asin(-1*s*n);let o=e.obliqueProjection.forward(t);return e.isIdentity&&(o.x*=Z,o.y*=Z),o}function D2(e,t){e.isIdentity&&(t.x*=q,t.y*=q);let r=e.obliqueProjection.inverse(t),{x:i,y:s}=r;if(i<Number.MAX_VALUE){i-=e.lamp;let n=Math.cos(i),o=Math.sin(s),a=Math.cos(s);t.x=Math.atan2(a*Math.sin(i),e.sphip*a*n-e.cphip*o),t.y=Math.asin(e.sphip*o+e.cphip*a*n)}return t.x=S(t.x+e.long0),t}function B2(e,t){e.isIdentity&&(t.x*=q,t.y*=q);let r=e.obliqueProjection.inverse(t),{x:i,y:s}=r;if(i<Number.MAX_VALUE){let n=Math.cos(s);i-=e.lamp,t.x=Math.atan2(n*Math.sin(i),-1*Math.sin(s)),t.y=Math.asin(n*Math.cos(i))}return t.x=S(t.x+e.long0),t}var z2=["General Oblique Transformation","General_Oblique_Transformation","ob_tran"],iu={init:A2,forward:I2,inverse:O2,names:z2};function su(e){e.Proj.projections.add(ze),e.Proj.projections.add(qe),e.Proj.projections.add(Ml),e.Proj.projections.add(xl),e.Proj.projections.add(Sl),e.Proj.projections.add(El),e.Proj.projections.add(Tl),e.Proj.projections.add(vl),e.Proj.projections.add(wl),e.Proj.projections.add(bl),e.Proj.projections.add(Pl),e.Proj.projections.add(Rl),e.Proj.projections.add(Cl),e.Proj.projections.add(Il),e.Proj.projections.add(Ol),e.Proj.projections.add(Ll),e.Proj.projections.add(Gl),e.Proj.projections.add(Dl),e.Proj.projections.add(Bl),e.Proj.projections.add(zl),e.Proj.projections.add(ql),e.Proj.projections.add(Fl),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),e.Proj.projections.add(Kl),e.Proj.projections.add(Ql),e.Proj.projections.add(Jl),e.Proj.projections.add(tu),e.Proj.projections.add(eu),e.Proj.projections.add(iu)}var nu=Object.assign(rl,{defaultDatum:"WGS84",Proj:It,WGS84:new It("WGS84"),Point:ll,toPoint:Ne,defs:Ae,nadgrid:Vn,transform:jn,mgrs:al,version:"__VERSION__"});su(nu);var so=nu;var no=so,Ft=class{static defineProjectionAliases(t){for(let r in t)no.defs(r,t[r])}static registerDatumGrid(t,r,i){no.nadgrid(t,r,i)}constructor({from:t="WGS84",to:r="WGS84",enforceAxis:i=!1}){if(this._projection=no(t,r),this._enforceAxis=i,!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 Nr=class extends Error{constructor(t){super(t.message||"CRS is not compatible with proj4js"),this.name="Proj4CRSCompatibilityError",this.compatibility=t}};var q2=new Set(["GeographicCRS","GeodeticCRS","ProjectedCRS","BoundCRS"]);function F2(e){return typeof e=="object"&&e!==null}function cs(e){return typeof e.type=="string"?e.type:void 0}function au(e){return q2.has(e.type)}function hu(e){return au(e)?e.type!=="BoundCRS"||hu(e.source_crs):!1}function ou(e,t,r,i=!1){return{status:"unsupported",checked:!1,lossy:i,type:e,reason:t,message:r}}function k2(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=>hu(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 U2(e,t){if(!F2(e))return{definition:e,lossy:!1};if(au(e))return{definition:e,lossy:!1,type:cs(e)};if(t==="horizontal"&&e.type==="CompoundCRS"){let i=k2(e);if("reason"in i)throw new Nr(ou(cs(e),i.reason,i.message,!0));return{definition:i.definition,lossy:!0,type:cs(e)}}let r=cs(e);throw new Nr(ou(r,"unsupported-crs-type",r?`${r} is not supported by proj4js`:"CRS object has no supported type"))}function oo(e,t){return U2(e,t?.mode||"strict").definition}var V2=[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],j2=372,W2=[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],H2=372,$2=[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],Y2=12,ao=20/2,X2=2,Lr=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 i=Z2(r,360);r=i!==-180?i:180;let s=r*this.options._rlonres,n=-t*this.options._rlatres,o=Math.floor(s),a=Math.min(Math.round((this.options._height-1)/2-1),Math.floor(n));s-=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(ao);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 d=[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=W2;a!==0&&(g=a===this.options._height-2?$2:V2);let _=j2;a!==0&&(_=a===this.options._height-2?H2:240);for(let y=0;y<ao;++y){f[y]=0;for(let M=0;M<Y2;++M)f[y]+=d[M]*g[ao*M+y];f[y]/=_}}if(!this.options.cubic){let d=(1-s)*h+s*c,g=(1-s)*l+s*u,_=(1-n)*d+n*g,y=this.options._offset+this.options._scale*_;return this._ix=o,this._iy=a,this._v00=h,this._v01=c,this._v10=l,this._v11=u,y}let m=f[0]+s*(f[1]+s*(f[3]+s*f[6]))+n*(f[2]+s*(f[4]+s*f[7])+n*(f[5]+s*f[8]+n*f[9]));return m=this.options._offset+this.options._scale*m,this._ix=o,this._iy=a,this._t=f,m}_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 i=this.options._datastart+X2*(r*this.options._swidth+t),s=this.options.data[i],n=this.options.data[i+1];return s<<8|n}};function Z2(e,t){t=Math.abs(t);let r=cu(e,t);return 2*Math.abs(r)===t?r-=cu(e,2*t)-r:2*Math.abs(r)>t&&(r+=r<0?t:-t),r}function cu(e,t){return e-Math.floor(e/t)*t}var K2=10,Q2=65535;function ho(e,t){let r=J2(e),i=r.next();if(i.done||i.value.line!=="P5")throw new Error("Geoid model file: File not in PGM format");let s=Number.MAX_VALUE,n=0,o=-1,a=-1,h="NONE",c="UNKNOWN",l=0,u=0,f=null,m=null;do{i=r.next();let y=i.value.line;if(y.length)if(y[0]==="#"){let M=y.split(" "),T=M[0],v=M[1];if(T!=="#"||!v)continue;let w=M.length>2?M.slice(2):[];if(v==="Description")h=w.join(" ");else if(v==="DateTime")c=w.join(" ");else if(v==="Offset"){if(!M[2])throw new Error("Geoid model file: Error reading offset");s=parseInt(M[2],10)}else if(v==="Scale"){if(!M[2])throw new Error("Geoid model file: Error reading scale");n=parseFloat(M[2])}else v===(t.cubic?"MaxCubicError":"MaxBilinearError")?isFinite(parseFloat(M[2]))&&(o=parseFloat(M[2])):v===(t.cubic?"RMSCubicError":"RMSBilinearError")&&isFinite(parseFloat(M[2]))&&(a=parseFloat(M[2]))}else{let M=y.split(" ");if(M=M.filter(T=>T!==""),l=parseInt(M[0],10),u=parseInt(M[1],10),!(l&&u))throw new Error("Geoid model file: Error reading raster size");break}}while(!i.done);i=r.next();let d=parseInt(i.value.line,10);if(i.done)throw new Error("Geoid model file: Error reading maxval");if(d!==Q2)throw new Error("Geoid model file: Incorrect value of maxval");if(f=i.value.offset,m=l,s===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,_=(u-1)/180;return new Lr({cubic:t.cubic,_width:l,_height:u,_rlonres:g,_rlatres:_,_offset:s,_scale:n,_swidth:m,_datastart:f,_maxerror:o,_rmserror:a,_description:h,_datetime:c,data:e})}function*J2(e){let t=0;do{let r=e.indexOf(K2,t);if(r!==-1){let i=e.subarray(t,r);t=r+1,yield{offset:t,line:lu(i)}}else{let i=e.subarray(t,e.length);t=e.length,yield{offset:t,line:lu(i)}}}while(t<e.length);return{offset:t,line:""}}function lu(e){let t="";for(let r of e)t+=String.fromCharCode(r);return t}var uu=new Map;function fu(e,t){lo(e,"CRS"),Ft.defineProjectionAliases({[e]:t})}function du(e,t){lo(e,"datum grid"),Ft.registerDatumGrid(e,t)}function co(e,t){lo(e,"geoid model"),uu.set(e,t)}function mu(e,t,r={}){let i=ho(t,r);return co(e,i),i}function ls(e){return uu.get(e)}function lo(e,t){if(!e.trim())throw new Error(`${t} name must not be empty`)}var bt=class{spatialReference;horizontalProjection;geographicProjection;heightOutputProjection;sourceIsGeocentric;outputIsGeocentric;sourceIsGeographic;outputIsGeographic;geoid;constructor(t,r={}){this.spatialReference=t,r_(t);let i=t.targetCrs||t.sourceCrs;if(this.sourceIsGeocentric=uo(t.sourceCrs),this.outputIsGeocentric=uo(i),this.sourceIsGeographic=pu(t.sourceCrs),this.outputIsGeographic=pu(i),t.sourceCrs&&t.targetCrs&&!this.sourceIsGeocentric&&!this.outputIsGeocentric&&(this.horizontalProjection=new Ft({from:us(t.sourceCrs),to:us(t.targetCrs),enforceAxis:!1})),(Gr(t)||this.sourceIsGeocentric||this.outputIsGeocentric)&&(!this.sourceIsGeographic&&!this.sourceIsGeocentric&&(this.geographicProjection=new Ft({from:us(t.sourceCrs),to:we,enforceAxis:!1})),!this.outputIsGeographic&&!this.outputIsGeocentric&&(this.heightOutputProjection=new Ft({from:we,to:us(i),enforceAxis:!1}))),Gr(t)&&(this.geoid=i_(r.geoidModel),!this.geoid)){let s=typeof r.geoidModel=="string"?` "${r.geoidModel}"`:"";throw new Error(`Height conversion requires a registered geoid model${s}; 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(Gr(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 i=this.toGeographic(r);if(Gr(this.spatialReference)){let n=this.geoid.getHeight(i[1],i[0]);i[2]=s_(i[2],n,this.spatialReference.heightReference,this.spatialReference.targetHeightReference)}let s=this.fromGeographic(i);return r.splice(0,s.length,...s),r}if(this.horizontalProjection){let i=this.horizontalProjection.project(r.slice(0,3));r.splice(0,i.length,...i)}return r}transformPositions(t){if(t.length%3!==0)throw new Error("Packed spatial positions must contain a multiple of three components");let r=new Float64Array(t.length);for(let i=0;i<t.length;i+=3){let s=this.transformPosition([Number(t[i]),Number(t[i+1]),Number(t[i+2])]);r[i]=s[0],r[i+1]=s[1],r[i+2]=s[2]}return r}transformNormals(t,r){if(t.length!==r.length||t.length%3!==0)throw new Error("Spatial normals and positions must have matching xyz component counts");let i=new Float32Array(t.length),s=1e-5;for(let n=0;n<t.length;n+=3){let o=[Number(r[n]),Number(r[n+1]),Number(r[n+2])],a=[Number(t[n]),Number(t[n+1]),Number(t[n+2])],h=t_(this,o,s),c=e_(h,a),l=Math.hypot(...c);l>0&&Number.isFinite(l)?(i[n]=c[0]/l,i[n+1]=c[1]/l,i[n+2]=c[2]/l):(i[n]=a[0],i[n+1]=a[1],i[n+2]=a[2])}return i}toGeographic(t){return this.sourceIsGeocentric?Array.from(P.WGS84.cartesianToCartographic(new p(t))):this.sourceIsGeographic?t.slice(0,3):this.geographicProjection.project(t.slice(0,3))}fromGeographic(t){return this.outputIsGeocentric?Array.from(P.WGS84.cartographicToCartesian(new p(t))):this.outputIsGeographic?t.slice(0,3):this.heightOutputProjection.project(t.slice(0,3))}};function t_(e,t,r){let i=[];for(let s=0;s<3;s++){let n=t.slice(),o=t.slice();n[s]+=r,o[s]-=r;let a=e.transformPosition(n),h=e.transformPosition(o);i.push([(a[0]-h[0])/(2*r),(a[1]-h[1])/(2*r),(a[2]-h[2])/(2*r)])}return i}function e_(e,t){let[r,i,s]=e,n=r[0]*(i[1]*s[2]-i[2]*s[1])-i[0]*(r[1]*s[2]-r[2]*s[1])+s[0]*(r[1]*i[2]-r[2]*i[1]);return!Number.isFinite(n)||Math.abs(n)<1e-15?t:[[i[1]*s[2]-i[2]*s[1],r[2]*s[1]-r[1]*s[2],r[1]*i[2]-r[2]*i[1]],[i[2]*s[0]-i[0]*s[2],r[0]*s[2]-r[2]*s[0],r[2]*i[0]-r[0]*i[2]],[i[0]*s[1]-i[1]*s[0],r[1]*s[0]-r[0]*s[1],r[0]*i[1]-r[1]*i[0]]].map(a=>(a[0]*t[0]+a[1]*t[1]+a[2]*t[2])/n)}function us(e){if(!e)throw new Error("Cannot construct a projection because the CRS is unknown");return oo(e,{mode:"horizontal"})}function r_(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(Gr(e)&&e.heightReference==="unknown")throw new Error("Cannot convert heights because the source height reference is unknown");if(e.coordinateFrame==="geocentric"&&!uo(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 uo(e){return typeof e=="string"&&fr(e)===Gi}function pu(e){if(typeof e!="string")return!1;let t=fr(e);return t===we||t==="EPSG:4979"||t==="OGC:CRS84"}function Gr(e){let t=e.targetHeightReference;return t!=="native"&&t!==e.heightReference}function i_(e){return typeof e=="string"?ls(e):e}function s_(e,t,r,i){if(r===i||i==="native")return e;if(r==="orthometric"&&i==="ellipsoidal")return e+t;if(r==="ellipsoidal"&&i==="orthometric")return e-t;throw new Error(`Unsupported height conversion from ${r} to ${i}`)}var re=class{spatialReference;coordinateTransformer;geographicCoordinateTransformer;constructor(t,r={}){this.coordinateTransformer=new bt(t,r);let i={...t,sourceCrs:"EPSG:4326",targetCrs:t.targetCrs||t.sourceCrs,coordinateFrame:"geographic",axisOrder:"xy"};this.geographicCoordinateTransformer=new bt(i,r),this.spatialReference=t}transformPositions(t){return this.coordinateTransformer.transformPositions(t)}transformNormals(t,r){return this.coordinateTransformer.transformNormals(t,r)}transformBoundingVolume(t,r){let i=r?new C(Array.from(r)):void 0,s=t.region?n_(t.region):o_(t).map(o=>i?Array.from(i.transformAsPoint(o)):o);if(!s.length)return t;let n=t.region?s.map(o=>this.transformRegionSample(o)):s.map(o=>this.coordinateTransformer.transformPosition(o));return{box:a_(n)}}transformRegionSample(t){let[r,i,s]=t,n=this.spatialReference.targetCrs||this.spatialReference.sourceCrs;if(n&&ht(n)==="geocentric"){let o=P.WGS84.cartographicToCartesian([r,i,s]);return Array.from(o)}return this.geographicCoordinateTransformer.transformPosition(t)}};function n_(e){if(e.length<6||e.some(u=>!Number.isFinite(u)))return[];let[t,r,i,s,n,o]=e,a=i<t?i+Math.PI*2:i,h=gu(t,a),c=gu(r,s),l=[];for(let u of h)for(let f of c)for(let m of[n,o])l.push([u*180/Math.PI,f*180/Math.PI,m]);return l}function gu(e,t){let r=[e,(e+t)/2,t],i=Math.PI/2,s=Math.ceil(e/i),n=Math.floor(t/i);for(let o=s;o<=n;o++)r.push(o*i);return r}function o_(e){if(e.box&&e.box.length>=12){let t=e.box.slice(0,3),r=[e.box.slice(3,6),e.box.slice(6,9),e.box.slice(9,12)],i=[];for(let s=0;s<=4;s++)for(let n=0;n<=4;n++)for(let o=0;o<=4;o++){let a=s/2-1,h=n/2-1,c=o/2-1;i.push([t[0]+a*r[0][0]+h*r[1][0]+c*r[2][0],t[1]+a*r[0][1]+h*r[1][1]+c*r[2][1],t[2]+a*r[0][2]+h*r[1][2]+c*r[2][2]])}return i}if(e.sphere&&e.sphere.length>=4){let[t,r,i,s]=e.sphere,n=[[t-s,r,i],[t+s,r,i],[t,r-s,i],[t,r+s,i],[t,r,i-s],[t,r,i+s]];for(let o=0;o<16;o++){let a=o*Math.PI*2/16;n.push([t+s*Math.cos(a),r+s*Math.sin(a),i])}return n}return[]}function a_(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 i=[Math.max((r[0]-t[0])*.01,1e-9),Math.max((r[1]-t[1])*.01,1e-9),Math.max((r[2]-t[2])*.01,1e-9)];return[...[(t[0]+r[0])/2,(t[1]+r[1])/2,(t[2]+r[2])/2],(r[0]-t[0])/2+i[0],0,0,0,(r[1]-t[1])/2+i[1],0,0,0,(r[2]-t[2])/2+i[2]]}function _u(e,t){let r=e.map(([h,c])=>[h,c]);if(r.length===0)return r;let i=1/0,s=-1/0;for(let[h]of e)i=Math.min(i,h),s=Math.max(s,h);if(s-i>=360)return r;let n=t??r[0][0];for(let h of r){let c=h[0]-n;c>180?h[0]-=360*Math.ceil((c-180)/360):c<-180&&(h[0]+=360*Math.ceil((-c-180)/360)),n=h[0]}let o=e[0],a=e[e.length-1];if(o[0]===a[0]&&o[1]===a[1]){if(Math.abs(r[r.length-1][0]-r[0][0])>180)return e.map(([h,c])=>[h,c]);r[r.length-1]=[...r[0]]}return r}function h_(e){let t=1/0,r=1/0,i=-1/0,s=-1/0;for(let[n,o]of e)t=Math.min(t,n),r=Math.min(r,o),i=Math.max(i,n),s=Math.max(s,o);return[[t,r],[i,s]]}function yu(e){let t=(r,i)=>{let s=e.cellToBoundary(r);return i?.unwrap?_u(s,i.referenceLongitude):s};return{...e,cellToBoundary:t,cellToBoundaryFlat:(r,i)=>i?.unwrap?t(r,i).flat():e.cellToBoundaryFlat(r),cellToBounds:(r,i)=>{let s=e.cellToBounds(r);if(!i?.unwrap||s[1][0]-s[0][0]>=360)return s;let n=h_(t(r,i));return n[0][1]=s[0][1],n[1][1]=s[1][1],n}}}var c_=(1n<<64n)-1n,l_=0x1555555555555555n;function Ve(e){if(e==="X")return 0n;if(!Mu(e))throw new Error(`Invalid S2 token: ${e}`);let t=e.padEnd(16,"0");return BigInt(`0x${t}`)}function Dr(e){if(e===0n)return"X";if(!je(e))throw new Error(`Invalid S2 index: ${e}`);let t=u_(e),r=t%4;t=(t-r)/4;let i=t;t*=4;let n=(e>>BigInt(t)).toString(16).replace(/0+$/,"");return Array(17-i-n.length).join("0")+n}function je(e){if(typeof e!="bigint"||e<=0n||e>c_)return!1;let t=e>>61n,r=e&-e;return t<6n&&(r&l_)!==0n}function Mu(e){if(typeof e!="string"||!/^[0-9a-fA-F]{1,16}$/.test(e)||e.endsWith("0"))return!1;let t=e.padEnd(16,"0");return je(BigInt(`0x${t}`))}function u_(e){let t=0;for(;e%2n===0n;)e/=2n,t++;return t}function We(e){if(!je(e))throw new Error(`Invalid S2 index: ${e}`);let t=g_(e);return p_(t)}var f_=3,fo=30,d_=2*fo+1,xu=180/Math.PI,m_={a:[[0,"d"],[1,"a"],[3,"b"],[2,"a"]],b:[[2,"b"],[1,"b"],[3,"a"],[0,"c"]],c:[[2,"c"],[3,"d"],[1,"c"],[0,"b"]],d:[[0,"a"],[3,"c"],[1,"d"],[2,"d"]]};function p_(e){if(!/^[0-5]\/[0-3]{0,30}$/.test(e))throw new Error(`Invalid S2 Hilbert quadkey: ${e}`);let t=e.split("/"),r=parseInt(t[0],10),i=t[1]||"",s=i.length,n=0,o=[0,0];for(let a=s-1;a>=0;a--){n=s-a;let h=i[a],c=0,l=0;h==="1"?l=1:h==="2"?(c=1,l=1):h==="3"&&(c=1);let u=Math.pow(2,n-1);__(u,o,c,l),o[0]+=u*c,o[1]+=u*l}if(r%2===1){let a=o[0];o[0]=o[1],o[1]=a}return{face:r,ij:o,level:n}}function g_(e){if(!je(e))throw new Error(`Invalid S2 index: ${e}`);let t=e.toString(2);for(;t.length<f_+d_;)t="0"+t;let r=t.lastIndexOf("1"),i=t.substring(0,3),s=t.substring(3,r),n=s.length/2,o=BigInt(`0b${i}`).toString(10),a="";if(n!==0)for(a=BigInt(`0b${s}`).toString(4);a.length<n;)a="0"+a;return`${o}/${a}`}function Eu(e){let{face:t,ij:r,level:i}=e;if(!Number.isInteger(t)||t<0||t>5)throw new Error(`Invalid S2 face: ${t}`);if(!Number.isInteger(i)||i<0||i>fo)throw new Error(`Invalid S2 level: ${i}`);let s=2**i;if(!Number.isInteger(r[0])||!Number.isInteger(r[1])||r[0]<0||r[1]<0||r[0]>=s||r[1]>=s)throw new Error(`Invalid S2 IJ coordinates: ${r[0]}, ${r[1]}`);let n=y_(r[0],r[1],i,t),o=BigInt(t)<<61n;for(let a=0;a<n.length;a++){let h=59-a*2;o|=BigInt(n[a])<<BigInt(h)}return o|=1n<<BigInt(60-i*2),o}function mo(e,t,r,i){let s=We(e);if(!Number.isInteger(t)||t<0||s.level+t>fo)throw new Error(`Invalid S2 relative level: ${t}`);let n=2**t;if(!Number.isInteger(r)||!Number.isInteger(i)||r<0||i<0||r>=n||i>=n)throw new Error(`Invalid S2 descendant coordinates: ${r}, ${i}`);return Eu({face:s.face,ij:[s.ij[0]*n+r,s.ij[1]*n+i],level:s.level+t})}function Br(e,t,r){let i=1<<t;return[(e[0]+r[0])/i,(e[1]+r[1])/i]}function Su(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function zr(e){return[Su(e[0]),Su(e[1])]}function qr(e,[t,r]){switch(e){case 0:return[1,t,r];case 1:return[-t,1,r];case 2:return[-t,-r,1];case 3:return[-1,-r,-t];case 4:return[r,-1,-t];case 5:return[r,t,-1];default:throw new Error("Invalid face")}}function Fr([e,t,r]){let i=Math.atan2(r,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*xu,i*xu]}function __(e,t,r,i){if(i===0){r===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let s=t[0];t[0]=t[1],t[1]=s}}function y_(e,t,r,i){let s=i%2===1?"d":"a",n=[];for(let o=r-1;o>=0;o--){let a=1<<o,h=(e&a)!==0?1:0,c=(t&a)!==0?1:0,[l,u]=m_[s][h*2+c];n.push(l),s=u}return n}var M_=100;function Tu(e){let t=We(e);return x_(t)}function x_({face:e,ij:t,level:r}){let i=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(M_*Math.pow(2,-r))),n=new Float64Array(4*s*2+2),o=0,a=0;for(let h=0;h<4;h++){let c=i[h].slice(0),l=i[h+1],u=(l[0]-c[0])/s,f=(l[1]-c[1])/s;for(let m=0;m<s;m++){c[0]+=u,c[1]+=f;let d=Br(t,r,c),g=zr(d),_=qr(e,g),y=Fr(_);Math.abs(y[1])>89.999&&(y[0]=a);let M=y[0]-a;y[0]+=M>180?-360:M<-180?360:0,n[o++]=y[0],n[o++]=y[1],a=y[0]}}return n[o++]=n[0],n[o++]=n[1],n}var S_=yu({name:"s2",hasNumericRepresentation:!0,cellColumnNames:["s2","s2Token","s2_token","s2Cell","s2_cell","s2CellId","s2_cell_id"],tokenToCell:e=>Ve(e),cellToToken:e=>Dr(ds(e)),cellToLngLat:e=>vu(e),cellToBoundary:e=>E_(e),cellToBoundaryFlat:e=>po(e),cellToBounds:e=>fs(e)});function vu(e){let t=ds(e),r=We(t),i=Br(r.ij,r.level,[.5,.5]),s=zr(i),n=qr(r.face,s);return Fr(n)}function po(e){let t=ds(e),r=Tu(t);return Array.from(r)}function E_(e){let t=po(e),r=[];for(let i=0;i<t.length;i+=2)r.push([t[i],t[i+1]]);return r}function fs(e){let t=We(ds(e));if(t.level===0)return T_(t.face);let r=[[0,0],[0,1],[1,1],[1,0]],i=1/0,s=1/0,n=-1/0,o=-1/0,a;for(let c of r){let l=Br(t.ij,t.level,c),u=zr(l),[f,m,d]=qr(t.face,u),[g,_]=Fr([f,m,d]);if(f===0&&m===0&&a!==void 0&&(g=a),a!==void 0){let y=g-a;g+=y>180?-360:y<-180?360:0}a=g,i=Math.min(i,g),s=Math.min(s,_),n=Math.max(n,g),o=Math.max(o,_)}let h=2*Number.EPSILON*180/Math.PI;return[[i-h,Math.max(-90,s-h)],[n+h,Math.min(90,o+h)]]}function ds(e){return typeof e=="bigint"?e:Ve(e)}function T_(e){let t=Math.asin(Math.sqrt(.3333333333333333))*180/Math.PI;switch(e){case 0:return[[-45,-45],[45,45]];case 1:return[[45,-45],[135,45]];case 2:return[[-180,t],[180,90]];case 3:return[[135,-45],[225,45]];case 4:return[[-135,-45],[-45,45]];case 5:return[[-180,-90],[180,-t]];default:throw new Error(`Invalid S2 face: ${e}`)}}function ms(e){let[[t,r],[i,s]]=fs(e.token),n=ir([t,r,i,s,e.minimumHeight,e.maximumHeight],P.WGS84,{units:"degrees"});return[...n.center,...n.halfAxes]}var v_=4,w_=8,wu=new WeakMap;function _o(e,t){return{coordinates:t,subtreeUrl:Ur(e.subtreesUrlTemplate,t),descriptor:e,resource:Nu(e.resourceFiles,Ur(e.subtreesUrlTemplate,t))}}function ps(e,t){let{descriptor:r}=t;N_(r),b_(e,r);let i={tileCount:0,childSubtreeCount:0},s=Ou(e,t,{localLevel:0,mortonIndex:0},t.coordinates,i);if(!s)throw new Error(`Invalid 3D Tiles subtree: root tile is unavailable at ${t.subtreeUrl}`);return{root:s,...i}}function b_(e,t){let r=Bu(t.subdivisionScheme),i=(r**t.subtreeLevels-1)/(r-1),s=r**t.subtreeLevels;go(e.tileAvailability,i,"tile");let n=Array.isArray(e.contentAvailability)?e.contentAvailability:e.contentAvailability?[e.contentAvailability]:[];for(let h of n)go(h,i,"content");go(e.childSubtreeAvailability,s,"child subtree");let o=bu(e.tileAvailability,i),a=n[0]?bu(n[0],i):0;if(Pu(e.tileAttributes,o,"tile"),Pu(e.contentAttributes,a,"content"),e.tilePropertyRows&&e.tilePropertyRows.length!==o)throw new Error("3DTILES_subtree: tile property-table count does not match availability");if(e.contentPropertyRows&&e.contentPropertyRows.length!==a)throw new Error("3DTILES_subtree: content property-table count does not match availability")}function go(e,t,r){if(!(e.constant===0||e.constant===1)&&(!e.explicitBitstream||e.explicitBitstream.byteLength*8<t))throw new Error(`3DTILES_subtree: ${r} availability bitstream is too short`)}function bu(e,t){if(e.constant===1)return t;if(e.constant===0)return 0;let r=0;for(let i=0;i<t;i++)He(e,i)&&r++;return r}function Pu(e,t,r){let i={TILE_BOUNDING_BOX:16,TILE_BOUNDING_SPHERE:4,TILE_GEOMETRIC_ERROR:1,TILE_REFINE:1,TILE_TRANSFORM:16,CONTENT_BOUNDING_BOX:16,CONTENT_BOUNDING_SPHERE:4};for(let[s,n]of Object.entries(e||{})){let o=i[s];if(o&&n.length!==t*o)throw new Error(`3DTILES_subtree: ${r} attribute ${s} count does not match availability`)}}function Ur(e,t,r={}){let i={level:t.level,x:t.x,y:t.y,z:t.z,...r};return e.replace(/{([^{}]+)}/g,(s,n)=>{let o=Object.hasOwn(i,n)?i[n]:i[n.toLowerCase()];return o===void 0?s:String(o)})}function Ou(e,t,r,i,s){let{descriptor:n}=t,o=Bu(n.subdivisionScheme),a=A_(o,r.localLevel)+r.mortonIndex;if(!He(e.tileAvailability,a))return null;s.tileCount++;let h=C_(e.contentAvailability,a),c=[];if(i.level<n.maximumLevel)if(r.localLevel+1<n.subtreeLevels)for(let l=0;l<o;l++){let u=Au(i,l,n.subdivisionScheme),f=Ou(e,t,{localLevel:r.localLevel+1,mortonIndex:r.mortonIndex*o+l},u,s);f&&c.push(f)}else for(let l=0;l<o;l++){let u=r.mortonIndex*o+l;if(He(e.childSubtreeAvailability,u)){let f=Au(i,l,n.subdivisionScheme);c.push(P_(e,n,f)),s.childSubtreeCount++}}return R_(e,n,t,i,a,h,c)}function P_(e,t,r){let i=Lu(t.resourceFiles,e.resourceFiles),s=i?{...t,resourceFiles:i}:t,n=_o(s,r);return{id:Du(n,r),children:[],implicitSubtree:n,boundingVolume:zu(t.rootBoundingVolume,r,t.subdivisionScheme),geometricError:t.rootLodMetricValue/2**r.level,lodMetricType:t.lodMetricType,lodMetricValue:t.rootLodMetricValue/2**r.level,refine:t.refine,type:Dt.EMPTY,implicitMetadata:Gu(e),_scaleGeometricError:t.scaleGeometricError!==!1}}function Ru(e,t,r){if(!e||t<0)return{};let i=kr(e[r==="tile"?"TILE_BOUNDING_BOX":"CONTENT_BOUNDING_BOX"],t,16),s=kr(e[r==="tile"?"TILE_BOUNDING_SPHERE":"CONTENT_BOUNDING_SPHERE"],t,4),n=i?{box:[i[12],i[13],i[14],i[0]/2,i[1]/2,i[2]/2,i[4]/2,i[5]/2,i[6]/2,i[8]/2,i[9]/2,i[10]/2]}:s?{sphere:s}:void 0;if(r==="content")return{boundingVolume:n};let o=kr(e.TILE_GEOMETRIC_ERROR,t,1)?.[0];if(o!==void 0&&(!Number.isFinite(o)||o<0))throw new Error("3DTILES_subtree: TILE_GEOMETRIC_ERROR must be nonnegative");let a=kr(e.TILE_REFINE,t,1)?.[0];if(a!==void 0&&a!==0&&a!==1)throw new Error("3DTILES_subtree: TILE_REFINE must be 0 or 1");return{boundingVolume:n,geometricError:o,refine:a===void 0?void 0:a===0?$.ADD:$.REPLACE,transform:kr(e.TILE_TRANSFORM,t,16)}}function kr(e,t,r){if(!e)return;let i=t*r;if(i+r>e.length)throw new Error("3DTILES_subtree: attribute accessor is shorter than availability");return Array.from({length:r},(s,n)=>Number(e[i+n]))}function Cu(e,t){if(e.constant===1)return t;if(e.constant===0)return 0;let r=wu.get(e);if(!r){let i=(e.explicitBitstream?.byteLength||0)*8;r=new Uint32Array(i+1);for(let s=0;s<i;s++)r[s+1]=r[s]+Number(He(e,s));wu.set(e,r)}return r[t]}function Nu(e,t){if(!e?.length)return;let r=t.split("?")[0],i=/^gltf-package:\/\/[^/]+\/(.*)$/.exec(r)?.[1],s=e.findIndex(o=>{let a=o.originalUri||o.name;return o.uri===r||!!(a&&(r===a||i===a))});if(s>=0)return{fileIndex:s,files:e};let n=e.findIndex(o=>{let a=o.originalUri||o.name;return!!(a&&(r.endsWith(`/${a}`)||r.endsWith(`:${a}`)))});return n<0?void 0:{fileIndex:n,files:e}}function Lu(e,t){if(!t?.length)return e;if(!e?.length)return t;let r=new Set(t.flatMap(i=>[i.uri,i.originalUri,i.name].filter(Boolean)));return[...t,...e.filter(i=>![i.uri,i.originalUri,i.name].some(s=>s&&r.has(s)))]}function R_(e,t,r,i,s,n,o){let a=Cu(e.tileAvailability,s),h=e.tilePropertyRows?.[a],c=Array.isArray(e.contentAvailability)?e.contentAvailability[0]:e.contentAvailability,l=c&&He(c,s)?Cu(c,s):-1,u=e.contentPropertyRows?.[l],f=e.tileTemplatePropertyRows?.[a]||h,m=e.contentTemplatePropertyRows?.[l]||u,d={...f,...m},g=Ru(e.tileAttributes,a,"tile"),_=Ru(e.contentAttributes,l,"content"),M=(t.contentUrlTemplates?.length?t.contentUrlTemplates:[t.contentUrlTemplate]).map((O,N)=>{if(!n[N]||!O)return null;let L=Ur(O,i,d);if(/{[^{}]+}/.test(L))throw new Error(`Implicit content URI has unresolved template values: ${L}`);return{contentIndex:N,contentUrl:L}}).filter(O=>!!O),T=M.map(O=>O.contentUrl),v=Lu(t.resourceFiles,e.resourceFiles),w=M.map(({contentIndex:O,contentUrl:N})=>{let L=Nu(v,N);return{...t.contentHeaders?.[O]||(O===0?t.contentHeader:{})||{},..._,uri:N,...u?{metadata:{properties:u}}:{},...L?{_resource:L}:{}}}),b=T[0],R=t.rootLodMetricValue/2**i.level,I=g.geometricError??R,A=zu(t.rootBoundingVolume,i,t.subdivisionScheme);return{id:Du(r,i),children:o,contentUrl:b,content:w.length>1?w:w[0],contents:t.useCanonicalContents&&w.length?w:void 0,contentUrls:T,refine:g.refine||t.refine,type:O_(b),lodMetricType:t.lodMetricType,lodMetricValue:I,geometricError:I,boundingVolume:g.boundingVolume||A,transform:g.transform,transformMatrix:g.transform,metadata:h?{properties:h}:void 0,implicitMetadata:Gu(e,h,u),_scaleGeometricError:t.scaleGeometricError!==!1}}function Gu(e,t,r){if(!(!e.propertyTables&&e.tileMetadata===void 0&&!e.contentMetadata&&e.subtreeMetadata===void 0&&!t&&!r))return{propertyTables:e.propertyTables,tileMetadata:e.tileMetadata,contentMetadata:e.contentMetadata,subtreeMetadata:e.subtreeMetadata,tileProperties:t,contentProperties:r}}function Du(e,t){return`${e.subtreeUrl}#implicit=${t.level}/${t.x}/${t.y}/${t.z}`}function He(e,t){if(typeof e?.constant=="number")return!!e.constant;let r=e?.explicitBitstream;if(!r)return!1;let i=Math.floor(t/8),s=t%8;return!!(r[i]>>s&1)}function C_(e,t){return(Array.isArray(e)?e:[e]).map(i=>He(i||{constant:0},t))}function A_(e,t){return(e**t-1)/(e-1)}function Au(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 Bu(e){return e==="OCTREE"?w_:v_}function zu(e,t,r){if(e.region){let[i,s,n,o,a,h]=e.region,c=2**t.level,u=(n>=i?n-i:n+2*Math.PI-i)/c,f=(o-s)/c,m=Iu(i+u*t.x),d=Iu(i+u*(t.x+1)),g=s+f*t.y,_=a,y=h;if(r==="OCTREE"){let M=(h-a)/c;_=a+M*t.z,y=_+M}return{region:[m,g,d,g+f,_,y]}}if(e.box){if(e.s2VolumeInfo)return I_(e,t,r);if(e.extensions?.["3DTILES_shape_cylinder_region"])return{...e,box:[...e.box]};let i=e.box,s=2**t.level,n=-1+(2*t.x+1)/s,o=-1+(2*t.y+1)/s,a=-1+(2*t.z+1)/s,h=r==="OCTREE";return{box:[...[i[0]+i[3]*n+i[6]*o+(h?i[9]*a:0),i[1]+i[4]*n+i[7]*o+(h?i[10]*a:0),i[2]+i[5]*n+i[8]*o+(h?i[11]*a:0)],i[3]/s,i[4]/s,i[5]/s,i[6]/s,i[7]/s,i[8]/s,h?i[9]/s:i[9],h?i[10]/s:i[10],h?i[11]/s:i[11]]}}throw new Error(`Unsupported implicit 3D Tiles bounding volume: ${JSON.stringify(e)}`)}function I_(e,t,r){let i=e.s2VolumeInfo,s=Ve(i.token),n=mo(s,t.level,t.x,t.y),o=2**t.level,a=(i.maximumHeight-i.minimumHeight)/o,h={token:Dr(n),minimumHeight:i.minimumHeight+(r==="OCTREE"?a*t.z:0),maximumHeight:i.minimumHeight+(r==="OCTREE"?a*(t.z+1):a*o)},c=e.extensions?{...e.extensions}:void 0;return c?.["3DTILES_bounding_volume_S2"]&&(c["3DTILES_bounding_volume_S2"]=h),c?.["3DTILES_shape_s2"]&&(c["3DTILES_shape_s2"]=h),{...e,...c?{extensions:c}:{},s2VolumeInfo:h,box:ms(h)}}function Iu(e){let t=e;for(;t>Math.PI;)t-=2*Math.PI;for(;t<-Math.PI;)t+=2*Math.PI;return t}function O_(e){if(!e)return Dt.EMPTY;let t=e.split("?")[0].split(".").pop()?.toLowerCase();switch(t){case"pnts":return Dt.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Dt.SCENEGRAPH;default:return t||Dt.EMPTY}}function N_(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 L_={draco:!1,meshopt:!1,dds:!1,ktx2:!1},G_=32,gs=class{type=at.TILES3D;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...L_};asset;properties;extras;credits;metadata;queryParams={};tileUrlCache=new Map;tileContentHeaders=new WeakMap;packageNamespaces=new WeakMap;nextPackageNamespace=0;implicitSubtreeCache;implicitTilingStats={requestedSubtrees:0,loadedSubtrees:0,cacheHits:0,materializedTiles:0};destroyed=!1;extensionsUsed=[];resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(t,r={}){let i=D_(t);this.rootTileset=qu(t)?null:t,this.tileset=this.rootTileset,this.loader=i.loader,this.url=i.url,this.basePath=i.basePath||_t.dirname(i.url),this.resolver=i.resolver,this.coreApi=i.coreApi,this.loadOptions=r;let s=Number(r["3d-tiles"]?.maximumCachedSubtrees),n=Number.isFinite(s)?Math.max(0,Math.floor(s)):G_;this.implicitSubtreeCache=new nr({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,i]of t.entries())this.setQueryParameter(r,i)}if(this.asset=this.rootTileset.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.rootTileset.formatVersion!=="2.0-draft"&&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 0.0, 1.0, 1.1, or 2.0-draft.");"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:ji(this.rootTileset)}}getMetadata(){if(!this.metadata)throw new Error("Tiles3DSource 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]||"3D Tiles spatial operations cannot be resolved from the supplied metadata and options");r.status!=="transformable"&&r.status!=="transformed"||(this.spatialTransformer||=new re(r,t.options.spatial),t.spatialReference=be(r),this.preparedRootHeader=this.transformTileHeader(this.getMetadata().tileset.root,new C))}initializeTileHeaders(t,r,i){let s=i?r.root:this.preparedRootHeader||r.root,n=new vt(t,s,i||void 0);i&&(i.children.push(n),n.depth=i.depth+1);let o=[n];for(;o.length>0;){let a=o.pop();t.stats.get("Tiles In Tileset(s)").incrementCount();let h=a.header.children||[];for(let c of h){let l=new vt(t,c,a);if(l.contentUrl?.includes("?session=")){let f=new URL(l.contentUrl).searchParams.get("session");f&&this.setQueryParameter("session",f)}a.children.push(l),l.depth=a.depth+1,o.push(l)}}return n}createTraverser(t){return new Ui(t)}async loadTileContent(t){let r=(t.contentUrls||[t.contentUrl]).filter(Boolean),i=this.tileContentHeaders.get(t),s=i||(Array.isArray(t.header?.content)?t.header.content:t.header?.content?[t.header.content]:[]);i||this.tileContentHeaders.set(t,s);let n=this.loadOptions[this.loader.id]||{},o={...this.loadOptions,[this.loader.id]:{...n,isTileset:"auto",assetGltfUpAxis:this.asset&&this.asset.gltfUpAxis||"Y",_tilesetOptions:{spatialReference:t.header?._spatialReference||t.tileset?.spatialReference,spatialOptions:t.tileset?.options.spatial,spatialTransform:t.header?._spatialTransform}}},a=await Promise.all(r.map((c,l)=>{let u=s[l]||{},f=u.extensions?.["3DTILES_content_gltf_vector"],m=u._vectorContent||(f?.vector===!0?{clip:f.clip===!0}:void 0),d=m?{...o,[this.loader.id]:{...o[this.loader.id],vectorContent:m}}:o;return this.loadContentResource(this.getTileUrl(c),u._resource,d)}));t.contents=a,t.content=a[0]||null;let h=a.filter(c=>c?.shape==="tileset3d");return{loaded:!0,contents:a,nestedTileset:h[0],nestedTilesets:h}}transformTileHeader(t,r=new C){return this.spatialTransformer?this.transformTileHeaderWithTransformer(t,this.spatialTransformer,r):t}transformTileHeaderWithTransformer(t,r,i,s){let n=t.transform?new C(t.transform):new C,o=new C(i).multiplyRight(n),a=Array.isArray(t.content)?t.content.map(h=>this.transformContentHeader(h,o,r)):t.content?this.transformContentHeader(t.content,o,r):t.content;return{...t,transform:void 0,boundingVolume:t.boundingVolume?r.transformBoundingVolume(t.boundingVolume,o):t.boundingVolume,_spatialReference:s,_spatialTransform:o.toArray(),content:a,children:Array.isArray(t.children)?t.children.map(h=>this.transformTileHeaderWithTransformer(h,r,o,s)):t.children}}transformContentHeader(t,r,i){return{...t,boundingVolume:t.boundingVolume?i.transformBoundingVolume(t.boundingVolume,r):t.boundingVolume}}async loadTileChildren(t,r){let i=t.header.implicitSubtree;if(!i)return{loaded:!1,tileCount:0,childSubtreeCount:0};let s=this.getTileUrl(i.subtreeUrl),n=await this.loadImplicitSubtreeResource(s,i.resource);if(this.destroyed||t.isDestroyed())return{loaded:!1,tileCount:0,childSubtreeCount:0};let o=ps(n,{...i,subtreeUrl:s}),a=t.header._spatialReference,h=a?new re(a,t.tileset.options.spatial):this.spatialTransformer,c=h?this.transformTileHeaderWithTransformer(o.root,h,new C,a):o.root;t.applyImplicitSubtreeHeader(c);let l=this.initializeMaterializedChildren(t.tileset,t,c.children);return this.implicitTilingStats.loadedSubtrees++,this.implicitTilingStats.materializedTiles+=l,{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[i,s=""]=t.split("?"),n=new URLSearchParams(s);for(let[h,c]of Object.entries(this.queryParams))n.has(h)||n.set(h,c);let o=n.toString(),a=o?`${i}?${o}`:i;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,i;return r&&(r[0]!==0||r[1]!==0||r[2]!==0)?(i=new p,P.WGS84.cartesianToCartographic(r,i)):i=new p(0,0,-P.WGS84.radii[0]),{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits,boundingVolume:t.boundingVolume,cartographicCenter:i,cartesianCenter:r,zoom:sc(t.boundingVolume,i)}}hasExtension(t){return this.extensionsUsed.includes(t)}onTileLoaded(t,r,i){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=i.nestedTilesets||(i.nestedTileset?[i.nestedTileset]:[]);for(let a of o)t._initializeTileHeaders(this.prepareNestedTileset(t,a),r)}prepareNestedTileset(t,r){let i=r.spatialMetadata,s=t.spatialReference;if(i?.status==="unresolved"||i?.crs.state==="unknown")throw new Error(i.warnings[0]||"Nested 3D Tiles CRS is explicitly unresolved and cannot be placed in the parent frame");if(!i||!i.sourceCrs)return this.spatialTransformer&&(s.status==="transformable"||s.status==="transformed")?{...r,spatialMetadata:s,root:this.transformTileHeaderWithTransformer(r.root,this.spatialTransformer,new C,s)}:yo(r,s);let n=s.coordinateEpoch,o=i.coordinateEpoch;if(n!==void 0&&o!==void 0&&n!==o)throw new Error(`Nested 3D Tiles coordinate epoch ${o} differs from parent epoch ${n}; epoch-aware transformation is unavailable`);let a=s.targetCrs||s.sourceCrs;if(!a)return yo(r,i);let h=ae(i,{...t.options.spatial,outputCoordinates:"target-crs",targetCrs:a});if(h.status==="unresolved")throw new Error(h.warnings[0]||"Nested 3D Tiles CRS cannot be resolved in the parent output frame");if(h.status==="native")return yo(r,h);let c=new re(h,t.options.spatial);return{...r,spatialMetadata:h,root:this.transformTileHeaderWithTransformer(r.root,c,new C,h)}}async loadWithCoreApi(t,r,i=this.loader){if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to load tileset data");return await this.coreApi.load(t,i,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,i=this.loader){return this.resolver?await this.resolver.loadResource(t,i,r):await this.loadWithCoreApi(t,r,i)}async loadContentResource(t,r,i){if(!r)return await this.loadResourceData(t,i);let s=r.files[r.fileIndex];if(!s)throw new Error(`3D Tiles package references missing file ${r.fileIndex}`);if(s.uri)return await this.loadResourceData(this.getTileUrl(s.uri),i);if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to parse embedded package data");let n=await this.getPackageFileData(s),a=`gltf-package://${this.getPackageNamespace(r.files)}/${r.fileIndex}`,h=s.name||"content",c=h.lastIndexOf("/"),l=c>=0?`${a}/${h.slice(0,c)}`:a;return await this.coreApi.parse(n,this.loader,i,{url:`${a}/${h}`,filename:h,baseUrl:l,loaders:[this.loader],coreApi:this.coreApi,_parse:this.coreApi.parse,_tiles3dPackageFiles:r.files,fetch:async(u,f)=>{let m=u.startsWith(`${a}/`)?u.slice(a.length+1):u,d=r.files.find(_=>_.name===m||_.originalUri===m);if(!d)throw new Error(`3D Tiles glTF package does not contain file ${m}`);if(d.uri)return await this.coreApi.fetchFile(this.getTileUrl(d.uri),f);let g=await this.getPackageFileData(d);return new Response(g,{headers:{"content-type":d.mimeType}})}})}getPackageNamespace(t){let r=this.packageNamespaces.get(t);if(r!==void 0)return r;let i=this.nextPackageNamespace++;return this.packageNamespaces.set(t,i),i}async getPackageFileData(t){if(t.data)return yi(t.data,t.byteOffset,t.byteLength);if(t.bufferUri&&this.coreApi){let r=await this.coreApi.fetchFile(this.getTileUrl(t.bufferUri));if(!r.ok)throw new Error(`Failed to fetch 3D Tiles package buffer: HTTP ${r.status}`);let i=await r.arrayBuffer();return yi(i,t.byteOffset,t.byteLength)}throw new Error("3D Tiles package file has no available byte source")}async loadImplicitSubtreeResource(t,r){let i=this.implicitSubtreeCache.get(t);if(i)return this.implicitTilingStats.cacheHits++,await i;this.implicitTilingStats.requestedSubtrees++;let s=this.loadOptions[this.loader.id]||{};return await this.implicitSubtreeCache.getOrLoad(t,async()=>{let n={...this.loadOptions,[this.loader.id]:{...s,isTileset:!1,isSubtree:!0}};return await(r?this.loadContentResource(t,r,n):this.loadResourceData(t,n))})}initializeMaterializedChildren(t,r,i){let s=0,n=[{parentTile:r,childHeaders:i}];for(;n.length>0;){let o=n.pop();for(let a of o.childHeaders){let h=new vt(t,a,o.parentTile);o.parentTile.children.push(h),h.depth=o.parentTile.depth+1,t.stats.get("Tiles In Tileset(s)").incrementCount(),s++,a.children?.length&&n.push({parentTile:h,childHeaders:a.children})}}return s}};function qu(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function D_(e){return qu(e)?{...e,basePath:e.basePath||_t.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||_t.dirname(e.url),resolver:e.resolver,coreApi:e.coreApi}}function yo(e,t){let r=i=>({...i,_spatialReference:t,children:Array.isArray(i.children)?i.children.map(r):i.children});return{...e,spatialMetadata:t,root:r(e.root)}}var _s=class{frameNumberMap=new Map;register(t,r){let i=this.frameNumberMap.get(t)||new Map,s=i.get(r)||0;i.set(r,s+1),this.frameNumberMap.set(t,i)}deregister(t,r){let i=this.frameNumberMap.get(t);if(!i)return;let s=i.get(r)||1;i.set(r,s-1)}isZero(t,r){return(this.frameNumberMap.get(t)?.get(r)||0)===0}};var Mo={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},ys=class{_statusMap;pendingTilesRegister=new _s;constructor(){this._statusMap={}}add(t,r,i,s){if(!this._statusMap[r]){let{frameNumber:n,viewport:{id:o}}=s;this._statusMap[r]={request:t,callback:i,key:r,frameState:s,status:Mo.REQUESTED},this.pendingTilesRegister.register(o,n),t().then(a=>{this._statusMap[r].status=Mo.COMPLETED;let{frameNumber:h,viewport:{id:c}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(c,h),this._statusMap[r].callback(a,s)}).catch(a=>{this._statusMap[r].status=Mo.ERROR;let{frameNumber:h,viewport:{id:c}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(c,h),i(a)})}}update(t,r){if(this._statusMap[t]){let{frameNumber:i,viewport:{id:s}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(s,i);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 Ms=class extends Bt{_tileManager;constructor(t){super(t),this._tileManager=new ys}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,r){return t._lodJudge=ki(t,r),t._lodJudge==="DIG"}updateChildTiles(t,r){let i=t.header.children||[],s=t.children;for(let n of i){let o=`${n.id}-${r.viewport.id}`,a=s&&s.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,i){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,i)}_onTileLoad(t,r,i){if(t instanceof Error){r.tileset._onSourceError(t,r);return}let s=new vt(r.tileset,t,r,i);r.children.push(s);let n=this._tileManager.find(s.id).frameState;this.updateTile(s,n),this._frameNumber===n.frameNumber&&(this.traversalFinished(n)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(s,n)}};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 i=t.targetCrs||t.sourceCrs;if(!i)throw new Error("I3S spatial transformation requires a target CRS");if(this.positionTransformer=new bt(t,r),this.sourceCoordinateFrame=t.coordinateFrame,this.sourceVerticalUnitScale=t.verticalUnitScale,this.elevationMode=t.elevationMode,this.elevationOffset=(t.elevationOffset||0)*t.elevationUnitScale,this.elevationProvider=B_(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 s=pr(this.elevationProvider?.unit||"meter");if(this.elevationProvider&&s===void 0)throw new Error(`Unsupported elevation-provider unit ${this.elevationProvider.unit}`);this.providerUnitScale=s||1,this.targetCoordinateFrame=ht(i),this.spatialReference=be(t);let n=yt({sourceCrs:t.sourceCrs,heightReference:t.heightReference,coordinateFrame:t.coordinateFrame,axisOrder:t.axisOrder,provenance:t.provenance},{targetCrs:"EPSG:4326"});if(this.sourceToGeographicTransformer=new bt(n),$e(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=yt({sourceCrs:"EPSG:4326",heightReference:a,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"caller-override"},{targetCrs:"EPSG:4326",targetHeightReference:t.heightReference,geoidModel:r.geoidModel});this.providerHeightTransformer=new bt(h,r)}}let o=yt({sourceCrs:"EPSG:4326",heightReference:t.heightReference,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"format-default"},{targetCrs:i,targetHeightReference:t.targetHeightReference,geoidModel:r.geoidModel});this.geographicToTargetTransformer=new bt(o,r)}transformPosition(t){let r=this.placeSourcePositionsSync(t),i=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[i[0],i[1],i[2]]}async transformPositionAsync(t){let r=await this.placeSourcePositions(t),i=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[i[0],i[1],i[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),i=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[i[0],i[1],i[2]]}async transformSourcePositionToGeographicAsync(t){let r=await this.placeSourcePositions(t),i=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[i[0],i[1],i[2]]}transformPositions(t,r){let i=this.placeSourcePositionsSync(t),s=this.placeSourcePositionsSync(r);return this.transformPlacedPositions(i,s)}async transformPositionsAsync(t,r){let i=new Float64Array(t.length+3);i.set(Array.from(t),0),i.set(Array.from(r).slice(0,3),t.length);let s=await this.placeSourcePositions(i);return this.transformPlacedPositions(s.subarray(0,t.length),s.subarray(t.length))}transformPlacedPositions(t,r){let i=this.transformPlacedPosition(r),s=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]]);s[h]=c[0]-i[0],s[h+1]=c[1]-i[1],s[h+2]=c[2]-i[2]}let o=this.targetCoordinateFrame==="geographic",a=o?new C:new C().translate(i);return{positions:s,sourcePositions:n,origin:i,cartographicOrigin:o?i:[0,0,0],coordinateSystem:o?"lnglat-offsets":"cartesian",modelMatrix:a}}transformNormals(t,r,i="earth-centered"){let s=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 p([t[n],t[n+1],t[n+2]]).normalize(),h=i==="earth-centered"?a:ju(a,o),c=this.transformEcefNormal(h,o);s.set(c,n)}return s}transformBoundingVolume(t){let i=this.getGeographicBoundSamples(t).map(s=>this.geographicToTargetTransformer.transformPosition(s));return this.targetCoordinateFrame==="geographic"?{region:ie(i)}:{box:de(i)}}async transformBoundingVolumeAsync(t){let i=(await this.getGeographicBoundSamplesAsync(t)).map(s=>this.geographicToTargetTransformer.transformPosition(s));return this.targetCoordinateFrame==="geographic"?{region:ie(i)}:{box:de(i)}}transformBoundingVolumeToGeographic(t){return{region:ie(this.getGeographicBoundSamples(t))}}async transformBoundingVolumeToGeographicAsync(t){return{region:ie(await this.getGeographicBoundSamplesAsync(t))}}transformBoundingVolumeToGeocentric(t){let r=this.getGeographicBoundSamples(t).map(i=>Array.from(P.WGS84.cartographicToCartesian(new p(i))));return{box:de(r)}}async transformBoundingVolumeToGeocentricAsync(t){let r=(await this.getGeographicBoundSamplesAsync(t)).map(i=>Array.from(P.WGS84.cartographicToCartesian(new p(i))));return{box:de(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 i=this.placeSourcePositionsSync(r),s=this.sourceToGeographicTransformer.transformPosition(Array.from(i)),n=t.mbs?.length?t.mbs[3]:Math.hypot(...Array.from(t.obb.halfSize).slice(0,3));return[s[0],s[1],s[2],n]}async transformBoundingSphereToGeographicAsync(t){return Fu(await this.getGeographicBoundSamplesAsync(t))}async transformBoundsAsync(t){let r=await this.getGeographicBoundSamplesAsync(t),i=r.map(n=>Array.from(P.WGS84.cartographicToCartesian(new p(n)))),s=r.map(n=>this.geographicToTargetTransformer.transformPosition(n));return{boundingVolume:{box:de(i)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ie(s)}:{box:de(s)},i3sLodMbs:$e(this.elevationMode)?Fu(r):this.transformBoundingSphereToGeographic(t)}}async transformPointCloudBoundsAsync(t){let r=await this.getGeographicBoundSamplesAsync(t),i=r.map(s=>this.geographicToTargetTransformer.transformPosition(s));return{boundingVolume:{region:ie(r)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ie(i)}:{box:de(i)}}}getGeographicBoundSamples(t){let r=ku(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let i=this.placeSourcePositionsSync(r.flat(),!0),s=xo(i);return this.sourceCoordinateFrame==="geographic"?s:s.map(n=>this.sourceToGeographicTransformer.transformPosition(n))}async getGeographicBoundSamplesAsync(t){let r=ku(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");if($e(this.elevationMode)){let s=this.sourceCoordinateFrame==="geographic"?r:r.map(n=>this.sourceToGeographicTransformer.transformPosition(n));return await this.placeGeographicBoundSamples(s)}let i=xo(await this.placeSourcePositions(r.flat(),!0));return this.sourceCoordinateFrame==="geographic"?i:i.map(s=>this.sourceToGeographicTransformer.transformPosition(s))}async placeGeographicBoundSamples(t){let i=await this.elevationProvider.getElevationRange(z_(t)),s=i.minimum*this.providerUnitScale,n=i.maximum*this.providerUnitScale;if(!Number.isFinite(s)||!Number.isFinite(n)||s>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,s])[2]:s,m=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([l,u,n])[2]:n,d=Math.min(f,m),g=Math.max(f,m),_=this.elevationMode==="onTheGround"?d:d+a+this.elevationOffset,y=this.elevationMode==="onTheGround"?g:g+h+this.elevationOffset;c.push([l,u,_],[l,u,y])}return c}placeSourcePositionsSync(t,r=!1){if($e(this.elevationMode))throw new Error(`I3S elevation mode ${this.elevationMode} requires asynchronous surface placement`);let i=Float64Array.from(t),s=this.elevationMode==="absoluteHeight"?this.elevationOffset:0;for(let n=2;n<i.length;n+=3)i[n]=i[n]*(r?1:this.sourceVerticalUnitScale)+s;return i}async placeSourcePositions(t,r=!1){if(!$e(this.elevationMode))return this.placeSourcePositionsSync(t,r);let i=Float64Array.from(t),s=xo(i).map(o=>{let a=this.sourceToGeographicTransformer.transformPosition(o);return[a[0],a[1]]}),n=await this.elevationProvider.sampleElevations(s);if(n.length!==s.length)throw new Error(`Elevation provider returned ${n.length} heights for ${s.length} positions`);for(let o=0;o<s.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]=s[o],l=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([h,c,a])[2]:a,u=i[o*3+2]*(r?1:this.sourceVerticalUnitScale);i[o*3+2]=this.elevationMode==="onTheGround"?l:l+u+this.elevationOffset}return i}transformEcefNormal(t,r){if(this.targetCoordinateFrame==="geocentric")return t.normalize();if(this.targetCoordinateFrame==="geographic")return F_(t,r).normalize();let i=P.WGS84.cartographicToCartesian(new p(r)),s=[];for(let o of q_()){let a=P.WGS84.cartesianToCartographic(new p(i).add(o)),h=P.WGS84.cartesianToCartographic(new p(i).subtract(o)),c=this.geographicToTargetTransformer.transformPosition(a),l=this.geographicToTargetTransformer.transformPosition(h);s.push((c[0]-l[0])/2,(c[1]-l[1])/2,(c[2]-l[2])/2)}let n=new k(s);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 p(t).transformByMatrix3(n).normalize()}};function B_(e,t){return e==="relativeToScene"?t.sceneElevationProvider:$e(e)?t.terrainElevationProvider:void 0}function $e(e){return e==="onTheGround"||e==="relativeToGround"||e==="relativeToScene"}function xo(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 z_(e){let t=ie(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 Fu(e){if(!e.length)throw new Error("I3S spatial transformation requires at least one bound sample");let t=e.map(n=>P.WGS84.cartographicToCartesian(new p(n))),r=new p;for(let n of t)r.add(n);r.scale(1/t.length);let i=0;for(let n of t)i=Math.max(i,new p(n).subtract(r).magnitude());let s=P.WGS84.cartesianToCartographic(r);return[s[0],s[1],s[2],i]}function ku(e,t,r,i){let s=e.obb;if(s){let h=Array.from(s.center).slice(0,3);h[2]*=i;let c=Array.from(s.halfSize).slice(0,3),l=new Et().fromArray(Array.from(s.quaternion)),u=[new p([c[0],0,0]).transformByQuaternion(l),new p([0,c[1],0]).transformByQuaternion(l),new p([0,0,c[2]]).transformByQuaternion(l)];if(t==="geographic"){let f=r.transformPosition(h),m=P.WGS84.cartographicToCartesian(new p(f)),d=e.normalReferenceFrame==="vertex-reference-frame"?u.map(g=>ju(g,f)):u;return Uu().map(g=>{let _=new p(m);for(let y=0;y<3;y++)_.add(new p(d[y]).scale(g[y]));return Array.from(P.WGS84.cartesianToCartographic(_))})}return Uu().map(f=>{let m=new p(h);for(let d=0;d<3;d++)m.add(new p(u[d]).scale(f[d]));return Array.from(m)})}let n=e.mbs?Array.from(e.mbs):[];if(n.length<4)return[];let o=n.slice(0,3);o[2]*=i;let a=n[3];if(t==="geographic"){let h=r.transformPosition(o),c=P.WGS84.cartographicToCartesian(new p(h));return Vu().map(l=>Array.from(P.WGS84.cartesianToCartographic(new p(c).add(new p(l).scale(a)))))}return Vu().map(h=>Array.from(new p(o).add(new p(h).scale(a))))}function Uu(){return[-1,1].flatMap(e=>[-1,1].flatMap(t=>[-1,1].map(r=>[e,t,r])))}function Vu(){return[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]]}function q_(){return[new p([1,0,0]),new p([0,1,0]),new p([0,0,1])]}function ju(e,t){let r=t[0]*Math.PI/180,i=t[1]*Math.PI/180,s=new p([-Math.sin(r),Math.cos(r),0]),n=new p([-Math.sin(i)*Math.cos(r),-Math.sin(i)*Math.sin(r),Math.cos(i)]),o=new p([Math.cos(i)*Math.cos(r),Math.cos(i)*Math.sin(r),Math.sin(i)]);return s.scale(e[0]).add(n.scale(e[1])).add(o.scale(e[2]))}function F_(e,t){let r=t[0]*Math.PI/180,i=t[1]*Math.PI/180,s=new p([-Math.sin(r),Math.cos(r),0]),n=new p([-Math.sin(i)*Math.cos(r),-Math.sin(i)*Math.sin(r),Math.cos(i)]),o=new p([Math.cos(i)*Math.cos(r),Math.cos(i)*Math.sin(r),Math.sin(i)]);return new p([s.dot(e),n.dot(e),o.dot(e)])}function de(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 i=t.map((n,o)=>(n+r[o])/2),s=t.map((n,o)=>(r[o]-n)/2);return[i[0],i[1],i[2],s[0],0,0,0,s[1],0,0,0,s[2]]}function ie(e){let t=e[0][0],r=1/0,i=-1/0,s=1/0,n=-1/0,o=1/0,a=-1/0;for(let h of e){let c=t+So(h[0]-t);r=Math.min(r,c),i=Math.max(i,c),s=Math.min(s,h[1]),n=Math.max(n,h[1]),o=Math.min(o,h[2]),a=Math.max(a,h[2])}return[So(r)*Math.PI/180,s*Math.PI/180,So(i)*Math.PI/180,n*Math.PI/180,o,a]}function So(e){return((e+180)%360+360)%360-180}var k_={draco:!1,meshopt:!1,dds:!1,ktx2:!1},xs=class{type=at.I3S;loader;contentLoader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...k_};asset;properties;extras;credits;metadata;queryParams={};resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(t,r={}){let i=V_(t);this.rootTileset=Wu(t)?null:t,this.tileset=this.rootTileset,this.loader=i.loader,this.contentLoader=U_(i.loader),this.url=i.url,this.basePath=i.basePath||_t.dirname(i.url),this.resolver=i.resolver,this.coreApi=i.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:Vi(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,i){let s=i?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 vt(t,s,i||void 0);return i&&(i.children.push(n),n.depth=i.depth+1),n}createTraverser(t){return new Ms(t)}async loadTileContent(t){let r=this.getTileUrl(t.contentUrl),i=this.loader.id,s=this.loadOptions[i]||{},n=this.getMetadata(),o={...this.loadOptions,[i]:{...s,...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,this.contentLoader),{loaded:!0}}async loadChildTileHeader(t,r,i){let s=this.getMetadata();if(s.tileset.nodePages||s.tileset.pointNodePages){let c=await s.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 i=t.slice(r+1),s=new Set(i.split("&").map(a=>a.split("=",1)[0])),n=new URLSearchParams;for(let[a,h]of Object.entries(this.queryParams))s.has(a)||n.set(a,h);let o=n.toString();return o?`${t}${i?"&":""}${o}`:t}getViewState(t){if(this.spatialTransformer&&t){let n=new p(t.boundingVolume.center),o=new p(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(),i=r.tileset.fullExtent;if(i){let{xmin:n,xmax:o,ymin:a,ymax:h,zmin:c,zmax:l}=i,u=new p(n+(o-n)/2,a+(h-a)/2,c+(l-c)/2),f=new p;return P.WGS84.cartographicToCartesian(u,f),{cartographicCenter:u,cartesianCenter:f,zoom:In(i,u,f)}}let s=r.tileset.store?.extent;if(s){let[n,o,a,h]=s,c=new p(n+(a-n)/2,o+(h-o)/2,0),l=new p;return P.WGS84.cartographicToCartesian(c,l),{cartographicCenter:c,cartesianCenter:l,zoom:nc(s,c,l)}}return console.warn("Extent is not defined in the tileset header"),{cartographicCenter:new p,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,i=this.loader){if(!this.coreApi)throw new Error("I3SSource requires an injected coreApi to load tileset data");return await this.coreApi.load(t,i,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 i=r.token;typeof i=="string"&&(this.queryParams.token=i)}}async loadResourceData(t,r,i=this.loader){return this.resolver?await this.resolver.loadResource(t,i,r):await this.loadWithCoreApi(t,r,i)}async transformTileHeader(t){if(!this.spatialTransformer)return t;let r={mbs:t.mbs,obb:t.obb,normalReferenceFrame:this.getMetadata().tileset.store?.normalReferenceFrame},i=await this.spatialTransformer.transformBoundsAsync(r);return{...t,boundingVolume:i.boundingVolume,spatialBoundingVolume:i.spatialBoundingVolume,i3sLodMbs:i.i3sLodMbs}}};function U_(e){return e.contentLoader||e}function Wu(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function V_(e){return Wu(e)?{...e,basePath:e.basePath||_t.dirname(e.url)}:{url:e.url,loader:e.loader,basePath:e.basePath||_t.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:i,onError:s}){let n=(_,y,M)=>{if(M===this._loaderId){if(this._loader=void 0,this.content=_,this.error=y?j_(y):null,this._isCancelled&&!_){this._isLoaded=!1;return}if(this._isLoaded=!0,this._isCancelled=!1,y){s(y,this);return}i(this)}},{index:o,id:a,bbox:h,userData:c,zoom:l}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:f}=this._abortController,m=await r.scheduleRequest(this,()=>1);if(!m){this._isCancelled=!0;return}if(this._isCancelled){m.done();return}let d=null,g;try{d=await t({index:o,id:a,bbox:h,userData:c,zoom:l,signal:f})}catch(_){g=_||!0}finally{m.done()}n(d,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 j_(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}var Eo="never",To="no-overlap",jr="best-available",Hu={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:jr,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},Vr=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={...Hu,...t,getTileData:t.getTileData||(()=>null),tileSource:t.tileSource},this._requestScheduler=new Vt({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||jr}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,i=this.opts.debounceTime;this._applyResolvedOptions(),(r!==this.opts.maxRequests||i!==this.opts.debounceTime)&&(this._requestScheduler=new Vt({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 i=this._cache.get(r);i&&!t.has(i)?(this._cache.delete(r),this._handleTileUnload(i),this._dirty=!0):i&&i.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,r,i){this._consumers.set(t,{selectedTiles:new Set(r),visibleTiles:new Set(i)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:r,minZoom:i,zRange:s,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:i,zRange:s,tileSize:h,extent:W_(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 i=this.getTileId(t),s=this._cache.get(i),n=!1;return!s&&r?(s=new me(t),Object.assign(s,this.getTileMetadata(s.index)),Object.assign(s,{id:i,zoom:this.getTileZoom(s.index)}),n=!0,this._cache.set(i,s),this._dirty=!0,this._updateStats()):s&&s.needsReload&&(n=!0),s&&this._touchTile(i,s),s&&n&&r&&(s.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),this._updateStats()),s}async _initializeTileSource(t){try{this.sourceMetadata=await t.getMetadata(),this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(r){let i=r instanceof Error?r:new Error(`TileSource metadata error: ${String(r)}`);this._notifyError(i)}}_rememberExplicitOptions(t){for(let r of Object.keys(t))this._explicitOptionKeys.add(r)}_applyResolvedOptions(){let t={...Hu,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let r=t.tileSource;t.getTileData=i=>r.getTileData(i)}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 i of this._listeners)i.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 i of r.selectedTiles)t.add(i);return t}_getVisibleTilesUnion(){let t=new Set;for(let r of this._consumers.values())for(let i of r.visibleTiles)t.add(i);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(),i=this._getVisibleTilesUnion(),s=[],n=0;for(let o of this._cache.values())o.isLoading&&(n++,!r.has(o)&&!i.has(o)&&s.push(o));for(;t>0&&n>t&&s.length>0;){let o=s.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,i=this._getVisibleTilesUnion(),s=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>r){for(let[o,a]of this._cache)if(!i.has(a)&&!s.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,i=t.index;for(;this.getTileZoom(i)>r;){i=this.getParentIndex(i);let s=this.getTile(i);if(s)return s}return null}};function W_(e){return e&&e.length===4?e:void 0}var Ss={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},Es=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,i=this._normalizeOptions({...this._opts,...t}),s=r!==i.imageSource||this._opts.getImage!==i.getImage||this._opts.getMetadata!==i.getMetadata;this._opts=i,s&&(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=$u(t,"Image metadata request failed");if(!this._finalized)for(let i of this._listeners)i.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestImage(t,r=this._opts.debounceTime){let i=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(i,t)},r):this._loadImage(i,t),i}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,r){if(!this._finalized){this._startLoading();for(let i of this._listeners)i.onImageLoadStart?.(t,r);try{let i=new AbortController;this._abortController=i;let s=await this._opts.getImage({...r,signal:i.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:r,image:s};for(let n of this._listeners)n.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(i){if(H_(i))return;let s=$u(i,"Image request failed");if(!this._finalized)for(let n of this._listeners)n.onImageLoadError?.(t,s,r)}finally{this._abortController?.signal===r.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let r=t.imageSource||null;return{...Ss,...t,imageSource:r,getMetadata:t.getMetadata||(()=>r?r.getMetadata():Ss.getMetadata()),getImage:t.getImage||(i=>r?r.getImage(i):Ss.getImage(i)),debounceTime:t.debounceTime??Ss.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 H_(e){return e instanceof Error&&e.name==="AbortError"}function $u(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}var Wr={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,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,i=this._normalizeOptions({...this._opts,...t}),s=r!==i.rasterSource||this._opts.getRaster!==i.getRaster||this._opts.getMetadata!==i.getMetadata;this._opts=i,s&&(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=Yu(t,"Raster metadata request failed");if(!this._finalized)for(let i of this._listeners)i.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestRaster(t,r=this._opts.debounceTime){if(!this.shouldRefetchRaster(t))return this._currentRequest?.requestId??-1;let i=this._nextRequestId++;return this._cancelScheduledRaster(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(i,t)},r):this._loadRaster(i,t),i}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 i of this._listeners)i.onRasterLoadStart?.(t,r);try{let i=new AbortController;this._abortController=i;let s=await this._opts.getRaster($_(r,i.signal));if(this._finalized||i.signal.aborted||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:r,raster:s};for(let n of this._listeners)n.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(i){if(Y_(i))return;let s=Yu(i,"Raster request failed");if(!this._finalized)for(let n of this._listeners)n.onRasterLoadError?.(t,s,r)}finally{this._abortController=null,this._finishLoading()}}}_normalizeOptions(t){let r=t.rasterSource||null;return{...Wr,...t,rasterSource:r,getMetadata:t.getMetadata||(()=>r?r.getMetadata():Wr.getMetadata()),getRaster:t.getRaster||(i=>r?r.getRaster(i):Wr.getRaster(i)),debounceTime:t.debounceTime??Wr.debounceTime,shouldRefetch:t.shouldRefetch||(i=>Wr.shouldRefetch(i))}}_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 $_(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 Yu(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function Y_(e){return e instanceof Error&&e.name==="AbortError"}var Xe=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 X_={debounceTime:0,minimumNodePixelSize:150,maximumScreenSpaceError:1,lodSelectionMetricType:"maxScreenThresholdSQ",densityThreshold:1,pointBudget:2e6,maxDepth:Number.POSITIVE_INFINITY,onTileLoad:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,onUpdate:()=>{}},vs=64,ws=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={...X_,...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 i=r?.cartographicCenter||this.root.boundingVolume.center;this.cartographicCenter=new p(i),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,i)=>{setTimeout(()=>{this.doSelectTiles().then(()=>r(this.frameNumberValue)).catch(i).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],i=new Map,s=new Set,n=0;for(let a of r){let h=this.getTraversalContext(a);n=await this.traverseTiles(h,i,n,s)}this.visibleTilesCount=s.size,this.selectedTiles=this.options.onTraversalComplete(Array.from(i.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,i,s){if(!this.root)return i;let n=i,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(s.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 i=Math.max(1,Math.PI*r*r),s=t.pointCount/i,n=t.header.lodThreshold||this.options.densityThreshold;return s<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 s=this.getCommonSpaceBoundingSphere(t.boundingVolume,r.viewport);if(s)return this.isBoundingSphereInsideCullingVolume(s,r.cullingVolume)}let i=this.getProjectedFootprint(t.boundingVolume,r.viewport);return i?this.isProjectedFootprintVisible(i,r.viewport):!1}shouldUseCullingVolume(t,r){if(!this.root||!r)return!1;let i=this.getCommonSpaceBoundingSphere(this.root.boundingVolume,t);if(!i)return!1;if(this.isBoundingSphereInsideCullingVolume(i,r))return!0;let s=this.getProjectedFootprint(this.root.boundingVolume,t);return!s||!this.isProjectedFootprintVisible(s,t)}isBoundingSphereInsideCullingVolume(t,r){return r.computeVisibilityWithPlaneMask(t,J.MASK_INDETERMINATE)!==J.MASK_OUTSIDE}isProjectedFootprintVisible(t,r){return!(t.x+t.radius<-vs||t.x-t.radius>r.width+vs||t.y+t.radius<-vs||t.y-t.radius>r.height+vs)}estimateScreenRadius(t,r){let i=this.getProjectedFootprint(t.boundingVolume,r);return i?i.radius:0}projectBounds(t,r){let i=this.getBoundingVolumeCorners(t),s=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;try{for(let h of i){let[c,l]=r.project(h);!Number.isFinite(c)||!Number.isFinite(l)||(s=Math.min(s,c),n=Math.min(n,l),o=Math.max(o,c),a=Math.max(a,l))}}catch{return null}return!Number.isFinite(s)||!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(a)?null:{minX:s,minY:n,maxX:o,maxY:a}}getProjectedFootprint(t,r){let i=Number.NaN,s=Number.NaN;try{[i,s]=r.project(t.center)}catch{return null}if(!Number.isFinite(i)||!Number.isFinite(s))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-i,c-s)))}}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:i,y:s,radius:o}}async getVisibleChildren(t,r){return t.level>=this.options.maxDepth?[]:(await this.getChildren(t)).map(s=>({tile:s,weight:this.estimateScreenRadius(s,r.viewport)})).filter(s=>this.isVisible(s.tile,r))}async getChildren(t){if(t.childrenLoaded)return t.children;if(!t.childrenPromise){let r=this.dataSource.getChildren(t.header).then(i=>i.map(s=>this.getOrCreateTile(s,t))).then(i=>(t.children=i,t.childrenLoaded=!0,i));t.childrenPromise=r.finally(()=>{t.childrenPromise===r&&(t.childrenPromise=null)})}return t.childrenPromise}getOrCreateTile(t,r){let i=this.tilesMap.get(t.id);if(i)return i.header=t,r&&i.parent!==r&&(i.parent=r),i;let s=new Xe(t,r);return this.tilesMap.set(t.id,s),r&&!r.children.find(n=>n.id===s.id)&&r.children.push(s),s}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,i]=t.cartographicBounds,s=t.coversFullLongitude?360:t.wrapsDateline?360-Math.abs(i[0]-r[0]):Math.abs(i[0]-r[0]),n=Math.max(s,1e-6);return Math.max(1,Math.round(Math.log2(360/n)))}haveSameIds(t,r){if(t.size!==r.size)return!1;for(let i of t)if(!r.has(i))return!1;return!0}getBoundingVolumeCorners(t){let[r,i]=t.cartographicBounds,s=t.coversFullLongitude?[[-180,180]]:t.wrapsDateline?[[r[0],180],[-180,i[0]]]:[[r[0],i[0]]],n=[],o=360-Math.abs(i[0]-r[0]),a=r[0]+o/2;for(let[h,c]of s){let l=m=>{if(!t.wrapsDateline)return m;let d=m;for(;d-a>180;)d-=360;for(;d-a<-180;)d+=360;return d},u=l(h),f=l(c);n.push([u,r[1],r[2]||0],[u,r[1],i[2]||0],[u,i[1],r[2]||0],[u,i[1],i[2]||0],[f,r[1],r[2]||0],[f,r[1],i[2]||0],[f,i[1],r[2]||0],[f,i[1],i[2]||0])}return n}getCullingVolume(t){let r=t.getFrustumPlanes?.bind(t);if(!r)return null;let i=r(),s=["left","right","bottom","top","near","far"],n=[];for(let o of s){let a=i[o];if(!a)return null;n.push(new Y(a.normal,-a.distance))}return new J(n)}getCommonSpaceBoundingSphere(t,r){let i=r.projectPosition?.bind(r);if(!i)return null;let s=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 s){let[f,m,d=0]=i(u);!Number.isFinite(f)||!Number.isFinite(m)||!Number.isFinite(d)||(n=Math.min(n,f),o=Math.min(o,m),a=Math.min(a,d),h=Math.max(h,f),c=Math.max(c,m),l=Math.max(l,d))}}catch{return null}return!Number.isFinite(n)||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(h)||!Number.isFinite(c)||!Number.isFinite(l)?null:new tt().fromCornerPoints([n,o,a],[h,c,l])}};return g0(Hr);})();
11
13
  return __exports__;
12
14
  });