vrembem 4.0.0-next.31 → 4.0.0-next.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,157 +1,162 @@
1
- var Jt = (t) => {
2
- throw TypeError(t);
3
- };
4
- var Xt = (t, e, s) => e.has(t) || Jt("Cannot " + s);
5
- var E = (t, e, s) => (Xt(t, e, "read from private field"), s ? s.call(t) : e.get(t)), U = (t, e, s) => e.has(t) ? Jt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, s), S = (t, e, s, n) => (Xt(t, e, "write to private field"), n ? n.call(t, s) : e.set(t, s), s);
6
- const C = ":not([inert])", $ = ':not([tabindex^="-"])', mt = ":not(:disabled)", se = [
7
- `a[href]${C}${$}`,
8
- `area[href]${C}${$}`,
9
- `input:not([type="hidden"]):not([type="radio"])${C}${$}${mt}`,
10
- `input[type="radio"]${C}${$}${mt}`,
11
- `select${C}${$}${mt}`,
12
- `textarea${C}${$}${mt}`,
13
- `button${C}${$}${mt}`,
14
- `details${C} > summary:first-of-type${$}`,
15
- `iframe${C}${$}`,
16
- `audio[controls]${C}${$}`,
17
- `video[controls]${C}${$}`,
18
- `[contenteditable]${C}${$}`,
19
- `[tabindex]${C}${$}`
1
+ const C = ":not([inert])", L = ':not([tabindex^="-"])', lt = ":not(:disabled)", Kt = [
2
+ `a[href]${C}${L}`,
3
+ `area[href]${C}${L}`,
4
+ `input:not([type="hidden"]):not([type="radio"])${C}${L}${lt}`,
5
+ `input[type="radio"]${C}${L}${lt}`,
6
+ `select${C}${L}${lt}`,
7
+ `textarea${C}${L}${lt}`,
8
+ `button${C}${L}${lt}`,
9
+ `details${C} > summary:first-of-type${L}`,
10
+ `iframe${C}${L}`,
11
+ `audio[controls]${C}${L}`,
12
+ `video[controls]${C}${L}`,
13
+ `[contenteditable]${C}${L}`,
14
+ `[tabindex]${C}${L}`
20
15
  ];
21
- function ie(t, e = "config") {
16
+ function Xt(t, e = "config") {
22
17
  const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
23
18
  return n ? JSON.parse(n) : {};
24
19
  }
25
- function Bt(t) {
26
- return typeof t == "string" ? document.getElementById(t) : t instanceof HTMLElement ? t : null;
20
+ function At(t) {
21
+ if (typeof t == "string") {
22
+ const e = document.getElementById(t);
23
+ if (e) return e;
24
+ throw new Error(`Element not found with ID: "${t}"`);
25
+ } else if (t instanceof HTMLElement) {
26
+ if (!t.id)
27
+ throw new Error("HTMLElement must have an ID");
28
+ return t;
29
+ } else
30
+ throw new Error("Invalid argument: query must be a string or HTMLElement");
27
31
  }
28
- async function Q(t, e, ...s) {
29
- e in t && typeof t[e] == "function" && await t[e](...s);
32
+ async function V(t, e, ...n) {
33
+ e in t && typeof t[e] == "function" && await t[e](...n);
30
34
  }
31
- function oe(t, e, s) {
35
+ function Yt(t, e, n) {
32
36
  if (typeof e == "string") {
33
- const i = document.querySelector(e);
34
- if (!i)
37
+ const r = document.querySelector(e);
38
+ if (!r)
35
39
  throw new Error(`No teleport reference found for selector: ${e}`);
36
- e = i;
40
+ e = r;
37
41
  } else if (!(e instanceof HTMLElement))
38
42
  throw new Error(`Not a valid teleport reference: '${e}'`);
39
- if (typeof e[s] != "function")
40
- throw new Error(`Not a valid teleport method: '${s}'`);
41
- let n = document.createComment(
43
+ if (typeof e[n] != "function")
44
+ throw new Error(`Not a valid teleport method: '${n}'`);
45
+ let s = document.createComment(
42
46
  "teleported #" + t.id
43
47
  );
44
- return t.before(n), e[s](t), () => {
45
- n && (n.after(t), n.remove(), n = null);
48
+ return t.before(s), e[n](t), () => {
49
+ s && (s.after(t), s.remove(), s = null);
46
50
  };
47
51
  }
48
- function re(t) {
52
+ function Gt(t) {
49
53
  return t.split("-").map(
50
- (e, s) => s === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)
54
+ (e, n) => n === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)
51
55
  ).join("");
52
56
  }
53
- function Ut(t) {
57
+ function Ot(t) {
54
58
  return t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
55
59
  }
56
- function le(t) {
60
+ function te(t) {
57
61
  if (typeof t == "number")
58
62
  return t;
59
63
  const e = parseFloat(t);
60
64
  if (!Number.isNaN(e)) {
61
- const s = t.includes("ms");
62
- return e * (s ? 1 : 1e3);
65
+ const n = t.includes("ms");
66
+ return e * (n ? 1 : 1e3);
63
67
  }
64
68
  throw new Error(`Could not convert value to milliseconds: ${t}`);
65
69
  }
66
- function wt(t, e, s, n, i = 0) {
67
- return new Promise((r) => {
68
- t.classList.remove(e), t.classList.add(s), setTimeout(() => {
69
- t.classList.add(n), t.classList.remove(s), r(t);
70
- }, le(i));
70
+ function Ue(t, e, n, s, r = 0) {
71
+ return new Promise((i) => {
72
+ t.classList.remove(e), t.classList.add(n), setTimeout(() => {
73
+ t.classList.add(s), t.classList.remove(n), i(t);
74
+ }, te(r));
71
75
  });
72
76
  }
73
- function ae(t, e = {}) {
74
- const s = {
77
+ function ee(t, e = {}) {
78
+ const n = {
75
79
  fallback: null,
76
80
  element: document.body,
77
81
  ...e
78
82
  };
79
83
  if (!t.startsWith("--")) {
80
- const i = kt();
81
- i && (t = `${i}${t}`), t = `--${t}`;
84
+ const r = mt();
85
+ r && (t = `${r}${t}`), t = `--${t}`;
82
86
  }
83
- const n = getComputedStyle(s.element).getPropertyValue(t).trim();
84
- if (n)
85
- return n;
86
- if (s.fallback)
87
- return s.fallback;
87
+ const s = getComputedStyle(n.element).getPropertyValue(t).trim();
88
+ if (s)
89
+ return s;
90
+ if (n.fallback)
91
+ return n.fallback;
88
92
  throw new Error(`CSS variable "${t}" was not found!`);
89
93
  }
90
- async function V(t, e, s) {
91
- await Q(e, t, s), s && await Q(s, t);
92
- for (const n of e.plugins)
93
- await Q(n, t, { plugin: n, parent: e, entry: s });
94
- await e.emit(t, s);
94
+ async function I(t, e, n) {
95
+ await V(e, t, n), n && await V(n, t);
96
+ for (const s of e.plugins)
97
+ await V(s, t, { plugin: s, parent: e, entry: n });
98
+ await e.emit(t, n);
95
99
  }
96
- function ce(t) {
97
- const e = getComputedStyle(t.el), s = {}, n = t.getSetting("customProps");
98
- for (let i = 0; i < n.length; i++) {
99
- const r = kt(), o = t.parent.module.toLowerCase(), l = Ut(n[i]), a = e.getPropertyValue(`--${r}${o}-${l}`).trim();
100
- a && (s[l] = a);
100
+ function ne(t) {
101
+ const e = getComputedStyle(t.el), n = {}, s = t.getSetting("customProps");
102
+ for (let r = 0; r < s.length; r++) {
103
+ const i = mt(), o = t.parent.module.toLowerCase(), a = Ot(s[r]), l = e.getPropertyValue(`--${i}${o}-${a}`).trim();
104
+ l && (n[a] = l);
101
105
  }
102
- return s;
106
+ return n;
103
107
  }
104
- function kt() {
108
+ function mt() {
105
109
  return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
106
110
  }
107
- function He(t, e, s = "camel") {
108
- return e = s === "camel" ? re(e) : Ut(e), t.split(".").concat(e).reduce((n, i) => n == null ? void 0 : n[i], this);
111
+ function Fe(t, e, n = "camel") {
112
+ return e = n === "camel" ? Gt(e) : Ot(e), t.split(".").concat(e).reduce((s, r) => s?.[r], this);
109
113
  }
110
- function fe(t, e = {}) {
114
+ function se(t, e = {}) {
111
115
  const {
112
- fallback: s,
113
- props: n = ["dataConfig", "customProps", "settings", "parent.settings"]
116
+ fallback: n,
117
+ props: s = ["dataConfig", "customProps", "settings", "parent.settings"]
114
118
  } = e;
115
- for (const i of n) {
116
- const r = i !== "customProps" ? "camel" : "kebab", o = He.call(this, i, t, r);
119
+ for (const r of s) {
120
+ const i = r !== "customProps" ? "camel" : "kebab", o = Fe.call(this, r, t, i);
117
121
  if (o !== void 0)
118
122
  return o;
119
123
  }
120
- if (s !== void 0)
121
- return s;
124
+ if (n !== void 0)
125
+ return n;
122
126
  throw new Error(`${this.parent.module} setting does not exist: ${t}`);
123
127
  }
124
- function Ne(t, e) {
128
+ function Ve(t, e) {
125
129
  e && document.querySelectorAll(e).forEach((n) => {
126
130
  t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
127
131
  });
128
132
  }
129
- function Be(t, e) {
133
+ function ze(t, e) {
130
134
  e && document.querySelectorAll(e).forEach((n) => {
131
- t ? (n.inert = !0, n.setAttribute("aria-hidden", "true")) : (n.inert = !1, n.removeAttribute("aria-hidden"));
135
+ n.inert = t;
132
136
  });
133
137
  }
134
- function bt(t, e, s) {
135
- Be(!!t, e), Ne(!!t, s);
138
+ function Be(t, e, n) {
139
+ ze(!!t, e), Ve(!!t, n);
136
140
  }
137
- const ue = {
138
- on(t, e, ...s) {
141
+ const ie = {
142
+ events: {},
143
+ on(t, e, ...n) {
139
144
  this.events[t] || (this.events[t] = []), this.events[t].some(
140
- (i) => i.listener === e
141
- ) || this.events[t].push({ listener: e, args: s });
145
+ (s) => s.listener === e
146
+ ) || this.events[t].push({ listener: e, args: n });
142
147
  },
143
148
  off(t, e) {
144
149
  this.events[t] && (this.events[t] = this.events[t].filter(
145
- (s) => s.listener !== e
150
+ (n) => n.listener !== e
146
151
  ));
147
152
  },
148
153
  async emit(t, e) {
149
154
  if (t = t.startsWith("on") ? t.slice(2, 3).toLowerCase() + t.slice(3) : t, !!this.events[t])
150
- for (const { listener: s, args: n } of this.events[t])
151
- await s(e, ...n);
155
+ for (const { listener: n, args: s } of this.events[t])
156
+ await n(e, ...s);
152
157
  }
153
158
  };
154
- class de extends Array {
159
+ let re = class extends Array {
155
160
  constructor(e = null) {
156
161
  super(), this.el = e, this.el && this.set();
157
162
  }
@@ -162,71 +167,73 @@ class de extends Array {
162
167
  return this[this.length - 1];
163
168
  }
164
169
  set(e = this.el) {
165
- this.length = 0, this.push(...e.querySelectorAll(se.join(",")));
170
+ this.length = 0, e && this.push(...e.querySelectorAll(Kt.join(",")));
166
171
  }
167
172
  clear() {
168
173
  this.length = 0;
169
174
  }
170
- }
171
- class he {
175
+ }, oe = class {
172
176
  constructor(e = null) {
173
- this.el = e, this.focusable = new de(), this.handleFocusTrap = Ue.bind(this);
177
+ this.el = e, this.focusable = new re(), this.handleFocusTrap = We.bind(this);
174
178
  }
175
179
  on(e = this.el) {
176
- this.focusable.set(e), this.focusable.length ? document.addEventListener("keydown", this.handleFocusTrap) : document.addEventListener("keydown", Gt);
180
+ this.focusable.set(e), this.focusable.length ? document.addEventListener("keydown", this.handleFocusTrap) : document.addEventListener("keydown", Ft);
177
181
  }
178
182
  off() {
179
- this.focusable.clear(), document.removeEventListener("keydown", this.handleFocusTrap), document.removeEventListener("keydown", Gt);
183
+ this.focusable.clear(), document.removeEventListener("keydown", this.handleFocusTrap), document.removeEventListener("keydown", Ft);
180
184
  }
181
- }
182
- function Gt(t) {
185
+ };
186
+ function Ft(t) {
183
187
  (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
184
188
  }
185
- function Ue(t) {
189
+ function We(t) {
186
190
  if (t.key !== "Tab" && t.keyCode !== 9) return;
187
- const { activeElement: e } = document, { el: s, focusable: n } = this, i = t.shiftKey, r = e === n.first || e === s, o = e === n.last || e === s;
188
- (i && r || !i && o) && (t.preventDefault(), (i ? n.last : n.first).focus());
191
+ const { activeElement: e } = document, { el: n, focusable: s } = this, r = t.shiftKey, i = e === s.first || e === n, o = e === s.last || e === n;
192
+ if (r && i || !r && o) {
193
+ t.preventDefault();
194
+ const a = r ? s.last : s.first;
195
+ a && typeof a.focus == "function" && a.focus();
196
+ }
189
197
  }
190
- function Vt(t, e = !0) {
191
- const s = localStorage.getItem(t), n = s ? JSON.parse(s) : {};
198
+ function Tt(t, e = !0) {
199
+ const n = localStorage.getItem(t), s = n ? JSON.parse(n) : {};
192
200
  return {
193
- get(i, r = void 0) {
194
- return i ? i in n ? n[i] : r : n;
201
+ get(r, i) {
202
+ return r ? r in s ? s[r] : i : s;
195
203
  },
196
- set(i, r) {
197
- return r ? n[i] = r : delete n[i], e && localStorage.setItem(t, JSON.stringify(n)), n;
204
+ set(r, i) {
205
+ return i ? s[r] = i : delete s[r], e && localStorage.setItem(t, JSON.stringify(s)), s;
198
206
  }
199
207
  };
200
208
  }
201
- class ge extends Array {
209
+ let ae = class extends Array {
202
210
  constructor(e = {}) {
203
211
  super(), this.presets = e;
204
212
  }
205
213
  applySettings(e) {
206
- var r;
207
- const s = (e == null ? void 0 : e.defaults) || {}, n = ((r = this.presets) == null ? void 0 : r[e.name]) || {}, i = (e == null ? void 0 : e.options) || {};
208
- e.settings = { ...s, ...n, ...i };
214
+ const n = e?.defaults || {}, s = this.presets?.[e.name] || {}, r = e?.options || {};
215
+ e.settings = { ...n, ...s, ...r };
209
216
  }
210
217
  validate(e) {
211
218
  return !("name" in e) || typeof e.name != "string" ? (console.error("Plugin requires a name!"), !1) : !0;
212
219
  }
213
220
  get(e) {
214
- return this.find((s) => s.name === e);
221
+ return this.find((n) => n.name === e);
215
222
  }
216
223
  add(e) {
217
224
  if (Array.isArray(e))
218
- e.forEach((s) => this.add(s));
225
+ e.forEach((n) => this.add(n));
219
226
  else if (this.applySettings(e), this.validate(e)) {
220
- const s = this.findIndex((n) => n.name === e.name);
221
- ~s ? this[s] = e : this.push(e);
227
+ const n = this.findIndex((s) => s.name === e.name);
228
+ ~n ? this[n] = e : this.push(e);
222
229
  }
223
230
  }
224
231
  remove(e) {
225
- const s = this.findIndex((n) => n.name === e);
226
- ~s && this.splice(s, 1);
232
+ const n = this.findIndex((s) => s.name === e);
233
+ ~n && this.splice(n, 1);
227
234
  }
228
- }
229
- class me extends Array {
235
+ };
236
+ class _e extends Array {
230
237
  constructor(e = {}) {
231
238
  super(), this.settings = e;
232
239
  }
@@ -234,14 +241,13 @@ class me extends Array {
234
241
  return [...this];
235
242
  }
236
243
  get top() {
237
- const e = this[this.length - 1];
238
- return e || null;
244
+ return this[this.length - 1] || null;
239
245
  }
240
246
  updateIndex() {
241
- this.forEach((e, s) => {
242
- e.el.style.zIndex = null;
243
- const n = getComputedStyle(e.el)["z-index"];
244
- e.el.style.zIndex = parseInt(n) + s + 1;
247
+ this.forEach((e, n) => {
248
+ e.el.style.zIndex = "";
249
+ const s = getComputedStyle(e.el)["z-index"];
250
+ e.el.style.zIndex = String(parseInt(s, 10) + n + 1);
245
251
  });
246
252
  }
247
253
  onChange() {
@@ -251,183 +257,198 @@ class me extends Array {
251
257
  this.push(e), this.onChange();
252
258
  }
253
259
  remove(e) {
254
- const s = this.findIndex((n) => n.id === e.id);
255
- ~s && (e.el.style.zIndex = null, this.splice(s, 1), this.onChange());
260
+ const n = this.findIndex((s) => s.id === e.id);
261
+ ~n && (e.el.style.zIndex = "", this.splice(n, 1), this.onChange());
256
262
  }
257
263
  moveToTop(e) {
258
- const s = this.findIndex((n) => n.id === e.id);
259
- ~s && (this.splice(s, 1), this.add(e));
264
+ const n = this.findIndex((s) => s.id === e.id);
265
+ ~n && (this.splice(n, 1), this.add(e));
260
266
  }
261
267
  }
262
- const Ve = {
268
+ const Qe = {
263
269
  condition: !0
264
- }, _e = {
270
+ }, Je = {
265
271
  primary: "hsl(152deg 60% 50%)",
266
272
  secondary: "hsl(214deg 50% 50%)",
267
273
  neutral: "hsl(214deg 20% 50%)",
268
274
  important: "hsl(0deg 80% 50%)"
269
275
  };
270
- function We(t = {}) {
276
+ function Ze(t = {}) {
271
277
  const e = {
272
278
  name: "debug",
273
- defaults: Ve,
279
+ defaults: Qe,
274
280
  options: t
275
281
  };
276
- function s(o, l = [], a = ["primary", "secondary"]) {
277
- const c = a.map((d) => `color: ${_e[d]}`);
278
- console.log(`%c📡 DEBUG: %c${o}`, ...c, ...l);
282
+ function n(i, o = [], a = ["primary", "secondary"]) {
283
+ const l = a.map((c) => `color: ${Je[c]}`);
284
+ console.log(`%c📡 DEBUG: %c${i}`, ...l, ...o);
279
285
  }
280
- function n(o, ...l) {
281
- return typeof o == "function" ? o(...l) : o;
286
+ function s(i, ...o) {
287
+ return typeof i == "function" ? i(...o) : i;
282
288
  }
283
- const i = {
284
- beforeMountRef: s.bind(null, "Event > beforeMount()"),
285
- afterMountRef: s.bind(null, "Event > afterMount()"),
286
- beforeUnmountRef: s.bind(
289
+ const r = {
290
+ beforeMountRef: n.bind(null, "Event > beforeMount()"),
291
+ afterMountRef: n.bind(null, "Event > afterMount()"),
292
+ beforeUnmountRef: n.bind(
287
293
  null,
288
294
  "Event > beforeUnmount()",
289
295
  [],
290
296
  ["important", "neutral"]
291
297
  ),
292
- afterUnmountRef: s.bind(
298
+ afterUnmountRef: n.bind(
293
299
  null,
294
300
  "Event > afterUnmount()",
295
301
  [],
296
302
  ["important", "neutral"]
297
303
  ),
298
- createEntryRef: (o, { parent: l, plugin: a }) => {
299
- if (n(a.settings.condition, o)) {
300
- const c = l.collection.length;
301
- s(`Event > createEntry() > [${c}] #${o.id}`);
304
+ createEntryRef: (i, { parent: o, plugin: a }) => {
305
+ if (s(a.settings.condition, i)) {
306
+ const l = o.collection.length;
307
+ n(`Event > createEntry() > [${l}] #${i.id}`);
302
308
  }
303
309
  },
304
- registerEntryRef: (o, { parent: l, plugin: a }) => {
305
- if (n(a.settings.condition, o)) {
306
- const c = l.collection.length;
307
- s(`Event > registerEntry() > [${c}] #${o.id}`);
310
+ registerEntryRef: (i, { parent: o, plugin: a }) => {
311
+ if (s(a.settings.condition, i)) {
312
+ const l = o.collection.length;
313
+ n(`Event > registerEntry() > [${l}] #${i.id}`);
308
314
  }
309
315
  },
310
- destroyEntryRef: (o, { parent: l, plugin: a }) => {
311
- if (n(a.settings.condition, o)) {
312
- const c = l.collection.length;
313
- s(
314
- `Event > destroyEntry() > [${c}] #${o.id}`,
316
+ destroyEntryRef: (i, { parent: o, plugin: a }) => {
317
+ if (s(a.settings.condition, i)) {
318
+ const l = o.collection.length;
319
+ n(
320
+ `Event > destroyEntry() > [${l}] #${i.id}`,
315
321
  [],
316
322
  ["important", "neutral"]
317
323
  );
318
324
  }
319
325
  },
320
- deregisterEntryRef: (o, { parent: l, plugin: a }) => {
321
- if (n(a.settings.condition, o)) {
322
- const c = l.collection.length;
323
- s(
324
- `Event > deregisterEntry() > [${c}] #${o.id}`,
326
+ deregisterEntryRef: (i, { parent: o, plugin: a }) => {
327
+ if (s(a.settings.condition, i)) {
328
+ const l = o.collection.length;
329
+ n(
330
+ `Event > deregisterEntry() > [${l}]`,
325
331
  [],
326
332
  ["important", "neutral"]
327
333
  );
328
334
  }
329
335
  }
330
336
  };
331
- return { ...e, ...{
337
+ return {
338
+ ...e,
332
339
  // Plugin setup/teardown methods
333
- setup({ parent: o }) {
334
- s("Plugin > setup()", arguments, ["secondary", "neutral"]), o.on("beforeMount", i.beforeMountRef), o.on("createEntry", i.createEntryRef, { parent: o, plugin: this }), o.on("registerEntry", i.registerEntryRef, {
335
- parent: o,
340
+ setup({ parent: i }) {
341
+ n("Plugin > setup()", Array.from(arguments), ["secondary", "neutral"]), i.on("beforeMount", r.beforeMountRef), i.on("createEntry", r.createEntryRef, { parent: i, plugin: this }), i.on("registerEntry", r.registerEntryRef, {
342
+ parent: i,
336
343
  plugin: this
337
- }), o.on("afterMount", i.afterMountRef), o.on("beforeUnmount", i.beforeUnmountRef), o.on("destroyEntry", i.destroyEntryRef, { parent: o, plugin: this }), o.on("deregisterEntry", i.deregisterEntryRef, {
338
- parent: o,
344
+ }), i.on("afterMount", r.afterMountRef), i.on("beforeUnmount", r.beforeUnmountRef), i.on("destroyEntry", r.destroyEntryRef, { parent: i, plugin: this }), i.on("deregisterEntry", r.deregisterEntryRef, {
345
+ parent: i,
339
346
  plugin: this
340
- }), o.on("afterUnmount", i.afterUnmountRef);
347
+ }), i.on("afterUnmount", r.afterUnmountRef);
341
348
  },
342
- teardown({ parent: o }) {
343
- s("Plugin > teardown()", arguments, ["secondary", "neutral"]), o.off("beforeMount", i.beforeMountRef), o.off("createEntry", i.createEntryRef), o.off("registerEntry", i.registerEntryRef), o.off("afterMount", i.afterMountRef), o.off("beforeUnmount", i.beforeUnmountRef), o.off("destroyEntry", i.destroyEntryRef), o.off("deregisterEntry", i.deregisterEntryRef), o.off("afterUnmount", i.afterUnmountRef);
349
+ teardown({ parent: i }) {
350
+ n("Plugin > teardown()", Array.from(arguments), [
351
+ "secondary",
352
+ "neutral"
353
+ ]), i.off("beforeMount", r.beforeMountRef), i.off("createEntry", r.createEntryRef), i.off("registerEntry", r.registerEntryRef), i.off("afterMount", r.afterMountRef), i.off("beforeUnmount", r.beforeUnmountRef), i.off("destroyEntry", r.destroyEntryRef), i.off("deregisterEntry", r.deregisterEntryRef), i.off("afterUnmount", r.afterUnmountRef);
344
354
  },
345
355
  // Mount lifecycle hooks
346
356
  beforeMount() {
347
- s("Hook > beforeMount()", arguments);
357
+ n("Hook > beforeMount()", Array.from(arguments));
348
358
  },
349
- onCreateEntry({ parent: o, entry: l }) {
350
- if (n(this.settings.condition, l)) {
351
- const a = o.collection.length;
352
- s(`Hook > onCreateEntry() > [${a}] #${l.id}`, arguments);
359
+ onCreateEntry({ parent: i, entry: o }) {
360
+ if (s(this.settings.condition, o)) {
361
+ const a = i.collection.length;
362
+ n(
363
+ `Hook > onCreateEntry() > [${a}] #${o.id}`,
364
+ Array.from(arguments)
365
+ );
353
366
  }
354
367
  },
355
- onRegisterEntry({ parent: o, entry: l }) {
356
- if (n(this.settings.condition, l)) {
357
- const a = o.collection.length - 1;
358
- s(`Hook > onRegisterEntry() > [${a}] #${l.id}`, arguments);
368
+ onRegisterEntry({ parent: i, entry: o }) {
369
+ if (s(this.settings.condition, o)) {
370
+ const a = i.collection.length - 1;
371
+ n(
372
+ `Hook > onRegisterEntry() > [${a}] #${o.id}`,
373
+ Array.from(arguments)
374
+ );
359
375
  }
360
376
  },
361
377
  afterMount() {
362
- s("Hook > afterMount()", arguments);
378
+ n("Hook > afterMount()", Array.from(arguments));
363
379
  },
364
380
  // Unmount lifecycle hooks
365
381
  beforeUnmount() {
366
- s("Hook > beforeUnmount()", arguments, ["important", "neutral"]);
382
+ n("Hook > beforeUnmount()", Array.from(arguments), [
383
+ "important",
384
+ "neutral"
385
+ ]);
367
386
  },
368
- onDestroyEntry({ parent: o, entry: l }) {
369
- if (n(this.settings.condition, l)) {
370
- const a = o.collection.length - 1;
371
- s(`Hook > onDestroyEntry() > [${a}] #${l.id}`, arguments, [
372
- "important",
373
- "neutral"
374
- ]);
387
+ onDestroyEntry({ parent: i, entry: o }) {
388
+ if (s(this.settings.condition, o)) {
389
+ const a = i.collection.length - 1;
390
+ n(
391
+ `Hook > onDestroyEntry() > [${a}] #${o.id}`,
392
+ Array.from(arguments),
393
+ ["important", "neutral"]
394
+ );
375
395
  }
376
396
  },
377
- onDeregisterEntry({ parent: o, entry: l }) {
378
- if (n(this.settings.condition, l)) {
379
- const a = o.collection.length;
380
- s(`Hook > onDeregisterEntry() > [${a}] #${l.id}`, arguments, [
397
+ onDeregisterEntry({ parent: i, entry: o }) {
398
+ if (s(this.settings.condition, o)) {
399
+ const a = i.collection.length;
400
+ n(`Hook > onDeregisterEntry() > [${a}]`, Array.from(arguments), [
381
401
  "important",
382
402
  "neutral"
383
403
  ]);
384
404
  }
385
405
  },
386
406
  afterUnmount() {
387
- s("Hook > afterUnmount()", arguments, ["important", "neutral"]);
407
+ n("Hook > afterUnmount()", Array.from(arguments), [
408
+ "important",
409
+ "neutral"
410
+ ]);
388
411
  }
389
- } };
412
+ };
390
413
  }
391
- const ze = {
414
+ const Ke = {
392
415
  condition: !0
393
416
  };
394
- function Qe(t = {}) {
417
+ function Xe(t = {}) {
395
418
  const e = {
396
419
  name: "focusTrap",
397
- defaults: ze,
420
+ defaults: Ke,
398
421
  options: t
399
- }, s = {
422
+ }, n = {
400
423
  setup({ parent: o }) {
401
- o.on("opened", i, this), o.on("closed", r, this);
424
+ o.on("opened", r, this), o.on("closed", i, this);
402
425
  },
403
426
  teardown({ parent: o }) {
404
- o.off("opened", i), o.off("closed", r);
427
+ o.off("opened", r), o.off("closed", i);
405
428
  },
406
429
  onCreateEntry({ entry: o }) {
407
- o.focusTrap = new he();
430
+ o.focusTrap = new oe();
408
431
  }
409
432
  };
410
- function n(o, ...l) {
411
- return typeof o == "function" ? o(...l) : o;
433
+ function s(o, ...a) {
434
+ return typeof o == "function" ? o(...a) : o;
412
435
  }
413
- function i(o, l) {
414
- var c;
415
- const a = { plugin: l, parent: o.parent, entry: o };
416
- n(l.settings.condition, a) && ((c = o.focusTrap) == null || c.on(o.dialog));
436
+ function r(o, a) {
437
+ const l = { plugin: a, parent: o.parent, entry: o };
438
+ s(a.settings.condition, l) && o.focusTrap?.on(o.dialog);
417
439
  }
418
- function r(o, l) {
419
- var c;
420
- const a = { plugin: l, parent: o.parent, entry: o };
421
- n(l.settings.condition, a) && ((c = o.focusTrap) == null || c.off());
440
+ function i(o, a) {
441
+ const l = { plugin: a, parent: o.parent, entry: o };
442
+ s(a.settings.condition, l) && o.focusTrap?.off();
422
443
  }
423
- return { ...e, ...s };
444
+ return { ...e, ...n };
424
445
  }
425
- const Ke = {
426
- // The data attributes to get the breakpoint values from.
446
+ const Ye = {
447
+ // The data attributes to get the breakpoint values from
427
448
  dataBreakpoint: "breakpoint",
428
- // The data attributes to get the media query value from.
449
+ // The data attributes to get the media query value from
429
450
  dataMediaQuery: "media-query",
430
- // The string token to replace in the media query string.
451
+ // The string token to replace in the media query string
431
452
  token: "{{BP}}",
432
453
  // Sets a global breakpoint. Can be overridden by setting a data attribute
433
454
  // value. Notice: setting this option will enable a media query breakpoint on
@@ -447,331 +468,580 @@ const Ke = {
447
468
  onChange: () => {
448
469
  }
449
470
  };
450
- function je(t = {}) {
471
+ function Ge(t = {}) {
451
472
  const e = {
452
473
  name: "mediaQuery",
453
- defaults: Ke,
474
+ defaults: Ye,
454
475
  options: t
455
- }, s = {
456
- onCreateEntry({ entry: l }) {
457
- r.call(this, l);
476
+ }, n = {
477
+ // Run when an entry is created
478
+ // Sets up the MediaQueryList and event listener
479
+ onCreateEntry({ entry: a }) {
480
+ i.call(this, a);
458
481
  },
459
- onDestroyEntry({ entry: l }) {
460
- o(l);
482
+ // Run when an entry is destroyed
483
+ // Removes the MediaQueryList and event listener
484
+ onDestroyEntry({ entry: a }) {
485
+ o(a);
461
486
  }
462
487
  };
463
- function n(l) {
464
- const a = l.el.getAttribute(`data-${this.settings.dataMediaQuery}`);
465
- return !a && l.id in this.settings.mediaQueries ? this.settings.mediaQueries[l.id] : a;
466
- }
467
- function i(l) {
468
- let a = l.el.getAttribute(`data-${this.settings.dataBreakpoint}`);
469
- return !a && l.id in this.settings.breakpoints && (a = this.settings.breakpoints[l.id]), a && a in this.settings.breakpoints && (a = this.settings.breakpoints[a]), a && (a = getComputedStyle(document.body).getPropertyValue(`--${kt()}breakpoint-${a}`).trim() || a), a || this.settings.breakpoint;
470
- }
471
- function r(l) {
472
- let a = n.call(this, l);
473
- const c = i.call(this, l);
474
- if (!c && !a) return;
475
- c && !a && (a = this.settings.mediaQuery);
476
- const d = a.replace(new RegExp(`${this.settings.token}`, "g"), c);
477
- l.mql = window.matchMedia(d), l.mql.onchange = (f) => {
478
- this.settings.onChange(f, l);
479
- }, this.settings.onChange(l.mql, l);
480
- }
481
- function o(l) {
482
- l.mql && (l.mql.onchange = null, l.mql = null);
483
- }
484
- return { ...e, ...s };
485
- }
486
- const Ye = {
487
- // The property on entry objects to watch.
488
+ function s(a) {
489
+ const l = a.el.getAttribute(`data-${this.settings.dataMediaQuery}`);
490
+ return !l && a.id in this.settings.mediaQueries ? this.settings.mediaQueries[a.id] : l || void 0;
491
+ }
492
+ function r(a) {
493
+ let l = a.el.getAttribute(`data-${this.settings.dataBreakpoint}`);
494
+ return !l && a.id in this.settings.breakpoints && (l = this.settings.breakpoints[a.id]), l && l in this.settings.breakpoints && (l = this.settings.breakpoints[l]), l && (l = getComputedStyle(document.body).getPropertyValue(`--${mt()}breakpoint-${l}`).trim() || l), l || this.settings.breakpoint;
495
+ }
496
+ function i(a) {
497
+ let l = s.call(this, a);
498
+ const c = r.call(this, a);
499
+ if (!c && !l) return;
500
+ c && !l && (l = this.settings.mediaQuery);
501
+ const h = l.replace(new RegExp(`${this.settings.token}`, "g"), c);
502
+ a.mql = window.matchMedia(h), a.mql.onchange = (f) => {
503
+ this.settings.onChange(f, a);
504
+ }, this.settings.onChange(a.mql, a);
505
+ }
506
+ function o(a) {
507
+ a.mql && (a.mql.onchange = null, a.mql = null);
508
+ }
509
+ return { ...e, ...n };
510
+ }
511
+ const tn = {
512
+ // The property on entry objects to watch
488
513
  prop: "state",
489
- // The default value or a function to compute the initial value.
514
+ // The default value or a function to compute the initial value
490
515
  value: null,
491
- // The local storage key prefix.
516
+ // The local storage key prefix
492
517
  keyPrefix: "VB:",
493
518
  // The local storage key to use. If not provided, module name and prop value
494
519
  // will be used e.g., "VB:ModalState".
495
520
  key: null,
496
- // Condition to determine whether or not to store the value in local storage.
521
+ // Condition to determine whether or not to store the value in local storage
497
522
  condition: !1,
498
- // The function to run whenever the value changes.
523
+ // The function to run whenever the value changes
499
524
  onChange() {
500
525
  }
501
526
  };
502
- function Je(t = {}) {
527
+ function en(t = {}) {
503
528
  const e = {
504
529
  name: "propStore",
505
- defaults: Ye,
530
+ defaults: tn,
506
531
  options: t,
507
532
  store: null
508
- }, s = {
509
- setup({ parent: l }) {
510
- this.store = Vt(o.call(this, l.module));
533
+ }, n = {
534
+ setup({ parent: a }) {
535
+ this.store = Tt(o.call(this, a.module));
511
536
  },
512
- async onCreateEntry({ entry: l }) {
513
- await n.call(this, l);
537
+ async onCreateEntry({ entry: a }) {
538
+ await s.call(this, a);
514
539
  },
515
- onDestroyEntry({ entry: l }) {
516
- r.call(this, l);
540
+ onDestroyEntry({ entry: a }) {
541
+ i.call(this, a);
517
542
  }
518
543
  };
519
- async function n(l) {
520
- let a = l[this.settings.prop] || null;
521
- const c = { plugin: this, parent: l.parent, entry: l };
522
- Object.defineProperty(l, this.settings.prop, {
544
+ async function s(a) {
545
+ let l = a[this.settings.prop] || null;
546
+ const c = { plugin: this, parent: a.parent, entry: a };
547
+ Object.defineProperty(a, this.settings.prop, {
523
548
  configurable: !0,
524
549
  get() {
525
- return a;
550
+ return l;
526
551
  },
527
- set: async (d) => {
528
- if (a === d) return;
529
- const f = a;
530
- a = d, i(
552
+ set: async (h) => {
553
+ if (l === h) return;
554
+ const f = l;
555
+ l = h, r(
531
556
  this.settings.condition,
532
557
  c,
533
- d,
558
+ h,
534
559
  f
535
- ) && this.store.set(l.id, d), await this.settings.onChange(c, d, f);
560
+ ) && this.store.set(a.id, h), await this.settings.onChange(c, h, f);
536
561
  }
537
- }), Object.defineProperty(l, "store", {
562
+ }), Object.defineProperty(a, "store", {
538
563
  configurable: !0,
539
- get: () => this.store.get(l.id),
540
- set: (d) => {
541
- l[this.settings.prop] = d;
564
+ get: () => this.store.get(a.id),
565
+ set: (h) => {
566
+ a[this.settings.prop] = h;
542
567
  }
543
- }), l[this.settings.prop] = await i(this.settings.value, c) || l[this.settings.prop];
568
+ }), a[this.settings.prop] = await r(this.settings.value, c) || a[this.settings.prop];
544
569
  }
545
- function i(l, ...a) {
546
- return typeof l == "function" ? l(...a) : l;
570
+ function r(a, ...l) {
571
+ return typeof a == "function" ? a(...l) : a;
547
572
  }
548
- async function r(l) {
549
- const a = l[this.settings.prop];
550
- delete l[this.settings.prop], l[this.settings.prop] = a, this.store.set(l.id, null);
573
+ async function i(a) {
574
+ const l = a[this.settings.prop];
575
+ delete a[this.settings.prop], a[this.settings.prop] = l, this.store.set(a.id, null);
551
576
  }
552
- function o(l) {
553
- const a = this.settings.prop.charAt(0).toUpperCase() + this.settings.prop.slice(1), c = this.settings.key || l + a;
577
+ function o(a) {
578
+ const l = this.settings.prop.charAt(0).toUpperCase() + this.settings.prop.slice(1), c = this.settings.key || a + l;
554
579
  return this.settings.keyPrefix + c;
555
580
  }
556
- return { ...e, ...s };
581
+ return { ...e, ...n };
557
582
  }
558
- const Xe = {
583
+ const nn = {
559
584
  where: null,
560
585
  how: "append"
561
586
  };
562
- function Ge(t = {}) {
587
+ function sn(t = {}) {
563
588
  const e = {
564
589
  name: "teleport",
565
- defaults: Xe,
590
+ defaults: nn,
566
591
  options: t
567
- }, s = {
568
- onCreateEntry({ plugin: r, entry: o }) {
569
- n(r, o);
592
+ }, n = {
593
+ onCreateEntry({ plugin: i, entry: o }) {
594
+ s(i, o);
570
595
  },
571
- onDestroyEntry({ plugin: r, entry: o }) {
572
- i(r, o);
596
+ onDestroyEntry({ plugin: i, entry: o }) {
597
+ r(i, o);
573
598
  }
574
599
  };
575
- function n(r, o) {
600
+ function s(i, o) {
576
601
  o.teleport = () => {
577
- typeof o.teleportReturn == "function" && o.teleportReturn(), o.teleportReturn = oe(
602
+ typeof o.teleportReturn == "function" && o.teleportReturn(), o.teleportReturn = Yt(
578
603
  o.el,
579
- o.getSetting("teleport", { fallback: r.settings.where }),
580
- o.getSetting("teleportMethod", { fallback: r.settings.how })
604
+ o.getSetting("teleport", { fallback: i.settings.where }),
605
+ o.getSetting("teleportMethod", { fallback: i.settings.how })
581
606
  );
582
- }, o.teleport(), o.parent.emit("teleport", { plugin: r, parent, entry: o });
607
+ }, o.teleport(), o.parent.emit("teleport", { plugin: i, parent: o.parent, entry: o });
583
608
  }
584
- function i(r, o) {
585
- typeof o.teleportReturn == "function" && o.teleportReturn(), o.parent.emit("teleportReturn", { plugin: r, parent, entry: o });
609
+ function r(i, o) {
610
+ typeof o.teleportReturn == "function" && o.teleportReturn(), o.parent.emit("teleportReturn", {
611
+ plugin: i,
612
+ parent: o.parent,
613
+ entry: o
614
+ });
586
615
  }
587
- return { ...e, ...s };
616
+ return { ...e, ...n };
588
617
  }
589
- const qe = {
618
+ const rn = {
590
619
  dataConfig: "config",
591
620
  customProps: []
592
621
  };
593
- class xt {
594
- constructor(e, s, n = {}) {
595
- this.parent = e, this.id = (s == null ? void 0 : s.id) || s, this.el = Bt(s), this.settings = { ...n }, this.dataConfig = {}, this.customProps = {};
622
+ let le = class {
623
+ constructor(e, n, s = {}) {
624
+ this.parent = e, this.el = At(n), this.settings = { ...s }, this.dataConfig = {}, this.customProps = {};
625
+ }
626
+ get id() {
627
+ return this.el.id;
596
628
  }
597
629
  applySettings(e) {
598
630
  return Object.assign(this.settings, e);
599
631
  }
600
- getSetting(e, s) {
601
- return fe.call(this, e, s);
632
+ getSetting(e, n) {
633
+ return se.call(this, e, n);
602
634
  }
603
635
  buildDataConfig() {
604
636
  return Object.assign(
605
637
  this.dataConfig,
606
- ie(this.el, this.getSetting("dataConfig"))
638
+ Xt(this.el, this.getSetting("dataConfig"))
607
639
  );
608
640
  }
609
641
  buildCustomProps() {
610
- return Object.assign(this.customProps, ce(this));
642
+ return Object.assign(this.customProps, ne(this));
611
643
  }
612
644
  async init(e = {}) {
613
- if (this.el === null)
614
- throw new Error(
615
- `${this.parent.module} element was not found with ID: "${this.id}"`
616
- );
617
645
  this.applySettings(e), this.buildDataConfig(), this.buildCustomProps();
618
646
  }
619
647
  async destroy() {
620
648
  Object.getOwnPropertyNames(this).forEach((e) => {
621
- e !== "id" && delete this[e];
649
+ delete this[e];
622
650
  });
623
651
  }
624
- }
625
- class Ot {
652
+ }, on = class {
626
653
  constructor(e = {}) {
627
- this.module = this.constructor.name, this.collection = [], this.entryClass = xt, this.settings = { ...qe, ...e }, this.plugins = new ge(this.settings.presets), this.events = {}, Object.assign(this, ue);
654
+ this.module = this.constructor.name, this.collection = [], this.entryClass = le, this.settings = { ...rn, ...e }, this.plugins = new ae(this.settings.presets), this.events = {}, Object.assign(this, ie);
628
655
  }
629
- get(e, s = "id") {
630
- return this.collection.find((n) => n[s] === e);
656
+ get(e, n = "id") {
657
+ return this.collection.find((s) => s[n] === e);
658
+ }
659
+ getOrThrow(e, n = "id") {
660
+ const s = this.get(e, n);
661
+ if (s)
662
+ return s;
663
+ throw new Error(
664
+ `${this.module} entry not found in collection with ${n} of "${e}"`
665
+ );
631
666
  }
632
667
  applySettings(e) {
633
668
  return Object.assign(this.settings, e);
634
669
  }
635
- async createEntry(e, s) {
636
- const n = new this.entryClass(this, e, s);
637
- return await Q(n, "init"), await V("onCreateEntry", this, n), n;
670
+ async createEntry(e, n) {
671
+ const s = new this.entryClass(this, e, n);
672
+ return await V(s, "init"), await I("onCreateEntry", this, s), s;
638
673
  }
639
674
  async destroyEntry(e) {
640
- return await V("onDestroyEntry", this, e), await Q(e, "destroy"), e;
675
+ return await I("onDestroyEntry", this, e), await V(e, "destroy"), e;
641
676
  }
642
- async register(e, s = {}) {
643
- const n = Bt(e);
644
- if (n === null)
645
- throw new Error(
646
- `${this.module} element was not found with ID: "${(e == null ? void 0 : e.id) || e}"`
647
- );
648
- const i = this.collection.findIndex((r) => r.id === n.id);
649
- if (~i) {
650
- const r = this.collection[i];
651
- return r.el = n, typeof r.init == "function" && await r.init(s), r;
677
+ async register(e, n = {}) {
678
+ const s = At(e), r = this.collection.findIndex((i) => i.id === s.id);
679
+ if (~r) {
680
+ const i = this.collection[r];
681
+ return i.el = s, typeof i.init == "function" && await i.init(n), i;
652
682
  } else {
653
- const r = await this.createEntry(n, s);
654
- return this.collection.push(r), await V("onRegisterEntry", this, r), r;
683
+ const i = await this.createEntry(s, n);
684
+ return this.collection.push(i), await I("onRegisterEntry", this, i), i;
655
685
  }
656
686
  }
657
687
  async deregister(e) {
658
- const s = this.collection.findIndex((n) => n.id === e);
659
- if (~s) {
660
- const n = await this.destroyEntry(this.collection[s]);
661
- return await V(
688
+ const n = this.collection.findIndex((s) => s.id === e);
689
+ if (~n) {
690
+ const s = await this.destroyEntry(this.collection[n]);
691
+ return await I(
662
692
  "onDeregisterEntry",
663
693
  this,
664
- this.collection[s]
665
- ), this.collection.splice(s, 1), n;
694
+ this.collection[n]
695
+ ), this.collection.splice(n, 1), s;
666
696
  }
667
697
  return null;
668
698
  }
669
699
  async mount(e = {}) {
670
- var n;
671
700
  this.applySettings(e);
672
- for (const i of ((n = this.settings) == null ? void 0 : n.plugins) || [])
673
- this.plugins.add(i);
674
- for (const i of this.plugins)
675
- await Q(i, "setup", { plugin: i, parent: this });
676
- await V("beforeMount", this);
677
- const s = document.querySelectorAll(this.settings.selector);
678
- for (const i of s)
679
- await this.register(i);
680
- return await V("afterMount", this), this;
701
+ for (const s of this.settings?.plugins || [])
702
+ this.plugins.add(s);
703
+ for (const s of this.plugins)
704
+ await V(s, "setup", { plugin: s, parent: this });
705
+ await I("beforeMount", this);
706
+ const n = document.querySelectorAll(this.settings.selector);
707
+ for (const s of n)
708
+ await this.register(s);
709
+ return await I("afterMount", this), this;
681
710
  }
682
711
  async unmount() {
683
- for (await V("beforeUnmount", this); this.collection.length > 0; )
712
+ for (await I("beforeUnmount", this); this.collection.length > 0; )
684
713
  await this.deregister(this.collection[0].id);
685
- await V("afterUnmount", this);
714
+ await I("afterUnmount", this);
686
715
  for (const e of this.plugins)
687
- await Q(e, "teardown", { plugin: e, parent: this });
716
+ await V(e, "teardown", { plugin: e, parent: this });
688
717
  for (const e of [...this.plugins])
689
718
  this.plugins.remove(e.name);
690
719
  return this;
691
720
  }
692
- }
693
- function Ze(t) {
721
+ };
722
+ function an(t = {}) {
694
723
  const e = {
695
- prefix: ae("prefix-themes", { fallback: "vb-theme-" }),
724
+ prefix: ee("prefix-themes", { fallback: "vb-theme-" }),
696
725
  themes: ["root", "light", "dark"],
697
726
  storeKey: "VB:Profile"
698
727
  };
699
- for (const [r] of Object.entries(e))
700
- t && t[r] && (e[r] = t[r]);
701
- const s = {
728
+ for (const [i] of Object.entries(e))
729
+ t && t[i] && (e[i] = t[i]);
730
+ const n = {
702
731
  onInit() {
703
732
  },
704
733
  onChange() {
705
734
  }
706
735
  };
707
- for (const [r] of Object.entries(s))
708
- t && t[r] && (s[r] = t[r]);
709
- const n = Vt(e.storeKey), i = {
736
+ for (const [i] of Object.entries(n))
737
+ t && t[i] && (n[i] = t[i]);
738
+ const s = Tt(e.storeKey), r = {
710
739
  // Store our settings in the API
711
740
  settings: e,
712
741
  // Actions
713
- add(r) {
714
- e.themes.push(r);
742
+ add(i) {
743
+ e.themes.push(i);
715
744
  },
716
- remove(r) {
717
- const o = e.themes.indexOf(r);
745
+ remove(i) {
746
+ const o = e.themes.indexOf(i);
718
747
  ~o && e.themes.splice(o, 1);
719
748
  },
720
- callback(r) {
721
- s[r].call(this);
749
+ callback(i) {
750
+ n[i].call(this);
722
751
  },
723
752
  // Getters
724
753
  get class() {
725
754
  return `${e.prefix}${this.theme}`;
726
755
  },
727
756
  get classes() {
728
- return e.themes.map((r) => `${e.prefix}${r}`);
757
+ return e.themes.map((i) => `${e.prefix}${i}`);
729
758
  },
730
759
  get themes() {
731
760
  return e.themes;
732
761
  },
733
762
  // Setup the theme get and set methods
734
763
  get theme() {
735
- return n.get("theme") || "root";
764
+ return s.get("theme") || "root";
736
765
  },
737
- set theme(r) {
738
- e.themes.includes(r) ? this.theme != r && (n.set("theme", r), document.documentElement.classList.remove(...this.classes), document.documentElement.classList.add(`${e.prefix}${r}`), this.callback("onChange")) : console.error(`Not a valid theme value: "${r}"`);
766
+ set theme(i) {
767
+ e.themes.includes(i) ? this.theme != i && (s.set("theme", i), document.documentElement.classList.remove(...this.classes), document.documentElement.classList.add(`${e.prefix}${i}`), this.callback("onChange")) : console.error(`Not a valid theme value: "${i}"`);
739
768
  }
740
769
  };
741
- return i.callback("onInit"), i;
770
+ return r.callback("onInit"), r;
742
771
  }
743
- const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
772
+ const gi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
744
773
  __proto__: null,
745
- Collection: Ot,
746
- CollectionEntry: xt,
747
- FocusTrap: he,
748
- FocusableArray: de,
749
- PluginsArray: ge,
750
- StackArray: me,
751
- cssVar: ae,
752
- debug: We,
753
- dispatchLifecycleHook: V,
754
- eventEmitter: ue,
755
- focusTrap: Qe,
756
- focusableSelectors: se,
757
- getCustomProps: ce,
758
- getDataConfig: ie,
759
- getElement: Bt,
760
- getPrefix: kt,
761
- getSetting: fe,
762
- localStore: Vt,
763
- maybeRunMethod: Q,
764
- mediaQuery: je,
765
- propStore: Je,
766
- setGlobalState: bt,
767
- teleport: Ge,
768
- teleportElement: oe,
769
- themeStore: Ze,
770
- toCamel: re,
771
- toKebab: Ut,
772
- toMilliseconds: le,
773
- transition: wt
774
- }, Symbol.toStringTag, { value: "Module" })), tn = {
774
+ Collection: on,
775
+ CollectionEntry: le,
776
+ FocusTrap: oe,
777
+ FocusableArray: re,
778
+ PluginsArray: ae,
779
+ StackArray: _e,
780
+ cssVar: ee,
781
+ debug: Ze,
782
+ dispatchLifecycleHook: I,
783
+ eventEmitter: ie,
784
+ focusTrap: Xe,
785
+ focusableSelectors: Kt,
786
+ getCustomProps: ne,
787
+ getDataConfig: Xt,
788
+ getElement: At,
789
+ getPrefix: mt,
790
+ getSetting: se,
791
+ localStore: Tt,
792
+ maybeRunMethod: V,
793
+ mediaQuery: Ge,
794
+ propStore: en,
795
+ setGlobalState: Be,
796
+ teleport: sn,
797
+ teleportElement: Yt,
798
+ themeStore: an,
799
+ toCamel: Gt,
800
+ toKebab: Ot,
801
+ toMilliseconds: te,
802
+ transition: Ue
803
+ }, Symbol.toStringTag, { value: "Module" }));
804
+ function ln(t, e = "config") {
805
+ const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
806
+ return n ? JSON.parse(n) : {};
807
+ }
808
+ function ce(t) {
809
+ if (typeof t == "string") {
810
+ const e = document.getElementById(t);
811
+ if (e) return e;
812
+ throw new Error(`Element not found with ID: "${t}"`);
813
+ } else if (t instanceof HTMLElement) {
814
+ if (!t.id)
815
+ throw new Error("HTMLElement must have an ID");
816
+ return t;
817
+ } else
818
+ throw new Error("Invalid argument: query must be a string or HTMLElement");
819
+ }
820
+ async function Z(t, e, ...n) {
821
+ e in t && typeof t[e] == "function" && await t[e](...n);
822
+ }
823
+ function cn(t) {
824
+ return t.split("-").map(
825
+ (e, n) => n === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)
826
+ ).join("");
827
+ }
828
+ function ue(t) {
829
+ return t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
830
+ }
831
+ function un(t) {
832
+ if (typeof t == "number")
833
+ return t;
834
+ const e = parseFloat(t);
835
+ if (!Number.isNaN(e)) {
836
+ const n = t.includes("ms");
837
+ return e * (n ? 1 : 1e3);
838
+ }
839
+ throw new Error(`Could not convert value to milliseconds: ${t}`);
840
+ }
841
+ function he(t, e, n, s, r = 0) {
842
+ return new Promise((i) => {
843
+ t.classList.remove(e), t.classList.add(n), setTimeout(() => {
844
+ t.classList.add(s), t.classList.remove(n), i(t);
845
+ }, un(r));
846
+ });
847
+ }
848
+ async function N(t, e, n) {
849
+ await Z(e, t, n), n && await Z(n, t);
850
+ for (const s of e.plugins)
851
+ await Z(s, t, { plugin: s, parent: e, entry: n });
852
+ await e.emit(t, n);
853
+ }
854
+ function hn(t) {
855
+ const e = getComputedStyle(t.el), n = {}, s = t.getSetting("customProps");
856
+ for (let r = 0; r < s.length; r++) {
857
+ const i = fn(), o = t.parent.module.toLowerCase(), a = ue(s[r]), l = e.getPropertyValue(`--${i}${o}-${a}`).trim();
858
+ l && (n[a] = l);
859
+ }
860
+ return n;
861
+ }
862
+ function fn() {
863
+ return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
864
+ }
865
+ function dn(t, e, n = "camel") {
866
+ return e = n === "camel" ? cn(e) : ue(e), t.split(".").concat(e).reduce((s, r) => s?.[r], this);
867
+ }
868
+ function gn(t, e = {}) {
869
+ const {
870
+ fallback: n,
871
+ props: s = ["dataConfig", "customProps", "settings", "parent.settings"]
872
+ } = e;
873
+ for (const r of s) {
874
+ const i = r !== "customProps" ? "camel" : "kebab", o = dn.call(this, r, t, i);
875
+ if (o !== void 0)
876
+ return o;
877
+ }
878
+ if (n !== void 0)
879
+ return n;
880
+ throw new Error(`${this.parent.module} setting does not exist: ${t}`);
881
+ }
882
+ function pn(t, e) {
883
+ e && document.querySelectorAll(e).forEach((n) => {
884
+ t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
885
+ });
886
+ }
887
+ function mn(t, e) {
888
+ e && document.querySelectorAll(e).forEach((n) => {
889
+ n.inert = t;
890
+ });
891
+ }
892
+ function Pt(t, e, n) {
893
+ mn(!!t, e), pn(!!t, n);
894
+ }
895
+ const yn = {
896
+ events: {},
897
+ on(t, e, ...n) {
898
+ this.events[t] || (this.events[t] = []), this.events[t].some(
899
+ (s) => s.listener === e
900
+ ) || this.events[t].push({ listener: e, args: n });
901
+ },
902
+ off(t, e) {
903
+ this.events[t] && (this.events[t] = this.events[t].filter(
904
+ (n) => n.listener !== e
905
+ ));
906
+ },
907
+ async emit(t, e) {
908
+ if (t = t.startsWith("on") ? t.slice(2, 3).toLowerCase() + t.slice(3) : t, !!this.events[t])
909
+ for (const { listener: n, args: s } of this.events[t])
910
+ await n(e, ...s);
911
+ }
912
+ };
913
+ let wn = class extends Array {
914
+ constructor(e = {}) {
915
+ super(), this.presets = e;
916
+ }
917
+ applySettings(e) {
918
+ const n = e?.defaults || {}, s = this.presets?.[e.name] || {}, r = e?.options || {};
919
+ e.settings = { ...n, ...s, ...r };
920
+ }
921
+ validate(e) {
922
+ return !("name" in e) || typeof e.name != "string" ? (console.error("Plugin requires a name!"), !1) : !0;
923
+ }
924
+ get(e) {
925
+ return this.find((n) => n.name === e);
926
+ }
927
+ add(e) {
928
+ if (Array.isArray(e))
929
+ e.forEach((n) => this.add(n));
930
+ else if (this.applySettings(e), this.validate(e)) {
931
+ const n = this.findIndex((s) => s.name === e.name);
932
+ ~n ? this[n] = e : this.push(e);
933
+ }
934
+ }
935
+ remove(e) {
936
+ const n = this.findIndex((s) => s.name === e);
937
+ ~n && this.splice(n, 1);
938
+ }
939
+ };
940
+ const vn = {
941
+ dataConfig: "config",
942
+ customProps: []
943
+ };
944
+ let fe = class {
945
+ constructor(e, n, s = {}) {
946
+ this.parent = e, this.el = ce(n), this.settings = { ...s }, this.dataConfig = {}, this.customProps = {};
947
+ }
948
+ get id() {
949
+ return this.el.id;
950
+ }
951
+ applySettings(e) {
952
+ return Object.assign(this.settings, e);
953
+ }
954
+ getSetting(e, n) {
955
+ return gn.call(this, e, n);
956
+ }
957
+ buildDataConfig() {
958
+ return Object.assign(
959
+ this.dataConfig,
960
+ ln(this.el, this.getSetting("dataConfig"))
961
+ );
962
+ }
963
+ buildCustomProps() {
964
+ return Object.assign(this.customProps, hn(this));
965
+ }
966
+ async init(e = {}) {
967
+ this.applySettings(e), this.buildDataConfig(), this.buildCustomProps();
968
+ }
969
+ async destroy() {
970
+ Object.getOwnPropertyNames(this).forEach((e) => {
971
+ delete this[e];
972
+ });
973
+ }
974
+ }, bn = class {
975
+ constructor(e = {}) {
976
+ this.module = this.constructor.name, this.collection = [], this.entryClass = fe, this.settings = { ...vn, ...e }, this.plugins = new wn(this.settings.presets), this.events = {}, Object.assign(this, yn);
977
+ }
978
+ get(e, n = "id") {
979
+ return this.collection.find((s) => s[n] === e);
980
+ }
981
+ getOrThrow(e, n = "id") {
982
+ const s = this.get(e, n);
983
+ if (s)
984
+ return s;
985
+ throw new Error(
986
+ `${this.module} entry not found in collection with ${n} of "${e}"`
987
+ );
988
+ }
989
+ applySettings(e) {
990
+ return Object.assign(this.settings, e);
991
+ }
992
+ async createEntry(e, n) {
993
+ const s = new this.entryClass(this, e, n);
994
+ return await Z(s, "init"), await N("onCreateEntry", this, s), s;
995
+ }
996
+ async destroyEntry(e) {
997
+ return await N("onDestroyEntry", this, e), await Z(e, "destroy"), e;
998
+ }
999
+ async register(e, n = {}) {
1000
+ const s = ce(e), r = this.collection.findIndex((i) => i.id === s.id);
1001
+ if (~r) {
1002
+ const i = this.collection[r];
1003
+ return i.el = s, typeof i.init == "function" && await i.init(n), i;
1004
+ } else {
1005
+ const i = await this.createEntry(s, n);
1006
+ return this.collection.push(i), await N("onRegisterEntry", this, i), i;
1007
+ }
1008
+ }
1009
+ async deregister(e) {
1010
+ const n = this.collection.findIndex((s) => s.id === e);
1011
+ if (~n) {
1012
+ const s = await this.destroyEntry(this.collection[n]);
1013
+ return await N(
1014
+ "onDeregisterEntry",
1015
+ this,
1016
+ this.collection[n]
1017
+ ), this.collection.splice(n, 1), s;
1018
+ }
1019
+ return null;
1020
+ }
1021
+ async mount(e = {}) {
1022
+ this.applySettings(e);
1023
+ for (const s of this.settings?.plugins || [])
1024
+ this.plugins.add(s);
1025
+ for (const s of this.plugins)
1026
+ await Z(s, "setup", { plugin: s, parent: this });
1027
+ await N("beforeMount", this);
1028
+ const n = document.querySelectorAll(this.settings.selector);
1029
+ for (const s of n)
1030
+ await this.register(s);
1031
+ return await N("afterMount", this), this;
1032
+ }
1033
+ async unmount() {
1034
+ for (await N("beforeUnmount", this); this.collection.length > 0; )
1035
+ await this.deregister(this.collection[0].id);
1036
+ await N("afterUnmount", this);
1037
+ for (const e of this.plugins)
1038
+ await Z(e, "teardown", { plugin: e, parent: this });
1039
+ for (const e of [...this.plugins])
1040
+ this.plugins.remove(e.name);
1041
+ return this;
1042
+ }
1043
+ };
1044
+ const En = {
775
1045
  focusTrap: {
776
1046
  condition: ({ entry: t }) => t.state === "closed" || t.state === "opened" && t.mode === "modal"
777
1047
  },
@@ -786,28 +1056,22 @@ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
786
1056
  condition: ({ entry: t }) => ["opened", "closed", "indeterminate"].includes(t.state),
787
1057
  onChange: ({ entry: t }) => t.applyState()
788
1058
  }
789
- }, en = {
790
- // Plugin presets
791
- presets: tn,
792
- // Data attributes
1059
+ }, xn = {
1060
+ presets: En,
793
1061
  dataOpen: "drawer-open",
794
1062
  dataClose: "drawer-close",
795
1063
  dataToggle: "drawer-toggle",
796
- // Selectors
797
1064
  selector: ".drawer",
798
1065
  selectorDialog: ".drawer__dialog",
799
1066
  selectorScreen: ".drawer",
800
1067
  selectorFocus: "[data-focus]",
801
1068
  selectorInert: null,
802
1069
  selectorOverflow: "body",
803
- // State classes
804
1070
  stateOpened: "is-opened",
805
1071
  stateOpening: "is-opening",
806
1072
  stateClosing: "is-closing",
807
1073
  stateClosed: "is-closed",
808
- // Classes
809
1074
  classModal: "drawer_modal",
810
- // Feature toggles
811
1075
  customProps: ["transition-duration"],
812
1076
  breakpoints: null,
813
1077
  customEventPrefix: "drawer:",
@@ -815,252 +1079,545 @@ const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
815
1079
  transition: !0,
816
1080
  transitionDuration: 300
817
1081
  };
818
- function nn(t) {
1082
+ function $n(t) {
819
1083
  switch (t.mode) {
820
1084
  case "inline":
821
- return sn.call(this, t);
1085
+ return Sn(t);
822
1086
  case "modal":
823
- return on.call(this, t);
1087
+ return Cn(t);
824
1088
  default:
825
1089
  throw new Error(`"${t.mode}" is not a valid drawer mode.`);
826
1090
  }
827
1091
  }
828
- async function sn(t) {
829
- return t.el.classList.remove(t.getSetting("classModal")), t.dialog.removeAttribute("aria-modal"), bt(
1092
+ async function Sn(t) {
1093
+ return t.el.classList.remove(t.getSetting("classModal")), t.dialog.removeAttribute("aria-modal"), Pt(
830
1094
  !1,
831
1095
  t.getSetting("selectorInert"),
832
1096
  t.getSetting("selectorOverflow")
833
1097
  ), t.applyState(), t.el.dispatchEvent(
834
1098
  new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
835
- detail: this,
1099
+ detail: t.parent,
836
1100
  bubbles: !0
837
1101
  })
838
1102
  ), await t.parent.emit("switchMode", t), t;
839
1103
  }
840
- async function on(t) {
1104
+ async function Cn(t) {
841
1105
  return t.el.classList.add(t.getSetting("classModal")), t.dialog.setAttribute("aria-modal", "true"), await t.close(!1, !1), t.el.dispatchEvent(
842
1106
  new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
843
- detail: this,
1107
+ detail: t.parent,
844
1108
  bubbles: !0
845
1109
  })
846
1110
  ), await t.parent.emit("switchMode", t), t;
847
1111
  }
848
- var q;
849
- class rn extends xt {
850
- constructor(s, n, i = {}) {
851
- super(s, n, i);
852
- U(this, q);
853
- this.dialog = null, this.trigger = null, this.state = null, this.inlineState = null, S(this, q, "indeterminate");
1112
+ function de(t) {
1113
+ t.dialog && t.state === "opened" ? (t.dialog.querySelector(t.parent.settings.selectorFocus) || t.dialog).focus() : t.trigger && (t.trigger.focus(), t.trigger = null);
1114
+ }
1115
+ async function kt(t, e, n = !0) {
1116
+ return (t.state === "closed" || t.state === "indeterminate" || t.state === null) && (t.setState("opening"), e ?? t.getSetting("transition") ? await he(
1117
+ t.el,
1118
+ t.getSetting("stateClosed"),
1119
+ t.getSetting("stateOpening"),
1120
+ t.getSetting("stateOpened"),
1121
+ t.getSetting("transitionDuration")
1122
+ ) : (t.el.classList.add(t.getSetting("stateOpened")), t.el.classList.remove(t.getSetting("stateClosed"))), t.setState("opened"), t.mode === "modal" && Pt(
1123
+ !0,
1124
+ t.getSetting("selectorInert"),
1125
+ t.getSetting("selectorOverflow")
1126
+ ), n && de(t), t.el.dispatchEvent(
1127
+ new CustomEvent(t.getSetting("customEventPrefix") + "opened", {
1128
+ detail: t.parent,
1129
+ bubbles: !0
1130
+ })
1131
+ ), await t.parent.emit("opened", t)), t;
1132
+ }
1133
+ async function Rt(t, e, n = !0) {
1134
+ return (t.state === "opened" || t.state === "indeterminate" || t.state === null) && (t.setState("closing"), document.activeElement && document.activeElement instanceof HTMLElement && document.activeElement.blur(), e ?? t.getSetting("transition") ? await he(
1135
+ t.el,
1136
+ t.getSetting("stateOpened"),
1137
+ t.getSetting("stateClosing"),
1138
+ t.getSetting("stateClosed"),
1139
+ t.getSetting("transitionDuration")
1140
+ ) : (t.el.classList.add(t.getSetting("stateClosed")), t.el.classList.remove(t.getSetting("stateOpened"))), t.setState("closed"), t.mode === "modal" && Pt(
1141
+ !1,
1142
+ t.getSetting("selectorInert"),
1143
+ t.getSetting("selectorOverflow")
1144
+ ), n && de(t), t.el.dispatchEvent(
1145
+ new CustomEvent(t.getSetting("customEventPrefix") + "closed", {
1146
+ detail: t.parent,
1147
+ bubbles: !0
1148
+ })
1149
+ ), await t.parent.emit("closed", t)), t;
1150
+ }
1151
+ async function ge(t, e, n) {
1152
+ return t.state === "closed" ? kt(t, e, n) : Rt(t, e, n);
1153
+ }
1154
+ class Ln extends fe {
1155
+ #t;
1156
+ constructor(e, n, s = {}) {
1157
+ super(e, n, s), this.#t = "indeterminate", this.dialog = this.el.querySelector(this.getSetting("selectorDialog")) || this.el, this.trigger = null, this.state = null, this.inlineState = null;
854
1158
  }
855
1159
  get mode() {
856
- return E(this, q);
1160
+ return this.#t;
857
1161
  }
858
- set mode(s) {
859
- E(this, q) !== s && (S(this, q, s), nn.call(this.parent, this));
1162
+ set mode(e) {
1163
+ this.#t !== e && (this.#t = e, $n(this));
860
1164
  }
861
- setState(s) {
862
- this.state = s;
1165
+ setState(e) {
1166
+ this.state = e;
863
1167
  const n = ["opening", "closing"];
864
- this.mode === "inline" && !n.includes(s) && (this.inlineState = s), s === "indeterminate" && (this.el.classList.remove(this.getSetting("stateOpened")), this.el.classList.remove(this.getSetting("stateOpening")), this.el.classList.remove(this.getSetting("stateClosed")), this.el.classList.remove(this.getSetting("stateClosing")));
1168
+ this.mode === "inline" && !n.includes(e) && (this.inlineState = e), e === "indeterminate" && (this.el.classList.remove(this.getSetting("stateOpened")), this.el.classList.remove(this.getSetting("stateOpening")), this.el.classList.remove(this.getSetting("stateClosed")), this.el.classList.remove(this.getSetting("stateClosing")));
865
1169
  }
866
1170
  async applyState() {
867
- if (this.mode !== "modal") {
868
- if (this.inlineState === "opened")
1171
+ if (this.mode === "modal") return this;
1172
+ if (this.inlineState === "opened")
1173
+ return await this.open(!1, !1);
1174
+ if (this.inlineState === "closed")
1175
+ return await this.close(!1, !1);
1176
+ if (this.state === null) {
1177
+ if (this.el.classList.contains(this.getSetting("stateOpened")))
869
1178
  return await this.open(!1, !1);
870
- if (this.inlineState === "closed")
1179
+ if (this.el.classList.contains(this.getSetting("stateClosed")))
871
1180
  return await this.close(!1, !1);
872
- if (this.state === null) {
873
- if (this.el.classList.contains(this.getSetting("stateOpened")))
874
- return await this.open(!1, !1);
875
- if (this.el.classList.contains(this.getSetting("stateClosed")))
876
- return await this.close(!1, !1);
877
- }
878
- return this.setState("indeterminate");
879
1181
  }
1182
+ return this.setState("indeterminate"), this;
880
1183
  }
881
- async open(s, n) {
882
- return this.parent.open(this, s, n);
1184
+ async open(e, n) {
1185
+ return kt(this, e, n);
883
1186
  }
884
- async close(s, n) {
885
- return this.parent.close(this, s, n);
1187
+ async close(e, n) {
1188
+ return Rt(this, e, n);
886
1189
  }
887
- async toggle(s, n) {
888
- return this.parent.toggle(this, s, n);
1190
+ async toggle(e, n) {
1191
+ return ge(this, e, n);
889
1192
  }
890
1193
  async deregister() {
891
1194
  return this.parent.deregister(this.id);
892
1195
  }
893
1196
  async onCreateEntry() {
894
- const s = this.el.querySelector(this.getSetting("selectorDialog"));
895
- this.dialog = s || this.el, this.getSetting("setTabindex") && this.dialog.setAttribute("tabindex", "-1"), await this.applyState(), this.inlineState = this.state, this.mode = this.el.classList.contains(this.getSetting("classModal")) ? "modal" : "inline";
1197
+ this.getSetting("setTabindex") && this.dialog && this.dialog.setAttribute("tabindex", "-1"), await this.applyState(), this.inlineState = this.state, this.mode = this.el && this.el.classList.contains(this.getSetting("classModal")) ? "modal" : "inline";
896
1198
  }
897
1199
  async onDestroyEntry() {
898
1200
  this.mode === "modal" && this.state === "opened" && await this.close(!1);
899
1201
  }
900
1202
  }
901
- q = new WeakMap();
902
- function nt(t) {
903
- const e = typeof t == "string" ? this.get(t) : t;
904
- if (e)
905
- return e;
906
- throw new Error(
907
- `Drawer not found in collection with id of "${t.id || t}".`
908
- );
909
- }
910
- async function ln(t) {
911
- const e = t.target.closest(`
912
- [data-${this.settings.dataOpen}],
913
- [data-${this.settings.dataToggle}],
914
- [data-${this.settings.dataClose}]
915
- `);
1203
+ async function An(t) {
1204
+ const e = t.target;
916
1205
  if (e) {
917
- t.preventDefault(), e.matches(`[data-${this.settings.dataToggle}]`) && e.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ").forEach((n) => {
918
- const i = nt.call(this, n);
919
- return i.trigger = e, i.toggle();
920
- }), e.matches(`[data-${this.settings.dataOpen}]`) && e.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ").forEach((n) => {
921
- const i = nt.call(this, n);
922
- return i.trigger = e, i.open();
923
- }), e.matches(`[data-${this.settings.dataClose}]`) && e.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ").forEach((n) => {
924
- if (n) {
925
- const i = nt.call(this, n);
926
- return i.trigger = e, i.close();
927
- } else {
928
- const i = t.target.closest(this.settings.selector);
929
- if (i) return this.close(i.id);
930
- }
931
- });
932
- return;
1206
+ const n = e.closest(`
1207
+ [data-${this.settings.dataOpen}],
1208
+ [data-${this.settings.dataToggle}],
1209
+ [data-${this.settings.dataClose}]
1210
+ `);
1211
+ if (n) {
1212
+ t.preventDefault(), n.matches(`[data-${this.settings.dataToggle}]`) && n.getAttribute(`data-${this.settings.dataToggle}`)?.trim().split(" ")?.forEach((s) => {
1213
+ const r = this.getOrThrow(s);
1214
+ return r.trigger = n, r.toggle();
1215
+ }), n.matches(`[data-${this.settings.dataOpen}]`) && n.getAttribute(`data-${this.settings.dataOpen}`)?.trim().split(" ")?.forEach((s) => {
1216
+ const r = this.getOrThrow(s);
1217
+ return r.trigger = n, r.open();
1218
+ }), n.matches(`[data-${this.settings.dataClose}]`) && n.getAttribute(`data-${this.settings.dataClose}`)?.trim().split(" ")?.forEach((s) => {
1219
+ if (s) {
1220
+ const r = this.getOrThrow(s);
1221
+ return r.trigger = n, r.close();
1222
+ } else {
1223
+ const r = e.closest(this.settings.selector);
1224
+ if (r) return this.close(r.id);
1225
+ }
1226
+ });
1227
+ return;
1228
+ }
1229
+ if (this.activeModal && e.matches(this.settings.selectorScreen))
1230
+ return this.close(this.activeModal.id);
933
1231
  }
934
- if (this.activeModal && t.target.matches(this.settings.selectorScreen))
935
- return this.close(this.activeModal.id);
936
1232
  }
937
- function an(t) {
1233
+ function On(t) {
938
1234
  if (t.key === "Escape" && this.activeModal)
939
1235
  return this.close(this.activeModal.id);
940
1236
  }
941
- function pe(t) {
942
- t.state === "opened" ? (t.dialog.querySelector(this.settings.selectorFocus) || t.dialog).focus() : t.trigger && (t.trigger.focus(), t.trigger = null);
943
- }
944
- async function ye(t, e, s = !0) {
945
- const n = nt.call(this, t);
946
- return (n.state === "closed" || n.state === "indeterminate" || n.state === null) && (n.setState("opening"), e ?? n.getSetting("transition") ? await wt(
947
- n.el,
948
- n.getSetting("stateClosed"),
949
- n.getSetting("stateOpening"),
950
- n.getSetting("stateOpened"),
951
- n.getSetting("transitionDuration")
952
- ) : (n.el.classList.add(n.getSetting("stateOpened")), n.el.classList.remove(n.getSetting("stateClosed"))), n.setState("opened"), n.mode === "modal" && bt(
953
- !0,
954
- n.getSetting("selectorInert"),
955
- n.getSetting("selectorOverflow")
956
- ), s && pe.call(this, n), n.el.dispatchEvent(
957
- new CustomEvent(n.getSetting("customEventPrefix") + "opened", {
958
- detail: this,
959
- bubbles: !0
960
- })
961
- ), await n.parent.emit("opened", n)), n;
962
- }
963
- async function we(t, e, s = !0) {
964
- const n = nt.call(this, t);
965
- return (n.state === "opened" || n.state === "indeterminate" || n.state === null) && (n.setState("closing"), document.activeElement.blur(), e ?? n.getSetting("transition") ? await wt(
966
- n.el,
967
- n.getSetting("stateOpened"),
968
- n.getSetting("stateClosing"),
969
- n.getSetting("stateClosed"),
970
- n.getSetting("transitionDuration")
971
- ) : (n.el.classList.add(n.getSetting("stateClosed")), n.el.classList.remove(n.getSetting("stateOpened"))), n.setState("closed"), n.mode === "modal" && bt(
972
- !1,
973
- n.getSetting("selectorInert"),
974
- n.getSetting("selectorOverflow")
975
- ), s && pe.call(this, n), n.el.dispatchEvent(
976
- new CustomEvent(n.getSetting("customEventPrefix") + "closed", {
977
- detail: this,
978
- bubbles: !0
979
- })
980
- ), await n.parent.emit("closed", n)), n;
981
- }
982
- async function cn(t, e, s) {
983
- const n = nt.call(this, t);
984
- return n.state === "closed" ? ye.call(this, n, e, s) : we.call(this, n, e, s);
985
- }
986
- var it, ot;
987
- class us extends Ot {
988
- constructor(s) {
989
- super({ ...en, ...s });
990
- U(this, it);
991
- U(this, ot);
992
- this.module = "Drawer", this.entryClass = rn, S(this, it, ln.bind(this)), S(this, ot, an.bind(this));
1237
+ class wi extends bn {
1238
+ #t;
1239
+ #e;
1240
+ constructor(e) {
1241
+ super({ ...xn, ...e }), this.module = "Drawer", this.entryClass = Ln, this.#t = An.bind(this), this.#e = On.bind(this);
993
1242
  }
994
1243
  get activeModal() {
995
- return this.collection.find((s) => s.state === "opened" && s.mode === "modal");
1244
+ return this.collection.find((e) => e.state === "opened" && e.mode === "modal");
996
1245
  }
997
- async open(s, n, i) {
998
- return ye.call(this, s, n, i);
1246
+ async open(e, n, s) {
1247
+ const r = this.getOrThrow(e);
1248
+ return kt(r, n, s);
999
1249
  }
1000
- async close(s, n, i) {
1001
- return we.call(this, s, n, i);
1250
+ async close(e, n, s) {
1251
+ const r = this.getOrThrow(e);
1252
+ return Rt(r, n, s);
1002
1253
  }
1003
- async toggle(s, n, i) {
1004
- return cn.call(this, s, n, i);
1254
+ async toggle(e, n, s) {
1255
+ const r = this.getOrThrow(e);
1256
+ return ge(r, n, s);
1005
1257
  }
1006
1258
  async afterMount() {
1007
- document.addEventListener("click", E(this, it), !1), document.addEventListener("keydown", E(this, ot), !1);
1008
- }
1009
- async beforeUnmount() {
1010
- this.trigger = null;
1259
+ document.addEventListener("click", this.#t, !1), document.addEventListener("keydown", this.#e, !1);
1011
1260
  }
1012
1261
  async afterUnmount() {
1013
- document.removeEventListener("click", E(this, it), !1), document.removeEventListener("keydown", E(this, ot), !1);
1262
+ document.removeEventListener("click", this.#t, !1), document.removeEventListener("keydown", this.#e, !1);
1014
1263
  }
1015
1264
  }
1016
- it = new WeakMap(), ot = new WeakMap();
1017
- const fn = {
1018
- // Data attributes
1019
- dataOpen: "modal-open",
1020
- dataClose: "modal-close",
1021
- dataReplace: "modal-replace",
1022
- // Selectors
1023
- selector: ".modal",
1024
- selectorDialog: ".modal__dialog",
1025
- selectorScreen: ".modal",
1026
- selectorRequired: '[role="alertdialog"]',
1027
- selectorFocus: "[data-focus]",
1028
- selectorInert: null,
1029
- selectorOverflow: "body",
1030
- // State classes
1031
- stateOpened: "is-opened",
1032
- stateOpening: "is-opening",
1033
- stateClosing: "is-closing",
1034
- stateClosed: "is-closed",
1035
- // Feature settings
1036
- customProps: ["transition-duration"],
1037
- customEventPrefix: "modal:",
1038
- setTabindex: !0,
1039
- transition: !0,
1040
- transitionDuration: 300
1041
- };
1042
- class un extends xt {
1043
- constructor(e, s, n = {}) {
1044
- super(e, s, n), this.state = "closed", this.dialog = null;
1045
- }
1046
- get isRequired() {
1047
- return this.dialog.matches(this.getSetting("selectorRequired"));
1048
- }
1049
- async open(e, s) {
1050
- return this.parent.open(this, e, s);
1051
- }
1052
- async close(e, s) {
1053
- return this.parent.close(this, e, s);
1054
- }
1055
- async replace(e, s) {
1056
- return this.parent.replace(this, e, s);
1057
- }
1058
- async deregister() {
1059
- return this.parent.deregister(this.id);
1265
+ function Tn(t, e = "config") {
1266
+ const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
1267
+ return n ? JSON.parse(n) : {};
1268
+ }
1269
+ function pe(t) {
1270
+ if (typeof t == "string") {
1271
+ const e = document.getElementById(t);
1272
+ if (e) return e;
1273
+ throw new Error(`Element not found with ID: "${t}"`);
1274
+ } else if (t instanceof HTMLElement) {
1275
+ if (!t.id)
1276
+ throw new Error("HTMLElement must have an ID");
1277
+ return t;
1278
+ } else
1279
+ throw new Error("Invalid argument: query must be a string or HTMLElement");
1280
+ }
1281
+ async function K(t, e, ...n) {
1282
+ e in t && typeof t[e] == "function" && await t[e](...n);
1283
+ }
1284
+ function Pn(t) {
1285
+ return t.split("-").map(
1286
+ (e, n) => n === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)
1287
+ ).join("");
1288
+ }
1289
+ function me(t) {
1290
+ return t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1291
+ }
1292
+ function kn(t) {
1293
+ if (typeof t == "number")
1294
+ return t;
1295
+ const e = parseFloat(t);
1296
+ if (!Number.isNaN(e)) {
1297
+ const n = t.includes("ms");
1298
+ return e * (n ? 1 : 1e3);
1299
+ }
1300
+ throw new Error(`Could not convert value to milliseconds: ${t}`);
1301
+ }
1302
+ function ye(t, e, n, s, r = 0) {
1303
+ return new Promise((i) => {
1304
+ t.classList.remove(e), t.classList.add(n), setTimeout(() => {
1305
+ t.classList.add(s), t.classList.remove(n), i(t);
1306
+ }, kn(r));
1307
+ });
1308
+ }
1309
+ async function U(t, e, n) {
1310
+ await K(e, t, n), n && await K(n, t);
1311
+ for (const s of e.plugins)
1312
+ await K(s, t, { plugin: s, parent: e, entry: n });
1313
+ await e.emit(t, n);
1314
+ }
1315
+ function Rn(t) {
1316
+ const e = getComputedStyle(t.el), n = {}, s = t.getSetting("customProps");
1317
+ for (let r = 0; r < s.length; r++) {
1318
+ const i = Dn(), o = t.parent.module.toLowerCase(), a = me(s[r]), l = e.getPropertyValue(`--${i}${o}-${a}`).trim();
1319
+ l && (n[a] = l);
1320
+ }
1321
+ return n;
1322
+ }
1323
+ function Dn() {
1324
+ return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
1325
+ }
1326
+ function Mn(t, e, n = "camel") {
1327
+ return e = n === "camel" ? Pn(e) : me(e), t.split(".").concat(e).reduce((s, r) => s?.[r], this);
1328
+ }
1329
+ function In(t, e = {}) {
1330
+ const {
1331
+ fallback: n,
1332
+ props: s = ["dataConfig", "customProps", "settings", "parent.settings"]
1333
+ } = e;
1334
+ for (const r of s) {
1335
+ const i = r !== "customProps" ? "camel" : "kebab", o = Mn.call(this, r, t, i);
1336
+ if (o !== void 0)
1337
+ return o;
1338
+ }
1339
+ if (n !== void 0)
1340
+ return n;
1341
+ throw new Error(`${this.parent.module} setting does not exist: ${t}`);
1342
+ }
1343
+ function Hn(t, e) {
1344
+ e && document.querySelectorAll(e).forEach((n) => {
1345
+ t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
1346
+ });
1347
+ }
1348
+ function qn(t, e) {
1349
+ e && document.querySelectorAll(e).forEach((n) => {
1350
+ n.inert = t;
1351
+ });
1352
+ }
1353
+ function jn(t, e, n) {
1354
+ qn(!!t, e), Hn(!!t, n);
1355
+ }
1356
+ const Nn = {
1357
+ events: {},
1358
+ on(t, e, ...n) {
1359
+ this.events[t] || (this.events[t] = []), this.events[t].some(
1360
+ (s) => s.listener === e
1361
+ ) || this.events[t].push({ listener: e, args: n });
1362
+ },
1363
+ off(t, e) {
1364
+ this.events[t] && (this.events[t] = this.events[t].filter(
1365
+ (n) => n.listener !== e
1366
+ ));
1367
+ },
1368
+ async emit(t, e) {
1369
+ if (t = t.startsWith("on") ? t.slice(2, 3).toLowerCase() + t.slice(3) : t, !!this.events[t])
1370
+ for (const { listener: n, args: s } of this.events[t])
1371
+ await n(e, ...s);
1372
+ }
1373
+ };
1374
+ let Un = class extends Array {
1375
+ constructor(e = {}) {
1376
+ super(), this.presets = e;
1377
+ }
1378
+ applySettings(e) {
1379
+ const n = e?.defaults || {}, s = this.presets?.[e.name] || {}, r = e?.options || {};
1380
+ e.settings = { ...n, ...s, ...r };
1381
+ }
1382
+ validate(e) {
1383
+ return !("name" in e) || typeof e.name != "string" ? (console.error("Plugin requires a name!"), !1) : !0;
1384
+ }
1385
+ get(e) {
1386
+ return this.find((n) => n.name === e);
1387
+ }
1388
+ add(e) {
1389
+ if (Array.isArray(e))
1390
+ e.forEach((n) => this.add(n));
1391
+ else if (this.applySettings(e), this.validate(e)) {
1392
+ const n = this.findIndex((s) => s.name === e.name);
1393
+ ~n ? this[n] = e : this.push(e);
1394
+ }
1395
+ }
1396
+ remove(e) {
1397
+ const n = this.findIndex((s) => s.name === e);
1398
+ ~n && this.splice(n, 1);
1399
+ }
1400
+ }, Fn = class extends Array {
1401
+ constructor(e = {}) {
1402
+ super(), this.settings = e;
1403
+ }
1404
+ get copy() {
1405
+ return [...this];
1406
+ }
1407
+ get top() {
1408
+ return this[this.length - 1] || null;
1409
+ }
1410
+ updateIndex() {
1411
+ this.forEach((e, n) => {
1412
+ e.el.style.zIndex = "";
1413
+ const s = getComputedStyle(e.el)["z-index"];
1414
+ e.el.style.zIndex = String(parseInt(s, 10) + n + 1);
1415
+ });
1416
+ }
1417
+ onChange() {
1418
+ this.updateIndex(), typeof this.settings.onChange == "function" && this.settings.onChange();
1419
+ }
1420
+ add(e) {
1421
+ this.push(e), this.onChange();
1422
+ }
1423
+ remove(e) {
1424
+ const n = this.findIndex((s) => s.id === e.id);
1425
+ ~n && (e.el.style.zIndex = "", this.splice(n, 1), this.onChange());
1426
+ }
1427
+ moveToTop(e) {
1428
+ const n = this.findIndex((s) => s.id === e.id);
1429
+ ~n && (this.splice(n, 1), this.add(e));
1430
+ }
1431
+ };
1432
+ const Vn = {
1433
+ dataConfig: "config",
1434
+ customProps: []
1435
+ };
1436
+ class we {
1437
+ constructor(e, n, s = {}) {
1438
+ this.parent = e, this.el = pe(n), this.settings = { ...s }, this.dataConfig = {}, this.customProps = {};
1439
+ }
1440
+ get id() {
1441
+ return this.el.id;
1442
+ }
1443
+ applySettings(e) {
1444
+ return Object.assign(this.settings, e);
1445
+ }
1446
+ getSetting(e, n) {
1447
+ return In.call(this, e, n);
1448
+ }
1449
+ buildDataConfig() {
1450
+ return Object.assign(
1451
+ this.dataConfig,
1452
+ Tn(this.el, this.getSetting("dataConfig"))
1453
+ );
1454
+ }
1455
+ buildCustomProps() {
1456
+ return Object.assign(this.customProps, Rn(this));
1457
+ }
1458
+ async init(e = {}) {
1459
+ this.applySettings(e), this.buildDataConfig(), this.buildCustomProps();
1460
+ }
1461
+ async destroy() {
1462
+ Object.getOwnPropertyNames(this).forEach((e) => {
1463
+ delete this[e];
1464
+ });
1465
+ }
1466
+ }
1467
+ class zn {
1468
+ constructor(e = {}) {
1469
+ this.module = this.constructor.name, this.collection = [], this.entryClass = we, this.settings = { ...Vn, ...e }, this.plugins = new Un(this.settings.presets), this.events = {}, Object.assign(this, Nn);
1470
+ }
1471
+ get(e, n = "id") {
1472
+ return this.collection.find((s) => s[n] === e);
1473
+ }
1474
+ getOrThrow(e, n = "id") {
1475
+ const s = this.get(e, n);
1476
+ if (s)
1477
+ return s;
1478
+ throw new Error(
1479
+ `${this.module} entry not found in collection with ${n} of "${e}"`
1480
+ );
1481
+ }
1482
+ applySettings(e) {
1483
+ return Object.assign(this.settings, e);
1484
+ }
1485
+ async createEntry(e, n) {
1486
+ const s = new this.entryClass(this, e, n);
1487
+ return await K(s, "init"), await U("onCreateEntry", this, s), s;
1488
+ }
1489
+ async destroyEntry(e) {
1490
+ return await U("onDestroyEntry", this, e), await K(e, "destroy"), e;
1491
+ }
1492
+ async register(e, n = {}) {
1493
+ const s = pe(e), r = this.collection.findIndex((i) => i.id === s.id);
1494
+ if (~r) {
1495
+ const i = this.collection[r];
1496
+ return i.el = s, typeof i.init == "function" && await i.init(n), i;
1497
+ } else {
1498
+ const i = await this.createEntry(s, n);
1499
+ return this.collection.push(i), await U("onRegisterEntry", this, i), i;
1500
+ }
1501
+ }
1502
+ async deregister(e) {
1503
+ const n = this.collection.findIndex((s) => s.id === e);
1504
+ if (~n) {
1505
+ const s = await this.destroyEntry(this.collection[n]);
1506
+ return await U(
1507
+ "onDeregisterEntry",
1508
+ this,
1509
+ this.collection[n]
1510
+ ), this.collection.splice(n, 1), s;
1511
+ }
1512
+ return null;
1513
+ }
1514
+ async mount(e = {}) {
1515
+ this.applySettings(e);
1516
+ for (const s of this.settings?.plugins || [])
1517
+ this.plugins.add(s);
1518
+ for (const s of this.plugins)
1519
+ await K(s, "setup", { plugin: s, parent: this });
1520
+ await U("beforeMount", this);
1521
+ const n = document.querySelectorAll(this.settings.selector);
1522
+ for (const s of n)
1523
+ await this.register(s);
1524
+ return await U("afterMount", this), this;
1525
+ }
1526
+ async unmount() {
1527
+ for (await U("beforeUnmount", this); this.collection.length > 0; )
1528
+ await this.deregister(this.collection[0].id);
1529
+ await U("afterUnmount", this);
1530
+ for (const e of this.plugins)
1531
+ await K(e, "teardown", { plugin: e, parent: this });
1532
+ for (const e of [...this.plugins])
1533
+ this.plugins.remove(e.name);
1534
+ return this;
1535
+ }
1536
+ }
1537
+ const Bn = {
1538
+ // Data attributes
1539
+ dataOpen: "modal-open",
1540
+ dataClose: "modal-close",
1541
+ dataReplace: "modal-replace",
1542
+ // Selectors
1543
+ selector: ".modal",
1544
+ selectorDialog: ".modal__dialog",
1545
+ selectorScreen: ".modal",
1546
+ selectorRequired: '[role="alertdialog"]',
1547
+ selectorFocus: "[data-focus]",
1548
+ selectorInert: null,
1549
+ selectorOverflow: "body",
1550
+ // State classes
1551
+ stateOpened: "is-opened",
1552
+ stateOpening: "is-opening",
1553
+ stateClosing: "is-closing",
1554
+ stateClosed: "is-closed",
1555
+ // Feature settings
1556
+ customProps: ["transition-duration"],
1557
+ customEventPrefix: "modal:",
1558
+ setTabindex: !0,
1559
+ transition: !0,
1560
+ transitionDuration: 300
1561
+ };
1562
+ function yt(t) {
1563
+ t.active ? (t.active.dialog.querySelector(t.settings.selectorFocus) || t.active.dialog).focus() : t.trigger && (t.trigger.focus(), t.trigger = null);
1564
+ }
1565
+ async function Dt(t, e, n = !0) {
1566
+ return t.parent.stack.moveToTop(t), t.state === "closed" && (t.state = "opening", t.parent.stack.add(t), e ?? t.getSetting("transition") ? await ye(
1567
+ t.el,
1568
+ t.getSetting("stateClosed"),
1569
+ t.getSetting("stateOpening"),
1570
+ t.getSetting("stateOpened"),
1571
+ t.getSetting("transitionDuration")
1572
+ ) : (t.el.classList.add(t.getSetting("stateOpened")), t.el.classList.remove(t.getSetting("stateClosed"))), t.state = "opened"), n && yt(t.parent), t.el.dispatchEvent(
1573
+ new CustomEvent(t.getSetting("customEventPrefix") + "opened", {
1574
+ detail: t.parent,
1575
+ bubbles: !0
1576
+ })
1577
+ ), await t.parent.emit("opened", t), t;
1578
+ }
1579
+ async function Mt(t, e, n = !0) {
1580
+ return t && t.state === "opened" && (t.state = "closing", document.activeElement && document.activeElement instanceof HTMLElement && document.activeElement.blur(), e ?? t.getSetting("transition") ? await ye(
1581
+ t.el,
1582
+ t.getSetting("stateOpened"),
1583
+ t.getSetting("stateClosing"),
1584
+ t.getSetting("stateClosed"),
1585
+ t.getSetting("transitionDuration")
1586
+ ) : (t.el.classList.add(t.getSetting("stateClosed")), t.el.classList.remove(t.getSetting("stateOpened"))), t.parent.stack.remove(t), t.state = "closed", n && yt(t.parent), t.el.dispatchEvent(
1587
+ new CustomEvent(t.getSetting("customEventPrefix") + "closed", {
1588
+ detail: t.parent,
1589
+ bubbles: !0
1590
+ })
1591
+ ), await t.parent.emit("closed", t)), t;
1592
+ }
1593
+ async function ve(t, e, n = !0) {
1594
+ let s, r;
1595
+ return t.state === "opened" ? (s = t, r = await t.parent.closeAll(t.id, e)) : [r, s] = await Promise.all([
1596
+ t.parent.closeAll("", e),
1597
+ Dt(t, e, !1)
1598
+ ]), n && yt(t.parent), { opened: s, closed: r };
1599
+ }
1600
+ let Wn = class extends we {
1601
+ constructor(e, n, s = {}) {
1602
+ super(e, n, s), this.state = "closed", this.dialog = this.el.querySelector(this.getSetting("selectorDialog")) || this.el;
1603
+ }
1604
+ get isRequired() {
1605
+ return this.dialog.matches(this.getSetting("selectorRequired"));
1606
+ }
1607
+ async open(e, n) {
1608
+ return Dt(this, e, n);
1609
+ }
1610
+ async close(e, n) {
1611
+ return Mt(this, e, n);
1612
+ }
1613
+ async replace(e, n) {
1614
+ return ve(this, e, n);
1615
+ }
1616
+ async deregister() {
1617
+ return this.parent.deregister(this.id);
1060
1618
  }
1061
1619
  async onCreateEntry() {
1062
- const e = this.el.querySelector(this.getSetting("selectorDialog"));
1063
- this.dialog = e || this.el, this.dialog.setAttribute("aria-modal", "true"), this.dialog.hasAttribute("role") || this.dialog.setAttribute("role", "dialog"), this.getSetting("setTabindex") && this.dialog.setAttribute("tabindex", "-1");
1620
+ this.dialog.setAttribute("aria-modal", "true"), this.dialog.hasAttribute("role") || this.dialog.setAttribute("role", "dialog"), this.getSetting("setTabindex") && this.dialog.setAttribute("tabindex", "-1");
1064
1621
  }
1065
1622
  async onRegisterEntry() {
1066
1623
  this.el.classList.contains(this.getSetting("stateOpened")) ? await this.open(!1) : (this.el.classList.remove(this.getSetting("stateOpening")), this.el.classList.remove(this.getSetting("stateClosing")), this.el.classList.add(this.getSetting("stateClosed")));
@@ -1068,98 +1625,53 @@ class un extends xt {
1068
1625
  async onDestroyEntry() {
1069
1626
  this.state === "opened" && await this.close(!1);
1070
1627
  }
1071
- }
1072
- function pt(t) {
1073
- const e = typeof t == "string" ? this.get(t) : this.get(t.id);
1074
- if (e)
1075
- return e;
1076
- throw new Error(
1077
- `Modal not found in collection with id of "${t.id || t}".`
1078
- );
1079
- }
1080
- async function dn(t) {
1081
- const e = t.target.closest(`
1082
- [data-${this.settings.dataOpen}],
1083
- [data-${this.settings.dataReplace}],
1084
- [data-${this.settings.dataClose}]
1085
- `);
1628
+ };
1629
+ async function _n(t) {
1630
+ const e = t.target;
1086
1631
  if (e) {
1087
- if (t.preventDefault(), e.matches(`[data-${this.settings.dataOpen}]`)) {
1088
- const s = e.getAttribute(`data-${this.settings.dataOpen}`).trim(), n = pt.call(this, s);
1089
- return t.target.closest(this.settings.selector) || (this.trigger = e), n.open();
1090
- }
1091
- if (e.matches(`[data-${this.settings.dataReplace}]`)) {
1092
- const s = e.getAttribute(`data-${this.settings.dataReplace}`).trim(), n = pt.call(this, s);
1093
- return t.target.closest(this.settings.selector) || (this.trigger = e), n.replace();
1094
- }
1095
- if (e.matches(`[data-${this.settings.dataClose}]`)) {
1096
- const s = e.getAttribute(`data-${this.settings.dataClose}`).trim();
1097
- return s === "*" ? this.closeAll() : this.close(s);
1632
+ const n = e.closest(`
1633
+ [data-${this.settings.dataOpen}],
1634
+ [data-${this.settings.dataReplace}],
1635
+ [data-${this.settings.dataClose}]
1636
+ `);
1637
+ if (n) {
1638
+ if (t.preventDefault(), n.matches(`[data-${this.settings.dataOpen}]`)) {
1639
+ const s = n.getAttribute(`data-${this.settings.dataOpen}`)?.trim(), r = this.getOrThrow(s);
1640
+ return e.closest(this.settings.selector) || (this.trigger = n), r.open();
1641
+ }
1642
+ if (n.matches(`[data-${this.settings.dataReplace}]`)) {
1643
+ const s = n.getAttribute(`data-${this.settings.dataReplace}`)?.trim(), r = this.getOrThrow(s);
1644
+ return e.closest(this.settings.selector) || (this.trigger = n), r.replace();
1645
+ }
1646
+ if (n.matches(`[data-${this.settings.dataClose}]`)) {
1647
+ const s = n.getAttribute(`data-${this.settings.dataClose}`)?.trim();
1648
+ return s === "*" ? this.closeAll() : this.close(s || "");
1649
+ }
1098
1650
  }
1651
+ if (this.active && e.matches(this.settings.selectorScreen) && !this.active.isRequired)
1652
+ return this.close();
1099
1653
  }
1100
- if (this.active && t.target.matches(this.settings.selectorScreen) && !this.active.isRequired)
1101
- return this.close(this.active.id);
1102
1654
  }
1103
- function hn(t) {
1655
+ function Qn(t) {
1104
1656
  if (t.key === "Escape" && this.active && !this.active.dialog.matches(this.settings.selectorRequired))
1105
1657
  return this.close();
1106
1658
  }
1107
- function Lt() {
1108
- this.active ? (this.active.dialog.querySelector(this.settings.selectorFocus) || this.active.dialog).focus() : this.trigger && (this.trigger.focus(), this.trigger = null);
1109
- }
1110
- async function be(t, e = void 0, s = !0) {
1111
- const n = pt.call(this, t);
1112
- return this.stack.moveToTop(n), n.state === "closed" && (n.state = "opening", this.stack.add(n), e ?? n.getSetting("transition") ? await wt(
1113
- n.el,
1114
- n.getSetting("stateClosed"),
1115
- n.getSetting("stateOpening"),
1116
- n.getSetting("stateOpened"),
1117
- n.getSetting("transitionDuration")
1118
- ) : (n.el.classList.add(n.getSetting("stateOpened")), n.el.classList.remove(n.getSetting("stateClosed"))), n.state = "opened"), s && Lt.call(this), n.el.dispatchEvent(
1119
- new CustomEvent(n.getSetting("customEventPrefix") + "opened", {
1120
- detail: n,
1121
- bubbles: !0
1122
- })
1123
- ), await n.parent.emit("opened", n), n;
1124
- }
1125
- async function xe(t, e, s = !0) {
1126
- const n = t ? pt.call(this, t) : this.active;
1127
- return n && n.state === "opened" && (n.state = "closing", document.activeElement.blur(), e ?? n.getSetting("transition") ? await wt(
1128
- n.el,
1129
- n.getSetting("stateOpened"),
1130
- n.getSetting("stateClosing"),
1131
- n.getSetting("stateClosed"),
1132
- n.getSetting("transitionDuration")
1133
- ) : (n.el.classList.add(n.getSetting("stateClosed")), n.el.classList.remove(n.getSetting("stateOpened"))), this.stack.remove(n), n.state = "closed", s && Lt.call(this), n.el.dispatchEvent(
1134
- new CustomEvent(n.getSetting("customEventPrefix") + "closed", {
1135
- detail: n,
1136
- bubbles: !0
1137
- })
1138
- ), await n.parent.emit("closed", n)), n;
1139
- }
1140
- async function It(t, e) {
1141
- const s = [];
1659
+ async function Jn(t = "", e) {
1660
+ const n = [];
1142
1661
  return await Promise.all(
1143
- this.stack.copy.map(async (n) => {
1144
- t && t === n.id || (s.push(await xe.call(this, n, e, !1)), n.trigger = null);
1662
+ this.stack.copy.map(async (s) => {
1663
+ t && t === s.id || n.push(await Mt(s, e, !1));
1145
1664
  })
1146
- ), s;
1147
- }
1148
- async function gn(t, e, s = !0) {
1149
- const n = pt.call(this, t);
1150
- let i, r;
1151
- return n.state === "opened" ? (i = n, r = await It.call(this, n.id, e)) : (r = It.call(this, !1, e), i = be.call(this, n, e, !1), await Promise.all([i, r])), s && Lt.call(this), { opened: i, closed: r };
1152
- }
1153
- var rt, lt;
1154
- class ds extends Ot {
1155
- constructor(s) {
1156
- super({ ...fn, ...s });
1157
- U(this, rt);
1158
- U(this, lt);
1159
- this.module = "Modal", this.entryClass = un, this.trigger = null, S(this, rt, dn.bind(this)), S(this, lt, hn.bind(this)), this.stack = new me({
1665
+ ), n;
1666
+ }
1667
+ let xi = class extends zn {
1668
+ #t;
1669
+ #e;
1670
+ constructor(e) {
1671
+ super({ ...Bn, ...e }), this.module = "Modal", this.entryClass = Wn, this.trigger = null, this.#t = _n.bind(this), this.#e = Qn.bind(this), this.stack = new Fn({
1160
1672
  onChange: () => {
1161
- bt(
1162
- this.stack.top,
1673
+ jn(
1674
+ !!this.stack.top,
1163
1675
  this.settings.selectorInert,
1164
1676
  this.settings.selectorOverflow
1165
1677
  );
@@ -1169,374 +1681,340 @@ class ds extends Ot {
1169
1681
  get active() {
1170
1682
  return this.stack.top;
1171
1683
  }
1172
- async open(s, n, i) {
1173
- return be.call(this, s, n, i);
1684
+ async open(e, n, s) {
1685
+ const r = this.getOrThrow(e);
1686
+ return Dt(r, n, s);
1174
1687
  }
1175
- async close(s, n, i) {
1176
- return xe.call(this, s, n, i);
1688
+ async close(e, n, s) {
1689
+ const r = e ? this.getOrThrow(e) : this.active;
1690
+ return Mt(r, n, s);
1177
1691
  }
1178
- async replace(s, n, i) {
1179
- return gn.call(this, s, n, i);
1692
+ async replace(e, n, s) {
1693
+ const r = this.getOrThrow(e);
1694
+ return ve(r, n, s);
1180
1695
  }
1181
- async closeAll(s = !1, n, i = !0) {
1182
- const r = await It.call(this, s, n);
1183
- return i && Lt.call(this), r;
1696
+ async closeAll(e, n, s = !0) {
1697
+ const r = await Jn.call(this, e, n);
1698
+ return s && yt(this), r;
1184
1699
  }
1185
1700
  async afterMount() {
1186
- document.addEventListener("click", E(this, rt), !1), document.addEventListener("keydown", E(this, lt), !1);
1701
+ document.addEventListener("click", this.#t, !1), document.addEventListener("keydown", this.#e, !1);
1187
1702
  }
1188
1703
  async beforeUnmount() {
1189
1704
  this.trigger = null;
1190
1705
  }
1191
1706
  async afterUnmount() {
1192
- document.removeEventListener("click", E(this, rt), !1), document.removeEventListener("keydown", E(this, lt), !1);
1707
+ document.removeEventListener("click", this.#t, !1), document.removeEventListener("keydown", this.#e, !1);
1193
1708
  }
1194
- }
1195
- rt = new WeakMap(), lt = new WeakMap();
1196
- const mn = {
1197
- // Selectors
1198
- selector: ".popover",
1199
- selectorTooltip: ".popover_tooltip",
1200
- selectorArrow: ".popover__arrow",
1201
- // State classes
1202
- stateActive: "is-active",
1203
- // Custom properties and their defaults
1204
- customProps: [
1205
- "placement",
1206
- "event",
1207
- "offset",
1208
- "flip-padding",
1209
- "shift-padding",
1210
- "arrow-padding",
1211
- "toggle-delay"
1212
- ],
1213
- customEventPrefix: "popover:",
1214
- placement: "bottom",
1215
- event: "click",
1216
- offset: 0,
1217
- flipPadding: 0,
1218
- shiftPadding: 0,
1219
- arrowPadding: 0,
1220
- toggleDelay: 0
1221
1709
  };
1222
- function qt(t, e, s) {
1223
- Object.assign(t.style, {
1224
- left: e != null ? `${e}px` : "",
1225
- top: s != null ? `${s}px` : ""
1226
- });
1710
+ function Zn(t, e = "config") {
1711
+ const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
1712
+ return n ? JSON.parse(n) : {};
1227
1713
  }
1228
- function ve(t, e) {
1229
- let s = t.getSetting("toggle-delay");
1230
- typeof s == "string" && (s.indexOf(",") > -1 && (s = s.split(",")), s.indexOf(" ") > -1 && (s = s.split(" "))), Array.isArray(s) && (s = s[e]);
1231
- const n = Number(s);
1232
- if (Number.isNaN(n))
1233
- throw new Error(`Provided delay value is not a number: "${s}"`);
1234
- return n;
1714
+ function be(t) {
1715
+ if (typeof t == "string") {
1716
+ const e = document.getElementById(t);
1717
+ if (e) return e;
1718
+ throw new Error(`Element not found with ID: "${t}"`);
1719
+ } else if (t instanceof HTMLElement) {
1720
+ if (!t.id)
1721
+ throw new Error("HTMLElement must have an ID");
1722
+ return t;
1723
+ } else
1724
+ throw new Error("Invalid argument: query must be a string or HTMLElement");
1235
1725
  }
1236
- function Mt(t) {
1237
- let e;
1238
- const s = typeof t == "string" ? t.trim().split(" ") : [t];
1239
- for (let n = 0; n < s.length; n++)
1240
- s[n] = Number(s[n]);
1241
- switch (s.length) {
1242
- case 1:
1243
- e = s[0];
1244
- break;
1245
- case 2:
1246
- e = {
1247
- top: s[0],
1248
- right: s[1],
1249
- bottom: s[0],
1250
- left: s[1]
1251
- };
1252
- break;
1253
- case 3:
1254
- e = {
1255
- top: s[0],
1256
- right: s[1],
1257
- bottom: s[2],
1258
- left: s[1]
1259
- };
1260
- break;
1261
- case 4:
1262
- e = {
1263
- top: s[0],
1264
- right: s[1],
1265
- bottom: s[2],
1266
- left: s[3]
1267
- };
1268
- break;
1269
- default:
1270
- e = !1;
1271
- break;
1272
- }
1273
- return e;
1726
+ async function X(t, e, ...n) {
1727
+ e in t && typeof t[e] == "function" && await t[e](...n);
1274
1728
  }
1275
- function pn(t) {
1276
- return {
1277
- offset: Number(t.getSetting("offset")),
1278
- flip: {
1279
- padding: Mt(t.getSetting("flip-padding"))
1280
- },
1281
- shift: {
1282
- padding: Mt(t.getSetting("shift-padding"))
1283
- },
1284
- arrow: {
1285
- element: t.getSetting("selectorArrow"),
1286
- padding: Mt(t.getSetting("arrow-padding"))
1287
- }
1288
- };
1729
+ function Kn(t) {
1730
+ return t.split("-").map(
1731
+ (e, n) => n === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)
1732
+ ).join("");
1289
1733
  }
1290
1734
  function Ee(t) {
1291
- const e = typeof t == "string" ? this.get(t) : this.get(t.id);
1292
- if (e)
1293
- return e;
1294
- throw new Error(`Popover not found in collection with id of "${t}".`);
1295
- }
1296
- async function Se(t) {
1297
- const e = t ? Ee.call(this, t) : await Ce.call(this);
1298
- return e && e.state === "opened" && (e.el.inert = !0, e.el.classList.remove(this.settings.stateActive), e.isTooltip || e.trigger.setAttribute("aria-expanded", "false"), e.floatingCleanup(), e.state = "closed", e.trigger === this.trigger && (this.trigger = null), e.el.dispatchEvent(
1299
- new CustomEvent(e.getSetting("customEventPrefix") + "closed", {
1300
- detail: this,
1301
- bubbles: !0
1302
- })
1303
- ), await e.parent.emit("closed", e)), e;
1735
+ return t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
1304
1736
  }
1305
- async function Ce() {
1306
- const t = [];
1307
- return await Promise.all(
1308
- this.collection.map(async (e) => {
1309
- e.state === "opened" && t.push(await Se.call(this, e));
1310
- })
1311
- ), t;
1737
+ async function F(t, e, n) {
1738
+ await X(e, t, n), n && await X(n, t);
1739
+ for (const s of e.plugins)
1740
+ await X(s, t, { plugin: s, parent: e, entry: n });
1741
+ await e.emit(t, n);
1312
1742
  }
1313
- function $e(t) {
1314
- t.state == "opened" && setTimeout(() => {
1315
- const e = t.el.matches(":hover") === t.el || t.trigger.matches(":hover") === t.trigger;
1316
- let s = document.activeElement.closest(
1317
- `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
1318
- );
1319
- return !e && !s && t.close(), t;
1320
- }, 1);
1743
+ function Xn(t) {
1744
+ const e = getComputedStyle(t.el), n = {}, s = t.getSetting("customProps");
1745
+ for (let r = 0; r < s.length; r++) {
1746
+ const i = Yn(), o = t.parent.module.toLowerCase(), a = Ee(s[r]), l = e.getPropertyValue(`--${i}${o}-${a}`).trim();
1747
+ l && (n[a] = l);
1748
+ }
1749
+ return n;
1321
1750
  }
1322
- function yn(t) {
1323
- t.state === "opened" ? t.close() : (this.trigger = t.trigger, t.open());
1751
+ function Yn() {
1752
+ return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
1324
1753
  }
1325
- function wn(t) {
1326
- t.isTooltip && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.close());
1754
+ function Gn(t, e, n = "camel") {
1755
+ return e = n === "camel" ? Kn(e) : Ee(e), t.split(".").concat(e).reduce((s, r) => s?.[r], this);
1327
1756
  }
1328
- function bn(t, e) {
1329
- if (t.isHovered = e, e.type == "focus" && !t.trigger.matches(":focus-visible"))
1330
- return;
1331
- t.toggleDelayId && clearTimeout(t.toggleDelayId);
1332
- const s = t.trigger.getAttribute("aria-expanded");
1333
- if (s && s == "true") return;
1334
- const n = this.activeHover ? 0 : ve(t, 0);
1335
- this.activeHover && this.activeHover.close(), t.toggleDelayId = setTimeout(() => {
1336
- t.id && t.open();
1337
- }, n);
1757
+ function ts(t, e = {}) {
1758
+ const {
1759
+ fallback: n,
1760
+ props: s = ["dataConfig", "customProps", "settings", "parent.settings"]
1761
+ } = e;
1762
+ for (const r of s) {
1763
+ const i = r !== "customProps" ? "camel" : "kebab", o = Gn.call(this, r, t, i);
1764
+ if (o !== void 0)
1765
+ return o;
1766
+ }
1767
+ if (n !== void 0)
1768
+ return n;
1769
+ throw new Error(`${this.parent.module} setting does not exist: ${t}`);
1338
1770
  }
1339
- function xn(t, e) {
1340
- setTimeout(() => {
1341
- t.isHovered = e, !t.isHovered && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.toggleDelayId = setTimeout(
1342
- () => {
1343
- $e.call(this, t);
1344
- },
1345
- ve(t, 1)
1771
+ const es = {
1772
+ events: {},
1773
+ on(t, e, ...n) {
1774
+ this.events[t] || (this.events[t] = []), this.events[t].some(
1775
+ (s) => s.listener === e
1776
+ ) || this.events[t].push({ listener: e, args: n });
1777
+ },
1778
+ off(t, e) {
1779
+ this.events[t] && (this.events[t] = this.events[t].filter(
1780
+ (n) => n.listener !== e
1346
1781
  ));
1347
- }, 1);
1348
- }
1349
- function vn(t) {
1350
- switch (t.key) {
1351
- case "Escape":
1352
- this.trigger && this.trigger.focus(), Ce.call(this);
1353
- return;
1354
- case "Tab":
1355
- this.collection.forEach((e) => {
1356
- $e.call(this, e);
1357
- });
1358
- return;
1359
- default:
1360
- return;
1782
+ },
1783
+ async emit(t, e) {
1784
+ if (t = t.startsWith("on") ? t.slice(2, 3).toLowerCase() + t.slice(3) : t, !!this.events[t])
1785
+ for (const { listener: n, args: s } of this.events[t])
1786
+ await n(e, ...s);
1787
+ }
1788
+ };
1789
+ class ns extends Array {
1790
+ constructor(e = {}) {
1791
+ super(), this.presets = e;
1792
+ }
1793
+ applySettings(e) {
1794
+ const n = e?.defaults || {}, s = this.presets?.[e.name] || {}, r = e?.options || {};
1795
+ e.settings = { ...n, ...s, ...r };
1796
+ }
1797
+ validate(e) {
1798
+ return !("name" in e) || typeof e.name != "string" ? (console.error("Plugin requires a name!"), !1) : !0;
1799
+ }
1800
+ get(e) {
1801
+ return this.find((n) => n.name === e);
1802
+ }
1803
+ add(e) {
1804
+ if (Array.isArray(e))
1805
+ e.forEach((n) => this.add(n));
1806
+ else if (this.applySettings(e), this.validate(e)) {
1807
+ const n = this.findIndex((s) => s.name === e.name);
1808
+ ~n ? this[n] = e : this.push(e);
1809
+ }
1810
+ }
1811
+ remove(e) {
1812
+ const n = this.findIndex((s) => s.name === e);
1813
+ ~n && this.splice(n, 1);
1361
1814
  }
1362
1815
  }
1363
- function En(t) {
1364
- const e = this;
1365
- document.addEventListener("click", function s(n) {
1366
- n.target.closest(
1367
- `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
1368
- ) ? t.el && !t.el.classList.contains(e.settings.stateActive) && this.removeEventListener("click", s) : (t.el && t.el.classList.contains(e.settings.stateActive) && t.close(), this.removeEventListener("click", s));
1369
- });
1370
- }
1371
- var L, z;
1372
- class Sn extends xt {
1373
- constructor(s, n, i = {}) {
1374
- super(s, n, i);
1375
- U(this, L);
1376
- U(this, z);
1377
- this.state = "closed", this.toggleDelayId = null, this.trigger = null, S(this, L, null), S(this, z, {
1378
- el: !1,
1379
- trigger: !1
1380
- }), this.floatingCleanup = () => {
1381
- };
1816
+ const ss = {
1817
+ dataConfig: "config",
1818
+ customProps: []
1819
+ };
1820
+ class xe {
1821
+ constructor(e, n, s = {}) {
1822
+ this.parent = e, this.el = be(n), this.settings = { ...s }, this.dataConfig = {}, this.customProps = {};
1382
1823
  }
1383
- get isTooltip() {
1384
- return !!this.el.closest(this.getSetting("selectorTooltip")) || this.el.getAttribute("role") == "tooltip";
1824
+ get id() {
1825
+ return this.el.id;
1385
1826
  }
1386
- get isHovered() {
1387
- return E(this, z).el || E(this, z).trigger;
1827
+ applySettings(e) {
1828
+ return Object.assign(this.settings, e);
1388
1829
  }
1389
- set isHovered(s) {
1390
- const n = s.type == "mouseenter" ? !0 : s.type == "mouseleave" ? !1 : void 0;
1391
- if (n != null)
1392
- switch (s.target) {
1393
- case this.el:
1394
- E(this, z).el = n;
1395
- break;
1396
- case this.trigger:
1397
- E(this, z).trigger = n;
1398
- break;
1399
- }
1830
+ getSetting(e, n) {
1831
+ return ts.call(this, e, n);
1400
1832
  }
1401
- async open() {
1402
- return this.parent.open(this);
1833
+ buildDataConfig() {
1834
+ return Object.assign(
1835
+ this.dataConfig,
1836
+ Zn(this.el, this.getSetting("dataConfig"))
1837
+ );
1403
1838
  }
1404
- async close() {
1405
- return this.parent.close(this);
1839
+ buildCustomProps() {
1840
+ return Object.assign(this.customProps, Xn(this));
1406
1841
  }
1407
- async deregister() {
1408
- return this.parent.deregister(this.id);
1842
+ async init(e = {}) {
1843
+ this.applySettings(e), this.buildDataConfig(), this.buildCustomProps();
1409
1844
  }
1410
- registerEventListeners() {
1411
- E(this, L) || (this.getSetting("event") === "hover" ? (S(this, L, [
1412
- {
1413
- el: ["el", "trigger"],
1414
- type: ["mouseenter", "focus"],
1415
- listener: bn.bind(this.parent, this)
1416
- },
1417
- {
1418
- el: ["el", "trigger"],
1419
- type: ["mouseleave", "focusout"],
1420
- listener: xn.bind(this.parent, this)
1421
- },
1422
- {
1423
- el: ["trigger"],
1424
- type: ["click"],
1425
- listener: wn.bind(this.parent, this)
1426
- }
1427
- ]), E(this, L).forEach((n) => {
1428
- n.el.forEach((i) => {
1429
- n.type.forEach((r) => {
1430
- this[i].addEventListener(r, n.listener, !1);
1431
- });
1432
- });
1433
- })) : (S(this, L, [
1434
- {
1435
- el: ["trigger"],
1436
- type: ["click"],
1437
- listener: yn.bind(this.parent, this)
1438
- }
1439
- ]), E(this, L).forEach((n) => {
1440
- n.el.forEach((i) => {
1441
- n.type.forEach((r) => {
1442
- this[i].addEventListener(r, n.listener, !1);
1443
- });
1444
- });
1445
- })));
1845
+ async destroy() {
1846
+ Object.getOwnPropertyNames(this).forEach((e) => {
1847
+ delete this[e];
1848
+ });
1446
1849
  }
1447
- deregisterEventListeners() {
1448
- E(this, L) && (E(this, L).forEach((s) => {
1449
- s.el.forEach((n) => {
1450
- s.type.forEach((i) => {
1451
- this[n].removeEventListener(i, s.listener, !1);
1452
- });
1453
- });
1454
- }), S(this, L, null));
1850
+ }
1851
+ class is {
1852
+ constructor(e = {}) {
1853
+ this.module = this.constructor.name, this.collection = [], this.entryClass = xe, this.settings = { ...ss, ...e }, this.plugins = new ns(this.settings.presets), this.events = {}, Object.assign(this, es);
1455
1854
  }
1456
- async onCreateEntry() {
1457
- this.trigger = document.querySelector(
1458
- `[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`
1459
- ), this.isTooltip ? (this.settings.event = "hover", this.el.setAttribute("role", "tooltip")) : this.trigger.setAttribute("aria-expanded", "false"), this.registerEventListeners();
1855
+ get(e, n = "id") {
1856
+ return this.collection.find((s) => s[n] === e);
1460
1857
  }
1461
- async onRegisterEntry() {
1462
- this.el.classList.contains(this.getSetting("stateActive")) ? await this.open() : this.el.inert = !0;
1858
+ getOrThrow(e, n = "id") {
1859
+ const s = this.get(e, n);
1860
+ if (s)
1861
+ return s;
1862
+ throw new Error(
1863
+ `${this.module} entry not found in collection with ${n} of "${e}"`
1864
+ );
1463
1865
  }
1464
- async onDestroyEntry() {
1465
- this.state === "opened" && await this.close(), this.floatingCleanup(), this.deregisterEventListeners();
1866
+ applySettings(e) {
1867
+ return Object.assign(this.settings, e);
1868
+ }
1869
+ async createEntry(e, n) {
1870
+ const s = new this.entryClass(this, e, n);
1871
+ return await X(s, "init"), await F("onCreateEntry", this, s), s;
1872
+ }
1873
+ async destroyEntry(e) {
1874
+ return await F("onDestroyEntry", this, e), await X(e, "destroy"), e;
1875
+ }
1876
+ async register(e, n = {}) {
1877
+ const s = be(e), r = this.collection.findIndex((i) => i.id === s.id);
1878
+ if (~r) {
1879
+ const i = this.collection[r];
1880
+ return i.el = s, typeof i.init == "function" && await i.init(n), i;
1881
+ } else {
1882
+ const i = await this.createEntry(s, n);
1883
+ return this.collection.push(i), await F("onRegisterEntry", this, i), i;
1884
+ }
1885
+ }
1886
+ async deregister(e) {
1887
+ const n = this.collection.findIndex((s) => s.id === e);
1888
+ if (~n) {
1889
+ const s = await this.destroyEntry(this.collection[n]);
1890
+ return await F(
1891
+ "onDeregisterEntry",
1892
+ this,
1893
+ this.collection[n]
1894
+ ), this.collection.splice(n, 1), s;
1895
+ }
1896
+ return null;
1897
+ }
1898
+ async mount(e = {}) {
1899
+ this.applySettings(e);
1900
+ for (const s of this.settings?.plugins || [])
1901
+ this.plugins.add(s);
1902
+ for (const s of this.plugins)
1903
+ await X(s, "setup", { plugin: s, parent: this });
1904
+ await F("beforeMount", this);
1905
+ const n = document.querySelectorAll(this.settings.selector);
1906
+ for (const s of n)
1907
+ await this.register(s);
1908
+ return await F("afterMount", this), this;
1909
+ }
1910
+ async unmount() {
1911
+ for (await F("beforeUnmount", this); this.collection.length > 0; )
1912
+ await this.deregister(this.collection[0].id);
1913
+ await F("afterUnmount", this);
1914
+ for (const e of this.plugins)
1915
+ await X(e, "teardown", { plugin: e, parent: this });
1916
+ for (const e of [...this.plugins])
1917
+ this.plugins.remove(e.name);
1918
+ return this;
1466
1919
  }
1467
1920
  }
1468
- L = new WeakMap(), z = new WeakMap();
1469
- const ct = Math.min, Z = Math.max, Ct = Math.round, St = Math.floor, I = (t) => ({
1921
+ const rs = {
1922
+ // Selectors
1923
+ selector: ".popover",
1924
+ selectorTooltip: ".popover_tooltip",
1925
+ selectorArrow: ".popover__arrow",
1926
+ // State classes
1927
+ stateActive: "is-active",
1928
+ // Custom properties and their defaults
1929
+ customProps: [
1930
+ "placement",
1931
+ "event",
1932
+ "offset",
1933
+ "flip-padding",
1934
+ "shift-padding",
1935
+ "arrow-padding",
1936
+ "toggle-delay"
1937
+ ],
1938
+ customEventPrefix: "popover:",
1939
+ placement: "bottom",
1940
+ event: "click",
1941
+ offset: 0,
1942
+ flipPadding: 0,
1943
+ shiftPadding: 0,
1944
+ arrowPadding: 0,
1945
+ toggleDelay: 0
1946
+ }, nt = Math.min, Y = Math.max, dt = Math.round, ft = Math.floor, P = (t) => ({
1470
1947
  x: t,
1471
1948
  y: t
1472
- }), Cn = {
1949
+ }), os = {
1473
1950
  left: "right",
1474
1951
  right: "left",
1475
1952
  bottom: "top",
1476
1953
  top: "bottom"
1477
- }, $n = {
1954
+ }, as = {
1478
1955
  start: "end",
1479
1956
  end: "start"
1480
1957
  };
1481
- function Ft(t, e, s) {
1482
- return Z(t, ct(e, s));
1958
+ function St(t, e, n) {
1959
+ return Y(t, nt(e, n));
1483
1960
  }
1484
- function tt(t, e) {
1961
+ function G(t, e) {
1485
1962
  return typeof t == "function" ? t(e) : t;
1486
1963
  }
1487
- function j(t) {
1964
+ function z(t) {
1488
1965
  return t.split("-")[0];
1489
1966
  }
1490
- function vt(t) {
1967
+ function ut(t) {
1491
1968
  return t.split("-")[1];
1492
1969
  }
1493
- function _t(t) {
1970
+ function It(t) {
1494
1971
  return t === "x" ? "y" : "x";
1495
1972
  }
1496
- function Wt(t) {
1973
+ function Ht(t) {
1497
1974
  return t === "y" ? "height" : "width";
1498
1975
  }
1499
- function K(t) {
1500
- return ["top", "bottom"].includes(j(t)) ? "y" : "x";
1976
+ const ls = /* @__PURE__ */ new Set(["top", "bottom"]);
1977
+ function H(t) {
1978
+ return ls.has(z(t)) ? "y" : "x";
1501
1979
  }
1502
- function zt(t) {
1503
- return _t(K(t));
1980
+ function qt(t) {
1981
+ return It(H(t));
1504
1982
  }
1505
- function An(t, e, s) {
1506
- s === void 0 && (s = !1);
1507
- const n = vt(t), i = zt(t), r = Wt(i);
1508
- let o = i === "x" ? n === (s ? "end" : "start") ? "right" : "left" : n === "start" ? "bottom" : "top";
1509
- return e.reference[r] > e.floating[r] && (o = $t(o)), [o, $t(o)];
1983
+ function cs(t, e, n) {
1984
+ n === void 0 && (n = !1);
1985
+ const s = ut(t), r = qt(t), i = Ht(r);
1986
+ let o = r === "x" ? s === (n ? "end" : "start") ? "right" : "left" : s === "start" ? "bottom" : "top";
1987
+ return e.reference[i] > e.floating[i] && (o = gt(o)), [o, gt(o)];
1510
1988
  }
1511
- function kn(t) {
1512
- const e = $t(t);
1513
- return [Ht(t), e, Ht(e)];
1989
+ function us(t) {
1990
+ const e = gt(t);
1991
+ return [Ct(t), e, Ct(e)];
1514
1992
  }
1515
- function Ht(t) {
1516
- return t.replace(/start|end/g, (e) => $n[e]);
1993
+ function Ct(t) {
1994
+ return t.replace(/start|end/g, (e) => as[e]);
1517
1995
  }
1518
- function On(t, e, s) {
1519
- const n = ["left", "right"], i = ["right", "left"], r = ["top", "bottom"], o = ["bottom", "top"];
1996
+ const Vt = ["left", "right"], zt = ["right", "left"], hs = ["top", "bottom"], fs = ["bottom", "top"];
1997
+ function ds(t, e, n) {
1520
1998
  switch (t) {
1521
1999
  case "top":
1522
2000
  case "bottom":
1523
- return s ? e ? i : n : e ? n : i;
2001
+ return n ? e ? zt : Vt : e ? Vt : zt;
1524
2002
  case "left":
1525
2003
  case "right":
1526
- return e ? r : o;
2004
+ return e ? hs : fs;
1527
2005
  default:
1528
2006
  return [];
1529
2007
  }
1530
2008
  }
1531
- function Ln(t, e, s, n) {
1532
- const i = vt(t);
1533
- let r = On(j(t), s === "start", n);
1534
- return i && (r = r.map((o) => o + "-" + i), e && (r = r.concat(r.map(Ht)))), r;
2009
+ function gs(t, e, n, s) {
2010
+ const r = ut(t);
2011
+ let i = ds(z(t), n === "start", s);
2012
+ return r && (i = i.map((o) => o + "-" + r), e && (i = i.concat(i.map(Ct)))), i;
1535
2013
  }
1536
- function $t(t) {
1537
- return t.replace(/left|right|bottom|top/g, (e) => Cn[e]);
2014
+ function gt(t) {
2015
+ return t.replace(/left|right|bottom|top/g, (e) => os[e]);
1538
2016
  }
1539
- function Rn(t) {
2017
+ function ps(t) {
1540
2018
  return {
1541
2019
  top: 0,
1542
2020
  right: 0,
@@ -1545,110 +2023,110 @@ function Rn(t) {
1545
2023
  ...t
1546
2024
  };
1547
2025
  }
1548
- function Ae(t) {
1549
- return typeof t != "number" ? Rn(t) : {
2026
+ function $e(t) {
2027
+ return typeof t != "number" ? ps(t) : {
1550
2028
  top: t,
1551
2029
  right: t,
1552
2030
  bottom: t,
1553
2031
  left: t
1554
2032
  };
1555
2033
  }
1556
- function At(t) {
2034
+ function pt(t) {
1557
2035
  const {
1558
2036
  x: e,
1559
- y: s,
1560
- width: n,
1561
- height: i
2037
+ y: n,
2038
+ width: s,
2039
+ height: r
1562
2040
  } = t;
1563
2041
  return {
1564
- width: n,
1565
- height: i,
1566
- top: s,
2042
+ width: s,
2043
+ height: r,
2044
+ top: n,
1567
2045
  left: e,
1568
- right: e + n,
1569
- bottom: s + i,
2046
+ right: e + s,
2047
+ bottom: n + r,
1570
2048
  x: e,
1571
- y: s
2049
+ y: n
1572
2050
  };
1573
2051
  }
1574
- function Zt(t, e, s) {
2052
+ function Bt(t, e, n) {
1575
2053
  let {
1576
- reference: n,
1577
- floating: i
2054
+ reference: s,
2055
+ floating: r
1578
2056
  } = t;
1579
- const r = K(e), o = zt(e), l = Wt(o), a = j(e), c = r === "y", d = n.x + n.width / 2 - i.width / 2, f = n.y + n.height / 2 - i.height / 2, h = n[l] / 2 - i[l] / 2;
2057
+ const i = H(e), o = qt(e), a = Ht(o), l = z(e), c = i === "y", h = s.x + s.width / 2 - r.width / 2, f = s.y + s.height / 2 - r.height / 2, d = s[a] / 2 - r[a] / 2;
1580
2058
  let u;
1581
- switch (a) {
2059
+ switch (l) {
1582
2060
  case "top":
1583
2061
  u = {
1584
- x: d,
1585
- y: n.y - i.height
2062
+ x: h,
2063
+ y: s.y - r.height
1586
2064
  };
1587
2065
  break;
1588
2066
  case "bottom":
1589
2067
  u = {
1590
- x: d,
1591
- y: n.y + n.height
2068
+ x: h,
2069
+ y: s.y + s.height
1592
2070
  };
1593
2071
  break;
1594
2072
  case "right":
1595
2073
  u = {
1596
- x: n.x + n.width,
2074
+ x: s.x + s.width,
1597
2075
  y: f
1598
2076
  };
1599
2077
  break;
1600
2078
  case "left":
1601
2079
  u = {
1602
- x: n.x - i.width,
2080
+ x: s.x - r.width,
1603
2081
  y: f
1604
2082
  };
1605
2083
  break;
1606
2084
  default:
1607
2085
  u = {
1608
- x: n.x,
1609
- y: n.y
2086
+ x: s.x,
2087
+ y: s.y
1610
2088
  };
1611
2089
  }
1612
- switch (vt(e)) {
2090
+ switch (ut(e)) {
1613
2091
  case "start":
1614
- u[o] -= h * (s && c ? -1 : 1);
2092
+ u[o] -= d * (n && c ? -1 : 1);
1615
2093
  break;
1616
2094
  case "end":
1617
- u[o] += h * (s && c ? -1 : 1);
2095
+ u[o] += d * (n && c ? -1 : 1);
1618
2096
  break;
1619
2097
  }
1620
2098
  return u;
1621
2099
  }
1622
- const Pn = async (t, e, s) => {
2100
+ const ms = async (t, e, n) => {
1623
2101
  const {
1624
- placement: n = "bottom",
1625
- strategy: i = "absolute",
1626
- middleware: r = [],
2102
+ placement: s = "bottom",
2103
+ strategy: r = "absolute",
2104
+ middleware: i = [],
1627
2105
  platform: o
1628
- } = s, l = r.filter(Boolean), a = await (o.isRTL == null ? void 0 : o.isRTL(e));
2106
+ } = n, a = i.filter(Boolean), l = await (o.isRTL == null ? void 0 : o.isRTL(e));
1629
2107
  let c = await o.getElementRects({
1630
2108
  reference: t,
1631
2109
  floating: e,
1632
- strategy: i
2110
+ strategy: r
1633
2111
  }), {
1634
- x: d,
2112
+ x: h,
1635
2113
  y: f
1636
- } = Zt(c, n, a), h = n, u = {}, g = 0;
1637
- for (let m = 0; m < l.length; m++) {
2114
+ } = Bt(c, s, l), d = s, u = {}, g = 0;
2115
+ for (let p = 0; p < a.length; p++) {
1638
2116
  const {
1639
- name: p,
2117
+ name: m,
1640
2118
  fn: y
1641
- } = l[m], {
2119
+ } = a[p], {
1642
2120
  x: w,
1643
- y: b,
1644
- data: v,
1645
- reset: x
2121
+ y: v,
2122
+ data: b,
2123
+ reset: E
1646
2124
  } = await y({
1647
- x: d,
2125
+ x: h,
1648
2126
  y: f,
1649
- initialPlacement: n,
1650
- placement: h,
1651
- strategy: i,
2127
+ initialPlacement: s,
2128
+ placement: d,
2129
+ strategy: r,
1652
2130
  middlewareData: u,
1653
2131
  rects: c,
1654
2132
  platform: o,
@@ -1657,203 +2135,201 @@ const Pn = async (t, e, s) => {
1657
2135
  floating: e
1658
2136
  }
1659
2137
  });
1660
- d = w ?? d, f = b ?? f, u = {
2138
+ h = w ?? h, f = v ?? f, u = {
1661
2139
  ...u,
1662
- [p]: {
1663
- ...u[p],
1664
- ...v
2140
+ [m]: {
2141
+ ...u[m],
2142
+ ...b
1665
2143
  }
1666
- }, x && g <= 50 && (g++, typeof x == "object" && (x.placement && (h = x.placement), x.rects && (c = x.rects === !0 ? await o.getElementRects({
2144
+ }, E && g <= 50 && (g++, typeof E == "object" && (E.placement && (d = E.placement), E.rects && (c = E.rects === !0 ? await o.getElementRects({
1667
2145
  reference: t,
1668
2146
  floating: e,
1669
- strategy: i
1670
- }) : x.rects), {
1671
- x: d,
2147
+ strategy: r
2148
+ }) : E.rects), {
2149
+ x: h,
1672
2150
  y: f
1673
- } = Zt(c, h, a)), m = -1);
2151
+ } = Bt(c, d, l)), p = -1);
1674
2152
  }
1675
2153
  return {
1676
- x: d,
2154
+ x: h,
1677
2155
  y: f,
1678
- placement: h,
1679
- strategy: i,
2156
+ placement: d,
2157
+ strategy: r,
1680
2158
  middlewareData: u
1681
2159
  };
1682
2160
  };
1683
- async function ke(t, e) {
1684
- var s;
2161
+ async function Se(t, e) {
2162
+ var n;
1685
2163
  e === void 0 && (e = {});
1686
2164
  const {
1687
- x: n,
1688
- y: i,
1689
- platform: r,
2165
+ x: s,
2166
+ y: r,
2167
+ platform: i,
1690
2168
  rects: o,
1691
- elements: l,
1692
- strategy: a
2169
+ elements: a,
2170
+ strategy: l
1693
2171
  } = t, {
1694
2172
  boundary: c = "clippingAncestors",
1695
- rootBoundary: d = "viewport",
2173
+ rootBoundary: h = "viewport",
1696
2174
  elementContext: f = "floating",
1697
- altBoundary: h = !1,
2175
+ altBoundary: d = !1,
1698
2176
  padding: u = 0
1699
- } = tt(e, t), g = Ae(u), p = l[h ? f === "floating" ? "reference" : "floating" : f], y = At(await r.getClippingRect({
1700
- element: (s = await (r.isElement == null ? void 0 : r.isElement(p))) == null || s ? p : p.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(l.floating)),
2177
+ } = G(e, t), g = $e(u), p = a[d ? f === "floating" ? "reference" : "floating" : f], m = pt(await i.getClippingRect({
2178
+ element: (n = await (i.isElement == null ? void 0 : i.isElement(p))) == null || n ? p : p.contextElement || await (i.getDocumentElement == null ? void 0 : i.getDocumentElement(a.floating)),
1701
2179
  boundary: c,
1702
- rootBoundary: d,
1703
- strategy: a
1704
- })), w = f === "floating" ? {
1705
- x: n,
1706
- y: i,
2180
+ rootBoundary: h,
2181
+ strategy: l
2182
+ })), y = f === "floating" ? {
2183
+ x: s,
2184
+ y: r,
1707
2185
  width: o.floating.width,
1708
2186
  height: o.floating.height
1709
- } : o.reference, b = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(l.floating)), v = await (r.isElement == null ? void 0 : r.isElement(b)) ? await (r.getScale == null ? void 0 : r.getScale(b)) || {
2187
+ } : o.reference, w = await (i.getOffsetParent == null ? void 0 : i.getOffsetParent(a.floating)), v = await (i.isElement == null ? void 0 : i.isElement(w)) ? await (i.getScale == null ? void 0 : i.getScale(w)) || {
1710
2188
  x: 1,
1711
2189
  y: 1
1712
2190
  } : {
1713
2191
  x: 1,
1714
2192
  y: 1
1715
- }, x = At(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
1716
- elements: l,
1717
- rect: w,
1718
- offsetParent: b,
1719
- strategy: a
1720
- }) : w);
2193
+ }, b = pt(i.convertOffsetParentRelativeRectToViewportRelativeRect ? await i.convertOffsetParentRelativeRectToViewportRelativeRect({
2194
+ elements: a,
2195
+ rect: y,
2196
+ offsetParent: w,
2197
+ strategy: l
2198
+ }) : y);
1721
2199
  return {
1722
- top: (y.top - x.top + g.top) / v.y,
1723
- bottom: (x.bottom - y.bottom + g.bottom) / v.y,
1724
- left: (y.left - x.left + g.left) / v.x,
1725
- right: (x.right - y.right + g.right) / v.x
2200
+ top: (m.top - b.top + g.top) / v.y,
2201
+ bottom: (b.bottom - m.bottom + g.bottom) / v.y,
2202
+ left: (m.left - b.left + g.left) / v.x,
2203
+ right: (b.right - m.right + g.right) / v.x
1726
2204
  };
1727
2205
  }
1728
- const Tn = (t) => ({
2206
+ const ys = (t) => ({
1729
2207
  name: "arrow",
1730
2208
  options: t,
1731
2209
  async fn(e) {
1732
2210
  const {
1733
- x: s,
1734
- y: n,
1735
- placement: i,
1736
- rects: r,
2211
+ x: n,
2212
+ y: s,
2213
+ placement: r,
2214
+ rects: i,
1737
2215
  platform: o,
1738
- elements: l,
1739
- middlewareData: a
2216
+ elements: a,
2217
+ middlewareData: l
1740
2218
  } = e, {
1741
2219
  element: c,
1742
- padding: d = 0
1743
- } = tt(t, e) || {};
2220
+ padding: h = 0
2221
+ } = G(t, e) || {};
1744
2222
  if (c == null)
1745
2223
  return {};
1746
- const f = Ae(d), h = {
1747
- x: s,
1748
- y: n
1749
- }, u = zt(i), g = Wt(u), m = await o.getDimensions(c), p = u === "y", y = p ? "top" : "left", w = p ? "bottom" : "right", b = p ? "clientHeight" : "clientWidth", v = r.reference[g] + r.reference[u] - h[u] - r.floating[g], x = h[u] - r.reference[u], k = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(c));
1750
- let O = k ? k[b] : 0;
1751
- (!O || !await (o.isElement == null ? void 0 : o.isElement(k))) && (O = l.floating[b] || r.floating[g]);
1752
- const dt = v / 2 - x / 2, J = O / 2 - m[g] / 2 - 1, N = ct(f[y], J), ht = ct(f[w], J), X = N, gt = O - m[g] - ht, M = O / 2 - m[g] / 2 + dt, R = Ft(X, M, gt), G = !a.arrow && vt(i) != null && M !== R && r.reference[g] / 2 - (M < X ? N : ht) - m[g] / 2 < 0, B = G ? M < X ? M - X : M - gt : 0;
2224
+ const f = $e(h), d = {
2225
+ x: n,
2226
+ y: s
2227
+ }, u = qt(r), g = Ht(u), p = await o.getDimensions(c), m = u === "y", y = m ? "top" : "left", w = m ? "bottom" : "right", v = m ? "clientHeight" : "clientWidth", b = i.reference[g] + i.reference[u] - d[u] - i.floating[g], E = d[u] - i.reference[u], $ = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(c));
2228
+ let W = $ ? $[v] : 0;
2229
+ (!W || !await (o.isElement == null ? void 0 : o.isElement($))) && (W = a.floating[v] || i.floating[g]);
2230
+ const rt = b / 2 - E / 2, _ = W / 2 - p[g] / 2 - 1, D = nt(f[y], _), ot = nt(f[w], _), Q = D, at = W - p[g] - ot, x = W / 2 - p[g] / 2 + rt, J = St(Q, x, at), M = !l.arrow && ut(r) != null && x !== J && i.reference[g] / 2 - (x < Q ? D : ot) - p[g] / 2 < 0, S = M ? x < Q ? x - Q : x - at : 0;
1753
2231
  return {
1754
- [u]: h[u] + B,
2232
+ [u]: d[u] + S,
1755
2233
  data: {
1756
- [u]: R,
1757
- centerOffset: M - R - B,
1758
- ...G && {
1759
- alignmentOffset: B
2234
+ [u]: J,
2235
+ centerOffset: x - J - S,
2236
+ ...M && {
2237
+ alignmentOffset: S
1760
2238
  }
1761
2239
  },
1762
- reset: G
2240
+ reset: M
1763
2241
  };
1764
2242
  }
1765
- }), Mn = function(t) {
2243
+ }), ws = function(t) {
1766
2244
  return t === void 0 && (t = {}), {
1767
2245
  name: "flip",
1768
2246
  options: t,
1769
2247
  async fn(e) {
1770
- var s, n;
2248
+ var n, s;
1771
2249
  const {
1772
- placement: i,
1773
- middlewareData: r,
2250
+ placement: r,
2251
+ middlewareData: i,
1774
2252
  rects: o,
1775
- initialPlacement: l,
1776
- platform: a,
2253
+ initialPlacement: a,
2254
+ platform: l,
1777
2255
  elements: c
1778
2256
  } = e, {
1779
- mainAxis: d = !0,
2257
+ mainAxis: h = !0,
1780
2258
  crossAxis: f = !0,
1781
- fallbackPlacements: h,
2259
+ fallbackPlacements: d,
1782
2260
  fallbackStrategy: u = "bestFit",
1783
2261
  fallbackAxisSideDirection: g = "none",
1784
- flipAlignment: m = !0,
1785
- ...p
1786
- } = tt(t, e);
1787
- if ((s = r.arrow) != null && s.alignmentOffset)
2262
+ flipAlignment: p = !0,
2263
+ ...m
2264
+ } = G(t, e);
2265
+ if ((n = i.arrow) != null && n.alignmentOffset)
1788
2266
  return {};
1789
- const y = j(i), w = K(l), b = j(l) === l, v = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), x = h || (b || !m ? [$t(l)] : kn(l)), k = g !== "none";
1790
- !h && k && x.push(...Ln(l, m, g, v));
1791
- const O = [l, ...x], dt = await ke(e, p), J = [];
1792
- let N = ((n = r.flip) == null ? void 0 : n.overflows) || [];
1793
- if (d && J.push(dt[y]), f) {
1794
- const R = An(i, o, v);
1795
- J.push(dt[R[0]], dt[R[1]]);
2267
+ const y = z(r), w = H(a), v = z(a) === a, b = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), E = d || (v || !p ? [gt(a)] : us(a)), $ = g !== "none";
2268
+ !d && $ && E.push(...gs(a, p, g, b));
2269
+ const W = [a, ...E], rt = await Se(e, m), _ = [];
2270
+ let D = ((s = i.flip) == null ? void 0 : s.overflows) || [];
2271
+ if (h && _.push(rt[y]), f) {
2272
+ const x = cs(r, o, b);
2273
+ _.push(rt[x[0]], rt[x[1]]);
1796
2274
  }
1797
- if (N = [...N, {
1798
- placement: i,
1799
- overflows: J
1800
- }], !J.every((R) => R <= 0)) {
1801
- var ht, X;
1802
- const R = (((ht = r.flip) == null ? void 0 : ht.index) || 0) + 1, G = O[R];
1803
- if (G) {
1804
- var gt;
1805
- const _ = f === "alignment" ? w !== K(G) : !1, D = ((gt = N[0]) == null ? void 0 : gt.overflows[0]) > 0;
1806
- if (!_ || D)
1807
- return {
1808
- data: {
1809
- index: R,
1810
- overflows: N
1811
- },
1812
- reset: {
1813
- placement: G
1814
- }
1815
- };
1816
- }
1817
- let B = (X = N.filter((_) => _.overflows[0] <= 0).sort((_, D) => _.overflows[1] - D.overflows[1])[0]) == null ? void 0 : X.placement;
1818
- if (!B)
2275
+ if (D = [...D, {
2276
+ placement: r,
2277
+ overflows: _
2278
+ }], !_.every((x) => x <= 0)) {
2279
+ var ot, Q;
2280
+ const x = (((ot = i.flip) == null ? void 0 : ot.index) || 0) + 1, J = W[x];
2281
+ if (J && (!(f === "alignment" && w !== H(J)) || // We leave the current main axis only if every placement on that axis
2282
+ // overflows the main axis.
2283
+ D.every((S) => H(S.placement) === w ? S.overflows[0] > 0 : !0)))
2284
+ return {
2285
+ data: {
2286
+ index: x,
2287
+ overflows: D
2288
+ },
2289
+ reset: {
2290
+ placement: J
2291
+ }
2292
+ };
2293
+ let M = (Q = D.filter((S) => S.overflows[0] <= 0).sort((S, q) => S.overflows[1] - q.overflows[1])[0]) == null ? void 0 : Q.placement;
2294
+ if (!M)
1819
2295
  switch (u) {
1820
2296
  case "bestFit": {
1821
- var M;
1822
- const _ = (M = N.filter((D) => {
1823
- if (k) {
1824
- const W = K(D.placement);
1825
- return W === w || // Create a bias to the `y` side axis due to horizontal
2297
+ var at;
2298
+ const S = (at = D.filter((q) => {
2299
+ if ($) {
2300
+ const j = H(q.placement);
2301
+ return j === w || // Create a bias to the `y` side axis due to horizontal
1826
2302
  // reading directions favoring greater width.
1827
- W === "y";
2303
+ j === "y";
1828
2304
  }
1829
2305
  return !0;
1830
- }).map((D) => [D.placement, D.overflows.filter((W) => W > 0).reduce((W, Fe) => W + Fe, 0)]).sort((D, W) => D[1] - W[1])[0]) == null ? void 0 : M[0];
1831
- _ && (B = _);
2306
+ }).map((q) => [q.placement, q.overflows.filter((j) => j > 0).reduce((j, Ne) => j + Ne, 0)]).sort((q, j) => q[1] - j[1])[0]) == null ? void 0 : at[0];
2307
+ S && (M = S);
1832
2308
  break;
1833
2309
  }
1834
2310
  case "initialPlacement":
1835
- B = l;
2311
+ M = a;
1836
2312
  break;
1837
2313
  }
1838
- if (i !== B)
2314
+ if (r !== M)
1839
2315
  return {
1840
2316
  reset: {
1841
- placement: B
2317
+ placement: M
1842
2318
  }
1843
2319
  };
1844
2320
  }
1845
2321
  return {};
1846
2322
  }
1847
2323
  };
1848
- };
1849
- async function Dn(t, e) {
2324
+ }, Ce = /* @__PURE__ */ new Set(["left", "top"]);
2325
+ async function vs(t, e) {
1850
2326
  const {
1851
- placement: s,
1852
- platform: n,
1853
- elements: i
1854
- } = t, r = await (n.isRTL == null ? void 0 : n.isRTL(i.floating)), o = j(s), l = vt(s), a = K(s) === "y", c = ["left", "top"].includes(o) ? -1 : 1, d = r && a ? -1 : 1, f = tt(e, t);
2327
+ placement: n,
2328
+ platform: s,
2329
+ elements: r
2330
+ } = t, i = await (s.isRTL == null ? void 0 : s.isRTL(r.floating)), o = z(n), a = ut(n), l = H(n) === "y", c = Ce.has(o) ? -1 : 1, h = i && l ? -1 : 1, f = G(e, t);
1855
2331
  let {
1856
- mainAxis: h,
2332
+ mainAxis: d,
1857
2333
  crossAxis: u,
1858
2334
  alignmentAxis: g
1859
2335
  } = typeof f == "number" ? {
@@ -1865,175 +2341,178 @@ async function Dn(t, e) {
1865
2341
  crossAxis: f.crossAxis || 0,
1866
2342
  alignmentAxis: f.alignmentAxis
1867
2343
  };
1868
- return l && typeof g == "number" && (u = l === "end" ? g * -1 : g), a ? {
1869
- x: u * d,
1870
- y: h * c
2344
+ return a && typeof g == "number" && (u = a === "end" ? g * -1 : g), l ? {
2345
+ x: u * h,
2346
+ y: d * c
1871
2347
  } : {
1872
- x: h * c,
1873
- y: u * d
2348
+ x: d * c,
2349
+ y: u * h
1874
2350
  };
1875
2351
  }
1876
- const In = function(t) {
2352
+ const bs = function(t) {
1877
2353
  return t === void 0 && (t = 0), {
1878
2354
  name: "offset",
1879
2355
  options: t,
1880
2356
  async fn(e) {
1881
- var s, n;
2357
+ var n, s;
1882
2358
  const {
1883
- x: i,
1884
- y: r,
2359
+ x: r,
2360
+ y: i,
1885
2361
  placement: o,
1886
- middlewareData: l
1887
- } = e, a = await Dn(e, t);
1888
- return o === ((s = l.offset) == null ? void 0 : s.placement) && (n = l.arrow) != null && n.alignmentOffset ? {} : {
1889
- x: i + a.x,
1890
- y: r + a.y,
2362
+ middlewareData: a
2363
+ } = e, l = await vs(e, t);
2364
+ return o === ((n = a.offset) == null ? void 0 : n.placement) && (s = a.arrow) != null && s.alignmentOffset ? {} : {
2365
+ x: r + l.x,
2366
+ y: i + l.y,
1891
2367
  data: {
1892
- ...a,
2368
+ ...l,
1893
2369
  placement: o
1894
2370
  }
1895
2371
  };
1896
2372
  }
1897
2373
  };
1898
- }, Fn = function(t) {
2374
+ }, Es = function(t) {
1899
2375
  return t === void 0 && (t = {}), {
1900
2376
  name: "shift",
1901
2377
  options: t,
1902
2378
  async fn(e) {
1903
2379
  const {
1904
- x: s,
1905
- y: n,
1906
- placement: i
2380
+ x: n,
2381
+ y: s,
2382
+ placement: r
1907
2383
  } = e, {
1908
- mainAxis: r = !0,
2384
+ mainAxis: i = !0,
1909
2385
  crossAxis: o = !1,
1910
- limiter: l = {
1911
- fn: (p) => {
2386
+ limiter: a = {
2387
+ fn: (m) => {
1912
2388
  let {
1913
2389
  x: y,
1914
2390
  y: w
1915
- } = p;
2391
+ } = m;
1916
2392
  return {
1917
2393
  x: y,
1918
2394
  y: w
1919
2395
  };
1920
2396
  }
1921
2397
  },
1922
- ...a
1923
- } = tt(t, e), c = {
1924
- x: s,
1925
- y: n
1926
- }, d = await ke(e, a), f = K(j(i)), h = _t(f);
1927
- let u = c[h], g = c[f];
1928
- if (r) {
1929
- const p = h === "y" ? "top" : "left", y = h === "y" ? "bottom" : "right", w = u + d[p], b = u - d[y];
1930
- u = Ft(w, u, b);
2398
+ ...l
2399
+ } = G(t, e), c = {
2400
+ x: n,
2401
+ y: s
2402
+ }, h = await Se(e, l), f = H(z(r)), d = It(f);
2403
+ let u = c[d], g = c[f];
2404
+ if (i) {
2405
+ const m = d === "y" ? "top" : "left", y = d === "y" ? "bottom" : "right", w = u + h[m], v = u - h[y];
2406
+ u = St(w, u, v);
1931
2407
  }
1932
2408
  if (o) {
1933
- const p = f === "y" ? "top" : "left", y = f === "y" ? "bottom" : "right", w = g + d[p], b = g - d[y];
1934
- g = Ft(w, g, b);
2409
+ const m = f === "y" ? "top" : "left", y = f === "y" ? "bottom" : "right", w = g + h[m], v = g - h[y];
2410
+ g = St(w, g, v);
1935
2411
  }
1936
- const m = l.fn({
2412
+ const p = a.fn({
1937
2413
  ...e,
1938
- [h]: u,
2414
+ [d]: u,
1939
2415
  [f]: g
1940
2416
  });
1941
2417
  return {
1942
- ...m,
2418
+ ...p,
1943
2419
  data: {
1944
- x: m.x - s,
1945
- y: m.y - n,
2420
+ x: p.x - n,
2421
+ y: p.y - s,
1946
2422
  enabled: {
1947
- [h]: r,
2423
+ [d]: i,
1948
2424
  [f]: o
1949
2425
  }
1950
2426
  }
1951
2427
  };
1952
2428
  }
1953
2429
  };
1954
- }, Hn = function(t) {
2430
+ }, xs = function(t) {
1955
2431
  return t === void 0 && (t = {}), {
1956
2432
  options: t,
1957
2433
  fn(e) {
1958
2434
  const {
1959
- x: s,
1960
- y: n,
1961
- placement: i,
1962
- rects: r,
2435
+ x: n,
2436
+ y: s,
2437
+ placement: r,
2438
+ rects: i,
1963
2439
  middlewareData: o
1964
2440
  } = e, {
1965
- offset: l = 0,
1966
- mainAxis: a = !0,
2441
+ offset: a = 0,
2442
+ mainAxis: l = !0,
1967
2443
  crossAxis: c = !0
1968
- } = tt(t, e), d = {
1969
- x: s,
1970
- y: n
1971
- }, f = K(i), h = _t(f);
1972
- let u = d[h], g = d[f];
1973
- const m = tt(l, e), p = typeof m == "number" ? {
1974
- mainAxis: m,
2444
+ } = G(t, e), h = {
2445
+ x: n,
2446
+ y: s
2447
+ }, f = H(r), d = It(f);
2448
+ let u = h[d], g = h[f];
2449
+ const p = G(a, e), m = typeof p == "number" ? {
2450
+ mainAxis: p,
1975
2451
  crossAxis: 0
1976
2452
  } : {
1977
2453
  mainAxis: 0,
1978
2454
  crossAxis: 0,
1979
- ...m
2455
+ ...p
1980
2456
  };
1981
- if (a) {
1982
- const b = h === "y" ? "height" : "width", v = r.reference[h] - r.floating[b] + p.mainAxis, x = r.reference[h] + r.reference[b] - p.mainAxis;
1983
- u < v ? u = v : u > x && (u = x);
2457
+ if (l) {
2458
+ const v = d === "y" ? "height" : "width", b = i.reference[d] - i.floating[v] + m.mainAxis, E = i.reference[d] + i.reference[v] - m.mainAxis;
2459
+ u < b ? u = b : u > E && (u = E);
1984
2460
  }
1985
2461
  if (c) {
1986
2462
  var y, w;
1987
- const b = h === "y" ? "width" : "height", v = ["top", "left"].includes(j(i)), x = r.reference[f] - r.floating[b] + (v && ((y = o.offset) == null ? void 0 : y[f]) || 0) + (v ? 0 : p.crossAxis), k = r.reference[f] + r.reference[b] + (v ? 0 : ((w = o.offset) == null ? void 0 : w[f]) || 0) - (v ? p.crossAxis : 0);
1988
- g < x ? g = x : g > k && (g = k);
2463
+ const v = d === "y" ? "width" : "height", b = Ce.has(z(r)), E = i.reference[f] - i.floating[v] + (b && ((y = o.offset) == null ? void 0 : y[f]) || 0) + (b ? 0 : m.crossAxis), $ = i.reference[f] + i.reference[v] + (b ? 0 : ((w = o.offset) == null ? void 0 : w[f]) || 0) - (b ? m.crossAxis : 0);
2464
+ g < E ? g = E : g > $ && (g = $);
1989
2465
  }
1990
2466
  return {
1991
- [h]: u,
2467
+ [d]: u,
1992
2468
  [f]: g
1993
2469
  };
1994
2470
  }
1995
2471
  };
1996
2472
  };
1997
- function Rt() {
2473
+ function wt() {
1998
2474
  return typeof window < "u";
1999
2475
  }
2000
- function ut(t) {
2001
- return Oe(t) ? (t.nodeName || "").toLowerCase() : "#document";
2476
+ function it(t) {
2477
+ return Le(t) ? (t.nodeName || "").toLowerCase() : "#document";
2002
2478
  }
2003
2479
  function A(t) {
2004
2480
  var e;
2005
2481
  return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
2006
2482
  }
2007
- function H(t) {
2483
+ function R(t) {
2008
2484
  var e;
2009
- return (e = (Oe(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
2485
+ return (e = (Le(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
2010
2486
  }
2011
- function Oe(t) {
2012
- return Rt() ? t instanceof Node || t instanceof A(t).Node : !1;
2487
+ function Le(t) {
2488
+ return wt() ? t instanceof Node || t instanceof A(t).Node : !1;
2013
2489
  }
2014
- function P(t) {
2015
- return Rt() ? t instanceof Element || t instanceof A(t).Element : !1;
2490
+ function O(t) {
2491
+ return wt() ? t instanceof Element || t instanceof A(t).Element : !1;
2016
2492
  }
2017
- function F(t) {
2018
- return Rt() ? t instanceof HTMLElement || t instanceof A(t).HTMLElement : !1;
2493
+ function k(t) {
2494
+ return wt() ? t instanceof HTMLElement || t instanceof A(t).HTMLElement : !1;
2019
2495
  }
2020
- function te(t) {
2021
- return !Rt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof A(t).ShadowRoot;
2496
+ function Wt(t) {
2497
+ return !wt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof A(t).ShadowRoot;
2022
2498
  }
2023
- function Et(t) {
2499
+ const $s = /* @__PURE__ */ new Set(["inline", "contents"]);
2500
+ function ht(t) {
2024
2501
  const {
2025
2502
  overflow: e,
2026
- overflowX: s,
2027
- overflowY: n,
2028
- display: i
2503
+ overflowX: n,
2504
+ overflowY: s,
2505
+ display: r
2029
2506
  } = T(t);
2030
- return /auto|scroll|overlay|hidden|clip/.test(e + n + s) && !["inline", "contents"].includes(i);
2507
+ return /auto|scroll|overlay|hidden|clip/.test(e + s + n) && !$s.has(r);
2031
2508
  }
2032
- function Nn(t) {
2033
- return ["table", "td", "th"].includes(ut(t));
2509
+ const Ss = /* @__PURE__ */ new Set(["table", "td", "th"]);
2510
+ function Cs(t) {
2511
+ return Ss.has(it(t));
2034
2512
  }
2035
- function Pt(t) {
2036
- return [":popover-open", ":modal"].some((e) => {
2513
+ const Ls = [":popover-open", ":modal"];
2514
+ function vt(t) {
2515
+ return Ls.some((e) => {
2037
2516
  try {
2038
2517
  return t.matches(e);
2039
2518
  } catch {
@@ -2041,32 +2520,34 @@ function Pt(t) {
2041
2520
  }
2042
2521
  });
2043
2522
  }
2044
- function Qt(t) {
2045
- const e = Kt(), s = P(t) ? T(t) : t;
2046
- return ["transform", "translate", "scale", "rotate", "perspective"].some((n) => s[n] ? s[n] !== "none" : !1) || (s.containerType ? s.containerType !== "normal" : !1) || !e && (s.backdropFilter ? s.backdropFilter !== "none" : !1) || !e && (s.filter ? s.filter !== "none" : !1) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((n) => (s.willChange || "").includes(n)) || ["paint", "layout", "strict", "content"].some((n) => (s.contain || "").includes(n));
2523
+ const As = ["transform", "translate", "scale", "rotate", "perspective"], Os = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Ts = ["paint", "layout", "strict", "content"];
2524
+ function jt(t) {
2525
+ const e = Nt(), n = O(t) ? T(t) : t;
2526
+ return As.some((s) => n[s] ? n[s] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || Os.some((s) => (n.willChange || "").includes(s)) || Ts.some((s) => (n.contain || "").includes(s));
2047
2527
  }
2048
- function Bn(t) {
2049
- let e = Y(t);
2050
- for (; F(e) && !ft(e); ) {
2051
- if (Qt(e))
2528
+ function Ps(t) {
2529
+ let e = B(t);
2530
+ for (; k(e) && !st(e); ) {
2531
+ if (jt(e))
2052
2532
  return e;
2053
- if (Pt(e))
2533
+ if (vt(e))
2054
2534
  return null;
2055
- e = Y(e);
2535
+ e = B(e);
2056
2536
  }
2057
2537
  return null;
2058
2538
  }
2059
- function Kt() {
2539
+ function Nt() {
2060
2540
  return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
2061
2541
  }
2062
- function ft(t) {
2063
- return ["html", "body", "#document"].includes(ut(t));
2542
+ const ks = /* @__PURE__ */ new Set(["html", "body", "#document"]);
2543
+ function st(t) {
2544
+ return ks.has(it(t));
2064
2545
  }
2065
2546
  function T(t) {
2066
2547
  return A(t).getComputedStyle(t);
2067
2548
  }
2068
- function Tt(t) {
2069
- return P(t) ? {
2549
+ function bt(t) {
2550
+ return O(t) ? {
2070
2551
  scrollLeft: t.scrollLeft,
2071
2552
  scrollTop: t.scrollTop
2072
2553
  } : {
@@ -2074,223 +2555,226 @@ function Tt(t) {
2074
2555
  scrollTop: t.scrollY
2075
2556
  };
2076
2557
  }
2077
- function Y(t) {
2078
- if (ut(t) === "html")
2558
+ function B(t) {
2559
+ if (it(t) === "html")
2079
2560
  return t;
2080
2561
  const e = (
2081
2562
  // Step into the shadow DOM of the parent of a slotted node.
2082
2563
  t.assignedSlot || // DOM Element detected.
2083
2564
  t.parentNode || // ShadowRoot detected.
2084
- te(t) && t.host || // Fallback.
2085
- H(t)
2565
+ Wt(t) && t.host || // Fallback.
2566
+ R(t)
2086
2567
  );
2087
- return te(e) ? e.host : e;
2568
+ return Wt(e) ? e.host : e;
2088
2569
  }
2089
- function Le(t) {
2090
- const e = Y(t);
2091
- return ft(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : F(e) && Et(e) ? e : Le(e);
2570
+ function Ae(t) {
2571
+ const e = B(t);
2572
+ return st(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : k(e) && ht(e) ? e : Ae(e);
2092
2573
  }
2093
- function yt(t, e, s) {
2094
- var n;
2095
- e === void 0 && (e = []), s === void 0 && (s = !0);
2096
- const i = Le(t), r = i === ((n = t.ownerDocument) == null ? void 0 : n.body), o = A(i);
2097
- if (r) {
2098
- const l = Nt(o);
2099
- return e.concat(o, o.visualViewport || [], Et(i) ? i : [], l && s ? yt(l) : []);
2574
+ function ct(t, e, n) {
2575
+ var s;
2576
+ e === void 0 && (e = []), n === void 0 && (n = !0);
2577
+ const r = Ae(t), i = r === ((s = t.ownerDocument) == null ? void 0 : s.body), o = A(r);
2578
+ if (i) {
2579
+ const a = Lt(o);
2580
+ return e.concat(o, o.visualViewport || [], ht(r) ? r : [], a && n ? ct(a) : []);
2100
2581
  }
2101
- return e.concat(i, yt(i, [], s));
2582
+ return e.concat(r, ct(r, [], n));
2102
2583
  }
2103
- function Nt(t) {
2584
+ function Lt(t) {
2104
2585
  return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
2105
2586
  }
2106
- function Re(t) {
2587
+ function Oe(t) {
2107
2588
  const e = T(t);
2108
- let s = parseFloat(e.width) || 0, n = parseFloat(e.height) || 0;
2109
- const i = F(t), r = i ? t.offsetWidth : s, o = i ? t.offsetHeight : n, l = Ct(s) !== r || Ct(n) !== o;
2110
- return l && (s = r, n = o), {
2111
- width: s,
2112
- height: n,
2113
- $: l
2589
+ let n = parseFloat(e.width) || 0, s = parseFloat(e.height) || 0;
2590
+ const r = k(t), i = r ? t.offsetWidth : n, o = r ? t.offsetHeight : s, a = dt(n) !== i || dt(s) !== o;
2591
+ return a && (n = i, s = o), {
2592
+ width: n,
2593
+ height: s,
2594
+ $: a
2114
2595
  };
2115
2596
  }
2116
- function jt(t) {
2117
- return P(t) ? t : t.contextElement;
2597
+ function Ut(t) {
2598
+ return O(t) ? t : t.contextElement;
2118
2599
  }
2119
- function st(t) {
2120
- const e = jt(t);
2121
- if (!F(e))
2122
- return I(1);
2123
- const s = e.getBoundingClientRect(), {
2124
- width: n,
2125
- height: i,
2126
- $: r
2127
- } = Re(e);
2128
- let o = (r ? Ct(s.width) : s.width) / n, l = (r ? Ct(s.height) : s.height) / i;
2129
- return (!o || !Number.isFinite(o)) && (o = 1), (!l || !Number.isFinite(l)) && (l = 1), {
2600
+ function et(t) {
2601
+ const e = Ut(t);
2602
+ if (!k(e))
2603
+ return P(1);
2604
+ const n = e.getBoundingClientRect(), {
2605
+ width: s,
2606
+ height: r,
2607
+ $: i
2608
+ } = Oe(e);
2609
+ let o = (i ? dt(n.width) : n.width) / s, a = (i ? dt(n.height) : n.height) / r;
2610
+ return (!o || !Number.isFinite(o)) && (o = 1), (!a || !Number.isFinite(a)) && (a = 1), {
2130
2611
  x: o,
2131
- y: l
2612
+ y: a
2132
2613
  };
2133
2614
  }
2134
- const Un = /* @__PURE__ */ I(0);
2135
- function Pe(t) {
2615
+ const Rs = /* @__PURE__ */ P(0);
2616
+ function Te(t) {
2136
2617
  const e = A(t);
2137
- return !Kt() || !e.visualViewport ? Un : {
2618
+ return !Nt() || !e.visualViewport ? Rs : {
2138
2619
  x: e.visualViewport.offsetLeft,
2139
2620
  y: e.visualViewport.offsetTop
2140
2621
  };
2141
2622
  }
2142
- function Vn(t, e, s) {
2143
- return e === void 0 && (e = !1), !s || e && s !== A(t) ? !1 : e;
2623
+ function Ds(t, e, n) {
2624
+ return e === void 0 && (e = !1), !n || e && n !== A(t) ? !1 : e;
2144
2625
  }
2145
- function et(t, e, s, n) {
2146
- e === void 0 && (e = !1), s === void 0 && (s = !1);
2147
- const i = t.getBoundingClientRect(), r = jt(t);
2148
- let o = I(1);
2149
- e && (n ? P(n) && (o = st(n)) : o = st(t));
2150
- const l = Vn(r, s, n) ? Pe(r) : I(0);
2151
- let a = (i.left + l.x) / o.x, c = (i.top + l.y) / o.y, d = i.width / o.x, f = i.height / o.y;
2152
- if (r) {
2153
- const h = A(r), u = n && P(n) ? A(n) : n;
2154
- let g = h, m = Nt(g);
2155
- for (; m && n && u !== g; ) {
2156
- const p = st(m), y = m.getBoundingClientRect(), w = T(m), b = y.left + (m.clientLeft + parseFloat(w.paddingLeft)) * p.x, v = y.top + (m.clientTop + parseFloat(w.paddingTop)) * p.y;
2157
- a *= p.x, c *= p.y, d *= p.x, f *= p.y, a += b, c += v, g = A(m), m = Nt(g);
2626
+ function tt(t, e, n, s) {
2627
+ e === void 0 && (e = !1), n === void 0 && (n = !1);
2628
+ const r = t.getBoundingClientRect(), i = Ut(t);
2629
+ let o = P(1);
2630
+ e && (s ? O(s) && (o = et(s)) : o = et(t));
2631
+ const a = Ds(i, n, s) ? Te(i) : P(0);
2632
+ let l = (r.left + a.x) / o.x, c = (r.top + a.y) / o.y, h = r.width / o.x, f = r.height / o.y;
2633
+ if (i) {
2634
+ const d = A(i), u = s && O(s) ? A(s) : s;
2635
+ let g = d, p = Lt(g);
2636
+ for (; p && s && u !== g; ) {
2637
+ const m = et(p), y = p.getBoundingClientRect(), w = T(p), v = y.left + (p.clientLeft + parseFloat(w.paddingLeft)) * m.x, b = y.top + (p.clientTop + parseFloat(w.paddingTop)) * m.y;
2638
+ l *= m.x, c *= m.y, h *= m.x, f *= m.y, l += v, c += b, g = A(p), p = Lt(g);
2158
2639
  }
2159
2640
  }
2160
- return At({
2161
- width: d,
2641
+ return pt({
2642
+ width: h,
2162
2643
  height: f,
2163
- x: a,
2644
+ x: l,
2164
2645
  y: c
2165
2646
  });
2166
2647
  }
2167
- function Yt(t, e) {
2168
- const s = Tt(t).scrollLeft;
2169
- return e ? e.left + s : et(H(t)).left + s;
2648
+ function Et(t, e) {
2649
+ const n = bt(t).scrollLeft;
2650
+ return e ? e.left + n : tt(R(t)).left + n;
2170
2651
  }
2171
- function Te(t, e, s) {
2172
- s === void 0 && (s = !1);
2173
- const n = t.getBoundingClientRect(), i = n.left + e.scrollLeft - (s ? 0 : (
2174
- // RTL <body> scrollbar.
2175
- Yt(t, n)
2176
- )), r = n.top + e.scrollTop;
2652
+ function Pe(t, e) {
2653
+ const n = t.getBoundingClientRect(), s = n.left + e.scrollLeft - Et(t, n), r = n.top + e.scrollTop;
2177
2654
  return {
2178
- x: i,
2655
+ x: s,
2179
2656
  y: r
2180
2657
  };
2181
2658
  }
2182
- function _n(t) {
2659
+ function Ms(t) {
2183
2660
  let {
2184
2661
  elements: e,
2185
- rect: s,
2186
- offsetParent: n,
2187
- strategy: i
2662
+ rect: n,
2663
+ offsetParent: s,
2664
+ strategy: r
2188
2665
  } = t;
2189
- const r = i === "fixed", o = H(n), l = e ? Pt(e.floating) : !1;
2190
- if (n === o || l && r)
2191
- return s;
2192
- let a = {
2666
+ const i = r === "fixed", o = R(s), a = e ? vt(e.floating) : !1;
2667
+ if (s === o || a && i)
2668
+ return n;
2669
+ let l = {
2193
2670
  scrollLeft: 0,
2194
2671
  scrollTop: 0
2195
- }, c = I(1);
2196
- const d = I(0), f = F(n);
2197
- if ((f || !f && !r) && ((ut(n) !== "body" || Et(o)) && (a = Tt(n)), F(n))) {
2198
- const u = et(n);
2199
- c = st(n), d.x = u.x + n.clientLeft, d.y = u.y + n.clientTop;
2672
+ }, c = P(1);
2673
+ const h = P(0), f = k(s);
2674
+ if ((f || !f && !i) && ((it(s) !== "body" || ht(o)) && (l = bt(s)), k(s))) {
2675
+ const u = tt(s);
2676
+ c = et(s), h.x = u.x + s.clientLeft, h.y = u.y + s.clientTop;
2200
2677
  }
2201
- const h = o && !f && !r ? Te(o, a, !0) : I(0);
2678
+ const d = o && !f && !i ? Pe(o, l) : P(0);
2202
2679
  return {
2203
- width: s.width * c.x,
2204
- height: s.height * c.y,
2205
- x: s.x * c.x - a.scrollLeft * c.x + d.x + h.x,
2206
- y: s.y * c.y - a.scrollTop * c.y + d.y + h.y
2680
+ width: n.width * c.x,
2681
+ height: n.height * c.y,
2682
+ x: n.x * c.x - l.scrollLeft * c.x + h.x + d.x,
2683
+ y: n.y * c.y - l.scrollTop * c.y + h.y + d.y
2207
2684
  };
2208
2685
  }
2209
- function Wn(t) {
2686
+ function Is(t) {
2210
2687
  return Array.from(t.getClientRects());
2211
2688
  }
2212
- function zn(t) {
2213
- const e = H(t), s = Tt(t), n = t.ownerDocument.body, i = Z(e.scrollWidth, e.clientWidth, n.scrollWidth, n.clientWidth), r = Z(e.scrollHeight, e.clientHeight, n.scrollHeight, n.clientHeight);
2214
- let o = -s.scrollLeft + Yt(t);
2215
- const l = -s.scrollTop;
2216
- return T(n).direction === "rtl" && (o += Z(e.clientWidth, n.clientWidth) - i), {
2217
- width: i,
2218
- height: r,
2689
+ function Hs(t) {
2690
+ const e = R(t), n = bt(t), s = t.ownerDocument.body, r = Y(e.scrollWidth, e.clientWidth, s.scrollWidth, s.clientWidth), i = Y(e.scrollHeight, e.clientHeight, s.scrollHeight, s.clientHeight);
2691
+ let o = -n.scrollLeft + Et(t);
2692
+ const a = -n.scrollTop;
2693
+ return T(s).direction === "rtl" && (o += Y(e.clientWidth, s.clientWidth) - r), {
2694
+ width: r,
2695
+ height: i,
2219
2696
  x: o,
2220
- y: l
2697
+ y: a
2221
2698
  };
2222
2699
  }
2223
- function Qn(t, e) {
2224
- const s = A(t), n = H(t), i = s.visualViewport;
2225
- let r = n.clientWidth, o = n.clientHeight, l = 0, a = 0;
2226
- if (i) {
2227
- r = i.width, o = i.height;
2228
- const c = Kt();
2229
- (!c || c && e === "fixed") && (l = i.offsetLeft, a = i.offsetTop);
2230
- }
2700
+ const _t = 25;
2701
+ function qs(t, e) {
2702
+ const n = A(t), s = R(t), r = n.visualViewport;
2703
+ let i = s.clientWidth, o = s.clientHeight, a = 0, l = 0;
2704
+ if (r) {
2705
+ i = r.width, o = r.height;
2706
+ const h = Nt();
2707
+ (!h || h && e === "fixed") && (a = r.offsetLeft, l = r.offsetTop);
2708
+ }
2709
+ const c = Et(s);
2710
+ if (c <= 0) {
2711
+ const h = s.ownerDocument, f = h.body, d = getComputedStyle(f), u = h.compatMode === "CSS1Compat" && parseFloat(d.marginLeft) + parseFloat(d.marginRight) || 0, g = Math.abs(s.clientWidth - f.clientWidth - u);
2712
+ g <= _t && (i -= g);
2713
+ } else c <= _t && (i += c);
2231
2714
  return {
2232
- width: r,
2715
+ width: i,
2233
2716
  height: o,
2234
- x: l,
2235
- y: a
2717
+ x: a,
2718
+ y: l
2236
2719
  };
2237
2720
  }
2238
- function Kn(t, e) {
2239
- const s = et(t, !0, e === "fixed"), n = s.top + t.clientTop, i = s.left + t.clientLeft, r = F(t) ? st(t) : I(1), o = t.clientWidth * r.x, l = t.clientHeight * r.y, a = i * r.x, c = n * r.y;
2721
+ const js = /* @__PURE__ */ new Set(["absolute", "fixed"]);
2722
+ function Ns(t, e) {
2723
+ const n = tt(t, !0, e === "fixed"), s = n.top + t.clientTop, r = n.left + t.clientLeft, i = k(t) ? et(t) : P(1), o = t.clientWidth * i.x, a = t.clientHeight * i.y, l = r * i.x, c = s * i.y;
2240
2724
  return {
2241
2725
  width: o,
2242
- height: l,
2243
- x: a,
2726
+ height: a,
2727
+ x: l,
2244
2728
  y: c
2245
2729
  };
2246
2730
  }
2247
- function ee(t, e, s) {
2248
- let n;
2731
+ function Qt(t, e, n) {
2732
+ let s;
2249
2733
  if (e === "viewport")
2250
- n = Qn(t, s);
2734
+ s = qs(t, n);
2251
2735
  else if (e === "document")
2252
- n = zn(H(t));
2253
- else if (P(e))
2254
- n = Kn(e, s);
2736
+ s = Hs(R(t));
2737
+ else if (O(e))
2738
+ s = Ns(e, n);
2255
2739
  else {
2256
- const i = Pe(t);
2257
- n = {
2258
- x: e.x - i.x,
2259
- y: e.y - i.y,
2740
+ const r = Te(t);
2741
+ s = {
2742
+ x: e.x - r.x,
2743
+ y: e.y - r.y,
2260
2744
  width: e.width,
2261
2745
  height: e.height
2262
2746
  };
2263
2747
  }
2264
- return At(n);
2748
+ return pt(s);
2265
2749
  }
2266
- function Me(t, e) {
2267
- const s = Y(t);
2268
- return s === e || !P(s) || ft(s) ? !1 : T(s).position === "fixed" || Me(s, e);
2750
+ function ke(t, e) {
2751
+ const n = B(t);
2752
+ return n === e || !O(n) || st(n) ? !1 : T(n).position === "fixed" || ke(n, e);
2269
2753
  }
2270
- function jn(t, e) {
2271
- const s = e.get(t);
2272
- if (s)
2273
- return s;
2274
- let n = yt(t, [], !1).filter((l) => P(l) && ut(l) !== "body"), i = null;
2275
- const r = T(t).position === "fixed";
2276
- let o = r ? Y(t) : t;
2277
- for (; P(o) && !ft(o); ) {
2278
- const l = T(o), a = Qt(o);
2279
- !a && l.position === "fixed" && (i = null), (r ? !a && !i : !a && l.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || Et(o) && !a && Me(t, o)) ? n = n.filter((d) => d !== o) : i = l, o = Y(o);
2754
+ function Us(t, e) {
2755
+ const n = e.get(t);
2756
+ if (n)
2757
+ return n;
2758
+ let s = ct(t, [], !1).filter((a) => O(a) && it(a) !== "body"), r = null;
2759
+ const i = T(t).position === "fixed";
2760
+ let o = i ? B(t) : t;
2761
+ for (; O(o) && !st(o); ) {
2762
+ const a = T(o), l = jt(o);
2763
+ !l && a.position === "fixed" && (r = null), (i ? !l && !r : !l && a.position === "static" && r && js.has(r.position) || ht(o) && !l && ke(t, o)) ? s = s.filter((c) => c !== o) : r = a, o = B(o);
2280
2764
  }
2281
- return e.set(t, n), n;
2765
+ return e.set(t, s), s;
2282
2766
  }
2283
- function Yn(t) {
2767
+ function Fs(t) {
2284
2768
  let {
2285
2769
  element: e,
2286
- boundary: s,
2287
- rootBoundary: n,
2288
- strategy: i
2770
+ boundary: n,
2771
+ rootBoundary: s,
2772
+ strategy: r
2289
2773
  } = t;
2290
- const o = [...s === "clippingAncestors" ? Pt(e) ? [] : jn(e, this._c) : [].concat(s), n], l = o[0], a = o.reduce((c, d) => {
2291
- const f = ee(e, d, i);
2292
- return c.top = Z(f.top, c.top), c.right = ct(f.right, c.right), c.bottom = ct(f.bottom, c.bottom), c.left = Z(f.left, c.left), c;
2293
- }, ee(e, l, i));
2774
+ const i = [...n === "clippingAncestors" ? vt(e) ? [] : Us(e, this._c) : [].concat(n), s], o = i[0], a = i.reduce((l, c) => {
2775
+ const h = Qt(e, c, r);
2776
+ return l.top = Y(h.top, l.top), l.right = nt(h.right, l.right), l.bottom = nt(h.bottom, l.bottom), l.left = Y(h.left, l.left), l;
2777
+ }, Qt(e, o, r));
2294
2778
  return {
2295
2779
  width: a.right - a.left,
2296
2780
  height: a.bottom - a.top,
@@ -2298,257 +2782,493 @@ function Yn(t) {
2298
2782
  y: a.top
2299
2783
  };
2300
2784
  }
2301
- function Jn(t) {
2785
+ function Vs(t) {
2302
2786
  const {
2303
2787
  width: e,
2304
- height: s
2305
- } = Re(t);
2788
+ height: n
2789
+ } = Oe(t);
2306
2790
  return {
2307
2791
  width: e,
2308
- height: s
2792
+ height: n
2309
2793
  };
2310
2794
  }
2311
- function Xn(t, e, s) {
2312
- const n = F(e), i = H(e), r = s === "fixed", o = et(t, !0, r, e);
2313
- let l = {
2795
+ function zs(t, e, n) {
2796
+ const s = k(e), r = R(e), i = n === "fixed", o = tt(t, !0, i, e);
2797
+ let a = {
2314
2798
  scrollLeft: 0,
2315
2799
  scrollTop: 0
2316
2800
  };
2317
- const a = I(0);
2801
+ const l = P(0);
2318
2802
  function c() {
2319
- a.x = Yt(i);
2320
- }
2321
- if (n || !n && !r)
2322
- if ((ut(e) !== "body" || Et(i)) && (l = Tt(e)), n) {
2323
- const u = et(e, !0, r, e);
2324
- a.x = u.x + e.clientLeft, a.y = u.y + e.clientTop;
2325
- } else i && c();
2326
- r && !n && i && c();
2327
- const d = i && !n && !r ? Te(i, l) : I(0), f = o.left + l.scrollLeft - a.x - d.x, h = o.top + l.scrollTop - a.y - d.y;
2803
+ l.x = Et(r);
2804
+ }
2805
+ if (s || !s && !i)
2806
+ if ((it(e) !== "body" || ht(r)) && (a = bt(e)), s) {
2807
+ const u = tt(e, !0, i, e);
2808
+ l.x = u.x + e.clientLeft, l.y = u.y + e.clientTop;
2809
+ } else r && c();
2810
+ i && !s && r && c();
2811
+ const h = r && !s && !i ? Pe(r, a) : P(0), f = o.left + a.scrollLeft - l.x - h.x, d = o.top + a.scrollTop - l.y - h.y;
2328
2812
  return {
2329
2813
  x: f,
2330
- y: h,
2814
+ y: d,
2331
2815
  width: o.width,
2332
2816
  height: o.height
2333
2817
  };
2334
2818
  }
2335
- function Dt(t) {
2819
+ function xt(t) {
2336
2820
  return T(t).position === "static";
2337
2821
  }
2338
- function ne(t, e) {
2339
- if (!F(t) || T(t).position === "fixed")
2822
+ function Jt(t, e) {
2823
+ if (!k(t) || T(t).position === "fixed")
2340
2824
  return null;
2341
2825
  if (e)
2342
2826
  return e(t);
2343
- let s = t.offsetParent;
2344
- return H(t) === s && (s = s.ownerDocument.body), s;
2827
+ let n = t.offsetParent;
2828
+ return R(t) === n && (n = n.ownerDocument.body), n;
2345
2829
  }
2346
- function De(t, e) {
2347
- const s = A(t);
2348
- if (Pt(t))
2349
- return s;
2350
- if (!F(t)) {
2351
- let i = Y(t);
2352
- for (; i && !ft(i); ) {
2353
- if (P(i) && !Dt(i))
2354
- return i;
2355
- i = Y(i);
2830
+ function Re(t, e) {
2831
+ const n = A(t);
2832
+ if (vt(t))
2833
+ return n;
2834
+ if (!k(t)) {
2835
+ let r = B(t);
2836
+ for (; r && !st(r); ) {
2837
+ if (O(r) && !xt(r))
2838
+ return r;
2839
+ r = B(r);
2356
2840
  }
2357
- return s;
2841
+ return n;
2358
2842
  }
2359
- let n = ne(t, e);
2360
- for (; n && Nn(n) && Dt(n); )
2361
- n = ne(n, e);
2362
- return n && ft(n) && Dt(n) && !Qt(n) ? s : n || Bn(t) || s;
2843
+ let s = Jt(t, e);
2844
+ for (; s && Cs(s) && xt(s); )
2845
+ s = Jt(s, e);
2846
+ return s && st(s) && xt(s) && !jt(s) ? n : s || Ps(t) || n;
2363
2847
  }
2364
- const Gn = async function(t) {
2365
- const e = this.getOffsetParent || De, s = this.getDimensions, n = await s(t.floating);
2848
+ const Bs = async function(t) {
2849
+ const e = this.getOffsetParent || Re, n = this.getDimensions, s = await n(t.floating);
2366
2850
  return {
2367
- reference: Xn(t.reference, await e(t.floating), t.strategy),
2851
+ reference: zs(t.reference, await e(t.floating), t.strategy),
2368
2852
  floating: {
2369
2853
  x: 0,
2370
2854
  y: 0,
2371
- width: n.width,
2372
- height: n.height
2855
+ width: s.width,
2856
+ height: s.height
2373
2857
  }
2374
2858
  };
2375
2859
  };
2376
- function qn(t) {
2860
+ function Ws(t) {
2377
2861
  return T(t).direction === "rtl";
2378
2862
  }
2379
- const Zn = {
2380
- convertOffsetParentRelativeRectToViewportRelativeRect: _n,
2381
- getDocumentElement: H,
2382
- getClippingRect: Yn,
2383
- getOffsetParent: De,
2384
- getElementRects: Gn,
2385
- getClientRects: Wn,
2386
- getDimensions: Jn,
2387
- getScale: st,
2388
- isElement: P,
2389
- isRTL: qn
2863
+ const _s = {
2864
+ convertOffsetParentRelativeRectToViewportRelativeRect: Ms,
2865
+ getDocumentElement: R,
2866
+ getClippingRect: Fs,
2867
+ getOffsetParent: Re,
2868
+ getElementRects: Bs,
2869
+ getClientRects: Is,
2870
+ getDimensions: Vs,
2871
+ getScale: et,
2872
+ isElement: O,
2873
+ isRTL: Ws
2390
2874
  };
2391
- function Ie(t, e) {
2875
+ function De(t, e) {
2392
2876
  return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
2393
2877
  }
2394
- function ts(t, e) {
2395
- let s = null, n;
2396
- const i = H(t);
2397
- function r() {
2398
- var l;
2399
- clearTimeout(n), (l = s) == null || l.disconnect(), s = null;
2878
+ function Qs(t, e) {
2879
+ let n = null, s;
2880
+ const r = R(t);
2881
+ function i() {
2882
+ var a;
2883
+ clearTimeout(s), (a = n) == null || a.disconnect(), n = null;
2400
2884
  }
2401
- function o(l, a) {
2402
- l === void 0 && (l = !1), a === void 0 && (a = 1), r();
2885
+ function o(a, l) {
2886
+ a === void 0 && (a = !1), l === void 0 && (l = 1), i();
2403
2887
  const c = t.getBoundingClientRect(), {
2404
- left: d,
2888
+ left: h,
2405
2889
  top: f,
2406
- width: h,
2890
+ width: d,
2407
2891
  height: u
2408
2892
  } = c;
2409
- if (l || e(), !h || !u)
2893
+ if (a || e(), !d || !u)
2410
2894
  return;
2411
- const g = St(f), m = St(i.clientWidth - (d + h)), p = St(i.clientHeight - (f + u)), y = St(d), b = {
2412
- rootMargin: -g + "px " + -m + "px " + -p + "px " + -y + "px",
2413
- threshold: Z(0, ct(1, a)) || 1
2895
+ const g = ft(f), p = ft(r.clientWidth - (h + d)), m = ft(r.clientHeight - (f + u)), y = ft(h), w = {
2896
+ rootMargin: -g + "px " + -p + "px " + -m + "px " + -y + "px",
2897
+ threshold: Y(0, nt(1, l)) || 1
2414
2898
  };
2415
2899
  let v = !0;
2416
- function x(k) {
2417
- const O = k[0].intersectionRatio;
2418
- if (O !== a) {
2900
+ function b(E) {
2901
+ const $ = E[0].intersectionRatio;
2902
+ if ($ !== l) {
2419
2903
  if (!v)
2420
2904
  return o();
2421
- O ? o(!1, O) : n = setTimeout(() => {
2905
+ $ ? o(!1, $) : s = setTimeout(() => {
2422
2906
  o(!1, 1e-7);
2423
2907
  }, 1e3);
2424
2908
  }
2425
- O === 1 && !Ie(c, t.getBoundingClientRect()) && o(), v = !1;
2909
+ $ === 1 && !De(c, t.getBoundingClientRect()) && o(), v = !1;
2426
2910
  }
2427
2911
  try {
2428
- s = new IntersectionObserver(x, {
2429
- ...b,
2912
+ n = new IntersectionObserver(b, {
2913
+ ...w,
2430
2914
  // Handle <iframe>s
2431
- root: i.ownerDocument
2915
+ root: r.ownerDocument
2432
2916
  });
2433
2917
  } catch {
2434
- s = new IntersectionObserver(x, b);
2918
+ n = new IntersectionObserver(b, w);
2435
2919
  }
2436
- s.observe(t);
2920
+ n.observe(t);
2437
2921
  }
2438
- return o(!0), r;
2922
+ return o(!0), i;
2439
2923
  }
2440
- function es(t, e, s, n) {
2441
- n === void 0 && (n = {});
2924
+ function Js(t, e, n, s) {
2925
+ s === void 0 && (s = {});
2442
2926
  const {
2443
- ancestorScroll: i = !0,
2444
- ancestorResize: r = !0,
2927
+ ancestorScroll: r = !0,
2928
+ ancestorResize: i = !0,
2445
2929
  elementResize: o = typeof ResizeObserver == "function",
2446
- layoutShift: l = typeof IntersectionObserver == "function",
2447
- animationFrame: a = !1
2448
- } = n, c = jt(t), d = i || r ? [...c ? yt(c) : [], ...yt(e)] : [];
2449
- d.forEach((y) => {
2450
- i && y.addEventListener("scroll", s, {
2930
+ layoutShift: a = typeof IntersectionObserver == "function",
2931
+ animationFrame: l = !1
2932
+ } = s, c = Ut(t), h = r || i ? [...c ? ct(c) : [], ...ct(e)] : [];
2933
+ h.forEach((y) => {
2934
+ r && y.addEventListener("scroll", n, {
2451
2935
  passive: !0
2452
- }), r && y.addEventListener("resize", s);
2936
+ }), i && y.addEventListener("resize", n);
2453
2937
  });
2454
- const f = c && l ? ts(c, s) : null;
2455
- let h = -1, u = null;
2938
+ const f = c && a ? Qs(c, n) : null;
2939
+ let d = -1, u = null;
2456
2940
  o && (u = new ResizeObserver((y) => {
2457
2941
  let [w] = y;
2458
- w && w.target === c && u && (u.unobserve(e), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
2459
- var b;
2460
- (b = u) == null || b.observe(e);
2461
- })), s();
2462
- }), c && !a && u.observe(c), u.observe(e));
2463
- let g, m = a ? et(t) : null;
2464
- a && p();
2465
- function p() {
2466
- const y = et(t);
2467
- m && !Ie(m, y) && s(), m = y, g = requestAnimationFrame(p);
2468
- }
2469
- return s(), () => {
2942
+ w && w.target === c && u && (u.unobserve(e), cancelAnimationFrame(d), d = requestAnimationFrame(() => {
2943
+ var v;
2944
+ (v = u) == null || v.observe(e);
2945
+ })), n();
2946
+ }), c && !l && u.observe(c), u.observe(e));
2947
+ let g, p = l ? tt(t) : null;
2948
+ l && m();
2949
+ function m() {
2950
+ const y = tt(t);
2951
+ p && !De(p, y) && n(), p = y, g = requestAnimationFrame(m);
2952
+ }
2953
+ return n(), () => {
2470
2954
  var y;
2471
- d.forEach((w) => {
2472
- i && w.removeEventListener("scroll", s), r && w.removeEventListener("resize", s);
2473
- }), f == null || f(), (y = u) == null || y.disconnect(), u = null, a && cancelAnimationFrame(g);
2955
+ h.forEach((w) => {
2956
+ r && w.removeEventListener("scroll", n), i && w.removeEventListener("resize", n);
2957
+ }), f?.(), (y = u) == null || y.disconnect(), u = null, l && cancelAnimationFrame(g);
2474
2958
  };
2475
2959
  }
2476
- const ns = In, ss = Fn, is = Mn, os = Tn, rs = Hn, ls = (t, e, s) => {
2477
- const n = /* @__PURE__ */ new Map(), i = {
2478
- platform: Zn,
2479
- ...s
2480
- }, r = {
2481
- ...i.platform,
2482
- _c: n
2960
+ const Zs = bs, Ks = Es, Xs = ws, Ys = ys, Gs = xs, ti = (t, e, n) => {
2961
+ const s = /* @__PURE__ */ new Map(), r = {
2962
+ platform: _s,
2963
+ ...n
2964
+ }, i = {
2965
+ ...r.platform,
2966
+ _c: s
2483
2967
  };
2484
- return Pn(t, e, {
2485
- ...i,
2486
- platform: r
2968
+ return ms(t, e, {
2969
+ ...r,
2970
+ platform: i
2487
2971
  });
2488
2972
  };
2489
- async function as(t) {
2490
- const e = Ee.call(this, t);
2491
- e.el.inert = !1, e.el.classList.add(this.settings.stateActive), e.isTooltip || e.trigger.setAttribute("aria-expanded", "true"), e.buildCustomProps();
2492
- const s = pn(e), n = e.el.querySelector(s.arrow.element);
2493
- return s.arrow.element = n || void 0, e.floatingCleanup = es(e.trigger, e.el, () => {
2494
- ls(e.trigger, e.el, {
2495
- placement: e.getSetting("placement"),
2496
- middleware: [
2497
- is(s.flip),
2498
- ss({ ...s.shift, limiter: rs() }),
2499
- ns(s.offset),
2500
- os(s.arrow)
2501
- ]
2502
- }).then(({ x: i, y: r, placement: o, middlewareData: l }) => {
2503
- if (e.el) {
2504
- if (qt(e.el, i, r), s.arrow.element && l.arrow) {
2505
- const { x: a, y: c } = l.arrow;
2506
- qt(s.arrow.element, a, c);
2973
+ function Zt(t, e, n) {
2974
+ Object.assign(t.style, {
2975
+ left: e != null ? `${e}px` : "",
2976
+ top: n != null ? `${n}px` : ""
2977
+ });
2978
+ }
2979
+ function Me(t, e) {
2980
+ let n = t.getSetting("toggle-delay");
2981
+ typeof n == "string" && (n.indexOf(",") > -1 && (n = n.split(",")), n.indexOf(" ") > -1 && (n = n.split(" "))), Array.isArray(n) && (n = n[e]);
2982
+ const s = Number(n);
2983
+ if (Number.isNaN(s))
2984
+ throw new Error(`Provided delay value is not a number: "${n}"`);
2985
+ return s;
2986
+ }
2987
+ function $t(t) {
2988
+ let e;
2989
+ const n = typeof t == "string" ? t.trim().split(" ").map((s) => parseFloat(s)).filter((s) => !isNaN(s)) : [t];
2990
+ for (let s = 0; s < n.length; s++)
2991
+ n[s] = Number(n[s]);
2992
+ switch (n.length) {
2993
+ case 1:
2994
+ e = n[0];
2995
+ break;
2996
+ case 2:
2997
+ e = {
2998
+ top: n[0],
2999
+ right: n[1],
3000
+ bottom: n[0],
3001
+ left: n[1]
3002
+ };
3003
+ break;
3004
+ case 3:
3005
+ e = {
3006
+ top: n[0],
3007
+ right: n[1],
3008
+ bottom: n[2],
3009
+ left: n[1]
3010
+ };
3011
+ break;
3012
+ case 4:
3013
+ e = {
3014
+ top: n[0],
3015
+ right: n[1],
3016
+ bottom: n[2],
3017
+ left: n[3]
3018
+ };
3019
+ break;
3020
+ default:
3021
+ e = void 0;
3022
+ break;
3023
+ }
3024
+ return e;
3025
+ }
3026
+ function ei(t) {
3027
+ return {
3028
+ offset: Number(t.getSetting("offset")),
3029
+ flip: {
3030
+ padding: $t(t.getSetting("flip-padding"))
3031
+ },
3032
+ shift: {
3033
+ padding: $t(t.getSetting("shift-padding"))
3034
+ },
3035
+ arrow: {
3036
+ selector: t.getSetting("selectorArrow"),
3037
+ element: null,
3038
+ padding: $t(t.getSetting("arrow-padding"))
3039
+ }
3040
+ };
3041
+ }
3042
+ async function Ie(t) {
3043
+ return t && t.state === "opened" && (t.el.inert = !0, t.el.classList.remove(t.parent.settings.stateActive), t.isTooltip || t.trigger?.setAttribute("aria-expanded", "false"), t.floatingCleanup(), t.state = "closed", t.trigger === t.parent.trigger && (t.parent.trigger = null), t.el.dispatchEvent(
3044
+ new CustomEvent(t.getSetting("customEventPrefix") + "closed", {
3045
+ detail: t.parent,
3046
+ bubbles: !0
3047
+ })
3048
+ ), await t.parent.emit("closed", t)), t;
3049
+ }
3050
+ async function He(t) {
3051
+ const e = [];
3052
+ for (const n of t.collection)
3053
+ n.state === "opened" && e.push(await n.close());
3054
+ return e;
3055
+ }
3056
+ function qe(t) {
3057
+ t.state == "opened" && setTimeout(() => (document.activeElement?.closest(
3058
+ `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
3059
+ ) || t.close(), t), 1);
3060
+ }
3061
+ function ni(t) {
3062
+ t.state === "opened" ? t.close() : (this.trigger = t.trigger, t.open());
3063
+ }
3064
+ function si(t) {
3065
+ t.isTooltip && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.close());
3066
+ }
3067
+ function ii(t, e) {
3068
+ if (t.isHovered = e, e.type == "focus" && t.trigger && !t.trigger.matches(":focus-visible"))
3069
+ return;
3070
+ t.toggleDelayId && clearTimeout(t.toggleDelayId);
3071
+ const n = t.trigger?.getAttribute("aria-expanded");
3072
+ if (n && n == "true") return;
3073
+ const s = this.activeHover ? 0 : Me(t, 0);
3074
+ this.activeHover && this.activeHover.close(), t.toggleDelayId = setTimeout(() => {
3075
+ t.id && t.open();
3076
+ }, s);
3077
+ }
3078
+ function ri(t, e) {
3079
+ setTimeout(() => {
3080
+ t.isHovered = e, !t.isHovered && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.toggleDelayId = setTimeout(
3081
+ () => qe(t),
3082
+ Me(t, 1)
3083
+ ));
3084
+ }, 1);
3085
+ }
3086
+ function oi(t) {
3087
+ switch (t.key) {
3088
+ case "Escape":
3089
+ this.trigger && this.trigger.focus(), He(this);
3090
+ return;
3091
+ case "Tab":
3092
+ this.collection.forEach((e) => {
3093
+ qe(e);
3094
+ });
3095
+ return;
3096
+ default:
3097
+ return;
3098
+ }
3099
+ }
3100
+ function ai(t) {
3101
+ const e = this;
3102
+ document.addEventListener("click", function n(s) {
3103
+ const r = s.target;
3104
+ r && (r.closest(
3105
+ `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
3106
+ ) ? t.el && !t.el.classList.contains(e.settings.stateActive) && this.removeEventListener("click", n) : (t.el && t.el.classList.contains(e.settings.stateActive) && t.close(), this.removeEventListener("click", n)));
3107
+ });
3108
+ }
3109
+ async function je(t) {
3110
+ t.el.inert = !1, t.el.classList.add(t.parent.settings.stateActive), t.isTooltip || t.trigger?.setAttribute("aria-expanded", "true"), t.buildCustomProps();
3111
+ const e = ei(t), n = t.el.querySelector(
3112
+ e.arrow.selector
3113
+ );
3114
+ return e.arrow.element = n || null, t.trigger instanceof HTMLElement && (t.floatingCleanup = Js(t.trigger, t.el, () => {
3115
+ const s = [
3116
+ Xs(e.flip),
3117
+ Ks({ ...e.shift, limiter: Gs() }),
3118
+ Zs(e.offset)
3119
+ ];
3120
+ e.arrow.element && s.push(
3121
+ Ys({
3122
+ ...e.arrow,
3123
+ element: e.arrow.element
3124
+ })
3125
+ ), ti(t.trigger, t.el, {
3126
+ placement: t.getSetting("placement"),
3127
+ middleware: s
3128
+ }).then(({ x: r, y: i, placement: o, middlewareData: a }) => {
3129
+ if (t.el) {
3130
+ if (Zt(t.el, r, i), e.arrow.element && a.arrow) {
3131
+ const { x: l, y: c } = a.arrow;
3132
+ Zt(e.arrow.element, l, c);
2507
3133
  }
2508
- e.el.setAttribute("data-floating-placement", o);
3134
+ t.el.setAttribute("data-floating-placement", o);
2509
3135
  }
2510
3136
  });
2511
- }), e.state = "opened", e.getSetting("event") === "click" && En.call(this, e), e.el.dispatchEvent(
2512
- new CustomEvent(e.getSetting("customEventPrefix") + "opened", {
2513
- detail: this,
3137
+ })), t.state = "opened", t.getSetting("event") === "click" && ai.call(t.parent, t), t.el.dispatchEvent(
3138
+ new CustomEvent(t.getSetting("customEventPrefix") + "opened", {
3139
+ detail: t.parent,
2514
3140
  bubbles: !0
2515
3141
  })
2516
- ), await e.parent.emit("opened", e), e;
3142
+ ), await t.parent.emit("opened", t), t;
3143
+ }
3144
+ class li extends xe {
3145
+ #t;
3146
+ #e;
3147
+ constructor(e, n, s = {}) {
3148
+ super(e, n, s), this.state = "closed", this.toggleDelayId = null, this.trigger = null, this.#t = null, this.#e = {
3149
+ el: !1,
3150
+ trigger: !1
3151
+ }, this.floatingCleanup = () => {
3152
+ };
3153
+ }
3154
+ get isTooltip() {
3155
+ return !!this.el.closest(this.getSetting("selectorTooltip")) || this.el.getAttribute("role") == "tooltip";
3156
+ }
3157
+ get isHovered() {
3158
+ return this.#e.el || this.#e.trigger;
3159
+ }
3160
+ set isHovered(e) {
3161
+ const n = e.type == "mouseenter" ? !0 : e.type == "mouseleave" ? !1 : void 0;
3162
+ if (n != null)
3163
+ switch (e.target) {
3164
+ case this.el:
3165
+ this.#e.el = n;
3166
+ break;
3167
+ case this.trigger:
3168
+ this.#e.trigger = n;
3169
+ break;
3170
+ }
3171
+ }
3172
+ async open() {
3173
+ return je(this);
3174
+ }
3175
+ async close() {
3176
+ return Ie(this);
3177
+ }
3178
+ async deregister() {
3179
+ return this.parent.deregister(this.id);
3180
+ }
3181
+ registerEventListeners() {
3182
+ this.#t || (this.getSetting("event") === "hover" ? (this.#t = [
3183
+ {
3184
+ el: ["el", "trigger"],
3185
+ type: ["mouseenter", "focus"],
3186
+ listener: ii.bind(this.parent, this)
3187
+ },
3188
+ {
3189
+ el: ["el", "trigger"],
3190
+ type: ["mouseleave", "focusout"],
3191
+ listener: ri.bind(this.parent, this)
3192
+ },
3193
+ {
3194
+ el: ["trigger"],
3195
+ type: ["click"],
3196
+ listener: si.bind(this.parent, this)
3197
+ }
3198
+ ], this.#t.forEach((e) => {
3199
+ e.el.forEach((n) => {
3200
+ e.type.forEach((s) => {
3201
+ this[n].addEventListener(s, e.listener, !1);
3202
+ });
3203
+ });
3204
+ })) : (this.#t = [
3205
+ {
3206
+ el: ["trigger"],
3207
+ type: ["click"],
3208
+ listener: ni.bind(this.parent, this)
3209
+ }
3210
+ ], this.#t.forEach((e) => {
3211
+ e.el.forEach((n) => {
3212
+ e.type.forEach((s) => {
3213
+ this[n].addEventListener(s, e.listener, !1);
3214
+ });
3215
+ });
3216
+ })));
3217
+ }
3218
+ deregisterEventListeners() {
3219
+ this.#t && (this.#t.forEach((e) => {
3220
+ e.el.forEach((n) => {
3221
+ e.type.forEach((s) => {
3222
+ this[n].removeEventListener(s, e.listener, !1);
3223
+ });
3224
+ });
3225
+ }), this.#t = null);
3226
+ }
3227
+ async onCreateEntry() {
3228
+ this.trigger = document.querySelector(
3229
+ `[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`
3230
+ ), this.isTooltip ? (this.settings.event = "hover", this.el.setAttribute("role", "tooltip")) : this.trigger && this.trigger instanceof HTMLElement && this.trigger.setAttribute("aria-expanded", "false"), this.registerEventListeners();
3231
+ }
3232
+ async onRegisterEntry() {
3233
+ this.el.classList.contains(this.getSetting("stateActive")) ? await this.open() : this.el.inert = !0;
3234
+ }
3235
+ async onDestroyEntry() {
3236
+ this.state === "opened" && await this.close(), this.floatingCleanup(), this.deregisterEventListeners();
3237
+ }
2517
3238
  }
2518
- var at;
2519
- class hs extends Ot {
2520
- constructor(s = {}) {
2521
- super({ ...mn, ...s });
2522
- U(this, at);
2523
- this.module = "Popover", this.entryClass = Sn, this.trigger = null, S(this, at, vn.bind(this));
3239
+ class Si extends is {
3240
+ #t;
3241
+ constructor(e) {
3242
+ super({ ...rs, ...e }), this.module = "Popover", this.entryClass = li, this.trigger = null, this.#t = oi.bind(this);
2524
3243
  }
2525
3244
  get active() {
2526
3245
  return this.get("opened", "state");
2527
3246
  }
2528
3247
  get activeHover() {
2529
- return this.collection.find((s) => s.state == "opened" && s.getSetting("event") == "hover");
3248
+ return this.collection.find((e) => e.state == "opened" && e.getSetting("event") == "hover");
2530
3249
  }
2531
- async open(s) {
2532
- return as.call(this, s);
3250
+ async open(e) {
3251
+ const n = this.getOrThrow(e);
3252
+ return je(n);
2533
3253
  }
2534
- async close(s) {
2535
- return Se.call(this, s);
3254
+ async close(e) {
3255
+ const n = e ? this.getOrThrow(e) : void 0;
3256
+ return n ? Ie(n) : He(this);
2536
3257
  }
2537
3258
  async afterMount() {
2538
- document.addEventListener("keydown", E(this, at), !1);
3259
+ document.addEventListener("keydown", this.#t, !1);
2539
3260
  }
2540
3261
  async beforeUnmount() {
2541
3262
  this.trigger = null;
2542
3263
  }
2543
3264
  async afterUnmount() {
2544
- document.removeEventListener("keydown", E(this, at), !1);
3265
+ document.removeEventListener("keydown", this.#t, !1);
2545
3266
  }
2546
3267
  }
2547
- at = new WeakMap();
2548
3268
  export {
2549
- us as Drawer,
2550
- ds as Modal,
2551
- hs as Popover,
2552
- fs as core
3269
+ wi as Drawer,
3270
+ xi as Modal,
3271
+ Si as Popover,
3272
+ gi as core
2553
3273
  };
2554
3274
  //# sourceMappingURL=index.js.map