vrembem 4.0.0-next.12 → 4.0.0-next.13

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/dev/index.umd.cjs CHANGED
@@ -1,291 +1,136 @@
1
1
  (function(global, factory) {
2
2
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.vrembem = {}));
3
3
  })(this, function(exports2) {
4
- "use strict";
5
- var b$2 = (t) => {
6
- throw TypeError(t);
7
- };
8
- var g$2 = (t, e, n) => e.has(t) || b$2("Cannot " + n);
9
- var o$2 = (t, e, n) => (g$2(t, e, "read from private field"), n ? n.call(t) : e.get(t)), m$2 = (t, e, n) => e.has(t) ? b$2("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), a$1 = (t, e, n, i) => (g$2(t, e, "write to private field"), e.set(t, n), n);
10
- var l$1;
11
- let L$2 = class L {
12
- constructor(e, n) {
13
- m$2(this, l$1);
14
- this.value = e, a$1(this, l$1, n), this.mql = null;
4
+ "use strict";var __typeError = (msg) => {
5
+ throw TypeError(msg);
6
+ };
7
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
+
12
+ var _handler, _focusable, _handleFocusTrap, _handleFocusLock, _handleClick, _handleKeydown, _handleClick2, _handleKeydown2, _handleKeydown3;
13
+ class Breakpoint {
14
+ constructor(value, handler) {
15
+ __privateAdd(this, _handler);
16
+ this.value = value;
17
+ __privateSet(this, _handler, handler);
18
+ this.mql = null;
15
19
  }
16
20
  get handler() {
17
- return o$2(this, l$1);
21
+ return __privateGet(this, _handler);
18
22
  }
19
23
  // Unmount existing handler before setting a new one.
20
- set handler(e) {
21
- this.mql && this.mql.removeEventListener("change", o$2(this, l$1)), a$1(this, l$1, e);
22
- }
23
- mount(e, n) {
24
- return e && (this.value = e), n && a$1(this, l$1, n), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), this.mql.addEventListener("change", o$2(this, l$1)), o$2(this, l$1).call(this, this.mql), this) : this;
25
- }
26
- unmount() {
27
- return this.mql ? (this.mql.removeEventListener("change", o$2(this, l$1)), this.value = null, a$1(this, l$1, null), this.mql = null, this) : this;
28
- }
29
- };
30
- l$1 = /* @__PURE__ */ new WeakMap();
31
- let S$3 = class S {
32
- constructor() {
33
- this.collection = [];
34
- }
35
- async register(e) {
36
- return await this.deregister(e), this.collection.push(e), this.collection;
37
- }
38
- async deregister(e) {
39
- const n = this.collection.findIndex((i) => i === e);
40
- if (n >= 0) {
41
- const i = this.collection[n];
42
- Object.getOwnPropertyNames(i).forEach((r) => {
43
- delete i[r];
44
- }), this.collection.splice(n, 1);
24
+ set handler(func) {
25
+ if (this.mql) {
26
+ this.mql.removeEventListener("change", __privateGet(this, _handler));
45
27
  }
46
- return this.collection;
28
+ __privateSet(this, _handler, func);
47
29
  }
48
- async registerCollection(e) {
49
- return await Promise.all(Array.from(e, (n) => {
50
- this.register(n);
51
- })), this.collection;
52
- }
53
- async deregisterCollection() {
54
- for (; this.collection.length > 0; )
55
- await this.deregister(this.collection[0]);
56
- return this.collection;
57
- }
58
- get(e, n = "id") {
59
- return this.collection.find((i) => i[n] === e);
60
- }
61
- };
62
- const s = {
63
- inert: ":not([inert]):not([inert] *)",
64
- negTabIndex: ':not([tabindex^="-"])',
65
- disabled: ":not(:disabled)"
66
- }, $$2 = [
67
- `a[href]${s.inert}${s.negTabIndex}`,
68
- `area[href]${s.inert}${s.negTabIndex}`,
69
- `input:not([type="hidden"]):not([type="radio"])${s.inert}${s.negTabIndex}${s.disabled}`,
70
- `input[type="radio"]${s.inert}${s.negTabIndex}${s.disabled}`,
71
- `select${s.inert}${s.negTabIndex}${s.disabled}`,
72
- `textarea${s.inert}${s.negTabIndex}${s.disabled}`,
73
- `button${s.inert}${s.negTabIndex}${s.disabled}`,
74
- `details${s.inert} > summary:first-of-type${s.negTabIndex}`,
75
- // Discard until Firefox supports `:has()`
76
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
77
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
78
- `iframe${s.inert}${s.negTabIndex}`,
79
- `audio[controls]${s.inert}${s.negTabIndex}`,
80
- `video[controls]${s.inert}${s.negTabIndex}`,
81
- `[contenteditable]${s.inert}${s.negTabIndex}`,
82
- `[tabindex]${s.inert}${s.negTabIndex}`
83
- ];
84
- var f$2, u$1, d$2;
85
- let q$2 = class q {
86
- constructor(e = null, n = "[data-focus]") {
87
- m$2(this, f$2);
88
- m$2(this, u$1);
89
- m$2(this, d$2);
90
- this.el = e, this.selectorFocus = n, a$1(this, u$1, v$2.bind(this)), a$1(this, d$2, y$2.bind(this));
91
- }
92
- get focusable() {
93
- return o$2(this, f$2);
94
- }
95
- set focusable(e) {
96
- a$1(this, f$2, e), o$2(this, f$2).length ? (document.removeEventListener("keydown", o$2(this, d$2)), document.addEventListener("keydown", o$2(this, u$1))) : (document.removeEventListener("keydown", o$2(this, u$1)), document.addEventListener("keydown", o$2(this, d$2)));
97
- }
98
- get focusableFirst() {
99
- return this.focusable[0];
100
- }
101
- get focusableLast() {
102
- return this.focusable[this.focusable.length - 1];
103
- }
104
- mount(e, n) {
105
- e && (this.el = e), n && (this.selectorFocus = n), this.focusable = this.getFocusable(), this.focus();
30
+ mount(value, handler) {
31
+ if (value) this.value = value;
32
+ if (handler) __privateSet(this, _handler, handler);
33
+ if (!this.value) return this;
34
+ this.mql = window.matchMedia(`(min-width: ${this.value})`);
35
+ this.mql.addEventListener("change", __privateGet(this, _handler));
36
+ __privateGet(this, _handler).call(this, this.mql);
37
+ return this;
106
38
  }
107
39
  unmount() {
108
- this.el = null, this.focusable = [], document.removeEventListener("keydown", o$2(this, u$1)), document.removeEventListener("keydown", o$2(this, d$2));
109
- }
110
- focus(e = this.el, n = this.selectorFocus) {
111
- (e.querySelector(n) || e).focus();
112
- }
113
- getFocusable(e = this.el) {
114
- const n = [], i = document.activeElement, r = e.scrollTop;
115
- return e.querySelectorAll($$2.join(",")).forEach((h2) => {
116
- h2.focus(), document.activeElement === h2 && n.push(h2);
117
- }), e.scrollTop = r, i.focus(), n;
118
- }
119
- };
120
- f$2 = /* @__PURE__ */ new WeakMap(), u$1 = /* @__PURE__ */ new WeakMap(), d$2 = /* @__PURE__ */ new WeakMap();
121
- function v$2(t) {
122
- (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()));
123
- }
124
- function y$2(t) {
125
- (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
126
- }
127
- function T$2() {
128
- return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
129
- }
130
- function E$2(t, e = document.body) {
131
- if (t.slice(0, 2) !== "--") {
132
- const i = T$2();
133
- i && (t = `${i}${t}`), t = `--${t}`;
40
+ if (!this.mql) return this;
41
+ this.mql.removeEventListener("change", __privateGet(this, _handler));
42
+ this.value = null;
43
+ __privateSet(this, _handler, null);
44
+ this.mql = null;
45
+ return this;
134
46
  }
135
- const n = getComputedStyle(e).getPropertyValue(t).trim();
136
- if (n)
137
- return n;
138
- throw new Error(`CSS variable "${t}" was not found!`);
139
- }
140
- function F$3(t, e) {
141
- const i = (t.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
142
- return i ? JSON.parse(i) : {};
143
- }
144
- function k$3(t, e = true) {
145
- const n = localStorage.getItem(t), i = n ? JSON.parse(n) : {};
146
- return {
147
- get(r) {
148
- return r ? i[r] : i;
149
- },
150
- set(r, c2) {
151
- return c2 ? i[r] = c2 : delete i[r], e && localStorage.setItem(t, JSON.stringify(i)), i;
152
- }
153
- };
154
- }
155
- function w$2(t, e, n) {
156
- const i = e.nodeType === Node.COMMENT_NODE, r = e.nodeType === Node.ELEMENT_NODE;
157
- if (e = i || r ? e : document.querySelector(e), i && (n = "after"), !e) throw new Error(`Not a valid teleport reference: '${e}'`);
158
- if (typeof e[n] != "function") throw new Error(`Not a valid teleport method: '${n}'`);
159
- let c2 = null;
160
- return i || (c2 = document.createComment("teleported #" + t.id), t.before(c2)), e[n](t), i && e.remove(), c2;
161
- }
162
- function C$2(t, e, n, i = "transition-duration") {
163
- return new Promise((r) => {
164
- if (typeof i == "string") {
165
- const c2 = E$2(i, t), h2 = !!c2.includes("ms");
166
- i = parseFloat(c2) * (h2 ? 1 : 1e3);
167
- }
168
- t.classList.remove(e.finish), t.classList.add(n.start), setTimeout(() => {
169
- t.classList.add(n.finish), t.classList.remove(n.start), r(t);
170
- }, i);
171
- });
172
- }
173
- function p$2(t, e) {
174
- e && document.querySelectorAll(e).forEach((i) => {
175
- t ? i.style.overflow = "hidden" : i.style.removeProperty("overflow");
176
- });
177
47
  }
178
- function x$2(t, e) {
179
- e && document.querySelectorAll(e).forEach((i) => {
180
- t ? (i.inert = true, i.setAttribute("aria-hidden", true)) : (i.inert = null, i.removeAttribute("aria-hidden"));
181
- });
182
- }
183
- function N$3(t, e) {
184
- x$2(!!t, e.selectorInert), p$2(!!t, e.selectorOverflow);
185
- }
186
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
187
- __proto__: null,
188
- Breakpoint: L$2,
189
- Collection: S$3,
190
- FocusTrap: q$2,
191
- cssVar: E$2,
192
- getConfig: F$3,
193
- getPrefix: T$2,
194
- localStore: k$3,
195
- teleport: w$2,
196
- transition: C$2,
197
- updateGlobalState: N$3
198
- }, Symbol.toStringTag, { value: "Module" }));
199
- var I$1 = (t) => {
200
- throw TypeError(t);
201
- };
202
- var O$1 = (t, s2, e) => s2.has(t) || I$1("Cannot " + e);
203
- var w$1 = (t, s2, e) => (O$1(t, s2, "read from private field"), e ? e.call(t) : s2.get(t)), S$2 = (t, s2, e) => s2.has(t) ? I$1("Cannot add the same private member more than once") : s2 instanceof WeakSet ? s2.add(t) : s2.set(t, e), k$2 = (t, s2, e, i) => (O$1(t, s2, "write to private field"), s2.set(t, e), e);
204
- var M$2 = (t) => {
205
- throw TypeError(t);
206
- }, y$1 = (t, s2, e) => s2.has(t) || M$2("Cannot " + e), l = (t, s2, e) => (y$1(t, s2, "read from private field"), e ? e.call(t) : s2.get(t)), $$1 = (t, s2, e) => s2.has(t) ? M$2("Cannot add the same private member more than once") : s2 instanceof WeakSet ? s2.add(t) : s2.set(t, e), h$1 = (t, s2, e, i) => (y$1(t, s2, "write to private field"), s2.set(t, e), e), d$1;
207
- let B$2 = class B {
208
- constructor(s2, e) {
209
- $$1(this, d$1), this.value = s2, h$1(this, d$1, e), this.mql = null;
210
- }
211
- get handler() {
212
- return l(this, d$1);
213
- }
214
- // Unmount existing handler before setting a new one.
215
- set handler(s2) {
216
- this.mql && this.mql.removeEventListener("change", l(this, d$1)), h$1(this, d$1, s2);
217
- }
218
- mount(s2, e) {
219
- return s2 && (this.value = s2), e && h$1(this, d$1, e), this.value ? (this.mql = window.matchMedia(`(min-width: ${this.value})`), this.mql.addEventListener("change", l(this, d$1)), l(this, d$1).call(this, this.mql), this) : this;
220
- }
221
- unmount() {
222
- return this.mql ? (this.mql.removeEventListener("change", l(this, d$1)), this.value = null, h$1(this, d$1, null), this.mql = null, this) : this;
223
- }
224
- };
225
- d$1 = /* @__PURE__ */ new WeakMap();
226
- let j$1 = class j {
48
+ _handler = new WeakMap();
49
+ class Collection {
227
50
  constructor() {
228
51
  this.collection = [];
229
52
  }
230
- async register(s2) {
231
- return await this.deregister(s2), this.collection.push(s2), this.collection;
53
+ async register(item) {
54
+ await this.deregister(item);
55
+ this.collection.push(item);
56
+ return this.collection;
232
57
  }
233
- async deregister(s2) {
234
- const e = this.collection.findIndex((i) => i === s2);
235
- if (e >= 0) {
236
- const i = this.collection[e];
237
- Object.getOwnPropertyNames(i).forEach((n) => {
238
- delete i[n];
239
- }), this.collection.splice(e, 1);
58
+ async deregister(ref) {
59
+ const index2 = this.collection.findIndex((entry) => {
60
+ return entry === ref;
61
+ });
62
+ if (index2 >= 0) {
63
+ const entry = this.collection[index2];
64
+ Object.getOwnPropertyNames(entry).forEach((prop) => {
65
+ delete entry[prop];
66
+ });
67
+ this.collection.splice(index2, 1);
240
68
  }
241
69
  return this.collection;
242
70
  }
243
- async registerCollection(s2) {
244
- return await Promise.all(Array.from(s2, (e) => {
245
- this.register(e);
246
- })), this.collection;
71
+ async registerCollection(items) {
72
+ await Promise.all(Array.from(items, (item) => {
73
+ this.register(item);
74
+ }));
75
+ return this.collection;
247
76
  }
248
77
  async deregisterCollection() {
249
- for (; this.collection.length > 0; )
78
+ while (this.collection.length > 0) {
250
79
  await this.deregister(this.collection[0]);
80
+ }
251
81
  return this.collection;
252
82
  }
253
- get(s2, e = "id") {
254
- return this.collection.find((i) => i[e] === s2);
83
+ get(value, key = "id") {
84
+ return this.collection.find((item) => {
85
+ return item[key] === value;
86
+ });
255
87
  }
256
- };
257
- const o$1 = {
88
+ }
89
+ const not = {
258
90
  inert: ":not([inert]):not([inert] *)",
259
91
  negTabIndex: ':not([tabindex^="-"])',
260
92
  disabled: ":not(:disabled)"
261
- }, N$2 = [
262
- `a[href]${o$1.inert}${o$1.negTabIndex}`,
263
- `area[href]${o$1.inert}${o$1.negTabIndex}`,
264
- `input:not([type="hidden"]):not([type="radio"])${o$1.inert}${o$1.negTabIndex}${o$1.disabled}`,
265
- `input[type="radio"]${o$1.inert}${o$1.negTabIndex}${o$1.disabled}`,
266
- `select${o$1.inert}${o$1.negTabIndex}${o$1.disabled}`,
267
- `textarea${o$1.inert}${o$1.negTabIndex}${o$1.disabled}`,
268
- `button${o$1.inert}${o$1.negTabIndex}${o$1.disabled}`,
269
- `details${o$1.inert} > summary:first-of-type${o$1.negTabIndex}`,
93
+ };
94
+ const focusableSelectors = [
95
+ `a[href]${not.inert}${not.negTabIndex}`,
96
+ `area[href]${not.inert}${not.negTabIndex}`,
97
+ `input:not([type="hidden"]):not([type="radio"])${not.inert}${not.negTabIndex}${not.disabled}`,
98
+ `input[type="radio"]${not.inert}${not.negTabIndex}${not.disabled}`,
99
+ `select${not.inert}${not.negTabIndex}${not.disabled}`,
100
+ `textarea${not.inert}${not.negTabIndex}${not.disabled}`,
101
+ `button${not.inert}${not.negTabIndex}${not.disabled}`,
102
+ `details${not.inert} > summary:first-of-type${not.negTabIndex}`,
270
103
  // Discard until Firefox supports `:has()`
271
104
  // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
272
105
  // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
273
- `iframe${o$1.inert}${o$1.negTabIndex}`,
274
- `audio[controls]${o$1.inert}${o$1.negTabIndex}`,
275
- `video[controls]${o$1.inert}${o$1.negTabIndex}`,
276
- `[contenteditable]${o$1.inert}${o$1.negTabIndex}`,
277
- `[tabindex]${o$1.inert}${o$1.negTabIndex}`
106
+ `iframe${not.inert}${not.negTabIndex}`,
107
+ `audio[controls]${not.inert}${not.negTabIndex}`,
108
+ `video[controls]${not.inert}${not.negTabIndex}`,
109
+ `[contenteditable]${not.inert}${not.negTabIndex}`,
110
+ `[tabindex]${not.inert}${not.negTabIndex}`
278
111
  ];
279
- var v$1, g$1, f$1;
280
- let q$1 = class q {
281
- constructor(s2 = null, e = "[data-focus]") {
282
- $$1(this, v$1), $$1(this, g$1), $$1(this, f$1), this.el = s2, this.selectorFocus = e, h$1(this, g$1, K$2.bind(this)), h$1(this, f$1, V$2.bind(this));
112
+ class FocusTrap {
113
+ constructor(el = null, selectorFocus = "[data-focus]") {
114
+ __privateAdd(this, _focusable);
115
+ __privateAdd(this, _handleFocusTrap);
116
+ __privateAdd(this, _handleFocusLock);
117
+ this.el = el;
118
+ this.selectorFocus = selectorFocus;
119
+ __privateSet(this, _handleFocusTrap, handleFocusTrap.bind(this));
120
+ __privateSet(this, _handleFocusLock, handleFocusLock.bind(this));
283
121
  }
284
122
  get focusable() {
285
- return l(this, v$1);
286
- }
287
- set focusable(s2) {
288
- h$1(this, v$1, s2), l(this, v$1).length ? (document.removeEventListener("keydown", l(this, f$1)), document.addEventListener("keydown", l(this, g$1))) : (document.removeEventListener("keydown", l(this, g$1)), document.addEventListener("keydown", l(this, f$1)));
123
+ return __privateGet(this, _focusable);
124
+ }
125
+ set focusable(value) {
126
+ __privateSet(this, _focusable, value);
127
+ if (__privateGet(this, _focusable).length) {
128
+ document.removeEventListener("keydown", __privateGet(this, _handleFocusLock));
129
+ document.addEventListener("keydown", __privateGet(this, _handleFocusTrap));
130
+ } else {
131
+ document.removeEventListener("keydown", __privateGet(this, _handleFocusTrap));
132
+ document.addEventListener("keydown", __privateGet(this, _handleFocusLock));
133
+ }
289
134
  }
290
135
  get focusableFirst() {
291
136
  return this.focusable[0];
@@ -293,82 +138,179 @@
293
138
  get focusableLast() {
294
139
  return this.focusable[this.focusable.length - 1];
295
140
  }
296
- mount(s2, e) {
297
- s2 && (this.el = s2), e && (this.selectorFocus = e), this.focusable = this.getFocusable(), this.focus();
141
+ mount(el, selectorFocus) {
142
+ if (el) this.el = el;
143
+ if (selectorFocus) this.selectorFocus = selectorFocus;
144
+ this.focusable = this.getFocusable();
145
+ this.focus();
298
146
  }
299
147
  unmount() {
300
- this.el = null, this.focusable = [], document.removeEventListener("keydown", l(this, g$1)), document.removeEventListener("keydown", l(this, f$1));
301
- }
302
- focus(s2 = this.el, e = this.selectorFocus) {
303
- (s2.querySelector(e) || s2).focus();
304
- }
305
- getFocusable(s2 = this.el) {
306
- const e = [], i = document.activeElement, n = s2.scrollTop;
307
- return s2.querySelectorAll(N$2.join(",")).forEach((c2) => {
308
- c2.focus(), document.activeElement === c2 && e.push(c2);
309
- }), s2.scrollTop = n, i.focus(), e;
148
+ this.el = null;
149
+ this.focusable = [];
150
+ document.removeEventListener("keydown", __privateGet(this, _handleFocusTrap));
151
+ document.removeEventListener("keydown", __privateGet(this, _handleFocusLock));
152
+ }
153
+ focus(el = this.el, selectorFocus = this.selectorFocus) {
154
+ const result = el.querySelector(selectorFocus) || el;
155
+ result.focus();
156
+ }
157
+ getFocusable(el = this.el) {
158
+ const focusable = [];
159
+ const initFocus = document.activeElement;
160
+ const initScrollTop = el.scrollTop;
161
+ const els = el.querySelectorAll(focusableSelectors.join(","));
162
+ els.forEach((el2) => {
163
+ el2.focus();
164
+ if (document.activeElement === el2) {
165
+ focusable.push(el2);
166
+ }
167
+ });
168
+ el.scrollTop = initScrollTop;
169
+ initFocus.focus();
170
+ return focusable;
171
+ }
172
+ }
173
+ _focusable = new WeakMap();
174
+ _handleFocusTrap = new WeakMap();
175
+ _handleFocusLock = new WeakMap();
176
+ function handleFocusTrap(event) {
177
+ const isTab = event.key === "Tab" || event.keyCode === 9;
178
+ if (!isTab) return;
179
+ if (event.shiftKey) {
180
+ if (document.activeElement === this.focusableFirst || document.activeElement === this.el) {
181
+ event.preventDefault();
182
+ this.focusableLast.focus();
183
+ }
184
+ } else {
185
+ if (document.activeElement === this.focusableLast || document.activeElement === this.el) {
186
+ event.preventDefault();
187
+ this.focusableFirst.focus();
188
+ }
310
189
  }
311
- };
312
- v$1 = /* @__PURE__ */ new WeakMap(), g$1 = /* @__PURE__ */ new WeakMap(), f$1 = /* @__PURE__ */ new WeakMap();
313
- function K$2(t) {
314
- (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()));
315
190
  }
316
- function V$2(t) {
317
- (t.key === "Tab" || t.keyCode === 9) && t.preventDefault();
191
+ function handleFocusLock(event) {
192
+ const isTab = event.key === "Tab" || event.keyCode === 9;
193
+ if (isTab) event.preventDefault();
318
194
  }
319
- function D$2() {
195
+ function getPrefix() {
320
196
  return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
321
197
  }
322
- function W$1(t, s2 = document.body) {
323
- if (t.slice(0, 2) !== "--") {
324
- const i = D$2();
325
- i && (t = `${i}${t}`), t = `--${t}`;
198
+ function cssVar(property, el = document.body) {
199
+ if (property.slice(0, 2) !== "--") {
200
+ const prefixValue = getPrefix();
201
+ if (prefixValue) {
202
+ property = `${prefixValue}${property}`;
203
+ }
204
+ property = `--${property}`;
205
+ }
206
+ const cssValue = getComputedStyle(el).getPropertyValue(property).trim();
207
+ if (cssValue) {
208
+ return cssValue;
209
+ } else {
210
+ throw new Error(`CSS variable "${property}" was not found!`);
326
211
  }
327
- const e = getComputedStyle(s2).getPropertyValue(t).trim();
328
- if (e)
329
- return e;
330
- throw new Error(`CSS variable "${t}" was not found!`);
331
212
  }
332
- function _$2(t, s2) {
333
- const e = (t.getAttribute(`data-${s2}`) || "").replace(/'/g, '"');
334
- return e ? JSON.parse(e) : {};
213
+ function getConfig$1(el, dataConfig) {
214
+ const string = el.getAttribute(`data-${dataConfig}`) || "";
215
+ const json = string.replace(/'/g, '"');
216
+ return json ? JSON.parse(json) : {};
335
217
  }
336
- function J$2(t, s2 = true) {
337
- const e = localStorage.getItem(t), i = e ? JSON.parse(e) : {};
218
+ function localStore(key, enable = true) {
219
+ const local = localStorage.getItem(key);
220
+ const store = local ? JSON.parse(local) : {};
338
221
  return {
339
- get(n) {
340
- return n ? i[n] : i;
222
+ get(prop) {
223
+ return prop ? store[prop] : store;
341
224
  },
342
- set(n, c2) {
343
- return c2 ? i[n] = c2 : delete i[n], s2 && localStorage.setItem(t, JSON.stringify(i)), i;
225
+ set(prop, value) {
226
+ if (value) {
227
+ store[prop] = value;
228
+ } else {
229
+ delete store[prop];
230
+ }
231
+ if (enable) localStorage.setItem(key, JSON.stringify(store));
232
+ return store;
344
233
  }
345
234
  };
346
235
  }
347
- function F$2(t, s2, e, i = "transition-duration") {
348
- return new Promise((n) => {
349
- if (typeof i == "string") {
350
- const c2 = W$1(i, t), r = !!c2.includes("ms");
351
- i = parseFloat(c2) * (r ? 1 : 1e3);
236
+ function teleport(what, where, how) {
237
+ const isComment = where.nodeType === Node.COMMENT_NODE;
238
+ const isElement2 = where.nodeType === Node.ELEMENT_NODE;
239
+ where = isComment || isElement2 ? where : document.querySelector(where);
240
+ if (isComment) how = "after";
241
+ if (!where) throw new Error(`Not a valid teleport reference: '${where}'`);
242
+ if (typeof where[how] != "function") throw new Error(`Not a valid teleport method: '${how}'`);
243
+ let returnRef = null;
244
+ if (!isComment) {
245
+ returnRef = document.createComment("teleported #" + what.id);
246
+ what.before(returnRef);
247
+ }
248
+ where[how](what);
249
+ if (isComment) {
250
+ where.remove();
251
+ }
252
+ return returnRef;
253
+ }
254
+ function transition(el, from, to, duration = "transition-duration") {
255
+ return new Promise((resolve) => {
256
+ if (typeof duration === "string") {
257
+ const cssValue = cssVar(duration, el);
258
+ const ms = cssValue.includes("ms") ? true : false;
259
+ duration = parseFloat(cssValue) * (ms ? 1 : 1e3);
352
260
  }
353
- t.classList.remove(s2.finish), t.classList.add(e.start), setTimeout(() => {
354
- t.classList.add(e.finish), t.classList.remove(e.start), n(t);
355
- }, i);
261
+ el.classList.remove(from.finish);
262
+ el.classList.add(to.start);
263
+ setTimeout(() => {
264
+ el.classList.add(to.finish);
265
+ el.classList.remove(to.start);
266
+ resolve(el);
267
+ }, duration);
356
268
  });
357
269
  }
358
- function z$1(t, s2) {
359
- s2 && document.querySelectorAll(s2).forEach((e) => {
360
- t ? e.style.overflow = "hidden" : e.style.removeProperty("overflow");
361
- });
270
+ function setOverflowHidden(state, selector) {
271
+ if (selector) {
272
+ const els = document.querySelectorAll(selector);
273
+ els.forEach((el) => {
274
+ if (state) {
275
+ el.style.overflow = "hidden";
276
+ } else {
277
+ el.style.removeProperty("overflow");
278
+ }
279
+ });
280
+ }
362
281
  }
363
- function G$1(t, s2) {
364
- s2 && document.querySelectorAll(s2).forEach((e) => {
365
- t ? (e.inert = true, e.setAttribute("aria-hidden", true)) : (e.inert = null, e.removeAttribute("aria-hidden"));
366
- });
282
+ function setInert(state, selector) {
283
+ if (selector) {
284
+ const els = document.querySelectorAll(selector);
285
+ els.forEach((el) => {
286
+ if (state) {
287
+ el.inert = true;
288
+ el.setAttribute("aria-hidden", true);
289
+ } else {
290
+ el.inert = null;
291
+ el.removeAttribute("aria-hidden");
292
+ }
293
+ });
294
+ }
367
295
  }
368
- function C$1(t, s2) {
369
- G$1(!!t, s2.selectorInert), z$1(!!t, s2.selectorOverflow);
296
+ function updateGlobalState(state, config) {
297
+ setInert(!!state, config.selectorInert);
298
+ setOverflowHidden(!!state, config.selectorOverflow);
370
299
  }
371
- const H$1 = {
300
+ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
301
+ __proto__: null,
302
+ Breakpoint,
303
+ Collection,
304
+ FocusTrap,
305
+ cssVar,
306
+ getConfig: getConfig$1,
307
+ getPrefix,
308
+ localStore,
309
+ teleport,
310
+ transition,
311
+ updateGlobalState
312
+ }, Symbol.toStringTag, { value: "Module" }));
313
+ const defaults$2 = {
372
314
  autoMount: false,
373
315
  // Data attributes
374
316
  dataOpen: "drawer-open",
@@ -400,372 +342,397 @@
400
342
  transition: true,
401
343
  transitionDuration: "drawer-transition-duration"
402
344
  };
403
- function Q$2(t) {
404
- t.store === "opened" ? t.open(false, false) : t.store === "closed" ? t.close(false, false) : t.store === "indeterminate" ? t.state = "indeterminate" : t.el.classList.contains(t.getSetting("stateOpened")) ? t.open(false, false) : t.el.classList.contains(t.getSetting("stateClosed")) ? t.close(false, false) : t.state = "indeterminate";
345
+ function applyInitialState(entry) {
346
+ if (entry.store === "opened") {
347
+ entry.open(false, false);
348
+ } else if (entry.store === "closed") {
349
+ entry.close(false, false);
350
+ } else if (entry.store === "indeterminate") {
351
+ entry.state = "indeterminate";
352
+ } else {
353
+ if (entry.el.classList.contains(entry.getSetting("stateOpened"))) {
354
+ entry.open(false, false);
355
+ } else if (entry.el.classList.contains(entry.getSetting("stateClosed"))) {
356
+ entry.close(false, false);
357
+ } else {
358
+ entry.state = "indeterminate";
359
+ }
360
+ }
405
361
  }
406
- async function R$1(t) {
407
- t.store === "opened" ? await t.open(false, false) : t.store === "closed" ? await t.close(false, false) : t.store === "indeterminate" ? t.state != "indeterminate" && (t.state = "indeterminate") : (t.state != t.inlineState && (t.state = t.inlineState), t.inlineState === "opened" ? await t.open(false, false) : t.inlineState === "closed" && await t.close(false, false));
362
+ async function applyInlineState(entry) {
363
+ if (entry.store === "opened") {
364
+ await entry.open(false, false);
365
+ } else if (entry.store === "closed") {
366
+ await entry.close(false, false);
367
+ } else if (entry.store === "indeterminate") {
368
+ if (entry.state != "indeterminate") {
369
+ entry.state = "indeterminate";
370
+ }
371
+ } else {
372
+ if (entry.state != entry.inlineState) {
373
+ entry.state = entry.inlineState;
374
+ }
375
+ if (entry.inlineState === "opened") {
376
+ await entry.open(false, false);
377
+ } else if (entry.inlineState === "closed") {
378
+ await entry.close(false, false);
379
+ }
380
+ }
408
381
  }
409
- function U(t) {
410
- const s2 = D$2(), e = t.getAttribute(`data-${this.settings.dataBreakpoint}`);
411
- return this.settings.breakpoints && this.settings.breakpoints[e] ? this.settings.breakpoints[e] : getComputedStyle(document.body).getPropertyValue(`--${s2}breakpoint-${e}`).trim() ? getComputedStyle(document.body).getPropertyValue(`--${s2}breakpoint-${e}`).trim() : e;
382
+ function getBreakpoint(drawer) {
383
+ const prefix = getPrefix();
384
+ const bp = drawer.getAttribute(`data-${this.settings.dataBreakpoint}`);
385
+ if (this.settings.breakpoints && this.settings.breakpoints[bp]) {
386
+ return this.settings.breakpoints[bp];
387
+ } else if (getComputedStyle(document.body).getPropertyValue(`--${prefix}breakpoint-${bp}`).trim()) {
388
+ return getComputedStyle(document.body).getPropertyValue(`--${prefix}breakpoint-${bp}`).trim();
389
+ } else {
390
+ return bp;
391
+ }
412
392
  }
413
- function m$1(t) {
414
- const s2 = typeof t == "string" ? this.get(t) : this.get(t.id);
415
- if (s2)
416
- return s2;
417
- throw new Error(`Drawer not found in collection with id of "${t.id || t}".`);
393
+ function getDrawer(query) {
394
+ const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
395
+ if (entry) {
396
+ return entry;
397
+ } else {
398
+ throw new Error(`Drawer not found in collection with id of "${query.id || query}".`);
399
+ }
418
400
  }
419
- function P$1(t) {
420
- 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());
401
+ function updateFocusState$1(entry) {
402
+ if (entry.state === "opened") {
403
+ if (entry.mode === "modal") {
404
+ this.focusTrap.mount(entry.dialog, this.settings.selectorFocus);
405
+ } else {
406
+ this.focusTrap.focus(entry.dialog, this.settings.selectorFocus);
407
+ }
408
+ } else {
409
+ if (entry.trigger) {
410
+ entry.trigger.focus();
411
+ entry.trigger = null;
412
+ }
413
+ this.focusTrap.unmount();
414
+ }
421
415
  }
422
- async function X(t) {
423
- const s2 = t.target.closest(`
416
+ async function handleClick$2(event) {
417
+ const trigger = event.target.closest(`
424
418
  [data-${this.settings.dataOpen}],
425
419
  [data-${this.settings.dataToggle}],
426
420
  [data-${this.settings.dataClose}]
427
421
  `);
428
- if (s2) {
429
- t.preventDefault(), s2.matches(`[data-${this.settings.dataToggle}]`) && s2.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ").forEach((i) => {
430
- const n = m$1.call(this, i);
431
- return n.trigger = s2, n.toggle();
432
- }), s2.matches(`[data-${this.settings.dataOpen}]`) && s2.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ").forEach((i) => {
433
- const n = m$1.call(this, i);
434
- return n.trigger = s2, n.open();
435
- }), s2.matches(`[data-${this.settings.dataClose}]`) && s2.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ").forEach((i) => {
436
- if (i) {
437
- const n = m$1.call(this, i);
438
- return n.trigger = s2, n.close();
439
- } else {
440
- const n = t.target.closest(this.settings.selectorDrawer);
441
- if (n) return this.close(n);
442
- }
443
- });
422
+ if (trigger) {
423
+ event.preventDefault();
424
+ if (trigger.matches(`[data-${this.settings.dataToggle}]`)) {
425
+ const selectors = trigger.getAttribute(`data-${this.settings.dataToggle}`).trim().split(" ");
426
+ selectors.forEach((selector) => {
427
+ const entry = getDrawer.call(this, selector);
428
+ entry.trigger = trigger;
429
+ return entry.toggle();
430
+ });
431
+ }
432
+ if (trigger.matches(`[data-${this.settings.dataOpen}]`)) {
433
+ const selectors = trigger.getAttribute(`data-${this.settings.dataOpen}`).trim().split(" ");
434
+ selectors.forEach((selector) => {
435
+ const entry = getDrawer.call(this, selector);
436
+ entry.trigger = trigger;
437
+ return entry.open();
438
+ });
439
+ }
440
+ if (trigger.matches(`[data-${this.settings.dataClose}]`)) {
441
+ const selectors = trigger.getAttribute(`data-${this.settings.dataClose}`).trim().split(" ");
442
+ selectors.forEach((selector) => {
443
+ if (selector) {
444
+ const entry = getDrawer.call(this, selector);
445
+ entry.trigger = trigger;
446
+ return entry.close();
447
+ } else {
448
+ const parent = event.target.closest(this.settings.selectorDrawer);
449
+ if (parent) return this.close(parent);
450
+ }
451
+ });
452
+ }
444
453
  return;
445
454
  }
446
- if (this.activeModal && t.target.matches(this.settings.selectorScreen))
455
+ if (this.activeModal && event.target.matches(this.settings.selectorScreen)) {
447
456
  return this.close(this.activeModal.id);
457
+ }
448
458
  }
449
- function Y(t) {
450
- if (t.key === "Escape" && this.activeModal)
451
- return this.close(this.activeModal);
459
+ function handleKeydown$2(event) {
460
+ if (event.key === "Escape") {
461
+ if (this.activeModal) return this.close(this.activeModal);
462
+ }
452
463
  }
453
- async function L$1(t, s2 = true) {
454
- const e = this.collection.findIndex((i) => i.id === t.id);
455
- if (e >= 0) {
456
- const i = this.collection[e];
457
- s2 && i.state === "opened" && await i.close(false), this.store.set(i.id), i.unmountBreakpoint(), Object.getOwnPropertyNames(i).forEach((n) => {
458
- delete i[n];
459
- }), this.collection.splice(e, 1);
464
+ async function deregister$2(obj, close2 = true) {
465
+ const index2 = this.collection.findIndex((entry) => {
466
+ return entry.id === obj.id;
467
+ });
468
+ if (index2 >= 0) {
469
+ const entry = this.collection[index2];
470
+ if (close2 && entry.state === "opened") {
471
+ await entry.close(false);
472
+ }
473
+ this.store.set(entry.id);
474
+ entry.unmountBreakpoint();
475
+ Object.getOwnPropertyNames(entry).forEach((prop) => {
476
+ delete entry[prop];
477
+ });
478
+ this.collection.splice(index2, 1);
460
479
  }
461
480
  return this.collection;
462
481
  }
463
- async function x$1(t, s2, e = true) {
464
- const i = m$1.call(this, t), n = { ...this.settings, ...i.settings };
465
- return s2 !== void 0 && (n.transition = s2), (i.state === "closed" || i.state === "indeterminate") && (i.state = "opening", n.transition ? await F$2(i.el, {
466
- start: n.stateClosing,
467
- finish: n.stateClosed
468
- }, {
469
- start: n.stateOpening,
470
- finish: n.stateOpened
471
- }, n.transitionDuration) : (i.el.classList.add(n.stateOpened), i.el.classList.remove(n.stateClosed)), i.state = "opened", i.mode === "modal" && C$1(true, n), e && P$1.call(this, i), i.el.dispatchEvent(new CustomEvent(n.customEventPrefix + "opened", {
472
- detail: this,
473
- bubbles: true
474
- }))), i;
475
- }
476
- async function E$1(t, s2, e = true) {
477
- const i = m$1.call(this, t), n = { ...this.settings, ...i.settings };
478
- return s2 !== void 0 && (n.transition = s2), (i.state === "opened" || i.state === "indeterminate") && (i.state = "closing", document.activeElement.blur(), n.transition ? await F$2(i.el, {
479
- start: n.stateOpening,
480
- finish: n.stateOpened
481
- }, {
482
- start: n.stateClosing,
483
- finish: n.stateClosed
484
- }, n.transitionDuration) : (i.el.classList.add(n.stateClosed), i.el.classList.remove(n.stateOpened)), i.state = "closed", i.mode === "modal" && C$1(false, n), e && P$1.call(this, i), i.el.dispatchEvent(new CustomEvent(n.customEventPrefix + "closed", {
485
- detail: this,
486
- bubbles: true
487
- }))), i;
482
+ async function open$2(query, enableTransition, focus = true) {
483
+ const entry = getDrawer.call(this, query);
484
+ const config = { ...this.settings, ...entry.settings };
485
+ if (enableTransition !== void 0) config.transition = enableTransition;
486
+ if (entry.state === "closed" || entry.state === "indeterminate") {
487
+ entry.state = "opening";
488
+ if (config.transition) {
489
+ await transition(entry.el, {
490
+ start: config.stateClosing,
491
+ finish: config.stateClosed
492
+ }, {
493
+ start: config.stateOpening,
494
+ finish: config.stateOpened
495
+ }, config.transitionDuration);
496
+ } else {
497
+ entry.el.classList.add(config.stateOpened);
498
+ entry.el.classList.remove(config.stateClosed);
499
+ }
500
+ entry.state = "opened";
501
+ if (entry.mode === "modal") updateGlobalState(true, config);
502
+ if (focus) {
503
+ updateFocusState$1.call(this, entry);
504
+ }
505
+ entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
506
+ detail: this,
507
+ bubbles: true
508
+ }));
509
+ }
510
+ return entry;
511
+ }
512
+ async function close$2(query, enableTransition, focus = true) {
513
+ const entry = getDrawer.call(this, query);
514
+ const config = { ...this.settings, ...entry.settings };
515
+ if (enableTransition !== void 0) config.transition = enableTransition;
516
+ if (entry.state === "opened" || entry.state === "indeterminate") {
517
+ entry.state = "closing";
518
+ document.activeElement.blur();
519
+ if (config.transition) {
520
+ await transition(entry.el, {
521
+ start: config.stateOpening,
522
+ finish: config.stateOpened
523
+ }, {
524
+ start: config.stateClosing,
525
+ finish: config.stateClosed
526
+ }, config.transitionDuration);
527
+ } else {
528
+ entry.el.classList.add(config.stateClosed);
529
+ entry.el.classList.remove(config.stateOpened);
530
+ }
531
+ entry.state = "closed";
532
+ if (entry.mode === "modal") updateGlobalState(false, config);
533
+ if (focus) {
534
+ updateFocusState$1.call(this, entry);
535
+ }
536
+ entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
537
+ detail: this,
538
+ bubbles: true
539
+ }));
540
+ }
541
+ return entry;
488
542
  }
489
- async function A$1(t, s2, e) {
490
- const i = m$1.call(this, t);
491
- return i.state === "closed" ? x$1.call(this, i, s2, e) : E$1.call(this, i, s2, e);
543
+ async function toggle(query, transition2, focus) {
544
+ const entry = getDrawer.call(this, query);
545
+ if (entry.state === "closed") {
546
+ return open$2.call(this, entry, transition2, focus);
547
+ } else {
548
+ return close$2.call(this, entry, transition2, focus);
549
+ }
492
550
  }
493
- function Z$1(t) {
494
- switch (t.mode) {
551
+ function switchMode(entry) {
552
+ switch (entry.mode) {
495
553
  case "inline":
496
- return tt$1.call(this, t);
554
+ return toInline.call(this, entry);
497
555
  case "modal":
498
- return et$1.call(this, t);
556
+ return toModal.call(this, entry);
499
557
  default:
500
- throw new Error(`"${t.mode}" is not a valid drawer mode.`);
558
+ throw new Error(`"${entry.mode}" is not a valid drawer mode.`);
501
559
  }
502
560
  }
503
- async function tt$1(t) {
504
- return t.el.classList.remove(t.getSetting("classModal")), t.dialog.removeAttribute("aria-modal"), C$1(false, { ...this.settings, ...t.settings }), this.focusTrap.unmount(), await R$1(t), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
561
+ async function toInline(entry) {
562
+ entry.el.classList.remove(entry.getSetting("classModal"));
563
+ entry.dialog.removeAttribute("aria-modal");
564
+ updateGlobalState(false, { ...this.settings, ...entry.settings });
565
+ this.focusTrap.unmount();
566
+ await applyInlineState(entry);
567
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
505
568
  detail: this,
506
569
  bubbles: true
507
- })), t;
508
- }
509
- async function et$1(t) {
510
- return t.el.classList.add(t.getSetting("classModal")), t.dialog.setAttribute("aria-modal", "true"), await E$1.call(this, t, false, false), t.el.dispatchEvent(new CustomEvent(t.getSetting("customEventPrefix") + "switchMode", {
570
+ }));
571
+ return entry;
572
+ }
573
+ async function toModal(entry) {
574
+ entry.el.classList.add(entry.getSetting("classModal"));
575
+ entry.dialog.setAttribute("aria-modal", "true");
576
+ await close$2.call(this, entry, false, false);
577
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
511
578
  detail: this,
512
579
  bubbles: true
513
- })), t;
514
- }
515
- async function st$1(t, s2 = {}) {
516
- await L$1.call(this, t, false);
517
- const e = this, i = new B$2();
518
- let n, c2 = "indeterminate";
519
- const r = {
520
- id: t.id,
521
- el: t,
580
+ }));
581
+ return entry;
582
+ }
583
+ async function register$2(el, config = {}) {
584
+ await deregister$2.call(this, el, false);
585
+ const root = this;
586
+ const breakpoint = new Breakpoint();
587
+ let _mode, _state = "indeterminate";
588
+ const entry = {
589
+ id: el.id,
590
+ el,
522
591
  dialog: null,
523
592
  trigger: null,
524
- settings: { ..._$2(t, this.settings.dataConfig), ...s2 },
593
+ settings: { ...getConfig$1(el, this.settings.dataConfig), ...config },
525
594
  inlineState: "indeterminate",
526
595
  get breakpoint() {
527
- return U.call(e, t);
596
+ return getBreakpoint.call(root, el);
528
597
  },
529
598
  get store() {
530
- return e.store.get(this.id);
599
+ return root.store.get(this.id);
531
600
  },
532
601
  get mode() {
533
- return n;
602
+ return _mode;
534
603
  },
535
- set mode(a2) {
536
- n = a2, Z$1.call(e, this);
604
+ set mode(value) {
605
+ _mode = value;
606
+ switchMode.call(root, this);
537
607
  },
538
608
  get state() {
539
- return c2;
609
+ return _state;
540
610
  },
541
- set state(a2) {
542
- c2 = a2, this.mode === "inline" && a2 != "opening" && a2 != "closing" && (this.inlineState = a2, this.getSetting("store") && e.store.set(this.id, a2)), a2 === "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")));
611
+ set state(value) {
612
+ _state = value;
613
+ if (this.mode === "inline" && value != "opening" && value != "closing") {
614
+ this.inlineState = value;
615
+ if (this.getSetting("store")) {
616
+ root.store.set(this.id, value);
617
+ }
618
+ }
619
+ if (value === "indeterminate") {
620
+ this.el.classList.remove(this.getSetting("stateOpened"));
621
+ this.el.classList.remove(this.getSetting("stateOpening"));
622
+ this.el.classList.remove(this.getSetting("stateClosed"));
623
+ this.el.classList.remove(this.getSetting("stateClosing"));
624
+ }
543
625
  },
544
- open(a2, u2) {
545
- return x$1.call(e, this, a2, u2);
626
+ open(transition2, focus) {
627
+ return open$2.call(root, this, transition2, focus);
546
628
  },
547
- close(a2, u2) {
548
- return E$1.call(e, this, a2, u2);
629
+ close(transition2, focus) {
630
+ return close$2.call(root, this, transition2, focus);
549
631
  },
550
- toggle(a2, u2) {
551
- return A$1.call(e, this, a2, u2);
632
+ toggle(transition2, focus) {
633
+ return toggle.call(root, this, transition2, focus);
552
634
  },
553
635
  deregister() {
554
- return L$1.call(e, this);
636
+ return deregister$2.call(root, this);
555
637
  },
556
638
  mountBreakpoint() {
557
- const a2 = this.breakpoint, u2 = this.handleBreakpoint.bind(this);
558
- return i.mount(a2, u2), this;
639
+ const value = this.breakpoint;
640
+ const handler = this.handleBreakpoint.bind(this);
641
+ breakpoint.mount(value, handler);
642
+ return this;
559
643
  },
560
644
  unmountBreakpoint() {
561
- return i.unmount(), this;
645
+ breakpoint.unmount();
646
+ return this;
562
647
  },
563
- handleBreakpoint(a2) {
564
- const u2 = a2.matches ? "inline" : "modal";
565
- return this.mode != u2 && (this.mode = u2), this;
648
+ handleBreakpoint(event) {
649
+ const bpMode = event.matches ? "inline" : "modal";
650
+ if (this.mode != bpMode) {
651
+ this.mode = bpMode;
652
+ }
653
+ return this;
566
654
  },
567
- getSetting(a2) {
568
- return a2 in this.settings ? this.settings[a2] : e.settings[a2];
655
+ getSetting(key) {
656
+ return key in this.settings ? this.settings[key] : root.settings[key];
569
657
  }
570
658
  };
571
- this.collection.push(r);
572
- const T2 = t.querySelector(r.getSetting("selectorDialog"));
573
- return r.dialog = T2 || t, r.getSetting("setTabindex") && r.dialog.setAttribute("tabindex", "-1"), await Q$2(r), r.inlineState = r.state, r.mode = t.classList.contains(r.getSetting("classModal")) ? "modal" : "inline", r.breakpoint && r.mountBreakpoint(), r;
574
- }
575
- var p$1, b$1;
576
- let nt$1 = class nt extends j$1 {
577
- constructor(e) {
659
+ this.collection.push(entry);
660
+ const dialog = el.querySelector(entry.getSetting("selectorDialog"));
661
+ entry.dialog = dialog ? dialog : el;
662
+ if (entry.getSetting("setTabindex")) {
663
+ entry.dialog.setAttribute("tabindex", "-1");
664
+ }
665
+ await applyInitialState(entry);
666
+ entry.inlineState = entry.state;
667
+ entry.mode = el.classList.contains(entry.getSetting("classModal")) ? "modal" : "inline";
668
+ if (entry.breakpoint) {
669
+ entry.mountBreakpoint();
670
+ }
671
+ return entry;
672
+ }
673
+ class Drawer extends Collection {
674
+ constructor(options) {
578
675
  super();
579
- S$2(this, p$1);
580
- S$2(this, b$1);
581
- this.defaults = H$1, this.settings = { ...this.defaults, ...e }, this.focusTrap = new q$1(), this.store = J$2(this.settings.storeKey, this.settings.store), k$2(this, p$1, X.bind(this)), k$2(this, b$1, Y.bind(this)), this.settings.autoMount && this.mount();
676
+ __privateAdd(this, _handleClick);
677
+ __privateAdd(this, _handleKeydown);
678
+ this.defaults = defaults$2;
679
+ this.settings = { ...this.defaults, ...options };
680
+ this.focusTrap = new FocusTrap();
681
+ this.store = localStore(this.settings.storeKey, this.settings.store);
682
+ __privateSet(this, _handleClick, handleClick$2.bind(this));
683
+ __privateSet(this, _handleKeydown, handleKeydown$2.bind(this));
684
+ if (this.settings.autoMount) this.mount();
582
685
  }
583
686
  get activeModal() {
584
- return this.collection.find((e) => e.state === "opened" && e.mode === "modal");
687
+ return this.collection.find((entry) => {
688
+ return entry.state === "opened" && entry.mode === "modal";
689
+ });
585
690
  }
586
- async mount(e = null) {
587
- e && (this.settings = { ...this.settings, ...e });
588
- const i = document.querySelectorAll(this.settings.selectorDrawer);
589
- return await this.registerCollection(i), this.settings.eventListeners && this.mountEventListeners(), this;
691
+ async mount(options = null) {
692
+ if (options) this.settings = { ...this.settings, ...options };
693
+ const drawers = document.querySelectorAll(this.settings.selectorDrawer);
694
+ await this.registerCollection(drawers);
695
+ if (this.settings.eventListeners) {
696
+ this.mountEventListeners();
697
+ }
698
+ return this;
590
699
  }
591
700
  async unmount() {
592
- return await this.deregisterCollection(), this.settings.eventListeners && this.unmountEventListeners(), this;
701
+ await this.deregisterCollection();
702
+ if (this.settings.eventListeners) {
703
+ this.unmountEventListeners();
704
+ }
705
+ return this;
593
706
  }
594
707
  mountEventListeners() {
595
- document.addEventListener("click", w$1(this, p$1), false), document.addEventListener("keydown", w$1(this, b$1), false);
708
+ document.addEventListener("click", __privateGet(this, _handleClick), false);
709
+ document.addEventListener("keydown", __privateGet(this, _handleKeydown), false);
596
710
  }
597
711
  unmountEventListeners() {
598
- document.removeEventListener("click", w$1(this, p$1), false), document.removeEventListener("keydown", w$1(this, b$1), false);
599
- }
600
- register(e, i = {}) {
601
- let n = typeof e == "string" ? document.getElementById(e) : e;
602
- return n ? st$1.call(this, n, i) : Promise.reject(new Error(`Failed to register; drawer not found with ID of: "${e.id || e}".`));
603
- }
604
- deregister(e) {
605
- let i = this.get(e.id || e);
606
- return i ? L$1.call(this, i) : Promise.reject(new Error(`Failed to deregister; drawer does not exist in collection with ID of: "${e.id || e}".`));
607
- }
608
- open(e, i, n) {
609
- return x$1.call(this, e, i, n);
610
- }
611
- close(e, i, n) {
612
- return E$1.call(this, e, i, n);
613
- }
614
- toggle(e, i, n) {
615
- return A$1.call(this, e, i, n);
616
- }
617
- };
618
- p$1 = /* @__PURE__ */ new WeakMap(), b$1 = /* @__PURE__ */ new WeakMap();
619
- var L = (i) => {
620
- throw TypeError(i);
621
- };
622
- var I = (i, e, t) => e.has(i) || L("Cannot " + t);
623
- var f = (i, e, t) => (I(i, e, "read from private field"), t ? t.call(i) : e.get(i)), v = (i, e, t) => e.has(i) ? L("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), b = (i, e, t, s2) => (I(i, e, "write to private field"), e.set(i, t), t);
624
- var S$1 = (i) => {
625
- throw TypeError(i);
626
- }, k$1 = (i, e, t) => e.has(i) || S$1("Cannot " + t), a = (i, e, t) => (k$1(i, e, "read from private field"), t ? t.call(i) : e.get(i)), y = (i, e, t) => e.has(i) ? S$1("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(i) : e.set(i, t), w = (i, e, t, s2) => (k$1(i, e, "write to private field"), e.set(i, t), t);
627
- class A {
628
- constructor() {
629
- this.collection = [];
630
- }
631
- async register(e) {
632
- return await this.deregister(e), this.collection.push(e), this.collection;
633
- }
634
- async deregister(e) {
635
- const t = this.collection.findIndex((s2) => s2 === e);
636
- if (t >= 0) {
637
- const s2 = this.collection[t];
638
- Object.getOwnPropertyNames(s2).forEach((n) => {
639
- delete s2[n];
640
- }), this.collection.splice(t, 1);
641
- }
642
- return this.collection;
643
- }
644
- async registerCollection(e) {
645
- return await Promise.all(Array.from(e, (t) => {
646
- this.register(t);
647
- })), this.collection;
648
- }
649
- async deregisterCollection() {
650
- for (; this.collection.length > 0; )
651
- await this.deregister(this.collection[0]);
652
- return this.collection;
653
- }
654
- get(e, t = "id") {
655
- return this.collection.find((s2) => s2[t] === e);
656
- }
657
- }
658
- const o = {
659
- inert: ":not([inert]):not([inert] *)",
660
- negTabIndex: ':not([tabindex^="-"])',
661
- disabled: ":not(:disabled)"
662
- }, F$1 = [
663
- `a[href]${o.inert}${o.negTabIndex}`,
664
- `area[href]${o.inert}${o.negTabIndex}`,
665
- `input:not([type="hidden"]):not([type="radio"])${o.inert}${o.negTabIndex}${o.disabled}`,
666
- `input[type="radio"]${o.inert}${o.negTabIndex}${o.disabled}`,
667
- `select${o.inert}${o.negTabIndex}${o.disabled}`,
668
- `textarea${o.inert}${o.negTabIndex}${o.disabled}`,
669
- `button${o.inert}${o.negTabIndex}${o.disabled}`,
670
- `details${o.inert} > summary:first-of-type${o.negTabIndex}`,
671
- // Discard until Firefox supports `:has()`
672
- // See: https://github.com/KittyGiraudel/focusable-selectors/issues/12
673
- // `details:not(:has(> summary))${not.inert}${not.negTabIndex}`,
674
- `iframe${o.inert}${o.negTabIndex}`,
675
- `audio[controls]${o.inert}${o.negTabIndex}`,
676
- `video[controls]${o.inert}${o.negTabIndex}`,
677
- `[contenteditable]${o.inert}${o.negTabIndex}`,
678
- `[tabindex]${o.inert}${o.negTabIndex}`
679
- ];
680
- var g, c, d;
681
- class P {
682
- constructor(e = null, t = "[data-focus]") {
683
- y(this, g), y(this, c), y(this, d), this.el = e, this.selectorFocus = t, w(this, c, R.bind(this)), w(this, d, D$1.bind(this));
712
+ document.removeEventListener("click", __privateGet(this, _handleClick), false);
713
+ document.removeEventListener("keydown", __privateGet(this, _handleKeydown), false);
684
714
  }
685
- get focusable() {
686
- return a(this, g);
687
- }
688
- set focusable(e) {
689
- w(this, g, e), a(this, g).length ? (document.removeEventListener("keydown", a(this, d)), document.addEventListener("keydown", a(this, c))) : (document.removeEventListener("keydown", a(this, c)), document.addEventListener("keydown", a(this, d)));
690
- }
691
- get focusableFirst() {
692
- return this.focusable[0];
693
- }
694
- get focusableLast() {
695
- return this.focusable[this.focusable.length - 1];
715
+ register(query, config = {}) {
716
+ let el = typeof query == "string" ? document.getElementById(query) : query;
717
+ return el ? register$2.call(this, el, config) : Promise.reject(new Error(`Failed to register; drawer not found with ID of: "${query.id || query}".`));
696
718
  }
697
- mount(e, t) {
698
- e && (this.el = e), t && (this.selectorFocus = t), this.focusable = this.getFocusable(), this.focus();
719
+ deregister(query) {
720
+ let obj = this.get(query.id || query);
721
+ return obj ? deregister$2.call(this, obj) : Promise.reject(new Error(`Failed to deregister; drawer does not exist in collection with ID of: "${query.id || query}".`));
699
722
  }
700
- unmount() {
701
- this.el = null, this.focusable = [], document.removeEventListener("keydown", a(this, c)), document.removeEventListener("keydown", a(this, d));
723
+ open(id, transition2, focus) {
724
+ return open$2.call(this, id, transition2, focus);
702
725
  }
703
- focus(e = this.el, t = this.selectorFocus) {
704
- (e.querySelector(t) || e).focus();
726
+ close(id, transition2, focus) {
727
+ return close$2.call(this, id, transition2, focus);
705
728
  }
706
- getFocusable(e = this.el) {
707
- const t = [], s2 = document.activeElement, n = e.scrollTop;
708
- return e.querySelectorAll(F$1.join(",")).forEach((r) => {
709
- r.focus(), document.activeElement === r && t.push(r);
710
- }), e.scrollTop = n, s2.focus(), t;
729
+ toggle(id, transition2, focus) {
730
+ return toggle.call(this, id, transition2, focus);
711
731
  }
712
732
  }
713
- g = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap();
714
- function R(i) {
715
- (i.key === "Tab" || i.keyCode === 9) && (i.shiftKey ? (document.activeElement === this.focusableFirst || document.activeElement === this.el) && (i.preventDefault(), this.focusableLast.focus()) : (document.activeElement === this.focusableLast || document.activeElement === this.el) && (i.preventDefault(), this.focusableFirst.focus()));
716
- }
717
- function D$1(i) {
718
- (i.key === "Tab" || i.keyCode === 9) && i.preventDefault();
719
- }
720
- function N$1() {
721
- return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
722
- }
723
- function z(i, e = document.body) {
724
- if (i.slice(0, 2) !== "--") {
725
- const s2 = N$1();
726
- s2 && (i = `${s2}${i}`), i = `--${i}`;
727
- }
728
- const t = getComputedStyle(e).getPropertyValue(i).trim();
729
- if (t)
730
- return t;
731
- throw new Error(`CSS variable "${i}" was not found!`);
732
- }
733
- function j(i, e) {
734
- const t = (i.getAttribute(`data-${e}`) || "").replace(/'/g, '"');
735
- return t ? JSON.parse(t) : {};
736
- }
737
- function T$1(i, e, t) {
738
- const s2 = e.nodeType === Node.COMMENT_NODE, n = e.nodeType === Node.ELEMENT_NODE;
739
- if (e = s2 || n ? e : document.querySelector(e), s2 && (t = "after"), !e) throw new Error(`Not a valid teleport reference: '${e}'`);
740
- if (typeof e[t] != "function") throw new Error(`Not a valid teleport method: '${t}'`);
741
- let r = null;
742
- return s2 || (r = document.createComment("teleported #" + i.id), i.before(r)), e[t](i), s2 && e.remove(), r;
743
- }
744
- function O(i, e, t, s2 = "transition-duration") {
745
- return new Promise((n) => {
746
- if (typeof s2 == "string") {
747
- const r = z(s2, i), l2 = !!r.includes("ms");
748
- s2 = parseFloat(r) * (l2 ? 1 : 1e3);
749
- }
750
- i.classList.remove(e.finish), i.classList.add(t.start), setTimeout(() => {
751
- i.classList.add(t.finish), i.classList.remove(t.start), n(i);
752
- }, s2);
753
- });
754
- }
755
- function W(i, e) {
756
- e && document.querySelectorAll(e).forEach((t) => {
757
- i ? t.style.overflow = "hidden" : t.style.removeProperty("overflow");
758
- });
759
- }
760
- function _$1(i, e) {
761
- e && document.querySelectorAll(e).forEach((t) => {
762
- i ? (t.inert = true, t.setAttribute("aria-hidden", true)) : (t.inert = null, t.removeAttribute("aria-hidden"));
763
- });
764
- }
765
- function G(i, e) {
766
- _$1(!!i, e.selectorInert), W(!!i, e.selectorOverflow);
767
- }
768
- const K$1 = {
733
+ _handleClick = new WeakMap();
734
+ _handleKeydown = new WeakMap();
735
+ const defaults$1 = {
769
736
  autoMount: false,
770
737
  // Data attributes
771
738
  dataOpen: "modal-open",
@@ -794,252 +761,361 @@
794
761
  transition: true,
795
762
  transitionDuration: "modal-transition-duration"
796
763
  };
797
- function m(i) {
798
- const e = typeof i == "string" ? this.get(i) : this.get(i.id);
799
- if (e)
800
- return e;
801
- throw new Error(`Modal not found in collection with id of "${i.id || i}".`);
802
- }
803
- function p() {
804
- this.active ? this.focusTrap.mount(this.active.dialog, this.settings.selectorFocus) : (this.trigger && (this.trigger.focus(), this.trigger = null), this.focusTrap.unmount());
764
+ function getModal(query) {
765
+ const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
766
+ if (entry) {
767
+ return entry;
768
+ } else {
769
+ throw new Error(`Modal not found in collection with id of "${query.id || query}".`);
770
+ }
771
+ }
772
+ function updateFocusState() {
773
+ if (this.active) {
774
+ this.focusTrap.mount(this.active.dialog, this.settings.selectorFocus);
775
+ } else {
776
+ if (this.trigger) {
777
+ this.trigger.focus();
778
+ this.trigger = null;
779
+ }
780
+ this.focusTrap.unmount();
781
+ }
805
782
  }
806
- async function V$1(i) {
807
- const e = i.target.closest(`
783
+ async function handleClick$1(event) {
784
+ const trigger = event.target.closest(`
808
785
  [data-${this.settings.dataOpen}],
809
786
  [data-${this.settings.dataReplace}],
810
787
  [data-${this.settings.dataClose}]
811
788
  `);
812
- if (e) {
813
- if (i.preventDefault(), e.matches(`[data-${this.settings.dataOpen}]`)) {
814
- const t = e.getAttribute(`data-${this.settings.dataOpen}`).trim(), s2 = m.call(this, t);
815
- return i.target.closest(this.settings.selectorModal) || (this.trigger = e), s2.open();
789
+ if (trigger) {
790
+ event.preventDefault();
791
+ if (trigger.matches(`[data-${this.settings.dataOpen}]`)) {
792
+ const selector = trigger.getAttribute(`data-${this.settings.dataOpen}`).trim();
793
+ const entry = getModal.call(this, selector);
794
+ const fromModal = event.target.closest(this.settings.selectorModal);
795
+ if (!fromModal) this.trigger = trigger;
796
+ return entry.open();
816
797
  }
817
- if (e.matches(`[data-${this.settings.dataReplace}]`)) {
818
- const t = e.getAttribute(`data-${this.settings.dataReplace}`).trim(), s2 = m.call(this, t);
819
- return i.target.closest(this.settings.selectorModal) || (this.trigger = e), s2.replace();
798
+ if (trigger.matches(`[data-${this.settings.dataReplace}]`)) {
799
+ const selector = trigger.getAttribute(`data-${this.settings.dataReplace}`).trim();
800
+ const entry = getModal.call(this, selector);
801
+ const fromModal = event.target.closest(this.settings.selectorModal);
802
+ if (!fromModal) this.trigger = trigger;
803
+ return entry.replace();
820
804
  }
821
- if (e.matches(`[data-${this.settings.dataClose}]`)) {
822
- const t = e.getAttribute(`data-${this.settings.dataClose}`).trim();
823
- return t === "*" ? this.closeAll() : this.close(t);
805
+ if (trigger.matches(`[data-${this.settings.dataClose}]`)) {
806
+ const selector = trigger.getAttribute(`data-${this.settings.dataClose}`).trim();
807
+ return selector === "*" ? this.closeAll() : this.close(selector);
824
808
  }
825
809
  }
826
- if (this.active && i.target.matches(this.settings.selectorScreen) && !this.active.required)
810
+ if (this.active && event.target.matches(this.settings.selectorScreen) && !this.active.required) {
827
811
  return this.close(this.active.id);
812
+ }
828
813
  }
829
- function q(i) {
830
- if (i.key === "Escape" && this.active && !this.active.dialog.matches(this.settings.selectorRequired))
831
- return this.close();
814
+ function handleKeydown$1(event) {
815
+ if (event.key === "Escape") {
816
+ if (this.active && !this.active.dialog.matches(this.settings.selectorRequired)) {
817
+ return this.close();
818
+ }
819
+ }
832
820
  }
833
- async function E(i, e = true) {
834
- const t = this.collection.findIndex((s2) => s2.id === i.id);
835
- if (t >= 0) {
836
- const s2 = this.collection[t];
837
- e && s2.state === "opened" ? await s2.close(false) : this.stack.remove(s2), s2.getSetting("teleport") && s2.teleportReturn(), Object.getOwnPropertyNames(s2).forEach((n) => {
838
- delete s2[n];
839
- }), this.collection.splice(t, 1);
821
+ async function deregister$1(obj, close2 = true) {
822
+ const index2 = this.collection.findIndex((entry) => {
823
+ return entry.id === obj.id;
824
+ });
825
+ if (index2 >= 0) {
826
+ const entry = this.collection[index2];
827
+ if (close2 && entry.state === "opened") {
828
+ await entry.close(false);
829
+ } else {
830
+ this.stack.remove(entry);
831
+ }
832
+ if (entry.getSetting("teleport")) {
833
+ entry.teleportReturn();
834
+ }
835
+ Object.getOwnPropertyNames(entry).forEach((prop) => {
836
+ delete entry[prop];
837
+ });
838
+ this.collection.splice(index2, 1);
840
839
  }
841
840
  return this.collection;
842
841
  }
843
- async function x(i, e, t = true) {
844
- const s2 = m.call(this, i), n = { ...this.settings, ...s2.settings };
845
- return e !== void 0 && (n.transition = e), this.stack.moveToTop(s2), s2.state === "closed" && (s2.state = "opening", this.stack.add(s2), n.transition ? await O(s2.el, {
846
- start: n.stateClosing,
847
- finish: n.stateClosed
848
- }, {
849
- start: n.stateOpening,
850
- finish: n.stateOpened
851
- }, n.transitionDuration) : (s2.el.classList.add(n.stateOpened), s2.el.classList.remove(n.stateClosed)), s2.state = "opened"), t && p.call(this), s2.el.dispatchEvent(new CustomEvent(n.customEventPrefix + "opened", {
842
+ async function open$1(query, enableTransition, focus = true) {
843
+ const entry = getModal.call(this, query);
844
+ const config = { ...this.settings, ...entry.settings };
845
+ if (enableTransition !== void 0) config.transition = enableTransition;
846
+ this.stack.moveToTop(entry);
847
+ if (entry.state === "closed") {
848
+ entry.state = "opening";
849
+ this.stack.add(entry);
850
+ if (config.transition) {
851
+ await transition(entry.el, {
852
+ start: config.stateClosing,
853
+ finish: config.stateClosed
854
+ }, {
855
+ start: config.stateOpening,
856
+ finish: config.stateOpened
857
+ }, config.transitionDuration);
858
+ } else {
859
+ entry.el.classList.add(config.stateOpened);
860
+ entry.el.classList.remove(config.stateClosed);
861
+ }
862
+ entry.state = "opened";
863
+ }
864
+ if (focus) {
865
+ updateFocusState.call(this);
866
+ }
867
+ entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
852
868
  detail: this,
853
869
  bubbles: true
854
- })), s2;
855
- }
856
- async function C(i, e, t = true) {
857
- const s2 = i ? m.call(this, i) : this.active;
858
- if (s2 && s2.state === "opened") {
859
- s2.state = "closing";
860
- const n = { ...this.settings, ...s2.settings };
861
- e !== void 0 && (n.transition = e), document.activeElement.blur(), n.transition ? await O(s2.el, {
862
- start: n.stateOpening,
863
- finish: n.stateOpened
864
- }, {
865
- start: n.stateClosing,
866
- finish: n.stateClosed
867
- }, n.transitionDuration) : (s2.el.classList.add(n.stateClosed), s2.el.classList.remove(n.stateOpened)), this.stack.remove(s2), s2.state = "closed", t && p.call(this), s2.el.dispatchEvent(new CustomEvent(n.customEventPrefix + "closed", {
870
+ }));
871
+ return entry;
872
+ }
873
+ async function close$1(query, enableTransition, focus = true) {
874
+ const entry = query ? getModal.call(this, query) : this.active;
875
+ if (entry && entry.state === "opened") {
876
+ entry.state = "closing";
877
+ const config = { ...this.settings, ...entry.settings };
878
+ if (enableTransition !== void 0) config.transition = enableTransition;
879
+ document.activeElement.blur();
880
+ if (config.transition) {
881
+ await transition(entry.el, {
882
+ start: config.stateOpening,
883
+ finish: config.stateOpened
884
+ }, {
885
+ start: config.stateClosing,
886
+ finish: config.stateClosed
887
+ }, config.transitionDuration);
888
+ } else {
889
+ entry.el.classList.add(config.stateClosed);
890
+ entry.el.classList.remove(config.stateOpened);
891
+ }
892
+ this.stack.remove(entry);
893
+ entry.state = "closed";
894
+ if (focus) {
895
+ updateFocusState.call(this);
896
+ }
897
+ entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
868
898
  detail: this,
869
899
  bubbles: true
870
900
  }));
871
901
  }
872
- return s2;
873
- }
874
- async function $(i, e) {
875
- const t = [];
876
- return await Promise.all(this.stack.value.map(async (s2) => {
877
- i && i === s2.id ? Promise.resolve() : t.push(await C.call(this, s2, e, false)), s2.trigger = null;
878
- })), t;
902
+ return entry;
879
903
  }
880
- async function M$1(i, e, t = true) {
881
- const s2 = m.call(this, i);
882
- let n, r;
883
- return s2.state === "opened" ? (n = s2, r = await $.call(this, s2.id, e)) : (r = $.call(this, false, e), n = x.call(this, s2, e, false), await Promise.all([n, r])), t && p.call(this), { opened: n, closed: r };
884
- }
885
- async function B$1(i, e = {}) {
886
- await E.call(this, i, false);
887
- const t = this, s2 = {
888
- id: i.id,
904
+ async function closeAll$1(exclude, transition2) {
905
+ const result = [];
906
+ await Promise.all(this.stack.value.map(async (modal) => {
907
+ if (exclude && exclude === modal.id) {
908
+ Promise.resolve();
909
+ } else {
910
+ result.push(await close$1.call(this, modal, transition2, false));
911
+ }
912
+ modal.trigger = null;
913
+ }));
914
+ return result;
915
+ }
916
+ async function replace(query, transition2, focus = true) {
917
+ const entry = getModal.call(this, query);
918
+ let resultOpened, resultClosed;
919
+ if (entry.state === "opened") {
920
+ resultOpened = entry;
921
+ resultClosed = await closeAll$1.call(this, entry.id, transition2);
922
+ } else {
923
+ resultClosed = closeAll$1.call(this, false, transition2);
924
+ resultOpened = open$1.call(this, entry, transition2, false);
925
+ await Promise.all([resultOpened, resultClosed]);
926
+ }
927
+ if (focus) {
928
+ updateFocusState.call(this);
929
+ }
930
+ return { opened: resultOpened, closed: resultClosed };
931
+ }
932
+ async function register$1(el, config = {}) {
933
+ await deregister$1.call(this, el, false);
934
+ const root = this;
935
+ const entry = {
936
+ id: el.id,
889
937
  state: "closed",
890
- el: i,
938
+ el,
891
939
  dialog: null,
892
940
  get required() {
893
941
  return this.dialog.matches(this.getSetting("selectorRequired"));
894
942
  },
895
943
  returnRef: null,
896
- settings: { ...j(i, this.settings.dataConfig), ...e },
897
- open(r, l2) {
898
- return x.call(t, this, r, l2);
944
+ settings: { ...getConfig$1(el, this.settings.dataConfig), ...config },
945
+ open(transition2, focus) {
946
+ return open$1.call(root, this, transition2, focus);
899
947
  },
900
- close(r, l2) {
901
- return C.call(t, this, r, l2);
948
+ close(transition2, focus) {
949
+ return close$1.call(root, this, transition2, focus);
902
950
  },
903
- replace(r, l2) {
904
- return M$1.call(t, this, r, l2);
951
+ replace(transition2, focus) {
952
+ return replace.call(root, this, transition2, focus);
905
953
  },
906
954
  deregister() {
907
- return E.call(t, this);
955
+ return deregister$1.call(root, this);
908
956
  },
909
- teleport(r = this.getSetting("teleport"), l2 = this.getSetting("teleportMethod")) {
910
- return this.returnRef ? (console.error("Element has already been teleported:", this.el), false) : (this.returnRef = T$1(this.el, r, l2), this.el);
957
+ teleport(ref = this.getSetting("teleport"), method = this.getSetting("teleportMethod")) {
958
+ if (!this.returnRef) {
959
+ this.returnRef = teleport(this.el, ref, method);
960
+ return this.el;
961
+ } else {
962
+ console.error("Element has already been teleported:", this.el);
963
+ return false;
964
+ }
911
965
  },
912
966
  teleportReturn() {
913
- return this.returnRef ? (this.returnRef = T$1(this.el, this.returnRef), this.el) : (console.error("No return reference found:", this.el), false);
967
+ if (this.returnRef) {
968
+ this.returnRef = teleport(this.el, this.returnRef);
969
+ return this.el;
970
+ } else {
971
+ console.error("No return reference found:", this.el);
972
+ return false;
973
+ }
914
974
  },
915
- getSetting(r) {
916
- return r in this.settings ? this.settings[r] : t.settings[r];
975
+ getSetting(key) {
976
+ return key in this.settings ? this.settings[key] : root.settings[key];
917
977
  }
918
- }, n = i.querySelector(s2.getSetting("selectorDialog"));
919
- return s2.dialog = n || i, s2.dialog.setAttribute("aria-modal", "true"), s2.dialog.hasAttribute("role") || s2.dialog.setAttribute("role", "dialog"), s2.getSetting("setTabindex") && s2.dialog.setAttribute("tabindex", "-1"), s2.getSetting("teleport") && s2.teleport(), this.collection.push(s2), s2.el.classList.contains(this.settings.stateOpened) ? await s2.open(false) : (s2.el.classList.remove(this.settings.stateOpening), s2.el.classList.remove(this.settings.stateClosing), s2.el.classList.add(this.settings.stateClosed)), s2;
920
- }
921
- function J$1(i) {
922
- const e = [];
978
+ };
979
+ const dialog = el.querySelector(entry.getSetting("selectorDialog"));
980
+ entry.dialog = dialog ? dialog : el;
981
+ entry.dialog.setAttribute("aria-modal", "true");
982
+ if (!entry.dialog.hasAttribute("role")) {
983
+ entry.dialog.setAttribute("role", "dialog");
984
+ }
985
+ if (entry.getSetting("setTabindex")) {
986
+ entry.dialog.setAttribute("tabindex", "-1");
987
+ }
988
+ if (entry.getSetting("teleport")) {
989
+ entry.teleport();
990
+ }
991
+ this.collection.push(entry);
992
+ if (entry.el.classList.contains(this.settings.stateOpened)) {
993
+ await entry.open(false);
994
+ } else {
995
+ entry.el.classList.remove(this.settings.stateOpening);
996
+ entry.el.classList.remove(this.settings.stateClosing);
997
+ entry.el.classList.add(this.settings.stateClosed);
998
+ }
999
+ return entry;
1000
+ }
1001
+ function stack(settings) {
1002
+ const stackArray = [];
923
1003
  return {
924
1004
  get value() {
925
- return [...e];
1005
+ return [...stackArray];
926
1006
  },
927
1007
  get top() {
928
- return e[e.length - 1];
1008
+ return stackArray[stackArray.length - 1];
929
1009
  },
930
1010
  updateIndex() {
931
- e.forEach((t, s2) => {
932
- t.el.style.zIndex = null;
933
- const n = getComputedStyle(t.el)["z-index"];
934
- t.el.style.zIndex = parseInt(n) + s2 + 1;
1011
+ stackArray.forEach((entry, index2) => {
1012
+ entry.el.style.zIndex = null;
1013
+ const value = getComputedStyle(entry.el)["z-index"];
1014
+ entry.el.style.zIndex = parseInt(value) + index2 + 1;
935
1015
  });
936
1016
  },
937
1017
  updateGlobalState() {
938
- G(this.top, i), this.updateIndex();
1018
+ updateGlobalState(this.top, settings);
1019
+ this.updateIndex();
939
1020
  },
940
- add(t) {
941
- t.el.style.zIndex = null;
942
- const s2 = getComputedStyle(t.el)["z-index"];
943
- t.el.style.zIndex = parseInt(s2) + e.length + 1, e.push(t), this.updateGlobalState();
1021
+ add(entry) {
1022
+ entry.el.style.zIndex = null;
1023
+ const value = getComputedStyle(entry.el)["z-index"];
1024
+ entry.el.style.zIndex = parseInt(value) + stackArray.length + 1;
1025
+ stackArray.push(entry);
1026
+ this.updateGlobalState();
944
1027
  },
945
- remove(t) {
946
- const s2 = e.findIndex((n) => n.id === t.id);
947
- s2 >= 0 && (t.el.style.zIndex = null, e.splice(s2, 1), this.updateGlobalState());
1028
+ remove(entry) {
1029
+ const index2 = stackArray.findIndex((item) => {
1030
+ return item.id === entry.id;
1031
+ });
1032
+ if (index2 >= 0) {
1033
+ entry.el.style.zIndex = null;
1034
+ stackArray.splice(index2, 1);
1035
+ this.updateGlobalState();
1036
+ }
948
1037
  },
949
- moveToTop(t) {
950
- const s2 = e.findIndex((n) => n.id === t.id);
951
- s2 >= 0 && (e.splice(s2, 1), this.add(t));
1038
+ moveToTop(entry) {
1039
+ const index2 = stackArray.findIndex((item) => {
1040
+ return item.id === entry.id;
1041
+ });
1042
+ if (index2 >= 0) {
1043
+ stackArray.splice(index2, 1);
1044
+ this.add(entry);
1045
+ }
952
1046
  }
953
1047
  };
954
1048
  }
955
- var u, h;
956
- let Q$1 = class Q extends A {
957
- constructor(t) {
1049
+ class Modal extends Collection {
1050
+ constructor(options) {
958
1051
  super();
959
- v(this, u);
960
- v(this, h);
961
- this.defaults = K$1, this.settings = { ...this.defaults, ...t }, this.trigger = null, this.focusTrap = new P(), this.stack = J$1(this.settings), b(this, u, V$1.bind(this)), b(this, h, q.bind(this)), this.settings.autoMount && this.mount();
1052
+ __privateAdd(this, _handleClick2);
1053
+ __privateAdd(this, _handleKeydown2);
1054
+ this.defaults = defaults$1;
1055
+ this.settings = { ...this.defaults, ...options };
1056
+ this.trigger = null;
1057
+ this.focusTrap = new FocusTrap();
1058
+ this.stack = stack(this.settings);
1059
+ __privateSet(this, _handleClick2, handleClick$1.bind(this));
1060
+ __privateSet(this, _handleKeydown2, handleKeydown$1.bind(this));
1061
+ if (this.settings.autoMount) this.mount();
962
1062
  }
963
1063
  get active() {
964
1064
  return this.stack.top;
965
1065
  }
966
- async mount(t) {
967
- t && (this.settings = { ...this.settings, ...t });
968
- const s2 = document.querySelectorAll(this.settings.selectorModal);
969
- return await this.registerCollection(s2), this.settings.eventListeners && this.mountEventListeners(), this;
1066
+ async mount(options) {
1067
+ if (options) this.settings = { ...this.settings, ...options };
1068
+ const modals = document.querySelectorAll(this.settings.selectorModal);
1069
+ await this.registerCollection(modals);
1070
+ if (this.settings.eventListeners) {
1071
+ this.mountEventListeners();
1072
+ }
1073
+ return this;
970
1074
  }
971
1075
  async unmount() {
972
- return this.trigger = null, await this.deregisterCollection(), this.settings.eventListeners && this.unmountEventListeners(), this;
1076
+ this.trigger = null;
1077
+ await this.deregisterCollection();
1078
+ if (this.settings.eventListeners) {
1079
+ this.unmountEventListeners();
1080
+ }
1081
+ return this;
973
1082
  }
974
1083
  mountEventListeners() {
975
- document.addEventListener("click", f(this, u), false), document.addEventListener("keydown", f(this, h), false);
1084
+ document.addEventListener("click", __privateGet(this, _handleClick2), false);
1085
+ document.addEventListener("keydown", __privateGet(this, _handleKeydown2), false);
976
1086
  }
977
1087
  unmountEventListeners() {
978
- document.removeEventListener("click", f(this, u), false), document.removeEventListener("keydown", f(this, h), false);
979
- }
980
- register(t, s2 = {}) {
981
- let n = typeof t == "string" ? document.getElementById(t) : t;
982
- return n ? B$1.call(this, n, s2) : Promise.reject(new Error(`Failed to register; modal not found with ID of: "${t.id || t}".`));
1088
+ document.removeEventListener("click", __privateGet(this, _handleClick2), false);
1089
+ document.removeEventListener("keydown", __privateGet(this, _handleKeydown2), false);
983
1090
  }
984
- deregister(t) {
985
- let s2 = this.get(t.id || t);
986
- return s2 ? E.call(this, s2) : Promise.reject(new Error(`Failed to deregister; modal does not exist in collection with ID of: "${t.id || t}".`));
1091
+ register(query, config = {}) {
1092
+ let el = typeof query == "string" ? document.getElementById(query) : query;
1093
+ return el ? register$1.call(this, el, config) : Promise.reject(new Error(`Failed to register; modal not found with ID of: "${query.id || query}".`));
987
1094
  }
988
- open(t, s2, n) {
989
- return x.call(this, t, s2, n);
1095
+ deregister(query) {
1096
+ let obj = this.get(query.id || query);
1097
+ return obj ? deregister$1.call(this, obj) : Promise.reject(new Error(`Failed to deregister; modal does not exist in collection with ID of: "${query.id || query}".`));
990
1098
  }
991
- close(t, s2, n) {
992
- return C.call(this, t, s2, n);
1099
+ open(id, transition2, focus) {
1100
+ return open$1.call(this, id, transition2, focus);
993
1101
  }
994
- replace(t, s2, n) {
995
- return M$1.call(this, t, s2, n);
1102
+ close(id, transition2, focus) {
1103
+ return close$1.call(this, id, transition2, focus);
996
1104
  }
997
- async closeAll(t = false, s2, n = true) {
998
- const r = await $.call(this, t, s2);
999
- return n && p.call(this), r;
1105
+ replace(id, transition2, focus) {
1106
+ return replace.call(this, id, transition2, focus);
1000
1107
  }
1001
- };
1002
- u = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap();
1003
- var Ue = (e) => {
1004
- throw TypeError(e);
1005
- };
1006
- var _e = (e, t, r) => t.has(e) || Ue("Cannot " + r);
1007
- var Ae = (e, t, r) => (_e(e, t, "read from private field"), r ? r.call(e) : t.get(e)), Ke = (e, t, r) => t.has(e) ? Ue("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, r), Ge = (e, t, r, i) => (_e(e, t, "write to private field"), t.set(e, r), r);
1008
- class Ct {
1009
- constructor() {
1010
- this.collection = [];
1011
- }
1012
- async register(t) {
1013
- return await this.deregister(t), this.collection.push(t), this.collection;
1014
- }
1015
- async deregister(t) {
1016
- const r = this.collection.findIndex((i) => i === t);
1017
- if (r >= 0) {
1018
- const i = this.collection[r];
1019
- Object.getOwnPropertyNames(i).forEach((n) => {
1020
- delete i[n];
1021
- }), this.collection.splice(r, 1);
1108
+ async closeAll(exclude = false, transition2, focus = true) {
1109
+ const result = await closeAll$1.call(this, exclude, transition2);
1110
+ if (focus) {
1111
+ updateFocusState.call(this);
1022
1112
  }
1023
- return this.collection;
1024
- }
1025
- async registerCollection(t) {
1026
- return await Promise.all(Array.from(t, (r) => {
1027
- this.register(r);
1028
- })), this.collection;
1029
- }
1030
- async deregisterCollection() {
1031
- for (; this.collection.length > 0; )
1032
- await this.deregister(this.collection[0]);
1033
- return this.collection;
1034
- }
1035
- get(t, r = "id") {
1036
- return this.collection.find((i) => i[r] === t);
1113
+ return result;
1037
1114
  }
1038
1115
  }
1039
- function kt() {
1040
- return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
1041
- }
1042
- const Dt = {
1116
+ _handleClick2 = new WeakMap();
1117
+ _handleKeydown2 = new WeakMap();
1118
+ const defaults = {
1043
1119
  autoMount: false,
1044
1120
  // Selectors
1045
1121
  selectorPopover: ".popover",
@@ -1051,192 +1127,294 @@
1051
1127
  eventType: "click",
1052
1128
  placement: "bottom"
1053
1129
  };
1054
- function at(e, t) {
1055
- const r = getComputedStyle(e), i = {
1056
- placement: t.placement,
1057
- event: t.eventType,
1058
- offset: 0,
1130
+ function getConfig(el, settings) {
1131
+ const styles = getComputedStyle(el);
1132
+ const config = {
1133
+ "placement": settings.placement,
1134
+ "event": settings.eventType,
1135
+ "offset": 0,
1059
1136
  "overflow-padding": 0,
1060
1137
  "flip-padding": 0,
1061
- "arrow-element": t.selectorArrow,
1138
+ "arrow-element": settings.selectorArrow,
1062
1139
  "arrow-padding": 0
1063
1140
  };
1064
- for (const n in i) {
1065
- const o2 = kt(), l2 = r.getPropertyValue(`--${o2}popover-${n}`).trim();
1066
- l2 && (i[n] = l2);
1067
- }
1068
- return i;
1069
- }
1070
- function Pe(e) {
1071
- let t;
1072
- const r = typeof e == "string" ? e.trim().split(" ") : [e];
1073
- switch (r.forEach(function(i, n) {
1074
- r[n] = parseInt(i, 10);
1075
- }), r.length) {
1141
+ for (const prop in config) {
1142
+ const prefix = getPrefix();
1143
+ const value = styles.getPropertyValue(`--${prefix}popover-${prop}`).trim();
1144
+ if (value) {
1145
+ config[prop] = value;
1146
+ }
1147
+ }
1148
+ return config;
1149
+ }
1150
+ function getPadding(value) {
1151
+ let padding;
1152
+ const array = typeof value === "string" ? value.trim().split(" ") : [value];
1153
+ array.forEach(function(item, index2) {
1154
+ array[index2] = parseInt(item, 10);
1155
+ });
1156
+ switch (array.length) {
1076
1157
  case 1:
1077
- t = r[0];
1158
+ padding = array[0];
1078
1159
  break;
1079
1160
  case 2:
1080
- t = {
1081
- top: r[0],
1082
- right: r[1],
1083
- bottom: r[0],
1084
- left: r[1]
1161
+ padding = {
1162
+ top: array[0],
1163
+ right: array[1],
1164
+ bottom: array[0],
1165
+ left: array[1]
1085
1166
  };
1086
1167
  break;
1087
1168
  case 3:
1088
- t = {
1089
- top: r[0],
1090
- right: r[1],
1091
- bottom: r[2],
1092
- left: r[1]
1169
+ padding = {
1170
+ top: array[0],
1171
+ right: array[1],
1172
+ bottom: array[2],
1173
+ left: array[1]
1093
1174
  };
1094
1175
  break;
1095
1176
  case 4:
1096
- t = {
1097
- top: r[0],
1098
- right: r[1],
1099
- bottom: r[2],
1100
- left: r[3]
1177
+ padding = {
1178
+ top: array[0],
1179
+ right: array[1],
1180
+ bottom: array[2],
1181
+ left: array[3]
1101
1182
  };
1102
1183
  break;
1103
1184
  default:
1104
- t = false;
1185
+ padding = false;
1105
1186
  break;
1106
1187
  }
1107
- return t;
1188
+ return padding;
1108
1189
  }
1109
- function Rt(e) {
1190
+ function getModifiers(options) {
1110
1191
  return [{
1111
1192
  name: "offset",
1112
1193
  options: {
1113
- offset: [0, parseInt(e.offset, 10)]
1194
+ offset: [0, parseInt(options["offset"], 10)]
1114
1195
  }
1115
1196
  }, {
1116
1197
  name: "preventOverflow",
1117
1198
  options: {
1118
- padding: Pe(e["overflow-padding"])
1199
+ padding: getPadding(options["overflow-padding"])
1119
1200
  }
1120
1201
  }, {
1121
1202
  name: "flip",
1122
1203
  options: {
1123
- padding: Pe(e["flip-padding"])
1204
+ padding: getPadding(options["flip-padding"])
1124
1205
  }
1125
1206
  }, {
1126
1207
  name: "arrow",
1127
1208
  options: {
1128
- element: e["arrow-element"],
1129
- padding: Pe(e["arrow-padding"])
1209
+ element: options["arrow-element"],
1210
+ padding: getPadding(options["arrow-padding"])
1130
1211
  }
1131
1212
  }];
1132
1213
  }
1133
- function st(e) {
1134
- const t = typeof e == "string" ? this.get(e) : this.get(e.id);
1135
- if (t)
1136
- return t;
1137
- throw new Error(`Popover not found in collection with id of "${e}".`);
1138
- }
1139
- function Bt(e) {
1140
- return typeof e == "string" ? e : typeof e.hasAttribute == "function" ? e.closest(this.settings.selectorPopover) ? (e = e.closest(this.settings.selectorPopover), e.id) : e.hasAttribute("aria-controls") ? e.getAttribute("aria-controls") : e.hasAttribute("aria-describedby") ? e.getAttribute("aria-describedby") : false : false;
1141
- }
1142
- function Tt(e) {
1143
- const t = Bt.call(this, e);
1144
- if (t) {
1145
- const r = document.querySelector(`#${t}`), i = document.querySelector(`[aria-controls="${t}"]`) || document.querySelector(`[aria-describedby="${t}"]`);
1146
- return !i && !r ? { error: new Error(`No popover elements found using the ID: "${t}".`) } : i ? r ? { popover: r, trigger: i } : { error: new Error("No popover associated with the provided popover trigger.") } : { error: new Error("No popover trigger associated with the provided popover.") };
1147
- } else
1214
+ function getPopover(query) {
1215
+ const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
1216
+ if (entry) {
1217
+ return entry;
1218
+ } else {
1219
+ throw new Error(`Popover not found in collection with id of "${query}".`);
1220
+ }
1221
+ }
1222
+ function getPopoverID(obj) {
1223
+ if (typeof obj === "string") {
1224
+ return obj;
1225
+ } else if (typeof obj.hasAttribute === "function") {
1226
+ if (obj.closest(this.settings.selectorPopover)) {
1227
+ obj = obj.closest(this.settings.selectorPopover);
1228
+ return obj.id;
1229
+ } else if (obj.hasAttribute("aria-controls")) {
1230
+ return obj.getAttribute("aria-controls");
1231
+ } else if (obj.hasAttribute("aria-describedby")) {
1232
+ return obj.getAttribute("aria-describedby");
1233
+ } else return false;
1234
+ } else return false;
1235
+ }
1236
+ function getPopoverElements(query) {
1237
+ const id = getPopoverID.call(this, query);
1238
+ if (id) {
1239
+ const popover = document.querySelector(`#${id}`);
1240
+ const trigger = document.querySelector(`[aria-controls="${id}"]`) || document.querySelector(`[aria-describedby="${id}"]`);
1241
+ if (!trigger && !popover) {
1242
+ return { error: new Error(`No popover elements found using the ID: "${id}".`) };
1243
+ } else if (!trigger) {
1244
+ return { error: new Error("No popover trigger associated with the provided popover.") };
1245
+ } else if (!popover) {
1246
+ return { error: new Error("No popover associated with the provided popover trigger.") };
1247
+ } else {
1248
+ return { popover, trigger };
1249
+ }
1250
+ } else {
1148
1251
  return { error: new Error("Could not resolve the popover ID.") };
1252
+ }
1149
1253
  }
1150
- async function ke(e) {
1151
- const t = e ? st.call(this, e) : await ct.call(this);
1152
- return t && t.state === "opened" && (t.el.classList.remove(this.settings.stateActive), t.trigger.hasAttribute("aria-controls") && t.trigger.setAttribute("aria-expanded", "false"), t.popper.setOptions({
1153
- modifiers: [{ name: "eventListeners", enabled: false }]
1154
- }), t.state = "closed", t.trigger === this.trigger && (this.trigger = null)), t;
1155
- }
1156
- async function ct() {
1157
- const e = [];
1158
- return await Promise.all(this.collection.map(async (t) => {
1159
- t.state === "opened" && e.push(await ke.call(this, t));
1160
- })), e;
1161
- }
1162
- function lt(e) {
1163
- e.state == "opened" && setTimeout(() => {
1164
- const t = e.el.closest(":hover") === e.el || e.trigger.closest(":hover") === e.trigger, r = document.activeElement.closest(
1165
- `#${e.id}, [aria-controls="${e.id}"], [aria-describedby="${e.id}"]`
1254
+ async function close(query) {
1255
+ const popover = query ? getPopover.call(this, query) : await closeAll.call(this);
1256
+ if (popover && popover.state === "opened") {
1257
+ popover.el.classList.remove(this.settings.stateActive);
1258
+ if (popover.trigger.hasAttribute("aria-controls")) {
1259
+ popover.trigger.setAttribute("aria-expanded", "false");
1260
+ }
1261
+ popover.popper.setOptions({
1262
+ modifiers: [{ name: "eventListeners", enabled: false }]
1263
+ });
1264
+ popover.state = "closed";
1265
+ if (popover.trigger === this.trigger) {
1266
+ this.trigger = null;
1267
+ }
1268
+ }
1269
+ return popover;
1270
+ }
1271
+ async function closeAll() {
1272
+ const result = [];
1273
+ await Promise.all(this.collection.map(async (popover) => {
1274
+ if (popover.state === "opened") {
1275
+ result.push(await close.call(this, popover));
1276
+ }
1277
+ }));
1278
+ return result;
1279
+ }
1280
+ function closeCheck(popover) {
1281
+ if (popover.state != "opened") return;
1282
+ setTimeout(() => {
1283
+ const isHovered = popover.el.closest(":hover") === popover.el || popover.trigger.closest(":hover") === popover.trigger;
1284
+ const isFocused = document.activeElement.closest(
1285
+ `#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`
1166
1286
  );
1167
- return !t && !r && e.close(), e;
1287
+ if (!isHovered && !isFocused) {
1288
+ popover.close();
1289
+ }
1290
+ return popover;
1168
1291
  }, 1);
1169
1292
  }
1170
- function St(e) {
1171
- e.state === "opened" ? e.close() : (this.trigger = e.trigger, e.open(), ft.call(this, e));
1293
+ function handleClick(popover) {
1294
+ if (popover.state === "opened") {
1295
+ popover.close();
1296
+ } else {
1297
+ this.trigger = popover.trigger;
1298
+ popover.open();
1299
+ handleDocumentClick.call(this, popover);
1300
+ }
1172
1301
  }
1173
- function Mt(e) {
1174
- switch (e.key) {
1302
+ function handleKeydown(event) {
1303
+ switch (event.key) {
1175
1304
  case "Escape":
1176
- this.trigger && this.trigger.focus(), ct.call(this);
1305
+ if (this.trigger) {
1306
+ this.trigger.focus();
1307
+ }
1308
+ closeAll.call(this);
1177
1309
  return;
1178
1310
  case "Tab":
1179
- this.collection.forEach((t) => {
1180
- lt.call(this, t);
1311
+ this.collection.forEach((popover) => {
1312
+ closeCheck.call(this, popover);
1181
1313
  });
1182
1314
  return;
1183
1315
  default:
1184
1316
  return;
1185
1317
  }
1186
1318
  }
1187
- function ft(e) {
1188
- const t = this;
1189
- document.addEventListener("click", function r(i) {
1190
- i.target.closest(
1191
- `#${e.id}, [aria-controls="${e.id}"], [aria-describedby="${e.id}"]`
1192
- ) ? e.el && !e.el.classList.contains(t.settings.stateActive) && this.removeEventListener("click", r) : (e.el && e.el.classList.contains(t.settings.stateActive) && e.close(), this.removeEventListener("click", r));
1319
+ function handleDocumentClick(popover) {
1320
+ const root = this;
1321
+ document.addEventListener("click", function _f(event) {
1322
+ const wasClicked = event.target.closest(
1323
+ `#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`
1324
+ );
1325
+ if (wasClicked) {
1326
+ if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
1327
+ this.removeEventListener("click", _f);
1328
+ }
1329
+ } else {
1330
+ if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
1331
+ popover.close();
1332
+ }
1333
+ this.removeEventListener("click", _f);
1334
+ }
1193
1335
  });
1194
1336
  }
1195
- var k = "top", S = "bottom", M = "right", D = "left", De = "auto", le = [k, S, M, D], Q = "start", se = "end", jt = "clippingParents", ut = "viewport", ne = "popper", Wt = "reference", Je = /* @__PURE__ */ le.reduce(function(e, t) {
1196
- return e.concat([t + "-" + Q, t + "-" + se]);
1197
- }, []), pt = /* @__PURE__ */ [].concat(le, [De]).reduce(function(e, t) {
1198
- return e.concat([t, t + "-" + Q, t + "-" + se]);
1199
- }, []), Ht = "beforeRead", Nt = "read", Vt = "afterRead", It = "beforeMain", Ft = "main", Xt = "afterMain", Yt = "beforeWrite", qt = "write", zt = "afterWrite", Ut = [Ht, Nt, Vt, It, Ft, Xt, Yt, qt, zt];
1200
- function N(e) {
1201
- return e ? (e.nodeName || "").toLowerCase() : null;
1202
- }
1203
- function B(e) {
1204
- if (e == null)
1337
+ var top = "top";
1338
+ var bottom = "bottom";
1339
+ var right = "right";
1340
+ var left = "left";
1341
+ var auto = "auto";
1342
+ var basePlacements = [top, bottom, right, left];
1343
+ var start = "start";
1344
+ var end = "end";
1345
+ var clippingParents = "clippingParents";
1346
+ var viewport = "viewport";
1347
+ var popper = "popper";
1348
+ var reference = "reference";
1349
+ var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
1350
+ return acc.concat([placement + "-" + start, placement + "-" + end]);
1351
+ }, []);
1352
+ var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
1353
+ return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
1354
+ }, []);
1355
+ var beforeRead = "beforeRead";
1356
+ var read = "read";
1357
+ var afterRead = "afterRead";
1358
+ var beforeMain = "beforeMain";
1359
+ var main = "main";
1360
+ var afterMain = "afterMain";
1361
+ var beforeWrite = "beforeWrite";
1362
+ var write = "write";
1363
+ var afterWrite = "afterWrite";
1364
+ var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
1365
+ function getNodeName(element) {
1366
+ return element ? (element.nodeName || "").toLowerCase() : null;
1367
+ }
1368
+ function getWindow(node) {
1369
+ if (node == null) {
1205
1370
  return window;
1206
- if (e.toString() !== "[object Window]") {
1207
- var t = e.ownerDocument;
1208
- return t && t.defaultView || window;
1209
1371
  }
1210
- return e;
1372
+ if (node.toString() !== "[object Window]") {
1373
+ var ownerDocument = node.ownerDocument;
1374
+ return ownerDocument ? ownerDocument.defaultView || window : window;
1375
+ }
1376
+ return node;
1211
1377
  }
1212
- function K(e) {
1213
- var t = B(e).Element;
1214
- return e instanceof t || e instanceof Element;
1378
+ function isElement(node) {
1379
+ var OwnElement = getWindow(node).Element;
1380
+ return node instanceof OwnElement || node instanceof Element;
1215
1381
  }
1216
- function T(e) {
1217
- var t = B(e).HTMLElement;
1218
- return e instanceof t || e instanceof HTMLElement;
1382
+ function isHTMLElement(node) {
1383
+ var OwnElement = getWindow(node).HTMLElement;
1384
+ return node instanceof OwnElement || node instanceof HTMLElement;
1219
1385
  }
1220
- function Re(e) {
1221
- if (typeof ShadowRoot > "u")
1386
+ function isShadowRoot(node) {
1387
+ if (typeof ShadowRoot === "undefined") {
1222
1388
  return false;
1223
- var t = B(e).ShadowRoot;
1224
- return e instanceof t || e instanceof ShadowRoot;
1225
- }
1226
- function _t(e) {
1227
- var t = e.state;
1228
- Object.keys(t.elements).forEach(function(r) {
1229
- var i = t.styles[r] || {}, n = t.attributes[r] || {}, o2 = t.elements[r];
1230
- !T(o2) || !N(o2) || (Object.assign(o2.style, i), Object.keys(n).forEach(function(l2) {
1231
- var s2 = n[l2];
1232
- s2 === false ? o2.removeAttribute(l2) : o2.setAttribute(l2, s2 === true ? "" : s2);
1233
- }));
1389
+ }
1390
+ var OwnElement = getWindow(node).ShadowRoot;
1391
+ return node instanceof OwnElement || node instanceof ShadowRoot;
1392
+ }
1393
+ function applyStyles(_ref) {
1394
+ var state = _ref.state;
1395
+ Object.keys(state.elements).forEach(function(name) {
1396
+ var style = state.styles[name] || {};
1397
+ var attributes = state.attributes[name] || {};
1398
+ var element = state.elements[name];
1399
+ if (!isHTMLElement(element) || !getNodeName(element)) {
1400
+ return;
1401
+ }
1402
+ Object.assign(element.style, style);
1403
+ Object.keys(attributes).forEach(function(name2) {
1404
+ var value = attributes[name2];
1405
+ if (value === false) {
1406
+ element.removeAttribute(name2);
1407
+ } else {
1408
+ element.setAttribute(name2, value === true ? "" : value);
1409
+ }
1410
+ });
1234
1411
  });
1235
1412
  }
1236
- function Kt(e) {
1237
- var t = e.state, r = {
1413
+ function effect$2(_ref2) {
1414
+ var state = _ref2.state;
1415
+ var initialStyles = {
1238
1416
  popper: {
1239
- position: t.options.strategy,
1417
+ position: state.options.strategy,
1240
1418
  left: "0",
1241
1419
  top: "0",
1242
1420
  margin: "0"
@@ -1246,137 +1424,198 @@
1246
1424
  },
1247
1425
  reference: {}
1248
1426
  };
1249
- return Object.assign(t.elements.popper.style, r.popper), t.styles = r, t.elements.arrow && Object.assign(t.elements.arrow.style, r.arrow), function() {
1250
- Object.keys(t.elements).forEach(function(i) {
1251
- var n = t.elements[i], o2 = t.attributes[i] || {}, l2 = Object.keys(t.styles.hasOwnProperty(i) ? t.styles[i] : r[i]), s2 = l2.reduce(function(a2, f2) {
1252
- return a2[f2] = "", a2;
1427
+ Object.assign(state.elements.popper.style, initialStyles.popper);
1428
+ state.styles = initialStyles;
1429
+ if (state.elements.arrow) {
1430
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
1431
+ }
1432
+ return function() {
1433
+ Object.keys(state.elements).forEach(function(name) {
1434
+ var element = state.elements[name];
1435
+ var attributes = state.attributes[name] || {};
1436
+ var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
1437
+ var style = styleProperties.reduce(function(style2, property) {
1438
+ style2[property] = "";
1439
+ return style2;
1253
1440
  }, {});
1254
- !T(n) || !N(n) || (Object.assign(n.style, s2), Object.keys(o2).forEach(function(a2) {
1255
- n.removeAttribute(a2);
1256
- }));
1441
+ if (!isHTMLElement(element) || !getNodeName(element)) {
1442
+ return;
1443
+ }
1444
+ Object.assign(element.style, style);
1445
+ Object.keys(attributes).forEach(function(attribute) {
1446
+ element.removeAttribute(attribute);
1447
+ });
1257
1448
  });
1258
1449
  };
1259
1450
  }
1260
- const Gt = {
1451
+ const applyStyles$1 = {
1261
1452
  name: "applyStyles",
1262
1453
  enabled: true,
1263
1454
  phase: "write",
1264
- fn: _t,
1265
- effect: Kt,
1455
+ fn: applyStyles,
1456
+ effect: effect$2,
1266
1457
  requires: ["computeStyles"]
1267
1458
  };
1268
- function H(e) {
1269
- return e.split("-")[0];
1270
- }
1271
- var _ = Math.max, ye = Math.min, Z = Math.round;
1272
- function Le() {
1273
- var e = navigator.userAgentData;
1274
- return e != null && e.brands && Array.isArray(e.brands) ? e.brands.map(function(t) {
1275
- return t.brand + "/" + t.version;
1276
- }).join(" ") : navigator.userAgent;
1277
- }
1278
- function dt() {
1279
- return !/^((?!chrome|android).)*safari/i.test(Le());
1280
- }
1281
- function ee(e, t, r) {
1282
- t === void 0 && (t = false), r === void 0 && (r = false);
1283
- var i = e.getBoundingClientRect(), n = 1, o2 = 1;
1284
- t && T(e) && (n = e.offsetWidth > 0 && Z(i.width) / e.offsetWidth || 1, o2 = e.offsetHeight > 0 && Z(i.height) / e.offsetHeight || 1);
1285
- var l2 = K(e) ? B(e) : window, s2 = l2.visualViewport, a2 = !dt() && r, f2 = (i.left + (a2 && s2 ? s2.offsetLeft : 0)) / n, c2 = (i.top + (a2 && s2 ? s2.offsetTop : 0)) / o2, h2 = i.width / n, y2 = i.height / o2;
1459
+ function getBasePlacement(placement) {
1460
+ return placement.split("-")[0];
1461
+ }
1462
+ var max = Math.max;
1463
+ var min = Math.min;
1464
+ var round = Math.round;
1465
+ function getUAString() {
1466
+ var uaData = navigator.userAgentData;
1467
+ if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
1468
+ return uaData.brands.map(function(item) {
1469
+ return item.brand + "/" + item.version;
1470
+ }).join(" ");
1471
+ }
1472
+ return navigator.userAgent;
1473
+ }
1474
+ function isLayoutViewport() {
1475
+ return !/^((?!chrome|android).)*safari/i.test(getUAString());
1476
+ }
1477
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1478
+ if (includeScale === void 0) {
1479
+ includeScale = false;
1480
+ }
1481
+ if (isFixedStrategy === void 0) {
1482
+ isFixedStrategy = false;
1483
+ }
1484
+ var clientRect = element.getBoundingClientRect();
1485
+ var scaleX = 1;
1486
+ var scaleY = 1;
1487
+ if (includeScale && isHTMLElement(element)) {
1488
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1489
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1490
+ }
1491
+ var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
1492
+ var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1493
+ var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
1494
+ var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
1495
+ var width = clientRect.width / scaleX;
1496
+ var height = clientRect.height / scaleY;
1286
1497
  return {
1287
- width: h2,
1288
- height: y2,
1289
- top: c2,
1290
- right: f2 + h2,
1291
- bottom: c2 + y2,
1292
- left: f2,
1293
- x: f2,
1294
- y: c2
1498
+ width,
1499
+ height,
1500
+ top: y,
1501
+ right: x + width,
1502
+ bottom: y + height,
1503
+ left: x,
1504
+ x,
1505
+ y
1295
1506
  };
1296
1507
  }
1297
- function Be(e) {
1298
- var t = ee(e), r = e.offsetWidth, i = e.offsetHeight;
1299
- return Math.abs(t.width - r) <= 1 && (r = t.width), Math.abs(t.height - i) <= 1 && (i = t.height), {
1300
- x: e.offsetLeft,
1301
- y: e.offsetTop,
1302
- width: r,
1303
- height: i
1508
+ function getLayoutRect(element) {
1509
+ var clientRect = getBoundingClientRect(element);
1510
+ var width = element.offsetWidth;
1511
+ var height = element.offsetHeight;
1512
+ if (Math.abs(clientRect.width - width) <= 1) {
1513
+ width = clientRect.width;
1514
+ }
1515
+ if (Math.abs(clientRect.height - height) <= 1) {
1516
+ height = clientRect.height;
1517
+ }
1518
+ return {
1519
+ x: element.offsetLeft,
1520
+ y: element.offsetTop,
1521
+ width,
1522
+ height
1304
1523
  };
1305
1524
  }
1306
- function vt(e, t) {
1307
- var r = t.getRootNode && t.getRootNode();
1308
- if (e.contains(t))
1525
+ function contains(parent, child) {
1526
+ var rootNode = child.getRootNode && child.getRootNode();
1527
+ if (parent.contains(child)) {
1309
1528
  return true;
1310
- if (r && Re(r)) {
1311
- var i = t;
1529
+ } else if (rootNode && isShadowRoot(rootNode)) {
1530
+ var next = child;
1312
1531
  do {
1313
- if (i && e.isSameNode(i))
1532
+ if (next && parent.isSameNode(next)) {
1314
1533
  return true;
1315
- i = i.parentNode || i.host;
1316
- } while (i);
1534
+ }
1535
+ next = next.parentNode || next.host;
1536
+ } while (next);
1317
1537
  }
1318
1538
  return false;
1319
1539
  }
1320
- function V(e) {
1321
- return B(e).getComputedStyle(e);
1540
+ function getComputedStyle$1(element) {
1541
+ return getWindow(element).getComputedStyle(element);
1322
1542
  }
1323
- function Jt(e) {
1324
- return ["table", "td", "th"].indexOf(N(e)) >= 0;
1543
+ function isTableElement(element) {
1544
+ return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
1325
1545
  }
1326
- function F(e) {
1327
- return ((K(e) ? e.ownerDocument : (
1546
+ function getDocumentElement(element) {
1547
+ return ((isElement(element) ? element.ownerDocument : (
1328
1548
  // $FlowFixMe[prop-missing]
1329
- e.document
1549
+ element.document
1330
1550
  )) || window.document).documentElement;
1331
1551
  }
1332
- function we(e) {
1333
- return N(e) === "html" ? e : (
1552
+ function getParentNode(element) {
1553
+ if (getNodeName(element) === "html") {
1554
+ return element;
1555
+ }
1556
+ return (
1334
1557
  // this is a quicker (but less type safe) way to save quite some bytes from the bundle
1335
1558
  // $FlowFixMe[incompatible-return]
1336
1559
  // $FlowFixMe[prop-missing]
1337
- e.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1338
- e.parentNode || // DOM Element detected
1339
- (Re(e) ? e.host : null) || // ShadowRoot detected
1560
+ element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1561
+ element.parentNode || // DOM Element detected
1562
+ (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
1340
1563
  // $FlowFixMe[incompatible-call]: HTMLElement is a Node
1341
- F(e)
1564
+ getDocumentElement(element)
1342
1565
  );
1343
1566
  }
1344
- function Qe(e) {
1345
- return !T(e) || // https://github.com/popperjs/popper-core/issues/837
1346
- V(e).position === "fixed" ? null : e.offsetParent;
1567
+ function getTrueOffsetParent(element) {
1568
+ if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
1569
+ getComputedStyle$1(element).position === "fixed") {
1570
+ return null;
1571
+ }
1572
+ return element.offsetParent;
1347
1573
  }
1348
- function Qt(e) {
1349
- var t = /firefox/i.test(Le()), r = /Trident/i.test(Le());
1350
- if (r && T(e)) {
1351
- var i = V(e);
1352
- if (i.position === "fixed")
1574
+ function getContainingBlock(element) {
1575
+ var isFirefox = /firefox/i.test(getUAString());
1576
+ var isIE = /Trident/i.test(getUAString());
1577
+ if (isIE && isHTMLElement(element)) {
1578
+ var elementCss = getComputedStyle$1(element);
1579
+ if (elementCss.position === "fixed") {
1353
1580
  return null;
1581
+ }
1582
+ }
1583
+ var currentNode = getParentNode(element);
1584
+ if (isShadowRoot(currentNode)) {
1585
+ currentNode = currentNode.host;
1354
1586
  }
1355
- var n = we(e);
1356
- for (Re(n) && (n = n.host); T(n) && ["html", "body"].indexOf(N(n)) < 0; ) {
1357
- var o2 = V(n);
1358
- if (o2.transform !== "none" || o2.perspective !== "none" || o2.contain === "paint" || ["transform", "perspective"].indexOf(o2.willChange) !== -1 || t && o2.willChange === "filter" || t && o2.filter && o2.filter !== "none")
1359
- return n;
1360
- n = n.parentNode;
1587
+ while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
1588
+ var css = getComputedStyle$1(currentNode);
1589
+ if (css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === "filter" || isFirefox && css.filter && css.filter !== "none") {
1590
+ return currentNode;
1591
+ } else {
1592
+ currentNode = currentNode.parentNode;
1593
+ }
1361
1594
  }
1362
1595
  return null;
1363
1596
  }
1364
- function fe(e) {
1365
- for (var t = B(e), r = Qe(e); r && Jt(r) && V(r).position === "static"; )
1366
- r = Qe(r);
1367
- return r && (N(r) === "html" || N(r) === "body" && V(r).position === "static") ? t : r || Qt(e) || t;
1597
+ function getOffsetParent(element) {
1598
+ var window2 = getWindow(element);
1599
+ var offsetParent = getTrueOffsetParent(element);
1600
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
1601
+ offsetParent = getTrueOffsetParent(offsetParent);
1602
+ }
1603
+ if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
1604
+ return window2;
1605
+ }
1606
+ return offsetParent || getContainingBlock(element) || window2;
1368
1607
  }
1369
- function Te(e) {
1370
- return ["top", "bottom"].indexOf(e) >= 0 ? "x" : "y";
1608
+ function getMainAxisFromPlacement(placement) {
1609
+ return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
1371
1610
  }
1372
- function oe(e, t, r) {
1373
- return _(e, ye(t, r));
1611
+ function within(min$1, value, max$1) {
1612
+ return max(min$1, min(value, max$1));
1374
1613
  }
1375
- function Zt(e, t, r) {
1376
- var i = oe(e, t, r);
1377
- return i > r ? r : i;
1614
+ function withinMaxClamp(min2, value, max2) {
1615
+ var v = within(min2, value, max2);
1616
+ return v > max2 ? max2 : v;
1378
1617
  }
1379
- function ht() {
1618
+ function getFreshSideObject() {
1380
1619
  return {
1381
1620
  top: 0,
1382
1621
  right: 0,
@@ -1384,838 +1623,1245 @@
1384
1623
  left: 0
1385
1624
  };
1386
1625
  }
1387
- function gt(e) {
1388
- return Object.assign({}, ht(), e);
1626
+ function mergePaddingObject(paddingObject) {
1627
+ return Object.assign({}, getFreshSideObject(), paddingObject);
1389
1628
  }
1390
- function mt(e, t) {
1391
- return t.reduce(function(r, i) {
1392
- return r[i] = e, r;
1629
+ function expandToHashMap(value, keys) {
1630
+ return keys.reduce(function(hashMap, key) {
1631
+ hashMap[key] = value;
1632
+ return hashMap;
1393
1633
  }, {});
1394
1634
  }
1395
- var er = function(t, r) {
1396
- return t = typeof t == "function" ? t(Object.assign({}, r.rects, {
1397
- placement: r.placement
1398
- })) : t, gt(typeof t != "number" ? t : mt(t, le));
1635
+ var toPaddingObject = function toPaddingObject2(padding, state) {
1636
+ padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
1637
+ placement: state.placement
1638
+ })) : padding;
1639
+ return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
1399
1640
  };
1400
- function tr(e) {
1401
- var t, r = e.state, i = e.name, n = e.options, o2 = r.elements.arrow, l2 = r.modifiersData.popperOffsets, s2 = H(r.placement), a2 = Te(s2), f2 = [D, M].indexOf(s2) >= 0, c2 = f2 ? "height" : "width";
1402
- if (!(!o2 || !l2)) {
1403
- var h2 = er(n.padding, r), y2 = Be(o2), u2 = a2 === "y" ? k : D, b2 = a2 === "y" ? S : M, v2 = r.rects.reference[c2] + r.rects.reference[a2] - l2[a2] - r.rects.popper[c2], d2 = l2[a2] - r.rects.reference[a2], w2 = fe(o2), O2 = w2 ? a2 === "y" ? w2.clientHeight || 0 : w2.clientWidth || 0 : 0, E2 = v2 / 2 - d2 / 2, p2 = h2[u2], g2 = O2 - y2[c2] - h2[b2], m2 = O2 / 2 - y2[c2] / 2 + E2, x2 = oe(p2, m2, g2), L2 = a2;
1404
- r.modifiersData[i] = (t = {}, t[L2] = x2, t.centerOffset = x2 - m2, t);
1641
+ function arrow(_ref) {
1642
+ var _state$modifiersData$;
1643
+ var state = _ref.state, name = _ref.name, options = _ref.options;
1644
+ var arrowElement = state.elements.arrow;
1645
+ var popperOffsets2 = state.modifiersData.popperOffsets;
1646
+ var basePlacement = getBasePlacement(state.placement);
1647
+ var axis = getMainAxisFromPlacement(basePlacement);
1648
+ var isVertical = [left, right].indexOf(basePlacement) >= 0;
1649
+ var len = isVertical ? "height" : "width";
1650
+ if (!arrowElement || !popperOffsets2) {
1651
+ return;
1405
1652
  }
1653
+ var paddingObject = toPaddingObject(options.padding, state);
1654
+ var arrowRect = getLayoutRect(arrowElement);
1655
+ var minProp = axis === "y" ? top : left;
1656
+ var maxProp = axis === "y" ? bottom : right;
1657
+ var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
1658
+ var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
1659
+ var arrowOffsetParent = getOffsetParent(arrowElement);
1660
+ var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1661
+ var centerToReference = endDiff / 2 - startDiff / 2;
1662
+ var min2 = paddingObject[minProp];
1663
+ var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
1664
+ var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1665
+ var offset2 = within(min2, center, max2);
1666
+ var axisProp = axis;
1667
+ state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
1668
+ }
1669
+ function effect$1(_ref2) {
1670
+ var state = _ref2.state, options = _ref2.options;
1671
+ var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
1672
+ if (arrowElement == null) {
1673
+ return;
1674
+ }
1675
+ if (typeof arrowElement === "string") {
1676
+ arrowElement = state.elements.popper.querySelector(arrowElement);
1677
+ if (!arrowElement) {
1678
+ return;
1679
+ }
1680
+ }
1681
+ if (!contains(state.elements.popper, arrowElement)) {
1682
+ return;
1683
+ }
1684
+ state.elements.arrow = arrowElement;
1406
1685
  }
1407
- function rr(e) {
1408
- var t = e.state, r = e.options, i = r.element, n = i === void 0 ? "[data-popper-arrow]" : i;
1409
- n != null && (typeof n == "string" && (n = t.elements.popper.querySelector(n), !n) || vt(t.elements.popper, n) && (t.elements.arrow = n));
1410
- }
1411
- const ir = {
1686
+ const arrow$1 = {
1412
1687
  name: "arrow",
1413
1688
  enabled: true,
1414
1689
  phase: "main",
1415
- fn: tr,
1416
- effect: rr,
1690
+ fn: arrow,
1691
+ effect: effect$1,
1417
1692
  requires: ["popperOffsets"],
1418
1693
  requiresIfExists: ["preventOverflow"]
1419
1694
  };
1420
- function te(e) {
1421
- return e.split("-")[1];
1695
+ function getVariation(placement) {
1696
+ return placement.split("-")[1];
1422
1697
  }
1423
- var nr = {
1698
+ var unsetSides = {
1424
1699
  top: "auto",
1425
1700
  right: "auto",
1426
1701
  bottom: "auto",
1427
1702
  left: "auto"
1428
1703
  };
1429
- function or(e, t) {
1430
- var r = e.x, i = e.y, n = t.devicePixelRatio || 1;
1704
+ function roundOffsetsByDPR(_ref, win) {
1705
+ var x = _ref.x, y = _ref.y;
1706
+ var dpr = win.devicePixelRatio || 1;
1431
1707
  return {
1432
- x: Z(r * n) / n || 0,
1433
- y: Z(i * n) / n || 0
1708
+ x: round(x * dpr) / dpr || 0,
1709
+ y: round(y * dpr) / dpr || 0
1434
1710
  };
1435
1711
  }
1436
- function Ze(e) {
1437
- var t, r = e.popper, i = e.popperRect, n = e.placement, o2 = e.variation, l2 = e.offsets, s2 = e.position, a2 = e.gpuAcceleration, f2 = e.adaptive, c2 = e.roundOffsets, h2 = e.isFixed, y2 = l2.x, u2 = y2 === void 0 ? 0 : y2, b2 = l2.y, v2 = b2 === void 0 ? 0 : b2, d2 = typeof c2 == "function" ? c2({
1438
- x: u2,
1439
- y: v2
1712
+ function mapToStyles(_ref2) {
1713
+ var _Object$assign2;
1714
+ var popper2 = _ref2.popper, popperRect = _ref2.popperRect, placement = _ref2.placement, variation = _ref2.variation, offsets = _ref2.offsets, position = _ref2.position, gpuAcceleration = _ref2.gpuAcceleration, adaptive = _ref2.adaptive, roundOffsets = _ref2.roundOffsets, isFixed = _ref2.isFixed;
1715
+ var _offsets$x = offsets.x, x = _offsets$x === void 0 ? 0 : _offsets$x, _offsets$y = offsets.y, y = _offsets$y === void 0 ? 0 : _offsets$y;
1716
+ var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
1717
+ x,
1718
+ y
1440
1719
  }) : {
1441
- x: u2,
1442
- y: v2
1720
+ x,
1721
+ y
1443
1722
  };
1444
- u2 = d2.x, v2 = d2.y;
1445
- var w2 = l2.hasOwnProperty("x"), O2 = l2.hasOwnProperty("y"), E2 = D, p2 = k, g2 = window;
1446
- if (f2) {
1447
- var m2 = fe(r), x2 = "clientHeight", L2 = "clientWidth";
1448
- if (m2 === B(r) && (m2 = F(r), V(m2).position !== "static" && s2 === "absolute" && (x2 = "scrollHeight", L2 = "scrollWidth")), m2 = m2, n === k || (n === D || n === M) && o2 === se) {
1449
- p2 = S;
1450
- var P2 = h2 && m2 === g2 && g2.visualViewport ? g2.visualViewport.height : (
1723
+ x = _ref3.x;
1724
+ y = _ref3.y;
1725
+ var hasX = offsets.hasOwnProperty("x");
1726
+ var hasY = offsets.hasOwnProperty("y");
1727
+ var sideX = left;
1728
+ var sideY = top;
1729
+ var win = window;
1730
+ if (adaptive) {
1731
+ var offsetParent = getOffsetParent(popper2);
1732
+ var heightProp = "clientHeight";
1733
+ var widthProp = "clientWidth";
1734
+ if (offsetParent === getWindow(popper2)) {
1735
+ offsetParent = getDocumentElement(popper2);
1736
+ if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
1737
+ heightProp = "scrollHeight";
1738
+ widthProp = "scrollWidth";
1739
+ }
1740
+ }
1741
+ offsetParent = offsetParent;
1742
+ if (placement === top || (placement === left || placement === right) && variation === end) {
1743
+ sideY = bottom;
1744
+ var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
1451
1745
  // $FlowFixMe[prop-missing]
1452
- m2[x2]
1746
+ offsetParent[heightProp]
1453
1747
  );
1454
- v2 -= P2 - i.height, v2 *= a2 ? 1 : -1;
1748
+ y -= offsetY - popperRect.height;
1749
+ y *= gpuAcceleration ? 1 : -1;
1455
1750
  }
1456
- if (n === D || (n === k || n === S) && o2 === se) {
1457
- E2 = M;
1458
- var A2 = h2 && m2 === g2 && g2.visualViewport ? g2.visualViewport.width : (
1751
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
1752
+ sideX = right;
1753
+ var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
1459
1754
  // $FlowFixMe[prop-missing]
1460
- m2[L2]
1755
+ offsetParent[widthProp]
1461
1756
  );
1462
- u2 -= A2 - i.width, u2 *= a2 ? 1 : -1;
1757
+ x -= offsetX - popperRect.width;
1758
+ x *= gpuAcceleration ? 1 : -1;
1463
1759
  }
1464
1760
  }
1465
- var $2 = Object.assign({
1466
- position: s2
1467
- }, f2 && nr), j2 = c2 === true ? or({
1468
- x: u2,
1469
- y: v2
1470
- }, B(r)) : {
1471
- x: u2,
1472
- y: v2
1761
+ var commonStyles = Object.assign({
1762
+ position
1763
+ }, adaptive && unsetSides);
1764
+ var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1765
+ x,
1766
+ y
1767
+ }, getWindow(popper2)) : {
1768
+ x,
1769
+ y
1473
1770
  };
1474
- if (u2 = j2.x, v2 = j2.y, a2) {
1475
- var C2;
1476
- return Object.assign({}, $2, (C2 = {}, C2[p2] = O2 ? "0" : "", C2[E2] = w2 ? "0" : "", C2.transform = (g2.devicePixelRatio || 1) <= 1 ? "translate(" + u2 + "px, " + v2 + "px)" : "translate3d(" + u2 + "px, " + v2 + "px, 0)", C2));
1477
- }
1478
- return Object.assign({}, $2, (t = {}, t[p2] = O2 ? v2 + "px" : "", t[E2] = w2 ? u2 + "px" : "", t.transform = "", t));
1479
- }
1480
- function ar(e) {
1481
- var t = e.state, r = e.options, i = r.gpuAcceleration, n = i === void 0 ? true : i, o2 = r.adaptive, l2 = o2 === void 0 ? true : o2, s2 = r.roundOffsets, a2 = s2 === void 0 ? true : s2, f2 = {
1482
- placement: H(t.placement),
1483
- variation: te(t.placement),
1484
- popper: t.elements.popper,
1485
- popperRect: t.rects.popper,
1486
- gpuAcceleration: n,
1487
- isFixed: t.options.strategy === "fixed"
1771
+ x = _ref4.x;
1772
+ y = _ref4.y;
1773
+ if (gpuAcceleration) {
1774
+ var _Object$assign;
1775
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? "0" : "", _Object$assign[sideX] = hasX ? "0" : "", _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1776
+ }
1777
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
1778
+ }
1779
+ function computeStyles(_ref5) {
1780
+ var state = _ref5.state, options = _ref5.options;
1781
+ var _options$gpuAccelerat = options.gpuAcceleration, gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, _options$adaptive = options.adaptive, adaptive = _options$adaptive === void 0 ? true : _options$adaptive, _options$roundOffsets = options.roundOffsets, roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1782
+ var commonStyles = {
1783
+ placement: getBasePlacement(state.placement),
1784
+ variation: getVariation(state.placement),
1785
+ popper: state.elements.popper,
1786
+ popperRect: state.rects.popper,
1787
+ gpuAcceleration,
1788
+ isFixed: state.options.strategy === "fixed"
1488
1789
  };
1489
- t.modifiersData.popperOffsets != null && (t.styles.popper = Object.assign({}, t.styles.popper, Ze(Object.assign({}, f2, {
1490
- offsets: t.modifiersData.popperOffsets,
1491
- position: t.options.strategy,
1492
- adaptive: l2,
1493
- roundOffsets: a2
1494
- })))), t.modifiersData.arrow != null && (t.styles.arrow = Object.assign({}, t.styles.arrow, Ze(Object.assign({}, f2, {
1495
- offsets: t.modifiersData.arrow,
1496
- position: "absolute",
1497
- adaptive: false,
1498
- roundOffsets: a2
1499
- })))), t.attributes.popper = Object.assign({}, t.attributes.popper, {
1500
- "data-popper-placement": t.placement
1790
+ if (state.modifiersData.popperOffsets != null) {
1791
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1792
+ offsets: state.modifiersData.popperOffsets,
1793
+ position: state.options.strategy,
1794
+ adaptive,
1795
+ roundOffsets
1796
+ })));
1797
+ }
1798
+ if (state.modifiersData.arrow != null) {
1799
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1800
+ offsets: state.modifiersData.arrow,
1801
+ position: "absolute",
1802
+ adaptive: false,
1803
+ roundOffsets
1804
+ })));
1805
+ }
1806
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1807
+ "data-popper-placement": state.placement
1501
1808
  });
1502
1809
  }
1503
- const sr = {
1810
+ const computeStyles$1 = {
1504
1811
  name: "computeStyles",
1505
1812
  enabled: true,
1506
1813
  phase: "beforeWrite",
1507
- fn: ar,
1814
+ fn: computeStyles,
1508
1815
  data: {}
1509
1816
  };
1510
- var ge = {
1817
+ var passive = {
1511
1818
  passive: true
1512
1819
  };
1513
- function cr(e) {
1514
- var t = e.state, r = e.instance, i = e.options, n = i.scroll, o2 = n === void 0 ? true : n, l2 = i.resize, s2 = l2 === void 0 ? true : l2, a2 = B(t.elements.popper), f2 = [].concat(t.scrollParents.reference, t.scrollParents.popper);
1515
- return o2 && f2.forEach(function(c2) {
1516
- c2.addEventListener("scroll", r.update, ge);
1517
- }), s2 && a2.addEventListener("resize", r.update, ge), function() {
1518
- o2 && f2.forEach(function(c2) {
1519
- c2.removeEventListener("scroll", r.update, ge);
1520
- }), s2 && a2.removeEventListener("resize", r.update, ge);
1820
+ function effect(_ref) {
1821
+ var state = _ref.state, instance = _ref.instance, options = _ref.options;
1822
+ var _options$scroll = options.scroll, scroll = _options$scroll === void 0 ? true : _options$scroll, _options$resize = options.resize, resize = _options$resize === void 0 ? true : _options$resize;
1823
+ var window2 = getWindow(state.elements.popper);
1824
+ var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1825
+ if (scroll) {
1826
+ scrollParents.forEach(function(scrollParent) {
1827
+ scrollParent.addEventListener("scroll", instance.update, passive);
1828
+ });
1829
+ }
1830
+ if (resize) {
1831
+ window2.addEventListener("resize", instance.update, passive);
1832
+ }
1833
+ return function() {
1834
+ if (scroll) {
1835
+ scrollParents.forEach(function(scrollParent) {
1836
+ scrollParent.removeEventListener("scroll", instance.update, passive);
1837
+ });
1838
+ }
1839
+ if (resize) {
1840
+ window2.removeEventListener("resize", instance.update, passive);
1841
+ }
1521
1842
  };
1522
1843
  }
1523
- const lr = {
1844
+ const eventListeners = {
1524
1845
  name: "eventListeners",
1525
1846
  enabled: true,
1526
1847
  phase: "write",
1527
- fn: function() {
1848
+ fn: function fn() {
1528
1849
  },
1529
- effect: cr,
1850
+ effect,
1530
1851
  data: {}
1531
1852
  };
1532
- var fr = {
1853
+ var hash$1 = {
1533
1854
  left: "right",
1534
1855
  right: "left",
1535
1856
  bottom: "top",
1536
1857
  top: "bottom"
1537
1858
  };
1538
- function me(e) {
1539
- return e.replace(/left|right|bottom|top/g, function(t) {
1540
- return fr[t];
1859
+ function getOppositePlacement(placement) {
1860
+ return placement.replace(/left|right|bottom|top/g, function(matched) {
1861
+ return hash$1[matched];
1541
1862
  });
1542
1863
  }
1543
- var ur = {
1864
+ var hash = {
1544
1865
  start: "end",
1545
1866
  end: "start"
1546
1867
  };
1547
- function et(e) {
1548
- return e.replace(/start|end/g, function(t) {
1549
- return ur[t];
1868
+ function getOppositeVariationPlacement(placement) {
1869
+ return placement.replace(/start|end/g, function(matched) {
1870
+ return hash[matched];
1550
1871
  });
1551
1872
  }
1552
- function Se(e) {
1553
- var t = B(e), r = t.pageXOffset, i = t.pageYOffset;
1873
+ function getWindowScroll(node) {
1874
+ var win = getWindow(node);
1875
+ var scrollLeft = win.pageXOffset;
1876
+ var scrollTop = win.pageYOffset;
1554
1877
  return {
1555
- scrollLeft: r,
1556
- scrollTop: i
1878
+ scrollLeft,
1879
+ scrollTop
1557
1880
  };
1558
1881
  }
1559
- function Me(e) {
1560
- return ee(F(e)).left + Se(e).scrollLeft;
1561
- }
1562
- function pr(e, t) {
1563
- var r = B(e), i = F(e), n = r.visualViewport, o2 = i.clientWidth, l2 = i.clientHeight, s2 = 0, a2 = 0;
1564
- if (n) {
1565
- o2 = n.width, l2 = n.height;
1566
- var f2 = dt();
1567
- (f2 || !f2 && t === "fixed") && (s2 = n.offsetLeft, a2 = n.offsetTop);
1882
+ function getWindowScrollBarX(element) {
1883
+ return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
1884
+ }
1885
+ function getViewportRect(element, strategy) {
1886
+ var win = getWindow(element);
1887
+ var html = getDocumentElement(element);
1888
+ var visualViewport = win.visualViewport;
1889
+ var width = html.clientWidth;
1890
+ var height = html.clientHeight;
1891
+ var x = 0;
1892
+ var y = 0;
1893
+ if (visualViewport) {
1894
+ width = visualViewport.width;
1895
+ height = visualViewport.height;
1896
+ var layoutViewport = isLayoutViewport();
1897
+ if (layoutViewport || !layoutViewport && strategy === "fixed") {
1898
+ x = visualViewport.offsetLeft;
1899
+ y = visualViewport.offsetTop;
1900
+ }
1568
1901
  }
1569
1902
  return {
1570
- width: o2,
1571
- height: l2,
1572
- x: s2 + Me(e),
1573
- y: a2
1903
+ width,
1904
+ height,
1905
+ x: x + getWindowScrollBarX(element),
1906
+ y
1574
1907
  };
1575
1908
  }
1576
- function dr(e) {
1577
- var t, r = F(e), i = Se(e), n = (t = e.ownerDocument) == null ? void 0 : t.body, o2 = _(r.scrollWidth, r.clientWidth, n ? n.scrollWidth : 0, n ? n.clientWidth : 0), l2 = _(r.scrollHeight, r.clientHeight, n ? n.scrollHeight : 0, n ? n.clientHeight : 0), s2 = -i.scrollLeft + Me(e), a2 = -i.scrollTop;
1578
- return V(n || r).direction === "rtl" && (s2 += _(r.clientWidth, n ? n.clientWidth : 0) - o2), {
1579
- width: o2,
1580
- height: l2,
1581
- x: s2,
1582
- y: a2
1909
+ function getDocumentRect(element) {
1910
+ var _element$ownerDocumen;
1911
+ var html = getDocumentElement(element);
1912
+ var winScroll = getWindowScroll(element);
1913
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1914
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1915
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1916
+ var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
1917
+ var y = -winScroll.scrollTop;
1918
+ if (getComputedStyle$1(body || html).direction === "rtl") {
1919
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1920
+ }
1921
+ return {
1922
+ width,
1923
+ height,
1924
+ x,
1925
+ y
1583
1926
  };
1584
1927
  }
1585
- function je(e) {
1586
- var t = V(e), r = t.overflow, i = t.overflowX, n = t.overflowY;
1587
- return /auto|scroll|overlay|hidden/.test(r + n + i);
1928
+ function isScrollParent(element) {
1929
+ var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
1930
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1588
1931
  }
1589
- function yt(e) {
1590
- return ["html", "body", "#document"].indexOf(N(e)) >= 0 ? e.ownerDocument.body : T(e) && je(e) ? e : yt(we(e));
1932
+ function getScrollParent(node) {
1933
+ if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
1934
+ return node.ownerDocument.body;
1935
+ }
1936
+ if (isHTMLElement(node) && isScrollParent(node)) {
1937
+ return node;
1938
+ }
1939
+ return getScrollParent(getParentNode(node));
1591
1940
  }
1592
- function ae(e, t) {
1593
- var r;
1594
- t === void 0 && (t = []);
1595
- var i = yt(e), n = i === ((r = e.ownerDocument) == null ? void 0 : r.body), o2 = B(i), l2 = n ? [o2].concat(o2.visualViewport || [], je(i) ? i : []) : i, s2 = t.concat(l2);
1596
- return n ? s2 : (
1941
+ function listScrollParents(element, list) {
1942
+ var _element$ownerDocumen;
1943
+ if (list === void 0) {
1944
+ list = [];
1945
+ }
1946
+ var scrollParent = getScrollParent(element);
1947
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
1948
+ var win = getWindow(scrollParent);
1949
+ var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
1950
+ var updatedList = list.concat(target);
1951
+ return isBody ? updatedList : (
1597
1952
  // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
1598
- s2.concat(ae(we(l2)))
1953
+ updatedList.concat(listScrollParents(getParentNode(target)))
1599
1954
  );
1600
1955
  }
1601
- function $e(e) {
1602
- return Object.assign({}, e, {
1603
- left: e.x,
1604
- top: e.y,
1605
- right: e.x + e.width,
1606
- bottom: e.y + e.height
1956
+ function rectToClientRect(rect) {
1957
+ return Object.assign({}, rect, {
1958
+ left: rect.x,
1959
+ top: rect.y,
1960
+ right: rect.x + rect.width,
1961
+ bottom: rect.y + rect.height
1962
+ });
1963
+ }
1964
+ function getInnerBoundingClientRect(element, strategy) {
1965
+ var rect = getBoundingClientRect(element, false, strategy === "fixed");
1966
+ rect.top = rect.top + element.clientTop;
1967
+ rect.left = rect.left + element.clientLeft;
1968
+ rect.bottom = rect.top + element.clientHeight;
1969
+ rect.right = rect.left + element.clientWidth;
1970
+ rect.width = element.clientWidth;
1971
+ rect.height = element.clientHeight;
1972
+ rect.x = rect.left;
1973
+ rect.y = rect.top;
1974
+ return rect;
1975
+ }
1976
+ function getClientRectFromMixedType(element, clippingParent, strategy) {
1977
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
1978
+ }
1979
+ function getClippingParents(element) {
1980
+ var clippingParents2 = listScrollParents(getParentNode(element));
1981
+ var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
1982
+ var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1983
+ if (!isElement(clipperElement)) {
1984
+ return [];
1985
+ }
1986
+ return clippingParents2.filter(function(clippingParent) {
1987
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
1607
1988
  });
1608
1989
  }
1609
- function vr(e, t) {
1610
- var r = ee(e, false, t === "fixed");
1611
- return r.top = r.top + e.clientTop, r.left = r.left + e.clientLeft, r.bottom = r.top + e.clientHeight, r.right = r.left + e.clientWidth, r.width = e.clientWidth, r.height = e.clientHeight, r.x = r.left, r.y = r.top, r;
1612
- }
1613
- function tt(e, t, r) {
1614
- return t === ut ? $e(pr(e, r)) : K(t) ? vr(t, r) : $e(dr(F(e)));
1615
- }
1616
- function hr(e) {
1617
- var t = ae(we(e)), r = ["absolute", "fixed"].indexOf(V(e).position) >= 0, i = r && T(e) ? fe(e) : e;
1618
- return K(i) ? t.filter(function(n) {
1619
- return K(n) && vt(n, i) && N(n) !== "body";
1620
- }) : [];
1621
- }
1622
- function gr(e, t, r, i) {
1623
- var n = t === "clippingParents" ? hr(e) : [].concat(t), o2 = [].concat(n, [r]), l2 = o2[0], s2 = o2.reduce(function(a2, f2) {
1624
- var c2 = tt(e, f2, i);
1625
- return a2.top = _(c2.top, a2.top), a2.right = ye(c2.right, a2.right), a2.bottom = ye(c2.bottom, a2.bottom), a2.left = _(c2.left, a2.left), a2;
1626
- }, tt(e, l2, i));
1627
- return s2.width = s2.right - s2.left, s2.height = s2.bottom - s2.top, s2.x = s2.left, s2.y = s2.top, s2;
1628
- }
1629
- function wt(e) {
1630
- var t = e.reference, r = e.element, i = e.placement, n = i ? H(i) : null, o2 = i ? te(i) : null, l2 = t.x + t.width / 2 - r.width / 2, s2 = t.y + t.height / 2 - r.height / 2, a2;
1631
- switch (n) {
1632
- case k:
1633
- a2 = {
1634
- x: l2,
1635
- y: t.y - r.height
1990
+ function getClippingRect(element, boundary, rootBoundary, strategy) {
1991
+ var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
1992
+ var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
1993
+ var firstClippingParent = clippingParents2[0];
1994
+ var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
1995
+ var rect = getClientRectFromMixedType(element, clippingParent, strategy);
1996
+ accRect.top = max(rect.top, accRect.top);
1997
+ accRect.right = min(rect.right, accRect.right);
1998
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1999
+ accRect.left = max(rect.left, accRect.left);
2000
+ return accRect;
2001
+ }, getClientRectFromMixedType(element, firstClippingParent, strategy));
2002
+ clippingRect.width = clippingRect.right - clippingRect.left;
2003
+ clippingRect.height = clippingRect.bottom - clippingRect.top;
2004
+ clippingRect.x = clippingRect.left;
2005
+ clippingRect.y = clippingRect.top;
2006
+ return clippingRect;
2007
+ }
2008
+ function computeOffsets(_ref) {
2009
+ var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
2010
+ var basePlacement = placement ? getBasePlacement(placement) : null;
2011
+ var variation = placement ? getVariation(placement) : null;
2012
+ var commonX = reference2.x + reference2.width / 2 - element.width / 2;
2013
+ var commonY = reference2.y + reference2.height / 2 - element.height / 2;
2014
+ var offsets;
2015
+ switch (basePlacement) {
2016
+ case top:
2017
+ offsets = {
2018
+ x: commonX,
2019
+ y: reference2.y - element.height
1636
2020
  };
1637
2021
  break;
1638
- case S:
1639
- a2 = {
1640
- x: l2,
1641
- y: t.y + t.height
2022
+ case bottom:
2023
+ offsets = {
2024
+ x: commonX,
2025
+ y: reference2.y + reference2.height
1642
2026
  };
1643
2027
  break;
1644
- case M:
1645
- a2 = {
1646
- x: t.x + t.width,
1647
- y: s2
2028
+ case right:
2029
+ offsets = {
2030
+ x: reference2.x + reference2.width,
2031
+ y: commonY
1648
2032
  };
1649
2033
  break;
1650
- case D:
1651
- a2 = {
1652
- x: t.x - r.width,
1653
- y: s2
2034
+ case left:
2035
+ offsets = {
2036
+ x: reference2.x - element.width,
2037
+ y: commonY
1654
2038
  };
1655
2039
  break;
1656
2040
  default:
1657
- a2 = {
1658
- x: t.x,
1659
- y: t.y
2041
+ offsets = {
2042
+ x: reference2.x,
2043
+ y: reference2.y
1660
2044
  };
1661
2045
  }
1662
- var f2 = n ? Te(n) : null;
1663
- if (f2 != null) {
1664
- var c2 = f2 === "y" ? "height" : "width";
1665
- switch (o2) {
1666
- case Q:
1667
- a2[f2] = a2[f2] - (t[c2] / 2 - r[c2] / 2);
2046
+ var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
2047
+ if (mainAxis != null) {
2048
+ var len = mainAxis === "y" ? "height" : "width";
2049
+ switch (variation) {
2050
+ case start:
2051
+ offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
1668
2052
  break;
1669
- case se:
1670
- a2[f2] = a2[f2] + (t[c2] / 2 - r[c2] / 2);
2053
+ case end:
2054
+ offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
1671
2055
  break;
1672
2056
  }
1673
2057
  }
1674
- return a2;
1675
- }
1676
- function ce(e, t) {
1677
- t === void 0 && (t = {});
1678
- var r = t, i = r.placement, n = i === void 0 ? e.placement : i, o2 = r.strategy, l2 = o2 === void 0 ? e.strategy : o2, s2 = r.boundary, a2 = s2 === void 0 ? jt : s2, f2 = r.rootBoundary, c2 = f2 === void 0 ? ut : f2, h2 = r.elementContext, y2 = h2 === void 0 ? ne : h2, u2 = r.altBoundary, b2 = u2 === void 0 ? false : u2, v2 = r.padding, d2 = v2 === void 0 ? 0 : v2, w2 = gt(typeof d2 != "number" ? d2 : mt(d2, le)), O2 = y2 === ne ? Wt : ne, E2 = e.rects.popper, p2 = e.elements[b2 ? O2 : y2], g2 = gr(K(p2) ? p2 : p2.contextElement || F(e.elements.popper), a2, c2, l2), m2 = ee(e.elements.reference), x2 = wt({
1679
- reference: m2,
1680
- element: E2,
2058
+ return offsets;
2059
+ }
2060
+ function detectOverflow(state, options) {
2061
+ if (options === void 0) {
2062
+ options = {};
2063
+ }
2064
+ var _options = options, _options$placement = _options.placement, placement = _options$placement === void 0 ? state.placement : _options$placement, _options$strategy = _options.strategy, strategy = _options$strategy === void 0 ? state.strategy : _options$strategy, _options$boundary = _options.boundary, boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, _options$rootBoundary = _options.rootBoundary, rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, _options$elementConte = _options.elementContext, elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, _options$altBoundary = _options.altBoundary, altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, _options$padding = _options.padding, padding = _options$padding === void 0 ? 0 : _options$padding;
2065
+ var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
2066
+ var altContext = elementContext === popper ? reference : popper;
2067
+ var popperRect = state.rects.popper;
2068
+ var element = state.elements[altBoundary ? altContext : elementContext];
2069
+ var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
2070
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
2071
+ var popperOffsets2 = computeOffsets({
2072
+ reference: referenceClientRect,
2073
+ element: popperRect,
1681
2074
  strategy: "absolute",
1682
- placement: n
1683
- }), L2 = $e(Object.assign({}, E2, x2)), P2 = y2 === ne ? L2 : m2, A2 = {
1684
- top: g2.top - P2.top + w2.top,
1685
- bottom: P2.bottom - g2.bottom + w2.bottom,
1686
- left: g2.left - P2.left + w2.left,
1687
- right: P2.right - g2.right + w2.right
1688
- }, $2 = e.modifiersData.offset;
1689
- if (y2 === ne && $2) {
1690
- var j2 = $2[n];
1691
- Object.keys(A2).forEach(function(C2) {
1692
- var X2 = [M, S].indexOf(C2) >= 0 ? 1 : -1, Y2 = [k, S].indexOf(C2) >= 0 ? "y" : "x";
1693
- A2[C2] += j2[Y2] * X2;
2075
+ placement
2076
+ });
2077
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
2078
+ var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
2079
+ var overflowOffsets = {
2080
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
2081
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
2082
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
2083
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
2084
+ };
2085
+ var offsetData = state.modifiersData.offset;
2086
+ if (elementContext === popper && offsetData) {
2087
+ var offset2 = offsetData[placement];
2088
+ Object.keys(overflowOffsets).forEach(function(key) {
2089
+ var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
2090
+ var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
2091
+ overflowOffsets[key] += offset2[axis] * multiply;
1694
2092
  });
1695
2093
  }
1696
- return A2;
2094
+ return overflowOffsets;
1697
2095
  }
1698
- function mr(e, t) {
1699
- t === void 0 && (t = {});
1700
- var r = t, i = r.placement, n = r.boundary, o2 = r.rootBoundary, l2 = r.padding, s2 = r.flipVariations, a2 = r.allowedAutoPlacements, f2 = a2 === void 0 ? pt : a2, c2 = te(i), h2 = c2 ? s2 ? Je : Je.filter(function(b2) {
1701
- return te(b2) === c2;
1702
- }) : le, y2 = h2.filter(function(b2) {
1703
- return f2.indexOf(b2) >= 0;
2096
+ function computeAutoPlacement(state, options) {
2097
+ if (options === void 0) {
2098
+ options = {};
2099
+ }
2100
+ var _options = options, placement = _options.placement, boundary = _options.boundary, rootBoundary = _options.rootBoundary, padding = _options.padding, flipVariations = _options.flipVariations, _options$allowedAutoP = _options.allowedAutoPlacements, allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
2101
+ var variation = getVariation(placement);
2102
+ var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
2103
+ return getVariation(placement2) === variation;
2104
+ }) : basePlacements;
2105
+ var allowedPlacements = placements$1.filter(function(placement2) {
2106
+ return allowedAutoPlacements.indexOf(placement2) >= 0;
1704
2107
  });
1705
- y2.length === 0 && (y2 = h2);
1706
- var u2 = y2.reduce(function(b2, v2) {
1707
- return b2[v2] = ce(e, {
1708
- placement: v2,
1709
- boundary: n,
1710
- rootBoundary: o2,
1711
- padding: l2
1712
- })[H(v2)], b2;
2108
+ if (allowedPlacements.length === 0) {
2109
+ allowedPlacements = placements$1;
2110
+ }
2111
+ var overflows = allowedPlacements.reduce(function(acc, placement2) {
2112
+ acc[placement2] = detectOverflow(state, {
2113
+ placement: placement2,
2114
+ boundary,
2115
+ rootBoundary,
2116
+ padding
2117
+ })[getBasePlacement(placement2)];
2118
+ return acc;
1713
2119
  }, {});
1714
- return Object.keys(u2).sort(function(b2, v2) {
1715
- return u2[b2] - u2[v2];
2120
+ return Object.keys(overflows).sort(function(a, b) {
2121
+ return overflows[a] - overflows[b];
1716
2122
  });
1717
2123
  }
1718
- function yr(e) {
1719
- if (H(e) === De)
2124
+ function getExpandedFallbackPlacements(placement) {
2125
+ if (getBasePlacement(placement) === auto) {
1720
2126
  return [];
1721
- var t = me(e);
1722
- return [et(e), t, et(t)];
1723
- }
1724
- function wr(e) {
1725
- var t = e.state, r = e.options, i = e.name;
1726
- if (!t.modifiersData[i]._skip) {
1727
- for (var n = r.mainAxis, o2 = n === void 0 ? true : n, l2 = r.altAxis, s2 = l2 === void 0 ? true : l2, a2 = r.fallbackPlacements, f2 = r.padding, c2 = r.boundary, h2 = r.rootBoundary, y2 = r.altBoundary, u2 = r.flipVariations, b2 = u2 === void 0 ? true : u2, v2 = r.allowedAutoPlacements, d2 = t.options.placement, w2 = H(d2), O2 = w2 === d2, E2 = a2 || (O2 || !b2 ? [me(d2)] : yr(d2)), p2 = [d2].concat(E2).reduce(function(G2, I2) {
1728
- return G2.concat(H(I2) === De ? mr(t, {
1729
- placement: I2,
1730
- boundary: c2,
1731
- rootBoundary: h2,
1732
- padding: f2,
1733
- flipVariations: b2,
1734
- allowedAutoPlacements: v2
1735
- }) : I2);
1736
- }, []), g2 = t.rects.reference, m2 = t.rects.popper, x2 = /* @__PURE__ */ new Map(), L2 = true, P2 = p2[0], A2 = 0; A2 < p2.length; A2++) {
1737
- var $2 = p2[A2], j2 = H($2), C2 = te($2) === Q, X2 = [k, S].indexOf(j2) >= 0, Y2 = X2 ? "width" : "height", R2 = ce(t, {
1738
- placement: $2,
1739
- boundary: c2,
1740
- rootBoundary: h2,
1741
- altBoundary: y2,
1742
- padding: f2
1743
- }), W2 = X2 ? C2 ? M : D : C2 ? S : k;
1744
- g2[Y2] > m2[Y2] && (W2 = me(W2));
1745
- var ue = me(W2), q2 = [];
1746
- if (o2 && q2.push(R2[j2] <= 0), s2 && q2.push(R2[W2] <= 0, R2[ue] <= 0), q2.every(function(G2) {
1747
- return G2;
1748
- })) {
1749
- P2 = $2, L2 = false;
1750
- break;
1751
- }
1752
- x2.set($2, q2);
1753
- }
1754
- if (L2)
1755
- for (var pe = b2 ? 3 : 1, be = function(I2) {
1756
- var ie = p2.find(function(ve) {
1757
- var z2 = x2.get(ve);
1758
- if (z2)
1759
- return z2.slice(0, I2).every(function(xe) {
1760
- return xe;
1761
- });
1762
- });
1763
- if (ie)
1764
- return P2 = ie, "break";
1765
- }, re = pe; re > 0; re--) {
1766
- var de = be(re);
1767
- if (de === "break") break;
2127
+ }
2128
+ var oppositePlacement = getOppositePlacement(placement);
2129
+ return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
2130
+ }
2131
+ function flip(_ref) {
2132
+ var state = _ref.state, options = _ref.options, name = _ref.name;
2133
+ if (state.modifiersData[name]._skip) {
2134
+ return;
2135
+ }
2136
+ var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, specifiedFallbackPlacements = options.fallbackPlacements, padding = options.padding, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, _options$flipVariatio = options.flipVariations, flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, allowedAutoPlacements = options.allowedAutoPlacements;
2137
+ var preferredPlacement = state.options.placement;
2138
+ var basePlacement = getBasePlacement(preferredPlacement);
2139
+ var isBasePlacement = basePlacement === preferredPlacement;
2140
+ var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
2141
+ var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
2142
+ return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, {
2143
+ placement: placement2,
2144
+ boundary,
2145
+ rootBoundary,
2146
+ padding,
2147
+ flipVariations,
2148
+ allowedAutoPlacements
2149
+ }) : placement2);
2150
+ }, []);
2151
+ var referenceRect = state.rects.reference;
2152
+ var popperRect = state.rects.popper;
2153
+ var checksMap = /* @__PURE__ */ new Map();
2154
+ var makeFallbackChecks = true;
2155
+ var firstFittingPlacement = placements2[0];
2156
+ for (var i = 0; i < placements2.length; i++) {
2157
+ var placement = placements2[i];
2158
+ var _basePlacement = getBasePlacement(placement);
2159
+ var isStartVariation = getVariation(placement) === start;
2160
+ var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
2161
+ var len = isVertical ? "width" : "height";
2162
+ var overflow = detectOverflow(state, {
2163
+ placement,
2164
+ boundary,
2165
+ rootBoundary,
2166
+ altBoundary,
2167
+ padding
2168
+ });
2169
+ var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
2170
+ if (referenceRect[len] > popperRect[len]) {
2171
+ mainVariationSide = getOppositePlacement(mainVariationSide);
2172
+ }
2173
+ var altVariationSide = getOppositePlacement(mainVariationSide);
2174
+ var checks = [];
2175
+ if (checkMainAxis) {
2176
+ checks.push(overflow[_basePlacement] <= 0);
2177
+ }
2178
+ if (checkAltAxis) {
2179
+ checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
2180
+ }
2181
+ if (checks.every(function(check) {
2182
+ return check;
2183
+ })) {
2184
+ firstFittingPlacement = placement;
2185
+ makeFallbackChecks = false;
2186
+ break;
2187
+ }
2188
+ checksMap.set(placement, checks);
2189
+ }
2190
+ if (makeFallbackChecks) {
2191
+ var numberOfChecks = flipVariations ? 3 : 1;
2192
+ var _loop = function _loop2(_i2) {
2193
+ var fittingPlacement = placements2.find(function(placement2) {
2194
+ var checks2 = checksMap.get(placement2);
2195
+ if (checks2) {
2196
+ return checks2.slice(0, _i2).every(function(check) {
2197
+ return check;
2198
+ });
2199
+ }
2200
+ });
2201
+ if (fittingPlacement) {
2202
+ firstFittingPlacement = fittingPlacement;
2203
+ return "break";
1768
2204
  }
1769
- t.placement !== P2 && (t.modifiersData[i]._skip = true, t.placement = P2, t.reset = true);
2205
+ };
2206
+ for (var _i = numberOfChecks; _i > 0; _i--) {
2207
+ var _ret = _loop(_i);
2208
+ if (_ret === "break") break;
2209
+ }
2210
+ }
2211
+ if (state.placement !== firstFittingPlacement) {
2212
+ state.modifiersData[name]._skip = true;
2213
+ state.placement = firstFittingPlacement;
2214
+ state.reset = true;
1770
2215
  }
1771
2216
  }
1772
- const br = {
2217
+ const flip$1 = {
1773
2218
  name: "flip",
1774
2219
  enabled: true,
1775
2220
  phase: "main",
1776
- fn: wr,
2221
+ fn: flip,
1777
2222
  requiresIfExists: ["offset"],
1778
2223
  data: {
1779
2224
  _skip: false
1780
2225
  }
1781
2226
  };
1782
- function rt(e, t, r) {
1783
- return r === void 0 && (r = {
1784
- x: 0,
1785
- y: 0
1786
- }), {
1787
- top: e.top - t.height - r.y,
1788
- right: e.right - t.width + r.x,
1789
- bottom: e.bottom - t.height + r.y,
1790
- left: e.left - t.width - r.x
2227
+ function getSideOffsets(overflow, rect, preventedOffsets) {
2228
+ if (preventedOffsets === void 0) {
2229
+ preventedOffsets = {
2230
+ x: 0,
2231
+ y: 0
2232
+ };
2233
+ }
2234
+ return {
2235
+ top: overflow.top - rect.height - preventedOffsets.y,
2236
+ right: overflow.right - rect.width + preventedOffsets.x,
2237
+ bottom: overflow.bottom - rect.height + preventedOffsets.y,
2238
+ left: overflow.left - rect.width - preventedOffsets.x
1791
2239
  };
1792
2240
  }
1793
- function it(e) {
1794
- return [k, M, S, D].some(function(t) {
1795
- return e[t] >= 0;
2241
+ function isAnySideFullyClipped(overflow) {
2242
+ return [top, right, bottom, left].some(function(side) {
2243
+ return overflow[side] >= 0;
1796
2244
  });
1797
2245
  }
1798
- function xr(e) {
1799
- var t = e.state, r = e.name, i = t.rects.reference, n = t.rects.popper, o2 = t.modifiersData.preventOverflow, l2 = ce(t, {
2246
+ function hide(_ref) {
2247
+ var state = _ref.state, name = _ref.name;
2248
+ var referenceRect = state.rects.reference;
2249
+ var popperRect = state.rects.popper;
2250
+ var preventedOffsets = state.modifiersData.preventOverflow;
2251
+ var referenceOverflow = detectOverflow(state, {
1800
2252
  elementContext: "reference"
1801
- }), s2 = ce(t, {
2253
+ });
2254
+ var popperAltOverflow = detectOverflow(state, {
1802
2255
  altBoundary: true
1803
- }), a2 = rt(l2, i), f2 = rt(s2, n, o2), c2 = it(a2), h2 = it(f2);
1804
- t.modifiersData[r] = {
1805
- referenceClippingOffsets: a2,
1806
- popperEscapeOffsets: f2,
1807
- isReferenceHidden: c2,
1808
- hasPopperEscaped: h2
1809
- }, t.attributes.popper = Object.assign({}, t.attributes.popper, {
1810
- "data-popper-reference-hidden": c2,
1811
- "data-popper-escaped": h2
2256
+ });
2257
+ var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
2258
+ var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
2259
+ var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
2260
+ var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
2261
+ state.modifiersData[name] = {
2262
+ referenceClippingOffsets,
2263
+ popperEscapeOffsets,
2264
+ isReferenceHidden,
2265
+ hasPopperEscaped
2266
+ };
2267
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
2268
+ "data-popper-reference-hidden": isReferenceHidden,
2269
+ "data-popper-escaped": hasPopperEscaped
1812
2270
  });
1813
2271
  }
1814
- const Or = {
2272
+ const hide$1 = {
1815
2273
  name: "hide",
1816
2274
  enabled: true,
1817
2275
  phase: "main",
1818
2276
  requiresIfExists: ["preventOverflow"],
1819
- fn: xr
2277
+ fn: hide
1820
2278
  };
1821
- function Er(e, t, r) {
1822
- var i = H(e), n = [D, k].indexOf(i) >= 0 ? -1 : 1, o2 = typeof r == "function" ? r(Object.assign({}, t, {
1823
- placement: e
1824
- })) : r, l2 = o2[0], s2 = o2[1];
1825
- return l2 = l2 || 0, s2 = (s2 || 0) * n, [D, M].indexOf(i) >= 0 ? {
1826
- x: s2,
1827
- y: l2
2279
+ function distanceAndSkiddingToXY(placement, rects, offset2) {
2280
+ var basePlacement = getBasePlacement(placement);
2281
+ var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
2282
+ var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
2283
+ placement
2284
+ })) : offset2, skidding = _ref[0], distance = _ref[1];
2285
+ skidding = skidding || 0;
2286
+ distance = (distance || 0) * invertDistance;
2287
+ return [left, right].indexOf(basePlacement) >= 0 ? {
2288
+ x: distance,
2289
+ y: skidding
1828
2290
  } : {
1829
- x: l2,
1830
- y: s2
2291
+ x: skidding,
2292
+ y: distance
1831
2293
  };
1832
2294
  }
1833
- function Ar(e) {
1834
- var t = e.state, r = e.options, i = e.name, n = r.offset, o2 = n === void 0 ? [0, 0] : n, l2 = pt.reduce(function(c2, h2) {
1835
- return c2[h2] = Er(h2, t.rects, o2), c2;
1836
- }, {}), s2 = l2[t.placement], a2 = s2.x, f2 = s2.y;
1837
- t.modifiersData.popperOffsets != null && (t.modifiersData.popperOffsets.x += a2, t.modifiersData.popperOffsets.y += f2), t.modifiersData[i] = l2;
2295
+ function offset(_ref2) {
2296
+ var state = _ref2.state, options = _ref2.options, name = _ref2.name;
2297
+ var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
2298
+ var data = placements.reduce(function(acc, placement) {
2299
+ acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
2300
+ return acc;
2301
+ }, {});
2302
+ var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
2303
+ if (state.modifiersData.popperOffsets != null) {
2304
+ state.modifiersData.popperOffsets.x += x;
2305
+ state.modifiersData.popperOffsets.y += y;
2306
+ }
2307
+ state.modifiersData[name] = data;
1838
2308
  }
1839
- const Pr = {
2309
+ const offset$1 = {
1840
2310
  name: "offset",
1841
2311
  enabled: true,
1842
2312
  phase: "main",
1843
2313
  requires: ["popperOffsets"],
1844
- fn: Ar
2314
+ fn: offset
1845
2315
  };
1846
- function Lr(e) {
1847
- var t = e.state, r = e.name;
1848
- t.modifiersData[r] = wt({
1849
- reference: t.rects.reference,
1850
- element: t.rects.popper,
2316
+ function popperOffsets(_ref) {
2317
+ var state = _ref.state, name = _ref.name;
2318
+ state.modifiersData[name] = computeOffsets({
2319
+ reference: state.rects.reference,
2320
+ element: state.rects.popper,
1851
2321
  strategy: "absolute",
1852
- placement: t.placement
2322
+ placement: state.placement
1853
2323
  });
1854
2324
  }
1855
- const $r = {
2325
+ const popperOffsets$1 = {
1856
2326
  name: "popperOffsets",
1857
2327
  enabled: true,
1858
2328
  phase: "read",
1859
- fn: Lr,
2329
+ fn: popperOffsets,
1860
2330
  data: {}
1861
2331
  };
1862
- function Cr(e) {
1863
- return e === "x" ? "y" : "x";
1864
- }
1865
- function kr(e) {
1866
- var t = e.state, r = e.options, i = e.name, n = r.mainAxis, o2 = n === void 0 ? true : n, l2 = r.altAxis, s2 = l2 === void 0 ? false : l2, a2 = r.boundary, f2 = r.rootBoundary, c2 = r.altBoundary, h2 = r.padding, y2 = r.tether, u2 = y2 === void 0 ? true : y2, b2 = r.tetherOffset, v2 = b2 === void 0 ? 0 : b2, d2 = ce(t, {
1867
- boundary: a2,
1868
- rootBoundary: f2,
1869
- padding: h2,
1870
- altBoundary: c2
1871
- }), w2 = H(t.placement), O2 = te(t.placement), E2 = !O2, p2 = Te(w2), g2 = Cr(p2), m2 = t.modifiersData.popperOffsets, x2 = t.rects.reference, L2 = t.rects.popper, P2 = typeof v2 == "function" ? v2(Object.assign({}, t.rects, {
1872
- placement: t.placement
1873
- })) : v2, A2 = typeof P2 == "number" ? {
1874
- mainAxis: P2,
1875
- altAxis: P2
2332
+ function getAltAxis(axis) {
2333
+ return axis === "x" ? "y" : "x";
2334
+ }
2335
+ function preventOverflow(_ref) {
2336
+ var state = _ref.state, options = _ref.options, name = _ref.name;
2337
+ var _options$mainAxis = options.mainAxis, checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, _options$altAxis = options.altAxis, checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, boundary = options.boundary, rootBoundary = options.rootBoundary, altBoundary = options.altBoundary, padding = options.padding, _options$tether = options.tether, tether = _options$tether === void 0 ? true : _options$tether, _options$tetherOffset = options.tetherOffset, tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
2338
+ var overflow = detectOverflow(state, {
2339
+ boundary,
2340
+ rootBoundary,
2341
+ padding,
2342
+ altBoundary
2343
+ });
2344
+ var basePlacement = getBasePlacement(state.placement);
2345
+ var variation = getVariation(state.placement);
2346
+ var isBasePlacement = !variation;
2347
+ var mainAxis = getMainAxisFromPlacement(basePlacement);
2348
+ var altAxis = getAltAxis(mainAxis);
2349
+ var popperOffsets2 = state.modifiersData.popperOffsets;
2350
+ var referenceRect = state.rects.reference;
2351
+ var popperRect = state.rects.popper;
2352
+ var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
2353
+ placement: state.placement
2354
+ })) : tetherOffset;
2355
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
2356
+ mainAxis: tetherOffsetValue,
2357
+ altAxis: tetherOffsetValue
1876
2358
  } : Object.assign({
1877
2359
  mainAxis: 0,
1878
2360
  altAxis: 0
1879
- }, P2), $2 = t.modifiersData.offset ? t.modifiersData.offset[t.placement] : null, j2 = {
2361
+ }, tetherOffsetValue);
2362
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2363
+ var data = {
1880
2364
  x: 0,
1881
2365
  y: 0
1882
2366
  };
1883
- if (m2) {
1884
- if (o2) {
1885
- var C2, X2 = p2 === "y" ? k : D, Y2 = p2 === "y" ? S : M, R2 = p2 === "y" ? "height" : "width", W2 = m2[p2], ue = W2 + d2[X2], q2 = W2 - d2[Y2], pe = u2 ? -L2[R2] / 2 : 0, be = O2 === Q ? x2[R2] : L2[R2], re = O2 === Q ? -L2[R2] : -x2[R2], de = t.elements.arrow, G2 = u2 && de ? Be(de) : {
1886
- width: 0,
1887
- height: 0
1888
- }, I2 = t.modifiersData["arrow#persistent"] ? t.modifiersData["arrow#persistent"].padding : ht(), ie = I2[X2], ve = I2[Y2], z2 = oe(0, x2[R2], G2[R2]), xe = E2 ? x2[R2] / 2 - pe - z2 - ie - A2.mainAxis : be - z2 - ie - A2.mainAxis, Ot = E2 ? -x2[R2] / 2 + pe + z2 + ve + A2.mainAxis : re + z2 + ve + A2.mainAxis, Oe = t.elements.arrow && fe(t.elements.arrow), Et = Oe ? p2 === "y" ? Oe.clientTop || 0 : Oe.clientLeft || 0 : 0, He = (C2 = $2 == null ? void 0 : $2[p2]) != null ? C2 : 0, At = W2 + xe - He - Et, Pt = W2 + Ot - He, Ne = oe(u2 ? ye(ue, At) : ue, W2, u2 ? _(q2, Pt) : q2);
1889
- m2[p2] = Ne, j2[p2] = Ne - W2;
1890
- }
1891
- if (s2) {
1892
- var Ve, Lt = p2 === "x" ? k : D, $t = p2 === "x" ? S : M, U2 = m2[g2], he = g2 === "y" ? "height" : "width", Ie = U2 + d2[Lt], Fe = U2 - d2[$t], Ee = [k, D].indexOf(w2) !== -1, Xe = (Ve = $2 == null ? void 0 : $2[g2]) != null ? Ve : 0, Ye = Ee ? Ie : U2 - x2[he] - L2[he] - Xe + A2.altAxis, qe = Ee ? U2 + x2[he] + L2[he] - Xe - A2.altAxis : Fe, ze = u2 && Ee ? Zt(Ye, U2, qe) : oe(u2 ? Ye : Ie, U2, u2 ? qe : Fe);
1893
- m2[g2] = ze, j2[g2] = ze - U2;
1894
- }
1895
- t.modifiersData[i] = j2;
2367
+ if (!popperOffsets2) {
2368
+ return;
1896
2369
  }
1897
- }
1898
- const Dr = {
2370
+ if (checkMainAxis) {
2371
+ var _offsetModifierState$;
2372
+ var mainSide = mainAxis === "y" ? top : left;
2373
+ var altSide = mainAxis === "y" ? bottom : right;
2374
+ var len = mainAxis === "y" ? "height" : "width";
2375
+ var offset2 = popperOffsets2[mainAxis];
2376
+ var min$1 = offset2 + overflow[mainSide];
2377
+ var max$1 = offset2 - overflow[altSide];
2378
+ var additive = tether ? -popperRect[len] / 2 : 0;
2379
+ var minLen = variation === start ? referenceRect[len] : popperRect[len];
2380
+ var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
2381
+ var arrowElement = state.elements.arrow;
2382
+ var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
2383
+ width: 0,
2384
+ height: 0
2385
+ };
2386
+ var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
2387
+ var arrowPaddingMin = arrowPaddingObject[mainSide];
2388
+ var arrowPaddingMax = arrowPaddingObject[altSide];
2389
+ var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2390
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2391
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2392
+ var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2393
+ var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2394
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2395
+ var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
2396
+ var tetherMax = offset2 + maxOffset - offsetModifierValue;
2397
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset2, tether ? max(max$1, tetherMax) : max$1);
2398
+ popperOffsets2[mainAxis] = preventedOffset;
2399
+ data[mainAxis] = preventedOffset - offset2;
2400
+ }
2401
+ if (checkAltAxis) {
2402
+ var _offsetModifierState$2;
2403
+ var _mainSide = mainAxis === "x" ? top : left;
2404
+ var _altSide = mainAxis === "x" ? bottom : right;
2405
+ var _offset = popperOffsets2[altAxis];
2406
+ var _len = altAxis === "y" ? "height" : "width";
2407
+ var _min = _offset + overflow[_mainSide];
2408
+ var _max = _offset - overflow[_altSide];
2409
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2410
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2411
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2412
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2413
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2414
+ popperOffsets2[altAxis] = _preventedOffset;
2415
+ data[altAxis] = _preventedOffset - _offset;
2416
+ }
2417
+ state.modifiersData[name] = data;
2418
+ }
2419
+ const preventOverflow$1 = {
1899
2420
  name: "preventOverflow",
1900
2421
  enabled: true,
1901
2422
  phase: "main",
1902
- fn: kr,
2423
+ fn: preventOverflow,
1903
2424
  requiresIfExists: ["offset"]
1904
2425
  };
1905
- function Rr(e) {
2426
+ function getHTMLElementScroll(element) {
1906
2427
  return {
1907
- scrollLeft: e.scrollLeft,
1908
- scrollTop: e.scrollTop
2428
+ scrollLeft: element.scrollLeft,
2429
+ scrollTop: element.scrollTop
1909
2430
  };
1910
2431
  }
1911
- function Br(e) {
1912
- return e === B(e) || !T(e) ? Se(e) : Rr(e);
2432
+ function getNodeScroll(node) {
2433
+ if (node === getWindow(node) || !isHTMLElement(node)) {
2434
+ return getWindowScroll(node);
2435
+ } else {
2436
+ return getHTMLElementScroll(node);
2437
+ }
1913
2438
  }
1914
- function Tr(e) {
1915
- var t = e.getBoundingClientRect(), r = Z(t.width) / e.offsetWidth || 1, i = Z(t.height) / e.offsetHeight || 1;
1916
- return r !== 1 || i !== 1;
2439
+ function isElementScaled(element) {
2440
+ var rect = element.getBoundingClientRect();
2441
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
2442
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
2443
+ return scaleX !== 1 || scaleY !== 1;
1917
2444
  }
1918
- function Sr(e, t, r) {
1919
- r === void 0 && (r = false);
1920
- var i = T(t), n = T(t) && Tr(t), o2 = F(t), l2 = ee(e, n, r), s2 = {
2445
+ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2446
+ if (isFixed === void 0) {
2447
+ isFixed = false;
2448
+ }
2449
+ var isOffsetParentAnElement = isHTMLElement(offsetParent);
2450
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2451
+ var documentElement = getDocumentElement(offsetParent);
2452
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
2453
+ var scroll = {
1921
2454
  scrollLeft: 0,
1922
2455
  scrollTop: 0
1923
- }, a2 = {
2456
+ };
2457
+ var offsets = {
1924
2458
  x: 0,
1925
2459
  y: 0
1926
2460
  };
1927
- return (i || !i && !r) && ((N(t) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
1928
- je(o2)) && (s2 = Br(t)), T(t) ? (a2 = ee(t, true), a2.x += t.clientLeft, a2.y += t.clientTop) : o2 && (a2.x = Me(o2))), {
1929
- x: l2.left + s2.scrollLeft - a2.x,
1930
- y: l2.top + s2.scrollTop - a2.y,
1931
- width: l2.width,
1932
- height: l2.height
2461
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2462
+ if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
2463
+ isScrollParent(documentElement)) {
2464
+ scroll = getNodeScroll(offsetParent);
2465
+ }
2466
+ if (isHTMLElement(offsetParent)) {
2467
+ offsets = getBoundingClientRect(offsetParent, true);
2468
+ offsets.x += offsetParent.clientLeft;
2469
+ offsets.y += offsetParent.clientTop;
2470
+ } else if (documentElement) {
2471
+ offsets.x = getWindowScrollBarX(documentElement);
2472
+ }
2473
+ }
2474
+ return {
2475
+ x: rect.left + scroll.scrollLeft - offsets.x,
2476
+ y: rect.top + scroll.scrollTop - offsets.y,
2477
+ width: rect.width,
2478
+ height: rect.height
1933
2479
  };
1934
2480
  }
1935
- function Mr(e) {
1936
- var t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = [];
1937
- e.forEach(function(o2) {
1938
- t.set(o2.name, o2);
2481
+ function order(modifiers) {
2482
+ var map = /* @__PURE__ */ new Map();
2483
+ var visited = /* @__PURE__ */ new Set();
2484
+ var result = [];
2485
+ modifiers.forEach(function(modifier) {
2486
+ map.set(modifier.name, modifier);
1939
2487
  });
1940
- function n(o2) {
1941
- r.add(o2.name);
1942
- var l2 = [].concat(o2.requires || [], o2.requiresIfExists || []);
1943
- l2.forEach(function(s2) {
1944
- if (!r.has(s2)) {
1945
- var a2 = t.get(s2);
1946
- a2 && n(a2);
2488
+ function sort(modifier) {
2489
+ visited.add(modifier.name);
2490
+ var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
2491
+ requires.forEach(function(dep) {
2492
+ if (!visited.has(dep)) {
2493
+ var depModifier = map.get(dep);
2494
+ if (depModifier) {
2495
+ sort(depModifier);
2496
+ }
1947
2497
  }
1948
- }), i.push(o2);
2498
+ });
2499
+ result.push(modifier);
1949
2500
  }
1950
- return e.forEach(function(o2) {
1951
- r.has(o2.name) || n(o2);
1952
- }), i;
2501
+ modifiers.forEach(function(modifier) {
2502
+ if (!visited.has(modifier.name)) {
2503
+ sort(modifier);
2504
+ }
2505
+ });
2506
+ return result;
1953
2507
  }
1954
- function jr(e) {
1955
- var t = Mr(e);
1956
- return Ut.reduce(function(r, i) {
1957
- return r.concat(t.filter(function(n) {
1958
- return n.phase === i;
2508
+ function orderModifiers(modifiers) {
2509
+ var orderedModifiers = order(modifiers);
2510
+ return modifierPhases.reduce(function(acc, phase) {
2511
+ return acc.concat(orderedModifiers.filter(function(modifier) {
2512
+ return modifier.phase === phase;
1959
2513
  }));
1960
2514
  }, []);
1961
2515
  }
1962
- function Wr(e) {
1963
- var t;
2516
+ function debounce(fn) {
2517
+ var pending;
1964
2518
  return function() {
1965
- return t || (t = new Promise(function(r) {
1966
- Promise.resolve().then(function() {
1967
- t = void 0, r(e());
2519
+ if (!pending) {
2520
+ pending = new Promise(function(resolve) {
2521
+ Promise.resolve().then(function() {
2522
+ pending = void 0;
2523
+ resolve(fn());
2524
+ });
1968
2525
  });
1969
- })), t;
2526
+ }
2527
+ return pending;
1970
2528
  };
1971
2529
  }
1972
- function Hr(e) {
1973
- var t = e.reduce(function(r, i) {
1974
- var n = r[i.name];
1975
- return r[i.name] = n ? Object.assign({}, n, i, {
1976
- options: Object.assign({}, n.options, i.options),
1977
- data: Object.assign({}, n.data, i.data)
1978
- }) : i, r;
2530
+ function mergeByName(modifiers) {
2531
+ var merged = modifiers.reduce(function(merged2, current) {
2532
+ var existing = merged2[current.name];
2533
+ merged2[current.name] = existing ? Object.assign({}, existing, current, {
2534
+ options: Object.assign({}, existing.options, current.options),
2535
+ data: Object.assign({}, existing.data, current.data)
2536
+ }) : current;
2537
+ return merged2;
1979
2538
  }, {});
1980
- return Object.keys(t).map(function(r) {
1981
- return t[r];
2539
+ return Object.keys(merged).map(function(key) {
2540
+ return merged[key];
1982
2541
  });
1983
2542
  }
1984
- var nt = {
2543
+ var DEFAULT_OPTIONS = {
1985
2544
  placement: "bottom",
1986
2545
  modifiers: [],
1987
2546
  strategy: "absolute"
1988
2547
  };
1989
- function ot() {
1990
- for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
1991
- t[r] = arguments[r];
1992
- return !t.some(function(i) {
1993
- return !(i && typeof i.getBoundingClientRect == "function");
2548
+ function areValidElements() {
2549
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2550
+ args[_key] = arguments[_key];
2551
+ }
2552
+ return !args.some(function(element) {
2553
+ return !(element && typeof element.getBoundingClientRect === "function");
1994
2554
  });
1995
2555
  }
1996
- function Nr(e) {
1997
- e === void 0 && (e = {});
1998
- var t = e, r = t.defaultModifiers, i = r === void 0 ? [] : r, n = t.defaultOptions, o2 = n === void 0 ? nt : n;
1999
- return function(s2, a2, f2) {
2000
- f2 === void 0 && (f2 = o2);
2001
- var c2 = {
2556
+ function popperGenerator(generatorOptions) {
2557
+ if (generatorOptions === void 0) {
2558
+ generatorOptions = {};
2559
+ }
2560
+ var _generatorOptions = generatorOptions, _generatorOptions$def = _generatorOptions.defaultModifiers, defaultModifiers2 = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, _generatorOptions$def2 = _generatorOptions.defaultOptions, defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
2561
+ return function createPopper2(reference2, popper2, options) {
2562
+ if (options === void 0) {
2563
+ options = defaultOptions;
2564
+ }
2565
+ var state = {
2002
2566
  placement: "bottom",
2003
2567
  orderedModifiers: [],
2004
- options: Object.assign({}, nt, o2),
2568
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
2005
2569
  modifiersData: {},
2006
2570
  elements: {
2007
- reference: s2,
2008
- popper: a2
2571
+ reference: reference2,
2572
+ popper: popper2
2009
2573
  },
2010
2574
  attributes: {},
2011
2575
  styles: {}
2012
- }, h2 = [], y2 = false, u2 = {
2013
- state: c2,
2014
- setOptions: function(w2) {
2015
- var O2 = typeof w2 == "function" ? w2(c2.options) : w2;
2016
- v2(), c2.options = Object.assign({}, o2, c2.options, O2), c2.scrollParents = {
2017
- reference: K(s2) ? ae(s2) : s2.contextElement ? ae(s2.contextElement) : [],
2018
- popper: ae(a2)
2576
+ };
2577
+ var effectCleanupFns = [];
2578
+ var isDestroyed = false;
2579
+ var instance = {
2580
+ state,
2581
+ setOptions: function setOptions(setOptionsAction) {
2582
+ var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
2583
+ cleanupModifierEffects();
2584
+ state.options = Object.assign({}, defaultOptions, state.options, options2);
2585
+ state.scrollParents = {
2586
+ reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
2587
+ popper: listScrollParents(popper2)
2019
2588
  };
2020
- var E2 = jr(Hr([].concat(i, c2.options.modifiers)));
2021
- return c2.orderedModifiers = E2.filter(function(p2) {
2022
- return p2.enabled;
2023
- }), b2(), u2.update();
2589
+ var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
2590
+ state.orderedModifiers = orderedModifiers.filter(function(m) {
2591
+ return m.enabled;
2592
+ });
2593
+ runModifierEffects();
2594
+ return instance.update();
2024
2595
  },
2025
2596
  // Sync update – it will always be executed, even if not necessary. This
2026
2597
  // is useful for low frequency updates where sync behavior simplifies the
2027
2598
  // logic.
2028
2599
  // For high frequency updates (e.g. `resize` and `scroll` events), always
2029
2600
  // prefer the async Popper#update method
2030
- forceUpdate: function() {
2031
- if (!y2) {
2032
- var w2 = c2.elements, O2 = w2.reference, E2 = w2.popper;
2033
- if (ot(O2, E2)) {
2034
- c2.rects = {
2035
- reference: Sr(O2, fe(E2), c2.options.strategy === "fixed"),
2036
- popper: Be(E2)
2037
- }, c2.reset = false, c2.placement = c2.options.placement, c2.orderedModifiers.forEach(function(A2) {
2038
- return c2.modifiersData[A2.name] = Object.assign({}, A2.data);
2039
- });
2040
- for (var p2 = 0; p2 < c2.orderedModifiers.length; p2++) {
2041
- if (c2.reset === true) {
2042
- c2.reset = false, p2 = -1;
2043
- continue;
2044
- }
2045
- var g2 = c2.orderedModifiers[p2], m2 = g2.fn, x2 = g2.options, L2 = x2 === void 0 ? {} : x2, P2 = g2.name;
2046
- typeof m2 == "function" && (c2 = m2({
2047
- state: c2,
2048
- options: L2,
2049
- name: P2,
2050
- instance: u2
2051
- }) || c2);
2052
- }
2601
+ forceUpdate: function forceUpdate() {
2602
+ if (isDestroyed) {
2603
+ return;
2604
+ }
2605
+ var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
2606
+ if (!areValidElements(reference3, popper3)) {
2607
+ return;
2608
+ }
2609
+ state.rects = {
2610
+ reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
2611
+ popper: getLayoutRect(popper3)
2612
+ };
2613
+ state.reset = false;
2614
+ state.placement = state.options.placement;
2615
+ state.orderedModifiers.forEach(function(modifier) {
2616
+ return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
2617
+ });
2618
+ for (var index2 = 0; index2 < state.orderedModifiers.length; index2++) {
2619
+ if (state.reset === true) {
2620
+ state.reset = false;
2621
+ index2 = -1;
2622
+ continue;
2623
+ }
2624
+ var _state$orderedModifie = state.orderedModifiers[index2], fn = _state$orderedModifie.fn, _state$orderedModifie2 = _state$orderedModifie.options, _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, name = _state$orderedModifie.name;
2625
+ if (typeof fn === "function") {
2626
+ state = fn({
2627
+ state,
2628
+ options: _options,
2629
+ name,
2630
+ instance
2631
+ }) || state;
2053
2632
  }
2054
2633
  }
2055
2634
  },
2056
2635
  // Async and optimistically optimized update – it will not be executed if
2057
2636
  // not necessary (debounced to run at most once-per-tick)
2058
- update: Wr(function() {
2059
- return new Promise(function(d2) {
2060
- u2.forceUpdate(), d2(c2);
2637
+ update: debounce(function() {
2638
+ return new Promise(function(resolve) {
2639
+ instance.forceUpdate();
2640
+ resolve(state);
2061
2641
  });
2062
2642
  }),
2063
- destroy: function() {
2064
- v2(), y2 = true;
2643
+ destroy: function destroy() {
2644
+ cleanupModifierEffects();
2645
+ isDestroyed = true;
2065
2646
  }
2066
2647
  };
2067
- if (!ot(s2, a2))
2068
- return u2;
2069
- u2.setOptions(f2).then(function(d2) {
2070
- !y2 && f2.onFirstUpdate && f2.onFirstUpdate(d2);
2648
+ if (!areValidElements(reference2, popper2)) {
2649
+ return instance;
2650
+ }
2651
+ instance.setOptions(options).then(function(state2) {
2652
+ if (!isDestroyed && options.onFirstUpdate) {
2653
+ options.onFirstUpdate(state2);
2654
+ }
2071
2655
  });
2072
- function b2() {
2073
- c2.orderedModifiers.forEach(function(d2) {
2074
- var w2 = d2.name, O2 = d2.options, E2 = O2 === void 0 ? {} : O2, p2 = d2.effect;
2075
- if (typeof p2 == "function") {
2076
- var g2 = p2({
2077
- state: c2,
2078
- name: w2,
2079
- instance: u2,
2080
- options: E2
2081
- }), m2 = function() {
2656
+ function runModifierEffects() {
2657
+ state.orderedModifiers.forEach(function(_ref) {
2658
+ var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect2 = _ref.effect;
2659
+ if (typeof effect2 === "function") {
2660
+ var cleanupFn = effect2({
2661
+ state,
2662
+ name,
2663
+ instance,
2664
+ options: options2
2665
+ });
2666
+ var noopFn = function noopFn2() {
2082
2667
  };
2083
- h2.push(g2 || m2);
2668
+ effectCleanupFns.push(cleanupFn || noopFn);
2084
2669
  }
2085
2670
  });
2086
2671
  }
2087
- function v2() {
2088
- h2.forEach(function(d2) {
2089
- return d2();
2090
- }), h2 = [];
2672
+ function cleanupModifierEffects() {
2673
+ effectCleanupFns.forEach(function(fn) {
2674
+ return fn();
2675
+ });
2676
+ effectCleanupFns = [];
2091
2677
  }
2092
- return u2;
2678
+ return instance;
2093
2679
  };
2094
2680
  }
2095
- var Vr = [lr, $r, sr, Gt, Pr, br, Dr, ir, Or], Ir = /* @__PURE__ */ Nr({
2096
- defaultModifiers: Vr
2681
+ var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
2682
+ var createPopper = /* @__PURE__ */ popperGenerator({
2683
+ defaultModifiers
2097
2684
  });
2098
- async function Ce(e) {
2099
- const t = this.collection.findIndex((r) => r.id === e.id);
2100
- if (t >= 0) {
2101
- const r = this.collection[t];
2102
- r.state === "opened" && r.close(), r.popper.destroy(), bt(r), Object.getOwnPropertyNames(r).forEach((i) => {
2103
- delete r[i];
2104
- }), this.collection.splice(t, 1);
2685
+ async function deregister(obj) {
2686
+ const index2 = this.collection.findIndex((entry) => {
2687
+ return entry.id === obj.id;
2688
+ });
2689
+ if (index2 >= 0) {
2690
+ const entry = this.collection[index2];
2691
+ if (entry.state === "opened") {
2692
+ entry.close();
2693
+ }
2694
+ entry.popper.destroy();
2695
+ deregisterEventListeners(entry);
2696
+ Object.getOwnPropertyNames(entry).forEach((prop) => {
2697
+ delete entry[prop];
2698
+ });
2699
+ this.collection.splice(index2, 1);
2105
2700
  }
2106
2701
  return this.collection;
2107
2702
  }
2108
- function bt(e) {
2109
- return e.__eventListeners && (e.__eventListeners.forEach((t) => {
2110
- t.el.forEach((r) => {
2111
- t.type.forEach((i) => {
2112
- e[r].removeEventListener(i, t.listener, false);
2703
+ function deregisterEventListeners(entry) {
2704
+ if (entry.__eventListeners) {
2705
+ entry.__eventListeners.forEach((evObj) => {
2706
+ evObj.el.forEach((el) => {
2707
+ evObj.type.forEach((type) => {
2708
+ entry[el].removeEventListener(type, evObj.listener, false);
2709
+ });
2113
2710
  });
2114
2711
  });
2115
- }), delete e.__eventListeners), e;
2712
+ delete entry.__eventListeners;
2713
+ }
2714
+ return entry;
2116
2715
  }
2117
- async function We(e) {
2118
- const t = st.call(this, e);
2119
- return t.el.classList.add(this.settings.stateActive), t.trigger.hasAttribute("aria-controls") && t.trigger.setAttribute("aria-expanded", "true"), t.config = at(t.el, this.settings), t.popper.setOptions({
2120
- placement: t.config.placement,
2716
+ async function open(query) {
2717
+ const popover = getPopover.call(this, query);
2718
+ popover.el.classList.add(this.settings.stateActive);
2719
+ if (popover.trigger.hasAttribute("aria-controls")) {
2720
+ popover.trigger.setAttribute("aria-expanded", "true");
2721
+ }
2722
+ popover.config = getConfig(popover.el, this.settings);
2723
+ popover.popper.setOptions({
2724
+ placement: popover.config["placement"],
2121
2725
  modifiers: [
2122
2726
  { name: "eventListeners", enabled: true },
2123
- ...Rt(t.config)
2727
+ ...getModifiers(popover.config)
2124
2728
  ]
2125
- }), t.popper.update(), t.state = "opened", t;
2126
- }
2127
- async function Fr(e, t) {
2128
- Ce.call(this, e);
2129
- const r = this, i = {
2130
- id: e.id,
2729
+ });
2730
+ popover.popper.update();
2731
+ popover.state = "opened";
2732
+ return popover;
2733
+ }
2734
+ async function register(el, trigger) {
2735
+ deregister.call(this, el);
2736
+ const root = this;
2737
+ const entry = {
2738
+ id: el.id,
2131
2739
  state: "closed",
2132
- el: e,
2133
- trigger: t,
2134
- popper: Ir(t, e),
2135
- config: at(e, this.settings),
2740
+ el,
2741
+ trigger,
2742
+ popper: createPopper(trigger, el),
2743
+ config: getConfig(el, this.settings),
2136
2744
  open() {
2137
- return We.call(r, this);
2745
+ return open.call(root, this);
2138
2746
  },
2139
2747
  close() {
2140
- return ke.call(r, this);
2748
+ return close.call(root, this);
2141
2749
  },
2142
2750
  deregister() {
2143
- return Ce.call(r, this);
2751
+ return deregister.call(root, this);
2144
2752
  }
2145
2753
  };
2146
- return i.trigger.hasAttribute("aria-controls") && i.trigger.setAttribute("aria-expanded", "false"), xt.call(this, i), this.collection.push(i), i.el.classList.contains(this.settings.stateActive) && (await i.open(), ft.call(this, i)), i;
2147
- }
2148
- function xt(e) {
2149
- return e.__eventListeners || (e.config.event === "hover" ? (e.__eventListeners = [{
2150
- el: ["trigger"],
2151
- type: ["mouseenter", "focus"],
2152
- listener: We.bind(this, e)
2153
- }, {
2154
- el: ["el", "trigger"],
2155
- type: ["mouseleave", "focusout"],
2156
- listener: lt.bind(this, e)
2157
- }], e.__eventListeners.forEach((r) => {
2158
- r.el.forEach((i) => {
2159
- r.type.forEach((n) => {
2160
- e[i].addEventListener(n, r.listener, false);
2754
+ if (entry.trigger.hasAttribute("aria-controls")) {
2755
+ entry.trigger.setAttribute("aria-expanded", "false");
2756
+ }
2757
+ registerEventListeners.call(this, entry);
2758
+ this.collection.push(entry);
2759
+ if (entry.el.classList.contains(this.settings.stateActive)) {
2760
+ await entry.open();
2761
+ handleDocumentClick.call(this, entry);
2762
+ }
2763
+ return entry;
2764
+ }
2765
+ function registerEventListeners(entry) {
2766
+ if (!entry.__eventListeners) {
2767
+ const eventType = entry.config["event"];
2768
+ if (eventType === "hover") {
2769
+ entry.__eventListeners = [{
2770
+ el: ["trigger"],
2771
+ type: ["mouseenter", "focus"],
2772
+ listener: open.bind(this, entry)
2773
+ }, {
2774
+ el: ["el", "trigger"],
2775
+ type: ["mouseleave", "focusout"],
2776
+ listener: closeCheck.bind(this, entry)
2777
+ }];
2778
+ entry.__eventListeners.forEach((evObj) => {
2779
+ evObj.el.forEach((el) => {
2780
+ evObj.type.forEach((type) => {
2781
+ entry[el].addEventListener(type, evObj.listener, false);
2782
+ });
2783
+ });
2161
2784
  });
2162
- });
2163
- })) : (e.__eventListeners = [{
2164
- el: ["trigger"],
2165
- type: ["click"],
2166
- listener: St.bind(this, e)
2167
- }], e.__eventListeners.forEach((r) => {
2168
- r.el.forEach((i) => {
2169
- r.type.forEach((n) => {
2170
- e[i].addEventListener(n, r.listener, false);
2785
+ } else {
2786
+ entry.__eventListeners = [{
2787
+ el: ["trigger"],
2788
+ type: ["click"],
2789
+ listener: handleClick.bind(this, entry)
2790
+ }];
2791
+ entry.__eventListeners.forEach((evObj) => {
2792
+ evObj.el.forEach((el) => {
2793
+ evObj.type.forEach((type) => {
2794
+ entry[el].addEventListener(type, evObj.listener, false);
2795
+ });
2796
+ });
2171
2797
  });
2172
- });
2173
- }))), e;
2798
+ }
2799
+ }
2800
+ return entry;
2174
2801
  }
2175
- var J;
2176
- class Yr extends Ct {
2177
- constructor(r) {
2802
+ class Popover extends Collection {
2803
+ constructor(options) {
2178
2804
  super();
2179
- Ke(this, J);
2180
- this.defaults = Dt, this.settings = { ...this.defaults, ...r }, this.trigger = null, Ge(this, J, Mt.bind(this)), this.settings.autoMount && this.mount();
2181
- }
2182
- async mount(r) {
2183
- r && (this.settings = { ...this.settings, ...r });
2184
- const i = document.querySelectorAll(this.settings.selectorPopover);
2185
- return await this.registerCollection(i), this.settings.eventListeners && this.mountEventListeners(false), this;
2805
+ __privateAdd(this, _handleKeydown3);
2806
+ this.defaults = defaults;
2807
+ this.settings = { ...this.defaults, ...options };
2808
+ this.trigger = null;
2809
+ __privateSet(this, _handleKeydown3, handleKeydown.bind(this));
2810
+ if (this.settings.autoMount) this.mount();
2811
+ }
2812
+ async mount(options) {
2813
+ if (options) this.settings = { ...this.settings, ...options };
2814
+ const popovers = document.querySelectorAll(this.settings.selectorPopover);
2815
+ await this.registerCollection(popovers);
2816
+ if (this.settings.eventListeners) {
2817
+ this.mountEventListeners(false);
2818
+ }
2819
+ return this;
2186
2820
  }
2187
2821
  async unmount() {
2188
- return this.trigger = null, await this.deregisterCollection(), this.settings.eventListeners && this.unmountEventListeners(false), this;
2822
+ this.trigger = null;
2823
+ await this.deregisterCollection();
2824
+ if (this.settings.eventListeners) {
2825
+ this.unmountEventListeners(false);
2826
+ }
2827
+ return this;
2189
2828
  }
2190
- mountEventListeners(r = true) {
2191
- r && this.collection.forEach((i) => {
2192
- xt.call(this, i);
2193
- }), document.addEventListener("keydown", Ae(this, J), false);
2829
+ mountEventListeners(processCollection = true) {
2830
+ if (processCollection) {
2831
+ this.collection.forEach((popover) => {
2832
+ registerEventListeners.call(this, popover);
2833
+ });
2834
+ }
2835
+ document.addEventListener("keydown", __privateGet(this, _handleKeydown3), false);
2194
2836
  }
2195
- unmountEventListeners(r = true) {
2196
- r && this.collection.forEach((i) => {
2197
- bt(i);
2198
- }), document.removeEventListener("keydown", Ae(this, J), false);
2837
+ unmountEventListeners(processCollection = true) {
2838
+ if (processCollection) {
2839
+ this.collection.forEach((popover) => {
2840
+ deregisterEventListeners(popover);
2841
+ });
2842
+ }
2843
+ document.removeEventListener("keydown", __privateGet(this, _handleKeydown3), false);
2199
2844
  }
2200
- register(r) {
2201
- const i = Tt.call(this, r);
2202
- return i.error ? Promise.reject(i.error) : Fr.call(this, i.popover, i.trigger);
2845
+ register(query) {
2846
+ const els = getPopoverElements.call(this, query);
2847
+ if (els.error) return Promise.reject(els.error);
2848
+ return register.call(this, els.popover, els.trigger);
2203
2849
  }
2204
- deregister(r) {
2205
- let i = this.get(r.id || r);
2206
- return i ? Ce.call(this, i) : Promise.reject(new Error(`Failed to deregister; popover does not exist in collection with ID of: "${r.id || r}".`));
2850
+ deregister(query) {
2851
+ let obj = this.get(query.id || query);
2852
+ return obj ? deregister.call(this, obj) : Promise.reject(new Error(`Failed to deregister; popover does not exist in collection with ID of: "${query.id || query}".`));
2207
2853
  }
2208
- open(r) {
2209
- return We.call(this, r);
2854
+ open(id) {
2855
+ return open.call(this, id);
2210
2856
  }
2211
- close(r) {
2212
- return ke.call(this, r);
2857
+ close(id) {
2858
+ return close.call(this, id);
2213
2859
  }
2214
2860
  }
2215
- J = /* @__PURE__ */ new WeakMap();
2216
- exports2.Drawer = nt$1;
2217
- exports2.Modal = Q$1;
2218
- exports2.Popover = Yr;
2861
+ _handleKeydown3 = new WeakMap();
2862
+ exports2.Drawer = Drawer;
2863
+ exports2.Modal = Modal;
2864
+ exports2.Popover = Popover;
2219
2865
  exports2.core = index;
2220
2866
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
2221
2867
  });