places-autocomplete-js 1.0.9 → 1.0.11

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.
package/README.md CHANGED
@@ -154,7 +154,7 @@ const autocomplete = new PlacesAutocomplete({
154
154
  });
155
155
  ```
156
156
 
157
- ### Fetch Fields (`fetchFields`)
157
+ ### Working with Fetch Fields (`fetchFields`)
158
158
  The `fetchFields` option allows you to specify which fields of place data you want to retrieve when a user selects a suggestion. This can help reduce API costs by only fetching the necessary information. See the [Place Class Data Fields](https://developers.google.com/maps/documentation/javascript/place-class-data-fields) for all available fields.
159
159
  By default, the library fetches `['formattedAddress', 'addressComponents']`, but you can customize this based on your needs.
160
160
 
@@ -260,7 +260,7 @@ Instances of `PlacesAutocomplete` have the following public methods:
260
260
  autocomplete.destroy();
261
261
  ```
262
262
 
263
- * **`setFetchFields(fields)`**: Dynamically updates the array of Place Data Fields to request when a place is selected. This allows you to change which details (e.g., `displayName`, `types`, `photos`) are retrieved after the instance has been initialised. Refer to the "Fetch Fields (`fetchFields`)" section and [Place Class Data Fields](https://developers.google.com/maps/documentation/javascript/place-class-data-fields) for available fields.
263
+ * **`setFetchFields(fields)`**: Dynamically updates the array of Place Data Fields. The provided `fields` array will be combined with the library's default fields (`formattedAddress`, `addressComponents`), ensuring uniqueness, to form the new set of fields to request. Refer to the "Fetch Fields (`fetchFields`)" section and [Place Class Data Fields](https://developers.google.com/maps/documentation/javascript/place-class-data-fields) for available fields.
264
264
  * `fields` (Array<string>): An array of field names to fetch. These will be merged with the default fields (`formattedAddress`, `addressComponents`) and any existing fetch fields, ensuring uniqueness.
265
265
  ```javascript
266
266
  // Example: Update to fetch displayName and geometry in addition to defaults
@@ -16,7 +16,7 @@ var e = (c, t, i) => (V(c, t, "read from private field"), i ? i.call(c) : t.get(
16
16
  * @license MIT
17
17
  *
18
18
  */
19
- var J, N, x, D, R, s, E, a, u, o, f, b, _, g, p, z, k, G, I, O, j, K;
19
+ var J, M, A, D, R, s, C, a, u, o, y, v, x, k, p, z, L, G, I, O, j, K;
20
20
  class W {
21
21
  // Fields to fetch for the selected place (can be extended).
22
22
  /**
@@ -32,24 +32,24 @@ class W {
32
32
  */
33
33
  constructor(t) {
34
34
  // --- Private Properties (using # or _ prefix by convention) ---
35
- h(this, N);
35
+ h(this, M);
36
36
  // Container ID where the autocomplete widget will be rendered.
37
- h(this, x);
37
+ h(this, A);
38
38
  h(this, D);
39
39
  h(this, R);
40
40
  h(this, s);
41
- h(this, E);
41
+ h(this, C);
42
42
  h(this, a);
43
43
  h(this, u);
44
44
  h(this, o);
45
- h(this, f);
46
- h(this, b);
47
- h(this, _);
48
- h(this, g, []);
45
+ h(this, y);
46
+ h(this, v);
47
+ h(this, x);
48
+ h(this, k, []);
49
49
  h(this, p, -1);
50
50
  h(this, z);
51
51
  // For user-provided data callback
52
- h(this, k);
52
+ h(this, L);
53
53
  // For user-provided error callback
54
54
  h(this, G, {
55
55
  // Default options for the autocomplete widget.
@@ -124,7 +124,7 @@ class W {
124
124
  language: "en-gb",
125
125
  region: "GB"
126
126
  });
127
- h(this, j, []);
127
+ h(this, j, ["formattedAddress", "addressComponents"]);
128
128
  h(this, K, ["formattedAddress", "addressComponents"]);
129
129
  /**
130
130
  * Debounced function to fetch autocomplete suggestions from the Google Places API.
@@ -135,26 +135,26 @@ class W {
135
135
  this._reset(), e(this, a) && e(this, a).setAttribute("aria-expanded", "false");
136
136
  return;
137
137
  }
138
- e(this, E).input = e(this, a).value;
138
+ e(this, C).input = e(this, a).value;
139
139
  try {
140
140
  const { suggestions: t } = (
141
141
  // eslint-disable-next-line no-undef
142
142
  await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(
143
- e(this, E)
143
+ e(this, C)
144
144
  )
145
145
  );
146
146
  t && t.length > 0 ? (e(this, o).replaceChildren(
147
147
  ...this._createSuggestionElements(t)
148
148
  ), e(this, o).style.display = "block", e(this, a).setAttribute("aria-expanded", "true")) : (this._reset(), e(this, a).setAttribute("aria-expanded", "false"));
149
149
  } catch (t) {
150
- e(this, k).call(this, t), this._reset();
150
+ e(this, L).call(this, t), this._reset();
151
151
  }
152
152
  }, ((J = e(this, s)) == null ? void 0 : J.debounce) ?? 100));
153
153
  if (!t || !t.containerId || !t.googleMapsApiKey)
154
154
  throw new Error(
155
155
  "PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey)."
156
156
  );
157
- if (l(this, N, t.containerId), l(this, x, document.getElementById(t.containerId)), !e(this, x))
157
+ if (l(this, M, t.containerId), l(this, A, document.getElementById(t.containerId)), !e(this, A))
158
158
  throw new Error(
159
159
  `PacAutocomplete: Container element with ID "${t.containerId}" not found.`
160
160
  );
@@ -168,12 +168,12 @@ class W {
168
168
  ...t.options.classes
169
169
  } : e(this, s).classes = e(this, I), t.fetchFields && Array.isArray(t.fetchFields) && this._setFetchFields(t.fetchFields), l(this, z, t.onResponse || ((i) => {
170
170
  console.info("---------Default onResponse not provided---------"), console.info("Selected Place:", JSON.stringify(i, null, 2));
171
- })), l(this, k, t.onError || ((i) => {
171
+ })), l(this, L, t.onError || ((i) => {
172
172
  console.error("---------Default onError not provided---------"), console.error("PAC Error:", i);
173
- })), t.requestParams && Object.keys(t.requestParams).length > 0 ? l(this, E, {
173
+ })), t.requestParams && Object.keys(t.requestParams).length > 0 ? l(this, C, {
174
174
  ...e(this, O),
175
175
  ...t.requestParams
176
- }) : l(this, E, { ...e(this, O) }), this._init();
176
+ }) : l(this, C, { ...e(this, O) }), this._init();
177
177
  }
178
178
  // --- Private Initialization Method ---
179
179
  async _init() {
@@ -183,7 +183,7 @@ class W {
183
183
  v: e(this, R)
184
184
  }), this._createPACStructure(), await this._initializeAutocomplete();
185
185
  } catch (t) {
186
- e(this, k).call(this, t);
186
+ e(this, L).call(this, t);
187
187
  }
188
188
  }
189
189
  /**
@@ -206,10 +206,10 @@ class W {
206
206
  _debounce(t, i) {
207
207
  let n = null;
208
208
  return function(...d) {
209
- const y = () => {
209
+ const m = () => {
210
210
  n = null, t(...d);
211
211
  };
212
- n !== null && clearTimeout(n), n = setTimeout(y, i ?? 100);
212
+ n !== null && clearTimeout(n), n = setTimeout(m, i ?? 100);
213
213
  };
214
214
  }
215
215
  /**
@@ -231,39 +231,39 @@ class W {
231
231
  * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).
232
232
  */
233
233
  async _loadGoogleMapsApi(t) {
234
- var i, n, r, d = "The Google Maps JavaScript API", y = "google", F = "importLibrary", L = "__ib__", M = document, w = window;
235
- w = w[y] || (w[y] = {});
236
- var A = w.maps || (w.maps = {}), S = /* @__PURE__ */ new Set(), T = new URLSearchParams(), q = () => (
234
+ var i, n, r, d = "The Google Maps JavaScript API", m = "google", S = "importLibrary", E = "__ib__", _ = document, f = window;
235
+ f = f[m] || (f[m] = {});
236
+ var b = f.maps || (f.maps = {}), N = /* @__PURE__ */ new Set(), T = new URLSearchParams(), q = () => (
237
237
  // Function to initiate API loading (if not already started)
238
238
  i || // eslint-disable-next-line no-async-promise-executor
239
- (i = new Promise(async (C, m) => {
240
- var P;
241
- n = M.createElement("script"), T.set("libraries", [...S].join(","));
239
+ (i = new Promise(async (P, g) => {
240
+ var F;
241
+ n = _.createElement("script"), T.set("libraries", [...N].join(","));
242
242
  for (r in t)
243
243
  T.set(
244
- r.replace(/[A-Z]/g, (v) => "_" + v[0].toLowerCase()),
244
+ r.replace(/[A-Z]/g, (w) => "_" + w[0].toLowerCase()),
245
245
  // Convert camelCase to snake_case
246
246
  t[r]
247
247
  );
248
- T.set("callback", y + ".maps." + L), n.src = `https://maps.${y}apis.com/maps/api/js?` + T, A[L] = C, n.onerror = () => i = m(Error(d + " could not load.")), n.nonce = ((P = M.querySelector("script[nonce]")) == null ? void 0 : P.nonce) || "", M.head.append(n);
248
+ T.set("callback", m + ".maps." + E), n.src = `https://maps.${m}apis.com/maps/api/js?` + T, b[E] = P, n.onerror = () => i = g(Error(d + " could not load.")), n.nonce = ((F = _.querySelector("script[nonce]")) == null ? void 0 : F.nonce) || "", _.head.append(n);
249
249
  }))
250
250
  );
251
- A[F] ? console.warn(d + " only loads once. Ignoring:", t) : A[F] = (C, ...m) => S.add(C) && q().then(() => A[F](C, ...m));
251
+ b[S] ? console.warn(d + " only loads once. Ignoring:", t) : b[S] = (P, ...g) => N.add(P) && q().then(() => b[S](P, ...g));
252
252
  }
253
253
  // --- UI Creation ---
254
254
  _createPACStructure() {
255
255
  const t = document.createElement("section");
256
- e(this, s).classes.section.split(" ").forEach((d) => d && t.classList.add(d)), l(this, u, document.createElement("div")), e(this, u).className = e(this, s).classes.container, e(this, u).setAttribute("id", e(this, N) + "-div"), t.appendChild(e(this, u));
256
+ e(this, s).classes.section.split(" ").forEach((d) => d && t.classList.add(d)), l(this, u, document.createElement("div")), e(this, u).className = e(this, s).classes.container, e(this, u).setAttribute("id", e(this, M) + "-div"), t.appendChild(e(this, u));
257
257
  const i = document.createElement("div");
258
258
  i.className = e(this, s).classes.icon_container, e(this, u).appendChild(i);
259
259
  const n = document.createElement("div");
260
- if (n.innerHTML = e(this, s).classes.icon, i.appendChild(n.firstElementChild), l(this, a, document.createElement("input")), e(this, a).id = e(this, N) + "-input", e(this, a).type = "text", e(this, a).name = "search", e(this, a).placeholder = e(this, s).placeholder, e(this, a).autocomplete = e(this, s).autocomplete, e(this, a).className = e(this, s).classes.input, e(this, a).setAttribute("role", "combobox"), e(this, a).setAttribute("aria-autocomplete", "list"), e(this, a).setAttribute("aria-expanded", "false"), e(this, a).setAttribute("aria-controls", "pacSuggestions"), e(this, s).autofocus && (e(this, a).autofocus = !0), e(this, s).label) {
260
+ if (n.innerHTML = e(this, s).classes.icon, i.appendChild(n.firstElementChild), l(this, a, document.createElement("input")), e(this, a).id = e(this, M) + "-input", e(this, a).type = "text", e(this, a).name = "search", e(this, a).placeholder = e(this, s).placeholder, e(this, a).autocomplete = e(this, s).autocomplete, e(this, a).className = e(this, s).classes.input, e(this, a).setAttribute("role", "combobox"), e(this, a).setAttribute("aria-autocomplete", "list"), e(this, a).setAttribute("aria-expanded", "false"), e(this, a).setAttribute("aria-controls", "pacSuggestions"), e(this, s).autofocus && (e(this, a).autofocus = !0), e(this, s).label) {
261
261
  const d = document.createElement("label");
262
- d.htmlFor = e(this, N) + "-labelInput", d.textContent = e(this, s).label, e(this, u).appendChild(d);
262
+ d.htmlFor = e(this, M) + "-labelInput", d.textContent = e(this, s).label, e(this, u).appendChild(d);
263
263
  }
264
264
  e(this, u).appendChild(e(this, a));
265
265
  const r = document.createElement("div");
266
- r.className = e(this, s).classes.kbd_container, l(this, f, document.createElement("kbd")), e(this, f).className = e(this, s).classes.kbd_escape, e(this, f).textContent = "Esc", r.appendChild(e(this, f)), l(this, b, document.createElement("kbd")), e(this, b).className = e(this, s).classes.kbd_up, e(this, b).innerHTML = "&#8593;", r.appendChild(e(this, b)), l(this, _, document.createElement("kbd")), e(this, _).className = e(this, s).classes.kbd_down, e(this, _).innerHTML = "&#8595;", r.appendChild(e(this, _)), e(this, u).appendChild(r), l(this, o, document.createElement("ul")), e(this, o).id = "pacSuggestions", e(this, o).className = e(this, s).classes.ul, e(this, o).style.display = "none", e(this, o).setAttribute("role", "listbox"), e(this, u).appendChild(e(this, o)), e(this, x).appendChild(t), t.addEventListener("keydown", this._onKeyDown.bind(this));
266
+ r.className = e(this, s).classes.kbd_container, l(this, y, document.createElement("kbd")), e(this, y).className = e(this, s).classes.kbd_escape, e(this, y).textContent = "Esc", r.appendChild(e(this, y)), l(this, v, document.createElement("kbd")), e(this, v).className = e(this, s).classes.kbd_up, e(this, v).innerHTML = "&#8593;", r.appendChild(e(this, v)), l(this, x, document.createElement("kbd")), e(this, x).className = e(this, s).classes.kbd_down, e(this, x).innerHTML = "&#8595;", r.appendChild(e(this, x)), e(this, u).appendChild(r), l(this, o, document.createElement("ul")), e(this, o).id = "pacSuggestions", e(this, o).className = e(this, s).classes.ul, e(this, o).style.display = "none", e(this, o).setAttribute("role", "listbox"), e(this, u).appendChild(e(this, o)), e(this, A).appendChild(t), t.addEventListener("keydown", this._onKeyDown.bind(this));
267
267
  }
268
268
  /**
269
269
  * Initializes the core autocomplete functionality after the API is loaded.
@@ -279,10 +279,10 @@ class W {
279
279
  e(this, o) && !e(this, o).contains(document.activeElement) && (e(this, o).style.display = "none", e(this, a).setAttribute("aria-expanded", "false"));
280
280
  }, 200);
281
281
  }), e(this, a).addEventListener("focus", () => {
282
- e(this, a).value && e(this, g).length > 0 && (e(this, o).style.display = "block", e(this, a).setAttribute("aria-expanded", "true"));
283
- })) : e(this, k).call(this, new Error("Input element not found during initialization."));
282
+ e(this, a).value && e(this, k).length > 0 && (e(this, o).style.display = "block", e(this, a).setAttribute("aria-expanded", "true"));
283
+ })) : e(this, L).call(this, new Error("Input element not found during initialization."));
284
284
  } catch (t) {
285
- console.error("Error initializing Google Places Autocomplete:", t), e(this, k).call(this, new Error("Google Maps Places library not available."));
285
+ console.error("Error initializing Google Places Autocomplete:", t), e(this, L).call(this, new Error("Google Maps Places library not available."));
286
286
  }
287
287
  }
288
288
  /**
@@ -290,7 +290,7 @@ class W {
290
290
  * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.
291
291
  */
292
292
  _reset(t = !1, i = null) {
293
- l(this, p, -1), e(this, a) && e(this, s).clear_input == !1 && i && i.formattedAddress ? e(this, a).value = i.formattedAddress : e(this, a) && (e(this, a).value = ""), e(this, a) && (e(this, a).setAttribute("aria-expanded", "false"), e(this, a).blur()), l(this, g, []), l(this, p, -1), e(this, o) && (e(this, o).innerHTML = "", e(this, o).style.display = "none"), t && this._refreshToken();
293
+ l(this, p, -1), e(this, a) && e(this, s).clear_input == !1 && i && i.formattedAddress ? e(this, a).value = i.formattedAddress : e(this, a) && (e(this, a).value = ""), e(this, a) && (e(this, a).setAttribute("aria-expanded", "false"), e(this, a).blur()), l(this, k, []), l(this, p, -1), e(this, o) && (e(this, o).innerHTML = "", e(this, o).style.display = "none"), t && this._refreshToken();
294
294
  }
295
295
  /**
296
296
  * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).
@@ -310,18 +310,18 @@ class W {
310
310
  _onKeyDown(t) {
311
311
  if (this._resetLiClasses(), t.key === "Escape" && (t.preventDefault(), e(this, s).classes.kbd_active.split(" ").forEach((i) => {
312
312
  var n;
313
- return (n = e(this, f)) == null ? void 0 : n.classList.add(i);
313
+ return (n = e(this, y)) == null ? void 0 : n.classList.add(i);
314
314
  }), setTimeout(
315
315
  () => e(this, s).classes.kbd_active.split(" ").forEach((i) => {
316
316
  var n;
317
- return (n = e(this, f)) == null ? void 0 : n.classList.remove(i);
317
+ return (n = e(this, y)) == null ? void 0 : n.classList.remove(i);
318
318
  }),
319
319
  300
320
- ), this._reset(!0)), !(!e(this, g).length || !e(this, o) || e(this, o).style.display === "none"))
320
+ ), this._reset(!0)), !(!e(this, k).length || !e(this, o) || e(this, o).style.display === "none"))
321
321
  if (t.key === "ArrowDown") {
322
322
  t.preventDefault(), l(this, p, Math.min(
323
323
  e(this, p) + 1,
324
- e(this, g).length - 1
324
+ e(this, k).length - 1
325
325
  )), e(this, p) < 0 && l(this, p, 0);
326
326
  const i = e(this, o).children.item(e(this, p));
327
327
  if (i) {
@@ -330,11 +330,11 @@ class W {
330
330
  }
331
331
  e(this, s).classes.kbd_active.split(" ").forEach((n) => {
332
332
  var r;
333
- return (r = e(this, _)) == null ? void 0 : r.classList.add(n);
333
+ return (r = e(this, x)) == null ? void 0 : r.classList.add(n);
334
334
  }), setTimeout(
335
335
  () => e(this, s).classes.kbd_active.split(" ").forEach((n) => {
336
336
  var r;
337
- return (r = e(this, _)) == null ? void 0 : r.classList.remove(n);
337
+ return (r = e(this, x)) == null ? void 0 : r.classList.remove(n);
338
338
  }),
339
339
  300
340
340
  );
@@ -347,16 +347,16 @@ class W {
347
347
  }
348
348
  e(this, s).classes.kbd_active.split(" ").forEach((n) => {
349
349
  var r;
350
- return (r = e(this, b)) == null ? void 0 : r.classList.add(n);
350
+ return (r = e(this, v)) == null ? void 0 : r.classList.add(n);
351
351
  }), setTimeout(
352
352
  () => e(this, s).classes.kbd_active.split(" ").forEach((n) => {
353
353
  var r;
354
- return (r = e(this, b)) == null ? void 0 : r.classList.remove(n);
354
+ return (r = e(this, v)) == null ? void 0 : r.classList.remove(n);
355
355
  }),
356
356
  300
357
357
  );
358
- } else t.key === "Enter" && (t.preventDefault(), e(this, p) >= 0 && e(this, p) < e(this, g).length && this._onPlaceSelected(
359
- e(this, g)[e(this, p)].place
358
+ } else t.key === "Enter" && (t.preventDefault(), e(this, p) >= 0 && e(this, p) < e(this, k).length && this._onPlaceSelected(
359
+ e(this, k)[e(this, p)].place
360
360
  ));
361
361
  }
362
362
  /**
@@ -367,8 +367,8 @@ class W {
367
367
  * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.
368
368
  */
369
369
  _createSuggestionElements(t) {
370
- return l(this, g, []), t.map((i, n) => {
371
- e(this, g).push({
370
+ return l(this, k, []), t.map((i, n) => {
371
+ e(this, k).push({
372
372
  id: n + 1,
373
373
  description: i.placePrediction.toString(),
374
374
  place: i.placePrediction.toPlace()
@@ -377,38 +377,38 @@ class W {
377
377
  r.className = e(this, s).classes.li_div_container;
378
378
  const d = document.createElement("div");
379
379
  d.className = e(this, s).classes.li_div_one, r.appendChild(d);
380
- const y = document.createElement("p");
381
- y.className = e(this, s).classes.li_div_one_p;
382
- const F = i.placePrediction.text, L = F.text, M = F.matches;
383
- let w = 0;
384
- M.sort((v, $) => v.startOffset - $.startOffset);
385
- const A = document.createElement("span"), S = document.createElement("span");
386
- S.classList = e(this, s).classes.highlight ?? "font-bold";
387
- for (const v of M)
388
- A.textContent += L.substring(
389
- w,
390
- v.startOffset
391
- ), v.startOffset > 0 && L.charAt(v.startOffset - 1) == " " && (S.textContent += " "), S.textContent += L.substring(
392
- v.startOffset,
393
- v.endOffset
394
- ), w = v.endOffset;
380
+ const m = document.createElement("p");
381
+ m.className = e(this, s).classes.li_div_one_p;
382
+ const S = i.placePrediction.text, E = S.text, _ = S.matches;
383
+ let f = 0;
384
+ _.sort((w, $) => w.startOffset - $.startOffset);
385
+ const b = document.createElement("span"), N = document.createElement("span");
386
+ N.classList = e(this, s).classes.highlight ?? "font-bold";
387
+ for (const w of _)
388
+ b.textContent += E.substring(
389
+ f,
390
+ w.startOffset
391
+ ), w.startOffset > 0 && E.charAt(w.startOffset - 1) == " " && (N.textContent += " "), N.textContent += E.substring(
392
+ w.startOffset,
393
+ w.endOffset
394
+ ), f = w.endOffset;
395
395
  const T = document.createTextNode(
396
- L.substring(w)
396
+ E.substring(f)
397
397
  );
398
- A.appendChild(S), A.appendChild(T), y.appendChild(A), d.appendChild(y), r.appendChild(d);
398
+ b.appendChild(N), b.appendChild(T), m.appendChild(b), d.appendChild(m), r.appendChild(d);
399
399
  const q = document.createElement("div");
400
400
  q.className = e(this, s).classes.li_div_two, r.appendChild(q);
401
- const C = document.createElement("p");
402
- C.className = e(this, s).classes.li_div_two_p, C.textContent = this._formatDistance(
401
+ const P = document.createElement("p");
402
+ P.className = e(this, s).classes.li_div_two_p, P.textContent = this._formatDistance(
403
403
  i.placePrediction.distanceMeters,
404
404
  e(this, s).distance_units ?? "km"
405
- ), q.appendChild(C);
406
- const m = document.createElement("a");
407
- m.href = "javascript:void(0)", m.tabIndex = n + 1, m.className = e(this, s).classes.li_a, m.addEventListener("click", () => {
405
+ ), q.appendChild(P);
406
+ const g = document.createElement("a");
407
+ g.href = "javascript:void(0)", g.tabIndex = n + 1, g.className = e(this, s).classes.li_a, g.addEventListener("click", () => {
408
408
  this._onPlaceSelected(i.placePrediction.toPlace());
409
- }), m.appendChild(r), m.appendChild(q);
410
- const P = document.createElement("li");
411
- return P.id = `option-${n + 1}`, P.className = e(this, s).classes.li, P.appendChild(m), P;
409
+ }), g.appendChild(r), g.appendChild(q);
410
+ const F = document.createElement("li");
411
+ return F.id = `option-${n + 1}`, F.className = e(this, s).classes.li, F.appendChild(g), F;
412
412
  });
413
413
  }
414
414
  /**
@@ -425,7 +425,7 @@ class W {
425
425
  //["displayName", "formattedAddress", "addressComponents"], // Add more fields as needed
426
426
  }), i = t.toJSON(), e(this, z).call(this, i);
427
427
  } catch (n) {
428
- console.error("Error fetching place details:", n), e(this, k).call(this, n);
428
+ console.error("Error fetching place details:", n), e(this, L).call(this, n);
429
429
  } finally {
430
430
  this._reset(!0, i);
431
431
  }
@@ -436,9 +436,9 @@ class W {
436
436
  */
437
437
  _refreshToken() {
438
438
  try {
439
- e(this, E).sessionToken = new google.maps.places.AutocompleteSessionToken();
439
+ e(this, C).sessionToken = new google.maps.places.AutocompleteSessionToken();
440
440
  } catch (t) {
441
- console.error("Error creating session token:", t), e(this, k).call(this, t);
441
+ console.error("Error creating session token:", t), e(this, L).call(this, t);
442
442
  }
443
443
  }
444
444
  /**
@@ -471,7 +471,7 @@ class W {
471
471
  * @param {*} params
472
472
  */
473
473
  setRequestParams(t) {
474
- typeof t == "object" && !Array.isArray(t) && t !== null && (t.input && typeof t.input == "string" && (e(this, a).value = t.input), l(this, E, {
474
+ typeof t == "object" && !Array.isArray(t) && t !== null && (t.input && typeof t.input == "string" && (e(this, a).value = t.input), l(this, C, {
475
475
  ...e(this, O),
476
476
  ...t
477
477
  }));
@@ -481,7 +481,7 @@ class W {
481
481
  * @returns {Object} The current request parameters.
482
482
  */
483
483
  getRequestParams() {
484
- return e(this, E);
484
+ return e(this, C);
485
485
  }
486
486
  /**
487
487
  * Sets the options for the Places Autocomplete instance.
@@ -493,12 +493,13 @@ class W {
493
493
  * @param {*} options
494
494
  */
495
495
  setOptions(t) {
496
+ var i, n, r, d, m, S, E;
496
497
  if (typeof t == "object" && !Array.isArray(t) && t !== null) {
497
- const i = t.classes || {};
498
+ const _ = t.classes || {};
498
499
  if (delete t.classes, l(this, s, {
499
500
  ...e(this, G),
500
501
  ...t
501
- }), e(this, a).placeholder = e(this, s).placeholder, e(this, a).autocomplete = e(this, s).autocomplete, e(this, a).autofocus = e(this, s).autofocus, e(this, a).debounce = e(this, s).debounce, e(this, a).clear_input = e(this, s).clear_input, e(this, a).distance = e(this, s).distance, e(this, a).distance_units = e(this, s).distance_units, e(this, a).label = e(this, s).label, e(this, a).setAttribute(
502
+ }), console.log(e(this, a).className), e(this, a).placeholder = e(this, s).placeholder, e(this, a).autocomplete = e(this, s).autocomplete, e(this, a).autofocus = e(this, s).autofocus, e(this, a).debounce = e(this, s).debounce, e(this, a).clear_input = e(this, s).clear_input, e(this, a).distance = e(this, s).distance, e(this, a).distance_units = e(this, s).distance_units, e(this, a).label = e(this, s).label, e(this, a).setAttribute(
502
503
  "aria-label",
503
504
  e(this, s).label || "Search for places"
504
505
  ), e(this, a).setAttribute(
@@ -516,12 +517,12 @@ class W {
516
517
  ), e(this, a).setAttribute(
517
518
  "aria-activedescendant",
518
519
  e(this, s).aria_activedescendant || ""
519
- ), i && typeof i == "object" && Object.keys(i).length > 0 && (e(this, s).classes = {
520
+ ), _ && typeof _ == "object" && Object.keys(_).length > 0 && (e(this, s).classes = {
520
521
  ...e(this, I),
521
- ...i
522
- }), e(this, u) && (e(this, u).className = e(this, s).classes.container), e(this, a) && (e(this, a).className = e(this, s).classes.input), e(this, o) && (e(this, o).className = e(this, s).classes.ul), e(this, f) && (e(this, f).className = e(this, s).classes.kbd_escape), e(this, b) && (e(this, b).className = e(this, s).classes.kbd_up), e(this, _) && (e(this, _).className = e(this, s).classes.kbd_down), e(this, x)) {
523
- const n = e(this, x).querySelector("section");
524
- n && e(this, s).classes.section.split(" ").forEach((r) => r && n.classList.add(r));
522
+ ..._
523
+ }), e(this, u) && ((i = e(this, s).classes) != null && i.container) && (e(this, u).className = e(this, s).classes.container), e(this, a) && ((n = e(this, s).classes) != null && n.input) && (e(this, a).className = e(this, s).classes.input), e(this, o) && ((r = e(this, s).classes) != null && r.ul) && (e(this, o).className = e(this, s).classes.ul), e(this, y) && ((d = e(this, s).classes) != null && d.kbd_escape) && (e(this, y).className = e(this, s).classes.kbd_escape), e(this, v) && ((m = e(this, s).classes) != null && m.kbd_up) && (e(this, v).className = e(this, s).classes.kbd_up), e(this, x) && ((S = e(this, s).classes) != null && S.kbd_down) && (e(this, x).className = e(this, s).classes.kbd_down), e(this, A)) {
524
+ const f = e(this, A).querySelector("section");
525
+ f && ((E = e(this, s).classes) != null && E.section) && e(this, s).classes.section.split(" ").forEach((b) => b && f.classList.add(b));
525
526
  }
526
527
  }
527
528
  }
@@ -553,13 +554,13 @@ class W {
553
554
  e(this, a) && e(this, a).removeEventListener(
554
555
  "input",
555
556
  this._debouncedMakeAcRequest
556
- ), e(this, x) && e(this, u) && e(this, x).removeChild(e(this, u).parentElement);
557
+ ), e(this, A) && e(this, u) && e(this, A).removeChild(e(this, u).parentElement);
557
558
  for (const t in this)
558
559
  Object.hasOwn(this, t) && (this[t] = null);
559
560
  console.log("PacAutocomplete instance destroyed.");
560
561
  }
561
562
  }
562
- N = new WeakMap(), x = new WeakMap(), D = new WeakMap(), R = new WeakMap(), s = new WeakMap(), E = new WeakMap(), a = new WeakMap(), u = new WeakMap(), o = new WeakMap(), f = new WeakMap(), b = new WeakMap(), _ = new WeakMap(), g = new WeakMap(), p = new WeakMap(), z = new WeakMap(), k = new WeakMap(), G = new WeakMap(), I = new WeakMap(), O = new WeakMap(), j = new WeakMap(), K = new WeakMap();
563
+ M = new WeakMap(), A = new WeakMap(), D = new WeakMap(), R = new WeakMap(), s = new WeakMap(), C = new WeakMap(), a = new WeakMap(), u = new WeakMap(), o = new WeakMap(), y = new WeakMap(), v = new WeakMap(), x = new WeakMap(), k = new WeakMap(), p = new WeakMap(), z = new WeakMap(), L = new WeakMap(), G = new WeakMap(), I = new WeakMap(), O = new WeakMap(), j = new WeakMap(), K = new WeakMap();
563
564
  export {
564
565
  W as PlacesAutocomplete
565
566
  };
@@ -1 +1 @@
1
- {"version":3,"file":"places-autocomplete.js","sources":["../lib/PlacesAutocomplete.js"],"sourcesContent":["/**\n * Initializes a Places Autocomplete widget.\n * This script dynamically loads the Google Maps JavaScript API, creates the UI elements\n * for the autocomplete input and suggestions list, handles user input with debouncing,\n * fetches suggestions, manages keyboard navigation, and calls user-defined callbacks\n * on place selection or error.\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n *\n */\n\n/**\n * PacAutocomplete class\n * This class provides a Places Autocomplete widget.\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: true, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: true, // Clear input button (not implemented in this version).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"\", // Outer section container.\n container: \"relative z-10 transform rounded-xl mt-4\", // Main container div.\n icon_container:\n \"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"w-5 h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input:\n \"border-1 w-full rounded-md border-0 shadow-sm bg-gray-100 px-4 py-2.5 pl-10 pr-20 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 sm:text-sm\", // Input field.\n kbd_container: \"absolute inset-y-0 right-0 flex py-1.5 pr-1.5\", // Container for keyboard hints.\n kbd_escape:\n \"inline-flex items-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-8 mr-1\", // Escape key hint.\n kbd_up:\n \"inline-flex items-center justify-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-6\", // Up arrow key hint.\n kbd_down:\n \"inline-flex items-center rounded border border-gray-400 px-1 font-sans text-xs text-gray-500 justify-center w-6\", // Down arrow key hint.\n kbd_active: \"bg-indigo-500 text-white\", // Class for active keyboard hint.\n ul: \"absolute z-50 -mb-2 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm divide-y divide-gray-100\", // Suggestions list (ul).\n li: \"z-50 cursor-default select-none py-2 px-2 lg:px-4 text-gray-900 hover:bg-indigo-500 hover:text-white\", // Suggestion item (li).\n li_current: \"bg-indigo-500\", // Class for the currently selected suggestion item.\n li_a: \"block w-full flex justify-between\", // Link element within a suggestion item.\n li_a_current: \"text-white\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"flex min-w-0 gap-x-4\", // Container div within the suggestion link.\n li_div_one: \"min-w-0 flex-auto\", // First inner div (for place name).\n li_div_one_p: \"text-sm/6\", // Paragraph for the place name.\n li_div_two: \"shrink-0 flex flex-col items-end min-w-16\", // Second inner div (for distance).\n li_div_two_p: \"mt-1 text-xs/5\", // Paragraph for the distance.\n highlight: \"font-bold\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n region: \"GB\",\n };\n #fetchFields = [];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n // console.log(\"PacAutocomplete constructor called.\", config.requestParams);\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\"\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n //console.log(this.#options);\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n //console.log(this.#request);\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure(); // Pass this.#options\n await this._initializeAutocomplete(); // Pass this.#options\n //console.log(\"PacAutocomplete Initialized for container:\", this.#pacEl.id);\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n * The debounced function delays invoking `func` until after `wait` milliseconds have\n * elapsed since the last time the debounced function was invoked.\n * @param {Function} func - The function to debounce.\n * @param {number} wait - The number of milliseconds to delay.\n * @returns {Function} The new debounced function.\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance in meters into kilometers or miles.\n * @param {number | null | undefined} distance - Distance in meters.\n * @param {'km' | 'miles'} units - The desired output units.\n * @returns {string | null} Formatted distance string (e.g., \"1.23 km\") or null if input is invalid.\n */\n _formatDistance(distance, units) {\n if (typeof distance !== \"number\" || !this.#options.distance) {\n return null; // Return null if distance isn't shown or invalid\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k]\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () => (h = n(Error(p + \" could not load.\"))); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#containerId + \"-labelInput\"; // Assuming inputElement gets this ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n this.#container.appendChild(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"&#8593;\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"&#8595;\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#container.appendChild(this.#ul);\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this.#inputElement.addEventListener(\n \"input\",\n this._debouncedMakeAcRequest.bind(this)\n );\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\")\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\")\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"a\");\n if (link) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1\n );\n if (this.#currentSuggestion < 0) this.#currentSuggestion = 0; // Handle case where it was -1\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Debounced function to fetch autocomplete suggestions from the Google Places API.\n * Triggered by the 'input' event on the input element.\n */\n _debouncedMakeAcRequest = this._debounce(async () => {\n if (!this.#inputElement || !this.#inputElement.value) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n this.#request.input = this.#inputElement.value;\n //console.log(\"Request:\", this.#request); // Debugging\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request\n );\n\n // Display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#ul.replaceChildren(\n ...this._createSuggestionElements(suggestions)\n );\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n // Optionally display a \"no results\" message in the 'ul'\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n // if (this.#inputElement)\n // this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, this.#options?.debounce ?? 100);\n\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n return suggestions.map((suggestion, index) => {\n this.#allSuggestions.push({\n id: index + 1,\n description: suggestion.placePrediction.toString(),\n place: suggestion.placePrediction.toPlace(),\n });\n\n // create div elements\n const divContainer = document.createElement(\"div\");\n divContainer.className = this.#options.classes.li_div_container; // flex min-w-0 gap-x-4\n // create inner div element - place name\n const divInner = document.createElement(\"div\");\n divInner.className = this.#options.classes.li_div_one; // min-w-0 flex-auto\n divContainer.appendChild(divInner);\n // create p element - place name\n const p = document.createElement(\"p\");\n p.className = this.#options.classes.li_div_one_p; // text-sm/6\n\n // get prediction text\n const predictionText = suggestion.placePrediction.text;\n const originalText = predictionText.text;\n // Array of objects with startOffset, endOffset\n const matches = predictionText.matches;\n\n //Highlighting Logic\n let lastIndex = 0;\n\n // Sort matches just in case they aren't ordered (though they usually are)\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n // 1. Create the outer span\n const outerSpan = document.createElement(\"span\");\n\n // 2. Create the inner span for the bold part\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\"; // Use the highlight class from options\n\n for (const match of matches) {\n // Append text before the current match\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset\n );\n\n // Append the highlighted match segment\n if (match.startOffset > 0) {\n // check previous charter is space\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar == \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset\n );\n\n // Update the last index processed\n lastIndex = match.endOffset;\n }\n\n // 3. Create a text node for the remaining text\n const remainingText = document.createTextNode(\n originalText.substring(lastIndex)\n );\n\n // 4. Append the inner span and the text node to the outer span\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(remainingText);\n\n // 5. Append the outer span to the paragraph element\n p.appendChild(outerSpan);\n\n divInner.appendChild(p);\n divContainer.appendChild(divInner);\n\n // create inner div element - distance\n const divInner2 = document.createElement(\"div\");\n divInner2.className = this.#options.classes.li_div_two; //'shrink-0 flex flex-col items-end min-w-16';\n divContainer.appendChild(divInner2);\n // create p element - distance\n const p2 = document.createElement(\"p\");\n p2.className = this.#options.classes.li_div_two_p; //'mt-1 text-xs/5 ';\n p2.textContent = this._formatDistance(\n suggestion.placePrediction.distanceMeters,\n this.#options.distance_units ?? \"km\"\n );\n divInner2.appendChild(p2);\n\n // // create a link element\n const a = document.createElement(\"a\");\n a.href = \"javascript:void(0)\";\n a.tabIndex = index + 1;\n a.className = this.#options.classes.li_a; // block w-full flex justify-between\n\n a.addEventListener(\"click\", () => {\n this._onPlaceSelected(suggestion.placePrediction.toPlace());\n });\n\n // ...\n // a.addEventListener(\"click\", () => {\n // this._fetchPlaceDetails(prediction.place_id);\n // });\n a.appendChild(divContainer);\n a.appendChild(divInner2);\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n\n li.appendChild(a);\n return li;\n });\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object\n this.#onDataCallback(data); // Convert to plain JSON object for the callback\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Gets the current request parameters used by the Places Autocomplete instance.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n\n this.#inputElement.placeholder = this.#options.placeholder; // Update placeholder text\n this.#inputElement.autocomplete = this.#options.autocomplete; // Update autocomplete attribute\n this.#inputElement.autofocus = this.#options.autofocus; // Update autofocus attribute\n this.#inputElement.debounce = this.#options.debounce; // Update debounce attribute\n this.#inputElement.clear_input = this.#options.clear_input; // Update clear_input attribute\n this.#inputElement.distance = this.#options.distance; // Update distance attribute\n this.#inputElement.distance_units = this.#options.distance_units; // Update distance units attribute\n this.#inputElement.label = this.#options.label; // Update label text\n\n this.#inputElement.setAttribute(\n \"aria-label\",\n this.#options.label || \"Search for places\"\n ); // Update ARIA label\n this.#inputElement.setAttribute(\n \"aria-autocomplete\",\n this.#options.aria_autocomplete || \"list\"\n ); // Update ARIA autocomplete attribute\n this.#inputElement.setAttribute(\n \"aria-expanded\",\n this.#options.aria_expanded || \"false\"\n ); // Update ARIA expanded attribute\n this.#inputElement.setAttribute(\n \"aria-controls\",\n this.#options.aria_controls || \"pacSuggestions\"\n ); // Update ARIA controls attribute\n this.#inputElement.setAttribute(\"role\", this.#options.role || \"combobox\"); // Update ARIA role attribute\n this.#inputElement.setAttribute(\n \"aria-required\",\n this.#options.aria_required || \"false\"\n ); // Update ARIA required attribute\n this.#inputElement.setAttribute(\n \"aria-activedescendant\",\n this.#options.aria_activedescendant || \"\"\n ); // Update ARIA activedescendant attribute\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n }\n\n // Update the classes of the container and input element\n if (this.#container) {\n this.#container.className = this.#options.classes.container; // Update container class\n }\n if (this.#inputElement) {\n this.#inputElement.className = this.#options.classes.input; // Update input class\n }\n // Update the classes of the suggestions list\n if (this.#ul) {\n this.#ul.className = this.#options.classes.ul; // Update suggestions list class\n }\n // Update the classes of the keyboard hints\n if (this.#kbdEscape) {\n this.#kbdEscape.className = this.#options.classes.kbd_escape; // Update Escape key hint class\n }\n if (this.#kbdUp) {\n this.#kbdUp.className = this.#options.classes.kbd_up; // Update Up arrow key hint class\n }\n if (this.#kbdDown) {\n this.#kbdDown.className = this.#options.classes.kbd_down; // Update Down arrow key hint class\n }\n // Update the classes of the section\n if (this.#pacEl) {\n const section = this.#pacEl.querySelector(\"section\");\n\n if (section) {\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n }\n }\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this._reset(true);\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this._debouncedMakeAcRequest\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n // Nullify properties\n for (const prop in this) {\n if (Object.hasOwn(this, prop)) {\n this[prop] = null;\n }\n }\n console.log(\"PacAutocomplete instance destroyed.\");\n }\n}\n"],"names":["_a","_containerId","_pacEl","_googleMapsApiKey","_googleMapsApiVersion","_options","_request","_inputElement","_container","_ul","_kbdEscape","_kbdUp","_kbdDown","_allSuggestions","_currentSuggestion","_onDataCallback","_onErrorCallback","_defaultOptions","_defaultClasses","_defaultRequestParams","_fetchFields","_defaultFetchFields","PlacesAutocomplete","config","__privateAdd","__publicField","__privateGet","suggestions","error","__privateSet","place","fields","e","func","wait","timeout","args","later","distance","units","value","unitLabel","g","h","a","k","p","c","l","q","m","b","d","r","u","f","n","t","section","cl","iconContainer","icon","label","kbdContainer","refresh","placeData","li","link","currentLi","currentA","suggestion","index","divContainer","divInner","predictionText","originalText","matches","lastIndex","outerSpan","innerSpan","match","remainingText","divInner2","p2","data","params","options","tmpClasses","prop"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AAgBO,MAAMC,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+E9B,YAAYC,GAAQ;AA7EpB;AAAA,IAAAC,EAAA,MAAAvB;AACA;AAAA,IAAAuB,EAAA,MAAAtB;AACA,IAAAsB,EAAA,MAAArB;AACA,IAAAqB,EAAA,MAAApB;AACA,IAAAoB,EAAA,MAAAnB;AACA,IAAA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AAOjC,EAAA,MAAKrB;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASE,QAAQ;AACN,SAAK,OAAO,EAAI;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASE,UAAU;AAER,IAAIqB,EAAA,MAAKnB,MACPmB,EAAA,MAAKnB,GAAc;AAAA,MACjB;AAAA,MACA,KAAK;AAAA,IACN,GAGCmB,EAAA,MAAKxB,MAAUwB,EAAA,MAAKlB,MACtBkB,EAAA,MAAKxB,GAAO,YAAYwB,EAAA,MAAKlB,GAAW,aAAa;AAGvD,eAAWgF,KAAQ;AACjB,MAAI,OAAO,OAAO,MAAMA,CAAI,MAC1B,KAAKA,CAAI,IAAI;AAGjB,YAAQ,IAAI,qCAAqC;AAAA,EACrD;AACA;AAx+BEvF,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eACAC,IAAA,eAWAC,IAAA,eA6BAC,IAAA,eAOAC,IAAA,eACAC,IAAA;"}
1
+ {"version":3,"file":"places-autocomplete.js","sources":["../lib/PlacesAutocomplete.js"],"sourcesContent":["/**\n * Initializes a Places Autocomplete widget.\n * This script dynamically loads the Google Maps JavaScript API, creates the UI elements\n * for the autocomplete input and suggestions list, handles user input with debouncing,\n * fetches suggestions, manages keyboard navigation, and calls user-defined callbacks\n * on place selection or error.\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n *\n */\n\n/**\n * PacAutocomplete class\n * This class provides a Places Autocomplete widget.\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: true, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: true, // Clear input button (not implemented in this version).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"\", // Outer section container.\n container: \"relative z-10 transform rounded-xl mt-4\", // Main container div.\n icon_container:\n \"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"w-5 h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input:\n \"border-1 w-full rounded-md border-0 shadow-sm bg-gray-100 px-4 py-2.5 pl-10 pr-20 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 sm:text-sm\", // Input field.\n kbd_container: \"absolute inset-y-0 right-0 flex py-1.5 pr-1.5\", // Container for keyboard hints.\n kbd_escape:\n \"inline-flex items-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-8 mr-1\", // Escape key hint.\n kbd_up:\n \"inline-flex items-center justify-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-6\", // Up arrow key hint.\n kbd_down:\n \"inline-flex items-center rounded border border-gray-400 px-1 font-sans text-xs text-gray-500 justify-center w-6\", // Down arrow key hint.\n kbd_active: \"bg-indigo-500 text-white\", // Class for active keyboard hint.\n ul: \"absolute z-50 -mb-2 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm divide-y divide-gray-100\", // Suggestions list (ul).\n li: \"z-50 cursor-default select-none py-2 px-2 lg:px-4 text-gray-900 hover:bg-indigo-500 hover:text-white\", // Suggestion item (li).\n li_current: \"bg-indigo-500\", // Class for the currently selected suggestion item.\n li_a: \"block w-full flex justify-between\", // Link element within a suggestion item.\n li_a_current: \"text-white\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"flex min-w-0 gap-x-4\", // Container div within the suggestion link.\n li_div_one: \"min-w-0 flex-auto\", // First inner div (for place name).\n li_div_one_p: \"text-sm/6\", // Paragraph for the place name.\n li_div_two: \"shrink-0 flex flex-col items-end min-w-16\", // Second inner div (for distance).\n li_div_two_p: \"mt-1 text-xs/5\", // Paragraph for the distance.\n highlight: \"font-bold\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n region: \"GB\",\n };\n #fetchFields = [\"formattedAddress\", \"addressComponents\"];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n // console.log(\"PacAutocomplete constructor called.\", config.requestParams);\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\"\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n //console.log(this.#options);\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n //console.log(this.#request);\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure(); // Pass this.#options\n await this._initializeAutocomplete(); // Pass this.#options\n //console.log(\"PacAutocomplete Initialized for container:\", this.#pacEl.id);\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n * The debounced function delays invoking `func` until after `wait` milliseconds have\n * elapsed since the last time the debounced function was invoked.\n * @param {Function} func - The function to debounce.\n * @param {number} wait - The number of milliseconds to delay.\n * @returns {Function} The new debounced function.\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance in meters into kilometers or miles.\n * @param {number | null | undefined} distance - Distance in meters.\n * @param {'km' | 'miles'} units - The desired output units.\n * @returns {string | null} Formatted distance string (e.g., \"1.23 km\") or null if input is invalid.\n */\n _formatDistance(distance, units) {\n if (typeof distance !== \"number\" || !this.#options.distance) {\n return null; // Return null if distance isn't shown or invalid\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k]\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () => (h = n(Error(p + \" could not load.\"))); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#containerId + \"-labelInput\"; // Assuming inputElement gets this ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n this.#container.appendChild(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"&#8593;\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"&#8595;\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#container.appendChild(this.#ul);\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this.#inputElement.addEventListener(\n \"input\",\n this._debouncedMakeAcRequest.bind(this)\n );\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\")\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\")\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"a\");\n if (link) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1\n );\n if (this.#currentSuggestion < 0) this.#currentSuggestion = 0; // Handle case where it was -1\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Debounced function to fetch autocomplete suggestions from the Google Places API.\n * Triggered by the 'input' event on the input element.\n */\n _debouncedMakeAcRequest = this._debounce(async () => {\n if (!this.#inputElement || !this.#inputElement.value) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n this.#request.input = this.#inputElement.value;\n //console.log(\"Request:\", this.#request); // Debugging\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request\n );\n\n // Display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#ul.replaceChildren(\n ...this._createSuggestionElements(suggestions)\n );\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n // Optionally display a \"no results\" message in the 'ul'\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n // if (this.#inputElement)\n // this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, this.#options?.debounce ?? 100);\n\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n return suggestions.map((suggestion, index) => {\n this.#allSuggestions.push({\n id: index + 1,\n description: suggestion.placePrediction.toString(),\n place: suggestion.placePrediction.toPlace(),\n });\n\n // create div elements\n const divContainer = document.createElement(\"div\");\n divContainer.className = this.#options.classes.li_div_container; // flex min-w-0 gap-x-4\n // create inner div element - place name\n const divInner = document.createElement(\"div\");\n divInner.className = this.#options.classes.li_div_one; // min-w-0 flex-auto\n divContainer.appendChild(divInner);\n // create p element - place name\n const p = document.createElement(\"p\");\n p.className = this.#options.classes.li_div_one_p; // text-sm/6\n\n // get prediction text\n const predictionText = suggestion.placePrediction.text;\n const originalText = predictionText.text;\n // Array of objects with startOffset, endOffset\n const matches = predictionText.matches;\n\n //Highlighting Logic\n let lastIndex = 0;\n\n // Sort matches just in case they aren't ordered (though they usually are)\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n // 1. Create the outer span\n const outerSpan = document.createElement(\"span\");\n\n // 2. Create the inner span for the bold part\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\"; // Use the highlight class from options\n\n for (const match of matches) {\n // Append text before the current match\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset\n );\n\n // Append the highlighted match segment\n if (match.startOffset > 0) {\n // check previous charter is space\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar == \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset\n );\n\n // Update the last index processed\n lastIndex = match.endOffset;\n }\n\n // 3. Create a text node for the remaining text\n const remainingText = document.createTextNode(\n originalText.substring(lastIndex)\n );\n\n // 4. Append the inner span and the text node to the outer span\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(remainingText);\n\n // 5. Append the outer span to the paragraph element\n p.appendChild(outerSpan);\n\n divInner.appendChild(p);\n divContainer.appendChild(divInner);\n\n // create inner div element - distance\n const divInner2 = document.createElement(\"div\");\n divInner2.className = this.#options.classes.li_div_two; //'shrink-0 flex flex-col items-end min-w-16';\n divContainer.appendChild(divInner2);\n // create p element - distance\n const p2 = document.createElement(\"p\");\n p2.className = this.#options.classes.li_div_two_p; //'mt-1 text-xs/5 ';\n p2.textContent = this._formatDistance(\n suggestion.placePrediction.distanceMeters,\n this.#options.distance_units ?? \"km\"\n );\n divInner2.appendChild(p2);\n\n // // create a link element\n const a = document.createElement(\"a\");\n a.href = \"javascript:void(0)\";\n a.tabIndex = index + 1;\n a.className = this.#options.classes.li_a; // block w-full flex justify-between\n\n a.addEventListener(\"click\", () => {\n this._onPlaceSelected(suggestion.placePrediction.toPlace());\n });\n\n // ...\n // a.addEventListener(\"click\", () => {\n // this._fetchPlaceDetails(prediction.place_id);\n // });\n a.appendChild(divContainer);\n a.appendChild(divInner2);\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n\n li.appendChild(a);\n return li;\n });\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object\n this.#onDataCallback(data); // Convert to plain JSON object for the callback\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Gets the current request parameters used by the Places Autocomplete instance.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n console.log(this.#inputElement.className);\n\n this.#inputElement.placeholder = this.#options.placeholder; // Update placeholder text\n this.#inputElement.autocomplete = this.#options.autocomplete; // Update autocomplete attribute\n this.#inputElement.autofocus = this.#options.autofocus; // Update autofocus attribute\n this.#inputElement.debounce = this.#options.debounce; // Update debounce attribute\n this.#inputElement.clear_input = this.#options.clear_input; // Update clear_input attribute\n this.#inputElement.distance = this.#options.distance; // Update distance attribute\n this.#inputElement.distance_units = this.#options.distance_units; // Update distance units attribute\n this.#inputElement.label = this.#options.label; // Update label text\n\n this.#inputElement.setAttribute(\n \"aria-label\",\n this.#options.label || \"Search for places\"\n ); // Update ARIA label\n this.#inputElement.setAttribute(\n \"aria-autocomplete\",\n this.#options.aria_autocomplete || \"list\"\n ); // Update ARIA autocomplete attribute\n this.#inputElement.setAttribute(\n \"aria-expanded\",\n this.#options.aria_expanded || \"false\"\n ); // Update ARIA expanded attribute\n this.#inputElement.setAttribute(\n \"aria-controls\",\n this.#options.aria_controls || \"pacSuggestions\"\n ); // Update ARIA controls attribute\n this.#inputElement.setAttribute(\"role\", this.#options.role || \"combobox\"); // Update ARIA role attribute\n this.#inputElement.setAttribute(\n \"aria-required\",\n this.#options.aria_required || \"false\"\n ); // Update ARIA required attribute\n this.#inputElement.setAttribute(\n \"aria-activedescendant\",\n this.#options.aria_activedescendant || \"\"\n ); // Update ARIA activedescendant attribute\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n }\n\n // Update the classes of the container and input element\n if (this.#container && this.#options.classes?.container) {\n this.#container.className = this.#options.classes.container; // Update container class\n }\n if (this.#inputElement && this.#options.classes?.input) {\n this.#inputElement.className = this.#options.classes.input; // Update input class\n }\n // Update the classes of the suggestions list\n if (this.#ul && this.#options.classes?.ul) {\n this.#ul.className = this.#options.classes.ul; // Update suggestions list class\n }\n // Update the classes of the keyboard hints\n if (this.#kbdEscape && this.#options.classes?.kbd_escape) {\n this.#kbdEscape.className = this.#options.classes.kbd_escape; // Update Escape key hint class\n }\n if (this.#kbdUp && this.#options.classes?.kbd_up) {\n this.#kbdUp.className = this.#options.classes.kbd_up; // Update Up arrow key hint class\n }\n if (this.#kbdDown && this.#options.classes?.kbd_down) {\n this.#kbdDown.className = this.#options.classes.kbd_down; // Update Down arrow key hint class\n }\n // Update the classes of the section\n if (this.#pacEl) {\n const section = this.#pacEl.querySelector(\"section\");\n\n if (section && this.#options.classes?.section) {\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n }\n }\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this._reset(true);\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this._debouncedMakeAcRequest\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n // Nullify properties\n for (const prop in this) {\n if (Object.hasOwn(this, prop)) {\n this[prop] = null;\n }\n }\n console.log(\"PacAutocomplete instance destroyed.\");\n }\n}\n"],"names":["_a","_containerId","_pacEl","_googleMapsApiKey","_googleMapsApiVersion","_options","_request","_inputElement","_container","_ul","_kbdEscape","_kbdUp","_kbdDown","_allSuggestions","_currentSuggestion","_onDataCallback","_onErrorCallback","_defaultOptions","_defaultClasses","_defaultRequestParams","_fetchFields","_defaultFetchFields","PlacesAutocomplete","config","__privateAdd","__publicField","__privateGet","suggestions","error","__privateSet","place","fields","e","func","wait","timeout","args","later","distance","units","value","unitLabel","g","h","a","k","p","c","l","q","m","b","d","r","u","f","n","t","section","cl","iconContainer","icon","label","kbdContainer","refresh","placeData","li","link","currentLi","currentA","suggestion","index","divContainer","divInner","predictionText","originalText","matches","lastIndex","outerSpan","innerSpan","match","remainingText","divInner2","p2","data","params","options","_b","_c","_d","_e","_f","_g","tmpClasses","prop"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC,GAAAC;AAgBO,MAAMC,EAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA+E9B,YAAYC,GAAQ;AA7EpB;AAAA,IAAAC,EAAA,MAAAvB;AACA;AAAA,IAAAuB,EAAA,MAAAtB;AACA,IAAAsB,EAAA,MAAArB;AACA,IAAAqB,EAAA,MAAApB;AACA,IAAAoB,EAAA,MAAAnB;AACA,IAAAmB,EAAA,MAAAlB;AACA,IAAAkB,EAAA,MAAAjB;AACA,IAAAiB,EAAA,MAAAhB;AACA,IAAAgB,EAAA,MAAAf;AACA,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AA;"}
@@ -1,4 +1,4 @@
1
- (function(l,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(l=typeof globalThis<"u"?globalThis:l||self,o(l.PlacesAutocomplete={}))})(this,function(l){"use strict";var Z=Object.defineProperty;var V=l=>{throw TypeError(l)};var Q=(l,o,u)=>o in l?Z(l,o,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[o]=u;var J=(l,o,u)=>Q(l,typeof o!="symbol"?o+"":o,u),U=(l,o,u)=>o.has(l)||V("Cannot "+u);var e=(l,o,u)=>(U(l,o,"read from private field"),u?u.call(l):o.get(l)),d=(l,o,u)=>o.has(l)?V("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(l):o.set(l,u),h=(l,o,u,x)=>(U(l,o,"write to private field"),x?x.call(l,u):o.set(l,u),u);/**
1
+ (function(l,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(l=typeof globalThis<"u"?globalThis:l||self,o(l.PlacesAutocomplete={}))})(this,function(l){"use strict";var Z=Object.defineProperty;var V=l=>{throw TypeError(l)};var Q=(l,o,p)=>o in l?Z(l,o,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[o]=p;var J=(l,o,p)=>Q(l,typeof o!="symbol"?o+"":o,p),U=(l,o,p)=>o.has(l)||V("Cannot "+p);var e=(l,o,p)=>(U(l,o,"read from private field"),p?p.call(l):o.get(l)),d=(l,o,p)=>o.has(l)?V("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(l):o.set(l,p),h=(l,o,p,w)=>(U(l,o,"write to private field"),w?w.call(l,p):o.set(l,p),p);/**
2
2
  * Initializes a Places Autocomplete widget.
3
3
  * This script dynamically loads the Google Maps JavaScript API, creates the UI elements
4
4
  * for the autocomplete input and suggestions list, handles user input with debouncing,
@@ -8,5 +8,5 @@
8
8
  * @author Alexander Pechkarev <alexpechkarev@gmail.com>
9
9
  * @license MIT
10
10
  *
11
- */var u,x,E,z,G,s,k,i,p,c,b,_,y,g,m,K,A,$,F,q,I,B;class o{constructor(t){d(this,x);d(this,E);d(this,z);d(this,G);d(this,s);d(this,k);d(this,i);d(this,p);d(this,c);d(this,b);d(this,_);d(this,y);d(this,g,[]);d(this,m,-1);d(this,K);d(this,A);d(this,$,{autofocus:!1,autocomplete:"off",placeholder:"Start typing your address ...",distance:!0,distance_units:"km",label:"",debounce:100,clear_input:!0});d(this,F,{section:"",container:"relative z-10 transform rounded-xl mt-4",icon_container:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",icon:'<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8" /><path d="m21 21-4.3-4.3" /></svg>',input:"border-1 w-full rounded-md border-0 shadow-sm bg-gray-100 px-4 py-2.5 pl-10 pr-20 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 sm:text-sm",kbd_container:"absolute inset-y-0 right-0 flex py-1.5 pr-1.5",kbd_escape:"inline-flex items-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-8 mr-1",kbd_up:"inline-flex items-center justify-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-6",kbd_down:"inline-flex items-center rounded border border-gray-400 px-1 font-sans text-xs text-gray-500 justify-center w-6",kbd_active:"bg-indigo-500 text-white",ul:"absolute z-50 -mb-2 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm divide-y divide-gray-100",li:"z-50 cursor-default select-none py-2 px-2 lg:px-4 text-gray-900 hover:bg-indigo-500 hover:text-white",li_current:"bg-indigo-500",li_a:"block w-full flex justify-between",li_a_current:"text-white",li_div_container:"flex min-w-0 gap-x-4",li_div_one:"min-w-0 flex-auto",li_div_one_p:"text-sm/6",li_div_two:"shrink-0 flex flex-col items-end min-w-16",li_div_two_p:"mt-1 text-xs/5",highlight:"font-bold"});d(this,q,{input:"",includedRegionCodes:["GB"],language:"en-gb",region:"GB"});d(this,I,[]);d(this,B,["formattedAddress","addressComponents"]);J(this,"_debouncedMakeAcRequest",this._debounce(async()=>{if(!e(this,i)||!e(this,i).value){this._reset(),e(this,i)&&e(this,i).setAttribute("aria-expanded","false");return}e(this,k).input=e(this,i).value;try{const{suggestions:t}=await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(e(this,k));t&&t.length>0?(e(this,c).replaceChildren(...this._createSuggestionElements(t)),e(this,c).style.display="block",e(this,i).setAttribute("aria-expanded","true")):(this._reset(),e(this,i).setAttribute("aria-expanded","false"))}catch(t){e(this,A).call(this,t),this._reset()}},((u=e(this,s))==null?void 0:u.debounce)??100));if(!t||!t.containerId||!t.googleMapsApiKey)throw new Error("PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).");if(h(this,x,t.containerId),h(this,E,document.getElementById(t.containerId)),!e(this,E))throw new Error(`PacAutocomplete: Container element with ID "${t.containerId}" not found.`);h(this,z,t.googleMapsApiKey),h(this,G,t.googleMapsApiVersion||"weekly"),h(this,s,{...e(this,$),...t.options}),t.options&&t.options.classes?e(this,s).classes={...e(this,F),...t.options.classes}:e(this,s).classes=e(this,F),t.fetchFields&&Array.isArray(t.fetchFields)&&this._setFetchFields(t.fetchFields),h(this,K,t.onResponse||(a=>{console.info("---------Default onResponse not provided---------"),console.info("Selected Place:",JSON.stringify(a,null,2))})),h(this,A,t.onError||(a=>{console.error("---------Default onError not provided---------"),console.error("PAC Error:",a)})),t.requestParams&&Object.keys(t.requestParams).length>0?h(this,k,{...e(this,q),...t.requestParams}):h(this,k,{...e(this,q)}),this._init()}async _init(){try{(typeof google>"u"||!google.maps)&&await this._loadGoogleMapsApi({key:e(this,z),v:e(this,G)}),this._createPACStructure(),await this._initializeAutocomplete()}catch(t){e(this,A).call(this,t)}}_setFetchFields(t){Array.isArray(t)&&t.length>0&&h(this,I,[...new Set([...e(this,B),...t])].filter(a=>a))}_debounce(t,a){let n=null;return function(...f){const w=()=>{n=null,t(...f)};n!==null&&clearTimeout(n),n=setTimeout(w,a??100)}}_formatDistance(t,a){if(typeof t!="number"||!e(this,s).distance)return null;let n,r;return a==="km"?(n=(t/1e3).toFixed(2),r="km"):(n=(t/1609.34).toFixed(2),r="miles"),n=n.replace(/\.00$/,""),`${n} ${r}`}async _loadGoogleMapsApi(t){var a,n,r,f="The Google Maps JavaScript API",w="google",O="importLibrary",N="__ib__",j=document,L=window;L=L[w]||(L[w]={});var S=L.maps||(L.maps={}),T=new Set,D=new URLSearchParams,R=()=>a||(a=new Promise(async(P,v)=>{var M;n=j.createElement("script"),D.set("libraries",[...T].join(","));for(r in t)D.set(r.replace(/[A-Z]/g,C=>"_"+C[0].toLowerCase()),t[r]);D.set("callback",w+".maps."+N),n.src=`https://maps.${w}apis.com/maps/api/js?`+D,S[N]=P,n.onerror=()=>a=v(Error(f+" could not load.")),n.nonce=((M=j.querySelector("script[nonce]"))==null?void 0:M.nonce)||"",j.head.append(n)}));S[O]?console.warn(f+" only loads once. Ignoring:",t):S[O]=(P,...v)=>T.add(P)&&R().then(()=>S[O](P,...v))}_createPACStructure(){const t=document.createElement("section");e(this,s).classes.section.split(" ").forEach(f=>f&&t.classList.add(f)),h(this,p,document.createElement("div")),e(this,p).className=e(this,s).classes.container,e(this,p).setAttribute("id",e(this,x)+"-div"),t.appendChild(e(this,p));const a=document.createElement("div");a.className=e(this,s).classes.icon_container,e(this,p).appendChild(a);const n=document.createElement("div");if(n.innerHTML=e(this,s).classes.icon,a.appendChild(n.firstElementChild),h(this,i,document.createElement("input")),e(this,i).id=e(this,x)+"-input",e(this,i).type="text",e(this,i).name="search",e(this,i).placeholder=e(this,s).placeholder,e(this,i).autocomplete=e(this,s).autocomplete,e(this,i).className=e(this,s).classes.input,e(this,i).setAttribute("role","combobox"),e(this,i).setAttribute("aria-autocomplete","list"),e(this,i).setAttribute("aria-expanded","false"),e(this,i).setAttribute("aria-controls","pacSuggestions"),e(this,s).autofocus&&(e(this,i).autofocus=!0),e(this,s).label){const f=document.createElement("label");f.htmlFor=e(this,x)+"-labelInput",f.textContent=e(this,s).label,e(this,p).appendChild(f)}e(this,p).appendChild(e(this,i));const r=document.createElement("div");r.className=e(this,s).classes.kbd_container,h(this,b,document.createElement("kbd")),e(this,b).className=e(this,s).classes.kbd_escape,e(this,b).textContent="Esc",r.appendChild(e(this,b)),h(this,_,document.createElement("kbd")),e(this,_).className=e(this,s).classes.kbd_up,e(this,_).innerHTML="&#8593;",r.appendChild(e(this,_)),h(this,y,document.createElement("kbd")),e(this,y).className=e(this,s).classes.kbd_down,e(this,y).innerHTML="&#8595;",r.appendChild(e(this,y)),e(this,p).appendChild(r),h(this,c,document.createElement("ul")),e(this,c).id="pacSuggestions",e(this,c).className=e(this,s).classes.ul,e(this,c).style.display="none",e(this,c).setAttribute("role","listbox"),e(this,p).appendChild(e(this,c)),e(this,E).appendChild(t),t.addEventListener("keydown",this._onKeyDown.bind(this))}async _initializeAutocomplete(){try{await google.maps.importLibrary("places"),this._refreshToken(),e(this,i)?(e(this,i).addEventListener("input",this._debouncedMakeAcRequest.bind(this)),e(this,i).addEventListener("blur",()=>{setTimeout(()=>{e(this,c)&&!e(this,c).contains(document.activeElement)&&(e(this,c).style.display="none",e(this,i).setAttribute("aria-expanded","false"))},200)}),e(this,i).addEventListener("focus",()=>{e(this,i).value&&e(this,g).length>0&&(e(this,c).style.display="block",e(this,i).setAttribute("aria-expanded","true"))})):e(this,A).call(this,new Error("Input element not found during initialization."))}catch(t){console.error("Error initializing Google Places Autocomplete:",t),e(this,A).call(this,new Error("Google Maps Places library not available."))}}_reset(t=!1,a=null){h(this,m,-1),e(this,i)&&e(this,s).clear_input==!1&&a&&a.formattedAddress?e(this,i).value=a.formattedAddress:e(this,i)&&(e(this,i).value=""),e(this,i)&&(e(this,i).setAttribute("aria-expanded","false"),e(this,i).blur()),h(this,g,[]),h(this,m,-1),e(this,c)&&(e(this,c).innerHTML="",e(this,c).style.display="none"),t&&this._refreshToken()}_resetLiClasses(){e(this,c)&&Array.from(e(this,c).children).forEach(t=>{e(this,s).classes.li_current.split(" ").forEach(n=>t.classList.remove(n));const a=t.querySelector("a");a&&e(this,s).classes.li_a_current.split(" ").forEach(n=>a.classList.remove(n))})}_onKeyDown(t){if(this._resetLiClasses(),t.key==="Escape"&&(t.preventDefault(),e(this,s).classes.kbd_active.split(" ").forEach(a=>{var n;return(n=e(this,b))==null?void 0:n.classList.add(a)}),setTimeout(()=>e(this,s).classes.kbd_active.split(" ").forEach(a=>{var n;return(n=e(this,b))==null?void 0:n.classList.remove(a)}),300),this._reset(!0)),!(!e(this,g).length||!e(this,c)||e(this,c).style.display==="none"))if(t.key==="ArrowDown"){t.preventDefault(),h(this,m,Math.min(e(this,m)+1,e(this,g).length-1)),e(this,m)<0&&h(this,m,0);const a=e(this,c).children.item(e(this,m));if(a){const n=a.querySelector("a");e(this,s).classes.li_current.split(" ").forEach(r=>a.classList.add(r)),n&&e(this,s).classes.li_a_current.split(" ").forEach(r=>n.classList.add(r)),a.scrollIntoView({block:"nearest"})}e(this,s).classes.kbd_active.split(" ").forEach(n=>{var r;return(r=e(this,y))==null?void 0:r.classList.add(n)}),setTimeout(()=>e(this,s).classes.kbd_active.split(" ").forEach(n=>{var r;return(r=e(this,y))==null?void 0:r.classList.remove(n)}),300)}else if(t.key==="ArrowUp"){t.preventDefault(),h(this,m,Math.max(e(this,m)-1,0));const a=e(this,c).children.item(e(this,m));if(a){const n=a.querySelector("a");e(this,s).classes.li_current.split(" ").forEach(r=>a.classList.add(r)),n&&e(this,s).classes.li_a_current.split(" ").forEach(r=>n.classList.add(r)),a.scrollIntoView({block:"nearest"})}e(this,s).classes.kbd_active.split(" ").forEach(n=>{var r;return(r=e(this,_))==null?void 0:r.classList.add(n)}),setTimeout(()=>e(this,s).classes.kbd_active.split(" ").forEach(n=>{var r;return(r=e(this,_))==null?void 0:r.classList.remove(n)}),300)}else t.key==="Enter"&&(t.preventDefault(),e(this,m)>=0&&e(this,m)<e(this,g).length&&this._onPlaceSelected(e(this,g)[e(this,m)].place))}_createSuggestionElements(t){return h(this,g,[]),t.map((a,n)=>{e(this,g).push({id:n+1,description:a.placePrediction.toString(),place:a.placePrediction.toPlace()});const r=document.createElement("div");r.className=e(this,s).classes.li_div_container;const f=document.createElement("div");f.className=e(this,s).classes.li_div_one,r.appendChild(f);const w=document.createElement("p");w.className=e(this,s).classes.li_div_one_p;const O=a.placePrediction.text,N=O.text,j=O.matches;let L=0;j.sort((C,H)=>C.startOffset-H.startOffset);const S=document.createElement("span"),T=document.createElement("span");T.classList=e(this,s).classes.highlight??"font-bold";for(const C of j)S.textContent+=N.substring(L,C.startOffset),C.startOffset>0&&N.charAt(C.startOffset-1)==" "&&(T.textContent+=" "),T.textContent+=N.substring(C.startOffset,C.endOffset),L=C.endOffset;const D=document.createTextNode(N.substring(L));S.appendChild(T),S.appendChild(D),w.appendChild(S),f.appendChild(w),r.appendChild(f);const R=document.createElement("div");R.className=e(this,s).classes.li_div_two,r.appendChild(R);const P=document.createElement("p");P.className=e(this,s).classes.li_div_two_p,P.textContent=this._formatDistance(a.placePrediction.distanceMeters,e(this,s).distance_units??"km"),R.appendChild(P);const v=document.createElement("a");v.href="javascript:void(0)",v.tabIndex=n+1,v.className=e(this,s).classes.li_a,v.addEventListener("click",()=>{this._onPlaceSelected(a.placePrediction.toPlace())}),v.appendChild(r),v.appendChild(R);const M=document.createElement("li");return M.id=`option-${n+1}`,M.className=e(this,s).classes.li,M.appendChild(v),M})}async _onPlaceSelected(t){let a=null;try{await t.fetchFields({fields:e(this,I)}),a=t.toJSON(),e(this,K).call(this,a)}catch(n){console.error("Error fetching place details:",n),e(this,A).call(this,n)}finally{this._reset(!0,a)}}_refreshToken(){try{e(this,k).sessionToken=new google.maps.places.AutocompleteSessionToken}catch(t){console.error("Error creating session token:",t),e(this,A).call(this,t)}}setFetchFields(t){this._setFetchFields(t)}getFetchFields(){return e(this,I)}setRequestParams(t){typeof t=="object"&&!Array.isArray(t)&&t!==null&&(t.input&&typeof t.input=="string"&&(e(this,i).value=t.input),h(this,k,{...e(this,q),...t}))}getRequestParams(){return e(this,k)}setOptions(t){if(typeof t=="object"&&!Array.isArray(t)&&t!==null){const a=t.classes||{};if(delete t.classes,h(this,s,{...e(this,$),...t}),e(this,i).placeholder=e(this,s).placeholder,e(this,i).autocomplete=e(this,s).autocomplete,e(this,i).autofocus=e(this,s).autofocus,e(this,i).debounce=e(this,s).debounce,e(this,i).clear_input=e(this,s).clear_input,e(this,i).distance=e(this,s).distance,e(this,i).distance_units=e(this,s).distance_units,e(this,i).label=e(this,s).label,e(this,i).setAttribute("aria-label",e(this,s).label||"Search for places"),e(this,i).setAttribute("aria-autocomplete",e(this,s).aria_autocomplete||"list"),e(this,i).setAttribute("aria-expanded",e(this,s).aria_expanded||"false"),e(this,i).setAttribute("aria-controls",e(this,s).aria_controls||"pacSuggestions"),e(this,i).setAttribute("role",e(this,s).role||"combobox"),e(this,i).setAttribute("aria-required",e(this,s).aria_required||"false"),e(this,i).setAttribute("aria-activedescendant",e(this,s).aria_activedescendant||""),a&&typeof a=="object"&&Object.keys(a).length>0&&(e(this,s).classes={...e(this,F),...a}),e(this,p)&&(e(this,p).className=e(this,s).classes.container),e(this,i)&&(e(this,i).className=e(this,s).classes.input),e(this,c)&&(e(this,c).className=e(this,s).classes.ul),e(this,b)&&(e(this,b).className=e(this,s).classes.kbd_escape),e(this,_)&&(e(this,_).className=e(this,s).classes.kbd_up),e(this,y)&&(e(this,y).className=e(this,s).classes.kbd_down),e(this,E)){const n=e(this,E).querySelector("section");n&&e(this,s).classes.section.split(" ").forEach(r=>r&&n.classList.add(r))}}}getOptions(){return e(this,s)}clear(){this._reset(!0)}destroy(){e(this,i)&&e(this,i).removeEventListener("input",this._debouncedMakeAcRequest),e(this,E)&&e(this,p)&&e(this,E).removeChild(e(this,p).parentElement);for(const t in this)Object.hasOwn(this,t)&&(this[t]=null);console.log("PacAutocomplete instance destroyed.")}}x=new WeakMap,E=new WeakMap,z=new WeakMap,G=new WeakMap,s=new WeakMap,k=new WeakMap,i=new WeakMap,p=new WeakMap,c=new WeakMap,b=new WeakMap,_=new WeakMap,y=new WeakMap,g=new WeakMap,m=new WeakMap,K=new WeakMap,A=new WeakMap,$=new WeakMap,F=new WeakMap,q=new WeakMap,I=new WeakMap,B=new WeakMap,l.PlacesAutocomplete=o,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
11
+ */var p,w,C,z,G,s,L,i,m,c,y,v,x,k,f,K,S,$,I,O,j,B;class o{constructor(t){d(this,w);d(this,C);d(this,z);d(this,G);d(this,s);d(this,L);d(this,i);d(this,m);d(this,c);d(this,y);d(this,v);d(this,x);d(this,k,[]);d(this,f,-1);d(this,K);d(this,S);d(this,$,{autofocus:!1,autocomplete:"off",placeholder:"Start typing your address ...",distance:!0,distance_units:"km",label:"",debounce:100,clear_input:!0});d(this,I,{section:"",container:"relative z-10 transform rounded-xl mt-4",icon_container:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",icon:'<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8" /><path d="m21 21-4.3-4.3" /></svg>',input:"border-1 w-full rounded-md border-0 shadow-sm bg-gray-100 px-4 py-2.5 pl-10 pr-20 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 sm:text-sm",kbd_container:"absolute inset-y-0 right-0 flex py-1.5 pr-1.5",kbd_escape:"inline-flex items-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-8 mr-1",kbd_up:"inline-flex items-center justify-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-6",kbd_down:"inline-flex items-center rounded border border-gray-400 px-1 font-sans text-xs text-gray-500 justify-center w-6",kbd_active:"bg-indigo-500 text-white",ul:"absolute z-50 -mb-2 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm divide-y divide-gray-100",li:"z-50 cursor-default select-none py-2 px-2 lg:px-4 text-gray-900 hover:bg-indigo-500 hover:text-white",li_current:"bg-indigo-500",li_a:"block w-full flex justify-between",li_a_current:"text-white",li_div_container:"flex min-w-0 gap-x-4",li_div_one:"min-w-0 flex-auto",li_div_one_p:"text-sm/6",li_div_two:"shrink-0 flex flex-col items-end min-w-16",li_div_two_p:"mt-1 text-xs/5",highlight:"font-bold"});d(this,O,{input:"",includedRegionCodes:["GB"],language:"en-gb",region:"GB"});d(this,j,["formattedAddress","addressComponents"]);d(this,B,["formattedAddress","addressComponents"]);J(this,"_debouncedMakeAcRequest",this._debounce(async()=>{if(!e(this,i)||!e(this,i).value){this._reset(),e(this,i)&&e(this,i).setAttribute("aria-expanded","false");return}e(this,L).input=e(this,i).value;try{const{suggestions:t}=await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(e(this,L));t&&t.length>0?(e(this,c).replaceChildren(...this._createSuggestionElements(t)),e(this,c).style.display="block",e(this,i).setAttribute("aria-expanded","true")):(this._reset(),e(this,i).setAttribute("aria-expanded","false"))}catch(t){e(this,S).call(this,t),this._reset()}},((p=e(this,s))==null?void 0:p.debounce)??100));if(!t||!t.containerId||!t.googleMapsApiKey)throw new Error("PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).");if(h(this,w,t.containerId),h(this,C,document.getElementById(t.containerId)),!e(this,C))throw new Error(`PacAutocomplete: Container element with ID "${t.containerId}" not found.`);h(this,z,t.googleMapsApiKey),h(this,G,t.googleMapsApiVersion||"weekly"),h(this,s,{...e(this,$),...t.options}),t.options&&t.options.classes?e(this,s).classes={...e(this,I),...t.options.classes}:e(this,s).classes=e(this,I),t.fetchFields&&Array.isArray(t.fetchFields)&&this._setFetchFields(t.fetchFields),h(this,K,t.onResponse||(n=>{console.info("---------Default onResponse not provided---------"),console.info("Selected Place:",JSON.stringify(n,null,2))})),h(this,S,t.onError||(n=>{console.error("---------Default onError not provided---------"),console.error("PAC Error:",n)})),t.requestParams&&Object.keys(t.requestParams).length>0?h(this,L,{...e(this,O),...t.requestParams}):h(this,L,{...e(this,O)}),this._init()}async _init(){try{(typeof google>"u"||!google.maps)&&await this._loadGoogleMapsApi({key:e(this,z),v:e(this,G)}),this._createPACStructure(),await this._initializeAutocomplete()}catch(t){e(this,S).call(this,t)}}_setFetchFields(t){Array.isArray(t)&&t.length>0&&h(this,j,[...new Set([...e(this,B),...t])].filter(n=>n))}_debounce(t,n){let a=null;return function(...u){const b=()=>{a=null,t(...u)};a!==null&&clearTimeout(a),a=setTimeout(b,n??100)}}_formatDistance(t,n){if(typeof t!="number"||!e(this,s).distance)return null;let a,r;return n==="km"?(a=(t/1e3).toFixed(2),r="km"):(a=(t/1609.34).toFixed(2),r="miles"),a=a.replace(/\.00$/,""),`${a} ${r}`}async _loadGoogleMapsApi(t){var n,a,r,u="The Google Maps JavaScript API",b="google",T="importLibrary",P="__ib__",E=document,_=window;_=_[b]||(_[b]={});var g=_.maps||(_.maps={}),F=new Set,D=new URLSearchParams,R=()=>n||(n=new Promise(async(M,A)=>{var q;a=E.createElement("script"),D.set("libraries",[...F].join(","));for(r in t)D.set(r.replace(/[A-Z]/g,N=>"_"+N[0].toLowerCase()),t[r]);D.set("callback",b+".maps."+P),a.src=`https://maps.${b}apis.com/maps/api/js?`+D,g[P]=M,a.onerror=()=>n=A(Error(u+" could not load.")),a.nonce=((q=E.querySelector("script[nonce]"))==null?void 0:q.nonce)||"",E.head.append(a)}));g[T]?console.warn(u+" only loads once. Ignoring:",t):g[T]=(M,...A)=>F.add(M)&&R().then(()=>g[T](M,...A))}_createPACStructure(){const t=document.createElement("section");e(this,s).classes.section.split(" ").forEach(u=>u&&t.classList.add(u)),h(this,m,document.createElement("div")),e(this,m).className=e(this,s).classes.container,e(this,m).setAttribute("id",e(this,w)+"-div"),t.appendChild(e(this,m));const n=document.createElement("div");n.className=e(this,s).classes.icon_container,e(this,m).appendChild(n);const a=document.createElement("div");if(a.innerHTML=e(this,s).classes.icon,n.appendChild(a.firstElementChild),h(this,i,document.createElement("input")),e(this,i).id=e(this,w)+"-input",e(this,i).type="text",e(this,i).name="search",e(this,i).placeholder=e(this,s).placeholder,e(this,i).autocomplete=e(this,s).autocomplete,e(this,i).className=e(this,s).classes.input,e(this,i).setAttribute("role","combobox"),e(this,i).setAttribute("aria-autocomplete","list"),e(this,i).setAttribute("aria-expanded","false"),e(this,i).setAttribute("aria-controls","pacSuggestions"),e(this,s).autofocus&&(e(this,i).autofocus=!0),e(this,s).label){const u=document.createElement("label");u.htmlFor=e(this,w)+"-labelInput",u.textContent=e(this,s).label,e(this,m).appendChild(u)}e(this,m).appendChild(e(this,i));const r=document.createElement("div");r.className=e(this,s).classes.kbd_container,h(this,y,document.createElement("kbd")),e(this,y).className=e(this,s).classes.kbd_escape,e(this,y).textContent="Esc",r.appendChild(e(this,y)),h(this,v,document.createElement("kbd")),e(this,v).className=e(this,s).classes.kbd_up,e(this,v).innerHTML="&#8593;",r.appendChild(e(this,v)),h(this,x,document.createElement("kbd")),e(this,x).className=e(this,s).classes.kbd_down,e(this,x).innerHTML="&#8595;",r.appendChild(e(this,x)),e(this,m).appendChild(r),h(this,c,document.createElement("ul")),e(this,c).id="pacSuggestions",e(this,c).className=e(this,s).classes.ul,e(this,c).style.display="none",e(this,c).setAttribute("role","listbox"),e(this,m).appendChild(e(this,c)),e(this,C).appendChild(t),t.addEventListener("keydown",this._onKeyDown.bind(this))}async _initializeAutocomplete(){try{await google.maps.importLibrary("places"),this._refreshToken(),e(this,i)?(e(this,i).addEventListener("input",this._debouncedMakeAcRequest.bind(this)),e(this,i).addEventListener("blur",()=>{setTimeout(()=>{e(this,c)&&!e(this,c).contains(document.activeElement)&&(e(this,c).style.display="none",e(this,i).setAttribute("aria-expanded","false"))},200)}),e(this,i).addEventListener("focus",()=>{e(this,i).value&&e(this,k).length>0&&(e(this,c).style.display="block",e(this,i).setAttribute("aria-expanded","true"))})):e(this,S).call(this,new Error("Input element not found during initialization."))}catch(t){console.error("Error initializing Google Places Autocomplete:",t),e(this,S).call(this,new Error("Google Maps Places library not available."))}}_reset(t=!1,n=null){h(this,f,-1),e(this,i)&&e(this,s).clear_input==!1&&n&&n.formattedAddress?e(this,i).value=n.formattedAddress:e(this,i)&&(e(this,i).value=""),e(this,i)&&(e(this,i).setAttribute("aria-expanded","false"),e(this,i).blur()),h(this,k,[]),h(this,f,-1),e(this,c)&&(e(this,c).innerHTML="",e(this,c).style.display="none"),t&&this._refreshToken()}_resetLiClasses(){e(this,c)&&Array.from(e(this,c).children).forEach(t=>{e(this,s).classes.li_current.split(" ").forEach(a=>t.classList.remove(a));const n=t.querySelector("a");n&&e(this,s).classes.li_a_current.split(" ").forEach(a=>n.classList.remove(a))})}_onKeyDown(t){if(this._resetLiClasses(),t.key==="Escape"&&(t.preventDefault(),e(this,s).classes.kbd_active.split(" ").forEach(n=>{var a;return(a=e(this,y))==null?void 0:a.classList.add(n)}),setTimeout(()=>e(this,s).classes.kbd_active.split(" ").forEach(n=>{var a;return(a=e(this,y))==null?void 0:a.classList.remove(n)}),300),this._reset(!0)),!(!e(this,k).length||!e(this,c)||e(this,c).style.display==="none"))if(t.key==="ArrowDown"){t.preventDefault(),h(this,f,Math.min(e(this,f)+1,e(this,k).length-1)),e(this,f)<0&&h(this,f,0);const n=e(this,c).children.item(e(this,f));if(n){const a=n.querySelector("a");e(this,s).classes.li_current.split(" ").forEach(r=>n.classList.add(r)),a&&e(this,s).classes.li_a_current.split(" ").forEach(r=>a.classList.add(r)),n.scrollIntoView({block:"nearest"})}e(this,s).classes.kbd_active.split(" ").forEach(a=>{var r;return(r=e(this,x))==null?void 0:r.classList.add(a)}),setTimeout(()=>e(this,s).classes.kbd_active.split(" ").forEach(a=>{var r;return(r=e(this,x))==null?void 0:r.classList.remove(a)}),300)}else if(t.key==="ArrowUp"){t.preventDefault(),h(this,f,Math.max(e(this,f)-1,0));const n=e(this,c).children.item(e(this,f));if(n){const a=n.querySelector("a");e(this,s).classes.li_current.split(" ").forEach(r=>n.classList.add(r)),a&&e(this,s).classes.li_a_current.split(" ").forEach(r=>a.classList.add(r)),n.scrollIntoView({block:"nearest"})}e(this,s).classes.kbd_active.split(" ").forEach(a=>{var r;return(r=e(this,v))==null?void 0:r.classList.add(a)}),setTimeout(()=>e(this,s).classes.kbd_active.split(" ").forEach(a=>{var r;return(r=e(this,v))==null?void 0:r.classList.remove(a)}),300)}else t.key==="Enter"&&(t.preventDefault(),e(this,f)>=0&&e(this,f)<e(this,k).length&&this._onPlaceSelected(e(this,k)[e(this,f)].place))}_createSuggestionElements(t){return h(this,k,[]),t.map((n,a)=>{e(this,k).push({id:a+1,description:n.placePrediction.toString(),place:n.placePrediction.toPlace()});const r=document.createElement("div");r.className=e(this,s).classes.li_div_container;const u=document.createElement("div");u.className=e(this,s).classes.li_div_one,r.appendChild(u);const b=document.createElement("p");b.className=e(this,s).classes.li_div_one_p;const T=n.placePrediction.text,P=T.text,E=T.matches;let _=0;E.sort((N,H)=>N.startOffset-H.startOffset);const g=document.createElement("span"),F=document.createElement("span");F.classList=e(this,s).classes.highlight??"font-bold";for(const N of E)g.textContent+=P.substring(_,N.startOffset),N.startOffset>0&&P.charAt(N.startOffset-1)==" "&&(F.textContent+=" "),F.textContent+=P.substring(N.startOffset,N.endOffset),_=N.endOffset;const D=document.createTextNode(P.substring(_));g.appendChild(F),g.appendChild(D),b.appendChild(g),u.appendChild(b),r.appendChild(u);const R=document.createElement("div");R.className=e(this,s).classes.li_div_two,r.appendChild(R);const M=document.createElement("p");M.className=e(this,s).classes.li_div_two_p,M.textContent=this._formatDistance(n.placePrediction.distanceMeters,e(this,s).distance_units??"km"),R.appendChild(M);const A=document.createElement("a");A.href="javascript:void(0)",A.tabIndex=a+1,A.className=e(this,s).classes.li_a,A.addEventListener("click",()=>{this._onPlaceSelected(n.placePrediction.toPlace())}),A.appendChild(r),A.appendChild(R);const q=document.createElement("li");return q.id=`option-${a+1}`,q.className=e(this,s).classes.li,q.appendChild(A),q})}async _onPlaceSelected(t){let n=null;try{await t.fetchFields({fields:e(this,j)}),n=t.toJSON(),e(this,K).call(this,n)}catch(a){console.error("Error fetching place details:",a),e(this,S).call(this,a)}finally{this._reset(!0,n)}}_refreshToken(){try{e(this,L).sessionToken=new google.maps.places.AutocompleteSessionToken}catch(t){console.error("Error creating session token:",t),e(this,S).call(this,t)}}setFetchFields(t){this._setFetchFields(t)}getFetchFields(){return e(this,j)}setRequestParams(t){typeof t=="object"&&!Array.isArray(t)&&t!==null&&(t.input&&typeof t.input=="string"&&(e(this,i).value=t.input),h(this,L,{...e(this,O),...t}))}getRequestParams(){return e(this,L)}setOptions(t){var n,a,r,u,b,T,P;if(typeof t=="object"&&!Array.isArray(t)&&t!==null){const E=t.classes||{};if(delete t.classes,h(this,s,{...e(this,$),...t}),console.log(e(this,i).className),e(this,i).placeholder=e(this,s).placeholder,e(this,i).autocomplete=e(this,s).autocomplete,e(this,i).autofocus=e(this,s).autofocus,e(this,i).debounce=e(this,s).debounce,e(this,i).clear_input=e(this,s).clear_input,e(this,i).distance=e(this,s).distance,e(this,i).distance_units=e(this,s).distance_units,e(this,i).label=e(this,s).label,e(this,i).setAttribute("aria-label",e(this,s).label||"Search for places"),e(this,i).setAttribute("aria-autocomplete",e(this,s).aria_autocomplete||"list"),e(this,i).setAttribute("aria-expanded",e(this,s).aria_expanded||"false"),e(this,i).setAttribute("aria-controls",e(this,s).aria_controls||"pacSuggestions"),e(this,i).setAttribute("role",e(this,s).role||"combobox"),e(this,i).setAttribute("aria-required",e(this,s).aria_required||"false"),e(this,i).setAttribute("aria-activedescendant",e(this,s).aria_activedescendant||""),E&&typeof E=="object"&&Object.keys(E).length>0&&(e(this,s).classes={...e(this,I),...E}),e(this,m)&&((n=e(this,s).classes)!=null&&n.container)&&(e(this,m).className=e(this,s).classes.container),e(this,i)&&((a=e(this,s).classes)!=null&&a.input)&&(e(this,i).className=e(this,s).classes.input),e(this,c)&&((r=e(this,s).classes)!=null&&r.ul)&&(e(this,c).className=e(this,s).classes.ul),e(this,y)&&((u=e(this,s).classes)!=null&&u.kbd_escape)&&(e(this,y).className=e(this,s).classes.kbd_escape),e(this,v)&&((b=e(this,s).classes)!=null&&b.kbd_up)&&(e(this,v).className=e(this,s).classes.kbd_up),e(this,x)&&((T=e(this,s).classes)!=null&&T.kbd_down)&&(e(this,x).className=e(this,s).classes.kbd_down),e(this,C)){const _=e(this,C).querySelector("section");_&&((P=e(this,s).classes)!=null&&P.section)&&e(this,s).classes.section.split(" ").forEach(g=>g&&_.classList.add(g))}}}getOptions(){return e(this,s)}clear(){this._reset(!0)}destroy(){e(this,i)&&e(this,i).removeEventListener("input",this._debouncedMakeAcRequest),e(this,C)&&e(this,m)&&e(this,C).removeChild(e(this,m).parentElement);for(const t in this)Object.hasOwn(this,t)&&(this[t]=null);console.log("PacAutocomplete instance destroyed.")}}w=new WeakMap,C=new WeakMap,z=new WeakMap,G=new WeakMap,s=new WeakMap,L=new WeakMap,i=new WeakMap,m=new WeakMap,c=new WeakMap,y=new WeakMap,v=new WeakMap,x=new WeakMap,k=new WeakMap,f=new WeakMap,K=new WeakMap,S=new WeakMap,$=new WeakMap,I=new WeakMap,O=new WeakMap,j=new WeakMap,B=new WeakMap,l.PlacesAutocomplete=o,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
12
12
  //# sourceMappingURL=places-autocomplete.umd.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"places-autocomplete.umd.cjs","sources":["../lib/PlacesAutocomplete.js"],"sourcesContent":["/**\n * Initializes a Places Autocomplete widget.\n * This script dynamically loads the Google Maps JavaScript API, creates the UI elements\n * for the autocomplete input and suggestions list, handles user input with debouncing,\n * fetches suggestions, manages keyboard navigation, and calls user-defined callbacks\n * on place selection or error.\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n *\n */\n\n/**\n * PacAutocomplete class\n * This class provides a Places Autocomplete widget.\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: true, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: true, // Clear input button (not implemented in this version).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"\", // Outer section container.\n container: \"relative z-10 transform rounded-xl mt-4\", // Main container div.\n icon_container:\n \"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"w-5 h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input:\n \"border-1 w-full rounded-md border-0 shadow-sm bg-gray-100 px-4 py-2.5 pl-10 pr-20 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 sm:text-sm\", // Input field.\n kbd_container: \"absolute inset-y-0 right-0 flex py-1.5 pr-1.5\", // Container for keyboard hints.\n kbd_escape:\n \"inline-flex items-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-8 mr-1\", // Escape key hint.\n kbd_up:\n \"inline-flex items-center justify-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-6\", // Up arrow key hint.\n kbd_down:\n \"inline-flex items-center rounded border border-gray-400 px-1 font-sans text-xs text-gray-500 justify-center w-6\", // Down arrow key hint.\n kbd_active: \"bg-indigo-500 text-white\", // Class for active keyboard hint.\n ul: \"absolute z-50 -mb-2 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm divide-y divide-gray-100\", // Suggestions list (ul).\n li: \"z-50 cursor-default select-none py-2 px-2 lg:px-4 text-gray-900 hover:bg-indigo-500 hover:text-white\", // Suggestion item (li).\n li_current: \"bg-indigo-500\", // Class for the currently selected suggestion item.\n li_a: \"block w-full flex justify-between\", // Link element within a suggestion item.\n li_a_current: \"text-white\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"flex min-w-0 gap-x-4\", // Container div within the suggestion link.\n li_div_one: \"min-w-0 flex-auto\", // First inner div (for place name).\n li_div_one_p: \"text-sm/6\", // Paragraph for the place name.\n li_div_two: \"shrink-0 flex flex-col items-end min-w-16\", // Second inner div (for distance).\n li_div_two_p: \"mt-1 text-xs/5\", // Paragraph for the distance.\n highlight: \"font-bold\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n region: \"GB\",\n };\n #fetchFields = [];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n // console.log(\"PacAutocomplete constructor called.\", config.requestParams);\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\"\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n //console.log(this.#options);\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n //console.log(this.#request);\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure(); // Pass this.#options\n await this._initializeAutocomplete(); // Pass this.#options\n //console.log(\"PacAutocomplete Initialized for container:\", this.#pacEl.id);\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n * The debounced function delays invoking `func` until after `wait` milliseconds have\n * elapsed since the last time the debounced function was invoked.\n * @param {Function} func - The function to debounce.\n * @param {number} wait - The number of milliseconds to delay.\n * @returns {Function} The new debounced function.\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance in meters into kilometers or miles.\n * @param {number | null | undefined} distance - Distance in meters.\n * @param {'km' | 'miles'} units - The desired output units.\n * @returns {string | null} Formatted distance string (e.g., \"1.23 km\") or null if input is invalid.\n */\n _formatDistance(distance, units) {\n if (typeof distance !== \"number\" || !this.#options.distance) {\n return null; // Return null if distance isn't shown or invalid\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k]\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () => (h = n(Error(p + \" could not load.\"))); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#containerId + \"-labelInput\"; // Assuming inputElement gets this ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n this.#container.appendChild(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"&#8593;\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"&#8595;\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#container.appendChild(this.#ul);\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this.#inputElement.addEventListener(\n \"input\",\n this._debouncedMakeAcRequest.bind(this)\n );\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\")\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\")\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"a\");\n if (link) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1\n );\n if (this.#currentSuggestion < 0) this.#currentSuggestion = 0; // Handle case where it was -1\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Debounced function to fetch autocomplete suggestions from the Google Places API.\n * Triggered by the 'input' event on the input element.\n */\n _debouncedMakeAcRequest = this._debounce(async () => {\n if (!this.#inputElement || !this.#inputElement.value) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n this.#request.input = this.#inputElement.value;\n //console.log(\"Request:\", this.#request); // Debugging\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request\n );\n\n // Display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#ul.replaceChildren(\n ...this._createSuggestionElements(suggestions)\n );\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n // Optionally display a \"no results\" message in the 'ul'\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n // if (this.#inputElement)\n // this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, this.#options?.debounce ?? 100);\n\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n return suggestions.map((suggestion, index) => {\n this.#allSuggestions.push({\n id: index + 1,\n description: suggestion.placePrediction.toString(),\n place: suggestion.placePrediction.toPlace(),\n });\n\n // create div elements\n const divContainer = document.createElement(\"div\");\n divContainer.className = this.#options.classes.li_div_container; // flex min-w-0 gap-x-4\n // create inner div element - place name\n const divInner = document.createElement(\"div\");\n divInner.className = this.#options.classes.li_div_one; // min-w-0 flex-auto\n divContainer.appendChild(divInner);\n // create p element - place name\n const p = document.createElement(\"p\");\n p.className = this.#options.classes.li_div_one_p; // text-sm/6\n\n // get prediction text\n const predictionText = suggestion.placePrediction.text;\n const originalText = predictionText.text;\n // Array of objects with startOffset, endOffset\n const matches = predictionText.matches;\n\n //Highlighting Logic\n let lastIndex = 0;\n\n // Sort matches just in case they aren't ordered (though they usually are)\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n // 1. Create the outer span\n const outerSpan = document.createElement(\"span\");\n\n // 2. Create the inner span for the bold part\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\"; // Use the highlight class from options\n\n for (const match of matches) {\n // Append text before the current match\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset\n );\n\n // Append the highlighted match segment\n if (match.startOffset > 0) {\n // check previous charter is space\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar == \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset\n );\n\n // Update the last index processed\n lastIndex = match.endOffset;\n }\n\n // 3. Create a text node for the remaining text\n const remainingText = document.createTextNode(\n originalText.substring(lastIndex)\n );\n\n // 4. Append the inner span and the text node to the outer span\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(remainingText);\n\n // 5. Append the outer span to the paragraph element\n p.appendChild(outerSpan);\n\n divInner.appendChild(p);\n divContainer.appendChild(divInner);\n\n // create inner div element - distance\n const divInner2 = document.createElement(\"div\");\n divInner2.className = this.#options.classes.li_div_two; //'shrink-0 flex flex-col items-end min-w-16';\n divContainer.appendChild(divInner2);\n // create p element - distance\n const p2 = document.createElement(\"p\");\n p2.className = this.#options.classes.li_div_two_p; //'mt-1 text-xs/5 ';\n p2.textContent = this._formatDistance(\n suggestion.placePrediction.distanceMeters,\n this.#options.distance_units ?? \"km\"\n );\n divInner2.appendChild(p2);\n\n // // create a link element\n const a = document.createElement(\"a\");\n a.href = \"javascript:void(0)\";\n a.tabIndex = index + 1;\n a.className = this.#options.classes.li_a; // block w-full flex justify-between\n\n a.addEventListener(\"click\", () => {\n this._onPlaceSelected(suggestion.placePrediction.toPlace());\n });\n\n // ...\n // a.addEventListener(\"click\", () => {\n // this._fetchPlaceDetails(prediction.place_id);\n // });\n a.appendChild(divContainer);\n a.appendChild(divInner2);\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n\n li.appendChild(a);\n return li;\n });\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object\n this.#onDataCallback(data); // Convert to plain JSON object for the callback\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Gets the current request parameters used by the Places Autocomplete instance.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n\n this.#inputElement.placeholder = this.#options.placeholder; // Update placeholder text\n this.#inputElement.autocomplete = this.#options.autocomplete; // Update autocomplete attribute\n this.#inputElement.autofocus = this.#options.autofocus; // Update autofocus attribute\n this.#inputElement.debounce = this.#options.debounce; // Update debounce attribute\n this.#inputElement.clear_input = this.#options.clear_input; // Update clear_input attribute\n this.#inputElement.distance = this.#options.distance; // Update distance attribute\n this.#inputElement.distance_units = this.#options.distance_units; // Update distance units attribute\n this.#inputElement.label = this.#options.label; // Update label text\n\n this.#inputElement.setAttribute(\n \"aria-label\",\n this.#options.label || \"Search for places\"\n ); // Update ARIA label\n this.#inputElement.setAttribute(\n \"aria-autocomplete\",\n this.#options.aria_autocomplete || \"list\"\n ); // Update ARIA autocomplete attribute\n this.#inputElement.setAttribute(\n \"aria-expanded\",\n this.#options.aria_expanded || \"false\"\n ); // Update ARIA expanded attribute\n this.#inputElement.setAttribute(\n \"aria-controls\",\n this.#options.aria_controls || \"pacSuggestions\"\n ); // Update ARIA controls attribute\n this.#inputElement.setAttribute(\"role\", this.#options.role || \"combobox\"); // Update ARIA role attribute\n this.#inputElement.setAttribute(\n \"aria-required\",\n this.#options.aria_required || \"false\"\n ); // Update ARIA required attribute\n this.#inputElement.setAttribute(\n \"aria-activedescendant\",\n this.#options.aria_activedescendant || \"\"\n ); // Update ARIA activedescendant attribute\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n }\n\n // Update the classes of the container and input element\n if (this.#container) {\n this.#container.className = this.#options.classes.container; // Update container class\n }\n if (this.#inputElement) {\n this.#inputElement.className = this.#options.classes.input; // Update input class\n }\n // Update the classes of the suggestions list\n if (this.#ul) {\n this.#ul.className = this.#options.classes.ul; // Update suggestions list class\n }\n // Update the classes of the keyboard hints\n if (this.#kbdEscape) {\n this.#kbdEscape.className = this.#options.classes.kbd_escape; // Update Escape key hint class\n }\n if (this.#kbdUp) {\n this.#kbdUp.className = this.#options.classes.kbd_up; // Update Up arrow key hint class\n }\n if (this.#kbdDown) {\n this.#kbdDown.className = this.#options.classes.kbd_down; // Update Down arrow key hint class\n }\n // Update the classes of the section\n if (this.#pacEl) {\n const section = this.#pacEl.querySelector(\"section\");\n\n if (section) {\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n }\n }\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this._reset(true);\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this._debouncedMakeAcRequest\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n // Nullify properties\n for (const prop in this) {\n if (Object.hasOwn(this, prop)) {\n this[prop] = null;\n }\n }\n console.log(\"PacAutocomplete instance destroyed.\");\n }\n}\n"],"names":["PlacesAutocomplete","config","__privateAdd","_containerId","_pacEl","_googleMapsApiKey","_googleMapsApiVersion","_options","_request","_inputElement","_container","_ul","_kbdEscape","_kbdUp","_kbdDown","_allSuggestions","_currentSuggestion","_onDataCallback","_onErrorCallback","_defaultOptions","_defaultClasses","_defaultRequestParams","_fetchFields","_defaultFetchFields","__publicField","__privateGet","suggestions","error","_a","__privateSet","place","fields","e","func","wait","timeout","args","later","distance","units","value","unitLabel","g","h","a","k","p","c","l","q","m","b","d","r","u","f","n","t","section","cl","iconContainer","icon","label","kbdContainer","refresh","placeData","li","link","currentLi","currentA","suggestion","index","divContainer","divInner","predictionText","originalText","matches","lastIndex","outerSpan","innerSpan","match","remainingText","divInner2","p2","data","params","options","tmpClasses","prop"],"mappings":"qtBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mDAgBO,MAAMA,CAAmB,CA+E9B,YAAYC,EAAQ,CA7EpBC,EAAA,KAAAC,GACAD,EAAA,KAAAE,GACAF,EAAA,KAAAG,GACAH,EAAA,KAAAI,GACAJ,EAAA,KAAAK,GACAL,EAAA,KAAAM,GACAN,EAAA,KAAAO,GACAP,EAAA,KAAAQ,GACAR,EAAA,KAAAS,GACAT,EAAA,KAAAU,GACAV,EAAA,KAAAW,GACAX,EAAA,KAAAY,GACAZ,EAAA,KAAAa,EAAkB,CAAE,GACpBb,EAAA,KAAAc,EAAqB,IACrBd,EAAA,KAAAe,GACAf,EAAA,KAAAgB,GACAhB,EAAA,KAAAiB,EAAkB,CAEhB,UAAW,GACX,aAAc,MACd,YAAa,gCACb,SAAU,GACV,eAAgB,KAChB,MAAO,GACP,SAAU,IACV,YAAa,EACd,GACDjB,EAAA,KAAAkB,EAAkB,CAEhB,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QAAQ,IAGzCkB,EAAA,KAAKb,KACPa,EAAA,KAAKb,GAAW,UAAYa,EAAA,KAAKlB,GAAS,QAAQ,YAEhDkB,EAAA,KAAKZ,KACPY,EAAA,KAAKZ,GAAO,UAAYY,EAAA,KAAKlB,GAAS,QAAQ,QAE5CkB,EAAA,KAAKX,KACPW,EAAA,KAAKX,GAAS,UAAYW,EAAA,KAAKlB,GAAS,QAAQ,UAG9CkB,EAAA,KAAKrB,GAAQ,CACf,MAAMsD,EAAUjC,EAAA,KAAKrB,GAAO,cAAc,SAAS,EAE/CsD,GACFjC,EAAA,KAAKlB,GAAS,QAAQ,QACnB,MAAM,GAAG,EACT,QAASoD,GAAOA,GAAMD,EAAQ,UAAU,IAAIC,CAAE,CAAC,CAE5D,CACA,CACA,CAME,YAAa,CAOX,OAAOlC,EAAA,KAAKlB,EAChB,CASE,OAAQ,CACN,KAAK,OAAO,EAAI,CACpB,CASE,SAAU,CAEJkB,EAAA,KAAKhB,IACPgB,EAAA,KAAKhB,GAAc,oBACjB,QACA,KAAK,uBACN,EAGCgB,EAAA,KAAKrB,IAAUqB,EAAA,KAAKf,IACtBe,EAAA,KAAKrB,GAAO,YAAYqB,EAAA,KAAKf,GAAW,aAAa,EAGvD,UAAW8E,KAAQ,KACb,OAAO,OAAO,KAAMA,CAAI,IAC1B,KAAKA,CAAI,EAAI,MAGjB,QAAQ,IAAI,qCAAqC,CACrD,CACA,CAx+BErF,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YAWAC,EAAA,YA6BAC,EAAA,YAOAC,EAAA,YACAC,EAAA"}
1
+ {"version":3,"file":"places-autocomplete.umd.cjs","sources":["../lib/PlacesAutocomplete.js"],"sourcesContent":["/**\n * Initializes a Places Autocomplete widget.\n * This script dynamically loads the Google Maps JavaScript API, creates the UI elements\n * for the autocomplete input and suggestions list, handles user input with debouncing,\n * fetches suggestions, manages keyboard navigation, and calls user-defined callbacks\n * on place selection or error.\n *\n * @author Alexander Pechkarev <alexpechkarev@gmail.com>\n * @license MIT\n *\n */\n\n/**\n * PacAutocomplete class\n * This class provides a Places Autocomplete widget.\n */\nexport class PlacesAutocomplete {\n // --- Private Properties (using # or _ prefix by convention) ---\n #containerId; // Container ID where the autocomplete widget will be rendered.\n #pacEl;\n #googleMapsApiKey;\n #googleMapsApiVersion;\n #options;\n #request;\n #inputElement;\n #container;\n #ul;\n #kbdEscape;\n #kbdUp;\n #kbdDown;\n #allSuggestions = [];\n #currentSuggestion = -1;\n #onDataCallback; // For user-provided data callback\n #onErrorCallback; // For user-provided error callback\n #defaultOptions = {\n // Default options for the autocomplete widget.\n autofocus: false, // Automatically focus the input on load.\n autocomplete: \"off\", // HTML autocomplete attribute for the input.\n placeholder: \"Start typing your address ...\", // Placeholder text for the input.\n distance: true, // Show distance in suggestions (requires origin in request).\n distance_units: \"km\", // Units for distance ('km' or 'miles').\n label: \"\", // Optional label text above the input.\n debounce: 100, // Debounce delay (ms) for API requests.\n clear_input: true, // Clear input button (not implemented in this version).\n };\n #defaultClasses = {\n // CSS classes for various parts of the widget.\n section: \"\", // Outer section container.\n container: \"relative z-10 transform rounded-xl mt-4\", // Main container div.\n icon_container:\n \"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3\", // Container for the search icon.\n icon: '<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"w-5 h-5\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"11\" cy=\"11\" r=\"8\" /><path d=\"m21 21-4.3-4.3\" /></svg>', // SVG for the search icon.\n input:\n \"border-1 w-full rounded-md border-0 shadow-sm bg-gray-100 px-4 py-2.5 pl-10 pr-20 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 sm:text-sm\", // Input field.\n kbd_container: \"absolute inset-y-0 right-0 flex py-1.5 pr-1.5\", // Container for keyboard hints.\n kbd_escape:\n \"inline-flex items-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-8 mr-1\", // Escape key hint.\n kbd_up:\n \"inline-flex items-center justify-center rounded border border-gray-300 px-1 font-sans text-xs text-gray-500 w-6\", // Up arrow key hint.\n kbd_down:\n \"inline-flex items-center rounded border border-gray-400 px-1 font-sans text-xs text-gray-500 justify-center w-6\", // Down arrow key hint.\n kbd_active: \"bg-indigo-500 text-white\", // Class for active keyboard hint.\n ul: \"absolute z-50 -mb-2 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm divide-y divide-gray-100\", // Suggestions list (ul).\n li: \"z-50 cursor-default select-none py-2 px-2 lg:px-4 text-gray-900 hover:bg-indigo-500 hover:text-white\", // Suggestion item (li).\n li_current: \"bg-indigo-500\", // Class for the currently selected suggestion item.\n li_a: \"block w-full flex justify-between\", // Link element within a suggestion item.\n li_a_current: \"text-white\", // Class for the link in the currently selected suggestion item.\n li_div_container: \"flex min-w-0 gap-x-4\", // Container div within the suggestion link.\n li_div_one: \"min-w-0 flex-auto\", // First inner div (for place name).\n li_div_one_p: \"text-sm/6\", // Paragraph for the place name.\n li_div_two: \"shrink-0 flex flex-col items-end min-w-16\", // Second inner div (for distance).\n li_div_two_p: \"mt-1 text-xs/5\", // Paragraph for the distance.\n highlight: \"font-bold\", // Class for highlighting matched text in suggestions.\n };\n #defaultRequestParams = {\n // Default parameters for the autocomplete request.\n input: \"\", // Initial input value (empty).\n includedRegionCodes: [\"GB\"], // Default region codes to include in suggestions.\n language: \"en-gb\",\n region: \"GB\",\n };\n #fetchFields = [\"formattedAddress\", \"addressComponents\"];\n #defaultFetchFields = [\"formattedAddress\", \"addressComponents\"]; // Fields to fetch for the selected place (can be extended).\n\n /**\n * Class constructor for PacAutocomplete.\n * Initializes the autocomplete widget with the provided configuration.\n * @param {Object} config - Configuration object for the autocomplete widget.\n * @param {string} config.containerId - ID of the container element for the widget.\n * @param {string} config.googleMapsApiKey - Google Maps API key.\n * @param {string} [config.googleMapsApiVersion] - Version of the Google Maps API to use (default: \"weekly\").\n * @param {Object} [config.options] - Additional options for the widget (e.g., classes, callbacks).\n * @param {Object} [config.requestParams] - Parameters for the autocomplete request (e.g., input, region).\n * @param {*} config\n */\n constructor(config) {\n // console.log(\"PacAutocomplete constructor called.\", config.requestParams);\n if (!config || !config.containerId || !config.googleMapsApiKey) {\n throw new Error(\n \"PacAutocomplete: Missing required configuration (containerId, googleMapsApiKey).\"\n );\n }\n\n this.#containerId = config.containerId; // Store the configuration object\n this.#pacEl = document.getElementById(config.containerId);\n if (!this.#pacEl) {\n throw new Error(\n `PacAutocomplete: Container element with ID \"${config.containerId}\" not found.`\n );\n }\n\n this.#googleMapsApiKey = config.googleMapsApiKey;\n this.#googleMapsApiVersion = config.googleMapsApiVersion || \"weekly\";\n\n // Merge user options with defaults\n this.#options = {\n ...this.#defaultOptions, // Default options\n ...config.options, // User-defined options override defaults\n };\n // Ensure classes are deeply merged if user provides partial classes\n if (config.options && config.options.classes) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...config.options.classes,\n };\n } else {\n this.#options.classes = this.#defaultClasses; // Use default classes if none provided\n }\n //console.log(this.#options);\n\n if (config.fetchFields && Array.isArray(config.fetchFields)) {\n this._setFetchFields(config.fetchFields); // Set fetch fields from user config\n }\n\n // Set default response and error callbacks if not provided\n this.#onDataCallback =\n config.onResponse ||\n ((place) => {\n console.info(\"---------Default onResponse not provided---------\");\n console.info(\"Selected Place:\", JSON.stringify(place, null, 2));\n });\n this.#onErrorCallback =\n config.onError ||\n ((error) => {\n console.error(\"---------Default onError not provided---------\");\n console.error(\"PAC Error:\", error);\n });\n\n if (config.requestParams && Object.keys(config.requestParams).length > 0) {\n this.#request = {\n ...this.#defaultRequestParams,\n ...config.requestParams,\n };\n } else {\n this.#request = { ...this.#defaultRequestParams }; // Use defaults if no requestParams provided\n }\n\n //console.log(this.#request);\n\n this._init(); // Underscore prefix for internal initialization method\n }\n\n // --- Private Initialization Method ---\n async _init() {\n try {\n // check if google maps api is already loaded\n if (typeof google === \"undefined\" || !google.maps) {\n // Load the Google Maps API dynamically\n await this._loadGoogleMapsApi({\n key: this.#googleMapsApiKey,\n v: this.#googleMapsApiVersion,\n });\n }\n this._createPACStructure(); // Pass this.#options\n await this._initializeAutocomplete(); // Pass this.#options\n //console.log(\"PacAutocomplete Initialized for container:\", this.#pacEl.id);\n } catch (error) {\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to fetch for the selected place.\n * @param {Array<string>} fields - The fields to fetch.\n */\n _setFetchFields(fields) {\n if (Array.isArray(fields) && fields.length > 0) {\n this.#fetchFields = [\n ...new Set([...this.#defaultFetchFields, ...fields]),\n ].filter((e) => e); // Ensure unique and non-empty fields\n }\n }\n\n /**\n * Creates a debounced version of a function.\n * The debounced function delays invoking `func` until after `wait` milliseconds have\n * elapsed since the last time the debounced function was invoked.\n * @param {Function} func - The function to debounce.\n * @param {number} wait - The number of milliseconds to delay.\n * @returns {Function} The new debounced function.\n */\n _debounce(func, wait) {\n let timeout = null;\n return function executedFunction(...args) {\n const later = () => {\n timeout = null;\n func(...args); // Call original function\n };\n if (timeout !== null) {\n clearTimeout(timeout); // Clear the previous timeout\n }\n timeout = setTimeout(later, wait ?? 100); // Set the new timeout\n };\n }\n /**\n * Formats a distance in meters into kilometers or miles.\n * @param {number | null | undefined} distance - Distance in meters.\n * @param {'km' | 'miles'} units - The desired output units.\n * @returns {string | null} Formatted distance string (e.g., \"1.23 km\") or null if input is invalid.\n */\n _formatDistance(distance, units) {\n if (typeof distance !== \"number\" || !this.#options.distance) {\n return null; // Return null if distance isn't shown or invalid\n }\n let value;\n let unitLabel;\n if (units === \"km\") {\n value = (distance / 1000).toFixed(2);\n unitLabel = \"km\";\n } else {\n // Default to miles if not 'km'\n value = (distance / 1609.34).toFixed(2);\n unitLabel = \"miles\";\n }\n // Avoid showing \".00\"\n value = value.replace(/\\.00$/, \"\");\n return `${value} ${unitLabel}`;\n }\n\n /**\n * Dynamically loads the Google Maps JavaScript API using the importLibrary method.\n * This is the standard approach recommended by Google.\n * @see https://developers.google.com/maps/documentation/javascript/load-maps-js-api\n * @param {object} g - Configuration object for the API loader (key, v, libraries, etc.).\n */\n async _loadGoogleMapsApi(g) {\n var h, // Promise tracking API load\n a, // Script element\n k, // Loop variable for config keys\n p = \"The Google Maps JavaScript API\", // Error message prefix\n c = \"google\", // Global namespace\n l = \"importLibrary\", // Loader function name\n q = \"__ib__\", // Internal callback name\n m = document, // Document reference\n b = window; // Window reference\n b = b[c] || (b[c] = {}); // Ensure google namespace exists\n var d = b.maps || (b.maps = {}), // Ensure google.maps namespace exists\n r = new Set(), // Set to track requested libraries\n e = new URLSearchParams(), // URL parameters for the API script\n u = () =>\n // Function to initiate API loading (if not already started)\n h ||\n // eslint-disable-next-line no-async-promise-executor\n (h = new Promise(async (f, n) => {\n // Create script element (done async to potentially wait for nonce)\n // await (a = m.createElement('script')); // Original Google code had await here, might not be needed\n a = m.createElement(\"script\"); // Create script tag\n e.set(\"libraries\", [...r].join(\",\")); // Add accumulated libraries\n // Add other parameters from the config object 'g'\n for (k in g)\n e.set(\n k.replace(/[A-Z]/g, (t) => \"_\" + t[0].toLowerCase()), // Convert camelCase to snake_case\n g[k]\n );\n e.set(\"callback\", c + \".maps.\" + q); // Set the internal callback function name\n a.src = `https://maps.${c}apis.com/maps/api/js?` + e; // Construct the API URL\n d[q] = f; // Assign the promise resolver to the callback name on google.maps\n // Error handling for script loading failure\n a.onerror = () => (h = n(Error(p + \" could not load.\"))); // Use onerror for load failures\n // Nonce for Content Security Policy\n a.nonce = m.querySelector(\"script[nonce]\")?.nonce || \"\";\n m.head.append(a); // Append the script to the document head\n }));\n // Define or reuse the importLibrary function on google.maps\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n d[l]\n ? console.warn(p + \" only loads once. Ignoring:\", g) // Warn if called again\n : (d[l] = (f, ...n) => r.add(f) && u().then(() => d[l](f, ...n))); // The actual importLibrary implementation\n }\n\n // --- UI Creation ---\n _createPACStructure() {\n const section = document.createElement(\"section\");\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n\n // Main container\n this.#container = document.createElement(\"div\");\n this.#container.className = this.#options.classes.container;\n this.#container.setAttribute(\"id\", this.#containerId + \"-div\");\n section.appendChild(this.#container);\n\n // Icon\n const iconContainer = document.createElement(\"div\");\n iconContainer.className = this.#options.classes.icon_container;\n this.#container.appendChild(iconContainer);\n const icon = document.createElement(\"div\");\n icon.innerHTML = this.#options.classes.icon;\n iconContainer.appendChild(icon.firstElementChild); // Append the actual SVG element\n\n // Input field\n this.#inputElement = document.createElement(\"input\");\n this.#inputElement.id = this.#containerId + \"-input\"; // Assign ID for label association\n this.#inputElement.type = \"text\";\n this.#inputElement.name = \"search\"; // Consider making name configurable\n this.#inputElement.placeholder = this.#options.placeholder;\n this.#inputElement.autocomplete = this.#options.autocomplete;\n this.#inputElement.className = this.#options.classes.input;\n this.#inputElement.setAttribute(\"role\", \"combobox\");\n this.#inputElement.setAttribute(\"aria-autocomplete\", \"list\");\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\"); // Will be updated dynamically\n this.#inputElement.setAttribute(\"aria-controls\", \"pacSuggestions\"); // Links to the suggestions list\n\n if (this.#options.autofocus) {\n this.#inputElement.autofocus = true;\n }\n if (this.#options.label) {\n const label = document.createElement(\"label\");\n label.htmlFor = this.#containerId + \"-labelInput\"; // Assuming inputElement gets this ID\n label.textContent = this.#options.label;\n // Add label classes if needed from opts.classes\n this.#container.appendChild(label); // Append label before input or adjust structure\n }\n this.#container.appendChild(this.#inputElement);\n\n // Keyboard hints container\n const kbdContainer = document.createElement(\"div\");\n kbdContainer.className = this.#options.classes.kbd_container;\n this.#kbdEscape = document.createElement(\"kbd\");\n this.#kbdEscape.className = this.#options.classes.kbd_escape;\n this.#kbdEscape.textContent = \"Esc\";\n kbdContainer.appendChild(this.#kbdEscape);\n this.#kbdUp = document.createElement(\"kbd\");\n this.#kbdUp.className = this.#options.classes.kbd_up;\n this.#kbdUp.innerHTML = \"&#8593;\"; // Up arrow HTML entity\n kbdContainer.appendChild(this.#kbdUp);\n this.#kbdDown = document.createElement(\"kbd\");\n this.#kbdDown.className = this.#options.classes.kbd_down;\n this.#kbdDown.innerHTML = \"&#8595;\"; // Down arrow HTML entity\n kbdContainer.appendChild(this.#kbdDown);\n this.#container.appendChild(kbdContainer);\n\n // Suggestions list (initially hidden)\n this.#ul = document.createElement(\"ul\");\n this.#ul.id = \"pacSuggestions\"; // Must match aria-controls\n this.#ul.className = this.#options.classes.ul;\n this.#ul.style.display = \"none\";\n this.#ul.setAttribute(\"role\", \"listbox\");\n this.#container.appendChild(this.#ul);\n\n this.#pacEl.appendChild(section);\n section.addEventListener(\"keydown\", this._onKeyDown.bind(this)); // Bind 'this'\n }\n\n /**\n * Initializes the core autocomplete functionality after the API is loaded.\n * Imports necessary libraries and sets up the input event listener.\n */\n async _initializeAutocomplete() {\n try {\n // Ensure the 'places' library is available via the dynamic loader\n // eslint-disable-next-line no-undef\n await google.maps.importLibrary(\"places\");\n // console.log('Places library imported successfully.'); // For debugging\n\n // Initial token generation\n this._refreshToken();\n\n // Attach the debounced request function to the input element's 'input' event\n if (this.#inputElement) {\n this.#inputElement.addEventListener(\n \"input\",\n this._debouncedMakeAcRequest.bind(this)\n );\n // Add focus/blur listeners if needed to manage suggestion visibility\n this.#inputElement.addEventListener(\"blur\", () => {\n // Delay hiding suggestions to allow click events on them\n setTimeout(() => {\n if (this.#ul && !this.#ul.contains(document.activeElement)) {\n // Check if focus moved outside suggestions\n this.#ul.style.display = \"none\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, 200); // Adjust delay as needed\n });\n this.#inputElement.addEventListener(\"focus\", () => {\n // Potentially show suggestions again if input has value\n if (this.#inputElement.value && this.#allSuggestions.length > 0) {\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n }\n });\n } else {\n this.#onErrorCallback(\n new Error(\"Input element not found during initialization.\")\n );\n }\n } catch (error) {\n console.error(\"Error initializing Google Places Autocomplete:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(\n new Error(\"Google Maps Places library not available.\")\n );\n }\n }\n\n /**\n * Resets the autocomplete input field, clears suggestions, and optionally refreshes the session token.\n * @param {boolean} [refresh=false] - Whether to refresh the Google Places session token.\n */\n _reset(refresh = false, placeData = null) {\n this.#currentSuggestion = -1;\n\n /**\n * If the input element exists and clear_input is false, set its value to the formatted address\n * from placeData. Otherwise, clear the input value.\n * This allows the user to keep the input value if they selected a place,\n * but still allows clearing it if clear_input is true or placeData is not provided.\n * @type {HTMLInputElement}\n * @property {string} value - The value of the input element.\n * @property {boolean} clear_input - Whether to clear the input value after selection.\n * @property {Object} placeData - The data of the selected place, containing formattedAddress.\n */\n if (\n this.#inputElement &&\n this.#options.clear_input == false &&\n placeData &&\n placeData.formattedAddress\n ) {\n this.#inputElement.value = placeData.formattedAddress; // Set input value to formatted address\n } else if (this.#inputElement) {\n this.#inputElement.value = \"\";\n }\n\n if (this.#inputElement) {\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n this.#inputElement.blur();\n }\n\n this.#allSuggestions = [];\n this.#currentSuggestion = -1;\n if (this.#ul) {\n this.#ul.innerHTML = \"\"; // Clear existing suggestions\n this.#ul.style.display = \"none\";\n }\n if (refresh) {\n this._refreshToken();\n }\n }\n /**\n * Removes the 'current' highlighting classes from all suggestion list items (li) and their links (a).\n */\n _resetLiClasses() {\n if (!this.#ul) return;\n Array.from(this.#ul.children).forEach((li) => {\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => li.classList.remove(cl));\n const link = li.querySelector(\"a\");\n if (link) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => link.classList.remove(cl));\n }\n });\n }\n\n /**\n * Handles keyboard events (ArrowDown, ArrowUp, Enter, Escape) for navigating\n * and selecting suggestions or closing the list.\n * @param {KeyboardEvent} e - The keyboard event object.\n */\n _onKeyDown(e) {\n this._resetLiClasses(); // Reset classes on any key press within the suggestions\n\n if (e.key === \"Escape\") {\n e.preventDefault();\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdEscape?.classList.remove(cl)),\n 300\n );\n\n this._reset(true); // Reset search input and results, refresh token\n }\n\n if (\n !this.#allSuggestions.length ||\n !this.#ul ||\n this.#ul.style.display === \"none\"\n )\n return;\n\n if (e.key === \"ArrowDown\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.min(\n this.#currentSuggestion + 1,\n this.#allSuggestions.length - 1\n );\n if (this.#currentSuggestion < 0) this.#currentSuggestion = 0; // Handle case where it was -1\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdDown?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault(); // Prevent cursor movement in input\n this.#currentSuggestion = Math.max(this.#currentSuggestion - 1, 0); // Stay at 0 if already there\n\n const currentLi = this.#ul.children.item(this.#currentSuggestion);\n if (currentLi) {\n const currentA = currentLi.querySelector(\"a\");\n this.#options.classes.li_current\n .split(\" \")\n .forEach((cl) => currentLi.classList.add(cl));\n if (currentA) {\n this.#options.classes.li_a_current\n .split(\" \")\n .forEach((cl) => currentA.classList.add(cl));\n }\n currentLi.scrollIntoView({ block: \"nearest\" }); // Ensure visible\n }\n\n // Visual feedback for key press\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.add(cl));\n setTimeout(\n () =>\n this.#options.classes.kbd_active\n .split(\" \")\n .forEach((cl) => this.#kbdUp?.classList.remove(cl)),\n 300\n );\n } else if (e.key === \"Enter\") {\n e.preventDefault(); // Prevent form submission if applicable\n if (\n this.#currentSuggestion >= 0 &&\n this.#currentSuggestion < this.#allSuggestions.length\n ) {\n this._onPlaceSelected(\n this.#allSuggestions[this.#currentSuggestion].place\n );\n // Reset is handled within onPlaceSelected via reset(true)\n }\n }\n }\n\n /**\n * Debounced function to fetch autocomplete suggestions from the Google Places API.\n * Triggered by the 'input' event on the input element.\n */\n _debouncedMakeAcRequest = this._debounce(async () => {\n if (!this.#inputElement || !this.#inputElement.value) {\n this._reset();\n if (this.#inputElement)\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n return;\n }\n\n this.#request.input = this.#inputElement.value;\n //console.log(\"Request:\", this.#request); // Debugging\n try {\n const { suggestions } =\n // eslint-disable-next-line no-undef\n await google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(\n this.#request\n );\n\n // Display suggestions\n if (suggestions && suggestions.length > 0) {\n this.#ul.replaceChildren(\n ...this._createSuggestionElements(suggestions)\n );\n this.#ul.style.display = \"block\";\n this.#inputElement.setAttribute(\"aria-expanded\", \"true\");\n } else {\n // No suggestions found\n this._reset(); // Clear any old suggestions\n this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n // Optionally display a \"no results\" message in the 'ul'\n }\n } catch (error) {\n this.#onErrorCallback(error);\n this._reset();\n // if (this.#inputElement)\n // this.#inputElement.setAttribute(\"aria-expanded\", \"false\");\n }\n }, this.#options?.debounce ?? 100);\n\n /**\n * Creates an array of list item (LI) elements for the suggestions dropdown.\n * Each LI contains a link (A) with the place prediction details and distance.\n * Handles highlighting the matched parts of the suggestion text.\n * @param {Array<google.maps.places.AutocompleteSuggestion>} suggestions - Array of suggestion objects from the API.\n * @returns {Array<HTMLLIElement>} An array of LI elements to be added to the suggestions UL.\n */\n _createSuggestionElements(suggestions) {\n this.#allSuggestions = []; // Reset before populating\n return suggestions.map((suggestion, index) => {\n this.#allSuggestions.push({\n id: index + 1,\n description: suggestion.placePrediction.toString(),\n place: suggestion.placePrediction.toPlace(),\n });\n\n // create div elements\n const divContainer = document.createElement(\"div\");\n divContainer.className = this.#options.classes.li_div_container; // flex min-w-0 gap-x-4\n // create inner div element - place name\n const divInner = document.createElement(\"div\");\n divInner.className = this.#options.classes.li_div_one; // min-w-0 flex-auto\n divContainer.appendChild(divInner);\n // create p element - place name\n const p = document.createElement(\"p\");\n p.className = this.#options.classes.li_div_one_p; // text-sm/6\n\n // get prediction text\n const predictionText = suggestion.placePrediction.text;\n const originalText = predictionText.text;\n // Array of objects with startOffset, endOffset\n const matches = predictionText.matches;\n\n //Highlighting Logic\n let lastIndex = 0;\n\n // Sort matches just in case they aren't ordered (though they usually are)\n matches.sort((a, b) => a.startOffset - b.startOffset);\n\n // 1. Create the outer span\n const outerSpan = document.createElement(\"span\");\n\n // 2. Create the inner span for the bold part\n const innerSpan = document.createElement(\"span\");\n innerSpan.classList = this.#options.classes.highlight ?? \"font-bold\"; // Use the highlight class from options\n\n for (const match of matches) {\n // Append text before the current match\n outerSpan.textContent += originalText.substring(\n lastIndex,\n match.startOffset\n );\n\n // Append the highlighted match segment\n if (match.startOffset > 0) {\n // check previous charter is space\n const prevChar = originalText.charAt(match.startOffset - 1);\n if (prevChar == \" \") {\n innerSpan.textContent += \" \";\n }\n }\n innerSpan.textContent += originalText.substring(\n match.startOffset,\n match.endOffset\n );\n\n // Update the last index processed\n lastIndex = match.endOffset;\n }\n\n // 3. Create a text node for the remaining text\n const remainingText = document.createTextNode(\n originalText.substring(lastIndex)\n );\n\n // 4. Append the inner span and the text node to the outer span\n outerSpan.appendChild(innerSpan);\n outerSpan.appendChild(remainingText);\n\n // 5. Append the outer span to the paragraph element\n p.appendChild(outerSpan);\n\n divInner.appendChild(p);\n divContainer.appendChild(divInner);\n\n // create inner div element - distance\n const divInner2 = document.createElement(\"div\");\n divInner2.className = this.#options.classes.li_div_two; //'shrink-0 flex flex-col items-end min-w-16';\n divContainer.appendChild(divInner2);\n // create p element - distance\n const p2 = document.createElement(\"p\");\n p2.className = this.#options.classes.li_div_two_p; //'mt-1 text-xs/5 ';\n p2.textContent = this._formatDistance(\n suggestion.placePrediction.distanceMeters,\n this.#options.distance_units ?? \"km\"\n );\n divInner2.appendChild(p2);\n\n // // create a link element\n const a = document.createElement(\"a\");\n a.href = \"javascript:void(0)\";\n a.tabIndex = index + 1;\n a.className = this.#options.classes.li_a; // block w-full flex justify-between\n\n a.addEventListener(\"click\", () => {\n this._onPlaceSelected(suggestion.placePrediction.toPlace());\n });\n\n // ...\n // a.addEventListener(\"click\", () => {\n // this._fetchPlaceDetails(prediction.place_id);\n // });\n a.appendChild(divContainer);\n a.appendChild(divInner2);\n\n const li = document.createElement(\"li\");\n li.id = `option-${index + 1}`;\n li.className = this.#options.classes.li;\n\n li.appendChild(a);\n return li;\n });\n }\n\n /**\n * Handles the selection of a place. Fetches required fields\n * (displayName, formattedAddress, addressComponents) and calls the\n * user-defined `onPacData` callback.\n * @param {google.maps.places.Place} place - The selected Place object.\n */\n async _onPlaceSelected(place) {\n let data = null;\n try {\n // Fetch necessary details for the selected place\n await place.fetchFields({\n fields: this.#fetchFields, //[\"displayName\", \"formattedAddress\", \"addressComponents\"], // Add more fields as needed\n });\n // Call the user-provided callback with the place data\n // eslint-disable-next-line no-undef\n data = place.toJSON(); // Convert to plain JSON object\n this.#onDataCallback(data); // Convert to plain JSON object for the callback\n } catch (error) {\n console.error(\"Error fetching place details:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n } finally {\n // Reset the input and suggestions regardless of success/error\n this._reset(true, data); // Refresh token after selection\n }\n }\n\n /**\n * Creates a new Google Places Autocomplete Session Token.\n * This should be called before starting a new series of autocomplete requests.\n */\n _refreshToken() {\n try {\n // eslint-disable-next-line no-undef\n this.#request.sessionToken =\n new google.maps.places.AutocompleteSessionToken();\n } catch (error) {\n console.error(\"Error creating session token:\", error);\n // eslint-disable-next-line no-undef\n this.#onErrorCallback(error);\n }\n }\n\n /**\n * Sets the fields to be fetched for the selected place.\n * This allows you to specify which details you want to retrieve\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @param {Array<string>} fields - Array of field names to fetch.\n */\n setFetchFields(fields) {\n this._setFetchFields(fields);\n }\n /**\n * Gets the current fields that will be fetched for the selected place.\n * This is useful for understanding what details will be available\n * when a place is selected, such as displayName, formattedAddress,\n * addressComponents, etc.\n * @returns {Array<string>} The current fetch fields.\n */\n getFetchFields() {\n return this.#fetchFields;\n }\n\n /**\n * Sets the request parameters for the Places Autocomplete instance.\n * This method allows you to update the request parameters dynamically,\n * such as the input value, region codes, language, etc.\n * It merges the provided parameters with the default request parameters,\n * allowing you to override specific values while keeping the defaults intact.\n * This is useful for updating the search criteria without needing to recreate the instance.\n * @param {*} params\n */\n setRequestParams(params) {\n if (\n typeof params === \"object\" &&\n !Array.isArray(params) &&\n params !== null\n ) {\n // if params.input is provided, set it to the input element\n if (params.input && typeof params.input === \"string\") {\n this.#inputElement.value = params.input; // Set input value if provided\n }\n // Merge provided params with default request parameters\n // This allows overriding specific request parameters while keeping defaults\n this.#request = {\n ...this.#defaultRequestParams,\n ...params,\n };\n }\n }\n\n /**\n * Gets the current request parameters used by the Places Autocomplete instance.\n * @returns {Object} The current request parameters.\n */\n getRequestParams() {\n /**\n * Returns the current request parameters used by the Places Autocomplete instance.\n * This includes the input value, included region codes, language, and other settings.\n * It is useful for debugging or when you need to know the current search criteria.\n * @returns {Object} The current request parameters.\n */\n return this.#request;\n }\n\n /**\n * Sets the options for the Places Autocomplete instance.\n * This method allows you to change the appearance and behavior of the autocomplete widget,\n * such as classes, placeholder text, debounce time, etc.\n * It merges the provided options with the default options, allowing you to override specific values\n * while keeping the defaults intact.\n * This is useful for updating the widget's configuration without needing to recreate the instance.\n * @param {*} options\n */\n setOptions(options) {\n if (\n typeof options === \"object\" &&\n !Array.isArray(options) &&\n options !== null\n ) {\n // Ensure classes are deeply merged if user provides partial classes\n const tmpClasses = options.classes || {};\n delete options.classes; // Remove classes from options to avoid overwriting\n\n // Merge provided options with default options\n // This allows overriding specific options while keeping defaults\n this.#options = {\n ...this.#defaultOptions,\n ...options,\n };\n console.log(this.#inputElement.className);\n\n this.#inputElement.placeholder = this.#options.placeholder; // Update placeholder text\n this.#inputElement.autocomplete = this.#options.autocomplete; // Update autocomplete attribute\n this.#inputElement.autofocus = this.#options.autofocus; // Update autofocus attribute\n this.#inputElement.debounce = this.#options.debounce; // Update debounce attribute\n this.#inputElement.clear_input = this.#options.clear_input; // Update clear_input attribute\n this.#inputElement.distance = this.#options.distance; // Update distance attribute\n this.#inputElement.distance_units = this.#options.distance_units; // Update distance units attribute\n this.#inputElement.label = this.#options.label; // Update label text\n\n this.#inputElement.setAttribute(\n \"aria-label\",\n this.#options.label || \"Search for places\"\n ); // Update ARIA label\n this.#inputElement.setAttribute(\n \"aria-autocomplete\",\n this.#options.aria_autocomplete || \"list\"\n ); // Update ARIA autocomplete attribute\n this.#inputElement.setAttribute(\n \"aria-expanded\",\n this.#options.aria_expanded || \"false\"\n ); // Update ARIA expanded attribute\n this.#inputElement.setAttribute(\n \"aria-controls\",\n this.#options.aria_controls || \"pacSuggestions\"\n ); // Update ARIA controls attribute\n this.#inputElement.setAttribute(\"role\", this.#options.role || \"combobox\"); // Update ARIA role attribute\n this.#inputElement.setAttribute(\n \"aria-required\",\n this.#options.aria_required || \"false\"\n ); // Update ARIA required attribute\n this.#inputElement.setAttribute(\n \"aria-activedescendant\",\n this.#options.aria_activedescendant || \"\"\n ); // Update ARIA activedescendant attribute\n\n // Merge classes with defaults\n // This allows overriding specific classes while keeping defaults\n if (\n tmpClasses &&\n typeof tmpClasses === \"object\" &&\n Object.keys(tmpClasses).length > 0\n ) {\n this.#options.classes = {\n ...this.#defaultClasses,\n ...tmpClasses,\n };\n }\n\n // Update the classes of the container and input element\n if (this.#container && this.#options.classes?.container) {\n this.#container.className = this.#options.classes.container; // Update container class\n }\n if (this.#inputElement && this.#options.classes?.input) {\n this.#inputElement.className = this.#options.classes.input; // Update input class\n }\n // Update the classes of the suggestions list\n if (this.#ul && this.#options.classes?.ul) {\n this.#ul.className = this.#options.classes.ul; // Update suggestions list class\n }\n // Update the classes of the keyboard hints\n if (this.#kbdEscape && this.#options.classes?.kbd_escape) {\n this.#kbdEscape.className = this.#options.classes.kbd_escape; // Update Escape key hint class\n }\n if (this.#kbdUp && this.#options.classes?.kbd_up) {\n this.#kbdUp.className = this.#options.classes.kbd_up; // Update Up arrow key hint class\n }\n if (this.#kbdDown && this.#options.classes?.kbd_down) {\n this.#kbdDown.className = this.#options.classes.kbd_down; // Update Down arrow key hint class\n }\n // Update the classes of the section\n if (this.#pacEl) {\n const section = this.#pacEl.querySelector(\"section\");\n\n if (section && this.#options.classes?.section) {\n this.#options.classes.section\n .split(\" \")\n .forEach((cl) => cl && section.classList.add(cl));\n }\n }\n }\n }\n\n /**\n * Gets the current options used by the Places Autocomplete instance.\n * @returns {Object} The current options.\n */\n getOptions() {\n /**\n * Returns the current options used by the Places Autocomplete instance.\n * This includes classes, placeholder text, debounce time, and other settings.\n * It is useful for debugging or when you need to know the current configuration of the widget.\n * @returns {Object} The current options.\n */\n return this.#options;\n }\n\n /**\n * Clears the autocomplete input field and suggestions list.\n * This method resets the state of the autocomplete widget,\n * allowing the user to start a new search without any previous input or suggestions.\n * It also refreshes the Google Places session token to ensure a new session.\n * @returns {void}\n */\n clear() {\n this._reset(true);\n }\n\n /**\n * Destroys the PacAutocomplete instance.\n * Removes event listeners, clears the DOM, and nullifies properties.\n * This method should be called when the autocomplete widget is no longer needed.\n * It ensures that all resources are cleaned up to prevent memory leaks.\n * @returns {void}\n */\n destroy() {\n // Remove event listeners, remove elements from DOM\n if (this.#inputElement) {\n this.#inputElement.removeEventListener(\n \"input\",\n this._debouncedMakeAcRequest\n );\n // remove other listeners\n }\n if (this.#pacEl && this.#container) {\n this.#pacEl.removeChild(this.#container.parentElement); // remove the whole section\n }\n // Nullify properties\n for (const prop in this) {\n if (Object.hasOwn(this, prop)) {\n this[prop] = null;\n }\n }\n console.log(\"PacAutocomplete instance destroyed.\");\n }\n}\n"],"names":["PlacesAutocomplete","config","__privateAdd","_containerId","_pacEl","_googleMapsApiKey","_googleMapsApiVersion","_options","_request","_inputElement","_container","_ul","_kbdEscape","_kbdUp","_kbdDown","_allSuggestions","_currentSuggestion","_onDataCallback","_onErrorCallback","_defaultOptions","_defaultClasses","_defaultRequestParams","_fetchFields","_defaultFetchFields","__publicField","__privateGet","suggestions","error","_a","__privateSet","place","fields","e","func","wait","timeout","args","later","distance","units","value","unitLabel","g","h","k","p","c","l","q","m","b","d","r","u","f","n","t","section","cl","iconContainer","icon","label","kbdContainer","refresh","placeData","li","link","currentLi","currentA","suggestion","index","divContainer","divInner","predictionText","originalText","matches","lastIndex","a","outerSpan","innerSpan","match","remainingText","divInner2","p2","data","params","options","tmpClasses","_b","_c","_d","_e","_f","_g","prop"],"mappings":"qtBAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mDAgBO,MAAMA,CAAmB,CA+E9B,YAAYC,EAAQ,CA7EpBC,EAAA,KAAAC,GACAD,EAAA,KAAAE,GACAF,EAAA,KAAAG,GACAH,EAAA,KAAAI,GACAJ,EAAA,KAAAK,GACAL,EAAA,KAAAM,GACAN,EAAA,KAAAO,GACAP,EAAA,K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,EACT,QAASmD,GAAOA,GAAMD,EAAQ,UAAU,IAAIC,CAAE,CAAC,CAE5D,CACA,CACA,CAME,YAAa,CAOX,OAAOjC,EAAA,KAAKlB,EAChB,CASE,OAAQ,CACN,KAAK,OAAO,EAAI,CACpB,CASE,SAAU,CAEJkB,EAAA,KAAKhB,IACPgB,EAAA,KAAKhB,GAAc,oBACjB,QACA,KAAK,uBACN,EAGCgB,EAAA,KAAKrB,IAAUqB,EAAA,KAAKf,IACtBe,EAAA,KAAKrB,GAAO,YAAYqB,EAAA,KAAKf,GAAW,aAAa,EAGvD,UAAWoF,KAAQ,KACb,OAAO,OAAO,KAAMA,CAAI,IAC1B,KAAKA,CAAI,EAAI,MAGjB,QAAQ,IAAI,qCAAqC,CACrD,CACA,CAz+BE3F,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YACAC,EAAA,YAWAC,EAAA,YA6BAC,EAAA,YAOAC,EAAA,YACAC,EAAA"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "places-autocomplete-js",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "1.0.9",
5
+ "version": "1.0.11",
6
6
  "description": "A flexible and customisable vanilla JavaScript library leveraging the Google Maps Places (New) Autocomplete API. This library provides a user-friendly way to search for and retrieve detailed address information in any web application.",
7
7
  "keywords": [
8
8
  "place-autocomplete",