@webority/ui-elements 0.7.5 → 0.7.6

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.
@@ -43,6 +43,7 @@ function c(e, t) {
43
43
  return;
44
44
  }
45
45
  r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute(s, ""), e.appendChild(r)), r.name = n, r.value = t == null ? "" : String(t);
46
+ for (let t of [...r.attributes]) t.name.startsWith("data-val") && !e.hasAttribute(t.name) && r.removeAttribute(t.name);
46
47
  for (let t of e.attributes) t.name.startsWith("data-val") && r.setAttribute(t.name, t.value);
47
48
  r.disabled = e.hasAttribute("disabled");
48
49
  }
@@ -75,7 +76,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
75
76
  ];
76
77
  }
77
78
  constructor() {
78
- super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null;
79
+ super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null, this._reqSeq = 0;
79
80
  try {
80
81
  this._internals = this.attachInternals();
81
82
  } catch {
@@ -211,6 +212,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
211
212
  t.hint && (t.hint.hidden = !(this._remote && s && !i.length)), t.empty && (t.empty.hidden = this._loading || o.length > 0 || this._remote && s);
212
213
  }
213
214
  _wire() {
215
+ this._teardown();
214
216
  let e = this._refs();
215
217
  if (!e.control || !e.input) return;
216
218
  let t = () => i(e.control, e.menu, { matchWidth: !0 }), n = () => this._optionEls().filter((e) => !e.hidden), r = (e) => {
@@ -237,11 +239,15 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
237
239
  e.input.addEventListener("focus", () => s()), e.input.addEventListener("input", () => {
238
240
  let t = e.input.value;
239
241
  if (e.clear && (e.clear.hidden = !t), o() || s(), this._remote) {
240
- if (this._renderOptions(t), t.trim().length < this._minChars) return;
241
- clearTimeout(this._timer), this._timer = setTimeout(() => {
242
+ if (this._renderOptions(t), clearTimeout(this._timer), t.trim().length < this._minChars) return;
243
+ let e = ++this._reqSeq;
244
+ this._timer = setTimeout(() => {
242
245
  this.dispatchEvent(new CustomEvent("search", {
243
246
  bubbles: !0,
244
- detail: { query: t }
247
+ detail: {
248
+ query: t,
249
+ seq: e
250
+ }
245
251
  }));
246
252
  }, this._debounceMs);
247
253
  } else this._renderOptions(t);
@@ -274,10 +280,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
274
280
  o() && t();
275
281
  });
276
282
  }
277
- disconnectedCallback() {
283
+ _teardown() {
278
284
  this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this), clearTimeout(this._timer);
279
285
  }
280
- }, m = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), h = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), g = [
286
+ disconnectedCallback() {
287
+ this._teardown();
288
+ }
289
+ }, m = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), h = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), g = [
281
290
  "January",
282
291
  "February",
283
292
  "March",
@@ -305,17 +314,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
305
314
  m: t[2] - 1,
306
315
  d: +t[3]
307
316
  } : null;
308
- }, x = (e) => {
317
+ }, ee = (e) => {
309
318
  let t = b(e);
310
319
  return t ? `${v(t.d)} ${g[t.m].slice(0, 3)} ${t.y}` : "";
311
- }, S = (e, t) => new Date(e, t + 1, 0).getDate(), C = (e, t) => {
320
+ }, x = (e, t) => new Date(e, t + 1, 0).getDate(), S = (e, t) => {
312
321
  for (; t < 0;) t += 12, --e;
313
322
  for (; t > 11;) t -= 12, e += 1;
314
323
  return {
315
324
  y: e,
316
325
  m: t
317
326
  };
318
- }, w = class extends HTMLElement {
327
+ }, te = class extends HTMLElement {
319
328
  static formAssociated = !0;
320
329
  static get observedAttributes() {
321
330
  return [
@@ -345,7 +354,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
345
354
  this._rendered || this.render();
346
355
  }
347
356
  attributeChangedCallback(e, t, n) {
348
- this._rendered && (e === "value" ? (this._value = n || "", this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
357
+ this._rendered && (e === "value" ? (this._value = n || "", this._syncFormValue(), this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
349
358
  }
350
359
  formResetCallback() {
351
360
  this.value = this._defaultValue || "";
@@ -354,7 +363,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
354
363
  return this._value;
355
364
  }
356
365
  set value(e) {
357
- this._value = e || "", c(this, this._value), this._syncTrigger(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
366
+ this._value = e || "", c(this, this._value), this._syncTrigger();
358
367
  }
359
368
  _firstDay() {
360
369
  let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
@@ -368,7 +377,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
368
377
  this.innerHTML = `
369
378
  <div class="datepicker">
370
379
  <button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${i ? ` aria-label="${u(i)}"` : ""}${a ? ` aria-describedby="${u(a)}"` : ""}>
371
- <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? x(this._value) : u(e)}</span>
380
+ <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? ee(this._value) : u(e)}</span>
372
381
  <i class="bi bi-calendar3" aria-hidden="true"></i>
373
382
  </button>
374
383
  <div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
@@ -381,7 +390,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
381
390
  let e = this.querySelector(".datepicker-trigger"), t = this.querySelector("[data-trigger-label]");
382
391
  if (!t) return;
383
392
  let n = b(this._value);
384
- t.textContent = n ? x(this._value) : this.getAttribute("placeholder") || "Enter Date", t.classList.toggle("search-select-placeholder", !n), e?.classList.toggle("has-value", !!n);
393
+ t.textContent = n ? ee(this._value) : this.getAttribute("placeholder") || "Enter Date", t.classList.toggle("search-select-placeholder", !n), e?.classList.toggle("has-value", !!n);
385
394
  }
386
395
  _limits() {
387
396
  let e = b(this.getAttribute("min")), t = b(this.getAttribute("max")), n = e ? new Date(e.y, e.m, e.d).getTime() : -Infinity, r = t ? new Date(t.y, t.m, t.d).getTime() : Infinity;
@@ -392,7 +401,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
392
401
  },
393
402
  monthDisabled: (e, t) => {
394
403
  let i = new Date(e, t, 1).getTime();
395
- return new Date(e, t, S(e, t)).getTime() < n || i > r;
404
+ return new Date(e, t, x(e, t)).getTime() < n || i > r;
396
405
  },
397
406
  yearDisabled: (e) => {
398
407
  let t = new Date(e, 0, 1).getTime();
@@ -405,7 +414,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
405
414
  e && (this._mode === "months" ? e.innerHTML = this._monthsHtml() : this._mode === "years" ? e.innerHTML = this._yearsHtml() : e.innerHTML = this._daysHtml(), this._focusActive());
406
415
  }
407
416
  _daysHtml() {
408
- let e = this._firstDay(), t = (new Date(this._viewY, this._viewM, 1).getDay() - e + 7) % 7, n = S(this._viewY, this._viewM), r = b(this._value), i = /* @__PURE__ */ new Date(), { dayDisabled: a } = this._limits(), o = this._focus || r || {
417
+ let e = this._firstDay(), t = (new Date(this._viewY, this._viewM, 1).getDay() - e + 7) % 7, n = x(this._viewY, this._viewM), r = b(this._value), i = /* @__PURE__ */ new Date(), { dayDisabled: a } = this._limits(), o = this._focus || r || {
409
418
  y: this._viewY,
410
419
  m: this._viewM,
411
420
  d: 1
@@ -417,10 +426,10 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
417
426
  u ? "is-today" : "",
418
427
  l ? "is-selected" : ""
419
428
  ].filter(Boolean).join(" ")}" data-iso="${c}" role="gridcell" tabindex="${d && !f ? "0" : "-1"}"${l ? " aria-selected=\"true\"" : ""}${f ? " disabled aria-disabled=\"true\"" : ""}>${n}</button>`;
420
- }, c = "", l = C(this._viewY, this._viewM - 1), u = S(l.y, l.m);
429
+ }, c = "", l = S(this._viewY, this._viewM - 1), u = x(l.y, l.m);
421
430
  for (let e = t - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
422
431
  for (let e = 1; e <= n; e++) c += s(this._viewY, this._viewM, e, !1);
423
- let d = C(this._viewY, this._viewM + 1), f = (7 - (t + n) % 7) % 7;
432
+ let d = S(this._viewY, this._viewM + 1), f = (7 - (t + n) % 7) % 7;
424
433
  for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
425
434
  let p = _.map((t, n) => _[(n + e) % 7]).map((e) => `<span>${e}</span>`).join("");
426
435
  return `
@@ -480,7 +489,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
480
489
  i(e, t);
481
490
  }
482
491
  _setFocus(e, t, n, r) {
483
- let { y: i, m: a } = C(e, t);
492
+ let { y: i, m: a } = S(e, t);
484
493
  this._focus = {
485
494
  y: i,
486
495
  m: a,
@@ -512,17 +521,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
512
521
  case "End": return n(6 - (new Date(t.y, t.m, t.d).getDay() - this._firstDay() + 7) % 7, "slide-next");
513
522
  case "PageUp": {
514
523
  e.preventDefault();
515
- let n = C(t.y, t.m - (e.shiftKey ? 12 : 1));
516
- return this._setFocus(n.y, n.m, Math.min(t.d, S(n.y, n.m)), "slide-prev");
524
+ let n = S(t.y, t.m - (e.shiftKey ? 12 : 1));
525
+ return this._setFocus(n.y, n.m, Math.min(t.d, x(n.y, n.m)), "slide-prev");
517
526
  }
518
527
  case "PageDown": {
519
528
  e.preventDefault();
520
- let n = C(t.y, t.m + (e.shiftKey ? 12 : 1));
521
- return this._setFocus(n.y, n.m, Math.min(t.d, S(n.y, n.m)), "slide-next");
529
+ let n = S(t.y, t.m + (e.shiftKey ? 12 : 1));
530
+ return this._setFocus(n.y, n.m, Math.min(t.d, x(n.y, n.m)), "slide-next");
522
531
  }
523
532
  case "Enter":
524
533
  case " ":
525
- e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value = y(t.y, t.m, t.d), this._close());
534
+ e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value = y(t.y, t.m, t.d), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
526
535
  return;
527
536
  case "Escape": return this._close();
528
537
  default:
@@ -551,7 +560,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
551
560
  let t = e.target.closest("[data-nav]");
552
561
  if (t) {
553
562
  this._viewNavigated = !0, this._slide = Number(t.dataset.nav) < 0 ? "slide-prev" : "slide-next";
554
- let e = C(this._viewY, this._viewM + Number(t.dataset.nav));
563
+ let e = S(this._viewY, this._viewM + Number(t.dataset.nav));
555
564
  this._viewY = e.y, this._viewM = e.m, this._focus = {
556
565
  y: e.y,
557
566
  m: e.m,
@@ -590,31 +599,33 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
590
599
  }
591
600
  if (e.target.closest("[data-today]")) {
592
601
  let e = /* @__PURE__ */ new Date();
593
- this.value = y(e.getFullYear(), e.getMonth(), e.getDate()), this._close();
602
+ this.value = y(e.getFullYear(), e.getMonth(), e.getDate()), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
594
603
  return;
595
604
  }
596
605
  if (e.target.closest("[data-clear]")) {
597
- this.value = "", this._close();
606
+ this.value = "", this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
598
607
  return;
599
608
  }
600
609
  let s = e.target.closest(".datepicker-day[data-iso]");
601
- s && !s.disabled && (this.value = s.dataset.iso, this._close());
610
+ s && !s.disabled && (this.value = s.dataset.iso, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
602
611
  }), this._onKeyBound = (e) => {
603
612
  r() && this._onKey(e);
604
613
  }, t.addEventListener("keydown", this._onKeyBound), this._onDocClick = (e) => {
605
614
  let t = this._popClick;
606
615
  this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
607
- }, document.addEventListener("click", this._onDocClick), a(this, () => {
616
+ }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
617
+ r() && e.key === "Escape" && this._close();
618
+ }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
608
619
  r() && this._position(e, t);
609
620
  }), this._syncFormValue();
610
621
  }
611
622
  _teardown() {
612
- this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
623
+ this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
613
624
  }
614
625
  disconnectedCallback() {
615
626
  this._teardown();
616
627
  }
617
- }, T = [
628
+ }, C = [
618
629
  "January",
619
630
  "February",
620
631
  "March",
@@ -627,7 +638,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
627
638
  "October",
628
639
  "November",
629
640
  "December"
630
- ], E = [
641
+ ], w = [
631
642
  "Su",
632
643
  "Mo",
633
644
  "Tu",
@@ -635,24 +646,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
635
646
  "Th",
636
647
  "Fr",
637
648
  "Sa"
638
- ], D = (e) => String(e).padStart(2, "0"), ee = (e, t, n) => `${e}-${D(t + 1)}-${D(n)}`, O = (e) => {
649
+ ], T = (e) => String(e).padStart(2, "0"), ne = (e, t, n) => `${e}-${T(t + 1)}-${T(n)}`, E = (e) => {
639
650
  let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
640
651
  return t ? {
641
652
  y: +t[1],
642
653
  m: t[2] - 1,
643
654
  d: +t[3]
644
655
  } : null;
645
- }, k = (e) => {
646
- let t = O(e);
647
- return t ? `${D(t.d)} ${T[t.m].slice(0, 3)} ${t.y}` : "";
648
- }, A = (e, t) => new Date(e, t + 1, 0).getDate(), j = (e, t) => {
656
+ }, D = (e) => {
657
+ let t = E(e);
658
+ return t ? `${T(t.d)} ${C[t.m].slice(0, 3)} ${t.y}` : "";
659
+ }, O = (e, t) => new Date(e, t + 1, 0).getDate(), k = (e, t) => {
649
660
  for (; t < 0;) t += 12, --e;
650
661
  for (; t > 11;) t -= 12, e += 1;
651
662
  return {
652
663
  y: e,
653
664
  m: t
654
665
  };
655
- }, M = class extends HTMLElement {
666
+ }, A = class extends HTMLElement {
656
667
  static formAssociated = !0;
657
668
  static get observedAttributes() {
658
669
  return [
@@ -695,7 +706,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
695
706
  };
696
707
  }
697
708
  set value(e) {
698
- this._start = e?.start || "", this._end = e?.end || "", this._syncTrigger(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
709
+ this._start = e?.start || "", this._end = e?.end || "", this._syncTrigger(), this._syncMirrors();
699
710
  }
700
711
  _firstDay() {
701
712
  let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
@@ -707,13 +718,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
707
718
  text: e,
708
719
  empty: !0
709
720
  } : {
710
- text: `${k(this._start) || "Start"} – ${k(this._end) || "End"}`,
721
+ text: `${D(this._start) || "Start"} – ${D(this._end) || "End"}`,
711
722
  empty: !1
712
723
  };
713
724
  }
714
725
  render() {
715
726
  this._defaultStart === void 0 && (this._defaultStart = this.getAttribute("start") || "", this._defaultEnd = this.getAttribute("end") || ""), this._start = this.getAttribute("start") || this._start, this._end = this.getAttribute("end") || this._end;
716
- let e = O(this._start);
727
+ let e = E(this._start);
717
728
  e && (this._viewY = e.y, this._viewM = e.m);
718
729
  let t = this.getAttribute("size"), n = t === "sm" ? " input-sm" : t === "lg" ? " input-lg" : "", { text: r, empty: i } = this._label(), a = this.getAttribute("aria-label"), o = this.getAttribute("aria-describedby");
719
730
  this.innerHTML = `
@@ -747,24 +758,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
747
758
  r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-range-mirror", e), this.appendChild(r)), r.name = t, r.value = n || "", r.disabled = this.hasAttribute("disabled");
748
759
  }
749
760
  _limits() {
750
- let e = O(this.getAttribute("min")), t = O(this.getAttribute("max")), n = e ? new Date(e.y, e.m, e.d).getTime() : -Infinity, r = t ? new Date(t.y, t.m, t.d).getTime() : Infinity;
761
+ let e = E(this.getAttribute("min")), t = E(this.getAttribute("max")), n = e ? new Date(e.y, e.m, e.d).getTime() : -Infinity, r = t ? new Date(t.y, t.m, t.d).getTime() : Infinity;
751
762
  return (e, t, i) => {
752
763
  let a = new Date(e, t, i).getTime();
753
764
  return a < n || a > r;
754
765
  };
755
766
  }
756
767
  _monthHtml(e, t) {
757
- let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = A(e, t), a = this._limits(), o = E.map((e, t) => E[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), s = (e, t, n, r) => {
758
- let i = ee(e, t, n), o = a(e, t, n);
768
+ let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = O(e, t), a = this._limits(), o = w.map((e, t) => w[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), s = (e, t, n, r) => {
769
+ let i = ne(e, t, n), o = a(e, t, n);
759
770
  return `<button type="button" class="${["datepicker-day", r ? "is-outside" : ""].filter(Boolean).join(" ")}" data-iso="${i}"${o ? " disabled" : ""}>${n}</button>`;
760
- }, c = "", l = j(e, t - 1), u = A(l.y, l.m);
771
+ }, c = "", l = k(e, t - 1), u = O(l.y, l.m);
761
772
  for (let e = r - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
762
773
  for (let n = 1; n <= i; n++) c += s(e, t, n, !1);
763
- let d = j(e, t + 1), f = (7 - (r + i) % 7) % 7;
774
+ let d = k(e, t + 1), f = (7 - (r + i) % 7) % 7;
764
775
  for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
765
776
  return `
766
777
  <div class="daterange-cal">
767
- <div class="datepicker-month-label">${T[t]} ${e}</div>
778
+ <div class="datepicker-month-label">${C[t]} ${e}</div>
768
779
  <div class="datepicker-weekdays">${o}</div>
769
780
  <div class="datepicker-grid" role="grid">${c}</div>
770
781
  </div>`;
@@ -772,7 +783,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
772
783
  _renderView() {
773
784
  let e = this.querySelector(".daterange-pop");
774
785
  if (!e) return;
775
- let t = j(this._viewY, this._viewM + 1);
786
+ let t = k(this._viewY, this._viewM + 1);
776
787
  e.innerHTML = `
777
788
  <div class="daterange-head">
778
789
  <button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month"><i class="bi bi-chevron-left" aria-hidden="true"></i></button>
@@ -798,7 +809,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
798
809
  n.classList.toggle("is-range-start", i), n.classList.toggle("is-range-end", a), n.classList.toggle("in-range", o);
799
810
  }
800
811
  let i = e.querySelector("[data-range-hint]");
801
- i && (i.textContent = this._start ? this._end ? `${k(this._start)} – ${k(this._end)}` : "Pick an end date" : "Pick a start date");
812
+ i && (i.textContent = this._start ? this._end ? `${D(this._start)} – ${D(this._end)}` : "Pick an end date" : "Pick a start date");
802
813
  }
803
814
  _position(e, t) {
804
815
  i(e, t);
@@ -809,7 +820,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
809
820
  return;
810
821
  }
811
822
  if (new Date(e).getTime() < new Date(this._start).getTime()) {
812
- this._start = e, this._syncTrigger(), this._syncMirrors(), this._paint();
823
+ this._start = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
813
824
  return;
814
825
  }
815
826
  this._end = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
@@ -820,7 +831,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
820
831
  if (!e || !t) return;
821
832
  let r = () => !t.hidden;
822
833
  this._open = () => {
823
- let r = O(this._start);
834
+ let r = E(this._start);
824
835
  if (r) this._viewY = r.y, this._viewM = r.m;
825
836
  else {
826
837
  let e = /* @__PURE__ */ new Date();
@@ -833,7 +844,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
833
844
  this._popClick = !0;
834
845
  let t = e.target.closest("[data-nav]");
835
846
  if (t) {
836
- let e = j(this._viewY, this._viewM + Number(t.dataset.nav));
847
+ let e = k(this._viewY, this._viewM + Number(t.dataset.nav));
837
848
  this._viewY = e.y, this._viewM = e.m, this._renderView();
838
849
  return;
839
850
  }
@@ -861,7 +872,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
861
872
  disconnectedCallback() {
862
873
  this._teardown();
863
874
  }
864
- }, N = class extends HTMLElement {
875
+ }, j = class extends HTMLElement {
865
876
  static formAssociated = !0;
866
877
  _accessibleName() {
867
878
  return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
@@ -940,13 +951,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
940
951
  let e = this.hasAttribute("searchable"), t = this.getAttribute("search-placeholder") || "Search…", n = this.getAttribute("icon"), r = this.getAttribute("size"), i = r === "sm" ? " search-select-sm" : r === "lg" ? " search-select-lg" : "";
941
952
  c(this, this._values.join(",")), this.innerHTML = `
942
953
  <div class="search-select${i}">
943
- <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${P(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
944
- ${n ? `<i class="bi bi-${P(n)} search-select-icon" aria-hidden="true"></i>` : ""}
954
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${M(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
955
+ ${n ? `<i class="bi bi-${M(n)} search-select-icon" aria-hidden="true"></i>` : ""}
945
956
  <div class="ms-chips" data-chips></div>
946
957
  <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
947
958
  </div>
948
959
  <div class="search-select-menu search-select-menu-fixed" role="listbox" aria-multiselectable="true" tabindex="-1" hidden>
949
- ${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${P(t)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
960
+ ${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${M(t)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
950
961
  <div class="search-select-options"></div>
951
962
  <div class="search-select-empty" hidden>No matches</div>
952
963
  </div>
@@ -960,7 +971,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
960
971
  e.innerHTML = `<span class="search-select-placeholder">${u(t)}</span>`;
961
972
  return;
962
973
  }
963
- e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${P(e)}" aria-label="Remove"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
974
+ e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${M(e)}" aria-label="Remove ${re(this._labelFor(e))}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
964
975
  }
965
976
  _collapseChips() {
966
977
  let e = this.querySelector("[data-chips]");
@@ -984,9 +995,9 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
984
995
  let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
985
996
  if (!t) return;
986
997
  let r = (e || "").trim().toLowerCase(), i = this._readOptions();
987
- r && (i = i.filter((e) => te(e.label).toLowerCase().includes(r))), t.innerHTML = i.map((e) => {
998
+ r && (i = i.filter((e) => re(e.label).toLowerCase().includes(r))), t.innerHTML = i.map((e) => {
988
999
  let t = this._values.includes(String(e.value));
989
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${P(e.value)}" aria-selected="${t}"><span class="ms-opt-label">${f(e)}</span><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span></button>`;
1000
+ return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${M(e.value)}" aria-selected="${t}"><span class="ms-opt-label">${f(e)}</span><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span></button>`;
990
1001
  }).join(""), n && (n.hidden = i.length > 0), this._active = -1;
991
1002
  }
992
1003
  _wire() {
@@ -1031,7 +1042,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
1031
1042
  });
1032
1043
  let y = (t) => {
1033
1044
  let r = d();
1034
- t.key === "ArrowDown" ? (t.preventDefault(), f(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), f(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && _(r[this._active].dataset.value)) : t.key === "Escape" ? (h(), e.focus()) : t.key === "Backspace" && !n.value && this._values.length && v(this._values[this._values.length - 1]);
1045
+ t.key === "ArrowDown" ? (t.preventDefault(), f(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), f(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && _(r[this._active].dataset.value)) : t.key === "Escape" ? (h(), e.focus()) : t.key === "Backspace" && !n?.value && this._values.length && v(this._values[this._values.length - 1]);
1035
1046
  };
1036
1047
  n?.addEventListener("keydown", y), r?.addEventListener("click", () => {
1037
1048
  n.value = "", this._renderOptions(""), r.hidden = !0, n.focus();
@@ -1053,7 +1064,8 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
1053
1064
  disconnectedCallback() {
1054
1065
  this._teardown(), this._ro?.disconnect(), this._ro = null;
1055
1066
  }
1056
- }, P = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), te = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), ne = /[^0-9]/g, re = /[^0-9a-zA-Z]/g, F = class extends HTMLElement {
1067
+ }, M = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), re = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), ie = /[^0-9]/g, ae = /[^0-9a-zA-Z]/g, oe = class extends HTMLElement {
1068
+ static formAssociated = !0;
1057
1069
  static get observedAttributes() {
1058
1070
  return [
1059
1071
  "value",
@@ -1083,10 +1095,21 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
1083
1095
  this._value = this._clean(e), c(this, this._value), this._paint();
1084
1096
  }
1085
1097
  _clean(e) {
1086
- return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? re : ne, "").slice(0, this.length);
1098
+ return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? ae : ie, "").slice(0, this.length);
1099
+ }
1100
+ constructor() {
1101
+ super();
1102
+ try {
1103
+ this._internals = this.attachInternals();
1104
+ } catch {
1105
+ this._internals = null;
1106
+ }
1087
1107
  }
1088
1108
  connectedCallback() {
1089
- this._rendered || this.render();
1109
+ this._rendered ? this._onSelectionChange && document.addEventListener("selectionchange", this._onSelectionChange) : (this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render());
1110
+ }
1111
+ formResetCallback() {
1112
+ this._value = this._defaultValue || "", c(this, this._value), this._paint();
1090
1113
  }
1091
1114
  attributeChangedCallback(e, t, n) {
1092
1115
  this._rendered && (e === "value" ? (this._value = this._clean(n), c(this, this._value), this._paint()) : this.render());
@@ -1145,11 +1168,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
1145
1168
  "blur",
1146
1169
  "select"
1147
1170
  ]) e.addEventListener(t, () => this._paint());
1148
- document.addEventListener("selectionchange", () => {
1171
+ this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange), this._onSelectionChange = () => {
1149
1172
  document.activeElement === e && this._paint();
1150
- });
1173
+ }, document.addEventListener("selectionchange", this._onSelectionChange);
1151
1174
  }
1152
- }, I = [
1175
+ disconnectedCallback() {
1176
+ this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange);
1177
+ }
1178
+ }, se = [
1153
1179
  [
1154
1180
  "AF",
1155
1181
  "Afghanistan",
@@ -2375,56 +2401,56 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
2375
2401
  "Zimbabwe",
2376
2402
  "263"
2377
2403
  ]
2378
- ], L = (e) => (I.find((t) => t[0] === e) || [
2404
+ ], N = (e) => (se.find((t) => t[0] === e) || [
2379
2405
  "",
2380
2406
  "",
2381
2407
  ""
2382
- ])[2], R = (e) => `wui-flag wui-flag-${String(e).toLowerCase()}`, z = null, B = null;
2383
- function ie() {
2384
- return z ? Promise.resolve(z) : (B ||= Promise.all([import("./libphonenumber-js-BcNT8oq0.js"), import("./examples.mobile.json-BMXTGiGC.js")]).then(([e, t]) => (z = {
2408
+ ])[2], P = (e) => `wui-flag wui-flag-${String(e).toLowerCase()}`, F = null, I = null;
2409
+ function ce() {
2410
+ return F ? Promise.resolve(F) : (I ||= Promise.all([import("./libphonenumber-js-BcNT8oq0.js"), import("./examples.mobile.json-BMXTGiGC.js")]).then(([e, t]) => (F = {
2385
2411
  AsYouType: e.AsYouType,
2386
2412
  getExampleNumber: e.getExampleNumber,
2387
2413
  isValidPhoneNumber: e.isValidPhoneNumber,
2388
2414
  examples: t.default || t
2389
- }, z)).catch(() => null), B);
2415
+ }, F)).catch(() => null), I);
2390
2416
  }
2391
- function V(e, t) {
2392
- if (!z || !t) return t;
2417
+ function L(e, t) {
2418
+ if (!F || !t) return t;
2393
2419
  try {
2394
- return new z.AsYouType(e).input(t);
2420
+ return new F.AsYouType(e).input(t);
2395
2421
  } catch {
2396
2422
  return t;
2397
2423
  }
2398
2424
  }
2399
- function H(e) {
2400
- if (!z) return null;
2425
+ function R(e) {
2426
+ if (!F) return null;
2401
2427
  try {
2402
- return z.getExampleNumber(e, z.examples)?.formatNational() || null;
2428
+ return F.getExampleNumber(e, F.examples)?.formatNational() || null;
2403
2429
  } catch {
2404
2430
  return null;
2405
2431
  }
2406
2432
  }
2407
- function U(e) {
2408
- if (!z || !e) return null;
2433
+ function z(e) {
2434
+ if (!F || !e) return null;
2409
2435
  try {
2410
- return z.isValidPhoneNumber(e);
2436
+ return F.isValidPhoneNumber(e);
2411
2437
  } catch {
2412
2438
  return null;
2413
2439
  }
2414
2440
  }
2415
- function ae(e) {
2416
- if (!z) return null;
2441
+ function le(e) {
2442
+ if (!F) return null;
2417
2443
  try {
2418
- let t = z.getExampleNumber(e, z.examples);
2444
+ let t = F.getExampleNumber(e, F.examples);
2419
2445
  return t?.nationalNumber ? t.nationalNumber.length : null;
2420
2446
  } catch {
2421
2447
  return null;
2422
2448
  }
2423
2449
  }
2424
- function W(e) {
2425
- if (!z || !e?.trim().startsWith("+")) return null;
2450
+ function B(e) {
2451
+ if (!F || !e?.trim().startsWith("+")) return null;
2426
2452
  try {
2427
- let t = new z.AsYouType();
2453
+ let t = new F.AsYouType();
2428
2454
  t.input(e.trim());
2429
2455
  let n = t.getCountry();
2430
2456
  return n ? {
@@ -2435,7 +2461,7 @@ function W(e) {
2435
2461
  return null;
2436
2462
  }
2437
2463
  }
2438
- var G = class extends HTMLElement {
2464
+ var V = class extends HTMLElement {
2439
2465
  static formAssociated = !0;
2440
2466
  static get observedAttributes() {
2441
2467
  return [
@@ -2471,100 +2497,100 @@ var G = class extends HTMLElement {
2471
2497
  this.value = this._defaultValue || "";
2472
2498
  }
2473
2499
  get value() {
2474
- return `+${L(this._country)}${this._national}`;
2500
+ return this._national ? `+${N(this._country)}${this._national}` : "";
2475
2501
  }
2476
2502
  set value(e) {
2477
- let t = String(e ?? "").trim(), n = W(t);
2503
+ let t = String(e ?? "").trim(), n = B(t);
2478
2504
  if (n) this._country = n.country, this._national = n.national.replace(/[^0-9]/g, "");
2479
2505
  else if (t.startsWith("+")) {
2480
- let e = t.replace(/[^0-9]/g, ""), n = String(L(this._country));
2506
+ let e = t.replace(/[^0-9]/g, ""), n = String(N(this._country));
2481
2507
  n && e.startsWith(n) && (e = e.slice(n.length)), this._national = e;
2482
2508
  } else this._national = t.replace(/[^0-9]/g, "");
2483
- n && this.getAttribute("country") !== this._country ? this.setAttribute("country", this._country) : this._rendered && this.render(), this._commit();
2509
+ n && this.getAttribute("country") !== this._country ? this.setAttribute("country", this._country) : this._rendered && this.render(), this._syncMirror();
2484
2510
  }
2485
- _commit() {
2486
- c(this, this.value), this.dispatchEvent(new Event("change", { bubbles: !0 }));
2511
+ _syncMirror() {
2512
+ c(this, this.value);
2487
2513
  }
2488
2514
  render() {
2489
2515
  this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "");
2490
- let e = this.getAttribute("placeholder") || H(this._country) || "Enter phone number";
2516
+ let e = this.getAttribute("placeholder") || R(this._country) || "Enter phone number";
2491
2517
  this._country = this.getAttribute("country") || this._country;
2492
- let t = I.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${R(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
2518
+ let t = se.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${P(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
2493
2519
  this.innerHTML = `
2494
2520
  <div class="phone-input-wrap">
2495
2521
  <div class="phone-country-adornment">
2496
2522
  <button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
2497
- <span class="${R(this._country)}" data-flag aria-hidden="true"></span>
2523
+ <span class="${P(this._country)}" data-flag aria-hidden="true"></span>
2498
2524
  <i class="bi bi-chevron-down phone-chevron" aria-hidden="true"></i>
2499
- <span class="phone-dial" data-dial>+${L(this._country)}</span>
2525
+ <span class="phone-dial" data-dial>+${N(this._country)}</span>
2500
2526
  </button>
2501
2527
  <div class="country-dropdown-menu" role="listbox" hidden>
2502
2528
  <div class="dropdown-search-wrapper"><span class="dropdown-search-icon"><i class="bi bi-search" aria-hidden="true"></i></span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" /></div>
2503
2529
  <div class="country-list-scroll">${t}<div class="country-empty" hidden>No countries found</div></div>
2504
2530
  </div>
2505
2531
  </div>
2506
- <input type="tel" class="input" placeholder="${K(e)}" value="${K(V(this._country, this._national))}"${this.getAttribute("aria-label") ? ` aria-label="${K(this.getAttribute("aria-label"))}"` : ""}${this.getAttribute("aria-describedby") ? ` aria-describedby="${K(this.getAttribute("aria-describedby"))}"` : ""}${this.hasAttribute("required") ? " required aria-required=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""} />
2532
+ <input type="tel" class="input" placeholder="${H(e)}" value="${H(L(this._country, this._national))}"${this.getAttribute("aria-label") ? ` aria-label="${H(this.getAttribute("aria-label"))}"` : ""}${this.getAttribute("aria-describedby") ? ` aria-describedby="${H(this.getAttribute("aria-describedby"))}"` : ""}${this.hasAttribute("required") ? " required aria-required=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""} />
2507
2533
  </div>
2508
2534
  <div class="field-error" data-phone-error hidden></div>`, this._rendered = !0, c(this, this.value), this._wire();
2509
2535
  }
2510
2536
  _wire() {
2511
2537
  this._teardown();
2512
- let e = this.querySelector(".country-toggle"), t = this.querySelector(".phone-input-wrap"), n = this.querySelector(".country-dropdown-menu"), r = this.querySelector(".dropdown-search-input"), i = this.querySelector(".country-list-scroll"), a = this.querySelector(".country-empty"), o = this.querySelector("input[type=tel]"), s = this.querySelector("[data-flag]"), l = this.querySelector("[data-dial]");
2538
+ let e = this.querySelector(".country-toggle"), t = this.querySelector(".phone-input-wrap"), n = this.querySelector(".country-dropdown-menu"), r = this.querySelector(".dropdown-search-input"), i = this.querySelector(".country-list-scroll"), a = this.querySelector(".country-empty"), o = this.querySelector("input[type=tel]"), s = this.querySelector("[data-flag]"), c = this.querySelector("[data-dial]");
2513
2539
  if (!e || !n) return;
2514
- let u = () => !n.hidden, d = () => {
2540
+ let l = () => !n.hidden, u = () => {
2515
2541
  let r = (t || e).getBoundingClientRect(), i = n.offsetWidth || 320, a = n.offsetHeight || 320, o = window.innerHeight - r.bottom, s = o < a + 6 && r.top > o ? r.top - a - 6 : r.bottom + 6, c = Math.min(Math.max(8, r.left), Math.max(8, window.innerWidth - i - 8));
2516
2542
  n.style.top = `${Math.max(8, s)}px`, n.style.left = `${c}px`;
2543
+ }, d = () => {
2544
+ n.hidden = !1, e.setAttribute("aria-expanded", "true"), r.value = "", p(""), u(), r.focus();
2517
2545
  }, f = () => {
2518
- n.hidden = !1, e.setAttribute("aria-expanded", "true"), r.value = "", m(""), d(), r.focus();
2519
- }, p = () => {
2520
2546
  n.hidden = !0, e.setAttribute("aria-expanded", "false");
2521
2547
  };
2522
2548
  this._reposition = () => {
2523
- u() && d();
2549
+ l() && u();
2524
2550
  }, window.addEventListener("scroll", this._reposition, !0), window.addEventListener("resize", this._reposition);
2525
- let m = (e) => {
2551
+ let p = (e) => {
2526
2552
  let t = e.trim().toLowerCase(), n = 0;
2527
2553
  for (let e of i.querySelectorAll(".country-dropdown-item")) {
2528
2554
  let r = !t || e.textContent.toLowerCase().includes(t);
2529
2555
  e.hidden = !r, r && (n += 1);
2530
2556
  }
2531
2557
  a && (a.hidden = n > 0);
2532
- }, h = (e) => {
2533
- this._country = e, this.setAttribute("country", e), s && (s.className = R(e)), l && (l.textContent = `+${L(e)}`);
2558
+ }, m = (e) => {
2559
+ this._country = e, this.setAttribute("country", e), s && (s.className = P(e)), c && (c.textContent = `+${N(e)}`);
2534
2560
  for (let t of i.querySelectorAll(".country-dropdown-item")) t.classList.toggle("selected", t.dataset.iso === e);
2535
- p(), this._commit();
2561
+ f(), this._syncMirror(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
2536
2562
  };
2537
- e.addEventListener("click", () => u() ? p() : f()), r.addEventListener("input", () => m(r.value)), i.addEventListener("click", (e) => {
2563
+ e.addEventListener("click", () => l() ? f() : d()), r.addEventListener("input", () => p(r.value)), i.addEventListener("click", (e) => {
2538
2564
  let t = e.target.closest(".country-dropdown-item");
2539
- t && h(t.dataset.iso);
2565
+ t && m(t.dataset.iso);
2540
2566
  });
2541
- let g = this.querySelector("[data-phone-error]"), _ = (e) => {
2542
- if (o.classList.toggle("is-invalid", e), e ? o.setAttribute("aria-invalid", "true") : o.removeAttribute("aria-invalid"), g) {
2567
+ let h = this.querySelector("[data-phone-error]"), g = (e) => {
2568
+ if (o.classList.toggle("is-invalid", e), e ? o.setAttribute("aria-invalid", "true") : o.removeAttribute("aria-invalid"), h) {
2543
2569
  if (e) {
2544
- let e = H(this._country);
2545
- g.textContent = e ? `Enter a valid phone number, e.g. ${e}` : "Enter a valid phone number";
2570
+ let e = R(this._country);
2571
+ h.textContent = e ? `Enter a valid phone number, e.g. ${e}` : "Enter a valid phone number";
2546
2572
  }
2547
- g.hidden = !e;
2573
+ h.hidden = !e;
2548
2574
  }
2549
2575
  };
2550
2576
  o.addEventListener("input", () => {
2551
- let e = o.value.replace(/[^0-9]/g, ""), t = ae(this._country);
2577
+ let e = o.value.replace(/[^0-9]/g, ""), t = le(this._country);
2552
2578
  t && e.length > t && (e = e.slice(0, t)), this._national = e;
2553
- let n = V(this._country, this._national);
2554
- o.value !== n && (o.value = n), this._commit(), o.classList.contains("is-invalid") && (!this._national || U(this.value) === !0) && _(!1);
2579
+ let n = L(this._country, this._national);
2580
+ o.value !== n && (o.value = n), this._syncMirror(), this.dispatchEvent(new Event("change", { bubbles: !0 })), o.classList.contains("is-invalid") && (!this._national || z(this.value) === !0) && g(!1);
2555
2581
  }), o.addEventListener("blur", () => {
2556
- _(this._national.length > 0 && U(this.value) === !1);
2582
+ g(this._national.length > 0 && z(this.value) === !1);
2557
2583
  }), o.addEventListener("paste", (e) => {
2558
- let t = W(e.clipboardData?.getData("text"));
2559
- t && (e.preventDefault(), this._national = t.national.replace(/[^0-9]/g, ""), t.country === this._country ? o.value = V(this._country, this._national) : this.setAttribute("country", t.country), this._commit(), this.querySelector("input[type=tel]")?.focus());
2584
+ let t = B(e.clipboardData?.getData("text"));
2585
+ t && (e.preventDefault(), this._national = t.national.replace(/[^0-9]/g, ""), t.country === this._country ? o.value = L(this._country, this._national) : this.setAttribute("country", t.country), this._syncMirror(), this.dispatchEvent(new Event("change", { bubbles: !0 })), this.querySelector("input[type=tel]")?.focus());
2560
2586
  }), this._onDocClick = (e) => {
2561
- u() && !this.contains(e.target) && p();
2562
- }, document.addEventListener("click", this._onDocClick), ie().then((e) => {
2563
- if (!(!e || !o) && (this._national && (o.value = V(this._country, this._national)), !this.getAttribute("placeholder"))) {
2564
- let e = H(this._country);
2587
+ l() && !this.contains(e.target) && f();
2588
+ }, document.addEventListener("click", this._onDocClick), ce().then((e) => {
2589
+ if (!(!e || !o) && (this._national && (o.value = L(this._country, this._national)), !this.getAttribute("placeholder"))) {
2590
+ let e = R(this._country);
2565
2591
  e && (o.placeholder = e);
2566
2592
  }
2567
- }), c(this, this.value);
2593
+ }), this._syncMirror();
2568
2594
  }
2569
2595
  _teardown() {
2570
2596
  this._reposition && (window.removeEventListener("scroll", this._reposition, !0), window.removeEventListener("resize", this._reposition)), this._onDocClick && document.removeEventListener("click", this._onDocClick);
@@ -2572,7 +2598,7 @@ var G = class extends HTMLElement {
2572
2598
  disconnectedCallback() {
2573
2599
  this._teardown();
2574
2600
  }
2575
- }, K = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), q = class extends HTMLElement {
2601
+ }, H = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), U = class extends HTMLElement {
2576
2602
  static formAssociated = !0;
2577
2603
  static get observedAttributes() {
2578
2604
  return [
@@ -2646,19 +2672,19 @@ var G = class extends HTMLElement {
2646
2672
  d && (this._value = String(d.value)), c(this, this._value);
2647
2673
  let p = e.map((e) => {
2648
2674
  let t = String(e.value) === String(this._value);
2649
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${J(e.value)}" aria-selected="${t}">${f(e)}</button>`;
2675
+ return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${W(e.value)}" aria-selected="${t}">${f(e)}</button>`;
2650
2676
  }).join("");
2651
2677
  this.innerHTML = `
2652
2678
  <div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}${i}">
2653
- <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${J(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
2654
- ${a ? `<i class="bi bi-${J(a)} search-select-icon" aria-hidden="true"></i>` : ""}
2679
+ <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${W(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
2680
+ ${a ? `<i class="bi bi-${W(a)} search-select-icon" aria-hidden="true"></i>` : ""}
2655
2681
  ${o ? `<span class="search-select-prefix">${u(o)}</span>` : ""}
2656
2682
  <span class="${d ? "" : "search-select-placeholder"}" data-label>${d ? f(d) : u(s)}</span>
2657
2683
  ${n ? "<span class=\"search-select-reset\" role=\"button\" aria-label=\"Clear selection\" hidden><i class=\"bi bi-x-lg\" aria-hidden=\"true\"></i></span>" : ""}
2658
2684
  <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
2659
2685
  </button>
2660
2686
  <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
2661
- ${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${J(l)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
2687
+ ${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${W(l)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
2662
2688
  <div class="search-select-options">${p}<div class="search-select-empty" hidden>No matches</div></div>
2663
2689
  </div>
2664
2690
  </div>`, this._rendered = !0, c(this, this._value), this._wire(), this._syncReset();
@@ -2687,7 +2713,7 @@ var G = class extends HTMLElement {
2687
2713
  let t = e.dataset.value === String(this._value);
2688
2714
  e.classList.toggle("selected", t), e.setAttribute("aria-selected", String(t));
2689
2715
  }
2690
- e && (e.innerHTML = t ? f(t) : e.innerHTML, e.classList.toggle("search-select-placeholder", !t));
2716
+ e && (e.innerHTML = t ? f(t) : u(this.getAttribute("placeholder") || "Select..."), e.classList.toggle("search-select-placeholder", !t));
2691
2717
  }
2692
2718
  _syncReset() {
2693
2719
  let { reset: e } = this._refs();
@@ -2754,14 +2780,534 @@ var G = class extends HTMLElement {
2754
2780
  disconnectedCallback() {
2755
2781
  this._teardown();
2756
2782
  }
2757
- }, J = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), Y = "image/png,image/jpeg,image/webp", oe = 5, se = {
2783
+ }, W = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), G = class extends HTMLElement {
2784
+ static formAssociated = !0;
2785
+ static get observedAttributes() {
2786
+ return [
2787
+ "min",
2788
+ "max",
2789
+ "step",
2790
+ "value",
2791
+ "start",
2792
+ "end",
2793
+ "name",
2794
+ "start-name",
2795
+ "end-name",
2796
+ "disabled",
2797
+ "size",
2798
+ "show-value",
2799
+ "unit",
2800
+ "aria-label"
2801
+ ];
2802
+ }
2803
+ constructor() {
2804
+ super();
2805
+ try {
2806
+ this._internals = this.attachInternals();
2807
+ } catch {
2808
+ this._internals = null;
2809
+ }
2810
+ this._value = 50, this._start = 25, this._end = 75, this._isDragging = !1, this._dragThumb = null, this._pointerDownListener = null, this._pointerMoveListener = null, this._pointerUpListener = null;
2811
+ }
2812
+ connectedCallback() {
2813
+ this._rendered || this.render();
2814
+ }
2815
+ attributeChangedCallback(e, t, n) {
2816
+ if (e === "value" || e === "start" || e === "end" || e === "min" || e === "max" || e === "step") {
2817
+ this._updateFromAttribute(e), this._rendered && (this._syncValue(), this._syncMirrors());
2818
+ return;
2819
+ }
2820
+ this._rendered && this.render();
2821
+ }
2822
+ formResetCallback() {
2823
+ this._isRange() ? this._resetRange() : this._resetSingle();
2824
+ }
2825
+ _updateFromAttribute(e) {
2826
+ let t = (e) => Number.parseFloat(e) || 0;
2827
+ e === "value" ? this._value = this._snapToStep(this._clamp(t(this.getAttribute("value")))) : e === "start" ? this._start = this._snapToStep(this._clamp(t(this.getAttribute("start")))) : e === "end" && (this._end = this._snapToStep(this._clamp(t(this.getAttribute("end")))));
2828
+ }
2829
+ _isRange() {
2830
+ return this.hasAttribute("range");
2831
+ }
2832
+ _min() {
2833
+ return Number.parseFloat(this.getAttribute("min")) || 0;
2834
+ }
2835
+ _max() {
2836
+ return Number.parseFloat(this.getAttribute("max")) || 100;
2837
+ }
2838
+ _step() {
2839
+ return Number.parseFloat(this.getAttribute("step")) || 1;
2840
+ }
2841
+ _clamp(e) {
2842
+ return Math.max(this._min(), Math.min(e, this._max()));
2843
+ }
2844
+ _snapToStep(e) {
2845
+ let t = this._step();
2846
+ return t <= 0 ? e : Math.round(e / t) * t;
2847
+ }
2848
+ _captureDefaults() {
2849
+ this._defaultsCaptured ||= (this._isRange() ? (this._defaultStart = this._start, this._defaultEnd = this._end) : this._defaultValue = this._value, !0);
2850
+ }
2851
+ _resetSingle() {
2852
+ this._value = this._defaultValue ?? 50, this._syncValue(), this._syncMirrors();
2853
+ }
2854
+ _resetRange() {
2855
+ this._start = this._defaultStart ?? 25, this._end = this._defaultEnd ?? 75, this._syncValue(), this._syncMirrors();
2856
+ }
2857
+ render() {
2858
+ this._captureDefaults();
2859
+ let e = this._min(), t = this._max(), n = this._isRange(), r = this.getAttribute("size"), i = r === "sm" ? " slider-sm" : r === "lg" ? " slider-lg" : "", a = this.hasAttribute("disabled");
2860
+ n ? (this._start = this._clamp(this._start), this._end = this._clamp(this._end), this._start > this._end && ([this._start, this._end] = [this._end, this._start])) : this._value = this._clamp(this._value);
2861
+ let o = (n) => (n - e) / (t - e) * 100, s = n ? o(this._start) : 0, c = o(n ? this._end : this._value);
2862
+ this.innerHTML = `
2863
+ <div class="slider${i}">
2864
+ <div class="slider-track" role="presentation"></div>
2865
+ <div class="slider-fill" style="left: ${s}%; right: ${100 - c}%;" role="presentation"></div>
2866
+ ${n ? `
2867
+ <button
2868
+ type="button"
2869
+ role="slider"
2870
+ class="slider-thumb"
2871
+ data-thumb="start"
2872
+ aria-label="Minimum"
2873
+ aria-valuemin="${e}"
2874
+ aria-valuemax="${t}"
2875
+ aria-valuenow="${this._start}"
2876
+ aria-valuetext="${this._formatValue(this._start)}"
2877
+ ${a ? "disabled" : ""}
2878
+ ></button>
2879
+ <button
2880
+ type="button"
2881
+ role="slider"
2882
+ class="slider-thumb"
2883
+ data-thumb="end"
2884
+ aria-label="Maximum"
2885
+ aria-valuemin="${e}"
2886
+ aria-valuemax="${t}"
2887
+ aria-valuenow="${this._end}"
2888
+ aria-valuetext="${this._formatValue(this._end)}"
2889
+ ${a ? "disabled" : ""}
2890
+ ></button>
2891
+ ` : `
2892
+ <button
2893
+ type="button"
2894
+ role="slider"
2895
+ class="slider-thumb"
2896
+ data-thumb="single"
2897
+ aria-valuemin="${e}"
2898
+ aria-valuemax="${t}"
2899
+ aria-valuenow="${this._value}"
2900
+ aria-valuetext="${this._formatValue(this._value)}"
2901
+ ${a ? "disabled" : ""}
2902
+ aria-label="${ue(this.getAttribute("aria-label") || "Value")}"
2903
+ ></button>
2904
+ `}
2905
+ ${this.hasAttribute("show-value") ? n ? `<span class="slider-value">${this._formatValue(this._start)} – ${this._formatValue(this._end)}</span>` : `<span class="slider-value">${this._formatValue(this._value)}</span>` : ""}
2906
+ </div>
2907
+ `, this._rendered = !0, this._syncMirrors(), this._wire();
2908
+ }
2909
+ _formatValue(e) {
2910
+ return `${e}${this.getAttribute("unit") || ""}`;
2911
+ }
2912
+ _syncValue() {
2913
+ if (!this._rendered) return;
2914
+ let e = this._min(), t = this._max(), n = (n) => (n - e) / (t - e) * 100, r = this.querySelector(".slider-fill");
2915
+ if (this._isRange()) {
2916
+ let e = n(this._start), t = n(this._end);
2917
+ r && (r.style.left = `${e}%`, r.style.right = `${100 - t}%`);
2918
+ let i = this.querySelector("[data-thumb=\"start\"]"), a = this.querySelector("[data-thumb=\"end\"]");
2919
+ i && (i.style.left = `${e}%`, i.setAttribute("aria-valuenow", String(this._start)), i.setAttribute("aria-valuetext", this._formatValue(this._start))), a && (a.style.left = `${t}%`, a.setAttribute("aria-valuenow", String(this._end)), a.setAttribute("aria-valuetext", this._formatValue(this._end)));
2920
+ let o = this.querySelector(".slider-value");
2921
+ o && (o.textContent = `${this._formatValue(this._start)} – ${this._formatValue(this._end)}`);
2922
+ } else {
2923
+ let e = n(this._value);
2924
+ r && (r.style.left = "0%", r.style.right = `${100 - e}%`);
2925
+ let t = this.querySelector(".slider-thumb");
2926
+ t && (t.style.left = `${e}%`, t.setAttribute("aria-valuenow", String(this._value)), t.setAttribute("aria-valuetext", this._formatValue(this._value)));
2927
+ let i = this.querySelector(".slider-value");
2928
+ i && (i.textContent = this._formatValue(this._value));
2929
+ }
2930
+ }
2931
+ _syncMirrors() {
2932
+ this._isRange() ? this._syncRangeMirrors() : this._syncSingleMirror();
2933
+ }
2934
+ _syncSingleMirror() {
2935
+ this.getAttribute("name") && c(this, String(this._value));
2936
+ }
2937
+ _syncRangeMirrors() {
2938
+ let e = this.getAttribute("start-name") || this.getAttribute("name"), t = this.getAttribute("end-name");
2939
+ this._mirrorRange("start", e, this._start), this._mirrorRange("end", t, this._end);
2940
+ }
2941
+ _mirrorRange(e, t, n) {
2942
+ if (!t) return;
2943
+ let r = this.querySelector(`input[type="hidden"][data-slider-mirror="${e}"]`);
2944
+ r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-slider-mirror", e), this.appendChild(r)), r.name = t, r.value = String(n), r.disabled = this.hasAttribute("disabled");
2945
+ }
2946
+ _valueAtPosition(e) {
2947
+ let t = this.querySelector(".slider-track");
2948
+ if (!t) return this._min();
2949
+ let n = t.getBoundingClientRect(), r = Math.max(0, Math.min(1, (e - n.left) / n.width)), i = this._min() + r * (this._max() - this._min()), a = this._step();
2950
+ return Math.round(i / a) * a;
2951
+ }
2952
+ _nearestThumb(e) {
2953
+ return Math.abs(e - this._start) <= Math.abs(e - this._end) ? "start" : "end";
2954
+ }
2955
+ _wire() {
2956
+ if (this._teardown(), this.hasAttribute("disabled")) return;
2957
+ let e = this.querySelectorAll(".slider-thumb"), t = this.querySelector(".slider-track"), n = this._isRange();
2958
+ this._pointerDownListener = (e) => {
2959
+ if (this.hasAttribute("disabled")) return;
2960
+ let t = e.target.closest(".slider-thumb");
2961
+ t && (e.preventDefault(), this._isDragging = !0, this._dragThumb = t.getAttribute("data-thumb"), document.addEventListener("pointermove", this._pointerMoveListener), document.addEventListener("pointerup", this._pointerUpListener));
2962
+ }, this._pointerMoveListener = (e) => {
2963
+ if (!this._isDragging) return;
2964
+ e.preventDefault();
2965
+ let t = this._valueAtPosition(e.clientX);
2966
+ if (this._dragThumb === "single") this._value = this._clamp(t), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: { value: this._value } }));
2967
+ else if (this._dragThumb === "start") {
2968
+ let e = Math.min(t, this._end);
2969
+ this._start = this._clamp(e), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: {
2970
+ start: this._start,
2971
+ end: this._end
2972
+ } }));
2973
+ } else if (this._dragThumb === "end") {
2974
+ let e = Math.max(t, this._start);
2975
+ this._end = this._clamp(e), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: {
2976
+ start: this._start,
2977
+ end: this._end
2978
+ } }));
2979
+ }
2980
+ }, this._pointerUpListener = () => {
2981
+ this._isDragging && (this._isDragging = !1, this._dragThumb = null, document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
2982
+ }, e.forEach((e) => {
2983
+ e.addEventListener("pointerdown", this._pointerDownListener), e.addEventListener("keydown", (t) => {
2984
+ if (this.hasAttribute("disabled")) return;
2985
+ let n = this._step(), r = n * 10, i = null, a = e.getAttribute("data-thumb");
2986
+ t.key === "ArrowLeft" || t.key === "ArrowDown" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) - n) : t.key === "ArrowRight" || t.key === "ArrowUp" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) + n) : t.key === "PageDown" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) - r) : t.key === "PageUp" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) + r) : t.key === "Home" ? (t.preventDefault(), i = this._min()) : t.key === "End" && (t.preventDefault(), i = this._max()), i != null && (i = this._clamp(i), a === "single" ? this._value = i : a === "start" ? this._start = Math.min(i, this._end) : a === "end" && (this._end = Math.max(i, this._start)), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
2987
+ });
2988
+ }), t && t.addEventListener("click", (e) => {
2989
+ if (this.hasAttribute("disabled")) return;
2990
+ let t = this._valueAtPosition(e.clientX);
2991
+ n ? this._nearestThumb(t) === "start" ? this._start = Math.min(t, this._end) : this._end = Math.max(t, this._start) : this._value = this._clamp(t), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
2992
+ });
2993
+ }
2994
+ _teardown() {
2995
+ this.querySelectorAll(".slider-thumb").forEach((e) => {
2996
+ e.removeEventListener("pointerdown", this._pointerDownListener), e.removeEventListener("keydown", this._pointerMoveListener);
2997
+ }), document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener);
2998
+ let e = this.querySelector(".slider-track");
2999
+ e && e.removeEventListener("click", this._pointerUpListener);
3000
+ }
3001
+ disconnectedCallback() {
3002
+ this._teardown();
3003
+ }
3004
+ }, ue = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), K = class extends HTMLElement {
3005
+ static formAssociated = !0;
3006
+ _accessibleName() {
3007
+ return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Add tags";
3008
+ }
3009
+ static get observedAttributes() {
3010
+ return [
3011
+ "placeholder",
3012
+ "disabled",
3013
+ "size",
3014
+ "max-tags",
3015
+ "aria-label"
3016
+ ];
3017
+ }
3018
+ constructor() {
3019
+ super(), this._values = [], this._draftText = "";
3020
+ try {
3021
+ this._internals = this.attachInternals();
3022
+ } catch {
3023
+ this._internals = null;
3024
+ }
3025
+ }
3026
+ connectedCallback() {
3027
+ if (!this._rendered) {
3028
+ if (!this._valuesInit && !this._values.length) {
3029
+ let e = [...this.querySelectorAll(":scope > wui-tag")].map((e) => e.textContent.trim());
3030
+ e.length && (this._values = e.map(String));
3031
+ }
3032
+ this._valuesInit = !0, this._defaultCaptured ||= (this._defaultValues = this._values.slice(), !0), this.render();
3033
+ }
3034
+ }
3035
+ formResetCallback() {
3036
+ this.values = (this._defaultValues || []).slice(), this._draftText = "";
3037
+ let e = this.querySelector("[data-input]");
3038
+ e && (e.value = "");
3039
+ }
3040
+ attributeChangedCallback() {
3041
+ this._rendered && this.render();
3042
+ }
3043
+ get values() {
3044
+ return this._values.slice();
3045
+ }
3046
+ set values(e) {
3047
+ this._values = Array.isArray(e) ? e.map(String) : [], c(this, this._values.join(",")), this._rendered && this._renderControl();
3048
+ }
3049
+ render() {
3050
+ let e = this.getAttribute("size"), t = e === "sm" ? " search-select-sm" : e === "lg" ? " search-select-lg" : "";
3051
+ c(this, this._values.join(",")), this.innerHTML = `
3052
+ <div class="search-select${t}">
3053
+ <div class="input search-select-control search-select-multi"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
3054
+ <div class="ms-chips" data-chips></div>
3055
+ <input type="text" class="ms-input" data-input aria-label="${q(this._accessibleName())}" placeholder="${q(this.getAttribute("placeholder") || "Add…")}" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""}/>
3056
+ </div>
3057
+ </div>`, this._rendered = !0, c(this, this._values.join(",")), this._renderControl(), this._wire();
3058
+ }
3059
+ _renderControl() {
3060
+ let e = this.querySelector("[data-chips]");
3061
+ if (e) {
3062
+ if (!this._values.length) {
3063
+ e.innerHTML = "";
3064
+ return;
3065
+ }
3066
+ e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${de(e)}</span><button type="button" class="chip-remove" data-remove="${q(e)}" aria-label="Remove ${q(e)}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join("");
3067
+ }
3068
+ }
3069
+ _wire() {
3070
+ this._teardown();
3071
+ let e = this.querySelector(".search-select-control"), t = this.querySelector("[data-input]");
3072
+ if (!e || !t) return;
3073
+ let n = () => this.hasAttribute("disabled"), r = (this.getAttribute("separators") || "enter,comma").split(",").map((e) => e.trim()), i = this.getAttribute("max-tags"), a = this.hasAttribute("allow-duplicates"), o = /* @__PURE__ */ new Set();
3074
+ for (let e of r) e === "enter" ? o.add("Enter") : e === "comma" ? o.add(",") : e === "space" ? o.add(" ") : e === "tab" && o.add("Tab");
3075
+ let s = () => {
3076
+ c(this, this._values.join(",")), this.dispatchEvent(new Event("change", { bubbles: !0 }));
3077
+ }, l = (e) => {
3078
+ let t = e.trim();
3079
+ if (!t || i && this._values.length >= parseInt(i, 10)) return;
3080
+ let n = a ? t : t.toLowerCase();
3081
+ (!this._values.some((e) => a ? e === t : e.toLowerCase() === n) || a) && (this._values.push(t), this._renderControl(), s());
3082
+ }, u = (e) => {
3083
+ this._values = this._values.filter((t) => t !== e), this._renderControl(), s();
3084
+ };
3085
+ e.addEventListener("click", (e) => {
3086
+ if (n()) return;
3087
+ let r = e.target.closest("[data-remove]");
3088
+ if (r) {
3089
+ e.stopPropagation(), u(r.dataset.remove), t.focus();
3090
+ return;
3091
+ }
3092
+ t.focus();
3093
+ }), t.addEventListener("keydown", (e) => {
3094
+ if (e.key === "Enter" && o.has("Enter")) {
3095
+ e.preventDefault(), l(t.value), t.value = "";
3096
+ return;
3097
+ }
3098
+ if (e.key === "," && o.has(",")) {
3099
+ e.preventDefault(), l(t.value.replace(/,+$/, "")), t.value = "";
3100
+ return;
3101
+ }
3102
+ if (e.key === " " && o.has(" ")) {
3103
+ let n = t.value.trim();
3104
+ n && (e.preventDefault(), l(n), t.value = "");
3105
+ return;
3106
+ }
3107
+ if (e.key === "Tab" && o.has("Tab")) {
3108
+ e.preventDefault(), l(t.value), t.value = "";
3109
+ return;
3110
+ }
3111
+ e.key === "Backspace" && !t.value && this._values.length && (e.preventDefault(), u(this._values[this._values.length - 1])), e.key === "Escape" && (t.value = "");
3112
+ }), t.addEventListener("paste", (e) => {
3113
+ e.preventDefault();
3114
+ let n = e.clipboardData.getData("text/plain"), a = [];
3115
+ for (let e of r) {
3116
+ let t = e;
3117
+ if (t === "enter" ? t = "\n" : t === "comma" ? t = "," : t === "space" ? t = " " : t === "tab" && (t = " "), n.includes(t)) {
3118
+ a.push(...n.split(t).map((e) => e.trim()).filter((e) => e));
3119
+ break;
3120
+ }
3121
+ }
3122
+ a.length || a.push(n.trim());
3123
+ for (let e of a) if (l(e), i && this._values.length >= parseInt(i, 10)) break;
3124
+ t.value = "";
3125
+ }), this._onDocClick = (e) => {
3126
+ this.contains(e.target) || t.blur();
3127
+ }, document.addEventListener("click", this._onDocClick);
3128
+ }
3129
+ _teardown() {
3130
+ this._onDocClick && document.removeEventListener("click", this._onDocClick);
3131
+ let e = this.querySelector("[data-input]");
3132
+ if (e) {
3133
+ let t = e, n = t.cloneNode(!1);
3134
+ t.replaceWith(n);
3135
+ }
3136
+ }
3137
+ disconnectedCallback() {
3138
+ this._teardown();
3139
+ }
3140
+ }, de = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), q = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), J = (e) => String(e).padStart(2, "0"), fe = (e, t) => `${J(e)}:${J(t)}`, Y = (e) => {
3141
+ let t = /^(\d{2}):(\d{2})$/.exec(e || "");
3142
+ return t ? {
3143
+ h: +t[1],
3144
+ m: +t[2]
3145
+ } : null;
3146
+ }, X = (e, t = "24") => {
3147
+ if (!e) return "";
3148
+ if (t === "24") return fe(e.h, e.m);
3149
+ let n = e.h % 12 || 12, r = e.h >= 12 ? "PM" : "AM";
3150
+ return `${n}:${J(e.m)} ${r}`;
3151
+ }, pe = class extends HTMLElement {
3152
+ static formAssociated = !0;
3153
+ static get observedAttributes() {
3154
+ return [
3155
+ "value",
3156
+ "min",
3157
+ "max",
3158
+ "step",
3159
+ "format",
3160
+ "placeholder",
3161
+ "disabled",
3162
+ "required",
3163
+ "size",
3164
+ "aria-label",
3165
+ "aria-describedby"
3166
+ ];
3167
+ }
3168
+ constructor() {
3169
+ super();
3170
+ try {
3171
+ this._internals = this.attachInternals();
3172
+ } catch {
3173
+ this._internals = null;
3174
+ }
3175
+ this._value = "", this._focus = null;
3176
+ }
3177
+ connectedCallback() {
3178
+ this._rendered || this.render();
3179
+ }
3180
+ attributeChangedCallback(e, t, n) {
3181
+ this._rendered && (e === "value" ? (this._value = n || "", this._syncFormValue(), this._syncTrigger()) : this.render());
3182
+ }
3183
+ formResetCallback() {
3184
+ this.value = this._defaultValue || "";
3185
+ }
3186
+ get value() {
3187
+ return this._value;
3188
+ }
3189
+ set value(e) {
3190
+ this._value = e || "", c(this, this._value), this._syncTrigger();
3191
+ }
3192
+ render() {
3193
+ this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._value = this.getAttribute("value") || this._value;
3194
+ let e = this.getAttribute("placeholder") || "Select time", t = Y(this._value), n = this.getAttribute("format") || "24", r = this.getAttribute("size"), i = r === "sm" ? " input-sm" : r === "lg" ? " input-lg" : "", a = this.getAttribute("aria-label"), o = this.getAttribute("aria-describedby");
3195
+ this.innerHTML = `
3196
+ <div class="timepicker">
3197
+ <button type="button" class="input timepicker-trigger${i}${t ? " has-value" : ""}" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${a ? ` aria-label="${u(a)}"` : ""}${o ? ` aria-describedby="${u(o)}"` : ""}>
3198
+ <span data-trigger-label class="${t ? "" : "timepicker-placeholder"}">${t ? X(t, n) : u(e)}</span>
3199
+ <i class="bi bi-clock" aria-hidden="true"></i>
3200
+ </button>
3201
+ <div class="timepicker-pop" role="listbox" tabindex="-1" hidden></div>
3202
+ </div>`, this._rendered = !0, c(this, this._value), this._wire();
3203
+ }
3204
+ _syncFormValue() {
3205
+ c(this, this._value);
3206
+ }
3207
+ _syncTrigger() {
3208
+ let e = this.querySelector(".timepicker-trigger"), t = this.querySelector("[data-trigger-label]");
3209
+ if (!t) return;
3210
+ let n = Y(this._value), r = this.getAttribute("format") || "24";
3211
+ t.textContent = n ? X(n, r) : this.getAttribute("placeholder") || "Select time", t.classList.toggle("timepicker-placeholder", !n), e?.classList.toggle("has-value", !!n);
3212
+ }
3213
+ _buildTimes() {
3214
+ let e = Math.max(1, parseInt(this.getAttribute("step") || "30", 10)), t = this.getAttribute("min") || "00:00", n = this.getAttribute("max") || "23:59", r = Y(t) || {
3215
+ h: 0,
3216
+ m: 0
3217
+ }, i = Y(n) || {
3218
+ h: 23,
3219
+ m: 59
3220
+ }, a = [], o = r.h, s = r.m;
3221
+ for (s = Math.ceil(s / e) * e, s >= 60 && (o += 1, s -= 60); o < i.h || o === i.h && s <= i.m;) a.push({
3222
+ h: o,
3223
+ m: s
3224
+ }), s += e, s >= 60 && (o += 1, s -= 60);
3225
+ return a;
3226
+ }
3227
+ _renderOptions() {
3228
+ let e = this.querySelector(".timepicker-pop");
3229
+ if (!e) return;
3230
+ let t = this.getAttribute("format") || "24", n = this._buildTimes(), r = Y(this._value), i = this._focus, a = "";
3231
+ for (let e = 0; e < n.length; e++) {
3232
+ let o = n[e], s = fe(o.h, o.m), c = r && r.h === o.h && r.m === o.m;
3233
+ a += `<button type="button" class="timepicker-option${c ? " is-selected" : ""}" data-hm="${s}" role="option" tabindex="${i === e ? "0" : "-1"}"${c ? " aria-selected=\"true\"" : ""}>${X(o, t)}</button>`;
3234
+ }
3235
+ e.innerHTML = a, this._focusActive();
3236
+ }
3237
+ _focusActive() {
3238
+ let e = this.querySelector(".timepicker-pop"), t = e?.querySelector("[tabindex=\"0\"]") || e?.querySelector(".is-selected");
3239
+ t && !e.hidden && t.focus();
3240
+ }
3241
+ _position(e, t) {
3242
+ i(e, t);
3243
+ }
3244
+ _onKey(e) {
3245
+ let t = [...this.querySelector(".timepicker-pop").querySelectorAll(".timepicker-option")];
3246
+ switch (e.key) {
3247
+ case "ArrowUp": {
3248
+ e.preventDefault();
3249
+ let t = Math.max((this._focus ?? 0) - 1, 0);
3250
+ this._focus = t, this._renderOptions();
3251
+ break;
3252
+ }
3253
+ case "ArrowDown": {
3254
+ e.preventDefault();
3255
+ let n = Math.min((this._focus ?? -1) + 1, t.length - 1);
3256
+ this._focus = n, this._renderOptions();
3257
+ break;
3258
+ }
3259
+ case "Enter":
3260
+ case " ":
3261
+ e.preventDefault(), t[this._focus] && (this.value = t[this._focus].dataset.hm, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
3262
+ break;
3263
+ case "Escape":
3264
+ this._close();
3265
+ break;
3266
+ default:
3267
+ }
3268
+ }
3269
+ _wire() {
3270
+ this._teardown();
3271
+ let e = this.querySelector(".timepicker-trigger"), t = this.querySelector(".timepicker-pop");
3272
+ if (!e || !t) return;
3273
+ let n = () => !t.hidden;
3274
+ this._open = () => {
3275
+ this._focus = null, this._renderOptions(), t.hidden = !1, e.setAttribute("aria-expanded", "true"), this._position(e, t);
3276
+ let n = t.querySelector(".is-selected");
3277
+ n ? this._focus = [...t.querySelectorAll(".timepicker-option")].indexOf(n) : this._focus = 0, this._renderOptions(), t.querySelector("[tabindex=\"0\"]")?.focus();
3278
+ }, this._close = () => {
3279
+ t.hidden = !0, e.setAttribute("aria-expanded", "false"), e.focus();
3280
+ }, e.addEventListener("click", () => n() ? this._close() : this._open()), e.addEventListener("keydown", (e) => {
3281
+ (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), n() || this._open());
3282
+ }), t.addEventListener("click", (e) => {
3283
+ this._popClick = !0;
3284
+ let t = e.target.closest(".timepicker-option");
3285
+ t && !t.disabled && (this.value = t.dataset.hm, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
3286
+ }), this._onKeyBound = (e) => {
3287
+ n() && this._onKey(e);
3288
+ }, t.addEventListener("keydown", this._onKeyBound), this._onDocClick = (e) => {
3289
+ let t = this._popClick;
3290
+ this._popClick = !1, n() && !t && !this.contains(e.target) && this._close();
3291
+ }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
3292
+ n() && e.key === "Escape" && this._close();
3293
+ }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
3294
+ n() && this._position(e, t);
3295
+ }), this._syncFormValue();
3296
+ }
3297
+ _teardown() {
3298
+ this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
3299
+ }
3300
+ disconnectedCallback() {
3301
+ this._teardown();
3302
+ }
3303
+ }, me = "image/png,image/jpeg,image/webp", he = 5, ge = {
2758
3304
  "image/png": [".png"],
2759
3305
  "image/jpeg": [".jpg", ".jpeg"],
2760
3306
  "image/webp": [".webp"],
2761
3307
  "image/gif": [".gif"],
2762
3308
  "image/svg+xml": [".svg"],
2763
3309
  "application/pdf": [".pdf"]
2764
- }, ce = {
3310
+ }, _e = {
2765
3311
  "image/png": "PNG",
2766
3312
  "image/jpeg": "JPG",
2767
3313
  "image/webp": "WEBP",
@@ -2775,7 +3321,7 @@ var G = class extends HTMLElement {
2775
3321
  ".gif": "GIF",
2776
3322
  ".svg": "SVG",
2777
3323
  ".pdf": "PDF"
2778
- }, X = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), Z = [
3324
+ }, Z = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), Q = [
2779
3325
  ".png",
2780
3326
  ".jpg",
2781
3327
  ".jpeg",
@@ -2786,44 +3332,44 @@ var G = class extends HTMLElement {
2786
3332
  ".avif",
2787
3333
  ".heic"
2788
3334
  ];
2789
- function le(e) {
3335
+ function ve(e) {
2790
3336
  if (!e) return !1;
2791
3337
  let t = typeof e == "object" && e.type ? String(e.type).toLowerCase() : "";
2792
3338
  if (t) return t.startsWith("image/");
2793
3339
  let n = typeof e == "string" ? e : e.name || e.url || "", r = String(n).toLowerCase();
2794
- return Z.some((e) => r.endsWith(e));
3340
+ return Q.some((e) => r.endsWith(e));
2795
3341
  }
2796
- function ue(e) {
2797
- let t = X(e);
2798
- return t.length ? t.every((e) => e.startsWith(".") ? Z.includes(e) : e === "image/*" || e.startsWith("image/")) : !1;
3342
+ function ye(e) {
3343
+ let t = Z(e);
3344
+ return t.length ? t.every((e) => e.startsWith(".") ? Q.includes(e) : e === "image/*" || e.startsWith("image/")) : !1;
2799
3345
  }
2800
- function Q(e) {
3346
+ function be(e) {
2801
3347
  let t = [];
2802
- for (let n of X(e)) {
2803
- let e = ce[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
3348
+ for (let n of Z(e)) {
3349
+ let e = _e[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
2804
3350
  t.includes(e) || t.push(e);
2805
3351
  }
2806
3352
  return t.length <= 1 ? t[0] || "supported" : `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
2807
3353
  }
2808
- function de(e, t) {
2809
- let n = X(t);
3354
+ function xe(e, t) {
3355
+ let n = Z(t);
2810
3356
  if (!n.length) return !0;
2811
3357
  let r = (e.type || "").toLowerCase(), i = (e.name || "").toLowerCase();
2812
- return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (se[e] || []).some((e) => i.endsWith(e)));
3358
+ return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (ge[e] || []).some((e) => i.endsWith(e)));
2813
3359
  }
2814
- function fe(e, t = {}) {
3360
+ function Se(e, t = {}) {
2815
3361
  if (!e) return null;
2816
- let n = t.accept === void 0 ? Y : t.accept, r = t.maxSizeMb || 5;
2817
- return de(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${Q(n)} file.`;
3362
+ let n = t.accept === void 0 ? me : t.accept, r = t.maxSizeMb || 5;
3363
+ return xe(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${be(n)} file.`;
2818
3364
  }
2819
3365
  //#endregion
2820
3366
  //#region src/index.js
2821
3367
  var $ = (e, t) => {
2822
3368
  typeof customElements < "u" && !customElements.get(e) && customElements.define(e, t);
2823
3369
  };
2824
- function pe() {
2825
- $("wui-select", q), $("wui-phone", G), $("wui-datepicker", w), $("wui-date-range", M), $("wui-autocomplete", p), $("wui-multiselect", N), $("wui-otp", F), $("wui-status-icon", n);
3370
+ function Ce() {
3371
+ $("wui-select", U), $("wui-phone", V), $("wui-datepicker", te), $("wui-date-range", A), $("wui-slider", G), $("wui-timepicker", pe), $("wui-autocomplete", p), $("wui-multiselect", j), $("wui-taginput", K), $("wui-otp", oe), $("wui-status-icon", n);
2826
3372
  }
2827
- pe();
3373
+ Ce();
2828
3374
  //#endregion
2829
- export { Y as DEFAULT_IMAGE_ACCEPT, oe as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, p as WuiAutocomplete, w as WuiDatePicker, M as WuiDateRange, N as WuiMultiSelect, F as WuiOtp, G as WuiPhone, q as WuiSelect, n as WuiStatusIcon, Q as acceptLabel, pe as defineWeborityElements, le as isImageFile, ue as isImageOnlyAccept, de as matchesAccept, fe as validateFile };
3375
+ export { me as DEFAULT_IMAGE_ACCEPT, he as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, p as WuiAutocomplete, te as WuiDatePicker, A as WuiDateRange, j as WuiMultiSelect, oe as WuiOtp, V as WuiPhone, U as WuiSelect, G as WuiSlider, n as WuiStatusIcon, K as WuiTagInput, pe as WuiTimePicker, be as acceptLabel, Ce as defineWeborityElements, ve as isImageFile, ye as isImageOnlyAccept, xe as matchesAccept, Se as validateFile };