@loaders.gl/tiles 5.0.0-alpha.6 → 5.0.0-alpha.8

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 (114) hide show
  1. package/README.md +26 -0
  2. package/dist/dist.dev.js +10015 -8172
  3. package/dist/dist.min.js +3 -4
  4. package/dist/index.cjs +1676 -477
  5. package/dist/index.cjs.map +3 -3
  6. package/dist/index.d.ts +10 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +4 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/spatial/format-spatial-reference.d.ts +1 -0
  11. package/dist/spatial/format-spatial-reference.d.ts.map +1 -1
  12. package/dist/spatial/format-spatial-reference.js +104 -46
  13. package/dist/spatial/format-spatial-reference.js.map +1 -1
  14. package/dist/spatial/get-spatial-coordinate-frame.d.ts +12 -1
  15. package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +1 -1
  16. package/dist/spatial/get-spatial-coordinate-frame.js +105 -24
  17. package/dist/spatial/get-spatial-coordinate-frame.js.map +1 -1
  18. package/dist/spatial/normalize-crs-identifier.d.ts +15 -0
  19. package/dist/spatial/normalize-crs-identifier.d.ts.map +1 -0
  20. package/dist/spatial/normalize-crs-identifier.js +22 -0
  21. package/dist/spatial/normalize-crs-identifier.js.map +1 -0
  22. package/dist/spatial/spatial-coordinate-transformer.d.ts +4 -0
  23. package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -1
  24. package/dist/spatial/spatial-coordinate-transformer.js +102 -18
  25. package/dist/spatial/spatial-coordinate-transformer.js.map +1 -1
  26. package/dist/spatial/spatial-resource-registry.js +3 -3
  27. package/dist/spatial/spatial-resource-registry.js.map +1 -1
  28. package/dist/spatial/tiles-3d-spatial-transformer.d.ts +32 -0
  29. package/dist/spatial/tiles-3d-spatial-transformer.d.ts.map +1 -0
  30. package/dist/spatial/tiles-3d-spatial-transformer.js +175 -0
  31. package/dist/spatial/tiles-3d-spatial-transformer.js.map +1 -0
  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 +33 -5
  37. package/dist/tileset-3d/common/tile-3d.d.ts.map +1 -1
  38. package/dist/tileset-3d/common/tile-3d.js +179 -29
  39. package/dist/tileset-3d/common/tile-3d.js.map +1 -1
  40. package/dist/tileset-3d/common/tileset-3d.d.ts +15 -25
  41. package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
  42. package/dist/tileset-3d/common/tileset-3d.js +35 -42
  43. package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
  44. package/dist/tileset-3d/common/tileset-content-traversal.d.ts +37 -0
  45. package/dist/tileset-3d/common/tileset-content-traversal.d.ts.map +1 -0
  46. package/dist/tileset-3d/common/tileset-content-traversal.js +80 -0
  47. package/dist/tileset-3d/common/tileset-content-traversal.js.map +1 -0
  48. package/dist/tileset-3d/common/tileset-observability.d.ts +60 -0
  49. package/dist/tileset-3d/common/tileset-observability.d.ts.map +1 -0
  50. package/dist/tileset-3d/common/tileset-observability.js +39 -0
  51. package/dist/tileset-3d/common/tileset-observability.js.map +1 -0
  52. package/dist/tileset-3d/common/tileset-source.d.ts +11 -1
  53. package/dist/tileset-3d/common/tileset-source.d.ts.map +1 -1
  54. package/dist/tileset-3d/common/tileset-source.js.map +1 -1
  55. package/dist/tileset-3d/common/tileset-traverser.d.ts.map +1 -1
  56. package/dist/tileset-3d/common/tileset-traverser.js +4 -3
  57. package/dist/tileset-3d/common/tileset-traverser.js.map +1 -1
  58. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +47 -1
  59. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -1
  60. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +327 -30
  61. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -1
  62. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +34 -0
  63. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +1 -1
  64. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +278 -14
  65. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +1 -1
  66. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts +5 -3
  67. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -1
  68. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js +7 -4
  69. package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js.map +1 -1
  70. package/dist/tileset-3d/format-i3s/i3s-source.d.ts +4 -2
  71. package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +1 -1
  72. package/dist/tileset-3d/format-i3s/i3s-source.js +60 -9
  73. package/dist/tileset-3d/format-i3s/i3s-source.js.map +1 -1
  74. package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.d.ts.map +1 -1
  75. package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js +1 -1
  76. package/dist/tileset-3d/format-i3s/i3s-tileset-traverser.js.map +1 -1
  77. package/dist/tileset-3d/helpers/bounding-volume.d.ts +7 -3
  78. package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +1 -1
  79. package/dist/tileset-3d/helpers/bounding-volume.js +19 -61
  80. package/dist/tileset-3d/helpers/bounding-volume.js.map +1 -1
  81. package/dist/tileset-3d/helpers/frame-state.d.ts +5 -0
  82. package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
  83. package/dist/tileset-3d/helpers/frame-state.js +11 -5
  84. package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
  85. package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts +17 -0
  86. package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +1 -0
  87. package/dist/tileset-3d/helpers/s2-bounding-volume.js +20 -0
  88. package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +1 -0
  89. package/dist/types.d.ts +2 -0
  90. package/dist/types.d.ts.map +1 -1
  91. package/package.json +11 -12
  92. package/src/index.ts +18 -1
  93. package/src/spatial/format-spatial-reference.ts +127 -53
  94. package/src/spatial/get-spatial-coordinate-frame.ts +126 -31
  95. package/src/spatial/normalize-crs-identifier.ts +26 -0
  96. package/src/spatial/spatial-coordinate-transformer.ts +124 -24
  97. package/src/spatial/spatial-resource-registry.ts +3 -3
  98. package/src/spatial/tiles-3d-spatial-transformer.ts +206 -0
  99. package/src/tileset-3d/common/tile-3d-contracts.ts +115 -0
  100. package/src/tileset-3d/common/tile-3d.ts +208 -32
  101. package/src/tileset-3d/common/tileset-3d.ts +37 -61
  102. package/src/tileset-3d/common/tileset-content-traversal.ts +114 -0
  103. package/src/tileset-3d/common/tileset-observability.ts +100 -0
  104. package/src/tileset-3d/common/tileset-source.ts +19 -1
  105. package/src/tileset-3d/common/tileset-traverser.ts +4 -3
  106. package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +481 -34
  107. package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +405 -14
  108. package/src/tileset-3d/format-3d-tiles/tileset-3d-traverser.ts +7 -4
  109. package/src/tileset-3d/format-i3s/i3s-source.ts +84 -13
  110. package/src/tileset-3d/format-i3s/i3s-tileset-traverser.ts +2 -1
  111. package/src/tileset-3d/helpers/bounding-volume.ts +29 -62
  112. package/src/tileset-3d/helpers/frame-state.ts +15 -7
  113. package/src/tileset-3d/helpers/s2-bounding-volume.ts +35 -0
  114. package/src/types.ts +2 -0
package/dist/dist.min.js CHANGED
@@ -4,9 +4,8 @@
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 Is=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(s){throw t=0,s}},cr=(e,t)=>{for(var s in t)Is(e,s,{get:t[s],enumerable:!0})},As=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of a0(t))!c0.call(e,r)&&r!==s&&Is(e,r,{get:()=>t[r],enumerable:!(i=o0(t,r))||i.enumerable});return e},Os=(e,t,s)=>(As(e,t,"default"),s&&As(s,t,"default")),u0=(e,t,s)=>(s=e!=null?n0(h0(e)):{},As(t||!e||!e.__esModule?Is(s,"default",{value:e,enumerable:!0}):s,e)),f0=e=>As(Is({},"__esModule",{value:!0}),e);var Xn=l0((f2,Zn)=>{Zn.exports=globalThis.loaders});var Rs={};cr(Rs,{I3SSource:()=>$i,I3SSpatialTransformer:()=>Be,ImageSet:()=>Ki,IndexedArchiveTilesetSource:()=>_i,LOD_METRIC_TYPE:()=>ye,PointCloudTile:()=>De,PointCloudTileset:()=>er,RasterSet:()=>Ji,STRATEGY_DEFAULT:()=>bs,STRATEGY_NEVER:()=>jn,STRATEGY_REPLACE:()=>Wn,SharedTile2DHeader:()=>le,SpatialCoordinateTransformer:()=>$t,TILESET_TYPE:()=>at,TILE_CONTENT_STATE:()=>et,TILE_REFINEMENT:()=>J,TILE_TYPE:()=>Lt,Tile3D:()=>Et,Tiles3DSource:()=>Ti,Tileset2D:()=>Ts,Tileset3D:()=>gi,TilesetCache:()=>xe,TilesetTraverser:()=>Gt,applyTilesetSpatialOptions:()=>es,calculateTransformProps:()=>li,createBoundingVolume:()=>Se,createImplicitSubtreeReference:()=>nn,createTilesetSpatialReference:()=>vt,get3DTilesSpatialReference:()=>vi,getFrameState:()=>ui,getGeoidModel:()=>Zi,getI3SSpatialReference:()=>Si,getLodStatus:()=>xi,getSpatialCoordinateFrame:()=>kt,isTileset3DSource:()=>pi,markTilesetSpatialReferenceTransformed:()=>mi,materializeImplicitSubtree:()=>Ei,registerGeoidModel:()=>Bn,registerGeoidModelFromPgm:()=>Nl,registerSpatialCrs:()=>Il,registerSpatialDatumGrid:()=>Ol,replaceImplicitUrlTemplate:()=>wi});Os(Rs,u0(Xn(),1));var q={};cr(q,{EPSILON1:()=>d0,EPSILON10:()=>v0,EPSILON11:()=>E0,EPSILON12:()=>w0,EPSILON13:()=>T0,EPSILON14:()=>Ns,EPSILON15:()=>b0,EPSILON16:()=>P0,EPSILON17:()=>R0,EPSILON18:()=>C0,EPSILON19:()=>A0,EPSILON2:()=>m0,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 d0=.1,m0=.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,Ns=1e-14,b0=1e-15,P0=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 V=globalThis.mathgl.config;function lr(e,{precision:t=V.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 Ls(e)}function fr(e){return ot(e)}function Ls(e,t){return mr(e,s=>s*z0,t)}function ot(e,t){return mr(e,s=>s*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 dr(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,s){return mr(e,i=>Math.max(t,Math.min(s,i)))}function pt(e,t,s){let i=V.EPSILON;s&&(V.EPSILON=s);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)<=V.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{V.EPSILON=i}}function D0(e){return Math.round(e/V.EPSILON)*V.EPSILON}function F0(e){return e.clone?e.clone():new Array(e.length)}function mr(e,t,s){if(Ot(e)){let i=e;s=s||F0(i);for(let r=0;r<s.length&&r<i.length;++r){let n=typeof e=="number"?e:e[r];s[r]=t(n,r,s)}return s}return t(e)}var Qt=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,s=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=t[i+s];return this.check()}toArray(t=[],s=0){for(let i=0;i<this.ELEMENTS;++i)t[s+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:Ot(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toString(){return this.formatString(V)}formatString(t){let s="";for(let i=0;i<this.ELEMENTS;++i)s+=(i>0?", ":"")+lr(this[i],t);return`${t.printTypes?this.constructor.name:""}[${s}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let s=0;s<this.ELEMENTS;++s)if(!pt(this[s],t[s]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let s=0;s<this.ELEMENTS;++s)if(this[s]!==t[s])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,s,i){if(i===void 0)return this.lerp(this,t,s);for(let r=0;r<this.ELEMENTS;++r){let n=t[r],o=typeof s=="number"?s:s[r];this[r]=n+i*(o-n)}return this.check()}min(t){for(let s=0;s<this.ELEMENTS;++s)this[s]=Math.min(t[s],this[s]);return this.check()}max(t){for(let s=0;s<this.ELEMENTS;++s)this[s]=Math.max(t[s],this[s]);return this.check()}clamp(t,s){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],t[i]),s[i]);return this.check()}add(...t){for(let s of t)for(let i=0;i<this.ELEMENTS;++i)this[i]+=s[i];return this.check()}subtract(...t){for(let s of t)for(let i=0;i<this.ELEMENTS;++i)this[i]-=s[i];return this.check()}scale(t){if(typeof t=="number")for(let s=0;s<this.ELEMENTS;++s)this[s]*=t;else for(let s=0;s<this.ELEMENTS&&s<t.length;++s)this[s]*=t[s];return this.check()}multiplyByScalar(t){for(let s=0;s<this.ELEMENTS;++s)this[s]*=t;return this.check()}check(){if(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 s=0;s<this.ELEMENTS;++s)t=t&&Number.isFinite(this[s]);return t}};function U0(e,t){if(e.length!==t)return!1;for(let s=0;s<e.length;++s)if(!Number.isFinite(e[s]))return!1;return!0}function F(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function fe(e,t,s=""){if(V.debug&&!U0(e,t))throw new Error(`math.gl: ${s} some fields set to invalid numbers'`);return e}var de=class extends Qt{toString(){let t="[";if(V.printRowMajor){t+="row-major:";for(let s=0;s<this.RANK;++s)for(let i=0;i<this.RANK;++i)t+=` ${this[i*this.RANK+s]}`}else{t+="column-major:";for(let s=0;s<this.ELEMENTS;++s)t+=` ${this[s]}`}return t+="]",t}getElementIndex(t,s){return s*this.RANK+t}getElement(t,s){return this[s*this.RANK+t]}setElement(t,s,i){return this[s*this.RANK+t]=F(i),this}getColumn(t,s=new Array(this.RANK).fill(-0)){let i=t*this.RANK;for(let r=0;r<this.RANK;++r)s[r]=this[i+r];return s}setColumn(t,s){let i=t*this.RANK;for(let r=0;r<this.RANK;++r)this[i+r]=s[r];return this}};function Q(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var me=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 s=0;s<this.ELEMENTS;++s)t+=this[s]*this[s];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let s=0;for(let i=0;i<this.ELEMENTS;++i){let r=this[i]-t[i];s+=r*r}return F(s)}dot(t){let s=0;for(let i=0;i<this.ELEMENTS;++i)s+=this[i]*t[i];return F(s)}normalize(){let t=this.magnitude();if(t!==0)for(let s=0;s<this.ELEMENTS;++s)this[s]/=t;return this.check()}multiply(...t){for(let s of t)for(let i=0;i<this.ELEMENTS;++i)this[i]*=s[i];return this.check()}divide(...t){for(let s of t)for(let i=0;i<this.ELEMENTS;++i)this[i]/=s[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,s){return Q(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=s,this.check()}addVectors(t,s){return this.copy(t).add(s)}subVectors(t,s){return this.copy(t).subtract(s)}multiplyVectors(t,s){return this.copy(t).multiply(s)}addScaledVector(t,s){for(let i=0;i<this.ELEMENTS;++i)this[i]+=t[i]*s;return this.check()}};var Gs=typeof Float32Array<"u"?Float32Array:Array;var R2=Math.PI/180;function Kn(e,t,s){let i=t[0],r=t[1];return e[0]=s[0]*i+s[2]*r,e[1]=s[1]*i+s[3]*r,e}function Jn(e,t,s){let i=t[0],r=t[1];return e[0]=s[0]*i+s[2]*r+s[4],e[1]=s[1]*i+s[3]*r+s[5],e}function zs(e,t,s){let i=t[0],r=t[1];return e[0]=s[0]*i+s[3]*r+s[6],e[1]=s[1]*i+s[4]*r+s[7],e}function qs(e,t,s){let i=t[0],r=t[1];return e[0]=s[0]*i+s[4]*r+s[12],e[1]=s[1]*i+s[5]*r+s[13],e}function Bs(e,t,s){let i=t[0],r=t[1],n=s[3]*i+s[7]*r||1;return e[0]=(s[0]*i+s[4]*r)/n,e[1]=(s[1]*i+s[5]*r)/n,e}function Ds(e,t,s){let i=t[0],r=t[1],n=t[2],o=s[3]*i+s[7]*r+s[11]*n||1;return e[0]=(s[0]*i+s[4]*r+s[8]*n)/o,e[1]=(s[1]*i+s[5]*r+s[9]*n)/o,e[2]=(s[2]*i+s[6]*r+s[10]*n)/o,e}function to(e,t,s){let i=t[0],r=t[1];return e[0]=s[0]*i+s[2]*r,e[1]=s[1]*i+s[3]*r,e[2]=t[2],e}function eo(e,t,s){let i=t[0],r=t[1],n=t[2];return e[0]=s[0]*i+s[3]*r+s[6]*n,e[1]=s[1]*i+s[4]*r+s[7]*n,e[2]=s[2]*i+s[5]*r+s[8]*n,e[3]=t[3],e}var xt=class extends me{constructor(t=0,s=0){super(2),Ot(t)&&arguments.length===1?this.copy(t):(V.debug&&(F(t),F(s)),this[0]=t,this[1]=s)}set(t,s){return this[0]=t,this[1]=s,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 qs(this,this,t),this.check()}transformAsVector(t){return Bs(this,this,t),this.check()}transformByMatrix3(t){return zs(this,this,t),this.check()}transformByMatrix2x3(t){return Jn(this,this,t),this.check()}transformByMatrix2(t){return Kn(this,this,t),this.check()}};function so(){let e=new Gs(3);return Gs!==Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function pr(e){let t=e[0],s=e[1],i=e[2];return Math.sqrt(t*t+s*s+i*i)}function gr(e,t,s){let i=new Gs(3);return i[0]=e,i[1]=t,i[2]=s,i}function io(e,t){let s=t[0],i=t[1],r=t[2],n=s*s+i*i+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 Ve(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function pe(e,t,s){let i=t[0],r=t[1],n=t[2],o=s[0],a=s[1],h=s[2];return e[0]=r*h-n*a,e[1]=n*o-i*h,e[2]=i*a-r*o,e}function Fs(e,t,s){let i=t[0],r=t[1],n=t[2],o=s[3]*i+s[7]*r+s[11]*n+s[15];return o=o||1,e[0]=(s[0]*i+s[4]*r+s[8]*n+s[12])/o,e[1]=(s[1]*i+s[5]*r+s[9]*n+s[13])/o,e[2]=(s[2]*i+s[6]*r+s[10]*n+s[14])/o,e}function Us(e,t,s){let i=t[0],r=t[1],n=t[2];return e[0]=i*s[0]+r*s[3]+n*s[6],e[1]=i*s[1]+r*s[4]+n*s[7],e[2]=i*s[2]+r*s[5]+n*s[8],e}function ro(e,t,s){let i=s[0],r=s[1],n=s[2],o=s[3],a=t[0],h=t[1],c=t[2],l=r*c-n*h,u=n*a-i*c,f=i*h-r*a,m=r*f-n*u,d=n*l-i*f,g=i*u-r*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 no(e,t,s,i){let r=[],n=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],n[0]=r[0],n[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),n[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),e[0]=n[0]+s[0],e[1]=n[1]+s[1],e[2]=n[2]+s[2],e}function oo(e,t,s,i){let r=[],n=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],n[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),n[1]=r[1],n[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),e[0]=n[0]+s[0],e[1]=n[1]+s[1],e[2]=n[2]+s[2],e}function ao(e,t,s,i){let r=[],n=[];return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],n[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),n[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),n[2]=r[2],e[0]=n[0]+s[0],e[1]=n[1]+s[1],e[2]=n[2]+s[2],e}function ho(e,t){let s=e[0],i=e[1],r=e[2],n=t[0],o=t[1],a=t[2],h=Math.sqrt((s*s+i*i+r*r)*(n*n+o*o+a*a)),c=h&&Ve(e,t)/h;return Math.acos(Math.min(Math.max(c,-1),1))}var co=pr;var _r=[0,0,0],ks,p=class e extends me{static get ZERO(){return ks||(ks=new e(0,0,0),Object.freeze(ks)),ks}constructor(t=0,s=0,i=0){super(-0,-0,-0),arguments.length===1&&Ot(t)?this.copy(t):(V.debug&&(F(t),F(s),F(i)),this[0]=t,this[1]=s,this[2]=i)}set(t,s,i){return this[0]=t,this[1]=s,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 ho(this,t)}cross(t){return pe(this,this,t),this.check()}rotateX({radians:t,origin:s=_r}){return no(this,this,s,t),this.check()}rotateY({radians:t,origin:s=_r}){return oo(this,this,s,t),this.check()}rotateZ({radians:t,origin:s=_r}){return ao(this,this,s,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Fs(this,this,t),this.check()}transformAsVector(t){return Ds(this,this,t),this.check()}transformByMatrix3(t){return Us(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 s=t[1],i=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=s,e[5]=t[7],e[6]=i,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 s=t[0],i=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,m=c*n-o*h,d=s*u+i*f+r*m;return d?(d=1/d,e[0]=u*d,e[1]=(-l*i+r*c)*d,e[2]=(a*i-r*o)*d,e[3]=f*d,e[4]=(l*s-r*h)*d,e[5]=(-a*s+r*n)*d,e[6]=m*d,e[7]=(-c*s+i*h)*d,e[8]=(o*s-i*n)*d,e):null}function fo(e){let t=e[0],s=e[1],i=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)+s*(-c*r+o*a)+i*(h*r-n*a)}function Mr(e,t,s){let i=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=s[0],m=s[1],d=s[2],g=s[3],_=s[4],M=s[5],y=s[6],E=s[7],w=s[8];return e[0]=f*i+m*o+d*c,e[1]=f*r+m*a+d*l,e[2]=f*n+m*h+d*u,e[3]=g*i+_*o+M*c,e[4]=g*r+_*a+M*l,e[5]=g*n+_*h+M*u,e[6]=y*i+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,s){let i=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=s[0],m=s[1];return e[0]=i,e[1]=r,e[2]=n,e[3]=o,e[4]=a,e[5]=h,e[6]=f*i+m*o+c,e[7]=f*r+m*a+l,e[8]=f*n+m*h+u,e}function po(e,t,s){let i=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(s),m=Math.cos(s);return e[0]=m*i+f*o,e[1]=m*r+f*a,e[2]=m*n+f*h,e[3]=m*o-f*i,e[4]=m*a-f*r,e[5]=m*h-f*n,e[6]=c,e[7]=l,e[8]=u,e}function xr(e,t,s){let i=s[0],r=s[1];return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*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 s=t[0],i=t[1],r=t[2],n=t[3],o=s+s,a=i+i,h=r+r,c=s*o,l=i*o,u=i*a,f=r*o,m=r*a,d=r*h,g=n*o,_=n*a,M=n*h;return e[0]=1-u-d,e[3]=l-M,e[6]=f+_,e[1]=l+M,e[4]=1-c-d,e[7]=m-g,e[2]=f-_,e[5]=m+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 de{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,s,i,r,n,o,a,h,c){return this[0]=t,this[1]=s,this[2]=i,this[3]=r,this[4]=n,this[5]=o,this[6]=a,this[7]=h,this[8]=c,this.check()}setRowMajor(t,s,i,r,n,o,a,h,c){return this[0]=t,this[1]=r,this[2]=a,this[3]=s,this[4]=n,this[5]=h,this[6]=i,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,s){let i;switch(t.length){case 2:i=zs(s||[-0,-0],t,this);break;case 3:i=Us(s||[-0,-0,-0],t,this);break;case 4:i=eo(s||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return fe(i,t.length),i}},Vs,js=null;function W0(){return Vs||(Vs=new U([0,0,0,0,0,0,0,0,0]),Object.freeze(Vs)),Vs}function H0(){return js||(js=new U,Object.freeze(js)),js}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 s=t[1],i=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]=s,e[6]=t[9],e[7]=t[13],e[8]=i,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 s=t[0],i=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],m=t[11],d=t[12],g=t[13],_=t[14],M=t[15],y=s*a-i*o,E=s*h-r*o,w=s*c-n*o,T=i*h-r*a,b=i*c-n*a,R=r*c-n*h,A=l*g-u*d,C=l*_-f*d,G=l*M-m*d,L=u*_-f*g,D=u*M-m*g,H=f*M-m*_,N=y*H-E*D+w*L+T*G-b*C+R*A;return N?(N=1/N,e[0]=(a*H-h*D+c*L)*N,e[1]=(r*D-i*H-n*L)*N,e[2]=(g*R-_*b+M*T)*N,e[3]=(f*b-u*R-m*T)*N,e[4]=(h*G-o*H-c*C)*N,e[5]=(s*H-r*G+n*C)*N,e[6]=(_*w-d*R-M*E)*N,e[7]=(l*R-f*w+m*E)*N,e[8]=(o*D-a*G+c*A)*N,e[9]=(i*G-s*D-n*A)*N,e[10]=(d*b-g*w+M*y)*N,e[11]=(u*w-l*b-m*y)*N,e[12]=(a*C-o*L-h*A)*N,e[13]=(s*L-i*C+r*A)*N,e[14]=(g*E-d*T-_*y)*N,e[15]=(l*T-u*E+f*y)*N,e):null}function xo(e){let t=e[0],s=e[1],i=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],m=e[12],d=e[13],g=e[14],_=e[15],M=t*o-s*n,y=t*a-i*n,E=s*a-i*o,w=c*d-l*m,T=c*g-u*m,b=l*g-u*d,R=t*b-s*T+i*w,A=n*b-o*T+a*w,C=c*E-l*y+u*M,G=m*E-d*y+g*M;return h*R-r*A+_*C-f*G}function Sr(e,t,s){let i=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],m=t[10],d=t[11],g=t[12],_=t[13],M=t[14],y=t[15],E=s[0],w=s[1],T=s[2],b=s[3];return e[0]=E*i+w*a+T*u+b*g,e[1]=E*r+w*h+T*f+b*_,e[2]=E*n+w*c+T*m+b*M,e[3]=E*o+w*l+T*d+b*y,E=s[4],w=s[5],T=s[6],b=s[7],e[4]=E*i+w*a+T*u+b*g,e[5]=E*r+w*h+T*f+b*_,e[6]=E*n+w*c+T*m+b*M,e[7]=E*o+w*l+T*d+b*y,E=s[8],w=s[9],T=s[10],b=s[11],e[8]=E*i+w*a+T*u+b*g,e[9]=E*r+w*h+T*f+b*_,e[10]=E*n+w*c+T*m+b*M,e[11]=E*o+w*l+T*d+b*y,E=s[12],w=s[13],T=s[14],b=s[15],e[12]=E*i+w*a+T*u+b*g,e[13]=E*r+w*h+T*f+b*_,e[14]=E*n+w*c+T*m+b*M,e[15]=E*o+w*l+T*d+b*y,e}function yo(e,t,s){let i=s[0],r=s[1],n=s[2],o,a,h,c,l,u,f,m,d,g,_,M;return t===e?(e[12]=t[0]*i+t[4]*r+t[8]*n+t[12],e[13]=t[1]*i+t[5]*r+t[9]*n+t[13],e[14]=t[2]*i+t[6]*r+t[10]*n+t[14],e[15]=t[3]*i+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],m=t[7],d=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]=m,e[8]=d,e[9]=g,e[10]=_,e[11]=M,e[12]=o*i+l*r+d*n+t[12],e[13]=a*i+u*r+g*n+t[13],e[14]=h*i+f*r+_*n+t[14],e[15]=c*i+m*r+M*n+t[15]),e}function So(e,t,s){let i=s[0],r=s[1],n=s[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]*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,s,i){let r=i[0],n=i[1],o=i[2],a=Math.sqrt(r*r+n*n+o*o),h,c,l,u,f,m,d,g,_,M,y,E,w,T,b,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(s),h=Math.cos(s),l=1-h,u=t[0],f=t[1],m=t[2],d=t[3],g=t[4],_=t[5],M=t[6],y=t[7],E=t[8],w=t[9],T=t[10],b=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]=m*R+M*A+T*C,e[3]=d*R+y*A+b*C,e[4]=u*G+g*L+E*D,e[5]=f*G+_*L+w*D,e[6]=m*G+M*L+T*D,e[7]=d*G+y*L+b*D,e[8]=u*H+g*N+E*At,e[9]=f*H+_*N+w*At,e[10]=m*H+M*N+T*At,e[11]=d*H+y*N+b*At,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Eo(e,t,s){let i=Math.sin(s),r=Math.cos(s),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*i,e[5]=o*r+l*i,e[6]=a*r+u*i,e[7]=h*r+f*i,e[8]=c*r-n*i,e[9]=l*r-o*i,e[10]=u*r-a*i,e[11]=f*r-h*i,e}function wo(e,t,s){let i=Math.sin(s),r=Math.cos(s),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*i,e[1]=o*r-l*i,e[2]=a*r-u*i,e[3]=h*r-f*i,e[8]=n*i+c*r,e[9]=o*i+l*r,e[10]=a*i+u*r,e[11]=h*i+f*r,e}function To(e,t,s){let i=Math.sin(s),r=Math.cos(s),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*i,e[1]=o*r+l*i,e[2]=a*r+u*i,e[3]=h*r+f*i,e[4]=c*r-n*i,e[5]=l*r-o*i,e[6]=u*r-a*i,e[7]=f*r-h*i,e}function bo(e,t){let s=t[0],i=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(s*s+i*i+r*r),e[1]=Math.sqrt(n*n+o*o+a*a),e[2]=Math.sqrt(h*h+c*c+l*l),e}function Po(e,t){let s=t[0],i=t[1],r=t[2],n=t[3],o=s+s,a=i+i,h=r+r,c=s*o,l=i*o,u=i*a,f=r*o,m=r*a,d=r*h,g=n*o,_=n*a,M=n*h;return e[0]=1-u-d,e[1]=l+M,e[2]=f-_,e[3]=0,e[4]=l-M,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 Ro(e,t,s,i,r,n,o){let a=1/(s-t),h=1/(r-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]=(s+t)*a,e[9]=(r+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 Z0(e,t,s,i,r){let n=1/Math.tan(t/2);if(e[0]=n/s,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/(i-r);e[10]=(r+i)*o,e[14]=2*r*i*o}else e[10]=-1,e[14]=-2*i;return e}var Co=Z0;function X0(e,t,s,i,r,n,o){let a=1/(t-s),h=1/(i-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+s)*a,e[13]=(r+i)*h,e[14]=(o+n)*c,e[15]=1,e}var Ao=X0;function Io(e,t,s,i){let r,n,o,a,h,c,l,u,f,m,d=t[0],g=t[1],_=t[2],M=i[0],y=i[1],E=i[2],w=s[0],T=s[1],b=s[2];return Math.abs(d-w)<1e-6&&Math.abs(g-T)<1e-6&&Math.abs(_-b)<1e-6?Y0(e):(u=d-w,f=g-T,m=_-b,r=1/Math.sqrt(u*u+f*f+m*m),u*=r,f*=r,m*=r,n=y*m-E*f,o=E*u-M*m,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-m*o,c=m*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]=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 Oo(e,t,s){return e[0]=t[0]+s[0],e[1]=t[1]+s[1],e[2]=t[2]+s[2],e[3]=t[3]+s[3],e}function No(e,t,s){return e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e[3]=t[3]*s,e}function Lo(e){let t=e[0],s=e[1],i=e[2],r=e[3];return Math.sqrt(t*t+s*s+i*i+r*r)}function Go(e){let t=e[0],s=e[1],i=e[2],r=e[3];return t*t+s*s+i*i+r*r}function zo(e,t){let s=t[0],i=t[1],r=t[2],n=t[3],o=s*s+i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=s*o,e[1]=i*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,s,i){let r=t[0],n=t[1],o=t[2],a=t[3];return e[0]=r+i*(s[0]-r),e[1]=n+i*(s[1]-n),e[2]=o+i*(s[2]-o),e[3]=a+i*(s[3]-a),e}function Do(e,t,s){let i=t[0],r=t[1],n=t[2],o=t[3];return e[0]=s[0]*i+s[4]*r+s[8]*n+s[12]*o,e[1]=s[1]*i+s[5]*r+s[9]*n+s[13]*o,e[2]=s[2]*i+s[6]*r+s[10]*n+s[14]*o,e[3]=s[3]*i+s[7]*r+s[11]*n+s[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 de{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,s,i,r,n,o,a,h,c,l,u,f,m,d,g,_){return this[0]=t,this[1]=s,this[2]=i,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]=m,this[13]=d,this[14]=g,this[15]=_,this.check()}setRowMajor(t,s,i,r,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]=s,this[5]=o,this[6]=l,this[7]=d,this[8]=i,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 Po(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:s,right:i,bottom:r,top:n,near:o=vr,far:a=Er}=t;return a===1/0?su(this,s,i,r,n,o):Ro(this,s,i,r,n,o,a),this.check()}lookAt(t){let{eye:s,center:i=[0,0,0],up:r=[0,1,0]}=t;return Io(this,s,i,r),this.check()}ortho(t){let{left:s,right:i,bottom:r,top:n,near:o=vr,far:a=Er}=t;return Ao(this,s,i,r,n,o,a),this.check()}orthographic(t){let{fovy:s=Q0,aspect:i=K0,focalDistance:r=1,near:n=vr,far:o=Er}=t;Fo(s);let a=s/2,h=r*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:s=45*Math.PI/180,aspect:i=1,near:r=.1,far:n=500}=t;return Fo(s),Co(this,s,i,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,s){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],s=s||[-0,-0,-0];let i=this.getScale(s),r=1/i[0],n=1/i[1],o=1/i[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,s){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],s=s||[-0,-0,-0];let i=this.getScale(s),r=1/i[0],n=1/i[1],o=1/i[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,s){return vo(this,this,t,s),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,s){return t.length===4?(s=Do(s||[-0,-0,-0,-0],t,this),fe(s,4),s):this.transformAsPoint(t,s)}transformAsPoint(t,s){let{length:i}=t,r;switch(i){case 2:r=qs(s||[-0,-0],t,this);break;case 3:r=Fs(s||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return fe(r,t.length),r}transformAsVector(t,s){let i;switch(t.length){case 2:i=Bs(s||[-0,-0],t,this);break;case 3:i=Ds(s||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return fe(i,t.length),i}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,s,i){return this.identity().translate([t,s,i])}},Ws,Hs;function tu(){return Ws||(Ws=new I([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ws)),Ws}function eu(){return Hs||(Hs=new I,Object.freeze(Hs)),Hs}function Fo(e){if(e>Math.PI*2)throw Error("expected radians")}function su(e,t,s,i,r,n){let o=2*n/(s-t),a=2*n/(r-i),h=(s+t)/(s-t),c=(r+i)/(r-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 Uo(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Tr(e,t,s){s=s*.5;let i=Math.sin(s);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(s),e}function br(e,t,s){let i=t[0],r=t[1],n=t[2],o=t[3],a=s[0],h=s[1],c=s[2],l=s[3];return e[0]=i*l+o*a+r*c-n*h,e[1]=r*l+o*h+n*a-i*c,e[2]=n*l+o*c+i*h-r*a,e[3]=o*l-i*a-r*h-n*c,e}function ko(e,t,s){s*=.5;let i=t[0],r=t[1],n=t[2],o=t[3],a=Math.sin(s),h=Math.cos(s);return e[0]=i*h+o*a,e[1]=r*h+n*a,e[2]=n*h-r*a,e[3]=o*h-i*a,e}function Vo(e,t,s){s*=.5;let i=t[0],r=t[1],n=t[2],o=t[3],a=Math.sin(s),h=Math.cos(s);return e[0]=i*h-n*a,e[1]=r*h+o*a,e[2]=n*h+i*a,e[3]=o*h-r*a,e}function jo(e,t,s){s*=.5;let i=t[0],r=t[1],n=t[2],o=t[3],a=Math.sin(s),h=Math.cos(s);return e[0]=i*h+r*a,e[1]=r*h-i*a,e[2]=n*h+o*a,e[3]=o*h-n*a,e}function Wo(e,t){let s=t[0],i=t[1],r=t[2];return e[0]=s,e[1]=i,e[2]=r,e[3]=Math.sqrt(Math.abs(1-s*s-i*i-r*r)),e}function Ho(e,t,s,i){let r=t[0],n=t[1],o=t[2],a=t[3],h=s[0],c=s[1],l=s[2],u=s[3],f,m,d,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?(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*r+g*h,e[1]=d*n+g*c,e[2]=d*o+g*l,e[3]=d*a+g*u,e}function Yo(e,t){let s=t[0],i=t[1],r=t[2],n=t[3],o=s*s+i*i+r*r+n*n,a=o?1/o:0;return e[0]=-s*a,e[1]=-i*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 s=t[0]+t[4]+t[8],i;if(s>0)i=Math.sqrt(s+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 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;i=Math.sqrt(t[r*3+r]-t[n*3+n]-t[o*3+o]+1),e[r]=.5*i,i=.5/i,e[3]=(t[n*3+o]-t[o*3+n])*i,e[n]=(t[n*3+r]+t[r*3+n])*i,e[o]=(t[o*3+r]+t[r*3+o])*i}return e}var $o=Oo;var Qo=No,Ko=qo,Jo=Bo,ta=Lo;var ea=Go;var iu=zo;var sa=(function(){let e=so(),t=gr(1,0,0),s=gr(0,1,0);return function(i,r,n){let o=Ve(r,n);return o<-.999999?(pe(e,t,r),co(e)<1e-6&&pe(e,s,r),io(e,e),Tr(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(pe(e,r,n),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+o,iu(i,i))}})();var yt=class extends Qt{constructor(t=0,s=0,i=0,r=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,s,i,r)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,s,i,r){return this[0]=t,this[1]=s,this[2]=i,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,s){return Tr(this,t,s),this.check()}identity(){return Uo(this),this.check()}setAxisAngle(t,s){return this.fromAxisRotation(t,s)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=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,s){return sa(this,t,s),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,s,i){return i===void 0?this.lerp(this,t,s):(Jo(this,t,s,i),this.check())}multiplyRight(t){return br(this,this,t),this.check()}multiplyLeft(t){return br(this,t,this),this.check()}normalize(){let t=this.len(),s=t>0?1/t:0;return this[0]=this[0]*s,this[1]=this[1]*s,this[2]=this[2]*s,this[3]=this[3]*s,t===0&&(this[3]=1),this.check()}rotateX(t){return ko(this,this,t),this.check()}rotateY(t){return Vo(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,s,i){let r,n,o;return arguments.length===2?(r=this,n=t,o=s):(r=t,n=s,o=i),Ho(this,r,n,o),this.check()}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,s){return this.setAxisAngle(t,s)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var 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 Ys(e){return e}var L_=new p;function nu(e,t=[],s=Ys){return"longitude"in e?(t[0]=s(e.longitude),t[1]=s(e.latitude),t[2]=e.height):"x"in e?(t[0]=s(e.x),t[1]=s(e.y),t[2]=e.z):(t[0]=s(e[0]),t[1]=s(e[1]),t[2]=e[2]),t}function ia(e,t=[]){return nu(e,t,V._cartographicRadians?Ys:ur)}function ou(e,t,s=Ys){return"longitude"in t?(t.longitude=s(e[0]),t.latitude=s(e[1]),t.height=e[2]):"x"in t?(t.x=s(e[0]),t.y=s(e[1]),t.z=e[2]):(t[0]=s(e[0]),t[1]=s(e[1]),t[2]=e[2]),t}function ra(e,t){return ou(e,t,V._cartographicRadians?Ys: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"}},Pr={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,s,i,r,n){let o=oa[t]&&oa[t][s];Q(o&&(!i||i===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(Pr[t]),t!=="east"&&t!=="west"&&a.scale(f),h=cu.fromArray(Pr[s]),s!=="east"&&s!=="west"&&h.scale(f),c=lu.fromArray(Pr[i]),i!=="east"&&i!=="west"&&c.scale(f)}else{let{up:f,east:m,north:d}=je;m.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,f),d.copy(f).cross(m);let{down:g,west:_,south:M}=je;g.copy(f).scale(-1),_.copy(m).scale(-1),M.copy(d).scale(-1),a=je[t],h=je[s],c=je[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 ge=new p,uu=new p,fu=new p;function aa(e,t,s=[]){let{oneOverRadii:i,oneOverRadiiSquared:r,centerToleranceSquared:n}=t;ge.from(e);let o=ge.x,a=ge.y,h=ge.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 M=uu;if(M.copy(e).scale(_),g<n)return M.to(s);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 b=(1-_)*ge.len()/(.5*T.len()),R=0,A,C,G,L;do{b-=R,A=1/(1+b*y),C=1/(1+b*E),G=1/(1+b*w);let D=A*A,H=C*C,N=G*G,At=D*A,Cs=H*C,sr=N*G;L=f*D+m*H+d*N-1;let ir=-2*(f*At*y+m*Cs*E+d*sr*w);R=L/ir}while(Math.abs(L)>q.EPSILON12);return ge.scale([A,C,G]).to(s)}var Zs=new p,ha=new p,pu=new p,Tt=new p,gu=new p,Xs=new p,P=class{constructor(t=0,s=0,i=0){this.centerToleranceSquared=q.EPSILON1,Q(t>=0),Q(s>=0),Q(i>=0),this.radii=new p(t,s,i),this.radiiSquared=new p(t*t,s*s,i*i),this.radiiToTheFourth=new p(t*t*t*t,s*s*s*s,i*i*i*i),this.oneOverRadii=new p(t===0?0:1/t,s===0?0:1/s,i===0?0:1/i),this.oneOverRadiiSquared=new p(t===0?0:1/(t*t),s===0?0:1/(s*s),i===0?0:1/(i*i)),this.minimumRadius=Math.min(t,s,i),this.maximumRadius=Math.max(t,s,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,s=[0,0,0]){let i=ha,r=pu,[,,n]=t;this.geodeticSurfaceNormalCartographic(t,i),r.copy(this.radiiSquared).scale(i);let o=Math.sqrt(i.dot(r));return r.scale(1/o),i.scale(n),r.add(i),r.to(s)}cartesianToCartographic(t,s=[0,0,0]){Xs.from(t);let i=this.scaleToGeodeticSurface(Xs,Tt);if(!i)return;let r=this.geodeticSurfaceNormal(i,ha),n=gu;n.copy(Xs).subtract(i);let o=Math.atan2(r.y,r.x),a=Math.asin(r.z),h=Math.sign(Ve(n,Xs))*pr(n);return ra([o,a,h],s)}eastNorthUpToFixedFrame(t,s=new I){return Rr(this,"east","north","up",t,s)}localFrameToFixedFrame(t,s,i,r,n=new I){return Rr(this,t,s,i,r,n)}geocentricSurfaceNormal(t,s=[0,0,0]){return Zs.from(t).normalize().to(s)}geodeticSurfaceNormalCartographic(t,s=[0,0,0]){let i=ia(t),r=i[0],n=i[1],o=Math.cos(n);return Zs.set(o*Math.cos(r),o*Math.sin(r),Math.sin(n)).normalize(),Zs.to(s)}geodeticSurfaceNormal(t,s=[0,0,0]){return Zs.from(t).scale(this.oneOverRadiiSquared).normalize().to(s)}scaleToGeodeticSurface(t,s){return aa(t,this,s)}scaleToGeocentricSurface(t,s=[0,0,0]){Tt.from(t);let i=Tt.x,r=Tt.y,n=Tt.z,o=this.oneOverRadiiSquared,a=1/Math.sqrt(i*i*o.x+r*r*o.y+n*n*o.z);return Tt.multiplyByScalar(a).to(s)}transformPositionToScaledSpace(t,s=[0,0,0]){return Tt.from(t).scale(this.oneOverRadii).to(s)}transformPositionFromScaledSpace(t,s=[0,0,0]){return Tt.from(t).scale(this.radii).to(s)}getSurfaceNormalIntersectionWithZAxis(t,s=0,i=[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-s))return Tt.set(0,0,r).to(i)}};P.WGS84=new P(6378137,6378137,Dt);var Cr;(function(e){e.OUTSIDE="outside",e.INTERSECTING="intersecting",e.INSIDE="inside"})(Cr||(Cr={}));var X_=new p,$_=new p;var We=new p,ca=new p,tt=class e{constructor(t=[0,0,0],s=0){this.radius=-0,this.center=new p,this.fromCenterRadius(t,s)}fromCenterRadius(t,s){return this.center.from(t),this.radius=s,this}fromCornerPoints(t,s){return s=We.from(s),this.center=new p().from(t).add(s).scale(.5),this.radius=this.center.distance(s),this}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new e(this.center,this.radius)}union(t){let s=this.center,i=this.radius,r=t.center,n=t.radius,o=We.copy(r).subtract(s),a=o.magnitude();if(i>=a+n)return this.clone();if(n>=a+i)return t.clone();let h=(i+a+n)*.5;return ca.copy(o).scale((-i+h)/a).add(s),this.center.copy(ca),this.radius=h,this}expand(t){let i=We.from(t).subtract(this.center).magnitude();return i>this.radius&&(this.radius=i),this}transform(t){this.center.transform(t);let s=bo(We,t);return this.radius=Math.max(s[0],Math.max(s[1],s[2]))*this.radius,this}distanceSquaredTo(t){let s=this.distanceTo(t);return s*s}distanceTo(t){let i=We.from(t).subtract(this.center);return Math.max(0,i.len()-this.radius)}intersectPlane(t){let s=this.center,i=this.radius,n=t.normal.dot(s)+t.distance;return n<-i?"outside":n<i?"intersecting":"inside"}};var _u=new p,Mu=new p,$s=new p,Qs=new p,Ks=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],s=[0,0,0,0,0,0,0,0,0]){this.center=new p().from(t),this.halfAxes=new U(s)}get halfSize(){let t=this.halfAxes.getColumn(0),s=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2);return[new p(t).len(),new p(s).len(),new p(i).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),s=this.halfAxes.getColumn(1),i=this.halfAxes.getColumn(2),r=new p(t).normalize(),n=new p(s).normalize(),o=new p(i).normalize();return new yt().fromMatrix3(new U([...r,...n,...o]))}fromCenterHalfSizeQuaternion(t,s,i){let r=new yt(i),n=new U().fromQuaternion(r);return n[0]=n[0]*s[0],n[1]=n[1]*s[0],n[2]=n[2]*s[0],n[3]=n[3]*s[1],n[4]=n[4]*s[1],n[5]=n[5]*s[1],n[6]=n[6]*s[2],n[7]=n[7]*s[2],n[8]=n[8]*s[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 s=this.halfAxes,i=s.getColumn(0,$s),r=s.getColumn(1,Qs),n=s.getColumn(2,Ks),o=_u.copy(i).add(r).add(n);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let s=this.center,i=t.normal,r=this.halfAxes,n=i.x,o=i.y,a=i.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=i.dot(s)+t.distance;return c<=-h?"outside":c>=h?"inside":"intersecting"}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let s=Mu.from(t).subtract(this.center),i=this.halfAxes,r=i.getColumn(0,$s),n=i.getColumn(1,Qs),o=i.getColumn(2,Ks),a=r.magnitude(),h=n.magnitude(),c=o.magnitude();r.normalize(),n.normalize(),o.normalize();let l=0,u;return u=Math.abs(s.dot(r))-a,u>0&&(l+=u*u),u=Math.abs(s.dot(n))-h,u>0&&(l+=u*u),u=Math.abs(s.dot(o))-c,u>0&&(l+=u*u),l}computePlaneDistances(t,s,i=[-0,-0]){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=this.center,a=this.halfAxes,h=a.getColumn(0,$s),c=a.getColumn(1,Qs),l=a.getColumn(2,Ks),u=xu.copy(h).add(c).add(l).add(o),f=yu.copy(u).subtract(t),m=s.dot(f);return r=Math.min(m,r),n=Math.max(m,n),u.copy(o).add(h).add(c).subtract(l),f.copy(u).subtract(t),m=s.dot(f),r=Math.min(m,r),n=Math.max(m,n),u.copy(o).add(h).subtract(c).add(l),f.copy(u).subtract(t),m=s.dot(f),r=Math.min(m,r),n=Math.max(m,n),u.copy(o).add(h).subtract(c).subtract(l),f.copy(u).subtract(t),m=s.dot(f),r=Math.min(m,r),n=Math.max(m,n),o.copy(u).subtract(h).add(c).add(l),f.copy(u).subtract(t),m=s.dot(f),r=Math.min(m,r),n=Math.max(m,n),o.copy(u).subtract(h).add(c).subtract(l),f.copy(u).subtract(t),m=s.dot(f),r=Math.min(m,r),n=Math.max(m,n),o.copy(u).subtract(h).subtract(c).add(l),f.copy(u).subtract(t),m=s.dot(f),r=Math.min(m,r),n=Math.max(m,n),o.copy(u).subtract(h).subtract(c).subtract(l),f.copy(u).subtract(t),m=s.dot(f),r=Math.min(m,r),n=Math.max(m,n),i[0]=r,i[1]=n,i}transform(t){this.center.transformAsPoint(t);let s=this.halfAxes.getColumn(0,$s);s.transformAsPoint(t);let i=this.halfAxes.getColumn(1,Qs);i.transformAsPoint(t);let r=this.halfAxes.getColumn(2,Ks);return r.transformAsPoint(t),this.halfAxes=new U([...s,...i,...r]),this}getTransform(){throw new Error("not implemented")}};var la=new p,ua=new p,Y=class e{constructor(t=[0,0,1],s=0){this.normal=new p,this.distance=-0,this.fromNormalDistance(t,s)}fromNormalDistance(t,s){return Q(Number.isFinite(s)),this.normal.from(t).normalize(),this.distance=s,this}fromPointNormal(t,s){t=la.from(t),this.normal.from(s).normalize();let i=-this.normal.dot(t);return this.distance=i,this}fromCoefficients(t,s,i,r){return this.normal.set(t,s,i),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 s=ua.copy(this.normal).transformAsVector(t).normalize(),i=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(i,s)}projectPointOntoPlane(t,s=[0,0,0]){let i=la.from(t),r=this.getPointDistance(i),n=ua.copy(this.normal).scale(r);return i.subtract(n).to(s)}intersectWithRay(t,s=new p){let i=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(i))/o;if(!(a<0))return s.copy(r).multiplyByScalar(a).add(i)}};var fa=[new p([1,0,0]),new p([0,1,0]),new p([0,0,1])],da=new p,Su=new p,K=class e{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*fa.length;let s=t.center,i=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=da.copy(n).scale(-i).add(s);o.fromPointNormal(h,n);let c=da.copy(n).scale(i).add(s),l=Su.copy(n).negate();a.fromPointNormal(c,l),r+=2}return this}computeVisibility(t){let s="inside";for(let i of this.planes)switch(t.intersectPlane(i)){case"outside":return"outside";case"intersecting":s="intersecting";break;default:}return s}computeVisibilityWithPlaneMask(t,s){if(Q(Number.isFinite(s),"parentPlaneMask is required."),s===e.MASK_OUTSIDE||s===e.MASK_INSIDE)return s;let i=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&&(s&o)===0)continue;let a=r[n],h=t.intersectPlane(a);if(h==="outside")return e.MASK_OUTSIDE;h==="intersecting"&&(i|=o)}return i}};K.MASK_OUTSIDE=4294967295;K.MASK_INSIDE=0;K.MASK_INDETERMINATE=2147483647;var PM=new p,RM=new p,CM=new p,AM=new p,IM=new p;var qM=new p,BM=new p,DM=new p,FM=new p,UM=new p,kM=new p,VM=new p,jM=new p,WM=new p,HM=new p,YM=new p,ZM=new p;var QM=new U,KM=new U,JM=new U,tx=new U,ex=new U;var ax=new p,hx=new p,cx=new p,lx=new p,ux=new p,fx=new U,dx={diagonal:new U,unitary:new U};var Tu=new p,Ar=new p,bu=new I,Pu=new p,He=class{constructor(t,s=P.WGS84){let i=s.scaleToGeodeticSurface(t,Tu),r=s.eastNorthUpToFixedFrame(i,bu);this._origin=new p(i),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,s){s||(s=new xt);let r=this._plane.projectPointOntoPlane(t,Pu).subtract(this._origin),n=this._xAxis.dot(r),o=this._yAxis.dot(r);return s.x=n,s.y=o,s}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,s,i,r){this.west=t,this.south=s,this.east=i,this.north=r}static center(t,s){s||(s=new p);let i=t.east,r=t.west;i<r&&(i+=q.TWO_PI);let n=dr((r+i)*.5,"negative-pi-to-pi"),o=(t.south+t.north)*.5;return s.x=n,s.y=o,s.z=0,s}get width(){let t=this.east,s=this.west;return t<s&&(t+=q.TWO_PI),t-s}};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,ku=new xt,Vu=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=P.WGS84,s={}){if(!e||e.length!==6||e.some(y=>!Number.isFinite(y)))throw new Error("makeOBBFromRegion: region must contain exactly six finite numbers");let i=s.units==="degrees"?Ls(1):1,[r,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=Ma(r*i),m=Ma(o*i);o*i-r*i>=q.TWO_PI-1e-12&&(m=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,_,m,M,h,c],t,s.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,s){let i=new Nt,[r,n,o,a,h,c]=e,l=ot(a),u=ot(n),f,m,d,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]),b=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),s0=It.projectPointToNearestOnPlane(Jl,Bu),Hn=It.projectPointToNearestOnPlane(ar,Du),i0=It.projectPointToNearestOnPlane(t0,Fu),Yn=It.projectPointToNearestOnPlane(hr,Uu),r0=It.projectPointToNearestOnPlane(e0,ku);return g=Math.min(Hn.x,i0.x,Yn.x),f=-g,m=Math.max(Hn.y,s0.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)),d=c,xa(Sa(It.origin,It.xAxis,It.yAxis,It.zAxis,g,f,_,m,M,d,i),s)}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,Cs=Hu.copy(N).cross(At);y=Vu.fromPointNormal(D,N);let sr=t.cartographicToCartesian([ot(b+q.PI_OVER_TWO),L,c],Yu);f=y.projectPointOntoPlane(sr,Zu).dot(Cs),g=-f;let ir=G?h:c,Hl=C?h:c;m=ya(t,l,ir,!0),_=ya(t,u,Hl,!1);let Yl=t.cartographicToCartesian([A,L,c],$u);return M=y.getPointDistance(Yl),d=0,xa(Sa(D,Cs,At,N,g,f,_,m,M,d,i),s)}function xa(e,t){if(!t)return e;let s=[0,1,2].map(a=>e.halfAxes.getColumn(a,new p)),i=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(i);for(let c=0;c<3;c++){let l=t.transformAsVector(s[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,s,i){let r=i?-1/0:1/0;for(let n of[0,90,180,270]){let o=e.cartographicToCartesian([n,t,s],Xu).z;r=i?Math.max(r,o):Math.min(r,o)}return r}function Sa(e,t,s,i,r,n,o,a,h,c,l){let u=l.center,f=l.halfAxes;f.setColumn(0,t),f.setColumn(1,s),f.setColumn(2,i);let m=Ru.set((r+n)/2,(o+a)/2,(h+c)/2).transformByMatrix3(f),d=(n-r)/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 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 se=class{constructor(t,s){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=s,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=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,s="count"){return this._getOrCreate({name:t,type:s})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let s of Object.values(this.stats))t(s)}getTable(){let t={};return this.forEach(s=>{t[s.name]={time:s.time||0,count:s.count||0,average:s.getAverageTime()||0,hz:s.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(s=>this._getOrCreate(s))}_getOrCreate(t){let{name:s,type:i}=t,r=this.stats[s];return r||(t instanceof se?r=t:r=new se(s,i),this.stats[s]=r),r}};function bt(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,s=()=>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:s},r=new Promise(n=>(i.resolve=n,i));return this.requestQueue.push(i),this.requestMap.set(t,r),this._issueNewRequests(),r}_issueRequest(t){let{handle:s,resolve:i}=t,r=!1,n=()=>{r||(r=!0,this.requestMap.delete(s),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 s=0;s<t;++s){let i=this.requestQueue.shift();i&&this._issueRequest(i)}}}_updateAllRequests(){let t=this.requestQueue;for(let s=0;s<t.length;++s){let i=t[s];this._updateRequest(i)||(t.splice(s,1),this.requestMap.delete(i.handle),s--)}t.sort((s,i)=>s.priority-i.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 s of this.entries.values())t+=s.pending?1:0;return t}get byteLength(){return this.retainedByteLength}get(t,s){let i=this.entries.get(t);if(i)return this.touch(t,i),this.waitForEntry(t,i,s)}has(t){return this.entries.has(t)}set(t,s){this.removeEntry(t,"replace");let i=Ea(this.getByteLength(s)),r={promise:Promise.resolve(s),pending:!1,waiterCount:0,byteLength:i};return this.entries.set(t,r),this.retainedByteLength+=i,this.trim(),s}getOrLoad(t,s,i){let r=this.get(t,i);if(r)return r;if(i?.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(s(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,s,i){if(this.entries.get(t)===s){s.pending=!1,s.controller=void 0;try{s.byteLength=Ea(this.getByteLength(i))}catch{this.removeEntry(t,"error");return}this.retainedByteLength+=s.byteLength,this.trim()}}handleLoadError(t,s){this.entries.get(t)===s&&this.removeEntry(t,s.controller?.signal.aborted?"abort":"error")}waitForEntry(t,s,i){return i?.aborted?Promise.reject(Or()):s.pending?(s.waiterCount++,new Promise((r,n)=>{let o=!0,a=()=>{o&&(o=!1,i?.removeEventListener("abort",h),s.waiterCount--)},h=()=>{o&&(a(),n(Or()),s.pending&&s.waiterCount===0&&this.entries.get(t)===s&&this.removeEntry(t,"abort"))};i?.addEventListener("abort",h,{once:!0}),s.promise.then(c=>{o&&(a(),r(c))},c=>{o&&(a(),n(c))})})):s.promise}touch(t,s){this.entries.delete(t),this.entries.set(t,s)}trim(){let t=this.entries.size-this.pendingSize;if(!(t<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)){for(let[s,i]of this.entries)if(i.pending||(this.removeEntry(s,"evict"),t--),t<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)break}}removeEntry(t,s){let i=this.entries.get(t);return i?(this.entries.delete(t),this.retainedByteLength-=i.byteLength,i.pending&&i.controller?.abort(),this.onRemove?.(t,s),!0):!1}};function Or(){let e=new Error("Request aborted");return e.name="AbortError",e}function va(e,t,s){let i=e??t;if(i<0||Number.isNaN(i))throw new Error(`${s} must be a non-negative number`);return i}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 k={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:ba("range-request-scheduler-default"),onEvent:()=>{}},ti=class{props;stats;onEvent;pendingRequests=[];flushTimer=null;constructor(t={}){let s=t.rangeExpansionBytes??t.maxGapBytes??Nr.rangeExpansionBytes;this.props={batchDelayMs:t.batchDelayMs??Nr.batchDelayMs,maxGapBytes:t.maxGapBytes??s,rangeExpansionBytes:s,maxMergedBytes:t.maxMergedBytes??Nr.maxMergedBytes},this.stats=t.stats||ba("range-request-scheduler"),this.onEvent=t.onEvent,Pa(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 s=new Promise((i,r)=>{let n={...t,resolve:i,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(),s}fetch(t){let s=t.fetch||globalThis.fetch;return this.scheduleRequest({sourceId:t.sourceId||t.url,offset:t.offset,length:t.length,signal:t.signal,isolationKey:t.isolationKey??{},fetchRange:(i,r,n)=>lf({url:t.url,offset:i,length:r,signal:n,fetch:s,fetchOptions:t.fetchOptions})})}flush(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null);let t=this.pendingRequests;this.pendingRequests=[];let s=t.filter(r=>r.settled||r.signal?.aborted?(this.abortRequest(r),!1):!0),i=this.mergeRequests(s);s.length>0&&this.trackBatch(s,i);for(let r of i)this.fetchMergedRequest(r)}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>this.flush(),this.props.batchDelayMs))}mergeRequests(t){t.sort((i,r)=>i.sourceId!==r.sourceId?i.sourceId<r.sourceId?-1:1:i.offset-r.offset);let s=[];for(let i of t){let r=i.offset+i.length,n=s[s.length-1];n&&uf(n,i,this.props)?(n.endOffset=Math.max(n.endOffset,r),n.requests.push(i)):s.push({sourceId:i.sourceId,isolationKey:i.isolationKey??i.sourceId,offset:i.offset,endOffset:r,fetchRange:i.fetchRange,requests:[i]})}return s}async fetchMergedRequest(t){let{offset:s,endOffset:i,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=i-s;this.trackEvent({type:"request",sourceId:t.sourceId,offset:s,length:l,logicalRequestCount:n.length,logicalBytes:c,transportBytes:l,overfetchBytes:Math.max(l-c,0)});let u=ff(await r(s,l,o.signal)),{arrayBuffer:f}=u,m=u.fullResponse&&s===0&&f.byteLength<l,d=f.byteLength<l&&Number.isSafeInteger(u.sourceByteLength)&&s+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??Xe()-a;this.trackEvent({type:"response",sourceId:t.sourceId,offset:s,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-s;_.settled=!0,_.resolve(f.slice(M,M+_.length))}}catch(c){this.trackEvent({type:"error",sourceId:t.sourceId,offset:s,length:i-s,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,s){let i=Lr(t),r=s.reduce((n,o)=>n+o.endOffset-o.offset,0);this.trackEvent({type:"batch",logicalRequestCount:t.length,transportRequestCount:s.length,logicalBytes:i,transportBytes:r,overfetchBytes:Math.max(r-i,0)})}};function cf(e,t){switch((t.type==="response"||t.type==="error")&&t.networkTimeMs!==void 0&&e.get(k.networkTimeMs,"time").addTime(t.networkTimeMs),t.type){case"queued":e.get(k.logicalRanges,"count").incrementCount(),e.get(k.requestedBytes,"count").addCount(t.logicalBytes||0);break;case"batch":e.get(k.rangeBatches,"count").incrementCount(),e.get("Logical Ranges Batched","count").addCount(t.logicalRequestCount||0),e.get(k.transportRanges,"count").addCount(t.transportRequestCount||0),e.get(k.coalescedRanges,"count").addCount(Math.max((t.logicalRequestCount||0)-(t.transportRequestCount||0),0)),e.get(k.transportBytes,"count").addCount(t.transportBytes||0),e.get(k.overfetchBytes,"count").addCount(t.overfetchBytes||0);break;case"response":e.get(k.completedTransportRanges,"count").incrementCount(),e.get(k.responseBytes,"count").addCount(t.responseBytes||0),t.fullResponse&&e.get(k.fullResponseFallbacks,"count").incrementCount();break;case"error":e.get(k.failedTransportRanges,"count").incrementCount();break;case"abort":e.get(k.abortedLogicalRanges,"count").incrementCount();break;default:}}function ba(e="range-request-scheduler"){let t=new St({id:e});return Pa(t),t}async function lf(e){let t=gf(e.signal),s=Xe();try{let i=!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=mf(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)),i=!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()-s,fullResponse:i}}finally{t.removeAbortListener()}}function uf(e,t,s){if(e.sourceId!==t.sourceId||e.isolationKey!==(t.isolationKey??t.sourceId))return!1;let i=t.offset+t.length,r=t.offset-e.endOffset,n=Math.max(e.endOffset,i)-e.offset;return r<=s.rangeExpansionBytes&&n<=s.maxMergedBytes}function Pa(e){e.get(k.logicalRanges,"count"),e.get(k.requestedBytes,"count"),e.get(k.rangeBatches,"count"),e.get("Logical Ranges Batched","count"),e.get(k.transportRanges,"count"),e.get(k.coalescedRanges,"count"),e.get(k.transportBytes,"count"),e.get(k.completedTransportRanges,"count"),e.get(k.responseBytes,"count"),e.get(k.networkTimeMs,"time"),e.get(k.overfetchBytes,"count"),e.get(k.fullResponseFallbacks,"count"),e.get(k.failedTransportRanges,"count"),e.get(k.abortedLogicalRanges,"count")}function Lr(e){return e.reduce((t,s)=>t+s.length,0)}function ff(e){return e instanceof ArrayBuffer?{arrayBuffer:e}:e}function wa(e,t,s,i){return{...e,signal:i,headers:{...df(e?.headers),Range:`bytes=${t}-${t+s-1}`}}}function df(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):e:{}}function mf(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 s=Number(t[1]),i=Number(t[2]),r=t[3]==="*"?void 0:Number(t[3]);return!Number.isSafeInteger(s)||!Number.isSafeInteger(i)||s>i||r!==void 0&&!Number.isSafeInteger(r)?null:{offset:s,endOffset:i,sourceByteLength:r}}function gf(e){let t=new AbortController,s=()=>t.abort();return e?.aborted?t.abort():e?.addEventListener("abort",s,{once:!0}),{signal:t.signal,abort:()=>t.abort(),removeAbortListener:()=>e?.removeEventListener("abort",s)}}async function _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((s,i)=>(i&&(s=s.replace(new RegExp("^/"),"")),i!==e.length-1&&(s=s.replace(new RegExp("/$"),"")),s)),e.join("/")}function Sf(...e){let t=[];for(let n=0;n<e.length;n++)t[n]=e[n];let s="",i=!1,r;for(let n=t.length-1;n>=-1&&!i;n--){let o;n>=0?o=t[n]:(r===void 0&&(r=Ra()),o=r),o.length!==0&&(s=`${o}/${s}`,i=o.charCodeAt(0)===$e)}return s=vf(s,!i),i?`/${s}`:s.length>0?s:"."}var $e=47,Gr=46;function vf(e,t){let s="",i=-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(!(i===a-1||r===1))if(i!==a-1&&r===2){if(s.length<2||!o||s.charCodeAt(s.length-1)!==Gr||s.charCodeAt(s.length-2)!==Gr){if(s.length>2){let h=s.length-1,c=h;for(;c>=0&&s.charCodeAt(c)!==$e;--c);if(c!==h){s=c===-1?"":s.slice(0,c),i=a,r=0,o=!1;continue}}else if(s.length===2||s.length===1){s="",i=a,r=0,o=!1;continue}}t&&(s.length>0?s+="/..":s="..",o=!0)}else{let h=e.slice(i+1,a);s.length>0?s+=`/${h}`:s=h,o=!1}i=a,r=0}else n===Gr&&r!==-1?++r:r=-1}return s}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,s,i){if(i?.aborted)throw new Error("Request aborted");let r=await this.handle.slice(Number(t),Number(t)+Number(s)).arrayBuffer();if(i?.aborted)throw new Error("Request aborted");return r}};var ii=class{url;fetchFunction;fetchOptions;consistency;identityHints;countedFailures=new WeakSet;telemetry={requestedBytes:0,downloadedBytes:0,requestCount:0,networkTimeMs:0,abortCount:0,errorCount:0};constructor(t,s){Rf(s.byteLength),this.url=t,this.fetchFunction=s.fetch||((i,r)=>globalThis.fetch(i,r)),this.fetchOptions=s.fetchOptions?{...s.fetchOptions,headers:new Headers(s.fetchOptions.headers)}:void 0,this.consistency=s.consistency||"best-effort",this.identityHints={byteLength:s.byteLength,etag:ni(s.etag),lastModified:ni(s.lastModified)}}getInitialIdentity(){let{byteLength:t,etag:s,lastModified:i}=this.identityHints;return t!==void 0&&(s!==void 0||i!==void 0)?ri(t,s,i):t===0&&this.consistency==="best-effort"?ri(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,s,i,r){let n=ei(),o=Cf(i,this.fetchOptions?.signal);this.telemetry.requestCount++,this.telemetry.requestedBytes+=s;try{let a=await this.fetchFunction(this.url,Ef(this.fetchOptions,t,s,o.signal));if(wf(a,t,s,r))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 Tf(a),c=Ca(a,h.byteLength),l=Ia(r,c,this.identityHints,this.consistency)||Pf(h,t,s);if(l)throw await si(a),new Error(l);let u=await a.arrayBuffer();if(this.telemetry.downloadedBytes+=u.byteLength,u.byteLength!==s)throw new Error(`HTTP byte-range response contained ${u.byteLength} bytes; expected ${s}`);return{arrayBuffer:u,identity:Aa(r,c,this.identityHints),status:a.status,transportBytes:u.byteLength,networkTimeMs:ei()-n}}catch(a){throw(r===null||!Oa(a))&&this.trackFailure(a),a}finally{o.removeAbortListeners(),this.telemetry.networkTimeMs+=ei()-n}}async readEmptyIdentityProbe(t,s){let i=Ca(t,0),r=Ia(null,i,this.identityHints,this.consistency);if(await si(t),r)throw new Error(r);return{arrayBuffer:new ArrayBuffer(0),identity:Aa(null,i,this.identityHints),status:t.status,transportBytes:0,networkTimeMs:ei()-s}}};function Ef(e,t,s,i){let r=new Headers(e?.headers);return r.set("Range",`bytes=${t}-${t+s-1}`),{...e,method:"GET",body:void 0,headers:r,signal:i}}function wf(e,t,s,i){return e.status===416&&i===null&&t===0&&s===1&&/^bytes \*\/0$/i.test(e.headers.get("Content-Range")||"")}async function Tf(e){try{return bf(e.headers.get("Content-Range"))}catch(t){throw await si(e),t}}function bf(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 ri(t,ni(e.headers.get("ETag")),ni(e.headers.get("Last-Modified")))}function Aa(e,t,s){return e||ri(t.byteLength,t.etag??s.etag,t.lastModified??s.lastModified)}function Pf(e,t,s){return!Number.isSafeInteger(e.offset)||!Number.isSafeInteger(e.endOffset)||!Number.isSafeInteger(e.byteLength)||e.offset<0||e.endOffset<e.offset||e.endOffset>=e.byteLength?"HTTP byte-range response has invalid range bounds":e.offset!==t||e.endOffset!==t+s-1?"HTTP byte-range response does not match the requested range":null}function Ia(e,t,s,i){let r=e?.byteLength??s.byteLength;if(r!==void 0&&t.byteLength!==r)return"HTTP file length changed while the file was open";let n=e?.etag??s.etag,o=e?.lastModified??s.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 ri(e,t,s){return Object.freeze({byteLength:e,etag:t,lastModified:s})}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 si(e){await e.body?.cancel().catch(()=>{})}function ni(e){return e||void 0}function ei(){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,s=[...new Set(e.filter(r=>!!r))],i=()=>t.abort();for(let r of s)r.aborted?t.abort():r.addEventListener("abort",i,{once:!0});return{signal:t.signal,removeAbortListeners:()=>{for(let r of s)r.removeEventListener("abort",i)}}}var Qe=class e{handle;url;transport;rangeScheduler;schedulerIsolationKey={};suppliedByteLength;identity;openPromise=null;closed=!1;constructor(t,s={}){this.handle=t,this.url=t,this.transport=new ii(t,s),this.rangeScheduler=s.rangeScheduler||new ti({batchDelayMs:0,...s.rangeSchedulerProps}),this.suppliedByteLength=s.byteLength,this.identity=this.transport.getInitialIdentity()}static async open(t,s={},i){let r=new e(t,s);return await r.open(i),r}async open(t){if(this.assertOpen(),t?.aborted){let s=oi();throw this.transport.trackFailure(s),s}return await this.getIdentity(t),this}get size(){return this.identity?.byteLength??this.suppliedByteLength??0}get bigsize(){return BigInt(this.size)}getIdentitySnapshot(){return this.identity}getTelemetry(){return this.transport.getTelemetry()}async close(){this.closed=!0}async stat(){this.assertOpen();let t=await this.getIdentity();return{size:t.byteLength,bigsize:BigInt(t.byteLength),isDirectory:!1}}async read(t=0,s=0,i){if(this.assertOpen(),i?.aborted){let o=oi();throw this.transport.trackFailure(o),o}let r=await this.getIdentity(i),n=Na(t);if(If(n,s,r.byteLength),s===0)return new ArrayBuffer(0);try{return await this.rangeScheduler.scheduleRequest({sourceId:this.url,isolationKey:this.schedulerIsolationKey,offset:n,length:s,signal:i,fetchRange:this.fetchScheduledRange})}catch(o){throw this.transport.trackFailure(o),o}}async fetchRange(t,s,i){let r=Na(t),n=await this.read(r,s,i),o=Af(this.identity,r,s);return new Response(n,{status:206,headers:o})}fetchScheduledRange=async(t,s,i)=>{let r=await this.getIdentity(i),n=await this.transport.requestRange(t,s,i,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 i=this.probeIdentity().catch(r=>{throw this.openPromise===i&&(this.openPromise=null),r});this.openPromise=i}return Of(this.openPromise,t).catch(s=>{throw this.transport.trackFailure(s),s})}async probeIdentity(){try{let t=await this.transport.requestRange(0,1,void 0,null);return this.identity=t.identity,t.identity}catch(t){throw this.transport.trackFailure(t),t}}assertOpen(){if(this.closed)throw new Error("HttpFile is closed")}};function Af(e,t,s){let i=new Headers;return s>0&&e&&i.set("Content-Range",`bytes ${t}-${t+s-1}/${e.byteLength}`),e?.etag&&i.set("ETag",e.etag),e?.lastModified&&i.set("Last-Modified",e.lastModified),i}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,s){if(!Number.isSafeInteger(t)||t<0)throw new Error("HTTP byte-range length must be a non-negative safe integer");if(e+t>s)throw new Error("HTTP byte range extends beyond the end of the file")}function oi(){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(oi()):new Promise((s,i)=>{let r=()=>{t.removeEventListener("abort",r),i(oi())};t.addEventListener("abort",r,{once:!0}),e.then(n=>{t.removeEventListener("abort",r),s(n)},n=>{t.removeEventListener("abort",r),i(n)})}):e}function ai(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,s])=>[t,zr(s)]))):e}var hi=class{item;previous;next;constructor(t,s,i){this.item=t,this.previous=s,this.next=i}};var ci=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let s=new hi(t,this.tail,null);return this.tail?(this.tail.next=s,this.tail=s):(this.head=s,this.tail=s),++this._length,s}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,s){t!==s&&(this.remove(s),this._insert(t,s))}_insert(t,s){let i=t.next;t.next=s,this.tail===t?this.tail=s:i.previous=s,s.next=i,s.previous=t,++this._length}};var xe=class{_list;_sentinel;_trimTiles;constructor(){this._list=new ci,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let s=t._cacheNode;s&&this._list.splice(this._sentinel,s)}add(t,s,i){s._cacheNode||(s._cacheNode=this._list.add(s),i&&i(t,s))}unloadTile(t,s,i){let r=s._cacheNode;r&&(this._list.remove(r),s._cacheNode=null,i&&i(t,s))}unloadTiles(t,s){let i=this._trimTiles;this._trimTiles=!1;let r=this._list,n=this._sentinel,o=r.head;for(;o!==n&&(t.gpuMemoryUsageInBytes>t.cacheBytes||i);){let a=o.item;o=o.next,this.unloadTile(t,a,s)}}trim(){this._trimTiles=!0}};function li(e,t){bt(e),bt(t);let{rtcCenter:s,gltfUpAxis:i}=t,{computedTransform:r,boundingVolume:{center:n}}=e,o=new I(r);switch(s&&o.translate(s),i){case"Z":break;case"Y":let f=new I().rotateX(Math.PI/2);o=o.multiplyRight(f);break;case"X":let m=new I().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=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 s=typeof t.scene=="number"?t.scene:0,r=t.scenes?.[s]?.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 ui(e,t,s={}){let{cameraUp:i,height:r}=e,n=e.cameraDirection,{metersPerUnit:o}=e.distanceScales,a=Je(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,T=Dr(w,e.cameraPosition),b=Je(e,T);u=new p(b).subtract(l).normalize()}let f=new p(h.transformAsVector(new p(i).scale(o))).normalize();qf(e);let m=e.constructor,{longitude:d,latitude:g,width:_,bearing:M,zoom:y}=e,E=new m({longitude:d,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:s.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,s,i){let r=Array.from(t),n=Array.from(s),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?i:e?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:r,direction:n,lastMovementTime:h},timeSinceMovement:Math.max((i-h)/1e3,0)}}function Ba(e,t,s){if(s===0||e.length<=s)return[e,[]];let i=[],{longitude:r,latitude:n}=t.viewport;for(let[c,l]of e.entries()){let[u,f]=l.header.mbs,m=Math.abs(r-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<s;c++)a.push(e[o[c][0]]);let h=[];for(let c=s;c<o.length;c++)h.push(e[o[c][0]]);return[a,h]}function qf(e){let t=e.getFrustumPlanes(),s=Dr(t.near,e.cameraPosition),i=Je(e,s),r=Je(e,e.cameraPosition,qr),n=0;Br.planes[n++].fromPointNormal(i,za.copy(i).subtract(r));for(let o in t){if(o==="near")continue;let a=t[o],h=Dr(a,s,qr),c=Je(e,h,qr);Br.planes[n++].fromPointNormal(c,za.copy(i).subtract(c))}}function Dr(e,t,s=new p){let i=e.normal.dot(t);return s.copy(e.normal).scale(e.distance-i).add(t),s}function Je(e,t,s=new p){let i=e.unprojectPosition(t);return P.WGS84.cartographicToCartesian(i,s)}var Va=new p,Bf=new p,ie=new p,Da=new p,ts=new p,Fa=new p,Ua=new p,ka=new p,fi=new yt,Df=new p(0,0,1);function ja(e,t){e._updateTransform(t)}function Wa(e,t,s){if(!Number.isFinite(s.dynamicScreenSpaceErrorDensity)||s.dynamicScreenSpaceErrorDensity<=0)return 0;let i=Vf(e),r=i.region?jf(i.region,t):Wf(e,i,t);if(!r)return 0;let n=Ue(s.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 s.dynamicScreenSpaceErrorDensity*l}function Ff(e,t){let s=e*t;return 1-Math.exp(-(s*s))}function Uf(e,t,s){return t<=0||s<=0||!Number.isFinite(t)||!Number.isFinite(s)?0:Ff(e,t)*s}function Ha(e,t,s,i=1){let r=e.tileset,n=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=s?n:e.lodMetricValue;if(o===0)return 0;let{viewDistanceScale:a}=r.options,h=a||1,c=Number.isFinite(i)?Math.max(i,0):1,l=kf(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 r.options.dynamicScreenSpaceError&&!t.viewport.orthographic&&(d-=Uf(u,t.dynamicScreenSpaceErrorDensity,r.options.dynamicScreenSpaceErrorFactor)),d}function kf(e,t,s,i){let r=t.viewport;if(!r?.orthographic)return null;let n=r.metersPerPixel;return!Number.isFinite(n)||!n||n<=0?null:e*s*i/n}function Vf(e){return e.header.content?.boundingVolume||e.header.boundingVolume}function jf(e,t){let s=Va.copy(t.camera.position).normalize(),i=ts.copy(t.camera.direction).normalize();return{cameraHeight:t.camera.cartographicPosition[2],minimumHeight:e[4],maximumHeight:e[5],cameraDirection:i,upDirection:s}}function Wf(e,t,s){let i=Hf(t,ie);if(i===null)return null;let r=new I(e.computedTransform).invert(),n=e.tileset.ellipsoid;if(Math.hypot(ie[0],ie[1],ie[2])>n.minimumRadius){let a=n.cartesianToCartographic(ie,Bf),h=Va.copy(s.camera.position).normalize(),c=ts.copy(s.camera.direction).normalize();return{cameraHeight:s.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:c,upDirection:h}}return r.transformAsPoint(s.camera.position,Da),r.transformAsVector(s.camera.direction,ts),ts.normalize(),{cameraHeight:Da[2],minimumHeight:ie[2]-i,maximumHeight:ie[2]+i,cameraDirection:ts,upDirection:Df}}function Hf(e,t){if(e.box){let s=e.box;return t.set(s[0],s[1],s[2]),Yf(s)}if(e.sphere){let s=e.sphere;return t.set(s[0],s[1],s[2]),s[3]}return null}function Yf(e){return e.length===10?(fi.fromArray(e,6),Fa.set(e[3],0,0).transformByQuaternion(fi),Ua.set(0,e[4],0).transformByQuaternion(fi),ka.set(0,0,e[5]).transformByQuaternion(fi),Math.abs(Fa[2])+Math.abs(Ua[2])+Math.abs(ka[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},J;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(J||(J={}));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 tt,Xa=new p,$a=new p,Fr=new p,di=new p;function Ur(e,t,s){return e+(t-e)*s}function Qa(e,t){let s=e instanceof tt?e:e.getBoundingSphere($f),{center:i,radius:r}=s;Xa.copy(i).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(i),Fr.magnitude()<=r||(di.copy(Fr).normalize().scale(r).add(i).subtract(t.position),di.magnitude()===0)?0:(di.normalize(),Math.min(Math.max(1-di.dot(t.direction),0),1))}function Ka(e,t,s,i){return!Number.isFinite(i)||i<=0||i>.5?!1:e>s?!0:t!==void 0&&t>s}function Ja(e){let t=Number.isFinite(e.foveatedConeSize)?Math.min(Math.max(e.foveatedConeSize,0),1):1,s=e.refinement===J.REPLACE;if(s&&!e.skipLevelOfDetail||!e.foveatedScreenSpaceError||t>=1||s&&e.skipLevelOfDetail&&e.priorityProgressiveResolution)return!1;let i=Number.isFinite(e.verticalFieldOfView)&&e.verticalFieldOfView>0?e.verticalFieldOfView:Math.PI/3,r=1-Math.cos(i*.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,s){return e&&Number.isFinite(t)&&Number.isFinite(s)&&s>0&&t<s}function eh(e){let t=e.rootScreenSpaceError>0?Math.min(Math.max(e.reverseScreenSpaceError/e.rootScreenSpaceError,0),1):0,s=Math.floor(t*(Za-1)),i=Number.isFinite(e.foveatedFactor)?Math.min(Math.max(e.foveatedFactor,0),1):0,r=Math.floor(i*(Za-1))*Zf;return(e.priorityProgressiveResolution?0:Xf)+r+s}var Qf="EPSG:4326",Kf="EPSG:4978";function Jf(e){let t=e.trim().toUpperCase(),s=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return s?`${s[1]}:${s[2]}`:t}function kt(e){if(typeof e=="string"){let s=Jf(e);return s===Kf||/^GEOCCS\s*[\[(]/.test(s)?"geocentric":s===Qf||s==="EPSG:4490"||s==="EPSG:4979"||s==="OGC:CRS84"||s.includes("+PROJ=LONGLAT")||s.includes("+PROJ=LATLONG")||/^(?:GEOGCS|GEOGCRS|GEOGRAPHICCRS|GEOGRAPHIC2DCRS|GEOGRAPHIC3DCRS)\s*[\[(]/.test(s)?"geographic":/^(?:GEODCRS|GEODETICCRS)\s*[\[(]/.test(s)?/CS\s*[\[(]\s*CARTESIAN/.test(s)?"geocentric":"geographic":"projected"}let t=e;return t.type==="BoundCRS"&&t.source_crs?kt(t.source_crs):t.type==="CompoundCRS"&&t.components?.[0]?kt(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 s=t.sourceCrs!==void 0,i=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),m=o!=="native"&&o!==e.heightReference,d=!!n||o!=="native"||r!=="auto"||f,g=r!=="target-crs"||!!n,_=!m||(e.heightReference||"unknown")!=="unknown",M=Number.isFinite(a)&&a>0&&Number.isFinite(h)&&h>0,y=!!i&&d&&g&&_&&M&&u&&r!=="local-enu",E=s?"caller-override":e.provenance||"unknown",w=s&&i?kt(i):e.coordinateFrame,T=s?"explicit":e.sourceCrsState||(i?E==="format-default"?"default":"explicit":"absent"),b=ai({crs:i?{state:T==="default"?"default":"explicit",definition:i,representation:!s&&e.sourceCrsRepresentation||Ke(i),provenance:E,alternatives:s?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:ed(e.axisOrder),units:s?void 0:e.units}),R=kr(b.crs),A=b.vertical?kr(b.vertical):void 0,C=n?td(n):void 0;return Object.freeze({...b,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:d?y?"transformable":"unresolved":"native",warnings:Object.freeze([...e.warnings||[]])})}function es(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 kr(e){return e.state==="explicit"||e.state==="default"?e.definition:void 0}function td(e){let t=ai({crs:{state:"explicit",definition:e,representation:Ke(e),provenance:"caller-override"}}),s=kr(t.crs);if(!s)throw new Error("Failed to normalize a known target CRS definition");return s}function ed(e){switch(e){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function mi(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 pi(e){return!!(e&&typeof e=="object"&&"initialize"in e&&"getRootTileset"in e&&"initializeTileHeaders"in e&&"loadTileContent"in e)}var st=1024*1024,Zr=512*st,Xr=512*st,sd=32*st,id=st;function ss(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 sh(e,t){let s=e.cacheBytes??(e.maximumMemoryUsage!==void 0?e.maximumMemoryUsage*st:t);return ss(s,"cacheBytes")}function ih(e,t){let s=e.maximumCacheOverflowBytes??(e.memoryCacheOverflow!==void 0?e.memoryCacheOverflow*st:t);return ss(s,"maximumCacheOverflowBytes")}var Vr={description:"",ellipsoid:P.WGS84,modelMatrix:new I,throttleRequests:!0,maxRequests:64,cacheBytes:Zr,maximumCacheOverflowBytes:Xr,maximumMemoryUsage:Zr/st,memoryCacheOverflow:Xr/st,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,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:{}},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",gi=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,s){if(!pi(t))throw new Error("Tileset3D requires a Tileset3DSource instance");let i=s||{},r=t.type===at.TILES3D,n=r?Vr.cacheBytes:sd,o=r?Vr.maximumCacheOverflowBytes:id,a=sh(i,n),h=ih(i,o);this.options={...Vr,...i,cacheBytes:a,maximumCacheOverflowBytes:h,maximumMemoryUsage:a/st,memoryCacheOverflow:h/st,memoryAdjustedScreenSpaceError:i.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=es(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=ss(t,"cacheBytes"),this.options.cacheBytes=this._cacheBytes,this.options.maximumMemoryUsage=this._cacheBytes/st}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(t){this._maximumCacheOverflowBytes=ss(t,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes,this.options.memoryCacheOverflow=this._maximumCacheOverflowBytes/st}get maximumMemoryUsage(){return this.cacheBytes/st}set maximumMemoryUsage(t){this.cacheBytes=ss(t*st,"maximumMemoryUsage")}get queryParams(){let t=this.source.getTileUrl(this.url),s=t.indexOf("?");return s>=0?t.slice(s+1):""}setProps(t){let s=sh(t,this.cacheBytes),i=ih(t,this.maximumCacheOverflowBytes);this.options={...this.options,...t,cacheBytes:s,maximumCacheOverflowBytes:i,maximumMemoryUsage:s/st,memoryCacheOverflow:i/st},this._cacheBytes=s,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(s=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),s(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this.cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this.cacheBytes+this.maximumCacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let s=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=s.length;let i=Date.now(),r=Number.POSITIVE_INFINITY,n=[];for(let o of s){let a=o.id;this._needTraverse(a)?n.push(a):this.traverseCounter--}for(let o of s){let a=o.id;if(this.roots[a]||(this.roots[a]=this._initializeTileHeaders(this.tileset,null)),!n.includes(a))continue;let h=ui(o,this._frameNumber),c=this.roots[a],l=qa(this._cameraMotionStates[a],h.camera.position,h.camera.direction,i);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(s=>{let i=s instanceof Error?s:new Error(String(s));this._onTilesetError(i)})},Math.max(t*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(t){let s=t;return this.options.viewportTraversersMap&&(s=this.options.viewportTraversersMap[t]),s===t}_onTraversalEnd(t){let s=t.viewport.id;this.frameStateData[s]||(this.frameStateData[s]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let i=this.frameStateData[s],r=Object.values(this._traverser.selectedTiles),[n,o]=Ba(r,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 s=new Set(this.selectedTiles.map(n=>n.id)),i=this.selectedTiles.some(n=>!n.tileDrawn),r=0;if(i){for(let n of s)this._heldTiles.add(n);for(let n of this._heldTiles){if(s.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=s;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,s){if(t.length!==s.length)return!0;let i=new Set(t.map(o=>o.id)),r=new Set(s.map(o=>o.id)),n=t.some(o=>!r.has(o.id));return n=n||s.some(o=>!i.has(o.id)),n}_loadTiles(){this._requestedTiles.sort((t,s)=>t._priority-s._priority);for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,s)=>t._unloadTile(s)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let t=0,s=0;for(let i of this.selectedTiles)if(i.contentAvailable&&i.content){t++;let r=i.contents.length?i.contents:[i.content];for(let n of r)n.pointCount?s+=n.pointCount:s+=n.vertexCount||0}this.stats.get(rh).count=this.selectedTiles.length,this.stats.get(nh).count=t,this.stats.get(ch).count=s,this.stats.get(lh).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let t=this.source.initialize(),s=this._getSourceMetadata();s&&this._syncSourceState(s),s?.tileset?.root&&typeof s.tileset.root.then!="function"&&!this.source.prepareTileset&&(this.root=this._initializeTileHeaders(s.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 s=t instanceof Error?t:new Error(String(t));throw this._onSourceError(s,this.root),this._onTilesetError(s),s}}_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,s){return this.source.initializeTileHeaders(this,t,s)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let s=null;try{this._onStartTileLoading(),s=await t.loadContent()}catch(i){let r=i instanceof Error?i:new Error("load failed");this._onSourceError(r,t),this._onTileLoadError(t,r)}finally{this._onEndTileLoading(),this._onTileLoad(t,s)}}async _loadTileChildren(t,s){try{this._onStartTileLoading(),await t.loadChildren(s)}catch(i){let r=i instanceof Error?i:new Error("subtree load failed");this._onSourceError(r,t),this._onTileLoadError(t,r)}finally{this._onEndTileLoading()}}_onTileLoadError(t,s){this.stats.get(hh).incrementCount();let i=s.message||s.toString(),r=t.url;console.error(`A 3D tile failed to load: ${t.url} ${i}`),this.options.onTileError(t,i,r)}_onSourceError(t,s=null){this.options.onSourceError(t,this.source,s)}_onTilesetError(t){this.options.onTilesetError(t,this)}_onTileLoad(t,s){if(!s?.loaded)return;t.content&&li(t,t.content),this.source.onTileLoaded?.(this,t,s),this._syncSourceState(this.source.getMetadata());let i=this.source.getTilesTotalCount?.();i&&(this.stats.get(jr).reset(),this.stats.get(jr).addCount(i)),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,s=>s._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 s=t.pop();for(let i of s.children)t.push(i);this._destroyTile(s)}this.root=null}_destroySubtree(t){let s=t,i=[s];for(;i.length>0;){t=i.pop();for(let r of t.children)i.push(r);t!==s&&this._destroyTile(t)}s.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_syncSourceState(t){this.tileset=t.tileset,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset;let s=t.tileset;this.schema=s.schema||null,this.schemaUri=s.schemaUri||null,this.groups=s.groups||[],this.metadata=s.metadata||null,this.statistics=s.statistics??null;let i=es(t.spatialReference,this.options.spatial);this.spatialReference=rd(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 rd(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 _i=class{sourceUrl;options;archivePromise;constructor(t){this.options=t,this.sourceUrl=nd(t.data,t.fallbackFilename)}async loadRoot(t,s,i){return await this.parseArchiveResource(t,this.options.rootPath,s,i,this.options.rootMode)}async loadResource(t,s,i){let r=this.resolveArchivePath(t,t);return await this.parseArchiveResource(t,r,s,i)}async parseArchiveResource(t,s,i,r,n){let o=this.options.getCoreApi();if(!o)throw new Error(this.options.missingCoreApiMessage);let a=await this.loadFile(s,n),h=this.createArchiveFetch(t);return await o.parse(a,i,{...r,fetch:h},{url:t,fetch:h,_parse:o.parse,loaders:[i],coreApi:o})}createArchiveFetch(t){return async s=>{let i=typeof s=="string"?s:s instanceof URL?s.toString():s.url,r=this.resolveArchivePath(i,t),n=await this.loadFile(r);return new Response(n,{status:200})}}async loadFile(t,s){this.archivePromise||=this.openArchiveReadableFile().then(r=>this.options.parseArchive(r));let i=await this.archivePromise;return await this.options.getFile(i,t,s)}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 s=this.options.getCoreApi();if(!s)throw new Error(this.options.missingCoreApiMessage);let i=await s.fetchFile(t);return new Me(await i.arrayBuffer())}resolveArchivePath(t,s){let i=$r(t),r=$r(this.sourceUrl),n=$r(s),o=n===r?r:gt.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(r)?i:n===r&&!c?`${r}/${i}`:gt.resolve(o,i);return l===r?"":l.startsWith(`${r}/`)?l.slice(r.length+1):l.replace(/^\/+/,"")}};function nd(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 it=new p,Mi=new p;function Se(e,t,s){if(bt(e,"3D Tile: boundingVolume must be defined"),e.box)return od(e.box,t,s);if(e.region)return Ir(e.region);if(e.sphere)return ad(e.sphere,t,s);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function fh(e,t){if(e.box)return hd(t);if(e.region){let[s,i,r,n,o,a]=e.region;return[[ot(s),ot(i),o],[ot(r),ot(n),a]]}if(e.sphere)return cd(t);throw new Error("Unkown boundingVolume type")}function od(e,t,s){let i=new p(e[0],e[1],e[2]);t.transform(i,i);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]),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]),r=[...u.toArray(),...f.toArray(),...m.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(s)?(s.center=i,s.halfAxes=h,s):new Nt(i,h)}function ad(e,t,s){let i=new p(e[0],e[1],e[2]);t.transform(i,i);let r=t.getScale(Mi),n=Math.max(Math.max(r[0],r[1]),r[2]),o=e[3]*n;return uh(s)?(s.center=i,s.radius=o,s):new tt(i,o)}function hd(e){let t=dh(),{halfAxes:s}=e,i=new p(s.getColumn(0)),r=new p(s.getColumn(1)),n=new p(s.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(r),it.add(n),mh(t,it),n.negate();r.negate()}i.negate()}return t}function cd(e){let t=dh(),{center:s,radius:i}=e,r=P.WGS84.scaleToGeodeticSurface(s,it),n;r?n=P.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]){Mi.copy(h).scale(i);for(let c=0;c<2;c++)it.copy(s),it.add(Mi),mh(t,it),Mi.negate()}return t}function dh(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function mh(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 Qr=new p,ph=new p,Kt=new p,gh=new p,ld=new p,Kr=new I,_h=new I;function xi(e,t){if(e.lodMetricValue===0||Number.isNaN(e.lodMetricValue))return"DIG";let s=2*Jr(e,t);if(s<2)return"OUT";if(!e.header.children)return"DRAW";switch(e.lodMetricType){case"screenSpaceRelative":{let i=t.topDownViewport.height||1;return s/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 s<=i?"DRAW":"DIG"}default:return s<=e.lodMetricValue?"DRAW":"DIG"}}function Jr(e,t){let{topDownViewport:s}=t,i=e.header.i3sLodMbs||e.header.mbs,r=i[1],n=i[0],o=i[2],a=i[3],h=[...e.boundingVolume.center],c=s.unprojectPosition(s.cameraPosition);P.WGS84.cartographicToCartesian(c,Qr),ph.copy(Qr).subtract(h).normalize(),P.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 m=gh.transform(Kr).subtract(h).normalize(),g=ph.cross(m).normalize().scale(a).add(h),_=P.WGS84.cartesianToCartographic(g),M=s.project([n,r,o]),y=s.project(_);return ld.copy(M).subtract(y).magnitude()}var is=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 bt(t<this._array.length),this._array[t]}set(t,s){bt(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=s,this._map.set(s,t)}delete(t){let s=this._map.get(t);s>=0&&(this._array.splice(s,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){let s=this.length++;this._array[s]=t,this._map.set(t,s)}}pop(){let t=this._array[--this.length];return this._map.delete(t),t}reserve(t){bt(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){bt(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 ud={loadSiblings:!1,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Gt=class{options;disableSkipLevelOfDetail=!1;root=null;selectedTiles={};requestedTiles={};deferredTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new is;_emptyTraversalStack=new is;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...ud,...t}}isSkipLevelOfDetailEnabled(){return this.options.skipLevelOfDetail&&!this.disableSkipLevelOfDetail}traverse(t,s,i){this.root=t,this.options={...this.options,...i},this.reset(),this.updateTile(t,s),this._frameNumber=s.frameNumber,this.executeTraversal(t,s)}reset(){this.requestedTiles={},this.deferredTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,s){let i=this._traversalStack;for(t._selectionDepth=1,i.push(t);i.length>0;){let r=i.pop(),n=!1;this.canTraverse(r,s)&&(this.updateChildTiles(r,s),n=this.updateAndPushChildren(r,s,i,r.hasRenderContent?r._selectionDepth+1:r._selectionDepth));let o=r.parent,a=!!(!o||o._shouldRefine),h=!n;r.hasRenderContent?r.refine===J.ADD?(this.loadTile(r,s),this.selectTile(r,s)):r.refine===J.REPLACE&&(this.loadTile(r,s),(h||this.isSkipLevelOfDetailEnabled())&&this.selectTile(r,s)):(this.emptyTiles[r.id]=r,this.loadTile(r,s),h&&this.selectTile(r,s)),this.touchTile(r,s),r._shouldRefine=n&&a}this.completeTraversal(s)}completeTraversal(t){let s=new Date().getTime();(this.traversalFinished(t)||s-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=s,this.options.onTraversalEnd(t))}updateChildTiles(t,s){let i=t.children;for(let r of i)this.updateTile(r,s)}updateAndPushChildren(t,s,i,r){let{loadSiblings:n}=this.options,o=this.isSkipLevelOfDetailEnabled(),a=t.children;a.sort(this.compareDistanceToCamera.bind(this));let h=t.refine===J.REPLACE&&t.hasRenderContent&&!o,c=!1,l=!0;for(let u of a)if(u._selectionDepth=r,u.isVisibleAndInRequestVolume?(i.find(u)&&i.delete(u),i.push(u),c=!0):(h||n)&&(this.loadTile(u,s),this.touchTile(u,s)),h){let f;if(u._inRequestVolume?u.hasRenderContent?f=u.contentAvailable:f=this.executeEmptyTraversal(u,s):f=!1,l=l&&f,!l)return!1}return c||(l=!1),l}updateTile(t,s){this.updateTileVisibility(t,s)}selectTile(t,s){this.shouldSelectTile(t,s)&&(t._selectedFrame=s.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,s){if(this.shouldLoadTile(t)){if(this.shouldDeferTileRequest(t)){this.deferredTiles[t.id]=t;return}t._requestedFrame=s.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t}}shouldDeferTileRequest(t){return t.priorityDeferred}touchTile(t,s){t.tileset._cache.touch(t),t._touchedFrame=s.frameNumber}canTraverse(t,s){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:this.shouldRefine(t,s):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t,s){return t.contentAvailable&&t.contentVisibility(s)!=="outside"}shouldRefine(t,s,i=!1){let r=t._screenSpaceError;return i&&(r=t.getScreenSpaceError(s,!0)),r>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,s){let i=[];if(this.options.viewportTraversersMap)for(let r in this.options.viewportTraversersMap)this.options.viewportTraversersMap[r]===s.viewport.id&&i.push(r);else i.push(s.viewport.id);t.updateVisibility(s,i)}compareDistanceToCamera(t,s){return t._distanceToCamera-s._distanceToCamera}anyChildrenVisible(t,s){let i=!1;for(let r of t.children)r.updateVisibility(s),i=i||r.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(t,s){let i=!0,r=!1,n=this._emptyTraversalStack;for(n.push(t);n.length>0;){let o=n.pop(),a=!o.hasRenderContent&&this.canTraverse(o,s),h=!o.hasRenderContent&&o.children.length===0;if(o.header.implicitSubtree&&(r=!0,i=!1),!a&&!o.contentAvailable&&!h&&(i=!1),this.updateTile(o,s),o.isVisibleAndInRequestVolume||(this.loadTile(o,s),this.touchTile(o,s)),a){let c=o.children;for(let l of c)n.push(l)}}return t.hasEmptyContent&&!r||i}};var tn=new p;function fd(e,t,s,i,r=[]){let n=e.length?e:[t],o=!1,a=!1;for(let h of n){let c="inside";if(i!==K.MASK_INSIDE&&(c=s.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 dd(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,s,i,r=""){this.header=s,this.tileset=t,this.id=r||s.id,this.url=s.url,this.parent=i,this.refine=this._getRefine(s.refine),this.type=s.type,this.contentUrl=s.contentUrl,this.contentUrls=s.contentUrls||(s.contentUrl?[s.contentUrl]:[]),this.metadata=s.metadata||null;let n=Array.isArray(s.content)?s.content:[s.content];this.contentMetadata=n.filter(Boolean).map(o=>o.metadata||null),this.childrenState=s.implicitSubtree?"unloaded":"ready",this._initializeLodMetric(s),this._initializeTransforms(s),this._updateLodMetricScale(),this._initializeBoundingVolumes(s),this._initializeContent(s),this._initializeRenderingState(s),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0||!!(this.header.implicitSubtree&&this.childrenState!=="ready")}get hasUnloadedChildren(){return!!(this.header.implicitSubtree&&(this.childrenState==="unloaded"||this.childrenState==="failed"))}get childrenLoading(){return this.childrenState==="loading"}get contentReady(){return this.contentState===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,s,i=1){switch(this.tileset.type){case at.I3S:return Jr(this,t);case at.TILES3D:return Ha(this,t,s,i);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return(this.contents.length?this.contents:[this.content]).reduce((s,i)=>s+(i?.gpuMemoryUsageInBytes||i?.byteLength||0),0)}_getPriority(){return this._calculateRequestPriority(!1)}_getChildrenPriority(){return this._calculateRequestPriority(!0)}_calculateRequestPriority(t){let s=this.tileset._traverser,i=s.options.skipLevelOfDetail&&!s.disableSkipLevelOfDetail,r=this.refine===J.ADD||i;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=s.root?s.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 s=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!s)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.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this.contentState=et.READY,this._onContentLoaded(),i}catch(i){throw this.contentState=et.FAILED,i}finally{s.done()}}async loadChildren(t){if(!this.header.implicitSubtree||this.childrenState==="ready")return{loaded:!1,tileCount:0,childSubtreeCount:0};if(this._childrenPromise)return await this._childrenPromise;if(!this.tileset.source.loadTileChildren)throw new Error("Tileset source does not support lazy tile children");this.childrenState="loading",this._childrenPromise=this._loadChildrenWithScheduler(t);try{return await this._childrenPromise}finally{this._childrenPromise=null}}async _loadChildrenWithScheduler(t){let s=await this.tileset._requestScheduler.scheduleRequest(`${this.id}:implicit-subtree`,this._getChildrenPriority.bind(this));if(!s)return this.childrenState="unloaded",{loaded:!1,tileCount:0,childSubtreeCount:0};try{let i=await this.tileset.source.loadTileChildren(this,t);return this.childrenState=i.loaded?"ready":"unloaded",i}catch(i){throw this.childrenState="failed",i}finally{s.done()}}applyImplicitSubtreeHeader(t){let s=this.header.transform,i=this.header.transformMatrix;this.header={...this.header,...t,transform:s,transformMatrix:i,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,s){if(this._frameNumber===t.frameNumber)return;let i=this.parent,r=i?i._visibilityPlaneMask:K.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,r),this._visible=this._visibilityPlaneMask!==K.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=s}_updateRequestPriorityMetrics(t){if(this.tileset.type!==at.TILES3D){this._screenSpaceErrorProgressiveResolution=this._screenSpaceError,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1;return}let s=this.tileset.options,i=s.progressiveResolutionHeightFraction;if(this._screenSpaceErrorProgressiveResolution=this.getScreenSpaceError(t,!1,i),this._priorityProgressiveResolution=Ka(this._screenSpaceErrorProgressiveResolution,this.parent?._screenSpaceErrorProgressiveResolution,this.tileset.memoryAdjustedScreenSpaceError,i),!s.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=this.tileset._traverser,n=r.options.skipLevelOfDetail&&!r.disableSkipLevelOfDetail,o=Ja({refinement:this.refine,skipLevelOfDetail:n,foveatedScreenSpaceError:s.foveatedScreenSpaceError,foveatedConeSize:s.foveatedConeSize,minimumScreenSpaceErrorRelaxation:s.foveatedMinimumScreenSpaceErrorRelaxation,interpolationCallback:s.foveatedInterpolationCallback,foveatedFactor:this._foveatedFactor,verticalFieldOfView:t.camera.verticalFieldOfView,screenSpaceError:this._screenSpaceError,parentScreenSpaceError:this.parent?._screenSpaceError,maximumScreenSpaceError:this.tileset.memoryAdjustedScreenSpaceError,priorityProgressiveResolution:this._priorityProgressiveResolution});this.priorityDeferred=th(o,t.camera.timeSinceMovement,s.foveatedTimeDelay)}visibility(t,s){let{cullingVolume:i}=t,{boundingVolume:r}=this;return i.computeVisibilityWithPlaneMask(r,s)}contentVisibility(t){return fd(this._contentBoundingVolumes,this.boundingVolume,t.cullingVolume,this._visibilityPlaneMask,t.clippingPlanes)}distanceToTile(t){let s=this.boundingVolume;return Math.sqrt(Math.max(s.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){let s=this.boundingVolume;return tn.subVectors(s.center,t.position),t.direction.dot(tn)}insideViewerRequestVolume(t){let s=this._viewerRequestVolume;return!s||s.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(dd(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 s=this.parent,i=this.tileset,r=s&&s.computedTransform?s.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new I(r).multiplyRight(this.transform);let n=s&&s._initialTransform?s._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),s=Math.max(t[0],t[1],t[2]);this.lodMetricValue=this._unscaledLodMetricValue*s}_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||J.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 s of t)switch(s&&s.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 s=t.content;s&&(this._contentBoundingVolumeHeaders=Array.isArray(s)?s:[s]);let i=s?Array.isArray(s)?s:[s]:this._contentBoundingVolumeHeaders;this._contentBoundingVolumes=i.length?i.map(r=>r?.boundingVolume?Se(r.boundingVolume,this.computedTransform):this.boundingVolume):[this.boundingVolume],this._contentBoundingVolume=this._contentBoundingVolumes[0]||null}_updateTransform(t=new I){let s=t.clone().multiplyRight(this.transform);s.equals(this.computedTransform)||(this.computedTransform=s,this._updateLodMetricScale(),this._updateBoundingVolume(this.header))}};var yi=class extends Gt{pendingImplicitSubtrees=new Map;traversalFinished(t){let s=`${t.viewport.id}:`;for(let[i,r]of this.pendingImplicitSubtrees)if(i.startsWith(s)&&r===t.frameNumber)return!1;return!0}executeTraversal(t,s){if(!this.isSkipLevelOfDetailEnabled()){super.executeTraversal(t,s);return}this.executeSkipTraversal(t,s)}executeSkipTraversal(t,s){let i=[t];for(t._selectionDepth=t.parent?t.parent._selectionDepth:1;i.length>0;){let r=i.pop(),n=!r.parent||r.parent._shouldRefine,o=this.canTraverse(r,s)&&this.updateAndPushSkipChildren(r,s,i)&&n,a=!o&&n;r.hasRenderContent?r.refine===J.ADD?(this.loadTile(r,s),this.selectDesiredTile(r,s)):r.refine===J.REPLACE&&(this.isInBaseTraversal(r,s)?(this.loadTile(r,s),a&&this.selectDesiredTile(r,s)):a?(this.loadTile(r,s),this.selectDesiredTile(r,s)):this.hasReachedSkippingThreshold(r,s)&&this.loadTile(r,s)):(this.emptyTiles[r.id]=r,this.loadTile(r,s),a&&this.selectDesiredTile(r,s)),this.touchTile(r,s),r._shouldRefine=o}this.completeTraversal(s)}updateAndPushSkipChildren(t,s,i){this.updateChildTiles(t,s),t.children.sort(this.compareDistanceToCamera.bind(this));let r=!1;for(let n of t.children)n._selectionDepth=t.hasRenderContent?t._selectionDepth+1:t._selectionDepth,n.isVisibleAndInRequestVolume?(i.push(n),r=!0):this.options.loadSiblings&&(this.loadTile(n,s),this.touchTile(n,s));return r}isInBaseTraversal(t,s){if(this.options.immediatelyLoadDesiredLevelOfDetail)return!1;if(!this.findNearestRequestedOrLoadedAncestor(t,s))return!0;let i=Number.isFinite(this.options.baseScreenSpaceError)?Math.max(this.options.baseScreenSpaceError,0):1024,r=Math.max(i,t.tileset.memoryAdjustedScreenSpaceError);return t._screenSpaceError===0&&t.parent?t.parent._screenSpaceError>r:t._screenSpaceError>r}hasReachedSkippingThreshold(t,s){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 r=this.findNearestRequestedOrLoadedAncestor(t,s);if(!r)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<r._screenSpaceError/n&&t.depth>r.depth+o}findNearestRequestedOrLoadedAncestor(t,s){let i=t.parent;for(;i;){if(i.hasRenderContent&&!i.contentFailed&&(!i.hasUnloadedContent||i._requestedFrame===s.frameNumber))return i;i=i.parent}return null}selectDesiredTile(t,s){let i=t;for(;i;){if(this.shouldSelectTile(i,s)){this.selectTile(i,s);return}i=i.parent}this.selectLoadedDescendants(t,s)}selectLoadedDescendants(t,s){let i=[{tile:t,depth:0}];for(;i.length>0;){let{tile:r,depth:n}=i.pop();for(let o of r.children)this.updateTile(o,s),o.isVisibleAndInRequestVolume&&(o.contentAvailable?(this.selectTile(o,s),this.touchTile(o,s)):n<1&&i.push({tile:o,depth:n+1}))}}compareDistanceToCamera(t,s){return s._distanceToCamera===0&&t._distanceToCamera===0?s._centerZDepth-t._centerZDepth:s._distanceToCamera-t._distanceToCamera}updateChildTiles(t,s){if(t.hasUnloadedChildren&&t.isVisibleAndInRequestVolume&&this.shouldRefine(t,s)){let i=`${s.viewport.id}:${t.id}`;this.pendingImplicitSubtrees.has(i)||(this.pendingImplicitSubtrees.set(i,s.frameNumber),t.tileset._loadTileChildren(t,s).finally(()=>{this.handleImplicitSubtreeLoad(t,s,i)}))}super.updateChildTiles(t,s)}handleImplicitSubtreeLoad(t,s,i){this.pendingImplicitSubtrees.delete(i),this._frameNumber===s.frameNumber&&(t.childrenState==="ready"?this.executeTraversal(t,s):this.traversalFinished(s)&&this.options.onTraversalEnd(s))}updateTileVisibility(t,s){if(super.updateTileVisibility(t,s),!t.isVisibleAndInRequestVolume)return;let i=t.children.length>0;if(t.hasTilesetContent&&i){let o=t.children[0];this.updateTileVisibility(o,s),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,s)){t._visible=!1;return}let r=t.refine===J.REPLACE,n=t._optimChildrenWithinParent===Ya.USE_OPTIMIZATION;if(r&&n&&i&&!this.anyChildrenVisible(t,s)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,s){let{parent:i}=t;return!i||i.hasTilesetContent||i.refine!==J.ADD?!1:!this.shouldRefine(t,s,!0)}};var md=6378137,pd=6378137,en=6356752314245179e-9,ve=new p;function Mh(e,t){if(e instanceof Nt){let{halfAxes:s}=e,i=gd(s);return Math.log2(en/(i+t[2]))}else if(e instanceof tt){let{radius:s}=e;return Math.log2(en/(s+t[2]))}else if(e.width&&e.height){let{width:s,height:i}=e,r=Math.log2(md/s),n=Math.log2(pd/i);return(r+n)/2}return 1}function sn(e,t,s){P.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],ve);let i=Math.sqrt(Math.pow(ve[0]-s[0],2)+Math.pow(ve[1]-s[1],2)+Math.pow(ve[2]-s[2],2));return Math.log2(en/(i+t[2]))}function xh(e,t,s){let[i,r,n,o]=e;return sn({xmin:i,xmax:n,ymin:r,ymax:o,zmin:0,zmax:0},t,s)}function gd(e){e.getColumn(0,ve);let t=e.getColumn(1),s=e.getColumn(2);return ve.add(t).add(s).len()}var _d=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}),Md=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 rs(e){if(!e)return;let t=e.trim().toLowerCase().replaceAll("_","-"),s=Md[t]||t;return _d[s]}function yh(e,t){return t!==void 0?Number.isFinite(t)&&t>0?t:void 0:e?rs(e):1}function Si(e){let t=e.spatialReference||e.fullExtent?.spatialReference,s=vd(t),i=e.heightModelInfo?.vertCRS||Ed(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?Td(t?.wkt):wd(h),l=xd(c,n,e.ZFactor),u=[],f=yd(e.elevationInfo?.mode),m=e.elevationInfo?e.elevationInfo.unit||"meter":void 0,d=rs(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`),vt({sourceCrs:s,sourceCrsRepresentation:h!==void 0?"identifier":s?"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:s?"xyz":"unknown",provenance:s?"metadata":"unknown",warnings:u})}function xd(e,t,s){if(e==="geocentric")return["meter","meter","meter"];if(e==="geographic"&&(t||s===void 0))return["degree","degree",t||"meter"]}function yd(e){switch(e){case"absoluteHeight":case"onTheGround":case"relativeToGround":case"relativeToScene":return e;default:return}}function vi(e){let t=Sh(e,"TILESET_CRS_GEOCENTRIC"),s=Sh(e,"TILESET_CRS_COORDINATE_EPOCH"),i=[],r,n="unknown",o;typeof t=="string"&&t.toUpperCase()!=="UNKNOWN"?(r=t,n="metadata",o="explicit"):t!==void 0?(i.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&&i.push("External 3D Tiles metadata schema must be loaded before CRS semantics can resolve");let a=Sd(s);return s!==void 0&&a===void 0&&i.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:i})}function Sd(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 vd(e){let t=vh(e);return t!==void 0?`EPSG:${t}`:e?.wkt}function Ed(e){let t=e?.latestVcsWkid??e?.vcsWkid;return t===void 0?void 0:`EPSG:${t}`}function vh(e){return e?.latestWkid??e?.wkid}function wd(e){return e===4978?"geocentric":e===4326||e===4490||e===4979?"geographic":"projected"}function Td(e){if(!e)return"unknown";let t=e.trim().toUpperCase(),s=t.match(/^([A-Z][A-Z0-9_]*)\s*[\[(]/)?.[1];if(s==="GEOCCS")return"geocentric";if(s==="GEOGCS"||s==="GEOGRAPHICCRS"||s==="GEOGRAPHIC2DCRS"||s==="GEOGRAPHIC3DCRS")return"geographic";if(s==="PROJCS"||s==="PROJCRS"||s==="PROJECTEDCRS")return"projected";if(s==="GEODCRS"||s==="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 s=e.metadata?.class;if(!s)return;let r=e.schema?.classes?.[s]?.properties,n=e.metadata?.properties;for(let[o,a]of Object.entries(r||{}))if(a.semantic===t)return n?.[o]}var bd=4,Pd=8;function nn(e,t){return{coordinates:t,subtreeUrl:wi(e.subtreesUrlTemplate,t),descriptor:e}}function Ei(e,t){let{descriptor:s}=t;Ld(s);let i={tileCount:0,childSubtreeCount:0},r=wh(e,t,{localLevel:0,mortonIndex:0},t.coordinates,i);if(!r)throw new Error(`Invalid 3D Tiles subtree: root tile is unavailable at ${t.subtreeUrl}`);return{root:r,...i}}function wi(e,t){let s={level:t.level,x:t.x,y:t.y,z:t.z};return e.replace(/{(level|x|y|z)}/gi,(i,r)=>String(s[r.toLowerCase()]))}function wh(e,t,s,i,r){let{descriptor:n}=t,o=Od(n.subdivisionScheme),a=Id(o,s.localLevel)+s.mortonIndex;if(!rn(e.tileAvailability,a))return null;r.tileCount++;let h=Ad(e.contentAvailability,a),c=[];if(i.level<n.maximumLevel)if(s.localLevel+1<n.subtreeLevels)for(let l=0;l<o;l++){let u=Eh(i,l,n.subdivisionScheme),f=wh(e,t,{localLevel:s.localLevel+1,mortonIndex:s.mortonIndex*o+l},u,r);f&&c.push(f)}else for(let l=0;l<o;l++){let u=s.mortonIndex*o+l;if(rn(e.childSubtreeAvailability,u)){let f=Eh(i,l,n.subdivisionScheme);c.push(Rd(e,n,f)),r.childSubtreeCount++}}return Cd(e,n,t,i,h,c)}function Rd(e,t,s){let i=nn(t,s);return{id:bh(i,s),children:[],implicitSubtree:i,boundingVolume:Ph(t.rootBoundingVolume,s,t.subdivisionScheme),geometricError:t.rootLodMetricValue/2**s.level,lodMetricType:t.lodMetricType,lodMetricValue:t.rootLodMetricValue/2**s.level,refine:t.refine,type:Lt.EMPTY,implicitMetadata:Th(e)}}function Cd(e,t,s,i,r,n){let a=(t.contentUrlTemplates?.length?t.contentUrlTemplates:[t.contentUrlTemplate]).map((f,m)=>!r[m]||!f?null:{contentIndex:m,contentUrl:wi(f,i)}).filter(f=>!!f),h=a.map(f=>f.contentUrl),c=a.map(({contentIndex:f,contentUrl:m})=>({...t.contentHeaders?.[f]||(f===0?t.contentHeader:{})||{},uri:m})),l=h[0],u=t.rootLodMetricValue/2**i.level;return{id:bh(s,i),children:n,contentUrl:l,content:c.length>1?c:c[0],contentUrls:h,refine:t.refine,type:Nd(l),lodMetricType:t.lodMetricType,lodMetricValue:u,geometricError:u,boundingVolume:Ph(t.rootBoundingVolume,i,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 bh(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 s=e?.explicitBitstream;if(!s)return!1;let i=Math.floor(t/8),r=t%8;return!!(s[i]>>r&1)}function Ad(e,t){return(Array.isArray(e)?e:[e]).map(i=>rn(i||{constant:0},t))}function Id(e,t){return(e**t-1)/(e-1)}function Eh(e,t,s){return{level:e.level+1,x:e.x*2+(t&1),y:e.y*2+(t>>1&1),z:s==="OCTREE"?e.z*2+(t>>2&1):0}}function Od(e){return e==="OCTREE"?Pd:bd}function Ph(e,t,s){if(e.region){let[i,r,n,o,a,h]=e.region,c=2**t.level,l=(n-i)/c,u=(o-r)/c,f=i+l*t.x,m=r+u*t.y,d=a,g=h;if(s==="OCTREE"){let _=(h-a)/c;d=a+_*t.z,g=d+_}return{region:[f,m,f+l,m+u,d,g]}}if(e.box){if(e.s2VolumeInfo)return{box:[...e.box],s2VolumeInfo:e.s2VolumeInfo};let i=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=s==="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]/r,i[4]/r,i[5]/r,i[6]/r,i[7]/r,i[8]/r,h?i[9]/r:i[9],h?i[10]/r:i[10],h?i[11]/r:i[11]]}}throw new Error(`Unsupported implicit 3D Tiles bounding volume: ${JSON.stringify(e)}`)}function Nd(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 Ld(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 Gd={draco:!1,meshopt:!1,dds:!1,ktx2:!1},zd=32,Ti=class{type=at.TILES3D;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...Gd};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,s={}){let i=qd(t);this.rootTileset=Rh(t)?null:t,this.tileset=this.rootTileset,this.loader=i.loader,this.url=i.url,this.basePath=i.basePath||gt.dirname(i.url),this.resolver=i.resolver,this.coreApi=i.coreApi,this.loadOptions=s;let r=Number(s["3d-tiles"]?.maximumCachedSubtrees),n=Number.isFinite(r)?Math.max(0,Math.floor(r)):zd;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[s,i]of t.entries())this.setQueryParameter(s,i)}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:vi(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,s,i){let r=new Et(t,s.root,i||void 0);i&&(i.children.push(r),r.depth=i.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 yi(t)}async loadTileContent(t){let s=(t.contentUrls||[t.contentUrl]).filter(Boolean),i=this.loadOptions[this.loader.id]||{},r={...this.loadOptions,[this.loader.id]:{...i,isTileset:"auto",assetGltfUpAxis:this.asset&&this.asset.gltfUpAxis||"Y"}},n=await Promise.all(s.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,s){let i=t.header.implicitSubtree;if(!i)return{loaded:!1,tileCount:0,childSubtreeCount:0};let r=this.getTileUrl(i.subtreeUrl),n=await this.loadImplicitSubtreeResource(r);if(this.destroyed||t.isDestroyed())return{loaded:!1,tileCount:0,childSubtreeCount:0};let o=Ei(n,{...i,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 s=this.tileUrlCache.get(t);if(s)return s;if(!Object.keys(this.queryParams).length)return this.tileUrlCache.set(t,t),t;let[i,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?`${i}?${o}`:i;return this.tileUrlCache.set(t,a),a}setQueryParameter(t,s){this.queryParams[t]!==s&&(this.queryParams[t]=s,this.tileUrlCache.clear())}getViewState(t){if(!t)return{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits};let{center:s}=t.boundingVolume,i;return s&&(s[0]!==0||s[1]!==0||s[2]!==0)?(i=new p,P.WGS84.cartesianToCartographic(s,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:s,zoom:Mh(t.boundingVolume,i)}}hasExtension(t){return this.extensionsUsed.includes(t)}onTileLoaded(t,s,i){let n=(s.contents.length?s.contents:[s.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(a,s)}async loadWithCoreApi(t,s,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,s)}async loadRootData(t,s){return this.resolver?await this.resolver.loadRoot(t,this.loader,s):await this.loadWithCoreApi(t,s)}async loadResourceData(t,s,i=this.loader){return this.resolver?await this.resolver.loadResource(t,i,s):await this.loadWithCoreApi(t,s,i)}async loadImplicitSubtreeResource(t){let s=this.implicitSubtreeCache.get(t);if(s)return this.implicitTilingStats.cacheHits++,await s;this.implicitTilingStats.requestedSubtrees++;let i=this.loadOptions[this.loader.id]||{};return await this.implicitSubtreeCache.getOrLoad(t,async()=>await this.loadResourceData(t,{...this.loadOptions,[this.loader.id]:{...i,isTileset:!1,isSubtree:!0}}))}initializeMaterializedChildren(t,s,i){let r=0,n=[{parentTile:s,childHeaders:i}];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 qd(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 bi=class{frameNumberMap=new Map;register(t,s){let i=this.frameNumberMap.get(t)||new Map,r=i.get(s)||0;i.set(s,r+1),this.frameNumberMap.set(t,i)}deregister(t,s){let i=this.frameNumberMap.get(t);if(!i)return;let r=i.get(s)||1;i.set(s,r-1)}isZero(t,s){return(this.frameNumberMap.get(t)?.get(s)||0)===0}};var on={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},Pi=class{_statusMap;pendingTilesRegister=new bi;constructor(){this._statusMap={}}add(t,s,i,r){if(!this._statusMap[s]){let{frameNumber:n,viewport:{id:o}}=r;this._statusMap[s]={request:t,callback:i,key:s,frameState:r,status:on.REQUESTED},this.pendingTilesRegister.register(o,n),t().then(a=>{this._statusMap[s].status=on.COMPLETED;let{frameNumber:h,viewport:{id:c}}=this._statusMap[s].frameState;this.pendingTilesRegister.deregister(c,h),this._statusMap[s].callback(a,r)}).catch(a=>{this._statusMap[s].status=on.ERROR;let{frameNumber:h,viewport:{id:c}}=this._statusMap[s].frameState;this.pendingTilesRegister.deregister(c,h),i(a)})}}update(t,s){if(this._statusMap[t]){let{frameNumber:i,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,i);let{frameNumber:n,viewport:{id:o}}=s;this.pendingTilesRegister.register(o,n),this._statusMap[t].frameState=s}}find(t){return this._statusMap[t]}hasPendingTiles(t,s){return!this.pendingTilesRegister.isZero(t,s)}};var Ri=class extends Gt{_tileManager;constructor(t){super(t),this._tileManager=new Pi}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,s){return t._lodJudge=xi(t,s),t._lodJudge==="DIG"}updateChildTiles(t,s){let i=t.header.children||[],r=t.children;for(let n of i){let o=`${n.id}-${s.viewport.id}`,a=r&&r.find(h=>h.id===o);if(a)a&&this.updateTile(a,s);else{let h=()=>this._loadTile(t,n.id,s);this._tileManager.find(o)?this._tileManager.update(o,s):this._tileManager.add(h,o,l=>this._onTileLoad(l,t,o),s)}}return!1}async _loadTile(t,s,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,s,i)}_onTileLoad(t,s,i){if(t instanceof Error){s.tileset._onSourceError(t,s);return}let r=new Et(s.tileset,t,s,i);s.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 Pt=1,Rt=2,Vt=3,Ah=4,ns=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 s=Object.keys(e),i=t.toLowerCase().replace(qh,""),r=-1,n,o;++r<s.length;)if(n=s[r],o=n.toLowerCase().replace(qh,""),o===i)return e[n]}function os(e){var t={},s=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,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(i in s)r=s[i],i in o?(n=o[i],typeof n=="function"?n(r):t[n]=r):t[i]=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 s=t.find(i=>Array.isArray(i)&&i[0]==="ID");return s&&s.length>=3?{authority:s[1],code:parseInt(s[2],10)}:null}static convertUnit(t,s="unit"){if(!t||t.length<3)return{type:s,name:"unknown",conversion_factor:null};let i=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:s,name:i,conversion_factor:r,id:o}}static convertAxis(t){let s=t[1]||"Unknown",i,r=s.match(/^\((.)\)$/);if(r){let c=r[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:s,direction:i,unit:h,order:o}}static extractAxes(t){return t.filter(s=>Array.isArray(s)&&s[0]==="AXIS").map(s=>this.convertAxis(s)).sort((s,i)=>(s.order||0)-(i.order||0))}static convert(t,s={}){switch(t[0]){case"PROJCRS":s.type="ProjectedCRS",s.name=t[1],s.base_crs=t.find(d=>Array.isArray(d)&&d[0]==="BASEGEOGCRS")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="BASEGEOGCRS")):null,s.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&&(s.coordinate_system={subtype:i[1],axis:this.extractAxes(t)});let r=t.find(d=>Array.isArray(d)&&d[0]==="LENGTHUNIT");if(r){let d=this.convertUnit(r);s.coordinate_system.unit=d}s.id=this.getId(t);break;case"BASEGEOGCRS":case"GEOGCRS":case"GEODCRS":s.type=t[0]==="GEODCRS"?"GeodeticCRS":"GeographicCRS",s.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"?s.datum_ensemble=d:s.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");s.coordinate_system={subtype:o?o[1]:"ellipsoidal",axis:this.extractAxes(t)},s.id=this.getId(t);break;case"DATUM":s.type="GeodeticReferenceFrame",s.name=t[1],s.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":s.type="DatumEnsemble",s.name=t[1],s.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&&(s.accuracy=parseFloat(a[1]));let h=t.find(d=>Array.isArray(d)&&d[0]==="ELLIPSOID");h&&(s.ellipsoid=this.convert(h)),s.id=this.getId(t);break;case"ELLIPSOID":s.type="Ellipsoid",s.name=t[1],s.semi_major_axis=parseFloat(t[2]),s.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"),s):null;break;case"CONVERSION":s.type="Conversion",s.name=t[1],s.method=t.find(d=>Array.isArray(d)&&d[0]==="METHOD")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="METHOD")):null,s.parameters=t.filter(d=>Array.isArray(d)&&d[0]==="PARAMETER").map(d=>this.convert(d));break;case"METHOD":s.type="Method",s.name=t[1],s.id=this.getId(t);break;case"PARAMETER":s.type="Parameter",s.name=t[1],s.value=parseFloat(t[2]),s.unit=this.convertUnit(t.find(d=>Array.isArray(d)&&(d[0]==="LENGTHUNIT"||d[0]==="ANGLEUNIT"||d[0]==="SCALEUNIT"))),s.id=this.getId(t);break;case"BOUNDCRS":s.type="BoundCRS";let l=t.find(d=>Array.isArray(d)&&d[0]==="SOURCECRS");if(l){let d=l.find(g=>Array.isArray(g));s.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));s.target_crs=d?this.convert(d):null}let f=t.find(d=>Array.isArray(d)&&d[0]==="ABRIDGEDTRANSFORMATION");f?s.transformation=this.convert(f):s.transformation=null;break;case"ABRIDGEDTRANSFORMATION":if(s.type="Transformation",s.name=t[1],s.method=t.find(d=>Array.isArray(d)&&d[0]==="METHOD")?this.convert(t.find(d=>Array.isArray(d)&&d[0]==="METHOD")):null,s.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}}}),s.parameters.length===7){let d=s.parameters[6];d.name==="Scale difference"&&(d.value=Math.round((d.value-1)*1e12)/1e6)}s.id=this.getId(t);break;case"AXIS":s.coordinate_system||(s.coordinate_system={type:"unspecified",axis:[]}),s.coordinate_system.axis.push(this.convertAxis(t));break;case"LENGTHUNIT":let m=this.convertUnit(t,"LinearUnit");s.coordinate_system&&s.coordinate_system.axis&&s.coordinate_system.axis.forEach(d=>{d.unit||(d.unit=m)}),m.conversion_factor&&m.conversion_factor!==1&&s.semi_major_axis&&(s.semi_major_axis={value:s.semi_major_axis,unit:m});break;default:s.keyword=t[0];break}return s}},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=Ud,as=1,kh=2,Vh=3,Ci=4,jh=5,ln=-1,Bd=/\s/,Dd=/[A-Za-z]/,Fd=/[A-Za-z84_]/,Ai=/[,\]]/,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=as}jt.prototype.readCharicter=function(){var e=this.text[this.place++];if(this.state!==Ci)for(;Bd.test(e);){if(this.place>=this.text.length)return;e=this.text[this.place++]}switch(this.state){case as:return this.neutral(e);case kh:return this.keyword(e);case Ci:return this.quoted(e);case jh:return this.afterquote(e);case Vh:return this.number(e);case ln:return}};jt.prototype.afterquote=function(e){if(e==='"'){this.word+='"',this.state=Ci;return}if(Ai.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=as;return}if(e==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=as,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(Ai.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(Fd.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=as;return}if(Ai.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(Dd.test(e)){this.word=e,this.state=kh;return}if(e==='"'){this.word="",this.state=Ci;return}if(Wh.test(e)){this.word=e,this.state=Vh;return}if(Ai.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 Ud(e){var t=new jt(e);return t.output()}function un(e,t,s){Array.isArray(t)&&(s.unshift(t),t=null);var i=t?{}:e,r=s.reduce(function(n,o){return ne(o,n),n},i);t&&(e[t]=r)}function ne(e,t){if(!Array.isArray(e)){t[e]=!0;return}var s=e.shift();if(s==="PARAMETER"&&(s=e.shift()),e.length===1){if(Array.isArray(e[0])){t[s]={},ne(e[0],t[s]);return}t[s]=e[0];return}if(!e.length){t[s]=!0;return}if(s==="TOWGS84"){t[s]=e;return}if(s==="AXIS"){s in t||(t[s]=[]),t[s].push(e);return}Array.isArray(s)||(t[s]={});var i;switch(s){case"UNIT":case"PRIMEM":case"VERT_DATUM":t[s]={name:e[0].toLowerCase(),convert:e[1]},e.length===3&&ne(e[2],t[s]);return;case"SPHEROID":case"ELLIPSOID":t[s]={name:e[0],a:e[1],rf:e[2]},e.length===4&&ne(e[3],t[s]);return;case"EDATUM":case"ENGINEERINGDATUM":case"LOCAL_DATUM":case"DATUM":case"VERT_CS":case"VERTCRS":case"VERTICALCRS":e[0]=["name",e[0]],un(t,s,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,s,e),t[s].type=s;return;default:for(i=-1;++i<e.length;)if(!Array.isArray(e[i]))return ne(e,t[s]);return un(t,s,e)}}var kd=.017453292519943295;function Mt(e){return e*kd}function Ii(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 hs(e,t={}){return!e||typeof e!="object"?e:e.type==="BoundCRS"?(hs(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(s=>s.value)),t):(Object.keys(e).forEach(s=>{let i=e[s];if(i!==null)switch(s){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,Zh(i,t)),i.prime_meridian&&(t.from_greenwich=i.prime_meridian.longitude*Math.PI/180);break;case"ellipsoid":t.ellps=i.name,Zh(i,t);break;case"prime_meridian":t.long0=(i.longitude||0)*Math.PI/180;break;case"coordinate_system":if(i.axis){let r={east:"e",north:"n",west:"w",south:"s",up:"u",down:"d",geocentricx:"e",geocentricy:"n",geocentricz:"u"},n=i.axis.map(o=>r[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}=Hh(i.unit);t.units=o,t.to_meter=a}else if(i.axis[0]&&i.axis[0].unit){let{units:o,to_meter:a}=Hh(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(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":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":hs(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),Ii(t),t)}var Vd=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function jd(e,t){var s=t[0],i=t[1];!(s in e)&&i in e&&(e[s]=e[i],t.length===3&&(e[s]=t[2](e[s])))}function Xh(e){for(var t=Object.keys(e),s=0,i=t.length;s<i;++s){var r=t[s];Vd.indexOf(r)!==-1&&Wd(e[r]),typeof e[r]=="object"&&Xh(e[r])}}function Wd(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 s="",i=0,r=e.AXIS.length;i<r;++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"?s+="n":n[0].indexOf("south")!==-1||(n[0]==="y"||n[0]==="lat")&&n[1]==="south"?s+="s":n[0].indexOf("east")!==-1||(n[0]==="x"||n[0]==="lon")&&n[1]==="east"?s+="e":(n[0].indexOf("west")!==-1||(n[0]==="x"||n[0]==="lon")&&n[1]==="west")&&(s+="w")}s.length===2&&(s+="u"),s.length===3&&(e.axis=s)}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 jd(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),Ii(e)}function Ee(e){if(typeof e=="object")return hs(e);let t=Fh(e);var s=Uh(e);if(t==="WKT2"){let n=Dh(s);return hs(n)}var i=s[0],r={};return ne(s,r),Xh(r),r[i]}function lt(e){var t=this;if(arguments.length===2){var s=arguments[1];typeof s=="string"?s.charAt(0)==="+"?lt[e]=os(arguments[1]):lt[e]=Ee(arguments[1]):s&&typeof s=="object"&&!("projName"in s)?lt[e]=Ee(arguments[1]):(lt[e]=s,s||delete lt[e])}else if(arguments.length===1){if(Array.isArray(e))return e.map(function(i){return Array.isArray(i)?lt.apply(t,i):lt(i)});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 Hd(e){return typeof e=="string"}function Yd(e){return e in we}function Zd(e){return e.indexOf("+")!==0&&e.indexOf("[")!==-1||typeof e=="object"&&!("srsCode"in e)}var $h=["3857","900913","3785","102113"];function Xd(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 s=_t(t,"epsg");return s&&$h.indexOf(s)>-1}}function $d(e){var t=_t(e,"extension");if(t)return _t(t,"proj4")}function Qd(e){return e[0]==="+"}function Kd(e){let t;if(Hd(e))if(Yd(e))t=we[e];else if(Zd(e)){t=Ee(e);var s=$d(t);s&&(t=os(s))}else Qd(e)&&(t=os(e));else"projName"in e?t=e:t=Ee(e);return t&&Xd(t)?we["EPSG:3857"]:t}var Qh=Kd;function fn(e,t){e=e||{};var s,i;if(!t)return e;for(i in t)s=t[i],s!==void 0&&(e[i]=s);return e}function rt(e,t,s){var i=e*t;return s/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)*Jt}function ht(e,t,s){var i=e*s,r=.5*e;return i=Math.pow((1-i)/(1+i),r),Math.tan(.5*(x-t))/i}function Wt(e,t){for(var s=.5*e,i,r,n=x-2*Math.atan(t),o=0;o<=15;o++)if(i=e*Math.sin(n),r=x-2*Math.atan(t*Math.pow((1-i)/(1+i),s))-n,n+=r,Math.abs(r)<=1e-10)return n;return-9999}function Jd(){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 tm(e){var t=e.x,s=e.y;if(s*X>90&&s*X<-90&&t*X>180&&t*X<-180)return null;var i,r;if(Math.abs(Math.abs(s)-x)<=v)return null;if(this.sphere)i=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*s));else{var n=Math.sin(s),o=ht(this.e,s,n);i=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=i,e.y=r,e}function em(e){var t=e.x-this.x0,s=e.y-this.y0,i,r;if(this.sphere)r=x-2*Math.atan(Math.exp(-s/(this.a*this.k0)));else{var n=Math.exp(-s/(this.a*this.k0));if(r=Wt(this.e,n),r===-9999)return null}return i=S(this.long0+t/(this.a*this.k0),this.over),e.x=i,e.y=r,e}var sm=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","Mercator_Variant_A","merc"],Kh={init:Jd,forward:tm,inverse:em,names:sm};function im(){}function Jh(e){return e}var dn=["longlat","identity"],tc={init:im,forward:Jh,inverse:Jh,names:dn};var rm=[Kh,tc],oe={},Te=[];function ec(e,t){var s=Te.length;return e.names?(Te[s]=e,e.names.forEach(function(i){oe[i.toLowerCase()]=s}),this):(console.log(t),!0)}function mn(e){return e.replace(/[-\(\)\s]+/g," ").trim().replace(/ /g,"_")}function nm(e){if(!e)return!1;var t=e.toLowerCase();if(typeof oe[t]<"u"&&Te[oe[t]]||(t=mn(t),t in oe&&Te[oe[t]]))return Te[oe[t]]}function om(){rm.forEach(ec)}var sc={start:om,add:ec,get:nm};var am={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=am;var hm=pn.WGS84;function ic(e,t,s,i){var r=e*e,n=t*t,o=(r-n)/r,a=0;i?(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,s,i,r){if(!e){var n=_t(pn,i);n||(n=hm),e=n.a,t=n.b,s=n.rf}return s&&!t&&(t=(1-1/s)*e),(s===0||Math.abs(e-t)<v)&&(r=!0,t=e),{a:e,b:t,rf:s,sphere:r}}var Ni={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 Ni)Oi=Ni[nc],Oi.datumName&&(Ni[Oi.datumName]=Oi);var Oi,nc,oc=Ni;function cm(e,t,s,i,r,n,o){var a={};return a.datum_type=ns,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=Pt),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=Vt,a.grids=o),a.a=s,a.b=i,a.es=r,a.ep2=n,a}var ac=cm;var _n={};function Mn(e,t,s){return t instanceof ArrayBuffer?lm(e,t,s):{ready:um(e,t)}}function lm(e,t,s){var i=!0;s!==void 0&&s.includeErrorFields===!1&&(i=!1);var r=new DataView(t),n=dm(r),o=mm(r,n),a=pm(r,o,n,i),h={header:o,subgrids:a};return _n[e]=h,h}async function um(e,t){for(var s=[],i=await t.getImageCount(),r=i-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],m=c[3]-(h[1]-1)*u[1],d=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(d[M])])}s.push({del:u,lim:h,ll:[-f,m],cvs:_})}var y={header:{nSubgrids:i},subgrids:s};return _n[e]=y,y}function cc(e){if(e===void 0)return null;var t=e.split(",");return t.map(fm)}function fm(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 dm(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 mm(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,s){return String.fromCharCode.apply(null,new Uint8Array(e.buffer.slice(t,s)))}function pm(e,t,s,i){for(var r=176,n=[],o=0;o<t.nSubgrids;o++){var a=_m(e,r,s),h=Mm(e,r,a,s,i),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:gm(h)});var u=16;i===!1&&(u=8),r+=176+a.gridNodeCount*u}return n}function gm(e){return e.map(function(t){return[te(t.longitudeShift),te(t.latitudeShift)]})}function _m(e,t,s){return{name:gn(e,t+8,t+16).trim(),parent:gn(e,t+24,t+24+8).trim(),lowerLatitude:e.getFloat64(t+72,s),upperLatitude:e.getFloat64(t+88,s),lowerLongitude:e.getFloat64(t+104,s),upperLongitude:e.getFloat64(t+120,s),latitudeInterval:e.getFloat64(t+136,s),longitudeInterval:e.getFloat64(t+152,s),gridNodeCount:e.getInt32(t+168,s)}}function Mm(e,t,s,i,r){var n=t+176,o=16;r===!1&&(o=8);for(var a=[],h=0;h<s.gridNodeCount;h++){var c={latitudeShift:e.getFloat32(n+h*o,i),longitudeShift:e.getFloat32(n+h*o+4,i)};r!==!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 be(e,t){if(!(this instanceof be))return new be(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 s=Qh(e);if(typeof s!="object"){t("Could not parse to valid json: "+e);return}var i=be.projections.get(s.projName);if(!i){t("Could not get projection name from: "+e);return}if(s.datumCode&&s.datumCode!=="none"){var r=_t(oc,s.datumCode);r&&(s.datum_params=s.datum_params||(r.towgs84?r.towgs84.split(","):null),s.ellps=r.ellipse,s.datumName=r.datumName?r.datumName:s.datumCode)}s.axis=s.axis||"enu",s.ellps=s.ellps||"wgs84",s.lat1=s.lat1||s.lat0;var n=rc(s.a,s.b,s.rf,s.ellps,s.sphere),o=ic(n.a,n.b,n.rf,s.R_A),a=cc(s.nadgrids),h=s.datum||ac(s.datumCode,s.datum_params,n.a,n.b,o.es,o.ep2,a);fn(this,s),fn(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)}be.projections=sc;be.projections.start();var Ct=be;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===Pt?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 Li(e,t,s){var i=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 i>Math.PI&&(i-=2*Math.PI),a=Math.sin(r),c=Math.cos(r),h=a*a,o=s/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 Gi(e,t,s,i){var r=1e-12,n=r*r,o=30,a,h,c,l,u,f,m,d,g,_,M,y,E,w=e.x,T=e.y,b=e.z?e.z:0,R,A,C;if(a=Math.sqrt(w*w+T*T),h=Math.sqrt(w*w+T*T+b*b),a/s<r){if(R=0,h/s<r)return A=x,C=-i,{x:e.x,y:e.y,z:e.z}}else R=Math.atan2(T,w);c=b/h,l=a/h,u=1/Math.sqrt(1-t*(2-t)*l*l),d=l*(1-t)*u,g=c*u,E=0;do E++,m=s/Math.sqrt(1-t*g*g),C=a*d+b*g-m*(1-t*g*g),f=t*m/(m+C),u=1/Math.sqrt(1-f*(2-f)*l*l),_=l*(1-f)*u,M=c*u,y=M*d-_*g,d=_,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,s){if(t===Pt)return{x:e.x+s[0],y:e.y+s[1],z:e.z+s[2]};if(t===Rt){var i=s[0],r=s[1],n=s[2],o=s[3],a=s[4],h=s[5],c=s[6];return{x:c*(e.x-h*e.y+a*e.z)+i,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,s){if(t===Pt)return{x:e.x-s[0],y:e.y-s[1],z:e.z-s[2]};if(t===Rt){var i=s[0],r=s[1],n=s[2],o=s[3],a=s[4],h=s[5],c=s[6],l=(e.x-i)/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 zi(e){return e===Pt||e===Rt}function pc(e,t,s){if(lc(e,t)||e.datum_type===ns||t.datum_type===ns)return s;var i=e.a,r=e.es;if(e.datum_type===Vt){var n=dc(e,!1,s);if(n!==0)return;i=an,r=hn}var o=t.a,a=t.b,h=t.es;if(t.datum_type===Vt&&(o=an,a=Ih,h=hn),r===h&&i===o&&!zi(e.datum_type)&&!zi(t.datum_type))return s;if(s=Li(s,r,i),zi(e.datum_type)&&(s=uc(s,e.datum_type,e.datum_params)),zi(t.datum_type)&&(s=fc(s,t.datum_type,t.datum_params)),s=Gi(s,h,o,a),t.datum_type===Vt){var c=dc(t,!0,s);if(c!==0)return}return s}function dc(e,t,s){if(e.grids===null||e.grids.length===0)return console.log("Grid shift grids not found"),-1;var i={x:-s.x,y:s.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=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)&&(r=xm(i,t,u),!isNaN(r.x)))break t}}return isNaN(r.x)?(console.log("Failed to find a grid shift table for location '"+-i.x*X+" "+i.y*X+" tried: '"+n+"'"),-1):(s.x=-r.x,s.y=r.y,0)}function xm(e,t,s){var i={x:Number.NaN,y:Number.NaN};if(isNaN(e.x))return i;var r={x:e.x,y:e.y};r.x-=s.ll[0],r.y-=s.ll[1],r.x=S(r.x-Math.PI)+Math.PI;var n=mc(r,s);if(t){if(isNaN(n.x))return i;n.x=r.x-n.x,n.y=r.y-n.y;var o=9,a=1e-12,h,c;do{if(c=mc(n,s),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."),i;i.x=S(n.x+s.ll[0]),i.y=n.y+s.ll[1]}else isNaN(n.x)||(i.x=e.x+n.x,i.y=e.y+n.y);return i}function mc(e,t){var s={x:e.x/t.del[0],y:e.y/t.del[1]},i={x:Math.floor(s.x),y:Math.floor(s.y)},r={x:s.x-1*i.x,y:s.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=r.x*r.y,f=r.x*(1-r.y),m=(1-r.x)*(1-r.y),d=(1-r.x)*r.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 ae=["x","y","z"];function gc(e,t){let s={};for(let i=0,r=e.axis.length;i<r;i++){if(i===2&&t.z===void 0)continue;let n=t[ae[i]];switch(e.axis[i]){case"e":s.x=n;break;case"w":s.x=-n;break;case"n":s.y=n;break;case"s":s.y=-n;break;case"u":s.z=n;break;case"d":s.z=-n;break;default:return null}}return s}function _c(e,t){let s={};for(let i=0,r=e.axis.length;i<r;i++)if(!(i===2&&t.z===void 0))switch(e.axis[i]){case"e":s[ae[i]]=t.x;break;case"w":s[ae[i]]=-t.x;break;case"n":s[ae[i]]=t.y;break;case"s":s[ae[i]]=-t.y;break;case"u":s[ae[i]]=t.z;break;case"d":s[ae[i]]=-t.z;break;default:return null}return s}function Pe(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 ym(e,t){return(e.datum.datum_type===Pt||e.datum.datum_type===Rt||e.datum.datum_type===Vt)&&t.datumCode!=="WGS84"||(t.datum.datum_type===Pt||t.datum.datum_type===Rt||t.datum.datum_type===Vt)&&e.datumCode!=="WGS84"}function cs(e,t,s,i){var r,n=s.z!==void 0;if(xc(s),e.datum&&t.datum&&ym(e,t)&&(r=new Ct("WGS84"),s=cs(e,r,s,i),e=r),i&&e.axis!=="enu"&&(s=gc(e,s)),e.projName==="longlat")s={x:s.x*B,y:s.y*B,z:s.z||0};else if(e.to_meter&&(s={x:s.x*e.to_meter,y:s.y*e.to_meter,z:s.z||0}),s=e.inverse(s),!s)return;if(e.from_greenwich&&(s.x+=e.from_greenwich),s=pc(e.datum,t.datum,s),!!s)return s=s,t.from_greenwich&&(s={x:s.x-t.from_greenwich,y:s.y,z:s.z||0}),t.projName==="longlat"?(t.long_wrap!==void 0&&(s.x=t.long_wrap+S(s.x-t.long_wrap)),s={x:s.x*X,y:s.y*X,z:s.z||0}):(s=t.forward(s),t.to_meter&&(s={x:s.x/t.to_meter,y:s.y/t.to_meter,z:s.z||0})),i&&t.axis!=="enu"?_c(t,s):(s&&!n&&t.projName!=="geocent"&&delete s.z,s)}function xn(e,t,s,i){var r;return Array.isArray(s)?r=Pe(s):r={x:s.x,y:s.y,z:s.z,m:s.m},cs(e,t,r,i)}var yc=Ct("WGS84");function yn(e,t,s,i){var r,n,o;return Array.isArray(s)?(r=cs(e,t,Pe(s),i)||{x:NaN,y:NaN},s.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(s.slice(3)):[r.x,r.y,s[2]].concat(s.slice(3)):i&&typeof r.z=="number"?[r.x,r.y,r.z].concat(s.slice(3)):[r.x,r.y].concat(s.slice(2))):[r.x,r.y]):(r=cs(e,t,{x:s.x,y:s.y,z:s.z,m:s.m},i)||{x:NaN,y:NaN},o=Object.keys(s),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)||(r[a]=s[a])})),r)}function qi(e){return e instanceof Ct?e:typeof e=="object"&&"oProj"in e?e.oProj:Ct(e)}function Sm(e,t,s){var i,r,n=!1,o;return typeof t>"u"?(r=qi(e),i=yc,n=!0):(typeof t.x<"u"||Array.isArray(t))&&(s=t,r=qi(e),i=yc,n=!0),i||(i=qi(e)),r||(r=qi(t)),s?yn(i,r,s):(o={forward:function(a,h){return yn(i,r,a,h)},inverse:function(a,h){return yn(r,i,a,h)}},n&&(o.oProj=r),o)}var Sc=Sm;var vc=6,wc="AJSAJS",Tc="AFAFAF",Re=65,ut=73,wt=79,ls=86,us=90,bc={forward:vn,inverse:vm,toPoint:En};function vn(e,t){return t=t||5,Tm(Em({lat:e[1],lon:e[0]}),t)}function vm(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 Em(e){var t=e.lat,s=e.lon,i=6378137,r=.00669438,n=.9996,o,a,h,c,l,u,f,m=Sn(t),d=Sn(s),g,_;_=Math.floor((s+180)/6)+1,s===180&&(_=60),t>=56&&t<64&&s>=3&&s<12&&(_=32),t>=72&&t<84&&(s>=0&&s<9?_=31:s>=9&&s<21?_=33:s>=21&&s<33?_=35:s>=33&&s<42&&(_=37)),o=(_-1)*6-180+3,g=Sn(o),a=r/(1-r),h=i/Math.sqrt(1-r*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-r/4-3*r*r/64-5*r*r*r/256)*m-(3*r/8+3*r*r/32+45*r*r*r/1024)*Math.sin(2*m)+(15*r*r/256+45*r*r*r/1024)*Math.sin(4*m)-35*r*r*r/3072*Math.sin(6*m));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(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&&(y+=1e7),{northing:Math.round(y),easting:Math.round(M),zoneNumber:_,zoneLetter:wm(t)}}function wn(e){var t=e.northing,s=e.easting,i=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,m,d,g,_,M,y,E=s-5e5,w=t;i<"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),m=o*(1-a)/Math.pow(1-a*Math.sin(y)*Math.sin(y),1.5),d=E/(l*n);var T=y-l*Math.tan(y)/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);T=Ec(T);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(y);b=_+Ec(b);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:b}}else R={lat:T,lon:b};return R}function wm(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 Tm(e,t){var s="00000"+e.easting,i="00000"+e.northing;return e.zoneNumber+e.zoneLetter+bm(e.easting,e.northing,e.zoneNumber)+s.substr(s.length-5,t)+i.substr(i.length-5,t)}function bm(e,t,s){var i=Pc(s),r=Math.floor(e/1e5),n=Math.floor(t/1e5)%20;return Pm(r,n,i)}function Pc(e){var t=e%vc;return t===0&&(t=vc),t}function Pm(e,t,s){var i=s-1,r=wc.charCodeAt(i),n=Tc.charCodeAt(i),o=r+e-1,a=n+t,h=!1;o>us&&(o=o-us+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>us&&(o=o-us+Re-1),a>ls?(a=a-ls+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>ls&&(a=a-ls+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,s=null,i="",r,n=0;!/[A-Z]/.test(r=e.charAt(n));){if(n>=2)throw"MGRSPoint bad conversion from: "+e;i+=r,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;s=e.substring(n,n+=2);for(var h=Pc(o),c=Rm(s.charAt(0),h),l=Cm(s.charAt(1),h);l<Am(a);)l+=2e6;var u=t-n;if(u%2!==0)throw`MGRSPoint has to have an even number
8
- of digits after the zone letter and two 100km letters - front
9
- half for easting meters, second half for
10
- northing meters`+e;var f=u/2,m=0,d=0,g,_,M,y,E;return f>0&&(g=1e5/Math.pow(10,f),_=e.substring(n,n+f),m=parseFloat(_)*g,M=e.substring(n+f),d=parseFloat(M)*g),y=m+c,E=d+l,{easting:y,northing:E,zoneLetter:a,zoneNumber:o,accuracy:g}}function Rm(e,t){for(var s=wc.charCodeAt(t-1),i=1e5,r=!1;s!==e.charCodeAt(0);){if(s++,s===ut&&s++,s===wt&&s++,s>us){if(r)throw"Bad character: "+e;s=Re,r=!0}i+=1e5}return i}function Cm(e,t){if(e>"V")throw"MGRSPoint given invalid Northing "+e;for(var s=Tc.charCodeAt(t-1),i=0,r=!1;s!==e.charCodeAt(0);){if(s++,s===ut&&s++,s===wt&&s++,s>ls){if(r)throw"Bad character: "+e;s=Re,r=!0}i+=1e5}return i}function Am(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,s){if(!(this instanceof Ce))return new Ce(e,t,s);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=s||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 Im=1,Om=.25,Ac=.046875,Ic=.01953125,Oc=.01068115234375,Nm=.75,Lm=.46875,Gm=.013020833333333334,zm=.007120768229166667,qm=.3645833333333333,Bm=.005696614583333333,Dm=.3076171875;function Ae(e){var t=[];t[0]=Im-e*(Om+e*(Ac+e*(Ic+e*Oc))),t[1]=e*(Nm-e*(Ac+e*(Ic+e*Oc)));var s=e*e;return t[2]=s*(Lm-e*(Gm+e*zm)),s*=e,t[3]=s*(qm-e*Bm),t[4]=s*e*Dm,t}function qt(e,t,s,i){return s*=t,t*=t,i[0]*e-s*(i[1]+t*(i[2]+t*(i[3]+t*i[4])))}var Fm=20;function Ie(e,t,s){for(var i=1/(1-t),r=e,n=Fm;n;--n){var o=Math.sin(r),a=1-t*o*o;if(a=(qt(r,o,Math.cos(r),s)-e)*(a*Math.sqrt(a))*i,r-=a,Math.abs(a)<v)return r}return r}function Um(){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 km(e){var t=e.x,s=e.y,i=S(t-this.long0,this.over),r,n,o,a=Math.sin(s),h=Math.cos(s);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)>v?Math.tan(s):0,g=Math.pow(d,2),_=Math.pow(g,2);r=1-this.es*Math.pow(a,2),l=l/Math.sqrt(r);var M=qt(s,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*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)<v)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>v)return 93;o=0}else o=Math.acos(o);s<0&&(o=-o),o=this.a*this.k0*(o-this.lat0)+this.y0}return e.x=n,e.y=o,e}function Vm(e){var t,s,i,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,s=Ie(t,this.es,this.en),Math.abs(s)<x){var u=Math.sin(s),f=Math.cos(s),m=Math.abs(f)>v?Math.tan(s):0,d=this.ep2*Math.pow(f,2),g=Math.pow(d,2),_=Math.pow(m,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*m,i=s-t*E/(1-this.es)*.5*(1-E/12*(5+3*_-9*d*_+d-4*g-E/30*(61+90*_-252*d*_+45*M+46*d-E/56*(1385+3633*_+4095*M+1574*M*_)))),r=S(this.long0+y*(1-E/6*(1+2*_+d-E/20*(5+28*_+24*M+8*d*_+6*d-E/42*(61+662*_+1320*M+720*M*_))))/f,this.over)}else i=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))),i=Math.asin(t),o<0&&(i=-i),h===0&&l===0?r=0:r=S(Math.atan2(h,l)+this.long0,this.over)}return e.x=r,e.y=i,e}var jm=["Fast_Transverse_Mercator","Fast Transverse Mercator"],Oe={init:Um,forward:km,inverse:Vm,names:jm};function Bi(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 s=Math.max(e,t),i=Math.min(e,t)/(s||1);return s*Math.sqrt(1+Math.pow(i,2))}function Nc(e){var t=1+e,s=t-1;return s===0?e:e*Math.log(t)/s}function Lc(e){var t=Math.abs(e);return t=Nc(t*(1+t/(Z(1,t)+1))),e<0?-t:t}function Di(e,t){for(var s=2*Math.cos(2*t),i=e.length-1,r=e[i],n=0,o;--i>=0;)o=-n+s*r+e[i],n=r,r=o;return t+o*Math.sin(2*t)}function Gc(e,t){for(var s=2*Math.cos(t),i=e.length-1,r=e[i],n=0,o;--i>=0;)o=-n+s*r+e[i],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,s){for(var i=Math.sin(t),r=Math.cos(t),n=Bi(s),o=zc(s),a=2*r*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=r*n,[a*l-h*m,a*m+h*l]}function Wm(){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),s=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)))))),s=s*t,this.cgb[1]=s*(7/3+t*(-8/5+t*(-227/45+t*(2704/315+t*(2323/945))))),this.cbg[1]=s*(5/3+t*(-16/15+t*(-13/9+t*(904/315+t*(-1522/945))))),s=s*t,this.cgb[2]=s*(56/15+t*(-136/35+t*(-1262/105+t*(73814/2835)))),this.cbg[2]=s*(-26/15+t*(34/21+t*(8/5+t*(-12686/2835)))),s=s*t,this.cgb[3]=s*(4279/630+t*(-332/35+t*(-399572/14175))),this.cbg[3]=s*(1237/630+t*(-12/5+t*(-24832/14175))),s=s*t,this.cgb[4]=s*(4174/315+t*(-144838/6237)),this.cbg[4]=s*(-734/315+t*(109598/31185)),s=s*t,this.cgb[5]=s*(601676/22275),this.cbg[5]=s*(444337/155925),s=Math.pow(t,2),this.Qn=this.k0/(1+t)*(1+s*(1/4+s*(1/64+s/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]=s*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+t*(1118711/3870720))))),this.gtu[1]=s*(13/48+t*(-3/5+t*(557/1440+t*(281/630+t*(-1983433/1935360))))),s=s*t,this.utg[2]=s*(-17/480+t*(37/840+t*(209/4480+t*(-5569/90720)))),this.gtu[2]=s*(61/240+t*(-103/140+t*(15061/26880+t*(167603/181440)))),s=s*t,this.utg[3]=s*(-4397/161280+t*(11/504+t*(830251/7257600))),this.gtu[3]=s*(49561/161280+t*(-179/168+t*(6601661/7257600))),s=s*t,this.utg[4]=s*(-4583/161280+t*(108847/3991680)),this.gtu[4]=s*(34729/80640+t*(-3418889/1995840)),s=s*t,this.utg[5]=s*(-20648693/638668800),this.gtu[5]=s*(212378941/319334400);var i=Di(this.cbg,this.lat0);this.Zb=-this.Qn*(i+Gc(this.gtu,2*i))}function Hm(e){var t=S(e.x-this.long0,this.over),s=e.y;s=Di(this.cbg,s);var i=Math.sin(s),r=Math.cos(s),n=Math.sin(t),o=Math.cos(t);s=Math.atan2(i,o*r),t=Math.atan2(n*r,Z(i,r*o)),t=Lc(Math.tan(t));var a=Tn(this.gtu,2*s,2*t);s=s+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*s+this.Zb)+this.y0):(h=1/0,c=1/0),e.x=h,e.y=c,e}function Ym(e){var t=(e.x-this.x0)*(1/this.a),s=(e.y-this.y0)*(1/this.a);s=(s-this.Zb)/this.Qn,t=t/this.Qn;var i,r;if(Math.abs(t)<=2.623395162778){var n=Tn(this.utg,2*s,2*t);s=s+n[0],t=t+n[1],t=Math.atan(Bi(t));var o=Math.sin(s),a=Math.cos(s),h=Math.sin(t),c=Math.cos(t);s=Math.atan2(o*c,Z(h,c*a)),t=Math.atan2(h,c*a),i=S(t+this.long0,this.over),r=Di(this.cgb,s)}else i=1/0,r=1/0;return e.x=i,e.y=r,e}var Zm=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc","Transverse_Mercator","Transverse Mercator","Gauss Kruger","Gauss_Kruger","tmerc"],Ne={init:Wm,forward:Hm,inverse:Ym,names:Zm};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 Xm="etmerc";function $m(){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 Qm=["Universal Transverse Mercator System","utm"],Bc={init:$m,names:Qm,dependsOn:Xm};function Fi(e,t){return Math.pow((1-e)/(1+e),t)}var Km=20;function Jm(){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)*Fi(this.e*e,this.ratexp))}function t1(e){var t=e.x,s=e.y;return e.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*s+O),this.C)*Fi(this.e*Math.sin(s),this.ratexp))-x,e.x=this.C*t,e}function e1(e){for(var t=1e-14,s=e.x/this.C,i=e.y,r=Math.pow(Math.tan(.5*i+O)/this.K,1/this.C),n=Km;n>0&&(i=2*Math.atan(r*Fi(this.e*Math.sin(e.y),-.5*this.e))-x,!(Math.abs(i-e.y)<t));--n)e.y=i;return n?(e.x=s,e.y=i,e):null}var s1=["gauss"],Ui={init:Jm,forward:t1,inverse:e1,names:s1};function i1(){Ui.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,s,i,r;return e.x=S(e.x-this.long0,this.over),Ui.forward.apply(this,[e]),t=Math.sin(e.y),s=Math.cos(e.y),i=Math.cos(e.x),r=this.k0*this.R2/(1+this.sinc0*t+this.cosc0*s*i),e.x=r*s*Math.sin(e.x),e.y=r*(this.cosc0*t-this.sinc0*s*i),e.x=this.a*e.x+this.x0,e.y=this.a*e.y+this.y0,e}function n1(e){var t,s,i,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),s=Math.cos(o),r=Math.asin(s*this.sinc0+e.y*t*this.cosc0/n),i=Math.atan2(e.x*t,n*this.cosc0*s-e.y*this.sinc0*t)}else r=this.phic0,i=0;return e.x=i,e.y=r,Ui.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:i1,forward:r1,inverse:n1,names:o1};function bn(e,t,s){return t*=s,Math.tan(.5*(x+e))*Math.pow((1-t)/(1+t),.5*s)}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(bn(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,s=e.y,i=Math.sin(s),r=Math.cos(s),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(s+this.lat0)<=v?(e.x=NaN,e.y=NaN,e):this.sphere?(n=2*this.k0/(1+this.sinlat0*i+this.coslat0*r*Math.cos(u)),e.x=this.a*n*r*Math.sin(u)+this.x0,e.y=this.a*n*(this.coslat0*i-this.sinlat0*r*Math.cos(u))+this.y0,e):(o=2*Math.atan(bn(s,i,this.e))-x,h=Math.cos(o),a=Math.sin(o),Math.abs(this.coslat0)<=v?(c=ht(this.e,s*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)<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,s,i,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,s=this.lat0,o<=v?(e.x=t,e.y=s,e):(s=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=s,e)}else if(Math.abs(this.coslat0)<=v){if(o<=v)return s=this.lat0,t=this.long0,e.x=t,e.y=s,e;e.x*=this.con,e.y*=this.con,i=o*this.cons/(2*this.a*this.k0),s=this.con*Wt(this.e,i),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)),s=-1*Wt(this.e,Math.tan(.5*(x+n)));return e.x=t,e.y=s,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_:bn};function u1(){this.k0||(this.k0=1);var e=this.lat0;this.lambda0=this.long0;var t=Math.sin(e),s=this.a,i=this.rf,r=1/i,n=2*r-Math.pow(r,2),o=this.e=Math.sqrt(n);this.R=this.k0*s*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)),s=this.e/2*Math.log((1+this.e*Math.sin(e.y))/(1-this.e*Math.sin(e.y))),i=-this.alpha*(t+s)+this.K,r=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(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 d1(e){for(var t=e.x-this.x0,s=e.y-this.y0,i=t/this.R,r=2*(Math.atan(Math.exp(s/this.R))-Math.PI/4),n=Math.asin(Math.cos(this.b0)*Math.sin(r)+Math.sin(this.b0)*Math.cos(r)*Math.cos(i)),o=Math.atan(Math.sin(i)/(Math.cos(this.b0)*Math.cos(i)-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 m1=["somerc"],Uc={init:u1,forward:f1,inverse:d1,names:m1};var Le=1e-7;function p1(e){var t=["Hotine_Oblique_Mercator","Hotine_Oblique_Mercator_variant_A","Hotine_Oblique_Mercator_Azimuth_Natural_Origin"],s=typeof e.projName=="object"?Object.keys(e.projName)[0]:e.projName;return"no_uoff"in e||"no_off"in e||t.indexOf(s)!==-1||t.indexOf(mn(s))!==-1}function g1(){var e,t,s,i,r,n,o,a,h,c,l=0,u,f=0,m=0,d=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(m=this.long1,g=this.lat1,d=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),s=Math.cos(this.lat0),e=1-this.es*a*a,this.B=s*s,this.B=Math.sqrt(1+this.es*this.B*this.B/w),this.A=this.B*this.k0*t/e,i=this.B*t/(s*Math.sqrt(e)),r=i*i-1,r<=0?r=0:(r=Math.sqrt(r),this.lat0<0&&(r=-r)),this.E=r+=i,this.E*=Math.pow(ht(this.e,this.lat0,a),this.B)):(this.B=1/t,this.A=this.k0,this.E=i=r=1),y||E?(y?(u=Math.asin(Math.sin(M)/i),E||(l=M)):(u=l,M=Math.asin(i*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=m-d,e<-Math.PI?d-=Jt:e>Math.PI&&(d+=Jt),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))/(r-1/r)),l=M=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(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={},s,i,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,s=.5*(o-a),i=.5*(o+a),n=Math.sin(this.B*e.x),r=(s*this.singam-n*this.cosgam)/i,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(s*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,s,i,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?(s=e.y,t=e.x):(s=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*s),r=.5*(i-1/i),n=.5*(i+1/i),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"],kc={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),s=Math.cos(this.lat1),i=rt(this.e,t,s),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(i/a)/Math.log(r/h):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=i/(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,s=e.y;Math.abs(2*Math.abs(s)-Math.PI)<=v&&(s=zt(s)*(x-2*v));var i=Math.abs(Math.abs(s)-x),r,n;if(i>v)r=ht(this.e,s,Math.sin(s)),n=this.a*this.f0*Math.pow(r,this.ns);else{if(i=s*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 v1(e){var t,s,i,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),s=1):(t=-Math.sqrt(o*o+a*a),s=-1);var h=0;if(t!==0&&(h=Math.atan2(s*o,s*a)),t!==0||this.ns>0){if(s=1/this.ns,i=Math.pow(t/(this.a*this.f0),s),r=Wt(this.e,i),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)"],Vc={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,s,i,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),s=2*(Math.atan(this.k*Math.pow(Math.tan(c/2+this.s45),this.alfa)/t)-this.s45),i=-l*this.alfa,r=Math.asin(Math.cos(this.ad)*Math.sin(s)+Math.sin(this.ad)*Math.cos(s)*Math.cos(i)),n=Math.asin(Math.cos(s)*Math.sin(i)/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 b1(e){var t,s,i,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),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(r)),s=Math.asin(Math.cos(i)*Math.sin(r)/Math.cos(t)),e.x=this.long0-s/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 P1=["Krovak","Krovak Modified","Krovak (North Orientated)","Krovak Modified (North Orientated)","krovak"],jc={init:w1,forward:T1,inverse:b1,names:P1};function $(e,t,s,i,r){return e*r-t*Math.sin(2*r)+s*Math.sin(4*r)-i*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 fs(e,t,s){var i=t*s;return e/Math.sqrt(1-i*i)}function ft(e){return Math.abs(e)<x?e:e-zt(e)*Math.PI}function he(e,t,s,i,r){var n,o;n=e/t;for(var a=0;a<15;a++)if(o=(e-(t*n-s*Math.sin(2*n)+i*Math.sin(4*n)-r*Math.sin(6*n)))/(t-2*s*Math.cos(2*n)+4*i*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,s,i=e.x,r=e.y;if(i=S(i-this.long0,this.over),this.sphere)t=this.a*Math.asin(Math.cos(r)*Math.sin(i)),s=this.a*(Math.atan2(Math.tan(r),Math.cos(i))-this.lat0);else{var n=Math.sin(r),o=Math.cos(r),a=fs(this.a,this.e,n),h=Math.tan(r)*Math.tan(r),c=i*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)),s=f-this.ml0+a*n/o*l*(.5+(5-h+6*u)*l/24)}return e.x=t+this.x0,e.y=s+this.y0,e}function A1(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,s=e.y/this.a,i,r;if(this.sphere){var n=s+this.lat0;i=Math.asin(Math.sin(n)*Math.cos(t)),r=Math.atan2(Math.tan(t),Math.cos(n))}else{var o=this.ml0/this.a+s,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,s<0&&(e.y*=-1),e;var h=fs(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),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(i),e}var I1=["Cassini","Cassini_Soldner","cass"],Wc={init:R1,forward:C1,inverse:A1,names:I1};function dt(e,t){var s;return e>1e-7?(s=e*t,(1-e*e)*(t/(1-s*s)-.5/e*Math.log((1-s)/(1+s)))):2*t}var O1=.3333333333333333,N1=.17222222222222222,L1=.10257936507936508,G1=.06388888888888888,z1=.0664021164021164,q1=.016415012942191543;function ds(e){var t,s=[];return s[0]=e*O1,t=e*e,s[0]+=t*N1,s[1]=t*G1,t*=e,s[0]+=t*L1,s[1]+=t*z1,s[2]=t*q1,s}function ms(e,t){var s=e+e;return e+t[0]*Math.sin(s)+t[1]*Math.sin(s+s)+t[2]*Math.sin(s+s+s)}var Pn=1,Rn=2,Cn=3,ki=4;function B1(){var e=Math.abs(this.lat0);if(Math.abs(e-x)<v?this.mode=this.lat0<0?Pn:Rn:Math.abs(e)<v?this.mode=Cn:this.mode=ki,this.es>0){var t;switch(this.qp=dt(this.e,1),this.mmf=.5/(1-this.es),this.apa=ds(this.es),this.mode){case Rn:this.dd=1;break;case Pn: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 ki:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=dt(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===ki&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function D1(e){var t,s,i,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),i=Math.cos(u),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(s=this.mode===this.EQUIT?1+l*i:1+this.sinph0*n+this.cosph0*l*i,s<=v)return null;s=Math.sqrt(2/s),t=s*l*Math.sin(u),s*=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)<v)return null;s=O-f*.5,s=2*(this.mode===this.S_POLE?Math.cos(s):Math.sin(s)),t=s*Math.sin(u),s*=i}}else{switch(a=0,h=0,c=0,i=Math.cos(u),r=Math.sin(u),n=Math.sin(f),o=dt(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)<v)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:c=Math.sqrt(2/c),this.mode===this.OBLIQ?s=this.ymf*c*(this.cosb1*a-this.sinb1*h*i):s=(c=Math.sqrt(2/(1+h*i)))*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,s=i*(this.mode===this.S_POLE?c:-c)):t=s=0;break}}return e.x=this.a*t+this.x0,e.y=this.a*s+this.y0,e}function F1(e){e.x-=this.x0,e.y-=this.y0;var t=e.x/this.a,s=e.y/this.a,i,r,n,o,a,h,c;if(this.sphere){var l=0,u,f=0;if(u=Math.sqrt(t*t+s*s),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(s*f/u),t*=f,s=l*u;break;case this.OBLIQ:r=Math.abs(u)<=v?this.lat0:Math.asin(l*this.sinph0+s*f*this.cosph0/u),t*=f*this.cosph0,s=(l-Math.sin(r)*this.sinph0)*u;break;case this.N_POLE:s=-s,r=x-r;break;case this.S_POLE:r-=x;break}i=s===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(t,s)}else{if(c=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(t/=this.dd,s*=this.dd,h=Math.sqrt(t*t+s*s),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+s*o*this.cosb1/h,a=this.qp*c,s=h*this.cosb1*n-s*this.sinb1*o):(c=s*o/h,a=this.qp*c,s=h*n)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(s=-s),a=t*t+s*s,!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,s),r=ms(Math.asin(c),this.apa)}return e.x=S(this.long0+i,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:Pn,N_POLE:Rn,EQUIT:Cn,OBLIQ:ki};function mt(e){return Math.abs(e)>1&&(e=e>1?1:-1),Math.asin(e)}function k1(){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=dt(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=dt(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=dt(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 V1(e){var t=e.x,s=e.y;this.sin_phi=Math.sin(s),this.cos_phi=Math.cos(s);var i=dt(this.e3,this.sin_phi),r=this.a*Math.sqrt(this.c-this.ns0*i)/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,s,i,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),i=1):(t=-Math.sqrt(e.x*e.x+e.y*e.y),i=-1),r=0,t!==0&&(r=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)):(s=(this.c-i*i)/this.ns0,o=this.phi1z(this.e3,s)),n=S(r/this.ns0+this.long0,this.over),e.x=n,e.y=o,e}function W1(e,t){var s,i,r,n,o,a=mt(.5*t);if(e<v)return a;for(var h=e*e,c=1;c<=25;c++)if(s=Math.sin(a),i=Math.cos(a),r=e*s,n=1-r*r,o=.5*n*n/i*(t/(1-h)-s/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:k1,forward:V1,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,s,i,r,n,o,a,h,c=e.x,l=e.y;return i=S(c-this.long0,this.over),t=Math.sin(l),s=Math.cos(l),r=Math.cos(i),o=this.sin_p14*t+this.cos_p14*s*r,n=1,o>0||Math.abs(o)<=v?(a=this.x0+this.a*n*s*Math.sin(i)/o,h=this.y0+this.a*n*(this.cos_p14*t-this.sin_p14*s*r)/o):(a=this.x0+this.infinity_dist*s*Math.sin(i),h=this.y0+this.infinity_dist*(this.cos_p14*t-this.sin_p14*s*r)),e.x=a,e.y=h,e}function X1(e){var t,s,i,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),s=Math.sin(r),i=Math.cos(r),o=mt(i*this.sin_p14+e.y*s*this.cos_p14/t),n=Math.atan2(e.x*s,t*this.cos_p14*i-e.y*this.sin_p14*s),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 s=1-(1-e*e)/(2*e)*Math.log((1-e)/(1+e));if(Math.abs(Math.abs(t)-s)<1e-6)return t<0?-1*x:x;for(var i=Math.asin(.5*t),r,n,o,a,h=0;h<30;h++)if(n=Math.sin(i),o=Math.cos(i),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))),i+=r,Math.abs(r)<=1e-10)return i;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,s=e.y,i,r,n=S(t-this.long0,this.over);if(this.sphere)i=this.x0+this.a*n*Math.cos(this.lat_ts),r=this.y0+this.a*Math.sin(s)/Math.cos(this.lat_ts);else{var o=dt(this.e,Math.sin(s));i=this.x0+this.a*this.k0*n,r=this.y0+this.a*o*.5/this.k0}return e.x=i,e.y=r,e}function J1(e){e.x-=this.x0,e.y-=this.y0;var t,s;return this.sphere?(t=S(this.long0+e.x/this.a/Math.cos(this.lat_ts),this.over),s=Math.asin(e.y/this.a*Math.cos(this.lat_ts))):(s=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=s,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 sp(e){var t=e.x,s=e.y,i=S(t-this.long0,this.over),r=ft(s-this.lat0);return e.x=this.x0+this.a*i*this.rc,e.y=this.y0+this.a*r,e}function ip(e){var t=e.x,s=e.y;return e.x=S(this.long0+(t-this.x0)/(this.a*this.rc),this.over),e.y=ft(this.lat0+(s-this.y0)/this.a),e}var rp=["Equirectangular","Equidistant_Cylindrical","Equidistant_Cylindrical_Spherical","eqc"],Qc={init:ep,forward:sp,inverse:ip,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,s=e.y,i,r,n,o=S(t-this.long0,this.over);if(n=o*Math.sin(s),this.sphere)Math.abs(s)<=v?(i=this.a*o,r=-1*this.a*this.lat0):(i=this.a*Math.sin(n)/Math.tan(s),r=this.a*(ft(s-this.lat0)+(1-Math.cos(n))/Math.tan(s)));else if(Math.abs(s)<=v)i=this.a*o,r=-1*this.ml0;else{var a=fs(this.a,this.e,Math.sin(s))/Math.tan(s);i=a*Math.sin(n),r=this.a*$(this.e0,this.e1,this.e2,this.e3,s)-this.ml0+a*(1-Math.cos(n))}return e.x=i+this.x0,e.y=r+this.y0,e}function ap(e){var t,s,i,r,n,o,a,h,c;if(i=e.x-this.x0,r=e.y-this.y0,this.sphere)if(Math.abs(r+this.a*this.lat0)<=v)t=S(i/this.a+this.long0,this.over),s=0;else{o=this.lat0+r/this.a,a=i*i/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){s=h;break}t=S(this.long0+Math.asin(i*Math.tan(h)/this.a)/Math.sin(s),this.over)}else if(Math.abs(r+this.ml0)<=v)s=0,t=S(this.long0+i/this.a,this.over);else{o=(this.ml0+r)/this.a,a=i*i/this.a/this.a+o*o,h=o;var u,f,m,d,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),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)<=v){s=h;break}u=Math.sqrt(1-this.es*Math.pow(Math.sin(s),2))*Math.tan(s),t=S(this.long0+Math.asin(i*u/this.a)/Math.sin(s),this.over)}return e.x=t,e.y=s,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,s=e.x,i=e.y,r=i-this.lat0,n=s-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,m=0,d,g,_=0,M=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,M=M+this.B_im[t]*f+this.B_re[t]*m;return e.x=M*this.a+this.x0,e.y=_*this.a+this.y0,e}function fp(e){var t,s=e.x,i=e.y,r=s-this.x0,n=i-this.y0,o=n/this.a,a=r/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,M,y,E=o,w=a;for(t=2;t<=6;t++)M=g*f-_*m,y=_*f+g*m,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],b=this.B_im[1];for(t=2;t<=6;t++)M=g*f-_*m,y=_*f+g*m,g=M,_=y,T=T+t*(this.B_re[t]*g-this.B_im[t]*_),b=b+t*(this.B_im[t]*g+this.B_re[t]*_);var R=T*T+b*b;f=(E*T+w*b)/R,m=(w*T-E*b)/R}var A=f,C=m,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 dp=["New_Zealand_Map_Grid","nzmg"],tl={init:lp,forward:up,inverse:fp,names:dp,iterations:cp};function mp(){}function pp(e){var t=e.x,s=e.y,i=S(t-this.long0,this.over),r=this.x0+this.a*i,n=this.y0+this.a*Math.log(Math.tan(Math.PI/4+s/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),s=2.5*(Math.atan(Math.exp(.8*e.y/this.a))-Math.PI/4);return e.x=t,e.y=s,e}var _p=["Miller_Cylindrical","mill"],el={init:mp,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,s,i=e.x,r=e.y;if(i=S(i-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*i*(this.m+Math.cos(r)),s=this.a*this.C_y*r}else{var h=Math.sin(r),c=Math.cos(r);s=this.a*qt(r,h,c,this.en),t=this.a*i*c/Math.sqrt(1-this.es*h*h)}return e.x=t,e.y=s,e}function In(e){var t,s,i,r;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=mt((this.m*t+Math.sin(t))/this.n):this.n!==1&&(t=mt(Math.sin(t)/this.n)),i=S(i+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),s=this.long0+e.x*Math.sqrt(1-this.es*r*r)/(this.a*Math.cos(t)),i=S(s,this.over)):r-v<x&&(i=this.long0)),e.x=i,e.y=t,e}var yp=["Sinusoidal","sinu"],sl={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"],il={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 bp(e){for(var t=e.x,s=e.y,i=S(t-this.long0,this.over),r=s,n=Math.PI*Math.sin(s);;){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(s)<v&&(i=0);var a=.900316316158*this.a*i*Math.cos(r)+this.x0,h=1.4142135623731*this.a*Math.sin(r)+this.y0;return e.x=a,e.y=h,e}function Pp(e){var t,s;e.x-=this.x0,e.y-=this.y0,s=e.y/(1.4142135623731*this.a),Math.abs(s)>.999999999999&&(s=.999999999999),t=Math.asin(s);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),s=(2*t+Math.sin(2*t))/Math.PI,Math.abs(s)>1&&(s=1);var r=Math.asin(s);return e.x=i,e.y=r,e}var Rp=["Mollweide","moll"],rl={init:Tp,forward:bp,inverse:Pp,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,s=e.y,i;if(this.sphere)i=this.a*(this.g-s);else{var r=$(this.e0,this.e1,this.e2,this.e3,s);i=this.a*(this.g-r)}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 Ip(e){e.x-=this.x0,e.y=this.rh-e.y+this.y0;var t,s,i,r;this.ns>=0?(s=Math.sqrt(e.x*e.x+e.y*e.y),t=1):(s=-Math.sqrt(e.x*e.x+e.y*e.y),t=-1);var n=0;if(s!==0&&(n=Math.atan2(t*e.x,t*e.y)),this.sphere)return r=S(this.long0+n/this.ns,this.over),i=ft(this.g-s/this.a),e.x=r,e.y=i,e;var o=this.g-s/this.a;return i=he(o,this.e0,this.e1,this.e2,this.e3),r=S(this.long0+n/this.ns,this.over),e.x=r,e.y=i,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,s=e.y,i=S(t-this.long0,this.over),r,n;if(Math.abs(s)<=v)return r=this.x0+this.R*i,n=this.y0,e.x=r,e.y=n,e;var o=mt(2*Math.abs(s/Math.PI));if(Math.abs(i)<=v||Math.abs(Math.abs(s)-x)<=v)return r=this.x0,s>=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/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),r=this.x0+g;var _=h+u;return g=Math.PI*this.R*(m*_-a*Math.sqrt((d+h)*(h+1)-_*_))/(d+h),s>=0?n=this.y0+g:n=this.y0-g,e.x=r,e.y=n,e}function Gp(e){var t,s,i,r,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,r=e.y/u,n=i*i+r*r,o=-Math.abs(r)*(1+n),a=o-2*r*r+i*i,h=-2*o+1+2*r*r+n*n,m=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*m/c/l,Math.abs(u)>1&&(u>=0?u=1:u=-1),f=Math.acos(u)/3,e.y>=0?s=(-l*Math.cos(f+Math.PI/3)-a/3/h)*Math.PI:s=-(-l*Math.cos(f+Math.PI/3)-a/3/h)*Math.PI,Math.abs(i)<v?t=this.long0:t=S(this.long0+Math.PI*(n-1+Math.sqrt(1+2*(i*i-r*r)+n*n))/2/i,this.over),e.x=t,e.y=s,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,s,i,r,n){let o=i-t,a=Math.atan((1-n)*Math.tan(e)),h=Math.atan((1-n)*Math.tan(s)),c=Math.sin(a),l=Math.cos(a),u=Math.sin(h),f=Math.cos(h),m=o,d,g=100,_,M,y,E,w,T,b,R,A,C,G,L,D,H;do{if(_=Math.sin(m),M=Math.cos(m),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,b=1-T*T,R=b!==0?E-2*c*u/b:0,A=n/16*b*(4+n*(4-3*b)),d=m,m=o+(1-A)*n*T*(w+A*y*(R+A*E*(-1+2*R*R)))}while(Math.abs(m-d)>1e-12&&--g>0);return g===0?{azi1:NaN,s12:NaN}:(C=b*(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,s,i,r,n){let o=Math.atan((1-n)*Math.tan(e)),a=Math.sin(o),h=Math.cos(o),c=Math.sin(s),l=Math.cos(s),u=Math.atan2(a,h*l),f=h*c,m=1-f*f,d=m*(r*r-r*(1-n)*(r*(1-n)))/(r*(1-n)*(r*(1-n))),g=1+d/16384*(4096+d*(-768+d*(320-175*d))),_=d/1024*(256+d*(-128+d*(74-47*d))),M=i/(r*(1-n)*g),y,E=100,w,T,b,R;do w=Math.cos(2*u+M),T=Math.sin(M),b=Math.cos(M),R=_*T*(w+_/4*(b*(-1+2*w*w)-_/6*w*(-3+4*T*T)*(-3+4*w*w))),y=M,M=i/(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*b*l,C=Math.atan2(a*b+h*T*l,(1-n)*Math.sqrt(f*f+A*A)),G=Math.atan2(T*c,h*b-a*T*l),L=n/16*m*(4+n*(4-3*m)),D=G-(1-L)*n*f*(M+L*T*(w+L*b*(-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,s=e.y,i=Math.sin(e.y),r=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)<=v?(e.x=this.x0+this.a*(x-s)*Math.sin(n),e.y=this.y0-this.a*(x-s)*Math.cos(n),e):Math.abs(this.sin_p12+1)<=v?(e.x=this.x0+this.a*(x+s)*Math.sin(n),e.y=this.y0+this.a*(x+s)*Math.cos(n),e):(d=this.sin_p12*i+this.cos_p12*r*Math.cos(n),f=Math.acos(d),m=f?f/Math.sin(f):1,e.x=this.x0+this.a*m*r*Math.sin(n),e.y=this.y0+this.a*m*(this.cos_p12*i-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,s),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,s),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(s-this.lat0)<v?(e.x=this.x0,e.y=this.y0,e):(g=al(this.lat0,this.long0,s,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,s,i,r,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:(s=t/this.a,i=Math.sin(s),r=Math.cos(s),n=this.long0,Math.abs(t)<=v?o=this.lat0:(o=mt(r*this.sin_p12+e.y*i*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*i,t*this.cos_p12*r-e.y*this.sin_p12*i),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),m=f-t,o=he(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)<=v?(f=this.a*$(h,c,l,u,x),t=Math.sqrt(e.x*e.x+e.y*e.y),m=t-f,o=he(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),_=hl(this.lat0,this.long0,d,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 kp(e){var t,s,i,r,n,o,a,h,c=e.x,l=e.y;return i=S(c-(this.long0||0),this.over),t=Math.sin(l),s=Math.cos(l),r=Math.cos(i),o=this.sin_p14*t+this.cos_p14*s*r,n=1,(o>0||Math.abs(o)<=v)&&(a=this.a*n*s*Math.sin(i),h=(this.y0||0)+this.a*n*(this.cos_p14*t-this.sin_p14*s*r)),e.x=a,e.y=h,e}function Vp(e){var t,s,i,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),s=mt(t/this.a),i=Math.sin(s),r=Math.cos(s),h=this.long0||0,c=this.lat0||0,o=h,Math.abs(t)<=v?(a=c,e.x=o,e.y=a,e):(a=mt(r*this.sin_p14+e.y*i*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*i,t*this.cos_p14*r-e.y*this.sin_p14*i),this.over),e.x=o,e.y=a,e))}var jp=["ortho"],ll={init:Up,forward:kp,inverse:Vp,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},s,i,r,n,o,a,h={value:0};if(e.x-=this.long0,this.es!==0?s=Math.atan(this.one_minus_f_squared*Math.tan(e.y)):s=e.y,i=e.x,this.face===W.TOP)n=x-s,i>=O&&i<=x+O?(h.value=z.AREA_0,r=i-x):i>x+O||i<=-(x+O)?(h.value=z.AREA_1,r=i>0?i-j:i+j):i>-(x+O)&&i<=-O?(h.value=z.AREA_2,r=i+x):(h.value=z.AREA_3,r=i);else if(this.face===W.BOTTOM)n=x+s,i>=O&&i<=x+O?(h.value=z.AREA_0,r=-i+x):i<O&&i>=-O?(h.value=z.AREA_1,r=-i):i<-O&&i>=-(x+O)?(h.value=z.AREA_2,r=-i-x):(h.value=z.AREA_3,r=i>0?-i+j:-i-j);else{var c,l,u,f,m,d,g;this.face===W.RIGHT?i=Ge(i,+x):this.face===W.BACK?i=Ge(i,+j):this.face===W.LEFT&&(i=Ge(i,-x)),f=Math.sin(s),m=Math.cos(s),d=Math.sin(i),g=Math.cos(i),c=m*g,l=m*d,u=f,this.face===W.FRONT?(n=Math.acos(c),r=Vi(n,u,l,h)):this.face===W.RIGHT?(n=Math.acos(l),r=Vi(n,u,-c,h)):this.face===W.BACK?(n=Math.acos(-c),r=Vi(n,u,-l,h)):this.face===W.LEFT?(n=Math.acos(-l),r=Vi(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},s,i,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,i=Math.atan(Math.sqrt(e.x*e.x+e.y*e.y)),s=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,s-=x):e.x<0&&-e.x>=Math.abs(e.y)?(u.value=z.AREA_2,s=s<0?s+j:s-j):(u.value=z.AREA_3,s+=x),l=j/12*Math.tan(s),o=Math.sin(l)/(Math.cos(l)-1/Math.sqrt(2)),a=Math.atan(o),r=Math.cos(s),n=Math.tan(i),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,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===z.AREA_1?(l=m,m=-d,d=l):u.value===z.AREA_2?(m=-m,d=-d):u.value===z.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=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 Vi(e,t,s,i){var r;return e<v?(i.value=z.AREA_0,r=0):(r=Math.atan2(t,s),Math.abs(r)<=O?i.value=z.AREA_0:r>O&&r<=x+O?(i.value=z.AREA_1,r-=x):r>x+O||r<=-(x+O)?(i.value=z.AREA_2,r=r>=0?r-j:r+j):(i.value=z.AREA_3,r+=x)),r}function Ge(e,t){var s=e+t;return s<-j?s+=Jt:s>+j&&(s-=Jt),s}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]],ps=[[-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,dl=1.3523,ml=X/5,Xp=1/ml,ze=18,ji=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,s,i){for(var r=t;i;--i){var n=e(r);if(r-=n,Math.abs(n)<s)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),s=Math.abs(e.y),i=Math.floor(s*ml);i<0?i=0:i>=ze&&(i=ze-1),s=X*(s-Xp*i);var r={x:ji(On[i],s)*t,y:ji(ps[i],s)};return e.y<0&&(r.y=-r.y),r.x=r.x*this.a*fl+this.x0,r.y=r.y*this.a*dl+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*dl)};if(t.y>=1)t.x/=On[ze][0],t.y=e.y<0?-x:x;else{var s=Math.floor(t.y*ze);for(s<0?s=0:s>=ze&&(s=ze-1);;)if(ps[s][0]>t.y)--s;else if(ps[s+1][0]<=t.y)++s;else break;var i=ps[s],r=5*(t.y-i[0])/(ps[s+1][0]-i[0]);r=Qp(function(n){return(ji(i,n)-t.y)/$p(i,n)},r,v,100),t.x/=ji(On[s],r),t.y=(5*s+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 sg(){this.name="geocent"}function ig(e){var t=Li(e,this.es,this.a);return t}function rg(e){var t=Gi(e,this.es,this.a,this.b);return t}var ng=["Geocentric","geocentric","geocent","Geocent"],gl={init:sg,forward:ig,inverse:rg,names:ng};var nt={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3},gs={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(gs).forEach((function(s){if(typeof this[s]>"u")this[s]=gs[s].def;else{if(gs[s].num&&isNaN(this[s]))throw new Error("Invalid parameter value, must be numeric "+s+" = "+this[s]);gs[s].num&&(this[s]=parseFloat(this[s]))}gs[s].degrees&&(this[s]=this[s]*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),s=Math.cos(e.y),i=Math.cos(e.x),r,n;switch(this.mode){case nt.OBLIQ:n=this.sinph0*t+this.cosph0*s*i;break;case nt.EQUIT:n=s*i;break;case nt.S_POLE:n=-t;break;case nt.N_POLE:n=t;break}switch(n=this.pn1/(this.p-n),r=n*s*Math.sin(e.x),this.mode){case nt.OBLIQ:n*=this.cosph0*t-this.sinph0*s*i;break;case nt.EQUIT:n*=t;break;case nt.N_POLE:n*=-(s*i);break;case nt.S_POLE:n*=s*i;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},s,i,r;r=1/(this.pn1-e.y*this.sw),s=this.pn1*e.x*r,i=this.pn1*e.y*this.cw*r,e.x=s*this.cg+i*this.sg,e.y=i*this.cg-s*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,s=e.y,i,r,n,o;if(t=t-this.long0,this.shape==="ellipse"){s=Math.atan(this.radius_p2*Math.tan(s));var a=this.radius_p/Z(this.radius_p*Math.cos(s),Math.sin(s));if(r=a*Math.cos(t)*Math.cos(s),n=a*Math.sin(t)*Math.cos(s),o=a*Math.sin(s),(this.radius_g-r)*r-n*n-o*o*this.radius_p_inv2<0)return e.x=Number.NaN,e.y=Number.NaN,e;i=this.radius_g-r,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/Z(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/Z(n,i)))}else this.shape==="sphere"&&(i=Math.cos(s),r=Math.cos(t)*i,n=Math.sin(t)*i,o=Math.sin(s),i=this.radius_g-r,this.flip_axis?(e.x=this.radius_g_1*Math.atan(n/Z(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/Z(n,i))));return e.x=e.x*this.a,e.y=e.y*this.a,e}function fg(e){var t=-1,s=0,i=0,r,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),s=Math.tan(e.x/this.radius_g_1)*Z(1,i)):(s=Math.tan(e.x/this.radius_g_1),i=Math.tan(e.y/this.radius_g_1)*Z(1,s));var h=i/this.radius_p;if(r=s*s+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,s*=a,i*=a,e.x=Math.atan2(s,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),s=Math.tan(e.x/this.radius_g_1)*Math.sqrt(1+i*i)):(s=Math.tan(e.x/this.radius_g_1),i=Math.tan(e.y/this.radius_g_1)*Math.sqrt(1+s*s)),r=s*s+i*i+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,s*=a,i*=a,e.x=Math.atan2(s,t),e.y=Math.atan(i*Math.cos(e.x)/t)}return e.x=e.x+this.long0,e}var dg=["Geostationary Satellite View","Geostationary_Satellite","geos"],Ml={init:lg,forward:ug,inverse:fg,names:dg};var _s=1.340264,Ms=-.081106,xs=893e-6,ys=.003796,Wi=Math.sqrt(3)/2;function mg(){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=ds(this.es),this.qp=dt(this.e,1),this.rqda=Math.sqrt(.5*this.qp))}function pg(e){var t=S(e.x-this.long0,this.over),s=e.y,i=Math.sin(s);this.es!==0&&(i=dt(this.e,i)/this.qp);var r=Math.asin(Wi*i),n=r*r,o=n*n*n;return e.x=t*Math.cos(r)/(Wi*(_s+3*Ms*n+o*(7*xs+9*ys*n))),e.y=r*(_s+Ms*n+o*(xs+ys*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,s=12,i=e.y,r,n,o,a,h,c;for(c=0;c<s&&(r=i*i,n=r*r*r,o=i*(_s+Ms*r+n*(xs+ys*r))-e.y,a=_s+3*Ms*r+n*(7*xs+9*ys*r),i-=h=o/a,!(Math.abs(h)<t));++c);return r=i*i,n=r*r*r,e.x=Wi*e.x*(_s+3*Ms*r+n*(7*xs+9*ys*r))/Math.cos(i),e.y=Math.asin(Math.sin(i)/Wi),this.es!==0&&(e.y=ms(e.y,this.apa)),e.x=S(e.x+this.long0,this.over),e}var _g=["eqearth","Equal Earth","Equal_Earth"],xl={init:mg,forward:pg,inverse:gg,names:_g};var Ss=1e-10;function Mg(){var e;if(this.phi1=this.lat1,Math.abs(this.phi1)<Ss)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)+Ss>=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),s=e.y,i,r,n;return i=this.am1+this.m1-qt(s,r=Math.sin(s),n=Math.cos(s),this.en),r=n*t/(i*Math.sqrt(1-this.es*r*r)),e.x=i*Math.sin(r),e.y=this.am1-i*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,s,i,r;if(s=Z(e.x,e.y=this.am1-e.y),r=Ie(this.am1+this.m1-s,this.es,this.en),(t=Math.abs(r))<x)t=Math.sin(r),i=s*Math.atan2(e.x,e.y)*Math.sqrt(1-this.es*t*t)/Math.cos(r);else if(Math.abs(t-x)<=Ss)i=0;else throw new Error;return e.x=S(i+(this.long0||0),this.over),e.y=ft(r),e}function Sg(e){var t=S(e.x-(this.long0||0),this.over),s=e.y,i,r;return r=this.cphi1+this.phi1-s,Math.abs(r)>Ss?(e.x=r*Math.sin(i=t*Math.cos(s)/r),e.y=this.cphi1-r*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 vg(e){e.x=(e.x-(this.x0||0))/this.a,e.y=(e.y-(this.y0||0))/this.a;var t,s,i=Z(e.x,e.y=this.cphi1-e.y);if(s=this.cphi1+this.phi1-i,Math.abs(s)>x)throw new Error;return Math.abs(Math.abs(s)-x)<=Ss?t=0:t=i*Math.atan2(e.x,e.y)/Math.cos(s),e.x=S(t+(this.long0||0),this.over),e.y=ft(s),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}},Hi={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=dn.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 s,i=Object.keys(Hi),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<i.length;a++){let h=i[a],c=Hi[h],l=Object.entries(c);if(l.some(([f])=>typeof this[f]<"u")){s=c;for(let f=0;f<l.length;f++){let[m,d]=l[f],g=r(m);if(typeof g>"u")throw new Error("Missing parameter: "+m+".");this[d]=g}break}}if(!s)throw new Error("No valid parameters provided for ob_tran projection.");let{lamp:n,phip:o}=Pg(this,s);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 bg(e){return this.projectionType.inverse(this,e)}function Pg(e,t){let s,i;if(t===Hi.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");i=r+Math.atan2(-1*Math.cos(o),-1*Math.sin(o)*Math.sin(n)),s=Math.asin(Math.cos(n)*Math.sin(o))}else if(t===Hi.NEW_POLE)i=e.oLongP,s=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");i=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)),s=Math.atan(-1*Math.cos(i-r)/Math.tan(n))}return{lamp:i,phip:s}}function Rg(e,t){let{x:s,y:i}=t;s=S(s-e.long0,e.over);let r=Math.cos(s),n=Math.sin(i),o=Math.cos(i);t.x=S(Math.atan2(o*Math.sin(s),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:s,y:i}=t;s=S(s-e.long0,e.over);let r=Math.cos(i),n=Math.cos(s);t.x=S(Math.atan2(r*Math.sin(s),Math.sin(i))+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 s=e.obliqueProjection.inverse(t),{x:i,y:r}=s;if(i<Number.MAX_VALUE){i-=e.lamp;let n=Math.cos(i),o=Math.sin(r),a=Math.cos(r);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 Ig(e,t){e.isIdentity&&(t.x*=B,t.y*=B);let s=e.obliqueProjection.inverse(t),{x:i,y:r}=s;if(i<Number.MAX_VALUE){let n=Math.cos(r);i-=e.lamp,t.x=Math.atan2(n*Math.sin(i),-1*Math.sin(r)),t.y=Math.asin(n*Math.cos(i))}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:bg,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(kc),e.Proj.projections.add(Vc),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(sl),e.Proj.projections.add(il),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:Pe,defs:we,nadgrid:Mn,transform:xn,mgrs:bc,version:"__VERSION__"});El(wl);var Nn=wl;var Ln=Nn,Bt=class{static defineProjectionAliases(t){for(let s in t)Ln.defs(s,t[s])}static registerDatumGrid(t,s,i){Ln.nadgrid(t,s,i)}constructor({from:t="WGS84",to:s="WGS84",enforceAxis:i=!1}){if(this._projection=Ln(t,s),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 vs=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 Yi(e){return typeof e.type=="string"?e.type:void 0}function bl(e){return Ng.has(e.type)}function Pl(e){return bl(e)?e.type!=="BoundCRS"||Pl(e.source_crs):!1}function Tl(e,t,s,i=!1){return{status:"unsupported",checked:!1,lossy:i,type:e,reason:t,message:s}}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(s=>Pl(s));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(bl(e))return{definition:e,lossy:!1,type:Yi(e)};if(t==="horizontal"&&e.type==="CompoundCRS"){let i=Gg(e);if("reason"in i)throw new vs(Tl(Yi(e),i.reason,i.message,!0));return{definition:i.definition,lossy:!0,type:Yi(e)}}let s=Yi(e);throw new vs(Tl(s,"unsupported-crs-type",s?`${s} 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],kg=12,zn=20/2,Vg=2,Es=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,s){if(t=Math.abs(t)>90?NaN:t,Number.isNaN(t)||Number.isNaN(s))return NaN;let i=jg(s,360);s=i!==-180?i:180;let r=s*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 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=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<kg;++y)f[M]+=d[y]*g[zn*y+M];f[M]/=_}}if(!this.options.cubic){let d=(1-r)*h+r*c,g=(1-r)*l+r*u,_=(1-n)*d+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 m=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 m=this.options._offset+this.options._scale*m,this._ix=o,this._iy=a,this._t=f,m}_rawval(t,s){t<0?t+=this.options._width:t>=this.options._width&&(t-=this.options._width),(s<0||s>=this.options._height)&&(s=s<0?-s:2*(this.options._height-1)-s,t+=(t<this.options._width/2?1:-1)*this.options._width/2);let i=this.options._datastart+Vg*(s*this.options._swidth+t),r=this.options.data[i],n=this.options.data[i+1];return r<<8|n}};function jg(e,t){t=Math.abs(t);let s=Rl(e,t);return 2*Math.abs(s)===t?s-=Rl(e,2*t)-s:2*Math.abs(s)>t&&(s+=s<0?t:-t),s}function Rl(e,t){return e-Math.floor(e/t)*t}var Wg=10,Hg=65535;function qn(e,t){let s=Yg(e),i=s.next();if(i.done||i.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,m=null;do{i=s.next();let M=i.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(!i.done);i=s.next();let d=parseInt(i.value.line,10);if(i.done)throw new Error("Geoid model file: Error reading maxval");if(d!==Hg)throw new Error("Geoid model file: Incorrect value of maxval");if(f=i.value.offset,m=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 Es({cubic:t.cubic,_width:l,_height:u,_rlonres:g,_rlatres:_,_offset:r,_scale:n,_swidth:m,_datastart:f,_maxerror:o,_rmserror:a,_description:h,_datetime:c,data:e})}function*Yg(e){let t=0;do{let s=e.indexOf(Wg,t);if(s!==-1){let i=e.subarray(t,s);t=s+1,yield{offset:t,line:Cl(i)}}else{let i=e.subarray(t,e.length);t=e.length,yield{offset:t,line:Cl(i)}}}while(t<e.length);return{offset:t,line:""}}function Cl(e){let t="";for(let s of e)t+=String.fromCharCode(s);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,s={}){let i=qn(t,s);return Bn(e,i),i}function Zi(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,s={}){this.spatialReference=t,Xg(t);let i=t.targetCrs||t.sourceCrs;if(this.sourceIsGeocentric=Un(t.sourceCrs),this.outputIsGeocentric=Un(i),this.sourceIsGeographic=Ll(t.sourceCrs),this.outputIsGeographic=Ll(i),t.sourceCrs&&t.targetCrs&&!this.sourceIsGeocentric&&!this.outputIsGeocentric&&(this.horizontalProjection=new Bt({from:Xi(t.sourceCrs),to:Xi(t.targetCrs),enforceAxis:!1})),(ws(t)||this.sourceIsGeocentric||this.outputIsGeocentric)&&(!this.sourceIsGeographic&&!this.sourceIsGeocentric&&(this.geographicProjection=new Bt({from:Xi(t.sourceCrs),to:Fn,enforceAxis:!1})),!this.outputIsGeographic&&!this.outputIsGeocentric&&(this.heightOutputProjection=new Bt({from:Fn,to:Xi(i),enforceAxis:!1}))),ws(t)&&(this.geoid=$g(s.geoidModel),!this.geoid)){let r=typeof s.geoidModel=="string"?` "${s.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 s=[...t];if(ws(this.spatialReference)||this.sourceIsGeocentric||this.outputIsGeocentric){if(s.length<3||!Number.isFinite(s[2]))throw new Error("Three-dimensional CRS conversion requires a finite z coordinate");let i=this.toGeographic(s);if(ws(this.spatialReference)){let n=this.geoid.getHeight(i[1],i[0]);i[2]=Qg(i[2],n,this.spatialReference.heightReference,this.spatialReference.targetHeightReference)}let r=this.fromGeographic(i);return s.splice(0,r.length,...r),s}if(this.horizontalProjection){let i=this.horizontalProjection.project(s.slice(0,3));s.splice(0,i.length,...i)}return s}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 Xi(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(ws(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(),s=t.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return s?`${s[1]}:${s[2]}`:t}function ws(e){let t=e.targetHeightReference;return t!=="native"&&t!==e.heightReference}function $g(e){return typeof e=="string"?Zi(e):e}function Qg(e,t,s,i){if(s===i||i==="native")return e;if(s==="orthometric"&&i==="ellipsoidal")return e+t;if(s==="ellipsoidal"&&i==="orthometric")return e-t;throw new Error(`Unsupported height conversion from ${s} to ${i}`)}var Be=class{spatialReference;targetCoordinateFrame;positionTransformer;sourceToGeographicTransformer;geographicToTargetTransformer;sourceCoordinateFrame;sourceVerticalUnitScale;elevationMode;elevationOffset;elevationProvider;providerUnitScale;providerHeightTransformer;constructor(t,s={}){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 $t(t,s),this.sourceCoordinateFrame=t.coordinateFrame,this.sourceVerticalUnitScale=t.verticalUnitScale,this.elevationMode=t.elevationMode,this.elevationOffset=(t.elevationOffset||0)*t.elevationUnitScale,this.elevationProvider=Kg(this.elevationMode,s),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=rs(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=kt(i),this.spatialReference=mi(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:s.geoidModel});this.providerHeightTransformer=new $t(h,s)}}let o=vt({sourceCrs:"EPSG:4326",heightReference:t.heightReference,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"format-default"},{targetCrs:i,targetHeightReference:t.targetHeightReference,geoidModel:s.geoidModel});this.geographicToTargetTransformer=new $t(o,s)}transformPosition(t){let s=this.placeSourcePositionsSync(t),i=this.positionTransformer.transformPosition([s[0],s[1],s[2]]);return[i[0],i[1],i[2]]}async transformPositionAsync(t){let s=await this.placeSourcePositions(t),i=this.positionTransformer.transformPosition([s[0],s[1],s[2]]);return[i[0],i[1],i[2]]}transformPlacedPosition(t){let s=this.positionTransformer.transformPosition([t[0],t[1],t[2]]);return[s[0],s[1],s[2]]}transformSourcePositionToGeographic(t){let s=this.placeSourcePositionsSync(t),i=this.sourceToGeographicTransformer.transformPosition([s[0],s[1],s[2]]);return[i[0],i[1],i[2]]}async transformSourcePositionToGeographicAsync(t){let s=await this.placeSourcePositions(t),i=this.sourceToGeographicTransformer.transformPosition([s[0],s[1],s[2]]);return[i[0],i[1],i[2]]}transformPositions(t,s){let i=this.placeSourcePositionsSync(t),r=this.placeSourcePositionsSync(s);return this.transformPlacedPositions(i,r)}async transformPositionsAsync(t,s){let i=new Float64Array(t.length+3);i.set(Array.from(t),0),i.set(Array.from(s).slice(0,3),t.length);let r=await this.placeSourcePositions(i);return this.transformPlacedPositions(r.subarray(0,t.length),r.subarray(t.length))}transformPlacedPositions(t,s){let i=this.transformPlacedPosition(s),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]-i[0],r[h+1]=c[1]-i[1],r[h+2]=c[2]-i[2]}let o=this.targetCoordinateFrame==="geographic",a=o?new I:new I().translate(i);return{positions:r,sourcePositions:n,origin:i,cartographicOrigin:o?i:[0,0,0],coordinateSystem:o?"lnglat-offsets":"cartesian",modelMatrix:a}}transformNormals(t,s,i="earth-centered"){let r=new Float32Array(t.length);for(let n=0;n<t.length;n+=3){let o=this.sourceToGeographicTransformer.transformPosition([s[n],s[n+1],s[n+2]]),a=new p([t[n],t[n+1],t[n+2]]).normalize(),h=i==="earth-centered"?a:Fl(a,o),c=this.transformEcefNormal(h,o);r.set(c,n)}return r}transformBoundingVolume(t){let i=this.getGeographicBoundSamples(t).map(r=>this.geographicToTargetTransformer.transformPosition(r));return this.targetCoordinateFrame==="geographic"?{region:ee(i)}:{box:ce(i)}}async transformBoundingVolumeAsync(t){let i=(await this.getGeographicBoundSamplesAsync(t)).map(r=>this.geographicToTargetTransformer.transformPosition(r));return this.targetCoordinateFrame==="geographic"?{region:ee(i)}:{box:ce(i)}}transformBoundingVolumeToGeographic(t){return{region:ee(this.getGeographicBoundSamples(t))}}async transformBoundingVolumeToGeographicAsync(t){return{region:ee(await this.getGeographicBoundSamplesAsync(t))}}transformBoundingVolumeToGeocentric(t){let s=this.getGeographicBoundSamples(t).map(i=>Array.from(P.WGS84.cartographicToCartesian(new p(i))));return{box:ce(s)}}async transformBoundingVolumeToGeocentricAsync(t){let s=(await this.getGeographicBoundSamplesAsync(t)).map(i=>Array.from(P.WGS84.cartographicToCartesian(new p(i))));return{box:ce(s)}}transformBoundingSphereToGeographic(t){let s=t.mbs?.length?Array.from(t.mbs).slice(0,3):t.obb?Array.from(t.obb.center).slice(0,3):null;if(!s)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let i=this.placeSourcePositionsSync(s),r=this.sourceToGeographicTransformer.transformPosition(Array.from(i)),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 s=await this.getGeographicBoundSamplesAsync(t),i=s.map(n=>Array.from(P.WGS84.cartographicToCartesian(new p(n)))),r=s.map(n=>this.geographicToTargetTransformer.transformPosition(n));return{boundingVolume:{box:ce(i)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ee(r)}:{box:ce(r)},i3sLodMbs:qe(this.elevationMode)?zl(s):this.transformBoundingSphereToGeographic(t)}}async transformPointCloudBoundsAsync(t){let s=await this.getGeographicBoundSamplesAsync(t),i=s.map(r=>this.geographicToTargetTransformer.transformPosition(r));return{boundingVolume:{region:ee(s)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:ee(i)}:{box:ce(i)}}}getGeographicBoundSamples(t){let s=ql(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!s.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let i=this.placeSourcePositionsSync(s.flat(),!0),r=kn(i);return this.sourceCoordinateFrame==="geographic"?r:r.map(n=>this.sourceToGeographicTransformer.transformPosition(n))}async getGeographicBoundSamplesAsync(t){let s=ql(t,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!s.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");if(qe(this.elevationMode)){let r=this.sourceCoordinateFrame==="geographic"?s:s.map(n=>this.sourceToGeographicTransformer.transformPosition(n));return await this.placeGeographicBoundSamples(r)}let i=kn(await this.placeSourcePositions(s.flat(),!0));return this.sourceCoordinateFrame==="geographic"?i:i.map(r=>this.sourceToGeographicTransformer.transformPosition(r))}async placeGeographicBoundSamples(t){let i=await this.elevationProvider.getElevationRange(Jg(t)),r=i.minimum*this.providerUnitScale,n=i.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,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,M=this.elevationMode==="onTheGround"?g:g+h+this.elevationOffset;c.push([l,u,_],[l,u,M])}return c}placeSourcePositionsSync(t,s=!1){if(qe(this.elevationMode))throw new Error(`I3S elevation mode ${this.elevationMode} requires asynchronous surface placement`);let i=Float64Array.from(t),r=this.elevationMode==="absoluteHeight"?this.elevationOffset:0;for(let n=2;n<i.length;n+=3)i[n]=i[n]*(s?1:this.sourceVerticalUnitScale)+r;return i}async placeSourcePositions(t,s=!1){if(!qe(this.elevationMode))return this.placeSourcePositionsSync(t,s);let i=Float64Array.from(t),r=kn(i).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=i[o*3+2]*(s?1:this.sourceVerticalUnitScale);i[o*3+2]=this.elevationMode==="onTheGround"?l:l+u+this.elevationOffset}return i}transformEcefNormal(t,s){if(this.targetCoordinateFrame==="geocentric")return t.normalize();if(this.targetCoordinateFrame==="geographic")return e2(t,s).normalize();let i=P.WGS84.cartographicToCartesian(new p(s)),r=[];for(let o of t2()){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);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 kn(e){if(e.length%3!==0)throw new Error("I3S position arrays must contain complete XYZ tuples");let t=[];for(let s=0;s<e.length;s+=3)t.push([e[s],e[s+1],e[s+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=>P.WGS84.cartographicToCartesian(new p(n))),s=new p;for(let n of t)s.add(n);s.scale(1/t.length);let i=0;for(let n of t)i=Math.max(i,new p(n).subtract(s).magnitude());let r=P.WGS84.cartesianToCartographic(s);return[r[0],r[1],r[2],i]}function ql(e,t,s,i){let r=e.obb;if(r){let h=Array.from(r.center).slice(0,3);h[2]*=i;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=s.transformPosition(h),m=P.WGS84.cartographicToCartesian(new p(f)),d=e.normalReferenceFrame==="vertex-reference-frame"?u.map(g=>Fl(g,f)):u;return Bl().map(g=>{let _=new p(m);for(let M=0;M<3;M++)_.add(new p(d[M]).scale(g[M]));return Array.from(P.WGS84.cartesianToCartographic(_))})}return Bl().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=s.transformPosition(o),c=P.WGS84.cartographicToCartesian(new p(h));return Dl().map(l=>Array.from(P.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(s=>[e,t,s])))}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 s=t[0]*Math.PI/180,i=t[1]*Math.PI/180,r=new p([-Math.sin(s),Math.cos(s),0]),n=new p([-Math.sin(i)*Math.cos(s),-Math.sin(i)*Math.sin(s),Math.cos(i)]),o=new p([Math.cos(i)*Math.cos(s),Math.cos(i)*Math.sin(s),Math.sin(i)]);return r.scale(e[0]).add(n.scale(e[1])).add(o.scale(e[2]))}function e2(e,t){let s=t[0]*Math.PI/180,i=t[1]*Math.PI/180,r=new p([-Math.sin(s),Math.cos(s),0]),n=new p([-Math.sin(i)*Math.cos(s),-Math.sin(i)*Math.sin(s),Math.cos(i)]),o=new p([Math.cos(i)*Math.cos(s),Math.cos(i)*Math.sin(s),Math.sin(i)]);return new p([r.dot(e),n.dot(e),o.dot(e)])}function ce(e){let t=[1/0,1/0,1/0],s=[-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]),s[o]=Math.max(s[o],n[o]);let i=t.map((n,o)=>(n+s[o])/2),r=t.map((n,o)=>(s[o]-n)/2);return[i[0],i[1],i[2],r[0],0,0,0,r[1],0,0,0,r[2]]}function ee(e){let t=e[0][0],s=1/0,i=-1/0,r=1/0,n=-1/0,o=1/0,a=-1/0;for(let h of e){let c=t+Vn(h[0]-t);s=Math.min(s,c),i=Math.max(i,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[Vn(s)*Math.PI/180,r*Math.PI/180,Vn(i)*Math.PI/180,n*Math.PI/180,o,a]}function Vn(e){return((e+180)%360+360)%360-180}var s2={draco:!1,meshopt:!1,dds:!1,ktx2:!1},$i=class{type=at.I3S;loader;contentLoader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...s2};asset;properties;extras;credits;metadata;queryParams={};resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(t,s={}){let i=r2(t);this.rootTileset=Ul(t)?null:t,this.tileset=this.rootTileset,this.loader=i.loader,this.contentLoader=i2(i.loader),this.url=i.url,this.basePath=i.basePath||gt.dirname(i.url),this.resolver=i.resolver,this.coreApi=i.coreApi,this.loadOptions=s,this.initializeQueryParams(s)}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:Si(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 s=t.spatialReference;if(s.status==="unresolved")throw new Error(s.warnings[0]||"I3S spatial operations cannot be resolved from the supplied metadata and options");s.status!=="transformable"&&s.status!=="transformed"||(this.spatialTransformer||=new Be(s,t.options.spatial),t.spatialReference=this.spatialTransformer.spatialReference,this.preparedRootHeader=await this.transformTileHeader(this.getMetadata().tileset.root))}initializeTileHeaders(t,s,i){let r=i?s.root:this.preparedRootHeader||s.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,i||void 0);return i&&(i.children.push(n),n.depth=i.depth+1),n}createTraverser(t){return new Ri(t)}async loadTileContent(t){let s=this.getTileUrl(t.contentUrl),i=this.loader.id,r=this.loadOptions[i]||{},n=this.getMetadata(),o={...this.loadOptions,[i]:{...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(s,o,this.contentLoader),{loaded:!0}}async loadChildTileHeader(t,s,i){let r=this.getMetadata();if(r.tileset.nodePages||r.tileset.pointNodePages){let c=await r.tileset.nodePagesTile.formTileFromNodePages(s);return await this.transformTileHeader(c)}let n=this.getTileUrl(`${this.url}/nodes/${s}`),o=this.loadOptions.i3s&&typeof this.loadOptions.i3s=="object"?this.loadOptions.i3s:{},a={...this.loadOptions,i3s:{...o,isTileHeader:!0}},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 s=t.indexOf("?");if(s===-1)return`${t}?${new URLSearchParams(this.queryParams).toString()}`;let i=t.slice(s+1),r=new Set(i.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}${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 s=this.getMetadata(),i=s.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:sn(i,u,f)}}let r=s.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 P.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,s){switch(s.header.isDracoGeometry&&(this.contentFormats.draco=!0),s.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}}getTilesTotalCount(){return this.getMetadata().tileset?.nodePagesTile?.nodesInNodePages||null}async loadWithCoreApi(t,s,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,s)}async loadRootData(t,s){return this.resolver?await this.resolver.loadRoot(t,this.loader,s):await this.loadWithCoreApi(t,s)}initializeQueryParams(t){let s=t.i3s;if(s&&typeof s=="object"&&"token"in s){let i=s.token;typeof i=="string"&&(this.queryParams.token=i)}}async loadResourceData(t,s,i=this.loader){return this.resolver?await this.resolver.loadResource(t,i,s):await this.loadWithCoreApi(t,s,i)}async transformTileHeader(t){if(!this.spatialTransformer)return t;let s={mbs:t.mbs,obb:t.obb,normalReferenceFrame:this.getMetadata().tileset.store?.normalReferenceFrame},i=await this.spatialTransformer.transformBoundsAsync(s);return{...t,boundingVolume:i.boundingVolume,spatialBoundingVolume:i.spatialBoundingVolume,i3sLodMbs:i.i3sLodMbs}}};function i2(e){return e.contentLoader||e}function Ul(e){return!!(e&&typeof e=="object"&&"url"in e&&"loader"in e&&!("type"in e))}function r2(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:s,onLoad:i,onError:r}){let n=(_,M,y)=>{if(y===this._loaderId){if(this._loader=void 0,this.content=_,this.error=M?n2(M):null,this._isCancelled&&!_){this._isLoaded=!1;return}if(this._isLoaded=!0,this._isCancelled=!1,M){r(M,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 s.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 n2(e){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error("Tile request failed")}var jn="never",Wn="no-overlap",bs="best-available",kl={adapter:null,extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:100,maxCacheByteSize:null,refinementStrategy:bs,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},tileSource:null},Ts=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={...kl,...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,s={}){return new e({...s,tileSource:t})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let t=this._getVisibleTilesUnion();for(let s of this._getSelectedTilesUnion())t.add(s);return Array.from(t)}get loadingTiles(){return Array.from(this._cache.values()).filter(t=>t.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(t=>!t.isLoaded)}get maxZoom(){return this._maxZoom}get minZoom(){return this._minZoom}get refinementStrategy(){return this.opts.refinementStrategy||bs}get adapter(){return this.opts.adapter}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}attachConsumer(t){this._consumers.set(t,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(t){this._consumers.delete(t),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(t){this._rememberExplicitOptions(t),this._baseOpts={...this._baseOpts,...t};let s=this.opts.maxRequests,i=this.opts.debounceTime;this._applyResolvedOptions(),(s!==this.opts.maxRequests||i!==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 s of this._cache.keys()){let i=this._cache.get(s);i&&!t.has(i)?(this._cache.delete(s),this._handleTileUnload(i),this._dirty=!0):i&&i.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(t,s,i){this._consumers.set(t,{selectedTiles:new Set(s),visibleTiles:new Set(i)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:t,maxZoom:s,minZoom:i,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:s,minZoom:i,zRange:r,tileSize:h,extent:o2(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,s){let i=this.getTileId(t),r=this._cache.get(i),n=!1;return!r&&s?(r=new le(t),Object.assign(r,this.getTileMetadata(r.index)),Object.assign(r,{id:i,zoom:this.getTileZoom(r.index)}),n=!0,this._cache.set(i,r),this._dirty=!0,this._updateStats()):r&&r.needsReload&&(n=!0),r&&this._touchTile(i,r),r&&n&&s&&(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(s){let i=s instanceof Error?s:new Error(`TileSource metadata error: ${String(s)}`);this._notifyError(i)}}_rememberExplicitOptions(t){for(let s of Object.keys(t))this._explicitOptionKeys.add(s)}_applyResolvedOptions(){let t={...kl,...this._sourceMetadataOverrides,...this._baseOpts};if(t.tileSource){let s=t.tileSource;t.getTileData=i=>s.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 s={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(t.minZoom)&&(s.minZoom=t.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(t.maxZoom)&&(s.maxZoom=t.maxZoom),!this._explicitOptionKeys.has("extent")&&t.boundingBox&&(s.extent=[t.boundingBox[0][0],t.boundingBox[0][1],t.boundingBox[1][0],t.boundingBox[1][1]]),s}_handleTileLoad(t){this.opts.onTileLoad?.(t),this._cacheByteSize=this._getCacheByteSize(),this._resizeCache();for(let s of this._listeners)s.onTileLoad?.(t);this._updateStats()}_handleTileError(t,s){this.opts.onTileError?.(t,s);for(let i of this._listeners)i.onTileError?.(t,s);this._updateStats()}_handleTileUnload(t){this._unloadedTileCount++,this.opts.onTileUnload?.(t);for(let s of this._listeners)s.onTileUnload?.(t);this._updateStats()}_notifyUpdate(){for(let t of this._listeners)t.onUpdate?.()}_notifyError(t){for(let s of this._listeners)s.onError?.(t)}_updateStats(){this._setStatCount("Tiles In Cache",this._cache.size),this._setStatCount("Cache Size",this.cacheByteSize),this._setStatCount("Visible Tiles",this.visibleTiles.length),this._setStatCount("Selected Tiles",this.selectedTiles.length),this._setStatCount("Loading Tiles",this.loadingTiles.length),this._setStatCount("Unloaded Tiles",this._unloadedTileCount),this._setStatCount("Consumers",this._consumers.size);for(let t of this._listeners)t.onStatsChange?.(this.stats)}_setStatCount(t,s){this.stats.get(t).reset().addCount(s)}_getSelectedTilesUnion(){let t=new Set;for(let s of this._consumers.values())for(let i of s.selectedTiles)t.add(i);return t}_getVisibleTilesUnion(){let t=new Set;for(let s of this._consumers.values())for(let i of s.visibleTiles)t.add(i);return t}_touchTile(t,s){this._cache.delete(t),this._cache.set(t,s)}_getCacheByteSize(){let t=0;for(let s of this._cache.values())t+=s.byteLength;return t}_pruneRequests(){let{maxRequests:t=0}=this.opts,s=this._getSelectedTilesUnion(),i=this._getVisibleTilesUnion(),r=[],n=0;for(let o of this._cache.values())o.isLoading&&(n++,!s.has(o)&&!i.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 s=this._getNearestAncestor(t);t.parent=s,s?.children&&s.children.push(t)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((t,s)=>t.zoom-s.zoom)}_resizeCache(){let t=this.opts.maxCacheSize??100,s=this.opts.maxCacheByteSize??1/0,i=this._getVisibleTilesUnion(),r=this._getSelectedTilesUnion();if(this._cache.size>t||this._cacheByteSize>s){for(let[o,a]of this._cache)if(!i.has(a)&&!r.has(a)&&(this._cache.delete(o),this._cacheByteSize=this._getCacheByteSize(),this._handleTileUnload(a)),this._cache.size<=t&&this._cacheByteSize<=s)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(t){let{_minZoom:s=0}=this,i=t.index;for(;this.getTileZoom(i)>s;){i=this.getParentIndex(i);let r=this.getTile(i);if(r)return r}return null}};function o2(e){return e&&e.length===4?e:void 0}var Qi={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},Ki=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.imageSource&&(!t.getImage||!t.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(t,s={}){return new e({...s,imageSource:t})}get isLoaded(){return this._loadCounter===0&&!!this._currentRequest}get image(){return this._currentRequest?.image||null}get currentRequest(){return this._currentRequest}get imageSource(){return this._opts.imageSource}subscribe(t){return this._listeners.add(t),()=>this._listeners.delete(t)}setOptions(t){let s=this._opts.imageSource,i=this._normalizeOptions({...this._opts,...t}),r=s!==i.imageSource||this._opts.getImage!==i.getImage||this._opts.getMetadata!==i.getMetadata;this._opts=i,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 s of this._listeners)s.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let s=Vl(t,"Image metadata request failed");if(!this._finalized)for(let i of this._listeners)i.onMetadataLoadError?.(s);throw s}finally{this._finishLoading()}}requestImage(t,s=this._opts.debounceTime){let i=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),s>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(i,t)},s):this._loadImage(i,t),i}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(t,s){if(!this._finalized){this._startLoading();for(let i of this._listeners)i.onImageLoadStart?.(t,s);try{let i=new AbortController;this._abortController=i;let r=await this._opts.getImage({...s,signal:i.signal});if(this._finalized||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:s,image:r};for(let n of this._listeners)n.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(i){if(a2(i))return;let r=Vl(i,"Image request failed");if(!this._finalized)for(let n of this._listeners)n.onImageLoadError?.(t,r,s)}finally{this._abortController?.signal===s.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(t){let s=t.imageSource||null;return{...Qi,...t,imageSource:s,getMetadata:t.getMetadata||(()=>s?s.getMetadata():Qi.getMetadata()),getImage:t.getImage||(i=>s?s.getImage(i):Qi.getImage(i)),debounceTime:t.debounceTime??Qi.debounceTime}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(t){for(let s of this._listeners)s.onLoadingStateChange?.(t)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function a2(e){return e instanceof Error&&e.name==="AbortError"}function Vl(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}var Ps={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},Ji=class e{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(t){if(this._opts=this._normalizeOptions(t),!this._opts.rasterSource&&(!t.getRaster||!t.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(t,s={}){return new e({...s,rasterSource:t})}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 s=this._opts.rasterSource,i=this._normalizeOptions({...this._opts,...t}),r=s!==i.rasterSource||this._opts.getRaster!==i.getRaster||this._opts.getMetadata!==i.getMetadata;this._opts=i,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 s of this._listeners)s.onMetadataLoad?.(t);return this._emitUpdate(),t}catch(t){let s=jl(t,"Raster metadata request failed");if(!this._finalized)for(let i of this._listeners)i.onMetadataLoadError?.(s);throw s}finally{this._finishLoading()}}requestRaster(t,s=this._opts.debounceTime){if(!this.shouldRefetchRaster(t))return this._currentRequest?.requestId??-1;let i=this._nextRequestId++;return this._cancelScheduledRaster(),s>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(i,t)},s):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,s){if(!this._finalized){this._startLoading();for(let i of this._listeners)i.onRasterLoadStart?.(t,s);try{let i=new AbortController;this._abortController=i;let r=await this._opts.getRaster(h2(s,i.signal));if(this._finalized||i.signal.aborted||t<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=t,this._currentRequest={requestId:t,parameters:s,raster:r};for(let n of this._listeners)n.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(i){if(c2(i))return;let r=jl(i,"Raster request failed");if(!this._finalized)for(let n of this._listeners)n.onRasterLoadError?.(t,r,s)}finally{this._abortController=null,this._finishLoading()}}}_normalizeOptions(t){let s=t.rasterSource||null;return{...Ps,...t,rasterSource:s,getMetadata:t.getMetadata||(()=>s?s.getMetadata():Ps.getMetadata()),getRaster:t.getRaster||(i=>s?s.getRaster(i):Ps.getRaster(i)),debounceTime:t.debounceTime??Ps.debounceTime,shouldRefetch:t.shouldRefetch||(i=>Ps.shouldRefetch(i))}}_emitUpdate(){for(let t of this._listeners)t.onUpdate?.()}_emitLoadingStateChange(t){for(let s of this._listeners)s.onLoadingStateChange?.(t)}_startLoading(){let t=this._loadCounter>0;this._loadCounter++,t||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let t=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),t&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_cancelScheduledRaster(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function h2(e,t){let s=Array.isArray(e)?e.slice():Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e));return Object.defineProperty(s,"signal",{configurable:!0,enumerable:!0,value:t,writable:!0}),s}function jl(e,t){return e instanceof Error?e:typeof e=="string"?new Error(e):new Error(t)}function c2(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,s=null){this.header=t,this.parent=s}get id(){return this.header.id}get level(){return this.header.level}get pointCount(){return this.header.pointCount}get geometricError(){return this.header.geometricError}get boundingVolume(){return this.header.boundingVolume}setSelected(t){this.selected=!0,this.viewportIds.includes(t)||this.viewportIds.push(t)}clearSelection(){this.selected=!1,this.viewportIds=[]}};var l2={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,s={}){this.dataSource=t,this.options={...l2,...s},this.tilesetInitializationPromise=this.initialize()}tilesetInitializationPromise;get isReady(){return this.dataSource.isReady}get frameNumber(){return this.frameNumberValue}get tiles(){return Array.from(this.tilesMap.values())}isLoaded(){return this.frameNumberValue>0&&this.pendingCount===0&&this.selectedTiles.every(t=>t.contentAvailable||t.contentFailed)}selectedTiles=[];update(t=null){this.selectTiles(t).catch(()=>{})}destroy(){this.selectedTiles=[],this.tilesMap.clear(),this.root=null,this.cartographicCenter=null,this.boundingVolume=null,this.visibleTilesCount=0,this.pendingCount=0,this.lastUpdatedViewports=null,this.updatePromise=null}async initialize(){await this.dataSource.initialize();let t=await this.dataSource.getRootTile();this.root=this.getOrCreateTile(t,null);let s=await this.dataSource.getViewState?.();this.boundingVolume=s?.boundingVolume||this.root.boundingVolume;let i=s?.cartographicCenter||this.root.boundingVolume.center;this.cartographicCenter=new p(i),this.zoom=s?.zoom||this.estimateZoom(this.boundingVolume)}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedViewports=t),this.updatePromise||(this.updatePromise=new Promise((s,i)=>{setTimeout(()=>{this.doSelectTiles().then(()=>s(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 s=Array.isArray(this.lastUpdatedViewports)?this.lastUpdatedViewports:[this.lastUpdatedViewports],i=new Map,r=new Set,n=0;for(let a of s){let h=this.getTraversalContext(a);n=await this.traverseTiles(h,i,n,r)}this.visibleTilesCount=r.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,s,i,r){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(r.add(h.id),!s.has(h.id)&&h.pointCount>0){if(n>0&&n+h.pointCount>this.options.pointBudget)break;s.set(h.id,h),n+=h.pointCount}if(s.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,s){if(t.level<this.options.maxDepth&&Number.isFinite(s)&&(t.header.lodSelectionMetricType||this.options.lodSelectionMetricType)==="density-threshold"){let i=Math.max(1,Math.PI*s*s),r=t.pointCount/i,n=t.header.lodThreshold||this.options.densityThreshold;return r<n}return t.level<this.options.maxDepth&&Number.isFinite(s)&&s>=this.options.minimumNodePixelSize}getTraversalContext(t){let s=this.getCullingVolume(t);return{viewport:t,cullingVolume:this.shouldUseCullingVolume(t,s)?s:null}}isVisible(t,s){if(s.cullingVolume){let r=this.getCommonSpaceBoundingSphere(t.boundingVolume,s.viewport);if(r)return this.isBoundingSphereInsideCullingVolume(r,s.cullingVolume)}let i=this.getProjectedFootprint(t.boundingVolume,s.viewport);return i?this.isProjectedFootprintVisible(i,s.viewport):!1}shouldUseCullingVolume(t,s){if(!this.root||!s)return!1;let i=this.getCommonSpaceBoundingSphere(this.root.boundingVolume,t);if(!i)return!1;if(this.isBoundingSphereInsideCullingVolume(i,s))return!0;let r=this.getProjectedFootprint(this.root.boundingVolume,t);return!r||!this.isProjectedFootprintVisible(r,t)}isBoundingSphereInsideCullingVolume(t,s){return s.computeVisibilityWithPlaneMask(t,K.MASK_INDETERMINATE)!==K.MASK_OUTSIDE}isProjectedFootprintVisible(t,s){return!(t.x+t.radius<-tr||t.x-t.radius>s.width+tr||t.y+t.radius<-tr||t.y-t.radius>s.height+tr)}estimateScreenRadius(t,s){let i=this.getProjectedFootprint(t.boundingVolume,s);return i?i.radius:0}projectBounds(t,s){let i=this.getBoundingVolumeCorners(t),r=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;try{for(let h of i){let[c,l]=s.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,s){let i=Number.NaN,r=Number.NaN;try{[i,r]=s.project(t.center)}catch{return null}if(!Number.isFinite(i)||!Number.isFinite(r))return null;let n=this.getBoundingVolumeCorners(t),o=0;try{for(let a of n){let[h,c]=s.project(a);!Number.isFinite(h)||!Number.isFinite(c)||(o=Math.max(o,Math.hypot(h-i,c-r)))}}catch{return null}if(o===0){let a=this.projectBounds(t,s);a&&(o=Math.max(a.maxX-a.minX,a.maxY-a.minY)/2)}return{x:i,y:r,radius:o}}async getVisibleChildren(t,s){return t.level>=this.options.maxDepth?[]:(await this.getChildren(t)).map(r=>({tile:r,weight:this.estimateScreenRadius(r,s.viewport)})).filter(r=>this.isVisible(r.tile,s))}async getChildren(t){if(t.childrenLoaded)return t.children;if(!t.childrenPromise){let s=this.dataSource.getChildren(t.header).then(i=>i.map(r=>this.getOrCreateTile(r,t))).then(i=>(t.children=i,t.childrenLoaded=!0,i));t.childrenPromise=s.finally(()=>{t.childrenPromise===s&&(t.childrenPromise=null)})}return t.childrenPromise}getOrCreateTile(t,s){let i=this.tilesMap.get(t.id);if(i)return i.header=t,s&&i.parent!==s&&(i.parent=s),i;let r=new De(t,s);return this.tilesMap.set(t.id,r),s&&!s.children.find(n=>n.id===r.id)&&s.children.push(r),r}async loadTile(t){if(!(t.contentAvailable||t.isContentLoading||t.contentFailed)){t.isContentLoading=!0,this.pendingCount++;try{let s=await this.dataSource.loadTileContent(t.header);t.content=s,t.contentAvailable=!0,s&&this.options.onTileLoad(t)}catch(s){t.contentFailed=!0,this.options.onTileError(t,s)}finally{t.isContentLoading=!1,this.pendingCount--}}}estimateZoom(t){if(!t||t.coordinateFrame==="cartesian")return 1;let[s,i]=t.cartographicBounds,r=t.coversFullLongitude?360:t.wrapsDateline?360-Math.abs(i[0]-s[0]):Math.abs(i[0]-s[0]),n=Math.max(r,1e-6);return Math.max(1,Math.round(Math.log2(360/n)))}haveSameIds(t,s){if(t.size!==s.size)return!1;for(let i of t)if(!s.has(i))return!1;return!0}getBoundingVolumeCorners(t){let[s,i]=t.cartographicBounds,r=t.coversFullLongitude?[[-180,180]]:t.wrapsDateline?[[s[0],180],[-180,i[0]]]:[[s[0],i[0]]],n=[],o=360-Math.abs(i[0]-s[0]),a=s[0]+o/2;for(let[h,c]of r){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,s[1],s[2]||0],[u,s[1],i[2]||0],[u,i[1],s[2]||0],[u,i[1],i[2]||0],[f,s[1],s[2]||0],[f,s[1],i[2]||0],[f,i[1],s[2]||0],[f,i[1],i[2]||0])}return n}getCullingVolume(t){let s=t.getFrustumPlanes?.bind(t);if(!s)return null;let i=s(),r=["left","right","bottom","top","near","far"],n=[];for(let o of r){let a=i[o];if(!a)return null;n.push(new Y(a.normal,-a.distance))}return new K(n)}getCommonSpaceBoundingSphere(t,s){let i=s.projectPosition?.bind(s);if(!i)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,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 f0(Rs);})();
7
+ "use strict";var __exports__=(()=>{var Cf=Object.create;var nn=Object.defineProperty;var Af=Object.getOwnPropertyDescriptor;var If=Object.getOwnPropertyNames;var Of=Object.getPrototypeOf,Nf=Object.prototype.hasOwnProperty;var Lf=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},$i=(t,e)=>{for(var r in e)nn(t,r,{get:e[r],enumerable:!0})},rn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of If(e))!Nf.call(t,i)&&i!==r&&nn(t,i,{get:()=>e[i],enumerable:!(n=Af(e,i))||n.enumerable});return t},on=(t,e,r)=>(rn(t,e,"default"),r&&rn(r,e,"default")),Gf=(t,e,r)=>(r=t!=null?Cf(Of(t)):{},rn(e||!t||!t.__esModule?nn(r,"default",{value:t,enumerable:!0}):r,t)),qf=t=>rn(nn({},"__esModule",{value:!0}),t);var la=Lf((N2,ca)=>{ca.exports=globalThis.loaders});var tn={};$i(tn,{I3SSource:()=>Li,I3SSpatialTransformer:()=>tr,ImageSet:()=>qi,IndexedArchiveTilesetSource:()=>Xn,LOD_METRIC_TYPE:()=>Dt,PointCloudTile:()=>rr,PointCloudTileset:()=>Di,RasterSet:()=>zi,STRATEGY_DEFAULT:()=>Jr,STRATEGY_NEVER:()=>ia,STRATEGY_REPLACE:()=>oa,SharedTile2DHeader:()=>Ct,SpatialCoordinateTransformer:()=>Be,TILESET_TYPE:()=>he,TILE_CONTENT_STATE:()=>ae,TILE_REFINEMENT:()=>te,TILE_TYPE:()=>Ke,Tile3D:()=>Pe,Tiles3DSource:()=>Ai,Tiles3DSpatialTransformer:()=>Mt,Tileset2D:()=>Qr,Tileset3D:()=>$n,TilesetCache:()=>Bt,TilesetTraverser:()=>Xe,applyTilesetSpatialOptions:()=>wt,calculateTransformProps:()=>kn,convertS2BoundingVolumeToOBB:()=>Ri,createBoundingVolume:()=>Ut,createImplicitSubtreeReference:()=>Js,createTilesetSpatialReference:()=>ve,get3DTilesSpatialReference:()=>ri,getFrameState:()=>Fn,getGeoidModel:()=>bi,getI3SSpatialReference:()=>ti,getLodStatus:()=>Jn,getSpatialCoordinateFrame:()=>_e,getTileset3DTraversalSnapshot:()=>Il,isTileset3DSource:()=>Wn,markTilesetSpatialReferenceTransformed:()=>Ft,materializeImplicitSubtree:()=>Ci,registerGeoidModel:()=>Hs,registerGeoidModelFromPgm:()=>I0,registerSpatialCrs:()=>C0,registerSpatialDatumGrid:()=>A0,replaceImplicitUrlTemplate:()=>Zr,traverseTilesetContents:()=>Ol});on(tn,Gf(la(),1));var V={};$i(V,{EPSILON1:()=>zf,EPSILON10:()=>Hf,EPSILON11:()=>$f,EPSILON12:()=>Yf,EPSILON13:()=>Kf,EPSILON14:()=>sn,EPSILON15:()=>Xf,EPSILON16:()=>Zf,EPSILON17:()=>Qf,EPSILON18:()=>Jf,EPSILON19:()=>ed,EPSILON2:()=>Bf,EPSILON20:()=>td,EPSILON3:()=>Df,EPSILON4:()=>kf,EPSILON5:()=>Ff,EPSILON6:()=>Uf,EPSILON7:()=>Vf,EPSILON8:()=>jf,EPSILON9:()=>Wf,PI:()=>At,PI_OVER_FOUR:()=>nd,PI_OVER_SIX:()=>id,PI_OVER_TWO:()=>rd,TWO_PI:()=>nr});var zf=.1,Bf=.01,Df=.001,kf=1e-4,Ff=1e-5,Uf=1e-6,Vf=1e-7,jf=1e-8,Wf=1e-9,Hf=1e-10,$f=1e-11,Yf=1e-12,Kf=1e-13,sn=1e-14,Xf=1e-15,Zf=1e-16,Qf=1e-17,Jf=1e-18,ed=1e-19,td=1e-20,rd=Math.PI/2,nd=Math.PI/4,id=Math.PI/6,At=Math.PI,nr=Math.PI*2;var od=1/Math.PI*180,sd=1/180*Math.PI,ad={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...ad}};var Y=globalThis.mathgl.config;function Yi(t,{precision:e=Y.precision}={}){return t=ld(t),`${parseFloat(t.toPrecision(e))}`}function $e(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ki(t){return an(t)}function Xi(t){return ge(t)}function an(t,e){return Qi(t,r=>r*sd,e)}function ge(t,e){return Qi(t,r=>r*od,e)}function ha(t,e){return Math.sign(t)===Math.sign(e)&&Math.abs(t)<Math.abs(e)?t:(t%e+e)%e}function Zi(t,e){switch(e){case"negative-pi-to-pi":return cd(t);case"zero-to-two-pi":return ua(t);default:return t}}function ua(t){if(t>=0&&t<=nr)return t;let e=ha(t,nr);return Math.abs(e)<1e-14&&Math.abs(t)>1e-14?nr:e}function cd(t){return t>=-At&&t<=At?t:ua(t+At)-At}function ir(t,e,r){return Qi(t,n=>Math.max(e,Math.min(r,n)))}function Te(t,e,r){let n=Y.EPSILON;r&&(Y.EPSILON=r);try{if(t===e)return!0;if($e(t)&&$e(e)){if(t.length!==e.length)return!1;for(let i=0;i<t.length;++i)if(!Te(t[i],e[i]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=Y.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{Y.EPSILON=n}}function ld(t){return Math.round(t/Y.EPSILON)*Y.EPSILON}function hd(t){return t.clone?t.clone():new Array(t.length)}function Qi(t,e,r){if($e(t)){let n=t;r=r||hd(n);for(let i=0;i<r.length&&i<n.length;++i){let o=typeof t=="number"?t:t[i];r[i]=e(o,i,r)}return r}return e(t)}var ut=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+r];return this.check()}toArray(e=[],r=0){for(let n=0;n<this.ELEMENTS;++n)e[r+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:$e(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toString(){return this.formatString(Y)}formatString(e){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Yi(this[n],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Te(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,n){if(n===void 0)return this.lerp(this,e,r);for(let i=0;i<this.ELEMENTS;++i){let o=e[i],s=typeof r=="number"?r:r[i];this[i]=o+n*(s-o)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),r[n]);return this.check()}add(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(Y.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}};function ud(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function j(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function It(t,e,r=""){if(Y.debug&&!ud(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}var Ot=class extends ut{toString(){let e="[";if(Y.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,n){return this[r*this.RANK+e]=j(n),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let i=0;i<this.RANK;++i)r[i]=this[n+i];return r}setColumn(e,r){let n=e*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=r[i];return this}};function oe(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Nt=class extends ut{get x(){return this[0]}set x(e){this[0]=j(e)}get y(){return this[1]}set y(e){this[1]=j(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-e[n];r+=i*i}return j(r)}dot(e){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*e[n];return j(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...e){for(let r of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return oe(e>=0&&e<this.ELEMENTS,"index is out of range"),j(this[e])}setComponent(e,r){return oe(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){for(let n=0;n<this.ELEMENTS;++n)this[n]+=e[n]*r;return this.check()}};var cn=typeof Float32Array<"u"?Float32Array:Array;var K2=Math.PI/180;function fa(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t}function da(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i+r[4],t[1]=r[1]*n+r[3]*i+r[5],t}function ln(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[3]*i+r[6],t[1]=r[1]*n+r[4]*i+r[7],t}function hn(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[4]*i+r[12],t[1]=r[1]*n+r[5]*i+r[13],t}function un(t,e,r){let n=e[0],i=e[1],o=r[3]*n+r[7]*i||1;return t[0]=(r[0]*n+r[4]*i)/o,t[1]=(r[1]*n+r[5]*i)/o,t}function fn(t,e,r){let n=e[0],i=e[1],o=e[2],s=r[3]*n+r[7]*i+r[11]*o||1;return t[0]=(r[0]*n+r[4]*i+r[8]*o)/s,t[1]=(r[1]*n+r[5]*i+r[9]*o)/s,t[2]=(r[2]*n+r[6]*i+r[10]*o)/s,t}function ma(t,e,r){let n=e[0],i=e[1];return t[0]=r[0]*n+r[2]*i,t[1]=r[1]*n+r[3]*i,t[2]=e[2],t}function pa(t,e,r){let n=e[0],i=e[1],o=e[2];return t[0]=r[0]*n+r[3]*i+r[6]*o,t[1]=r[1]*n+r[4]*i+r[7]*o,t[2]=r[2]*n+r[5]*i+r[8]*o,t[3]=e[3],t}var Oe=class extends Nt{constructor(e=0,r=0){super(2),$e(e)&&arguments.length===1?this.copy(e):(Y.debug&&(j(e),j(r)),this[0]=e,this[1]=r)}set(e,r){return this[0]=e,this[1]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Y.debug&&(j(e.x),j(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return hn(this,this,e),this.check()}transformAsVector(e){return un(this,this,e),this.check()}transformByMatrix3(e){return ln(this,this,e),this.check()}transformByMatrix2x3(e){return da(this,this,e),this.check()}transformByMatrix2(e){return fa(this,this,e),this.check()}};function ga(){let t=new cn(3);return cn!==Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Ji(t){let e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function eo(t,e,r){let n=new cn(3);return n[0]=t,n[1]=e,n[2]=r,n}function _a(t,e){let r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function sr(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Lt(t,e,r){let n=e[0],i=e[1],o=e[2],s=r[0],a=r[1],c=r[2];return t[0]=i*c-o*a,t[1]=o*s-n*c,t[2]=n*a-i*s,t}function dn(t,e,r){let n=e[0],i=e[1],o=e[2],s=r[3]*n+r[7]*i+r[11]*o+r[15];return s=s||1,t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/s,t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/s,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/s,t}function mn(t,e,r){let n=e[0],i=e[1],o=e[2];return t[0]=n*r[0]+i*r[3]+o*r[6],t[1]=n*r[1]+i*r[4]+o*r[7],t[2]=n*r[2]+i*r[5]+o*r[8],t}function Ma(t,e,r){let n=r[0],i=r[1],o=r[2],s=r[3],a=e[0],c=e[1],l=e[2],h=i*l-o*c,u=o*a-n*l,f=n*c-i*a,d=i*f-o*u,m=o*h-n*f,_=n*u-i*h,p=s*2;return h*=p,u*=p,f*=p,d*=2,m*=2,_*=2,t[0]=a+h+d,t[1]=c+u+m,t[2]=l+f+_,t}function ya(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0],o[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),o[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function xa(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),o[1]=i[1],o[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function Sa(t,e,r,n){let i=[],o=[];return i[0]=e[0]-r[0],i[1]=e[1]-r[1],i[2]=e[2]-r[2],o[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),o[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),o[2]=i[2],t[0]=o[0]+r[0],t[1]=o[1]+r[1],t[2]=o[2]+r[2],t}function wa(t,e){let r=t[0],n=t[1],i=t[2],o=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+n*n+i*i)*(o*o+s*s+a*a)),l=c&&sr(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}var Ea=Ji;var to=[0,0,0],pn,g=class t extends Nt{static get ZERO(){return pn||(pn=new t(0,0,0),Object.freeze(pn)),pn}constructor(e=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&$e(e)?this.copy(e):(Y.debug&&(j(e),j(r),j(n)),this[0]=e,this[1]=r,this[2]=n)}set(e,r,n){return this[0]=e,this[1]=r,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Y.debug&&(j(e.x),j(e.y),j(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=j(e)}angle(e){return wa(this,e)}cross(e){return Lt(this,this,e),this.check()}rotateX({radians:e,origin:r=to}){return ya(this,this,r,e),this.check()}rotateY({radians:e,origin:r=to}){return xa(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=to}){return Sa(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return dn(this,this,e),this.check()}transformAsVector(e){return fn(this,this,e),this.check()}transformByMatrix3(e){return mn(this,this,e),this.check()}transformByMatrix2(e){return ma(this,this,e),this.check()}transformByQuaternion(e){return Ma(this,this,e),this.check()}};function Ta(t,e){if(t===e){let r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function ba(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=h*s-a*l,f=-h*o+a*c,d=l*o-s*c,m=r*u+n*f+i*d;return m?(m=1/m,t[0]=u*m,t[1]=(-h*n+i*l)*m,t[2]=(a*n-i*s)*m,t[3]=f*m,t[4]=(h*r-i*c)*m,t[5]=(-a*r+i*o)*m,t[6]=d*m,t[7]=(-l*r+n*c)*m,t[8]=(s*r-n*o)*m,t):null}function va(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],l=t[8];return e*(l*o-s*c)+r*(-l*i+s*a)+n*(c*i-o*a)}function ro(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=r[0],d=r[1],m=r[2],_=r[3],p=r[4],M=r[5],y=r[6],S=r[7],x=r[8];return t[0]=f*n+d*s+m*l,t[1]=f*i+d*a+m*h,t[2]=f*o+d*c+m*u,t[3]=_*n+p*s+M*l,t[4]=_*i+p*a+M*h,t[5]=_*o+p*c+M*u,t[6]=y*n+S*s+x*l,t[7]=y*i+S*a+x*h,t[8]=y*o+S*c+x*u,t}function Pa(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=r[0],d=r[1];return t[0]=n,t[1]=i,t[2]=o,t[3]=s,t[4]=a,t[5]=c,t[6]=f*n+d*s+l,t[7]=f*i+d*a+h,t[8]=f*o+d*c+u,t}function Ra(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=Math.sin(r),d=Math.cos(r);return t[0]=d*n+f*s,t[1]=d*i+f*a,t[2]=d*o+f*c,t[3]=d*s-f*n,t[4]=d*a-f*i,t[5]=d*c-f*o,t[6]=l,t[7]=h,t[8]=u,t}function no(t,e,r){let n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function Ca(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r+r,a=n+n,c=i+i,l=r*s,h=n*s,u=n*a,f=i*s,d=i*a,m=i*c,_=o*s,p=o*a,M=o*c;return t[0]=1-u-m,t[3]=h-M,t[6]=f+p,t[1]=h+M,t[4]=1-l-m,t[7]=d-_,t[2]=f-p,t[5]=d+_,t[8]=1-l-u,t}var io;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(io||(io={}));var md=Object.freeze([1,0,0,0,1,0,0,0,1]),W=class extends Ot{static get IDENTITY(){return gd()}static get ZERO(){return pd()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return io}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(md)}fromObject(e){return this.check()}fromQuaternion(e){return Ca(this,e),this.check()}fromMatrix4(e){return this.set(e[0],e[1],e[2],e[4],e[5],e[6],e[8],e[9],e[10])}set(e,r,n,i,o,s,a,c,l){return this[0]=e,this[1]=r,this[2]=n,this[3]=i,this[4]=o,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,r,n,i,o,s,a,c,l){return this[0]=e,this[1]=i,this[2]=a,this[3]=r,this[4]=o,this[5]=c,this[6]=n,this[7]=s,this[8]=l,this.check()}determinant(){return va(this)}transpose(){return Ta(this,this),this.check()}invert(){return ba(this,this),this.check()}multiplyLeft(e){return ro(this,e,this),this.check()}multiplyRight(e){return ro(this,this,e),this.check()}rotate(e){return Ra(this,this,e),this.check()}scale(e){return Array.isArray(e)?no(this,this,e):no(this,this,[e,e]),this.check()}translate(e){return Pa(this,this,e),this.check()}transform(e,r){let n;switch(e.length){case 2:n=ln(r||[-0,-0],e,this);break;case 3:n=mn(r||[-0,-0,-0],e,this);break;case 4:n=pa(r||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return It(n,e.length),n}},gn,_n=null;function pd(){return gn||(gn=new W([0,0,0,0,0,0,0,0,0]),Object.freeze(gn)),gn}function gd(){return _n||(_n=new W,Object.freeze(_n)),_n}function _d(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Aa(t,e){if(t===e){let r=e[1],n=e[2],i=e[3],o=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=i,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ia(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],f=e[10],d=e[11],m=e[12],_=e[13],p=e[14],M=e[15],y=r*a-n*s,S=r*c-i*s,x=r*l-o*s,E=n*c-i*a,T=n*l-o*a,R=i*l-o*c,C=h*_-u*m,O=h*p-f*m,v=h*M-d*m,A=u*p-f*_,I=u*M-d*_,k=f*M-d*p,B=y*k-S*I+x*A+E*v-T*O+R*C;return B?(B=1/B,t[0]=(a*k-c*I+l*A)*B,t[1]=(i*I-n*k-o*A)*B,t[2]=(_*R-p*T+M*E)*B,t[3]=(f*T-u*R-d*E)*B,t[4]=(c*v-s*k-l*O)*B,t[5]=(r*k-i*v+o*O)*B,t[6]=(p*x-m*R-M*S)*B,t[7]=(h*R-f*x+d*S)*B,t[8]=(s*I-a*v+l*C)*B,t[9]=(n*v-r*I-o*C)*B,t[10]=(m*T-_*x+M*y)*B,t[11]=(u*x-h*T-d*y)*B,t[12]=(a*O-s*A-c*C)*B,t[13]=(r*A-n*O+i*C)*B,t[14]=(_*S-m*E-p*y)*B,t[15]=(h*E-u*S+f*y)*B,t):null}function Oa(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],s=t[5],a=t[6],c=t[7],l=t[8],h=t[9],u=t[10],f=t[11],d=t[12],m=t[13],_=t[14],p=t[15],M=e*s-r*o,y=e*a-n*o,S=r*a-n*s,x=l*m-h*d,E=l*_-u*d,T=h*_-u*m,R=e*T-r*E+n*x,C=o*T-s*E+a*x,O=l*S-h*y+u*M,v=d*S-m*y+_*M;return c*R-i*C+p*O-f*v}function oo(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=e[4],c=e[5],l=e[6],h=e[7],u=e[8],f=e[9],d=e[10],m=e[11],_=e[12],p=e[13],M=e[14],y=e[15],S=r[0],x=r[1],E=r[2],T=r[3];return t[0]=S*n+x*a+E*u+T*_,t[1]=S*i+x*c+E*f+T*p,t[2]=S*o+x*l+E*d+T*M,t[3]=S*s+x*h+E*m+T*y,S=r[4],x=r[5],E=r[6],T=r[7],t[4]=S*n+x*a+E*u+T*_,t[5]=S*i+x*c+E*f+T*p,t[6]=S*o+x*l+E*d+T*M,t[7]=S*s+x*h+E*m+T*y,S=r[8],x=r[9],E=r[10],T=r[11],t[8]=S*n+x*a+E*u+T*_,t[9]=S*i+x*c+E*f+T*p,t[10]=S*o+x*l+E*d+T*M,t[11]=S*s+x*h+E*m+T*y,S=r[12],x=r[13],E=r[14],T=r[15],t[12]=S*n+x*a+E*u+T*_,t[13]=S*i+x*c+E*f+T*p,t[14]=S*o+x*l+E*d+T*M,t[15]=S*s+x*h+E*m+T*y,t}function Na(t,e,r){let n=r[0],i=r[1],o=r[2],s,a,c,l,h,u,f,d,m,_,p,M;return e===t?(t[12]=e[0]*n+e[4]*i+e[8]*o+e[12],t[13]=e[1]*n+e[5]*i+e[9]*o+e[13],t[14]=e[2]*n+e[6]*i+e[10]*o+e[14],t[15]=e[3]*n+e[7]*i+e[11]*o+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],h=e[4],u=e[5],f=e[6],d=e[7],m=e[8],_=e[9],p=e[10],M=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=h,t[5]=u,t[6]=f,t[7]=d,t[8]=m,t[9]=_,t[10]=p,t[11]=M,t[12]=s*n+h*i+m*o+e[12],t[13]=a*n+u*i+_*o+e[13],t[14]=c*n+f*i+p*o+e[14],t[15]=l*n+d*i+M*o+e[15]),t}function La(t,e,r){let n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Ga(t,e,r,n){let i=n[0],o=n[1],s=n[2],a=Math.sqrt(i*i+o*o+s*s),c,l,h,u,f,d,m,_,p,M,y,S,x,E,T,R,C,O,v,A,I,k,B,$;return a<1e-6?null:(a=1/a,i*=a,o*=a,s*=a,l=Math.sin(r),c=Math.cos(r),h=1-c,u=e[0],f=e[1],d=e[2],m=e[3],_=e[4],p=e[5],M=e[6],y=e[7],S=e[8],x=e[9],E=e[10],T=e[11],R=i*i*h+c,C=o*i*h+s*l,O=s*i*h-o*l,v=i*o*h-s*l,A=o*o*h+c,I=s*o*h+i*l,k=i*s*h+o*l,B=o*s*h-i*l,$=s*s*h+c,t[0]=u*R+_*C+S*O,t[1]=f*R+p*C+x*O,t[2]=d*R+M*C+E*O,t[3]=m*R+y*C+T*O,t[4]=u*v+_*A+S*I,t[5]=f*v+p*A+x*I,t[6]=d*v+M*A+E*I,t[7]=m*v+y*A+T*I,t[8]=u*k+_*B+S*$,t[9]=f*k+p*B+x*$,t[10]=d*k+M*B+E*$,t[11]=m*k+y*B+T*$,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function qa(t,e,r){let n=Math.sin(r),i=Math.cos(r),o=e[4],s=e[5],a=e[6],c=e[7],l=e[8],h=e[9],u=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+l*n,t[5]=s*i+h*n,t[6]=a*i+u*n,t[7]=c*i+f*n,t[8]=l*i-o*n,t[9]=h*i-s*n,t[10]=u*i-a*n,t[11]=f*i-c*n,t}function za(t,e,r){let n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],c=e[3],l=e[8],h=e[9],u=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-l*n,t[1]=s*i-h*n,t[2]=a*i-u*n,t[3]=c*i-f*n,t[8]=o*n+l*i,t[9]=s*n+h*i,t[10]=a*n+u*i,t[11]=c*n+f*i,t}function Ba(t,e,r){let n=Math.sin(r),i=Math.cos(r),o=e[0],s=e[1],a=e[2],c=e[3],l=e[4],h=e[5],u=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+l*n,t[1]=s*i+h*n,t[2]=a*i+u*n,t[3]=c*i+f*n,t[4]=l*i-o*n,t[5]=h*i-s*n,t[6]=u*i-a*n,t[7]=f*i-c*n,t}function Da(t,e){let r=e[0],n=e[1],i=e[2],o=e[4],s=e[5],a=e[6],c=e[8],l=e[9],h=e[10];return t[0]=Math.sqrt(r*r+n*n+i*i),t[1]=Math.sqrt(o*o+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+h*h),t}function ka(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r+r,a=n+n,c=i+i,l=r*s,h=n*s,u=n*a,f=i*s,d=i*a,m=i*c,_=o*s,p=o*a,M=o*c;return t[0]=1-u-m,t[1]=h+M,t[2]=f-p,t[3]=0,t[4]=h-M,t[5]=1-l-m,t[6]=d+_,t[7]=0,t[8]=f+p,t[9]=d-_,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Fa(t,e,r,n,i,o,s){let a=1/(r-e),c=1/(i-n),l=1/(o-s);return t[0]=o*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(i+n)*c,t[10]=(s+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*o*2*l,t[15]=0,t}function Md(t,e,r,n,i){let o=1/Math.tan(e/2);if(t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0){let s=1/(n-i);t[10]=(i+n)*s,t[14]=2*i*n*s}else t[10]=-1,t[14]=-2*n;return t}var Ua=Md;function yd(t,e,r,n,i,o,s){let a=1/(e-r),c=1/(n-i),l=1/(o-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(i+n)*c,t[14]=(s+o)*l,t[15]=1,t}var Va=yd;function ja(t,e,r,n){let i,o,s,a,c,l,h,u,f,d,m=e[0],_=e[1],p=e[2],M=n[0],y=n[1],S=n[2],x=r[0],E=r[1],T=r[2];return Math.abs(m-x)<1e-6&&Math.abs(_-E)<1e-6&&Math.abs(p-T)<1e-6?_d(t):(u=m-x,f=_-E,d=p-T,i=1/Math.sqrt(u*u+f*f+d*d),u*=i,f*=i,d*=i,o=y*d-S*f,s=S*u-M*d,a=M*f-y*u,i=Math.sqrt(o*o+s*s+a*a),i?(i=1/i,o*=i,s*=i,a*=i):(o=0,s=0,a=0),c=f*a-d*s,l=d*o-u*a,h=u*s-f*o,i=Math.sqrt(c*c+l*l+h*h),i?(i=1/i,c*=i,l*=i,h*=i):(c=0,l=0,h=0),t[0]=o,t[1]=c,t[2]=u,t[3]=0,t[4]=s,t[5]=l,t[6]=f,t[7]=0,t[8]=a,t[9]=h,t[10]=d,t[11]=0,t[12]=-(o*m+s*_+a*p),t[13]=-(c*m+l*_+h*p),t[14]=-(u*m+f*_+d*p),t[15]=1,t)}function Wa(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Ha(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function $a(t){let e=t[0],r=t[1],n=t[2],i=t[3];return Math.sqrt(e*e+r*r+n*n+i*i)}function Ya(t){let e=t[0],r=t[1],n=t[2],i=t[3];return e*e+r*r+n*n+i*i}function Ka(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r*r+n*n+i*i+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=n*s,t[2]=i*s,t[3]=o*s,t}function Xa(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Za(t,e,r,n){let i=e[0],o=e[1],s=e[2],a=e[3];return t[0]=i+n*(r[0]-i),t[1]=o+n*(r[1]-o),t[2]=s+n*(r[2]-s),t[3]=a+n*(r[3]-a),t}function Qa(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*o+r[12]*s,t[1]=r[1]*n+r[5]*i+r[9]*o+r[13]*s,t[2]=r[2]*n+r[6]*i+r[10]*o+r[14]*s,t[3]=r[3]*n+r[7]*i+r[11]*o+r[15]*s,t}var co;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(co||(co={}));var Sd=45*Math.PI/180,wd=1,so=.1,ao=500,Ed=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),G=class extends Ot{static get IDENTITY(){return bd()}static get ZERO(){return Td()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return co}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,r,n,i,o,s,a,c,l,h,u,f,d,m,_,p){return this[0]=e,this[1]=r,this[2]=n,this[3]=i,this[4]=o,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this[9]=h,this[10]=u,this[11]=f,this[12]=d,this[13]=m,this[14]=_,this[15]=p,this.check()}setRowMajor(e,r,n,i,o,s,a,c,l,h,u,f,d,m,_,p){return this[0]=e,this[1]=o,this[2]=l,this[3]=d,this[4]=r,this[5]=s,this[6]=h,this[7]=m,this[8]=n,this[9]=a,this[10]=u,this[11]=_,this[12]=i,this[13]=c,this[14]=f,this[15]=p,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Ed)}fromObject(e){return this.check()}fromQuaternion(e){return ka(this,e),this.check()}fromMatrix3(e){return this.set(e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1)}frustum(e){let{left:r,right:n,bottom:i,top:o,near:s=so,far:a=ao}=e;return a===1/0?vd(this,r,n,i,o,s):Fa(this,r,n,i,o,s,a),this.check()}lookAt(e){let{eye:r,center:n=[0,0,0],up:i=[0,1,0]}=e;return ja(this,r,n,i),this.check()}ortho(e){let{left:r,right:n,bottom:i,top:o,near:s=so,far:a=ao}=e;return Va(this,r,n,i,o,s,a),this.check()}orthographic(e){let{fovy:r=Sd,aspect:n=wd,focalDistance:i=1,near:o=so,far:s=ao}=e;Ja(r);let a=r/2,c=i*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:o,far:s})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:n=1,near:i=.1,far:o=500}=e;return Ja(r),Ua(this,r,n,i,o),this.check()}determinant(){return Oa(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],o=1/n[1],s=1/n[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*i,e[5]=this[5]*o,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*i,e[9]=this[9]*o,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],o=1/n[1],s=1/n[2];return e[0]=this[0]*i,e[1]=this[1]*o,e[2]=this[2]*s,e[3]=this[4]*i,e[4]=this[5]*o,e[5]=this[6]*s,e[6]=this[8]*i,e[7]=this[9]*o,e[8]=this[10]*s,e}transpose(){return Aa(this,this),this.check()}invert(){return Ia(this,this),this.check()}multiplyLeft(e){return oo(this,e,this),this.check()}multiplyRight(e){return oo(this,this,e),this.check()}rotateX(e){return qa(this,this,e),this.check()}rotateY(e){return za(this,this,e),this.check()}rotateZ(e){return Ba(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return Ga(this,this,e,r),this.check()}scale(e){return La(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Na(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Qa(r||[-0,-0,-0,-0],e,this),It(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:n}=e,i;switch(n){case 2:i=hn(r||[-0,-0],e,this);break;case 3:i=dn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return It(i,e.length),i}transformAsVector(e,r){let n;switch(e.length){case 2:n=un(r||[-0,-0],e,this);break;case 3:n=fn(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return It(n,e.length),n}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,n){return this.identity().translate([e,r,n])}},Mn,yn;function Td(){return Mn||(Mn=new G([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Mn)),Mn}function bd(){return yn||(yn=new G,Object.freeze(yn)),yn}function Ja(t){if(t>Math.PI*2)throw Error("expected radians")}function vd(t,e,r,n,i,o){let s=2*o/(r-e),a=2*o/(i-n),c=(r+e)/(r-e),l=(i+n)/(i-n),h=-1,u=-1,f=-2*o;return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=h,t[11]=u,t[12]=0,t[13]=0,t[14]=f,t[15]=0,t}function ec(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function lo(t,e,r){r=r*.5;let n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function ho(t,e,r){let n=e[0],i=e[1],o=e[2],s=e[3],a=r[0],c=r[1],l=r[2],h=r[3];return t[0]=n*h+s*a+i*l-o*c,t[1]=i*h+s*c+o*a-n*l,t[2]=o*h+s*l+n*c-i*a,t[3]=s*h-n*a-i*c-o*l,t}function tc(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+s*a,t[1]=i*c+o*a,t[2]=o*c-i*a,t[3]=s*c-n*a,t}function rc(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c-o*a,t[1]=i*c+s*a,t[2]=o*c+n*a,t[3]=s*c-i*a,t}function nc(t,e,r){r*=.5;let n=e[0],i=e[1],o=e[2],s=e[3],a=Math.sin(r),c=Math.cos(r);return t[0]=n*c+i*a,t[1]=i*c-n*a,t[2]=o*c+s*a,t[3]=s*c-o*a,t}function ic(t,e){let r=e[0],n=e[1],i=e[2];return t[0]=r,t[1]=n,t[2]=i,t[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i)),t}function oc(t,e,r,n){let i=e[0],o=e[1],s=e[2],a=e[3],c=r[0],l=r[1],h=r[2],u=r[3],f,d,m,_,p;return f=i*c+o*l+s*h+a*u,f<0&&(f=-f,c=-c,l=-l,h=-h,u=-u),1-f>1e-6?(d=Math.acos(f),p=Math.sin(d),m=Math.sin((1-n)*d)/p,_=Math.sin(n*d)/p):(m=1-n,_=n),t[0]=m*i+_*c,t[1]=m*o+_*l,t[2]=m*s+_*h,t[3]=m*a+_*u,t}function sc(t,e){let r=e[0],n=e[1],i=e[2],o=e[3],s=r*r+n*n+i*i+o*o,a=s?1/s:0;return t[0]=-r*a,t[1]=-n*a,t[2]=-i*a,t[3]=o*a,t}function ac(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function cc(t,e){let r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let i=0;e[4]>e[0]&&(i=1),e[8]>e[i*3+i]&&(i=2);let o=(i+1)%3,s=(i+2)%3;n=Math.sqrt(e[i*3+i]-e[o*3+o]-e[s*3+s]+1),t[i]=.5*n,n=.5/n,t[3]=(e[o*3+s]-e[s*3+o])*n,t[o]=(e[o*3+i]+e[i*3+o])*n,t[s]=(e[s*3+i]+e[i*3+s])*n}return t}var lc=Wa;var hc=Ha,uc=Xa,fc=Za,dc=$a;var mc=Ya;var Pd=Ka;var pc=(function(){let t=ga(),e=eo(1,0,0),r=eo(0,1,0);return function(n,i,o){let s=sr(i,o);return s<-.999999?(Lt(t,e,i),Ea(t)<1e-6&&Lt(t,r,i),_a(t,t),lo(n,t,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Lt(t,i,o),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+s,Pd(n,n))}})();var Ne=class extends ut{constructor(e=0,r=0,n=0,i=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,r,n,i)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,r,n,i){return this[0]=e,this[1]=r,this[2]=n,this[3]=i,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return cc(this,e),this.check()}fromEuler(e){switch(this.identity(),e.order){case"xyz":return this.rotateX(e.x).rotateY(e.y).rotateZ(e.z);case"yxz":return this.rotateY(e.y).rotateX(e.x).rotateZ(e.z);case"zxy":return this.rotateZ(e.z).rotateX(e.x).rotateY(e.y);case"zyx":return this.rotateZ(e.z).rotateY(e.y).rotateX(e.x);case"yzx":return this.rotateY(e.y).rotateZ(e.z).rotateX(e.x);case"xzy":return this.rotateX(e.x).rotateZ(e.z).rotateY(e.y);default:throw new Error("Unknown Euler angle order")}}fromAxisRotation(e,r){return lo(this,e,r),this.check()}identity(){return ec(this),this.check()}setAxisAngle(e,r){return this.fromAxisRotation(e,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=j(e)}get y(){return this[1]}set y(e){this[1]=j(e)}get z(){return this[2]}set z(e){this[2]=j(e)}get w(){return this[3]}set w(e){this[3]=j(e)}len(){return dc(this)}lengthSquared(){return mc(this)}dot(e){return uc(this,e)}rotationTo(e,r){return pc(this,e,r),this.check()}add(e){return lc(this,this,e),this.check()}calculateW(){return ic(this,this),this.check()}conjugate(){return ac(this,this),this.check()}invert(){return sc(this,this),this.check()}lerp(e,r,n){return n===void 0?this.lerp(this,e,r):(fc(this,e,r,n),this.check())}multiplyRight(e){return ho(this,this,e),this.check()}multiplyLeft(e){return ho(this,e,this),this.check()}normalize(){let e=this.len(),r=e>0?1/e:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,e===0&&(this[3]=1),this.check()}rotateX(e){return tc(this,this,e),this.check()}rotateY(e){return rc(this,this,e),this.check()}rotateZ(e){return nc(this,this,e),this.check()}scale(e){return hc(this,this,e),this.check()}slerp(e,r,n){let i,o,s;return arguments.length===2?(i=this,o=e,s=r):(i=e,o=r,s=n),oc(this,i,o,s),this.check()}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,r){return this.setAxisAngle(e,r)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}};var it=6356752314245179e-9,Rd={radii:[6378137,6378137,it],radiiSquared:[6378137*6378137,6378137*6378137,it*it],oneOverRadii:[1/6378137,1/6378137,1/it],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(it*it)],maximumRadius:Math.max(6378137,6378137,it),centerToleranceSquared:.1};function xn(t){return t}var tM=new g;function Cd(t,e=[],r=xn){return"longitude"in t?(e[0]=r(t.longitude),e[1]=r(t.latitude),e[2]=t.height):"x"in t?(e[0]=r(t.x),e[1]=r(t.y),e[2]=t.z):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function gc(t,e=[]){return Cd(t,e,Y._cartographicRadians?xn:Ki)}function Ad(t,e,r=xn){return"longitude"in e?(e.longitude=r(t[0]),e.latitude=r(t[1]),e.height=t[2]):"x"in e?(e.x=r(t[0]),e.y=r(t[1]),e.z=t[2]):(e[0]=r(t[0]),e[1]=r(t[1]),e[2]=t[2]),e}function _c(t,e){return Ad(t,e,Y._cartographicRadians?xn:Xi)}var Mc=1e-14,Id=new g,yc={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"}},uo={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},ar={east:new g,north:new g,up:new g,west:new g,south:new g,down:new g},Od=new g,Nd=new g,Ld=new g;function fo(t,e,r,n,i,o){let s=yc[e]&&yc[e][r];oe(s&&(!n||n===s));let a,c,l,h=Id.copy(i);if(Te(h.x,0,Mc)&&Te(h.y,0,Mc)){let f=Math.sign(h.z);a=Od.fromArray(uo[e]),e!=="east"&&e!=="west"&&a.scale(f),c=Nd.fromArray(uo[r]),r!=="east"&&r!=="west"&&c.scale(f),l=Ld.fromArray(uo[n]),n!=="east"&&n!=="west"&&l.scale(f)}else{let{up:f,east:d,north:m}=ar;d.set(-h.y,h.x,0).normalize(),t.geodeticSurfaceNormal(h,f),m.copy(f).cross(d);let{down:_,west:p,south:M}=ar;_.copy(f).scale(-1),p.copy(d).scale(-1),M.copy(m).scale(-1),a=ar[e],c=ar[r],l=ar[n]}return o[0]=a.x,o[1]=a.y,o[2]=a.z,o[3]=0,o[4]=c.x,o[5]=c.y,o[6]=c.z,o[7]=0,o[8]=l.x,o[9]=l.y,o[10]=l.z,o[11]=0,o[12]=h.x,o[13]=h.y,o[14]=h.z,o[15]=1,o}var Gt=new g,Gd=new g,qd=new g;function xc(t,e,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:i,centerToleranceSquared:o}=e;Gt.from(t);let s=Gt.x,a=Gt.y,c=Gt.z,l=n.x,h=n.y,u=n.z,f=s*s*l*l,d=a*a*h*h,m=c*c*u*u,_=f+d+m,p=Math.sqrt(1/_);if(!Number.isFinite(p))return;let M=Gd;if(M.copy(t).scale(p),_<o)return M.to(r);let y=i.x,S=i.y,x=i.z,E=qd;E.set(M.x*y*2,M.y*S*2,M.z*x*2);let T=(1-p)*Gt.len()/(.5*E.len()),R=0,C,O,v,A;do{T-=R,C=1/(1+T*y),O=1/(1+T*S),v=1/(1+T*x);let I=C*C,k=O*O,B=v*v,$=I*C,nt=k*O,ki=B*v;A=f*I+d*k+m*B-1;let Fi=-2*(f*$*y+d*nt*S+m*ki*x);R=A/Fi}while(Math.abs(A)>V.EPSILON12);return Gt.scale([C,O,v]).to(r)}var Sn=new g,Sc=new g,Dd=new g,De=new g,kd=new g,wn=new g,N=class{constructor(e=0,r=0,n=0){this.centerToleranceSquared=V.EPSILON1,oe(e>=0),oe(r>=0),oe(n>=0),this.radii=new g(e,r,n),this.radiiSquared=new g(e*e,r*r,n*n),this.radiiToTheFourth=new g(e*e*e*e,r*r*r*r,n*n*n*n),this.oneOverRadii=new g(e===0?0:1/e,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new g(e===0?0:1/(e*e),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(e,r,n),this.maximumRadius=Math.max(e,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||!!(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,r=[0,0,0]){let n=Sc,i=Dd,[,,o]=e;this.geodeticSurfaceNormalCartographic(e,n),i.copy(this.radiiSquared).scale(n);let s=Math.sqrt(n.dot(i));return i.scale(1/s),n.scale(o),i.add(n),i.to(r)}cartesianToCartographic(e,r=[0,0,0]){wn.from(e);let n=this.scaleToGeodeticSurface(wn,De);if(!n)return;let i=this.geodeticSurfaceNormal(n,Sc),o=kd;o.copy(wn).subtract(n);let s=Math.atan2(i.y,i.x),a=Math.asin(i.z),c=Math.sign(sr(o,wn))*Ji(o);return _c([s,a,c],r)}eastNorthUpToFixedFrame(e,r=new G){return fo(this,"east","north","up",e,r)}localFrameToFixedFrame(e,r,n,i,o=new G){return fo(this,e,r,n,i,o)}geocentricSurfaceNormal(e,r=[0,0,0]){return Sn.from(e).normalize().to(r)}geodeticSurfaceNormalCartographic(e,r=[0,0,0]){let n=gc(e),i=n[0],o=n[1],s=Math.cos(o);return Sn.set(s*Math.cos(i),s*Math.sin(i),Math.sin(o)).normalize(),Sn.to(r)}geodeticSurfaceNormal(e,r=[0,0,0]){return Sn.from(e).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(e,r){return xc(e,this,r)}scaleToGeocentricSurface(e,r=[0,0,0]){De.from(e);let n=De.x,i=De.y,o=De.z,s=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*s.x+i*i*s.y+o*o*s.z);return De.multiplyByScalar(a).to(r)}transformPositionToScaledSpace(e,r=[0,0,0]){return De.from(e).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(e,r=[0,0,0]){return De.from(e).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(e,r=0,n=[0,0,0]){oe(Te(this.radii.x,this.radii.y,V.EPSILON15)),oe(this.radii.z>0),De.from(e);let i=De.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(i)>=this.radii.z-r))return De.set(0,0,i).to(n)}};N.WGS84=new N(6378137,6378137,it);var mo;(function(t){t.OUTSIDE="outside",t.INTERSECTING="intersecting",t.INSIDE="inside"})(mo||(mo={}));var gM=new g,_M=new g;var cr=new g,wc=new g,fe=class t{constructor(e=[0,0,0],r=0){this.radius=-0,this.center=new g,this.fromCenterRadius(e,r)}fromCenterRadius(e,r){return this.center.from(e),this.radius=r,this}fromCornerPoints(e,r){return r=cr.from(r),this.center=new g().from(e).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(e){return this===e||!!e&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new t(this.center,this.radius)}union(e){let r=this.center,n=this.radius,i=e.center,o=e.radius,s=cr.copy(i).subtract(r),a=s.magnitude();if(n>=a+o)return this.clone();if(o>=a+n)return e.clone();let c=(n+a+o)*.5;return wc.copy(s).scale((-n+c)/a).add(r),this.center.copy(wc),this.radius=c,this}expand(e){let n=cr.from(e).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(e){this.center.transform(e);let r=Da(cr,e);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(e){let r=this.distanceTo(e);return r*r}distanceTo(e){let n=cr.from(e).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(e){let r=this.center,n=this.radius,o=e.normal.dot(r)+e.distance;return o<-n?"outside":o<n?"intersecting":"inside"}};var Fd=new g,Ud=new g,En=new g,Tn=new g,bn=new g,Vd=new g,jd=new g,ot={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Ye=class t{constructor(e=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new g().from(e),this.halfAxes=new W(r)}get halfSize(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new g(e).len(),new g(r).len(),new g(n).len()]}get quaternion(){let e=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),i=new g(e).normalize(),o=new g(r).normalize(),s=new g(n).normalize();return new Ne().fromMatrix3(new W([...i,...o,...s]))}fromCenterHalfSizeQuaternion(e,r,n){let i=new Ne(n),o=new W().fromQuaternion(i);return o[0]=o[0]*r[0],o[1]=o[1]*r[0],o[2]=o[2]*r[0],o[3]=o[3]*r[1],o[4]=o[4]*r[1],o[5]=o[5]*r[1],o[6]=o[6]*r[2],o[7]=o[7]*r[2],o[8]=o[8]*r[2],this.center=new g().from(e),this.halfAxes=o,this}clone(){return new t(this.center,this.halfAxes)}equals(e){return this===e||!!e&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new fe){let r=this.halfAxes,n=r.getColumn(0,En),i=r.getColumn(1,Tn),o=r.getColumn(2,bn),s=Fd.copy(n).add(i).add(o);return e.center.copy(this.center),e.radius=s.magnitude(),e}intersectPlane(e){let r=this.center,n=e.normal,i=this.halfAxes,o=n.x,s=n.y,a=n.z,c=Math.abs(o*i[ot.COLUMN0ROW0]+s*i[ot.COLUMN0ROW1]+a*i[ot.COLUMN0ROW2])+Math.abs(o*i[ot.COLUMN1ROW0]+s*i[ot.COLUMN1ROW1]+a*i[ot.COLUMN1ROW2])+Math.abs(o*i[ot.COLUMN2ROW0]+s*i[ot.COLUMN2ROW1]+a*i[ot.COLUMN2ROW2]),l=n.dot(r)+e.distance;return l<=-c?"outside":l>=c?"inside":"intersecting"}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){let r=Ud.from(e).subtract(this.center),n=this.halfAxes,i=n.getColumn(0,En),o=n.getColumn(1,Tn),s=n.getColumn(2,bn),a=i.magnitude(),c=o.magnitude(),l=s.magnitude();i.normalize(),o.normalize(),s.normalize();let h=0,u;return u=Math.abs(r.dot(i))-a,u>0&&(h+=u*u),u=Math.abs(r.dot(o))-c,u>0&&(h+=u*u),u=Math.abs(r.dot(s))-l,u>0&&(h+=u*u),h}computePlaneDistances(e,r,n=[-0,-0]){let i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=this.center,a=this.halfAxes,c=a.getColumn(0,En),l=a.getColumn(1,Tn),h=a.getColumn(2,bn),u=Vd.copy(c).add(l).add(h).add(s),f=jd.copy(u).subtract(e),d=r.dot(f);return i=Math.min(d,i),o=Math.max(d,o),u.copy(s).add(c).add(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),u.copy(s).add(c).subtract(l).add(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),u.copy(s).add(c).subtract(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).add(l).add(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).add(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).subtract(l).add(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),s.copy(u).subtract(c).subtract(l).subtract(h),f.copy(u).subtract(e),d=r.dot(f),i=Math.min(d,i),o=Math.max(d,o),n[0]=i,n[1]=o,n}transform(e){this.center.transformAsPoint(e);let r=this.halfAxes.getColumn(0,En);r.transformAsPoint(e);let n=this.halfAxes.getColumn(1,Tn);n.transformAsPoint(e);let i=this.halfAxes.getColumn(2,bn);return i.transformAsPoint(e),this.halfAxes=new W([...r,...n,...i]),this}getTransform(){throw new Error("not implemented")}};var Ec=new g,Tc=new g,re=class t{constructor(e=[0,0,1],r=0){this.normal=new g,this.distance=-0,this.fromNormalDistance(e,r)}fromNormalDistance(e,r){return oe(Number.isFinite(r)),this.normal.from(e).normalize(),this.distance=r,this}fromPointNormal(e,r){e=Ec.from(e),this.normal.from(r).normalize();let n=-this.normal.dot(e);return this.distance=n,this}fromCoefficients(e,r,n,i){return this.normal.set(e,r,n),oe(Te(this.normal.len(),1)),this.distance=i,this}clone(){return new t(this.normal,this.distance)}equals(e){return Te(this.distance,e.distance)&&Te(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){let r=Tc.copy(this.normal).transformAsVector(e).normalize(),n=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(n,r)}projectPointOntoPlane(e,r=[0,0,0]){let n=Ec.from(e),i=this.getPointDistance(n),o=Tc.copy(this.normal).scale(i);return n.subtract(o).to(r)}intersectWithRay(e,r=new g){let n=e.origin,i=e.direction,o=this.normal,s=o.dot(i);if(Math.abs(s)<V.EPSILON15)return;let a=(-this.distance-o.dot(n))/s;if(!(a<0))return r.copy(i).multiplyByScalar(a).add(n)}};var bc=[new g([1,0,0]),new g([0,1,0]),new g([0,0,1])],vc=new g,Wd=new g,se=class t{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*bc.length;let r=e.center,n=e.radius,i=0;for(let o of bc){let s=this.planes[i],a=this.planes[i+1];s||(s=this.planes[i]=new re),a||(a=this.planes[i+1]=new re);let c=vc.copy(o).scale(-n).add(r);s.fromPointNormal(c,o);let l=vc.copy(o).scale(n).add(r),h=Wd.copy(o).negate();a.fromPointNormal(l,h),i+=2}return this}computeVisibility(e){let r="inside";for(let n of this.planes)switch(e.intersectPlane(n)){case"outside":return"outside";case"intersecting":r="intersecting";break;default:}return r}computeVisibilityWithPlaneMask(e,r){if(oe(Number.isFinite(r),"parentPlaneMask is required."),r===t.MASK_OUTSIDE||r===t.MASK_INSIDE)return r;let n=t.MASK_INSIDE,i=this.planes;for(let o=0;o<this.planes.length;++o){let s=o<31?1<<o:0;if(o<31&&(r&s)===0)continue;let a=i[o],c=e.intersectPlane(a);if(c==="outside")return t.MASK_OUTSIDE;c==="intersecting"&&(n|=s)}return n}};se.MASK_OUTSIDE=4294967295;se.MASK_INSIDE=0;se.MASK_INDETERMINATE=2147483647;var YM=new g,KM=new g,XM=new g,ZM=new g,QM=new g;var iy=new g,oy=new g,sy=new g,ay=new g,cy=new g,ly=new g,hy=new g,uy=new g,fy=new g,dy=new g,my=new g,py=new g;var My=new W,yy=new W,xy=new W,Sy=new W,wy=new W;var Ry=new g,Cy=new g,Ay=new g,Iy=new g,Oy=new g,Ny=new W,Ly={diagonal:new W,unitary:new W};var Kd=new g,po=new g,Xd=new G,Zd=new g,lr=class{constructor(e,r=N.WGS84){let n=r.scaleToGeodeticSurface(e,Kd),i=r.eastNorthUpToFixedFrame(n,Xd);this._origin=new g(n),this._xAxis=new g(po.from(i.getColumn(0))),this._yAxis=new g(po.from(i.getColumn(1)));let o=new g(po.from(i.getColumn(2)));this._plane=new re().fromPointNormal(this._origin,o)}projectPointToNearestOnPlane(e,r){r||(r=new Oe);let i=this._plane.projectPointOntoPlane(e,Zd).subtract(this._origin),o=this._xAxis.dot(i),s=this._yAxis.dot(i);return r.x=o,r.y=s,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 qt=class{constructor(e,r,n,i){this.west=e,this.south=r,this.east=n,this.north=i}static center(e,r){r||(r=new g);let n=e.east,i=e.west;n<i&&(n+=V.TWO_PI);let o=Zi((i+n)*.5,"negative-pi-to-pi"),s=(e.south+e.north)*.5;return r.x=o,r.y=s,r.z=0,r}get width(){let e=this.east,r=this.west;return e<r&&(e+=V.TWO_PI),e-r}};var Qd=new g,Jd=new g,em=new g,tm=new g,rm=new g,nm=new g,im=new g,om=new g,Cc=new g,sm=new g,Ac=new g,am=new g,cm=new Oe,lm=new Oe,hm=new Oe,um=new Oe,fm=new Oe,dm=new re,mm=new g,pm=new g,gm=new g,_m=new g,Mm=new Oe,ym=new g,xm=new g,Sm=new g(1,0,0),wm=new g(0,0,1);function hr(t,e=N.WGS84,r={}){if(!t||t.length!==6||t.some(y=>!Number.isFinite(y)))throw new Error("makeOBBFromRegion: region must contain exactly six finite numbers");let n=r.units==="degrees"?an(1):1,[i,o,s,a,c,l]=t;if(c>l)throw new Error("makeOBBFromRegion: minimumHeight must not exceed maximumHeight");let h=o*n,u=a*n,f=Ic(i*n),d=Ic(s*n);s*n-i*n>=V.TWO_PI-1e-12&&(d=f+V.TWO_PI);let _=1e-12;if(h>u||h<-V.PI_OVER_TWO-_||u>V.PI_OVER_TWO+_)throw new Error("makeOBBFromRegion: latitude must be within [-\u03C0/2, \u03C0/2] and south \u2264 north");let p=Math.max(-V.PI_OVER_TWO,Math.min(V.PI_OVER_TWO,h)),M=Math.max(-V.PI_OVER_TWO,Math.min(V.PI_OVER_TWO,u));return Em([f,p,d,M,c,l],e,r.transform)}function Ic(t){let e=((t+Math.PI)%V.TWO_PI+V.TWO_PI)%V.TWO_PI-Math.PI;return e===-Math.PI&&t>0?Math.PI:e}function Em(t,e,r){let n=new Ye,[i,o,s,a,c,l]=t,h=ge(a),u=ge(o),f,d,m,_,p,M,y,S=new qt(i,o,s,a),x=qt.center(S,Jd),E=new g([ge(x.x),ge(x.y),0]),T=x.x,R=E.x;if(S.width<=V.PI){let Ui=ge(i),Mf=e.cartographicToCartesian(E),He=new lr(Mf,e),yf=u<0&&h>0?0:E.y,xf=em.copy([R,h,l]),Vi=tm.copy([Ui,h,l]),Sf=rm.copy([Ui,yf,l]),ji=nm.copy([Ui,u,l]),wf=im.copy([R,u,l]),Ef=e.cartographicToCartesian(xf,om),Wi=e.cartographicToCartesian(Vi,Cc),Tf=e.cartographicToCartesian(Sf,sm),Hi=e.cartographicToCartesian(ji,Ac),bf=e.cartographicToCartesian(wf,am),vf=He.projectPointToNearestOnPlane(Ef,cm),sa=He.projectPointToNearestOnPlane(Wi,lm),Pf=He.projectPointToNearestOnPlane(Tf,hm),aa=He.projectPointToNearestOnPlane(Hi,um),Rf=He.projectPointToNearestOnPlane(bf,fm);return _=Math.min(sa.x,Pf.x,aa.x),f=-_,d=Math.max(sa.y,vf.y),p=Math.min(aa.y,Rf.y),Vi.z=ji.z=c,Wi=e.cartographicToCartesian(Vi,Cc),Hi=e.cartographicToCartesian(ji,Ac),y=He.plane,M=Math.min(y.getPointDistance(Wi),y.getPointDistance(Hi)),m=l,Oc(Lc(He.origin,He.xAxis,He.yAxis,He.zAxis,_,f,p,d,M,m,n),r)}let C=ge(s),O=o>0,v=a<0,A=O?u:v?h:0,I=e.cartographicToCartesian([R,A,l],mm);I.z=0;let B=Math.abs(I.x)<V.EPSILON10&&Math.abs(I.y)<V.EPSILON10?Sm:pm.copy(I).normalize(),$=wm,nt=gm.copy(B).cross($);y=dm.fromPointNormal(I,B);let ki=e.cartographicToCartesian([ge(T+V.PI_OVER_TWO),A,l],_m);f=y.projectPointOntoPlane(ki,Mm).dot(nt),_=-f;let Fi=v?c:l,gf=O?c:l;d=Nc(e,h,Fi,!0),p=Nc(e,u,gf,!1);let _f=e.cartographicToCartesian([C,A,l],xm);return M=y.getPointDistance(_f),m=0,Oc(Lc(I,nt,$,B,_,f,p,d,M,m,n),r)}function Oc(t,e){if(!e)return t;let r=[0,1,2].map(a=>t.halfAxes.getColumn(a,new g)),n=e.transformAsPoint(t.center),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];for(let a=0;a<8;a++){let c=new g(n);for(let l=0;l<3;l++){let h=e.transformAsVector(r[l]);c.add(new g(h).scale((a&1<<l)===0?-1:1))}for(let l=0;l<3;l++)i[l]=Math.min(i[l],c[l]),o[l]=Math.max(o[l],c[l])}t.center.copy(i).add(o).scale(.5);let s=new g(o).subtract(i).scale(.5);return t.halfAxes=new W().set(s.x,0,0,0,s.y,0,0,0,s.z),t}function Nc(t,e,r,n){let i=n?-1/0:1/0;for(let o of[0,90,180,270]){let s=t.cartographicToCartesian([o,e,r],ym).z;i=n?Math.max(i,s):Math.min(i,s)}return i}function Lc(t,e,r,n,i,o,s,a,c,l,h){let u=h.center,f=h.halfAxes;f.setColumn(0,e),f.setColumn(1,r),f.setColumn(2,n);let d=Qd.set((i+o)/2,(s+a)/2,(c+l)/2).transformByMatrix3(f),m=(o-i)/2,_=(a-s)/2,p=(l-c)/2;return f[0]*=m,f[1]*=m,f[2]*=m,f[3]*=_,f[4]*=_,f[5]*=_,f[6]*=p,f[7]*=p,f[8]*=p,u.copy(t).add(d),h}function ur(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var xt=class{constructor(e,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=e,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(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=ur(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(ur()-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 Le=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:n}=e,i=this.stats[r];return i||(e instanceof xt?i=e:i=new xt(r,n),this.stats[r]=i),i}};function ke(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function Pn(t,e,r){let n=r!==void 0?new Uint8Array(t).subarray(e,e+r):new Uint8Array(t).subarray(e);return new Uint8Array(n).buffer}var Tm="Queued Requests",bm="Active Requests",vm="Cancelled Requests",Pm="Queued Requests Ever",Rm="Active Requests Ever",Cm={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},st=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...Cm,...e},this.stats=new Le({id:this.props.id}),this.stats.get(Tm),this.stats.get(bm),this.stats.get(vm),this.stats.get(Pm),this.stats.get(Rm)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);let n={handle:e,priority:0,getPriority:r},i=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(e,i),this._issueNewRequests(),i}_issueRequest(e){let{handle:r,resolve:n}=e,i=!1,o=()=>{i||(i=!0,this.requestMap.delete(r),this.activeRequestCount--,this.scheduleRefill())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}scheduleRefill(){this.updateTimer===null&&(this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),0))}_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 e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let r=0;r<e;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let e=this.requestQueue;for(let r=0;r<e.length;++r){let n=e[r];this._updateRequest(n)||(e.splice(r,1),this.requestMap.delete(n.handle),r--)}e.sort((r,n)=>r.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}};var Am=Number.POSITIVE_INFINITY,Im=Number.POSITIVE_INFINITY,fr=class{maxEntries;maxBytes;getByteLength;onRemove;entries=new Map;retainedByteLength=0;constructor(e={}){this.maxEntries=Gc(e.maxEntries,Am,"maxEntries"),this.maxBytes=Gc(e.maxBytes,Im,"maxBytes"),this.getByteLength=e.getByteLength||(()=>0),this.onRemove=e.onRemove}get size(){return this.entries.size}get pendingSize(){let e=0;for(let r of this.entries.values())e+=r.pending?1:0;return e}get byteLength(){return this.retainedByteLength}get(e,r){let n=this.entries.get(e);if(n)return this.touch(e,n),this.waitForEntry(e,n,r)}has(e){return this.entries.has(e)}set(e,r){this.removeEntry(e,"replace");let n=qc(this.getByteLength(r)),i={promise:Promise.resolve(r),pending:!1,waiterCount:0,byteLength:n};return this.entries.set(e,i),this.retainedByteLength+=n,this.trim(),r}getOrLoad(e,r,n){let i=this.get(e,n);if(i)return i;if(n?.aborted)return Promise.reject(go());let o=new AbortController,s,a,l={promise:new Promise((h,u)=>{s=h,a=u}),controller:o,pending:!0,waiterCount:0,byteLength:0};this.entries.set(e,l),l.promise.then(h=>this.handleLoadedValue(e,l,h),()=>this.handleLoadError(e,l));try{Promise.resolve(r(o.signal)).then(s,a)}catch(h){a(h)}return this.waitForEntry(e,l,n)}delete(e){return this.removeEntry(e,"delete")}clear(){for(let e of Array.from(this.entries.keys()))this.removeEntry(e,"clear")}handleLoadedValue(e,r,n){if(this.entries.get(e)===r){r.pending=!1,r.controller=void 0;try{r.byteLength=qc(this.getByteLength(n))}catch{this.removeEntry(e,"error");return}this.retainedByteLength+=r.byteLength,this.trim()}}handleLoadError(e,r){this.entries.get(e)===r&&this.removeEntry(e,r.controller?.signal.aborted?"abort":"error")}waitForEntry(e,r,n){return n?.aborted?Promise.reject(go()):r.pending?(r.waiterCount++,new Promise((i,o)=>{let s=!0,a=()=>{s&&(s=!1,n?.removeEventListener("abort",c),r.waiterCount--)},c=()=>{s&&(a(),o(go()),r.pending&&r.waiterCount===0&&this.entries.get(e)===r&&this.removeEntry(e,"abort"))};n?.addEventListener("abort",c,{once:!0}),r.promise.then(l=>{s&&(a(),i(l))},l=>{s&&(a(),o(l))})})):r.promise}touch(e,r){this.entries.delete(e),this.entries.set(e,r)}trim(){let e=this.entries.size-this.pendingSize;if(!(e<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)){for(let[r,n]of this.entries)if(n.pending||(this.removeEntry(r,"evict"),e--),e<=this.maxEntries&&this.retainedByteLength<=this.maxBytes)break}}removeEntry(e,r){let n=this.entries.get(e);return n?(this.entries.delete(e),this.retainedByteLength-=n.byteLength,n.pending&&n.controller?.abort(),this.onRemove?.(e,r),!0):!1}};function go(){let t=new Error("Request aborted");return t.name="AbortError",t}function Gc(t,e,r){let n=t??e;if(n<0||Number.isNaN(n))throw new Error(`${r} must be a non-negative number`);return n}function qc(t){if(!Number.isFinite(t)||t<0)throw new Error("Request cache entry byte length must be a non-negative finite number");return t}var H={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"},_o={batchDelayMs:50,maxGapBytes:65536,rangeExpansionBytes:65536,maxMergedBytes:8388608,stats:Dc("range-request-scheduler-default"),onEvent:()=>{}},Rn=class{props;stats;onEvent;pendingRequests=[];flushTimer=null;constructor(e={}){let r=e.rangeExpansionBytes??e.maxGapBytes??_o.rangeExpansionBytes;this.props={batchDelayMs:e.batchDelayMs??_o.batchDelayMs,maxGapBytes:e.maxGapBytes??r,rangeExpansionBytes:r,maxMergedBytes:e.maxMergedBytes??_o.maxMergedBytes},this.stats=e.stats||Dc("range-request-scheduler"),this.onEvent=e.onEvent,kc(this.stats)}scheduleRequest(e){if(e.length<0)return Promise.reject(new Error("Byte range length cannot be negative"));if(e.signal?.aborted)return Promise.reject(Bc());if(e.length===0)return Promise.resolve(new ArrayBuffer(0));let r=new Promise((n,i)=>{let o={...e,resolve:n,reject:i,settled:!1};e.signal&&(o.abortListener=()=>{this.abortRequest(o),o.onAbort?.()},e.signal.addEventListener("abort",o.abortListener,{once:!0})),this.pendingRequests.push(o)});return this.trackEvent({type:"queued",sourceId:e.sourceId,offset:e.offset,length:e.length,logicalRequestCount:1,logicalBytes:e.length}),this.scheduleFlush(),r}fetch(e){let r=e.fetch||globalThis.fetch;return this.scheduleRequest({sourceId:e.sourceId||e.url,offset:e.offset,length:e.length,signal:e.signal,isolationKey:e.isolationKey??{},fetchRange:(n,i,o)=>Nm({url:e.url,offset:n,length:i,signal:o,fetch:r,fetchOptions:e.fetchOptions})})}flush(){this.flushTimer!==null&&(clearTimeout(this.flushTimer),this.flushTimer=null);let e=this.pendingRequests;this.pendingRequests=[];let r=e.filter(i=>i.settled||i.signal?.aborted?(this.abortRequest(i),!1):!0),n=this.mergeRequests(r);r.length>0&&this.trackBatch(r,n);for(let i of n)this.fetchMergedRequest(i)}scheduleFlush(){this.flushTimer===null&&(this.flushTimer=setTimeout(()=>this.flush(),this.props.batchDelayMs))}mergeRequests(e){e.sort((n,i)=>n.sourceId!==i.sourceId?n.sourceId<i.sourceId?-1:1:n.offset-i.offset);let r=[];for(let n of e){let i=n.offset+n.length,o=r[r.length-1];o&&Lm(o,n,this.props)?(o.endOffset=Math.max(o.endOffset,i),o.requests.push(n)):r.push({sourceId:n.sourceId,isolationKey:n.isolationKey??n.sourceId,offset:n.offset,endOffset:i,fetchRange:n.fetchRange,requests:[n]})}return r}async fetchMergedRequest(e){let{offset:r,endOffset:n,fetchRange:i,requests:o}=e,s=new AbortController,a=dr(),c=()=>{o.every(l=>l.signal?.aborted)&&s.abort()};try{for(let p of o)p.onAbort=c;if(c(),o.every(p=>p.settled))return;let l=Mo(o),h=n-r;this.trackEvent({type:"request",sourceId:e.sourceId,offset:r,length:h,logicalRequestCount:o.length,logicalBytes:l,transportBytes:h,overfetchBytes:Math.max(h-l,0)});let u=Gm(await i(r,h,s.signal)),{arrayBuffer:f}=u,d=u.fullResponse&&r===0&&f.byteLength<h,m=f.byteLength<h&&Number.isSafeInteger(u.sourceByteLength)&&r+f.byteLength===u.sourceByteLength;if(f.byteLength!==h&&!d&&!m)throw new Error(`Byte-range transport returned ${f.byteLength} bytes; expected ${h}`);let _=u.networkTimeMs??dr()-a;this.trackEvent({type:"response",sourceId:e.sourceId,offset:r,length:h,logicalRequestCount:o.length,logicalBytes:l,transportBytes:h,responseBytes:u.transportBytes??f.byteLength,networkTimeMs:_,overfetchBytes:Math.max(h-l,0),status:u.status,fullResponse:u.fullResponse});for(let p of o){if(p.settled)continue;let M=p.offset-r;p.settled=!0,p.resolve(f.slice(M,M+p.length))}}catch(l){this.trackEvent({type:"error",sourceId:e.sourceId,offset:r,length:n-r,logicalRequestCount:o.length,logicalBytes:Mo(o),networkTimeMs:dr()-a,error:l});for(let h of o)h.settled||(h.signal?.aborted?this.abortRequest(h):(h.settled=!0,h.reject(l)))}finally{for(let l of o)l.abortListener&&l.signal?.removeEventListener("abort",l.abortListener),l.onAbort=void 0}}abortRequest(e){e.settled||(e.settled=!0,e.reject(Bc()),this.trackEvent({type:"abort",sourceId:e.sourceId,offset:e.offset,length:e.length,logicalRequestCount:1,logicalBytes:e.length}))}trackEvent(e){Om(this.stats,e);try{this.onEvent?.(e)}catch{}}trackBatch(e,r){let n=Mo(e),i=r.reduce((o,s)=>o+s.endOffset-s.offset,0);this.trackEvent({type:"batch",logicalRequestCount:e.length,transportRequestCount:r.length,logicalBytes:n,transportBytes:i,overfetchBytes:Math.max(i-n,0)})}};function Om(t,e){switch((e.type==="response"||e.type==="error")&&e.networkTimeMs!==void 0&&t.get(H.networkTimeMs,"time").addTime(e.networkTimeMs),e.type){case"queued":t.get(H.logicalRanges,"count").incrementCount(),t.get(H.requestedBytes,"count").addCount(e.logicalBytes||0);break;case"batch":t.get(H.rangeBatches,"count").incrementCount(),t.get("Logical Ranges Batched","count").addCount(e.logicalRequestCount||0),t.get(H.transportRanges,"count").addCount(e.transportRequestCount||0),t.get(H.coalescedRanges,"count").addCount(Math.max((e.logicalRequestCount||0)-(e.transportRequestCount||0),0)),t.get(H.transportBytes,"count").addCount(e.transportBytes||0),t.get(H.overfetchBytes,"count").addCount(e.overfetchBytes||0);break;case"response":t.get(H.completedTransportRanges,"count").incrementCount(),t.get(H.responseBytes,"count").addCount(e.responseBytes||0),e.fullResponse&&t.get(H.fullResponseFallbacks,"count").incrementCount();break;case"error":t.get(H.failedTransportRanges,"count").incrementCount();break;case"abort":t.get(H.abortedLogicalRanges,"count").incrementCount();break;default:}}function Dc(t="range-request-scheduler"){let e=new Le({id:t});return kc(e),e}async function Nm(t){let e=Dm(t.signal),r=dr();try{let n=!1,i=await t.fetch(t.url,zc(t.fetchOptions,t.offset,t.length,e.signal));if(i.status===416&&t.offset===0){let c=zm(i.headers.get("Content-Range"));if(!c)throw new Error("Missing content-length on 416 response");i=await t.fetch(t.url,zc(t.fetchOptions,0,c,e.signal)),n=!0}if(i.status===200)throw e.abort(),await km(i),new Error("Byte-range request failed: server returned 200 instead of 206");if(i.status!==206&&!i.ok)throw new Error(`Bad response code: ${i.status}`);let o=await i.arrayBuffer(),s=i.headers.get("Content-Range"),a=Bm(s);if(s&&!a)throw new Error(`Invalid Content-Range header: ${s}`);if(a){let c=a.endOffset-a.offset+1,l=t.offset+t.length-1;if(a.offset!==t.offset||a.endOffset>l||c!==o.byteLength||a.sourceByteLength!==void 0&&a.endOffset>=a.sourceByteLength)throw new Error(`Content-Range does not match requested range: ${s}`)}return{arrayBuffer:o,status:i.status,sourceByteLength:a?.sourceByteLength,transportBytes:o.byteLength,networkTimeMs:dr()-r,fullResponse:n}}finally{e.removeAbortListener()}}function Lm(t,e,r){if(t.sourceId!==e.sourceId||t.isolationKey!==(e.isolationKey??e.sourceId))return!1;let n=e.offset+e.length,i=e.offset-t.endOffset,o=Math.max(t.endOffset,n)-t.offset;return i<=r.rangeExpansionBytes&&o<=r.maxMergedBytes}function kc(t){t.get(H.logicalRanges,"count"),t.get(H.requestedBytes,"count"),t.get(H.rangeBatches,"count"),t.get("Logical Ranges Batched","count"),t.get(H.transportRanges,"count"),t.get(H.coalescedRanges,"count"),t.get(H.transportBytes,"count"),t.get(H.completedTransportRanges,"count"),t.get(H.responseBytes,"count"),t.get(H.networkTimeMs,"time"),t.get(H.overfetchBytes,"count"),t.get(H.fullResponseFallbacks,"count"),t.get(H.failedTransportRanges,"count"),t.get(H.abortedLogicalRanges,"count")}function Mo(t){return t.reduce((e,r)=>e+r.length,0)}function Gm(t){return t instanceof ArrayBuffer?{arrayBuffer:t}:t}function zc(t,e,r,n){return{...t,signal:n,headers:{...qm(t?.headers),Range:`bytes=${e}-${e+r-1}`}}}function qm(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):t:{}}function zm(t){let e=t?.match(/^bytes \*\/(\d+)$/);return e?Number(e[1]):null}function Bm(t){let e=t?.match(/^bytes (\d+)-(\d+)\/(\d+|\*)$/);if(!e)return null;let r=Number(e[1]),n=Number(e[2]),i=e[3]==="*"?void 0:Number(e[3]);return!Number.isSafeInteger(r)||!Number.isSafeInteger(n)||r>n||i!==void 0&&!Number.isSafeInteger(i)?null:{offset:r,endOffset:n,sourceByteLength:i}}function Dm(t){let e=new AbortController,r=()=>e.abort();return t?.aborted?e.abort():t?.addEventListener("abort",r,{once:!0}),{signal:e.signal,abort:()=>e.abort(),removeAbortListener:()=>t?.removeEventListener("abort",r)}}async function km(t){await t.body?.cancel().catch(()=>{})}function dr(){return globalThis.performance?.now()??Date.now()}function Bc(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let t=new Error("Request aborted");return t.name="AbortError",t}var be={};$i(be,{dirname:()=>Um,filename:()=>Fm,join:()=>Vm,resolve:()=>jm});function Fc(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function Fm(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function Um(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function Vm(...t){return t=t.map((r,n)=>(n&&(r=r.replace(new RegExp("^/"),"")),n!==t.length-1&&(r=r.replace(new RegExp("/$"),"")),r)),t.join("/")}function jm(...t){let e=[];for(let o=0;o<t.length;o++)e[o]=t[o];let r="",n=!1,i;for(let o=e.length-1;o>=-1&&!n;o--){let s;o>=0?s=e[o]:(i===void 0&&(i=Fc()),s=i),s.length!==0&&(r=`${s}/${r}`,n=s.charCodeAt(0)===mr)}return r=Wm(r,!n),n?`/${r}`:r.length>0?r:"."}var mr=47,yo=46;function Wm(t,e){let r="",n=-1,i=0,o,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)o=t.charCodeAt(a);else{if(o===mr)break;o=mr}if(o===mr){if(!(n===a-1||i===1))if(n!==a-1&&i===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==yo||r.charCodeAt(r.length-2)!==yo){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==mr;--l);if(l!==c){r=l===-1?"":r.slice(0,l),n=a,i=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",n=a,i=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(n+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}n=a,i=0}else o===yo&&i!==-1?++i:i=-1}return r}var zt=class{handle;size;bigsize;url;constructor(e){this.handle=e instanceof ArrayBuffer?new Blob([e]):e,this.size=e instanceof ArrayBuffer?e.byteLength:e.size,this.bigsize=BigInt(this.size),this.url=e instanceof File?e.name:""}async close(){}async stat(){return{size:this.handle.size,bigsize:BigInt(this.handle.size),isDirectory:!1}}async read(e,r,n){if(n?.aborted)throw new Error("Request aborted");let i=await this.handle.slice(Number(e),Number(e)+Number(r)).arrayBuffer();if(n?.aborted)throw new Error("Request aborted");return i}};var In=class{url;fetchFunction;fetchOptions;consistency;identityHints;countedFailures=new WeakSet;telemetry={requestedBytes:0,downloadedBytes:0,requestCount:0,networkTimeMs:0,abortCount:0,errorCount:0};constructor(e,r){Zm(r.byteLength),this.url=e,this.fetchFunction=r.fetch||((n,i)=>globalThis.fetch(n,i)),this.fetchOptions=r.fetchOptions?{...r.fetchOptions,headers:new Headers(r.fetchOptions.headers)}:void 0,this.consistency=r.consistency||"best-effort",this.identityHints={byteLength:r.byteLength,etag:Nn(r.etag),lastModified:Nn(r.lastModified)}}getInitialIdentity(){let{byteLength:e,etag:r,lastModified:n}=this.identityHints;return e!==void 0&&(r!==void 0||n!==void 0)?On(e,r,n):e===0&&this.consistency==="best-effort"?On(0):null}getTelemetry(){return Object.freeze({...this.telemetry})}trackFailure(e){if(typeof e=="object"&&e!==null){if(this.countedFailures.has(e))return;this.countedFailures.add(e)}Wc(e)?this.telemetry.abortCount++:this.telemetry.errorCount++}async requestRange(e,r,n,i){let o=Cn(),s=Qm(n,this.fetchOptions?.signal);this.telemetry.requestCount++,this.telemetry.requestedBytes+=r;try{let a=await this.fetchFunction(this.url,Hm(this.fetchOptions,e,r,s.signal));if($m(a,e,r,i))return await this.readEmptyIdentityProbe(a,o);if(a.status!==206)throw await An(a),new Error(`HTTP byte-range request expected 206, received ${a.status}`);let c=await Ym(a),l=Uc(a,c.byteLength),h=jc(i,l,this.identityHints,this.consistency)||Xm(c,e,r);if(h)throw await An(a),new Error(h);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:Vc(i,l,this.identityHints),status:a.status,transportBytes:u.byteLength,networkTimeMs:Cn()-o}}catch(a){throw(i===null||!Wc(a))&&this.trackFailure(a),a}finally{s.removeAbortListeners(),this.telemetry.networkTimeMs+=Cn()-o}}async readEmptyIdentityProbe(e,r){let n=Uc(e,0),i=jc(null,n,this.identityHints,this.consistency);if(await An(e),i)throw new Error(i);return{arrayBuffer:new ArrayBuffer(0),identity:Vc(null,n,this.identityHints),status:e.status,transportBytes:0,networkTimeMs:Cn()-r}}};function Hm(t,e,r,n){let i=new Headers(t?.headers);return i.set("Range",`bytes=${e}-${e+r-1}`),{...t,method:"GET",body:void 0,headers:i,signal:n}}function $m(t,e,r,n){return t.status===416&&n===null&&e===0&&r===1&&/^bytes \*\/0$/i.test(t.headers.get("Content-Range")||"")}async function Ym(t){try{return Km(t.headers.get("Content-Range"))}catch(e){throw await An(t),e}}function Km(t){let e=t?.match(/^bytes (\d+)-(\d+)\/(\d+)$/);if(!e)throw new Error("HTTP byte-range response has an invalid Content-Range header");return{offset:Number(e[1]),endOffset:Number(e[2]),byteLength:Number(e[3])}}function Uc(t,e){return On(e,Nn(t.headers.get("ETag")),Nn(t.headers.get("Last-Modified")))}function Vc(t,e,r){return t||On(e.byteLength,e.etag??r.etag,e.lastModified??r.lastModified)}function Xm(t,e,r){return!Number.isSafeInteger(t.offset)||!Number.isSafeInteger(t.endOffset)||!Number.isSafeInteger(t.byteLength)||t.offset<0||t.endOffset<t.offset||t.endOffset>=t.byteLength?"HTTP byte-range response has invalid range bounds":t.offset!==e||t.endOffset!==e+r-1?"HTTP byte-range response does not match the requested range":null}function jc(t,e,r,n){let i=t?.byteLength??r.byteLength;if(i!==void 0&&e.byteLength!==i)return"HTTP file length changed while the file was open";let o=t?.etag??r.etag,s=t?.lastModified??r.lastModified;return o?e.etag?o===e.etag?null:"HTTP file ETag changed while the file was open":n==="strict"?"HTTP byte-range response is missing the pinned ETag":s&&e.lastModified&&s!==e.lastModified?"HTTP file Last-Modified value changed while the file was open":null:s?e.lastModified&&s!==e.lastModified?"HTTP file Last-Modified value changed while the file was open":n==="strict"&&!e.lastModified?"HTTP byte-range response is missing the pinned Last-Modified value":null:n==="strict"&&!e.etag&&!e.lastModified?"HTTP byte-range response does not provide an ETag or Last-Modified validator":null}function On(t,e,r){return Object.freeze({byteLength:t,etag:e,lastModified:r})}function Zm(t){if(t!==void 0&&(!Number.isSafeInteger(t)||t<0))throw new Error("HttpFile byteLength must be a non-negative safe integer")}async function An(t){await t.body?.cancel().catch(()=>{})}function Nn(t){return t||void 0}function Cn(){return globalThis.performance?.now()??Date.now()}function Wc(t){return t instanceof Error&&t.name==="AbortError"||t instanceof Error&&/aborted/i.test(t.message)}function Qm(...t){let e=new AbortController,r=[...new Set(t.filter(i=>!!i))],n=()=>e.abort();for(let i of r)i.aborted?e.abort():i.addEventListener("abort",n,{once:!0});return{signal:e.signal,removeAbortListeners:()=>{for(let i of r)i.removeEventListener("abort",n)}}}var pr=class t{handle;url;transport;rangeScheduler;schedulerIsolationKey={};suppliedByteLength;identity;openPromise=null;closed=!1;constructor(e,r={}){this.handle=e,this.url=e,this.transport=new In(e,r),this.rangeScheduler=r.rangeScheduler||new Rn({batchDelayMs:0,...r.rangeSchedulerProps}),this.suppliedByteLength=r.byteLength,this.identity=this.transport.getInitialIdentity()}static async open(e,r={},n){let i=new t(e,r);return await i.open(n),i}async open(e){if(this.assertOpen(),e?.aborted){let r=Ln();throw this.transport.trackFailure(r),r}return await this.getIdentity(e),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 e=await this.getIdentity();return{size:e.byteLength,bigsize:BigInt(e.byteLength),isDirectory:!1}}async read(e=0,r=0,n){if(this.assertOpen(),n?.aborted){let s=Ln();throw this.transport.trackFailure(s),s}let i=await this.getIdentity(n),o=Hc(e);if(ep(o,r,i.byteLength),r===0)return new ArrayBuffer(0);try{return await this.rangeScheduler.scheduleRequest({sourceId:this.url,isolationKey:this.schedulerIsolationKey,offset:o,length:r,signal:n,fetchRange:this.fetchScheduledRange})}catch(s){throw this.transport.trackFailure(s),s}}async fetchRange(e,r,n){let i=Hc(e),o=await this.read(i,r,n),s=Jm(this.identity,i,r);return new Response(o,{status:206,headers:s})}fetchScheduledRange=async(e,r,n)=>{let i=await this.getIdentity(n),o=await this.transport.requestRange(e,r,n,i);return{arrayBuffer:o.arrayBuffer,status:o.status,transportBytes:o.transportBytes,networkTimeMs:o.networkTimeMs}};getIdentity(e){if(this.identity)return Promise.resolve(this.identity);if(!this.openPromise){let n=this.probeIdentity().catch(i=>{throw this.openPromise===n&&(this.openPromise=null),i});this.openPromise=n}return tp(this.openPromise,e).catch(r=>{throw this.transport.trackFailure(r),r})}async probeIdentity(){try{let e=await this.transport.requestRange(0,1,void 0,null);return this.identity=e.identity,e.identity}catch(e){throw this.transport.trackFailure(e),e}}assertOpen(){if(this.closed)throw new Error("HttpFile is closed")}};function Jm(t,e,r){let n=new Headers;return r>0&&t&&n.set("Content-Range",`bytes ${e}-${e+r-1}/${t.byteLength}`),t?.etag&&n.set("ETag",t.etag),t?.lastModified&&n.set("Last-Modified",t.lastModified),n}function Hc(t){let e=Number(t);if(!Number.isSafeInteger(e)||e<0)throw new Error("HTTP byte-range offset must be a non-negative safe integer");return e}function ep(t,e,r){if(!Number.isSafeInteger(e)||e<0)throw new Error("HTTP byte-range length must be a non-negative safe integer");if(t+e>r)throw new Error("HTTP byte range extends beyond the end of the file")}function Ln(){if(typeof DOMException<"u")return new DOMException("Request aborted","AbortError");let t=new Error("Request aborted");return t.name="AbortError",t}function tp(t,e){return e?e.aborted?Promise.reject(Ln()):new Promise((r,n)=>{let i=()=>{e.removeEventListener("abort",i),n(Ln())};e.addEventListener("abort",i,{once:!0}),t.then(o=>{e.removeEventListener("abort",i),r(o)},o=>{e.removeEventListener("abort",i),n(o)})}):t}function Gn(t={}){if(t.coordinateEpoch!==void 0&&!Number.isFinite(t.coordinateEpoch))throw new Error("Spatial reference coordinate epoch must be a finite decimal year");return Object.freeze({crs:$c(t.crs||{state:"absent",provenance:"unknown"}),vertical:t.vertical?$c(t.vertical):void 0,coordinateEpoch:t.coordinateEpoch,coordinateFrame:t.coordinateFrame||"unknown",coordinateOrder:Object.freeze([...t.coordinateOrder||[]]),units:t.units?Object.freeze([...t.units]):void 0})}function Me(t){if(typeof t=="object")return"projjson";let e=t.trim();return/^[A-Z][A-Z0-9_]*\s*[\[(]/i.test(e)?"wkt":/(?:^|\s)\+?proj=/i.test(e)?"proj-string":/^[A-Z][A-Z0-9._-]*(?::[A-Z0-9._-]+)+$/i.test(e)||/^urn:ogc:def:crs:/i.test(e)||/^https?:\/\//i.test(e)||/^[A-Z][A-Z0-9._-]*$/i.test(e)?"identifier":"opaque"}function $c(t){return t.state==="explicit"||t.state==="default"?Object.freeze({...t,definition:Yc(t.definition),alternatives:t.alternatives?Object.freeze(t.alternatives.map(e=>Object.freeze({...e,definition:Yc(e.definition)}))):void 0}):Object.freeze({...t})}function Yc(t){return typeof t=="string"?t:xo(t)}function xo(t){return Array.isArray(t)?Object.freeze(t.map(e=>xo(e))):t&&typeof t=="object"?Object.freeze(Object.fromEntries(Object.entries(t).map(([e,r])=>[e,xo(r)]))):t}var qn=class extends SyntaxError{constructor(e,r,n){let i=mp(r,n);super(`${e} at ${i.line}:${i.column}`),this.name="WKTCRSSyntaxError",this.offset=n,this.line=i.line,this.column=i.column}},zn=class extends Error{constructor(e){super(e[0]?.message||"WKT validation failed"),this.name="WKTCRSValidationError",this.issues=e}},rp=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?$/,np=/^[A-Za-z][A-Za-z0-9_]*/,gr=new Set(["COMPD_CS","CONCAT_MT","FITTED_CS","GEOCCS","GEOGCS","INVERSE_MT","LOCAL_CS","PARAM_MT","PASSTHROUGH_MT","PROJCS","VERT_CS"]),wo=new Set([...gr,"AUTHORITY","AXIS","CONCAT_MT","DATUM","INVERSE_MT","LOCAL_DATUM","PARAMETER","PARAM_MT","PASSTHROUGH_MT","PRIMEM","PROJECTION","SPHEROID","TOWGS84","UNIT","VERT_DATUM"]),ip=new Set(gr),op=new Set([...wo,"EXTENSION"]),sp=new Set([...gr,"COMPDCS","LOCALCS","VERTCS"]),ap=new Set([...wo,"COMPDCS","LOCALCS","VDATUM","VERTCS"]),Kc=new Set(["BOUNDCRS","COMPOUNDCRS","COORDINATEOPERATION","ENGCRS","ENGINEERINGCRS","GEODCRS","GEODETICCRS","PARAMETRICCRS","PROJCRS","PROJECTEDCRS","TIMECRS","VERTCRS","VERTICALCRS"]),Xc=new Set([...Kc,"CONCATENATEDOPERATION","COORDINATEMETADATA","DERIVEDPROJCRS","GEOGCRS","GEOGRAPHICCRS","POINTMOTIONOPERATION"]),Zc=new Set([...Xc,"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"]),cp=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"]),lp=new Set([...Zc].filter(t=>!cp.has(t))),hp={wkt1:gr,gdal:ip,esri:sp,"wkt2:2015":Kc,"wkt2:2019":Xc},up={wkt1:wo,gdal:op,esri:ap,"wkt2:2015":lp,"wkt2:2019":Zc};function _r(t,e){let n={type:"wkt-crs",root:new So(t).parse()};if(e?.strict){let i=Qc(n,{profile:e.profile,allowExtensions:!1});if(i.length>0)throw new zn(i)}return n}function Qc(t,e){if(!t||t.type!=="wkt-crs"||t.root?.type!=="node")throw new TypeError("validateWKTCRS expects a WKTCRSAst");let r=fp(t.root.keyword,e?.profile||"auto"),n=hp[r],i=up[r],o=[],s=t.root.keyword.toUpperCase();return n.has(s)||o.push({code:"invalid-root",message:`${t.root.keyword} is not a ${r} root keyword`,path:[],keyword:t.root.keyword}),Jc(t.root,[],a=>{let c=a.node.keyword.toUpperCase();!e?.allowExtensions&&!i.has(c)&&o.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&&o.push({code:"empty-node",message:`${a.node.keyword} must contain at least one value`,path:a.path,keyword:a.node.keyword});let l=dp(a.node);l&&o.push({code:"invalid-value",message:l,path:a.path,keyword:a.node.keyword})}),o}var So=class{constructor(e){this.offset=0,this.source=e}parse(){this.skipWhitespace();let e=this.parseNode();return this.skipWhitespace(),this.offset!==this.source.length&&this.fail("Unexpected content after WKT root"),e}parseNode(){let e=this.parseKeyword();return this.parseNodeAfterKeyword(e)}parseNodeAfterKeyword(e){this.skipWhitespace();let r=this.source[this.offset];r!=="["&&r!=="("&&this.fail(`Expected '[' or '(' after ${e}`),this.offset++;let n=r==="["?"bracket":"parenthesis",i=r==="["?"]":")",o=[];if(this.skipWhitespace(),this.source[this.offset]===i)return this.offset++,{type:"node",keyword:e,delimiter:n,values:o};for(;this.offset<this.source.length;){o.push(this.parseValue()),this.skipWhitespace();let s=this.source[this.offset];if(s===","){this.offset++,this.skipWhitespace(),this.source[this.offset]===i&&this.fail("Expected a WKT value after comma");continue}if(s===i)return this.offset++,{type:"node",keyword:e,delimiter:n,values:o};(s==="]"||s===")")&&this.fail(`Expected '${i}' to close ${e}`),this.fail(`Expected ',' or '${i}' in ${e}`)}this.fail(`Unterminated ${e} 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 n=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(n)||this.fail(`Invalid WKT keyword '${n}'`),this.parseNodeAfterKeyword(n)):rp.test(n)?{type:"number",value:Number(n),raw:n}:{type:"enumeration",value:n}}parseKeyword(){let e=this.source.slice(this.offset).match(np);return e||this.fail("Expected a WKT keyword"),this.offset+=e[0].length,e[0]}parseString(){this.offset++;let e="";for(;this.offset<this.source.length;){let r=this.source[this.offset++];if(r==='"'){if(this.source[this.offset]==='"'){e+='"',this.offset++;continue}return{type:"string",value:e}}e+=r}this.fail("Unterminated WKT string")}skipWhitespace(){for(;this.offset<this.source.length&&/\s/.test(this.source[this.offset]);)this.offset++}fail(e){throw new qn(e,this.source,this.offset)}};function fp(t,e){return e!=="auto"?e:gr.has(t.toUpperCase())?"wkt1":"wkt2:2019"}function dp(t){let e=t.keyword.toUpperCase(),r=t.values,n=(o,...s)=>!!(r[o]&&s.includes(r[o].type)),i=(o,...s)=>r.length===o&&s.every((a,c)=>n(c,a));if(["ANGLEUNIT","LENGTHUNIT","PARAMETRICUNIT","SCALEUNIT","TIMEUNIT","TEMPORALQUANTITY","UNIT"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${t.keyword} must start with a quoted name and numeric conversion factor`;if(e==="CS"&&!i(2,"enumeration","number"))return`${t.keyword} must contain a coordinate-system type and dimension`;if(e==="BBOX"&&!i(4,"number","number","number","number"))return`${t.keyword} must contain four numeric bounds`;if(["ENSEMBLEACCURACY","EPOCH","COORDEPOCH","FRAMEEPOCH","OPERATIONACCURACY","ORDER"].includes(e)&&!i(1,"number"))return`${t.keyword} must contain one number`;if(["ANCHOR","AREA","CALENDAR","CITATION","REMARK","SCOPE","URI","VERSION"].includes(e)&&!i(1,"string"))return`${t.keyword} must contain one quoted string`;if(["ELLIPSOID","SPHEROID","TRIAXIAL"].includes(e)&&!(r.length>=3&&n(0,"string")&&n(1,"number")&&n(2,"number")))return`${t.keyword} must start with a quoted name and numeric ellipsoid axes`;if(["PARAMETER"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"number")))return`${t.keyword} must start with a quoted name and numeric value`;if(e==="PARAMETERFILE"&&!i(2,"string","string"))return`${t.keyword} must contain a quoted name and file name`;if(["AUTHORITY","ID"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"string","number")))return`${t.keyword} must start with a quoted authority and identifier`;if(["AXIS"].includes(e)&&!(r.length>=2&&n(0,"string")&&n(1,"enumeration")))return`${t.keyword} must start with a quoted name and axis direction`;if(["METHOD","PROJECTION"].includes(e)&&!(r.length>=1&&n(0,"string")))return`${t.keyword} must start with a quoted name`;if(e==="TIMEEXTENT"){let o=s=>n(s,"enumeration","string");if(r.length!==2||!o(0)||!o(1))return`${t.keyword} must contain two date-time or quoted values`}if(e==="VERTICALEXTENT"&&(r.length<2||r.length>3||!n(0,"number")||!n(1,"number")||r.length===3&&!n(2,"node")))return`${t.keyword} must contain two numeric bounds and an optional unit`;if(e==="COORDINATEMETADATA"&&(r.length<1||r.length>2||!n(0,"node")||r.length===2&&(!n(1,"node")||!["EPOCH","COORDEPOCH"].includes(r[1].keyword.toUpperCase()))))return`${t.keyword} must contain a CRS and an optional coordinate epoch`;if(e==="BOUNDCRS"){let o=r.slice(0,3).map(s=>s.type==="node"?s.keyword.toUpperCase():"");if(o[0]!=="SOURCECRS"||o[1]!=="TARGETCRS"||o[2]!=="ABRIDGEDTRANSFORMATION")return`${t.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(e)&&!n(0,"string")?`${t.keyword} must start with a quoted name`:null}function Jc(t,e,r){r({node:t,path:e});for(let n=0;n<t.values.length;n++){let i=t.values[n];i.type==="node"&&Jc(i,[...e,n],r)}}function mp(t,e){let r=1,n=1;for(let i=0;i<e&&i<t.length;i++)t[i]===`
8
+ `?(r++,n=1):n++;return{line:r,column:n}}var at=class extends SyntaxError{constructor(e,r,n){let i=yp(r,n);super(`${e} at ${i.line}:${i.column}`),this.name="PROJStringSyntaxError",this.offset=n,this.line=i.line,this.column=i.column}};function Mr(t){let e=_p(t);if(e.length===0)throw new at("PROJ string is empty",t,0);return{type:"proj-string",parameters:e.map(n=>gp(n.raw,n.offset,t))}}var pp=/^[+-]?\d+(?:\.\d*)?d(?:\d+(?:\.\d*)?'(?:\d+(?:\.\d*)?")?)?[NSEW]?$/i;function gp(t,e,r){let n=t.startsWith("+")?t.slice(1):t;if(!n)throw new at("Expected a parameter after '+'",r,e);let i=n.indexOf("="),o=i<0?n:n.slice(0,i);if(!o||/[\s+=]/.test(o))throw new at(`Invalid PROJ parameter name '${o}'`,r,e);if(i<0)return{type:"parameter",name:o};let s=n.slice(i+1),a=Mp(s,r,e+i+1);return{type:"parameter",name:o,value:a,rawValue:s}}function _p(t){let e=[],r=0;for(;r<t.length;){for(;r<t.length&&/\s/.test(t[r]);)r++;if(r>=t.length)break;let n=r,i=null,o=!1;for(;r<t.length;){let s=t[r];if(o){o=!1,r++;continue}if(s==="\\"&&i){o=!0,r++;continue}if(i){s===i&&(i=null),r++;continue}if((s==='"'||s==="'")&&t[r-1]==="="){i=s,r++;continue}if(/\s/.test(s))break;r++}if(i)throw new at("Unterminated quoted PROJ value",t,n);e.push({raw:t.slice(n,r),offset:n})}return e}function Mp(t,e,r){if(!t)return"";let n=t[0];if(n!=='"'&&n!=="'"){if((t.includes('"')||t.includes("'"))&&!pp.test(t))throw new at("Quote must begin a PROJ parameter value",e,r);return t}if(t[t.length-1]!==n)throw new at("Unterminated quoted PROJ value",e,r);let i="";for(let o=1;o<t.length-1;o++){let s=t[o];s==="\\"&&o+1<t.length-1?i+=t[++o]:i+=s}return i}function yp(t,e){let r=1,n=1;for(let i=0;i<e&&i<t.length;i++)t[i]===`
9
+ `?(r++,n=1):n++;return{line:r,column:n}}var Bn=class{item;previous;next;constructor(e,r,n){this.item=e,this.previous=r,this.next=n}};var Dn=class{head=null;tail=null;_length=0;get length(){return this._length}add(e){let r=new Bn(e,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,r){e!==r&&(this.remove(r),this._insert(e,r))}_insert(e,r){let n=e.next;e.next=r,this.tail===e?this.tail=r:n.previous=r,r.next=n,r.previous=e,++this._length}};var Bt=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Dn,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){let r=e._cacheNode;r&&this._list.splice(this._sentinel,r)}add(e,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(e,r))}unloadTile(e,r,n){let i=r._cacheNode;i&&(this._list.remove(i),r._cacheNode=null,n&&n(e,r))}unloadTiles(e,r){let n=this._trimTiles;this._trimTiles=!1;let i=this._list,o=this._sentinel,s=i.head;for(;s!==o&&(e.gpuMemoryUsageInBytes>e.cacheBytes||n);){let a=s.item;s=s.next,this.unloadTile(e,a,r)}}trim(){this._trimTiles=!0}};function kn(t,e){ke(t),ke(e);let{rtcCenter:r,gltfUpAxis:n}=e,{computedTransform:i,boundingVolume:{center:o}}=t,s=new G(i);switch(r&&s.translate(r),n){case"Z":break;case"Y":let f=new G().rotateX(Math.PI/2);s=s.multiplyRight(f);break;case"X":let d=new G().rotateY(-Math.PI/2);s=s.multiplyRight(d);break;default:break}e.isQuantized&&s.translate(e.quantizedVolumeOffset).scale(e.quantizedVolumeScale);let a=new g(o);e.cartesianModelMatrix=s,e.cartesianOrigin=a;let c=N.WGS84.cartesianToCartographic(a,new g),h=N.WGS84.eastNorthUpToFixedFrame(a).invert();e.cartographicModelMatrix=h.multiplyRight(s),e.cartographicOrigin=c;let u=Sp(e);u&&(e.cartesianModelMatrix=new G(s).multiplyRight(u.matrix),e.cartographicModelMatrix.multiplyRight(u.matrix),u.matrix=G.IDENTITY),e.coordinateSystem||(e.modelMatrix=e.cartographicModelMatrix)}var xp=1e6**2;function Sp(t){let e=t.gltf;if(!e)return null;let r=typeof e.scene=="number"?e.scene:0,i=e.scenes?.[r]?.nodes?.[0];if(!i?.matrix)return null;let o=i.matrix;return o[12]*o[12]+o[13]*o[13]+o[14]*o[14]<=xp?null:i}var el=new g,Eo=new g,wp=1e-5,Ep=1e-7,To=new se([new re,new re,new re,new re,new re,new re]);function Fn(t,e,r={}){let{cameraUp:n,height:i}=t,o=t.cameraDirection,{metersPerUnit:s}=t.distanceScales,a=yr(t,t.center),c=N.WGS84.eastNorthUpToFixedFrame(a),l=t.unprojectPosition(t.cameraPosition),h=N.WGS84.cartographicToCartesian(l,new g),u;if(o)u=new g(c.transformAsVector(new g(o).scale(s))).normalize();else{let T=t.getFrustumPlanes().near,R=bo(T,t.cameraPosition),C=yr(t,R);u=new g(C).subtract(h).normalize()}let f=new g(c.transformAsVector(new g(n).scale(s))).normalize();Tp(t);let d=t.constructor,{longitude:m,latitude:_,width:p,bearing:M,zoom:y,position:S}=t,x=new d({longitude:m,latitude:_,height:i,width:p,bearing:M,zoom:y,position:S,pitch:0}),E=Number.isFinite(t.fovy)&&Number(t.fovy)>0&&Number(t.fovy)<180?Number(t.fovy)*Math.PI/180:Math.PI/3;return{camera:{position:h,direction:u,up:f,cartographicPosition:l,verticalFieldOfView:E,timeSinceMovement:r.timeSinceCameraMovement??Number.POSITIVE_INFINITY},viewport:t,topDownViewport:x,height:i,cullingVolume:To,clippingPlanes:t.clippingPlanes,frameNumber:e,sseDenominator:2*Math.tan(E/2),dynamicScreenSpaceErrorDensity:0}}function tl(t,e,r,n){let i=Array.from(e),o=Array.from(r),s=t?i.length!==t.position.length||i.some((l,h)=>Math.abs(l-t.position[h])>wp):!1,a=t?o.length!==t.direction.length||o.some((l,h)=>Math.abs(l-t.direction[h])>Ep):!1,c=s||a?n:t?.lastMovementTime??Number.NEGATIVE_INFINITY;return{state:{position:i,direction:o,lastMovementTime:c},timeSinceMovement:Math.max((n-c)/1e3,0)}}function rl(t,e,r){if(r===0||t.length<=r)return[t,[]];let n=[],{longitude:i,latitude:o}=e.viewport;for(let[l,h]of t.entries()){let[u,f]=h.header.mbs,d=Math.abs(i-u),m=Math.abs(o-f),_=Math.sqrt(m*m+d*d);n.push([l,_])}let s=n.sort((l,h)=>l[1]-h[1]),a=[];for(let l=0;l<r;l++)a.push(t[s[l][0]]);let c=[];for(let l=r;l<s.length;l++)c.push(t[s[l][0]]);return[a,c]}function Tp(t){let e=t.getFrustumPlanes(),r=bo(e.near,t.cameraPosition),n=yr(t,r),i=yr(t,t.cameraPosition,Eo),o=0;To.planes[o++].fromPointNormal(n,el.copy(n).subtract(i));for(let s in e){if(s==="near")continue;let a=e[s],c=bo(a,r,Eo),l=yr(t,c,Eo);To.planes[o++].fromPointNormal(l,el.copy(n).subtract(l))}}function bo(t,e,r=new g){let n=t.normal.dot(e);return r.copy(t.normal).scale(t.distance-n).add(e),r}function yr(t,e,r=new g){let n=t.unprojectPosition(e);return N.WGS84.cartographicToCartesian(n,r)}var al=new g,bp=new g,St=new g,nl=new g,xr=new g,il=new g,ol=new g,sl=new g,Un=new Ne,vp=new g(0,0,1);function cl(t,e){t._updateTransform(e)}function ll(t,e,r){if(!Number.isFinite(r.dynamicScreenSpaceErrorDensity)||r.dynamicScreenSpaceErrorDensity<=0)return 0;let n=Ap(t),i=n.region?Ip(n.region,e):Op(t,n,e);if(!i)return 0;let o=ir(r.dynamicScreenSpaceErrorHeightFalloff,0,1),s=i.minimumHeight+(i.maximumHeight-i.minimumHeight)*o,a=i.maximumHeight-s,c=a>0?ir((i.cameraHeight-s)/a,0,1):i.cameraHeight>=i.maximumHeight?1:0,h=(1-ir(Math.abs(i.cameraDirection.dot(i.upDirection)),0,1))*(1-c);return r.dynamicScreenSpaceErrorDensity*h}function Pp(t,e){let r=t*e;return 1-Math.exp(-(r*r))}function Rp(t,e,r){return e<=0||r<=0||!Number.isFinite(e)||!Number.isFinite(r)?0:Pp(t,e)*r}function hl(t,e,r,n=1){let i=t.tileset,o=t.parent&&t.parent.lodMetricValue||t.lodMetricValue,s=r?o:t.lodMetricValue;if(s===0)return 0;let{viewDistanceScale:a}=i.options,c=a||1,l=Number.isFinite(n)?Math.max(n,0):1,h=Cp(s,e,c,l);if(h!==null)return h;let u=Math.max(t._distanceToCamera,1e-7),{height:f,sseDenominator:d}=e,m=s*f*l*c/(u*d);return i.options.dynamicScreenSpaceError&&!e.viewport.orthographic&&(m-=Rp(u,e.dynamicScreenSpaceErrorDensity,i.options.dynamicScreenSpaceErrorFactor)),m}function Cp(t,e,r,n){let i=e.viewport;if(!i?.orthographic)return null;let o=i.metersPerPixel;return!Number.isFinite(o)||!o||o<=0?null:t*r*n/o}function Ap(t){return t.header.content?.boundingVolume||t.header.boundingVolume}function Ip(t,e){let r=al.copy(e.camera.position).normalize(),n=xr.copy(e.camera.direction).normalize();return{cameraHeight:e.camera.cartographicPosition[2],minimumHeight:t[4],maximumHeight:t[5],cameraDirection:n,upDirection:r}}function Op(t,e,r){let n=Np(e,St);if(n===null)return null;let i=new G(t.computedTransform).invert(),o=t.tileset.ellipsoid;if(Math.hypot(St[0],St[1],St[2])>o.minimumRadius){let a=o.cartesianToCartographic(St,bp),c=al.copy(r.camera.position).normalize(),l=xr.copy(r.camera.direction).normalize();return{cameraHeight:r.camera.cartographicPosition[2],minimumHeight:0,maximumHeight:a[2]*2,cameraDirection:l,upDirection:c}}return i.transformAsPoint(r.camera.position,nl),i.transformAsVector(r.camera.direction,xr),xr.normalize(),{cameraHeight:nl[2],minimumHeight:St[2]-n,maximumHeight:St[2]+n,cameraDirection:xr,upDirection:vp}}function Np(t,e){if(t.box){let r=t.box;return e.set(r[0],r[1],r[2]),Lp(r)}if(t.sphere){let r=t.sphere;return e.set(r[0],r[1],r[2]),r[3]}return null}function Lp(t){return t.length===10?(Un.fromArray(t,6),il.set(t[3],0,0).transformByQuaternion(Un),ol.set(0,t[4],0).transformByQuaternion(Un),sl.set(0,0,t[5]).transformByQuaternion(Un),Math.abs(il[2])+Math.abs(ol[2])+Math.abs(sl[2])):Math.abs(t[5])+Math.abs(t[8])+Math.abs(t[11])}var ae={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},te;(function(t){t[t.ADD=1]="ADD",t[t.REPLACE=2]="REPLACE"})(te||(te={}));var Ke;(function(t){t.EMPTY="empty",t.SCENEGRAPH="scenegraph",t.POINTCLOUD="pointcloud",t.MESH="mesh"})(Ke||(Ke={}));var he;(function(t){t.I3S="I3S",t.TILES3D="TILES3D"})(he||(he={}));var Dt;(function(t){t.GEOMETRIC_ERROR="geometricError",t.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(Dt||(Dt={}));var ul={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};var fl=1e4,Gp=1e4,qp=1e8,zp=new fe,dl=new g,ml=new g,vo=new g,Vn=new g;function Po(t,e,r){return t+(e-t)*r}function pl(t,e){let r=t instanceof fe?t:t.getBoundingSphere(zp),{center:n,radius:i}=r;dl.copy(n).subtract(e.position);let o=Math.max(dl.dot(e.direction),0);return ml.copy(e.direction).scale(o).add(e.position),vo.copy(ml).subtract(n),vo.magnitude()<=i||(Vn.copy(vo).normalize().scale(i).add(n).subtract(e.position),Vn.magnitude()===0)?0:(Vn.normalize(),Math.min(Math.max(1-Vn.dot(e.direction),0),1))}function gl(t,e,r,n){return!Number.isFinite(n)||n<=0||n>.5?!1:t>r?!0:e!==void 0&&e>r}function _l(t){let e=Number.isFinite(t.foveatedConeSize)?Math.min(Math.max(t.foveatedConeSize,0),1):1,r=t.refinement===te.REPLACE;if(r&&!t.skipLevelOfDetail||!t.foveatedScreenSpaceError||e>=1||r&&t.skipLevelOfDetail&&t.priorityProgressiveResolution)return!1;let n=Number.isFinite(t.verticalFieldOfView)&&t.verticalFieldOfView>0?t.verticalFieldOfView:Math.PI/3,i=1-Math.cos(n*.5),o=e*i;if(t.foveatedFactor<=o||i<=o)return!1;let s=Math.min(Math.max((t.foveatedFactor-o)/(i-o),0),1),c=(typeof t.interpolationCallback=="function"?t.interpolationCallback:Po)(t.minimumScreenSpaceErrorRelaxation,t.maximumScreenSpaceError,s),l=Number.isFinite(c)?Math.min(Math.max(c,0),t.maximumScreenSpaceError):0,h=t.screenSpaceError===0&&t.parentScreenSpaceError!==void 0?t.parentScreenSpaceError*.5:t.screenSpaceError;return t.maximumScreenSpaceError-l<=h}function Ml(t,e,r){return t&&Number.isFinite(e)&&Number.isFinite(r)&&r>0&&e<r}function yl(t){let e=t.rootScreenSpaceError>0?Math.min(Math.max(t.reverseScreenSpaceError/t.rootScreenSpaceError,0),1):0,r=Math.floor(e*(fl-1)),n=Number.isFinite(t.foveatedFactor)?Math.min(Math.max(t.foveatedFactor,0),1):0,i=Math.floor(n*(fl-1))*Gp;return(t.priorityProgressiveResolution?0:qp)+i+r}var kt="EPSG:4326",jn="EPSG:4978";function Sr(t){let e=t.trim().toUpperCase(),r=e.match(/(?:\/DEF\/CRS\/|URN:OGC:DEF:CRS:)([A-Z0-9_-]+)(?:\/|::)(?:[^/:]*[/:])?([A-Z0-9_.-]+)$/);return r?`${r[1]}:${r[2]}`:e}function _e(t){if(typeof t=="string"){let r=Me(t);return r==="wkt"?Bp(t):r==="proj-string"?Dp(t):Ro(t)||"projected"}let e=t;return e.type==="BoundCRS"&&e.source_crs?_e(e.source_crs):e.type==="CompoundCRS"&&e.components?.[0]?_e(e.components[0]):String(e.type).includes("Projected")?"projected":String(e.type).includes("Geographic")?"geographic":String(e.type).includes("Geodetic")?e.coordinate_system?.subtype==="Cartesian"?"geocentric":"geographic":"unknown"}function Ro(t){if(typeof t!="string")return;let e=Sr(t);if(e===jn)return"geocentric";if(e===kt||e==="OGC:CRS84")return"geographic";let r=/^EPSG:(\d+)$/.exec(e);if(!r)return;let n=Number(r[1]);if(n===7789)return"geocentric";if(n===4490||n===4979)return"geographic";if(n===3857||n>=32601&&n<=32660||n>=32701&&n<=32760)return"projected"}function Bp(t){let e;try{e=_r(t).root}catch{return"unknown"}switch(e.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 n=e.values.find(i=>i.type==="node"&&i.keyword.toUpperCase()==="CS")?.values[0];return n?.type!=="enumeration"&&n?.type!=="string"?"unknown":n.value.toUpperCase()==="CARTESIAN"?"geocentric":n.value.toUpperCase()==="ELLIPSOIDAL"?"geographic":"unknown"}default:return"unknown"}}function Dp(t){try{let e=Mr(t).parameters.find(r=>r.name.toLowerCase()==="proj")?.value;switch(e?.toLowerCase()){case"longlat":case"latlong":return"geographic";case"geocent":return"geocentric";default:return e?"projected":"unknown"}}catch{return"unknown"}}function ve(t,e={}){let r=e.sourceCrs!==void 0,n=e.sourceCrs||t.sourceCrs,i=e.outputCoordinates||"auto",o=e.targetCrs||(i==="ecef"?"EPSG:4978":void 0),s=e.targetHeightReference||"native",a=t.verticalUnitScale??1,c=t.elevationUnitScale??1,l=t.elevationOffset||0,h=t.elevationMode==="onTheGround"||t.elevationMode==="relativeToGround"||t.elevationMode==="relativeToScene",u=t.elevationMode==="relativeToScene"?!!e.sceneElevationProvider:!h||!!e.terrainElevationProvider,f=a!==1||c!==1||t.elevationMode!==void 0&&(h||t.elevationMode==="absoluteHeight"&&l!==0),d=s!=="native"&&s!==t.heightReference,m=!!o||s!=="native"||i!=="auto"||f,_=i!=="target-crs"||!!o,p=!d||(t.heightReference||"unknown")!=="unknown",M=Number.isFinite(a)&&a>0&&Number.isFinite(c)&&c>0,y=!!n&&m&&_&&p&&M&&u&&i!=="local-enu",S=r?"caller-override":t.provenance||"unknown",x=r&&n?_e(n):t.coordinateFrame,E=r?"explicit":t.sourceCrsState||(n?S==="format-default"?"default":"explicit":"absent"),T=Gn({crs:n?{state:E==="default"?"default":"explicit",definition:n,representation:!r&&t.sourceCrsRepresentation||Me(n),provenance:S,alternatives:r?void 0:t.sourceCrsAlternatives}:{state:E==="unknown"?"unknown":"absent",provenance:S},vertical:t.verticalCrs?{state:"explicit",definition:t.verticalCrs,representation:Me(t.verticalCrs),provenance:t.provenance||"metadata"}:void 0,coordinateEpoch:e.coordinateEpoch??t.coordinateEpoch,coordinateFrame:x,coordinateOrder:Fp(t.axisOrder),units:r?void 0:t.units}),R=Co(T.crs),C=T.vertical?Co(T.vertical):void 0,O=o?kp(o):void 0;return Object.freeze({...T,sourceCrs:R,verticalCrs:C,verticalUnitScale:a,coordinateEpoch:e.coordinateEpoch??t.coordinateEpoch,heightReference:t.heightReference||"unknown",elevationMode:t.elevationMode,elevationOffset:t.elevationOffset,elevationUnit:t.elevationUnit,elevationUnitScale:c,coordinateFrame:x||"unknown",axisOrder:t.axisOrder||"unknown",provenance:S,targetCrs:O,targetHeightReference:s,outputCoordinates:i,status:m?y?"transformable":"unresolved":"native",warnings:Object.freeze([...t.warnings||[]])})}function wt(t,e={}){return ve({sourceCrs:t?.sourceCrs,sourceCrsState:t?.crs.state,sourceCrsRepresentation:t?.crs.state==="explicit"||t?.crs.state==="default"?t.crs.representation:void 0,sourceCrsAlternatives:t?.crs.state==="explicit"||t?.crs.state==="default"?t.crs.alternatives:void 0,verticalCrs:t?.verticalCrs,units:t?.units,verticalUnitScale:t?.verticalUnitScale,coordinateEpoch:t?.coordinateEpoch,heightReference:t?.heightReference,elevationMode:t?.elevationMode,elevationOffset:t?.elevationOffset,elevationUnit:t?.elevationUnit,elevationUnitScale:t?.elevationUnitScale,coordinateFrame:t?.coordinateFrame,axisOrder:t?.axisOrder,provenance:t?.provenance,warnings:t?.warnings},e)}function Co(t){return t.state==="explicit"||t.state==="default"?t.definition:void 0}function kp(t){let e=Gn({crs:{state:"explicit",definition:t,representation:Me(t),provenance:"caller-override"}}),r=Co(e.crs);if(!r)throw new Error("Failed to normalize a known target CRS definition");return r}function Fp(t){switch(t){case"xy":return["x","y"];case"yx":return["y","x"];case"xyz":return["x","y","z"];default:return[]}}function Ft(t){if(t.status!=="transformable"&&t.status!=="transformed")throw new Error("Only a transformable spatial reference can be marked as transformed");return Object.freeze({...t,status:"transformed"})}function Wn(t){return!!(t&&typeof t=="object"&&"initialize"in t&&"getRootTileset"in t&&"initializeTileHeaders"in t&&"loadTileContent"in t)}var Yn=1024*1024,Cl=512*Yn,Al=512*Yn,Up=32*Yn,Vp=Yn;function Hn(t,e){if(!Number.isFinite(t)||t<0)throw new Error(`${e} must be a finite number greater than or equal to 0`);return t}function xl(t,e){let r=t.cacheBytes??e;return Hn(r,"cacheBytes")}function Sl(t,e){let r=t.maximumCacheOverflowBytes??e;return Hn(r,"maximumCacheOverflowBytes")}var Ao={description:"",ellipsoid:N.WGS84,modelMatrix:new G,throttleRequests:!0,maxRequests:64,cacheBytes:Cl,maximumCacheOverflowBytes:Al,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onSourceError:()=>{},onTilesetError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{},contentLoader:void 0,viewDistanceScale:1,progressiveResolutionHeightFraction:.3,foveatedScreenSpaceError:!0,foveatedConeSize:.1,foveatedMinimumScreenSpaceErrorRelaxation:0,foveatedInterpolationCallback:Po,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:{}},Io="Tiles In Tileset(s)",Oo="Tiles In Memory",wl="Tiles In View",El="Tiles To Render",Tl="Tiles Loaded",No="Tiles Loading",bl="Tiles Unloaded",vl="Failed Tile Loads",Pl="Points/Vertices",Lo="Tile Memory Use",Rl="Maximum Screen Space Error",$n=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=ve({});description="";properties;extras=null;attributions={};credits={};stats;contentFormats;cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=Cl;_maximumCacheOverflowBytes=Al;_frameNumber=0;_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_cameraMotionStates={};_deferredTraversalTimeout=null;_traverser;_cache=new Bt;_requestScheduler;_heldTiles=new Set;updatePromise=null;tilesetInitializationPromise;constructor(e,r){if(!Wn(e))throw new Error("Tileset3D requires a Tileset3DSource instance");let n=r||{},i=e.type===he.TILES3D,o=i?Ao.cacheBytes:Up,s=i?Ao.maximumCacheOverflowBytes:Vp,a=xl(n,o),c=Sl(n,s);this.options={...Ao,...n,cacheBytes:a,maximumCacheOverflowBytes:c,memoryAdjustedScreenSpaceError:n.memoryAdjustedScreenSpaceError??i},this.loadOptions=this.options.loadOptions||{},this.source=e,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 st({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=a,this._maximumCacheOverflowBytes=c;let l=this._getSourceMetadata();l&&(this.spatialReference=wt(l.spatialReference,this.options.spatial)),this.stats=new Le({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(e){this._cacheBytes=Hn(e,"cacheBytes"),this.options.cacheBytes=this._cacheBytes}get maximumCacheOverflowBytes(){return this._maximumCacheOverflowBytes}set maximumCacheOverflowBytes(e){this._maximumCacheOverflowBytes=Hn(e,"maximumCacheOverflowBytes"),this.options.maximumCacheOverflowBytes=this._maximumCacheOverflowBytes}get queryParams(){let e=this.source.getTileUrl(this.url),r=e.indexOf("?");return r>=0?e.slice(r+1):""}setProps(e){let r=xl(e,this.cacheBytes),n=Sl(e,this.maximumCacheOverflowBytes);this.options={...this.options,...e,cacheBytes:r,maximumCacheOverflowBytes:n},this._cacheBytes=r,this._maximumCacheOverflowBytes=n}getTileUrl(e){return this.source.getTileUrl(e)}hasExtension(e){return!!this.source.hasExtension?.(e)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),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(e){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=e instanceof Array?e:[e],n=new Set(r.map(a=>a.id));for(let a of Object.keys(this.frameStateData))n.has(a)||delete this.frameStateData[a];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let i=Date.now(),o=Number.POSITIVE_INFINITY,s=[];for(let a of r){let c=a.id;this._needTraverse(c)?s.push(c):this.traverseCounter--}for(let a of r){let c=a.id;if(this.roots[c]||(this.roots[c]=this._initializeTileHeaders(this.tileset,null)),!s.includes(c))continue;let l=Fn(a,this._frameNumber),h=this.roots[c],u=tl(this._cameraMotionStates[c],l.camera.position,l.camera.direction,i);this._cameraMotionStates[c]=u.state,l.camera.timeSinceMovement=u.timeSinceMovement,cl(h,this.modelMatrix),l.dynamicScreenSpaceErrorDensity=this.type===he.TILES3D&&this.options.dynamicScreenSpaceError&&!l.viewport.orthographic?ll(h,l,this.options):0,this.dynamicScreenSpaceErrorComputedDensity=l.dynamicScreenSpaceErrorDensity,this._traverser.traverse(h,l,this.options),Object.keys(this._traverser.deferredTiles).length>0&&(o=Math.min(o,Math.max(this.options.foveatedTimeDelay-u.timeSinceMovement,0)))}Number.isFinite(o)?this._scheduleDeferredTraversal(o):this._clearDeferredTraversal()}_scheduleDeferredTraversal(e){this._clearDeferredTraversal(),this._deferredTraversalTimeout=setTimeout(()=>{this._deferredTraversalTimeout=null,this.selectTiles().catch(r=>{let n=r instanceof Error?r:new Error(String(r));this._onTilesetError(n)})},Math.max(e*1e3,0))}_clearDeferredTraversal(){this._deferredTraversalTimeout!==null&&(clearTimeout(this._deferredTraversalTimeout),this._deferredTraversalTimeout=null)}_needTraverse(e){let r=e;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[e]),r===e}_onTraversalEnd(e){let r=e.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],i=Object.values(this._traverser.selectedTiles),[o,s]=rl(i,e,this.options.maximumTilesSelected);n.selectedTiles=o;for(let a of s)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){let e=this.selectedTiles;this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let o in this.frameStateData){let s=this.frameStateData[o];this.selectedTiles=this.selectedTiles.concat(s.selectedTiles),this._requestedTiles=this._requestedTiles.concat(s._requestedTiles),this._emptyTiles=this._emptyTiles.concat(s._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);let r=new Set(this.selectedTiles.map(o=>o.id)),n=this.selectedTiles.some(o=>!o.tileDrawn),i=0;if(n){for(let o of r)this._heldTiles.add(o);for(let o of this._heldTiles){if(r.has(o))continue;let s=this._tiles[o];s&&s.contentAvailable?(s._selectedFrame=this._frameNumber,this.selectedTiles.push(s),i++):this._heldTiles.delete(o)}}else this._heldTiles=r;i>0&&setTimeout(()=>{this.selectTiles()},0);for(let o of this.selectedTiles)this._tiles[o.id]=o;this._loadTiles(),this._unloadTiles(),this._updateStats(),this._tilesChanged(e,this.selectedTiles)&&this.options.onUpdate()}_tilesChanged(e,r){if(e.length!==r.length)return!0;let n=new Set(e.map(s=>s.id)),i=new Set(r.map(s=>s.id)),o=e.some(s=>!i.has(s.id));return o=o||r.some(s=>!n.has(s.id)),o}_loadTiles(){this._requestedTiles.sort((e,r)=>e._priority-r._priority);for(let e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,r)=>e._unloadTile(r)),this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_updateStats(){let e=0,r=0;for(let n of this.selectedTiles)if(n.contentAvailable&&n.content){e++;let i=n.contents.length?n.contents:[n.content];for(let o of i)o.pointCount?r+=o.pointCount:r+=o.vertexCount||0}this.stats.get(wl).count=this.selectedTiles.length,this.stats.get(El).count=e,this.stats.get(Pl).count=r,this.stats.get(Rl).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(){try{let e=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 e;let n=this.source.getMetadata();this._syncSourceState(n),await this.source.prepareTileset?.(this),this.root||(this.root=this._initializeTileHeaders(n.tileset,null)),this._applyViewState()}catch(e){let r=e instanceof Error?e:new Error(String(e));throw this._onSourceError(r,this.root),this._onTilesetError(r),r}}_initializeStats(){this.stats.get(Io),this.stats.get(No),this.stats.get(Oo),this.stats.get(wl),this.stats.get(El),this.stats.get(Tl),this.stats.get(bl),this.stats.get(vl),this.stats.get(Pl),this.stats.get(Lo,"memory"),this.stats.get(Rl)}_initializeTileHeaders(e,r){return this.source.initializeTileHeaders(this,e,r)}_initializeTraverser(){return this.source.createTraverser({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let r=null;try{this._onStartTileLoading(),r=await e.loadContent()}catch(n){let i=n instanceof Error?n:new Error("load failed");this._onSourceError(i,e),this._onTileLoadError(e,i)}finally{this._onEndTileLoading(),this._onTileLoad(e,r)}}async _loadTileChildren(e,r){try{this._onStartTileLoading(),await e.loadChildren(r)}catch(n){let i=n instanceof Error?n:new Error("subtree load failed");this._onSourceError(i,e),this._onTileLoadError(e,i)}finally{this._onEndTileLoading()}}_onTileLoadError(e,r){this.stats.get(vl).incrementCount();let n=r.message||r.toString(),i=e.url;console.error(`A 3D tile failed to load: ${e.url} ${n}`),this.options.onTileError(e,n,i)}_onSourceError(e,r=null){this.options.onSourceError(e,this.source,r)}_onTilesetError(e){this.options.onTilesetError(e,this)}_onTileLoad(e,r){if(!r?.loaded)return;e.content&&kn(e,e.content),this.source.onTileLoaded?.(this,e,r),this._syncSourceState(this.source.getMetadata());let n=this.source.getTilesTotalCount?.();n&&(this.stats.get(Io).reset(),this.stats.get(Io).addCount(n)),this._addTileToCache(e),this.options.onTileLoad(e)}_onStartTileLoading(){this._pendingCount++,this.stats.get(No).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(No).decrementCount()}_addTileToCache(e){this._cache.add(this,e,r=>r._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(Tl).incrementCount(),this.stats.get(Oo).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(Lo).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(Oo).decrementCount(),this.stats.get(bl).incrementCount(),this.stats.get(Lo).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){let e=[];for(this.root&&e.push(this.root);e.length>0;){let r=e.pop();for(let n of r.children)e.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(e){let r=e,n=[r];for(;n.length>0;){e=n.pop();for(let i of e.children)n.push(i);e!==r&&this._destroyTile(e)}r.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_syncSourceState(e){this.tileset=e.tileset,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.refine,this.contentFormats=this.source.contentFormats,this.asset=this.source.asset||this.asset;let r=e.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 n=wt(e.spatialReference,this.options.spatial);this.spatialReference=jp(this.spatialReference,n),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 e=this.source.getViewState(this.root);this.asset=e.asset||this.source.asset||{},this.properties=e.properties??this.source.properties,this.extras=e.extras??this.source.extras??null,this.credits=e.credits||this.source.credits||this.credits||{attributions:this.options.attributions||[]},this.description=e.description||this.options.description||"",this.boundingVolume=e.boundingVolume||this.root?.boundingVolume||null,this.cartographicCenter=e.cartographicCenter||new g,this.cartesianCenter=e.cartesianCenter||null,this.zoom=e.zoom||1,this.geometricError=this.tileset?.geometricError||0}_getSourceMetadata(){try{return this.source.getMetadata()}catch{return null}}};function jp(t,e){return t?.status==="transformed"&&t.sourceCrs===e.sourceCrs&&t.targetCrs===e.targetCrs&&t.targetHeightReference===e.targetHeightReference&&t.outputCoordinates===e.outputCoordinates?t:e}function Il(t){let e=t.selectedTiles.slice(),r=t.requestedTiles.slice(),n=t.emptyTiles.slice(),i=c=>c.map(l=>String(l.id)).sort(),o=c=>{let l=t.stats.get(c).count;return typeof l=="number"&&Number.isFinite(l)?l:0},a=t.source.getImplicitTilingStats?.();return{frameNumber:t.frameNumber,selectedTileIds:i(e),requestedTileIds:i(r),emptyTileIds:i(n),visibleTileCount:e.length,renderableTileCount:e.filter(c=>c.contentAvailable&&!!c.content).length,loadingTileCount:o("Tiles Loading"),loadedTileCount:o("Tiles Loaded"),failedTileCount:o("Failed Tile Loads"),cachedTileCount:o("Tiles In Memory"),cacheBytes:t.gpuMemoryUsageInBytes,maximumScreenSpaceError:t.memoryAdjustedScreenSpaceError,...a?{implicitTiling:a}:{}}}async function*Ol(t,e={}){if(await t.tilesetInitializationPromise,Kn(e.signal),!t.root)throw new Error("Tileset initialization completed without a root tile");let r=[t.root],n=new Set;for(;r.length>0;){Kn(e.signal);let i=r.pop();if(n.has(i))continue;if(n.add(i),i.header.implicitSubtree&&i.childrenState!=="ready"){let s=t.source.loadTileChildrenForTraversal;if(!s)throw new Error("Tileset source does not support camera-independent subtree loading");if(!(await s.call(t.source,i,e.signal)).loaded)throw new Error(`Unable to load implicit subtree for tile ${i.id}`);i.childrenState="ready"}if(t.type===he.I3S&&t.source.loadTileChildrenForTraversal&&!(await t.source.loadTileChildrenForTraversal(i,e.signal)).loaded)throw new Error(`Unable to load I3S child nodes for tile ${i.id}`);Kn(e.signal);let o=i.contentUrls.length>0&&!i.content;try{if(o){let s=await i.loadContentForTraversal();if(Kn(e.signal),!s.loaded)throw new Error(`Unable to load tile content for tile ${i.id}`);t.source.onTileLoaded?.(t,i,s)}yield{tile:i,contents:i.contentEntries}}finally{e.unloadContent&&o&&i.unloadContent()}for(let s=i.children.length-1;s>=0;s--)r.push(i.children[s])}}function Kn(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted","AbortError")}var Xn=class{sourceUrl;options;archivePromise;constructor(e){this.options=e,this.sourceUrl=Wp(e.data,e.fallbackFilename)}async loadRoot(e,r,n){return await this.parseArchiveResource(e,this.options.rootPath,r,n,this.options.rootMode)}async loadResource(e,r,n){let i=this.resolveArchivePath(e,e);return await this.parseArchiveResource(e,i,r,n)}async parseArchiveResource(e,r,n,i,o){let s=this.options.getCoreApi();if(!s)throw new Error(this.options.missingCoreApiMessage);let a=await this.loadFile(r,o),c=this.createArchiveFetch(e);return await s.parse(a,n,{...i,fetch:c},{url:e,fetch:c,_parse:s.parse,loaders:[n],coreApi:s})}createArchiveFetch(e){return async r=>{let n=typeof r=="string"?r:r instanceof URL?r.toString():r.url,i=this.resolveArchivePath(n,e),o=await this.loadFile(i);return new Response(o,{status:200})}}async loadFile(e,r){this.archivePromise||=this.openArchiveReadableFile().then(i=>this.options.parseArchive(i));let n=await this.archivePromise;return await this.options.getFile(n,e,r)}async openArchiveReadableFile(){let{data:e}=this.options;if(typeof e!="string")return new zt(e);if(/^https?:\/\//i.test(e))return new pr(e);let r=this.options.getCoreApi();if(!r)throw new Error(this.options.missingCoreApiMessage);let n=await r.fetchFile(e);return new zt(await n.arrayBuffer())}resolveArchivePath(e,r){let n=Go(e),i=Go(this.sourceUrl),o=Go(r),s=o===i?i:be.dirname(o),a=new RegExp(`\\.${this.options.archiveExtension}/(.*)$`,"i"),c=n.match(a);if(c?.[1])return c[1];let l=/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith("/"),h=n.startsWith(i)?n:o===i&&!l?`${i}/${n}`:be.resolve(s,n);return h===i?"":h.startsWith(`${i}/`)?h.slice(i.length+1):h.replace(/^\/+/,"")}};function Wp(t,e){return typeof t=="string"?t:`memory://${"name"in t&&typeof t.name=="string"&&t.name?t.name:e}`}function Go(t){let e=t.indexOf("?");return e>=0?t.slice(0,e):t}function Zn(t){let e=[],r=new Set,n=i=>{if(!i||typeof i!="object"||r.has(i))return;r.add(i);let o=i,s=o.extensions?.EXT_mesh_features?.featureIds;if(Array.isArray(s))for(let a of s){if(!a||typeof a!="object")continue;let c=a.texture?"texture":a.implicit?"implicit":a.attribute!==void 0?"attribute":a.propertyTable!==void 0?"property-table":"constant";e.push({source:c,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(o))n(a)};return n(t),e}function Gl(t){return t!=null}var de=new g,Qn=new g,Nl=new G;function Ut(t,e,r,n=e){if(ke(t,"3D Tile: boundingVolume must be defined"),t.box){let i=t.s2VolumeInfo?Nl:e;return Ll(t.box,i,r)}if(t.region){let i=hr(t.region),o=e.equals(n)?Nl:e.clone().multiplyRight(n.clone().invert());return Ll([...i.center,...i.halfAxes],o,r)}if(t.sphere)return Hp(t.sphere,e,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function ql(t,e,r=!1){if(t.box||t.region&&r)return $p(e);if(t.region){let[n,i,o,s,a,c]=t.region;return[[ge(n),ge(i),a],[ge(o),ge(s),c]]}if(t.sphere)return Yp(e);throw new Error("Unkown boundingVolume type")}function Ll(t,e,r){let n=new g(t[0],t[1],t[2]);e.transform(n,n);let i=[];if(t.length===10){let l=t.slice(3,6),h=new Ne;h.fromArray(t,6);let u=new g([1,0,0]),f=new g([0,1,0]),d=new g([0,0,1]);u.transformByQuaternion(h),u.scale(l[0]),f.transformByQuaternion(h),f.scale(l[1]),d.transformByQuaternion(h),d.scale(l[2]),i=[...u.toArray(),...f.toArray(),...d.toArray()]}else i=[...t.slice(3,6),...t.slice(6,9),...t.slice(9,12)];let o=e.transformAsVector(i.slice(0,3)),s=e.transformAsVector(i.slice(3,6)),a=e.transformAsVector(i.slice(6,9)),c=new W([o[0],o[1],o[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return Gl(r)?(r.center=n,r.halfAxes=c,r):new Ye(n,c)}function Hp(t,e,r){let n=new g(t[0],t[1],t[2]);e.transform(n,n);let i=e.getScale(Qn),o=Math.max(Math.max(i[0],i[1]),i[2]),s=t[3]*o;return Gl(r)?(r.center=n,r.radius=s,r):new fe(n,s)}function $p(t){let e=zl(),{halfAxes:r}=t,n=new g(r.getColumn(0)),i=new g(r.getColumn(1)),o=new g(r.getColumn(2));for(let s=0;s<2;s++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)de.copy(t.center),de.add(n),de.add(i),de.add(o),Bl(e,de),o.negate();i.negate()}n.negate()}return e}function Yp(t){let e=zl(),{center:r,radius:n}=t,i=N.WGS84.scaleToGeodeticSurface(r,de),o;i?o=N.WGS84.geodeticSurfaceNormal(i):o=new g(0,0,1);let s=new g(o[2],-o[1],0);s.len()>0?s.normalize():s=new g(0,1,0);let a=s.clone().cross(o);for(let c of[s,a,o]){Qn.copy(c).scale(n);for(let l=0;l<2;l++)de.copy(r),de.add(Qn),Bl(e,de),Qn.negate()}return e}function zl(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Bl(t,e){N.WGS84.cartesianToCartographic(e,de),t[0][0]=Math.min(t[0][0],de[0]),t[0][1]=Math.min(t[0][1],de[1]),t[0][2]=Math.min(t[0][2],de[2]),t[1][0]=Math.max(t[1][0],de[0]),t[1][1]=Math.max(t[1][1],de[1]),t[1][2]=Math.max(t[1][2],de[2])}var qo=new g,Dl=new g,ft=new g,kl=new g,Kp=new g,zo=new G,Fl=new G;function Jn(t,e){if(t.lodMetricValue===0||Number.isNaN(t.lodMetricValue))return"DIG";let r=2*Bo(t,e);if(r<2)return"OUT";if(!t.header.children)return"DRAW";switch(t.lodMetricType){case"screenSpaceRelative":{let n=e.topDownViewport.height||1;return r/n<=t.lodMetricValue?"DRAW":"DIG"}case"distanceRangeFromDefaultCamera":return t.distanceToTile(e)>=t.lodMetricValue?"DRAW":"DIG";case"maxScreenThresholdSQ":{let n=Math.sqrt(t.lodMetricValue/(Math.PI*.25));return r<=n?"DRAW":"DIG"}default:return r<=t.lodMetricValue?"DRAW":"DIG"}}function Bo(t,e){let{topDownViewport:r}=e,n=t.header.i3sLodMbs||t.header.mbs,i=n[1],o=n[0],s=n[2],a=n[3],c=[...t.boundingVolume.center],l=r.unprojectPosition(r.cameraPosition);N.WGS84.cartographicToCartesian(l,qo),Dl.copy(qo).subtract(c).normalize(),N.WGS84.eastNorthUpToFixedFrame(c,zo),Fl.copy(zo).invert(),ft.copy(qo).transform(Fl);let h=Math.sqrt(ft[0]*ft[0]+ft[1]*ft[1]),u=h*h/ft[2];kl.copy([ft[0],ft[1],u]);let d=kl.transform(zo).subtract(c).normalize(),_=Dl.cross(d).normalize().scale(a).add(c),p=N.WGS84.cartesianToCartographic(_),M=r.project([o,i,s]),y=r.project(p);return Kp.copy(M).subtract(y).magnitude()}var wr=class{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return ke(e<this._array.length),this._array[e]}set(e,r){ke(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=r,this._map.set(r,e)}delete(e){let r=this._map.get(e);r>=0&&(this._array.splice(r,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){let r=this.length++;this._array[r]=e,this._map.set(e,r)}}pop(){let e=this._array[--this.length];return this._map.delete(e),e}reserve(e){ke(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){ke(e>=0),this.length=e}trim(e){e==null&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}};var Xp={loadSiblings:!1,skipLevelOfDetail:!1,baseScreenSpaceError:1024,skipScreenSpaceErrorFactor:16,skipLevels:1,immediatelyLoadDesiredLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Xe=class{options;disableSkipLevelOfDetail=!1;root=null;selectedTiles={};requestedTiles={};deferredTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new wr;_emptyTraversalStack=new wr;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...Xp,...e}}isSkipLevelOfDetailEnabled(){return this.options.skipLevelOfDetail&&!this.disableSkipLevelOfDetail}traverse(e,r,n){this.root=e,this.options={...this.options,...n},this.reset(),this.updateTile(e,r),this._frameNumber=r.frameNumber,this.executeTraversal(e,r)}reset(){this.requestedTiles={},this.deferredTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,r){let n=this._traversalStack;for(e._selectionDepth=1,n.push(e);n.length>0;){let i=n.pop(),o=!1;this.canTraverse(i,r)&&(this.updateChildTiles(i,r),o=this.updateAndPushChildren(i,r,n,i.hasRenderContent?i._selectionDepth+1:i._selectionDepth));let s=i.parent,a=!!(!s||s._shouldRefine),c=!o;i.hasRenderContent?i.refine===te.ADD?(this.loadTile(i,r),this.selectTile(i,r)):i.refine===te.REPLACE&&(this.loadTile(i,r),(c||this.isSkipLevelOfDetailEnabled())&&this.selectTile(i,r)):(this.emptyTiles[i.id]=i,this.loadTile(i,r),c&&this.selectTile(i,r)),this.touchTile(i,r),i._shouldRefine=o&&a}this.completeTraversal(r)}completeTraversal(e){let r=new Date().getTime();(this.traversalFinished(e)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(e))}updateChildTiles(e,r){let n=e.children;for(let i of n)this.updateTile(i,r)}updateAndPushChildren(e,r,n,i){let{loadSiblings:o}=this.options,s=this.isSkipLevelOfDetailEnabled(),a=e.children;a.sort(this.compareDistanceToCamera.bind(this));let c=e.refine===te.REPLACE&&e.hasRenderContent&&!s,l=!1,h=!0;for(let u of a)if(u._selectionDepth=i,u.isVisibleAndInRequestVolume?(n.find(u)&&n.delete(u),n.push(u),l=!0):(c||o)&&u._inRequestVolume&&(this.loadTile(u,r),this.touchTile(u,r)),c){let f;if(u._inRequestVolume?u.hasRenderContent?f=u.contentAvailable:f=this.executeEmptyTraversal(u,r):f=!1,h=h&&f,!h)return!1}return l||(h=!1),h}updateTile(e,r){this.updateTileVisibility(e,r)}selectTile(e,r){this.shouldSelectTile(e,r)&&(e._selectedFrame=r.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,r){if(this.shouldLoadTile(e)){if(this.shouldDeferTileRequest(e)){this.deferredTiles[e.id]=e;return}e._requestedFrame=r.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e}}shouldDeferTileRequest(e){return e.priorityDeferred}touchTile(e,r){e.tileset._cache.touch(e),e._touchedFrame=r.frameNumber}canTraverse(e,r){return e.hasChildren?e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,r):!1}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e,r){return e.contentAvailable&&e.contentVisibility(r)!=="outside"}shouldRefine(e,r,n=!1){let i=e._screenSpaceError;return n&&(i=e.getScreenSpaceError(r,!0)),i>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,r){let n=[];if(this.options.viewportTraversersMap)for(let i in this.options.viewportTraversersMap)this.options.viewportTraversersMap[i]===r.viewport.id&&n.push(i);else n.push(r.viewport.id);e.updateVisibility(r,n)}compareDistanceToCamera(e,r){return e._distanceToCamera-r._distanceToCamera}anyChildrenVisible(e,r){let n=!1;for(let i of e.children)i.updateVisibility(r),n=n||i.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(e,r){let n=!0,i=!1,o=this._emptyTraversalStack;for(o.push(e);o.length>0;){let s=o.pop(),a=!s.hasRenderContent&&this.canTraverse(s,r),c=!s.hasRenderContent&&s.children.length===0;if(s.header.implicitSubtree&&(i=!0,n=!1),!a&&!s.contentAvailable&&!c&&(n=!1),this.updateTile(s,r),s.isVisibleAndInRequestVolume||(this.loadTile(s,r),this.touchTile(s,r)),a){let l=s.children;for(let h of l)o.push(h)}}return e.hasEmptyContent&&!i||n}};var Do=new g;function Zp(t,e,r,n,i=[]){let o=t.length?t:[e],s=!1,a=!1;for(let c of o){let l="inside";if(n!==se.MASK_INSIDE&&(l=r.computeVisibility(c),l==="outside"))continue;let h=!1;for(let u of i)if(c.intersectPlane(u)==="outside"){h=!0;break}h||(s=!0,a=a||l==="intersecting")}return s?a?"intersecting":"inside":"outside"}function Ul(t){if(!t||typeof t!="object")return!1;let e=t;return e.shape==="tileset3d"||e.type==="tileset3d"||!!e.tileset}function Qp(t){return t!=null}var Pe=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=ae.UNLOADED;gpuMemoryUsageInBytes=0;children=[];childrenState="ready";depth=0;viewportIds=[];transform=new G;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Xe({});_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 G;_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(e,r,n,i=""){this.header=r,this.tileset=e,this.id=i||r.id,this.url=r.url,this.parent=n,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===ae.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===ae.UNLOADED}get contentExpired(){return this.contentState===ae.EXPIRED}get contentFailed(){return this.contentState===ae.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=ql(this.header.boundingVolume,this.boundingVolume,!this.computedTransform.equals(this._initialTransform))),this._boundingBox}getScreenSpaceError(e,r,n=1){switch(this.tileset.type){case he.I3S:return Bo(this,e);case he.TILES3D:return hl(this,e,r,n);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return(this.contents.length?this.contents:[this.content]).reduce((r,n)=>r+(n?.gpuMemoryUsageInBytes||n?.byteLength||0),0)}_getPriority(){return this._calculateRequestPriority(!1)}_getChildrenPriority(){return this._calculateRequestPriority(!0)}_calculateRequestPriority(e){let r=this.tileset._traverser,n=r.options.skipLevelOfDetail&&!r.disableSkipLevelOfDetail,i=this.refine===te.ADD||n;if(i&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.priorityDeferred||!e&&this.contentState===ae.UNLOADED)return-1;let o=this.parent,a=o&&(!i||this._screenSpaceError===0||o.hasTilesetContent)?o._screenSpaceError:this._screenSpaceError,c=r.root?r.root._screenSpaceError:0,l=Math.max(c-a,0);return yl({priorityProgressiveResolution:this._priorityProgressiveResolution,foveatedFactor:this._foveatedFactor,reverseScreenSpaceError:l,rootScreenSpaceError:c})}async loadContent(){if(this.hasEmptyContent)return{loaded:!1};if(this.content)return{loaded:!0};this.contentExpired&&(this._expireDate=null),this.contentState=ae.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=ae.UNLOADED,{loaded:!1};try{return await this._loadContentFromSource()}catch(n){throw this.contentState=ae.FAILED,n}finally{r.done()}}async loadContentForTraversal(){if(this.hasEmptyContent)return{loaded:!1};if(this.content)return{loaded:!0,contents:this.contents};this.contentState=ae.LOADING;try{return await this._loadContentFromSource()}catch(e){throw this.contentState=ae.FAILED,e}}async _loadContentFromSource(){let e=await this.tileset.source.loadTileContent(this);return e.contents&&(this.contents=e.contents,this.content=this.contents[0]||null),this.vectorContent=this.contents.find(r=>!!r?.vectorContent)?.vectorContent||null,this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this.contentState=ae.READY,this._onContentLoaded(),this._updateContentEntriesAfterLoad(e),e}async loadChildren(e){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(e);try{return await this._childrenPromise}finally{this._childrenPromise=null}}async _loadChildrenWithScheduler(e){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 n=await this.tileset.source.loadTileChildren(this,e);return this.childrenState=n.loaded?"ready":"unloaded",n}catch(n){throw this.childrenState="failed",n}finally{r.done()}}applyImplicitSubtreeHeader(e){let r=this.header.transform,n=this.header.transformMatrix,i=e.transform!==void 0;this.header={...this.header,...e,transform:i?e.transform:r,transformMatrix:i?e.transformMatrix:n,implicitSubtree:void 0},i&&this._initializeTransforms(this.header),this.refine=this._getRefine(e.refine),this.type=e.type,this.contentUrl=e.contentUrl,this.contentUrls=e.contentUrls||(e.contentUrl?[e.contentUrl]:[]),this._initializeMetadata(this.header),this._initializeLodMetric(e),this._updateLodMetricScale(),this._initializeBoundingVolumes(this.header),this._boundingBox=void 0,this._initializeContent(this.header),this._initializeContentEntries(this.header)}_initializeMetadata(e){this.metadata=e.metadata||null;let r=Array.isArray(e.content)?e.content:[e.content];this.contentMetadata=r.filter(Boolean).map(a=>a.metadata||null);let i=(r.find(Boolean)||{}).group,o=typeof i=="number"?this.tileset.groups?.[i]||null:i||null,s={tileset:this.tileset.metadata||null,group:o,tile:this.metadata,content:this.contentMetadata[0]||null,subtree:e.implicitMetadata||null};this.tileset.groups&&(s.groups=this.tileset.groups),this.metadataContext=s}_updateContentEntriesAfterLoad(e){if(e.contentEntries){this.contentEntries=e.contentEntries.map((r,n)=>({...r,index:n,boundingVolume:r.boundingVolume||this._contentBoundingVolumes[n]||this.boundingVolume,payload:r.payload??this.contents[n]??null,featureIds:r.featureIds?.length?r.featureIds:Zn(r.payload??this.contents[n]),renderable:!!(r.renderable!==!1&&(r.payload??this.contents[n])&&!Ul(r.payload??this.contents[n]))})),this.featureIdSets=this.contentEntries.flatMap(r=>r.featureIds);return}this.contentEntries=this.contentEntries.map((r,n)=>({...r,payload:this.contents[n]??null,featureIds:Zn(this.contents[n]),renderable:!!this.contents[n]&&!Ul(this.contents[n])})),this.featureIdSets=this.contentEntries.flatMap(r=>r.featureIds)}getContentEntry(e){return this.contentEntries[e]||null}isContentRenderable(e){return!!this.contentEntries[e]?.renderable}_initializeContentEntries(e){let r=Array.isArray(e.content)?e.content:e.content?[e.content]:[];this.contentEntries=r.map((n,i)=>{let o=n||{};return{index:i,uri:this.contentUrls[i]||o.uri||o.url,group:o.group,type:o.type,payload:null,metadata:o.metadata||null,boundingVolume:this._contentBoundingVolumes[i]||this.boundingVolume,featureIds:this._getFeatureIdSets(o),renderable:!1}})}_getFeatureIdSets(e){return Zn(e)}unloadContent(){for(let e of this.contents.length?this.contents:[this.content])e&&e.destroy&&e.destroy();return this.contents=[],this.content=null,this.vectorContent=null,this.contentEntries=this.contentEntries.map(e=>({...e,payload:null,renderable:!1})),this.featureIdSets=this.contentEntries.flatMap(e=>e.featureIds),this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=ae.UNLOADED,this.tileDrawn=!0,!0}updateVisibility(e,r){if(this._frameNumber===e.frameNumber)return;let n=this.parent,i=n?n._visibilityPlaneMask:se.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let o=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(o)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._updateRequestPriorityMetrics(e),this._visibilityPlaneMask=this.visibility(e,i),this._visible=this._visibilityPlaneMask!==se.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=r}_updateRequestPriorityMetrics(e){if(this.tileset.type!==he.TILES3D){this._screenSpaceErrorProgressiveResolution=this._screenSpaceError,this._priorityProgressiveResolution=!1,this._foveatedFactor=0,this.priorityDeferred=!1;return}let r=this.tileset.options,n=r.progressiveResolutionHeightFraction;if(this._screenSpaceErrorProgressiveResolution=this.getScreenSpaceError(e,!1,n),this._priorityProgressiveResolution=gl(this._screenSpaceErrorProgressiveResolution,this.parent?._screenSpaceErrorProgressiveResolution,this.tileset.memoryAdjustedScreenSpaceError,n),!r.foveatedScreenSpaceError||e.viewport?.orthographic||!e.camera?.position||!e.camera?.direction){this._foveatedFactor=0,this.priorityDeferred=!1;return}this._foveatedFactor=pl(this.boundingVolume,e.camera);let i=this.tileset._traverser,o=i.options.skipLevelOfDetail&&!i.disableSkipLevelOfDetail,s=_l({refinement:this.refine,skipLevelOfDetail:o,foveatedScreenSpaceError:r.foveatedScreenSpaceError,foveatedConeSize:r.foveatedConeSize,minimumScreenSpaceErrorRelaxation:r.foveatedMinimumScreenSpaceErrorRelaxation,interpolationCallback:r.foveatedInterpolationCallback,foveatedFactor:this._foveatedFactor,verticalFieldOfView:e.camera.verticalFieldOfView,screenSpaceError:this._screenSpaceError,parentScreenSpaceError:this.parent?._screenSpaceError,maximumScreenSpaceError:this.tileset.memoryAdjustedScreenSpaceError,priorityProgressiveResolution:this._priorityProgressiveResolution});this.priorityDeferred=Ml(s,e.camera.timeSinceMovement,r.foveatedTimeDelay)}visibility(e,r){let{cullingVolume:n}=e,{boundingVolume:i}=this;return n.computeVisibilityWithPlaneMask(i,r)}contentVisibility(e,r){let n=r===void 0?this._contentBoundingVolumes:this._contentBoundingVolumes[r]?[this._contentBoundingVolumes[r]]:[];return Zp(n,this.boundingVolume,e.cullingVolume,this._visibilityPlaneMask,e.clippingPlanes)}distanceToTile(e){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){let r=this.boundingVolume;return Do.subVectors(r.center,e.position),e.direction.dot(Do)}insideViewerRequestVolume(e){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(Qp(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=ae.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){this._scaleGeometricError=typeof e._scaleGeometricError=="boolean"?e._scaleGeometricError:this.parent?._scaleGeometricError??!0,"lodMetricType"in e?this.lodMetricType=e.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 e?this._unscaledLodMetricValue=e.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(e){this.transform=e.transform?new G(e.transform):new G;let r=this.parent,n=this.tileset,i=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new G(i).multiplyRight(this.transform);let o=r&&r._initialTransform?r._initialTransform.clone():new G;this._initialTransform=new G(o).multiplyRight(this.transform)}_updateLodMetricScale(){if(this.lodMetricType!==Dt.GEOMETRIC_ERROR||!this._scaleGeometricError){this.lodMetricValue=this._unscaledLodMetricValue;return}let e=this.computedTransform.getScale(Do),r=Math.max(e[0],e[1],e[2]);this.lodMetricValue=this._unscaledLodMetricValue*r}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._contentBoundingVolumeHeaders=[],this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.contents=[],this.hasEmptyContent=!0,this.contentState=ae.UNLOADED,this.hasTilesetContent=!1,(e.contentUrl||e.contentUrls?.length)&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.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=se.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(e){return e||this.parent&&this.parent.refine||te.REPLACE}_isTileset(){return(this.contents.length?this.contents:[this.content]).some(e=>e?.shape==="tileset3d")}_onContentLoaded(){let e=this.contents.length?this.contents:[this.content];for(let r of e)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(e){this._boundingBox=void 0,this.boundingVolume=Ut(e.boundingVolume,this.computedTransform,this.boundingVolume,this._initialTransform),e.viewerRequestVolume&&(this._viewerRequestVolume=Ut(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume,this._initialTransform));let r=e.content;r&&(this._contentBoundingVolumeHeaders=Array.isArray(r)?r:[r]);let n=r?Array.isArray(r)?r:[r]:this._contentBoundingVolumeHeaders;this._contentBoundingVolumes=n.length?n.map(i=>i?.boundingVolume?Ut(i.boundingVolume,this.computedTransform,void 0,this._initialTransform):this.boundingVolume):[this.boundingVolume],this._contentBoundingVolume=this._contentBoundingVolumes[0]||null}_updateTransform(e=new G){let r=e.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateLodMetricScale(),this._updateBoundingVolume(this.header))}};var ei=class extends Xe{pendingImplicitSubtrees=new Map;traversalFinished(e){let r=`${e.viewport.id}:`;for(let[n,i]of this.pendingImplicitSubtrees)if(n.startsWith(r)&&i===e.frameNumber)return!1;return!0}executeTraversal(e,r){if(!this.isSkipLevelOfDetailEnabled()){super.executeTraversal(e,r);return}this.executeSkipTraversal(e,r)}executeSkipTraversal(e,r){let n=[e];for(e._selectionDepth=e.parent?e.parent._selectionDepth:1;n.length>0;){let i=n.pop(),o=!i.parent||i.parent._shouldRefine,s=this.canTraverse(i,r)&&this.updateAndPushSkipChildren(i,r,n)&&o,a=!s&&o;i.hasRenderContent?i.refine===te.ADD?(this.loadTile(i,r),this.selectDesiredTile(i,r)):i.refine===te.REPLACE&&(this.isInBaseTraversal(i,r)?(this.loadTile(i,r),a&&this.selectDesiredTile(i,r)):a?(this.loadTile(i,r),this.selectDesiredTile(i,r)):this.hasReachedSkippingThreshold(i,r)&&this.loadTile(i,r)):(this.emptyTiles[i.id]=i,this.loadTile(i,r),a&&this.selectDesiredTile(i,r)),this.touchTile(i,r),i._shouldRefine=s}this.completeTraversal(r)}updateAndPushSkipChildren(e,r,n){this.updateChildTiles(e,r),e.children.sort(this.compareDistanceToCamera.bind(this));let i=!1;for(let o of e.children)o._selectionDepth=e.hasRenderContent?e._selectionDepth+1:e._selectionDepth,o.isVisibleAndInRequestVolume?(n.push(o),i=!0):this.options.loadSiblings&&(this.loadTile(o,r),this.touchTile(o,r));return i}isInBaseTraversal(e,r){if(this.options.immediatelyLoadDesiredLevelOfDetail)return!1;if(!this.findNearestRequestedOrLoadedAncestor(e,r))return!0;let n=Number.isFinite(this.options.baseScreenSpaceError)?Math.max(this.options.baseScreenSpaceError,0):1024,i=Math.max(n,e.tileset.memoryAdjustedScreenSpaceError);return e._screenSpaceError===0&&e.parent?e.parent._screenSpaceError>i:e._screenSpaceError>i}hasReachedSkippingThreshold(e,r){if(this.options.immediatelyLoadDesiredLevelOfDetail)return!1;if(e._priorityProgressiveResolution&&e._screenSpaceErrorProgressiveResolution<=e.tileset.memoryAdjustedScreenSpaceError&&!!(e.parent&&e.parent._screenSpaceErrorProgressiveResolution>e.tileset.memoryAdjustedScreenSpaceError))return!0;let i=this.findNearestRequestedOrLoadedAncestor(e,r);if(!i)return!1;let o=Number.isFinite(this.options.skipScreenSpaceErrorFactor)&&this.options.skipScreenSpaceErrorFactor>0?this.options.skipScreenSpaceErrorFactor:16,s=Number.isFinite(this.options.skipLevels)?Math.max(Math.floor(this.options.skipLevels),0):1;return e._screenSpaceError<i._screenSpaceError/o&&e.depth>i.depth+s}findNearestRequestedOrLoadedAncestor(e,r){let n=e.parent;for(;n;){if(n.hasRenderContent&&!n.contentFailed&&(!n.hasUnloadedContent||n._requestedFrame===r.frameNumber))return n;n=n.parent}return null}selectDesiredTile(e,r){let n=e;for(;n;){if(this.shouldSelectTile(n,r)){this.selectTile(n,r);return}n=n.parent}this.selectLoadedDescendants(e,r)}selectLoadedDescendants(e,r){let n=[{tile:e,depth:0}];for(;n.length>0;){let{tile:i,depth:o}=n.pop();for(let s of i.children)this.updateTile(s,r),s.isVisibleAndInRequestVolume&&(s.contentAvailable?(this.selectTile(s,r),this.touchTile(s,r)):o<1&&n.push({tile:s,depth:o+1}))}}compareDistanceToCamera(e,r){return r._distanceToCamera===0&&e._distanceToCamera===0?r._centerZDepth-e._centerZDepth:r._distanceToCamera-e._distanceToCamera}updateChildTiles(e,r){let n=e.header.implicitSubtree?.coordinates.level===0;if(e.hasUnloadedChildren&&e.isVisibleAndInRequestVolume&&(n||this.shouldRefine(e,r))){let i=`${r.viewport.id}:${e.id}`;this.pendingImplicitSubtrees.has(i)||(this.pendingImplicitSubtrees.set(i,r.frameNumber),e.tileset._loadTileChildren(e,r).finally(()=>{this.handleImplicitSubtreeLoad(e,r,i)}))}super.updateChildTiles(e,r)}handleImplicitSubtreeLoad(e,r,n){this.pendingImplicitSubtrees.delete(n),this._frameNumber===r.frameNumber&&(e.childrenState==="ready"?this.executeTraversal(e,r):this.traversalFinished(r)&&this.options.onTraversalEnd(r))}updateTileVisibility(e,r){if(super.updateTileVisibility(e,r),!e.isVisibleAndInRequestVolume)return;let n=e.children.length>0;if(e.hasTilesetContent&&n){let s=e.children[0];this.updateTileVisibility(s,r),e._visible=s._visible;return}if(this.meetsScreenSpaceErrorEarly(e,r)){e._visible=!1;return}let i=e.refine===te.REPLACE,o=e._optimChildrenWithinParent===ul.USE_OPTIMIZATION;if(i&&o&&n&&!this.anyChildrenVisible(e,r)){e._visible=!1;return}}meetsScreenSpaceErrorEarly(e,r){let{parent:n}=e;return!n||n.hasTilesetContent||n.refine!==te.ADD?!1:!this.shouldRefine(e,r,!0)}};var Jp=6378137,e1=6378137,ko=6356752314245179e-9,Vt=new g;function Vl(t,e){if(t instanceof Ye){let{halfAxes:r}=t,n=t1(r);return Math.log2(ko/(n+e[2]))}else if(t instanceof fe){let{radius:r}=t;return Math.log2(ko/(r+e[2]))}else if(t.width&&t.height){let{width:r,height:n}=t,i=Math.log2(Jp/r),o=Math.log2(e1/n);return(i+o)/2}return 1}function Fo(t,e,r){N.WGS84.cartographicToCartesian([t.xmax,t.ymax,t.zmax],Vt);let n=Math.sqrt(Math.pow(Vt[0]-r[0],2)+Math.pow(Vt[1]-r[1],2)+Math.pow(Vt[2]-r[2],2));return Math.log2(ko/(n+e[2]))}function jl(t,e,r){let[n,i,o,s]=t;return Fo({xmin:n,xmax:o,ymin:i,ymax:s,zmin:0,zmax:0},e,r)}function t1(t){t.getColumn(0,Vt);let e=t.getColumn(1),r=t.getColumn(2);return Vt.add(e).add(r).len()}var r1=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}),n1=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 Er(t){if(!t)return;let e=t.trim().toLowerCase().replaceAll("_","-"),r=n1[e]||e;return r1[r]}function Wl(t,e){return e!==void 0?Number.isFinite(e)&&e>0?e:void 0:t?Er(t):1}function ti(t){let e=t.spatialReference||t.fullExtent?.spatialReference,r=c1(e),n=t.heightModelInfo?.vertCRS||l1(e),i=t.heightModelInfo?.heightModel,o=t.heightModelInfo?.heightUnit,s=Wl(o,t.ZFactor),a=i==="ellipsoidal"?"ellipsoidal":i==="gravity_related_height"?"orthometric":"unknown",c=Yl(e),l=c===void 0?r?_e(r):"unknown":_e(`EPSG:${c}`),h=i1(l,o,t.ZFactor),u=[],f=o1(t.elevationInfo?.mode),d=t.elevationInfo?t.elevationInfo.unit||"meter":void 0,m=Er(d);return s===void 0&&u.push(t.ZFactor!==void 0?`I3S ZFactor ${t.ZFactor} is not a positive finite conversion factor`:`Unsupported I3S vertical unit ${o}`),t.elevationInfo&&m===void 0&&u.push(`Unsupported I3S elevation unit ${d}`),t.elevationInfo?.mode&&!f&&u.push(`Unsupported I3S elevation mode ${t.elevationInfo.mode}`),f&&f!=="absoluteHeight"&&u.push(`I3S elevation mode ${f} requires a terrain or scene elevation provider`),ve({sourceCrs:r,sourceCrsRepresentation:c!==void 0?"identifier":r?"wkt":void 0,sourceCrsAlternatives:c!==void 0&&e?.wkt?[{definition:e.wkt,representation:"wkt"}]:void 0,verticalCrs:n,units:h,verticalUnitScale:s??Number.NaN,heightReference:a,elevationMode:f,elevationOffset:t.elevationInfo?.offset,elevationUnit:d,elevationUnitScale:t.elevationInfo?.mode&&!f?Number.NaN:m??(t.elevationInfo?Number.NaN:1),coordinateFrame:l,axisOrder:r?"xyz":"unknown",provenance:r?"metadata":"unknown",warnings:u})}function i1(t,e,r){if(t==="geocentric")return["meter","meter","meter"];if(t==="geographic"&&(e||r===void 0))return["degree","degree",e||"meter"]}function o1(t){switch(t){case"absoluteHeight":case"onTheGround":case"relativeToGround":case"relativeToScene":return t;default:return}}function ri(t){let e=s1(t);if(e)return e;let r=Hl(t,"TILESET_CRS_GEOCENTRIC"),n=Hl(t,"TILESET_CRS_COORDINATE_EPOCH"),i=[],o,s="unknown",a;typeof r=="string"&&r.toUpperCase()!=="UNKNOWN"?(o=r,s="metadata",a="explicit"):r!==void 0?(i.push("3D Tiles geocentric CRS is explicitly unknown"),s="metadata",a="unknown"):t.root?.boundingVolume?.region?(o="EPSG:4978",s="format-default",a="default"):t.schemaUri&&!t.schema&&i.push("External 3D Tiles metadata schema must be loaded before CRS semantics can resolve");let c=$l(n);return n!==void 0&&c===void 0&&i.push("3D Tiles coordinate epoch is not a finite decimal year"),ve({sourceCrs:o,sourceCrsState:a,sourceCrsRepresentation:o?"identifier":void 0,coordinateEpoch:c,heightReference:o?"ellipsoidal":"unknown",coordinateFrame:o?"geocentric":"unknown",axisOrder:o?"xyz":"unknown",provenance:s,warnings:i})}function s1(t){let e=t.extensions?.EXT_geospatial_crs;if(!e)return;let r=[],n,i,o,s;if(e.format==="wkid"){let h=e.extensions?.EXT_geospatial_crs_wkid;typeof h?.authority=="string"&&Number.isInteger(h.wkid)?(n=`${h.authority}:${h.wkid}`,s="identifier",Number.isInteger(h.vcsWkid)&&(i=`${h.authority}:${h.vcsWkid}`),o=$l(h.epoch),h.epoch!==void 0&&o===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(e.format==="wkt2"){let h=e.extensions?.EXT_geospatial_crs_wkt2;typeof h?.wkt2=="string"&&h.wkt2.trim()?(n=h.wkt2,s="wkt"):r.push("EXT_geospatial_crs_wkt2 requires a nonempty wkt2 string")}else r.push(`Unsupported EXT_geospatial_crs format ${String(e.format)}`);let a=s==="wkt"?_e(n):Ro(n)||"unknown",c=a1(i);i&&!c&&r.push(`Unsupported vertical CRS ${String(i)}; vertical unit and height reference are unknown`);let l=i?c?.unit:"meter";return ve({sourceCrs:n,sourceCrsState:n?"explicit":"unknown",sourceCrsRepresentation:s,verticalCrs:i,coordinateEpoch:o,units:a==="geocentric"?["meter","meter","meter"]:a==="geographic"&&l?["degree","degree",l]:void 0,verticalUnitScale:i?c?.verticalUnitScale??Number.NaN:1,heightReference:i?c?.heightReference??"unknown":n?"ellipsoidal":"unknown",coordinateFrame:a,axisOrder:n?"xyz":"unknown",provenance:"metadata",warnings:r})}function a1(t){if(typeof t!="string")return;let e=/^EPSG:(\d+)$/i.exec(t);if(e)switch(Number(e[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 $l(t){if(typeof t!="string"&&typeof t!="number"||typeof t=="string"&&!t.trim())return;let e=Number(t);return Number.isFinite(e)?e:void 0}function c1(t){let e=Yl(t);return e!==void 0?`EPSG:${e}`:t?.wkt}function l1(t){let e=t?.latestVcsWkid??t?.vcsWkid;return e===void 0?void 0:`EPSG:${e}`}function Yl(t){return t?.latestWkid??t?.wkid}function Hl(t,e){let r=t.metadata?.class;if(!r)return;let i=t.schema?.classes?.[r]?.properties,o=t.metadata?.properties;for(let[s,a]of Object.entries(i||{}))if(a.semantic===e)return o?.[s]}var Uo=Symbol.for("@math.gl/proj4/projection-implementations");function Vo(){let t=globalThis;return t[Uo]||(t[Uo]=new WeakMap),t[Uo]}function Kl(t){return"create"in t?t:Vo().get(t)?.implementation}function Xl(t){if("create"in t)return Promise.resolve(t);let e=Vo().get(t);if(e||(e={load:()=>t.preload()},Vo().set(t,e)),e.implementation)return Promise.resolve(e.implementation);let r=e;return r.pending||(r.pending=Promise.resolve().then(r.load).then(n=>{let i=s=>s.toLowerCase().replace(/[\s_-]/g,""),o=new Set([n.name,...n.aliases||[]].map(i));if(typeof n.create!="function"||![t.name,...t.aliases||[]].every(s=>o.has(i(s))))throw new Error("Loaded projection does not match descriptor: "+t.name);return r.implementation=n,n}).catch(n=>{throw r.pending=void 0,n})),r.pending}function Ge(t,e){return{forward(r,n){let i={x:r,y:n,z:0};return t(i),[i.x,i.y]},inverse(r,n){let i={x:r,y:n,z:0};return e(i),[i.x,i.y]},forwardInPlace:t,inverseInPlace:e}}function ct(t,e,r=!1){let n=e?t.inverseInPlace:t.forwardInPlace;if(n)return n.bind(t);if(r){let o=e?t.inverse3D:t.forward3D;return s=>{let a=o.call(t,[s.x,s.y,s.z]);s.x=a[0],s.y=a[1],s.z=a[2]}}let i=e?t.inverse:t.forward;return o=>{let s=i.call(t,o.x,o.y);o.x=s[0],o.y=s[1]}}var Zl,Ql=Symbol.for("@math.gl/proj4/TypeScriptCRSError"),Re=class t extends Error{static[(Zl=Ql,Symbol.hasInstance)](e){return this!==t?Function.prototype[Symbol.hasInstance].call(this,e):e instanceof Error&&e[Ql]===!0}constructor(e,r){super(r),this.reason=e,this[Zl]=!0,this.name="TypeScriptCRSError"}};function D(t){throw new Re("missing-transform-stage",t)}function Jl(t,e){if(typeof t=="string"||"type"in t)return{definition:t,lossy:!1};let r=t,n="crs"in r?r:void 0,i="crs"in r?r.crs:r;if(i.state!=="explicit"&&i.state!=="default")throw new Re("unknown-syntax","Cannot transform an "+i.state+" CRS reference");let o=!1;return n?.coordinateEpoch!==void 0&&D("Coordinate epochs require a time-dependent transformation"),n?.vertical&&n.vertical.state!=="absent"&&(e.mode!=="horizontal"&&D("A separately declared vertical CRS requires explicit horizontal extraction"),o=!0),{definition:i.definition,spatialReference:n,lossy:o}}function eh(t,e){if(!e)return t;if(e.coordinateFrame!=="unknown"&&e.coordinateFrame!==t.kind)throw new Error("SpatialReference coordinate frame disagrees with its CRS");let r=e.coordinateOrder,n=t.kind==="geocentric"?{x:"e",y:"n",z:"u"}:{longitude:"e",lon:"e",latitude:"n",lat:"n",easting:"e",northing:"n",height:"u",altitude:"u",x:"e",y:"n",z:"u"},i;if(r.length&&(i=r.slice(0,3).map(o=>n[o.toLowerCase()]||"?").join(""),i.length===2&&(i+="u"),(i.length!==3||!i.includes("e")||!i.includes("n")||!i.includes("u"))&&D("Unsupported SpatialReference coordinate order"),(r.length>4||r.length>3&&!["m","measure"].includes(r[3]))&&D("Unsupported fourth coordinate component")),e.units?.length){let o={m:1,meter:1,metre:1,meters:1,metres:1,km:1e3,ft:.3048,"us-ft":.3048006096012192,degree:Math.PI/180,degrees:Math.PI/180,radian:1,radians:1,grad:Math.PI/200};for(let s=0;s<Math.min(e.units.length,3);s++){let a=(i||"enu")[s]==="u",c=t.kind==="geocentric"?t.toMeter:a?t.verticalUnit:t.kind==="geographic"?t.angularUnit:t.toMeter;(Math.abs((o[e.units[s]]??NaN)-c)>1e-12||o[e.units[s]]===void 0)&&D("SpatialReference units disagree with its CRS")}}return Object.freeze({...t,storedAxis:i})}var ee=Math.PI/180;function L(t,e,r){if(!Object.prototype.hasOwnProperty.call(t,e))return r;let n=t[e];if(typeof n!="string"||!/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i.test(n))throw new Error(`Invalid numeric PROJ parameter: +${e}`);let i=Number(n);if(!Number.isFinite(i))throw new Error(`Invalid numeric PROJ parameter: +${e}`);return i}function Tr(t,e){let r=L(t,e,0);if(Math.abs(r)>=90)throw new Error(`+${e} must be between -90 and 90 degrees`);return r*ee}function qe(t){if(Math.abs(t)<=Math.PI)return t;let e=2*Math.PI;return((t+Math.PI)%e+e)%e-Math.PI}var ni={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(let t in ni){let e=ni[t];e.datumName&&(ni[e.datumName]=e)}var br=ni;var h1={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"},WGS72:{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)"}},th=h1;var ye={};ye.greenwich=0;ye.lisbon=-9.131906111111;ye.paris=2.337229166667;ye.bogota=-74.080916666667;ye.madrid=-3.687938888889;ye.rome=12.452333333333;ye.bern=7.439583333333;ye.jakarta=106.807719444444;ye.ferro=-17.666666666667;ye.brussels=4.367975;ye.stockholm=18.058277777778;ye.athens=23.7163375;ye.oslo=10.722916666667;var rh=ye;var nh={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 ih={WGS84:"+proj=longlat +datum=WGS84","EPSG:4326":"+proj=longlat +datum=WGS84","EPSG:4269":"+proj=longlat +datum=NAD83","EPSG:4978":"+proj=geocent +datum=WGS84","EPSG:4979":"+proj=longlat +datum=WGS84","EPSG:3857":"+proj=merc +a=6378137 +b=6378137 +nadgrids=@null +units=m","EPSG:3785":"EPSG:3857",GOOGLE:"EPSG:3857","EPSG:900913":"EPSG:3857","EPSG:102113":"EPSG:3857"},ii=["proj","datum","ellps","a","b","rf","f","R","units","to_meter","vunits","vto_meter","no_defs","type","title","towgs84","nadgrids","geoidgrids","axis","pm","over","lon_wrap"],lh=["no_defs","over"],Ze=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),oh=t=>t.toLowerCase().replace(/[\s_-]/g,"");function jo(t,e){let r=Object.keys(t).find(n=>oh(n)===oh(e));return r===void 0?void 0:t[r]}function sh(t){if(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(t)){let r=Number(t);if(Number.isFinite(r))return r}if(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?r$/i.test(t)){let r=Number(t.slice(0,-1))/ee;if(Number.isFinite(r))return r}let e=/^([+-]?)(\d+(?:\.\d*)?)(?:d(?:(\d+(?:\.\d*)?)'(?:(\d+(?:\.\d*)?)")?)?)?([NSEW])?$/i.exec(t);if(e&&(/d/i.test(t)||e[5])){let r=Number(e[3]||0),n=Number(e[4]||0);if(r<60&&n<60){let i=e[1]==="-"?-1:1,o=/[SW]/i.test(e[5]||"")?-1:1,s=i*o*(Number(e[2])+r/60+n/3600);if(Number.isFinite(s))return s}}throw new Error("Invalid angular parameter: "+t)}function vr(t,e={}){let r=Jl(t,e),n=r.definition,i=e.aliases||{},o=new Set;for(;typeof n=="string"&&(Ze(i,n)||Ze(ih,n));){if(o.has(n))throw new Error("Circular CRS alias: "+n);o.add(n),n=Ze(i,n)?i[n]:ih[n]}if(typeof n=="string"){let v=/^EPSG:(326|327)(\d{2})$/.exec(n);v&&Number(v[2])>=1&&Number(v[2])<=60&&(n="+proj=utm +datum=WGS84 +zone="+Number(v[2])+(v[1]==="327"?" +south":"")),(n==="EPSG:5041"||n==="EPSG:5042")&&(n="+proj=stere +datum=WGS84 +lat_0="+(n==="EPSG:5041"?90:-90)+" +k_0=0.994 +x_0=2000000 +y_0=2000000")}let s;if(Me(n)==="proj-string"&&typeof n=="string"){let v=Object.create(null);for(let A of Mr(n).parameters){if(Ze(v,A.name))throw new Error("Duplicate PROJ parameter: +"+A.name);v[A.name]=A.value}s={parameters:v}}else{let v=e.parsers?.find(A=>A.canParse(n));if(!v){let A=["wkt","projjson"].includes(Me(n));throw new Re(A?"missing-parser":"unknown-syntax","Unsupported CRS definition; register a WKT or PROJJSON parser for structured definitions")}s=v.parse(n,e)}let a={...s.parameters};for(let v of["lon_0","lat_0","lat_1","lat_2","lat_ts","lon_wrap","lon_1","lon_2","lonc","alpha","gamma","tilt","azi","o_alpha","o_lon_c","o_lat_c","o_lon_p","o_lat_p","o_lon_1","o_lat_1","o_lon_2","o_lat_2"])a[v]!==void 0&&(a[v]=String(sh(a[v])));let c=a.proj,l=c?.toLowerCase(),h=l==="geocentric"?"geocent":["longlat","latlong","latlon","lonlat","identity","geocent"].includes(l)?l:c;if(!h)throw new Error("CRS requires +proj");let u=["longlat","latlong","latlon","lonlat"].includes(h)?"geographic":h==="geocent"?"geocentric":h==="identity"?"identity":"projected",f=a.datum,d=f&&f!=="none"?jo(br,f):void 0;f&&f!=="none"&&!d&&D("Unknown datum: "+f);let m=ch(a,d?.ellipse),_=a.nadgrids??d?.nadgrids,p=_===void 0?void 0:_.split(",").map(v=>{let A=v.startsWith("@"),I=A?v.slice(1):v;if(!I||/\s/.test(I))throw new Error("Invalid datum grid name");return Object.freeze({name:I,optional:A})}),M=a.towgs84??d?.towgs84,y;if(M!==void 0&&(y=M.split(",").map(v=>L({value:v},"value",NaN)),![3,7].includes(y.length)||y.some(v=>!Number.isFinite(v))||y.length===7&&y[6]<=-1e6))throw new Error("+towgs84 requires three or seven finite values and positive scale");f==="none"&&(y=void 0),p&&f!=="none"&&(y=[0,0,0]);let S=_==="@null"||_==="null"?ch({ellps:"WGS84"}):m,x=a.axis||"enu";if(x.length!==3||!/[ew]/.test(x)||!/[ns]/.test(x)||!/[ud]/.test(x))throw new Error("Invalid axis: "+x);let E=s.angularUnit??ee;if(u==="geographic"&&(a.units&&a.units!=="degrees"||Ze(a,"to_meter")))throw new Error("Geographic coordinates must use angular units");if(u!=="geographic"&&a.units==="degrees")throw new Error("Linear coordinates require linear units");let T=ah(a,"units","to_meter"),R=s.verticalUnit??ah(a,"vunits","vto_meter");if(!(R>0)||!Number.isFinite(R))throw new Error("Invalid vertical unit");if(!(E>0)||!Number.isFinite(E))throw new Error("Invalid angular unit");let C=a.pm,O=C===void 0?0:(jo(rh,C)??sh(C))*ee;return eh(Object.freeze({kind:u,projection:h,parameters:Object.freeze(a),ellipsoid:m,datum:Object.freeze({ellipsoid:S,towgs84:y&&Object.freeze(y),grids:f==="none"||_==="@null"||_==="null"?void 0:p&&Object.freeze(p)}),angularUnit:E,toMeter:T,verticalUnit:R,primeMeridian:O,axis:x,longitudeWrap:a.lon_wrap===void 0?void 0:Number(a.lon_wrap)*ee,lossy:!!(s.lossy||r.lossy)}),r.spatialReference)}function ah(t,e,r){let n=t[e],i=nh;if(e==="vunits"&&n==="degrees")throw new Error("Height requires linear units");if(n&&!["m","degrees"].includes(n)&&!Ze(i,n))throw new Error("Unsupported units: "+n);let o=L(t,r,n&&i[n]?i[n].to_meter:1);if(!(o>0))throw new Error("+"+r+" must be positive");return o}function ch(t,e){let r=e||t.ellps||"WGS84",n=jo(th,r);if(!n)throw new Error("Unsupported ellipsoid: "+r);let i=L(t,"a",n.a),o=L(t,"f",NaN),s=L(t,"rf",Number.isNaN(o)?n.rf||0:o===0?0:1/o),a=L(t,"b",s?i*(1-1/s):Ze(t,"f")||Ze(t,"rf")||Ze(t,"a")?i:n.b||i),c=L(t,"R",0);if(i<=0||a<=0||a>i||s<0||s>0&&s<=1||Ze(t,"R")&&c<=0||!Number.isNaN(o)&&(o<0||o>=1))throw new Error("Invalid ellipsoid dimensions");return Object.freeze({semiMajorAxis:c||i,semiMinorAxis:c||a,eccentricitySquared:c?0:1-(a/i)**2})}var Wo=Math.PI/648e3,oi={ellipsoid:{semiMajorAxis:6378137,semiMinorAxis:6356752314245179e-9,eccentricitySquared:.0066943799901413165},towgs84:[0,0,0]};function ai(t,e){let r=t.x,n=t.y,i=t.z,{semiMajorAxis:o,eccentricitySquared:s}=e;if(Math.abs(n)>Math.PI/2)throw new Error("Latitude outside geocentric domain");let a=Math.sin(n),c=Math.cos(n),l=o/Math.sqrt(1-s*a*a);t.x=(l+i)*c*Math.cos(r),t.y=(l+i)*c*Math.sin(r),t.z=(l*(1-s)+i)*a}function ci(t,e){let r=t.x,n=t.y,i=t.z,{semiMajorAxis:o,semiMinorAxis:s,eccentricitySquared:a}=e,c=Math.hypot(r,n),l=Math.hypot(r,n,i);if(l===0)throw new Error("Geodetic coordinates are undefined at the Earth center");if(c<1e-12*o){t.x=0,t.y=Math.sign(i)*Math.PI/2,t.z=Math.abs(i)-s;return}let h=i/l,u=c/l,f=1/Math.sqrt(1-a*(2-a)*u*u),d=u*(1-a)*f,m=h*f;for(let _=0;_<30;_++){let p=o/Math.sqrt(1-a*m*m),M=c*d+i*m-p*(1-a*m*m),y=a*p/(p+M);f=1/Math.sqrt(1-y*(2-y)*u*u);let S=u*(1-y)*f,x=h*f;if(Math.abs(x*d-S*m)<=1e-12){t.x=Math.atan2(n,r),t.y=Math.atan2(x,Math.abs(S)),t.z=M;return}d=S,m=x}throw new Error("Geocentric inverse did not converge")}function hh(t,e){let r=t[0],n=t[1],i=t[2],o=(t[3]||0)*Wo,s=(t[4]||0)*Wo,a=(t[5]||0)*Wo,c=1+(t[6]||0)/1e6;return e?l=>{let h=(l.x-r)/c,u=(l.y-n)/c,f=(l.z-i)/c;l.x=h+a*u-s*f,l.y=-a*h+u+o*f,l.z=s*h-o*u+f}:l=>{let h=l.x,u=l.y,f=l.z;l.x=c*(h-a*u+s*f)+r,l.y=c*(a*h+u-o*f)+n,l.z=c*(-s*h+o*u+f)+i}}function si(t){return!!t.towgs84?.some(e=>e!==0)}function $o(t,e){if(!(!t.towgs84||!e.towgs84)){if(t.grids||e.grids){if(t.grids&&e.grids&&t.ellipsoid.semiMajorAxis===e.ellipsoid.semiMajorAxis&&t.ellipsoid.eccentricitySquared===e.ellipsoid.eccentricitySquared&&t.grids.length===e.grids.length&&t.grids.every((n,i)=>n.name===e.grids[i].name&&n.optional===e.grids[i].optional&&n.grid===e.grids[i].grid))return;let r=$o(t.grids?oi:t,e.grids?oi:e);return n=>{t.grids&&uh(n,t,!1),r?.(n),e.grids&&uh(n,e,!0)}}if(si(t)||si(e)){let r=Ho(t,oi),n=Ho(oi,e);return i=>{r?.(i),n?.(i)}}return Ho(t,e)}}function Ho(t,e){if(!t.towgs84||!e.towgs84)return;let r=t.ellipsoid,n=e.ellipsoid,i=!0;for(let a=0;a<7;a++)(t.towgs84[a]||0)!==(e.towgs84[a]||0)&&(i=!1);if(r.semiMajorAxis===n.semiMajorAxis&&Math.abs(r.eccentricitySquared-n.eccentricitySquared)<=5e-11&&i)return;let o=si(t)?hh(t.towgs84,!1):void 0,s=si(e)?hh(e.towgs84,!0):void 0;return a=>{ai(a,r),o?.(a),s?.(a),ci(a,n)}}function uh(t,e,r){for(let n of e.grids){if(n.name==="null")return;if(!n.grid){if(n.optional)continue;throw new Error("Required datum grid is not registered: "+n.name)}let i=!1;if(n.grid.shiftInPlace)i=n.grid.shiftInPlace(t,r);else{let o=n.grid.shift(t.x,t.y,r);o&&(t.x=o[0],t.y=o[1],i=!0)}if(i){if(!Number.isFinite(t.x)||!Number.isFinite(t.y)||Math.abs(t.y)>Math.PI/2)throw new Error("Datum grid produced a coordinate outside the geographic domain");return}}throw new Error("No datum grid covers coordinate: "+e.grids.map(n=>n.name).join(","))}function fh(t,e){let r={x:t[0],y:t[1],z:t[2]};return ai(r,e),[r.x,r.y,r.z]}function dh(t,e){let r={x:t[0],y:t[1],z:t[2]};return ci(r,e),[r.x,r.y,r.z]}function mh(t,e={}){if(t===void 0)return;let r=[];for(let n of t.split(",")){let i=n.startsWith("@"),o=i?n.slice(1):n;if(!o||/\s/.test(o))throw new Error("Invalid vertical grid name");if(o==="null"){r.push(null);break}let s=Object.prototype.hasOwnProperty.call(e,o)?e[o]:void 0;if(s){if(typeof s.getOffset!="function")throw new Error("Invalid vertical grid: "+o);r.push(s.getOffset.bind(s))}else i||D("Required vertical grid is not registered: "+o)}return(n,i)=>{for(let o of r){if(!o)return 0;let s=o(n,i);if(s!==void 0){if(!Number.isFinite(s))throw new Error("Vertical grid returned a non-finite offset");return s}}throw new Error("No vertical grid covers this coordinate")}}var ui=class t{static async create(e={}){let r=await Promise.all(ph(e).map(Xl));return new t({...e,projections:r})}constructor(e={}){let r=e.projections||[],n=yh(r);if(r.some(i=>!("create"in i))){let i=vr(e.from??"WGS84",e),o=vr(e.to??"WGS84",e);this.lossy=i.lossy||o.lossy,this.deferred={options:{...e,projections:[...r]}}}else{let i=e,o=n,s=gh(i.from??"WGS84",o,i),a=gh(i.to??"WGS84",o,i);this.lossy=s.lossy||a.lossy,this.lossy&&(s.kind==="geocentric"||a.kind==="geocentric")&&D("Horizontal extraction cannot supply ellipsoidal height for geocentric coordinates"),this.lossy&&(s.verticalGrid||a.verticalGrid)&&D("Horizontal extraction cannot be combined with vertical grids"),this.forwardTransform=Mh(s,a,!!e.enforceAxis),this.inverseTransform=Mh(a,s,!!e.enforceAxis)}this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this),this.projectSync=this.projectSync.bind(this),this.unprojectSync=this.unprojectSync.bind(this),this.projectFlatSync=this.projectFlatSync.bind(this),this.unprojectFlatSync=this.unprojectFlatSync.bind(this)}load(){let e=this.deferred;return e?e.implementation?Promise.resolve(e.implementation):(e.pending||(e.pending=t.create(e.options).then(r=>(e.implementation=r,r)).catch(r=>{throw e.pending=void 0,r})),e.pending):Promise.resolve(this)}loadSync(){let e=this.deferred;if(!e)return this;if(!e.implementation){let r=ph(e.options).map(n=>{let i=Kl(n);if(!i)throw new Error("Projection is not preloaded: "+n.name+". Call preload() first.");return i});e.implementation=new t({...e.options,projections:r})}return e.implementation}projectSync(e){return this.deferred?this.loadSync().project(e):li(e,this.forwardTransform)}unprojectSync(e){return this.deferred?this.loadSync().unproject(e):li(e,this.inverseTransform)}projectFlatSync(e,r=2){return this.deferred?this.loadSync().projectFlat(e,r):hi(e,r,this.forwardTransform)}unprojectFlatSync(e,r=2){return this.deferred?this.loadSync().unprojectFlat(e,r):hi(e,r,this.inverseTransform)}async preload(){await this.load()}project(e){return this.deferred?this.projectLoaded(e,!1):li(e,this.forwardTransform)}unproject(e){return this.deferred?this.projectLoaded(e,!0):li(e,this.inverseTransform)}projectLoaded(e,r){let n=e.slice();return this.load().then(i=>r?i.unproject(n):i.project(n))}projectFlat(e,r=2){return this.deferred?this.load().then(i=>i.projectFlat(e,r)):hi(e,r,this.forwardTransform)}unprojectFlat(e,r=2){return this.deferred?this.load().then(i=>i.unprojectFlat(e,r)):hi(e,r,this.inverseTransform)}};function ph(t){let e=yh(t.projections||[]),r=new Set;for(let n of[t.from??"WGS84",t.to??"WGS84"]){let i=vr(n,t);if(["geographic","identity"].includes(i.kind))continue;let o=e.get(fi(i.projection));if(!o)throw new Re("missing-plugin","Projection plugin is not registered: "+i.projection);r.add(o)}return[...r]}var fi=t=>t.toLowerCase().replace(/[\s_-]/g,"");function yh(t){let e=new Map;for(let r of t)for(let n of new Set([r.name,...r.aliases||[]].map(fi))){if(!n||["longlat","latlong","latlon","lonlat","identity"].includes(n)||e.has(n))throw new Error("Duplicate or reserved projection plugin: "+n);e.set(n,r)}return e}function gh(t,e,r){let n=vr(t,r),i=e.get(fi(n.projection));if(!["geographic","identity"].includes(n.kind)&&!i)throw new Re("missing-plugin","Projection plugin is not registered: "+n.projection);let o=new Set([...ii,...i?.parameters||[]]);for(let d of Object.keys(n.parameters)){if(!o.has(d))throw new Re("missing-transform-stage","Unsupported PROJ parameter: +"+d);let m=lh.includes(d)||i?.flags?.includes(d);if(m&&n.parameters[d]!==void 0)throw new Error("Expected a flag without a value: +"+d);if(!m&&!n.parameters[d])throw new Error("PROJ parameter requires a value: +"+d)}if(n.parameters.type&&n.parameters.type!=="crs")throw new Error("Only +type=crs is supported");let s=fi(n.projection)==="fasttransversemercator"?Object.freeze({...n.parameters,approx:void 0}):n.parameters,a=i?.create({...n.ellipsoid,parameters:s});if(n.kind==="geocentric"&&(!a?.forward3D||!a?.inverse3D))throw new Error("Geocentric plugin must implement 3D operations");let c=n.datum.grids,l=c?.findIndex(d=>d.name==="null")??-1,h=c?.slice(0,l<0?void 0:l+1).map(d=>{let m=Object.prototype.hasOwnProperty.call(r.datumGrids||{},d.name)?r.datumGrids[d.name]:void 0;if(m&&typeof m.shift!="function")throw new Error("Invalid prepared datum grid: "+d.name);return Object.freeze({...d,grid:m})});for(let d of h||[]){if(d.name==="null")break;!d.optional&&!d.grid&&D("Required datum grid is not registered: "+d.name)}let u=h?Object.freeze({...n.datum,grids:Object.freeze(h)}):n.datum,f=mh(n.parameters.geoidgrids,r.verticalGrids);return f&&(n.kind==="geocentric"||n.kind==="identity"||n.lossy)&&D("Vertical grids require a non-lossy geographic or projected CRS"),{...n,datum:u,implementation:a,verticalGrid:f}}function Yo(t){return Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.z)}function _h(t,e){if(t==="enu")return;let r=[0,0,0],n=[0,0,0];for(let i=0;i<3;i++){let o=t[i],s="ew".includes(o)?0:"ns".includes(o)?1:2;r[e?i:s]=e?s:i,n[e?i:s]="wsd".includes(o)?-1:1}return i=>{let o=i.x,s=i.y,a=i.z;i.x=n[0]*(r[0]===0?o:r[0]===1?s:a),i.y=n[1]*(r[1]===0?o:r[1]===1?s:a),i.z=n[2]*(r[2]===0?o:r[2]===1?s:a)}}function Mh(t,e,r){let n=t.storedAxis||(r?t.axis:"enu"),i=e.storedAxis||(r?e.axis:"enu"),o=_h(n,!1),s=_h(i,!0),a=t.implementation&&ct(t.implementation,!0,t.kind==="geocentric"),c=e.implementation&&ct(e.implementation,!1,e.kind==="geocentric"),l=$o(t.datum,e.datum),h=t.lossy||e.lossy,u=t.kind==="geocentric",f=t.kind==="geographic"?t.angularUnit:t.toMeter,d=e.kind==="geographic"?e.angularUnit:e.toMeter,m=u?1:t.verticalUnit,_=e.kind==="geocentric"?d:e.verticalUnit,p=t.primeMeridian,M=e.primeMeridian,y=e.kind==="geographic"?e.longitudeWrap:void 0,S;if(!l&&!t.verticalGrid&&!e.verticalGrid&&!h&&!o&&!s&&!p&&!M&&t.verticalUnit===1&&e.verticalUnit===1&&y===void 0){let x=Object.freeze({inputScale:f,outputScale:d});t.kind==="geographic"&&e.kind==="projected"&&(S=e.implementation?.createForwardFlat?.(x)),t.kind==="projected"&&e.kind==="geographic"&&(S=t.implementation?.createInverseFlat?.(x))}return{flat:S,requiresInputZ:!!(t.verticalGrid||e.verticalGrid)||t.kind==="geocentric"||/[ud]/.test(n.slice(0,2))||/[ud]/.test(i.slice(0,2)),geocentricOutput:e.kind==="geocentric",run(x){if(!Yo(x))throw new Error("Coordinates must contain finite x, y and optional z values");o?.(x);let E=x.z;if(h&&(x.z=0),f!==1&&(x.x*=f,x.y*=f,u&&(x.z*=f)),a?.(x),m!==1&&(x.z*=m),Math.abs(x.y)>Math.PI/2||!Yo(x))throw new Error("Coordinate is outside the geographic domain");if(x.x+=p,t.verticalGrid&&(x.z+=t.verticalGrid(x.x,x.y)),l?.(x),e.verticalGrid&&(x.z-=e.verticalGrid(x.x,x.y)),x.x-=M,y!==void 0&&(x.x=y+qe(x.x-y)),c?.(x),d!==1&&(x.x/=d,x.y/=d),_!==1&&(x.z/=_),h&&(x.z=E),s?.(x),!Yo(x))throw new Error("Projection produced non-finite coordinates")}}}function li(t,e){if(t.length<2)throw new Error("Coordinates must contain finite x, y and optional z values");if(t.length<3&&e.requiresInputZ)throw new Error("This transform requires three ordinates");let r={x:t[0],y:t[1],z:t.length>=3?t[2]:0};e.run(r);let n=t.slice();return n[0]=r.x,n[1]=r.y,(t.length>=3||e.geocentricOutput)&&(n[2]=r.z),n}function hi(t,e,r){if(!(t instanceof Float32Array||t instanceof Float64Array))throw new Error("In-place projection requires a Float32Array or Float64Array");if(!Number.isSafeInteger(e)||e<2||t.length%e!==0)throw new Error("Dimension must be an integer >= 2 and divide the typed array length");if(e<3&&(r.requiresInputZ||r.geocentricOutput))throw new Error("This transform requires a dimension of at least 3");if(r.flat)return r.flat(t,e),t;let n={x:0,y:0,z:0},i=t instanceof Float32Array;for(let o=0;o<t.length;o+=e){if(n.x=t[o],n.y=t[o+1],n.z=e>=3?t[o+2]:0,r.run(n),i&&(Math.abs(n.x)>34028234663852886e22||Math.abs(n.y)>34028234663852886e22||e>=3&&Math.abs(n.z)>34028234663852886e22))throw new Error("Projected coordinate exceeds Float32 range");t[o]=n.x,t[o+1]=n.y,e>=3&&(t[o+2]=n.z)}return t}function Fe(t,e){return{...Ge(t,e),createForwardFlat(r){return this.forwardInPlace===t?xh(t,!1,r):void 0},createInverseFlat(r){return this.inverseInPlace===e?xh(e,!0,r):void 0}}}function xh(t,e,{inputScale:r,outputScale:n}){return(i,o)=>{let s={x:0,y:0,z:0},a=i instanceof Float32Array;for(let c=0;c<i.length;c+=o){if(s.x=i[c],s.y=i[c+1],s.z=o>=3?i[c+2]:0,!Number.isFinite(s.x)||!Number.isFinite(s.y)||!Number.isFinite(s.z))throw new Error("Coordinates must contain finite x, y and optional z values");if(r!==1&&(s.x*=r,s.y*=r),e&&t(s),Math.abs(s.y)>Math.PI/2||!Number.isFinite(s.x)||!Number.isFinite(s.y))throw new Error("Coordinate is outside the geographic domain");if(s.x+=0,s.x-=0,e||t(s),n!==1&&(s.x/=n,s.y/=n),!Number.isFinite(s.x)||!Number.isFinite(s.y))throw new Error("Projection produced non-finite coordinates");if(a&&(Math.abs(s.x)>34028234663852886e22||Math.abs(s.y)>34028234663852886e22))throw new Error("Projected coordinate exceeds Float32 range");i[c]=s.x,i[c+1]=s.y}}}var Ko={name:"merc",aliases:["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","Mercator_Variant_A"],parameters:["lon_0","lat_ts","k","k_0","x_0","y_0"],create({semiMajorAxis:t,eccentricitySquared:e,parameters:r}){let n=Math.sqrt(e),i=Object.prototype.hasOwnProperty.call(r,"over")?h=>h:qe,o=L(r,"lon_0",0)*ee,s=L(r,"x_0",0),a=L(r,"y_0",0),c=L(r,"k_0",L(r,"k",1));if(Object.prototype.hasOwnProperty.call(r,"lat_ts")){let h=Tr(r,"lat_ts");c=Math.cos(h)/Math.sqrt(1-e*Math.sin(h)**2)}if(c<=0)throw new Error("Mercator scale must be positive");let l=t*c;return Fe(h=>{let u=h.x,f=h.y;if(Math.abs(f)>=Math.PI/2)throw new Error("Mercator is undefined at the poles");let d=Math.asinh(Math.tan(f));h.x=s+l*i(u-o),h.y=a+l*(n===0?d+0:d-n*Math.atanh(n*Math.sin(f)))},h=>{let u=h.x,d=(h.y-a)/l,m=Math.atan(Math.sinh(d));if(n===0){h.x=i(o+(u-s)/l),h.y=m+0;return}for(let _=0;_<30;_++){let p=Math.atan(Math.sinh(d+n*Math.atanh(n*Math.sin(m))));if(Math.abs(p-m)<1e-13){h.x=i(o+(u-s)/l),h.y=p;return}m=p}throw new Error("Mercator inverse did not converge")})}};var Xo={name:"eqc",aliases:["Equirectangular","Equidistant_Cylindrical","Equidistant_Cylindrical_Spherical"],parameters:["lon_0","lat_0","lat_ts","x_0","y_0"],create({semiMajorAxis:t,parameters:e}){let r=Object.prototype.hasOwnProperty.call(e,"over")?c=>c:qe,n=L(e,"lon_0",0)*ee,i=Tr(e,"lat_0"),o=Math.cos(Tr(e,"lat_ts")),s=L(e,"x_0",0),a=L(e,"y_0",0);return Ge(c=>{c.x=s+t*o*r(c.x-n),c.y=a+t*(c.y-i)},c=>{c.x=r(n+(c.x-s)/(t*o)),c.y=i+(c.y-a)/t})}};var ue=["lon_0","lat_0","x_0","y_0"],lt=["k","k_0"];function dt(t,e,r=0){let n=L(t,e,r);if(e!=="lon_0"&&Math.abs(n)>90)throw new Error("Latitude parameter must be between -90 and 90 degrees: +"+e);return n*ee}function Ue(t,e){let r=Object.prototype.hasOwnProperty.call(t,e);if(r&&t[e]!==void 0)throw new Error("Expected a flag without a value: +"+e);return r}function ce({semiMajorAxis:t,eccentricitySquared:e,parameters:r}){let n=L(r,"k_0",L(r,"k",1));if(n<=0)throw new Error("Projection scale must be positive");return{a:t,b:t*Math.sqrt(1-e),es:e,e:Math.sqrt(e),ep2:e/(1-e),sphere:e===0,over:Ue(r,"over"),long0:dt(r,"lon_0"),lat0:dt(r,"lat_0"),lat1:dt(r,"lat_1"),lat2:dt(r,"lat_2",L(r,"lat_1",0)),lat_ts:dt(r,"lat_ts",NaN),x0:L(r,"x_0",0),y0:L(r,"y_0",0),k0:n}}function jt(t,e){if(!Object.prototype.hasOwnProperty.call(e,"lat_1"))throw new Error("Conic projections require +lat_1");if(Math.abs(t.lat1+t.lat2)<1e-10||Math.abs(t.lat1)>=Math.PI/2||Math.abs(t.lat2)>=Math.PI/2)throw new Error("Conic standard parallels must not be opposite or at a pole")}function ie(t,e,r,n,i=Ge){let o=(s,a)=>{let c=s(e,a);if(!c||typeof c!="object"||!Number.isFinite(c.x)||!Number.isFinite(c.y))throw new Error(t+": coordinate outside projection domain or inverse did not converge");a.x=c.x,a.y=c.y};return i(s=>o(r,s),s=>o(n,s))}function mt(t,e){let r=ct(e,!1);return Ge(n=>{let i=n.x,o=n.y,s=Math.atan2(Math.sin(i-t.long0),Math.cos(i-t.long0)),a=Math.abs(Math.abs(t.lat0)-Math.PI/2)<1e-10;if(Math.abs(o+t.lat0)<1e-10&&(a||Math.abs(Math.abs(s)-Math.PI)<1e-10))throw new Error("Azimuthal projection is undefined at the antipode");r(n)},ct(e,!0))}function xe(t,e,r){var n=t*e;return r/Math.sqrt(1-n*n)}var w=Math.PI/2,F=Math.PI/4,pt=Math.PI*2,X=3.14159265359,Zo=Math.PI/180,Qo=180/Math.PI,Jo=Math.PI/(180*3600);function Ce(t,e,r){var n=t*r,i=.5*t;return n=Math.pow((1-n)/(1+n),i),Math.tan(.5*(w-e))/n}function Qe(t){return t<0?-1:1}function b(t,e){return e||Math.abs(t)<=X?t:t-Qe(t)*pt}function Et(t,e){for(var r=.5*t,n,i,o=w-2*Math.atan(e),s=0;s<=15;s++)if(n=t*Math.sin(o),i=w-2*Math.atan(e*Math.pow((1-n)/(1+n),r))-o,o+=i,Math.abs(i)<=1e-10)return o;return-9999}function u1(t){if(t.k0||(t.k0=1),t.x0=t.x0||0,t.y0=t.y0||0,t.long0=t.long0||0,!(Math.abs(t.lat1+t.lat2)<1e-10)){var e=t.b/t.a;t.e=Math.sqrt(1-e*e);var r=Math.sin(t.lat1),n=Math.cos(t.lat1),i=xe(t.e,r,n),o=Ce(t.e,t.lat1,r),s=Math.sin(t.lat2),a=Math.cos(t.lat2),c=xe(t.e,s,a),l=Ce(t.e,t.lat2,s),h=Ce(t.e,t.lat0,Math.sin(t.lat0));Math.abs(t.lat1-t.lat2)>1e-10?t.ns=Math.log(i/c)/Math.log(o/l):t.ns=r,Number.isNaN(t.ns)&&(t.ns=r),t.f0=i/(t.ns*Math.pow(o,t.ns)),t.rh=Math.abs(Math.abs(t.lat0)-w)<1e-10?0:t.a*t.f0*Math.pow(h,t.ns)}}function Sh(t,e){var r=e.x,n=e.y;Math.abs(2*Math.abs(n)-Math.PI)<=1e-10&&(n=Qe(n)*(w-2*1e-10));var i=Math.abs(Math.abs(n)-w),o,s;if(i>1e-10)o=Ce(t.e,n,Math.sin(n)),s=t.a*t.f0*Math.pow(o,t.ns);else{if(i=n*t.ns,i<=0)return null;s=0}var a=t.ns*b(r-t.long0,t.over);return e.x=t.k0*(s*Math.sin(a))+t.x0,e.y=t.k0*(t.rh-s*Math.cos(a))+t.y0,e}function wh(t,e){var r,n,i,o,s,a=(e.x-t.x0)/t.k0,c=t.rh-(e.y-t.y0)/t.k0;t.ns>0?(r=Math.sqrt(a*a+c*c),n=1):(r=-Math.sqrt(a*a+c*c),n=-1);var l=0;if(r!==0&&(l=Math.atan2(n*a,n*c)),r!==0||t.ns>0){if(n=1/t.ns,i=Math.pow(r/(t.a*t.f0),n),o=Et(t.e,i),o===-9999)return null}else o=-w;return s=b(l/t.ns+t.long0,t.over),e.x=s,e.y=o,e}function Eh(t){let e={...t,ns:0,f0:0,rh:0};return u1(e),e}var es={name:"lcc",aliases:["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_1SP","Lambert_Conformal_Conic_2SP","Lambert Conic Conformal (1SP)","Lambert Conic Conformal (2SP)"],parameters:[...ue,...lt,"lat_1","lat_2"],create(t){let e=ce(t);jt(e,t.parameters);let r=Eh(e),n=ie("lcc",r,Sh,wh);return Fe(i=>{let o=i.y;if(Math.abs(o)===Math.PI/2&&o*r.ns<0)throw new Error("Lambert conformal conic is undefined at the opposite pole");n.forwardInPlace(i)},n.inverseInPlace)}};function Se(t,e){var r;return t>1e-7?(r=t*e,(1-t*t)*(e/(1-r*r)-.5/t*Math.log((1-r)/(1+r)))):2*e}function we(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}function f1(t){Math.abs(t.lat1+t.lat2)<1e-10||(t.temp=t.b/t.a,t.es=1-Math.pow(t.temp,2),t.e3=Math.sqrt(t.es),t.sin_po=Math.sin(t.lat1),t.cos_po=Math.cos(t.lat1),t.t1=t.sin_po,t.con=t.sin_po,t.ms1=xe(t.e3,t.sin_po,t.cos_po),t.qs1=Se(t.e3,t.sin_po),t.sin_po=Math.sin(t.lat2),t.cos_po=Math.cos(t.lat2),t.t2=t.sin_po,t.ms2=xe(t.e3,t.sin_po,t.cos_po),t.qs2=Se(t.e3,t.sin_po),t.sin_po=Math.sin(t.lat0),t.cos_po=Math.cos(t.lat0),t.t3=t.sin_po,t.qs0=Se(t.e3,t.sin_po),Math.abs(t.lat1-t.lat2)>1e-10?t.ns0=(t.ms1*t.ms1-t.ms2*t.ms2)/(t.qs2-t.qs1):t.ns0=t.con,t.c=t.ms1*t.ms1+t.ns0*t.qs1,t.rh=t.a*Math.sqrt(t.c-t.ns0*t.qs0)/t.ns0)}function Th(t,e){var r=e.x,n=e.y;t.sin_phi=Math.sin(n),t.cos_phi=Math.cos(n);var i=Se(t.e3,t.sin_phi),o=t.a*Math.sqrt(t.c-t.ns0*i)/t.ns0,s=t.ns0*b(r-t.long0,t.over),a=o*Math.sin(s)+t.x0,c=t.rh-o*Math.cos(s)+t.y0;return e.x=a,e.y=c,e}function bh(t,e){var r,n,i,o,s,a;return e.x-=t.x0,e.y=t.rh-e.y+t.y0,t.ns0>=0?(r=Math.sqrt(e.x*e.x+e.y*e.y),i=1):(r=-Math.sqrt(e.x*e.x+e.y*e.y),i=-1),o=0,r!==0&&(o=Math.atan2(i*e.x,i*e.y)),i=r*t.ns0/t.a,t.sphere?a=Math.asin((t.c-i*i)/(2*t.ns0)):(n=(t.c-i*i)/t.ns0,a=d1(t.e3,n)),s=b(o/t.ns0+t.long0,t.over),e.x=s,e.y=a,e}function d1(t,e){var r,n,i,o,s,a=we(.5*e);if(t<1e-10)return a;for(var c=t*t,l=1;l<=25;l++)if(r=Math.sin(a),n=Math.cos(a),i=t*r,o=1-i*i,s=.5*o*o/n*(e/(1-c)-r/o+.5/t*Math.log((1-i)/(1+i))),a=a+s,Math.abs(s)<=1e-7)return a;return null}function vh(t){let e={...t,temp:0,e3:0,sin_po:0,cos_po:0,t1:0,con:0,ms1:0,qs1:0,t2:0,ms2:0,qs2:0,t3:0,qs0:0,ns0:0,c:0,rh:0,sin_phi:0,cos_phi:0};return f1(e),e}var ts={name:"aea",aliases:["Albers_Conic_Equal_Area","Albers_Equal_Area","Albers"],parameters:[...ue,"lat_1","lat_2"],create(t){let e=ce(t);return jt(e,t.parameters),ie("aea",vh(e),Th,bh,Fe)}};var m1=1,p1=.25,Ph=.046875,Rh=.01953125,Ch=.01068115234375,g1=.75,_1=.46875,M1=.013020833333333334,y1=.007120768229166667,x1=.3645833333333333,S1=.005696614583333333,w1=.3076171875;function Je(t){var e=[];e[0]=m1-t*(p1+t*(Ph+t*(Rh+t*Ch))),e[1]=t*(g1-t*(Ph+t*(Rh+t*Ch)));var r=t*t;return e[2]=r*(_1-t*(M1+t*y1)),r*=t,e[3]=r*(x1-t*S1),e[4]=r*t*w1,e}function le(t,e,r,n){return r*=e,e*=e,n[0]*t-r*(n[1]+e*(n[2]+e*(n[3]+e*n[4])))}var E1=20;function et(t,e,r){for(var n=1/(1-e),i=t,o=E1;o;--o){var s=Math.sin(i),a=1-e*s*s;if(a=(le(i,s,Math.cos(i),r)-t)*(a*Math.sqrt(a))*n,i-=a,Math.abs(a)<1e-10)return i}return i}function Ve(t){return Math.abs(t)<w?t:t-Qe(t)*Math.PI}function T1(t){Math.abs(t.lat1+t.lat2)<1e-10||(t.temp=t.b/t.a,t.es=1-Math.pow(t.temp,2),t.e=Math.sqrt(t.es),t.en=Je(t.es),t.sin_phi=Math.sin(t.lat1),t.cos_phi=Math.cos(t.lat1),t.ms1=xe(t.e,t.sin_phi,t.cos_phi),t.ml1=le(t.lat1,Math.sin(t.lat1),Math.cos(t.lat1),t.en),Math.abs(t.lat1-t.lat2)<1e-10?t.ns=t.sin_phi:(t.sin_phi=Math.sin(t.lat2),t.cos_phi=Math.cos(t.lat2),t.ms2=xe(t.e,t.sin_phi,t.cos_phi),t.ml2=le(t.lat2,Math.sin(t.lat2),Math.cos(t.lat2),t.en),t.ns=(t.ms1-t.ms2)/(t.ml2-t.ml1)),t.g=t.ml1+t.ms1/t.ns,t.ml0=le(t.lat0,Math.sin(t.lat0),Math.cos(t.lat0),t.en),t.rh=t.a*(t.g-t.ml0))}function Ah(t,e){var r=e.x,n=e.y,i;if(t.sphere)i=t.a*(t.g-n);else{var o=le(n,Math.sin(n),Math.cos(n),t.en);i=t.a*(t.g-o)}var s=t.ns*b(r-t.long0,t.over),a=t.x0+i*Math.sin(s),c=t.y0+t.rh-i*Math.cos(s);return e.x=a,e.y=c,e}function Ih(t,e){e.x-=t.x0,e.y=t.rh-e.y+t.y0;var r,n,i,o;t.ns>=0?(n=Math.sqrt(e.x*e.x+e.y*e.y),r=1):(n=-Math.sqrt(e.x*e.x+e.y*e.y),r=-1);var s=0;if(n!==0&&(s=Math.atan2(r*e.x,r*e.y)),t.sphere)return o=b(t.long0+s/t.ns,t.over),i=Ve(t.g-n/t.a),e.x=o,e.y=i,e;var a=t.g-n/t.a;return i=et(a,t.es,t.en),o=b(t.long0+s/t.ns,t.over),e.x=o,e.y=i,e}function Oh(t){let e={...t,temp:0,en:[],sin_phi:0,cos_phi:0,ms1:0,ml1:0,ns:0,ms2:0,ml2:0,g:0,ml0:0,rh:0};return T1(e),e}var rs={name:"eqdc",aliases:["Equidistant_Conic"],parameters:[...ue,"lat_1","lat_2"],create(t){let e=ce(t);return jt(e,t.parameters),ie("eqdc",Oh(e),Ah,Ih,Fe)}};var b1=.3333333333333333,v1=.17222222222222222,P1=.10257936507936508,R1=.06388888888888888,C1=.0664021164021164,A1=.016415012942191543;function Pr(t){var e,r=[];return r[0]=t*b1,e=t*t,r[0]+=e*v1,r[1]=e*R1,e*=t,r[0]+=e*P1,r[1]+=e*C1,r[2]=e*A1,r}function Rr(t,e){var r=t+t;return t+e[0]*Math.sin(r)+e[1]*Math.sin(r+r)+e[2]*Math.sin(r+r+r)}var tt=1,ht=2,ze=3,Ae=4;function I1(t){var e=Math.abs(t.lat0);if(Math.abs(e-w)<1e-10?t.mode=t.lat0<0?tt:ht:Math.abs(e)<1e-10?t.mode=ze:t.mode=Ae,t.es>0){var r;switch(t.qp=Se(t.e,1),t.mmf=.5/(1-t.es),t.apa=Pr(t.es),t.mode){case ht:t.dd=1;break;case tt:t.dd=1;break;case ze:t.rq=Math.sqrt(.5*t.qp),t.dd=1/t.rq,t.xmf=1,t.ymf=.5*t.qp;break;case Ae:t.rq=Math.sqrt(.5*t.qp),r=Math.sin(t.lat0),t.sinb1=Se(t.e,r)/t.qp,t.cosb1=Math.sqrt(1-t.sinb1*t.sinb1),t.dd=Math.cos(t.lat0)/(Math.sqrt(1-t.es*r*r)*t.rq*t.cosb1),t.xmf=t.rq,t.ymf=t.xmf/t.dd,t.xmf*=t.dd;break}}else t.mode===Ae&&(t.sinph0=Math.sin(t.lat0),t.cosph0=Math.cos(t.lat0))}function Nh(t,e){var r,n,i,o,s,a,c,l,h,u,f=e.x,d=e.y;if(f=b(f-t.long0,t.over),t.sphere){if(s=Math.sin(d),u=Math.cos(d),i=Math.cos(f),t.mode===Ae||t.mode===ze){if(n=t.mode===ze?1+u*i:1+t.sinph0*s+t.cosph0*u*i,n<=1e-10)return null;n=Math.sqrt(2/n),r=n*u*Math.sin(f),n*=t.mode===ze?s:t.cosph0*s-t.sinph0*u*i}else if(t.mode===ht||t.mode===tt){if(t.mode===ht&&(i=-i),Math.abs(d+t.lat0)<1e-10)return null;n=F-d*.5,n=2*(t.mode===tt?Math.cos(n):Math.sin(n)),r=n*Math.sin(f),n*=i}}else{switch(c=0,l=0,h=0,i=Math.cos(f),o=Math.sin(f),s=Math.sin(d),a=Se(t.e,s),(t.mode===Ae||t.mode===ze)&&(c=a/t.qp,l=Math.sqrt(1-c*c)),t.mode){case Ae:h=1+t.sinb1*c+t.cosb1*l*i;break;case ze:h=1+l*i;break;case ht:h=w+d,a=t.qp-a;break;case tt:h=d-w,a=t.qp+a;break}if(Math.abs(h)<1e-10)return null;switch(t.mode){case Ae:case ze:h=Math.sqrt(2/h),t.mode===Ae?n=t.ymf*h*(t.cosb1*c-t.sinb1*l*i):(h=Math.sqrt(2/(1+l*i)),n=h*c*t.ymf),r=t.xmf*h*l*o;break;case ht:case tt:a>=0?(h=Math.sqrt(a),r=h*o,n=i*(t.mode===tt?h:-h)):r=n=0;break}}return e.x=t.a*r+t.x0,e.y=t.a*n+t.y0,e}function Lh(t,e){e.x-=t.x0,e.y-=t.y0;var r=e.x/t.a,n=e.y/t.a,i,o,s,a,c,l,h;if(t.sphere){var u=0,f,d=0;if(f=Math.sqrt(r*r+n*n),o=f*.5,o>1)return null;switch(o=2*Math.asin(o),(t.mode===Ae||t.mode===ze)&&(d=Math.sin(o),u=Math.cos(o)),t.mode){case ze:o=Math.abs(f)<=1e-10?0:Math.asin(n*d/f),r*=d,n=u*f;break;case Ae:o=Math.abs(f)<=1e-10?t.lat0:Math.asin(u*t.sinph0+n*d*t.cosph0/f),r*=d*t.cosph0,n=(u-Math.sin(o)*t.sinph0)*f;break;case ht:n=-n,o=w-o;break;case tt:o-=w;break}i=n===0&&(t.mode===ze||t.mode===Ae)?0:Math.atan2(r,n)}else{if(h=0,t.mode===Ae||t.mode===ze){if(r/=t.dd,n*=t.dd,l=Math.sqrt(r*r+n*n),l<1e-10)return e.x=t.long0,e.y=t.lat0,e;a=2*Math.asin(.5*l/t.rq),s=Math.cos(a),r*=a=Math.sin(a),t.mode===Ae?(h=s*t.sinb1+n*a*t.cosb1/l,c=t.qp*h,n=l*t.cosb1*s-n*t.sinb1*a):(h=n*a/l,c=t.qp*h,n=l*s)}else if(t.mode===ht||t.mode===tt){if(t.mode===ht&&(n=-n),c=r*r+n*n,!c)return e.x=t.long0,e.y=t.lat0,e;h=1-c/t.qp,t.mode===tt&&(h=-h)}i=Math.atan2(r,n),o=Rr(Math.asin(h),t.apa)}return e.x=b(t.long0+i,t.over),e.y=o,e}function Gh(t){let e={...t,mode:0,qp:0,mmf:0,apa:[],dd:0,rq:0,xmf:0,ymf:0,sinb1:0,cosb1:0,sinph0:0,cosph0:0};return I1(e),e}var ns={name:"laea",aliases:["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area"],parameters:ue,create(t){let e=ce(t);return mt(e,ie("laea",Gh(e),Nh,Lh))}};function qh(t,e,r){return e*=r,Math.tan(.5*(w+t))*Math.pow((1-e)/(1+e),.5*r)}function O1(t){t.x0=t.x0||0,t.y0=t.y0||0,t.lat0=t.lat0||0,t.long0=t.long0||0,t.coslat0=Math.cos(t.lat0),t.sinlat0=Math.sin(t.lat0),t.sphere?!Number.isNaN(t.lat_ts)&&Math.abs(t.coslat0)<=1e-10&&(t.k0=.5*(1+Qe(t.lat0)*Math.sin(t.lat_ts))):(Math.abs(t.coslat0)<=1e-10&&(t.lat0>0?t.con=1:t.con=-1),t.cons=Math.sqrt(Math.pow(1+t.e,1+t.e)*Math.pow(1-t.e,1-t.e)),!Number.isNaN(t.lat_ts)&&Math.abs(t.coslat0)<=1e-10&&Math.abs(Math.cos(t.lat_ts))>1e-10&&(t.k0=.5*t.cons*xe(t.e,Math.sin(t.lat_ts),Math.cos(t.lat_ts))/Ce(t.e,t.con*t.lat_ts,t.con*Math.sin(t.lat_ts))),t.ms1=xe(t.e,t.sinlat0,t.coslat0),t.X0=2*Math.atan(qh(t.lat0,t.sinlat0,t.e))-w,t.cosX0=Math.cos(t.X0),t.sinX0=Math.sin(t.X0))}function zh(t,e){var r=e.x,n=e.y,i=Math.sin(n),o=Math.cos(n),s,a,c,l,h,u,f=b(r-t.long0,t.over);return Math.abs(Math.abs(r-t.long0)-Math.PI)<=1e-10&&Math.abs(n+t.lat0)<=1e-10?(e.x=NaN,e.y=NaN,e):t.sphere?(s=2*t.k0/(1+t.sinlat0*i+t.coslat0*o*Math.cos(f)),e.x=t.a*s*o*Math.sin(f)+t.x0,e.y=t.a*s*(t.coslat0*i-t.sinlat0*o*Math.cos(f))+t.y0,e):(a=2*Math.atan(qh(n,i,t.e))-w,l=Math.cos(a),c=Math.sin(a),Math.abs(t.coslat0)<=1e-10?(h=Ce(t.e,n*t.con,t.con*i),u=2*t.a*t.k0*h/t.cons,e.x=t.x0+u*Math.sin(r-t.long0),e.y=t.y0-t.con*u*Math.cos(r-t.long0),e):(Math.abs(t.sinlat0)<1e-10?(s=2*t.a*t.k0/(1+l*Math.cos(f)),e.y=s*c+t.y0):(s=2*t.a*t.k0*t.ms1/(t.cosX0*(1+t.sinX0*c+t.cosX0*l*Math.cos(f))),e.y=s*(t.cosX0*c-t.sinX0*l*Math.cos(f))+t.y0),e.x=s*l*Math.sin(f)+t.x0,e))}function Bh(t,e){e.x-=t.x0,e.y-=t.y0;var r,n,i,o,s,a=Math.sqrt(e.x*e.x+e.y*e.y);if(t.sphere){var c=2*Math.atan(a/(2*t.a*t.k0));return r=t.long0,n=t.lat0,a<=1e-10?(e.x=r,e.y=n,e):(n=Math.asin(Math.cos(c)*t.sinlat0+e.y*Math.sin(c)*t.coslat0/a),Math.abs(t.coslat0)<1e-10?t.lat0>0?r=b(t.long0+Math.atan2(e.x,-1*e.y),t.over):r=b(t.long0+Math.atan2(e.x,e.y),t.over):r=b(t.long0+Math.atan2(e.x*Math.sin(c),a*t.coslat0*Math.cos(c)-e.y*t.sinlat0*Math.sin(c)),t.over),e.x=r,e.y=n,e)}else if(Math.abs(t.coslat0)<=1e-10){if(a<=1e-10)return n=t.lat0,r=t.long0,e.x=r,e.y=n,e;e.x*=t.con,e.y*=t.con,i=a*t.cons/(2*t.a*t.k0),n=t.con*Et(t.e,i),r=t.con*b(t.con*t.long0+Math.atan2(e.x,-1*e.y),t.over)}else o=2*Math.atan(a*t.cosX0/(2*t.a*t.k0*t.ms1)),r=t.long0,a<=1e-10?s=t.X0:(s=Math.asin(Math.cos(o)*t.sinX0+e.y*Math.sin(o)*t.cosX0/a),r=b(t.long0+Math.atan2(e.x*Math.sin(o),a*t.cosX0*Math.cos(o)-e.y*t.sinX0*Math.sin(o)),t.over)),n=-1*Et(t.e,Math.tan(.5*(w+s)));return e.x=r,e.y=n,e}function Dh(t){let e={...t,coslat0:0,sinlat0:0,con:0,cons:0,ms1:0,X0:0,cosX0:0,sinX0:0};return O1(e),e}var is={name:"stere",aliases:["Stereographic_South_Pole","Polar_Stereographic_variant_A","Polar_Stereographic_variant_B","Polar_Stereographic"],parameters:[...ue,...lt,"lat_ts"],create(t){let e=ce(t);return mt(e,ie("stere",Dh(e),zh,Bh))}};function di(t,e){return Math.pow((1-t)/(1+t),e)}var N1=20;function L1(t){var e=Math.sin(t.lat0),r=Math.cos(t.lat0);r*=r,t.rc=Math.sqrt(1-t.es)/(1-t.es*e*e),t.C=Math.sqrt(1+t.es*r*r/(1-t.es)),t.phic0=Math.asin(e/t.C),t.ratexp=.5*t.C*t.e,t.K=Math.tan(.5*t.phic0+F)/(Math.pow(Math.tan(.5*t.lat0+F),t.C)*di(t.e*e,t.ratexp))}function kh(t,e){var r=e.x,n=e.y;return e.y=2*Math.atan(t.K*Math.pow(Math.tan(.5*n+F),t.C)*di(t.e*Math.sin(n),t.ratexp))-w,e.x=t.C*r,e}function Fh(t,e){for(var r=1e-14,n=e.x/t.C,i=e.y,o=Math.pow(Math.tan(.5*i+F)/t.K,1/t.C),s=N1;s>0&&(i=2*Math.atan(o*di(t.e*Math.sin(e.y),-.5*t.e))-w,!(Math.abs(i-e.y)<r));--s)e.y=i;return s?(e.x=n,e.y=i,e):null}function Uh(t){let e={...t,rc:0,C:0,phic0:0,ratexp:0,K:0};return L1(e),e}function ne(t,e){t=Math.abs(t),e=Math.abs(e);var r=Math.max(t,e),n=Math.min(t,e)/(r||1);return r*Math.sqrt(1+Math.pow(n,2))}function G1(t){t.rc&&(t.sinc0=Math.sin(t.phic0),t.cosc0=Math.cos(t.phic0),t.R2=2*t.rc)}function Vh(t,e){var r,n,i,o;return e.x=b(e.x-t.long0,t.over),kh(t,e),r=Math.sin(e.y),n=Math.cos(e.y),i=Math.cos(e.x),o=t.k0*t.R2/(1+t.sinc0*r+t.cosc0*n*i),e.x=o*n*Math.sin(e.x),e.y=o*(t.cosc0*r-t.sinc0*n*i),e.x=t.a*e.x+t.x0,e.y=t.a*e.y+t.y0,e}function jh(t,e){var r,n,i,o,s;if(e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,e.x/=t.k0,e.y/=t.k0,s=ne(e.x,e.y),s){var a=2*Math.atan2(s,t.R2);r=Math.sin(a),n=Math.cos(a),o=Math.asin(n*t.sinc0+e.y*r*t.cosc0/s),i=Math.atan2(e.x*r,s*t.cosc0*n-e.y*t.sinc0*r)}else o=t.phic0,i=0;if(e.x=i,e.y=o,!Fh(t,e))throw new Error("Oblique stereographic inverse did not converge");return e.x=b(e.x+t.long0,t.over),e}function Wh(t){let e={...Uh(t),sinc0:0,cosc0:0,R2:0};return G1(e),e}var os={name:"sterea",aliases:["Stereographic_North_Pole","Oblique_Stereographic","Oblique Stereographic Alternative","Double_Stereographic"],parameters:[...ue,...lt],create(t){let e=ce(t);if(Math.abs(e.lat0)===Math.PI/2)throw new Error("sterea requires a non-polar origin; use stere at the poles");return mt(e,ie("sterea",Wh(e),Vh,jh))}};function je(t,e,r,n,i){return t*i-e*Math.sin(2*i)+r*Math.sin(4*i)-n*Math.sin(6*i)}function Cr(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function Ar(t){return .375*t*(1+.25*t*(1+.46875*t))}function Ir(t){return .05859375*t*t*(1+.75*t)}function Or(t){return t*t*t*(35/3072)}function ss(t,e,r,n,i){var o,s;o=t/e;for(var a=0;a<15;a++)if(s=(t-(e*o-r*Math.sin(2*o)+n*Math.sin(4*o)-i*Math.sin(6*o)))/(e-2*r*Math.cos(2*o)+4*n*Math.cos(4*o)-6*i*Math.cos(6*o)),o+=s,Math.abs(s)<=1e-10)return o;return NaN}function Hh(t,e,r,n,i,o){let s=n-e,a=Math.atan((1-o)*Math.tan(t)),c=Math.atan((1-o)*Math.tan(r)),l=Math.sin(a),h=Math.cos(a),u=Math.sin(c),f=Math.cos(c),d=s,m,_=100,p,M,y,S,x,E,T,R,C,O,v,A,I,k;do{if(p=Math.sin(d),M=Math.cos(d),y=Math.sqrt(f*p*(f*p)+(h*u-l*f*M)*(h*u-l*f*M)),y===0)return{azi1:0,s12:0};S=l*u+h*f*M,x=Math.atan2(y,S),E=h*f*p/y,T=1-E*E,R=T!==0?S-2*l*u/T:0,C=o/16*T*(4+o*(4-3*T)),m=d,d=s+(1-C)*o*E*(x+C*y*(R+C*S*(-1+2*R*R)))}while(Math.abs(d-m)>1e-12&&--_>0);return _===0?{azi1:NaN,s12:NaN}:(O=T*(i*i-i*(1-o)*(i*(1-o)))/(i*(1-o)*(i*(1-o))),v=1+O/16384*(4096+O*(-768+O*(320-175*O))),A=O/1024*(256+O*(-128+O*(74-47*O))),I=A*y*(R+A/4*(S*(-1+2*R*R)-A/6*R*(-3+4*y*y)*(-3+4*R*R))),k=i*(1-o)*v*(x-I),{azi1:Math.atan2(f*p,h*u-l*f*M),s12:k})}function $h(t,e,r,n,i,o){let s=Math.atan((1-o)*Math.tan(t)),a=Math.sin(s),c=Math.cos(s),l=Math.sin(r),h=Math.cos(r),u=Math.atan2(a,c*h),f=c*l,d=1-f*f,m=d*(i*i-i*(1-o)*(i*(1-o)))/(i*(1-o)*(i*(1-o))),_=1+m/16384*(4096+m*(-768+m*(320-175*m))),p=m/1024*(256+m*(-128+m*(74-47*m))),M=n/(i*(1-o)*_),y,S=100,x,E,T,R;do x=Math.cos(2*u+M),E=Math.sin(M),T=Math.cos(M),R=p*E*(x+p/4*(T*(-1+2*x*x)-p/6*x*(-3+4*E*E)*(-3+4*x*x))),y=M,M=n/(i*(1-o)*_)+R;while(Math.abs(M-y)>1e-12&&--S>0);if(S===0)return{lat2:NaN,lon2:NaN};let C=a*E-c*T*h,O=Math.atan2(a*T+c*E*h,(1-o)*Math.sqrt(f*f+C*C)),v=Math.atan2(E*l,c*T-a*E*h),A=o/16*d*(4+o*(4-3*d)),I=v-(1-A)*o*f*(M+A*E*(x+A*T*(-1+2*x*x))),k=e+I;return{lat2:O,lon2:k}}function q1(t){t.sin_p12=Math.sin(t.lat0),t.cos_p12=Math.cos(t.lat0),t.x0=t.x0||0,t.y0=t.y0||0,t.long0=t.long0||0,t.f=t.es/(1+Math.sqrt(1-t.es))}function Yh(t,e){var r=e.x,n=e.y,i=Math.sin(e.y),o=Math.cos(e.y),s=b(r-t.long0,t.over),a,c,l,h,u,f,d,m,_,p,M;return t.sphere?Math.abs(t.sin_p12-1)<=1e-10?(e.x=t.x0+t.a*(w-n)*Math.sin(s),e.y=t.y0-t.a*(w-n)*Math.cos(s),e):Math.abs(t.sin_p12+1)<=1e-10?(e.x=t.x0+t.a*(w+n)*Math.sin(s),e.y=t.y0+t.a*(w+n)*Math.cos(s),e):(_=t.sin_p12*i+t.cos_p12*o*Math.cos(s),d=Math.acos(_),m=d?d/Math.sin(d):1,e.x=t.x0+t.a*m*o*Math.sin(s),e.y=t.y0+t.a*m*(t.cos_p12*i-t.sin_p12*o*Math.cos(s)),e):(a=Cr(t.es),c=Ar(t.es),l=Ir(t.es),h=Or(t.es),Math.abs(t.sin_p12-1)<=1e-10?(u=t.a*je(a,c,l,h,w),f=t.a*je(a,c,l,h,n),e.x=t.x0+(u-f)*Math.sin(s),e.y=t.y0-(u-f)*Math.cos(s),e):Math.abs(t.sin_p12+1)<=1e-10?(u=t.a*je(a,c,l,h,w),f=t.a*je(a,c,l,h,n),e.x=t.x0+(u+f)*Math.sin(s),e.y=t.y0+(u+f)*Math.cos(s),e):Math.abs(s)<1e-10&&Math.abs(n-t.lat0)<1e-10?(e.x=t.x0,e.y=t.y0,e):(p=Hh(t.lat0,t.long0,n,r,t.a,t.f),M=p.azi1,e.x=t.x0+p.s12*Math.sin(M),e.y=t.y0+p.s12*Math.cos(M),e))}function Kh(t,e){e.x-=t.x0,e.y-=t.y0;var r,n,i,o,s,a,c,l,h,u,f,d,m,_,p,M;return t.sphere?(r=Math.sqrt(e.x*e.x+e.y*e.y),r>2*w*t.a?null:(n=r/t.a,i=Math.sin(n),o=Math.cos(n),s=t.long0,Math.abs(r)<=1e-10?a=t.lat0:(a=we(o*t.sin_p12+e.y*i*t.cos_p12/r),c=Math.abs(t.lat0)-w,Math.abs(c)<=1e-10?t.lat0>=0?s=b(t.long0+Math.atan2(e.x,-e.y),t.over):s=b(t.long0-Math.atan2(-e.x,e.y),t.over):s=b(t.long0+Math.atan2(e.x*i,r*t.cos_p12*o-e.y*t.sin_p12*i),t.over)),e.x=s,e.y=a,e)):(l=Cr(t.es),h=Ar(t.es),u=Ir(t.es),f=Or(t.es),Math.abs(t.sin_p12-1)<=1e-10?(d=t.a*je(l,h,u,f,w),r=Math.sqrt(e.x*e.x+e.y*e.y),m=d-r,a=ss(m/t.a,l,h,u,f),s=b(t.long0+Math.atan2(e.x,-1*e.y),t.over),e.x=s,e.y=a,e):Math.abs(t.sin_p12+1)<=1e-10?(d=t.a*je(l,h,u,f,w),r=Math.sqrt(e.x*e.x+e.y*e.y),m=r-d,a=ss(m/t.a,l,h,u,f),s=b(t.long0+Math.atan2(e.x,e.y),t.over),e.x=s,e.y=a,e):(_=Math.atan2(e.x,e.y),p=Math.sqrt(e.x*e.x+e.y*e.y),M=$h(t.lat0,t.long0,_,p,t.a,t.f),e.x=M.lon2,e.y=M.lat2,e))}function Xh(t){let e={...t,sin_p12:0,cos_p12:0,f:0};return q1(e),e}var as={name:"aeqd",aliases:["Azimuthal_Equidistant"],parameters:ue,create(t){let e=ce(t);return mt(e,ie("aeqd",Xh(e),Yh,Kh))}};function Tt(t){var e=Math.exp(t);return e=(e-1/e)/2,e}function Zh(t){var e=1+t,r=e-1;return r===0?t:t*Math.log(e)/r}function Qh(t){var e=Math.abs(t);return e=Zh(e*(1+e/(ne(1,e)+1))),t<0?-e:e}function mi(t,e){for(var r=2*Math.cos(2*e),n=t.length-1,i=t[n],o=0,s;--n>=0;)s=-o+r*i+t[n],o=i,i=s;return e+s*Math.sin(2*e)}function Jh(t,e){for(var r=2*Math.cos(e),n=t.length-1,i=t[n],o=0,s;--n>=0;)s=-o+r*i+t[n],o=i,i=s;return Math.sin(e)*s}function Nr(t){var e=Math.exp(t);return e=(e+1/e)/2,e}function cs(t,e,r,n){for(var i=Math.sin(e),o=Math.cos(e),s=Tt(r),a=Nr(r),c=2*o*a,l=-2*i*s,h=t.length-1,u=t[h],f=0,d=0,m=0,_,p;--h>=0;)_=d,p=f,d=u,f=m,u=-_+c*d-l*f+t[h],m=-p+l*d+c*f;c=i*a,l=o*s,n.x=c*u-l*m,n.y=c*m+l*u}function z1(t){t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.long0=t.long0!==void 0?t.long0:0,t.lat0=t.lat0!==void 0?t.lat0:0,t.k0=t.k0!==void 0?t.k0:1,t.cgb=[],t.cbg=[],t.utg=[],t.gtu=[];var e=t.es/(1+Math.sqrt(1-t.es)),r=e/(2-e),n=r;t.cgb[0]=r*(2+r*(-2/3+r*(-2+r*(116/45+r*(26/45+r*(-2854/675)))))),t.cbg[0]=r*(-2+r*(2/3+r*(4/3+r*(-82/45+r*(32/45+r*(4642/4725)))))),n=n*r,t.cgb[1]=n*(7/3+r*(-8/5+r*(-227/45+r*(2704/315+r*(2323/945))))),t.cbg[1]=n*(5/3+r*(-16/15+r*(-13/9+r*(904/315+r*(-1522/945))))),n=n*r,t.cgb[2]=n*(56/15+r*(-136/35+r*(-1262/105+r*(73814/2835)))),t.cbg[2]=n*(-26/15+r*(34/21+r*(8/5+r*(-12686/2835)))),n=n*r,t.cgb[3]=n*(4279/630+r*(-332/35+r*(-399572/14175))),t.cbg[3]=n*(1237/630+r*(-12/5+r*(-24832/14175))),n=n*r,t.cgb[4]=n*(4174/315+r*(-144838/6237)),t.cbg[4]=n*(-734/315+r*(109598/31185)),n=n*r,t.cgb[5]=n*(601676/22275),t.cbg[5]=n*(444337/155925),n=Math.pow(r,2),t.Qn=t.k0/(1+r)*(1+n*(1/4+n*(1/64+n/256))),t.utg[0]=r*(-.5+r*(2/3+r*(-37/96+r*(1/360+r*(81/512+r*(-96199/604800)))))),t.gtu[0]=r*(.5+r*(-2/3+r*(5/16+r*(41/180+r*(-127/288+r*(7891/37800)))))),t.utg[1]=n*(-1/48+r*(-1/15+r*(437/1440+r*(-46/105+r*(1118711/3870720))))),t.gtu[1]=n*(13/48+r*(-3/5+r*(557/1440+r*(281/630+r*(-1983433/1935360))))),n=n*r,t.utg[2]=n*(-17/480+r*(37/840+r*(209/4480+r*(-5569/90720)))),t.gtu[2]=n*(61/240+r*(-103/140+r*(15061/26880+r*(167603/181440)))),n=n*r,t.utg[3]=n*(-4397/161280+r*(11/504+r*(830251/7257600))),t.gtu[3]=n*(49561/161280+r*(-179/168+r*(6601661/7257600))),n=n*r,t.utg[4]=n*(-4583/161280+r*(108847/3991680)),t.gtu[4]=n*(34729/80640+r*(-3418889/1995840)),n=n*r,t.utg[5]=n*(-20648693/638668800),t.gtu[5]=n*(212378941/319334400);var i=mi(t.cbg,t.lat0);t.Zb=-t.Qn*(i+Jh(t.gtu,2*i))}function eu(t,e){var r=b(e.x-t.long0,t.over),n=e.y;n=mi(t.cbg,n);var i=Math.sin(n),o=Math.cos(n),s=Math.sin(r),a=Math.cos(r);n=Math.atan2(i,a*o),r=Math.atan2(s*o,ne(i,o*a)),r=Qh(Math.tan(r)),cs(t.gtu,2*n,2*r,e),n=n+e.x,r=r+e.y;var c,l;return Math.abs(r)<=2.623395162778?(c=t.a*(t.Qn*r)+t.x0,l=t.a*(t.Qn*n+t.Zb)+t.y0):(c=1/0,l=1/0),e.x=c,e.y=l,e}function tu(t,e){var r=(e.x-t.x0)*(1/t.a),n=(e.y-t.y0)*(1/t.a);n=(n-t.Zb)/t.Qn,r=r/t.Qn;var i,o;if(Math.abs(r)<=2.623395162778){cs(t.utg,2*n,2*r,e),n=n+e.x,r=r+e.y,r=Math.atan(Tt(r));var s=Math.sin(n),a=Math.cos(n),c=Math.sin(r),l=Math.cos(r);n=Math.atan2(s*l,ne(c,l*a)),r=Math.atan2(c,l*a),i=b(r+t.long0,t.over),o=mi(t.cgb,n)}else i=1/0,o=1/0;return e.x=i,e.y=o,e}function ru(t){let e={...t,cgb:[],cbg:[],utg:[],gtu:[],Qn:0,Zb:0};return z1(e),e}function B1(t){t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.long0=t.long0!==void 0?t.long0:0,t.lat0=t.lat0!==void 0?t.lat0:0,t.es&&(t.en=Je(t.es),t.ml0=le(t.lat0,Math.sin(t.lat0),Math.cos(t.lat0),t.en))}function nu(t,e){var r=e.x,n=e.y,i=b(r-t.long0,t.over),o,s,a,c=Math.sin(n),l=Math.cos(n);if(t.es){var u=l*i,f=Math.pow(u,2),d=t.ep2*Math.pow(l,2),m=Math.pow(d,2),_=Math.abs(l)>1e-10?Math.tan(n):0,p=Math.pow(_,2),M=Math.pow(p,2);o=1-t.es*Math.pow(c,2),u=u/Math.sqrt(o);var y=le(n,c,l,t.en);s=t.a*(t.k0*u*(1+f/6*(1-p+d+f/20*(5-18*p+M+14*d-58*p*d+f/42*(61+179*M-M*p-479*p)))))+t.x0,a=t.a*(t.k0*(y-t.ml0+c*i*u/2*(1+f/12*(5-p+9*d+4*m+f/30*(61+M-58*p+270*d-330*p*d+f/56*(1385+543*M-M*p-3111*p))))))+t.y0}else{var h=l*Math.sin(i);if(Math.abs(Math.abs(h)-1)<1e-10)return 93;if(s=.5*t.a*t.k0*Math.log((1+h)/(1-h))+t.x0,a=l*Math.cos(i)/Math.sqrt(1-Math.pow(h,2)),h=Math.abs(a),h>=1){if(h-1>1e-10)return 93;a=0}else a=Math.acos(a);n<0&&(a=-a),a=t.a*t.k0*(a-t.lat0)+t.y0}return e.x=s,e.y=a,e}function iu(t,e){var r,n,i,o,s=(e.x-t.x0)*(1/t.a),a=(e.y-t.y0)*(1/t.a);if(t.es)if(r=t.ml0+a/t.k0,n=et(r,t.es,t.en),Math.abs(n)<w){var f=Math.sin(n),d=Math.cos(n),m=Math.abs(d)>1e-10?Math.tan(n):0,_=t.ep2*Math.pow(d,2),p=Math.pow(_,2),M=Math.pow(m,2),y=Math.pow(M,2);r=1-t.es*Math.pow(f,2);var S=s*Math.sqrt(r)/t.k0,x=Math.pow(S,2);r=r*m,i=n-r*x/(1-t.es)*.5*(1-x/12*(5+3*M-9*_*M+_-4*p-x/30*(61+90*M-252*_*M+45*y+46*_-x/56*(1385+3633*M+4095*y+1574*y*M)))),o=b(t.long0+S*(1-x/6*(1+2*M+_-x/20*(5+28*M+24*y+8*_*M+6*_-x/42*(61+662*M+1320*y+720*y*M))))/d,t.over)}else i=w*Qe(a),o=0;else{var c=Math.exp(s/t.k0),l=.5*(c-1/c),h=t.lat0+a/t.k0,u=Math.cos(h);r=Math.sqrt((1-Math.pow(u,2))/(1+Math.pow(l,2))),i=Math.asin(r),Math.sin(h)<0&&(i=-i),l===0&&u===0?o=0:o=b(Math.atan2(l,u)+t.long0,t.over)}return e.x=o,e.y=i,e}function ou(t){let e={...t,en:[],ml0:0};return B1(e),e}function pi(t){let e=ce(t);if(Ue(t.parameters,"approx"))return ie("tmerc +approx",ou(e),nu,iu,Fe);if(e.sphere)throw new Error("Spherical transverse Mercator requires +approx");return ie("etmerc",ru(e),eu,tu,Fe)}var ls={name:"tmerc",aliases:["Fast_Transverse_Mercator","Fast Transverse Mercator","Transverse_Mercator","Transverse Mercator","Gauss Kruger","Gauss_Kruger"],parameters:[...ue,...lt,"approx"],flags:["approx"],create:pi},hs={name:"etmerc",aliases:["Extended_Transverse_Mercator","Extended Transverse Mercator"],parameters:[...ue,...lt,"approx"],flags:["approx"],create:pi};var us={name:"utm",aliases:["Universal Transverse Mercator System"],parameters:["zone","south","approx"],flags:["south","approx"],create(t){let e=L(t.parameters,"zone",NaN);if(!Number.isInteger(e)||e<1||e>60)throw new Error("UTM requires an integer +zone from 1 to 60");let r=Ue(t.parameters,"south");return pi({...t,parameters:{...t.parameters,lat_0:"0",lon_0:String(6*e-183),x_0:"500000",y_0:r?"10000000":"0",k_0:"0.9996"}})}};var fs={name:"geocent",aliases:["Geocentric","geocentric","Geocent"],parameters:[],create({semiMajorAxis:t,eccentricitySquared:e}){let r={semiMajorAxis:t,eccentricitySquared:e,semiMinorAxis:t*Math.sqrt(1-e)};return{forward(){throw new Error("Geocentric projection requires the 3D pipeline")},inverse(){throw new Error("Geocentric projection requires the 3D pipeline")},forwardInPlace:n=>ai(n,r),inverseInPlace:n=>ci(n,r),forward3D:n=>fh(n,r),inverse3D:n=>dh(n,r)}}};function q(t){let e=ce(t);return{...e,x0:0,y0:0,lat_ts:Number.isNaN(e.lat_ts)?0:e.lat_ts}}function z(t,e,r,n,i,o){let s=ie(t,r,n,i),a=L(e.parameters,"x_0",0),c=L(e.parameters,"y_0",0);return Ge(l=>{o?.(l.x,l.y),s.forwardInPlace(l),l.x+=a,l.y+=c},l=>{l.x-=a,l.y-=c,s.inverseInPlace(l)})}function gt(t,e=0,r=!1){return(n,i)=>{let o=Math.sin(t.lat0)*Math.sin(i)+Math.cos(t.lat0)*Math.cos(i)*Math.cos(n-t.long0);if(r?o<e-1e-14:o<=e+1e-14)throw new Error("Coordinate is outside the visible projection horizon")}}var Lr=1e-10;function D1(t){var e;if(t.phi1=t.lat1,Math.abs(t.phi1)<Lr)throw new Error;t.es?(t.en=Je(t.es),t.am1=Math.sin(t.phi1),e=Math.cos(t.phi1),t.m1=le(t.phi1,t.am1,e,t.en),t.am1=e/(Math.sqrt(1-t.es*t.am1*t.am1)*t.am1)):Math.abs(t.phi1)+Lr>=w?t.cphi1=0:t.cphi1=1/Math.tan(t.phi1)}function k1(t,e){var r=b(e.x-(t.long0||0),t.over),n=e.y,i,o,s;return o=Math.sin(n),s=Math.cos(n),i=t.am1+t.m1-le(n,o,s,t.en),o=s*r/(i*Math.sqrt(1-t.es*o*o)),e.x=i*Math.sin(o),e.y=t.am1-i*Math.cos(o),e.x=t.a*e.x+(t.x0||0),e.y=t.a*e.y+(t.y0||0),e}function F1(t,e){e.x=(e.x-(t.x0||0))/t.a,e.y=(e.y-(t.y0||0))/t.a;var r,n,i,o;if(e.y=t.am1-e.y,n=ne(e.x,e.y),t.phi1<0&&(n=-n),o=et(t.am1+t.m1-n,t.es,t.en),r=Math.abs(o),r<w)r=Math.sin(o),i=n*Math.atan2(Math.sign(t.phi1)*e.x,Math.sign(t.phi1)*e.y)*Math.sqrt(1-t.es*r*r)/Math.cos(o);else if(Math.abs(r-w)<=Lr)i=0;else throw new Error;return e.x=b(i+(t.long0||0),t.over),e.y=Ve(o),e}function U1(t,e){var r=b(e.x-(t.long0||0),t.over),n=e.y,i,o;return o=t.cphi1+t.phi1-n,Math.abs(o)>Lr?(i=r*Math.cos(n)/o,e.x=o*Math.sin(i),e.y=t.cphi1-o*Math.cos(i)):e.x=e.y=0,e.x=t.a*e.x+(t.x0||0),e.y=t.a*e.y+(t.y0||0),e}function V1(t,e){e.x=(e.x-(t.x0||0))/t.a,e.y=(e.y-(t.y0||0))/t.a;var r,n;e.y=t.cphi1-e.y;var i=ne(e.x,e.y);if(t.phi1<0&&(i=-i),n=t.cphi1+t.phi1-i,Math.abs(n)>w)throw new Error;return Math.abs(Math.abs(n)-w)<=Lr?r=0:r=i*Math.atan2(Math.sign(t.phi1)*e.x,Math.sign(t.phi1)*e.y)/Math.cos(n),e.x=b(r+(t.long0||0),t.over),e.y=Ve(n),e}function su(t,e){return t.es?k1(t,e):U1(t,e)}function au(t,e){return t.es?F1(t,e):V1(t,e)}function cu(t,e={}){let r={...t,phi1:0,en:[],m1:0,am1:0,cphi1:0,...e};return D1(r),r}var ds={name:"bonne",aliases:["Bonne (Werner lat_1=90)"],parameters:["lon_0","x_0","y_0","lat_1"],create(t){let e=q(t);if(!Object.prototype.hasOwnProperty.call(t.parameters,"lat_1")||Math.abs(e.lat1)<1e-10)throw new Error("Bonne requires a nonzero lat_1");let r=cu(e);return z("bonne",t,r,su,au)}};function Gr(t,e,r){var n=e*r;return t/Math.sqrt(1-n*n)}function j1(t){t.sphere||(t.en=Je(t.es),t.ml0=t.a*le(t.lat0,Math.sin(t.lat0),Math.cos(t.lat0),t.en))}function ps(t,e){var r,n,i=e.x,o=e.y;if(i=b(i-t.long0,t.over),t.sphere)r=t.a*Math.asin(Math.cos(o)*Math.sin(i)),n=t.a*(Math.atan2(Math.tan(o),Math.cos(i))-t.lat0);else{var s=Math.sin(o),a=Math.cos(o),c=Gr(t.a,t.e,s),l=Math.tan(o)*Math.tan(o),h=i*Math.cos(o),u=h*h,f=t.es*a*a/(1-t.es),d=t.a*le(o,s,a,t.en);r=c*h*(1-u*l*(1/6+(8-l+8*f)*u/120)),n=d-t.ml0+c*s/a*u*(.5+(5-l+6*f)*u/24)}return e.x=r+t.x0,e.y=n+t.y0,e}function lu(t,e){e.x-=t.x0,e.y-=t.y0;var r=e.x/t.a,n=e.y/t.a,i,o;if(t.sphere){var s=n+t.lat0;i=Math.asin(Math.sin(s)*Math.cos(r)),o=Math.atan2(Math.tan(r),Math.cos(s))}else{var a=t.ml0/t.a+n,c=et(a,t.es,t.en);if(Math.abs(Math.abs(c)-w)<=1e-10)return e.x=t.long0,e.y=Math.sign(c)*w,e;var l=Gr(t.a,t.e,Math.sin(c)),h=l*l*l/t.a/t.a*(1-t.es),u=Math.pow(Math.tan(c),2),f=r*t.a/l,d=f*f;i=c-l*Math.tan(c)/h*f*f*(.5-(1+3*u)*f*f/24),o=f*(1-d*(u/3-(1+3*u)*u*d/15))/Math.cos(c)}if(!t.sphere){let m=e.x+t.x0,_=e.y+t.y0,p=t.scratch,M=!1;for(let y=0;y<12;y++){ms(t,o,i);let S=p.x-m,x=p.y-_;if(Math.max(Math.abs(S),Math.abs(x))<1e-7){M=!0;break}let E=1e-7,T=i>w-E?-E:E,R=p.x,C=p.y;ms(t,o+E,i);let O=(p.x-R)/E,v=(p.y-C)/E;ms(t,o,i+T);let A=(p.x-R)/T,I=(p.y-C)/T,k=O*I-A*v;if(!Number.isFinite(k)||Math.abs(k)<1e-12||(o-=(I*S-A*x)/k,i-=(O*x-v*S)/k,!Number.isFinite(o)||Math.abs(i)>w))break}if(!M)throw new Error("Cassini inverse did not converge")}return e.x=b(o+t.long0,t.over),e.y=Ve(i),e}function ms(t,e,r){t.scratch.x=e+t.long0,t.scratch.y=r,ps(t,t.scratch)}function hu(t,e={}){let r={...t,en:[],scratch:{x:0,y:0},ml0:0,...e};return j1(r),r}var gs={name:"cass",aliases:["Cassini","Cassini_Soldner"],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=q(t),r=hu(e);return z("cass",t,r,ps,lu)}};function uu(t,e){var r=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));let n=4*Number.EPSILON*r;if(Math.abs(e)>r+n)return NaN;if(Math.abs(Math.abs(e)-r)<=n)return e<0?-1*w:w;for(var i=Math.asin(.5*e),o,s,a,c,l=0;l<30;l++)if(s=Math.sin(i),a=Math.cos(i),c=t*s,o=Math.pow(1-c*c,2)/(2*a)*(e/(1-t*t)-s/(1-c*c)+.5/t*Math.log((1-c)/(1+c))),i+=o,Math.abs(o)<=1e-10)return i;return NaN}function W1(t){t.sphere||(t.k0=xe(t.e,Math.sin(t.lat_ts),Math.cos(t.lat_ts)))}function fu(t,e){var r=e.x,n=e.y,i,o,s=b(r-t.long0,t.over);if(t.sphere)i=t.x0+t.a*s*Math.cos(t.lat_ts),o=t.y0+t.a*Math.sin(n)/Math.cos(t.lat_ts);else{var a=Se(t.e,Math.sin(n));i=t.x0+t.a*t.k0*s,o=t.y0+t.a*a*.5/t.k0}return e.x=i,e.y=o,e}function du(t,e){e.x-=t.x0,e.y-=t.y0;var r,n;return t.sphere?(r=b(t.long0+e.x/t.a/Math.cos(t.lat_ts),t.over),n=Math.asin(e.y/t.a*Math.cos(t.lat_ts))):(n=uu(t.e,2*e.y*t.k0/t.a),r=b(t.long0+e.x/(t.a*t.k0),t.over)),e.x=r,e.y=n,e}function mu(t,e={}){let r={...t,...e};return W1(r),r}var _s={name:"cea",aliases:[],parameters:["lon_0","x_0","y_0","lat_ts"],create(t){let e=q(t);if(Math.abs(e.lat_ts)>=Math.PI/2)throw new Error("CEA standard parallel must be away from the poles");let r=mu(e);return z("cea",t,r,fu,du)}};var H1=20;function $1(t){t.long0=t.long0||0,t.sphere?(t.n=1,t.m=0,t.es=0,t.C_y=Math.sqrt((t.m+1)/t.n),t.C_x=t.C_y/(t.m+1)):t.en=Je(t.es)}function gi(t,e){var r,n,i=e.x,o=e.y;if(i=b(i-t.long0,t.over),t.sphere){if(!t.m)o=t.n!==1?Math.asin(t.n*Math.sin(o)):o;else for(var s=t.n*Math.sin(o),a=H1;a;--a){var c=(t.m*o+Math.sin(o)-s)/(t.m+Math.cos(o));if(o-=c,Math.abs(c)<1e-10)break}r=t.a*t.C_x*i*(t.m+Math.cos(o)),n=t.a*t.C_y*o}else{var l=Math.sin(o),h=Math.cos(o);n=t.a*le(o,l,h,t.en),r=t.a*i*h/Math.sqrt(1-t.es*l*l)}return e.x=r,e.y=n,e}function _i(t,e){var r,n,i,o;return e.x-=t.x0,i=e.x/t.a,e.y-=t.y0,r=e.y/t.a,t.sphere?(r/=t.C_y,i=i/(t.C_x*(t.m+Math.cos(r))),t.m?r=we((t.m*r+Math.sin(r))/t.n):t.n!==1&&(r=we(Math.sin(r)/t.n)),i=b(i+t.long0,t.over),r=Ve(r)):(r=et(e.y/t.a,t.es,t.en),o=Math.abs(r),o<w?(o=Math.sin(r),n=t.long0+e.x*Math.sqrt(1-t.es*o*o)/(t.a*Math.cos(r)),i=b(n,t.over)):o-1e-10<w&&(i=t.long0)),e.x=i,e.y=r,e}function pu(t,e={}){let r={...t,en:[],n:0,m:0,C_y:0,C_x:0,...e};return $1(r),r}function Y1(t){t.sphere=!0,t.b=t.a,t.m=1,t.n=2.5707963267948966,t.es=0,t.C_y=Math.sqrt((t.m+1)/t.n),t.C_x=t.C_y/(t.m+1)}var gu=gi,_u=_i;function Mu(t,e={}){let r={...t,m:0,n:0,C_y:0,C_x:0,en:[],...e};return Y1(r),r}var Ms={name:"eck6",aliases:["Eckert_VI"],parameters:["lon_0","x_0","y_0"],create(t){let e=q(t),r=Mu(e);return z("eck6",t,r,gu,_u)}};var qr=1.340264,zr=-.081106,Br=893e-6,Dr=.003796,Mi=Math.sqrt(3)/2;function K1(t){t.long0=t.long0!==void 0?t.long0:0,t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.es!==0&&(t.apa=Pr(t.es),t.qp=Se(t.e,1),t.rqda=Math.sqrt(.5*t.qp))}function yu(t,e){var r=b(e.x-t.long0,t.over),n=e.y,i=Math.sin(n);t.es!==0&&(i=Se(t.e,i)/t.qp);var o=Math.asin(Mi*i),s=o*o,a=s*s*s;return e.x=r*Math.cos(o)/(Mi*(qr+3*zr*s+a*(7*Br+9*Dr*s))),e.y=o*(qr+zr*s+a*(Br+Dr*s)),t.es!==0&&(e.x*=t.rqda,e.y*=t.rqda),e.x=t.a*e.x+t.x0,e.y=t.a*e.y+t.y0,e}function xu(t,e){e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,t.es!==0&&(e.x/=t.rqda,e.y/=t.rqda);var r=1e-9,n=12,i=e.y,o,s,a,c,l,h;for(h=0;h<n&&(o=i*i,s=o*o*o,a=i*(qr+zr*o+s*(Br+Dr*o))-e.y,c=qr+3*zr*o+s*(7*Br+9*Dr*o),i-=l=a/c,!(Math.abs(l)<r));++h);return o=i*i,s=o*o*o,e.x=Mi*e.x*(qr+3*zr*o+s*(7*Br+9*Dr*o))/Math.cos(i),e.y=Math.asin(Math.sin(i)/Mi),t.es!==0&&(e.y=Rr(e.y,t.apa)),e.x=b(e.x+t.long0,t.over),e}function Su(t,e={}){let r={...t,apa:[],qp:0,rqda:0,...e};return K1(r),r}var ys={name:"eqearth",aliases:["Equal Earth","Equal_Earth"],parameters:["lon_0","x_0","y_0"],create(t){let e=q(t),r=Su(e);return z("eqearth",t,r,yu,xu)}};function X1(t){t.x0=t.x0||0,t.y0=t.y0||0,t.lat0=t.lat0||0,t.long0=t.long0||0}function wu(t,e){var r=e.x,n=e.y,i=b(r-t.long0,t.over),o=t.x0+t.a*i*Math.cos(t.lat0),s=t.y0+t.a*n;return t.t1=o,t.t2=Math.cos(t.lat0),e.x=o,e.y=s,e}function Eu(t,e){e.x-=t.x0,e.y-=t.y0;var r=e.y/t.a,n=b(t.long0+e.x/(t.a*Math.cos(t.lat0)),t.over);return e.x=n,e.y=r,e}function Tu(t,e={}){let r={...t,t2:0,t1:0,...e};return X1(r),r}var xs={name:"equi",aliases:[],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=q(t);if(Math.abs(e.lat0)>=Math.PI/2)throw new Error("Equirectangular standard parallel must be away from the poles");let r=Tu(e);return z("equi",t,r,wu,Eu)}};function Z1(t){if(t.flip_axis=t.sweep==="x"?1:0,t.h=Number(t.h),t.radius_g_1=t.h/t.a,t.radius_g_1<=0||t.radius_g_1>1e10)throw new Error;if(t.radius_g=1+t.radius_g_1,t.C=t.radius_g*t.radius_g-1,t.es!==0){var e=1-t.es,r=1/e;t.radius_p=Math.sqrt(e),t.radius_p2=e,t.radius_p_inv2=r,t.shape="ellipse"}else t.radius_p=1,t.radius_p2=1,t.radius_p_inv2=1,t.shape="sphere"}function bu(t,e){var r=e.x,n=e.y,i,o,s,a;if(r=r-t.long0,t.shape==="ellipse"){n=Math.atan(t.radius_p2*Math.tan(n));var c=t.radius_p/ne(t.radius_p*Math.cos(n),Math.sin(n));if(o=c*Math.cos(r)*Math.cos(n),s=c*Math.sin(r)*Math.cos(n),a=c*Math.sin(n),(t.radius_g-o)*o-s*s-a*a*t.radius_p_inv2<0)return e.x=Number.NaN,e.y=Number.NaN,e;i=t.radius_g-o,t.flip_axis?(e.x=t.radius_g_1*Math.atan(s/ne(a,i)),e.y=t.radius_g_1*Math.atan(a/i)):(e.x=t.radius_g_1*Math.atan(s/i),e.y=t.radius_g_1*Math.atan(a/ne(s,i)))}else t.shape==="sphere"&&(i=Math.cos(n),o=Math.cos(r)*i,s=Math.sin(r)*i,a=Math.sin(n),i=t.radius_g-o,t.flip_axis?(e.x=t.radius_g_1*Math.atan(s/ne(a,i)),e.y=t.radius_g_1*Math.atan(a/i)):(e.x=t.radius_g_1*Math.atan(s/i),e.y=t.radius_g_1*Math.atan(a/ne(s,i))));return e.x=e.x*t.a,e.y=e.y*t.a,e}function vu(t,e){var r=-1,n=0,i=0,o,s,a,c;if(e.x=e.x/t.a,e.y=e.y/t.a,t.shape==="ellipse"){t.flip_axis?(i=Math.tan(e.y/t.radius_g_1),n=Math.tan(e.x/t.radius_g_1)*ne(1,i)):(n=Math.tan(e.x/t.radius_g_1),i=Math.tan(e.y/t.radius_g_1)*ne(1,n));var l=i/t.radius_p;if(o=n*n+l*l+r*r,s=2*t.radius_g*r,a=s*s-4*o*t.C,a<0)return e.x=Number.NaN,e.y=Number.NaN,e;c=(-s-Math.sqrt(a))/(2*o),r=t.radius_g+c*r,n*=c,i*=c,e.x=Math.atan2(n,r),e.y=Math.atan(i*Math.cos(e.x)/r),e.y=Math.atan(t.radius_p_inv2*Math.tan(e.y))}else if(t.shape==="sphere"){if(t.flip_axis?(i=Math.tan(e.y/t.radius_g_1),n=Math.tan(e.x/t.radius_g_1)*Math.sqrt(1+i*i)):(n=Math.tan(e.x/t.radius_g_1),i=Math.tan(e.y/t.radius_g_1)*Math.sqrt(1+n*n)),o=n*n+i*i+r*r,s=2*t.radius_g*r,a=s*s-4*o*t.C,a<0)return e.x=Number.NaN,e.y=Number.NaN,e;c=(-s-Math.sqrt(a))/(2*o),r=t.radius_g+c*r,n*=c,i*=c,e.x=Math.atan2(n,r),e.y=Math.atan(i*Math.cos(e.x)/r)}return e.x=e.x+t.long0,e}function Pu(t,e={}){let r={...t,flip_axis:0,sweep:"",h:0,radius_g_1:0,radius_g:0,C:0,radius_p:0,radius_p2:0,radius_p_inv2:0,shape:"",...e};return Z1(r),r}var Ss={name:"geos",aliases:["Geostationary Satellite View","Geostationary_Satellite"],parameters:["lon_0","x_0","y_0","h","sweep"],create(t){let e=q(t),r=L(t.parameters,"h",NaN);if(!Number.isFinite(r)||r<=0)throw new Error("Geostationary projection requires positive h");let n=t.parameters.sweep||"y";if(!["x","y"].includes(n))throw new Error("Geostationary sweep must be x or y");let i=Pu(e,{h:r,sweep:n});return z("geos",t,i,bu,vu,e.sphere?gt({...e,lat0:0},1/(1+r/e.a),!0):void 0)}};function Q1(t){t.sin_p14=Math.sin(t.lat0),t.cos_p14=Math.cos(t.lat0),t.infinity_dist=1e3*t.a,t.rc=1}function Ru(t,e){var r,n,i,o,s,a,c,l,h=e.x,u=e.y;return i=b(h-t.long0,t.over),r=Math.sin(u),n=Math.cos(u),o=Math.cos(i),a=t.sin_p14*r+t.cos_p14*n*o,s=1,a>0||Math.abs(a)<=1e-10?(c=t.x0+t.a*s*n*Math.sin(i)/a,l=t.y0+t.a*s*(t.cos_p14*r-t.sin_p14*n*o)/a):(c=t.x0+t.infinity_dist*n*Math.sin(i),l=t.y0+t.infinity_dist*(t.cos_p14*r-t.sin_p14*n*o)),e.x=c,e.y=l,e}function Cu(t,e){var r,n,i,o,s,a;return e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,e.x/=t.k0,e.y/=t.k0,r=Math.sqrt(e.x*e.x+e.y*e.y),r?(o=Math.atan2(r,t.rc),n=Math.sin(o),i=Math.cos(o),a=we(i*t.sin_p14+e.y*n*t.cos_p14/r),s=Math.atan2(e.x*n,r*t.cos_p14*i-e.y*t.sin_p14*n),s=b(t.long0+s,t.over)):(a=t.lat0,s=t.long0),e.x=s,e.y=a,e}function Au(t,e={}){let r={...t,sin_p14:0,cos_p14:0,infinity_dist:0,rc:0,phic0:0,...e};return Q1(r),r}var ws={name:"gnom",aliases:[],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=q(t),r=Au(e);return z("gnom",t,r,Ru,Cu,gt(e))}};function Wt(t,e,r){if(Math.abs(e)>w)return Number.NaN;if(e===w)return Number.POSITIVE_INFINITY;if(e===-1*w)return Number.NEGATIVE_INFINITY;var n=t*r;return Math.log(Math.tan((w+e)/2))+t*Math.log((1-n)/(1+n))/2}function Es(t,e){return 2*Math.atan(t*Math.exp(e))-w}function Iu(t,e){var r=Es(1,e),n=0,i=0;let o=0;do{if(++o>50)throw new Error("Isometric latitude inverse did not converge");n=r,i=t*Math.sin(n),r=Es(Math.exp(t*Math.log((1+i)/(1-i))/2),e)}while(Math.abs(r-n)>1e-12);return r}function J1(t){t.k0||(t.k0=1);var e=t.b/t.a;t.e=Math.sqrt(1-e*e),t.lc=t.long0,t.rs=Math.sqrt(1+t.e*t.e*Math.pow(Math.cos(t.lat0),4)/(1-t.e*t.e));var r=Math.sin(t.lat0),n=Math.asin(r/t.rs),i=Math.sin(n);t.cp=Wt(0,n,i)-t.rs*Wt(t.e,t.lat0,r),t.n2=t.k0*t.a*Math.sqrt(1-t.e*t.e)/(1-t.e*t.e*r*r),t.xs=t.x0,t.ys=t.y0-t.n2*n}function Ou(t,e){var r=e.x,n=e.y,i=t.rs*(r-t.lc),o=t.cp+t.rs*Wt(t.e,n,Math.sin(n)),s=Math.asin(Math.sin(i)/Nr(o)),a=Wt(0,s,Math.sin(s));return e.x=t.xs+t.n2*a,e.y=t.ys+t.n2*Math.atan(Tt(o)/Math.cos(i)),e}function Nu(t,e){var r=e.x,n=e.y,i=Math.atan(Tt((r-t.xs)/t.n2)/Math.cos((n-t.ys)/t.n2)),o=Math.asin(Math.sin((n-t.ys)/t.n2)/Nr((r-t.xs)/t.n2)),s=Wt(0,o,Math.sin(o));return e.x=t.lc+i/t.rs,e.y=Iu(t.e,(s-t.cp)/t.rs),e}function Lu(t,e={}){let r={...t,lc:0,rs:0,cp:0,n2:0,xs:0,ys:0,...e};return J1(r),r}var Ts={name:"gstmerc",aliases:["gstmerg"],parameters:["lon_0","x_0","y_0","lat_0","k","k_0"],create(t){let e=q(t),r=Lu(e);return z("gstmerc",t,r,Ou,Nu)}};function eg(t){t.a=6377397155e-3,t.es=.006674372230614,t.e=Math.sqrt(t.es),t.s45=.785398163397448,t.s90=2*t.s45,t.fi0=t.lat0,t.e2=t.es,t.e=Math.sqrt(t.e2),t.alfa=Math.sqrt(1+t.e2*Math.pow(Math.cos(t.fi0),4)/(1-t.e2)),t.uq=1.04216856380474,t.u0=Math.asin(Math.sin(t.fi0)/t.alfa),t.g=Math.pow((1+t.e*Math.sin(t.fi0))/(1-t.e*Math.sin(t.fi0)),t.alfa*t.e/2),t.k=Math.tan(t.u0/2+t.s45)/Math.pow(Math.tan(t.fi0/2+t.s45),t.alfa)*t.g,t.k1=t.k0,t.n0=t.a*Math.sqrt(1-t.e2)/(1-t.e2*Math.pow(Math.sin(t.fi0),2)),t.s0=1.37008346281555,t.n=Math.sin(t.s0),t.ro0=t.k1*t.n0/Math.tan(t.s0),t.ad=t.s90-t.uq}function Gu(t,e){var r,n,i,o,s,a,c,l=e.x,h=e.y,u=b(l-t.long0,t.over);return r=Math.pow((1+t.e*Math.sin(h))/(1-t.e*Math.sin(h)),t.alfa*t.e/2),n=2*(Math.atan(t.k*Math.pow(Math.tan(h/2+t.s45),t.alfa)/r)-t.s45),i=-u*t.alfa,o=Math.asin(Math.cos(t.ad)*Math.sin(n)+Math.sin(t.ad)*Math.cos(n)*Math.cos(i)),s=Math.asin(Math.cos(n)*Math.sin(i)/Math.cos(o)),a=t.n*s,c=t.ro0*Math.pow(Math.tan(t.s0/2+t.s45),t.n)/Math.pow(Math.tan(o/2+t.s45),t.n),e.y=c*Math.cos(a)/1,e.x=c*Math.sin(a)/1,t.czech||(e.y*=-1,e.x*=-1),e}function qu(t,e){var r,n,i,o,s,a,c,l,h=e.x;e.x=e.y,e.y=h,t.czech||(e.y*=-1,e.x*=-1),a=Math.sqrt(e.x*e.x+e.y*e.y),s=Math.atan2(e.y,e.x),o=s/Math.sin(t.s0),i=2*(Math.atan(Math.pow(t.ro0/a,1/t.n)*Math.tan(t.s0/2+t.s45))-t.s45),r=Math.asin(Math.cos(t.ad)*Math.sin(i)-Math.sin(t.ad)*Math.cos(i)*Math.cos(o)),n=Math.asin(Math.cos(i)*Math.sin(o)/Math.cos(r)),e.x=t.long0-n/t.alfa,c=r,l=0;var u=0;do e.y=2*(Math.atan(Math.pow(t.k,-1/t.alfa)*Math.pow(Math.tan(r/2+t.s45),1/t.alfa)*Math.pow((1+t.e*Math.sin(c))/(1-t.e*Math.sin(c)),t.e/2))-t.s45),Math.abs(c-e.y)<1e-10&&(l=1),c=e.y,u+=1;while(l===0&&u<15);return u>=15?null:e}function zu(t,e={}){let r={...t,s45:0,s90:0,fi0:0,e2:0,alfa:0,uq:0,u0:0,g:0,k:0,k1:0,n0:0,s0:0,n:0,ro0:0,ad:0,czech:!1,...e};return eg(r),r}var bs={name:"krovak",aliases:["Krovak","Krovak Modified","Krovak (North Orientated)","Krovak Modified (North Orientated)"],parameters:["lon_0","x_0","y_0","lat_0","k","k_0","czech","alpha","lat_ts"],flags:["czech"],create(t){let e=L(t.parameters,"alpha",30.28813972222222),r=L(t.parameters,"lat_ts",78.5);if(![30.28813972222222,30.28813975277778].some(o=>Math.abs(e-o)<=1e-10))throw new Error("Krovak requires its fixed cone-axis co-latitude");if(Math.abs(r-78.5)>1e-10)throw new Error("Krovak requires its fixed 78.5 degree pseudo standard parallel");let n=q(t);n.lat0=dt(t.parameters,"lat_0",49.5),n.long0=dt(t.parameters,"lon_0",24.83333333333333),n.k0=L(t.parameters,"k_0",L(t.parameters,"k",.9999));let i=zu(n,{czech:Ue(t.parameters,"czech")});return z("krovak",t,i,Gu,qu)}};function Bu(t,e){var r=e.x,n=e.y,i=b(r-t.long0,t.over),o=t.x0+t.a*i,s=t.y0+t.a*Math.log(Math.tan(Math.PI/4+n/2.5))*1.25;return e.x=o,e.y=s,e}function Du(t,e){e.x-=t.x0,e.y-=t.y0;var r=b(t.long0+e.x/t.a,t.over),n=2.5*(Math.atan(Math.exp(.8*e.y/t.a))-Math.PI/4);return e.x=r,e.y=n,e}function ku(t,e={}){let r={...t,...e};return r}var vs={name:"mill",aliases:["Miller_Cylindrical"],parameters:["lon_0","x_0","y_0"],create(t){let e=q(t),r=ku(e);return z("mill",t,r,Bu,Du)}};function tg(t){t.x0=t.x0!==void 0?t.x0:0,t.y0=t.y0!==void 0?t.y0:0,t.long0=t.long0!==void 0?t.long0:0}function Fu(t,e){var r=e.x,n=e.y,i=b(r-t.long0,t.over),o=n,s=Math.PI*Math.sin(n);for(let h=0;h<50;h++){if(Math.abs(Math.abs(n)-Math.PI/2)<1e-10){o=Math.sign(n)*Math.PI;break}var a=-(o+Math.sin(o)-s)/(1+Math.cos(o));if(o+=a,h===49)throw new Error("Mollweide forward did not converge");if(Math.abs(a)<1e-10)break}o/=2,Math.PI/2-Math.abs(n)<1e-10&&(i=0);var c=.900316316158*t.a*i*Math.cos(o)+t.x0,l=1.4142135623731*t.a*Math.sin(o)+t.y0;return e.x=c,e.y=l,e}function Uu(t,e){var r,n;e.x-=t.x0,e.y-=t.y0,n=e.y/(1.4142135623731*t.a),Math.abs(n)>.999999999999&&(n=Math.sign(n)*.999999999999),r=Math.asin(n);var i=b(t.long0+e.x/(.900316316158*t.a*Math.cos(r)),t.over);!t.over&&i<-Math.PI&&(i=-Math.PI),!t.over&&i>Math.PI&&(i=Math.PI),n=(2*r+Math.sin(2*r))/Math.PI,Math.abs(n)>1&&(n=Math.sign(n));var o=Math.asin(n);return e.x=i,e.y=o,e}function Vu(t,e={}){let r={...t,...e};return tg(r),r}var Ps={name:"moll",aliases:["Mollweide"],parameters:["lon_0","x_0","y_0"],create(t){let e=q(t),r=Vu(e);return z("moll",t,r,Fu,Uu)}};function rg(t){t.A=[],t.A[1]=.6399175073,t.A[2]=-.1358797613,t.A[3]=.063294409,t.A[4]=-.02526853,t.A[5]=.0117879,t.A[6]=-.0055161,t.A[7]=.0026906,t.A[8]=-.001333,t.A[9]=67e-5,t.A[10]=-34e-5,t.B_re=[],t.B_im=[],t.B_re[1]=.7557853228,t.B_im[1]=0,t.B_re[2]=.249204646,t.B_im[2]=.003371507,t.B_re[3]=-.001541739,t.B_im[3]=.04105856,t.B_re[4]=-.10162907,t.B_im[4]=.01727609,t.B_re[5]=-.26623489,t.B_im[5]=-.36249218,t.B_re[6]=-.6870983,t.B_im[6]=-1.1651967,t.C_re=[],t.C_im=[],t.C_re[1]=1.3231270439,t.C_im[1]=0,t.C_re[2]=-.577245789,t.C_im[2]=-.007809598,t.C_re[3]=.508307513,t.C_im[3]=-.112208952,t.C_re[4]=-.15094762,t.C_im[4]=.18200602,t.C_re[5]=1.01418179,t.C_im[5]=1.64497696,t.C_re[6]=1.9660549,t.C_im[6]=2.5127645,t.D=[],t.D[1]=1.5627014243,t.D[2]=.5185406398,t.D[3]=-.03333098,t.D[4]=-.1052906,t.D[5]=-.0368594,t.D[6]=.007317,t.D[7]=.0122,t.D[8]=.00394,t.D[9]=-.0013}function ju(t,e){var r,n=e.x,i=e.y,o=i-t.lat0,s=n-t.long0,a=o/Jo*1e-5,c=s,l=1,h=0;for(r=1;r<=10;r++)l=l*a,h=h+t.A[r]*l;var u=h,f=c,d=1,m=0,_,p,M=0,y=0;for(r=1;r<=6;r++)_=d*u-m*f,p=m*u+d*f,d=_,m=p,M=M+t.B_re[r]*d-t.B_im[r]*m,y=y+t.B_im[r]*d+t.B_re[r]*m;return e.x=y*t.a+t.x0,e.y=M*t.a+t.y0,e}function Wu(t,e){var r,n=e.x,i=e.y,o=n-t.x0,s=i-t.y0,a=s/t.a,c=o/t.a,l=1,h=0,u,f,d=0,m=0;for(r=1;r<=6;r++)u=l*a-h*c,f=h*a+l*c,l=u,h=f,d=d+t.C_re[r]*l-t.C_im[r]*h,m=m+t.C_im[r]*l+t.C_re[r]*h;for(var _=0;_<t.iterations;_++){var p=d,M=m,y,S,x=a,E=c;for(r=2;r<=6;r++)y=p*d-M*m,S=M*d+p*m,p=y,M=S,x=x+(r-1)*(t.B_re[r]*p-t.B_im[r]*M),E=E+(r-1)*(t.B_im[r]*p+t.B_re[r]*M);p=1,M=0;var T=t.B_re[1],R=t.B_im[1];for(r=2;r<=6;r++)y=p*d-M*m,S=M*d+p*m,p=y,M=S,T=T+r*(t.B_re[r]*p-t.B_im[r]*M),R=R+r*(t.B_im[r]*p+t.B_re[r]*M);var C=T*T+R*R;d=(x*T+E*R)/C,m=(E*T-x*R)/C}var O=d,v=m,A=1,I=0;for(r=1;r<=9;r++)A=A*O,I=I+t.D[r]*A;var k=t.lat0+I*Jo*1e5,B=t.long0+v;return e.x=B,e.y=k,e}function Hu(t,e={}){let r={...t,A:[],B_re:[],B_im:[],C_re:[],C_im:[],D:[],iterations:1,...e};return rg(r),r}var Rs={name:"nzmg",aliases:["New_Zealand_Map_Grid"],parameters:["lon_0","x_0","y_0","lat_0","iterations"],create(t){let e=q(t),r=L(t.parameters,"iterations",1);if(!Number.isInteger(r)||r<0||r>10)throw new Error("NZMG iterations must be an integer from 0 to 10");if(!Object.prototype.hasOwnProperty.call(t.parameters,"lat_0")||!Object.prototype.hasOwnProperty.call(t.parameters,"lon_0"))throw new Error("NZMG requires lat_0 and lon_0");let n=Hu(e,{iterations:r});return z("nzmg",t,n,ju,Wu)}};var Ht=1e-7;function ng(t){return t.no_uoff||t.no_off||["hotineobliquemercator","hotineobliquemercatorvarianta","hotineobliquemercatorazimuthnaturalorigin"].includes(t.projName.toLowerCase().replace(/[ _-]/g,""))}function ig(t){var e,r,n,i,o,s,a,c,l,h,u=0,f,d=0,m=0,_=0,p=0,M=0,y=0;t.k0||(t.k0=1),t.no_off=ng(t),t.no_rot=t.no_rot;var S=!1;Number.isFinite(t.alpha)&&(S=!0);var x=!1;if(Number.isFinite(t.rectified_grid_angle)&&(x=!0),S&&(y=t.alpha),x&&(u=t.rectified_grid_angle,S||(y=0,S=!0)),S||x)d=t.longc;else if(m=t.long1,p=t.lat1,_=t.long2,M=t.lat2,Math.abs(p-M)<=Ht||Math.abs(p)<=Ht||Math.abs(Math.abs(p)-w)<=Ht||Math.abs(Math.abs(t.lat0)-w)<=Ht||Math.abs(Math.abs(M)-w)<=Ht)throw new Error;var E=1-t.es;if(r=Math.sqrt(E),Math.abs(t.lat0)>1e-10?(c=Math.sin(t.lat0),n=Math.cos(t.lat0),e=1-t.es*c*c,t.B=n*n,t.B=Math.sqrt(1+t.es*t.B*t.B/E),t.A=t.B*t.k0*r/e,i=t.B*r/(n*Math.sqrt(e)),o=i*i-1,o<=0?o=0:(o=Math.sqrt(o),t.lat0<0&&(o=-o)),t.E=o+=i,t.E*=Math.pow(Ce(t.e,t.lat0,c),t.B)):(t.B=1/r,t.A=t.k0,t.E=i=o=1),S||x){S?(f=Math.asin(Math.sin(y)/i),x||(u=y)):(f=u,y=Math.asin(i*Math.sin(f)));let T=.5*(o-1/o)*Math.tan(f);i>1&&Math.abs(Math.cos(y))<=8*Number.EPSILON?T=Math.sign(t.lat0)*Math.sign(Math.sin(y)):Math.abs(T)>1&&Math.abs(T)<=1+8*Number.EPSILON&&(T=Math.sign(T)),t.lam0=d-Math.asin(T)/t.B}else s=Math.pow(Ce(t.e,p,Math.sin(p)),t.B),a=Math.pow(Ce(t.e,M,Math.sin(M)),t.B),o=t.E/s,l=(a-s)/(a+s),h=t.E*t.E,h=(h-a*s)/(h+a*s),e=m-_,e<-Math.PI?_-=pt:e>Math.PI&&(_+=pt),t.lam0=b(.5*(m+_)-Math.atan(h*Math.tan(.5*t.B*(m-_))/l)/t.B,t.over),f=Math.atan(2*Math.sin(t.B*b(m-t.lam0,t.over))/(o-1/o)),u=y=Math.asin(i*Math.sin(f));t.singam=Math.sin(f),t.cosgam=Math.cos(f),t.sinrot=Math.sin(u),t.cosrot=Math.cos(u),t.rB=1/t.B,t.ArB=t.A*t.rB,t.BrA=1/t.ArB,t.no_off?t.u_0=0:(t.u_0=Math.abs(t.ArB*Math.atan(Math.sqrt(i*i-1)/Math.cos(y))),t.lat0<0&&(t.u_0=-t.u_0)),o=.5*f,t.v_pole_n=t.ArB*Math.log(Math.tan(F-o)),t.v_pole_s=t.ArB*Math.log(Math.tan(F+o))}function $u(t,e){var r={x:0,y:0},n,i,o,s,a,c,l,h;if(e.x=e.x-t.lam0,Math.abs(Math.abs(e.y)-w)>1e-10){if(a=t.E/Math.pow(Ce(t.e,e.y,Math.sin(e.y)),t.B),c=1/a,n=.5*(a-c),i=.5*(a+c),s=Math.sin(t.B*e.x),o=(n*t.singam-s*t.cosgam)/i,Math.abs(Math.abs(o)-1)<1e-10)throw new Error;h=.5*t.ArB*Math.log((1-o)/(1+o)),c=Math.cos(t.B*e.x),Math.abs(c)<Ht?l=t.A*e.x:l=t.ArB*Math.atan2(n*t.cosgam+s*t.singam,c)}else h=e.y>0?t.v_pole_n:t.v_pole_s,l=t.ArB*e.y;return t.no_rot?(r.x=l,r.y=h):(l-=t.u_0,r.x=h*t.cosrot+l*t.sinrot,r.y=l*t.cosrot-h*t.sinrot),r.x=t.a*r.x+t.x0,r.y=t.a*r.y+t.y0,r}function Yu(t,e){var r,n,i,o,s,a,c,l={x:0,y:0};if(e.x=(e.x-t.x0)*(1/t.a),e.y=(e.y-t.y0)*(1/t.a),t.no_rot?(n=e.y,r=e.x):(n=e.x*t.cosrot-e.y*t.sinrot,r=e.y*t.cosrot+e.x*t.sinrot+t.u_0),i=Math.exp(-t.BrA*n),o=.5*(i-1/i),s=.5*(i+1/i),a=Math.sin(t.BrA*r),c=(a*t.cosgam+o*t.singam)/s,Math.abs(Math.abs(c)-1)<1e-10)l.x=0,l.y=c<0?-w:w;else{if(l.y=t.E/Math.sqrt((1+c)/(1-c)),l.y=Et(t.e,Math.pow(l.y,1/t.B)),l.y===1/0)throw new Error;l.x=-t.rB*Math.atan2(o*t.cosgam-a*t.singam,Math.cos(t.BrA*r))}return l.x+=t.lam0,l}function Ku(t,e={}){let r={...t,no_off:!1,no_rot:!1,alpha:NaN,rectified_grid_angle:NaN,longc:0,long1:0,long2:0,B:0,A:0,E:0,lam0:0,singam:0,cosgam:0,sinrot:0,cosrot:0,rB:0,ArB:0,BrA:0,u_0:0,v_pole_n:0,v_pole_s:0,no_uoff:!1,projName:"",...e};return ig(r),r}var Cs={name:"omerc",aliases:["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"],parameters:["lon_0","x_0","y_0","lat_0","k","k_0","alpha","gamma","lonc","lon_1","lon_2","lat_1","lat_2","no_off","no_uoff","no_rot"],flags:["no_off","no_uoff","no_rot"],create(t){let e=q(t);if(Math.abs(e.lat0)>=Math.PI/2)throw new Error("Oblique Mercator origin must be away from the poles");let n=Object.prototype.hasOwnProperty.call(t.parameters,"alpha")||Object.prototype.hasOwnProperty.call(t.parameters,"gamma")?["lonc"]:["lon_1","lat_1","lon_2","lat_2"];for(let o of n)if(!Object.prototype.hasOwnProperty.call(t.parameters,o))throw new Error("Oblique Mercator requires "+o);let i=Ku(e,{projName:t.parameters.proj||"omerc",alpha:L(t.parameters,"alpha",NaN)*Math.PI/180,rectified_grid_angle:L(t.parameters,"gamma",NaN)*Math.PI/180,longc:L(t.parameters,"lonc",0)*Math.PI/180,long1:L(t.parameters,"lon_1",0)*Math.PI/180,long2:L(t.parameters,"lon_2",0)*Math.PI/180,no_off:Ue(t.parameters,"no_off"),no_uoff:Ue(t.parameters,"no_uoff"),no_rot:Ue(t.parameters,"no_rot")});return z("omerc",t,i,$u,Yu)}};function og(t){t.sin_p14=Math.sin(t.lat0||0),t.cos_p14=Math.cos(t.lat0||0)}function Xu(t,e){var r,n,i,o,s,a,c,l,h=e.x,u=e.y;return i=b(h-(t.long0||0),t.over),r=Math.sin(u),n=Math.cos(u),o=Math.cos(i),a=t.sin_p14*r+t.cos_p14*n*o,s=1,(a>0||Math.abs(a)<=1e-10)&&(c=(t.x0||0)+t.a*s*n*Math.sin(i),l=(t.y0||0)+t.a*s*(t.cos_p14*r-t.sin_p14*n*o)),e.x=c,e.y=l,e}function Zu(t,e){var r,n,i,o,s,a,c,l,h;if(e.x-=t.x0||0,e.y-=t.y0||0,r=Math.sqrt(e.x*e.x+e.y*e.y),r>t.a*(1+1e-14))throw new Error("Coordinate is outside the orthographic disk");return n=we(r/t.a),i=Math.sin(n),o=Math.cos(n),l=t.long0||0,h=t.lat0||0,a=l,Math.abs(r)<=1e-10?(c=h,e.x=a,e.y=c,e):(c=we(o*t.sin_p14+e.y*i*t.cos_p14/r),s=Math.abs(h)-w,Math.abs(s)<=1e-10?(h>=0?a=b(l+Math.atan2(e.x,-e.y),t.over):a=b(l-Math.atan2(-e.x,e.y),t.over),e.x=a,e.y=c,e):(a=b(l+Math.atan2(e.x*i,r*t.cos_p14*o-e.y*t.sin_p14*i),t.over),e.x=a,e.y=c,e))}function Qu(t,e={}){let r={...t,sin_p14:0,cos_p14:0,...e};return og(r),r}var As={name:"ortho",aliases:[],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=q(t),r=Qu(e);return z("ortho",t,r,Xu,Zu,gt(e,0,!0))}};var Ju=20;function sg(t){t.temp=t.b/t.a,t.es=1-Math.pow(t.temp,2),t.e=Math.sqrt(t.es),t.e0=Cr(t.es),t.e1=Ar(t.es),t.e2=Ir(t.es),t.e3=Or(t.es),t.ml0=t.a*je(t.e0,t.e1,t.e2,t.e3,t.lat0)}function e0(t,e){var r=e.x,n=e.y,i,o,s,a=b(r-t.long0,t.over);if(s=a*Math.sin(n),t.sphere)Math.abs(n)<=1e-10?(i=t.a*a,o=-1*t.a*t.lat0):(i=t.a*Math.sin(s)/Math.tan(n),o=t.a*(Ve(n-t.lat0)+(1-Math.cos(s))/Math.tan(n)));else if(Math.abs(n)<=1e-10)i=t.a*a,o=-1*t.ml0;else{var c=Gr(t.a,t.e,Math.sin(n))/Math.tan(n);i=c*Math.sin(s),o=t.a*je(t.e0,t.e1,t.e2,t.e3,n)-t.ml0+c*(1-Math.cos(s))}return e.x=i+t.x0,e.y=o+t.y0,e}function t0(t,e){var r,n,i,o,s,a,c,l,h;if(i=e.x-t.x0,o=e.y-t.y0,t.sphere)if(Math.abs(o+t.a*t.lat0)<=1e-10)r=b(i/t.a+t.long0,t.over),n=0;else{a=t.lat0+o/t.a,c=i*i/t.a/t.a+a*a,l=a;var u;for(s=Ju;s;--s)if(u=Math.tan(l),h=-1*(a*(l*u+1)-l-.5*(l*l+c)*u)/((l-a)/u-1),l+=h,Math.abs(h)<=1e-10){n=l;break}r=b(t.long0+Math.asin(i*Math.tan(l)/t.a)/Math.sin(n),t.over)}else if(Math.abs(o+t.ml0)<=1e-10)n=0,r=b(t.long0+i/t.a,t.over);else{a=(t.ml0+o)/t.a,c=i*i/t.a/t.a+a*a,l=a;var f,d,m,_,p;for(s=Ju;s;--s)if(p=t.e*Math.sin(l),f=Math.sqrt(1-p*p)*Math.tan(l),d=t.a*je(t.e0,t.e1,t.e2,t.e3,l),m=t.e0-2*t.e1*Math.cos(2*l)+4*t.e2*Math.cos(4*l)-6*t.e3*Math.cos(6*l),_=d/t.a,h=(a*(f*_+1)-_-.5*f*(_*_+c))/(t.es*Math.sin(2*l)*(_*_+c-2*a*_)/(4*f)+(a-_)*(f*m-2/Math.sin(2*l))-m),l-=h,Math.abs(h)<=1e-10){n=l;break}f=Math.sqrt(1-t.es*Math.pow(Math.sin(n),2))*Math.tan(n),r=b(t.long0+Math.asin(i*f/t.a)/Math.sin(n),t.over)}return e.x=r,e.y=n,e}function r0(t,e={}){let r={...t,temp:0,e0:0,e1:0,e2:0,e3:0,ml0:0,...e};return sg(r),r}var Is={name:"poly",aliases:["Polyconic","American_Polyconic"],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=q(t),r=r0(e);return z("poly",t,r,e0,t0)}};var Z={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},U={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function ag(t){t.x0=t.x0||0,t.y0=t.y0||0,t.lat0=t.lat0||0,t.long0=t.long0||0,t.lat_ts=t.lat_ts||0,t.lat0>=w-F/2?t.face=Z.TOP:t.lat0<=-(w-F/2)?t.face=Z.BOTTOM:Math.abs(t.long0)<=F?t.face=Z.FRONT:Math.abs(t.long0)<=w+F?t.face=t.long0>0?Z.RIGHT:Z.LEFT:t.face=Z.BACK,t.es!==0&&(t.one_minus_f=1-(t.a-t.b)/t.a,t.one_minus_f_squared=t.one_minus_f*t.one_minus_f)}function n0(t,e){var r={x:0,y:0},n,i,o,s,a,c,l={value:0};if(e.x-=t.long0,t.es!==0?n=Math.atan(t.one_minus_f_squared*Math.tan(e.y)):n=e.y,i=e.x,t.face===Z.TOP)s=w-n,i>=F&&i<=w+F?(l.value=U.AREA_0,o=i-w):i>w+F||i<=-(w+F)?(l.value=U.AREA_1,o=i>0?i-X:i+X):i>-(w+F)&&i<=-F?(l.value=U.AREA_2,o=i+w):(l.value=U.AREA_3,o=i);else if(t.face===Z.BOTTOM)s=w+n,i>=F&&i<=w+F?(l.value=U.AREA_0,o=-i+w):i<F&&i>=-F?(l.value=U.AREA_1,o=-i):i<-F&&i>=-(w+F)?(l.value=U.AREA_2,o=-i-w):(l.value=U.AREA_3,o=i>0?-i+X:-i-X);else{var h,u,f,d,m,_,p;t.face===Z.RIGHT?i=$t(i,+w):t.face===Z.BACK?i=$t(i,+X):t.face===Z.LEFT&&(i=$t(i,-w)),d=Math.sin(n),m=Math.cos(n),_=Math.sin(i),p=Math.cos(i),h=m*p,u=m*_,f=d,t.face===Z.FRONT?(s=Math.acos(h),o=yi(s,f,u,l)):t.face===Z.RIGHT?(s=Math.acos(u),o=yi(s,f,-h,l)):t.face===Z.BACK?(s=Math.acos(-h),o=yi(s,f,-u,l)):t.face===Z.LEFT?(s=Math.acos(-u),o=yi(s,f,h,l)):(s=o=0,l.value=U.AREA_0)}return c=Math.atan(12/X*(o+Math.acos(Math.sin(o)*Math.cos(F))-w)),a=Math.sqrt((1-Math.cos(s))/(Math.cos(c)*Math.cos(c))/(1-Math.cos(Math.atan(1/Math.cos(o))))),l.value===U.AREA_1?c+=w:l.value===U.AREA_2?c+=X:l.value===U.AREA_3&&(c+=1.5*X),r.x=a*Math.cos(c),r.y=a*Math.sin(c),r.x=r.x*t.a+t.x0,r.y=r.y*t.a+t.y0,e.x=r.x,e.y=r.y,e}function i0(t,e){var r={lam:0,phi:0},n,i,o,s,a,c,l,h,u,f={value:0};if(e.x=(e.x-t.x0)/t.a,e.y=(e.y-t.y0)/t.a,i=Math.atan(Math.sqrt(e.x*e.x+e.y*e.y)),n=Math.atan2(e.y,e.x),e.x>=0&&e.x>=Math.abs(e.y)?f.value=U.AREA_0:e.y>=0&&e.y>=Math.abs(e.x)?(f.value=U.AREA_1,n-=w):e.x<0&&-e.x>=Math.abs(e.y)?(f.value=U.AREA_2,n=n<0?n+X:n-X):(f.value=U.AREA_3,n+=w),u=X/12*Math.tan(n),a=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),c=Math.atan(a),o=Math.cos(n),s=Math.tan(i),l=1-o*o*s*s*(1-Math.cos(Math.atan(1/Math.cos(c)))),l<-1?l=-1:l>1&&(l=1),t.face===Z.TOP)h=Math.acos(l),r.phi=w-h,f.value===U.AREA_0?r.lam=c+w:f.value===U.AREA_1?r.lam=c<0?c+X:c-X:f.value===U.AREA_2?r.lam=c-w:r.lam=c;else if(t.face===Z.BOTTOM)h=Math.acos(l),r.phi=h-w,f.value===U.AREA_0?r.lam=-c+w:f.value===U.AREA_1?r.lam=-c:f.value===U.AREA_2?r.lam=-c-w:r.lam=c<0?-c-X:-c+X;else{var d,m,_;d=l,u=d*d,u>=1?_=0:_=Math.sqrt(1-u)*Math.sin(c),u+=_*_,u>=1?m=0:m=Math.sqrt(1-u),f.value===U.AREA_1?(u=m,m=-_,_=u):f.value===U.AREA_2?(m=-m,_=-_):f.value===U.AREA_3&&(u=m,m=_,_=-u),t.face===Z.RIGHT?(u=d,d=-m,m=u):t.face===Z.BACK?(d=-d,m=-m):t.face===Z.LEFT&&(u=d,d=m,m=-u),r.phi=Math.acos(-_)-w,r.lam=Math.atan2(m,d),t.face===Z.RIGHT?r.lam=$t(r.lam,-w):t.face===Z.BACK?r.lam=$t(r.lam,-X):t.face===Z.LEFT&&(r.lam=$t(r.lam,+w))}if(t.es!==0){var p,M,y;p=r.phi<0?1:0,M=Math.tan(r.phi),y=t.b/Math.sqrt(M*M+t.one_minus_f_squared),r.phi=Math.atan(Math.sqrt(t.a*t.a-y*y)/(t.one_minus_f*y)),p&&(r.phi=-r.phi)}return r.lam+=t.long0,e.x=r.lam,e.y=r.phi,e}function yi(t,e,r,n){var i;return t<1e-10?(n.value=U.AREA_0,i=0):(i=Math.atan2(e,r),Math.abs(i)<=F?n.value=U.AREA_0:i>F&&i<=w+F?(n.value=U.AREA_1,i-=w):i>w+F||i<=-(w+F)?(n.value=U.AREA_2,i=i>=0?i-X:i+X):(n.value=U.AREA_3,i+=w)),i}function $t(t,e){var r=t+e;return r<-X?r+=pt:r>+X&&(r-=pt),r}function o0(t,e={}){let r={...t,face:0,one_minus_f:0,one_minus_f_squared:0,...e};return ag(r),r}var Os={name:"qsc",aliases:["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube"],parameters:["lon_0","x_0","y_0","lat_0"],create(t){let e=q(t),r=o0(e);return z("qsc",t,r,n0,i0)}};var Yt=[[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]],_t=[[-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]];Yt=Yt.map(t=>t.map(Math.fround));_t=_t.map(t=>t.map(Math.fround));var s0=.8487,a0=1.3523,c0=Qo/5,cg=1/c0,bt=18,xi=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))},lg=function(t,e){return t[1]+e*(2*t[2]+e*3*t[3])};function hg(t,e,r,n){for(var i=e;n;--n){var o=t(i);if(i-=o,Math.abs(o)<r)break}return i}function ug(t){t.x0=t.x0||0,t.y0=t.y0||0,t.long0=t.long0||0,t.es=0}function l0(t,e){var r=b(e.x-t.long0,t.over),n=Math.abs(e.y),i=Math.floor(n*c0+1e-15);i<0?i=0:i>=bt&&(i=bt),n=Qo*(n-cg*i);var o={x:xi(Yt[i],n)*r,y:xi(_t[i],n)};return e.y<0&&(o.y=-o.y),o.x=o.x*t.a*s0+t.x0,o.y=o.y*t.a*a0+t.y0,o}function h0(t,e){var r={x:(e.x-t.x0)/(t.a*s0),y:Math.abs(e.y-t.y0)/(t.a*a0)};for(let s=0;s<=bt;s++)if(Math.abs(r.y-_t[s][0])<=8*Number.EPSILON)return r.x=b(r.x/Yt[s][0]+t.long0,t.over),r.y=(e.y<t.y0?-1:1)*s*5*Zo,r;if(r.y>=1)r.x/=Yt[bt][0],r.y=e.y<0?-w:w;else{var n=Math.floor(r.y*bt);for(n<0?n=0:n>=bt&&(n=bt-1);;)if(_t[n][0]>r.y)--n;else if(_t[n+1][0]<=r.y)++n;else break;var i=_t[n],o=5*(r.y-i[0])/(_t[n+1][0]-i[0]);o=hg(function(s){return(xi(i,s)-r.y)/lg(i,s)},o,1e-10,100),r.x/=xi(Yt[n],o),r.y=(5*n+o)*Zo,e.y<0&&(r.y=-r.y)}return r.x=b(r.x+t.long0,t.over),r}function u0(t,e={}){let r={...t,...e};return ug(r),r}var Ns={name:"robin",aliases:["Robinson"],parameters:["lon_0","x_0","y_0"],create(t){let e=q(t),r=u0(e);return z("robin",t,r,l0,h0)}};var Ls={name:"sinu",aliases:["Sinusoidal"],parameters:["lon_0","x_0","y_0"],create(t){let e=q(t),r=pu(e);return z("sinu",t,r,gi,_i)}};function fg(t){t.k0||(t.k0=1);var e=t.lat0;t.lambda0=t.long0;var r=Math.sin(e),n=t.a,i=t.rf,o=1/i,s=2*o-Math.pow(o,2);t.e=Math.sqrt(s);var a=t.e;t.R=t.k0*n*Math.sqrt(1-s)/(1-s*Math.pow(r,2)),t.alpha=Math.sqrt(1+s/(1-s)*Math.pow(Math.cos(e),4)),t.b0=Math.asin(r/t.alpha);var c=Math.log(Math.tan(Math.PI/4+t.b0/2)),l=Math.log(Math.tan(Math.PI/4+e/2)),h=Math.log((1+a*r)/(1-a*r));t.K=c-t.alpha*l+t.alpha*a/2*h}function f0(t,e){var r=Math.log(Math.tan(Math.PI/4-e.y/2)),n=t.e/2*Math.log((1+t.e*Math.sin(e.y))/(1-t.e*Math.sin(e.y))),i=-t.alpha*(r+n)+t.K,o=2*(Math.atan(Math.exp(i))-Math.PI/4),s=t.alpha*(e.x-t.lambda0),a=Math.atan(Math.sin(s)/(Math.sin(t.b0)*Math.tan(o)+Math.cos(t.b0)*Math.cos(s))),c=Math.asin(Math.cos(t.b0)*Math.sin(o)-Math.sin(t.b0)*Math.cos(o)*Math.cos(s));return e.y=t.R/2*Math.log((1+Math.sin(c))/(1-Math.sin(c)))+t.y0,e.x=t.R*a+t.x0,e}function d0(t,e){for(var r=e.x-t.x0,n=e.y-t.y0,i=r/t.R,o=2*(Math.atan(Math.exp(n/t.R))-Math.PI/4),s=Math.asin(Math.cos(t.b0)*Math.sin(o)+Math.sin(t.b0)*Math.cos(o)*Math.cos(i)),a=Math.atan(Math.sin(i)/(Math.cos(t.b0)*Math.cos(i)-Math.sin(t.b0)*Math.tan(o))),c=t.lambda0+a/t.alpha,l=0,h=s,u=-1e3,f=0;Math.abs(h-u)>1e-7;){if(++f>20)return;l=1/t.alpha*(Math.log(Math.tan(Math.PI/4+s/2))-t.K)+t.e*Math.log(Math.tan(Math.PI/4+Math.asin(t.e*Math.sin(h))/2)),u=h,h=2*Math.atan(Math.exp(l))-Math.PI/2}return e.x=c,e.y=h,e}function m0(t,e={}){let r={...t,lambda0:0,rf:0,R:0,alpha:0,b0:0,K:0,...e};return fg(r),r}var Gs={name:"somerc",aliases:[],parameters:["lon_0","x_0","y_0","lat_0","k","k_0"],create(t){let e=q(t),r=m0(e,{rf:e.a===e.b?1/0:1/(1-e.b/e.a)});return z("somerc",t,r,f0,d0)}};var me={N_POLE:0,S_POLE:1,EQUIT:2,OBLIQ:3};function dg(t){if(Math.abs(Math.abs(t.lat0)-w)<1e-10?t.mode=t.lat0<0?me.S_POLE:me.N_POLE:Math.abs(t.lat0)<1e-10?t.mode=me.EQUIT:(t.mode=me.OBLIQ,t.sinph0=Math.sin(t.lat0),t.cosph0=Math.cos(t.lat0)),t.pn1=t.h/t.a,t.pn1<=0||t.pn1>1e10)throw new Error("Invalid height");t.p=1+t.pn1,t.rp=1/t.p,t.h1=1/t.pn1,t.pfact=(t.p+1)*t.h1,t.es=0;var e=t.tilt,r=t.azi;t.cg=Math.cos(r),t.sg=Math.sin(r),t.cw=Math.cos(e),t.sw=Math.sin(e)}function p0(t,e){e.x-=t.long0;var r=Math.sin(e.y),n=Math.cos(e.y),i=Math.cos(e.x),o,s;switch(t.mode){case me.OBLIQ:s=t.sinph0*r+t.cosph0*n*i;break;case me.EQUIT:s=n*i;break;case me.S_POLE:s=-r;break;case me.N_POLE:s=r;break}switch(s=t.pn1/(t.p-s),o=s*n*Math.sin(e.x),t.mode){case me.OBLIQ:s*=t.cosph0*r-t.sinph0*n*i;break;case me.EQUIT:s*=r;break;case me.N_POLE:s*=-(n*i);break;case me.S_POLE:s*=n*i;break}var a,c;return a=s*t.cg+o*t.sg,c=1/(a*t.sw*t.h1+t.cw),o=(o*t.cg-s*t.sg)*t.cw*c,s=a*c,e.x=o*t.a,e.y=s*t.a,e}function g0(t,e){e.x/=t.a,e.y/=t.a;var r={x:e.x,y:e.y},n,i,o;o=1/(t.pn1-e.y*t.sw),n=t.pn1*e.x*o,i=t.pn1*e.y*t.cw*o,e.x=n*t.cg+i*t.sg,e.y=i*t.cg-n*t.sg;var s=ne(e.x,e.y);if(Math.abs(s)<1e-10)r.x=0,r.y=t.lat0;else{var a,c;switch(c=1-s*s*t.pfact,c=(t.p-Math.sqrt(c))/(t.pn1/s+s/t.pn1),a=Math.sqrt(1-c*c),t.mode){case me.OBLIQ:r.y=Math.asin(a*t.sinph0+e.y*c*t.cosph0/s),e.y=(a-t.sinph0*Math.sin(r.y))*s,e.x*=c*t.cosph0;break;case me.EQUIT:r.y=Math.asin(e.y*c/s),e.y=a*s,e.x*=c;break;case me.N_POLE:r.y=Math.asin(a),e.y=-e.y;break;case me.S_POLE:r.y=-Math.asin(a);break}r.x=Math.atan2(e.x,e.y)}return e.x=r.x+t.long0,e.y=r.y,e}function _0(t,e={}){let r={...t,mode:0,sinph0:0,cosph0:0,pn1:0,h:0,p:0,rp:0,h1:0,pfact:0,tilt:0,azi:0,cg:0,sg:0,cw:0,sw:0,...e};return dg(r),r}var qs={name:"tpers",aliases:["Tilted_Perspective"],parameters:["lon_0","x_0","y_0","lat_0","h","tilt","azi"],create(t){let e=q(t),r=L(t.parameters,"h",1e5),n=L(t.parameters,"tilt",0)*Math.PI/180,i=L(t.parameters,"azi",0)*Math.PI/180;if(Math.abs(n)>=Math.PI/2)throw new Error("Perspective tilt must be between -90 and 90 degrees");let o=_0(e,{h:r,tilt:n,azi:i});return z("tpers",t,o,p0,g0,gt(e,1/(1+r/e.a)))}};function mg(t){t.R=t.a}function M0(t,e){var r=e.x,n=e.y,i=b(r-t.long0,t.over),o,s;if(Math.abs(n)<=1e-10)return o=t.x0+t.R*i,s=t.y0,e.x=o,e.y=s,e;var a=we(2*Math.abs(n/Math.PI));if(Math.abs(i)<=1e-10||Math.abs(Math.abs(n)-w)<=1e-10)return o=t.x0,n>=0?s=t.y0+Math.PI*t.R*Math.tan(.5*a):s=t.y0+Math.PI*t.R*-Math.tan(.5*a),e.x=o,e.y=s,e;var c=.5*Math.abs(Math.PI/i-i/Math.PI),l=c*c,h=Math.sin(a),u=Math.cos(a),f=u/(h+u-1),d=f*f,m=f*(2/h-1),_=m*m,p=Math.PI*t.R*(c*(f-_)+Math.sqrt(l*(f-_)*(f-_)-(_+l)*(d-_)))/(_+l);i<0&&(p=-p),o=t.x0+p;var M=l+f;return p=Math.PI*t.R*(m*M-c*Math.sqrt((_+l)*(l+1)-M*M))/(_+l),n>=0?s=t.y0+p:s=t.y0-p,e.x=o,e.y=s,e}function y0(t,e){var r,n,i,o,s,a,c,l,h,u,f,d,m;return e.x-=t.x0,e.y-=t.y0,Math.abs(e.y)<1e-10?(e.x=b(t.long0+e.x/t.R,t.over),e.y=0,e):(f=Math.PI*t.R,i=e.x/f,o=e.y/f,s=i*i+o*o,a=-Math.abs(o)*(1+s),c=a-2*o*o+i*i,l=-2*a+1+2*o*o+s*s,m=o*o/l+(2*c*c*c/l/l/l-9*a*c/l/l)/27,h=(a-c*c/3/l)/l,u=2*Math.sqrt(-h/3),f=3*m/h/u,Math.abs(f)>1&&(f>=0?f=1:f=-1),d=Math.acos(f)/3,e.y>=0?n=(-u*Math.cos(d+Math.PI/3)-c/3/l)*Math.PI:n=-(-u*Math.cos(d+Math.PI/3)-c/3/l)*Math.PI,Math.abs(i)<1e-10?r=t.long0:r=b(t.long0+Math.PI*(s-1+Math.sqrt(1+2*(i*i-o*o)+s*s))/2/i,t.over),e.x=r,e.y=n,e)}function x0(t,e={}){let r={...t,R:0,...e};return mg(r),r}var zs={name:"vandg",aliases:["Van_der_Grinten_I","VanDerGrinten","Van_der_Grinten"],parameters:["lon_0","x_0","y_0"],create(t){let e=q(t),r=x0(e);return z("vandg",t,r,M0,y0)}};var S0=["o_proj","o_alpha","o_lon_c","o_lat_c","o_lon_p","o_lat_p","o_lon_1","o_lat_1","o_lon_2","o_lat_2"],Bs=t=>t.toLowerCase().replace(/[ _-]/g,""),Ds=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),We=(t,e)=>L(t,e,0)*Math.PI/180;function pg(t){let e=[["o_alpha","o_lon_c","o_lat_c"],["o_lat_p","o_lon_p"],["o_lon_1","o_lat_1","o_lon_2","o_lat_2"]],r=e.find(c=>c.some(l=>Ds(t,l)));if(!r)throw new Error("Oblique transformation requires a rotation parameter set");for(let c of r){if(!Ds(t,c))throw new Error("Oblique transformation requires "+c);if(c.includes("lat")&&Math.abs(We(t,c))>Math.PI/2)throw new Error("Invalid rotation latitude: "+c)}if(r===e[0]){let c=We(t,"o_alpha"),l=We(t,"o_lon_c"),h=We(t,"o_lat_c");if(Math.abs(h)>=Math.PI/2-1e-10)throw new Error("Rotation center must be away from the poles");return{lamp:l+Math.atan2(-Math.cos(c),-Math.sin(c)*Math.sin(h)),phip:Math.asin(Math.cos(h)*Math.sin(c))}}if(r===e[1])return{lamp:We(t,"o_lon_p"),phip:We(t,"o_lat_p")};let n=We(t,"o_lon_1"),i=We(t,"o_lat_1"),o=We(t,"o_lon_2"),s=We(t,"o_lat_2");if(Math.abs(i)>=Math.PI/2-1e-10||Math.abs(s)>=Math.PI/2-1e-10||Math.abs(i)<1e-10||Math.abs(i-s)<1e-10)throw new Error("Invalid new-equator reference points");let a=Math.atan2(Math.cos(i)*Math.sin(s)*Math.cos(n)-Math.sin(i)*Math.cos(s)*Math.cos(o),Math.sin(i)*Math.cos(s)*Math.sin(o)-Math.cos(i)*Math.sin(s)*Math.sin(n));return{lamp:a,phip:Math.atan(-Math.cos(a-n)/Math.tan(i))}}function Si(t){let e=t==="longlat";if(!e&&["obtran","geocent"].includes(Bs(t.name)))throw new Error("Cannot wrap a composite or geocentric projection");return{name:"ob_tran",aliases:["General Oblique Transformation","General_Oblique_Transformation"],parameters:[...S0,"lon_0",...e?[]:t.parameters],flags:e?[]:t.flags,create(r){let{parameters:n}=r,i=n.o_proj,o=e?["longlat","latlong","lonlat","latlon","identity"]:[t.name,...t.aliases||[]];if(i&&!o.map(Bs).includes(Bs(i)))throw new Re("missing-plugin","Oblique transformation dependency does not match +o_proj="+i);let{lamp:s,phip:a}=pg(n),c=Math.cos(a),l=Math.sin(a),h=Math.abs(a)>1e-10,u=We(n,"lon_0"),f=Ds(n,"over"),d={...n,proj:e?"longlat":i||t.name,lon_0:"0"};for(let y of S0)delete d[y];let m=e?Ge(y=>{y.x*=180/Math.PI,y.y*=180/Math.PI},y=>{y.x*=Math.PI/180,y.y*=Math.PI/180}):t.create({...r,parameters:Object.freeze(d)}),_=ct(m,!1),p=ct(m,!0),M=y=>Math.asin(Math.max(-1,Math.min(1,y)));return Ge(y=>{let S=y.x,x=y.y,E=f?S-u:qe(S-u),T=Math.cos(E),R=Math.sin(x),C=Math.cos(x),O=qe(Math.atan2(C*Math.sin(E),h?l*C*T+c*R:R)+s),v=M(h?l*R-c*C*T:-C*T);y.x=O,y.y=v,_(y)},y=>{p(y);let S=y.x,x=y.y,E=S-s,T=Math.cos(E),R=Math.sin(x),C=Math.cos(x),O=Math.atan2(C*Math.sin(E),h?l*C*T-c*R:-R),v=M(h?l*R+c*C*T:C*T);y.x=qe(O+u),y.y=v})}}}function Q(t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Expected a CRS object");return t}function kr(t){return Array.isArray(t)?t:[]}function pe(t){return String(t||"").toLowerCase().replace(/[^a-z0-9]/g,"")}function Ie(t){if(typeof t!="number"||!Number.isFinite(t))throw new Error("Expected a finite CRS parameter");return t}function Ee(t,e){if(t===void 0)return e;if(typeof t=="object"){let i=Ie(Q(t).conversion_factor);if(i<=0)throw new Error("Unit conversion factor must be positive");return i}let n={metre:1,meter:1,degree:ee,radian:1,grad:Math.PI/200,gon:Math.PI/200,foot:.3048,ussurveyfoot:1200/3937,kilometre:1e3,arcsecond:ee/3600,partspermillion:1e-6,unity:1}[pe(t)];return n||D("Unsupported CRS unit: "+String(t)),n}var gg={hotineobliquemercator:"omerc",hotineobliquemercatorvarianta:"omerc",hotineobliquemercatorvariantb:"omerc",hotineobliquemercatorazimuthnaturalorigin:"omerc",hotineobliquemercatorazimuthcenter:"omerc",obliquemercator:"omerc",krovak:"krovak",krovaknorthorientated:"krovak",quadrilateralizedsphericalcube:"qsc",transversemercator:"tmerc",transversemercatorsouthorientated:"unsupported-south-tmerc",mercator:"merc",mercator1sp:"merc",mercator2sp:"merc",mercatorvarianta:"merc",mercatorvariantb:"merc",mercatorauxiliarysphere:"webmerc",popularvisualisationpseudomercator:"webmerc",lambertconformalconic:"lcc",lambertconformalconic1sp:"lcc",lambertconformalconic2sp:"lcc",lambertconicconformal1sp:"lcc",lambertconicconformal2sp:"lcc",albers:"aea",albersconicequalarea:"aea",albersequalarea:"aea",equidistantconic:"eqdc",lambertazimuthalequalarea:"laea",stereographic:"stere",stereographicnorthpole:"sterea",stereographicsouthpole:"stere",polarstereographic:"stere",polarstereographicvarianta:"stere",polarstereographicvariantb:"stere",obliquestereographic:"sterea",doublestereographic:"sterea",azimuthalequidistant:"aeqd",modifiedazimuthalequidistant:"aeqd",equidistantcylindrical:"eqc",equidistantcylindricalspherical:"eqc",equirectangular:"eqc",platecarree:"eqc",bonne:"bonne",cassinisoldner:"cass",cassini:"cass",cylindricalequalarea:"cea",lambertcylindricalequalarea:"cea",eckertvi:"eck6",equalearth:"eqearth",millercylindrical:"mill",mollweide:"moll",robinson:"robin",sinusoidal:"sinu",vandergrinten:"vandg",vandergrinteni:"vandg",gnomonic:"gnom",orthographic:"ortho",polyconic:"poly",americanpolyconic:"poly",newzealandmapgrid:"nzmg",gaussschreibertransversemercator:"gstmerc"},_g={centralmeridian:"lon_0",longitudeoforigin:"lon_0",longitudeofcenter:"lon_0",longitudeofnaturalorigin:"lon_0",longitudeoffalseorigin:"lon_0",longitudeofprojectioncentre:"lon_0",straightverticalpolelongitude:"lon_0",longitudeoforiginmeridian:"lon_0",latitudeoforigin:"lat_0",latitudeofcenter:"lat_0",latitudeofnaturalorigin:"lat_0",latitudeoffalseorigin:"lat_0",latitudeofprojectioncentre:"lat_0",standardparallel1:"lat_1",latitudeof1ststandardparallel:"lat_1",standardparallel2:"lat_2",latitudeof2ndstandardparallel:"lat_2",latitudeofstandardparallel:"lat_ts",scalefactor:"k_0",scalefactoratnaturalorigin:"k_0",scalefactoratprojectionorigin:"k_0",falseeasting:"x_0",falsenorthing:"y_0",eastingatfalseorigin:"x_0",northingatfalseorigin:"y_0"},Mg={omerc:{longitudeofcenter:"lonc",longitudeofprojectioncentre:"lonc",azimuth:"alpha",azimuthatprojectioncentre:"alpha",rectifiedgridangle:"gamma",anglefromrectifiedtoskewgrid:"gamma",scalefactoratprojectioncentre:"k_0",eastingatprojectioncentre:"x_0",northingatprojectioncentre:"y_0"},krovak:{azimuth:"alpha",colatitudeofconeaxis:"alpha",pseudostandardparallel1:"lat_ts",latitudeofpseudostandardparallel:"lat_ts",scalefactoronpseudostandardparallel:"k_0"}},yg={east:"e",west:"w",north:"n",south:"s",up:"u",down:"d",geocentricx:"e",geocentricy:"n",geocentricz:"u"};function vt(t,e){let r=String(t.type);if(r==="CompoundCRS"){e.mode!=="horizontal"&&D("CompoundCRS requires explicit horizontal extraction");let S=kr(t.components).map(Q).filter(x=>["ProjectedCRS","GeographicCRS","GeodeticCRS","BoundCRS"].includes(String(x.type)));if(S.length!==1)throw new Error("CompoundCRS requires exactly one horizontal component");return{...vt(S[0],e),lossy:!0}}if(r==="BoundCRS"){let S=vt(Q(t.source_crs),e),x=vt(Q(t.target_crs),e);(x.parameters.datum!=="WGS84"||!["longlat","geocent"].includes(x.parameters.proj)||Number(x.parameters.pm||0)!==0||x.parameters.towgs84||Number(x.parameters.a)!==6378137||!(Math.abs(Number(x.parameters.rf)-298.257223563)<=1e-9||Math.abs(Number(x.parameters.b)-6356752314245179e-9)<=1e-6))&&D("BoundCRS requires a WGS84 target");let E=Q(t.transformation),T=pe(Q(E.method).name),R=T==="geocentrictranslations"||/^geocentrictranslationsgeog[23]ddomain$/.test(T),C=/^positionvector(?:transformation)?(?:geog[23]ddomain|geocentricdomain)?$/.test(T),O=/^coordinateframe(?:rotation)?(?:geog[23]ddomain|geocentricdomain)?$/.test(T);!R&&!C&&!O&&D("Unsupported BoundCRS transformation: "+T);let v=["xaxistranslation","yaxistranslation","zaxistranslation","xaxisrotation","yaxisrotation","zaxisrotation","scaledifference"],A=new Array(R?3:7).fill(void 0);for(let k of kr(E.parameters)){let B=Q(k),$=v.indexOf(pe(B.name));($<0||$>=A.length||A[$]!==void 0)&&D("Unsupported or duplicate Helmert parameter: "+String(B.name));let nt=$<3?1:$<6?ee/3600:1e-6;A[$]=Ie(B.value)*Ee(B.unit,nt)/nt*(O&&$>=3&&$<6?-1:1)}if(A.some(k=>k===void 0))throw new Error("Incomplete BoundCRS Helmert transformation");let I={...S.parameters,towgs84:A.join(",")};return delete I.datum,{...S,parameters:I}}["ProjectedCRS","GeographicCRS","GeodeticCRS"].includes(r)||D("Unsupported CRS type: "+r);let n=r==="ProjectedCRS"?Q(t.base_crs):t,i=Q(n.datum||n.datum_ensemble);(i.type==="DynamicGeodeticReferenceFrame"||i.frame_reference_epoch!==void 0||t.coordinate_epoch!==void 0)&&D("Time-dependent datum transformations are not implemented");let o=Q(i.ellipsoid),s=Ie(o.semi_major_axis??o.radius),a={proj:"longlat",a:String(s*Ee(o.unit,1))};if(o.inverse_flattening!==void 0)a.rf=String(Ie(o.inverse_flattening));else if(o.semi_minor_axis!==void 0)a.b=String(Ie(o.semi_minor_axis)*Ee(o.unit,1));else if(o.radius!==void 0)a.b=a.a;else throw new Error("Ellipsoid requires inverse flattening or semi-minor axis");let c=pe(i.name),l=Object.keys(br).find(S=>pe(S)===c||pe(S)===c.replace(/^d/,""));l&&(a.datum=l),["wgs84","worldgeodeticsystem1984","worldgeodeticsystem1984ensemble","dwgs1984","wgs1984"].includes(c)&&(a.datum="WGS84"),["nad83","northamericandatum1983","dnorthamerican1983"].includes(c)&&(a.datum="NAD83"),["nad27","northamericandatum1927","dnorthamerican1927"].includes(c)&&(a.datum="NAD27");let u={newzealand1949:"nzgd49",belge1972:"rnb72"}[c.replace(/^d/,"")];if(u&&(a.datum=u),r==="ProjectedCRS"&&n.id){let S=Q(n.id),x=String(S.authority)+"_"+String(S.code);Object.prototype.hasOwnProperty.call(br,x)&&(a.datum=x)}i.towgs84!==void 0&&(a.towgs84=kr(i.towgs84).map(Ie).join(","),delete a.datum);let f=t.coordinate_system?Q(t.coordinate_system):{},d=kr(f.axis).map(Q),m=pe(f.subtype)==="cartesian"&&r==="GeodeticCRS";r!=="ProjectedCRS"&&!m&&f.subtype&&pe(f.subtype)!=="ellipsoidal"&&D("Unsupported coordinate system subtype"),m&&(a.proj="geocent");let _=Ee(n.angular_unit,ee),p=Ee(d[0]?.unit,r==="ProjectedCRS"||m?1:_);d[1]&&Ee(d[1].unit,p)!==p&&D("Mixed horizontal axis units are not supported"),m&&d[2]&&Ee(d[2].unit,p)!==p&&D("Mixed geocentric axis units are not supported");let M=n.prime_meridian||i.prime_meridian;if(M){let S=Q(M);a.pm=String(Ie(S.longitude)*Ee(S.unit,_)/ee)}if(r==="ProjectedCRS"){let S=Q(t.conversion),x=pe(Q(S.method).name),E=kr(S.parameters).map(Q),T=x==="stereographicnorthpole"&&!E.some(v=>pe(v.name).startsWith("scalefactor")),R=T?"stere":gg[x],C=E.filter(v=>["xscale","yscale","xyplanerotation"].includes(pe(v.name)));if(C.length){let v={xscale:-1,yscale:1,xyplanerotation:90};(R!=="krovak"||C.length!==3||new Set(C.map(A=>pe(A.name))).size!==3||C.some(A=>{let I=pe(A.name),k=I==="xyplanerotation"?Ee(A.unit,_)/ee:Ee(A.unit,1);return Math.abs(Ie(A.value)*k-v[I])>1e-10}))&&D("Unsupported ESRI Krovak axis adjustment")}(!R||R.startsWith("unsupported"))&&D("Unsupported projection method: "+String(Q(S.method).name)),a.proj=R==="webmerc"?"merc":R;let O=!1;for(let v of E){let A=pe(v.name);if(C.includes(v)||A==="auxiliaryspheretype"&&R==="webmerc"&&v.value===0)continue;if(A==="semiminor"&&R==="webmerc"){if(O)throw new Error("Duplicate conversion parameter: semi_minor");O=!0;let nt=Ie(v.value)*Ee(v.unit,1);Math.abs(nt-Number(a.a))>4*Number.EPSILON*Number(a.a)&&D("Pseudo-Mercator semi_minor must equal the semi-major axis");continue}let I=Mg[R]?.[A]||_g[A];if(I||D("Unsupported conversion parameter: "+String(v.name)),I==="lat_1"&&x==="stereographicnorthpole"&&!T?I="lat_0":I==="lat_1"&&["merc","webmerc","eqc","stere","cea"].includes(R)&&(I="lat_ts"),a[I]!==void 0)throw new Error("Duplicate conversion parameter: "+I);if(["merc","webmerc"].includes(R)&&I==="lat_0"&&v.value===0)continue;let k=I.startsWith("lat")||I.startsWith("lon")||I==="alpha"||I==="gamma",B=I==="x_0"||I==="y_0",$=Ie(v.value)*Ee(v.unit,k?_:B?p:1)/(k?ee:1);I.startsWith("lat")&&Math.abs(Math.abs($)-90)<=4*Number.EPSILON*90&&($=Math.sign($)*90),a[I]=String($)}if(R==="omerc"&&["hotineobliquemercator","hotineobliquemercatorvarianta","hotineobliquemercatorazimuthnaturalorigin"].includes(x)&&(a.no_uoff=void 0),R==="omerc"&&a.lon_0!==void 0&&a.lonc!==void 0&&(Math.abs(Number(a.lon_0)-Number(a.lonc))>1e-10&&D("Oblique Mercator central meridian conflicts with projection centre"),delete a.lon_0),x==="stereographicnorthpole"&&Math.abs(Number(a.lat_0))===90&&(a.proj="stere"),R==="lcc"&&a.lat_1===void 0&&(a.lat_1=a.lat_0),x==="polarstereographic"&&a.lat_0!==void 0){if(a.lat_ts!==void 0)throw new Error("Duplicate polar stereographic latitude of true scale");a.lat_ts=a.lat_0,delete a.lat_0}R==="stere"&&(x.includes("polar")||x==="stereographicsouthpole"||T)&&a.lat_0===void 0&&(a.lat_0=Number(a.lat_ts||90)<0?"-90":"90"),R==="webmerc"&&(a.b=a.a,delete a.rf,a.nadgrids="@null")}let y=d.map(S=>xg(S,a,r==="ProjectedCRS")).join("");return y.length===2&&(y+="u"),!m&&/[ud]/.test(y.slice(0,2))&&D("Structured CRS vertical-first axes require an explicit PROJ axis definition"),y&&(a.axis=y),(r==="ProjectedCRS"||m)&&(a.to_meter=String(p)),{parameters:a,angularUnit:r==="ProjectedCRS"||m?_:p,verticalUnit:m?1:Ee(d[2]?.unit,1)}}function xg(t,e,r){let n=String(t.direction),i=t.meridian,o=/^(north|south) along ([+-]?(?:\d+(?:\.\d*)?|\.\d+)) deg(?: (east|west))?$/i.exec(n);if(o){if(i!==void 0)throw new Error("Duplicate axis meridian");n=o[1],i={longitude:Number(o[2])*(o[3]?.toLowerCase()==="west"?-1:1)}}if(i!==void 0){let a=Number(e.lat_0),c=a===90;(!r||e.proj!=="stere"||Math.abs(a)!==90||pe(n)!==(c?"south":"north"))&&D("Axis meridians require an outward-facing polar stereographic axis");let l=Q(i).longitude,h=typeof l=="number"?Ie(l):Ie(Q(l).value)*Ee(Q(l).unit,ee)/ee,u=Ie((h-Number(e.lon_0||0))/90);Math.abs(u-Math.round(u))>1e-12&&D("Non-cardinal axis meridians require an orientation operation");let f=(Math.round(u)%4+4)%4;return(c?"senw":"nesw")[f]}let s=yg[pe(n)];return s||D("Unsupported axis direction: "+n),s}function wi(t,...e){return t.values.filter(r=>r.type==="node"&&e.includes(r.keyword.toUpperCase()))}function K(t,...e){return wi(t,...e)[0]}function J(t,e=0){let r=t.values[e];return r&&r.type!=="node"?r.value:void 0}function Pt(t){return t?{name:J(t),conversion_factor:J(t,1)}:void 0}function Sg(t,e){let r=J(t,1);if(e&&String(r).toLowerCase()==="unknown"){let n=String(J(t)).toLowerCase(),i=/^(easting|northing|westing|southing)(?:\s*\([a-z]\))?$/.exec(n);if(i)return{easting:"east",northing:"north",westing:"west",southing:"south"}[i[1]]}return r}function wg(t){let e=K(t,"MERIDIAN");if(e)return{longitude:{value:J(e),unit:Pt(K(e,"ANGLEUNIT"))}}}function w0(t){let e=K(t,"METHOD","PROJECTION");if(!e)throw new Error("WKT conversion requires a METHOD or PROJECTION");return K(t,"PARAMETERFILE")&&D("Grid-based WKT operation is not implemented"),{method:{name:J(e)},parameters:wi(t,"PARAMETER").map(r=>({name:J(r),value:J(r,1),unit:Pt(K(r,"ANGLEUNIT","LENGTHUNIT","SCALEUNIT"))}))}}function Fr(t){let e=t.keyword.toUpperCase();if(e==="COMPD_CS"||e==="COMPOUNDCRS")return{type:"CompoundCRS",components:wi(t,"PROJCS","PROJCRS","GEOGCS","GEOGCRS","GEODCRS","BOUNDCRS","VERT_CS","VERTCRS").map(Fr)};if(e==="BOUNDCRS"){let h=K(t,"SOURCECRS"),u=K(t,"TARGETCRS"),f=K(t,"ABRIDGEDTRANSFORMATION");if(!h||!u||!f)throw new Error("Incomplete WKT BoundCRS");let d=p=>{let M=p.values.find(y=>y.type==="node");if(!M)throw new Error("Missing bound CRS component");return M},m=w0(f),_=m.parameters;for(let p of _)String(p.name).toLowerCase()==="scale difference"&&p.unit===void 0&&(p.value=(Number(p.value)-1)*1e6);return{type:"BoundCRS",source_crs:Fr(d(h)),target_crs:Fr(d(u)),transformation:m}}if(["VERT_CS","VERTCRS"].includes(e))return{type:"VerticalCRS"};let r=["PROJCS","PROJCRS","PROJECTEDCRS"].includes(e),n=["GEOGCS","GEOGCRS","GEODCRS","GEODETICCRS","GEOGRAPHICCRS","BASEGEOGCRS","BASEGEODCRS","GEOCCS"].includes(e);!r&&!n&&D("Unsupported WKT CRS: "+e),K(t,"DYNAMIC","DERIVINGCONVERSION","VELOCITYGRID","EXTENSION")&&D("Unsupported WKT dynamic/extension operation");let i=K(t,"CS"),o=e==="GEOCCS"||String(J(i||t)).toLowerCase()==="cartesian"&&!r,s=K(t,r||o?"LENGTHUNIT":"ANGLEUNIT","UNIT"),a=wi(t,"AXIS").sort((h,u)=>Number(J(K(h,"ORDER")||h))-Number(J(K(u,"ORDER")||u))).map((h,u)=>({name:J(h),direction:e==="GEOCCS"?["geocentricX","geocentricY","geocentricZ"][u]:Sg(h,r),unit:Pt(K(h,"ANGLEUNIT","LENGTHUNIT")||(!o&&!r&&/^(up|down)$/i.test(String(J(h,1)))?void 0:s)),meridian:wg(h)}));if(!a.length)for(let h of o?["geocentricX","geocentricY","geocentricZ"]:["east","north"])a.push({name:h,direction:h,unit:Pt(s),meridian:void 0});let c=e==="GEOGCS"?void 0:K(t,"ID"),l={type:r?"ProjectedCRS":o?"GeodeticCRS":"GeographicCRS",name:J(t),id:c?{authority:J(c),code:J(c,1)}:void 0,coordinate_system:{subtype:r||o?"Cartesian":"ellipsoidal",axis:a}};if(r){let h=K(t,"GEOGCS","BASEGEOGCRS","BASEGEODCRS","GEODCRS","GEOGCRS");if(!h)throw new Error("Projected WKT requires a base geographic CRS");l.base_crs=Fr(h),l.conversion=w0(K(t,"CONVERSION")||t)}else{let h=K(t,"DATUM","GEODETICDATUM","ENSEMBLE");if(!h)throw new Error("WKT requires a geodetic datum");K(h,"EXTENSION","DYNAMIC")&&D("Unsupported datum extension");let u=K(h,"SPHEROID","ELLIPSOID");if(!u)throw new Error("WKT datum requires an ellipsoid");let f=K(h,"TOWGS84");l.datum={name:J(h),ellipsoid:{name:J(u),semi_major_axis:J(u,1),inverse_flattening:J(u,2),unit:Pt(K(u,"LENGTHUNIT"))},towgs84:f?.values.map((m,_)=>J(f,_))};let d=K(t,"PRIMEM");d&&(l.prime_meridian={name:J(d),longitude:J(d,1),unit:Pt(K(d,"ANGLEUNIT")||(o?void 0:s))}),l.angular_unit=o?void 0:Pt(s)}return l}var ks={name:"wkt",canParse:t=>Me(t)==="wkt",parse(t,e){if(typeof t!="string")throw new Error("Expected serialized WKT");return vt(Fr(_r(t).root),e)}};var Fs={name:"projjson",canParse:t=>Me(t)==="projjson",parse:(t,e)=>vt(Q(t),e)};var Us=1e-12;function Ei(t,e,r,n,i=!1){let o=(e-t.origin[0])/t.step[0],s=(r-t.origin[1])/t.step[1],a=t.size[0],c=t.size[1];if(!i&&(o<-1e-10||s<-1e-10||o>a-1+1e-10||s>c-1+1e-10))return!1;o=Math.max(0,Math.min(a-1,o)),s=Math.max(0,Math.min(c-1,s));let l=Math.min(a-2,Math.floor(o)),h=Math.min(c-2,Math.floor(s)),u=o-l,f=s-h,d=0,m=0;for(let _=0;_<4;_++){let p=_%2,M=_>1,y=(p?u:1-u)*(M?f:1-f);if(y===0)continue;let S=t.shifts[(h+(M?1:0))*a+l+p];if(!Number.isFinite(S[0])||!Number.isFinite(S[1]))return!1;d+=y*S[0],m+=y*S[1]}return n.x=d,n.y=m,!0}function Eg(t,e,r,n,i){if(!n)return Ei(t,e,r,i)?(i.x+=e,i.y+=r,!0):!1;for(let a=0;a<2;a++){let c=a===0?e:r;if(c<t.origin[a]-t.maxShift[a]-Us||c>t.origin[a]+(t.size[a]-1)*t.step[a]+t.maxShift[a]+Us)return!1}if(!Ei(t,e,r,i,!0))return!1;let o=e-i.x,s=r-i.y;for(let a=0;a<20;a++){if(!Ei(t,o,s,i,!0))return!1;let c=e-o-i.x,l=r-s-i.y;if(o+=c,s+=l,Math.max(Math.abs(c),Math.abs(l))<=Us)return Ei(t,o,s,i)?(i.x=qe(o),i.y=s,!0):!1}throw new Error("Inverse datum grid shift did not converge")}function E0(t){if(!t.length)throw new Error("Datum grid requires at least one subgrid");let e=t.map(n=>{let[i,o]=n.size;if(![i,o].every(a=>Number.isSafeInteger(a)&&a>=2)||i*o!==n.shifts.length||!n.origin.every(Number.isFinite)||!n.step.every(a=>Number.isFinite(a)&&a>0))throw new Error("Invalid datum subgrid geometry or node count");let s=[0,0];for(let a of n.shifts)for(let c=0;c<2;c++)Number.isFinite(a[c])&&(s[c]=Math.max(s[c],Math.abs(a[c])));return{...n,maxShift:s}}),r=(n,i)=>{let o=n.x,s=n.y;if(!Number.isFinite(o)||!Number.isFinite(s))throw new Error("Grid coordinates must be finite");for(let a of e)if(Eg(a,-o,s,i,n))return n.x=-n.x,!0;return n.x=o,n.y=s,!1};return Object.freeze({subgridCount:e.length,shiftInPlace:r,shift(n,i,o){let s={x:n,y:i};return r(s,o)?[s.x,s.y]:void 0}})}var Kt=Math.PI/648e3;function Vs(t,e={}){let r=new DataView(t);if(r.byteLength<176)throw new Error("Truncated NTv2 overview header");let n=r.getInt32(8,!0)===11;if(!n&&r.getInt32(8,!1)!==11)throw new Error("Invalid NTv2 header or byte order");let i=u=>r.getInt32(u,n),o=u=>r.getFloat64(u,n),s=u=>String.fromCharCode(...new Uint8Array(t,u,8)).replace(/\0/g,"").trim();if(s(0)!=="NUM_OREC"||i(24)!==11||s(56)!=="SECONDS")throw new Error("Unsupported NTv2 header or shift units");let a=i(40),c=e.includeErrorFields===!1?8:16;if(a<1||a>Math.floor((r.byteLength-176)/(176+4*c)))throw new Error("Invalid NTv2 subgrid count");let l=176,h=[];for(let u=0;u<a;u++){if(l+176>r.byteLength)throw new Error("Truncated NTv2 subgrid header");let f=o(l+72),d=o(l+88),m=o(l+104),_=o(l+120),p=o(l+136),M=o(l+152),y=i(l+168),S=1+(_-m)/M,x=1+(d-f)/p;if(![S,x].every(C=>Number.isFinite(C)&&C>=2&&Math.abs(C-Math.round(C))<1e-7)||!(M>0&&p>0)||y!==Math.round(S)*Math.round(x))throw new Error("Invalid NTv2 subgrid dimensions");let E=l+176,T=E+y*c;if(T>r.byteLength)throw new Error("Truncated NTv2 node records");let R=[];for(let C=0;C<y;C++)R.push([r.getFloat32(E+C*c+4,n)*Kt,r.getFloat32(E+C*c,n)*Kt]);h.push({origin:[m*Kt,f*Kt],step:[M*Kt,p*Kt],size:[Math.round(S),Math.round(x)],shifts:R}),l=T}return E0(h)}var T0=Object.create(null),b0=Object.create(null),Ti;function Tg(){if(Ti)return Ti;let t=[Ko,Xo,es,ts,rs,ns,is,os,as,ls,hs,us,fs,ds,gs,_s,Ms,ys,xs,Ss,ws,Ts,bs,vs,Ps,Rs,Cs,As,Is,Os,Ns,Ls,Gs,qs,zs],e=i=>i.toLowerCase().replace(/[\s_-]/g,""),r=Si("longlat"),n={name:r.name,aliases:r.aliases,parameters:[...new Set([...r.parameters,...t.flatMap(i=>i.parameters)])],flags:[...new Set(t.flatMap(i=>i.flags||[]))],create(i){let o=i.parameters.o_proj;if(!o)throw new Error("Oblique transformation requires +o_proj");let s=["longlat","latlong","latlon","lonlat","identity"].includes(e(o))?"longlat":t.find(l=>[l.name,...l.aliases||[]].some(h=>e(h)===e(o)));if(!s)throw new Error("Unknown oblique transformation projection: "+o);let a=Si(s),c=new Set([...ii,...a.parameters]);for(let l of Object.keys(i.parameters))if(!c.has(l))throw new Error("Unsupported PROJ parameter: +"+l);return a.create(i)}};return Ti=[...t,n],Ti}var rt=class extends ui{static defineProjectionAliases(e){for(let r of Object.keys(e)){let n=e[r];T0[r]=typeof n=="string"?n:JSON.parse(JSON.stringify(n))}}static registerDatumGrid(e,r,n){b0[e]=Vs(r,n)}constructor({from:e="WGS84",to:r="WGS84",enforceAxis:n=!1,verticalGrids:i}){super({from:e,to:r,enforceAxis:n,verticalGrids:i,projections:Tg(),parsers:[ks,Fs],aliases:T0,datumGrids:b0})}};var bg=[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],vg=372,Pg=[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],Rg=372,Cg=[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],Ag=12,js=20/2,Ig=2,Ur=class{constructor(e){this._v00=0,this._v01=0,this._v10=0,this._v11=0,this._t=[],this.options=e,this._ix=this.options._width,this._iy=this.options._height}getHeight(e,r){if(e=Math.abs(e)>90?NaN:e,Number.isNaN(e)||Number.isNaN(r))return NaN;let n=Og(r,360);r=n!==-180?n:180;let i=r*this.options._rlonres,o=-e*this.options._rlatres,s=Math.floor(i),a=Math.min(Math.round((this.options._height-1)/2-1),Math.floor(o));i-=s,o-=a,a+=(this.options._height-1)/2,s+=s<0?this.options._width:s>=this.options._width?-this.options._width:0;let c=0,l=0,h=0,u=0,f=new Array(js);if(s===this._ix&&a===this._iy)this.options.cubic?f=this._t:(c=this._v00,l=this._v01,h=this._v10,u=this._v11);else if(!this.options.cubic)c=this._rawval(s,a),l=this._rawval(s+1,a),h=this._rawval(s,a+1),u=this._rawval(s+1,a+1);else{let m=[this._rawval(s,a-1),this._rawval(s+1,a-1),this._rawval(s-1,a),this._rawval(s,a),this._rawval(s+1,a),this._rawval(s+2,a),this._rawval(s-1,a+1),this._rawval(s,a+1),this._rawval(s+1,a+1),this._rawval(s+2,a+1),this._rawval(s,a+2),this._rawval(s+1,a+2)],_=Pg;a!==0&&(_=a===this.options._height-2?Cg:bg);let p=vg;a!==0&&(p=a===this.options._height-2?Rg:240);for(let M=0;M<js;++M){f[M]=0;for(let y=0;y<Ag;++y)f[M]+=m[y]*_[js*y+M];f[M]/=p}}if(!this.options.cubic){let m=(1-i)*c+i*l,_=(1-i)*h+i*u,p=(1-o)*m+o*_,M=this.options._offset+this.options._scale*p;return this._ix=s,this._iy=a,this._v00=c,this._v01=l,this._v10=h,this._v11=u,M}let d=f[0]+i*(f[1]+i*(f[3]+i*f[6]))+o*(f[2]+i*(f[4]+i*f[7])+o*(f[5]+i*f[8]+o*f[9]));return d=this.options._offset+this.options._scale*d,this._ix=s,this._iy=a,this._t=f,d}_rawval(e,r){e<0?e+=this.options._width:e>=this.options._width&&(e-=this.options._width),(r<0||r>=this.options._height)&&(r=r<0?-r:2*(this.options._height-1)-r,e+=(e<this.options._width/2?1:-1)*this.options._width/2);let n=this.options._datastart+Ig*(r*this.options._swidth+e),i=this.options.data[n],o=this.options.data[n+1];return i<<8|o}};function Og(t,e){e=Math.abs(e);let r=v0(t,e);return 2*Math.abs(r)===e?r-=v0(t,2*e)-r:2*Math.abs(r)>e&&(r+=r<0?e:-e),r}function v0(t,e){return t-Math.floor(t/e)*e}var Ng=10,Lg=65535;function Ws(t,e){let r=Gg(t),n=r.next();if(n.done||n.value.line!=="P5")throw new Error("Geoid model file: File not in PGM format");let i=Number.MAX_VALUE,o=0,s=-1,a=-1,c="NONE",l="UNKNOWN",h=0,u=0,f=null,d=null;do{n=r.next();let M=n.value.line;if(M.length)if(M[0]==="#"){let y=M.split(" "),S=y[0],x=y[1];if(S!=="#"||!x)continue;let E=y.length>2?y.slice(2):[];if(x==="Description")c=E.join(" ");else if(x==="DateTime")l=E.join(" ");else if(x==="Offset"){if(!y[2])throw new Error("Geoid model file: Error reading offset");i=parseInt(y[2],10)}else if(x==="Scale"){if(!y[2])throw new Error("Geoid model file: Error reading scale");o=parseFloat(y[2])}else x===(e.cubic?"MaxCubicError":"MaxBilinearError")?isFinite(parseFloat(y[2]))&&(s=parseFloat(y[2])):x===(e.cubic?"RMSCubicError":"RMSBilinearError")&&isFinite(parseFloat(y[2]))&&(a=parseFloat(y[2]))}else{let y=M.split(" ");if(y=y.filter(S=>S!==""),h=parseInt(y[0],10),u=parseInt(y[1],10),!(h&&u))throw new Error("Geoid model file: Error reading raster size");break}}while(!n.done);n=r.next();let m=parseInt(n.value.line,10);if(n.done)throw new Error("Geoid model file: Error reading maxval");if(m!==Lg)throw new Error("Geoid model file: Incorrect value of maxval");if(f=n.value.offset,d=h,i===Number.MAX_VALUE)throw new Error("Geoid model file: Offset not set");if(o===0)throw new Error("Geoid model file: Scale not set");if(o<0)throw new Error("Geoid model file: Scale must be positive");if(u<2||h<2)throw new Error("Geoid model file: Raster size too small");if(h&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 _=h/360,p=(u-1)/180;return new Ur({cubic:e.cubic,_width:h,_height:u,_rlonres:_,_rlatres:p,_offset:i,_scale:o,_swidth:d,_datastart:f,_maxerror:s,_rmserror:a,_description:c,_datetime:l,data:t})}function*Gg(t){let e=0;do{let r=t.indexOf(Ng,e);if(r!==-1){let n=t.subarray(e,r);e=r+1,yield{offset:e,line:P0(n)}}else{let n=t.subarray(e,t.length);e=t.length,yield{offset:e,line:P0(n)}}}while(e<t.length);return{offset:e,line:""}}function P0(t){let e="";for(let r of t)e+=String.fromCharCode(r);return e}var R0=new Map;function C0(t,e){$s(t,"CRS"),rt.defineProjectionAliases({[t]:e})}function A0(t,e){$s(t,"datum grid"),rt.registerDatumGrid(t,e)}function Hs(t,e){$s(t,"geoid model"),R0.set(t,e)}function I0(t,e,r={}){let n=Ws(e,r);return Hs(t,n),n}function bi(t){return R0.get(t)}function $s(t,e){if(!t.trim())throw new Error(`${e} name must not be empty`)}var Be=class{spatialReference;horizontalProjection;geographicProjection;heightOutputProjection;sourceIsGeocentric;outputIsGeocentric;sourceIsGeographic;outputIsGeographic;geoid;constructor(e,r={}){this.spatialReference=e,Bg(e);let n=e.targetCrs||e.sourceCrs;if(this.sourceIsGeocentric=Ys(e.sourceCrs),this.outputIsGeocentric=Ys(n),this.sourceIsGeographic=O0(e.sourceCrs),this.outputIsGeographic=O0(n),e.sourceCrs&&e.targetCrs&&!this.sourceIsGeocentric&&!this.outputIsGeocentric&&(this.horizontalProjection=new rt({from:Vr(e.sourceCrs),to:Vr(e.targetCrs),enforceAxis:!1})),(jr(e)||this.sourceIsGeocentric||this.outputIsGeocentric)&&(!this.sourceIsGeographic&&!this.sourceIsGeocentric&&(this.geographicProjection=new rt({from:Vr(e.sourceCrs),to:kt,enforceAxis:!1})),!this.outputIsGeographic&&!this.outputIsGeocentric&&(this.heightOutputProjection=new rt({from:kt,to:Vr(n),enforceAxis:!1}))),jr(e)&&(this.geoid=Dg(r.geoidModel),!this.geoid)){let i=typeof r.geoidModel=="string"?` "${r.geoidModel}"`:"";throw new Error(`Height conversion requires a registered geoid model${i}; call registerGeoidModel() or pass a parsed Geoid instance`)}}transformPosition(e){if(e.length<2)throw new Error("A spatial coordinate must contain at least x and y components");let r=[...e];if(jr(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 n=this.toGeographic(r);if(jr(this.spatialReference)){let o=this.geoid.getHeight(n[1],n[0]);n[2]=kg(n[2],o,this.spatialReference.heightReference,this.spatialReference.targetHeightReference)}let i=this.fromGeographic(n);return r.splice(0,i.length,...i),r}if(this.horizontalProjection){let n=this.horizontalProjection.project(r.slice(0,3));r.splice(0,n.length,...n)}return r}transformPositions(e){if(e.length%3!==0)throw new Error("Packed spatial positions must contain a multiple of three components");let r=new Float64Array(e.length);for(let n=0;n<e.length;n+=3){let i=this.transformPosition([Number(e[n]),Number(e[n+1]),Number(e[n+2])]);r[n]=i[0],r[n+1]=i[1],r[n+2]=i[2]}return r}transformNormals(e,r){if(e.length!==r.length||e.length%3!==0)throw new Error("Spatial normals and positions must have matching xyz component counts");let n=new Float32Array(e.length),i=1e-5;for(let o=0;o<e.length;o+=3){let s=[Number(r[o]),Number(r[o+1]),Number(r[o+2])],a=[Number(e[o]),Number(e[o+1]),Number(e[o+2])],c=qg(this,s,i),l=zg(c,a),h=Math.hypot(...l);h>0&&Number.isFinite(h)?(n[o]=l[0]/h,n[o+1]=l[1]/h,n[o+2]=l[2]/h):(n[o]=a[0],n[o+1]=a[1],n[o+2]=a[2])}return n}toGeographic(e){return this.sourceIsGeocentric?Array.from(N.WGS84.cartesianToCartographic(new g(e))):this.sourceIsGeographic?e.slice(0,3):this.geographicProjection.project(e.slice(0,3))}fromGeographic(e){return this.outputIsGeocentric?Array.from(N.WGS84.cartographicToCartesian(new g(e))):this.outputIsGeographic?e.slice(0,3):this.heightOutputProjection.project(e.slice(0,3))}};function qg(t,e,r){let n=[];for(let i=0;i<3;i++){let o=e.slice(),s=e.slice();o[i]+=r,s[i]-=r;let a=t.transformPosition(o),c=t.transformPosition(s);n.push([(a[0]-c[0])/(2*r),(a[1]-c[1])/(2*r),(a[2]-c[2])/(2*r)])}return n}function zg(t,e){let[r,n,i]=t,o=r[0]*(n[1]*i[2]-n[2]*i[1])-n[0]*(r[1]*i[2]-r[2]*i[1])+i[0]*(r[1]*n[2]-r[2]*n[1]);return!Number.isFinite(o)||Math.abs(o)<1e-15?e:[[n[1]*i[2]-n[2]*i[1],r[2]*i[1]-r[1]*i[2],r[1]*n[2]-r[2]*n[1]],[n[2]*i[0]-n[0]*i[2],r[0]*i[2]-r[2]*i[0],r[2]*n[0]-r[0]*n[2]],[n[0]*i[1]-n[1]*i[0],r[1]*i[0]-r[0]*i[1],r[0]*n[1]-r[1]*n[0]]].map(a=>(a[0]*e[0]+a[1]*e[1]+a[2]*e[2])/o)}function Vr(t){if(!t)throw new Error("Cannot construct a projection because the CRS is unknown");if(typeof t!="string"&&t.type==="CompoundCRS"){let e=t.components.filter(r=>r.type!=="VerticalCRS");if(e.length!==1)throw new Error("CompoundCRS requires exactly one horizontal component");return Vr(e[0])}return t}function Bg(t){if(t.outputCoordinates==="local-enu")throw new Error("local-enu output requires a dataset-derived local origin and must be created by a tileset source");if(t.outputCoordinates==="target-crs"&&!t.targetCrs)throw new Error("target-crs output requires targetCrs");if(!t.sourceCrs&&t.status==="unresolved")throw new Error("Cannot transform coordinates because the source CRS is unknown");if(jr(t)&&t.heightReference==="unknown")throw new Error("Cannot convert heights because the source height reference is unknown");if(t.coordinateFrame==="geocentric"&&!Ys(t.sourceCrs))throw new Error("Only EPSG:4978 geocentric coordinates are supported by the current spatial transformer");if(t.status==="unresolved")throw new Error("The requested spatial output cannot be resolved from the available metadata")}function Ys(t){return typeof t=="string"&&Sr(t)===jn}function O0(t){if(typeof t!="string")return!1;let e=Sr(t);return e===kt||e==="EPSG:4979"||e==="OGC:CRS84"}function jr(t){let e=t.targetHeightReference;return e!=="native"&&e!==t.heightReference}function Dg(t){return typeof t=="string"?bi(t):t}function kg(t,e,r,n){if(r===n||n==="native")return t;if(r==="orthometric"&&n==="ellipsoidal")return t+e;if(r==="ellipsoidal"&&n==="orthometric")return t-e;throw new Error(`Unsupported height conversion from ${r} to ${n}`)}var Mt=class{spatialReference;coordinateTransformer;geographicCoordinateTransformer;constructor(e,r={}){this.coordinateTransformer=new Be(e,r);let n={...e,sourceCrs:"EPSG:4326",targetCrs:e.targetCrs||e.sourceCrs,coordinateFrame:"geographic",axisOrder:"xy"};this.geographicCoordinateTransformer=new Be(n,r),this.spatialReference=e}transformPositions(e){return this.coordinateTransformer.transformPositions(e)}transformNormals(e,r){return this.coordinateTransformer.transformNormals(e,r)}transformBoundingVolume(e,r){let n=r?new G(Array.from(r)):void 0,i=e.region?Fg(e.region):Ug(e).map(s=>n?Array.from(n.transformAsPoint(s)):s);if(!i.length)return e;let o=e.region?i.map(s=>this.transformRegionSample(s)):i.map(s=>this.coordinateTransformer.transformPosition(s));return{box:Vg(o)}}transformRegionSample(e){let[r,n,i]=e,o=this.spatialReference.targetCrs||this.spatialReference.sourceCrs;if(o&&_e(o)==="geocentric"){let s=N.WGS84.cartographicToCartesian([r,n,i]);return Array.from(s)}return this.geographicCoordinateTransformer.transformPosition(e)}};function Fg(t){if(t.length<6||t.some(u=>!Number.isFinite(u)))return[];let[e,r,n,i,o,s]=t,a=n<e?n+Math.PI*2:n,c=N0(e,a),l=N0(r,i),h=[];for(let u of c)for(let f of l)for(let d of[o,s])h.push([u*180/Math.PI,f*180/Math.PI,d]);return h}function N0(t,e){let r=[t,(t+e)/2,e],n=Math.PI/2,i=Math.ceil(t/n),o=Math.floor(e/n);for(let s=i;s<=o;s++)r.push(s*n);return r}function Ug(t){if(t.box&&t.box.length>=12){let e=t.box.slice(0,3),r=[t.box.slice(3,6),t.box.slice(6,9),t.box.slice(9,12)],n=[];for(let i=0;i<=4;i++)for(let o=0;o<=4;o++)for(let s=0;s<=4;s++){let a=i/2-1,c=o/2-1,l=s/2-1;n.push([e[0]+a*r[0][0]+c*r[1][0]+l*r[2][0],e[1]+a*r[0][1]+c*r[1][1]+l*r[2][1],e[2]+a*r[0][2]+c*r[1][2]+l*r[2][2]])}return n}if(t.sphere&&t.sphere.length>=4){let[e,r,n,i]=t.sphere,o=[[e-i,r,n],[e+i,r,n],[e,r-i,n],[e,r+i,n],[e,r,n-i],[e,r,n+i]];for(let s=0;s<16;s++){let a=s*Math.PI*2/16;o.push([e+i*Math.cos(a),r+i*Math.sin(a),n])}return o}return[]}function Vg(t){let e=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let o of t)for(let s=0;s<3;s++)e[s]=Math.min(e[s],o[s]),r[s]=Math.max(r[s],o[s]);let n=[Math.max((r[0]-e[0])*.01,1e-9),Math.max((r[1]-e[1])*.01,1e-9),Math.max((r[2]-e[2])*.01,1e-9)];return[...[(e[0]+r[0])/2,(e[1]+r[1])/2,(e[2]+r[2])/2],(r[0]-e[0])/2+n[0],0,0,0,(r[1]-e[1])/2+n[1],0,0,0,(r[2]-e[2])/2+n[2]]}function L0(t,e){let r=t.map(([c,l])=>[c,l]);if(r.length===0)return r;let n=1/0,i=-1/0;for(let[c]of t)n=Math.min(n,c),i=Math.max(i,c);if(i-n>=360)return r;let o=e??r[0][0];for(let c of r){let l=c[0]-o;l>180?c[0]-=360*Math.ceil((l-180)/360):l<-180&&(c[0]+=360*Math.ceil((-l-180)/360)),o=c[0]}let s=t[0],a=t[t.length-1];if(s[0]===a[0]&&s[1]===a[1]){if(Math.abs(r[r.length-1][0]-r[0][0])>180)return t.map(([c,l])=>[c,l]);r[r.length-1]=[...r[0]]}return r}function jg(t){let e=1/0,r=1/0,n=-1/0,i=-1/0;for(let[o,s]of t)e=Math.min(e,o),r=Math.min(r,s),n=Math.max(n,o),i=Math.max(i,s);return[[e,r],[n,i]]}function G0(t){let e=(r,n)=>{let i=t.cellToBoundary(r);return n?.unwrap?L0(i,n.referenceLongitude):i};return{...t,cellToBoundary:e,cellToBoundaryFlat:(r,n)=>n?.unwrap?e(r,n).flat():t.cellToBoundaryFlat(r),cellToBounds:(r,n)=>{let i=t.cellToBounds(r);if(!n?.unwrap||i[1][0]-i[0][0]>=360)return i;let o=jg(e(r,n));return o[0][1]=i[0][1],o[1][1]=i[1][1],o}}}var Wg=(1n<<64n)-1n,Hg=0x1555555555555555n;function Xt(t){if(t==="X")return 0n;if(!q0(t))throw new Error(`Invalid S2 token: ${t}`);let e=t.padEnd(16,"0");return BigInt(`0x${e}`)}function Wr(t){if(t===0n)return"X";if(!Zt(t))throw new Error(`Invalid S2 index: ${t}`);let e=$g(t),r=e%4;e=(e-r)/4;let n=e;e*=4;let o=(t>>BigInt(e)).toString(16).replace(/0+$/,"");return Array(17-n-o.length).join("0")+o}function Zt(t){if(typeof t!="bigint"||t<=0n||t>Wg)return!1;let e=t>>61n,r=t&-t;return e<6n&&(r&Hg)!==0n}function q0(t){if(typeof t!="string"||!/^[0-9a-fA-F]{1,16}$/.test(t)||t.endsWith("0"))return!1;let e=t.padEnd(16,"0");return Zt(BigInt(`0x${e}`))}function $g(t){let e=0;for(;t%2n===0n;)t/=2n,e++;return e}function Qt(t){if(!Zt(t))throw new Error(`Invalid S2 index: ${t}`);let e=Qg(t);return Zg(e)}var Yg=3,Ks=30,Kg=2*Ks+1,z0=180/Math.PI,Xg={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 Zg(t){if(!/^[0-5]\/[0-3]{0,30}$/.test(t))throw new Error(`Invalid S2 Hilbert quadkey: ${t}`);let e=t.split("/"),r=parseInt(e[0],10),n=e[1]||"",i=n.length,o=0,s=[0,0];for(let a=i-1;a>=0;a--){o=i-a;let c=n[a],l=0,h=0;c==="1"?h=1:c==="2"?(l=1,h=1):c==="3"&&(l=1);let u=Math.pow(2,o-1);Jg(u,s,l,h),s[0]+=u*l,s[1]+=u*h}if(r%2===1){let a=s[0];s[0]=s[1],s[1]=a}return{face:r,ij:s,level:o}}function Qg(t){if(!Zt(t))throw new Error(`Invalid S2 index: ${t}`);let e=t.toString(2);for(;e.length<Yg+Kg;)e="0"+e;let r=e.lastIndexOf("1"),n=e.substring(0,3),i=e.substring(3,r),o=i.length/2,s=BigInt(`0b${n}`).toString(10),a="";if(o!==0)for(a=BigInt(`0b${i}`).toString(4);a.length<o;)a="0"+a;return`${s}/${a}`}function D0(t){let{face:e,ij:r,level:n}=t;if(!Number.isInteger(e)||e<0||e>5)throw new Error(`Invalid S2 face: ${e}`);if(!Number.isInteger(n)||n<0||n>Ks)throw new Error(`Invalid S2 level: ${n}`);let i=2**n;if(!Number.isInteger(r[0])||!Number.isInteger(r[1])||r[0]<0||r[1]<0||r[0]>=i||r[1]>=i)throw new Error(`Invalid S2 IJ coordinates: ${r[0]}, ${r[1]}`);let o=e2(r[0],r[1],n,e),s=BigInt(e)<<61n;for(let a=0;a<o.length;a++){let c=59-a*2;s|=BigInt(o[a])<<BigInt(c)}return s|=1n<<BigInt(60-n*2),s}function Xs(t,e,r,n){let i=Qt(t);if(!Number.isInteger(e)||e<0||i.level+e>Ks)throw new Error(`Invalid S2 relative level: ${e}`);let o=2**e;if(!Number.isInteger(r)||!Number.isInteger(n)||r<0||n<0||r>=o||n>=o)throw new Error(`Invalid S2 descendant coordinates: ${r}, ${n}`);return D0({face:i.face,ij:[i.ij[0]*o+r,i.ij[1]*o+n],level:i.level+e})}function Hr(t,e,r){let n=1<<e;return[(t[0]+r[0])/n,(t[1]+r[1])/n]}function B0(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))}function $r(t){return[B0(t[0]),B0(t[1])]}function Yr(t,[e,r]){switch(t){case 0:return[1,e,r];case 1:return[-e,1,r];case 2:return[-e,-r,1];case 3:return[-1,-r,-e];case 4:return[r,-1,-e];case 5:return[r,e,-1];default:throw new Error("Invalid face")}}function Kr([t,e,r]){let n=Math.atan2(r,Math.sqrt(t*t+e*e));return[Math.atan2(e,t)*z0,n*z0]}function Jg(t,e,r,n){if(n===0){r===1&&(e[0]=t-1-e[0],e[1]=t-1-e[1]);let i=e[0];e[0]=e[1],e[1]=i}}function e2(t,e,r,n){let i=n%2===1?"d":"a",o=[];for(let s=r-1;s>=0;s--){let a=1<<s,c=(t&a)!==0?1:0,l=(e&a)!==0?1:0,[h,u]=Xg[i][c*2+l];o.push(h),i=u}return o}var t2=100;function k0(t){let e=Qt(t);return r2(e)}function r2({face:t,ij:e,level:r}){let n=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(t2*Math.pow(2,-r))),o=new Float64Array(4*i*2+2),s=0,a=0;for(let c=0;c<4;c++){let l=n[c].slice(0),h=n[c+1],u=(h[0]-l[0])/i,f=(h[1]-l[1])/i;for(let d=0;d<i;d++){l[0]+=u,l[1]+=f;let m=Hr(e,r,l),_=$r(m),p=Yr(t,_),M=Kr(p);Math.abs(M[1])>89.999&&(M[0]=a);let y=M[0]-a;M[0]+=y>180?-360:y<-180?360:0,o[s++]=M[0],o[s++]=M[1],a=M[0]}}return o[s++]=o[0],o[s++]=o[1],o}var n2=G0({name:"s2",hasNumericRepresentation:!0,cellColumnNames:["s2","s2Token","s2_token","s2Cell","s2_cell","s2CellId","s2_cell_id"],tokenToCell:t=>Xt(t),cellToToken:t=>Wr(Pi(t)),cellToLngLat:t=>F0(t),cellToBoundary:t=>i2(t),cellToBoundaryFlat:t=>Zs(t),cellToBounds:t=>vi(t)});function F0(t){let e=Pi(t),r=Qt(e),n=Hr(r.ij,r.level,[.5,.5]),i=$r(n),o=Yr(r.face,i);return Kr(o)}function Zs(t){let e=Pi(t),r=k0(e);return Array.from(r)}function i2(t){let e=Zs(t),r=[];for(let n=0;n<e.length;n+=2)r.push([e[n],e[n+1]]);return r}function vi(t){let e=Qt(Pi(t));if(e.level===0)return o2(e.face);let r=[[0,0],[0,1],[1,1],[1,0]],n=1/0,i=1/0,o=-1/0,s=-1/0,a;for(let l of r){let h=Hr(e.ij,e.level,l),u=$r(h),[f,d,m]=Yr(e.face,u),[_,p]=Kr([f,d,m]);if(f===0&&d===0&&a!==void 0&&(_=a),a!==void 0){let M=_-a;_+=M>180?-360:M<-180?360:0}a=_,n=Math.min(n,_),i=Math.min(i,p),o=Math.max(o,_),s=Math.max(s,p)}let c=2*Number.EPSILON*180/Math.PI;return[[n-c,Math.max(-90,i-c)],[o+c,Math.min(90,s+c)]]}function Pi(t){return typeof t=="bigint"?t:Xt(t)}function o2(t){let e=Math.asin(Math.sqrt(.3333333333333333))*180/Math.PI;switch(t){case 0:return[[-45,-45],[45,45]];case 1:return[[45,-45],[135,45]];case 2:return[[-180,e],[180,90]];case 3:return[[135,-45],[225,45]];case 4:return[[-135,-45],[-45,45]];case 5:return[[-180,-90],[180,-e]];default:throw new Error(`Invalid S2 face: ${t}`)}}function Ri(t){let[[e,r],[n,i]]=vi(t.token),o=hr([e,r,n,i,t.minimumHeight,t.maximumHeight],N.WGS84,{units:"degrees"});return[...o.center,...o.halfAxes]}var s2=4,a2=8,U0=new WeakMap;function Js(t,e){return{coordinates:e,subtreeUrl:Zr(t.subtreesUrlTemplate,e),descriptor:t,resource:X0(t.resourceFiles,Zr(t.subtreesUrlTemplate,e))}}function Ci(t,e){let{descriptor:r}=e;p2(r),c2(t,r);let n={tileCount:0,childSubtreeCount:0},i=K0(t,e,{localLevel:0,mortonIndex:0},e.coordinates,n);if(!i)throw new Error(`Invalid 3D Tiles subtree: root tile is unavailable at ${e.subtreeUrl}`);return{root:i,...n}}function c2(t,e){let r=ef(e.subdivisionScheme),n=(r**e.subtreeLevels-1)/(r-1),i=r**e.subtreeLevels;Qs(t.tileAvailability,n,"tile");let o=Array.isArray(t.contentAvailability)?t.contentAvailability:t.contentAvailability?[t.contentAvailability]:[];for(let c of o)Qs(c,n,"content");Qs(t.childSubtreeAvailability,i,"child subtree");let s=V0(t.tileAvailability,n),a=o[0]?V0(o[0],n):0;if(j0(t.tileAttributes,s,"tile"),j0(t.contentAttributes,a,"content"),t.tilePropertyRows&&t.tilePropertyRows.length!==s)throw new Error("3DTILES_subtree: tile property-table count does not match availability");if(t.contentPropertyRows&&t.contentPropertyRows.length!==a)throw new Error("3DTILES_subtree: content property-table count does not match availability")}function Qs(t,e,r){if(!(t.constant===0||t.constant===1)&&(!t.explicitBitstream||t.explicitBitstream.byteLength*8<e))throw new Error(`3DTILES_subtree: ${r} availability bitstream is too short`)}function V0(t,e){if(t.constant===1)return e;if(t.constant===0)return 0;let r=0;for(let n=0;n<e;n++)Jt(t,n)&&r++;return r}function j0(t,e,r){let n={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[i,o]of Object.entries(t||{})){let s=n[i];if(s&&o.length!==e*s)throw new Error(`3DTILES_subtree: ${r} attribute ${i} count does not match availability`)}}function Zr(t,e,r={}){let n={level:e.level,x:e.x,y:e.y,z:e.z,...r};return t.replace(/{([^{}]+)}/g,(i,o)=>{let s=Object.hasOwn(n,o)?n[o]:n[o.toLowerCase()];return s===void 0?i:String(s)})}function K0(t,e,r,n,i){let{descriptor:o}=e,s=ef(o.subdivisionScheme),a=f2(s,r.localLevel)+r.mortonIndex;if(!Jt(t.tileAvailability,a))return null;i.tileCount++;let c=u2(t.contentAvailability,a),l=[];if(n.level<o.maximumLevel)if(r.localLevel+1<o.subtreeLevels)for(let h=0;h<s;h++){let u=$0(n,h,o.subdivisionScheme),f=K0(t,e,{localLevel:r.localLevel+1,mortonIndex:r.mortonIndex*s+h},u,i);f&&l.push(f)}else for(let h=0;h<s;h++){let u=r.mortonIndex*s+h;if(Jt(t.childSubtreeAvailability,u)){let f=$0(n,h,o.subdivisionScheme);l.push(l2(t,o,f)),i.childSubtreeCount++}}return h2(t,o,e,n,a,c,l)}function l2(t,e,r){let n=Z0(e.resourceFiles,t.resourceFiles),i=n?{...e,resourceFiles:n}:e,o=Js(i,r);return{id:J0(o,r),children:[],implicitSubtree:o,boundingVolume:tf(e.rootBoundingVolume,r,e.subdivisionScheme),geometricError:e.rootLodMetricValue/2**r.level,lodMetricType:e.lodMetricType,lodMetricValue:e.rootLodMetricValue/2**r.level,refine:e.refine,type:Ke.EMPTY,implicitMetadata:Q0(t),_scaleGeometricError:e.scaleGeometricError!==!1}}function W0(t,e,r){if(!t||e<0)return{};let n=Xr(t[r==="tile"?"TILE_BOUNDING_BOX":"CONTENT_BOUNDING_BOX"],e,16),i=Xr(t[r==="tile"?"TILE_BOUNDING_SPHERE":"CONTENT_BOUNDING_SPHERE"],e,4),o=n?{box:[n[12],n[13],n[14],n[0]/2,n[1]/2,n[2]/2,n[4]/2,n[5]/2,n[6]/2,n[8]/2,n[9]/2,n[10]/2]}:i?{sphere:i}:void 0;if(r==="content")return{boundingVolume:o};let s=Xr(t.TILE_GEOMETRIC_ERROR,e,1)?.[0];if(s!==void 0&&(!Number.isFinite(s)||s<0))throw new Error("3DTILES_subtree: TILE_GEOMETRIC_ERROR must be nonnegative");let a=Xr(t.TILE_REFINE,e,1)?.[0];if(a!==void 0&&a!==0&&a!==1)throw new Error("3DTILES_subtree: TILE_REFINE must be 0 or 1");return{boundingVolume:o,geometricError:s,refine:a===void 0?void 0:a===0?te.ADD:te.REPLACE,transform:Xr(t.TILE_TRANSFORM,e,16)}}function Xr(t,e,r){if(!t)return;let n=e*r;if(n+r>t.length)throw new Error("3DTILES_subtree: attribute accessor is shorter than availability");return Array.from({length:r},(i,o)=>Number(t[n+o]))}function H0(t,e){if(t.constant===1)return e;if(t.constant===0)return 0;let r=U0.get(t);if(!r){let n=(t.explicitBitstream?.byteLength||0)*8;r=new Uint32Array(n+1);for(let i=0;i<n;i++)r[i+1]=r[i]+Number(Jt(t,i));U0.set(t,r)}return r[e]}function X0(t,e){if(!t?.length)return;let r=e.split("?")[0],n=/^gltf-package:\/\/[^/]+\/(.*)$/.exec(r)?.[1],i=t.findIndex(s=>{let a=s.originalUri||s.name;return s.uri===r||!!(a&&(r===a||n===a))});if(i>=0)return{fileIndex:i,files:t};let o=t.findIndex(s=>{let a=s.originalUri||s.name;return!!(a&&(r.endsWith(`/${a}`)||r.endsWith(`:${a}`)))});return o<0?void 0:{fileIndex:o,files:t}}function Z0(t,e){if(!e?.length)return t;if(!t?.length)return e;let r=new Set(e.flatMap(n=>[n.uri,n.originalUri,n.name].filter(Boolean)));return[...e,...t.filter(n=>![n.uri,n.originalUri,n.name].some(i=>i&&r.has(i)))]}function h2(t,e,r,n,i,o,s){let a=H0(t.tileAvailability,i),c=t.tilePropertyRows?.[a],l=Array.isArray(t.contentAvailability)?t.contentAvailability[0]:t.contentAvailability,h=l&&Jt(l,i)?H0(l,i):-1,u=t.contentPropertyRows?.[h],f=t.tileTemplatePropertyRows?.[a]||c,d=t.contentTemplatePropertyRows?.[h]||u,m={...f,...d},_=W0(t.tileAttributes,a,"tile"),p=W0(t.contentAttributes,h,"content"),y=(e.contentUrlTemplates?.length?e.contentUrlTemplates:[e.contentUrlTemplate]).map((v,A)=>{if(!o[A]||!v)return null;let I=Zr(v,n,m);if(/{[^{}]+}/.test(I))throw new Error(`Implicit content URI has unresolved template values: ${I}`);return{contentIndex:A,contentUrl:I}}).filter(v=>!!v),S=y.map(v=>v.contentUrl),x=Z0(e.resourceFiles,t.resourceFiles),E=y.map(({contentIndex:v,contentUrl:A})=>{let I=X0(x,A);return{...e.contentHeaders?.[v]||(v===0?e.contentHeader:{})||{},...p,uri:A,...u?{metadata:{properties:u}}:{},...I?{_resource:I}:{}}}),T=S[0],R=e.rootLodMetricValue/2**n.level,C=_.geometricError??R,O=tf(e.rootBoundingVolume,n,e.subdivisionScheme);return{id:J0(r,n),children:s,contentUrl:T,content:E.length>1?E:E[0],contents:e.useCanonicalContents&&E.length?E:void 0,contentUrls:S,refine:_.refine||e.refine,type:m2(T),lodMetricType:e.lodMetricType,lodMetricValue:C,geometricError:C,boundingVolume:_.boundingVolume||O,transform:_.transform,transformMatrix:_.transform,metadata:c?{properties:c}:void 0,implicitMetadata:Q0(t,c,u),_scaleGeometricError:e.scaleGeometricError!==!1}}function Q0(t,e,r){if(!(!t.propertyTables&&t.tileMetadata===void 0&&!t.contentMetadata&&t.subtreeMetadata===void 0&&!e&&!r))return{propertyTables:t.propertyTables,tileMetadata:t.tileMetadata,contentMetadata:t.contentMetadata,subtreeMetadata:t.subtreeMetadata,tileProperties:e,contentProperties:r}}function J0(t,e){return`${t.subtreeUrl}#implicit=${e.level}/${e.x}/${e.y}/${e.z}`}function Jt(t,e){if(typeof t?.constant=="number")return!!t.constant;let r=t?.explicitBitstream;if(!r)return!1;let n=Math.floor(e/8),i=e%8;return!!(r[n]>>i&1)}function u2(t,e){return(Array.isArray(t)?t:[t]).map(n=>Jt(n||{constant:0},e))}function f2(t,e){return(t**e-1)/(t-1)}function $0(t,e,r){return{level:t.level+1,x:t.x*2+(e&1),y:t.y*2+(e>>1&1),z:r==="OCTREE"?t.z*2+(e>>2&1):0}}function ef(t){return t==="OCTREE"?a2:s2}function tf(t,e,r){if(t.region){let[n,i,o,s,a,c]=t.region,l=2**e.level,u=(o>=n?o-n:o+2*Math.PI-n)/l,f=(s-i)/l,d=Y0(n+u*e.x),m=Y0(n+u*(e.x+1)),_=i+f*e.y,p=a,M=c;if(r==="OCTREE"){let y=(c-a)/l;p=a+y*e.z,M=p+y}return{region:[d,_,m,_+f,p,M]}}if(t.box){if(t.s2VolumeInfo)return d2(t,e,r);if(t.extensions?.["3DTILES_shape_cylinder_region"])return{...t,box:[...t.box]};let n=t.box,i=2**e.level,o=-1+(2*e.x+1)/i,s=-1+(2*e.y+1)/i,a=-1+(2*e.z+1)/i,c=r==="OCTREE";return{box:[...[n[0]+n[3]*o+n[6]*s+(c?n[9]*a:0),n[1]+n[4]*o+n[7]*s+(c?n[10]*a:0),n[2]+n[5]*o+n[8]*s+(c?n[11]*a:0)],n[3]/i,n[4]/i,n[5]/i,n[6]/i,n[7]/i,n[8]/i,c?n[9]/i:n[9],c?n[10]/i:n[10],c?n[11]/i:n[11]]}}throw new Error(`Unsupported implicit 3D Tiles bounding volume: ${JSON.stringify(t)}`)}function d2(t,e,r){let n=t.s2VolumeInfo,i=Xt(n.token),o=Xs(i,e.level,e.x,e.y),s=2**e.level,a=(n.maximumHeight-n.minimumHeight)/s,c={token:Wr(o),minimumHeight:n.minimumHeight+(r==="OCTREE"?a*e.z:0),maximumHeight:n.minimumHeight+(r==="OCTREE"?a*(e.z+1):a*s)},l=t.extensions?{...t.extensions}:void 0;return l?.["3DTILES_bounding_volume_S2"]&&(l["3DTILES_bounding_volume_S2"]=c),l?.["3DTILES_shape_s2"]&&(l["3DTILES_shape_s2"]=c),{...t,...l?{extensions:l}:{},s2VolumeInfo:c,box:Ri(c)}}function Y0(t){let e=t;for(;e>Math.PI;)e-=2*Math.PI;for(;e<-Math.PI;)e+=2*Math.PI;return e}function m2(t){if(!t)return Ke.EMPTY;let e=t.split("?")[0].split(".").pop()?.toLowerCase();switch(e){case"pnts":return Ke.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Ke.SCENEGRAPH;default:return e||Ke.EMPTY}}function p2(t){if(t.subdivisionScheme!=="QUADTREE"&&t.subdivisionScheme!=="OCTREE")throw new Error(`Unsupported implicit subdivision scheme: ${t.subdivisionScheme}`);if(!Number.isInteger(t.subtreeLevels)||t.subtreeLevels<1)throw new Error("Implicit subtreeLevels must be a positive integer");if(!Number.isInteger(t.maximumLevel)||t.maximumLevel<0)throw new Error("Implicit availableLevels must describe at least the root level")}var g2={draco:!1,meshopt:!1,dds:!1,ktx2:!1},_2=32,Ai=class{type=he.TILES3D;loader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...g2};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(e,r={}){let n=M2(e);this.rootTileset=nf(e)?null:e,this.tileset=this.rootTileset,this.loader=n.loader,this.url=n.url,this.basePath=n.basePath||be.dirname(n.url),this.resolver=n.resolver,this.coreApi=n.coreApi,this.loadOptions=r;let i=Number(r["3d-tiles"]?.maximumCachedSubtrees),o=Number.isFinite(i)?Math.max(0,Math.floor(i)):_2;this.implicitSubtreeCache=new fr({maxEntries:o})}destroy(){this.destroyed=!0,this.tileUrlCache.clear(),this.implicitSubtreeCache.clear()}async initialize(){if(!this.rootTileset){let e=this.loadOptions[this.loader.id]||{};this.rootTileset=await this.loadRootData(this.url,{...this.loadOptions,[this.loader.id]:{...e,isTileset:!0}})}if(this.tileset=this.rootTileset,this.rootTileset.queryString){let e=new URLSearchParams(this.rootTileset.queryString);for(let[r,n]of e.entries())this.setQueryParameter(r,n)}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:ri(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(e){let r=e.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 Mt(r,e.options.spatial),e.spatialReference=Ft(r),this.preparedRootHeader=this.transformTileHeader(this.getMetadata().tileset.root,new G))}initializeTileHeaders(e,r,n){let i=n?r.root:this.preparedRootHeader||r.root,o=new Pe(e,i,n||void 0);n&&(n.children.push(o),o.depth=n.depth+1);let s=[o];for(;s.length>0;){let a=s.pop();e.stats.get("Tiles In Tileset(s)").incrementCount();let c=a.header.children||[];for(let l of c){let h=new Pe(e,l,a);if(h.contentUrl?.includes("?session=")){let f=new URL(h.contentUrl).searchParams.get("session");f&&this.setQueryParameter("session",f)}a.children.push(h),h.depth=a.depth+1,s.push(h)}}return o}createTraverser(e){return new ei(e)}async loadTileContent(e){let r=(e.contentUrls||[e.contentUrl]).filter(Boolean),n=this.tileContentHeaders.get(e),i=n||(Array.isArray(e.header?.content)?e.header.content:e.header?.content?[e.header.content]:[]);n||this.tileContentHeaders.set(e,i);let o=this.loadOptions[this.loader.id]||{},s={...this.loadOptions,[this.loader.id]:{...o,isTileset:"auto",assetGltfUpAxis:this.asset&&this.asset.gltfUpAxis||"Y",_tilesetOptions:{spatialReference:e.header?._spatialReference||e.tileset?.spatialReference,spatialOptions:e.tileset?.options.spatial,spatialTransform:e.header?._spatialTransform}}},a=await Promise.all(r.map((l,h)=>{let u=i[h]||{},f=u.extensions?.["3DTILES_content_gltf_vector"],d=u._vectorContent||(f?.vector===!0?{clip:f.clip===!0}:void 0),m=d?{...s,[this.loader.id]:{...s[this.loader.id],vectorContent:d}}:s;return this.loadContentResource(this.getTileUrl(l),u._resource,m)}));e.contents=a,e.content=a[0]||null;let c=a.filter(l=>l?.shape==="tileset3d");return{loaded:!0,contents:a,nestedTileset:c[0],nestedTilesets:c}}transformTileHeader(e,r=new G){return this.spatialTransformer?this.transformTileHeaderWithTransformer(e,this.spatialTransformer,r):e}transformTileHeaderWithTransformer(e,r,n,i){let o=e.transform?new G(e.transform):new G,s=new G(n).multiplyRight(o),a=Array.isArray(e.content)?e.content.map(c=>this.transformContentHeader(c,s,r)):e.content?this.transformContentHeader(e.content,s,r):e.content;return{...e,transform:void 0,boundingVolume:e.boundingVolume?r.transformBoundingVolume(e.boundingVolume,s):e.boundingVolume,_spatialReference:i,_spatialTransform:s.toArray(),content:a,children:Array.isArray(e.children)?e.children.map(c=>this.transformTileHeaderWithTransformer(c,r,s,i)):e.children}}transformContentHeader(e,r,n){return{...e,boundingVolume:e.boundingVolume?n.transformBoundingVolume(e.boundingVolume,r):e.boundingVolume}}async loadTileChildren(e,r){let n=e.header.implicitSubtree;if(!n)return{loaded:!1,tileCount:0,childSubtreeCount:0};let i=this.getTileUrl(n.subtreeUrl),o=await this.loadImplicitSubtreeResource(i,n.resource);if(this.destroyed||e.isDestroyed())return{loaded:!1,tileCount:0,childSubtreeCount:0};let s=Ci(o,{...n,subtreeUrl:i}),a=e.header._spatialReference,c=a?new Mt(a,e.tileset.options.spatial):this.spatialTransformer,l=c?this.transformTileHeaderWithTransformer(s.root,c,new G,a):s.root;e.applyImplicitSubtreeHeader(l);let h=this.initializeMaterializedChildren(e.tileset,e,l.children);return this.implicitTilingStats.loadedSubtrees++,this.implicitTilingStats.materializedTiles+=h,{loaded:!0,tileCount:s.tileCount,childSubtreeCount:s.childSubtreeCount}}async loadTileChildrenForTraversal(e,r){rf(r);let n=await this.loadTileChildren(e,{});return rf(r),n}getImplicitTilingStats(){return{...this.implicitTilingStats,cachedSubtrees:this.implicitSubtreeCache.size-this.implicitSubtreeCache.pendingSize,pendingSubtrees:this.implicitSubtreeCache.pendingSize}}getTileUrl(e){if(e.startsWith("data:"))return e;let r=this.tileUrlCache.get(e);if(r)return r;if(!Object.keys(this.queryParams).length)return this.tileUrlCache.set(e,e),e;let[n,i=""]=e.split("?"),o=new URLSearchParams(i);for(let[c,l]of Object.entries(this.queryParams))o.has(c)||o.set(c,l);let s=o.toString(),a=s?`${n}?${s}`:n;return this.tileUrlCache.set(e,a),a}setQueryParameter(e,r){this.queryParams[e]!==r&&(this.queryParams[e]=r,this.tileUrlCache.clear())}getViewState(e){if(!e)return{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits};let{center:r}=e.boundingVolume,n;return r&&(r[0]!==0||r[1]!==0||r[2]!==0)?(n=new g,N.WGS84.cartesianToCartographic(r,n)):n=new g(0,0,-N.WGS84.radii[0]),{asset:this.asset,properties:this.properties,extras:this.extras,credits:this.credits,boundingVolume:e.boundingVolume,cartographicCenter:n,cartesianCenter:r,zoom:Vl(e.boundingVolume,n)}}hasExtension(e){return this.extensionsUsed.includes(e)}onTileLoaded(e,r,n){let o=(r.contents.length?r.contents:[r.content]).flatMap(a=>a?.gltf?.extensionsRemoved||[]);o.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),o.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),o.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0);let s=n.nestedTilesets||(n.nestedTileset?[n.nestedTileset]:[]);for(let a of s)e._initializeTileHeaders(this.prepareNestedTileset(e,a),r)}prepareNestedTileset(e,r){let n=r.spatialMetadata,i=e.spatialReference;if(n?.status==="unresolved"||n?.crs.state==="unknown")throw new Error(n.warnings[0]||"Nested 3D Tiles CRS is explicitly unresolved and cannot be placed in the parent frame");if(!n||!n.sourceCrs)return this.spatialTransformer&&(i.status==="transformable"||i.status==="transformed")?{...r,spatialMetadata:i,root:this.transformTileHeaderWithTransformer(r.root,this.spatialTransformer,new G,i)}:ea(r,i);let o=i.coordinateEpoch,s=n.coordinateEpoch;if(o!==void 0&&s!==void 0&&o!==s)throw new Error(`Nested 3D Tiles coordinate epoch ${s} differs from parent epoch ${o}; epoch-aware transformation is unavailable`);let a=i.targetCrs||i.sourceCrs;if(!a)return ea(r,n);let c=wt(n,{...e.options.spatial,outputCoordinates:"target-crs",targetCrs:a});if(c.status==="unresolved")throw new Error(c.warnings[0]||"Nested 3D Tiles CRS cannot be resolved in the parent output frame");if(c.status==="native")return ea(r,c);let l=new Mt(c,e.options.spatial);return{...r,spatialMetadata:c,root:this.transformTileHeaderWithTransformer(r.root,l,new G,c)}}async loadWithCoreApi(e,r,n=this.loader){if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to load tileset data");return await this.coreApi.load(e,n,r)}async loadRootData(e,r){return this.resolver?await this.resolver.loadRoot(e,this.loader,r):await this.loadWithCoreApi(e,r)}async loadResourceData(e,r,n=this.loader){return this.resolver?await this.resolver.loadResource(e,n,r):await this.loadWithCoreApi(e,r,n)}async loadContentResource(e,r,n){if(!r)return await this.loadResourceData(e,n);let i=r.files[r.fileIndex];if(!i)throw new Error(`3D Tiles package references missing file ${r.fileIndex}`);if(i.uri)return await this.loadResourceData(this.getTileUrl(i.uri),n);if(!this.coreApi)throw new Error("Tiles3DSource requires an injected coreApi to parse embedded package data");let o=await this.getPackageFileData(i),a=`gltf-package://${this.getPackageNamespace(r.files)}/${r.fileIndex}`,c=i.name||"content",l=c.lastIndexOf("/"),h=l>=0?`${a}/${c.slice(0,l)}`:a;return await this.coreApi.parse(o,this.loader,n,{url:`${a}/${c}`,filename:c,baseUrl:h,loaders:[this.loader],coreApi:this.coreApi,_parse:this.coreApi.parse,_tiles3dPackageFiles:r.files,fetch:async(u,f)=>{let d=u.startsWith(`${a}/`)?u.slice(a.length+1):u,m=r.files.find(p=>p.name===d||p.originalUri===d);if(!m)throw new Error(`3D Tiles glTF package does not contain file ${d}`);if(m.uri)return await this.coreApi.fetchFile(this.getTileUrl(m.uri),f);let _=await this.getPackageFileData(m);return new Response(_,{headers:{"content-type":m.mimeType}})}})}getPackageNamespace(e){let r=this.packageNamespaces.get(e);if(r!==void 0)return r;let n=this.nextPackageNamespace++;return this.packageNamespaces.set(e,n),n}async getPackageFileData(e){if(e.data)return Pn(e.data,e.byteOffset,e.byteLength);if(e.bufferUri&&this.coreApi){let r=await this.coreApi.fetchFile(this.getTileUrl(e.bufferUri));if(!r.ok)throw new Error(`Failed to fetch 3D Tiles package buffer: HTTP ${r.status}`);let n=await r.arrayBuffer();return Pn(n,e.byteOffset,e.byteLength)}throw new Error("3D Tiles package file has no available byte source")}async loadImplicitSubtreeResource(e,r){let n=this.implicitSubtreeCache.get(e);if(n)return this.implicitTilingStats.cacheHits++,await n;this.implicitTilingStats.requestedSubtrees++;let i=this.loadOptions[this.loader.id]||{};return await this.implicitSubtreeCache.getOrLoad(e,async()=>{let o={...this.loadOptions,[this.loader.id]:{...i,isTileset:!1,isSubtree:!0}};return await(r?this.loadContentResource(e,r,o):this.loadResourceData(e,o))})}initializeMaterializedChildren(e,r,n){let i=0,o=[{parentTile:r,childHeaders:n}];for(;o.length>0;){let s=o.pop();for(let a of s.childHeaders){let c=new Pe(e,a,s.parentTile);s.parentTile.children.push(c),c.depth=s.parentTile.depth+1,e.stats.get("Tiles In Tileset(s)").incrementCount(),i++,a.children?.length&&o.push({parentTile:c,childHeaders:a.children})}}return i}};function rf(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted","AbortError")}function nf(t){return!!(t&&typeof t=="object"&&"url"in t&&"loader"in t&&!("type"in t))}function M2(t){return nf(t)?{...t,basePath:t.basePath||be.dirname(t.url)}:{url:t.url,loader:t.loader,basePath:t.basePath||be.dirname(t.url),resolver:t.resolver,coreApi:t.coreApi}}function ea(t,e){let r=n=>({...n,_spatialReference:e,children:Array.isArray(n.children)?n.children.map(r):n.children});return{...t,spatialMetadata:e,root:r(t.root)}}var Ii=class{frameNumberMap=new Map;register(e,r){let n=this.frameNumberMap.get(e)||new Map,i=n.get(r)||0;n.set(r,i+1),this.frameNumberMap.set(e,n)}deregister(e,r){let n=this.frameNumberMap.get(e);if(!n)return;let i=n.get(r)||1;n.set(r,i-1)}isZero(e,r){return(this.frameNumberMap.get(e)?.get(r)||0)===0}};var ta={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},Oi=class{_statusMap;pendingTilesRegister=new Ii;constructor(){this._statusMap={}}add(e,r,n,i){if(!this._statusMap[r]){let{frameNumber:o,viewport:{id:s}}=i;this._statusMap[r]={request:e,callback:n,key:r,frameState:i,status:ta.REQUESTED},this.pendingTilesRegister.register(s,o),e().then(a=>{this._statusMap[r].status=ta.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,i)}).catch(a=>{this._statusMap[r].status=ta.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),n(a)})}}update(e,r){if(this._statusMap[e]){let{frameNumber:n,viewport:{id:i}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(i,n);let{frameNumber:o,viewport:{id:s}}=r;this.pendingTilesRegister.register(s,o),this._statusMap[e].frameState=r}}find(e){return this._statusMap[e]}hasPendingTiles(e,r){return!this.pendingTilesRegister.isZero(e,r)}};var Ni=class extends Xe{_tileManager;constructor(e){super(e),this._tileManager=new Oi}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,r){return e._lodJudge=Jn(e,r),e._lodJudge==="DIG"}updateChildTiles(e,r){let n=e.header.children||[],i=e.children;for(let o of n){let s=`${o.id}-${r.viewport.id}`,a=i&&i.find(c=>c.id===s||c.header?.id===o.id);if(a)a&&this.updateTile(a,r);else{let c=()=>this._loadTile(e,o.id,r);this._tileManager.find(s)?this._tileManager.update(s,r):this._tileManager.add(c,s,h=>this._onTileLoad(h,e,s),r)}}return!1}async _loadTile(e,r,n){if(!e.tileset.source.loadChildTileHeader)throw new Error("I3S source does not support child tile header loading");return await e.tileset.source.loadChildTileHeader(e,r,n)}_onTileLoad(e,r,n){if(e instanceof Error){r.tileset._onSourceError(e,r);return}let i=new Pe(r.tileset,e,r,n);r.children.push(i);let o=this._tileManager.find(i.id).frameState;this.updateTile(i,o),this._frameNumber===o.frameNumber&&(this.traversalFinished(o)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(i,o)}};var tr=class{spatialReference;targetCoordinateFrame;positionTransformer;sourceToGeographicTransformer;geographicToTargetTransformer;sourceCoordinateFrame;sourceVerticalUnitScale;elevationMode;elevationOffset;elevationProvider;providerUnitScale;providerHeightTransformer;constructor(e,r={}){if(e.status!=="transformable"&&e.status!=="transformed")throw new Error("I3SSpatialTransformer requires a requested, transformable spatial output");let n=e.targetCrs||e.sourceCrs;if(!n)throw new Error("I3S spatial transformation requires a target CRS");if(this.positionTransformer=new Be(e,r),this.sourceCoordinateFrame=e.coordinateFrame,this.sourceVerticalUnitScale=e.verticalUnitScale,this.elevationMode=e.elevationMode,this.elevationOffset=(e.elevationOffset||0)*e.elevationUnitScale,this.elevationProvider=y2(this.elevationMode,r),this.elevationProvider&&(typeof this.elevationProvider.sampleElevations!="function"||typeof this.elevationProvider.getElevationRange!="function"))throw new Error("An I3S elevation provider must implement sampleElevations() and getElevationRange()");let i=Er(this.elevationProvider?.unit||"meter");if(this.elevationProvider&&i===void 0)throw new Error(`Unsupported elevation-provider unit ${this.elevationProvider.unit}`);this.providerUnitScale=i||1,this.targetCoordinateFrame=_e(n),this.spatialReference=Ft(e);let o=ve({sourceCrs:e.sourceCrs,heightReference:e.heightReference,coordinateFrame:e.coordinateFrame,axisOrder:e.axisOrder,provenance:e.provenance},{targetCrs:"EPSG:4326"});if(this.sourceToGeographicTransformer=new Be(o),er(this.elevationMode)){if(!this.elevationProvider){let c=this.elevationMode==="relativeToScene"?"scene":"terrain";throw new Error(`I3S elevation mode ${this.elevationMode} requires a ${c} elevation provider`)}if(e.heightReference==="unknown")throw new Error(`I3S elevation mode ${this.elevationMode} requires a known source height reference`);let a=this.elevationProvider.heightReference||e.heightReference;if(a!==e.heightReference){if(e.heightReference!=="ellipsoidal"&&e.heightReference!=="orthometric")throw new Error("Converting elevation-provider heights requires an ellipsoidal or orthometric source height reference");let c=ve({sourceCrs:"EPSG:4326",heightReference:a,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"caller-override"},{targetCrs:"EPSG:4326",targetHeightReference:e.heightReference,geoidModel:r.geoidModel});this.providerHeightTransformer=new Be(c,r)}}let s=ve({sourceCrs:"EPSG:4326",heightReference:e.heightReference,coordinateFrame:"geographic",axisOrder:"xyz",provenance:"format-default"},{targetCrs:n,targetHeightReference:e.targetHeightReference,geoidModel:r.geoidModel});this.geographicToTargetTransformer=new Be(s,r)}transformPosition(e){let r=this.placeSourcePositionsSync(e),n=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}async transformPositionAsync(e){let r=await this.placeSourcePositions(e),n=this.positionTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}transformPlacedPosition(e){let r=this.positionTransformer.transformPosition([e[0],e[1],e[2]]);return[r[0],r[1],r[2]]}transformSourcePositionToGeographic(e){let r=this.placeSourcePositionsSync(e),n=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}async transformSourcePositionToGeographicAsync(e){let r=await this.placeSourcePositions(e),n=this.sourceToGeographicTransformer.transformPosition([r[0],r[1],r[2]]);return[n[0],n[1],n[2]]}transformPositions(e,r){let n=this.placeSourcePositionsSync(e),i=this.placeSourcePositionsSync(r);return this.transformPlacedPositions(n,i)}async transformPositionsAsync(e,r){let n=new Float64Array(e.length+3);n.set(Array.from(e),0),n.set(Array.from(r).slice(0,3),e.length);let i=await this.placeSourcePositions(n);return this.transformPlacedPositions(i.subarray(0,e.length),i.subarray(e.length))}transformPlacedPositions(e,r){let n=this.transformPlacedPosition(r),i=new Float32Array(e.length),o=Float64Array.from(e);for(let c=0;c<e.length;c+=3){let l=this.transformPlacedPosition([e[c],e[c+1],e[c+2]]);i[c]=l[0]-n[0],i[c+1]=l[1]-n[1],i[c+2]=l[2]-n[2]}let s=this.targetCoordinateFrame==="geographic",a=s?new G:new G().translate(n);return{positions:i,sourcePositions:o,origin:n,cartographicOrigin:s?n:[0,0,0],coordinateSystem:s?"lnglat-offsets":"cartesian",modelMatrix:a}}transformNormals(e,r,n="earth-centered"){let i=new Float32Array(e.length);for(let o=0;o<e.length;o+=3){let s=this.sourceToGeographicTransformer.transformPosition([r[o],r[o+1],r[o+2]]),a=new g([e[o],e[o+1],e[o+2]]).normalize(),c=n==="earth-centered"?a:lf(a,s),l=this.transformEcefNormal(c,s);i.set(l,o)}return i}transformBoundingVolume(e){let n=this.getGeographicBoundSamples(e).map(i=>this.geographicToTargetTransformer.transformPosition(i));return this.targetCoordinateFrame==="geographic"?{region:yt(n)}:{box:Rt(n)}}async transformBoundingVolumeAsync(e){let n=(await this.getGeographicBoundSamplesAsync(e)).map(i=>this.geographicToTargetTransformer.transformPosition(i));return this.targetCoordinateFrame==="geographic"?{region:yt(n)}:{box:Rt(n)}}transformBoundingVolumeToGeographic(e){return{region:yt(this.getGeographicBoundSamples(e))}}async transformBoundingVolumeToGeographicAsync(e){return{region:yt(await this.getGeographicBoundSamplesAsync(e))}}transformBoundingVolumeToGeocentric(e){let r=this.getGeographicBoundSamples(e).map(n=>Array.from(N.WGS84.cartographicToCartesian(new g(n))));return{box:Rt(r)}}async transformBoundingVolumeToGeocentricAsync(e){let r=(await this.getGeographicBoundSamplesAsync(e)).map(n=>Array.from(N.WGS84.cartographicToCartesian(new g(n))));return{box:Rt(r)}}transformBoundingSphereToGeographic(e){let r=e.mbs?.length?Array.from(e.mbs).slice(0,3):e.obb?Array.from(e.obb.center).slice(0,3):null;if(!r)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let n=this.placeSourcePositionsSync(r),i=this.sourceToGeographicTransformer.transformPosition(Array.from(n)),o=e.mbs?.length?e.mbs[3]:Math.hypot(...Array.from(e.obb.halfSize).slice(0,3));return[i[0],i[1],i[2],o]}async transformBoundingSphereToGeographicAsync(e){return of(await this.getGeographicBoundSamplesAsync(e))}async transformBoundsAsync(e){let r=await this.getGeographicBoundSamplesAsync(e),n=r.map(o=>Array.from(N.WGS84.cartographicToCartesian(new g(o)))),i=r.map(o=>this.geographicToTargetTransformer.transformPosition(o));return{boundingVolume:{box:Rt(n)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:yt(i)}:{box:Rt(i)},i3sLodMbs:er(this.elevationMode)?of(r):this.transformBoundingSphereToGeographic(e)}}async transformPointCloudBoundsAsync(e){let r=await this.getGeographicBoundSamplesAsync(e),n=r.map(i=>this.geographicToTargetTransformer.transformPosition(i));return{boundingVolume:{region:yt(r)},spatialBoundingVolume:this.targetCoordinateFrame==="geographic"?{region:yt(n)}:{box:Rt(n)}}}getGeographicBoundSamples(e){let r=sf(e,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");let n=this.placeSourcePositionsSync(r.flat(),!0),i=ra(n);return this.sourceCoordinateFrame==="geographic"?i:i.map(o=>this.sourceToGeographicTransformer.transformPosition(o))}async getGeographicBoundSamplesAsync(e){let r=sf(e,this.sourceCoordinateFrame,this.sourceToGeographicTransformer,this.sourceVerticalUnitScale);if(!r.length)throw new Error("I3S spatial transformation requires an MBS or OBB bound");if(er(this.elevationMode)){let i=this.sourceCoordinateFrame==="geographic"?r:r.map(o=>this.sourceToGeographicTransformer.transformPosition(o));return await this.placeGeographicBoundSamples(i)}let n=ra(await this.placeSourcePositions(r.flat(),!0));return this.sourceCoordinateFrame==="geographic"?n:n.map(i=>this.sourceToGeographicTransformer.transformPosition(i))}async placeGeographicBoundSamples(e){let n=await this.elevationProvider.getElevationRange(x2(e)),i=n.minimum*this.providerUnitScale,o=n.maximum*this.providerUnitScale;if(!Number.isFinite(i)||!Number.isFinite(o)||i>o)throw new Error("Elevation provider returned an invalid range; minimum and maximum must be finite and ordered");let s=e.map(h=>h[2]),a=Math.min(...s),c=Math.max(...s),l=[];for(let[h,u]of e){let f=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([h,u,i])[2]:i,d=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([h,u,o])[2]:o,m=Math.min(f,d),_=Math.max(f,d),p=this.elevationMode==="onTheGround"?m:m+a+this.elevationOffset,M=this.elevationMode==="onTheGround"?_:_+c+this.elevationOffset;l.push([h,u,p],[h,u,M])}return l}placeSourcePositionsSync(e,r=!1){if(er(this.elevationMode))throw new Error(`I3S elevation mode ${this.elevationMode} requires asynchronous surface placement`);let n=Float64Array.from(e),i=this.elevationMode==="absoluteHeight"?this.elevationOffset:0;for(let o=2;o<n.length;o+=3)n[o]=n[o]*(r?1:this.sourceVerticalUnitScale)+i;return n}async placeSourcePositions(e,r=!1){if(!er(this.elevationMode))return this.placeSourcePositionsSync(e,r);let n=Float64Array.from(e),i=ra(n).map(s=>{let a=this.sourceToGeographicTransformer.transformPosition(s);return[a[0],a[1]]}),o=await this.elevationProvider.sampleElevations(i);if(o.length!==i.length)throw new Error(`Elevation provider returned ${o.length} heights for ${i.length} positions`);for(let s=0;s<i.length;s++){let a=o[s]*this.providerUnitScale;if(!Number.isFinite(a))throw new Error(`Elevation provider returned a non-finite height at index ${s}`);let[c,l]=i[s],h=this.providerHeightTransformer?this.providerHeightTransformer.transformPosition([c,l,a])[2]:a,u=n[s*3+2]*(r?1:this.sourceVerticalUnitScale);n[s*3+2]=this.elevationMode==="onTheGround"?h:h+u+this.elevationOffset}return n}transformEcefNormal(e,r){if(this.targetCoordinateFrame==="geocentric")return e.normalize();if(this.targetCoordinateFrame==="geographic")return w2(e,r).normalize();let n=N.WGS84.cartographicToCartesian(new g(r)),i=[];for(let s of S2()){let a=N.WGS84.cartesianToCartographic(new g(n).add(s)),c=N.WGS84.cartesianToCartographic(new g(n).subtract(s)),l=this.geographicToTargetTransformer.transformPosition(a),h=this.geographicToTargetTransformer.transformPosition(c);i.push((l[0]-h[0])/2,(l[1]-h[1])/2,(l[2]-h[2])/2)}let o=new W(i);if(Math.abs(o.determinant())<1e-12)throw new Error("Cannot transform an I3S normal through a singular local projection");return o.invert().transpose(),new g(e).transformByMatrix3(o).normalize()}};function y2(t,e){return t==="relativeToScene"?e.sceneElevationProvider:er(t)?e.terrainElevationProvider:void 0}function er(t){return t==="onTheGround"||t==="relativeToGround"||t==="relativeToScene"}function ra(t){if(t.length%3!==0)throw new Error("I3S position arrays must contain complete XYZ tuples");let e=[];for(let r=0;r<t.length;r+=3)e.push([t[r],t[r+1],t[r+2]]);return e}function x2(t){let e=yt(t);return{west:e[0]*180/Math.PI,south:e[1]*180/Math.PI,east:e[2]*180/Math.PI,north:e[3]*180/Math.PI}}function of(t){if(!t.length)throw new Error("I3S spatial transformation requires at least one bound sample");let e=t.map(o=>N.WGS84.cartographicToCartesian(new g(o))),r=new g;for(let o of e)r.add(o);r.scale(1/e.length);let n=0;for(let o of e)n=Math.max(n,new g(o).subtract(r).magnitude());let i=N.WGS84.cartesianToCartographic(r);return[i[0],i[1],i[2],n]}function sf(t,e,r,n){let i=t.obb;if(i){let c=Array.from(i.center).slice(0,3);c[2]*=n;let l=Array.from(i.halfSize).slice(0,3),h=new Ne().fromArray(Array.from(i.quaternion)),u=[new g([l[0],0,0]).transformByQuaternion(h),new g([0,l[1],0]).transformByQuaternion(h),new g([0,0,l[2]]).transformByQuaternion(h)];if(e==="geographic"){let f=r.transformPosition(c),d=N.WGS84.cartographicToCartesian(new g(f)),m=t.normalReferenceFrame==="vertex-reference-frame"?u.map(_=>lf(_,f)):u;return af().map(_=>{let p=new g(d);for(let M=0;M<3;M++)p.add(new g(m[M]).scale(_[M]));return Array.from(N.WGS84.cartesianToCartographic(p))})}return af().map(f=>{let d=new g(c);for(let m=0;m<3;m++)d.add(new g(u[m]).scale(f[m]));return Array.from(d)})}let o=t.mbs?Array.from(t.mbs):[];if(o.length<4)return[];let s=o.slice(0,3);s[2]*=n;let a=o[3];if(e==="geographic"){let c=r.transformPosition(s),l=N.WGS84.cartographicToCartesian(new g(c));return cf().map(h=>Array.from(N.WGS84.cartesianToCartographic(new g(l).add(new g(h).scale(a)))))}return cf().map(c=>Array.from(new g(s).add(new g(c).scale(a))))}function af(){return[-1,1].flatMap(t=>[-1,1].flatMap(e=>[-1,1].map(r=>[t,e,r])))}function cf(){return[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]]}function S2(){return[new g([1,0,0]),new g([0,1,0]),new g([0,0,1])]}function lf(t,e){let r=e[0]*Math.PI/180,n=e[1]*Math.PI/180,i=new g([-Math.sin(r),Math.cos(r),0]),o=new g([-Math.sin(n)*Math.cos(r),-Math.sin(n)*Math.sin(r),Math.cos(n)]),s=new g([Math.cos(n)*Math.cos(r),Math.cos(n)*Math.sin(r),Math.sin(n)]);return i.scale(t[0]).add(o.scale(t[1])).add(s.scale(t[2]))}function w2(t,e){let r=e[0]*Math.PI/180,n=e[1]*Math.PI/180,i=new g([-Math.sin(r),Math.cos(r),0]),o=new g([-Math.sin(n)*Math.cos(r),-Math.sin(n)*Math.sin(r),Math.cos(n)]),s=new g([Math.cos(n)*Math.cos(r),Math.cos(n)*Math.sin(r),Math.sin(n)]);return new g([i.dot(t),o.dot(t),s.dot(t)])}function Rt(t){let e=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0];for(let o of t)for(let s=0;s<3;s++)e[s]=Math.min(e[s],o[s]),r[s]=Math.max(r[s],o[s]);let n=e.map((o,s)=>(o+r[s])/2),i=e.map((o,s)=>(r[s]-o)/2);return[n[0],n[1],n[2],i[0],0,0,0,i[1],0,0,0,i[2]]}function yt(t){let e=t[0][0],r=1/0,n=-1/0,i=1/0,o=-1/0,s=1/0,a=-1/0;for(let c of t){let l=e+na(c[0]-e);r=Math.min(r,l),n=Math.max(n,l),i=Math.min(i,c[1]),o=Math.max(o,c[1]),s=Math.min(s,c[2]),a=Math.max(a,c[2])}return[na(r)*Math.PI/180,i*Math.PI/180,na(n)*Math.PI/180,o*Math.PI/180,s,a]}function na(t){return((t+180)%360+360)%360-180}var E2={draco:!1,meshopt:!1,dds:!1,ktx2:!1},Li=class{type=he.I3S;loader;contentLoader;url;basePath;tileset=null;loadOptions;coreApi;contentFormats={...E2};asset;properties;extras;credits;metadata;queryParams={};resolver;rootTileset;spatialTransformer;preparedRootHeader;constructor(e,r={}){let n=b2(e);this.rootTileset=uf(e)?null:e,this.tileset=this.rootTileset,this.loader=n.loader,this.contentLoader=T2(n.loader),this.url=n.url,this.basePath=n.basePath||be.dirname(n.url),this.resolver=n.resolver,this.coreApi=n.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:ti(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(e){let r=e.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 tr(r,e.options.spatial),e.spatialReference=this.spatialTransformer.spatialReference,this.preparedRootHeader=await this.transformTileHeader(this.getMetadata().tileset.root))}initializeTileHeaders(e,r,n){let i=n?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 o=new Pe(e,i,n||void 0);return n&&(n.children.push(o),o.depth=n.depth+1),o}createTraverser(e){return new Ni(e)}async loadTileContent(e){let r=this.getTileUrl(e.contentUrl),n=this.loader.id,i=this.loadOptions[n]||{},o=this.getMetadata(),s={...this.loadOptions,[n]:{...i,...e.tileset.options.i3s,_tileOptions:{attributeUrls:e.header.attributeUrls,textureUrl:e.header.textureUrl,textureUrls:e.header.textureUrls,textureFormat:e.header.textureFormat,textureLoaderOptions:e.header.textureLoaderOptions,materialDefinition:e.header.materialDefinition,layerType:e.header.layerType,pointRenderer:e.header.pointRenderer,pointSymbol:e.header.pointSymbol,isDracoGeometry:e.header.isDracoGeometry,mbs:e.header.mbs},_tilesetOptions:{store:o.tileset.store,attributeStorageInfo:o.tileset.attributeStorageInfo,fields:o.tileset.fields,spatialReference:e.tileset.spatialReference,spatialOptions:e.tileset.options.spatial},isTileHeader:!1}};e.content=await this.loadResourceData(r,s,this.contentLoader);let a={index:0,uri:e.contentUrl,type:e.header.layerType,payload:e.content,metadata:e.header.metadata||null,boundingVolume:e.boundingVolume,featureIds:e.featureIdSets,renderable:!!e.content};return{loaded:!0,contents:[e.content],contentEntries:[a]}}async loadChildTileHeader(e,r,n){let i=this.getMetadata();if(i.tileset.nodePages||i.tileset.pointNodePages){let l=await i.tileset.nodePagesTile.formTileFromNodePages(r);return await this.transformTileHeader(l)}let o=this.getTileUrl(`${this.url}/nodes/${r}`),s=this.loadOptions.i3s&&typeof this.loadOptions.i3s=="object"?this.loadOptions.i3s:{},a={...this.loadOptions,i3s:{...s,isTileHeader:!0}},c=await this.loadResourceData(o,a);return await this.transformTileHeader(c)}async loadTileChildrenForTraversal(e,r){let n=e.header.children||[],i=0,o=[];for(let a of n){hf(r);let c=a.id;if(typeof c!="string"&&typeof c!="number")throw new Error("I3S child header is missing its node ID");let l=e.children.find(f=>f.id===String(c)||f.header?.id===c);if(l){o.push(l);continue}let h=await this.loadChildTileHeader(e,String(c),null);hf(r);let u=new Pe(e.tileset,h,e,String(c));o.push(u),i++}let s=new Set(o);return e.children=[...o,...e.children.filter(a=>!s.has(a))],{loaded:!0,tileCount:i,childSubtreeCount:0}}getTileUrl(e){if(e.startsWith("data:")||!Object.keys(this.queryParams).length)return e;let r=e.indexOf("#"),n=r>=0?e.slice(r):"",i=r>=0?e.slice(0,r):e,o=i.indexOf("?"),s=o===-1?i:i.slice(0,o),a=o===-1?"":i.slice(o+1),c=new URLSearchParams(a),l=new URLSearchParams;for(let[u,f]of Object.entries(this.queryParams))c.has(u)||l.set(u,f);let h=l.toString();return`${s}${a?`?${a}`:""}${h?`${a?"&":"?"}${h}`:""}${n}`}getViewState(e){if(this.spatialTransformer&&e){let o=new g(e.boundingVolume.center),s=new g(e.header.i3sLodMbs.slice(0,3));return this.spatialTransformer.targetCoordinateFrame==="geographic"?{boundingVolume:e.boundingVolume,cartographicCenter:s,cartesianCenter:o,zoom:1}:{boundingVolume:e.boundingVolume,cartographicCenter:s,cartesianCenter:o,zoom:1}}let r=this.getMetadata(),n=r.tileset.fullExtent;if(n){let{xmin:o,xmax:s,ymin:a,ymax:c,zmin:l,zmax:h}=n,u=new g(o+(s-o)/2,a+(c-a)/2,l+(h-l)/2),f=new g;return N.WGS84.cartographicToCartesian(u,f),{cartographicCenter:u,cartesianCenter:f,zoom:Fo(n,u,f)}}let i=r.tileset.store?.extent;if(i){let[o,s,a,c]=i,l=new g(o+(a-o)/2,s+(c-s)/2,0),h=new g;return N.WGS84.cartographicToCartesian(l,h),{cartographicCenter:l,cartesianCenter:h,zoom:jl(i,l,h)}}return console.warn("Extent is not defined in the tileset header"),{cartographicCenter:new g,zoom:1}}onTileLoaded(e,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(e,r,n=this.loader){if(!this.coreApi)throw new Error("I3SSource requires an injected coreApi to load tileset data");return await this.coreApi.load(e,n,r)}async loadRootData(e,r){return this.resolver?await this.resolver.loadRoot(e,this.loader,r):await this.loadWithCoreApi(e,r)}initializeQueryParams(e){for(let[n,i]of Object.entries(e.searchParams||{}))this.queryParams[n]=String(i);let r=e.i3s;if(r&&typeof r=="object"&&"token"in r){let n=r.token;typeof n=="string"&&(this.queryParams.token=n)}}async loadResourceData(e,r,n=this.loader){return this.resolver?await this.resolver.loadResource(e,n,r):await this.loadWithCoreApi(e,r,n)}async transformTileHeader(e){if(!this.spatialTransformer)return e;let r={mbs:e.mbs,obb:e.obb,normalReferenceFrame:this.getMetadata().tileset.store?.normalReferenceFrame},n=await this.spatialTransformer.transformBoundsAsync(r);return{...e,boundingVolume:n.boundingVolume,spatialBoundingVolume:n.spatialBoundingVolume,i3sLodMbs:n.i3sLodMbs}}};function hf(t){if(t?.aborted)throw t.reason??new DOMException("The operation was aborted","AbortError")}function T2(t){return t.contentLoader||t}function uf(t){return!!(t&&typeof t=="object"&&"url"in t&&"loader"in t&&!("type"in t))}function b2(t){return uf(t)?{...t,basePath:t.basePath||be.dirname(t.url)}:{url:t.url,loader:t.loader,basePath:t.basePath||be.dirname(t.url),resolver:t.resolver,coreApi:t.coreApi}}var Ct=class{index;parent;children;content;error;id;zoom;userData;boundingBox;_abortController;_loader;_loaderId;_isLoaded;_isCancelled;_needsReload;_bbox;constructor(e){this.index=e,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(e){this._bbox||(this._bbox=e,"west"in e?this.boundingBox=[[e.west,e.south],[e.east,e.north]]:this.boundingBox=[[e.left,e.top],[e.right,e.bottom]])}get data(){let e=this._loader;return!this._isCancelled&&e!==void 0?e.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 e=this.content?this.content.byteLength:0;return Number.isFinite(e)?e:0}async _loadData({getData:e,requestScheduler:r,onLoad:n,onError:i}){let o=(p,M,y)=>{if(y===this._loaderId){if(this._loader=void 0,this.content=p,this.error=M?v2(M):null,this._isCancelled&&!p){this._isLoaded=!1;return}if(this._isLoaded=!0,this._isCancelled=!1,M){i(M,this);return}n(this)}},{index:s,id:a,bbox:c,userData:l,zoom:h}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:f}=this._abortController,d=await r.scheduleRequest(this,()=>1);if(!d){this._isCancelled=!0;return}if(this._isCancelled){d.done();return}let m=null,_;try{m=await e({index:s,id:a,bbox:c,userData:l,zoom:h,signal:f})}catch(p){_=p||!0}finally{d.done()}o(m,_,u)}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this.error=null,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}};function v2(t){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error("Tile request failed")}var ia="never",oa="no-overlap",Jr="best-available",ff={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},Qr=class t{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(e){if(this.stats=new Le({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={...ff,...e,getTileData:e.getTileData||(()=>null),tileSource:e.tileSource},this._requestScheduler=new st({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&&!e.getTileData)throw new Error("Tileset2D requires either `getTileData` or `tileSource`.");this.setOptions(e),this._updateStats(),this.opts.tileSource&&this._initializeTileSource(this.opts.tileSource).catch(()=>{})}static fromTileSource(e,r={}){return new t({...r,tileSource:e})}get tiles(){return this._tiles}get cacheByteSize(){return this._cacheByteSize}get selectedTiles(){return Array.from(this._getSelectedTilesUnion())}get visibleTiles(){let e=this._getVisibleTilesUnion();for(let r of this._getSelectedTilesUnion())e.add(r);return Array.from(e)}get loadingTiles(){return Array.from(this._cache.values()).filter(e=>e.isLoading)}get unloadedTiles(){return Array.from(this._cache.values()).filter(e=>!e.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(e){return this._listeners.add(e),()=>this._listeners.delete(e)}attachConsumer(e){this._consumers.set(e,{selectedTiles:new Set,visibleTiles:new Set}),this._updateStats()}detachConsumer(e){this._consumers.delete(e),this._pruneRequests(),this._resizeCache(),this._updateStats()}setOptions(e){this._rememberExplicitOptions(e),this._baseOpts={...this._baseOpts,...e};let r=this.opts.maxRequests,n=this.opts.debounceTime;this._applyResolvedOptions(),(r!==this.opts.maxRequests||n!==this.opts.debounceTime)&&(this._requestScheduler=new st({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}))}finalize(){for(let e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._consumers.clear(),this._cacheByteSize=0,this._unloadedTileCount=0,this._updateStats()}reloadAll(){let e=this._getSelectedTilesUnion();for(let r of this._cache.keys()){let n=this._cache.get(r);n&&!e.has(n)?(this._cache.delete(r),this._handleTileUnload(n),this._dirty=!0):n&&n.setNeedsReload()}this._cacheByteSize=this._getCacheByteSize(),this.prepareTiles(),this._updateStats()}updateConsumer(e,r,n){this._consumers.set(e,{selectedTiles:new Set(r),visibleTiles:new Set(n)}),this._pruneRequests(),this._resizeCache(),this._updateStats()}prepareTiles(){this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}getTileIndices({viewState:e,maxZoom:r,minZoom:n,zRange:i,modelMatrix:o,modelMatrixInverse:s}){let{adapter:a,tileSize:c,extent:l,zoomOffset:h}=this.opts;if(!a)throw new Error("Tileset2D requires an adapter before tile traversal can be used.");return this._lastTileContext={viewState:e,tileSize:c},a.getTileIndices({viewState:e,maxZoom:r,minZoom:n,zRange:i,tileSize:c,extent:P2(l),modelMatrix:o,modelMatrixInverse:s,zoomOffset:h})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){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,e)}}getParentIndex(e){return{x:Math.floor(e.x/2),y:Math.floor(e.y/2),z:e.z-1}}getTile(e,r){let n=this.getTileId(e),i=this._cache.get(n),o=!1;return!i&&r?(i=new Ct(e),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:n,zoom:this.getTileZoom(i.index)}),o=!0,this._cache.set(n,i),this._dirty=!0,this._updateStats()):i&&i.needsReload&&(o=!0),i&&this._touchTile(n,i),i&&o&&r&&(i.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this._handleTileLoad.bind(this),onError:this._handleTileError.bind(this)}).catch(()=>{}),this._updateStats()),i}async _initializeTileSource(e){try{this.sourceMetadata=await e.getMetadata(),this._sourceMetadataOverrides=this._getMetadataOverrides(this.sourceMetadata),this._applyResolvedOptions(),this._notifyUpdate()}catch(r){let n=r instanceof Error?r:new Error(`TileSource metadata error: ${String(r)}`);this._notifyError(n)}}_rememberExplicitOptions(e){for(let r of Object.keys(e))this._explicitOptionKeys.add(r)}_applyResolvedOptions(){let e={...ff,...this._sourceMetadataOverrides,...this._baseOpts};if(e.tileSource){let r=e.tileSource;e.getTileData=n=>r.getTileData(n)}this.opts=e,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(e){if(!e)return{};let r={};return!this._explicitOptionKeys.has("minZoom")&&Number.isFinite(e.minZoom)&&(r.minZoom=e.minZoom),!this._explicitOptionKeys.has("maxZoom")&&Number.isFinite(e.maxZoom)&&(r.maxZoom=e.maxZoom),!this._explicitOptionKeys.has("extent")&&e.boundingBox&&(r.extent=[e.boundingBox[0][0],e.boundingBox[0][1],e.boundingBox[1][0],e.boundingBox[1][1]]),r}_handleTileLoad(e){this.opts.onTileLoad?.(e),this._cacheByteSize=this._getCacheByteSize(),this._resizeCache();for(let r of this._listeners)r.onTileLoad?.(e);this._updateStats()}_handleTileError(e,r){this.opts.onTileError?.(e,r);for(let n of this._listeners)n.onTileError?.(e,r);this._updateStats()}_handleTileUnload(e){this._unloadedTileCount++,this.opts.onTileUnload?.(e);for(let r of this._listeners)r.onTileUnload?.(e);this._updateStats()}_notifyUpdate(){for(let e of this._listeners)e.onUpdate?.()}_notifyError(e){for(let r of this._listeners)r.onError?.(e)}_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 e of this._listeners)e.onStatsChange?.(this.stats)}_setStatCount(e,r){this.stats.get(e).reset().addCount(r)}_getSelectedTilesUnion(){let e=new Set;for(let r of this._consumers.values())for(let n of r.selectedTiles)e.add(n);return e}_getVisibleTilesUnion(){let e=new Set;for(let r of this._consumers.values())for(let n of r.visibleTiles)e.add(n);return e}_touchTile(e,r){this._cache.delete(e),this._cache.set(e,r)}_getCacheByteSize(){let e=0;for(let r of this._cache.values())e+=r.byteLength;return e}_pruneRequests(){let{maxRequests:e=0}=this.opts,r=this._getSelectedTilesUnion(),n=this._getVisibleTilesUnion(),i=[],o=0;for(let s of this._cache.values())s.isLoading&&(o++,!r.has(s)&&!n.has(s)&&i.push(s));for(;e>0&&o>e&&i.length>0;){let s=i.shift();s&&s.abort(),o--}}_rebuildTree(){for(let e of this._cache.values())e.parent=null,e.children&&(e.children.length=0);for(let e of this._cache.values()){let r=this._getNearestAncestor(e);e.parent=r,r?.children&&r.children.push(e)}}_syncTiles(){this._tiles=Array.from(this._cache.values()).sort((e,r)=>e.zoom-r.zoom)}_resizeCache(){let e=this.opts.maxCacheSize??100,r=this.opts.maxCacheByteSize??1/0,n=this._getVisibleTilesUnion(),i=this._getSelectedTilesUnion();if(this._cache.size>e||this._cacheByteSize>r){for(let[s,a]of this._cache)if(!n.has(a)&&!i.has(a)&&(this._cache.delete(s),this._cacheByteSize=this._getCacheByteSize(),this._handleTileUnload(a)),this._cache.size<=e&&this._cacheByteSize<=r)break;this._dirty=!0}this._dirty&&(this._rebuildTree(),this._syncTiles(),this._dirty=!1)}_getNearestAncestor(e){let{_minZoom:r=0}=this,n=e.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let i=this.getTile(n);if(i)return i}return null}};function P2(t){return t&&t.length===4?t:void 0}var Gi={getMetadata:async()=>({name:"",keywords:[],layers:[]}),getImage:async()=>null,debounceTime:0},qi=class t{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(e){if(this._opts=this._normalizeOptions(e),!this._opts.imageSource&&(!e.getImage||!e.getMetadata))throw new Error("ImageSet requires either `imageSource` or both `getImage` and `getMetadata`.")}static fromImageSource(e,r={}){return new t({...r,imageSource:e})}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(e){return this._listeners.add(e),()=>this._listeners.delete(e)}setOptions(e){let r=this._opts.imageSource,n=this._normalizeOptions({...this._opts,...e}),i=r!==n.imageSource||this._opts.getImage!==n.getImage||this._opts.getMetadata!==n.getMetadata;this._opts=n,i&&(this._cancelScheduledImage(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let e=await this._opts.getMetadata();if(this._finalized)return e;this.metadata=e;for(let r of this._listeners)r.onMetadataLoad?.(e);return this._emitUpdate(),e}catch(e){let r=df(e,"Image metadata request failed");if(!this._finalized)for(let n of this._listeners)n.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestImage(e,r=this._opts.debounceTime){let n=this._nextRequestId++;return this._cancelScheduledImage(),this._abortActiveRequest(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadImage(n,e)},r):this._loadImage(n,e),n}finalize(){this._finalized=!0,this._cancelScheduledImage(),this._abortActiveRequest(),this._listeners.clear()}async _loadImage(e,r){if(!this._finalized){this._startLoading();for(let n of this._listeners)n.onImageLoadStart?.(e,r);try{let n=new AbortController;this._abortController=n;let i=await this._opts.getImage({...r,signal:n.signal});if(this._finalized||e<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=e,this._currentRequest={requestId:e,parameters:r,image:i};for(let o of this._listeners)o.onImageLoad?.(this._currentRequest);this._emitUpdate()}catch(n){if(R2(n))return;let i=df(n,"Image request failed");if(!this._finalized)for(let o of this._listeners)o.onImageLoadError?.(e,i,r)}finally{this._abortController?.signal===r.signal&&(this._abortController=null),this._finishLoading()}}}_normalizeOptions(e){let r=e.imageSource||null;return{...Gi,...e,imageSource:r,getMetadata:e.getMetadata||(()=>r?r.getMetadata():Gi.getMetadata()),getImage:e.getImage||(n=>r?r.getImage(n):Gi.getImage(n)),debounceTime:e.debounceTime??Gi.debounceTime}}_emitUpdate(){for(let e of this._listeners)e.onUpdate?.()}_startLoading(){let e=this._loadCounter>0;this._loadCounter++,e||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let e=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),e&&this._loadCounter===0&&(this._emitLoadingStateChange(!1),this._emitUpdate())}_emitLoadingStateChange(e){for(let r of this._listeners)r.onLoadingStateChange?.(e)}_cancelScheduledImage(){this._timeoutId!==null&&(clearTimeout(this._timeoutId),this._timeoutId=null)}_abortActiveRequest(){this._abortController?.abort(),this._abortController=null}};function R2(t){return t instanceof Error&&t.name==="AbortError"}function df(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}var en={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},zi=class t{metadata=null;_opts;_listeners=new Set;_currentRequest=null;_lastAcceptedRequestId=-1;_nextRequestId=0;_loadCounter=0;_timeoutId=null;_abortController=null;_finalized=!1;constructor(e){if(this._opts=this._normalizeOptions(e),!this._opts.rasterSource&&(!e.getRaster||!e.getMetadata))throw new Error("RasterSet requires either `rasterSource` or both `getRaster` and `getMetadata`.")}static fromRasterSource(e,r={}){return new t({...r,rasterSource:e})}static fromCallbacks(e){return new t(e)}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(e){return this._listeners.add(e),()=>this._listeners.delete(e)}setOptions(e){let r=this._opts.rasterSource,n=this._normalizeOptions({...this._opts,...e}),i=r!==n.rasterSource||this._opts.getRaster!==n.getRaster||this._opts.getMetadata!==n.getMetadata;this._opts=n,i&&(this._cancelScheduledRaster(),this.metadata=null,this._currentRequest=null,this._lastAcceptedRequestId=-1,this._nextRequestId=0,this._emitUpdate())}async loadMetadata(){this._startLoading();try{let e=await this._opts.getMetadata();if(this._finalized)return e;this.metadata=e;for(let r of this._listeners)r.onMetadataLoad?.(e);return this._emitUpdate(),e}catch(e){let r=mf(e,"Raster metadata request failed");if(!this._finalized)for(let n of this._listeners)n.onMetadataLoadError?.(r);throw r}finally{this._finishLoading()}}requestRaster(e,r=this._opts.debounceTime){if(!this.shouldRefetchRaster(e))return this._currentRequest?.requestId??-1;let n=this._nextRequestId++;return this._cancelScheduledRaster(),r>0?this._timeoutId=setTimeout(()=>{this._timeoutId=null,this._loadRaster(n,e)},r):this._loadRaster(n,e),n}shouldRefetchRaster(e){return this._opts.shouldRefetch({currentRequest:this._currentRequest,metadata:this.metadata,nextParameters:e})}finalize(){this._finalized=!0,this._cancelScheduledRaster(),this._abortActiveRequest(),this._listeners.clear()}async _loadRaster(e,r){if(!this._finalized){this._startLoading();for(let n of this._listeners)n.onRasterLoadStart?.(e,r);try{let n=new AbortController;this._abortController=n;let i=await this._opts.getRaster(C2(r,n.signal));if(this._finalized||n.signal.aborted||e<=this._lastAcceptedRequestId)return;this._lastAcceptedRequestId=e,this._currentRequest={requestId:e,parameters:r,raster:i};for(let o of this._listeners)o.onRasterLoad?.(this._currentRequest);this._emitUpdate()}catch(n){if(A2(n))return;let i=mf(n,"Raster request failed");if(!this._finalized)for(let o of this._listeners)o.onRasterLoadError?.(e,i,r)}finally{this._abortController=null,this._finishLoading()}}}_normalizeOptions(e){let r=e.rasterSource||null;return{...en,...e,rasterSource:r,getMetadata:e.getMetadata||(()=>r?r.getMetadata():en.getMetadata()),getRaster:e.getRaster||(n=>r?r.getRaster(n):en.getRaster(n)),debounceTime:e.debounceTime??en.debounceTime,shouldRefetch:e.shouldRefetch||(n=>en.shouldRefetch(n))}}_emitUpdate(){for(let e of this._listeners)e.onUpdate?.()}_emitLoadingStateChange(e){for(let r of this._listeners)r.onLoadingStateChange?.(e)}_startLoading(){let e=this._loadCounter>0;this._loadCounter++,e||(this._emitLoadingStateChange(!0),this._emitUpdate())}_finishLoading(){let e=this._loadCounter>0;this._loadCounter=Math.max(0,this._loadCounter-1),e&&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 C2(t,e){let r=Array.isArray(t)?t.slice():Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t));return Object.defineProperty(r,"signal",{configurable:!0,enumerable:!0,value:e,writable:!0}),r}function mf(t,e){return t instanceof Error?t:typeof t=="string"?new Error(t):new Error(e)}function A2(t){return t instanceof Error&&t.name==="AbortError"}var rr=class{header;parent;children=[];childrenLoaded=!1;childrenPromise=null;selected=!1;viewportIds=[];content=null;contentAvailable=!1;contentFailed=!1;isContentLoading=!1;constructor(e,r=null){this.header=e,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(e){this.selected=!0,this.viewportIds.includes(e)||this.viewportIds.push(e)}clearSelection(){this.selected=!1,this.viewportIds=[]}};var I2={debounceTime:0,minimumNodePixelSize:150,maximumScreenSpaceError:1,lodSelectionMetricType:"maxScreenThresholdSQ",densityThreshold:1,pointBudget:2e6,maxDepth:Number.POSITIVE_INFINITY,onTileLoad:()=>{},onTileError:()=>{},onTraversalComplete:t=>t,onUpdate:()=>{}},Bi=64,Di=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(e,r={}){this.dataSource=e,this.options={...I2,...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(e=>e.contentAvailable||e.contentFailed)}selectedTiles=[];update(e=null){this.selectTiles(e).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 e=await this.dataSource.getRootTile();this.root=this.getOrCreateTile(e,null);let r=await this.dataSource.getViewState?.();this.boundingVolume=r?.boundingVolume||this.root.boundingVolume;let n=r?.cartographicCenter||this.root.boundingVolume.center;this.cartographicCenter=new g(n),this.zoom=r?.zoom||this.estimateZoom(this.boundingVolume)}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedViewports=e),this.updatePromise||(this.updatePromise=new Promise((r,n)=>{setTimeout(()=>{this.doSelectTiles().then(()=>r(this.frameNumberValue)).catch(n).finally(()=>{this.updatePromise=null})},this.options.debounceTime)})),this.updatePromise}async doSelectTiles(){if(!this.root||!this.lastUpdatedViewports)return;let e=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],n=new Map,i=new Set,o=0;for(let a of r){let c=this.getTraversalContext(a);o=await this.traverseTiles(c,n,o,i)}this.visibleTilesCount=i.size,this.selectedTiles=this.options.onTraversalComplete(Array.from(n.values()));for(let a of this.selectedTiles)this.loadTile(a).catch(()=>{});let s=new Set(this.selectedTiles.map(a=>a.id));this.haveSameIds(e,s)||this.options.onUpdate()}async traverseTiles(e,r,n,i){if(!this.root)return n;let o=n,s=[{tile:this.root,weight:this.estimateScreenRadius(this.root,e.viewport)}];for(;s.length>0;){s.sort((u,f)=>f.weight-u.weight);let a=s.shift();if(!a)break;let{tile:c,weight:l}=a;if(!this.isVisible(c,e))continue;if(i.add(c.id),!r.has(c.id)&&c.pointCount>0){if(o>0&&o+c.pointCount>this.options.pointBudget)break;r.set(c.id,c),o+=c.pointCount}if(r.has(c.id)&&c.setSelected(e.viewport.id),!this.shouldRefine(c,l))continue;let h=await this.getVisibleChildren(c,e);h.length>0&&s.push(...h)}return o}shouldRefine(e,r){if(e.level<this.options.maxDepth&&Number.isFinite(r)&&(e.header.lodSelectionMetricType||this.options.lodSelectionMetricType)==="density-threshold"){let n=Math.max(1,Math.PI*r*r),i=e.pointCount/n,o=e.header.lodThreshold||this.options.densityThreshold;return i<o}return e.level<this.options.maxDepth&&Number.isFinite(r)&&r>=this.options.minimumNodePixelSize}getTraversalContext(e){let r=this.getCullingVolume(e);return{viewport:e,cullingVolume:this.shouldUseCullingVolume(e,r)?r:null}}isVisible(e,r){if(r.cullingVolume){let i=this.getCommonSpaceBoundingSphere(e.boundingVolume,r.viewport);if(i)return this.isBoundingSphereInsideCullingVolume(i,r.cullingVolume)}let n=this.getProjectedFootprint(e.boundingVolume,r.viewport);return n?this.isProjectedFootprintVisible(n,r.viewport):!1}shouldUseCullingVolume(e,r){if(!this.root||!r)return!1;let n=this.getCommonSpaceBoundingSphere(this.root.boundingVolume,e);if(!n)return!1;if(this.isBoundingSphereInsideCullingVolume(n,r))return!0;let i=this.getProjectedFootprint(this.root.boundingVolume,e);return!i||!this.isProjectedFootprintVisible(i,e)}isBoundingSphereInsideCullingVolume(e,r){return r.computeVisibilityWithPlaneMask(e,se.MASK_INDETERMINATE)!==se.MASK_OUTSIDE}isProjectedFootprintVisible(e,r){return!(e.x+e.radius<-Bi||e.x-e.radius>r.width+Bi||e.y+e.radius<-Bi||e.y-e.radius>r.height+Bi)}estimateScreenRadius(e,r){let n=this.getProjectedFootprint(e.boundingVolume,r);return n?n.radius:0}projectBounds(e,r){let n=this.getBoundingVolumeCorners(e),i=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;try{for(let c of n){let[l,h]=r.project(c);!Number.isFinite(l)||!Number.isFinite(h)||(i=Math.min(i,l),o=Math.min(o,h),s=Math.max(s,l),a=Math.max(a,h))}}catch{return null}return!Number.isFinite(i)||!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)?null:{minX:i,minY:o,maxX:s,maxY:a}}getProjectedFootprint(e,r){let n=Number.NaN,i=Number.NaN;try{[n,i]=r.project(e.center)}catch{return null}if(!Number.isFinite(n)||!Number.isFinite(i))return null;let o=this.getBoundingVolumeCorners(e),s=0;try{for(let a of o){let[c,l]=r.project(a);!Number.isFinite(c)||!Number.isFinite(l)||(s=Math.max(s,Math.hypot(c-n,l-i)))}}catch{return null}if(s===0){let a=this.projectBounds(e,r);a&&(s=Math.max(a.maxX-a.minX,a.maxY-a.minY)/2)}return{x:n,y:i,radius:s}}async getVisibleChildren(e,r){return e.level>=this.options.maxDepth?[]:(await this.getChildren(e)).map(i=>({tile:i,weight:this.estimateScreenRadius(i,r.viewport)})).filter(i=>this.isVisible(i.tile,r))}async getChildren(e){if(e.childrenLoaded)return e.children;if(!e.childrenPromise){let r=this.dataSource.getChildren(e.header).then(n=>n.map(i=>this.getOrCreateTile(i,e))).then(n=>(e.children=n,e.childrenLoaded=!0,n));e.childrenPromise=r.finally(()=>{e.childrenPromise===r&&(e.childrenPromise=null)})}return e.childrenPromise}getOrCreateTile(e,r){let n=this.tilesMap.get(e.id);if(n)return n.header=e,r&&n.parent!==r&&(n.parent=r),n;let i=new rr(e,r);return this.tilesMap.set(e.id,i),r&&!r.children.find(o=>o.id===i.id)&&r.children.push(i),i}async loadTile(e){if(!(e.contentAvailable||e.isContentLoading||e.contentFailed)){e.isContentLoading=!0,this.pendingCount++;try{let r=await this.dataSource.loadTileContent(e.header);e.content=r,e.contentAvailable=!0,r&&this.options.onTileLoad(e)}catch(r){e.contentFailed=!0,this.options.onTileError(e,r)}finally{e.isContentLoading=!1,this.pendingCount--}}}estimateZoom(e){if(!e||e.coordinateFrame==="cartesian")return 1;let[r,n]=e.cartographicBounds,i=e.coversFullLongitude?360:e.wrapsDateline?360-Math.abs(n[0]-r[0]):Math.abs(n[0]-r[0]),o=Math.max(i,1e-6);return Math.max(1,Math.round(Math.log2(360/o)))}haveSameIds(e,r){if(e.size!==r.size)return!1;for(let n of e)if(!r.has(n))return!1;return!0}getBoundingVolumeCorners(e){let[r,n]=e.cartographicBounds,i=e.coversFullLongitude?[[-180,180]]:e.wrapsDateline?[[r[0],180],[-180,n[0]]]:[[r[0],n[0]]],o=[],s=360-Math.abs(n[0]-r[0]),a=r[0]+s/2;for(let[c,l]of i){let h=d=>{if(!e.wrapsDateline)return d;let m=d;for(;m-a>180;)m-=360;for(;m-a<-180;)m+=360;return m},u=h(c),f=h(l);o.push([u,r[1],r[2]||0],[u,r[1],n[2]||0],[u,n[1],r[2]||0],[u,n[1],n[2]||0],[f,r[1],r[2]||0],[f,r[1],n[2]||0],[f,n[1],r[2]||0],[f,n[1],n[2]||0])}return o}getCullingVolume(e){let r=e.getFrustumPlanes?.bind(e);if(!r)return null;let n=r(),i=["left","right","bottom","top","near","far"],o=[];for(let s of i){let a=n[s];if(!a)return null;o.push(new re(a.normal,-a.distance))}return new se(o)}getCommonSpaceBoundingSphere(e,r){let n=r.projectPosition?.bind(r);if(!n)return null;let i=this.getBoundingVolumeCorners(e),o=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,c=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;try{for(let u of i){let[f,d,m=0]=n(u);!Number.isFinite(f)||!Number.isFinite(d)||!Number.isFinite(m)||(o=Math.min(o,f),s=Math.min(s,d),a=Math.min(a,m),c=Math.max(c,f),l=Math.max(l,d),h=Math.max(h,m))}}catch{return null}return!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(c)||!Number.isFinite(l)||!Number.isFinite(h)?null:new fe().fromCornerPoints([o,s,a],[c,l,h])}};return qf(tn);})();
11
10
  return __exports__;
12
11
  });