Socket
Socket
Sign inDemoInstall

@nextgis/webmap

Package Overview
Dependencies
Maintainers
3
Versions
215
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nextgis/webmap - npm Package Compare versions

Comparing version 1.11.10 to 1.12.0

20

lib/index.d.ts

@@ -48,3 +48,3 @@ /**

import type { Feature } from 'geojson';
import { FeatureProperties } from '@nextgis/utils';
import type { FeatureProperties } from '@nextgis/utils';
import type { GeoJsonGeometryTypes } from 'geojson';

@@ -62,3 +62,3 @@ import type { GeoJsonObject } from 'geojson';

import type StrictEventEmitter from 'strict-event-emitter-types';
import { TileJson } from '@nextgis/utils';
import type { TileJson } from '@nextgis/utils';
import { Type } from '@nextgis/utils';

@@ -175,2 +175,3 @@ import { ViewOptions as ViewOptions_2 } from '@nextgis/webmap';

srs?: number;
onAdded?: (layer: LayerAdapter) => void;
}

@@ -272,3 +273,3 @@

*/
export declare type Cursor = 'auto' | 'crosshair' | 'default' | 'e-resize' | 'grab' | 'help' | 'move' | 'n-resize' | 'ne-resize' | 'nw-resize' | 'pointer' | 'progress' | 's-resize' | 'se-resize' | 'sw-resize' | 'text' | 'w-resize' | 'wait' | 'inherit';
export declare type Cursor = '' | 'auto' | 'crosshair' | 'default' | 'e-resize' | 'grab' | 'help' | 'move' | 'n-resize' | 'ne-resize' | 'nw-resize' | 'pointer' | 'progress' | 's-resize' | 'se-resize' | 'sw-resize' | 'text' | 'w-resize' | 'wait' | 'inherit';

@@ -860,5 +861,5 @@ export declare type DataLayerFilter<F extends Feature = Feature, L = any> = CallbackFilter<F, L>;

export declare type onClickAsync = (status?: boolean) => Promise<void>;
export declare type onClickAsync = () => Promise<void>;
export declare type OnClickSync = (status?: boolean) => void;
export declare type OnClickSync = () => void;

@@ -884,2 +885,8 @@ /** @deprecated use {@link OnLayerMouseOptions} instead */

export declare type OnToggleClick = OnToggleClickSync | onToggleClickAsync;
export declare type onToggleClickAsync = (status: boolean) => Promise<void>;
export declare type OnToggleClickSync = (status: boolean) => void;
/**

@@ -988,3 +995,3 @@ * Screen coordinates in pixels.

/** Set an action to execute when button clicked. */
onClick?: OnClick;
onClick?: OnToggleClick;
/** Get current control status. */

@@ -1545,2 +1552,3 @@ getStatus?: () => boolean;

addImageLayer(url: string, options: Omit<ImageAdapterOptions, 'url'>): Promise<MainLayerAdapter<M, L, ImageAdapterOptions>>;
addImageLayer(options: ImageAdapterOptions): Promise<MainLayerAdapter<M, L, ImageAdapterOptions>>;
/**

@@ -1547,0 +1555,0 @@ * Show added layer on the map by it definition.

@@ -1,2 +0,16 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@nextgis/paint"),e=require("@nextgis/properties-filter"),s=require("events"),i=require("@nextgis/utils");function r(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var o=r(require("@nextgis/cancelable-promise"));function a(t){const e={};for(let i=0;i<t.length;i++)e[t[i]]=1+(e[t[i]]||0);let s;for(const i in e){e[i]>((void 0!==s?e[s]:0)||0)&&(s=i)}return s}function n(t){let e;if("FeatureCollection"===t.type){e=a(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=a(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const d={polygon:"path",line:"path",point:"circle"},l={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function h(e){if(e.data){const s=l[n(e.data)],i=e.paint;i&&t.isPaint(i)&&(i.type=i.type?i.type:"polygon"===s||"line"===s?"path":"html"in i||"className"in i?"icon":d[s]),e.type=e.type||s}return e}class p{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class c{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class y extends c{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class u extends c{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let m=0;const f={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class L{constructor(t){this.options=f,this.emitter=new s.EventEmitter,this.keys=L.keys,this.runtimeParams=[],this.getPaintFunctions=L.getPaintFunctions,this.mapState=[y,u],this.id=m++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=i.deepmerge(f||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const s of this.runtimeParams){const i=s.get(e.name);if(void 0!==i){t[e.name]=e.parse(i);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return i.getBoundsFeature(t)}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){const t=this.mapAdapter.getZoom();if("number"==typeof t)return t}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(void 0!==t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(void 0!==t){this.setZoom(t-1)}}}setView(t,e){if(Array.isArray(t)){const s=t;this.mapAdapter.setView&&s&&i.defined(e)?this.mapAdapter.setView(s,e):(s&&this.mapAdapter.setCenter(s),i.defined(e)&&this.mapAdapter.setZoom(e))}else{const e=t;this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(t,e){return t.every((t=>i.defined(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var s;const i=()=>{const s=this.mapAdapter;t&&t(s),s&&e(s)},r=null===(s=this.mapAdapter.isLoaded)||void 0===s||s;this.mapAdapter.map&&r?i():this.mapAdapter.emitter.once("create",(()=>{i()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new o(((t,e,s)=>{const r=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const o=()=>{this.setCursor(r),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",a),this._coordFromMapClickPromise=void 0},a=e=>{o(),i.deprecatedMapClick(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",a),s(o)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const s=t;this._eventsStatus[s]=!0,this.emitter.emit(s,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),i.defined(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),i.defined(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),i.defined(t.maxzoom)&&i.defined(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:s}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):s&&this.fitBounds(s)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const s=e.get(t.name);if(void 0!==s){const e=t.parse(s);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((s=>{s.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}L.keys=new class{constructor(){this.keyCodeAlias=new p,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class g extends L{constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const s=this.getLayer(t),i=s&&(s.getBounds||s.getExtent);if(i){const t=await i.call(s);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const s=this._layers[e];s&&t.push(s)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const s=this._layers[e];if(t(s))return s}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},s){var r,o;const a=this._layersIdCounter++,n=i.defined(s)?s:void 0!==e.order?e.order:this.reserveOrder();let d;"string"==typeof t?d=this.getLayerAdapter(t):"function"==typeof t?d=t:"then"in t&&(d=await t);const l=e;this._updateGeoJsonOptions(l);const h=null===(r=(e={id:String(a),order:n,...e}).visibility)||void 0===r||r;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:d});t&&(t.options&&(e=t.options),t.adapter&&(d=t.adapter))}if(void 0!==d){const t=new d(this.mapAdapter.map,e);let s;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(s=String(t.options.id),this._layers[s]=t),this._emitLayerEvent("layer:preadd",s||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const i=await t.addLayer(t.options);if(t.layer=i,t.id=t.options.id||String(a),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(o=t.options.order)&&void 0!==o?o:n,s&&delete this._layers[s],s=String(t.id),this._layers[s])throw Error(`layer with id '${s}' already exist`);s&&(this._layers[s]=t,l.filter&&this.filterLayer(t,l.filter),e.baselayer&&this._baselayers.push(s),h&&await this.showLayer(s));const r=e.opacity;void 0!==r&&r<=1&&this.setLayerOpacity(t,r);const p=i&&(t.getBounds||t.getExtent);if(e.fit&&p){const e=await p.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",s,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,s){const i=s||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,i):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let s=!0;t&&(s=t(e,this._layers[e])),s&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),s=e&&this.getLayerId(e);if(e&&s){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(s);t&&this._baselayers.splice(t,1)}delete this._layers[s],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=h(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,s={}){const i=this.getLayer(t),r=void 0!==e?e:!(i&&i.options.visibility),o=void 0!==s.silent&&s.silent,a=async t=>{const e=String(t.id),s=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.filter((e=>e!==t.id&&this.isLayerVisible(e)));for(const t of e)await this.hideLayer(t)}t.showLayer?await t.showLayer.call(t,t.layer):void 0!==t.layer&&await this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?await t.hideLayer.call(t,t.layer):void 0!==t.layer&&await this.mapAdapter.hideLayer(t.layer);t.options.visibility=r,o||(this._emitLayerEvent(s,e,t),this._emitLayerEvent("layer:toggle",e,t))};return i&&i.options.visibility!==r?this.onMapLoad().then((()=>a(i))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);if(e){if(e.updateLayer)return Promise.resolve(e.updateLayer());if(this.isLayerVisible(e))return this.hideLayer(e,{silent:!0}).then((()=>this.showLayer(e,{silent:!0})))}return Promise.resolve()}setLayerOpacity(t,e){const s=this.getLayer(t);s&&(s.setOpacity?s.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(s.layer,e))}selectLayer(t,e){const s=this.getLayer(t);if(s){const t=s;t&&t.select&&t.select(e);const i=this.getLayerId(s);i&&this._selectedLayers.push(i)}}unSelectLayer(t,e){const s=this.getLayer(t);if(s){const t=s&&s;t.unselect&&t.unselect(e);const i=this.getLayerId(s);if(i){const t=this._selectedLayers.indexOf(i);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const s=this.getLayer(t);return s.filter?s.filter(e):[]}propertiesFilter(t,s,i){const r=this.getLayer(t);if(!r)return;const o=r;o.propertiesFilter?o.propertiesFilter(s,i):o.filter&&this.filterLayer(o,(t=>!t.feature||!t.feature.properties||e.propertiesFilter(t.feature.properties,s)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const s=this.getLayer(t);if(s){if(s.setData)return s.setData(e);if(s.clearLayer&&s.addData)return s.clearLayer(),s.addData(e)}return Promise.resolve()}addLayerData(t,e){const s=this.getLayer(t);s.addData&&s.addData(e)}clearLayerData(t,e){const s=this.getLayer(t);s&&s.clearLayer&&s.clearLayer(e)}setLayerPaint(t,e){const s=this.getLayer(t);e&&s&&s.setPaint&&s.setPaint(e)}setLayerSelectedPaint(t,e){const s=this.getLayer(t);e&&s&&s.setSelectedPaint&&s.setSelectedPaint(e)}updateLayerPaint(t,e){const s=this.getLayer(t);e&&s&&s.updatePaint&&s.updatePaint(e)}updateLayerSelectedPaint(t,e){const s=this.getLayer(t);e&&s&&s.updateSelectedPaint&&s.updateSelectedPaint(e)}getAttributions(t){const e=[];for(const s in this._layers){const i=this._layers[s];let r=!(void 0===t.onlyVisible||t.onlyVisible)||i.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(s)),r){const t=i.options&&i.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}_emitLayerEvent(t,e,s){const r=String(t);if(i.defined(e)&&r.startsWith("layer:")){const t=r.replace("layer:","layer-"+e+":");this.emitter.emit(t,s)}this.emitter.emit(t,s)}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(e){const{onSelect:s,onLayerSelect:r,onClick:o,onLayerClick:a,onMouseOut:n,onMouseOver:d}=e,l=o||a;e.onClick=t=>(l&&l(t),this._onLayerClick(t)),e.onMouseOut=t=>{const e=t.layer.id;n&&n(t),i.defined(e)&&this._emitLayerEvent("layer:mouseout",e,t)},e.onMouseOver=t=>{const e=t.layer.id;d&&d(t),i.defined(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const h=s||r;e.onSelect=t=>(h&&h(t),this._onLayerSelect(t)),e.nativePaint||(this.options.paint&&(e.paint=t.preparePaint(e.paint||{},this.options.paint,this.getPaintFunctions)),e.selectedPaint&&this.options.selectedPaint&&(e.selectedPaint=t.preparePaint(e.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}}function _(t,e){const s=document.createElement("div");let i=!1;e.getStatus?i=e.getStatus():e.status&&(i=e.status);const r=e.title||"",o=e.html;function a(){r&&(s.title="string"==typeof r?r:i?r.on:r.off,s.setAttribute("aria-label",s.title))}function n(t){t instanceof HTMLElement?(s.innerHTML="",s.appendChild(t)):"string"==typeof t&&(s.innerHTML=t)}function d(){o&&("string"==typeof o||o instanceof HTMLElement?n(o):n(i?o.on:o.off),s.setAttribute("aria-label",s.title))}function l(t,e){t.split(" ").forEach((t=>{e?s.classList.add(t):s.classList.remove(t)}))}function h(){e.addClassOn&&l(e.addClassOn,i),e.addClassOff&&l(e.addClassOff,!i)}a(),d(),e.addClass&&l(e.addClass,!0),h();const p=t=>{void 0!==t&&(i=t),d(),a(),h()},c=t=>{if(i=void 0!==t?t:!i,e.onClick){const t=e.onClick(i);Promise.resolve(t).then((()=>p())).catch((()=>i=!i))}else p()},y=t({html:s,onClick:c});return y.onClick=c,y.changeStatus=p,y}class v extends g{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,s){let i;if(e=null!=e?e:"top-left",i="string"==typeof t?this.getControl(t,s):t,i)return new Promise((t=>{this._setControlQueue(e,(async()=>{const s=await i,r=this.mapAdapter.addControl(s,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?_(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const s=this.mapAdapter.controlAdapters[t];if(s)return new s(e);{const s=v.controls[t];if(s)return s(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}v.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const C={};function w(t){return C[t]}class b extends v{constructor(t){super(t),this._addControls(),C[this.id]=this}static get(t){return w(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const e of this._starterKits)if(e.onLoadSync)try{await e.onLoadSync.call(e,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,s={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(s=this.options.controlsOptions[t],void 0!==s.control&&(e=s.control));const{position:i,...r}=s;this.addControl(e,i||"top-left",r)})),this._emitStatusEvent("controls:create")}}exports.WebMap=b,exports.WebMapControls=v,exports.WebMapLayers=g,exports.WebMapMain=L,exports.createToggleControl=_,exports.createWebMap=async function(t){return new b(t).onLoad()},exports.detectGeometryType=n,exports.findMostFrequentGeomType=a,exports.getWebMap=w,exports.updateGeoJsonAdapterOptions=h;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@nextgis/utils"),e=require("@nextgis/paint"),r=require("@nextgis/properties-filter"),n=require("events");function o(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var i=o(require("@nextgis/cancelable-promise")),s=function(t,e){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};
/*! *****************************************************************************
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 a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var u=function(){return(u=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function p(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function c(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(a){i=[6,a],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function l(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=l(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}function h(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function y(t){var e;if("FeatureCollection"===t.type)e=h(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=h(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var f={polygon:"path",line:"path",point:"circle"},m={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function v(t){if(t.data){var r=m[y(t.data)],n=t.paint;n&&e.isPaint(n)&&(n.type=n.type?n.type:"polygon"===r||"line"===r?"path":"html"in n||"className"in n?"icon":f[r]),t.type=t.type||r}return t}var g=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},L=function(){function t(){this.keyCodeAlias=new g,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),_=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),b=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return a(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(_),w=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return a(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(_);var C=0,A={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},P=function(){function e(r){this.options=A,this.emitter=new n.EventEmitter,this.keys=e.keys,this.runtimeParams=[],this.getPaintFunctions=e.getPaintFunctions,this.mapState=[b,w],this.id=C++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=r.mapAdapter,this._starterKits=r.starterKits||[],r&&(this.options=t.deepmerge(A||{},r)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return e.prototype.getId=function(){return this.id},e.prototype.create=function(){return p(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},e.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},e.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},e.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},e.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},e.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},e.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},e.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},e.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},e.prototype.getCenter=function(){return this.mapAdapter.getCenter()},e.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},e.prototype.getBoundsPolygon=function(){var e=this.getBounds();if(e)return t.getBoundsFeature(e)},e.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},e.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},e.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},e.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},e.prototype.setView=function(e,r){if(Array.isArray(e)){var n=e;this.mapAdapter.setView&&n&&t.defined(r)?this.mapAdapter.setView(n,r):(n&&this.mapAdapter.setCenter(n),t.defined(r)&&this.mapAdapter.setZoom(r))}else{this.mapAdapter.setView&&this.mapAdapter.setView(e)}},e.prototype.fitBounds=function(e,r){return e.every((function(e){return t.defined(e)}))&&(e[1]<-85.06&&(e[1]=-85.06),e[3]>85.06&&(e[3]=85.06),this.mapAdapter.fitBounds(e,r)),this},e.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},e.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},e.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},e.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},e.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},e.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},e.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},e.prototype.getCoordFromMapClick=function(){var e=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new i((function(r,n,o){var i=e.getCursor()||"grab";e._removeEventListeners({include:["click"]}),e.setCursor("crosshair");var s=function(){e.setCursor(i),e._addEventsListeners({include:["click"]}),e.mapAdapter.emitter.off("click",a),e._coordFromMapClickPromise=void 0},a=function(e){s(),t.deprecatedMapClick(e),r(e.lngLat)};e.mapAdapter.emitter.once("click",a),o(s)})),this._coordFromMapClickPromise)},e.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},e.prototype._addLayerProviders=function(){return p(this,void 0,void 0,(function(){return c(this,(function(t){return[2]}))}))},e.prototype._onLoadSync=function(){return p(this,void 0,void 0,(function(){return c(this,(function(t){return[2]}))}))},e.prototype._setupMap=function(){return p(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},e.prototype._setTileJsonOptions=function(e){e.center&&(this.options.center=e.center),e.bounds&&(this.options.bounds=e.bounds),t.defined(e.maxzoom)&&(this.options.maxZoom=e.maxzoom,this.options.zoom=e.maxzoom),t.defined(e.minzoom)&&(this.options.minZoom=e.minzoom,this.options.zoom=e.minzoom),t.defined(e.maxzoom)&&t.defined(e.minzoom)&&(this.options.zoom=(e.maxzoom+e.minzoom)/2)},e.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},e.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},e.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},e.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},e.keys=new L,e}(),k=function(n){function o(t){var e=n.call(this,t)||this;e._layersIdCounter=1,e._layersOrderCounter=1,e._baselayers=[],e._layers={},e._selectedLayers=[];var r=e.options.tileJson;return r&&e.emitter.once("build-map",(function(){return e.addTileJsonLayer(r)})),e}return a(o,n),o.prototype.fitLayer=function(t,e){return p(this,void 0,void 0,(function(){var r,n,o;return c(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},o.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},o.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},o.prototype.getBaseLayersIds=function(){return this._baselayers},o.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},o.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},o.prototype.getLayers=function(){return Object.keys(this._layers)},o.prototype.allLayers=function(){return this._layers},o.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},o.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},o.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},o.prototype.addBaseLayer=function(t,e){return p(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,u(u({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},o.prototype.addLayer=function(e,r,n){var o,i;return void 0===r&&(r={}),p(this,void 0,void 0,(function(){var s,a,p,l,d,h,y,f,m,v,g,L;return c(this,(function(c){switch(c.label){case 0:return s=this._layersIdCounter++,a=t.defined(n)?n:void 0!==r.order?r.order:this.reserveOrder(),"string"!=typeof e?[3,1]:(p=this.getLayerAdapter(e),[3,4]);case 1:return"function"!=typeof e?[3,2]:(p=e,[3,4]);case 2:return"then"in e?[4,e]:[3,4];case 3:p=c.sent(),c.label=4;case 4:return this._updateGeoJsonOptions(l=r),r=u({id:String(s),order:a},r),d=null===(o=r.visibility)||void 0===o||o,r.visibility=!1,r.baselayer&&(r.order=0),this.options.onBeforeAddLayer&&(h=this.options.onBeforeAddLayer({options:r,adapter:p}))&&(h.options&&(r=h.options),h.adapter&&(p=h.adapter)),void 0===p?[3,12]:((y=new p(this.mapAdapter.map,r)).options=u(u({},r),y.options),y.options.baselayer&&(r.baselayer=!0,r.order=0,y.options.order=0),f=void 0,y.options.id&&(f=String(y.options.id),this._layers[f]=y),this._emitLayerEvent("layer:preadd",f||"",y),[4,this.onMapLoad()]);case 5:return c.sent(),y.map=this.mapAdapter.map,[4,y.addLayer(y.options)];case 6:if(m=c.sent(),y.layer=m,y.id=y.options.id||String(s),y.options.id=y.id,r.baselayer&&(y.options.order=0),y.order=null!==(i=y.options.order)&&void 0!==i?i:a,f&&delete this._layers[f],f=String(y.id),this._layers[f])throw Error("layer with id '".concat(f,"' already exist"));return f?(this._layers[f]=y,l.filter&&this.filterLayer(y,l.filter),r.baselayer&&this._baselayers.push(f),d?[4,this.showLayer(f)]:[3,8]):[3,8];case 7:c.sent(),c.label=8;case 8:return void 0!==(v=r.opacity)&&v<=1&&this.setLayerOpacity(y,v),g=m&&(y.getBounds||y.getExtent),r.fit&&g?[4,g.call(y)]:[3,11];case 9:return(L=c.sent())?[4,this.fitBounds(L)]:[3,11];case 10:c.sent(),c.label=11;case 11:return r.onAdded&&r.onAdded(y),this._emitLayerEvent("layer:add",f,y),[2,y];case 12:return[2,Promise.reject("No adapter")]}}))}))},o.prototype.addLayerFromAsyncAdapter=function(t,e,r){return p(this,void 0,void 0,(function(){var n,o;return c(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},o.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},o.prototype.reserveOrder=function(){return this._layersOrderCounter++},o.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},o.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},o.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=v(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},o.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},o.prototype.addTileLayer=function(t,e){return this.addLayer("TILE",u(u({},e),{url:t}))},o.prototype.addImageLayer=function(t,e){var r;return"string"==typeof t?r=t:(r=t.url,e=t),this.addLayer("IMAGE",u(u({},e),{url:r}))},o.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},o.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},o.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var o=this.getLayer(t),i=void 0!==e?e:!(o&&o.options.visibility),s=void 0!==r.silent&&r.silent;return o&&o.options.visibility!==i?this.onMapLoad().then((function(){return t=o,p(n,void 0,void 0,(function(){var e,r,n,o,a,u,p,l=this;return c(this,(function(c){switch(c.label){case 0:if(e=String(t.id),r=i?"layer:preshow":"layer:prehide",n=i?"layer:show":"layer:hide",s||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!i||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];a=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),u=0,p=a,c.label=1;case 1:return u<p.length?[4,this.hideLayer(p[u])]:[3,4];case 2:c.sent(),c.label=3;case 3:return u++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return c.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:c.sent(),c.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return c.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:c.sent(),c.label=13;case 13:return t.options.visibility=i,s||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},o.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},o.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},o.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},o.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},o.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},o.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},o.prototype.propertiesFilter=function(t,e,n){var o=this.getLayer(t);if(o){var i=o;i.propertiesFilter?i.propertiesFilter(e,n):i.filter&&this.filterLayer(i,(function(t){return!t.feature||!t.feature.properties||r.propertiesFilter(t.feature.properties,e)}))}},o.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},o.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},o.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},o.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},o.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},o.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},o.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},o.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},o.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},o.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},o.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},o.prototype._emitLayerEvent=function(e,r,n){var o=String(e);if(t.defined(r)&&o.startsWith("layer:")){var i=o.replace("layer:","layer-"+r+":");this.emitter.emit(i,n)}this.emitter.emit(e,n)},o.prototype._onLayerClick=function(t){return p(this,void 0,void 0,(function(){return c(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},o.prototype._onLayerSelect=function(t){return p(this,void 0,void 0,(function(){return c(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},o.prototype._updateGeoJsonOptions=function(r){var n=this,o=r.onSelect,i=r.onLayerSelect,s=r.onMouseOut,a=r.onMouseOver,u=r.onClick||r.onLayerClick;r.onClick=function(t){return u&&u(t),n._onLayerClick(t)},r.onMouseOut=function(e){var r=e.layer.id;s&&s(e),t.defined(r)&&n._emitLayerEvent("layer:mouseout",r,e)},r.onMouseOver=function(e){var r=e.layer.id;a&&a(e),t.defined(r)&&n._emitLayerEvent("layer:mouseover",r,e)};var p=o||i;r.onSelect=function(t){return p&&p(t),n._onLayerSelect(t)},r.nativePaint||(this.options.paint&&(r.paint=e.preparePaint(r.paint||{},this.options.paint,this.getPaintFunctions)),r.selectedPaint&&this.options.selectedPaint&&(r.selectedPaint=e.preparePaint(r.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},o}(P);function O(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function p(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function c(){e.addClassOn&&p(e.addClassOn,n),e.addClassOff&&p(e.addClassOff,!n)}s(),u(),e.addClass&&p(e.addClass,!0),c();var l=function(t){void 0!==t&&(n=t),u(),s(),c()},d=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},h=t({html:r,onClick:d});return h.onClick=d,h.changeStatus=l,h}var S=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return a(e,t),e.prototype.addControl=function(t,e,r){return p(this,void 0,void 0,(function(){var n,o=this;return c(this,(function(i){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){o._setControlQueue(e,(function(){return p(o,void 0,void 0,(function(){var r,o;return c(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return p(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return p(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return p(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,O(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return p(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(k),E={};function x(t){return E[t]}var M=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),E[r.id]=r,r}return a(e,t),e.get=function(t){return x(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return p(this,void 0,void 0,(function(){var o,i,s,a,u,p,l,h,y,f;return c(this,(function(c){switch(c.label){case 0:c.trys.push([0,18,19,24]),o=d(this._starterKits),c.label=1;case 1:return[4,o.next()];case 2:return(i=c.sent()).done?[3,17]:(s=i.value).getLayerAdapters?[4,s.getLayerAdapters.call(s)]:[3,16];case 3:if(!(a=c.sent()))return[3,16];c.label=4;case 4:c.trys.push([4,10,11,16]),r=void 0,u=d(a),c.label=5;case 5:return[4,u.next()];case 6:return(p=c.sent()).done?[3,9]:[4,(l=p.value).createAdapter(this)];case 7:(h=c.sent())&&(this.mapAdapter.layerAdapters[l.name]=h),c.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return y=c.sent(),r={error:y},[3,16];case 11:return c.trys.push([11,,14,15]),p&&!p.done&&(n=u.return)?[4,n.call(u)]:[3,13];case 12:c.sent(),c.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return f=c.sent(),t={error:f},[3,24];case 19:return c.trys.push([19,,22,23]),i&&!i.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:c.sent(),c.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return p(this,void 0,void 0,(function(){var r,n,o,i,s;return c(this,(function(a){switch(a.label){case 0:a.trys.push([0,8,9,14]),r=d(this._starterKits),a.label=1;case 1:return[4,r.next()];case 2:if((n=a.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];a.label=3;case 3:return a.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return a.sent(),[3,6];case 5:return i=a.sent(),console.error(i),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return s=a.sent(),t={error:s},[3,14];case 9:return a.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:a.sent(),a.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(S);exports.WebMap=M,exports.WebMapControls=S,exports.WebMapLayers=k,exports.WebMapMain=P,exports.createToggleControl=O,exports.createWebMap=function(t){return p(this,void 0,void 0,(function(){return c(this,(function(e){return[2,new M(t).onLoad()]}))}))},exports.detectGeometryType=y,exports.findMostFrequentGeomType=h,exports.getWebMap=x,exports.updateGeoJsonAdapterOptions=v;
//# sourceMappingURL=webmap.cjs.prod.js.map

@@ -1,2 +0,16 @@

function t(t){return"function"==typeof t}const e={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){const[s,...r]=e;let n=s;Array.isArray(s)&&(n=i(t,s));const o=r.splice(-1,r.length%2)[0];for(let i=0;i<r.length-1;i+=2){if(r[i]===n)return r[i+1]}return o}};function i(t,i){const[s,...r]=i,n=e[s];if(n)return n(t,r)}function s(t){return e=>i(e,t)}const r=["iconSize","iconAnchor"];function n(t,e,i){if((e=String(e))===(t=String(t)))return!0;if(i&&e.toUpperCase()===t.toUpperCase())return!0;const s=`^${r=e,r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}$`.replace(/%/g,".*").replace("_",".");var r;return null!==new RegExp(s,i?"i":"").exec(t)}const o={gt:(t,e)=>t>e,lt:(t,e)=>t<e,ge:(t,e)=>t>=e,le:(t,e)=>t<=e,eq:(t,e)=>t===e,ne:(t,e)=>t!==e,in:(t,e)=>-1!==e.indexOf(t),notin:(t,e)=>-1===e.indexOf(t),like:(t,e)=>n(t,e),ilike:(t,e)=>n(t,e,!0)};function a(t,e){const i="string"==typeof e[0]?e[0]:"all",s=e=>{if(3===(i=e).length&&"string"==typeof i[0]&&"string"==typeof i[1]){const[i,s,r]=e,n=o[s];if(n){if(("like"===s||"ilike"===s)&&"string"==typeof i){let e="";const s=i.replace(/^%?(\w+)%?$/,((s,n)=>(e=t[n],i.replace(n,r))));return n(e,s)}return n(t[i],r)}return!1}return a(t,e);var i},r=e.filter((t=>Array.isArray(t)));return"any"===i?r.some(s):r.every(s)}function c(t){let e={};const i=[];return t.forEach((t=>{t&&(Array.isArray(t)?i.push(t):e=t)})),t=>{const s=i.find((e=>function(t,e){const i={...t.properties};return!!i&&(i.$id=t.id,a(i,e))}(t,e[0])));return s?{...e,...s[1]}:e}}function l(e,i,n){if(!e)throw new Error("paint is empty");let o={...i};if(t(e)){const t=t=>{const s=l(e(t),i,n);return s.type=e.type,s};return t.type=e.type,t}if(function(t){return!!Array.isArray(t)}(e))return t=>l(c(e)(t),i,n);if("get-paint"===e.type){const t=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){const i=e[t.from];if(i)return i(t.options)}}(e,n);t&&(o=l(t,i,n))}else{if("icon"===e.type)return e;{const t=function(t){let e=!1;const i={};for(const n in t)if(-1===r.indexOf(n)){const r=n,o=t[r];Array.isArray(o)&&(e=!0,i[r]=s(o))}if(e)return e=>{const s={};for(const t in i)s[t]=i[t](e);return{...t,...s}}}(e);if(t)return e=>l(t(e),i,n);o={...o,...e},o.fill=void 0===o.fill||o.fill,o.stroke=void 0!==o.stroke?o.stroke:!o.fill||!(!o.strokeColor&&!o.strokeOpacity)}}return t(o)||("color"in o&&(o.strokeColor||(o.strokeColor=o.color),o.fillColor||(o.fillColor=o.color)),"opacity"in o&&(void 0===o.strokeOpacity&&(o.strokeOpacity=o.opacity),void 0===o.fillOpacity&&(o.fillOpacity=o.opacity))),o}function h(t){const e={};for(let s=0;s<t.length;s++)e[t[s]]=1+(e[t[s]]||0);let i;for(const s in e){e[s]>((void 0!==i?e[i]:0)||0)&&(i=s)}return i}function p(t){let e;if("FeatureCollection"===t.type){e=h(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=h(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const d={polygon:"path",line:"path",point:"circle"},u={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function y(t){if(t.data){const e=u[p(t.data)],i=t.paint;i&&"[object Object]"===Object.prototype.toString.call(i)&&(i.type=i.type?i.type:"polygon"===e||"line"===e?"path":"html"in i||"className"in i?"icon":d[e]),t.type=t.type||e}return t}var m,f={exports:{}},v="object"==typeof Reflect?Reflect:null,g=v&&"function"==typeof v.apply?v.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};m=v&&"function"==typeof v.ownKeys?v.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var _=Number.isNaN||function(t){return t!=t};function L(){L.init.call(this)}f.exports=L,f.exports.once=function(t,e){return new Promise((function(i,s){function r(i){t.removeListener(e,n),s(i)}function n(){"function"==typeof t.removeListener&&t.removeListener("error",r),i([].slice.call(arguments))}x(t,e,n,{once:!0}),"error"!==e&&function(t,e,i){"function"==typeof t.on&&x(t,"error",e,i)}(t,r,{once:!0})}))},L.EventEmitter=L,L.prototype._events=void 0,L.prototype._eventsCount=0,L.prototype._maxListeners=void 0;var w=10;function C(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function b(t){return void 0===t._maxListeners?L.defaultMaxListeners:t._maxListeners}function A(t,e,i,s){var r,n,o,a;if(C(i),void 0===(n=t._events)?(n=t._events=Object.create(null),t._eventsCount=0):(void 0!==n.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),n=t._events),o=n[e]),void 0===o)o=n[e]=i,++t._eventsCount;else if("function"==typeof o?o=n[e]=s?[i,o]:[o,i]:s?o.unshift(i):o.push(i),(r=b(t))>0&&o.length>r&&!o.warned){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=o.length,a=c,console&&console.warn&&console.warn(a)}return t}function P(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function E(t,e,i){var s={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},r=P.bind(s);return r.listener=i,s.wrapFn=r,r}function O(t,e,i){var s=t._events;if(void 0===s)return[];var r=s[e];return void 0===r?[]:"function"==typeof r?i?[r.listener||r]:[r]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(r):S(r,r.length)}function k(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function S(t,e){for(var i=new Array(e),s=0;s<e;++s)i[s]=t[s];return i}function x(t,e,i,s){if("function"==typeof t.on)s.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function r(n){s.once&&t.removeEventListener(e,r),i(n)}))}}function M(t){return null!=t}function F(t,e,i=!1){let s=t;const r=e,n=Array.isArray(r);let o=n&&[]||{};return n&&Array.isArray(r)?i?(s=s||[],o=o.concat(s),r.forEach(((t,e)=>{void 0===o[e]?o[e]=t:"object"==typeof t?o[e]=F(s[e],t,i):-1===s.indexOf(t)&&o.push(t)}))):o=r:(s&&"object"==typeof s&&Object.keys(s).forEach((function(t){o[t]=s[t]})),Object.keys(r).forEach((function(t){o[t]="object"==typeof r[t]&&r[t]&&"object"==typeof s[t]&&"object"==typeof r[t]?F(s[t],r[t],i):r[t]}))),o}function j(t){return{type:"Polygon",coordinates:[T(t)]}}function T(t){const e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}Object.defineProperty(L,"defaultMaxListeners",{enumerable:!0,get:function(){return w},set:function(t){if("number"!=typeof t||t<0||_(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");w=t}}),L.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},L.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||_(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},L.prototype.getMaxListeners=function(){return b(this)},L.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var s="error"===t,r=this._events;if(void 0!==r)s=s&&void 0===r.error;else if(!s)return!1;if(s){var n;if(e.length>0&&(n=e[0]),n instanceof Error)throw n;var o=new Error("Unhandled error."+(n?" ("+n.message+")":""));throw o.context=n,o}var a=r[t];if(void 0===a)return!1;if("function"==typeof a)g(a,this,e);else{var c=a.length,l=S(a,c);for(i=0;i<c;++i)g(l[i],this,e)}return!0},L.prototype.on=L.prototype.addListener=function(t,e){return A(this,t,e,!1)},L.prototype.prependListener=function(t,e){return A(this,t,e,!0)},L.prototype.once=function(t,e){return C(e),this.on(t,E(this,t,e)),this},L.prototype.prependOnceListener=function(t,e){return C(e),this.prependListener(t,E(this,t,e)),this},L.prototype.off=L.prototype.removeListener=function(t,e){var i,s,r,n,o;if(C(e),void 0===(s=this._events))return this;if(void 0===(i=s[t]))return this;if(i===e||i.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete s[t],s.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(r=-1,n=i.length-1;n>=0;n--)if(i[n]===e||i[n].listener===e){o=i[n].listener,r=n;break}if(r<0)return this;0===r?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,r),1===i.length&&(s[t]=i[0]),void 0!==s.removeListener&&this.emit("removeListener",t,o||e)}return this},L.prototype.removeAllListeners=function(t){var e,i,s;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var r,n=Object.keys(i);for(s=0;s<n.length;++s)"removeListener"!==(r=n[s])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(s=e.length-1;s>=0;s--)this.removeListener(t,e[s]);return this},L.prototype.listeners=function(t){return O(this,t,!0)},L.prototype.rawListeners=function(t){return O(this,t,!1)},L.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):k.call(t,e)},L.prototype.listenerCount=k,L.prototype.eventNames=function(){return this._eventsCount>0?m(this._events):[]};class z extends Error{constructor(){super(),this.name="CancelError",Object.setPrototypeOf(this,z.prototype)}}class B{constructor(t={}){this.options=t,this._promises=new Map}get isLoaded(){return this._promises.size>0}remove(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())}get(t){return this._promises.get(t)}add(t,e){const i=e||t,s=this._promises.get(i);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),s||(this._promises.set(i,t),t.finally((()=>{this.remove(i)})),t)}abort(){this.isLoaded&&(this._promises.forEach((t=>{t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())}waitFunc(t,e=""){const i=this.get(e=e||t.name);return i||this.add(t(),e)}WaitForMe(t=""){const e=this.get.bind(this),i=this.add.bind(this);return function(s,r,n){const o=n.value;return t=t||r,n.value=function(...s){const r=e(t);if(r)return r;return i(o.apply(this,s),t)},n}}GetOrCreateDecorator(t=""){return this.WaitForMe(t)}_onStop(){this.options.onStop&&!this.isLoaded&&this.options.onStop()}}class I extends Error{constructor(){super(),this.name="TimeoutError",Object.setPrototypeOf(this,I.prototype)}}const V=(t,e,i,s)=>{try{t(i(s))}catch(r){e(r)}};let R=0;class Z{constructor(t,e){this.id=R++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise(((t,e)=>{this._setCanceledCallback=e=>t(e||new z)}));const i=[this._cancelPromise,new Promise(((e,i)=>t((t=>{t instanceof Z?this.attach(t):this._isPending=!1,e(t)}),(t=>{this._isPending=!1,i(t)}),(t=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(t)}))))];e&&i.push(new Promise(((t,i)=>{setTimeout((()=>{if(this._isPending)try{this.cancel()}finally{i(new I)}}),e)}))),this._promise=Promise.race(i)}static createControl(t){return new B(t)}static resolve(t){return new Z((e=>e(t)))}static reject(t){return new Z(((e,i)=>i(t)))}static all(t){return new Z(((e,i)=>{Promise.all(t).then(e).catch(i)})).catch((e=>{if(e instanceof this.CancelError)for(const i of t)"cancel"in i&&i.cancel();throw e}))}attach(t){this._isCanceled?t.cancel():this._children.push(t)}then(t,e){const i=new Z(((i,s)=>{if(this._promise){const r=t=>{e?V(i,s,e,t):s(t)};this._promise.then((e=>{this._isCanceled?r(e):t?V(i,s,t,e):i(e)}),r)}}));return i._parentPromise=this,this._children.push(i),i}catch(t){return this._isCanceled&&t&&t(new z),this.then(void 0,t)}finally(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new z:t)}cancel(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;const t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((t=>t.cancel())),this._isPending){if(this._cancelHandlers.length)try{for(const t of this._cancelHandlers)t()}catch(e){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this}_getTopParent(){let t=this._parentPromise,e=!!t;for(;e;)t&&t._parentPromise?(t=t._parentPromise,e=!!t):e=!1;return t}_destroy(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0}}Z.CancelError=z,Z.TimeoutError=I,Z.PromiseControl=B,Object.setPrototypeOf(Z.prototype,Promise.prototype);var N=Z;class J{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class G{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class D extends G{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class H extends G{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let K=0;const Q={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class ${constructor(t){this.options=Q,this.emitter=new f.exports.EventEmitter,this.keys=$.keys,this.runtimeParams=[],this.getPaintFunctions=$.getPaintFunctions,this.mapState=[D,H],this.id=K++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=F(Q||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const i of this.runtimeParams){const s=i.get(e.name);if(void 0!==s){t[e.name]=e.parse(s);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return{type:"Feature",properties:{},geometry:j(t)}}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){const t=this.mapAdapter.getZoom();if("number"==typeof t)return t}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(void 0!==t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(void 0!==t){this.setZoom(t-1)}}}setView(t,e){if(Array.isArray(t)){const i=t;this.mapAdapter.setView&&i&&M(e)?this.mapAdapter.setView(i,e):(i&&this.mapAdapter.setCenter(i),M(e)&&this.mapAdapter.setZoom(e))}else{const e=t;this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(t,e){return t.every((t=>M(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var i;const s=()=>{const i=this.mapAdapter;t&&t(i),i&&e(i)},r=null===(i=this.mapAdapter.isLoaded)||void 0===i||i;this.mapAdapter.map&&r?s():this.mapAdapter.emitter.once("create",(()=>{s()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new N(((t,e,i)=>{const s=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const r=()=>{this.setCursor(s),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",n),this._coordFromMapClickPromise=void 0},n=e=>{r(),function(t){!t.lngLat&&t.latLng&&(t.lngLat=[t.latLng.lng,t.latLng.lat])}(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",n),i(r)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const i=t;this._eventsStatus[i]=!0,this.emitter.emit(i,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),M(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),M(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),M(t.maxzoom)&&M(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:i}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):i&&this.fitBounds(i)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const i=e.get(t.name);if(void 0!==i){const e=t.parse(i);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((i=>{i.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}$.keys=new class{constructor(){this.keyCodeAlias=new J,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class U extends ${constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const i=this.getLayer(t),s=i&&(i.getBounds||i.getExtent);if(s){const t=await s.call(i);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const i=this._layers[e];i&&t.push(i)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const i=this._layers[e];if(t(i))return i}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},i){var s,r;const n=this._layersIdCounter++,o=M(i)?i:void 0!==e.order?e.order:this.reserveOrder();let a;"string"==typeof t?a=this.getLayerAdapter(t):"function"==typeof t?a=t:"then"in t&&(a=await t);const c=e;this._updateGeoJsonOptions(c);const l=null===(s=(e={id:String(n),order:o,...e}).visibility)||void 0===s||s;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:a});t&&(t.options&&(e=t.options),t.adapter&&(a=t.adapter))}if(void 0!==a){const t=new a(this.mapAdapter.map,e);let i;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(i=String(t.options.id),this._layers[i]=t),this._emitLayerEvent("layer:preadd",i||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const s=await t.addLayer(t.options);if(t.layer=s,t.id=t.options.id||String(n),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(r=t.options.order)&&void 0!==r?r:o,i&&delete this._layers[i],i=String(t.id),this._layers[i])throw Error(`layer with id '${i}' already exist`);i&&(this._layers[i]=t,c.filter&&this.filterLayer(t,c.filter),e.baselayer&&this._baselayers.push(i),l&&await this.showLayer(i));const h=e.opacity;void 0!==h&&h<=1&&this.setLayerOpacity(t,h);const p=s&&(t.getBounds||t.getExtent);if(e.fit&&p){const e=await p.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",i,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,i){const s=i||void 0!==e.order?e.order:this.reserveOrder(),r=t(),n=await r;return n?this.addLayer(n,e,s):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let i=!0;t&&(i=t(e,this._layers[e])),i&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),i=e&&this.getLayerId(e);if(e&&i){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(i);t&&this._baselayers.splice(t,1)}delete this._layers[i],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=y(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,i={}){const s=this.getLayer(t),r=void 0!==e?e:!(s&&s.options.visibility),n=void 0!==i.silent&&i.silent,o=async t=>{const e=String(t.id),i=r?"layer:show":"layer:hide";if(n||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.filter((e=>e!==t.id&&this.isLayerVisible(e)));for(const t of e)await this.hideLayer(t)}t.showLayer?await t.showLayer.call(t,t.layer):void 0!==t.layer&&await this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?await t.hideLayer.call(t,t.layer):void 0!==t.layer&&await this.mapAdapter.hideLayer(t.layer);t.options.visibility=r,n||(this._emitLayerEvent(i,e,t),this._emitLayerEvent("layer:toggle",e,t))};return s&&s.options.visibility!==r?this.onMapLoad().then((()=>o(s))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);if(e){if(e.updateLayer)return Promise.resolve(e.updateLayer());if(this.isLayerVisible(e))return this.hideLayer(e,{silent:!0}).then((()=>this.showLayer(e,{silent:!0})))}return Promise.resolve()}setLayerOpacity(t,e){const i=this.getLayer(t);i&&(i.setOpacity?i.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(i.layer,e))}selectLayer(t,e){const i=this.getLayer(t);if(i){const t=i;t&&t.select&&t.select(e);const s=this.getLayerId(i);s&&this._selectedLayers.push(s)}}unSelectLayer(t,e){const i=this.getLayer(t);if(i){const t=i&&i;t.unselect&&t.unselect(e);const s=this.getLayerId(i);if(s){const t=this._selectedLayers.indexOf(s);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const i=this.getLayer(t);return i.filter?i.filter(e):[]}propertiesFilter(t,e,i){const s=this.getLayer(t);if(!s)return;const r=s;r.propertiesFilter?r.propertiesFilter(e,i):r.filter&&this.filterLayer(r,(t=>!t.feature||!t.feature.properties||a(t.feature.properties,e)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const i=this.getLayer(t);if(i){if(i.setData)return i.setData(e);if(i.clearLayer&&i.addData)return i.clearLayer(),i.addData(e)}return Promise.resolve()}addLayerData(t,e){const i=this.getLayer(t);i.addData&&i.addData(e)}clearLayerData(t,e){const i=this.getLayer(t);i&&i.clearLayer&&i.clearLayer(e)}setLayerPaint(t,e){const i=this.getLayer(t);e&&i&&i.setPaint&&i.setPaint(e)}setLayerSelectedPaint(t,e){const i=this.getLayer(t);e&&i&&i.setSelectedPaint&&i.setSelectedPaint(e)}updateLayerPaint(t,e){const i=this.getLayer(t);e&&i&&i.updatePaint&&i.updatePaint(e)}updateLayerSelectedPaint(t,e){const i=this.getLayer(t);e&&i&&i.updateSelectedPaint&&i.updateSelectedPaint(e)}getAttributions(t){const e=[];for(const i in this._layers){const s=this._layers[i];let r=!(void 0===t.onlyVisible||t.onlyVisible)||s.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(i)),r){const t=s.options&&s.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}_emitLayerEvent(t,e,i){const s=String(t);if(M(e)&&s.startsWith("layer:")){const t=s.replace("layer:","layer-"+e+":");this.emitter.emit(t,i)}this.emitter.emit(t,i)}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(t){const{onSelect:e,onLayerSelect:i,onClick:s,onLayerClick:r,onMouseOut:n,onMouseOver:o}=t,a=s||r;t.onClick=t=>(a&&a(t),this._onLayerClick(t)),t.onMouseOut=t=>{const e=t.layer.id;n&&n(t),M(e)&&this._emitLayerEvent("layer:mouseout",e,t)},t.onMouseOver=t=>{const e=t.layer.id;o&&o(t),M(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const c=e||i;t.onSelect=t=>(c&&c(t),this._onLayerSelect(t)),t.nativePaint||(this.options.paint&&(t.paint=l(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=l(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}}function W(t,e){const i=document.createElement("div");let s=!1;e.getStatus?s=e.getStatus():e.status&&(s=e.status);const r=e.title||"",n=e.html;function o(){r&&(i.title="string"==typeof r?r:s?r.on:r.off,i.setAttribute("aria-label",i.title))}function a(t){t instanceof HTMLElement?(i.innerHTML="",i.appendChild(t)):"string"==typeof t&&(i.innerHTML=t)}function c(){n&&("string"==typeof n||n instanceof HTMLElement?a(n):a(s?n.on:n.off),i.setAttribute("aria-label",i.title))}function l(t,e){t.split(" ").forEach((t=>{e?i.classList.add(t):i.classList.remove(t)}))}function h(){e.addClassOn&&l(e.addClassOn,s),e.addClassOff&&l(e.addClassOff,!s)}o(),c(),e.addClass&&l(e.addClass,!0),h();const p=t=>{void 0!==t&&(s=t),c(),o(),h()},d=t=>{if(s=void 0!==t?t:!s,e.onClick){const t=e.onClick(s);Promise.resolve(t).then((()=>p())).catch((()=>s=!s))}else p()},u=t({html:i,onClick:d});return u.onClick=d,u.changeStatus=p,u}class q extends U{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,i){let s;if(e=null!=e?e:"top-left",s="string"==typeof t?this.getControl(t,i):t,s)return new Promise((t=>{this._setControlQueue(e,(async()=>{const i=await s,r=this.mapAdapter.addControl(i,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?W(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const i=this.mapAdapter.controlAdapters[t];if(i)return new i(e);{const i=q.controls[t];if(i)return i(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}q.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const X={};function Y(t){return X[t]}class tt extends q{constructor(t){super(t),this._addControls(),X[this.id]=this}static get(t){return Y(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const e of this._starterKits)if(e.onLoadSync)try{await e.onLoadSync.call(e,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,i={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(i=this.options.controlsOptions[t],void 0!==i.control&&(e=i.control));const{position:s,...r}=i;this.addControl(e,s||"top-left",r)})),this._emitStatusEvent("controls:create")}}async function et(t){return new tt(t).onLoad()}export{tt as WebMap,q as WebMapControls,U as WebMapLayers,$ as WebMapMain,W as createToggleControl,et as createWebMap,p as detectGeometryType,h as findMostFrequentGeomType,Y as getWebMap,y as updateGeoJsonAdapterOptions};
/*! *****************************************************************************
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.
***************************************************************************** */
var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};function e(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(e){o(e)}}function a(t){try{u(n.throw(t))}catch(e){o(e)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(a){o=[6,a],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function o(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=o(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,i,(e=t[r](e)).done,e.value)}))}}}function a(t){return null!=t}function u(t,e,r){void 0===r&&(r=!1);var n=t,i=e,o=Array.isArray(i),s=o&&[]||{};return o&&Array.isArray(i)?r?(s=s.concat(n=n||[]),i.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=u(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=i:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(i).forEach((function(t){s[t]="object"==typeof i[t]&&i[t]&&"object"==typeof n[t]&&"object"==typeof i[t]?u(n[t],i[t],r):i[t]}))),s}function c(t){return{type:"Polygon",coordinates:[p(t)]}}function p(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}function l(t){return"function"==typeof t}var f={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){var r=e[0],n=e.slice(1),i=r;Array.isArray(r)&&(i=h(t,r));for(var o=n.splice(-1,n.length%2)[0],s=0;s<n.length-1;s+=2){if(n[s]===i)return n[s+1]}return o}};function h(t,e){var r=e[0],n=e.slice(1),i=f[r];if(i)return i(t,n)}function d(t){return function(e){return h(e,t)}}var y=["iconSize","iconAnchor"];function v(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,i="^".concat((n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")),"$").replace(/%/g,".*").replace("_",".");return null!==new RegExp(i,r?"i":"").exec(t)}var m={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return v(t,e)},ilike:function(t,e){return v(t,e,!0)}};function g(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(3===(u=e).length&&"string"==typeof u[0]&&"string"==typeof u[1]){var r=e[0],n=e[1],i=e[2],o=m[n];if(o){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,i)}));return o(s,a)}return o(t[r],i)}return!1}return g(t,e);var u},i=e.filter((function(t){return Array.isArray(t)}));return"any"===r?i.some(n):i.every(n)}function _(t){var e={},n=[];return t.forEach((function(t){t&&(Array.isArray(t)?n.push(t):e=t)})),function(t){var i=n.find((function(e){return function(t,e){var n=r({},t.properties);return!!n&&(n.$id=t.id,g(n,e))}(t,e[0])}));return i?r(r({},e),i[1]):e}}function L(t,e,n){if(!t)throw new Error("paint is empty");var i=r({},e);if(l(t)){var o=function(r){var i=L(t(r),e,n);return i.type=t.type,i};return o.type=t.type,o}if(function(t){return!!Array.isArray(t)}(t))return function(r){return L(_(t)(r),e,n)};if("get-paint"===t.type){var s=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(t,n);s&&(i=L(s,e,n))}else{if("icon"===t.type)return t;var a=function(t){var e=!1,n={};for(var i in t)if(-1===y.indexOf(i)){var o=i,s=t[o];Array.isArray(s)&&(e=!0,n[o]=d(s))}if(e)return function(e){var i={};for(var o in n)i[o]=n[o](e);return r(r({},t),i)}}(t);if(a)return function(t){return L(a(t),e,n)};(i=r(r({},i),t)).fill=void 0===i.fill||i.fill,i.stroke=void 0!==i.stroke?i.stroke:!i.fill||!(!i.strokeColor&&!i.strokeOpacity)}return l(i)||("color"in i&&(i.strokeColor||(i.strokeColor=i.color),i.fillColor||(i.fillColor=i.color)),"opacity"in i&&(void 0===i.strokeOpacity&&(i.strokeOpacity=i.opacity),void 0===i.fillOpacity&&(i.fillOpacity=i.opacity))),i}function b(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var i in r){r[i]>((void 0!==e?r[e]:0)||0)&&(e=i)}return e}function w(t){var e;if("FeatureCollection"===t.type)e=b(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=b(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var C={polygon:"path",line:"path",point:"circle"},P={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function A(t){if(t.data){var e=P[w(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":C[e]),t.type=t.type||e}return t}var O,E={exports:{}},k="object"==typeof Reflect?Reflect:null,S=k&&"function"==typeof k.apply?k.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};O=k&&"function"==typeof k.ownKeys?k.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var x=Number.isNaN||function(t){return t!=t};function M(){M.init.call(this)}E.exports=M,E.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}N(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&N(t,"error",e,r)}(t,i,{once:!0})}))},M.EventEmitter=M,M.prototype._events=void 0,M.prototype._eventsCount=0,M.prototype._maxListeners=void 0;var j=10;function F(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function T(t){return void 0===t._maxListeners?M.defaultMaxListeners:t._maxListeners}function z(t,e,r,n){var i,o,s,a;if(F(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=T(t))>0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function B(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function I(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=B.bind(n);return i.listener=r,n.wrapFn=i,i}function V(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):Z(i,i.length)}function R(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function Z(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function N(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){n.once&&t.removeEventListener(e,i),r(o)}))}}Object.defineProperty(M,"defaultMaxListeners",{enumerable:!0,get:function(){return j},set:function(t){if("number"!=typeof t||t<0||x(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");j=t}}),M.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},M.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||x(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},M.prototype.getMaxListeners=function(){return T(this)},M.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=i[t];if(void 0===a)return!1;if("function"==typeof a)S(a,this,e);else{var u=a.length,c=Z(a,u);for(r=0;r<u;++r)S(c[r],this,e)}return!0},M.prototype.on=M.prototype.addListener=function(t,e){return z(this,t,e,!1)},M.prototype.prependListener=function(t,e){return z(this,t,e,!0)},M.prototype.once=function(t,e){return F(e),this.on(t,I(this,t,e)),this},M.prototype.prependOnceListener=function(t,e){return F(e),this.prependListener(t,I(this,t,e)),this},M.prototype.off=M.prototype.removeListener=function(t,e){var r,n,i,o,s;if(F(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},M.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},M.prototype.listeners=function(t){return V(this,t,!0)},M.prototype.rawListeners=function(t){return V(this,t,!1)},M.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):R.call(t,e)},M.prototype.listenerCount=R,M.prototype.eventNames=function(){return this._eventsCount>0?O(this._events):[]};var G=function(t){function r(){var e=t.call(this)||this;return e.name="CancelError",Object.setPrototypeOf(e,r.prototype),e}return e(r,t),r}(Error),J=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,i=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),i||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,i,o){var s=o.value;return t=t||i,o.value=function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var o=e(t);if(o)return o;var a=r(s.apply(this,n),t);return a},o}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),D=function(t){function r(){var e=t.call(this)||this;return e.name="TimeoutError",Object.setPrototypeOf(e,r.prototype),e}return e(r,t),r}(Error),H=function(t,e,r,n){try{t(r(n))}catch(i){e(i)}},K=0,Q=function(){function t(e,r){var n=this;this.id=K++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new G)}}));var i=[this._cancelPromise,new Promise((function(r,i){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,i(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&i.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new D)}}),r)}))),this._promise=Promise.race(i)}return t.createControl=function(t){return new J(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,i=e;n<i.length;n++){var o=i[n];"cancel"in o&&o.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,i=new t((function(t,i){if(n._promise){var o=function(e){r?H(t,i,r,e):i(e)};n._promise.then((function(r){n._isCanceled?o(r):e?H(t,i,e,r):t(r)}),o)}}));return i._parentPromise=this,this._children.push(i),i},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new G),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new G:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(n){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=G,t.TimeoutError=D,t.PromiseControl=J,t}();Object.setPrototypeOf(Q.prototype,Promise.prototype);var U=Q,W=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},$=function(){function t(){this.keyCodeAlias=new W,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),q=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),X=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return e(r,t),r.prototype.getValue=function(){return this.webMap.getCenter()},r.prototype.setValue=function(t){this.webMap.setCenter(t)},r.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},r.prototype.parse=function(t){return t.split("_").map(Number)},r}(q),Y=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return e(r,t),r.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},r.prototype.setValue=function(t){this.webMap.setZoom(t)},r.prototype.toString=function(t){return String(t)},r.prototype.parse=function(t){return Number(t)},r}(q);var tt=0,et={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},rt=function(){function t(e){this.options=et,this.emitter=new E.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[X,Y],this.id=tt++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=u(et||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,i=t.runtimeParams;n<i.length;n++){var o=i[n].get(r.name);if(void 0!==o){e[r.name]=r.parse(o);break}}})),e},t.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:c(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){if(Array.isArray(t)){var r=t;this.mapAdapter.setView&&r&&a(e)?this.mapAdapter.setView(r,e):(r&&this.mapAdapter.setCenter(r),a(e)&&this.mapAdapter.setZoom(e))}else{this.mapAdapter.setView&&this.mapAdapter.setView(t)}},t.prototype.fitBounds=function(t,e){return t.every((function(t){return a(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,i=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},o=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&o?i():e.mapAdapter.emitter.once("create",(function(){i()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new U((function(e,r,n){var i=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var o=function(){t.setCursor(i),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){var r;o(),!(r=t).lngLat&&r.latLng&&(r.lngLat=[r.latLng.lng,r.latLng.lat]),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(o)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),a(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),a(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),a(t.maxzoom)&&a(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var i=0,o=this.runtimeParams;i<o.length;i++){var s=o[i].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var i=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,i)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new $,t}(),nt=function(t){function o(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return e(o,t),o.prototype.fitLayer=function(t,e){return n(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},o.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},o.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},o.prototype.getBaseLayersIds=function(){return this._baselayers},o.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},o.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},o.prototype.getLayers=function(){return Object.keys(this._layers)},o.prototype.allLayers=function(){return this._layers},o.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},o.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},o.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},o.prototype.addBaseLayer=function(t,e){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.addLayer(t,r(r({},e),{baselayer:!0}),void 0)];case 1:return[2,n.sent()]}}))}))},o.prototype.addLayer=function(t,e,o){var s,u;return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var n,c,p,l,f,h,d,y,v,m,g,_;return i(this,(function(i){switch(i.label){case 0:return n=this._layersIdCounter++,c=a(o)?o:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(p=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(p=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:p=i.sent(),i.label=4;case 4:return this._updateGeoJsonOptions(l=e),e=r({id:String(n),order:c},e),f=null===(s=e.visibility)||void 0===s||s,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(h=this.options.onBeforeAddLayer({options:e,adapter:p}))&&(h.options&&(e=h.options),h.adapter&&(p=h.adapter)),void 0===p?[3,12]:((d=new p(this.mapAdapter.map,e)).options=r(r({},e),d.options),d.options.baselayer&&(e.baselayer=!0,e.order=0,d.options.order=0),y=void 0,d.options.id&&(y=String(d.options.id),this._layers[y]=d),this._emitLayerEvent("layer:preadd",y||"",d),[4,this.onMapLoad()]);case 5:return i.sent(),d.map=this.mapAdapter.map,[4,d.addLayer(d.options)];case 6:if(v=i.sent(),d.layer=v,d.id=d.options.id||String(n),d.options.id=d.id,e.baselayer&&(d.options.order=0),d.order=null!==(u=d.options.order)&&void 0!==u?u:c,y&&delete this._layers[y],y=String(d.id),this._layers[y])throw Error("layer with id '".concat(y,"' already exist"));return y?(this._layers[y]=d,l.filter&&this.filterLayer(d,l.filter),e.baselayer&&this._baselayers.push(y),f?[4,this.showLayer(y)]:[3,8]):[3,8];case 7:i.sent(),i.label=8;case 8:return void 0!==(m=e.opacity)&&m<=1&&this.setLayerOpacity(d,m),g=v&&(d.getBounds||d.getExtent),e.fit&&g?[4,g.call(d)]:[3,11];case 9:return(_=i.sent())?[4,this.fitBounds(_)]:[3,11];case 10:i.sent(),i.label=11;case 11:return e.onAdded&&e.onAdded(d),this._emitLayerEvent("layer:add",y,d),[2,d];case 12:return[2,Promise.reject("No adapter")]}}))}))},o.prototype.addLayerFromAsyncAdapter=function(t,e,r){return n(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},o.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},o.prototype.reserveOrder=function(){return this._layersOrderCounter++},o.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},o.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},o.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=A(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},o.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},o.prototype.addTileLayer=function(t,e){return this.addLayer("TILE",r(r({},e),{url:t}))},o.prototype.addImageLayer=function(t,e){var n;return"string"==typeof t?n=t:(n=t.url,e=t),this.addLayer("IMAGE",r(r({},e),{url:n}))},o.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},o.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},o.prototype.toggleLayer=function(t,e,r){var o=this;void 0===r&&(r={});var s=this.getLayer(t),a=void 0!==e?e:!(s&&s.options.visibility),u=void 0!==r.silent&&r.silent;return s&&s.options.visibility!==a?this.onMapLoad().then((function(){return t=s,n(o,void 0,void 0,(function(){var e,r,n,o,s,c,p,l=this;return i(this,(function(i){switch(i.label){case 0:if(e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!a||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];s=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),c=0,p=s,i.label=1;case 1:return c<p.length?[4,this.hideLayer(p[c])]:[3,4];case 2:i.sent(),i.label=3;case 3:return c++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return i.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:i.sent(),i.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return i.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:i.sent(),i.label=13;case 13:return t.options.visibility=a,u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},o.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},o.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},o.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},o.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var i=this.getLayerId(r);if(i){var o=this._selectedLayers.indexOf(i);-1!==o&&this._selectedLayers.splice(o,1)}}},o.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},o.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},o.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var i=n;i.propertiesFilter?i.propertiesFilter(e,r):i.filter&&this.filterLayer(i,(function(t){return!t.feature||!t.feature.properties||g(t.feature.properties,e)}))}},o.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},o.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},o.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},o.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},o.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},o.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},o.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},o.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},o.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],i=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(i&&t.onlyBaselayer&&(i=this._baselayers.includes(r)),i){var o=n.options&&n.options.attribution;o&&e.push(o)}}return e},o.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},o.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},o.prototype._emitLayerEvent=function(t,e,r){var n=String(t);if(a(e)&&n.startsWith("layer:")){var i=n.replace("layer:","layer-"+e+":");this.emitter.emit(i,r)}this.emitter.emit(t,r)},o.prototype._onLayerClick=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},o.prototype._onLayerSelect=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},o.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,i=t.onMouseOut,o=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;i&&i(t),a(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;o&&o(t),a(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var u=r||n;t.onSelect=function(t){return u&&u(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=L(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=L(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},o}(rt);function it(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var i=e.title||"",o=e.html;function s(){i&&(r.title="string"==typeof i?i:n?i.on:i.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){o&&("string"==typeof o||o instanceof HTMLElement?a(o):a(n?o.on:o.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},f=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},h=t({html:r,onClick:f});return h.onClick=f,h.changeStatus=l,h}var ot=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return e(r,t),r.prototype.addControl=function(t,e,r){return n(this,void 0,void 0,(function(){var o,s=this;return i(this,(function(a){return e=null!=e?e:"top-left",(o="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){s._setControlQueue(e,(function(){return n(s,void 0,void 0,(function(){var r,n;return i(this,(function(i){switch(i.label){case 0:return[4,o];case 1:return r=i.sent(),n=this.mapAdapter.addControl(r,e),t(n),[2]}}))}))}))}))]:[2]}))}))},r.prototype.createControl=function(t,e){return n(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},r.prototype.createButtonControl=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},r.prototype.createToggleControl=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,it(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},r.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},r.prototype.getControl=function(t,e){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(e);var i=r.controls[t];return i?i(this,e):void 0},r.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},r.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},r.prototype._applyControls=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},r.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},r}(nt),st={};function at(t){return st[t]}var ut=function(t){function r(e){var r=t.call(this,e)||this;return r._addControls(),st[r.id]=r,r}return e(r,t),r.get=function(t){return at(t)},r.prototype._addLayerProviders=function(){var t,e,r,o;return n(this,void 0,void 0,(function(){var n,a,u,c,p,l,f,h,d,y;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,18,19,24]),n=s(this._starterKits),i.label=1;case 1:return[4,n.next()];case 2:return(a=i.sent()).done?[3,17]:(u=a.value).getLayerAdapters?[4,u.getLayerAdapters.call(u)]:[3,16];case 3:if(!(c=i.sent()))return[3,16];i.label=4;case 4:i.trys.push([4,10,11,16]),r=void 0,p=s(c),i.label=5;case 5:return[4,p.next()];case 6:return(l=i.sent()).done?[3,9]:[4,(f=l.value).createAdapter(this)];case 7:(h=i.sent())&&(this.mapAdapter.layerAdapters[f.name]=h),i.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return d=i.sent(),r={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l&&!l.done&&(o=p.return)?[4,o.call(p)]:[3,13];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=i.sent(),t={error:y},[3,24];case 19:return i.trys.push([19,,22,23]),a&&!a.done&&(e=n.return)?[4,e.call(n)]:[3,21];case 20:i.sent(),i.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},r.prototype._onLoadSync=function(){var t,e;return n(this,void 0,void 0,(function(){var r,n,o,a,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,14]),r=s(this._starterKits),i.label=1;case 1:return[4,r.next()];case 2:if((n=i.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return i.sent(),[3,6];case 5:return a=i.sent(),console.error(a),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return u=i.sent(),t={error:u},[3,14];case 9:return i.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},r.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var i=n.position,o=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(n,["position"]);t.addControl(r,i||"top-left",o)})),this._emitStatusEvent("controls:create")},r}(ot);function ct(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new ut(t).onLoad()]}))}))}export{ut as WebMap,ot as WebMapControls,nt as WebMapLayers,rt as WebMapMain,it as createToggleControl,ct as createWebMap,w as detectGeometryType,b as findMostFrequentGeomType,at as getWebMap,A as updateGeoJsonAdapterOptions};
//# sourceMappingURL=webmap.esm-browser.prod.js.map

@@ -1,2 +0,16 @@

import{isPaint as t,preparePaint as e}from"@nextgis/paint";import{propertiesFilter as s}from"@nextgis/properties-filter";import{EventEmitter as i}from"events";import{deepmerge as r,getBoundsFeature as o,defined as a,deprecatedMapClick as n}from"@nextgis/utils";import h from"@nextgis/cancelable-promise";function l(t){const e={};for(let i=0;i<t.length;i++)e[t[i]]=1+(e[t[i]]||0);let s;for(const i in e){e[i]>((void 0!==s?e[s]:0)||0)&&(s=i)}return s}function d(t){let e;if("FeatureCollection"===t.type){e=l(t.features.map((t=>t.geometry.type)))}else if("GeometryCollection"===t.type){e=l(t.geometries.map((t=>t.type)))}else e="Feature"===t.type?t.geometry.type:t.type;return e}const p={polygon:"path",line:"path",point:"circle"},c={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function y(e){if(e.data){const s=c[d(e.data)],i=e.paint;i&&t(i)&&(i.type=i.type?i.type:"polygon"===s||"line"===s?"path":"html"in i||"className"in i?"icon":p[s]),e.type=e.type||s}return e}class m{constructor(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222}}class u{constructor(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}getValue(){return this.value}setValue(t){this.value=t}}class f extends u{constructor(){super(...arguments),this.name="center",this.event="moveend"}getValue(){return this.webMap.getCenter()}setValue(t){this.webMap.setCenter(t)}toString(t){const e=t.map((t=>t.toFixed(5)));return e[0]+"_"+e[1]}parse(t){return t.split("_").map(Number)}}class L extends u{constructor(){super(...arguments),this.name="zoom",this.event="zoomend"}getValue(){const t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0}setValue(t){this.webMap.setZoom(t)}toString(t){return String(t)}parse(t){return Number(t)}}let g=0;const _={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0};class v{constructor(t){this.options=_,this.emitter=new i,this.keys=v.keys,this.runtimeParams=[],this.getPaintFunctions=v.getPaintFunctions,this.mapState=[f,L],this.id=g++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(_||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}getId(){return this.id}async create(){return this.getEventStatus("create")||(await this._setInitMapState(this.mapState),await this._setupMap(),this._emitStatusEvent("create",this)),this}setRuntimeParams(t){this.runtimeParams.push(t)}destroy(){this._removeEventListeners(),function(t){for(const e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()}getState(){const t={};return this._mapState.forEach((e=>{t[e.name]=e.getValue()})),t}getRuntimeParams(){const t={};return this._mapState.forEach((e=>{for(const s of this.runtimeParams){const i=s.get(e.name);if(void 0!==i){t[e.name]=e.parse(i);break}}})),t}getContainer(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){const t=document.getElementById(this.options.target);if(t)return t}}}setCursor(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)}getCursor(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();const t=this.getContainer();return t?t.style.cursor:void 0}setCenter(t){return this.mapAdapter.setCenter(t),this}getCenter(){return this.mapAdapter.getCenter()}getBounds(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()}getBoundsPolygon(){const t=this.getBounds();if(t){return o(t)}}setZoom(t){return this.mapAdapter.setZoom(t),this}getZoom(){const t=this.mapAdapter.getZoom();if("number"==typeof t)return t}zoomIn(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{const t=this.getZoom();if(void 0!==t){this.setZoom(t+1)}}}zoomOut(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{const t=this.getZoom();if(void 0!==t){this.setZoom(t-1)}}}setView(t,e){if(Array.isArray(t)){const s=t;this.mapAdapter.setView&&s&&a(e)?this.mapAdapter.setView(s,e):(s&&this.mapAdapter.setCenter(s),a(e)&&this.mapAdapter.setZoom(e))}else{const e=t;this.mapAdapter.setView&&this.mapAdapter.setView(e)}}fitBounds(t,e){return t.every((t=>a(t)))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this}getEventStatus(t){const e=this._eventsStatus[t];return null!=e&&e}onLoad(t="create"){return new Promise((e=>{this.getEventStatus(t)?e(this):this.emitter.once(t,(()=>{e(this)}))}))}onMapLoad(t){return new Promise((e=>{var s;const i=()=>{const s=this.mapAdapter;t&&t(s),s&&e(s)},r=null===(s=this.mapAdapter.isLoaded)||void 0===s||s;this.mapAdapter.map&&r?i():this.mapAdapter.emitter.once("create",(()=>{i()}))}))}getLayerAdapters(){return this.mapAdapter.layerAdapters}getLayerAdapter(t){return this.mapAdapter.layerAdapters[t]}locate(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:()=>({})}}stopGetCoordFromMapClick(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()}getCoordFromMapClick(){return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new h(((t,e,s)=>{const i=this.getCursor()||"grab";this._removeEventListeners({include:["click"]}),this.setCursor("crosshair");const r=()=>{this.setCursor(i),this._addEventsListeners({include:["click"]}),this.mapAdapter.emitter.off("click",o),this._coordFromMapClickPromise=void 0},o=e=>{r(),n(e),t(e.lngLat)};this.mapAdapter.emitter.once("click",o),s(r)})),this._coordFromMapClickPromise)}_emitStatusEvent(t,e){const s=t;this._eventsStatus[s]=!0,this.emitter.emit(s,e)}async _addLayerProviders(){}async _onLoadSync(){}async _setupMap(){if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return await this.mapAdapter.create(this.options),this._zoomToInitialExtent(),await this._addLayerProviders(),await this._onLoadSync(),this._emitStatusEvent("build-map",this.mapAdapter),this}_setTileJsonOptions(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),a(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),a(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),a(t.maxzoom)&&a(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)}_zoomToInitialExtent(){const{center:t,zoom:e,bounds:s}=this.options;this._extent?this.fitBounds(this._extent):t&&e?this.setView(t,e):s&&this.fitBounds(s)}_setInitMapState(t){for(const e of t){const t=new e(this);this._mapState.push(t);for(const e of this.runtimeParams){const s=e.get(t.name);if(void 0!==s){const e=t.parse(s);this._initMapState[t.name]=e,Object.defineProperty(this.options,t.name,{value:e,configurable:!0,enumerable:!0});break}}}}_addEventsListeners(t){let e=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(e=e.filter((e=>t.include.includes(e)))),e.forEach((t=>{this._mapEvents[t]=e=>{if(this.runtimeParams.length){const e=this._mapState.find((e=>e.event===t));if(e){const t=e.toString(e.getValue());this.runtimeParams.forEach((s=>{s.set(e.name,t)}))}}this._eventsStatus&&this.emitter.emit(t,e)};const e=this._mapEvents[t];e&&this.mapAdapter.emitter.on(t,e)}))}_removeEventListeners(t){let e=Object.entries(this._mapEvents);t&&t.include&&(e=e.filter((e=>t.include.includes(e[0])))),e.forEach((([t,e])=>{e&&this.mapAdapter.emitter.removeListener(t,e)}))}}v.keys=new class{constructor(){this.keyCodeAlias=new m,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}pressed(t){const e=this.keyCodeAlias[t];return!!e&&this.keys[e]}addKeyboardEventsListener(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))}removeKeyboardEventsListener(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))}keysPressed(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)}keysReleased(t){t.stopPropagation(),this.keys[t.keyCode]=!1}windowOnFocus(){this.keys={}}};class C extends v{constructor(t){super(t),this._layersIdCounter=1,this._layersOrderCounter=1,this._baselayers=[],this._layers={},this._selectedLayers=[];const e=this.options.tileJson;e&&this.emitter.once("build-map",(()=>this.addTileJsonLayer(e)))}async fitLayer(t,e){const s=this.getLayer(t),i=s&&(s.getBounds||s.getExtent);if(i){const t=await i.call(s);t&&this.fitBounds(t,e)}}isBaseLayer(t){const e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)}getBaseLayers(){const t=[];return this._baselayers.forEach((e=>{const s=this._layers[e];s&&t.push(s)})),t}getBaseLayersIds(){return this._baselayers}getLayer(t){return"string"==typeof t?this._layers[t]:t}getLayerId(t){const e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")}getLayers(){return Object.keys(this._layers)}allLayers(){return this._layers}orderedLayers(){return Object.values(this._layers).sort(((t,e)=>t.order&&e.order?t.order-e.order:0))}findLayer(t){for(const e in this._layers){const s=this._layers[e];if(t(s))return s}}isLayerVisible(t){const e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility}async addBaseLayer(t,e){return await this.addLayer(t,{...e,baselayer:!0},void 0)}async addLayer(t,e={},s){var i,r;const o=this._layersIdCounter++,n=a(s)?s:void 0!==e.order?e.order:this.reserveOrder();let h;"string"==typeof t?h=this.getLayerAdapter(t):"function"==typeof t?h=t:"then"in t&&(h=await t);const l=e;this._updateGeoJsonOptions(l);const d=null===(i=(e={id:String(o),order:n,...e}).visibility)||void 0===i||i;if(e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer){const t=this.options.onBeforeAddLayer({options:e,adapter:h});t&&(t.options&&(e=t.options),t.adapter&&(h=t.adapter))}if(void 0!==h){const t=new h(this.mapAdapter.map,e);let s;t.options={...e,...t.options},t.options.baselayer&&(e.baselayer=!0,e.order=0,t.options.order=0),t.options.id&&(s=String(t.options.id),this._layers[s]=t),this._emitLayerEvent("layer:preadd",s||"",t),await this.onMapLoad(),t.map=this.mapAdapter.map;const i=await t.addLayer(t.options);if(t.layer=i,t.id=t.options.id||String(o),t.options.id=t.id,e.baselayer&&(t.options.order=0),t.order=null!==(r=t.options.order)&&void 0!==r?r:n,s&&delete this._layers[s],s=String(t.id),this._layers[s])throw Error(`layer with id '${s}' already exist`);s&&(this._layers[s]=t,l.filter&&this.filterLayer(t,l.filter),e.baselayer&&this._baselayers.push(s),d&&await this.showLayer(s));const a=e.opacity;void 0!==a&&a<=1&&this.setLayerOpacity(t,a);const p=i&&(t.getBounds||t.getExtent);if(e.fit&&p){const e=await p.call(t);e&&await this.fitBounds(e)}return this._emitLayerEvent("layer:add",s,t),t}return Promise.reject("No adapter")}async addLayerFromAsyncAdapter(t,e,s){const i=s||void 0!==e.order?e.order:this.reserveOrder(),r=t(),o=await r;return o?this.addLayer(o,e,i):Promise.reject("No adapter")}removeLayers(t){for(const e in this._layers){let s=!0;t&&(s=t(e,this._layers[e])),s&&(this.removeLayer(e),delete this._layers[e])}}reserveOrder(){return this._layersOrderCounter++}removeOverlays(){this.removeLayers(((t,e)=>!(e&&e.options&&e.options.baselayer)))}removeLayer(t){const e=this.getLayer(t),s=e&&this.getLayerId(e);if(e&&s){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){const t=this._baselayers.indexOf(s);t&&this._baselayers.splice(t,1)}delete this._layers[s],this.emitter.emit("layer:remove",e)}}addGeoJsonLayer(t={},e){return(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=y(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)}addFeatureLayer(t={}){return this.addGeoJsonLayer(t)}addTileLayer(t,e){return this.addLayer("TILE",{...e,url:t})}addImageLayer(t,e){return this.addLayer("IMAGE",{...e,url:t})}showLayer(t,e={}){return this.toggleLayer(t,!0,e)}hideLayer(t,e={}){return this.toggleLayer(t,!1,e)}toggleLayer(t,e,s={}){const i=this.getLayer(t),r=void 0!==e?e:!(i&&i.options.visibility),o=void 0!==s.silent&&s.silent,a=async t=>{const e=String(t.id),s=r?"layer:show":"layer:hide";if(o||(this._emitLayerEvent(r?"layer:preshow":"layer:prehide",e,t),this._emitLayerEvent("layer:pretoggle",e,t)),r&&this.mapAdapter){const e=t.options.baselayer?0:t.options.order;if(t.options.baselayer&&this._baselayers.length){const e=this._baselayers.filter((e=>e!==t.id&&this.isLayerVisible(e)));for(const t of e)await this.hideLayer(t)}t.showLayer?await t.showLayer.call(t,t.layer):void 0!==t.layer&&await this.mapAdapter.showLayer(t.layer),void 0!==e&&this.mapAdapter.setLayerOrder(t.layer,e,this._layers)}else t.hideLayer?await t.hideLayer.call(t,t.layer):void 0!==t.layer&&await this.mapAdapter.hideLayer(t.layer);t.options.visibility=r,o||(this._emitLayerEvent(s,e,t),this._emitLayerEvent("layer:toggle",e,t))};return i&&i.options.visibility!==r?this.onMapLoad().then((()=>a(i))):Promise.resolve()}updateLayer(t){const e=this.getLayer(t);if(e){if(e.updateLayer)return Promise.resolve(e.updateLayer());if(this.isLayerVisible(e))return this.hideLayer(e,{silent:!0}).then((()=>this.showLayer(e,{silent:!0})))}return Promise.resolve()}setLayerOpacity(t,e){const s=this.getLayer(t);s&&(s.setOpacity?s.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(s.layer,e))}selectLayer(t,e){const s=this.getLayer(t);if(s){const t=s;t&&t.select&&t.select(e);const i=this.getLayerId(s);i&&this._selectedLayers.push(i)}}unSelectLayer(t,e){const s=this.getLayer(t);if(s){const t=s&&s;t.unselect&&t.unselect(e);const i=this.getLayerId(s);if(i){const t=this._selectedLayers.indexOf(i);-1!==t&&this._selectedLayers.splice(t,1)}}}unSelectLayers(){const t=Object.values(this.allLayers());let e;for(e of t)e.unselect&&e.unselect()}filterLayer(t,e){const s=this.getLayer(t);return s.filter?s.filter(e):[]}propertiesFilter(t,e,i){const r=this.getLayer(t);if(!r)return;const o=r;o.propertiesFilter?o.propertiesFilter(e,i):o.filter&&this.filterLayer(o,(t=>!t.feature||!t.feature.properties||s(t.feature.properties,e)))}removeLayerFilter(t){const e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((()=>!0))}setLayerData(t,e){const s=this.getLayer(t);if(s){if(s.setData)return s.setData(e);if(s.clearLayer&&s.addData)return s.clearLayer(),s.addData(e)}return Promise.resolve()}addLayerData(t,e){const s=this.getLayer(t);s.addData&&s.addData(e)}clearLayerData(t,e){const s=this.getLayer(t);s&&s.clearLayer&&s.clearLayer(e)}setLayerPaint(t,e){const s=this.getLayer(t);e&&s&&s.setPaint&&s.setPaint(e)}setLayerSelectedPaint(t,e){const s=this.getLayer(t);e&&s&&s.setSelectedPaint&&s.setSelectedPaint(e)}updateLayerPaint(t,e){const s=this.getLayer(t);e&&s&&s.updatePaint&&s.updatePaint(e)}updateLayerSelectedPaint(t,e){const s=this.getLayer(t);e&&s&&s.updateSelectedPaint&&s.updateSelectedPaint(e)}getAttributions(t){const e=[];for(const s in this._layers){const i=this._layers[s];let r=!(void 0===t.onlyVisible||t.onlyVisible)||i.options.visibility;if(r&&t.onlyBaselayer&&(r=this._baselayers.includes(s)),r){const t=i.options&&i.options.attribution;t&&e.push(t)}}return e}getActiveBaseLayer(){const t=this.getBaseLayers().find((t=>this.isLayerVisible(t)));if(t)return this.getLayer(t)}addTileJsonLayer(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})}_emitLayerEvent(t,e,s){const i=String(t);if(a(e)&&i.startsWith("layer:")){const t=i.replace("layer:","layer-"+e+":");this.emitter.emit(t,s)}this.emitter.emit(t,s)}async _onLayerClick(t){return this._emitLayerEvent("layer:click",t.layer.id||"",t),Promise.resolve(t)}async _onLayerSelect(t){return this._emitLayerEvent("layer:select",t.layer.id||"",t),Promise.resolve(t)}_updateGeoJsonOptions(t){const{onSelect:s,onLayerSelect:i,onClick:r,onLayerClick:o,onMouseOut:n,onMouseOver:h}=t,l=r||o;t.onClick=t=>(l&&l(t),this._onLayerClick(t)),t.onMouseOut=t=>{const e=t.layer.id;n&&n(t),a(e)&&this._emitLayerEvent("layer:mouseout",e,t)},t.onMouseOver=t=>{const e=t.layer.id;h&&h(t),a(e)&&this._emitLayerEvent("layer:mouseover",e,t)};const d=s||i;t.onSelect=t=>(d&&d(t),this._onLayerSelect(t)),t.nativePaint||(this.options.paint&&(t.paint=e(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=e(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))}}function w(t,e){const s=document.createElement("div");let i=!1;e.getStatus?i=e.getStatus():e.status&&(i=e.status);const r=e.title||"",o=e.html;function a(){r&&(s.title="string"==typeof r?r:i?r.on:r.off,s.setAttribute("aria-label",s.title))}function n(t){t instanceof HTMLElement?(s.innerHTML="",s.appendChild(t)):"string"==typeof t&&(s.innerHTML=t)}function h(){o&&("string"==typeof o||o instanceof HTMLElement?n(o):n(i?o.on:o.off),s.setAttribute("aria-label",s.title))}function l(t,e){t.split(" ").forEach((t=>{e?s.classList.add(t):s.classList.remove(t)}))}function d(){e.addClassOn&&l(e.addClassOn,i),e.addClassOff&&l(e.addClassOff,!i)}a(),h(),e.addClass&&l(e.addClass,!0),d();const p=t=>{void 0!==t&&(i=t),h(),a(),d()},c=t=>{if(i=void 0!==t?t:!i,e.onClick){const t=e.onClick(i);Promise.resolve(t).then((()=>p())).catch((()=>i=!i))}else p()},y=t({html:s,onClick:c});return y.onClick=c,y.changeStatus=p,y}class A extends C{constructor(){super(...arguments),this._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},this._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1}}async addControl(t,e,s){let i;if(e=null!=e?e:"top-left",i="string"==typeof t?this.getControl(t,s):t,i)return new Promise((t=>{this._setControlQueue(e,(async()=>{const s=await i,r=this.mapAdapter.addControl(s,e);t(r)}))}))}async createControl(t,e){if(await this.onLoad("build-map"),this.mapAdapter.createControl)return this.mapAdapter.createControl(t,e)}async createButtonControl(t){if(await this.onLoad("build-map"),this.mapAdapter.createButtonControl)return this.mapAdapter.createButtonControl(t)}async createToggleControl(t){return await this.onLoad("build-map"),this.mapAdapter.createToggleControl?this.mapAdapter.createToggleControl(t):this.mapAdapter.createButtonControl?w(this.mapAdapter.createButtonControl,t):void 0}removeControl(t){"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((t=>{this.mapAdapter.removeControl(t)}))}getControl(t,e){const s=this.mapAdapter.controlAdapters[t];if(s)return new s(e);{const s=A.controls[t];if(s)return s(this,e)}}getControlContainer(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()}_setControlQueue(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)}async _applyControls(t){if(this._loadControlQueue[t].length){this._isControlLoading[t]=!0;const e=this._loadControlQueue[t][0];await e(),this._loadControlQueue[t].splice(0,1),this._applyControls(t)}else this._isControlLoading[t]=!1}}A.controls={CONTROL:(t,e)=>t.createControl(e.control,e.options),BUTTON:(t,e)=>t.createButtonControl(e),TOGGLE:(t,e)=>t.createToggleControl(e)};const b={};function k(t){return b[t]}class P extends A{constructor(t){super(t),this._addControls(),b[this.id]=this}static get(t){return k(t)}async _addLayerProviders(){for await(const t of this._starterKits)if(t.getLayerAdapters){const e=await t.getLayerAdapters.call(t);if(e)for await(const t of e){const e=await t.createAdapter(this);e&&(this.mapAdapter.layerAdapters[t.name]=e)}}}async _onLoadSync(){for await(const e of this._starterKits)if(e.onLoadSync)try{await e.onLoadSync.call(e,this)}catch(t){console.error(t)}}_addControls(){this.options.controls&&this.options.controls.forEach((t=>{let e=t,s={};"string"==typeof t&&this.options.controlsOptions&&this.options.controlsOptions[t]&&(s=this.options.controlsOptions[t],void 0!==s.control&&(e=s.control));const{position:i,...r}=s;this.addControl(e,i||"top-left",r)})),this._emitStatusEvent("controls:create")}}async function E(t){return new P(t).onLoad()}export{P as WebMap,A as WebMapControls,C as WebMapLayers,v as WebMapMain,w as createToggleControl,E as createWebMap,d as detectGeometryType,l as findMostFrequentGeomType,k as getWebMap,y as updateGeoJsonAdapterOptions};
import{getBoundsFeature as t,defined as e,deepmerge as r,deprecatedMapClick as n}from"@nextgis/utils";import{isPaint as o,preparePaint as i}from"@nextgis/paint";import{propertiesFilter as s}from"@nextgis/properties-filter";import{EventEmitter as a}from"events";import u from"@nextgis/cancelable-promise";
/*! *****************************************************************************
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.
***************************************************************************** */var p=function(t,e){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)};function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var l=function(){return(l=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function h(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function d(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(a){i=[6,a],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function y(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function f(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=y(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}function m(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function v(t){var e;if("FeatureCollection"===t.type)e=m(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=m(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var g={polygon:"path",line:"path",point:"circle"},L={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function _(t){if(t.data){var e=L[v(t.data)],r=t.paint;r&&o(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":g[e]),t.type=t.type||e}return t}var b=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},w=function(){function t(){this.keyCodeAlias=new b,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),C=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),A=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return c(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(C),P=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return c(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(C);var k=0,O={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},S=function(){function o(t){this.options=O,this.emitter=new a,this.keys=o.keys,this.runtimeParams=[],this.getPaintFunctions=o.getPaintFunctions,this.mapState=[A,P],this.id=k++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=t.mapAdapter,this._starterKits=t.starterKits||[],t&&(this.options=r(O||{},t)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return o.prototype.getId=function(){return this.id},o.prototype.create=function(){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},o.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},o.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},o.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},o.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},o.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},o.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},o.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},o.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},o.prototype.getCenter=function(){return this.mapAdapter.getCenter()},o.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},o.prototype.getBoundsPolygon=function(){var e=this.getBounds();if(e)return t(e)},o.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},o.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},o.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},o.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},o.prototype.setView=function(t,r){if(Array.isArray(t)){var n=t;this.mapAdapter.setView&&n&&e(r)?this.mapAdapter.setView(n,r):(n&&this.mapAdapter.setCenter(n),e(r)&&this.mapAdapter.setZoom(r))}else{this.mapAdapter.setView&&this.mapAdapter.setView(t)}},o.prototype.fitBounds=function(t,r){return t.every((function(t){return e(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,r)),this},o.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},o.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},o.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},o.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},o.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},o.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},o.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},o.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new u((function(e,r,o){var i=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var s=function(){t.setCursor(i),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",a),t._coordFromMapClickPromise=void 0},a=function(t){s(),n(t),e(t.lngLat)};t.mapAdapter.emitter.once("click",a),o(s)})),this._coordFromMapClickPromise)},o.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},o.prototype._addLayerProviders=function(){return h(this,void 0,void 0,(function(){return d(this,(function(t){return[2]}))}))},o.prototype._onLoadSync=function(){return h(this,void 0,void 0,(function(){return d(this,(function(t){return[2]}))}))},o.prototype._setupMap=function(){return h(this,void 0,void 0,(function(){return d(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},o.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),e(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),e(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),e(t.maxzoom)&&e(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},o.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},o.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},o.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},o.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},o.keys=new w,o}(),E=function(t){function r(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return c(r,t),r.prototype.fitLayer=function(t,e){return h(this,void 0,void 0,(function(){var r,n,o;return d(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},r.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},r.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},r.prototype.getBaseLayersIds=function(){return this._baselayers},r.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},r.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},r.prototype.getLayers=function(){return Object.keys(this._layers)},r.prototype.allLayers=function(){return this._layers},r.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},r.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},r.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},r.prototype.addBaseLayer=function(t,e){return h(this,void 0,void 0,(function(){return d(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,l(l({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},r.prototype.addLayer=function(t,r,n){var o,i;return void 0===r&&(r={}),h(this,void 0,void 0,(function(){var s,a,u,p,c,h,y,f,m,v,g,L;return d(this,(function(d){switch(d.label){case 0:return s=this._layersIdCounter++,a=e(n)?n:void 0!==r.order?r.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(u=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(u=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:u=d.sent(),d.label=4;case 4:return this._updateGeoJsonOptions(p=r),r=l({id:String(s),order:a},r),c=null===(o=r.visibility)||void 0===o||o,r.visibility=!1,r.baselayer&&(r.order=0),this.options.onBeforeAddLayer&&(h=this.options.onBeforeAddLayer({options:r,adapter:u}))&&(h.options&&(r=h.options),h.adapter&&(u=h.adapter)),void 0===u?[3,12]:((y=new u(this.mapAdapter.map,r)).options=l(l({},r),y.options),y.options.baselayer&&(r.baselayer=!0,r.order=0,y.options.order=0),f=void 0,y.options.id&&(f=String(y.options.id),this._layers[f]=y),this._emitLayerEvent("layer:preadd",f||"",y),[4,this.onMapLoad()]);case 5:return d.sent(),y.map=this.mapAdapter.map,[4,y.addLayer(y.options)];case 6:if(m=d.sent(),y.layer=m,y.id=y.options.id||String(s),y.options.id=y.id,r.baselayer&&(y.options.order=0),y.order=null!==(i=y.options.order)&&void 0!==i?i:a,f&&delete this._layers[f],f=String(y.id),this._layers[f])throw Error("layer with id '".concat(f,"' already exist"));return f?(this._layers[f]=y,p.filter&&this.filterLayer(y,p.filter),r.baselayer&&this._baselayers.push(f),c?[4,this.showLayer(f)]:[3,8]):[3,8];case 7:d.sent(),d.label=8;case 8:return void 0!==(v=r.opacity)&&v<=1&&this.setLayerOpacity(y,v),g=m&&(y.getBounds||y.getExtent),r.fit&&g?[4,g.call(y)]:[3,11];case 9:return(L=d.sent())?[4,this.fitBounds(L)]:[3,11];case 10:d.sent(),d.label=11;case 11:return r.onAdded&&r.onAdded(y),this._emitLayerEvent("layer:add",f,y),[2,y];case 12:return[2,Promise.reject("No adapter")]}}))}))},r.prototype.addLayerFromAsyncAdapter=function(t,e,r){return h(this,void 0,void 0,(function(){var n,o;return d(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},r.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},r.prototype.reserveOrder=function(){return this._layersOrderCounter++},r.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},r.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},r.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=_(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},r.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},r.prototype.addTileLayer=function(t,e){return this.addLayer("TILE",l(l({},e),{url:t}))},r.prototype.addImageLayer=function(t,e){var r;return"string"==typeof t?r=t:(r=t.url,e=t),this.addLayer("IMAGE",l(l({},e),{url:r}))},r.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},r.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},r.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var o=this.getLayer(t),i=void 0!==e?e:!(o&&o.options.visibility),s=void 0!==r.silent&&r.silent;return o&&o.options.visibility!==i?this.onMapLoad().then((function(){return t=o,h(n,void 0,void 0,(function(){var e,r,n,o,a,u,p,c=this;return d(this,(function(l){switch(l.label){case 0:if(e=String(t.id),r=i?"layer:preshow":"layer:prehide",n=i?"layer:show":"layer:hide",s||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!i||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];a=this._baselayers.filter((function(e){return e!==t.id&&c.isLayerVisible(e)})),u=0,p=a,l.label=1;case 1:return u<p.length?[4,this.hideLayer(p[u])]:[3,4];case 2:l.sent(),l.label=3;case 3:return u++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return l.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:l.sent(),l.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return l.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:l.sent(),l.label=13;case 13:return t.options.visibility=i,s||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},r.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},r.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},r.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},r.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},r.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},r.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},r.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;o.propertiesFilter?o.propertiesFilter(e,r):o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||s(t.feature.properties,e)}))}},r.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},r.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},r.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},r.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},r.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},r.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},r.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},r.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},r.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},r.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},r.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},r.prototype._emitLayerEvent=function(t,r,n){var o=String(t);if(e(r)&&o.startsWith("layer:")){var i=o.replace("layer:","layer-"+r+":");this.emitter.emit(i,n)}this.emitter.emit(t,n)},r.prototype._onLayerClick=function(t){return h(this,void 0,void 0,(function(){return d(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},r.prototype._onLayerSelect=function(t){return h(this,void 0,void 0,(function(){return d(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},r.prototype._updateGeoJsonOptions=function(t){var r=this,n=t.onSelect,o=t.onLayerSelect,s=t.onMouseOut,a=t.onMouseOver,u=t.onClick||t.onLayerClick;t.onClick=function(t){return u&&u(t),r._onLayerClick(t)},t.onMouseOut=function(t){var n=t.layer.id;s&&s(t),e(n)&&r._emitLayerEvent("layer:mouseout",n,t)},t.onMouseOver=function(t){var n=t.layer.id;a&&a(t),e(n)&&r._emitLayerEvent("layer:mouseover",n,t)};var p=n||o;t.onSelect=function(t){return p&&p(t),r._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=i(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=i(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},r}(S);function x(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function p(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function c(){e.addClassOn&&p(e.addClassOn,n),e.addClassOff&&p(e.addClassOff,!n)}s(),u(),e.addClass&&p(e.addClass,!0),c();var l=function(t){void 0!==t&&(n=t),u(),s(),c()},h=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},d=t({html:r,onClick:h});return d.onClick=h,d.changeStatus=l,d}var M=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return c(e,t),e.prototype.addControl=function(t,e,r){return h(this,void 0,void 0,(function(){var n,o=this;return d(this,(function(i){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){o._setControlQueue(e,(function(){return h(o,void 0,void 0,(function(){var r,o;return d(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return h(this,void 0,void 0,(function(){return d(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,x(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return h(this,void 0,void 0,(function(){return d(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(E),B={};function z(t){return B[t]}var F=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),B[r.id]=r,r}return c(e,t),e.get=function(t){return z(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return h(this,void 0,void 0,(function(){var o,i,s,a,u,p,c,l,h,y;return d(this,(function(d){switch(d.label){case 0:d.trys.push([0,18,19,24]),o=f(this._starterKits),d.label=1;case 1:return[4,o.next()];case 2:return(i=d.sent()).done?[3,17]:(s=i.value).getLayerAdapters?[4,s.getLayerAdapters.call(s)]:[3,16];case 3:if(!(a=d.sent()))return[3,16];d.label=4;case 4:d.trys.push([4,10,11,16]),r=void 0,u=f(a),d.label=5;case 5:return[4,u.next()];case 6:return(p=d.sent()).done?[3,9]:[4,(c=p.value).createAdapter(this)];case 7:(l=d.sent())&&(this.mapAdapter.layerAdapters[c.name]=l),d.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return h=d.sent(),r={error:h},[3,16];case 11:return d.trys.push([11,,14,15]),p&&!p.done&&(n=u.return)?[4,n.call(u)]:[3,13];case 12:d.sent(),d.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=d.sent(),t={error:y},[3,24];case 19:return d.trys.push([19,,22,23]),i&&!i.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:d.sent(),d.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return h(this,void 0,void 0,(function(){var r,n,o,i,s;return d(this,(function(a){switch(a.label){case 0:a.trys.push([0,8,9,14]),r=f(this._starterKits),a.label=1;case 1:return[4,r.next()];case 2:if((n=a.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];a.label=3;case 3:return a.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return a.sent(),[3,6];case 5:return i=a.sent(),console.error(i),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return s=a.sent(),t={error:s},[3,14];case 9:return a.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:a.sent(),a.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(M);function T(t){return h(this,void 0,void 0,(function(){return d(this,(function(e){return[2,new F(t).onLoad()]}))}))}export{F as WebMap,M as WebMapControls,E as WebMapLayers,S as WebMapMain,x as createToggleControl,T as createWebMap,v as detectGeometryType,m as findMostFrequentGeomType,z as getWebMap,_ as updateGeoJsonAdapterOptions};
//# sourceMappingURL=webmap.esm-bundler.prod.js.map

@@ -15,3 +15,3 @@ var WebMap=function(t){"use strict";

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(a){i=[6,a],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}function u(t){return"function"==typeof t}var c={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){var r=e[0],n=e.slice(1),o=r;Array.isArray(r)&&(o=p(t,r));for(var i=n.splice(-1,n.length%2)[0],s=0;s<n.length-1;s+=2){if(n[s]===o)return n[s+1]}return i}};function p(t,e){var r=e[0],n=e.slice(1),o=c[r];if(o)return o(t,n)}function l(t){return function(e){return p(e,t)}}var f=["iconSize","iconAnchor"];function h(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,o="^".concat((n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")),"$").replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(t)}var d={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return h(t,e)},ilike:function(t,e){return h(t,e,!0)}};function y(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(3===(u=e).length&&"string"==typeof u[0]&&"string"==typeof u[1]){var r=e[0],n=e[1],o=e[2],i=d[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,o)}));return i(s,a)}return i(t[r],o)}return!1}return y(t,e);var u},o=e.filter((function(t){return Array.isArray(t)}));return"any"===r?o.some(n):o.every(n)}function v(t){var e={},r=[];return t.forEach((function(t){t&&(Array.isArray(t)?r.push(t):e=t)})),function(t){var o=r.find((function(e){return function(t,e){var r=n({},t.properties);return!!r&&(r.$id=t.id,y(r,e))}(t,e[0])}));return o?n(n({},e),o[1]):e}}function m(t,e,r){if(!t)throw new Error("paint is empty");var o=n({},e);if(u(t)){var i=function(n){var o=m(t(n),e,r);return o.type=t.type,o};return i.type=t.type,i}if(function(t){return!!Array.isArray(t)}(t))return function(n){return m(v(t)(n),e,r)};if("get-paint"===t.type){var s=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(t,r);s&&(o=m(s,e,r))}else{if("icon"===t.type)return t;var a=function(t){var e=!1,r={};for(var o in t)if(-1===f.indexOf(o)){var i=o,s=t[i];Array.isArray(s)&&(e=!0,r[i]=l(s))}if(e)return function(e){var o={};for(var i in r)o[i]=r[i](e);return n(n({},t),o)}}(t);if(a)return function(t){return m(a(t),e,r)};(o=n(n({},o),t)).fill=void 0===o.fill||o.fill,o.stroke=void 0!==o.stroke?o.stroke:!o.fill||!(!o.strokeColor&&!o.strokeOpacity)}return u(o)||("color"in o&&(o.strokeColor||(o.strokeColor=o.color),o.fillColor||(o.fillColor=o.color)),"opacity"in o&&(void 0===o.strokeOpacity&&(o.strokeOpacity=o.opacity),void 0===o.fillOpacity&&(o.fillOpacity=o.opacity))),o}function g(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function _(t){var e;if("FeatureCollection"===t.type)e=g(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=g(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var L={polygon:"path",line:"path",point:"circle"},b={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function w(t){if(t.data){var e=b[_(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":L[e]),t.type=t.type||e}return t}var C,P={exports:{}},O="object"==typeof Reflect?Reflect:null,A=O&&"function"==typeof O.apply?O.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};C=O&&"function"==typeof O.ownKeys?O.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var E=Number.isNaN||function(t){return t!=t};function k(){k.init.call(this)}P.exports=k,P.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}V(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&V(t,"error",e,r)}(t,o,{once:!0})}))},k.EventEmitter=k,k.prototype._events=void 0,k.prototype._eventsCount=0,k.prototype._maxListeners=void 0;var S=10;function x(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function M(t){return void 0===t._maxListeners?k.defaultMaxListeners:t._maxListeners}function j(t,e,r,n){var o,i,s,a;if(x(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=M(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function T(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function F(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=T.bind(n);return o.listener=r,n.wrapFn=o,o}function z(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):I(o,o.length)}function B(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function I(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function V(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}function R(t){return null!=t}function Z(t,e,r){void 0===r&&(r=!1);var n=t,o=e,i=Array.isArray(o),s=i&&[]||{};return i&&Array.isArray(o)?r?(s=s.concat(n=n||[]),o.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=Z(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(o).forEach((function(t){s[t]="object"==typeof o[t]&&o[t]&&"object"==typeof n[t]&&"object"==typeof o[t]?Z(n[t],o[t],r):o[t]}))),s}function G(t){return{type:"Polygon",coordinates:[N(t)]}}function N(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}Object.defineProperty(k,"defaultMaxListeners",{enumerable:!0,get:function(){return S},set:function(t){if("number"!=typeof t||t<0||E(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");S=t}}),k.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},k.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||E(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},k.prototype.getMaxListeners=function(){return M(this)},k.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)A(a,this,e);else{var u=a.length,c=I(a,u);for(r=0;r<u;++r)A(c[r],this,e)}return!0},k.prototype.on=k.prototype.addListener=function(t,e){return j(this,t,e,!1)},k.prototype.prependListener=function(t,e){return j(this,t,e,!0)},k.prototype.once=function(t,e){return x(e),this.on(t,F(this,t,e)),this},k.prototype.prependOnceListener=function(t,e){return x(e),this.prependListener(t,F(this,t,e)),this},k.prototype.off=k.prototype.removeListener=function(t,e){var r,n,o,i,s;if(x(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},k.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},k.prototype.listeners=function(t){return z(this,t,!0)},k.prototype.rawListeners=function(t){return z(this,t,!1)},k.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):B.call(t,e)},k.prototype.listenerCount=B,k.prototype.eventNames=function(){return this._eventsCount>0?C(this._events):[]};var J=function(t){function e(){var r=t.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),W=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return t=t||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=e(t);if(i)return i;var a=r(s.apply(this,n),t);return a},i}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),D=function(t){function e(){var r=t.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),H=function(t,e,r,n){try{t(r(n))}catch(o){e(o)}},K=0,Q=function(){function t(e,r){var n=this;this.id=K++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new J)}}));var o=[this._cancelPromise,new Promise((function(r,o){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,o(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&o.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new D)}}),r)}))),this._promise=Promise.race(o)}return t.createControl=function(t){return new W(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,o=e;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,o=new t((function(t,o){if(n._promise){var i=function(e){r?H(t,o,r,e):o(e)};n._promise.then((function(r){n._isCanceled?i(r):e?H(t,o,e,r):t(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new J),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new J:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(n){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=J,t.TimeoutError=D,t.PromiseControl=W,t}();Object.setPrototypeOf(Q.prototype,Promise.prototype);var U=Q,$=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},q=function(){function t(){this.keyCodeAlias=new $,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),X=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),Y=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return r(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(X),tt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return r(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(X);var et=0,rt={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},nt=function(){function t(e){this.options=rt,this.emitter=new P.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[Y,tt],this.id=et++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=Z(rt||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},t.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:G(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){if(Array.isArray(t)){var r=t;this.mapAdapter.setView&&r&&R(e)?this.mapAdapter.setView(r,e):(r&&this.mapAdapter.setCenter(r),R(e)&&this.mapAdapter.setZoom(e))}else{this.mapAdapter.setView&&this.mapAdapter.setView(t)}},t.prototype.fitBounds=function(t,e){return t.every((function(t){return R(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new U((function(e,r,n){var o=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var i=function(){t.setCursor(o),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){var r;i(),!(r=t).lngLat&&r.latLng&&(r.lngLat=[r.latLng.lng,r.latLng.lat]),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(i)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),R(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),R(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),R(t.maxzoom)&&R(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new q,t}(),ot=function(t){function e(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return r(e,t),e.prototype.fitLayer=function(t,e){return o(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},e.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},e.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},e.prototype.getBaseLayersIds=function(){return this._baselayers},e.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},e.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},e.prototype.getLayers=function(){return Object.keys(this._layers)},e.prototype.allLayers=function(){return this._layers},e.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},e.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},e.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},e.prototype.addBaseLayer=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,n(n({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},e.prototype.addLayer=function(t,e,r){var s,a;return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var o,u,c,p,l,f,h,d,y,v,m,g;return i(this,(function(i){switch(i.label){case 0:return o=this._layersIdCounter++,u=R(r)?r:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(c=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(c=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:c=i.sent(),i.label=4;case 4:return this._updateGeoJsonOptions(p=e),e=n({id:String(o),order:u},e),l=null===(s=e.visibility)||void 0===s||s,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(f=this.options.onBeforeAddLayer({options:e,adapter:c}))&&(f.options&&(e=f.options),f.adapter&&(c=f.adapter)),void 0===c?[3,12]:((h=new c(this.mapAdapter.map,e)).options=n(n({},e),h.options),h.options.baselayer&&(e.baselayer=!0,e.order=0,h.options.order=0),d=void 0,h.options.id&&(d=String(h.options.id),this._layers[d]=h),this._emitLayerEvent("layer:preadd",d||"",h),[4,this.onMapLoad()]);case 5:return i.sent(),h.map=this.mapAdapter.map,[4,h.addLayer(h.options)];case 6:if(y=i.sent(),h.layer=y,h.id=h.options.id||String(o),h.options.id=h.id,e.baselayer&&(h.options.order=0),h.order=null!==(a=h.options.order)&&void 0!==a?a:u,d&&delete this._layers[d],d=String(h.id),this._layers[d])throw Error("layer with id '".concat(d,"' already exist"));return d?(this._layers[d]=h,p.filter&&this.filterLayer(h,p.filter),e.baselayer&&this._baselayers.push(d),l?[4,this.showLayer(d)]:[3,8]):[3,8];case 7:i.sent(),i.label=8;case 8:return void 0!==(v=e.opacity)&&v<=1&&this.setLayerOpacity(h,v),m=y&&(h.getBounds||h.getExtent),e.fit&&m?[4,m.call(h)]:[3,11];case 9:return(g=i.sent())?[4,this.fitBounds(g)]:[3,11];case 10:i.sent(),i.label=11;case 11:return this._emitLayerEvent("layer:add",d,h),[2,h];case 12:return[2,Promise.reject("No adapter")]}}))}))},e.prototype.addLayerFromAsyncAdapter=function(t,e,r){return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},e.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},e.prototype.reserveOrder=function(){return this._layersOrderCounter++},e.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},e.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},e.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=w(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},e.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},e.prototype.addTileLayer=function(t,e){return this.addLayer("TILE",n(n({},e),{url:t}))},e.prototype.addImageLayer=function(t,e){return this.addLayer("IMAGE",n(n({},e),{url:t}))},e.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},e.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},e.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var s=this.getLayer(t),a=void 0!==e?e:!(s&&s.options.visibility),u=void 0!==r.silent&&r.silent;return s&&s.options.visibility!==a?this.onMapLoad().then((function(){return t=s,o(n,void 0,void 0,(function(){var e,r,n,o,s,c,p,l=this;return i(this,(function(i){switch(i.label){case 0:if(e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!a||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];s=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),c=0,p=s,i.label=1;case 1:return c<p.length?[4,this.hideLayer(p[c])]:[3,4];case 2:i.sent(),i.label=3;case 3:return c++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return i.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:i.sent(),i.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return i.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:i.sent(),i.label=13;case 13:return t.options.visibility=a,u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},e.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},e.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},e.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},e.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},e.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},e.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},e.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;o.propertiesFilter?o.propertiesFilter(e,r):o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||y(t.feature.properties,e)}))}},e.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},e.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},e.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},e.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},e.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},e.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},e.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},e.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},e.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},e.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},e.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},e.prototype._emitLayerEvent=function(t,e,r){var n=String(t);if(R(e)&&n.startsWith("layer:")){var o=n.replace("layer:","layer-"+e+":");this.emitter.emit(o,r)}this.emitter.emit(t,r)},e.prototype._onLayerClick=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._onLayerSelect=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,o=t.onMouseOut,i=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;o&&o(t),R(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;i&&i(t),R(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var a=r||n;t.onSelect=function(t){return a&&a(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=m(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=m(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},e}(nt);function it(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},f=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},h=t({html:r,onClick:f});return h.onClick=f,h.changeStatus=l,h}var st=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return r(e,t),e.prototype.addControl=function(t,e,r){return o(this,void 0,void 0,(function(){var n,s=this;return i(this,(function(a){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){s._setControlQueue(e,(function(){return o(s,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,it(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(ot),at={};function ut(t){return at[t]}var ct=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),at[r.id]=r,r}return r(e,t),e.get=function(t){return ut(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return o(this,void 0,void 0,(function(){var o,s,u,c,p,l,f,h,d,y;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,18,19,24]),o=a(this._starterKits),i.label=1;case 1:return[4,o.next()];case 2:return(s=i.sent()).done?[3,17]:(u=s.value).getLayerAdapters?[4,u.getLayerAdapters.call(u)]:[3,16];case 3:if(!(c=i.sent()))return[3,16];i.label=4;case 4:i.trys.push([4,10,11,16]),r=void 0,p=a(c),i.label=5;case 5:return[4,p.next()];case 6:return(l=i.sent()).done?[3,9]:[4,(f=l.value).createAdapter(this)];case 7:(h=i.sent())&&(this.mapAdapter.layerAdapters[f.name]=h),i.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return d=i.sent(),r={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l&&!l.done&&(n=p.return)?[4,n.call(p)]:[3,13];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=i.sent(),t={error:y},[3,24];case 19:return i.trys.push([19,,22,23]),s&&!s.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:i.sent(),i.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return o(this,void 0,void 0,(function(){var r,n,o,s,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,14]),r=a(this._starterKits),i.label=1;case 1:return[4,r.next()];case 2:if((n=i.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return i.sent(),[3,6];case 5:return s=i.sent(),console.error(s),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return u=i.sent(),t={error:u},[3,14];case 9:return i.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(st);return t.WebMap=ct,t.WebMapControls=st,t.WebMapLayers=ot,t.WebMapMain=nt,t.createToggleControl=it,t.createWebMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new ct(t).onLoad()]}))}))},t.detectGeometryType=_,t.findMostFrequentGeomType=g,t.getWebMap=ut,t.updateGeoJsonAdapterOptions=w,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
***************************************************************************** */var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(e){i(e)}}function a(t){try{u(n.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(a){i=[6,a],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=s(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}}function u(t){return null!=t}function c(t,e,r){void 0===r&&(r=!1);var n=t,o=e,i=Array.isArray(o),s=i&&[]||{};return i&&Array.isArray(o)?r?(s=s.concat(n=n||[]),o.forEach((function(t,e){void 0===s[e]?s[e]=t:"object"==typeof t?s[e]=c(n[e],t,r):-1===n.indexOf(t)&&s.push(t)}))):s=o:(n&&"object"==typeof n&&Object.keys(n).forEach((function(t){s[t]=n[t]})),Object.keys(o).forEach((function(t){s[t]="object"==typeof o[t]&&o[t]&&"object"==typeof n[t]&&"object"==typeof o[t]?c(n[t],o[t],r):o[t]}))),s}function p(t){return{type:"Polygon",coordinates:[l(t)]}}function l(t){var e=[t[0],t[1]];return[e,[t[2],t[1]],[t[2],t[3]],[t[0],t[3]],e]}function f(t){return"function"==typeof t}var h={get:function(t,e){return t.properties&&t.properties[e[0]]},match:function(t,e){var r=e[0],n=e.slice(1),o=r;Array.isArray(r)&&(o=d(t,r));for(var i=n.splice(-1,n.length%2)[0],s=0;s<n.length-1;s+=2){if(n[s]===o)return n[s+1]}return i}};function d(t,e){var r=e[0],n=e.slice(1),o=h[r];if(o)return o(t,n)}function y(t){return function(e){return d(e,t)}}var v=["iconSize","iconAnchor"];function m(t,e,r){if((e=String(e))===(t=String(t)))return!0;if(r&&e.toUpperCase()===t.toUpperCase())return!0;var n,o="^".concat((n=e,n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")),"$").replace(/%/g,".*").replace("_",".");return null!==new RegExp(o,r?"i":"").exec(t)}var g={gt:function(t,e){return t>e},lt:function(t,e){return t<e},ge:function(t,e){return t>=e},le:function(t,e){return t<=e},eq:function(t,e){return t===e},ne:function(t,e){return t!==e},in:function(t,e){return-1!==e.indexOf(t)},notin:function(t,e){return-1===e.indexOf(t)},like:function(t,e){return m(t,e)},ilike:function(t,e){return m(t,e,!0)}};function _(t,e){var r="string"==typeof e[0]?e[0]:"all",n=function(e){if(3===(u=e).length&&"string"==typeof u[0]&&"string"==typeof u[1]){var r=e[0],n=e[1],o=e[2],i=g[n];if(i){if(("like"===n||"ilike"===n)&&"string"==typeof r){var s="",a=r.replace(/^%?(\w+)%?$/,(function(e,n){return s=t[n],r.replace(n,o)}));return i(s,a)}return i(t[r],o)}return!1}return _(t,e);var u},o=e.filter((function(t){return Array.isArray(t)}));return"any"===r?o.some(n):o.every(n)}function L(t){var e={},r=[];return t.forEach((function(t){t&&(Array.isArray(t)?r.push(t):e=t)})),function(t){var o=r.find((function(e){return function(t,e){var r=n({},t.properties);return!!r&&(r.$id=t.id,_(r,e))}(t,e[0])}));return o?n(n({},e),o[1]):e}}function b(t,e,r){if(!t)throw new Error("paint is empty");var o=n({},e);if(f(t)){var i=function(n){var o=b(t(n),e,r);return o.type=t.type,o};return i.type=t.type,i}if(function(t){return!!Array.isArray(t)}(t))return function(n){return b(L(t)(n),e,r)};if("get-paint"===t.type){var s=function(t,e){if("function"==typeof t.from)return t.from(t.options);if("string"==typeof t.from&&e){var r=e[t.from];if(r)return r(t.options)}}(t,r);s&&(o=b(s,e,r))}else{if("icon"===t.type)return t;var a=function(t){var e=!1,r={};for(var o in t)if(-1===v.indexOf(o)){var i=o,s=t[i];Array.isArray(s)&&(e=!0,r[i]=y(s))}if(e)return function(e){var o={};for(var i in r)o[i]=r[i](e);return n(n({},t),o)}}(t);if(a)return function(t){return b(a(t),e,r)};(o=n(n({},o),t)).fill=void 0===o.fill||o.fill,o.stroke=void 0!==o.stroke?o.stroke:!o.fill||!(!o.strokeColor&&!o.strokeOpacity)}return f(o)||("color"in o&&(o.strokeColor||(o.strokeColor=o.color),o.fillColor||(o.fillColor=o.color)),"opacity"in o&&(void 0===o.strokeOpacity&&(o.strokeOpacity=o.opacity),void 0===o.fillOpacity&&(o.fillOpacity=o.opacity))),o}function w(t){for(var e,r={},n=0;n<t.length;n++)r[t[n]]=1+(r[t[n]]||0);for(var o in r){r[o]>((void 0!==e?r[e]:0)||0)&&(e=o)}return e}function C(t){var e;if("FeatureCollection"===t.type)e=w(t.features.map((function(t){return t.geometry.type})));else if("GeometryCollection"===t.type){e=w(t.geometries.map((function(t){return t.type})))}else e="Feature"===t.type?t.geometry.type:t.type;return e}var P={polygon:"path",line:"path",point:"circle"},A={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon"};function O(t){if(t.data){var e=A[C(t.data)],r=t.paint;r&&"[object Object]"===Object.prototype.toString.call(r)&&(r.type=r.type?r.type:"polygon"===e||"line"===e?"path":"html"in r||"className"in r?"icon":P[e]),t.type=t.type||e}return t}var E,k={exports:{}},S="object"==typeof Reflect?Reflect:null,x=S&&"function"==typeof S.apply?S.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};E=S&&"function"==typeof S.ownKeys?S.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var M=Number.isNaN||function(t){return t!=t};function j(){j.init.call(this)}k.exports=j,k.exports.once=function(t,e){return new Promise((function(r,n){function o(r){t.removeListener(e,i),n(r)}function i(){"function"==typeof t.removeListener&&t.removeListener("error",o),r([].slice.call(arguments))}N(t,e,i,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&N(t,"error",e,r)}(t,o,{once:!0})}))},j.EventEmitter=j,j.prototype._events=void 0,j.prototype._eventsCount=0,j.prototype._maxListeners=void 0;var T=10;function F(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function z(t){return void 0===t._maxListeners?j.defaultMaxListeners:t._maxListeners}function B(t,e,r,n){var o,i,s,a;if(F(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=z(t))>0&&s.length>o&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function I(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function V(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=I.bind(n);return o.listener=r,n.wrapFn=o,o}function R(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):G(o,o.length)}function Z(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function G(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function N(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function o(i){n.once&&t.removeEventListener(e,o),r(i)}))}}Object.defineProperty(j,"defaultMaxListeners",{enumerable:!0,get:function(){return T},set:function(t){if("number"!=typeof t||t<0||M(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");T=t}}),j.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},j.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||M(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},j.prototype.getMaxListeners=function(){return z(this)},j.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var i;if(e.length>0&&(i=e[0]),i instanceof Error)throw i;var s=new Error("Unhandled error."+(i?" ("+i.message+")":""));throw s.context=i,s}var a=o[t];if(void 0===a)return!1;if("function"==typeof a)x(a,this,e);else{var u=a.length,c=G(a,u);for(r=0;r<u;++r)x(c[r],this,e)}return!0},j.prototype.on=j.prototype.addListener=function(t,e){return B(this,t,e,!1)},j.prototype.prependListener=function(t,e){return B(this,t,e,!0)},j.prototype.once=function(t,e){return F(e),this.on(t,V(this,t,e)),this},j.prototype.prependOnceListener=function(t,e){return F(e),this.prependListener(t,V(this,t,e)),this},j.prototype.off=j.prototype.removeListener=function(t,e){var r,n,o,i,s;if(F(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},j.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},j.prototype.listeners=function(t){return R(this,t,!0)},j.prototype.rawListeners=function(t){return R(this,t,!1)},j.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):Z.call(t,e)},j.prototype.listenerCount=Z,j.prototype.eventNames=function(){return this._eventsCount>0?E(this._events):[]};var J=function(t){function e(){var r=t.call(this)||this;return r.name="CancelError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),W=function(){function t(t){void 0===t&&(t={}),this.options=t,this._promises=new Map}return Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._promises.size>0},enumerable:!1,configurable:!0}),t.prototype.remove=function(t){this._promises.has(t)&&(this._promises.delete(t),this._onStop())},t.prototype.get=function(t){return this._promises.get(t)},t.prototype.add=function(t,e){var r=this,n=e||t,o=this._promises.get(n);return this.options.onStart&&!this.isLoaded&&this.options.onStart(),o||(this._promises.set(n,t),t.finally((function(){r.remove(n)})),t)},t.prototype.abort=function(){this.isLoaded&&(this._promises.forEach((function(t){t.cancel&&t.cancel()})),this._promises.clear(),this._onStop())},t.prototype.waitFunc=function(t,e){void 0===e&&(e="");var r=this.get(e=e||t.name);return r||this.add(t(),e)},t.prototype.WaitForMe=function(t){void 0===t&&(t="");var e=this.get.bind(this),r=this.add.bind(this);return function(n,o,i){var s=i.value;return t=t||o,i.value=function(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];var i=e(t);if(i)return i;var a=r(s.apply(this,n),t);return a},i}},t.prototype.GetOrCreateDecorator=function(t){return void 0===t&&(t=""),this.WaitForMe(t)},t.prototype._onStop=function(){this.options.onStop&&!this.isLoaded&&this.options.onStop()},t}(),D=function(t){function e(){var r=t.call(this)||this;return r.name="TimeoutError",Object.setPrototypeOf(r,e.prototype),r}return r(e,t),e}(Error),H=function(t,e,r,n){try{t(r(n))}catch(o){e(o)}},K=0,Q=function(){function t(e,r){var n=this;this.id=K++,this._isCanceled=!1,this._isPending=!0,this._cancelHandlers=[],this._children=[],this._cancelPromise=new Promise((function(t,e){n._setCanceledCallback=function(e){return t(e||new J)}}));var o=[this._cancelPromise,new Promise((function(r,o){return e((function(e){e instanceof t?n.attach(e):n._isPending=!1,r(e)}),(function(t){n._isPending=!1,o(t)}),(function(t){if(!n._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");n._cancelHandlers.push(t)}))}))];r&&o.push(new Promise((function(t,e){setTimeout((function(){if(n._isPending)try{n.cancel()}finally{e(new D)}}),r)}))),this._promise=Promise.race(o)}return t.createControl=function(t){return new W(t)},t.resolve=function(e){return new t((function(t){return t(e)}))},t.reject=function(e){return new t((function(t,r){return r(e)}))},t.all=function(e){var r=this;return new t((function(t,r){Promise.all(e).then(t).catch(r)})).catch((function(t){if(t instanceof r.CancelError)for(var n=0,o=e;n<o.length;n++){var i=o[n];"cancel"in i&&i.cancel()}throw t}))},t.prototype.attach=function(t){this._isCanceled?t.cancel():this._children.push(t)},t.prototype.then=function(e,r){var n=this,o=new t((function(t,o){if(n._promise){var i=function(e){r?H(t,o,r,e):o(e)};n._promise.then((function(r){n._isCanceled?i(r):e?H(t,o,e,r):t(r)}),i)}}));return o._parentPromise=this,this._children.push(o),o},t.prototype.catch=function(t){return this._isCanceled&&t&&t(new J),this.then(void 0,t)},t.prototype.finally=function(t){return this._promise?this._promise.finally(t):Promise.reject(this._isCanceled?new J:t)},t.prototype.cancel=function(){if(this._isCanceled||!this._isPending)return this;this._isCanceled=!0;var t=this._getTopParent();if(t&&t.cancel(),this._children&&this._children.forEach((function(t){return t.cancel()})),this._isPending){if(this._cancelHandlers.length)try{for(var e=0,r=this._cancelHandlers;e<r.length;e++){(0,r[e])()}}catch(n){}this._setCanceledCallback&&this._setCanceledCallback()}return this._destroy(),this},t.prototype._getTopParent=function(){for(var t=this._parentPromise,e=!!t;e;)e=!(!t||!t._parentPromise)&&!!(t=t._parentPromise);return t},t.prototype._destroy=function(){this._setCanceledCallback=void 0,this._cancelPromise=void 0,this._promise=void 0},t.CancelError=J,t.TimeoutError=D,t.PromiseControl=W,t}();Object.setPrototypeOf(Q.prototype,Promise.prototype);var U=Q,$=function(){this.backspace=8,this.tab=9,this.enter=13,this.shift=16,this.ctrl=17,this.alt=18,this["pause/break"]=19,this.caps_lock=20,this.escape=27,this.page_up=33,this.page_down=34,this.end=35,this.home=36,this.left_arrow=37,this.up_arrow=38,this.right_arrow=39,this.down_arrow=40,this.insert=45,this.delete=46,this.left_window_key=91,this.right_window_key=92,this.select_key=93,this.numpad_0=96,this.numpad_1=97,this.numpad_2=98,this.numpad_3=99,this.numpad_4=100,this.numpad_5=101,this.numpad_6=102,this.numpad_7=103,this.numpad_8=104,this.numpad_9=105,this.multiply=106,this.add=107,this.subtract=109,this.decimal_point=110,this.divide=111,this.f1=112,this.f2=113,this.f3=114,this.f4=115,this.f5=116,this.f6=117,this.f7=118,this.f8=119,this.f9=120,this.f10=121,this.f11=122,this.f12=123,this.num_lock=144,this.scroll_lock=145,this["semi-colon"]=186,this.equal_sign=187,this[","]=188,this["-"]=189,this["."]=190,this["/"]=191,this["`"]=192,this["["]=219,this["\\"]=220,this["]"]=221,this["'"]=222},q=function(){function t(){this.keyCodeAlias=new $,this.keys={},this._windowOnFocus=this.windowOnFocus.bind(this),this._keysPressed=this.keysPressed.bind(this),this._keysReleased=this.keysReleased.bind(this),this.addKeyboardEventsListener()}return t.prototype.pressed=function(t){var e=this.keyCodeAlias[t];return!!e&&this.keys[e]},t.prototype.addKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.addEventListener("focus",this._windowOnFocus,!1),window.addEventListener("keydown",this._keysPressed,!1),window.addEventListener("keyup",this._keysReleased,!1))},t.prototype.removeKeyboardEventsListener=function(){"undefined"!=typeof window&&(window.removeEventListener("focus",this._windowOnFocus,!1),window.removeEventListener("keydown",this._keysPressed,!1),window.removeEventListener("keyup",this._keysReleased,!1))},t.prototype.keysPressed=function(t){t.stopPropagation(),this.keys[t.keyCode]||(this.keys[t.keyCode]=!0)},t.prototype.keysReleased=function(t){t.stopPropagation(),this.keys[t.keyCode]=!1},t.prototype.windowOnFocus=function(){this.keys={}},t}(),X=function(){function t(t,e){this.webMap=t,e&&(e.value&&this.setValue(e.value),e.name&&(this.name=e.name),e.event&&(this.event=e.event))}return t.prototype.getValue=function(){return this.value},t.prototype.setValue=function(t){this.value=t},t}(),Y=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="center",e.event="moveend",e}return r(e,t),e.prototype.getValue=function(){return this.webMap.getCenter()},e.prototype.setValue=function(t){this.webMap.setCenter(t)},e.prototype.toString=function(t){var e=t.map((function(t){return t.toFixed(5)}));return e[0]+"_"+e[1]},e.prototype.parse=function(t){return t.split("_").map(Number)},e}(X),tt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="zoom",e.event="zoomend",e}return r(e,t),e.prototype.getValue=function(){var t=this.webMap.getZoom();return void 0!==t?Math.round(t):void 0},e.prototype.setValue=function(t){this.webMap.setZoom(t)},e.prototype.toString=function(t){return String(t)},e.prototype.parse=function(t){return Number(t)},e}(X);var et=0,rt={minZoom:0,maxZoom:20,paint:{color:"#0000ff",opacity:.4,strokeOpacity:1,stroke:!0,radius:8,weight:1},selectedPaint:{color:"#00008b",opacity:.4,strokeOpacity:1,stroke:!0,radius:12,weight:1},create:!0},nt=function(){function t(e){this.options=rt,this.emitter=new k.exports.EventEmitter,this.keys=t.keys,this.runtimeParams=[],this.getPaintFunctions=t.getPaintFunctions,this.mapState=[Y,tt],this.id=et++,this._initMapState={},this._mapState=[],this._eventsStatus={},this._mapEvents={},this.mapAdapter=e.mapAdapter,this._starterKits=e.starterKits||[],e&&(this.options=c(rt||{},e)),this.options.runtimeParams&&(this.runtimeParams=this.options.runtimeParams),this._addEventsListeners(),this.options.tileJson&&this._setTileJsonOptions(this.options.tileJson),this.options.create&&this.create()}return t.prototype.getId=function(){return this.id},t.prototype.create=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.getEventStatus("create")?[3,3]:[4,this._setInitMapState(this.mapState)];case 1:return t.sent(),[4,this._setupMap()];case 2:t.sent(),this._emitStatusEvent("create",this),t.label=3;case 3:return[2,this]}}))}))},t.prototype.setRuntimeParams=function(t){this.runtimeParams.push(t)},t.prototype.destroy=function(){this._removeEventListeners(),function(t){for(var e in t)delete t[e]}(this._emitStatusEvent),this.mapAdapter.destroy&&this.mapAdapter.destroy()},t.prototype.getState=function(){var t={};return this._mapState.forEach((function(e){t[e.name]=e.getValue()})),t},t.prototype.getRuntimeParams=function(){var t=this,e={};return this._mapState.forEach((function(r){for(var n=0,o=t.runtimeParams;n<o.length;n++){var i=o[n].get(r.name);if(void 0!==i){e[r.name]=r.parse(i);break}}})),e},t.prototype.getContainer=function(){if(this.mapAdapter.getContainer)return this.mapAdapter.getContainer();if(this.options.target){if(this.options.target instanceof HTMLElement)return this.options.target;if("string"==typeof this.options.target){var t=document.getElementById(this.options.target);if(t)return t}}},t.prototype.setCursor=function(t){this.mapAdapter.setCursor&&this.mapAdapter.setCursor(t)},t.prototype.getCursor=function(){if(this.mapAdapter.getCursor)return this.mapAdapter.getCursor();var t=this.getContainer();return t?t.style.cursor:void 0},t.prototype.setCenter=function(t){return this.mapAdapter.setCenter(t),this},t.prototype.getCenter=function(){return this.mapAdapter.getCenter()},t.prototype.getBounds=function(){if(this.mapAdapter.getBounds)return this.mapAdapter.getBounds()},t.prototype.getBoundsPolygon=function(){var t=this.getBounds();if(t)return{type:"Feature",properties:{},geometry:p(t)}},t.prototype.setZoom=function(t){return this.mapAdapter.setZoom(t),this},t.prototype.getZoom=function(){var t=this.mapAdapter.getZoom();if("number"==typeof t)return t},t.prototype.zoomIn=function(){if(this.mapAdapter.zoomIn)this.mapAdapter.zoomIn();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t+1)}},t.prototype.zoomOut=function(){if(this.mapAdapter.zoomOut)this.mapAdapter.zoomOut();else{var t=this.getZoom();if(void 0!==t)this.setZoom(t-1)}},t.prototype.setView=function(t,e){if(Array.isArray(t)){var r=t;this.mapAdapter.setView&&r&&u(e)?this.mapAdapter.setView(r,e):(r&&this.mapAdapter.setCenter(r),u(e)&&this.mapAdapter.setZoom(e))}else{this.mapAdapter.setView&&this.mapAdapter.setView(t)}},t.prototype.fitBounds=function(t,e){return t.every((function(t){return u(t)}))&&(t[1]<-85.06&&(t[1]=-85.06),t[3]>85.06&&(t[3]=85.06),this.mapAdapter.fitBounds(t,e)),this},t.prototype.getEventStatus=function(t){var e=this._eventsStatus[t];return null!=e&&e},t.prototype.onLoad=function(t){var e=this;return void 0===t&&(t="create"),new Promise((function(r){e.getEventStatus(t)?r(e):e.emitter.once(t,(function(){r(e)}))}))},t.prototype.onMapLoad=function(t){var e=this;return new Promise((function(r){var n,o=function(){var n=e.mapAdapter;t&&t(n),n&&r(n)},i=null===(n=e.mapAdapter.isLoaded)||void 0===n||n;e.mapAdapter.map&&i?o():e.mapAdapter.emitter.once("create",(function(){o()}))}))},t.prototype.getLayerAdapters=function(){return this.mapAdapter.layerAdapters},t.prototype.getLayerAdapter=function(t){return this.mapAdapter.layerAdapters[t]},t.prototype.locate=function(t,e){if(this.mapAdapter&&this.mapAdapter.locate)return this.mapAdapter.locate(t,e);return{stop:function(){return{}}}},t.prototype.stopGetCoordFromMapClick=function(){this._coordFromMapClickPromise&&this._coordFromMapClickPromise.cancel()},t.prototype.getCoordFromMapClick=function(){var t=this;return this._coordFromMapClickPromise?this.getCoordFromMapClick():(this._coordFromMapClickPromise=new U((function(e,r,n){var o=t.getCursor()||"grab";t._removeEventListeners({include:["click"]}),t.setCursor("crosshair");var i=function(){t.setCursor(o),t._addEventsListeners({include:["click"]}),t.mapAdapter.emitter.off("click",s),t._coordFromMapClickPromise=void 0},s=function(t){var r;i(),!(r=t).lngLat&&r.latLng&&(r.lngLat=[r.latLng.lng,r.latLng.lat]),e(t.lngLat)};t.mapAdapter.emitter.once("click",s),n(i)})),this._coordFromMapClickPromise)},t.prototype._emitStatusEvent=function(t,e){var r=t;this._eventsStatus[r]=!0,this.emitter.emit(r,e)},t.prototype._addLayerProviders=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._onLoadSync=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2]}))}))},t.prototype._setupMap=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:if(!this.mapAdapter)throw new Error("WebMap `mapAdapter` option is not set");return[4,this.mapAdapter.create(this.options)];case 1:return t.sent(),this._zoomToInitialExtent(),[4,this._addLayerProviders()];case 2:return t.sent(),[4,this._onLoadSync()];case 3:return t.sent(),this._emitStatusEvent("build-map",this.mapAdapter),[2,this]}}))}))},t.prototype._setTileJsonOptions=function(t){t.center&&(this.options.center=t.center),t.bounds&&(this.options.bounds=t.bounds),u(t.maxzoom)&&(this.options.maxZoom=t.maxzoom,this.options.zoom=t.maxzoom),u(t.minzoom)&&(this.options.minZoom=t.minzoom,this.options.zoom=t.minzoom),u(t.maxzoom)&&u(t.minzoom)&&(this.options.zoom=(t.maxzoom+t.minzoom)/2)},t.prototype._zoomToInitialExtent=function(){var t=this.options,e=t.center,r=t.zoom,n=t.bounds;this._extent?this.fitBounds(this._extent):e&&r?this.setView(e,r):n&&this.fitBounds(n)},t.prototype._setInitMapState=function(t){for(var e=0,r=t;e<r.length;e++){var n=new(0,r[e])(this);this._mapState.push(n);for(var o=0,i=this.runtimeParams;o<i.length;o++){var s=i[o].get(n.name);if(void 0!==s){var a=n.parse(s);this._initMapState[n.name]=a,Object.defineProperty(this.options,n.name,{value:a,configurable:!0,enumerable:!0});break}}}},t.prototype._addEventsListeners=function(t){var e=this,r=["preclick","click","zoomstart","zoom","zoomend","movestart","move","moveend"];t&&t.include&&(r=r.filter((function(e){return t.include.includes(e)}))),r.forEach((function(t){e._mapEvents[t]=function(r){if(e.runtimeParams.length){var n=e._mapState.find((function(e){return e.event===t}));if(n){var o=n.toString(n.getValue());e.runtimeParams.forEach((function(t){t.set(n.name,o)}))}}e._eventsStatus&&e.emitter.emit(t,r)};var r=e._mapEvents[t];r&&e.mapAdapter.emitter.on(t,r)}))},t.prototype._removeEventListeners=function(t){var e=this,r=Object.entries(this._mapEvents);t&&t.include&&(r=r.filter((function(e){return t.include.includes(e[0])}))),r.forEach((function(t){var r=t[1];r&&e.mapAdapter.emitter.removeListener(t[0],r)}))},t.keys=new q,t}(),ot=function(t){function e(e){var r=t.call(this,e)||this;r._layersIdCounter=1,r._layersOrderCounter=1,r._baselayers=[],r._layers={},r._selectedLayers=[];var n=r.options.tileJson;return n&&r.emitter.once("build-map",(function(){return r.addTileJsonLayer(n)})),r}return r(e,t),e.prototype.fitLayer=function(t,e){return o(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=this.getLayer(t),(n=r&&(r.getBounds||r.getExtent))?[4,n.call(r)]:[3,2];case 1:(o=i.sent())&&this.fitBounds(o,e),i.label=2;case 2:return[2]}}))}))},e.prototype.isBaseLayer=function(t){var e=this.getLayer(t);if(e&&e.id)return-1!==this._baselayers.indexOf(e.id)},e.prototype.getBaseLayers=function(){var t=this,e=[];return this._baselayers.forEach((function(r){var n=t._layers[r];n&&e.push(n)})),e},e.prototype.getBaseLayersIds=function(){return this._baselayers},e.prototype.getLayer=function(t){return"string"==typeof t?this._layers[t]:t},e.prototype.getLayerId=function(t){var e=this.getLayer(t);if(e){if(e.id)return null==e?void 0:e.id;if(e&&e.options)return e.options.id}throw new Error("No id for layer")},e.prototype.getLayers=function(){return Object.keys(this._layers)},e.prototype.allLayers=function(){return this._layers},e.prototype.orderedLayers=function(){return Object.values(this._layers).sort((function(t,e){return t.order&&e.order?t.order-e.order:0}))},e.prototype.findLayer=function(t){for(var e in this._layers){var r=this._layers[e];if(t(r))return r}},e.prototype.isLayerVisible=function(t){var e=this.getLayer(t);return!(!e||void 0===e.options.visibility)&&e.options.visibility},e.prototype.addBaseLayer=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.addLayer(t,n(n({},e),{baselayer:!0}),void 0)];case 1:return[2,r.sent()]}}))}))},e.prototype.addLayer=function(t,e,r){var s,a;return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var o,c,p,l,f,h,d,y,v,m,g,_;return i(this,(function(i){switch(i.label){case 0:return o=this._layersIdCounter++,c=u(r)?r:void 0!==e.order?e.order:this.reserveOrder(),"string"!=typeof t?[3,1]:(p=this.getLayerAdapter(t),[3,4]);case 1:return"function"!=typeof t?[3,2]:(p=t,[3,4]);case 2:return"then"in t?[4,t]:[3,4];case 3:p=i.sent(),i.label=4;case 4:return this._updateGeoJsonOptions(l=e),e=n({id:String(o),order:c},e),f=null===(s=e.visibility)||void 0===s||s,e.visibility=!1,e.baselayer&&(e.order=0),this.options.onBeforeAddLayer&&(h=this.options.onBeforeAddLayer({options:e,adapter:p}))&&(h.options&&(e=h.options),h.adapter&&(p=h.adapter)),void 0===p?[3,12]:((d=new p(this.mapAdapter.map,e)).options=n(n({},e),d.options),d.options.baselayer&&(e.baselayer=!0,e.order=0,d.options.order=0),y=void 0,d.options.id&&(y=String(d.options.id),this._layers[y]=d),this._emitLayerEvent("layer:preadd",y||"",d),[4,this.onMapLoad()]);case 5:return i.sent(),d.map=this.mapAdapter.map,[4,d.addLayer(d.options)];case 6:if(v=i.sent(),d.layer=v,d.id=d.options.id||String(o),d.options.id=d.id,e.baselayer&&(d.options.order=0),d.order=null!==(a=d.options.order)&&void 0!==a?a:c,y&&delete this._layers[y],y=String(d.id),this._layers[y])throw Error("layer with id '".concat(y,"' already exist"));return y?(this._layers[y]=d,l.filter&&this.filterLayer(d,l.filter),e.baselayer&&this._baselayers.push(y),f?[4,this.showLayer(y)]:[3,8]):[3,8];case 7:i.sent(),i.label=8;case 8:return void 0!==(m=e.opacity)&&m<=1&&this.setLayerOpacity(d,m),g=v&&(d.getBounds||d.getExtent),e.fit&&g?[4,g.call(d)]:[3,11];case 9:return(_=i.sent())?[4,this.fitBounds(_)]:[3,11];case 10:i.sent(),i.label=11;case 11:return e.onAdded&&e.onAdded(d),this._emitLayerEvent("layer:add",y,d),[2,d];case 12:return[2,Promise.reject("No adapter")]}}))}))},e.prototype.addLayerFromAsyncAdapter=function(t,e,r){return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=r||void 0!==e.order?e.order:this.reserveOrder(),[4,t()];case 1:return(o=i.sent())?[2,this.addLayer(o,e,n)]:[2,Promise.reject("No adapter")]}}))}))},e.prototype.removeLayers=function(t){for(var e in this._layers){var r=!0;t&&(r=t(e,this._layers[e])),r&&(this.removeLayer(e),delete this._layers[e])}},e.prototype.reserveOrder=function(){return this._layersOrderCounter++},e.prototype.removeOverlays=function(){this.removeLayers((function(t,e){return!(e&&e.options&&e.options.baselayer)}))},e.prototype.removeLayer=function(t){var e=this.getLayer(t),r=e&&this.getLayerId(e);if(e&&r){if(this.emitter.emit("layer:preremove",e),e.beforeRemove&&e.beforeRemove(),e.removeLayer?e.removeLayer():this.mapAdapter.removeLayer(e.layer),e.options&&e.options.baselayer){var n=this._baselayers.indexOf(r);n&&this._baselayers.splice(n,1)}delete this._layers[r],this.emitter.emit("layer:remove",e)}},e.prototype.addGeoJsonLayer=function(t,e){return void 0===t&&(t={}),(t=t||{}).multiselect=void 0!==t.multiselect&&t.multiselect,t.unselectOnSecondClick=void 0===t.unselectOnSecondClick||t.unselectOnSecondClick,e||(t=O(t)),t.paint=t.paint||{},this.addLayer(e||"GEOJSON",t)},e.prototype.addFeatureLayer=function(t){return void 0===t&&(t={}),this.addGeoJsonLayer(t)},e.prototype.addTileLayer=function(t,e){return this.addLayer("TILE",n(n({},e),{url:t}))},e.prototype.addImageLayer=function(t,e){var r;return"string"==typeof t?r=t:(r=t.url,e=t),this.addLayer("IMAGE",n(n({},e),{url:r}))},e.prototype.showLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!0,e)},e.prototype.hideLayer=function(t,e){return void 0===e&&(e={}),this.toggleLayer(t,!1,e)},e.prototype.toggleLayer=function(t,e,r){var n=this;void 0===r&&(r={});var s=this.getLayer(t),a=void 0!==e?e:!(s&&s.options.visibility),u=void 0!==r.silent&&r.silent;return s&&s.options.visibility!==a?this.onMapLoad().then((function(){return t=s,o(n,void 0,void 0,(function(){var e,r,n,o,s,c,p,l=this;return i(this,(function(i){switch(i.label){case 0:if(e=String(t.id),r=a?"layer:preshow":"layer:prehide",n=a?"layer:show":"layer:hide",u||(this._emitLayerEvent(r,e,t),this._emitLayerEvent("layer:pretoggle",e,t)),!a||!this.mapAdapter)return[3,9];if(o=t.options.baselayer?0:t.options.order,!t.options.baselayer||!this._baselayers.length)return[3,4];s=this._baselayers.filter((function(e){return e!==t.id&&l.isLayerVisible(e)})),c=0,p=s,i.label=1;case 1:return c<p.length?[4,this.hideLayer(p[c])]:[3,4];case 2:i.sent(),i.label=3;case 3:return c++,[3,1];case 4:return t.showLayer?[4,t.showLayer.call(t,t.layer)]:[3,6];case 5:return i.sent(),[3,8];case 6:return void 0===t.layer?[3,8]:[4,this.mapAdapter.showLayer(t.layer)];case 7:i.sent(),i.label=8;case 8:return void 0!==o&&this.mapAdapter.setLayerOrder(t.layer,o,this._layers),[3,13];case 9:return t.hideLayer?[4,t.hideLayer.call(t,t.layer)]:[3,11];case 10:return i.sent(),[3,13];case 11:return void 0===t.layer?[3,13]:[4,this.mapAdapter.hideLayer(t.layer)];case 12:i.sent(),i.label=13;case 13:return t.options.visibility=a,u||(this._emitLayerEvent(n,e,t),this._emitLayerEvent("layer:toggle",e,t)),[2]}}))}));var t})):Promise.resolve()},e.prototype.updateLayer=function(t){var e=this,r=this.getLayer(t);if(r){if(r.updateLayer)return Promise.resolve(r.updateLayer());if(this.isLayerVisible(r))return this.hideLayer(r,{silent:!0}).then((function(){return e.showLayer(r,{silent:!0})}))}return Promise.resolve()},e.prototype.setLayerOpacity=function(t,e){var r=this.getLayer(t);r&&(r.setOpacity?r.setOpacity(e):this.mapAdapter.setLayerOpacity&&this.mapAdapter.setLayerOpacity(r.layer,e))},e.prototype.selectLayer=function(t,e){var r=this.getLayer(t);if(r){r&&r.select&&r.select(e);var n=this.getLayerId(r);n&&this._selectedLayers.push(n)}},e.prototype.unSelectLayer=function(t,e){var r=this.getLayer(t);if(r){var n=r&&r;n.unselect&&n.unselect(e);var o=this.getLayerId(r);if(o){var i=this._selectedLayers.indexOf(o);-1!==i&&this._selectedLayers.splice(i,1)}}},e.prototype.unSelectLayers=function(){for(var t,e=0,r=Object.values(this.allLayers());e<r.length;e++)(t=r[e]).unselect&&t.unselect()},e.prototype.filterLayer=function(t,e){var r=this.getLayer(t);return r.filter?r.filter(e):[]},e.prototype.propertiesFilter=function(t,e,r){var n=this.getLayer(t);if(n){var o=n;o.propertiesFilter?o.propertiesFilter(e,r):o.filter&&this.filterLayer(o,(function(t){return!t.feature||!t.feature.properties||_(t.feature.properties,e)}))}},e.prototype.removeLayerFilter=function(t){var e=this.getLayer(t);e.removeFilter?e.removeFilter():e.filter&&e.filter((function(){return!0}))},e.prototype.setLayerData=function(t,e){var r=this.getLayer(t);if(r){if(r.setData)return r.setData(e);if(r.clearLayer&&r.addData)return r.clearLayer(),r.addData(e)}return Promise.resolve()},e.prototype.addLayerData=function(t,e){var r=this.getLayer(t);r.addData&&r.addData(e)},e.prototype.clearLayerData=function(t,e){var r=this.getLayer(t);r&&r.clearLayer&&r.clearLayer(e)},e.prototype.setLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setPaint&&r.setPaint(e)},e.prototype.setLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.setSelectedPaint&&r.setSelectedPaint(e)},e.prototype.updateLayerPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updatePaint&&r.updatePaint(e)},e.prototype.updateLayerSelectedPaint=function(t,e){var r=this.getLayer(t);e&&r&&r.updateSelectedPaint&&r.updateSelectedPaint(e)},e.prototype.getAttributions=function(t){var e=[];for(var r in this._layers){var n=this._layers[r],o=!(void 0===t.onlyVisible||t.onlyVisible)||n.options.visibility;if(o&&t.onlyBaselayer&&(o=this._baselayers.includes(r)),o){var i=n.options&&n.options.attribution;i&&e.push(i)}}return e},e.prototype.getActiveBaseLayer=function(){var t=this,e=this.getBaseLayers().find((function(e){return t.isLayerVisible(e)}));if(e)return this.getLayer(e)},e.prototype.addTileJsonLayer=function(t){return this.addLayer("TILE",{url:t.tiles[0],maxZoom:t.maxzoom,minZoom:t.minzoom,subdomains:t.scheme,attribution:t.attribution})},e.prototype._emitLayerEvent=function(t,e,r){var n=String(t);if(u(e)&&n.startsWith("layer:")){var o=n.replace("layer:","layer-"+e+":");this.emitter.emit(o,r)}this.emitter.emit(t,r)},e.prototype._onLayerClick=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:click",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._onLayerSelect=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return this._emitLayerEvent("layer:select",t.layer.id||"",t),[2,Promise.resolve(t)]}))}))},e.prototype._updateGeoJsonOptions=function(t){var e=this,r=t.onSelect,n=t.onLayerSelect,o=t.onMouseOut,i=t.onMouseOver,s=t.onClick||t.onLayerClick;t.onClick=function(t){return s&&s(t),e._onLayerClick(t)},t.onMouseOut=function(t){var r=t.layer.id;o&&o(t),u(r)&&e._emitLayerEvent("layer:mouseout",r,t)},t.onMouseOver=function(t){var r=t.layer.id;i&&i(t),u(r)&&e._emitLayerEvent("layer:mouseover",r,t)};var a=r||n;t.onSelect=function(t){return a&&a(t),e._onLayerSelect(t)},t.nativePaint||(this.options.paint&&(t.paint=b(t.paint||{},this.options.paint,this.getPaintFunctions)),t.selectedPaint&&this.options.selectedPaint&&(t.selectedPaint=b(t.selectedPaint,this.options.selectedPaint,this.getPaintFunctions)))},e}(nt);function it(t,e){var r=document.createElement("div"),n=!1;e.getStatus?n=e.getStatus():e.status&&(n=e.status);var o=e.title||"",i=e.html;function s(){o&&(r.title="string"==typeof o?o:n?o.on:o.off,r.setAttribute("aria-label",r.title))}function a(t){t instanceof HTMLElement?(r.innerHTML="",r.appendChild(t)):"string"==typeof t&&(r.innerHTML=t)}function u(){i&&("string"==typeof i||i instanceof HTMLElement?a(i):a(n?i.on:i.off),r.setAttribute("aria-label",r.title))}function c(t,e){t.split(" ").forEach((function(t){e?r.classList.add(t):r.classList.remove(t)}))}function p(){e.addClassOn&&c(e.addClassOn,n),e.addClassOff&&c(e.addClassOff,!n)}s(),u(),e.addClass&&c(e.addClass,!0),p();var l=function(t){void 0!==t&&(n=t),u(),s(),p()},f=function(t){if(n=void 0!==t?t:!n,e.onClick){var r=e.onClick(n);Promise.resolve(r).then((function(){return l()})).catch((function(){return n=!n}))}else l()},h=t({html:r,onClick:f});return h.onClick=f,h.changeStatus=l,h}var st=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._loadControlQueue={"top-right":[],"bottom-right":[],"top-left":[],"bottom-left":[]},e._isControlLoading={"top-right":!1,"bottom-right":!1,"top-left":!1,"bottom-left":!1},e}return r(e,t),e.prototype.addControl=function(t,e,r){return o(this,void 0,void 0,(function(){var n,s=this;return i(this,(function(a){return e=null!=e?e:"top-left",(n="string"==typeof t?this.getControl(t,r):t)?[2,new Promise((function(t){s._setControlQueue(e,(function(){return o(s,void 0,void 0,(function(){var r,o;return i(this,(function(i){switch(i.label){case 0:return[4,n];case 1:return r=i.sent(),o=this.mapAdapter.addControl(r,e),t(o),[2]}}))}))}))}))]:[2]}))}))},e.prototype.createControl=function(t,e){return o(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.onLoad("build-map")];case 1:return r.sent(),this.mapAdapter.createControl?[2,this.mapAdapter.createControl(t,e)]:[2]}}))}))},e.prototype.createButtonControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createButtonControl?[2,this.mapAdapter.createButtonControl(t)]:[2]}}))}))},e.prototype.createToggleControl=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.onLoad("build-map")];case 1:return e.sent(),this.mapAdapter.createToggleControl?[2,this.mapAdapter.createToggleControl(t)]:this.mapAdapter.createButtonControl?[2,it(this.mapAdapter.createButtonControl,t)]:[2]}}))}))},e.prototype.removeControl=function(t){var e=this;"remove"in t?t.remove():this.mapAdapter.removeControl&&Promise.resolve(t).then((function(t){e.mapAdapter.removeControl(t)}))},e.prototype.getControl=function(t,r){var n=this.mapAdapter.controlAdapters[t];if(n)return new n(r);var o=e.controls[t];return o?o(this,r):void 0},e.prototype.getControlContainer=function(){if(this.mapAdapter.getControlContainer)return this.mapAdapter.getControlContainer()},e.prototype._setControlQueue=function(t,e){this._loadControlQueue[t].push(e),this._isControlLoading[t]||this._applyControls(t)},e.prototype._applyControls=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return this._loadControlQueue[t].length?(this._isControlLoading[t]=!0,[4,(0,this._loadControlQueue[t][0])()]):[3,2];case 1:return e.sent(),this._loadControlQueue[t].splice(0,1),this._applyControls(t),[3,3];case 2:this._isControlLoading[t]=!1,e.label=3;case 3:return[2]}}))}))},e.controls={CONTROL:function(t,e){return t.createControl(e.control,e.options)},BUTTON:function(t,e){return t.createButtonControl(e)},TOGGLE:function(t,e){return t.createToggleControl(e)}},e}(ot),at={};function ut(t){return at[t]}var ct=function(t){function e(e){var r=t.call(this,e)||this;return r._addControls(),at[r.id]=r,r}return r(e,t),e.get=function(t){return ut(t)},e.prototype._addLayerProviders=function(){var t,e,r,n;return o(this,void 0,void 0,(function(){var o,s,u,c,p,l,f,h,d,y;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,18,19,24]),o=a(this._starterKits),i.label=1;case 1:return[4,o.next()];case 2:return(s=i.sent()).done?[3,17]:(u=s.value).getLayerAdapters?[4,u.getLayerAdapters.call(u)]:[3,16];case 3:if(!(c=i.sent()))return[3,16];i.label=4;case 4:i.trys.push([4,10,11,16]),r=void 0,p=a(c),i.label=5;case 5:return[4,p.next()];case 6:return(l=i.sent()).done?[3,9]:[4,(f=l.value).createAdapter(this)];case 7:(h=i.sent())&&(this.mapAdapter.layerAdapters[f.name]=h),i.label=8;case 8:return[3,5];case 9:return[3,16];case 10:return d=i.sent(),r={error:d},[3,16];case 11:return i.trys.push([11,,14,15]),l&&!l.done&&(n=p.return)?[4,n.call(p)]:[3,13];case 12:i.sent(),i.label=13;case 13:return[3,15];case 14:if(r)throw r.error;return[7];case 15:return[7];case 16:return[3,1];case 17:return[3,24];case 18:return y=i.sent(),t={error:y},[3,24];case 19:return i.trys.push([19,,22,23]),s&&!s.done&&(e=o.return)?[4,e.call(o)]:[3,21];case 20:i.sent(),i.label=21;case 21:return[3,23];case 22:if(t)throw t.error;return[7];case 23:return[7];case 24:return[2]}}))}))},e.prototype._onLoadSync=function(){var t,e;return o(this,void 0,void 0,(function(){var r,n,o,s,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,8,9,14]),r=a(this._starterKits),i.label=1;case 1:return[4,r.next()];case 2:if((n=i.sent()).done)return[3,7];if(!(o=n.value).onLoadSync)return[3,6];i.label=3;case 3:return i.trys.push([3,5,,6]),[4,o.onLoadSync.call(o,this)];case 4:return i.sent(),[3,6];case 5:return s=i.sent(),console.error(s),[3,6];case 6:return[3,1];case 7:return[3,14];case 8:return u=i.sent(),t={error:u},[3,14];case 9:return i.trys.push([9,,12,13]),n&&!n.done&&(e=r.return)?[4,e.call(r)]:[3,11];case 10:i.sent(),i.label=11;case 11:return[3,13];case 12:if(t)throw t.error;return[7];case 13:return[7];case 14:return[2]}}))}))},e.prototype._addControls=function(){var t=this;this.options.controls&&this.options.controls.forEach((function(e){var r=e,n={};"string"==typeof e&&t.options.controlsOptions&&t.options.controlsOptions[e]&&void 0!==(n=t.options.controlsOptions[e]).control&&(r=n.control);var o=n.position,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(n,["position"]);t.addControl(r,o||"top-left",i)})),this._emitStatusEvent("controls:create")},e}(st);return t.WebMap=ct,t.WebMapControls=st,t.WebMapLayers=ot,t.WebMapMain=nt,t.createToggleControl=it,t.createWebMap=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new ct(t).onLoad()]}))}))},t.detectGeometryType=C,t.findMostFrequentGeomType=w,t.getWebMap=ut,t.updateGeoJsonAdapterOptions=O,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
//# sourceMappingURL=webmap.global.prod.js.map
{
"name": "@nextgis/webmap",
"version": "1.11.10",
"version": "1.12.0",
"_priority": 14,

@@ -12,6 +12,6 @@ "description": "Universal map constructor",

"dependencies": {
"@nextgis/cancelable-promise": "^1.11.10",
"@nextgis/paint": "^1.11.10",
"@nextgis/properties-filter": "^1.11.10",
"@nextgis/utils": "^1.11.10",
"@nextgis/cancelable-promise": "^1.12.0",
"@nextgis/paint": "^1.12.0",
"@nextgis/properties-filter": "^1.12.0",
"@nextgis/utils": "^1.12.0",
"@types/events": "^3.0.0",

@@ -23,3 +23,3 @@ "@types/geojson": "^7946.0.8",

"devDependencies": {
"@nextgis/build-tools": "^1.11.10"
"@nextgis/build-tools": "^1.12.0"
},

@@ -60,3 +60,3 @@ "buildOptions": {

},
"gitHead": "51bd939cf50df9657bbe5ed37327d641457eb417"
"gitHead": "cc0e45b49ec7cfcbd3c5ce00a5e0d6682cf8f21c"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc