@defra/interactive-map 0.0.23-alpha → 0.0.24-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/assets/images/light-raster-thumb.jpg +0 -0
  2. package/assets/images/outdoor-raster-thumb.jpg +0 -0
  3. package/assets/images/road-raster-thumb.jpg +0 -0
  4. package/docs/plugins/search.md +70 -0
  5. package/package.json +16 -2
  6. package/plugins/beta/draw-ml/dist/css/index.css +1 -21
  7. package/plugins/beta/draw-ml/dist/esm/im-draw-ml-plugin.js +1 -1
  8. package/plugins/beta/draw-ml/dist/umd/im-draw-ml-plugin.js +1 -1
  9. package/plugins/beta/draw-ml/src/api/editFeature.js +9 -4
  10. package/plugins/beta/draw-ml/src/modes/createDrawMode.js +11 -3
  11. package/plugins/interact/src/hooks/useAttachEvents.test.js +3 -0
  12. package/plugins/search/dist/esm/im-search-plugin.js +1 -1
  13. package/plugins/search/dist/esm/index.js +1 -1
  14. package/plugins/search/dist/umd/im-search-plugin.js +1 -1
  15. package/plugins/search/dist/umd/index.js +1 -1
  16. package/plugins/search/src/Search.jsx +2 -1
  17. package/plugins/search/src/components/Form/Form.jsx +11 -7
  18. package/plugins/search/src/components/Form/Form.test.jsx +23 -1
  19. package/plugins/search/src/datasets.js +2 -2
  20. package/plugins/search/src/datasets.test.js +1 -1
  21. package/plugins/search/src/defaults.js +7 -1
  22. package/plugins/search/src/events/fetchSuggestions.js +13 -10
  23. package/plugins/search/src/events/fetchSuggestions.test.js +14 -1
  24. package/plugins/search/src/events/formHandlers.js +2 -4
  25. package/plugins/search/src/events/formHandlers.test.js +3 -3
  26. package/plugins/search/src/events/inputHandlers.js +1 -1
  27. package/plugins/search/src/events/inputHandlers.test.js +1 -1
  28. package/plugins/search/src/events/suggestionHandlers.js +2 -1
  29. package/plugins/search/src/events/suggestionHandlers.test.js +7 -1
  30. package/plugins/search/src/index.js +3 -7
  31. package/plugins/search/src/reducer.js +10 -5
  32. package/plugins/search/src/reducer.test.js +2 -1
  33. package/plugins/search/src/utils/parseOsNamesResults.js +3 -3
  34. package/providers/beta/openlayers/dist/esm/im-openlayers-provider.js +1 -0
  35. package/providers/beta/openlayers/dist/esm/index.js +1 -0
  36. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js +2 -0
  37. package/providers/beta/openlayers/dist/umd/im-openlayers-provider.js.LICENSE.txt +1 -0
  38. package/providers/beta/openlayers/dist/umd/index.js +2 -0
  39. package/providers/beta/openlayers/dist/umd/index.js.LICENSE.txt +1 -0
  40. package/providers/beta/openlayers/src/appEvents.js +50 -0
  41. package/providers/beta/openlayers/src/appEvents.test.js +140 -0
  42. package/providers/beta/openlayers/src/defaults.js +36 -0
  43. package/providers/beta/openlayers/src/index.js +21 -0
  44. package/providers/beta/openlayers/src/mapEvents.js +132 -0
  45. package/providers/beta/openlayers/src/mapEvents.test.js +197 -0
  46. package/providers/beta/openlayers/src/openlayersProvider.js +234 -0
  47. package/providers/beta/openlayers/src/openlayersProvider.test.js +331 -0
  48. package/providers/beta/openlayers/src/utils/spatial.js +142 -0
  49. package/providers/beta/openlayers/src/utils/spatial.test.js +117 -0
  50. package/providers/beta/openlayers/src/utils/zoom.js +26 -0
  51. package/providers/beta/openlayers/src/utils/zoom.test.js +23 -0
  52. package/providers/maplibre/dist/esm/im-maplibre-provider.js +1 -1
  53. package/providers/maplibre/dist/umd/im-maplibre-provider.js +1 -1
  54. package/providers/maplibre/src/utils/highlightFeatures.js +17 -7
  55. package/providers/maplibre/src/utils/highlightFeatures.test.js +17 -0
  56. package/providers/maplibre/src/utils/patternImages.js +14 -9
  57. package/providers/maplibre/src/utils/patternImages.test.js +2 -1
  58. package/rollup.esm.mjs +14 -3
  59. package/src/App/hooks/useFeatureItems.test.js +1 -0
  60. package/src/App/hooks/useLayoutMeasurements.test.js +0 -1
  61. package/src/App/hooks/useMarkersAPI.test.js +1 -0
  62. package/src/App/hooks/useModalPanelBehaviour.test.js +2 -1
  63. package/src/App/store/AppProvider.test.jsx +5 -0
  64. package/src/App/store/MapProvider.test.jsx +8 -1
  65. package/src/services/announcer.test.js +5 -7
  66. package/webpack.dev.mjs +6 -1
  67. package/webpack.umd.mjs +1 -0
@@ -0,0 +1,117 @@
1
+ import {
2
+ formatDimension,
3
+ getAreaDimensions,
4
+ getCardinalMove,
5
+ getExtentFromGeoJSON,
6
+ getPaddedExtent,
7
+ isGeometryObscured
8
+ } from './spatial.js'
9
+
10
+ jest.mock('ol/proj.js', () => ({
11
+ __esModule: true,
12
+ transform: (coord) => coord,
13
+ transformExtent: (extent) => extent
14
+ }))
15
+
16
+ describe('formatDimension', () => {
17
+ it('formats sub-mile distances in meters', () => {
18
+ expect(formatDimension(400)).toBe('400m')
19
+ })
20
+
21
+ it('formats exactly 1 mile', () => {
22
+ expect(formatDimension(1609.344)).toBe('1 mile')
23
+ })
24
+
25
+ it('formats decimal miles with plural', () => {
26
+ expect(formatDimension(2414.016)).toBe('1.5 miles')
27
+ })
28
+
29
+ it('formats 10+ miles as whole number', () => {
30
+ expect(formatDimension(20000)).toBe('12 miles')
31
+ })
32
+ })
33
+
34
+ describe('getAreaDimensions', () => {
35
+ it('returns empty string for null extent', () => {
36
+ expect(getAreaDimensions(null)).toBe('')
37
+ })
38
+
39
+ it('returns height by width as formatted strings', () => {
40
+ // 1609m height (~1 mile), 804m width (sub-mile)
41
+ expect(getAreaDimensions([0, 0, 804, 1609])).toBe('1 mile by 804m')
42
+ })
43
+ })
44
+
45
+ describe('getCardinalMove', () => {
46
+ it('returns empty string for sub-threshold move', () => {
47
+ expect(getCardinalMove([0, 0], [0.5, 0.5])).toBe('')
48
+ })
49
+
50
+ it('describes north and east movement', () => {
51
+ expect(getCardinalMove([0, 0], [100, 100])).toBe('north 100m, east 100m')
52
+ })
53
+
54
+ it('describes south and west movement', () => {
55
+ expect(getCardinalMove([100, 100], [0, 0])).toBe('south 100m, west 100m')
56
+ })
57
+
58
+ it('describes single-axis movement', () => {
59
+ expect(getCardinalMove([0, 0], [0, 100])).toBe('north 100m')
60
+ })
61
+ })
62
+
63
+ describe('getExtentFromGeoJSON', () => {
64
+ it('returns a 4-element extent from a GeoJSON point', () => {
65
+ const point = { type: 'Feature', geometry: { type: 'Point', coordinates: [0, 51] } }
66
+ expect(getExtentFromGeoJSON(point)).toEqual([0, 51, 0, 51])
67
+ })
68
+ })
69
+
70
+ describe('getPaddedExtent', () => {
71
+ const makeMap = (padding) => ({
72
+ getSize: () => [800, 600],
73
+ getView: () => ({ padding }),
74
+ getCoordinateFromPixel: (pixel) => pixel
75
+ })
76
+
77
+ it('applies padding to sw and ne corner pixels', () => {
78
+ // padding [top=10, right=20, bottom=30, left=40]
79
+ // sw pixel: [left=40, height-bottom=570] → ne pixel: [width-right=780, top=10]
80
+ expect(getPaddedExtent(makeMap([10, 20, 30, 40]))).toEqual([40, 570, 780, 10])
81
+ })
82
+
83
+ it('uses zero padding when view.padding is null', () => {
84
+ expect(getPaddedExtent(makeMap(null))).toEqual([0, 600, 800, 0])
85
+ })
86
+
87
+ it('returns null when coordinate projection fails', () => {
88
+ const map = {
89
+ getSize: () => [800, 600],
90
+ getView: () => ({ padding: null }),
91
+ getCoordinateFromPixel: () => null
92
+ }
93
+ expect(getPaddedExtent(map)).toBeNull()
94
+ })
95
+ })
96
+
97
+ describe('isGeometryObscured', () => {
98
+ const point = { type: 'Feature', geometry: { type: 'Point', coordinates: [-1, 51] } }
99
+ const panel = { left: 0, top: 0, right: 100, bottom: 100 }
100
+
101
+ const makeMap = (pixelFn) => ({
102
+ getTargetElement: () => ({ getBoundingClientRect: () => ({ left: 0, top: 0 }) }),
103
+ getPixelFromCoordinate: pixelFn
104
+ })
105
+
106
+ it('returns false when no corners project to screen pixels', () => {
107
+ expect(isGeometryObscured(point, panel, makeMap(() => null))).toBe(false)
108
+ })
109
+
110
+ it('returns true when geometry overlaps panel', () => {
111
+ expect(isGeometryObscured(point, panel, makeMap(() => [50, 50]))).toBe(true)
112
+ })
113
+
114
+ it('returns false when geometry is outside panel', () => {
115
+ expect(isGeometryObscured(point, panel, makeMap(() => [200, 200]))).toBe(false)
116
+ })
117
+ })
@@ -0,0 +1,26 @@
1
+ import { TILE_GRID_RESOLUTIONS, WORLD_LOD_RESOLUTIONS, WORLD_DEFAULT_MIN_ZOOM, WORLD_DEFAULT_MAX_ZOOM } from '../defaults.js'
2
+
3
+ export const ZOOM_ALIGNMENT = {
4
+ UK: 'uk',
5
+ WORLD: 'world'
6
+ }
7
+
8
+ /**
9
+ * Returns OL View resolution config for the requested zoom alignment mode.
10
+ * 'uk' — OS tile grid zoom levels (0–13); zoom 0 shows all of Great Britain (default)
11
+ * 'world' — ESRI LOD sequence; zoom levels match ESRI SDK, full UK visible around zoom 7
12
+ */
13
+ export function getViewResolutionConfig (zoomAlignment) {
14
+ if (zoomAlignment === ZOOM_ALIGNMENT.WORLD) {
15
+ return {
16
+ resolutions: WORLD_LOD_RESOLUTIONS,
17
+ defaultMinZoom: WORLD_DEFAULT_MIN_ZOOM,
18
+ maxZoom: WORLD_DEFAULT_MAX_ZOOM
19
+ }
20
+ }
21
+ return {
22
+ resolutions: TILE_GRID_RESOLUTIONS,
23
+ defaultMinZoom: 0,
24
+ maxZoom: TILE_GRID_RESOLUTIONS.length - 1
25
+ }
26
+ }
@@ -0,0 +1,23 @@
1
+ import { getViewResolutionConfig, ZOOM_ALIGNMENT } from './zoom.js'
2
+ import { TILE_GRID_RESOLUTIONS, WORLD_LOD_RESOLUTIONS, WORLD_DEFAULT_MIN_ZOOM, WORLD_DEFAULT_MAX_ZOOM } from '../defaults.js'
3
+
4
+ describe('getViewResolutionConfig', () => {
5
+ it('returns UK tile grid config', () => {
6
+ const config = getViewResolutionConfig(ZOOM_ALIGNMENT.UK)
7
+ expect(config.resolutions).toBe(TILE_GRID_RESOLUTIONS)
8
+ expect(config.defaultMinZoom).toBe(0)
9
+ expect(config.maxZoom).toBe(TILE_GRID_RESOLUTIONS.length - 1)
10
+ })
11
+
12
+ it('returns world LOD config', () => {
13
+ const config = getViewResolutionConfig(ZOOM_ALIGNMENT.WORLD)
14
+ expect(config.resolutions).toBe(WORLD_LOD_RESOLUTIONS)
15
+ expect(config.defaultMinZoom).toBe(WORLD_DEFAULT_MIN_ZOOM)
16
+ expect(config.maxZoom).toBe(WORLD_DEFAULT_MAX_ZOOM)
17
+ })
18
+
19
+ it('falls back to UK config for unknown alignment', () => {
20
+ const config = getViewResolutionConfig(undefined)
21
+ expect(config.resolutions).toBe(TILE_GRID_RESOLUTIONS)
22
+ })
23
+ })
@@ -1 +1 @@
1
- import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/objectWithoutProperties";import a from"@babel/runtime/helpers/asyncToGenerator";var r=400,n=7,i=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];var o=(t,e)=>{var a=null,r=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];clearTimeout(a),a=setTimeout(()=>{t(...n)},e)};return r.cancel=()=>{a&&(clearTimeout(a),a=null)},r};function s(t){var{map:e,events:a,eventBus:r,getCenter:n,getZoom:i,getBounds:s,getResolution:l}=t,h=[],u=[],c=()=>{var t=i();return{center:n(),bounds:s(),resolution:l(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},d=(t,e)=>r.emit(t,e),p=()=>d(a.MAP_LOADED);e.on("load",p),h.push(["load",p]);e.once("idle",()=>d(a.MAP_FIRST_IDLE,c()));var g=()=>d(a.MAP_MOVE_START);e.on("movestart",g),h.push(["movestart",g]);var f=o(()=>{d(a.MAP_MOVE_END,c())},500);e.on("moveend",f),h.push(["moveend",f]);var y,m,v,M=(y=()=>{d(a.MAP_MOVE,c())},m=10,v=0,function(){var t=Date.now();t-v>=m&&(v=t,y(...arguments))});e.on("zoom",M),h.push(["zoom",M]);var b=()=>d(a.MAP_RENDER);e.on("render",b),h.push(["render",b]);var w=o(()=>{d(a.MAP_DATA_CHANGE,c())},500),x=t=>{t.isSourceLoaded&&w()};e.on("styledata",w),e.on("sourcedata",x),h.push(["styledata",w],["sourcedata",x]);var P=()=>d(a.MAP_STYLE_CHANGE);e.on("style.load",P),h.push(["style.load",P]);var N=t=>d(a.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]});return e.on("click",N),h.push(["click",N]),u.push(f,M,w),{remove(){u.forEach(t=>t.cancel()),h.forEach(t=>{var[a,r]=t;return e.off(a,r)})}}}let l=" ";class h{static get separator(){return l}static set separator(t){l=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let a=null;switch(e.length){case 3:a=e[0]/1+e[1]/60+e[2]/3600;break;case 2:a=e[0]/1+e[1]/60;break;case 1:a=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(a=-a),Number(a)}static toDms(t,e="d",a=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===a)switch(e){case"d":case"deg":a=4;break;case"dm":case"deg+min":a=2;break;case"dms":case"deg+min+sec":a=0;break;default:e="d",a=4}t=Math.abs(t);let r=null,n=null,i=null,o=null;switch(e){default:case"d":case"deg":n=t.toFixed(a),n<100&&(n="0"+n),n<10&&(n="0"+n),r=n+"°";break;case"dm":case"deg+min":n=Math.floor(t),i=(60*t%60).toFixed(a),60==i&&(i=(0).toFixed(a),n++),n=("000"+n).slice(-3),i<10&&(i="0"+i),r=n+"°"+h.separator+i+"′";break;case"dms":case"deg+min+sec":n=Math.floor(t),i=Math.floor(3600*t/60)%60,o=(3600*t%60).toFixed(a),60==o&&(o=(0).toFixed(a),i++),60==i&&(i=0,n++),n=("000"+n).slice(-3),i=("00"+i).slice(-2),o<10&&(o="0"+o),r=n+"°"+h.separator+i+"′"+h.separator+o+"″"}return r}static toLat(t,e,a){const r=h.toDms(h.wrap90(t),e,a);return null===r?"–":r.slice(1)+h.separator+(t<0?"S":"N")}static toLon(t,e,a){const r=h.toDms(h.wrap180(t),e,a);return null===r?"–":r+h.separator+(t<0?"W":"E")}static toBrng(t,e,a){const r=h.toDms(h.wrap360(t),e,a);return null===r?"–":r.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(a.thousands,"⁜").replace(a.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",a.decimal).replace("⁜",a.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=h.wrap360(t);const a=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*a/360)%a*16/a]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t,a=360;return 1*Math.abs(((e-90)%a+a)%a-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const u=Math.PI;class c{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=h.wrap90(Number(t)),this._lon=h.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?h.wrap90(h.parse(t)):h.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?h.wrap90(h.parse(t)):h.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,a;if(2==t.length&&([e,a]=t,e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,a]=t[0].split(","),e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const r=t[0];if("Point"==r.type&&Array.isArray(r.coordinates)?[a,e]=r.coordinates:(null!=r.latitude&&(e=r.latitude),null!=r.lat&&(e=r.lat),null!=r.longitude&&(a=r.longitude),null!=r.lng&&(a=r.lng),null!=r.lon&&(a=r.lon),e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a))),isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${t.toString()}’`);return new c(e,a)}distanceTo(t,e=6371e3){if(t instanceof c||(t=c.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const a=e,r=this.lat.toRadians(),n=this.lon.toRadians(),i=t.lat.toRadians(),o=i-r,s=t.lon.toRadians()-n,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return a*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))}initialBearingTo(t){if(t instanceof c||(t=c.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),n=Math.cos(e)*Math.sin(a)-Math.sin(e)*Math.cos(a)*Math.cos(r),i=Math.sin(r)*Math.cos(a),o=Math.atan2(i,n).toDegrees();return h.wrap360(o)}finalBearingTo(t){t instanceof c||(t=c.parse(t));const e=t.initialBearingTo(this)+180;return h.wrap360(e)}midpointTo(t){t instanceof c||(t=c.parse(t));const e=this.lat.toRadians(),a=this.lon.toRadians(),r=t.lat.toRadians(),n=(t.lon-this.lon).toRadians(),i=Math.cos(e),o=0,s=Math.sin(e),l={x:i+Math.cos(r)*Math.cos(n),y:o+Math.cos(r)*Math.sin(n),z:s+Math.sin(r)},h=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),u=a+Math.atan2(l.y,l.x),d=h.toDegrees(),p=u.toDegrees();return new c(d,p)}intermediatePointTo(t,e){if(t instanceof c||(t=c.parse(t)),this.equals(t))return new c(this.lat,this.lon);const a=this.lat.toRadians(),r=this.lon.toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=n-a,s=i-r,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(a)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2),h=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),u=Math.sin((1-e)*h)/Math.sin(h),d=Math.sin(e*h)/Math.sin(h),p=u*Math.cos(a)*Math.cos(r)+d*Math.cos(n)*Math.cos(i),g=u*Math.cos(a)*Math.sin(r)+d*Math.cos(n)*Math.sin(i),f=u*Math.sin(a)+d*Math.sin(n),y=Math.atan2(f,Math.sqrt(p*p+g*g)),m=Math.atan2(g,p),v=y.toDegrees(),M=m.toDegrees();return new c(v,M)}destinationPoint(t,e,a=6371e3){const r=t/a,n=Number(e).toRadians(),i=this.lat.toRadians(),o=this.lon.toRadians(),s=Math.sin(i)*Math.cos(r)+Math.cos(i)*Math.sin(r)*Math.cos(n),l=Math.asin(s),h=Math.sin(n)*Math.sin(r)*Math.cos(i),u=Math.cos(r)-Math.sin(i)*s,d=o+Math.atan2(h,u),p=l.toDegrees(),g=d.toDegrees();return new c(p,g)}static intersection(t,e,a,r){if(t instanceof c||(t=c.parse(t)),a instanceof c||(a=c.parse(a)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(r))throw new TypeError(`invalid brng2 ‘${r}’`);const n=t.lat.toRadians(),i=t.lon.toRadians(),o=a.lat.toRadians(),s=a.lon.toRadians(),l=Number(e).toRadians(),h=Number(r).toRadians(),d=o-n,p=s-i,g=2*Math.asin(Math.sqrt(Math.sin(d/2)*Math.sin(d/2)+Math.cos(n)*Math.cos(o)*Math.sin(p/2)*Math.sin(p/2)));if(Math.abs(g)<Number.EPSILON)return new c(t.lat,t.lon);const f=(Math.sin(o)-Math.sin(n)*Math.cos(g))/(Math.sin(g)*Math.cos(n)),y=(Math.sin(n)-Math.sin(o)*Math.cos(g))/(Math.sin(g)*Math.cos(o)),m=Math.acos(Math.min(Math.max(f,-1),1)),v=Math.acos(Math.min(Math.max(y,-1),1)),M=l-(Math.sin(s-i)>0?m:2*u-m),b=(Math.sin(s-i)>0?2*u-v:v)-h;if(0==Math.sin(M)&&0==Math.sin(b))return null;if(Math.sin(M)*Math.sin(b)<0)return null;const w=-Math.cos(M)*Math.cos(b)+Math.sin(M)*Math.sin(b)*Math.cos(g),x=Math.atan2(Math.sin(g)*Math.sin(M)*Math.sin(b),Math.cos(b)+Math.cos(M)*w),P=Math.asin(Math.min(Math.max(Math.sin(n)*Math.cos(x)+Math.cos(n)*Math.sin(x)*Math.cos(l),-1),1)),N=i+Math.atan2(Math.sin(l)*Math.sin(x)*Math.cos(n),Math.cos(x)-Math.sin(n)*Math.sin(P)),S=P.toDegrees(),E=N.toDegrees();return new c(S,E)}crossTrackDistanceTo(t,e,a=6371e3){t instanceof c||(t=c.parse(t)),e instanceof c||(e=c.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(n)*Math.sin(i-o))*r}alongTrackDistanceTo(t,e,a=6371e3){t instanceof c||(t=c.parse(t)),e instanceof c||(e=c.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians(),s=Math.asin(Math.sin(n)*Math.sin(i-o));return Math.acos(Math.cos(n)/Math.abs(Math.cos(s)))*Math.sign(Math.cos(o-i))*r}maxLatitude(t){const e=Number(t).toRadians(),a=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(a))).toDegrees()}static crossingParallels(t,e,a){if(t.equals(e))return null;const r=Number(a).toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=e.lat.toRadians(),s=e.lon.toRadians()-i,l=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.sin(s),u=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.cos(s)-Math.cos(n)*Math.sin(o)*Math.cos(r),c=Math.cos(n)*Math.cos(o)*Math.sin(r)*Math.sin(s);if(c*c>l*l+u*u)return null;const d=Math.atan2(-u,l),p=Math.acos(c/Math.sqrt(l*l+u*u)),g=i+d+p,f=(i+d-p).toDegrees(),y=g.toDegrees();return{lon1:h.wrap180(f),lon2:h.wrap180(y)}}rhumbDistanceTo(t,e=6371e3){t instanceof c||(t=c.parse(t));const a=e,r=this.lat.toRadians(),n=t.lat.toRadians(),i=n-r;let o=Math.abs(t.lon-this.lon).toRadians();Math.abs(o)>u&&(o=o>0?-(2*u-o):2*u+o);const s=Math.log(Math.tan(n/2+u/4)/Math.tan(r/2+u/4)),l=Math.abs(s)>1e-11?i/s:Math.cos(r);return Math.sqrt(i*i+l*l*o*o)*a}rhumbBearingTo(t){if(t instanceof c||(t=c.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>u&&(r=r>0?-(2*u-r):2*u+r);const n=Math.log(Math.tan(a/2+u/4)/Math.tan(e/2+u/4)),i=Math.atan2(r,n).toDegrees();return h.wrap360(i)}rhumbDestinationPoint(t,e,a=6371e3){const r=this.lat.toRadians(),n=this.lon.toRadians(),i=Number(e).toRadians(),o=t/a,s=o*Math.cos(i);let l=r+s;Math.abs(l)>u/2&&(l=l>0?u-l:-u-l);const h=Math.log(Math.tan(l/2+u/4)/Math.tan(r/2+u/4)),d=Math.abs(h)>1e-11?s/h:Math.cos(r),p=n+o*Math.sin(i)/d,g=l.toDegrees(),f=p.toDegrees();return new c(g,f)}rhumbMidpointTo(t){t instanceof c||(t=c.parse(t));const e=this.lat.toRadians();let a=this.lon.toRadians();const r=t.lat.toRadians(),n=t.lon.toRadians();Math.abs(n-a)>u&&(a+=2*u);const i=(e+r)/2,o=Math.tan(u/4+e/2),s=Math.tan(u/4+r/2),l=Math.tan(u/4+i/2);let h=((n-a)*Math.log(l)+a*Math.log(s)-n*Math.log(o))/Math.log(s/o);isFinite(h)||(h=(a+n)/2);const d=i.toDegrees(),p=h.toDegrees();return new c(d,p)}static areaOf(t,e=6371e3){const a=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const n=t.length-1;let i=0;for(let e=0;e<n;e++){const a=t[e].lat.toRadians(),r=t[e+1].lat.toRadians(),n=(t[e+1].lon-t[e].lon).toRadians();i+=2*Math.atan2(Math.tan(n/2)*(Math.tan(a/2)+Math.tan(r/2)),1+Math.tan(a/2)*Math.tan(r/2))}(function(t){let e=0,a=t[0].initialBearingTo(t[1]);for(let r=0;r<t.length-1;r++){const n=t[r].initialBearingTo(t[r+1]),i=t[r].finalBearingTo(t[r+1]);e+=(n-a+540)%360-180,e+=(i-n+540)%360-180,a=i}const r=t[0].initialBearingTo(t[1]);e+=(r-a+540)%360-180;return Math.abs(e)<90})(t)&&(i=Math.abs(i)-2*u);const o=Math.abs(i*a*a);return r||t.pop(),o}equals(t){return t instanceof c||(t=c.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${h.toLat(this.lat,t,e)}, ${h.toLon(this.lon,t,e)}`}}function d(t,e,a){if(null!==t)for(var r,n,i,o,s,l,h,u,c=0,p=0,g=t.type,f="FeatureCollection"===g,y="Feature"===g,m=f?t.features.length:1,v=0;v<m;v++){s=(u=!!(h=f?t.features[v].geometry:y?t.geometry:t)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var M=0;M<s;M++){var b=0,w=0;if(null!==(o=u?h.geometries[M]:h)){l=o.coordinates;var x=o.type;switch(c=0,x){case null:break;case"Point":if(!1===e(l,p,v,b,w))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],p,v,b,w))return!1;p++,"MultiPoint"===x&&b++}"LineString"===x&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-c;n++){if(!1===e(l[r][n],p,v,b,w))return!1;p++}"MultiLineString"===x&&b++,"Polygon"===x&&w++}"Polygon"===x&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(w=0,n=0;n<l[r].length;n++){for(i=0;i<l[r][n].length-c;i++){if(!1===e(l[r][n][i],p,v,b,w))return!1;p++}w++}b++}break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===d(o.geometries[r],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var p=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const a=[1/0,1/0,-1/0,-1/0];return d(t,t=>{a[0]>t[0]&&(a[0]=t[0]),a[1]>t[1]&&(a[1]=t[1]),a[2]<t[0]&&(a[2]=t[0]),a[3]<t[1]&&(a[3]=t[1])}),a},g=(t,e)=>{var[a,r]=t,[n,i]=e,o=new c(r,a),s=new c(i,n);return o.distanceTo(s)},f=t=>{var e=t/1609.344;if(e<.5)return"".concat(Math.round(t),"m");if(e<10){var a=Number.parseFloat(e.toFixed(1)),r=1===a?"mile":"miles";return"".concat(a," ").concat(r)}var n=Math.round(e);return"".concat(n," miles")},y=(t,e,a)=>{var[r,n]=e,i=a.filter(e=>{var[a,i]=e;return(a!==r||i!==n)&&((t,e,a)=>{switch(t){case"ArrowUp":return a<0&&Math.abs(a)>=Math.abs(e);case"ArrowDown":return a>0&&Math.abs(a)>=Math.abs(e);case"ArrowLeft":return e<0&&Math.abs(e)>Math.abs(a);case"ArrowRight":return e>0&&Math.abs(e)>Math.abs(a);default:return!1}})(t,a-r,i-n)});if(!i.length)return a.findIndex(t=>t[0]===r&&t[1]===n);var o=-1,s=1/0;return i.forEach(t=>{var e=t[0]-r,i=t[1]-n,l=e*e+i*i;l<s&&(s=l,o=a.indexOf(t))}),o},m=t=>p(t);function v(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function M(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?v(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var b="highlighted-label";function w(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var{stops:a}=t;if(a.length<2)return a.length>0?a[0][1]:0;for(var r=a[0],n=a[a.length-1],i=1;i<a.length;i++){var o=a[i];if(o[0]>e){n=o,r=a[i-1];break}r=a[i-1],n=o}var[s,l]=r,[h,u]=n;return e<=s?l:e>=h?u:l+(e-s)/(h-s)*(u-l)}(t,e);var[,,a,...r]=t;if("zoom"!==a[0])throw new Error("Only zoom-based expressions supported");for(var n=0;n<r.length-2;n+=2){var i=r[n],o=r[n+1],s=r[n+2],l=r[n+3];if(e<=i)return o;if(e<=s)return o+(e-i)/(s-i)*(l-o)}return r[r.length-1]}function x(t,e,a){return e.flatMap(e=>{var r,n=function(t){var e,a;return"string"==typeof t?null===(e=/^{(.+)}$/.exec(t))||void 0===e?void 0:e[1]:Array.isArray(t)?null===(a=t.find(t=>Array.isArray(t)&&"get"===t[0]))||void 0===a?void 0:a[1]:null}(null===(r=e.layout)||void 0===r?void 0:r["text-field"]);return n?a.filter(t=>{var a;return t.layer.id===e.id&&(null===(a=t.properties)||void 0===a?void 0:a[n])}).map(a=>function(t,e,a,r){var n=function(t){var{type:e,coordinates:a}=t;if("Point"===e)return a;if("MultiPoint"===e)return a[0];if(e.includes("LineString")){var r="LineString"===e?a:a[0];return[(r[0][0]+r[r.length-1][0])/2,(r[0][1]+r[r.length-1][1])/2]}if(e.includes("Polygon")){var n="Polygon"===e?a[0]:a[0][0],i=n.reduce((t,e)=>[t[0]+e[0],t[1]+e[1]],[0,0]);return[i[0]/n.length,i[1]/n.length]}return null}(t.geometry);if(!n)return null;var i=r.project({lng:n[0],lat:n[1]});return{text:t.properties[a],x:i.x,y:i.y,feature:t,layer:e}}(a,e,n,t)).filter(Boolean):[]})}function P(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function N(t,e,a){var r;if(null!=e&&null!==(r=e.feature)&&void 0!==r&&r.layer){P(t,a);var{feature:n,layer:i}=e;a.highlightLayerId="highlight-".concat(i.id);var{id:o,type:s,properties:l,geometry:h}=n;t.getSource(b).setData({id:o,type:s,properties:l,geometry:h}),a.highlightedExpr=i.layout["text-size"];var u=t.getZoom(),c=function(t,e,a){return{id:"highlight-".concat(t.id),type:t.type,source:b,layout:M(M({},t.layout),{},{"text-size":e,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:M(M({},t.paint),{},{"text-color":a.text,"text-halo-color":a.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})}}(i,1.5*w(a.highlightedExpr,u),a.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});t.addLayer(c),t.moveLayer(a.highlightLayerId)}}function S(t){t.getSource(b)||t.addSource(b,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function E(t){t.getStyle().layers.filter(t=>{var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(e=>t.setLayoutProperty(e.id,"symbol-placement","line-center"))}function L(t,e,a,r){var n={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function i(){var e=t.getStyle().layers.filter(t=>"symbol"===t.type),a=t.queryRenderedFeatures({layers:e.map(t=>t.id)});n.labels=x(t,e,a)}function o(){if(i(),!n.labels.length)return null;var e=t.project(t.getCenter()),a=function(t,e){var a;return null===(a=t.reduce((t,a)=>{var r=(a.x-e.x)**2+(a.y-e.y)**2;return!t||r<t.dist?{label:a,dist:r}:t},null))||void 0===a?void 0:a.label}(n.labels,e);return n.currentPixel={x:a.x,y:a.y},N(t,a,n),"".concat(a.text," (").concat(a.layer.id,")")}return E(t),S(t),null==r||r.on(a.MAP_SET_STYLE,e=>{t.once("styledata",()=>t.once("idle",()=>{E(t),S(t),n.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)}))}),t.on("zoom",()=>{if(n.highlightLayerId&&n.highlightedExpr){var e=w(n.highlightedExpr,t.getZoom());t.setLayoutProperty(n.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(t=>"symbol"===t.type).forEach(e=>{t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:i,highlightNextLabel:function(e){if(i(),!n.labels.length)return null;if(!n.currentPixel)return o();var a=function(t,e){if(!e.currentPixel)return null;var a=e.labels.map((t,e)=>({pixel:[t.x,t.y],index:e})).filter(t=>t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y);if(!a.length)return null;var r=a.map(t=>t.pixel),n=y(t,[e.currentPixel.x,e.currentPixel.y],r);return(null==n||n<0||n>=a.length)&&(n=0),e.labels[a[n].index]}(e,n);return a?(n.currentPixel={x:a.x,y:a.y},N(t,a,n),"".concat(a.text," (").concat(a.layer.id,")")):null},highlightLabelAtCenter:o,clearHighlightedLabel:()=>P(t,n)}}function R(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function O(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?R(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var T="icon-image",I="active-highlight",D="active-highlight-inner",A="selected-highlight",j=(t,e)=>{var a,r;return null!==(a=null===(r=t._activeSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},_=(t,e)=>{var a,r;return null!==(a=null===(r=t._selectedSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},C=(t,e,a,r)=>{e.forEach(e=>{if(!a.has(e)){var n="".concat(r,"-").concat(e);["".concat(n,"-fill"),"".concat(n,"-line"),"".concat(n,"-symbol")].forEach(e=>{t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})},F=(t,e)=>{var a="_".concat(e.replaceAll("-",""),"Sources");C(t,t[a]||new Set,new Set,e),t[a]=new Set},k=(t,e,a,r,n,i,o)=>{t.getLayer(e)||t.addLayer(O(O({id:e,type:a,source:r},n&&{"source-layer":n}),{},{paint:i})),Object.entries(i).forEach(a=>{var[r,n]=a;t.setPaintProperty(e,r,n)}),t.setFilter(e,o),t.moveLayer(e)},B=(t,e,a,r,n,i,o)=>{var s=t.getLayoutProperty(n,T),l=o(t,s);l&&((t,e,a,r,n,i,o)=>{var s;t.getLayer(e)||t.addLayer(O(O({id:e,type:"symbol",source:a},r&&{"source-layer":r}),{},{layout:{[T]:i,"icon-anchor":null!==(s=t.getLayoutProperty(n,"icon-anchor"))&&void 0!==s?s:"center","icon-allow-overlap":!0}})),t.setLayoutProperty(e,T,i),t.setFilter(e,o),t.moveLayer(e)})(t,"".concat(e,"-symbol"),a,r,n,l,i)},z=(t,e,a,r,n,i)=>{var{ids:o,fillIds:s,idProperty:l,layerId:h,hasFillGeometry:u}=a[e],c=t.getLayer(h),d=c.sourceLayer,p=u?"fill":c.type,g="".concat(n,"-").concat(e),{stroke:f,selectionStroke:y,strokeWidth:m,activeStrokeWidth:v,fill:M}=r[h],b=n===A,w=(t=>t===A||t===D)(n),x=w?y:f,P=w?m:v,N=l?["get",l]:["id"],S=["in",N,["literal",[...o]]];if("fill"===p){if(b){var E=["in",N,["literal",[...s]]];k(t,"".concat(g,"-fill"),"fill",e,d,{"fill-color":M},E)}k(t,"".concat(g,"-line"),"line",e,d,{"line-color":x,"line-width":P},S)}"line"===p&&(t.getLayer("".concat(g,"-fill"))&&t.setFilter("".concat(g,"-fill"),["==","id",""]),k(t,"".concat(g,"-line"),"line",e,d,{"line-color":x,"line-width":P},S)),"symbol"===p&&B(t,g,e,d,h,S,i)},q=(t,e,a,r,n)=>{var i=((t,e)=>{var a={};return null==e||e.forEach(e=>{var{featureId:r,layerId:n,idProperty:i,geometry:o}=e,s=t.getLayer(n);if(s){var l=s.source;a[l]||(a[l]={ids:new Set,fillIds:new Set,idProperty:i,layerId:n,hasFillGeometry:!1}),!o||"Polygon"!==o.type&&"MultiPolygon"!==o.type||(a[l].hasFillGeometry=!0,a[l].fillIds.add(r)),a[l].ids.add(r)}}),a})(t,e),o=new Set(Object.keys(i)),s="_".concat(r.replaceAll("-",""),"Sources"),l=t[s]||new Set;return C(t,l,o,r),t[s]=o,o.forEach(e=>z(t,e,i,a,r,n)),i};var $=(t,e,a)=>{var r=(e.x-a.x)**2+(e.y-a.y)**2;if(0===r)return(t.x-e.x)**2+(t.y-e.y)**2;var n=((t.x-e.x)*(a.x-e.x)+(t.y-e.y)*(a.y-e.y))/r;return n=Math.max(0,Math.min(1,n)),(t.x-(e.x+n*(a.x-e.x)))**2+(t.y-(e.y+n*(a.y-e.y)))**2},W=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{radius:r=10}=a,n=[[e.x-r,e.y-r],[e.x+r,e.y+r]],i=t.queryRenderedFeatures(n);if(0===i.length)return[];var o=new Set(t.queryRenderedFeatures([e.x,e.y]).map(t=>{var e,a=void 0===t.id?JSON.stringify(t.properties):t.id;return"".concat(null===(e=t.layer)||void 0===e?void 0:e.source,":").concat(a)})),s=[];i.forEach(t=>{!1===s.includes(t.layer.id)&&s.push(t.layer.id)});for(var l=new Set,h=[],u=i.length-1;u>=0;u--){var c,d=i[u],p=void 0===d.id?JSON.stringify(d.properties):d.id,g="".concat(null===(c=d.layer)||void 0===c?void 0:c.source,":").concat(p);!1===l.has(g)&&(l.add(g),h.push(d))}var f=t.unproject(e),y=[f.lng,f.lat],m=h.filter(t=>{var e=t.geometry.type;if(e.includes("Polygon"))return("Polygon"===e?[t.geometry.coordinates]:t.geometry.coordinates).some(t=>((t,e)=>{for(var[a,r]=t,n=!1,i=0,o=e.length-1;i<e.length;o=i,i++){var[s,l]=e[i],[h,u]=e[o];l>r!=u>r&&a<(h-s)*(r-l)/(u-l)+s&&(n=!n)}return n})(y,t[0]));if("Point"===e||"MultiPoint"===e){var a,r=void 0===t.id?JSON.stringify(t.properties):t.id;return o.has("".concat(null===(a=t.layer)||void 0===a?void 0:a.source,":").concat(r))}return!0});return m.map(a=>{var r=0,n=a.geometry.type,i=((t,e,a)=>{var{coordinates:r,type:n}=a,i=1/0,o=e=>t.project(e),s=t=>{for(var a=0;a<t.length-1;a++){var r=$(e,o(t[a]),o(t[a+1]));r<i&&(i=r)}};if("Point"===n){var l=o(r);i=(e.x-l.x)**2+(e.y-l.y)**2}else"LineString"===n||"MultiPoint"===n?"LineString"===n?s(r):r.forEach(t=>{var a=o(t),r=(e.x-a.x)**2+(e.y-a.y)**2;r<i&&(i=r)}):"Polygon"===n||"MultiLineString"===n?r.forEach(s):"MultiPolygon"===n&&r.forEach(t=>t.forEach(s));return i})(t,e,a.geometry);return r+=1e6*s.indexOf(a.layer.id),n.includes("Polygon")&&(r-=5e5),{f:a,score:r+=i}}).sort((t,e)=>t.score-e.score).map(t=>{var{f:e}=t;return e})},Z=function(){var t=a(function*(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2;e.length&&(t._activeSymbolImageMap={},t._selectedSymbolImageMap={},yield Promise.all(e.flatMap(e=>{var o=n.getSymbolImageId(e,r,!1,i),s=n.getSymbolImageId(e,r,!0,i);return o&&s&&(t._activeSymbolImageMap[o]=s),["normal","active","selected"].map(function(){var l=a(function*(a){var l="active"===a?s:o;if("selected"===a||l&&!t.hasImage(l)){var h=yield n.rasteriseSymbolImage(e,r,a,i);h&&("selected"===a&&o&&(t._selectedSymbolImageMap[o]=h.imageId),t.hasImage(h.imageId)||t.addImage(h.imageId,h.imageData,{pixelRatio:i}))}});return function(t){return l.apply(this,arguments)}}())})))});return function(e,a,r,n){return t.apply(this,arguments)}}(),G=t=>Math.max(2,2*t),H=(t,e)=>{if(!t)return null;if("string"==typeof t)return t.trim();if("object"==typeof t){if(e&&t[e])return t[e];var a=Object.values(t)[0];return null!=a?a:null}return null},V=new Map,J=function(){var t=a(function*(t,e,a,r){var n=a.getPatternInnerContent(t);if(!n)return null;var i=a.getPatternImageId(t,e,r);if(!i)return null;var o,s,l=V.get(i);if(!l){var h=H(t.fillPatternForegroundColor,e)||"black",u=H(t.fillPatternBackgroundColor,e)||"transparent",c=(o=h,s=u,n.replace(/\{\{foregroundColor\}\}/g,o||"black").replace(/\{\{backgroundColor\}\}/g,s||"transparent")),d='<rect width="16" height="16" fill="'.concat(u,'"/>'),p=G(r),g=Math.round(8*p),f='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(g,'" height="').concat(g,'" viewBox="0 0 16 16">').concat(d).concat(c,"</svg>");l=yield((t,e,a)=>new Promise((r,n)=>{var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),o=new Image(e,a);o.onload=()=>{var t=document.createElement("canvas");t.width=e,t.height=a;var n=t.getContext("2d");n.drawImage(o,0,0,e,a),r(n.getImageData(0,0,e,a))},o.onerror=()=>{n(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},o.src=i}))(f,g,g),V.set(i,l)}return{imageId:i,imageData:l}});return function(e,a,r,n){return t.apply(this,arguments)}}(),Y=function(){var t=a(function*(t,e,r,n,i){if(e.length){var o=G(i);yield Promise.all(e.map(function(){var e=a(function*(e){var a=n.getPatternImageId(e,r,i);if(a&&!t.hasImage(a)){var s=yield J(e,r,n,i);s&&t.addImage(s.imageId,s.imageData,{pixelRatio:o})}});return function(t){return e.apply(this,arguments)}}()))}});return function(e,a,r,n,i){return t.apply(this,arguments)}}(),K=["container","padding","mapStyle","mapSize","center","zoom","bounds","pixelRatio"];function U(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function X(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?U(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Q{constructor(t){var{mapFramework:e,mapProviderConfig:a={},events:r,eventBus:n}=t;this.maplibreModule=e,this.events=r,this.eventBus=n,this.capabilities={supportedShortcuts:i,supportsMapSizes:!0},Object.assign(this,a)}initMap(t){var r=this;return a(function*(){var{container:a,padding:n,mapStyle:i,mapSize:o,center:l,zoom:h,bounds:u,pixelRatio:c}=t,d=e(t,K);r.mapStyleId=null==i?void 0:i.id,r.mapSize=o;var{Map:p}=r.maplibreModule,{events:g,eventBus:f}=r,y=new p(X(X({},d),{},{container:a,style:null==i?void 0:i.url,pixelRatio:c,padding:n,center:l,zoom:h,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}));y.touchZoomRotate.disableRotation(),r.map=y,r.map.setPadding(n),u&&y.fitBounds(u,{duration:0}),function(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var a=t.getCanvas();if(a&&(this.target===a||a.contains(this.target)))return}e.call(this)}}(y),function(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block",e.addEventListener("focus",t=>{e.blur(),t.relatedTarget&&t.relatedTarget.focus()})}(y),s({map:y,events:g,eventBus:f,getCenter:r.getCenter.bind(r),getZoom:r.getZoom.bind(r),getBounds:r.getBounds.bind(r),getResolution:r.getResolution.bind(r)}),function(t){var{mapProvider:e,map:a,events:r,eventBus:n}=t,i=t=>{a.once("style.load",()=>{n.emit(r.MAP_STYLE_CHANGE,{mapStyleId:t.id})}),a.setStyle(t.url,{diff:!1})},o=t=>{a.setPixelRatio(t)},s=t=>{var{mapSize:a}=t;e.mapSize=a};n.on(r.MAP_SET_STYLE,i),n.on(r.MAP_SET_PIXEL_RATIO,o),n.on(r.MAP_SIZE_CHANGE,s)}({mapProvider:r,map:y,events:g,eventBus:f}),y.on("load",()=>{r.labelNavigator=L(y,null==i?void 0:i.mapColorScheme,g,f)}),r.eventBus.emit(g.MAP_READY,{map:r.map,mapStyleId:r.mapStyleId,mapSize:r.mapSize,crs:r.crs})})()}destroyMap(){var t,e;this.setHoverCursor([]),null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(t){this.map&&(this._onHoverMove=((t,e,a)=>{var r=t.getCanvas();if(a&&t.off("mousemove",a),null==e||!e.length)return r.style.cursor="",null;var n=a=>{var n=e.filter(e=>t.getLayer(e));if(0!==n.length){var{lineLayers:i,otherLayers:o}=((t,e)=>{var a=[],r=[];for(var n of e)if("line"===t.getLayer(n).type){var i=n.endsWith("-stroke")?n.slice(0,-7):null;null!==i&&e.includes(i)||a.push(n)}else r.push(n);return{lineLayers:a,otherLayers:r}})(t,n),{x:s,y:l}=a.point,h=[[s-10,l-10],[s+10,l+10]],u=i.length>0&&t.queryRenderedFeatures(h,{layers:i}).length>0,c=o.length>0&&t.queryRenderedFeatures(a.point,{layers:o}).length>0;r.style.cursor=u||c?"pointer":""}else r.style.cursor=""};return t.on("mousemove",n),n})(this.map,t,this._onHoverMove))}setView(t){var{center:e,zoom:a}=t;this.map.flyTo({center:e||this.getCenter(),zoom:a||this.getZoom(),duration:this.map.isStyleLoaded()?r:0})}zoomIn(t){this.map.easeTo({zoom:this.getZoom()+t,duration:r})}zoomOut(t){this.map.easeTo({zoom:this.getZoom()-t,duration:r})}panBy(t){this.map.panBy(t,{duration:r})}fitToBounds(t){var e=Array.isArray(t)?t:m(t),a=this.map.isStyleLoaded()?r:0;this.map.fitBounds(e,{duration:a})}setPadding(t){this.map.setPadding(t)}updateHighlightedFeatures(t,e,a){var{LngLatBounds:r}=this.maplibreModule;return function(t){var{LngLatBounds:e,map:a,selectedFeatures:r,activeFeatures:n,stylesMap:i}=t;if(!a)return null;null!=n&&n.length?(q(a,n,i,I,j),q(a,n,i,D,_)):(F(a,I),F(a,D));var o={};null!=r&&r.length?o=q(a,r,i,A,_):F(a,A);var s=[];return Object.entries(o).forEach(t=>{var[,{ids:e,idProperty:r,layerId:n}]=t;s.push(...a.queryRenderedFeatures({layers:[n]}).filter(t=>{var a;return e.has(r?null===(a=t.properties)||void 0===a?void 0:a[r]:t.id)}))}),((t,e)=>{if(!e.length)return null;var a=new t;return e.forEach(t=>{var e=t=>"number"==typeof t[0]?a.extend(t):t.forEach(e);e(t.geometry.coordinates)}),[a.getWest(),a.getSouth(),a.getEast(),a.getNorth()]})(e,s)}({LngLatBounds:r,map:this.map,selectedFeatures:t,activeFeatures:e,stylesMap:a})}highlightNextLabel(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}highlightLabelAtCenter(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}clearHighlightedLabel(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}getCenter(){var t=this.map.getCenter();return[Number(t.lng.toFixed(n)),Number(t.lat.toFixed(n))]}getZoom(){return Number(this.map.getZoom().toFixed(n))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(t,e){return W(this.map,t,e)}getVisibleFeatures(t){var e=t.filter(t=>this.map.getLayer(t));return e.length?this.map.queryRenderedFeatures(void 0,{layers:e}):[]}addSymbolsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return Z(n.map,t,e,r,a)})()}addPatternsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return Y(n.map,t,e,r,a)})()}getAreaDimensions(){var{LngLatBounds:t}=this.maplibreModule;return(t=>{var e,a,r,n;if(t&&"function"==typeof t.getWest)e=t.getWest(),a=t.getSouth(),r=t.getEast(),n=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";[[e,a],[r,n]]=t}var i=g([e,a],[r,a]),o=g([e,a],[e,n]),s=f(i),l=f(o);return"".concat(l," by ").concat(s)})(((t,e)=>{var{width:a,height:r}=e.getContainer().getBoundingClientRect(),n=e.getPadding(),i=[n.left,r-n.bottom],o=[a-n.right,n.top];return new t(e.unproject(i),e.unproject(o))})(t,this.map))}getCardinalMove(t,e){return((t,e)=>{var[a,r]=t,[n,i]=e,o=i-r,s=n-a,l=[];if(Math.abs(o)>1e-4){var h=Math.round(g([a,r],[a,i]));l.push("".concat(o>0?"north":"south"," ").concat(f(h)))}if(Math.abs(s)>1e-4){var u=Math.round(g([a,r],[n,r]));l.push("".concat(s>0?"east":"west"," ").concat(f(u)))}return l.join(", ")})(t,e)}getResolution(){return t=this.map.getCenter(),e=this.map.getZoom(),a=t.lat,r=Math.pow(2,e),40075016.686*Math.cos(a*Math.PI/180)/(512*r);var t,e,a,r}mapToScreen(t){return this.map.project(t)}screenToMap(t){var{lng:e,lat:a}=this.map.unproject([t.x,t.y]);return[e,a]}isGeometryObscured(t,e){return((t,e,a)=>{var r=a.getContainer().getBoundingClientRect(),[n,i,o,s]=m(t),l=[a.project([n,i]),a.project([n,s]),a.project([o,i]),a.project([o,s])],h=Math.min(...l.map(t=>t.x)),u=Math.max(...l.map(t=>t.x)),c=Math.min(...l.map(t=>t.y)),d=Math.max(...l.map(t=>t.y)),p=e.left-r.left,g=e.top-r.top,f=e.right-r.left,y=e.bottom-r.top;return h<f&&u>p&&c<y&&d>g})(t,e,this.map)}}export{Q as default};
1
+ import t from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/objectWithoutProperties";import a from"@babel/runtime/helpers/asyncToGenerator";var r=400,n=7,i=["showKeyboardHelp","selectControl","moveLarge","nudgeMap","zoomLarge","nudgeZoom","highlightLabelAtCenter","highlightNextLabel"];var o=(t,e)=>{var a=null,r=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];clearTimeout(a),a=setTimeout(()=>{t(...n)},e)};return r.cancel=()=>{a&&(clearTimeout(a),a=null)},r};function s(t){var{map:e,events:a,eventBus:r,getCenter:n,getZoom:i,getBounds:s,getResolution:l}=t,h=[],u=[],c=()=>{var t=i();return{center:n(),bounds:s(),resolution:l(),zoom:t,isAtMaxZoom:e.getMaxZoom()<=t,isAtMinZoom:e.getMinZoom()>=t}},d=(t,e)=>r.emit(t,e),p=()=>d(a.MAP_LOADED);e.on("load",p),h.push(["load",p]);e.once("idle",()=>d(a.MAP_FIRST_IDLE,c()));var g=()=>d(a.MAP_MOVE_START);e.on("movestart",g),h.push(["movestart",g]);var f=o(()=>{d(a.MAP_MOVE_END,c())},500);e.on("moveend",f),h.push(["moveend",f]);var y,m,v,M=(y=()=>{d(a.MAP_MOVE,c())},m=10,v=0,function(){var t=Date.now();t-v>=m&&(v=t,y(...arguments))});e.on("zoom",M),h.push(["zoom",M]);var b=()=>d(a.MAP_RENDER);e.on("render",b),h.push(["render",b]);var w=o(()=>{d(a.MAP_DATA_CHANGE,c())},500),x=t=>{t.isSourceLoaded&&w()};e.on("styledata",w),e.on("sourcedata",x),h.push(["styledata",w],["sourcedata",x]);var P=()=>d(a.MAP_STYLE_CHANGE);e.on("style.load",P),h.push(["style.load",P]);var N=t=>d(a.MAP_CLICK,{point:t.point,coords:[t.lngLat.lng,t.lngLat.lat]});return e.on("click",N),h.push(["click",N]),u.push(f,M,w),{remove(){u.forEach(t=>t.cancel()),h.forEach(t=>{var[a,r]=t;return e.off(a,r)})}}}let l=" ";class h{static get separator(){return l}static set separator(t){l=t}static parse(t){if(!isNaN(parseFloat(t))&&isFinite(t))return Number(t);const e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;let a=null;switch(e.length){case 3:a=e[0]/1+e[1]/60+e[2]/3600;break;case 2:a=e[0]/1+e[1]/60;break;case 1:a=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(a=-a),Number(a)}static toDms(t,e="d",a=void 0){if(isNaN(t))return null;if("string"==typeof t&&""==t.trim())return null;if("boolean"==typeof t)return null;if(t==1/0)return null;if(null==t)return null;if(void 0===a)switch(e){case"d":case"deg":a=4;break;case"dm":case"deg+min":a=2;break;case"dms":case"deg+min+sec":a=0;break;default:e="d",a=4}t=Math.abs(t);let r=null,n=null,i=null,o=null;switch(e){default:case"d":case"deg":n=t.toFixed(a),n<100&&(n="0"+n),n<10&&(n="0"+n),r=n+"°";break;case"dm":case"deg+min":n=Math.floor(t),i=(60*t%60).toFixed(a),60==i&&(i=(0).toFixed(a),n++),n=("000"+n).slice(-3),i<10&&(i="0"+i),r=n+"°"+h.separator+i+"′";break;case"dms":case"deg+min+sec":n=Math.floor(t),i=Math.floor(3600*t/60)%60,o=(3600*t%60).toFixed(a),60==o&&(o=(0).toFixed(a),i++),60==i&&(i=0,n++),n=("000"+n).slice(-3),i=("00"+i).slice(-2),o<10&&(o="0"+o),r=n+"°"+h.separator+i+"′"+h.separator+o+"″"}return r}static toLat(t,e,a){const r=h.toDms(h.wrap90(t),e,a);return null===r?"–":r.slice(1)+h.separator+(t<0?"S":"N")}static toLon(t,e,a){const r=h.toDms(h.wrap180(t),e,a);return null===r?"–":r+h.separator+(t<0?"W":"E")}static toBrng(t,e,a){const r=h.toDms(h.wrap360(t),e,a);return null===r?"–":r.replace("360","0")}static fromLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(a.thousands,"⁜").replace(a.decimal,".").replace("⁜",",")}static toLocale(t){const e=123456.789.toLocaleString(),a={thousands:e.slice(3,4),decimal:e.slice(7,8)};return t.replace(/,([0-9])/,"⁜$1").replace(".",a.decimal).replace("⁜",a.thousands)}static compassPoint(t,e=3){if(![1,2,3].includes(Number(e)))throw new RangeError(`invalid precision ‘${e}’`);t=h.wrap360(t);const a=4*2**(e-1);return["N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW"][Math.round(t*a/360)%a*16/a]}static wrap90(t){if(-90<=t&&t<=90)return t;const e=t,a=360;return 1*Math.abs(((e-90)%a+a)%a-180)-90}static wrap180(t){if(-180<=t&&t<=180)return t;const e=360;return((360*t/e-180)%e+e)%e-180}static wrap360(t){if(0<=t&&t<360)return t;const e=360;return(360*t/e%e+e)%e}}Number.prototype.toRadians=function(){return this*Math.PI/180},Number.prototype.toDegrees=function(){return 180*this/Math.PI};const u=Math.PI;class c{constructor(t,e){if(isNaN(t))throw new TypeError(`invalid lat ‘${t}’`);if(isNaN(e))throw new TypeError(`invalid lon ‘${e}’`);this._lat=h.wrap90(Number(t)),this._lon=h.wrap180(Number(e))}get lat(){return this._lat}get latitude(){return this._lat}set lat(t){if(this._lat=isNaN(t)?h.wrap90(h.parse(t)):h.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid lat ‘${t}’`)}set latitude(t){if(this._lat=isNaN(t)?h.wrap90(h.parse(t)):h.wrap90(Number(t)),isNaN(this._lat))throw new TypeError(`invalid latitude ‘${t}’`)}get lon(){return this._lon}get lng(){return this._lon}get longitude(){return this._lon}set lon(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lon ‘${t}’`)}set lng(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid lng ‘${t}’`)}set longitude(t){if(this._lon=isNaN(t)?h.wrap180(h.parse(t)):h.wrap180(Number(t)),isNaN(this._lon))throw new TypeError(`invalid longitude ‘${t}’`)}static get metresToKm(){return.001}static get metresToMiles(){return 1/1609.344}static get metresToNauticalMiles(){return 1/1852}static parse(...t){if(0==t.length)throw new TypeError("invalid (empty) point");if(null===t[0]||null===t[1])throw new TypeError("invalid (null) point");let e,a;if(2==t.length&&([e,a]=t,e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t.toString()}’`);if(1==t.length&&"string"==typeof t[0]&&([e,a]=t[0].split(","),e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a)),isNaN(e)||isNaN(a)))throw new TypeError(`invalid point ‘${t[0]}’`);if(1==t.length&&"object"==typeof t[0]){const r=t[0];if("Point"==r.type&&Array.isArray(r.coordinates)?[a,e]=r.coordinates:(null!=r.latitude&&(e=r.latitude),null!=r.lat&&(e=r.lat),null!=r.longitude&&(a=r.longitude),null!=r.lng&&(a=r.lng),null!=r.lon&&(a=r.lon),e=h.wrap90(h.parse(e)),a=h.wrap180(h.parse(a))),isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${JSON.stringify(t[0])}’`)}if(isNaN(e)||isNaN(a))throw new TypeError(`invalid point ‘${t.toString()}’`);return new c(e,a)}distanceTo(t,e=6371e3){if(t instanceof c||(t=c.parse(t)),isNaN(e))throw new TypeError(`invalid radius ‘${e}’`);const a=e,r=this.lat.toRadians(),n=this.lon.toRadians(),i=t.lat.toRadians(),o=i-r,s=t.lon.toRadians()-n,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(r)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return a*(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)))}initialBearingTo(t){if(t instanceof c||(t=c.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),n=Math.cos(e)*Math.sin(a)-Math.sin(e)*Math.cos(a)*Math.cos(r),i=Math.sin(r)*Math.cos(a),o=Math.atan2(i,n).toDegrees();return h.wrap360(o)}finalBearingTo(t){t instanceof c||(t=c.parse(t));const e=t.initialBearingTo(this)+180;return h.wrap360(e)}midpointTo(t){t instanceof c||(t=c.parse(t));const e=this.lat.toRadians(),a=this.lon.toRadians(),r=t.lat.toRadians(),n=(t.lon-this.lon).toRadians(),i=Math.cos(e),o=0,s=Math.sin(e),l={x:i+Math.cos(r)*Math.cos(n),y:o+Math.cos(r)*Math.sin(n),z:s+Math.sin(r)},h=Math.atan2(l.z,Math.sqrt(l.x*l.x+l.y*l.y)),u=a+Math.atan2(l.y,l.x),d=h.toDegrees(),p=u.toDegrees();return new c(d,p)}intermediatePointTo(t,e){if(t instanceof c||(t=c.parse(t)),this.equals(t))return new c(this.lat,this.lon);const a=this.lat.toRadians(),r=this.lon.toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=n-a,s=i-r,l=Math.sin(o/2)*Math.sin(o/2)+Math.cos(a)*Math.cos(n)*Math.sin(s/2)*Math.sin(s/2),h=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),u=Math.sin((1-e)*h)/Math.sin(h),d=Math.sin(e*h)/Math.sin(h),p=u*Math.cos(a)*Math.cos(r)+d*Math.cos(n)*Math.cos(i),g=u*Math.cos(a)*Math.sin(r)+d*Math.cos(n)*Math.sin(i),f=u*Math.sin(a)+d*Math.sin(n),y=Math.atan2(f,Math.sqrt(p*p+g*g)),m=Math.atan2(g,p),v=y.toDegrees(),M=m.toDegrees();return new c(v,M)}destinationPoint(t,e,a=6371e3){const r=t/a,n=Number(e).toRadians(),i=this.lat.toRadians(),o=this.lon.toRadians(),s=Math.sin(i)*Math.cos(r)+Math.cos(i)*Math.sin(r)*Math.cos(n),l=Math.asin(s),h=Math.sin(n)*Math.sin(r)*Math.cos(i),u=Math.cos(r)-Math.sin(i)*s,d=o+Math.atan2(h,u),p=l.toDegrees(),g=d.toDegrees();return new c(p,g)}static intersection(t,e,a,r){if(t instanceof c||(t=c.parse(t)),a instanceof c||(a=c.parse(a)),isNaN(e))throw new TypeError(`invalid brng1 ‘${e}’`);if(isNaN(r))throw new TypeError(`invalid brng2 ‘${r}’`);const n=t.lat.toRadians(),i=t.lon.toRadians(),o=a.lat.toRadians(),s=a.lon.toRadians(),l=Number(e).toRadians(),h=Number(r).toRadians(),d=o-n,p=s-i,g=2*Math.asin(Math.sqrt(Math.sin(d/2)*Math.sin(d/2)+Math.cos(n)*Math.cos(o)*Math.sin(p/2)*Math.sin(p/2)));if(Math.abs(g)<Number.EPSILON)return new c(t.lat,t.lon);const f=(Math.sin(o)-Math.sin(n)*Math.cos(g))/(Math.sin(g)*Math.cos(n)),y=(Math.sin(n)-Math.sin(o)*Math.cos(g))/(Math.sin(g)*Math.cos(o)),m=Math.acos(Math.min(Math.max(f,-1),1)),v=Math.acos(Math.min(Math.max(y,-1),1)),M=l-(Math.sin(s-i)>0?m:2*u-m),b=(Math.sin(s-i)>0?2*u-v:v)-h;if(0==Math.sin(M)&&0==Math.sin(b))return null;if(Math.sin(M)*Math.sin(b)<0)return null;const w=-Math.cos(M)*Math.cos(b)+Math.sin(M)*Math.sin(b)*Math.cos(g),x=Math.atan2(Math.sin(g)*Math.sin(M)*Math.sin(b),Math.cos(b)+Math.cos(M)*w),P=Math.asin(Math.min(Math.max(Math.sin(n)*Math.cos(x)+Math.cos(n)*Math.sin(x)*Math.cos(l),-1),1)),N=i+Math.atan2(Math.sin(l)*Math.sin(x)*Math.cos(n),Math.cos(x)-Math.sin(n)*Math.sin(P)),S=P.toDegrees(),E=N.toDegrees();return new c(S,E)}crossTrackDistanceTo(t,e,a=6371e3){t instanceof c||(t=c.parse(t)),e instanceof c||(e=c.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians();return Math.asin(Math.sin(n)*Math.sin(i-o))*r}alongTrackDistanceTo(t,e,a=6371e3){t instanceof c||(t=c.parse(t)),e instanceof c||(e=c.parse(e));const r=a;if(this.equals(t))return 0;const n=t.distanceTo(this,r)/r,i=t.initialBearingTo(this).toRadians(),o=t.initialBearingTo(e).toRadians(),s=Math.asin(Math.sin(n)*Math.sin(i-o));return Math.acos(Math.cos(n)/Math.abs(Math.cos(s)))*Math.sign(Math.cos(o-i))*r}maxLatitude(t){const e=Number(t).toRadians(),a=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(a))).toDegrees()}static crossingParallels(t,e,a){if(t.equals(e))return null;const r=Number(a).toRadians(),n=t.lat.toRadians(),i=t.lon.toRadians(),o=e.lat.toRadians(),s=e.lon.toRadians()-i,l=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.sin(s),u=Math.sin(n)*Math.cos(o)*Math.cos(r)*Math.cos(s)-Math.cos(n)*Math.sin(o)*Math.cos(r),c=Math.cos(n)*Math.cos(o)*Math.sin(r)*Math.sin(s);if(c*c>l*l+u*u)return null;const d=Math.atan2(-u,l),p=Math.acos(c/Math.sqrt(l*l+u*u)),g=i+d+p,f=(i+d-p).toDegrees(),y=g.toDegrees();return{lon1:h.wrap180(f),lon2:h.wrap180(y)}}rhumbDistanceTo(t,e=6371e3){t instanceof c||(t=c.parse(t));const a=e,r=this.lat.toRadians(),n=t.lat.toRadians(),i=n-r;let o=Math.abs(t.lon-this.lon).toRadians();Math.abs(o)>u&&(o=o>0?-(2*u-o):2*u+o);const s=Math.log(Math.tan(n/2+u/4)/Math.tan(r/2+u/4)),l=Math.abs(s)>1e-11?i/s:Math.cos(r);return Math.sqrt(i*i+l*l*o*o)*a}rhumbBearingTo(t){if(t instanceof c||(t=c.parse(t)),this.equals(t))return NaN;const e=this.lat.toRadians(),a=t.lat.toRadians();let r=(t.lon-this.lon).toRadians();Math.abs(r)>u&&(r=r>0?-(2*u-r):2*u+r);const n=Math.log(Math.tan(a/2+u/4)/Math.tan(e/2+u/4)),i=Math.atan2(r,n).toDegrees();return h.wrap360(i)}rhumbDestinationPoint(t,e,a=6371e3){const r=this.lat.toRadians(),n=this.lon.toRadians(),i=Number(e).toRadians(),o=t/a,s=o*Math.cos(i);let l=r+s;Math.abs(l)>u/2&&(l=l>0?u-l:-u-l);const h=Math.log(Math.tan(l/2+u/4)/Math.tan(r/2+u/4)),d=Math.abs(h)>1e-11?s/h:Math.cos(r),p=n+o*Math.sin(i)/d,g=l.toDegrees(),f=p.toDegrees();return new c(g,f)}rhumbMidpointTo(t){t instanceof c||(t=c.parse(t));const e=this.lat.toRadians();let a=this.lon.toRadians();const r=t.lat.toRadians(),n=t.lon.toRadians();Math.abs(n-a)>u&&(a+=2*u);const i=(e+r)/2,o=Math.tan(u/4+e/2),s=Math.tan(u/4+r/2),l=Math.tan(u/4+i/2);let h=((n-a)*Math.log(l)+a*Math.log(s)-n*Math.log(o))/Math.log(s/o);isFinite(h)||(h=(a+n)/2);const d=i.toDegrees(),p=h.toDegrees();return new c(d,p)}static areaOf(t,e=6371e3){const a=e,r=t[0].equals(t[t.length-1]);r||t.push(t[0]);const n=t.length-1;let i=0;for(let e=0;e<n;e++){const a=t[e].lat.toRadians(),r=t[e+1].lat.toRadians(),n=(t[e+1].lon-t[e].lon).toRadians();i+=2*Math.atan2(Math.tan(n/2)*(Math.tan(a/2)+Math.tan(r/2)),1+Math.tan(a/2)*Math.tan(r/2))}(function(t){let e=0,a=t[0].initialBearingTo(t[1]);for(let r=0;r<t.length-1;r++){const n=t[r].initialBearingTo(t[r+1]),i=t[r].finalBearingTo(t[r+1]);e+=(n-a+540)%360-180,e+=(i-n+540)%360-180,a=i}const r=t[0].initialBearingTo(t[1]);e+=(r-a+540)%360-180;return Math.abs(e)<90})(t)&&(i=Math.abs(i)-2*u);const o=Math.abs(i*a*a);return r||t.pop(),o}equals(t){return t instanceof c||(t=c.parse(t)),!(Math.abs(this.lat-t.lat)>Number.EPSILON)&&!(Math.abs(this.lon-t.lon)>Number.EPSILON)}toGeoJSON(){return{type:"Point",coordinates:[this.lon,this.lat]}}toString(t="d",e=void 0){if(!["d","dm","dms","n"].includes(t))throw new RangeError(`invalid format ‘${t}’`);if("n"==t)return null==e&&(e=4),`${this.lat.toFixed(e)},${this.lon.toFixed(e)}`;return`${h.toLat(this.lat,t,e)}, ${h.toLon(this.lon,t,e)}`}}function d(t,e,a){if(null!==t)for(var r,n,i,o,s,l,h,u,c=0,p=0,g=t.type,f="FeatureCollection"===g,y="Feature"===g,m=f?t.features.length:1,v=0;v<m;v++){s=(u=!!(h=f?t.features[v].geometry:y?t.geometry:t)&&"GeometryCollection"===h.type)?h.geometries.length:1;for(var M=0;M<s;M++){var b=0,w=0;if(null!==(o=u?h.geometries[M]:h)){l=o.coordinates;var x=o.type;switch(c=0,x){case null:break;case"Point":if(!1===e(l,p,v,b,w))return!1;p++,b++;break;case"LineString":case"MultiPoint":for(r=0;r<l.length;r++){if(!1===e(l[r],p,v,b,w))return!1;p++,"MultiPoint"===x&&b++}"LineString"===x&&b++;break;case"Polygon":case"MultiLineString":for(r=0;r<l.length;r++){for(n=0;n<l[r].length-c;n++){if(!1===e(l[r][n],p,v,b,w))return!1;p++}"MultiLineString"===x&&b++,"Polygon"===x&&w++}"Polygon"===x&&b++;break;case"MultiPolygon":for(r=0;r<l.length;r++){for(w=0,n=0;n<l[r].length;n++){for(i=0;i<l[r][n].length-c;i++){if(!1===e(l[r][n][i],p,v,b,w))return!1;p++}w++}b++}break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(!1===d(o.geometries[r],e))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}var p=function(t,e={}){if(null!=t.bbox&&!0!==e.recompute)return t.bbox;const a=[1/0,1/0,-1/0,-1/0];return d(t,t=>{a[0]>t[0]&&(a[0]=t[0]),a[1]>t[1]&&(a[1]=t[1]),a[2]<t[0]&&(a[2]=t[0]),a[3]<t[1]&&(a[3]=t[1])}),a},g=(t,e)=>{var[a,r]=t,[n,i]=e,o=new c(r,a),s=new c(i,n);return o.distanceTo(s)},f=t=>{var e=t/1609.344;if(e<.5)return"".concat(Math.round(t),"m");if(e<10){var a=Number.parseFloat(e.toFixed(1)),r=1===a?"mile":"miles";return"".concat(a," ").concat(r)}var n=Math.round(e);return"".concat(n," miles")},y=(t,e,a)=>{var[r,n]=e,i=a.filter(e=>{var[a,i]=e;return(a!==r||i!==n)&&((t,e,a)=>{switch(t){case"ArrowUp":return a<0&&Math.abs(a)>=Math.abs(e);case"ArrowDown":return a>0&&Math.abs(a)>=Math.abs(e);case"ArrowLeft":return e<0&&Math.abs(e)>Math.abs(a);case"ArrowRight":return e>0&&Math.abs(e)>Math.abs(a);default:return!1}})(t,a-r,i-n)});if(!i.length)return a.findIndex(t=>t[0]===r&&t[1]===n);var o=-1,s=1/0;return i.forEach(t=>{var e=t[0]-r,i=t[1]-n,l=e*e+i*i;l<s&&(s=l,o=a.indexOf(t))}),o},m=t=>p(t);function v(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function M(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?v(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var b="highlighted-label";function w(t,e){if("number"==typeof t)return t;if(!Array.isArray(t)||"interpolate"!==t[0])return function(t,e){var{stops:a}=t;if(a.length<2)return a.length>0?a[0][1]:0;for(var r=a[0],n=a[a.length-1],i=1;i<a.length;i++){var o=a[i];if(o[0]>e){n=o,r=a[i-1];break}r=a[i-1],n=o}var[s,l]=r,[h,u]=n;return e<=s?l:e>=h?u:l+(e-s)/(h-s)*(u-l)}(t,e);var[,,a,...r]=t;if("zoom"!==a[0])throw new Error("Only zoom-based expressions supported");for(var n=0;n<r.length-2;n+=2){var i=r[n],o=r[n+1],s=r[n+2],l=r[n+3];if(e<=i)return o;if(e<=s)return o+(e-i)/(s-i)*(l-o)}return r[r.length-1]}function x(t,e,a){return e.flatMap(e=>{var r,n=function(t){var e,a;return"string"==typeof t?null===(e=/^{(.+)}$/.exec(t))||void 0===e?void 0:e[1]:Array.isArray(t)?null===(a=t.find(t=>Array.isArray(t)&&"get"===t[0]))||void 0===a?void 0:a[1]:null}(null===(r=e.layout)||void 0===r?void 0:r["text-field"]);return n?a.filter(t=>{var a;return t.layer.id===e.id&&(null===(a=t.properties)||void 0===a?void 0:a[n])}).map(a=>function(t,e,a,r){var n=function(t){var{type:e,coordinates:a}=t;if("Point"===e)return a;if("MultiPoint"===e)return a[0];if(e.includes("LineString")){var r="LineString"===e?a:a[0];return[(r[0][0]+r[r.length-1][0])/2,(r[0][1]+r[r.length-1][1])/2]}if(e.includes("Polygon")){var n="Polygon"===e?a[0]:a[0][0],i=n.reduce((t,e)=>[t[0]+e[0],t[1]+e[1]],[0,0]);return[i[0]/n.length,i[1]/n.length]}return null}(t.geometry);if(!n)return null;var i=r.project({lng:n[0],lat:n[1]});return{text:t.properties[a],x:i.x,y:i.y,feature:t,layer:e}}(a,e,n,t)).filter(Boolean):[]})}function P(t,e){if(e.highlightLayerId&&t.getLayer(e.highlightLayerId)){try{t.removeLayer(e.highlightLayerId)}catch(t){}e.highlightLayerId=null,e.highlightedExpr=null}}function N(t,e,a){var r;if(null!=e&&null!==(r=e.feature)&&void 0!==r&&r.layer){P(t,a);var{feature:n,layer:i}=e;a.highlightLayerId="highlight-".concat(i.id);var{id:o,type:s,properties:l,geometry:h}=n;t.getSource(b).setData({id:o,type:s,properties:l,geometry:h}),a.highlightedExpr=i.layout["text-size"];var u=t.getZoom(),c=function(t,e,a){return{id:"highlight-".concat(t.id),type:t.type,source:b,layout:M(M({},t.layout),{},{"text-size":e,"text-allow-overlap":!0,"text-ignore-placement":!0,"text-max-angle":90}),paint:M(M({},t.paint),{},{"text-color":a.text,"text-halo-color":a.halo,"text-halo-width":3,"text-halo-blur":1,"text-opacity":1})}}(i,1.5*w(a.highlightedExpr,u),a.isDarkStyle?{text:"#ffffff",halo:"#000000"}:{text:"#000000",halo:"#ffffff"});t.addLayer(c),t.moveLayer(a.highlightLayerId)}}function S(t){t.getSource(b)||t.addSource(b,{type:"geojson",data:{type:"FeatureCollection",features:[]}})}function E(t){t.getStyle().layers.filter(t=>{var e;return"line"===(null===(e=t.layout)||void 0===e?void 0:e["symbol-placement"])}).forEach(e=>t.setLayoutProperty(e.id,"symbol-placement","line-center"))}function L(t,e,a,r){var n={isDarkStyle:"dark"===e,labels:[],currentPixel:null,highlightLayerId:null,highlightedExpr:null};function i(){var e=t.getStyle().layers.filter(t=>"symbol"===t.type),a=t.queryRenderedFeatures({layers:e.map(t=>t.id)});n.labels=x(t,e,a)}function o(){if(i(),!n.labels.length)return null;var e=t.project(t.getCenter()),a=function(t,e){var a;return null===(a=t.reduce((t,a)=>{var r=(a.x-e.x)**2+(a.y-e.y)**2;return!t||r<t.dist?{label:a,dist:r}:t},null))||void 0===a?void 0:a.label}(n.labels,e);return n.currentPixel={x:a.x,y:a.y},N(t,a,n),"".concat(a.text," (").concat(a.layer.id,")")}return E(t),S(t),null==r||r.on(a.MAP_SET_STYLE,e=>{t.once("styledata",()=>t.once("idle",()=>{E(t),S(t),n.isDarkStyle="dark"===(null==e?void 0:e.mapColorScheme)}))}),t.on("zoom",()=>{if(n.highlightLayerId&&n.highlightedExpr){var e=w(n.highlightedExpr,t.getZoom());t.setLayoutProperty(n.highlightLayerId,"text-size",1.5*e)}}),function(t){t.getStyle().layers.filter(t=>"symbol"===t.type).forEach(e=>{t.setPaintProperty(e.id,"text-opacity",["case",["boolean",["feature-state","highlighted"],!1],0,1])})}(t),{refreshLabels:i,highlightNextLabel:function(e){if(i(),!n.labels.length)return null;if(!n.currentPixel)return o();var a=function(t,e){if(!e.currentPixel)return null;var a=e.labels.map((t,e)=>({pixel:[t.x,t.y],index:e})).filter(t=>t.pixel[0]!==e.currentPixel.x||t.pixel[1]!==e.currentPixel.y);if(!a.length)return null;var r=a.map(t=>t.pixel),n=y(t,[e.currentPixel.x,e.currentPixel.y],r);return(null==n||n<0||n>=a.length)&&(n=0),e.labels[a[n].index]}(e,n);return a?(n.currentPixel={x:a.x,y:a.y},N(t,a,n),"".concat(a.text," (").concat(a.layer.id,")")):null},highlightLabelAtCenter:o,clearHighlightedLabel:()=>P(t,n)}}function R(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function O(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?R(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var T="icon-image",I="active-highlight",D="active-highlight-inner",j="selected-highlight",A=(t,e)=>{var a,r;return null!==(a=null===(r=t._activeSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},_=(t,e)=>{var a,r;return null!==(a=null===(r=t._selectedSymbolImageMap)||void 0===r?void 0:r[e])&&void 0!==a?a:null},C=(t,e,a,r)=>{e.forEach(e=>{if(!a.has(e)){var n="".concat(r,"-").concat(e);["".concat(n,"-fill"),"".concat(n,"-line"),"".concat(n,"-symbol")].forEach(e=>{t.getLayer(e)&&t.setFilter(e,["==","id",""])})}})},F=(t,e)=>{var a="_".concat(e.replaceAll("-",""),"Sources");C(t,t[a]||new Set,new Set,e),t[a]=new Set},k=(t,e,a,r,n,i,o)=>{t.getLayer(e)||t.addLayer(O(O({id:e,type:a,source:r},n&&{"source-layer":n}),{},{paint:i})),Object.entries(i).forEach(a=>{var[r,n]=a;t.setPaintProperty(e,r,n)}),t.setFilter(e,o),t.moveLayer(e)},B=(t,e,a,r,n,i,o)=>{var s=t.getLayoutProperty(n,T),l=o(t,s);l&&((t,e,a,r,n,i,o)=>{var s;t.getLayer(e)||t.addLayer(O(O({id:e,type:"symbol",source:a},r&&{"source-layer":r}),{},{layout:{[T]:i,"icon-anchor":null!==(s=t.getLayoutProperty(n,"icon-anchor"))&&void 0!==s?s:"center","icon-allow-overlap":!0}})),t.setLayoutProperty(e,T,i),t.setFilter(e,o),t.moveLayer(e)})(t,"".concat(e,"-symbol"),a,r,n,l,i)},z=(t,e,a,r,n,i)=>{var{ids:o,fillIds:s,idProperty:l,layerId:h,hasFillGeometry:u}=a[e],c=t.getLayer(h),d=c.sourceLayer,p=u?"fill":c.type,g="".concat(n,"-").concat(e),f=r[h];if(f){var{stroke:y,selectionStroke:m,strokeWidth:v,activeStrokeWidth:M,fill:b}=f,w=n===j,x=(t=>t===j||t===D)(n),P=x?m:y,N=x?v:M,S=l?["get",l]:["id"],E=["in",S,["literal",[...o]]];"fill"===p&&((t,e,a,r,n)=>{var{isSelected:i,idExpression:o,fillIds:s,fill:l,lineColor:h,lineWidth:u,filter:c}=n;if(i){var d=["in",o,["literal",[...s]]];k(t,"".concat(e,"-fill"),"fill",a,r,{"fill-color":l},d)}k(t,"".concat(e,"-line"),"line",a,r,{"line-color":h,"line-width":u},c)})(t,g,e,d,{isSelected:w,idExpression:S,fillIds:s,fill:b,lineColor:P,lineWidth:N,filter:E}),"line"===p&&(t.getLayer("".concat(g,"-fill"))&&t.setFilter("".concat(g,"-fill"),["==","id",""]),k(t,"".concat(g,"-line"),"line",e,d,{"line-color":P,"line-width":N},E)),"symbol"===p&&B(t,g,e,d,h,E,i)}},q=(t,e,a,r,n)=>{var i=((t,e)=>{var a={};return null==e||e.forEach(e=>{var{featureId:r,layerId:n,idProperty:i,geometry:o}=e,s=t.getLayer(n);if(s){var l=s.source;a[l]||(a[l]={ids:new Set,fillIds:new Set,idProperty:i,layerId:n,hasFillGeometry:!1}),!o||"Polygon"!==o.type&&"MultiPolygon"!==o.type||(a[l].hasFillGeometry=!0,a[l].fillIds.add(r)),a[l].ids.add(r)}}),a})(t,e),o=new Set(Object.keys(i)),s="_".concat(r.replaceAll("-",""),"Sources"),l=t[s]||new Set;return C(t,l,o,r),t[s]=o,o.forEach(e=>z(t,e,i,a,r,n)),i};var $=(t,e,a)=>{var r=(e.x-a.x)**2+(e.y-a.y)**2;if(0===r)return(t.x-e.x)**2+(t.y-e.y)**2;var n=((t.x-e.x)*(a.x-e.x)+(t.y-e.y)*(a.y-e.y))/r;return n=Math.max(0,Math.min(1,n)),(t.x-(e.x+n*(a.x-e.x)))**2+(t.y-(e.y+n*(a.y-e.y)))**2},W=function(t,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{radius:r=10}=a,n=[[e.x-r,e.y-r],[e.x+r,e.y+r]],i=t.queryRenderedFeatures(n);if(0===i.length)return[];var o=new Set(t.queryRenderedFeatures([e.x,e.y]).map(t=>{var e,a=void 0===t.id?JSON.stringify(t.properties):t.id;return"".concat(null===(e=t.layer)||void 0===e?void 0:e.source,":").concat(a)})),s=[];i.forEach(t=>{!1===s.includes(t.layer.id)&&s.push(t.layer.id)});for(var l=new Set,h=[],u=i.length-1;u>=0;u--){var c,d=i[u],p=void 0===d.id?JSON.stringify(d.properties):d.id,g="".concat(null===(c=d.layer)||void 0===c?void 0:c.source,":").concat(p);!1===l.has(g)&&(l.add(g),h.push(d))}var f=t.unproject(e),y=[f.lng,f.lat],m=h.filter(t=>{var e=t.geometry.type;if(e.includes("Polygon"))return("Polygon"===e?[t.geometry.coordinates]:t.geometry.coordinates).some(t=>((t,e)=>{for(var[a,r]=t,n=!1,i=0,o=e.length-1;i<e.length;o=i,i++){var[s,l]=e[i],[h,u]=e[o];l>r!=u>r&&a<(h-s)*(r-l)/(u-l)+s&&(n=!n)}return n})(y,t[0]));if("Point"===e||"MultiPoint"===e){var a,r=void 0===t.id?JSON.stringify(t.properties):t.id;return o.has("".concat(null===(a=t.layer)||void 0===a?void 0:a.source,":").concat(r))}return!0});return m.map(a=>{var r=0,n=a.geometry.type,i=((t,e,a)=>{var{coordinates:r,type:n}=a,i=1/0,o=e=>t.project(e),s=t=>{for(var a=0;a<t.length-1;a++){var r=$(e,o(t[a]),o(t[a+1]));r<i&&(i=r)}};if("Point"===n){var l=o(r);i=(e.x-l.x)**2+(e.y-l.y)**2}else"LineString"===n||"MultiPoint"===n?"LineString"===n?s(r):r.forEach(t=>{var a=o(t),r=(e.x-a.x)**2+(e.y-a.y)**2;r<i&&(i=r)}):"Polygon"===n||"MultiLineString"===n?r.forEach(s):"MultiPolygon"===n&&r.forEach(t=>t.forEach(s));return i})(t,e,a.geometry);return r+=1e6*s.indexOf(a.layer.id),n.includes("Polygon")&&(r-=5e5),{f:a,score:r+=i}}).sort((t,e)=>t.score-e.score).map(t=>{var{f:e}=t;return e})},Z=function(){var t=a(function*(t,e,r,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:2;e.length&&(t._activeSymbolImageMap={},t._selectedSymbolImageMap={},yield Promise.all(e.flatMap(e=>{var o=n.getSymbolImageId(e,r,!1,i),s=n.getSymbolImageId(e,r,!0,i);return o&&s&&(t._activeSymbolImageMap[o]=s),["normal","active","selected"].map(function(){var l=a(function*(a){var l="active"===a?s:o;if("selected"===a||l&&!t.hasImage(l)){var h=yield n.rasteriseSymbolImage(e,r,a,i);h&&("selected"===a&&o&&(t._selectedSymbolImageMap[o]=h.imageId),t.hasImage(h.imageId)||t.addImage(h.imageId,h.imageData,{pixelRatio:i}))}});return function(t){return l.apply(this,arguments)}}())})))});return function(e,a,r,n){return t.apply(this,arguments)}}(),G=t=>Math.max(2,2*t),H=(t,e)=>{if(!t)return null;if("string"==typeof t)return t.trim();if("object"==typeof t){if(e&&t[e])return t[e];var a=Object.values(t)[0];return null!=a?a:null}return null},V=new Map,J=function(){var t=a(function*(t,e,a,r){var n=a.getPatternInnerContent(t);if(!n)return null;var i=a.getPatternImageId(t,e,r);if(!i)return null;var o,s,l=V.get(i);if(!l){var h=H(t.fillPatternForegroundColor,e)||"black",u=H(t.fillPatternBackgroundColor,e)||"transparent",c=(o=h,s=u,n.replace(/\{\{foregroundColor\}\}/g,o||"black").replace(/\{\{backgroundColor\}\}/g,s||"transparent")),d='<rect width="16" height="16" fill="'.concat(u,'"/>'),p=G(r),g=Math.round(8*p),f='<svg xmlns="http://www.w3.org/2000/svg" width="'.concat(g,'" height="').concat(g,'" viewBox="0 0 16 16">').concat(d).concat(c,"</svg>");l=yield((t,e,a)=>new Promise((r,n)=>{var i="data:image/svg+xml;charset=utf-8,".concat(encodeURIComponent(t)),o=new Image(e,a);o.onload=()=>{var t=document.createElement("canvas");t.width=e,t.height=a;var n=t.getContext("2d");n.drawImage(o,0,0,e,a),r(n.getImageData(0,0,e,a))},o.onerror=()=>{n(new Error("Failed to rasterise SVG: ".concat(t.slice(0,80))))},o.src=i}))(f,g,g),V.set(i,l)}return{imageId:i,imageData:l}});return function(e,a,r,n){return t.apply(this,arguments)}}(),Y=function(){var t=a(function*(t,e,r,n,i){if(e.length){var o=G(i),s=e.reduce((e,s)=>{var l=n.getPatternImageId(s,r,i);return!l||e[l]||t.hasImage(l)||(e[l]=a(function*(){var e=yield J(s,r,n,i);e&&t.addImage(e.imageId,e.imageData,{pixelRatio:o})})),e},{});yield Promise.all(Object.values(s).map(t=>t()))}});return function(e,a,r,n,i){return t.apply(this,arguments)}}(),K=["container","padding","mapStyle","mapSize","center","zoom","bounds","pixelRatio"];function U(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),a.push.apply(a,r)}return a}function X(e){for(var a=1;a<arguments.length;a++){var r=null!=arguments[a]?arguments[a]:{};a%2?U(Object(r),!0).forEach(function(a){t(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}class Q{constructor(t){var{mapFramework:e,mapProviderConfig:a={},events:r,eventBus:n}=t;this.maplibreModule=e,this.events=r,this.eventBus=n,this.capabilities={supportedShortcuts:i,supportsMapSizes:!0},Object.assign(this,a)}initMap(t){var r=this;return a(function*(){var{container:a,padding:n,mapStyle:i,mapSize:o,center:l,zoom:h,bounds:u,pixelRatio:c}=t,d=e(t,K);r.mapStyleId=null==i?void 0:i.id,r.mapSize=o;var{Map:p}=r.maplibreModule,{events:g,eventBus:f}=r,y=new p(X(X({},d),{},{container:a,style:null==i?void 0:i.url,pixelRatio:c,padding:n,center:l,zoom:h,fadeDuration:0,attributionControl:!1,dragRotate:!1,doubleClickZoom:!1}));y.touchZoomRotate.disableRotation(),r.map=y,r.map.setPadding(n),u&&y.fitBounds(u,{duration:0}),function(t){var e=Event.prototype.preventDefault;Event.prototype.preventDefault=function(){if(("touchmove"===this.type||"touchstart"===this.type)&&!this.cancelable){var a=t.getCanvas();if(a&&(this.target===a||a.contains(this.target)))return}e.call(this)}}(y),function(t){var e=t.getCanvas();e.removeAttribute("role"),e.setAttribute("tabindex",-1),e.removeAttribute("aria-label"),e.style.display="block",e.addEventListener("focus",t=>{e.blur(),t.relatedTarget&&t.relatedTarget.focus()})}(y),s({map:y,events:g,eventBus:f,getCenter:r.getCenter.bind(r),getZoom:r.getZoom.bind(r),getBounds:r.getBounds.bind(r),getResolution:r.getResolution.bind(r)}),function(t){var{mapProvider:e,map:a,events:r,eventBus:n}=t,i=t=>{a.once("style.load",()=>{n.emit(r.MAP_STYLE_CHANGE,{mapStyleId:t.id})}),a.setStyle(t.url,{diff:!1})},o=t=>{a.setPixelRatio(t)},s=t=>{var{mapSize:a}=t;e.mapSize=a};n.on(r.MAP_SET_STYLE,i),n.on(r.MAP_SET_PIXEL_RATIO,o),n.on(r.MAP_SIZE_CHANGE,s)}({mapProvider:r,map:y,events:g,eventBus:f}),y.on("load",()=>{r.labelNavigator=L(y,null==i?void 0:i.mapColorScheme,g,f)}),r.eventBus.emit(g.MAP_READY,{map:r.map,mapStyleId:r.mapStyleId,mapSize:r.mapSize,crs:r.crs})})()}destroyMap(){var t,e;this.setHoverCursor([]),null===(t=this.mapEvents)||void 0===t||t.remove(),null===(e=this.appEvents)||void 0===e||e.remove(),this.mapEvents=null,this.appEvents=null,this.map.remove()}setHoverCursor(t){this.map&&(this._onHoverMove=((t,e,a)=>{var r=t.getCanvas();if(a&&t.off("mousemove",a),null==e||!e.length)return r.style.cursor="",null;var n=a=>{var n=e.filter(e=>t.getLayer(e));if(0!==n.length){var{lineLayers:i,otherLayers:o}=((t,e)=>{var a=[],r=[];for(var n of e)if("line"===t.getLayer(n).type){var i=n.endsWith("-stroke")?n.slice(0,-7):null;null!==i&&e.includes(i)||a.push(n)}else r.push(n);return{lineLayers:a,otherLayers:r}})(t,n),{x:s,y:l}=a.point,h=[[s-10,l-10],[s+10,l+10]],u=i.length>0&&t.queryRenderedFeatures(h,{layers:i}).length>0,c=o.length>0&&t.queryRenderedFeatures(a.point,{layers:o}).length>0;r.style.cursor=u||c?"pointer":""}else r.style.cursor=""};return t.on("mousemove",n),n})(this.map,t,this._onHoverMove))}setView(t){var{center:e,zoom:a}=t;this.map.flyTo({center:e||this.getCenter(),zoom:a||this.getZoom(),duration:this.map.isStyleLoaded()?r:0})}zoomIn(t){this.map.easeTo({zoom:this.getZoom()+t,duration:r})}zoomOut(t){this.map.easeTo({zoom:this.getZoom()-t,duration:r})}panBy(t){this.map.panBy(t,{duration:r})}fitToBounds(t){var e=Array.isArray(t)?t:m(t),a=this.map.isStyleLoaded()?r:0;this.map.fitBounds(e,{duration:a})}setPadding(t){this.map.setPadding(t)}updateHighlightedFeatures(t,e,a){var{LngLatBounds:r}=this.maplibreModule;return function(t){var{LngLatBounds:e,map:a,selectedFeatures:r,activeFeatures:n,stylesMap:i}=t;if(!a)return null;null!=n&&n.length?(q(a,n,i,I,A),q(a,n,i,D,_)):(F(a,I),F(a,D));var o={};null!=r&&r.length?o=q(a,r,i,j,_):F(a,j);var s=[];return Object.entries(o).forEach(t=>{var[,{ids:e,idProperty:r,layerId:n}]=t;s.push(...a.queryRenderedFeatures({layers:[n]}).filter(t=>{var a;return e.has(r?null===(a=t.properties)||void 0===a?void 0:a[r]:t.id)}))}),((t,e)=>{if(!e.length)return null;var a=new t;return e.forEach(t=>{var e=t=>"number"==typeof t[0]?a.extend(t):t.forEach(e);e(t.geometry.coordinates)}),[a.getWest(),a.getSouth(),a.getEast(),a.getNorth()]})(e,s)}({LngLatBounds:r,map:this.map,selectedFeatures:t,activeFeatures:e,stylesMap:a})}highlightNextLabel(t){var e;return(null===(e=this.labelNavigator)||void 0===e?void 0:e.highlightNextLabel(t))||null}highlightLabelAtCenter(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.highlightLabelAtCenter())||null}clearHighlightedLabel(){var t;return(null===(t=this.labelNavigator)||void 0===t?void 0:t.clearHighlightedLabel())||null}getCenter(){var t=this.map.getCenter();return[Number(t.lng.toFixed(n)),Number(t.lat.toFixed(n))]}getZoom(){return Number(this.map.getZoom().toFixed(n))}getBounds(){return this.map.getBounds().toArray().flat(1)}getFeaturesAtPoint(t,e){return W(this.map,t,e)}getVisibleFeatures(t){var e=t.filter(t=>this.map.getLayer(t));return e.length?this.map.queryRenderedFeatures(void 0,{layers:e}):[]}addSymbolsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return Z(n.map,t,e,r,a)})()}addPatternsToMap(t,e,r){var n=this;return a(function*(){var a=n.map.getPixelRatio()||1;return Y(n.map,t,e,r,a)})()}getAreaDimensions(){var{LngLatBounds:t}=this.maplibreModule;return(t=>{var e,a,r,n;if(t&&"function"==typeof t.getWest)e=t.getWest(),a=t.getSouth(),r=t.getEast(),n=t.getNorth();else{if(!Array.isArray(t)||2!==t.length)return"";[[e,a],[r,n]]=t}var i=g([e,a],[r,a]),o=g([e,a],[e,n]),s=f(i),l=f(o);return"".concat(l," by ").concat(s)})(((t,e)=>{var{width:a,height:r}=e.getContainer().getBoundingClientRect(),n=e.getPadding(),i=[n.left,r-n.bottom],o=[a-n.right,n.top];return new t(e.unproject(i),e.unproject(o))})(t,this.map))}getCardinalMove(t,e){return((t,e)=>{var[a,r]=t,[n,i]=e,o=i-r,s=n-a,l=[];if(Math.abs(o)>1e-4){var h=Math.round(g([a,r],[a,i]));l.push("".concat(o>0?"north":"south"," ").concat(f(h)))}if(Math.abs(s)>1e-4){var u=Math.round(g([a,r],[n,r]));l.push("".concat(s>0?"east":"west"," ").concat(f(u)))}return l.join(", ")})(t,e)}getResolution(){return t=this.map.getCenter(),e=this.map.getZoom(),a=t.lat,r=Math.pow(2,e),40075016.686*Math.cos(a*Math.PI/180)/(512*r);var t,e,a,r}mapToScreen(t){return this.map.project(t)}screenToMap(t){var{lng:e,lat:a}=this.map.unproject([t.x,t.y]);return[e,a]}isGeometryObscured(t,e){return((t,e,a)=>{var r=a.getContainer().getBoundingClientRect(),[n,i,o,s]=m(t),l=[a.project([n,i]),a.project([n,s]),a.project([o,i]),a.project([o,s])],h=Math.min(...l.map(t=>t.x)),u=Math.max(...l.map(t=>t.x)),c=Math.min(...l.map(t=>t.y)),d=Math.max(...l.map(t=>t.y)),p=e.left-r.left,g=e.top-r.top,f=e.right-r.left,y=e.bottom-r.top;return h<f&&u>p&&c<y&&d>g})(t,e,this.map)}}export{Q as default};