vrembem 4.0.0-next.3 → 4.0.0-next.30

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,282 +1,210 @@
1
- var Ke = (t, e, n) => {
2
- if (!e.has(t))
3
- throw TypeError("Cannot " + n);
4
- }, S = (t, e, n) => (Ke(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Rt = (t, e, n) => {
5
- if (e.has(t))
6
- throw TypeError("Cannot add the same private member more than once");
7
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
8
- }, nt = (t, e, n, i) => (Ke(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), q;
9
- let Cn = class {
10
- constructor(e, n) {
11
- Rt(this, q, void 0), this.value = e, nt(this, q, n), this.mql = null;
12
- }
13
- get handler() {
14
- return S(this, q);
15
- }
16
- // Unmount existing handler before setting a new one.
17
- set handler(e) {
18
- this.mql && (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", S(this, q)) : this.mql.removeListener(S(this, q))), nt(this, q, e);
19
- }
20
- mount(e, n) {
21
- return e && (this.value = e), n && nt(this, q, n), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), typeof this.mql.addEventListener == "function" ? this.mql.addEventListener("change", S(this, q)) : this.mql.addListener(S(this, q)), S(this, q).call(this, this.mql), this) : this;
22
- }
23
- unmount() {
24
- return this.mql ? (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", S(this, q)) : this.mql.removeListener(S(this, q)), this.value = null, nt(this, q, null), this.mql = null, this) : this;
25
- }
26
- };
27
- q = /* @__PURE__ */ new WeakMap();
28
- let In = class {
29
- constructor() {
30
- this.collection = [];
31
- }
32
- async register(e) {
33
- return await this.deregister(e), this.collection.push(e), this.collection;
34
- }
35
- async deregister(e) {
36
- const n = this.collection.findIndex((i) => i === e);
37
- if (n >= 0) {
38
- const i = this.collection[n];
39
- Object.getOwnPropertyNames(i).forEach((s) => {
40
- delete i[s];
41
- }), this.collection.splice(n, 1);
42
- }
43
- return this.collection;
44
- }
45
- async registerCollection(e) {
46
- return await Promise.all(Array.from(e, (n) => {
47
- this.register(n);
48
- })), this.collection;
49
- }
50
- async deregisterCollection() {
51
- for (; this.collection.length > 0; )
52
- await this.deregister(this.collection[0]);
53
- return this.collection;
54
- }
55
- get(e, n = "id") {
56
- return this.collection.find((i) => i[n] === e);
57
- }
1
+ var te = (t) => {
2
+ throw TypeError(t);
58
3
  };
59
- const p = {
60
- inert: ":not([inert]):not([inert] *)",
61
- negTabIndex: ':not([tabindex^="-"])',
62
- disabled: ":not(:disabled)"
63
- }, Sn = [
64
- `a[href]${p.inert}${p.negTabIndex}`,
65
- `area[href]${p.inert}${p.negTabIndex}`,
66
- `input:not([type="hidden"]):not([type="radio"])${p.inert}${p.negTabIndex}${p.disabled}`,
67
- `input[type="radio"]${p.inert}${p.negTabIndex}${p.disabled}`,
68
- `select${p.inert}${p.negTabIndex}${p.disabled}`,
69
- `textarea${p.inert}${p.negTabIndex}${p.disabled}`,
70
- `button${p.inert}${p.negTabIndex}${p.disabled}`,
71
- `details${p.inert} > summary:first-of-type${p.negTabIndex}`,
72
- // Discard until Firefox supports `:has()`
73
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
74
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
75
- `iframe${p.inert}${p.negTabIndex}`,
76
- `audio[controls]${p.inert}${p.negTabIndex}`,
77
- `video[controls]${p.inert}${p.negTabIndex}`,
78
- `[contenteditable]${p.inert}${p.negTabIndex}`,
79
- `[tabindex]${p.inert}${p.negTabIndex}`
80
- ];
81
- var wt, at, lt;
82
- let Dn = class {
83
- constructor(e = null, n = "[data-focus]") {
84
- Rt(this, wt, void 0), Rt(this, at, void 0), Rt(this, lt, void 0), this.el = e, this.selectorFocus = n, nt(this, at, Pn.bind(this)), nt(this, lt, qn.bind(this));
85
- }
86
- get focusable() {
87
- return S(this, wt);
88
- }
89
- set focusable(e) {
90
- nt(this, wt, e), S(this, wt).length ? (document.removeEventListener("keydown", S(this, lt)), document.addEventListener("keydown", S(this, at))) : (document.removeEventListener("keydown", S(this, at)), document.addEventListener("keydown", S(this, lt)));
91
- }
92
- get focusableFirst() {
93
- return this.focusable[0];
94
- }
95
- get focusableLast() {
96
- return this.focusable[this.focusable.length - 1];
97
- }
98
- mount(e, n) {
99
- e && (this.el = e), n && (this.selectorFocus = n), this.focusable = this.getFocusable(), this.focus();
100
- }
101
- unmount() {
102
- this.el = null, this.focusable = [], document.removeEventListener("keydown", S(this, at)), document.removeEventListener("keydown", S(this, lt));
103
- }
104
- focus(e = this.el, n = this.selectorFocus) {
105
- (e.querySelector(n) || e).focus();
106
- }
107
- getFocusable(e = this.el) {
108
- const n = [], i = document.activeElement, s = e.scrollTop;
109
- return e.querySelectorAll(Sn.join(",")).forEach((r) => {
110
- r.focus(), document.activeElement === r && n.push(r);
111
- }), e.scrollTop = s, i.focus(), n;
4
+ var ee = (t, e, i) => e.has(t) || te("Cannot " + i);
5
+ var w = (t, e, i) => (ee(t, e, "read from private field"), i ? i.call(t) : e.get(t)), $ = (t, e, i) => e.has(t) ? te("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), E = (t, e, i, s) => (ee(t, e, "write to private field"), s ? s.call(t, i) : e.set(t, i), i);
6
+ function le(t) {
7
+ return t.split("-").map((e, i) => i === 0 ? e : e.charAt(0).toUpperCase() + e.slice(1)).join("");
8
+ }
9
+ function Kt(t) {
10
+ return t.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
11
+ }
12
+ function ae(t) {
13
+ if (typeof t == "number")
14
+ return t;
15
+ const e = parseFloat(t);
16
+ if (!Number.isNaN(e)) {
17
+ const i = t.includes("ms");
18
+ return e * (i ? 1 : 1e3);
19
+ }
20
+ throw new Error(`Could not convert value to milliseconds: ${t}`);
21
+ }
22
+ function Pt() {
23
+ return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
24
+ }
25
+ function ce(t, e) {
26
+ const i = {
27
+ fallback: null,
28
+ element: document.body,
29
+ ...e
30
+ };
31
+ if (t.slice(0, 2) !== "--") {
32
+ const n = Pt();
33
+ n && (t = `${n}${t}`), t = `--${t}`;
112
34
  }
113
- };
114
- wt = /* @__PURE__ */ new WeakMap(), at = /* @__PURE__ */ new WeakMap(), lt = /* @__PURE__ */ new WeakMap();
115
- function Pn(t) {
116
- (t.key === "Tab" || t.keyCode === 9) && (t.shiftKey ? (document.activeElement === this.focusableFirst || document.activeElement === this.el) && (t.preventDefault(), this.focusableLast.focus()) : (document.activeElement === this.focusableLast || document.activeElement === this.el) && (t.preventDefault(), this.focusableFirst.focus()));
117
- }
118
- function qn(t) {
119
- (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
35
+ const s = getComputedStyle(i.element).getPropertyValue(t).trim();
36
+ if (s)
37
+ return s;
38
+ if (i.fallback)
39
+ return i.fallback;
40
+ throw new Error(`CSS variable "${t}" was not found!`);
120
41
  }
121
- function Mn(t, e) {
122
- const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
123
- return n ? JSON.parse(n) : {};
42
+ function fe(t, e = "config") {
43
+ const s = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
44
+ return s ? JSON.parse(s) : {};
124
45
  }
125
- function Wn() {
126
- return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
46
+ function ue(t) {
47
+ const e = getComputedStyle(t.el), i = {}, s = t.getSetting("customProps");
48
+ for (let n = 0; n < s.length; n++) {
49
+ const o = Pt(), r = t.context.module.toLowerCase(), l = Kt(s[n]), a = e.getPropertyValue(`--${o}${r}-${l}`).trim();
50
+ a && (i[l] = a);
51
+ }
52
+ return i;
127
53
  }
128
- function jn(t, e = !0) {
129
- const n = localStorage.getItem(t), i = n ? JSON.parse(n) : {};
130
- return {
131
- get(s) {
132
- return s ? i[s] : i;
133
- },
134
- set(s, r) {
135
- return r ? i[s] = r : delete i[s], e && localStorage.setItem(t, JSON.stringify(i)), i;
136
- }
137
- };
54
+ function de(t) {
55
+ return typeof t == "string" ? document.getElementById(t) : t instanceof HTMLElement ? t : null;
56
+ }
57
+ function Me(t, e, i = "camel") {
58
+ return e = i === "camel" ? le(e) : Kt(e), t.split(".").concat(e).reduce((s, n) => s == null ? void 0 : s[n], this);
59
+ }
60
+ function he(t, e = {}) {
61
+ const {
62
+ fallback: i,
63
+ props: s = ["dataConfig", "customProps", "settings", "context.settings"]
64
+ } = e;
65
+ for (const n of s) {
66
+ const o = n !== "customProps" ? "camel" : "kebab", r = Me.call(this, n, t, o);
67
+ if (r !== void 0)
68
+ return r;
69
+ }
70
+ if (i !== void 0)
71
+ return i;
72
+ throw new Error(`${this.context.module} setting does not exist: ${t}`);
73
+ }
74
+ async function C(t, ...e) {
75
+ t in this && typeof this[t] == "function" && await this[t](...e);
76
+ }
77
+ function St(t, e, i, s, n = 0) {
78
+ return new Promise((o) => {
79
+ t.classList.remove(e), t.classList.add(i), setTimeout(() => {
80
+ t.classList.add(s), t.classList.remove(i), o(t);
81
+ }, ae(n));
82
+ });
138
83
  }
139
- function Nn(t, e, n) {
140
- const i = e.nodeType === Node.COMMENT_NODE, s = e.nodeType === Node.ELEMENT_NODE;
141
- if (e = i || s ? e : document.querySelector(e), i && (n = "after"), !e)
142
- throw new Error(`Not a valid teleport reference: '${e}'`);
143
- if (typeof e[n] != "function")
144
- throw new Error(`Not a valid teleport method: '${n}'`);
145
- let r = null;
146
- return i || (r = document.createComment("teleported #" + t.id), t.before(r)), e[n](t), i && e.remove(), r;
147
- }
148
- const _n = (t, e) => new Promise((n) => {
149
- e.transition ? (t.classList.remove(e.stateClosed), t.classList.add(e.stateOpening), t.addEventListener("transitionend", function i(s) {
150
- s.target == t && (t.classList.add(e.stateOpened), t.classList.remove(e.stateOpening), n(t), this.removeEventListener("transitionend", i));
151
- })) : (t.classList.add(e.stateOpened), t.classList.remove(e.stateClosed), n(t));
152
- }), Fn = (t, e) => new Promise((n) => {
153
- e.transition ? (t.classList.add(e.stateClosing), t.classList.remove(e.stateOpened), t.addEventListener("transitionend", function i(s) {
154
- s.target == t && (t.classList.remove(e.stateClosing), t.classList.add(e.stateClosed), n(t), this.removeEventListener("transitionend", i));
155
- })) : (t.classList.add(e.stateClosed), t.classList.remove(e.stateOpened), n(t));
156
- });
157
- function Bn(t, e) {
158
- e && document.querySelectorAll(e).forEach((n) => {
159
- t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
84
+ function Fe(t, e) {
85
+ e && document.querySelectorAll(e).forEach((s) => {
86
+ t ? s.style.overflow = "hidden" : s.style.removeProperty("overflow");
160
87
  });
161
88
  }
162
- function Rn(t, e) {
163
- e && document.querySelectorAll(e).forEach((n) => {
164
- t ? (n.inert = !0, n.setAttribute("aria-hidden", !0)) : (n.inert = null, n.removeAttribute("aria-hidden"));
89
+ function Ie(t, e) {
90
+ e && document.querySelectorAll(e).forEach((s) => {
91
+ t ? (s.inert = !0, s.setAttribute("aria-hidden", !0)) : (s.inert = null, s.removeAttribute("aria-hidden"));
165
92
  });
166
93
  }
167
- function Hn(t, e) {
168
- Rn(!!t, e.selectorInert), Bn(!!t, e.selectorOverflow);
94
+ function Et(t, e, i) {
95
+ Ie(!!t, e), Fe(!!t, i);
169
96
  }
170
- const Gs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
171
- __proto__: null,
172
- Breakpoint: Cn,
173
- Collection: In,
174
- FocusTrap: Dn,
175
- closeTransition: Fn,
176
- getConfig: Mn,
177
- getPrefix: Wn,
178
- localStore: jn,
179
- openTransition: _n,
180
- teleport: Nn,
181
- updateGlobalState: Hn
182
- }, Symbol.toStringTag, { value: "Module" }));
183
- var Ge = (t, e, n) => {
184
- if (!e.has(t))
185
- throw TypeError("Cannot " + n);
186
- }, _t = (t, e, n) => (Ge(t, e, "read from private field"), n ? n.call(t) : e.get(t)), De = (t, e, n) => {
187
- if (e.has(t))
188
- throw TypeError("Cannot add the same private member more than once");
189
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
190
- }, Pe = (t, e, n, i) => (Ge(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), Qe = (t, e, n) => {
191
- if (!e.has(t))
192
- throw TypeError("Cannot " + n);
193
- }, D = (t, e, n) => (Qe(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Ht = (t, e, n) => {
194
- if (e.has(t))
195
- throw TypeError("Cannot add the same private member more than once");
196
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
197
- }, it = (t, e, n, i) => (Qe(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), M;
198
- let Vn = class {
199
- constructor(e, n) {
200
- Ht(this, M, void 0), this.value = e, it(this, M, n), this.mql = null;
97
+ var P;
98
+ class ge {
99
+ constructor(e, i) {
100
+ $(this, P);
101
+ this.value = e, E(this, P, i), this.mql = null;
201
102
  }
202
103
  get handler() {
203
- return D(this, M);
104
+ return w(this, P);
204
105
  }
205
106
  // Unmount existing handler before setting a new one.
206
107
  set handler(e) {
207
- this.mql && (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", D(this, M)) : this.mql.removeListener(D(this, M))), it(this, M, e);
108
+ this.mql && this.mql.removeEventListener("change", w(this, P)), E(this, P, e);
208
109
  }
209
- mount(e, n) {
210
- return e && (this.value = e), n && it(this, M, n), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), typeof this.mql.addEventListener == "function" ? this.mql.addEventListener("change", D(this, M)) : this.mql.addListener(D(this, M)), D(this, M).call(this, this.mql), this) : this;
110
+ mount(e, i) {
111
+ return e && (this.value = e), i && E(this, P, i), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), this.mql.addEventListener("change", w(this, P)), w(this, P).call(this, this.mql), this) : this;
211
112
  }
212
113
  unmount() {
213
- return this.mql ? (typeof this.mql.removeEventListener == "function" ? this.mql.removeEventListener("change", D(this, M)) : this.mql.removeListener(D(this, M)), this.value = null, it(this, M, null), this.mql = null, this) : this;
214
- }
215
- };
216
- M = /* @__PURE__ */ new WeakMap();
217
- let Jn = class {
218
- constructor() {
219
- this.collection = [];
220
- }
221
- async register(e) {
222
- return await this.deregister(e), this.collection.push(e), this.collection;
223
- }
224
- async deregister(e) {
225
- const n = this.collection.findIndex((i) => i === e);
226
- if (n >= 0) {
227
- const i = this.collection[n];
228
- Object.getOwnPropertyNames(i).forEach((s) => {
229
- delete i[s];
230
- }), this.collection.splice(n, 1);
114
+ return this.mql ? (this.mql.removeEventListener("change", w(this, P)), this.value = null, E(this, P, null), this.mql = null, this) : this;
115
+ }
116
+ }
117
+ P = new WeakMap();
118
+ class Rt {
119
+ constructor(e = {}) {
120
+ this.module = this.constructor.name, this.collection = [], this.settings = Object.assign({
121
+ dataConfig: "config",
122
+ customProps: [],
123
+ teleport: null,
124
+ teleportMethod: "append"
125
+ }, e);
126
+ }
127
+ get(e, i = "id") {
128
+ return this.collection.find((s) => s[i] === e);
129
+ }
130
+ applySettings(e) {
131
+ return Object.assign(this.settings, e);
132
+ }
133
+ async createEntry(e, i) {
134
+ return new Ct(this, e, i);
135
+ }
136
+ async register(e, i = {}) {
137
+ await this.deregister((e == null ? void 0 : e.id) || e, !0);
138
+ const s = await this.createEntry(e, i);
139
+ return await s.mount(), await C.call(this, "beforeRegister", s), await C.call(s, "beforeRegister"), this.collection.push(s), await C.call(s, "afterRegister"), await C.call(this, "afterRegister", s), s;
140
+ }
141
+ async deregister(e, i = !1) {
142
+ const s = this.collection.findIndex((n) => n.id === e);
143
+ if (~s) {
144
+ const n = this.collection[s];
145
+ await n.unmount(i), await C.call(this, "beforeDeregister", n), await C.call(n, "beforeDeregister", i), Object.getOwnPropertyNames(n).forEach((o) => {
146
+ o != "beforeDeregister" && o != "afterDeregister" && delete n[o];
147
+ }), this.collection.splice(s, 1), await C.call(n, "afterDeregister", i), await C.call(this, "afterDeregister", n);
231
148
  }
232
149
  return this.collection;
233
150
  }
234
- async registerCollection(e) {
235
- return await Promise.all(Array.from(e, (n) => {
236
- this.register(n);
237
- })), this.collection;
151
+ async mount(e = {}) {
152
+ this.applySettings(e), await C.call(this, "beforeMount");
153
+ const i = document.querySelectorAll(this.settings.selector);
154
+ for (const s of i)
155
+ await this.register(s);
156
+ return await C.call(this, "afterMount"), this;
238
157
  }
239
- async deregisterCollection() {
240
- for (; this.collection.length > 0; )
241
- await this.deregister(this.collection[0]);
242
- return this.collection;
158
+ async unmount() {
159
+ for (await C.call(this, "beforeUnmount"); this.collection.length > 0; )
160
+ await this.deregister(this.collection[0].id);
161
+ return await C.call(this, "afterUnmount"), this;
162
+ }
163
+ }
164
+ class Ct {
165
+ constructor(e, i, s = {}) {
166
+ this.context = e, this.id = (i == null ? void 0 : i.id) || i, this.el = de(i), this.settings = Object.assign({}, s), this.dataConfig = {}, this.customProps = {}, this.returnRef = null;
243
167
  }
244
- get(e, n = "id") {
245
- return this.collection.find((i) => i[n] === e);
168
+ applySettings(e) {
169
+ return Object.assign(this.settings, e);
246
170
  }
247
- };
248
- const g = {
249
- inert: ":not([inert]):not([inert] *)",
250
- negTabIndex: ':not([tabindex^="-"])',
251
- disabled: ":not(:disabled)"
252
- }, zn = [
253
- `a[href]${g.inert}${g.negTabIndex}`,
254
- `area[href]${g.inert}${g.negTabIndex}`,
255
- `input:not([type="hidden"]):not([type="radio"])${g.inert}${g.negTabIndex}${g.disabled}`,
256
- `input[type="radio"]${g.inert}${g.negTabIndex}${g.disabled}`,
257
- `select${g.inert}${g.negTabIndex}${g.disabled}`,
258
- `textarea${g.inert}${g.negTabIndex}${g.disabled}`,
259
- `button${g.inert}${g.negTabIndex}${g.disabled}`,
260
- `details${g.inert} > summary:first-of-type${g.negTabIndex}`,
261
- // Discard until Firefox supports `:has()`
262
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
263
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
264
- `iframe${g.inert}${g.negTabIndex}`,
265
- `audio[controls]${g.inert}${g.negTabIndex}`,
266
- `video[controls]${g.inert}${g.negTabIndex}`,
267
- `[contenteditable]${g.inert}${g.negTabIndex}`,
268
- `[tabindex]${g.inert}${g.negTabIndex}`
269
- ];
270
- var $t, ct, dt;
271
- let Kn = class {
272
- constructor(e = null, n = "[data-focus]") {
273
- Ht(this, $t, void 0), Ht(this, ct, void 0), Ht(this, dt, void 0), this.el = e, this.selectorFocus = n, it(this, ct, Gn.bind(this)), it(this, dt, Qn.bind(this));
171
+ getDataConfig() {
172
+ return Object.assign(this.dataConfig, fe(this.el, this.getSetting("dataConfig")));
173
+ }
174
+ getCustomProps() {
175
+ return Object.assign(this.customProps, ue(this));
176
+ }
177
+ getSetting(e, i = {}) {
178
+ return he.call(this, e, i);
179
+ }
180
+ async mount(e = {}) {
181
+ if (this.el === null)
182
+ throw new Error(`${this.context.module} element was not found with ID: "${this.id}"`);
183
+ this.applySettings(e), this.getDataConfig(), this.getCustomProps(), await C.call(this, "beforeMount"), this.getSetting("teleport") && this.teleport(), await C.call(this, "afterMount");
184
+ }
185
+ async unmount(e = !1) {
186
+ await C.call(this, "beforeUnmount", e), this.getSetting("teleport") && this.teleportReturn(), await C.call(this, "afterUnmount", e);
187
+ }
188
+ teleport(e = this.getSetting("teleport"), i = this.getSetting("teleportMethod")) {
189
+ return this.returnRef ? (console.error("Element has already been teleported:", this.el), !1) : (this.returnRef = Vt(this.el, e, i), this.el);
190
+ }
191
+ teleportReturn() {
192
+ return this.returnRef ? (this.returnRef = Vt(this.el, this.returnRef), this.el) : (console.error("No return reference found:", this.el), !1);
193
+ }
194
+ }
195
+ var nt, G, J;
196
+ class jt {
197
+ constructor(e = null, i = "[data-focus]") {
198
+ $(this, nt);
199
+ $(this, G);
200
+ $(this, J);
201
+ this.el = e, this.selectorFocus = i, E(this, G, Be.bind(this)), E(this, J, Ve.bind(this));
274
202
  }
275
203
  get focusable() {
276
- return D(this, $t);
204
+ return w(this, nt);
277
205
  }
278
206
  set focusable(e) {
279
- it(this, $t, e), D(this, $t).length ? (document.removeEventListener("keydown", D(this, dt)), document.addEventListener("keydown", D(this, ct))) : (document.removeEventListener("keydown", D(this, ct)), document.addEventListener("keydown", D(this, dt)));
207
+ E(this, nt, e), w(this, nt).length ? (document.removeEventListener("keydown", w(this, J)), document.addEventListener("keydown", w(this, G))) : (document.removeEventListener("keydown", w(this, G)), document.addEventListener("keydown", w(this, J)));
280
208
  }
281
209
  get focusableFirst() {
282
210
  return this.focusable[0];
@@ -284,80 +212,143 @@ let Kn = class {
284
212
  get focusableLast() {
285
213
  return this.focusable[this.focusable.length - 1];
286
214
  }
287
- mount(e, n) {
288
- e && (this.el = e), n && (this.selectorFocus = n), this.focusable = this.getFocusable(), this.focus();
215
+ mount(e, i) {
216
+ e && (this.el = e), i && (this.selectorFocus = i), this.focusable = this.getFocusable(), this.focus();
289
217
  }
290
218
  unmount() {
291
- this.el = null, this.focusable = [], document.removeEventListener("keydown", D(this, ct)), document.removeEventListener("keydown", D(this, dt));
219
+ this.el = null, this.focusable = [], document.removeEventListener("keydown", w(this, G)), document.removeEventListener("keydown", w(this, J));
292
220
  }
293
- focus(e = this.el, n = this.selectorFocus) {
294
- (e.querySelector(n) || e).focus();
221
+ focus(e = this.el, i = this.selectorFocus) {
222
+ (e.querySelector(i) || e).focus();
295
223
  }
296
224
  getFocusable(e = this.el) {
297
- const n = [], i = document.activeElement, s = e.scrollTop;
298
- return e.querySelectorAll(zn.join(",")).forEach((r) => {
299
- r.focus(), document.activeElement === r && n.push(r);
300
- }), e.scrollTop = s, i.focus(), n;
301
- }
302
- };
303
- $t = /* @__PURE__ */ new WeakMap(), ct = /* @__PURE__ */ new WeakMap(), dt = /* @__PURE__ */ new WeakMap();
304
- function Gn(t) {
225
+ const i = [], s = document.activeElement, n = e.scrollTop, o = Ne.join(",");
226
+ return e.querySelectorAll(o).forEach((l) => {
227
+ l.focus(), document.activeElement === l && i.push(l);
228
+ }), e.scrollTop = n, s.focus(), i;
229
+ }
230
+ }
231
+ nt = new WeakMap(), G = new WeakMap(), J = new WeakMap();
232
+ const L = ":not([inert])", O = ':not([tabindex^="-"])', yt = ":not(:disabled)", Ne = [
233
+ `a[href]${L}${O}`,
234
+ `area[href]${L}${O}`,
235
+ `input:not([type="hidden"]):not([type="radio"])${L}${O}${yt}`,
236
+ `input[type="radio"]${L}${O}${yt}`,
237
+ `select${L}${O}${yt}`,
238
+ `textarea${L}${O}${yt}`,
239
+ `button${L}${O}${yt}`,
240
+ `details${L} > summary:first-of-type${O}`,
241
+ `iframe${L}${O}`,
242
+ `audio[controls]${L}${O}`,
243
+ `video[controls]${L}${O}`,
244
+ `[contenteditable]${L}${O}`,
245
+ `[tabindex]${L}${O}`
246
+ ];
247
+ function Be(t) {
305
248
  (t.key === "Tab" || t.keyCode === 9) && (t.shiftKey ? (document.activeElement === this.focusableFirst || document.activeElement === this.el) && (t.preventDefault(), this.focusableLast.focus()) : (document.activeElement === this.focusableLast || document.activeElement === this.el) && (t.preventDefault(), this.focusableFirst.focus()));
306
249
  }
307
- function Qn(t) {
250
+ function Ve(t) {
308
251
  (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
309
252
  }
310
- function Zn(t, e) {
311
- const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
312
- return n ? JSON.parse(n) : {};
313
- }
314
- function Un() {
315
- return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
316
- }
317
- function Xn(t, e = !0) {
318
- const n = localStorage.getItem(t), i = n ? JSON.parse(n) : {};
253
+ function Xt(t, e = !0) {
254
+ const i = localStorage.getItem(t), s = i ? JSON.parse(i) : {};
319
255
  return {
320
- get(s) {
321
- return s ? i[s] : i;
256
+ get(n) {
257
+ return n ? s[n] : s;
322
258
  },
323
- set(s, r) {
324
- return r ? i[s] = r : delete i[s], e && localStorage.setItem(t, JSON.stringify(i)), i;
259
+ set(n, o) {
260
+ return o ? s[n] = o : delete s[n], e && localStorage.setItem(t, JSON.stringify(s)), s;
325
261
  }
326
262
  };
327
263
  }
328
- const Yn = (t, e) => new Promise((n) => {
329
- e.transition ? (t.classList.remove(e.stateClosed), t.classList.add(e.stateOpening), t.addEventListener("transitionend", function i(s) {
330
- s.target == t && (t.classList.add(e.stateOpened), t.classList.remove(e.stateOpening), n(t), this.removeEventListener("transitionend", i));
331
- })) : (t.classList.add(e.stateOpened), t.classList.remove(e.stateClosed), n(t));
332
- }), ti = (t, e) => new Promise((n) => {
333
- e.transition ? (t.classList.add(e.stateClosing), t.classList.remove(e.stateOpened), t.addEventListener("transitionend", function i(s) {
334
- s.target == t && (t.classList.remove(e.stateClosing), t.classList.add(e.stateClosed), n(t), this.removeEventListener("transitionend", i));
335
- })) : (t.classList.add(e.stateClosed), t.classList.remove(e.stateOpened), n(t));
336
- });
337
- function ei(t, e) {
338
- e && document.querySelectorAll(e).forEach((n) => {
339
- t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
340
- });
341
- }
342
- function ni(t, e) {
343
- e && document.querySelectorAll(e).forEach((n) => {
344
- t ? (n.inert = !0, n.setAttribute("aria-hidden", !0)) : (n.inert = null, n.removeAttribute("aria-hidden"));
345
- });
346
- }
347
- function le(t, e) {
348
- ni(!!t, e.selectorInert), ei(!!t, e.selectorOverflow);
264
+ function Vt(t, e, i) {
265
+ const s = e.nodeType === Node.COMMENT_NODE, n = e.nodeType === Node.ELEMENT_NODE;
266
+ if (e = s || n ? e : document.querySelector(e), s && (i = "after"), !e) throw new Error(`Not a valid teleport reference: '${e}'`);
267
+ if (typeof e[i] != "function") throw new Error(`Not a valid teleport method: '${i}'`);
268
+ let o = null;
269
+ return s || (o = document.createComment("teleported #" + t.id), t.before(o)), e[i](t), s && e.remove(), o;
270
+ }
271
+ function He(t) {
272
+ const e = {
273
+ prefix: ce("prefix-themes", { fallback: "vb-theme-" }),
274
+ themes: ["root", "light", "dark"],
275
+ storeKey: "VB:Profile"
276
+ };
277
+ for (const [o] of Object.entries(e))
278
+ t && t[o] && (e[o] = t[o]);
279
+ const i = {
280
+ onInit() {
281
+ },
282
+ onChange() {
283
+ }
284
+ };
285
+ for (const [o] of Object.entries(i))
286
+ t && t[o] && (i[o] = t[o]);
287
+ const s = Xt(e.storeKey), n = {
288
+ // Store our settings in the API.
289
+ settings: e,
290
+ // Actions.
291
+ add(o) {
292
+ e.themes.push(o);
293
+ },
294
+ remove(o) {
295
+ const r = e.themes.indexOf(o);
296
+ ~r && e.themes.splice(r, 1);
297
+ },
298
+ callback(o) {
299
+ i[o].call(this);
300
+ },
301
+ // Getters.
302
+ get class() {
303
+ return `${e.prefix}${this.theme}`;
304
+ },
305
+ get classes() {
306
+ return e.themes.map((o) => `${e.prefix}${o}`);
307
+ },
308
+ get themes() {
309
+ return e.themes;
310
+ },
311
+ // Setup the theme get and set methods.
312
+ get theme() {
313
+ return s.get("theme") || "root";
314
+ },
315
+ set theme(o) {
316
+ e.themes.includes(o) ? this.theme != o && (s.set("theme", o), document.documentElement.classList.remove(...this.classes), document.documentElement.classList.add(`${e.prefix}${o}`), this.callback("onChange")) : console.error(`Not a valid theme value: "${o}"`);
317
+ }
318
+ };
319
+ return n.callback("onInit"), n;
349
320
  }
350
- const ii = {
351
- autoInit: !1,
321
+ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
322
+ __proto__: null,
323
+ Breakpoint: ge,
324
+ Collection: Rt,
325
+ CollectionEntry: Ct,
326
+ FocusTrap: jt,
327
+ cssVar: ce,
328
+ getConfig: fe,
329
+ getCustomProps: ue,
330
+ getElement: de,
331
+ getPrefix: Pt,
332
+ getSetting: he,
333
+ lifecycleHook: C,
334
+ localStore: Xt,
335
+ setGlobalState: Et,
336
+ teleport: Vt,
337
+ themeStore: He,
338
+ toCamel: le,
339
+ toKebab: Kt,
340
+ toMilliseconds: ae,
341
+ transition: St
342
+ }, Symbol.toStringTag, { value: "Module" })), _e = {
352
343
  // Data attributes
353
344
  dataOpen: "drawer-open",
354
345
  dataClose: "drawer-close",
355
346
  dataToggle: "drawer-toggle",
356
347
  dataBreakpoint: "drawer-breakpoint",
357
- dataConfig: "drawer-config",
358
348
  // Selectors
359
- selectorDrawer: ".drawer",
349
+ selector: ".drawer",
360
350
  selectorDialog: ".drawer__dialog",
351
+ selectorScreen: ".drawer",
361
352
  selectorFocus: "[data-focus]",
362
353
  selectorInert: null,
363
354
  selectorOverflow: "body",
@@ -369,373 +360,223 @@ const ii = {
369
360
  // Classes
370
361
  classModal: "drawer_modal",
371
362
  // Feature toggles
363
+ customProps: [
364
+ "transition-duration"
365
+ ],
372
366
  breakpoints: null,
373
367
  customEventPrefix: "drawer:",
374
- eventListeners: !0,
375
368
  store: !0,
376
369
  storeKey: "VB:DrawerState",
377
370
  setTabindex: !0,
378
- transition: !0
371
+ teleport: null,
372
+ teleportMethod: "prepend",
373
+ transition: !0,
374
+ transitionDuration: 300
379
375
  };
380
- function si(t) {
381
- const e = t.target.closest(`
382
- [data-${this.settings.dataOpen}],
383
- [data-${this.settings.dataToggle}],
384
- [data-${this.settings.dataClose}]
385
- `);
386
- if (e) {
387
- t.preventDefault(), e.matches(`[data-${this.settings.dataToggle}]`) && e.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ").forEach((n) => {
388
- const i = this.get(n);
389
- i.trigger = e, i.toggle();
390
- }), e.matches(`[data-${this.settings.dataOpen}]`) && e.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ").forEach((n) => {
391
- const i = this.get(n);
392
- i.trigger = e, i.open();
393
- }), e.matches(`[data-${this.settings.dataClose}]`) && e.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ").forEach((n) => {
394
- if (n) {
395
- const i = this.get(n);
396
- i.trigger = e, i.close();
397
- } else {
398
- const i = t.target.closest(this.settings.selectorDrawer);
399
- i && this.close(i);
400
- }
401
- });
402
- return;
403
- }
404
- t.target.matches(this.settings.selectorDrawer) && this.close(t.target.id);
405
- }
406
- function ri(t) {
407
- if (t.key === "Escape") {
408
- const e = this.activeModal;
409
- e && this.close(e);
410
- }
376
+ function ze(t) {
377
+ t.store === "opened" ? t.open(!1, !1) : t.store === "closed" ? t.close(!1, !1) : t.store === "indeterminate" ? t.state = "indeterminate" : t.el.classList.contains(t.getSetting("stateOpened")) ? t.open(!1, !1) : t.el.classList.contains(t.getSetting("stateClosed")) ? t.close(!1, !1) : t.state = "indeterminate";
411
378
  }
412
- async function ne(t, e = !0) {
413
- if (!t)
414
- return this.collection;
415
- const n = this.collection.findIndex((i) => i.id === t.id);
416
- if (n >= 0) {
417
- const i = this.collection[n];
418
- e && i.state === "opened" && await i.close(!1), this.store.set(i.id), i.unmountBreakpoint(), Object.getOwnPropertyNames(i).forEach((s) => {
419
- delete i[s];
420
- }), this.collection.splice(n, 1);
421
- }
422
- return this.collection;
379
+ async function We(t) {
380
+ t.store === "opened" ? await t.open(!1, !1) : t.store === "closed" ? await t.close(!1, !1) : t.store === "indeterminate" ? t.state != "indeterminate" && (t.state = "indeterminate") : (t.state != t.inlineState && (t.state = t.inlineState), t.inlineState === "opened" ? await t.open(!1, !1) : t.inlineState === "closed" && await t.close(!1, !1));
423
381
  }
424
- function oi(t) {
425
- const e = Un(), n = t.getAttribute(`data-${this.settings.dataBreakpoint}`);
426
- return this.settings.breakpoints && this.settings.breakpoints[n] ? this.settings.breakpoints[n] : getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${n}`).trim() ? getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${n}`).trim() : n;
382
+ function Ue(t) {
383
+ const e = Pt(), i = t.getAttribute(`data-${this.settings.dataBreakpoint}`);
384
+ return this.settings.breakpoints && this.settings.breakpoints[i] ? this.settings.breakpoints[i] : getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${i}`).trim() ? getComputedStyle(document.body).getPropertyValue(`--${e}breakpoint-${i}`).trim() : i;
427
385
  }
428
- function ce(t) {
429
- const e = typeof t == "string" ? this.get(t) : this.get(t.id);
386
+ function it(t) {
387
+ const e = typeof t == "string" ? this.get(t) : t;
430
388
  if (e)
431
389
  return e;
432
390
  throw new Error(`Drawer not found in collection with id of "${t.id || t}".`);
433
391
  }
434
- function Ze(t) {
435
- return typeof t == "string" ? t : typeof t.hasAttribute == "function" ? t.hasAttribute(`data-${this.settings.dataOpen}`) ? t.getAttribute(`data-${this.settings.dataOpen}`) : t.hasAttribute(`data-${this.settings.dataClose}`) ? t.getAttribute(`data-${this.settings.dataClose}`) || !1 : t.hasAttribute(`data-${this.settings.dataToggle}`) ? t.getAttribute(`data-${this.settings.dataToggle}`) : t.closest(this.settings.selectorDrawer) ? (t = t.closest(this.settings.selectorDrawer), t.id || !1) : !1 : t.id ? t.id : !1;
436
- }
437
- function ai(t) {
438
- const e = Ze.call(this, t);
439
- if (e) {
440
- const n = document.querySelector(`#${e}`), i = n ? n.querySelector(this.settings.selectorDialog) : null;
441
- return !n && !i ? { error: new Error(`No drawer elements found using the ID: "${e}".`) } : i ? { drawer: n, dialog: i } : { error: new Error("Drawer is missing dialog element.") };
442
- } else
443
- return { error: new Error("Could not resolve the drawer ID.") };
444
- }
445
- async function Ue(t) {
446
- this.store.get(t.id) ? this.store.get(t.id) === "opened" ? await t.open(!1, !1) : await t.close(!1, !1) : t.el.classList.contains(this.settings.stateOpened) ? t.state = "opened" : (t.el.classList.remove(this.settings.stateOpening), t.el.classList.remove(this.settings.stateClosing), t.el.classList.add(this.settings.stateClosed));
447
- }
448
- function Xe(t) {
392
+ function me(t) {
449
393
  t.state === "opened" ? t.mode === "modal" ? this.focusTrap.mount(t.dialog, this.settings.selectorFocus) : this.focusTrap.focus(t.dialog, this.settings.selectorFocus) : (t.trigger && (t.trigger.focus(), t.trigger = null), this.focusTrap.unmount());
450
394
  }
451
- async function de(t, e, n = !0) {
452
- const i = ce.call(this, t), s = { ...this.settings, ...i.settings };
453
- return e !== void 0 && (s.transition = e), i.state === "closed" && (i.state = "opening", await Yn(i.el, s), i.mode === "modal" && le(!0, s), i.state = "opened"), n && Xe.call(this, i), i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "opened", {
454
- detail: this,
455
- bubbles: !0
456
- })), i;
457
- }
458
- async function Kt(t, e, n = !0) {
459
- const i = ce.call(this, t), s = { ...this.settings, ...i.settings };
460
- return e !== void 0 && (s.transition = e), i.state === "opened" && (i.state = "closing", document.activeElement.blur(), await ti(i.el, s), i.mode === "modal" && le(!1, s), n && Xe.call(this, i), i.state = "closed", i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "closed", {
461
- detail: this,
462
- bubbles: !0
463
- }))), i;
464
- }
465
- async function Ye(t, e, n) {
466
- const i = ce.call(this, t);
467
- return i.state === "closed" ? de.call(this, i, e, n) : Kt.call(this, i, e, n);
468
- }
469
- function li(t) {
395
+ function Ke(t) {
470
396
  switch (t.mode) {
471
397
  case "inline":
472
- return ci.call(this, t);
398
+ return je.call(this, t);
473
399
  case "modal":
474
- return di.call(this, t);
400
+ return Xe.call(this, t);
475
401
  default:
476
402
  throw new Error(`"${t.mode}" is not a valid drawer mode.`);
477
403
  }
478
404
  }
479
- async function ci(t) {
480
- return t.el.classList.remove(t.getSetting("classModal")), t.dialog.removeAttribute("aria-modal"), le(!1, { ...this.settings, ...t.settings }), this.focusTrap.unmount(), await Ue.call(this, t), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
405
+ async function je(t) {
406
+ return t.el.classList.remove(t.getSetting("classModal")), t.dialog.removeAttribute("aria-modal"), Et(!1, t.getSetting("selectorInert"), t.getSetting("selectorOverflow")), this.focusTrap.unmount(), await We(t), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
481
407
  detail: this,
482
408
  bubbles: !0
483
409
  })), t;
484
410
  }
485
- async function di(t) {
486
- return t.el.classList.add(t.getSetting("classModal")), t.dialog.setAttribute("aria-modal", "true"), !this.store.get(t.id) && t.el.classList.contains(t.getSetting("stateOpened")) && this.store.set(t.id, "opened"), await Kt.call(this, t, !1, !1), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
411
+ async function Xe(t) {
412
+ return t.el.classList.add(t.getSetting("classModal")), t.dialog.setAttribute("aria-modal", "true"), await t.close(!1, !1), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
487
413
  detail: this,
488
414
  bubbles: !0
489
415
  })), t;
490
416
  }
491
- async function ui(t, e) {
492
- await ne.call(this, t, !1);
493
- const n = this, i = new Vn(), s = {
494
- open(o, c) {
495
- return de.call(n, this, o, c);
496
- },
497
- close(o, c) {
498
- return Kt.call(n, this, o, c);
499
- },
500
- toggle(o, c) {
501
- return Ye.call(n, this, o, c);
502
- },
503
- deregister() {
504
- return ne.call(n, this);
505
- },
506
- mountBreakpoint() {
507
- const o = this.breakpoint, c = this.handleBreakpoint.bind(this);
508
- return i.mount(o, c), this;
509
- },
510
- unmountBreakpoint() {
511
- return i.unmount(), this;
512
- },
513
- handleBreakpoint(o) {
514
- return this.mode = o.matches ? "inline" : "modal", this;
515
- },
516
- getSetting(o) {
517
- return o in this.settings ? this.settings[o] : n.settings[o];
518
- }
519
- }, r = {
520
- id: t.id,
521
- el: t,
522
- dialog: e,
523
- trigger: null,
524
- settings: Zn(t, this.settings.dataConfig),
525
- get breakpoint() {
526
- return oi.call(n, t);
527
- },
528
- get state() {
529
- return a;
530
- },
531
- set state(o) {
532
- a = o, (o === "opened" || o === "closed") && this.mode === "inline" && n.store.set(this.id, this.state);
533
- },
534
- get mode() {
535
- return l;
536
- },
537
- set mode(o) {
538
- l = o, li.call(n, this);
539
- },
540
- ...s
541
- };
542
- let a = t.classList.contains(r.getSetting("stateOpened")) ? "opened" : "closed", l = t.classList.contains(r.getSetting("classModal")) ? "modal" : "inline";
543
- return r.mode === "modal" ? r.dialog.setAttribute("aria-modal", "true") : r.dialog.removeAttribute("aria-modal"), r.getSetting("setTabindex") && r.dialog.setAttribute("tabindex", "-1"), this.collection.push(r), r.breakpoint ? r.mountBreakpoint() : await Ue.call(this, r), r;
544
- }
545
- var Et, xt;
546
- let Xs = class extends Jn {
547
- constructor(e) {
548
- super(), De(this, Et, void 0), De(this, xt, void 0), this.defaults = ii, this.settings = { ...this.defaults, ...e }, this.focusTrap = new Kn(), this.store = Xn(this.settings.storeKey, this.settings.store), Pe(this, Et, si.bind(this)), Pe(this, xt, ri.bind(this)), this.settings.autoInit && this.init();
417
+ var ot, rt, lt;
418
+ class Ye extends Ct {
419
+ constructor(i, s, n = {}) {
420
+ super(i, s, n);
421
+ $(this, ot);
422
+ $(this, rt);
423
+ $(this, lt);
424
+ this.dialog = null, this.trigger = null, E(this, lt, new ge()), E(this, ot, "indeterminate"), E(this, rt, "indeterminate"), this.inlineState = "indeterminate";
549
425
  }
550
- get activeModal() {
551
- return this.collection.find((e) => e.state === "opened" && e.mode === "modal");
426
+ get breakpoint() {
427
+ return Ue.call(this.context, this.el);
552
428
  }
553
- async init(e = null) {
554
- e && (this.settings = { ...this.settings, ...e });
555
- const n = document.querySelectorAll(this.settings.selectorDrawer);
556
- return await this.registerCollection(n), this.settings.eventListeners && this.initEventListeners(), this;
429
+ get store() {
430
+ return this.context.store.get(this.id);
557
431
  }
558
- async destroy() {
559
- return await this.deregisterCollection(), this.settings.eventListeners && this.destroyEventListeners(), this;
432
+ get mode() {
433
+ return w(this, ot);
560
434
  }
561
- initEventListeners() {
562
- document.addEventListener("click", _t(this, Et), !1), document.addEventListener("keydown", _t(this, xt), !1);
435
+ set mode(i) {
436
+ E(this, ot, i), Ke.call(this.context, this);
563
437
  }
564
- destroyEventListeners() {
565
- document.removeEventListener("click", _t(this, Et), !1), document.removeEventListener("keydown", _t(this, xt), !1);
438
+ get state() {
439
+ return w(this, rt);
566
440
  }
567
- register(e) {
568
- const n = ai.call(this, e);
569
- return n.error ? Promise.reject(n.error) : ui.call(this, n.drawer, n.dialog);
441
+ set state(i) {
442
+ E(this, rt, i), this.mode === "inline" && i != "opening" && i != "closing" && (this.inlineState = i, this.getSetting("store") && this.context.store.set(this.id, i)), i === "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")));
570
443
  }
571
- deregister(e) {
572
- const n = this.get(Ze.call(this, e));
573
- return ne.call(this, n);
444
+ async open(i, s) {
445
+ return this.context.open(this, i, s);
574
446
  }
575
- open(e, n, i) {
576
- return de.call(this, e, n, i);
447
+ async close(i, s) {
448
+ return this.context.close(this, i, s);
577
449
  }
578
- close(e, n, i) {
579
- return Kt.call(this, e, n, i);
450
+ async toggle(i, s) {
451
+ return this.context.toggle(this, i, s);
580
452
  }
581
- toggle(e, n, i) {
582
- return Ye.call(this, e, n, i);
453
+ async deregister() {
454
+ return this.context.deregister(this.id);
583
455
  }
584
- };
585
- Et = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
586
- var tn = (t, e, n) => {
587
- if (!e.has(t))
588
- throw TypeError("Cannot " + n);
589
- }, Ft = (t, e, n) => (tn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), qe = (t, e, n) => {
590
- if (e.has(t))
591
- throw TypeError("Cannot add the same private member more than once");
592
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
593
- }, Me = (t, e, n, i) => (tn(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n), en = (t, e, n) => {
594
- if (!e.has(t))
595
- throw TypeError("Cannot " + n);
596
- }, Q = (t, e, n) => (en(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Yt = (t, e, n) => {
597
- if (e.has(t))
598
- throw TypeError("Cannot add the same private member more than once");
599
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
600
- }, te = (t, e, n, i) => (en(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n);
601
- class hi {
602
- constructor() {
603
- this.collection = [];
604
- }
605
- async register(e) {
606
- return await this.deregister(e), this.collection.push(e), this.collection;
607
- }
608
- async deregister(e) {
609
- const n = this.collection.findIndex((i) => i === e);
610
- if (n >= 0) {
611
- const i = this.collection[n];
612
- Object.getOwnPropertyNames(i).forEach((s) => {
613
- delete i[s];
614
- }), this.collection.splice(n, 1);
615
- }
616
- return this.collection;
456
+ mountBreakpoint() {
457
+ const i = this.breakpoint, s = this.handleBreakpoint.bind(this);
458
+ w(this, lt).mount(i, s);
617
459
  }
618
- async registerCollection(e) {
619
- return await Promise.all(Array.from(e, (n) => {
620
- this.register(n);
621
- })), this.collection;
460
+ unmountBreakpoint() {
461
+ w(this, lt).unmount();
622
462
  }
623
- async deregisterCollection() {
624
- for (; this.collection.length > 0; )
625
- await this.deregister(this.collection[0]);
626
- return this.collection;
463
+ handleBreakpoint(i) {
464
+ const s = i.matches ? "inline" : "modal";
465
+ this.mode != s && (this.mode = s);
627
466
  }
628
- get(e, n = "id") {
629
- return this.collection.find((i) => i[n] === e);
630
- }
631
- }
632
- const m = {
633
- inert: ":not([inert]):not([inert] *)",
634
- negTabIndex: ':not([tabindex^="-"])',
635
- disabled: ":not(:disabled)"
636
- }, fi = [
637
- `a[href]${m.inert}${m.negTabIndex}`,
638
- `area[href]${m.inert}${m.negTabIndex}`,
639
- `input:not([type="hidden"]):not([type="radio"])${m.inert}${m.negTabIndex}${m.disabled}`,
640
- `input[type="radio"]${m.inert}${m.negTabIndex}${m.disabled}`,
641
- `select${m.inert}${m.negTabIndex}${m.disabled}`,
642
- `textarea${m.inert}${m.negTabIndex}${m.disabled}`,
643
- `button${m.inert}${m.negTabIndex}${m.disabled}`,
644
- `details${m.inert} > summary:first-of-type${m.negTabIndex}`,
645
- // Discard until Firefox supports `:has()`
646
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
647
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
648
- `iframe${m.inert}${m.negTabIndex}`,
649
- `audio[controls]${m.inert}${m.negTabIndex}`,
650
- `video[controls]${m.inert}${m.negTabIndex}`,
651
- `[contenteditable]${m.inert}${m.negTabIndex}`,
652
- `[tabindex]${m.inert}${m.negTabIndex}`
653
- ];
654
- var Lt, ut, ht;
655
- let pi = class {
656
- constructor(e = null, n = "[data-focus]") {
657
- Yt(this, Lt, void 0), Yt(this, ut, void 0), Yt(this, ht, void 0), this.el = e, this.selectorFocus = n, te(this, ut, gi.bind(this)), te(this, ht, mi.bind(this));
467
+ async beforeMount() {
468
+ const i = this.el.querySelector(this.getSetting("selectorDialog"));
469
+ this.dialog = i || this.el, this.getSetting("setTabindex") && this.dialog.setAttribute("tabindex", "-1"), ze(this), this.inlineState = this.state, this.mode = this.el.classList.contains(this.getSetting("classModal")) ? "modal" : "inline", this.breakpoint && this.mountBreakpoint();
658
470
  }
659
- get focusable() {
660
- return Q(this, Lt);
471
+ async beforeUnmount(i = !0) {
472
+ i && this.state === "opened" && await this.close(!1), this.context.store.set(this.id), this.unmountBreakpoint();
661
473
  }
662
- set focusable(e) {
663
- te(this, Lt, e), Q(this, Lt).length ? (document.removeEventListener("keydown", Q(this, ht)), document.addEventListener("keydown", Q(this, ut))) : (document.removeEventListener("keydown", Q(this, ut)), document.addEventListener("keydown", Q(this, ht)));
474
+ }
475
+ ot = new WeakMap(), rt = new WeakMap(), lt = new WeakMap();
476
+ async function Ge(t) {
477
+ const e = t.target.closest(`
478
+ [data-${this.settings.dataOpen}],
479
+ [data-${this.settings.dataToggle}],
480
+ [data-${this.settings.dataClose}]
481
+ `);
482
+ if (e) {
483
+ t.preventDefault(), e.matches(`[data-${this.settings.dataToggle}]`) && e.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ").forEach((s) => {
484
+ const n = it.call(this, s);
485
+ return n.trigger = e, n.toggle();
486
+ }), e.matches(`[data-${this.settings.dataOpen}]`) && e.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ").forEach((s) => {
487
+ const n = it.call(this, s);
488
+ return n.trigger = e, n.open();
489
+ }), e.matches(`[data-${this.settings.dataClose}]`) && e.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ").forEach((s) => {
490
+ if (s) {
491
+ const n = it.call(this, s);
492
+ return n.trigger = e, n.close();
493
+ } else {
494
+ const n = t.target.closest(this.settings.selector);
495
+ if (n) return this.close(n.id);
496
+ }
497
+ });
498
+ return;
664
499
  }
665
- get focusableFirst() {
666
- return this.focusable[0];
500
+ if (this.activeModal && t.target.matches(this.settings.selectorScreen))
501
+ return this.close(this.activeModal.id);
502
+ }
503
+ function Je(t) {
504
+ if (t.key === "Escape" && this.activeModal)
505
+ return this.close(this.activeModal.id);
506
+ }
507
+ async function pe(t, e, i = !0) {
508
+ const s = it.call(this, t);
509
+ return (s.state === "closed" || s.state === "indeterminate") && (s.state = "opening", e ?? s.getSetting("transition") ? await St(
510
+ s.el,
511
+ s.getSetting("stateClosed"),
512
+ s.getSetting("stateOpening"),
513
+ s.getSetting("stateOpened"),
514
+ s.getSetting("transitionDuration")
515
+ ) : (s.el.classList.add(s.getSetting("stateOpened")), s.el.classList.remove(s.getSetting("stateClosed"))), s.state = "opened", s.mode === "modal" && Et(!0, s.getSetting("selectorInert"), s.getSetting("selectorOverflow")), i && me.call(this, s), s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix") + "opened", {
516
+ detail: this,
517
+ bubbles: !0
518
+ }))), s;
519
+ }
520
+ async function we(t, e, i = !0) {
521
+ const s = it.call(this, t);
522
+ return (s.state === "opened" || s.state === "indeterminate") && (s.state = "closing", document.activeElement.blur(), e ?? s.getSetting("transition") ? await St(
523
+ s.el,
524
+ s.getSetting("stateOpened"),
525
+ s.getSetting("stateClosing"),
526
+ s.getSetting("stateClosed"),
527
+ s.getSetting("transitionDuration")
528
+ ) : (s.el.classList.add(s.getSetting("stateClosed")), s.el.classList.remove(s.getSetting("stateOpened"))), s.state = "closed", s.mode === "modal" && Et(!1, s.getSetting("selectorInert"), s.getSetting("selectorOverflow")), i && me.call(this, s), s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix") + "closed", {
529
+ detail: this,
530
+ bubbles: !0
531
+ }))), s;
532
+ }
533
+ async function Ze(t, e, i) {
534
+ const s = it.call(this, t);
535
+ return s.state === "closed" ? pe.call(this, s, e, i) : we.call(this, s, e, i);
536
+ }
537
+ var at, ct;
538
+ class ts extends Rt {
539
+ constructor(i) {
540
+ super({ ..._e, ...i });
541
+ $(this, at);
542
+ $(this, ct);
543
+ this.focusTrap = new jt(), E(this, at, Ge.bind(this)), E(this, ct, Je.bind(this)), this.store = Xt(this.settings.storeKey, this.settings.store);
667
544
  }
668
- get focusableLast() {
669
- return this.focusable[this.focusable.length - 1];
545
+ get activeModal() {
546
+ return this.collection.find((i) => i.state === "opened" && i.mode === "modal");
670
547
  }
671
- mount(e, n) {
672
- e && (this.el = e), n && (this.selectorFocus = n), this.focusable = this.getFocusable(), this.focus();
548
+ async createEntry(i, s) {
549
+ return new Ye(this, i, s);
673
550
  }
674
- unmount() {
675
- this.el = null, this.focusable = [], document.removeEventListener("keydown", Q(this, ut)), document.removeEventListener("keydown", Q(this, ht));
551
+ async open(i, s, n) {
552
+ return pe.call(this, i, s, n);
676
553
  }
677
- focus(e = this.el, n = this.selectorFocus) {
678
- (e.querySelector(n) || e).focus();
554
+ async close(i, s, n) {
555
+ return we.call(this, i, s, n);
679
556
  }
680
- getFocusable(e = this.el) {
681
- const n = [], i = document.activeElement, s = e.scrollTop;
682
- return e.querySelectorAll(fi.join(",")).forEach((r) => {
683
- r.focus(), document.activeElement === r && n.push(r);
684
- }), e.scrollTop = s, i.focus(), n;
557
+ async toggle(i, s, n) {
558
+ return Ze.call(this, i, s, n);
559
+ }
560
+ async afterMount() {
561
+ document.addEventListener("click", w(this, at), !1), document.addEventListener("keydown", w(this, ct), !1);
562
+ }
563
+ async beforeUnmount() {
564
+ this.trigger = null;
565
+ }
566
+ async afterUnmount() {
567
+ document.removeEventListener("click", w(this, at), !1), document.removeEventListener("keydown", w(this, ct), !1);
685
568
  }
686
- };
687
- Lt = /* @__PURE__ */ new WeakMap(), ut = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap();
688
- function gi(t) {
689
- (t.key === "Tab" || t.keyCode === 9) && (t.shiftKey ? (document.activeElement === this.focusableFirst || document.activeElement === this.el) && (t.preventDefault(), this.focusableLast.focus()) : (document.activeElement === this.focusableLast || document.activeElement === this.el) && (t.preventDefault(), this.focusableFirst.focus()));
690
- }
691
- function mi(t) {
692
- (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
693
- }
694
- function vi(t, e) {
695
- const n = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
696
- return n ? JSON.parse(n) : {};
697
- }
698
- function We(t, e, n) {
699
- const i = e.nodeType === Node.COMMENT_NODE, s = e.nodeType === Node.ELEMENT_NODE;
700
- if (e = i || s ? e : document.querySelector(e), i && (n = "after"), !e)
701
- throw new Error(`Not a valid teleport reference: '${e}'`);
702
- if (typeof e[n] != "function")
703
- throw new Error(`Not a valid teleport method: '${n}'`);
704
- let r = null;
705
- return i || (r = document.createComment("teleported #" + t.id), t.before(r)), e[n](t), i && e.remove(), r;
706
- }
707
- const bi = (t, e) => new Promise((n) => {
708
- e.transition ? (t.classList.remove(e.stateClosed), t.classList.add(e.stateOpening), t.addEventListener("transitionend", function i(s) {
709
- s.target == t && (t.classList.add(e.stateOpened), t.classList.remove(e.stateOpening), n(t), this.removeEventListener("transitionend", i));
710
- })) : (t.classList.add(e.stateOpened), t.classList.remove(e.stateClosed), n(t));
711
- }), yi = (t, e) => new Promise((n) => {
712
- e.transition ? (t.classList.add(e.stateClosing), t.classList.remove(e.stateOpened), t.addEventListener("transitionend", function i(s) {
713
- s.target == t && (t.classList.remove(e.stateClosing), t.classList.add(e.stateClosed), n(t), this.removeEventListener("transitionend", i));
714
- })) : (t.classList.add(e.stateClosed), t.classList.remove(e.stateOpened), n(t));
715
- });
716
- function wi(t, e) {
717
- e && document.querySelectorAll(e).forEach((n) => {
718
- t ? n.style.overflow = "hidden" : n.style.removeProperty("overflow");
719
- });
720
- }
721
- function $i(t, e) {
722
- e && document.querySelectorAll(e).forEach((n) => {
723
- t ? (n.inert = !0, n.setAttribute("aria-hidden", !0)) : (n.inert = null, n.removeAttribute("aria-hidden"));
724
- });
725
- }
726
- function Ei(t, e) {
727
- $i(!!t, e.selectorInert), wi(!!t, e.selectorOverflow);
728
569
  }
729
- const xi = {
730
- autoInit: !1,
570
+ at = new WeakMap(), ct = new WeakMap();
571
+ const Qe = {
731
572
  // Data attributes
732
573
  dataOpen: "modal-open",
733
574
  dataClose: "modal-close",
734
575
  dataReplace: "modal-replace",
735
- dataConfig: "modal-config",
736
576
  // Selectors
737
- selectorModal: ".modal",
577
+ selector: ".modal",
738
578
  selectorDialog: ".modal__dialog",
579
+ selectorScreen: ".modal",
739
580
  selectorRequired: '[role="alertdialog"]',
740
581
  selectorFocus: "[data-focus]",
741
582
  selectorInert: null,
@@ -746,311 +587,265 @@ const xi = {
746
587
  stateClosing: "is-closing",
747
588
  stateClosed: "is-closed",
748
589
  // Feature settings
590
+ customProps: [
591
+ "transition-duration"
592
+ ],
749
593
  customEventPrefix: "modal:",
750
- eventListeners: !0,
594
+ setTabindex: !0,
751
595
  teleport: null,
752
596
  teleportMethod: "append",
753
- setTabindex: !0,
754
- transition: !0
597
+ transition: !0,
598
+ transitionDuration: 300
755
599
  };
756
- function ue(t) {
600
+ class qe extends Ct {
601
+ constructor(e, i, s = {}) {
602
+ super(e, i, s), this.state = "closed", this.dialog = null;
603
+ }
604
+ get isRequired() {
605
+ return this.dialog.matches(this.getSetting("selectorRequired"));
606
+ }
607
+ async open(e, i) {
608
+ return this.context.open(this, e, i);
609
+ }
610
+ async close(e, i) {
611
+ return this.context.close(this, e, i);
612
+ }
613
+ async replace(e, i) {
614
+ return this.context.replace(this, e, i);
615
+ }
616
+ async deregister() {
617
+ return this.context.deregister(this.id);
618
+ }
619
+ async beforeMount() {
620
+ const e = this.el.querySelector(this.getSetting("selectorDialog"));
621
+ 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");
622
+ }
623
+ async afterRegister() {
624
+ 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")));
625
+ }
626
+ async beforeUnmount(e = !1) {
627
+ !e && this.state === "opened" ? await this.close(!1) : this.context.stack.remove(this);
628
+ }
629
+ }
630
+ function xt(t) {
757
631
  const e = typeof t == "string" ? this.get(t) : this.get(t.id);
758
632
  if (e)
759
633
  return e;
760
634
  throw new Error(`Modal not found in collection with id of "${t.id || t}".`);
761
635
  }
762
- function Jt(t) {
763
- return typeof t == "string" ? t : typeof t.hasAttribute == "function" ? t.hasAttribute(`data-${this.settings.dataOpen}`) ? t.getAttribute(`data-${this.settings.dataOpen}`) : t.hasAttribute(`data-${this.settings.dataClose}`) ? t.getAttribute(`data-${this.settings.dataClose}`) || !1 : t.hasAttribute(`data-${this.settings.dataReplace}`) ? t.getAttribute(`data-${this.settings.dataReplace}`) : t.closest(this.settings.selectorModal) ? (t = t.closest(this.settings.selectorModal), t.id || !1) : !1 : t.id ? t.id : !1;
764
- }
765
- function Li(t) {
766
- const e = Jt.call(this, t);
767
- if (e) {
768
- const n = document.querySelector(`#${e}`), i = n ? n.querySelector(this.settings.selectorDialog) : null;
769
- return !n && !i ? { error: new Error(`No modal elements found using the ID: "${e}".`) } : i ? { modal: n, dialog: i } : { error: new Error("Modal is missing dialog element.") };
770
- } else
771
- return { error: new Error("Could not resolve the modal ID.") };
772
- }
773
- function Gt() {
636
+ function Dt() {
774
637
  this.active ? this.focusTrap.mount(this.active.dialog, this.settings.selectorFocus) : (this.trigger && (this.trigger.focus(), this.trigger = null), this.focusTrap.unmount());
775
638
  }
776
- async function Oi(t) {
777
- let e = t.target.closest(
778
- `[data-${this.settings.dataOpen}], [data-${this.settings.dataReplace}]`
779
- );
639
+ async function ti(t) {
640
+ const e = t.target.closest(`
641
+ [data-${this.settings.dataOpen}],
642
+ [data-${this.settings.dataReplace}],
643
+ [data-${this.settings.dataClose}]
644
+ `);
780
645
  if (e) {
781
- t.preventDefault(), t.target.closest(this.settings.selectorModal) || (this.trigger = e);
782
- const n = this.get(Jt.call(this, e));
783
- return e.matches(`[data-${this.settings.dataOpen}]`) ? n.open() : n.replace();
784
- }
785
- if (e = t.target.closest(`[data-${this.settings.dataClose}]`), e) {
786
- t.preventDefault();
787
- const n = e.getAttribute(`data-${this.settings.dataClose}`);
788
- return n === "*" ? this.closeAll() : this.close(n);
646
+ if (t.preventDefault(), e.matches(`[data-${this.settings.dataOpen}]`)) {
647
+ const i = e.getAttribute(`data-${this.settings.dataOpen}`).trim(), s = xt.call(this, i);
648
+ return t.target.closest(this.settings.selector) || (this.trigger = e), s.open();
649
+ }
650
+ if (e.matches(`[data-${this.settings.dataReplace}]`)) {
651
+ const i = e.getAttribute(`data-${this.settings.dataReplace}`).trim(), s = xt.call(this, i);
652
+ return t.target.closest(this.settings.selector) || (this.trigger = e), s.replace();
653
+ }
654
+ if (e.matches(`[data-${this.settings.dataClose}]`)) {
655
+ const i = e.getAttribute(`data-${this.settings.dataClose}`).trim();
656
+ return i === "*" ? this.closeAll() : this.close(i);
657
+ }
789
658
  }
790
- if (t.target.matches(this.settings.selectorModal) && !t.target.querySelector(this.settings.selectorRequired))
791
- return this.close(Jt.call(this, t.target));
659
+ if (this.active && t.target.matches(this.settings.selectorScreen) && !this.active.isRequired)
660
+ return this.close(this.active.id);
792
661
  }
793
- function ki(t) {
662
+ function ei(t) {
794
663
  if (t.key === "Escape" && this.active && !this.active.dialog.matches(this.settings.selectorRequired))
795
664
  return this.close();
796
665
  }
797
- async function ie(t, e = !0) {
798
- if (!t)
799
- return this.collection;
800
- const n = this.collection.findIndex((i) => i.id === t.id);
801
- if (n >= 0) {
802
- const i = this.collection[n];
803
- e && i.state === "opened" ? await i.close(!1) : this.stack.remove(i), i.getSetting("teleport") && i.teleportReturn(), Object.getOwnPropertyNames(i).forEach((s) => {
804
- delete i[s];
805
- }), this.collection.splice(n, 1);
806
- }
807
- return this.collection;
808
- }
809
- async function he(t, e, n = !0) {
810
- const i = ue.call(this, t), s = { ...this.settings, ...i.settings };
811
- return e !== void 0 && (s.transition = e), this.stack.moveToTop(i), i.state === "closed" && (i.state = "opening", this.stack.add(i), await bi(i.el, s), i.state = "opened"), n && Gt.call(this), i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "opened", {
666
+ async function be(t, e = void 0, i = !0) {
667
+ const s = xt.call(this, t);
668
+ return this.stack.moveToTop(s), s.state === "closed" && (s.state = "opening", this.stack.add(s), e ?? s.getSetting("transition") ? await St(
669
+ s.el,
670
+ s.getSetting("stateClosed"),
671
+ s.getSetting("stateOpening"),
672
+ s.getSetting("stateOpened"),
673
+ s.getSetting("transitionDuration")
674
+ ) : (s.el.classList.add(s.getSetting("stateOpened")), s.el.classList.remove(s.getSetting("stateClosed"))), s.state = "opened"), i && Dt.call(this), s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix") + "opened", {
812
675
  detail: this,
813
676
  bubbles: !0
814
- })), i;
677
+ })), s;
678
+ }
679
+ async function ye(t, e, i = !0) {
680
+ const s = t ? xt.call(this, t) : this.active;
681
+ return s && s.state === "opened" && (s.state = "closing", document.activeElement.blur(), e ?? s.getSetting("transition") ? await St(
682
+ s.el,
683
+ s.getSetting("stateOpened"),
684
+ s.getSetting("stateClosing"),
685
+ s.getSetting("stateClosed"),
686
+ s.getSetting("transitionDuration")
687
+ ) : (s.el.classList.add(s.getSetting("stateClosed")), s.el.classList.remove(s.getSetting("stateOpened"))), this.stack.remove(s), s.state = "closed", i && Dt.call(this), s.el.dispatchEvent(new CustomEvent(s.getSetting("customEventPrefix") + "closed", {
688
+ detail: this,
689
+ bubbles: !0
690
+ }))), s;
815
691
  }
816
- async function fe(t, e, n = !0) {
817
- const i = t ? ue.call(this, t) : this.active;
818
- if (i && i.state === "opened") {
819
- i.state = "closing";
820
- const s = { ...this.settings, ...i.settings };
821
- e !== void 0 && (s.transition = e), document.activeElement.blur(), await yi(i.el, s), this.stack.remove(i), n && Gt.call(this), i.state = "closed", i.el.dispatchEvent(new CustomEvent(s.customEventPrefix + "closed", {
822
- detail: this,
823
- bubbles: !0
824
- }));
825
- }
826
- return i;
692
+ async function Ht(t, e) {
693
+ const i = [];
694
+ return await Promise.all(this.stack.value.map(async (s) => {
695
+ t && t === s.id ? Promise.resolve() : i.push(await ye.call(this, s, e, !1)), s.trigger = null;
696
+ })), i;
827
697
  }
828
- async function se(t, e) {
829
- const n = [];
830
- return await Promise.all(this.stack.value.map(async (i) => {
831
- t && t === i.id ? Promise.resolve() : n.push(await fe.call(this, i, e, !1)), i.trigger = null;
832
- })), n;
833
- }
834
- async function nn(t, e, n = !0) {
835
- const i = ue.call(this, t);
836
- let s, r;
837
- return i.state === "opened" ? (s = i, r = await se.call(this, i.id, e)) : (s = he.call(this, i, e, !1), r = se.call(this, !1, e), await Promise.all([s, r])), n && Gt.call(this), { opened: s, closed: r };
838
- }
839
- async function Ti(t, e) {
840
- await ie.call(this, t, !1);
841
- const n = this, i = {
842
- open(r, a) {
843
- return he.call(n, this, r, a);
844
- },
845
- close(r, a) {
846
- return fe.call(n, this, r, a);
847
- },
848
- replace(r, a) {
849
- return nn.call(n, this, r, a);
850
- },
851
- deregister() {
852
- return ie.call(n, this);
853
- },
854
- teleport(r = this.getSetting("teleport"), a = this.getSetting("teleportMethod")) {
855
- return this.returnRef ? (console.error("Element has already been teleported:", this.el), !1) : (this.returnRef = We(this.el, r, a), this.el);
856
- },
857
- teleportReturn() {
858
- return this.returnRef ? (this.returnRef = We(this.el, this.returnRef), this.el) : (console.error("No return reference found:", this.el), !1);
859
- },
860
- getSetting(r) {
861
- return r in this.settings ? this.settings[r] : n.settings[r];
862
- }
863
- }, s = {
864
- id: t.id,
865
- state: "closed",
866
- el: t,
867
- dialog: e,
868
- returnRef: null,
869
- settings: vi(t, this.settings.dataConfig),
870
- ...i
871
- };
872
- return s.dialog.setAttribute("aria-modal", "true"), s.dialog.hasAttribute("role") || s.dialog.setAttribute("role", "dialog"), s.getSetting("setTabindex") && s.dialog.setAttribute("tabindex", "-1"), s.getSetting("teleport") && s.teleport(), this.collection.push(s), s.el.classList.contains(this.settings.stateOpened) ? await s.open(!1) : (s.el.classList.remove(this.settings.stateOpening), s.el.classList.remove(this.settings.stateClosing), s.el.classList.add(this.settings.stateClosed)), s;
698
+ async function ii(t, e, i = !0) {
699
+ const s = xt.call(this, t);
700
+ let n, o;
701
+ return s.state === "opened" ? (n = s, o = await Ht.call(this, s.id, e)) : (o = Ht.call(this, !1, e), n = be.call(this, s, e, !1), await Promise.all([n, o])), i && Dt.call(this), { opened: n, closed: o };
873
702
  }
874
- function Ai(t) {
703
+ function si(t) {
875
704
  const e = [];
876
705
  return {
877
706
  get value() {
878
707
  return [...e];
879
708
  },
880
709
  get top() {
881
- return e[e.length - 1];
710
+ const i = e[e.length - 1];
711
+ return i || null;
882
712
  },
883
713
  updateIndex() {
884
- e.forEach((n, i) => {
885
- n.el.style.zIndex = null;
886
- const s = getComputedStyle(n.el)["z-index"];
887
- n.el.style.zIndex = parseInt(s) + i + 1;
714
+ e.forEach((i, s) => {
715
+ i.el.style.zIndex = null;
716
+ const n = getComputedStyle(i.el)["z-index"];
717
+ i.el.style.zIndex = parseInt(n) + s + 1;
888
718
  });
889
719
  },
890
- updateGlobalState() {
891
- Ei(this.top, t), this.updateIndex();
720
+ setGlobalState() {
721
+ Et(this.top, t.selectorInert, t.selectorOverflow), this.updateIndex();
892
722
  },
893
- add(n) {
894
- n.el.style.zIndex = null;
895
- const i = getComputedStyle(n.el)["z-index"];
896
- n.el.style.zIndex = parseInt(i) + e.length + 1, e.push(n), this.updateGlobalState();
723
+ add(i) {
724
+ i.el.style.zIndex = null;
725
+ const s = getComputedStyle(i.el)["z-index"];
726
+ i.el.style.zIndex = parseInt(s) + e.length + 1, e.push(i), this.setGlobalState();
897
727
  },
898
- remove(n) {
899
- const i = e.findIndex((s) => s.id === n.id);
900
- i >= 0 && (n.el.style.zIndex = null, e.splice(i, 1), this.updateGlobalState());
728
+ remove(i) {
729
+ const s = e.findIndex((n) => n.id === i.id);
730
+ s >= 0 && (i.el.style.zIndex = null, e.splice(s, 1), this.setGlobalState());
901
731
  },
902
- moveToTop(n) {
903
- const i = e.findIndex((s) => s.id === n.id);
904
- i >= 0 && (e.splice(i, 1), this.add(n));
732
+ moveToTop(i) {
733
+ const s = e.findIndex((n) => n.id === i.id);
734
+ s >= 0 && (e.splice(s, 1), this.add(i));
905
735
  }
906
736
  };
907
737
  }
908
- var Ot, kt;
909
- class er extends hi {
910
- constructor(e) {
911
- super(), qe(this, Ot, void 0), qe(this, kt, void 0), this.defaults = xi, this.settings = { ...this.defaults, ...e }, this.trigger = null, this.focusTrap = new pi(), this.stack = Ai(this.settings), Me(this, Ot, Oi.bind(this)), Me(this, kt, ki.bind(this)), this.settings.autoInit && this.init();
738
+ var ft, ut;
739
+ class es extends Rt {
740
+ constructor(i) {
741
+ super({ ...Qe, ...i });
742
+ $(this, ft);
743
+ $(this, ut);
744
+ this.trigger = null, this.focusTrap = new jt(), E(this, ft, ti.bind(this)), E(this, ut, ei.bind(this)), this.stack = si(this.settings);
912
745
  }
913
746
  get active() {
914
747
  return this.stack.top;
915
748
  }
916
- async init(e) {
917
- e && (this.settings = { ...this.settings, ...e });
918
- const n = document.querySelectorAll(this.settings.selectorModal);
919
- return await this.registerCollection(n), this.settings.eventListeners && this.initEventListeners(), this;
920
- }
921
- async destroy() {
922
- return this.trigger = null, await this.deregisterCollection(), this.settings.eventListeners && this.destroyEventListeners(), this;
923
- }
924
- initEventListeners() {
925
- document.addEventListener("click", Ft(this, Ot), !1), document.addEventListener("keydown", Ft(this, kt), !1);
926
- }
927
- destroyEventListeners() {
928
- document.removeEventListener("click", Ft(this, Ot), !1), document.removeEventListener("keydown", Ft(this, kt), !1);
929
- }
930
- register(e) {
931
- const n = Li.call(this, e);
932
- return n.error ? Promise.reject(n.error) : Ti.call(this, n.modal, n.dialog);
933
- }
934
- deregister(e) {
935
- const n = this.get(Jt.call(this, e));
936
- return ie.call(this, n);
937
- }
938
- open(e, n, i) {
939
- return he.call(this, e, n, i);
940
- }
941
- close(e, n, i) {
942
- return fe.call(this, e, n, i);
943
- }
944
- replace(e, n, i) {
945
- return nn.call(this, e, n, i);
946
- }
947
- async closeAll(e = !1, n, i = !0) {
948
- const s = await se.call(this, e, n);
949
- return i && Gt.call(this), s;
950
- }
951
- }
952
- Ot = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap();
953
- var sn = (t, e, n) => {
954
- if (!e.has(t))
955
- throw TypeError("Cannot " + n);
956
- }, je = (t, e, n) => (sn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), Ci = (t, e, n) => {
957
- if (e.has(t))
958
- throw TypeError("Cannot add the same private member more than once");
959
- e instanceof WeakSet ? e.add(t) : e.set(t, n);
960
- }, Ii = (t, e, n, i) => (sn(t, e, "write to private field"), i ? i.call(t, n) : e.set(t, n), n);
961
- class Si {
962
- constructor() {
963
- this.collection = [];
964
- }
965
- async register(e) {
966
- return await this.deregister(e), this.collection.push(e), this.collection;
967
- }
968
- async deregister(e) {
969
- const n = this.collection.findIndex((i) => i === e);
970
- if (n >= 0) {
971
- const i = this.collection[n];
972
- Object.getOwnPropertyNames(i).forEach((s) => {
973
- delete i[s];
974
- }), this.collection.splice(n, 1);
975
- }
976
- return this.collection;
749
+ async createEntry(i, s) {
750
+ return new qe(this, i, s);
977
751
  }
978
- async registerCollection(e) {
979
- return await Promise.all(Array.from(e, (n) => {
980
- this.register(n);
981
- })), this.collection;
752
+ async open(i, s, n) {
753
+ return be.call(this, i, s, n);
982
754
  }
983
- async deregisterCollection() {
984
- for (; this.collection.length > 0; )
985
- await this.deregister(this.collection[0]);
986
- return this.collection;
755
+ async close(i, s, n) {
756
+ return ye.call(this, i, s, n);
987
757
  }
988
- get(e, n = "id") {
989
- return this.collection.find((i) => i[n] === e);
758
+ async replace(i, s, n) {
759
+ return ii.call(this, i, s, n);
760
+ }
761
+ async closeAll(i = !1, s, n = !0) {
762
+ const o = await Ht.call(this, i, s);
763
+ return n && Dt.call(this), o;
764
+ }
765
+ async afterMount() {
766
+ document.addEventListener("click", w(this, ft), !1), document.addEventListener("keydown", w(this, ut), !1);
767
+ }
768
+ async beforeUnmount() {
769
+ this.trigger = null;
770
+ }
771
+ async afterUnmount() {
772
+ document.removeEventListener("click", w(this, ft), !1), document.removeEventListener("keydown", w(this, ut), !1);
990
773
  }
991
774
  }
992
- function Di() {
993
- return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
994
- }
995
- const Pi = {
996
- autoInit: !1,
775
+ ft = new WeakMap(), ut = new WeakMap();
776
+ const ni = {
997
777
  // Selectors
998
- selectorPopover: ".popover",
778
+ selector: ".popover",
779
+ selectorTooltip: ".popover_tooltip",
999
780
  selectorArrow: ".popover__arrow",
1000
781
  // State classes
1001
782
  stateActive: "is-active",
783
+ // Custom properties and their defaults
784
+ customProps: [
785
+ "placement",
786
+ "event",
787
+ "offset",
788
+ "flip-padding",
789
+ "shift-padding",
790
+ "arrow-padding",
791
+ "toggle-delay"
792
+ ],
793
+ placement: "bottom",
794
+ event: "click",
795
+ offset: 0,
796
+ flipPadding: 0,
797
+ shiftPadding: 0,
798
+ arrowPadding: 0,
799
+ toggleDelay: 0,
1002
800
  // Feature settings
1003
- eventListeners: !0,
1004
- eventType: "click",
1005
- placement: "bottom"
801
+ teleport: null,
802
+ teleportMethod: "append"
1006
803
  };
1007
- function rn(t, e) {
1008
- const n = getComputedStyle(t), i = {
1009
- placement: e.placement,
1010
- event: e.eventType,
1011
- offset: 0,
1012
- "overflow-padding": 0,
1013
- "flip-padding": 0,
1014
- "arrow-element": e.selectorArrow,
1015
- "arrow-padding": 0
1016
- };
1017
- for (const s in i) {
1018
- const r = Di(), a = n.getPropertyValue(`--${r}popover-${s}`).trim();
1019
- a && (i[s] = a);
1020
- }
1021
- return i;
804
+ function ie(t, e, i) {
805
+ Object.assign(t.style, {
806
+ left: e != null ? `${e}px` : "",
807
+ top: i != null ? `${i}px` : ""
808
+ });
1022
809
  }
1023
- function ee(t) {
810
+ function xe(t, e) {
811
+ let i = t.getSetting("toggle-delay");
812
+ typeof i == "string" && (i.indexOf(",") > -1 && (i = i.split(",")), i.indexOf(" ") > -1 && (i = i.split(" "))), Array.isArray(i) && (i = i[e]);
813
+ const s = Number(i);
814
+ if (Number.isNaN(s))
815
+ throw new Error(`Provided delay value is not a number: "${i}"`);
816
+ return s;
817
+ }
818
+ function Nt(t) {
1024
819
  let e;
1025
- const n = typeof t == "string" ? t.trim().split(" ") : [t];
1026
- switch (n.forEach(function(i, s) {
1027
- n[s] = parseInt(i, 10);
1028
- }), n.length) {
820
+ const i = typeof t == "string" ? t.trim().split(" ") : [t];
821
+ for (let s = 0; s < i.length; s++)
822
+ i[s] = Number(i[s]);
823
+ switch (i.length) {
1029
824
  case 1:
1030
- e = n[0];
825
+ e = i[0];
1031
826
  break;
1032
827
  case 2:
1033
828
  e = {
1034
- top: n[0],
1035
- right: n[1],
1036
- bottom: n[0],
1037
- left: n[1]
829
+ top: i[0],
830
+ right: i[1],
831
+ bottom: i[0],
832
+ left: i[1]
1038
833
  };
1039
834
  break;
1040
835
  case 3:
1041
836
  e = {
1042
- top: n[0],
1043
- right: n[1],
1044
- bottom: n[2],
1045
- left: n[1]
837
+ top: i[0],
838
+ right: i[1],
839
+ bottom: i[2],
840
+ left: i[1]
1046
841
  };
1047
842
  break;
1048
843
  case 4:
1049
844
  e = {
1050
- top: n[0],
1051
- right: n[1],
1052
- bottom: n[2],
1053
- left: n[3]
845
+ top: i[0],
846
+ right: i[1],
847
+ bottom: i[2],
848
+ left: i[3]
1054
849
  };
1055
850
  break;
1056
851
  default:
@@ -1059,1120 +854,1247 @@ function ee(t) {
1059
854
  }
1060
855
  return e;
1061
856
  }
1062
- function qi(t) {
1063
- return [{
1064
- name: "offset",
1065
- options: {
1066
- offset: [0, parseInt(t.offset, 10)]
1067
- }
1068
- }, {
1069
- name: "preventOverflow",
1070
- options: {
1071
- padding: ee(t["overflow-padding"])
1072
- }
1073
- }, {
1074
- name: "flip",
1075
- options: {
1076
- padding: ee(t["flip-padding"])
1077
- }
1078
- }, {
1079
- name: "arrow",
1080
- options: {
1081
- element: t["arrow-element"],
1082
- padding: ee(t["arrow-padding"])
857
+ function oi(t) {
858
+ return {
859
+ offset: Number(t.getSetting("offset")),
860
+ flip: {
861
+ padding: Nt(t.getSetting("flip-padding"))
862
+ },
863
+ shift: {
864
+ padding: Nt(t.getSetting("shift-padding"))
865
+ },
866
+ arrow: {
867
+ element: t.getSetting("selectorArrow"),
868
+ padding: Nt(t.getSetting("arrow-padding"))
1083
869
  }
1084
- }];
870
+ };
1085
871
  }
1086
- function on(t) {
872
+ function ve(t) {
1087
873
  const e = typeof t == "string" ? this.get(t) : this.get(t.id);
1088
874
  if (e)
1089
875
  return e;
1090
876
  throw new Error(`Popover not found in collection with id of "${t}".`);
1091
877
  }
1092
- function an(t) {
1093
- return typeof t == "string" ? t : typeof t.hasAttribute == "function" ? t.closest(this.settings.selectorPopover) ? (t = t.closest(this.settings.selectorPopover), t.id) : t.hasAttribute("aria-controls") ? t.getAttribute("aria-controls") : t.hasAttribute("aria-describedby") ? t.getAttribute("aria-describedby") : !1 : t.id ? t.id : !1;
878
+ async function Se(t) {
879
+ const e = t ? ve.call(this, t) : await Ee.call(this);
880
+ 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;
1094
881
  }
1095
- function Mi(t) {
1096
- const e = an.call(this, t);
1097
- if (e) {
1098
- const n = document.querySelector(`#${e}`), i = document.querySelector(`[aria-controls="${e}"]`) || document.querySelector(`[aria-describedby="${e}"]`);
1099
- return !i && !n ? { error: new Error(`No popover elements found using the ID: "${e}".`) } : i ? n ? { popover: n, trigger: i } : { error: new Error("No popover associated with the provided popover trigger.") } : { error: new Error("No popover trigger associated with the provided popover.") };
1100
- } else
1101
- return { error: new Error("Could not resolve the popover ID.") };
1102
- }
1103
- async function pe(t) {
1104
- const e = t ? on.call(this, t) : await ln.call(this);
1105
- return e && e.state === "opened" && (e.el.classList.remove(this.settings.stateActive), e.trigger.hasAttribute("aria-controls") && e.trigger.setAttribute("aria-expanded", "false"), e.popper.setOptions({
1106
- modifiers: [{ name: "eventListeners", enabled: !1 }]
1107
- }), e.state = "closed", e.trigger === this.trigger && (this.trigger = null)), e;
1108
- }
1109
- async function ln() {
882
+ async function Ee() {
1110
883
  const t = [];
1111
884
  return await Promise.all(this.collection.map(async (e) => {
1112
- e.state === "opened" && t.push(await pe.call(this, e));
885
+ e.state === "opened" && t.push(await Se.call(this, e));
1113
886
  })), t;
1114
887
  }
1115
- function cn(t) {
888
+ function Ce(t) {
1116
889
  t.state == "opened" && setTimeout(() => {
1117
- const e = t.el.closest(":hover") === t.el || t.trigger.closest(":hover") === t.trigger, n = document.activeElement.closest(
890
+ const e = t.el.matches(":hover") === t.el || t.trigger.matches(":hover") === t.trigger;
891
+ let i = document.activeElement.closest(
1118
892
  `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
1119
893
  );
1120
- return !e && !n && t.close(), t;
894
+ return i = i ? i.matches(":focus-visible") : !1, !e && !i && t.close(), t;
1121
895
  }, 1);
1122
896
  }
1123
- function Wi(t) {
1124
- t.state === "opened" ? t.close() : (this.trigger = t.trigger, t.open(), dn.call(this, t));
897
+ function ri(t) {
898
+ t.state === "opened" ? t.close() : (this.trigger = t.trigger, t.open());
1125
899
  }
1126
- function ji(t) {
1127
- switch (t.key) {
900
+ function li(t) {
901
+ t.isTooltip && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.close());
902
+ }
903
+ function ai(t, e) {
904
+ if (t.isHovered = e, e.type == "focus" && !t.trigger.matches(":focus-visible"))
905
+ return;
906
+ t.toggleDelayId && clearTimeout(t.toggleDelayId);
907
+ const i = t.trigger.getAttribute("aria-expanded");
908
+ if (i && i == "true") return;
909
+ const s = this.activeHover ? 0 : xe(t, 0);
910
+ this.activeHover && this.activeHover.close(), t.toggleDelayId = setTimeout(() => {
911
+ t.id && t.open();
912
+ }, s);
913
+ }
914
+ function ci(t, e) {
915
+ setTimeout(() => {
916
+ t.isHovered = e, !t.isHovered && (t.toggleDelayId && clearTimeout(t.toggleDelayId), t.toggleDelayId = setTimeout(() => {
917
+ Ce.call(this, t);
918
+ }, xe(t, 1)));
919
+ }, 1);
920
+ }
921
+ function fi(t) {
922
+ switch (t.key) {
1128
923
  case "Escape":
1129
- this.trigger && this.trigger.focus(), ln.call(this);
924
+ this.trigger && this.trigger.focus(), Ee.call(this);
1130
925
  return;
1131
926
  case "Tab":
1132
927
  this.collection.forEach((e) => {
1133
- cn.call(this, e);
928
+ Ce.call(this, e);
1134
929
  });
1135
930
  return;
1136
931
  default:
1137
932
  return;
1138
933
  }
1139
934
  }
1140
- function dn(t) {
935
+ function ui(t) {
1141
936
  const e = this;
1142
- document.addEventListener("click", function n(i) {
1143
- i.target.closest(
937
+ document.addEventListener("click", function i(s) {
938
+ s.target.closest(
1144
939
  `#${t.id}, [aria-controls="${t.id}"], [aria-describedby="${t.id}"]`
1145
- ) ? 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));
940
+ ) ? t.el && !t.el.classList.contains(e.settings.stateActive) && this.removeEventListener("click", i) : (t.el && t.el.classList.contains(e.settings.stateActive) && t.close(), this.removeEventListener("click", i));
1146
941
  });
1147
942
  }
1148
- var W = "top", B = "bottom", R = "right", j = "left", ge = "auto", Dt = [W, B, R, j], ft = "start", It = "end", Ni = "clippingParents", un = "viewport", yt = "popper", _i = "reference", Ne = /* @__PURE__ */ Dt.reduce(function(t, e) {
1149
- return t.concat([e + "-" + ft, e + "-" + It]);
1150
- }, []), hn = /* @__PURE__ */ [].concat(Dt, [ge]).reduce(function(t, e) {
1151
- return t.concat([e, e + "-" + ft, e + "-" + It]);
1152
- }, []), Fi = "beforeRead", Bi = "read", Ri = "afterRead", Hi = "beforeMain", Vi = "main", Ji = "afterMain", zi = "beforeWrite", Ki = "write", Gi = "afterWrite", Qi = [Fi, Bi, Ri, Hi, Vi, Ji, zi, Ki, Gi];
1153
- function z(t) {
1154
- return t ? (t.nodeName || "").toLowerCase() : null;
1155
- }
1156
- function _(t) {
1157
- if (t == null)
1158
- return window;
1159
- if (t.toString() !== "[object Window]") {
1160
- var e = t.ownerDocument;
1161
- return e && e.defaultView || window;
943
+ var R, z;
944
+ class di extends Ct {
945
+ constructor(i, s, n = {}) {
946
+ super(i, s, n);
947
+ $(this, R);
948
+ $(this, z);
949
+ this.state = "closed", this.toggleDelayId = null, this.trigger = null, E(this, R, null), E(this, z, {
950
+ el: !1,
951
+ trigger: !1
952
+ }), this.floatingCleanup = () => {
953
+ };
954
+ }
955
+ get isTooltip() {
956
+ return !!this.el.closest(this.getSetting("selectorTooltip")) || this.el.getAttribute("role") == "tooltip";
957
+ }
958
+ get isHovered() {
959
+ return w(this, z).el || w(this, z).trigger;
960
+ }
961
+ set isHovered(i) {
962
+ const s = i.type == "mouseenter" ? !0 : i.type == "mouseleave" ? !1 : void 0;
963
+ if (s != null)
964
+ switch (i.target) {
965
+ case this.el:
966
+ w(this, z).el = s;
967
+ break;
968
+ case this.trigger:
969
+ w(this, z).trigger = s;
970
+ break;
971
+ }
972
+ }
973
+ async open() {
974
+ return this.context.open(this);
975
+ }
976
+ async close() {
977
+ return this.context.close(this);
978
+ }
979
+ async deregister() {
980
+ return this.context.deregister(this.id);
981
+ }
982
+ registerEventListeners() {
983
+ w(this, R) || (this.getSetting("event") === "hover" ? (E(this, R, [{
984
+ el: ["el", "trigger"],
985
+ type: ["mouseenter", "focus"],
986
+ listener: ai.bind(this.context, this)
987
+ }, {
988
+ el: ["el", "trigger"],
989
+ type: ["mouseleave", "focusout"],
990
+ listener: ci.bind(this.context, this)
991
+ }, {
992
+ el: ["trigger"],
993
+ type: ["click"],
994
+ listener: li.bind(this.context, this)
995
+ }]), w(this, R).forEach((s) => {
996
+ s.el.forEach((n) => {
997
+ s.type.forEach((o) => {
998
+ this[n].addEventListener(o, s.listener, !1);
999
+ });
1000
+ });
1001
+ })) : (E(this, R, [{
1002
+ el: ["trigger"],
1003
+ type: ["click"],
1004
+ listener: ri.bind(this.context, this)
1005
+ }]), w(this, R).forEach((s) => {
1006
+ s.el.forEach((n) => {
1007
+ s.type.forEach((o) => {
1008
+ this[n].addEventListener(o, s.listener, !1);
1009
+ });
1010
+ });
1011
+ })));
1012
+ }
1013
+ deregisterEventListeners() {
1014
+ w(this, R) && (w(this, R).forEach((i) => {
1015
+ i.el.forEach((s) => {
1016
+ i.type.forEach((n) => {
1017
+ this[s].removeEventListener(n, i.listener, !1);
1018
+ });
1019
+ });
1020
+ }), E(this, R, null));
1021
+ }
1022
+ async beforeMount() {
1023
+ this.trigger = document.querySelector(
1024
+ `[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`
1025
+ ), this.isTooltip ? (this.settings.event = "hover", this.el.setAttribute("role", "tooltip")) : this.trigger.setAttribute("aria-expanded", "false"), this.registerEventListeners();
1026
+ }
1027
+ async afterRegister() {
1028
+ this.el.classList.contains(this.getSetting("stateActive")) ? await this.open() : this.el.inert = !0;
1029
+ }
1030
+ async beforeUnmount() {
1031
+ this.state === "opened" && await this.close(), this.floatingCleanup(), this.deregisterEventListeners();
1162
1032
  }
1163
- return t;
1164
- }
1165
- function rt(t) {
1166
- var e = _(t).Element;
1167
- return t instanceof e || t instanceof Element;
1168
- }
1169
- function F(t) {
1170
- var e = _(t).HTMLElement;
1171
- return t instanceof e || t instanceof HTMLElement;
1172
1033
  }
1173
- function me(t) {
1174
- if (typeof ShadowRoot > "u")
1175
- return !1;
1176
- var e = _(t).ShadowRoot;
1177
- return t instanceof e || t instanceof ShadowRoot;
1178
- }
1179
- function Zi(t) {
1180
- var e = t.state;
1181
- Object.keys(e.elements).forEach(function(n) {
1182
- var i = e.styles[n] || {}, s = e.attributes[n] || {}, r = e.elements[n];
1183
- !F(r) || !z(r) || (Object.assign(r.style, i), Object.keys(s).forEach(function(a) {
1184
- var l = s[a];
1185
- l === !1 ? r.removeAttribute(a) : r.setAttribute(a, l === !0 ? "" : l);
1186
- }));
1187
- });
1034
+ R = new WeakMap(), z = new WeakMap();
1035
+ const ht = Math.min, Z = Math.max, Lt = Math.round, kt = Math.floor, W = (t) => ({
1036
+ x: t,
1037
+ y: t
1038
+ }), hi = {
1039
+ left: "right",
1040
+ right: "left",
1041
+ bottom: "top",
1042
+ top: "bottom"
1043
+ }, gi = {
1044
+ start: "end",
1045
+ end: "start"
1046
+ };
1047
+ function _t(t, e, i) {
1048
+ return Z(t, ht(e, i));
1188
1049
  }
1189
- function Ui(t) {
1190
- var e = t.state, n = {
1191
- popper: {
1192
- position: e.options.strategy,
1193
- left: "0",
1194
- top: "0",
1195
- margin: "0"
1196
- },
1197
- arrow: {
1198
- position: "absolute"
1199
- },
1200
- reference: {}
1201
- };
1202
- return Object.assign(e.elements.popper.style, n.popper), e.styles = n, e.elements.arrow && Object.assign(e.elements.arrow.style, n.arrow), function() {
1203
- Object.keys(e.elements).forEach(function(i) {
1204
- var s = e.elements[i], r = e.attributes[i] || {}, a = Object.keys(e.styles.hasOwnProperty(i) ? e.styles[i] : n[i]), l = a.reduce(function(o, c) {
1205
- return o[c] = "", o;
1206
- }, {});
1207
- !F(s) || !z(s) || (Object.assign(s.style, l), Object.keys(r).forEach(function(o) {
1208
- s.removeAttribute(o);
1209
- }));
1210
- });
1211
- };
1050
+ function Q(t, e) {
1051
+ return typeof t == "function" ? t(e) : t;
1212
1052
  }
1213
- const Xi = {
1214
- name: "applyStyles",
1215
- enabled: !0,
1216
- phase: "write",
1217
- fn: Zi,
1218
- effect: Ui,
1219
- requires: ["computeStyles"]
1220
- };
1221
- function J(t) {
1053
+ function U(t) {
1222
1054
  return t.split("-")[0];
1223
1055
  }
1224
- var st = Math.max, zt = Math.min, pt = Math.round;
1225
- function re() {
1226
- var t = navigator.userAgentData;
1227
- return t != null && t.brands && Array.isArray(t.brands) ? t.brands.map(function(e) {
1228
- return e.brand + "/" + e.version;
1229
- }).join(" ") : navigator.userAgent;
1230
- }
1231
- function fn() {
1232
- return !/^((?!chrome|android).)*safari/i.test(re());
1233
- }
1234
- function gt(t, e, n) {
1235
- e === void 0 && (e = !1), n === void 0 && (n = !1);
1236
- var i = t.getBoundingClientRect(), s = 1, r = 1;
1237
- e && F(t) && (s = t.offsetWidth > 0 && pt(i.width) / t.offsetWidth || 1, r = t.offsetHeight > 0 && pt(i.height) / t.offsetHeight || 1);
1238
- var a = rt(t) ? _(t) : window, l = a.visualViewport, o = !fn() && n, c = (i.left + (o && l ? l.offsetLeft : 0)) / s, d = (i.top + (o && l ? l.offsetTop : 0)) / r, b = i.width / s, v = i.height / r;
1239
- return {
1240
- width: b,
1241
- height: v,
1242
- top: d,
1243
- right: c + b,
1244
- bottom: d + v,
1245
- left: c,
1246
- x: c,
1247
- y: d
1248
- };
1056
+ function At(t) {
1057
+ return t.split("-")[1];
1249
1058
  }
1250
- function ve(t) {
1251
- var e = gt(t), n = t.offsetWidth, i = t.offsetHeight;
1252
- return Math.abs(e.width - n) <= 1 && (n = e.width), Math.abs(e.height - i) <= 1 && (i = e.height), {
1253
- x: t.offsetLeft,
1254
- y: t.offsetTop,
1255
- width: n,
1256
- height: i
1257
- };
1059
+ function Yt(t) {
1060
+ return t === "x" ? "y" : "x";
1258
1061
  }
1259
- function pn(t, e) {
1260
- var n = e.getRootNode && e.getRootNode();
1261
- if (t.contains(e))
1262
- return !0;
1263
- if (n && me(n)) {
1264
- var i = e;
1265
- do {
1266
- if (i && t.isSameNode(i))
1267
- return !0;
1268
- i = i.parentNode || i.host;
1269
- } while (i);
1270
- }
1271
- return !1;
1272
- }
1273
- function G(t) {
1274
- return _(t).getComputedStyle(t);
1275
- }
1276
- function Yi(t) {
1277
- return ["table", "td", "th"].indexOf(z(t)) >= 0;
1278
- }
1279
- function Z(t) {
1280
- return ((rt(t) ? t.ownerDocument : (
1281
- // $FlowFixMe[prop-missing]
1282
- t.document
1283
- )) || window.document).documentElement;
1284
- }
1285
- function Qt(t) {
1286
- return z(t) === "html" ? t : (
1287
- // this is a quicker (but less type safe) way to save quite some bytes from the bundle
1288
- // $FlowFixMe[incompatible-return]
1289
- // $FlowFixMe[prop-missing]
1290
- t.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1291
- t.parentNode || // DOM Element detected
1292
- (me(t) ? t.host : null) || // ShadowRoot detected
1293
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
1294
- Z(t)
1295
- );
1062
+ function Gt(t) {
1063
+ return t === "y" ? "height" : "width";
1296
1064
  }
1297
- function _e(t) {
1298
- return !F(t) || // https://github.com/popperjs/popper-core/issues/837
1299
- G(t).position === "fixed" ? null : t.offsetParent;
1065
+ function q(t) {
1066
+ return ["top", "bottom"].includes(U(t)) ? "y" : "x";
1300
1067
  }
1301
- function ts(t) {
1302
- var e = /firefox/i.test(re()), n = /Trident/i.test(re());
1303
- if (n && F(t)) {
1304
- var i = G(t);
1305
- if (i.position === "fixed")
1306
- return null;
1307
- }
1308
- var s = Qt(t);
1309
- for (me(s) && (s = s.host); F(s) && ["html", "body"].indexOf(z(s)) < 0; ) {
1310
- var r = G(s);
1311
- if (r.transform !== "none" || r.perspective !== "none" || r.contain === "paint" || ["transform", "perspective"].indexOf(r.willChange) !== -1 || e && r.willChange === "filter" || e && r.filter && r.filter !== "none")
1312
- return s;
1313
- s = s.parentNode;
1068
+ function Jt(t) {
1069
+ return Yt(q(t));
1070
+ }
1071
+ function mi(t, e, i) {
1072
+ i === void 0 && (i = !1);
1073
+ const s = At(t), n = Jt(t), o = Gt(n);
1074
+ let r = n === "x" ? s === (i ? "end" : "start") ? "right" : "left" : s === "start" ? "bottom" : "top";
1075
+ return e.reference[o] > e.floating[o] && (r = Ot(r)), [r, Ot(r)];
1076
+ }
1077
+ function pi(t) {
1078
+ const e = Ot(t);
1079
+ return [zt(t), e, zt(e)];
1080
+ }
1081
+ function zt(t) {
1082
+ return t.replace(/start|end/g, (e) => gi[e]);
1083
+ }
1084
+ function wi(t, e, i) {
1085
+ const s = ["left", "right"], n = ["right", "left"], o = ["top", "bottom"], r = ["bottom", "top"];
1086
+ switch (t) {
1087
+ case "top":
1088
+ case "bottom":
1089
+ return i ? e ? n : s : e ? s : n;
1090
+ case "left":
1091
+ case "right":
1092
+ return e ? o : r;
1093
+ default:
1094
+ return [];
1314
1095
  }
1315
- return null;
1316
1096
  }
1317
- function Pt(t) {
1318
- for (var e = _(t), n = _e(t); n && Yi(n) && G(n).position === "static"; )
1319
- n = _e(n);
1320
- return n && (z(n) === "html" || z(n) === "body" && G(n).position === "static") ? e : n || ts(t) || e;
1097
+ function bi(t, e, i, s) {
1098
+ const n = At(t);
1099
+ let o = wi(U(t), i === "start", s);
1100
+ return n && (o = o.map((r) => r + "-" + n), e && (o = o.concat(o.map(zt)))), o;
1321
1101
  }
1322
- function be(t) {
1323
- return ["top", "bottom"].indexOf(t) >= 0 ? "x" : "y";
1102
+ function Ot(t) {
1103
+ return t.replace(/left|right|bottom|top/g, (e) => hi[e]);
1324
1104
  }
1325
- function At(t, e, n) {
1326
- return st(t, zt(e, n));
1327
- }
1328
- function es(t, e, n) {
1329
- var i = At(t, e, n);
1330
- return i > n ? n : i;
1331
- }
1332
- function gn() {
1105
+ function yi(t) {
1333
1106
  return {
1334
1107
  top: 0,
1335
1108
  right: 0,
1336
1109
  bottom: 0,
1337
- left: 0
1110
+ left: 0,
1111
+ ...t
1338
1112
  };
1339
1113
  }
1340
- function mn(t) {
1341
- return Object.assign({}, gn(), t);
1342
- }
1343
- function vn(t, e) {
1344
- return e.reduce(function(n, i) {
1345
- return n[i] = t, n;
1346
- }, {});
1347
- }
1348
- var ns = function(t, e) {
1349
- return t = typeof t == "function" ? t(Object.assign({}, e.rects, {
1350
- placement: e.placement
1351
- })) : t, mn(typeof t != "number" ? t : vn(t, Dt));
1352
- };
1353
- function is(t) {
1354
- var e, n = t.state, i = t.name, s = t.options, r = n.elements.arrow, a = n.modifiersData.popperOffsets, l = J(n.placement), o = be(l), c = [j, R].indexOf(l) >= 0, d = c ? "height" : "width";
1355
- if (!(!r || !a)) {
1356
- var b = ns(s.padding, n), v = ve(r), h = o === "y" ? W : j, $ = o === "y" ? B : R, u = n.rects.reference[d] + n.rects.reference[o] - a[o] - n.rects.popper[d], w = a[o] - n.rects.reference[o], E = Pt(r), L = E ? o === "y" ? E.clientHeight || 0 : E.clientWidth || 0 : 0, O = u / 2 - w / 2, f = b[h], y = L - v[d] - b[$], x = L / 2 - v[d] / 2 + O, k = At(f, x, y), T = o;
1357
- n.modifiersData[i] = (e = {}, e[T] = k, e.centerOffset = k - x, e);
1358
- }
1359
- }
1360
- function ss(t) {
1361
- var e = t.state, n = t.options, i = n.element, s = i === void 0 ? "[data-popper-arrow]" : i;
1362
- s != null && (typeof s == "string" && (s = e.elements.popper.querySelector(s), !s) || pn(e.elements.popper, s) && (e.elements.arrow = s));
1363
- }
1364
- const rs = {
1365
- name: "arrow",
1366
- enabled: !0,
1367
- phase: "main",
1368
- fn: is,
1369
- effect: ss,
1370
- requires: ["popperOffsets"],
1371
- requiresIfExists: ["preventOverflow"]
1372
- };
1373
- function mt(t) {
1374
- return t.split("-")[1];
1114
+ function Ae(t) {
1115
+ return typeof t != "number" ? yi(t) : {
1116
+ top: t,
1117
+ right: t,
1118
+ bottom: t,
1119
+ left: t
1120
+ };
1375
1121
  }
1376
- var os = {
1377
- top: "auto",
1378
- right: "auto",
1379
- bottom: "auto",
1380
- left: "auto"
1381
- };
1382
- function as(t, e) {
1383
- var n = t.x, i = t.y, s = e.devicePixelRatio || 1;
1122
+ function Tt(t) {
1123
+ const {
1124
+ x: e,
1125
+ y: i,
1126
+ width: s,
1127
+ height: n
1128
+ } = t;
1384
1129
  return {
1385
- x: pt(n * s) / s || 0,
1386
- y: pt(i * s) / s || 0
1130
+ width: s,
1131
+ height: n,
1132
+ top: i,
1133
+ left: e,
1134
+ right: e + s,
1135
+ bottom: i + n,
1136
+ x: e,
1137
+ y: i
1387
1138
  };
1388
1139
  }
1389
- function Fe(t) {
1390
- var e, n = t.popper, i = t.popperRect, s = t.placement, r = t.variation, a = t.offsets, l = t.position, o = t.gpuAcceleration, c = t.adaptive, d = t.roundOffsets, b = t.isFixed, v = a.x, h = v === void 0 ? 0 : v, $ = a.y, u = $ === void 0 ? 0 : $, w = typeof d == "function" ? d({
1391
- x: h,
1392
- y: u
1393
- }) : {
1394
- x: h,
1395
- y: u
1396
- };
1397
- h = w.x, u = w.y;
1398
- var E = a.hasOwnProperty("x"), L = a.hasOwnProperty("y"), O = j, f = W, y = window;
1399
- if (c) {
1400
- var x = Pt(n), k = "clientHeight", T = "clientWidth";
1401
- if (x === _(n) && (x = Z(n), G(x).position !== "static" && l === "absolute" && (k = "scrollHeight", T = "scrollWidth")), x = x, s === W || (s === j || s === R) && r === It) {
1402
- f = B;
1403
- var A = b && x === y && y.visualViewport ? y.visualViewport.height : (
1404
- // $FlowFixMe[prop-missing]
1405
- x[k]
1406
- );
1407
- u -= A - i.height, u *= o ? 1 : -1;
1408
- }
1409
- if (s === j || (s === W || s === B) && r === It) {
1410
- O = R;
1411
- var C = b && x === y && y.visualViewport ? y.visualViewport.width : (
1412
- // $FlowFixMe[prop-missing]
1413
- x[T]
1414
- );
1415
- h -= C - i.width, h *= o ? 1 : -1;
1416
- }
1140
+ function se(t, e, i) {
1141
+ let {
1142
+ reference: s,
1143
+ floating: n
1144
+ } = t;
1145
+ const o = q(e), r = Jt(e), l = Gt(r), a = U(e), c = o === "y", d = s.x + s.width / 2 - n.width / 2, u = s.y + s.height / 2 - n.height / 2, h = s[l] / 2 - n[l] / 2;
1146
+ let f;
1147
+ switch (a) {
1148
+ case "top":
1149
+ f = {
1150
+ x: d,
1151
+ y: s.y - n.height
1152
+ };
1153
+ break;
1154
+ case "bottom":
1155
+ f = {
1156
+ x: d,
1157
+ y: s.y + s.height
1158
+ };
1159
+ break;
1160
+ case "right":
1161
+ f = {
1162
+ x: s.x + s.width,
1163
+ y: u
1164
+ };
1165
+ break;
1166
+ case "left":
1167
+ f = {
1168
+ x: s.x - n.width,
1169
+ y: u
1170
+ };
1171
+ break;
1172
+ default:
1173
+ f = {
1174
+ x: s.x,
1175
+ y: s.y
1176
+ };
1417
1177
  }
1418
- var I = Object.assign({
1419
- position: l
1420
- }, c && os), H = d === !0 ? as({
1421
- x: h,
1422
- y: u
1423
- }, _(n)) : {
1424
- x: h,
1178
+ switch (At(e)) {
1179
+ case "start":
1180
+ f[r] -= h * (i && c ? -1 : 1);
1181
+ break;
1182
+ case "end":
1183
+ f[r] += h * (i && c ? -1 : 1);
1184
+ break;
1185
+ }
1186
+ return f;
1187
+ }
1188
+ const xi = async (t, e, i) => {
1189
+ const {
1190
+ placement: s = "bottom",
1191
+ strategy: n = "absolute",
1192
+ middleware: o = [],
1193
+ platform: r
1194
+ } = i, l = o.filter(Boolean), a = await (r.isRTL == null ? void 0 : r.isRTL(e));
1195
+ let c = await r.getElementRects({
1196
+ reference: t,
1197
+ floating: e,
1198
+ strategy: n
1199
+ }), {
1200
+ x: d,
1425
1201
  y: u
1202
+ } = se(c, s, a), h = s, f = {}, g = 0;
1203
+ for (let m = 0; m < l.length; m++) {
1204
+ const {
1205
+ name: b,
1206
+ fn: p
1207
+ } = l[m], {
1208
+ x: y,
1209
+ y: x,
1210
+ data: S,
1211
+ reset: v
1212
+ } = await p({
1213
+ x: d,
1214
+ y: u,
1215
+ initialPlacement: s,
1216
+ placement: h,
1217
+ strategy: n,
1218
+ middlewareData: f,
1219
+ rects: c,
1220
+ platform: r,
1221
+ elements: {
1222
+ reference: t,
1223
+ floating: e
1224
+ }
1225
+ });
1226
+ d = y ?? d, u = x ?? u, f = {
1227
+ ...f,
1228
+ [b]: {
1229
+ ...f[b],
1230
+ ...S
1231
+ }
1232
+ }, v && g <= 50 && (g++, typeof v == "object" && (v.placement && (h = v.placement), v.rects && (c = v.rects === !0 ? await r.getElementRects({
1233
+ reference: t,
1234
+ floating: e,
1235
+ strategy: n
1236
+ }) : v.rects), {
1237
+ x: d,
1238
+ y: u
1239
+ } = se(c, h, a)), m = -1);
1240
+ }
1241
+ return {
1242
+ x: d,
1243
+ y: u,
1244
+ placement: h,
1245
+ strategy: n,
1246
+ middlewareData: f
1426
1247
  };
1427
- if (h = H.x, u = H.y, o) {
1428
- var P;
1429
- return Object.assign({}, I, (P = {}, P[f] = L ? "0" : "", P[O] = E ? "0" : "", P.transform = (y.devicePixelRatio || 1) <= 1 ? "translate(" + h + "px, " + u + "px)" : "translate3d(" + h + "px, " + u + "px, 0)", P));
1430
- }
1431
- return Object.assign({}, I, (e = {}, e[f] = L ? u + "px" : "", e[O] = E ? h + "px" : "", e.transform = "", e));
1432
- }
1433
- function ls(t) {
1434
- var e = t.state, n = t.options, i = n.gpuAcceleration, s = i === void 0 ? !0 : i, r = n.adaptive, a = r === void 0 ? !0 : r, l = n.roundOffsets, o = l === void 0 ? !0 : l, c = {
1435
- placement: J(e.placement),
1436
- variation: mt(e.placement),
1437
- popper: e.elements.popper,
1438
- popperRect: e.rects.popper,
1439
- gpuAcceleration: s,
1440
- isFixed: e.options.strategy === "fixed"
1248
+ };
1249
+ async function $e(t, e) {
1250
+ var i;
1251
+ e === void 0 && (e = {});
1252
+ const {
1253
+ x: s,
1254
+ y: n,
1255
+ platform: o,
1256
+ rects: r,
1257
+ elements: l,
1258
+ strategy: a
1259
+ } = t, {
1260
+ boundary: c = "clippingAncestors",
1261
+ rootBoundary: d = "viewport",
1262
+ elementContext: u = "floating",
1263
+ altBoundary: h = !1,
1264
+ padding: f = 0
1265
+ } = Q(e, t), g = Ae(f), b = l[h ? u === "floating" ? "reference" : "floating" : u], p = Tt(await o.getClippingRect({
1266
+ element: (i = await (o.isElement == null ? void 0 : o.isElement(b))) == null || i ? b : b.contextElement || await (o.getDocumentElement == null ? void 0 : o.getDocumentElement(l.floating)),
1267
+ boundary: c,
1268
+ rootBoundary: d,
1269
+ strategy: a
1270
+ })), y = u === "floating" ? {
1271
+ x: s,
1272
+ y: n,
1273
+ width: r.floating.width,
1274
+ height: r.floating.height
1275
+ } : r.reference, x = await (o.getOffsetParent == null ? void 0 : o.getOffsetParent(l.floating)), S = await (o.isElement == null ? void 0 : o.isElement(x)) ? await (o.getScale == null ? void 0 : o.getScale(x)) || {
1276
+ x: 1,
1277
+ y: 1
1278
+ } : {
1279
+ x: 1,
1280
+ y: 1
1281
+ }, v = Tt(o.convertOffsetParentRelativeRectToViewportRelativeRect ? await o.convertOffsetParentRelativeRectToViewportRelativeRect({
1282
+ elements: l,
1283
+ rect: y,
1284
+ offsetParent: x,
1285
+ strategy: a
1286
+ }) : y);
1287
+ return {
1288
+ top: (p.top - v.top + g.top) / S.y,
1289
+ bottom: (v.bottom - p.bottom + g.bottom) / S.y,
1290
+ left: (p.left - v.left + g.left) / S.x,
1291
+ right: (v.right - p.right + g.right) / S.x
1441
1292
  };
1442
- e.modifiersData.popperOffsets != null && (e.styles.popper = Object.assign({}, e.styles.popper, Fe(Object.assign({}, c, {
1443
- offsets: e.modifiersData.popperOffsets,
1444
- position: e.options.strategy,
1445
- adaptive: a,
1446
- roundOffsets: o
1447
- })))), e.modifiersData.arrow != null && (e.styles.arrow = Object.assign({}, e.styles.arrow, Fe(Object.assign({}, c, {
1448
- offsets: e.modifiersData.arrow,
1449
- position: "absolute",
1450
- adaptive: !1,
1451
- roundOffsets: o
1452
- })))), e.attributes.popper = Object.assign({}, e.attributes.popper, {
1453
- "data-popper-placement": e.placement
1454
- });
1455
1293
  }
1456
- const cs = {
1457
- name: "computeStyles",
1458
- enabled: !0,
1459
- phase: "beforeWrite",
1460
- fn: ls,
1461
- data: {}
1462
- };
1463
- var Bt = {
1464
- passive: !0
1294
+ const vi = (t) => ({
1295
+ name: "arrow",
1296
+ options: t,
1297
+ async fn(e) {
1298
+ const {
1299
+ x: i,
1300
+ y: s,
1301
+ placement: n,
1302
+ rects: o,
1303
+ platform: r,
1304
+ elements: l,
1305
+ middlewareData: a
1306
+ } = e, {
1307
+ element: c,
1308
+ padding: d = 0
1309
+ } = Q(t, e) || {};
1310
+ if (c == null)
1311
+ return {};
1312
+ const u = Ae(d), h = {
1313
+ x: i,
1314
+ y: s
1315
+ }, f = Jt(n), g = Gt(f), m = await r.getDimensions(c), b = f === "y", p = b ? "top" : "left", y = b ? "bottom" : "right", x = b ? "clientHeight" : "clientWidth", S = o.reference[g] + o.reference[f] - h[f] - o.floating[g], v = h[f] - o.reference[f], k = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(c));
1316
+ let j = k ? k[x] : 0;
1317
+ (!j || !await (r.isElement == null ? void 0 : r.isElement(k))) && (j = l.floating[x] || o.floating[g]);
1318
+ const pt = S / 2 - v / 2, X = j / 2 - m[g] / 2 - 1, V = ht(u[p], X), wt = ht(u[y], X), Y = V, bt = j - m[g] - wt, A = j / 2 - m[g] / 2 + pt, et = _t(Y, A, bt), B = !a.arrow && At(n) != null && A !== et && o.reference[g] / 2 - (A < Y ? V : wt) - m[g] / 2 < 0, F = B ? A < Y ? A - Y : A - bt : 0;
1319
+ return {
1320
+ [f]: h[f] + F,
1321
+ data: {
1322
+ [f]: et,
1323
+ centerOffset: A - et - F,
1324
+ ...B && {
1325
+ alignmentOffset: F
1326
+ }
1327
+ },
1328
+ reset: B
1329
+ };
1330
+ }
1331
+ }), Si = function(t) {
1332
+ return t === void 0 && (t = {}), {
1333
+ name: "flip",
1334
+ options: t,
1335
+ async fn(e) {
1336
+ var i, s;
1337
+ const {
1338
+ placement: n,
1339
+ middlewareData: o,
1340
+ rects: r,
1341
+ initialPlacement: l,
1342
+ platform: a,
1343
+ elements: c
1344
+ } = e, {
1345
+ mainAxis: d = !0,
1346
+ crossAxis: u = !0,
1347
+ fallbackPlacements: h,
1348
+ fallbackStrategy: f = "bestFit",
1349
+ fallbackAxisSideDirection: g = "none",
1350
+ flipAlignment: m = !0,
1351
+ ...b
1352
+ } = Q(t, e);
1353
+ if ((i = o.arrow) != null && i.alignmentOffset)
1354
+ return {};
1355
+ const p = U(n), y = q(l), x = U(l) === l, S = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), v = h || (x || !m ? [Ot(l)] : pi(l)), k = g !== "none";
1356
+ !h && k && v.push(...bi(l, m, g, S));
1357
+ const j = [l, ...v], pt = await $e(e, b), X = [];
1358
+ let V = ((s = o.flip) == null ? void 0 : s.overflows) || [];
1359
+ if (d && X.push(pt[p]), u) {
1360
+ const A = mi(n, r, S);
1361
+ X.push(pt[A[0]], pt[A[1]]);
1362
+ }
1363
+ if (V = [...V, {
1364
+ placement: n,
1365
+ overflows: X
1366
+ }], !X.every((A) => A <= 0)) {
1367
+ var wt, Y;
1368
+ const A = (((wt = o.flip) == null ? void 0 : wt.index) || 0) + 1, et = j[A];
1369
+ if (et)
1370
+ return {
1371
+ data: {
1372
+ index: A,
1373
+ overflows: V
1374
+ },
1375
+ reset: {
1376
+ placement: et
1377
+ }
1378
+ };
1379
+ let B = (Y = V.filter((F) => F.overflows[0] <= 0).sort((F, H) => F.overflows[1] - H.overflows[1])[0]) == null ? void 0 : Y.placement;
1380
+ if (!B)
1381
+ switch (f) {
1382
+ case "bestFit": {
1383
+ var bt;
1384
+ const F = (bt = V.filter((H) => {
1385
+ if (k) {
1386
+ const _ = q(H.placement);
1387
+ return _ === y || // Create a bias to the `y` side axis due to horizontal
1388
+ // reading directions favoring greater width.
1389
+ _ === "y";
1390
+ }
1391
+ return !0;
1392
+ }).map((H) => [H.placement, H.overflows.filter((_) => _ > 0).reduce((_, De) => _ + De, 0)]).sort((H, _) => H[1] - _[1])[0]) == null ? void 0 : bt[0];
1393
+ F && (B = F);
1394
+ break;
1395
+ }
1396
+ case "initialPlacement":
1397
+ B = l;
1398
+ break;
1399
+ }
1400
+ if (n !== B)
1401
+ return {
1402
+ reset: {
1403
+ placement: B
1404
+ }
1405
+ };
1406
+ }
1407
+ return {};
1408
+ }
1409
+ };
1465
1410
  };
1466
- function ds(t) {
1467
- var e = t.state, n = t.instance, i = t.options, s = i.scroll, r = s === void 0 ? !0 : s, a = i.resize, l = a === void 0 ? !0 : a, o = _(e.elements.popper), c = [].concat(e.scrollParents.reference, e.scrollParents.popper);
1468
- return r && c.forEach(function(d) {
1469
- d.addEventListener("scroll", n.update, Bt);
1470
- }), l && o.addEventListener("resize", n.update, Bt), function() {
1471
- r && c.forEach(function(d) {
1472
- d.removeEventListener("scroll", n.update, Bt);
1473
- }), l && o.removeEventListener("resize", n.update, Bt);
1411
+ async function Ei(t, e) {
1412
+ const {
1413
+ placement: i,
1414
+ platform: s,
1415
+ elements: n
1416
+ } = t, o = await (s.isRTL == null ? void 0 : s.isRTL(n.floating)), r = U(i), l = At(i), a = q(i) === "y", c = ["left", "top"].includes(r) ? -1 : 1, d = o && a ? -1 : 1, u = Q(e, t);
1417
+ let {
1418
+ mainAxis: h,
1419
+ crossAxis: f,
1420
+ alignmentAxis: g
1421
+ } = typeof u == "number" ? {
1422
+ mainAxis: u,
1423
+ crossAxis: 0,
1424
+ alignmentAxis: null
1425
+ } : {
1426
+ mainAxis: u.mainAxis || 0,
1427
+ crossAxis: u.crossAxis || 0,
1428
+ alignmentAxis: u.alignmentAxis
1429
+ };
1430
+ return l && typeof g == "number" && (f = l === "end" ? g * -1 : g), a ? {
1431
+ x: f * d,
1432
+ y: h * c
1433
+ } : {
1434
+ x: h * c,
1435
+ y: f * d
1474
1436
  };
1475
1437
  }
1476
- const us = {
1477
- name: "eventListeners",
1478
- enabled: !0,
1479
- phase: "write",
1480
- fn: function() {
1481
- },
1482
- effect: ds,
1483
- data: {}
1484
- };
1485
- var hs = {
1486
- left: "right",
1487
- right: "left",
1488
- bottom: "top",
1489
- top: "bottom"
1438
+ const Ci = function(t) {
1439
+ return t === void 0 && (t = 0), {
1440
+ name: "offset",
1441
+ options: t,
1442
+ async fn(e) {
1443
+ var i, s;
1444
+ const {
1445
+ x: n,
1446
+ y: o,
1447
+ placement: r,
1448
+ middlewareData: l
1449
+ } = e, a = await Ei(e, t);
1450
+ return r === ((i = l.offset) == null ? void 0 : i.placement) && (s = l.arrow) != null && s.alignmentOffset ? {} : {
1451
+ x: n + a.x,
1452
+ y: o + a.y,
1453
+ data: {
1454
+ ...a,
1455
+ placement: r
1456
+ }
1457
+ };
1458
+ }
1459
+ };
1460
+ }, Ai = function(t) {
1461
+ return t === void 0 && (t = {}), {
1462
+ name: "shift",
1463
+ options: t,
1464
+ async fn(e) {
1465
+ const {
1466
+ x: i,
1467
+ y: s,
1468
+ placement: n
1469
+ } = e, {
1470
+ mainAxis: o = !0,
1471
+ crossAxis: r = !1,
1472
+ limiter: l = {
1473
+ fn: (b) => {
1474
+ let {
1475
+ x: p,
1476
+ y
1477
+ } = b;
1478
+ return {
1479
+ x: p,
1480
+ y
1481
+ };
1482
+ }
1483
+ },
1484
+ ...a
1485
+ } = Q(t, e), c = {
1486
+ x: i,
1487
+ y: s
1488
+ }, d = await $e(e, a), u = q(U(n)), h = Yt(u);
1489
+ let f = c[h], g = c[u];
1490
+ if (o) {
1491
+ const b = h === "y" ? "top" : "left", p = h === "y" ? "bottom" : "right", y = f + d[b], x = f - d[p];
1492
+ f = _t(y, f, x);
1493
+ }
1494
+ if (r) {
1495
+ const b = u === "y" ? "top" : "left", p = u === "y" ? "bottom" : "right", y = g + d[b], x = g - d[p];
1496
+ g = _t(y, g, x);
1497
+ }
1498
+ const m = l.fn({
1499
+ ...e,
1500
+ [h]: f,
1501
+ [u]: g
1502
+ });
1503
+ return {
1504
+ ...m,
1505
+ data: {
1506
+ x: m.x - i,
1507
+ y: m.y - s,
1508
+ enabled: {
1509
+ [h]: o,
1510
+ [u]: r
1511
+ }
1512
+ }
1513
+ };
1514
+ }
1515
+ };
1516
+ }, $i = function(t) {
1517
+ return t === void 0 && (t = {}), {
1518
+ options: t,
1519
+ fn(e) {
1520
+ const {
1521
+ x: i,
1522
+ y: s,
1523
+ placement: n,
1524
+ rects: o,
1525
+ middlewareData: r
1526
+ } = e, {
1527
+ offset: l = 0,
1528
+ mainAxis: a = !0,
1529
+ crossAxis: c = !0
1530
+ } = Q(t, e), d = {
1531
+ x: i,
1532
+ y: s
1533
+ }, u = q(n), h = Yt(u);
1534
+ let f = d[h], g = d[u];
1535
+ const m = Q(l, e), b = typeof m == "number" ? {
1536
+ mainAxis: m,
1537
+ crossAxis: 0
1538
+ } : {
1539
+ mainAxis: 0,
1540
+ crossAxis: 0,
1541
+ ...m
1542
+ };
1543
+ if (a) {
1544
+ const x = h === "y" ? "height" : "width", S = o.reference[h] - o.floating[x] + b.mainAxis, v = o.reference[h] + o.reference[x] - b.mainAxis;
1545
+ f < S ? f = S : f > v && (f = v);
1546
+ }
1547
+ if (c) {
1548
+ var p, y;
1549
+ const x = h === "y" ? "width" : "height", S = ["top", "left"].includes(U(n)), v = o.reference[u] - o.floating[x] + (S && ((p = r.offset) == null ? void 0 : p[u]) || 0) + (S ? 0 : b.crossAxis), k = o.reference[u] + o.reference[x] + (S ? 0 : ((y = r.offset) == null ? void 0 : y[u]) || 0) - (S ? b.crossAxis : 0);
1550
+ g < v ? g = v : g > k && (g = k);
1551
+ }
1552
+ return {
1553
+ [h]: f,
1554
+ [u]: g
1555
+ };
1556
+ }
1557
+ };
1490
1558
  };
1491
- function Vt(t) {
1492
- return t.replace(/left|right|bottom|top/g, function(e) {
1493
- return hs[e];
1494
- });
1559
+ function Mt() {
1560
+ return typeof window < "u";
1495
1561
  }
1496
- var fs = {
1497
- start: "end",
1498
- end: "start"
1499
- };
1500
- function Be(t) {
1501
- return t.replace(/start|end/g, function(e) {
1502
- return fs[e];
1503
- });
1562
+ function mt(t) {
1563
+ return ke(t) ? (t.nodeName || "").toLowerCase() : "#document";
1504
1564
  }
1505
- function ye(t) {
1506
- var e = _(t), n = e.pageXOffset, i = e.pageYOffset;
1507
- return {
1508
- scrollLeft: n,
1509
- scrollTop: i
1510
- };
1565
+ function T(t) {
1566
+ var e;
1567
+ return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
1511
1568
  }
1512
- function we(t) {
1513
- return gt(Z(t)).left + ye(t).scrollLeft;
1569
+ function N(t) {
1570
+ var e;
1571
+ return (e = (ke(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
1514
1572
  }
1515
- function ps(t, e) {
1516
- var n = _(t), i = Z(t), s = n.visualViewport, r = i.clientWidth, a = i.clientHeight, l = 0, o = 0;
1517
- if (s) {
1518
- r = s.width, a = s.height;
1519
- var c = fn();
1520
- (c || !c && e === "fixed") && (l = s.offsetLeft, o = s.offsetTop);
1521
- }
1522
- return {
1523
- width: r,
1524
- height: a,
1525
- x: l + we(t),
1526
- y: o
1527
- };
1573
+ function ke(t) {
1574
+ return Mt() ? t instanceof Node || t instanceof T(t).Node : !1;
1528
1575
  }
1529
- function gs(t) {
1530
- var e, n = Z(t), i = ye(t), s = (e = t.ownerDocument) == null ? void 0 : e.body, r = st(n.scrollWidth, n.clientWidth, s ? s.scrollWidth : 0, s ? s.clientWidth : 0), a = st(n.scrollHeight, n.clientHeight, s ? s.scrollHeight : 0, s ? s.clientHeight : 0), l = -i.scrollLeft + we(t), o = -i.scrollTop;
1531
- return G(s || n).direction === "rtl" && (l += st(n.clientWidth, s ? s.clientWidth : 0) - r), {
1532
- width: r,
1533
- height: a,
1534
- x: l,
1535
- y: o
1536
- };
1576
+ function D(t) {
1577
+ return Mt() ? t instanceof Element || t instanceof T(t).Element : !1;
1537
1578
  }
1538
- function $e(t) {
1539
- var e = G(t), n = e.overflow, i = e.overflowX, s = e.overflowY;
1540
- return /auto|scroll|overlay|hidden/.test(n + s + i);
1579
+ function I(t) {
1580
+ return Mt() ? t instanceof HTMLElement || t instanceof T(t).HTMLElement : !1;
1541
1581
  }
1542
- function bn(t) {
1543
- return ["html", "body", "#document"].indexOf(z(t)) >= 0 ? t.ownerDocument.body : F(t) && $e(t) ? t : bn(Qt(t));
1582
+ function ne(t) {
1583
+ return !Mt() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof T(t).ShadowRoot;
1544
1584
  }
1545
- function Ct(t, e) {
1546
- var n;
1547
- e === void 0 && (e = []);
1548
- var i = bn(t), s = i === ((n = t.ownerDocument) == null ? void 0 : n.body), r = _(i), a = s ? [r].concat(r.visualViewport || [], $e(i) ? i : []) : i, l = e.concat(a);
1549
- return s ? l : (
1550
- // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1551
- l.concat(Ct(Qt(a)))
1552
- );
1585
+ function $t(t) {
1586
+ const {
1587
+ overflow: e,
1588
+ overflowX: i,
1589
+ overflowY: s,
1590
+ display: n
1591
+ } = M(t);
1592
+ return /auto|scroll|overlay|hidden|clip/.test(e + s + i) && !["inline", "contents"].includes(n);
1553
1593
  }
1554
- function oe(t) {
1555
- return Object.assign({}, t, {
1556
- left: t.x,
1557
- top: t.y,
1558
- right: t.x + t.width,
1559
- bottom: t.y + t.height
1594
+ function ki(t) {
1595
+ return ["table", "td", "th"].includes(mt(t));
1596
+ }
1597
+ function Ft(t) {
1598
+ return [":popover-open", ":modal"].some((e) => {
1599
+ try {
1600
+ return t.matches(e);
1601
+ } catch {
1602
+ return !1;
1603
+ }
1560
1604
  });
1561
1605
  }
1562
- function ms(t, e) {
1563
- var n = gt(t, !1, e === "fixed");
1564
- return n.top = n.top + t.clientTop, n.left = n.left + t.clientLeft, n.bottom = n.top + t.clientHeight, n.right = n.left + t.clientWidth, n.width = t.clientWidth, n.height = t.clientHeight, n.x = n.left, n.y = n.top, n;
1565
- }
1566
- function Re(t, e, n) {
1567
- return e === un ? oe(ps(t, n)) : rt(e) ? ms(e, n) : oe(gs(Z(t)));
1568
- }
1569
- function vs(t) {
1570
- var e = Ct(Qt(t)), n = ["absolute", "fixed"].indexOf(G(t).position) >= 0, i = n && F(t) ? Pt(t) : t;
1571
- return rt(i) ? e.filter(function(s) {
1572
- return rt(s) && pn(s, i) && z(s) !== "body";
1573
- }) : [];
1574
- }
1575
- function bs(t, e, n, i) {
1576
- var s = e === "clippingParents" ? vs(t) : [].concat(e), r = [].concat(s, [n]), a = r[0], l = r.reduce(function(o, c) {
1577
- var d = Re(t, c, i);
1578
- return o.top = st(d.top, o.top), o.right = zt(d.right, o.right), o.bottom = zt(d.bottom, o.bottom), o.left = st(d.left, o.left), o;
1579
- }, Re(t, a, i));
1580
- return l.width = l.right - l.left, l.height = l.bottom - l.top, l.x = l.left, l.y = l.top, l;
1581
- }
1582
- function yn(t) {
1583
- var e = t.reference, n = t.element, i = t.placement, s = i ? J(i) : null, r = i ? mt(i) : null, a = e.x + e.width / 2 - n.width / 2, l = e.y + e.height / 2 - n.height / 2, o;
1584
- switch (s) {
1585
- case W:
1586
- o = {
1587
- x: a,
1588
- y: e.y - n.height
1589
- };
1590
- break;
1591
- case B:
1592
- o = {
1593
- x: a,
1594
- y: e.y + e.height
1595
- };
1596
- break;
1597
- case R:
1598
- o = {
1599
- x: e.x + e.width,
1600
- y: l
1601
- };
1602
- break;
1603
- case j:
1604
- o = {
1605
- x: e.x - n.width,
1606
- y: l
1607
- };
1608
- break;
1609
- default:
1610
- o = {
1611
- x: e.x,
1612
- y: e.y
1613
- };
1614
- }
1615
- var c = s ? be(s) : null;
1616
- if (c != null) {
1617
- var d = c === "y" ? "height" : "width";
1618
- switch (r) {
1619
- case ft:
1620
- o[c] = o[c] - (e[d] / 2 - n[d] / 2);
1621
- break;
1622
- case It:
1623
- o[c] = o[c] + (e[d] / 2 - n[d] / 2);
1624
- break;
1625
- }
1626
- }
1627
- return o;
1606
+ function Zt(t) {
1607
+ const e = Qt(), i = D(t) ? M(t) : t;
1608
+ return i.transform !== "none" || i.perspective !== "none" || (i.containerType ? i.containerType !== "normal" : !1) || !e && (i.backdropFilter ? i.backdropFilter !== "none" : !1) || !e && (i.filter ? i.filter !== "none" : !1) || ["transform", "perspective", "filter"].some((s) => (i.willChange || "").includes(s)) || ["paint", "layout", "strict", "content"].some((s) => (i.contain || "").includes(s));
1628
1609
  }
1629
- function St(t, e) {
1630
- e === void 0 && (e = {});
1631
- var n = e, i = n.placement, s = i === void 0 ? t.placement : i, r = n.strategy, a = r === void 0 ? t.strategy : r, l = n.boundary, o = l === void 0 ? Ni : l, c = n.rootBoundary, d = c === void 0 ? un : c, b = n.elementContext, v = b === void 0 ? yt : b, h = n.altBoundary, $ = h === void 0 ? !1 : h, u = n.padding, w = u === void 0 ? 0 : u, E = mn(typeof w != "number" ? w : vn(w, Dt)), L = v === yt ? _i : yt, O = t.rects.popper, f = t.elements[$ ? L : v], y = bs(rt(f) ? f : f.contextElement || Z(t.elements.popper), o, d, a), x = gt(t.elements.reference), k = yn({
1632
- reference: x,
1633
- element: O,
1634
- strategy: "absolute",
1635
- placement: s
1636
- }), T = oe(Object.assign({}, O, k)), A = v === yt ? T : x, C = {
1637
- top: y.top - A.top + E.top,
1638
- bottom: A.bottom - y.bottom + E.bottom,
1639
- left: y.left - A.left + E.left,
1640
- right: A.right - y.right + E.right
1641
- }, I = t.modifiersData.offset;
1642
- if (v === yt && I) {
1643
- var H = I[s];
1644
- Object.keys(C).forEach(function(P) {
1645
- var U = [R, B].indexOf(P) >= 0 ? 1 : -1, X = [W, B].indexOf(P) >= 0 ? "y" : "x";
1646
- C[P] += H[X] * U;
1647
- });
1610
+ function Li(t) {
1611
+ let e = K(t);
1612
+ for (; I(e) && !gt(e); ) {
1613
+ if (Zt(e))
1614
+ return e;
1615
+ if (Ft(e))
1616
+ return null;
1617
+ e = K(e);
1648
1618
  }
1649
- return C;
1619
+ return null;
1650
1620
  }
1651
- function ys(t, e) {
1652
- e === void 0 && (e = {});
1653
- var n = e, i = n.placement, s = n.boundary, r = n.rootBoundary, a = n.padding, l = n.flipVariations, o = n.allowedAutoPlacements, c = o === void 0 ? hn : o, d = mt(i), b = d ? l ? Ne : Ne.filter(function($) {
1654
- return mt($) === d;
1655
- }) : Dt, v = b.filter(function($) {
1656
- return c.indexOf($) >= 0;
1657
- });
1658
- v.length === 0 && (v = b);
1659
- var h = v.reduce(function($, u) {
1660
- return $[u] = St(t, {
1661
- placement: u,
1662
- boundary: s,
1663
- rootBoundary: r,
1664
- padding: a
1665
- })[J(u)], $;
1666
- }, {});
1667
- return Object.keys(h).sort(function($, u) {
1668
- return h[$] - h[u];
1669
- });
1621
+ function Qt() {
1622
+ return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
1670
1623
  }
1671
- function ws(t) {
1672
- if (J(t) === ge)
1673
- return [];
1674
- var e = Vt(t);
1675
- return [Be(t), e, Be(e)];
1676
- }
1677
- function $s(t) {
1678
- var e = t.state, n = t.options, i = t.name;
1679
- if (!e.modifiersData[i]._skip) {
1680
- for (var s = n.mainAxis, r = s === void 0 ? !0 : s, a = n.altAxis, l = a === void 0 ? !0 : a, o = n.fallbackPlacements, c = n.padding, d = n.boundary, b = n.rootBoundary, v = n.altBoundary, h = n.flipVariations, $ = h === void 0 ? !0 : h, u = n.allowedAutoPlacements, w = e.options.placement, E = J(w), L = E === w, O = o || (L || !$ ? [Vt(w)] : ws(w)), f = [w].concat(O).reduce(function(tt, K) {
1681
- return tt.concat(J(K) === ge ? ys(e, {
1682
- placement: K,
1683
- boundary: d,
1684
- rootBoundary: b,
1685
- padding: c,
1686
- flipVariations: $,
1687
- allowedAutoPlacements: u
1688
- }) : K);
1689
- }, []), y = e.rects.reference, x = e.rects.popper, k = /* @__PURE__ */ new Map(), T = !0, A = f[0], C = 0; C < f.length; C++) {
1690
- var I = f[C], H = J(I), P = mt(I) === ft, U = [W, B].indexOf(H) >= 0, X = U ? "width" : "height", N = St(e, {
1691
- placement: I,
1692
- boundary: d,
1693
- rootBoundary: b,
1694
- altBoundary: v,
1695
- padding: c
1696
- }), V = U ? P ? R : j : P ? B : W;
1697
- y[X] > x[X] && (V = Vt(V));
1698
- var qt = Vt(V), Y = [];
1699
- if (r && Y.push(N[H] <= 0), l && Y.push(N[V] <= 0, N[qt] <= 0), Y.every(function(tt) {
1700
- return tt;
1701
- })) {
1702
- A = I, T = !1;
1703
- break;
1704
- }
1705
- k.set(I, Y);
1706
- }
1707
- if (T)
1708
- for (var Mt = $ ? 3 : 1, Zt = function(tt) {
1709
- var K = f.find(function(jt) {
1710
- var bt = k.get(jt);
1711
- if (bt)
1712
- return bt.slice(0, tt).every(function(ot) {
1713
- return ot;
1714
- });
1715
- });
1716
- if (K)
1717
- return A = K, "break";
1718
- }, vt = Mt; vt > 0; vt--) {
1719
- var Wt = Zt(vt);
1720
- if (Wt === "break")
1721
- break;
1722
- }
1723
- e.placement !== A && (e.modifiersData[i]._skip = !0, e.placement = A, e.reset = !0);
1724
- }
1624
+ function gt(t) {
1625
+ return ["html", "body", "#document"].includes(mt(t));
1725
1626
  }
1726
- const Es = {
1727
- name: "flip",
1728
- enabled: !0,
1729
- phase: "main",
1730
- fn: $s,
1731
- requiresIfExists: ["offset"],
1732
- data: {
1733
- _skip: !1
1734
- }
1735
- };
1736
- function He(t, e, n) {
1737
- return n === void 0 && (n = {
1738
- x: 0,
1739
- y: 0
1740
- }), {
1741
- top: t.top - e.height - n.y,
1742
- right: t.right - e.width + n.x,
1743
- bottom: t.bottom - e.height + n.y,
1744
- left: t.left - e.width - n.x
1745
- };
1627
+ function M(t) {
1628
+ return T(t).getComputedStyle(t);
1746
1629
  }
1747
- function Ve(t) {
1748
- return [W, R, B, j].some(function(e) {
1749
- return t[e] >= 0;
1750
- });
1630
+ function It(t) {
1631
+ return D(t) ? {
1632
+ scrollLeft: t.scrollLeft,
1633
+ scrollTop: t.scrollTop
1634
+ } : {
1635
+ scrollLeft: t.scrollX,
1636
+ scrollTop: t.scrollY
1637
+ };
1751
1638
  }
1752
- function xs(t) {
1753
- var e = t.state, n = t.name, i = e.rects.reference, s = e.rects.popper, r = e.modifiersData.preventOverflow, a = St(e, {
1754
- elementContext: "reference"
1755
- }), l = St(e, {
1756
- altBoundary: !0
1757
- }), o = He(a, i), c = He(l, s, r), d = Ve(o), b = Ve(c);
1758
- e.modifiersData[n] = {
1759
- referenceClippingOffsets: o,
1760
- popperEscapeOffsets: c,
1761
- isReferenceHidden: d,
1762
- hasPopperEscaped: b
1763
- }, e.attributes.popper = Object.assign({}, e.attributes.popper, {
1764
- "data-popper-reference-hidden": d,
1765
- "data-popper-escaped": b
1766
- });
1639
+ function K(t) {
1640
+ if (mt(t) === "html")
1641
+ return t;
1642
+ const e = (
1643
+ // Step into the shadow DOM of the parent of a slotted node.
1644
+ t.assignedSlot || // DOM Element detected.
1645
+ t.parentNode || // ShadowRoot detected.
1646
+ ne(t) && t.host || // Fallback.
1647
+ N(t)
1648
+ );
1649
+ return ne(e) ? e.host : e;
1650
+ }
1651
+ function Le(t) {
1652
+ const e = K(t);
1653
+ return gt(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : I(e) && $t(e) ? e : Le(e);
1654
+ }
1655
+ function vt(t, e, i) {
1656
+ var s;
1657
+ e === void 0 && (e = []), i === void 0 && (i = !0);
1658
+ const n = Le(t), o = n === ((s = t.ownerDocument) == null ? void 0 : s.body), r = T(n);
1659
+ if (o) {
1660
+ const l = Wt(r);
1661
+ return e.concat(r, r.visualViewport || [], $t(n) ? n : [], l && i ? vt(l) : []);
1662
+ }
1663
+ return e.concat(n, vt(n, [], i));
1664
+ }
1665
+ function Wt(t) {
1666
+ return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
1667
+ }
1668
+ function Oe(t) {
1669
+ const e = M(t);
1670
+ let i = parseFloat(e.width) || 0, s = parseFloat(e.height) || 0;
1671
+ const n = I(t), o = n ? t.offsetWidth : i, r = n ? t.offsetHeight : s, l = Lt(i) !== o || Lt(s) !== r;
1672
+ return l && (i = o, s = r), {
1673
+ width: i,
1674
+ height: s,
1675
+ $: l
1676
+ };
1767
1677
  }
1768
- const Ls = {
1769
- name: "hide",
1770
- enabled: !0,
1771
- phase: "main",
1772
- requiresIfExists: ["preventOverflow"],
1773
- fn: xs
1774
- };
1775
- function Os(t, e, n) {
1776
- var i = J(t), s = [j, W].indexOf(i) >= 0 ? -1 : 1, r = typeof n == "function" ? n(Object.assign({}, e, {
1777
- placement: t
1778
- })) : n, a = r[0], l = r[1];
1779
- return a = a || 0, l = (l || 0) * s, [j, R].indexOf(i) >= 0 ? {
1780
- x: l,
1781
- y: a
1782
- } : {
1783
- x: a,
1678
+ function qt(t) {
1679
+ return D(t) ? t : t.contextElement;
1680
+ }
1681
+ function st(t) {
1682
+ const e = qt(t);
1683
+ if (!I(e))
1684
+ return W(1);
1685
+ const i = e.getBoundingClientRect(), {
1686
+ width: s,
1687
+ height: n,
1688
+ $: o
1689
+ } = Oe(e);
1690
+ let r = (o ? Lt(i.width) : i.width) / s, l = (o ? Lt(i.height) : i.height) / n;
1691
+ return (!r || !Number.isFinite(r)) && (r = 1), (!l || !Number.isFinite(l)) && (l = 1), {
1692
+ x: r,
1784
1693
  y: l
1785
1694
  };
1786
1695
  }
1787
- function ks(t) {
1788
- var e = t.state, n = t.options, i = t.name, s = n.offset, r = s === void 0 ? [0, 0] : s, a = hn.reduce(function(d, b) {
1789
- return d[b] = Os(b, e.rects, r), d;
1790
- }, {}), l = a[e.placement], o = l.x, c = l.y;
1791
- e.modifiersData.popperOffsets != null && (e.modifiersData.popperOffsets.x += o, e.modifiersData.popperOffsets.y += c), e.modifiersData[i] = a;
1792
- }
1793
- const Ts = {
1794
- name: "offset",
1795
- enabled: !0,
1796
- phase: "main",
1797
- requires: ["popperOffsets"],
1798
- fn: ks
1799
- };
1800
- function As(t) {
1801
- var e = t.state, n = t.name;
1802
- e.modifiersData[n] = yn({
1803
- reference: e.rects.reference,
1804
- element: e.rects.popper,
1805
- strategy: "absolute",
1806
- placement: e.placement
1696
+ const Oi = /* @__PURE__ */ W(0);
1697
+ function Te(t) {
1698
+ const e = T(t);
1699
+ return !Qt() || !e.visualViewport ? Oi : {
1700
+ x: e.visualViewport.offsetLeft,
1701
+ y: e.visualViewport.offsetTop
1702
+ };
1703
+ }
1704
+ function Ti(t, e, i) {
1705
+ return e === void 0 && (e = !1), !i || e && i !== T(t) ? !1 : e;
1706
+ }
1707
+ function tt(t, e, i, s) {
1708
+ e === void 0 && (e = !1), i === void 0 && (i = !1);
1709
+ const n = t.getBoundingClientRect(), o = qt(t);
1710
+ let r = W(1);
1711
+ e && (s ? D(s) && (r = st(s)) : r = st(t));
1712
+ const l = Ti(o, i, s) ? Te(o) : W(0);
1713
+ let a = (n.left + l.x) / r.x, c = (n.top + l.y) / r.y, d = n.width / r.x, u = n.height / r.y;
1714
+ if (o) {
1715
+ const h = T(o), f = s && D(s) ? T(s) : s;
1716
+ let g = h, m = Wt(g);
1717
+ for (; m && s && f !== g; ) {
1718
+ const b = st(m), p = m.getBoundingClientRect(), y = M(m), x = p.left + (m.clientLeft + parseFloat(y.paddingLeft)) * b.x, S = p.top + (m.clientTop + parseFloat(y.paddingTop)) * b.y;
1719
+ a *= b.x, c *= b.y, d *= b.x, u *= b.y, a += x, c += S, g = T(m), m = Wt(g);
1720
+ }
1721
+ }
1722
+ return Tt({
1723
+ width: d,
1724
+ height: u,
1725
+ x: a,
1726
+ y: c
1807
1727
  });
1808
1728
  }
1809
- const Cs = {
1810
- name: "popperOffsets",
1811
- enabled: !0,
1812
- phase: "read",
1813
- fn: As,
1814
- data: {}
1815
- };
1816
- function Is(t) {
1817
- return t === "x" ? "y" : "x";
1729
+ function Pi(t) {
1730
+ let {
1731
+ elements: e,
1732
+ rect: i,
1733
+ offsetParent: s,
1734
+ strategy: n
1735
+ } = t;
1736
+ const o = n === "fixed", r = N(s), l = e ? Ft(e.floating) : !1;
1737
+ if (s === r || l && o)
1738
+ return i;
1739
+ let a = {
1740
+ scrollLeft: 0,
1741
+ scrollTop: 0
1742
+ }, c = W(1);
1743
+ const d = W(0), u = I(s);
1744
+ if ((u || !u && !o) && ((mt(s) !== "body" || $t(r)) && (a = It(s)), I(s))) {
1745
+ const h = tt(s);
1746
+ c = st(s), d.x = h.x + s.clientLeft, d.y = h.y + s.clientTop;
1747
+ }
1748
+ return {
1749
+ width: i.width * c.x,
1750
+ height: i.height * c.y,
1751
+ x: i.x * c.x - a.scrollLeft * c.x + d.x,
1752
+ y: i.y * c.y - a.scrollTop * c.y + d.y
1753
+ };
1818
1754
  }
1819
- function Ss(t) {
1820
- var e = t.state, n = t.options, i = t.name, s = n.mainAxis, r = s === void 0 ? !0 : s, a = n.altAxis, l = a === void 0 ? !1 : a, o = n.boundary, c = n.rootBoundary, d = n.altBoundary, b = n.padding, v = n.tether, h = v === void 0 ? !0 : v, $ = n.tetherOffset, u = $ === void 0 ? 0 : $, w = St(e, {
1821
- boundary: o,
1822
- rootBoundary: c,
1823
- padding: b,
1824
- altBoundary: d
1825
- }), E = J(e.placement), L = mt(e.placement), O = !L, f = be(E), y = Is(f), x = e.modifiersData.popperOffsets, k = e.rects.reference, T = e.rects.popper, A = typeof u == "function" ? u(Object.assign({}, e.rects, {
1826
- placement: e.placement
1827
- })) : u, C = typeof A == "number" ? {
1828
- mainAxis: A,
1829
- altAxis: A
1830
- } : Object.assign({
1831
- mainAxis: 0,
1832
- altAxis: 0
1833
- }, A), I = e.modifiersData.offset ? e.modifiersData.offset[e.placement] : null, H = {
1834
- x: 0,
1835
- y: 0
1755
+ function Ri(t) {
1756
+ return Array.from(t.getClientRects());
1757
+ }
1758
+ function Ut(t, e) {
1759
+ const i = It(t).scrollLeft;
1760
+ return e ? e.left + i : tt(N(t)).left + i;
1761
+ }
1762
+ function Di(t) {
1763
+ const e = N(t), i = It(t), s = t.ownerDocument.body, n = Z(e.scrollWidth, e.clientWidth, s.scrollWidth, s.clientWidth), o = Z(e.scrollHeight, e.clientHeight, s.scrollHeight, s.clientHeight);
1764
+ let r = -i.scrollLeft + Ut(t);
1765
+ const l = -i.scrollTop;
1766
+ return M(s).direction === "rtl" && (r += Z(e.clientWidth, s.clientWidth) - n), {
1767
+ width: n,
1768
+ height: o,
1769
+ x: r,
1770
+ y: l
1836
1771
  };
1837
- if (x) {
1838
- if (r) {
1839
- var P, U = f === "y" ? W : j, X = f === "y" ? B : R, N = f === "y" ? "height" : "width", V = x[f], qt = V + w[U], Y = V - w[X], Mt = h ? -T[N] / 2 : 0, Zt = L === ft ? k[N] : T[N], vt = L === ft ? -T[N] : -k[N], Wt = e.elements.arrow, tt = h && Wt ? ve(Wt) : {
1840
- width: 0,
1841
- height: 0
1842
- }, K = e.modifiersData["arrow#persistent"] ? e.modifiersData["arrow#persistent"].padding : gn(), jt = K[U], bt = K[X], ot = At(0, k[N], tt[N]), En = O ? k[N] / 2 - Mt - ot - jt - C.mainAxis : Zt - ot - jt - C.mainAxis, xn = O ? -k[N] / 2 + Mt + ot + bt + C.mainAxis : vt + ot + bt + C.mainAxis, Ut = e.elements.arrow && Pt(e.elements.arrow), Ln = Ut ? f === "y" ? Ut.clientTop || 0 : Ut.clientLeft || 0 : 0, xe = (P = I == null ? void 0 : I[f]) != null ? P : 0, On = V + En - xe - Ln, kn = V + xn - xe, Le = At(h ? zt(qt, On) : qt, V, h ? st(Y, kn) : Y);
1843
- x[f] = Le, H[f] = Le - V;
1844
- }
1845
- if (l) {
1846
- var Oe, Tn = f === "x" ? W : j, An = f === "x" ? B : R, et = x[y], Nt = y === "y" ? "height" : "width", ke = et + w[Tn], Te = et - w[An], Xt = [W, j].indexOf(E) !== -1, Ae = (Oe = I == null ? void 0 : I[y]) != null ? Oe : 0, Ce = Xt ? ke : et - k[Nt] - T[Nt] - Ae + C.altAxis, Ie = Xt ? et + k[Nt] + T[Nt] - Ae - C.altAxis : Te, Se = h && Xt ? es(Ce, et, Ie) : At(h ? Ce : ke, et, h ? Ie : Te);
1847
- x[y] = Se, H[y] = Se - et;
1848
- }
1849
- e.modifiersData[i] = H;
1772
+ }
1773
+ function Mi(t, e) {
1774
+ const i = T(t), s = N(t), n = i.visualViewport;
1775
+ let o = s.clientWidth, r = s.clientHeight, l = 0, a = 0;
1776
+ if (n) {
1777
+ o = n.width, r = n.height;
1778
+ const c = Qt();
1779
+ (!c || c && e === "fixed") && (l = n.offsetLeft, a = n.offsetTop);
1850
1780
  }
1781
+ return {
1782
+ width: o,
1783
+ height: r,
1784
+ x: l,
1785
+ y: a
1786
+ };
1851
1787
  }
1852
- const Ds = {
1853
- name: "preventOverflow",
1854
- enabled: !0,
1855
- phase: "main",
1856
- fn: Ss,
1857
- requiresIfExists: ["offset"]
1858
- };
1859
- function Ps(t) {
1788
+ function Fi(t, e) {
1789
+ const i = tt(t, !0, e === "fixed"), s = i.top + t.clientTop, n = i.left + t.clientLeft, o = I(t) ? st(t) : W(1), r = t.clientWidth * o.x, l = t.clientHeight * o.y, a = n * o.x, c = s * o.y;
1860
1790
  return {
1861
- scrollLeft: t.scrollLeft,
1862
- scrollTop: t.scrollTop
1791
+ width: r,
1792
+ height: l,
1793
+ x: a,
1794
+ y: c
1863
1795
  };
1864
1796
  }
1865
- function qs(t) {
1866
- return t === _(t) || !F(t) ? ye(t) : Ps(t);
1797
+ function oe(t, e, i) {
1798
+ let s;
1799
+ if (e === "viewport")
1800
+ s = Mi(t, i);
1801
+ else if (e === "document")
1802
+ s = Di(N(t));
1803
+ else if (D(e))
1804
+ s = Fi(e, i);
1805
+ else {
1806
+ const n = Te(t);
1807
+ s = {
1808
+ ...e,
1809
+ x: e.x - n.x,
1810
+ y: e.y - n.y
1811
+ };
1812
+ }
1813
+ return Tt(s);
1814
+ }
1815
+ function Pe(t, e) {
1816
+ const i = K(t);
1817
+ return i === e || !D(i) || gt(i) ? !1 : M(i).position === "fixed" || Pe(i, e);
1818
+ }
1819
+ function Ii(t, e) {
1820
+ const i = e.get(t);
1821
+ if (i)
1822
+ return i;
1823
+ let s = vt(t, [], !1).filter((l) => D(l) && mt(l) !== "body"), n = null;
1824
+ const o = M(t).position === "fixed";
1825
+ let r = o ? K(t) : t;
1826
+ for (; D(r) && !gt(r); ) {
1827
+ const l = M(r), a = Zt(r);
1828
+ !a && l.position === "fixed" && (n = null), (o ? !a && !n : !a && l.position === "static" && !!n && ["absolute", "fixed"].includes(n.position) || $t(r) && !a && Pe(t, r)) ? s = s.filter((d) => d !== r) : n = l, r = K(r);
1829
+ }
1830
+ return e.set(t, s), s;
1831
+ }
1832
+ function Ni(t) {
1833
+ let {
1834
+ element: e,
1835
+ boundary: i,
1836
+ rootBoundary: s,
1837
+ strategy: n
1838
+ } = t;
1839
+ const r = [...i === "clippingAncestors" ? Ft(e) ? [] : Ii(e, this._c) : [].concat(i), s], l = r[0], a = r.reduce((c, d) => {
1840
+ const u = oe(e, d, n);
1841
+ return c.top = Z(u.top, c.top), c.right = ht(u.right, c.right), c.bottom = ht(u.bottom, c.bottom), c.left = Z(u.left, c.left), c;
1842
+ }, oe(e, l, n));
1843
+ return {
1844
+ width: a.right - a.left,
1845
+ height: a.bottom - a.top,
1846
+ x: a.left,
1847
+ y: a.top
1848
+ };
1867
1849
  }
1868
- function Ms(t) {
1869
- var e = t.getBoundingClientRect(), n = pt(e.width) / t.offsetWidth || 1, i = pt(e.height) / t.offsetHeight || 1;
1870
- return n !== 1 || i !== 1;
1850
+ function Bi(t) {
1851
+ const {
1852
+ width: e,
1853
+ height: i
1854
+ } = Oe(t);
1855
+ return {
1856
+ width: e,
1857
+ height: i
1858
+ };
1871
1859
  }
1872
- function Ws(t, e, n) {
1873
- n === void 0 && (n = !1);
1874
- var i = F(e), s = F(e) && Ms(e), r = Z(e), a = gt(t, s, n), l = {
1860
+ function Vi(t, e, i) {
1861
+ const s = I(e), n = N(e), o = i === "fixed", r = tt(t, !0, o, e);
1862
+ let l = {
1875
1863
  scrollLeft: 0,
1876
1864
  scrollTop: 0
1877
- }, o = {
1878
- x: 0,
1879
- y: 0
1880
1865
  };
1881
- return (i || !i && !n) && ((z(e) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
1882
- $e(r)) && (l = qs(e)), F(e) ? (o = gt(e, !0), o.x += e.clientLeft, o.y += e.clientTop) : r && (o.x = we(r))), {
1883
- x: a.left + l.scrollLeft - o.x,
1884
- y: a.top + l.scrollTop - o.y,
1885
- width: a.width,
1886
- height: a.height
1866
+ const a = W(0);
1867
+ if (s || !s && !o)
1868
+ if ((mt(e) !== "body" || $t(n)) && (l = It(e)), s) {
1869
+ const f = tt(e, !0, o, e);
1870
+ a.x = f.x + e.clientLeft, a.y = f.y + e.clientTop;
1871
+ } else n && (a.x = Ut(n));
1872
+ let c = 0, d = 0;
1873
+ if (n && !s && !o) {
1874
+ const f = n.getBoundingClientRect();
1875
+ d = f.top + l.scrollTop, c = f.left + l.scrollLeft - // RTL <body> scrollbar.
1876
+ Ut(n, f);
1877
+ }
1878
+ const u = r.left + l.scrollLeft - a.x - c, h = r.top + l.scrollTop - a.y - d;
1879
+ return {
1880
+ x: u,
1881
+ y: h,
1882
+ width: r.width,
1883
+ height: r.height
1887
1884
  };
1888
1885
  }
1889
- function js(t) {
1890
- var e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), i = [];
1891
- t.forEach(function(r) {
1892
- e.set(r.name, r);
1893
- });
1894
- function s(r) {
1895
- n.add(r.name);
1896
- var a = [].concat(r.requires || [], r.requiresIfExists || []);
1897
- a.forEach(function(l) {
1898
- if (!n.has(l)) {
1899
- var o = e.get(l);
1900
- o && s(o);
1901
- }
1902
- }), i.push(r);
1903
- }
1904
- return t.forEach(function(r) {
1905
- n.has(r.name) || s(r);
1906
- }), i;
1886
+ function Bt(t) {
1887
+ return M(t).position === "static";
1907
1888
  }
1908
- function Ns(t) {
1909
- var e = js(t);
1910
- return Qi.reduce(function(n, i) {
1911
- return n.concat(e.filter(function(s) {
1912
- return s.phase === i;
1913
- }));
1914
- }, []);
1889
+ function re(t, e) {
1890
+ if (!I(t) || M(t).position === "fixed")
1891
+ return null;
1892
+ if (e)
1893
+ return e(t);
1894
+ let i = t.offsetParent;
1895
+ return N(t) === i && (i = i.ownerDocument.body), i;
1896
+ }
1897
+ function Re(t, e) {
1898
+ const i = T(t);
1899
+ if (Ft(t))
1900
+ return i;
1901
+ if (!I(t)) {
1902
+ let n = K(t);
1903
+ for (; n && !gt(n); ) {
1904
+ if (D(n) && !Bt(n))
1905
+ return n;
1906
+ n = K(n);
1907
+ }
1908
+ return i;
1909
+ }
1910
+ let s = re(t, e);
1911
+ for (; s && ki(s) && Bt(s); )
1912
+ s = re(s, e);
1913
+ return s && gt(s) && Bt(s) && !Zt(s) ? i : s || Li(t) || i;
1915
1914
  }
1916
- function _s(t) {
1917
- var e;
1918
- return function() {
1919
- return e || (e = new Promise(function(n) {
1920
- Promise.resolve().then(function() {
1921
- e = void 0, n(t());
1922
- });
1923
- })), e;
1915
+ const Hi = async function(t) {
1916
+ const e = this.getOffsetParent || Re, i = this.getDimensions, s = await i(t.floating);
1917
+ return {
1918
+ reference: Vi(t.reference, await e(t.floating), t.strategy),
1919
+ floating: {
1920
+ x: 0,
1921
+ y: 0,
1922
+ width: s.width,
1923
+ height: s.height
1924
+ }
1924
1925
  };
1925
- }
1926
- function Fs(t) {
1927
- var e = t.reduce(function(n, i) {
1928
- var s = n[i.name];
1929
- return n[i.name] = s ? Object.assign({}, s, i, {
1930
- options: Object.assign({}, s.options, i.options),
1931
- data: Object.assign({}, s.data, i.data)
1932
- }) : i, n;
1933
- }, {});
1934
- return Object.keys(e).map(function(n) {
1935
- return e[n];
1936
- });
1937
- }
1938
- var Je = {
1939
- placement: "bottom",
1940
- modifiers: [],
1941
- strategy: "absolute"
1942
1926
  };
1943
- function ze() {
1944
- for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
1945
- e[n] = arguments[n];
1946
- return !e.some(function(i) {
1947
- return !(i && typeof i.getBoundingClientRect == "function");
1948
- });
1949
- }
1950
- function Bs(t) {
1951
- t === void 0 && (t = {});
1952
- var e = t, n = e.defaultModifiers, i = n === void 0 ? [] : n, s = e.defaultOptions, r = s === void 0 ? Je : s;
1953
- return function(a, l, o) {
1954
- o === void 0 && (o = r);
1955
- var c = {
1956
- placement: "bottom",
1957
- orderedModifiers: [],
1958
- options: Object.assign({}, Je, r),
1959
- modifiersData: {},
1960
- elements: {
1961
- reference: a,
1962
- popper: l
1963
- },
1964
- attributes: {},
1965
- styles: {}
1966
- }, d = [], b = !1, v = {
1967
- state: c,
1968
- setOptions: function(u) {
1969
- var w = typeof u == "function" ? u(c.options) : u;
1970
- $(), c.options = Object.assign({}, r, c.options, w), c.scrollParents = {
1971
- reference: rt(a) ? Ct(a) : a.contextElement ? Ct(a.contextElement) : [],
1972
- popper: Ct(l)
1973
- };
1974
- var E = Ns(Fs([].concat(i, c.options.modifiers)));
1975
- return c.orderedModifiers = E.filter(function(L) {
1976
- return L.enabled;
1977
- }), h(), v.update();
1978
- },
1979
- // Sync update – it will always be executed, even if not necessary. This
1980
- // is useful for low frequency updates where sync behavior simplifies the
1981
- // logic.
1982
- // For high frequency updates (e.g. `resize` and `scroll` events), always
1983
- // prefer the async Popper#update method
1984
- forceUpdate: function() {
1985
- if (!b) {
1986
- var u = c.elements, w = u.reference, E = u.popper;
1987
- if (ze(w, E)) {
1988
- c.rects = {
1989
- reference: Ws(w, Pt(E), c.options.strategy === "fixed"),
1990
- popper: ve(E)
1991
- }, c.reset = !1, c.placement = c.options.placement, c.orderedModifiers.forEach(function(T) {
1992
- return c.modifiersData[T.name] = Object.assign({}, T.data);
1993
- });
1994
- for (var L = 0; L < c.orderedModifiers.length; L++) {
1995
- if (c.reset === !0) {
1996
- c.reset = !1, L = -1;
1997
- continue;
1998
- }
1999
- var O = c.orderedModifiers[L], f = O.fn, y = O.options, x = y === void 0 ? {} : y, k = O.name;
2000
- typeof f == "function" && (c = f({
2001
- state: c,
2002
- options: x,
2003
- name: k,
2004
- instance: v
2005
- }) || c);
2006
- }
2007
- }
2008
- }
2009
- },
2010
- // Async and optimistically optimized update – it will not be executed if
2011
- // not necessary (debounced to run at most once-per-tick)
2012
- update: _s(function() {
2013
- return new Promise(function(u) {
2014
- v.forceUpdate(), u(c);
2015
- });
2016
- }),
2017
- destroy: function() {
2018
- $(), b = !0;
2019
- }
1927
+ function _i(t) {
1928
+ return M(t).direction === "rtl";
1929
+ }
1930
+ const zi = {
1931
+ convertOffsetParentRelativeRectToViewportRelativeRect: Pi,
1932
+ getDocumentElement: N,
1933
+ getClippingRect: Ni,
1934
+ getOffsetParent: Re,
1935
+ getElementRects: Hi,
1936
+ getClientRects: Ri,
1937
+ getDimensions: Bi,
1938
+ getScale: st,
1939
+ isElement: D,
1940
+ isRTL: _i
1941
+ };
1942
+ function Wi(t, e) {
1943
+ let i = null, s;
1944
+ const n = N(t);
1945
+ function o() {
1946
+ var l;
1947
+ clearTimeout(s), (l = i) == null || l.disconnect(), i = null;
1948
+ }
1949
+ function r(l, a) {
1950
+ l === void 0 && (l = !1), a === void 0 && (a = 1), o();
1951
+ const {
1952
+ left: c,
1953
+ top: d,
1954
+ width: u,
1955
+ height: h
1956
+ } = t.getBoundingClientRect();
1957
+ if (l || e(), !u || !h)
1958
+ return;
1959
+ const f = kt(d), g = kt(n.clientWidth - (c + u)), m = kt(n.clientHeight - (d + h)), b = kt(c), y = {
1960
+ rootMargin: -f + "px " + -g + "px " + -m + "px " + -b + "px",
1961
+ threshold: Z(0, ht(1, a)) || 1
2020
1962
  };
2021
- if (!ze(a, l))
2022
- return v;
2023
- v.setOptions(o).then(function(u) {
2024
- !b && o.onFirstUpdate && o.onFirstUpdate(u);
2025
- });
2026
- function h() {
2027
- c.orderedModifiers.forEach(function(u) {
2028
- var w = u.name, E = u.options, L = E === void 0 ? {} : E, O = u.effect;
2029
- if (typeof O == "function") {
2030
- var f = O({
2031
- state: c,
2032
- name: w,
2033
- instance: v,
2034
- options: L
2035
- }), y = function() {
2036
- };
2037
- d.push(f || y);
2038
- }
2039
- });
1963
+ let x = !0;
1964
+ function S(v) {
1965
+ const k = v[0].intersectionRatio;
1966
+ if (k !== a) {
1967
+ if (!x)
1968
+ return r();
1969
+ k ? r(!1, k) : s = setTimeout(() => {
1970
+ r(!1, 1e-7);
1971
+ }, 1e3);
1972
+ }
1973
+ x = !1;
2040
1974
  }
2041
- function $() {
2042
- d.forEach(function(u) {
2043
- return u();
2044
- }), d = [];
1975
+ try {
1976
+ i = new IntersectionObserver(S, {
1977
+ ...y,
1978
+ // Handle <iframe>s
1979
+ root: n.ownerDocument
1980
+ });
1981
+ } catch {
1982
+ i = new IntersectionObserver(S, y);
2045
1983
  }
2046
- return v;
1984
+ i.observe(t);
1985
+ }
1986
+ return r(!0), o;
1987
+ }
1988
+ function Ui(t, e, i, s) {
1989
+ s === void 0 && (s = {});
1990
+ const {
1991
+ ancestorScroll: n = !0,
1992
+ ancestorResize: o = !0,
1993
+ elementResize: r = typeof ResizeObserver == "function",
1994
+ layoutShift: l = typeof IntersectionObserver == "function",
1995
+ animationFrame: a = !1
1996
+ } = s, c = qt(t), d = n || o ? [...c ? vt(c) : [], ...vt(e)] : [];
1997
+ d.forEach((p) => {
1998
+ n && p.addEventListener("scroll", i, {
1999
+ passive: !0
2000
+ }), o && p.addEventListener("resize", i);
2001
+ });
2002
+ const u = c && l ? Wi(c, i) : null;
2003
+ let h = -1, f = null;
2004
+ r && (f = new ResizeObserver((p) => {
2005
+ let [y] = p;
2006
+ y && y.target === c && f && (f.unobserve(e), cancelAnimationFrame(h), h = requestAnimationFrame(() => {
2007
+ var x;
2008
+ (x = f) == null || x.observe(e);
2009
+ })), i();
2010
+ }), c && !a && f.observe(c), f.observe(e));
2011
+ let g, m = a ? tt(t) : null;
2012
+ a && b();
2013
+ function b() {
2014
+ const p = tt(t);
2015
+ m && (p.x !== m.x || p.y !== m.y || p.width !== m.width || p.height !== m.height) && i(), m = p, g = requestAnimationFrame(b);
2016
+ }
2017
+ return i(), () => {
2018
+ var p;
2019
+ d.forEach((y) => {
2020
+ n && y.removeEventListener("scroll", i), o && y.removeEventListener("resize", i);
2021
+ }), u == null || u(), (p = f) == null || p.disconnect(), f = null, a && cancelAnimationFrame(g);
2047
2022
  };
2048
2023
  }
2049
- var Rs = [us, Cs, cs, Xi, Ts, Es, Ds, rs, Ls], Hs = /* @__PURE__ */ Bs({
2050
- defaultModifiers: Rs
2051
- });
2052
- async function ae(t) {
2053
- if (!t)
2054
- return this.collection;
2055
- const e = this.collection.findIndex((n) => n.id === t.id);
2056
- if (e >= 0) {
2057
- const n = this.collection[e];
2058
- n.state === "opened" && n.close(), n.popper.destroy(), wn(n), Object.getOwnPropertyNames(n).forEach((i) => {
2059
- delete n[i];
2060
- }), this.collection.splice(e, 1);
2061
- }
2062
- return this.collection;
2063
- }
2064
- function wn(t) {
2065
- return t.__eventListeners && (t.__eventListeners.forEach((e) => {
2066
- e.el.forEach((n) => {
2067
- e.type.forEach((i) => {
2068
- t[n].removeEventListener(i, e.listener, !1);
2069
- });
2070
- });
2071
- }), delete t.__eventListeners), t;
2072
- }
2073
- async function Ee(t) {
2074
- const e = on.call(this, t);
2075
- return e.el.classList.add(this.settings.stateActive), e.trigger.hasAttribute("aria-controls") && e.trigger.setAttribute("aria-expanded", "true"), e.config = rn(e.el, this.settings), e.popper.setOptions({
2076
- placement: e.config.placement,
2077
- modifiers: [
2078
- { name: "eventListeners", enabled: !0 },
2079
- ...qi(e.config)
2080
- ]
2081
- }), e.popper.update(), e.state = "opened", e;
2082
- }
2083
- async function Vs(t, e) {
2084
- ae.call(this, t);
2085
- const n = this, i = {
2086
- open() {
2087
- return Ee.call(n, this);
2088
- },
2089
- close() {
2090
- return pe.call(n, this);
2091
- },
2092
- deregister() {
2093
- return ae.call(n, this);
2094
- }
2095
- }, s = {
2096
- id: t.id,
2097
- state: "closed",
2098
- el: t,
2099
- trigger: e,
2100
- popper: Hs(e, t),
2101
- config: rn(t, this.settings),
2024
+ const Ki = Ci, ji = Ai, Xi = Si, Yi = vi, Gi = $i, Ji = (t, e, i) => {
2025
+ const s = /* @__PURE__ */ new Map(), n = {
2026
+ platform: zi,
2102
2027
  ...i
2028
+ }, o = {
2029
+ ...n.platform,
2030
+ _c: s
2103
2031
  };
2104
- return s.trigger.hasAttribute("aria-controls") && s.trigger.setAttribute("aria-expanded", "false"), $n.call(this, s), this.collection.push(s), s.el.classList.contains(this.settings.stateActive) && (await s.open(), dn.call(this, s)), s;
2105
- }
2106
- function $n(t) {
2107
- return t.__eventListeners || (t.config.event === "hover" ? (t.__eventListeners = [{
2108
- el: ["trigger"],
2109
- type: ["mouseenter", "focus"],
2110
- listener: Ee.bind(this, t)
2111
- }, {
2112
- el: ["el", "trigger"],
2113
- type: ["mouseleave", "focusout"],
2114
- listener: cn.bind(this, t)
2115
- }], t.__eventListeners.forEach((e) => {
2116
- e.el.forEach((n) => {
2117
- e.type.forEach((i) => {
2118
- t[n].addEventListener(i, e.listener, !1);
2119
- });
2120
- });
2121
- })) : (t.__eventListeners = [{
2122
- el: ["trigger"],
2123
- type: ["click"],
2124
- listener: Wi.bind(this, t)
2125
- }], t.__eventListeners.forEach((e) => {
2126
- e.el.forEach((n) => {
2127
- e.type.forEach((i) => {
2128
- t[n].addEventListener(i, e.listener, !1);
2129
- });
2032
+ return xi(t, e, {
2033
+ ...n,
2034
+ platform: o
2035
+ });
2036
+ };
2037
+ async function Zi(t) {
2038
+ const e = ve.call(this, t);
2039
+ e.el.inert = !1, e.el.classList.add(this.settings.stateActive), e.isTooltip || e.trigger.setAttribute("aria-expanded", "true"), e.getCustomProps();
2040
+ const i = oi(e), s = e.el.querySelector(i.arrow.element);
2041
+ return i.arrow.element = s || void 0, e.floatingCleanup = Ui(e.trigger, e.el, () => {
2042
+ Ji(e.trigger, e.el, {
2043
+ placement: e.getSetting("placement"),
2044
+ middleware: [
2045
+ Xi(i.flip),
2046
+ ji({ ...i.shift, limiter: Gi() }),
2047
+ Ki(i.offset),
2048
+ Yi(i.arrow)
2049
+ ]
2050
+ }).then(({ x: n, y: o, placement: r, middlewareData: l }) => {
2051
+ if (e.el) {
2052
+ if (ie(e.el, n, o), i.arrow.element && l.arrow) {
2053
+ const { x: a, y: c } = l.arrow;
2054
+ ie(i.arrow.element, a, c);
2055
+ }
2056
+ e.el.setAttribute("data-floating-placement", r);
2057
+ }
2130
2058
  });
2131
- }))), t;
2059
+ }), e.state = "opened", e.getSetting("event") === "click" && ui.call(this, e), e;
2132
2060
  }
2133
- var Tt;
2134
- class nr extends Si {
2135
- constructor(e) {
2136
- super(), Ci(this, Tt, void 0), this.defaults = Pi, this.settings = { ...this.defaults, ...e }, this.trigger = null, Ii(this, Tt, ji.bind(this)), this.settings.autoInit && this.init();
2061
+ var dt;
2062
+ class is extends Rt {
2063
+ constructor(i = {}) {
2064
+ super({ ...ni, ...i });
2065
+ $(this, dt);
2066
+ this.trigger = null, E(this, dt, fi.bind(this));
2137
2067
  }
2138
- async init(e) {
2139
- e && (this.settings = { ...this.settings, ...e });
2140
- const n = document.querySelectorAll(this.settings.selectorPopover);
2141
- return await this.registerCollection(n), this.settings.eventListeners && this.initEventListeners(!1), this;
2068
+ get active() {
2069
+ return this.get("opened", "state");
2142
2070
  }
2143
- async destroy() {
2144
- return this.trigger = null, await this.deregisterCollection(), this.settings.eventListeners && this.destroyEventListeners(!1), this;
2071
+ get activeHover() {
2072
+ return this.collection.find((i) => i.state == "opened" && i.getSetting("event") == "hover");
2145
2073
  }
2146
- initEventListeners(e = !0) {
2147
- e && this.collection.forEach((n) => {
2148
- $n.call(this, n);
2149
- }), document.addEventListener("keydown", je(this, Tt), !1);
2074
+ async createEntry(i, s) {
2075
+ return new di(this, i, s);
2150
2076
  }
2151
- destroyEventListeners(e = !0) {
2152
- e && this.collection.forEach((n) => {
2153
- wn(n);
2154
- }), document.removeEventListener("keydown", je(this, Tt), !1);
2077
+ async open(i) {
2078
+ return Zi.call(this, i);
2155
2079
  }
2156
- register(e) {
2157
- const n = Mi.call(this, e);
2158
- return n.error ? Promise.reject(n.error) : Vs.call(this, n.popover, n.trigger);
2080
+ async close(i) {
2081
+ return Se.call(this, i);
2159
2082
  }
2160
- deregister(e) {
2161
- const n = this.get(an.call(this, e));
2162
- return ae.call(this, n);
2083
+ async afterMount() {
2084
+ document.addEventListener("keydown", w(this, dt), !1);
2163
2085
  }
2164
- open(e) {
2165
- return Ee.call(this, e);
2086
+ async beforeUnmount() {
2087
+ this.trigger = null;
2166
2088
  }
2167
- close(e) {
2168
- return pe.call(this, e);
2089
+ async afterUnmount() {
2090
+ document.removeEventListener("keydown", w(this, dt), !1);
2169
2091
  }
2170
2092
  }
2171
- Tt = /* @__PURE__ */ new WeakMap();
2093
+ dt = new WeakMap();
2172
2094
  export {
2173
- Xs as Drawer,
2174
- er as Modal,
2175
- nr as Popover,
2176
- Gs as core
2095
+ ts as Drawer,
2096
+ es as Modal,
2097
+ is as Popover,
2098
+ qi as core
2177
2099
  };
2178
2100
  //# sourceMappingURL=index.js.map