@defra/interactive-map 0.0.24-alpha → 0.0.26-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.
@@ -98,8 +98,10 @@ describe('isGeometryObscured', () => {
98
98
  const point = { type: 'Feature', geometry: { type: 'Point', coordinates: [-1, 51] } }
99
99
  const panel = { left: 0, top: 0, right: 100, bottom: 100 }
100
100
 
101
- const makeMap = (pixelFn) => ({
102
- getTargetElement: () => ({ getBoundingClientRect: () => ({ left: 0, top: 0 }) }),
101
+ const containerRect = { left: 0, top: 0, width: 1000, height: 1000 }
102
+ const makeMap = (pixelFn, viewportRect = containerRect) => ({
103
+ getTargetElement: () => ({ getBoundingClientRect: () => containerRect }),
104
+ getViewport: () => ({ getBoundingClientRect: () => viewportRect }),
103
105
  getPixelFromCoordinate: pixelFn
104
106
  })
105
107
 
@@ -0,0 +1,133 @@
1
+ import XYZ from 'ol/source/XYZ.js'
2
+ import VectorTileSource from 'ol/source/VectorTile.js'
3
+ import VectorTileLayer from 'ol/layer/VectorTile.js'
4
+ import OGCVectorTile from 'ol/source/OGCVectorTile.js'
5
+ import MVT from 'ol/format/MVT.js'
6
+ import TileGrid from 'ol/tilegrid/TileGrid.js'
7
+ import TileState from 'ol/TileState.js'
8
+ import { stylefunction } from 'ol-mapbox-style'
9
+ import { TILE_GRID_RESOLUTIONS, TILE_GRID_ORIGIN, TILE_SIZE } from '../defaults.js'
10
+
11
+ const CRS = 'EPSG:27700'
12
+
13
+ export function fetchWithTransform (url, resourceType, transformRequest) {
14
+ const result = transformRequest ? (transformRequest(url, resourceType) || {}) : {}
15
+ return fetch(result.url || url, { headers: result.headers || {} })
16
+ }
17
+
18
+ const createTileLoadFunction = (transformRequest) => (tile, src) => {
19
+ const result = transformRequest(src, 'Tile') || {}
20
+ const url = result.url || src
21
+ const headers = result.headers || {}
22
+ fetch(url, { headers })
23
+ .then(r => r.blob())
24
+ .then(blob => { tile.getImage().src = URL.createObjectURL(blob) })
25
+ .catch(() => tile.setState(TileState.ERROR))
26
+ }
27
+
28
+ export function createTileSource (url, transformRequest) {
29
+ const tileGrid = new TileGrid({
30
+ resolutions: TILE_GRID_RESOLUTIONS,
31
+ origin: TILE_GRID_ORIGIN,
32
+ tileSize: TILE_SIZE
33
+ })
34
+
35
+ const tileUrlFunction = ([z, x, y]) => url
36
+ .replace('{z}', z)
37
+ .replace('{x}', x)
38
+ .replace('{y}', y)
39
+
40
+ return new XYZ({
41
+ projection: CRS,
42
+ tileGrid,
43
+ tileUrlFunction,
44
+ tileLoadFunction: transformRequest ? createTileLoadFunction(transformRequest) : undefined
45
+ })
46
+ }
47
+
48
+ // Insert extension before any query string to match Mapbox GL sprite convention
49
+ function resolveSprite (spriteBase, transformRequest) {
50
+ const queryIdx = spriteBase.indexOf('?')
51
+ const [spritePath, spriteQuery] = queryIdx >= 0 ? [spriteBase.slice(0, queryIdx), spriteBase.slice(queryIdx)] : [spriteBase, '']
52
+ const jsonUrl = `${spritePath}.json${spriteQuery}`
53
+ const pngUrl = `${spritePath}.png${spriteQuery}`
54
+ return { jsonUrl, pngUrl, fetch: () => fetchWithTransform(jsonUrl, 'SpriteJSON', transformRequest).then(r => r.json()) }
55
+ }
56
+
57
+ // The OS VTS styles are designed to work with the limited ArcGIS/ESRI SDK, which does not support
58
+ // icon-color for sprite tinting. OS works around this by setting icon-color alpha to 0 (a no-op
59
+ // in the ESRI renderer) so the sprite renders as-is. ol-mapbox-style interprets the colour
60
+ // literally though, making icons invisible. Fix by setting alpha to 1 (opaque tint).
61
+ function fixIconOpacity (styleJson) {
62
+ styleJson.layers.forEach(styleLayer => {
63
+ if (styleLayer.paint?.['icon-color']) {
64
+ styleLayer.paint['icon-color'] = styleLayer.paint['icon-color'].replace(',0)', ',1)')
65
+ }
66
+ })
67
+ }
68
+
69
+ export async function createVectorTileLayer (url, transformRequest, { renderMode } = {}) {
70
+ const styleJson = await fetchWithTransform(url, 'Style', transformRequest).then(r => r.json())
71
+
72
+ const sourceId = Object.keys(styleJson.sources)[0]
73
+ const capabilitiesUrl = styleJson.sources[sourceId].url
74
+ const serviceJson = await fetchWithTransform(capabilitiesUrl, 'Source', transformRequest).then(r => r.json())
75
+
76
+ const extent = [serviceJson.fullExtent.xmin, serviceJson.fullExtent.ymin, serviceJson.fullExtent.xmax, serviceJson.fullExtent.ymax]
77
+ const origin = [serviceJson.tileInfo.origin.x, serviceJson.tileInfo.origin.y]
78
+ const resolutions = serviceJson.tileInfo.lods.map(l => l.resolution).slice(0, 16)
79
+ const tileSize = serviceJson.tileInfo.rows
80
+ const tileUrl = serviceJson.tiles[0]
81
+
82
+ const sprite = resolveSprite(styleJson.sprite, transformRequest)
83
+ const spritesJson = await sprite.fetch()
84
+
85
+ fixIconOpacity(styleJson)
86
+
87
+ const tileGrid = new TileGrid({ extent, origin, resolutions, tileSize })
88
+
89
+ // Tile URL from capabilities already includes the API key — no custom tileLoadFunction needed
90
+ const source = new VectorTileSource({
91
+ format: new MVT(),
92
+ url: tileUrl,
93
+ projection: CRS,
94
+ tileGrid
95
+ })
96
+ const layer = new VectorTileLayer({ source, declutter: true, ...(renderMode && { renderMode }) })
97
+
98
+ stylefunction(layer, styleJson, sourceId, resolutions, spritesJson, sprite.pngUrl)
99
+
100
+ return { layer, source }
101
+ }
102
+
103
+ export async function createOGCVectorTileLayer (url, transformRequest, { renderMode } = {}) {
104
+ const styleJson = await fetchWithTransform(url, 'Style', transformRequest).then(r => r.json())
105
+
106
+ const sourceId = Object.keys(styleJson.sources)[0]
107
+ const tilesUrl = styleJson.sources[sourceId].url
108
+
109
+ // Fetch tileset descriptor to get the tile matrix set URL (includes API key), in parallel with sprites
110
+ const sprite = resolveSprite(styleJson.sprite, transformRequest)
111
+ const tilesetJson = await fetchWithTransform(tilesUrl, 'Source', transformRequest).then(r => r.json())
112
+ const tmsLink = tilesetJson.links?.find(l => l.rel === 'http://www.opengis.net/def/rel/ogc/1.0/tiling-scheme')
113
+ const [tmsJson, spritesJson] = await Promise.all([
114
+ fetchWithTransform(tmsLink.href, 'Source', transformRequest).then(r => r.json()),
115
+ sprite.fetch()
116
+ ])
117
+
118
+ const resolutions = tmsJson.tileMatrices.map(m => m.cellSize)
119
+ const origin = tmsJson.tileMatrices[0].pointOfOrigin
120
+ const tileSize = [tmsJson.tileMatrices[0].tileHeight, tmsJson.tileMatrices[0].tileWidth]
121
+
122
+ // OS NGD returns tiles as 'application/octet-stream' rather than the standard MVT media type
123
+ const format = new MVT()
124
+ format.supportedMediaTypes.push('application/octet-stream')
125
+
126
+ const tileGrid = new TileGrid({ resolutions, origin, tileSize })
127
+ const source = new OGCVectorTile({ url: tilesUrl, format, tileGrid, projection: CRS })
128
+ const layer = new VectorTileLayer({ source, declutter: true, ...(renderMode && { renderMode }) })
129
+
130
+ stylefunction(layer, styleJson, sourceId, resolutions, spritesJson, sprite.pngUrl)
131
+
132
+ return { layer, source }
133
+ }
@@ -0,0 +1,256 @@
1
+ import XYZ from 'ol/source/XYZ.js'
2
+ import TileGrid from 'ol/tilegrid/TileGrid.js'
3
+ import VectorTileSource from 'ol/source/VectorTile.js'
4
+ import VectorTileLayer from 'ol/layer/VectorTile.js'
5
+ import { stylefunction } from 'ol-mapbox-style'
6
+ import { createTileSource, createVectorTileLayer } from './tileLayers.js'
7
+ import { TILE_GRID_RESOLUTIONS, TILE_GRID_ORIGIN, TILE_SIZE } from '../defaults.js'
8
+
9
+ const mockTileGridInstance = {}
10
+ const mockSourceInstance = {}
11
+ const mockVectorTileSourceInstance = {}
12
+ const mockVectorTileLayerInstance = {}
13
+ const mockMVTInstance = {}
14
+
15
+ jest.mock('ol/source/XYZ.js', () => ({ __esModule: true, default: jest.fn(() => mockSourceInstance) }))
16
+ jest.mock('ol/tilegrid/TileGrid.js', () => ({ __esModule: true, default: jest.fn(() => mockTileGridInstance) }))
17
+ jest.mock('ol/TileState.js', () => ({ __esModule: true, default: { ERROR: 'error' } }))
18
+ jest.mock('ol/source/VectorTile.js', () => ({ __esModule: true, default: jest.fn(() => mockVectorTileSourceInstance) }))
19
+ jest.mock('ol/layer/VectorTile.js', () => ({ __esModule: true, default: jest.fn(() => mockVectorTileLayerInstance) }))
20
+ jest.mock('ol/format/MVT.js', () => ({ __esModule: true, default: jest.fn(() => mockMVTInstance) }))
21
+ jest.mock('ol-mapbox-style', () => ({ __esModule: true, stylefunction: jest.fn() }))
22
+
23
+ const flushPromises = () => new Promise(resolve => setTimeout(resolve, 0))
24
+
25
+ const mockStyleJson = {
26
+ sources: { esri: { url: 'https://example.com/caps.json' } },
27
+ sprite: 'https://example.com/sprites/sprite',
28
+ layers: []
29
+ }
30
+
31
+ const mockServiceJson = {
32
+ fullExtent: { xmin: -238375, ymin: 0, xmax: 700000, ymax: 1300000 },
33
+ tileInfo: {
34
+ origin: { x: -238375, y: 1376256 },
35
+ lods: Array.from({ length: 20 }, (_, i) => ({ resolution: 896 / Math.pow(2, i) })),
36
+ rows: 256,
37
+ spatialReference: { latestWkid: 27700 }
38
+ },
39
+ tiles: ['https://example.com/tiles/{z}/{x}/{y}.pbf']
40
+ }
41
+
42
+ const mockSpritesJson = { myIcon: { x: 0, y: 0, width: 16, height: 16, pixelRatio: 1 } }
43
+
44
+ function makeVectorFetchMock (styleJson = mockStyleJson) {
45
+ return jest.fn().mockImplementation(url => {
46
+ if (url === styleJson.sources[Object.keys(styleJson.sources)[0]].url) {
47
+ return Promise.resolve({ json: () => Promise.resolve(mockServiceJson) })
48
+ }
49
+ if (url.endsWith('.json') || url.includes('.json?')) {
50
+ return Promise.resolve({ json: () => Promise.resolve(mockSpritesJson) })
51
+ }
52
+ return Promise.resolve({ json: () => Promise.resolve(styleJson) })
53
+ })
54
+ }
55
+
56
+ describe('createTileSource', () => {
57
+ beforeEach(() => jest.clearAllMocks())
58
+
59
+ it('creates TileGrid with correct OS tile grid config', () => {
60
+ createTileSource('https://tiles.example.com/{z}/{x}/{y}', null)
61
+ expect(TileGrid).toHaveBeenCalledWith({
62
+ resolutions: TILE_GRID_RESOLUTIONS,
63
+ origin: TILE_GRID_ORIGIN,
64
+ tileSize: TILE_SIZE
65
+ })
66
+ })
67
+
68
+ it('creates XYZ source with EPSG:27700 projection', () => {
69
+ createTileSource('https://tiles.example.com/{z}/{x}/{y}', null)
70
+ expect(XYZ).toHaveBeenCalledWith(expect.objectContaining({ projection: 'EPSG:27700' }))
71
+ })
72
+
73
+ it('tileUrlFunction substitutes z, x, y into url template', () => {
74
+ createTileSource('https://tiles.example.com/{z}/{x}/{y}', null)
75
+ const { tileUrlFunction } = XYZ.mock.calls[0][0]
76
+ expect(tileUrlFunction([7, 3, 5])).toBe('https://tiles.example.com/7/3/5')
77
+ })
78
+
79
+ it('does not set tileLoadFunction when transformRequest is null', () => {
80
+ createTileSource('https://tiles.example.com/{z}/{x}/{y}', null)
81
+ const { tileLoadFunction } = XYZ.mock.calls[0][0]
82
+ expect(tileLoadFunction).toBeUndefined()
83
+ })
84
+
85
+ it('sets tileLoadFunction when transformRequest is provided', () => {
86
+ createTileSource('https://tiles.example.com/{z}/{x}/{y}', jest.fn())
87
+ const { tileLoadFunction } = XYZ.mock.calls[0][0]
88
+ expect(typeof tileLoadFunction).toBe('function')
89
+ })
90
+ })
91
+
92
+ describe('tileLoadFunction (via transformRequest)', () => {
93
+ const url = 'https://tiles.example.com/7/3/5'
94
+ const mockImg = { src: null }
95
+ const mockTile = { getImage: () => mockImg, setState: jest.fn() }
96
+
97
+ beforeEach(() => {
98
+ jest.clearAllMocks()
99
+ mockImg.src = null
100
+ global.URL.createObjectURL = jest.fn(() => 'blob:test')
101
+ global.fetch = jest.fn().mockResolvedValue({
102
+ blob: () => Promise.resolve(new Blob())
103
+ })
104
+ })
105
+
106
+ function getTileLoadFn (transformRequest) {
107
+ createTileSource('https://tiles.example.com/{z}/{x}/{y}', transformRequest)
108
+ return XYZ.mock.calls[0][0].tileLoadFunction
109
+ }
110
+
111
+ it('calls transformRequest with src and "Tile" resource type', async () => {
112
+ const transformRequest = jest.fn(() => null)
113
+ const fn = getTileLoadFn(transformRequest)
114
+ fn(mockTile, url)
115
+ expect(transformRequest).toHaveBeenCalledWith(url, 'Tile')
116
+ })
117
+
118
+ it('uses url and headers from transformRequest result', async () => {
119
+ const transformRequest = jest.fn(() => ({ url: 'https://proxied.example.com/tile', headers: { Authorization: 'Bearer abc' } }))
120
+ const fn = getTileLoadFn(transformRequest)
121
+ fn(mockTile, url)
122
+ await flushPromises()
123
+ expect(fetch).toHaveBeenCalledWith('https://proxied.example.com/tile', { headers: { Authorization: 'Bearer abc' } })
124
+ })
125
+
126
+ it('falls back to original src and empty headers when transformRequest returns null', async () => {
127
+ const fn = getTileLoadFn(() => null)
128
+ fn(mockTile, url)
129
+ await flushPromises()
130
+ expect(fetch).toHaveBeenCalledWith(url, { headers: {} })
131
+ })
132
+
133
+ it('sets tile image src via createObjectURL on success', async () => {
134
+ const fn = getTileLoadFn(() => null)
135
+ fn(mockTile, url)
136
+ await flushPromises()
137
+ expect(mockImg.src).toBe('blob:test')
138
+ })
139
+
140
+ it('sets tile state to ERROR on fetch failure', async () => {
141
+ global.fetch = jest.fn().mockRejectedValue(new Error('network error'))
142
+ const fn = getTileLoadFn(() => null)
143
+ fn(mockTile, url)
144
+ await flushPromises()
145
+ expect(mockTile.setState).toHaveBeenCalledWith('error')
146
+ })
147
+ })
148
+
149
+ describe('createVectorTileLayer', () => {
150
+ const styleUrl = 'https://example.com/styles'
151
+
152
+ beforeEach(() => {
153
+ jest.clearAllMocks()
154
+ global.fetch = makeVectorFetchMock()
155
+ })
156
+
157
+ it('fetches style JSON from url', async () => {
158
+ await createVectorTileLayer(styleUrl, null)
159
+ expect(fetch).toHaveBeenCalledWith(styleUrl, { headers: {} })
160
+ })
161
+
162
+ it('fetches capabilities from first source url in style JSON', async () => {
163
+ await createVectorTileLayer(styleUrl, null)
164
+ expect(fetch).toHaveBeenCalledWith('https://example.com/caps.json', { headers: {} })
165
+ })
166
+
167
+ it('fetches sprite JSON from sprite base + .json', async () => {
168
+ await createVectorTileLayer(styleUrl, null)
169
+ expect(fetch).toHaveBeenCalledWith('https://example.com/sprites/sprite.json', { headers: {} })
170
+ })
171
+
172
+ it('creates TileGrid from capabilities tileInfo', async () => {
173
+ await createVectorTileLayer(styleUrl, null)
174
+ expect(TileGrid).toHaveBeenCalledWith({
175
+ extent: [-238375, 0, 700000, 1300000],
176
+ origin: [-238375, 1376256],
177
+ resolutions: expect.any(Array),
178
+ tileSize: 256
179
+ })
180
+ })
181
+
182
+ it('slices capabilities lods to max 16 resolutions', async () => {
183
+ await createVectorTileLayer(styleUrl, null)
184
+ const { resolutions } = TileGrid.mock.calls[0][0]
185
+ expect(resolutions.length).toBe(16)
186
+ })
187
+
188
+ it('creates VectorTileSource with MVT format and 27700 projection', async () => {
189
+ await createVectorTileLayer(styleUrl, null)
190
+ expect(VectorTileSource).toHaveBeenCalledWith(expect.objectContaining({
191
+ format: mockMVTInstance,
192
+ url: 'https://example.com/tiles/{z}/{x}/{y}.pbf',
193
+ projection: 'EPSG:27700',
194
+ tileGrid: mockTileGridInstance
195
+ }))
196
+ })
197
+
198
+ it('does not set tileLoadFunction on VectorTileSource', async () => {
199
+ await createVectorTileLayer(styleUrl, null)
200
+ const { tileLoadFunction } = VectorTileSource.mock.calls[0][0]
201
+ expect(tileLoadFunction).toBeUndefined()
202
+ })
203
+
204
+ it('creates VectorTileLayer with source and declutter true', async () => {
205
+ await createVectorTileLayer(styleUrl, null)
206
+ expect(VectorTileLayer).toHaveBeenCalledWith({ source: mockVectorTileSourceInstance, declutter: true })
207
+ })
208
+
209
+ it('passes renderMode to VectorTileLayer when provided', async () => {
210
+ await createVectorTileLayer(styleUrl, null, { renderMode: 'vector' })
211
+ expect(VectorTileLayer).toHaveBeenCalledWith(expect.objectContaining({ renderMode: 'vector' }))
212
+ })
213
+
214
+ it('applies stylefunction with layer, styleJson, sourceId, resolutions, spritesJson, spritesPngUrl', async () => {
215
+ await createVectorTileLayer(styleUrl, null)
216
+ expect(stylefunction).toHaveBeenCalledWith(
217
+ mockVectorTileLayerInstance,
218
+ mockStyleJson,
219
+ 'esri',
220
+ expect.any(Array),
221
+ mockSpritesJson,
222
+ 'https://example.com/sprites/sprite.png'
223
+ )
224
+ })
225
+
226
+ it('returns the constructed layer and source', async () => {
227
+ const result = await createVectorTileLayer(styleUrl, null)
228
+ expect(result.layer).toBe(mockVectorTileLayerInstance)
229
+ expect(result.source).toBe(mockVectorTileSourceInstance)
230
+ })
231
+
232
+ it('inserts sprite extension before query string when sprite URL has one', async () => {
233
+ const styleWithQuery = { ...mockStyleJson, sprite: 'https://example.com/sprites/sprite?key=abc123' }
234
+ global.fetch = makeVectorFetchMock(styleWithQuery)
235
+ await createVectorTileLayer(styleUrl, null)
236
+ expect(fetch).toHaveBeenCalledWith('https://example.com/sprites/sprite.json?key=abc123', { headers: {} })
237
+ expect(stylefunction).toHaveBeenCalledWith(
238
+ expect.anything(), expect.anything(), expect.anything(), expect.anything(), expect.anything(),
239
+ 'https://example.com/sprites/sprite.png?key=abc123'
240
+ )
241
+ })
242
+
243
+ it('passes transformRequest result url and headers to each fetch', async () => {
244
+ const transformRequest = jest.fn((url) => ({
245
+ url: url + '&auth=1',
246
+ headers: { Authorization: 'Bearer token' }
247
+ }))
248
+ global.fetch = jest.fn().mockImplementation(url => {
249
+ if (url.includes('caps.json')) { return Promise.resolve({ json: () => Promise.resolve(mockServiceJson) }) }
250
+ if (url.includes('.json')) { return Promise.resolve({ json: () => Promise.resolve(mockSpritesJson) }) }
251
+ return Promise.resolve({ json: () => Promise.resolve(mockStyleJson) })
252
+ })
253
+ await createVectorTileLayer(styleUrl, transformRequest)
254
+ expect(fetch).toHaveBeenCalledWith(styleUrl + '&auth=1', { headers: { Authorization: 'Bearer token' } })
255
+ })
256
+ })
@@ -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",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};
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({preventScroll:!0})})}(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};