@m3ui-vue/m3ui-vue 1.0.2 → 1.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 (157) hide show
  1. package/dist/API.md +666 -12
  2. package/dist/MMenuItem-BOkcVtEe.js +809 -0
  3. package/dist/MMenuItem-BOkcVtEe.js.map +1 -0
  4. package/dist/MSlider-BXsBv0ox.js +1402 -0
  5. package/dist/MSlider-BXsBv0ox.js.map +1 -0
  6. package/dist/MTextField-rML9jnXs.js +671 -0
  7. package/dist/MTextField-rML9jnXs.js.map +1 -0
  8. package/dist/api.json +1 -1
  9. package/dist/code-editor.js +1 -1
  10. package/dist/components/MBottomSheet.vue.d.ts +20 -1
  11. package/dist/components/MDialog.vue.d.ts +17 -8
  12. package/dist/components/MDragDropList.vue.d.ts +1 -1
  13. package/dist/components/MIconButton.vue.d.ts +1 -1
  14. package/dist/components/MMap.vue.d.ts +74 -0
  15. package/dist/components/MMapBaseLayers.vue.d.ts +15 -0
  16. package/dist/components/MMapControl.vue.d.ts +40 -0
  17. package/dist/components/MMapFeatureInfo.vue.d.ts +25 -0
  18. package/dist/components/MMapFilter.vue.d.ts +19 -0
  19. package/dist/components/MMapGeoJson.vue.d.ts +34 -0
  20. package/dist/components/MMapHover.vue.d.ts +17 -0
  21. package/dist/components/MMapIdentify.vue.d.ts +37 -0
  22. package/dist/components/MMapLayers.vue.d.ts +31 -0
  23. package/dist/components/MMapMarker.vue.d.ts +45 -0
  24. package/dist/components/MMapMeasure.vue.d.ts +43 -0
  25. package/dist/components/MMapPopup.vue.d.ts +45 -0
  26. package/dist/components/MMapSearch.vue.d.ts +28 -0
  27. package/dist/components/MMenuItem.vue.d.ts +2 -2
  28. package/dist/components/MSeekBar.vue.d.ts +122 -0
  29. package/dist/components/MSplitButton.vue.d.ts +2 -2
  30. package/dist/components/_MMapAttribution.vue.d.ts +7 -0
  31. package/dist/components/_MMapLayerItem.vue.d.ts +25 -0
  32. package/dist/composables/_mapGeometry.d.ts +13 -0
  33. package/dist/composables/_mapPin.d.ts +5 -0
  34. package/dist/composables/_popupPosition.d.ts +12 -0
  35. package/dist/composables/_ssrState.d.ts +30 -0
  36. package/dist/composables/_storageKeys.d.ts +3 -0
  37. package/dist/composables/_useCalendarMonth.d.ts +24 -0
  38. package/dist/composables/_useEscapeStack.d.ts +3 -0
  39. package/dist/composables/_useScrollLock.d.ts +8 -0
  40. package/dist/composables/_useSheetMotion.d.ts +16 -1
  41. package/dist/composables/_useThemeTokens.d.ts +7 -0
  42. package/dist/composables/mapAdapters.d.ts +111 -0
  43. package/dist/composables/mapSearch.d.ts +31 -0
  44. package/dist/composables/themeInitScript.d.ts +4 -3
  45. package/dist/composables/useColorPalette.d.ts +173 -7
  46. package/dist/composables/useLocale.d.ts +38 -0
  47. package/dist/composables/useMap.d.ts +47 -0
  48. package/dist/composables/useMapFilter.d.ts +10 -0
  49. package/dist/composables/useMapLayers.d.ts +30 -0
  50. package/dist/composables/useTheme.d.ts +2 -1
  51. package/dist/index.d.ts +4 -1
  52. package/dist/locales/index.js +273 -7
  53. package/dist/locales/index.js.map +1 -1
  54. package/dist/m3ui-vue.css +1 -1
  55. package/dist/m3ui.js +7913 -8625
  56. package/dist/m3ui.js.map +1 -1
  57. package/dist/map.d.ts +24 -0
  58. package/dist/map.js +2067 -0
  59. package/dist/map.js.map +1 -0
  60. package/dist/plugin.d.ts +18 -2
  61. package/dist/rich-text-editor.js +26 -25
  62. package/dist/rich-text-editor.js.map +1 -1
  63. package/dist/styles.css +1 -1
  64. package/dist/{useLocale-CuvWRZ1h.js → useLocale-CqQrhWFl.js} +40 -2
  65. package/dist/useLocale-CqQrhWFl.js.map +1 -0
  66. package/package.json +11 -2
  67. package/src/__tests__/MDialog.test.ts +30 -0
  68. package/src/__tests__/MFab.test.ts +52 -6
  69. package/src/__tests__/MMap.test.ts +422 -0
  70. package/src/__tests__/MMapLayers.test.ts +257 -0
  71. package/src/__tests__/MMapTools.test.ts +233 -0
  72. package/src/__tests__/MSeekBar.test.ts +170 -0
  73. package/src/__tests__/MTooltip.test.ts +110 -0
  74. package/src/__tests__/_fakeMaplibre.ts +161 -0
  75. package/src/__tests__/calendarMonth.test.ts +59 -0
  76. package/src/__tests__/hydration.test.ts +33 -0
  77. package/src/__tests__/pickerModals.test.ts +128 -0
  78. package/src/__tests__/popupPosition.test.ts +224 -0
  79. package/src/__tests__/scrollLock.test.ts +110 -0
  80. package/src/__tests__/sheets.test.ts +158 -0
  81. package/src/__tests__/ssr.test.ts +63 -1
  82. package/src/__tests__/ssrState.test.ts +155 -0
  83. package/src/__tests__/themeInitScript.test.ts +18 -0
  84. package/src/components/MAutocomplete.vue +2 -4
  85. package/src/components/MBottomSheet.vue +211 -13
  86. package/src/components/MCommandPalette.vue +4 -6
  87. package/src/components/MContextMenu.vue +19 -5
  88. package/src/components/MDatePicker.vue +29 -70
  89. package/src/components/MDatePickerModal.vue +116 -172
  90. package/src/components/MDateRangePicker.vue +29 -51
  91. package/src/components/MDateRangePickerModal.vue +84 -162
  92. package/src/components/MDialog.vue +87 -63
  93. package/src/components/MFab.vue +29 -7
  94. package/src/components/MIconButton.vue +1 -1
  95. package/src/components/MLightbox.vue +12 -5
  96. package/src/components/MMap.vue +568 -0
  97. package/src/components/MMapBaseLayers.vue +67 -0
  98. package/src/components/MMapControl.vue +175 -0
  99. package/src/components/MMapFeatureInfo.vue +41 -0
  100. package/src/components/MMapFilter.vue +80 -0
  101. package/src/components/MMapGeoJson.vue +136 -0
  102. package/src/components/MMapHover.vue +131 -0
  103. package/src/components/MMapIdentify.vue +104 -0
  104. package/src/components/MMapLayers.vue +111 -0
  105. package/src/components/MMapMarker.vue +109 -0
  106. package/src/components/MMapMeasure.vue +452 -0
  107. package/src/components/MMapPopup.vue +103 -0
  108. package/src/components/MMapSearch.vue +162 -0
  109. package/src/components/MMenu.vue +31 -12
  110. package/src/components/MMenuItem.vue +21 -4
  111. package/src/components/MMultiAutocomplete.vue +2 -4
  112. package/src/components/MMultiSelect.vue +2 -4
  113. package/src/components/MNavigationDrawer.vue +2 -8
  114. package/src/components/MNavigationRail.vue +2 -3
  115. package/src/components/MSearchBar.vue +2 -5
  116. package/src/components/MSeekBar.vue +593 -0
  117. package/src/components/MSelect.vue +2 -8
  118. package/src/components/MSplitButton.vue +23 -7
  119. package/src/components/MSpotlightSearch.vue +4 -6
  120. package/src/components/MTimePicker.vue +23 -6
  121. package/src/components/MTimePickerModal.vue +213 -226
  122. package/src/components/MTooltip.vue +99 -3
  123. package/src/components/_MMapAttribution.vue +81 -0
  124. package/src/components/_MMapLayerItem.vue +77 -0
  125. package/src/composables/_mapGeometry.ts +75 -0
  126. package/src/composables/_mapPin.ts +25 -0
  127. package/src/composables/_popupPosition.ts +39 -0
  128. package/src/composables/_ssrState.ts +80 -0
  129. package/src/composables/_storageKeys.ts +6 -0
  130. package/src/composables/_useCalendarMonth.ts +74 -0
  131. package/src/composables/_useEscapeStack.ts +33 -0
  132. package/src/composables/_useScrollLock.ts +41 -0
  133. package/src/composables/_useSheetMotion.ts +82 -20
  134. package/src/composables/_useThemeTokens.ts +42 -0
  135. package/src/composables/mapAdapters.ts +208 -0
  136. package/src/composables/mapSearch.ts +56 -0
  137. package/src/composables/themeInitScript.ts +6 -4
  138. package/src/composables/useColorPalette.ts +23 -9
  139. package/src/composables/useLocale.ts +78 -0
  140. package/src/composables/useMap.ts +98 -0
  141. package/src/composables/useMapFilter.ts +45 -0
  142. package/src/composables/useMapLayers.ts +124 -0
  143. package/src/composables/useTheme.ts +8 -3
  144. package/src/composables/useWindowSizeClass.ts +14 -5
  145. package/src/index.ts +4 -1
  146. package/src/locales/de.ts +39 -1
  147. package/src/locales/es.ts +39 -1
  148. package/src/locales/fr.ts +39 -1
  149. package/src/locales/ja.ts +39 -1
  150. package/src/locales/ko.ts +39 -1
  151. package/src/locales/pt.ts +39 -1
  152. package/src/locales/zh.ts +39 -1
  153. package/src/map.ts +32 -0
  154. package/src/plugin.ts +54 -3
  155. package/dist/MTextField-BPbFeI9M.js +0 -1368
  156. package/dist/MTextField-BPbFeI9M.js.map +0 -1
  157. package/dist/useLocale-CuvWRZ1h.js.map +0 -1
package/dist/map.js ADDED
@@ -0,0 +1,2067 @@
1
+ import { a as e, c as t, d as n, i as r, l as i, n as a, p as o, s, t as c, u as l } from "./MSlider-BXsBv0ox.js";
2
+ import { i as u } from "./useLocale-CqQrhWFl.js";
3
+ import { f as d, h as f, n as p, t as m } from "./MTextField-rML9jnXs.js";
4
+ import { t as h } from "./MIcon-DLOkQduI.js";
5
+ import { Fragment as g, Transition as _, computed as v, createBlock as y, createCommentVNode as b, createElementBlock as x, createElementVNode as S, createSlots as C, createTextVNode as w, createVNode as T, defineComponent as E, getCurrentInstance as D, inject as O, markRaw as k, mergeProps as A, normalizeClass as j, normalizeStyle as M, onBeforeUnmount as N, onMounted as P, onUnmounted as ee, openBlock as F, provide as I, reactive as L, ref as R, renderList as z, renderSlot as B, shallowRef as V, toDisplayString as H, unref as U, useId as te, useSlots as ne, watch as W, withCtx as G, withModifiers as K } from "vue";
6
+ //#region src/composables/useMap.ts
7
+ var q = Symbol("m3-map");
8
+ function J() {
9
+ let e = O(q, null);
10
+ if (!e) throw Error("useMap() must be called in a component inside <MMap>");
11
+ let t = [];
12
+ D() && N(() => t.splice(0).forEach((e) => e()));
13
+ function n(n) {
14
+ let r = () => {
15
+ if (e.map.value && e.maplibre.value) return n(e.map.value, e.maplibre.value);
16
+ let r = W(e.map, (t) => {
17
+ t && e.maplibre.value && (r(), n(t, e.maplibre.value));
18
+ });
19
+ t.push(r);
20
+ }, i = D();
21
+ i && !i.isMounted ? P(r) : r();
22
+ }
23
+ function r(e, r) {
24
+ n((n) => {
25
+ n.on(e, r), t.push(() => n.off(e, r));
26
+ });
27
+ }
28
+ function i(e, r, i) {
29
+ n((n) => {
30
+ n.on(e, r, i), t.push(() => n.off(e, r, i));
31
+ });
32
+ }
33
+ return {
34
+ map: v(() => e.map.value),
35
+ maplibre: v(() => e.maplibre.value),
36
+ styleVersion: v(() => e.styleVersion.value),
37
+ activeTool: e.activeTool,
38
+ onReady: n,
39
+ on: r,
40
+ onLayer: i
41
+ };
42
+ }
43
+ //#endregion
44
+ //#region src/components/MMapControl.vue?vue&type=script&setup=true&lang.ts
45
+ var re = { class: "hidden" }, ie = {
46
+ key: 0,
47
+ class: "m3-map-control-panel-in"
48
+ }, ae = /* @__PURE__ */ E({
49
+ inheritAttrs: !1,
50
+ __name: "MMapControl",
51
+ props: {
52
+ position: { default: "top-right" },
53
+ group: {
54
+ type: Boolean,
55
+ default: !0
56
+ },
57
+ expanded: {
58
+ type: Boolean,
59
+ default: !1
60
+ },
61
+ animate: {
62
+ type: Boolean,
63
+ default: !0
64
+ }
65
+ },
66
+ emits: ["update:expanded"],
67
+ setup(e, { emit: r }) {
68
+ let a = e, o = r, s = ne(), c = R(), { onReady: u } = J(), f = R(a.expanded);
69
+ W(() => a.expanded, (e) => {
70
+ f.value = e;
71
+ });
72
+ let p = v(() => f.value && !!s.panel);
73
+ function m(e) {
74
+ e !== f.value && (f.value = e, o("update:expanded", e));
75
+ }
76
+ let h = () => m(!f.value), g = () => m(!1);
77
+ function _(e) {
78
+ p.value && !c.value?.contains(e.target) && g();
79
+ }
80
+ function y(e) {
81
+ e.key === "Escape" && p.value && (g(), e.stopPropagation());
82
+ }
83
+ let b = null, C = null, w = [], T = {
84
+ w: 0,
85
+ h: 0
86
+ }, E = {
87
+ w: 0,
88
+ h: 0
89
+ }, D = null;
90
+ function O() {
91
+ return {
92
+ w: c.value.offsetWidth,
93
+ h: c.value.offsetHeight
94
+ };
95
+ }
96
+ function k() {
97
+ let e = c.value;
98
+ if (!e || C) return;
99
+ let t = O();
100
+ b && (t.w !== b.w || t.h !== b.h) && a.animate && !i() && j(e, b, t), b = t;
101
+ }
102
+ function j(e, r, i) {
103
+ if (T = r, E = i, w = n(0, 1, 0, d.standard.defaultSpatial, .002), e.style.overflow = "hidden", C = t(e, w, (e) => ({
104
+ width: `${r.w + (i.w - r.w) * e}px`,
105
+ height: `${r.h + (i.h - r.h) * e}px`
106
+ })), !C) return M(e);
107
+ C.onfinish = () => M(e);
108
+ }
109
+ function M(e) {
110
+ C?.cancel(), C = null, e.style.overflow = "";
111
+ let t = O();
112
+ t.w !== E.w || t.h !== E.h ? (b = E, k()) : b = t;
113
+ }
114
+ function ee() {
115
+ if (!c.value || !C) return;
116
+ let e = l(w, C.currentTime), t = {
117
+ w: T.w + (E.w - T.w) * e,
118
+ h: T.h + (E.h - T.h) * e
119
+ };
120
+ C.onfinish = null, C.cancel(), C = null, b = t, k();
121
+ }
122
+ W(p, ee, { flush: "post" });
123
+ let I, L = {
124
+ onAdd: () => c.value,
125
+ onRemove: () => c.value?.remove()
126
+ };
127
+ return u((e) => {
128
+ I = e, c.value && e.addControl(L, a.position);
129
+ }), W(() => a.position, (e) => {
130
+ I && c.value && (I.removeControl(L), I.addControl(L, e));
131
+ }), P(() => {
132
+ document.addEventListener("pointerdown", _, !0), !(typeof ResizeObserver > "u" || !c.value) && (D = new ResizeObserver(k), D.observe(c.value));
133
+ }), N(() => {
134
+ document.removeEventListener("pointerdown", _, !0), D?.disconnect(), C?.cancel(), I?.hasControl(L) && I.removeControl(L);
135
+ }), (t, n) => (F(), x("div", re, [S("div", A({
136
+ ref_key: "el",
137
+ ref: c,
138
+ class: ["maplibregl-ctrl m3-map-control", p.value ? "m3-map-control-panel" : e.group ? "maplibregl-ctrl-group" : ""]
139
+ }, t.$attrs, { onKeydown: y }), [p.value ? (F(), x("div", ie, [B(t.$slots, "panel", { close: g })])) : B(t.$slots, "default", {
140
+ expanded: f.value,
141
+ toggle: h
142
+ }, void 0, void 0, 1)], 16)]));
143
+ }
144
+ }), Y = [
145
+ "title",
146
+ "aria-label",
147
+ "aria-expanded"
148
+ ], X = ["innerHTML"], oe = /* @__PURE__ */ E({
149
+ __name: "_MMapAttribution",
150
+ props: { position: {} },
151
+ setup(e) {
152
+ let t = e, n = u(), { on: r, onReady: i } = J(), a = R([]), o = R(!0), s = R(0), c;
153
+ function l() {
154
+ if (!c) return;
155
+ let e = c.getStyle?.();
156
+ if (!e?.sources) return;
157
+ let t = new Set(e.layers?.map((e) => e.source).filter(Boolean)), n = [];
158
+ for (let [r, i] of Object.entries(e.sources)) {
159
+ if (t.size && !t.has(r)) continue;
160
+ let e = c.getSource(r)?.attribution ?? i.attribution;
161
+ e && !n.includes(e) && n.push(e);
162
+ }
163
+ let r = n.filter((e) => !n.some((t) => t !== e && t.includes(e)));
164
+ r.join("\n") !== a.value.join("\n") && (a.value = r), s.value = Math.max(0, c.getContainer().clientWidth - 20);
165
+ }
166
+ i((e) => {
167
+ c = e, l();
168
+ }), r("styledata", l), r("sourcedata", l), r("resize", l), r("dragstart", () => {
169
+ o.value = !1;
170
+ });
171
+ let d = v(() => a.value.join(" ")), f = v(() => t.position.endsWith("right"));
172
+ return (t, r) => d.value ? (F(), y(ae, {
173
+ key: 0,
174
+ position: e.position,
175
+ group: !1,
176
+ class: j(["m3-map-attrib", o.value ? "m3-map-attrib-open" : ""])
177
+ }, {
178
+ default: G(() => [S("div", {
179
+ class: j(["m3-map-attrib-row", f.value ? "flex-row-reverse" : ""]),
180
+ style: M(s.value ? { maxWidth: `${s.value}px` } : void 0)
181
+ }, [S("button", {
182
+ type: "button",
183
+ class: "m3-map-attrib-button",
184
+ title: U(n).mapToggleAttribution,
185
+ "aria-label": U(n).mapToggleAttribution,
186
+ "aria-expanded": o.value,
187
+ onClick: r[0] ||= (e) => o.value = !o.value
188
+ }, [T(h, {
189
+ name: "info",
190
+ size: 20
191
+ })], 8, Y), o.value ? (F(), x("div", {
192
+ key: 0,
193
+ class: j(["m3-map-attrib-text", f.value ? "pl-3.5" : "pr-3.5"]),
194
+ innerHTML: d.value
195
+ }, null, 10, X)) : b("", !0)], 6)]),
196
+ _: 1
197
+ }, 8, ["position", "class"])) : b("", !0);
198
+ }
199
+ }), se = {
200
+ fill: ["fill-opacity"],
201
+ line: ["line-opacity"],
202
+ circle: ["circle-opacity", "circle-stroke-opacity"],
203
+ symbol: ["icon-opacity", "text-opacity"],
204
+ raster: ["raster-opacity"],
205
+ heatmap: ["heatmap-opacity"],
206
+ "fill-extrusion": ["fill-extrusion-opacity"]
207
+ };
208
+ function ce() {
209
+ return L({
210
+ visible: {},
211
+ opacity: {}
212
+ });
213
+ }
214
+ function le(e, t, n) {
215
+ let r = {}, i = {};
216
+ for (let e of n?.layers ?? []) {
217
+ let n = t.getLayer(e.id);
218
+ if (!n) continue;
219
+ r[e.id] = t.getLayoutProperty(e.id, "visibility") !== "none";
220
+ let a = se[n.type]?.[0], o = a ? t.getPaintProperty(e.id, a) : void 0;
221
+ i[e.id] = typeof o == "number" ? o : 1;
222
+ }
223
+ e.visible = r, e.opacity = i;
224
+ }
225
+ function Z() {
226
+ let e = O(q, null);
227
+ if (!e) throw Error("useMapLayers() must be called in a component inside <MMap>");
228
+ let { map: t, model: n, layerState: r } = e, i = v(() => n.value?.layers ?? []), a = v(() => new Map(i.value.map((e) => [e.id, e])));
229
+ function o(e) {
230
+ return r.visible[e] ?? !0;
231
+ }
232
+ function s(e, n) {
233
+ let i = t.value;
234
+ i?.getLayer(e) && i.setLayoutProperty(e, "visibility", n ? "visible" : "none"), r.visible[e] = n;
235
+ for (let t of a.value.get(e)?.children ?? []) s(t, n);
236
+ }
237
+ function c(e) {
238
+ s(e, !o(e));
239
+ }
240
+ function l(e) {
241
+ return r.opacity[e] ?? 1;
242
+ }
243
+ function u(e, n) {
244
+ let i = t.value, o = i?.getLayer(e);
245
+ if (o) for (let t of se[o.type] ?? []) i.setPaintProperty(e, t, n);
246
+ r.opacity[e] = n;
247
+ for (let t of a.value.get(e)?.children ?? []) u(t, n);
248
+ }
249
+ function d(e) {
250
+ return i.value.filter((t) => t.listed && (e === null ? !t.group || !n.value?.groups.some((e) => e.name === t.group) : t.group === e));
251
+ }
252
+ function f(e) {
253
+ let t = d(e).map((e) => o(e.id));
254
+ return t.length && t.every(Boolean) ? "visible" : t.some(Boolean) ? "partial" : "hidden";
255
+ }
256
+ function p(e, t) {
257
+ for (let n of d(e)) s(n.id, t);
258
+ }
259
+ let m = v(() => i.value.filter((e) => e.base)), h = v(() => m.value.find((e) => o(e.id))?.id ?? null);
260
+ function g(e) {
261
+ for (let t of m.value) s(t.id, t.id === e);
262
+ }
263
+ return {
264
+ model: v(() => n.value),
265
+ layers: i,
266
+ isVisible: o,
267
+ setVisible: s,
268
+ toggle: c,
269
+ opacityOf: l,
270
+ setOpacity: u,
271
+ layersOf: d,
272
+ groupState: f,
273
+ setGroupVisible: p,
274
+ baseLayers: m,
275
+ baseLayer: h,
276
+ setBaseLayer: g
277
+ };
278
+ }
279
+ //#endregion
280
+ //#region src/components/MMap.vue?vue&type=script&setup=true&lang.ts
281
+ var ue = 600, de = /* @__PURE__ */ E({
282
+ __name: "MMap",
283
+ props: {
284
+ mapStyle: {},
285
+ center: {},
286
+ zoom: {},
287
+ bearing: {},
288
+ pitch: {},
289
+ persist: {
290
+ type: [Boolean, String],
291
+ default: !1
292
+ },
293
+ navigation: {
294
+ type: [Boolean, String],
295
+ default: !0
296
+ },
297
+ geolocate: {
298
+ type: [Boolean, String],
299
+ default: !1
300
+ },
301
+ fullscreen: {
302
+ type: [Boolean, String],
303
+ default: !1
304
+ },
305
+ scale: {
306
+ type: [Boolean, String],
307
+ default: !0
308
+ },
309
+ attribution: {
310
+ type: [Boolean, String],
311
+ default: !0
312
+ },
313
+ options: {},
314
+ adapter: {}
315
+ },
316
+ emits: [
317
+ "ready",
318
+ "click",
319
+ "update:center",
320
+ "update:zoom",
321
+ "update:bearing",
322
+ "update:pitch"
323
+ ],
324
+ setup(e, { expose: t, emit: n }) {
325
+ let r = e, i = n, a = R(), o = R(), s = V(), c = V(), l = R(0), d = V(), f = ce(), p = R(null);
326
+ I(q, {
327
+ map: s,
328
+ maplibre: c,
329
+ styleVersion: l,
330
+ model: d,
331
+ layerState: f,
332
+ activeTool: p
333
+ });
334
+ function m(e) {
335
+ d.value = r.adapter ? r.adapter(e.getStyle(), { styleUrl: typeof r.mapStyle == "string" ? r.mapStyle : void 0 }) : void 0, le(f, e, d.value);
336
+ }
337
+ let h = u(), g = () => typeof r.persist == "string" ? r.persist : r.persist ? "m3-map-view" : null;
338
+ function v() {
339
+ let e = g();
340
+ if (!e) return {};
341
+ try {
342
+ let t = JSON.parse(localStorage.getItem(e) ?? "null");
343
+ return t && typeof t == "object" ? t : {};
344
+ } catch {
345
+ return {};
346
+ }
347
+ }
348
+ function C(e) {
349
+ let t = e.getCenter();
350
+ return {
351
+ center: [t.lng, t.lat],
352
+ zoom: e.getZoom(),
353
+ bearing: e.getBearing(),
354
+ pitch: e.getPitch()
355
+ };
356
+ }
357
+ let w = {
358
+ navigation: {
359
+ corner: "top-right",
360
+ create: (e) => new e.NavigationControl()
361
+ },
362
+ geolocate: {
363
+ corner: "top-right",
364
+ create: (e) => new e.GeolocateControl({
365
+ positionOptions: { enableHighAccuracy: !0 },
366
+ trackUserLocation: !0
367
+ })
368
+ },
369
+ fullscreen: {
370
+ corner: "top-right",
371
+ create: (e) => new e.FullscreenControl({ container: a.value })
372
+ },
373
+ scale: {
374
+ corner: "bottom-left",
375
+ create: (e) => new e.ScaleControl({
376
+ maxWidth: 100,
377
+ unit: "metric"
378
+ })
379
+ }
380
+ }, E = /* @__PURE__ */ new Map();
381
+ function D(e) {
382
+ let t = s.value, n = c.value;
383
+ if (!t || !n) return;
384
+ let i = E.get(e);
385
+ i && (t.removeControl(i), E.delete(e));
386
+ let a = r[e];
387
+ if (!a) return;
388
+ let o = w[e].create(n);
389
+ t.addControl(o, a === !0 ? w[e].corner : a), E.set(e, o);
390
+ }
391
+ for (let e of Object.keys(w)) W(() => r[e], () => D(e));
392
+ function O() {
393
+ return {
394
+ "AttributionControl.ToggleAttribution": h.mapToggleAttribution,
395
+ "AttributionControl.MapFeedback": h.mapFeedback,
396
+ "FullscreenControl.Enter": h.mapEnterFullscreen,
397
+ "FullscreenControl.Exit": h.mapExitFullscreen,
398
+ "GeolocateControl.FindMyLocation": h.mapFindMyLocation,
399
+ "GeolocateControl.LocationNotAvailable": h.mapLocationNotAvailable,
400
+ "Map.Title": h.mapTitle,
401
+ "Marker.Title": h.mapMarker,
402
+ "NavigationControl.ResetBearing": h.mapResetBearing,
403
+ "NavigationControl.ZoomIn": h.mapZoomIn,
404
+ "NavigationControl.ZoomOut": h.mapZoomOut,
405
+ "Popup.Close": h.close,
406
+ "CooperativeGesturesHandler.WindowsHelpText": h.mapCtrlScroll,
407
+ "CooperativeGesturesHandler.MacHelpText": h.mapCmdScroll,
408
+ "CooperativeGesturesHandler.MobileHelpText": h.mapTwoFingers
409
+ };
410
+ }
411
+ let A = R(null), L, z;
412
+ function U(e) {
413
+ let t = e.getAttribute("title");
414
+ t && e.closest(".maplibregl-ctrl") && (e.setAttribute("data-m3-tip", t), e.hasAttribute("aria-label") || e.setAttribute("aria-label", t), e.removeAttribute("title"));
415
+ }
416
+ function te(e) {
417
+ let t = e.getAttribute("data-m3-tip"), n = a.value?.getBoundingClientRect();
418
+ if (!t || !n) return;
419
+ let r = e.getBoundingClientRect(), i = r.left + r.width / 2 > n.left + n.width / 2;
420
+ A.value = {
421
+ text: t,
422
+ left: i,
423
+ x: (i ? r.left - 8 : r.right + 8) - n.left,
424
+ y: r.top + r.height / 2 - n.top
425
+ };
426
+ }
427
+ function ne() {
428
+ clearTimeout(L), A.value = null;
429
+ }
430
+ let K = (e) => e.target?.closest?.(".maplibregl-ctrl [data-m3-tip]") ?? null;
431
+ function J(e) {
432
+ let t = K(e);
433
+ t && e.pointerType !== "touch" && (clearTimeout(L), L = setTimeout(() => te(t), ue));
434
+ }
435
+ function re(e) {
436
+ let t = K(e);
437
+ t && !t.contains(e.relatedTarget) && ne();
438
+ }
439
+ function ie(e) {
440
+ let t = K(e);
441
+ t?.matches(":focus-visible") && te(t);
442
+ }
443
+ P(() => {
444
+ let e = a.value;
445
+ e && (e.querySelectorAll("[title]").forEach(U), z = new MutationObserver((e) => {
446
+ for (let t of e) t.type === "attributes" ? U(t.target) : t.addedNodes.forEach((e) => {
447
+ e instanceof Element && (U(e), e.querySelectorAll("[title]").forEach(U));
448
+ });
449
+ }), z.observe(e, {
450
+ subtree: !0,
451
+ childList: !0,
452
+ attributes: !0,
453
+ attributeFilter: ["title"]
454
+ }));
455
+ }), N(() => {
456
+ z?.disconnect(), clearTimeout(L);
457
+ });
458
+ let ae = !1;
459
+ P(async () => {
460
+ let e = await import("maplibre-gl"), t = "Map" in e ? e : e.default;
461
+ if (ae || !o.value) return;
462
+ let n = v(), a = {
463
+ center: n.center ?? r.center,
464
+ zoom: n.zoom ?? r.zoom,
465
+ bearing: n.bearing ?? r.bearing,
466
+ pitch: n.pitch ?? r.pitch
467
+ }, u = k(new t.Map({
468
+ container: o.value,
469
+ style: r.mapStyle,
470
+ attributionControl: !1,
471
+ locale: O(),
472
+ ...Object.fromEntries(Object.entries(a).filter(([, e]) => e !== void 0)),
473
+ ...r.options
474
+ }));
475
+ c.value = t, u.on("style.load", () => {
476
+ m(u), l.value++;
477
+ }), u.on("click", (e) => i("click", e)), u.on("moveend", () => {
478
+ let e = C(u);
479
+ i("update:center", e.center), i("update:zoom", e.zoom), i("update:bearing", e.bearing), i("update:pitch", e.pitch);
480
+ let t = g();
481
+ if (t) try {
482
+ localStorage.setItem(t, JSON.stringify(e));
483
+ } catch {}
484
+ }), u.once("load", () => {
485
+ s.value = u;
486
+ for (let e of Object.keys(w)) D(e);
487
+ i("ready", u);
488
+ });
489
+ }), ee(() => {
490
+ ae = !0, s.value?.remove(), s.value = void 0;
491
+ });
492
+ let Y = (e, t) => Math.abs(e - t) < 1e-9;
493
+ return W(() => r.center?.join(","), () => {
494
+ let e = s.value;
495
+ if (!e || !r.center) return;
496
+ let t = e.getCenter();
497
+ (!Y(t.lng, r.center[0]) || !Y(t.lat, r.center[1])) && e.jumpTo({ center: r.center });
498
+ }), W(() => r.zoom, (e) => {
499
+ s.value && e !== void 0 && !Y(s.value.getZoom(), e) && s.value.jumpTo({ zoom: e });
500
+ }), W(() => r.bearing, (e) => {
501
+ s.value && e !== void 0 && !Y(s.value.getBearing(), e) && s.value.jumpTo({ bearing: e });
502
+ }), W(() => r.pitch, (e) => {
503
+ s.value && e !== void 0 && !Y(s.value.getPitch(), e) && s.value.jumpTo({ pitch: e });
504
+ }), W(() => r.adapter, () => {
505
+ s.value && m(s.value);
506
+ }), W(() => r.mapStyle, (e) => s.value?.setStyle(e, { diff: !1 })), t({ map: s }), (t, n) => (F(), x("div", {
507
+ ref_key: "root",
508
+ ref: a,
509
+ class: "m3-map relative overflow-hidden",
510
+ onPointerover: J,
511
+ onPointerout: re,
512
+ onPointerdown: ne,
513
+ onFocusin: ie,
514
+ onFocusout: ne
515
+ }, [
516
+ S("div", {
517
+ ref_key: "container",
518
+ ref: o,
519
+ class: "h-full w-full"
520
+ }, null, 512),
521
+ s.value && e.attribution ? (F(), y(oe, {
522
+ key: 0,
523
+ position: e.attribution === !0 ? "bottom-right" : e.attribution
524
+ }, null, 8, ["position"])) : b("", !0),
525
+ s.value ? B(t.$slots, "default", {}, void 0, void 0, 1) : b("", !0),
526
+ T(_, {
527
+ "enter-active-class": "transition-opacity duration-150",
528
+ "enter-from-class": "opacity-0",
529
+ "leave-active-class": "transition-opacity duration-100",
530
+ "leave-to-class": "opacity-0"
531
+ }, {
532
+ default: G(() => [A.value ? (F(), x("div", {
533
+ key: 0,
534
+ role: "tooltip",
535
+ class: j(["pointer-events-none absolute z-10 min-h-6 max-w-[200px] -translate-y-1/2 rounded bg-inverse-surface px-2 py-1 text-body-small whitespace-nowrap text-inverse-on-surface", A.value.left ? "-translate-x-full" : ""]),
536
+ style: M({
537
+ left: `${A.value.x}px`,
538
+ top: `${A.value.y}px`
539
+ })
540
+ }, H(A.value.text), 7)) : b("", !0)]),
541
+ _: 1
542
+ })
543
+ ], 544));
544
+ }
545
+ }), fe = 13.5, pe = fe / Math.SQRT2, me = [0, -14], he = {
546
+ center: [0, 0],
547
+ top: [0, 0],
548
+ "top-left": [0, 0],
549
+ "top-right": [0, 0],
550
+ bottom: [0, -38.1],
551
+ "bottom-left": [pe, (24.6 + pe) * -1],
552
+ "bottom-right": [-pe, (24.6 + pe) * -1],
553
+ left: [fe, -24.6],
554
+ right: [-13.5, -24.6]
555
+ }, ge = { class: "hidden" }, _e = /* @__PURE__ */ E({
556
+ inheritAttrs: !1,
557
+ __name: "MMapMarker",
558
+ props: {
559
+ lngLat: {},
560
+ color: {},
561
+ draggable: {
562
+ type: Boolean,
563
+ default: !1
564
+ },
565
+ anchor: {},
566
+ offset: {},
567
+ rotation: { default: 0 }
568
+ },
569
+ emits: ["update:lngLat", "click"],
570
+ setup(e, { expose: t, emit: n }) {
571
+ let r = e, i = n, a = ne(), o = R(), s = R(), { onReady: c } = J(), l, u = !1;
572
+ c((e, t) => {
573
+ u = !!a.default && !!o.value, l = new t.Marker({
574
+ ...u ? { element: o.value } : { color: r.color ?? "currentColor" },
575
+ draggable: r.draggable,
576
+ ...r.anchor ? { anchor: r.anchor } : u ? { anchor: "center" } : {},
577
+ ...r.offset ? { offset: r.offset } : {},
578
+ rotation: r.rotation
579
+ }), !u && !r.color && l.getElement().classList.add("m3-map-marker--default"), l.setLngLat(r.lngLat).addTo(e), l.getElement().addEventListener("click", d), l.on("dragend", () => {
580
+ let { lng: e, lat: t } = l.getLngLat();
581
+ i("update:lngLat", [e, t]);
582
+ }), a.popup && s.value && l.setPopup(new t.Popup({
583
+ ...u ? { offset: 16 } : {},
584
+ maxWidth: "320px"
585
+ }).setDOMContent(s.value));
586
+ });
587
+ function d(e) {
588
+ i("click", e);
589
+ }
590
+ return W(() => r.lngLat.join(","), () => l?.setLngLat(r.lngLat)), W(() => r.draggable, (e) => l?.setDraggable(e)), W(() => r.rotation, (e) => l?.setRotation(e)), W(() => r.offset?.join(","), () => l?.setOffset(r.offset ?? (u ? [0, 0] : me))), N(() => {
591
+ l?.getElement().removeEventListener("click", d), l?.getPopup()?.remove(), l?.remove();
592
+ }), t({ marker: () => l }), (e, t) => (F(), x("div", ge, [e.$slots.default ? (F(), x("div", A({
593
+ key: 0,
594
+ ref_key: "content",
595
+ ref: o,
596
+ class: "m3-map-marker"
597
+ }, e.$attrs), [B(e.$slots, "default")], 16)) : b("", !0), e.$slots.popup ? (F(), x("div", {
598
+ key: 1,
599
+ ref_key: "popupContent",
600
+ ref: s
601
+ }, [B(e.$slots, "popup")], 512)) : b("", !0)]));
602
+ }
603
+ }), ve = { class: "hidden" }, ye = /* @__PURE__ */ E({
604
+ inheritAttrs: !1,
605
+ __name: "MMapPopup",
606
+ props: {
607
+ lngLat: {},
608
+ open: {
609
+ type: Boolean,
610
+ default: !0
611
+ },
612
+ closeButton: {
613
+ type: Boolean,
614
+ default: !0
615
+ },
616
+ closeOnClick: {
617
+ type: Boolean,
618
+ default: !0
619
+ },
620
+ anchor: {},
621
+ offset: {},
622
+ maxWidth: { default: "320px" }
623
+ },
624
+ emits: ["update:open"],
625
+ setup(e, { expose: t, emit: n }) {
626
+ let r = e, i = n, a = R(), { onReady: o } = J(), s, c, l = !1;
627
+ function u() {
628
+ s && c && !s.isOpen() && s.setLngLat(r.lngLat).addTo(c);
629
+ }
630
+ return o((e, t) => {
631
+ c = e, s = new t.Popup({
632
+ closeButton: r.closeButton,
633
+ closeOnClick: r.closeOnClick,
634
+ closeOnMove: !1,
635
+ anchor: r.anchor,
636
+ ...r.offset === void 0 ? {} : { offset: r.offset },
637
+ maxWidth: r.maxWidth,
638
+ focusAfterOpen: !1
639
+ }), a.value && s.setDOMContent(a.value), s.on("close", () => {
640
+ l || i("update:open", !1);
641
+ }), r.open && u();
642
+ }), W(() => r.open, (e) => {
643
+ e ? u() : s?.isOpen() && (l = !0, s.remove(), l = !1);
644
+ }), W(() => r.lngLat.join(","), () => s?.setLngLat(r.lngLat)), W(() => r.maxWidth, (e) => s?.setMaxWidth(e)), W(() => r.offset, (e) => s?.setOffset(e ?? 0)), N(() => {
645
+ l = !0, s?.remove();
646
+ }), t({ popup: () => s }), (e, t) => (F(), x("div", ve, [S("div", A({
647
+ ref_key: "content",
648
+ ref: a
649
+ }, e.$attrs), [B(e.$slots, "default")], 16)]));
650
+ }
651
+ });
652
+ //#endregion
653
+ //#region src/composables/_useThemeTokens.ts
654
+ function be(e) {
655
+ let t = () => {
656
+ let t = getComputedStyle(document.documentElement);
657
+ return Object.fromEntries(e.map((e) => [e, t.getPropertyValue(`--color-${e}`).trim()]));
658
+ }, n = R(typeof document > "u" ? Object.fromEntries(e.map((e) => [e, ""])) : t()), r, i;
659
+ return P(() => {
660
+ let a = () => {
661
+ let r = t();
662
+ e.some((e) => r[e] !== n.value[e]) && (n.value = r);
663
+ }, s = (e) => (e instanceof Element ? e : e?.parentElement)?.id === o;
664
+ r = new MutationObserver((e) => {
665
+ e.some((e) => e.target === document.documentElement || s(e.target) || Array.from(e.addedNodes).some(s)) && (a(), clearTimeout(i), i = setTimeout(a, 300));
666
+ }), r.observe(document.documentElement, {
667
+ attributes: !0,
668
+ attributeFilter: [
669
+ "class",
670
+ "style",
671
+ "data-palette",
672
+ "data-contrast"
673
+ ]
674
+ }), r.observe(document.head, {
675
+ childList: !0,
676
+ characterData: !0,
677
+ subtree: !0
678
+ });
679
+ }), N(() => {
680
+ r?.disconnect(), clearTimeout(i);
681
+ }), n;
682
+ }
683
+ //#endregion
684
+ //#region src/components/MMapGeoJson.vue
685
+ var xe = /* @__PURE__ */ E({
686
+ inheritAttrs: !1,
687
+ __name: "MMapGeoJson",
688
+ props: {
689
+ data: {},
690
+ id: {},
691
+ layers: {},
692
+ before: {},
693
+ interactive: {
694
+ type: Boolean,
695
+ default: !1
696
+ },
697
+ sourceOptions: {}
698
+ },
699
+ emits: ["click"],
700
+ setup(e, { expose: t, emit: n }) {
701
+ let r = e, i = n, a = r.id ?? `m3-geojson-${te()}`, { onReady: o, styleVersion: s } = J(), c = be(["primary", "surface"]), l = (...e) => [
702
+ "match",
703
+ ["geometry-type"],
704
+ e,
705
+ !0,
706
+ !1
707
+ ], u = v(() => {
708
+ let { primary: e, surface: t } = c.value;
709
+ return [
710
+ {
711
+ id: `${a}-fill`,
712
+ type: "fill",
713
+ filter: l("Polygon", "MultiPolygon"),
714
+ paint: {
715
+ "fill-color": e,
716
+ "fill-opacity": .24
717
+ }
718
+ },
719
+ {
720
+ id: `${a}-line`,
721
+ type: "line",
722
+ filter: l("Polygon", "MultiPolygon", "LineString", "MultiLineString"),
723
+ paint: {
724
+ "line-color": e,
725
+ "line-width": 2
726
+ }
727
+ },
728
+ {
729
+ id: `${a}-circle`,
730
+ type: "circle",
731
+ filter: l("Point", "MultiPoint"),
732
+ paint: {
733
+ "circle-color": e,
734
+ "circle-radius": 6,
735
+ "circle-stroke-color": t,
736
+ "circle-stroke-width": 2
737
+ }
738
+ }
739
+ ];
740
+ }), d = v(() => (r.layers ?? u.value).map((e, t) => ({
741
+ ...e,
742
+ id: e.id ?? `${a}-${t}`,
743
+ source: a
744
+ }))), f, p = [], m = (e) => i("click", e), h = () => {
745
+ r.interactive && f && (f.getCanvas().style.cursor = "pointer");
746
+ }, g = () => {
747
+ r.interactive && f && (f.getCanvas().style.cursor = "");
748
+ };
749
+ function _() {
750
+ if (f) {
751
+ for (let e of p) f.off("click", e, m), f.off("mouseenter", e, h), f.off("mouseleave", e, g), f.getLayer(e) && f.removeLayer(e);
752
+ p = [];
753
+ }
754
+ }
755
+ function y() {
756
+ if (f) {
757
+ _();
758
+ for (let e of d.value) f.addLayer(e, r.before && f.getLayer(r.before) ? r.before : void 0), f.on("click", e.id, m), f.on("mouseenter", e.id, h), f.on("mouseleave", e.id, g), p.push(e.id);
759
+ }
760
+ }
761
+ function b() {
762
+ f && (f.getSource(a) || (f.addSource(a, {
763
+ type: "geojson",
764
+ data: r.data,
765
+ ...r.sourceOptions
766
+ }), p = []), (!p.length || !f.getLayer(p[0])) && y());
767
+ }
768
+ return o((e) => {
769
+ f = e, b();
770
+ }), W(s, () => b()), W(() => r.data, (e) => (f?.getSource(a))?.setData(e)), W(() => JSON.stringify(d.value), () => y()), W(() => r.before, () => y()), N(() => {
771
+ f &&= (_(), f.getSource(a) && f.removeSource(a), void 0);
772
+ }), t({
773
+ sourceId: a,
774
+ layerIds: () => [...p]
775
+ }), (e, t) => null;
776
+ }
777
+ }), Q = { class: "flex min-w-0 flex-1 flex-col" }, Se = ["aria-label", "aria-pressed"], Ce = { class: "flex min-w-0 flex-1 flex-col" }, we = {
778
+ key: 0,
779
+ class: "truncate text-label-small text-on-surface-variant"
780
+ }, Te = {
781
+ key: 0,
782
+ class: "rounded-full bg-primary/8 px-2 py-0.5 text-label-small tabular-nums text-primary"
783
+ }, Ee = { class: "min-h-0 overflow-hidden" }, De = { class: "flex flex-col gap-3 px-3 pb-3" }, Oe = {
784
+ key: 0,
785
+ class: "text-body-small text-on-surface-variant"
786
+ }, ke = { class: "flex items-center gap-2 rounded-2xl bg-surface-container-highest/60 px-3 py-1" }, Ae = ["src"], je = {
787
+ key: 2,
788
+ class: "flex flex-wrap items-center gap-2"
789
+ }, Me = ["href"], Ne = /* @__PURE__ */ E({
790
+ __name: "_MMapLayerItem",
791
+ props: {
792
+ layer: {},
793
+ expanded: { type: Boolean }
794
+ },
795
+ emits: ["toggle-expanded"],
796
+ setup(e, { emit: t }) {
797
+ let n = t, r = u(), { isVisible: i, toggle: a, opacityOf: o, setOpacity: s } = Z();
798
+ return (t, l) => (F(), x("div", { class: j(["flex overflow-hidden rounded-2xl bg-surface-container", U(i)(e.layer.id) ? "" : "opacity-75"]) }, [S("div", { class: j(["w-1 shrink-0 transition-colors duration-200", U(i)(e.layer.id) ? "bg-primary" : "bg-outline-variant"]) }, null, 2), S("div", Q, [S("div", {
799
+ class: "flex cursor-pointer items-center gap-2 px-3 py-2",
800
+ onClick: l[1] ||= (e) => n("toggle-expanded")
801
+ }, [
802
+ S("button", {
803
+ type: "button",
804
+ class: j(["grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200", U(i)(e.layer.id) ? "bg-primary/12 text-primary" : "bg-on-surface/5 text-on-surface-variant"]),
805
+ "aria-label": U(i)(e.layer.id) ? U(r).mapHideLayer : U(r).mapShowLayer,
806
+ "aria-pressed": U(i)(e.layer.id),
807
+ onClick: l[0] ||= K((t) => U(a)(e.layer.id), ["stop"])
808
+ }, [T(h, {
809
+ name: U(i)(e.layer.id) ? "visibility" : "visibility_off",
810
+ size: 18
811
+ }, null, 8, ["name"])], 10, Se),
812
+ S("div", Ce, [S("span", { class: j(["truncate text-body-medium", U(i)(e.layer.id) ? "text-on-surface" : "text-on-surface-variant"]) }, H(e.layer.title), 3), e.layer.description && !e.expanded ? (F(), x("span", we, H(e.layer.description), 1)) : b("", !0)]),
813
+ U(i)(e.layer.id) && U(o)(e.layer.id) < 1 ? (F(), x("span", Te, H(Math.round(U(o)(e.layer.id) * 100)) + "% ", 1)) : b("", !0),
814
+ T(h, {
815
+ name: "expand_more",
816
+ size: 18,
817
+ class: j(["shrink-0 text-on-surface-variant transition-transform duration-300", e.expanded ? "rotate-180" : ""])
818
+ }, null, 8, ["class"])
819
+ ]), S("div", {
820
+ class: "grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]",
821
+ style: M({ gridTemplateRows: e.expanded ? "1fr" : "0fr" })
822
+ }, [S("div", Ee, [S("div", De, [
823
+ e.layer.description ? (F(), x("p", Oe, H(e.layer.description), 1)) : b("", !0),
824
+ S("div", ke, [T(h, {
825
+ name: "opacity",
826
+ size: 16,
827
+ class: "shrink-0 text-on-surface-variant"
828
+ }), T(c, {
829
+ "model-value": U(o)(e.layer.id),
830
+ min: 0,
831
+ max: 1,
832
+ step: .01,
833
+ label: U(r).mapOpacity,
834
+ class: "flex-1",
835
+ "onUpdate:modelValue": l[2] ||= (t) => U(s)(e.layer.id, Number(t))
836
+ }, null, 8, ["model-value", "label"])]),
837
+ e.layer.legend ? (F(), x("img", {
838
+ key: 1,
839
+ src: e.layer.legend,
840
+ alt: "",
841
+ class: "max-w-full self-start",
842
+ loading: "lazy"
843
+ }, null, 8, Ae)) : b("", !0),
844
+ e.layer.download || t.$slots.actions ? (F(), x("div", je, [e.layer.download ? (F(), x("a", {
845
+ key: 0,
846
+ href: e.layer.download,
847
+ target: "_blank",
848
+ rel: "noopener",
849
+ download: "",
850
+ class: "inline-flex items-center gap-1 rounded-full px-3 py-1.5 text-label-large text-primary hover:bg-primary/8"
851
+ }, [T(h, {
852
+ name: "download",
853
+ size: 18
854
+ }), w(" " + H(U(r).mapDownload), 1)], 8, Me)) : b("", !0), B(t.$slots, "actions", {
855
+ layer: e.layer,
856
+ visible: U(i)(e.layer.id)
857
+ })])) : b("", !0)
858
+ ])])], 4)])], 2));
859
+ }
860
+ }), Pe = { class: "flex flex-col gap-3" }, Fe = ["onClick"], Ie = [
861
+ "aria-label",
862
+ "aria-pressed",
863
+ "onClick"
864
+ ], Le = { class: "flex-1 select-none truncate text-label-large text-on-surface" }, Re = { class: "rounded-full bg-surface-container-highest px-2 py-0.5 text-label-small tabular-nums text-on-surface-variant" }, ze = {
865
+ key: 1,
866
+ class: "flex flex-col gap-1.5"
867
+ }, Be = {
868
+ key: 2,
869
+ class: "flex flex-col items-center gap-3 py-8"
870
+ }, Ve = { class: "grid size-14 place-items-center rounded-full bg-surface-container-highest" }, He = { class: "text-body-medium text-on-surface-variant" }, Ue = /* @__PURE__ */ E({
871
+ __name: "MMapLayers",
872
+ props: {
873
+ search: {
874
+ type: Boolean,
875
+ default: !0
876
+ },
877
+ collapsed: {
878
+ type: Boolean,
879
+ default: !1
880
+ }
881
+ },
882
+ setup(e) {
883
+ let t = e, n = u(), { model: r, layersOf: i, isVisible: a, groupState: o, setGroupVisible: s } = Z(), c = R(""), l = (e) => !c.value || e.title.toLowerCase().includes(c.value.toLowerCase()), d = v(() => (r.value?.groups ?? []).map((e) => ({
884
+ ...e,
885
+ all: i(e.name),
886
+ layers: i(e.name).filter(l)
887
+ })).filter((e) => e.layers.length)), f = v(() => i(null).filter(l)), p = R(/* @__PURE__ */ new Set()), _ = (e) => p.value.has(e) === t.collapsed;
888
+ function w(e) {
889
+ let t = new Set(p.value);
890
+ t.delete(e) || t.add(e), p.value = t;
891
+ }
892
+ let E = R(/* @__PURE__ */ new Set());
893
+ function D(e) {
894
+ let t = new Set(E.value);
895
+ t.delete(e) || t.add(e), E.value = t;
896
+ }
897
+ let O = (e) => e.filter((e) => a(e.id)).length;
898
+ return (t, r) => (F(), x("div", Pe, [
899
+ e.search ? (F(), y(m, {
900
+ key: 0,
901
+ modelValue: c.value,
902
+ "onUpdate:modelValue": r[0] ||= (e) => c.value = e,
903
+ label: U(n).mapSearchLayers,
904
+ "leading-icon": "search",
905
+ variant: "outlined",
906
+ clearable: ""
907
+ }, null, 8, ["modelValue", "label"])) : b("", !0),
908
+ (F(!0), x(g, null, z(d.value, (e) => (F(), x("section", {
909
+ key: e.name,
910
+ class: "flex flex-col"
911
+ }, [S("div", {
912
+ class: "m3-map-layers-row flex cursor-pointer items-center gap-2 rounded-xl px-2 py-1.5",
913
+ onClick: (t) => w(e.name)
914
+ }, [
915
+ S("button", {
916
+ type: "button",
917
+ class: j(["grid size-8 shrink-0 cursor-pointer place-items-center rounded-full transition-colors duration-200", U(o)(e.name) === "visible" ? "bg-primary-container text-on-primary-container" : U(o)(e.name) === "partial" ? "bg-secondary-container text-on-secondary-container" : "bg-on-surface/8 text-on-surface-variant"]),
918
+ "aria-label": U(o)(e.name) === "hidden" ? U(n).mapShowLayer : U(n).mapHideLayer,
919
+ "aria-pressed": U(o)(e.name) !== "hidden",
920
+ onClick: K((t) => U(s)(e.name, U(o)(e.name) !== "visible"), ["stop"])
921
+ }, [T(h, {
922
+ name: U(o)(e.name) === "hidden" ? "visibility_off" : "visibility",
923
+ size: 18
924
+ }, null, 8, ["name"])], 10, Ie),
925
+ S("span", Le, H(e.title), 1),
926
+ S("span", Re, H(O(e.all)) + "/" + H(e.all.length), 1),
927
+ T(h, {
928
+ name: "expand_more",
929
+ size: 18,
930
+ class: j(["text-on-surface-variant transition-transform duration-300", _(e.name) ? "rotate-180" : ""])
931
+ }, null, 8, ["class"])
932
+ ], 8, Fe), S("div", {
933
+ class: "grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.2,0,0,1)]",
934
+ style: M({ gridTemplateRows: _(e.name) ? "1fr" : "0fr" })
935
+ }, [S("div", { class: j(["flex min-h-0 flex-col gap-1.5 overflow-hidden", _(e.name) ? "pt-1.5" : ""]) }, [(F(!0), x(g, null, z(e.layers, (e) => (F(), y(Ne, {
936
+ key: e.id,
937
+ layer: e,
938
+ expanded: E.value.has(e.id),
939
+ onToggleExpanded: (t) => D(e.id)
940
+ }, C({ _: 2 }, [t.$slots.actions ? {
941
+ name: "actions",
942
+ fn: G((e) => [B(t.$slots, "actions", A({ ref_for: !0 }, e))]),
943
+ key: "0"
944
+ } : void 0]), 1032, [
945
+ "layer",
946
+ "expanded",
947
+ "onToggleExpanded"
948
+ ]))), 128))], 2)], 4)]))), 128)),
949
+ f.value.length ? (F(), x("div", ze, [(F(!0), x(g, null, z(f.value, (e) => (F(), y(Ne, {
950
+ key: e.id,
951
+ layer: e,
952
+ expanded: E.value.has(e.id),
953
+ onToggleExpanded: (t) => D(e.id)
954
+ }, C({ _: 2 }, [t.$slots.actions ? {
955
+ name: "actions",
956
+ fn: G((e) => [B(t.$slots, "actions", A({ ref_for: !0 }, e))]),
957
+ key: "0"
958
+ } : void 0]), 1032, [
959
+ "layer",
960
+ "expanded",
961
+ "onToggleExpanded"
962
+ ]))), 128))])) : b("", !0),
963
+ !d.value.length && !f.value.length ? (F(), x("div", Be, [S("div", Ve, [T(h, {
964
+ name: "layers_clear",
965
+ size: 28,
966
+ class: "text-on-surface-variant"
967
+ })]), S("p", He, H(U(n).mapNoLayers), 1)])) : b("", !0)
968
+ ]));
969
+ }
970
+ }), We = [
971
+ "title",
972
+ "aria-label",
973
+ "aria-checked",
974
+ "onClick"
975
+ ], Ge = ["src"], Ke = [
976
+ "title",
977
+ "aria-label",
978
+ "aria-checked"
979
+ ], qe = /* @__PURE__ */ E({
980
+ __name: "MMapBaseLayers",
981
+ props: {
982
+ imageBase: { default: "" },
983
+ none: {
984
+ type: Boolean,
985
+ default: !0
986
+ },
987
+ vertical: {
988
+ type: Boolean,
989
+ default: !1
990
+ }
991
+ },
992
+ setup(e) {
993
+ let t = u(), { baseLayers: n, baseLayer: r, setBaseLayer: i } = Z(), a = (e, t) => /^(https?:|data:|\/\/)/.test(e) ? e : `${t}${e}`;
994
+ return (o, s) => (F(), x("div", {
995
+ class: j(["flex gap-2", e.vertical ? "flex-col" : "flex-row flex-wrap"]),
996
+ role: "radiogroup"
997
+ }, [(F(!0), x(g, null, z(U(n), (t) => (F(), x("button", {
998
+ key: t.id,
999
+ type: "button",
1000
+ role: "radio",
1001
+ class: j(["m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center overflow-hidden rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110", U(r) === t.id ? "m3-map-base--active border-primary" : "border-transparent"]),
1002
+ title: t.title,
1003
+ "aria-label": t.title,
1004
+ "aria-checked": U(r) === t.id,
1005
+ onClick: (e) => U(i)(t.id)
1006
+ }, [t.base?.image ? (F(), x("img", {
1007
+ key: 0,
1008
+ src: a(t.base.image, e.imageBase),
1009
+ alt: "",
1010
+ class: "size-full object-cover"
1011
+ }, null, 8, Ge)) : (F(), y(h, {
1012
+ key: 1,
1013
+ name: "map",
1014
+ size: 22,
1015
+ class: "text-on-surface-variant"
1016
+ }))], 10, We))), 128)), e.none ? (F(), x("button", {
1017
+ key: 0,
1018
+ type: "button",
1019
+ role: "radio",
1020
+ class: j(["m3-map-base grid size-12 shrink-0 cursor-pointer place-items-center rounded-full border-2 bg-surface-variant transition-[border-color,transform] duration-150 hover:scale-110", U(r) === null ? "m3-map-base--active border-primary" : "border-transparent"]),
1021
+ title: U(t).mapNoBaseLayer,
1022
+ "aria-label": U(t).mapNoBaseLayer,
1023
+ "aria-checked": U(r) === null,
1024
+ onClick: s[0] ||= (e) => U(i)(null)
1025
+ }, [T(h, {
1026
+ name: "layers_clear",
1027
+ size: 22,
1028
+ class: "text-on-surface-variant"
1029
+ })], 10, Ke)) : b("", !0)], 2));
1030
+ }
1031
+ }), Je = { class: "flex flex-col gap-2" }, Ye = { class: "flex items-center gap-2 bg-primary-container/40 px-4 py-2" }, Xe = { class: "text-label-large text-on-primary-container" }, Ze = { class: "flex flex-col px-4 py-1" }, Qe = { class: "text-label-small text-on-surface-variant" }, $e = { class: "text-body-medium text-on-surface" }, et = {
1032
+ key: 0,
1033
+ class: "break-words"
1034
+ }, tt = {
1035
+ key: 1,
1036
+ class: "text-body-small italic text-on-surface-variant"
1037
+ }, nt = /* @__PURE__ */ E({
1038
+ __name: "MMapFeatureInfo",
1039
+ props: { results: {} },
1040
+ setup(e) {
1041
+ let t = u();
1042
+ return (n, r) => (F(), x("div", Je, [(F(!0), x(g, null, z(e.results, (e, r) => (F(), x("div", {
1043
+ key: r,
1044
+ class: "overflow-hidden rounded-2xl bg-surface-container"
1045
+ }, [S("div", Ye, [T(h, {
1046
+ name: "layers",
1047
+ size: 16,
1048
+ class: "text-on-primary-container"
1049
+ }), S("span", Xe, H(e.layer.title), 1)]), S("dl", Ze, [(F(!0), x(g, null, z(e.fields, (r) => (F(), x("div", {
1050
+ key: r.key,
1051
+ class: "flex flex-col gap-0.5 border-b border-outline-variant py-1.5 last:border-b-0"
1052
+ }, [S("dt", Qe, H(r.label), 1), S("dd", $e, [B(n.$slots, "value", {
1053
+ field: r,
1054
+ result: e
1055
+ }, () => [r.value ? (F(), x("span", et, H(r.value), 1)) : (F(), x("span", tt, H(U(t).mapNoValue), 1))])])]))), 128))])]))), 128))]));
1056
+ }
1057
+ }), rt = (e) => e.metadata, it = /* @__PURE__ */ new Set([
1058
+ "fill",
1059
+ "line",
1060
+ "circle",
1061
+ "symbol",
1062
+ "fill-extrusion",
1063
+ "heatmap"
1064
+ ]), at = (e) => ({
1065
+ title: e.name,
1066
+ groups: [],
1067
+ layers: e.layers.filter((e) => e.type !== "background").map((e) => ({
1068
+ id: e.id,
1069
+ title: rt(e)?.title ?? e.id,
1070
+ listed: !0,
1071
+ children: [],
1072
+ identify: it.has(e.type) ? {
1073
+ format: {},
1074
+ exclude: []
1075
+ } : !1,
1076
+ hover: !1
1077
+ }))
1078
+ });
1079
+ function ot(e = {}) {
1080
+ let t = e.legend ?? ((e, t) => {
1081
+ let n = rt(e)?.legend;
1082
+ if (n?.show === !1) return;
1083
+ if (n?.wmslegend) return n.wmslegend;
1084
+ if (!t?.includes("/services/styles/")) return;
1085
+ let r = t.replace("/services/styles/", "/services/legends/");
1086
+ return `${r}${r.includes("?") ? "&" : "?"}has_label=false&include_raster=true&layer_id=${encodeURIComponent(e.id)}`;
1087
+ });
1088
+ return (e, { styleUrl: n }) => {
1089
+ let r = e.metadata?.groups ?? [];
1090
+ return {
1091
+ title: e.name,
1092
+ groups: r.map((e) => ({
1093
+ name: e.name,
1094
+ title: e.alias ?? e.name
1095
+ })),
1096
+ layers: e.layers.filter((e) => e.type !== "background").map((e) => {
1097
+ let r = rt(e) ?? {}, i = { ...r.fields }, a = i.exclude ?? [];
1098
+ delete i.exclude;
1099
+ let o = {};
1100
+ for (let [e, t] of Object.entries(i)) o[e] = {
1101
+ label: t.alias,
1102
+ prefix: t.prefix,
1103
+ suffix: t.suffix,
1104
+ mask: t.mask,
1105
+ hidden: t.show === !1
1106
+ };
1107
+ let s = r.hover, c = e.type === "raster" && r.isbaselayer === !0;
1108
+ return {
1109
+ id: e.id,
1110
+ title: r.alias ?? e.id,
1111
+ description: r.description,
1112
+ group: r.group,
1113
+ listed: !c && r.show_in_layerlist !== !1,
1114
+ base: c && r.show_in_layerlist !== !1 ? { image: r.image } : void 0,
1115
+ children: Array.isArray(r.childs) ? r.childs : [],
1116
+ identify: r.identify === !0 && {
1117
+ format: o,
1118
+ exclude: a
1119
+ },
1120
+ hover: s?.enable ? { fields: (s.fields ?? []).flatMap((e) => Object.entries(e).map(([e, t]) => ({
1121
+ key: e,
1122
+ label: t.alias ?? t.label,
1123
+ prefix: t.prefix,
1124
+ suffix: t.suffix,
1125
+ mask: t.mask
1126
+ }))) } : !1,
1127
+ legend: c ? void 0 : t(e, n),
1128
+ download: e.type === "raster" ? void 0 : r.download
1129
+ };
1130
+ })
1131
+ };
1132
+ };
1133
+ }
1134
+ function st(e, t) {
1135
+ return t?.label ?? e.charAt(0).toUpperCase() + e.slice(1);
1136
+ }
1137
+ function ct(e, t) {
1138
+ if (e == null || String(e).trim() === "") return "";
1139
+ let n = String(e), r = typeof e == "number" ? e : Number(e);
1140
+ if (t?.mask && !Number.isNaN(r)) {
1141
+ let e = t.mask.split(".")[1]?.length ?? 0, i = typeof document < "u" && document.documentElement.lang || void 0;
1142
+ n = new Intl.NumberFormat(i, {
1143
+ minimumFractionDigits: e,
1144
+ maximumFractionDigits: e,
1145
+ useGrouping: t.mask.includes(",")
1146
+ }).format(r);
1147
+ }
1148
+ return t?.prefix && (n = `${t.prefix} ${n}`), t?.suffix && (n = `${n} ${t.suffix}`), n;
1149
+ }
1150
+ var lt = /* @__PURE__ */ new Set([
1151
+ "coordinates",
1152
+ "mapCoordinates",
1153
+ "layerId",
1154
+ "__layerMetadata"
1155
+ ]);
1156
+ function ut(e, t, n) {
1157
+ let r = new Map((n?.layers ?? []).filter((t) => t.identify && e.getLayer(t.id)).map((e) => [e.id, e]));
1158
+ if (!r.size) return [];
1159
+ let i = [];
1160
+ for (let n of e.queryRenderedFeatures(t, { layers: [...r.keys()] })) {
1161
+ let e = r.get(n.layer.id);
1162
+ if (!e || !e.identify) continue;
1163
+ let { format: t, exclude: a } = e.identify, o = Object.entries(n.properties ?? {}).filter(([e]) => !lt.has(e) && !a.includes(e) && !t[e]?.hidden).map(([e, n]) => ({
1164
+ key: e,
1165
+ label: st(e, t[e]),
1166
+ value: ct(n, t[e])
1167
+ }));
1168
+ o.length && i.push({
1169
+ layer: e,
1170
+ feature: n,
1171
+ fields: o
1172
+ });
1173
+ }
1174
+ return i;
1175
+ }
1176
+ //#endregion
1177
+ //#region src/components/MMapIdentify.vue?vue&type=script&setup=true&lang.ts
1178
+ var dt = { class: "hidden" }, ft = /* @__PURE__ */ E({
1179
+ inheritAttrs: !1,
1180
+ __name: "MMapIdentify",
1181
+ props: {
1182
+ enabled: {
1183
+ type: Boolean,
1184
+ default: !0
1185
+ },
1186
+ popup: {
1187
+ type: Boolean,
1188
+ default: !0
1189
+ },
1190
+ marker: {
1191
+ type: Boolean,
1192
+ default: !0
1193
+ }
1194
+ },
1195
+ emits: ["identify"],
1196
+ setup(e, { expose: t, emit: n }) {
1197
+ let r = e, i = n, { on: a, onReady: o, activeTool: s } = J(), { model: c } = Z(), l = V([]), u = R([0, 0]), d = R(!1);
1198
+ a("click", (e) => {
1199
+ if (!r.enabled || s.value) return;
1200
+ let t = e.target;
1201
+ l.value = ut(t, e.point, c.value), u.value = [e.lngLat.lng, e.lngLat.lat], d.value = l.value.length > 0, i("identify", l.value, u.value);
1202
+ });
1203
+ function f() {
1204
+ d.value = !1;
1205
+ }
1206
+ W(() => r.enabled, (e) => {
1207
+ e || f();
1208
+ });
1209
+ let p, m = [], h = () => {
1210
+ r.enabled && !s.value && p && (p.getCanvas().style.cursor = "pointer");
1211
+ }, g = () => {
1212
+ p && (p.getCanvas().style.cursor = "");
1213
+ };
1214
+ function _() {
1215
+ if (p) {
1216
+ for (let e of m) p.off("mouseenter", e, h), p.off("mouseleave", e, g);
1217
+ m = (c.value?.layers ?? []).filter((e) => e.identify).map((e) => e.id);
1218
+ for (let e of m) p.on("mouseenter", e, h), p.on("mouseleave", e, g);
1219
+ }
1220
+ }
1221
+ return o((e) => {
1222
+ p = e, _();
1223
+ }), W(c, _), N(() => {
1224
+ m.forEach((e) => {
1225
+ p?.off("mouseenter", e, h), p?.off("mouseleave", e, g);
1226
+ });
1227
+ }), t({ close: f }), (t, n) => (F(), x("div", dt, [e.marker && d.value ? (F(), y(_e, {
1228
+ key: 0,
1229
+ "lng-lat": u.value
1230
+ }, null, 8, ["lng-lat"])) : b("", !0), e.popup && l.value.length ? (F(), y(ye, {
1231
+ key: 1,
1232
+ open: d.value,
1233
+ "onUpdate:open": n[0] ||= (e) => d.value = e,
1234
+ "lng-lat": u.value,
1235
+ "max-width": "360px",
1236
+ offset: e.marker ? U(he) : void 0
1237
+ }, {
1238
+ default: G(() => [S("div", A({ class: "max-h-80 overflow-y-auto" }, t.$attrs), [B(t.$slots, "default", {
1239
+ results: l.value,
1240
+ lngLat: u.value,
1241
+ close: f
1242
+ }, () => [T(nt, { results: l.value }, null, 8, ["results"])])], 16)]),
1243
+ _: 3
1244
+ }, 8, [
1245
+ "open",
1246
+ "lng-lat",
1247
+ "offset"
1248
+ ])) : b("", !0)]));
1249
+ }
1250
+ }), pt = { class: "hidden" }, mt = [
1251
+ "title",
1252
+ "aria-label",
1253
+ "aria-pressed"
1254
+ ], ht = { class: "-mx-4 -mt-3 mb-1 bg-primary-container px-3 py-1.5 text-label-medium text-on-primary-container" }, gt = { class: "flex flex-col" }, _t = { class: "text-label-small text-on-surface-variant" }, vt = { class: "text-body-small text-on-surface" }, yt = /* @__PURE__ */ E({
1255
+ __name: "MMapHover",
1256
+ props: {
1257
+ modelValue: {
1258
+ type: Boolean,
1259
+ default: !1
1260
+ },
1261
+ control: {
1262
+ type: [Boolean, String],
1263
+ default: !0
1264
+ }
1265
+ },
1266
+ emits: ["update:modelValue"],
1267
+ setup(e, { emit: t }) {
1268
+ let n = e, r = t, i = u(), { onReady: a } = J(), { model: o } = Z(), s = v(() => (o.value?.layers ?? []).filter((e) => e.hover && e.hover.fields.length)), c = V(null), l = R([0, 0]), d = R(!1), f, p = [];
1269
+ function m(e) {
1270
+ let t = e.features?.[0], n = s.value.find((e) => e.id === t?.layer.id);
1271
+ if (!t || !n || !n.hover) return;
1272
+ let r = t.properties ?? {};
1273
+ c.value = {
1274
+ layer: n,
1275
+ fields: n.hover.fields.map((e) => ({
1276
+ key: e.key,
1277
+ label: st(e.key, e),
1278
+ value: ct(r[e.key], e)
1279
+ })).filter((e) => e.value)
1280
+ }, l.value = [e.lngLat.lng, e.lngLat.lat], d.value = !0;
1281
+ }
1282
+ function _() {
1283
+ d.value = !1;
1284
+ }
1285
+ function C() {
1286
+ if (f) {
1287
+ for (let e of p) f.off("mousemove", e, m), f.off("mouseleave", e, _);
1288
+ p = n.modelValue ? s.value.map((e) => e.id) : [];
1289
+ for (let e of p) f.on("mousemove", e, m), f.on("mouseleave", e, _);
1290
+ n.modelValue || (d.value = !1);
1291
+ }
1292
+ }
1293
+ a((e) => {
1294
+ f = e, C();
1295
+ }), W([() => n.modelValue, s], C), N(() => {
1296
+ for (let e of p) f?.off("mousemove", e, m), f?.off("mouseleave", e, _);
1297
+ });
1298
+ let w = v(() => n.control === !0 ? "top-right" : n.control || "top-right");
1299
+ return (t, n) => (F(), x("div", pt, [e.control && s.value.length ? (F(), y(ae, {
1300
+ key: 0,
1301
+ position: w.value
1302
+ }, {
1303
+ default: G(() => [S("button", {
1304
+ type: "button",
1305
+ class: "grid place-items-center",
1306
+ title: U(i).mapHoverInfo,
1307
+ "aria-label": U(i).mapHoverInfo,
1308
+ "aria-pressed": e.modelValue,
1309
+ onClick: n[0] ||= (t) => r("update:modelValue", !e.modelValue)
1310
+ }, [T(h, {
1311
+ name: "ads_click",
1312
+ size: 20
1313
+ })], 8, mt)]),
1314
+ _: 1
1315
+ }, 8, ["position"])) : b("", !0), c.value ? (F(), y(ye, {
1316
+ key: 1,
1317
+ open: d.value,
1318
+ "onUpdate:open": n[1] ||= (e) => d.value = e,
1319
+ "lng-lat": l.value,
1320
+ "close-button": !1,
1321
+ "close-on-click": !1,
1322
+ offset: 12,
1323
+ "max-width": "280px",
1324
+ class: "m3-map-hover"
1325
+ }, {
1326
+ default: G(() => [S("p", ht, H(c.value.layer.title), 1), S("dl", gt, [(F(!0), x(g, null, z(c.value.fields, (e) => (F(), x("div", {
1327
+ key: e.key,
1328
+ class: "border-b border-outline-variant py-1 last:border-b-0"
1329
+ }, [S("dt", _t, H(e.label), 1), S("dd", vt, H(e.value), 1)]))), 128))])]),
1330
+ _: 1
1331
+ }, 8, ["open", "lng-lat"])) : b("", !0)]));
1332
+ }
1333
+ }), bt = 6371008.8, $ = Math.PI / 180;
1334
+ function xt(e, t) {
1335
+ let n = (t[1] - e[1]) * $, r = (t[0] - e[0]) * $, i = Math.sin(n / 2) ** 2 + Math.cos(e[1] * $) * Math.cos(t[1] * $) * Math.sin(r / 2) ** 2;
1336
+ return 2 * bt * Math.asin(Math.min(1, Math.sqrt(i)));
1337
+ }
1338
+ function St(e) {
1339
+ let t = 0;
1340
+ for (let n = 1; n < e.length; n++) t += xt(e[n - 1], e[n]);
1341
+ return t;
1342
+ }
1343
+ function Ct(e, t) {
1344
+ let [n, r, i, a] = [
1345
+ e[0] * $,
1346
+ e[1] * $,
1347
+ t[0] * $,
1348
+ t[1] * $
1349
+ ], o = Math.cos(a) * Math.cos(i - n), s = Math.cos(a) * Math.sin(i - n), c = Math.atan2(Math.sin(r) + Math.sin(a), Math.sqrt((Math.cos(r) + o) ** 2 + s ** 2));
1350
+ return [(n + Math.atan2(s, Math.cos(r) + o)) / $, c / $];
1351
+ }
1352
+ function wt(e) {
1353
+ let t = Tt(e), n = t.length - 1;
1354
+ if (n <= 2) return 0;
1355
+ let r = 0;
1356
+ for (let e = 0; e < n; e++) {
1357
+ let i = t[e], a = t[e + 1 === n ? 0 : e + 1], o = t[e + 2 >= n ? (e + 2) % n : e + 2];
1358
+ r += (o[0] - i[0]) * $ * Math.sin(a[1] * $);
1359
+ }
1360
+ return Math.abs(r * bt * bt / 2);
1361
+ }
1362
+ function Tt(e) {
1363
+ let t = e[0], n = e[e.length - 1];
1364
+ return t && n && (t[0] !== n[0] || t[1] !== n[1]) ? [...e, t] : e;
1365
+ }
1366
+ function Et(e) {
1367
+ let t = Tt(e), n = 0, r = 0, i = 0;
1368
+ for (let e = 0; e < t.length - 1; e++) {
1369
+ let [a, o] = t[e], [s, c] = t[e + 1], l = a * c - s * o;
1370
+ n += l, r += (a + s) * l, i += (o + c) * l;
1371
+ }
1372
+ if (Math.abs(n) < 1e-12) {
1373
+ let e = t.slice(0, -1);
1374
+ return [e.reduce((e, t) => e + t[0], 0) / e.length, e.reduce((e, t) => e + t[1], 0) / e.length];
1375
+ }
1376
+ return [r / (3 * n), i / (3 * n)];
1377
+ }
1378
+ //#endregion
1379
+ //#region src/components/MMapMeasure.vue?vue&type=script&setup=true&lang.ts
1380
+ var Dt = { class: "hidden" }, Ot = ["title", "aria-pressed"], kt = ["title", "aria-pressed"], At = ["title", "disabled"], jt = [
1381
+ "aria-label",
1382
+ "title",
1383
+ "onClick"
1384
+ ], Mt = /* @__PURE__ */ E({
1385
+ __name: "MMapMeasure",
1386
+ props: {
1387
+ modelValue: { default: null },
1388
+ control: {
1389
+ type: [Boolean, String],
1390
+ default: !0
1391
+ }
1392
+ },
1393
+ emits: ["update:modelValue", "change"],
1394
+ setup(e, { expose: t, emit: n }) {
1395
+ let r = e, i = n, a = u(), { onReady: o, styleVersion: s, activeTool: c } = J(), l = be(["primary", "surface"]), d = `m3-measure-${te()}`, f = {
1396
+ done: `${d}-done`,
1397
+ draft: `${d}-draft`,
1398
+ handles: `${d}-handles`
1399
+ }, p = `${f.handles}-vertex`, m = `${f.handles}-midpoint`, _ = [], C = [], E = null, D = !1, O = null, k = 0, A, M = R(null), P = R(0), ee = V([]), I = () => typeof document < "u" && document.documentElement.lang || void 0, L = (e, t) => new Intl.NumberFormat(I(), {
1400
+ minimumFractionDigits: t,
1401
+ maximumFractionDigits: t
1402
+ }).format(e), B = (e) => e === 0 ? "" : e < 1e3 ? `${L(Math.round(e), 0)} m` : `${L(e / 1e3, 2)} km`, ne = (e) => e >= 1e6 ? `${L(e / 1e6, 2)} km²` : e >= 1e4 ? `${L(e / 1e4, 2)} ha` : `${L(Math.round(e), 0)} m²`, q = (e, t = {}) => ({
1403
+ type: "Feature",
1404
+ geometry: {
1405
+ type: "Point",
1406
+ coordinates: e
1407
+ },
1408
+ properties: t
1409
+ });
1410
+ function re(e, t, n, r) {
1411
+ let i = e.map((e) => q(e)), o = [];
1412
+ if (e.length < 2) return {
1413
+ features: i,
1414
+ labels: o
1415
+ };
1416
+ i.push({
1417
+ type: "Feature",
1418
+ geometry: {
1419
+ type: "LineString",
1420
+ coordinates: e
1421
+ },
1422
+ properties: {}
1423
+ });
1424
+ let s = (e) => {
1425
+ for (let t = 0; t < e.length - 1; t++) {
1426
+ let r = B(xt(e[t], e[t + 1]));
1427
+ r && o.push({
1428
+ key: `${n}-s${t}`,
1429
+ at: Ct(e[t], e[t + 1]),
1430
+ text: r,
1431
+ kind: "segment"
1432
+ });
1433
+ }
1434
+ };
1435
+ if (t === "distance") s(e), o.push({
1436
+ key: `${n}-t`,
1437
+ at: e[e.length - 1],
1438
+ text: `${a.mapTotal}: ${B(St(e))}`,
1439
+ kind: "total",
1440
+ m: r
1441
+ });
1442
+ else if (e.length >= 3) {
1443
+ let t = Tt(e);
1444
+ i.push({
1445
+ type: "Feature",
1446
+ geometry: {
1447
+ type: "Polygon",
1448
+ coordinates: [t]
1449
+ },
1450
+ properties: {}
1451
+ }), s(t), o.push({
1452
+ key: `${n}-a`,
1453
+ at: Et(t),
1454
+ text: ne(wt(t)),
1455
+ kind: "area",
1456
+ m: r
1457
+ });
1458
+ } else o.push({
1459
+ key: `${n}-t`,
1460
+ at: e[e.length - 1],
1461
+ text: B(St(e)),
1462
+ kind: "total",
1463
+ m: r
1464
+ });
1465
+ return {
1466
+ features: i,
1467
+ labels: o
1468
+ };
1469
+ }
1470
+ let ie = (e) => ({
1471
+ type: "FeatureCollection",
1472
+ features: e
1473
+ }), Y = (e, t) => (A?.getSource(e))?.setData(ie(t));
1474
+ function X() {
1475
+ if (!A) return;
1476
+ let e = _.map((e, t) => re(e.points, e.mode, `m${t}`, t)), t = M.value && C.length ? re(E ? [...C, E] : C, M.value, "draft") : {
1477
+ features: [],
1478
+ labels: []
1479
+ };
1480
+ Y(f.done, e.flatMap((e) => e.features)), Y(f.draft, t.features);
1481
+ let n = [];
1482
+ M.value || _.forEach((e, t) => {
1483
+ (e.closed ? e.points.slice(0, -1) : e.points).forEach((e, r) => n.push(q(e, {
1484
+ handle: "vertex",
1485
+ m: t,
1486
+ v: r
1487
+ })));
1488
+ for (let r = 0; r < e.points.length - 1; r++) n.push(q(Ct(e.points[r], e.points[r + 1]), {
1489
+ handle: "midpoint",
1490
+ m: t,
1491
+ after: r
1492
+ }));
1493
+ }), Y(f.handles, n), ee.value = [...e.flatMap((e) => e.labels), ...t.labels];
1494
+ }
1495
+ function oe() {
1496
+ P.value = _.length, i("change", _.map((e) => ({
1497
+ mode: e.mode,
1498
+ points: e.points.map((e) => [...e]),
1499
+ closed: e.closed,
1500
+ length: St(e.points),
1501
+ ...e.mode === "area" || e.closed ? { area: wt(e.points) } : {}
1502
+ })));
1503
+ }
1504
+ let se = (e) => [
1505
+ "==",
1506
+ ["geometry-type"],
1507
+ e
1508
+ ];
1509
+ function ce() {
1510
+ let { primary: e, surface: t } = l.value;
1511
+ return {
1512
+ fill: { "fill-color": e },
1513
+ line: { "line-color": e },
1514
+ vertices: {
1515
+ "circle-color": t,
1516
+ "circle-stroke-color": e
1517
+ }
1518
+ };
1519
+ }
1520
+ function le() {
1521
+ if (!A) return;
1522
+ for (let e of Object.values(f)) A.getSource(e) || A.addSource(e, {
1523
+ type: "geojson",
1524
+ data: ie([])
1525
+ });
1526
+ let e = ce(), t = (e) => {
1527
+ A.getLayer(e.id) || A.addLayer(e);
1528
+ };
1529
+ for (let [n, r] of [[f.done, !1], [f.draft, !0]]) t({
1530
+ id: `${n}-fill`,
1531
+ type: "fill",
1532
+ source: n,
1533
+ filter: se("Polygon"),
1534
+ paint: {
1535
+ ...e.fill,
1536
+ "fill-opacity": r ? .15 : .2
1537
+ }
1538
+ }), t({
1539
+ id: `${n}-line`,
1540
+ type: "line",
1541
+ source: n,
1542
+ filter: [
1543
+ "!=",
1544
+ ["geometry-type"],
1545
+ "Point"
1546
+ ],
1547
+ paint: {
1548
+ ...e.line,
1549
+ "line-width": 3,
1550
+ ...r ? { "line-dasharray": [2, 2] } : {}
1551
+ }
1552
+ }), t({
1553
+ id: `${n}-points`,
1554
+ type: "circle",
1555
+ source: n,
1556
+ filter: se("Point"),
1557
+ paint: {
1558
+ ...e.vertices,
1559
+ "circle-radius": 5,
1560
+ "circle-stroke-width": 2
1561
+ }
1562
+ });
1563
+ t({
1564
+ id: m,
1565
+ type: "circle",
1566
+ source: f.handles,
1567
+ filter: [
1568
+ "==",
1569
+ ["get", "handle"],
1570
+ "midpoint"
1571
+ ],
1572
+ paint: {
1573
+ ...e.vertices,
1574
+ "circle-radius": 4,
1575
+ "circle-stroke-width": 1.5,
1576
+ "circle-opacity": .7
1577
+ }
1578
+ }), t({
1579
+ id: p,
1580
+ type: "circle",
1581
+ source: f.handles,
1582
+ filter: [
1583
+ "==",
1584
+ ["get", "handle"],
1585
+ "vertex"
1586
+ ],
1587
+ paint: {
1588
+ ...e.vertices,
1589
+ "circle-radius": 7,
1590
+ "circle-stroke-width": 2.5
1591
+ }
1592
+ });
1593
+ }
1594
+ W(l, () => {
1595
+ if (!A) return;
1596
+ let e = ce(), t = (e, t) => {
1597
+ if (A.getLayer(e)) for (let [n, r] of Object.entries(t)) A.setPaintProperty(e, n, r);
1598
+ };
1599
+ for (let n of [f.done, f.draft]) t(`${n}-fill`, e.fill), t(`${n}-line`, e.line), t(`${n}-points`, e.vertices);
1600
+ t(m, e.vertices), t(p, e.vertices);
1601
+ });
1602
+ let Z = (e) => [e.lngLat.lng, e.lngLat.lat];
1603
+ function ue(e) {
1604
+ if (C.length >= 2) {
1605
+ let t = A.project(C[0]);
1606
+ if (Math.hypot(t.x - e.point.x, t.y - e.point.y) < 20) {
1607
+ D = !0, Q();
1608
+ return;
1609
+ }
1610
+ }
1611
+ C.push(Z(e)), X();
1612
+ }
1613
+ function de(e) {
1614
+ E = Z(e), !k && (k = requestAnimationFrame(() => {
1615
+ k = 0, X();
1616
+ }));
1617
+ }
1618
+ function fe(e) {
1619
+ if (e.preventDefault(), C.length < 2) return;
1620
+ let t = A.project(C[C.length - 1]), n = A.project(C[C.length - 2]);
1621
+ Math.hypot(t.x - n.x, t.y - n.y) < 10 && C.pop(), Q();
1622
+ }
1623
+ function pe(e) {
1624
+ (e.key === "Escape" || e.key === "Enter") && Q(e.key === "Escape");
1625
+ }
1626
+ let me = () => typeof navigator < "u" ? navigator.keyboard : void 0, he = !1;
1627
+ function ge() {
1628
+ M.value && document.fullscreenElement && me()?.lock && me().lock(["Escape"]).then(() => {
1629
+ he = !0;
1630
+ }, () => {});
1631
+ }
1632
+ function ve() {
1633
+ M.value || (he && me()?.unlock?.(), he = !1);
1634
+ }
1635
+ function ye() {
1636
+ let e, t = () => {
1637
+ document.removeEventListener("keyup", n, !0), clearTimeout(e), setTimeout(ve);
1638
+ }, n = (e) => {
1639
+ e.key === "Escape" && t();
1640
+ };
1641
+ document.addEventListener("keyup", n, !0), e = setTimeout(t, 1500);
1642
+ }
1643
+ function xe(e) {
1644
+ if (A) {
1645
+ if (M.value === e) return Q();
1646
+ M.value && Q(), M.value = e, c.value = "measure", C = [], E = null, A.getCanvas().style.cursor = "crosshair", A.doubleClickZoom.disable(), A.on("click", ue), A.on("mousemove", de), A.on("dblclick", fe), document.addEventListener("keydown", pe), document.addEventListener("fullscreenchange", ge), ge(), X(), r.modelValue !== e && i("update:modelValue", e);
1647
+ }
1648
+ }
1649
+ function Q(e = !1) {
1650
+ if (!A || !M.value) return;
1651
+ cancelAnimationFrame(k), k = 0;
1652
+ let t = C.length >= 3 && (D || M.value === "area");
1653
+ C.length >= 2 && _.push({
1654
+ mode: M.value,
1655
+ points: t ? [...C, [...C[0]]] : C,
1656
+ closed: t
1657
+ }), C = [], E = null, D = !1, M.value = null, c.value === "measure" && (c.value = null), A.getCanvas().style.cursor = "", A.doubleClickZoom.enable(), A.off("click", ue), A.off("mousemove", de), A.off("dblclick", fe), document.removeEventListener("keydown", pe), document.removeEventListener("fullscreenchange", ge), e && he ? ye() : ve(), X(), oe(), r.modelValue !== null && i("update:modelValue", null);
1658
+ }
1659
+ function Se(e) {
1660
+ _[e] && (_.splice(e, 1), X(), oe());
1661
+ }
1662
+ function Ce() {
1663
+ M.value && Q(), _.length = 0, X(), oe();
1664
+ }
1665
+ function we(e) {
1666
+ let t = e.features?.[0];
1667
+ if (!t || M.value || !A) return;
1668
+ e.preventDefault();
1669
+ let n = t.properties.m, r = _[n];
1670
+ if (!r) return;
1671
+ let i = t.properties.v;
1672
+ t.properties.handle === "midpoint" && (i = t.properties.after + 1, r.points.splice(i, 0, Z(e))), O = {
1673
+ m: n,
1674
+ v: i
1675
+ }, c.value = "measure", A.getCanvas().style.cursor = "grabbing";
1676
+ let a = e.type === "touchstart";
1677
+ a && A.dragPan.disable(), A.on(a ? "touchmove" : "mousemove", Te), A.once(a ? "touchend" : "mouseup", Ee), X();
1678
+ }
1679
+ function Te(e) {
1680
+ if (!O) return;
1681
+ let t = _[O.m];
1682
+ if (!t) return;
1683
+ let n = Z(e);
1684
+ t.points[O.v] = n, t.closed && O.v === 0 && (t.points[t.points.length - 1] = n), X();
1685
+ }
1686
+ function Ee() {
1687
+ A && (O = null, A.off("mousemove", Te), A.off("touchmove", Te), A.dragPan.enable(), A.getCanvas().style.cursor = "", oe(), setTimeout(() => {
1688
+ c.value === "measure" && !M.value && (c.value = null);
1689
+ }));
1690
+ }
1691
+ let De = () => {
1692
+ A && !O && !M.value && (A.getCanvas().style.cursor = "grab");
1693
+ }, Oe = () => {
1694
+ A && !O && !M.value && (A.getCanvas().style.cursor = "");
1695
+ };
1696
+ o((e) => {
1697
+ A = e, le();
1698
+ for (let t of [p, m]) e.on("mousedown", t, we), e.on("touchstart", t, we), e.on("mouseenter", t, De), e.on("mouseleave", t, Oe);
1699
+ r.modelValue && xe(r.modelValue);
1700
+ }), W(s, () => {
1701
+ le(), X();
1702
+ }), W(() => r.modelValue, (e) => {
1703
+ e && e !== M.value ? xe(e) : !e && M.value && Q();
1704
+ }), N(() => {
1705
+ if (!A) return;
1706
+ M.value && Q();
1707
+ for (let e of [p, m]) A.off("mousedown", e, we), A.off("touchstart", e, we), A.off("mouseenter", e, De), A.off("mouseleave", e, Oe);
1708
+ let e = [
1709
+ p,
1710
+ m,
1711
+ ...[f.done, f.draft].flatMap((e) => [
1712
+ `${e}-points`,
1713
+ `${e}-line`,
1714
+ `${e}-fill`
1715
+ ])
1716
+ ];
1717
+ for (let t of e) A.getLayer(t) && A.removeLayer(t);
1718
+ for (let e of Object.values(f)) A.getSource(e) && A.removeSource(e);
1719
+ });
1720
+ let ke = v(() => r.control === !0 ? "top-right" : r.control || "top-right");
1721
+ return t({
1722
+ start: xe,
1723
+ finish: Q,
1724
+ clear: Ce,
1725
+ remove: Se
1726
+ }), (t, n) => (F(), x("div", Dt, [e.control ? (F(), y(ae, {
1727
+ key: 0,
1728
+ position: ke.value
1729
+ }, {
1730
+ default: G(() => [
1731
+ S("button", {
1732
+ type: "button",
1733
+ class: "grid place-items-center",
1734
+ title: U(a).mapMeasureDistance,
1735
+ "aria-pressed": M.value === "distance",
1736
+ onClick: n[0] ||= (e) => xe("distance")
1737
+ }, [T(h, {
1738
+ name: "straighten",
1739
+ size: 20
1740
+ })], 8, Ot),
1741
+ S("button", {
1742
+ type: "button",
1743
+ class: "grid place-items-center",
1744
+ title: U(a).mapMeasureArea,
1745
+ "aria-pressed": M.value === "area",
1746
+ onClick: n[1] ||= (e) => xe("area")
1747
+ }, [T(h, {
1748
+ name: "pentagon",
1749
+ size: 20
1750
+ })], 8, kt),
1751
+ S("button", {
1752
+ type: "button",
1753
+ class: "grid place-items-center",
1754
+ title: U(a).mapClearMeasurements,
1755
+ disabled: !P.value && !M.value,
1756
+ onClick: Ce
1757
+ }, [T(h, {
1758
+ name: "delete",
1759
+ size: 20
1760
+ })], 8, At)
1761
+ ]),
1762
+ _: 1
1763
+ }, 8, ["position"])) : b("", !0), (F(!0), x(g, null, z(ee.value, (e) => (F(), y(_e, {
1764
+ key: e.key,
1765
+ "lng-lat": e.at,
1766
+ anchor: e.kind === "area" ? "center" : "top",
1767
+ offset: e.kind === "area" ? [0, 0] : [0, 8],
1768
+ class: "pointer-events-none"
1769
+ }, {
1770
+ default: G(() => [S("span", { class: j(["flex items-center gap-1 whitespace-nowrap rounded-full py-0.5 shadow-elevation-1", [e.kind === "segment" ? "bg-surface-container-highest text-label-small text-on-surface" : "bg-primary text-label-medium text-on-primary", e.m === void 0 ? "px-2" : "pr-0.5 pl-2"]]) }, [w(H(e.text) + " ", 1), e.m === void 0 ? b("", !0) : (F(), x("button", {
1771
+ key: 0,
1772
+ type: "button",
1773
+ class: "pointer-events-auto grid size-5 cursor-pointer place-items-center rounded-full hover:bg-on-primary/12 focus-visible:outline-2 focus-visible:outline-on-primary",
1774
+ "aria-label": U(a).mapDeleteMeasurement,
1775
+ title: U(a).mapDeleteMeasurement,
1776
+ onClick: K((t) => Se(e.m), ["stop"]),
1777
+ onPointerdown: n[2] ||= K(() => {}, ["stop"]),
1778
+ onMousedown: n[3] ||= K(() => {}, ["stop"]),
1779
+ onTouchstart: n[4] ||= K(() => {}, ["stop"]),
1780
+ onDblclick: n[5] ||= K(() => {}, ["stop"])
1781
+ }, [T(h, {
1782
+ name: "close",
1783
+ size: 14
1784
+ })], 40, jt))], 2)]),
1785
+ _: 2
1786
+ }, 1032, [
1787
+ "lng-lat",
1788
+ "anchor",
1789
+ "offset"
1790
+ ]))), 128))]));
1791
+ }
1792
+ }), Nt = /* @__PURE__ */ new WeakMap();
1793
+ function Pt() {
1794
+ let e = O(q, null);
1795
+ if (!e) throw Error("useMapFilter() must be called in a component inside <MMap>");
1796
+ function t(t, n) {
1797
+ let r = e.map.value;
1798
+ if (!r?.getLayer(t)) return;
1799
+ let i = Nt.get(r);
1800
+ i || Nt.set(r, i = /* @__PURE__ */ new Map()), i.has(t) || i.set(t, r.getFilter(t) ?? void 0);
1801
+ let a = i.get(t);
1802
+ r.setFilter(t, n ? a ? [
1803
+ "all",
1804
+ a,
1805
+ n
1806
+ ] : n : a ?? null);
1807
+ }
1808
+ function n(t, n) {
1809
+ let r = e.map.value, i = r?.getLayer(t);
1810
+ if (!r || !i?.source) return [];
1811
+ let a = r.querySourceFeatures(i.source, i.sourceLayer ? { sourceLayer: i.sourceLayer } : void 0), o = /* @__PURE__ */ new Set();
1812
+ for (let e of a) {
1813
+ let t = e.properties?.[n];
1814
+ (typeof t == "string" || typeof t == "number") && o.add(t);
1815
+ }
1816
+ return [...o].sort((e, t) => typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t)));
1817
+ }
1818
+ return {
1819
+ setFilter: t,
1820
+ valuesOf: n
1821
+ };
1822
+ }
1823
+ //#endregion
1824
+ //#region src/components/MMapFilter.vue?vue&type=script&setup=true&lang.ts
1825
+ var Ft = { class: "flex flex-wrap gap-2" }, It = /* @__PURE__ */ E({
1826
+ __name: "MMapFilter",
1827
+ props: {
1828
+ layer: {},
1829
+ property: {},
1830
+ values: {},
1831
+ labels: {},
1832
+ modelValue: {}
1833
+ },
1834
+ emits: ["update:modelValue"],
1835
+ setup(t, { emit: n }) {
1836
+ let r = t, i = n, { onReady: a, styleVersion: o } = J(), { setFilter: s, valuesOf: c } = Pt(), l = R([]), u = v(() => r.values ?? l.value), d = R([]), f = v(() => r.modelValue ?? d.value);
1837
+ function p() {
1838
+ let e = f.value;
1839
+ s(r.layer, e.length ? [
1840
+ "in",
1841
+ ["get", r.property],
1842
+ ["literal", e]
1843
+ ] : null);
1844
+ }
1845
+ function m(e) {
1846
+ let t = f.value.includes(e) ? f.value.filter((t) => t !== e) : [...f.value, e];
1847
+ d.value = t, i("update:modelValue", t);
1848
+ }
1849
+ function h(e) {
1850
+ let t = () => {
1851
+ r.values || (l.value = c(r.layer, r.property));
1852
+ };
1853
+ t(), e.once("idle", t);
1854
+ }
1855
+ return a((e) => {
1856
+ h(e), p();
1857
+ }), W(f, p, { deep: !0 }), W(o, () => p()), W(() => [r.layer, r.property], ([e], [t]) => {
1858
+ e !== t && s(t, null), p();
1859
+ }), N(() => s(r.layer, null)), (n, r) => (F(), x("div", Ft, [(F(!0), x(g, null, z(u.value, (n) => (F(), y(e, {
1860
+ key: n,
1861
+ type: "filter",
1862
+ clickable: "",
1863
+ selected: f.value.includes(n),
1864
+ onClick: (e) => m(n)
1865
+ }, {
1866
+ default: G(() => [w(H(t.labels?.[String(n)] ?? n), 1)]),
1867
+ _: 2
1868
+ }, 1032, ["selected", "onClick"]))), 128))]));
1869
+ }
1870
+ });
1871
+ //#endregion
1872
+ //#region src/composables/mapSearch.ts
1873
+ function Lt(e = {}) {
1874
+ return async (t, n) => {
1875
+ let r = new URLSearchParams({
1876
+ format: "jsonv2",
1877
+ q: t,
1878
+ limit: String(e.limit ?? 6)
1879
+ }), i = e.language ?? (typeof document < "u" ? document.documentElement.lang : "");
1880
+ i && r.set("accept-language", i), e.countryCodes?.length && r.set("countrycodes", e.countryCodes.join(",")), e.viewbox && r.set("viewbox", e.viewbox.join(",")), e.bounded && r.set("bounded", "1");
1881
+ let a = await fetch(`${e.url ?? "https://nominatim.openstreetmap.org"}/search?${r}`, { signal: n });
1882
+ if (!a.ok) throw Error(`Nominatim: ${a.status}`);
1883
+ return (await a.json()).map((e) => {
1884
+ let t = e.boundingbox?.map(Number);
1885
+ return {
1886
+ label: e.display_name,
1887
+ lngLat: [Number(e.lon), Number(e.lat)],
1888
+ bbox: t && t.length === 4 ? [
1889
+ t[2],
1890
+ t[0],
1891
+ t[3],
1892
+ t[1]
1893
+ ] : void 0,
1894
+ type: e.type
1895
+ };
1896
+ });
1897
+ };
1898
+ }
1899
+ //#endregion
1900
+ //#region src/components/MMapSearch.vue?vue&type=script&setup=true&lang.ts
1901
+ var Rt = { class: "hidden" }, zt = [
1902
+ "value",
1903
+ "placeholder",
1904
+ "aria-label"
1905
+ ], Bt = {
1906
+ key: 0,
1907
+ class: "border-t border-outline-variant"
1908
+ }, Vt = {
1909
+ key: 1,
1910
+ class: "flex flex-col items-center gap-2 py-6"
1911
+ }, Ht = { class: "text-body-small text-on-surface-variant" }, Ut = /* @__PURE__ */ E({
1912
+ __name: "MMapSearch",
1913
+ props: {
1914
+ provider: {},
1915
+ position: { default: "top-left" },
1916
+ placeholder: {},
1917
+ zoom: { default: 17 },
1918
+ marker: {
1919
+ type: Boolean,
1920
+ default: !0
1921
+ },
1922
+ instant: {
1923
+ type: Boolean,
1924
+ default: !1
1925
+ }
1926
+ },
1927
+ emits: ["select"],
1928
+ setup(e, { emit: t }) {
1929
+ let n = e, i = t, o = u(), { map: c } = J(), l = v(() => n.provider ?? Lt()), d = R(""), m = V([]), _ = R(!1), C = R(!1), w = R(!1), E = V(null), D, O;
1930
+ async function k() {
1931
+ let e = d.value.trim();
1932
+ if (!e) return;
1933
+ D?.abort(), D = new AbortController();
1934
+ let t = D;
1935
+ _.value = !0, w.value = !0;
1936
+ try {
1937
+ m.value = await l.value(e, t.signal);
1938
+ } catch {
1939
+ if (t.signal.aborted) return;
1940
+ m.value = [];
1941
+ } finally {
1942
+ D === t && (_.value = !1, C.value = !0);
1943
+ }
1944
+ }
1945
+ function A(e) {
1946
+ if (d.value = e, !e) return M();
1947
+ n.instant && (clearTimeout(O), O = setTimeout(k, 350));
1948
+ }
1949
+ function j(e) {
1950
+ E.value = e, w.value = !1;
1951
+ let t = c.value;
1952
+ e.bbox && e.bbox[0] !== e.bbox[2] ? t?.fitBounds([[e.bbox[0], e.bbox[1]], [e.bbox[2], e.bbox[3]]], {
1953
+ padding: 48,
1954
+ maxZoom: n.zoom
1955
+ }) : t?.flyTo({
1956
+ center: e.lngLat,
1957
+ zoom: n.zoom
1958
+ }), i("select", e);
1959
+ }
1960
+ function M() {
1961
+ D?.abort(), clearTimeout(O), d.value = "", m.value = [], C.value = !1, _.value = !1, w.value = !1, E.value = null;
1962
+ }
1963
+ N(() => {
1964
+ D?.abort(), clearTimeout(O);
1965
+ });
1966
+ let P = {
1967
+ city: "location_city",
1968
+ town: "location_city",
1969
+ village: "holiday_village",
1970
+ hamlet: "cottage",
1971
+ suburb: "apartment",
1972
+ neighbourhood: "maps_home_work",
1973
+ road: "road",
1974
+ residential: "home",
1975
+ house: "home",
1976
+ building: "domain",
1977
+ shop: "storefront",
1978
+ park: "park",
1979
+ water: "water",
1980
+ river: "water",
1981
+ lake: "water",
1982
+ school: "school",
1983
+ university: "school",
1984
+ hospital: "local_hospital",
1985
+ restaurant: "restaurant",
1986
+ cafe: "local_cafe",
1987
+ hotel: "hotel",
1988
+ station: "train",
1989
+ bus_stop: "directions_bus",
1990
+ administrative: "map",
1991
+ country: "public",
1992
+ state: "map"
1993
+ }, ee = (e) => e && P[e] || "location_on";
1994
+ return (t, n) => (F(), x("div", Rt, [T(ae, {
1995
+ position: e.position,
1996
+ group: !1
1997
+ }, {
1998
+ default: G(() => [T(s, {
1999
+ variant: "elevated",
2000
+ class: "w-80 max-w-[calc(100vw-5rem)] overflow-hidden"
2001
+ }, {
2002
+ default: G(() => [S("form", {
2003
+ class: "flex items-center gap-2 py-1 pr-1 pl-3",
2004
+ role: "search",
2005
+ onSubmit: K(k, ["prevent"])
2006
+ }, [
2007
+ T(h, {
2008
+ name: "search",
2009
+ size: 20,
2010
+ class: "shrink-0 text-on-surface-variant"
2011
+ }),
2012
+ S("input", {
2013
+ value: d.value,
2014
+ type: "search",
2015
+ enterkeyhint: "search",
2016
+ placeholder: e.placeholder ?? U(o).mapSearchPlaces,
2017
+ "aria-label": e.placeholder ?? U(o).mapSearchPlaces,
2018
+ class: "min-w-0 flex-1 bg-transparent py-2 text-body-medium text-on-surface outline-none placeholder:text-on-surface-variant [&::-webkit-search-cancel-button]:hidden",
2019
+ onInput: n[0] ||= (e) => A(e.target.value),
2020
+ onFocus: n[1] ||= (e) => w.value = C.value && !E.value
2021
+ }, null, 40, zt),
2022
+ _.value ? (F(), y(f, {
2023
+ key: 0,
2024
+ size: 20,
2025
+ class: "mr-2 shrink-0"
2026
+ })) : d.value ? (F(), y(p, {
2027
+ key: 1,
2028
+ icon: "close",
2029
+ label: U(o).clearSearch,
2030
+ size: "sm",
2031
+ onClick: M
2032
+ }, null, 8, ["label"])) : b("", !0)
2033
+ ], 32), w.value && C.value && !_.value ? (F(), x("div", Bt, [m.value.length ? (F(), y(r, {
2034
+ key: 0,
2035
+ class: "max-h-72 overflow-y-auto"
2036
+ }, {
2037
+ default: G(() => [(F(!0), x(g, null, z(m.value, (e, t) => (F(), y(a, {
2038
+ key: t,
2039
+ title: e.label,
2040
+ icon: ee(e.type),
2041
+ leading: "icon",
2042
+ clickable: "",
2043
+ onClick: (t) => j(e)
2044
+ }, null, 8, [
2045
+ "title",
2046
+ "icon",
2047
+ "onClick"
2048
+ ]))), 128))]),
2049
+ _: 1
2050
+ })) : (F(), x("div", Vt, [T(h, {
2051
+ name: "search_off",
2052
+ size: 28,
2053
+ class: "text-on-surface-variant"
2054
+ }), S("span", Ht, H(U(o).noResults), 1)]))])) : b("", !0)]),
2055
+ _: 1
2056
+ })]),
2057
+ _: 1
2058
+ }, 8, ["position"]), e.marker && E.value ? (F(), y(_e, {
2059
+ key: 0,
2060
+ "lng-lat": E.value.lngLat
2061
+ }, null, 8, ["lng-lat"])) : b("", !0)]));
2062
+ }
2063
+ });
2064
+ //#endregion
2065
+ export { de as MMap, qe as MMapBaseLayers, ae as MMapControl, nt as MMapFeatureInfo, It as MMapFilter, xe as MMapGeoJson, yt as MMapHover, ft as MMapIdentify, Ue as MMapLayers, _e as MMapMarker, Mt as MMapMeasure, ye as MMapPopup, Ut as MMapSearch, st as fieldLabel, ct as formatFieldValue, at as genericAdapter, ut as identifyFeatures, Lt as nominatimProvider, ot as orvianAdapter, J as useMap, Pt as useMapFilter, Z as useMapLayers };
2066
+
2067
+ //# sourceMappingURL=map.js.map