vrembem 4.0.0-next.31 → 4.0.0-next.32

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