riskscape-plugins 1.0.1

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.
@@ -0,0 +1,2419 @@
1
+ var ts = Object.defineProperty;
2
+ var De = (i) => {
3
+ throw TypeError(i);
4
+ };
5
+ var es = (i, t, e) => t in i ? ts(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
+ var S = (i, t, e) => es(i, typeof t != "symbol" ? t + "" : t, e), ge = (i, t, e) => t.has(i) || De("Cannot " + e);
7
+ var n = (i, t, e) => (ge(i, t, "read from private field"), e ? e.call(i) : t.get(i)), _ = (i, t, e) => t.has(i) ? De("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), p = (i, t, e, s) => (ge(i, t, "write to private field"), s ? s.call(i, e) : t.set(i, e), e), l = (i, t, e) => (ge(i, t, "access private method"), e);
8
+ var Dt = (i, t, e, s) => ({
9
+ set _(r) {
10
+ p(i, t, r, e);
11
+ },
12
+ get _() {
13
+ return n(i, t, s);
14
+ }
15
+ });
16
+ import "leaflet";
17
+ const is = L.TileLayer.WMS.extend({
18
+ /**
19
+ * Initialize the WMS layer
20
+ * @param {string} url - The base URL for WMS tiles
21
+ * @param {Object} options - Layer options
22
+ * @param {string} apiKey - The API key for authentication
23
+ */
24
+ initialize: function(i, t, e) {
25
+ this.apiKey = e, L.TileLayer.WMS.prototype.initialize.call(this, i, t);
26
+ },
27
+ /**
28
+ * Get the URL for a specific tile
29
+ * @param {Object} coords - The tile coordinates
30
+ * @returns {string} The tile URL with authentication
31
+ */
32
+ getTileUrl: function(i) {
33
+ var s;
34
+ const t = this._tileCoordsToBounds(i).toBBoxString();
35
+ let e = `${this._url}?key=${this.apiKey}&bbox=${t}`;
36
+ return (s = this.wmsParams) != null && s.cql_filter && (e += `&cql_filter=${this.wmsParams.cql_filter}`), e;
37
+ }
38
+ });
39
+ L.RiskscapeWmsLayer = is;
40
+ const ss = L.TileLayer.extend({
41
+ /**
42
+ * Initialize the tile layer
43
+ * @param {string} url - The base URL for tiles
44
+ * @param {Object} options - Layer options
45
+ * @param {string} apiKey - The API key for authentication
46
+ */
47
+ initialize: function(i, t, e) {
48
+ this.apiKey = e, L.TileLayer.prototype.initialize.call(this, i, t);
49
+ },
50
+ /**
51
+ * Get the URL for a specific tile
52
+ * @param {Object} coords - The tile coordinates
53
+ * @returns {string} The tile URL with authentication
54
+ */
55
+ getTileUrl: function(i) {
56
+ return `${L.TileLayer.prototype.getTileUrl.call(this, i)}?key=${this.apiKey}`;
57
+ }
58
+ });
59
+ L.RiskscapeTileLayer = ss;
60
+ var nt, B, U, J, gt, yt, ae, M, E, w, W, z, K, lt, g, qe, Ye, Xe, Je, Qe, ti, ei, ii, _e, Jt, Ut, Qt, Pt, be, we;
61
+ class ns {
62
+ constructor(t = {}) {
63
+ _(this, g);
64
+ _(this, nt, []);
65
+ _(this, B, []);
66
+ _(this, U, -1);
67
+ _(this, J, !1);
68
+ _(this, gt, null);
69
+ _(this, yt, null);
70
+ _(this, ae, null);
71
+ _(this, M, null);
72
+ // DOM elements
73
+ _(this, E, null);
74
+ _(this, w, null);
75
+ _(this, W, null);
76
+ _(this, z, null);
77
+ _(this, K, null);
78
+ // Configuration
79
+ _(this, lt, {
80
+ maxVisibleItems: 8,
81
+ placeholder: "Type to search unit numbers...",
82
+ noResultsText: "No units found"
83
+ });
84
+ p(this, lt, { ...n(this, lt), ...t }), l(this, g, qe).call(this), l(this, g, Ye).call(this);
85
+ }
86
+ /**
87
+ * Show the unit selector with units
88
+ * @param {Array} units - Array of unit objects { property_key, unit_number }
89
+ * @param {HTMLElement} mapContainer - The map container element to overlay
90
+ * @param {L.Map} mapInstance - The Leaflet map instance to disable interactions
91
+ * @param {Object} options - Options for the selector
92
+ * @param {Function} options.onSelect - Callback when unit is selected
93
+ * @param {Function} options.onCancel - Callback when cancelled
94
+ */
95
+ show(t, e, s, { onSelect: r, onCancel: a } = {}) {
96
+ if (p(this, nt, t || []), p(this, B, [...n(this, nt)]), p(this, U, -1), p(this, gt, r), p(this, yt, a), p(this, M, s), n(this, w).value = "", l(this, g, Jt).call(this), n(this, M))
97
+ try {
98
+ n(this, M).dragging.disable(), n(this, M).touchZoom.disable(), n(this, M).doubleClickZoom.disable(), n(this, M).scrollWheelZoom.disable(), n(this, M).boxZoom.disable(), n(this, M).keyboard.disable(), n(this, M).tap && n(this, M).tap.disable();
99
+ } catch (o) {
100
+ console.warn("Could not disable map interactions:", o);
101
+ }
102
+ if (e) {
103
+ const o = e.getBoundingClientRect(), h = window.pageYOffset || document.documentElement.scrollTop, u = window.pageXOffset || document.documentElement.scrollLeft;
104
+ n(this, E).style.position = "absolute", n(this, E).style.top = `${o.top + h + o.height / 2 - 50}px`, n(this, E).style.left = `${o.left + u + o.width / 2}px`, n(this, E).style.transform = "translate(-50%, -50%)", n(this, E).style.zIndex = "10000";
105
+ }
106
+ document.body.contains(n(this, E)) || document.body.appendChild(n(this, E)), l(this, g, Qt).call(this), setTimeout(() => {
107
+ n(this, w).focus();
108
+ }, 100);
109
+ }
110
+ /**
111
+ * Check if selector is currently visible
112
+ */
113
+ isVisible() {
114
+ return n(this, J);
115
+ }
116
+ /**
117
+ * Get the container element (for positioning)
118
+ */
119
+ getElement() {
120
+ return n(this, E);
121
+ }
122
+ hide() {
123
+ if (!(!n(this, E) || !document.body.contains(n(this, E)))) {
124
+ if (l(this, g, Pt).call(this), n(this, M))
125
+ try {
126
+ n(this, M).dragging.enable(), n(this, M).touchZoom.enable(), n(this, M).doubleClickZoom.enable(), n(this, M).scrollWheelZoom.enable(), n(this, M).boxZoom.enable(), n(this, M).keyboard.enable(), n(this, M).tap && n(this, M).tap.enable();
127
+ } catch (t) {
128
+ console.warn("Could not re-enable map interactions:", t);
129
+ }
130
+ try {
131
+ document.body.removeChild(n(this, E));
132
+ } catch (t) {
133
+ console.warn("Could not remove unit selector from DOM:", t);
134
+ }
135
+ p(this, U, -1), p(this, J, !1), n(this, w).value = "";
136
+ }
137
+ }
138
+ /**
139
+ * Destroy the unit selector and clean up
140
+ */
141
+ destroy() {
142
+ l(this, g, Pt).call(this);
143
+ try {
144
+ if (n(this, w) && n(this, w).parentNode) {
145
+ const t = n(this, w).cloneNode(!0);
146
+ n(this, w).parentNode.replaceChild(t, n(this, w));
147
+ }
148
+ } catch (t) {
149
+ console.warn("Could not clean up input event listeners:", t);
150
+ }
151
+ try {
152
+ if (n(this, z) && n(this, z).parentNode) {
153
+ const t = n(this, z).cloneNode(!0);
154
+ n(this, z).parentNode.replaceChild(t, n(this, z));
155
+ }
156
+ } catch (t) {
157
+ console.warn("Could not clean up list event listeners:", t);
158
+ }
159
+ try {
160
+ n(this, E) && (document.body.contains(n(this, E)) && document.body.removeChild(n(this, E)), n(this, E).parentNode && n(this, E).parentNode.removeChild(n(this, E)), document.querySelectorAll(".rs-unit-selector-container").forEach((e) => {
161
+ try {
162
+ e.parentNode && e.parentNode.removeChild(e);
163
+ } catch (s) {
164
+ console.warn("Could not remove orphaned unit selector element:", s);
165
+ }
166
+ }));
167
+ } catch (t) {
168
+ console.warn("Could not remove container during destroy:", t);
169
+ }
170
+ try {
171
+ p(this, nt, []), p(this, B, []), p(this, gt, null), p(this, yt, null), p(this, M, null), p(this, E, null), p(this, w, null), p(this, W, null), p(this, z, null), p(this, K, null), p(this, ae, null);
172
+ } catch (t) {
173
+ console.warn("Could not clear references during destroy:", t);
174
+ }
175
+ }
176
+ }
177
+ nt = new WeakMap(), B = new WeakMap(), U = new WeakMap(), J = new WeakMap(), gt = new WeakMap(), yt = new WeakMap(), ae = new WeakMap(), M = new WeakMap(), E = new WeakMap(), w = new WeakMap(), W = new WeakMap(), z = new WeakMap(), K = new WeakMap(), lt = new WeakMap(), g = new WeakSet(), qe = function() {
178
+ p(this, E, document.createElement("div")), n(this, E).className = "rs-unit-selector-container";
179
+ const t = document.createElement("div");
180
+ t.className = "rs-unit-selector-header", t.innerHTML = `
181
+ <span class="rs-unit-selector-title">Select Unit</span>
182
+ <button class="rs-unit-selector-cancel" type="button" aria-label="Cancel">
183
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
184
+ <path d="M12.5 3.5L8 8l4.5 4.5-1 1L7 9l-4.5 4.5-1-1L6 8 1.5 3.5l1-1L7 7l4.5-4.5 1 1z"/>
185
+ </svg>
186
+ </button>
187
+ `, p(this, w, document.createElement("input")), n(this, w).type = "text", n(this, w).className = "rs-unit-selector-input", n(this, w).placeholder = n(this, lt).placeholder, n(this, w).autocomplete = "off", n(this, w).spellcheck = !1, n(this, w).setAttribute("role", "combobox"), n(this, w).setAttribute("aria-autocomplete", "list"), n(this, w).setAttribute("aria-expanded", "false"), p(this, W, document.createElement("div")), n(this, W).className = "rs-unit-selector-dropdown", n(this, W).style.display = "none", p(this, z, document.createElement("ul")), n(this, z).className = "rs-unit-selector-list", n(this, z).setAttribute("role", "listbox"), p(this, K, document.createElement("div")), n(this, K).className = "rs-unit-selector-no-results", n(this, K).textContent = n(this, lt).noResultsText, n(this, K).style.display = "none", n(this, W).appendChild(n(this, z)), n(this, W).appendChild(n(this, K)), n(this, E).appendChild(t), n(this, E).appendChild(n(this, w)), n(this, E).appendChild(n(this, W));
188
+ }, Ye = function() {
189
+ n(this, w).addEventListener("input", l(this, g, Xe).bind(this)), n(this, w).addEventListener("keydown", l(this, g, Je).bind(this)), n(this, w).addEventListener("focus", l(this, g, Qe).bind(this)), n(this, w).addEventListener("blur", l(this, g, ti).bind(this)), n(this, E).querySelector(".rs-unit-selector-cancel").addEventListener("click", l(this, g, we).bind(this)), n(this, z).addEventListener("click", l(this, g, ei).bind(this)), n(this, z).addEventListener("mouseover", l(this, g, ii).bind(this));
190
+ }, Xe = function(t) {
191
+ const e = t.target.value.trim();
192
+ l(this, g, _e).call(this, e), p(this, U, -1), l(this, g, Jt).call(this), l(this, g, Qt).call(this);
193
+ }, Je = function(t) {
194
+ if (n(this, J))
195
+ switch (t.key) {
196
+ case "ArrowDown":
197
+ t.preventDefault(), p(this, U, Math.min(n(this, U) + 1, n(this, B).length - 1)), l(this, g, Ut).call(this);
198
+ break;
199
+ case "ArrowUp":
200
+ t.preventDefault(), p(this, U, Math.max(n(this, U) - 1, -1)), l(this, g, Ut).call(this);
201
+ break;
202
+ case "Enter":
203
+ t.preventDefault(), n(this, U) >= 0 && n(this, B)[n(this, U)] && l(this, g, be).call(this, n(this, B)[n(this, U)]);
204
+ break;
205
+ case "Escape":
206
+ t.preventDefault(), l(this, g, Pt).call(this), l(this, g, we).call(this);
207
+ break;
208
+ }
209
+ }, Qe = function() {
210
+ n(this, nt).length > 0 && (l(this, g, _e).call(this, n(this, w).value.trim()), l(this, g, Jt).call(this), l(this, g, Qt).call(this));
211
+ }, ti = function(t) {
212
+ }, ei = function(t) {
213
+ const e = t.target.closest(".rs-unit-selector-item");
214
+ if (e) {
215
+ const s = parseInt(e.dataset.index), r = n(this, B)[s];
216
+ r && l(this, g, be).call(this, r);
217
+ }
218
+ }, ii = function(t) {
219
+ const e = t.target.closest(".rs-unit-selector-item");
220
+ if (e) {
221
+ const s = parseInt(e.dataset.index);
222
+ p(this, U, s), l(this, g, Ut).call(this);
223
+ }
224
+ }, _e = function(t) {
225
+ t ? p(this, B, n(this, nt).filter(
226
+ (e) => e.unit_number.toLowerCase().includes(t.toLowerCase())
227
+ )) : p(this, B, [...n(this, nt)]);
228
+ }, Jt = function() {
229
+ if (n(this, B).length === 0) {
230
+ n(this, z).style.display = "none", n(this, K).style.display = "block";
231
+ return;
232
+ }
233
+ n(this, z).style.display = "block", n(this, K).style.display = "none";
234
+ const t = n(this, B).slice(0, n(this, lt).maxVisibleItems * 2);
235
+ n(this, z).innerHTML = t.map((e, s) => `
236
+ <li class="rs-unit-selector-item" data-index="${s}" role="option">
237
+ <span class="rs-unit-selector-unit-number">${e.unit_number}</span>
238
+ </li>
239
+ `).join(""), l(this, g, Ut).call(this);
240
+ }, Ut = function() {
241
+ const t = n(this, z).querySelectorAll(".rs-unit-selector-item");
242
+ if (t.forEach((e, s) => {
243
+ e.classList.toggle("rs-unit-selector-item--selected", s === n(this, U));
244
+ }), n(this, U) >= 0) {
245
+ const e = t[n(this, U)];
246
+ e && e.scrollIntoView({ block: "nearest" });
247
+ }
248
+ }, Qt = function() {
249
+ n(this, J) || (p(this, J, !0), n(this, W).style.display = "block", n(this, w).setAttribute("aria-expanded", "true"));
250
+ }, Pt = function() {
251
+ n(this, J) && (p(this, J, !1), n(this, W) && (n(this, W).style.display = "none"), n(this, w) && n(this, w).setAttribute("aria-expanded", "false"));
252
+ }, be = function(t) {
253
+ n(this, w).value = t.unit_number, l(this, g, Pt).call(this), this.hide(), n(this, gt) && n(this, gt).call(this, t);
254
+ }, we = function() {
255
+ this.hide(), n(this, yt) && n(this, yt).call(this);
256
+ };
257
+ var Wt, $t, le, Q, si, Et, Ve;
258
+ let rs = (Ve = class {
259
+ constructor({ apiKey: t, baseUrl: e }) {
260
+ _(this, Q);
261
+ _(this, Wt);
262
+ _(this, $t);
263
+ _(this, le, 8e3);
264
+ p(this, Wt, t), p(this, $t, e);
265
+ }
266
+ async fetchAddress(t) {
267
+ return l(this, Q, Et).call(this, "get", "addressing/v2/address", {
268
+ params: { address_id: t }
269
+ });
270
+ }
271
+ async fetchFeature(t, e) {
272
+ return l(this, Q, Et).call(this, "get", "features/v1/feature", {
273
+ params: { type: t, ...e }
274
+ });
275
+ }
276
+ async fetchProperty(t, e) {
277
+ return l(this, Q, Et).call(this, "get", "properties/v1/property", {
278
+ params: { property_key: t, unit_number: e }
279
+ });
280
+ }
281
+ async fetchPropertyUnits(t) {
282
+ return l(this, Q, Et).call(this, "get", "properties/v1/unit-numbers", {
283
+ params: { property_key: t }
284
+ });
285
+ }
286
+ async fetchSchemeUnits(t) {
287
+ return l(this, Q, Et).call(this, "get", "schemes/v1/units", {
288
+ params: { scheme_id: t }
289
+ });
290
+ }
291
+ }, Wt = new WeakMap(), $t = new WeakMap(), le = new WeakMap(), Q = new WeakSet(), si = function(t) {
292
+ var s, r;
293
+ console.error("API call failed:", t.message);
294
+ const e = new CustomEvent("riskscape-api:error", {
295
+ detail: {
296
+ message: t.message,
297
+ response: (s = t.response) == null ? void 0 : s.data,
298
+ status: (r = t.response) == null ? void 0 : r.status
299
+ }
300
+ });
301
+ throw document.dispatchEvent(e), t;
302
+ }, Et = async function(t, e, s = {}) {
303
+ try {
304
+ const r = new URL(e, n(this, $t));
305
+ s.params && Object.entries(s.params).forEach(([o, h]) => {
306
+ h != null && r.searchParams.append(o, h);
307
+ });
308
+ const a = await fetch(r, {
309
+ method: t.toUpperCase(),
310
+ headers: {
311
+ accept: "application/json",
312
+ "x-api-key": n(this, Wt),
313
+ ...s.headers
314
+ },
315
+ signal: AbortSignal.timeout ? AbortSignal.timeout(n(this, le)) : void 0
316
+ });
317
+ if (!a.ok) {
318
+ const o = new Error(`HTTP ${a.status}`);
319
+ throw o.response = {
320
+ status: a.status,
321
+ data: await a.json().catch(() => ({}))
322
+ }, o;
323
+ }
324
+ return await a.json();
325
+ } catch (r) {
326
+ return l(this, Q, si).call(this, r);
327
+ }
328
+ }, Ve);
329
+ var Nt = { exports: {} }, os = Nt.exports, Ue;
330
+ function as() {
331
+ return Ue || (Ue = 1, function(i, t) {
332
+ (function(e, s) {
333
+ s(t);
334
+ })(os, function(e) {
335
+ var s = { ar: { touch: "استخدم إصبعين لتحريك الخريطة", scroll: "‏استخدم ctrl + scroll لتصغير/تكبير الخريطة", scrollMac: "يمكنك استخدام ⌘ + التمرير لتكبير/تصغير الخريطة" }, bg: { touch: "Използвайте два пръста, за да преместите картата", scroll: "Задръжте бутона Ctrl натиснат, докато превъртате, за да промените мащаба на картата", scrollMac: "Задръжте бутона ⌘ натиснат, докато превъртате, за да промените мащаба на картата" }, bn: { touch: "মানচিত্রটিকে সরাতে দুটি আঙ্গুল ব্যবহার করুন", scroll: "ম্যাপ জুম করতে ctrl + scroll ব্যবহার করুন", scrollMac: "ম্যাপে জুম করতে ⌘ বোতাম টিপে স্ক্রল করুন" }, ca: { touch: "Fes servir dos dits per moure el mapa", scroll: "Prem la tecla Control mentre et desplaces per apropar i allunyar el mapa", scrollMac: "Prem la tecla ⌘ mentre et desplaces per apropar i allunyar el mapa" }, cs: { touch: "K posunutí mapy použijte dva prsty", scroll: "Velikost zobrazení mapy změňte podržením klávesy Ctrl a posouváním kolečka myši", scrollMac: "Velikost zobrazení mapy změníte podržením klávesy ⌘ a posunutím kolečka myši / touchpadu" }, da: { touch: "Brug to fingre til at flytte kortet", scroll: "Brug ctrl + rullefunktionen til at zoome ind og ud på kortet", scrollMac: "Brug ⌘ + rullefunktionen til at zoome ind og ud på kortet" }, de: { touch: "Verschieben der Karte mit zwei Fingern", scroll: "Verwende Strg+Scrollen zum Zoomen der Karte", scrollMac: "⌘" }, el: { touch: "Χρησιμοποιήστε δύο δάχτυλα για μετακίνηση στον χάρτη", scroll: "Χρησιμοποιήστε το πλήκτρο Ctrl και κύλιση, για να μεγεθύνετε τον χάρτη", scrollMac: "Χρησιμοποιήστε το πλήκτρο ⌘ + κύλιση για εστίαση στον χάρτη" }, en: { touch: "Use two fingers to move the map", scroll: "Use ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, "en-AU": { touch: "Use two fingers to move the map", scroll: "Use ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, "en-GB": { touch: "Use two fingers to move the map", scroll: "Use ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, es: { touch: "Para mover el mapa, utiliza dos dedos", scroll: "Mantén pulsada la tecla Ctrl mientras te desplazas para acercar o alejar el mapa", scrollMac: "Mantén pulsada la tecla ⌘ mientras te desplazas para acercar o alejar el mapa" }, eu: { touch: "Erabili bi hatz mapa mugitzeko", scroll: "Mapan zooma aplikatzeko, sakatu Ktrl eta egin gora edo behera", scrollMac: "Eduki sakatuta ⌘ eta egin gora eta behera mapa handitu eta txikitzeko" }, fa: { touch: "برای حرکت دادن نقشه از دو انگشت استفاده کنید.", scroll: "‏برای بزرگ‌نمایی نقشه از ctrl + scroll استفاده کنید", scrollMac: "برای بزرگ‌نمایی نقشه، از ⌘ + پیمایش استفاده کنید." }, fi: { touch: "Siirrä karttaa kahdella sormella.", scroll: "Zoomaa karttaa painamalla Ctrl-painiketta ja vierittämällä.", scrollMac: "Zoomaa karttaa pitämällä painike ⌘ painettuna ja vierittämällä." }, fil: { touch: "Gumamit ng dalawang daliri upang iusog ang mapa", scroll: "Gamitin ang ctrl + scroll upang i-zoom ang mapa", scrollMac: "Gamitin ang ⌘ + scroll upang i-zoom ang mapa" }, fr: { touch: "Utilisez deux doigts pour déplacer la carte", scroll: "Vous pouvez zoomer sur la carte à l'aide de CTRL+Molette de défilement", scrollMac: "Vous pouvez zoomer sur la carte à l'aide de ⌘+Molette de défilement" }, gl: { touch: "Utiliza dous dedos para mover o mapa", scroll: "Preme Ctrl mentres te desprazas para ampliar o mapa", scrollMac: "Preme ⌘ e desprázate para ampliar o mapa" }, gu: { touch: "નકશો ખસેડવા બે આંગળીઓનો ઉપયોગ કરો", scroll: "નકશાને ઝૂમ કરવા માટે ctrl + સ્ક્રોલનો ઉપયોગ કરો", scrollMac: "નકશાને ઝૂમ કરવા ⌘ + સ્ક્રોલનો ઉપયોગ કરો" }, hi: { touch: "मैप एक जगह से दूसरी जगह ले जाने के लिए दो उंगलियों का इस्तेमाल करें", scroll: "मैप को ज़ूम करने के लिए ctrl + स्क्रोल का उपयोग करें", scrollMac: "मैप को ज़ूम करने के लिए ⌘ + स्क्रोल का उपयोग करें" }, hr: { touch: "Pomičite kartu pomoću dva prsta", scroll: "Upotrijebite Ctrl i klizač miša da biste zumirali kartu", scrollMac: "Upotrijebite gumb ⌘ dok se pomičete za zumiranje karte" }, hu: { touch: "Két ujjal mozgassa a térképet", scroll: "A térkép a ctrl + görgetés használatával nagyítható", scrollMac: "A térkép a ⌘ + görgetés használatával nagyítható" }, id: { touch: "Gunakan dua jari untuk menggerakkan peta", scroll: "Gunakan ctrl + scroll untuk memperbesar atau memperkecil peta", scrollMac: "Gunakan ⌘ + scroll untuk memperbesar atau memperkecil peta" }, it: { touch: "Utilizza due dita per spostare la mappa", scroll: "Utilizza CTRL + scorrimento per eseguire lo zoom della mappa", scrollMac: "Utilizza ⌘ + scorrimento per eseguire lo zoom della mappa" }, iw: { touch: "הזז את המפה באמצעות שתי אצבעות", scroll: "‏אפשר לשנות את מרחק התצוגה במפה באמצעות מקש ctrl וגלילה", scrollMac: "אפשר לשנות את מרחק התצוגה במפה באמצעות מקש ⌘ וגלילה" }, ja: { touch: "地図を移動させるには指 2 本で操作します", scroll: "地図をズームするには、Ctrl キーを押しながらスクロールしてください", scrollMac: "地図をズームするには、⌘ キーを押しながらスクロールしてください" }, kn: { touch: "Use two fingers to move the map", scroll: "Use Ctrl + scroll to zoom the map", scrollMac: "Use ⌘ + scroll to zoom the map" }, ko: { touch: "지도를 움직이려면 두 손가락을 사용하세요.", scroll: "지도를 확대/축소하려면 Ctrl을 누른 채 스크롤하세요.", scrollMac: "지도를 확대하려면 ⌘ + 스크롤 사용" }, lt: { touch: "Perkelkite žemėlapį dviem pirštais", scroll: "Slinkite nuspaudę klavišą „Ctrl“, kad pakeistumėte žemėlapio mastelį", scrollMac: "Paspauskite klavišą ⌘ ir slinkite, kad priartintumėte žemėlapį" }, lv: { touch: "Lai pārvietotu karti, bīdiet to ar diviem pirkstiem", scroll: "Kartes tālummaiņai izmantojiet ctrl + ritināšanu", scrollMac: "Lai veiktu kartes tālummaiņu, izmantojiet ⌘ + ritināšanu" }, ml: { touch: "മാപ്പ് നീക്കാൻ രണ്ട് വിരലുകൾ ഉപയോഗിക്കുക", scroll: "കൺട്രോൾ + സ്‌ക്രോൾ ഉപയോഗിച്ച് ‌മാപ്പ് ‌സൂം ചെയ്യുക", scrollMac: "⌘ + സ്‌ക്രോൾ ഉപയോഗിച്ച് ‌മാപ്പ് ‌സൂം ചെയ്യുക" }, mr: { touch: "नकाशा हलविण्यासाठी दोन बोटे वापरा", scroll: "नकाशा झूम करण्यासाठी ctrl + scroll वापरा", scrollMac: "नकाशावर झूम करण्यासाठी ⌘ + स्क्रोल वापरा" }, nl: { touch: "Gebruik twee vingers om de kaart te verplaatsen", scroll: "Gebruik Ctrl + scrollen om in- en uit te zoomen op de kaart", scrollMac: "Gebruik ⌘ + scrollen om in en uit te zoomen op de kaart" }, no: { touch: "Bruk to fingre for å flytte kartet", scroll: "Hold ctrl-tasten inne og rull for å zoome på kartet", scrollMac: "Hold inne ⌘-tasten og rull for å zoome på kartet" }, pl: { touch: "Przesuń mapę dwoma palcami", scroll: "Naciśnij CTRL i przewiń, by przybliżyć mapę", scrollMac: "Naciśnij ⌘ i przewiń, by przybliżyć mapę" }, pt: { touch: "Use dois dedos para mover o mapa", scroll: "Pressione Ctrl e role a tela simultaneamente para aplicar zoom no mapa", scrollMac: "Use ⌘ e role a tela simultaneamente para aplicar zoom no mapa" }, "pt-BR": { touch: "Use dois dedos para mover o mapa", scroll: "Pressione Ctrl e role a tela simultaneamente para aplicar zoom no mapa", scrollMac: "Use ⌘ e role a tela simultaneamente para aplicar zoom no mapa" }, "pt-PT": { touch: "Utilize dois dedos para mover o mapa", scroll: "Utilizar ctrl + deslocar para aumentar/diminuir zoom do mapa", scrollMac: "Utilize ⌘ + deslocar para aumentar/diminuir o zoom do mapa" }, ro: { touch: "Folosiți două degete pentru a deplasa harta", scroll: "Apăsați tasta ctrl și derulați simultan pentru a mări harta", scrollMac: "Folosiți ⌘ și derulați pentru a mări/micșora harta" }, ru: { touch: "Чтобы переместить карту, проведите по ней двумя пальцами", scroll: "Чтобы изменить масштаб, прокручивайте карту, удерживая клавишу Ctrl.", scrollMac: "Чтобы изменить масштаб, нажмите ⌘ + прокрутка" }, sk: { touch: "Mapu môžete posunúť dvoma prstami", scroll: "Ak chcete priblížiť mapu, stlačte kláves ctrl a posúvajte", scrollMac: "Ak chcete priblížiť mapu, stlačte kláves ⌘ a posúvajte kolieskom myši" }, sl: { touch: "Premaknite zemljevid z dvema prstoma", scroll: "Zemljevid povečate tako, da držite tipko Ctrl in vrtite kolesce na miški", scrollMac: "Uporabite ⌘ + funkcijo pomika, da povečate ali pomanjšate zemljevid" }, sr: { touch: "Мапу померајте помоћу два прста", scroll: "Притисните ctrl тастер док померате да бисте зумирали мапу", scrollMac: "Притисните тастер ⌘ док померате да бисте зумирали мапу" }, sv: { touch: "Använd två fingrar för att flytta kartan", scroll: "Använd ctrl + rulla för att zooma kartan", scrollMac: "Använd ⌘ + rulla för att zooma på kartan" }, ta: { touch: "மேப்பை நகர்த்த இரண்டு விரல்களைப் பயன்படுத்தவும்", scroll: "மேப்பை பெரிதாக்கி/சிறிதாக்கிப் பார்க்க, ctrl பட்டனைப் பிடித்தபடி, மேலே/கீழே ஸ்க்ரால் செய்யவும்", scrollMac: "மேப்பை பெரிதாக்கி/சிறிதாக்கிப் பார்க்க, ⌘ பட்டனைப் பிடித்தபடி, மேலே/கீழே ஸ்க்ரால் செய்யவும்" }, te: { touch: "మ్యాప్‌ని తరలించడం కోసం రెండు వేళ్లను ఉపయోగించండి", scroll: "మ్యాప్‌ని జూమ్ చేయడానికి ctrl బటన్‌ను నొక్కి ఉంచి, స్క్రోల్ చేయండి", scrollMac: "మ్యాప్ జూమ్ చేయాలంటే ⌘ + స్క్రోల్ ఉపయోగించండి" }, th: { touch: "ใช้ 2 นิ้วเพื่อเลื่อนแผนที่", scroll: "กด Ctrl ค้างไว้ แล้วเลื่อนหน้าจอเพื่อซูมแผนที่", scrollMac: "กด ⌘ แล้วเลื่อนหน้าจอเพื่อซูมแผนที่" }, tl: { touch: "Gumamit ng dalawang daliri upang iusog ang mapa", scroll: "Gamitin ang ctrl + scroll upang i-zoom ang mapa", scrollMac: "Gamitin ang ⌘ + scroll upang i-zoom ang mapa" }, tr: { touch: "Haritada gezinmek için iki parmağınızı kullanın", scroll: "Haritayı yakınlaştırmak için ctrl + kaydırma kombinasyonunu kullanın", scrollMac: "Haritayı yakınlaştırmak için ⌘ tuşuna basıp ekranı kaydırın" }, uk: { touch: "Переміщуйте карту двома пальцями", scroll: "Щоб змінювати масштаб карти, прокручуйте коліщатко миші, утримуючи клавішу Ctrl", scrollMac: "Щоб змінити масштаб карти, використовуйте ⌘ + прокручування" }, vi: { touch: "Sử dụng hai ngón tay để di chuyển bản đồ", scroll: "Sử dụng ctrl + cuộn để thu phóng bản đồ", scrollMac: "Sử dụng ⌘ + cuộn để thu phóng bản đồ" }, "zh-CN": { touch: "使用双指移动地图", scroll: "按住 Ctrl 并滚动鼠标滚轮才可缩放地图", scrollMac: "按住 ⌘ 并滚动鼠标滚轮才可缩放地图" }, "zh-TW": { touch: "同時以兩指移動地圖", scroll: "按住 ctrl 鍵加上捲動滑鼠可以縮放地圖", scrollMac: "按 ⌘ 加上滾動捲軸可以縮放地圖" } };
336
+ L.Map.mergeOptions({ gestureHandlingOptions: { text: {}, duration: 1e3 } });
337
+ var r = !1, a = L.Handler.extend({ addHooks: function() {
338
+ this._handleTouch = this._handleTouch.bind(this), this._setupPluginOptions(), this._setLanguageContent(), this._disableInteractions(), this._map._container.addEventListener("touchstart", this._handleTouch), this._map._container.addEventListener("touchmove", this._handleTouch), this._map._container.addEventListener("touchend", this._handleTouch), this._map._container.addEventListener("touchcancel", this._handleTouch), this._map._container.addEventListener("click", this._handleTouch), L.DomEvent.on(this._map._container, "wheel", this._handleScroll, this), L.DomEvent.on(this._map, "mouseover", this._handleMouseOver, this), L.DomEvent.on(this._map, "mouseout", this._handleMouseOut, this), L.DomEvent.on(this._map, "movestart", this._handleDragging, this), L.DomEvent.on(this._map, "move", this._handleDragging, this), L.DomEvent.on(this._map, "moveend", this._handleDragging, this);
339
+ }, removeHooks: function() {
340
+ this._enableInteractions(), this._map._container.removeEventListener("touchstart", this._handleTouch), this._map._container.removeEventListener("touchmove", this._handleTouch), this._map._container.removeEventListener("touchend", this._handleTouch), this._map._container.removeEventListener("touchcancel", this._handleTouch), this._map._container.removeEventListener("click", this._handleTouch), L.DomEvent.off(this._map._container, "wheel", this._handleScroll, this), L.DomEvent.off(this._map, "mouseover", this._handleMouseOver, this), L.DomEvent.off(this._map, "mouseout", this._handleMouseOut, this), L.DomEvent.off(this._map, "movestart", this._handleDragging, this), L.DomEvent.off(this._map, "move", this._handleDragging, this), L.DomEvent.off(this._map, "moveend", this._handleDragging, this);
341
+ }, _handleDragging: function(o) {
342
+ o.type == "movestart" || o.type == "move" ? r = !0 : o.type == "moveend" && (r = !1);
343
+ }, _disableInteractions: function() {
344
+ this._map.dragging.disable(), this._map.scrollWheelZoom.disable(), this._map.tap && this._map.tap.disable();
345
+ }, _enableInteractions: function() {
346
+ this._map.dragging.enable(), this._map.scrollWheelZoom.enable(), this._map.tap && this._map.tap.enable();
347
+ }, _setupPluginOptions: function() {
348
+ this._map.options.gestureHandlingText && (this._map.options.gestureHandlingOptions.text = this._map.options.gestureHandlingText);
349
+ }, _setLanguageContent: function() {
350
+ var o;
351
+ if (this._map.options.gestureHandlingOptions && this._map.options.gestureHandlingOptions.text && this._map.options.gestureHandlingOptions.text.touch && this._map.options.gestureHandlingOptions.text.scroll && this._map.options.gestureHandlingOptions.text.scrollMac) o = this._map.options.gestureHandlingOptions.text;
352
+ else {
353
+ var h = this._getUserLanguage();
354
+ h || (h = "en"), s[h] && (o = s[h]), o || h.indexOf("-") === -1 || (h = h.split("-")[0], o = s[h]), o || (o = s[h = "en"]);
355
+ }
356
+ var u = !1;
357
+ 0 <= navigator.platform.toUpperCase().indexOf("MAC") && (u = !0);
358
+ var d = o.scroll;
359
+ u && (d = o.scrollMac), this._map._container.setAttribute("data-gesture-handling-touch-content", o.touch), this._map._container.setAttribute("data-gesture-handling-scroll-content", d);
360
+ }, _getUserLanguage: function() {
361
+ return navigator.languages ? navigator.languages[0] : navigator.language || navigator.userLanguage;
362
+ }, _handleTouch: function(o) {
363
+ for (var h = ["leaflet-control-minimap", "leaflet-interactive", "leaflet-popup-content", "leaflet-popup-content-wrapper", "leaflet-popup-close-button", "leaflet-control-zoom-in", "leaflet-control-zoom-out"], u = !1, d = 0; d < h.length; d++) L.DomUtil.hasClass(o.target, h[d]) && (u = !0);
364
+ u ? L.DomUtil.hasClass(o.target, "leaflet-interactive") && o.type === "touchmove" && o.touches.length === 1 ? (L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-touch-warning"), this._disableInteractions()) : L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning") : o.type === "touchmove" || o.type === "touchstart" ? o.touches.length === 1 ? (L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-touch-warning"), this._disableInteractions()) : (o.preventDefault(), this._enableInteractions(), L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning")) : L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning");
365
+ }, _isScrolling: !1, _handleScroll: function(o) {
366
+ o.metaKey || o.ctrlKey ? (o.preventDefault(), L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-scroll-warning"), this._map.scrollWheelZoom.enable()) : (L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-scroll-warning"), this._map.scrollWheelZoom.disable(), clearTimeout(this._isScrolling), this._isScrolling = setTimeout(function() {
367
+ for (var h = document.getElementsByClassName("leaflet-gesture-handling-scroll-warning"), u = 0; u < h.length; u++) L.DomUtil.removeClass(h[u], "leaflet-gesture-handling-scroll-warning");
368
+ }, this._map.options.gestureHandlingOptions.duration));
369
+ }, _handleMouseOver: function(o) {
370
+ this._enableInteractions();
371
+ }, _handleMouseOut: function(o) {
372
+ r || this._disableInteractions();
373
+ } });
374
+ L.Map.addInitHook("addHandler", "gestureHandling", a), e.GestureHandling = a, e.default = a, Object.defineProperty(e, "__esModule", { value: !0 });
375
+ });
376
+ }(Nt, Nt.exports)), Nt.exports;
377
+ }
378
+ as();
379
+ const ls = (i) => `/maps/v1/${i}/{z}/{x}/{y}`, Yt = (i) => `/tiles/v1/${i}`, cs = {
380
+ default: [
381
+ {
382
+ name: "base",
383
+ type: "RiskscapeTileLayer",
384
+ layerUrl: ls("default"),
385
+ layerOptions: {
386
+ pane: "tilePane",
387
+ zIndex: 4,
388
+ maxZoom: 20,
389
+ tileSize: 512,
390
+ zoomOffset: -1,
391
+ crossOrigin: !0
392
+ }
393
+ },
394
+ {
395
+ name: "wmsDefault",
396
+ type: "RiskscapeWmsLayer",
397
+ layerUrl: Yt("default"),
398
+ layerOptions: {
399
+ pane: "tilePane",
400
+ zIndex: 2,
401
+ minZoom: 12,
402
+ maxZoom: 20,
403
+ tileSize: 512,
404
+ zoomOffset: -1
405
+ }
406
+ },
407
+ {
408
+ name: "wmsDefaultLabels",
409
+ type: "RiskscapeWmsLayer",
410
+ layerUrl: Yt("default-labels"),
411
+ layerOptions: {
412
+ pane: "overlayPane",
413
+ zIndex: 10,
414
+ minZoom: 13,
415
+ maxZoom: 20,
416
+ tileSize: 512,
417
+ zoomOffset: -1
418
+ }
419
+ }
420
+ ],
421
+ hybrid: [
422
+ {
423
+ name: "googleSatellite",
424
+ type: "GoogleMutant",
425
+ layerOptions: {
426
+ type: "satellite"
427
+ }
428
+ },
429
+ {
430
+ name: "wmsHybrid",
431
+ type: "RiskscapeWmsLayer",
432
+ layerUrl: Yt("hybrid"),
433
+ layerOptions: {
434
+ pane: "tilePane",
435
+ zIndex: 1,
436
+ minZoom: 5,
437
+ maxZoom: 20,
438
+ tileSize: 512,
439
+ zoomOffset: -1
440
+ }
441
+ },
442
+ {
443
+ name: "wmsHybridLabels",
444
+ type: "RiskscapeWmsLayer",
445
+ layerUrl: Yt("hybrid-labels"),
446
+ layerOptions: {
447
+ pane: "overlayPane",
448
+ minZoom: 5,
449
+ maxZoom: 20,
450
+ tileSize: 512,
451
+ zoomOffset: -1
452
+ }
453
+ }
454
+ ]
455
+ };
456
+ function hs(i) {
457
+ return cs[i];
458
+ }
459
+ function us(i) {
460
+ return {
461
+ lat: i.lat.toFixed(6),
462
+ lon: i.lng.toFixed(6)
463
+ };
464
+ }
465
+ function ds(i) {
466
+ const t = us(i);
467
+ return `${t.lat},${t.lon}`;
468
+ }
469
+ var T, ni, ri, oi, ai, li, ci, hi, Ct;
470
+ class Pe extends L.Map {
471
+ /**
472
+ * Creates a new RiskscapeMap instance
473
+ * @param {Object} config - Configuration object
474
+ * @param {string} config.key - API key for Riskscape services
475
+ * @param {HTMLElement|string} config.element - HTML element or element ID to render the map
476
+ * @param {Object} [config.url] - Base URL for Riskscape API
477
+ * @param {string} [config.style='default'] - Map style to use ('default' or 'hybrid')
478
+ * @param {string} [config.googleKey] - Google Maps API key (required for 'hybrid' style)
479
+ * @param {Object} [config.featureStyle] - Custom style for features
480
+ * @param {Object} [config.locationFeatureStyle] - Custom style for location features
481
+ * @param {string} [config.operationMode='default'] - Mode for feature selection
482
+ * @param {Object} [config.options] - Additional Leaflet map options
483
+ * @throws {Error} Will throw an error if API key is not provided
484
+ * @throws {Error} Will throw an error if googleKey is not provided when style is 'hybrid'
485
+ * @note The map requires Ctrl + scrollwheel for zooming (like Google Maps)
486
+ */
487
+ constructor(e) {
488
+ let s = e == null ? void 0 : e.key;
489
+ if (!s)
490
+ throw new Error("API key is required.");
491
+ let r = e.element, a = e.options;
492
+ const o = (e == null ? void 0 : e.style) || "default", h = e == null ? void 0 : e.googleKey;
493
+ if (o === "hybrid" && !h)
494
+ throw new Error("Google API key is required for hybrid style.");
495
+ let u = {
496
+ key: s,
497
+ googleKey: h,
498
+ url: (e == null ? void 0 : e.url) || "https://api.cloud.riskscape.pro",
499
+ style: o,
500
+ featureStyle: (e == null ? void 0 : e.featureStyle) || {
501
+ weight: 2,
502
+ color: "white",
503
+ fillColor: "#1E88E5",
504
+ fillOpacity: 0.3
505
+ },
506
+ locationFeatureStyle: (e == null ? void 0 : e.locationFeatureStyle) || {
507
+ weight: 3,
508
+ color: "#1E88E5",
509
+ fill: !1,
510
+ dashArray: "15,5"
511
+ },
512
+ operationMode: (e == null ? void 0 : e.operationMode) || "default"
513
+ };
514
+ if (a = { ...{
515
+ zoom: 5,
516
+ center: [-29.15, 25.15],
517
+ minZoom: 5,
518
+ maxZoom: 20,
519
+ gestureHandling: !0
520
+ }, ...a }, a.maxZoom > 20)
521
+ throw new Error("Max zoom level cannot be greater than 20.");
522
+ super(r, a);
523
+ _(this, T);
524
+ S(this, "_api");
525
+ S(this, "_search");
526
+ S(this, "_searchMarker");
527
+ S(this, "_unitSelector");
528
+ S(this, "_loading", !1);
529
+ S(this, "_locationFeature");
530
+ S(this, "_handleMapClick", async (e) => {
531
+ this.getZoom() <= 15 || await l(this, T, Ct).call(this, "property_scheme", e.latlng);
532
+ });
533
+ S(this, "_handleSearchSelect", async ({ candidate: e }) => {
534
+ this._removeSearchMarker(), this._removeLocationFeature();
535
+ const { category: s, subcategory: r, position: a, attributes: o } = e, h = [a.lat, a.lon];
536
+ if (this.pluginOptions.operationMode === "identify") {
537
+ if (s === "StreetAddress") {
538
+ if (r === "StreetNumberScheme") {
539
+ await l(this, T, Ct).call(this, "scheme", { id: o.scheme_id });
540
+ return;
541
+ }
542
+ if (r === "SchemeUnit") {
543
+ await l(this, T, Ct).call(this, "scheme", { id: o.scheme_id }, {
544
+ unit_number: e.attributes.unit_number,
545
+ property_key: e.attributes.property_key
546
+ });
547
+ return;
548
+ }
549
+ if (!o.property_key) {
550
+ this._setSearchMarker(h);
551
+ return;
552
+ }
553
+ await l(this, T, Ct).call(this, "property", { id: o.property_key });
554
+ return;
555
+ }
556
+ if (s === "Scheme" && r !== "Commercial") {
557
+ await l(this, T, Ct).call(this, "scheme", { id: o.scheme_id });
558
+ return;
559
+ }
560
+ }
561
+ if (s === "Location") {
562
+ const u = await this._getFeature("location", { id: o.location_id });
563
+ this._setLocationFeature(u);
564
+ return;
565
+ }
566
+ this._setSearchMarker(h);
567
+ });
568
+ this._api = new rs({
569
+ apiKey: u.key,
570
+ baseUrl: u.url
571
+ }), this._unitSelector = new ns({
572
+ placeholder: "Type to search unit numbers..."
573
+ }), this.pluginOptions = u, this.styleLayers = {}, l(this, T, ni).call(this).catch((y) => {
574
+ console.error("Failed to setup map:", y);
575
+ });
576
+ }
577
+ _withLatLonParams(e) {
578
+ const s = {
579
+ ...e
580
+ };
581
+ return s != null && s.lng && (s.latlon = ds(s), delete s.lat, delete s.lng), s;
582
+ }
583
+ async _getFeature(e, s) {
584
+ if (!this._loading) {
585
+ this._loading = !0;
586
+ try {
587
+ const { data: r } = await this._api.fetchFeature(e, this._withLatLonParams(s));
588
+ return r;
589
+ } catch (r) {
590
+ console.error("Failed to fetch feature:", r);
591
+ } finally {
592
+ this._loading = !1;
593
+ }
594
+ }
595
+ }
596
+ _setLocationFeature(e) {
597
+ this._removeLocationFeature(), e && (this._locationFeature = L.geoJSON(e, {
598
+ style: this.pluginOptions.locationFeatureStyle
599
+ }).addTo(this), this.fitBounds(this._locationFeature.getBounds()));
600
+ }
601
+ _removeLocationFeature() {
602
+ var e;
603
+ (e = this._locationFeature) == null || e.remove();
604
+ }
605
+ _setSearchMarker(e) {
606
+ this._searchMarker = L.marker(e).addTo(this);
607
+ const s = this.getZoom();
608
+ this.setView(e, s >= 17 ? s : 17);
609
+ }
610
+ _removeSearchMarker() {
611
+ var e;
612
+ (e = this._searchMarker) == null || e.remove();
613
+ }
614
+ bindSearch(e, s) {
615
+ this._search = e, this._search.bindToMap(), this._search.on("select", this._handleSearchSelect.bind(this));
616
+ }
617
+ /**
618
+ * Set the map style
619
+ * @param {string} style - The style to use ('default' or 'hybrid')
620
+ * @throws {Error} Will throw an error if style is not valid
621
+ * @throws {Error} Will throw an error if googleKey is not provided when style is 'hybrid'
622
+ */
623
+ async setStyle(e) {
624
+ const s = hs(e);
625
+ if (!s)
626
+ throw new Error(`Style "${e}" is not valid.`);
627
+ if (e === "hybrid" && !this.pluginOptions.googleKey)
628
+ throw new Error("Google API key is required for hybrid style.");
629
+ for (const r in this.styleLayers)
630
+ this.removeLayer(this.styleLayers[r]);
631
+ for (const r of s) {
632
+ let a = null;
633
+ if (r.type !== "GoogleMutant") {
634
+ const o = L[r.type];
635
+ if (!o)
636
+ throw new Error(`Layer type "${r.type}" is not valid.`);
637
+ a = new o(
638
+ this.pluginOptions.url + r.layerUrl,
639
+ r.layerOptions,
640
+ this.pluginOptions.key
641
+ );
642
+ }
643
+ a && (this.styleLayers[r.name] = a.addTo(this));
644
+ }
645
+ this.pluginOptions.style = e;
646
+ }
647
+ setOperationMode(e) {
648
+ this.off("click"), this.pluginOptions.operationMode = e, e === "identify" && this.on("click", this._handleMapClick.bind(this));
649
+ }
650
+ enableInteraction() {
651
+ this.dragging.enable(), this.touchZoom.enable(), this.doubleClickZoom.enable(), this.scrollWheelZoom.enable(), this.boxZoom.enable(), this.keyboard.enable(), this.tap && this.tap.enable();
652
+ }
653
+ disableInteraction() {
654
+ this.dragging.disable(), this.touchZoom.disable(), this.doubleClickZoom.disable(), this.scrollWheelZoom.disable(), this.boxZoom.disable(), this.keyboard.disable(), this.tap && this.tap.disable();
655
+ }
656
+ /**
657
+ * Unbind search instance from the map
658
+ */
659
+ unbindSearch() {
660
+ this._search && (this._search.off("select", this._handleSearchSelect), this._search.unbindFromMap(), this._search = null);
661
+ }
662
+ /**
663
+ * Destroy the map and clean up all resources
664
+ * This method should be called when the map is no longer needed
665
+ */
666
+ destroy() {
667
+ this._unitSelector && (this._unitSelector = null), this.unbindSearch();
668
+ }
669
+ }
670
+ T = new WeakSet(), ni = async function() {
671
+ try {
672
+ await this.setStyle(this.pluginOptions.style);
673
+ } catch (e) {
674
+ console.error("Failed to set map style:", e), this.pluginOptions.style === "hybrid" && (console.warn("Falling back to default style"), this.pluginOptions.style = "default", await this.setStyle("default"));
675
+ }
676
+ this.zoomControl && this.zoomControl.setPosition("bottomright"), this.attributionControl && this.attributionControl.setPrefix(`
677
+ Powered by <a href="https://riskscape.pro/powered-by" target="_blank" style="color: #b01d21 !important;">Riskscape</a>
678
+ | &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors
679
+ `), this.setOperationMode(this.pluginOptions.operationMode);
680
+ }, ri = async function(e) {
681
+ return e.type === "scheme" ? await l(this, T, ai).call(this, e.scheme_id) : e.type === "property" ? await l(this, T, oi).call(this, e.property_key) : null;
682
+ }, oi = async function(e) {
683
+ const { data: s } = await this._api.fetchPropertyUnits(e);
684
+ return s.map((r) => ({
685
+ unit_number: r,
686
+ property_key: e
687
+ }));
688
+ }, ai = async function(e) {
689
+ const { data: s } = await this._api.fetchSchemeUnits(e);
690
+ return s;
691
+ }, li = function(e, s = {}) {
692
+ l(this, T, ci).call(this), s != null && s.style || (s.style = this.pluginOptions.featureStyle), this.feature = e, this.featureLayer = L.geoJSON(this.feature, s), this.featureLayer.addTo(this);
693
+ }, ci = function() {
694
+ var e;
695
+ (e = this.featureLayer) == null || e.remove(), this.feature = null, this.featureLayer = null;
696
+ }, hi = function() {
697
+ this.fitBounds(
698
+ this.featureLayer.getBounds(),
699
+ {
700
+ padding: [50, 50],
701
+ minZoom: 12
702
+ }
703
+ );
704
+ }, Ct = async function(e, s, r = {}) {
705
+ const a = await this._getFeature(e, s);
706
+ if (!a)
707
+ return;
708
+ l(this, T, li).call(this, a), l(this, T, hi).call(this);
709
+ let o = (a == null ? void 0 : a.properties) || {};
710
+ if (o = {
711
+ ...o,
712
+ ...r
713
+ }, o != null && o.has_sectional_units && !(o != null && o.unit_number)) {
714
+ const h = await l(this, T, ri).call(this, o);
715
+ this._unitSelector.show(h, this.getContainer(), this, {
716
+ onSelect: (u) => {
717
+ this.fire("property:identified", {
718
+ property: {
719
+ unit_number: u.unit_number,
720
+ property_key: u.property_key,
721
+ address_id: o.address_id
722
+ }
723
+ });
724
+ },
725
+ onCancel: () => {
726
+ }
727
+ });
728
+ return;
729
+ }
730
+ this.fire("property:identified", {
731
+ property: {
732
+ unit_number: o.unit_number || "00000",
733
+ property_key: o.property_key,
734
+ address_id: o.address_id
735
+ }
736
+ // latlng: e.latlng
737
+ });
738
+ };
739
+ function ps(i) {
740
+ return /^[A-Z0-9]{8}[0-9]{13}$/.test(i);
741
+ }
742
+ function ms(i) {
743
+ return /^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?((180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?))$/.test(i);
744
+ }
745
+ const te = {
746
+ // API and service configuration
747
+ API_TIMEOUT: 5e3,
748
+ // UI configuration
749
+ DEFAULT_MIN_CHARS: 5,
750
+ DEFAULT_MAX_RESULTS: 10,
751
+ DEFAULT_DEBOUNCE_TIME: 400
752
+ }, Ne = {
753
+ MISSING_ELEMENT: 'Configuration error: "element" id is required',
754
+ ELEMENT_NOT_FOUND: (i) => `Element with id "${i}" not found`,
755
+ API_KEY_REQUIRED: "API Key is required",
756
+ UNAUTHORIZED: "Authentication error. Please check your API key.",
757
+ NETWORK_ERROR: "Network error. Please check your connection and try again.",
758
+ GENERIC_ERROR: "An error occurred while searching. Please try again.",
759
+ NO_RESULTS: (i) => "No results found. Try a different search term."
760
+ // NO_RESULTS: (query) => `No results found for "${query}". Try a different search term.`
761
+ };
762
+ function fs(i) {
763
+ return { all: i = i || /* @__PURE__ */ new Map(), on: function(t, e) {
764
+ var s = i.get(t);
765
+ s ? s.push(e) : i.set(t, [e]);
766
+ }, off: function(t, e) {
767
+ var s = i.get(t);
768
+ s && (e ? s.splice(s.indexOf(e) >>> 0, 1) : i.set(t, []));
769
+ }, emit: function(t, e) {
770
+ var s = i.get(t);
771
+ s && s.slice().map(function(r) {
772
+ r(e);
773
+ }), (s = i.get("*")) && s.slice().map(function(r) {
774
+ r(t, e);
775
+ });
776
+ } };
777
+ }
778
+ function gs(i, t) {
779
+ let e;
780
+ return function(...r) {
781
+ const a = () => {
782
+ clearTimeout(e), i.apply(this, r);
783
+ };
784
+ clearTimeout(e), e = setTimeout(a, t);
785
+ };
786
+ }
787
+ function Ie(i) {
788
+ return i ? i.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").toLowerCase().replace(/\b\w/g, (t) => t.toUpperCase()) : "";
789
+ }
790
+ function Fe(i, t) {
791
+ return !i || !t ? !1 : i.toLowerCase().startsWith(t.toLowerCase());
792
+ }
793
+ const se = Math.min, bt = Math.max, ne = Math.round, Xt = Math.floor, tt = (i) => ({
794
+ x: i,
795
+ y: i
796
+ }), ys = {
797
+ left: "right",
798
+ right: "left",
799
+ bottom: "top",
800
+ top: "bottom"
801
+ }, _s = {
802
+ start: "end",
803
+ end: "start"
804
+ };
805
+ function He(i, t, e) {
806
+ return bt(i, se(t, e));
807
+ }
808
+ function ce(i, t) {
809
+ return typeof i == "function" ? i(t) : i;
810
+ }
811
+ function wt(i) {
812
+ return i.split("-")[0];
813
+ }
814
+ function he(i) {
815
+ return i.split("-")[1];
816
+ }
817
+ function ui(i) {
818
+ return i === "x" ? "y" : "x";
819
+ }
820
+ function di(i) {
821
+ return i === "y" ? "height" : "width";
822
+ }
823
+ const bs = /* @__PURE__ */ new Set(["top", "bottom"]);
824
+ function ht(i) {
825
+ return bs.has(wt(i)) ? "y" : "x";
826
+ }
827
+ function pi(i) {
828
+ return ui(ht(i));
829
+ }
830
+ function ws(i, t, e) {
831
+ e === void 0 && (e = !1);
832
+ const s = he(i), r = pi(i), a = di(r);
833
+ let o = r === "x" ? s === (e ? "end" : "start") ? "right" : "left" : s === "start" ? "bottom" : "top";
834
+ return t.reference[a] > t.floating[a] && (o = re(o)), [o, re(o)];
835
+ }
836
+ function vs(i) {
837
+ const t = re(i);
838
+ return [ve(i), t, ve(t)];
839
+ }
840
+ function ve(i) {
841
+ return i.replace(/start|end/g, (t) => _s[t]);
842
+ }
843
+ const Be = ["left", "right"], We = ["right", "left"], xs = ["top", "bottom"], ks = ["bottom", "top"];
844
+ function Ls(i, t, e) {
845
+ switch (i) {
846
+ case "top":
847
+ case "bottom":
848
+ return e ? t ? We : Be : t ? Be : We;
849
+ case "left":
850
+ case "right":
851
+ return t ? xs : ks;
852
+ default:
853
+ return [];
854
+ }
855
+ }
856
+ function Es(i, t, e, s) {
857
+ const r = he(i);
858
+ let a = Ls(wt(i), e === "start", s);
859
+ return r && (a = a.map((o) => o + "-" + r), t && (a = a.concat(a.map(ve)))), a;
860
+ }
861
+ function re(i) {
862
+ return i.replace(/left|right|bottom|top/g, (t) => ys[t]);
863
+ }
864
+ function Cs(i) {
865
+ return {
866
+ top: 0,
867
+ right: 0,
868
+ bottom: 0,
869
+ left: 0,
870
+ ...i
871
+ };
872
+ }
873
+ function As(i) {
874
+ return typeof i != "number" ? Cs(i) : {
875
+ top: i,
876
+ right: i,
877
+ bottom: i,
878
+ left: i
879
+ };
880
+ }
881
+ function oe(i) {
882
+ const {
883
+ x: t,
884
+ y: e,
885
+ width: s,
886
+ height: r
887
+ } = i;
888
+ return {
889
+ width: s,
890
+ height: r,
891
+ top: e,
892
+ left: t,
893
+ right: t + s,
894
+ bottom: e + r,
895
+ x: t,
896
+ y: e
897
+ };
898
+ }
899
+ function $e(i, t, e) {
900
+ let {
901
+ reference: s,
902
+ floating: r
903
+ } = i;
904
+ const a = ht(t), o = pi(t), h = di(o), u = wt(t), d = a === "y", y = s.x + s.width / 2 - r.width / 2, m = s.y + s.height / 2 - r.height / 2, b = s[h] / 2 - r[h] / 2;
905
+ let f;
906
+ switch (u) {
907
+ case "top":
908
+ f = {
909
+ x: y,
910
+ y: s.y - r.height
911
+ };
912
+ break;
913
+ case "bottom":
914
+ f = {
915
+ x: y,
916
+ y: s.y + s.height
917
+ };
918
+ break;
919
+ case "right":
920
+ f = {
921
+ x: s.x + s.width,
922
+ y: m
923
+ };
924
+ break;
925
+ case "left":
926
+ f = {
927
+ x: s.x - r.width,
928
+ y: m
929
+ };
930
+ break;
931
+ default:
932
+ f = {
933
+ x: s.x,
934
+ y: s.y
935
+ };
936
+ }
937
+ switch (he(t)) {
938
+ case "start":
939
+ f[o] -= b * (e && d ? -1 : 1);
940
+ break;
941
+ case "end":
942
+ f[o] += b * (e && d ? -1 : 1);
943
+ break;
944
+ }
945
+ return f;
946
+ }
947
+ const Ss = async (i, t, e) => {
948
+ const {
949
+ placement: s = "bottom",
950
+ strategy: r = "absolute",
951
+ middleware: a = [],
952
+ platform: o
953
+ } = e, h = a.filter(Boolean), u = await (o.isRTL == null ? void 0 : o.isRTL(t));
954
+ let d = await o.getElementRects({
955
+ reference: i,
956
+ floating: t,
957
+ strategy: r
958
+ }), {
959
+ x: y,
960
+ y: m
961
+ } = $e(d, s, u), b = s, f = {}, v = 0;
962
+ for (let k = 0; k < h.length; k++) {
963
+ const {
964
+ name: C,
965
+ fn: x
966
+ } = h[k], {
967
+ x: A,
968
+ y: R,
969
+ data: F,
970
+ reset: D
971
+ } = await x({
972
+ x: y,
973
+ y: m,
974
+ initialPlacement: s,
975
+ placement: b,
976
+ strategy: r,
977
+ middlewareData: f,
978
+ rects: d,
979
+ platform: o,
980
+ elements: {
981
+ reference: i,
982
+ floating: t
983
+ }
984
+ });
985
+ y = A ?? y, m = R ?? m, f = {
986
+ ...f,
987
+ [C]: {
988
+ ...f[C],
989
+ ...F
990
+ }
991
+ }, D && v <= 50 && (v++, typeof D == "object" && (D.placement && (b = D.placement), D.rects && (d = D.rects === !0 ? await o.getElementRects({
992
+ reference: i,
993
+ floating: t,
994
+ strategy: r
995
+ }) : D.rects), {
996
+ x: y,
997
+ y: m
998
+ } = $e(d, b, u)), k = -1);
999
+ }
1000
+ return {
1001
+ x: y,
1002
+ y: m,
1003
+ placement: b,
1004
+ strategy: r,
1005
+ middlewareData: f
1006
+ };
1007
+ };
1008
+ async function mi(i, t) {
1009
+ var e;
1010
+ t === void 0 && (t = {});
1011
+ const {
1012
+ x: s,
1013
+ y: r,
1014
+ platform: a,
1015
+ rects: o,
1016
+ elements: h,
1017
+ strategy: u
1018
+ } = i, {
1019
+ boundary: d = "clippingAncestors",
1020
+ rootBoundary: y = "viewport",
1021
+ elementContext: m = "floating",
1022
+ altBoundary: b = !1,
1023
+ padding: f = 0
1024
+ } = ce(t, i), v = As(f), C = h[b ? m === "floating" ? "reference" : "floating" : m], x = oe(await a.getClippingRect({
1025
+ element: (e = await (a.isElement == null ? void 0 : a.isElement(C))) == null || e ? C : C.contextElement || await (a.getDocumentElement == null ? void 0 : a.getDocumentElement(h.floating)),
1026
+ boundary: d,
1027
+ rootBoundary: y,
1028
+ strategy: u
1029
+ })), A = m === "floating" ? {
1030
+ x: s,
1031
+ y: r,
1032
+ width: o.floating.width,
1033
+ height: o.floating.height
1034
+ } : o.reference, R = await (a.getOffsetParent == null ? void 0 : a.getOffsetParent(h.floating)), F = await (a.isElement == null ? void 0 : a.isElement(R)) ? await (a.getScale == null ? void 0 : a.getScale(R)) || {
1035
+ x: 1,
1036
+ y: 1
1037
+ } : {
1038
+ x: 1,
1039
+ y: 1
1040
+ }, D = oe(a.convertOffsetParentRelativeRectToViewportRelativeRect ? await a.convertOffsetParentRelativeRectToViewportRelativeRect({
1041
+ elements: h,
1042
+ rect: A,
1043
+ offsetParent: R,
1044
+ strategy: u
1045
+ }) : A);
1046
+ return {
1047
+ top: (x.top - D.top + v.top) / F.y,
1048
+ bottom: (D.bottom - x.bottom + v.bottom) / F.y,
1049
+ left: (x.left - D.left + v.left) / F.x,
1050
+ right: (D.right - x.right + v.right) / F.x
1051
+ };
1052
+ }
1053
+ const Ms = function(i) {
1054
+ return i === void 0 && (i = {}), {
1055
+ name: "flip",
1056
+ options: i,
1057
+ async fn(t) {
1058
+ var e, s;
1059
+ const {
1060
+ placement: r,
1061
+ middlewareData: a,
1062
+ rects: o,
1063
+ initialPlacement: h,
1064
+ platform: u,
1065
+ elements: d
1066
+ } = t, {
1067
+ mainAxis: y = !0,
1068
+ crossAxis: m = !0,
1069
+ fallbackPlacements: b,
1070
+ fallbackStrategy: f = "bestFit",
1071
+ fallbackAxisSideDirection: v = "none",
1072
+ flipAlignment: k = !0,
1073
+ ...C
1074
+ } = ce(i, t);
1075
+ if ((e = a.arrow) != null && e.alignmentOffset)
1076
+ return {};
1077
+ const x = wt(r), A = ht(h), R = wt(h) === h, F = await (u.isRTL == null ? void 0 : u.isRTL(d.floating)), D = b || (R || !k ? [re(h)] : vs(h)), Rt = v !== "none";
1078
+ !b && Rt && D.push(...Es(h, k, v, F));
1079
+ const kt = [h, ...D], me = await mi(t, C), qt = [];
1080
+ let Lt = ((s = a.flip) == null ? void 0 : s.overflows) || [];
1081
+ if (y && qt.push(me[x]), m) {
1082
+ const dt = ws(r, o, F);
1083
+ qt.push(me[dt[0]], me[dt[1]]);
1084
+ }
1085
+ if (Lt = [...Lt, {
1086
+ placement: r,
1087
+ overflows: qt
1088
+ }], !qt.every((dt) => dt <= 0)) {
1089
+ var Oe, Re;
1090
+ const dt = (((Oe = a.flip) == null ? void 0 : Oe.index) || 0) + 1, fe = kt[dt];
1091
+ if (fe && (!(m === "alignment" ? A !== ht(fe) : !1) || // We leave the current main axis only if every placement on that axis
1092
+ // overflows the main axis.
1093
+ Lt.every((Z) => Z.overflows[0] > 0 && ht(Z.placement) === A)))
1094
+ return {
1095
+ data: {
1096
+ index: dt,
1097
+ overflows: Lt
1098
+ },
1099
+ reset: {
1100
+ placement: fe
1101
+ }
1102
+ };
1103
+ let zt = (Re = Lt.filter((pt) => pt.overflows[0] <= 0).sort((pt, Z) => pt.overflows[1] - Z.overflows[1])[0]) == null ? void 0 : Re.placement;
1104
+ if (!zt)
1105
+ switch (f) {
1106
+ case "bestFit": {
1107
+ var ze;
1108
+ const pt = (ze = Lt.filter((Z) => {
1109
+ if (Rt) {
1110
+ const rt = ht(Z.placement);
1111
+ return rt === A || // Create a bias to the `y` side axis due to horizontal
1112
+ // reading directions favoring greater width.
1113
+ rt === "y";
1114
+ }
1115
+ return !0;
1116
+ }).map((Z) => [Z.placement, Z.overflows.filter((rt) => rt > 0).reduce((rt, Qi) => rt + Qi, 0)]).sort((Z, rt) => Z[1] - rt[1])[0]) == null ? void 0 : ze[0];
1117
+ pt && (zt = pt);
1118
+ break;
1119
+ }
1120
+ case "initialPlacement":
1121
+ zt = h;
1122
+ break;
1123
+ }
1124
+ if (r !== zt)
1125
+ return {
1126
+ reset: {
1127
+ placement: zt
1128
+ }
1129
+ };
1130
+ }
1131
+ return {};
1132
+ }
1133
+ };
1134
+ }, Ts = /* @__PURE__ */ new Set(["left", "top"]);
1135
+ async function Os(i, t) {
1136
+ const {
1137
+ placement: e,
1138
+ platform: s,
1139
+ elements: r
1140
+ } = i, a = await (s.isRTL == null ? void 0 : s.isRTL(r.floating)), o = wt(e), h = he(e), u = ht(e) === "y", d = Ts.has(o) ? -1 : 1, y = a && u ? -1 : 1, m = ce(t, i);
1141
+ let {
1142
+ mainAxis: b,
1143
+ crossAxis: f,
1144
+ alignmentAxis: v
1145
+ } = typeof m == "number" ? {
1146
+ mainAxis: m,
1147
+ crossAxis: 0,
1148
+ alignmentAxis: null
1149
+ } : {
1150
+ mainAxis: m.mainAxis || 0,
1151
+ crossAxis: m.crossAxis || 0,
1152
+ alignmentAxis: m.alignmentAxis
1153
+ };
1154
+ return h && typeof v == "number" && (f = h === "end" ? v * -1 : v), u ? {
1155
+ x: f * y,
1156
+ y: b * d
1157
+ } : {
1158
+ x: b * d,
1159
+ y: f * y
1160
+ };
1161
+ }
1162
+ const Rs = function(i) {
1163
+ return i === void 0 && (i = 0), {
1164
+ name: "offset",
1165
+ options: i,
1166
+ async fn(t) {
1167
+ var e, s;
1168
+ const {
1169
+ x: r,
1170
+ y: a,
1171
+ placement: o,
1172
+ middlewareData: h
1173
+ } = t, u = await Os(t, i);
1174
+ return o === ((e = h.offset) == null ? void 0 : e.placement) && (s = h.arrow) != null && s.alignmentOffset ? {} : {
1175
+ x: r + u.x,
1176
+ y: a + u.y,
1177
+ data: {
1178
+ ...u,
1179
+ placement: o
1180
+ }
1181
+ };
1182
+ }
1183
+ };
1184
+ }, zs = function(i) {
1185
+ return i === void 0 && (i = {}), {
1186
+ name: "shift",
1187
+ options: i,
1188
+ async fn(t) {
1189
+ const {
1190
+ x: e,
1191
+ y: s,
1192
+ placement: r
1193
+ } = t, {
1194
+ mainAxis: a = !0,
1195
+ crossAxis: o = !1,
1196
+ limiter: h = {
1197
+ fn: (C) => {
1198
+ let {
1199
+ x,
1200
+ y: A
1201
+ } = C;
1202
+ return {
1203
+ x,
1204
+ y: A
1205
+ };
1206
+ }
1207
+ },
1208
+ ...u
1209
+ } = ce(i, t), d = {
1210
+ x: e,
1211
+ y: s
1212
+ }, y = await mi(t, u), m = ht(wt(r)), b = ui(m);
1213
+ let f = d[b], v = d[m];
1214
+ if (a) {
1215
+ const C = b === "y" ? "top" : "left", x = b === "y" ? "bottom" : "right", A = f + y[C], R = f - y[x];
1216
+ f = He(A, f, R);
1217
+ }
1218
+ if (o) {
1219
+ const C = m === "y" ? "top" : "left", x = m === "y" ? "bottom" : "right", A = v + y[C], R = v - y[x];
1220
+ v = He(A, v, R);
1221
+ }
1222
+ const k = h.fn({
1223
+ ...t,
1224
+ [b]: f,
1225
+ [m]: v
1226
+ });
1227
+ return {
1228
+ ...k,
1229
+ data: {
1230
+ x: k.x - e,
1231
+ y: k.y - s,
1232
+ enabled: {
1233
+ [b]: a,
1234
+ [m]: o
1235
+ }
1236
+ }
1237
+ };
1238
+ }
1239
+ };
1240
+ };
1241
+ function ue() {
1242
+ return typeof window < "u";
1243
+ }
1244
+ function Ot(i) {
1245
+ return fi(i) ? (i.nodeName || "").toLowerCase() : "#document";
1246
+ }
1247
+ function $(i) {
1248
+ var t;
1249
+ return (i == null || (t = i.ownerDocument) == null ? void 0 : t.defaultView) || window;
1250
+ }
1251
+ function it(i) {
1252
+ var t;
1253
+ return (t = (fi(i) ? i.ownerDocument : i.document) || window.document) == null ? void 0 : t.documentElement;
1254
+ }
1255
+ function fi(i) {
1256
+ return ue() ? i instanceof Node || i instanceof $(i).Node : !1;
1257
+ }
1258
+ function Y(i) {
1259
+ return ue() ? i instanceof Element || i instanceof $(i).Element : !1;
1260
+ }
1261
+ function et(i) {
1262
+ return ue() ? i instanceof HTMLElement || i instanceof $(i).HTMLElement : !1;
1263
+ }
1264
+ function je(i) {
1265
+ return !ue() || typeof ShadowRoot > "u" ? !1 : i instanceof ShadowRoot || i instanceof $(i).ShadowRoot;
1266
+ }
1267
+ const Ds = /* @__PURE__ */ new Set(["inline", "contents"]);
1268
+ function Vt(i) {
1269
+ const {
1270
+ overflow: t,
1271
+ overflowX: e,
1272
+ overflowY: s,
1273
+ display: r
1274
+ } = X(i);
1275
+ return /auto|scroll|overlay|hidden|clip/.test(t + s + e) && !Ds.has(r);
1276
+ }
1277
+ const Us = /* @__PURE__ */ new Set(["table", "td", "th"]);
1278
+ function Ps(i) {
1279
+ return Us.has(Ot(i));
1280
+ }
1281
+ const Ns = [":popover-open", ":modal"];
1282
+ function de(i) {
1283
+ return Ns.some((t) => {
1284
+ try {
1285
+ return i.matches(t);
1286
+ } catch {
1287
+ return !1;
1288
+ }
1289
+ });
1290
+ }
1291
+ const Is = ["transform", "translate", "scale", "rotate", "perspective"], Fs = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Hs = ["paint", "layout", "strict", "content"];
1292
+ function Ae(i) {
1293
+ const t = Se(), e = Y(i) ? X(i) : i;
1294
+ return Is.some((s) => e[s] ? e[s] !== "none" : !1) || (e.containerType ? e.containerType !== "normal" : !1) || !t && (e.backdropFilter ? e.backdropFilter !== "none" : !1) || !t && (e.filter ? e.filter !== "none" : !1) || Fs.some((s) => (e.willChange || "").includes(s)) || Hs.some((s) => (e.contain || "").includes(s));
1295
+ }
1296
+ function Bs(i) {
1297
+ let t = ut(i);
1298
+ for (; et(t) && !Tt(t); ) {
1299
+ if (Ae(t))
1300
+ return t;
1301
+ if (de(t))
1302
+ return null;
1303
+ t = ut(t);
1304
+ }
1305
+ return null;
1306
+ }
1307
+ function Se() {
1308
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
1309
+ }
1310
+ const Ws = /* @__PURE__ */ new Set(["html", "body", "#document"]);
1311
+ function Tt(i) {
1312
+ return Ws.has(Ot(i));
1313
+ }
1314
+ function X(i) {
1315
+ return $(i).getComputedStyle(i);
1316
+ }
1317
+ function pe(i) {
1318
+ return Y(i) ? {
1319
+ scrollLeft: i.scrollLeft,
1320
+ scrollTop: i.scrollTop
1321
+ } : {
1322
+ scrollLeft: i.scrollX,
1323
+ scrollTop: i.scrollY
1324
+ };
1325
+ }
1326
+ function ut(i) {
1327
+ if (Ot(i) === "html")
1328
+ return i;
1329
+ const t = (
1330
+ // Step into the shadow DOM of the parent of a slotted node.
1331
+ i.assignedSlot || // DOM Element detected.
1332
+ i.parentNode || // ShadowRoot detected.
1333
+ je(i) && i.host || // Fallback.
1334
+ it(i)
1335
+ );
1336
+ return je(t) ? t.host : t;
1337
+ }
1338
+ function gi(i) {
1339
+ const t = ut(i);
1340
+ return Tt(t) ? i.ownerDocument ? i.ownerDocument.body : i.body : et(t) && Vt(t) ? t : gi(t);
1341
+ }
1342
+ function Bt(i, t, e) {
1343
+ var s;
1344
+ t === void 0 && (t = []), e === void 0 && (e = !0);
1345
+ const r = gi(i), a = r === ((s = i.ownerDocument) == null ? void 0 : s.body), o = $(r);
1346
+ if (a) {
1347
+ const h = xe(o);
1348
+ return t.concat(o, o.visualViewport || [], Vt(r) ? r : [], h && e ? Bt(h) : []);
1349
+ }
1350
+ return t.concat(r, Bt(r, [], e));
1351
+ }
1352
+ function xe(i) {
1353
+ return i.parent && Object.getPrototypeOf(i.parent) ? i.frameElement : null;
1354
+ }
1355
+ function yi(i) {
1356
+ const t = X(i);
1357
+ let e = parseFloat(t.width) || 0, s = parseFloat(t.height) || 0;
1358
+ const r = et(i), a = r ? i.offsetWidth : e, o = r ? i.offsetHeight : s, h = ne(e) !== a || ne(s) !== o;
1359
+ return h && (e = a, s = o), {
1360
+ width: e,
1361
+ height: s,
1362
+ $: h
1363
+ };
1364
+ }
1365
+ function Me(i) {
1366
+ return Y(i) ? i : i.contextElement;
1367
+ }
1368
+ function At(i) {
1369
+ const t = Me(i);
1370
+ if (!et(t))
1371
+ return tt(1);
1372
+ const e = t.getBoundingClientRect(), {
1373
+ width: s,
1374
+ height: r,
1375
+ $: a
1376
+ } = yi(t);
1377
+ let o = (a ? ne(e.width) : e.width) / s, h = (a ? ne(e.height) : e.height) / r;
1378
+ return (!o || !Number.isFinite(o)) && (o = 1), (!h || !Number.isFinite(h)) && (h = 1), {
1379
+ x: o,
1380
+ y: h
1381
+ };
1382
+ }
1383
+ const $s = /* @__PURE__ */ tt(0);
1384
+ function _i(i) {
1385
+ const t = $(i);
1386
+ return !Se() || !t.visualViewport ? $s : {
1387
+ x: t.visualViewport.offsetLeft,
1388
+ y: t.visualViewport.offsetTop
1389
+ };
1390
+ }
1391
+ function js(i, t, e) {
1392
+ return t === void 0 && (t = !1), !e || t && e !== $(i) ? !1 : t;
1393
+ }
1394
+ function vt(i, t, e, s) {
1395
+ t === void 0 && (t = !1), e === void 0 && (e = !1);
1396
+ const r = i.getBoundingClientRect(), a = Me(i);
1397
+ let o = tt(1);
1398
+ t && (s ? Y(s) && (o = At(s)) : o = At(i));
1399
+ const h = js(a, e, s) ? _i(a) : tt(0);
1400
+ let u = (r.left + h.x) / o.x, d = (r.top + h.y) / o.y, y = r.width / o.x, m = r.height / o.y;
1401
+ if (a) {
1402
+ const b = $(a), f = s && Y(s) ? $(s) : s;
1403
+ let v = b, k = xe(v);
1404
+ for (; k && s && f !== v; ) {
1405
+ const C = At(k), x = k.getBoundingClientRect(), A = X(k), R = x.left + (k.clientLeft + parseFloat(A.paddingLeft)) * C.x, F = x.top + (k.clientTop + parseFloat(A.paddingTop)) * C.y;
1406
+ u *= C.x, d *= C.y, y *= C.x, m *= C.y, u += R, d += F, v = $(k), k = xe(v);
1407
+ }
1408
+ }
1409
+ return oe({
1410
+ width: y,
1411
+ height: m,
1412
+ x: u,
1413
+ y: d
1414
+ });
1415
+ }
1416
+ function Te(i, t) {
1417
+ const e = pe(i).scrollLeft;
1418
+ return t ? t.left + e : vt(it(i)).left + e;
1419
+ }
1420
+ function bi(i, t, e) {
1421
+ e === void 0 && (e = !1);
1422
+ const s = i.getBoundingClientRect(), r = s.left + t.scrollLeft - (e ? 0 : (
1423
+ // RTL <body> scrollbar.
1424
+ Te(i, s)
1425
+ )), a = s.top + t.scrollTop;
1426
+ return {
1427
+ x: r,
1428
+ y: a
1429
+ };
1430
+ }
1431
+ function Zs(i) {
1432
+ let {
1433
+ elements: t,
1434
+ rect: e,
1435
+ offsetParent: s,
1436
+ strategy: r
1437
+ } = i;
1438
+ const a = r === "fixed", o = it(s), h = t ? de(t.floating) : !1;
1439
+ if (s === o || h && a)
1440
+ return e;
1441
+ let u = {
1442
+ scrollLeft: 0,
1443
+ scrollTop: 0
1444
+ }, d = tt(1);
1445
+ const y = tt(0), m = et(s);
1446
+ if ((m || !m && !a) && ((Ot(s) !== "body" || Vt(o)) && (u = pe(s)), et(s))) {
1447
+ const f = vt(s);
1448
+ d = At(s), y.x = f.x + s.clientLeft, y.y = f.y + s.clientTop;
1449
+ }
1450
+ const b = o && !m && !a ? bi(o, u, !0) : tt(0);
1451
+ return {
1452
+ width: e.width * d.x,
1453
+ height: e.height * d.y,
1454
+ x: e.x * d.x - u.scrollLeft * d.x + y.x + b.x,
1455
+ y: e.y * d.y - u.scrollTop * d.y + y.y + b.y
1456
+ };
1457
+ }
1458
+ function Ks(i) {
1459
+ return Array.from(i.getClientRects());
1460
+ }
1461
+ function Gs(i) {
1462
+ const t = it(i), e = pe(i), s = i.ownerDocument.body, r = bt(t.scrollWidth, t.clientWidth, s.scrollWidth, s.clientWidth), a = bt(t.scrollHeight, t.clientHeight, s.scrollHeight, s.clientHeight);
1463
+ let o = -e.scrollLeft + Te(i);
1464
+ const h = -e.scrollTop;
1465
+ return X(s).direction === "rtl" && (o += bt(t.clientWidth, s.clientWidth) - r), {
1466
+ width: r,
1467
+ height: a,
1468
+ x: o,
1469
+ y: h
1470
+ };
1471
+ }
1472
+ function Vs(i, t) {
1473
+ const e = $(i), s = it(i), r = e.visualViewport;
1474
+ let a = s.clientWidth, o = s.clientHeight, h = 0, u = 0;
1475
+ if (r) {
1476
+ a = r.width, o = r.height;
1477
+ const d = Se();
1478
+ (!d || d && t === "fixed") && (h = r.offsetLeft, u = r.offsetTop);
1479
+ }
1480
+ return {
1481
+ width: a,
1482
+ height: o,
1483
+ x: h,
1484
+ y: u
1485
+ };
1486
+ }
1487
+ const qs = /* @__PURE__ */ new Set(["absolute", "fixed"]);
1488
+ function Ys(i, t) {
1489
+ const e = vt(i, !0, t === "fixed"), s = e.top + i.clientTop, r = e.left + i.clientLeft, a = et(i) ? At(i) : tt(1), o = i.clientWidth * a.x, h = i.clientHeight * a.y, u = r * a.x, d = s * a.y;
1490
+ return {
1491
+ width: o,
1492
+ height: h,
1493
+ x: u,
1494
+ y: d
1495
+ };
1496
+ }
1497
+ function Ze(i, t, e) {
1498
+ let s;
1499
+ if (t === "viewport")
1500
+ s = Vs(i, e);
1501
+ else if (t === "document")
1502
+ s = Gs(it(i));
1503
+ else if (Y(t))
1504
+ s = Ys(t, e);
1505
+ else {
1506
+ const r = _i(i);
1507
+ s = {
1508
+ x: t.x - r.x,
1509
+ y: t.y - r.y,
1510
+ width: t.width,
1511
+ height: t.height
1512
+ };
1513
+ }
1514
+ return oe(s);
1515
+ }
1516
+ function wi(i, t) {
1517
+ const e = ut(i);
1518
+ return e === t || !Y(e) || Tt(e) ? !1 : X(e).position === "fixed" || wi(e, t);
1519
+ }
1520
+ function Xs(i, t) {
1521
+ const e = t.get(i);
1522
+ if (e)
1523
+ return e;
1524
+ let s = Bt(i, [], !1).filter((h) => Y(h) && Ot(h) !== "body"), r = null;
1525
+ const a = X(i).position === "fixed";
1526
+ let o = a ? ut(i) : i;
1527
+ for (; Y(o) && !Tt(o); ) {
1528
+ const h = X(o), u = Ae(o);
1529
+ !u && h.position === "fixed" && (r = null), (a ? !u && !r : !u && h.position === "static" && !!r && qs.has(r.position) || Vt(o) && !u && wi(i, o)) ? s = s.filter((y) => y !== o) : r = h, o = ut(o);
1530
+ }
1531
+ return t.set(i, s), s;
1532
+ }
1533
+ function Js(i) {
1534
+ let {
1535
+ element: t,
1536
+ boundary: e,
1537
+ rootBoundary: s,
1538
+ strategy: r
1539
+ } = i;
1540
+ const o = [...e === "clippingAncestors" ? de(t) ? [] : Xs(t, this._c) : [].concat(e), s], h = o[0], u = o.reduce((d, y) => {
1541
+ const m = Ze(t, y, r);
1542
+ return d.top = bt(m.top, d.top), d.right = se(m.right, d.right), d.bottom = se(m.bottom, d.bottom), d.left = bt(m.left, d.left), d;
1543
+ }, Ze(t, h, r));
1544
+ return {
1545
+ width: u.right - u.left,
1546
+ height: u.bottom - u.top,
1547
+ x: u.left,
1548
+ y: u.top
1549
+ };
1550
+ }
1551
+ function Qs(i) {
1552
+ const {
1553
+ width: t,
1554
+ height: e
1555
+ } = yi(i);
1556
+ return {
1557
+ width: t,
1558
+ height: e
1559
+ };
1560
+ }
1561
+ function tn(i, t, e) {
1562
+ const s = et(t), r = it(t), a = e === "fixed", o = vt(i, !0, a, t);
1563
+ let h = {
1564
+ scrollLeft: 0,
1565
+ scrollTop: 0
1566
+ };
1567
+ const u = tt(0);
1568
+ function d() {
1569
+ u.x = Te(r);
1570
+ }
1571
+ if (s || !s && !a)
1572
+ if ((Ot(t) !== "body" || Vt(r)) && (h = pe(t)), s) {
1573
+ const f = vt(t, !0, a, t);
1574
+ u.x = f.x + t.clientLeft, u.y = f.y + t.clientTop;
1575
+ } else r && d();
1576
+ a && !s && r && d();
1577
+ const y = r && !s && !a ? bi(r, h) : tt(0), m = o.left + h.scrollLeft - u.x - y.x, b = o.top + h.scrollTop - u.y - y.y;
1578
+ return {
1579
+ x: m,
1580
+ y: b,
1581
+ width: o.width,
1582
+ height: o.height
1583
+ };
1584
+ }
1585
+ function ye(i) {
1586
+ return X(i).position === "static";
1587
+ }
1588
+ function Ke(i, t) {
1589
+ if (!et(i) || X(i).position === "fixed")
1590
+ return null;
1591
+ if (t)
1592
+ return t(i);
1593
+ let e = i.offsetParent;
1594
+ return it(i) === e && (e = e.ownerDocument.body), e;
1595
+ }
1596
+ function vi(i, t) {
1597
+ const e = $(i);
1598
+ if (de(i))
1599
+ return e;
1600
+ if (!et(i)) {
1601
+ let r = ut(i);
1602
+ for (; r && !Tt(r); ) {
1603
+ if (Y(r) && !ye(r))
1604
+ return r;
1605
+ r = ut(r);
1606
+ }
1607
+ return e;
1608
+ }
1609
+ let s = Ke(i, t);
1610
+ for (; s && Ps(s) && ye(s); )
1611
+ s = Ke(s, t);
1612
+ return s && Tt(s) && ye(s) && !Ae(s) ? e : s || Bs(i) || e;
1613
+ }
1614
+ const en = async function(i) {
1615
+ const t = this.getOffsetParent || vi, e = this.getDimensions, s = await e(i.floating);
1616
+ return {
1617
+ reference: tn(i.reference, await t(i.floating), i.strategy),
1618
+ floating: {
1619
+ x: 0,
1620
+ y: 0,
1621
+ width: s.width,
1622
+ height: s.height
1623
+ }
1624
+ };
1625
+ };
1626
+ function sn(i) {
1627
+ return X(i).direction === "rtl";
1628
+ }
1629
+ const nn = {
1630
+ convertOffsetParentRelativeRectToViewportRelativeRect: Zs,
1631
+ getDocumentElement: it,
1632
+ getClippingRect: Js,
1633
+ getOffsetParent: vi,
1634
+ getElementRects: en,
1635
+ getClientRects: Ks,
1636
+ getDimensions: Qs,
1637
+ getScale: At,
1638
+ isElement: Y,
1639
+ isRTL: sn
1640
+ };
1641
+ function xi(i, t) {
1642
+ return i.x === t.x && i.y === t.y && i.width === t.width && i.height === t.height;
1643
+ }
1644
+ function rn(i, t) {
1645
+ let e = null, s;
1646
+ const r = it(i);
1647
+ function a() {
1648
+ var h;
1649
+ clearTimeout(s), (h = e) == null || h.disconnect(), e = null;
1650
+ }
1651
+ function o(h, u) {
1652
+ h === void 0 && (h = !1), u === void 0 && (u = 1), a();
1653
+ const d = i.getBoundingClientRect(), {
1654
+ left: y,
1655
+ top: m,
1656
+ width: b,
1657
+ height: f
1658
+ } = d;
1659
+ if (h || t(), !b || !f)
1660
+ return;
1661
+ const v = Xt(m), k = Xt(r.clientWidth - (y + b)), C = Xt(r.clientHeight - (m + f)), x = Xt(y), R = {
1662
+ rootMargin: -v + "px " + -k + "px " + -C + "px " + -x + "px",
1663
+ threshold: bt(0, se(1, u)) || 1
1664
+ };
1665
+ let F = !0;
1666
+ function D(Rt) {
1667
+ const kt = Rt[0].intersectionRatio;
1668
+ if (kt !== u) {
1669
+ if (!F)
1670
+ return o();
1671
+ kt ? o(!1, kt) : s = setTimeout(() => {
1672
+ o(!1, 1e-7);
1673
+ }, 1e3);
1674
+ }
1675
+ kt === 1 && !xi(d, i.getBoundingClientRect()) && o(), F = !1;
1676
+ }
1677
+ try {
1678
+ e = new IntersectionObserver(D, {
1679
+ ...R,
1680
+ // Handle <iframe>s
1681
+ root: r.ownerDocument
1682
+ });
1683
+ } catch {
1684
+ e = new IntersectionObserver(D, R);
1685
+ }
1686
+ e.observe(i);
1687
+ }
1688
+ return o(!0), a;
1689
+ }
1690
+ function on(i, t, e, s) {
1691
+ s === void 0 && (s = {});
1692
+ const {
1693
+ ancestorScroll: r = !0,
1694
+ ancestorResize: a = !0,
1695
+ elementResize: o = typeof ResizeObserver == "function",
1696
+ layoutShift: h = typeof IntersectionObserver == "function",
1697
+ animationFrame: u = !1
1698
+ } = s, d = Me(i), y = r || a ? [...d ? Bt(d) : [], ...Bt(t)] : [];
1699
+ y.forEach((x) => {
1700
+ r && x.addEventListener("scroll", e, {
1701
+ passive: !0
1702
+ }), a && x.addEventListener("resize", e);
1703
+ });
1704
+ const m = d && h ? rn(d, e) : null;
1705
+ let b = -1, f = null;
1706
+ o && (f = new ResizeObserver((x) => {
1707
+ let [A] = x;
1708
+ A && A.target === d && f && (f.unobserve(t), cancelAnimationFrame(b), b = requestAnimationFrame(() => {
1709
+ var R;
1710
+ (R = f) == null || R.observe(t);
1711
+ })), e();
1712
+ }), d && !u && f.observe(d), f.observe(t));
1713
+ let v, k = u ? vt(i) : null;
1714
+ u && C();
1715
+ function C() {
1716
+ const x = vt(i);
1717
+ k && !xi(k, x) && e(), k = x, v = requestAnimationFrame(C);
1718
+ }
1719
+ return e(), () => {
1720
+ var x;
1721
+ y.forEach((A) => {
1722
+ r && A.removeEventListener("scroll", e), a && A.removeEventListener("resize", e);
1723
+ }), m == null || m(), (x = f) == null || x.disconnect(), f = null, u && cancelAnimationFrame(v);
1724
+ };
1725
+ }
1726
+ const an = Rs, ln = zs, cn = Ms, hn = (i, t, e) => {
1727
+ const s = /* @__PURE__ */ new Map(), r = {
1728
+ platform: nn,
1729
+ ...e
1730
+ }, a = {
1731
+ ...r.platform,
1732
+ _c: s
1733
+ };
1734
+ return Ss(i, t, {
1735
+ ...r,
1736
+ platform: a
1737
+ });
1738
+ };
1739
+ var St, jt, Zt, N, Kt, Gt, xt, ki, ke;
1740
+ class un {
1741
+ /**
1742
+ * Creates a new Api instance
1743
+ *
1744
+ * @param {Object} config - API configuration
1745
+ * @param {string} config.apiKey - API key for authentication
1746
+ * @param {string} config.baseUrl - Base URL for API requests
1747
+ */
1748
+ constructor({ apiKey: t, baseUrl: e }) {
1749
+ _(this, xt);
1750
+ _(this, St);
1751
+ _(this, jt);
1752
+ _(this, Zt, te.API_TIMEOUT);
1753
+ _(this, N);
1754
+ _(this, Kt, 0);
1755
+ _(this, Gt, 0);
1756
+ p(this, St, t), p(this, jt, e);
1757
+ }
1758
+ async fetchAddress(t) {
1759
+ return l(this, xt, ke).call(this, "GET", "/addressing/v2/address", {
1760
+ params: { address_id: t }
1761
+ });
1762
+ }
1763
+ async geocode(t, e = {}, s = {}) {
1764
+ const r = {
1765
+ q: t,
1766
+ ...e
1767
+ };
1768
+ return l(this, xt, ke).call(this, "GET", "/addressing/v2/autocomplete", {
1769
+ params: r,
1770
+ ...s
1771
+ });
1772
+ }
1773
+ cancel() {
1774
+ n(this, N) && (n(this, N).abort(), p(this, N, null));
1775
+ }
1776
+ createAbortController() {
1777
+ p(this, N, new AbortController());
1778
+ }
1779
+ getAbortSignal() {
1780
+ return n(this, N) || this.createAbortController(), n(this, N).signal;
1781
+ }
1782
+ }
1783
+ St = new WeakMap(), jt = new WeakMap(), Zt = new WeakMap(), N = new WeakMap(), Kt = new WeakMap(), Gt = new WeakMap(), xt = new WeakSet(), /**
1784
+ * Handles API errors and categorizes them
1785
+ *
1786
+ * @param {Error} e - The error to handle
1787
+ * @throws {Error} A more descriptive error
1788
+ * @private
1789
+ */
1790
+ ki = function(t) {
1791
+ var e;
1792
+ throw t.name === "AbortError" ? (Dt(this, Gt)._++, new Error("Request cancelled")) : (Dt(this, Kt)._++, t.response ? t.response.status === 401 ? new Error("Unauthorized") : new Error(((e = t.response.data) == null ? void 0 : e.message) || "Unknown error") : navigator.onLine ? t : new Error("Network error: No internet connection"));
1793
+ }, ke = async function(t, e, s = {}) {
1794
+ if (!n(this, St))
1795
+ throw new Error("API Key is required");
1796
+ try {
1797
+ n(this, N) && n(this, N).abort(), p(this, N, new AbortController());
1798
+ const r = new URL(e, n(this, jt));
1799
+ s.params && Object.entries(s.params).forEach(([o, h]) => {
1800
+ h != null && r.searchParams.append(o, h);
1801
+ });
1802
+ const a = await fetch(r, {
1803
+ method: t,
1804
+ headers: {
1805
+ accept: "application/json",
1806
+ "x-api-key": n(this, St),
1807
+ ...s.headers
1808
+ },
1809
+ signal: n(this, N).signal,
1810
+ ...n(this, Zt) && {
1811
+ // Simple timeout implementation
1812
+ signal: AbortSignal.timeout ? AbortSignal.timeout(n(this, Zt)) : n(this, N).signal
1813
+ }
1814
+ });
1815
+ if (!a.ok) {
1816
+ const o = new Error(`HTTP ${a.status}`);
1817
+ throw o.response = {
1818
+ status: a.status,
1819
+ data: await a.json().catch(() => ({}))
1820
+ }, o;
1821
+ }
1822
+ return p(this, Kt, 0), p(this, Gt, 0), { data: await a.json() };
1823
+ } catch (r) {
1824
+ return l(this, xt, ki).call(this, r);
1825
+ } finally {
1826
+ p(this, N, null);
1827
+ }
1828
+ };
1829
+ const mt = {
1830
+ MENU: "rs-search-menu",
1831
+ RESULTS: "rs-search-results",
1832
+ LOADING: "rs-search-loading",
1833
+ LOADING_SPINNER: "rs-search-loading__spinner",
1834
+ LOADING_TEXT: "rs-search-loading__text",
1835
+ POWERED_BY: "rs-search-powered-by",
1836
+ CONTAINER: "rs-search-container"
1837
+ }, ot = {
1838
+ ARROW_UP: "ArrowUp",
1839
+ ARROW_DOWN: "ArrowDown",
1840
+ ENTER: "Enter",
1841
+ ESCAPE: "Escape"
1842
+ };
1843
+ var G, O, V, j, P, ct, q, _t, Mt, H, I, c, Li, Ei, Ci, Ai, Si, Mi, Ti, Oi, Ri, zi, Di, Ui, Pi, Ni, at, ft, st, Ii, Fi, Hi, ee, Le, It, Bi, Wi, $i, ji, Zi, Ki, Gi, Vi, qi, Yi, Ee, ie, Ce, Xi, Ft, Ht, Ji;
1844
+ class Ge {
1845
+ /**
1846
+ * Creates a new RiskscapeSearch instance
1847
+ *
1848
+ * @param {Object} config - Configuration options
1849
+ * @param {string} config.element - ID of the input element
1850
+ * @param {string} config.key - API key for Riskscape service
1851
+ * @param {string} [config.url] - Base URL for the API
1852
+ * @param {boolean} [config.showCategory=false] - Whether to show categories
1853
+ * @param {boolean} [config.showPoweredBy=true] - Whether to show "powered by" text
1854
+ * @param {number} [config.maxResults=10] - Maximum results to display
1855
+ * @throws {Error} When required configuration is missing
1856
+ */
1857
+ constructor(t) {
1858
+ _(this, c);
1859
+ // Private fields with better organization
1860
+ S(this, "_api");
1861
+ _(this, G);
1862
+ S(this, "_input");
1863
+ S(this, "_events");
1864
+ // UI Elements
1865
+ S(this, "_dropdown");
1866
+ S(this, "_dropdownContainer");
1867
+ _(this, O);
1868
+ _(this, V);
1869
+ _(this, j);
1870
+ // State management
1871
+ _(this, P, -1);
1872
+ S(this, "_dropdownCleanup", null);
1873
+ _(this, ct, null);
1874
+ _(this, q, null);
1875
+ _(this, _t, "");
1876
+ _(this, Mt, !1);
1877
+ _(this, H, !1);
1878
+ S(this, "_boundToMap", !1);
1879
+ // Configuration
1880
+ S(this, "_filters", {
1881
+ categories: "StreetAddress,Scheme"
1882
+ });
1883
+ _(this, I, []);
1884
+ // Bound event handlers (declared as fields for proper context)
1885
+ S(this, "_handleChange");
1886
+ S(this, "_boundHandleBlur");
1887
+ S(this, "_boundHandleFocus");
1888
+ S(this, "_boundHandleKeydown");
1889
+ S(this, "_boundHandlePaste");
1890
+ S(this, "_boundHandleItemClick");
1891
+ l(this, c, Li).call(this, t), l(this, c, Ei).call(this, t), l(this, c, Ci).call(this, t.element), this._api = new un({
1892
+ apiKey: n(this, G).key,
1893
+ baseUrl: n(this, G).url
1894
+ }), this._events = fs(), l(this, c, Ai).call(this), l(this, c, Si).call(this), l(this, c, Mi).call(this);
1895
+ }
1896
+ // ===== PUBLIC API METHODS =====
1897
+ /**
1898
+ * Registers an event listener
1899
+ * @param {string} event - Event name
1900
+ * @param {Function} callback - Event callback
1901
+ * @returns {RiskscapeSearch} This instance for chaining
1902
+ * @public
1903
+ */
1904
+ on(t, e) {
1905
+ return this._events.on(t, e), this;
1906
+ }
1907
+ /**
1908
+ * Removes an event listener
1909
+ * @param {string} event - Event name
1910
+ * @param {Function} callback - Event callback
1911
+ * @returns {RiskscapeSearch} This instance for chaining
1912
+ * @public
1913
+ */
1914
+ off(t, e) {
1915
+ return this._events.off(t, e), this;
1916
+ }
1917
+ /**
1918
+ * Sets search filters
1919
+ * @param {Object} filters - Search filters
1920
+ * @returns {void}
1921
+ * @public
1922
+ */
1923
+ setFilters(t) {
1924
+ this._filters = t;
1925
+ }
1926
+ /**
1927
+ * Resets the search component to its initial state
1928
+ * @returns {void}
1929
+ * @public
1930
+ */
1931
+ reset() {
1932
+ this._input.value = "", l(this, c, ee).call(this), l(this, c, st).call(this);
1933
+ }
1934
+ /**
1935
+ * Binds the search component to a map
1936
+ * @returns {void}
1937
+ * @public
1938
+ */
1939
+ bindToMap() {
1940
+ this.setFilters({}), this._boundToMap = !0;
1941
+ }
1942
+ /**
1943
+ * Unbinds the search component from a map
1944
+ * @returns {void}
1945
+ * @public
1946
+ */
1947
+ unbindFromMap() {
1948
+ this._boundToMap = !1;
1949
+ }
1950
+ /**
1951
+ * Gets an address by its ID
1952
+ * @param {string} addressId - The address ID
1953
+ * @returns {Promise<Object>} The address data
1954
+ * @public
1955
+ */
1956
+ async getAddress(t) {
1957
+ const { data: e } = await this._api.fetchAddress(t);
1958
+ return e.data;
1959
+ }
1960
+ /**
1961
+ * Fetches the full address details for the currently selected candidate
1962
+ * @returns {Promise<Object|null>} The detailed address data or null if no candidate selected or error
1963
+ * @public
1964
+ */
1965
+ async fetchSelectedAddress() {
1966
+ var t, e, s;
1967
+ if (!n(this, q))
1968
+ return console.warn("No candidate selected"), null;
1969
+ if (!((e = (t = n(this, q)) == null ? void 0 : t.attributes) != null && e.address_id))
1970
+ return console.warn("No address ID available for selected candidate"), null;
1971
+ try {
1972
+ const r = await this._api.fetchAddress(n(this, q).attributes.address_id);
1973
+ return (s = r == null ? void 0 : r.data) != null && s.data ? r.data.data : (console.warn("Invalid response structure from fetchAddress"), null);
1974
+ } catch (r) {
1975
+ return console.error("Error fetching selected address:", r), this._events.emit("error", new Error("Failed to fetch address details")), null;
1976
+ }
1977
+ }
1978
+ /**
1979
+ * Destroys the search component and cleans up resources
1980
+ * @returns {void}
1981
+ * @public
1982
+ */
1983
+ destroy() {
1984
+ var t, e;
1985
+ this._events.all.clear(), this._input.removeEventListener("input", this._handleChange), this._dropdown && (this._input.removeEventListener("blur", this._boundHandleBlur), this._input.removeEventListener("focus", this._boundHandleFocus), this._input.removeEventListener("keydown", this._boundHandleKeydown), this._input.removeEventListener("paste", this._boundHandlePaste), this._dropdown.removeEventListener("click", this._boundHandleItemClick), (t = this._dropdownContainer) == null || t.remove(), (e = this._dropdownCleanup) == null || e.call(this)), this._api = null, this._input = null, this._dropdown = null, this._dropdownContainer = null;
1986
+ }
1987
+ }
1988
+ G = new WeakMap(), O = new WeakMap(), V = new WeakMap(), j = new WeakMap(), P = new WeakMap(), ct = new WeakMap(), q = new WeakMap(), _t = new WeakMap(), Mt = new WeakMap(), H = new WeakMap(), I = new WeakMap(), c = new WeakSet(), /**
1989
+ * Validates the configuration object
1990
+ * @param {Object} config - Configuration to validate
1991
+ * @throws {Error} When configuration is invalid
1992
+ * @private
1993
+ */
1994
+ Li = function(t) {
1995
+ if (!(t != null && t.element))
1996
+ throw new Error(Ne.MISSING_ELEMENT);
1997
+ }, /**
1998
+ * Sets up the options object with defaults
1999
+ * @param {Object} config - User configuration
2000
+ * @private
2001
+ */
2002
+ Ei = function(t) {
2003
+ p(this, G, {
2004
+ url: "https://api.cloud.riskscape.pro",
2005
+ showCategory: !1,
2006
+ showPoweredBy: !0,
2007
+ maxResults: te.DEFAULT_MAX_RESULTS,
2008
+ ...t
2009
+ }), n(this, G).minChars = te.DEFAULT_MIN_CHARS;
2010
+ }, /**
2011
+ * Sets up the input element and its attributes
2012
+ * @param {string|HTMLElement} element - ID of the input element, CSS selector, or HTMLElement
2013
+ * @throws {Error} When element is not found
2014
+ * @private
2015
+ */
2016
+ Ci = function(t) {
2017
+ if (typeof t == "string")
2018
+ t.startsWith("#") || t.startsWith(".") ? this._input = document.querySelector(t) : this._input = document.getElementById(t);
2019
+ else if (t instanceof HTMLElement)
2020
+ this._input = t;
2021
+ else
2022
+ throw new Error("Element must be a string selector, element ID, or HTMLElement");
2023
+ if (!this._input)
2024
+ throw new Error(Ne.ELEMENT_NOT_FOUND(t));
2025
+ Object.assign(this._input, {
2026
+ autocomplete: "off"
2027
+ }), this._input.setAttribute("role", "combobox"), this._input.setAttribute("aria-autocomplete", "list"), this._input.setAttribute("aria-expanded", "false"), this._input.setAttribute("aria-haspopup", "listbox");
2028
+ }, /**
2029
+ * Binds methods to this context for better performance
2030
+ * @private
2031
+ */
2032
+ Ai = function() {
2033
+ this._handleChange = gs(l(this, c, $i).bind(this), te.DEFAULT_DEBOUNCE_TIME), this._boundHandleBlur = l(this, c, ji).bind(this), this._boundHandleFocus = l(this, c, Zi).bind(this), this._boundHandleKeydown = l(this, c, Gi).bind(this), this._boundHandlePaste = l(this, c, Ki).bind(this), this._boundHandleItemClick = l(this, c, Xi).bind(this);
2034
+ }, /**
2035
+ * Sets up the UI components
2036
+ * @private */
2037
+ Si = function() {
2038
+ l(this, c, Ti).call(this);
2039
+ }, /**
2040
+ * Sets up event listeners
2041
+ * @private
2042
+ */
2043
+ Mi = function() {
2044
+ this._input.addEventListener("input", this._handleChange), this._input.addEventListener("blur", this._boundHandleBlur), this._input.addEventListener("focus", this._boundHandleFocus), this._input.addEventListener("keydown", this._boundHandleKeydown), this._input.addEventListener("paste", this._boundHandlePaste);
2045
+ }, /**
2046
+ * Creates the dropdown menu DOM elements
2047
+ * @private
2048
+ */
2049
+ Ti = function() {
2050
+ l(this, c, Oi).call(this), l(this, c, Ri).call(this), l(this, c, zi).call(this), l(this, c, Di).call(this), l(this, c, Ui).call(this), l(this, c, Pi).call(this), l(this, c, Ni).call(this);
2051
+ }, /**
2052
+ * Creates the dropdown container element
2053
+ * @private
2054
+ */
2055
+ Oi = function() {
2056
+ this._dropdownContainer = l(this, c, at).call(this, "div", mt.CONTAINER);
2057
+ }, /**
2058
+ * Creates the main dropdown menu element
2059
+ * @private
2060
+ */
2061
+ Ri = function() {
2062
+ this._dropdown = l(this, c, at).call(this, "nav", mt.MENU, {
2063
+ role: "listbox"
2064
+ }), this._dropdown.addEventListener("click", this._boundHandleItemClick), this._dropdownContainer.appendChild(this._dropdown);
2065
+ }, /**
2066
+ * Creates the results list element
2067
+ * @private
2068
+ */
2069
+ zi = function() {
2070
+ p(this, O, l(this, c, at).call(this, "ul", mt.RESULTS)), this._dropdown.appendChild(n(this, O));
2071
+ }, /**
2072
+ * Creates the "powered by" section if enabled
2073
+ * @private
2074
+ */
2075
+ Di = function() {
2076
+ n(this, G).showPoweredBy && (p(this, j, l(this, c, at).call(this, "div", mt.POWERED_BY, {
2077
+ style: { display: "none" }
2078
+ })), n(this, j).innerHTML = 'powered by <a href="https://riskscape.pro/powered-by" target="_blank">Riskscape</a>', this._dropdownContainer.appendChild(n(this, j)));
2079
+ }, /**
2080
+ * Creates the loading indicator
2081
+ * @private
2082
+ */
2083
+ Ui = function() {
2084
+ p(this, V, l(this, c, at).call(this, "div", mt.LOADING, {
2085
+ "aria-label": "Loading search results",
2086
+ role: "status",
2087
+ style: { display: "none" }
2088
+ }));
2089
+ const t = l(this, c, at).call(this, "div", mt.LOADING_SPINNER), e = l(this, c, at).call(this, "div", mt.LOADING_TEXT);
2090
+ e.textContent = "Searching...", n(this, V).appendChild(t), n(this, V).appendChild(e), this._dropdown.appendChild(n(this, V));
2091
+ }, /**
2092
+ * Attaches the dropdown to the DOM
2093
+ * @private
2094
+ */
2095
+ Pi = function() {
2096
+ document.body.appendChild(this._dropdownContainer);
2097
+ }, /**
2098
+ * Sets up dropdown positioning using Floating UI
2099
+ * @private
2100
+ */
2101
+ Ni = function() {
2102
+ this._dropdownCleanup = on(this._input, this._dropdownContainer, () => {
2103
+ hn(this._input, this._dropdownContainer, {
2104
+ placement: "bottom-start",
2105
+ middleware: [an(5), cn(), ln()]
2106
+ }).then(({ x: t, y: e }) => {
2107
+ Object.assign(this._dropdownContainer.style, {
2108
+ top: `${e}px`,
2109
+ left: `${t}px`
2110
+ });
2111
+ });
2112
+ });
2113
+ }, /**
2114
+ * Utility method to create DOM elements with classes and attributes
2115
+ * @param {string} tagName - The tag name for the element
2116
+ * @param {string} className - CSS class name to add
2117
+ * @param {Object} [attributes] - Additional attributes to set
2118
+ * @returns {HTMLElement} The created element
2119
+ * @private
2120
+ */
2121
+ at = function(t, e, s = {}) {
2122
+ const r = document.createElement(t);
2123
+ return r.className = e, Object.entries(s).forEach(([a, o]) => {
2124
+ a === "style" && typeof o == "object" ? Object.assign(r.style, o) : r.setAttribute(a, o);
2125
+ }), r;
2126
+ }, /**
2127
+ * Shows the dropdown with search results
2128
+ *
2129
+ * @private
2130
+ */
2131
+ ft = function() {
2132
+ this._dropdown && (n(this, q) && p(this, P, n(this, ct)), p(this, H, !0), this._dropdown.style.display = "block", n(this, j) && (n(this, j).style.display = "block"), this._input && this._input.setAttribute("aria-expanded", "true"));
2133
+ }, /**
2134
+ * Hides the dropdown
2135
+ *
2136
+ * @private
2137
+ */
2138
+ st = function() {
2139
+ if (!this._dropdown) {
2140
+ p(this, H, !1);
2141
+ return;
2142
+ }
2143
+ setTimeout(() => {
2144
+ p(this, P, -1), p(this, H, !1), this._dropdown && (this._dropdown.style.display = "none"), n(this, j) && (n(this, j).style.display = "none"), this._input && this._input.setAttribute("aria-expanded", "false");
2145
+ }, 200);
2146
+ }, /**
2147
+ * Populates the dropdown with search results
2148
+ *
2149
+ * @private
2150
+ */
2151
+ Ii = function() {
2152
+ p(this, P, -1), l(this, c, Le).call(this), l(this, c, It).call(this), n(this, O).innerHTML = "", this._dropdown.setAttribute("aria-expanded", "true"), this._input.setAttribute("aria-controls", "rs-search-results-list"), n(this, O).id = "rs-search-results-list";
2153
+ const t = document.createDocumentFragment();
2154
+ if (n(this, I).forEach((e, s) => {
2155
+ const r = l(this, c, Fi).call(this, e, s);
2156
+ t.appendChild(r);
2157
+ }), !n(this, I).length) {
2158
+ const e = document.createElement("li");
2159
+ e.classList.add("rs-search-results__message"), e.innerHTML = "<div>Search returned no results.</div>", t.appendChild(e);
2160
+ }
2161
+ n(this, O).appendChild(t), l(this, c, ft).call(this);
2162
+ }, /**
2163
+ * Creates a single result item element
2164
+ * @param {Object} result - The result data
2165
+ * @param {number} index - The result index
2166
+ * @returns {HTMLElement} The created list item
2167
+ * @private
2168
+ */
2169
+ Fi = function(t, e) {
2170
+ const s = document.createElement("li");
2171
+ s.dataset.index = e.toString(), s.classList.add("rs-search-results__item"), s.setAttribute("role", "option"), s.setAttribute("aria-selected", "false"), s.setAttribute("id", `rs-search-result-${e}`);
2172
+ const r = t.candidate.split(", "), a = `<span>${r.shift()}</span>, ${r.join(", ")}`;
2173
+ let o = "";
2174
+ return n(this, G).showCategory && (o += l(this, c, Hi).call(this, t)), o && (o = `<div class="rs-search-results__meta">${o}</div>`), s.innerHTML = `
2175
+ <div class="rs-search-results__content">
2176
+ <div class="rs-search-results__candidate">${a}</div>
2177
+ ${o}
2178
+ </div>
2179
+ `, s;
2180
+ }, /**
2181
+ * Builds category HTML for a result
2182
+ * @param {Object} result - The result data
2183
+ * @returns {string} Category HTML string
2184
+ * @private
2185
+ */
2186
+ Hi = function(t) {
2187
+ const e = [Ie(t.category), Ie(t.subcategory)];
2188
+ e[1] === "Sub Place" && (e[1] = "SubPlace");
2189
+ let s = e[1];
2190
+ return Fe(e[1], "Street Number") ? s = "Street Number" : Fe(e[1], "Stand Number") ? s = "Stand Number" : ["Residential", "Commercial"].includes(e[1]) ? s = e[1] + " Scheme" : e[1] === "Scheme Unit" && (s = "Sectional Scheme Unit"), `<div class="rs-search-results__category">${s}</div>`;
2191
+ }, /**
2192
+ * Clears the search results
2193
+ * @private
2194
+ */
2195
+ ee = function() {
2196
+ p(this, I, []), p(this, _t, ""), p(this, P, -1), l(this, c, Le).call(this);
2197
+ }, /**
2198
+ * Clears the currently selected item
2199
+ * @private
2200
+ */
2201
+ Le = function() {
2202
+ p(this, ct, null), p(this, q, null);
2203
+ }, /**
2204
+ * Toggles the highlighted class on dropdown items
2205
+ * @private
2206
+ */
2207
+ It = function() {
2208
+ n(this, O).querySelectorAll("li").forEach((t, e) => {
2209
+ t.classList.toggle("rs-search-results__item--hover", e === n(this, P));
2210
+ });
2211
+ }, /**
2212
+ * Toggles the selected class on dropdown items
2213
+ * @private
2214
+ * @param {number} selectedIndex - Index of the selected item
2215
+ */
2216
+ Bi = function(t) {
2217
+ n(this, O).querySelectorAll("li").forEach((e, s) => {
2218
+ e.classList.toggle("rs-search-results__item--selected", s === t);
2219
+ });
2220
+ }, /**
2221
+ * Sanitizes and normalizes input query
2222
+ * @param {string} input - Raw input string
2223
+ * @returns {string} Sanitized query
2224
+ * @private
2225
+ */
2226
+ Wi = function(t) {
2227
+ return typeof t != "string" ? "" : t.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/<[^>]*>/g, "").replace(/[^\w\s,.-]/g, "").trim().slice(0, 100);
2228
+ }, $i = async function(t) {
2229
+ const e = l(this, c, Wi).call(this, t.target.value);
2230
+ if (e.length < n(this, G).minChars) {
2231
+ n(this, H) && (l(this, c, ee).call(this), l(this, c, st).call(this));
2232
+ return;
2233
+ }
2234
+ if (e !== n(this, _t)) {
2235
+ p(this, _t, e), this._api.cancel(), this._api.createAbortController(), l(this, c, Ft).call(this, !0), !n(this, H) && this._dropdown && l(this, c, ft).call(this), this._events.emit("geocode:before", { query: e });
2236
+ try {
2237
+ const { data: s } = await this._api.geocode(e, this._filters);
2238
+ p(this, I, s.data.slice(0, n(this, G).maxResults)), n(this, I).length === 0 ? l(this, c, Ht).call(this, "No results found. Try a different search term.") : l(this, c, Ii).call(this), this._events.emit("geocode:after", n(this, I));
2239
+ } catch (s) {
2240
+ this._events.emit("error", s), s.message === "Network error: No response received" ? l(this, c, Ht).call(this, "Network error. Please check your connection and try again.") : s.message === "Unauthorized" ? l(this, c, Ht).call(this, "Authentication error. Please check your API key.") : s.message === "Request cancelled" || (l(this, c, Ht).call(this, "An error occurred while searching. Please try again."), console.error("Error fetching geocode results:", s));
2241
+ } finally {
2242
+ l(this, c, Ft).call(this, !1);
2243
+ }
2244
+ }
2245
+ }, /**
2246
+ * Handles blur event on input element
2247
+ * @private
2248
+ */
2249
+ ji = function() {
2250
+ n(this, H) && l(this, c, st).call(this);
2251
+ }, /**
2252
+ * Handles focus event on input element
2253
+ * @private
2254
+ */
2255
+ Zi = function() {
2256
+ n(this, I).length && (this._boundToMap && (this._input.value = n(this, _t)), l(this, c, ft).call(this));
2257
+ }, /**
2258
+ * Handles paste event on input element
2259
+ * @param {Event} e - Paste event
2260
+ * @private
2261
+ */
2262
+ Ki = function(t) {
2263
+ if (this._boundToMap)
2264
+ return;
2265
+ const e = t.clipboardData.getData("text/plain");
2266
+ if (l(this, c, ee).call(this), ms(e)) {
2267
+ t.preventDefault();
2268
+ const [s, r] = e.split(",").map((a) => parseFloat(a).toFixed(6));
2269
+ this._events.emit("paste", {
2270
+ type: "latlon",
2271
+ data: { lat: s, lon: r }
2272
+ }), this._input.value = `${s}, ${r}`, this._input.blur(), l(this, c, st).call(this);
2273
+ } else ps(e) && (t.preventDefault(), this._events.emit("paste", {
2274
+ type: "property_key",
2275
+ data: e
2276
+ }), this._input.value = e, this._input.blur(), l(this, c, st).call(this));
2277
+ }, /**
2278
+ * Handles keydown event on input element
2279
+ * @param {KeyboardEvent} event - Keydown event
2280
+ * @private
2281
+ */
2282
+ Gi = function(t) {
2283
+ var a;
2284
+ const { key: e } = t;
2285
+ if (![ot.ARROW_UP, ot.ARROW_DOWN, ot.ENTER, ot.ESCAPE].includes(e))
2286
+ return;
2287
+ t.preventDefault();
2288
+ const r = {
2289
+ [ot.ARROW_DOWN]: () => l(this, c, Vi).call(this),
2290
+ [ot.ARROW_UP]: () => l(this, c, qi).call(this),
2291
+ [ot.ENTER]: () => l(this, c, Yi).call(this),
2292
+ [ot.ESCAPE]: () => l(this, c, st).call(this)
2293
+ };
2294
+ (a = r[e]) == null || a.call(r);
2295
+ }, /**
2296
+ * Handles arrow down key press
2297
+ * @private
2298
+ */
2299
+ Vi = function() {
2300
+ if (!n(this, H) && n(this, I).length) {
2301
+ l(this, c, ft).call(this);
2302
+ return;
2303
+ }
2304
+ n(this, P) < n(this, I).length - 1 && (Dt(this, P)._++, l(this, c, Ee).call(this), l(this, c, It).call(this));
2305
+ }, /**
2306
+ * Handles arrow up key press
2307
+ * @private
2308
+ */
2309
+ qi = function() {
2310
+ n(this, H) && n(this, P) > 0 && (Dt(this, P)._--, l(this, c, Ee).call(this), l(this, c, It).call(this));
2311
+ }, /**
2312
+ * Handles enter key press
2313
+ * @private
2314
+ */
2315
+ Yi = function() {
2316
+ if (!n(this, H) && n(this, I).length) {
2317
+ l(this, c, ft).call(this);
2318
+ return;
2319
+ }
2320
+ if (n(this, P) >= 0) {
2321
+ l(this, c, ie).call(this);
2322
+ const t = n(this, O).querySelector(`li[data-index="${n(this, P)}"]`);
2323
+ t == null || t.click();
2324
+ }
2325
+ }, /**
2326
+ * Scrolls the highlighted item into view
2327
+ * @private
2328
+ */
2329
+ Ee = function() {
2330
+ const t = n(this, O).querySelector(`li[data-index="${n(this, P)}"]`);
2331
+ t == null || t.scrollIntoView({
2332
+ block: "nearest",
2333
+ behavior: "smooth"
2334
+ });
2335
+ }, /**
2336
+ * Disables the input field
2337
+ * @private
2338
+ */
2339
+ ie = function() {
2340
+ this._input && (this._input.disabled = !0, this._input.setAttribute("aria-disabled", "true"));
2341
+ }, /**
2342
+ * Enables the input field
2343
+ * @private
2344
+ */
2345
+ Ce = function() {
2346
+ this._input && (this._input.disabled = !1, this._input.setAttribute("aria-disabled", "false"));
2347
+ }, Xi = async function(t) {
2348
+ if (n(this, Mt))
2349
+ return;
2350
+ const e = t.target.closest("li");
2351
+ if (!e)
2352
+ return;
2353
+ p(this, P, -1), l(this, c, It).call(this), p(this, ct, parseInt(e.dataset.index)), l(this, c, Bi).call(this, n(this, ct)), l(this, c, st).call(this);
2354
+ const s = n(this, I)[n(this, ct)];
2355
+ if (p(this, q, s), this._boundToMap) {
2356
+ l(this, c, ie).call(this), this._events.emit("select", { candidate: s }), this._input.value = s.candidate, setTimeout(() => {
2357
+ l(this, c, Ce).call(this);
2358
+ }, 300);
2359
+ return;
2360
+ }
2361
+ l(this, c, ie).call(this);
2362
+ try {
2363
+ const r = await l(this, c, Ji).call(this);
2364
+ this._events.emit("select", { candidate: s, address: r }), this._input.value = (r == null ? void 0 : r.full_address) || s.candidate;
2365
+ } catch (r) {
2366
+ console.error("Error in handleItemClick:", r), this._events.emit("error", new Error("Failed to process selection"));
2367
+ } finally {
2368
+ l(this, c, Ce).call(this), this._input.blur();
2369
+ }
2370
+ }, /**
2371
+ * Sets the loading state and controls the loading indicator visibility
2372
+ *
2373
+ * @param {boolean} isLoading - Whether the component is in loading state
2374
+ * @private
2375
+ */
2376
+ Ft = function(t) {
2377
+ if (p(this, Mt, t), !!n(this, V)) {
2378
+ if (t) {
2379
+ if (n(this, V).style.display = "flex", !n(this, H) && n(this, O)) {
2380
+ if (n(this, O).innerHTML = "", n(this, O)) {
2381
+ const e = document.createElement("li");
2382
+ e.classList.add("rs-search-results__message"), e.classList.add("rs-search-results__loading-placeholder"), n(this, O).appendChild(e);
2383
+ }
2384
+ this._dropdown && (this._dropdown.style.display = "block", this._dropdown.style.overflowY = "hidden"), n(this, j) && (n(this, j).style.display = "block"), p(this, H, !0), this._input.setAttribute("aria-expanded", "true");
2385
+ }
2386
+ } else if (n(this, V) && (n(this, V).style.display = "none"), n(this, O)) {
2387
+ const e = n(this, O).querySelector(".rs-search-results__loading-placeholder");
2388
+ e && e.remove(), this._dropdown && (this._dropdown.style.overflowY = "auto"), n(this, I).length === 0 && n(this, O).querySelector(".rs-search-results__error") === null && l(this, c, st).call(this);
2389
+ }
2390
+ this._events.emit("loading", n(this, Mt));
2391
+ }
2392
+ }, /**
2393
+ * Displays an error message in the dropdown
2394
+ * @param {string} message - The error message to display
2395
+ * @private
2396
+ */
2397
+ Ht = function(t) {
2398
+ n(this, O).innerHTML = "";
2399
+ const e = document.createElement("li");
2400
+ e.classList.add("rs-search-results__message", "rs-search-results__error"), e.innerHTML = `<div>${t}</div>`, n(this, O).appendChild(e), l(this, c, ft).call(this);
2401
+ }, Ji = async function() {
2402
+ var t, e, s;
2403
+ if (!((e = (t = n(this, q)) == null ? void 0 : t.attributes) != null && e.address_id))
2404
+ return console.warn("No address ID available for selected candidate"), null;
2405
+ l(this, c, Ft).call(this, !0);
2406
+ try {
2407
+ const r = await this._api.fetchAddress(n(this, q).attributes.address_id);
2408
+ return (s = r == null ? void 0 : r.data) != null && s.data ? r.data.data : (console.warn("Invalid response structure from fetchAddress"), null);
2409
+ } catch (r) {
2410
+ return console.error("Error fetching candidate address:", r), this._events.emit("error", new Error("Failed to fetch address details")), null;
2411
+ } finally {
2412
+ l(this, c, Ft).call(this, !1);
2413
+ }
2414
+ };
2415
+ typeof window < "u" && (window.RiskscapePlugins = { RiskscapeMap: Pe, RiskscapeSearch: Ge }, window.RiskscapeSearch = Ge, window.RiskscapeMap = Pe);
2416
+ export {
2417
+ Pe as RiskscapeMap,
2418
+ Ge as RiskscapeSearch
2419
+ };