stimulus_plumbers 0.2.2 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +38 -0
  3. data/README.md +57 -41
  4. data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.es.js +1628 -0
  5. data/app/assets/javascripts/stimulus-plumbers/stimulus-plumbers-controllers.umd.js +1 -0
  6. data/lib/stimulus_plumbers/components/combobox/autocomplete.rb +57 -0
  7. data/lib/stimulus_plumbers/components/combobox/date.rb +52 -0
  8. data/lib/stimulus_plumbers/components/combobox/dropdown.rb +41 -0
  9. data/lib/stimulus_plumbers/components/combobox/option.rb +27 -0
  10. data/lib/stimulus_plumbers/components/combobox/option_group.rb +52 -0
  11. data/lib/stimulus_plumbers/components/combobox/renderer.rb +78 -0
  12. data/lib/stimulus_plumbers/components/combobox/time.rb +103 -0
  13. data/lib/stimulus_plumbers/components/date_picker/navigation.rb +1 -1
  14. data/lib/stimulus_plumbers/components/plumber/html_options.rb +22 -3
  15. data/lib/stimulus_plumbers/components/time_picker/renderer.rb +38 -0
  16. data/lib/stimulus_plumbers/form/builder.rb +57 -12
  17. data/lib/stimulus_plumbers/form/field_component.rb +12 -10
  18. data/lib/stimulus_plumbers/form/fields/combobox.rb +41 -0
  19. data/lib/stimulus_plumbers/form/fields/password.rb +55 -0
  20. data/lib/stimulus_plumbers/form/fields/renderer.rb +1 -2
  21. data/lib/stimulus_plumbers/form/fields/search.rb +40 -0
  22. data/lib/stimulus_plumbers/form/fields/select.rb +8 -2
  23. data/lib/stimulus_plumbers/form/fields/text.rb +12 -4
  24. data/lib/stimulus_plumbers/helpers/combobox_helper.rb +74 -0
  25. data/lib/stimulus_plumbers/helpers.rb +2 -2
  26. data/lib/stimulus_plumbers/themes/{form.rb → base/form.rb} +6 -2
  27. data/lib/stimulus_plumbers/themes/base.rb +7 -7
  28. data/lib/stimulus_plumbers/themes/tailwind/form.rb +10 -6
  29. data/lib/stimulus_plumbers/version.rb +1 -1
  30. data/lib/stimulus_plumbers.rb +18 -1
  31. metadata +25 -15
  32. data/lib/stimulus_plumbers/components/date_picker/renderer.rb +0 -82
  33. data/lib/stimulus_plumbers/helpers/date_picker_helper.rb +0 -17
  34. /data/lib/stimulus_plumbers/themes/{action_list.rb → base/action_list.rb} +0 -0
  35. /data/lib/stimulus_plumbers/themes/{avatar.rb → base/avatar.rb} +0 -0
  36. /data/lib/stimulus_plumbers/themes/{button.rb → base/button.rb} +0 -0
  37. /data/lib/stimulus_plumbers/themes/{calendar.rb → base/calendar.rb} +0 -0
  38. /data/lib/stimulus_plumbers/themes/{card.rb → base/card.rb} +0 -0
  39. /data/lib/stimulus_plumbers/themes/{layout.rb → base/layout.rb} +0 -0
@@ -0,0 +1,1628 @@
1
+ import { Controller as e } from "@hotwired/stimulus";
2
+ //#region src/focus.js
3
+ var t = [
4
+ "a[href]",
5
+ "area[href]",
6
+ "button:not([disabled])",
7
+ "input:not([disabled])",
8
+ "select:not([disabled])",
9
+ "textarea:not([disabled])",
10
+ "[tabindex]:not([tabindex=\"-1\"])",
11
+ "audio[controls]",
12
+ "video[controls]",
13
+ "[contenteditable]:not([contenteditable=\"false\"])"
14
+ ].join(",");
15
+ function n(e) {
16
+ return Array.from(e.querySelectorAll(t)).filter((e) => r(e));
17
+ }
18
+ function r(e) {
19
+ return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
20
+ }
21
+ function i(e) {
22
+ let t = n(e);
23
+ return t.length > 0 ? (t[0].focus(), !0) : !1;
24
+ }
25
+ var a = class {
26
+ constructor(e, t = {}) {
27
+ this.container = e, this.previouslyFocused = null, this.options = t, this.isActive = !1;
28
+ }
29
+ activate() {
30
+ this.isActive || (this.previouslyFocused = document.activeElement, this.isActive = !0, this.options.initialFocus ? this.options.initialFocus.focus() : i(this.container), this.container.addEventListener("keydown", this.handleKeyDown));
31
+ }
32
+ deactivate() {
33
+ if (!this.isActive) return;
34
+ this.isActive = !1, this.container.removeEventListener("keydown", this.handleKeyDown);
35
+ let e = this.options.returnFocus || this.previouslyFocused;
36
+ e && r(e) && e.focus();
37
+ }
38
+ handleKeyDown = (e) => {
39
+ if (e.key === "Escape" && this.options.escapeDeactivates) {
40
+ e.preventDefault(), this.deactivate();
41
+ return;
42
+ }
43
+ if (e.key !== "Tab") return;
44
+ let t = n(this.container);
45
+ if (t.length === 0) return;
46
+ let r = t[0], i = t[t.length - 1];
47
+ e.shiftKey && document.activeElement === r ? (e.preventDefault(), i.focus()) : !e.shiftKey && document.activeElement === i && (e.preventDefault(), r.focus());
48
+ };
49
+ }, o = class {
50
+ constructor() {
51
+ this.savedElement = null;
52
+ }
53
+ save() {
54
+ this.savedElement = document.activeElement;
55
+ }
56
+ restore() {
57
+ this.savedElement && r(this.savedElement) && (this.savedElement.focus(), this.savedElement = null);
58
+ }
59
+ };
60
+ //#endregion
61
+ //#region src/keyboard.js
62
+ function s(e, t) {
63
+ return e.key === t;
64
+ }
65
+ function c(e) {
66
+ return e.key === "Enter" || e.key === " ";
67
+ }
68
+ function l(e) {
69
+ return [
70
+ "ArrowUp",
71
+ "ArrowDown",
72
+ "ArrowLeft",
73
+ "ArrowRight"
74
+ ].includes(e.key);
75
+ }
76
+ function u(e) {
77
+ e.preventDefault(), e.stopPropagation();
78
+ }
79
+ var d = class {
80
+ constructor(e, t = 0) {
81
+ this.items = e, this.currentIndex = t, this.updateTabIndex();
82
+ }
83
+ handleKeyDown(e) {
84
+ let t;
85
+ switch (e.key) {
86
+ case "ArrowDown":
87
+ case "ArrowRight":
88
+ e.preventDefault(), t = (this.currentIndex + 1) % this.items.length;
89
+ break;
90
+ case "ArrowUp":
91
+ case "ArrowLeft":
92
+ e.preventDefault(), t = this.currentIndex === 0 ? this.items.length - 1 : this.currentIndex - 1;
93
+ break;
94
+ case "Home":
95
+ e.preventDefault(), t = 0;
96
+ break;
97
+ case "End":
98
+ e.preventDefault(), t = this.items.length - 1;
99
+ break;
100
+ default: return;
101
+ }
102
+ this.setCurrentIndex(t);
103
+ }
104
+ setCurrentIndex(e) {
105
+ e >= 0 && e < this.items.length && (this.currentIndex = e, this.updateTabIndex(), this.items[e].focus());
106
+ }
107
+ updateTabIndex() {
108
+ this.items.forEach((e, t) => {
109
+ e.tabIndex = t === this.currentIndex ? 0 : -1;
110
+ });
111
+ }
112
+ updateItems(e) {
113
+ this.items = e, this.currentIndex = Math.min(this.currentIndex, e.length - 1), this.updateTabIndex();
114
+ }
115
+ }, f = (e, t, n) => {
116
+ let r = document.querySelector(`[data-live-region="${e}"]`);
117
+ return r || (r = document.createElement("div"), r.className = "sr-only", r.dataset.liveRegion = e, r.setAttribute("aria-live", e), r.setAttribute("aria-atomic", t.toString()), r.setAttribute("aria-relevant", n), document.body.appendChild(r)), r;
118
+ };
119
+ function p(e, t = {}) {
120
+ let { politeness: n = "polite", atomic: r = !0, relevant: i = "additions text" } = t, a = f(n, r, i);
121
+ a.textContent = "", setTimeout(() => {
122
+ a.textContent = e;
123
+ }, 100);
124
+ }
125
+ var m = (e = "a11y") => `${e}-${Math.random().toString(36).substr(2, 9)}`, h = (e, t = "element") => e.id ||= m(t), g = (e, t, n) => {
126
+ e.setAttribute(t, n.toString());
127
+ }, _ = (e, t) => g(e, "aria-expanded", t), v = (e, t) => g(e, "aria-pressed", t), ee = (e, t) => g(e, "aria-checked", t);
128
+ function te(e, t) {
129
+ g(e, "aria-disabled", t), t ? e.setAttribute("tabindex", "-1") : e.removeAttribute("tabindex");
130
+ }
131
+ var y = {
132
+ menu: "menu",
133
+ listbox: "listbox",
134
+ tree: "tree",
135
+ grid: "grid",
136
+ dialog: "dialog"
137
+ }, b = (e, t, n) => {
138
+ Object.entries(t).forEach(([t, r]) => {
139
+ e.setAttribute(t, r), n[t] = r;
140
+ });
141
+ }, x = (e, t, n) => n || !e.hasAttribute(t);
142
+ function S({ trigger: e, target: t, role: n = null, override: r = !1 }) {
143
+ let i = {
144
+ trigger: {},
145
+ target: {}
146
+ };
147
+ if (!e || !t) return i;
148
+ let a = {}, o = {};
149
+ if (n && x(t, "role", r) && (o.role = n), t.id && (x(e, "aria-controls", r) && (a["aria-controls"] = t.id), n === "tooltip" && x(e, "aria-describedby", r) && (a["aria-describedby"] = t.id)), n && x(e, "aria-haspopup", r)) {
150
+ let e = y[n] || "true";
151
+ e && (a["aria-haspopup"] = e);
152
+ }
153
+ return b(t, o, i.target), b(e, a, i.trigger), i;
154
+ }
155
+ var C = (e, t) => {
156
+ t.forEach((t) => {
157
+ e.hasAttribute(t) && e.removeAttribute(t);
158
+ });
159
+ };
160
+ function ne({ trigger: e, target: t, attributes: n = null }) {
161
+ !e || !t || (C(e, n || [
162
+ "aria-controls",
163
+ "aria-haspopup",
164
+ "aria-describedby"
165
+ ]), (!n || n.includes("role")) && C(t, ["role"]));
166
+ }
167
+ //#endregion
168
+ //#region src/plumbers/plumber/support.js
169
+ var w = {
170
+ get visibleOnly() {
171
+ return !0;
172
+ },
173
+ hiddenClass: null
174
+ }, T = {
175
+ get top() {
176
+ return "bottom";
177
+ },
178
+ get bottom() {
179
+ return "top";
180
+ },
181
+ get left() {
182
+ return "right";
183
+ },
184
+ get right() {
185
+ return "left";
186
+ }
187
+ };
188
+ function E({ x: e, y: t, width: n, height: r }) {
189
+ return {
190
+ x: e,
191
+ y: t,
192
+ width: n,
193
+ height: r,
194
+ left: e,
195
+ right: e + n,
196
+ top: t,
197
+ bottom: t + r
198
+ };
199
+ }
200
+ function D() {
201
+ return E({
202
+ x: 0,
203
+ y: 0,
204
+ width: window.innerWidth || document.documentElement.clientWidth,
205
+ height: window.innerHeight || document.documentElement.clientHeight
206
+ });
207
+ }
208
+ function re(e) {
209
+ if (!(e instanceof HTMLElement)) return !1;
210
+ let t = D(), n = e.getBoundingClientRect(), r = n.top <= t.height && n.top + n.height > 0, i = n.left <= t.width && n.left + n.width > 0;
211
+ return r && i;
212
+ }
213
+ function O(e) {
214
+ return e instanceof Date && !isNaN(e);
215
+ }
216
+ function k(...e) {
217
+ if (e.length === 0) throw "Missing values to parse as date";
218
+ if (e.length === 1) {
219
+ let t = new Date(e[0]);
220
+ if (e[0] && O(t)) return t;
221
+ } else {
222
+ let t = new Date(...e);
223
+ if (O(t)) return t;
224
+ }
225
+ }
226
+ //#endregion
227
+ //#region src/plumbers/plumber/index.js
228
+ var ie = {
229
+ element: null,
230
+ visible: null,
231
+ dispatch: !0,
232
+ prefix: ""
233
+ }, A = class {
234
+ constructor(e, t = {}) {
235
+ this.controller = e;
236
+ let { element: n, visible: r, dispatch: i, prefix: a } = Object.assign({}, ie, t);
237
+ this.element = n || e.element, this.visibleOnly = typeof r == "boolean" ? r : w.visibleOnly, this.visibleCallback = typeof r == "string" ? r : null, this.notify = !!i, this.prefix = typeof a == "string" && a ? a : e.identifier;
238
+ }
239
+ get visible() {
240
+ return this.element instanceof HTMLElement ? this.visibleOnly ? re(this.element) && this.isVisible(this.element) : !0 : !1;
241
+ }
242
+ isVisible(e) {
243
+ if (this.visibleCallback) {
244
+ let t = this.findCallback(this.visibleCallback);
245
+ if (typeof t == "function") return t(e);
246
+ }
247
+ return e instanceof HTMLElement ? !e.hasAttribute("hidden") : !1;
248
+ }
249
+ dispatch(e, { target: t = null, prefix: n = null, detail: r = null } = {}) {
250
+ if (this.notify) return this.controller.dispatch(e, {
251
+ target: t || this.element,
252
+ prefix: n || this.prefix,
253
+ detail: r
254
+ });
255
+ }
256
+ findCallback(e) {
257
+ if (typeof e != "string") return;
258
+ let t = this, n = e.split(".").reduce((e, t) => e && e[t], t.controller);
259
+ if (typeof n == "function") return n.bind(t.controller);
260
+ let r = e.split(".").reduce((e, t) => e && e[t], t);
261
+ if (typeof r == "function") return r.bind(t);
262
+ }
263
+ async awaitCallback(e, ...t) {
264
+ if (typeof e == "string" && (e = this.findCallback(e)), typeof e == "function") {
265
+ let n = e(...t);
266
+ return n instanceof Promise ? await n : n;
267
+ }
268
+ }
269
+ }, j = 7, M = {
270
+ locales: ["default"],
271
+ today: "",
272
+ day: null,
273
+ month: null,
274
+ year: null,
275
+ since: null,
276
+ till: null,
277
+ disabledDates: [],
278
+ disabledWeekdays: [],
279
+ disabledDays: [],
280
+ disabledMonths: [],
281
+ disabledYears: [],
282
+ firstDayOfWeek: 0,
283
+ onNavigated: "navigated"
284
+ }, ae = class extends A {
285
+ constructor(e, t = {}) {
286
+ super(e, t);
287
+ let n = Object.assign({}, M, t), { onNavigated: r, since: i, till: a, firstDayOfWeek: o } = n;
288
+ this.onNavigated = r, this.since = k(i), this.till = k(a), this.firstDayOfWeek = 0 <= o && o < 7 ? o : M.firstDayOfWeek;
289
+ let { disabledDates: s, disabledWeekdays: c, disabledDays: l, disabledMonths: u, disabledYears: d } = n;
290
+ this.disabledDates = Array.isArray(s) ? s : [], this.disabledWeekdays = Array.isArray(c) ? c : [], this.disabledDays = Array.isArray(l) ? l : [], this.disabledMonths = Array.isArray(u) ? u : [], this.disabledYears = Array.isArray(d) ? d : [];
291
+ let { today: f, day: p, month: m, year: h } = n;
292
+ this.now = k(f) || /* @__PURE__ */ new Date(), typeof h == "number" && typeof m == "number" && typeof p == "number" ? this.current = k(h, m, p) : this.current = this.now, this.build(), this.enhance();
293
+ }
294
+ build() {
295
+ this.daysOfWeek = this.buildDaysOfWeek(), this.daysOfMonth = this.buildDaysOfMonth(), this.monthsOfYear = this.buildMonthsOfYear();
296
+ }
297
+ buildDaysOfWeek() {
298
+ let e = new Intl.DateTimeFormat(this.localesValue, { weekday: "long" }), t = new Intl.DateTimeFormat(this.localesValue, { weekday: "short" }), n = /* @__PURE__ */ new Date("2024-10-06"), r = [];
299
+ for (let i = this.firstDayOfWeek, a = i + 7; i < a; i++) {
300
+ let a = new Date(n);
301
+ a.setDate(n.getDate() + i), r.push({
302
+ date: a,
303
+ value: a.getDay(),
304
+ long: e.format(a),
305
+ short: t.format(a)
306
+ });
307
+ }
308
+ return r;
309
+ }
310
+ buildDaysOfMonth() {
311
+ let e = this.month, t = this.year, n = [], r = (e) => ({
312
+ current: this.month === e.getMonth() && this.year === e.getFullYear(),
313
+ date: e,
314
+ value: e.getDate(),
315
+ month: e.getMonth(),
316
+ year: e.getFullYear(),
317
+ iso: e.toISOString()
318
+ }), i = new Date(t, e).getDay(), a = this.firstDayOfWeek - i;
319
+ for (let i = a > 0 ? a - 7 : a; i < 0; i++) {
320
+ let a = new Date(t, e, i + 1);
321
+ n.push(r(a));
322
+ }
323
+ let o = new Date(t, e + 1, 0).getDate();
324
+ for (let i = 1; i <= o; i++) {
325
+ let a = new Date(t, e, i);
326
+ n.push(r(a));
327
+ }
328
+ let s = n.length % j, c = s === 0 ? 0 : j - s;
329
+ for (let i = 1; i <= c; i++) {
330
+ let a = new Date(t, e + 1, i);
331
+ n.push(r(a));
332
+ }
333
+ return n;
334
+ }
335
+ buildMonthsOfYear() {
336
+ let e = new Intl.DateTimeFormat(this.localesValue, { month: "long" }), t = new Intl.DateTimeFormat(this.localesValue, { month: "short" }), n = new Intl.DateTimeFormat(this.localesValue, { month: "numeric" }), r = [];
337
+ for (let i = 0; i < 12; i++) {
338
+ let a = new Date(this.year, i);
339
+ r.push({
340
+ date: a,
341
+ value: a.getMonth(),
342
+ long: e.format(a),
343
+ short: t.format(a),
344
+ numeric: n.format(a)
345
+ });
346
+ }
347
+ return r;
348
+ }
349
+ get today() {
350
+ return this.now;
351
+ }
352
+ set today(e) {
353
+ if (!O(e)) return;
354
+ let t = this.month ? this.month : e.getMonth(), n = this.year ? this.year : e.getFullYear(), r = t == e.getMonth() && n == e.getFullYear(), i = this.hasDayValue ? this.day : r ? e.getDate() : 1;
355
+ this.now = new Date(n, t, i).toISOString();
356
+ }
357
+ get current() {
358
+ return typeof this.year == "number" && typeof this.month == "number" && typeof this.day == "number" ? k(this.year, this.month, this.day) : null;
359
+ }
360
+ set current(e) {
361
+ O(e) && (this.day = e.getDate(), this.month = e.getMonth(), this.year = e.getFullYear());
362
+ }
363
+ navigate = async (e) => {
364
+ if (!O(e)) return;
365
+ let t = this.current, n = e.toISOString(), r = t.toISOString();
366
+ this.dispatch("navigate", { detail: {
367
+ from: r,
368
+ to: n
369
+ } }), this.current = e, this.build(), await this.awaitCallback(this.onNavigated, {
370
+ from: r,
371
+ to: n
372
+ }), this.dispatch("navigated", { detail: {
373
+ from: r,
374
+ to: n
375
+ } });
376
+ };
377
+ step = async (e, t) => {
378
+ if (t === 0) return;
379
+ let n = this.current;
380
+ switch (e) {
381
+ case "year":
382
+ n.setFullYear(n.getFullYear() + t);
383
+ break;
384
+ case "month":
385
+ n.setMonth(n.getMonth() + t);
386
+ break;
387
+ case "day":
388
+ n.setDate(n.getDate() + t);
389
+ break;
390
+ default: return;
391
+ }
392
+ await this.navigate(n);
393
+ };
394
+ isDisabled = (e) => {
395
+ if (!O(e)) return !1;
396
+ if (this.disabledDates.length) {
397
+ let t = e.getTime();
398
+ for (let e of this.disabledDates) if (t === new Date(e).getTime()) return !0;
399
+ }
400
+ if (this.disabledWeekdays.length) {
401
+ let t = e.getDay(), n = this.daysOfWeek, r = n.findIndex((e) => e.value === t);
402
+ if (r >= 0) {
403
+ let e = n[r];
404
+ for (let t of this.disabledWeekdays) if (e.value == t || e.short === t || e.long === t) return !0;
405
+ }
406
+ }
407
+ if (this.disabledDays.length) {
408
+ let t = e.getDate();
409
+ for (let e of this.disabledDays) if (t == e) return !0;
410
+ }
411
+ if (this.disabledMonths.length) {
412
+ let t = e.getMonth(), n = this.monthsOfYear, r = n.findIndex((e) => e.value === t);
413
+ if (r >= 0) {
414
+ let e = n[r];
415
+ for (let t of this.disabledMonths) if (e.value == t || e.short === t || e.long === t) return !0;
416
+ }
417
+ }
418
+ if (this.disabledYears.length) {
419
+ let t = e.getFullYear();
420
+ for (let e of this.disabledYears) if (t == e) return !0;
421
+ }
422
+ return !1;
423
+ };
424
+ isWithinRange = (e) => {
425
+ if (!O(e)) return !1;
426
+ let t = !0;
427
+ return this.since && (t &&= e >= this.since), this.till && (t &&= e <= this.till), t;
428
+ };
429
+ enhance() {
430
+ let e = this;
431
+ Object.assign(this.controller, { get calendar() {
432
+ return {
433
+ get today() {
434
+ return e.today;
435
+ },
436
+ get current() {
437
+ return e.current;
438
+ },
439
+ get day() {
440
+ return e.day;
441
+ },
442
+ get month() {
443
+ return e.month;
444
+ },
445
+ get year() {
446
+ return e.year;
447
+ },
448
+ get since() {
449
+ return e.since;
450
+ },
451
+ get till() {
452
+ return e.till;
453
+ },
454
+ get firstDayOfWeek() {
455
+ return e.firstDayOfWeek;
456
+ },
457
+ get disabledDates() {
458
+ return e.disabledDates;
459
+ },
460
+ get disabledWeekdays() {
461
+ return e.disabledWeekdays;
462
+ },
463
+ get disabledDays() {
464
+ return e.disabledDays;
465
+ },
466
+ get disabledMonths() {
467
+ return e.disabledMonths;
468
+ },
469
+ get disabledYears() {
470
+ return e.disabledYears;
471
+ },
472
+ get daysOfWeek() {
473
+ return e.daysOfWeek;
474
+ },
475
+ get daysOfMonth() {
476
+ return e.daysOfMonth;
477
+ },
478
+ get monthsOfYear() {
479
+ return e.monthsOfYear;
480
+ },
481
+ navigate: async (t) => await e.navigate(t),
482
+ step: async (t, n) => await e.step(t, n),
483
+ isDisabled: (t) => e.isDisabled(t),
484
+ isWithinRange: (t) => e.isWithinRange(t)
485
+ };
486
+ } });
487
+ }
488
+ }, oe = (e, t) => new ae(e, t), se = class extends A {
489
+ constructor(e, t = {}) {
490
+ super(e, t), this.debounceTimer = null, this.abortController = null;
491
+ }
492
+ fuzzyFilter(e, t) {
493
+ let n = t.toLowerCase(), r = 0;
494
+ return e.querySelectorAll("[role=\"option\"]").forEach((e) => {
495
+ let t = this.fuzzyMatch(n, e.textContent.trim().toLowerCase());
496
+ e.hidden = !t, t && r++;
497
+ }), r;
498
+ }
499
+ fuzzyMatch(e, t) {
500
+ let n = 0;
501
+ for (let r = 0; r < t.length && n < e.length; r++) t[r] === e[n] && n++;
502
+ return n === e.length;
503
+ }
504
+ scheduleFetch(e, t, n) {
505
+ clearTimeout(this.debounceTimer), this.debounceTimer = setTimeout(() => this.fetch(e, n), t);
506
+ }
507
+ async fetch(e, { url: t, field: n, onLoading: r, onLoaded: i, onError: a }) {
508
+ this.abortController?.abort(), this.abortController = new AbortController(), r?.(!0);
509
+ let o = new URL(t, window.location.href);
510
+ o.searchParams.set(n, e);
511
+ try {
512
+ let e = await fetch(o, {
513
+ signal: this.abortController.signal,
514
+ headers: {
515
+ Accept: "text/html",
516
+ "X-Requested-With": "XMLHttpRequest"
517
+ }
518
+ });
519
+ if (!e.ok) throw Error(`${e.status}`);
520
+ i?.(await e.text());
521
+ } catch (e) {
522
+ e.name !== "AbortError" && a?.(e);
523
+ } finally {
524
+ r?.(!1);
525
+ }
526
+ }
527
+ cancel() {
528
+ clearTimeout(this.debounceTimer), this.abortController?.abort();
529
+ }
530
+ }, ce = (e, t) => new se(e, t), N = {
531
+ content: null,
532
+ url: "",
533
+ reload: "never",
534
+ stale: 3600,
535
+ onLoad: "canLoad",
536
+ onLoading: "contentLoading",
537
+ onLoaded: "contentLoaded"
538
+ }, le = class extends A {
539
+ constructor(e, t = {}) {
540
+ super(e, t);
541
+ let n = Object.assign({}, N, t), { content: r, url: i, reload: a, stale: o } = n;
542
+ this.content = r, this.url = i, this.reload = typeof a == "string" ? a : N.reload, this.stale = typeof o == "number" ? o : N.stale;
543
+ let { onLoad: s, onLoading: c, onLoaded: l } = n;
544
+ this.onLoad = s, this.onLoading = c, this.onLoaded = l, this.enhance();
545
+ }
546
+ get reloadable() {
547
+ switch (this.reload) {
548
+ case "never": return !1;
549
+ case "always": return !0;
550
+ default: {
551
+ let e = k(this.loadedAt);
552
+ return e && /* @__PURE__ */ new Date() - e > this.stale * 1e3;
553
+ }
554
+ }
555
+ }
556
+ contentLoadable = ({ url: e }) => !!e;
557
+ contentLoading = async ({ url: e }) => e ? await this.remoteContentLoader(e) : await this.contentLoader();
558
+ contentLoader = async () => "";
559
+ remoteContentLoader = async (e) => (await fetch(e)).text();
560
+ load = async () => {
561
+ if (this.loadedAt && !this.reloadable) return;
562
+ let e = this.findCallback(this.onLoad), t = await this.awaitCallback(e || this.contentLoadable, { url: this.url });
563
+ if (this.dispatch("load", { detail: { url: this.url } }), !t) return;
564
+ let n = this.url ? await this.remoteContentLoader(this.url) : await this.contentLoader();
565
+ this.dispatch("loading", { detail: { url: this.url } }), n && (await this.awaitCallback(this.onLoaded, {
566
+ url: this.url,
567
+ content: n
568
+ }), this.loadedAt = (/* @__PURE__ */ new Date()).getTime(), this.dispatch("loaded", { detail: {
569
+ url: this.url,
570
+ content: n
571
+ } }));
572
+ };
573
+ enhance() {
574
+ let e = this;
575
+ Object.assign(this.controller, { load: e.load.bind(e) });
576
+ }
577
+ }, ue = (e, t) => new le(e, t), de = {
578
+ trigger: null,
579
+ events: ["click"],
580
+ onDismissed: "dismissed"
581
+ }, fe = class extends A {
582
+ constructor(e, t = {}) {
583
+ super(e, t);
584
+ let { trigger: n, events: r, onDismissed: i } = Object.assign({}, de, t);
585
+ this.onDismissed = i, this.trigger = n || this.element, this.events = r, this.enhance(), this.observe();
586
+ }
587
+ dismiss = async (e) => {
588
+ let { target: t } = e;
589
+ t instanceof HTMLElement && (this.element.contains(t) || this.visible && (this.dispatch("dismiss"), await this.awaitCallback(this.onDismissed, { target: this.trigger }), this.dispatch("dismissed")));
590
+ };
591
+ observe() {
592
+ this.events.forEach((e) => {
593
+ window.addEventListener(e, this.dismiss, !0);
594
+ });
595
+ }
596
+ unobserve() {
597
+ this.events.forEach((e) => {
598
+ window.removeEventListener(e, this.dismiss, !0);
599
+ });
600
+ }
601
+ enhance() {
602
+ let e = this, t = e.controller.disconnect.bind(e.controller);
603
+ Object.assign(this.controller, { disconnect: () => {
604
+ e.unobserve(), t();
605
+ } });
606
+ }
607
+ }, P = (e, t) => new fe(e, t), F = {
608
+ anchor: null,
609
+ events: ["click"],
610
+ placement: "bottom",
611
+ alignment: "start",
612
+ onFlipped: "flipped",
613
+ ariaRole: null,
614
+ respectMotion: !0
615
+ }, I = class extends A {
616
+ constructor(e, t = {}) {
617
+ super(e, t);
618
+ let { anchor: n, events: r, placement: i, alignment: a, onFlipped: o, ariaRole: s, respectMotion: c } = Object.assign({}, F, t);
619
+ this.anchor = n, this.events = r, this.placement = i, this.alignment = a, this.onFlipped = o, this.ariaRole = s, this.respectMotion = c, this.prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.anchor && this.element && S({
620
+ trigger: this.anchor,
621
+ target: this.element,
622
+ role: this.ariaRole
623
+ }), this.enhance(), this.observe();
624
+ }
625
+ flip = async () => {
626
+ if (!this.visible) return;
627
+ this.dispatch("flip"), window.getComputedStyle(this.element).position != "absolute" && (this.element.style.position = "absolute");
628
+ let e = this.flippedRect(this.anchor.getBoundingClientRect(), this.element.getBoundingClientRect());
629
+ this.element.style.transition = this.respectMotion && this.prefersReducedMotion ? "none" : "";
630
+ for (let [t, n] of Object.entries(e)) this.element.style[t] = n;
631
+ await this.awaitCallback(this.onFlipped, {
632
+ target: this.element,
633
+ placement: e
634
+ }), this.dispatch("flipped", { detail: { placement: e } });
635
+ };
636
+ flippedRect(e, t) {
637
+ let n = this.quadrumRect(e, D()), r = [this.placement, T[this.placement]], i = {};
638
+ for (; !Object.keys(i).length && r.length > 0;) {
639
+ let a = r.shift();
640
+ if (!this.biggerRectThan(n[a], t)) continue;
641
+ let o = this.quadrumPlacement(e, a, t), s = this.quadrumAlignment(e, a, o);
642
+ i.top = `${s.top + window.scrollY}px`, i.left = `${s.left + window.scrollX}px`;
643
+ }
644
+ return Object.keys(i).length || (i.top = "", i.left = ""), i;
645
+ }
646
+ quadrumRect(e, t) {
647
+ return {
648
+ left: E({
649
+ x: t.x,
650
+ y: t.y,
651
+ width: e.x - t.x,
652
+ height: t.height
653
+ }),
654
+ right: E({
655
+ x: e.x + e.width,
656
+ y: t.y,
657
+ width: t.width - (e.x + e.width),
658
+ height: t.height
659
+ }),
660
+ top: E({
661
+ x: t.x,
662
+ y: t.y,
663
+ width: t.width,
664
+ height: e.y - t.y
665
+ }),
666
+ bottom: E({
667
+ x: t.x,
668
+ y: e.y + e.height,
669
+ width: t.width,
670
+ height: t.height - (e.y + e.height)
671
+ })
672
+ };
673
+ }
674
+ quadrumPlacement(e, t, n) {
675
+ switch (t) {
676
+ case "top": return E({
677
+ x: n.x,
678
+ y: e.y - n.height,
679
+ width: n.width,
680
+ height: n.height
681
+ });
682
+ case "bottom": return E({
683
+ x: n.x,
684
+ y: e.y + e.height,
685
+ width: n.width,
686
+ height: n.height
687
+ });
688
+ case "left": return E({
689
+ x: e.x - n.width,
690
+ y: n.y,
691
+ width: n.width,
692
+ height: n.height
693
+ });
694
+ case "right": return E({
695
+ x: e.x + e.width,
696
+ y: n.y,
697
+ width: n.width,
698
+ height: n.height
699
+ });
700
+ default: throw `Unable place at the quadrum, ${t}`;
701
+ }
702
+ }
703
+ quadrumAlignment(e, t, n) {
704
+ switch (t) {
705
+ case "top":
706
+ case "bottom": {
707
+ let t = e.x;
708
+ return this.alignment === "center" ? t = e.x + e.width / 2 - n.width / 2 : this.alignment === "end" && (t = e.x + e.width - n.width), E({
709
+ x: t,
710
+ y: n.y,
711
+ width: n.width,
712
+ height: n.height
713
+ });
714
+ }
715
+ case "left":
716
+ case "right": {
717
+ let t = e.y;
718
+ return this.alignment === "center" ? t = e.y + e.height / 2 - n.height / 2 : this.alignment === "end" && (t = e.y + e.height - n.height), E({
719
+ x: n.x,
720
+ y: t,
721
+ width: n.width,
722
+ height: n.height
723
+ });
724
+ }
725
+ default: throw `Unable align at the quadrum, ${t}`;
726
+ }
727
+ }
728
+ biggerRectThan(e, t) {
729
+ return e.height >= t.height && e.width >= t.width;
730
+ }
731
+ observe() {
732
+ this.events.forEach((e) => {
733
+ window.addEventListener(e, this.flip, !0);
734
+ });
735
+ }
736
+ unobserve() {
737
+ this.events.forEach((e) => {
738
+ window.removeEventListener(e, this.flip, !0);
739
+ });
740
+ }
741
+ enhance() {
742
+ let e = this, t = e.controller.disconnect.bind(e.controller);
743
+ Object.assign(this.controller, {
744
+ disconnect: () => {
745
+ e.unobserve(), t();
746
+ },
747
+ flip: e.flip.bind(e)
748
+ });
749
+ }
750
+ }, L = (e, t) => new I(e, t), R = {
751
+ normalize(e) {
752
+ return typeof e == "string" ? e : "";
753
+ },
754
+ validate() {
755
+ return !0;
756
+ }
757
+ };
758
+ //#endregion
759
+ //#region src/plumbers/input_format/formatters/credit_card.js
760
+ function z(e) {
761
+ let t = 0, n = !1;
762
+ for (let r = e.length - 1; r >= 0; r--) {
763
+ let i = parseInt(e[r], 10);
764
+ n && (i *= 2, i > 9 && (i -= 9)), t += i, n = !n;
765
+ }
766
+ return t % 10 == 0;
767
+ }
768
+ var B = /\D/g, V = /^\d{13,19}$/, pe = /(.{4})(?=.)/g, me = {
769
+ normalize(e) {
770
+ return typeof e == "string" ? e.replace(B, "") : "";
771
+ },
772
+ validate(e) {
773
+ return typeof e != "string" || !V.test(e) ? !1 : z(e);
774
+ },
775
+ format(e) {
776
+ return typeof e == "string" ? e.replace(pe, "$1 ") : "";
777
+ }
778
+ }, H = { 1: 10 }, U = /\D/g, he = /^\+\d{7,15}$/, ge = {
779
+ normalize(e) {
780
+ if (typeof e != "string") return "";
781
+ let t = e.trimStart().startsWith("+"), n = e.replace(U, "");
782
+ return t ? `+${n}` : n;
783
+ },
784
+ validate(e) {
785
+ if (typeof e != "string") return !1;
786
+ if (he.test(e)) return !0;
787
+ let t = e.replace(U, "");
788
+ return Object.values(H).includes(t.length);
789
+ },
790
+ format(e) {
791
+ if (typeof e != "string") return "";
792
+ let t = e.replace(U, "");
793
+ for (let [e, n] of Object.entries(H)) {
794
+ if (t.length === n) return `(${t.slice(0, 3)}) ${t.slice(3, 6)}-${t.slice(6)}`;
795
+ let r = n + e.length;
796
+ if (t.length === r && t.startsWith(e)) {
797
+ let n = t.slice(e.length);
798
+ return `+${e} (${n.slice(0, 3)}) ${n.slice(3, 6)}-${n.slice(6)}`;
799
+ }
800
+ }
801
+ return e;
802
+ }
803
+ }, _e = /[^\d.,-]/g, ve = /^-?\d+(\.\d+)?$/, ye = {
804
+ normalize(e) {
805
+ if (typeof e != "string") return "";
806
+ let t = e.replace(_e, "");
807
+ if (!t) return "";
808
+ let n = t.lastIndexOf(","), r = t.lastIndexOf(".");
809
+ return n > -1 && r > -1 ? n > r ? t.replace(/\./g, "").replace(",", ".") : t.replace(/,/g, "") : n > -1 ? t.slice(n + 1).length <= 2 ? t.replace(",", ".") : t.replace(/,/g, "") : t;
810
+ },
811
+ validate(e) {
812
+ return typeof e == "string" ? ve.test(e) : !1;
813
+ },
814
+ format(e, t = {}) {
815
+ if (typeof e != "string") return "";
816
+ let n = parseFloat(e);
817
+ if (isNaN(n)) return e;
818
+ let r = t.locale || "en-US", i = t.currency || "USD", a = t.fractionDigits === void 0 ? {} : {
819
+ minimumFractionDigits: t.fractionDigits,
820
+ maximumFractionDigits: t.fractionDigits
821
+ };
822
+ try {
823
+ return new Intl.NumberFormat(r, {
824
+ style: "currency",
825
+ currency: i,
826
+ ...a
827
+ }).format(n);
828
+ } catch {
829
+ return e;
830
+ }
831
+ }
832
+ }, W = /^\d{4}-\d{2}-\d{2}$/, be = /^(\d{1,4})[/\-.](\d{1,2})[/\-.](\d{1,4})$/, xe = /\D/g, G = {
833
+ normalize(e) {
834
+ if (typeof e != "string") return "";
835
+ let t = e.trim();
836
+ if (W.test(t)) return t;
837
+ let n = t.match(be);
838
+ if (n) {
839
+ let [, e, t, r] = n;
840
+ if (e.length === 4) return `${e}-${t.padStart(2, "0")}-${r.padStart(2, "0")}`;
841
+ if (r.length === 4) return `${r}-${e.padStart(2, "0")}-${t.padStart(2, "0")}`;
842
+ }
843
+ let r = t.replace(xe, "");
844
+ if (r.length === 8) {
845
+ let e = parseInt(r.slice(0, 4), 10);
846
+ return e >= 1e3 && e <= 9999 ? `${r.slice(0, 4)}-${r.slice(4, 6)}-${r.slice(6, 8)}` : `${r.slice(4, 8)}-${r.slice(0, 2)}-${r.slice(2, 4)}`;
847
+ }
848
+ return t;
849
+ },
850
+ validate(e) {
851
+ if (typeof e != "string") return !1;
852
+ let t = G.normalize(e);
853
+ if (!W.test(t)) return !1;
854
+ let n = /* @__PURE__ */ new Date(`${t}T00:00:00Z`);
855
+ return !isNaN(n.getTime()) && n.toISOString().startsWith(t);
856
+ },
857
+ format(e, t = {}) {
858
+ if (typeof e != "string") return "";
859
+ let n = /* @__PURE__ */ new Date(`${e}T00:00:00Z`);
860
+ if (isNaN(n.getTime())) return e;
861
+ let r = t.locale || "en-US";
862
+ try {
863
+ return new Intl.DateTimeFormat(r, {
864
+ year: t.year || "numeric",
865
+ month: t.month || "2-digit",
866
+ day: t.day || "2-digit",
867
+ timeZone: t.timeZone || "UTC"
868
+ }).format(n);
869
+ } catch {
870
+ return e;
871
+ }
872
+ }
873
+ }, Se = /^([01]?\d|2[0-3]):([0-5]\d)$/, K = {
874
+ normalize(e) {
875
+ if (typeof e != "string") return "";
876
+ let t = e.trim();
877
+ if (Se.test(t)) {
878
+ let [e, n] = t.split(":");
879
+ return `${String(parseInt(e, 10)).padStart(2, "0")}:${n}`;
880
+ }
881
+ let n = t.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);
882
+ if (n) {
883
+ let e = parseInt(n[1], 10), t = n[2];
884
+ return e = n[3].toUpperCase() === "AM" ? e === 12 ? 0 : e : e === 12 ? 12 : e + 12, e > 23 || parseInt(t, 10) > 59 ? "" : `${String(e).padStart(2, "0")}:${t}`;
885
+ }
886
+ return "";
887
+ },
888
+ validate(e) {
889
+ return K.normalize(e) !== "";
890
+ },
891
+ format(e, t = {}) {
892
+ if (typeof e != "string") return "";
893
+ let n = e.match(/^(\d{2}):(\d{2})$/);
894
+ if (!n) return e;
895
+ let r = parseInt(n[1], 10), i = n[2];
896
+ if (t.format === "h24") return `${String(r).padStart(2, "0")}:${i}`;
897
+ let a = r < 12 ? "AM" : "PM";
898
+ return `${r % 12 || 12}:${i} ${a}`;
899
+ }
900
+ }, q = {
901
+ PLAIN: "plain",
902
+ CREDIT_CARD: "creditCard",
903
+ PHONE: "phone",
904
+ CURRENCY: "currency",
905
+ DATE: "date",
906
+ TIME: "time"
907
+ }, J = new Map([
908
+ [q.PLAIN, R],
909
+ [q.CREDIT_CARD, me],
910
+ [q.PHONE, ge],
911
+ [q.CURRENCY, ye],
912
+ [q.DATE, G],
913
+ [q.TIME, K]
914
+ ]), Y = {
915
+ type: q.PLAIN,
916
+ options: {}
917
+ }, Ce = class extends A {
918
+ static register(e, t) {
919
+ J.set(e, t);
920
+ }
921
+ constructor(e, t = {}) {
922
+ super(e, t), this.type = t.type ?? Y.type, this.options = t.options ?? Y.options, this.enhance();
923
+ }
924
+ enhance() {
925
+ let e = this, t = J.get(e.type) ?? J.get(q.PLAIN), n = {
926
+ normalize: (n) => t.normalize?.(n, e.options) ?? (typeof n == "string" ? n : ""),
927
+ validate: (n) => t.validate?.(n, e.options) ?? !0,
928
+ format: (n) => t.format?.(n, e.options) ?? (typeof n == "string" ? n : ""),
929
+ mask: (n) => t.mask?.(n, e.options) ?? null,
930
+ maskable: () => typeof t.mask == "function"
931
+ };
932
+ Object.defineProperty(this.controller, "inputFormat", {
933
+ get() {
934
+ return n;
935
+ },
936
+ configurable: !0
937
+ });
938
+ }
939
+ }, X = (e, t) => new Ce(e, t), we = {
940
+ events: ["resize"],
941
+ boundaries: [
942
+ "top",
943
+ "left",
944
+ "right"
945
+ ],
946
+ onShifted: "shifted",
947
+ respectMotion: !0
948
+ }, Te = class extends A {
949
+ constructor(e, t = {}) {
950
+ super(e, t);
951
+ let { onShifted: n, events: r, boundaries: i, respectMotion: a } = Object.assign({}, we, t);
952
+ this.onShifted = n, this.events = r, this.boundaries = i, this.respectMotion = a, this.prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.enhance(), this.observe();
953
+ }
954
+ shift = async () => {
955
+ if (!this.visible) return;
956
+ this.dispatch("shift");
957
+ let e = this.overflowRect(this.element.getBoundingClientRect(), this.elementTranslations(this.element)), t = e.left || e.right || 0, n = e.top || e.bottom || 0;
958
+ this.element.style.transition = this.respectMotion && this.prefersReducedMotion ? "none" : "", this.element.style.transform = `translate(${t}px, ${n}px)`, await this.awaitCallback(this.onShifted, e), this.dispatch("shifted", { detail: e });
959
+ };
960
+ overflowRect(e, t) {
961
+ let n = {}, r = D(), i = E({
962
+ x: e.x - t.x,
963
+ y: e.y - t.y,
964
+ width: e.width,
965
+ height: e.height
966
+ });
967
+ for (let e of this.boundaries) {
968
+ let t = this.directionDistance(i, e, r), a = T[e];
969
+ t < 0 ? i[a] + t >= r[a] && !n[a] && (n[e] = t) : n[e] = "";
970
+ }
971
+ return n;
972
+ }
973
+ directionDistance(e, t, n) {
974
+ switch (t) {
975
+ case "top":
976
+ case "left": return e[t] - n[t];
977
+ case "bottom":
978
+ case "right": return n[t] - e[t];
979
+ default: throw `Invalid direction to calcuate distance, ${t}`;
980
+ }
981
+ }
982
+ elementTranslations(e) {
983
+ let t = window.getComputedStyle(e), n = t.transform || t.webkitTransform || t.mozTransform;
984
+ if (n === "none" || n === void 0) return {
985
+ x: 0,
986
+ y: 0
987
+ };
988
+ let r = n.includes("3d") ? "3d" : "2d", i = n.match(/matrix.*\((.+)\)/)[1].split(", ");
989
+ return r === "2d" ? {
990
+ x: Number(i[4]),
991
+ y: Number(i[5])
992
+ } : {
993
+ x: 0,
994
+ y: 0
995
+ };
996
+ }
997
+ observe() {
998
+ this.events.forEach((e) => {
999
+ window.addEventListener(e, this.shift, !0);
1000
+ });
1001
+ }
1002
+ unobserve() {
1003
+ this.events.forEach((e) => {
1004
+ window.removeEventListener(e, this.shift, !0);
1005
+ });
1006
+ }
1007
+ enhance() {
1008
+ let e = this, t = e.controller.disconnect.bind(e.controller);
1009
+ Object.assign(this.controller, {
1010
+ disconnect: () => {
1011
+ e.unobserve(), t();
1012
+ },
1013
+ shift: e.shift.bind(e)
1014
+ });
1015
+ }
1016
+ }, Ee = (e, t) => new Te(e, t), Z = {
1017
+ visibility: "visibility",
1018
+ onShown: "shown",
1019
+ onHidden: "hidden"
1020
+ }, De = class extends A {
1021
+ constructor(e, t = {}) {
1022
+ let { visibility: n, onShown: r, onHidden: i, activator: a } = Object.assign({}, Z, t), o = typeof n == "string" ? n : Z.namespace, s = typeof t.visible == "string" ? t.visible : "isVisible";
1023
+ (typeof t.visible != "boolean" || t.visible) && (t.visible = `${o}.${s}`), super(e, t), this.visibility = o, this.visibilityResolver = s, this.onShown = r, this.onHidden = i, this.activator = a instanceof HTMLElement ? a : null, this.enhance(), this.element instanceof HTMLElement && this.activate(this.isVisible(this.element));
1024
+ }
1025
+ isVisible(e) {
1026
+ if (!(e instanceof HTMLElement)) return !1;
1027
+ let t = w.hiddenClass;
1028
+ return t ? !e.classList.contains(t) : !e.hasAttribute("hidden");
1029
+ }
1030
+ toggle(e, t) {
1031
+ if (!(e instanceof HTMLElement)) return;
1032
+ let n = w.hiddenClass;
1033
+ n ? t ? e.classList.remove(n) : e.classList.add(n) : t ? e.removeAttribute("hidden") : e.setAttribute("hidden", !0);
1034
+ }
1035
+ activate(e) {
1036
+ this.activator && this.activator.setAttribute("aria-expanded", e ? "true" : "false");
1037
+ }
1038
+ async show() {
1039
+ !(this.element instanceof HTMLElement) || this.isVisible(this.element) || (this.dispatch("show"), this.toggle(this.element, !0), this.activate(!0), await this.awaitCallback(this.onShown, { target: this.element }), this.dispatch("shown"));
1040
+ }
1041
+ async hide() {
1042
+ !(this.element instanceof HTMLElement) || !this.isVisible(this.element) || (this.dispatch("hide"), this.toggle(this.element, !1), this.activate(!1), await this.awaitCallback(this.onHidden, { target: this.element }), this.dispatch("hidden"));
1043
+ }
1044
+ enhance() {
1045
+ let e = this, t = {
1046
+ show: e.show.bind(e),
1047
+ hide: e.hide.bind(e)
1048
+ };
1049
+ Object.defineProperty(t, "visible", { get() {
1050
+ return e.isVisible(e.element);
1051
+ } }), Object.defineProperty(t, this.visibilityResolver, { value: e.isVisible.bind(e) }), Object.defineProperty(this.controller, this.visibility, { get() {
1052
+ return t;
1053
+ } });
1054
+ }
1055
+ }, Q = (e, t) => new De(e, t), $ = class extends e {
1056
+ static targets = ["daysOfWeek", "daysOfMonth"];
1057
+ static classes = ["dayOfWeek", "dayOfMonth"];
1058
+ static values = {
1059
+ locales: {
1060
+ type: Array,
1061
+ default: ["default"]
1062
+ },
1063
+ weekdayFormat: {
1064
+ type: String,
1065
+ default: "short"
1066
+ },
1067
+ dayFormat: {
1068
+ type: String,
1069
+ default: "numeric"
1070
+ },
1071
+ daysOfOtherMonth: {
1072
+ type: Boolean,
1073
+ default: !1
1074
+ }
1075
+ };
1076
+ initialize() {
1077
+ oe(this);
1078
+ }
1079
+ connect() {
1080
+ this.draw();
1081
+ }
1082
+ navigated() {
1083
+ this.draw();
1084
+ }
1085
+ draw() {
1086
+ this.drawDaysOfWeek(), this.drawDaysOfMonth();
1087
+ }
1088
+ createDayElement(e, { selectable: t = !1, disabled: n = !1 } = {}) {
1089
+ let r = document.createElement(t ? "button" : "div");
1090
+ return r.tabIndex = -1, e ? r.textContent = e : r.setAttribute("aria-hidden", "true"), n && (r instanceof HTMLButtonElement ? r.disabled = !0 : r.setAttribute("aria-disabled", "true")), r;
1091
+ }
1092
+ drawDaysOfWeek() {
1093
+ if (!this.hasDaysOfWeekTarget) return;
1094
+ let e = new Intl.DateTimeFormat(this.localesValue, { weekday: this.weekdayFormatValue }), t = [];
1095
+ for (let n of this.calendar.daysOfWeek) {
1096
+ let r = this.createDayElement(e.format(n.date));
1097
+ r.setAttribute("role", "columnheader"), r.title = n.long, this.hasDayOfWeekClass && r.classList.add(...this.dayOfWeekClasses), t.push(r);
1098
+ }
1099
+ let n = document.createElement("div");
1100
+ n.setAttribute("role", "row"), n.replaceChildren(...t), this.daysOfWeekTarget.replaceChildren(n);
1101
+ }
1102
+ drawDaysOfMonth() {
1103
+ if (!this.hasDaysOfMonthTarget) return;
1104
+ let e = this.calendar.today, t = new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), n = [];
1105
+ for (let e of this.calendar.daysOfMonth) {
1106
+ let r = !e.current || this.calendar.isDisabled(e.date) || !this.calendar.isWithinRange(e.date), i = e.current || this.daysOfOtherMonthValue ? e.value : "", a = this.createDayElement(i, {
1107
+ selectable: e.current,
1108
+ disabled: r
1109
+ });
1110
+ t === e.date.getTime() && a.setAttribute("aria-current", "date"), this.hasDayOfMonthClass && a.classList.add(...this.dayOfMonthClasses);
1111
+ let o = document.createElement("time");
1112
+ o.dateTime = e.iso, a.appendChild(o), n.push(a);
1113
+ }
1114
+ let r = [];
1115
+ for (let e = 0; e < n.length; e += 7) {
1116
+ let t = document.createElement("div");
1117
+ t.setAttribute("role", "row");
1118
+ for (let r of n.slice(e, e + 7)) r.setAttribute("role", "gridcell"), t.appendChild(r);
1119
+ r.push(t);
1120
+ }
1121
+ this.daysOfMonthTarget.replaceChildren(...r);
1122
+ }
1123
+ }, Oe = class extends e {
1124
+ onSelect(e) {
1125
+ if (!(e.target instanceof HTMLElement)) return;
1126
+ e.preventDefault();
1127
+ let t = e.target instanceof HTMLTimeElement ? e.target.parentElement : e.target;
1128
+ if (t.disabled || t.getAttribute("aria-disabled") === "true") return;
1129
+ this.dispatch("selecting", { target: t });
1130
+ let n = e.target instanceof HTMLTimeElement ? e.target : e.target.querySelector("time");
1131
+ if (!n) return console.error(`unable to locate time element within ${t}`);
1132
+ let r = k(n.dateTime);
1133
+ if (!r) return console.error(`unable to parse ${n.dateTime} found within the time element`);
1134
+ this.select(r.toISOString());
1135
+ }
1136
+ select(e) {
1137
+ let t = k(e);
1138
+ t && this.dispatch("selected", { detail: {
1139
+ epoch: t.getTime(),
1140
+ iso: e
1141
+ } });
1142
+ }
1143
+ }, ke = class extends e {
1144
+ static targets = ["source"];
1145
+ static values = { type: {
1146
+ type: String,
1147
+ default: "text/plain"
1148
+ } };
1149
+ onPaste(e) {
1150
+ let t = e.clipboardData?.getData(this.typeValue) ?? "", n = Array.from(e.clipboardData?.types ?? []);
1151
+ e.preventDefault(), this.dispatch("pasted", {
1152
+ detail: {
1153
+ text: t,
1154
+ types: n
1155
+ },
1156
+ bubbles: !0
1157
+ });
1158
+ }
1159
+ async copy(e) {
1160
+ let t = e.params?.text ?? (this.hasSourceTarget ? this.sourceTarget.value ?? this.sourceTarget.textContent ?? "" : "");
1161
+ try {
1162
+ await navigator.clipboard.writeText(t), this.dispatch("copied", {
1163
+ detail: { text: t },
1164
+ bubbles: !0
1165
+ });
1166
+ } catch (e) {
1167
+ this.dispatch("copy-failed", {
1168
+ detail: { error: e },
1169
+ bubbles: !0
1170
+ });
1171
+ }
1172
+ }
1173
+ }, Ae = class extends e {
1174
+ static targets = [
1175
+ "previous",
1176
+ "next",
1177
+ "day",
1178
+ "month",
1179
+ "year"
1180
+ ];
1181
+ static outlets = ["calendar-month"];
1182
+ static values = {
1183
+ date: String,
1184
+ locales: {
1185
+ type: Array,
1186
+ default: ["default"]
1187
+ },
1188
+ dayFormat: {
1189
+ type: String,
1190
+ default: "numeric"
1191
+ },
1192
+ monthFormat: {
1193
+ type: String,
1194
+ default: "long"
1195
+ },
1196
+ yearFormat: {
1197
+ type: String,
1198
+ default: "numeric"
1199
+ }
1200
+ };
1201
+ initialize() {
1202
+ this.previous = this.previous.bind(this), this.next = this.next.bind(this);
1203
+ }
1204
+ async calendarMonthOutletConnected() {
1205
+ if (this.dateValue) {
1206
+ let e = k(this.dateValue);
1207
+ e && await this.calendarMonthOutlet.calendar.navigate(e);
1208
+ }
1209
+ this.draw();
1210
+ }
1211
+ onSelect(e) {
1212
+ this.dateValue = e.detail.iso, this.draw(), this.dispatch("selected", {
1213
+ detail: { value: e.detail.iso },
1214
+ bubbles: !0
1215
+ });
1216
+ }
1217
+ previousTargetConnected(e) {
1218
+ e.addEventListener("click", this.previous);
1219
+ }
1220
+ previousTargetDisconnected(e) {
1221
+ e.removeEventListener("click", this.previous);
1222
+ }
1223
+ async previous() {
1224
+ await this.calendarMonthOutlet.calendar.step("month", -1), this.draw();
1225
+ }
1226
+ nextTargetConnected(e) {
1227
+ e.addEventListener("click", this.next);
1228
+ }
1229
+ nextTargetDisconnected(e) {
1230
+ e.removeEventListener("click", this.next);
1231
+ }
1232
+ async next() {
1233
+ await this.calendarMonthOutlet.calendar.step("month", 1), this.draw();
1234
+ }
1235
+ draw() {
1236
+ this.drawDay(), this.drawMonth(), this.drawYear();
1237
+ }
1238
+ drawDay() {
1239
+ if (!this.hasDayTarget || !this.hasCalendarMonthOutlet) return;
1240
+ let { year: e, month: t, day: n } = this.calendarMonthOutlet.calendar;
1241
+ this.dayTarget.textContent = new Intl.DateTimeFormat(this.localesValue, { day: this.dayFormatValue }).format(new Date(e, t, n));
1242
+ }
1243
+ drawMonth() {
1244
+ if (!this.hasMonthTarget || !this.hasCalendarMonthOutlet) return;
1245
+ let { year: e, month: t } = this.calendarMonthOutlet.calendar;
1246
+ this.monthTarget.textContent = new Intl.DateTimeFormat(this.localesValue, { month: this.monthFormatValue }).format(new Date(e, t));
1247
+ }
1248
+ drawYear() {
1249
+ if (!this.hasYearTarget || !this.hasCalendarMonthOutlet) return;
1250
+ let { year: e } = this.calendarMonthOutlet.calendar;
1251
+ this.yearTarget.textContent = new Intl.DateTimeFormat(this.localesValue, { year: this.yearFormatValue }).format(new Date(e, 0));
1252
+ }
1253
+ }, je = class extends e {
1254
+ static targets = [
1255
+ "listbox",
1256
+ "loading",
1257
+ "empty"
1258
+ ];
1259
+ static values = {
1260
+ url: {
1261
+ type: String,
1262
+ default: ""
1263
+ },
1264
+ field: {
1265
+ type: String,
1266
+ default: "q"
1267
+ },
1268
+ delay: {
1269
+ type: Number,
1270
+ default: 300
1271
+ }
1272
+ };
1273
+ initialize() {
1274
+ this.comboboxDropdown = ce(this);
1275
+ }
1276
+ onSelect(e) {
1277
+ let t = e.target.closest("[role=\"option\"]");
1278
+ !t || t.getAttribute("aria-disabled") === "true" || this.select(t.dataset.value ?? "");
1279
+ }
1280
+ select(e) {
1281
+ let t = this.listboxTarget.querySelectorAll("[role=\"option\"]");
1282
+ t.forEach((e) => e.setAttribute("aria-selected", "false"));
1283
+ let n = [...t].find((t) => t.dataset.value === e);
1284
+ n && n.setAttribute("aria-selected", "true"), this.dispatch("selected", {
1285
+ detail: { value: e },
1286
+ bubbles: !0
1287
+ });
1288
+ }
1289
+ onNavigate(e) {
1290
+ if ([
1291
+ "ArrowUp",
1292
+ "ArrowDown",
1293
+ "Enter",
1294
+ " "
1295
+ ].includes(e.key)) {
1296
+ if (e.preventDefault(), e.key === "Enter" || e.key === " ") {
1297
+ this.listboxTarget.querySelector("[aria-selected=\"true\"]")?.click();
1298
+ return;
1299
+ }
1300
+ this.step(e.key === "ArrowDown" ? 1 : -1);
1301
+ }
1302
+ }
1303
+ step(e) {
1304
+ let t = [...this.listboxTarget.querySelectorAll("[role=\"option\"]:not([aria-disabled=\"true\"]):not([hidden])")];
1305
+ if (!t.length) return;
1306
+ let n = this.listboxTarget.querySelector("[aria-selected=\"true\"]"), r = t.indexOf(n), i = e > 0 ? t[Math.min(r + 1, t.length - 1)] : t[Math.max(r - 1, 0)];
1307
+ !i || i === n || (t.forEach((e) => e.setAttribute("aria-selected", "false")), i.setAttribute("aria-selected", "true"), i.scrollIntoView({ block: "nearest" }));
1308
+ }
1309
+ filter(e) {
1310
+ if (this.urlValue) this.comboboxDropdown.scheduleFetch(e, this.delayValue, {
1311
+ url: this.urlValue,
1312
+ field: this.fieldValue,
1313
+ onLoading: (e) => this.setLoading(e),
1314
+ onLoaded: (e) => {
1315
+ this.listboxTarget.innerHTML = e, this.setEmpty(this.listboxTarget.querySelectorAll("[role=\"option\"]").length === 0);
1316
+ },
1317
+ onError: (e) => console.error("[combobox-dropdown] fetch failed", e)
1318
+ });
1319
+ else {
1320
+ let t = this.comboboxDropdown.fuzzyFilter(this.listboxTarget, e);
1321
+ this.setEmpty(t === 0);
1322
+ }
1323
+ }
1324
+ showAll() {
1325
+ this.listboxTarget.querySelectorAll("[role=\"option\"]").forEach((e) => e.hidden = !1), this.setEmpty(!1);
1326
+ }
1327
+ setLoading(e) {
1328
+ this.hasLoadingTarget && (this.loadingTarget.hidden = !e);
1329
+ }
1330
+ setEmpty(e) {
1331
+ this.hasEmptyTarget && (this.emptyTarget.hidden = !e);
1332
+ }
1333
+ disconnect() {
1334
+ this.comboboxDropdown.cancel();
1335
+ }
1336
+ }, Me = class extends e {
1337
+ static targets = [
1338
+ "hour",
1339
+ "minute",
1340
+ "period"
1341
+ ];
1342
+ connect() {
1343
+ this.select(this.toH24());
1344
+ }
1345
+ onSelect(e) {
1346
+ let t = e.target.closest("[role=\"option\"]");
1347
+ t && (t.closest("[role=\"listbox\"]").querySelectorAll("[role=\"option\"]").forEach((e) => e.setAttribute("aria-selected", "false")), t.setAttribute("aria-selected", "true"), this.select(this.toH24()));
1348
+ }
1349
+ select(e) {
1350
+ e && this.dispatch("selected", {
1351
+ detail: { value: e },
1352
+ bubbles: !0
1353
+ });
1354
+ }
1355
+ onNavigate(e) {
1356
+ ["ArrowUp", "ArrowDown"].includes(e.key) && (e.preventDefault(), this.step(e.currentTarget, e.key === "ArrowDown" ? 1 : -1));
1357
+ }
1358
+ step(e, t) {
1359
+ let n = [...e.querySelectorAll("[role=\"option\"]")], r = e.querySelector("[aria-selected=\"true\"]"), i = n.indexOf(r), a = t > 0 ? n[Math.min(i + 1, n.length - 1)] : n[Math.max(i - 1, 0)];
1360
+ !a || a === r || (n.forEach((e) => e.setAttribute("aria-selected", "false")), a.setAttribute("aria-selected", "true"), a.scrollIntoView({ block: "nearest" }), this.select(this.toH24()));
1361
+ }
1362
+ toH24() {
1363
+ let e = this.selectedValue(this.hourTarget), t = this.selectedValue(this.minuteTarget);
1364
+ if (!e || !t) return null;
1365
+ if (!this.hasPeriodTarget) return `${e}:${t}`;
1366
+ let n = this.selectedValue(this.periodTarget), r = parseInt(e, 10);
1367
+ return r = n === "AM" ? r === 12 ? 0 : r : r === 12 ? 12 : r + 12, `${String(r).padStart(2, "0")}:${t}`;
1368
+ }
1369
+ selectedValue(e) {
1370
+ return e?.querySelector("[aria-selected=\"true\"]")?.dataset.value ?? null;
1371
+ }
1372
+ }, Ne = class extends e {
1373
+ static targets = ["trigger"];
1374
+ connect() {
1375
+ P(this, { trigger: this.hasTriggerTarget ? this.triggerTarget : null });
1376
+ }
1377
+ }, Pe = class extends e {
1378
+ static targets = ["anchor", "reference"];
1379
+ static values = {
1380
+ placement: {
1381
+ type: String,
1382
+ default: "bottom"
1383
+ },
1384
+ alignment: {
1385
+ type: String,
1386
+ default: "start"
1387
+ },
1388
+ role: {
1389
+ type: String,
1390
+ default: "tooltip"
1391
+ }
1392
+ };
1393
+ connect() {
1394
+ if (!this.hasReferenceTarget) {
1395
+ console.error("FlipperController requires a reference target. Add data-flipper-target=\"reference\" to your element.");
1396
+ return;
1397
+ }
1398
+ if (!this.hasAnchorTarget) {
1399
+ console.error("FlipperController requires an anchor target. Add data-flipper-target=\"anchor\" to your element.");
1400
+ return;
1401
+ }
1402
+ L(this, {
1403
+ element: this.referenceTarget,
1404
+ anchor: this.anchorTarget,
1405
+ placement: this.placementValue,
1406
+ alignment: this.alignmentValue,
1407
+ ariaRole: this.roleValue
1408
+ });
1409
+ }
1410
+ }, Fe = class extends e {
1411
+ static targets = [
1412
+ "trigger",
1413
+ "popover",
1414
+ "value"
1415
+ ];
1416
+ static values = {
1417
+ value: String,
1418
+ minLength: {
1419
+ type: Number,
1420
+ default: 1
1421
+ }
1422
+ };
1423
+ static outlets = ["combobox-dropdown"];
1424
+ open() {
1425
+ this.hasPopoverTarget && (this.popoverTarget.hidden = !1, this.hasTriggerTarget && _(this.triggerTarget, !0), this.focusFirstInPopover());
1426
+ }
1427
+ close() {
1428
+ this.hasPopoverTarget && (this.popoverTarget.hidden = !0, this.hasTriggerTarget && (_(this.triggerTarget, !1), this.triggerTarget.focus()));
1429
+ }
1430
+ toggle() {
1431
+ this.hasPopoverTarget && this.popoverTarget.hidden ? this.open() : this.close();
1432
+ }
1433
+ onSelect(e) {
1434
+ e.detail?.value !== void 0 && (this.valueValue = e.detail.value), this.close();
1435
+ }
1436
+ onInput(e) {
1437
+ if (e.target !== this.triggerTarget) return;
1438
+ let t = e.target.value.trim();
1439
+ if (t.length < this.minLengthValue) {
1440
+ this.hasComboboxDropdownOutlet && this.comboboxDropdownOutlet.showAll();
1441
+ return;
1442
+ }
1443
+ this.hasComboboxDropdownOutlet && this.comboboxDropdownOutlet.filter(t);
1444
+ }
1445
+ valueValueChanged(e) {
1446
+ this.hasValueTarget && (this.valueTarget.value = e), this.dispatch("changed", { detail: { value: e } });
1447
+ }
1448
+ focusFirstInPopover() {
1449
+ this.hasPopoverTarget && this.popoverTarget.querySelector("button:not([disabled]), [href], input:not([type=\"hidden\"]):not([disabled]), [tabindex]:not([tabindex=\"-1\"])")?.focus();
1450
+ }
1451
+ }, Ie = class extends e {
1452
+ static targets = ["input", "toggle"];
1453
+ static values = {
1454
+ type: {
1455
+ type: String,
1456
+ default: "plain"
1457
+ },
1458
+ options: {
1459
+ type: Object,
1460
+ default: {}
1461
+ },
1462
+ revealed: {
1463
+ type: Boolean,
1464
+ default: !1
1465
+ }
1466
+ };
1467
+ connect() {
1468
+ X(this, {
1469
+ type: this.typeValue,
1470
+ options: this.optionsValue
1471
+ }), this.format(this.readValue()), this.drawToggle();
1472
+ }
1473
+ typeValueChanged() {
1474
+ this.inputFormat && (X(this, {
1475
+ type: this.typeValue,
1476
+ options: this.optionsValue
1477
+ }), this.format(this.readValue()), this.drawToggle());
1478
+ }
1479
+ optionsValueChanged() {
1480
+ this.inputFormat && (X(this, {
1481
+ type: this.typeValue,
1482
+ options: this.optionsValue
1483
+ }), this.format(this.readValue()));
1484
+ }
1485
+ revealedValueChanged() {
1486
+ this.inputFormat && (this.format(this.readValue()), this.drawToggle());
1487
+ }
1488
+ onChange(e) {
1489
+ this.format(e?.detail?.value ?? "");
1490
+ }
1491
+ format(e) {
1492
+ this.inputFormat && this.onFormatting(e);
1493
+ }
1494
+ toggle() {
1495
+ !this.inputFormat.maskable() && this.typeValue !== "password" || (this.revealedValue = !this.revealedValue);
1496
+ }
1497
+ onPaste(e) {
1498
+ let t = e.detail?.text ?? "";
1499
+ if (!this.inputFormat || !t) return;
1500
+ let n = this.inputFormat.normalize(t);
1501
+ this.inputFormat.validate(n) && this.format(n);
1502
+ }
1503
+ drawToggle() {
1504
+ if (!this.hasToggleTarget) return;
1505
+ let e = this.inputFormat?.maskable() || this.typeValue === "password";
1506
+ this.toggleTarget.hidden = !e, e && v(this.toggleTarget, this.revealedValue);
1507
+ }
1508
+ readValue() {
1509
+ return this.hasInputTarget ? this.inputTarget instanceof HTMLInputElement ? this.inputTarget.value : this.inputTarget.textContent : "";
1510
+ }
1511
+ onFormatting(e) {
1512
+ if (!this.inputFormat) return;
1513
+ if (this.typeValue === "password") {
1514
+ this.hasInputTarget && (this.inputTarget.type = this.revealedValue ? "text" : "password");
1515
+ return;
1516
+ }
1517
+ let t = this.inputFormat.normalize(e), n = this.revealedValue || !this.inputFormat.maskable() ? this.inputFormat.format(t) : this.inputFormat.mask(t);
1518
+ this.hasInputTarget && (this.inputTarget instanceof HTMLInputElement ? this.inputTarget.value = n : this.inputTarget.textContent = n), this.dispatch("formatted", { detail: { value: n } });
1519
+ }
1520
+ }, Le = class extends e {
1521
+ static targets = ["modal", "overlay"];
1522
+ connect() {
1523
+ if (!this.hasModalTarget) {
1524
+ console.error("ModalController requires a modal target. Add data-modal-target=\"modal\" to your element.");
1525
+ return;
1526
+ }
1527
+ this.isNativeDialog = this.modalTarget instanceof HTMLDialogElement, this.isNativeDialog ? (this.modalTarget.addEventListener("cancel", this.close), this.modalTarget.addEventListener("click", this.onBackdropClick)) : (this.focusTrap = new a(this.modalTarget, { escapeDeactivates: !0 }), P(this, { element: this.modalTarget }));
1528
+ }
1529
+ dismissed = () => {
1530
+ this.close();
1531
+ };
1532
+ disconnect() {
1533
+ this.isNativeDialog && (this.modalTarget.removeEventListener("cancel", this.close), this.modalTarget.removeEventListener("click", this.onBackdropClick));
1534
+ }
1535
+ open(e) {
1536
+ if (e && e.preventDefault(), this.hasModalTarget) {
1537
+ if (this.isNativeDialog) this.previouslyFocused = document.activeElement, this.modalTarget.showModal();
1538
+ else {
1539
+ let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
1540
+ e.hidden = !1, document.body.style.overflow = "hidden", this.focusTrap && this.focusTrap.activate();
1541
+ }
1542
+ p("Modal opened");
1543
+ }
1544
+ }
1545
+ close(e) {
1546
+ if (e && e.preventDefault(), this.hasModalTarget) {
1547
+ if (this.isNativeDialog) this.modalTarget.close(), this.previouslyFocused && this.previouslyFocused.isConnected && setTimeout(() => {
1548
+ this.previouslyFocused.focus();
1549
+ }, 0);
1550
+ else {
1551
+ let e = this.hasOverlayTarget ? this.overlayTarget : this.modalTarget;
1552
+ e.hidden = !0, document.body.style.overflow = "", this.focusTrap && this.focusTrap.deactivate();
1553
+ }
1554
+ p("Modal closed");
1555
+ }
1556
+ }
1557
+ onBackdropClick = (e) => {
1558
+ let t = this.modalTarget.getBoundingClientRect();
1559
+ (e.clientY < t.top || e.clientY > t.bottom || e.clientX < t.left || e.clientX > t.right) && this.close();
1560
+ };
1561
+ }, Re = class extends e {
1562
+ static targets = ["content"];
1563
+ connect() {
1564
+ Ee(this, { element: this.hasContentTarget ? this.contentTarget : null });
1565
+ }
1566
+ }, ze = class extends e {
1567
+ static targets = [
1568
+ "content",
1569
+ "template",
1570
+ "loader",
1571
+ "activator"
1572
+ ];
1573
+ static classes = ["hidden"];
1574
+ static values = {
1575
+ url: String,
1576
+ loadedAt: String,
1577
+ reload: {
1578
+ type: String,
1579
+ default: "never"
1580
+ },
1581
+ staleAfter: {
1582
+ type: Number,
1583
+ default: 3600
1584
+ }
1585
+ };
1586
+ connect() {
1587
+ ue(this, {
1588
+ element: this.hasContentTarget ? this.contentTarget : null,
1589
+ url: this.hasUrlValue ? this.urlValue : null
1590
+ }), this.hasContentTarget && Q(this, {
1591
+ element: this.contentTarget,
1592
+ activator: this.hasActivatorTarget ? this.activatorTarget : null
1593
+ }), this.hasLoaderTarget && Q(this, {
1594
+ element: this.loaderTarget,
1595
+ visibility: "contentLoaderVisibility"
1596
+ });
1597
+ }
1598
+ async show() {
1599
+ await this.visibility.show();
1600
+ }
1601
+ async hide() {
1602
+ await this.visibility.hide();
1603
+ }
1604
+ async shown() {
1605
+ await this.load();
1606
+ }
1607
+ canLoad() {
1608
+ return this.hasContentTarget && this.contentTarget.tagName.toLowerCase() === "turbo-frame" ? (this.hasUrlValue && this.contentTarget.setAttribute("src", this.urlValue), !1) : !0;
1609
+ }
1610
+ async contentLoading() {
1611
+ this.hasLoaderTarget && await this.contentLoaderVisibility.show();
1612
+ }
1613
+ async contentLoaded({ content: e }) {
1614
+ this.hasContentTarget && this.contentTarget.replaceChildren(this.getContentNode(e)), this.hasLoaderTarget && await this.contentLoaderVisibility.hide();
1615
+ }
1616
+ getContentNode(e) {
1617
+ if (typeof e == "string") {
1618
+ let t = document.createElement("template");
1619
+ return t.innerHTML = e, document.importNode(t.content, !0);
1620
+ }
1621
+ return document.importNode(e, !0);
1622
+ }
1623
+ contentLoader() {
1624
+ if (this.hasTemplateTarget) return this.templateTarget instanceof HTMLTemplateElement ? this.templateTarget.content : this.templateTarget.innerHTML;
1625
+ }
1626
+ };
1627
+ //#endregion
1628
+ export { y as ARIA_HASPOPUP_VALUES, $ as CalendarMonthController, Oe as CalendarMonthObserverController, ke as ClipboardController, Ae as ComboboxDateController, je as ComboboxDropdownController, Me as ComboboxTimeController, Ne as DismisserController, t as FOCUSABLE_SELECTOR, Pe as FlipperController, o as FocusRestoration, a as FocusTrap, Fe as InputComboboxController, Ie as InputFormatController, Le as ModalController, Re as PannerController, ze as PopoverController, d as RovingTabIndex, p as announce, S as connectTriggerToTarget, ne as disconnectTriggerFromTarget, h as ensureId, i as focusFirst, m as generateId, n as getFocusableElements, c as isActivationKey, l as isArrowKey, s as isKey, r as isVisible, u as preventDefault, g as setAriaState, ee as setChecked, te as setDisabled, _ as setExpanded, v as setPressed };