maplair 4.1.0 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/dist/esm/Maplair.js +5 -4
- package/dist/esm/Maplair.js.map +1 -1
- package/dist/esm/_virtual/_rolldown/runtime.js +1 -2
- package/dist/esm/control/AttributionControl.js +1 -2
- package/dist/esm/control/ButtonControl.js +1 -2
- package/dist/esm/control/ContextMenu.js +1 -2
- package/dist/esm/control/Control.js +1 -2
- package/dist/esm/control/FullscreenControl.js +1 -2
- package/dist/esm/control/LayersControl.js +27 -31
- package/dist/esm/control/LayersControl.js.map +1 -1
- package/dist/esm/control/LegendControl.js +1 -2
- package/dist/esm/control/MiniMapControl.js +1 -2
- package/dist/esm/control/RotateControl.js +1 -2
- package/dist/esm/control/ScaleControl.js +1 -2
- package/dist/esm/control/SearchControl.js +1 -2
- package/dist/esm/control/SideBySideControl.js +1 -2
- package/dist/esm/control/TextControl.js +1 -2
- package/dist/esm/control/TimeControl.js +1 -2
- package/dist/esm/control/ZoomControl.js +18 -29
- package/dist/esm/control/ZoomControl.js.map +1 -1
- package/dist/esm/core/Class.js +2 -9
- package/dist/esm/core/Class.js.map +1 -1
- package/dist/esm/core/Events.js +2 -2
- package/dist/esm/core/Events.js.map +1 -1
- package/dist/esm/core/Handler.js +10 -3
- package/dist/esm/core/Handler.js.map +1 -1
- package/dist/esm/core/I18n.js +1 -2
- package/dist/esm/core/Util.js +2 -3
- package/dist/esm/core/Util.js.map +1 -1
- package/dist/esm/dom/DomEvent.DoubleTap.js +1 -2
- package/dist/esm/dom/DomEvent.PointerEvents.js +1 -2
- package/dist/esm/dom/DomEvent.js +10 -18
- package/dist/esm/dom/DomEvent.js.map +1 -1
- package/dist/esm/dom/DomUtil.js +1 -2
- package/dist/esm/dom/Draggable.js +4 -3
- package/dist/esm/dom/Draggable.js.map +1 -1
- package/dist/esm/dom/PosAnimation.js +1 -2
- package/dist/esm/geo/LatLng.js +1 -2
- package/dist/esm/geo/LatLngBounds.js +9 -15
- package/dist/esm/geo/LatLngBounds.js.map +1 -1
- package/dist/esm/geo/crs/CRS.js +1 -2
- package/dist/esm/geo/crs/EPSG3395.js +4 -5
- package/dist/esm/geo/crs/EPSG3395.js.map +1 -1
- package/dist/esm/geo/crs/EPSG3857.js +4 -5
- package/dist/esm/geo/crs/EPSG3857.js.map +1 -1
- package/dist/esm/geo/crs/EPSG4326.js +3 -4
- package/dist/esm/geo/crs/EPSG4326.js.map +1 -1
- package/dist/esm/geo/crs/EarthCRS.js +1 -2
- package/dist/esm/geo/crs/SimpleCRS.js +3 -4
- package/dist/esm/geo/crs/SimpleCRS.js.map +1 -1
- package/dist/esm/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +4 -5
- package/dist/esm/geo/projection/LonLatProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +3 -4
- package/dist/esm/geo/projection/MercatorProjection.js.map +1 -0
- package/dist/esm/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +4 -5
- package/dist/esm/geo/projection/SphericalMercatorProjection.js.map +1 -0
- package/dist/esm/geometry/Bounds.js +10 -14
- package/dist/esm/geometry/Bounds.js.map +1 -1
- package/dist/esm/geometry/LineUtil.js +2 -3
- package/dist/esm/geometry/LineUtil.js.map +1 -1
- package/dist/esm/geometry/Point.js +1 -2
- package/dist/esm/geometry/PolyUtil.js +17 -25
- package/dist/esm/geometry/PolyUtil.js.map +1 -1
- package/dist/esm/geometry/Transformation.js +1 -2
- package/dist/esm/layer/BlanketOverlay.js +1 -2
- package/dist/esm/layer/Classification.js +1 -2
- package/dist/esm/layer/DivOverlay.js +2 -3
- package/dist/esm/layer/DivOverlay.js.map +1 -1
- package/dist/esm/layer/FeatureGroup.js +5 -4
- package/dist/esm/layer/FeatureGroup.js.map +1 -1
- package/dist/esm/layer/GeoJSON.Load.js +1 -2
- package/dist/esm/layer/GeoJSON.js +8 -10
- package/dist/esm/layer/GeoJSON.js.map +1 -1
- package/dist/esm/layer/GeoJSONUtil.js +1 -2
- package/dist/esm/layer/HeatLayer.js +2 -3
- package/dist/esm/layer/HeatLayer.js.map +1 -1
- package/dist/esm/layer/ImageOverlay.js +2 -3
- package/dist/esm/layer/ImageOverlay.js.map +1 -1
- package/dist/esm/layer/Layer.js +1 -2
- package/dist/esm/layer/LayerGroup.js +2 -3
- package/dist/esm/layer/LayerGroup.js.map +1 -1
- package/dist/esm/layer/Popup.js +9 -16
- package/dist/esm/layer/Popup.js.map +1 -1
- package/dist/esm/layer/SVGOverlay.js +1 -2
- package/dist/esm/layer/Tooltip.js +16 -17
- package/dist/esm/layer/Tooltip.js.map +1 -1
- package/dist/esm/layer/VideoOverlay.js +1 -2
- package/dist/esm/layer/marker/DefaultIcon.js +29 -7
- package/dist/esm/layer/marker/DefaultIcon.js.map +1 -1
- package/dist/esm/layer/marker/DivIcon.js +1 -2
- package/dist/esm/layer/marker/Icon.js +2 -2
- package/dist/esm/layer/marker/Icon.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Drag.js +43 -4
- package/dist/esm/layer/marker/Marker.Drag.js.map +1 -1
- package/dist/esm/layer/marker/Marker.Move.js +4 -6
- package/dist/esm/layer/marker/Marker.Move.js.map +1 -1
- package/dist/esm/layer/marker/Marker.js +54 -14
- package/dist/esm/layer/marker/Marker.js.map +1 -1
- package/dist/esm/layer/marker/MarkerClusterGroup.js +1 -2
- package/dist/esm/layer/marker/SvgIcon.js +1 -2
- package/dist/esm/layer/tile/GridLayer.js +4 -4
- package/dist/esm/layer/tile/GridLayer.js.map +1 -1
- package/dist/esm/layer/tile/TileLayer.js +8 -8
- package/dist/esm/layer/tile/TileLayer.js.map +1 -1
- package/dist/esm/layer/tile/WMSTileLayer.js +5 -4
- package/dist/esm/layer/tile/WMSTileLayer.js.map +1 -1
- package/dist/esm/layer/vector/Canvas.js +7 -14
- package/dist/esm/layer/vector/Canvas.js.map +1 -1
- package/dist/esm/layer/vector/Circle.js +5 -3
- package/dist/esm/layer/vector/Circle.js.map +1 -1
- package/dist/esm/layer/vector/CircleMarker.js +2 -3
- package/dist/esm/layer/vector/CircleMarker.js.map +1 -1
- package/dist/esm/layer/vector/Path.DashAnimation.js +1 -2
- package/dist/esm/layer/vector/Path.ZoomStyles.js +1 -2
- package/dist/esm/layer/vector/Path.js +1 -2
- package/dist/esm/layer/vector/Polygon.js +2 -3
- package/dist/esm/layer/vector/Polygon.js.map +1 -1
- package/dist/esm/layer/vector/Polyline.Decorations.js +1 -2
- package/dist/esm/layer/vector/Polyline.js +2 -3
- package/dist/esm/layer/vector/Polyline.js.map +1 -1
- package/dist/esm/layer/vector/Rectangle.js +1 -2
- package/dist/esm/layer/vector/Renderer.getRenderer.js +4 -5
- package/dist/esm/layer/vector/Renderer.getRenderer.js.map +1 -1
- package/dist/esm/layer/vector/Renderer.js +1 -2
- package/dist/esm/layer/vector/SVG.js +7 -4
- package/dist/esm/layer/vector/SVG.js.map +1 -1
- package/dist/esm/map/Hash.js +1 -2
- package/dist/esm/map/Map.Rotation.js +31 -16
- package/dist/esm/map/Map.Rotation.js.map +1 -1
- package/dist/esm/map/Map.js +10 -17
- package/dist/esm/map/Map.js.map +1 -1
- package/dist/esm/map/MapSync.js +1 -2
- package/dist/esm/map/handler/BoxZoomHandler.js +20 -40
- package/dist/esm/map/handler/BoxZoomHandler.js.map +1 -1
- package/dist/esm/map/handler/DisplaceHandler.js +1 -2
- package/dist/esm/map/handler/DoubleClickZoomHandler.js +1 -2
- package/dist/esm/map/handler/DragHandler.js +1 -2
- package/dist/esm/map/handler/KeyboardHandler.js +23 -43
- package/dist/esm/map/handler/KeyboardHandler.js.map +1 -1
- package/dist/esm/map/handler/PinchZoomHandler.js +1 -2
- package/dist/esm/map/handler/ScrollWheelZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapDragZoomHandler.js +1 -2
- package/dist/esm/map/handler/TapHoldHandler.js +1 -2
- package/dist/esm/package.js +2 -3
- package/dist/maplair-global-src.js +489 -613
- package/dist/maplair-global-src.js.map +1 -1
- package/dist/maplair-global.js +2 -2
- package/dist/maplair-global.js.map +1 -1
- package/dist/maplair-src.js +485 -609
- package/dist/maplair-src.js.map +1 -1
- package/dist/maplair.css +1 -1263
- package/dist/maplair.js +2 -2
- package/dist/maplair.js.map +1 -1
- package/package.json +4 -8
- package/src/Maplair.all.js +0 -1
- package/src/control/LayersControl.js +39 -52
- package/src/control/ZoomControl.js +17 -31
- package/src/core/Class.js +5 -14
- package/src/core/Events.js +2 -0
- package/src/core/Handler.js +11 -1
- package/src/core/Util.js +1 -1
- package/src/dom/DomEvent.js +9 -19
- package/src/dom/Draggable.js +5 -1
- package/src/geo/LatLngBounds.js +8 -15
- package/src/geo/crs/EPSG3395.js +3 -3
- package/src/geo/crs/EPSG3857.js +3 -3
- package/src/geo/crs/EPSG4326.js +2 -2
- package/src/geo/crs/SimpleCRS.js +2 -2
- package/src/geo/index.js +1 -2
- package/src/geo/projection/{Projection.LonLat.js → LonLatProjection.js} +1 -1
- package/src/geo/projection/{Projection.Mercator.js → MercatorProjection.js} +1 -1
- package/src/geo/projection/{Projection.SphericalMercator.js → SphericalMercatorProjection.js} +1 -1
- package/src/geo/projection/index.js +5 -5
- package/src/geometry/Bounds.js +12 -17
- package/src/geometry/LineUtil.js +1 -1
- package/src/geometry/PolyUtil.js +23 -31
- package/src/layer/DivOverlay.js +1 -1
- package/src/layer/FeatureGroup.js +8 -2
- package/src/layer/GeoJSON.js +10 -13
- package/src/layer/HeatLayer.js +1 -1
- package/src/layer/ImageOverlay.js +2 -2
- package/src/layer/LayerGroup.js +1 -1
- package/src/layer/Popup.js +9 -19
- package/src/layer/Tooltip.js +19 -17
- package/src/layer/marker/DefaultIcon.js +33 -5
- package/src/layer/marker/Icon.js +2 -0
- package/src/layer/marker/Marker.Drag.js +53 -5
- package/src/layer/marker/Marker.Move.js +3 -4
- package/src/layer/marker/Marker.js +64 -13
- package/src/layer/tile/GridLayer.js +5 -2
- package/src/layer/tile/TileLayer.js +9 -6
- package/src/layer/tile/WMSTileLayer.js +5 -2
- package/src/layer/vector/Canvas.js +10 -14
- package/src/layer/vector/Circle.js +7 -1
- package/src/layer/vector/CircleMarker.js +2 -1
- package/src/layer/vector/Polygon.js +1 -1
- package/src/layer/vector/Polyline.js +1 -1
- package/src/layer/vector/Renderer.getRenderer.js +4 -3
- package/src/layer/vector/SVG.js +12 -2
- package/src/map/Map.Rotation.js +28 -4
- package/src/map/Map.js +17 -21
- package/src/map/handler/BoxZoomHandler.js +21 -42
- package/src/map/handler/KeyboardHandler.js +34 -53
- package/src/maplair.css +5 -0
- package/dist/esm/geo/projection/Projection.LonLat.js.map +0 -1
- package/dist/esm/geo/projection/Projection.Mercator.js.map +0 -1
- package/dist/esm/geo/projection/Projection.SphericalMercator.js.map +0 -1
- package/dist/esm/geo/projection/index.js +0 -14
- package/dist/esm/geo/projection/index.js.map +0 -1
- package/dist/esm/layer/marker/Marker.Rotation.js +0 -70
- package/dist/esm/layer/marker/Marker.Rotation.js.map +0 -1
- package/src/layer/marker/Marker.Rotation.js +0 -103
package/dist/maplair.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* Maplair 4.
|
|
2
|
+
* Maplair 4.3.0, a JS library for interactive maps. https://maplair.org
|
|
3
3
|
* (c) 2026 Simon Legner and Maplair contributors, (c) 2010-2026 Volodymyr Agafonkin, (c) 2010-2011 CloudMade
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=`4.1.0`,r=/* @__PURE__ */ t({falseFn:()=>c,formatNum:()=>l,lastId:()=>i,setOptions:()=>f,splitWords:()=>d,stamp:()=>a,template:()=>m,throttle:()=>o,wrapNum:()=>s});let i=0;function a(e){return`_maplair_id`in e||(e._maplair_id=++i),e._maplair_id}function o(e,t,n){let r,i;function a(){r=!1,i&&=(o.apply(n,i),!1)}function o(...o){r?i=o:(e.apply(n,o),setTimeout(a,t),r=!0)}return o}function s(e,t,n){let r=t[1],i=t[0],a=r-i;return e===r&&n?e:((e-i)%a+a)%a+i}function c(){return!1}function l(e,t){if(t===!1)return e;let n=10**(t===void 0?6:t);return Math.round(e*n)/n}const u=/\s+/;function d(e){return e.trim().split(u)}function f(e,t){if(!Object.hasOwn(e,`options`)){let t=ee(e.constructor)??e.options;e.options=t?Object.create(t):{}}for(let n in t)Object.hasOwn(t,n)&&(e.options[n]=t[n]);return e.options}const p=/* @__PURE__ */ new WeakMap;function ee(e){let t=e?.defaultOptions;if(t&&p.get(e)!==t){for(let t=e;t.defaultOptions;t=Object.getPrototypeOf(t))Object.hasOwn(t,`defaultOptions`)&&Object.setPrototypeOf(t.defaultOptions,Object.getPrototypeOf(t).defaultOptions??Object.prototype);p.set(e,t)}return t}const te=/\{ *([\w_ -]+) *\}/g;function m(e,t){return e.replace(te,(e,n)=>{let r=t[n];if(r===void 0)throw Error(`No value provided for variable ${e}`);return typeof r==`function`&&(r=r(t)),r})}var h=class{static include(e){for(let n of t(e))n!==`constructor`&&n!==`options`&&(this.prototype[n]=e[n]);return e.options&&this.mergeOptions(e.options),this;function*t(e){do{if(e===Object||e===Object.prototype)break;for(let t of Object.getOwnPropertyNames(e))yield t}while((e=Object.getPrototypeOf(e))!==null)}}static mergeOptions(e){return Object.hasOwn(this,`defaultOptions`)||(this.defaultOptions=Object.create(this.defaultOptions??Object.prototype)),Object.assign(this.defaultOptions,e),this}static setDefaultOptions(e){return this.mergeOptions(e)}static addInitHook(e,...t){let n=typeof e==`function`?e:function(){this[e](...t)};return Object.hasOwn(this,`_initHooks`)||(this._initHooks=[]),this._initHooks.push(n),this}constructor(){if(this.initialize)throw Error(`${this.constructor.name}: initialize() is not called in Maplair. Rename it to constructor() and call super() at its start.`);f(this)}callInitHooks(e=this.constructor){let t=this._initHooksCalledFor;if(t&&(t===e||t.prototype instanceof e))return this;let n=[];for(let r=e;r&&r!==Function.prototype&&r!==t;r=Object.getPrototypeOf(r))n.unshift(r);this._initHooksCalledFor=e;for(let e of n)if(Object.hasOwn(e,`_initHooks`))for(let t of e._initHooks)t.call(this);return this}},g=class e{constructor(t,n,r){if(!e.validate(t,n))throw Error(`Invalid Point object: (${t}, ${n})`);let i,a;t instanceof e?(i=t.x,a=t.y):Array.isArray(t)?(i=t[0],a=t[1]):typeof t==`object`&&`x`in t&&`y`in t?(i=t.x,a=t.y):(i=t,a=n),this.x=r?Math.round(i):i,this.y=r?Math.round(a):a}static from(t,n,r){return t instanceof e&&!r?t:new e(t,n,r)}static validate(t,n){return!!(t instanceof e||Array.isArray(t)||t&&typeof t==`object`&&`x`in t&&`y`in t||(t||t===0)&&(n||n===0))}add(t){return new e(this)._add(e.from(t))}_add(e){return this.x+=e.x,this.y+=e.y,this}subtract(t){return new e(this)._subtract(e.from(t))}_subtract(e){return this.x-=e.x,this.y-=e.y,this}divideBy(t){return new e(this)._divideBy(t)}_divideBy(e){return this.x/=e,this.y/=e,this}multiplyBy(t){return new e(this)._multiplyBy(t)}_multiplyBy(e){return this.x*=e,this.y*=e,this}scaleBy(t){return new e(this.x*t.x,this.y*t.y)}unscaleBy(t){return new e(this.x/t.x,this.y/t.y)}round(){return new e(this)._round()}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}floor(){return new e(this)._floor()}_floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return new e(this)._ceil()}_ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}trunc(){return new e(this)._trunc()}_trunc(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}distanceTo(t){t=e.from(t);let n=t.x-this.x,r=t.y-this.y;return Math.sqrt(n*n+r*r)}equals(t){return t=e.from(t),t.x===this.x&&t.y===this.y}contains(t){return t=e.from(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)}toString(){return`Point(${l(this.x)}, ${l(this.y)})`}};function ne(e){let t={bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed,detail:2,view:e.view,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,button:e.button,buttons:e.buttons,relatedTarget:e.relatedTarget,region:e.region},n;return n=e instanceof PointerEvent?new PointerEvent(`dblclick`,{...t,pointerId:e.pointerId,width:e.width,height:e.height,pressure:e.pressure,tangentialPressure:e.tangentialPressure,tiltX:e.tiltX,tiltY:e.tiltY,twist:e.twist,pointerType:e.pointerType,isPrimary:e.isPrimary}):new MouseEvent(`dblclick`,t),n}function re(e,t){e.addEventListener(`dblclick`,t);let n=0,r,i;function a(e){i=e.pointerType}function o(e){if(e.detail!==1){r=e.detail;return}if(i===`mouse`||e.sourceCapabilities&&!e.sourceCapabilities.firesTouchEvents)return;let t=e.composedPath();if(t.some(e=>e instanceof HTMLLabelElement&&e.htmlFor)&&!t.some(e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement))return;let a=Date.now();a-n<=200?(r++,r===2&&e.target.dispatchEvent(ne(e))):r=1,n=a}return e.addEventListener(`pointerdown`,a,!0),e.addEventListener(`click`,o),{dblclick:t,onPointerDown:a,simDblclick:o}}function ie(e,t){e.removeEventListener(`dblclick`,t.dblclick),e.removeEventListener(`pointerdown`,t.onPointerDown,!0),e.removeEventListener(`click`,t.simDblclick)}var ae=/* @__PURE__ */ t({disablePointerDetection:()=>se,enablePointerDetection:()=>oe,getPointers:()=>v});const _=/* @__PURE__ */ new Map;function oe(e){e.addEventListener(`pointerdown`,ce,{capture:!0}),e.addEventListener(`pointermove`,le,{capture:!0}),e.addEventListener(`pointerup`,ue,{capture:!0}),e.addEventListener(`pointercancel`,ue,{capture:!0}),_.clear()}function se(e){e.removeEventListener(`pointerdown`,ce,{capture:!0}),e.removeEventListener(`pointermove`,le,{capture:!0}),e.removeEventListener(`pointerup`,ue,{capture:!0}),e.removeEventListener(`pointercancel`,ue,{capture:!0})}function ce(e){e.isTrusted&&e.target.setPointerCapture(e.pointerId),_.set(e.pointerId,e)}function le(e){_.has(e.pointerId)&&_.set(e.pointerId,e)}function ue(e){e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId),_.delete(e.pointerId)}function v(){return[..._.values()]}var de=/* @__PURE__ */ t({PointerEvents:()=>ae,disableClickPropagation:()=>w,disableScrollPropagation:()=>C,getPointerPosition:()=>ge,getWheelDelta:()=>ve,getWheelPxFactor:()=>_e,isExternalTarget:()=>ye,off:()=>x,on:()=>y,preventDefault:()=>T,stop:()=>E,stopPropagation:()=>S});function y(e,t,n,r){if(t&&typeof t==`object`)for(let[r,i]of Object.entries(t))me(e,r,i,n);else for(let i of d(t))me(e,i,n,r);return this}const b=`_maplair_events`;function x(e,t,n,r){if(arguments.length===1)pe(e),delete e[b];else if(t&&typeof t==`object`)for(let[r,i]of Object.entries(t))he(e,r,i,n);else if(t=d(t),arguments.length===2)pe(e,e=>t.includes(e));else for(let i of t)he(e,i,n,r);return this}const fe=/\d/;function pe(e,t){for(let n of Object.keys(e[b]??{})){let r=n.split(fe)[0];(!t||t(r))&&he(e,r,null,null,n)}}function me(e,t,n,r){let i=t+a(n)+(r?`_${a(r)}`:``);if(e[b]&&e[b][i])return this;let o=function(t){return n.call(r||e,t)};t===`dblclick`?o=re(e,o):e.addEventListener(t,o,t===`wheel`&&{passive:!1}),e[b]??={},e[b][i]=o}function he(e,t,n,r,i){i??=t+a(n)+(r?`_${a(r)}`:``);let o=e[b]&&e[b][i];if(!o)return this;t===`dblclick`?ie(e,o):e.removeEventListener(t,o,!1),e[b][i]=null}function S(e){return e.stopPropagation?e.stopPropagation():e.originalEvent?e.originalEvent._stopped=!0:console.debug(`Unsupported event`,e),this}function C(e){return me(e,`wheel`,S),this}function w(e){return y(e,`pointerdown dblclick contextmenu`,S),e._maplair_disable_click=!0,this}function T(e){return e.preventDefault?.(),this}function E(e){return T(e),S(e),this}function ge(e,t){if(!t)return new g(e.clientX,e.clientY);let n=De(t),r=n.boundingClientRect;return new g((e.clientX-r.left)/n.x-t.clientLeft,(e.clientY-r.top)/n.y-t.clientTop)}function _e(){return window.devicePixelRatio*2}function ve(e){return e.deltaY&&e.deltaMode===0?-e.deltaY/_e():e.deltaY&&e.deltaMode===1?-e.deltaY*20:e.deltaY&&e.deltaMode===2?-e.deltaY*60:(e.deltaX||e.deltaZ,0)}function ye(e,t){return!e.contains(t.relatedTarget)}var be=/* @__PURE__ */ t({create:()=>D,disableImageDrag:()=>we,enableImageDrag:()=>Te,get:()=>xe,getPosition:()=>j,getScale:()=>De,getSizedParentNode:()=>Ee,setPosition:()=>A,setTransform:()=>k,toBack:()=>Se,toFront:()=>O});function xe(e){return typeof e==`string`?document.getElementById(e):e}function D(e,t,n){let r=document.createElement(e);return r.className=t??``,n?.appendChild(r),r}function O(e){let t=e.parentNode;if(t&&t.lastChild!==e){if(e.matches(`:hover`))for(;e.nextSibling;)t.insertBefore(e.nextSibling,e);else t.appendChild(e)}}function Se(e){let t=e.parentNode;if(t&&t.firstChild!==e){if(e.matches(`:hover`))for(;e.previousSibling;)t.insertBefore(e.previousSibling,e.nextSibling);else t.insertBefore(e,t.firstChild)}}function k(e,t,n){let r=t??new g(0,0),i=`translate3d(${r.x}px, ${r.y}px, 0px)${n?` scale(${n})`:``}`;e.style.transform!==i&&(e.style.transform=i)}const Ce=/* @__PURE__ */ new WeakMap;function A(e,t,n){Ce.set(e,t),n?e.style.transform=`translate(${t.x}px, ${t.y}px)`:k(e,t)}function j(e){return Ce.get(e)??new g(0,0)}function we(){y(window,`dragstart`,T)}function Te(){x(window,`dragstart`,T)}function Ee(e){do e=e.parentNode;while((!e.offsetWidth||!e.offsetHeight)&&e!==document.body);return e}function De(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}const Oe={addControl(e){return e.addTo(this),this},removeControl(e){return e.remove(),this},_initControlPos(){let e=this._controlCorners={},t=`maplair-`,n=this._controlContainer=D(`div`,`${t}control-container`,this._container);for(let r of[`top`,`bottom`])for(let i of[`left`,`right`])e[r+i]=D(`div`,`${t+r} ${t}${i}`,n)},_clearControlPos(){this._controlContainer.remove(),delete this._controlCorners,delete this._controlContainer}},ke=/* @__PURE__ */ new WeakMap;var M=class e extends h{static defaultOptions={position:`topright`,order:0};constructor(t){super(),f(this,t),this.callInitHooks(e)}getPosition(){return this.options.position}setPosition(e){let t=this._map;return t?.removeControl(this),this.options.position=e,t?.addControl(this),this}getContainer(){return this._container}addTo(e){this.remove(),this._map=e;let t=this._container=this.onAdd(e),n=this.getPosition(),r=e._controlCorners[n];t.classList.add(`maplair-control`);let i=this.options.order??0,a=n.includes(`bottom`),o=[...r.children];return ke.set(t,i),r.insertBefore(t,o.find(e=>a?(ke.get(e)??0)<=i:(ke.get(e)??0)>i)??null),this._map.on(`unload`,this.remove,this),this}remove(){return this._map&&=(this._container.remove(),this.onRemove&&this.onRemove(this._map),this._map.off(`unload`,this.remove,this),null),this}_refocusOnMap(e){this._map&&e&&(e.screenX!==0||e.screenY!==0)&&this._map.getContainer().focus({preventScroll:!0,focusVisible:!1})}static register(e){e.include(Oe)}},N=class{static#e={};static#t=null;static registerLocale(e,t){this.#e[e]={...this.#e[e],...t}}static setLocale(e){this.#t=e}static getLocale(){return this.#t}static translate(e,t={}){if(this.#t===null)return m(e,t);let n=this.#e[this.#t]?.[e];if(!n)return console.warn(`No translation found for "${e}", falling back to the original string.`),m(e,t);try{return m(n,t)}catch(e){return console.error(`Error while translating "${n}".`,e),n}}},Ae=class e extends M{static defaultOptions={position:`bottomright`,prefix:null};constructor(t){if(super(t),this.options.prefix===null){let e=N.translate(`A JavaScript library for interactive maps`);this.options.prefix=`<a target="_blank" href="https://maplair.org" title="${e}"><span aria-hidden="true" class="maplair-attribution-leaf">🍁</span>Maplair</a>`}this._attributions={},this._orders={},this._layerAttributions=/* @__PURE__ */ new Map,this.callInitHooks(e)}onAdd(e){return e.attributionControl=this,this._container=D(`div`,`maplair-control-attribution`),w(this._container),e._loaded&&e.eachLayer(e=>this._addLayer({layer:e})),this._update(),e.on({layeradd:this._addLayer,layerremove:this._removeLayer},this),this._container}onRemove(e){e.off({layeradd:this._addLayer,layerremove:this._removeLayer},this);for(let e of this._layerAttributions.keys())this._removeLayer({layer:e})}_addLayer({layer:e}){let t=e.getAttribution?.();t&&!this._layerAttributions.has(e)&&(this._layerAttributions.set(e,t),this.addAttribution(t,e.options?.attributionOrder))}_removeLayer({layer:e}){this.removeAttribution(this._layerAttributions.get(e)),this._layerAttributions.delete(e)}setPrefix(e){return this.options.prefix=e,this._update(),this}addAttribution(e,t=0){return e&&(this._orders[e]=t,this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update()),this}removeAttribution(e){return e&&this._attributions[e]&&(this._attributions[e]--,this._update()),this}_update(){if(!this._map)return;let e=Object.keys(this._attributions).filter(e=>this._attributions[e]).sort((e,t)=>this._orders[e]-this._orders[t]),t=[];this.options.prefix&&t.push(this.options.prefix),e.length&&t.push(e.join(`, `)),this._container.innerHTML=t.join(` <span aria-hidden="true">|</span> `)}static register(t){t.mergeOptions({attributionControl:!0}),t.addInitHook(function(){this.options.attributionControl&&new e().addTo(this)})}},je=class e extends M{static defaultOptions={position:`topleft`,content:``,title:``,onClick:void 0,states:void 0,className:``,accessKey:``};constructor(...t){super(...t),this._state=this.options.states?.[0],this.callInitHooks(e)}onAdd(){let e=D(`div`,`maplair-bar maplair-control-button`);return this._createButton(e),e}_createButton(e){let t=this._button=D(`button`,`maplair-control-button-button ${this.options.className}`,e);return t.type=`button`,t.accessKey=this.options.accessKey,w(t),y(t,`click`,E),y(t,`click`,this._onClick,this),y(t,`click`,this._refocusOnMap,this),this._update(),t}_onClick(e){this._disabled||(this._state??this.options).onClick?.call(this,e,this,this._map)}_update(){if(!this._button)return;let{content:e,title:t}=this._state??this.options,n=this._button;typeof e==`string`?n.innerHTML=e:n.replaceChildren(e);let r=n.accessKeyLabel||this.options.accessKey.toUpperCase();n.title=[t,r&&`[${r}]`].filter(Boolean).join(` `),n.setAttribute(`aria-label`,t??``),this._state&&(n.dataset.state=this._state.name),n.classList.toggle(`maplair-disabled`,!!this._disabled),n.setAttribute(`aria-disabled`,!!this._disabled)}setState(e){let t=this.options.states?.find(t=>t.name===e);if(!t)throw Error(`Unknown button state "${e}".`);return this._state=t,this._update(),this}getState(){return this._state?.name}disable(){return this._disabled=!0,this._update(),this}enable(){return this._disabled=!1,this._update(),this}getButton(){return this._button}},Me=class e extends M{constructor(t,n){super(n),this._buttons=t,this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-bar maplair-control-button-bar`);for(let n of this._buttons)n._map=e,n._createButton(t);return t}onRemove(){for(let e of this._buttons)e._map=null}getButtons(){return this._buttons}};const Ne=/* @__PURE__ */ new Set;var Pe=class e extends h{on(e,t,n){if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._on(n,r,t);else for(let r of d(e))this._on(r,t,n);return this}off(e,t,n){if(!arguments.length)delete this._events,delete this._listenerIndex;else if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._off(n,r,t);else{let r=arguments.length===1;for(let i of d(e))r?this._off(i):this._off(i,t,n)}return this}static __REMOVED_EVENTS={mousedown:`pointerdown`,mouseup:`pointerup`,mouseover:`pointerover`,mouseout:`pointerout`,mousemove:`pointermove`,keypress:`keydown`};_on(t,n,r,i){if(Object.hasOwn(e.__REMOVED_EVENTS,t)&&!Ne.has(t)&&(Ne.add(t),console.error(`The event ${t} has been removed in Maplair. Use ${e.__REMOVED_EVENTS[t]} instead.`)),typeof n!=`function`){console.warn(`wrong listener type: ${typeof n}`);return}r===this&&(r=void 0);let a=this._getListenerIndex(t).get(n);if(a?.has(r))return;let o={fn:n,ctx:r};i&&(o.once=!0),this._events??={},this._events[t]??=/* @__PURE__ */ new Set,this._events[t].add(o),a?a.set(r,o):this._listenerIndex[t].set(n,/* @__PURE__ */ new Map([[r,o]]))}_getListenerIndex(e){return this._listenerIndex??={},this._listenerIndex[e]??=/* @__PURE__ */ new Map}_off(e,t,n){if(!this._events)return;let r=this._events[e];if(!r)return;if(arguments.length===1){if(this._firingCount)for(let e of r)e.fn=c;delete this._events[e],delete this._listenerIndex?.[e];return}if(typeof t!=`function`){console.warn(`wrong listener type: ${typeof t}`);return}n===this&&(n=void 0);let i=this._listenerIndex?.[e]?.get(t),a=i?.get(n);a&&(i.delete(n),i.size||this._listenerIndex[e].delete(t),this._firingCount&&(a.fn=c,this._events[e]=r=new Set(r)),r.delete(a))}fire(e,t,n){if(!this.listens(e,n))return this;let r={...t,type:e,target:this,sourceTarget:t?.sourceTarget||this};if(this._events){let t=this._events[e];if(t){this._firingCount=this._firingCount+1||1;for(let n of t){let t=n.fn;n.once&&this.off(e,t,n.ctx),t.call(n.ctx||this,r)}this._firingCount--}}return n&&this._propagateEvent(r),this}listens(e,t,n,r){typeof e!=`string`&&console.warn(`"string" type argument expected`);let i=t;if(typeof t!=`function`&&(r=!!t,i=void 0,n=void 0),this._events?.[e]?.size&&this._listens(e,i,n)!==!1)return!0;if(r){for(let i of Object.values(this._eventParents??{}))if(i.listens(e,t,n,r))return!0}return!1}_listens(e,t,n){if(!this._events)return!1;let r=this._events[e];return t?(n===this&&(n=void 0),!!this._listenerIndex?.[e]?.get(t)?.has(n)):!!r?.size}once(e,t,n){if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._on(n,r,t,!0);else for(let r of d(e))this._on(r,t,n,!0);return this}addEventParent(e){return this._eventParents??={},this._eventParents[a(e)]=e,this}removeEventParent(e){return this._eventParents&&delete this._eventParents[a(e)],this}_propagateEvent(e){for(let t of Object.values(this._eventParents??{}))t.fire(e.type,{propagatedFrom:e.target,...e},!0)}};const Fe={addLayer(e){if(!e._layerAdd)throw Error(`The provided object is not a Layer.`);let t=a(e);return this._layers[t]||(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e)),this},removeLayer(e){let t=a(e);return this._layers[t]&&(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire(`layerremove`,{layer:e}),e.fire(`remove`)),e._map=e._mapToAdd=null),this},hasLayer(e){return a(e)in this._layers},eachLayer(e,t){for(let n of Object.values(this._layers))e.call(t,n);return this},_addLayers(e){e=e?Array.isArray(e)?e:[e]:[];for(let t of e)this.addLayer(t)},_addZoomLimit(e){(!isNaN(e.options.maxZoom)||!isNaN(e.options.minZoom))&&(this._zoomBoundLayers[a(e)]=e,this._updateZoomLevels())},_removeZoomLimit(e){let t=a(e);this._zoomBoundLayers[t]&&(delete this._zoomBoundLayers[t],this._updateZoomLevels())},_updateZoomLevels(){let e=1/0,t=-1/0,n=this._getZoomSpan();for(let n of Object.values(this._zoomBoundLayers)){let r=n.options;e=Math.min(e,r.minZoom??1/0),t=Math.max(t,r.maxZoom??-1/0)}this._layersMaxZoom=t===-1/0?void 0:t,this._layersMinZoom=e===1/0?void 0:e,n!==this._getZoomSpan()&&this.fire(`zoomlevelschange`),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}};var P=class extends Pe{static defaultOptions={pane:`overlayPane`,attribution:null,attributionOrder:0,bubblingPointerEvents:!0};addTo(e){return e.addLayer(this),this}remove(){return this.removeFrom(this._map||this._mapToAdd)}removeFrom(e){return e?.removeLayer(this),this}getPane(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)}setInteractive(e){return e=!!e,this.options.interactive!==e&&(f(this,{interactive:e}),this._map&&this._updateInteractive()),this}_updateInteractive(){}addInteractiveTarget(e){return this._map._targets[a(e)]=this,this}removeInteractiveTarget(e){return delete this._map._targets[a(e)],this}getAttribution(){return this.options.attribution}setAttribution(e){let t=this._map?.attributionControl;return t?._removeLayer({layer:this}),f(this,{attribution:e}),t?._addLayer({layer:this}),this}_layerAdd(e){let t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){let e=this.getEvents();t.on(e,this),this.once(`remove`,()=>t.off(e,this))}this.onAdd(t),this.fire(`add`),t.fire(`layeradd`,{layer:this})}}static register(e){e.include(Fe)}},Ie=class e extends h{static defaultOptions={className:``};constructor(t,n){super(),f(this,n),this._items=t,this.callInitHooks(e)}addTo(e){return this.remove(),this._target=e,e.on(`contextmenu`,this._open,this),this}remove(){return this.close(),this._target?.off(`contextmenu`,this._open,this),this._target=null,this._container?.remove(),this._container=null,this}close(){return this._container?.matches(`:popover-open`)&&this._container.hidePopover(),this}isOpen(){return!!this._container?.matches(`:popover-open`)}_open(e){E(e);let t=this._target instanceof P?this._target._map:this._target;if(!t)return;this._map=t,this._event={latlng:e.latlng,containerPoint:e.containerPoint,layerPoint:e.layerPoint,originalEvent:e.originalEvent,relatedTarget:this._target instanceof P?this._target:void 0};let n=this._createMenu(t._container);n.matches(`:popover-open`)||n.showPopover(),this._position(e.originalEvent),n.querySelector(`button:not([disabled])`)?.focus({preventScroll:!0}),t.once(`movestart`,this.close,this)}_createMenu(e){let t=this._container??=D(`div`,`maplair-contextmenu ${this.options.className}`);t.parentNode!==e&&e.appendChild(t),t.popover=`auto`,t.setAttribute(`role`,`menu`),t.replaceChildren();for(let e of this._items){if(e===`-`){D(`div`,`maplair-contextmenu-separator`,t).setAttribute(`role`,`separator`);continue}let n=D(`button`,`maplair-contextmenu-item`,t);n.type=`button`,n.setAttribute(`role`,`menuitem`),n.textContent=e.text,n.disabled=!!e.disabled,y(n,`click`,t=>{E(t),this.close(),e.callback?.call(this,this._event)})}return y(t,`keydown`,this._onKeyDown,this),w(t),C(t),y(t,`contextmenu`,E),t}_position(e){let t=this._container,n=document.documentElement,r=Math.min(e.clientX,n.clientWidth-t.offsetWidth),i=Math.min(e.clientY,n.clientHeight-t.offsetHeight);t.style.left=`${Math.max(0,r)}px`,t.style.top=`${Math.max(0,i)}px`}_onKeyDown(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;E(e);let t=[...this._container.querySelectorAll(`button:not([disabled])`)],n=t.indexOf(document.activeElement),r=e.key===`ArrowDown`?n+1:n-1;t.at(r%t.length)?.focus()}};const Le={toggleFullscreen(){let e=this._container;return this._fullscreen===`pseudo`?this._setFullscreen(!1):this._fullscreen?document.exitFullscreen():document.fullscreenEnabled&&e.requestFullscreen?(y(document,`fullscreenchange`,this._onFullscreenChange,this),e.requestFullscreen().catch(()=>{x(document,`fullscreenchange`,this._onFullscreenChange,this),this._setFullscreen(`pseudo`)})):this._setFullscreen(`pseudo`),this},isFullscreen(){return!!this._fullscreen},_onFullscreenChange(){let e=document.fullscreenElement===this._container;e||x(document,`fullscreenchange`,this._onFullscreenChange,this),e!==this.isFullscreen()&&this._setFullscreen(e&&`native`)},_onFullscreenKeyDown(e){e.key===`Escape`&&this._setFullscreen(!1)},_setFullscreen(e){let t=this._container;this._fullscreen=e,t.classList.toggle(`maplair-fullscreen`,!!e),t.classList.toggle(`maplair-pseudo-fullscreen`,e===`pseudo`),e===`pseudo`?y(document,`keydown`,this._onFullscreenKeyDown,this):x(document,`keydown`,this._onFullscreenKeyDown,this),this.invalidateSize(),this.fire(e?`enterfullscreen`:`exitfullscreen`),this.fire(`fullscreenchange`)}};var Re=class e extends M{static defaultOptions={position:`topleft`,enterText:`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M2 2h5v2H4v3H2zm7 0h5v5h-2V4H9zM2 9h2v3h3v2H2zm10 0h2v5H9v-2h3z"/></svg>`,exitText:`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M5 2h2v5H2V5h3zm4 0h2v3h3v2H9zM2 9h5v5H5v-3H2zm7 0h5v2h-3v3H9z"/></svg>`};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-control-fullscreen maplair-bar`),n=this._button=D(`button`,`maplair-control-fullscreen-button`,t);return n.type=`button`,w(n),y(n,`click`,E),y(n,`click`,this._toggleFullscreen,this),y(n,`click`,this._refocusOnMap,this),this._update(),e.on(`fullscreenchange`,this._update,this),t}onRemove(e){e.off(`fullscreenchange`,this._update,this)}_toggleFullscreen(){this._map.toggleFullscreen()}_update(){let e=this._map.isFullscreen(),t=e?N.translate(`Exit fullscreen`):N.translate(`View fullscreen`);this._button.innerHTML=e?this.options.exitText:this.options.enterText,this._button.title=t,this._button.setAttribute(`aria-label`,t),this._button.setAttribute(`aria-pressed`,e)}static register(t){t.mergeOptions({fullscreenControl:!1}),t.include(Le),t.addInitHook(function(){this.on(`unload`,function(){this._fullscreen===`native`&&(x(document,`fullscreenchange`,this._onFullscreenChange,this),document.exitFullscreen()),this._container.classList.remove(`maplair-fullscreen`,`maplair-pseudo-fullscreen`),x(document,`keydown`,this._onFullscreenKeyDown,this),this._fullscreen=!1}),this.options.fullscreenControl&&(this.fullscreenControl=new e,this.addControl(this.fullscreenControl))})}},ze=class e extends M{static defaultOptions={collapsed:!0,inline:!1,groupBy:void 0,toggleContent:void 0,collapseDelay:0,position:`topright`,autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction(e,t,n,r){return n<r?-1:+(r<n)}};constructor(t,n,r){super(r),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(let[e,n]of Object.entries(t??{}))this._addLayer(n,e);for(let[e,t]of Object.entries(n??{}))this._addLayer(t,e,!0);this.callInitHooks(e)}onAdd(e){this._initLayout(),this._update(),this._map=e,e.on(`zoomend`,this._checkDisabledLayers,this);for(let e of this._layers)e.layer.on(`add remove`,this._onLayerChange,this);return this._isCollapsible()||e.on(`resize`,this._expandIfNotCollapsed,this),this._container}addTo(e){return super.addTo(e),this._expandIfNotCollapsed()}onRemove(){this._map.off(`zoomend`,this._checkDisabledLayers,this);for(let e of this._layers)e.layer.off(`add remove`,this._onLayerChange,this);this._map.off(`resize`,this._expandIfNotCollapsed,this)}addBaseLayer(e,t){return this._addLayer(e,t),this._map?this._update():this}addOverlay(e,t){return this._addLayer(e,t,!0),this._map?this._update():this}removeLayer(e){e.off(`add remove`,this._onLayerChange,this);let t=this._getLayer(a(e));return t&&this._layers.splice(this._layers.indexOf(t),1),this._map?this._update():this}getLayers(){return this._layers.map(({layer:e,name:t,overlay:n})=>({layer:e,name:t,overlay:n}))}selectLayer(e){let t=this._layerControlInputs.find(t=>t.layerId===a(e));return t&&!t.checked&&(t.checked=!0,this._onInputClick()),this}expand(){clearTimeout(this._collapseDelayTimeout),this._container.classList.add(`maplair-control-layers-expanded`),this._section.style.height=``;let e=this._map.getSize().y-(this._container.offsetTop+50);return e<this._section.clientHeight?(this._section.classList.add(`maplair-control-layers-scrollbar`),this._section.style.height=`${e}px`):this._section.classList.remove(`maplair-control-layers-scrollbar`),this._checkDisabledLayers(),this}collapse(e){if(this.options.inline)return this;if(!e||e.type!==`pointerleave`&&e.type!==`pointerout`||e.pointerType!==`touch`){if(this.options.collapseDelay>0)return this._collapseDelayTimeout=setTimeout(()=>{this._container.classList.remove(`maplair-control-layers-expanded`)},this.options.collapseDelay),this;this._container.classList.remove(`maplair-control-layers-expanded`)}return this}_initLayout(){let e=`maplair-control-layers`,t=this._container=D(`div`,e),n=this._isCollapsible();this.options.inline&&t.classList.add(`${e}-inline`),w(t),C(t);let r=this._section=D(`fieldset`,`${e}-list`);if(r.setAttribute(`aria-label`,N.translate(`Layers`)),n&&(this._map.on(`click`,this.collapse,this),y(t,{pointerenter:this._expandSafely,pointerleave:this.collapse},this)),!this.options.inline){let n=this._layersLink=D(`button`,`${e}-toggle`,t);n.type=`button`,n.title=N.translate(`Layers`),n.setAttribute(`aria-label`,N.translate(`Layers`));let{toggleContent:r}=this.options;typeof r==`string`?n.innerHTML=r:r&&n.replaceChildren(r),y(n,{keydown(e){e.code===`Enter`&&this._expandSafely()},click(e){e.preventDefault(),this._expandSafely()}},this)}n||this.expand(),this._baseLayersList=D(`div`,`${e}-base`,r),this._separator=D(`div`,`${e}-separator`,r),this._overlaysList=D(`div`,`${e}-overlays`,r),t.appendChild(r)}_getLayer(e){for(let t of this._layers)if(t&&a(t.layer)===e)return t}_addLayer(e,t,n){this._map&&e.on(`add remove`,this._onLayerChange,this),this._layers.push({layer:e,name:t,overlay:!!n}),this.options.sortLayers&&this._layers.sort(((e,t)=>this.options.sortFunction(e.layer,t.layer,e.name,t.name))),this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()}_update(){if(!this._container)return this;this._baseLayersList.replaceChildren(),this._overlaysList.replaceChildren(),this._layerControlInputs=[],this._groupCount=0;let e,t,n=0;for(let r of this._layers)this._addItem(r),t||=r.overlay,e||=!r.overlay,n+=+!r.overlay;return this.options.hideSingleBase&&(e&&=n>1,this._baseLayersList.style.display=e?``:`none`),this._separator.style.display=t&&e?``:`none`,this}_onLayerChange(e){this._handlingClick||this._update();let t=this._getLayer(a(e.target)),n=t.overlay?e.type===`add`?`overlayadd`:`overlayremove`:e.type===`add`?`baselayerchange`:null;n&&this._map.fire(n,this._clickEvent?{...t,originalEvent:this._clickEvent}:t)}_addItem(e){let t=document.createElement(`label`),n=this._map.hasLayer(e.layer),r=document.createElement(`input`);r.type=e.overlay?`checkbox`:`radio`,r.className=`maplair-control-layers-selector`,r.defaultChecked=n,e.overlay||(r.name=`maplair-base-layers_${a(this)}`),this._layerControlInputs.push(r),r.layerId=a(e.layer),y(r,`click`,this._onInputClick,this);let i=this.options.groupBy?.(e.name,e.layer,e.overlay),o=document.createElement(`span`);o.innerHTML=` ${i?i.label:e.name}`;let s=document.createElement(`span`);t.appendChild(s),s.appendChild(r),s.appendChild(o);let c=e.overlay?this._overlaysList:this._baseLayersList;return(i?this._getGroupContainer(c,i.group):c).appendChild(t),this._checkDisabledLayers(),t}_getGroupContainer(e,t){let n=e.lastElementChild;if(n?._maplairGroup===t)return n;let r=`maplair-control-layers-group`,i=D(`div`,r,e),o=D(`span`,`${r}-name`,i);return o.id=`${r}_${a(this)}_${++this._groupCount}`,o.textContent=t,i.setAttribute(`role`,`group`),i.setAttribute(`aria-labelledby`,o.id),i._maplairGroup=t,i}_onInputClick(e){if(this._preventClick)return;let t=this._layerControlInputs,n=[],r=[];this._handlingClick=!0,this._clickEvent=e;for(let e of t){let t=this._getLayer(e.layerId).layer;e.checked?n.push(t):e.checked||r.push(t)}for(let e of r)this._map.hasLayer(e)&&this._map.removeLayer(e);for(let e of n)this._map.hasLayer(e)||this._map.addLayer(e);this._handlingClick=!1,this._clickEvent=void 0,this._refocusOnMap(e)}_checkDisabledLayers(){let e=this._layerControlInputs,t=this._map.getZoom();for(let n of e){let e=this._getLayer(n.layerId).layer;n.disabled=e.options.minZoom!==void 0&&t<e.options.minZoom||e.options.maxZoom!==void 0&&t>e.options.maxZoom}}_isCollapsible(){return this.options.collapsed&&!this.options.inline}_expandIfNotCollapsed(){return this._map&&!this._isCollapsible()&&this.expand(),this}_expandSafely(){let e=this._section;this._preventClick=!0,y(e,`click`,T),this.expand(),setTimeout(()=>{x(e,`click`,T),this._preventClick=!1})}},F=class e{constructor(t,n){if(!t)return;if(t instanceof e){t.isValid()&&(this.min=new g(t.min),this.max=new g(t.max));return}let r=n?[t,n]:t;for(let e of r)this.extend(e)}static from(t,n){return t instanceof e?t:new e(t,n)}extend(t){let n,r;if(!t)return this;if(t instanceof g||typeof t[0]==`number`||`x`in t)n=r=g.from(t);else if(t=e.from(t),n=t.min,r=t.max,!n||!r)return this;return!this.min&&!this.max?(this.min=new g(n),this.max=new g(r)):(this.min.x=Math.min(n.x,this.min.x),this.max.x=Math.max(r.x,this.max.x),this.min.y=Math.min(n.y,this.min.y),this.max.y=Math.max(r.y,this.max.y)),this}getCenter(e){return new g((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,e)}getBottomLeft(){return new g(this.min.x,this.max.y)}getTopRight(){return new g(this.max.x,this.min.y)}getTopLeft(){return this.min}getBottomRight(){return this.max}getSize(){return this.max.subtract(this.min)}contains(t){let n,r;return t=typeof t[0]==`number`||t instanceof g?g.from(t):e.from(t),t instanceof e?(n=t.min,r=t.max):n=r=t,n.x>=this.min.x&&r.x<=this.max.x&&n.y>=this.min.y&&r.y<=this.max.y}intersects(t){t=e.from(t);let n=this.min,r=this.max,i=t.min,a=t.max,o=a.x>=n.x&&i.x<=r.x,s=a.y>=n.y&&i.y<=r.y;return o&&s}overlaps(t){t=e.from(t);let n=this.min,r=this.max,i=t.min,a=t.max,o=a.x>n.x&&i.x<r.x,s=a.y>n.y&&i.y<r.y;return o&&s}isValid(){return!!(this.min&&this.max)}pad(t){let n=this.min,r=this.max,i=Math.abs(n.x-r.x)*t,a=Math.abs(n.y-r.y)*t;return new e(new g(n.x-i,n.y-a),new g(r.x+i,r.y+a))}equals(t){return t?(t=e.from(t),this.min.equals(t.getTopLeft())&&this.max.equals(t.getBottomRight())):!1}},Be=class e extends P{static defaultOptions={padding:.1,continuous:!1};constructor(t){super(),f(this,t),this.callInitHooks(e)}onAdd(){this._container||(this._initContainer(),this._container.classList.add(`maplair-zoom-animated`)),this.getPane().appendChild(this._container),this._resizeContainer(),this._onMoveEnd()}onRemove(){this._destroyContainer()}getEvents(){let e={viewreset:this._reset,zoom:this._onZoom,moveend:this._onMoveEnd,resize:this._resizeContainer,zoomend:this._onZoomEnd,zoomanim:this._onAnimZoom};return this.options.continuous&&(e.move=this._onMoveEnd),e}_onAnimZoom(e){this._updateTransform(e.center,e.zoom)}_onZoom(){this._updateTransform(this._map.getCenter(),this._map.getZoom())}_updateTransform(e,t){let n=this._map.getZoomScale(t,this._zoom),r=this._map.getSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n)._add(i)._subtract(this._map._getNewPixelOrigin(e,t))._round();k(this._container,a,n)}_onMoveEnd(e){let t=this.options.padding,n=this._map.getSize(),r=this._map.containerPointToLayerPoint(n.multiplyBy(-t)).round();this._bounds=new F(r,r.add(n.multiplyBy(1+t*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._updateTransform(this._center,this._zoom),this._onSettled(e)}_reset(){this._onSettled(),this._updateTransform(this._center,this._zoom),this._onViewReset()}_initContainer(){this._container=D(`div`)}_destroyContainer(){x(this._container),this._container.remove(),delete this._container}_resizeContainer(){let e=this.options.padding,t=this._map.getSize().multiplyBy(1+e*2).round();return this._container.style.width=`${t.x}px`,this._container.style.height=`${t.y}px`,t}_onZoomEnd(){}_onViewReset(){}_onSettled(){}},Ve=class e extends Be{constructor(t){super({...t,continuous:!1}),a(this),this._layers??={},this.callInitHooks(e)}onAdd(e){super.onAdd(e),this.on(`update`,this._updatePaths,this)}onRemove(){super.onRemove(),this.off(`update`,this._updatePaths,this)}_onZoomEnd(){for(let e of Object.values(this._layers))e._project()}_updatePaths(){for(let e of Object.values(this._layers))e._update()}_onViewReset(){for(let e of Object.values(this._layers))e._reset()}_onSettled(){this._update()}_update(){}},I=class e extends Ve{constructor(...t){super(...t),this.callInitHooks(e)}_initContainer(){this._container=e.create(`svg`),this._container.setAttribute(`pointer-events`,`none`),this._rootGroup=e.create(`g`),this._container.appendChild(this._rootGroup)}_destroyContainer(){super._destroyContainer(),delete this._rootGroup,delete this._svgSize}_resizeContainer(){let e=super._resizeContainer();(!this._svgSize||!this._svgSize.equals(e))&&(this._svgSize=e,this._container.setAttribute(`width`,`${e.x}`),this._container.setAttribute(`height`,`${e.y}`));let t=this._bounds;t&&this._container.setAttribute(`viewBox`,[t.min.x,t.min.y,e.x,e.y].join(` `))}_update(){if(this._map._animatingZoom&&this._bounds)return;let e=this._bounds,t=e.getSize();this._container.setAttribute(`viewBox`,[e.min.x,e.min.y,t.x,t.y].join(` `)),this.fire(`update`)}_initPath(t){let n=t._path=e.create(`path`);t.options.className&&n.classList.add(...d(t.options.className)),t.options.interactive&&n.classList.add(`maplair-interactive`),this._updateStyle(t),this._layers[a(t)]=t}_updateInteractive(e){e._path.classList.toggle(`maplair-interactive`,!!e.options.interactive)}_addPath(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)}_removePath(e){e._path.remove(),e.removeInteractiveTarget(e._path),delete this._layers[a(e)]}_updatePath(e){e._project(),e._update()}_updateStyle(e){let t=e._path,n=e.options;t&&(n.stroke?(t.setAttribute(`stroke`,n.color),t.setAttribute(`stroke-opacity`,`${n.opacity}`),t.setAttribute(`stroke-width`,`${n.weight}`),t.setAttribute(`stroke-linecap`,n.lineCap),t.setAttribute(`stroke-linejoin`,n.lineJoin),n.dashArray?t.setAttribute(`stroke-dasharray`,n.dashArray):t.removeAttribute(`stroke-dasharray`),n.dashOffset?t.setAttribute(`stroke-dashoffset`,n.dashOffset):t.removeAttribute(`stroke-dashoffset`)):t.setAttribute(`stroke`,`none`),n.fill?(t.setAttribute(`fill`,n.fillColor||n.color),t.setAttribute(`fill-opacity`,`${n.fillOpacity}`),t.setAttribute(`fill-rule`,n.fillRule||`evenodd`)):t.setAttribute(`fill`,`none`))}_updatePoly(t,n){this._setPath(t,e.pointsToPath(t._parts,n))}_updateCircle(e){let t=e._point,n=Math.max(Math.round(e._pxRadius),1),r=`a${n},${Math.max(Math.round(e._pxRadiusY),1)||n} 0 1,0 `,i=e._empty()?`M0 0`:`M${t.x-n},${t.y}${r}${n*2},0 ${r}${-n*2},0 `;this._setPath(e,i)}_setPath(e,t){e._path.setAttribute(`d`,t)}_bringToFront(e){O(e._path)}_bringToBack(e){Se(e._path)}static create(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}static pointsToPath(e,t){return e.flatMap(e=>[...e.map((e,t)=>`${(t?`L`:`M`)+e.x} ${e.y}`),t?`z`:``]).join(``)||`M0 0`}},L=class extends P{static defaultOptions={stroke:!0,color:`#3388ff`,weight:3,opacity:1,lineCap:`round`,lineJoin:`round`,dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:`evenodd`,interactive:!0,bubblingPointerEvents:!0};beforeAdd(e){this._renderer=e.getRenderer(this)}onAdd(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)}onRemove(){this._renderer._removePath(this)}redraw(){return this._map&&this._renderer._updatePath(this),this}_updateInteractive(){this._renderer._updateInteractive(this)}setStyle(e){return f(this,e),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&e&&Object.hasOwn(e,`weight`)&&this._updateBounds()),this}bringToFront(){return this._renderer?._bringToFront(this),this}bringToBack(){return this._renderer?._bringToBack(this),this}getElement(){return this._path}_createRenderer(e){return new I(e)}_reset(){this._project(),this._update()}_clickTolerance(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}},R=class e{constructor(t,n){if(!t)return;if(t instanceof e){t.isValid()&&(this._southWest=new B(t._southWest),this._northEast=new B(t._northEast));return}let r=n?[t,n]:t;for(let e of r)this.extend(e)}static from(t,n){return t instanceof e?t:new e(t,n)}extend(t){let n=this._southWest,r=this._northEast,i,a;if(t instanceof B)i=t,a=t;else if(t instanceof e){if(i=t._southWest,a=t._northEast,!i||!a)return this}else return t?B.validate(t)?this.extend(B.from(t)):this.extend(e.from(t)):this;return!n&&!r?(this._southWest=new B(i.lat,i.lng),this._northEast=new B(a.lat,a.lng)):(n.lat=Math.min(i.lat,n.lat),n.lng=Math.min(i.lng,n.lng),r.lat=Math.max(a.lat,r.lat),r.lng=Math.max(a.lng,r.lng)),this}pad(t){let n=this._southWest,r=this._northEast,i=Math.abs(n.lat-r.lat)*t,a=Math.abs(n.lng-r.lng)*t;return new e(new B(n.lat-i,n.lng-a),new B(r.lat+i,r.lng+a))}getCenter(){return new B((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)}getSouthWest(){return this._southWest}getNorthEast(){return this._northEast}getNorthWest(){return new B(this.getNorth(),this.getWest())}getSouthEast(){return new B(this.getSouth(),this.getEast())}getWest(){return this._southWest.lng}getSouth(){return this._southWest.lat}getEast(){return this._northEast.lng}getNorth(){return this._northEast.lat}contains(t){t=B.validate(t)?B.from(t):e.from(t);let n=this._southWest,r=this._northEast,i,a;return t instanceof e?(i=t.getSouthWest(),a=t.getNorthEast()):i=a=t,i.lat>=n.lat&&a.lat<=r.lat&&i.lng>=n.lng&&a.lng<=r.lng}intersects(t){t=e.from(t);let n=this._southWest,r=this._northEast,i=t.getSouthWest(),a=t.getNorthEast(),o=a.lat>=n.lat&&i.lat<=r.lat,s=a.lng>=n.lng&&i.lng<=r.lng;return o&&s}overlaps(t){t=e.from(t);let n=this._southWest,r=this._northEast,i=t.getSouthWest(),a=t.getNorthEast(),o=a.lat>n.lat&&i.lat<r.lat,s=a.lng>n.lng&&i.lng<r.lng;return o&&s}toBBoxString(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(`,`)}equals(t,n){return t?(t=e.from(t),this._southWest.equals(t.getSouthWest(),n)&&this._northEast.equals(t.getNorthEast(),n)):!1}isValid(){return!!(this._southWest&&this._northEast)}};const z=String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`,He=String.raw`(?:\s*[,;]\s*|\s+)`,Ue=RegExp(`^${z}${He}${z}$`),We=RegExp(`^([NSEW])\\s*${z}${He}([NSEW])\\s*${z}$`,`i`),Ge=RegExp(`^${z}\\s*([NSEW])${He}${z}\\s*([NSEW])$`,`i`),Ke=/^[NSEW]$/i,qe=/^geo:([+-]?\d+(?:\.\d+)?),([+-]?\d+(?:\.\d+)?)(?:,([+-]?\d+(?:\.\d+)?))?(?:[;?].*)?$/i;var B=class e{constructor(t,n,r){if(!e.validate(t,n,r))throw Error(`Invalid LatLng object: (${t}, ${n})`);let i,a,o;t instanceof e?(i=t.lat,a=t.lng,o=t.alt):Array.isArray(t)&&typeof t[0]!=`object`?t.length===3?(i=t[0],a=t[1],o=t[2]):t.length===2&&(i=t[0],a=t[1]):typeof t==`object`&&`lat`in t?(i=t.lat,a=`lng`in t?t.lng:t.lon,o=t.alt):(i=t,a=n,o=r),this.lat=+i,this.lng=+a,o!==void 0&&(this.alt=+o)}static from(t,n,r){return t instanceof e?t:new e(t,n,r)}static validate(t,n,r){return t instanceof e||typeof t==`object`&&t&&`lat`in t?!0:t&&Array.isArray(t)&&typeof t[0]!=`object`?t.length===3||t.length===2:!(!t&&t!==0||!n&&n!==0)}static parse(t){t=t.trim();let n,r,i,a;if(a=qe.exec(t))[n,r,i]=a.slice(1).map(e=>e===void 0?void 0:Number(e));else if(a=Ue.exec(t))[n,r]=a.slice(1).map(Number);else if(a=We.exec(t)??Ge.exec(t)){let e=Ke.test(a[1])?[[a[1],a[2]],[a[3],a[4]]]:[[a[2],a[1]],[a[4],a[3]]];for(let[t,i]of e){let e=t.toUpperCase(),a=Math.abs(Number(i))*(e===`S`||e===`W`?-1:1);if(e===`N`||e===`S`){if(n!==void 0)return null;n=a}else{if(r!==void 0)return null;r=a}}}return n===void 0||Math.abs(n)>90||Math.abs(r)>180?null:new e(n,r,i)}equals(t,n){return t?(t=e.from(t),Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng))<=(n??1e-9)):!1}toString(e){return`LatLng(${l(this.lat,e)}, ${l(this.lng,e)})`}distanceTo(t){return Je(this,e.from(t),6371e3)}wrap(){return new e(this.lat,s(this.lng,[-180,180],!0),this.alt)}toBounds(e){let t=180*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new R([this.lat-t,this.lng-n],[this.lat+t,this.lng+n])}};function Je(e,t,n){let r=Math.PI/180,i=e.lat*r,a=t.lat*r,o=Math.sin((t.lat-e.lat)*r/2),s=Math.sin((t.lng-e.lng)*r/2),c=o*o+Math.cos(i)*Math.cos(a)*s*s;return n*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}var Ye=/* @__PURE__ */ t({_getBitCode:()=>V,_getEdgeIntersection:()=>it,_projectRing:()=>ct,_sqClosestPointOnSegment:()=>ot,clipSegment:()=>rt,closestPointOnSegment:()=>Qe,isFlat:()=>H,pointToSegmentDistance:()=>Ze,polylineCenter:()=>st,simplify:()=>Xe});function Xe(e,t){if(!t||!e.length)return e.slice();let n=t*t;return e=tt(e,n),e=$e(e,n),e}function Ze(e,t,n){return Math.sqrt(ot(e,t,n,!0))}function Qe(e,t,n){return ot(e,t,n)}function $e(e,t){let n=e.length,r=new Uint8Array(n);r[0]=r[n-1]=1,et(e,r,t,0,n-1);let i,a=[];for(i=0;i<n;i++)r[i]&&a.push(e[i]);return a}function et(e,t,n,r,i){let a=0,o,s,c;for(s=r+1;s<=i-1;s++)c=ot(e[s],e[r],e[i],!0),c>a&&(o=s,a=c);a>n&&(t[o]=1,et(e,t,n,r,o),et(e,t,n,o,i))}function tt(e,t){let n=[e[0]],r=0;for(let i=1;i<e.length;i++)at(e[i],e[r])>t&&(n.push(e[i]),r=i);return r<e.length-1&&n.push(e[e.length-1]),n}let nt;function rt(e,t,n,r,i){let a=e,o=t,s=r?nt:V(e,n),c=V(t,n),l,u,d;for(nt=c;;){if(!(s|c))return i&&(e!==a&&(e=e.round()),t!==o&&(t=t.round())),[e,t];if(s&c)return!1;l=s||c,u=it(e,t,l,n),d=V(u,n),l===s?(e=u,s=d):(t=u,c=d)}}function it(e,t,n,r,i){let a=t.x-e.x,o=t.y-e.y,s=r.min,c=r.max,l,u;return n&8?(l=e.x+a*(c.y-e.y)/o,u=c.y):n&4?(l=e.x+a*(s.y-e.y)/o,u=s.y):n&2?(l=c.x,u=e.y+o*(c.x-e.x)/a):n&1&&(l=s.x,u=e.y+o*(s.x-e.x)/a),new g(l,u,i)}function V(e,t){let n=0;return e.x<t.min.x?n|=1:e.x>t.max.x&&(n|=2),e.y<t.min.y?n|=4:e.y>t.max.y&&(n|=8),n}function at(e,t){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function ot(e,t,n,r){let i=t.x,a=t.y,o=n.x-i,s=n.y-a,c,l=o*o+s*s;return l>0&&(c=((e.x-i)*o+(e.y-a)*s)/l,c>1?(i=n.x,a=n.y):c>0&&(i+=o*c,a+=s*c)),o=e.x-i,s=e.y-a,r?o*o+s*s:new g(i,a)}function H(e){return!Array.isArray(e[0])||typeof e[0][0]!=`object`&&e[0][0]!==void 0}function st(e,t){let n=ct(e,t),r=n.length,i=0;for(let e=1;e<r;e++)i+=n[e-1].distanceTo(n[e]);i/=2;let a=n[0];for(let e=1,t=0;e<r;e++){let r=n[e-1],o=n[e],s=r.distanceTo(o);if(t+=s,t>i){let e=(t-i)/s;a=new g(o.x-e*(o.x-r.x),o.y-e*(o.y-r.y));break}}return t.unproject(a)}function ct(e,t){if(!e||e.length===0)throw Error(`latlngs not passed`);return H(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]),e.map(e=>t.project(B.from(e)))}function lt(e,t){return e=B.from(e),e.alt===void 0?[l(e.lng,t),l(e.lat,t)]:[l(e.lng,t),l(e.lat,t),l(e.alt,t)]}function ut(e,t,n,r){let i=e.map(e=>t?ut(e,H(e)?0:t-1,n,r):lt(e,r));return!t&&n&&i.length>0&&i.push(i[0].slice()),i}function U(e,t){return e.feature?{...e.feature,geometry:t}:dt(t)}function dt(e){return e.type===`Feature`||e.type===`FeatureCollection`?e:{type:`Feature`,properties:{},geometry:e}}function ft(e,t){return U(e,{type:`Point`,coordinates:lt(e.getLatLng(),t)})}var W=class e extends L{static defaultOptions={fill:!0,radius:10};constructor(t,n){super(),f(this,n),this._latlng=new B(t),this._radius=this.options.radius,this.callInitHooks(e)}setLatLng(e){let t=this._latlng;return this._latlng=new B(e),this.redraw(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})}getLatLng(){return this._latlng}setRadius(e){return this.options.radius=this._radius=e,this.redraw()}getRadius(){return this._radius}setStyle(e){return super.setStyle(e),e?.radius!==void 0&&this.setRadius(e.radius),this}_project(){this._point=this._map.latLngToLayerPoint(this._latlng),this._pxRadius=this._radius,this._updateBounds()}_updateBounds(){let e=this._pxRadius,t=this._pxRadiusY??e,n=this._clickTolerance(),r=[e+n,t+n];this._pxBounds=new F(this._point.subtract(r),this._point.add(r))}_update(){this._map&&this._updatePath()}_updatePath(){this._renderer._updateCircle(this)}_empty(){return this._pxRadius&&!this._renderer._bounds.intersects(this._pxBounds)}_containsPoint(e){return e.distanceTo(this._point)<=this._pxRadius+this._clickTolerance()}toGeoJSON(e){return ft(this,e)}};const pt=`http://www.w3.org/2000/svg`;var mt=class e extends M{static defaultOptions={position:`bottomright`,collapsed:!1,featureCount:!1,bar:!1};constructor(...t){super(...t),this._classifications=[],this._legendLayers=/* @__PURE__ */ new Set,this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-control-legend`),n=this._details=D(`details`,``,t),r=D(`summary`,`maplair-control-legend-title`,n);return r.textContent=N.translate(`Legend`),n.open=!this.options.collapsed,this._list=D(`div`,`maplair-control-legend-list`,n),w(t),C(t),this._container=t,e.on(`layeradd layerremove`,this._scheduleUpdate,this),this._update(),t}onRemove(e){e.off(`layeradd layerremove`,this._scheduleUpdate,this),cancelAnimationFrame(this._frame),this._frame=null;for(let e of this._legendLayers)e.off(`legendchange`,this._scheduleUpdate,this);this._legendLayers.clear()}addClassification(e,t){return this._classifications.push({layer:e,classification:t}),e.on(`layeradd layerremove`,this._scheduleUpdate,this),this._scheduleUpdate(),this}removeClassification(e){return this._classifications=this._classifications.filter(t=>t.layer!==e),e.off(`layeradd layerremove`,this._scheduleUpdate,this),this._scheduleUpdate(),this}_scheduleUpdate(){this._map&&!this._frame&&(this._frame=requestAnimationFrame(()=>{this._frame=null,this._update()}))}_update(){let e=this._map;if(!e)return;let t=this._classifications.filter(({layer:t})=>e.hasLayer(t)).map(({layer:e,classification:t})=>this._renderClassification(e,t)),n=new Set(Object.values(e._layers).filter(e=>e.getLegend));for(let e of this._legendLayers)n.has(e)||e.off(`legendchange`,this._scheduleUpdate,this);for(let e of n){this._legendLayers.has(e)||e.on(`legendchange`,this._scheduleUpdate,this);let n=e.getLegend();if(n){let e=D(`div`,`maplair-control-legend-section`);typeof n==`string`?e.innerHTML=n:e.append(n),t.push(e)}}this._legendLayers=n,this._list.replaceChildren(...t),this._container.hidden=!t.length}_renderClassification(e,t){let n=e.getLayers(),r=t.featureCount(n),{featureCount:i,bar:a}=this.options,o=D(`div`,`maplair-control-legend-section`),{name:s}=t.options,c=r.reduce((e,t)=>e+(t.counted?t.count:0),0);s&&(D(`div`,`maplair-control-legend-name`,o).textContent=s),i&&(D(`div`,`maplair-control-legend-total`,o).textContent=N.translate(`{n} features`,{n:c}));let l=/* @__PURE__ */ new Map;for(let e of n){let n=t.classify(e),i=r.find(e=>e.classes.includes(n));if(i&&!l.has(i)&&l.set(i,e),l.size===r.length)break}let u=D(`ul`,`maplair-control-legend-items`,o);for(let e of r){let t=D(`li`,``,u);t.append(gt(l.get(e)??n[0],e.symbol,!!l.get(e))),D(`span`,`maplair-control-legend-label`,t).textContent=e.legend,i&&e.counted&&(D(`span`,`maplair-control-legend-count`,t).textContent=ht(e))}if(a&&c){let e=D(`div`,`maplair-control-legend-bar`,o);e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,r.filter(e=>e.counted&&e.count).map(e=>`${e.legend}: ${ht(e)}`).join(`, `));for(let t of r){if(!t.counted||!t.count)continue;let n=D(`div`,``,e);n.style.flexGrow=t.count,n.style.backgroundColor=t.symbol.fillColor??t.symbol.color??``,n.title=`${t.legend}: ${ht(t)}`}}return o}};function ht({count:e,share:t}){return`${e} (${new Intl.NumberFormat(N.getLocale()??void 0,{style:`percent`,maximumFractionDigits:1}).format(t)})`}function gt(e,t,n){for(;e?.getLayers;)e=e.getLayers()[0];e?.setStyle||(e=void 0);let r=e?.options??new W([0,0]).options,i=Object.assign(Object.create(r),e&&n?{}:t),a=document.createElementNS(pt,`svg`);a.setAttribute(`class`,`maplair-control-legend-patch`),a.setAttribute(`width`,16),a.setAttribute(`height`,16),a.setAttribute(`viewBox`,`0 0 16 16`),a.setAttribute(`aria-hidden`,`true`);let o;return o=e?.getLatLngs&&i.fill?_t(`rect`,{x:2,y:2,width:12,height:12}):e?.getLatLngs?_t(`line`,{x1:1,y1:8,x2:15,y2:8}):_t(`circle`,{cx:8,cy:8,r:6}),o.setAttribute(`fill`,i.fill?i.fillColor??i.color:`none`),o.setAttribute(`fill-opacity`,i.fillOpacity),o.setAttribute(`stroke`,i.stroke?i.color:`none`),o.setAttribute(`stroke-opacity`,i.opacity),o.setAttribute(`stroke-width`,Math.min(i.weight,4)),i.dashArray&&o.setAttribute(`stroke-dasharray`,i.dashArray),a.append(o),a}function _t(e,t){let n=document.createElementNS(pt,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}var vt=class{static projection=void 0;static transformation=void 0;static latLngToPoint(e,t){let n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)}static pointToLatLng(e,t){let n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)}static project(e){return this.projection.project(e)}static unproject(e){return this.projection.unproject(e)}static scale(e){return 256*2**e}static zoom(e){return Math.log(e/256)/Math.LN2}static getProjectedBounds(e){if(this.infinite)return null;let t=this.projection.bounds,n=this.scale(e);return new F(this.transformation.transform(t.min,n),this.transformation.transform(t.max,n))}static infinite=!1;static wrapLatLng(e){e=B.from(e);let t=this.wrapLng?s(e.lng,this.wrapLng,!0):e.lng,n=this.wrapLat?s(e.lat,this.wrapLat,!0):e.lat,r=e.alt;return new B(n,t,r)}static wrapLatLngBounds(e){e=new R(e);let t=e.getCenter(),n=this.wrapLatLng(t),r=t.lat-n.lat,i=t.lng-n.lng;if(r===0&&i===0)return e;let a=e.getSouthWest(),o=e.getNorthEast();return new R(new B(a.lat-r,a.lng-i),new B(o.lat-r,o.lng-i))}},G=class extends vt{static wrapLng=[-180,180];static R=6371e3;static distance(e,t){return Je(e,t,this.R)}};const yt=6378137,bt={R:yt,MAX_LATITUDE:85.0511287798,project(e){e=B.from(e);let t=Math.PI/180,n=this.MAX_LATITUDE,r=Math.max(Math.min(n,e.lat),-n),i=Math.sin(r*t);return new g(this.R*e.lng*t,this.R*Math.log((1+i)/(1-i))/2)},unproject(e){e=g.from(e);let t=180/Math.PI;return new B((2*Math.atan(Math.exp(e.y/this.R))-Math.PI/2)*t,e.x*t/this.R)},bounds:/* @__PURE__ */ (()=>{let e=yt*Math.PI;return new F([-e,-e],[e,e])})()};var xt=class{constructor(e,t,n,r){Array.isArray(e)?(this._a=e[0],this._b=e[1],this._c=e[2],this._d=e[3]):(this._a=e,this._b=t,this._c=n,this._d=r)}transform(e,t){return this._transform(new g(e),t)}_transform(e,t){return t||=1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e}untransform(e,t){return t||=1,new g((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}},St=class extends G{static code=`EPSG:3857`;static projection=bt;static transformation=/* @__PURE__ */ (()=>{let e=.5/(Math.PI*bt.R);return new xt(e,.5,-e,.5)})()},Ct=class extends St{static code=`EPSG:900913`},wt=class e extends Pe{constructor(...t){super(...t),this.callInitHooks(e)}run(e,t,n,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=n??.25,this._easeOutPower=1/Math.max(r??.5,.2),this._startPos=j(e),this._offset=t.subtract(this._startPos),this._startTime=Date.now(),this.fire(`start`),this._animate()}stop(){this._inProgress&&(this._step(!0),this._complete())}_animate(){this._animId=requestAnimationFrame(this._animate.bind(this)),this._step()}_step(e){let t=Date.now()-this._startTime,n=this._duration*1e3;t<n?this._runFrame(this._easeOut(t/n),e):(this._runFrame(1),this._complete())}_runFrame(e,t){let n=this._startPos.add(this._offset.multiplyBy(e));t&&n._round(),A(this._el,n),this.fire(`step`)}_complete(){cancelAnimationFrame(this._animId),this._inProgress=!1,this.fire(`end`)}_easeOut(e){return 1-(1-e)**this._easeOutPower}},Tt=class e extends M{static defaultOptions={position:`topleft`,zoomInText:`<span aria-hidden="true">+</span>`,zoomOutText:`<span aria-hidden="true">−</span>`};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=`maplair-control-zoom`,n=D(`div`,`${t} maplair-bar`),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,N.translate(`Zoom in`),`${t}-in`,n,this._zoomIn),this._zoomOutButton=this._createButton(r.zoomOutText,N.translate(`Zoom out`),`${t}-out`,n,this._zoomOut),this._updateDisabled(),e.on(`zoomend zoomlevelschange`,this._updateDisabled,this),n}onRemove(e){e.off(`zoomend zoomlevelschange`,this._updateDisabled,this)}disable(){return this._disabled=!0,this._updateDisabled(),this}enable(){return this._disabled=!1,this._updateDisabled(),this}_zoomIn(e){!this._disabled&&this._map._zoom<this._map.getMaxZoom()&&(this._map._setUserEvent(e),this._map.zoomIn(this._map.options.zoomDelta*(e.shiftKey?3:1)))}_zoomOut(e){!this._disabled&&this._map._zoom>this._map.getMinZoom()&&(this._map._setUserEvent(e),this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1)))}_createButton(e,t,n,r,i){let a=D(`button`,n,r);return a.type=`button`,a.innerHTML=e,a.title=t,a.setAttribute(`aria-label`,t),w(a),y(a,`click`,E),y(a,`click`,i,this),y(a,`click`,this._refocusOnMap,this),a}_updateDisabled(){let e=this._map,t=`maplair-disabled`;this._zoomInButton.classList.remove(t),this._zoomOutButton.classList.remove(t),this._zoomInButton.setAttribute(`aria-disabled`,`false`),this._zoomOutButton.setAttribute(`aria-disabled`,`false`),(this._disabled||e._zoom===e.getMinZoom())&&(this._zoomOutButton.classList.add(t),this._zoomOutButton.setAttribute(`aria-disabled`,`true`)),(this._disabled||e._zoom===e.getMaxZoom())&&(this._zoomInButton.classList.add(t),this._zoomInButton.setAttribute(`aria-disabled`,`true`))}static register(t){t.mergeOptions({zoomControl:!0}),t.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new e,this.addControl(this.zoomControl))})}},Et=class e extends P{constructor(t,n){super(),f(this,n),this._layers={};for(let e of t??[])this.addLayer(e);this.callInitHooks(e)}addLayer(e){let t=this.getLayerId(e);return this._layers[t]=e,this._map?.addLayer(e),this}removeLayer(e){let t=e in this._layers?e:this.getLayerId(e);return this._map&&this._layers[t]&&this._map.removeLayer(this._layers[t]),delete this._layers[t],this}hasLayer(e){return(typeof e==`number`?e:this.getLayerId(e))in this._layers}clearLayers(){return this.eachLayer(this.removeLayer,this)}onAdd(e){this.eachLayer(e.addLayer,e)}onRemove(e){this.eachLayer(e.removeLayer,e)}eachLayer(e,t){for(let n of Object.values(this._layers))e.call(t,n);return this}getLayer(e){return this._layers[e]}getLayers(){let e=[];return this.eachLayer(e.push,e),e}setZIndex(e){return this.eachLayer(t=>t.setZIndex?.(e))}getLayerId(e){return a(e)}toMultiPoint(e){let t=[];return this.eachLayer(n=>{t.push(n.toGeoJSON(e).geometry.coordinates)}),U(this,{type:`MultiPoint`,coordinates:t})}toGeoJSON(e){let t=this.feature?.geometry?.type;if(t===`MultiPoint`)return this.toMultiPoint(e);let n=t===`GeometryCollection`,r=[];return this.eachLayer(t=>{if(t.toGeoJSON){let i=t.toGeoJSON(e);if(n)r.push(i.geometry);else{let e=dt(i);e.type===`FeatureCollection`?r.push(...e.features):r.push(e)}}}),n?U(this,{geometries:r,type:`GeometryCollection`}):{type:`FeatureCollection`,features:r}}},K=class e extends Et{constructor(...t){super(...t),this.callInitHooks(e)}addLayer(e){return this.hasLayer(e)?this:(e.addEventParent(this),super.addLayer(e),this.fire(`layeradd`,{layer:e}))}removeLayer(e){return this.hasLayer(e)?(e in this._layers&&(e=this._layers[e]),e.removeEventParent(this),super.removeLayer(e),this.fire(`layerremove`,{layer:e})):this}setStyle(e){return this.eachLayer(t=>t.setStyle?.(e))}setInteractive(e){return f(this,{interactive:!!e}),this.eachLayer(t=>t.setInteractive?.(e))}bringToFront(){return this.eachLayer(e=>e.bringToFront?.())}bringToBack(){return this.eachLayer(e=>e.bringToBack?.())}getBounds(){let e=new R;for(let t of Object.values(this._layers))e.extend(t.getBounds?t.getBounds():t.getLatLng());return e}};const Dt={_initOverlay(e,t,n,r){let i=t;return i instanceof e||(i=new e(r).setContent(t)),n&&i.setLatLng(n),i}},Ot={_initOverlay(e,t,n,r){let i=n;return i instanceof e?(f(i,r),i._source=this):(i=t&&!r?t:new e(r,this),i.setContent(n)),i}};var q=class e extends P{static defaultOptions={interactive:!1,offset:[0,0],className:``,pane:void 0,overflow:!1,content:``};constructor(t,n){super(),t instanceof B||Array.isArray(t)?(this._latlng=new B(t),f(this,n)):(f(this,t),this._source=n),this.options.content&&(this._content=this.options.content),this.callInitHooks(e)}openOn(e){return e=arguments.length?e:this._source._map,e.hasLayer(this)||e.addLayer(this),this}close(){return this._map?.removeLayer(this),this}toggle(e){return this._map?this.close():(arguments.length?this._source=e:e=this._source,this._prepareOpen(),this.openOn(e._map)),this}onAdd(e){this._container||this._initLayout(),e._fadeAnimated&&(this._container.style.opacity=`0`),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.options.overflow&&(this._container.classList.add(`maplair-overflow`),this._container.popover=`manual`,this._container.showPopover(),this._onPageChange??=()=>this._updatePosition(),document.addEventListener(`scroll`,this._onPageChange,{capture:!0,passive:!0}),window.addEventListener(`resize`,this._onPageChange,{passive:!0})),this.update(),e._fadeAnimated&&(this._container.style.opacity=`1`),this.options.overflow||this.bringToFront(),this.options.interactive&&(this._container.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._container))}onRemove(e){this.options.overflow&&(document.removeEventListener(`scroll`,this._onPageChange,{capture:!0}),window.removeEventListener(`resize`,this._onPageChange)),e._fadeAnimated?(this._container.style.opacity=`0`,this._removeTimeout=setTimeout(()=>this._container.remove(),200)):this._container.remove(),this.options.interactive&&(this._container.classList.remove(`maplair-interactive`),this.removeInteractiveTarget(this._container))}_updateInteractive(){this._container.classList.toggle(`maplair-interactive`,this.options.interactive),this.options.interactive?this.addInteractiveTarget(this._container):this.removeInteractiveTarget(this._container)}getLatLng(){return this._latlng}setLatLng(e){return this._latlng=new B(e),this._map&&(this._updatePosition(),this._adjustPan()),this}getContent(){return this._content}setContent(e){return this._content=e,this.update(),this}getElement(){return this._container}update(){this._map&&(this._container.style.visibility=`hidden`,this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility=``,this._adjustPan())}getEvents(){let e={zoom:this._updatePosition,viewreset:this._updatePosition,zoomanim:this._animateZoom};return this.options.overflow&&(e.move=this._updatePosition),e}isOpen(){return!!this._map&&this._map.hasLayer(this)}bringToFront(){return this._map&&(O(this._container),this._restackPopovers()),this}bringToBack(){return this._map&&(Se(this._container),this._restackPopovers()),this}_restackPopovers(){if(this.options.overflow)for(let e of this.getPane().children)e.classList.contains(`maplair-overflow`)&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}_prepareOpen(e){let t=this._source;if(!t._map)return!1;if(t instanceof K){t=null;for(let e of Object.values(this._source._layers))if(e._map){t=e;break}if(!t)return!1;this._source=t}if(!e){if(t.getCenter)e=t.getCenter();else if(t.getLatLng)e=t.getLatLng();else if(t.getBounds)e=t.getBounds().getCenter();else throw Error(`Unable to get source layer LatLng.`)}return this.setLatLng(e),this._map&&this.update(),!0}_updateContent(){if(!this._content)return;let e=this._contentNode,t=typeof this._content==`function`?this._content(this._source??this):this._content;if(typeof t==`string`)e.innerHTML=t;else{for(;e.hasChildNodes();)e.removeChild(e.firstChild);e.appendChild(t)}this.fire(`contentupdate`)}_updatePosition(){if(!this._map)return;let e=this._map.latLngToLayerPoint(this._latlng),t=g.from(this.options.offset);this._setContainerPosition(e.add(this._getAnchor()));let n=this._containerBottom=-t.y,r=this._containerLeft=-Math.round(this._containerWidth/2)+t.x;this.options.overflow?(this._container.style.top=`auto`,this._container.style.bottom=`calc(100% + ${n}px)`):this._container.style.bottom=`${n}px`,this._container.style.left=`${r}px`}_setContainerPosition(e){if(this._containerPos=e,this.options.overflow){let t=this._map._container,n=t.getBoundingClientRect();e=this._map.layerPointToContainerPoint(e)._add(new g(n.left+t.clientLeft,n.top+t.clientTop))}A(this._container,e)}_getContainerPosition(){return this._containerPos??new g(0,0)}_getAnchor(){return[0,0]}static register(e){e.include(Dt),P.include(Ot)}};const kt={openPopup(e,t,n){return this._initOverlay(jt,e,t,n).openOn(this),this},closePopup(e){return e=arguments.length?e:this._popup,e?.close(),this}},At={bindPopup(e,t){return this._popup=this._initOverlay(jt,this._popup,e,t),this.on({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),this},unbindPopup(){return this._popup&&=(this.off({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),null),this},openPopup(e){return this._popup&&(this instanceof K||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup(){return this._popup?.close(),this},togglePopup(){return this._popup?.toggle(this),this},isPopupOpen(){return this._popup?.isOpen()??!1},setPopupContent(e){return this._popup?.setContent(e),this},getPopup(){return this._popup},_openPopup(e){if(!this._popup||!this._map)return;E(e);let t=e.propagatedFrom??e.target;this._popup._source===t&&!(t instanceof L)?this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng):(this._popup._source=t,this.openPopup(e.latlng))},_movePopup(e){this._popup.setLatLng(e.latlng)}};var jt=class e extends q{static defaultOptions={pane:`popupPane`,offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:``,trackResize:!0};constructor(...t){super(...t),this.callInitHooks(e)}openOn(e){return e=arguments.length?e:this._source._map,!e.hasLayer(this)&&e._popup&&e._popup.options.autoClose&&e.removeLayer(e._popup),e._popup=this,super.openOn(e)}onAdd(e){let t=document.activeElement;this._returnFocus=e._container.contains(t)&&!this._container?.contains(t)?t:null,super.onAdd(e),this._source?._clickedByKeyboard&&(this._closeButton||(this._container.tabIndex=-1),(this._closeButton??this._container).focus({preventScroll:!0})),e.fire(`popupopen`,{popup:this}),this._source&&(this._source.fire(`popupopen`,{popup:this},!0),this._source instanceof L||this._source.on(`preclick`,S))}onRemove(e){this._container.contains(document.activeElement)&&this._returnFocus?.isConnected&&this._returnFocus.focus({preventScroll:!0}),this._returnFocus=null,super.onRemove(e),e.fire(`popupclose`,{popup:this}),this._source&&(this._source.fire(`popupclose`,{popup:this},!0),this._source instanceof L||this._source.off(`preclick`,S))}getEvents(){let e=super.getEvents();return(this.options.closeOnClick??this._map.options.closePopupOnClick)&&(e.preclick=this.close),this.options.keepInView&&(e.moveend=this._adjustPan),e}_initLayout(){let e=`maplair-popup`,t=this._container=D(`div`,`${e} ${this.options.className||``} maplair-zoom-animated`),n=this._wrapper=D(`div`,`${e}-content-wrapper`,t);if(this._contentNode=D(`div`,`${e}-content`,n),w(t),y(t,`keydown`,e=>{e.key===`Escape`&&this.options.closeOnEscapeKey&&this.close()}),C(this._contentNode),y(t,`contextmenu`,S),this._tipContainer=D(`div`,`${e}-tip-container`,t),this._tip=D(`div`,`${e}-tip`,this._tipContainer),this.options.closeButton){let n=this._closeButton=D(`button`,`${e}-close-button`,t);n.type=`button`,n.setAttribute(`aria-label`,N.translate(`Close popup`)),n.innerHTML=`<span aria-hidden="true">×</span>`,y(n,`click`,e=>{e.preventDefault(),this.close()})}this.options.trackResize&&(this._resizeObserver=new ResizeObserver((e=>{this._map&&(this._containerWidth=e[0]?.contentRect?.width,this._containerHeight=e[0]?.contentRect?.height,this._updateLayout(),this._updatePosition(),this._adjustPan())})),this._resizeObserver.observe(this._contentNode))}_updateLayout(){let e=this._contentNode,t=e.style;t.maxWidth=`${this.options.maxWidth}px`,t.minWidth=`${this.options.minWidth}px`;let n=this.options.maxHeight,r=`maplair-popup-scrolled`;n&&(this._containerHeight??e.offsetHeight)>n?(t.height=`${n}px`,e.classList.add(r)):e.classList.remove(r),this._containerWidth=this._container.offsetWidth,this._containerHeight=this._container.offsetHeight,this._containerMarginBottom=parseInt(getComputedStyle(this._container).marginBottom,10)||0}_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._getAnchor();this._setContainerPosition(t.add(n))}_adjustPan(){if(!this.options.autoPan||(this._map._panAnim?.stop(),!this._map))return;if(this._autopanning){this._autopanning=!1;return}let e=this._map,t=this._containerMarginBottom??(parseInt(getComputedStyle(this._container).marginBottom,10)||0),n=this._containerHeight+t,r=this._containerWidth,i=new g(this._containerLeft,-n-this._containerBottom);i._add(this._getContainerPosition());let a=e.layerPointToContainerPoint(i),o=g.from(this.options.autoPanPadding),s=g.from(this.options.autoPanPaddingTopLeft??o),c=g.from(this.options.autoPanPaddingBottomRight??o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}_getAnchor(){return new g(this._source?._getPopupAnchor?this._source._getPopupAnchor():[0,0])}static register(e){e.mergeOptions({closePopupOnClick:!0}),e.include(kt),P.include(At)}};const Mt=[`top`,`bottom`,`center`,`right`,`left`];function Nt(e,t,n,r){return Math.max(0,n-e)-Math.max(0,e+t-r)}function Pt(e,t){let n=Math.max(0,t/2-12);return Math.round(Math.min(n,Math.max(-n,e)))}const Ft={openTooltip(e,t,n){return this._initOverlay(J,e,t,n).openOn(this),this},closeTooltip(e){return e.close(),this}},It={bindTooltip(e,t){return this._tooltip&&this.isTooltipOpen()&&this.unbindTooltip(),this._tooltip=this._initOverlay(J,this._tooltip,e,t),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip(){return this._tooltip&&=(this._initTooltipInteractions(!0),this.closeTooltip(),null),this},_initTooltipInteractions(e){if(!e&&this._tooltipHandlersAdded)return;let t=e?`off`:`on`,n={remove:this.closeTooltip,move:this._moveTooltip};this._tooltip.options.permanent?n.add=this._openTooltip:(n.pointerover=this._openTooltip,n.pointerout=this.closeTooltip,n.click=this._openTooltip,this._map?this._addFocusListeners(e):n.add=()=>this._addFocusListeners(e)),this._tooltip.options.sticky&&(n.pointermove=this._moveTooltip),this[t](n),this._tooltipHandlersAdded=!e},openTooltip(e){return this._tooltip&&(this instanceof K||(this._tooltip._source=this),this._tooltip._prepareOpen(e)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip(){return this._tooltip?.close(),this},toggleTooltip(){return this._tooltip?.toggle(this),this},isTooltipOpen(){return this._tooltip?.isOpen()??!1},setTooltipContent(e){return this._tooltip?.setContent(e),this},getTooltip(){return this._tooltip},_addFocusListeners(e){this.getElement?this._addFocusListenersOnLayer(this,e):this.eachLayer&&this.eachLayer(t=>this._addFocusListenersOnLayer(t,e),this)},_addFocusListenersOnLayer(e,t){let n=typeof e.getElement==`function`&&e.getElement();if(n){let r=t?x:y;t||(n._maplair_focus_handler&&x(n,`focus`,n._maplair_focus_handler,this),n._maplair_focus_handler=()=>{this._tooltip&&(this._tooltip._source=e,this.openTooltip())}),n._maplair_focus_handler&&r(n,`focus`,n._maplair_focus_handler,this),r(n,`blur`,this.closeTooltip,this),t&&delete n._maplair_focus_handler}},_setAriaDescribedByOnLayer(e){(typeof e.getElement==`function`&&e.getElement())?.setAttribute?.(`aria-describedby`,this._tooltip._container.id)},_openTooltip(e){this._tooltip&&this._map&&(this._map.dragging?.moving()?e.type===`add`&&!this._moveEndOpensTooltip&&(this._moveEndOpensTooltip=!0,this._map.once(`moveend`,()=>{this._moveEndOpensTooltip=!1,this._openTooltip(e)})):(this._tooltip._source=e.propagatedFrom??e.target,this.openTooltip(this._tooltip.options.sticky?e.latlng:void 0)))},_moveTooltip(e){let t=e.latlng,n,r;this._tooltip.options.sticky&&e.originalEvent&&(n=this._map.pointerEventToContainerPoint(e.originalEvent),r=this._map.containerPointToLayerPoint(n),t=this._map.layerPointToLatLng(r)),this._tooltip.setLatLng(t)}};var J=class e extends q{static defaultOptions={pane:`tooltipPane`,offset:[0,0],direction:`auto`,permanent:!1,sticky:!1,opacity:.9};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){super.onAdd(e),this.setOpacity(this.options.opacity),e.fire(`tooltipopen`,{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire(`tooltipopen`,{tooltip:this},!0))}onRemove(e){super.onRemove(e),e.fire(`tooltipclose`,{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire(`tooltipclose`,{tooltip:this},!0))}getEvents(){let e=super.getEvents();return this.options.permanent||(e.preclick=this.close),e}_initLayout(){let e=`maplair-tooltip ${this.options.className||``} maplair-zoom-animated`;this._contentNode=this._container=D(`div`,e),this._container.setAttribute(`role`,`tooltip`),this._container.setAttribute(`id`,`maplair-tooltip-${a(this)}`)}_updateLayout(){}_adjustPan(){}update(){this._autoDirection=void 0,super.update()}_setPosition(e){let t=this.options.direction,n=new g(0,0),r=this._container,i=r.offsetWidth,a=r.offsetHeight,o=new g(this.options.offset),s=this._getAnchor();Mt.includes(t)||({direction:t,shift:n}=this._getAutoPlacement(e,o,s,i,a),t===`left`&&(o.x=-o.x,s.x=-s.x));let c=i/2,l=a/2;t===`top`?l=a:t===`bottom`?l=0:t===`right`?c=0:t===`left`&&(c=i),e=e.subtract(new g(c,l,!0)).add(o).add(s).add(n),r.classList.remove(`maplair-tooltip-right`,`maplair-tooltip-left`,`maplair-tooltip-top`,`maplair-tooltip-bottom`),r.classList.add(`maplair-tooltip-${t}`);let u=t===`top`||t===`bottom`?Pt(-n.x,i):Pt(-n.y,a);u?r.style.setProperty(`--maplair-tooltip-tip-shift`,`${u}px`):r.style.removeProperty(`--maplair-tooltip-tip-shift`),this._setContainerPosition(e)}_getAutoPlacement(e,t,n,r,i){let a=this._getAutoArea(),o=this._map.layerPointToContainerPoint(e),s=o.x+t.x+n.x,c=o.y+t.y+n.y,l={right:a.max.x-s-r-6,left:o.x-t.x-n.x-a.min.x-r-6,top:c-a.min.y-i-6,bottom:a.max.y-c-i-6};if(!this._autoDirection){let e=o.x<(a.min.x+a.max.x)/2?[`right`,`left`]:[`left`,`right`],t=l.right>=l.left?`right`:`left`;this._autoDirection=[...e,`top`,`bottom`].find(e=>l[e]>=0&&(e===`right`||e===`left`||r<=a.max.x-a.min.x))??t}let u=this._autoDirection;return{direction:u,shift:u===`top`||u===`bottom`?new g(Nt(s-r/2,r,a.min.x,a.max.x),0):new g(0,Nt(c-i/2,i,a.min.y,a.max.y))}}_getAutoArea(){let e=this._map,t=new g(0,0),n=e.getSize();if(this.options.overflow){let r=e._container,i=r.getBoundingClientRect(),a=new g(i.left+r.clientLeft,i.top+r.clientTop),o=document.documentElement;t=t.subtract(a),n=new g(o.clientWidth,o.clientHeight).subtract(a)}let r=new g(4,4);return{min:t.add(r),max:n.subtract(r)}}_updatePosition(){let e=this._map.latLngToLayerPoint(this._latlng);this._setPosition(e)}setOpacity(e){this.options.opacity=e,this._container&&(this._container.style.opacity=`${e}`)}_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);this._setPosition(t)}_getAnchor(){return new g(this._source?._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}static register(e){e.include(Ft),P.include(It)}},Lt=/* @__PURE__ */ t({register:()=>zt});const Rt={getRenderer(e){let t=e.options.renderer??this._getPaneRenderer(e)??this.options.renderer??(this._renderer??=e._createRenderer());return this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer(e){let t=e.options.pane;if(t===`overlayPane`||t===void 0)return;let n=this._paneRenderers[t];if(!n){let r=this.options.renderer?.constructor;n=r?new r({...this.options.renderer.options,pane:t}):e._createRenderer({pane:t}),this._paneRenderers[t]=n}return n}};function zt(e){e.include(Rt),e.addInitHook(function(){this.options.preferCanvas!==void 0&&console.error(`MaplairMap: preferCanvas option has been removed. Use renderer: new Canvas() instead.`)})}var Y=class e extends h{constructor(t){super(),this._map=t,this.callInitHooks(e)}enable(){return this._enabled||(this._enabled=!0,this.addHooks()),this}disable(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this}enabled(){return!!this._enabled}static addTo(e,t){return e.addHandler(t,this),this}},Bt=class e extends Y{constructor(t){super(t),this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on(`unload`,this._destroy,this),this.callInitHooks(e)}addHooks(){y(this._container,`pointerdown`,this._onPointerDown,this)}removeHooks(){x(this._container,`pointerdown`,this._onPointerDown,this)}moved(){return this._moved}_destroy(){this._pane.remove(),delete this._pane}_resetState(){this._resetStateTimeout=0,this._moved=!1}_clearDeferredResetState(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)}_onPointerDown(e){if(!e.shiftKey||e.button!==0)return!1;this._clearDeferredResetState(),this._resetState(),T(e),this._startPoint=this._map.pointerEventToContainerPoint(e),y(this._container,{contextmenu:E,pointermove:this._onPointerMove,pointerup:this._onPointerUp,keydown:this._onKeyDown},this),y(document,`keydown`,this._onKeyDown,this)}_onPointerMove(e){this._moved||(this._moved=!0,this._box=D(`div`,`maplair-zoom-box`,this._container),this._container.classList.add(`maplair-crosshair`),this._map.fire(`boxzoomstart`)),this._point=this._map.pointerEventToContainerPoint(e);let t=new F(this._point,this._startPoint),n=t.getSize();A(this._box,t.min),this._box.style.width=`${n.x}px`,this._box.style.height=`${n.y}px`}_finish(){this._moved&&(this._box.remove(),this._container.classList.remove(`maplair-crosshair`)),x(this._container,{contextmenu:E,pointermove:this._onPointerMove,pointerup:this._onPointerUp},this),x(document,`keydown`,this._onKeyDown,this)}_onPointerUp(e){if(e.button!==0||(this._finish(),!this._moved))return;this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(this._resetState.bind(this),0);let t=new R(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map._setUserEvent(e),this._map.getBoundsZoom(t)!==1/0&&this._map.fitBounds(t),this._map.fire(`boxzoomend`,{boxZoomBounds:t})}_onKeyDown(e){e.code===`Escape`&&(this._finish(),this._clearDeferredResetState(),this._resetState())}static register(t){t.mergeOptions({boxZoom:!0}),t.addInitHook(`addHandler`,`boxZoom`,e)}},Vt=class e extends Y{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){this._map.on(`dblclick`,this._onDoubleClick,this)}removeHooks(){this._map.off(`dblclick`,this._onDoubleClick,this)}_onDoubleClick(e){let t=this._map,n=t.getZoom(),r=t.options.zoomDelta,i=e.originalEvent.shiftKey?n-r:n+r;t._setUserEvent(e.originalEvent),t.options.doubleClickZoom===`center`?t.setZoom(i):t.setZoomAround(e.containerPoint,i)}static register(t){t.mergeOptions({doubleClickZoom:!0}),t.addInitHook(`addHandler`,`doubleClickZoom`,e)}},X=class e extends Pe{static defaultOptions={clickTolerance:3};constructor(t,n,r){if(typeof r==`boolean`)throw Error(`Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.`);super(),f(this,r),this._element=t,this._dragStartTarget=n??t,this.callInitHooks(e)}enable(){this._enabled||=(y(this._dragStartTarget,`pointerdown`,this._onDown,this),!0)}disable(){this._enabled&&(e._dragging===this&&this.finishDrag(!0),x(this._dragStartTarget,`pointerdown`,this._onDown,this),this._enabled=!1,this._moved=!1)}_onDown(t){if(this._moved=!1,this._element.classList.contains(`maplair-zoom-anim`))return;if(v().length!==1){e._dragging===this&&this.finishDrag();return}if(e._dragging||t.shiftKey||t.button!==0&&t.pointerType!==`touch`||(e._dragging=this,we(),this._moving))return;this.fire(`down`);let n=Ee(this._element);this._startPoint=new g(t.clientX,t.clientY),this._startPos=j(this._element),this._parentScale=De(n),y(this._dragStartTarget,`pointermove`,this._onMove,this),y(this._dragStartTarget,`pointerup pointercancel lostpointercapture`,this._onUp,this)}_onMove(e){if(v().length>1){this._moved=!0;return}let t=new g(e.clientX,e.clientY)._subtract(this._startPoint),n=Math.abs(t.x)+Math.abs(t.y);!this._moved&&(!n||n<this.options.clickTolerance)||(t.x/=this._parentScale.x,t.y/=this._parentScale.y,e.cancelable&&e.preventDefault(),this._moved||(this.fire(`dragstart`,{originalEvent:e}),this._moved=!0,this._draggingContainer=this._element.closest(`.maplair-container`)??this._element,this._draggingContainer.classList.add(`maplair-dragging`),this._lastTarget=e.target,this._lastTarget.classList.add(`maplair-drag-target`)),this._newPos=this._startPos.add(t),this._moving=!0,this._lastEvent=e,this._updatePosition())}_updatePosition(){let e={originalEvent:this._lastEvent};this.fire(`predrag`,e);let t=window.devicePixelRatio;this._newPos=this._newPos.multiplyBy(t)._round()._divideBy(t),A(this._element,this._newPos),this.fire(`drag`,e)}_onUp(e){e.type===`lostpointercapture`&&e.buttons||this.finishDrag()}finishDrag(t){this._draggingContainer?.classList.remove(`maplair-dragging`),this._draggingContainer=null,this._lastTarget&&=(this._lastTarget.classList.remove(`maplair-drag-target`),null),x(this._dragStartTarget,`pointermove`,this._onMove,this),x(this._dragStartTarget,`pointerup pointercancel lostpointercapture`,this._onUp,this),Te();let n=this._moved&&this._moving;this._moving=!1,e._dragging=!1,n&&this.fire(`dragend`,{noInertia:t,distance:this._newPos.distanceTo(this._startPos)})}},Ht=class e extends Y{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){if(!this._draggable){let e=this._map;this._draggable=new X(e._mapPane,e._container),this._draggable.on({down:this._onDown,dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on(`predrag`,this._onPreDragLimit,this),e.options.worldCopyJump&&this._draggable.on(`predrag`,this._onPreDragWrap,this)}this._map._container.classList.add(`maplair-grab`,`maplair-touch-drag`),this._draggable.enable(),this._positions=[],this._times=[]}removeHooks(){this._map._container.classList.remove(`maplair-grab`,`maplair-touch-drag`),this._draggable.disable()}moved(){return this._draggable?._moved}moving(){return this._draggable?._moving}_onDown(){this._map._stop()}_onDragStart(e){let t=this._map;if(t._stop(),t._setUserEvent(e.originalEvent),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){let e=R.from(this._map.options.maxBounds);this._offsetLimit=new F(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire(`movestart`).fire(`dragstart`),t.options.inertia&&(this._positions=[],this._times=[])}_onDrag(e){if(this._map.options.inertia){let e=this._lastTime=Date.now(),t=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(t),this._times.push(e),this._prunePositions(e)}this._map.fire(`move`,e).fire(`drag`,e)}_prunePositions(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()}_viscousLimit(e,t){return e-(e-t)*this._viscosity}_onPreDragLimit(){if(!this._viscosity||!this._offsetLimit)return;let e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.x<t.min.x&&(e.x=this._viscousLimit(e.x,t.min.x)),e.y<t.min.y&&(e.y=this._viscousLimit(e.y,t.min.y)),e.x>t.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}_onPreDragWrap(){let e=this._draggable;e._absPos=e._newPos,e._newPos=this._map._wrapWorldCopy(e._newPos)}_onDragEnd(e){let t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(Date.now());let e=this._lastPos.subtract(this._positions[0]),r=(this._lastTime-this._times[0])/1e3,i=n.easeLinearity,a=e.multiplyBy(i/r),o=a.distanceTo([0,0]),s=Math.min(n.inertiaMaxSpeed,o),c=a.multiplyBy(s/o),l=t.getSize().divideBy(2),u=s/(n.inertiaDeceleration*i),d=c.multiplyBy(-u/2).round();if(t._prefersReducedMotion()&&!l.contains(d)){let e=Math.min(l.x/Math.abs(d.x),l.y/Math.abs(d.y));d=d.multiplyBy(e).round(),u*=Math.sqrt(e)}!d.x&&!d.y?t.fire(`moveend`):(d=t._limitOffset(d,t.options.maxBounds),requestAnimationFrame(()=>{t.panBy(d,{duration:u,easeLinearity:i,noMoveStart:!0,animate:!0})}))}}static register(t){t.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1400,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0}),t.addInitHook(`addHandler`,`dragging`,e)}},Ut=class e extends Y{static keys={left:[`ArrowLeft`],right:[`ArrowRight`],down:[`ArrowDown`],up:[`ArrowUp`],zoomIn:[`+`,`=`],zoomOut:[`-`,`_`]};constructor(t){super(t),this._setPanDelta(t.options.keyboardPanDelta),this._setZoomDelta(t.options.zoomDelta),this.callInitHooks(e)}addHooks(){let e=this._map._container;e.tabIndex<=0&&(e.tabIndex=0);let t=this._map.options.ariaKeyShortcuts;t&&(e.ariaKeyShortcuts=t===!0?`ArrowLeft ArrowRight ArrowUp ArrowDown = Plus -`:t),y(e,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.on({focus:this._addHooks,blur:this._removeHooks},this)}removeHooks(){this._removeHooks(),this._map.options.ariaKeyShortcuts&&this._map._container.removeAttribute(`aria-keyshortcuts`),x(this._map._container,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown},this),this._map.off({focus:this._addHooks,blur:this._removeHooks},this),this._help?.remove(),this._help=null}_toggleHelp(){this._help??=this._createHelp(),this._help.togglePopover()}_createHelp(){let e=D(`div`,`maplair-keyboard-help`,this._map._container),t=N.translate(`Keyboard shortcuts`);e.popover=`auto`,e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-label`,t),D(`h2`,``,e).textContent=t;let n=D(`dl`,``,e);for(let[e,t]of[[[`←`,`→`,`↑`,`↓`],N.translate(`Pan the map`)],[[`+`],N.translate(`Zoom in`)],[[`−`],N.translate(`Zoom out`)],[[`Shift`],N.translate(`Pan or zoom further, together with the keys above`)],[[`Esc`],N.translate(`Close popup`)],[[`?`],N.translate(`Show or hide the keyboard shortcuts`)]]){let r=D(`div`,``,n),i=D(`dt`,``,r);for(let t of e)D(`kbd`,``,i).textContent=t;D(`dd`,``,r).textContent=t}return w(e),C(e),e}_onPointerDown(){this._focused||this._map._container.focus({preventScroll:!0,focusVisible:!1})}_onFocus(){this._focused=!0,this._map.fire(`focus`)}_onBlur(){this._focused=!1,this._map.fire(`blur`)}_setPanDelta(t){let n=this._panKeys={},{left:r,right:i,down:a,up:o}=e.keys;for(let e of r)n[e]=[-t,0];for(let e of i)n[e]=[t,0];for(let e of a)n[e]=[0,t];for(let e of o)n[e]=[0,-t]}_setZoomDelta(t){let n=this._zoomKeys={},{zoomIn:r,zoomOut:i}=e.keys;for(let e of r)n[e]=t;for(let e of i)n[e]=-t}_addHooks(){y(document,`keydown`,this._onKeyDown,this)}_removeHooks(){x(document,`keydown`,this._onKeyDown,this)}_onKeyDown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;if(e.key===`?`){this._toggleHelp(),E(e);return}let t=e.key,n=this._map,r;if(t in this._panKeys)(!n._panAnim||!n._panAnim._inProgress)&&(r=this._panKeys[t],e.shiftKey&&(r=g.from(r).multiplyBy(3)),n.options.maxBounds&&(r=n._limitOffset(g.from(r),n.options.maxBounds)),n._setUserEvent(e),n.panBy(r));else if(t in this._zoomKeys)n._zoomInputBlocked()||(n._setUserEvent(e),n.setZoom(n.getZoom()+(e.shiftKey?3:1)*this._zoomKeys[t]));else if(t===`Escape`&&n._popup&&n._popup.options.closeOnEscapeKey)n.closePopup();else return;E(e)}static register(t){t.mergeOptions({keyboard:!0,keyboardPanDelta:80,ariaKeyShortcuts:!1}),t.addInitHook(`addHandler`,`keyboard`,e)}},Wt=class e extends Y{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){this._map._container.classList.add(`maplair-touch-zoom`),y(this._map._container,`pointerdown`,this._onPointerStart,this)}removeHooks(){this._map._container.classList.remove(`maplair-touch-zoom`),x(this._map._container,`pointerdown`,this._onPointerStart,this),x(this._map._container,`pointermove`,this._onPointerMove,this),x(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this)}_onPointerStart(e){let t=this._map,n=v();if(n.length!==2||t._animatingZoom||this._zooming)return;let r=t.pointerEventToContainerPoint(n[0]),i=t.pointerEventToContainerPoint(n[1]),{x:a,y:o}=De(t._container);this._containerScale=new g(a,o),this._containerOrigin=new g(n[0].clientX,n[0].clientY)._subtract(r.scaleBy(this._containerScale)),this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.pinchZoom!==`center`&&(this._pinchStartLatLng=t.containerPointToLatLng(r.add(i)._divideBy(2))),this._startDist=r.distanceTo(i),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),y(this._map._container,`pointermove`,this._onPointerMove,this),y(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this),e.preventDefault()}_onPointerMove(e){let t=v();if(t.length!==2||!this._zooming)return;let n=this._map,r=this._toContainerPoint(t[0]),i=this._toContainerPoint(t[1]),a=r.distanceTo(i)/this._startDist;if(this._zoom=n.getScaleZoom(a,this._startZoom),!n.options.bounceAtZoomLimits&&(this._zoom<n.getMinZoom()&&a<1||this._zoom>n.getMaxZoom()&&a>1)&&(this._zoom=n._limitZoom(this._zoom)),n.options.pinchZoom===`center`){if(this._center=this._startLatLng,a===1)return}else{let e=r._add(i)._divideBy(2)._subtract(this._centerPoint);if(a===1&&e.x===0&&e.y===0)return;this._center=n.unproject(n.project(this._pinchStartLatLng,this._zoom).subtract(e),this._zoom)}this._moved||=(n._setUserEvent(e),n._moveStart(!0,!1),!0),cancelAnimationFrame(this._animRequest);let o=n._move.bind(n,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=requestAnimationFrame(o.bind(this)),e.preventDefault()}_toContainerPoint(e){return new g(e.clientX,e.clientY)._subtract(this._containerOrigin).unscaleBy(this._containerScale)}_onPointerEnd(){x(this._map._container,`pointermove`,this._onPointerMove,this),x(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this),!this._moved||!this._zooming?this._zooming=!1:(this._zooming=!1,cancelAnimationFrame(this._animRequest),this._map._zoomAnimated?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))}static register(t){t.mergeOptions({pinchZoom:!0,bounceAtZoomLimits:!0}),t.addInitHook(`addHandler`,`pinchZoom`,e),t.addInitHook(function(){this.touchZoom=this.pinchZoom,this.options.touchZoom!==void 0&&(console.warn(`Map: touchZoom option is deprecated and will be removed in future versions. Use pinchZoom instead.`),this.options.pinchZoom=this.options.touchZoom,delete this.options.touchZoom),this.options.pinchZoom?this.pinchZoom.enable():this.pinchZoom.disable()})}},Gt=class e extends Y{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){y(this._map._container,`wheel`,this._onWheelScroll,this),y(this._map._container,`gesturestart`,this._onGestureStart,this),y(this._map._container,`gesturechange`,this._onGestureChange,this),y(this._map._container,`gestureend`,this._onGestureEnd,this),this._delta=0}removeHooks(){x(this._map._container,`wheel`,this._onWheelScroll,this),x(this._map._container,`gesturestart`,this._onGestureStart,this),x(this._map._container,`gesturechange`,this._onGestureChange,this),x(this._map._container,`gestureend`,this._onGestureEnd,this),clearTimeout(this._timer),this._endPinch(),this._endPan()}_onWheelScroll(e){if(e.ctrlKey){E(e);let t=-e.deltaY*(e.deltaMode===1?20:e.deltaMode===2?60:1);this._pinchTo(e,(this._pinch?.zoom??this._map.getZoom())+t/100),clearTimeout(this._pinchTimer),this._pinchTimer=setTimeout(this._endPinch.bind(this),150)}else this._map.options.scrollWheelZoom===`trackpad`?this._panBy(e):this._onWheelZoom(e)}_onGestureStart(e){v().length||(E(e),this._gestureStartZoom=this._map.getZoom())}_onGestureChange(e){this._gestureStartZoom!==void 0&&(E(e),this._pinchTo(e,this._gestureStartZoom+Math.log2(e.scale)))}_onGestureEnd(e){this._gestureStartZoom!==void 0&&(E(e),this._gestureStartZoom=void 0,this._endPinch())}_pinchTo(e,t,n){let r=this._map;if(!this._pinch){if(r._animatingZoom)return;r._stop();let t=r.pointerEventToContainerPoint(e),n=t.subtract(r.getSize()._divideBy(2));this._pinch={aroundLatLng:r.options.scrollWheelZoom===`center`?r.getCenter():r.containerPointToLatLng(t),offset:r.options.scrollWheelZoom===`center`?new g(0,0):n},r._setUserEvent(e),r._moveStart(!0,!1)}(!r.options.bounceAtZoomLimits||n)&&(t=Math.max(r.getMinZoom(),Math.min(r.getMaxZoom(),t))),this._pinch.zoom=t,this._pinch.shown??=r.getZoom();let i=()=>{let e=this._pinch,t=e.zoom-e.shown;e.shown=n&&Math.abs(t)>.01?e.shown+t*.3:e.zoom,r._move(this._getPinchCenter(e.shown),e.shown,{pinch:!0,round:!1}),e.shown!==e.zoom&&(this._pinchFrame=requestAnimationFrame(i))};cancelAnimationFrame(this._pinchFrame),this._pinchFrame=requestAnimationFrame(i)}_getPinchCenter(e){let{aroundLatLng:t,offset:n}=this._pinch,r=this._map;return r.unproject(r.project(t,e).subtract(n),e)}_endPinch(){if(clearTimeout(this._pinchTimer),!this._pinch)return;cancelAnimationFrame(this._pinchFrame);let e=this._map,t=e._limitZoom(this._pinch.zoom),n=this._getPinchCenter(t);this._pinch=null,e.options.zoomAnimation&&Math.abs(t-e.getZoom())>1e-9?e._animateZoom(n,t,!0,e.options.zoomSnap):e._move(n,t)._moveEnd(!0)}_panBy(e){E(e);let t=this._map;if(t._animatingZoom)return;let n=e.deltaMode===1?20:e.deltaMode===2?60:1,r=new g(e.deltaX*n,e.deltaY*n);e.shiftKey&&!e.deltaX&&(r=new g(r.y,0)),t.options.maxBounds&&(r=t._limitOffset(r,t.options.maxBounds)),this._panning||(t._stop(),this._panning=!0,t._setUserEvent(e),t.fire(`movestart`)),t._rawPanBy(r.round()),t.fire(`move`),clearTimeout(this._panTimer),this._panTimer=setTimeout(this._endPan.bind(this),150)}_endPan(){clearTimeout(this._panTimer),this._panning&&(this._panning=!1,this._map.fire(`moveend`))}_onWheelZoom(e){if(this._map.options.continuousZoom){E(e);let t=ve(e)/this._map.options.wheelPxPerZoomLevel;this._pinchTo(e,(this._pinch?.zoom??this._map.getZoom())+t,!0),clearTimeout(this._pinchTimer),this._pinchTimer=setTimeout(this._endPinch.bind(this),150);return}let t=ve(e),n=this._map.options.wheelDebounceTime;this._delta+=t,this._lastEvent=e,this._startTime||=Date.now();let r=Math.max(n-(Date.now()-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(this._performZoom.bind(this),r),E(e)}_performZoom(){let e=this._map,t=e.getZoom(),n=this._map.options.zoomSnap??0;e._stop();let r=this._delta/(this._map.options.wheelPxPerZoomLevel*4),i=4*Math.log(2/(1+Math.exp(-Math.abs(r))))/Math.LN2,a=n?Math.ceil(i/n)*n:i,o=e._prefersReducedMotion()?Math.min(a,1):a,s=e._limitZoom(t+(this._delta>0?o:-o))-t;this._delta=0,this._startTime=null,s&&!e._zoomInputBlocked()&&(e._setUserEvent(this._lastEvent),e.options.scrollWheelZoom===`center`?e.setZoom(t+s):e.setZoomAround(e.pointerEventToContainerPoint(this._lastEvent),t+s))}static register(t){t.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60}),t.addInitHook(`addHandler`,`scrollWheelZoom`,e)}},Kt=class e extends Y{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){y(this._map._container,`pointerdown`,this._onDown,this)}removeHooks(){x(this._map._container,`pointerdown`,this._onDown,this),this._cancel(),this._cancelClickPrevent(),this._stopPreventingNative()}_onDown(e){if(clearTimeout(this._holdTimeout),v().length!==1||e.pointerType===`mouse`)return;let t=this._map._container;this._startPos=this._newPos=new g(e.clientX,e.clientY),this._holdTimeout=setTimeout((()=>{this._cancel(),this._isTapValid()&&(y(t,`pointerup`,T),y(t,`pointerup pointercancel`,this._cancelClickPrevent,this),this._simulateEvent(`contextmenu`,e),t.addEventListener(`contextmenu`,E,!0),t.addEventListener(`pointerdown`,this._stopPreventingNative,!0))}),600),y(t,`pointerup pointercancel contextmenu`,this._cancel,this),y(t,`pointermove`,this._onMove,this)}_cancelClickPrevent(){let e=this._map._container;x(e,`pointerup`,T),x(e,`pointerup pointercancel`,this._cancelClickPrevent,this)}_stopPreventingNative=()=>{let e=this._map._container;e.removeEventListener(`contextmenu`,E,!0),e.removeEventListener(`pointerdown`,this._stopPreventingNative,!0)};_cancel(){clearTimeout(this._holdTimeout);let e=this._map._container;x(e,`pointerup pointercancel contextmenu`,this._cancel,this),x(e,`pointermove`,this._onMove,this)}_onMove(e){this._newPos=new g(e.clientX,e.clientY)}_isTapValid(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance}_simulateEvent(e,t){let n=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});n._simulated=!0,t.target.dispatchEvent(n)}static register(t){t.mergeOptions({tapHold:!0,tapTolerance:15}),t.addInitHook(`addHandler`,`tapHold`,e)}},qt=class e extends Y{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){y(this._map._container,`pointerdown`,this._onDown,this),y(this._map._container,`pointerup`,this._onTapUp,this),y(this._map._container,`pointercancel`,this._reset,this)}removeHooks(){x(this._map._container,`pointerdown`,this._onDown,this),x(this._map._container,`pointerup`,this._onTapUp,this),x(this._map._container,`pointercancel`,this._reset,this),this._onUp(),this._reset()}_onDown(e){if(e.pointerType===`mouse`||v().length!==1){this._onUp(),this._reset();return}let t=this._map,n=new g(e.clientX,e.clientY),r=Date.now();if(!this._tapPos||r-this._tapTime>500||n.distanceTo(this._tapPos)>30||t._animatingZoom){this._tapPos=null,this._downPos=n,this._downTime=r;return}this._tapPos=this._downPos=null,this._startPos=n,this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0;let i=t.pointerEventToContainerPoint(e);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.tapDragZoom!==`center`&&(this._aroundLatLng=t.containerPointToLatLng(i),this._aroundOffset=i.subtract(this._centerPoint)),this._cancelDragging(),y(t._container,`pointermove`,this._onMove,this),y(t._container,`pointerup pointercancel`,this._onUp,this)}_onTapUp(e){if(!this._downPos)return;let t=new g(e.clientX,e.clientY),n=Date.now();n-this._downTime<=500&&t.distanceTo(this._downPos)<=this._map.options.tapTolerance&&(this._tapPos=this._downPos,this._tapTime=n),this._downPos=null}_reset(){this._tapPos=this._downPos=null}_cancelDragging(){let e=this._map.dragging?._draggable;e&&X._dragging===e&&e.finishDrag(!0)}_onMove(e){if(!this._zooming||v().length!==1)return;let t=this._map,n=e.clientY-this._startPos.y;!this._moved&&Math.abs(n)<=t.options.tapTolerance||(this._cancelDragging(),this._zoom=this._startZoom+n/128,t.options.bounceAtZoomLimits||(this._zoom=t._limitZoom(this._zoom)),this._center=t.options.tapDragZoom===`center`?this._startLatLng:t.unproject(t.project(this._aroundLatLng,this._zoom).subtract(this._aroundOffset),this._zoom),this._moved||=(t._stop(),t._setUserEvent(e),t._moveStart(!0,!1),!0),cancelAnimationFrame(this._animRequest),this._animRequest=requestAnimationFrame(()=>t._move(this._center,this._zoom,{pinch:!0,round:!1})),e.preventDefault())}_onUp(){if(x(this._map._container,`pointermove`,this._onMove,this),x(this._map._container,`pointerup pointercancel`,this._onUp,this),!this._zooming||(this._zooming=!1,!this._moved))return;this._moved=!1,cancelAnimationFrame(this._animRequest);let e=this._map,t=e._limitZoom(this._zoom);e.options.zoomAnimation?e._animateZoom(this._center,t,!0,e.options.zoomSnap):e._move(this._center,t)._moveEnd(!0)}static register(t){t.mergeOptions({tapDragZoom:!0}),t.addInitHook(`addHandler`,`tapDragZoom`,e)}},Z=class e extends Pe{static defaultOptions={crs:St,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],ariaLabel:void 0,maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,continuousZoom:!1,fadeAnimation:!0,markerZoomAnimation:!0,markerCulling:!1,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0};constructor(t,n){super(),n=f(this,n),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(t),this._initLayout(),this._initEvents(),this._watchPixelRatio(),this.on({movestart:this._onBusy,zoomstart:this._onBusy,move:this._onMove,moveend:this._onViewChanged,layerremove:this._scheduleIdleCheck},this),n.maxBounds&&this.setMaxBounds(n.maxBounds),n.zoom!==void 0&&(this._zoom=this._limitZoom(n.zoom)),n.center&&n.zoom!==void 0&&this.setView(B.from(n.center),n.zoom,{reset:!0}),this.callInitHooks(e),this._zoomAnimated=this.options.zoomAnimation,this._zoomAnimated&&this._createAnimProxy(),this._addLayers(this.options.layers)}setView(e,t,n){return t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(new B(e),t,this.options.maxBounds),n??={},this._stop(),this._loaded&&!n.reset&&n!==!0&&(n.animate!==void 0&&(n.zoom={animate:n.animate,...n.zoom},n.pan={animate:n.animate,duration:n.duration,...n.pan}),this._zoom===t?this._tryAnimatedPan(e,n.pan):this._tryAnimatedZoom&&this._tryAnimatedZoom(e,t,n.zoom))?(clearTimeout(this._sizeTimer),this):(this._resetView(e,t,n.pan?.noMoveStart),this)}setZoom(e,t){return this._loaded?this.setView(this.getCenter(),e,{zoom:t}):(this._zoom=e,this)}zoomIn(e,t){return e??=this.options.zoomDelta,this.setZoom(this._zoom+e,t)}zoomOut(e,t){return e??=this.options.zoomDelta,this.setZoom(this._zoom-e,t)}setZoomAround(e,t,n){let r=this.getZoomScale(t),i=this.getSize().divideBy(2),a=(e instanceof g?e:this.latLngToContainerPoint(e)).subtract(i).multiplyBy(1-1/r),o=this.containerPointToLatLng(i.add(a));return this.setView(o,t,{zoom:n})}_getBoundsCenterZoom(e,t){t??={},e=e.getBounds?e.getBounds():R.from(e);let n=g.from(t.paddingTopLeft||t.padding||[0,0]),r=g.from(t.paddingBottomRight||t.padding||[0,0]),i=this.getBoundsZoom(e,!1,n.add(r));if(i=typeof t.maxZoom==`number`?Math.min(t.maxZoom,i):i,i===1/0)return{center:e.getCenter(),zoom:i};let a=r.subtract(n).divideBy(2),o=this.project(e.getSouthWest(),i),s=this.project(e.getNorthEast(),i);return{center:this.unproject(o.add(s).divideBy(2).add(a),i),zoom:i}}fitBounds(e,t){if(e=R.from(e),!e.isValid())throw Error(`Bounds are not valid.`);let n=this._getBoundsCenterZoom(e,t);return this.setView(n.center,n.zoom,t)}fitWorld(e){return this.fitBounds([[-90,-180],[90,180]],e)}panTo(e,t){return this.setView(e,this._zoom,{pan:t})}panBy(e,t){if(e=g.from(e).round(),t??={},!e.x&&!e.y)return this.fire(`moveend`);let n=this.getSize();if(t.animate!==!0&&!n.contains(e)){let t=this.unproject(this.project(this.getCenter()).add(e));return this._resetView(this.options.worldCopyJump?this.wrapLatLng(t):t,this.getZoom()),this}this._panAnim||(this._panAnim=new wt,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),t.noMoveStart||this.fire(`movestart`);let r=this._prefersReducedMotion()&&!n.divideBy(2).contains(e);if(t.animate===!0||t.animate!==!1&&!r){this._mapPane.classList.add(`maplair-pan-anim`);let n=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,n,t.duration||.25,t.easeLinearity)}else this._rawPanBy(e),this._wrapWorldCopy(),this.fire(`move`).fire(`moveend`);return this}flyTo(e,t,n){if(n??={},n.animate===!1)return this.setView(e,t,{...n,zoom:{...n.zoom,animate:!1}});if(n.animate!==!0&&this._prefersReducedMotion())return this.setView(e,t,n);this._stop(),t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(new B(e),t,this.options.maxBounds);let r=this.project(this.getCenter()),i=this.project(e),a=this.getSize(),o=this._zoom,s=Math.max(a.x,a.y),c=s*this.getZoomScale(o,t),l=i.distanceTo(r)||1,u=1.42,d=u*u;function f(e){let t=e?-1:1,n=e?c:s,r=c*c-s*s+t*d*d*l*l,i=2*n*d*l;return-Math.asinh(r/i)}let p=f(0);function ee(e){return s*(Math.cosh(p)/Math.cosh(p+u*e))}function te(e){return s*(Math.cosh(p)*Math.tanh(p+u*e)-Math.sinh(p))/d}function m(e){return 1-(1-e)**1.5}let h=Date.now(),g=(f(1)-p)/u,ne=n.duration?1e3*n.duration:1e3*g*.8,re=()=>{let n=(Date.now()-h)/ne,a=m(n)*g;if(n<=1)this._flyToFrame=requestAnimationFrame(re),this._move(this.unproject(r.add(i.subtract(r).multiplyBy(te(a)/l)),o),this.getScaleZoom(s/ee(a),o),{flyTo:!0});else{let n=this._zoom!==t;this._move(e,t),n||this.fire(`zoom`),this._moveEnd(!0)}};return this._moveStart(!0,n.noMoveStart),re(this),this}flyToBounds(e,t){let n=this._getBoundsCenterZoom(e,t);return this.flyTo(n.center,n.zoom,t)}setCrs(e){let t=this.options.crs;if(e===t)return this;if(!this._loaded)return this.options.crs=e,this.fire(`crschange`,{oldCrs:t,crs:e}),this;this._stop();let n=this.getCenter(),r=this._getResolution(n);this.options.crs=e;let i=this._limitZoom(e.zoom(e.scale(this._zoom)*this._getResolution(n)/r));return this.fire(`crschange`,{oldCrs:t,crs:e}),this._resetView(n,i),this}_getResolution(e){let t=this.options.crs,n=t.latLngToPoint(e,this._zoom);return t.distance(e,t.pointToLatLng(n.add([1,0]),this._zoom))}setMaxBounds(e){return e=new R(e),this.listens(`moveend`,this._panInsideMaxBounds)&&this.off(`moveend`,this._panInsideMaxBounds),e.isValid()?(this.options.maxBounds=e,this._loaded&&this._panInsideMaxBounds(),this.on(`moveend`,this._panInsideMaxBounds)):(this.options.maxBounds=null,this)}setMinZoom(e){let t=this.options.minZoom;return this.options.minZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()<this.options.minZoom)?this.setZoom(e):this}setMaxZoom(e){let t=this.options.maxZoom;return this.options.maxZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()>this.options.maxZoom)?this.setZoom(e):this}panInsideBounds(e,t){this._enforcingBounds=!0;let n=this.getCenter(),r=this._limitCenter(n,this._zoom,R.from(e));return n.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this}panInside(e,t){t??={};let n=g.from(t.paddingTopLeft||t.padding||[0,0]),r=g.from(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),a=this.project(e),o=this.getPixelBounds(),s=new F([o.min.add(n),o.max.subtract(r)]),c=s.getSize();if(!s.contains(a)){this._enforcingBounds=!0;let e=a.subtract(s.getCenter()),n=s.extend(a).getSize().subtract(c);i.x+=e.x<0?-n.x:n.x,i.y+=e.y<0?-n.y:n.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this}invalidateSize(e){if(!this._loaded)return this;e={animate:!1,pan:!0,...e===!0?{animate:!0}:e};let t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;let n=this.getSize(),r=t.divideBy(2).round(),i=n.divideBy(2).round(),a=r.subtract(i);return!a.x&&!a.y?this:(e.animate&&e.pan?this.panBy(a):(e.pan&&this._rawPanBy(a),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(this.fire.bind(this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:n}))}stop(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire(`viewreset`),this._stop()}locate(e){if(e=this._locateOptions={timeout:1e4,watch:!1,...e},!(`geolocation`in navigator))return this._handleGeolocationError({code:0,message:`Geolocation not supported.`}),this;let t=this._handleGeolocationResponse.bind(this),n=this._handleGeolocationError.bind(this);return e.watch?(this._locationWatchId!==void 0&&navigator.geolocation.clearWatch(this._locationWatchId),this._locationWatchId=navigator.geolocation.watchPosition(t,n,e)):navigator.geolocation.getCurrentPosition(t,n,e),this}stopLocate(){return navigator.geolocation?.clearWatch?.(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this}_handleGeolocationError(e){if(!this._container._maplair_id)return;let t=e.code,n=e.message||(t===1?`permission denied`:t===2?`position unavailable`:`timeout`);this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire(`locationerror`,{code:t,message:`Geolocation error: ${n}.`})}_handleGeolocationResponse(e){if(!this._container._maplair_id)return;let t=e.coords.latitude,n=e.coords.longitude,r=new B(t,n),i=r.toBounds(e.coords.accuracy*2),a=this._locateOptions;if(a.setView){let e=this.getBoundsZoom(i);this.setView(r,a.maxZoom?Math.min(e,a.maxZoom):e)}let o={latlng:r,bounds:i,timestamp:e.timestamp};for(let t in e.coords)typeof e.coords[t]==`number`&&(o[t]=e.coords[t]);this.fire(`locationfound`,o)}addHandler(e,t){if(!t)return this;let n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this}remove(){if(this._initEvents(!0),this.options.maxBounds&&this.off(`moveend`,this._panInsideMaxBounds),this._containerId!==this._container._maplair_id)throw Error(`Map container is being reused by another instance`);delete this._container._maplair_id,delete this._containerId,this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),se(this._container),this._mapPane.remove();for(let e of this._ariaAttributes)this._container.removeAttribute(e);this._clearControlPos&&this._clearControlPos(),cancelAnimationFrame(this._resizeRequest),cancelAnimationFrame(this._idleRequest),this._watchPixelRatio(!0);for(let e of this._handlers)e.disable();clearTimeout(this._transitionEndTimer),clearTimeout(this._sizeTimer),this._loaded&&this.fire(`unload`);for(let e of Object.values(this._layers))e.remove();for(let e of Object.values(this._panes))e.remove();return this._layers={},this._panes={},delete this._mapPane,delete this._renderer,this}createPane(e,t){let n=D(`div`,`maplair-pane${e?` maplair-${e.replace(`Pane`,``)}-pane`:``}`,t||this._mapPane);return e&&(this._panes[e]=n),n}getCenter(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?new B(this._lastCenter):this.layerPointToLatLng(this._getCenterLayerPoint())}getZoom(){return this._zoom}getBounds(){let e=this.getPixelBounds();return new R(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))}getMinZoom(){return this.options.minZoom??this._layersMinZoom??0}getMaxZoom(){return this.options.maxZoom??this._layersMaxZoom??1/0}getBoundsZoom(e,t,n){e=R.from(e),n=g.from(n??[0,0]);let r=this.getZoom()??0,i=this.getMinZoom(),a=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),c=this.getSize().subtract(n),l=new F(this.project(s,r),this.project(o,r)).getSize(),u=this.options.zoomSnap,d=c.x/l.x,f=c.y/l.y,p=t?Math.max(d,f):Math.min(d,f);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(i,Math.min(a,r))}getSize(){return(!this._size||this._sizeChanged)&&(this._size=new g(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),new g(this._size)}getPixelBounds(e,t){let n=this._getTopLeftPoint(e,t);return new F(n,n.add(this.getSize()))}getPixelOrigin(){return this._checkIfLoaded(),this._pixelOrigin}getPixelWorldBounds(e){return this.options.crs.getProjectedBounds(e??this.getZoom())}getPane(e){return typeof e==`string`?this._panes[e]:e}getPanes(){return this._panes}getContainer(){return this._container}getZoomScale(e,t){let n=this.options.crs;return t??=this._zoom,n.scale(e)/n.scale(t)}getScaleZoom(e,t){let n=this.options.crs;t??=this._zoom;let r=n.zoom(e*n.scale(t));return isNaN(r)?1/0:r}project(e,t){return t??=this._zoom,this.options.crs.latLngToPoint(B.from(e),t)}unproject(e,t){return t??=this._zoom,this.options.crs.pointToLatLng(g.from(e),t)}layerPointToLatLng(e){let t=g.from(e).add(this.getPixelOrigin());return this.unproject(t)}latLngToLayerPoint(e){return this.project(B.from(e))._round()._subtract(this.getPixelOrigin())}wrapLatLng(e){return this.options.crs.wrapLatLng(B.from(e))}wrapLatLngBounds(e){return this.options.crs.wrapLatLngBounds(new R(e))}distance(e,t){return this.options.crs.distance(B.from(e),B.from(t))}containerPointToLayerPoint(e){return g.from(e).subtract(this._getMapPanePos())}layerPointToContainerPoint(e){return g.from(e).add(this._getMapPanePos())}containerPointToLatLng(e){let t=this.containerPointToLayerPoint(g.from(e));return this.layerPointToLatLng(t)}latLngToContainerPoint(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(B.from(e)))}pointerEventToContainerPoint(e){return ge(e,this._container)}pointerEventToLayerPoint(e){return this.containerPointToLayerPoint(this.pointerEventToContainerPoint(e))}pointerEventToLatLng(e){return this.layerPointToLatLng(this.pointerEventToLayerPoint(e))}_initContainer(e){let t=this._container=xe(e);if(!t)throw Error(`Map container not found.`);if(t._maplair_id)throw Error(`Map container is already initialized.`);oe(t),y(t,`scroll`,this._onScroll,this),this._containerId=a(t)}_initLayout(){let e=this._container;this._fadeAnimated=this.options.fadeAnimation;let t=[`maplair-container`,`maplair-touch`];window.devicePixelRatio>1&&t.push(`maplair-retina`),this._fadeAnimated&&t.push(`maplair-fade-anim`),e.classList.add(...t),this._ariaAttributes=[],e.hasAttribute(`role`)||(e.setAttribute(`role`,`region`),this._ariaAttributes.push(`role`)),!e.hasAttribute(`aria-label`)&&!e.hasAttribute(`aria-labelledby`)&&(e.setAttribute(`aria-label`,this.options.ariaLabel??N.translate(`Map`)),this._ariaAttributes.push(`aria-label`));let{position:n}=getComputedStyle(e);n!==`absolute`&&n!==`relative`&&n!==`fixed`&&n!==`sticky`&&(e.style.position=`relative`),this._initPanes(),this._initControlPos&&this._initControlPos()}_initPanes(){let e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane(`mapPane`,this._container),A(this._mapPane,new g(0,0)),this.createPane(`tilePane`),this.createPane(`overlayPane`),this.createPane(`shadowPane`),this.createPane(`markerPane`),this.createPane(`tooltipPane`),this.createPane(`popupPane`),this.options.markerZoomAnimation||(e.markerPane.classList.add(`maplair-zoom-hide`),e.shadowPane.classList.add(`maplair-zoom-hide`))}_resetView(e,t,n){let r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire(`viewprereset`,{center:e,zoom:t}),A(this._mapPane,new g(0,0));let i=this._zoom!==t;i&&!r&&(this._instantZoomEnd=Date.now()+250),this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire(`viewreset`),r&&this.fire(`load`)}fire(t,n,r){return this._userEvent&&e._viewEvents.has(t)&&(n={originalEvent:this._userEvent,...n},t===`moveend`?this._userEvent=null:this._userMoving=!0),super.fire(t,n,r)}static _viewEvents=/* @__PURE__ */ new Set([`movestart`,`move`,`moveend`,`zoomstart`,`zoom`,`zoomend`,`zoomanim`]);_watchPixelRatio(e){this._pixelRatioQuery?.removeEventListener(`change`,this._onPixelRatioChange),!e&&typeof window<`u`&&window.matchMedia&&(this._onPixelRatioChange??=()=>{this._watchPixelRatio(),this.fire(`pixelratiochange`)},this._pixelRatioQuery=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._pixelRatioQuery.addEventListener(`change`,this._onPixelRatioChange))}_onBusy(){this._viewChanging=!0,this._idle=!1}_onMove(){this._cullingBounds=null}_onViewChanged(){this._viewChanging=!1,this._scheduleIdleCheck()}_onLayerLoading(){this._idle=!1}_scheduleIdleCheck(){cancelAnimationFrame(this._idleRequest),this._idleRequest=requestAnimationFrame(()=>this._checkIdle())}_checkIdle(){if(!(this._idle||!this._loaded||this._viewChanging||this._animatingZoom)){for(let e of Object.values(this._layers))if(e.isLoading?.())return;this._idle=!0,this.fire(`idle`)}}_setUserEvent(e){this._userEvent=e,this._userMoving=!1,queueMicrotask(()=>{this._userEvent===e&&!this._userMoving&&(this._userEvent=null)})}_moveStart(e,t){return e&&this.fire(`zoomstart`),t||this.fire(`movestart`),this}_move(e,t,n,r){t===void 0&&(t=this._zoom);let i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),r?n?.pinch&&this.fire(`zoom`,n):((i||n?.pinch)&&this.fire(`zoom`,n),this.fire(`move`,n)),this}_moveEnd(e){return e&&this.fire(`zoomend`),this.fire(`moveend`)}_stop(){return cancelAnimationFrame(this._flyToFrame),cancelAnimationFrame(this._zoomAnimFrame),this._panAnim?.stop(),this}_rawPanBy(e){A(this._mapPane,this._getMapPanePos().subtract(e))}_wrapWorldCopy(e=this._getMapPanePos()){if(!this._loaded||!this.options.worldCopyJump||this.options.crs.infinite)return e;let t=this.getPixelWorldBounds().getSize().x,n=e.x-t*Math.round((e.x+this.latLngToLayerPoint([0,0]).x-this.getSize().x/2)/t),r=Math.round((n-this._getMapPanePos().x)/t);return e=new g(n,e.y),r&&(A(this._mapPane,e),this.fire(`worldcopyjump`,{worlds:r})),e}_getZoomSpan(){return this.getMaxZoom()-this.getMinZoom()}_panInsideMaxBounds(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)}_checkIfLoaded(){if(!this._loaded)throw Error(`Set map center and zoom first.`)}_initEvents(e){this._targets={},this._targets[a(this._container)]=this,(e?x:y)(this._container,`click dblclick pointerdown pointerup pointerover pointerout pointermove contextmenu keydown keyup`,this._handleDOMEvent,this),this.options.trackResize&&(e?this._resizeObserver.disconnect():(this._resizeObserver||=new ResizeObserver(this._onResize.bind(this)),this._resizeObserver.observe(this._container))),this.options.transform3DLimit&&(e?this.off:this.on).call(this,`moveend`,this._onMoveEnd)}_onResize(){cancelAnimationFrame(this._resizeRequest),this._resizeRequest=requestAnimationFrame(()=>{(this._container.clientWidth||this._container.clientHeight)&&this.invalidateSize({debounceMoveend:!0})})}_onScroll(){this._container.scrollTop=0,this._container.scrollLeft=0}_onMoveEnd(){let e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())}_findEventTargets(e,t){let n=[],r,i=e.target,o=!1,s=t===`pointerout`||t===`pointerover`;for(;i;){if(r=this._targets[a(i)],r&&(t===`click`||t===`preclick`)&&this._draggableMoved(r)){o=!0;break}if(r&&r.listens(t,!0)&&(s&&!ye(i,e)||(n.push(r),s))||i===this._container)break;i=i.parentNode}return!n.length&&!o&&!s&&this.listens(t,!0)&&(n=[this]),n}_isClickDisabled(e){for(;e&&e!==this._container;){if(e._maplair_disable_click||!e.parentNode)return!0;e=e.parentNode}}_handleDOMEvent(e){let t=e.target;!this._loaded||t._maplair_disable_events||e.type===`click`&&this._isClickDisabled(t)||this._fireDOMEvent(e,e.type)}static _pointerEvents=[`click`,`dblclick`,`pointerover`,`pointerout`,`contextmenu`];_fireDOMEvent(t,n,r){n===`click`&&this._fireDOMEvent(t,`preclick`,r);let i=this._findEventTargets(t,n);if(r&&(i=[...r.filter(e=>e.listens(n,!0)),...i]),!i.length)return;n===`contextmenu`&&t.preventDefault();let a=i[0],o={originalEvent:t};if(t.type!==`keydown`&&t.type!==`keyup`){let e=a.getLatLng&&(!a._pxRadius||a._pxRadius<=10);o.containerPoint=e?this.latLngToContainerPoint(a.getLatLng()):this.pointerEventToContainerPoint(t),o.layerPoint=this.containerPointToLayerPoint(o.containerPoint),o.latlng=e?a.getLatLng():this.layerPointToLatLng(o.layerPoint)}for(let t of i){t.fire(n,o,!0);let r=t.options.bubblingMouseEvents??t.options.bubblingPointerEvents;if(o.originalEvent._stopped||r===!1&&e._pointerEvents.includes(n))return}}_draggableMoved(e){return e=e.dragging?.enabled()?e:this,e.dragging?.moved()||this.boxZoom?.moved()}whenReady(e,t){return this._loaded?e.call(t||this,{target:this}):this.on(`load`,e,t),this}_getMapPanePos(){return j(this._mapPane)}_moved(){let e=this._getMapPanePos();return e&&!e.equals([0,0])}_getTopLeftPoint(e,t){return(e&&t!==void 0?this._getNewPixelOrigin(e,t):this.getPixelOrigin()).subtract(this._getMapPanePos())}_getNewPixelOrigin(e,t){let n=this.getSize()._divideBy(2);return this.project(e,t)._subtract(n)._add(this._getMapPanePos())._round()}_latLngToNewLayerPoint(e,t,n){let r=this._getNewPixelOrigin(n,t);return this.project(e,t)._subtract(r)}_getCenterLayerPoint(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))}_getCenterOffset(e){return this.latLngToLayerPoint(e).subtract(this._getCenterLayerPoint())}_limitCenter(e,t,n){if(!n)return e;let r=this.project(e,t),i=this.getSize().divideBy(2),a=new F(r.subtract(i),r.add(i)),o=this._getBoundsOffset(a,n,t);return Math.abs(o.x)<=1&&Math.abs(o.y)<=1?e:this.unproject(r.add(o),t)}_prefersReducedMotion(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}_limitOffset(e,t){if(!t)return e;let n=this.getPixelBounds(),r=new F(n.min.add(e),n.max.add(e));return e.add(this._getBoundsOffset(r,t))}_getBoundsOffset(e,t,n){let r=new F(this.project(t.getNorthEast(),n),this.project(t.getSouthWest(),n)),i=r.min.subtract(e.min),a=r.max.subtract(e.max);return new g(this._rebound(i.x,-a.x),this._rebound(i.y,-a.y))}_rebound(e,t){return e+t>0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))}_limitZoom(e){let t=this.getMinZoom(),n=this.getMaxZoom(),r=this.options.zoomSnap;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(n,e))}_onPanTransitionStep(){this.fire(`move`)}_onPanTransitionEnd(){this._mapPane.classList.remove(`maplair-pan-anim`),this._wrapWorldCopy(),this.fire(`moveend`)}_tryAnimatedPan(e,t){let n=this._getCenterOffset(e)._trunc();return t?.animate!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)}_createAnimProxy(){this._proxy=D(`div`,`maplair-proxy maplair-zoom-animated`),this._panes.mapPane.appendChild(this._proxy),this.on(`zoomanim`,this._animateProxyZoom,this),this.on(`load moveend`,this._animMoveEnd,this),y(this._proxy,`transitionend`,this._catchTransitionEnd,this)}_animateProxyZoom(e){let t=this._proxy.style.transform;k(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),t===this._proxy.style.transform&&this._animatingZoom&&this._onZoomTransitionEnd()}_animMoveEnd(){let e=this.getCenter(),t=this.getZoom();k(this._proxy,this.project(e,t),this.getZoomScale(t,1))}_catchTransitionEnd(e){this._animatingZoom&&e.propertyName.includes(`transform`)&&this._onZoomTransitionEnd()}_nothingToAnimate(){return!this._container.getElementsByClassName(`maplair-zoom-animated`).length}_continuousZoom(e,t,n,r){let i=this._zoom,a=n.multiplyBy(-1),o=this.containerPointToLatLng(this.getSize()._divideBy(2).add(n)),s=performance.now();this._moveStart(!0,r.noMoveStart??!1);let c=()=>{let n=Math.min(1,(performance.now()-s)/250);if(n<1){let e=i+(t-i)*(1-(1-n)**2);this._move(this.unproject(this.project(o,e).add(a),e),e,{continuous:!0}),this._flyToFrame=requestAnimationFrame(c)}else this._move(e,t)._moveEnd(!0)};this._flyToFrame=requestAnimationFrame(c)}_zoomInputBlocked(){return this._animatingZoom||Date.now()<this._instantZoomEnd}_tryAnimatedZoom(e,t,n){if(this._animatingZoom)return!0;n??={};let r=this.options.zoomAnimationThreshold,i=this._prefersReducedMotion()&&n.animate!==!0?Math.min(r,1):r;if(!this._zoomAnimated||n.animate===!1||this._nothingToAnimate()&&!this.options.continuousZoom||Math.abs(t-this._zoom)>i)return!1;let a=this.getZoomScale(t),o=this._getCenterOffset(e)._divideBy(1-1/a);if(n.animate!==!0&&!this.getSize().contains(o))return!1;if(this.options.continuousZoom)return this._continuousZoom(e,t,o,n),!0;let s=this._userEvent;return this._zoomAnimFrame=requestAnimationFrame(()=>{this._zoomAnimFrame=null,s&&this._setUserEvent(s),this._moveStart(!0,n.noMoveStart??!1)._animateZoom(e,t,!0)}),!0}_animateZoom(e,t,n,r){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,this._mapPane.classList.add(`maplair-zoom-anim`)),this.fire(`zoomanim`,{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||=this._zoom!==this._animateToZoom,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._transitionEndTimer=setTimeout(this._onZoomTransitionEnd.bind(this),250))}_onZoomTransitionEnd(){this._animatingZoom&&(this._mapPane?.classList.remove(`maplair-zoom-anim`),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire(`zoom`),delete this._tempFireZoomEvent,this.fire(`move`),this._moveEnd(!0))}};for(let e of[Ae,M,q,P,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,jt,J,Lt,Tt,Re])e.register(Z);var Jt=class e extends L{static defaultOptions={smoothFactor:.5,noClip:!1};constructor(t,n){super(),f(this,n),this._setLatLngs(t),this.callInitHooks(e)}getLatLngs(){return this._latlngs}setLatLngs(e){return this._setLatLngs(e),this.redraw()}isEmpty(){return!this._latlngs.length}closestLayerPoint(e){e=g.from(e);let t=1/0,n=null,r,i,a=ot;for(let o of this._parts)for(let s=1,c=o.length;s<c;s++){r=o[s-1],i=o[s];let c=a(e,r,i,!0);c<t&&(t=c,n=a(e,r,i))}return n&&(n.distance=Math.sqrt(t)),n}getCenter(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return st(this._defaultShape(),this._map.options.crs)}getBounds(){return this._bounds}addLatLng(e,t){return t??=this._defaultShape(),e=new B(e),t.push(e),this._bounds.extend(e),this.redraw()}_setLatLngs(e){this._bounds=new R,this._latlngs=this._convertLatLngs(e)}_defaultShape(){return H(this._latlngs)?this._latlngs:this._latlngs[0]}_convertLatLngs(e){let t=[],n=H(e);for(let r=0,i=e.length;r<i;r++)n?(t[r]=new B(e[r]),this._bounds.extend(t[r])):t[r]=this._convertLatLngs(e[r]);return t}_project(){let e=new F;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,e),this._bounds.isValid()&&e.isValid()&&(this._rawPxBounds=e,this._updateBounds())}_updateBounds(){let e=this._clickTolerance(),t=new g(e,e);this._rawPxBounds&&(this._pxBounds=new F([this._rawPxBounds.min.subtract(t),this._rawPxBounds.max.add(t)]))}_projectLatlngs(e,t,n){if(e[0]instanceof B){let r=e.map(e=>this._map.latLngToLayerPoint(e));r.forEach(e=>n.extend(e)),t.push(r)}else e.forEach(e=>this._projectLatlngs(e,t,n))}_clipPoints(){let e=this._renderer._bounds;if(this._parts=[],!this._pxBounds||!this._pxBounds.intersects(e))return;if(this.options.noClip){this._parts=this._rings;return}let t=this._parts,n,r,i,a,o,s,c;for(n=0,i=0,a=this._rings.length;n<a;n++)for(c=this._rings[n],r=0,o=c.length;r<o-1;r++)s=rt(c[r],c[r+1],e,r,!0),s&&(t[i]??=[],t[i].push(s[0]),(s[1]!==c[r+1]||r===o-2)&&(t[i].push(s[1]),i++))}_simplifyPoints(){let e=this._parts,t=this.options.smoothFactor;for(let n=0,r=e.length;n<r;n++)e[n]=Xe(e[n],t)}_update(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())}_updatePath(){this._renderer._updatePoly(this)}_containsPoint(e,t){let n,r,i,a,o,s,c=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(n=0,a=this._parts.length;n<a;n++)for(s=this._parts[n],r=0,o=s.length,i=o-1;r<o;i=r++)if((t||r!==0)&&Ze(e,s[i],s[r])<=c)return!0;return!1}toGeoJSON(e){let t=!H(this._latlngs),n=ut(this._latlngs,+!!t,!1,e);return U(this,{type:`${t?`Multi`:``}LineString`,coordinates:n})}},Yt=/* @__PURE__ */ t({centroid:()=>Qt,clipPolygon:()=>Xt,polygonCenter:()=>Zt});function Xt(e,t,n){let r,i,a,o,s,c,l,u,d,f=[1,4,2,8];for(i=0,l=e.length;i<l;i++)e[i]._code=V(e[i],t);for(o=0;o<4;o++){for(u=f[o],r=[],i=0,l=e.length,a=l-1;i<l;a=i++)s=e[i],c=e[a],s._code&u?c._code&u||(d=it(c,s,u,t,n),d._code=V(d,t),r.push(d)):(c._code&u&&(d=it(c,s,u,t,n),d._code=V(d,t),r.push(d)),r.push(s));e=r}return e}function Zt(e,t){let n=ct(e,t),r=new g(n[0]),i=n.length;for(let e of n)e._subtract(r);let a=0,o=0,s=0;for(let e=0,t=i-1;e<i;t=e++){let r=n[e],i=n[t],c=r.y*i.x-i.y*r.x;o+=(r.x+i.x)*c,s+=(r.y+i.y)*c,a+=c}return t.unproject(a===0?r:new g(o/(3*a),s/(3*a))._add(r))}function Qt(e){let t=0,n=0,r=0;for(let i of e){let e=B.from(i);t+=e.lat,n+=e.lng,r++}return new B([t/r,n/r])}var $t=class e extends Jt{static defaultOptions={fill:!0};constructor(...t){super(...t),this.callInitHooks(e)}isEmpty(){return!this._latlngs.length||!this._latlngs[0].length}getCenter(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return Zt(this._defaultShape(),this._map.options.crs)}_convertLatLngs(e){let t=super._convertLatLngs(e),n=t.length;return n>=2&&t[0]instanceof B&&t[0].equals(t[n-1])&&t.pop(),t}_setLatLngs(e){super._setLatLngs(e),H(this._latlngs)&&(this._latlngs=[this._latlngs])}_defaultShape(){return H(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]}_clipPoints(){let e=this._renderer._bounds,t=this.options.weight,n=new g(t,t);if(e=new F(e.min.subtract(n),e.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(let t of this._rings){let n=Xt(t,e,!0);n.length&&this._parts.push(n)}}}_updatePath(){this._renderer._updatePoly(this,!0)}_containsPoint(e){let t=!1,n,r,i,a,o,s,c,l;if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(a=0,c=this._parts.length;a<c;a++)for(n=this._parts[a],o=0,l=n.length,s=l-1;o<l;s=o++)r=n[o],i=n[s],r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(t=!t);return t||super._containsPoint(e,!0)}toGeoJSON(e){let t=!H(this._latlngs),n=t&&!H(this._latlngs[0]),r=ut(this._latlngs,n?2:+!!t,!0,e);return t||(r=[r]),U(this,{type:`${n?`Multi`:``}Polygon`,coordinates:r})}},en=class e extends M{static defaultOptions={position:`bottomright`,width:150,height:150,zoomOffset:-5,collapsed:!1,rectangleOptions:{color:`#ff7800`,weight:1,fillOpacity:.2},mapOptions:{}};constructor(t,n){super(n),this._layer=t,this.callInitHooks(e)}addTo(e){return super.addTo(e),this._miniMap.invalidateSize({pan:!1}),this._update(),this}onAdd(e){let t=D(`div`,`maplair-control-minimap`),n=D(`div`,`maplair-control-minimap-map`,t);t.style.width=`${this.options.width}px`,t.style.height=`${this.options.height}px`;let r=this._toggle=D(`button`,`maplair-control-minimap-toggle`,t);return r.type=`button`,y(r,`click`,E),y(r,`click`,this.toggle,this),w(t),C(t),this._miniMap=new Z(n,{attributionControl:!1,zoomControl:!1,doubleClickZoom:!1,scrollWheelZoom:!1,boxZoom:!1,keyboard:!1,pinchZoom:!1,tapDragZoom:!1,ariaLabel:N.translate(`Overview map`),...this.options.mapOptions,layers:[this._layer]}),n.tabIndex=-1,this._rectangle=new $t([],{interactive:!1,...this.options.rectangleOptions}),this._miniMap.on({moveend:this._onMiniMapMoveEnd,click:this._onMiniMapClick},this),e.on(`move zoom rotate resize`,this._update,this),e.whenReady(this._update,this),this._setCollapsed(this.options.collapsed),t}onRemove(e){e.off(`move zoom rotate resize`,this._update,this),this._miniMap.remove(),this._miniMap=null}getMiniMap(){return this._miniMap}toggle(){return this._setCollapsed(!this._collapsed)}_setCollapsed(e){this._collapsed=e;let t=this._container??this._toggle.parentNode,n=e?N.translate(`Show the overview map`):N.translate(`Hide the overview map`);return t.classList.toggle(`maplair-control-minimap-collapsed`,e),this._toggle.title=n,this._toggle.setAttribute(`aria-label`,n),this._toggle.setAttribute(`aria-expanded`,!e),e||(this._miniMap.invalidateSize(),this._update()),this}_update(){let e=this._map,t=this._miniMap;if(!e?._loaded||!t||this._collapsed)return;let n=Math.max(t.getMinZoom(),Math.min(e.getZoom()+this.options.zoomOffset,t.getMaxZoom()));t.setView(e.getCenter(),n,{animate:!1});let r=e.getSize();this._rectangle.setLatLngs([[0,0],[r.x,0],r,[0,r.y]].map(t=>e.containerPointToLatLng(t))),t.hasLayer(this._rectangle)||this._rectangle.addTo(t)}_onMiniMapMoveEnd(e){e.originalEvent&&this._map.panTo(this._miniMap.getCenter())}_onMiniMapClick(e){this._miniMap.dragging?.moved()||this._map.panTo(e.latlng)}},tn=class e extends M{static defaultOptions={position:`bottomleft`,maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=`maplair-control-scale`,n=D(`div`,t),r=this.options;return this._addScales(r,`${t}-line`,n),e.on(r.updateWhenIdle?`moveend`:`move`,this._update,this),e.whenReady(this._update,this),n}onRemove(e){e.off(this.options.updateWhenIdle?`moveend`:`move`,this._update,this)}_addScales(e,t,n){e.metric&&(this._mScale=D(`div`,t,n)),e.imperial&&(this._iScale=D(`div`,t,n))}_update(){let e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)}_updateScales(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)}_updateMetric(e){let t=this._getRoundNum(e),n=t<1e3?N.translate(`{meters} m`,{meters:t}):N.translate(`{kilometers} km`,{kilometers:t/1e3});this._updateScale(this._mScale,n,t/e)}_updateImperial(e){let t=e*3.2808399,n,r,i;t>5280?(n=t/5280,r=this._getRoundNum(n),this._updateScale(this._iScale,N.translate(`{miles} mi`,{miles:r}),r/n)):(i=this._getRoundNum(t),this._updateScale(this._iScale,N.translate(`{feet} ft`,{feet:i}),i/t))}_updateScale(e,t,n){e.style.width=`${Math.round(this.options.maxWidth*n)}px`,e.innerHTML=t}_getRoundNum(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}},nn=class e extends h{static defaultOptions={popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1};constructor(t){super(),f(this,t),this.callInitHooks(e)}createIcon(e){return this._createIcon(`icon`,e)}createShadow(e){return this._createIcon(`shadow`,e)}_createIcon(e,t){let n=this._getIconUrl(e);if(!n){if(e===`icon`)throw Error(`iconUrl not set in Icon options (see the docs).`);return null}let r=this._createImg(n,t instanceof HTMLImageElement?t:null);return this._setIconStyles(r,e),(this.options.crossOrigin||this.options.crossOrigin===``)&&(r.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),r}_setIconStyles(e,t){let n=this.options,r=n[`${t}Size`];typeof r==`number`&&(r=[r,r]);let i=g.validate(r)&&g.from(r),a=t===`shadow`&&n.shadowAnchor||n.iconAnchor||i&&i.divideBy(2,!0),o=g.validate(a)&&g.from(a);e.className=`maplair-marker-${t} ${n.className||``}`,o&&(e.style.marginLeft=`${-o.x}px`,e.style.marginTop=`${-o.y}px`),i&&(e.style.width=`${i.x}px`,e.style.height=`${i.y}px`)}_createImg(e,t){return t??=document.createElement(`img`),t.src=e,t}_getIconUrl(e){return window.devicePixelRatio>1&&this.options[`${e}RetinaUrl`]||this.options[`${e}Url`]}},rn=class e extends nn{static defaultOptions={iconUrl:`data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round" viewBox="0 0 500 820"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 478.727 62.272)scale(37.566)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="%23C2331B"/><stop offset="1" stop-color="%23E2603F"/></linearGradient><linearGradient id="b" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 468.484 54.002)scale(19.053)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="%238F2D20"/><stop offset="1" stop-color="%23B23A27"/></linearGradient></defs><path fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10" d="M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z" transform="translate(-7889.1 -9807.44)scale(19.5417)"/><path fill="%23FFF" d="m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z" transform="translate(250 258)scale(.068)"/></svg>`,shadowUrl:`data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 817.2 820"><radialGradient id="a" cx="526.6" cy="486.836" r="478.154" fx="275.876" fy="893.983" gradientUnits="userSpaceOnUse"><stop offset="0" style="stop-color:%235c5c5c;stop-opacity:.9477"/><stop offset=".112" style="stop-color:%23474747;stop-opacity:.7805"/><stop offset=".34" style="stop-color:%23202020;stop-opacity:.4413"/><stop offset=".523" style="stop-color:%23090909;stop-opacity:.1692"/><stop offset=".637" style="stop-color:%23000;stop-opacity:0"/></radialGradient><path d="M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z" style="fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)"/></svg>`,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41]};constructor(...t){super(...t),this.callInitHooks(e)}},an=class e extends Y{constructor(t){super(t._map),this._marker=t,this.callInitHooks(e)}addHooks(){let e=this._marker._icon;this._draggable||=new X(e),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),e.classList.add(`maplair-marker-draggable`)}removeHooks(){this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),this._marker._icon?.classList.remove(`maplair-marker-draggable`)}moved(){return this._draggable?._moved}_adjustPan(e){let t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=j(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=new F(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){let i=new g((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(i,{animate:!1}),this._draggable._newPos._add(i),this._draggable._startPos._add(i),A(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e))}}_onDragStart(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup?.(),this._marker.fire(`movestart`).fire(`dragstart`)}_onPreDrag(e){this._marker.options.autoPan&&(cancelAnimationFrame(this._panRequest),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e)))}_onDrag(e){let t=this._marker,n=t._shadow,r=j(t._icon),i=t._map.layerPointToLatLng(r);n&&A(n,r),t._latlng=i,e.latlng=i,e.oldLatLng=this._oldLatLng,t.fire(`move`,e).fire(`drag`,e)}_onDragEnd(e){cancelAnimationFrame(this._panRequest),delete this._oldLatLng,this._marker.fire(`moveend`).fire(`dragend`,e)}},Q=class e extends P{static defaultOptions={icon:/* @__PURE__ */ new rn,interactive:!0,keyboard:!0,title:``,alt:`Marker`,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250,pane:`markerPane`,shadowPane:`shadowPane`,shadow:!0,bubblingPointerEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10};constructor(t,n){super(),f(this,n),this._latlng=new B(t),this.callInitHooks(e)}onAdd(e){this._zoomAnimated=this._zoomAnimated&&e.options.markerZoomAnimation,this._zoomAnimated&&e.on(`zoomanim`,this._animateZoom,this),this._initIcon(),this.update(),e.options.markerCulling&&this._updateCulling()}onRemove(e){this.dragging&&(this.options.draggable=this.dragging.enabled(),this.options.draggable&&this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&e.off(`zoomanim`,this._animateZoom,this),this._removeIcon(),this._removeShadow(),this._culled=!1}getEvents(){let e={zoom:this.update,viewreset:this.update};return this._map?.options.markerCulling&&(e.moveend=this._updateCulling),e}getLatLng(){return this._latlng}setLatLng(e){let t=this._latlng;return this._latlng=new B(e),this._map?.options.markerCulling&&this._updateCulling(),this.update(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})}setZIndexOffset(e){return this.options.zIndexOffset=e,this.update()}getIcon(){return this.options.icon}setIcon(e){return this.options.icon=e,this._map&&(this._initIcon(),this.update()),this}getElement(){return this._icon}update(){if(this._icon&&this._map&&!this._culled){let e=this._map.latLngToLayerPoint(this._latlng).round();this._setPos(e)}return this}_initIcon(){let e=this.options,t=`maplair-zoom-${this._zoomAnimated?`animated`:`hide`}`,n=e.icon.createIcon(this._icon),r=!1;n!==this._icon&&(this._icon&&this._removeIcon(),r=!0,e.title&&(n.title=e.title),n instanceof HTMLImageElement&&(n.alt=e.alt??``)),n.classList.add(t),e.keyboard&&(n.tabIndex=0,e.interactive&&n.setAttribute(`role`,`button`),y(n,`keydown`,this._onKeyDown,this)),this._icon=n,e.riseOnHover&&this.on({pointerover:this._bringToFront,pointerout:this._resetZIndex}),this.options.autoPanOnFocus&&y(n,`focus`,this._panOnFocus,this);let i=e.shadow?e.icon.createShadow(this._shadow):null,a=!1;i!==this._shadow&&(this._removeShadow(),a=!0),i&&(i.classList.add(t),i.alt=``),this._shadow=i,e.opacity<1&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),i&&a&&this.getPane(e.shadowPane).appendChild(this._shadow)}_removeIcon(){this.options.riseOnHover&&this.off({pointerover:this._bringToFront,pointerout:this._resetZIndex}),this.options.autoPanOnFocus&&x(this._icon,`focus`,this._panOnFocus,this),x(this._icon,`keydown`,this._onKeyDown,this),this._icon.remove(),this.removeInteractiveTarget(this._icon),this._icon=null}_updateCulling(){if(!this._icon||!this._map)return;let e=this._map,t=(e._cullingBounds??=e.getBounds().pad(.5)).contains(this._latlng)||!!this.dragging?._draggable?._moving||this._icon.contains(document.activeElement);t!==!this._culled&&(this._culled=!t,t?(this.getPane().appendChild(this._icon),this._shadow&&this.getPane(this.options.shadowPane).appendChild(this._shadow),this.update()):(this._icon.remove(),this._shadow?.remove()))}_removeShadow(){this._shadow?.remove(),this._shadow=null}_setPos(e){this._icon&&A(this._icon,e),this._shadow&&A(this._shadow,e),this._zIndex=e.y+this.options.zIndexOffset,this._resetZIndex()}_updateZIndex(e){let t=String(this._zIndex+e);this._icon&&this._icon.style.zIndex!==t&&(this._icon.style.zIndex=t)}_animateZoom(e){if(this._culled)return;let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center).round();this._setPos(t)}_updateInteractive(){this._icon&&(this.options.keyboard&&(this.options.interactive?this._icon.setAttribute(`role`,`button`):this._icon.removeAttribute(`role`)),this.options.interactive?(this._initInteraction(),this._draggableBeforeNonInteractive&&this.dragging?.enable()):(this._icon.classList.remove(`maplair-interactive`),this.removeInteractiveTarget(this._icon),this._draggableBeforeNonInteractive=this.dragging?.enabled(),this.dragging?.disable()))}_initInteraction(){if(this.options.interactive&&(this._icon.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._icon),an)){if(this.dragging?._draggable?._element===this._icon){this._icon.classList.toggle(`maplair-marker-draggable`,this.dragging.enabled());return}let e=this.options.draggable;this.dragging&&(e=this.dragging.enabled(),this.dragging.disable()),this.dragging=new an(this),e&&this.dragging.enable()}}setOpacity(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this}_updateOpacity(){let e=this.options.opacity;this._icon&&(this._icon.style.opacity=`${e}`),this._shadow&&(this._shadow.style.opacity=`${e}`)}_bringToFront(){this._updateZIndex(this.options.riseOffset)}_resetZIndex(){this._updateZIndex(0)}_onKeyDown(e){this.options.interactive&&e.target===this._icon&&!e.repeat&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this._clickedByKeyboard=!0,this._icon.click(),this._clickedByKeyboard=!1)}_panOnFocus(){let e=this._map;if(!e)return;let t=this.options.icon.options,n=t.iconSize?g.from(t.iconSize):new g(0,0),r=t.iconAnchor?g.from(t.iconAnchor):new g(0,0);e.panInside(this._latlng,{paddingTopLeft:r,paddingBottomRight:n.subtract(r)})}_getPopupAnchor(){return this.options.icon.options.popupAnchor}_getTooltipAnchor(){return this.options.icon.options.tooltipAnchor}toGeoJSON(e){return ft(this,e)}};const on=/* @__PURE__ */ new Map;function sn(e,t){return new Promise((n,r)=>{let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(t.reason)},{once:!0})})}var cn=class e extends M{static defaultOptions={position:`topleft`,geocoder:void 0,collapsed:!0,autoComplete:!1,autoCompleteDelay:250,minLength:3,zoom:16,marker:!0,clearOnMapClick:!1,placeholder:void 0,noResultsText:void 0};static nominatim({url:e=`https://nominatim.openstreetmap.org/search`,params:t={},acceptUsagePolicy:n=!1}={}){let{host:r}=new URL(e),i=r===`nominatim.openstreetmap.org`;if(i&&!n)throw Error(`Using the public Nominatim service requires that you read and accept its usage policy (https://operations.osmfoundation.org/policies/nominatim/) with the acceptUsagePolicy option.`);let a=/* @__PURE__ */ new Map;async function o(n,{signal:i}){let o=`${e}?${new URLSearchParams({q:n,format:`jsonv2`,limit:`5`,...t})}`;if(a.has(o))return a.get(o);let s=Date.now(),c=on.get(r)??0,l=c-s;on.set(r,Math.max(s,c)+1e3),l>0&&await sn(l,i);let u=await fetch(o,{signal:i});if(!u.ok)throw Error(`Nominatim: ${u.status} ${u.statusText}`);let d=(await u.json()).map(e=>{let[t,n,r,i]=e.boundingbox.map(Number);return{label:e.display_name,latlng:[Number(e.lat),Number(e.lon)],bounds:[[t,r],[n,i]],raw:e}});return a.set(o,d),a.size>100&&a.delete(a.keys().next().value),d}return Object.defineProperties(o,{attribution:{get:()=>`© <a href="https://www.openstreetmap.org/copyright">${N.translate(`OpenStreetMap contributors`)}</a>`},autoComplete:{value:!i}})}static layers(e,{property:t=`name`,label:n=e=>e.feature?.properties?.[t],limit:r=10}={}){return t=>{t=t.toLocaleLowerCase();let i=[];return e.eachLayer(function e(r){let a=n(r);if(a==null||a===``){r.eachLayer?.(e);return}let o={label:String(a),layer:r,raw:r.feature},s=o.label.toLocaleLowerCase().indexOf(t);if(!(s<0)){if(r.getLatLng)o.latlng=r.getLatLng();else if(r.getBounds?.().isValid())o.bounds=r.getBounds(),o.latlng=o.bounds.getCenter();else return;i.push({result:o,prefix:s===0})}}),Promise.resolve(i.sort((e,t)=>t.prefix-e.prefix||e.result.label.localeCompare(t.result.label)).slice(0,r).map(({result:e})=>e))}}constructor(...t){if(super(...t),!this.options.geocoder)throw Error(`SearchControl: the geocoder option is required, e.g. SearchControl.nominatim().`);this.callInitHooks(e)}onAdd(e){let t=`maplair-control-search`,n=this._container=D(`div`,`${t} maplair-bar`),r=D(`form`,`${t}-form`,n),i=this._toggle=D(`button`,`${t}-toggle`,r),o=this._input=D(`input`,`${t}-input`,r),s=D(`button`,`${t}-reset`,r),c=this._list=D(`ul`,`${t}-results`,n),l=`${t}-results-${a(this)}`,u=N.translate(`Search`);return r.role=`search`,i.type=`button`,i.innerHTML=`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M10 10l4.5 4.5"/></svg>`,i.title=u,i.setAttribute(`aria-label`,u),o.type=`search`,o.placeholder=this.options.placeholder??u,o.autocomplete=`off`,o.enterKeyHint=`search`,o.role=`combobox`,o.setAttribute(`aria-label`,u),o.setAttribute(`aria-autocomplete`,`list`),o.setAttribute(`aria-controls`,l),s.type=`reset`,s.innerHTML=`<span aria-hidden="true">×</span>`,s.title=N.translate(`Clear the search`),s.setAttribute(`aria-label`,s.title),c.id=l,c.role=`listbox`,c.setAttribute(`aria-label`,N.translate(`Search results`)),this._message=D(`div`,`${t}-message`,n),this._message.role=`status`,w(n),C(n),y(i,`click`,this._onToggle,this),y(r,`submit`,this._onSubmit,this),y(r,`reset`,this._onReset,this),y(o,`input`,this._onInput,this),y(o,`keydown`,this._onKeyDown,this),y(c,`click`,this._onListClick,this),e.on(`click`,this._onMapClick,this),this._attribution=this.options.geocoder.attribution,e.attributionControl?.addAttribution(this._attribution),this._showResults([]),this._setExpanded(!this.options.collapsed),n}onRemove(e){e.off(`click`,this._onMapClick,this),e.attributionControl?.removeAttribution(this._attribution),this._abort(),this._marker?.remove()}expand(){return this._setExpanded(!0),this._input.focus(),this}collapse(){return this._showResults([]),this._setExpanded(!this.options.collapsed),this}async search(e){if(this._abort(),this._input.value=e,e=e.trim(),!e)return this._showResults([]),[];let t=B.parse(e);if(t){let n=[{label:e,latlng:t}];return this._showResults(n),n}let n=this._controller=new AbortController;this._container.classList.add(`maplair-control-search-loading`);try{let t=await this.options.geocoder(e,{signal:n.signal});return n.signal.aborted||this._showResults(t,this.options.noResultsText??N.translate(`No results`)),t}catch(e){if(n.signal.aborted)return[];throw this._showResults([],N.translate(`The search failed`)),e}finally{this._controller===n&&(this._controller=null,this._container.classList.remove(`maplair-control-search-loading`))}}select(e){let t=this._map,n=B.from(e.latlng),r=e.bounds?R.from(e.bounds):void 0;this._input.value=e.label,this._showResults([]),r?.isValid()&&!r.getNorthWest().equals(r.getSouthEast())?t.fitBounds(r,{maxZoom:this.options.zoom}):t.setView(n,this.options.zoom),this._marker?.remove();let{marker:i}=this.options;return this._marker=typeof i==`function`?i(e)?.addTo(t)??null:i?new Q(n,{title:e.label}).addTo(t):null,t.fire(`searchresult`,{result:e,latlng:n,bounds:r}),this}clear(){return this._abort(),this._input.value=``,this._showResults([]),this._marker?.remove(),this._marker=null,this}_setExpanded(e){this._container.classList.toggle(`maplair-control-search-expanded`,e),this._toggle.setAttribute(`aria-expanded`,e)}_abort(){clearTimeout(this._autoCompleteTimeout),this._controller?.abort(),this._controller=null,this._container?.classList.remove(`maplair-control-search-loading`)}_showResults(e,t=``){this._results=e,this._list.replaceChildren(...e.map((e,t)=>{let n=D(`li`,`maplair-control-search-result`);return n.id=`${this._list.id}-${t}`,n.role=`option`,n.textContent=e.label,n})),this._list.hidden=!e.length,this._message.textContent=e.length?``:t,this._message.hidden=!this._message.textContent,this._input.setAttribute(`aria-expanded`,!!e.length),this._setActive(-1)}_setActive(e){this._active=e;for(let[t,n]of[...this._list.children].entries())n.setAttribute(`aria-selected`,t===e);if(e<0)this._input.removeAttribute(`aria-activedescendant`);else{let t=this._list.children[e];this._input.setAttribute(`aria-activedescendant`,t.id),t.scrollIntoView({block:`nearest`})}}_onToggle(){this.options.collapsed&&!this._container.classList.contains(`maplair-control-search-expanded`)?this.expand():this._onSubmit()}_onSubmit(e){e&&T(e);let t=this._input.value,n=this._results[this._active],r=B.parse(t);n?this.select(n):r?this.select({label:t.trim(),latlng:r}):this.search(t).catch(c)}_onReset(){this.clear(),this._input.focus()}_onInput(){clearTimeout(this._autoCompleteTimeout);let e=this._input.value.trim();!this.options.autoComplete||this.options.geocoder.autoComplete===!1?this._showResults([]):e.length>=this.options.minLength||B.parse(e)?this._autoCompleteTimeout=setTimeout(()=>{this.search(this._input.value).catch(c)},this.options.autoCompleteDelay):(this._abort(),this._showResults([]))}_onKeyDown(e){let t=this._results.length;if((e.key===`ArrowDown`||e.key===`ArrowUp`)&&t){T(e);let n=e.key===`ArrowDown`?1:-1;this._setActive(((this._active<0&&n<0?t:this._active)+n+t)%t)}else e.key===`Escape`&&(T(e),t||!this._message.hidden?this._showResults([]):this._input.value?this.clear():this.options.collapsed&&(this.collapse(),this._map.getContainer().focus()))}_onListClick(e){let t=e.target.closest(`.maplair-control-search-result`),n=[...this._list.children].indexOf(t);n>=0&&this.select(this._results[n])}_onMapClick(){this.options.clearOnMapClick?(this.clear(),this.collapse()):this._input.value?this._showResults([]):this.collapse()}},ln=class e extends M{static defaultOptions={ratio:.5};constructor(t,n,r){super(r),this._leftLayers=[t??[]].flat(),this._rightLayers=[n??[]].flat(),this._ratio=this.options.ratio,this.callInitHooks(e)}addTo(e){return this.remove(),this._map=e,this._container=this.onAdd(e),e._container.appendChild(this._container),e.on(`unload`,this.remove,this),this}onAdd(e){let t=D(`div`,`maplair-sidebyside-divider`),n=N.translate(`Divider between the compared layers`);return t.tabIndex=0,t.setAttribute(`role`,`slider`),t.setAttribute(`aria-label`,n),t.setAttribute(`aria-valuemin`,0),t.setAttribute(`aria-valuemax`,100),w(t),y(t,`pointerdown`,this._onPointerDown,this),y(t,`keydown`,this._onKeyDown,this),e.on(`move zoom viewreset resize rotate layeradd`,this._update,this),this._container=t,this._update(),t}onRemove(e){this._onPointerUp(),e.off(`move zoom viewreset resize rotate layeradd`,this._update,this);for(let e of[...this._leftLayers,...this._rightLayers]){let t=un(e);t&&(t.style.clipPath=``)}}setLeftLayers(e){return this._clear(this._leftLayers),this._leftLayers=[e].flat(),this._update()}setRightLayers(e){return this._clear(this._rightLayers),this._rightLayers=[e].flat(),this._update()}getRatio(){return this._ratio}setRatio(e){return this._ratio=Math.min(1,Math.max(0,e)),this._update(),this._map?.fire(`dividermove`,{ratio:this._ratio,x:this._x}),this}_clear(e){for(let t of e){let e=un(t);e&&(e.style.clipPath=``)}}_update(){let e=this._map;if(!e?._loaded||!this._container)return this;let t=e.getSize(),n=this._x=Math.round(t.x*this._ratio);return this._container.style.left=`${n}px`,this._container.setAttribute(`aria-valuenow`,Math.round(this._ratio*100)),this._clip(this._leftLayers,0,n,t.y),this._clip(this._rightLayers,n,t.x,t.y),this}_clip(e,t,n,r){let i=this._map;for(let a of e){let e=un(a);if(!e||!i.hasLayer(a))continue;let o=j(e),s=[[t,0],[n,0],[n,r],[t,r]].map(e=>{let t=i.containerPointToLayerPoint(e).subtract(o);return`${t.x}px ${t.y}px`});e.style.clipPath=`polygon(${s.join(`, `)})`}}_onPointerDown(e){E(e),this._container.focus({preventScroll:!0}),y(document,`pointermove`,this._onPointerMove,this),y(document,`pointerup pointercancel`,this._onPointerUp,this)}_onPointerMove(e){let t=this._map._container.getBoundingClientRect();this.setRatio((e.clientX-t.left)/t.width)}_onPointerUp(){x(document,`pointermove`,this._onPointerMove,this),x(document,`pointerup pointercancel`,this._onPointerUp,this)}_onKeyDown(e){let t=e.shiftKey?.01:.05;if(e.key===`ArrowLeft`)this.setRatio(this._ratio-t);else if(e.key===`ArrowRight`)this.setRatio(this._ratio+t);else return;E(e)}};function un(e){return e.getContainer?.()??e.getElement?.()}var dn=class e extends M{static defaultOptions={position:`topright`,content:``,className:``};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(){let e=D(`div`,`maplair-control-text ${this.options.className}`);return w(e),C(e),this._container=e,this._update(),e}setContent(e){return this.options.content=e,this._update(),this}getContent(){return this.options.content}_update(){let e=this._container,{content:t}=this.options;e&&(typeof t==`string`?e.innerHTML=t:e.replaceChildren(t??``),e.hidden=!t)}};const fn=e=>`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="${e}"/></svg>`,pn=fn(`M3 3h2v10H3zm10 0v10L6 8z`),mn=fn(`M4 2v12l10-6z`),hn=fn(`M4 3h3v10H4zm5 0h3v10H9z`),gn=fn(`M11 3h2v10h-2zM3 3v10l7-5z`),_n=/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;function vn(e){let t=_n.exec(e);if(!t||e===`P`||e.endsWith(`T`))throw Error(`Invalid or unsupported ISO 8601 duration "${e}".`);let[n,r,i,a,o,s,c]=t.slice(1).map(e=>Number(e??0));return{years:n,months:r,ms:((((i*7+a)*24+o)*60+s)*60+c)*1e3}}function yn(e,t,n){let r=new Date(e);return r.setUTCFullYear(r.getUTCFullYear()+n*t.years,r.getUTCMonth()+n*t.months),new Date(+r+n*t.ms)}function bn(e){let t=Date.parse(e);if(Number.isNaN(t))throw Error(`Invalid date "${e}".`);return new Date(t)}function xn(e,t){let n=e.split(`/`);if(n.length===3&&(t=n.pop()),n.length!==2)throw Error(`Invalid ISO 8601 interval "${e}".`);let[r,i]=n,a=vn(t),o,s;if(r.startsWith(`P`)?(s=bn(i),o=yn(s,vn(r),-1)):(o=bn(r),s=i.startsWith(`P`)?yn(o,vn(i),1):bn(i)),!(yn(o,a,1)>o))throw Error(`The period "${t}" has to be positive.`);let c=[];for(let e=0,t=o;t<=s;t=yn(o,a,++e))c.push(t);return c}var Sn=class e extends M{static defaultOptions={position:`bottomleft`,times:void 0,interval:void 0,period:`P1D`,time:void 0,layers:[],transitionTime:1e3,loop:!1,formatTime:void 0};constructor(...t){super(...t);let{times:n,interval:r,period:i,time:a,layers:o}=this.options;this._layers=[],this._playing=!1,this._times=[],this._index=-1,this.setTimes(r?xn(r,i):n??[],a);for(let e of o)this.addLayer(e);this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-bar maplair-control-time`);w(t),C(t),this._previousButton=new je({className:`maplair-control-time-previous`,content:pn,title:N.translate(`Step back`),onClick:()=>this.previous()}),this._playButton=new je({className:`maplair-control-time-play`,states:[{name:`play`,content:mn,title:N.translate(`Play`),onClick:()=>this.play()},{name:`pause`,content:hn,title:N.translate(`Pause`),onClick:()=>this.pause()}]}),this._nextButton=new je({className:`maplair-control-time-next`,content:gn,title:N.translate(`Step forward`),onClick:()=>this.next()});for(let n of[this._previousButton,this._playButton,this._nextButton])n._map=e,n._createButton(t);let n=this._slider=D(`input`,`maplair-control-time-slider`,t);return n.type=`range`,n.min=`0`,n.step=`1`,n.setAttribute(`aria-label`,N.translate(`Time`)),y(n,`input`,this._onSliderInput,this),this._label=D(`span`,`maplair-control-time-label`,t),this._formatter=new Intl.DateTimeFormat(N.getLocale()??void 0,{dateStyle:`short`,timeStyle:`short`}),this._updateControl(),t}onRemove(){this.pause(),this._slider=null}_onSliderInput(){this.pause(),this._setIndex(Number(this._slider.value))}_updateControl(){if(!this._slider)return;let e=this._index,t=this._times.length-1,n=this.getTime(),r=n?(this.options.formatTime??this._formatter.format)(n):``,i=this.options.loop;this._slider.max=String(Math.max(t,0)),this._slider.value=String(Math.max(e,0)),this._slider.disabled=t<1,this._slider.setAttribute(`aria-valuetext`,r),this._label.textContent=r,this._playButton.setState(this._playing?`pause`:`play`),this._setDisabled(this._playButton,t<1),this._setDisabled(this._previousButton,t<1||e===0&&!i),this._setDisabled(this._nextButton,t<1||e===t&&!i)}_setDisabled(e,t){t?e.disable():e.enable()}setTimes(e,t=this.getTime()){return this._times=e.map(e=>new Date(e)),this._index=-1,this._times.length<2&&this.pause(),this.setTime(t??Date.now())}getTimes(){return this._times}setTime(e){let t=+new Date(e),n=this._times.length?0:-1;return this._times.forEach((e,r)=>{Math.abs(+e-t)<Math.abs(+this._times[n]-t)&&(n=r)}),this._setIndex(n)}getTime(){return this._times[this._index]}_setIndex(e){if(e!==this._index){this._index=e;for(let e of this._layers)this._updateLayer(e);e>=0&&this._map?.fire(`timechange`,{time:this.getTime(),index:e}),this._playing&&this._schedule()}return this._updateControl(),this}next(){return this._index<this._times.length-1?this._setIndex(this._index+1):this.options.loop&&this._times.length>1&&this._setIndex(0),this}previous(){return this._index>0?this._setIndex(this._index-1):this.options.loop&&this._times.length>1&&this._setIndex(this._times.length-1),this}play(){return this._playing||this._times.length<2||(this._playing=!0,this._index===this._times.length-1?this._setIndex(0):(this._schedule(),this._updateControl())),this}pause(){return clearTimeout(this._timeout),this._timeout=null,this._playing&&(this._playing=!1,this._updateControl()),this}isPlaying(){return this._playing}_schedule(){clearTimeout(this._timeout),this._timeout=setTimeout(()=>{this._timeout=null,this._advance()},this.options.transitionTime)}_advance(){!this._playing||this._timeout||this._layers.some(e=>e._map&&e.isLoading?.())||(this._index<this._times.length-1||this.options.loop?this.next():this.pause())}_updateLayer(e){let t=this.getTime();t&&(typeof e.setTime==`function`?e.setTime(t):typeof e.setParams==`function`?e.setParams({time:t.toISOString()}):typeof e.setUrl==`function`&&(e.options.time=t.toISOString(),e.setUrl(e._url,!1)))}addLayer(e){return this._layers.includes(e)||(this._layers.push(e),e.on(`load remove`,this._advance,this),this._updateLayer(e)),this}removeLayer(e){return this._layers=this._layers.filter(t=>t!==e),e.off(`load remove`,this._advance,this),this._advance(),this}};const Cn={project(e){return e=B.from(e),new g(e.lng,e.lat)},unproject(e){return e=g.from(e),new B(e.y,e.x)},bounds:/* @__PURE__ */ new F([-180,-90],[180,90])},wn={R:6378137,R_MINOR:6356752.314245179,bounds:/* @__PURE__ */ new F([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project(e){e=B.from(e);let t=Math.PI/180,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=e.lat*t,o=i*Math.sin(a),s=Math.tan(Math.PI/4-a/2)/((1-o)/(1+o))**(i/2);return a=-n*Math.log(Math.max(s,1e-10)),new g(e.lng*t*n,a)},unproject(e){e=g.from(e);let t=180/Math.PI,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=Math.exp(-e.y/n),o=Math.PI/2-2*Math.atan(a);for(let e=0,t=.1,n;e<15&&Math.abs(t)>1e-7;e++)n=i*Math.sin(o),n=((1-n)/(1+n))**(i/2),t=Math.PI/2-2*Math.atan(a*n)-o,o+=t;return new B(o*t,e.x*t/n)}};var Tn=/* @__PURE__ */ t({LonLat:()=>Cn,Mercator:()=>wn,SphericalMercator:()=>bt}),En=class extends G{static code=`EPSG:3395`;static projection=wn;static transformation=/* @__PURE__ */ (()=>{let e=.5/(Math.PI*wn.R);return new xt(e,.5,-e,.5)})()},Dn=class extends G{static code=`EPSG:4326`;static projection=Cn;static transformation=/* @__PURE__ */ new xt(1/180,1,-1/180,.5)},On=class extends vt{static projection=Cn;static transformation=/* @__PURE__ */ new xt(1,0,-1,0);static scale(e){return 2**e}static zoom(e){return Math.log(e)/Math.LN2}static distance(e,t){let n=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(n*n+r*r)}static infinite=!0},kn=class e extends K{constructor(t,n){super(void 0,n),t&&this.addData(t),this.callInitHooks(e)}addData(t){let n=Array.isArray(t)?t:t.features;if(n){for(let e of n)(e.geometries||e.geometry||e.features||e.coordinates)&&this.addData(e);return this}let r=this.options;if(r.filter&&!r.filter(t))return this;let i=e.geometryToLayer(t,r);return i?(i.feature=e.asFeature(t),i.defaultOptions=i.options,this.resetStyle(i),r.onEachFeature&&r.onEachFeature(t,i),this.addLayer(i)):this}resetStyle(e){return e===void 0?this.eachLayer(this.resetStyle,this):(e.options=Object.create(e.defaultOptions),this._setLayerStyle(e,this.options.style),this)}setStyle(e){return this.eachLayer(t=>this._setLayerStyle(t,e))}_setLayerStyle(e,t){e.setStyle&&(typeof t==`function`&&(t=t(e.feature)),e.setStyle(t))}static geometryToLayer(t,n){let r=t.type===`Feature`?t.geometry:t,i=r?.coordinates,a=[],o=n?.pointToLayer,s=n?.coordsToLatLng??e.coordsToLatLng,c,l;if(!i&&!r)return null;switch(r.type){case`Point`:return c=s(i),e._pointToLayer(o,t,c,n);case`MultiPoint`:for(let r of i)c=s(r),a.push(e._pointToLayer(o,t,c,n));return new K(a);case`LineString`:case`MultiLineString`:return l=e.coordsToLatLngs(i,r.type===`LineString`?0:1,s),new Jt(l,n);case`Polygon`:case`MultiPolygon`:return l=e.coordsToLatLngs(i,r.type===`Polygon`?1:2,s),new $t(l,n);case`GeometryCollection`:for(let i of r.geometries){let r=e.geometryToLayer({geometry:i,type:`Feature`,properties:t.properties},n);r&&(r.feature=e.asFeature(i),a.push(r))}return new K(a);case`FeatureCollection`:for(let t of r.features){let r=e.geometryToLayer(t,n);r&&a.push(r)}return new K(a);default:throw Error(`Invalid GeoJSON object.`)}}static _pointToLayer(e,t,n,r){return e?e(t,n):new Q(n,r?.markersInheritOptions&&r)}static coordsToLatLng(e){return new B(e[1],e[0],e[2])}static coordsToLatLngs(t,n,r){return t.map(t=>n?e.coordsToLatLngs(t,n-1,r):(r||e.coordsToLatLng)(t))}static latLngToCoords(e,t){return lt(e,t)}static latLngsToCoords(e,t,n,r){return ut(e,t,n,r)}static getFeature(e,t){return U(e,t)}static asFeature(e){return dt(e)}},An=class{constructor(e,t){this.options={name:``,value:void 0,normalize:void 0,otherValues:void 0,...t},this._classes=e,this._values=/* @__PURE__ */ new Map,this._labels=/* @__PURE__ */ new Map;let n=[];for(let t of e){if(`value`in t)for(let e of Array.isArray(t.value)?t.value:[t.value]){let n=this._normalize(e);this._values.has(n)||this._values.set(n,t)}else n.push(t);t.legend!==void 0&&!this._labels.has(this._normalize(t.legend))&&this._labels.set(this._normalize(t.legend),t)}this._ranges=n.sort((e,t)=>(e.lower??-1/0)-(t.lower??-1/0));let r=this.options.otherValues;this._other=r&&{legend:N.translate(`All other values`),...r},this.style=this.style.bind(this)}classify(e){let t=this._normalize(this._getValue(e?.feature??e));return this._values.get(t)??this._findRange(t)??this._labels.get(t)??this._other}style(e){return this.classify(e)?.symbol??{}}legendItems(){return this._getItems().items}featureCount(e){let{items:t,itemOf:n}=this._getItems(),r=new Map(t.map(e=>[e,0]));for(let t of e){let e=n.get(this.classify(t));e&&r.set(e,r.get(e)+1)}let i=t.reduce((e,t)=>e+(t.counted?r.get(t):0),0);return t.map(e=>({...e,count:r.get(e),share:e.counted?i?r.get(e)/i:0:void 0}))}_getValue(e){let{value:t}=this.options;return typeof t==`function`?t(e):t===void 0?e:e?.properties?.[t]}_normalize(e){e??=null;let{normalize:t}=this.options;return t&&e!==null?t(e):e}_findRange(e){let t=typeof e==`string`&&e.trim()!==``?Number(e):e;if(typeof t!=`number`||Number.isNaN(t))return;let n=this._ranges,r=0,i=n.length-1,a;for(;r<=i;){let e=r+i>>1;(n[e].lower??-1/0)<=t?(a=n[e],r=e+1):i=e-1}return a&&t<(a.upper??1/0)?a:void 0}_getItems(){let e=[],t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=this._other?[...this._classes,this._other]:this._classes;for(let i of r){let r=i.legend??this._defaultLegend(i),a=`${r}\u0000${JSON.stringify(i.symbol??{})}`,o=n.get(a);o||(o={legend:r,symbol:i.symbol??{},counted:i.counted!==!1,classes:[]},n.set(a,o),e.push(o)),o.classes.push(i),t.set(i,o)}return{items:e,itemOf:t}}_defaultLegend(e){if(`value`in e)return[e.value].flat().map(String).join(`, `);let t=e=>e.toLocaleString(N.getLocale()??void 0);return e.lower===void 0?`< ${t(e.upper)}`:e.upper===void 0?`≥ ${t(e.lower)}`:`${t(e.lower)}–${t(e.upper)}`}static quantile(e,t){let n=e.filter(Number.isFinite).toSorted((e,t)=>e-t),r=[];for(let e=1;e<t&&n.length;e++)r.push(n[Math.floor(e*n.length/t)]);return jn(r)}static equalInterval(e,t){let n=e.filter(Number.isFinite);if(!n.length)return jn([]);let r=Math.min(...n),i=(Math.max(...n)-r)/t,a=[];for(let e=1;e<t;e++)a.push(r+e*i);return jn(a)}};function jn(e){let t=[...new Set(e)];return[void 0,...t].map((e,n)=>{let r={};return e!==void 0&&(r.lower=e),n<t.length&&(r.upper=t[n]),r})}var Mn=class e extends Be{static defaultOptions={radius:25,blur:15,max:1,maxZoom:void 0,minOpacity:.05,gradient:{.4:`blue`,.6:`cyan`,.7:`lime`,.8:`yellow`,1:`red`},pane:`overlayPane`};constructor(t,n){super(n),this._latlngs=t??[],this.callInitHooks(e)}setLatLngs(e){return this._latlngs=e,this.redraw()}addLatLng(e){return this._latlngs.push(e),this.redraw()}getLatLngs(){return this._latlngs}setOptions(e){return f(this,e),this._circle=this._gradient=null,this.redraw()}redraw(){return this._map&&this._bounds&&(cancelAnimationFrame(this._frame),this._frame=requestAnimationFrame(()=>this._draw())),this}_initContainer(){this._container=document.createElement(`canvas`),this._container.classList.add(`maplair-heatmap-layer`),this._ctx=this._container.getContext(`2d`)}_destroyContainer(){cancelAnimationFrame(this._frame),super._destroyContainer()}_resizeContainer(){let e=super._resizeContainer();return this._container.width=e.x,this._container.height=e.y,e}_onSettled(){this._draw()}_getCircle(){if(this._circle)return this._circle;let{radius:e,blur:t}=this.options,n=e+t,r=this._circle=document.createElement(`canvas`),i=r.getContext(`2d`);return r.width=r.height=n*2,i.shadowOffsetX=i.shadowOffsetY=n*2,i.shadowBlur=t,i.shadowColor=`black`,i.beginPath(),i.arc(-n,-n,e,0,Math.PI*2,!0),i.closePath(),i.fill(),r}_getGradient(){if(this._gradient)return this._gradient;let e=document.createElement(`canvas`),t=e.getContext(`2d`),n=t.createLinearGradient(0,0,0,256);e.width=1,e.height=256;for(let[e,t]of Object.entries(this.options.gradient))n.addColorStop(Number(e),t);return t.fillStyle=n,t.fillRect(0,0,1,256),this._gradient=t.getImageData(0,0,1,256).data,this._gradient}_draw(){let e=this._map;if(!e||!this._bounds)return;let t=this._ctx,{width:n,height:r}=this._container,i=this._bounds.min,{radius:a,blur:o,max:s,minOpacity:c}=this.options,l=a+o,u=this.options.maxZoom??e.getMaxZoom(),d=1/2**Math.max(0,Math.min(u-e.getZoom(),12)),f=a/2,p=/* @__PURE__ */ new Map;for(let t of this._latlngs){let a=e.latLngToLayerPoint(t).subtract(i);if(a.x<-l||a.y<-l||a.x>n+l||a.y>r+l)continue;let o=(t.alt??t[2]??1)*d,s=`${Math.floor(a.x/f)}:${Math.floor(a.y/f)}`,c=p.get(s);if(c){let e=c.intensity+o;c.x=(c.x*c.intensity+a.x*o)/e,c.y=(c.y*c.intensity+a.y*o)/e,c.intensity=e}else p.set(s,{x:a.x,y:a.y,intensity:o})}t.clearRect(0,0,n,r);let ee=this._getCircle();for(let{x:e,y:n,intensity:r}of p.values())t.globalAlpha=Math.min(Math.max(r/s,c),1),t.drawImage(ee,e-l,n-l);if(t.globalAlpha=1,!p.size)return;let te=t.getImageData(0,0,n,r),m=te.data,h=this._getGradient();for(let e=3;e<m.length;e+=4){let t=m[e]*4;t&&(m[e-3]=h[t],m[e-2]=h[t+1],m[e-1]=h[t+2])}t.putImageData(te,0,0)}},Nn=class e extends P{static defaultOptions={opacity:1,alt:``,interactive:!1,crossOrigin:!1,errorOverlayUrl:``,zIndex:1,className:``,pixelated:!1,decoding:`auto`};constructor(t,n,r){super(),this._url=t,this._bounds=new R(n),f(this,r),this.callInitHooks(e)}onAdd(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(this._image.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._image)),this._image.classList.toggle(`maplair-pixelated`,!!this.options.pixelated),this.getPane().appendChild(this._image),this._reset()}onRemove(){this._image.remove(),this.options.interactive&&this.removeInteractiveTarget(this._image)}_updateInteractive(){this._image.classList.toggle(`maplair-interactive`,this.options.interactive),this.options.interactive?this.addInteractiveTarget(this._image):this.removeInteractiveTarget(this._image)}setOpacity(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this}setStyle(e){return e.opacity&&this.setOpacity(e.opacity),this}bringToFront(){return this._map&&O(this._image),this}bringToBack(){return this._map&&Se(this._image),this}setUrl(e){return this._url=e,this._image&&(this._image.src=e),this}setBounds(e){return this._bounds=new R(e),this._map&&this._reset(),this}getEvents(){return{zoom:this._reset,viewreset:this._reset,zoomanim:this._animateZoom}}setZIndex(e){return this.options.zIndex=e,this._updateZIndex(),this}getBounds(){return this._bounds}getElement(){return this._image}_initImage(){let e=this._url instanceof HTMLImageElement,t=this._image=e?this._url:D(`img`);t.classList.add(`maplair-image-layer`,`maplair-zoom-animated`),this.options.className&&t.classList.add(...d(this.options.className)),t.onload=this.fire.bind(this,`load`),t.onerror=this._overlayOnError.bind(this),(this.options.crossOrigin||this.options.crossOrigin===``)&&(t.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),t.decoding=this.options.decoding,this.options.zIndex&&this._updateZIndex(),e?this._url=t.src:(t.src=this._url,t.alt=this.options.alt)}_animateZoom(e){let t=this._map.getZoomScale(e.zoom),n=this._map._latLngToNewLayerPoint(this._bounds.getNorthWest(),e.zoom,e.center);k(this._image,n,t)}_reset(){let e=this._image,t=new F(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=t.getSize();A(e,t.min),e.style.width=`${n.x}px`,e.style.height=`${n.y}px`}_updateOpacity(){this._image.style.opacity=`${this.options.opacity}`}_updateZIndex(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=`${this.options.zIndex}`)}_overlayOnError(){this.fire(`error`);let e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)}getCenter(){return this._bounds.getCenter()}},Pn=class e extends Nn{static defaultOptions={autoplay:!0,controls:!1,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0};constructor(...t){super(...t),this.callInitHooks(e)}_initImage(){let e=this._url instanceof HTMLVideoElement,t=this._image=e?this._url:D(`video`);if(t.classList.add(`maplair-image-layer`,`maplair-zoom-animated`),this.options.className&&t.classList.add(...d(this.options.className)),y(t,`pointerdown`,e=>{t.controls&&S(e)}),t.onloadeddata=this.fire.bind(this,`load`),e){let e=t.getElementsByTagName(`source`),n=Array.from(e,e=>e.src);this._url=e.length>0?n:[t.src]}else{Array.isArray(this._url)||(this._url=[this._url]),this.options.keepAspectRatio||(t.style.objectFit=`fill`),t.autoplay=!!this.options.autoplay,t.controls=!!this.options.controls,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(let e of this._url){let n=D(`source`);n.src=e,t.appendChild(n)}}}},Fn=class e extends Nn{constructor(...t){super(...t),this.callInitHooks(e)}_initImage(){let e=this._image=this._url;e.classList.add(`maplair-image-layer`,`maplair-zoom-animated`),this.options.className&&e.classList.add(...d(this.options.className))}},In=class e extends nn{static defaultOptions={iconSize:[12,12],html:!1,bgPos:null,className:`maplair-div-icon`};constructor(...t){super(...t),this.callInitHooks(e)}createIcon(e){let t=e instanceof HTMLDivElement?e:document.createElement(`div`),n=this.options;if(n.html instanceof Element?(t.replaceChildren(),t.appendChild(n.html)):t.innerHTML=n.html===!1?``:n.html,n.bgPos){let e=g.from(n.bgPos);t.style.backgroundPosition=`${-e.x}px ${-e.y}px`}return this._setIconStyles(t,`icon`),t}createShadow(){return null}};function Ln(e,t,n){let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return n?.appendChild(r),r}var Rn=class e extends rn{static defaultOptions={color:`#d4462c`,glyph:void 0,glyphPath:void 0,glyphColor:`white`};constructor(...t){super(...t),this.callInitHooks(e)}createIcon(e){let t=e?.tagName===`DIV`?e:document.createElement(`div`),n=this.options,r=Ln(`svg`,{viewBox:`0 0 500 820`,width:`100%`,height:`100%`,"aria-hidden":`true`});return Ln(`path`,{d:`M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z`,transform:`translate(-7889.1 -9807.44)scale(19.5417)`,fill:n.color,stroke:`color-mix(in srgb, ${n.color}, black 30%)`,"stroke-width":`1.1`,"stroke-linejoin":`miter`},r),n.glyphPath?Ln(`path`,{d:n.glyphPath,fill:n.glyphColor,transform:`translate(135 155)scale(9.583333333333334)`},r):n.glyph?Ln(`text`,{x:250,y:270,fill:n.glyphColor,"font-size":230,"font-family":`sans-serif`,"font-weight":`bold`,"text-anchor":`middle`,"dominant-baseline":`central`},r).textContent=n.glyph:Ln(`path`,{d:`m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z`,transform:`translate(250 258)scale(.068)`,fill:n.glyphColor},r),t.replaceChildren(r),this._setIconStyles(t,`icon`),t}},zn=class e extends K{static defaultOptions={maxClusterRadius:80,disableClusteringAtZoom:void 0,zoomToBoundsOnClick:!0,spiderfyOnMaxZoom:!0,iconCreateFunction:void 0};constructor(t,n){super(t,n),this._shown=/* @__PURE__ */ new Set,this.callInitHooks(e)}addLayer(e){return this.addLayers([e])}addLayers(e){for(let t of e)this.hasLayer(t)||(t.addEventParent(this).on(`dragend`,this._onDragEnd,this),this._layers[this.getLayerId(t)]=t,this.fire(`layeradd`,{layer:t}));return this.refreshClusters()}removeLayer(e){return e=typeof e==`number`?this._layers[e]:e,!e||!this.hasLayer(e)?this:(this._unspiderfy(),e.removeEventParent(this).off(`dragend`,this._onDragEnd,this),delete this._layers[this.getLayerId(e)],this._shown?.delete(e)&&this._map.removeLayer(e),this.fire(`layerremove`,{layer:e}),this.refreshClusters())}clearLayers(){this._unspiderfy();for(let e of this.getLayers())e.removeEventParent(this).off(`dragend`,this._onDragEnd,this),this.fire(`layerremove`,{layer:e});return this._layers={},this.refreshClusters()}refreshClusters(){return this._clusters=null,this._map&&this._update(),this}onAdd(){this._clusters=null,this._update()}onRemove(e){this._unspiderfy();for(let t of this._shown)e.removeLayer(t);this._shown.clear()}getEvents(){return{moveend:this._update,zoomstart:this._unspiderfy,click:this._unspiderfy}}_onDragEnd({target:e}){e._clusterLatLng&&=e.getLatLng(),this.refreshClusters()}_update(){let e=this._map,t=e.getZoom();(!this._clusters||this._clustersZoom!==t)&&(this._unspiderfy(),this._clusters=this._cluster(),this._clustersZoom=t);let n=e.getPixelBounds().pad(.5),r=/* @__PURE__ */ new Set;for(let e of this._clusters){let{markers:t,point:i}=e;t.length>1?n.contains(i)&&(e.marker??=this._createClusterMarker(e),r.add(e.marker)):(!t[0].getLatLng||n.contains(i))&&r.add(t[0])}let i=this._spider?.clusterMarker;for(let t of this._shown)r.has(t)||e.removeLayer(t);for(let t of r)t!==i&&e.addLayer(t);this._shown=r}_cluster(){let e=this._map,t=e.getZoom(),n=this.options.maxClusterRadius,r=t>=(this.options.disableClusteringAtZoom??1/0),i=/* @__PURE__ */ new Map,a=[];for(let o of Object.values(this._layers)){if(!o.getLatLng){a.push({markers:[o]});continue}let s=e.project(o.getLatLng(),t),c=Math.floor(s.x/n),l=Math.floor(s.y/n),u,d=n;for(let e=c-1;e<=c+1;e++)for(let t=l-1;t<=l+1;t++)for(let n of r?[]:i.get(`${e}:${t}`)??[]){let e=n.point.distanceTo(s);e<=d&&(u=n,d=e)}if(u)u.markers.push(o);else{let e={point:s,markers:[o]},t=`${c}:${l}`;i.has(t)||i.set(t,[]),i.get(t).push(e),a.push(e)}}for(let n of a)if(n.markers.length>1){let r=n.markers.map(e=>e.getLatLng());n.latlng=new B(r.reduce((e,t)=>e+t.lat,0)/r.length,r.reduce((e,t)=>e+t.lng,0)/r.length),n.point=e.project(n.latlng,t)}return a}_createClusterMarker({latlng:e,markers:t}){let n={latlng:e,bounds:new R(t.map(e=>e.getLatLng())),markers:t,count:t.length},r=new Q(e,{icon:this.options.iconCreateFunction?.(n)??this._createIcon(n),title:N.translate(`{count} markers`,{count:n.count})});return r.on(`click`,e=>this._onClusterClick(n,r,e)),r}_createIcon({count:e}){let t=e<10?`small`:e<100?`medium`:`large`;return new In({html:`<span>${e}</span>`,className:`maplair-cluster maplair-cluster-${t}`,iconSize:{small:32,medium:38,large:44}[t]})}_onClusterClick(e,t,n){this.fire(`clusterclick`,{cluster:e,layer:t,originalEvent:n.originalEvent});let r=this._map,i=r.getMaxZoom(),{bounds:a}=e;r.getZoom()<i&&(this.options.disableClusteringAtZoom<=i||r.project(a.getNorthEast(),i).distanceTo(r.project(a.getSouthWest(),i))>this.options.maxClusterRadius)?this.options.zoomToBoundsOnClick&&r.fitBounds(a):this.options.spiderfyOnMaxZoom&&this._spiderfy(e,t)}_spiderfy({markers:e},t){this._unspiderfy();let n=this._map,r=n.latLngToLayerPoint(t.getLatLng()),i=Math.max(30,e.length*30/(2*Math.PI)),a=this._spider={markers:e,clusterMarker:t,legs:[]};n.removeLayer(t),e.forEach((o,s)=>{let c=2*Math.PI*s/e.length,l=n.layerPointToLatLng(r.add(new g(Math.cos(c),Math.sin(c)).multiplyBy(i)));o._clusterLatLng=o.getLatLng(),o.setLatLng(l);let u=new Jt([t.getLatLng(),l],{className:`maplair-cluster-leg`,interactive:!1,weight:1.5});a.legs.push(u),n.addLayer(u),n.addLayer(o)})}_unspiderfy(){let e=this._spider;if(!e)return;this._spider=null;let t=this._map;for(let n of e.legs)t?.removeLayer(n);for(let n of e.markers)t?.removeLayer(n),n.setLatLng(n._clusterLatLng),delete n._clusterLatLng;t&&this._shown.has(e.clusterMarker)&&t.addLayer(e.clusterMarker)}},Bn=class e extends P{static defaultOptions={tileSize:256,opacity:1,placeholder:null,updateWhenIdle:!1,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:`tilePane`,className:``,pixelated:!1,keepBuffer:2};constructor(t){super(),f(this,t),this.callInitHooks(e)}onAdd(){this._initContainer(),this._levels={},this._tiles={},this._resetView()}beforeAdd(e){e._addZoomLimit(this)}onRemove(e){this._removeKeptLevel(),this._removeAllTiles(),this._container.remove(),e._removeZoomLimit(this),this._container=null,this._tileZoom=void 0,clearTimeout(this._pruneTimeout),cancelAnimationFrame(this._fadePruneFrame),this._fadePruneFrame=0}bringToFront(){return this._map&&(O(this._container),this._setAutoZIndex(Math.max)),this}bringToBack(){return this._map&&(Se(this._container),this._setAutoZIndex(Math.min)),this}getContainer(){return this._container}setOpacity(e){return this.options.opacity=e,this._updateOpacity(),this}setZIndex(e){return this.options.zIndex=e,this._updateZIndex(),this}isLoading(){return this._loading}redraw(){if(this._map){this._removeAllTiles();let e=this._clampZoom(Math.round(this._map.getZoom()));e!==this._tileZoom&&(this._tileZoom=e,this._updateLevels()),this._update()}return this}getEvents(){let e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd,worldcopyjump:this._onWorldCopyJump,zoomanim:this._animateZoom};return this.options.updateWhenIdle||(this._onMove||=o(this._onMoveEnd,this.options.updateInterval,this),e.move=this._onMove),e}createTile(){return document.createElement(`div`)}getTileSize(){let e=this.options.tileSize;return e instanceof g?e:new g(e,e)}_updateZIndex(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=`${this.options.zIndex}`)}_setAutoZIndex(e){let t=this.getPane().children,n=-e(-1/0,1/0);for(let r of t){let t=r.style.zIndex;r!==this._container&&t&&(n=e(n,+t))}isFinite(n)&&(this.options.zIndex=n+e(-1,1),this._updateZIndex())}_updateOpacity(){this._map&&(this._container.style.opacity=`${this.options.opacity}`)}_onOpaqueTile(){}_initContainer(){this._container||(this._container=D(`div`,`maplair-layer ${this.options.className??``}`),this._container.classList.toggle(`maplair-pixelated`,!!this.options.pixelated),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))}_keepCurrentTiles(){let e=this._tileZoom,t=this._levels?.[e];if(!this._map||!t||this._keptLevel)return;let n=[];for(let[t,r]of Object.entries(this._tiles))r.coords.z===e&&r.loaded&&(n.push(r),delete this._tiles[t]);delete this._levels[e],t.el.style.zIndex=-1,this._keptLevel={level:t,tiles:n},this._updateLevels(),this.on(`load`,this._onLoadKeptLevel,this),this._map.on(`zoomstart viewprereset`,this._removeKeptLevel,this)}_onLoadKeptLevel(){this._map._fadeAnimated?(clearTimeout(this._keptLevelTimeout),this._keptLevelTimeout=setTimeout(this._removeKeptLevel.bind(this),250)):this._removeKeptLevel()}_removeKeptLevel(){if(!this._keptLevel)return;let{level:e,tiles:t}=this._keptLevel;this._keptLevel=null,clearTimeout(this._keptLevelTimeout),this.off(`load`,this._onLoadKeptLevel,this),this._map.off(`zoomstart viewprereset`,this._removeKeptLevel,this),e.el.remove();for(let e of t)this.fire(`tileunload`,{tile:e.el,coords:e.coords})}_updateLevels(){let e=this._tileZoom,t=this.options.maxZoom;if(e===void 0)return;for(let n of Object.keys(this._levels))n=Number(n),this._levels[n].el.children.length||n===e?(this._levels[n].el.style.zIndex=`${t-Math.abs(e-n)}`,this._onUpdateLevel(n)):(this._levels[n].el.remove(),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);let n=this._levels[e],r=this._map;return n||(n=this._levels[e]={},n.el=D(`div`,`maplair-tile-container maplair-zoom-animated`,this._container),n.el.style.zIndex=`${t}`,n.origin=r.project(r.unproject(r.getPixelOrigin()),e).round(),n.zoom=e,this._setZoomTransform(n,r.getCenter(),r.getZoom()),n.el.offsetWidth,this._onCreateLevel(n)),this._level=n,n}_onUpdateLevel(){}_onRemoveLevel(){}_onCreateLevel(){}_pruneTiles(){if(!this._map)return;let e=this._map.getZoom();if(e>this.options.maxZoom||e<this.options.minZoom)this._removeAllTiles();else{for(let e of Object.values(this._tiles))e.retain=e.current;for(let e of Object.values(this._tiles))if(e.current&&!e.active){let t=e.coords;this._retainParent(t.x,t.y,t.z,t.z-5)||this._retainChildren(t.x,t.y,t.z,t.z+2)}for(let[e,t]of Object.entries(this._tiles))t.retain||this._removeTile(e)}}_removeTilesAtZoom(e){for(let[t,n]of Object.entries(this._tiles))n.coords.z===e&&this._removeTile(t)}_removeAllTiles(){for(let e of Object.keys(this._tiles))this._removeTile(e)}_invalidateAll(e){let t=this._map;if(!(e?.zoom!==void 0&&e.zoom!==t.getZoom()&&t.getBounds().contains(e.center))){for(let e of Object.keys(this._levels))this._levels[e].el.remove(),this._onRemoveLevel(Number(e)),delete this._levels[e];this._removeAllTiles(),this._tileZoom=void 0}}_retainParent(e,t,n,r){for(n--;n>=r;n--)if(e=Math.floor(e/2),t=Math.floor(t/2),this._retain(e,t,n))return!0;return!1}_retainChildren(e,t,n,r){for(let i=2*e;i<2*e+2;i++)for(let e=2*t;e<2*t+2;e++)!this._retain(i,e,n+1)&&n+1<r&&this._retainChildren(i,e,n+1,r)}_retain(e,t,n){let r=this._tiles[this._tileCoordsToKey({x:e,y:t,z:n})];return r?.loaded&&(r.retain=!0),r?.active}_resetView(e){let t=e&&(e.pinch||e.flyTo||e.continuous);this._setView(this._map.getCenter(),this._map.getZoom(),t,t)}_animateZoom(e){this._setView(e.center,e.zoom,!0,e.noUpdate)}_clampZoom(e){let t=this.options;return t.minNativeZoom!==void 0&&e<t.minNativeZoom?t.minNativeZoom:t.maxNativeZoom!==void 0&&t.maxNativeZoom<e?t.maxNativeZoom:e}_setView(e,t,n,r){let i=Math.round(t);i=this.options.maxZoom!==void 0&&i>this.options.maxZoom||this.options.minZoom!==void 0&&i<this.options.minZoom?void 0:this._clampZoom(i);let a=this.options.updateWhenZooming&&i!==this._tileZoom;(!r||a)&&(this._tileZoom=i,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),i!==void 0&&this._update(e),n||this._pruneTiles(),this._noPrune=!!n),this._setZoomTransforms(e,t)}_setZoomTransforms(e,t){for(let n of Object.values(this._levels))this._setZoomTransform(n,e,t)}_setZoomTransform(e,t,n){let r=this._map.getZoomScale(n,e.zoom),i=e.origin.multiplyBy(r).subtract(this._map._getNewPixelOrigin(t,n)).round();k(e.el,i,r)}_resetGrid(){let e=this._map,t=e.options.crs,n=this._tileSize=this.getTileSize(),r=this._tileZoom,i=this._map.getPixelWorldBounds(this._tileZoom);i&&(this._globalTileRange=this._pxBoundsToTileRange(i)),this._wrapX=t.wrapLng&&!this.options.noWrap&&[Math.floor(e.project([0,t.wrapLng[0]],r).x/n.x),Math.ceil(e.project([0,t.wrapLng[1]],r).x/n.x)],this._wrapY=t.wrapLat&&!this.options.noWrap&&[Math.floor(e.project([t.wrapLat[0],0],r).y/n.y),Math.ceil(e.project([t.wrapLat[1],0],r).y/n.y)]}_onMoveEnd(){this._map&&!this._map._animatingZoom&&this._update()}_onWorldCopyJump({worlds:e}){if(!this._wrapX)return;let t=this.getTileSize(),n={};for(let r of Object.values(this._tiles)){let{coords:i,el:a}=r,o=e*this._map.getPixelWorldBounds(i.z).getSize().x;o%t.x===0&&(i.x-=o/t.x,A(a,j(a).subtract([o,0]),!0)),n[this._tileCoordsToKey(i)]=r}this._tiles=n}_getTiledPixelBounds(e){let t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t.getSize().divideBy(r*2);return new F(i.subtract(a),i.add(a))}_update(e){let t=this._map;if(!t)return;let n=this._clampZoom(t.getZoom());if(e===void 0&&(e=t.getCenter()),this._tileZoom===void 0)return;let r=this._getTiledPixelBounds(e),i=this._pxBoundsToTileRange(r),a=i.getCenter(),o=[],s=this.options.keepBuffer,c=new F(i.getBottomLeft().subtract([s,-s]),i.getTopRight().add([s,-s]));if(!(isFinite(i.min.x)&&isFinite(i.min.y)&&isFinite(i.max.x)&&isFinite(i.max.y)))throw Error(`Attempted to load an infinite number of tiles`);for(let e of Object.values(this._tiles)){let t=e.coords;(t.z!==this._tileZoom||!c.contains(new g(t.x,t.y)))&&(e.current=!1)}if(Math.abs(n-this._tileZoom)>1)this._setView(e,n);else{for(let e=i.min.y;e<=i.max.y;e++)for(let t=i.min.x;t<=i.max.x;t++){let n=new g(t,e);if(n.z=this._tileZoom,!this._isValidTile(n))continue;let r=this._tiles[this._tileCoordsToKey(n)];r?r.current=!0:o.push(n)}if(o.sort((e,t)=>e.distanceTo(a)-t.distanceTo(a)),o.length!==0){this._loading||(this._loading=!0,this.fire(`loading`),this._map._onLayerLoading());let e=document.createDocumentFragment();for(let t of o)this._addTile(t,e);this._level.el.appendChild(e)}}}_isValidTile(e){let t=this._map.options.crs;if(!t.infinite){let n=this._globalTileRange;if(!t.wrapLng&&(e.x<n.min.x||e.x>n.max.x)||!t.wrapLat&&(e.y<n.min.y||e.y>n.max.y))return!1}if(!this.options.bounds)return!0;let n=this._tileCoordsToBounds(e);return R.from(this.options.bounds).overlaps(n)}_tileCoordsToNwSe(e){let t=this._map,n=this.getTileSize(),r=e.scaleBy(n),i=r.add(n);return[t.unproject(r,e.z),t.unproject(i,e.z)]}_tileCoordsToBounds(e){let t=this._tileCoordsToNwSe(e),n=new R(t[0],t[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n}_tileCoordsToKey(e){return`${e.x}:${e.y}:${e.z}`}_removeTile(e){let t=this._tiles[e];t&&(t.el.remove(),delete this._tiles[e],this.fire(`tileunload`,{tile:t.el,coords:t.coords}))}_initTile(e){e.classList.add(`maplair-tile`);let t=this.getTileSize();e.style.width=`${t.x}px`,e.style.height=`${t.y}px`,this.options.placeholder&&(e.style.background=this.options.placeholder)}_addTile(e,t){let n=this._getTilePos(e),r=this._tileCoordsToKey(e),i=this.createTile(this._wrapCoords(e),this._tileReady.bind(this,e));this._initTile(i),this.createTile.length<2&&requestAnimationFrame(this._tileReady.bind(this,e,null,i)),A(i,n,!0),this._tiles[r]={el:i,coords:e,current:!0},t.appendChild(i),this.fire(`tileloadstart`,{tile:i,coords:e})}_tileReady(e,t,n){t&&this.fire(`tileerror`,{error:t,tile:n,coords:e});let r=this._tileCoordsToKey(e);n=this._tiles[r],n&&(this.options.placeholder&&(n.el.style.background=``),!this._map._fadeAnimated||this.options.placeholder?(n.active=!0,this._pruneTiles()):n.loaded||(n.el.classList.add(`maplair-tile-fading`),n.el.animate({opacity:[0,1]},200).onfinish=this._onTileFaded.bind(this,n)),n.loaded=!0,t||(n.el.classList.add(`maplair-tile-loaded`),this.fire(`tileload`,{tile:n.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire(`load`),this._map._scheduleIdleCheck(),this._map._fadeAnimated?this._pruneTimeout=setTimeout(this._pruneTiles.bind(this),250):requestAnimationFrame(this._pruneTiles.bind(this))))}_onTileFaded(e){e.el.classList.remove(`maplair-tile-fading`),this._tiles[this._tileCoordsToKey(e.coords)]===e&&(e.active=!0,this._onOpaqueTile(e),!(this._noPrune||this._fadePruneFrame)&&(this._fadePruneFrame=requestAnimationFrame(()=>{this._fadePruneFrame=0,this._noPrune||this._pruneTiles()})))}_getTilePos(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)}_wrapCoords(e){let t=new g(this._wrapX?s(e.x,this._wrapX):e.x,this._wrapY?s(e.y,this._wrapY):e.y);return t.z=e.z,t}_pxBoundsToTileRange(e){let t=this.getTileSize();return new F(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))}_noTilesToLoad(){return Object.values(this._tiles).every(e=>e.loaded)}};const Vn=[`tile.openstreetmap.org`,`tile.osm.org`],Hn=/^(https?:)?\/\/([^/?#:]*)/i,Un=/^http:/i;function Wn(e){let t=Hn.exec(e)?.[2]??``;return Vn.some(e=>t===e||t.endsWith(`.${e}`))}const Gn=e=>Wn(e)?e.replace(Un,`https:`):e;var Kn=class e extends Bn{static defaultOptions={minZoom:0,maxZoom:18,subdomains:`abc`,errorTileUrl:``,zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:`strict-origin-when-cross-origin`,fetchOptions:null};constructor(t,n){super(n),n=f(this,n),Wn(t)&&n.attribution===null&&(n.attribution=`© <a href="https://www.openstreetmap.org/copyright">${N.translate(`OpenStreetMap contributors`)}</a>`),this._url=Gn(t);let{tileSize:r,zoomOffset:i,minZoom:a,maxZoom:o,minNativeZoom:s,maxNativeZoom:c}=this.options;this._nonRetinaOptions={tileSize:r,zoomOffset:i,minZoom:a,maxZoom:o,minNativeZoom:s,maxNativeZoom:c},this._applyRetina(),typeof this.options.subdomains==`string`&&(this.options.subdomains=this.options.subdomains.split(``)),this.callInitHooks(e)}_applyRetina(){Object.assign(this.options,this._nonRetinaOptions),this._retina=window.devicePixelRatio>1,this.options.detectRetina&&this._retina&&this.options.maxZoom>0?(this.options.tileSize=Math.floor(this.options.tileSize/2),this.options.zoomReverse?(this.options.zoomOffset--,this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom+1)):(this.options.zoomOffset++,this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom-1),this.options.maxNativeZoom!==void 0&&(this.options.maxNativeZoom=Math.max(0,this.options.maxNativeZoom-1)),this.options.minNativeZoom!==void 0&&(this.options.minNativeZoom=Math.max(0,this.options.minNativeZoom-1))),this.options.minZoom=Math.max(0,this.options.minZoom)):this.options.zoomReverse?this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom):this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom)}getEvents(){let e=super.getEvents();return e.pixelratiochange=this._onPixelRatioChange,e}_onPixelRatioChange(){if(window.devicePixelRatio>1===this._retina)return;let e=this._map;this._applyRetina(),this.options.detectRetina?(e._removeZoomLimit(this),e._addZoomLimit(this),this._invalidateAll(),this._resetView()):this._url.includes(`{r}`)&&this.redraw()}setUrl(e,t){return e=Gn(e),this._url===e&&t===void 0&&(t=!0),this._url=e,t||(this._keepCurrentTiles(),this.redraw()),this}createTile(e,t){let n=document.createElement(`img`);y(n,`load`,this._tileOnLoad.bind(this,t,n)),y(n,`error`,this._tileOnError.bind(this,t,n)),(this.options.crossOrigin||this.options.crossOrigin===``)&&(n.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),typeof this.options.referrerPolicy==`string`&&(n.referrerPolicy=this.options.referrerPolicy),n.alt=``;let r=this.getTileUrl(e);return this.options.fetchOptions?this._fetchTile(n,r,t):n.src=r,n}_fetchTile(e,t,n){let r=new AbortController,i={signal:r.signal,...this.options.fetchOptions};typeof this.options.referrerPolicy==`string`&&(i.referrerPolicy??=this.options.referrerPolicy),this._tileFetches??=/* @__PURE__ */ new Map,this._tileFetches.set(e,r),fetch(t,i).then(e=>{if(!e.ok)throw Error(`Failed to load the tile ${t}: HTTP ${e.status}`);return e.blob()}).then(t=>{e.src=URL.createObjectURL(t)}).catch(t=>{r.signal.aborted||this._tileOnError(n,e,t)}).finally(()=>this._tileFetches.delete(e))}_abortTileFetch(e){let t=this._tileFetches?.get(e);return t?(t.abort(),this._tileFetches.delete(e),!0):!1}getTileUrl(e){let t=Object.create(this.options);if(Object.assign(t,{r:window.devicePixelRatio>1?`@2x`:``,s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()}),this._map&&!this._map.options.crs.infinite){let n=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=n),t[`-y`]=n}return m(this._url,t)}_tileOnLoad(e,t){t.src.startsWith(`blob:`)&&URL.revokeObjectURL(t.src),e(null,t)}_tileOnError(e,t,n){let r=this.options.errorTileUrl;r&&t.getAttribute(`src`)!==r&&(t.src=r),e(n,t)}_getZoomForUrl(){let e=this._tileZoom,t=this.options.maxZoom,n=this.options.zoomReverse,r=this.options.zoomOffset;return n&&(e=t-e),e+r}_getSubdomain(e){let t=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]}_abortLoading(){let e,t;for(e of Object.keys(this._tiles))if(this._tiles[e].coords.z!==this._tileZoom&&(t=this._tiles[e].el,this._abortTileFetch(t)||!t.complete)){t.setAttribute(`src`,``);let n=this._tiles[e].coords;t.remove(),delete this._tiles[e],this.fire(`tileabort`,{tile:t,coords:n})}}_removeTile(e){let t=this._tiles[e];if(t)return this._abortTileFetch(t.el),t.el.setAttribute(`src`,``),super._removeTile(e)}_tileReady(e,t,n){if(!(!this._map||n&&n.getAttribute(`src`)===``))return super._tileReady(e,t,n)}_clampZoom(e){return Math.round(super._clampZoom(e))}},qn=class e extends Kn{static defaultWmsParams={service:`WMS`,request:`GetMap`,layers:``,styles:``,format:`image/jpeg`,transparent:!1,version:`1.1.1`};static defaultOptions={crs:null,uppercase:!1};constructor(t,n){super(t,n);let r={...e.defaultWmsParams};for(let[t,i]of Object.entries(n))t in e.defaultOptions||(r[t]=i);this.wmsParams=r,this._updateWmsSize(),this.callInitHooks(e)}_updateWmsSize(){let e=this.options.detectRetina&&window.devicePixelRatio>1?2:1,t=this.getTileSize();this.wmsParams.width=t.x*e,this.wmsParams.height=t.y*e}_applyRetina(){super._applyRetina(),this.wmsParams&&this._updateWmsSize()}onAdd(e){this._updateCrs(),super.onAdd(e)}_updateCrs(){this._crs=this.options.crs??this._map.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);let e=this._wmsVersion>=1.3?`crs`:`srs`;this.wmsParams[e]=this._crs.code}getEvents(){let e=super.getEvents();return e.crschange=this._updateCrs,e}getTileUrl(e){let t=this._tileCoordsToNwSe(e),n=this._crs,r=new F(n.project(t[0]),n.project(t[1])),i=r.min,a=r.max,o=(this._wmsVersion>=1.3&&this._crs===Dn?[i.y,i.x,a.y,a.x]:[i.x,i.y,a.x,a.y]).join(`,`),s=new URL(super.getTileUrl(e),document.baseURI);for(let[e,t]of Object.entries({...this.wmsParams,bbox:o}))s.searchParams.append(this.options.uppercase?e.toUpperCase():e,`${t}`);return s.toString()}getLegendUrl(e){let{version:t,format:n,layers:r,styles:i}=this.wmsParams,a=new URL(this._url,document.baseURI);for(let[o,s]of Object.entries({service:`WMS`,request:`GetLegendGraphic`,version:t,format:n,layer:r.split(`,`)[0],style:i?.split(`,`)[0]||void 0,sld_version:parseFloat(t)>=1.3?`1.1.0`:void 0,...e}))s!==void 0&&a.searchParams.set(this.options.uppercase?o.toUpperCase():o,s);return a.toString()}setParams(e,t){return Object.assign(this.wmsParams,e),t||(this._keepCurrentTiles(),this.redraw()),this}};const Jn=/[, ]+/;var $=class e extends Ve{static defaultOptions={tolerance:0};constructor(...t){super(...t),this.callInitHooks(e)}getEvents(){let e=super.getEvents();return e.viewprereset=this._onViewPreReset,e.pixelratiochange=this._onPixelRatioChange,e}_onPixelRatioChange(){this._resizeContainer(),this._update()}_onViewPreReset(){this._postponeUpdatePaths=!0}onAdd(e){super.onAdd(e),this._draw()}onRemove(){super.onRemove(),clearTimeout(this._pointerHoverThrottleTimeout)}_initContainer(){let e=this._container=document.createElement(`canvas`);y(e,`pointermove`,this._onPointerMove,this),y(e,`click dblclick pointerdown pointerup contextmenu`,this._onClick,this),y(e,`pointerout`,this._handlePointerOut,this),e._maplair_disable_events=!0,this._ctx=e.getContext(`2d`)}_destroyContainer(){cancelAnimationFrame(this._redrawRequest),this._redrawRequest=null,delete this._ctx,super._destroyContainer()}_resizeContainer(){let e=super._resizeContainer(),t=this._ctxScale=window.devicePixelRatio;this._container.width=t*e.x,this._container.height=t*e.y}_updatePaths(){if(!this._postponeUpdatePaths){this._redrawBounds=null;for(let e of Object.values(this._layers))e._update();this._redraw()}}_update(){if(this._map._animatingZoom&&this._bounds)return;let e=this._bounds,t=this._ctxScale;this._ctx.setTransform(t,0,0,t,-e.min.x*t,-e.min.y*t),this.fire(`update`)}_reset(){super._reset(),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())}_initPath(e){this._updateDashArray(e),this._layers[a(e)]=e;let t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst??=this._drawLast}_addPath(e){this._requestRedraw(e)}_removePath(e){let t=e._order,n=t.next,r=t.prev;n?n.prev=r:this._drawLast=r,r?r.next=n:this._drawFirst=n,delete e._order,delete this._layers[a(e)],this._requestRedraw(e)}_updatePath(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)}_updateStyle(e){this._updateDashArray(e),this._requestRedraw(e)}_updateDashArray(e){if(typeof e.options.dashArray==`string`){let t=e.options.dashArray.split(Jn);e.options._dashArray=t.map(e=>Number(e)).filter(e=>!isNaN(e))}else e.options._dashArray=e.options.dashArray}_requestRedraw(e){this._map&&(this._extendRedrawBounds(e),this._redrawRequest??=requestAnimationFrame(this._redraw.bind(this)))}_extendRedrawBounds(e){if(e._pxBounds){let t=(e.options.weight??0)+1;this._redrawBounds??=new F,this._redrawBounds.extend(e._pxBounds.min.subtract([t,t])),this._redrawBounds.extend(e._pxBounds.max.add([t,t]))}}_redraw(){cancelAnimationFrame(this._redrawRequest),this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null}_clear(){let e=this._redrawBounds;if(e){let t=e.getSize();this._ctx.clearRect(e.min.x,e.min.y,t.x,t.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()}_draw(){let e,t=this._redrawBounds;if(this._ctx.save(),t){let e=t.getSize();this._ctx.beginPath(),this._ctx.rect(t.min.x,t.min.y,e.x,e.y),this._ctx.clip()}this._drawing=!0;for(let n=this._drawFirst;n;n=n.next)e=n.layer,(!t||e._pxBounds&&e._pxBounds.intersects(t))&&e._updatePath();this._drawing=!1,this._ctx.restore()}_updatePoly(e,t){if(!this._drawing)return;let n=e._parts,r=this._ctx;n.length&&(r.beginPath(),n.forEach(e=>{e.forEach((e,t)=>{r[t?`lineTo`:`moveTo`](e.x,e.y)}),t&&r.closePath()}),this._fillStroke(r,e))}_updateCircle(e){if(!this._drawing||e._empty())return;let t=e._point,n=this._ctx,r=Math.max(Math.round(e._pxRadius),1),i=(Math.max(Math.round(e._pxRadiusY),1)||r)/r;i!==1&&(n.save(),n.scale(1,i)),n.beginPath(),n.arc(t.x,t.y/i,r,0,Math.PI*2,!1),i!==1&&n.restore(),this._fillStroke(n,e)}_fillStroke(e,t){let n=t.options;n.fill&&(e.globalAlpha=n.fillOpacity,e.fillStyle=n.fillColor??n.color,e.fill(n.fillRule||`evenodd`)),n.stroke&&n.weight!==0&&(e.lineDashOffset=Number(n.dashOffset??0),e.setLineDash(n._dashArray??[]),e.globalAlpha=n.opacity,e.lineWidth=n.weight,e.strokeStyle=n.color,e.lineCap=n.lineCap,e.lineJoin=n.lineJoin,e.stroke())}_updateInteractive(){}_onClick(e){let t=this._map.pointerEventToLayerPoint(e),n,r;for(let i=this._drawFirst;i;i=i.next)n=i.layer,n.options.interactive&&n._containsPoint(t)&&(e.type!==`click`&&e.type!==`preclick`||!this._map._draggableMoved(n))&&(r=n);this._fireEvent(r?[r]:!1,e)}_onPointerMove(e){if(!this._map||this._map.dragging.moving()||this._map._animatingZoom)return;let t=this._map.pointerEventToLayerPoint(e);this._handlePointerHover(e,t)}_handlePointerOut(e){let t=this._hoveredLayer;t&&(this._container.classList.remove(`maplair-interactive`),this._fireEvent([t],e,`pointerout`),this._hoveredLayer=null,this._pointerHoverThrottled=!1)}_handlePointerHover(e,t){if(this._pointerHoverThrottled)return;let n,r;for(let e=this._drawFirst;e;e=e.next)n=e.layer,n.options.interactive&&n._containsPoint(t)&&(r=n);r!==this._hoveredLayer&&(this._handlePointerOut(e),r&&(this._container.classList.add(`maplair-interactive`),this._fireEvent([r],e,`pointerover`),this._hoveredLayer=r)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,e),this._pointerHoverThrottled=!0,this._pointerHoverThrottleTimeout=setTimeout((()=>{this._pointerHoverThrottled=!1}),32)}_fireEvent(e,t,n){this._map._fireDOMEvent(t,n||t.type,e)}_bringToFront(e){let t=e._order;if(!t)return;let n=t.next,r=t.prev;if(n)n.prev=r;else return;r?r.next=n:n&&(this._drawFirst=n),t.prev=this._drawLast,this._drawLast.next=t,t.next=null,this._drawLast=t,this._requestRedraw(e)}_bringToBack(e){let t=e._order;if(!t)return;let n=t.next,r=t.prev;if(r)r.next=n;else return;n?n.prev=r:r&&(this._drawLast=r),t.prev=null,t.next=this._drawFirst,this._drawFirst.prev=t,this._drawFirst=t,this._requestRedraw(e)}},Yn=class e extends W{constructor(t,n){if(super(t,n),isNaN(this.options.radius))throw Error(`Circle radius cannot be NaN`);this.callInitHooks(e)}getBounds(){let e=[this._pxRadius,this._pxRadiusY??this._pxRadius];return new R(this._map.layerPointToLatLng(this._point.subtract(e)),this._map.layerPointToLatLng(this._point.add(e)))}_project(){let e=this._latlng.lng,t=this._latlng.lat,n=this._map,r=n.options.crs;if(r.distance===G.distance){let r=Math.PI/180,i=this._radius/G.R/r,a=n.project([t+i,e]),o=n.project([t-i,e]),s=a.add(o).divideBy(2),c=n.unproject(s).lat,l=2*Math.asin(Math.sqrt((Math.sin(i*r/2)**2-Math.sin((c-t)*r/2)**2)/(Math.cos(t*r)*Math.cos(c*r))))/r;(isNaN(l)||l===0)&&(l=i/Math.cos(Math.PI/180*t)),this._point=s.subtract(n.getPixelOrigin()),this._pxRadius=isNaN(l)?0:s.x-n.project([c,e-l]).x,this._pxRadiusY=s.y-a.y}else{let e=r.unproject(r.project(this._latlng).subtract([this._radius,0]));this._point=n.latLngToLayerPoint(this._latlng),this._pxRadius=Math.abs(this._point.x-n.latLngToLayerPoint(e).x)}this._updateBounds()}},Xn=class e extends $t{constructor(t,n){super(e._boundsToLatLngs(t),n),this.callInitHooks(e)}setBounds(t){return this.setLatLngs(e._boundsToLatLngs(t))}static _boundsToLatLngs(e){return e=new R(e),[e.getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}};const Zn=/^#/,Qn=/^\?/,$n=[`zoom`,`lat`,`lng`,`bearing`,`layers`];function er(e){let t=(e??``).split(`&`).find(e=>e.startsWith(`layers=`))?.slice(7);return t===void 0?void 0:t.split(`,`).filter(Boolean).map(decodeURIComponent)}function tr(e,t){let n=e.getCenter(),r=Math.max(0,Math.ceil(Math.log10(256*2**e.getZoom()/360))),i=t&&Object.keys(t).filter(n=>e.hasLayer(t[n]));return{zoom:Math.round(e.getZoom()*100)/100,lat:n.lat.toFixed(r),lng:n.lng.toFixed(r),bearing:Math.round((e.getBearing?.()??0)*10)/10,layers:i?`layers=${i.map(encodeURIComponent).join(`,`)}`:``}}var nr=class e{constructor(e,t){this.options={format:`zoom/lat/lng`,layers:void 0,mode:`hash`,...t},this._map=e,this._onHashChange=this._onHashChange.bind(this),this._event=this.options.mode===`query`?`popstate`:`hashchange`,window.addEventListener(this._event,this._onHashChange),e.on(`moveend layeradd layerremove`,this._onMoveEnd,this),!this._onHashChange()&&e._loaded&&this._onMoveEnd()}remove(){return window.removeEventListener(this._event,this._onHashChange),this._map.off(`moveend layeradd layerremove`,this._onMoveEnd,this),this}_onHashChange(){let t=this.options.mode===`query`?e.parseQuery(location.search):e.parse(location.hash);if(!t)return!1;if(t.hash===this._hash)return!0;this._hash=t.hash,this._restoring=!0;let n=this._map;if(n.setView(t.center,t.zoom??n.getZoom(),{animate:!1}),n.setBearing&&(t.bearing!==void 0||n.getBearing())&&n.setBearing(t.bearing??0),t.layers&&this.options.layers)for(let[e,r]of Object.entries(this.options.layers))t.layers.includes(e)?n.addLayer(r):n.hasLayer(r)&&n.removeLayer(r);return this._restoring=!1,this._onMoveEnd(),!0}_onMoveEnd(){if(this._restoring||!this._map._loaded)return;let t=this.options.mode===`query`,n=t?e.formatQuery(this._map,this.options.layers,location.search):e.format(this._map,this.options.format,this.options.layers);n!==this._hash&&n!==(t?location.search:location.hash)&&(this._hash=n,history.replaceState(history.state,``,t?n+location.hash:n))}static parse(e){let[t,n]=e.replace(Zn,``).split(`?`),r=new URLSearchParams(n),i=er(n),a,o,s,c;if(t.startsWith(`geo:`)){let e=B.parse(t);if(!e)return;({lat:o,lng:s}=e),a=r.has(`z`)?Number(r.get(`z`)):void 0,c=r.has(`bearing`)?Number(r.get(`bearing`)):void 0}else{let e=t.split(`/`);if(e.length!==3&&e.length!==4||e.includes(``))return;[a,o,s,c]=e.map(Number)}if(![a,o,s,c].some(Number.isNaN))return{zoom:a,center:new B(o,s),bearing:c,layers:i,hash:`#${e.replace(Zn,``)}`}}static format(e,t=`zoom/lat/lng`,n=void 0){let{zoom:r,lat:i,lng:a,bearing:o,layers:s}=tr(e,n);return t===`geo`?`#geo:${i},${a}?z=${r}${o?`&bearing=${o}`:``}${s?`&${s}`:``}`:`#${r}/${i}/${a}${o?`/${o}`:``}${s?`?${s}`:``}`}static parseQuery(e){let t=e.replace(Qn,``),n=new URLSearchParams(t);if(!n.has(`lat`)||!n.has(`lng`))return;let[r,i]=[`zoom`,`bearing`].map(e=>n.has(e)?Number(n.get(e)):void 0),a=Number(n.get(`lat`)),o=Number(n.get(`lng`));if(![r,a,o,i].some(Number.isNaN))return{zoom:r,center:new B(a,o),bearing:i,layers:er(t),hash:e}}static formatQuery(e,t=void 0,n=``){let r=tr(e,t),i=new URLSearchParams(n);for(let e of $n)i.delete(e);return`?${[i.toString(),`zoom=${r.zoom}&lat=${r.lat}&lng=${r.lng}`,r.bearing?`bearing=${r.bearing}`:``,r.layers].filter(Boolean).join(`&`)}`}},rr=class{constructor(e,t){this.options={bearing:!0,oneWay:!1,fit:`center`,...t},this._maps=[...e],this._listeners=/* @__PURE__ */ new Map,this._animating=/* @__PURE__ */ new Set,this._ended=/* @__PURE__ */ new Set;for(let e of this._maps){let t={movestart:()=>this._onMoveStart(e),zoomstart:()=>this._onZoomStart(e),move:()=>this._onMove(e),zoomanim:t=>this._onZoomAnim(e,t),moveend:()=>this._onMoveEnd(e),rotate:()=>this._onRotate(e)};e.on(t),this._listeners.set(e,t)}this._maps[0]?._loaded&&this._syncAll(this._maps[0])}remove(){for(let[e,t]of this._listeners)e.off(t);return this._listeners.clear(),this._maps=[],this}_followers(e){return this._maps.filter(t=>t!==e&&t._loaded)}_canLead(e){return!this.options.oneWay||e===this._maps[0]}_zoomFor(e,t,n=t.getZoom(),r=!0){let i=e.getSize(),a=t.getSize();if(this.options.fit!==`bounds`||!i.x||!i.y||!a.x||!a.y)return n;let o=n+Math.log2(Math.min(i.x/a.x,i.y/a.y)),s=e.options.zoomSnap;return r&&s&&(o=Math.floor(o/s+1e-6)*s),Math.max(e.getMinZoom(),Math.min(e.getMaxZoom(),o))}_onMoveStart(e){if(!this._leader&&this._canLead(e)){this._leader=e,this._leaderEnded=!1,this._ended.clear();for(let t of this._followers(e))t._stop(),t._syncStartZoom=t.getZoom(),t.fire(`movestart`)}}_onZoomStart(e){if(this._onMoveStart(e),this._leader===e)for(let t of this._followers(e))t.fire(`zoomstart`)}_onMove(e){if(!this._leader)this._canLead(e)&&this._syncAll(e);else if(this._leader===e)for(let t of this._followers(e))this._animating.has(t)||this._follow(t,e,!0)}_onZoomAnim(e,t){if(this._leader===e)for(let n of this._followers(e))n._zoomAnimated&&(this._animating.add(n),n._animateZoom(t.center,this._zoomFor(n,e,t.zoom),!0,t.noUpdate))}_onMoveEnd(e){if(this._leader!==e)this._animating.delete(e)&&(this._ended.add(e),this._leaderEnded&&!this._animating.size&&(this._leader=null));else{for(let t of this._followers(e))!this._animating.has(t)&&!this._ended.has(t)&&(this._follow(t,e,!1),t._moveEnd(t.getZoom()!==t._syncStartZoom));this._leaderEnded=!0,this._animating.size||(this._leader=null)}}_onRotate(e){if(this.options.bearing&&this._canLead(e))for(let t of this._followers(e))t._rotate&&t.getBearing()!==e.getBearing()&&t._rotate(e.getBearing())}_follow(e,t,n){let r=t.getCenter(),i=this._zoomFor(e,t,t.getZoom(),!n);if(i===e.getZoom()){let t=e.project(r,i).subtract(e.project(e.getCenter(),i)).round();(t.x||t.y)&&(e._rawPanBy(t),e.fire(`move`))}else e._move(r,i,n?{pinch:!0,round:!1}:void 0)}_syncAll(e){for(let t of this._maps.filter(t=>t!==e)){this.options.bearing&&t._rotate&&t.getBearing()!==e.getBearing()&&t._rotate(e.getBearing());let n=this._zoomFor(t,e);(!t._loaded||t.getZoom()!==n||t.latLngToContainerPoint(e.getCenter()).distanceTo(t.getSize()._divideBy(2))>=1)&&(this._leader=e,t.setView(e.getCenter(),n,{animate:!1}),this._leader=null)}}};function ir(e){return e instanceof W&&!!e.options.displace}var ar=class e extends Y{static defaultOptions={gap:2,iterations:80,maxDistance:1/0};constructor(...t){super(...t),f(this,this._map.options.displace),this._trueLatLngs=/* @__PURE__ */ new WeakMap,this._displacedPositions=/* @__PURE__ */ new Map,this.callInitHooks(e)}addHooks(){this._map.on(`zoomend`,this.schedule,this),this._map.on(`layeradd`,this._onLayerAdd,this),this._map.on(`layerremove`,this._onLayerRemove,this),this._map.eachLayer(e=>this._track(e)),this.schedule()}removeHooks(){this._map.off(`zoomend`,this.schedule,this),this._map.off(`layeradd`,this._onLayerAdd,this),this._map.off(`layerremove`,this._onLayerRemove,this),this._frame&&cancelAnimationFrame(this._frame),this._frame=void 0,this._restore()}schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=void 0,this.relayout()})}relayout(){let e=this._map,t=[];if(e.eachLayer(e=>{this._trueLatLngs.has(e)&&t.push(e)}),t.length<2)return;let n=e.getZoom(),r=this._displacedPositions.get(n);if(r||(r=/* @__PURE__ */ new Map,this._displacedPositions.set(n,r)),t.every(e=>e.options.displaceId&&r.has(e.options.displaceId))){for(let e of t)this._moveTo(e,r.get(e.options.displaceId));return}let{gap:i,iterations:a,maxDistance:o}=this.options,s=t.map(t=>e.project(this._trueLatLngs.get(t),n));or(s,2*t.reduce((e,t)=>Math.max(e,t.getRadius()),0)+i,{iterations:a,maxDisplacement:o*this._pixelsPerMeter(n)});for(let i=0;i<t.length;i++){let a=e.unproject(s[i],n);this._moveTo(t[i],a),t[i].options.displaceId&&r.set(t[i].options.displaceId,a)}}_pixelsPerMeter(e){let t=this._map,n=t.getCenter(),r=t.unproject(t.project(n,e).add(new g(100,0)),e);return 100/t.distance(n,r)}_moveTo(e,t){this._moving=!0;try{e.setLatLng(t)}finally{this._moving=!1}}_onMarkerMove(e){this._moving||(this._trueLatLngs.set(e.target,e.latlng),this._displacedPositions.clear(),this._enabled&&this._map.hasLayer(e.target)&&this.schedule())}_onLayerAdd(e){this._track(e.layer),ir(e.layer)&&this.schedule()}_onLayerRemove(e){ir(e.layer)&&this.schedule()}_track(e){ir(e)&&(this._trueLatLngs.has(e)||(this._trueLatLngs.set(e,e.getLatLng()),e.on(`move`,this._onMarkerMove,this)))}_restore(){this._map.eachLayer(e=>{let t=this._trueLatLngs.get(e);t&&this._moveTo(e,t)})}};function or(e,t,{iterations:n=ar.defaultOptions.iterations,maxDisplacement:r=1/0}={}){let i=e.length;if(i<2)return e;let a=t,o=a*a,s=a,c=new Float64Array(i),l=new Float64Array(i),u=Float64Array.from(e,e=>e.x),d=Float64Array.from(e,e=>e.y);for(let t=0;t<n;t++){c.fill(0),l.fill(0);let t=/* @__PURE__ */ new Map;for(let n=0;n<i;n++){let r=`${Math.floor(e[n].x/s)},${Math.floor(e[n].y/s)}`,i=t.get(r);i?i.push(n):t.set(r,[n])}let n=0;for(let r=0;r<i;r++){let i=Math.floor(e[r].x/s),u=Math.floor(e[r].y/s);for(let s=i-1;s<=i+1;s++)for(let i=u-1;i<=u+1;i++){let u=t.get(`${s},${i}`);if(u)for(let t of u){if(t<=r)continue;let i=e[r].x-e[t].x,s=e[r].y-e[t].y,u=i*i+s*s;if(u>=o)continue;n++;let d;if(u===0){let e=r*2.399963229728653;i=Math.cos(e),s=Math.sin(e),d=1}else d=Math.sqrt(u),i/=d,s/=d;let f=(a-d)/2;c[r]+=i*f,l[r]+=s*f,c[t]-=i*f,l[t]-=s*f}}}if(n===0)break;for(let t=0;t<i;t++){e[t].x+=c[t],e[t].y+=l[t];let n=e[t].x-u[t],i=e[t].y-d[t],a=n*n+i*i;if(a>r*r){let o=r/Math.sqrt(a);e[t].x=u[t]+n*o,e[t].y=d[t]+i*o}}}return e}const sr=n,{_setPos:cr}=Q.prototype,{_onDrag:lr}=an.prototype;Q.include({options:{rotationAngle:0,rotationOrigin:void 0,rotateWithView:!1}}),Q.include({setRotationAngle(e){return this.options.rotationAngle=e,this.update()},setRotationOrigin(e){return this.options.rotationOrigin=e,this.update()},_setPos(e){cr.call(this,e),this._rotateIcon()},_rotateIcon(){let e=this.options.rotateWithView?0:this._map?.getBearing?.()??0;this._rotateElement(this._icon,e+(this.options.rotationAngle||0),this.options.rotationOrigin),this._rotateElement(this._shadow,e)},_rotateElement(e,t,n){e&&(t%360?(e.style.transform+=` rotate(${t}deg)`,e.style.transformOrigin=n??`${-parseFloat(e.style.marginLeft)||0}px ${-parseFloat(e.style.marginTop)||0}px`):e.style.transformOrigin&&(e.style.transformOrigin=``))}}),an.include({_onDrag(e){lr.call(this,e),this._marker._rotateIcon()}});var ur=class e extends M{static defaultOptions={position:`topleft`};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-control-rotate maplair-bar`),n=this._button=D(`button`,`maplair-control-rotate-button`,t),r=N.translate(`Reset north`);return n.type=`button`,n.title=r,n.setAttribute(`aria-label`,r),n.innerHTML=`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16"><path d="M8 1 11 8H5z" fill="#d22"/><path d="M8 15 5 8h6z" fill="#999"/></svg>`,w(n),y(n,`click`,E),y(n,`click`,this._resetNorth,this),y(n,`click`,this._refocusOnMap,this),this._update(),e.on(`rotate`,this._update,this),t}onRemove(e){e.off(`rotate`,this._update,this)}_resetNorth(e){this._map._setUserEvent(e),this._map.setBearing(0,{animate:!0})}_update(){this._button.firstChild.style.transform=`rotate(${-this._map.getBearing()}deg)`}static register(t){t.mergeOptions({rotateControl:!1}),t.addInitHook(function(){this.options.rotateControl&&(this.rotateControl=new e,this.addControl(this.rotateControl))})}};function dr(e){return(Number(e)%360+360)%360}function fr(e,t){let n=t*Math.PI/180,r=Math.cos(n),i=Math.sin(n);return new g(e.x*r-e.y*i,e.x*i+e.y*r)}const pr=/* @__PURE__ */ new WeakMap,{panBy:mr}=Z.prototype,{getEvents:hr}=q.prototype,{_setPosition:gr}=J.prototype,{getEvents:_r}=Q.prototype,{_onDown:vr,_updatePosition:yr}=X.prototype,{_onPointerStart:br}=Wt.prototype,{_onDown:xr}=qt.prototype,{_pinchTo:Sr}=Gt.prototype;Z.mergeOptions({bearing:0,pinchRotate:!1}),Z.addInitHook(function(){(this.options.bearing||this.options.pinchRotate||this.options.rotateControl)&&(this._rotate(this.options.bearing),this._loaded&&this.fire(`moveend`))}),ur.register(Z),Z.include({setBearing(e,t){e=dr(e);let n=this.getBearing();if(!this._rotatePane&&!e||e===n)return this;if(this._stop(),!t?.animate||!this._loaded||this._prefersReducedMotion())return this._rotate(e),this._loaded?this.fire(`movestart`).fire(`move`).fire(`moveend`):this;let r=(e-n+540)%360-180,i=performance.now();this.fire(`movestart`);let a=()=>{let e=Math.min(1,(performance.now()-i)/250);this._rotate(n+r*(1-(1-e)**2)),this.fire(`move`),e<1?this._flyToFrame=requestAnimationFrame(a):this.fire(`moveend`)};return this._flyToFrame=requestAnimationFrame(a),this},_rotate(e){if(e=dr(e),!this._rotatePane){let e=this._rotatePane=D(`div`,`maplair-rotate-pane`);pr.set(e,this),this._container.insertBefore(e,this._mapPane),e.appendChild(this._mapPane)}e!==this.getBearing()&&(this._bearing=e,this._rotatePane.style.transform=e?`rotate(${-e}deg)`:``,this._loaded&&this.fire(`rotate`))},getBearing(){return this._bearing??0},_rotateToPane(e){return this._bearing?fr(e,this._bearing):e},_rotateToContainer(e){return this._bearing?fr(e,-this._bearing):e},_getViewSize(){let e=this.getSize();if(!this._bearing)return e;let t=this._bearing*Math.PI/180,n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return new g(e.x*n+e.y*r,e.x*r+e.y*n)},_rotateUpright(e,t){this._bearing?(e.style.transform+=` rotate(${this._bearing}deg)`,e.style.transformOrigin=t):e.style.transformOrigin&&(e.style.transformOrigin=``)},containerPointToLayerPoint(e){if(e=g.from(e),this._bearing){let t=this.getSize()._divideBy(2);e=this._rotateToPane(e.subtract(t))._add(t)}return e.subtract(this._getMapPanePos())},layerPointToContainerPoint(e){if(e=g.from(e).add(this._getMapPanePos()),this._bearing){let t=this.getSize()._divideBy(2);e=this._rotateToContainer(e.subtract(t))._add(t)}return e},getPixelBounds(e,t){let n=this._getTopLeftPoint(e,t);if(!this._bearing)return new F(n,n.add(this.getSize()));let r=n.add(this.getSize()._divideBy(2)),i=this._getViewSize()._divideBy(2);return new F(r.subtract(i),r.add(i))},panBy(e,t){return mr.call(this,this._rotateToPane(g.from(e)),t)},_tryAnimatedPan(e,t){let n=this._rotateToContainer(this._getCenterOffset(e)._trunc());return t?.animate!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)},invalidateSize(e){if(!this._loaded)return this;e={animate:!1,pan:!0,...e===!0?{animate:!0}:e};let t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;let n=this.getSize(),r=t.divideBy(2).round(),i=n.divideBy(2).round(),a=r.subtract(i);return!a.x&&!a.y?this:(e.animate&&e.pan?this.panBy(this._rotateToContainer(a)):(e.pan&&this._rawPanBy(a),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(this.fire.bind(this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:n}))},_continuousZoom(e,t,n,r){let i=this._zoom,a=n.multiplyBy(-1),o=this.layerPointToLatLng(this._getCenterLayerPoint().add(n)),s=performance.now();this._moveStart(!0,r.noMoveStart??!1);let c=()=>{let n=Math.min(1,(performance.now()-s)/250);if(n<1){let e=i+(t-i)*(1-(1-n)**2);this._move(this.unproject(this.project(o,e).add(a),e),e,{continuous:!0}),this._flyToFrame=requestAnimationFrame(c)}else this._move(e,t)._moveEnd(!0)};this._flyToFrame=requestAnimationFrame(c)}}),Bn.include({_getTiledPixelBounds(e){let t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t._getViewSize().divideBy(r*2);return new F(i.subtract(a),i.add(a))}}),Be.include({_updateTransform(e,t){let n=this._map.getZoomScale(t,this._zoom),r=this._map._getViewSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n)._add(i)._subtract(this._map._getNewPixelOrigin(e,t))._round();k(this._container,a,n)},_onMoveEnd(e){let t=this.options.padding,n=this._map._getViewSize();n.multiplyBy(1+t*2).round().equals(this._containerSize)||this._resizeContainer();let r=this._map._getCenterLayerPoint().subtract(n.multiplyBy(.5+t)).round();this._bounds=new F(r,r.add(n.multiplyBy(1+t*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._updateTransform(this._center,this._zoom),this._onSettled(e)},_resizeContainer(){let e=this.options.padding,t=this._containerSize=this._map._getViewSize().multiplyBy(1+e*2).round();return this._container.style.width=`${t.x}px`,this._container.style.height=`${t.y}px`,t}}),q.include({getEvents(){return{...hr.call(this),rotate:this._updatePosition}},_updatePosition(){if(!this._map)return;let e=this._map,t=e.latLngToLayerPoint(this._latlng),n=e._rotateToPane(new g(this._getAnchor())),r=g.from(this.options.offset),i=this._zoomAnimated||this.options.overflow||e._bearing;i||(r=r.add(t).add(n));let a=this._containerBottom=-r.y,o=this._containerLeft=-Math.round(this._containerWidth/2)+r.x;this.options.overflow?(this._container.style.top=`auto`,this._container.style.bottom=`calc(100% + ${a}px)`):this._container.style.bottom=`${a}px`,this._container.style.left=`${o}px`,i&&this._setContainerPosition(t.add(n),`${-o}px calc(100% + ${a+(this._containerMarginBottom??0)}px)`)},_setContainerPosition(e,t){if(this._containerPos=e,this.options.overflow){let t=this._map._container,n=t.getBoundingClientRect();e=this._map.layerPointToContainerPoint(e)._add(new g(n.left+t.clientLeft,n.top+t.clientTop))}A(this._container,e),this.options.overflow||this._map._rotateUpright(this._container,t)}}),jt.include({_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._map._rotateToPane(new g(this._getAnchor()));this._setContainerPosition(t.add(n),this._container.style.transformOrigin)},_adjustPan(){if(!this.options.autoPan)return;if(this._map._panAnim?.stop(),this._autopanning){this._autopanning=!1;return}let e=this._map,t=this._containerMarginBottom??(parseInt(getComputedStyle(this._container).marginBottom,10)||0),n=this._containerHeight+t,r=this._containerWidth,i=new g(this._containerLeft,-n-this._containerBottom),a=e.layerPointToContainerPoint(this._getContainerPosition())._add(i),o=g.from(this.options.autoPanPadding),s=g.from(this.options.autoPanPaddingTopLeft??o),c=g.from(this.options.autoPanPaddingBottomRight??o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}});const Cr={top:[0,-6],bottom:[0,6],left:[-6,0],right:[6,0]};J.include({_setPosition(e){gr.call(this,e);let t=this._container;if(this.options.overflow)return;if(!this._map._bearing){t.style.left=t.style.top=``;return}let n=this._containerPos.subtract(e),r=Object.keys(Cr).find(e=>t.classList.contains(`maplair-tooltip-${e}`)),i=Cr[r]??[0,0];t.style.left=`${n.x}px`,t.style.top=`${n.y}px`,this._setContainerPosition(e,`${-n.x-i[0]}px ${-n.y-i[1]}px`)}}),Q.include({getEvents(){return{..._r.call(this),rotate:this.update}}}),an.include({_adjustPan(e){let t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=j(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=new F(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){let i=new g((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(n._rotateToContainer(i),{animate:!1}),this._draggable._newPos._add(i),this._draggable._startPos._add(i),A(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e))}}}),X.include({_onDown(e){vr.call(this,e);let t=this._element.closest?.(`.maplair-rotate-pane`);this._rotatedMap=t&&pr.get(t),this._rotatedMap&&this._parentScale&&(this._parentScale=De(t.parentNode))},_updatePosition(){let e=this._rotatedMap;e?._bearing&&(this._newPos=this._startPos.add(e._rotateToPane(this._newPos.subtract(this._startPos)))),yr.call(this)}}),Ht.include({_onDragEnd(e){let t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(Date.now());let e=this._lastPos.subtract(this._positions[0]),r=(this._lastTime-this._times[0])/1e3,i=n.easeLinearity,a=e.multiplyBy(i/r),o=a.distanceTo([0,0]),s=Math.min(n.inertiaMaxSpeed,o),c=a.multiplyBy(s/o),l=t.getSize().divideBy(2),u=s/(n.inertiaDeceleration*i),d=c.multiplyBy(-u/2).round();if(t._prefersReducedMotion()&&!l.contains(d)){let e=Math.min(l.x/Math.abs(d.x),l.y/Math.abs(d.y));d=d.multiplyBy(e).round(),u*=Math.sqrt(e)}!d.x&&!d.y?t.fire(`moveend`):(d=t._limitOffset(d,t.options.maxBounds),requestAnimationFrame(()=>{t.panBy(t._rotateToContainer(d),{duration:u,easeLinearity:i,noMoveStart:!0,animate:!0})}))}}});function wr(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI}Wt.include({_onPointerStart(e){br.call(this,e);let t=v();this._zooming&&t.length===2&&(this._startAngle=wr(...t.map(e=>this._map.pointerEventToContainerPoint(e))),this._startBearing=this._map.getBearing(),this._rotating=!1)},_onPointerMove(e){let t=v();if(t.length!==2||!this._zooming)return;let n=this._map,r=n.pointerEventToContainerPoint(t[0]),i=n.pointerEventToContainerPoint(t[1]),a=r.distanceTo(i)/this._startDist;if(this._zoom=n.getScaleZoom(a,this._startZoom),n.options.pinchRotate){let e=(wr(r,i)-this._startAngle+540)%360-180;!this._rotating&&Math.abs(e)>15&&(this._rotating=!0,this._startAngle+=Math.sign(e)*15,e-=Math.sign(e)*15),this._rotating&&n._rotate(this._startBearing-e)}if(!n.options.bounceAtZoomLimits&&(this._zoom<n.getMinZoom()&&a<1||this._zoom>n.getMaxZoom()&&a>1)&&(this._zoom=n._limitZoom(this._zoom)),n.options.pinchZoom===`center`){if(this._center=this._startLatLng,a===1&&!this._rotating)return}else{let e=n._rotateToPane(r._add(i)._divideBy(2)._subtract(this._centerPoint));if(a===1&&e.x===0&&e.y===0&&!this._rotating)return;this._center=n.unproject(n.project(this._pinchStartLatLng,this._zoom).subtract(e),this._zoom)}this._moved||=(n._setUserEvent(e),n._moveStart(!0,!1),!0),cancelAnimationFrame(this._animRequest);let o=n._move.bind(n,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=requestAnimationFrame(o.bind(this)),e.preventDefault()}}),qt.include({_onDown(e){xr.call(this,e),this._zooming&&this._aroundOffset&&(this._aroundOffset=this._map._rotateToPane(this._aroundOffset))}}),Gt.include({_pinchTo(e,t,n){Sr.call(this,e,t,n),this._pinch&&!this._pinch.rotated&&(this._pinch.offset=this._map._rotateToPane(this._pinch.offset),this._pinch.rotated=!0)},_panBy(e){E(e);let t=this._map;if(t._animatingZoom)return;let n=e.deltaMode===1?20:e.deltaMode===2?60:1,r=new g(e.deltaX*n,e.deltaY*n);e.shiftKey&&!e.deltaX&&(r=new g(r.y,0)),r=t._rotateToPane(r),t.options.maxBounds&&(r=t._limitOffset(r,t.options.maxBounds)),this._panning||(t._stop(),this._panning=!0,t._setUserEvent(e),t.fire(`movestart`)),t._rawPanBy(r.round()),t.fire(`move`),clearTimeout(this._panTimer),this._panTimer=setTimeout(this._endPan.bind(this),150)}});const{onRemove:Tr}=Q.prototype;Q.include({moveTo(e,t){return this.moveAlong([e],t)},moveAlong(e,t={}){this.stopMoving();let n=[this._latlng,...e.map(e=>B.from(e))],r=n.slice(1).map((e,t)=>this._map?.distance(n[t],e)??n[t].distanceTo(e)),i=r.reduce((e,t)=>e+t,0),a=t.speed?i/t.speed*1e3:t.duration??1e3,o=performance.now(),s=()=>{let e=a&&!this._map?._prefersReducedMotion()?Math.min(1,(performance.now()-o)/a)*i:i,c=0,l=e;for(;c<r.length-1&&e>r[c];)e-=r[c],c++;let u=n[c],d=n[c+1];t.rotate&&!u.equals(d)&&(this.options.rotationAngle=this._heading(u,d)),this.setLatLng(this._interpolate(u,d,r[c]?Math.min(1,e/r[c]):1)),l<i?this._moveFrame=requestAnimationFrame(s):(this._moveFrame=null,this.fire(`moveend`))};return this._moveFrame=requestAnimationFrame(s),this},stopMoving(){return cancelAnimationFrame(this._moveFrame),this._moveFrame=null,this},isMoving(){return!!this._moveFrame},_interpolate(e,t,n){let r=this._map?.options.crs;if(!r)return new B(e.lat+(t.lat-e.lat)*n,e.lng+(t.lng-e.lng)*n);let i=r.projection.project(e),a=r.projection.project(t);return r.projection.unproject(i.add(a.subtract(i).multiplyBy(n)))},_heading(e,t){let n=this._map?.options.crs,r=n?n.latLngToPoint(e,0):new g(e.lng,-e.lat),i=n?n.latLngToPoint(t,0):new g(t.lng,-t.lat);return Math.atan2(i.x-r.x,r.y-i.y)*180/Math.PI-(this.options.rotateWithView?0:this._map?.getBearing?.()??0)},onRemove(e){return this.stopMoving(),Tr.call(this,e)}});const Er=/[ ,]+/,{_updateStyle:Dr}=I.prototype,{_fillStroke:Or,_destroyContainer:kr}=$.prototype;L.include({options:{dashSpeed:0},_getDashLength(){let e=this.options.dashArray,t=(Array.isArray(e)?e:String(e??``).split(Er)).map(Number).filter(e=>!Number.isNaN(e)),n=t.reduce((e,t)=>e+t,0);return t.length%2?n*2:n}}),I.include({_updateStyle(e){Dr.call(this,e);let t=e._path;if(!t)return;let n=e.options.dashSpeed,r=e.options.stroke&&n&&e._getDashLength();t.classList.toggle(`maplair-dash-animated`,!!r),r&&(t.style.setProperty(`--maplair-dash-length`,`${Math.sign(n)*r}px`),t.style.setProperty(`--maplair-dash-duration`,`${r/Math.abs(n)}s`))}}),$.include({_fillStroke(e,t){let n=this._getDashShift(t);if(!n){Or.call(this,e,t);return}let r=t.options,i=Object.hasOwn(r,`dashOffset`),a=r.dashOffset;f(t,{dashOffset:Number(a??0)-n}),Or.call(this,e,t),i?r.dashOffset=a:delete r.dashOffset},_destroyContainer(){cancelAnimationFrame(this._dashFrame),this._dashFrame=null,kr.call(this)},_getDashShift(e){let t=e.options.dashSpeed,n=t&&!this._map._prefersReducedMotion()&&e._getDashLength();return n?(this._animatedDashes??=/* @__PURE__ */ new Set,this._animatedDashes.add(e),this._dashFrame??=requestAnimationFrame(()=>{this._dashFrame=null;for(let e of this._animatedDashes)this._layers[a(e)]&&e.options.dashSpeed&&this._requestRedraw(e);this._animatedDashes.clear()}),performance.now()/1e3*t%n):0}});function Ar(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n],a=r.distanceTo(i);if(t<=a||n===e.length-1){let e=a?Math.min(1,t/a):0;return{point:new g(r.x+(i.x-r.x)*e,r.y+(i.y-r.y)*e),angle:Math.atan2(i.y-r.y,i.x-r.x)}}t-=a}return{point:e[0],angle:0}}function jr(e){let t=0;for(let n=1;n<e.length;n++)t+=e[n-1].distanceTo(e[n]);return t}const{_setPath:Mr,_updateStyle:Nr,_addPath:Pr,_removePath:Fr,_bringToFront:Ir,_bringToBack:Lr}=I.prototype,{_updatePoly:Rr,_extendRedrawBounds:zr}=$.prototype;L.include({options:{arrowheads:!1,text:null}}),Jt.include({_getArrowheadOptions(){let e=this.options.arrowheads;return e?{size:10,repeat:0,...e===!0?{}:e}:null},_getTextOptions(){let e=this.options.text;return e?{repeat:!1,center:!1,offset:0,fontSize:12,...typeof e==`string`?{content:e}:e}:null},_getDecorationPadding(){let e=this._getTextOptions();return(this._getArrowheadOptions()?.size??0)+(e?e.fontSize+Math.abs(e.offset):0)},_getArrowheads(){let{size:e,repeat:t}=this._getArrowheadOptions(),n=[];for(let r of this._rings){if(r.length<2)continue;let i=jr(r),a=[];if(t>0)for(let e=t;e<=i;e+=t)a.push(e);else a.push(i);for(let t of a){let{point:i,angle:a}=Ar(r,t),o=Math.cos(a),s=Math.sin(a),c=new g(i.x-o*e,i.y-s*e),l=e/2;n.push([i,new g(c.x-s*l,c.y+o*l),new g(c.x+s*l,c.y-o*l)])}}return n},_getTextPlacements(e){let t=this._getTextOptions(),n=[];if(!t)return n;let r=e(t.content);for(let i of this._parts){let a=jr(i);if(!r||r>a)continue;let o=t.center?(a-r)/2:0,s=t.repeat?a-r:o;for(;o<=s+1e-9;o+=r){let r=o;for(let a of t.content){let t=e(a);n.push({char:a,width:t,...Ar(i,r+t/2)}),r+=t}}}return n}}),I.include({_setPath(e,t){Mr.call(this,e,t),this._updateDecorations(e)},_updateStyle(e){Nr.call(this,e),e._rings&&this._updateDecorations(e)},_addPath(e){Pr.call(this,e),this._updateDecorations(e)},_removePath(e){Fr.call(this,e),e._arrowheads?.remove(),e._text?.remove()},_bringToFront(e){Ir.call(this,e),this._placeDecorations(e)},_bringToBack(e){Lr.call(this,e),this._placeDecorations(e)},_updateDecorations(e){let t=e._path,n=e.options,r=e._getArrowheadOptions?.(),i=e._getTextOptions?.();if(t){if(r){let t=e._arrowheads??=I.create(`path`);t.setAttribute(`class`,`maplair-path-arrowheads`),t.setAttribute(`d`,e._getArrowheads().map(([e,t,n])=>`M${e.x} ${e.y}L${t.x} ${t.y}L${n.x} ${n.y}z`).join(``)||`M0 0`),t.setAttribute(`fill`,r.color??n.color),t.setAttribute(`fill-opacity`,n.opacity)}else e._arrowheads?.remove(),e._arrowheads=null;if(i){t.id||=`maplair-path-${a(e)}`;let r=e._text??=I.create(`text`),o=r.firstChild??r.appendChild(I.create(`textPath`));if(r.setAttribute(`class`,`maplair-path-text`),r.setAttribute(`fill`,i.color??n.color),r.setAttribute(`font-size`,i.fontSize),r.setAttribute(`dy`,i.offset),o.setAttribute(`href`,`#${t.id}`),i.center?(o.setAttribute(`startOffset`,`50%`),o.setAttribute(`text-anchor`,`middle`)):(o.removeAttribute(`startOffset`),o.removeAttribute(`text-anchor`)),o.textContent=i.content,this._placeDecorations(e),i.repeat&&t.isConnected){let e=r.getComputedTextLength();o.textContent=i.content+i.content;let n=r.getComputedTextLength()-e,a=n>0?Math.floor((t.getTotalLength()-e+n)/n):1;o.textContent=Array(Math.max(1,a)).fill(i.content).join(``)}}else e._text?.remove(),e._text=null;this._placeDecorations(e)}},_placeDecorations(e){let t=[e._arrowheads,e._text].filter(Boolean);t.length&&e._path.parentNode&&e._path.after(...t)}}),$.include({_updatePoly(e,t){Rr.call(this,e,t),this._drawing&&e._parts.length&&this._drawDecorations(this._ctx,e)},_extendRedrawBounds(e){zr.call(this,e);let t=e._getDecorationPadding?.();if(t&&e._pxBounds){let n=(e.options.weight??0)+1+t;this._redrawBounds.extend(e._pxBounds.min.subtract([n,n])),this._redrawBounds.extend(e._pxBounds.max.add([n,n]))}},_drawDecorations(e,t){let n=t.options,r=t._getArrowheadOptions?.(),i=t._getTextOptions?.();if(r){e.beginPath();for(let[n,r,i]of t._getArrowheads())e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.lineTo(i.x,i.y),e.closePath();e.globalAlpha=n.opacity,e.fillStyle=r.color??n.color,e.fill()}if(i){e.globalAlpha=1,e.fillStyle=i.color??n.color,e.font=`${i.fontSize}px sans-serif`,e.textBaseline=`alphabetic`;for(let{char:n,width:r,point:a,angle:o}of t._getTextPlacements(t=>e.measureText(t).width))e.save(),e.translate(a.x,a.y),e.rotate(o),e.fillText(n,-r/2,i.offset),e.restore()}}}),kn.include({options:{url:void 0,fetchOptions:void 0,fitBounds:!1}}),kn.include({load(e,t=this.options.fetchOptions){this._loadAbort?.abort();let n=this._loadAbort=new AbortController,r=typeof e==`string`?fetch(e,{...t,signal:n.signal}).then(e=>{if(!e.ok)throw Error(`${e.status} ${e.statusText}`);return e.json()}):e;return this.fire(`loading`),Promise.resolve(r).then(e=>(n.signal.aborted||(this._loadAbort=null,this.clearLayers().addData(e),this.options.fitBounds&&this._map&&this.getBounds().isValid()&&this._map.fitBounds(this.getBounds()),this.fire(`load`,{data:e})),this),e=>{if(n.signal.aborted)return this;throw this._loadAbort=null,this.fire(`error`,{error:e}),e})}}),kn.addInitHook(function(){this.options.url&&this.load(this.options.url).catch(()=>{})});const Br=[`weight`,`radius`];function Vr(e,t){if(typeof e==`function`)return e(t);let n=Object.keys(e).map(Number).sort((e,t)=>e-t);return e[n.findLast(e=>e<=t)??n[0]]}const{beforeAdd:Hr,setStyle:Ur}=L.prototype,{setRadius:Wr}=W.prototype;L.include({getEvents(){return{zoomend:this._updateZoomStyles}},beforeAdd(e){Hr.call(this,e),this._applyZoomStyles(e.getZoom())},setStyle(e){this._takeZoomStyles(e);let t=this._map?.getZoom();if(e&&this._zoomStyles&&t!==void 0){e={...e};for(let[n,r]of Object.entries(this._zoomStyles))Object.hasOwn(e,n)&&(e[n]=Vr(r,t))}return Ur.call(this,e)},_takeZoomStyles(e){for(let t of Br){if(!e||!Object.hasOwn(e,t))continue;let n=e[t];n&&(typeof n==`function`||typeof n==`object`)?this._zoomStyles={...this._zoomStyles,[t]:n}:this._zoomStyles&&delete this._zoomStyles[t]}},_applyZoomStyles(e){if(!this._zoomStyles)return;let t={};for(let[n,r]of Object.entries(this._zoomStyles))t[n]=Vr(r,e);Ur.call(this,t),t.radius!==void 0&&this.setRadius&&Wr.call(this,t.radius)},_updateZoomStyles(){this._applyZoomStyles(this._map.getZoom())}}),W.include({setRadius(e){return this._takeZoomStyles({radius:e}),this._zoomStyles?.radius&&this._map?Wr.call(this,Vr(e,this._map.getZoom())):Wr.call(this,e)}}),L.addInitHook(function(){this._takeZoomStyles(this.options)});export{Ae as AttributionControl,Be as BlanketOverlay,F as Bounds,Bt as BoxZoomHandler,Me as ButtonBarControl,je as ButtonControl,vt as CRS,$ as Canvas,Yn as Circle,W as CircleMarker,h as Class,An as Classification,Ie as ContextMenu,M as Control,rn as DefaultIcon,ar as DisplaceHandler,In as DivIcon,q as DivOverlay,de as DomEvent,be as DomUtil,Vt as DoubleClickZoomHandler,Ht as DragHandler,X as Draggable,En as EPSG3395,St as EPSG3857,Dn as EPSG4326,Ct as EPSG900913,G as EarthCRS,Pe as Evented,K as FeatureGroup,Re as FullscreenControl,kn as GeoJSON,Bn as GridLayer,Y as Handler,nr as Hash,Mn as HeatLayer,N as I18n,nn as Icon,Nn as ImageOverlay,Ut as KeyboardHandler,B as LatLng,R as LatLngBounds,P as Layer,Et as LayerGroup,ze as LayersControl,Z as LeafletMap,Z as Map,Z as MaplairMap,mt as LegendControl,Ye as LineUtil,rr as MapSync,Q as Marker,zn as MarkerClusterGroup,en as MiniMapControl,L as Path,Wt as PinchZoomHandler,g as Point,Yt as PolyUtil,$t as Polygon,Jt as Polyline,jt as Popup,Tn as Projection,Xn as Rectangle,Ve as Renderer,ur as RotateControl,I as SVG,Fn as SVGOverlay,tn as ScaleControl,Gt as ScrollWheelZoomHandler,cn as SearchControl,ln as SideBySideControl,On as SimpleCRS,Rn as SvgIcon,qt as TapDragZoomHandler,Kt as TapHoldHandler,dn as TextControl,Kn as TileLayer,Sn as TimeControl,J as Tooltip,xt as Transformation,r as Util,Pn as VideoOverlay,qn as WMSTileLayer,Tt as ZoomControl,or as displace,sr as version};
|
|
6
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n=`4.3.0`,r=/* @__PURE__ */ t({falseFn:()=>c,formatNum:()=>l,lastId:()=>i,setOptions:()=>f,splitWords:()=>d,stamp:()=>a,template:()=>m,throttle:()=>o,wrapNum:()=>s});let i=0;function a(e){return`_maplair_id`in e||(e._maplair_id=++i),e._maplair_id}function o(e,t,n){let r,i;function a(){r=!1,i&&=(o.apply(n,i),!1)}function o(...o){r?i=o:(e.apply(n,o),setTimeout(a,t),r=!0)}return o}function s(e,t,n){let r=t[1],i=t[0],a=r-i;return e===r&&n?e:((e-i)%a+a)%a+i}function c(){return!1}function l(e,t){if(t===!1)return e;let n=10**(t===void 0?6:t);return Math.round(e*n)/n}const u=/\s+/;function d(e){return e.trim().split(u)}function f(e,t){if(!Object.hasOwn(e,`options`)){let t=ee(e.constructor)??e.options;e.options=t?Object.create(t):{}}for(let n in t)Object.hasOwn(t,n)&&(e.options[n]=t[n]);return e.options}const p=/* @__PURE__ */ new WeakMap;function ee(e){let t=e?.defaultOptions;if(t&&p.get(e)!==t){for(let t=e;t.defaultOptions;t=Object.getPrototypeOf(t))Object.hasOwn(t,`defaultOptions`)&&Object.setPrototypeOf(t.defaultOptions,Object.getPrototypeOf(t).defaultOptions??Object.prototype);p.set(e,t)}return t}const te=/\{ *([\w_ -]+) *\}/g;function m(e,t){return e.replace(te,(e,n)=>{let r=t[n];if(r===void 0)throw Error(`No value provided for variable ${e}`);return typeof r==`function`&&(r=r(t)),r})}var h=class{static include(e){for(let t=e;t&&t!==Object.prototype;t=Object.getPrototypeOf(t))for(let n of Object.getOwnPropertyNames(t))n!==`constructor`&&n!==`options`&&(this.prototype[n]=e[n]);return e.options&&this.mergeOptions(e.options),this}static mergeOptions(e){return Object.hasOwn(this,`defaultOptions`)||(this.defaultOptions=Object.create(this.defaultOptions??Object.prototype)),Object.assign(this.defaultOptions,e),this}static setDefaultOptions(e){return this.mergeOptions(e)}static addInitHook(e,...t){let n=typeof e==`function`?e:function(){this[e](...t)};return Object.hasOwn(this,`_initHooks`)||(this._initHooks=[]),this._initHooks.push(n),this}constructor(){if(this.initialize)throw Error(`${this.constructor.name}: initialize() is not called in Maplair. Rename it to constructor() and call super() at its start.`);f(this)}callInitHooks(e=this.constructor){let t=this._initHooksCalledFor;if(t&&(t===e||t.prototype instanceof e))return this;let n=[];for(let r=e;r&&r!==Function.prototype&&r!==t;r=Object.getPrototypeOf(r))n.unshift(r);this._initHooksCalledFor=e;for(let e of n)if(Object.hasOwn(e,`_initHooks`))for(let t of e._initHooks)t.call(this);return this}},g=class e{constructor(t,n,r){if(!e.validate(t,n))throw Error(`Invalid Point object: (${t}, ${n})`);let i,a;t instanceof e?(i=t.x,a=t.y):Array.isArray(t)?(i=t[0],a=t[1]):typeof t==`object`&&`x`in t&&`y`in t?(i=t.x,a=t.y):(i=t,a=n),this.x=r?Math.round(i):i,this.y=r?Math.round(a):a}static from(t,n,r){return t instanceof e&&!r?t:new e(t,n,r)}static validate(t,n){return!!(t instanceof e||Array.isArray(t)||t&&typeof t==`object`&&`x`in t&&`y`in t||(t||t===0)&&(n||n===0))}add(t){return new e(this)._add(e.from(t))}_add(e){return this.x+=e.x,this.y+=e.y,this}subtract(t){return new e(this)._subtract(e.from(t))}_subtract(e){return this.x-=e.x,this.y-=e.y,this}divideBy(t){return new e(this)._divideBy(t)}_divideBy(e){return this.x/=e,this.y/=e,this}multiplyBy(t){return new e(this)._multiplyBy(t)}_multiplyBy(e){return this.x*=e,this.y*=e,this}scaleBy(t){return new e(this.x*t.x,this.y*t.y)}unscaleBy(t){return new e(this.x/t.x,this.y/t.y)}round(){return new e(this)._round()}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}floor(){return new e(this)._floor()}_floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return new e(this)._ceil()}_ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}trunc(){return new e(this)._trunc()}_trunc(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}distanceTo(t){t=e.from(t);let n=t.x-this.x,r=t.y-this.y;return Math.sqrt(n*n+r*r)}equals(t){return t=e.from(t),t.x===this.x&&t.y===this.y}contains(t){return t=e.from(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)}toString(){return`Point(${l(this.x)}, ${l(this.y)})`}};function ne(e){let t={bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed,detail:2,view:e.view,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,altKey:e.altKey,metaKey:e.metaKey,button:e.button,buttons:e.buttons,relatedTarget:e.relatedTarget,region:e.region},n;return n=e instanceof PointerEvent?new PointerEvent(`dblclick`,{...t,pointerId:e.pointerId,width:e.width,height:e.height,pressure:e.pressure,tangentialPressure:e.tangentialPressure,tiltX:e.tiltX,tiltY:e.tiltY,twist:e.twist,pointerType:e.pointerType,isPrimary:e.isPrimary}):new MouseEvent(`dblclick`,t),n}function re(e,t){e.addEventListener(`dblclick`,t);let n=0,r,i;function a(e){i=e.pointerType}function o(e){if(e.detail!==1){r=e.detail;return}if(i===`mouse`||e.sourceCapabilities&&!e.sourceCapabilities.firesTouchEvents)return;let t=e.composedPath();if(t.some(e=>e instanceof HTMLLabelElement&&e.htmlFor)&&!t.some(e=>e instanceof HTMLInputElement||e instanceof HTMLSelectElement))return;let a=Date.now();a-n<=200?(r++,r===2&&e.target.dispatchEvent(ne(e))):r=1,n=a}return e.addEventListener(`pointerdown`,a,!0),e.addEventListener(`click`,o),{dblclick:t,onPointerDown:a,simDblclick:o}}function ie(e,t){e.removeEventListener(`dblclick`,t.dblclick),e.removeEventListener(`pointerdown`,t.onPointerDown,!0),e.removeEventListener(`click`,t.simDblclick)}var ae=/* @__PURE__ */ t({disablePointerDetection:()=>se,enablePointerDetection:()=>oe,getPointers:()=>v});const _=/* @__PURE__ */ new Map;function oe(e){e.addEventListener(`pointerdown`,ce,{capture:!0}),e.addEventListener(`pointermove`,le,{capture:!0}),e.addEventListener(`pointerup`,ue,{capture:!0}),e.addEventListener(`pointercancel`,ue,{capture:!0}),_.clear()}function se(e){e.removeEventListener(`pointerdown`,ce,{capture:!0}),e.removeEventListener(`pointermove`,le,{capture:!0}),e.removeEventListener(`pointerup`,ue,{capture:!0}),e.removeEventListener(`pointercancel`,ue,{capture:!0})}function ce(e){e.isTrusted&&e.target.setPointerCapture(e.pointerId),_.set(e.pointerId,e)}function le(e){_.has(e.pointerId)&&_.set(e.pointerId,e)}function ue(e){e.target.hasPointerCapture(e.pointerId)&&e.target.releasePointerCapture(e.pointerId),_.delete(e.pointerId)}function v(){return[..._.values()]}var de=/* @__PURE__ */ t({PointerEvents:()=>ae,disableClickPropagation:()=>w,disableScrollPropagation:()=>C,getPointerPosition:()=>ge,getWheelDelta:()=>ve,getWheelPxFactor:()=>_e,isExternalTarget:()=>ye,off:()=>x,on:()=>y,preventDefault:()=>T,stop:()=>E,stopPropagation:()=>S});function y(e,t,n,r){if(t&&typeof t==`object`)for(let[r,i]of Object.entries(t))me(e,r,i,n);else for(let i of d(t))me(e,i,n,r)}const b=`_maplair_events`;function x(e,t,n,r){if(arguments.length===1)pe(e),delete e[b];else if(t&&typeof t==`object`)for(let[r,i]of Object.entries(t))he(e,r,i,n);else if(t=d(t),arguments.length===2)pe(e,e=>t.includes(e));else for(let i of t)he(e,i,n,r)}const fe=/\d/;function pe(e,t){for(let n of Object.keys(e[b]??{})){let r=n.split(fe)[0];(!t||t(r))&&he(e,r,null,null,n)}}function me(e,t,n,r){let i=t+a(n)+(r?`_${a(r)}`:``);if(e[b]&&e[b][i])return;let o=function(t){return n.call(r||e,t)};t===`dblclick`?o=re(e,o):e.addEventListener(t,o,t===`wheel`&&{passive:!1}),e[b]??={},e[b][i]=o}function he(e,t,n,r,i){i??=t+a(n)+(r?`_${a(r)}`:``);let o=e[b]&&e[b][i];o&&(t===`dblclick`?ie(e,o):e.removeEventListener(t,o,!1),e[b][i]=null)}function S(e){e.stopPropagation?e.stopPropagation():e.originalEvent?e.originalEvent._stopped=!0:console.debug(`Unsupported event`,e)}function C(e){me(e,`wheel`,S)}function w(e){y(e,`pointerdown dblclick contextmenu`,S),e._maplair_disable_click=!0}function T(e){e.preventDefault?.()}function E(e){T(e),S(e)}function ge(e,t){if(!t)return new g(e.clientX,e.clientY);let n=M(t),r=n.boundingClientRect;return new g((e.clientX-r.left)/n.x-t.clientLeft,(e.clientY-r.top)/n.y-t.clientTop)}function _e(){return window.devicePixelRatio*2}function ve(e){return e.deltaY&&e.deltaMode===0?-e.deltaY/_e():e.deltaY&&e.deltaMode===1?-e.deltaY*20:e.deltaY&&e.deltaMode===2?-e.deltaY*60:(e.deltaX||e.deltaZ,0)}function ye(e,t){return!e.contains(t.relatedTarget)}var be=/* @__PURE__ */ t({create:()=>D,disableImageDrag:()=>we,enableImageDrag:()=>Te,get:()=>xe,getPosition:()=>j,getScale:()=>M,getSizedParentNode:()=>Ee,setPosition:()=>A,setTransform:()=>k,toBack:()=>Se,toFront:()=>O});function xe(e){return typeof e==`string`?document.getElementById(e):e}function D(e,t,n){let r=document.createElement(e);return r.className=t??``,n?.appendChild(r),r}function O(e){let t=e.parentNode;if(t&&t.lastChild!==e){if(e.matches(`:hover`))for(;e.nextSibling;)t.insertBefore(e.nextSibling,e);else t.appendChild(e)}}function Se(e){let t=e.parentNode;if(t&&t.firstChild!==e){if(e.matches(`:hover`))for(;e.previousSibling;)t.insertBefore(e.previousSibling,e.nextSibling);else t.insertBefore(e,t.firstChild)}}function k(e,t,n){let r=t??new g(0,0),i=`translate3d(${r.x}px, ${r.y}px, 0px)${n?` scale(${n})`:``}`;e.style.transform!==i&&(e.style.transform=i)}const Ce=/* @__PURE__ */ new WeakMap;function A(e,t,n){Ce.set(e,t),n?e.style.transform=`translate(${t.x}px, ${t.y}px)`:k(e,t)}function j(e){return Ce.get(e)??new g(0,0)}function we(){y(window,`dragstart`,T)}function Te(){x(window,`dragstart`,T)}function Ee(e){do e=e.parentNode;while((!e.offsetWidth||!e.offsetHeight)&&e!==document.body);return e}function M(e){let t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}const De={addControl(e){return e.addTo(this),this},removeControl(e){return e.remove(),this},_initControlPos(){let e=this._controlCorners={},t=`maplair-`,n=this._controlContainer=D(`div`,`${t}control-container`,this._container);for(let r of[`top`,`bottom`])for(let i of[`left`,`right`])e[r+i]=D(`div`,`${t+r} ${t}${i}`,n)},_clearControlPos(){this._controlContainer.remove(),delete this._controlCorners,delete this._controlContainer}},Oe=/* @__PURE__ */ new WeakMap;var N=class e extends h{static defaultOptions={position:`topright`,order:0};constructor(t){super(),f(this,t),this.callInitHooks(e)}getPosition(){return this.options.position}setPosition(e){let t=this._map;return t?.removeControl(this),this.options.position=e,t?.addControl(this),this}getContainer(){return this._container}addTo(e){this.remove(),this._map=e;let t=this._container=this.onAdd(e),n=this.getPosition(),r=e._controlCorners[n];t.classList.add(`maplair-control`);let i=this.options.order??0,a=n.includes(`bottom`),o=[...r.children];return Oe.set(t,i),r.insertBefore(t,o.find(e=>a?(Oe.get(e)??0)<=i:(Oe.get(e)??0)>i)??null),this._map.on(`unload`,this.remove,this),this}remove(){return this._map&&=(this._container.remove(),this.onRemove&&this.onRemove(this._map),this._map.off(`unload`,this.remove,this),null),this}_refocusOnMap(e){this._map&&e&&(e.screenX!==0||e.screenY!==0)&&this._map.getContainer().focus({preventScroll:!0,focusVisible:!1})}static register(e){e.include(De)}},P=class{static#e={};static#t=null;static registerLocale(e,t){this.#e[e]={...this.#e[e],...t}}static setLocale(e){this.#t=e}static getLocale(){return this.#t}static translate(e,t={}){if(this.#t===null)return m(e,t);let n=this.#e[this.#t]?.[e];if(!n)return console.warn(`No translation found for "${e}", falling back to the original string.`),m(e,t);try{return m(n,t)}catch(e){return console.error(`Error while translating "${n}".`,e),n}}},ke=class e extends N{static defaultOptions={position:`bottomright`,prefix:null};constructor(t){if(super(t),this.options.prefix===null){let e=P.translate(`A JavaScript library for interactive maps`);this.options.prefix=`<a target="_blank" href="https://maplair.org" title="${e}"><span aria-hidden="true" class="maplair-attribution-leaf">🍁</span>Maplair</a>`}this._attributions={},this._orders={},this._layerAttributions=/* @__PURE__ */ new Map,this.callInitHooks(e)}onAdd(e){return e.attributionControl=this,this._container=D(`div`,`maplair-control-attribution`),w(this._container),e._loaded&&e.eachLayer(e=>this._addLayer({layer:e})),this._update(),e.on({layeradd:this._addLayer,layerremove:this._removeLayer},this),this._container}onRemove(e){e.off({layeradd:this._addLayer,layerremove:this._removeLayer},this);for(let e of this._layerAttributions.keys())this._removeLayer({layer:e})}_addLayer({layer:e}){let t=e.getAttribution?.();t&&!this._layerAttributions.has(e)&&(this._layerAttributions.set(e,t),this.addAttribution(t,e.options?.attributionOrder))}_removeLayer({layer:e}){this.removeAttribution(this._layerAttributions.get(e)),this._layerAttributions.delete(e)}setPrefix(e){return this.options.prefix=e,this._update(),this}addAttribution(e,t=0){return e&&(this._orders[e]=t,this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update()),this}removeAttribution(e){return e&&this._attributions[e]&&(this._attributions[e]--,this._update()),this}_update(){if(!this._map)return;let e=Object.keys(this._attributions).filter(e=>this._attributions[e]).sort((e,t)=>this._orders[e]-this._orders[t]),t=[];this.options.prefix&&t.push(this.options.prefix),e.length&&t.push(e.join(`, `)),this._container.innerHTML=t.join(` <span aria-hidden="true">|</span> `)}static register(t){t.mergeOptions({attributionControl:!0}),t.addInitHook(function(){this.options.attributionControl&&new e().addTo(this)})}},Ae=class e extends N{static defaultOptions={position:`topleft`,content:``,title:``,onClick:void 0,states:void 0,className:``,accessKey:``};constructor(...t){super(...t),this._state=this.options.states?.[0],this.callInitHooks(e)}onAdd(){let e=D(`div`,`maplair-bar maplair-control-button`);return this._createButton(e),e}_createButton(e){let t=this._button=D(`button`,`maplair-control-button-button ${this.options.className}`,e);return t.type=`button`,t.accessKey=this.options.accessKey,w(t),y(t,`click`,E),y(t,`click`,this._onClick,this),y(t,`click`,this._refocusOnMap,this),this._update(),t}_onClick(e){this._disabled||(this._state??this.options).onClick?.call(this,e,this,this._map)}_update(){if(!this._button)return;let{content:e,title:t}=this._state??this.options,n=this._button;typeof e==`string`?n.innerHTML=e:n.replaceChildren(e);let r=n.accessKeyLabel||this.options.accessKey.toUpperCase();n.title=[t,r&&`[${r}]`].filter(Boolean).join(` `),n.setAttribute(`aria-label`,t??``),this._state&&(n.dataset.state=this._state.name),n.classList.toggle(`maplair-disabled`,!!this._disabled),n.setAttribute(`aria-disabled`,!!this._disabled)}setState(e){let t=this.options.states?.find(t=>t.name===e);if(!t)throw Error(`Unknown button state "${e}".`);return this._state=t,this._update(),this}getState(){return this._state?.name}disable(){return this._disabled=!0,this._update(),this}enable(){return this._disabled=!1,this._update(),this}getButton(){return this._button}},je=class e extends N{constructor(t,n){super(n),this._buttons=t,this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-bar maplair-control-button-bar`);for(let n of this._buttons)n._map=e,n._createButton(t);return t}onRemove(){for(let e of this._buttons)e._map=null}getButtons(){return this._buttons}};const Me=/* @__PURE__ */ new Set;var Ne=class e extends h{on(e,t,n){if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._on(n,r,t);else for(let r of d(e))this._on(r,t,n);return this}off(e,t,n){if(!arguments.length)delete this._events,delete this._listenerIndex;else if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._off(n,r,t);else{let r=arguments.length===1;for(let i of d(e))r?this._off(i):this._off(i,t,n)}return this}static __REMOVED_EVENTS={mousedown:`pointerdown`,mouseup:`pointerup`,mouseover:`pointerover`,mouseout:`pointerout`,mousemove:`pointermove`,keypress:`keydown`};_on(t,n,r,i){if(Object.hasOwn(e.__REMOVED_EVENTS,t)&&!Me.has(t)&&(Me.add(t),console.error(`The event ${t} has been removed in Maplair. Use ${e.__REMOVED_EVENTS[t]} instead.`)),typeof n!=`function`){console.warn(`wrong listener type: ${typeof n}`);return}r===this&&(r=void 0);let a=this._getListenerIndex(t).get(n);if(a?.has(r))return;let o={fn:n,ctx:r};i&&(o.once=!0),this._events??={},this._events[t]??=/* @__PURE__ */ new Set,this._events[t].add(o),a?a.set(r,o):this._listenerIndex[t].set(n,/* @__PURE__ */ new Map([[r,o]]))}_getListenerIndex(e){return this._listenerIndex??={},this._listenerIndex[e]??=/* @__PURE__ */ new Map}_off(e,t,n){if(!this._events)return;let r=this._events[e];if(!r)return;if(arguments.length===1){if(this._firingCount)for(let e of r)e.fn=c;delete this._events[e],delete this._listenerIndex?.[e];return}if(typeof t!=`function`){console.warn(`wrong listener type: ${typeof t}`);return}n===this&&(n=void 0);let i=this._listenerIndex?.[e]?.get(t),a=i?.get(n);a&&(i.delete(n),i.size||this._listenerIndex[e].delete(t),this._firingCount&&(a.fn=c,this._events[e]=r=new Set(r)),r.delete(a))}fire(e,t,n){if(!this.listens(e,n))return this;let r={...t,type:e,target:this,sourceTarget:t?.sourceTarget||this};if(this._events){let t=this._events[e];if(t){this._firingCount=this._firingCount+1||1;for(let n of t){let t=n.fn;n.once&&this.off(e,t,n.ctx),t.call(n.ctx||this,r)}this._firingCount--}}return n&&this._propagateEvent(r),this}listens(e,t,n,r){typeof e!=`string`&&console.warn(`"string" type argument expected`);let i=t;if(typeof t!=`function`&&(r=!!t,i=void 0,n=void 0),this._events?.[e]?.size&&this._listens(e,i,n)!==!1)return!0;if(r){for(let i of Object.values(this._eventParents??{}))if(i.listens(e,t,n,r))return!0}return!1}_listens(e,t,n){if(!this._events)return!1;let r=this._events[e];return t?(n===this&&(n=void 0),!!this._listenerIndex?.[e]?.get(t)?.has(n)):!!r?.size}once(e,t,n){if(typeof e==`object`)for(let[n,r]of Object.entries(e))this._on(n,r,t,!0);else for(let r of d(e))this._on(r,t,n,!0);return this}addEventParent(e){return this._eventParents??={},this._eventParents[a(e)]=e,this}removeEventParent(e){return this._eventParents&&delete this._eventParents[a(e)],this}_propagateEvent(e){for(let t of Object.values(this._eventParents??{}))t.fire(e.type,{layer:e.target,propagatedFrom:e.target,...e},!0)}};const Pe={addLayer(e){if(!e._layerAdd)throw Error(`The provided object is not a Layer.`);let t=a(e);return this._layers[t]||(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e)),this},removeLayer(e){let t=a(e);return this._layers[t]&&(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire(`layerremove`,{layer:e}),e.fire(`remove`)),e._map=e._mapToAdd=null),this},hasLayer(e){return a(e)in this._layers},eachLayer(e,t){for(let n of Object.values(this._layers))e.call(t,n);return this},_addLayers(e){e=e?Array.isArray(e)?e:[e]:[];for(let t of e)this.addLayer(t)},_addZoomLimit(e){isNaN(e.options.maxZoom)&&isNaN(e.options.minZoom)||(this._zoomBoundLayers[a(e)]=e,this._updateZoomLevels())},_removeZoomLimit(e){let t=a(e);this._zoomBoundLayers[t]&&(delete this._zoomBoundLayers[t],this._updateZoomLevels())},_updateZoomLevels(){let e=1/0,t=-1/0,n=this._getZoomSpan();for(let n of Object.values(this._zoomBoundLayers)){let r=n.options;e=Math.min(e,r.minZoom??1/0),t=Math.max(t,r.maxZoom??-1/0)}this._layersMaxZoom=t===-1/0?void 0:t,this._layersMinZoom=e===1/0?void 0:e,n!==this._getZoomSpan()&&this.fire(`zoomlevelschange`),this.options.maxZoom===void 0&&this._layersMaxZoom&&this.getZoom()>this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()<this._layersMinZoom&&this.setZoom(this._layersMinZoom)}};var F=class extends Ne{static defaultOptions={pane:`overlayPane`,attribution:null,attributionOrder:0,bubblingPointerEvents:!0};addTo(e){return e.addLayer(this),this}remove(){return this.removeFrom(this._map||this._mapToAdd)}removeFrom(e){return e?.removeLayer(this),this}getPane(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)}setInteractive(e){return e=!!e,this.options.interactive!==e&&(f(this,{interactive:e}),this._map&&this._updateInteractive()),this}_updateInteractive(){}addInteractiveTarget(e){return this._map._targets[a(e)]=this,this}removeInteractiveTarget(e){return delete this._map._targets[a(e)],this}getAttribution(){return this.options.attribution}setAttribution(e){let t=this._map?.attributionControl;return t?._removeLayer({layer:this}),f(this,{attribution:e}),t?._addLayer({layer:this}),this}_layerAdd(e){let t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){let e=this.getEvents();t.on(e,this),this.once(`remove`,()=>t.off(e,this))}this.onAdd(t),this.fire(`add`),t.fire(`layeradd`,{layer:this})}}static register(e){e.include(Pe)}},Fe=class e extends h{static defaultOptions={className:``};constructor(t,n){super(),f(this,n),this._items=t,this.callInitHooks(e)}addTo(e){return this.remove(),this._target=e,e.on(`contextmenu`,this._open,this),this}remove(){return this.close(),this._target?.off(`contextmenu`,this._open,this),this._target=null,this._container?.remove(),this._container=null,this}close(){return this._container?.matches(`:popover-open`)&&this._container.hidePopover(),this}isOpen(){return!!this._container?.matches(`:popover-open`)}_open(e){E(e);let t=this._target instanceof F?this._target._map:this._target;if(!t)return;this._map=t,this._event={latlng:e.latlng,containerPoint:e.containerPoint,layerPoint:e.layerPoint,originalEvent:e.originalEvent,relatedTarget:this._target instanceof F?this._target:void 0};let n=this._createMenu(t._container);n.matches(`:popover-open`)||n.showPopover(),this._position(e.originalEvent),n.querySelector(`button:not([disabled])`)?.focus({preventScroll:!0}),t.once(`movestart`,this.close,this)}_createMenu(e){let t=this._container??=D(`div`,`maplair-contextmenu ${this.options.className}`);t.parentNode!==e&&e.appendChild(t),t.popover=`auto`,t.setAttribute(`role`,`menu`),t.replaceChildren();for(let e of this._items){if(e===`-`){D(`div`,`maplair-contextmenu-separator`,t).setAttribute(`role`,`separator`);continue}let n=D(`button`,`maplair-contextmenu-item`,t);n.type=`button`,n.setAttribute(`role`,`menuitem`),n.textContent=e.text,n.disabled=!!e.disabled,y(n,`click`,t=>{E(t),this.close(),e.callback?.call(this,this._event)})}return y(t,`keydown`,this._onKeyDown,this),w(t),C(t),y(t,`contextmenu`,E),t}_position(e){let t=this._container,n=document.documentElement,r=Math.min(e.clientX,n.clientWidth-t.offsetWidth),i=Math.min(e.clientY,n.clientHeight-t.offsetHeight);t.style.left=`${Math.max(0,r)}px`,t.style.top=`${Math.max(0,i)}px`}_onKeyDown(e){if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;E(e);let t=[...this._container.querySelectorAll(`button:not([disabled])`)],n=t.indexOf(document.activeElement),r=e.key===`ArrowDown`?n+1:n-1;t.at(r%t.length)?.focus()}};const Ie={toggleFullscreen(){let e=this._container;return this._fullscreen===`pseudo`?this._setFullscreen(!1):this._fullscreen?document.exitFullscreen():document.fullscreenEnabled&&e.requestFullscreen?(y(document,`fullscreenchange`,this._onFullscreenChange,this),e.requestFullscreen().catch(()=>{x(document,`fullscreenchange`,this._onFullscreenChange,this),this._setFullscreen(`pseudo`)})):this._setFullscreen(`pseudo`),this},isFullscreen(){return!!this._fullscreen},_onFullscreenChange(){let e=document.fullscreenElement===this._container;e||x(document,`fullscreenchange`,this._onFullscreenChange,this),e!==this.isFullscreen()&&this._setFullscreen(e&&`native`)},_onFullscreenKeyDown(e){e.key===`Escape`&&this._setFullscreen(!1)},_setFullscreen(e){let t=this._container;this._fullscreen=e,t.classList.toggle(`maplair-fullscreen`,!!e),t.classList.toggle(`maplair-pseudo-fullscreen`,e===`pseudo`),e===`pseudo`?y(document,`keydown`,this._onFullscreenKeyDown,this):x(document,`keydown`,this._onFullscreenKeyDown,this),this.invalidateSize(),this.fire(e?`enterfullscreen`:`exitfullscreen`),this.fire(`fullscreenchange`)}};var Le=class e extends N{static defaultOptions={position:`topleft`,enterText:`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M2 2h5v2H4v3H2zm7 0h5v5h-2V4H9zM2 9h2v3h3v2H2zm10 0h2v5H9v-2h3z"/></svg>`,exitText:`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="M5 2h2v5H2V5h3zm4 0h2v3h3v2H9zM2 9h5v5H5v-3H2zm7 0h5v2h-3v3H9z"/></svg>`};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-control-fullscreen maplair-bar`),n=this._button=D(`button`,`maplair-control-fullscreen-button`,t);return n.type=`button`,w(n),y(n,`click`,E),y(n,`click`,this._toggleFullscreen,this),y(n,`click`,this._refocusOnMap,this),this._update(),e.on(`fullscreenchange`,this._update,this),t}onRemove(e){e.off(`fullscreenchange`,this._update,this)}_toggleFullscreen(){this._map.toggleFullscreen()}_update(){let e=this._map.isFullscreen(),t=e?P.translate(`Exit fullscreen`):P.translate(`View fullscreen`);this._button.innerHTML=e?this.options.exitText:this.options.enterText,this._button.title=t,this._button.setAttribute(`aria-label`,t),this._button.setAttribute(`aria-pressed`,e)}static register(t){t.mergeOptions({fullscreenControl:!1}),t.include(Ie),t.addInitHook(function(){this.on(`unload`,function(){this._fullscreen===`native`&&(x(document,`fullscreenchange`,this._onFullscreenChange,this),document.exitFullscreen()),this._container.classList.remove(`maplair-fullscreen`,`maplair-pseudo-fullscreen`),x(document,`keydown`,this._onFullscreenKeyDown,this),this._fullscreen=!1}),this.options.fullscreenControl&&(this.fullscreenControl=new e,this.addControl(this.fullscreenControl))})}},Re=class e extends N{static defaultOptions={collapsed:!0,inline:!1,groupBy:void 0,toggleContent:void 0,collapseDelay:0,position:`topright`,autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction(e,t,n,r){return n<r?-1:+(r<n)}};constructor(t,n,r){super(r),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,this._preventClick=!1;for(let[e,n]of Object.entries(t??{}))this._addLayer(n,e);for(let[e,t]of Object.entries(n??{}))this._addLayer(t,e,!0);this.callInitHooks(e)}onAdd(e){this._initLayout(),this._update(),this._map=e,e.on(`zoomend`,this._checkDisabledLayers,this);for(let e of this._layers)e.layer.on(`add remove`,this._onLayerChange,this);return this._isCollapsible()||e.on(`resize`,this._expandIfNotCollapsed,this),this._container}addTo(e){return super.addTo(e),this._expandIfNotCollapsed()}onRemove(){this._map.off(`zoomend`,this._checkDisabledLayers,this);for(let e of this._layers)e.layer.off(`add remove`,this._onLayerChange,this);this._map.off(`resize`,this._expandIfNotCollapsed,this),this._map.off(`click`,this.collapse,this)}addBaseLayer(e,t){return this._addLayer(e,t),this._map?this._update():this}addOverlay(e,t){return this._addLayer(e,t,!0),this._map?this._update():this}removeLayer(e){return e.off(`add remove`,this._onLayerChange,this),this._layers=this._layers.filter(t=>t.layer!==e),this._map?this._update():this}getLayers(){return this._layers.map(({layer:e,name:t,overlay:n})=>({layer:e,name:t,overlay:n}))}selectLayer(e){let t=this._layerControlInputs.find(t=>t._layer===e);return t&&!t.checked&&(t.checked=!0,this._onInputClick()),this}expand(){clearTimeout(this._collapseDelayTimeout),this._container.classList.add(`maplair-control-layers-expanded`),this._section.style.height=``;let e=this._map.getSize().y-(this._container.offsetTop+50);return e<this._section.clientHeight?(this._section.classList.add(`maplair-control-layers-scrollbar`),this._section.style.height=`${e}px`):this._section.classList.remove(`maplair-control-layers-scrollbar`),this._checkDisabledLayers(),this}collapse(){return this.options.inline||(this.options.collapseDelay>0?this._collapseDelayTimeout=setTimeout(()=>{this._container.classList.remove(`maplair-control-layers-expanded`)},this.options.collapseDelay):this._container.classList.remove(`maplair-control-layers-expanded`)),this}_initLayout(){let e=`maplair-control-layers`,t=this._container=D(`div`,e),n=this._isCollapsible();this.options.inline&&t.classList.add(`${e}-inline`),w(t),C(t);let r=this._section=D(`fieldset`,`${e}-list`);if(r.setAttribute(`aria-label`,P.translate(`Layers`)),n&&(this._map.on(`click`,this.collapse,this),y(t,{pointerenter:this._expandSafely,pointerleave(e){e.pointerType!==`touch`&&this.collapse()}},this)),!this.options.inline){let n=this._layersLink=D(`button`,`${e}-toggle`,t);n.type=`button`,n.title=P.translate(`Layers`),n.setAttribute(`aria-label`,P.translate(`Layers`));let{toggleContent:r}=this.options;typeof r==`string`?n.innerHTML=r:r&&n.replaceChildren(r),y(n,{keydown(e){e.code===`Enter`&&this._expandSafely()},click(e){e.preventDefault(),this._expandSafely()}},this)}n||this.expand(),this._baseLayersList=D(`div`,`${e}-base`,r),this._separator=D(`div`,`${e}-separator`,r),this._overlaysList=D(`div`,`${e}-overlays`,r),t.appendChild(r)}_addLayer(e,t,n){this._map&&e.on(`add remove`,this._onLayerChange,this),this._layers.push({layer:e,name:t,overlay:!!n}),this.options.sortLayers&&this._layers.sort(((e,t)=>this.options.sortFunction(e.layer,t.layer,e.name,t.name))),this.options.autoZIndex&&e.setZIndex&&(this._lastZIndex++,e.setZIndex(this._lastZIndex)),this._expandIfNotCollapsed()}_update(){if(!this._container)return this;this._baseLayersList.replaceChildren(),this._overlaysList.replaceChildren(),this._layerControlInputs=[],this._groupCount=0;let e,t,n=0;for(let r of this._layers)this._addItem(r),t||=r.overlay,e||=!r.overlay,n+=+!r.overlay;return this.options.hideSingleBase&&(e&&=n>1,this._baseLayersList.style.display=e?``:`none`),this._separator.style.display=t&&e?``:`none`,this}_onLayerChange(e){this._handlingClick||this._update();let t=this._layers.find(t=>t.layer===e.target),n=t.overlay?e.type===`add`?`overlayadd`:`overlayremove`:e.type===`add`?`baselayerchange`:null;n&&this._map.fire(n,this._clickEvent?{...t,originalEvent:this._clickEvent}:t)}_addItem(e){let t=document.createElement(`label`),n=this._map.hasLayer(e.layer),r=document.createElement(`input`);r.type=e.overlay?`checkbox`:`radio`,r.className=`maplair-control-layers-selector`,r.defaultChecked=n,e.overlay||(r.name=`maplair-base-layers_${a(this)}`),this._layerControlInputs.push(r),r._layer=e.layer,y(r,`click`,this._onInputClick,this);let i=this.options.groupBy?.(e.name,e.layer,e.overlay),o=document.createElement(`span`);o.innerHTML=` ${i?i.label:e.name}`;let s=document.createElement(`span`);t.appendChild(s),s.appendChild(r),s.appendChild(o);let c=e.overlay?this._overlaysList:this._baseLayersList;return(i?this._getGroupContainer(c,i.group):c).appendChild(t),this._checkDisabledLayers(),t}_getGroupContainer(e,t){let n=e.lastElementChild;if(n?._maplairGroup===t)return n;let r=`maplair-control-layers-group`,i=D(`div`,r,e),o=D(`span`,`${r}-name`,i);return o.id=`${r}_${a(this)}_${++this._groupCount}`,o.textContent=t,i.setAttribute(`role`,`group`),i.setAttribute(`aria-labelledby`,o.id),i._maplairGroup=t,i}_onInputClick(e){if(this._preventClick)return;let t=/* @__PURE__ */ new Map;for(let e of this._layerControlInputs){let n=e._layer;t.set(n,t.get(n)||e.checked)}let n=[],r=[];for(let[e,i]of t)i!==this._map.hasLayer(e)&&(i?n:r).push(e);this._handlingClick=!0,this._clickEvent=e;for(let e of r)this._map.removeLayer(e);for(let e of n)this._map.addLayer(e);this._handlingClick=!1,this._clickEvent=void 0;for(let[e,n]of t)if(n!==this._map.hasLayer(e)){this._update();break}this._refocusOnMap(e)}_checkDisabledLayers(){let e=this._layerControlInputs,t=this._map.getZoom();for(let n of e){let e=n._layer;n.disabled=e.options.minZoom!==void 0&&t<e.options.minZoom||e.options.maxZoom!==void 0&&t>e.options.maxZoom}}_isCollapsible(){return this.options.collapsed&&!this.options.inline}_expandIfNotCollapsed(){return this._map&&!this._isCollapsible()&&this.expand(),this}_expandSafely(){let e=this._section;this._preventClick=!0,y(e,`click`,T),this.expand(),setTimeout(()=>{x(e,`click`,T),this._preventClick=!1})}},I=class e{constructor(t,n){if(!t)return;if(t instanceof e){t.isValid()&&(this.min=new g(t.min),this.max=new g(t.max));return}let r=n?[t,n]:t;for(let e of r)this.extend(e)}static from(t,n){return t instanceof e?t:new e(t,n)}extend(t){let n,r;if(!t)return this;if(ze(t))n=r=g.from(t);else if({min:n,max:r}=e.from(t),!n)return this;return this.min?(this.min.x=Math.min(n.x,this.min.x),this.max.x=Math.max(r.x,this.max.x),this.min.y=Math.min(n.y,this.min.y),this.max.y=Math.max(r.y,this.max.y)):(this.min=new g(n),this.max=new g(r)),this}getCenter(e){return new g((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,e)}getBottomLeft(){return new g(this.min.x,this.max.y)}getTopRight(){return new g(this.max.x,this.min.y)}getTopLeft(){return this.min}getBottomRight(){return this.max}getSize(){return this.max.subtract(this.min)}contains(t){let n,r;return ze(t)?n=r=g.from(t):{min:n,max:r}=e.from(t),n.x>=this.min.x&&r.x<=this.max.x&&n.y>=this.min.y&&r.y<=this.max.y}intersects(t){t=e.from(t);let n=this.min,r=this.max,i=t.min,a=t.max,o=a.x>=n.x&&i.x<=r.x,s=a.y>=n.y&&i.y<=r.y;return o&&s}overlaps(t){t=e.from(t);let n=this.min,r=this.max,i=t.min,a=t.max,o=a.x>n.x&&i.x<r.x,s=a.y>n.y&&i.y<r.y;return o&&s}isValid(){return!!(this.min&&this.max)}pad(t){let n=this.min,r=this.max,i=Math.abs(n.x-r.x)*t,a=Math.abs(n.y-r.y)*t;return new e(new g(n.x-i,n.y-a),new g(r.x+i,r.y+a))}equals(t){return t?(t=e.from(t),this.min.equals(t.getTopLeft())&&this.max.equals(t.getBottomRight())):!1}};function ze(e){return e instanceof g||(Array.isArray(e)?typeof e[0]==`number`:`x`in e)}var Be=class e extends F{static defaultOptions={padding:.1,continuous:!1};constructor(t){super(),f(this,t),this.callInitHooks(e)}onAdd(){this._container||(this._initContainer(),this._container.classList.add(`maplair-zoom-animated`)),this.getPane().appendChild(this._container),this._resizeContainer(),this._onMoveEnd()}onRemove(){this._destroyContainer()}getEvents(){let e={viewreset:this._reset,zoom:this._onZoom,moveend:this._onMoveEnd,resize:this._resizeContainer,zoomend:this._onZoomEnd,zoomanim:this._onAnimZoom};return this.options.continuous&&(e.move=this._onMoveEnd),e}_onAnimZoom(e){this._updateTransform(e.center,e.zoom)}_onZoom(){this._updateTransform(this._map.getCenter(),this._map.getZoom())}_updateTransform(e,t){let n=this._map.getZoomScale(t,this._zoom),r=this._map.getSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n)._add(i)._subtract(this._map._getNewPixelOrigin(e,t))._round();k(this._container,a,n)}_onMoveEnd(e){let t=this.options.padding,n=this._map.getSize(),r=this._map.containerPointToLayerPoint(n.multiplyBy(-t)).round();this._bounds=new I(r,r.add(n.multiplyBy(1+t*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._updateTransform(this._center,this._zoom),this._onSettled(e)}_reset(){this._onSettled(),this._updateTransform(this._center,this._zoom),this._onViewReset()}_initContainer(){this._container=D(`div`)}_destroyContainer(){x(this._container),this._container.remove(),delete this._container}_resizeContainer(){let e=this.options.padding,t=this._map.getSize().multiplyBy(1+e*2).round();return this._container.style.width=`${t.x}px`,this._container.style.height=`${t.y}px`,t}_onZoomEnd(){}_onViewReset(){}_onSettled(){}},Ve=class e extends Be{constructor(t){super({...t,continuous:!1}),a(this),this._layers??={},this.callInitHooks(e)}onAdd(e){super.onAdd(e),this.on(`update`,this._updatePaths,this)}onRemove(){super.onRemove(),this.off(`update`,this._updatePaths,this)}_onZoomEnd(){for(let e of Object.values(this._layers))e._project()}_updatePaths(){for(let e of Object.values(this._layers))e._update()}_onViewReset(){for(let e of Object.values(this._layers))e._reset()}_onSettled(){this._update()}_update(){}},L=class e extends Ve{constructor(...t){super(...t),this.callInitHooks(e)}_initContainer(){this._container=e.create(`svg`),this._container.setAttribute(`pointer-events`,`none`),this._rootGroup=e.create(`g`),this._container.appendChild(this._rootGroup)}_destroyContainer(){super._destroyContainer(),delete this._rootGroup,delete this._svgSize}_resizeContainer(){let e=super._resizeContainer();this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,this._container.setAttribute(`width`,`${e.x}`),this._container.setAttribute(`height`,`${e.y}`));let t=this._bounds;t&&this._container.setAttribute(`viewBox`,[t.min.x,t.min.y,e.x,e.y].join(` `))}_update(){if(this._map._animatingZoom&&this._bounds)return;let e=this._bounds,t=e.getSize();this._container.setAttribute(`viewBox`,[e.min.x,e.min.y,t.x,t.y].join(` `)),this.fire(`update`)}_initPath(t){let n=t._path=e.create(`path`);t.options.className&&n.classList.add(...d(t.options.className)),t.options.interactive&&n.classList.add(`maplair-interactive`),this._updateStyle(t),this._layers[a(t)]=t}_updateInteractive(e){e._path.classList.toggle(`maplair-interactive`,!!e.options.interactive)}_addPath(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)}_removePath(e){e._path.remove(),e.removeInteractiveTarget(e._path),delete this._layers[a(e)]}_updatePath(e){e._project(),e._update()}_updateStyle(e){let t=e._path,n=e.options;t&&(n.stroke?(t.setAttribute(`stroke`,n.color),t.setAttribute(`stroke-opacity`,`${n.opacity}`),t.setAttribute(`stroke-width`,`${n.weight}`),t.setAttribute(`stroke-linecap`,n.lineCap),t.setAttribute(`stroke-linejoin`,n.lineJoin),n.dashArray?t.setAttribute(`stroke-dasharray`,n.dashArray):t.removeAttribute(`stroke-dasharray`),n.dashOffset?t.setAttribute(`stroke-dashoffset`,n.dashOffset):t.removeAttribute(`stroke-dashoffset`)):t.setAttribute(`stroke`,`none`),n.fill?(t.setAttribute(`fill`,n.fillColor||n.color),t.setAttribute(`fill-opacity`,`${n.fillOpacity}`),t.setAttribute(`fill-rule`,n.fillRule||`evenodd`)):t.setAttribute(`fill`,`none`))}_updatePoly(t,n){this._setPath(t,e.pointsToPath(t._parts,n))}_updateCircle(e){let t=e._point,n=Math.max(Math.round(e._pxRadius),1),r=`a${n},${Math.max(Math.round(e._pxRadiusY),1)||n} 0 1,0 `,i=e._empty()?`M0 0`:`M${He(t.x-n)},${He(t.y)}${r}${n*2},0 ${r}${-n*2},0 `;this._setPath(e,i)}_setPath(e,t){e._path.setAttribute(`d`,t)}_bringToFront(e){O(e._path)}_bringToBack(e){Se(e._path)}static create(e){return document.createElementNS(`http://www.w3.org/2000/svg`,e)}static pointsToPath(e,t){return e.flatMap(e=>[...e.map((e,t)=>`${(t?`L`:`M`)+He(e.x)} ${He(e.y)}`),t?`z`:``]).join(``)||`M0 0`}};function He(e){let t=Math.round(e*10),n=t<0?-t:t,r=Math.floor(n/10),i=n-r*10;return(t<0?`-`:``)+(i?`${r}.${i}`:r)}var R=class extends F{static defaultOptions={stroke:!0,color:`#3388ff`,weight:3,opacity:1,lineCap:`round`,lineJoin:`round`,dashArray:null,dashOffset:null,fill:!1,fillColor:null,fillOpacity:.2,fillRule:`evenodd`,interactive:!0,bubblingPointerEvents:!0};beforeAdd(e){this._renderer=e.getRenderer(this)}onAdd(){this._renderer._initPath(this),this._reset(),this._renderer._addPath(this)}onRemove(){this._renderer._removePath(this)}redraw(){return this._map&&this._renderer._updatePath(this),this}_updateInteractive(){this._renderer._updateInteractive(this)}setStyle(e){return f(this,e),this._renderer&&(this._renderer._updateStyle(this),this.options.stroke&&e&&Object.hasOwn(e,`weight`)&&this._updateBounds()),this}bringToFront(){return this._renderer?._bringToFront(this),this}bringToBack(){return this._renderer?._bringToBack(this),this}getElement(){return this._path}_createRenderer(e){return new L(e)}_reset(){this._project(),this._update()}_clickTolerance(){return(this.options.stroke?this.options.weight/2:0)+(this._renderer.options.tolerance||0)}},z=class e{constructor(t,n){if(!t)return;if(t instanceof e){t.isValid()&&(this._southWest=new V(t._southWest),this._northEast=new V(t._northEast));return}let r=n?[t,n]:t;for(let e of r)this.extend(e)}static from(t,n){return t instanceof e?t:new e(t,n)}extend(t){let n=this._southWest,r=this._northEast,i,a;if(t instanceof V)i=a=t;else if(t instanceof e){if({_southWest:i,_northEast:a}=t,!i)return this}else if(!t)return this;else if(V.validate(t))i=a=V.from(t);else return this.extend(e.from(t));return n?(n.lat=Math.min(i.lat,n.lat),n.lng=Math.min(i.lng,n.lng),r.lat=Math.max(a.lat,r.lat),r.lng=Math.max(a.lng,r.lng)):(this._southWest=new V(i.lat,i.lng),this._northEast=new V(a.lat,a.lng)),this}pad(t){let n=this._southWest,r=this._northEast,i=Math.abs(n.lat-r.lat)*t,a=Math.abs(n.lng-r.lng)*t;return new e(new V(n.lat-i,n.lng-a),new V(r.lat+i,r.lng+a))}getCenter(){return new V((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)}getSouthWest(){return this._southWest}getNorthEast(){return this._northEast}getNorthWest(){return new V(this.getNorth(),this.getWest())}getSouthEast(){return new V(this.getSouth(),this.getEast())}getWest(){return this._southWest.lng}getSouth(){return this._southWest.lat}getEast(){return this._northEast.lng}getNorth(){return this._northEast.lat}contains(t){t=V.validate(t)?V.from(t):e.from(t);let n=this._southWest,r=this._northEast,i,a;return t instanceof e?(i=t.getSouthWest(),a=t.getNorthEast()):i=a=t,i.lat>=n.lat&&a.lat<=r.lat&&i.lng>=n.lng&&a.lng<=r.lng}intersects(t){t=e.from(t);let n=this._southWest,r=this._northEast,i=t.getSouthWest(),a=t.getNorthEast(),o=a.lat>=n.lat&&i.lat<=r.lat,s=a.lng>=n.lng&&i.lng<=r.lng;return o&&s}overlaps(t){t=e.from(t);let n=this._southWest,r=this._northEast,i=t.getSouthWest(),a=t.getNorthEast(),o=a.lat>n.lat&&i.lat<r.lat,s=a.lng>n.lng&&i.lng<r.lng;return o&&s}toBBoxString(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(`,`)}equals(t,n){return t?(t=e.from(t),this._southWest.equals(t.getSouthWest(),n)&&this._northEast.equals(t.getNorthEast(),n)):!1}isValid(){return!!(this._southWest&&this._northEast)}};const B=String.raw`([+-]?\d+(?:\.\d+)?)\s*°?`,Ue=String.raw`(?:\s*[,;]\s*|\s+)`,We=RegExp(`^${B}${Ue}${B}$`),Ge=RegExp(`^([NSEW])\\s*${B}${Ue}([NSEW])\\s*${B}$`,`i`),Ke=RegExp(`^${B}\\s*([NSEW])${Ue}${B}\\s*([NSEW])$`,`i`),qe=/^[NSEW]$/i,Je=/^geo:([+-]?\d+(?:\.\d+)?),([+-]?\d+(?:\.\d+)?)(?:,([+-]?\d+(?:\.\d+)?))?(?:[;?].*)?$/i;var V=class e{constructor(t,n,r){if(!e.validate(t,n,r))throw Error(`Invalid LatLng object: (${t}, ${n})`);let i,a,o;t instanceof e?(i=t.lat,a=t.lng,o=t.alt):Array.isArray(t)&&typeof t[0]!=`object`?t.length===3?(i=t[0],a=t[1],o=t[2]):t.length===2&&(i=t[0],a=t[1]):typeof t==`object`&&`lat`in t?(i=t.lat,a=`lng`in t?t.lng:t.lon,o=t.alt):(i=t,a=n,o=r),this.lat=+i,this.lng=+a,o!==void 0&&(this.alt=+o)}static from(t,n,r){return t instanceof e?t:new e(t,n,r)}static validate(t,n,r){return t instanceof e||typeof t==`object`&&t&&`lat`in t?!0:t&&Array.isArray(t)&&typeof t[0]!=`object`?t.length===3||t.length===2:!(!t&&t!==0||!n&&n!==0)}static parse(t){t=t.trim();let n,r,i,a;if(a=Je.exec(t))[n,r,i]=a.slice(1).map(e=>e===void 0?void 0:Number(e));else if(a=We.exec(t))[n,r]=a.slice(1).map(Number);else if(a=Ge.exec(t)??Ke.exec(t)){let e=qe.test(a[1])?[[a[1],a[2]],[a[3],a[4]]]:[[a[2],a[1]],[a[4],a[3]]];for(let[t,i]of e){let e=t.toUpperCase(),a=Math.abs(Number(i))*(e===`S`||e===`W`?-1:1);if(e===`N`||e===`S`){if(n!==void 0)return null;n=a}else{if(r!==void 0)return null;r=a}}}return n===void 0||Math.abs(n)>90||Math.abs(r)>180?null:new e(n,r,i)}equals(t,n){return t?(t=e.from(t),Math.max(Math.abs(this.lat-t.lat),Math.abs(this.lng-t.lng))<=(n??1e-9)):!1}toString(e){return`LatLng(${l(this.lat,e)}, ${l(this.lng,e)})`}distanceTo(t){return Ye(this,e.from(t),6371e3)}wrap(){return new e(this.lat,s(this.lng,[-180,180],!0),this.alt)}toBounds(e){let t=180*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new z([this.lat-t,this.lng-n],[this.lat+t,this.lng+n])}};function Ye(e,t,n){let r=Math.PI/180,i=e.lat*r,a=t.lat*r,o=Math.sin((t.lat-e.lat)*r/2),s=Math.sin((t.lng-e.lng)*r/2),c=o*o+Math.cos(i)*Math.cos(a)*s*s;return n*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}var Xe=/* @__PURE__ */ t({_getBitCode:()=>ot,_getEdgeIntersection:()=>at,_projectRing:()=>lt,_sqClosestPointOnSegment:()=>H,clipSegment:()=>it,closestPointOnSegment:()=>$e,isFlat:()=>U,pointToSegmentDistance:()=>Qe,polylineCenter:()=>ct,simplify:()=>Ze});function Ze(e,t){if(!t||!e.length)return e.slice();let n=t*t;return e=nt(e,n),e=et(e,n),e}function Qe(e,t,n){return Math.sqrt(H(e,t,n,!0))}function $e(e,t,n){return H(e,t,n)}function et(e,t){let n=e.length,r=new Uint8Array(n);r[0]=r[n-1]=1,tt(e,r,t,0,n-1);let i,a=[];for(i=0;i<n;i++)r[i]&&a.push(e[i]);return a}function tt(e,t,n,r,i){let a=0,o,s,c;for(s=r+1;s<=i-1;s++)c=H(e[s],e[r],e[i],!0),c>a&&(o=s,a=c);a>n&&(t[o]=1,tt(e,t,n,r,o),tt(e,t,n,o,i))}function nt(e,t){let n=[e[0]],r=0;for(let i=1;i<e.length;i++)st(e[i],e[r])>t&&(n.push(e[i]),r=i);return r<e.length-1&&n.push(e[e.length-1]),n}let rt;function it(e,t,n,r,i){let a=e,o=t,s=r?rt:ot(e,n),c=ot(t,n),l,u,d;for(rt=c;;){if(!(s|c))return i&&(e!==a&&(e=e.round()),t!==o&&(t=t.round())),[e,t];if(s&c)return!1;l=s||c,u=at(e,t,l,n),d=ot(u,n),l===s?(e=u,s=d):(t=u,c=d)}}function at(e,t,n,r,i){let a=t.x-e.x,o=t.y-e.y,s=r.min,c=r.max,l,u;return n&8?(l=e.x+a*(c.y-e.y)/o,u=c.y):n&4?(l=e.x+a*(s.y-e.y)/o,u=s.y):n&2?(l=c.x,u=e.y+o*(c.x-e.x)/a):n&1&&(l=s.x,u=e.y+o*(s.x-e.x)/a),new g(l,u,i)}function ot(e,t){let n=0;return e.x<t.min.x?n|=1:e.x>t.max.x&&(n|=2),e.y<t.min.y?n|=4:e.y>t.max.y&&(n|=8),n}function st(e,t){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function H(e,t,n,r){let i=t.x,a=t.y,o=n.x-i,s=n.y-a,c,l=o*o+s*s;return l>0&&(c=((e.x-i)*o+(e.y-a)*s)/l,c>1?(i=n.x,a=n.y):c>0&&(i+=o*c,a+=s*c)),o=e.x-i,s=e.y-a,r?o*o+s*s:new g(i,a)}function U(e){return!Array.isArray(e[0])||typeof e[0][0]!=`object`&&e[0][0]!==void 0}function ct(e,t){let n=lt(e,t),r=n.length,i=0;for(let e=1;e<r;e++)i+=n[e-1].distanceTo(n[e]);i/=2;let a=n[0];for(let e=1,t=0;e<r;e++){let r=n[e-1],o=n[e],s=r.distanceTo(o);if(t+=s,t>i){let e=(t-i)/s;a=new g(o.x-e*(o.x-r.x),o.y-e*(o.y-r.y));break}}return t.unproject(a)}function lt(e,t){if(!e||e.length===0)throw Error(`latlngs not passed`);return U(e)?e.map(e=>t.project(V.from(e))):(console.warn(`latlngs are not flat! Only the first ring will be used`),lt(e[0],t))}function ut(e,t){return e=V.from(e),e.alt===void 0?[l(e.lng,t),l(e.lat,t)]:[l(e.lng,t),l(e.lat,t),l(e.alt,t)]}function dt(e,t,n,r){let i=e.map(e=>t?dt(e,U(e)?0:t-1,n,r):ut(e,r));return!t&&n&&i.length>0&&i.push(i[0].slice()),i}function W(e,t){return e.feature?{...e.feature,geometry:t}:ft(t)}function ft(e){return e.type===`Feature`||e.type===`FeatureCollection`?e:{type:`Feature`,properties:{},geometry:e}}function pt(e,t){return W(e,{type:`Point`,coordinates:ut(e.getLatLng(),t)})}var G=class e extends R{static defaultOptions={fill:!0,radius:10};constructor(t,n){super(),f(this,n),this._latlng=new V(t),this._radius=this.options.radius,this.callInitHooks(e)}setLatLng(e){let t=this._latlng;return this._latlng=new V(e),this.redraw(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})}getLatLng(){return this._latlng}setRadius(e){return this.options.radius=this._radius=e,this.redraw()}getRadius(){return this._radius}setStyle(e){return super.setStyle(e),e?.radius!==void 0&&this.setRadius(e.radius),this}_project(){this._point=this._map.latLngToLayerPoint(this._latlng)._round(),this._pxRadius=this._radius,this._updateBounds()}_updateBounds(){let e=this._pxRadius,t=this._pxRadiusY??e,n=this._clickTolerance(),r=[e+n,t+n];this._pxBounds=new I(this._point.subtract(r),this._point.add(r))}_update(){this._map&&this._updatePath()}_updatePath(){this._renderer._updateCircle(this)}_empty(){return this._pxRadius&&!this._renderer._bounds.intersects(this._pxBounds)}_containsPoint(e){return e.distanceTo(this._point)<=this._pxRadius+this._clickTolerance()}toGeoJSON(e){return pt(this,e)}};const mt=`http://www.w3.org/2000/svg`;var ht=class e extends N{static defaultOptions={position:`bottomright`,collapsed:!1,featureCount:!1,bar:!1};constructor(...t){super(...t),this._classifications=[],this._legendLayers=/* @__PURE__ */ new Set,this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-control-legend`),n=this._details=D(`details`,``,t),r=D(`summary`,`maplair-control-legend-title`,n);return r.textContent=P.translate(`Legend`),n.open=!this.options.collapsed,this._list=D(`div`,`maplair-control-legend-list`,n),w(t),C(t),this._container=t,e.on(`layeradd layerremove`,this._scheduleUpdate,this),this._update(),t}onRemove(e){e.off(`layeradd layerremove`,this._scheduleUpdate,this),cancelAnimationFrame(this._frame),this._frame=null;for(let e of this._legendLayers)e.off(`legendchange`,this._scheduleUpdate,this);this._legendLayers.clear()}addClassification(e,t){return this._classifications.push({layer:e,classification:t}),e.on(`layeradd layerremove`,this._scheduleUpdate,this),this._scheduleUpdate(),this}removeClassification(e){return this._classifications=this._classifications.filter(t=>t.layer!==e),e.off(`layeradd layerremove`,this._scheduleUpdate,this),this._scheduleUpdate(),this}_scheduleUpdate(){this._map&&!this._frame&&(this._frame=requestAnimationFrame(()=>{this._frame=null,this._update()}))}_update(){let e=this._map;if(!e)return;let t=this._classifications.filter(({layer:t})=>e.hasLayer(t)).map(({layer:e,classification:t})=>this._renderClassification(e,t)),n=new Set(Object.values(e._layers).filter(e=>e.getLegend));for(let e of this._legendLayers)n.has(e)||e.off(`legendchange`,this._scheduleUpdate,this);for(let e of n){this._legendLayers.has(e)||e.on(`legendchange`,this._scheduleUpdate,this);let n=e.getLegend();if(n){let e=D(`div`,`maplair-control-legend-section`);typeof n==`string`?e.innerHTML=n:e.append(n),t.push(e)}}this._legendLayers=n,this._list.replaceChildren(...t),this._container.hidden=!t.length}_renderClassification(e,t){let n=e.getLayers(),r=t.featureCount(n),{featureCount:i,bar:a}=this.options,o=D(`div`,`maplair-control-legend-section`),{name:s}=t.options,c=r.reduce((e,t)=>e+(t.counted?t.count:0),0);s&&(D(`div`,`maplair-control-legend-name`,o).textContent=s),i&&(D(`div`,`maplair-control-legend-total`,o).textContent=P.translate(`{n} features`,{n:c}));let l=/* @__PURE__ */ new Map;for(let e of n){let n=t.classify(e),i=r.find(e=>e.classes.includes(n));if(i&&!l.has(i)&&l.set(i,e),l.size===r.length)break}let u=D(`ul`,`maplair-control-legend-items`,o);for(let e of r){let t=D(`li`,``,u);t.append(_t(l.get(e)??n[0],e.symbol,!!l.get(e))),D(`span`,`maplair-control-legend-label`,t).textContent=e.legend,i&&e.counted&&(D(`span`,`maplair-control-legend-count`,t).textContent=gt(e))}if(a&&c){let e=D(`div`,`maplair-control-legend-bar`,o);e.setAttribute(`role`,`img`),e.setAttribute(`aria-label`,r.filter(e=>e.counted&&e.count).map(e=>`${e.legend}: ${gt(e)}`).join(`, `));for(let t of r){if(!t.counted||!t.count)continue;let n=D(`div`,``,e);n.style.flexGrow=t.count,n.style.backgroundColor=t.symbol.fillColor??t.symbol.color??``,n.title=`${t.legend}: ${gt(t)}`}}return o}};function gt({count:e,share:t}){return`${e} (${new Intl.NumberFormat(P.getLocale()??void 0,{style:`percent`,maximumFractionDigits:1}).format(t)})`}function _t(e,t,n){for(;e?.getLayers;)e=e.getLayers()[0];e?.setStyle||(e=void 0);let r=e?.options??new G([0,0]).options,i=Object.assign(Object.create(r),e&&n?{}:t),a=document.createElementNS(mt,`svg`);a.setAttribute(`class`,`maplair-control-legend-patch`),a.setAttribute(`width`,16),a.setAttribute(`height`,16),a.setAttribute(`viewBox`,`0 0 16 16`),a.setAttribute(`aria-hidden`,`true`);let o;return o=e?.getLatLngs&&i.fill?vt(`rect`,{x:2,y:2,width:12,height:12}):e?.getLatLngs?vt(`line`,{x1:1,y1:8,x2:15,y2:8}):vt(`circle`,{cx:8,cy:8,r:6}),o.setAttribute(`fill`,i.fill?i.fillColor??i.color:`none`),o.setAttribute(`fill-opacity`,i.fillOpacity),o.setAttribute(`stroke`,i.stroke?i.color:`none`),o.setAttribute(`stroke-opacity`,i.opacity),o.setAttribute(`stroke-width`,Math.min(i.weight,4)),i.dashArray&&o.setAttribute(`stroke-dasharray`,i.dashArray),a.append(o),a}function vt(e,t){let n=document.createElementNS(mt,e);for(let[e,r]of Object.entries(t))n.setAttribute(e,r);return n}var yt=class{static projection=void 0;static transformation=void 0;static latLngToPoint(e,t){let n=this.projection.project(e),r=this.scale(t);return this.transformation._transform(n,r)}static pointToLatLng(e,t){let n=this.scale(t),r=this.transformation.untransform(e,n);return this.projection.unproject(r)}static project(e){return this.projection.project(e)}static unproject(e){return this.projection.unproject(e)}static scale(e){return 256*2**e}static zoom(e){return Math.log(e/256)/Math.LN2}static getProjectedBounds(e){if(this.infinite)return null;let t=this.projection.bounds,n=this.scale(e);return new I(this.transformation.transform(t.min,n),this.transformation.transform(t.max,n))}static infinite=!1;static wrapLatLng(e){e=V.from(e);let t=this.wrapLng?s(e.lng,this.wrapLng,!0):e.lng,n=this.wrapLat?s(e.lat,this.wrapLat,!0):e.lat,r=e.alt;return new V(n,t,r)}static wrapLatLngBounds(e){e=new z(e);let t=e.getCenter(),n=this.wrapLatLng(t),r=t.lat-n.lat,i=t.lng-n.lng;if(r===0&&i===0)return e;let a=e.getSouthWest(),o=e.getNorthEast();return new z(new V(a.lat-r,a.lng-i),new V(o.lat-r,o.lng-i))}},K=class extends yt{static wrapLng=[-180,180];static R=6371e3;static distance(e,t){return Ye(e,t,this.R)}};const bt=6378137,xt={R:bt,MAX_LATITUDE:85.0511287798,project(e){e=V.from(e);let t=Math.PI/180,n=this.MAX_LATITUDE,r=Math.max(Math.min(n,e.lat),-n),i=Math.sin(r*t);return new g(this.R*e.lng*t,this.R*Math.log((1+i)/(1-i))/2)},unproject(e){e=g.from(e);let t=180/Math.PI;return new V((2*Math.atan(Math.exp(e.y/this.R))-Math.PI/2)*t,e.x*t/this.R)},bounds:/* @__PURE__ */ (()=>{let e=bt*Math.PI;return new I([-e,-e],[e,e])})()};var St=class{constructor(e,t,n,r){Array.isArray(e)?(this._a=e[0],this._b=e[1],this._c=e[2],this._d=e[3]):(this._a=e,this._b=t,this._c=n,this._d=r)}transform(e,t){return this._transform(new g(e),t)}_transform(e,t){return t||=1,e.x=t*(this._a*e.x+this._b),e.y=t*(this._c*e.y+this._d),e}untransform(e,t){return t||=1,new g((e.x/t-this._b)/this._a,(e.y/t-this._d)/this._c)}},Ct=class extends K{static code=`EPSG:3857`;static projection=xt;static transformation=/* @__PURE__ */ (()=>{let e=.5/(Math.PI*xt.R);return new St(e,.5,-e,.5)})()},wt=class extends Ct{static code=`EPSG:900913`},Tt=class e extends Ne{constructor(...t){super(...t),this.callInitHooks(e)}run(e,t,n,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=n??.25,this._easeOutPower=1/Math.max(r??.5,.2),this._startPos=j(e),this._offset=t.subtract(this._startPos),this._startTime=Date.now(),this.fire(`start`),this._animate()}stop(){this._inProgress&&(this._step(!0),this._complete())}_animate(){this._animId=requestAnimationFrame(this._animate.bind(this)),this._step()}_step(e){let t=Date.now()-this._startTime,n=this._duration*1e3;t<n?this._runFrame(this._easeOut(t/n),e):(this._runFrame(1),this._complete())}_runFrame(e,t){let n=this._startPos.add(this._offset.multiplyBy(e));t&&n._round(),A(this._el,n),this.fire(`step`)}_complete(){cancelAnimationFrame(this._animId),this._inProgress=!1,this.fire(`end`)}_easeOut(e){return 1-(1-e)**this._easeOutPower}},Et=class e extends N{static defaultOptions={position:`topleft`,zoomInText:`<span aria-hidden="true">+</span>`,zoomOutText:`<span aria-hidden="true">−</span>`};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=`maplair-control-zoom`,n=D(`div`,`${t} maplair-bar`),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,P.translate(`Zoom in`),`${t}-in`,n,e=>this._zoom(e,1)),this._zoomOutButton=this._createButton(r.zoomOutText,P.translate(`Zoom out`),`${t}-out`,n,e=>this._zoom(e,-1)),this._updateDisabled(),e.on(`zoomend zoomlevelschange`,this._updateDisabled,this),n}onRemove(e){e.off(`zoomend zoomlevelschange`,this._updateDisabled,this)}disable(){return this._disabled=!0,this._updateDisabled(),this}enable(){return this._disabled=!1,this._updateDisabled(),this}_zoom(e,t){let n=this._map;!this._disabled&&(t>0?n._zoom<n.getMaxZoom():n._zoom>n.getMinZoom())&&(n._setUserEvent(e),n.zoomIn(t*n.options.zoomDelta*(e.shiftKey?3:1)))}_createButton(e,t,n,r,i){let a=D(`button`,n,r);return a.type=`button`,a.innerHTML=e,a.title=t,a.setAttribute(`aria-label`,t),w(a),y(a,`click`,e=>{E(e),i.call(this,e),this._refocusOnMap(e)}),a}_updateDisabled(){let e=this._map;for(let[t,n]of[[this._zoomInButton,e.getMaxZoom()],[this._zoomOutButton,e.getMinZoom()]]){let r=this._disabled||e._zoom===n;t.classList.toggle(`maplair-disabled`,r),t.setAttribute(`aria-disabled`,`${r}`)}}static register(t){t.mergeOptions({zoomControl:!0}),t.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new e,this.addControl(this.zoomControl))})}},Dt=class e extends F{constructor(t,n){super(),f(this,n),this._layers={};for(let e of t??[])this.addLayer(e);this.callInitHooks(e)}addLayer(e){let t=this.getLayerId(e);return this._layers[t]=e,this._map?.addLayer(e),this}removeLayer(e){let t=typeof e==`number`?e:this.getLayerId(e);return this._map&&this._layers[t]&&this._map.removeLayer(this._layers[t]),delete this._layers[t],this}hasLayer(e){return(typeof e==`number`?e:this.getLayerId(e))in this._layers}clearLayers(){return this.eachLayer(this.removeLayer,this)}onAdd(e){this.eachLayer(e.addLayer,e)}onRemove(e){this.eachLayer(e.removeLayer,e)}eachLayer(e,t){for(let n of Object.values(this._layers))e.call(t,n);return this}getLayer(e){return this._layers[e]}getLayers(){let e=[];return this.eachLayer(e.push,e),e}setZIndex(e){return this.eachLayer(t=>t.setZIndex?.(e))}getLayerId(e){return a(e)}toMultiPoint(e){let t=[];return this.eachLayer(n=>{t.push(n.toGeoJSON(e).geometry.coordinates)}),W(this,{type:`MultiPoint`,coordinates:t})}toGeoJSON(e){let t=this.feature?.geometry?.type;if(t===`MultiPoint`)return this.toMultiPoint(e);let n=t===`GeometryCollection`,r=[];return this.eachLayer(t=>{if(t.toGeoJSON){let i=t.toGeoJSON(e);if(n)r.push(i.geometry);else{let e=ft(i);e.type===`FeatureCollection`?r.push(...e.features):r.push(e)}}}),n?W(this,{geometries:r,type:`GeometryCollection`}):{type:`FeatureCollection`,features:r}}},q=class e extends Dt{constructor(...t){super(...t),this.callInitHooks(e)}addLayer(e){return this.hasLayer(e)?this:(e.addEventParent(this),super.addLayer(e),this.fire(`layeradd`,{layer:e}))}removeLayer(e){return this.hasLayer(e)?(e in this._layers&&(e=this._layers[e]),e.removeEventParent(this),super.removeLayer(e),this.fire(`layerremove`,{layer:e})):this}setStyle(e){return this.eachLayer(t=>t.setStyle?.(e))}setInteractive(e){return f(this,{interactive:!!e}),this.eachLayer(t=>t.setInteractive?.(e))}bringToFront(){return this.eachLayer(e=>e.bringToFront?.())}bringToBack(){return this.eachLayer(e=>e.bringToBack?.())}getBounds(){let t=new z;for(let n of Object.values(this._layers))n.getBounds?t.extend(n.getBounds()):n.getLatLng?t.extend(n.getLatLng()):n instanceof Dt&&t.extend(e.prototype.getBounds.call(n));return t}};const Ot={_initOverlay(e,t,n,r){let i=t;return i instanceof e||(i=new e(r).setContent(t)),n&&i.setLatLng(n),i}},kt={_initOverlay(e,t,n,r){let i=n;return i instanceof e?(f(i,r),i._source=this):(i=t&&!r?t:new e(r,this),i.setContent(n)),i}};var J=class e extends F{static defaultOptions={interactive:!1,offset:[0,0],className:``,pane:void 0,overflow:!1,content:``};constructor(t,n){super(),t instanceof V||Array.isArray(t)?(this._latlng=new V(t),f(this,n)):(f(this,t),this._source=n),this.options.content&&(this._content=this.options.content),this.callInitHooks(e)}openOn(e){return e=arguments.length?e:this._source._map,e.hasLayer(this)||e.addLayer(this),this}close(){return this._map?.removeLayer(this),this}toggle(e){return this._map?this.close():(arguments.length?this._source=e:e=this._source,this._prepareOpen(),this.openOn(e._map)),this}onAdd(e){this._container||this._initLayout(),e._fadeAnimated&&(this._container.style.opacity=`0`),clearTimeout(this._removeTimeout),this.getPane().appendChild(this._container),this.options.overflow&&(this._container.classList.add(`maplair-overflow`),this._container.popover=`manual`,this._container.showPopover(),this._onPageChange??=()=>this._updatePosition(),document.addEventListener(`scroll`,this._onPageChange,{capture:!0,passive:!0}),window.addEventListener(`resize`,this._onPageChange,{passive:!0})),this.update(),e._fadeAnimated&&(this._container.style.opacity=`1`),this.options.overflow||this.bringToFront(),this.options.interactive&&(this._container.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._container))}onRemove(e){this.options.overflow&&(document.removeEventListener(`scroll`,this._onPageChange,{capture:!0}),window.removeEventListener(`resize`,this._onPageChange)),e._fadeAnimated?(this._container.style.opacity=`0`,this._removeTimeout=setTimeout(()=>this._container.remove(),200)):this._container.remove(),this.options.interactive&&(this._container.classList.remove(`maplair-interactive`),this.removeInteractiveTarget(this._container))}_updateInteractive(){this._container.classList.toggle(`maplair-interactive`,this.options.interactive),this.options.interactive?this.addInteractiveTarget(this._container):this.removeInteractiveTarget(this._container)}getLatLng(){return this._latlng}setLatLng(e){return this._latlng=new V(e),this._map&&(this._updatePosition(),this._adjustPan()),this}getContent(){return this._content}setContent(e){return this._content=e,this.update(),this}getElement(){return this._container}update(){this._map&&(this._container.style.visibility=`hidden`,this._updateContent(),this._updateLayout(),this._updatePosition(),this._container.style.visibility=``,this._adjustPan())}getEvents(){let e={zoom:this._updatePosition,viewreset:this._updatePosition,zoomanim:this._animateZoom};return this.options.overflow&&(e.move=this._updatePosition),e}isOpen(){return!!this._map&&this._map.hasLayer(this)}bringToFront(){return this._map&&(O(this._container),this._restackPopovers()),this}bringToBack(){return this._map&&(Se(this._container),this._restackPopovers()),this}_restackPopovers(){if(this.options.overflow)for(let e of this.getPane().children)e.classList.contains(`maplair-overflow`)&&(e.matches(`:popover-open`)&&e.hidePopover(),e.showPopover())}_prepareOpen(e){let t=this._source;if(!t._map)return!1;if(t instanceof q){t=null;for(let e of Object.values(this._source._layers))if(e._map){t=e;break}if(!t)return!1;this._source=t}if(!e){if(t.getCenter)e=t.getCenter();else if(t.getLatLng)e=t.getLatLng();else if(t.getBounds)e=t.getBounds().getCenter();else throw Error(`Unable to get source layer LatLng.`)}return this.setLatLng(e),this._map&&this.update(),!0}_updateContent(){if(!this._content)return;let e=this._contentNode,t=typeof this._content==`function`?this._content(this._source??this):this._content;if(typeof t==`string`)e.innerHTML=t;else{for(;e.hasChildNodes();)e.removeChild(e.firstChild);e.appendChild(t)}this.fire(`contentupdate`)}_updatePosition(){if(!this._map)return;let e=this._map.latLngToLayerPoint(this._latlng)._round(),t=g.from(this.options.offset);this._setContainerPosition(e.add(this._getAnchor()));let n=this._containerBottom=-t.y,r=this._containerLeft=-Math.round(this._containerWidth/2)+t.x;this.options.overflow?(this._container.style.top=`auto`,this._container.style.bottom=`calc(100% + ${n}px)`):this._container.style.bottom=`${n}px`,this._container.style.left=`${r}px`}_setContainerPosition(e){if(this._containerPos=e,this.options.overflow){let t=this._map._container,n=t.getBoundingClientRect();e=this._map.layerPointToContainerPoint(e)._add(new g(n.left+t.clientLeft,n.top+t.clientTop))}A(this._container,e)}_getContainerPosition(){return this._containerPos??new g(0,0)}_getAnchor(){return[0,0]}static register(e){e.include(Ot),F.include(kt)}};const At={openPopup(e,t,n){return this._initOverlay(Mt,e,t,n).openOn(this),this},closePopup(e){return e=arguments.length?e:this._popup,e?.close(),this}},jt={bindPopup(e,t){return this._popup=this._initOverlay(Mt,this._popup,e,t),this.on({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),this},unbindPopup(){return this._popup&&=(this.off({click:this._openPopup,remove:this.closePopup,move:this._movePopup}),null),this},openPopup(e){return this._popup&&(this instanceof q||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup(){return this._popup?.close(),this},togglePopup(){return this._popup?.toggle(this),this},isPopupOpen(){return this._popup?.isOpen()??!1},setPopupContent(e){return this._popup?.setContent(e),this},getPopup(){return this._popup},_openPopup(e){if(!this._popup||!this._map)return;S(e);let t=e.propagatedFrom??e.target;this._popup._source===t&&!(t instanceof R)?this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng):(this._popup._source=t,this.openPopup(e.latlng))},_movePopup(e){this._popup.setLatLng(e.latlng)}};var Mt=class e extends J{static defaultOptions={pane:`popupPane`,offset:[0,7],maxWidth:300,minWidth:50,maxHeight:null,autoPan:!0,autoPanPaddingTopLeft:null,autoPanPaddingBottomRight:null,autoPanPadding:[5,5],keepInView:!1,closeButton:!0,autoClose:!0,closeOnEscapeKey:!0,className:``,trackResize:!0};constructor(...t){super(...t),this.callInitHooks(e)}openOn(e){return e=arguments.length?e:this._source._map,!e.hasLayer(this)&&e._popup&&e._popup.options.autoClose&&e.removeLayer(e._popup),e._popup=this,super.openOn(e)}onAdd(e){let t=document.activeElement;this._returnFocus=e._container.contains(t)&&!this._container?.contains(t)?t:null,super.onAdd(e),this._source?._clickedByKeyboard&&(this._closeButton||(this._container.tabIndex=-1),(this._closeButton??this._container).focus({preventScroll:!0})),e.fire(`popupopen`,{popup:this}),this._source&&(this._source.fire(`popupopen`,{popup:this},!0),this._source instanceof R||this._source.on(`preclick`,S))}onRemove(e){this._container.contains(document.activeElement)&&this._returnFocus?.isConnected&&this._returnFocus.focus({preventScroll:!0}),this._returnFocus=null,super.onRemove(e),e.fire(`popupclose`,{popup:this}),this._source&&(this._source.fire(`popupclose`,{popup:this},!0),this._source instanceof R||this._source.off(`preclick`,S))}getEvents(){let e=super.getEvents();return(this.options.closeOnClick??this._map.options.closePopupOnClick)&&(e.preclick=this.close),this.options.keepInView&&(e.moveend=this._adjustPan),e}_initLayout(){let e=`maplair-popup`,t=this._container=D(`div`,`${e} ${this.options.className||``} maplair-zoom-animated`),n=this._wrapper=D(`div`,`${e}-content-wrapper`,t);if(this._contentNode=D(`div`,`${e}-content`,n),w(t),C(this._contentNode),y(t,`contextmenu`,S),this._tipContainer=D(`div`,`${e}-tip-container`,t),this._tip=D(`div`,`${e}-tip`,this._tipContainer),this.options.closeButton){let n=this._closeButton=D(`button`,`${e}-close-button`,t);n.type=`button`,n.setAttribute(`aria-label`,P.translate(`Close popup`)),n.innerHTML=`<span aria-hidden="true">×</span>`,y(n,`click`,e=>{e.preventDefault(),this.close()})}this.options.trackResize&&(this._resizeObserver=new ResizeObserver(()=>{this._map&&(this._updateLayout(),this._updatePosition(),this._adjustPan())}),this._resizeObserver.observe(this._contentNode))}_updateLayout(){let e=this._contentNode,t=e.style;t.maxWidth=`${this.options.maxWidth}px`,t.minWidth=`${this.options.minWidth}px`,t.height=``;let n=this.options.maxHeight,r=!!n&&e.offsetHeight>n;r&&(t.height=`${n}px`),e.classList.toggle(`maplair-popup-scrolled`,r),this._containerWidth=this._container.offsetWidth,this._containerHeight=this._container.offsetHeight,this._containerMarginBottom=parseInt(getComputedStyle(this._container).marginBottom,10)||0}_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._getAnchor();this._setContainerPosition(t.add(n))}_adjustPan(){if(!this.options.autoPan||(this._map._panAnim?.stop(),!this._map))return;if(this._autopanning){this._autopanning=!1;return}let e=this._map,t=this._containerMarginBottom??(parseInt(getComputedStyle(this._container).marginBottom,10)||0),n=this._containerHeight+t,r=this._containerWidth,i=new g(this._containerLeft,-n-this._containerBottom);i._add(this._getContainerPosition());let a=e.layerPointToContainerPoint(i),o=g.from(this.options.autoPanPadding),s=g.from(this.options.autoPanPaddingTopLeft??o),c=g.from(this.options.autoPanPaddingBottomRight??o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}_getAnchor(){return new g(this._source?._getPopupAnchor?this._source._getPopupAnchor():[0,0])}static register(e){e.mergeOptions({closePopupOnClick:!0}),e.include(At),F.include(jt)}};const Nt=[`top`,`bottom`,`center`,`right`,`left`];function Pt(e,t,n,r){return Math.max(0,n-e)-Math.max(0,e+t-r)}function Ft(e,t){let n=Math.max(0,t/2-12);return Math.round(Math.min(n,Math.max(-n,e)))}const It={openTooltip(e,t,n){return this._initOverlay(Y,e,t,n).openOn(this),this},closeTooltip(e){return e.close(),this}},Lt={bindTooltip(e,t){let n=this.isTooltipOpen()?null:this._tooltip;return this._tooltip&&this.unbindTooltip(),this._tooltip=this._initOverlay(Y,n,e,t),this._initTooltipInteractions(),this._tooltip.options.permanent&&this._map&&this._map.hasLayer(this)&&this.openTooltip(),this},unbindTooltip(){return this._tooltip&&=(this._initTooltipInteractions(!0),this.closeTooltip(),null),this},_initTooltipInteractions(e){let{permanent:t,sticky:n}=this._tooltip.options,r={remove:this.closeTooltip,move:this._moveTooltip};t?r.add=this._openTooltip:(r.pointerover=this._openTooltip,r.pointerout=this.closeTooltip,r.click=this._openTooltip,r.add=this._toggleFocusListeners,this._map&&this._toggleFocusListeners(!e)),n&&(r.pointermove=this._moveTooltip),this[e?`off`:`on`](r)},openTooltip(e){return this._tooltip&&(this instanceof q||(this._tooltip._source=this),this._tooltip._prepareOpen(e)&&(this._tooltip.openOn(this._map),this.getElement?this._setAriaDescribedByOnLayer(this):this.eachLayer&&this.eachLayer(this._setAriaDescribedByOnLayer,this))),this},closeTooltip(){return this._tooltip?.close(),this},toggleTooltip(){return this._tooltip?.toggle(this),this},isTooltipOpen(){return this._tooltip?.isOpen()??!1},setTooltipContent(e){return this._tooltip?.setContent(e),this},getTooltip(){return this._tooltip},_toggleFocusListeners(e){this.getElement?this._addFocusListenersOnLayer(this,!e):this.eachLayer&&this.eachLayer(t=>this._addFocusListenersOnLayer(t,!e),this)},_addFocusListenersOnLayer(e,t){let n=typeof e.getElement==`function`&&e.getElement();if(n){let r=t?x:y;t||(n._maplair_focus_handler&&x(n,`focus`,n._maplair_focus_handler,this),n._maplair_focus_handler=()=>{this._tooltip&&(this._tooltip._source=e,this.openTooltip())}),n._maplair_focus_handler&&r(n,`focus`,n._maplair_focus_handler,this),r(n,`blur`,this.closeTooltip,this),t&&delete n._maplair_focus_handler}},_setAriaDescribedByOnLayer(e){(typeof e.getElement==`function`&&e.getElement())?.setAttribute?.(`aria-describedby`,this._tooltip._container.id)},_openTooltip(e){this._tooltip&&this._map&&(this._map.dragging?.moving()?e.type===`add`&&!this._moveEndOpensTooltip&&(this._moveEndOpensTooltip=!0,this._map.once(`moveend`,()=>{this._moveEndOpensTooltip=!1,this._openTooltip(e)})):(this._tooltip._source=e.propagatedFrom??e.target,this.openTooltip(this._tooltip.options.sticky?e.latlng:void 0)))},_moveTooltip(e){let t=e.latlng,n,r;this._tooltip.options.sticky&&e.originalEvent&&(n=this._map.pointerEventToContainerPoint(e.originalEvent),r=this._map.containerPointToLayerPoint(n),t=this._map.layerPointToLatLng(r)),this._tooltip.setLatLng(t)}};var Y=class e extends J{static defaultOptions={pane:`tooltipPane`,offset:[0,0],direction:`auto`,permanent:!1,sticky:!1,opacity:.9};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){super.onAdd(e),this.setOpacity(this.options.opacity),e.fire(`tooltipopen`,{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire(`tooltipopen`,{tooltip:this},!0))}onRemove(e){super.onRemove(e),e.fire(`tooltipclose`,{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire(`tooltipclose`,{tooltip:this},!0))}getEvents(){let e=super.getEvents();return this.options.permanent||(e.preclick=this.close),e}_initLayout(){let e=`maplair-tooltip ${this.options.className||``} maplair-zoom-animated`;this._contentNode=this._container=D(`div`,e),this._container.setAttribute(`role`,`tooltip`),this._container.setAttribute(`id`,`maplair-tooltip-${a(this)}`)}_updateLayout(){}_adjustPan(){}update(){this._autoDirection=void 0,super.update()}_setPosition(e){let t=this.options.direction,n=new g(0,0),r=this._container,i=r.offsetWidth,a=r.offsetHeight,o=new g(this.options.offset),s=this._getAnchor();Nt.includes(t)||({direction:t,shift:n}=this._getAutoPlacement(e,o,s,i,a),t===`left`&&(o.x=-o.x,s.x=-s.x));let c=i/2,l=a/2;t===`top`?l=a:t===`bottom`?l=0:t===`right`?c=0:t===`left`&&(c=i),e=e.subtract(new g(c,l,!0)).add(o).add(s).add(n),r.classList.remove(`maplair-tooltip-right`,`maplair-tooltip-left`,`maplair-tooltip-top`,`maplair-tooltip-bottom`),r.classList.add(`maplair-tooltip-${t}`);let u=t===`top`||t===`bottom`?Ft(-n.x,i):Ft(-n.y,a);u?r.style.setProperty(`--maplair-tooltip-tip-shift`,`${u}px`):r.style.removeProperty(`--maplair-tooltip-tip-shift`),this._setContainerPosition(e)}_getAutoPlacement(e,t,n,r,i){let a=this._getAutoArea(),o=this._map.layerPointToContainerPoint(e),s=o.x+t.x+n.x,c=o.y+t.y+n.y,l={right:a.max.x-s-r-6,left:o.x-t.x-n.x-a.min.x-r-6,top:c-a.min.y-i-6,bottom:a.max.y-c-i-6};if(!this._autoDirection){let e=o.x<(a.min.x+a.max.x)/2?[`right`,`left`]:[`left`,`right`],t=l.right>=l.left?`right`:`left`;this._autoDirection=[...e,`top`,`bottom`].find(e=>l[e]>=0&&(e===`right`||e===`left`||r<=a.max.x-a.min.x))??t}let u=this._autoDirection;return{direction:u,shift:u===`top`||u===`bottom`?new g(Pt(s-r/2,r,a.min.x,a.max.x),0):new g(0,Pt(c-i/2,i,a.min.y,a.max.y))}}_getAutoArea(){let e=this._map,t=new g(0,0),n=e.getSize();if(this.options.overflow){let r=e._container,i=r.getBoundingClientRect(),a=new g(i.left+r.clientLeft,i.top+r.clientTop),o=document.documentElement;t=t.subtract(a),n=new g(o.clientWidth,o.clientHeight).subtract(a)}let r=new g(4,4);return{min:t.add(r),max:n.subtract(r)}}_updatePosition(){let e=this._map.latLngToLayerPoint(this._latlng)._round();this._setPosition(e)}setOpacity(e){this.options.opacity=e,this._container&&(this._container.style.opacity=`${e}`)}_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center);this._setPosition(t)}_getAnchor(){return new g(this._source?._getTooltipAnchor&&!this.options.sticky?this._source._getTooltipAnchor():[0,0])}static register(e){e.include(It),F.include(Lt)}},Rt=/* @__PURE__ */ t({register:()=>Bt});const zt={getRenderer(e){let t=e.options.renderer??this._getPaneRenderer(e)??this.options.renderer??(this._renderer??=e._createRenderer?.());return t&&!this.hasLayer(t)&&this.addLayer(t),t},_getPaneRenderer(e){let t=e.options.pane;if(t===`overlayPane`||t===void 0)return;let n=this._paneRenderers[t];if(!n){let r=this.options.renderer?.constructor;n=r?new r({...this.options.renderer.options,pane:t}):e._createRenderer({pane:t}),this._paneRenderers[t]=n}return n}};function Bt(e){e.include(zt),e.addInitHook(function(){this.options.preferCanvas!==void 0&&console.error(`MaplairMap: preferCanvas option has been removed. Use renderer: new Canvas() instead.`)})}var X=class e extends h{constructor(t){super(),this._map=t,this.callInitHooks(e)}enable(){return this._enabled||(this._enabled=!0,this.addHooks()),this}disable(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this}enabled(){return!!this._enabled}addHooks(){}removeHooks(){}static addTo(e,t){return e.addHandler(t,this),this}},Vt=class e extends X{constructor(t){super(t),this.callInitHooks(e)}addHooks(){y(this._map._container,`pointerdown`,this._onPointerDown,this)}removeHooks(){x(this._map._container,`pointerdown`,this._onPointerDown,this)}moved(){return this._moved}_resetState(){clearTimeout(this._resetStateTimeout),this._moved=!1}_toggleListeners(e){e(this._map._container,{contextmenu:E,pointermove:this._onPointerMove,pointerup:this._onPointerUp},this),e(document,`keydown`,this._onKeyDown,this)}_onPointerDown(e){if(!e.shiftKey||e.button!==0)return!1;this._resetState(),T(e),this._startPoint=this._map.pointerEventToContainerPoint(e),this._toggleListeners(y)}_onPointerMove(e){let t=this._map;this._moved||(this._moved=!0,this._box=D(`div`,`maplair-zoom-box`,t._container),t._container.classList.add(`maplair-crosshair`),t.fire(`boxzoomstart`)),this._point=t.pointerEventToContainerPoint(e);let n=new I(this._point,this._startPoint),r=n.getSize();A(this._box,n.min),this._box.style.width=`${r.x}px`,this._box.style.height=`${r.y}px`}_finish(){this._moved&&(this._box.remove(),this._map._container.classList.remove(`maplair-crosshair`)),this._toggleListeners(x)}_onPointerUp(e){if(e.button!==0||(this._finish(),!this._moved))return;this._resetStateTimeout=setTimeout(()=>this._resetState(),0);let t=new z(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map._setUserEvent(e),this._map.getBoundsZoom(t)!==1/0&&this._map.fitBounds(t),this._map.fire(`boxzoomend`,{boxZoomBounds:t})}_onKeyDown(e){e.code===`Escape`&&(this._finish(),this._resetState())}static register(t){t.mergeOptions({boxZoom:!0}),t.addInitHook(`addHandler`,`boxZoom`,e)}},Ht=class e extends X{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){this._map.on(`dblclick`,this._onDoubleClick,this)}removeHooks(){this._map.off(`dblclick`,this._onDoubleClick,this)}_onDoubleClick(e){let t=this._map,n=t.getZoom(),r=t.options.zoomDelta,i=e.originalEvent.shiftKey?n-r:n+r;t._setUserEvent(e.originalEvent),t.options.doubleClickZoom===`center`?t.setZoom(i):t.setZoomAround(e.containerPoint,i)}static register(t){t.mergeOptions({doubleClickZoom:!0}),t.addInitHook(`addHandler`,`doubleClickZoom`,e)}},Z=class e extends Ne{static defaultOptions={clickTolerance:3};constructor(t,n,r){if(typeof r==`boolean`)throw Error(`Draggable: the preventOutline argument is removed in Maplair. Pass options as the third argument.`);super(),f(this,r),this._element=t,this._dragStartTarget=n??t,this.callInitHooks(e)}enable(){this._enabled||=(y(this._dragStartTarget,`pointerdown`,this._onDown,this),!0)}disable(){this._enabled&&(e._dragging===this&&this.finishDrag(!0),x(this._dragStartTarget,`pointerdown`,this._onDown,this),this._enabled=!1,this._moved=!1)}_onDown(t){if(this._moved=!1,this._element.classList.contains(`maplair-zoom-anim`))return;let n=v().length;if(n>1){e._dragging===this&&this.finishDrag();return}if(e._dragging||t.shiftKey||t.button!==0&&t.pointerType!==`touch`||(e._dragging=this,we(),this._moving))return;!n&&t.isTrusted&&t.target.setPointerCapture(t.pointerId),this.fire(`down`);let r=Ee(this._element);this._startPoint=new g(t.clientX,t.clientY),this._startPos=j(this._element),this._parentScale=M(r),y(this._dragStartTarget,`pointermove`,this._onMove,this),y(this._dragStartTarget,`pointerup pointercancel lostpointercapture`,this._onUp,this)}_onMove(e){if(v().length>1){this._moved=!0;return}let t=new g(e.clientX,e.clientY)._subtract(this._startPoint),n=Math.abs(t.x)+Math.abs(t.y);!this._moved&&(!n||n<this.options.clickTolerance)||(t.x/=this._parentScale.x,t.y/=this._parentScale.y,e.cancelable&&e.preventDefault(),this._moved||(this.fire(`dragstart`,{originalEvent:e}),this._moved=!0,this._draggingContainer=this._element.closest(`.maplair-container`)??this._element,this._draggingContainer.classList.add(`maplair-dragging`),this._lastTarget=e.target,this._lastTarget.classList.add(`maplair-drag-target`)),this._newPos=this._startPos.add(t),this._moving=!0,this._lastEvent=e,this._updatePosition())}_updatePosition(){let e={originalEvent:this._lastEvent};this.fire(`predrag`,e);let t=window.devicePixelRatio;this._newPos=this._newPos.multiplyBy(t)._round()._divideBy(t),A(this._element,this._newPos),this.fire(`drag`,e)}_onUp(e){e.type===`lostpointercapture`&&e.buttons||this.finishDrag()}finishDrag(t){this._draggingContainer?.classList.remove(`maplair-dragging`),this._draggingContainer=null,this._lastTarget&&=(this._lastTarget.classList.remove(`maplair-drag-target`),null),x(this._dragStartTarget,`pointermove`,this._onMove,this),x(this._dragStartTarget,`pointerup pointercancel lostpointercapture`,this._onUp,this),Te();let n=this._moved&&this._moving;this._moving=!1,e._dragging=!1,n&&this.fire(`dragend`,{noInertia:t,distance:this._newPos.distanceTo(this._startPos)})}},Ut=class e extends X{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){if(!this._draggable){let e=this._map;this._draggable=new Z(e._mapPane,e._container),this._draggable.on({down:this._onDown,dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on(`predrag`,this._onPreDragLimit,this),e.options.worldCopyJump&&this._draggable.on(`predrag`,this._onPreDragWrap,this)}this._map._container.classList.add(`maplair-grab`,`maplair-touch-drag`),this._draggable.enable(),this._positions=[],this._times=[]}removeHooks(){this._map._container.classList.remove(`maplair-grab`,`maplair-touch-drag`),this._draggable.disable()}moved(){return this._draggable?._moved}moving(){return this._draggable?._moving}_onDown(){this._map._stop()}_onDragStart(e){let t=this._map;if(t._stop(),t._setUserEvent(e.originalEvent),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){let e=z.from(this._map.options.maxBounds);this._offsetLimit=new I(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire(`movestart`).fire(`dragstart`),t.options.inertia&&(this._positions=[],this._times=[])}_onDrag(e){if(this._map.options.inertia){let e=this._lastTime=Date.now(),t=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(t),this._times.push(e),this._prunePositions(e)}this._map.fire(`move`,e).fire(`drag`,e)}_prunePositions(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()}_viscousLimit(e,t){return e-(e-t)*this._viscosity}_onPreDragLimit(){if(!this._viscosity||!this._offsetLimit)return;let e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.x<t.min.x&&(e.x=this._viscousLimit(e.x,t.min.x)),e.y<t.min.y&&(e.y=this._viscousLimit(e.y,t.min.y)),e.x>t.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}_onPreDragWrap(){let e=this._draggable;e._absPos=e._newPos,e._newPos=this._map._wrapWorldCopy(e._newPos)}_onDragEnd(e){let t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(Date.now());let e=this._lastPos.subtract(this._positions[0]),r=(this._lastTime-this._times[0])/1e3,i=n.easeLinearity,a=e.multiplyBy(i/r),o=a.distanceTo([0,0]),s=Math.min(n.inertiaMaxSpeed,o),c=a.multiplyBy(s/o),l=t.getSize().divideBy(2),u=s/(n.inertiaDeceleration*i),d=c.multiplyBy(-u/2).round();if(t._prefersReducedMotion()&&!l.contains(d)){let e=Math.min(l.x/Math.abs(d.x),l.y/Math.abs(d.y));d=d.multiplyBy(e).round(),u*=Math.sqrt(e)}!d.x&&!d.y?t.fire(`moveend`):(d=t._limitOffset(d,t.options.maxBounds),requestAnimationFrame(()=>{t.panBy(d,{duration:u,easeLinearity:i,noMoveStart:!0,animate:!0})}))}}static register(t){t.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1400,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0}),t.addInitHook(`addHandler`,`dragging`,e)}},Wt=class e extends X{static keys={left:[`ArrowLeft`],right:[`ArrowRight`],down:[`ArrowDown`],up:[`ArrowUp`],zoomIn:[`+`,`=`],zoomOut:[`-`,`_`]};constructor(t){super(t),this.callInitHooks(e)}addHooks(){let e=this._map._container;e.tabIndex<=0&&(e.tabIndex=0);let t=this._map.options.ariaKeyShortcuts;t&&(e.ariaKeyShortcuts=t===!0?`ArrowLeft ArrowRight ArrowUp ArrowDown = Plus -`:t),y(e,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown,keydown:this._onContainerKeyDown},this)}removeHooks(){x(document,`keydown`,this._onKeyDown,this),this._map.options.ariaKeyShortcuts&&this._map._container.removeAttribute(`aria-keyshortcuts`),x(this._map._container,{focus:this._onFocus,blur:this._onBlur,pointerdown:this._onPointerDown,keydown:this._onContainerKeyDown},this),this._help?.remove(),this._help=null}_toggleHelp(){this._help??=this._createHelp(),this._help.togglePopover()}_createHelp(){let e=D(`div`,`maplair-keyboard-help`,this._map._container),t=P.translate(`Keyboard shortcuts`);e.popover=`auto`,e.setAttribute(`role`,`dialog`),e.setAttribute(`aria-label`,t),D(`h2`,``,e).textContent=t;let n=D(`dl`,``,e);for(let[e,t]of[[[`←`,`→`,`↑`,`↓`],P.translate(`Pan the map`)],[[`+`],P.translate(`Zoom in`)],[[`−`],P.translate(`Zoom out`)],[[`Shift`],P.translate(`Pan or zoom further, together with the keys above`)],[[`Esc`],P.translate(`Close popup`)],[[`?`],P.translate(`Show or hide the keyboard shortcuts`)]]){let r=D(`div`,``,n),i=D(`dt`,``,r);for(let t of e)D(`kbd`,``,i).textContent=t;D(`dd`,``,r).textContent=t}return w(e),C(e),e}_onPointerDown(){this._focused||this._map._container.focus({preventScroll:!0,focusVisible:!1})}_onFocus(){this._focused=!0,y(document,`keydown`,this._onKeyDown,this),this._map.fire(`focus`)}_onBlur(){this._focused=!1,x(document,`keydown`,this._onKeyDown,this),this._map.fire(`blur`)}_onContainerKeyDown(e){let t=this._map,n=t._popup;if(e.key!==`Escape`||e.defaultPrevented||!n?.options.closeOnEscapeKey||t._controlContainer?.contains(e.target))return;let r=n._container.contains(e.target),i=n._source?._icon;t.closePopup(),e.preventDefault(),r&&(i?.tabIndex>=0?i:t._container).focus()}_onKeyDown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;if(t.key===`?`){this._toggleHelp(),E(t);return}let n=t.key,r=this._map,{left:i,right:a,down:o,up:s,zoomIn:c,zoomOut:l}=e.keys,u=+a.includes(n)-i.includes(n),d=+o.includes(n)-s.includes(n),f=+c.includes(n)-l.includes(n),p=t.shiftKey?3:1;if(u||d){if(!r._panAnim?._inProgress){let e=new g(u,d).multiplyBy(p*r.options.keyboardPanDelta);r.options.maxBounds&&(e=r._limitOffset(e,r.options.maxBounds)),r._setUserEvent(t),r.panBy(e)}}else if(f)r._zoomInputBlocked()||(r._setUserEvent(t),r.setZoom(r.getZoom()+p*f*r.options.zoomDelta));else return;E(t)}static register(t){t.mergeOptions({keyboard:!0,keyboardPanDelta:80,ariaKeyShortcuts:!1}),t.addInitHook(`addHandler`,`keyboard`,e)}},Gt=class e extends X{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){this._map._container.classList.add(`maplair-touch-zoom`),y(this._map._container,`pointerdown`,this._onPointerStart,this)}removeHooks(){this._map._container.classList.remove(`maplair-touch-zoom`),x(this._map._container,`pointerdown`,this._onPointerStart,this),x(this._map._container,`pointermove`,this._onPointerMove,this),x(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this)}_onPointerStart(e){let t=this._map,n=v();if(n.length!==2||t._animatingZoom||this._zooming)return;let r=t.pointerEventToContainerPoint(n[0]),i=t.pointerEventToContainerPoint(n[1]),{x:a,y:o}=M(t._container);this._containerScale=new g(a,o),this._containerOrigin=new g(n[0].clientX,n[0].clientY)._subtract(r.scaleBy(this._containerScale)),this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.pinchZoom!==`center`&&(this._pinchStartLatLng=t.containerPointToLatLng(r.add(i)._divideBy(2))),this._startDist=r.distanceTo(i),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),y(this._map._container,`pointermove`,this._onPointerMove,this),y(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this),e.preventDefault()}_onPointerMove(e){let t=v();if(t.length!==2||!this._zooming)return;let n=this._map,r=this._toContainerPoint(t[0]),i=this._toContainerPoint(t[1]),a=r.distanceTo(i)/this._startDist;if(this._zoom=n.getScaleZoom(a,this._startZoom),!n.options.bounceAtZoomLimits&&(this._zoom<n.getMinZoom()&&a<1||this._zoom>n.getMaxZoom()&&a>1)&&(this._zoom=n._limitZoom(this._zoom)),n.options.pinchZoom===`center`){if(this._center=this._startLatLng,a===1)return}else{let e=r._add(i)._divideBy(2)._subtract(this._centerPoint);if(a===1&&e.x===0&&e.y===0)return;this._center=n.unproject(n.project(this._pinchStartLatLng,this._zoom).subtract(e),this._zoom)}this._moved||=(n._setUserEvent(e),n._moveStart(!0,!1),!0),cancelAnimationFrame(this._animRequest);let o=n._move.bind(n,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=requestAnimationFrame(o.bind(this)),e.preventDefault()}_toContainerPoint(e){return new g(e.clientX,e.clientY)._subtract(this._containerOrigin).unscaleBy(this._containerScale)}_onPointerEnd(){x(this._map._container,`pointermove`,this._onPointerMove,this),x(this._map._container,`pointerup pointercancel`,this._onPointerEnd,this),!this._moved||!this._zooming?this._zooming=!1:(this._zooming=!1,cancelAnimationFrame(this._animRequest),this._map._zoomAnimated?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))}static register(t){t.mergeOptions({pinchZoom:!0,bounceAtZoomLimits:!0}),t.addInitHook(`addHandler`,`pinchZoom`,e),t.addInitHook(function(){this.touchZoom=this.pinchZoom,this.options.touchZoom!==void 0&&(console.warn(`Map: touchZoom option is deprecated and will be removed in future versions. Use pinchZoom instead.`),this.options.pinchZoom=this.options.touchZoom,delete this.options.touchZoom),this.options.pinchZoom?this.pinchZoom.enable():this.pinchZoom.disable()})}},Kt=class e extends X{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){y(this._map._container,`wheel`,this._onWheelScroll,this),y(this._map._container,`gesturestart`,this._onGestureStart,this),y(this._map._container,`gesturechange`,this._onGestureChange,this),y(this._map._container,`gestureend`,this._onGestureEnd,this),this._delta=0}removeHooks(){x(this._map._container,`wheel`,this._onWheelScroll,this),x(this._map._container,`gesturestart`,this._onGestureStart,this),x(this._map._container,`gesturechange`,this._onGestureChange,this),x(this._map._container,`gestureend`,this._onGestureEnd,this),clearTimeout(this._timer),this._endPinch(),this._endPan()}_onWheelScroll(e){if(e.ctrlKey){E(e);let t=-e.deltaY*(e.deltaMode===1?20:e.deltaMode===2?60:1);this._pinchTo(e,(this._pinch?.zoom??this._map.getZoom())+t/100),clearTimeout(this._pinchTimer),this._pinchTimer=setTimeout(this._endPinch.bind(this),150)}else this._map.options.scrollWheelZoom===`trackpad`?this._panBy(e):this._onWheelZoom(e)}_onGestureStart(e){v().length||(E(e),this._gestureStartZoom=this._map.getZoom())}_onGestureChange(e){this._gestureStartZoom!==void 0&&(E(e),this._pinchTo(e,this._gestureStartZoom+Math.log2(e.scale)))}_onGestureEnd(e){this._gestureStartZoom!==void 0&&(E(e),this._gestureStartZoom=void 0,this._endPinch())}_pinchTo(e,t,n){let r=this._map;if(!this._pinch){if(r._animatingZoom)return;r._stop();let t=r.pointerEventToContainerPoint(e),n=t.subtract(r.getSize()._divideBy(2));this._pinch={aroundLatLng:r.options.scrollWheelZoom===`center`?r.getCenter():r.containerPointToLatLng(t),offset:r.options.scrollWheelZoom===`center`?new g(0,0):n},r._setUserEvent(e),r._moveStart(!0,!1)}(!r.options.bounceAtZoomLimits||n)&&(t=Math.max(r.getMinZoom(),Math.min(r.getMaxZoom(),t))),this._pinch.zoom=t,this._pinch.shown??=r.getZoom();let i=()=>{let e=this._pinch,t=e.zoom-e.shown;e.shown=n&&Math.abs(t)>.01?e.shown+t*.3:e.zoom,r._move(this._getPinchCenter(e.shown),e.shown,{pinch:!0,round:!1}),e.shown!==e.zoom&&(this._pinchFrame=requestAnimationFrame(i))};cancelAnimationFrame(this._pinchFrame),this._pinchFrame=requestAnimationFrame(i)}_getPinchCenter(e){let{aroundLatLng:t,offset:n}=this._pinch,r=this._map;return r.unproject(r.project(t,e).subtract(n),e)}_endPinch(){if(clearTimeout(this._pinchTimer),!this._pinch)return;cancelAnimationFrame(this._pinchFrame);let e=this._map,t=e._limitZoom(this._pinch.zoom),n=this._getPinchCenter(t);this._pinch=null,e.options.zoomAnimation&&Math.abs(t-e.getZoom())>1e-9?e._animateZoom(n,t,!0,e.options.zoomSnap):e._move(n,t)._moveEnd(!0)}_panBy(e){E(e);let t=this._map;if(t._animatingZoom)return;let n=e.deltaMode===1?20:e.deltaMode===2?60:1,r=new g(e.deltaX*n,e.deltaY*n);e.shiftKey&&!e.deltaX&&(r=new g(r.y,0)),t.options.maxBounds&&(r=t._limitOffset(r,t.options.maxBounds)),this._panning||(t._stop(),this._panning=!0,t._setUserEvent(e),t.fire(`movestart`)),t._rawPanBy(r.round()),t.fire(`move`),clearTimeout(this._panTimer),this._panTimer=setTimeout(this._endPan.bind(this),150)}_endPan(){clearTimeout(this._panTimer),this._panning&&(this._panning=!1,this._map.fire(`moveend`))}_onWheelZoom(e){if(this._map.options.continuousZoom){E(e);let t=ve(e)/this._map.options.wheelPxPerZoomLevel;this._pinchTo(e,(this._pinch?.zoom??this._map.getZoom())+t,!0),clearTimeout(this._pinchTimer),this._pinchTimer=setTimeout(this._endPinch.bind(this),150);return}let t=ve(e),n=this._map.options.wheelDebounceTime;this._delta+=t,this._lastEvent=e,this._startTime||=Date.now();let r=Math.max(n-(Date.now()-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(this._performZoom.bind(this),r),E(e)}_performZoom(){let e=this._map,t=e.getZoom(),n=this._map.options.zoomSnap??0;e._stop();let r=this._delta/(this._map.options.wheelPxPerZoomLevel*4),i=4*Math.log(2/(1+Math.exp(-Math.abs(r))))/Math.LN2,a=n?Math.ceil(i/n)*n:i,o=e._prefersReducedMotion()?Math.min(a,1):a,s=e._limitZoom(t+(this._delta>0?o:-o))-t;this._delta=0,this._startTime=null,s&&!e._zoomInputBlocked()&&(e._setUserEvent(this._lastEvent),e.options.scrollWheelZoom===`center`?e.setZoom(t+s):e.setZoomAround(e.pointerEventToContainerPoint(this._lastEvent),t+s))}static register(t){t.mergeOptions({scrollWheelZoom:!0,wheelDebounceTime:40,wheelPxPerZoomLevel:60}),t.addInitHook(`addHandler`,`scrollWheelZoom`,e)}},qt=class e extends X{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){y(this._map._container,`pointerdown`,this._onDown,this)}removeHooks(){x(this._map._container,`pointerdown`,this._onDown,this),this._cancel(),this._cancelClickPrevent(),this._stopPreventingNative()}_onDown(e){if(clearTimeout(this._holdTimeout),v().length!==1||e.pointerType===`mouse`)return;let t=this._map._container;this._startPos=this._newPos=new g(e.clientX,e.clientY),this._holdTimeout=setTimeout((()=>{this._cancel(),this._isTapValid()&&(y(t,`pointerup`,T),y(t,`pointerup pointercancel`,this._cancelClickPrevent,this),this._simulateEvent(`contextmenu`,e),t.addEventListener(`contextmenu`,E,!0),t.addEventListener(`pointerdown`,this._stopPreventingNative,!0))}),600),y(t,`pointerup pointercancel contextmenu`,this._cancel,this),y(t,`pointermove`,this._onMove,this)}_cancelClickPrevent(){let e=this._map._container;x(e,`pointerup`,T),x(e,`pointerup pointercancel`,this._cancelClickPrevent,this)}_stopPreventingNative=()=>{let e=this._map._container;e.removeEventListener(`contextmenu`,E,!0),e.removeEventListener(`pointerdown`,this._stopPreventingNative,!0)};_cancel(){clearTimeout(this._holdTimeout);let e=this._map._container;x(e,`pointerup pointercancel contextmenu`,this._cancel,this),x(e,`pointermove`,this._onMove,this)}_onMove(e){this._newPos=new g(e.clientX,e.clientY)}_isTapValid(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance}_simulateEvent(e,t){let n=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});n._simulated=!0,t.target.dispatchEvent(n)}static register(t){t.mergeOptions({tapHold:!0,tapTolerance:15}),t.addInitHook(`addHandler`,`tapHold`,e)}},Jt=class e extends X{constructor(...t){super(...t),this.callInitHooks(e)}addHooks(){y(this._map._container,`pointerdown`,this._onDown,this),y(this._map._container,`pointerup`,this._onTapUp,this),y(this._map._container,`pointercancel`,this._reset,this)}removeHooks(){x(this._map._container,`pointerdown`,this._onDown,this),x(this._map._container,`pointerup`,this._onTapUp,this),x(this._map._container,`pointercancel`,this._reset,this),this._onUp(),this._reset()}_onDown(e){if(e.pointerType===`mouse`||v().length!==1){this._onUp(),this._reset();return}let t=this._map,n=new g(e.clientX,e.clientY),r=Date.now();if(!this._tapPos||r-this._tapTime>500||n.distanceTo(this._tapPos)>30||t._animatingZoom){this._tapPos=null,this._downPos=n,this._downTime=r;return}this._tapPos=this._downPos=null,this._startPos=n,this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0;let i=t.pointerEventToContainerPoint(e);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),t.options.tapDragZoom!==`center`&&(this._aroundLatLng=t.containerPointToLatLng(i),this._aroundOffset=i.subtract(this._centerPoint)),this._cancelDragging(),y(t._container,`pointermove`,this._onMove,this),y(t._container,`pointerup pointercancel`,this._onUp,this)}_onTapUp(e){if(!this._downPos)return;let t=new g(e.clientX,e.clientY),n=Date.now();n-this._downTime<=500&&t.distanceTo(this._downPos)<=this._map.options.tapTolerance&&(this._tapPos=this._downPos,this._tapTime=n),this._downPos=null}_reset(){this._tapPos=this._downPos=null}_cancelDragging(){let e=this._map.dragging?._draggable;e&&Z._dragging===e&&e.finishDrag(!0)}_onMove(e){if(!this._zooming||v().length!==1)return;let t=this._map,n=e.clientY-this._startPos.y;!this._moved&&Math.abs(n)<=t.options.tapTolerance||(this._cancelDragging(),this._zoom=this._startZoom+n/128,t.options.bounceAtZoomLimits||(this._zoom=t._limitZoom(this._zoom)),this._center=t.options.tapDragZoom===`center`?this._startLatLng:t.unproject(t.project(this._aroundLatLng,this._zoom).subtract(this._aroundOffset),this._zoom),this._moved||=(t._stop(),t._setUserEvent(e),t._moveStart(!0,!1),!0),cancelAnimationFrame(this._animRequest),this._animRequest=requestAnimationFrame(()=>t._move(this._center,this._zoom,{pinch:!0,round:!1})),e.preventDefault())}_onUp(){if(x(this._map._container,`pointermove`,this._onMove,this),x(this._map._container,`pointerup pointercancel`,this._onUp,this),!this._zooming||(this._zooming=!1,!this._moved))return;this._moved=!1,cancelAnimationFrame(this._animRequest);let e=this._map,t=e._limitZoom(this._zoom);e.options.zoomAnimation?e._animateZoom(this._center,t,!0,e.options.zoomSnap):e._move(this._center,t)._moveEnd(!0)}static register(t){t.mergeOptions({tapDragZoom:!0}),t.addInitHook(`addHandler`,`tapDragZoom`,e)}},Q=class e extends Ne{static defaultOptions={crs:Ct,center:void 0,zoom:void 0,minZoom:void 0,maxZoom:void 0,layers:[],ariaLabel:void 0,maxBounds:void 0,renderer:void 0,zoomAnimation:!0,zoomAnimationThreshold:4,continuousZoom:!1,fadeAnimation:!0,markerZoomAnimation:!0,markerCulling:!1,transform3DLimit:8388608,zoomSnap:1,zoomDelta:1,trackResize:!0};constructor(t,n){super(),n=f(this,n),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._sizeChanged=!0,this._initContainer(t),this._initLayout(),this._initEvents(),this._watchPixelRatio(),this.on({movestart:this._onBusy,zoomstart:this._onBusy,move:this._onMove,moveend:this._onViewChanged,layerremove:this._scheduleIdleCheck},this),n.maxBounds&&this.setMaxBounds(n.maxBounds),n.zoom!==void 0&&(this._zoom=this._limitZoom(n.zoom)),n.center&&n.zoom!==void 0&&this.setView(V.from(n.center),n.zoom,{reset:!0}),this.callInitHooks(e),this._zoomAnimated=this.options.zoomAnimation,this._zoomAnimated&&this._createAnimProxy(),this._addLayers(this.options.layers)}setView(e,t,n){return t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(new V(e),t,this.options.maxBounds),n??={},this._stop(),this._loaded&&!n.reset&&n!==!0&&(n.animate!==void 0&&(n.zoom={animate:n.animate,...n.zoom},n.pan={animate:n.animate,duration:n.duration,...n.pan}),this._zoom===t?this._tryAnimatedPan(e,n.pan):this._tryAnimatedZoom&&this._tryAnimatedZoom(e,t,n.zoom))?(clearTimeout(this._sizeTimer),this):(this._resetView(e,t,n.pan?.noMoveStart),this)}setZoom(e,t){return this._loaded?this.setView(this.getCenter(),e,{zoom:t}):(this._zoom=e,this)}zoomIn(e,t){return e??=this.options.zoomDelta,this.setZoom(this._zoom+e,t)}zoomOut(e,t){return e??=this.options.zoomDelta,this.setZoom(this._zoom-e,t)}setZoomAround(e,t,n){let r=this.project(this.getCenter()),i=e instanceof g?this.containerPointToLayerPoint(e).subtract(this.containerPointToLayerPoint(this.getSize().divideBy(2))):this.project(e).subtract(r),a=this.unproject(r.add(i.multiplyBy(1-1/this.getZoomScale(t))));return this.setView(a,t,{zoom:n})}_getBoundsCenterZoom(e,t){t??={},e=e.getBounds?e.getBounds():z.from(e);let n=g.from(t.paddingTopLeft||t.padding||[0,0]),r=g.from(t.paddingBottomRight||t.padding||[0,0]),i=this.getBoundsZoom(e,!1,n.add(r));if(i=typeof t.maxZoom==`number`?Math.min(t.maxZoom,i):i,i===1/0)return{center:e.getCenter(),zoom:i};let a=r.subtract(n).divideBy(2),o=this.project(e.getSouthWest(),i),s=this.project(e.getNorthEast(),i);return{center:this.unproject(o.add(s).divideBy(2).add(a),i),zoom:i}}fitBounds(e,t){if(e=z.from(e),!e.isValid())throw Error(`Bounds are not valid.`);let n=this._getBoundsCenterZoom(e,t);return this.setView(n.center,n.zoom,t)}fitWorld(e){return this.fitBounds([[-90,-180],[90,180]],e)}panTo(e,t){return this.setView(e,this._zoom,{pan:t})}panBy(e,t){if(e=g.from(e).round(),t??={},!e.x&&!e.y)return this.fire(`moveend`);let n=this.getSize();if(t.animate!==!0&&!n.contains(e)){let t=this.unproject(this.project(this.getCenter()).add(e));return this._resetView(this.options.worldCopyJump?this.wrapLatLng(t):t,this.getZoom()),this}this._panAnim||(this._panAnim=new Tt,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),t.noMoveStart||this.fire(`movestart`);let r=this._prefersReducedMotion()&&!n.divideBy(2).contains(e);if(t.animate===!0||t.animate!==!1&&!r){this._mapPane.classList.add(`maplair-pan-anim`);let n=this._getMapPanePos().subtract(e).round();this._panAnim.run(this._mapPane,n,t.duration||.25,t.easeLinearity)}else this._rawPanBy(e),this._wrapWorldCopy(),this.fire(`move`).fire(`moveend`);return this}flyTo(e,t,n){if(n??={},n.animate===!1)return this.setView(e,t,{...n,zoom:{...n.zoom,animate:!1}});if(n.animate!==!0&&this._prefersReducedMotion())return this.setView(e,t,n);this._stop(),t=t===void 0?this._zoom:this._limitZoom(t),e=this._limitCenter(new V(e),t,this.options.maxBounds);let r=this.project(this.getCenter()),i=this.project(e),a=this.getSize(),o=this._zoom,s=Math.max(a.x,a.y),c=s*this.getZoomScale(o,t),l=i.distanceTo(r)||1,u=1.42,d=u*u;function f(e){let t=e?-1:1,n=e?c:s,r=c*c-s*s+t*d*d*l*l,i=2*n*d*l;return-Math.asinh(r/i)}let p=f(0);function ee(e){return s*(Math.cosh(p)*Math.tanh(p+u*e)-Math.sinh(p))/d}function te(e){return 1-(1-e)**1.5}let m=Date.now(),h=(f(1)-p)/u,g=n.duration?1e3*n.duration:1e3*h*.8,ne=()=>{let n=(Date.now()-m)/g,a=te(n)*h;if(n<=1)this._flyToFrame=requestAnimationFrame(ne),this._move(this.unproject(r.add(i.subtract(r).multiplyBy(ee(a)/l)),o),this.getScaleZoom(Math.cosh(p+u*a)/Math.cosh(p),o),{flyTo:!0});else{let n=this._zoom!==t;this._move(e,t),n||this.fire(`zoom`),this._moveEnd(!0)}};return this._moveStart(!0,n.noMoveStart),ne(this),this}flyToBounds(e,t){let n=this._getBoundsCenterZoom(e,t);return this.flyTo(n.center,n.zoom,t)}setCrs(e){let t=this.options.crs;if(e===t)return this;if(!this._loaded)return this.options.crs=e,this.fire(`crschange`,{oldCrs:t,crs:e}),this;this._stop();let n=this.getCenter(),r=this._getResolution(n);this.options.crs=e;let i=this._limitZoom(e.zoom(e.scale(this._zoom)*this._getResolution(n)/r));return this.fire(`crschange`,{oldCrs:t,crs:e}),this._resetView(n,i),this}_getResolution(e){let t=this.options.crs,n=t.latLngToPoint(e,this._zoom);return t.distance(e,t.pointToLatLng(n.add([1,0]),this._zoom))}setMaxBounds(e){return e=new z(e),this.listens(`moveend`,this._panInsideMaxBounds)&&this.off(`moveend`,this._panInsideMaxBounds),e.isValid()?(this.options.maxBounds=e,this._loaded&&this._panInsideMaxBounds(),this.on(`moveend`,this._panInsideMaxBounds)):(this.options.maxBounds=null,this)}setMinZoom(e){let t=this.options.minZoom;return this.options.minZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()<this.options.minZoom)?this.setZoom(e):this}setMaxZoom(e){let t=this.options.maxZoom;return this.options.maxZoom=e,this._loaded&&t!==e&&(this.fire(`zoomlevelschange`),this.getZoom()>this.options.maxZoom)?this.setZoom(e):this}panInsideBounds(e,t){this._enforcingBounds=!0;let n=this.getCenter(),r=this._limitCenter(n,this._zoom,z.from(e));return n.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this}panInside(e,t){t??={};let n=g.from(t.paddingTopLeft||t.padding||[0,0]),r=g.from(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),a=this.project(e),o=this.getPixelBounds(),s=new I([o.min.add(n),o.max.subtract(r)]),c=s.getSize();if(!s.contains(a)){this._enforcingBounds=!0;let e=a.subtract(s.getCenter()),n=s.extend(a).getSize().subtract(c);i.x+=e.x<0?-n.x:n.x,i.y+=e.y<0?-n.y:n.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this}invalidateSize(e){if(!this._loaded)return this;e={animate:!1,pan:!0,...e===!0?{animate:!0}:e};let t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;let n=this.getSize(),r=t.divideBy(2).round(),i=n.divideBy(2).round(),a=r.subtract(i);return!a.x&&!a.y?this:(e.animate&&e.pan?this.panBy(a):(e.pan&&this._rawPanBy(a),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(this.fire.bind(this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:n}))}stop(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire(`viewreset`),this._stop()}locate(e){if(e=this._locateOptions={timeout:1e4,watch:!1,...e},!(`geolocation`in navigator))return this._handleGeolocationError({code:0,message:`Geolocation not supported.`}),this;let t=this._handleGeolocationResponse.bind(this),n=this._handleGeolocationError.bind(this);return e.watch?(this._locationWatchId!==void 0&&navigator.geolocation.clearWatch(this._locationWatchId),this._locationWatchId=navigator.geolocation.watchPosition(t,n,e)):navigator.geolocation.getCurrentPosition(t,n,e),this}stopLocate(){return navigator.geolocation?.clearWatch?.(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this}_handleGeolocationError(e){if(!this._container._maplair_id)return;let t=e.code,n=e.message||(t===1?`permission denied`:t===2?`position unavailable`:`timeout`);this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire(`locationerror`,{code:t,message:`Geolocation error: ${n}.`})}_handleGeolocationResponse(e){if(!this._container._maplair_id)return;let t=e.coords.latitude,n=e.coords.longitude,r=new V(t,n),i=r.toBounds(e.coords.accuracy*2),a=this._locateOptions;if(a.setView){let e=this.getBoundsZoom(i);this.setView(r,a.maxZoom?Math.min(e,a.maxZoom):e)}let o={latlng:r,bounds:i,timestamp:e.timestamp};for(let t in e.coords)typeof e.coords[t]==`number`&&(o[t]=e.coords[t]);this.fire(`locationfound`,o)}addHandler(e,t){if(!t)return this;let n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this}remove(){if(this._initEvents(!0),this.options.maxBounds&&this.off(`moveend`,this._panInsideMaxBounds),this._containerId!==this._container._maplair_id)throw Error(`Map container is being reused by another instance`);delete this._container._maplair_id,delete this._containerId,this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),se(this._container),this._mapPane.remove();for(let e of this._ariaAttributes)this._container.removeAttribute(e);this._clearControlPos&&this._clearControlPos(),cancelAnimationFrame(this._resizeRequest),cancelAnimationFrame(this._idleRequest),this._watchPixelRatio(!0);for(let e of this._handlers)e.disable();clearTimeout(this._transitionEndTimer),clearTimeout(this._sizeTimer),this._loaded&&this.fire(`unload`);for(let e of Object.values(this._layers))e.remove();for(let e of Object.values(this._panes))e.remove();return this._layers={},this._panes={},delete this._mapPane,delete this._renderer,this}createPane(e,t){let n=D(`div`,`maplair-pane${e?` maplair-${e.replace(`Pane`,``)}-pane`:``}`,t||this._mapPane);return e&&(this._panes[e]=n),n}getCenter(){return this._checkIfLoaded(),this._lastCenter&&this._getMapPanePos().equals(this._lastCenterPanePos)?new V(this._lastCenter):this.layerPointToLatLng(this._getCenterLayerPoint())}getZoom(){return this._zoom}getBounds(){let e=this.getPixelBounds();return new z(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))}getMinZoom(){return this.options.minZoom??this._layersMinZoom??0}getMaxZoom(){return this.options.maxZoom??this._layersMaxZoom??1/0}getBoundsZoom(e,t,n){e=z.from(e),n=g.from(n??[0,0]);let r=this.getZoom()??0,i=this.getMinZoom(),a=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),c=this.getSize().subtract(n),l=new I(this.project(s,r),this.project(o,r)).getSize(),u=this.options.zoomSnap,d=c.x/l.x,f=c.y/l.y,p=t?Math.max(d,f):Math.min(d,f);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(i,Math.min(a,r))}getSize(){return(!this._size||this._sizeChanged)&&(this._size=new g(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),new g(this._size)}getPixelBounds(e,t){let n=this._getTopLeftPoint(e,t);return new I(n,n.add(this.getSize()))}getPixelOrigin(){return this._checkIfLoaded(),this._pixelOrigin}getPixelWorldBounds(e){return this.options.crs.getProjectedBounds(e??this.getZoom())}getPane(e){return typeof e==`string`?this._panes[e]:e}getPanes(){return this._panes}getContainer(){return this._container}getZoomScale(e,t){let n=this.options.crs;return t??=this._zoom,n.scale(e)/n.scale(t)}getScaleZoom(e,t){let n=this.options.crs;t??=this._zoom;let r=n.zoom(e*n.scale(t));return isNaN(r)?1/0:r}project(e,t){return t??=this._zoom,this.options.crs.latLngToPoint(V.from(e),t)}unproject(e,t){return t??=this._zoom,this.options.crs.pointToLatLng(g.from(e),t)}layerPointToLatLng(e){let t=g.from(e).add(this.getPixelOrigin());return this.unproject(t)}latLngToLayerPoint(e){return this.project(V.from(e))._subtract(this.getPixelOrigin())}wrapLatLng(e){return this.options.crs.wrapLatLng(V.from(e))}wrapLatLngBounds(e){return this.options.crs.wrapLatLngBounds(new z(e))}distance(e,t){return this.options.crs.distance(V.from(e),V.from(t))}containerPointToLayerPoint(e){return g.from(e).subtract(this._getMapPanePos())}layerPointToContainerPoint(e){return g.from(e).add(this._getMapPanePos())}containerPointToLatLng(e){let t=this.containerPointToLayerPoint(g.from(e));return this.layerPointToLatLng(t)}latLngToContainerPoint(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(V.from(e)))}pointerEventToContainerPoint(e){return ge(e,this._container)}pointerEventToLayerPoint(e){return this.containerPointToLayerPoint(this.pointerEventToContainerPoint(e))}pointerEventToLatLng(e){return this.layerPointToLatLng(this.pointerEventToLayerPoint(e))}_initContainer(e){let t=this._container=xe(e);if(!t)throw Error(`Map container not found.`);if(t._maplair_id)throw Error(`Map container is already initialized.`);oe(t),y(t,`scroll`,this._onScroll,this),this._containerId=a(t)}_initLayout(){let e=this._container;this._fadeAnimated=this.options.fadeAnimation;let t=[`maplair-container`,`maplair-touch`];window.devicePixelRatio>1&&t.push(`maplair-retina`),this._fadeAnimated&&t.push(`maplair-fade-anim`),e.classList.add(...t),this._ariaAttributes=[],e.hasAttribute(`role`)||(e.setAttribute(`role`,`region`),this._ariaAttributes.push(`role`)),!e.hasAttribute(`aria-label`)&&!e.hasAttribute(`aria-labelledby`)&&(e.setAttribute(`aria-label`,this.options.ariaLabel??P.translate(`Map`)),this._ariaAttributes.push(`aria-label`));let{position:n}=getComputedStyle(e);n!==`absolute`&&n!==`relative`&&n!==`fixed`&&n!==`sticky`&&(e.style.position=`relative`),this._initPanes(),this._initControlPos&&this._initControlPos()}_initPanes(){let e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane(`mapPane`,this._container),A(this._mapPane,new g(0,0)),this.createPane(`tilePane`),this.createPane(`overlayPane`),this.createPane(`shadowPane`),this.createPane(`markerPane`),this.createPane(`tooltipPane`),this.createPane(`popupPane`),this.options.markerZoomAnimation||(e.markerPane.classList.add(`maplair-zoom-hide`),e.shadowPane.classList.add(`maplair-zoom-hide`))}_resetView(e,t,n){let r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire(`viewprereset`,{center:e,zoom:t}),A(this._mapPane,new g(0,0));let i=this._zoom!==t;i&&!r&&(this._instantZoomEnd=Date.now()+250),this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire(`viewreset`),r&&this.fire(`load`)}fire(t,n,r){return this._userEvent&&e._viewEvents.has(t)&&(n={originalEvent:this._userEvent,...n},t===`moveend`?this._userEvent=null:this._userMoving=!0),super.fire(t,n,r)}static _viewEvents=/* @__PURE__ */ new Set([`movestart`,`move`,`moveend`,`zoomstart`,`zoom`,`zoomend`,`zoomanim`]);_watchPixelRatio(e){this._pixelRatioQuery?.removeEventListener(`change`,this._onPixelRatioChange),!e&&typeof window<`u`&&window.matchMedia&&(this._onPixelRatioChange??=()=>{this._watchPixelRatio(),this.fire(`pixelratiochange`)},this._pixelRatioQuery=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._pixelRatioQuery.addEventListener(`change`,this._onPixelRatioChange))}_onBusy(){this._viewChanging=!0,this._idle=!1}_onMove(){this._cullingBounds=null}_onViewChanged(){this._viewChanging=!1,this._scheduleIdleCheck()}_onLayerLoading(){this._idle=!1}_scheduleIdleCheck(){cancelAnimationFrame(this._idleRequest),this._idleRequest=requestAnimationFrame(()=>this._checkIdle())}_checkIdle(){if(!(this._idle||!this._loaded||this._viewChanging||this._animatingZoom)){for(let e of Object.values(this._layers))if(e.isLoading?.())return;this._idle=!0,this.fire(`idle`)}}_setUserEvent(e){this._userEvent=e,this._userMoving=!1,queueMicrotask(()=>{this._userEvent===e&&!this._userMoving&&(this._userEvent=null)})}_moveStart(e,t){return e&&this.fire(`zoomstart`),t||this.fire(`movestart`),this}_move(e,t,n,r){t===void 0&&(t=this._zoom);let i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._lastCenterPanePos=this._getMapPanePos(),this._pixelOrigin=this._getNewPixelOrigin(e),r?n?.pinch&&this.fire(`zoom`,n):((i||n?.pinch)&&this.fire(`zoom`,n),this.fire(`move`,n)),this}_moveEnd(e){return e&&this.fire(`zoomend`),this.fire(`moveend`)}_stop(){return cancelAnimationFrame(this._flyToFrame),cancelAnimationFrame(this._zoomAnimFrame),this._panAnim?.stop(),this}_rawPanBy(e){A(this._mapPane,this._getMapPanePos().subtract(e))}_wrapWorldCopy(e=this._getMapPanePos()){if(!this._loaded||!this.options.worldCopyJump||this.options.crs.infinite)return e;let t=this.getPixelWorldBounds().getSize().x,n=e.x-t*Math.round((e.x+this.latLngToLayerPoint([0,0]).x-this.getSize().x/2)/t),r=Math.round((n-this._getMapPanePos().x)/t);return e=new g(n,e.y),r&&(A(this._mapPane,e),this.fire(`worldcopyjump`,{worlds:r})),e}_getZoomSpan(){return this.getMaxZoom()-this.getMinZoom()}_panInsideMaxBounds(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)}_checkIfLoaded(){if(!this._loaded)throw Error(`Set map center and zoom first.`)}_initEvents(e){this._targets={},this._targets[a(this._container)]=this,(e?x:y)(this._container,`click dblclick pointerdown pointerup pointerover pointerout pointermove contextmenu keydown keyup`,this._handleDOMEvent,this),this.options.trackResize&&(e?this._resizeObserver.disconnect():(this._resizeObserver||=new ResizeObserver(this._onResize.bind(this)),this._resizeObserver.observe(this._container))),this.options.transform3DLimit&&(e?this.off:this.on).call(this,`moveend`,this._onMoveEnd)}_onResize(){cancelAnimationFrame(this._resizeRequest),this._resizeRequest=requestAnimationFrame(()=>{(this._container.clientWidth||this._container.clientHeight)&&this.invalidateSize({debounceMoveend:!0})})}_onScroll(){this._container.scrollTop=0,this._container.scrollLeft=0}_onMoveEnd(){let e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())}_findEventTargets(e,t){let n=[],r,i=e.target,o=!1,s=t===`pointerout`||t===`pointerover`;for(;i;){if(r=this._targets[a(i)],r&&(t===`click`||t===`preclick`)&&this._draggableMoved(r)){o=!0;break}if(r&&r.listens(t,!0)&&(s&&!ye(i,e)||(n.push(r),s))||i===this._container)break;i=i.parentNode}return!n.length&&!o&&!s&&this.listens(t,!0)&&(n=[this]),n}_isClickDisabled(e){for(;e&&e!==this._container;){if(e._maplair_disable_click||!e.parentNode)return!0;e=e.parentNode}}_handleDOMEvent(e){let t=e.target;!this._loaded||t._maplair_disable_events||e.type===`click`&&this._isClickDisabled(t)||this._fireDOMEvent(e,e.type)}static _pointerEvents=[`click`,`dblclick`,`pointerover`,`pointerout`,`contextmenu`];_fireDOMEvent(t,n,r){n===`click`&&this._fireDOMEvent(t,`preclick`,r);let i=this._findEventTargets(t,n);if(r&&(i=[...r.filter(e=>e.listens(n,!0)),...i]),!i.length)return;n===`contextmenu`&&t.preventDefault();let a=i[0],o={originalEvent:t};if(t.type!==`keydown`&&t.type!==`keyup`){let e=(!a._pxRadius||a._pxRadius<=10)&&a.getLatLng?.();o.containerPoint=e?this.latLngToContainerPoint(e):this.pointerEventToContainerPoint(t),o.layerPoint=this.containerPointToLayerPoint(o.containerPoint),o.latlng=e||this.layerPointToLatLng(o.layerPoint)}for(let t of i){t.fire(n,o,!0);let r=t.options.bubblingMouseEvents??t.options.bubblingPointerEvents;if(o.originalEvent._stopped||r===!1&&e._pointerEvents.includes(n))return}}_draggableMoved(e){return e=e.dragging?.enabled()?e:this,e.dragging?.moved()||this.boxZoom?.moved()}whenReady(e,t){return this._loaded?e.call(t||this,{target:this}):this.on(`load`,e,t),this}_getMapPanePos(){return j(this._mapPane)}_getTopLeftPoint(e,t){return(e&&t!==void 0?this._getNewPixelOrigin(e,t):this.getPixelOrigin()).subtract(this._getMapPanePos())}_getNewPixelOrigin(e,t){let n=this.getSize()._divideBy(2);return this.project(e,t)._subtract(n)._add(this._getMapPanePos())._round()}_latLngToNewLayerPoint(e,t,n){let r=this._getNewPixelOrigin(n,t);return this.project(e,t)._subtract(r)}_getCenterLayerPoint(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))}_getCenterOffset(e){return this.latLngToLayerPoint(e)._round()._subtract(this._getCenterLayerPoint())}_limitCenter(e,t,n){if(!n)return e;let r=this.project(e,t),i=this.getSize().divideBy(2),a=new I(r.subtract(i),r.add(i)),o=this._getBoundsOffset(a,n,t);return Math.abs(o.x)<=1&&Math.abs(o.y)<=1?e:this.unproject(r.add(o),t)}_prefersReducedMotion(){return window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}_limitOffset(e,t){if(!t)return e;let n=this.getPixelBounds(),r=new I(n.min.add(e),n.max.add(e));return e.add(this._getBoundsOffset(r,t))}_getBoundsOffset(e,t,n){let r=new I(this.project(t.getNorthEast(),n),this.project(t.getSouthWest(),n)),i=r.min.subtract(e.min),a=r.max.subtract(e.max);return new g(this._rebound(i.x,-a.x),this._rebound(i.y,-a.y))}_rebound(e,t){return e+t>0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))}_limitZoom(e){let t=this.getMinZoom(),n=this.getMaxZoom(),r=this.options.zoomSnap;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(n,e))}_onPanTransitionStep(){this.fire(`move`)}_onPanTransitionEnd(){this._mapPane.classList.remove(`maplair-pan-anim`),this._wrapWorldCopy(),this.fire(`moveend`)}_tryAnimatedPan(e,t){let n=this._getCenterOffset(e)._trunc();return t?.animate!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)}_createAnimProxy(){this._proxy=D(`div`,`maplair-proxy maplair-zoom-animated`),this._panes.mapPane.appendChild(this._proxy),this.on(`zoomanim`,this._animateProxyZoom,this),this.on(`load moveend`,this._animMoveEnd,this),y(this._proxy,`transitionend`,this._catchTransitionEnd,this)}_animateProxyZoom(e){let t=this._proxy.style.transform;k(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),t===this._proxy.style.transform&&this._animatingZoom&&this._onZoomTransitionEnd()}_animMoveEnd(){let e=this.getCenter(),t=this.getZoom();k(this._proxy,this.project(e,t),this.getZoomScale(t,1))}_catchTransitionEnd(e){this._animatingZoom&&e.propertyName.includes(`transform`)&&this._onZoomTransitionEnd()}_nothingToAnimate(){return!this._container.getElementsByClassName(`maplair-zoom-animated`).length}_continuousZoom(e,t,n,r){let i=this._zoom,a=n.multiplyBy(-1),o=this.containerPointToLatLng(this.getSize()._divideBy(2).add(n)),s=performance.now();this._moveStart(!0,r.noMoveStart??!1);let c=()=>{let n=Math.min(1,(performance.now()-s)/250);if(n<1){let e=i+(t-i)*(1-(1-n)**2);this._move(this.unproject(this.project(o,e).add(a),e),e,{continuous:!0}),this._flyToFrame=requestAnimationFrame(c)}else this._move(e,t)._moveEnd(!0)};this._flyToFrame=requestAnimationFrame(c)}_zoomInputBlocked(){return this._animatingZoom||Date.now()<this._instantZoomEnd}_tryAnimatedZoom(e,t,n){if(this._animatingZoom)return!0;n??={};let r=this.options.zoomAnimationThreshold,i=this._prefersReducedMotion()&&n.animate!==!0?Math.min(r,1):r;if(!this._zoomAnimated||n.animate===!1||this._nothingToAnimate()&&!this.options.continuousZoom||Math.abs(t-this._zoom)>i)return!1;let a=this.getZoomScale(t),o=this._getCenterOffset(e)._divideBy(1-1/a);if(n.animate!==!0&&!this.getSize().contains(o))return!1;if(this.options.continuousZoom)return this._continuousZoom(e,t,o,n),!0;let s=this._userEvent;return this._zoomAnimFrame=requestAnimationFrame(()=>{this._zoomAnimFrame=null,s&&this._setUserEvent(s),this._moveStart(!0,n.noMoveStart??!1)._animateZoom(e,t,!0)}),!0}_animateZoom(e,t,n,r){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,this._mapPane.classList.add(`maplair-zoom-anim`)),this.fire(`zoomanim`,{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||=this._zoom!==this._animateToZoom,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._transitionEndTimer=setTimeout(this._onZoomTransitionEnd.bind(this),250))}_onZoomTransitionEnd(){this._animatingZoom&&(this._mapPane?.classList.remove(`maplair-zoom-anim`),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire(`zoom`),delete this._tempFireZoomEvent,this.fire(`move`),this._moveEnd(!0))}};for(let e of[ke,N,J,F,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Mt,Y,Rt,Et,Le])e.register(Q);var Yt=class e extends R{static defaultOptions={smoothFactor:.5,noClip:!1};constructor(t,n){super(),f(this,n),this._setLatLngs(t),this.callInitHooks(e)}getLatLngs(){return this._latlngs}setLatLngs(e){return this._setLatLngs(e),this.redraw()}isEmpty(){return!this._latlngs.length}closestLayerPoint(e){e=g.from(e);let t=1/0,n=null,r,i,a=H;for(let o of this._parts)for(let s=1,c=o.length;s<c;s++){r=o[s-1],i=o[s];let c=a(e,r,i,!0);c<t&&(t=c,n=a(e,r,i))}return n&&(n.distance=Math.sqrt(t)),n}getCenter(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return ct(this._defaultShape(),this._map.options.crs)}getBounds(){return this._bounds}addLatLng(e,t){return t??=this._defaultShape(),e=new V(e),t.push(e),this._bounds.extend(e),this.redraw()}_setLatLngs(e){this._bounds=new z,this._latlngs=this._convertLatLngs(e)}_defaultShape(){return U(this._latlngs)?this._latlngs:this._latlngs[0]}_convertLatLngs(e){let t=[],n=U(e);for(let r=0,i=e.length;r<i;r++)n?(t[r]=new V(e[r]),this._bounds.extend(t[r])):t[r]=this._convertLatLngs(e[r]);return t}_project(){let e=new I;this._rings=[],this._projectLatlngs(this._latlngs,this._rings,e),this._bounds.isValid()&&e.isValid()&&(this._rawPxBounds=e,this._updateBounds())}_updateBounds(){let e=this._clickTolerance(),t=new g(e,e);this._rawPxBounds&&(this._pxBounds=new I([this._rawPxBounds.min.subtract(t),this._rawPxBounds.max.add(t)]))}_projectLatlngs(e,t,n){if(e[0]instanceof V){let r=e.map(e=>this._map.latLngToLayerPoint(e));r.forEach(e=>n.extend(e)),t.push(r)}else e.forEach(e=>this._projectLatlngs(e,t,n))}_clipPoints(){let e=this._renderer._bounds;if(this._parts=[],!this._pxBounds||!this._pxBounds.intersects(e))return;if(this.options.noClip){this._parts=this._rings;return}let t=this._parts,n,r,i,a,o,s,c;for(n=0,i=0,a=this._rings.length;n<a;n++)for(c=this._rings[n],r=0,o=c.length;r<o-1;r++)s=it(c[r],c[r+1],e,r),s&&(t[i]??=[],t[i].push(s[0]),(s[1]!==c[r+1]||r===o-2)&&(t[i].push(s[1]),i++))}_simplifyPoints(){let e=this._parts,t=this.options.smoothFactor;for(let n=0,r=e.length;n<r;n++)e[n]=Ze(e[n],t)}_update(){this._map&&(this._clipPoints(),this._simplifyPoints(),this._updatePath())}_updatePath(){this._renderer._updatePoly(this)}_containsPoint(e,t){let n,r,i,a,o,s,c=this._clickTolerance();if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(n=0,a=this._parts.length;n<a;n++)for(s=this._parts[n],r=0,o=s.length,i=o-1;r<o;i=r++)if((t||r!==0)&&Qe(e,s[i],s[r])<=c)return!0;return!1}toGeoJSON(e){let t=!U(this._latlngs),n=dt(this._latlngs,+!!t,!1,e);return W(this,{type:`${t?`Multi`:``}LineString`,coordinates:n})}},Xt=/* @__PURE__ */ t({centroid:()=>en,clipPolygon:()=>Zt,polygonCenter:()=>$t});function Zt(e,t,n){for(let r of[1,4,2,8]){if(!e.length)break;let i=[],a=e[e.length-1],o=Qt(a,r,t);for(let s of e){let e=Qt(s,r,t);e!==o&&i.push(at(a,s,r,t,n)),e||i.push(s),a=s,o=e}e=i}return e}function Qt(e,t,n){return t===1?e.x<n.min.x:t===2?e.x>n.max.x:t===4?e.y<n.min.y:e.y>n.max.y}function $t(e,t){let n=lt(e,t),r=new g(n[0]),i=n.length;for(let e of n)e._subtract(r);let a=0,o=0,s=0;for(let e=0,t=i-1;e<i;t=e++){let r=n[e],i=n[t],c=r.y*i.x-i.y*r.x;o+=(r.x+i.x)*c,s+=(r.y+i.y)*c,a+=c}return t.unproject(a===0?r:new g(o/(3*a),s/(3*a))._add(r))}function en(e){let t=0,n=0,r=0;for(let i of e){let e=V.from(i);t+=e.lat,n+=e.lng,r++}return new V([t/r,n/r])}var tn=class e extends Yt{static defaultOptions={fill:!0};constructor(...t){super(...t),this.callInitHooks(e)}isEmpty(){return!this._latlngs.length||!this._latlngs[0].length}getCenter(){if(!this._map)throw Error(`Must add layer to map before using getCenter()`);return $t(this._defaultShape(),this._map.options.crs)}_convertLatLngs(e){let t=super._convertLatLngs(e),n=t.length;return n>=2&&t[0]instanceof V&&t[0].equals(t[n-1])&&t.pop(),t}_setLatLngs(e){super._setLatLngs(e),U(this._latlngs)&&(this._latlngs=[this._latlngs])}_defaultShape(){return U(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]}_clipPoints(){let e=this._renderer._bounds,t=this.options.weight,n=new g(t,t);if(e=new I(e.min.subtract(n),e.max.add(n)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e)){if(this.options.noClip)this._parts=this._rings;else for(let t of this._rings){let n=Zt(t,e);n.length&&this._parts.push(n)}}}_updatePath(){this._renderer._updatePoly(this,!0)}_containsPoint(e){let t=!1,n,r,i,a,o,s,c,l;if(!this._pxBounds||!this._pxBounds.contains(e))return!1;for(a=0,c=this._parts.length;a<c;a++)for(n=this._parts[a],o=0,l=n.length,s=l-1;o<l;s=o++)r=n[o],i=n[s],r.y>e.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(t=!t);return t||super._containsPoint(e,!0)}toGeoJSON(e){let t=!U(this._latlngs),n=t&&!U(this._latlngs[0]),r=dt(this._latlngs,n?2:+!!t,!0,e);return t||(r=[r]),W(this,{type:`${n?`Multi`:``}Polygon`,coordinates:r})}},nn=class e extends N{static defaultOptions={position:`bottomright`,width:150,height:150,zoomOffset:-5,collapsed:!1,rectangleOptions:{color:`#ff7800`,weight:1,fillOpacity:.2},mapOptions:{}};constructor(t,n){super(n),this._layer=t,this.callInitHooks(e)}addTo(e){return super.addTo(e),this._miniMap.invalidateSize({pan:!1}),this._update(),this}onAdd(e){let t=D(`div`,`maplair-control-minimap`),n=D(`div`,`maplair-control-minimap-map`,t);t.style.width=`${this.options.width}px`,t.style.height=`${this.options.height}px`;let r=this._toggle=D(`button`,`maplair-control-minimap-toggle`,t);return r.type=`button`,y(r,`click`,E),y(r,`click`,this.toggle,this),w(t),C(t),this._miniMap=new Q(n,{attributionControl:!1,zoomControl:!1,doubleClickZoom:!1,scrollWheelZoom:!1,boxZoom:!1,keyboard:!1,pinchZoom:!1,tapDragZoom:!1,ariaLabel:P.translate(`Overview map`),...this.options.mapOptions,layers:[this._layer]}),n.tabIndex=-1,this._rectangle=new tn([],{interactive:!1,...this.options.rectangleOptions}),this._miniMap.on({moveend:this._onMiniMapMoveEnd,click:this._onMiniMapClick},this),e.on(`move zoom rotate resize`,this._update,this),e.whenReady(this._update,this),this._setCollapsed(this.options.collapsed),t}onRemove(e){e.off(`move zoom rotate resize`,this._update,this),this._miniMap.remove(),this._miniMap=null}getMiniMap(){return this._miniMap}toggle(){return this._setCollapsed(!this._collapsed)}_setCollapsed(e){this._collapsed=e;let t=this._container??this._toggle.parentNode,n=e?P.translate(`Show the overview map`):P.translate(`Hide the overview map`);return t.classList.toggle(`maplair-control-minimap-collapsed`,e),this._toggle.title=n,this._toggle.setAttribute(`aria-label`,n),this._toggle.setAttribute(`aria-expanded`,!e),e||(this._miniMap.invalidateSize(),this._update()),this}_update(){let e=this._map,t=this._miniMap;if(!e?._loaded||!t||this._collapsed)return;let n=Math.max(t.getMinZoom(),Math.min(e.getZoom()+this.options.zoomOffset,t.getMaxZoom()));t.setView(e.getCenter(),n,{animate:!1});let r=e.getSize();this._rectangle.setLatLngs([[0,0],[r.x,0],r,[0,r.y]].map(t=>e.containerPointToLatLng(t))),t.hasLayer(this._rectangle)||this._rectangle.addTo(t)}_onMiniMapMoveEnd(e){e.originalEvent&&this._map.panTo(this._miniMap.getCenter())}_onMiniMapClick(e){this._miniMap.dragging?.moved()||this._map.panTo(e.latlng)}},rn=class e extends N{static defaultOptions={position:`bottomleft`,maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=`maplair-control-scale`,n=D(`div`,t),r=this.options;return this._addScales(r,`${t}-line`,n),e.on(r.updateWhenIdle?`moveend`:`move`,this._update,this),e.whenReady(this._update,this),n}onRemove(e){e.off(this.options.updateWhenIdle?`moveend`:`move`,this._update,this)}_addScales(e,t,n){e.metric&&(this._mScale=D(`div`,t,n)),e.imperial&&(this._iScale=D(`div`,t,n))}_update(){let e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)}_updateScales(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)}_updateMetric(e){let t=this._getRoundNum(e),n=t<1e3?P.translate(`{meters} m`,{meters:t}):P.translate(`{kilometers} km`,{kilometers:t/1e3});this._updateScale(this._mScale,n,t/e)}_updateImperial(e){let t=e*3.2808399,n,r,i;t>5280?(n=t/5280,r=this._getRoundNum(n),this._updateScale(this._iScale,P.translate(`{miles} mi`,{miles:r}),r/n)):(i=this._getRoundNum(t),this._updateScale(this._iScale,P.translate(`{feet} ft`,{feet:i}),i/t))}_updateScale(e,t,n){e.style.width=`${Math.round(this.options.maxWidth*n)}px`,e.innerHTML=t}_getRoundNum(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}},an=class e extends h{static defaultOptions={popupAnchor:[0,0],tooltipAnchor:[0,0],crossOrigin:!1};constructor(t){super(),f(this,t),this.callInitHooks(e)}createIcon(e){return this._createIcon(`icon`,e)}createShadow(e){return this._createIcon(`shadow`,e)}_createIcon(e,t){let n=this._getIconUrl(e);if(!n){if(e===`icon`)throw Error(`iconUrl not set in Icon options (see the docs).`);return null}let r=this._createImg(n,t instanceof HTMLImageElement?t:null);return this._setIconStyles(r,e),(this.options.crossOrigin||this.options.crossOrigin===``)&&(r.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),r}_setIconStyles(e,t){let n=this.options,r=n[`${t}Size`];typeof r==`number`&&(r=[r,r]);let i=g.validate(r)&&g.from(r),a=t===`shadow`&&n.shadowAnchor||n.iconAnchor||i&&i.divideBy(2,!0),o=g.validate(a)&&g.from(a);e.className=`maplair-marker-${t} ${n.className||``}`,o&&(e.style.marginLeft=`${-o.x}px`,e.style.marginTop=`${-o.y}px`),e.style.transformOrigin=o?`${o.x}px ${o.y}px`:`0 0`,i&&(e.style.width=`${i.x}px`,e.style.height=`${i.y}px`)}_createImg(e,t){return t??=document.createElement(`img`),t.src=e,t}_getIconUrl(e){return window.devicePixelRatio>1&&this.options[`${e}RetinaUrl`]||this.options[`${e}Url`]}};const on=(e,t,n,r,i,a=``)=>`data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round" viewBox="0 0 500 820"><defs><linearGradient id="a" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 478.727 62.272)scale(37.566)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${e}"/><stop offset="1" stop-color="${t}" stop-opacity="${n}"/></linearGradient><linearGradient id="b" x1="0" x2="1" y1="0" y2="0" gradientTransform="rotate(-90 468.484 54.002)scale(19.053)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="${r}"/><stop offset="1" stop-color="${i}"/></linearGradient></defs><g fill="%23FFF"><path id="p" d="M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z" transform="translate(-7889.1 -9807.44)scale(19.5417)"/></g><use href="%23p" fill="url(%23a)" stroke="url(%23b)" stroke-width="1.1" stroke-linejoin="miter" stroke-miterlimit="10"/>${a}<path fill="%23FFF" d="m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z" transform="translate(250 258)scale(.068)"/></svg>`;var sn=class e extends an{static defaultOptions={iconUrl:/* @__PURE__ */ on(`%23C2331B`,`%23E2603F`,1,`%238F2D20`,`%23B23A27`),shadowUrl:`data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 817.2 820"><radialGradient id="a" cx="526.6" cy="486.836" r="478.154" fx="275.876" fy="893.983" gradientUnits="userSpaceOnUse"><stop offset="0" style="stop-color:%235c5c5c;stop-opacity:.9477"/><stop offset=".112" style="stop-color:%23474747;stop-opacity:.7805"/><stop offset=".34" style="stop-color:%23202020;stop-opacity:.4413"/><stop offset=".523" style="stop-color:%23090909;stop-opacity:.1692"/><stop offset=".637" style="stop-color:%23000;stop-opacity:0"/></radialGradient><path d="M254.7 820.0L430.1 664.9L473.9 626.1L541.3 599.9L561.5 548.6L629.0 522.4L648.1 470.5L715.4 440.2L726.3 388.9L789.2 347.6L774.9 302.4L817.1 250.3L775.4 221.8L792.3 168.8L732.1 159.3L721.8 112.9L651.7 124.5L614.0 92.7L545.0 124.7L486.2 113.3L430.2 159.7L360.8 169.0L325.1 222.0L255.1 250.3L245.6 302.4L186.6 347.8L209.1 388.9L169.0 440.0L205.6 470.8L173.5 522.7L215.1 548.9L184.8 600.2L226.4 626.3L232.1 665.1Z" style="fill-rule:evenodd;clip-rule:evenodd;fill:url(%23a);fill-opacity:.7;filter:blur(15px)"/></svg>`,iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],tooltipAnchor:[16,-28],shadowSize:[41,41],color:null};constructor(...t){super(...t),this.callInitHooks(e)}_getIconUrl(e){let{color:t}=this.options;if(!t||e!==`icon`)return super._getIconUrl(e);let n=encodeURIComponent(t);return on(n,n,.75,n,n,`<use href="%23p" fill="none" stroke="%23666" stroke-opacity=".4"/>`)}};const cn={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]};var ln=class e extends X{constructor(t){super(t._map),this._marker=t,this.callInitHooks(e)}addHooks(){let e=this._marker._icon;this._draggable||=new Z(e),this._draggable.on({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).enable(),y(e,`keydown keyup blur`,this._onKey,this),e.classList.add(`maplair-marker-draggable`)}removeHooks(){this._keyOffset=null,this._draggable.off({dragstart:this._onDragStart,predrag:this._onPreDrag,drag:this._onDrag,dragend:this._onDragEnd},this).disable(),x(this._draggable._element,`keydown keyup blur`,this._onKey,this),this._marker._icon?.classList.remove(`maplair-marker-draggable`)}moved(){return this._draggable?._moved}_adjustPan(e){let t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=j(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=new I(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){let i=new g((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(i,{animate:!1}),this._draggable._newPos._add(i),this._draggable._startPos._add(i),A(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e))}}_onDragStart(){this._oldLatLng=this._marker.getLatLng(),this._marker.closePopup?.(),this._marker.fire(`movestart`).fire(`dragstart`)}_onPreDrag(e){this._marker.options.autoPan&&(cancelAnimationFrame(this._panRequest),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e)))}_onDrag(e){let t=this._marker,n=j(t._icon),r=t._map.layerPointToLatLng(n);t._positionElements(n),t._latlng=r,e.latlng=r,e.oldLatLng=this._oldLatLng,t.fire(`move`,e).fire(`drag`,e)}_onDragEnd(e){cancelAnimationFrame(this._panRequest),delete this._oldLatLng,this._marker.fire(`moveend`).fire(`dragend`,e)}_onKey(e){let t=e,n=cn[t.key],r=this._draggable,{options:i,_map:a}=this._marker;if(e.type!==`keydown`)this._keyOffset&&(this._keyOffset=null,r.finishDrag());else if(n&&t.target===r._element&&!(t.altKey||t.ctrlKey||t.metaKey)){if(e.preventDefault(),!this._keyOffset){if(Z._dragging)return;Z._dragging=r,r._startPos=j(r._element),r._moved=r._moving=!0,this._keyOffset=new g(0,0),r.fire(`dragstart`)}let o=new g(...n).multiplyBy(t.shiftKey?30:10);this._keyOffset=this._keyOffset.add(a._rotateToPane?.(o)??o),r._newPos=r._startPos.add(this._keyOffset),A(r._element,r._newPos),r.fire(`drag`,{originalEvent:t}),i.autoPan&&a.panInside(this._marker._latlng,{padding:i.autoPanPadding,animate:!1})}}},$=class e extends F{static defaultOptions={icon:/* @__PURE__ */ new sn,interactive:!0,keyboard:!0,title:``,alt:`Marker`,zIndexOffset:0,opacity:1,rotation:null,riseOnHover:!1,riseOffset:250,pane:`markerPane`,shadowPane:`shadowPane`,shadow:!0,bubblingPointerEvents:!1,autoPanOnFocus:!0,draggable:!1,autoPan:!1,autoPanPadding:[50,50],autoPanSpeed:10};constructor(t,n){super(),f(this,n),this._latlng=new V(t),this.callInitHooks(e)}onAdd(e){this._zoomAnimated=this._zoomAnimated&&e.options.markerZoomAnimation,this._zoomAnimated&&e.on(`zoomanim`,this._animateZoom,this),this._initIcon(),this.update(),e.options.markerCulling&&this._updateCulling()}onRemove(e){this.dragging&&(this.options.draggable=this.dragging.enabled(),this.options.draggable&&this.dragging.removeHooks()),delete this.dragging,this._zoomAnimated&&e.off(`zoomanim`,this._animateZoom,this),this._removeIcon(),this._removeShadow(),this._culled=!1}getEvents(){let e={zoom:this.update,viewreset:this.update};return this._map?.options.markerCulling&&(e.moveend=this._updateCulling),e}getLatLng(){return this._latlng}setLatLng(e){let t=this._latlng;return this._latlng=new V(e),this._map?.options.markerCulling&&this._updateCulling(),this.update(),this.fire(`move`,{oldLatLng:t,latlng:this._latlng})}setZIndexOffset(e){return this.options.zIndexOffset=e,this.update()}getIcon(){return this.options.icon}setIcon(e){return this.options.icon=e,this._map&&(this._initIcon(),this.update()),this}getElement(){return this._icon}update(){if(this._icon&&this._map&&!this._culled){let e=this._map.latLngToLayerPoint(this._latlng)._round();this._setPos(e)}return this}_initIcon(){let e=this.options,t=`maplair-zoom-${this._zoomAnimated?`animated`:`hide`}`,n=e.icon.createIcon(this._icon),r=!1;n!==this._icon&&(this._icon&&this._removeIcon(),r=!0,e.title&&(n.title=e.title),n instanceof HTMLImageElement&&(n.alt=e.alt??``)),n.classList.add(t),e.keyboard&&(n.tabIndex=0,e.interactive&&n.setAttribute(`role`,`button`),y(n,`keydown`,this._onKeyDown,this)),this._icon=n,e.riseOnHover&&this.on({pointerover:this._bringToFront,pointerout:this._resetZIndex}),this.options.autoPanOnFocus&&y(n,`focus`,this._panOnFocus,this);let i=e.shadow?e.icon.createShadow?.(this._shadow)??null:null,a=!1;i!==this._shadow&&(this._removeShadow(),a=!0),i&&(i.classList.add(t),i.alt=``),this._shadow=i,e.opacity<1&&this._updateOpacity(),r&&this.getPane().appendChild(this._icon),this._initInteraction(),i&&a&&this.getPane(e.shadowPane).appendChild(this._shadow)}_removeIcon(){this.options.riseOnHover&&this.off({pointerover:this._bringToFront,pointerout:this._resetZIndex}),this.options.autoPanOnFocus&&x(this._icon,`focus`,this._panOnFocus,this),x(this._icon,`keydown`,this._onKeyDown,this),this._icon.remove(),this.removeInteractiveTarget(this._icon),this._icon=null}_updateCulling(){if(!this._icon||!this._map)return;let e=this._map,t=(e._cullingBounds??=e.getBounds().pad(.5)).contains(this._latlng)||!!this.dragging?._draggable?._moving||this._icon.contains(document.activeElement);t!==!this._culled&&(this._culled=!t,t?(this.getPane().appendChild(this._icon),this._shadow&&this.getPane(this.options.shadowPane).appendChild(this._shadow),this.update()):(this._icon.remove(),this._shadow?.remove()))}_removeShadow(){this._shadow?.remove(),this._shadow=null}_setPos(e){this._positionElements(e),this._zIndex=e.y+this.options.zIndexOffset,this._resetZIndex()}_positionElements(e){let t=this.options.rotation;this._icon&&(A(this._icon,e),t!=null&&(this._icon.style.transform+=` rotate(${t}deg)`)),this._shadow&&(A(this._shadow,e),this._shadow.style.display=t==null?``:`none`)}_updateZIndex(e){let t=String(this._zIndex+e);this._icon&&this._icon.style.zIndex!==t&&(this._icon.style.zIndex=t)}_animateZoom(e){if(this._culled)return;let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center)._round();this._setPos(t)}_updateInteractive(){this._icon&&(this.options.keyboard&&(this.options.interactive?this._icon.setAttribute(`role`,`button`):this._icon.removeAttribute(`role`)),this.options.interactive?(this._initInteraction(),this._draggableBeforeNonInteractive&&this.dragging?.enable()):(this._icon.classList.remove(`maplair-interactive`),this.removeInteractiveTarget(this._icon),this._draggableBeforeNonInteractive=this.dragging?.enabled(),this.dragging?.disable()))}_initInteraction(){if(this.options.interactive&&(this._icon.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._icon),ln)){if(this.dragging?._draggable?._element===this._icon){this._icon.classList.toggle(`maplair-marker-draggable`,this.dragging.enabled());return}let e=this.options.draggable;this.dragging&&(e=this.dragging.enabled(),this.dragging.disable()),this.dragging=new ln(this),e&&this.dragging.enable()}}getRotation(){return this.options.rotation}setRotation(e){return this.options.rotation=e,this._icon&&!this._map._animatingZoom&&(this._positionElements(j(this._icon)),this._popup?._updatePosition(),this._tooltip?._updatePosition()),this}setOpacity(e){return this.options.opacity=e,this._map&&this._updateOpacity(),this}_updateOpacity(){let e=this.options.opacity;this._icon&&(this._icon.style.opacity=`${e}`),this._shadow&&(this._shadow.style.opacity=`${e}`)}_bringToFront(){this._updateZIndex(this.options.riseOffset)}_resetZIndex(){this._updateZIndex(0)}_onKeyDown(e){this.options.interactive&&e.target===this._icon&&!e.repeat&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this._clickedByKeyboard=!0,this._icon.click(),this._clickedByKeyboard=!1)}_panOnFocus(){let e=this._map;if(!e)return;let t=this._icon,n=getComputedStyle(t),r=new g(-parseFloat(n.marginLeft)||0,-parseFloat(n.marginTop)||0),i=new g(t.offsetWidth,t.offsetHeight);e.panInside(this._latlng,{paddingTopLeft:r,paddingBottomRight:i.subtract(r)})}_getPopupAnchor(){return this._rotateAnchor(this.options.icon.options.popupAnchor)}_getTooltipAnchor(){return this._rotateAnchor(this.options.icon.options.tooltipAnchor)}_rotateAnchor(e){let t=this.options.rotation*Math.PI/180;if(!t||!e)return e;let{x:n,y:r}=g.from(e),i=Math.cos(t),a=Math.sin(t);return new g(n*i-r*a,n*a+r*i)}toGeoJSON(e){return pt(this,e)}};const un=/* @__PURE__ */ new Map;function dn(e,t){return new Promise((n,r)=>{let i=setTimeout(n,e);t.addEventListener(`abort`,()=>{clearTimeout(i),r(t.reason)},{once:!0})})}var fn=class e extends N{static defaultOptions={position:`topleft`,geocoder:void 0,collapsed:!0,autoComplete:!1,autoCompleteDelay:250,minLength:3,zoom:16,marker:!0,clearOnMapClick:!1,placeholder:void 0,noResultsText:void 0};static nominatim({url:e=`https://nominatim.openstreetmap.org/search`,params:t={},acceptUsagePolicy:n=!1}={}){let{host:r}=new URL(e),i=r===`nominatim.openstreetmap.org`;if(i&&!n)throw Error(`Using the public Nominatim service requires that you read and accept its usage policy (https://operations.osmfoundation.org/policies/nominatim/) with the acceptUsagePolicy option.`);let a=/* @__PURE__ */ new Map;async function o(n,{signal:i}){let o=`${e}?${new URLSearchParams({q:n,format:`jsonv2`,limit:`5`,...t})}`;if(a.has(o))return a.get(o);let s=Date.now(),c=un.get(r)??0,l=c-s;un.set(r,Math.max(s,c)+1e3),l>0&&await dn(l,i);let u=await fetch(o,{signal:i});if(!u.ok)throw Error(`Nominatim: ${u.status} ${u.statusText}`);let d=(await u.json()).map(e=>{let[t,n,r,i]=e.boundingbox.map(Number);return{label:e.display_name,latlng:[Number(e.lat),Number(e.lon)],bounds:[[t,r],[n,i]],raw:e}});return a.set(o,d),a.size>100&&a.delete(a.keys().next().value),d}return Object.defineProperties(o,{attribution:{get:()=>`© <a href="https://www.openstreetmap.org/copyright">${P.translate(`OpenStreetMap contributors`)}</a>`},autoComplete:{value:!i}})}static layers(e,{property:t=`name`,label:n=e=>e.feature?.properties?.[t],limit:r=10}={}){return t=>{t=t.toLocaleLowerCase();let i=[];return e.eachLayer(function e(r){let a=n(r);if(a==null||a===``){r.eachLayer?.(e);return}let o={label:String(a),layer:r,raw:r.feature},s=o.label.toLocaleLowerCase().indexOf(t);if(!(s<0)){if(r.getLatLng)o.latlng=r.getLatLng();else if(r.getBounds?.().isValid())o.bounds=r.getBounds(),o.latlng=o.bounds.getCenter();else return;i.push({result:o,prefix:s===0})}}),Promise.resolve(i.sort((e,t)=>t.prefix-e.prefix||e.result.label.localeCompare(t.result.label)).slice(0,r).map(({result:e})=>e))}}constructor(...t){if(super(...t),!this.options.geocoder)throw Error(`SearchControl: the geocoder option is required, e.g. SearchControl.nominatim().`);this.callInitHooks(e)}onAdd(e){let t=`maplair-control-search`,n=this._container=D(`div`,`${t} maplair-bar`),r=D(`form`,`${t}-form`,n),i=this._toggle=D(`button`,`${t}-toggle`,r),o=this._input=D(`input`,`${t}-input`,r),s=D(`button`,`${t}-reset`,r),c=this._list=D(`ul`,`${t}-results`,n),l=`${t}-results-${a(this)}`,u=P.translate(`Search`);return r.role=`search`,i.type=`button`,i.innerHTML=`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><circle cx="6.5" cy="6.5" r="4.5"/><path d="M10 10l4.5 4.5"/></svg>`,i.title=u,i.setAttribute(`aria-label`,u),o.type=`search`,o.placeholder=this.options.placeholder??u,o.autocomplete=`off`,o.enterKeyHint=`search`,o.role=`combobox`,o.setAttribute(`aria-label`,u),o.setAttribute(`aria-autocomplete`,`list`),o.setAttribute(`aria-controls`,l),s.type=`reset`,s.innerHTML=`<span aria-hidden="true">×</span>`,s.title=P.translate(`Clear the search`),s.setAttribute(`aria-label`,s.title),c.id=l,c.role=`listbox`,c.setAttribute(`aria-label`,P.translate(`Search results`)),this._message=D(`div`,`${t}-message`,n),this._message.role=`status`,w(n),C(n),y(i,`click`,this._onToggle,this),y(r,`submit`,this._onSubmit,this),y(r,`reset`,this._onReset,this),y(o,`input`,this._onInput,this),y(o,`keydown`,this._onKeyDown,this),y(c,`click`,this._onListClick,this),e.on(`click`,this._onMapClick,this),this._attribution=this.options.geocoder.attribution,e.attributionControl?.addAttribution(this._attribution),this._showResults([]),this._setExpanded(!this.options.collapsed),n}onRemove(e){e.off(`click`,this._onMapClick,this),e.attributionControl?.removeAttribution(this._attribution),this._abort(),this._marker?.remove()}expand(){return this._setExpanded(!0),this._input.focus(),this}collapse(){return this._showResults([]),this._setExpanded(!this.options.collapsed),this}async search(e){if(this._abort(),this._input.value=e,e=e.trim(),!e)return this._showResults([]),[];let t=V.parse(e);if(t){let n=[{label:e,latlng:t}];return this._showResults(n),n}let n=this._controller=new AbortController;this._container.classList.add(`maplair-control-search-loading`);try{let t=await this.options.geocoder(e,{signal:n.signal});return n.signal.aborted||this._showResults(t,this.options.noResultsText??P.translate(`No results`)),t}catch(e){if(n.signal.aborted)return[];throw this._showResults([],P.translate(`The search failed`)),e}finally{this._controller===n&&(this._controller=null,this._container.classList.remove(`maplair-control-search-loading`))}}select(e){let t=this._map,n=V.from(e.latlng),r=e.bounds?z.from(e.bounds):void 0;this._input.value=e.label,this._showResults([]),r?.isValid()&&!r.getNorthWest().equals(r.getSouthEast())?t.fitBounds(r,{maxZoom:this.options.zoom}):t.setView(n,this.options.zoom),this._marker?.remove();let{marker:i}=this.options;return this._marker=typeof i==`function`?i(e)?.addTo(t)??null:i?new $(n,{title:e.label}).addTo(t):null,t.fire(`searchresult`,{result:e,latlng:n,bounds:r}),this}clear(){return this._abort(),this._input.value=``,this._showResults([]),this._marker?.remove(),this._marker=null,this}_setExpanded(e){this._container.classList.toggle(`maplair-control-search-expanded`,e),this._toggle.setAttribute(`aria-expanded`,e)}_abort(){clearTimeout(this._autoCompleteTimeout),this._controller?.abort(),this._controller=null,this._container?.classList.remove(`maplair-control-search-loading`)}_showResults(e,t=``){this._results=e,this._list.replaceChildren(...e.map((e,t)=>{let n=D(`li`,`maplair-control-search-result`);return n.id=`${this._list.id}-${t}`,n.role=`option`,n.textContent=e.label,n})),this._list.hidden=!e.length,this._message.textContent=e.length?``:t,this._message.hidden=!this._message.textContent,this._input.setAttribute(`aria-expanded`,!!e.length),this._setActive(-1)}_setActive(e){this._active=e;for(let[t,n]of[...this._list.children].entries())n.setAttribute(`aria-selected`,t===e);if(e<0)this._input.removeAttribute(`aria-activedescendant`);else{let t=this._list.children[e];this._input.setAttribute(`aria-activedescendant`,t.id),t.scrollIntoView({block:`nearest`})}}_onToggle(){this.options.collapsed&&!this._container.classList.contains(`maplair-control-search-expanded`)?this.expand():this._onSubmit()}_onSubmit(e){e&&T(e);let t=this._input.value,n=this._results[this._active],r=V.parse(t);n?this.select(n):r?this.select({label:t.trim(),latlng:r}):this.search(t).catch(c)}_onReset(){this.clear(),this._input.focus()}_onInput(){clearTimeout(this._autoCompleteTimeout);let e=this._input.value.trim();!this.options.autoComplete||this.options.geocoder.autoComplete===!1?this._showResults([]):e.length>=this.options.minLength||V.parse(e)?this._autoCompleteTimeout=setTimeout(()=>{this.search(this._input.value).catch(c)},this.options.autoCompleteDelay):(this._abort(),this._showResults([]))}_onKeyDown(e){let t=this._results.length;if((e.key===`ArrowDown`||e.key===`ArrowUp`)&&t){T(e);let n=e.key===`ArrowDown`?1:-1;this._setActive(((this._active<0&&n<0?t:this._active)+n+t)%t)}else e.key===`Escape`&&(T(e),t||!this._message.hidden?this._showResults([]):this._input.value?this.clear():this.options.collapsed&&(this.collapse(),this._map.getContainer().focus()))}_onListClick(e){let t=e.target.closest(`.maplair-control-search-result`),n=[...this._list.children].indexOf(t);n>=0&&this.select(this._results[n])}_onMapClick(){this.options.clearOnMapClick?(this.clear(),this.collapse()):this._input.value?this._showResults([]):this.collapse()}},pn=class e extends N{static defaultOptions={ratio:.5};constructor(t,n,r){super(r),this._leftLayers=[t??[]].flat(),this._rightLayers=[n??[]].flat(),this._ratio=this.options.ratio,this.callInitHooks(e)}addTo(e){return this.remove(),this._map=e,this._container=this.onAdd(e),e._container.appendChild(this._container),e.on(`unload`,this.remove,this),this}onAdd(e){let t=D(`div`,`maplair-sidebyside-divider`),n=P.translate(`Divider between the compared layers`);return t.tabIndex=0,t.setAttribute(`role`,`slider`),t.setAttribute(`aria-label`,n),t.setAttribute(`aria-valuemin`,0),t.setAttribute(`aria-valuemax`,100),w(t),y(t,`pointerdown`,this._onPointerDown,this),y(t,`keydown`,this._onKeyDown,this),e.on(`move zoom viewreset resize rotate layeradd`,this._update,this),this._container=t,this._update(),t}onRemove(e){this._onPointerUp(),e.off(`move zoom viewreset resize rotate layeradd`,this._update,this);for(let e of[...this._leftLayers,...this._rightLayers]){let t=mn(e);t&&(t.style.clipPath=``)}}setLeftLayers(e){return this._clear(this._leftLayers),this._leftLayers=[e].flat(),this._update()}setRightLayers(e){return this._clear(this._rightLayers),this._rightLayers=[e].flat(),this._update()}getRatio(){return this._ratio}setRatio(e){return this._ratio=Math.min(1,Math.max(0,e)),this._update(),this._map?.fire(`dividermove`,{ratio:this._ratio,x:this._x}),this}_clear(e){for(let t of e){let e=mn(t);e&&(e.style.clipPath=``)}}_update(){let e=this._map;if(!e?._loaded||!this._container)return this;let t=e.getSize(),n=this._x=Math.round(t.x*this._ratio);return this._container.style.left=`${n}px`,this._container.setAttribute(`aria-valuenow`,Math.round(this._ratio*100)),this._clip(this._leftLayers,0,n,t.y),this._clip(this._rightLayers,n,t.x,t.y),this}_clip(e,t,n,r){let i=this._map;for(let a of e){let e=mn(a);if(!e||!i.hasLayer(a))continue;let o=j(e),s=[[t,0],[n,0],[n,r],[t,r]].map(e=>{let t=i.containerPointToLayerPoint(e).subtract(o);return`${t.x}px ${t.y}px`});e.style.clipPath=`polygon(${s.join(`, `)})`}}_onPointerDown(e){E(e),this._container.focus({preventScroll:!0}),y(document,`pointermove`,this._onPointerMove,this),y(document,`pointerup pointercancel`,this._onPointerUp,this)}_onPointerMove(e){let t=this._map._container.getBoundingClientRect();this.setRatio((e.clientX-t.left)/t.width)}_onPointerUp(){x(document,`pointermove`,this._onPointerMove,this),x(document,`pointerup pointercancel`,this._onPointerUp,this)}_onKeyDown(e){let t=e.shiftKey?.01:.05;if(e.key===`ArrowLeft`)this.setRatio(this._ratio-t);else if(e.key===`ArrowRight`)this.setRatio(this._ratio+t);else return;E(e)}};function mn(e){return e.getContainer?.()??e.getElement?.()}var hn=class e extends N{static defaultOptions={position:`topright`,content:``,className:``};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(){let e=D(`div`,`maplair-control-text ${this.options.className}`);return w(e),C(e),this._container=e,this._update(),e}setContent(e){return this.options.content=e,this._update(),this}getContent(){return this.options.content}_update(){let e=this._container,{content:t}=this.options;e&&(typeof t==`string`?e.innerHTML=t:e.replaceChildren(t??``),e.hidden=!t)}};const gn=e=>`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="currentColor"><path d="${e}"/></svg>`,_n=gn(`M3 3h2v10H3zm10 0v10L6 8z`),vn=gn(`M4 2v12l10-6z`),yn=gn(`M4 3h3v10H4zm5 0h3v10H9z`),bn=gn(`M11 3h2v10h-2zM3 3v10l7-5z`),xn=/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/;function Sn(e){let t=xn.exec(e);if(!t||e===`P`||e.endsWith(`T`))throw Error(`Invalid or unsupported ISO 8601 duration "${e}".`);let[n,r,i,a,o,s,c]=t.slice(1).map(e=>Number(e??0));return{years:n,months:r,ms:((((i*7+a)*24+o)*60+s)*60+c)*1e3}}function Cn(e,t,n){let r=new Date(e);return r.setUTCFullYear(r.getUTCFullYear()+n*t.years,r.getUTCMonth()+n*t.months),new Date(+r+n*t.ms)}function wn(e){let t=Date.parse(e);if(Number.isNaN(t))throw Error(`Invalid date "${e}".`);return new Date(t)}function Tn(e,t){let n=e.split(`/`);if(n.length===3&&(t=n.pop()),n.length!==2)throw Error(`Invalid ISO 8601 interval "${e}".`);let[r,i]=n,a=Sn(t),o,s;if(r.startsWith(`P`)?(s=wn(i),o=Cn(s,Sn(r),-1)):(o=wn(r),s=i.startsWith(`P`)?Cn(o,Sn(i),1):wn(i)),!(Cn(o,a,1)>o))throw Error(`The period "${t}" has to be positive.`);let c=[];for(let e=0,t=o;t<=s;t=Cn(o,a,++e))c.push(t);return c}var En=class e extends N{static defaultOptions={position:`bottomleft`,times:void 0,interval:void 0,period:`P1D`,time:void 0,layers:[],transitionTime:1e3,loop:!1,formatTime:void 0};constructor(...t){super(...t);let{times:n,interval:r,period:i,time:a,layers:o}=this.options;this._layers=[],this._playing=!1,this._times=[],this._index=-1,this.setTimes(r?Tn(r,i):n??[],a);for(let e of o)this.addLayer(e);this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-bar maplair-control-time`);w(t),C(t),this._previousButton=new Ae({className:`maplair-control-time-previous`,content:_n,title:P.translate(`Step back`),onClick:()=>this.previous()}),this._playButton=new Ae({className:`maplair-control-time-play`,states:[{name:`play`,content:vn,title:P.translate(`Play`),onClick:()=>this.play()},{name:`pause`,content:yn,title:P.translate(`Pause`),onClick:()=>this.pause()}]}),this._nextButton=new Ae({className:`maplair-control-time-next`,content:bn,title:P.translate(`Step forward`),onClick:()=>this.next()});for(let n of[this._previousButton,this._playButton,this._nextButton])n._map=e,n._createButton(t);let n=this._slider=D(`input`,`maplair-control-time-slider`,t);return n.type=`range`,n.min=`0`,n.step=`1`,n.setAttribute(`aria-label`,P.translate(`Time`)),y(n,`input`,this._onSliderInput,this),this._label=D(`span`,`maplair-control-time-label`,t),this._formatter=new Intl.DateTimeFormat(P.getLocale()??void 0,{dateStyle:`short`,timeStyle:`short`}),this._updateControl(),t}onRemove(){this.pause(),this._slider=null}_onSliderInput(){this.pause(),this._setIndex(Number(this._slider.value))}_updateControl(){if(!this._slider)return;let e=this._index,t=this._times.length-1,n=this.getTime(),r=n?(this.options.formatTime??this._formatter.format)(n):``,i=this.options.loop;this._slider.max=String(Math.max(t,0)),this._slider.value=String(Math.max(e,0)),this._slider.disabled=t<1,this._slider.setAttribute(`aria-valuetext`,r),this._label.textContent=r,this._playButton.setState(this._playing?`pause`:`play`),this._setDisabled(this._playButton,t<1),this._setDisabled(this._previousButton,t<1||e===0&&!i),this._setDisabled(this._nextButton,t<1||e===t&&!i)}_setDisabled(e,t){t?e.disable():e.enable()}setTimes(e,t=this.getTime()){return this._times=e.map(e=>new Date(e)),this._index=-1,this._times.length<2&&this.pause(),this.setTime(t??Date.now())}getTimes(){return this._times}setTime(e){let t=+new Date(e),n=this._times.length?0:-1;return this._times.forEach((e,r)=>{Math.abs(+e-t)<Math.abs(+this._times[n]-t)&&(n=r)}),this._setIndex(n)}getTime(){return this._times[this._index]}_setIndex(e){if(e!==this._index){this._index=e;for(let e of this._layers)this._updateLayer(e);e>=0&&this._map?.fire(`timechange`,{time:this.getTime(),index:e}),this._playing&&this._schedule()}return this._updateControl(),this}next(){return this._index<this._times.length-1?this._setIndex(this._index+1):this.options.loop&&this._times.length>1&&this._setIndex(0),this}previous(){return this._index>0?this._setIndex(this._index-1):this.options.loop&&this._times.length>1&&this._setIndex(this._times.length-1),this}play(){return this._playing||this._times.length<2||(this._playing=!0,this._index===this._times.length-1?this._setIndex(0):(this._schedule(),this._updateControl())),this}pause(){return clearTimeout(this._timeout),this._timeout=null,this._playing&&(this._playing=!1,this._updateControl()),this}isPlaying(){return this._playing}_schedule(){clearTimeout(this._timeout),this._timeout=setTimeout(()=>{this._timeout=null,this._advance()},this.options.transitionTime)}_advance(){!this._playing||this._timeout||this._layers.some(e=>e._map&&e.isLoading?.())||(this._index<this._times.length-1||this.options.loop?this.next():this.pause())}_updateLayer(e){let t=this.getTime();t&&(typeof e.setTime==`function`?e.setTime(t):typeof e.setParams==`function`?e.setParams({time:t.toISOString()}):typeof e.setUrl==`function`&&(e.options.time=t.toISOString(),e.setUrl(e._url,!1)))}addLayer(e){return this._layers.includes(e)||(this._layers.push(e),e.on(`load remove`,this._advance,this),this._updateLayer(e)),this}removeLayer(e){return this._layers=this._layers.filter(t=>t!==e),e.off(`load remove`,this._advance,this),this._advance(),this}};const Dn={project(e){return e=V.from(e),new g(e.lng,e.lat)},unproject(e){return e=g.from(e),new V(e.y,e.x)},bounds:/* @__PURE__ */ new I([-180,-90],[180,90])},On={R:6378137,R_MINOR:6356752.314245179,bounds:/* @__PURE__ */ new I([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project(e){e=V.from(e);let t=Math.PI/180,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=e.lat*t,o=i*Math.sin(a),s=Math.tan(Math.PI/4-a/2)/((1-o)/(1+o))**(i/2);return a=-n*Math.log(Math.max(s,1e-10)),new g(e.lng*t*n,a)},unproject(e){e=g.from(e);let t=180/Math.PI,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=Math.exp(-e.y/n),o=Math.PI/2-2*Math.atan(a);for(let e=0,t=.1,n;e<15&&Math.abs(t)>1e-7;e++)n=i*Math.sin(o),n=((1-n)/(1+n))**(i/2),t=Math.PI/2-2*Math.atan(a*n)-o,o+=t;return new V(o*t,e.x*t/n)}};var kn=class extends K{static code=`EPSG:3395`;static projection=On;static transformation=/* @__PURE__ */ (()=>{let e=.5/(Math.PI*On.R);return new St(e,.5,-e,.5)})()},An=class extends K{static code=`EPSG:4326`;static projection=Dn;static transformation=/* @__PURE__ */ new St(1/180,1,-1/180,.5)},jn=class extends yt{static projection=Dn;static transformation=/* @__PURE__ */ new St(1,0,-1,0);static scale(e){return 2**e}static zoom(e){return Math.log(e)/Math.LN2}static distance(e,t){let n=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(n*n+r*r)}static infinite=!0},Mn=class e extends q{constructor(t,n){super(void 0,n),t&&this.addData(t),this.callInitHooks(e)}addData(t){if(Array.isArray(t)||`features`in t){for(let e of Array.isArray(t)?t:t.features)this.addData(e);return this}let n=this.options,r=e.asFeature(t);if(!r.geometry||n.filter&&!n.filter(r))return this;let i=e.geometryToLayer(r,n);return i?(i.feature=r,i.defaultOptions=i.options,this.resetStyle(i),n.onEachFeature&&n.onEachFeature(r,i),this.addLayer(i)):this}resetStyle(e){return e===void 0?this.eachLayer(this.resetStyle,this):(e.options=Object.create(e.defaultOptions),this._setLayerStyle(e,this.options.style),this)}setStyle(e){return this.eachLayer(t=>this._setLayerStyle(t,e))}_setLayerStyle(e,t){e.setStyle&&(typeof t==`function`&&(t=t(e.feature)),e.setStyle(t))}static geometryToLayer(t,n){let r=t.type===`Feature`?t.geometry:t,i=r?.coordinates,a=[],o=n?.pointToLayer,s=n?.coordsToLatLng??e.coordsToLatLng,c,l;if(!i&&!r)return null;switch(r.type){case`Point`:return c=s(i),e._pointToLayer(o,t,c,n);case`MultiPoint`:for(let r of i)c=s(r),a.push(e._pointToLayer(o,t,c,n));return new q(a);case`LineString`:case`MultiLineString`:return l=e.coordsToLatLngs(i,r.type===`LineString`?0:1,s),new Yt(l,n);case`Polygon`:case`MultiPolygon`:return l=e.coordsToLatLngs(i,r.type===`Polygon`?1:2,s),new tn(l,n);case`GeometryCollection`:for(let i of r.geometries){let r=e.geometryToLayer({geometry:i,type:`Feature`,properties:t.properties},n);r&&(r.feature=e.asFeature(i),a.push(r))}return new q(a);case`FeatureCollection`:for(let t of r.features){let r=e.geometryToLayer(t,n);r&&a.push(r)}return new q(a);default:throw Error(`Invalid GeoJSON object.`)}}static _pointToLayer(e,t,n,r){return e?e(t,n):new $(n,r?.markersInheritOptions&&r)}static coordsToLatLng(e){return new V(e[1],e[0],e[2])}static coordsToLatLngs(t,n,r){return t.map(t=>n?e.coordsToLatLngs(t,n-1,r):(r||e.coordsToLatLng)(t))}static latLngToCoords(e,t){return ut(e,t)}static latLngsToCoords(e,t,n,r){return dt(e,t,n,r)}static getFeature(e,t){return W(e,t)}static asFeature(e){return ft(e)}},Nn=class{constructor(e,t){this.options={name:``,value:void 0,normalize:void 0,otherValues:void 0,...t},this._classes=e,this._values=/* @__PURE__ */ new Map,this._labels=/* @__PURE__ */ new Map;let n=[];for(let t of e){if(`value`in t)for(let e of Array.isArray(t.value)?t.value:[t.value]){let n=this._normalize(e);this._values.has(n)||this._values.set(n,t)}else n.push(t);t.legend!==void 0&&!this._labels.has(this._normalize(t.legend))&&this._labels.set(this._normalize(t.legend),t)}this._ranges=n.sort((e,t)=>(e.lower??-1/0)-(t.lower??-1/0));let r=this.options.otherValues;this._other=r&&{legend:P.translate(`All other values`),...r},this.style=this.style.bind(this)}classify(e){let t=this._normalize(this._getValue(e?.feature??e));return this._values.get(t)??this._findRange(t)??this._labels.get(t)??this._other}style(e){return this.classify(e)?.symbol??{}}legendItems(){return this._getItems().items}featureCount(e){let{items:t,itemOf:n}=this._getItems(),r=new Map(t.map(e=>[e,0]));for(let t of e){let e=n.get(this.classify(t));e&&r.set(e,r.get(e)+1)}let i=t.reduce((e,t)=>e+(t.counted?r.get(t):0),0);return t.map(e=>({...e,count:r.get(e),share:e.counted?i?r.get(e)/i:0:void 0}))}_getValue(e){let{value:t}=this.options;return typeof t==`function`?t(e):t===void 0?e:e?.properties?.[t]}_normalize(e){e??=null;let{normalize:t}=this.options;return t&&e!==null?t(e):e}_findRange(e){let t=typeof e==`string`&&e.trim()!==``?Number(e):e;if(typeof t!=`number`||Number.isNaN(t))return;let n=this._ranges,r=0,i=n.length-1,a;for(;r<=i;){let e=r+i>>1;(n[e].lower??-1/0)<=t?(a=n[e],r=e+1):i=e-1}return a&&t<(a.upper??1/0)?a:void 0}_getItems(){let e=[],t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=this._other?[...this._classes,this._other]:this._classes;for(let i of r){let r=i.legend??this._defaultLegend(i),a=`${r}\u0000${JSON.stringify(i.symbol??{})}`,o=n.get(a);o||(o={legend:r,symbol:i.symbol??{},counted:i.counted!==!1,classes:[]},n.set(a,o),e.push(o)),o.classes.push(i),t.set(i,o)}return{items:e,itemOf:t}}_defaultLegend(e){if(`value`in e)return[e.value].flat().map(String).join(`, `);let t=e=>e.toLocaleString(P.getLocale()??void 0);return e.lower===void 0?`< ${t(e.upper)}`:e.upper===void 0?`≥ ${t(e.lower)}`:`${t(e.lower)}–${t(e.upper)}`}static quantile(e,t){let n=e.filter(Number.isFinite).toSorted((e,t)=>e-t),r=[];for(let e=1;e<t&&n.length;e++)r.push(n[Math.floor(e*n.length/t)]);return Pn(r)}static equalInterval(e,t){let n=e.filter(Number.isFinite);if(!n.length)return Pn([]);let r=Math.min(...n),i=(Math.max(...n)-r)/t,a=[];for(let e=1;e<t;e++)a.push(r+e*i);return Pn(a)}};function Pn(e){let t=[...new Set(e)];return[void 0,...t].map((e,n)=>{let r={};return e!==void 0&&(r.lower=e),n<t.length&&(r.upper=t[n]),r})}var Fn=class e extends Be{static defaultOptions={radius:25,blur:15,max:1,maxZoom:void 0,minOpacity:.05,gradient:{.4:`blue`,.6:`cyan`,.7:`lime`,.8:`yellow`,1:`red`},pane:`overlayPane`};constructor(t,n){super(n),this._latlngs=t??[],this.callInitHooks(e)}setLatLngs(e){return this._latlngs=e,this.redraw()}addLatLng(e){return this._latlngs.push(e),this.redraw()}getLatLngs(){return this._latlngs}setOptions(e){return f(this,e),this._circle=this._gradient=null,this.redraw()}redraw(){return this._map&&this._bounds&&(cancelAnimationFrame(this._frame),this._frame=requestAnimationFrame(()=>this._draw())),this}_initContainer(){this._container=document.createElement(`canvas`),this._container.classList.add(`maplair-heatmap-layer`),this._ctx=this._container.getContext(`2d`)}_destroyContainer(){cancelAnimationFrame(this._frame),super._destroyContainer()}_resizeContainer(){let e=super._resizeContainer();return this._container.width=e.x,this._container.height=e.y,e}_onSettled(){this._draw()}_getCircle(){if(this._circle)return this._circle;let{radius:e,blur:t}=this.options,n=e+t,r=this._circle=document.createElement(`canvas`),i=r.getContext(`2d`);return r.width=r.height=n*2,i.shadowOffsetX=i.shadowOffsetY=n*2,i.shadowBlur=t,i.shadowColor=`black`,i.beginPath(),i.arc(-n,-n,e,0,Math.PI*2,!0),i.closePath(),i.fill(),r}_getGradient(){if(this._gradient)return this._gradient;let e=document.createElement(`canvas`),t=e.getContext(`2d`),n=t.createLinearGradient(0,0,0,256);e.width=1,e.height=256;for(let[e,t]of Object.entries(this.options.gradient))n.addColorStop(Number(e),t);return t.fillStyle=n,t.fillRect(0,0,1,256),this._gradient=t.getImageData(0,0,1,256).data,this._gradient}_draw(){let e=this._map;if(!e||!this._bounds)return;let t=this._ctx,{width:n,height:r}=this._container,i=this._bounds.min,{radius:a,blur:o,max:s,minOpacity:c}=this.options,l=a+o,u=this.options.maxZoom??e.getMaxZoom(),d=1/2**Math.max(0,Math.min(u-e.getZoom(),12)),f=a/2,p=/* @__PURE__ */ new Map;for(let t of this._latlngs){let a=e.latLngToLayerPoint(t)._round()._subtract(i);if(a.x<-l||a.y<-l||a.x>n+l||a.y>r+l)continue;let o=(t.alt??t[2]??1)*d,s=`${Math.floor(a.x/f)}:${Math.floor(a.y/f)}`,c=p.get(s);if(c){let e=c.intensity+o;c.x=(c.x*c.intensity+a.x*o)/e,c.y=(c.y*c.intensity+a.y*o)/e,c.intensity=e}else p.set(s,{x:a.x,y:a.y,intensity:o})}t.clearRect(0,0,n,r);let ee=this._getCircle();for(let{x:e,y:n,intensity:r}of p.values())t.globalAlpha=Math.min(Math.max(r/s,c),1),t.drawImage(ee,e-l,n-l);if(t.globalAlpha=1,!p.size)return;let te=t.getImageData(0,0,n,r),m=te.data,h=this._getGradient();for(let e=3;e<m.length;e+=4){let t=m[e]*4;t&&(m[e-3]=h[t],m[e-2]=h[t+1],m[e-1]=h[t+2])}t.putImageData(te,0,0)}},In=class e extends F{static defaultOptions={opacity:1,alt:``,interactive:!1,crossOrigin:!1,errorOverlayUrl:``,zIndex:1,className:``,pixelated:!1,decoding:`auto`};constructor(t,n,r){super(),this._url=t,this._bounds=new z(n),f(this,r),this.callInitHooks(e)}onAdd(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(this._image.classList.add(`maplair-interactive`),this.addInteractiveTarget(this._image)),this._image.classList.toggle(`maplair-pixelated`,!!this.options.pixelated),this.getPane().appendChild(this._image),this._reset()}onRemove(){this._image.remove(),this.options.interactive&&this.removeInteractiveTarget(this._image)}_updateInteractive(){this._image.classList.toggle(`maplair-interactive`,this.options.interactive),this.options.interactive?this.addInteractiveTarget(this._image):this.removeInteractiveTarget(this._image)}setOpacity(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this}setStyle(e){return e.opacity&&this.setOpacity(e.opacity),this}bringToFront(){return this._map&&O(this._image),this}bringToBack(){return this._map&&Se(this._image),this}setUrl(e){return this._url=e,this._image&&(this._image.src=e),this}setBounds(e){return this._bounds=new z(e),this._map&&this._reset(),this}getEvents(){return{zoom:this._reset,viewreset:this._reset,zoomanim:this._animateZoom}}setZIndex(e){return this.options.zIndex=e,this._updateZIndex(),this}getBounds(){return this._bounds}getElement(){return this._image}_initImage(){let e=this._url instanceof HTMLImageElement,t=this._image=e?this._url:D(`img`);t.classList.add(`maplair-image-layer`,`maplair-zoom-animated`),this.options.className&&t.classList.add(...d(this.options.className)),t.onload=this.fire.bind(this,`load`),t.onerror=this._overlayOnError.bind(this),(this.options.crossOrigin||this.options.crossOrigin===``)&&(t.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),t.decoding=this.options.decoding,this.options.zIndex&&this._updateZIndex(),e?this._url=t.src:(t.src=this._url,t.alt=this.options.alt)}_animateZoom(e){let t=this._map.getZoomScale(e.zoom),n=this._map._latLngToNewLayerPoint(this._bounds.getNorthWest(),e.zoom,e.center);k(this._image,n,t)}_reset(){let e=this._image,t=new I(this._map.latLngToLayerPoint(this._bounds.getNorthWest())._round(),this._map.latLngToLayerPoint(this._bounds.getSouthEast())._round()),n=t.getSize();A(e,t.min),e.style.width=`${n.x}px`,e.style.height=`${n.y}px`}_updateOpacity(){this._image.style.opacity=`${this.options.opacity}`}_updateZIndex(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=`${this.options.zIndex}`)}_overlayOnError(){this.fire(`error`);let e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)}getCenter(){return this._bounds.getCenter()}},Ln=class e extends In{static defaultOptions={autoplay:!0,controls:!1,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0};constructor(...t){super(...t),this.callInitHooks(e)}_initImage(){let e=this._url instanceof HTMLVideoElement,t=this._image=e?this._url:D(`video`);if(t.classList.add(`maplair-image-layer`,`maplair-zoom-animated`),this.options.className&&t.classList.add(...d(this.options.className)),y(t,`pointerdown`,e=>{t.controls&&S(e)}),t.onloadeddata=this.fire.bind(this,`load`),e){let e=t.getElementsByTagName(`source`),n=Array.from(e,e=>e.src);this._url=e.length>0?n:[t.src]}else{Array.isArray(this._url)||(this._url=[this._url]),this.options.keepAspectRatio||(t.style.objectFit=`fill`),t.autoplay=!!this.options.autoplay,t.controls=!!this.options.controls,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(let e of this._url){let n=D(`source`);n.src=e,t.appendChild(n)}}}},Rn=class e extends In{constructor(...t){super(...t),this.callInitHooks(e)}_initImage(){let e=this._image=this._url;e.classList.add(`maplair-image-layer`,`maplair-zoom-animated`),this.options.className&&e.classList.add(...d(this.options.className))}},zn=class e extends an{static defaultOptions={iconSize:[12,12],html:!1,bgPos:null,className:`maplair-div-icon`};constructor(...t){super(...t),this.callInitHooks(e)}createIcon(e){let t=e instanceof HTMLDivElement?e:document.createElement(`div`),n=this.options;if(n.html instanceof Element?(t.replaceChildren(),t.appendChild(n.html)):t.innerHTML=n.html===!1?``:n.html,n.bgPos){let e=g.from(n.bgPos);t.style.backgroundPosition=`${-e.x}px ${-e.y}px`}return this._setIconStyles(t,`icon`),t}createShadow(){return null}};function Bn(e,t,n){let r=document.createElementNS(`http://www.w3.org/2000/svg`,e);for(let[e,n]of Object.entries(t))r.setAttribute(e,n);return n?.appendChild(r),r}var Vn=class e extends sn{static defaultOptions={color:`#d4462c`,glyph:void 0,glyphPath:void 0,glyphColor:`white`};constructor(...t){super(...t),this.callInitHooks(e)}createIcon(e){let t=e?.tagName===`DIV`?e:document.createElement(`div`),n=this.options,r=Bn(`svg`,{viewBox:`0 0 500 820`,width:`100%`,height:`100%`,"aria-hidden":`true`});return Bn(`path`,{d:`M416.500 542.096L420.919 533.569L422.024 531.437L424.460 529.996L424.233 527.174L426.670 525.732L426.382 522.881L428.720 521.213L428.075 518.393L429.979 516.125L428.342 513.639L429.080 510.777L426.581 509.207L426.168 506.292L423.266 505.773L421.781 503.221L418.898 503.859L416.511 502.112L414.131 503.870L411.248 503.241L409.766 505.793L406.865 506.302L406.439 509.216L403.933 510.775L404.661 513.641L403.023 516.136L404.935 518.393L404.271 521.204L406.590 522.896L406.299 525.752L408.738 527.189L408.516 530.011L410.956 531.448L412.065 533.578Z`,transform:`translate(-7889.1 -9807.44)scale(19.5417)`,fill:n.color,stroke:`color-mix(in srgb, ${n.color}, black 30%)`,"stroke-width":`1.1`,"stroke-linejoin":`miter`},r),n.glyphPath?Bn(`path`,{d:n.glyphPath,fill:n.glyphColor,transform:`translate(135 155)scale(9.583333333333334)`},r):n.glyph?Bn(`text`,{x:250,y:270,fill:n.glyphColor,"font-size":230,"font-family":`sans-serif`,"font-weight":`bold`,"text-anchor":`middle`,"dominant-baseline":`central`},r).textContent=n.glyph:Bn(`path`,{d:`m-90 2030 45-863a95 95 0 0 0-111-98l-859 151 116-320a65 65 0 0 0-20-73l-941-762 212-99a65 65 0 0 0 34-79l-186-572 542 115a65 65 0 0 0 73-38l105-247 423 454a65 65 0 0 0 111-57l-204-1052 327 189a65 65 0 0 0 91-27l332-652 332 652a65 65 0 0 0 91 27l327-189-204 1052a65 65 0 0 0 111 57l423-454 105 247a65 65 0 0 0 73 38l542-115-186 572a65 65 0 0 0 34 79l212 99-941 762a65 65 0 0 0-20 73l116 320-859-151a95 95 0 0 0-111 98l45 863z`,transform:`translate(250 258)scale(.068)`,fill:n.glyphColor},r),t.replaceChildren(r),this._setIconStyles(t,`icon`),t}},Hn=class e extends q{static defaultOptions={maxClusterRadius:80,disableClusteringAtZoom:void 0,zoomToBoundsOnClick:!0,spiderfyOnMaxZoom:!0,iconCreateFunction:void 0};constructor(t,n){super(t,n),this._shown=/* @__PURE__ */ new Set,this.callInitHooks(e)}addLayer(e){return this.addLayers([e])}addLayers(e){for(let t of e)this.hasLayer(t)||(t.addEventParent(this).on(`dragend`,this._onDragEnd,this),this._layers[this.getLayerId(t)]=t,this.fire(`layeradd`,{layer:t}));return this.refreshClusters()}removeLayer(e){return e=typeof e==`number`?this._layers[e]:e,!e||!this.hasLayer(e)?this:(this._unspiderfy(),e.removeEventParent(this).off(`dragend`,this._onDragEnd,this),delete this._layers[this.getLayerId(e)],this._shown?.delete(e)&&this._map.removeLayer(e),this.fire(`layerremove`,{layer:e}),this.refreshClusters())}clearLayers(){this._unspiderfy();for(let e of this.getLayers())e.removeEventParent(this).off(`dragend`,this._onDragEnd,this),this.fire(`layerremove`,{layer:e});return this._layers={},this.refreshClusters()}refreshClusters(){return this._clusters=null,this._map&&this._update(),this}onAdd(){this._clusters=null,this._update()}onRemove(e){this._unspiderfy();for(let t of this._shown)e.removeLayer(t);this._shown.clear()}getEvents(){return{moveend:this._update,zoomstart:this._unspiderfy,click:this._unspiderfy}}_onDragEnd({target:e}){e._clusterLatLng&&=e.getLatLng(),this.refreshClusters()}_update(){let e=this._map,t=e.getZoom();this._clusters&&this._clustersZoom===t||(this._unspiderfy(),this._clusters=this._cluster(),this._clustersZoom=t);let n=e.getPixelBounds().pad(.5),r=/* @__PURE__ */ new Set;for(let e of this._clusters){let{markers:t,point:i}=e;t.length>1?n.contains(i)&&(e.marker??=this._createClusterMarker(e),r.add(e.marker)):(!t[0].getLatLng||n.contains(i))&&r.add(t[0])}let i=this._spider?.clusterMarker;for(let t of this._shown)r.has(t)||e.removeLayer(t);for(let t of r)t!==i&&e.addLayer(t);this._shown=r}_cluster(){let e=this._map,t=e.getZoom(),n=this.options.maxClusterRadius,r=t>=(this.options.disableClusteringAtZoom??1/0),i=/* @__PURE__ */ new Map,a=[];for(let o of Object.values(this._layers)){if(!o.getLatLng){a.push({markers:[o]});continue}let s=e.project(o.getLatLng(),t),c=Math.floor(s.x/n),l=Math.floor(s.y/n),u,d=n;for(let e=c-1;e<=c+1;e++)for(let t=l-1;t<=l+1;t++)for(let n of r?[]:i.get(`${e}:${t}`)??[]){let e=n.point.distanceTo(s);e<=d&&(u=n,d=e)}if(u)u.markers.push(o);else{let e={point:s,markers:[o]},t=`${c}:${l}`;i.has(t)||i.set(t,[]),i.get(t).push(e),a.push(e)}}for(let n of a)if(n.markers.length>1){let r=n.markers.map(e=>e.getLatLng());n.latlng=new V(r.reduce((e,t)=>e+t.lat,0)/r.length,r.reduce((e,t)=>e+t.lng,0)/r.length),n.point=e.project(n.latlng,t)}return a}_createClusterMarker({latlng:e,markers:t}){let n={latlng:e,bounds:new z(t.map(e=>e.getLatLng())),markers:t,count:t.length},r=new $(e,{icon:this.options.iconCreateFunction?.(n)??this._createIcon(n),title:P.translate(`{count} markers`,{count:n.count})});return r.on(`click`,e=>this._onClusterClick(n,r,e)),r}_createIcon({count:e}){let t=e<10?`small`:e<100?`medium`:`large`;return new zn({html:`<span>${e}</span>`,className:`maplair-cluster maplair-cluster-${t}`,iconSize:{small:32,medium:38,large:44}[t]})}_onClusterClick(e,t,n){this.fire(`clusterclick`,{cluster:e,layer:t,originalEvent:n.originalEvent});let r=this._map,i=r.getMaxZoom(),{bounds:a}=e;r.getZoom()<i&&(this.options.disableClusteringAtZoom<=i||r.project(a.getNorthEast(),i).distanceTo(r.project(a.getSouthWest(),i))>this.options.maxClusterRadius)?this.options.zoomToBoundsOnClick&&r.fitBounds(a):this.options.spiderfyOnMaxZoom&&this._spiderfy(e,t)}_spiderfy({markers:e},t){this._unspiderfy();let n=this._map,r=n.latLngToLayerPoint(t.getLatLng()),i=Math.max(30,e.length*30/(2*Math.PI)),a=this._spider={markers:e,clusterMarker:t,legs:[]};n.removeLayer(t),e.forEach((o,s)=>{let c=2*Math.PI*s/e.length,l=n.layerPointToLatLng(r.add(new g(Math.cos(c),Math.sin(c)).multiplyBy(i)));o._clusterLatLng=o.getLatLng(),o.setLatLng(l);let u=new Yt([t.getLatLng(),l],{className:`maplair-cluster-leg`,interactive:!1,weight:1.5});a.legs.push(u),n.addLayer(u),n.addLayer(o)})}_unspiderfy(){let e=this._spider;if(!e)return;this._spider=null;let t=this._map;for(let n of e.legs)t?.removeLayer(n);for(let n of e.markers)t?.removeLayer(n),n.setLatLng(n._clusterLatLng),delete n._clusterLatLng;t&&this._shown.has(e.clusterMarker)&&t.addLayer(e.clusterMarker)}},Un=class e extends F{static defaultOptions={tileSize:256,opacity:1,placeholder:null,updateWhenIdle:!1,updateWhenZooming:!0,updateInterval:200,zIndex:1,bounds:null,minZoom:0,maxZoom:void 0,maxNativeZoom:void 0,minNativeZoom:void 0,noWrap:!1,pane:`tilePane`,className:``,pixelated:!1,keepBuffer:2};constructor(t){super(),f(this,t),this.callInitHooks(e)}onAdd(){this._initContainer(),this._levels={},this._tiles={},this._resetView()}beforeAdd(e){e._addZoomLimit(this)}onRemove(e){this._removeKeptLevel(),this._removeAllTiles(),this._container.remove(),e._removeZoomLimit(this),this._container=null,this._tileZoom=void 0,clearTimeout(this._pruneTimeout),cancelAnimationFrame(this._fadePruneFrame),this._fadePruneFrame=0}bringToFront(){return this._map&&(O(this._container),this._setAutoZIndex(Math.max)),this}bringToBack(){return this._map&&(Se(this._container),this._setAutoZIndex(Math.min)),this}getContainer(){return this._container}setOpacity(e){return this.options.opacity=e,this._updateOpacity(),this}setZIndex(e){return this.options.zIndex=e,this._updateZIndex(),this}isLoading(){return!!this._loading}redraw(){if(this._map){this._removeAllTiles();let e=this._clampZoom(Math.round(this._map.getZoom()));e!==this._tileZoom&&(this._tileZoom=e,this._updateLevels()),this._update()}return this}getEvents(){let e={viewprereset:this._invalidateAll,viewreset:this._resetView,zoom:this._resetView,moveend:this._onMoveEnd,worldcopyjump:this._onWorldCopyJump,zoomanim:this._animateZoom};return this.options.updateWhenIdle||(this._onMove||=o(this._onMoveEnd,this.options.updateInterval,this),e.move=this._onMove),e}createTile(){return document.createElement(`div`)}getTileSize(){let e=this.options.tileSize;return e instanceof g?e:new g(e,e)}_updateZIndex(){this._container&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._container.style.zIndex=`${this.options.zIndex}`)}_setAutoZIndex(e){let t=this.getPane().children,n=-e(-1/0,1/0);for(let r of t){let t=r.style.zIndex;r!==this._container&&t&&(n=e(n,+t))}isFinite(n)&&(this.options.zIndex=n+e(-1,1),this._updateZIndex())}_updateOpacity(){this._map&&(this._container.style.opacity=`${this.options.opacity}`)}_onOpaqueTile(){}_initContainer(){this._container||(this._container=D(`div`,`maplair-layer ${this.options.className??``}`),this._container.classList.toggle(`maplair-pixelated`,!!this.options.pixelated),this._updateZIndex(),this.options.opacity<1&&this._updateOpacity(),this.getPane().appendChild(this._container))}_keepCurrentTiles(){let e=this._tileZoom,t=this._levels?.[e];if(!this._map||!t||this._keptLevel)return;let n=[];for(let[t,r]of Object.entries(this._tiles))r.coords.z===e&&r.loaded&&(n.push(r),delete this._tiles[t]);delete this._levels[e],t.el.style.zIndex=-1,this._keptLevel={level:t,tiles:n},this._updateLevels(),this.on(`load`,this._onLoadKeptLevel,this),this._map.on(`zoomstart viewprereset`,this._removeKeptLevel,this)}_onLoadKeptLevel(){this._map._fadeAnimated?(clearTimeout(this._keptLevelTimeout),this._keptLevelTimeout=setTimeout(this._removeKeptLevel.bind(this),250)):this._removeKeptLevel()}_removeKeptLevel(){if(!this._keptLevel)return;let{level:e,tiles:t}=this._keptLevel;this._keptLevel=null,clearTimeout(this._keptLevelTimeout),this.off(`load`,this._onLoadKeptLevel,this),this._map.off(`zoomstart viewprereset`,this._removeKeptLevel,this),e.el.remove();for(let e of t)this.fire(`tileunload`,{tile:e.el,coords:e.coords})}_updateLevels(){let e=this._tileZoom,t=this.options.maxZoom;if(e===void 0)return;for(let n of Object.keys(this._levels))n=Number(n),this._levels[n].el.children.length||n===e?(this._levels[n].el.style.zIndex=`${t-Math.abs(e-n)}`,this._onUpdateLevel(n)):(this._levels[n].el.remove(),this._removeTilesAtZoom(n),this._onRemoveLevel(n),delete this._levels[n]);let n=this._levels[e],r=this._map;return n||(n=this._levels[e]={},n.el=D(`div`,`maplair-tile-container maplair-zoom-animated`,this._container),n.el.style.zIndex=`${t}`,n.origin=r.project(r.unproject(r.getPixelOrigin()),e).round(),n.zoom=e,this._setZoomTransform(n,r.getCenter(),r.getZoom()),n.el.offsetWidth,this._onCreateLevel(n)),this._level=n,n}_onUpdateLevel(){}_onRemoveLevel(){}_onCreateLevel(){}_pruneTiles(){if(!this._map)return;let e=this._map.getZoom();if(e>this.options.maxZoom||e<this.options.minZoom)this._removeAllTiles();else{for(let e of Object.values(this._tiles))e.retain=e.current;for(let e of Object.values(this._tiles))if(e.current&&!e.active){let t=e.coords;this._retainParent(t.x,t.y,t.z,t.z-5)||this._retainChildren(t.x,t.y,t.z,t.z+2)}for(let[e,t]of Object.entries(this._tiles))t.retain||this._removeTile(e)}}_removeTilesAtZoom(e){for(let[t,n]of Object.entries(this._tiles))n.coords.z===e&&this._removeTile(t)}_removeAllTiles(){for(let e of Object.keys(this._tiles))this._removeTile(e)}_invalidateAll(e){let t=this._map;if(!(e?.zoom!==void 0&&e.zoom!==t.getZoom()&&t.getBounds().contains(e.center))){for(let e of Object.keys(this._levels))this._levels[e].el.remove(),this._onRemoveLevel(Number(e)),delete this._levels[e];this._removeAllTiles(),this._tileZoom=void 0}}_retainParent(e,t,n,r){for(n--;n>=r;n--)if(e=Math.floor(e/2),t=Math.floor(t/2),this._retain(e,t,n))return!0;return!1}_retainChildren(e,t,n,r){for(let i=2*e;i<2*e+2;i++)for(let e=2*t;e<2*t+2;e++)!this._retain(i,e,n+1)&&n+1<r&&this._retainChildren(i,e,n+1,r)}_retain(e,t,n){let r=this._tiles[this._tileCoordsToKey({x:e,y:t,z:n})];return r?.loaded&&(r.retain=!0),r?.active}_resetView(e){let t=e&&(e.pinch||e.flyTo||e.continuous);this._setView(this._map.getCenter(),this._map.getZoom(),t,t)}_animateZoom(e){this._setView(e.center,e.zoom,!0,e.noUpdate)}_clampZoom(e){let t=this.options;return t.minNativeZoom!==void 0&&e<t.minNativeZoom?t.minNativeZoom:t.maxNativeZoom!==void 0&&t.maxNativeZoom<e?t.maxNativeZoom:e}_setView(e,t,n,r){let i=Math.round(t);i=this.options.maxZoom!==void 0&&i>this.options.maxZoom||this.options.minZoom!==void 0&&i<this.options.minZoom?void 0:this._clampZoom(i);let a=this.options.updateWhenZooming&&i!==this._tileZoom;(!r||a)&&(this._tileZoom=i,this._abortLoading&&this._abortLoading(),this._updateLevels(),this._resetGrid(),i!==void 0&&this._update(e),n||this._pruneTiles(),this._noPrune=!!n),this._setZoomTransforms(e,t)}_setZoomTransforms(e,t){for(let n of Object.values(this._levels))this._setZoomTransform(n,e,t)}_setZoomTransform(e,t,n){let r=this._map.getZoomScale(n,e.zoom),i=e.origin.multiplyBy(r).subtract(this._map._getNewPixelOrigin(t,n)).round();k(e.el,i,r)}_resetGrid(){let e=this._map,t=e.options.crs,n=this._tileSize=this.getTileSize(),r=this._tileZoom,i=this._map.getPixelWorldBounds(this._tileZoom);i&&(this._globalTileRange=this._pxBoundsToTileRange(i)),this._wrapX=t.wrapLng&&!this.options.noWrap&&[Math.floor(e.project([0,t.wrapLng[0]],r).x/n.x),Math.ceil(e.project([0,t.wrapLng[1]],r).x/n.x)],this._wrapY=t.wrapLat&&!this.options.noWrap&&[Math.floor(e.project([t.wrapLat[0],0],r).y/n.y),Math.ceil(e.project([t.wrapLat[1],0],r).y/n.y)]}_onMoveEnd(){this._map&&!this._map._animatingZoom&&this._update()}_onWorldCopyJump({worlds:e}){if(!this._wrapX)return;let t=this.getTileSize(),n={};for(let r of Object.values(this._tiles)){let{coords:i,el:a}=r,o=e*this._map.getPixelWorldBounds(i.z).getSize().x;o%t.x===0&&(i.x-=o/t.x,A(a,j(a).subtract([o,0]),!0)),n[this._tileCoordsToKey(i)]=r}this._tiles=n}_getTiledPixelBounds(e){let t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t.getSize().divideBy(r*2);return new I(i.subtract(a),i.add(a))}_update(e){let t=this._map;if(!t)return;let n=this._clampZoom(t.getZoom());if(e===void 0&&(e=t.getCenter()),this._tileZoom===void 0)return;let r=this._getTiledPixelBounds(e),i=this._pxBoundsToTileRange(r),a=i.getCenter(),o=[],s=this.options.keepBuffer,c=new I(i.getBottomLeft().subtract([s,-s]),i.getTopRight().add([s,-s]));if(!(isFinite(i.min.x)&&isFinite(i.min.y)&&isFinite(i.max.x)&&isFinite(i.max.y)))throw Error(`Attempted to load an infinite number of tiles`);for(let e of Object.values(this._tiles)){let t=e.coords;t.z===this._tileZoom&&c.contains(new g(t.x,t.y))||(e.current=!1)}if(Math.abs(n-this._tileZoom)>1)this._setView(e,n);else{for(let e=i.min.y;e<=i.max.y;e++)for(let t=i.min.x;t<=i.max.x;t++){let n=new g(t,e);if(n.z=this._tileZoom,!this._isValidTile(n))continue;let r=this._tiles[this._tileCoordsToKey(n)];r?r.current=!0:o.push(n)}if(o.sort((e,t)=>e.distanceTo(a)-t.distanceTo(a)),o.length!==0){this._loading||(this._loading=!0,this.fire(`loading`),this._map._onLayerLoading());let e=document.createDocumentFragment();for(let t of o)this._addTile(t,e);this._level.el.appendChild(e)}}}_isValidTile(e){let t=this._map.options.crs;if(!t.infinite){let n=this._globalTileRange;if(!t.wrapLng&&(e.x<n.min.x||e.x>n.max.x)||!t.wrapLat&&(e.y<n.min.y||e.y>n.max.y))return!1}if(!this.options.bounds)return!0;let n=this._tileCoordsToBounds(e);return z.from(this.options.bounds).overlaps(n)}_tileCoordsToNwSe(e){let t=this._map,n=this.getTileSize(),r=e.scaleBy(n),i=r.add(n);return[t.unproject(r,e.z),t.unproject(i,e.z)]}_tileCoordsToBounds(e){let t=this._tileCoordsToNwSe(e),n=new z(t[0],t[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n}_tileCoordsToKey(e){return`${e.x}:${e.y}:${e.z}`}_removeTile(e){let t=this._tiles[e];t&&(t.el.remove(),delete this._tiles[e],this.fire(`tileunload`,{tile:t.el,coords:t.coords}))}_initTile(e){e.classList.add(`maplair-tile`);let t=this.getTileSize();e.style.width=`${t.x}px`,e.style.height=`${t.y}px`,this.options.placeholder&&(e.style.background=this.options.placeholder)}_addTile(e,t){let n=this._getTilePos(e),r=this._tileCoordsToKey(e),i=this.createTile(this._wrapCoords(e),this._tileReady.bind(this,e));this._initTile(i),this.createTile.length<2&&requestAnimationFrame(this._tileReady.bind(this,e,null,i)),A(i,n,!0),this._tiles[r]={el:i,coords:e,current:!0},t.appendChild(i),this.fire(`tileloadstart`,{tile:i,coords:e})}_tileReady(e,t,n){t&&this.fire(`tileerror`,{error:t,tile:n,coords:e});let r=this._tileCoordsToKey(e);if(n=this._tiles[r],n&&(this.options.placeholder&&(n.el.style.background=``),!this._map._fadeAnimated||this.options.placeholder?(n.active=!0,this._pruneTiles()):n.loaded||(n.el.classList.add(`maplair-tile-fading`),n.el.animate({opacity:[0,1]},200).onfinish=this._onTileFaded.bind(this,n)),n.loaded=!0,t||(n.el.classList.add(`maplair-tile-loaded`),this.fire(`tileload`,{tile:n.el,coords:e})),this._map&&this._noTilesToLoad())){if(this._loading=!1,this.fire(`load`),!this._map)return;this._map._scheduleIdleCheck(),this._map._fadeAnimated?this._pruneTimeout=setTimeout(this._pruneTiles.bind(this),250):requestAnimationFrame(this._pruneTiles.bind(this))}}_onTileFaded(e){e.el.classList.remove(`maplair-tile-fading`),this._tiles[this._tileCoordsToKey(e.coords)]===e&&(e.active=!0,this._onOpaqueTile(e),!(this._noPrune||this._fadePruneFrame)&&(this._fadePruneFrame=requestAnimationFrame(()=>{this._fadePruneFrame=0,this._noPrune||this._pruneTiles()})))}_getTilePos(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)}_wrapCoords(e){let t=new g(this._wrapX?s(e.x,this._wrapX):e.x,this._wrapY?s(e.y,this._wrapY):e.y);return t.z=e.z,t}_pxBoundsToTileRange(e){let t=this.getTileSize();return new I(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))}_noTilesToLoad(){return Object.values(this._tiles).every(e=>e.loaded)}};const Wn=[`tile.openstreetmap.org`,`tile.osm.org`],Gn=/^(https?:)?\/\/([^/?#:]*)/i,Kn=/^http:/i;function qn(e){let t=Gn.exec(e)?.[2]??``;return Wn.some(e=>t===e||t.endsWith(`.${e}`))}const Jn=e=>qn(e)?e.replace(Kn,`https:`):e;var Yn=class e extends Un{static defaultOptions={minZoom:0,maxZoom:18,subdomains:`abc`,errorTileUrl:``,zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:`strict-origin-when-cross-origin`,fetchOptions:null};constructor(t,n){super(n),n=f(this,n),qn(t)&&n.attribution===null&&(n.attribution=`© <a href="https://www.openstreetmap.org/copyright">${P.translate(`OpenStreetMap contributors`)}</a>`),this._url=Jn(t);let{tileSize:r,zoomOffset:i,minZoom:a,maxZoom:o,minNativeZoom:s,maxNativeZoom:c}=this.options;this._nonRetinaOptions={tileSize:r,zoomOffset:i,minZoom:a,maxZoom:o,minNativeZoom:s,maxNativeZoom:c},this._applyRetina(),typeof this.options.subdomains==`string`&&(this.options.subdomains=this.options.subdomains.split(``)),this.callInitHooks(e)}_applyRetina(){if(Object.assign(this.options,this._nonRetinaOptions),this._retina=window.devicePixelRatio>1,this.options.detectRetina&&this._retina&&this.options.maxZoom>0){let e=this.options.tileSize;this.options.tileSize=e instanceof g?e.divideBy(2).floor():Math.floor(e/2),this.options.zoomReverse?(this.options.zoomOffset--,this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom+1)):(this.options.zoomOffset++,this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom-1),this.options.maxNativeZoom!==void 0&&(this.options.maxNativeZoom=Math.max(0,this.options.maxNativeZoom-1)),this.options.minNativeZoom!==void 0&&(this.options.minNativeZoom=Math.max(0,this.options.minNativeZoom-1))),this.options.minZoom=Math.max(0,this.options.minZoom)}else this.options.zoomReverse?this.options.minZoom=Math.min(this.options.maxZoom,this.options.minZoom):this.options.maxZoom=Math.max(this.options.minZoom,this.options.maxZoom)}getEvents(){let e=super.getEvents();return e.pixelratiochange=this._onPixelRatioChange,e}_onPixelRatioChange(){if(window.devicePixelRatio>1===this._retina)return;let e=this._map;this._applyRetina(),this.options.detectRetina?(e._removeZoomLimit(this),e._addZoomLimit(this),this._invalidateAll(),this._resetView()):this._url.includes(`{r}`)&&this.redraw()}setUrl(e,t){return e=Jn(e),this._url===e&&t===void 0&&(t=!0),this._url=e,t||(this._keepCurrentTiles(),this.redraw()),this}createTile(e,t){let n=document.createElement(`img`);y(n,`load`,this._tileOnLoad.bind(this,t,n)),y(n,`error`,this._tileOnError.bind(this,t,n)),(this.options.crossOrigin||this.options.crossOrigin===``)&&(n.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),typeof this.options.referrerPolicy==`string`&&(n.referrerPolicy=this.options.referrerPolicy),n.alt=``;let r=this.getTileUrl(e);return this.options.fetchOptions?this._fetchTile(n,r,t):n.src=r,n}_fetchTile(e,t,n){let r=new AbortController,i={signal:r.signal,...this.options.fetchOptions};typeof this.options.referrerPolicy==`string`&&(i.referrerPolicy??=this.options.referrerPolicy),this._tileFetches??=/* @__PURE__ */ new Map,this._tileFetches.set(e,r),fetch(t,i).then(e=>{if(!e.ok)throw Error(`Failed to load the tile ${t}: HTTP ${e.status}`);return e.blob()}).then(t=>{e.src=URL.createObjectURL(t)}).catch(t=>{r.signal.aborted||this._tileOnError(n,e,t)}).finally(()=>this._tileFetches.delete(e))}_abortTileFetch(e){let t=this._tileFetches?.get(e);return t?(t.abort(),this._tileFetches.delete(e),!0):!1}getTileUrl(e){let t=Object.create(this.options);if(Object.assign(t,{r:window.devicePixelRatio>1?`@2x`:``,s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()}),this._map&&!this._map.options.crs.infinite){let n=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=n),t[`-y`]=n}return m(this._url,t)}_tileOnLoad(e,t){t.src.startsWith(`blob:`)&&URL.revokeObjectURL(t.src),e(null,t)}_tileOnError(e,t,n){let r=this.options.errorTileUrl,i=t.getAttribute(`src`);r&&i!==r&&(i||t.isConnected)&&(t.src=r),e(n,t)}_getZoomForUrl(){let e=this._tileZoom,t=this.options.maxZoom,n=this.options.zoomReverse,r=this.options.zoomOffset;return n&&(e=t-e),e+r}_getSubdomain(e){let{subdomains:t}=this.options;return t?.[Math.abs(e.x+e.y)%t.length]}_abortLoading(){let e,t;for(e of Object.keys(this._tiles))if(this._tiles[e].coords.z!==this._tileZoom&&(t=this._tiles[e].el,this._abortTileFetch(t)||!t.complete)){t.setAttribute(`src`,``);let n=this._tiles[e].coords;t.remove(),delete this._tiles[e],this.fire(`tileabort`,{tile:t,coords:n})}}_removeTile(e){let t=this._tiles[e];if(t)return this._abortTileFetch(t.el),t.el.setAttribute(`src`,``),super._removeTile(e)}_tileReady(e,t,n){if(!(!this._map||n&&n.getAttribute(`src`)===``))return super._tileReady(e,t,n)}_clampZoom(e){return Math.round(super._clampZoom(e))}},Xn=class e extends Yn{static defaultWmsParams={service:`WMS`,request:`GetMap`,layers:``,styles:``,format:`image/jpeg`,transparent:!1,version:`1.1.1`};static defaultOptions={crs:null,uppercase:!1};constructor(t,n){super(t,n);let r={...e.defaultWmsParams};for(let[t,i]of Object.entries(n))t in e.defaultOptions||(r[t]=i);this.wmsParams=r,this._updateWmsSize(),this.callInitHooks(e)}_updateWmsSize(){let e=this.options.detectRetina&&window.devicePixelRatio>1?2:1,t=this.getTileSize();this.wmsParams.width=t.x*e,this.wmsParams.height=t.y*e}_applyRetina(){super._applyRetina(),this.wmsParams&&this._updateWmsSize()}onAdd(e){this._updateCrs(),super.onAdd(e)}_updateCrs(){this._crs=this.options.crs??this._map.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version),delete this.wmsParams.srs,delete this.wmsParams.crs,this.wmsParams[this._wmsVersion>=1.3?`crs`:`srs`]=this._crs.code}getEvents(){let e=super.getEvents();return e.crschange=this._updateCrs,e}getTileUrl(e){let t=this._tileCoordsToNwSe(e),n=this._crs,r=new I(n.project(t[0]),n.project(t[1])),i=r.min,a=r.max,o=(this._wmsVersion>=1.3&&this._crs===An?[i.y,i.x,a.y,a.x]:[i.x,i.y,a.x,a.y]).join(`,`),s=new URL(super.getTileUrl(e),document.baseURI);for(let[e,t]of Object.entries({...this.wmsParams,bbox:o}))s.searchParams.append(this.options.uppercase?e.toUpperCase():e,`${t}`);return s.toString()}getLegendUrl(e){let{version:t,format:n,layers:r,styles:i}=this.wmsParams,a=new URL(this._url,document.baseURI);for(let[o,s]of Object.entries({service:`WMS`,request:`GetLegendGraphic`,version:t,format:n,layer:r.split(`,`)[0],style:i?.split(`,`)[0]||void 0,sld_version:parseFloat(t)>=1.3?`1.1.0`:void 0,...e}))s!==void 0&&a.searchParams.set(this.options.uppercase?o.toUpperCase():o,s);return a.toString()}setParams(e,t){return Object.assign(this.wmsParams,e),this._map&&this._updateCrs(),t||(this._keepCurrentTiles(),this.redraw()),this}};const Zn=/[, ]+/;var Qn=class e extends Ve{static defaultOptions={tolerance:0};constructor(...t){super(...t),this.callInitHooks(e)}getEvents(){let e=super.getEvents();return e.viewprereset=this._onViewPreReset,e.pixelratiochange=this._onPixelRatioChange,e}_onPixelRatioChange(){this._resizeContainer(),this._update()}_onViewPreReset(){this._postponeUpdatePaths=!0}onAdd(e){super.onAdd(e),this._draw()}onRemove(){super.onRemove(),clearTimeout(this._pointerHoverThrottleTimeout)}_initContainer(){let e=this._container=document.createElement(`canvas`);y(e,`pointermove`,this._onPointerMove,this),y(e,`click dblclick pointerdown pointerup contextmenu`,this._onClick,this),y(e,`pointerout`,this._handlePointerOut,this),e._maplair_disable_events=!0,this._ctx=e.getContext(`2d`)}_destroyContainer(){cancelAnimationFrame(this._redrawRequest),this._redrawRequest=null,delete this._ctx,super._destroyContainer()}_resizeContainer(){let e=super._resizeContainer(),t=this._ctxScale=window.devicePixelRatio;this._container.width=t*e.x,this._container.height=t*e.y}_updatePaths(){if(!this._postponeUpdatePaths){this._redrawBounds=null;for(let e of Object.values(this._layers))e._update();this._redraw()}}_update(){if(this._map._animatingZoom&&this._bounds)return;let e=this._bounds,t=this._ctxScale;this._ctx.setTransform(t,0,0,t,-e.min.x*t,-e.min.y*t),this.fire(`update`)}_reset(){super._reset(),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())}_initPath(e){this._updateDashArray(e),this._layers[a(e)]=e;let t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst??=this._drawLast}_addPath(e){this._requestRedraw(e)}_removePath(e){let t=e._order,n=t.next,r=t.prev;n?n.prev=r:this._drawLast=r,r?r.next=n:this._drawFirst=n,delete e._order,delete this._layers[a(e)],this._requestRedraw(e)}_updatePath(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)}_updateStyle(e){this._updateDashArray(e),this._requestRedraw(e)}_updateDashArray(e){e._dashArray=typeof e.options.dashArray==`string`?e.options.dashArray.split(Zn).map(e=>Number(e)).filter(e=>!isNaN(e)):e.options.dashArray}_requestRedraw(e){this._map&&(this._extendRedrawBounds(e),this._redrawRequest??=requestAnimationFrame(this._redraw.bind(this)))}_extendRedrawBounds(e){if(e._pxBounds){let t=(e.options.weight??0)+1;this._redrawBounds??=new I,this._redrawBounds.extend(e._pxBounds.min.subtract([t,t])),this._redrawBounds.extend(e._pxBounds.max.add([t,t]))}}_redraw(){cancelAnimationFrame(this._redrawRequest),this._redrawRequest=null,this._redrawBounds&&(this._redrawBounds.min._floor(),this._redrawBounds.max._ceil()),this._clear(),this._draw(),this._redrawBounds=null}_clear(){let e=this._redrawBounds;if(e){let t=e.getSize();this._ctx.clearRect(e.min.x,e.min.y,t.x,t.y)}else this._ctx.save(),this._ctx.setTransform(1,0,0,1,0,0),this._ctx.clearRect(0,0,this._container.width,this._container.height),this._ctx.restore()}_draw(){let e,t=this._redrawBounds;if(this._ctx.save(),t){let e=t.getSize();this._ctx.beginPath(),this._ctx.rect(t.min.x,t.min.y,e.x,e.y),this._ctx.clip()}this._drawing=!0;for(let n=this._drawFirst;n;n=n.next)e=n.layer,(!t||e._pxBounds&&e._pxBounds.intersects(t))&&e._updatePath();this._drawing=!1,this._ctx.restore()}_updatePoly(e,t){if(!this._drawing)return;let n=e._parts,r=this._ctx;n.length&&(r.beginPath(),n.forEach(e=>{e.forEach((e,t)=>{r[t?`lineTo`:`moveTo`](e.x,e.y)}),t&&r.closePath()}),this._fillStroke(r,e))}_updateCircle(e){if(!this._drawing||e._empty())return;let{x:t,y:n}=e._point,r=this._ctx,i=Math.max(Math.round(e._pxRadius),1),a=Math.max(Math.round(e._pxRadiusY),1)||i;r.beginPath(),a===i?r.arc(t,n,i,0,Math.PI*2):r.ellipse(t,n,i,a,0,0,Math.PI*2),this._fillStroke(r,e)}_fillStroke(e,t){let n=t.options;n.fill&&(e.globalAlpha=n.fillOpacity,e.fillStyle=n.fillColor??n.color,e.fill(n.fillRule||`evenodd`)),n.stroke&&n.weight!==0&&(e.lineDashOffset=Number(n.dashOffset??0),e.setLineDash(t._dashArray??[]),e.globalAlpha=n.opacity,e.lineWidth=n.weight,e.strokeStyle=n.color,e.lineCap=n.lineCap,e.lineJoin=n.lineJoin,e.stroke())}_updateInteractive(){}_onClick(e){let t=this._map.pointerEventToLayerPoint(e),n,r;for(let i=this._drawFirst;i;i=i.next)n=i.layer,n.options.interactive&&n._containsPoint(t)&&(e.type!==`click`&&e.type!==`preclick`||!this._map._draggableMoved(n))&&(r=n);this._fireEvent(r?[r]:!1,e)}_onPointerMove(e){if(!this._map||this._map.dragging.moving()||this._map._animatingZoom)return;let t=this._map.pointerEventToLayerPoint(e);this._handlePointerHover(e,t)}_handlePointerOut(e){let t=this._hoveredLayer;t&&(this._container.classList.remove(`maplair-interactive`),this._fireEvent([t],e,`pointerout`),this._hoveredLayer=null,this._pointerHoverThrottled=!1)}_handlePointerHover(e,t){if(this._pointerHoverThrottled)return;let n,r;for(let e=this._drawFirst;e;e=e.next)n=e.layer,n.options.interactive&&n._containsPoint(t)&&(r=n);r!==this._hoveredLayer&&(this._handlePointerOut(e),r&&(this._container.classList.add(`maplair-interactive`),this._fireEvent([r],e,`pointerover`),this._hoveredLayer=r)),this._fireEvent(this._hoveredLayer?[this._hoveredLayer]:!1,e),this._pointerHoverThrottled=!0,this._pointerHoverThrottleTimeout=setTimeout((()=>{this._pointerHoverThrottled=!1}),32)}_fireEvent(e,t,n){this._map._fireDOMEvent(t,n||t.type,e)}_bringToFront(e){let t=e._order;if(!t)return;let n=t.next,r=t.prev;if(n)n.prev=r;else return;r?r.next=n:n&&(this._drawFirst=n),t.prev=this._drawLast,this._drawLast.next=t,t.next=null,this._drawLast=t,this._requestRedraw(e)}_bringToBack(e){let t=e._order;if(!t)return;let n=t.next,r=t.prev;if(r)r.next=n;else return;n?n.prev=r:r&&(this._drawLast=r),t.prev=null,t.next=this._drawFirst,this._drawFirst.prev=t,this._drawFirst=t,this._requestRedraw(e)}},$n=class e extends G{constructor(t,n){if(typeof n==`number`)throw Error(`Circle: the radius is an option in Maplair. Use new Circle(latlng, {radius}).`);if(super(t,n),isNaN(this.options.radius))throw Error(`Circle radius cannot be NaN`);this.callInitHooks(e)}getBounds(){if(!this._map)return this._latlng.toBounds(this._radius*2);let e=[this._pxRadius,this._pxRadiusY??this._pxRadius];return new z(this._map.layerPointToLatLng(this._point.subtract(e)),this._map.layerPointToLatLng(this._point.add(e)))}_project(){let e=this._latlng.lng,t=this._latlng.lat,n=this._map,r=n.options.crs;if(r.distance===K.distance){let r=Math.PI/180,i=this._radius/K.R/r,a=n.project([t+i,e]),o=n.project([t-i,e]),s=a.add(o).divideBy(2),c=n.unproject(s).lat,l=2*Math.asin(Math.sqrt((Math.sin(i*r/2)**2-Math.sin((c-t)*r/2)**2)/(Math.cos(t*r)*Math.cos(c*r))))/r;(isNaN(l)||l===0)&&(l=i/Math.cos(Math.PI/180*t)),this._point=s.subtract(n.getPixelOrigin()),this._pxRadius=isNaN(l)?0:s.x-n.project([c,e-l]).x,this._pxRadiusY=s.y-a.y}else{let e=r.unproject(r.project(this._latlng).subtract([this._radius,0]));this._point=n.latLngToLayerPoint(this._latlng),this._pxRadius=Math.abs(this._point.x-n.latLngToLayerPoint(e).x)}this._updateBounds()}},er=class e extends tn{constructor(t,n){super(e._boundsToLatLngs(t),n),this.callInitHooks(e)}setBounds(t){return this.setLatLngs(e._boundsToLatLngs(t))}static _boundsToLatLngs(e){return e=new z(e),[e.getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}};const tr=/^#/,nr=/^\?/,rr=[`zoom`,`lat`,`lng`,`bearing`,`layers`];function ir(e){let t=(e??``).split(`&`).find(e=>e.startsWith(`layers=`))?.slice(7);return t===void 0?void 0:t.split(`,`).filter(Boolean).map(decodeURIComponent)}function ar(e,t){let n=e.getCenter(),r=Math.max(0,Math.ceil(Math.log10(256*2**e.getZoom()/360))),i=t&&Object.keys(t).filter(n=>e.hasLayer(t[n]));return{zoom:Math.round(e.getZoom()*100)/100,lat:n.lat.toFixed(r),lng:n.lng.toFixed(r),bearing:Math.round((e.getBearing?.()??0)*10)/10,layers:i?`layers=${i.map(encodeURIComponent).join(`,`)}`:``}}var or=class e{constructor(e,t){this.options={format:`zoom/lat/lng`,layers:void 0,mode:`hash`,...t},this._map=e,this._onHashChange=this._onHashChange.bind(this),this._event=this.options.mode===`query`?`popstate`:`hashchange`,window.addEventListener(this._event,this._onHashChange),e.on(`moveend layeradd layerremove`,this._onMoveEnd,this),!this._onHashChange()&&e._loaded&&this._onMoveEnd()}remove(){return window.removeEventListener(this._event,this._onHashChange),this._map.off(`moveend layeradd layerremove`,this._onMoveEnd,this),this}_onHashChange(){let t=this.options.mode===`query`?e.parseQuery(location.search):e.parse(location.hash);if(!t)return!1;if(t.hash===this._hash)return!0;this._hash=t.hash,this._restoring=!0;let n=this._map;if(n.setView(t.center,t.zoom??n.getZoom(),{animate:!1}),n.setBearing&&(t.bearing!==void 0||n.getBearing())&&n.setBearing(t.bearing??0),t.layers&&this.options.layers)for(let[e,r]of Object.entries(this.options.layers))t.layers.includes(e)?n.addLayer(r):n.hasLayer(r)&&n.removeLayer(r);return this._restoring=!1,this._onMoveEnd(),!0}_onMoveEnd(){if(this._restoring||!this._map._loaded)return;let t=this.options.mode===`query`,n=t?e.formatQuery(this._map,this.options.layers,location.search):e.format(this._map,this.options.format,this.options.layers);n!==this._hash&&n!==(t?location.search:location.hash)&&(this._hash=n,history.replaceState(history.state,``,t?n+location.hash:n))}static parse(e){let[t,n]=e.replace(tr,``).split(`?`),r=new URLSearchParams(n),i=ir(n),a,o,s,c;if(t.startsWith(`geo:`)){let e=V.parse(t);if(!e)return;({lat:o,lng:s}=e),a=r.has(`z`)?Number(r.get(`z`)):void 0,c=r.has(`bearing`)?Number(r.get(`bearing`)):void 0}else{let e=t.split(`/`);if(e.length!==3&&e.length!==4||e.includes(``))return;[a,o,s,c]=e.map(Number)}if(![a,o,s,c].some(Number.isNaN))return{zoom:a,center:new V(o,s),bearing:c,layers:i,hash:`#${e.replace(tr,``)}`}}static format(e,t=`zoom/lat/lng`,n=void 0){let{zoom:r,lat:i,lng:a,bearing:o,layers:s}=ar(e,n);return t===`geo`?`#geo:${i},${a}?z=${r}${o?`&bearing=${o}`:``}${s?`&${s}`:``}`:`#${r}/${i}/${a}${o?`/${o}`:``}${s?`?${s}`:``}`}static parseQuery(e){let t=e.replace(nr,``),n=new URLSearchParams(t);if(!n.has(`lat`)||!n.has(`lng`))return;let[r,i]=[`zoom`,`bearing`].map(e=>n.has(e)?Number(n.get(e)):void 0),a=Number(n.get(`lat`)),o=Number(n.get(`lng`));if(![r,a,o,i].some(Number.isNaN))return{zoom:r,center:new V(a,o),bearing:i,layers:ir(t),hash:e}}static formatQuery(e,t=void 0,n=``){let r=ar(e,t),i=new URLSearchParams(n);for(let e of rr)i.delete(e);return`?${[i.toString(),`zoom=${r.zoom}&lat=${r.lat}&lng=${r.lng}`,r.bearing?`bearing=${r.bearing}`:``,r.layers].filter(Boolean).join(`&`)}`}},sr=class{constructor(e,t){this.options={bearing:!0,oneWay:!1,fit:`center`,...t},this._maps=[...e],this._listeners=/* @__PURE__ */ new Map,this._animating=/* @__PURE__ */ new Set,this._ended=/* @__PURE__ */ new Set;for(let e of this._maps){let t={movestart:()=>this._onMoveStart(e),zoomstart:()=>this._onZoomStart(e),move:()=>this._onMove(e),zoomanim:t=>this._onZoomAnim(e,t),moveend:()=>this._onMoveEnd(e),rotate:()=>this._onRotate(e)};e.on(t),this._listeners.set(e,t)}this._maps[0]?._loaded&&this._syncAll(this._maps[0])}remove(){for(let[e,t]of this._listeners)e.off(t);return this._listeners.clear(),this._maps=[],this}_followers(e){return this._maps.filter(t=>t!==e&&t._loaded)}_canLead(e){return!this.options.oneWay||e===this._maps[0]}_zoomFor(e,t,n=t.getZoom(),r=!0){let i=e.getSize(),a=t.getSize();if(this.options.fit!==`bounds`||!i.x||!i.y||!a.x||!a.y)return n;let o=n+Math.log2(Math.min(i.x/a.x,i.y/a.y)),s=e.options.zoomSnap;return r&&s&&(o=Math.floor(o/s+1e-6)*s),Math.max(e.getMinZoom(),Math.min(e.getMaxZoom(),o))}_onMoveStart(e){if(!this._leader&&this._canLead(e)){this._leader=e,this._leaderEnded=!1,this._ended.clear();for(let t of this._followers(e))t._stop(),t._syncStartZoom=t.getZoom(),t.fire(`movestart`)}}_onZoomStart(e){if(this._onMoveStart(e),this._leader===e)for(let t of this._followers(e))t.fire(`zoomstart`)}_onMove(e){if(!this._leader)this._canLead(e)&&this._syncAll(e);else if(this._leader===e)for(let t of this._followers(e))this._animating.has(t)||this._follow(t,e,!0)}_onZoomAnim(e,t){if(this._leader===e)for(let n of this._followers(e))n._zoomAnimated&&(this._animating.add(n),n._animateZoom(t.center,this._zoomFor(n,e,t.zoom),!0,t.noUpdate))}_onMoveEnd(e){if(this._leader!==e)this._animating.delete(e)&&(this._ended.add(e),this._leaderEnded&&!this._animating.size&&(this._leader=null));else{for(let t of this._followers(e))!this._animating.has(t)&&!this._ended.has(t)&&(this._follow(t,e,!1),t._moveEnd(t.getZoom()!==t._syncStartZoom));this._leaderEnded=!0,this._animating.size||(this._leader=null)}}_onRotate(e){if(this.options.bearing&&this._canLead(e))for(let t of this._followers(e))t._rotate&&t.getBearing()!==e.getBearing()&&t._rotate(e.getBearing())}_follow(e,t,n){let r=t.getCenter(),i=this._zoomFor(e,t,t.getZoom(),!n);if(i===e.getZoom()){let t=e.project(r,i).subtract(e.project(e.getCenter(),i)).round();(t.x||t.y)&&(e._rawPanBy(t),e.fire(`move`))}else e._move(r,i,n?{pinch:!0,round:!1}:void 0)}_syncAll(e){for(let t of this._maps.filter(t=>t!==e)){this.options.bearing&&t._rotate&&t.getBearing()!==e.getBearing()&&t._rotate(e.getBearing());let n=this._zoomFor(t,e);(!t._loaded||t.getZoom()!==n||t.latLngToContainerPoint(e.getCenter()).distanceTo(t.getSize()._divideBy(2))>=1)&&(this._leader=e,t.setView(e.getCenter(),n,{animate:!1}),this._leader=null)}}};function cr(e){return e instanceof G&&!!e.options.displace}var lr=class e extends X{static defaultOptions={gap:2,iterations:80,maxDistance:1/0};constructor(...t){super(...t),f(this,this._map.options.displace),this._trueLatLngs=/* @__PURE__ */ new WeakMap,this._displacedPositions=/* @__PURE__ */ new Map,this.callInitHooks(e)}addHooks(){this._map.on(`zoomend`,this.schedule,this),this._map.on(`layeradd`,this._onLayerAdd,this),this._map.on(`layerremove`,this._onLayerRemove,this),this._map.eachLayer(e=>this._track(e)),this.schedule()}removeHooks(){this._map.off(`zoomend`,this.schedule,this),this._map.off(`layeradd`,this._onLayerAdd,this),this._map.off(`layerremove`,this._onLayerRemove,this),this._frame&&cancelAnimationFrame(this._frame),this._frame=void 0,this._restore()}schedule(){this._frame||=requestAnimationFrame(()=>{this._frame=void 0,this.relayout()})}relayout(){let e=this._map,t=[];if(e.eachLayer(e=>{this._trueLatLngs.has(e)&&t.push(e)}),t.length<2)return;let n=e.getZoom(),r=this._displacedPositions.get(n);if(r||(r=/* @__PURE__ */ new Map,this._displacedPositions.set(n,r)),t.every(e=>e.options.displaceId&&r.has(e.options.displaceId))){for(let e of t)this._moveTo(e,r.get(e.options.displaceId));return}let{gap:i,iterations:a,maxDistance:o}=this.options,s=t.map(t=>e.project(this._trueLatLngs.get(t),n));ur(s,2*t.reduce((e,t)=>Math.max(e,t.getRadius()),0)+i,{iterations:a,maxDisplacement:o*this._pixelsPerMeter(n)});for(let i=0;i<t.length;i++){let a=e.unproject(s[i],n);this._moveTo(t[i],a),t[i].options.displaceId&&r.set(t[i].options.displaceId,a)}}_pixelsPerMeter(e){let t=this._map,n=t.getCenter(),r=t.unproject(t.project(n,e).add(new g(100,0)),e);return 100/t.distance(n,r)}_moveTo(e,t){this._moving=!0;try{e.setLatLng(t)}finally{this._moving=!1}}_onMarkerMove(e){this._moving||(this._trueLatLngs.set(e.target,e.latlng),this._displacedPositions.clear(),this._enabled&&this._map.hasLayer(e.target)&&this.schedule())}_onLayerAdd(e){this._track(e.layer),cr(e.layer)&&this.schedule()}_onLayerRemove(e){cr(e.layer)&&this.schedule()}_track(e){cr(e)&&(this._trueLatLngs.has(e)||(this._trueLatLngs.set(e,e.getLatLng()),e.on(`move`,this._onMarkerMove,this)))}_restore(){this._map.eachLayer(e=>{let t=this._trueLatLngs.get(e);t&&this._moveTo(e,t)})}};function ur(e,t,{iterations:n=lr.defaultOptions.iterations,maxDisplacement:r=1/0}={}){let i=e.length;if(i<2)return e;let a=t,o=a*a,s=a,c=new Float64Array(i),l=new Float64Array(i),u=Float64Array.from(e,e=>e.x),d=Float64Array.from(e,e=>e.y);for(let t=0;t<n;t++){c.fill(0),l.fill(0);let t=/* @__PURE__ */ new Map;for(let n=0;n<i;n++){let r=`${Math.floor(e[n].x/s)},${Math.floor(e[n].y/s)}`,i=t.get(r);i?i.push(n):t.set(r,[n])}let n=0;for(let r=0;r<i;r++){let i=Math.floor(e[r].x/s),u=Math.floor(e[r].y/s);for(let s=i-1;s<=i+1;s++)for(let i=u-1;i<=u+1;i++){let u=t.get(`${s},${i}`);if(u)for(let t of u){if(t<=r)continue;let i=e[r].x-e[t].x,s=e[r].y-e[t].y,u=i*i+s*s;if(u>=o)continue;n++;let d;if(u===0){let e=r*2.399963229728653;i=Math.cos(e),s=Math.sin(e),d=1}else d=Math.sqrt(u),i/=d,s/=d;let f=(a-d)/2;c[r]+=i*f,l[r]+=s*f,c[t]-=i*f,l[t]-=s*f}}}if(n===0)break;for(let t=0;t<i;t++){e[t].x+=c[t],e[t].y+=l[t];let n=e[t].x-u[t],i=e[t].y-d[t],a=n*n+i*i;if(a>r*r){let o=r/Math.sqrt(a);e[t].x=u[t]+n*o,e[t].y=d[t]+i*o}}}return e}const dr=n;var fr=class e extends N{static defaultOptions={position:`topleft`};constructor(...t){super(...t),this.callInitHooks(e)}onAdd(e){let t=D(`div`,`maplair-control-rotate maplair-bar`),n=this._button=D(`button`,`maplair-control-rotate-button`,t),r=P.translate(`Reset north`);return n.type=`button`,n.title=r,n.setAttribute(`aria-label`,r),n.innerHTML=`<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16"><path d="M8 1 11 8H5z" fill="#d22"/><path d="M8 15 5 8h6z" fill="#999"/></svg>`,w(n),y(n,`click`,E),y(n,`click`,this._resetNorth,this),y(n,`click`,this._refocusOnMap,this),this._update(),e.on(`rotate`,this._update,this),t}onRemove(e){e.off(`rotate`,this._update,this)}_resetNorth(e){this._map._setUserEvent(e),this._map.setBearing(0,{animate:!0})}_update(){this._button.firstChild.style.transform=`rotate(${-this._map.getBearing()}deg)`}static register(t){t.mergeOptions({rotateControl:!1}),t.addInitHook(function(){this.options.rotateControl&&(this.rotateControl=new e,this.addControl(this.rotateControl))})}};function pr(e){return(Number(e)%360+360)%360}function mr(e,t){let n=t*Math.PI/180,r=Math.cos(n),i=Math.sin(n);return new g(e.x*r-e.y*i,e.x*i+e.y*r)}const hr=/* @__PURE__ */ new WeakMap,{panBy:gr}=Q.prototype,{getEvents:_r}=J.prototype,{_setPosition:vr}=Y.prototype,{getEvents:yr,_positionElements:br}=$.prototype,{_onDown:xr,_updatePosition:Sr}=Z.prototype,{_onPointerStart:Cr}=Gt.prototype,{_onDown:wr}=Jt.prototype,{_pinchTo:Tr}=Kt.prototype;Q.mergeOptions({bearing:0,pinchRotate:!1}),Q.addInitHook(function(){(this.options.bearing||this.options.pinchRotate||this.options.rotateControl)&&(this._rotate(this.options.bearing),this._loaded&&this.fire(`moveend`))}),fr.register(Q),Q.include({setBearing(e,t){e=pr(e);let n=this.getBearing();if(!this._rotatePane&&!e||e===n)return this;if(this._stop(),!t?.animate||!this._loaded||this._prefersReducedMotion())return this._rotate(e),this._loaded?this.fire(`movestart`).fire(`move`).fire(`moveend`):this;let r=(e-n+540)%360-180,i=performance.now();this.fire(`movestart`);let a=()=>{let e=Math.min(1,(performance.now()-i)/250);this._rotate(n+r*(1-(1-e)**2)),this.fire(`move`),e<1?this._flyToFrame=requestAnimationFrame(a):this.fire(`moveend`)};return this._flyToFrame=requestAnimationFrame(a),this},_rotate(e){if(e=pr(e),!this._rotatePane){let e=this._rotatePane=D(`div`,`maplair-rotate-pane`);hr.set(e,this),this._container.insertBefore(e,this._mapPane),e.appendChild(this._mapPane)}e!==this.getBearing()&&(this._bearing=e,this._rotatePane.style.transform=e?`rotate(${-e}deg)`:``,this._loaded&&this.fire(`rotate`))},getBearing(){return this._bearing??0},_rotateToPane(e){return this._bearing?mr(e,this._bearing):e},_rotateToContainer(e){return this._bearing?mr(e,-this._bearing):e},_getViewSize(){let e=this.getSize();if(!this._bearing)return e;let t=this._bearing*Math.PI/180,n=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return new g(e.x*n+e.y*r,e.x*r+e.y*n)},_rotateUpright(e,t){this._bearing?(e.style.transform+=` rotate(${this._bearing}deg)`,e.style.transformOrigin=t):e.style.transformOrigin&&(e.style.transformOrigin=``)},containerPointToLayerPoint(e){if(e=g.from(e),this._bearing){let t=this.getSize()._divideBy(2);e=this._rotateToPane(e.subtract(t))._add(t)}return e.subtract(this._getMapPanePos())},layerPointToContainerPoint(e){if(e=g.from(e).add(this._getMapPanePos()),this._bearing){let t=this.getSize()._divideBy(2);e=this._rotateToContainer(e.subtract(t))._add(t)}return e},getPixelBounds(e,t){let n=this._getTopLeftPoint(e,t);if(!this._bearing)return new I(n,n.add(this.getSize()));let r=n.add(this.getSize()._divideBy(2)),i=this._getViewSize()._divideBy(2);return new I(r.subtract(i),r.add(i))},panBy(e,t){return gr.call(this,this._rotateToPane(g.from(e)),t)},_tryAnimatedPan(e,t){let n=this._rotateToContainer(this._getCenterOffset(e)._trunc());return t?.animate!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)},invalidateSize(e){if(!this._loaded)return this;e={animate:!1,pan:!0,...e===!0?{animate:!0}:e};let t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;let n=this.getSize(),r=t.divideBy(2).round(),i=n.divideBy(2).round(),a=r.subtract(i);return!a.x&&!a.y?this:(e.animate&&e.pan?this.panBy(this._rotateToContainer(a)):(e.pan&&this._rawPanBy(a),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(this.fire.bind(this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:n}))},_continuousZoom(e,t,n,r){let i=this._zoom,a=n.multiplyBy(-1),o=this.layerPointToLatLng(this._getCenterLayerPoint().add(n)),s=performance.now();this._moveStart(!0,r.noMoveStart??!1);let c=()=>{let n=Math.min(1,(performance.now()-s)/250);if(n<1){let e=i+(t-i)*(1-(1-n)**2);this._move(this.unproject(this.project(o,e).add(a),e),e,{continuous:!0}),this._flyToFrame=requestAnimationFrame(c)}else this._move(e,t)._moveEnd(!0)};this._flyToFrame=requestAnimationFrame(c)}}),Un.include({_getTiledPixelBounds(e){let t=this._map,n=t._animatingZoom?Math.max(t._animateToZoom,t.getZoom()):t.getZoom(),r=t.getZoomScale(n,this._tileZoom),i=t.project(e,this._tileZoom).floor(),a=t._getViewSize().divideBy(r*2);return new I(i.subtract(a),i.add(a))}}),Be.include({_updateTransform(e,t){let n=this._map.getZoomScale(t,this._zoom),r=this._map._getViewSize().multiplyBy(.5+this.options.padding),i=this._map.project(this._center,t),a=r.multiplyBy(-n)._add(i)._subtract(this._map._getNewPixelOrigin(e,t))._round();k(this._container,a,n)},_onMoveEnd(e){let t=this.options.padding,n=this._map._getViewSize();n.multiplyBy(1+t*2).round().equals(this._containerSize)||this._resizeContainer();let r=this._map._getCenterLayerPoint().subtract(n.multiplyBy(.5+t)).round();this._bounds=new I(r,r.add(n.multiplyBy(1+t*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._updateTransform(this._center,this._zoom),this._onSettled(e)},_resizeContainer(){let e=this.options.padding,t=this._containerSize=this._map._getViewSize().multiplyBy(1+e*2).round();return this._container.style.width=`${t.x}px`,this._container.style.height=`${t.y}px`,t}}),J.include({getEvents(){return{..._r.call(this),rotate:this._updatePosition}},_updatePosition(){if(!this._map)return;let e=this._map,t=e.latLngToLayerPoint(this._latlng)._round(),n=e._rotateToPane(new g(this._getAnchor())),r=g.from(this.options.offset),i=this._zoomAnimated||this.options.overflow||e._bearing;i||(r=r.add(t).add(n));let a=this._containerBottom=-r.y,o=this._containerLeft=-Math.round(this._containerWidth/2)+r.x;this.options.overflow?(this._container.style.top=`auto`,this._container.style.bottom=`calc(100% + ${a}px)`):this._container.style.bottom=`${a}px`,this._container.style.left=`${o}px`,i&&this._setContainerPosition(t.add(n),`${-o}px calc(100% + ${a+(this._containerMarginBottom??0)}px)`)},_setContainerPosition(e,t){if(this._containerPos=e,this.options.overflow){let t=this._map._container,n=t.getBoundingClientRect();e=this._map.layerPointToContainerPoint(e)._add(new g(n.left+t.clientLeft,n.top+t.clientTop))}A(this._container,e),this.options.overflow||this._map._rotateUpright(this._container,t)}}),Mt.include({_animateZoom(e){let t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),n=this._map._rotateToPane(new g(this._getAnchor()));this._setContainerPosition(t.add(n),this._container.style.transformOrigin)},_adjustPan(){if(!this.options.autoPan)return;if(this._map._panAnim?.stop(),this._autopanning){this._autopanning=!1;return}let e=this._map,t=this._containerMarginBottom??(parseInt(getComputedStyle(this._container).marginBottom,10)||0),n=this._containerHeight+t,r=this._containerWidth,i=new g(this._containerLeft,-n-this._containerBottom),a=e.layerPointToContainerPoint(this._getContainerPosition())._add(i),o=g.from(this.options.autoPanPadding),s=g.from(this.options.autoPanPaddingTopLeft??o),c=g.from(this.options.autoPanPaddingBottomRight??o),l=e.getSize(),u=0,d=0;a.x+r+c.x>l.x&&(u=a.x+r-l.x+c.x),a.x-u-s.x<0&&(u=a.x-s.x),a.y+n+c.y>l.y&&(d=a.y+n-l.y+c.y),a.y-d-s.y<0&&(d=a.y-s.y),(u||d)&&(this.options.keepInView&&(this._autopanning=!0),e.fire(`autopanstart`).panBy([u,d]))}});const Er={top:[0,-6],bottom:[0,6],left:[-6,0],right:[6,0]};Y.include({_setPosition(e){vr.call(this,e);let t=this._container;if(this.options.overflow)return;if(!this._map._bearing){t.style.left=t.style.top=``;return}let n=this._containerPos.subtract(e),r=Object.keys(Er).find(e=>t.classList.contains(`maplair-tooltip-${e}`)),i=Er[r]??[0,0];t.style.left=`${n.x}px`,t.style.top=`${n.y}px`,this._setContainerPosition(e,`${-n.x-i[0]}px ${-n.y-i[1]}px`)}}),$.include({options:{rotateWithView:!1}}),$.include({getEvents(){return{...yr.call(this),rotate:this.update}},_positionElements(e){br.call(this,e);let t=this.options.rotateWithView?0:this._map?.getBearing()??0;if(t)for(let e of[this._icon,this._shadow])e&&(e.style.transform+=` rotate(${t}deg)`)}}),ln.include({_adjustPan(e){let t=this._marker,n=t._map,r=this._marker.options.autoPanSpeed,i=this._marker.options.autoPanPadding,a=j(t._icon),o=n.getPixelBounds(),s=n.getPixelOrigin(),c=new I(o.min._subtract(s).add(i),o.max._subtract(s).subtract(i));if(!c.contains(a)){let i=new g((Math.max(c.max.x,a.x)-c.max.x)/(o.max.x-c.max.x)-(Math.min(c.min.x,a.x)-c.min.x)/(o.min.x-c.min.x),(Math.max(c.max.y,a.y)-c.max.y)/(o.max.y-c.max.y)-(Math.min(c.min.y,a.y)-c.min.y)/(o.min.y-c.min.y)).multiplyBy(r);n.panBy(n._rotateToContainer(i),{animate:!1}),this._draggable._newPos._add(i),this._draggable._startPos._add(i),A(t._icon,this._draggable._newPos),this._onDrag(e),this._panRequest=requestAnimationFrame(this._adjustPan.bind(this,e))}}}),Z.include({_onDown(e){xr.call(this,e);let t=this._element.closest?.(`.maplair-rotate-pane`);this._rotatedMap=t&&hr.get(t),this._rotatedMap&&this._parentScale&&(this._parentScale=M(t.parentNode))},_updatePosition(){let e=this._rotatedMap;e?._bearing&&(this._newPos=this._startPos.add(e._rotateToPane(this._newPos.subtract(this._startPos)))),Sr.call(this)}}),Ut.include({_onDragEnd(e){let t=this._map,n=t.options,r=!n.inertia||e.noInertia||this._times.length<2;if(t.fire(`dragend`,e),r)t.fire(`moveend`);else{this._prunePositions(Date.now());let e=this._lastPos.subtract(this._positions[0]),r=(this._lastTime-this._times[0])/1e3,i=n.easeLinearity,a=e.multiplyBy(i/r),o=a.distanceTo([0,0]),s=Math.min(n.inertiaMaxSpeed,o),c=a.multiplyBy(s/o),l=t.getSize().divideBy(2),u=s/(n.inertiaDeceleration*i),d=c.multiplyBy(-u/2).round();if(t._prefersReducedMotion()&&!l.contains(d)){let e=Math.min(l.x/Math.abs(d.x),l.y/Math.abs(d.y));d=d.multiplyBy(e).round(),u*=Math.sqrt(e)}!d.x&&!d.y?t.fire(`moveend`):(d=t._limitOffset(d,t.options.maxBounds),requestAnimationFrame(()=>{t.panBy(t._rotateToContainer(d),{duration:u,easeLinearity:i,noMoveStart:!0,animate:!0})}))}}});function Dr(e,t){return Math.atan2(t.y-e.y,t.x-e.x)*180/Math.PI}Gt.include({_onPointerStart(e){Cr.call(this,e);let t=v();this._zooming&&t.length===2&&(this._startAngle=Dr(...t.map(e=>this._map.pointerEventToContainerPoint(e))),this._startBearing=this._map.getBearing(),this._rotating=!1)},_onPointerMove(e){let t=v();if(t.length!==2||!this._zooming)return;let n=this._map,r=n.pointerEventToContainerPoint(t[0]),i=n.pointerEventToContainerPoint(t[1]),a=r.distanceTo(i)/this._startDist;if(this._zoom=n.getScaleZoom(a,this._startZoom),n.options.pinchRotate){let e=(Dr(r,i)-this._startAngle+540)%360-180;!this._rotating&&Math.abs(e)>15&&(this._rotating=!0,this._startAngle+=Math.sign(e)*15,e-=Math.sign(e)*15),this._rotating&&n._rotate(this._startBearing-e)}if(!n.options.bounceAtZoomLimits&&(this._zoom<n.getMinZoom()&&a<1||this._zoom>n.getMaxZoom()&&a>1)&&(this._zoom=n._limitZoom(this._zoom)),n.options.pinchZoom===`center`){if(this._center=this._startLatLng,a===1&&!this._rotating)return}else{let e=n._rotateToPane(r._add(i)._divideBy(2)._subtract(this._centerPoint));if(a===1&&e.x===0&&e.y===0&&!this._rotating)return;this._center=n.unproject(n.project(this._pinchStartLatLng,this._zoom).subtract(e),this._zoom)}this._moved||=(n._setUserEvent(e),n._moveStart(!0,!1),!0),cancelAnimationFrame(this._animRequest);let o=n._move.bind(n,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=requestAnimationFrame(o.bind(this)),e.preventDefault()}}),Jt.include({_onDown(e){wr.call(this,e),this._zooming&&this._aroundOffset&&(this._aroundOffset=this._map._rotateToPane(this._aroundOffset))}}),Kt.include({_pinchTo(e,t,n){Tr.call(this,e,t,n),this._pinch&&!this._pinch.rotated&&(this._pinch.offset=this._map._rotateToPane(this._pinch.offset),this._pinch.rotated=!0)},_panBy(e){E(e);let t=this._map;if(t._animatingZoom)return;let n=e.deltaMode===1?20:e.deltaMode===2?60:1,r=new g(e.deltaX*n,e.deltaY*n);e.shiftKey&&!e.deltaX&&(r=new g(r.y,0)),r=t._rotateToPane(r),t.options.maxBounds&&(r=t._limitOffset(r,t.options.maxBounds)),this._panning||(t._stop(),this._panning=!0,t._setUserEvent(e),t.fire(`movestart`)),t._rawPanBy(r.round()),t.fire(`move`),clearTimeout(this._panTimer),this._panTimer=setTimeout(this._endPan.bind(this),150)}});const{onRemove:Or}=$.prototype;$.include({moveTo(e,t){return this.moveAlong([e],t)},moveAlong(e,t={}){this.stopMoving();let n=[this._latlng,...e.map(e=>V.from(e))],r=n.slice(1).map((e,t)=>this._map?.distance(n[t],e)??n[t].distanceTo(e)),i=r.reduce((e,t)=>e+t,0),a=t.speed?i/t.speed*1e3:t.duration??1e3,o=performance.now(),s=()=>{let e=a&&!this._map?._prefersReducedMotion()?Math.min(1,(performance.now()-o)/a)*i:i,c=0,l=e;for(;c<r.length-1&&e>r[c];)e-=r[c],c++;let u=n[c],d=n[c+1];t.rotate&&!u.equals(d)&&(this.options.rotation=this._heading(u,d)),this.setLatLng(this._interpolate(u,d,r[c]?Math.min(1,e/r[c]):1)),l<i?this._moveFrame=requestAnimationFrame(s):(this._moveFrame=null,this.fire(`moveend`))};return this._moveFrame=requestAnimationFrame(s),this},stopMoving(){return cancelAnimationFrame(this._moveFrame),this._moveFrame=null,this},isMoving(){return!!this._moveFrame},_interpolate(e,t,n){let r=this._map?.options.crs;if(!r)return new V(e.lat+(t.lat-e.lat)*n,e.lng+(t.lng-e.lng)*n);let i=r.projection.project(e),a=r.projection.project(t);return r.projection.unproject(i.add(a.subtract(i).multiplyBy(n)))},_heading(e,t){let n=this._map?.options.crs,r=n?n.latLngToPoint(e,0):new g(e.lng,-e.lat),i=n?n.latLngToPoint(t,0):new g(t.lng,-t.lat);return Math.atan2(i.x-r.x,r.y-i.y)*180/Math.PI-(this.options.rotateWithView?0:this._map?.getBearing?.()??0)},onRemove(e){return this.stopMoving(),Or.call(this,e)}});const kr=/[ ,]+/,{_updateStyle:Ar}=L.prototype,{_fillStroke:jr,_destroyContainer:Mr}=Qn.prototype;R.include({options:{dashSpeed:0},_getDashLength(){let e=this.options.dashArray,t=(Array.isArray(e)?e:String(e??``).split(kr)).map(Number).filter(e=>!Number.isNaN(e)),n=t.reduce((e,t)=>e+t,0);return t.length%2?n*2:n}}),L.include({_updateStyle(e){Ar.call(this,e);let t=e._path;if(!t)return;let n=e.options.dashSpeed,r=e.options.stroke&&n&&e._getDashLength();t.classList.toggle(`maplair-dash-animated`,!!r),r&&(t.style.setProperty(`--maplair-dash-length`,`${Math.sign(n)*r}px`),t.style.setProperty(`--maplair-dash-duration`,`${r/Math.abs(n)}s`))}}),Qn.include({_fillStroke(e,t){let n=this._getDashShift(t);if(!n){jr.call(this,e,t);return}let r=t.options,i=Object.hasOwn(r,`dashOffset`),a=r.dashOffset;f(t,{dashOffset:Number(a??0)-n}),jr.call(this,e,t),i?r.dashOffset=a:delete r.dashOffset},_destroyContainer(){cancelAnimationFrame(this._dashFrame),this._dashFrame=null,Mr.call(this)},_getDashShift(e){let t=e.options.dashSpeed,n=t&&!this._map._prefersReducedMotion()&&e._getDashLength();return n?(this._animatedDashes??=/* @__PURE__ */ new Set,this._animatedDashes.add(e),this._dashFrame??=requestAnimationFrame(()=>{this._dashFrame=null;for(let e of this._animatedDashes)this._layers[a(e)]&&e.options.dashSpeed&&this._requestRedraw(e);this._animatedDashes.clear()}),performance.now()/1e3*t%n):0}});function Nr(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n],a=r.distanceTo(i);if(t<=a||n===e.length-1){let e=a?Math.min(1,t/a):0;return{point:new g(r.x+(i.x-r.x)*e,r.y+(i.y-r.y)*e),angle:Math.atan2(i.y-r.y,i.x-r.x)}}t-=a}return{point:e[0],angle:0}}function Pr(e){let t=0;for(let n=1;n<e.length;n++)t+=e[n-1].distanceTo(e[n]);return t}const{_setPath:Fr,_updateStyle:Ir,_addPath:Lr,_removePath:Rr,_bringToFront:zr,_bringToBack:Br}=L.prototype,{_updatePoly:Vr,_extendRedrawBounds:Hr}=Qn.prototype;R.include({options:{arrowheads:!1,text:null}}),Yt.include({_getArrowheadOptions(){let e=this.options.arrowheads;return e?{size:10,repeat:0,...e===!0?{}:e}:null},_getTextOptions(){let e=this.options.text;return e?{repeat:!1,center:!1,offset:0,fontSize:12,...typeof e==`string`?{content:e}:e}:null},_getDecorationPadding(){let e=this._getTextOptions();return(this._getArrowheadOptions()?.size??0)+(e?e.fontSize+Math.abs(e.offset):0)},_getArrowheads(){let{size:e,repeat:t}=this._getArrowheadOptions(),n=[];for(let r of this._rings){if(r.length<2)continue;let i=Pr(r),a=[];if(t>0)for(let e=t;e<=i;e+=t)a.push(e);else a.push(i);for(let t of a){let{point:i,angle:a}=Nr(r,t),o=Math.cos(a),s=Math.sin(a),c=new g(i.x-o*e,i.y-s*e),l=e/2;n.push([i,new g(c.x-s*l,c.y+o*l),new g(c.x+s*l,c.y-o*l)])}}return n},_getTextPlacements(e){let t=this._getTextOptions(),n=[];if(!t)return n;let r=e(t.content);for(let i of this._parts){let a=Pr(i);if(!r||r>a)continue;let o=t.center?(a-r)/2:0,s=t.repeat?a-r:o;for(;o<=s+1e-9;o+=r){let r=o;for(let a of t.content){let t=e(a);n.push({char:a,width:t,...Nr(i,r+t/2)}),r+=t}}}return n}}),L.include({_setPath(e,t){Fr.call(this,e,t),this._updateDecorations(e)},_updateStyle(e){Ir.call(this,e),e._rings&&this._updateDecorations(e)},_addPath(e){Lr.call(this,e),this._updateDecorations(e)},_removePath(e){Rr.call(this,e),e._arrowheads?.remove(),e._text?.remove()},_bringToFront(e){zr.call(this,e),this._placeDecorations(e)},_bringToBack(e){Br.call(this,e),this._placeDecorations(e)},_updateDecorations(e){let t=e._path,n=e.options,r=e._getArrowheadOptions?.(),i=e._getTextOptions?.();if(t){if(r){let t=e._arrowheads??=L.create(`path`);t.setAttribute(`class`,`maplair-path-arrowheads`),t.setAttribute(`d`,e._getArrowheads().map(([e,t,n])=>`M${e.x} ${e.y}L${t.x} ${t.y}L${n.x} ${n.y}z`).join(``)||`M0 0`),t.setAttribute(`fill`,r.color??n.color),t.setAttribute(`fill-opacity`,n.opacity)}else e._arrowheads?.remove(),e._arrowheads=null;if(i){t.id||=`maplair-path-${a(e)}`;let r=e._text??=L.create(`text`),o=r.firstChild??r.appendChild(L.create(`textPath`));if(r.setAttribute(`class`,`maplair-path-text`),r.setAttribute(`fill`,i.color??n.color),r.setAttribute(`font-size`,i.fontSize),r.setAttribute(`dy`,i.offset),o.setAttribute(`href`,`#${t.id}`),i.center?(o.setAttribute(`startOffset`,`50%`),o.setAttribute(`text-anchor`,`middle`)):(o.removeAttribute(`startOffset`),o.removeAttribute(`text-anchor`)),o.textContent=i.content,this._placeDecorations(e),i.repeat&&t.isConnected){let e=r.getComputedTextLength();o.textContent=i.content+i.content;let n=r.getComputedTextLength()-e,a=n>0?Math.floor((t.getTotalLength()-e+n)/n):1;o.textContent=Array(Math.max(1,a)).fill(i.content).join(``)}}else e._text?.remove(),e._text=null;this._placeDecorations(e)}},_placeDecorations(e){let t=[e._arrowheads,e._text].filter(Boolean);t.length&&e._path.parentNode&&e._path.after(...t)}}),Qn.include({_updatePoly(e,t){Vr.call(this,e,t),this._drawing&&e._parts.length&&this._drawDecorations(this._ctx,e)},_extendRedrawBounds(e){Hr.call(this,e);let t=e._getDecorationPadding?.();if(t&&e._pxBounds){let n=(e.options.weight??0)+1+t;this._redrawBounds.extend(e._pxBounds.min.subtract([n,n])),this._redrawBounds.extend(e._pxBounds.max.add([n,n]))}},_drawDecorations(e,t){let n=t.options,r=t._getArrowheadOptions?.(),i=t._getTextOptions?.();if(r){e.beginPath();for(let[n,r,i]of t._getArrowheads())e.moveTo(n.x,n.y),e.lineTo(r.x,r.y),e.lineTo(i.x,i.y),e.closePath();e.globalAlpha=n.opacity,e.fillStyle=r.color??n.color,e.fill()}if(i){e.globalAlpha=1,e.fillStyle=i.color??n.color,e.font=`${i.fontSize}px sans-serif`,e.textBaseline=`alphabetic`;for(let{char:n,width:r,point:a,angle:o}of t._getTextPlacements(t=>e.measureText(t).width))e.save(),e.translate(a.x,a.y),e.rotate(o),e.fillText(n,-r/2,i.offset),e.restore()}}}),Mn.include({options:{url:void 0,fetchOptions:void 0,fitBounds:!1}}),Mn.include({load(e,t=this.options.fetchOptions){this._loadAbort?.abort();let n=this._loadAbort=new AbortController,r=typeof e==`string`?fetch(e,{...t,signal:n.signal}).then(e=>{if(!e.ok)throw Error(`${e.status} ${e.statusText}`);return e.json()}):e;return this.fire(`loading`),Promise.resolve(r).then(e=>(n.signal.aborted||(this._loadAbort=null,this.clearLayers().addData(e),this.options.fitBounds&&this._map&&this.getBounds().isValid()&&this._map.fitBounds(this.getBounds()),this.fire(`load`,{data:e})),this),e=>{if(n.signal.aborted)return this;throw this._loadAbort=null,this.fire(`error`,{error:e}),e})}}),Mn.addInitHook(function(){this.options.url&&this.load(this.options.url).catch(()=>{})});const Ur=[`weight`,`radius`];function Wr(e,t){if(typeof e==`function`)return e(t);let n=Object.keys(e).map(Number).sort((e,t)=>e-t);return e[n.findLast(e=>e<=t)??n[0]]}const{beforeAdd:Gr,setStyle:Kr}=R.prototype,{setRadius:qr}=G.prototype;R.include({getEvents(){return{zoomend:this._updateZoomStyles}},beforeAdd(e){Gr.call(this,e),this._applyZoomStyles(e.getZoom())},setStyle(e){this._takeZoomStyles(e);let t=this._map?.getZoom();if(e&&this._zoomStyles&&t!==void 0){e={...e};for(let[n,r]of Object.entries(this._zoomStyles))Object.hasOwn(e,n)&&(e[n]=Wr(r,t))}return Kr.call(this,e)},_takeZoomStyles(e){for(let t of Ur){if(!e||!Object.hasOwn(e,t))continue;let n=e[t];n&&(typeof n==`function`||typeof n==`object`)?this._zoomStyles={...this._zoomStyles,[t]:n}:this._zoomStyles&&delete this._zoomStyles[t]}},_applyZoomStyles(e){if(!this._zoomStyles)return;let t={};for(let[n,r]of Object.entries(this._zoomStyles))t[n]=Wr(r,e);Kr.call(this,t),t.radius!==void 0&&this.setRadius&&qr.call(this,t.radius)},_updateZoomStyles(){this._applyZoomStyles(this._map.getZoom())}}),G.include({setRadius(e){return this._takeZoomStyles({radius:e}),this._zoomStyles?.radius&&this._map?qr.call(this,Wr(e,this._map.getZoom())):qr.call(this,e)}}),R.addInitHook(function(){this._takeZoomStyles(this.options)});export{ke as AttributionControl,Be as BlanketOverlay,I as Bounds,Vt as BoxZoomHandler,je as ButtonBarControl,Ae as ButtonControl,yt as CRS,Qn as Canvas,$n as Circle,G as CircleMarker,h as Class,Nn as Classification,Fe as ContextMenu,N as Control,sn as DefaultIcon,lr as DisplaceHandler,zn as DivIcon,J as DivOverlay,de as DomEvent,be as DomUtil,Ht as DoubleClickZoomHandler,Ut as DragHandler,Z as Draggable,kn as EPSG3395,Ct as EPSG3857,An as EPSG4326,wt as EPSG900913,K as EarthCRS,Ne as Evented,q as FeatureGroup,Le as FullscreenControl,Mn as GeoJSON,Un as GridLayer,X as Handler,or as Hash,Fn as HeatLayer,P as I18n,an as Icon,In as ImageOverlay,Wt as KeyboardHandler,V as LatLng,z as LatLngBounds,F as Layer,Dt as LayerGroup,Re as LayersControl,Q as LeafletMap,Q as Map,Q as MaplairMap,ht as LegendControl,Xe as LineUtil,Dn as LonLatProjection,sr as MapSync,$ as Marker,Hn as MarkerClusterGroup,On as MercatorProjection,nn as MiniMapControl,R as Path,Gt as PinchZoomHandler,g as Point,Xt as PolyUtil,tn as Polygon,Yt as Polyline,Mt as Popup,er as Rectangle,Ve as Renderer,fr as RotateControl,L as SVG,Rn as SVGOverlay,rn as ScaleControl,Kt as ScrollWheelZoomHandler,fn as SearchControl,pn as SideBySideControl,jn as SimpleCRS,xt as SphericalMercatorProjection,Vn as SvgIcon,Jt as TapDragZoomHandler,qt as TapHoldHandler,hn as TextControl,Yn as TileLayer,En as TimeControl,Y as Tooltip,St as Transformation,r as Util,Ln as VideoOverlay,Xn as WMSTileLayer,Et as ZoomControl,ur as displace,dr as version};
|
|
7
7
|
//# sourceMappingURL=maplair.js.map
|