/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/bmap-geo-three@0.0.23/build/geo-three.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Geo={},t.THREE)}(this,(function(t,e){"use strict";class i{constructor(){this.name="",this.minZoom=0,this.maxZoom=20,this.bounds=[],this.center=[]}fetchTile(t,e,i){return null}getMetaData(){}}class s extends i{constructor(t="https://a.tile.openstreetmap.org/"){super(),this.address=t,this.format="png"}fetchTile(t,e,i){return new Promise(((s,r)=>{const o=document.createElement("img");o.onload=function(){s(o)},o.onerror=function(){r()},o.crossOrigin="Anonymous",o.src=this.address+t+"/"+e+"/"+i+"."+this.format}))}}class r extends e.BufferGeometry{constructor(t=1,i=1,s=1,o=1,a=!1,n=10){super();const h=[],l=[],d=[],c=[];r.buildPlane(t,i,s,o,h,l,d,c),a&&r.buildSkirt(t,i,s,o,n,h,l,d,c),this.setIndex(h),this.setAttribute("position",new e.Float32BufferAttribute(l,3)),this.setAttribute("normal",new e.Float32BufferAttribute(d,3)),this.setAttribute("uv",new e.Float32BufferAttribute(c,2))}static buildPlane(t=1,e=1,i=1,s=1,r,o,a,n){const h=t/2,l=e/2,d=i+1,c=s+1,u=t/i,p=e/s;for(let t=0;t<c;t++){const e=t*p-l;for(let r=0;r<d;r++){const l=r*u-h;o.push(l,0,e),a.push(0,1,0),n.push(r/i,1-t/s)}}for(let t=0;t<s;t++)for(let e=0;e<i;e++){const i=e+d*t,s=e+d*(t+1),o=e+1+d*(t+1),a=e+1+d*t;r.push(i,s,a,s,o,a)}}static buildSkirt(t=1,e=1,i=1,s=1,r,o,a,n,h){const l=t/2,d=e/2,c=i+1,u=s+1,p=t/i,m=e/s;let f=a.length/3;for(let t=0;t<c;t++){const e=t*p-l,s=-d;a.push(e,-r,s),n.push(0,1,0),h.push(t/i,1)}for(let t=0;t<i;t++){const e=t,i=t+1,s=t+f,r=t+f+1;o.push(i,s,e,i,r,s)}f=a.length/3;for(let t=0;t<c;t++){const e=t*p-l,o=s*m-d;a.push(e,-r,o),n.push(0,1,0),h.push(t/i,0)}let g=c*u-i-1;for(let t=0;t<i;t++){const e=g+t,i=g+t+1,s=t+f,r=t+f+1;o.push(e,s,i,s,r,i)}f=a.length/3;for(let t=0;t<u;t++){const e=t*m-d,i=-l;a.push(i,-r,e),n.push(0,1,0),h.push(0,1-t/s)}for(let t=0;t<s;t++){const e=t*u,i=(t+1)*u,s=t+f,r=t+f+1;o.push(e,s,i,s,r,i)}f=a.length/3;for(let t=0;t<u;t++){const e=t*m-d,o=i*p-l;a.push(o,-r,e),n.push(0,1,0),h.push(1,1-t/s)}for(let t=0;t<s;t++){const e=t*u+s,i=(t+1)*u+s,r=t+f,a=t+f+1;o.push(i,r,e,i,a,r)}}}class o{static createOffscreenCanvas(t,e){if(OffscreenCanvas)return new OffscreenCanvas(t,e);{let i=document.createElement("canvas");return i.width=t,i.height=e,i}}}class a extends e.Mesh{constructor(t=null,e=null,i=a.root,s=0,r=0,o=0,n=null,h=null){super(n,h),this.mapView=null,this.parentNode=null,this.nodesLoaded=0,this.subdivided=!1,this.childrenCache=null,this.cacheChild=!1,this.isMesh=!0,this.mapView=e,this.parentNode=t,this.location=i,this.level=s,this.x=r,this.y=o,e.overrideMaterial&&(this.material=e.overrideMaterial,this.textureLoaded=!0),this.initialize()}initialize(){this.mapView.onNodeCreated&&this.mapView.onNodeCreated(this)}createChildNodes(){}subdivide(){const t=Math.min(this.mapView.provider.maxZoom,this.mapView.heightProvider.maxZoom);this.children.length>0||this.level+1>t||null!==this.parentNode&&this.parentNode.nodesLoaded<a.childrens||(this.subdivided=!0,this.cacheChild&&null!==this.childrenCache?(this.isMesh=!1,this.children=this.childrenCache):this.createChildNodes(),this.mapView.onNodeSubdivided&&this.mapView.onNodeSubdivided())}simplify(){this.cacheChild&&this.children.length>0&&(this.childrenCache=this.children),this.subdivided=!1,this.isMesh=!0,this.children=[]}loadTexture(){this.mapView.provider.fetchTile(this.level,this.x,this.y).then((t=>{const i=new e.Texture(t);i.generateMipmaps=!1,i.format=e.RGBAFormat,i.magFilter=e.LinearFilter,i.minFilter=e.LinearFilter,i.needsUpdate=!0,this.material.map=i,this.nodeReady()})).catch((()=>{const t=o.createOffscreenCanvas(1,1),i=t.getContext("2d");i.fillStyle="#FF0000",i.fillRect(0,0,1,1);const s=new e.Texture(t);s.generateMipmaps=!1,s.needsUpdate=!0,this.material.map=s,this.nodeReady()}))}nodeReady(){if(null!==this.parentNode){if(this.parentNode.nodesLoaded++,this.parentNode.nodesLoaded>=a.childrens){!0===this.parentNode.subdivided&&(this.parentNode.isMesh=!1);for(let t=0;t<this.parentNode.children.length;t++)this.parentNode.children[t].visible=!0}}else this.visible=!0;this.mapView.onNodeReady&&this.mapView.onNodeReady()}getNeighborsDirection(t){return null}getNeighbors(){return[]}}a.baseGeometry=null,a.baseScale=null,a.childrens=4,a.root=-1,a.topLeft=0,a.topRight=1,a.bottomLeft=2,a.bottomRight=3;class n{static get(t,e){navigator.geolocation.getCurrentPosition((function(e){t(e.coords,e.timestamp)}),e)}static datumsToSpherical(t,i){const s=i*n.EARTH_ORIGIN/180;let r=Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180);return r=r*n.EARTH_ORIGIN/180,new e.Vector2(s,r)}static sphericalToDatums(t,e){const i=t/n.EARTH_ORIGIN*180;let s=e/n.EARTH_ORIGIN*180;return s=180/Math.PI*(2*Math.atan(Math.exp(s*Math.PI/180))-Math.PI/2),{latitude:s,longitude:i}}static quadtreeToDatums(t,e,i){const s=Math.pow(2,t),r=e/s*360-180;return{latitude:Math.atan(Math.sinh(Math.PI*(1-2*i/s)))/Math.PI*180,longitude:r}}}n.EARTH_RADIUS=6378137,n.EARTH_PERIMETER=2*Math.PI*n.EARTH_RADIUS,n.EARTH_ORIGIN=n.EARTH_PERIMETER/2;class h extends a{constructor(t=null,i=null,s=a.root,r=0,o=0,n=0){super(t,i,s,r,o,n,h.geometry,new e.MeshBasicMaterial({wireframe:!1})),this.matrixAutoUpdate=!1,this.isMesh=!0,this.visible=!1}initialize(){super.initialize(),this.loadTexture()}createChildNodes(){const t=this.level+1,e=2*this.x,i=2*this.y,s=Object.getPrototypeOf(this).constructor;let r=new s(this,this.mapView,a.topLeft,t,e,i);r.scale.set(.5,1,.5),r.position.set(-.25,0,-.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new s(this,this.mapView,a.topRight,t,e+1,i),r.scale.set(.5,1,.5),r.position.set(.25,0,-.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new s(this,this.mapView,a.bottomLeft,t,e,i+1),r.scale.set(.5,1,.5),r.position.set(-.25,0,.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new s(this,this.mapView,a.bottomRight,t,e+1,i+1),r.scale.set(.5,1,.5),r.position.set(.25,0,.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0)}raycast(t,e){return!0===this.isMesh&&super.raycast(t,e)}}h.geometry=new r(1,1,1,1,!1),h.baseGeometry=h.geometry,h.baseScale=new e.Vector3(n.EARTH_PERIMETER,1,n.EARTH_PERIMETER);class l extends e.BufferGeometry{constructor(t=1,i=1,s=1,o=1,a=!1,n=10,h=null,l=!0){super();const d=[],c=[],u=[],p=[];r.buildPlane(t,i,s,o,d,c,u,p);const m=h.data;for(let t=0,e=0;t<m.length&&e<c.length;t+=4,e+=3){const i=m[t],s=m[t+1],r=m[t+2];if(0===i&&0===s&&0===r)c[e+1]=0;else{const t=.1*(65536*i+256*s+r)-1e4;c[e+1]=t}}a&&r.buildSkirt(t,i,s,o,n,d,c,u,p),this.setIndex(d),this.setAttribute("position",new e.Float32BufferAttribute(c,3)),this.setAttribute("normal",new e.Float32BufferAttribute(u,3)),this.setAttribute("uv",new e.Float32BufferAttribute(p,2)),l&&this.computeNormals(s,o)}computeNormals(t,i){const s=this.getAttribute("position");if(void 0!==s){let r=this.getAttribute("normal");const o=i*t;for(let t=0;t<o;t++)r.setXYZ(t,0,0,0);const a=new e.Vector3,n=new e.Vector3,h=new e.Vector3,l=new e.Vector3,d=new e.Vector3,c=new e.Vector3,u=new e.Vector3,p=new e.Vector3,m=i*t*6;for(let t=0;t<m;t+=3){const e=this.index.getX(t+0),i=this.index.getX(t+1),o=this.index.getX(t+2);a.fromBufferAttribute(s,e),n.fromBufferAttribute(s,i),h.fromBufferAttribute(s,o),u.subVectors(h,n),p.subVectors(a,n),u.cross(p),l.fromBufferAttribute(r,e),d.fromBufferAttribute(r,i),c.fromBufferAttribute(r,o),l.add(u),d.add(u),c.add(u),r.setXYZ(e,l.x,l.y,l.z),r.setXYZ(i,d.x,d.y,d.z),r.setXYZ(o,c.x,c.y,c.z)}this.normalizeNormals(),r.needsUpdate=!0}}}class d extends a{constructor(t=null,i=null,s=a.root,r=0,o=0,n=0,h=d.geometry,l=new e.MeshStandardMaterial({wireframe:!1,color:16777215})){super(t,i,s,r,o,n,h,l),this.heightLoaded=!1,this.geometrySize=16,this.geometryNormals=!1,l.alphaTest=.1,this.isMesh=!0,this.visible=!1,this.matrixAutoUpdate=!1}initialize(){super.initialize(),this.textureLoaded?setTimeout((()=>{this.textureLoaded=!0}),0):this.loadTexture(),this.loadHeightGeometry()}loadTexture(){this.mapView.provider.fetchTile(this.level,this.x,this.y).then((t=>{const i=new e.Texture(t);i.generateMipmaps=!1,i.format=e.RGBAFormat,i.magFilter=e.LinearFilter,i.minFilter=e.LinearFilter,i.needsUpdate=!0,this.material.map=i})).catch((()=>{console.log("texture error")})).finally((()=>{this.textureLoaded=!0,this.nodeReady()}))}nodeReady(){this.heightLoaded&&this.textureLoaded&&(this.visible=!0,super.nodeReady())}createChildNodes(){const t=this.level+1,e=Object.getPrototypeOf(this).constructor,i=2*this.x,s=2*this.y;let r=new e(this,this.mapView,a.topLeft,t,i,s);r.scale.set(.5,1,.5),r.position.set(-.25,0,-.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new e(this,this.mapView,a.topRight,t,i+1,s),r.scale.set(.5,1,.5),r.position.set(.25,0,-.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new e(this,this.mapView,a.bottomLeft,t,i,s+1),r.scale.set(.5,1,.5),r.position.set(-.25,0,.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new e(this,this.mapView,a.bottomRight,t,i+1,s+1),r.scale.set(.5,1,.5),r.position.set(.25,0,.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0)}loadHeightGeometry(){if(null===this.mapView.heightProvider)throw new Error("GeoThree: MapView.heightProvider provider is null.");return this.mapView.heightProvider.fetchTile(this.level,this.x,this.y).then((t=>{const e=o.createOffscreenCanvas(this.geometrySize+1,this.geometrySize+1),i=e.getContext("2d");i.imageSmoothingEnabled=!1,i.drawImage(t,0,0,d.tileSize,d.tileSize,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=new l(1,1,this.geometrySize,this.geometrySize,!0,10,s,!0);this.geometry=r})).catch((()=>{})).finally((()=>{this.heightLoaded=!0,this.nodeReady()}))}raycast(t,e){return!0===this.isMesh&&super.raycast(t,e)}}d.tileSize=256,d.geometry=new r(1,1,1,1),d.baseGeometry=h.geometry,d.baseScale=new e.Vector3(n.EARTH_PERIMETER,1,n.EARTH_PERIMETER);class c extends e.BufferGeometry{constructor(t,i,s,r,o,a,n){super();const h=a+n;let l=0;const d=[],c=new e.Vector3,u=new e.Vector3,p=[],m=[],f=[],g=[];for(let e=0;e<=s;e++){const h=[],p=e/s;for(let e=0;e<=i;e++){const s=e/i;c.x=-t*Math.cos(r+s*o)*Math.sin(a+p*n),c.y=t*Math.cos(a+p*n),c.z=t*Math.sin(r+s*o)*Math.sin(a+p*n),m.push(c.x,c.y,c.z),u.set(c.x,c.y,c.z).normalize(),f.push(u.x,u.y,u.z),g.push(s,1-p),h.push(l++)}d.push(h)}for(let t=0;t<s;t++)for(let e=0;e<i;e++){const i=d[t][e+1],r=d[t][e],o=d[t+1][e],n=d[t+1][e+1];(0!==t||a>0)&&p.push(i,r,n),(t!==s-1||h<Math.PI)&&p.push(r,o,n)}this.setIndex(p),this.setAttribute("position",new e.Float32BufferAttribute(m,3)),this.setAttribute("normal",new e.Float32BufferAttribute(f,3)),this.setAttribute("uv",new e.Float32BufferAttribute(g,2))}}class u extends a{constructor(t=null,i=null,s=a.root,r=0,o=0,n=0){super(t,i,s,r,o,n,u.createGeometry(r,o,n),new e.MeshBasicMaterial({wireframe:!1})),this.applyScaleNode(),this.matrixAutoUpdate=!1,this.isMesh=!0,this.visible=!1}initialize(){super.initialize(),this.loadTexture()}static createGeometry(t,e,i){const s=Math.pow(2,t),r=Math.floor(u.segments*(40/(t+1))/40),o=1/s*2*Math.PI,a=e*o,n=1/s*Math.PI;return new c(1,r,r,a,o,i*n,n)}applyScaleNode(){this.geometry.computeBoundingBox();const t=this.geometry.boundingBox.clone().getCenter(new e.Vector3),i=new e.Matrix4;i.compose(new e.Vector3(-t.x,-t.y,-t.z),new e.Quaternion,new e.Vector3(n.EARTH_RADIUS,n.EARTH_RADIUS,n.EARTH_RADIUS)),this.geometry.applyMatrix4(i),this.position.copy(t),this.updateMatrix(),this.updateMatrixWorld()}updateMatrix(){this.matrix.setPosition(this.position),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t=!1){(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1)}createChildNodes(){const t=this.level+1,e=2*this.x,i=2*this.y,s=Object.getPrototypeOf(this).constructor;let r=new s(this,this.mapView,a.topLeft,t,e,i);this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new s(this,this.mapView,a.topRight,t,e+1,i),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new s(this,this.mapView,a.bottomLeft,t,e,i+1),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new s(this,this.mapView,a.bottomRight,t,e+1,i+1),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0)}raycast(t,e){return!0===this.isMesh&&super.raycast(t,e)}}u.baseGeometry=new c(n.EARTH_RADIUS,64,64,0,2*Math.PI,0,Math.PI),u.baseScale=new e.Vector3(1,1,1),u.segments=80;class p extends d{constructor(t=null,i=null,s=a.root,r=0,o=0,n=0){const h=p.prepareMaterial(new e.MeshPhongMaterial({map:p.emptyTexture,color:16777215}));super(t,i,s,r,o,n,p.geometry,h),this.frustumCulled=!1}static prepareMaterial(t){return t.userData={heightMap:{value:p.emptyTexture}},t.onBeforeCompile=e=>{for(const i in t.userData)e.uniforms[i]=t.userData[i];e.vertexShader="\n\t\t\tuniform sampler2D heightMap;\n\t\t\t"+e.vertexShader,e.vertexShader=e.vertexShader.replace("#include <fog_vertex>","\n\t\t\t#include <fog_vertex>\n\t\n\t\t\t// Calculate height of the title\n\t\t\tvec4 _theight = texture2D(heightMap, vUv);\n\t\t\tfloat _height = ((_theight.r * 255.0 * 65536.0 + _theight.g * 255.0 * 256.0 + _theight.b * 255.0) * 0.1) - 10000.0;\n\t\t\tvec3 _transformed = position + _height * normal;\n\t\n\t\t\t// Vertex position based on height\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4(_transformed, 1.0);\n\t\t\t")},t}loadTexture(){this.mapView.provider.fetchTile(this.level,this.x,this.y).then((t=>{const i=new e.Texture(t);i.generateMipmaps=!1,i.format=e.RGBAFormat,i.magFilter=e.LinearFilter,i.minFilter=e.LinearFilter,i.needsUpdate=!0,this.material.map=i,this.textureLoaded=!0,this.nodeReady()})).catch((t=>{console.error("GeoThree: Failed to load color node data.",t)})).finally((()=>{this.textureLoaded=!0,this.nodeReady()})),this.loadHeightGeometry()}loadHeightGeometry(){if(null===this.mapView.heightProvider)throw new Error("GeoThree: MapView.heightProvider provider is null.");return this.mapView.heightProvider.fetchTile(this.level,this.x,this.y).then((t=>{const i=new e.Texture(t);i.generateMipmaps=!1,i.format=e.RGBAFormat,i.magFilter=e.NearestFilter,i.minFilter=e.NearestFilter,i.needsUpdate=!0,this.material.userData.heightMap.value=i})).catch((t=>{console.error("GeoThree: Failed to load height node data.",t)})).finally((()=>{this.heightLoaded=!0,this.nodeReady()}))}raycast(t,e){if(!0===this.isMesh){this.geometry=h.geometry;const i=super.raycast(t,e);return this.geometry=p.geometry,i}return!1}}p.emptyTexture=new e.Texture,p.geometrySize=256,p.geometry=new r(1,1,p.geometrySize,p.geometrySize,!0),p.baseGeometry=h.geometry,p.baseScale=new e.Vector3(n.EARTH_PERIMETER,1,n.EARTH_PERIMETER);const m=new e.Vector3,f=new e.Vector3;class g{constructor(){this.subdivideDistance=50,this.simplifyDistance=300}updateLOD(t,e,i,s){e.getWorldPosition(m),t.children[0].traverse((e=>{e.getWorldPosition(f);let i=m.distanceTo(f);i/=Math.pow(2,t.provider.maxZoom-e.level),i<this.subdivideDistance?e.subdivide():i>this.simplifyDistance&&e.parentNode&&e.parentNode.simplify()}))}}const v=new e.Matrix4,y=new e.Vector3,w=new e.Frustum,x=new e.Vector3;class M extends g{constructor(){super(...arguments),this.subdivideDistance=120,this.simplifyDistance=400,this.testCenter=!0,this.pointOnly=!1,this.lodOffset=0}updateLOD(t,e,i,s){v.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),w.setFromProjectionMatrix(v),e.getWorldPosition(y),t.children[0].traverse((e=>{e.getWorldPosition(x);let i=y.distanceTo(x);i/=Math.pow(2,t.provider.maxZoom-e.level+this.lodOffset);const s=this.pointOnly?w.containsPoint(x):w.intersectsObject(e);i<this.subdivideDistance&&s?e.subdivide():i>this.simplifyDistance&&e.parentNode&&e.parentNode.simplify()}))}}
/*! *****************************************************************************
	Copyright (c) Microsoft Corporation.

	Permission to use, copy, modify, and/or distribute this software for any
	purpose with or without fee is hereby granted.

	THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
	REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
	INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
	LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
	OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
	PERFORMANCE OF THIS SOFTWARE.
	***************************************************************************** */function T(t,e,i,s){return new(i||(i=Promise))((function(r,o){function a(t){try{h(s.next(t))}catch(t){o(t)}}function n(t){try{h(s.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?r(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,n)}h((s=s.apply(t,e||[])).next())}))}class b{constructor(t=257){this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let t=0;t<this.numTriangles;t++){let i=t+2,s=0,r=0,o=0,a=0,n=0,h=0;for(1&i?o=a=n=e:s=r=h=e;(i>>=1)>1;){const t=s+o>>1,e=r+a>>1;1&i?(o=s,a=r,s=n,r=h):(s=o,r=a,o=n,a=h),n=t,h=e}const l=4*t;this.coords[l+0]=s,this.coords[l+1]=r,this.coords[l+2]=o,this.coords[l+3]=a}}createTile(t){return new R(t,this)}}class R{constructor(t,e){const i=e.gridSize;if(t.length!==i*i)throw new Error(`Expected terrain data of length ${i*i} (${i} x ${i}), got ${t.length}.`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:i,gridSize:s}=this.martini,{terrain:r,errors:o}=this;for(let a=t-1;a>=0;a--){const t=4*a,n=i[t+0],h=i[t+1],l=i[t+2],d=i[t+3],c=n+l>>1,u=h+d>>1,p=c+u-h,m=u+n-c,f=(r[h*s+n]+r[d*s+l])/2,g=u*s+c,v=Math.abs(f-r[g]);if(o[g]=Math.max(o[g],v),a<e){const t=(h+m>>1)*s+(n+p>>1),e=(d+m>>1)*s+(l+p>>1);o[g]=Math.max(o[g],o[t],o[e])}}}getMesh(t=0,e=!1){const{gridSize:i,indices:s}=this.martini,{errors:r}=this;let o=0,a=0;const n=i-1;let h,l,d=0;const c=[],u=[],p=[],m=[];function f(g,v,y,w,x,M){const T=g+y>>1,b=v+w>>1;Math.abs(g-x)+Math.abs(v-M)>1&&r[b*i+T]>t?(f(x,M,g,v,T,b),f(y,w,x,M,T,b)):(h=v*i+g,l=w*i+y,d=M*i+x,0===s[h]&&(e&&(0===g?c.push(o):g===n&&u.push(o),0===v?p.push(o):v===n&&m.push(o)),s[h]=++o),0===s[l]&&(e&&(0===y?c.push(o):y===n&&u.push(o),0===w?p.push(o):w===n&&m.push(o)),s[l]=++o),0===s[d]&&(e&&(0===x?c.push(o):x===n&&u.push(o),0===M?p.push(o):M===n&&m.push(o)),s[d]=++o),a++)}s.fill(0),f(0,0,n,n,n,0),f(n,n,0,0,0,n);let g=2*o,v=3*a;e&&(g+=2*(c.length+u.length+p.length+m.length),v+=3*(2*(c.length-1)+2*(u.length-1)+2*(p.length-1)+2*(m.length-1)));const y=new Uint16Array(g),w=new Uint32Array(v);let x=0;function M(e,o,a,n,h,l){const d=e+a>>1,c=o+n>>1;if(Math.abs(e-h)+Math.abs(o-l)>1&&r[c*i+d]>t)M(h,l,e,o,d,c),M(a,n,h,l,d,c);else{const t=s[o*i+e]-1,r=s[n*i+a]-1,d=s[l*i+h]-1;y[2*t]=e,y[2*t+1]=o,y[2*r]=a,y[2*r+1]=n,y[2*d]=h,y[2*d+1]=l,w[x++]=t,w[x++]=r,w[x++]=d}}if(M(0,0,n,n,n,0),M(n,n,0,0,0,n),e){c.sort(((t,e)=>y[2*t+1]-y[2*e+1])),u.sort(((t,e)=>y[2*e+1]-y[2*t+1])),p.sort(((t,e)=>y[2*e]-y[2*t])),m.sort(((t,e)=>y[2*t]-y[2*e]));let T=2*o;function b(t){const e=t.length;for(let i=0;i<e-1;i++){const e=t[i],s=t[i+1],r=T/2,o=(T+2)/2;y[T++]=y[2*e],y[T++]=y[2*e+1],w[x++]=e,w[x++]=r,w[x++]=s,w[x++]=r,w[x++]=o,w[x++]=s}y[T++]=y[2*t[e-1]],y[T++]=y[2*t[e-1]+1]}b(c),b(u),b(p),b(m)}return{vertices:y,triangles:w,numVerticesWithoutSkirts:o}}}class E extends d{constructor(t=null,i=null,s=a.root,r=0,o=0,n=0,{elevationDecoder:h=null,meshMaxError:l=10,exageration:d=1}={}){super(t,i,s,r,o,n,E.geometry,E.prepareMaterial(new e.MeshPhongMaterial({map:E.emptyTexture,color:16777215,side:e.DoubleSide}),r,d)),this.elevationDecoder={rScaler:256,gScaler:1,bScaler:1/256,offset:-32768},this.exageration=1,this.meshMaxError=10,h&&(this.elevationDecoder=h),this.meshMaxError=l,this.exageration=d,this.frustumCulled=!1}static prepareMaterial(t,e,i=1){return t.userData={heightMap:{value:E.emptyTexture},drawNormals:{value:0},drawBlack:{value:0},zoomlevel:{value:e},computeNormals:{value:1},drawTexture:{value:1}},t.onBeforeCompile=e=>{for(let i in t.userData)e.uniforms[i]=t.userData[i];e.vertexShader="\n\t\t\t\tuniform bool computeNormals;\n\t\t\t\tuniform float zoomlevel;\n\t\t\t\tuniform sampler2D heightMap;\n\t\t\t\t"+e.vertexShader,e.fragmentShader="\n\t\t\t\tuniform bool drawNormals;\n\t\t\t\tuniform bool drawTexture;\n\t\t\t\tuniform bool drawBlack;\n\t\t\t\t"+e.fragmentShader,e.fragmentShader=e.fragmentShader.replace("#include <dithering_fragment>","\n\t\t\t\tif(drawBlack) {\n\t\t\t\t\tgl_FragColor = vec4( 0.0,0.0,0.0, 1.0 );\n\t\t\t\t} else if(drawNormals) {\n\t\t\t\t\tgl_FragColor = vec4( ( 0.5 * vNormal + 0.5 ), 1.0 );\n\t\t\t\t} else if (!drawTexture) {\n\t\t\t\t\tgl_FragColor = vec4( 0.0,0.0,0.0, 0.0 );\n\t\t\t\t}"),e.vertexShader=e.vertexShader.replace("#include <fog_vertex>","\n\t\t\t\t#include <fog_vertex>\n\n\t\t\t\t// queried pixels:\n\t\t\t\t// +-----------+\n\t\t\t\t// |   |   |   |\n\t\t\t\t// | a | b | c |\n\t\t\t\t// |   |   |   |\n\t\t\t\t// +-----------+\n\t\t\t\t// |   |   |   |\n\t\t\t\t// | d | e | f |\n\t\t\t\t// |   |   |   |\n\t\t\t\t// +-----------+\n\t\t\t\t// |   |   |   |\n\t\t\t\t// | g | h | i |\n\t\t\t\t// |   |   |   |\n\t\t\t\t// +-----------+\n\n\t\t\t\tif (computeNormals) {\n\t\t\t\t\tfloat e = getElevation(vUv, 0.0);\n\t\t\t\t\tivec2 size = textureSize(heightMap, 0);\n\t\t\t\t\tfloat offset = 1.0 / float(size.x);\n\t\t\t\t\tfloat a = getElevation(vUv + vec2(-offset, -offset), 0.0);\n\t\t\t\t\tfloat b = getElevation(vUv + vec2(0, -offset), 0.0);\n\t\t\t\t\tfloat c = getElevation(vUv + vec2(offset, -offset), 0.0);\n\t\t\t\t\tfloat d = getElevation(vUv + vec2(-offset, 0), 0.0);\n\t\t\t\t\tfloat f = getElevation(vUv + vec2(offset, 0), 0.0);\n\t\t\t\t\tfloat g = getElevation(vUv + vec2(-offset, offset), 0.0);\n\t\t\t\t\tfloat h = getElevation(vUv + vec2(0, offset), 0.0);\n\t\t\t\t\tfloat i = getElevation(vUv + vec2(offset,offset), 0.0);\n\n\n\t\t\t\t\tfloat normalLength = 500.0 / zoomlevel;\n\n\t\t\t\t\tvec3 v0 = vec3(0.0, 0.0, 0.0);\n\t\t\t\t\tvec3 v1 = vec3(0.0, normalLength, 0.0);\n\t\t\t\t\tvec3 v2 = vec3(normalLength, 0.0, 0.0);\n\t\t\t\t\tv0.z = (e + d + g + h) / 4.0;\n\t\t\t\t\tv1.z = (e+ b + a + d) / 4.0;\n\t\t\t\t\tv2.z = (e+ h + i + f) / 4.0;\n\t\t\t\t\tvNormal = (normalize(cross(v2 - v0, v1 - v0))).rbg;\n\t\t\t\t}\n\t\t\t\t")},t}static getTerrain(t,e,i){const{rScaler:s,bScaler:r,gScaler:o,offset:a}=i,n=e+1,h=new Float32Array(n*n);for(let i=0,n=0;n<e;n++)for(let l=0;l<e;l++,i++){const e=4*i,l=t[e+0],d=t[e+1],c=t[e+2];h[i+n]=l*s+d*o+c*r+a}for(let t=n*(n-1),e=0;e<n-1;e++,t++)h[t]=h[t-n];for(let t=n-1,e=0;e<n;e++,t+=n)h[t]=h[t-1];return h}static getMeshAttributes(t,e,i,s,r){const o=i+1,a=t.length/2,n=new Float32Array(3*a),h=new Float32Array(2*a),[l,d,c,u]=s||[0,0,i,i],p=(c-l)/i,m=(u-d)/i;for(let s=0;s<a;s++){const a=t[2*s],d=t[2*s+1],c=d*o+a;n[3*s+0]=a*p+l,n[3*s+1]=-e[c]*r,n[3*s+2]=-d*m+u,h[2*s+0]=a/i,h[2*s+1]=d/i}return{position:{value:n,size:3},uv:{value:h,size:2}}}onHeightImage(t){return T(this,void 0,void 0,(function*(){const i=t.width,s=i+1;var r=o.createOffscreenCanvas(i,i),a=r.getContext("2d");a.imageSmoothingEnabled=!1,a.drawImage(t,0,0,i,i,0,0,r.width,r.height);var n=a.getImageData(0,0,r.width,r.height).data;const h=E.getTerrain(n,i,this.elevationDecoder),l=new b(s).createTile(h),{vertices:d,triangles:c}=l.getMesh("function"==typeof this.meshMaxError?this.meshMaxError(this.level):this.meshMaxError),u=E.getMeshAttributes(d,h,i,[-.5,-.5,.5,.5],this.exageration);this.geometry=new e.BufferGeometry,this.geometry.setIndex(new e.Uint32BufferAttribute(c,1)),this.geometry.setAttribute("position",new e.Float32BufferAttribute(u.position.value,u.position.size)),this.geometry.setAttribute("uv",new e.Float32BufferAttribute(u.uv.value,u.uv.size)),this.geometry.rotateX(Math.PI);var p=new e.Texture(t);p.generateMipmaps=!1,p.format=e.RGBAFormat,p.magFilter=e.NearestFilter,p.minFilter=e.NearestFilter,p.needsUpdate=!0,this.material.userData.heightMap.value=p}))}loadHeightGeometry(){if(null===this.mapView.heightProvider)throw new Error("GeoThree: MapView.heightProvider provider is null.");return this.mapView.heightProvider.fetchTile(this.level,this.x,this.y).then((t=>T(this,void 0,void 0,(function*(){this.onHeightImage(t)})))).finally((()=>{this.heightLoaded=!0,this.nodeReady()}))}}E.geometrySize=16,E.emptyTexture=new e.Texture,E.geometry=new r(1,1,1,1),E.tileSize=256;class A extends a{constructor(t=null,i=null,s=a.root,r=0,o=0,n=0,h=A.geometry,l=new e.MeshStandardMaterial({wireframe:!1,color:16777215})){super(t,i,s,r,o,n,h,l),this.heightLoaded=!1,this.textureLoaded=!1,this.geometrySize=16,this.geometryNormals=!1,this.isMesh=!0,this.visible=!1,this.matrixAutoUpdate=!1}initialize(){super.initialize(),this.loadTexture(),this.loadHeightGeometry()}loadTexture(){this.mapView.provider.fetchTile(this.level,this.x,this.y).then((t=>{const i=new e.Texture(t);i.generateMipmaps=!1,i.format=e.RGBAFormat,i.magFilter=e.LinearFilter,i.minFilter=e.LinearFilter,i.needsUpdate=!0,this.material.map=i})).finally((()=>{this.textureLoaded=!0,this.nodeReady()}))}nodeReady(){this.heightLoaded&&this.textureLoaded&&(this.visible=!0,super.nodeReady())}createChildNodes(){const t=this.level+1,e=Object.getPrototypeOf(this).constructor,i=2*this.x,s=2*this.y;let r=new e(this,this.mapView,a.topLeft,t,i,s);r.scale.set(.5,1,.5),r.position.set(-.25,0,-.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new e(this,this.mapView,a.topRight,t,i+1,s),r.scale.set(.5,1,.5),r.position.set(.25,0,-.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new e(this,this.mapView,a.bottomLeft,t,i,s+1),r.scale.set(.5,1,.5),r.position.set(-.25,0,.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0),r=new e(this,this.mapView,a.bottomRight,t,i+1,s+1),r.scale.set(.5,1,.5),r.position.set(.25,0,.25),this.add(r),r.updateMatrix(),r.updateMatrixWorld(!0)}loadHeightGeometry(){if(null===this.mapView.heightProvider)throw new Error("GeoThree: MapView.heightProvider provider is null.");return this.mapView.heightProvider.fetchTile(this.level,this.x,this.y).then((t=>{const e=new l(1,1,this.geometrySize,this.geometrySize,!0,10,imageData,!0);this.geometry=e})).catch((()=>{console.error("GeoThree: Failed to load height node data.",this)})).finally((()=>{this.heightLoaded=!0,this.nodeReady()}))}raycast(t,e){return!0===this.isMesh&&super.raycast(t,e)}}A.tileSize=256,A.geometry=new r(1,1,1,1),A.baseGeometry=h.geometry,A.baseScale=new e.Vector3(n.EARTH_PERIMETER,1,n.EARTH_PERIMETER);class S extends e.Mesh{constructor(t=S.PLANAR,i=new s,r=null,o=null){super(void 0,new e.MeshBasicMaterial({transparent:!0,opacity:0})),this.lod=null,this.onNodeReady=null,this.provider=null,this.heightProvider=null,this.root=null,this.overrideMaterial=o,this.lod=new M,this.provider=i,this.heightProvider=r,this.setRoot(t)}update(t,e,i){this.lod.updateLOD(this,t,e,i)}setRoot(t){if("number"==typeof t){if(!S.mapModes.has(t))throw new Error("Map mode "+t+" does is not registered.");t=new(S.mapModes.get(t))(null,this)}null!==this.root&&(this.remove(this.root),this.root=null),this.root=t,null!==this.root&&(this.geometry=this.root.constructor.baseGeometry,this.scale.copy(this.root.constructor.baseScale),this.root.mapView=this,this.add(this.root))}setProvider(t){t!==this.provider&&(this.provider=t,this.clear())}setHeightProvider(t){t!==this.heightProvider&&(this.heightProvider=t,this.clear())}clear(){return this.traverse((function(t){t.childrenCache&&(t.childrenCache=null),t.initialize&&t.initialize()})),this}getMetaData(){this.provider.getMetaData()}raycast(t,e){return!1}}S.PLANAR=200,S.SPHERICAL=201,S.HEIGHT=202,S.HEIGHT_SHADER=203,S.MARTINI=204,S.TERRAIN=205,S.mapModes=new Map([[S.PLANAR,h],[S.SPHERICAL,u],[S.HEIGHT,d],[S.HEIGHT_SHADER,p],[S.MARTINI,E],[S.TERRAIN,A]]);class P{static get(t,e,i){const s=new XMLHttpRequest;return s.overrideMimeType("text/plain"),s.open("GET",t,!0),void 0!==e&&(s.onload=function(){e(s.response)}),void 0!==i&&(s.onerror=i),s.send(null),s}static getRaw(t,e,i){var s=new XMLHttpRequest;return s.responseType="arraybuffer",s.open("GET",t,!0),void 0!==e&&(s.onload=function(){e(s.response)}),void 0!==i&&(s.onerror=i),s.send(null),s}static request(t,e,i,s,r,o,a){const n=new XMLHttpRequest;if(n.overrideMimeType("text/plain"),n.open(e,t,!0),null!=i)for(const t in i)n.setRequestHeader(t,i[t]);return void 0!==r&&(n.onload=function(t){r(function(t){try{return JSON.parse(t)}catch(e){return t}}(n.response),n)}),void 0!==o&&(n.onerror=o),void 0!==a&&(n.onprogress=a),void 0!==s?n.send(s):n.send(null),n}}class I extends i{constructor(t="",e=I.AERIAL){super(),this.maxZoom=19,this.format="jpeg",this.mapSize=512,this.subdomain="t1",this.apiKey=t,this.type=e}getMetaData(){const t="http://dev.virtualearth.net/REST/V1/Imagery/Metadata/RoadOnDemand?output=json&include=ImageryProviders&key="+this.apiKey;P.get(t,(function(t){JSON.parse(t)}))}static quadKey(t,e,i){let s="";for(let r=t;r>0;r--){const t=1<<r-1;let o=0;e&t&&o++,i&t&&(o+=2),s+=o}return s}fetchTile(t,e,i){return new Promise(((s,r)=>{const o=document.createElement("img");if(o.onload=function(){s(o)},o.onerror=function(){r()},o.crossOrigin="Anonymous",this.getUrl){const s=this.getUrl(t,e,i);if(!1!==s)return void(o.src=s)}o.src="http://ecn."+this.subdomain+".tiles.virtualearth.net/tiles/"+this.type+I.quadKey(t,e,i)+".jpeg?g=1173"}))}}I.AERIAL="a",I.ROAD="r",I.AERIAL_LABELS="h",I.OBLIQUE="o",I.OBLIQUE_LABELS="b";class N extends i{constructor(t,e,i,s,r,o){super(),this.appId=void 0!==t?t:"",this.appCode=void 0!==e?e:"",this.style=void 0!==i?i:"base",this.scheme=void 0!==s?s:"normal.day",this.format=void 0!==r?r:"png",this.size=void 0!==o?o:512,this.version="newest",this.server=1}nextServer(){this.server=this.server%4==0?1:this.server+1}getMetaData(){}fetchTile(t,e,i){return this.nextServer(),new Promise(((s,r)=>{const o=document.createElement("img");o.onload=function(){s(o)},o.onerror=function(){r()},o.crossOrigin="Anonymous",o.src="https://"+this.server+"."+this.style+".maps.api.here.com/maptile/2.1/maptile/"+this.version+"/"+this.scheme+"/"+t+"/"+e+"/"+i+"/"+this.size+"/"+this.format+"?app_id="+this.appId+"&app_code="+this.appCode}))}}N.PATH="/maptile/2.1/";class D extends i{constructor(t="",e="",i=D.STYLE,s="png",r=!1,o="v4"){super(),this.apiToken=t,this.format=s,this.useHDPI=r,this.mode=i,this.mapId=e,this.style=e,this.version=o}getMetaData(){const t=D.ADDRESS+this.version+"/"+this.mapId+".json?access_token="+this.apiToken;P.get(t,(t=>{const e=JSON.parse(t);this.name=e.name,this.minZoom=e.minZoom,this.maxZoom=e.maxZoom,this.bounds=e.bounds,this.center=e.center}))}fetchTile(t,e,i){return new Promise(((s,r)=>{const o=document.createElement("img");if(o.onload=function(){s(o)},o.onerror=function(){r()},o.crossOrigin="Anonymous",this.getUrl){const s=this.getUrl(t,e,i);if(!1!==s)return void(o.src=s)}this.mode===D.STYLE?o.src=D.ADDRESS+"styles/v1/"+this.style+"/tiles/"+t+"/"+e+"/"+i+(this.useHDPI?"@2x?access_token=":"?access_token=")+this.apiToken:o.src=D.ADDRESS+"v4/"+this.mapId+"/"+t+"/"+e+"/"+i+(this.useHDPI?"@2x.":".")+this.format+"?access_token="+this.apiToken}))}}D.ADDRESS="https://api.mapbox.com/",D.STYLE=100,D.MAP_ID=101;class V{constructor(t){this.fulfilled=!1,this.rejected=!1,this.called=!1;const e=t=>{this.fulfilled=!0,this.value=t,"function"==typeof this.onResolve&&(this.onResolve(this.value),this.called=!0)},i=t=>{this.rejected=!0,this.value=t,"function"==typeof this.onReject&&(this.onReject(this.value),this.called=!0)};try{t(e,i)}catch(t){i(t)}}cancel(){return!1}then(t){return this.onResolve=t,this.fulfilled&&!this.called&&(this.called=!0,this.onResolve(this.value)),this}catch(t){return this.onReject=t,this.rejected&&!this.called&&(this.called=!0,this.onReject(this.value)),this}finally(t){return this}static resolve(t){return new V((function(e,i){e(t)}))}static reject(t){return new V((function(e,i){i(t)}))}static all(t){const e=[],i=[];return new V((function(s,r){t.forEach(((o,a)=>o.then((r=>{if(e.push(!0),i[a]=r,e.length===t.length)return s(i)})).catch((t=>r(t)))))}))}}t.BingMapsProvider=I,t.CancelablePromise=V,t.DebugProvider=class extends i{constructor(){super(...arguments),this.resolution=256}fetchTile(t,i,s){const r=o.createOffscreenCanvas(this.resolution,this.resolution),a=r.getContext("2d"),n=new e.Color(65280),h=new e.Color(16711680),l=n.lerpHSL(h,(t-this.minZoom)/(this.maxZoom-this.minZoom));return a.fillStyle=l.getStyle(),a.fillRect(0,0,this.resolution,this.resolution),a.fillStyle="#000000",a.textAlign="center",a.textBaseline="middle",a.font="bold "+.1*this.resolution+"px arial",a.fillText("("+t+")",this.resolution/2,.4*this.resolution),a.fillText("("+i+", "+s+")",this.resolution/2,.6*this.resolution),Promise.resolve(r)}},t.GoogleMapsProvider=class extends i{constructor(t){super(),this.sessionToken=null,this.orientation=0,this.format="png",this.mapType="roadmap",this.overlay=!1,this.apiToken=void 0!==t?t:"",this.createSession()}createSession(){const t="https://www.googleapis.com/tile/v1/createSession?key="+this.apiToken,e=JSON.stringify({mapType:this.mapType,language:"en-EN",region:"en",layerTypes:["layerRoadmap","layerStreetview"],overlay:this.overlay,scale:"scaleFactor1x"});P.request(t,"GET",{"Content-Type":"text/json"},e,((t,e)=>{console.log("Created google maps session.",t,e),this.sessionToken=t.session}),(function(t){console.warn("Unable to create a google maps session.",t)}))}fetchTile(t,e,i){return new Promise(((s,r)=>{const o=document.createElement("img");o.onload=function(){s(o)},o.onerror=function(){r()},o.crossOrigin="Anonymous",o.src="https://www.googleapis.com/tile/v1/tiles/"+t+"/"+e+"/"+i+"?session="+this.sessionToken+"&orientation="+this.orientation+"&key="+this.apiToken}))}},t.HeightDebugProvider=class extends i{constructor(t){super(),this.fromColor=new e.Color(16711680),this.toColor=new e.Color(65280),this.provider=t}fetchTile(t,e,i){return new Promise(((s,r)=>{this.provider.fetchTile(t,e,i).then((t=>{const e=256,i=o.createOffscreenCanvas(e,e),r=i.getContext("2d");r.drawImage(t,0,0,e,e,0,0,e,e);const a=r.getImageData(0,0,e,e),n=a.data;for(let t=0;t<n.length;t+=4){const e=.1*(65536*n[t]+256*n[t+1]+n[t+2])-1e4,i=1667721.6,s=this.fromColor.clone().lerpHSL(this.toColor,e/i);n[t]=255*s.r,n[t+1]=255*s.g,n[t+2]=255*s.b}r.putImageData(a,0,0),s(i)})).catch(r)}))}},t.HereMapsProvider=N,t.LODFrustum=M,t.LODRadial=g,t.LODRaycast=class{constructor(){this.subdivisionRays=1,this.thresholdUp=.6,this.thresholdDown=.15,this.raycaster=new e.Raycaster,this.mouse=new e.Vector2,this.powerDistance=!1,this.scaleDistance=!0}updateLOD(t,i,s,r){const o=[];for(let e=0;e<this.subdivisionRays;e++)this.mouse.set(2*Math.random()-1,2*Math.random()-1),this.raycaster.setFromCamera(this.mouse,i),this.raycaster.intersectObjects(t.children,!0,o);for(let t=0;t<o.length;t++){const i=o[t].object;let s=o[t].distance;if(this.powerDistance&&(s=Math.pow(2*s,i.level)),this.scaleDistance){const t=i.matrixWorld.elements;s=new e.Vector3(t[0],t[1],t[2]).length()/s}if(s>this.thresholdUp)return void i.subdivide();if(s<this.thresholdDown&&null!==i.parentNode)return void i.parentNode.simplify()}}},t.MapBoxProvider=D,t.MapHeightNode=d,t.MapHeightNodeShader=p,t.MapNode=a,t.MapNodeGeometry=r,t.MapNodeHeightGeometry=l,t.MapPlaneNode=h,t.MapProvider=i,t.MapSphereNode=u,t.MapSphereNodeGeometry=c,t.MapTerrainNode=A,t.MapTilerProvider=class extends i{constructor(t,e,i,s){super(),this.apiKey=void 0!==t?t:"",this.format=void 0!==s?s:"png",this.category=void 0!==e?e:"maps",this.style=void 0!==i?i:"satellite",this.resolution=512}fetchTile(t,e,i){return new Promise(((s,r)=>{const o=document.createElement("img");o.onload=function(){s(o)},o.onerror=function(){r()},o.crossOrigin="Anonymous",o.src="https://api.maptiler.com/"+this.category+"/"+this.style+"/"+t+"/"+e+"/"+i+"."+this.format+"?key="+this.apiKey}))}},t.MapView=S,t.OpenMapTilesProvider=class extends i{constructor(t,e="png",i="klokantech-basic"){super(),this.address=t,this.format=e,this.theme=i}getMetaData(){const t=this.address+"styles/"+this.theme+".json";P.get(t,(t=>{const e=JSON.parse(t);this.name=e.name,this.format=e.format,this.minZoom=e.minZoom,this.maxZoom=e.maxZoom,this.bounds=e.bounds,this.center=e.center}))}fetchTile(t,e,i){return new Promise(((s,r)=>{const o=document.createElement("img");o.onload=function(){s(o)},o.onerror=function(){r()},o.crossOrigin="Anonymous",o.src=this.address+"styles/"+this.theme+"/"+t+"/"+e+"/"+i+"."+this.format}))}},t.OpenStreetMapsProvider=s,t.TerrainProvider=class extends i{constructor(t={}){super(),this.getUrl=t.getUrl}getMetaData(){}fetchTile(t,e,i){const s=this.getUrl(t,e,i);return new Promise(((t,e)=>{P.get(s,(e=>{t(e)}),(()=>{e()}))}))}},t.UnitsUtils=n,t.XHRUtils=P,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=/sm/ce0cdc4ce967c58015d60994b21ca59a9564d5f3aa412655d216450bd7f9b526.map