vrembem 4.0.0-next.25 → 4.0.0-next.27

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
@@ -9,7 +9,126 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
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
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
11
 
12
- var _handler, _focusable, _handleFocusTrap, _handleFocusLock, _handleClick, _handleKeydown, _handleClick2, _handleKeydown2, _handleKeydown3;
12
+ var _handler, _focusable, _handleFocusTrap, _handleFocusLock, _mode, _state, _breakpoint, _handleClick, _handleKeydown, _handleClick2, _handleKeydown2, _eventListeners, _isHovered, _handleKeydown3;
13
+ function toCamel(value) {
14
+ return value.split("-").map((word, index2) => index2 === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join("");
15
+ }
16
+ function toKebab(value) {
17
+ return value.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
18
+ }
19
+ function toMilliseconds(value) {
20
+ if (typeof value === "number") {
21
+ return value;
22
+ }
23
+ const parsed = parseFloat(value);
24
+ if (!Number.isNaN(parsed)) {
25
+ const isMilliseconds = value.includes("ms");
26
+ return parsed * (isMilliseconds ? 1 : 1e3);
27
+ }
28
+ throw new Error(`Could not convert value to milliseconds: ${value}`);
29
+ }
30
+ function getPrefix() {
31
+ return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
32
+ }
33
+ function cssVar(property, options) {
34
+ const settings = {
35
+ fallback: null,
36
+ element: document.body,
37
+ ...options
38
+ };
39
+ if (property.slice(0, 2) !== "--") {
40
+ const prefixValue = getPrefix();
41
+ if (prefixValue) {
42
+ property = `${prefixValue}${property}`;
43
+ }
44
+ property = `--${property}`;
45
+ }
46
+ const cssValue = getComputedStyle(settings.element).getPropertyValue(property).trim();
47
+ if (cssValue) {
48
+ return cssValue;
49
+ } else {
50
+ if (settings.fallback) {
51
+ return settings.fallback;
52
+ } else {
53
+ throw new Error(`CSS variable "${property}" was not found!`);
54
+ }
55
+ }
56
+ }
57
+ function getConfig(el, dataConfig = "config") {
58
+ const string = el.getAttribute(`data-${dataConfig}`) || "";
59
+ const json = string.replace(/'/g, '"');
60
+ return json ? JSON.parse(json) : {};
61
+ }
62
+ function getCustomProps(entry) {
63
+ const styles = getComputedStyle(entry.el);
64
+ const result = {};
65
+ const keys = Object.keys(entry.context.settings);
66
+ for (let i = 0; i < keys.length; i++) {
67
+ const prefix = getPrefix();
68
+ const module2 = entry.context.module.toLowerCase();
69
+ const key = toKebab(keys[i]);
70
+ const value = styles.getPropertyValue(`--${prefix}${module2}-${key}`).trim();
71
+ if (value) {
72
+ result[key] = value;
73
+ }
74
+ }
75
+ return result;
76
+ }
77
+ function getElement(query) {
78
+ if (typeof query === "string") {
79
+ return document.getElementById(query);
80
+ } else if (query instanceof HTMLElement) {
81
+ return query;
82
+ } else {
83
+ return null;
84
+ }
85
+ }
86
+ async function lifecycleHook(name, ...args) {
87
+ if (name in this && typeof this[name] === "function") {
88
+ await this[name](...args);
89
+ }
90
+ }
91
+ function transition(el, init, interim, final, duration = 0) {
92
+ return new Promise((resolve) => {
93
+ el.classList.remove(init);
94
+ el.classList.add(interim);
95
+ setTimeout(() => {
96
+ el.classList.add(final);
97
+ el.classList.remove(interim);
98
+ resolve(el);
99
+ }, toMilliseconds(duration));
100
+ });
101
+ }
102
+ function setOverflowHidden(state, selector) {
103
+ if (selector) {
104
+ const els = document.querySelectorAll(selector);
105
+ els.forEach((el) => {
106
+ if (state) {
107
+ el.style.overflow = "hidden";
108
+ } else {
109
+ el.style.removeProperty("overflow");
110
+ }
111
+ });
112
+ }
113
+ }
114
+ function setInert(state, selector) {
115
+ if (selector) {
116
+ const els = document.querySelectorAll(selector);
117
+ els.forEach((el) => {
118
+ if (state) {
119
+ el.inert = true;
120
+ el.setAttribute("aria-hidden", true);
121
+ } else {
122
+ el.inert = null;
123
+ el.removeAttribute("aria-hidden");
124
+ }
125
+ });
126
+ }
127
+ }
128
+ function setGlobalState(state, selectorInert, selectorOverflow) {
129
+ setInert(!!state, selectorInert);
130
+ setOverflowHidden(!!state, selectorOverflow);
131
+ }
13
132
  class Breakpoint {
14
133
  constructor(value, handler) {
15
134
  __privateAdd(this, _handler);
@@ -47,43 +166,145 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
47
166
  }
48
167
  _handler = new WeakMap();
49
168
  class Collection {
50
- constructor() {
169
+ constructor(options = {}) {
170
+ this.module = this.constructor.name;
51
171
  this.collection = [];
172
+ this.settings = Object.assign({
173
+ dataConfig: "config",
174
+ teleport: null,
175
+ teleportMethod: "append"
176
+ }, options);
52
177
  }
53
- async register(item) {
54
- await this.deregister(item);
55
- this.collection.push(item);
56
- return this.collection;
178
+ get(value, key = "id") {
179
+ return this.collection.find((entry) => entry[key] === value);
180
+ }
181
+ applySettings(obj) {
182
+ return Object.assign(this.settings, obj);
183
+ }
184
+ async createEntry(query, config) {
185
+ return new CollectionEntry(this, query, config);
186
+ }
187
+ async register(query, config = {}) {
188
+ await this.deregister((query == null ? void 0 : query.id) || query, true);
189
+ const entry = await this.createEntry(query, config);
190
+ await entry.mount();
191
+ await lifecycleHook.call(this, "beforeRegister", entry);
192
+ await lifecycleHook.call(entry, "beforeRegister");
193
+ this.collection.push(entry);
194
+ await lifecycleHook.call(entry, "afterRegister");
195
+ await lifecycleHook.call(this, "afterRegister", entry);
196
+ return entry;
57
197
  }
58
- async deregister(ref) {
59
- const index2 = this.collection.findIndex((entry) => {
60
- return entry === ref;
61
- });
62
- if (index2 >= 0) {
198
+ async deregister(id, reReg = false) {
199
+ const index2 = this.collection.findIndex((entry) => entry.id === id);
200
+ if (~index2) {
63
201
  const entry = this.collection[index2];
202
+ await entry.unmount(reReg);
203
+ await lifecycleHook.call(this, "beforeDeregister", entry);
204
+ await lifecycleHook.call(entry, "beforeDeregister", reReg);
64
205
  Object.getOwnPropertyNames(entry).forEach((prop) => {
65
- delete entry[prop];
206
+ if (prop != "beforeDeregister" && prop != "afterDeregister") {
207
+ delete entry[prop];
208
+ }
66
209
  });
67
210
  this.collection.splice(index2, 1);
211
+ await lifecycleHook.call(entry, "afterDeregister", reReg);
212
+ await lifecycleHook.call(this, "afterDeregister", entry);
68
213
  }
69
214
  return this.collection;
70
215
  }
71
- async registerCollection(items) {
72
- await Promise.all(Array.from(items, (item) => {
73
- this.register(item);
74
- }));
75
- return this.collection;
216
+ async mount(options = {}) {
217
+ this.applySettings(options);
218
+ await lifecycleHook.call(this, "beforeMount");
219
+ const els = document.querySelectorAll(this.settings.selector);
220
+ for (const el of els) {
221
+ await this.register(el);
222
+ }
223
+ await lifecycleHook.call(this, "afterMount");
224
+ return this;
76
225
  }
77
- async deregisterCollection() {
226
+ async unmount() {
227
+ await lifecycleHook.call(this, "beforeUnmount");
78
228
  while (this.collection.length > 0) {
79
- await this.deregister(this.collection[0]);
229
+ await this.deregister(this.collection[0].id);
80
230
  }
81
- return this.collection;
231
+ await lifecycleHook.call(this, "afterUnmount");
232
+ return this;
82
233
  }
83
- get(value, key = "id") {
84
- return this.collection.find((item) => {
85
- return item[key] === value;
86
- });
234
+ }
235
+ class CollectionEntry {
236
+ constructor(context, query, options = {}) {
237
+ this.context = context;
238
+ this.id = (query == null ? void 0 : query.id) || query;
239
+ this.el = getElement(query);
240
+ this.settings = Object.assign({}, options);
241
+ this.dataConfig = {};
242
+ this.customProps = {};
243
+ this.returnRef = null;
244
+ }
245
+ applySettings(obj) {
246
+ return Object.assign(this.settings, obj);
247
+ }
248
+ getDataConfig() {
249
+ return Object.assign(this.dataConfig, getConfig(this.el, this.getSetting("dataConfig")));
250
+ }
251
+ getCustomProps() {
252
+ return Object.assign(this.customProps, getCustomProps(this));
253
+ }
254
+ getSetting(key) {
255
+ const camel = toCamel(key);
256
+ const kebab = toKebab(key);
257
+ if ("dataConfig" in this && camel in this.dataConfig) {
258
+ return this.dataConfig[camel];
259
+ }
260
+ if ("customProps" in this && kebab in this.customProps) {
261
+ return this.customProps[kebab];
262
+ }
263
+ if ("settings" in this && camel in this.settings) {
264
+ return this.settings[camel];
265
+ }
266
+ if ("settings" in this.context && camel in this.context.settings) {
267
+ return this.context.settings[camel];
268
+ }
269
+ throw new Error(`${this.context.module} setting does not exist: ${key}`);
270
+ }
271
+ async mount(options = {}) {
272
+ if (this.el === null) {
273
+ throw new Error(`${this.context.module} element was not found with ID: "${this.id}"`);
274
+ }
275
+ this.applySettings(options);
276
+ this.getDataConfig();
277
+ this.getCustomProps();
278
+ await lifecycleHook.call(this, "beforeMount");
279
+ if (this.getSetting("teleport")) {
280
+ this.teleport();
281
+ }
282
+ await lifecycleHook.call(this, "afterMount");
283
+ }
284
+ async unmount(reMount = false) {
285
+ await lifecycleHook.call(this, "beforeUnmount", reMount);
286
+ if (this.getSetting("teleport")) {
287
+ this.teleportReturn();
288
+ }
289
+ await lifecycleHook.call(this, "afterUnmount", reMount);
290
+ }
291
+ teleport(ref = this.getSetting("teleport"), method = this.getSetting("teleportMethod")) {
292
+ if (!this.returnRef) {
293
+ this.returnRef = teleport(this.el, ref, method);
294
+ return this.el;
295
+ } else {
296
+ console.error("Element has already been teleported:", this.el);
297
+ return false;
298
+ }
299
+ }
300
+ teleportReturn() {
301
+ if (this.returnRef) {
302
+ this.returnRef = teleport(this.el, this.returnRef);
303
+ return this.el;
304
+ } else {
305
+ console.error("No return reference found:", this.el);
306
+ return false;
307
+ }
87
308
  }
88
309
  }
89
310
  class FocusTrap {
@@ -188,38 +409,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
188
409
  const isTab = event.key === "Tab" || event.keyCode === 9;
189
410
  if (isTab) event.preventDefault();
190
411
  }
191
- function getPrefix() {
192
- return getComputedStyle(document.body).getPropertyValue("--vb-prefix").trim();
193
- }
194
- function cssVar(property, options) {
195
- const settings = {
196
- fallback: null,
197
- element: document.body,
198
- ...options
199
- };
200
- if (property.slice(0, 2) !== "--") {
201
- const prefixValue = getPrefix();
202
- if (prefixValue) {
203
- property = `${prefixValue}${property}`;
204
- }
205
- property = `--${property}`;
206
- }
207
- const cssValue = getComputedStyle(settings.element).getPropertyValue(property).trim();
208
- if (cssValue) {
209
- return cssValue;
210
- } else {
211
- if (settings.fallback) {
212
- return settings.fallback;
213
- } else {
214
- throw new Error(`CSS variable "${property}" was not found!`);
215
- }
216
- }
217
- }
218
- function getConfig$1(el, dataConfig) {
219
- const string = el.getAttribute(`data-${dataConfig}`) || "";
220
- const json = string.replace(/'/g, '"');
221
- return json ? JSON.parse(json) : {};
222
- }
223
412
  function localStore(key, enable = true) {
224
413
  const local = localStorage.getItem(key);
225
414
  const store = local ? JSON.parse(local) : {};
@@ -323,76 +512,35 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
323
512
  api.callback("onInit");
324
513
  return api;
325
514
  }
326
- function transition(el, from, to, duration = "transition-duration") {
327
- return new Promise((resolve) => {
328
- if (typeof duration === "string") {
329
- const cssValue = cssVar(duration, { element: el });
330
- const ms = cssValue.includes("ms") ? true : false;
331
- duration = parseFloat(cssValue) * (ms ? 1 : 1e3);
332
- }
333
- el.classList.remove(from.finish);
334
- el.classList.add(to.start);
335
- setTimeout(() => {
336
- el.classList.add(to.finish);
337
- el.classList.remove(to.start);
338
- resolve(el);
339
- }, duration);
340
- });
341
- }
342
- function setOverflowHidden(state, selector) {
343
- if (selector) {
344
- const els = document.querySelectorAll(selector);
345
- els.forEach((el) => {
346
- if (state) {
347
- el.style.overflow = "hidden";
348
- } else {
349
- el.style.removeProperty("overflow");
350
- }
351
- });
352
- }
353
- }
354
- function setInert(state, selector) {
355
- if (selector) {
356
- const els = document.querySelectorAll(selector);
357
- els.forEach((el) => {
358
- if (state) {
359
- el.inert = true;
360
- el.setAttribute("aria-hidden", true);
361
- } else {
362
- el.inert = null;
363
- el.removeAttribute("aria-hidden");
364
- }
365
- });
366
- }
367
- }
368
- function updateGlobalState(state, config) {
369
- setInert(!!state, config.selectorInert);
370
- setOverflowHidden(!!state, config.selectorOverflow);
371
- }
372
515
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
373
516
  __proto__: null,
374
517
  Breakpoint,
375
518
  Collection,
519
+ CollectionEntry,
376
520
  FocusTrap,
377
521
  cssVar,
378
- getConfig: getConfig$1,
522
+ getConfig,
523
+ getCustomProps,
524
+ getElement,
379
525
  getPrefix,
526
+ lifecycleHook,
380
527
  localStore,
528
+ setGlobalState,
381
529
  teleport,
382
530
  themeStore,
383
- transition,
384
- updateGlobalState
531
+ toCamel,
532
+ toKebab,
533
+ toMilliseconds,
534
+ transition
385
535
  }, Symbol.toStringTag, { value: "Module" }));
386
536
  const defaults$2 = {
387
- autoMount: false,
388
537
  // Data attributes
389
538
  dataOpen: "drawer-open",
390
539
  dataClose: "drawer-close",
391
540
  dataToggle: "drawer-toggle",
392
541
  dataBreakpoint: "drawer-breakpoint",
393
- dataConfig: "drawer-config",
394
542
  // Selectors
395
- selectorDrawer: ".drawer",
543
+ selector: ".drawer",
396
544
  selectorDialog: ".drawer__dialog",
397
545
  selectorScreen: ".drawer",
398
546
  selectorFocus: "[data-focus]",
@@ -408,10 +556,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
408
556
  // Feature toggles
409
557
  breakpoints: null,
410
558
  customEventPrefix: "drawer:",
411
- eventListeners: true,
412
559
  store: true,
413
560
  storeKey: "VB:DrawerState",
414
561
  setTabindex: true,
562
+ teleport: null,
563
+ teleportMethod: "prepend",
415
564
  transition: true,
416
565
  transitionDuration: "drawer-transition-duration"
417
566
  };
@@ -464,7 +613,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
464
613
  }
465
614
  }
466
615
  function getDrawer(query) {
467
- const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
616
+ const entry = typeof query === "string" ? this.get(query) : query;
468
617
  if (entry) {
469
618
  return entry;
470
619
  } else {
@@ -486,6 +635,132 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
486
635
  this.focusTrap.unmount();
487
636
  }
488
637
  }
638
+ function switchMode(entry) {
639
+ switch (entry.mode) {
640
+ case "inline":
641
+ return toInline.call(this, entry);
642
+ case "modal":
643
+ return toModal.call(this, entry);
644
+ default:
645
+ throw new Error(`"${entry.mode}" is not a valid drawer mode.`);
646
+ }
647
+ }
648
+ async function toInline(entry) {
649
+ entry.el.classList.remove(entry.getSetting("classModal"));
650
+ entry.dialog.removeAttribute("aria-modal");
651
+ setGlobalState(false, entry.getSetting("selectorInert"), entry.getSetting("selectorOverflow"));
652
+ this.focusTrap.unmount();
653
+ await applyInlineState(entry);
654
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
655
+ detail: this,
656
+ bubbles: true
657
+ }));
658
+ return entry;
659
+ }
660
+ async function toModal(entry) {
661
+ entry.el.classList.add(entry.getSetting("classModal"));
662
+ entry.dialog.setAttribute("aria-modal", "true");
663
+ await entry.close(false, false);
664
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
665
+ detail: this,
666
+ bubbles: true
667
+ }));
668
+ return entry;
669
+ }
670
+ class DrawerEntry extends CollectionEntry {
671
+ constructor(context, query, options = {}) {
672
+ super(context, query, options);
673
+ __privateAdd(this, _mode);
674
+ __privateAdd(this, _state);
675
+ __privateAdd(this, _breakpoint);
676
+ this.dialog = null;
677
+ this.trigger = null;
678
+ __privateSet(this, _breakpoint, new Breakpoint());
679
+ __privateSet(this, _mode, "indeterminate");
680
+ __privateSet(this, _state, "indeterminate");
681
+ this.inlineState = "indeterminate";
682
+ }
683
+ get breakpoint() {
684
+ return getBreakpoint.call(this.context, this.el);
685
+ }
686
+ get store() {
687
+ return this.context.store.get(this.id);
688
+ }
689
+ get mode() {
690
+ return __privateGet(this, _mode);
691
+ }
692
+ set mode(value) {
693
+ __privateSet(this, _mode, value);
694
+ switchMode.call(this.context, this);
695
+ }
696
+ get state() {
697
+ return __privateGet(this, _state);
698
+ }
699
+ set state(value) {
700
+ __privateSet(this, _state, value);
701
+ if (this.mode === "inline" && value != "opening" && value != "closing") {
702
+ this.inlineState = value;
703
+ if (this.getSetting("store")) {
704
+ this.context.store.set(this.id, value);
705
+ }
706
+ }
707
+ if (value === "indeterminate") {
708
+ this.el.classList.remove(this.getSetting("stateOpened"));
709
+ this.el.classList.remove(this.getSetting("stateOpening"));
710
+ this.el.classList.remove(this.getSetting("stateClosed"));
711
+ this.el.classList.remove(this.getSetting("stateClosing"));
712
+ }
713
+ }
714
+ async open(transition2, focus) {
715
+ return this.context.open(this, transition2, focus);
716
+ }
717
+ async close(transition2, focus) {
718
+ return this.context.close(this, transition2, focus);
719
+ }
720
+ async toggle(transition2, focus) {
721
+ return this.context.toggle(this, transition2, focus);
722
+ }
723
+ async deregister() {
724
+ return this.context.deregister(this.id);
725
+ }
726
+ mountBreakpoint() {
727
+ const value = this.breakpoint;
728
+ const handler = this.handleBreakpoint.bind(this);
729
+ __privateGet(this, _breakpoint).mount(value, handler);
730
+ }
731
+ unmountBreakpoint() {
732
+ __privateGet(this, _breakpoint).unmount();
733
+ }
734
+ handleBreakpoint(event) {
735
+ const bpMode = event.matches ? "inline" : "modal";
736
+ if (this.mode != bpMode) {
737
+ this.mode = bpMode;
738
+ }
739
+ }
740
+ async beforeMount() {
741
+ const dialog = this.el.querySelector(this.getSetting("selectorDialog"));
742
+ this.dialog = dialog ? dialog : this.el;
743
+ if (this.getSetting("setTabindex")) {
744
+ this.dialog.setAttribute("tabindex", "-1");
745
+ }
746
+ applyInitialState(this);
747
+ this.inlineState = this.state;
748
+ this.mode = this.el.classList.contains(this.getSetting("classModal")) ? "modal" : "inline";
749
+ if (this.breakpoint) {
750
+ this.mountBreakpoint();
751
+ }
752
+ }
753
+ async beforeUnmount(close2 = true) {
754
+ if (close2 && this.state === "opened") {
755
+ await this.close(false);
756
+ }
757
+ this.context.store.set(this.id);
758
+ this.unmountBreakpoint();
759
+ }
760
+ }
761
+ _mode = new WeakMap();
762
+ _state = new WeakMap();
763
+ _breakpoint = new WeakMap();
489
764
  async function handleClick$2(event) {
490
765
  const trigger = event.target.closest(`
491
766
  [data-${this.settings.dataOpen}],
@@ -518,8 +793,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
518
793
  entry.trigger = trigger;
519
794
  return entry.close();
520
795
  } else {
521
- const parent = event.target.closest(this.settings.selectorDrawer);
522
- if (parent) return this.close(parent);
796
+ const parent = event.target.closest(this.settings.selector);
797
+ if (parent) return this.close(parent.id);
523
798
  }
524
799
  });
525
800
  }
@@ -531,82 +806,60 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
531
806
  }
532
807
  function handleKeydown$2(event) {
533
808
  if (event.key === "Escape") {
534
- if (this.activeModal) return this.close(this.activeModal);
535
- }
536
- }
537
- async function deregister$2(obj, close2 = true) {
538
- const index2 = this.collection.findIndex((entry) => {
539
- return entry.id === obj.id;
540
- });
541
- if (index2 >= 0) {
542
- const entry = this.collection[index2];
543
- if (close2 && entry.state === "opened") {
544
- await entry.close(false);
545
- }
546
- this.store.set(entry.id);
547
- entry.unmountBreakpoint();
548
- Object.getOwnPropertyNames(entry).forEach((prop) => {
549
- delete entry[prop];
550
- });
551
- this.collection.splice(index2, 1);
809
+ if (this.activeModal) return this.close(this.activeModal.id);
552
810
  }
553
- return this.collection;
554
811
  }
555
- async function open$2(query, enableTransition, focus = true) {
812
+ async function open$2(query, transitionOverride, focus = true) {
556
813
  const entry = getDrawer.call(this, query);
557
- const config = { ...this.settings, ...entry.settings };
558
- if (enableTransition !== void 0) config.transition = enableTransition;
559
814
  if (entry.state === "closed" || entry.state === "indeterminate") {
560
815
  entry.state = "opening";
561
- if (config.transition) {
562
- await transition(entry.el, {
563
- start: config.stateClosing,
564
- finish: config.stateClosed
565
- }, {
566
- start: config.stateOpening,
567
- finish: config.stateOpened
568
- }, config.transitionDuration);
816
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
817
+ await transition(
818
+ entry.el,
819
+ entry.getSetting("stateClosed"),
820
+ entry.getSetting("stateOpening"),
821
+ entry.getSetting("stateOpened"),
822
+ entry.getSetting("transitionDuration")
823
+ );
569
824
  } else {
570
- entry.el.classList.add(config.stateOpened);
571
- entry.el.classList.remove(config.stateClosed);
825
+ entry.el.classList.add(entry.getSetting("stateOpened"));
826
+ entry.el.classList.remove(entry.getSetting("stateClosed"));
572
827
  }
573
828
  entry.state = "opened";
574
- if (entry.mode === "modal") updateGlobalState(true, config);
829
+ if (entry.mode === "modal") setGlobalState(true, entry.getSetting("selectorInert"), entry.getSetting("selectorOverflow"));
575
830
  if (focus) {
576
831
  updateFocusState$1.call(this, entry);
577
832
  }
578
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
833
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "opened", {
579
834
  detail: this,
580
835
  bubbles: true
581
836
  }));
582
837
  }
583
838
  return entry;
584
839
  }
585
- async function close$2(query, enableTransition, focus = true) {
840
+ async function close$2(query, transitionOverride, focus = true) {
586
841
  const entry = getDrawer.call(this, query);
587
- const config = { ...this.settings, ...entry.settings };
588
- if (enableTransition !== void 0) config.transition = enableTransition;
589
842
  if (entry.state === "opened" || entry.state === "indeterminate") {
590
843
  entry.state = "closing";
591
844
  document.activeElement.blur();
592
- if (config.transition) {
593
- await transition(entry.el, {
594
- start: config.stateOpening,
595
- finish: config.stateOpened
596
- }, {
597
- start: config.stateClosing,
598
- finish: config.stateClosed
599
- }, config.transitionDuration);
845
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
846
+ await transition(
847
+ entry.el,
848
+ entry.getSetting("stateOpened"),
849
+ entry.getSetting("stateClosing"),
850
+ entry.getSetting("stateClosed"),
851
+ entry.getSetting("transitionDuration")
852
+ );
600
853
  } else {
601
- entry.el.classList.add(config.stateClosed);
602
- entry.el.classList.remove(config.stateOpened);
854
+ entry.el.classList.add(entry.getSetting("stateClosed"));
855
+ entry.el.classList.remove(entry.getSetting("stateOpened"));
603
856
  }
604
857
  entry.state = "closed";
605
- if (entry.mode === "modal") updateGlobalState(false, config);
858
+ if (entry.mode === "modal") setGlobalState(false, entry.getSetting("selectorInert"), entry.getSetting("selectorOverflow"));
606
859
  if (focus) {
607
860
  updateFocusState$1.call(this, entry);
608
861
  }
609
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
862
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "closed", {
610
863
  detail: this,
611
864
  bubbles: true
612
865
  }));
@@ -621,199 +874,54 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
621
874
  return close$2.call(this, entry, transition2, focus);
622
875
  }
623
876
  }
624
- function switchMode(entry) {
625
- switch (entry.mode) {
626
- case "inline":
627
- return toInline.call(this, entry);
628
- case "modal":
629
- return toModal.call(this, entry);
630
- default:
631
- throw new Error(`"${entry.mode}" is not a valid drawer mode.`);
632
- }
633
- }
634
- async function toInline(entry) {
635
- entry.el.classList.remove(entry.getSetting("classModal"));
636
- entry.dialog.removeAttribute("aria-modal");
637
- updateGlobalState(false, { ...this.settings, ...entry.settings });
638
- this.focusTrap.unmount();
639
- await applyInlineState(entry);
640
- entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
641
- detail: this,
642
- bubbles: true
643
- }));
644
- return entry;
645
- }
646
- async function toModal(entry) {
647
- entry.el.classList.add(entry.getSetting("classModal"));
648
- entry.dialog.setAttribute("aria-modal", "true");
649
- await close$2.call(this, entry, false, false);
650
- entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
651
- detail: this,
652
- bubbles: true
653
- }));
654
- return entry;
655
- }
656
- async function register$2(el, config = {}) {
657
- await deregister$2.call(this, el, false);
658
- const root = this;
659
- const breakpoint = new Breakpoint();
660
- let _mode, _state = "indeterminate";
661
- const entry = {
662
- id: el.id,
663
- el,
664
- dialog: null,
665
- trigger: null,
666
- settings: { ...getConfig$1(el, this.settings.dataConfig), ...config },
667
- inlineState: "indeterminate",
668
- get breakpoint() {
669
- return getBreakpoint.call(root, el);
670
- },
671
- get store() {
672
- return root.store.get(this.id);
673
- },
674
- get mode() {
675
- return _mode;
676
- },
677
- set mode(value) {
678
- _mode = value;
679
- switchMode.call(root, this);
680
- },
681
- get state() {
682
- return _state;
683
- },
684
- set state(value) {
685
- _state = value;
686
- if (this.mode === "inline" && value != "opening" && value != "closing") {
687
- this.inlineState = value;
688
- if (this.getSetting("store")) {
689
- root.store.set(this.id, value);
690
- }
691
- }
692
- if (value === "indeterminate") {
693
- this.el.classList.remove(this.getSetting("stateOpened"));
694
- this.el.classList.remove(this.getSetting("stateOpening"));
695
- this.el.classList.remove(this.getSetting("stateClosed"));
696
- this.el.classList.remove(this.getSetting("stateClosing"));
697
- }
698
- },
699
- open(transition2, focus) {
700
- return open$2.call(root, this, transition2, focus);
701
- },
702
- close(transition2, focus) {
703
- return close$2.call(root, this, transition2, focus);
704
- },
705
- toggle(transition2, focus) {
706
- return toggle.call(root, this, transition2, focus);
707
- },
708
- deregister() {
709
- return deregister$2.call(root, this);
710
- },
711
- mountBreakpoint() {
712
- const value = this.breakpoint;
713
- const handler = this.handleBreakpoint.bind(this);
714
- breakpoint.mount(value, handler);
715
- return this;
716
- },
717
- unmountBreakpoint() {
718
- breakpoint.unmount();
719
- return this;
720
- },
721
- handleBreakpoint(event) {
722
- const bpMode = event.matches ? "inline" : "modal";
723
- if (this.mode != bpMode) {
724
- this.mode = bpMode;
725
- }
726
- return this;
727
- },
728
- getSetting(key) {
729
- return key in this.settings ? this.settings[key] : root.settings[key];
730
- }
731
- };
732
- this.collection.push(entry);
733
- const dialog = el.querySelector(entry.getSetting("selectorDialog"));
734
- entry.dialog = dialog ? dialog : el;
735
- if (entry.getSetting("setTabindex")) {
736
- entry.dialog.setAttribute("tabindex", "-1");
737
- }
738
- await applyInitialState(entry);
739
- entry.inlineState = entry.state;
740
- entry.mode = el.classList.contains(entry.getSetting("classModal")) ? "modal" : "inline";
741
- if (entry.breakpoint) {
742
- entry.mountBreakpoint();
743
- }
744
- return entry;
745
- }
746
877
  class Drawer extends Collection {
747
878
  constructor(options) {
748
- super();
879
+ super({ ...defaults$2, ...options });
749
880
  __privateAdd(this, _handleClick);
750
881
  __privateAdd(this, _handleKeydown);
751
- this.defaults = defaults$2;
752
- this.settings = { ...this.defaults, ...options };
753
882
  this.focusTrap = new FocusTrap();
754
- this.store = localStore(this.settings.storeKey, this.settings.store);
755
883
  __privateSet(this, _handleClick, handleClick$2.bind(this));
756
884
  __privateSet(this, _handleKeydown, handleKeydown$2.bind(this));
757
- if (this.settings.autoMount) this.mount();
885
+ this.store = localStore(this.settings.storeKey, this.settings.store);
758
886
  }
759
887
  get activeModal() {
760
888
  return this.collection.find((entry) => {
761
889
  return entry.state === "opened" && entry.mode === "modal";
762
890
  });
763
891
  }
764
- async mount(options = null) {
765
- if (options) this.settings = { ...this.settings, ...options };
766
- const drawers = document.querySelectorAll(this.settings.selectorDrawer);
767
- await this.registerCollection(drawers);
768
- if (this.settings.eventListeners) {
769
- this.mountEventListeners();
770
- }
771
- return this;
892
+ async createEntry(query, config) {
893
+ return new DrawerEntry(this, query, config);
772
894
  }
773
- async unmount() {
774
- await this.deregisterCollection();
775
- if (this.settings.eventListeners) {
776
- this.unmountEventListeners();
777
- }
778
- return this;
895
+ async open(id, transition2, focus) {
896
+ return open$2.call(this, id, transition2, focus);
897
+ }
898
+ async close(id, transition2, focus) {
899
+ return close$2.call(this, id, transition2, focus);
779
900
  }
780
- mountEventListeners() {
901
+ async toggle(id, transition2, focus) {
902
+ return toggle.call(this, id, transition2, focus);
903
+ }
904
+ async afterMount() {
781
905
  document.addEventListener("click", __privateGet(this, _handleClick), false);
782
906
  document.addEventListener("keydown", __privateGet(this, _handleKeydown), false);
783
907
  }
784
- unmountEventListeners() {
908
+ async beforeUnmount() {
909
+ this.trigger = null;
910
+ }
911
+ async afterUnmount() {
785
912
  document.removeEventListener("click", __privateGet(this, _handleClick), false);
786
913
  document.removeEventListener("keydown", __privateGet(this, _handleKeydown), false);
787
914
  }
788
- register(query, config = {}) {
789
- let el = typeof query == "string" ? document.getElementById(query) : query;
790
- return el ? register$2.call(this, el, config) : Promise.reject(new Error(`Failed to register; drawer not found with ID of: "${query.id || query}".`));
791
- }
792
- deregister(query) {
793
- let obj = this.get(query.id || query);
794
- 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}".`));
795
- }
796
- open(id, transition2, focus) {
797
- return open$2.call(this, id, transition2, focus);
798
- }
799
- close(id, transition2, focus) {
800
- return close$2.call(this, id, transition2, focus);
801
- }
802
- toggle(id, transition2, focus) {
803
- return toggle.call(this, id, transition2, focus);
804
- }
805
915
  }
806
916
  _handleClick = new WeakMap();
807
917
  _handleKeydown = new WeakMap();
808
918
  const defaults$1 = {
809
- autoMount: false,
810
919
  // Data attributes
811
920
  dataOpen: "modal-open",
812
921
  dataClose: "modal-close",
813
922
  dataReplace: "modal-replace",
814
- dataConfig: "modal-config",
815
923
  // Selectors
816
- selectorModal: ".modal",
924
+ selector: ".modal",
817
925
  selectorDialog: ".modal__dialog",
818
926
  selectorScreen: ".modal",
819
927
  selectorRequired: '[role="alertdialog"]',
@@ -827,13 +935,61 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
827
935
  stateClosed: "is-closed",
828
936
  // Feature settings
829
937
  customEventPrefix: "modal:",
830
- eventListeners: true,
938
+ setTabindex: true,
831
939
  teleport: null,
832
940
  teleportMethod: "append",
833
- setTabindex: true,
834
941
  transition: true,
835
942
  transitionDuration: "modal-transition-duration"
836
943
  };
944
+ class ModalEntry extends CollectionEntry {
945
+ constructor(context, query, options = {}) {
946
+ super(context, query, options);
947
+ this.state = "closed";
948
+ this.dialog = null;
949
+ }
950
+ get isRequired() {
951
+ return this.dialog.matches(this.getSetting("selectorRequired"));
952
+ }
953
+ async open(transition2, focus) {
954
+ return this.context.open(this, transition2, focus);
955
+ }
956
+ async close(transition2, focus) {
957
+ return this.context.close(this, transition2, focus);
958
+ }
959
+ async replace(transition2, focus) {
960
+ return this.context.replace(this, transition2, focus);
961
+ }
962
+ async deregister() {
963
+ return this.context.deregister(this.id);
964
+ }
965
+ async beforeMount() {
966
+ const dialog = this.el.querySelector(this.getSetting("selectorDialog"));
967
+ this.dialog = dialog ? dialog : this.el;
968
+ this.dialog.setAttribute("aria-modal", "true");
969
+ if (!this.dialog.hasAttribute("role")) {
970
+ this.dialog.setAttribute("role", "dialog");
971
+ }
972
+ if (this.getSetting("setTabindex")) {
973
+ this.dialog.setAttribute("tabindex", "-1");
974
+ }
975
+ }
976
+ async afterRegister() {
977
+ if (this.el.classList.contains(this.getSetting("stateOpened"))) {
978
+ await this.open(false);
979
+ } else {
980
+ this.el.classList.remove(this.getSetting("stateOpening"));
981
+ this.el.classList.remove(this.getSetting("stateClosing"));
982
+ this.el.classList.add(this.getSetting("stateClosed"));
983
+ }
984
+ }
985
+ async beforeUnmount(reMount = false) {
986
+ if (!reMount && this.state === "opened") {
987
+ await this.close(false);
988
+ } else {
989
+ this.context.stack.remove(this);
990
+ }
991
+ }
992
+ }
837
993
  function getModal(query) {
838
994
  const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
839
995
  if (entry) {
@@ -864,14 +1020,14 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
864
1020
  if (trigger.matches(`[data-${this.settings.dataOpen}]`)) {
865
1021
  const selector = trigger.getAttribute(`data-${this.settings.dataOpen}`).trim();
866
1022
  const entry = getModal.call(this, selector);
867
- const fromModal = event.target.closest(this.settings.selectorModal);
1023
+ const fromModal = event.target.closest(this.settings.selector);
868
1024
  if (!fromModal) this.trigger = trigger;
869
1025
  return entry.open();
870
1026
  }
871
1027
  if (trigger.matches(`[data-${this.settings.dataReplace}]`)) {
872
1028
  const selector = trigger.getAttribute(`data-${this.settings.dataReplace}`).trim();
873
1029
  const entry = getModal.call(this, selector);
874
- const fromModal = event.target.closest(this.settings.selectorModal);
1030
+ const fromModal = event.target.closest(this.settings.selector);
875
1031
  if (!fromModal) this.trigger = trigger;
876
1032
  return entry.replace();
877
1033
  }
@@ -880,7 +1036,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
880
1036
  return selector === "*" ? this.closeAll() : this.close(selector);
881
1037
  }
882
1038
  }
883
- if (this.active && event.target.matches(this.settings.selectorScreen) && !this.active.required) {
1039
+ if (this.active && event.target.matches(this.settings.selectorScreen) && !this.active.isRequired) {
884
1040
  return this.close(this.active.id);
885
1041
  }
886
1042
  }
@@ -891,83 +1047,58 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
891
1047
  }
892
1048
  }
893
1049
  }
894
- async function deregister$1(obj, close2 = true) {
895
- const index2 = this.collection.findIndex((entry) => {
896
- return entry.id === obj.id;
897
- });
898
- if (index2 >= 0) {
899
- const entry = this.collection[index2];
900
- if (close2 && entry.state === "opened") {
901
- await entry.close(false);
902
- } else {
903
- this.stack.remove(entry);
904
- }
905
- if (entry.getSetting("teleport")) {
906
- entry.teleportReturn();
907
- }
908
- Object.getOwnPropertyNames(entry).forEach((prop) => {
909
- delete entry[prop];
910
- });
911
- this.collection.splice(index2, 1);
912
- }
913
- return this.collection;
914
- }
915
- async function open$1(query, enableTransition, focus = true) {
1050
+ async function open$1(query, transitionOverride = void 0, focus = true) {
916
1051
  const entry = getModal.call(this, query);
917
- const config = { ...this.settings, ...entry.settings };
918
- if (enableTransition !== void 0) config.transition = enableTransition;
919
1052
  this.stack.moveToTop(entry);
920
1053
  if (entry.state === "closed") {
921
1054
  entry.state = "opening";
922
1055
  this.stack.add(entry);
923
- if (config.transition) {
924
- await transition(entry.el, {
925
- start: config.stateClosing,
926
- finish: config.stateClosed
927
- }, {
928
- start: config.stateOpening,
929
- finish: config.stateOpened
930
- }, config.transitionDuration);
1056
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
1057
+ await transition(
1058
+ entry.el,
1059
+ entry.getSetting("stateClosed"),
1060
+ entry.getSetting("stateOpening"),
1061
+ entry.getSetting("stateOpened"),
1062
+ entry.getSetting("transitionDuration")
1063
+ );
931
1064
  } else {
932
- entry.el.classList.add(config.stateOpened);
933
- entry.el.classList.remove(config.stateClosed);
1065
+ entry.el.classList.add(entry.getSetting("stateOpened"));
1066
+ entry.el.classList.remove(entry.getSetting("stateClosed"));
934
1067
  }
935
1068
  entry.state = "opened";
936
1069
  }
937
1070
  if (focus) {
938
1071
  updateFocusState.call(this);
939
1072
  }
940
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
1073
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "opened", {
941
1074
  detail: this,
942
1075
  bubbles: true
943
1076
  }));
944
1077
  return entry;
945
1078
  }
946
- async function close$1(query, enableTransition, focus = true) {
1079
+ async function close$1(query, transitionOverride, focus = true) {
947
1080
  const entry = query ? getModal.call(this, query) : this.active;
948
1081
  if (entry && entry.state === "opened") {
949
1082
  entry.state = "closing";
950
- const config = { ...this.settings, ...entry.settings };
951
- if (enableTransition !== void 0) config.transition = enableTransition;
952
1083
  document.activeElement.blur();
953
- if (config.transition) {
954
- await transition(entry.el, {
955
- start: config.stateOpening,
956
- finish: config.stateOpened
957
- }, {
958
- start: config.stateClosing,
959
- finish: config.stateClosed
960
- }, config.transitionDuration);
1084
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
1085
+ await transition(
1086
+ entry.el,
1087
+ entry.getSetting("stateOpened"),
1088
+ entry.getSetting("stateClosing"),
1089
+ entry.getSetting("stateClosed"),
1090
+ entry.getSetting("transitionDuration")
1091
+ );
961
1092
  } else {
962
- entry.el.classList.add(config.stateClosed);
963
- entry.el.classList.remove(config.stateOpened);
1093
+ entry.el.classList.add(entry.getSetting("stateClosed"));
1094
+ entry.el.classList.remove(entry.getSetting("stateOpened"));
964
1095
  }
965
1096
  this.stack.remove(entry);
966
1097
  entry.state = "closed";
967
1098
  if (focus) {
968
1099
  updateFocusState.call(this);
969
1100
  }
970
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
1101
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "closed", {
971
1102
  detail: this,
972
1103
  bubbles: true
973
1104
  }));
@@ -1002,75 +1133,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1002
1133
  }
1003
1134
  return { opened: resultOpened, closed: resultClosed };
1004
1135
  }
1005
- async function register$1(el, config = {}) {
1006
- await deregister$1.call(this, el, false);
1007
- const root = this;
1008
- const entry = {
1009
- id: el.id,
1010
- state: "closed",
1011
- el,
1012
- dialog: null,
1013
- get required() {
1014
- return this.dialog.matches(this.getSetting("selectorRequired"));
1015
- },
1016
- returnRef: null,
1017
- settings: { ...getConfig$1(el, this.settings.dataConfig), ...config },
1018
- open(transition2, focus) {
1019
- return open$1.call(root, this, transition2, focus);
1020
- },
1021
- close(transition2, focus) {
1022
- return close$1.call(root, this, transition2, focus);
1023
- },
1024
- replace(transition2, focus) {
1025
- return replace.call(root, this, transition2, focus);
1026
- },
1027
- deregister() {
1028
- return deregister$1.call(root, this);
1029
- },
1030
- teleport(ref = this.getSetting("teleport"), method = this.getSetting("teleportMethod")) {
1031
- if (!this.returnRef) {
1032
- this.returnRef = teleport(this.el, ref, method);
1033
- return this.el;
1034
- } else {
1035
- console.error("Element has already been teleported:", this.el);
1036
- return false;
1037
- }
1038
- },
1039
- teleportReturn() {
1040
- if (this.returnRef) {
1041
- this.returnRef = teleport(this.el, this.returnRef);
1042
- return this.el;
1043
- } else {
1044
- console.error("No return reference found:", this.el);
1045
- return false;
1046
- }
1047
- },
1048
- getSetting(key) {
1049
- return key in this.settings ? this.settings[key] : root.settings[key];
1050
- }
1051
- };
1052
- const dialog = el.querySelector(entry.getSetting("selectorDialog"));
1053
- entry.dialog = dialog ? dialog : el;
1054
- entry.dialog.setAttribute("aria-modal", "true");
1055
- if (!entry.dialog.hasAttribute("role")) {
1056
- entry.dialog.setAttribute("role", "dialog");
1057
- }
1058
- if (entry.getSetting("setTabindex")) {
1059
- entry.dialog.setAttribute("tabindex", "-1");
1060
- }
1061
- if (entry.getSetting("teleport")) {
1062
- entry.teleport();
1063
- }
1064
- this.collection.push(entry);
1065
- if (entry.el.classList.contains(this.settings.stateOpened)) {
1066
- await entry.open(false);
1067
- } else {
1068
- entry.el.classList.remove(this.settings.stateOpening);
1069
- entry.el.classList.remove(this.settings.stateClosing);
1070
- entry.el.classList.add(this.settings.stateClosed);
1071
- }
1072
- return entry;
1073
- }
1074
1136
  function stack(settings) {
1075
1137
  const stackArray = [];
1076
1138
  return {
@@ -1078,7 +1140,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1078
1140
  return [...stackArray];
1079
1141
  },
1080
1142
  get top() {
1081
- return stackArray[stackArray.length - 1];
1143
+ const result = stackArray[stackArray.length - 1];
1144
+ return result ? result : null;
1082
1145
  },
1083
1146
  updateIndex() {
1084
1147
  stackArray.forEach((entry, index2) => {
@@ -1087,8 +1150,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1087
1150
  entry.el.style.zIndex = parseInt(value) + index2 + 1;
1088
1151
  });
1089
1152
  },
1090
- updateGlobalState() {
1091
- updateGlobalState(this.top, settings);
1153
+ setGlobalState() {
1154
+ setGlobalState(this.top, settings.selectorInert, settings.selectorOverflow);
1092
1155
  this.updateIndex();
1093
1156
  },
1094
1157
  add(entry) {
@@ -1096,7 +1159,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1096
1159
  const value = getComputedStyle(entry.el)["z-index"];
1097
1160
  entry.el.style.zIndex = parseInt(value) + stackArray.length + 1;
1098
1161
  stackArray.push(entry);
1099
- this.updateGlobalState();
1162
+ this.setGlobalState();
1100
1163
  },
1101
1164
  remove(entry) {
1102
1165
  const index2 = stackArray.findIndex((item) => {
@@ -1105,7 +1168,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1105
1168
  if (index2 >= 0) {
1106
1169
  entry.el.style.zIndex = null;
1107
1170
  stackArray.splice(index2, 1);
1108
- this.updateGlobalState();
1171
+ this.setGlobalState();
1109
1172
  }
1110
1173
  },
1111
1174
  moveToTop(entry) {
@@ -1121,61 +1184,28 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1121
1184
  }
1122
1185
  class Modal extends Collection {
1123
1186
  constructor(options) {
1124
- super();
1187
+ super({ ...defaults$1, ...options });
1125
1188
  __privateAdd(this, _handleClick2);
1126
1189
  __privateAdd(this, _handleKeydown2);
1127
- this.defaults = defaults$1;
1128
- this.settings = { ...this.defaults, ...options };
1129
1190
  this.trigger = null;
1130
1191
  this.focusTrap = new FocusTrap();
1131
- this.stack = stack(this.settings);
1132
1192
  __privateSet(this, _handleClick2, handleClick$1.bind(this));
1133
1193
  __privateSet(this, _handleKeydown2, handleKeydown$1.bind(this));
1134
- if (this.settings.autoMount) this.mount();
1194
+ this.stack = stack(this.settings);
1135
1195
  }
1136
1196
  get active() {
1137
1197
  return this.stack.top;
1138
1198
  }
1139
- async mount(options) {
1140
- if (options) this.settings = { ...this.settings, ...options };
1141
- const modals = document.querySelectorAll(this.settings.selectorModal);
1142
- await this.registerCollection(modals);
1143
- if (this.settings.eventListeners) {
1144
- this.mountEventListeners();
1145
- }
1146
- return this;
1147
- }
1148
- async unmount() {
1149
- this.trigger = null;
1150
- await this.deregisterCollection();
1151
- if (this.settings.eventListeners) {
1152
- this.unmountEventListeners();
1153
- }
1154
- return this;
1155
- }
1156
- mountEventListeners() {
1157
- document.addEventListener("click", __privateGet(this, _handleClick2), false);
1158
- document.addEventListener("keydown", __privateGet(this, _handleKeydown2), false);
1159
- }
1160
- unmountEventListeners() {
1161
- document.removeEventListener("click", __privateGet(this, _handleClick2), false);
1162
- document.removeEventListener("keydown", __privateGet(this, _handleKeydown2), false);
1163
- }
1164
- register(query, config = {}) {
1165
- let el = typeof query == "string" ? document.getElementById(query) : query;
1166
- return el ? register$1.call(this, el, config) : Promise.reject(new Error(`Failed to register; modal not found with ID of: "${query.id || query}".`));
1167
- }
1168
- deregister(query) {
1169
- let obj = this.get(query.id || query);
1170
- 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}".`));
1199
+ async createEntry(query, config) {
1200
+ return new ModalEntry(this, query, config);
1171
1201
  }
1172
- open(id, transition2, focus) {
1202
+ async open(id, transition2, focus) {
1173
1203
  return open$1.call(this, id, transition2, focus);
1174
1204
  }
1175
- close(id, transition2, focus) {
1205
+ async close(id, transition2, focus) {
1176
1206
  return close$1.call(this, id, transition2, focus);
1177
1207
  }
1178
- replace(id, transition2, focus) {
1208
+ async replace(id, transition2, focus) {
1179
1209
  return replace.call(this, id, transition2, focus);
1180
1210
  }
1181
1211
  async closeAll(exclude = false, transition2, focus = true) {
@@ -1185,50 +1215,71 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1185
1215
  }
1186
1216
  return result;
1187
1217
  }
1218
+ async afterMount() {
1219
+ document.addEventListener("click", __privateGet(this, _handleClick2), false);
1220
+ document.addEventListener("keydown", __privateGet(this, _handleKeydown2), false);
1221
+ }
1222
+ async beforeUnmount() {
1223
+ this.trigger = null;
1224
+ }
1225
+ async afterUnmount() {
1226
+ document.removeEventListener("click", __privateGet(this, _handleClick2), false);
1227
+ document.removeEventListener("keydown", __privateGet(this, _handleKeydown2), false);
1228
+ }
1188
1229
  }
1189
1230
  _handleClick2 = new WeakMap();
1190
1231
  _handleKeydown2 = new WeakMap();
1191
1232
  const defaults = {
1192
- autoMount: false,
1193
1233
  // Selectors
1194
- selectorPopover: ".popover",
1234
+ selector: ".popover",
1195
1235
  selectorTooltip: ".popover_tooltip",
1196
1236
  selectorArrow: ".popover__arrow",
1197
1237
  // State classes
1198
1238
  stateActive: "is-active",
1199
- // Feature settings
1200
- eventListeners: true,
1201
- eventType: "click",
1239
+ // Custom properties and their defaults
1202
1240
  placement: "bottom",
1203
- hoverToggleDelay: 0
1241
+ event: "click",
1242
+ offset: 0,
1243
+ flipPadding: 0,
1244
+ shiftPadding: 0,
1245
+ arrowPadding: 0,
1246
+ toggleDelay: 0,
1247
+ // Feature settings
1248
+ teleport: null,
1249
+ teleportMethod: "append"
1204
1250
  };
1205
- function getConfig(el, settings) {
1206
- const styles = getComputedStyle(el);
1207
- const config = {
1208
- "placement": settings.placement,
1209
- "event": settings.eventType,
1210
- "offset": 0,
1211
- "overflow-padding": 0,
1212
- "flip-padding": 0,
1213
- "arrow-element": settings.selectorArrow,
1214
- "arrow-padding": 0,
1215
- "toggle-delay": settings.hoverToggleDelay
1216
- };
1217
- for (const prop in config) {
1218
- const prefix = getPrefix();
1219
- const value = styles.getPropertyValue(`--${prefix}popover-${prop}`).trim();
1220
- if (value) {
1221
- config[prop] = value;
1251
+ function applyPositionStyle(el, x, y) {
1252
+ Object.assign(el.style, {
1253
+ left: x != null ? `${x}px` : "",
1254
+ top: y != null ? `${y}px` : ""
1255
+ });
1256
+ }
1257
+ function getDelay(popover, index2) {
1258
+ let value = popover.getSetting("toggle-delay");
1259
+ if (typeof value == "string") {
1260
+ if (value.indexOf(",") > -1) {
1261
+ value = value.split(",");
1222
1262
  }
1263
+ if (value.indexOf(" ") > -1) {
1264
+ value = value.split(" ");
1265
+ }
1266
+ }
1267
+ if (Array.isArray(value)) {
1268
+ value = value[index2];
1269
+ }
1270
+ const number = Number(value);
1271
+ if (!Number.isNaN(number)) {
1272
+ return number;
1273
+ } else {
1274
+ throw new Error(`Provided delay value is not a number: "${value}"`);
1223
1275
  }
1224
- return config;
1225
1276
  }
1226
1277
  function getPadding(value) {
1227
1278
  let padding;
1228
1279
  const array = typeof value === "string" ? value.trim().split(" ") : [value];
1229
- array.forEach(function(item, index2) {
1230
- array[index2] = parseInt(item, 10);
1231
- });
1280
+ for (let index2 = 0; index2 < array.length; index2++) {
1281
+ array[index2] = Number(array[index2]);
1282
+ }
1232
1283
  switch (array.length) {
1233
1284
  case 1:
1234
1285
  padding = array[0];
@@ -1263,29 +1314,20 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1263
1314
  }
1264
1315
  return padding;
1265
1316
  }
1266
- function getModifiers(options) {
1267
- return [{
1268
- name: "offset",
1269
- options: {
1270
- offset: [0, parseInt(options["offset"], 10)]
1271
- }
1272
- }, {
1273
- name: "preventOverflow",
1274
- options: {
1275
- padding: getPadding(options["overflow-padding"])
1276
- }
1277
- }, {
1278
- name: "flip",
1279
- options: {
1280
- padding: getPadding(options["flip-padding"])
1281
- }
1282
- }, {
1283
- name: "arrow",
1284
- options: {
1285
- element: options["arrow-element"],
1286
- padding: getPadding(options["arrow-padding"])
1317
+ function getMiddlewareOptions(popover) {
1318
+ return {
1319
+ offset: Number(popover.getSetting("offset")),
1320
+ flip: {
1321
+ padding: getPadding(popover.getSetting("flip-padding"))
1322
+ },
1323
+ shift: {
1324
+ padding: getPadding(popover.getSetting("shift-padding"))
1325
+ },
1326
+ arrow: {
1327
+ element: popover.getSetting("selectorArrow"),
1328
+ padding: getPadding(popover.getSetting("arrow-padding"))
1287
1329
  }
1288
- }];
1330
+ };
1289
1331
  }
1290
1332
  function getPopover(query) {
1291
1333
  const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
@@ -1295,38 +1337,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1295
1337
  throw new Error(`Popover not found in collection with id of "${query}".`);
1296
1338
  }
1297
1339
  }
1298
- function getPopoverID(obj) {
1299
- if (typeof obj === "string") {
1300
- return obj;
1301
- } else if (typeof obj.hasAttribute === "function") {
1302
- if (obj.closest(this.settings.selectorPopover)) {
1303
- obj = obj.closest(this.settings.selectorPopover);
1304
- return obj.id;
1305
- } else if (obj.hasAttribute("aria-controls")) {
1306
- return obj.getAttribute("aria-controls");
1307
- } else if (obj.hasAttribute("aria-describedby")) {
1308
- return obj.getAttribute("aria-describedby");
1309
- } else return false;
1310
- } else return false;
1311
- }
1312
- function getPopoverElements(query) {
1313
- const id = getPopoverID.call(this, query);
1314
- if (id) {
1315
- const popover = document.querySelector(`#${id}`);
1316
- const trigger = document.querySelector(`[aria-controls="${id}"]`) || document.querySelector(`[aria-describedby="${id}"]`);
1317
- if (!trigger && !popover) {
1318
- return { error: new Error(`No popover elements found using the ID: "${id}".`) };
1319
- } else if (!trigger) {
1320
- return { error: new Error(`No popover trigger associated with the provided popover: "${id}".`) };
1321
- } else if (!popover) {
1322
- return { error: new Error(`No popover associated with the provided popover trigger: "${id}".`) };
1323
- } else {
1324
- return { popover, trigger };
1325
- }
1326
- } else {
1327
- return { error: new Error("Could not resolve the popover ID.") };
1328
- }
1329
- }
1330
1340
  async function close(query) {
1331
1341
  const popover = query ? getPopover.call(this, query) : await closeAll.call(this);
1332
1342
  if (popover && popover.state === "opened") {
@@ -1335,13 +1345,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1335
1345
  if (!popover.isTooltip) {
1336
1346
  popover.trigger.setAttribute("aria-expanded", "false");
1337
1347
  }
1338
- popover.popper.setOptions({
1339
- placement: popover.config["placement"],
1340
- modifiers: [
1341
- { name: "eventListeners", enabled: false },
1342
- ...getModifiers(popover.config)
1343
- ]
1344
- });
1348
+ popover.floatingCleanup();
1345
1349
  popover.state = "closed";
1346
1350
  if (popover.trigger === this.trigger) {
1347
1351
  this.trigger = null;
@@ -1373,48 +1377,48 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1373
1377
  }, 1);
1374
1378
  }
1375
1379
  function handleClick(popover) {
1376
- const tooltipId = popover.trigger.getAttribute("aria-describedby");
1377
- if (tooltipId) {
1378
- const entry = this.get(tooltipId);
1379
- if (entry.isTooltip) {
1380
- if (entry.toggleDelayId) {
1381
- clearTimeout(entry.toggleDelayId);
1382
- }
1383
- entry.close();
1384
- }
1385
- }
1386
1380
  if (popover.state === "opened") {
1387
1381
  popover.close();
1388
1382
  } else {
1389
1383
  this.trigger = popover.trigger;
1390
1384
  popover.open();
1391
- handleDocumentClick.call(this, popover);
1385
+ }
1386
+ }
1387
+ function handleTooltipClick(popover) {
1388
+ if (popover.isTooltip) {
1389
+ if (popover.toggleDelayId) {
1390
+ clearTimeout(popover.toggleDelayId);
1391
+ }
1392
+ popover.close();
1392
1393
  }
1393
1394
  }
1394
1395
  function handleMouseEnter(popover, event) {
1396
+ popover.isHovered = event;
1395
1397
  if (event.type == "focus" && !popover.trigger.matches(":focus-visible")) {
1396
1398
  return;
1397
1399
  }
1398
- const isExpanded = popover.trigger.getAttribute("aria-expanded");
1399
- if (isExpanded && isExpanded == "true") {
1400
- return;
1401
- }
1402
1400
  if (popover.toggleDelayId) {
1403
1401
  clearTimeout(popover.toggleDelayId);
1404
1402
  }
1405
- const delay = this.activeTooltip ? 0 : popover.config["toggle-delay"];
1406
- if (this.activeTooltip) this.activeTooltip.close();
1403
+ const isExpanded = popover.trigger.getAttribute("aria-expanded");
1404
+ if (isExpanded && isExpanded == "true") return;
1405
+ const delay = this.activeHover ? 0 : getDelay(popover, 0);
1406
+ if (this.activeHover) this.activeHover.close();
1407
1407
  popover.toggleDelayId = setTimeout(() => {
1408
1408
  if (popover.id) popover.open();
1409
1409
  }, delay);
1410
1410
  }
1411
- function handleMouseLeave(popover) {
1412
- if (popover.toggleDelayId) {
1413
- clearTimeout(popover.toggleDelayId);
1414
- }
1415
- popover.toggleDelayId = setTimeout(() => {
1416
- closeCheck.call(this, popover);
1417
- }, popover.config["toggle-delay"]);
1411
+ function handleMouseLeave(popover, event) {
1412
+ setTimeout(() => {
1413
+ popover.isHovered = event;
1414
+ if (popover.isHovered) return;
1415
+ if (popover.toggleDelayId) {
1416
+ clearTimeout(popover.toggleDelayId);
1417
+ }
1418
+ popover.toggleDelayId = setTimeout(() => {
1419
+ closeCheck.call(this, popover);
1420
+ }, getDelay(popover, 1));
1421
+ }, 1);
1418
1422
  }
1419
1423
  function handleKeydown(event) {
1420
1424
  switch (event.key) {
@@ -1451,567 +1455,1162 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1451
1455
  }
1452
1456
  });
1453
1457
  }
1454
- var top = "top";
1455
- var bottom = "bottom";
1456
- var right = "right";
1457
- var left = "left";
1458
- var auto = "auto";
1459
- var basePlacements = [top, bottom, right, left];
1460
- var start = "start";
1461
- var end = "end";
1462
- var clippingParents = "clippingParents";
1463
- var viewport = "viewport";
1464
- var popper = "popper";
1465
- var reference = "reference";
1466
- var variationPlacements = /* @__PURE__ */ basePlacements.reduce(function(acc, placement) {
1467
- return acc.concat([placement + "-" + start, placement + "-" + end]);
1468
- }, []);
1469
- var placements = /* @__PURE__ */ [].concat(basePlacements, [auto]).reduce(function(acc, placement) {
1470
- return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
1471
- }, []);
1472
- var beforeRead = "beforeRead";
1473
- var read = "read";
1474
- var afterRead = "afterRead";
1475
- var beforeMain = "beforeMain";
1476
- var main = "main";
1477
- var afterMain = "afterMain";
1478
- var beforeWrite = "beforeWrite";
1479
- var write = "write";
1480
- var afterWrite = "afterWrite";
1481
- var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
1482
- function getNodeName(element) {
1483
- return element ? (element.nodeName || "").toLowerCase() : null;
1484
- }
1485
- function getWindow(node) {
1486
- if (node == null) {
1487
- return window;
1458
+ class PopoverEntry extends CollectionEntry {
1459
+ constructor(context, query, options = {}) {
1460
+ super(context, query, options);
1461
+ __privateAdd(this, _eventListeners);
1462
+ __privateAdd(this, _isHovered);
1463
+ this.state = "closed";
1464
+ this.toggleDelayId = null;
1465
+ this.trigger = null;
1466
+ __privateSet(this, _eventListeners, null);
1467
+ __privateSet(this, _isHovered, {
1468
+ el: false,
1469
+ trigger: false
1470
+ });
1471
+ this.floatingCleanup = () => {
1472
+ };
1488
1473
  }
1489
- if (node.toString() !== "[object Window]") {
1490
- var ownerDocument = node.ownerDocument;
1491
- return ownerDocument ? ownerDocument.defaultView || window : window;
1474
+ get isTooltip() {
1475
+ return !!this.el.closest(this.getSetting("selectorTooltip")) || this.el.getAttribute("role") == "tooltip";
1492
1476
  }
1493
- return node;
1494
- }
1495
- function isElement(node) {
1496
- var OwnElement = getWindow(node).Element;
1497
- return node instanceof OwnElement || node instanceof Element;
1498
- }
1499
- function isHTMLElement(node) {
1500
- var OwnElement = getWindow(node).HTMLElement;
1501
- return node instanceof OwnElement || node instanceof HTMLElement;
1502
- }
1503
- function isShadowRoot(node) {
1504
- if (typeof ShadowRoot === "undefined") {
1505
- return false;
1477
+ get isHovered() {
1478
+ return __privateGet(this, _isHovered).el || __privateGet(this, _isHovered).trigger;
1506
1479
  }
1507
- var OwnElement = getWindow(node).ShadowRoot;
1508
- return node instanceof OwnElement || node instanceof ShadowRoot;
1509
- }
1510
- function applyStyles(_ref) {
1511
- var state = _ref.state;
1512
- Object.keys(state.elements).forEach(function(name) {
1513
- var style = state.styles[name] || {};
1514
- var attributes = state.attributes[name] || {};
1515
- var element = state.elements[name];
1516
- if (!isHTMLElement(element) || !getNodeName(element)) {
1517
- return;
1480
+ set isHovered(event) {
1481
+ const state = event.type == "mouseenter" ? true : event.type == "mouseleave" ? false : void 0;
1482
+ if (state == void 0) return;
1483
+ switch (event.target) {
1484
+ case this.el:
1485
+ __privateGet(this, _isHovered).el = state;
1486
+ break;
1487
+ case this.trigger:
1488
+ __privateGet(this, _isHovered).trigger = state;
1489
+ break;
1518
1490
  }
1519
- Object.assign(element.style, style);
1520
- Object.keys(attributes).forEach(function(name2) {
1521
- var value = attributes[name2];
1522
- if (value === false) {
1523
- element.removeAttribute(name2);
1491
+ }
1492
+ async open() {
1493
+ return this.context.open(this);
1494
+ }
1495
+ async close() {
1496
+ return this.context.close(this);
1497
+ }
1498
+ async deregister() {
1499
+ return this.context.deregister(this.id);
1500
+ }
1501
+ registerEventListeners() {
1502
+ if (!__privateGet(this, _eventListeners)) {
1503
+ const eventType = this.getSetting("event");
1504
+ if (eventType === "hover") {
1505
+ __privateSet(this, _eventListeners, [{
1506
+ el: ["el", "trigger"],
1507
+ type: ["mouseenter", "focus"],
1508
+ listener: handleMouseEnter.bind(this.context, this)
1509
+ }, {
1510
+ el: ["el", "trigger"],
1511
+ type: ["mouseleave", "focusout"],
1512
+ listener: handleMouseLeave.bind(this.context, this)
1513
+ }, {
1514
+ el: ["trigger"],
1515
+ type: ["click"],
1516
+ listener: handleTooltipClick.bind(this.context, this)
1517
+ }]);
1518
+ __privateGet(this, _eventListeners).forEach((evObj) => {
1519
+ evObj.el.forEach((el) => {
1520
+ evObj.type.forEach((type) => {
1521
+ this[el].addEventListener(type, evObj.listener, false);
1522
+ });
1523
+ });
1524
+ });
1524
1525
  } else {
1525
- element.setAttribute(name2, value === true ? "" : value);
1526
- }
1527
- });
1528
- });
1529
- }
1530
- function effect$2(_ref2) {
1531
- var state = _ref2.state;
1532
- var initialStyles = {
1533
- popper: {
1534
- position: state.options.strategy,
1535
- left: "0",
1536
- top: "0",
1537
- margin: "0"
1538
- },
1539
- arrow: {
1540
- position: "absolute"
1541
- },
1542
- reference: {}
1543
- };
1544
- Object.assign(state.elements.popper.style, initialStyles.popper);
1545
- state.styles = initialStyles;
1546
- if (state.elements.arrow) {
1547
- Object.assign(state.elements.arrow.style, initialStyles.arrow);
1548
- }
1549
- return function() {
1550
- Object.keys(state.elements).forEach(function(name) {
1551
- var element = state.elements[name];
1552
- var attributes = state.attributes[name] || {};
1553
- var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]);
1554
- var style = styleProperties.reduce(function(style2, property) {
1555
- style2[property] = "";
1556
- return style2;
1557
- }, {});
1558
- if (!isHTMLElement(element) || !getNodeName(element)) {
1559
- return;
1526
+ __privateSet(this, _eventListeners, [{
1527
+ el: ["trigger"],
1528
+ type: ["click"],
1529
+ listener: handleClick.bind(this.context, this)
1530
+ }]);
1531
+ __privateGet(this, _eventListeners).forEach((evObj) => {
1532
+ evObj.el.forEach((el) => {
1533
+ evObj.type.forEach((type) => {
1534
+ this[el].addEventListener(type, evObj.listener, false);
1535
+ });
1536
+ });
1537
+ });
1560
1538
  }
1561
- Object.assign(element.style, style);
1562
- Object.keys(attributes).forEach(function(attribute) {
1563
- element.removeAttribute(attribute);
1539
+ }
1540
+ }
1541
+ deregisterEventListeners() {
1542
+ if (__privateGet(this, _eventListeners)) {
1543
+ __privateGet(this, _eventListeners).forEach((evObj) => {
1544
+ evObj.el.forEach((el) => {
1545
+ evObj.type.forEach((type) => {
1546
+ this[el].removeEventListener(type, evObj.listener, false);
1547
+ });
1548
+ });
1564
1549
  });
1565
- });
1566
- };
1550
+ __privateSet(this, _eventListeners, null);
1551
+ }
1552
+ }
1553
+ async beforeMount() {
1554
+ this.trigger = document.querySelector(
1555
+ `[aria-controls="${this.id}"], [aria-describedby="${this.id}"]`
1556
+ );
1557
+ if (this.isTooltip) {
1558
+ this.settings.event = "hover";
1559
+ this.el.setAttribute("role", "tooltip");
1560
+ } else {
1561
+ this.trigger.setAttribute("aria-expanded", "false");
1562
+ }
1563
+ this.registerEventListeners();
1564
+ }
1565
+ async afterRegister() {
1566
+ if (this.el.classList.contains(this.getSetting("stateActive"))) {
1567
+ await this.open();
1568
+ } else {
1569
+ this.el.inert = true;
1570
+ }
1571
+ }
1572
+ async beforeUnmount() {
1573
+ if (this.state === "opened") {
1574
+ await this.close();
1575
+ }
1576
+ this.floatingCleanup();
1577
+ this.deregisterEventListeners();
1578
+ }
1567
1579
  }
1568
- const applyStyles$1 = {
1569
- name: "applyStyles",
1570
- enabled: true,
1571
- phase: "write",
1572
- fn: applyStyles,
1573
- effect: effect$2,
1574
- requires: ["computeStyles"]
1580
+ _eventListeners = new WeakMap();
1581
+ _isHovered = new WeakMap();
1582
+ const min = Math.min;
1583
+ const max = Math.max;
1584
+ const round = Math.round;
1585
+ const floor = Math.floor;
1586
+ const createCoords = (v) => ({
1587
+ x: v,
1588
+ y: v
1589
+ });
1590
+ const oppositeSideMap = {
1591
+ left: "right",
1592
+ right: "left",
1593
+ bottom: "top",
1594
+ top: "bottom"
1595
+ };
1596
+ const oppositeAlignmentMap = {
1597
+ start: "end",
1598
+ end: "start"
1575
1599
  };
1576
- function getBasePlacement(placement) {
1600
+ function clamp(start, value, end) {
1601
+ return max(start, min(value, end));
1602
+ }
1603
+ function evaluate(value, param) {
1604
+ return typeof value === "function" ? value(param) : value;
1605
+ }
1606
+ function getSide(placement) {
1577
1607
  return placement.split("-")[0];
1578
1608
  }
1579
- var max = Math.max;
1580
- var min = Math.min;
1581
- var round = Math.round;
1582
- function getUAString() {
1583
- var uaData = navigator.userAgentData;
1584
- if (uaData != null && uaData.brands && Array.isArray(uaData.brands)) {
1585
- return uaData.brands.map(function(item) {
1586
- return item.brand + "/" + item.version;
1587
- }).join(" ");
1588
- }
1589
- return navigator.userAgent;
1609
+ function getAlignment(placement) {
1610
+ return placement.split("-")[1];
1590
1611
  }
1591
- function isLayoutViewport() {
1592
- return !/^((?!chrome|android).)*safari/i.test(getUAString());
1612
+ function getOppositeAxis(axis) {
1613
+ return axis === "x" ? "y" : "x";
1593
1614
  }
1594
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1595
- if (includeScale === void 0) {
1596
- includeScale = false;
1615
+ function getAxisLength(axis) {
1616
+ return axis === "y" ? "height" : "width";
1617
+ }
1618
+ function getSideAxis(placement) {
1619
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
1620
+ }
1621
+ function getAlignmentAxis(placement) {
1622
+ return getOppositeAxis(getSideAxis(placement));
1623
+ }
1624
+ function getAlignmentSides(placement, rects, rtl) {
1625
+ if (rtl === void 0) {
1626
+ rtl = false;
1627
+ }
1628
+ const alignment = getAlignment(placement);
1629
+ const alignmentAxis = getAlignmentAxis(placement);
1630
+ const length = getAxisLength(alignmentAxis);
1631
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
1632
+ if (rects.reference[length] > rects.floating[length]) {
1633
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1634
+ }
1635
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1636
+ }
1637
+ function getExpandedPlacements(placement) {
1638
+ const oppositePlacement = getOppositePlacement(placement);
1639
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1640
+ }
1641
+ function getOppositeAlignmentPlacement(placement) {
1642
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
1643
+ }
1644
+ function getSideList(side, isStart, rtl) {
1645
+ const lr = ["left", "right"];
1646
+ const rl = ["right", "left"];
1647
+ const tb = ["top", "bottom"];
1648
+ const bt = ["bottom", "top"];
1649
+ switch (side) {
1650
+ case "top":
1651
+ case "bottom":
1652
+ if (rtl) return isStart ? rl : lr;
1653
+ return isStart ? lr : rl;
1654
+ case "left":
1655
+ case "right":
1656
+ return isStart ? tb : bt;
1657
+ default:
1658
+ return [];
1597
1659
  }
1598
- if (isFixedStrategy === void 0) {
1599
- isFixedStrategy = false;
1660
+ }
1661
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1662
+ const alignment = getAlignment(placement);
1663
+ let list = getSideList(getSide(placement), direction === "start", rtl);
1664
+ if (alignment) {
1665
+ list = list.map((side) => side + "-" + alignment);
1666
+ if (flipAlignment) {
1667
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1668
+ }
1600
1669
  }
1601
- var clientRect = element.getBoundingClientRect();
1602
- var scaleX = 1;
1603
- var scaleY = 1;
1604
- if (includeScale && isHTMLElement(element)) {
1605
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1606
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1607
- }
1608
- var _ref = isElement(element) ? getWindow(element) : window, visualViewport = _ref.visualViewport;
1609
- var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1610
- var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
1611
- var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
1612
- var width = clientRect.width / scaleX;
1613
- var height = clientRect.height / scaleY;
1670
+ return list;
1671
+ }
1672
+ function getOppositePlacement(placement) {
1673
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
1674
+ }
1675
+ function expandPaddingObject(padding) {
1614
1676
  return {
1615
- width,
1616
- height,
1617
- top: y,
1618
- right: x + width,
1619
- bottom: y + height,
1677
+ top: 0,
1678
+ right: 0,
1679
+ bottom: 0,
1680
+ left: 0,
1681
+ ...padding
1682
+ };
1683
+ }
1684
+ function getPaddingObject(padding) {
1685
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
1686
+ top: padding,
1687
+ right: padding,
1688
+ bottom: padding,
1689
+ left: padding
1690
+ };
1691
+ }
1692
+ function rectToClientRect(rect) {
1693
+ const {
1694
+ x,
1695
+ y,
1696
+ width,
1697
+ height
1698
+ } = rect;
1699
+ return {
1700
+ width,
1701
+ height,
1702
+ top: y,
1620
1703
  left: x,
1704
+ right: x + width,
1705
+ bottom: y + height,
1621
1706
  x,
1622
1707
  y
1623
1708
  };
1624
1709
  }
1625
- function getLayoutRect(element) {
1626
- var clientRect = getBoundingClientRect(element);
1627
- var width = element.offsetWidth;
1628
- var height = element.offsetHeight;
1629
- if (Math.abs(clientRect.width - width) <= 1) {
1630
- width = clientRect.width;
1710
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1711
+ let {
1712
+ reference,
1713
+ floating
1714
+ } = _ref;
1715
+ const sideAxis = getSideAxis(placement);
1716
+ const alignmentAxis = getAlignmentAxis(placement);
1717
+ const alignLength = getAxisLength(alignmentAxis);
1718
+ const side = getSide(placement);
1719
+ const isVertical = sideAxis === "y";
1720
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1721
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1722
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1723
+ let coords;
1724
+ switch (side) {
1725
+ case "top":
1726
+ coords = {
1727
+ x: commonX,
1728
+ y: reference.y - floating.height
1729
+ };
1730
+ break;
1731
+ case "bottom":
1732
+ coords = {
1733
+ x: commonX,
1734
+ y: reference.y + reference.height
1735
+ };
1736
+ break;
1737
+ case "right":
1738
+ coords = {
1739
+ x: reference.x + reference.width,
1740
+ y: commonY
1741
+ };
1742
+ break;
1743
+ case "left":
1744
+ coords = {
1745
+ x: reference.x - floating.width,
1746
+ y: commonY
1747
+ };
1748
+ break;
1749
+ default:
1750
+ coords = {
1751
+ x: reference.x,
1752
+ y: reference.y
1753
+ };
1631
1754
  }
1632
- if (Math.abs(clientRect.height - height) <= 1) {
1633
- height = clientRect.height;
1755
+ switch (getAlignment(placement)) {
1756
+ case "start":
1757
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1758
+ break;
1759
+ case "end":
1760
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1761
+ break;
1762
+ }
1763
+ return coords;
1764
+ }
1765
+ const computePosition$1 = async (reference, floating, config) => {
1766
+ const {
1767
+ placement = "bottom",
1768
+ strategy = "absolute",
1769
+ middleware = [],
1770
+ platform: platform2
1771
+ } = config;
1772
+ const validMiddleware = middleware.filter(Boolean);
1773
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
1774
+ let rects = await platform2.getElementRects({
1775
+ reference,
1776
+ floating,
1777
+ strategy
1778
+ });
1779
+ let {
1780
+ x,
1781
+ y
1782
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1783
+ let statefulPlacement = placement;
1784
+ let middlewareData = {};
1785
+ let resetCount = 0;
1786
+ for (let i = 0; i < validMiddleware.length; i++) {
1787
+ const {
1788
+ name,
1789
+ fn
1790
+ } = validMiddleware[i];
1791
+ const {
1792
+ x: nextX,
1793
+ y: nextY,
1794
+ data,
1795
+ reset
1796
+ } = await fn({
1797
+ x,
1798
+ y,
1799
+ initialPlacement: placement,
1800
+ placement: statefulPlacement,
1801
+ strategy,
1802
+ middlewareData,
1803
+ rects,
1804
+ platform: platform2,
1805
+ elements: {
1806
+ reference,
1807
+ floating
1808
+ }
1809
+ });
1810
+ x = nextX != null ? nextX : x;
1811
+ y = nextY != null ? nextY : y;
1812
+ middlewareData = {
1813
+ ...middlewareData,
1814
+ [name]: {
1815
+ ...middlewareData[name],
1816
+ ...data
1817
+ }
1818
+ };
1819
+ if (reset && resetCount <= 50) {
1820
+ resetCount++;
1821
+ if (typeof reset === "object") {
1822
+ if (reset.placement) {
1823
+ statefulPlacement = reset.placement;
1824
+ }
1825
+ if (reset.rects) {
1826
+ rects = reset.rects === true ? await platform2.getElementRects({
1827
+ reference,
1828
+ floating,
1829
+ strategy
1830
+ }) : reset.rects;
1831
+ }
1832
+ ({
1833
+ x,
1834
+ y
1835
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1836
+ }
1837
+ i = -1;
1838
+ }
1634
1839
  }
1635
1840
  return {
1636
- x: element.offsetLeft,
1637
- y: element.offsetTop,
1638
- width,
1639
- height
1841
+ x,
1842
+ y,
1843
+ placement: statefulPlacement,
1844
+ strategy,
1845
+ middlewareData
1846
+ };
1847
+ };
1848
+ async function detectOverflow(state, options) {
1849
+ var _await$platform$isEle;
1850
+ if (options === void 0) {
1851
+ options = {};
1852
+ }
1853
+ const {
1854
+ x,
1855
+ y,
1856
+ platform: platform2,
1857
+ rects,
1858
+ elements,
1859
+ strategy
1860
+ } = state;
1861
+ const {
1862
+ boundary = "clippingAncestors",
1863
+ rootBoundary = "viewport",
1864
+ elementContext = "floating",
1865
+ altBoundary = false,
1866
+ padding = 0
1867
+ } = evaluate(options, state);
1868
+ const paddingObject = getPaddingObject(padding);
1869
+ const altContext = elementContext === "floating" ? "reference" : "floating";
1870
+ const element = elements[altBoundary ? altContext : elementContext];
1871
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
1872
+ element: ((_await$platform$isEle = await (platform2.isElement == null ? void 0 : platform2.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform2.getDocumentElement == null ? void 0 : platform2.getDocumentElement(elements.floating)),
1873
+ boundary,
1874
+ rootBoundary,
1875
+ strategy
1876
+ }));
1877
+ const rect = elementContext === "floating" ? {
1878
+ x,
1879
+ y,
1880
+ width: rects.floating.width,
1881
+ height: rects.floating.height
1882
+ } : rects.reference;
1883
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
1884
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
1885
+ x: 1,
1886
+ y: 1
1887
+ } : {
1888
+ x: 1,
1889
+ y: 1
1890
+ };
1891
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
1892
+ elements,
1893
+ rect,
1894
+ offsetParent,
1895
+ strategy
1896
+ }) : rect);
1897
+ return {
1898
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1899
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1900
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1901
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1640
1902
  };
1641
1903
  }
1642
- function contains(parent, child) {
1643
- var rootNode = child.getRootNode && child.getRootNode();
1644
- if (parent.contains(child)) {
1645
- return true;
1646
- } else if (rootNode && isShadowRoot(rootNode)) {
1647
- var next = child;
1648
- do {
1649
- if (next && parent.isSameNode(next)) {
1650
- return true;
1904
+ const arrow$1 = (options) => ({
1905
+ name: "arrow",
1906
+ options,
1907
+ async fn(state) {
1908
+ const {
1909
+ x,
1910
+ y,
1911
+ placement,
1912
+ rects,
1913
+ platform: platform2,
1914
+ elements,
1915
+ middlewareData
1916
+ } = state;
1917
+ const {
1918
+ element,
1919
+ padding = 0
1920
+ } = evaluate(options, state) || {};
1921
+ if (element == null) {
1922
+ return {};
1923
+ }
1924
+ const paddingObject = getPaddingObject(padding);
1925
+ const coords = {
1926
+ x,
1927
+ y
1928
+ };
1929
+ const axis = getAlignmentAxis(placement);
1930
+ const length = getAxisLength(axis);
1931
+ const arrowDimensions = await platform2.getDimensions(element);
1932
+ const isYAxis = axis === "y";
1933
+ const minProp = isYAxis ? "top" : "left";
1934
+ const maxProp = isYAxis ? "bottom" : "right";
1935
+ const clientProp = isYAxis ? "clientHeight" : "clientWidth";
1936
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1937
+ const startDiff = coords[axis] - rects.reference[axis];
1938
+ const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
1939
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1940
+ if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
1941
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1942
+ }
1943
+ const centerToReference = endDiff / 2 - startDiff / 2;
1944
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1945
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1946
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1947
+ const min$1 = minPadding;
1948
+ const max2 = clientSize - arrowDimensions[length] - maxPadding;
1949
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1950
+ const offset2 = clamp(min$1, center, max2);
1951
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1952
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
1953
+ return {
1954
+ [axis]: coords[axis] + alignmentOffset,
1955
+ data: {
1956
+ [axis]: offset2,
1957
+ centerOffset: center - offset2 - alignmentOffset,
1958
+ ...shouldAddOffset && {
1959
+ alignmentOffset
1960
+ }
1961
+ },
1962
+ reset: shouldAddOffset
1963
+ };
1964
+ }
1965
+ });
1966
+ const flip$1 = function(options) {
1967
+ if (options === void 0) {
1968
+ options = {};
1969
+ }
1970
+ return {
1971
+ name: "flip",
1972
+ options,
1973
+ async fn(state) {
1974
+ var _middlewareData$arrow, _middlewareData$flip;
1975
+ const {
1976
+ placement,
1977
+ middlewareData,
1978
+ rects,
1979
+ initialPlacement,
1980
+ platform: platform2,
1981
+ elements
1982
+ } = state;
1983
+ const {
1984
+ mainAxis: checkMainAxis = true,
1985
+ crossAxis: checkCrossAxis = true,
1986
+ fallbackPlacements: specifiedFallbackPlacements,
1987
+ fallbackStrategy = "bestFit",
1988
+ fallbackAxisSideDirection = "none",
1989
+ flipAlignment = true,
1990
+ ...detectOverflowOptions
1991
+ } = evaluate(options, state);
1992
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1993
+ return {};
1651
1994
  }
1652
- next = next.parentNode || next.host;
1653
- } while (next);
1995
+ const side = getSide(placement);
1996
+ const initialSideAxis = getSideAxis(initialPlacement);
1997
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1998
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1999
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
2000
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
2001
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
2002
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
2003
+ }
2004
+ const placements = [initialPlacement, ...fallbackPlacements];
2005
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2006
+ const overflows = [];
2007
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
2008
+ if (checkMainAxis) {
2009
+ overflows.push(overflow[side]);
2010
+ }
2011
+ if (checkCrossAxis) {
2012
+ const sides = getAlignmentSides(placement, rects, rtl);
2013
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
2014
+ }
2015
+ overflowsData = [...overflowsData, {
2016
+ placement,
2017
+ overflows
2018
+ }];
2019
+ if (!overflows.every((side2) => side2 <= 0)) {
2020
+ var _middlewareData$flip2, _overflowsData$filter;
2021
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
2022
+ const nextPlacement = placements[nextIndex];
2023
+ if (nextPlacement) {
2024
+ return {
2025
+ data: {
2026
+ index: nextIndex,
2027
+ overflows: overflowsData
2028
+ },
2029
+ reset: {
2030
+ placement: nextPlacement
2031
+ }
2032
+ };
2033
+ }
2034
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter((d) => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
2035
+ if (!resetPlacement) {
2036
+ switch (fallbackStrategy) {
2037
+ case "bestFit": {
2038
+ var _overflowsData$filter2;
2039
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
2040
+ if (hasFallbackAxisSideDirection) {
2041
+ const currentSideAxis = getSideAxis(d.placement);
2042
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
2043
+ // reading directions favoring greater width.
2044
+ currentSideAxis === "y";
2045
+ }
2046
+ return true;
2047
+ }).map((d) => [d.placement, d.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
2048
+ if (placement2) {
2049
+ resetPlacement = placement2;
2050
+ }
2051
+ break;
2052
+ }
2053
+ case "initialPlacement":
2054
+ resetPlacement = initialPlacement;
2055
+ break;
2056
+ }
2057
+ }
2058
+ if (placement !== resetPlacement) {
2059
+ return {
2060
+ reset: {
2061
+ placement: resetPlacement
2062
+ }
2063
+ };
2064
+ }
2065
+ }
2066
+ return {};
2067
+ }
2068
+ };
2069
+ };
2070
+ async function convertValueToCoords(state, options) {
2071
+ const {
2072
+ placement,
2073
+ platform: platform2,
2074
+ elements
2075
+ } = state;
2076
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
2077
+ const side = getSide(placement);
2078
+ const alignment = getAlignment(placement);
2079
+ const isVertical = getSideAxis(placement) === "y";
2080
+ const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
2081
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
2082
+ const rawValue = evaluate(options, state);
2083
+ let {
2084
+ mainAxis,
2085
+ crossAxis,
2086
+ alignmentAxis
2087
+ } = typeof rawValue === "number" ? {
2088
+ mainAxis: rawValue,
2089
+ crossAxis: 0,
2090
+ alignmentAxis: null
2091
+ } : {
2092
+ mainAxis: rawValue.mainAxis || 0,
2093
+ crossAxis: rawValue.crossAxis || 0,
2094
+ alignmentAxis: rawValue.alignmentAxis
2095
+ };
2096
+ if (alignment && typeof alignmentAxis === "number") {
2097
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
1654
2098
  }
1655
- return false;
2099
+ return isVertical ? {
2100
+ x: crossAxis * crossAxisMulti,
2101
+ y: mainAxis * mainAxisMulti
2102
+ } : {
2103
+ x: mainAxis * mainAxisMulti,
2104
+ y: crossAxis * crossAxisMulti
2105
+ };
1656
2106
  }
1657
- function getComputedStyle$1(element) {
1658
- return getWindow(element).getComputedStyle(element);
2107
+ const offset$1 = function(options) {
2108
+ if (options === void 0) {
2109
+ options = 0;
2110
+ }
2111
+ return {
2112
+ name: "offset",
2113
+ options,
2114
+ async fn(state) {
2115
+ var _middlewareData$offse, _middlewareData$arrow;
2116
+ const {
2117
+ x,
2118
+ y,
2119
+ placement,
2120
+ middlewareData
2121
+ } = state;
2122
+ const diffCoords = await convertValueToCoords(state, options);
2123
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2124
+ return {};
2125
+ }
2126
+ return {
2127
+ x: x + diffCoords.x,
2128
+ y: y + diffCoords.y,
2129
+ data: {
2130
+ ...diffCoords,
2131
+ placement
2132
+ }
2133
+ };
2134
+ }
2135
+ };
2136
+ };
2137
+ const shift$1 = function(options) {
2138
+ if (options === void 0) {
2139
+ options = {};
2140
+ }
2141
+ return {
2142
+ name: "shift",
2143
+ options,
2144
+ async fn(state) {
2145
+ const {
2146
+ x,
2147
+ y,
2148
+ placement
2149
+ } = state;
2150
+ const {
2151
+ mainAxis: checkMainAxis = true,
2152
+ crossAxis: checkCrossAxis = false,
2153
+ limiter = {
2154
+ fn: (_ref) => {
2155
+ let {
2156
+ x: x2,
2157
+ y: y2
2158
+ } = _ref;
2159
+ return {
2160
+ x: x2,
2161
+ y: y2
2162
+ };
2163
+ }
2164
+ },
2165
+ ...detectOverflowOptions
2166
+ } = evaluate(options, state);
2167
+ const coords = {
2168
+ x,
2169
+ y
2170
+ };
2171
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2172
+ const crossAxis = getSideAxis(getSide(placement));
2173
+ const mainAxis = getOppositeAxis(crossAxis);
2174
+ let mainAxisCoord = coords[mainAxis];
2175
+ let crossAxisCoord = coords[crossAxis];
2176
+ if (checkMainAxis) {
2177
+ const minSide = mainAxis === "y" ? "top" : "left";
2178
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
2179
+ const min2 = mainAxisCoord + overflow[minSide];
2180
+ const max2 = mainAxisCoord - overflow[maxSide];
2181
+ mainAxisCoord = clamp(min2, mainAxisCoord, max2);
2182
+ }
2183
+ if (checkCrossAxis) {
2184
+ const minSide = crossAxis === "y" ? "top" : "left";
2185
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
2186
+ const min2 = crossAxisCoord + overflow[minSide];
2187
+ const max2 = crossAxisCoord - overflow[maxSide];
2188
+ crossAxisCoord = clamp(min2, crossAxisCoord, max2);
2189
+ }
2190
+ const limitedCoords = limiter.fn({
2191
+ ...state,
2192
+ [mainAxis]: mainAxisCoord,
2193
+ [crossAxis]: crossAxisCoord
2194
+ });
2195
+ return {
2196
+ ...limitedCoords,
2197
+ data: {
2198
+ x: limitedCoords.x - x,
2199
+ y: limitedCoords.y - y,
2200
+ enabled: {
2201
+ [mainAxis]: checkMainAxis,
2202
+ [crossAxis]: checkCrossAxis
2203
+ }
2204
+ }
2205
+ };
2206
+ }
2207
+ };
2208
+ };
2209
+ const limitShift$1 = function(options) {
2210
+ if (options === void 0) {
2211
+ options = {};
2212
+ }
2213
+ return {
2214
+ options,
2215
+ fn(state) {
2216
+ const {
2217
+ x,
2218
+ y,
2219
+ placement,
2220
+ rects,
2221
+ middlewareData
2222
+ } = state;
2223
+ const {
2224
+ offset: offset2 = 0,
2225
+ mainAxis: checkMainAxis = true,
2226
+ crossAxis: checkCrossAxis = true
2227
+ } = evaluate(options, state);
2228
+ const coords = {
2229
+ x,
2230
+ y
2231
+ };
2232
+ const crossAxis = getSideAxis(placement);
2233
+ const mainAxis = getOppositeAxis(crossAxis);
2234
+ let mainAxisCoord = coords[mainAxis];
2235
+ let crossAxisCoord = coords[crossAxis];
2236
+ const rawOffset = evaluate(offset2, state);
2237
+ const computedOffset = typeof rawOffset === "number" ? {
2238
+ mainAxis: rawOffset,
2239
+ crossAxis: 0
2240
+ } : {
2241
+ mainAxis: 0,
2242
+ crossAxis: 0,
2243
+ ...rawOffset
2244
+ };
2245
+ if (checkMainAxis) {
2246
+ const len = mainAxis === "y" ? "height" : "width";
2247
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2248
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2249
+ if (mainAxisCoord < limitMin) {
2250
+ mainAxisCoord = limitMin;
2251
+ } else if (mainAxisCoord > limitMax) {
2252
+ mainAxisCoord = limitMax;
2253
+ }
2254
+ }
2255
+ if (checkCrossAxis) {
2256
+ var _middlewareData$offse, _middlewareData$offse2;
2257
+ const len = mainAxis === "y" ? "width" : "height";
2258
+ const isOriginSide = ["top", "left"].includes(getSide(placement));
2259
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
2260
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
2261
+ if (crossAxisCoord < limitMin) {
2262
+ crossAxisCoord = limitMin;
2263
+ } else if (crossAxisCoord > limitMax) {
2264
+ crossAxisCoord = limitMax;
2265
+ }
2266
+ }
2267
+ return {
2268
+ [mainAxis]: mainAxisCoord,
2269
+ [crossAxis]: crossAxisCoord
2270
+ };
2271
+ }
2272
+ };
2273
+ };
2274
+ function hasWindow() {
2275
+ return typeof window !== "undefined";
1659
2276
  }
1660
- function isTableElement(element) {
1661
- return ["table", "td", "th"].indexOf(getNodeName(element)) >= 0;
1662
- }
1663
- function getDocumentElement(element) {
1664
- return ((isElement(element) ? element.ownerDocument : (
1665
- // $FlowFixMe[prop-missing]
1666
- element.document
1667
- )) || window.document).documentElement;
1668
- }
1669
- function getParentNode(element) {
1670
- if (getNodeName(element) === "html") {
1671
- return element;
1672
- }
1673
- return (
1674
- // this is a quicker (but less type safe) way to save quite some bytes from the bundle
1675
- // $FlowFixMe[incompatible-return]
1676
- // $FlowFixMe[prop-missing]
1677
- element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1678
- element.parentNode || // DOM Element detected
1679
- (isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
1680
- // $FlowFixMe[incompatible-call]: HTMLElement is a Node
1681
- getDocumentElement(element)
1682
- );
2277
+ function getNodeName(node) {
2278
+ if (isNode(node)) {
2279
+ return (node.nodeName || "").toLowerCase();
2280
+ }
2281
+ return "#document";
1683
2282
  }
1684
- function getTrueOffsetParent(element) {
1685
- if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
1686
- getComputedStyle$1(element).position === "fixed") {
1687
- return null;
2283
+ function getWindow(node) {
2284
+ var _node$ownerDocument;
2285
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2286
+ }
2287
+ function getDocumentElement(node) {
2288
+ var _ref;
2289
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2290
+ }
2291
+ function isNode(value) {
2292
+ if (!hasWindow()) {
2293
+ return false;
1688
2294
  }
1689
- return element.offsetParent;
2295
+ return value instanceof Node || value instanceof getWindow(value).Node;
1690
2296
  }
1691
- function getContainingBlock(element) {
1692
- var isFirefox = /firefox/i.test(getUAString());
1693
- var isIE = /Trident/i.test(getUAString());
1694
- if (isIE && isHTMLElement(element)) {
1695
- var elementCss = getComputedStyle$1(element);
1696
- if (elementCss.position === "fixed") {
1697
- return null;
1698
- }
2297
+ function isElement(value) {
2298
+ if (!hasWindow()) {
2299
+ return false;
2300
+ }
2301
+ return value instanceof Element || value instanceof getWindow(value).Element;
2302
+ }
2303
+ function isHTMLElement(value) {
2304
+ if (!hasWindow()) {
2305
+ return false;
1699
2306
  }
1700
- var currentNode = getParentNode(element);
1701
- if (isShadowRoot(currentNode)) {
1702
- currentNode = currentNode.host;
2307
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2308
+ }
2309
+ function isShadowRoot(value) {
2310
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
2311
+ return false;
1703
2312
  }
1704
- while (isHTMLElement(currentNode) && ["html", "body"].indexOf(getNodeName(currentNode)) < 0) {
1705
- var css = getComputedStyle$1(currentNode);
1706
- 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") {
2313
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2314
+ }
2315
+ function isOverflowElement(element) {
2316
+ const {
2317
+ overflow,
2318
+ overflowX,
2319
+ overflowY,
2320
+ display
2321
+ } = getComputedStyle$1(element);
2322
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
2323
+ }
2324
+ function isTableElement(element) {
2325
+ return ["table", "td", "th"].includes(getNodeName(element));
2326
+ }
2327
+ function isTopLayer(element) {
2328
+ return [":popover-open", ":modal"].some((selector) => {
2329
+ try {
2330
+ return element.matches(selector);
2331
+ } catch (e) {
2332
+ return false;
2333
+ }
2334
+ });
2335
+ }
2336
+ function isContainingBlock(elementOrCss) {
2337
+ const webkit = isWebKit();
2338
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
2339
+ return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
2340
+ }
2341
+ function getContainingBlock(element) {
2342
+ let currentNode = getParentNode(element);
2343
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2344
+ if (isContainingBlock(currentNode)) {
1707
2345
  return currentNode;
1708
- } else {
1709
- currentNode = currentNode.parentNode;
2346
+ } else if (isTopLayer(currentNode)) {
2347
+ return null;
1710
2348
  }
2349
+ currentNode = getParentNode(currentNode);
1711
2350
  }
1712
2351
  return null;
1713
2352
  }
1714
- function getOffsetParent(element) {
1715
- var window2 = getWindow(element);
1716
- var offsetParent = getTrueOffsetParent(element);
1717
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === "static") {
1718
- offsetParent = getTrueOffsetParent(offsetParent);
1719
- }
1720
- if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle$1(offsetParent).position === "static")) {
1721
- return window2;
1722
- }
1723
- return offsetParent || getContainingBlock(element) || window2;
2353
+ function isWebKit() {
2354
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
2355
+ return CSS.supports("-webkit-backdrop-filter", "none");
1724
2356
  }
1725
- function getMainAxisFromPlacement(placement) {
1726
- return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
2357
+ function isLastTraversableNode(node) {
2358
+ return ["html", "body", "#document"].includes(getNodeName(node));
1727
2359
  }
1728
- function within(min$1, value, max$1) {
1729
- return max(min$1, min(value, max$1));
1730
- }
1731
- function withinMaxClamp(min2, value, max2) {
1732
- var v = within(min2, value, max2);
1733
- return v > max2 ? max2 : v;
2360
+ function getComputedStyle$1(element) {
2361
+ return getWindow(element).getComputedStyle(element);
1734
2362
  }
1735
- function getFreshSideObject() {
2363
+ function getNodeScroll(element) {
2364
+ if (isElement(element)) {
2365
+ return {
2366
+ scrollLeft: element.scrollLeft,
2367
+ scrollTop: element.scrollTop
2368
+ };
2369
+ }
1736
2370
  return {
1737
- top: 0,
1738
- right: 0,
1739
- bottom: 0,
1740
- left: 0
2371
+ scrollLeft: element.scrollX,
2372
+ scrollTop: element.scrollY
1741
2373
  };
1742
2374
  }
1743
- function mergePaddingObject(paddingObject) {
1744
- return Object.assign({}, getFreshSideObject(), paddingObject);
1745
- }
1746
- function expandToHashMap(value, keys) {
1747
- return keys.reduce(function(hashMap, key) {
1748
- hashMap[key] = value;
1749
- return hashMap;
1750
- }, {});
2375
+ function getParentNode(node) {
2376
+ if (getNodeName(node) === "html") {
2377
+ return node;
2378
+ }
2379
+ const result = (
2380
+ // Step into the shadow DOM of the parent of a slotted node.
2381
+ node.assignedSlot || // DOM Element detected.
2382
+ node.parentNode || // ShadowRoot detected.
2383
+ isShadowRoot(node) && node.host || // Fallback.
2384
+ getDocumentElement(node)
2385
+ );
2386
+ return isShadowRoot(result) ? result.host : result;
1751
2387
  }
1752
- var toPaddingObject = function toPaddingObject2(padding, state) {
1753
- padding = typeof padding === "function" ? padding(Object.assign({}, state.rects, {
1754
- placement: state.placement
1755
- })) : padding;
1756
- return mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
1757
- };
1758
- function arrow(_ref) {
1759
- var _state$modifiersData$;
1760
- var state = _ref.state, name = _ref.name, options = _ref.options;
1761
- var arrowElement = state.elements.arrow;
1762
- var popperOffsets2 = state.modifiersData.popperOffsets;
1763
- var basePlacement = getBasePlacement(state.placement);
1764
- var axis = getMainAxisFromPlacement(basePlacement);
1765
- var isVertical = [left, right].indexOf(basePlacement) >= 0;
1766
- var len = isVertical ? "height" : "width";
1767
- if (!arrowElement || !popperOffsets2) {
1768
- return;
2388
+ function getNearestOverflowAncestor(node) {
2389
+ const parentNode = getParentNode(node);
2390
+ if (isLastTraversableNode(parentNode)) {
2391
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1769
2392
  }
1770
- var paddingObject = toPaddingObject(options.padding, state);
1771
- var arrowRect = getLayoutRect(arrowElement);
1772
- var minProp = axis === "y" ? top : left;
1773
- var maxProp = axis === "y" ? bottom : right;
1774
- var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets2[axis] - state.rects.popper[len];
1775
- var startDiff = popperOffsets2[axis] - state.rects.reference[axis];
1776
- var arrowOffsetParent = getOffsetParent(arrowElement);
1777
- var clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
1778
- var centerToReference = endDiff / 2 - startDiff / 2;
1779
- var min2 = paddingObject[minProp];
1780
- var max2 = clientSize - arrowRect[len] - paddingObject[maxProp];
1781
- var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
1782
- var offset2 = within(min2, center, max2);
1783
- var axisProp = axis;
1784
- state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset2, _state$modifiersData$.centerOffset = offset2 - center, _state$modifiersData$);
1785
- }
1786
- function effect$1(_ref2) {
1787
- var state = _ref2.state, options = _ref2.options;
1788
- var _options$element = options.element, arrowElement = _options$element === void 0 ? "[data-popper-arrow]" : _options$element;
1789
- if (arrowElement == null) {
1790
- return;
2393
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2394
+ return parentNode;
1791
2395
  }
1792
- if (typeof arrowElement === "string") {
1793
- arrowElement = state.elements.popper.querySelector(arrowElement);
1794
- if (!arrowElement) {
1795
- return;
1796
- }
2396
+ return getNearestOverflowAncestor(parentNode);
2397
+ }
2398
+ function getOverflowAncestors(node, list, traverseIframes) {
2399
+ var _node$ownerDocument2;
2400
+ if (list === void 0) {
2401
+ list = [];
1797
2402
  }
1798
- if (!contains(state.elements.popper, arrowElement)) {
1799
- return;
2403
+ if (traverseIframes === void 0) {
2404
+ traverseIframes = true;
2405
+ }
2406
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2407
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2408
+ const win = getWindow(scrollableAncestor);
2409
+ if (isBody) {
2410
+ const frameElement = getFrameElement(win);
2411
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2412
+ }
2413
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2414
+ }
2415
+ function getFrameElement(win) {
2416
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2417
+ }
2418
+ function getCssDimensions(element) {
2419
+ const css = getComputedStyle$1(element);
2420
+ let width = parseFloat(css.width) || 0;
2421
+ let height = parseFloat(css.height) || 0;
2422
+ const hasOffset = isHTMLElement(element);
2423
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2424
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2425
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2426
+ if (shouldFallback) {
2427
+ width = offsetWidth;
2428
+ height = offsetHeight;
1800
2429
  }
1801
- state.elements.arrow = arrowElement;
1802
- }
1803
- const arrow$1 = {
1804
- name: "arrow",
1805
- enabled: true,
1806
- phase: "main",
1807
- fn: arrow,
1808
- effect: effect$1,
1809
- requires: ["popperOffsets"],
1810
- requiresIfExists: ["preventOverflow"]
1811
- };
1812
- function getVariation(placement) {
1813
- return placement.split("-")[1];
1814
- }
1815
- var unsetSides = {
1816
- top: "auto",
1817
- right: "auto",
1818
- bottom: "auto",
1819
- left: "auto"
1820
- };
1821
- function roundOffsetsByDPR(_ref, win) {
1822
- var x = _ref.x, y = _ref.y;
1823
- var dpr = win.devicePixelRatio || 1;
1824
2430
  return {
1825
- x: round(x * dpr) / dpr || 0,
1826
- y: round(y * dpr) / dpr || 0
2431
+ width,
2432
+ height,
2433
+ $: shouldFallback
1827
2434
  };
1828
2435
  }
1829
- function mapToStyles(_ref2) {
1830
- var _Object$assign2;
1831
- 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;
1832
- 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;
1833
- var _ref3 = typeof roundOffsets === "function" ? roundOffsets({
1834
- x,
1835
- y
1836
- }) : {
1837
- x,
1838
- y
1839
- };
1840
- x = _ref3.x;
1841
- y = _ref3.y;
1842
- var hasX = offsets.hasOwnProperty("x");
1843
- var hasY = offsets.hasOwnProperty("y");
1844
- var sideX = left;
1845
- var sideY = top;
1846
- var win = window;
1847
- if (adaptive) {
1848
- var offsetParent = getOffsetParent(popper2);
1849
- var heightProp = "clientHeight";
1850
- var widthProp = "clientWidth";
1851
- if (offsetParent === getWindow(popper2)) {
1852
- offsetParent = getDocumentElement(popper2);
1853
- if (getComputedStyle$1(offsetParent).position !== "static" && position === "absolute") {
1854
- heightProp = "scrollHeight";
1855
- widthProp = "scrollWidth";
1856
- }
1857
- }
1858
- offsetParent = offsetParent;
1859
- if (placement === top || (placement === left || placement === right) && variation === end) {
1860
- sideY = bottom;
1861
- var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : (
1862
- // $FlowFixMe[prop-missing]
1863
- offsetParent[heightProp]
1864
- );
1865
- y -= offsetY - popperRect.height;
1866
- y *= gpuAcceleration ? 1 : -1;
1867
- }
1868
- if (placement === left || (placement === top || placement === bottom) && variation === end) {
1869
- sideX = right;
1870
- var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : (
1871
- // $FlowFixMe[prop-missing]
1872
- offsetParent[widthProp]
1873
- );
1874
- x -= offsetX - popperRect.width;
1875
- x *= gpuAcceleration ? 1 : -1;
1876
- }
2436
+ function unwrapElement(element) {
2437
+ return !isElement(element) ? element.contextElement : element;
2438
+ }
2439
+ function getScale(element) {
2440
+ const domElement = unwrapElement(element);
2441
+ if (!isHTMLElement(domElement)) {
2442
+ return createCoords(1);
1877
2443
  }
1878
- var commonStyles = Object.assign({
1879
- position
1880
- }, adaptive && unsetSides);
1881
- var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1882
- x,
1883
- y
1884
- }, getWindow(popper2)) : {
2444
+ const rect = domElement.getBoundingClientRect();
2445
+ const {
2446
+ width,
2447
+ height,
2448
+ $
2449
+ } = getCssDimensions(domElement);
2450
+ let x = ($ ? round(rect.width) : rect.width) / width;
2451
+ let y = ($ ? round(rect.height) : rect.height) / height;
2452
+ if (!x || !Number.isFinite(x)) {
2453
+ x = 1;
2454
+ }
2455
+ if (!y || !Number.isFinite(y)) {
2456
+ y = 1;
2457
+ }
2458
+ return {
1885
2459
  x,
1886
2460
  y
1887
2461
  };
1888
- x = _ref4.x;
1889
- y = _ref4.y;
1890
- if (gpuAcceleration) {
1891
- var _Object$assign;
1892
- 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));
1893
- }
1894
- return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : "", _Object$assign2[sideX] = hasX ? x + "px" : "", _Object$assign2.transform = "", _Object$assign2));
1895
- }
1896
- function computeStyles(_ref5) {
1897
- var state = _ref5.state, options = _ref5.options;
1898
- 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;
1899
- var commonStyles = {
1900
- placement: getBasePlacement(state.placement),
1901
- variation: getVariation(state.placement),
1902
- popper: state.elements.popper,
1903
- popperRect: state.rects.popper,
1904
- gpuAcceleration,
1905
- isFixed: state.options.strategy === "fixed"
2462
+ }
2463
+ const noOffsets = /* @__PURE__ */ createCoords(0);
2464
+ function getVisualOffsets(element) {
2465
+ const win = getWindow(element);
2466
+ if (!isWebKit() || !win.visualViewport) {
2467
+ return noOffsets;
2468
+ }
2469
+ return {
2470
+ x: win.visualViewport.offsetLeft,
2471
+ y: win.visualViewport.offsetTop
1906
2472
  };
1907
- if (state.modifiersData.popperOffsets != null) {
1908
- state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1909
- offsets: state.modifiersData.popperOffsets,
1910
- position: state.options.strategy,
1911
- adaptive,
1912
- roundOffsets
1913
- })));
1914
- }
1915
- if (state.modifiersData.arrow != null) {
1916
- state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1917
- offsets: state.modifiersData.arrow,
1918
- position: "absolute",
1919
- adaptive: false,
1920
- roundOffsets
1921
- })));
1922
- }
1923
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
1924
- "data-popper-placement": state.placement
1925
- });
1926
2473
  }
1927
- const computeStyles$1 = {
1928
- name: "computeStyles",
1929
- enabled: true,
1930
- phase: "beforeWrite",
1931
- fn: computeStyles,
1932
- data: {}
1933
- };
1934
- var passive = {
1935
- passive: true
1936
- };
1937
- function effect(_ref) {
1938
- var state = _ref.state, instance = _ref.instance, options = _ref.options;
1939
- 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;
1940
- var window2 = getWindow(state.elements.popper);
1941
- var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1942
- if (scroll) {
1943
- scrollParents.forEach(function(scrollParent) {
1944
- scrollParent.addEventListener("scroll", instance.update, passive);
1945
- });
2474
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2475
+ if (isFixed === void 0) {
2476
+ isFixed = false;
1946
2477
  }
1947
- if (resize) {
1948
- window2.addEventListener("resize", instance.update, passive);
2478
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2479
+ return false;
1949
2480
  }
1950
- return function() {
1951
- if (scroll) {
1952
- scrollParents.forEach(function(scrollParent) {
1953
- scrollParent.removeEventListener("scroll", instance.update, passive);
1954
- });
2481
+ return isFixed;
2482
+ }
2483
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2484
+ if (includeScale === void 0) {
2485
+ includeScale = false;
2486
+ }
2487
+ if (isFixedStrategy === void 0) {
2488
+ isFixedStrategy = false;
2489
+ }
2490
+ const clientRect = element.getBoundingClientRect();
2491
+ const domElement = unwrapElement(element);
2492
+ let scale = createCoords(1);
2493
+ if (includeScale) {
2494
+ if (offsetParent) {
2495
+ if (isElement(offsetParent)) {
2496
+ scale = getScale(offsetParent);
2497
+ }
2498
+ } else {
2499
+ scale = getScale(element);
2500
+ }
2501
+ }
2502
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2503
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
2504
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
2505
+ let width = clientRect.width / scale.x;
2506
+ let height = clientRect.height / scale.y;
2507
+ if (domElement) {
2508
+ const win = getWindow(domElement);
2509
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2510
+ let currentWin = win;
2511
+ let currentIFrame = getFrameElement(currentWin);
2512
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2513
+ const iframeScale = getScale(currentIFrame);
2514
+ const iframeRect = currentIFrame.getBoundingClientRect();
2515
+ const css = getComputedStyle$1(currentIFrame);
2516
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2517
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2518
+ x *= iframeScale.x;
2519
+ y *= iframeScale.y;
2520
+ width *= iframeScale.x;
2521
+ height *= iframeScale.y;
2522
+ x += left;
2523
+ y += top;
2524
+ currentWin = getWindow(currentIFrame);
2525
+ currentIFrame = getFrameElement(currentWin);
2526
+ }
2527
+ }
2528
+ return rectToClientRect({
2529
+ width,
2530
+ height,
2531
+ x,
2532
+ y
2533
+ });
2534
+ }
2535
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2536
+ let {
2537
+ elements,
2538
+ rect,
2539
+ offsetParent,
2540
+ strategy
2541
+ } = _ref;
2542
+ const isFixed = strategy === "fixed";
2543
+ const documentElement = getDocumentElement(offsetParent);
2544
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
2545
+ if (offsetParent === documentElement || topLayer && isFixed) {
2546
+ return rect;
2547
+ }
2548
+ let scroll = {
2549
+ scrollLeft: 0,
2550
+ scrollTop: 0
2551
+ };
2552
+ let scale = createCoords(1);
2553
+ const offsets = createCoords(0);
2554
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2555
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2556
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2557
+ scroll = getNodeScroll(offsetParent);
1955
2558
  }
1956
- if (resize) {
1957
- window2.removeEventListener("resize", instance.update, passive);
2559
+ if (isHTMLElement(offsetParent)) {
2560
+ const offsetRect = getBoundingClientRect(offsetParent);
2561
+ scale = getScale(offsetParent);
2562
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2563
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1958
2564
  }
2565
+ }
2566
+ return {
2567
+ width: rect.width * scale.x,
2568
+ height: rect.height * scale.y,
2569
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2570
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1959
2571
  };
1960
2572
  }
1961
- const eventListeners = {
1962
- name: "eventListeners",
1963
- enabled: true,
1964
- phase: "write",
1965
- fn: function fn() {
1966
- },
1967
- effect,
1968
- data: {}
1969
- };
1970
- var hash$1 = {
1971
- left: "right",
1972
- right: "left",
1973
- bottom: "top",
1974
- top: "bottom"
1975
- };
1976
- function getOppositePlacement(placement) {
1977
- return placement.replace(/left|right|bottom|top/g, function(matched) {
1978
- return hash$1[matched];
1979
- });
2573
+ function getClientRects(element) {
2574
+ return Array.from(element.getClientRects());
1980
2575
  }
1981
- var hash = {
1982
- start: "end",
1983
- end: "start"
1984
- };
1985
- function getOppositeVariationPlacement(placement) {
1986
- return placement.replace(/start|end/g, function(matched) {
1987
- return hash[matched];
1988
- });
2576
+ function getWindowScrollBarX(element, rect) {
2577
+ const leftScroll = getNodeScroll(element).scrollLeft;
2578
+ if (!rect) {
2579
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2580
+ }
2581
+ return rect.left + leftScroll;
1989
2582
  }
1990
- function getWindowScroll(node) {
1991
- var win = getWindow(node);
1992
- var scrollLeft = win.pageXOffset;
1993
- var scrollTop = win.pageYOffset;
2583
+ function getDocumentRect(element) {
2584
+ const html = getDocumentElement(element);
2585
+ const scroll = getNodeScroll(element);
2586
+ const body = element.ownerDocument.body;
2587
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2588
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2589
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2590
+ const y = -scroll.scrollTop;
2591
+ if (getComputedStyle$1(body).direction === "rtl") {
2592
+ x += max(html.clientWidth, body.clientWidth) - width;
2593
+ }
1994
2594
  return {
1995
- scrollLeft,
1996
- scrollTop
2595
+ width,
2596
+ height,
2597
+ x,
2598
+ y
1997
2599
  };
1998
2600
  }
1999
- function getWindowScrollBarX(element) {
2000
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
2001
- }
2002
2601
  function getViewportRect(element, strategy) {
2003
- var win = getWindow(element);
2004
- var html = getDocumentElement(element);
2005
- var visualViewport = win.visualViewport;
2006
- var width = html.clientWidth;
2007
- var height = html.clientHeight;
2008
- var x = 0;
2009
- var y = 0;
2602
+ const win = getWindow(element);
2603
+ const html = getDocumentElement(element);
2604
+ const visualViewport = win.visualViewport;
2605
+ let width = html.clientWidth;
2606
+ let height = html.clientHeight;
2607
+ let x = 0;
2608
+ let y = 0;
2010
2609
  if (visualViewport) {
2011
2610
  width = visualViewport.width;
2012
2611
  height = visualViewport.height;
2013
- var layoutViewport = isLayoutViewport();
2014
- if (layoutViewport || !layoutViewport && strategy === "fixed") {
2612
+ const visualViewportBased = isWebKit();
2613
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2015
2614
  x = visualViewport.offsetLeft;
2016
2615
  y = visualViewport.offsetTop;
2017
2616
  }
@@ -2019,22 +2618,19 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2019
2618
  return {
2020
2619
  width,
2021
2620
  height,
2022
- x: x + getWindowScrollBarX(element),
2621
+ x,
2023
2622
  y
2024
2623
  };
2025
2624
  }
2026
- function getDocumentRect(element) {
2027
- var _element$ownerDocumen;
2028
- var html = getDocumentElement(element);
2029
- var winScroll = getWindowScroll(element);
2030
- var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
2031
- var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
2032
- var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
2033
- var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
2034
- var y = -winScroll.scrollTop;
2035
- if (getComputedStyle$1(body || html).direction === "rtl") {
2036
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
2037
- }
2625
+ function getInnerBoundingClientRect(element, strategy) {
2626
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2627
+ const top = clientRect.top + element.clientTop;
2628
+ const left = clientRect.left + element.clientLeft;
2629
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2630
+ const width = element.clientWidth * scale.x;
2631
+ const height = element.clientHeight * scale.y;
2632
+ const x = left * scale.x;
2633
+ const y = top * scale.y;
2038
2634
  return {
2039
2635
  width,
2040
2636
  height,
@@ -2042,794 +2638,358 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2042
2638
  y
2043
2639
  };
2044
2640
  }
2045
- function isScrollParent(element) {
2046
- var _getComputedStyle = getComputedStyle$1(element), overflow = _getComputedStyle.overflow, overflowX = _getComputedStyle.overflowX, overflowY = _getComputedStyle.overflowY;
2047
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
2048
- }
2049
- function getScrollParent(node) {
2050
- if (["html", "body", "#document"].indexOf(getNodeName(node)) >= 0) {
2051
- return node.ownerDocument.body;
2052
- }
2053
- if (isHTMLElement(node) && isScrollParent(node)) {
2054
- return node;
2641
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2642
+ let rect;
2643
+ if (clippingAncestor === "viewport") {
2644
+ rect = getViewportRect(element, strategy);
2645
+ } else if (clippingAncestor === "document") {
2646
+ rect = getDocumentRect(getDocumentElement(element));
2647
+ } else if (isElement(clippingAncestor)) {
2648
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2649
+ } else {
2650
+ const visualOffsets = getVisualOffsets(element);
2651
+ rect = {
2652
+ ...clippingAncestor,
2653
+ x: clippingAncestor.x - visualOffsets.x,
2654
+ y: clippingAncestor.y - visualOffsets.y
2655
+ };
2055
2656
  }
2056
- return getScrollParent(getParentNode(node));
2657
+ return rectToClientRect(rect);
2057
2658
  }
2058
- function listScrollParents(element, list) {
2059
- var _element$ownerDocumen;
2060
- if (list === void 0) {
2061
- list = [];
2659
+ function hasFixedPositionAncestor(element, stopNode) {
2660
+ const parentNode = getParentNode(element);
2661
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2662
+ return false;
2062
2663
  }
2063
- var scrollParent = getScrollParent(element);
2064
- var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
2065
- var win = getWindow(scrollParent);
2066
- var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
2067
- var updatedList = list.concat(target);
2068
- return isBody ? updatedList : (
2069
- // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
2070
- updatedList.concat(listScrollParents(getParentNode(target)))
2071
- );
2072
- }
2073
- function rectToClientRect(rect) {
2074
- return Object.assign({}, rect, {
2075
- left: rect.x,
2076
- top: rect.y,
2077
- right: rect.x + rect.width,
2078
- bottom: rect.y + rect.height
2079
- });
2080
- }
2081
- function getInnerBoundingClientRect(element, strategy) {
2082
- var rect = getBoundingClientRect(element, false, strategy === "fixed");
2083
- rect.top = rect.top + element.clientTop;
2084
- rect.left = rect.left + element.clientLeft;
2085
- rect.bottom = rect.top + element.clientHeight;
2086
- rect.right = rect.left + element.clientWidth;
2087
- rect.width = element.clientWidth;
2088
- rect.height = element.clientHeight;
2089
- rect.x = rect.left;
2090
- rect.y = rect.top;
2091
- return rect;
2092
- }
2093
- function getClientRectFromMixedType(element, clippingParent, strategy) {
2094
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
2095
- }
2096
- function getClippingParents(element) {
2097
- var clippingParents2 = listScrollParents(getParentNode(element));
2098
- var canEscapeClipping = ["absolute", "fixed"].indexOf(getComputedStyle$1(element).position) >= 0;
2099
- var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
2100
- if (!isElement(clipperElement)) {
2101
- return [];
2102
- }
2103
- return clippingParents2.filter(function(clippingParent) {
2104
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body";
2105
- });
2664
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2665
+ }
2666
+ function getClippingElementAncestors(element, cache) {
2667
+ const cachedResult = cache.get(element);
2668
+ if (cachedResult) {
2669
+ return cachedResult;
2670
+ }
2671
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2672
+ let currentContainingBlockComputedStyle = null;
2673
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
2674
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2675
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2676
+ const computedStyle = getComputedStyle$1(currentNode);
2677
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2678
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2679
+ currentContainingBlockComputedStyle = null;
2680
+ }
2681
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2682
+ if (shouldDropCurrentNode) {
2683
+ result = result.filter((ancestor) => ancestor !== currentNode);
2684
+ } else {
2685
+ currentContainingBlockComputedStyle = computedStyle;
2686
+ }
2687
+ currentNode = getParentNode(currentNode);
2688
+ }
2689
+ cache.set(element, result);
2690
+ return result;
2106
2691
  }
2107
- function getClippingRect(element, boundary, rootBoundary, strategy) {
2108
- var mainClippingParents = boundary === "clippingParents" ? getClippingParents(element) : [].concat(boundary);
2109
- var clippingParents2 = [].concat(mainClippingParents, [rootBoundary]);
2110
- var firstClippingParent = clippingParents2[0];
2111
- var clippingRect = clippingParents2.reduce(function(accRect, clippingParent) {
2112
- var rect = getClientRectFromMixedType(element, clippingParent, strategy);
2692
+ function getClippingRect(_ref) {
2693
+ let {
2694
+ element,
2695
+ boundary,
2696
+ rootBoundary,
2697
+ strategy
2698
+ } = _ref;
2699
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2700
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2701
+ const firstClippingAncestor = clippingAncestors[0];
2702
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2703
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2113
2704
  accRect.top = max(rect.top, accRect.top);
2114
2705
  accRect.right = min(rect.right, accRect.right);
2115
2706
  accRect.bottom = min(rect.bottom, accRect.bottom);
2116
2707
  accRect.left = max(rect.left, accRect.left);
2117
2708
  return accRect;
2118
- }, getClientRectFromMixedType(element, firstClippingParent, strategy));
2119
- clippingRect.width = clippingRect.right - clippingRect.left;
2120
- clippingRect.height = clippingRect.bottom - clippingRect.top;
2121
- clippingRect.x = clippingRect.left;
2122
- clippingRect.y = clippingRect.top;
2123
- return clippingRect;
2124
- }
2125
- function computeOffsets(_ref) {
2126
- var reference2 = _ref.reference, element = _ref.element, placement = _ref.placement;
2127
- var basePlacement = placement ? getBasePlacement(placement) : null;
2128
- var variation = placement ? getVariation(placement) : null;
2129
- var commonX = reference2.x + reference2.width / 2 - element.width / 2;
2130
- var commonY = reference2.y + reference2.height / 2 - element.height / 2;
2131
- var offsets;
2132
- switch (basePlacement) {
2133
- case top:
2134
- offsets = {
2135
- x: commonX,
2136
- y: reference2.y - element.height
2137
- };
2138
- break;
2139
- case bottom:
2140
- offsets = {
2141
- x: commonX,
2142
- y: reference2.y + reference2.height
2143
- };
2144
- break;
2145
- case right:
2146
- offsets = {
2147
- x: reference2.x + reference2.width,
2148
- y: commonY
2149
- };
2150
- break;
2151
- case left:
2152
- offsets = {
2153
- x: reference2.x - element.width,
2154
- y: commonY
2155
- };
2156
- break;
2157
- default:
2158
- offsets = {
2159
- x: reference2.x,
2160
- y: reference2.y
2161
- };
2162
- }
2163
- var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
2164
- if (mainAxis != null) {
2165
- var len = mainAxis === "y" ? "height" : "width";
2166
- switch (variation) {
2167
- case start:
2168
- offsets[mainAxis] = offsets[mainAxis] - (reference2[len] / 2 - element[len] / 2);
2169
- break;
2170
- case end:
2171
- offsets[mainAxis] = offsets[mainAxis] + (reference2[len] / 2 - element[len] / 2);
2172
- break;
2173
- }
2174
- }
2175
- return offsets;
2176
- }
2177
- function detectOverflow(state, options) {
2178
- if (options === void 0) {
2179
- options = {};
2180
- }
2181
- 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;
2182
- var paddingObject = mergePaddingObject(typeof padding !== "number" ? padding : expandToHashMap(padding, basePlacements));
2183
- var altContext = elementContext === popper ? reference : popper;
2184
- var popperRect = state.rects.popper;
2185
- var element = state.elements[altBoundary ? altContext : elementContext];
2186
- var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
2187
- var referenceClientRect = getBoundingClientRect(state.elements.reference);
2188
- var popperOffsets2 = computeOffsets({
2189
- reference: referenceClientRect,
2190
- element: popperRect,
2191
- strategy: "absolute",
2192
- placement
2193
- });
2194
- var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets2));
2195
- var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect;
2196
- var overflowOffsets = {
2197
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
2198
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
2199
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
2200
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
2201
- };
2202
- var offsetData = state.modifiersData.offset;
2203
- if (elementContext === popper && offsetData) {
2204
- var offset2 = offsetData[placement];
2205
- Object.keys(overflowOffsets).forEach(function(key) {
2206
- var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
2207
- var axis = [top, bottom].indexOf(key) >= 0 ? "y" : "x";
2208
- overflowOffsets[key] += offset2[axis] * multiply;
2209
- });
2210
- }
2211
- return overflowOffsets;
2212
- }
2213
- function computeAutoPlacement(state, options) {
2214
- if (options === void 0) {
2215
- options = {};
2216
- }
2217
- 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;
2218
- var variation = getVariation(placement);
2219
- var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function(placement2) {
2220
- return getVariation(placement2) === variation;
2221
- }) : basePlacements;
2222
- var allowedPlacements = placements$1.filter(function(placement2) {
2223
- return allowedAutoPlacements.indexOf(placement2) >= 0;
2224
- });
2225
- if (allowedPlacements.length === 0) {
2226
- allowedPlacements = placements$1;
2227
- }
2228
- var overflows = allowedPlacements.reduce(function(acc, placement2) {
2229
- acc[placement2] = detectOverflow(state, {
2230
- placement: placement2,
2231
- boundary,
2232
- rootBoundary,
2233
- padding
2234
- })[getBasePlacement(placement2)];
2235
- return acc;
2236
- }, {});
2237
- return Object.keys(overflows).sort(function(a, b) {
2238
- return overflows[a] - overflows[b];
2239
- });
2240
- }
2241
- function getExpandedFallbackPlacements(placement) {
2242
- if (getBasePlacement(placement) === auto) {
2243
- return [];
2244
- }
2245
- var oppositePlacement = getOppositePlacement(placement);
2246
- return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
2247
- }
2248
- function flip(_ref) {
2249
- var state = _ref.state, options = _ref.options, name = _ref.name;
2250
- if (state.modifiersData[name]._skip) {
2251
- return;
2252
- }
2253
- 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;
2254
- var preferredPlacement = state.options.placement;
2255
- var basePlacement = getBasePlacement(preferredPlacement);
2256
- var isBasePlacement = basePlacement === preferredPlacement;
2257
- var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
2258
- var placements2 = [preferredPlacement].concat(fallbackPlacements).reduce(function(acc, placement2) {
2259
- return acc.concat(getBasePlacement(placement2) === auto ? computeAutoPlacement(state, {
2260
- placement: placement2,
2261
- boundary,
2262
- rootBoundary,
2263
- padding,
2264
- flipVariations,
2265
- allowedAutoPlacements
2266
- }) : placement2);
2267
- }, []);
2268
- var referenceRect = state.rects.reference;
2269
- var popperRect = state.rects.popper;
2270
- var checksMap = /* @__PURE__ */ new Map();
2271
- var makeFallbackChecks = true;
2272
- var firstFittingPlacement = placements2[0];
2273
- for (var i = 0; i < placements2.length; i++) {
2274
- var placement = placements2[i];
2275
- var _basePlacement = getBasePlacement(placement);
2276
- var isStartVariation = getVariation(placement) === start;
2277
- var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
2278
- var len = isVertical ? "width" : "height";
2279
- var overflow = detectOverflow(state, {
2280
- placement,
2281
- boundary,
2282
- rootBoundary,
2283
- altBoundary,
2284
- padding
2285
- });
2286
- var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
2287
- if (referenceRect[len] > popperRect[len]) {
2288
- mainVariationSide = getOppositePlacement(mainVariationSide);
2289
- }
2290
- var altVariationSide = getOppositePlacement(mainVariationSide);
2291
- var checks = [];
2292
- if (checkMainAxis) {
2293
- checks.push(overflow[_basePlacement] <= 0);
2294
- }
2295
- if (checkAltAxis) {
2296
- checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
2297
- }
2298
- if (checks.every(function(check) {
2299
- return check;
2300
- })) {
2301
- firstFittingPlacement = placement;
2302
- makeFallbackChecks = false;
2303
- break;
2304
- }
2305
- checksMap.set(placement, checks);
2306
- }
2307
- if (makeFallbackChecks) {
2308
- var numberOfChecks = flipVariations ? 3 : 1;
2309
- var _loop = function _loop2(_i2) {
2310
- var fittingPlacement = placements2.find(function(placement2) {
2311
- var checks2 = checksMap.get(placement2);
2312
- if (checks2) {
2313
- return checks2.slice(0, _i2).every(function(check) {
2314
- return check;
2315
- });
2316
- }
2317
- });
2318
- if (fittingPlacement) {
2319
- firstFittingPlacement = fittingPlacement;
2320
- return "break";
2321
- }
2322
- };
2323
- for (var _i = numberOfChecks; _i > 0; _i--) {
2324
- var _ret = _loop(_i);
2325
- if (_ret === "break") break;
2326
- }
2327
- }
2328
- if (state.placement !== firstFittingPlacement) {
2329
- state.modifiersData[name]._skip = true;
2330
- state.placement = firstFittingPlacement;
2331
- state.reset = true;
2332
- }
2333
- }
2334
- const flip$1 = {
2335
- name: "flip",
2336
- enabled: true,
2337
- phase: "main",
2338
- fn: flip,
2339
- requiresIfExists: ["offset"],
2340
- data: {
2341
- _skip: false
2342
- }
2343
- };
2344
- function getSideOffsets(overflow, rect, preventedOffsets) {
2345
- if (preventedOffsets === void 0) {
2346
- preventedOffsets = {
2347
- x: 0,
2348
- y: 0
2349
- };
2350
- }
2709
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2351
2710
  return {
2352
- top: overflow.top - rect.height - preventedOffsets.y,
2353
- right: overflow.right - rect.width + preventedOffsets.x,
2354
- bottom: overflow.bottom - rect.height + preventedOffsets.y,
2355
- left: overflow.left - rect.width - preventedOffsets.x
2356
- };
2357
- }
2358
- function isAnySideFullyClipped(overflow) {
2359
- return [top, right, bottom, left].some(function(side) {
2360
- return overflow[side] >= 0;
2361
- });
2362
- }
2363
- function hide(_ref) {
2364
- var state = _ref.state, name = _ref.name;
2365
- var referenceRect = state.rects.reference;
2366
- var popperRect = state.rects.popper;
2367
- var preventedOffsets = state.modifiersData.preventOverflow;
2368
- var referenceOverflow = detectOverflow(state, {
2369
- elementContext: "reference"
2370
- });
2371
- var popperAltOverflow = detectOverflow(state, {
2372
- altBoundary: true
2373
- });
2374
- var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
2375
- var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
2376
- var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
2377
- var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
2378
- state.modifiersData[name] = {
2379
- referenceClippingOffsets,
2380
- popperEscapeOffsets,
2381
- isReferenceHidden,
2382
- hasPopperEscaped
2711
+ width: clippingRect.right - clippingRect.left,
2712
+ height: clippingRect.bottom - clippingRect.top,
2713
+ x: clippingRect.left,
2714
+ y: clippingRect.top
2383
2715
  };
2384
- state.attributes.popper = Object.assign({}, state.attributes.popper, {
2385
- "data-popper-reference-hidden": isReferenceHidden,
2386
- "data-popper-escaped": hasPopperEscaped
2387
- });
2388
- }
2389
- const hide$1 = {
2390
- name: "hide",
2391
- enabled: true,
2392
- phase: "main",
2393
- requiresIfExists: ["preventOverflow"],
2394
- fn: hide
2395
- };
2396
- function distanceAndSkiddingToXY(placement, rects, offset2) {
2397
- var basePlacement = getBasePlacement(placement);
2398
- var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
2399
- var _ref = typeof offset2 === "function" ? offset2(Object.assign({}, rects, {
2400
- placement
2401
- })) : offset2, skidding = _ref[0], distance = _ref[1];
2402
- skidding = skidding || 0;
2403
- distance = (distance || 0) * invertDistance;
2404
- return [left, right].indexOf(basePlacement) >= 0 ? {
2405
- x: distance,
2406
- y: skidding
2407
- } : {
2408
- x: skidding,
2409
- y: distance
2410
- };
2411
- }
2412
- function offset(_ref2) {
2413
- var state = _ref2.state, options = _ref2.options, name = _ref2.name;
2414
- var _options$offset = options.offset, offset2 = _options$offset === void 0 ? [0, 0] : _options$offset;
2415
- var data = placements.reduce(function(acc, placement) {
2416
- acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset2);
2417
- return acc;
2418
- }, {});
2419
- var _data$state$placement = data[state.placement], x = _data$state$placement.x, y = _data$state$placement.y;
2420
- if (state.modifiersData.popperOffsets != null) {
2421
- state.modifiersData.popperOffsets.x += x;
2422
- state.modifiersData.popperOffsets.y += y;
2423
- }
2424
- state.modifiersData[name] = data;
2425
- }
2426
- const offset$1 = {
2427
- name: "offset",
2428
- enabled: true,
2429
- phase: "main",
2430
- requires: ["popperOffsets"],
2431
- fn: offset
2432
- };
2433
- function popperOffsets(_ref) {
2434
- var state = _ref.state, name = _ref.name;
2435
- state.modifiersData[name] = computeOffsets({
2436
- reference: state.rects.reference,
2437
- element: state.rects.popper,
2438
- strategy: "absolute",
2439
- placement: state.placement
2440
- });
2441
2716
  }
2442
- const popperOffsets$1 = {
2443
- name: "popperOffsets",
2444
- enabled: true,
2445
- phase: "read",
2446
- fn: popperOffsets,
2447
- data: {}
2448
- };
2449
- function getAltAxis(axis) {
2450
- return axis === "x" ? "y" : "x";
2451
- }
2452
- function preventOverflow(_ref) {
2453
- var state = _ref.state, options = _ref.options, name = _ref.name;
2454
- 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;
2455
- var overflow = detectOverflow(state, {
2456
- boundary,
2457
- rootBoundary,
2458
- padding,
2459
- altBoundary
2460
- });
2461
- var basePlacement = getBasePlacement(state.placement);
2462
- var variation = getVariation(state.placement);
2463
- var isBasePlacement = !variation;
2464
- var mainAxis = getMainAxisFromPlacement(basePlacement);
2465
- var altAxis = getAltAxis(mainAxis);
2466
- var popperOffsets2 = state.modifiersData.popperOffsets;
2467
- var referenceRect = state.rects.reference;
2468
- var popperRect = state.rects.popper;
2469
- var tetherOffsetValue = typeof tetherOffset === "function" ? tetherOffset(Object.assign({}, state.rects, {
2470
- placement: state.placement
2471
- })) : tetherOffset;
2472
- var normalizedTetherOffsetValue = typeof tetherOffsetValue === "number" ? {
2473
- mainAxis: tetherOffsetValue,
2474
- altAxis: tetherOffsetValue
2475
- } : Object.assign({
2476
- mainAxis: 0,
2477
- altAxis: 0
2478
- }, tetherOffsetValue);
2479
- var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
2480
- var data = {
2481
- x: 0,
2482
- y: 0
2483
- };
2484
- if (!popperOffsets2) {
2485
- return;
2486
- }
2487
- if (checkMainAxis) {
2488
- var _offsetModifierState$;
2489
- var mainSide = mainAxis === "y" ? top : left;
2490
- var altSide = mainAxis === "y" ? bottom : right;
2491
- var len = mainAxis === "y" ? "height" : "width";
2492
- var offset2 = popperOffsets2[mainAxis];
2493
- var min$1 = offset2 + overflow[mainSide];
2494
- var max$1 = offset2 - overflow[altSide];
2495
- var additive = tether ? -popperRect[len] / 2 : 0;
2496
- var minLen = variation === start ? referenceRect[len] : popperRect[len];
2497
- var maxLen = variation === start ? -popperRect[len] : -referenceRect[len];
2498
- var arrowElement = state.elements.arrow;
2499
- var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
2500
- width: 0,
2501
- height: 0
2502
- };
2503
- var arrowPaddingObject = state.modifiersData["arrow#persistent"] ? state.modifiersData["arrow#persistent"].padding : getFreshSideObject();
2504
- var arrowPaddingMin = arrowPaddingObject[mainSide];
2505
- var arrowPaddingMax = arrowPaddingObject[altSide];
2506
- var arrowLen = within(0, referenceRect[len], arrowRect[len]);
2507
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
2508
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
2509
- var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
2510
- var clientOffset = arrowOffsetParent ? mainAxis === "y" ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
2511
- var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
2512
- var tetherMin = offset2 + minOffset - offsetModifierValue - clientOffset;
2513
- var tetherMax = offset2 + maxOffset - offsetModifierValue;
2514
- var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset2, tether ? max(max$1, tetherMax) : max$1);
2515
- popperOffsets2[mainAxis] = preventedOffset;
2516
- data[mainAxis] = preventedOffset - offset2;
2517
- }
2518
- if (checkAltAxis) {
2519
- var _offsetModifierState$2;
2520
- var _mainSide = mainAxis === "x" ? top : left;
2521
- var _altSide = mainAxis === "x" ? bottom : right;
2522
- var _offset = popperOffsets2[altAxis];
2523
- var _len = altAxis === "y" ? "height" : "width";
2524
- var _min = _offset + overflow[_mainSide];
2525
- var _max = _offset - overflow[_altSide];
2526
- var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
2527
- var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
2528
- var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
2529
- var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
2530
- var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
2531
- popperOffsets2[altAxis] = _preventedOffset;
2532
- data[altAxis] = _preventedOffset - _offset;
2533
- }
2534
- state.modifiersData[name] = data;
2535
- }
2536
- const preventOverflow$1 = {
2537
- name: "preventOverflow",
2538
- enabled: true,
2539
- phase: "main",
2540
- fn: preventOverflow,
2541
- requiresIfExists: ["offset"]
2542
- };
2543
- function getHTMLElementScroll(element) {
2717
+ function getDimensions(element) {
2718
+ const {
2719
+ width,
2720
+ height
2721
+ } = getCssDimensions(element);
2544
2722
  return {
2545
- scrollLeft: element.scrollLeft,
2546
- scrollTop: element.scrollTop
2723
+ width,
2724
+ height
2547
2725
  };
2548
2726
  }
2549
- function getNodeScroll(node) {
2550
- if (node === getWindow(node) || !isHTMLElement(node)) {
2551
- return getWindowScroll(node);
2552
- } else {
2553
- return getHTMLElementScroll(node);
2554
- }
2555
- }
2556
- function isElementScaled(element) {
2557
- var rect = element.getBoundingClientRect();
2558
- var scaleX = round(rect.width) / element.offsetWidth || 1;
2559
- var scaleY = round(rect.height) / element.offsetHeight || 1;
2560
- return scaleX !== 1 || scaleY !== 1;
2561
- }
2562
- function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
2563
- if (isFixed === void 0) {
2564
- isFixed = false;
2565
- }
2566
- var isOffsetParentAnElement = isHTMLElement(offsetParent);
2567
- var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
2568
- var documentElement = getDocumentElement(offsetParent);
2569
- var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
2570
- var scroll = {
2727
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2728
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2729
+ const documentElement = getDocumentElement(offsetParent);
2730
+ const isFixed = strategy === "fixed";
2731
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2732
+ let scroll = {
2571
2733
  scrollLeft: 0,
2572
2734
  scrollTop: 0
2573
2735
  };
2574
- var offsets = {
2575
- x: 0,
2576
- y: 0
2577
- };
2736
+ const offsets = createCoords(0);
2578
2737
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2579
- if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
2580
- isScrollParent(documentElement)) {
2738
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2581
2739
  scroll = getNodeScroll(offsetParent);
2582
2740
  }
2583
- if (isHTMLElement(offsetParent)) {
2584
- offsets = getBoundingClientRect(offsetParent, true);
2585
- offsets.x += offsetParent.clientLeft;
2586
- offsets.y += offsetParent.clientTop;
2741
+ if (isOffsetParentAnElement) {
2742
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2743
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2744
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2587
2745
  } else if (documentElement) {
2588
2746
  offsets.x = getWindowScrollBarX(documentElement);
2589
2747
  }
2590
2748
  }
2749
+ let htmlX = 0;
2750
+ let htmlY = 0;
2751
+ if (documentElement && !isOffsetParentAnElement && !isFixed) {
2752
+ const htmlRect = documentElement.getBoundingClientRect();
2753
+ htmlY = htmlRect.top + scroll.scrollTop;
2754
+ htmlX = htmlRect.left + scroll.scrollLeft - // RTL <body> scrollbar.
2755
+ getWindowScrollBarX(documentElement, htmlRect);
2756
+ }
2757
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlX;
2758
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlY;
2591
2759
  return {
2592
- x: rect.left + scroll.scrollLeft - offsets.x,
2593
- y: rect.top + scroll.scrollTop - offsets.y,
2760
+ x,
2761
+ y,
2594
2762
  width: rect.width,
2595
2763
  height: rect.height
2596
2764
  };
2597
2765
  }
2598
- function order(modifiers) {
2599
- var map = /* @__PURE__ */ new Map();
2600
- var visited = /* @__PURE__ */ new Set();
2601
- var result = [];
2602
- modifiers.forEach(function(modifier) {
2603
- map.set(modifier.name, modifier);
2604
- });
2605
- function sort(modifier) {
2606
- visited.add(modifier.name);
2607
- var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
2608
- requires.forEach(function(dep) {
2609
- if (!visited.has(dep)) {
2610
- var depModifier = map.get(dep);
2611
- if (depModifier) {
2612
- sort(depModifier);
2613
- }
2614
- }
2615
- });
2616
- result.push(modifier);
2766
+ function isStaticPositioned(element) {
2767
+ return getComputedStyle$1(element).position === "static";
2768
+ }
2769
+ function getTrueOffsetParent(element, polyfill) {
2770
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
2771
+ return null;
2617
2772
  }
2618
- modifiers.forEach(function(modifier) {
2619
- if (!visited.has(modifier.name)) {
2620
- sort(modifier);
2773
+ if (polyfill) {
2774
+ return polyfill(element);
2775
+ }
2776
+ let rawOffsetParent = element.offsetParent;
2777
+ if (getDocumentElement(element) === rawOffsetParent) {
2778
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
2779
+ }
2780
+ return rawOffsetParent;
2781
+ }
2782
+ function getOffsetParent(element, polyfill) {
2783
+ const win = getWindow(element);
2784
+ if (isTopLayer(element)) {
2785
+ return win;
2786
+ }
2787
+ if (!isHTMLElement(element)) {
2788
+ let svgOffsetParent = getParentNode(element);
2789
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2790
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2791
+ return svgOffsetParent;
2792
+ }
2793
+ svgOffsetParent = getParentNode(svgOffsetParent);
2621
2794
  }
2622
- });
2623
- return result;
2795
+ return win;
2796
+ }
2797
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2798
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2799
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2800
+ }
2801
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2802
+ return win;
2803
+ }
2804
+ return offsetParent || getContainingBlock(element) || win;
2624
2805
  }
2625
- function orderModifiers(modifiers) {
2626
- var orderedModifiers = order(modifiers);
2627
- return modifierPhases.reduce(function(acc, phase) {
2628
- return acc.concat(orderedModifiers.filter(function(modifier) {
2629
- return modifier.phase === phase;
2630
- }));
2631
- }, []);
2632
- }
2633
- function debounce(fn) {
2634
- var pending;
2635
- return function() {
2636
- if (!pending) {
2637
- pending = new Promise(function(resolve) {
2638
- Promise.resolve().then(function() {
2639
- pending = void 0;
2640
- resolve(fn());
2641
- });
2642
- });
2806
+ const getElementRects = async function(data) {
2807
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2808
+ const getDimensionsFn = this.getDimensions;
2809
+ const floatingDimensions = await getDimensionsFn(data.floating);
2810
+ return {
2811
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2812
+ floating: {
2813
+ x: 0,
2814
+ y: 0,
2815
+ width: floatingDimensions.width,
2816
+ height: floatingDimensions.height
2643
2817
  }
2644
- return pending;
2645
2818
  };
2646
- }
2647
- function mergeByName(modifiers) {
2648
- var merged = modifiers.reduce(function(merged2, current) {
2649
- var existing = merged2[current.name];
2650
- merged2[current.name] = existing ? Object.assign({}, existing, current, {
2651
- options: Object.assign({}, existing.options, current.options),
2652
- data: Object.assign({}, existing.data, current.data)
2653
- }) : current;
2654
- return merged2;
2655
- }, {});
2656
- return Object.keys(merged).map(function(key) {
2657
- return merged[key];
2658
- });
2659
- }
2660
- var DEFAULT_OPTIONS = {
2661
- placement: "bottom",
2662
- modifiers: [],
2663
- strategy: "absolute"
2664
2819
  };
2665
- function areValidElements() {
2666
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2667
- args[_key] = arguments[_key];
2668
- }
2669
- return !args.some(function(element) {
2670
- return !(element && typeof element.getBoundingClientRect === "function");
2671
- });
2672
- }
2673
- function popperGenerator(generatorOptions) {
2674
- if (generatorOptions === void 0) {
2675
- generatorOptions = {};
2676
- }
2677
- 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;
2678
- return function createPopper2(reference2, popper2, options) {
2679
- if (options === void 0) {
2680
- options = defaultOptions;
2820
+ function isRTL(element) {
2821
+ return getComputedStyle$1(element).direction === "rtl";
2822
+ }
2823
+ const platform = {
2824
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2825
+ getDocumentElement,
2826
+ getClippingRect,
2827
+ getOffsetParent,
2828
+ getElementRects,
2829
+ getClientRects,
2830
+ getDimensions,
2831
+ getScale,
2832
+ isElement,
2833
+ isRTL
2834
+ };
2835
+ function observeMove(element, onMove) {
2836
+ let io = null;
2837
+ let timeoutId;
2838
+ const root = getDocumentElement(element);
2839
+ function cleanup() {
2840
+ var _io;
2841
+ clearTimeout(timeoutId);
2842
+ (_io = io) == null || _io.disconnect();
2843
+ io = null;
2844
+ }
2845
+ function refresh(skip, threshold) {
2846
+ if (skip === void 0) {
2847
+ skip = false;
2848
+ }
2849
+ if (threshold === void 0) {
2850
+ threshold = 1;
2851
+ }
2852
+ cleanup();
2853
+ const {
2854
+ left,
2855
+ top,
2856
+ width,
2857
+ height
2858
+ } = element.getBoundingClientRect();
2859
+ if (!skip) {
2860
+ onMove();
2861
+ }
2862
+ if (!width || !height) {
2863
+ return;
2681
2864
  }
2682
- var state = {
2683
- placement: "bottom",
2684
- orderedModifiers: [],
2685
- options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
2686
- modifiersData: {},
2687
- elements: {
2688
- reference: reference2,
2689
- popper: popper2
2690
- },
2691
- attributes: {},
2692
- styles: {}
2865
+ const insetTop = floor(top);
2866
+ const insetRight = floor(root.clientWidth - (left + width));
2867
+ const insetBottom = floor(root.clientHeight - (top + height));
2868
+ const insetLeft = floor(left);
2869
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2870
+ const options = {
2871
+ rootMargin,
2872
+ threshold: max(0, min(1, threshold)) || 1
2693
2873
  };
2694
- var effectCleanupFns = [];
2695
- var isDestroyed = false;
2696
- var instance = {
2697
- state,
2698
- setOptions: function setOptions(setOptionsAction) {
2699
- var options2 = typeof setOptionsAction === "function" ? setOptionsAction(state.options) : setOptionsAction;
2700
- cleanupModifierEffects();
2701
- state.options = Object.assign({}, defaultOptions, state.options, options2);
2702
- state.scrollParents = {
2703
- reference: isElement(reference2) ? listScrollParents(reference2) : reference2.contextElement ? listScrollParents(reference2.contextElement) : [],
2704
- popper: listScrollParents(popper2)
2705
- };
2706
- var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers2, state.options.modifiers)));
2707
- state.orderedModifiers = orderedModifiers.filter(function(m) {
2708
- return m.enabled;
2709
- });
2710
- runModifierEffects();
2711
- return instance.update();
2712
- },
2713
- // Sync update – it will always be executed, even if not necessary. This
2714
- // is useful for low frequency updates where sync behavior simplifies the
2715
- // logic.
2716
- // For high frequency updates (e.g. `resize` and `scroll` events), always
2717
- // prefer the async Popper#update method
2718
- forceUpdate: function forceUpdate() {
2719
- if (isDestroyed) {
2720
- return;
2721
- }
2722
- var _state$elements = state.elements, reference3 = _state$elements.reference, popper3 = _state$elements.popper;
2723
- if (!areValidElements(reference3, popper3)) {
2724
- return;
2874
+ let isFirstUpdate = true;
2875
+ function handleObserve(entries) {
2876
+ const ratio = entries[0].intersectionRatio;
2877
+ if (ratio !== threshold) {
2878
+ if (!isFirstUpdate) {
2879
+ return refresh();
2725
2880
  }
2726
- state.rects = {
2727
- reference: getCompositeRect(reference3, getOffsetParent(popper3), state.options.strategy === "fixed"),
2728
- popper: getLayoutRect(popper3)
2729
- };
2730
- state.reset = false;
2731
- state.placement = state.options.placement;
2732
- state.orderedModifiers.forEach(function(modifier) {
2733
- return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
2734
- });
2735
- for (var index2 = 0; index2 < state.orderedModifiers.length; index2++) {
2736
- if (state.reset === true) {
2737
- state.reset = false;
2738
- index2 = -1;
2739
- continue;
2740
- }
2741
- 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;
2742
- if (typeof fn === "function") {
2743
- state = fn({
2744
- state,
2745
- options: _options,
2746
- name,
2747
- instance
2748
- }) || state;
2749
- }
2881
+ if (!ratio) {
2882
+ timeoutId = setTimeout(() => {
2883
+ refresh(false, 1e-7);
2884
+ }, 1e3);
2885
+ } else {
2886
+ refresh(false, ratio);
2750
2887
  }
2751
- },
2752
- // Async and optimistically optimized update – it will not be executed if
2753
- // not necessary (debounced to run at most once-per-tick)
2754
- update: debounce(function() {
2755
- return new Promise(function(resolve) {
2756
- instance.forceUpdate();
2757
- resolve(state);
2758
- });
2759
- }),
2760
- destroy: function destroy() {
2761
- cleanupModifierEffects();
2762
- isDestroyed = true;
2763
2888
  }
2764
- };
2765
- if (!areValidElements(reference2, popper2)) {
2766
- return instance;
2767
- }
2768
- instance.setOptions(options).then(function(state2) {
2769
- if (!isDestroyed && options.onFirstUpdate) {
2770
- options.onFirstUpdate(state2);
2771
- }
2772
- });
2773
- function runModifierEffects() {
2774
- state.orderedModifiers.forEach(function(_ref) {
2775
- var name = _ref.name, _ref$options = _ref.options, options2 = _ref$options === void 0 ? {} : _ref$options, effect2 = _ref.effect;
2776
- if (typeof effect2 === "function") {
2777
- var cleanupFn = effect2({
2778
- state,
2779
- name,
2780
- instance,
2781
- options: options2
2782
- });
2783
- var noopFn = function noopFn2() {
2784
- };
2785
- effectCleanupFns.push(cleanupFn || noopFn);
2786
- }
2787
- });
2889
+ isFirstUpdate = false;
2788
2890
  }
2789
- function cleanupModifierEffects() {
2790
- effectCleanupFns.forEach(function(fn) {
2791
- return fn();
2891
+ try {
2892
+ io = new IntersectionObserver(handleObserve, {
2893
+ ...options,
2894
+ // Handle <iframe>s
2895
+ root: root.ownerDocument
2792
2896
  });
2793
- effectCleanupFns = [];
2897
+ } catch (e) {
2898
+ io = new IntersectionObserver(handleObserve, options);
2794
2899
  }
2795
- return instance;
2796
- };
2797
- }
2798
- var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
2799
- var createPopper = /* @__PURE__ */ popperGenerator({
2800
- defaultModifiers
2801
- });
2802
- async function deregister(obj) {
2803
- const index2 = this.collection.findIndex((entry) => {
2804
- return entry.id === obj.id;
2805
- });
2806
- if (index2 >= 0) {
2807
- const entry = this.collection[index2];
2808
- if (entry.state === "opened") {
2809
- entry.close();
2810
- }
2811
- entry.popper.destroy();
2812
- deregisterEventListeners(entry);
2813
- Object.getOwnPropertyNames(entry).forEach((prop) => {
2814
- delete entry[prop];
2815
- });
2816
- this.collection.splice(index2, 1);
2900
+ io.observe(element);
2817
2901
  }
2818
- return this.collection;
2902
+ refresh(true);
2903
+ return cleanup;
2819
2904
  }
2820
- function deregisterEventListeners(entry) {
2821
- if (entry.__eventListeners) {
2822
- entry.__eventListeners.forEach((evObj) => {
2823
- evObj.el.forEach((el) => {
2824
- evObj.type.forEach((type) => {
2825
- entry[el].removeEventListener(type, evObj.listener, false);
2905
+ function autoUpdate(reference, floating, update, options) {
2906
+ if (options === void 0) {
2907
+ options = {};
2908
+ }
2909
+ const {
2910
+ ancestorScroll = true,
2911
+ ancestorResize = true,
2912
+ elementResize = typeof ResizeObserver === "function",
2913
+ layoutShift = typeof IntersectionObserver === "function",
2914
+ animationFrame = false
2915
+ } = options;
2916
+ const referenceEl = unwrapElement(reference);
2917
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
2918
+ ancestors.forEach((ancestor) => {
2919
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
2920
+ passive: true
2921
+ });
2922
+ ancestorResize && ancestor.addEventListener("resize", update);
2923
+ });
2924
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2925
+ let reobserveFrame = -1;
2926
+ let resizeObserver = null;
2927
+ if (elementResize) {
2928
+ resizeObserver = new ResizeObserver((_ref) => {
2929
+ let [firstEntry] = _ref;
2930
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2931
+ resizeObserver.unobserve(floating);
2932
+ cancelAnimationFrame(reobserveFrame);
2933
+ reobserveFrame = requestAnimationFrame(() => {
2934
+ var _resizeObserver;
2935
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2826
2936
  });
2827
- });
2937
+ }
2938
+ update();
2828
2939
  });
2829
- delete entry.__eventListeners;
2830
- }
2831
- return entry;
2940
+ if (referenceEl && !animationFrame) {
2941
+ resizeObserver.observe(referenceEl);
2942
+ }
2943
+ resizeObserver.observe(floating);
2944
+ }
2945
+ let frameId;
2946
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2947
+ if (animationFrame) {
2948
+ frameLoop();
2949
+ }
2950
+ function frameLoop() {
2951
+ const nextRefRect = getBoundingClientRect(reference);
2952
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2953
+ update();
2954
+ }
2955
+ prevRefRect = nextRefRect;
2956
+ frameId = requestAnimationFrame(frameLoop);
2957
+ }
2958
+ update();
2959
+ return () => {
2960
+ var _resizeObserver2;
2961
+ ancestors.forEach((ancestor) => {
2962
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
2963
+ ancestorResize && ancestor.removeEventListener("resize", update);
2964
+ });
2965
+ cleanupIo == null || cleanupIo();
2966
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2967
+ resizeObserver = null;
2968
+ if (animationFrame) {
2969
+ cancelAnimationFrame(frameId);
2970
+ }
2971
+ };
2832
2972
  }
2973
+ const offset = offset$1;
2974
+ const shift = shift$1;
2975
+ const flip = flip$1;
2976
+ const arrow = arrow$1;
2977
+ const limitShift = limitShift$1;
2978
+ const computePosition = (reference, floating, options) => {
2979
+ const cache = /* @__PURE__ */ new Map();
2980
+ const mergedOptions = {
2981
+ platform,
2982
+ ...options
2983
+ };
2984
+ const platformWithCache = {
2985
+ ...mergedOptions.platform,
2986
+ _c: cache
2987
+ };
2988
+ return computePosition$1(reference, floating, {
2989
+ ...mergedOptions,
2990
+ platform: platformWithCache
2991
+ });
2992
+ };
2833
2993
  async function open(query) {
2834
2994
  const popover = getPopover.call(this, query);
2835
2995
  popover.el.inert = false;
@@ -2837,161 +2997,69 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2837
2997
  if (!popover.isTooltip) {
2838
2998
  popover.trigger.setAttribute("aria-expanded", "true");
2839
2999
  }
2840
- popover.config = getConfig(popover.el, this.settings);
2841
- popover.popper.setOptions({
2842
- placement: popover.config["placement"],
2843
- modifiers: [
2844
- { name: "eventListeners", enabled: true },
2845
- ...getModifiers(popover.config)
2846
- ]
3000
+ popover.getCustomProps();
3001
+ const middlewareOptions = getMiddlewareOptions(popover);
3002
+ const arrowEl = popover.el.querySelector(middlewareOptions.arrow.element);
3003
+ middlewareOptions.arrow.element = arrowEl ? arrowEl : void 0;
3004
+ popover.floatingCleanup = autoUpdate(popover.trigger, popover.el, () => {
3005
+ computePosition(popover.trigger, popover.el, {
3006
+ placement: popover.getSetting("placement"),
3007
+ middleware: [
3008
+ flip(middlewareOptions.flip),
3009
+ shift({ ...middlewareOptions.shift, limiter: limitShift() }),
3010
+ offset(middlewareOptions.offset),
3011
+ arrow(middlewareOptions.arrow)
3012
+ ]
3013
+ }).then(({ x, y, placement, middlewareData }) => {
3014
+ if (!popover.el) {
3015
+ return;
3016
+ }
3017
+ applyPositionStyle(popover.el, x, y);
3018
+ if (middlewareOptions.arrow.element && middlewareData.arrow) {
3019
+ const { x: x2, y: y2 } = middlewareData.arrow;
3020
+ applyPositionStyle(middlewareOptions.arrow.element, x2, y2);
3021
+ }
3022
+ popover.el.setAttribute("data-floating-placement", placement);
3023
+ });
2847
3024
  });
2848
- popover.popper.update();
2849
3025
  popover.state = "opened";
2850
- return popover;
2851
- }
2852
- async function register(el, trigger) {
2853
- deregister.call(this, el);
2854
- const root = this;
2855
- const entry = {
2856
- id: el.id,
2857
- state: "closed",
2858
- el,
2859
- trigger,
2860
- toggleDelayId: null,
2861
- popper: createPopper(trigger, el),
2862
- config: getConfig(el, this.settings),
2863
- get isTooltip() {
2864
- return !!el.closest(root.settings.selectorTooltip) || el.getAttribute("role") == "tooltip";
2865
- },
2866
- open() {
2867
- return open.call(root, this);
2868
- },
2869
- close() {
2870
- return close.call(root, this);
2871
- },
2872
- deregister() {
2873
- return deregister.call(root, this);
2874
- }
2875
- };
2876
- if (entry.isTooltip) {
2877
- entry.el.setAttribute("role", "tooltip");
2878
- }
2879
- if (!entry.isTooltip) {
2880
- entry.trigger.setAttribute("aria-expanded", "false");
2881
- }
2882
- registerEventListeners.call(this, entry);
2883
- this.collection.push(entry);
2884
- if (entry.el.classList.contains(this.settings.stateActive)) {
2885
- await entry.open();
2886
- handleDocumentClick.call(this, entry);
2887
- } else {
2888
- entry.el.inert = true;
2889
- }
2890
- entry.popper.setOptions({
2891
- placement: entry.config["placement"]
2892
- });
2893
- return entry;
2894
- }
2895
- function registerEventListeners(entry) {
2896
- if (!entry.__eventListeners) {
2897
- const eventType = entry.isTooltip ? "hover" : entry.config["event"];
2898
- if (eventType === "hover") {
2899
- entry.__eventListeners = [{
2900
- el: ["trigger"],
2901
- type: ["mouseenter", "focus"],
2902
- listener: handleMouseEnter.bind(this, entry)
2903
- }, {
2904
- el: ["el", "trigger"],
2905
- type: ["mouseleave", "focusout"],
2906
- listener: handleMouseLeave.bind(this, entry)
2907
- }];
2908
- entry.__eventListeners.forEach((evObj) => {
2909
- evObj.el.forEach((el) => {
2910
- evObj.type.forEach((type) => {
2911
- entry[el].addEventListener(type, evObj.listener, false);
2912
- });
2913
- });
2914
- });
2915
- } else {
2916
- entry.__eventListeners = [{
2917
- el: ["trigger"],
2918
- type: ["click"],
2919
- listener: handleClick.bind(this, entry)
2920
- }];
2921
- entry.__eventListeners.forEach((evObj) => {
2922
- evObj.el.forEach((el) => {
2923
- evObj.type.forEach((type) => {
2924
- entry[el].addEventListener(type, evObj.listener, false);
2925
- });
2926
- });
2927
- });
2928
- }
3026
+ if (popover.getSetting("event") === "click") {
3027
+ handleDocumentClick.call(this, popover);
2929
3028
  }
2930
- return entry;
3029
+ return popover;
2931
3030
  }
2932
3031
  class Popover extends Collection {
2933
- constructor(options) {
2934
- super();
3032
+ constructor(options = {}) {
3033
+ super({ ...defaults, ...options });
2935
3034
  __privateAdd(this, _handleKeydown3);
2936
- this.defaults = defaults;
2937
- this.settings = { ...this.defaults, ...options };
2938
3035
  this.trigger = null;
2939
3036
  __privateSet(this, _handleKeydown3, handleKeydown.bind(this));
2940
- if (this.settings.autoMount) this.mount();
2941
3037
  }
2942
3038
  get active() {
2943
- return this.collection.find((popover) => popover.state == "opened");
3039
+ return this.get("opened", "state");
2944
3040
  }
2945
- get activeTooltip() {
2946
- return this.collection.find((popover) => popover.state == "opened" && popover.isTooltip);
2947
- }
2948
- async mount(options) {
2949
- if (options) this.settings = { ...this.settings, ...options };
2950
- const popovers = document.querySelectorAll(this.settings.selectorPopover);
2951
- await this.registerCollection(popovers);
2952
- if (this.settings.eventListeners) {
2953
- this.mountEventListeners(false);
2954
- }
2955
- return this;
2956
- }
2957
- async unmount() {
2958
- this.trigger = null;
2959
- await this.deregisterCollection();
2960
- if (this.settings.eventListeners) {
2961
- this.unmountEventListeners(false);
2962
- }
2963
- return this;
3041
+ get activeHover() {
3042
+ return this.collection.find((popover) => {
3043
+ return popover.state == "opened" && popover.getSetting("event") == "hover";
3044
+ });
2964
3045
  }
2965
- mountEventListeners(processCollection = true) {
2966
- if (processCollection) {
2967
- this.collection.forEach((popover) => {
2968
- registerEventListeners.call(this, popover);
2969
- });
2970
- }
2971
- document.addEventListener("keydown", __privateGet(this, _handleKeydown3), false);
3046
+ async createEntry(query, config) {
3047
+ return new PopoverEntry(this, query, config);
2972
3048
  }
2973
- unmountEventListeners(processCollection = true) {
2974
- if (processCollection) {
2975
- this.collection.forEach((popover) => {
2976
- deregisterEventListeners(popover);
2977
- });
2978
- }
2979
- document.removeEventListener("keydown", __privateGet(this, _handleKeydown3), false);
3049
+ async open(id) {
3050
+ return open.call(this, id);
2980
3051
  }
2981
- register(query) {
2982
- const els = getPopoverElements.call(this, query);
2983
- if (els.error) return Promise.reject(els.error);
2984
- return register.call(this, els.popover, els.trigger);
3052
+ async close(id) {
3053
+ return close.call(this, id);
2985
3054
  }
2986
- deregister(query) {
2987
- let obj = this.get(query.id || query);
2988
- 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}".`));
3055
+ async afterMount() {
3056
+ document.addEventListener("keydown", __privateGet(this, _handleKeydown3), false);
2989
3057
  }
2990
- open(id) {
2991
- return open.call(this, id);
3058
+ async beforeUnmount() {
3059
+ this.trigger = null;
2992
3060
  }
2993
- close(id) {
2994
- return close.call(this, id);
3061
+ async afterUnmount() {
3062
+ document.removeEventListener("keydown", __privateGet(this, _handleKeydown3), false);
2995
3063
  }
2996
3064
  }
2997
3065
  _handleKeydown3 = new WeakMap();