@edugis-org/webmapx 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +149 -0
  2. package/dist-lib/WMTS-DCN4zX0-.js +1169 -0
  3. package/dist-lib/alert-GeHlqlN8.js +310 -0
  4. package/dist-lib/assets/epsg-lookup.worker-J7TVnHDq.js +1 -0
  5. package/dist-lib/assets/shapefile.worker-kQfZj6G2.js +4 -0
  6. package/dist-lib/attribution-format-B4f05_u0.js +62 -0
  7. package/dist-lib/button-DFdGkRPQ.js +741 -0
  8. package/dist-lib/cesium-adapter-BHXNytkU.js +1488 -0
  9. package/dist-lib/checkbox-QoR4S8tV.js +284 -0
  10. package/dist-lib/chunk-HEgqtunE.js +20 -0
  11. package/dist-lib/chunk.36O46B5H-B6ZL7Sm1.js +77 -0
  12. package/dist-lib/chunk.3RPBFEDE-BFO1fHVm.js +138 -0
  13. package/dist-lib/chunk.5JY5FUCG-DTXsslmx.js +1090 -0
  14. package/dist-lib/chunk.6CTB5ZDJ-DjZrBd6Y.js +99 -0
  15. package/dist-lib/chunk.AJ3ENQ5C-Ci7Gm2b6.js +175 -0
  16. package/dist-lib/chunk.LD4M4QGE-CiCfhE8r.js +8 -0
  17. package/dist-lib/chunk.NYIIDP5N-BikXIStD.js +99 -0
  18. package/dist-lib/chunk.RWUUFNUL-DFztA4uV.js +43 -0
  19. package/dist-lib/chunk.SI4ACBFK-CLb9VfMG.js +61 -0
  20. package/dist-lib/chunk.YHLNUJ7P-D-kanrCf.js +503 -0
  21. package/dist-lib/core-CMAlSR68.js +22 -0
  22. package/dist-lib/decorate-CWgUV1hU.js +1139 -0
  23. package/dist-lib/decorators-B35AgiCU.js +351 -0
  24. package/dist-lib/deferred-query-service-BJDcngw6.js +386 -0
  25. package/dist-lib/dist-Dm6b7XCs.js +12318 -0
  26. package/dist-lib/dist-Ha9LQCut.js +244 -0
  27. package/dist-lib/dist-c1PlDAd1.js +2359 -0
  28. package/dist-lib/dist-kKlmcBXq.js +50 -0
  29. package/dist-lib/divider-CPm675yY.js +41 -0
  30. package/dist-lib/dropped-config-C_GyVa8o.js +17 -0
  31. package/dist-lib/dropped-layer-builder-DAaYgUPk.js +396 -0
  32. package/dist-lib/epsg-definitions-BZLZWa8Q.js +668 -0
  33. package/dist-lib/esm-CTuscnN5.js +46 -0
  34. package/dist-lib/file-sniff-Dhxj3KTF.js +251 -0
  35. package/dist-lib/geo-calculations-DbFJAUoI.js +30 -0
  36. package/dist-lib/icon-CEOgWlro.js +9 -0
  37. package/dist-lib/icon-button-Da_nBTy3.js +408 -0
  38. package/dist-lib/input-CeGntPlT.js +590 -0
  39. package/dist-lib/layer-discovery-afWzu5hY.js +2825 -0
  40. package/dist-lib/leaflet-adapter-D9djjrKv.js +1227 -0
  41. package/dist-lib/lib-CdHVicAE.js +4074 -0
  42. package/dist-lib/map-layer-registry-2cmkiRDK.js +62 -0
  43. package/dist-lib/maplibre-adapter-TFc3e0G9.js +1190 -0
  44. package/dist-lib/maplibre-expression-evaluator-DCWUcpwf.js +7233 -0
  45. package/dist-lib/marker-utils-DztWXeop.js +12 -0
  46. package/dist-lib/ol-tilegrid-9VtyxaLG.js +64 -0
  47. package/dist-lib/openlayers-adapter-DVW1KCRv.js +13307 -0
  48. package/dist-lib/option-CBxl1mZP.js +1106 -0
  49. package/dist-lib/papaparse.min-B7v3c0D7.js +501 -0
  50. package/dist-lib/rbush-C8k41T4z.js +254 -0
  51. package/dist-lib/shapefile-SawVY6xg.js +207 -0
  52. package/dist-lib/spinner-DysxdNG9.js +6 -0
  53. package/dist-lib/src-CL94RDe3.js +111 -0
  54. package/dist-lib/throttle-BeneRNYK.js +16 -0
  55. package/dist-lib/toast-Cm28o9U6.js +15 -0
  56. package/dist-lib/togeojson.es-DAgiTBvg.js +579 -0
  57. package/dist-lib/tooltip-Cucn1SiD.js +197 -0
  58. package/dist-lib/webmapx-3d-tool-D4CTD2gB.js +176 -0
  59. package/dist-lib/webmapx-base-tool-Dm9NAWLD.js +75 -0
  60. package/dist-lib/webmapx-config-edit-tool-DCTyxqTk.js +389 -0
  61. package/dist-lib/webmapx-coordinates-tool-jeWohup9.js +648 -0
  62. package/dist-lib/webmapx-core-bundle-BDImi1RE.js +8203 -0
  63. package/dist-lib/webmapx-draw-tool-DooAV8cF.js +4336 -0
  64. package/dist-lib/webmapx-geolocation-tool-Rw3-Iad1.js +788 -0
  65. package/dist-lib/webmapx-import-layer-tool-DRYviHd5.js +250 -0
  66. package/dist-lib/webmapx-info-tool-BJA157cy.js +412 -0
  67. package/dist-lib/webmapx-language-osmvector-M5y_lwOg.js +489 -0
  68. package/dist-lib/webmapx-measure-tool-BXhMJFC6.js +590 -0
  69. package/dist-lib/webmapx-modal-tool-eF6Naluv.js +84 -0
  70. package/dist-lib/webmapx-plugin-tool-D2Hghf9n.js +45 -0
  71. package/dist-lib/webmapx-print-tool-ob1bOsR5.js +348 -0
  72. package/dist-lib/webmapx-search-tool-Cv8BrYvY.js +437 -0
  73. package/dist-lib/webmapx-settings-DDEJ8aoV.js +479 -0
  74. package/dist-lib/webmapx-truearea-tool-CMB4Orm-.js +615 -0
  75. package/dist-lib/webmapx-view-mode-tool-CUpLNjOj.js +106 -0
  76. package/dist-lib/webmapx.css +2 -0
  77. package/dist-lib/webmapx.js +1321 -0
  78. package/dist-lib/wms-feature-info-C0RVMEQC.js +145 -0
  79. package/dist-lib/wms-url-builder-DIJLQ1v2.js +54 -0
  80. package/dist-lib/zip.js-DVhmtjxZ.js +3615 -0
  81. package/package.json +107 -0
  82. package/public/data/country-epsg-codes.json +297 -0
  83. package/public/data/world-countries-simplified.topojson +1 -0
  84. package/src/locales/en/core.json +20 -0
@@ -0,0 +1,1190 @@
1
+ import { t as e } from "./wms-url-builder-DIJLQ1v2.js";
2
+ import { t } from "./wms-feature-info-C0RVMEQC.js";
3
+ import { a as n, i as r, n as i, o as a, t as o } from "./deferred-query-service-BJDcngw6.js";
4
+ import * as s from "maplibre-gl";
5
+ //#region src/map/maplibre-services/MapCoreService.ts
6
+ function c(e) {
7
+ return "sourceId" in e;
8
+ }
9
+ var l = class e {
10
+ constructor(e, t) {
11
+ this.store = e, this.eventBus = t, this.mapInstance = null, this.mapReadyCallbacks = [], this.lastContainerId = null, this.lastInitOptions = void 0, this.silentSourceIds = /* @__PURE__ */ new Set(), this.geoJSONData = /* @__PURE__ */ new Map(), this.initialConfig = {
12
+ center: [10.45, 51.17],
13
+ zoom: 4,
14
+ pitch: 0,
15
+ bearing: 0,
16
+ style: {
17
+ version: 8,
18
+ sources: {},
19
+ layers: []
20
+ }
21
+ };
22
+ }
23
+ getViewportState() {
24
+ return this.mapInstance ? {
25
+ center: this.mapInstance.getCenter().toArray(),
26
+ zoom: this.mapInstance.getZoom(),
27
+ bearing: this.mapInstance.getBearing(),
28
+ pitch: this.mapInstance.getPitch()
29
+ } : {
30
+ center: [0, 0],
31
+ zoom: 1,
32
+ bearing: 0,
33
+ pitch: 0
34
+ };
35
+ }
36
+ setViewport(e, t) {
37
+ this.mapInstance && this.mapInstance.flyTo({
38
+ center: e,
39
+ zoom: t
40
+ });
41
+ }
42
+ initialize(e, t) {
43
+ console.log(`[CORE SERVICE] Initializing MapLibre instance in #${e}`), this.lastContainerId = e, this.lastInitOptions = t;
44
+ let n = t?.center ?? this.initialConfig.center, r = t?.zoom ?? this.initialConfig.zoom, i = this.resolveContainer(e), a = t?.projection ? { projection: { type: t.projection } } : {}, o;
45
+ o = t?.style ? {
46
+ version: 8,
47
+ sources: t.style.sources || {},
48
+ layers: t.style.layers || [],
49
+ ...t.style.glyphs && { glyphs: t.style.glyphs },
50
+ ...t.style.sprite && { sprite: t.style.sprite },
51
+ ...t.style.name && { name: t.style.name },
52
+ ...a
53
+ } : t?.styleUrl ? t.styleUrl : {
54
+ ...this.initialConfig.style,
55
+ ...a
56
+ }, this.mapInstance = new s.Map({
57
+ container: i,
58
+ center: n,
59
+ zoom: r,
60
+ minZoom: t?.minZoom,
61
+ maxZoom: t?.maxZoom,
62
+ minPitch: t?.minPitch,
63
+ maxPitch: t?.maxPitch,
64
+ pitch: t?.pitch ?? this.initialConfig.pitch,
65
+ bearing: t?.bearing ?? this.initialConfig.bearing,
66
+ attributionControl: !1,
67
+ style: o
68
+ }), this.flushMapReadyCallbacks();
69
+ let l = this.mapInstance.getCanvasContainer();
70
+ l && (l.tabIndex = -1), this.mapInstance.on("load", () => {
71
+ let e = this.buildViewportFeature();
72
+ this.store.dispatch({
73
+ mapLoaded: !0,
74
+ zoomLevel: r,
75
+ mapCenter: n,
76
+ mapViewportBounds: e
77
+ }, "MAP"), this.applyGlobeFog();
78
+ }), this.mapInstance.on("dataloading", (e) => {
79
+ c(e) && e.sourceId && this.silentSourceIds.has(e.sourceId) || this.store.dispatch({ mapBusy: !0 }, "MAP");
80
+ }), this.mapInstance.on("idle", () => {
81
+ this.store.dispatch({ mapBusy: !1 }, "MAP");
82
+ }), this.mapInstance.on("zoomend", () => {
83
+ let e = this.mapInstance.getZoom(), t = this.buildViewportFeature();
84
+ this.store.dispatch({
85
+ zoomLevel: e,
86
+ mapViewportBounds: t
87
+ }, "MAP"), this.eventBus?.emit({
88
+ type: "zoom-end",
89
+ zoom: e
90
+ });
91
+ }), this.mapInstance.on("moveend", () => {
92
+ let e = this.mapInstance.getCenter().toArray(), t = this.mapInstance.getZoom(), n = this.buildViewportFeature();
93
+ this.store.dispatch({
94
+ mapCenter: e,
95
+ zoomLevel: t,
96
+ mapViewportBounds: n
97
+ }, "MAP"), this.emitViewChangeEnd();
98
+ }), this.mapInstance.on("move", () => {
99
+ this.dispatchViewportBoundsSnapshot(), this.emitViewChange();
100
+ }), this.attachPointerEvents(this.mapInstance);
101
+ }
102
+ attachPointerEvents(e) {
103
+ e.on("mousemove", (e) => {
104
+ let t = [e.lngLat.lng, e.lngLat.lat], n = [e.point.x, e.point.y], r = this.computePointerResolution(e);
105
+ this.eventBus?.emit({
106
+ type: "pointer-move",
107
+ coords: t,
108
+ pixel: n,
109
+ resolution: r,
110
+ originalEvent: e.originalEvent
111
+ }), this.store.dispatch({
112
+ pointerCoordinates: t,
113
+ pointerResolution: r
114
+ }, "MAP");
115
+ }), e.on("mousedown", (e) => {
116
+ let t = [e.lngLat.lng, e.lngLat.lat], n = [e.point.x, e.point.y];
117
+ this.eventBus?.emit({
118
+ type: "pointer-down",
119
+ coords: t,
120
+ pixel: n,
121
+ button: e.originalEvent.button,
122
+ originalEvent: e.originalEvent
123
+ });
124
+ }), e.on("mouseup", (e) => {
125
+ let t = [e.lngLat.lng, e.lngLat.lat], n = [e.point.x, e.point.y];
126
+ this.eventBus?.emit({
127
+ type: "pointer-up",
128
+ coords: t,
129
+ pixel: n,
130
+ button: e.originalEvent.button,
131
+ originalEvent: e.originalEvent
132
+ });
133
+ });
134
+ let t = e.getCanvas();
135
+ t.addEventListener("pointerdown", (n) => {
136
+ if (n.pointerType === "mouse") return;
137
+ let r = t.getBoundingClientRect(), i = [n.clientX - r.left, n.clientY - r.top], a = e.unproject(i), o = [a.lng, a.lat];
138
+ this.eventBus?.emit({
139
+ type: "pointer-down",
140
+ coords: o,
141
+ pixel: i,
142
+ button: 0,
143
+ originalEvent: n
144
+ });
145
+ }), t.addEventListener("pointermove", (n) => {
146
+ if (n.pointerType === "mouse") return;
147
+ let r = t.getBoundingClientRect(), i = [n.clientX - r.left, n.clientY - r.top], a = e.unproject(i), o = [a.lng, a.lat];
148
+ this.eventBus?.emit({
149
+ type: "pointer-move",
150
+ coords: o,
151
+ pixel: i,
152
+ resolution: null,
153
+ originalEvent: n
154
+ });
155
+ }), t.addEventListener("pointerup", (n) => {
156
+ if (n.pointerType === "mouse") return;
157
+ let r = t.getBoundingClientRect(), i = [n.clientX - r.left, n.clientY - r.top], a = e.unproject(i), o = [a.lng, a.lat];
158
+ this.eventBus?.emit({
159
+ type: "pointer-up",
160
+ coords: o,
161
+ pixel: i,
162
+ button: 0,
163
+ originalEvent: n
164
+ });
165
+ }), t.addEventListener("pointercancel", () => {
166
+ this.eventBus?.emit({ type: "pointer-cancel" });
167
+ }), e.on("mouseout", (e) => {
168
+ this.eventBus?.emit({
169
+ type: "pointer-leave",
170
+ originalEvent: e.originalEvent
171
+ }), this.store.dispatch({
172
+ pointerCoordinates: null,
173
+ pointerResolution: null
174
+ }, "MAP");
175
+ }), e.on("click", (e) => {
176
+ let t = [e.lngLat.lng, e.lngLat.lat], n = [e.point.x, e.point.y], r = this.computePointerResolution(e);
177
+ this.eventBus?.emit({
178
+ type: "click",
179
+ coords: t,
180
+ pixel: n,
181
+ resolution: r,
182
+ originalEvent: e.originalEvent
183
+ }), this.store.dispatch({
184
+ lastClickedCoordinates: t,
185
+ lastClickedResolution: r,
186
+ pointerCoordinates: t,
187
+ pointerResolution: r
188
+ }, "MAP");
189
+ }), e.on("dblclick", (e) => {
190
+ let t = [e.lngLat.lng, e.lngLat.lat], n = [e.point.x, e.point.y];
191
+ this.eventBus?.emit({
192
+ type: "dblclick",
193
+ coords: t,
194
+ pixel: n,
195
+ originalEvent: e.originalEvent
196
+ });
197
+ }), e.on("contextmenu", (e) => {
198
+ let t = [e.lngLat.lng, e.lngLat.lat], n = [e.point.x, e.point.y];
199
+ this.eventBus?.emit({
200
+ type: "contextmenu",
201
+ coords: t,
202
+ pixel: n,
203
+ originalEvent: e.originalEvent
204
+ });
205
+ });
206
+ }
207
+ computePointerResolution(e) {
208
+ if (!this.mapInstance || !e.point) return null;
209
+ let t = this.mapInstance, n = e.point, r = e.lngLat, i = t.unproject([n.x + 1, n.y]), a = t.unproject([n.x, n.y + 1]), o = Math.abs(i.lng - r.lng), s = Math.abs(a.lat - r.lat);
210
+ return !isFinite(o) || !isFinite(s) ? null : {
211
+ lng: Math.max(o, 1e-12),
212
+ lat: Math.max(s, 1e-12)
213
+ };
214
+ }
215
+ emitViewChange() {
216
+ if (!this.eventBus || !this.mapInstance) return;
217
+ let e = this.mapInstance.getCenter(), t = this.mapInstance.getBounds();
218
+ this.eventBus.emit({
219
+ type: "view-change",
220
+ center: [e.lng, e.lat],
221
+ zoom: this.mapInstance.getZoom(),
222
+ bearing: this.mapInstance.getBearing(),
223
+ pitch: this.mapInstance.getPitch(),
224
+ bounds: {
225
+ sw: [t.getSouthWest().lng, t.getSouthWest().lat],
226
+ ne: [t.getNorthEast().lng, t.getNorthEast().lat]
227
+ }
228
+ });
229
+ }
230
+ emitViewChangeEnd() {
231
+ if (!this.eventBus || !this.mapInstance) return;
232
+ let e = this.mapInstance.getCenter(), t = this.mapInstance.getBounds();
233
+ this.eventBus.emit({
234
+ type: "view-change-end",
235
+ center: [e.lng, e.lat],
236
+ zoom: this.mapInstance.getZoom(),
237
+ bearing: this.mapInstance.getBearing(),
238
+ pitch: this.mapInstance.getPitch(),
239
+ bounds: {
240
+ sw: [t.getSouthWest().lng, t.getSouthWest().lat],
241
+ ne: [t.getNorthEast().lng, t.getNorthEast().lat]
242
+ }
243
+ });
244
+ }
245
+ onMapReady(e) {
246
+ if (this.mapInstance) {
247
+ e(this.mapInstance);
248
+ return;
249
+ }
250
+ this.mapReadyCallbacks.push(e);
251
+ }
252
+ setZoom(e) {
253
+ this.mapInstance && this.mapInstance.setZoom(e);
254
+ }
255
+ getZoom() {
256
+ return this.mapInstance ? this.mapInstance.getZoom() : this.initialConfig.zoom;
257
+ }
258
+ addLayer(e, t) {
259
+ if (!this.mapInstance || e?.id && this.mapInstance.getLayer(e.id)) return !1;
260
+ if (t?.beforeLayerId) return this.mapInstance.addLayer(e, t.beforeLayerId), !0;
261
+ if (t?.afterLayerId) {
262
+ let n = this.mapInstance.getStyle(), r = Array.isArray(n?.layers) ? n.layers : [], i = r.findIndex((e) => e?.id === t.afterLayerId), a = i >= 0 && i + 1 < r.length ? r[i + 1]?.id : void 0;
263
+ return this.mapInstance.addLayer(e, a), !0;
264
+ }
265
+ return this.mapInstance.addLayer(e), !0;
266
+ }
267
+ removeLayer(e) {
268
+ this.mapInstance?.getLayer(e) && this.mapInstance.removeLayer(e);
269
+ }
270
+ static {
271
+ this.TERRAIN_SOURCE_ID = "webmapx-terrain-dem";
272
+ }
273
+ static {
274
+ this.TERRAIN_HILLSHADE_LAYER_ID = "webmapx-terrain-hillshade";
275
+ }
276
+ static {
277
+ this.TERRAIN_SOURCE_CONFIG = {
278
+ type: "raster-dem",
279
+ tiles: [
280
+ "https://t1.edugis.nl/mapproxy/nextzenelevation/wmts/nextzenelevation/webmercator/{z}/{x}/{y}.png",
281
+ "https://t2.edugis.nl/mapproxy/nextzenelevation/wmts/nextzenelevation/webmercator/{z}/{x}/{y}.png",
282
+ "https://t3.edugis.nl/mapproxy/nextzenelevation/wmts/nextzenelevation/webmercator/{z}/{x}/{y}.png",
283
+ "https://t4.edugis.nl/mapproxy/nextzenelevation/wmts/nextzenelevation/webmercator/{z}/{x}/{y}.png"
284
+ ],
285
+ tileSize: 256,
286
+ encoding: "terrarium",
287
+ maxzoom: 15,
288
+ attribution: "NextZen"
289
+ };
290
+ }
291
+ setTerrainEnabled(t, n, r) {
292
+ if (!this.mapInstance || t && this.mapInstance.getProjection?.()?.type === "globe") return !1;
293
+ try {
294
+ if (t) {
295
+ let t = r ?? e.TERRAIN_SOURCE_ID;
296
+ this.mapInstance.getSource(t) || this.mapInstance.addSource(t, n ?? e.TERRAIN_SOURCE_CONFIG), this.mapInstance.setTerrain({
297
+ source: t,
298
+ exaggeration: 1
299
+ }), !r && !this.mapInstance.getLayer(e.TERRAIN_HILLSHADE_LAYER_ID) && this.mapInstance.addLayer({
300
+ id: e.TERRAIN_HILLSHADE_LAYER_ID,
301
+ type: "hillshade",
302
+ source: e.TERRAIN_SOURCE_ID,
303
+ paint: { "hillshade-exaggeration": .2 }
304
+ });
305
+ } else this.mapInstance.setTerrain(null), this.mapInstance.getLayer(e.TERRAIN_HILLSHADE_LAYER_ID) && this.mapInstance.removeLayer(e.TERRAIN_HILLSHADE_LAYER_ID);
306
+ } catch (e) {
307
+ return console.error("[MapLibre] setTerrain failed", e), this.mapInstance.setTerrain(null), !1;
308
+ }
309
+ return !0;
310
+ }
311
+ isTerrainEnabled() {
312
+ return this.mapInstance ? !!this.mapInstance.getTerrain() : null;
313
+ }
314
+ addSource(e, t) {
315
+ this.mapInstance?.addSource(e, t), t?.type === "geojson" && t.data && typeof t.data == "object" && this.geoJSONData.set(e, t.data);
316
+ }
317
+ removeSource(e) {
318
+ this.mapInstance?.getSource(e) && this.mapInstance.removeSource(e), this.geoJSONData.delete(e);
319
+ }
320
+ getSource(e) {
321
+ let t = this.mapInstance?.getSource(e);
322
+ if (!t) return;
323
+ let n = this;
324
+ return {
325
+ id: e,
326
+ setData: (r) => {
327
+ t.setData(r), n.geoJSONData.set(e, r);
328
+ }
329
+ };
330
+ }
331
+ project(e) {
332
+ if (!this.mapInstance) return console.warn("[CORE SERVICE - MapLibre] project called before map instance is ready."), [0, 0];
333
+ try {
334
+ let t = this.mapInstance.project(e);
335
+ return [t.x, t.y];
336
+ } catch {
337
+ return [0, 0];
338
+ }
339
+ }
340
+ unproject(e) {
341
+ if (!this.mapInstance) return console.warn("[CORE SERVICE - MapLibre] unproject called before map instance is ready."), null;
342
+ let t = [e[0], e[1]], n = this.mapInstance.unproject(t);
343
+ return [n.lng, n.lat];
344
+ }
345
+ fitBounds(e) {
346
+ if (this.mapInstance) try {
347
+ this.mapInstance.fitBounds([[e[0], e[1]], [e[2], e[3]]], {
348
+ padding: 40,
349
+ animate: !0
350
+ });
351
+ } catch {
352
+ let t = (e[0] + e[2]) / 2, n = (e[1] + e[3]) / 2;
353
+ this.setViewport([t, n], this.initialConfig.zoom);
354
+ }
355
+ }
356
+ setCursor(e) {
357
+ this.mapInstance && (this.mapInstance.getCanvas().style.cursor = e);
358
+ }
359
+ setPanEnabled(e) {
360
+ this.mapInstance && (e ? this.mapInstance.dragPan.enable() : this.mapInstance.dragPan.disable());
361
+ }
362
+ setTouchCaptureEnabled(e) {}
363
+ setDoubleClickZoomEnabled(e) {
364
+ this.mapInstance && (e ? this.mapInstance.doubleClickZoom.enable() : this.mapInstance.doubleClickZoom.disable());
365
+ }
366
+ setLayerVisibility(e, t) {
367
+ if (this.mapInstance) try {
368
+ this.mapInstance.setLayoutProperty(e, "visibility", t ? "visible" : "none");
369
+ } catch {}
370
+ }
371
+ getSourceData(e) {
372
+ let t = this.geoJSONData.get(e);
373
+ if (t) return t;
374
+ if (!this.mapInstance) return null;
375
+ let n = this.mapInstance.getSource(e);
376
+ if (!n || n.type !== "geojson") return null;
377
+ try {
378
+ let t = n.serialize();
379
+ if (!t) return null;
380
+ if (typeof t.data == "string") return t.data;
381
+ if (typeof t.data == "object") return this.geoJSONData.set(e, t.data), t.data;
382
+ } catch {}
383
+ return null;
384
+ }
385
+ suppressBusySignalForSource(e) {
386
+ this.silentSourceIds.add(e);
387
+ }
388
+ unsuppressBusySignalForSource(e) {
389
+ this.silentSourceIds.delete(e);
390
+ }
391
+ getNavigationCapabilities() {
392
+ return {
393
+ bearing: !0,
394
+ pitch: !0
395
+ };
396
+ }
397
+ getBearing() {
398
+ return this.mapInstance?.getBearing() ?? 0;
399
+ }
400
+ setBearing(e) {
401
+ this.mapInstance?.setBearing(e);
402
+ }
403
+ getPitch() {
404
+ return this.mapInstance?.getPitch() ?? 0;
405
+ }
406
+ setPitch(e) {
407
+ this.mapInstance?.setPitch(e);
408
+ }
409
+ resetNorth() {
410
+ this.mapInstance?.resetNorth();
411
+ }
412
+ resetNorthPitch() {
413
+ this.mapInstance?.resetNorthPitch();
414
+ }
415
+ applyGlobeFog() {
416
+ if (!this.mapInstance) return;
417
+ let e = this.mapInstance.getProjection?.()?.type === "globe", t = this.mapInstance.getCanvas?.();
418
+ t && (t.style.background = e ? "#000008" : "var(--color-background-secondary, #f4f4f4)");
419
+ try {
420
+ this.mapInstance.setSky(e ? { "sky-color": "#000000" } : void 0);
421
+ } catch {}
422
+ }
423
+ setProjection(e) {
424
+ if (!this.mapInstance) return !1;
425
+ try {
426
+ let t = typeof e == "string" ? { type: e } : {
427
+ type: e.name,
428
+ center: e.center,
429
+ parallels: e.parallels
430
+ };
431
+ return this.mapInstance.setProjection(t), this.applyGlobeFog(), !0;
432
+ } catch {
433
+ return !1;
434
+ }
435
+ }
436
+ getProjection() {
437
+ if (!this.mapInstance) return { name: "mercator" };
438
+ try {
439
+ let e = this.mapInstance.getProjection();
440
+ return {
441
+ name: e?.type ?? e?.name ?? "mercator",
442
+ ...e?.center ? { center: e.center } : {},
443
+ ...e?.parallels ? { parallels: e.parallels } : {}
444
+ };
445
+ } catch {
446
+ return { name: "mercator" };
447
+ }
448
+ }
449
+ dispatchViewportBoundsSnapshot() {
450
+ let e = this.buildViewportFeature();
451
+ this.store.dispatch({ mapViewportBounds: e }, "MAP");
452
+ }
453
+ buildViewportFeature() {
454
+ if (!this.mapInstance) return null;
455
+ let e = [], t = this.mapInstance.getCanvas(), n = this.mapInstance.pixelRatio ?? window.devicePixelRatio ?? 1, r = (t?.width ?? 0) / n || t?.clientWidth || 0, i = (t?.height ?? 0) / n || t?.clientHeight || 0;
456
+ if (r > 0 && i > 0) {
457
+ let t = [
458
+ [0, i],
459
+ [r, i],
460
+ [r, 0],
461
+ [0, 0]
462
+ ];
463
+ for (let n of t) {
464
+ let t = this.mapInstance.unproject(n);
465
+ e.push([t.lng, t.lat]);
466
+ }
467
+ e.push(e[0]);
468
+ }
469
+ if (e.length === 0) {
470
+ let t = this.mapInstance.getBounds();
471
+ if (!t) return null;
472
+ let n = t.getSouthWest(), r = t.getNorthEast();
473
+ e.push([n.lng, n.lat], [n.lng, r.lat], [r.lng, r.lat], [r.lng, n.lat], [n.lng, n.lat]);
474
+ }
475
+ return {
476
+ type: "Feature",
477
+ properties: { role: "mapViewport" },
478
+ geometry: {
479
+ type: "Polygon",
480
+ coordinates: [e]
481
+ }
482
+ };
483
+ }
484
+ resolveContainer(e) {
485
+ let t = document.getElementById(e);
486
+ if (!t) return console.warn(`[CORE SERVICE] Container #${e} not found. Falling back to ID.`), e;
487
+ if (t.tagName.toLowerCase() === "webmapx-map") {
488
+ let e = t.querySelector("[slot=\"map-view\"]");
489
+ if (e) return e;
490
+ console.warn("[CORE SERVICE] <webmapx-map> is missing a [slot=\"map-view\"] element. Using host as fallback.");
491
+ }
492
+ return t;
493
+ }
494
+ flushMapReadyCallbacks() {
495
+ if (this.mapInstance) for (let e of this.mapReadyCallbacks) try {
496
+ e(this.mapInstance);
497
+ } catch (e) {
498
+ console.error("[CORE SERVICE] mapReady callback failed.", e);
499
+ }
500
+ }
501
+ supportsRuntimeProjection() {
502
+ return typeof this.mapInstance?.setProjection == "function";
503
+ }
504
+ destroyAndReinitialize(e) {
505
+ if (!this.mapInstance || !this.lastContainerId) return;
506
+ let t = this.getViewportState();
507
+ this.mapInstance.remove(), this.mapInstance = null, this.initialize(this.lastContainerId, {
508
+ ...this.lastInitOptions,
509
+ center: t.center,
510
+ zoom: t.zoom,
511
+ bearing: t.bearing,
512
+ pitch: t.pitch,
513
+ projection: e
514
+ });
515
+ }
516
+ }, u = class {
517
+ constructor(e) {
518
+ this.mapLibreInstance = {}, this.mapLibreInstance = e;
519
+ }
520
+ setBufferRadius(e) {
521
+ console.log(`[SERVICE TEMPLATE] Set buffer radius to ${e}km on MapLibre.`);
522
+ }
523
+ toggleTool() {
524
+ console.log("[SERVICE TEMPLATE] Toggled buffer tool activation.");
525
+ }
526
+ }, d = "https://demotiles.maplibre.org/style.json";
527
+ function f(e) {
528
+ return e.includes("{s}") ? [
529
+ "a",
530
+ "b",
531
+ "c"
532
+ ].map((t) => e.replace("{s}", t)) : [e];
533
+ }
534
+ var p = class {
535
+ constructor(e, t) {
536
+ this.id = e, this.map = t;
537
+ }
538
+ setData(e) {
539
+ let t = this.map.getSource(this.id);
540
+ t && t.setData(e);
541
+ }
542
+ }, m = class {
543
+ constructor(e, t, n) {
544
+ this.id = e, this.sourceId = t, this.map = n;
545
+ }
546
+ getSource() {
547
+ return new p(this.sourceId, this.map);
548
+ }
549
+ remove() {
550
+ this.map.getLayer(this.id) && this.map.removeLayer(this.id);
551
+ }
552
+ }, h = class {
553
+ constructor(e) {
554
+ this.map = e;
555
+ }
556
+ setViewport(e, t, n, r) {
557
+ this.map.jumpTo({
558
+ center: e,
559
+ zoom: t,
560
+ bearing: n ?? 0,
561
+ pitch: r ?? 0
562
+ });
563
+ }
564
+ createSource(e, t) {
565
+ return this.map.getSource(e) || this.map.addSource(e, {
566
+ type: "geojson",
567
+ data: t
568
+ }), new p(e, this.map);
569
+ }
570
+ getSource(e) {
571
+ return this.map.getSource(e) ? new p(e, this.map) : null;
572
+ }
573
+ createLayer(e) {
574
+ if (!this.map.getLayer(e.id)) {
575
+ let t = this.toMapLibreLayerSpec(e);
576
+ this.map.addLayer(t);
577
+ }
578
+ return new m(e.id, e.sourceId, this.map);
579
+ }
580
+ getLayer(e) {
581
+ let t = this.map.getLayer(e);
582
+ if (t) {
583
+ let n = t.source;
584
+ return new m(e, n, this.map);
585
+ }
586
+ return null;
587
+ }
588
+ onReady(e) {
589
+ this.map.isStyleLoaded() ? e() : this.map.once("load", e);
590
+ }
591
+ destroy() {
592
+ this.map.remove();
593
+ }
594
+ toMapLibreLayerSpec(e) {
595
+ switch (e.type) {
596
+ case "fill": return {
597
+ id: e.id,
598
+ type: "fill",
599
+ source: e.sourceId,
600
+ paint: e.paint
601
+ };
602
+ case "line": return {
603
+ id: e.id,
604
+ type: "line",
605
+ source: e.sourceId,
606
+ paint: e.paint
607
+ };
608
+ case "circle": return {
609
+ id: e.id,
610
+ type: "circle",
611
+ source: e.sourceId,
612
+ paint: e.paint
613
+ };
614
+ case "symbol": return {
615
+ id: e.id,
616
+ type: "symbol",
617
+ source: e.sourceId,
618
+ layout: {}
619
+ };
620
+ default: throw Error(`Unsupported layer type: ${e.type}`);
621
+ }
622
+ }
623
+ }, g = class {
624
+ createMap(e, t) {
625
+ let n = Array.isArray(t?.tileUrls) && t.tileUrls.length > 0 ? t.tileUrls : typeof t?.tileUrl == "string" && t.tileUrl.length > 0 ? f(t.tileUrl) : void 0, r = t?.style ?? (n ? {
626
+ version: 8,
627
+ sources: { insetBackground: {
628
+ type: "raster",
629
+ tiles: n,
630
+ tileSize: t?.tileSize ?? 256,
631
+ ...t?.tileAttribution ? { attribution: t.tileAttribution } : {}
632
+ } },
633
+ layers: [{
634
+ id: "inset-background",
635
+ type: "raster",
636
+ source: "insetBackground"
637
+ }]
638
+ } : void 0) ?? t?.styleUrl ?? d, i = new s.Map({
639
+ container: e,
640
+ style: r,
641
+ center: t?.center ?? [0, 0],
642
+ zoom: t?.zoom ?? 1,
643
+ attributionControl: !1,
644
+ interactive: t?.interactive ?? !0
645
+ });
646
+ return t?.interactive === !1 && (i.boxZoom?.disable(), i.scrollZoom?.disable(), i.dragPan?.disable(), i.dragRotate?.disable(), i.keyboard?.disable(), i.doubleClickZoom?.disable(), i.touchZoomRotate?.disable()), new h(i);
647
+ }
648
+ }, _ = {
649
+ fill: ["fill-opacity"],
650
+ line: ["line-opacity"],
651
+ circle: ["circle-opacity"],
652
+ raster: ["raster-opacity"],
653
+ "fill-extrusion": ["fill-extrusion-opacity"],
654
+ heatmap: ["heatmap-opacity"],
655
+ background: ["background-opacity"],
656
+ symbol: ["icon-opacity", "text-opacity"],
657
+ hillshade: [
658
+ "hillshade-shadow-color",
659
+ "hillshade-highlight-color",
660
+ "hillshade-accent-color"
661
+ ]
662
+ }, v = class t {
663
+ constructor(e, t) {
664
+ this.logicalToNative = /* @__PURE__ */ new Map(), this.logicalSourceToNative = /* @__PURE__ */ new Map(), this.nativeLayerToSource = /* @__PURE__ */ new Map(), this.warpedMapLayers = /* @__PURE__ */ new Map(), this.nativeSourceToConfig = /* @__PURE__ */ new Map(), this.sourceIdCounter = 0, this.logicalLayerLegendRole = /* @__PURE__ */ new Map(), this._pendingHillshade = /* @__PURE__ */ new Map(), this.map = e, this.store = t;
665
+ }
666
+ resolveLegendRole(e) {
667
+ return (e?.metadata && typeof e.metadata == "object" ? e.metadata : null)?.legendRole === "background" ? "background" : "overlay";
668
+ }
669
+ findNextStyleLayerId(e) {
670
+ let t = this.map.getStyle()?.layers ?? [];
671
+ for (let n = 0; n < t.length; n += 1) if (t[n].id === e) return t[n + 1]?.id;
672
+ }
673
+ resolveInsertBeforeLayerIdFromOptions(e) {
674
+ if (e?.beforeLayerId) {
675
+ for (let t of this.logicalToNative.get(e.beforeLayerId) ?? []) if (this.map.getLayer(t)) return t;
676
+ if (this.map.getLayer(e.beforeLayerId)) return e.beforeLayerId;
677
+ }
678
+ if (e?.afterLayerId) {
679
+ let t = this.logicalToNative.get(e.afterLayerId) ?? [];
680
+ for (let e = t.length - 1; e >= 0; --e) if (this.map.getLayer(t[e])) return this.findNextStyleLayerId(t[e]);
681
+ if (this.map.getLayer(e.afterLayerId)) return this.findNextStyleLayerId(e.afterLayerId);
682
+ }
683
+ }
684
+ collectBackgroundNativeLayerIds() {
685
+ let e = /* @__PURE__ */ new Set();
686
+ for (let [t, n] of this.logicalToNative.entries()) if ((this.logicalLayerLegendRole.get(t) ?? "overlay") === "background") for (let t of n) e.add(t);
687
+ return e;
688
+ }
689
+ findBackgroundInsertionBeforeLayerId() {
690
+ let e = this.collectBackgroundNativeLayerIds();
691
+ for (let [t, n] of this.logicalToNative.entries()) if (this.logicalLayerLegendRole.get(t) !== "background") {
692
+ for (let t of n) if (!e.has(t)) return t;
693
+ }
694
+ }
695
+ getNativeSourceId(e) {
696
+ return this.logicalSourceToNative.get(e);
697
+ }
698
+ getOrCreateNativeSourceId(e) {
699
+ if (this.logicalSourceToNative.has(e)) return this.logicalSourceToNative.get(e);
700
+ let t = `src-${e.replace(/[^a-zA-Z0-9_-]/g, "-")}-${this.sourceIdCounter++}`;
701
+ return this.logicalSourceToNative.set(e, t), t;
702
+ }
703
+ ensureNativeSource(t, n) {
704
+ if (this.map.getSource(t)) {
705
+ this.nativeSourceToConfig.has(t) || this.nativeSourceToConfig.set(t, n);
706
+ return;
707
+ }
708
+ let r = { type: n.type };
709
+ if (n.type === "raster") {
710
+ if (n.service === "xyz" || n.service === void 0) r = {
711
+ type: "raster",
712
+ tiles: Array.isArray(n.url) ? n.url : [n.url]
713
+ }, "tileSize" in n && (r.tileSize = n.tileSize), "bounds" in n && (r.bounds = n.bounds), typeof n.minzoom == "number" && (r.minzoom = n.minzoom), typeof n.maxzoom == "number" && (r.maxzoom = n.maxzoom), "scheme" in n && (r.scheme = n.scheme), typeof n.attribution == "string" && (r.attribution = n.attribution), typeof n.volatile == "boolean" && (r.volatile = n.volatile);
714
+ else if (n.service === "wms") {
715
+ let t = n, i = n.tiles, a;
716
+ a = i?.length ? i : [e({
717
+ baseUrl: Array.isArray(t.url) ? t.url[0] : t.url,
718
+ layers: t.layers ?? "",
719
+ version: t.version,
720
+ styles: t.styles,
721
+ format: t.format,
722
+ transparent: t.transparent,
723
+ crs: t.crs,
724
+ tileSize: t.tileSize
725
+ }, "maplibre")], r = {
726
+ type: "raster",
727
+ tiles: a
728
+ }, "tileSize" in n && (r.tileSize = n.tileSize), "bounds" in n && (r.bounds = n.bounds), typeof n.minzoom == "number" && (r.minzoom = n.minzoom), typeof n.maxzoom == "number" && (r.maxzoom = n.maxzoom), "scheme" in n && (r.scheme = n.scheme), typeof n.attribution == "string" && (r.attribution = n.attribution), typeof n.volatile == "boolean" && (r.volatile = n.volatile);
729
+ }
730
+ } else if (n.type === "geojson") r = {
731
+ type: "geojson",
732
+ data: n.data
733
+ }, typeof n.attribution == "string" && (r.attribution = n.attribution);
734
+ else if (n.type === "raster-dem") {
735
+ let e = n;
736
+ r = {
737
+ type: "raster-dem",
738
+ tiles: e.tiles
739
+ }, typeof e.tileSize == "number" && (r.tileSize = e.tileSize), typeof e.encoding == "string" && (r.encoding = e.encoding), typeof e.maxzoom == "number" && (r.maxzoom = e.maxzoom), typeof e.attribution == "string" && (r.attribution = e.attribution);
740
+ } else if (n.type === "vector") {
741
+ let e = n;
742
+ r = e.tiles ? {
743
+ type: "vector",
744
+ tiles: e.tiles
745
+ } : {
746
+ type: "vector",
747
+ url: e.url
748
+ }, typeof n.attribution == "string" && (r.attribution = n.attribution);
749
+ }
750
+ this.map.addSource(t, r), this.nativeSourceToConfig.set(t, n);
751
+ }
752
+ buildNativeLayer(e, t, n, r) {
753
+ let i = {
754
+ id: e,
755
+ type: t.type,
756
+ source: n,
757
+ metadata: { mapLayerId: r }
758
+ };
759
+ return t["source-layer"] && (i["source-layer"] = t["source-layer"]), t.minzoom !== void 0 && (i.minzoom = t.minzoom), t.maxzoom !== void 0 && (i.maxzoom = t.maxzoom), t.paint && typeof t.paint == "object" && (i.paint = t.paint), t.layout && typeof t.layout == "object" && (i.layout = t.layout), Array.isArray(t.filter) && (i.filter = t.filter), i;
760
+ }
761
+ async addAllmapsLayer(e, t, n) {
762
+ let { WarpedMapLayer: r } = await import("./dist-kKlmcBXq.js"), i = `warpedmap-${e}`, a = new r({ layerId: i });
763
+ return this.map.addLayer(a, n), await a.addGeoreferenceAnnotationByUrl(t), this.warpedMapLayers.set(e, a), this.logicalToNative.set(e, [i]), !0;
764
+ }
765
+ async addCompositeLayer(e, t) {
766
+ let n = e.styleId, r = e.metadata?.legendRole === "background" ? "background" : "overlay", i = this.resolveInsertBeforeLayerIdFromOptions(t) ?? (r === "background" ? this.findBackgroundInsertionBeforeLayerId() : void 0), a = /* @__PURE__ */ new Map();
767
+ for (let t of e.sources) {
768
+ let e = this.getOrCreateNativeSourceId(t.globalId);
769
+ this.ensureNativeSource(e, t.config), a.set(t.key, e);
770
+ }
771
+ let o = [...this.logicalToNative.get(n) ?? []];
772
+ for (let t of e.subLayers) {
773
+ let e = `${n}-${t.id}`;
774
+ if (t.type === "background") {
775
+ if (!this.map.getLayer(e)) {
776
+ let n = {
777
+ id: e,
778
+ type: "background"
779
+ };
780
+ t.paint && (n.paint = t.paint), t.layout && (n.layout = t.layout), this.map.addLayer(n, i);
781
+ }
782
+ o.push(e);
783
+ continue;
784
+ }
785
+ let r = a.get(t.source ?? "");
786
+ !r || !this.map.getSource(r) || (this.map.getLayer(e) || this.map.addLayer(this.buildNativeLayer(e, t, r, n), i), o.push(e), this.nativeLayerToSource.set(e, r));
787
+ }
788
+ return this.logicalLayerLegendRole.set(n, r), this.logicalToNative.set(n, Array.from(new Set(o))), o.length > 0;
789
+ }
790
+ static {
791
+ this.LAYOUT_KEYS = new Set([
792
+ "text-size",
793
+ "icon-size",
794
+ "text-field",
795
+ "visibility"
796
+ ]);
797
+ }
798
+ applyHillshadePaintThrottled(e, t, n) {
799
+ let r = this._pendingHillshade.get(e);
800
+ if (r) {
801
+ r.key = t, r.value = n;
802
+ return;
803
+ }
804
+ let i = requestAnimationFrame(() => {
805
+ let t = this._pendingHillshade.get(e);
806
+ t && (this._pendingHillshade.delete(e), this.map.setPaintProperty(e, t.key, t.value), this.map.triggerRepaint());
807
+ });
808
+ this._pendingHillshade.set(e, {
809
+ key: t,
810
+ value: n,
811
+ rafId: i
812
+ });
813
+ }
814
+ static layerTypeForKey(e) {
815
+ return e.startsWith("fill-extrusion") ? "fill-extrusion" : e.startsWith("text-") || e.startsWith("icon-") ? "symbol" : e.split("-")[0];
816
+ }
817
+ applyStyleProperty(e, n, r) {
818
+ t.LAYOUT_KEYS.has(n) ? (this.map.setLayoutProperty(e, n, r), this.map.triggerRepaint()) : n === "hillshade-exaggeration" ? this.applyHillshadePaintThrottled(e, n, r) : (this.map.setPaintProperty(e, n, r), this.map.triggerRepaint());
819
+ }
820
+ updateLayerStyle(e, n, r) {
821
+ let i = `${e}-${n}`;
822
+ if (this.map.getLayer(i)) {
823
+ for (let [e, t] of Object.entries(r)) this.applyStyleProperty(i, e, t);
824
+ return !0;
825
+ }
826
+ if (e !== n) return !1;
827
+ let a = !1, o = this.logicalToNative.get(e) ?? [];
828
+ for (let e of o) if (this.map.getLayer(e)) for (let [n, i] of Object.entries(r)) {
829
+ let r = t.layerTypeForKey(n);
830
+ e.endsWith(`-${r}`) && (this.applyStyleProperty(e, n, i), a = !0);
831
+ }
832
+ return a;
833
+ }
834
+ async addLayer(e, t) {
835
+ let i = e.id, a = this.resolveLegendRole(e), o = this.resolveInsertBeforeLayerIdFromOptions(t) ?? (a === "background" ? this.findBackgroundInsertionBeforeLayerId() : void 0);
836
+ if (e.type === "allmaps") {
837
+ let t = await this.addAllmapsLayer(i, e.annotation, o);
838
+ return t && this.logicalLayerLegendRole.set(i, a), t;
839
+ }
840
+ if (e.type === "style") {
841
+ let n = r(e);
842
+ return n ? this.addCompositeLayer(n, t) : !1;
843
+ }
844
+ let s = e;
845
+ if (s.type === "background") {
846
+ let e = `${i}-background`;
847
+ if (!this.map.getLayer(e)) {
848
+ let t = {
849
+ id: e,
850
+ type: "background"
851
+ };
852
+ s.paint && (t.paint = s.paint), s.layout && (t.layout = s.layout), this.map.addLayer(t, o);
853
+ }
854
+ return this.logicalLayerLegendRole.set(i, a), this.logicalToNative.set(i, [e]), !0;
855
+ }
856
+ if (!s.source) return !1;
857
+ let c = e.sources?.[s.source], l = c ? n(s.source, c) : null;
858
+ if (!l) return !1;
859
+ let u = this.getOrCreateNativeSourceId(l.id);
860
+ if (this.ensureNativeSource(u, l), !this.map.getSource(u)) return !1;
861
+ let d = `${i}-${l.id}-${s.type}`;
862
+ this.map.getLayer(d) || (this.map.addLayer(this.buildNativeLayer(d, s, u, i), o), s.type === "hillshade" && this.map.setPaintProperty(d, "hillshade-exaggeration-transition", {
863
+ duration: 0,
864
+ delay: 0
865
+ })), this.logicalLayerLegendRole.set(i, a);
866
+ let f = this.logicalToNative.get(i) ?? [];
867
+ return this.logicalToNative.set(i, Array.from(new Set([...f, d]))), this.nativeLayerToSource.set(d, u), !0;
868
+ }
869
+ moveLayer(e, t) {
870
+ let n = this.logicalToNative.get(e) ?? [], r = t ? this.resolveInsertBeforeLayerIdFromOptions({ beforeLayerId: t }) : void 0;
871
+ for (let e of n) if (this.map.getLayer(e)) try {
872
+ this.map.moveLayer(e, r);
873
+ } catch {}
874
+ }
875
+ removeLayer(e) {
876
+ if (this.warpedMapLayers.has(e)) {
877
+ for (let t of this.logicalToNative.get(e) ?? []) this.map.getLayer(t) && this.map.removeLayer(t);
878
+ this.warpedMapLayers.delete(e), this.logicalToNative.delete(e), this.logicalLayerLegendRole.delete(e);
879
+ return;
880
+ }
881
+ let t = this.logicalToNative.get(e) ?? [], n = /* @__PURE__ */ new Set();
882
+ for (let e of t) {
883
+ let t = this.nativeLayerToSource.get(e);
884
+ t && n.add(t), this.map.getLayer(e) && this.map.removeLayer(e), this.nativeLayerToSource.delete(e);
885
+ }
886
+ this.logicalToNative.delete(e), this.logicalLayerLegendRole.delete(e);
887
+ let r = this.map.getTerrain?.();
888
+ if (r && n.has(r.source)) {
889
+ this.map.setTerrain(null);
890
+ let e = r.source;
891
+ this.map.getSource(e) && !n.has(e) && this.map.removeSource(e);
892
+ }
893
+ for (let e of n) {
894
+ let t = !1;
895
+ for (let n of this.nativeLayerToSource.values()) if (n === e) {
896
+ t = !0;
897
+ break;
898
+ }
899
+ if (!t && this.map.getSource(e)) {
900
+ this.map.removeSource(e);
901
+ for (let [t, n] of this.logicalSourceToNative.entries()) if (n === e) {
902
+ this.logicalSourceToNative.delete(t);
903
+ break;
904
+ }
905
+ }
906
+ }
907
+ }
908
+ getVisibleLayers() {
909
+ return Array.from(this.logicalToNative.keys());
910
+ }
911
+ isLayerVisible(e) {
912
+ return this.logicalToNative.has(e);
913
+ }
914
+ setLayerVisibility(e, t) {
915
+ let n = this.logicalToNative.get(e) ?? [];
916
+ for (let e of n) try {
917
+ this.map.setLayoutProperty(e, "visibility", t ? "visible" : "none");
918
+ } catch {}
919
+ }
920
+ setLayerOpacity(e, t) {
921
+ let n = this.warpedMapLayers.get(e);
922
+ if (n) {
923
+ n.setOpacity(t);
924
+ return;
925
+ }
926
+ let r = this.logicalToNative.get(e) ?? [];
927
+ for (let e of r) try {
928
+ let n = this.map.getLayer(e), r = n ? _[n.type] : void 0;
929
+ if (!r) continue;
930
+ if (n.type === "hillshade") {
931
+ this.map.setPaintProperty(e, "hillshade-shadow-color", `rgba(0,0,0,${t})`), this.map.setPaintProperty(e, "hillshade-highlight-color", `rgba(255,255,255,${t})`), this.map.setPaintProperty(e, "hillshade-accent-color", `rgba(0,0,0,${t})`);
932
+ continue;
933
+ }
934
+ for (let n of r) this.map.setPaintProperty(e, n, t);
935
+ } catch {}
936
+ }
937
+ getSourceData(e) {
938
+ let t = this.logicalSourceToNative.get(e);
939
+ if (!t) return null;
940
+ let n = this.map.getSource(t);
941
+ if (!n || n.type !== "geojson") return null;
942
+ try {
943
+ let e = n.serialize?.()?.data;
944
+ if (typeof e == "string" || e && typeof e == "object") return e;
945
+ } catch {}
946
+ return null;
947
+ }
948
+ querySourceFeatures(e, t = {}) {
949
+ let n = this.logicalSourceToNative.get(e);
950
+ if (!n || !this.map.getSource(n)) return null;
951
+ try {
952
+ let e = t.sourceLayer ? { sourceLayer: t.sourceLayer } : void 0, r = this.map.querySourceFeatures(n, e);
953
+ return { features: this.dedupeSourceFeatures(r.map((e) => e.toJSON())) };
954
+ } catch {
955
+ return null;
956
+ }
957
+ }
958
+ dedupeSourceFeatures(e) {
959
+ let t = /* @__PURE__ */ new Set();
960
+ return e.filter((e) => {
961
+ let n = e.id === void 0 ? JSON.stringify([e.geometry, e.properties ?? {}]) : `id:${String(e.id)}`;
962
+ return t.has(n) ? !1 : (t.add(n), !0);
963
+ });
964
+ }
965
+ setSourceData(e, t) {
966
+ let n = this.logicalSourceToNative.get(e);
967
+ if (!n) return !1;
968
+ let r = this.map.getSource(n);
969
+ return !r || r.type !== "geojson" || typeof r.setData != "function" ? !1 : (r.setData(t), !0);
970
+ }
971
+ getVisibleWMSLayers() {
972
+ let e = [];
973
+ for (let t of this.logicalToNative.keys()) {
974
+ let n = this.logicalToNative.get(t) ?? [];
975
+ for (let r of n) {
976
+ let n = this.nativeLayerToSource.get(r);
977
+ if (!n) continue;
978
+ let i = this.nativeSourceToConfig.get(n);
979
+ if (i?.type === "raster" && i.service === "wms") {
980
+ let n = i, r = "gfiUrl" in n ? {
981
+ ...n,
982
+ url: n.gfiUrl,
983
+ layers: n.gfiLayers,
984
+ version: n.gfiVersion
985
+ } : n;
986
+ e.push({
987
+ layerId: t,
988
+ sourceConfig: r
989
+ });
990
+ }
991
+ break;
992
+ }
993
+ }
994
+ return e;
995
+ }
996
+ }, y = class {
997
+ constructor(e, t, n) {
998
+ this.map = e, this.layerService = t, this.store = n;
999
+ }
1000
+ async queryFeatures(e, n = {}) {
1001
+ let { pixel: r, lngLat: i } = e, a = n.tolerancePx ?? 5, o = [], s = [[r[0] - a, r[1] - a], [r[0] + a, r[1] + a]], c = n.layerIds?.length ? new Set(n.layerIds) : null, l = this.store.getState().mapLayers ?? {}, u = this.map.queryRenderedFeatures(s);
1002
+ for (let e of u) {
1003
+ let t = this.resolveRegisteredLayerId(e.layer, l);
1004
+ if (!t || c && !c.has(t)) continue;
1005
+ let n = this.resolveLayerTitle(t, l), r = typeof e.layer?.id == "string" ? e.layer.id : "", i = `${t}-style:`, a = r.startsWith(i) ? r.slice(i.length) : void 0, s = typeof e.layer?.type == "string" ? e.layer.type : void 0;
1006
+ o.push({
1007
+ layerId: t,
1008
+ ...n ? { layerTitle: n } : {},
1009
+ properties: e.properties,
1010
+ geometry: e.geometry,
1011
+ source: "vector",
1012
+ ...a ? { subLayerId: a } : {},
1013
+ ...s ? { subLayerType: s } : {}
1014
+ });
1015
+ }
1016
+ if (n.includeWMS) {
1017
+ let e = this.map.getContainer(), n = e.clientWidth, i = e.clientHeight, a = this.map.getBounds(), s = {
1018
+ west: a.getWest(),
1019
+ south: a.getSouth(),
1020
+ east: a.getEast(),
1021
+ north: a.getNorth()
1022
+ }, l = this.layerService.getVisibleWMSLayers(), u = await Promise.all(l.filter((e) => !c || c.has(e.layerId)).map((e) => t({
1023
+ sourceConfig: e.sourceConfig,
1024
+ layerId: e.layerId,
1025
+ layerTitle: e.layerTitle,
1026
+ bounds: s,
1027
+ containerWidth: n,
1028
+ containerHeight: i,
1029
+ pixelX: r[0],
1030
+ pixelY: r[1]
1031
+ })));
1032
+ for (let e of u) o.push(...e);
1033
+ }
1034
+ return o;
1035
+ }
1036
+ resolveRegisteredLayerId(e, t) {
1037
+ let n = e.metadata && typeof e.metadata == "object" ? e.metadata : {}, r = typeof n.mapLayerId == "string" ? n.mapLayerId : typeof e.id == "string" ? e.id : null;
1038
+ return r && t[r] ? r : null;
1039
+ }
1040
+ resolveLayerTitle(e, t) {
1041
+ let n = t[e];
1042
+ return typeof n?.label == "string" && n.label.length > 0 ? n.label : null;
1043
+ }
1044
+ }, b = class {
1045
+ constructor(e) {
1046
+ this.map = e, this.markers = /* @__PURE__ */ new Map();
1047
+ }
1048
+ add(e, t, n = {}) {
1049
+ this.remove(e);
1050
+ let r = new s.Marker({
1051
+ color: n.color ?? "#e63946",
1052
+ draggable: n.draggable ?? !1
1053
+ }).setLngLat([t[0], t[1]]).addTo(this.map);
1054
+ this.markers.set(e, r);
1055
+ }
1056
+ move(e, t) {
1057
+ this.markers.get(e)?.setLngLat([t[0], t[1]]);
1058
+ }
1059
+ remove(e) {
1060
+ let t = this.markers.get(e);
1061
+ t && (t.remove(), this.markers.delete(e));
1062
+ }
1063
+ }, x = class extends a {
1064
+ constructor() {
1065
+ super(), this.engineId = "maplibre", this.engineVersion = typeof s.getVersion == "function" ? s.getVersion() : s.version ?? "", this.markerService = null, this.layerService = null, this.core = new l(this.store, this.events), this.toolService = new u({}), this.logicalLayerExecutor = new i(), this.queryExecutor = new o(), this.queryService = this.queryExecutor, this.mapFactory = new g(), this.core.onMapReady?.((e) => {
1066
+ let t = () => {
1067
+ let t = new v(e, this.store);
1068
+ this.layerService = t, this.logicalLayerExecutor.bind(t), this.queryExecutor.bind(new y(e, t, this.store)), this.markerService = new b(e);
1069
+ };
1070
+ if (typeof e?.once == "function") {
1071
+ e.once("load", t);
1072
+ return;
1073
+ }
1074
+ t();
1075
+ });
1076
+ }
1077
+ initialize(e, t) {
1078
+ this.core.initialize(e, t);
1079
+ }
1080
+ getViewportState() {
1081
+ return this.core.getViewportState();
1082
+ }
1083
+ setViewport(e, t) {
1084
+ this.core.setViewport(e, t);
1085
+ }
1086
+ getZoom() {
1087
+ return this.core.getZoom();
1088
+ }
1089
+ setZoom(e) {
1090
+ this.core.setZoom(e);
1091
+ }
1092
+ getBearing() {
1093
+ return this.core.getBearing();
1094
+ }
1095
+ setBearing(e) {
1096
+ this.core.setBearing(e);
1097
+ }
1098
+ getPitch() {
1099
+ return this.core.getPitch();
1100
+ }
1101
+ setPitch(e) {
1102
+ this.core.setPitch(e);
1103
+ }
1104
+ setTerrainEnabled(e, t) {
1105
+ let n = t?.id, r = n ? this.layerService?.getNativeSourceId(n) : void 0;
1106
+ return this.core.setTerrainEnabled(e, t, r);
1107
+ }
1108
+ isTerrainEnabled() {
1109
+ return this.core.isTerrainEnabled();
1110
+ }
1111
+ resetNorth() {
1112
+ this.core.resetNorth();
1113
+ }
1114
+ resetNorthPitch() {
1115
+ this.core.resetNorthPitch();
1116
+ }
1117
+ fitBounds(e) {
1118
+ this.core.fitBounds(e);
1119
+ }
1120
+ setProjection(e) {
1121
+ return this.core.setProjection(e);
1122
+ }
1123
+ getProjection() {
1124
+ return this.core.getProjection();
1125
+ }
1126
+ setCursor(e) {
1127
+ this.core.setCursor(e);
1128
+ }
1129
+ setPanEnabled(e) {
1130
+ this.core.setPanEnabled(e);
1131
+ }
1132
+ setTouchCaptureEnabled(e) {}
1133
+ setDoubleClickZoomEnabled(e) {
1134
+ this.core.setDoubleClickZoomEnabled(e);
1135
+ }
1136
+ setLayerVisibility(e, t) {
1137
+ this.logicalLayerExecutor.setLayerVisibility(e, t);
1138
+ }
1139
+ setLayerOpacity(e, t) {
1140
+ this.logicalLayerExecutor.setLayerOpacity(e, t);
1141
+ }
1142
+ getSourceData(e) {
1143
+ let t = this.core.getSourceData(e);
1144
+ if (t !== null) return t;
1145
+ let n = this.layerService?.getNativeSourceId(e);
1146
+ if (n && n !== e) {
1147
+ let e = this.core.getSourceData(n);
1148
+ if (e !== null) return e;
1149
+ }
1150
+ return this.logicalLayerExecutor.getSourceData(e);
1151
+ }
1152
+ querySourceFeatures(e, t) {
1153
+ return this.logicalLayerExecutor.querySourceFeatures(e, t);
1154
+ }
1155
+ project(e) {
1156
+ return this.core.project(e);
1157
+ }
1158
+ unproject(e) {
1159
+ return this.core.unproject(e);
1160
+ }
1161
+ getNavigationCapabilities() {
1162
+ return this.core.getNavigationCapabilities();
1163
+ }
1164
+ async engineAddLayer(e, t) {
1165
+ return await this.logicalLayerExecutor.addLayer(e, t) ? !0 : this.core.addLayer(e, t);
1166
+ }
1167
+ removeLogicalLayer(e) {
1168
+ this.removeLayer(e);
1169
+ }
1170
+ engineAddSource(e, t) {
1171
+ this.core.addSource(e, t);
1172
+ }
1173
+ engineRemoveLayer(e) {
1174
+ this.logicalLayerExecutor.removeLayer(e), this.core.removeLayer(e);
1175
+ }
1176
+ engineRemoveSource(e) {
1177
+ this.core.removeSource(e);
1178
+ }
1179
+ getCore() {
1180
+ return this.core;
1181
+ }
1182
+ getLogicalLayerExecutor() {
1183
+ return this.logicalLayerExecutor;
1184
+ }
1185
+ getMarkerService() {
1186
+ return this.markerService;
1187
+ }
1188
+ };
1189
+ //#endregion
1190
+ export { x as MapLibreAdapter };