vrembem 4.0.0-next.25 → 4.0.0-next.26

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,7 @@ 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, _entryPrototype, _focusable, _handleFocusTrap, _handleFocusLock, _handleClick, _handleKeydown, _handleClick2, _handleKeydown2, _handleKeydown3;
13
13
  class Breakpoint {
14
14
  constructor(value, handler) {
15
15
  __privateAdd(this, _handler);
@@ -47,8 +47,72 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
47
47
  }
48
48
  _handler = new WeakMap();
49
49
  class Collection {
50
- constructor() {
50
+ constructor(options = {}) {
51
+ __privateAdd(this, _entryPrototype);
52
+ const root = this;
53
+ this.module = this.constructor.name;
51
54
  this.collection = [];
55
+ this.settings = Object.assign({ dataConfig: "config" }, options);
56
+ __privateSet(this, _entryPrototype, {
57
+ applySettings(obj) {
58
+ return Object.assign(this.settings, obj);
59
+ },
60
+ getDataConfig() {
61
+ return Object.assign(this.dataConfig, getConfig(this.el, this.getSetting("dataConfig")));
62
+ },
63
+ getCustomProps() {
64
+ return Object.assign(this.customProps, getCustomProps(this.el, root.module, this.customPropKeys));
65
+ },
66
+ getSetting(key) {
67
+ const camel = toCamel(key);
68
+ const kebab = toKebab(key);
69
+ if ("dataConfig" in this && camel in this.dataConfig) {
70
+ return this.dataConfig[camel];
71
+ }
72
+ if ("customProps" in this && kebab in this.customProps) {
73
+ return this.customProps[kebab];
74
+ }
75
+ if ("settings" in this && camel in this.settings) {
76
+ return this.settings[camel];
77
+ }
78
+ if ("settings" in root && camel in root.settings) {
79
+ return root.settings[camel];
80
+ }
81
+ throw new Error(`${root.module} setting does not exist: ${key}`);
82
+ },
83
+ teleport(ref = this.getSetting("teleport"), method = this.getSetting("teleportMethod")) {
84
+ if (!this.returnRef) {
85
+ this.returnRef = teleport(this.el, ref, method);
86
+ return this.el;
87
+ } else {
88
+ console.error("Element has already been teleported:", this.el);
89
+ return false;
90
+ }
91
+ },
92
+ teleportReturn() {
93
+ if (this.returnRef) {
94
+ this.returnRef = teleport(this.el, this.returnRef);
95
+ return this.el;
96
+ } else {
97
+ console.error("No return reference found:", this.el);
98
+ return false;
99
+ }
100
+ }
101
+ });
102
+ }
103
+ createEntry(query, overrides = {}) {
104
+ const el = getElement(query);
105
+ const entry = Object.create(__privateGet(this, _entryPrototype));
106
+ Object.assign(entry, {
107
+ id: el == null ? void 0 : el.id,
108
+ el,
109
+ settings: {},
110
+ dataConfig: {},
111
+ customProps: {},
112
+ customPropKeys: [],
113
+ returnRef: null
114
+ }, overrides);
115
+ return entry;
52
116
  }
53
117
  async register(item) {
54
118
  await this.deregister(item);
@@ -81,11 +145,10 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
81
145
  return this.collection;
82
146
  }
83
147
  get(value, key = "id") {
84
- return this.collection.find((item) => {
85
- return item[key] === value;
86
- });
148
+ return this.collection.find((entry) => entry[key] === value);
87
149
  }
88
150
  }
151
+ _entryPrototype = new WeakMap();
89
152
  class FocusTrap {
90
153
  constructor(el = null, selectorFocus = "[data-focus]") {
91
154
  __privateAdd(this, _focusable);
@@ -215,11 +278,31 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
215
278
  }
216
279
  }
217
280
  }
218
- function getConfig$1(el, dataConfig) {
281
+ function getConfig(el, dataConfig = "config") {
219
282
  const string = el.getAttribute(`data-${dataConfig}`) || "";
220
283
  const json = string.replace(/'/g, '"');
221
284
  return json ? JSON.parse(json) : {};
222
285
  }
286
+ function getCustomProps(el, module2, array) {
287
+ const styles = getComputedStyle(el);
288
+ const result = {};
289
+ for (let i = 0; i < array.length; i++) {
290
+ const prefix = getPrefix();
291
+ const value = styles.getPropertyValue(`--${prefix}${module2.toLowerCase()}-${array[i]}`).trim();
292
+ if (value) {
293
+ result[array[i]] = value;
294
+ }
295
+ }
296
+ return result;
297
+ }
298
+ function getElement(query) {
299
+ if (typeof query === "string") {
300
+ return document.getElementById(query);
301
+ } else if (query instanceof HTMLElement) {
302
+ return query;
303
+ }
304
+ return void 0;
305
+ }
223
306
  function localStore(key, enable = true) {
224
307
  const local = localStorage.getItem(key);
225
308
  const store = local ? JSON.parse(local) : {};
@@ -323,6 +406,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
323
406
  api.callback("onInit");
324
407
  return api;
325
408
  }
409
+ function toCamel(value) {
410
+ return value.split("-").map((word, index2) => index2 === 0 ? word : word.charAt(0).toUpperCase() + word.slice(1)).join("");
411
+ }
412
+ function toKebab(value) {
413
+ return value.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
414
+ }
326
415
  function transition(el, from, to, duration = "transition-duration") {
327
416
  return new Promise((resolve) => {
328
417
  if (typeof duration === "string") {
@@ -365,9 +454,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
365
454
  });
366
455
  }
367
456
  }
368
- function updateGlobalState(state, config) {
369
- setInert(!!state, config.selectorInert);
370
- setOverflowHidden(!!state, config.selectorOverflow);
457
+ function updateGlobalState(state, selectorInert, selectorOverflow) {
458
+ setInert(!!state, selectorInert);
459
+ setOverflowHidden(!!state, selectorOverflow);
371
460
  }
372
461
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
373
462
  __proto__: null,
@@ -375,22 +464,24 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
375
464
  Collection,
376
465
  FocusTrap,
377
466
  cssVar,
378
- getConfig: getConfig$1,
467
+ getConfig,
468
+ getCustomProps,
469
+ getElement,
379
470
  getPrefix,
380
471
  localStore,
381
472
  teleport,
382
473
  themeStore,
474
+ toCamel,
475
+ toKebab,
383
476
  transition,
384
477
  updateGlobalState
385
478
  }, Symbol.toStringTag, { value: "Module" }));
386
479
  const defaults$2 = {
387
- autoMount: false,
388
480
  // Data attributes
389
481
  dataOpen: "drawer-open",
390
482
  dataClose: "drawer-close",
391
483
  dataToggle: "drawer-toggle",
392
484
  dataBreakpoint: "drawer-breakpoint",
393
- dataConfig: "drawer-config",
394
485
  // Selectors
395
486
  selectorDrawer: ".drawer",
396
487
  selectorDialog: ".drawer__dialog",
@@ -412,6 +503,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
412
503
  store: true,
413
504
  storeKey: "VB:DrawerState",
414
505
  setTabindex: true,
506
+ teleport: null,
507
+ teleportMethod: "prepend",
415
508
  transition: true,
416
509
  transitionDuration: "drawer-transition-duration"
417
510
  };
@@ -552,61 +645,57 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
552
645
  }
553
646
  return this.collection;
554
647
  }
555
- async function open$2(query, enableTransition, focus = true) {
648
+ async function open$2(query, transitionOverride, focus = true) {
556
649
  const entry = getDrawer.call(this, query);
557
- const config = { ...this.settings, ...entry.settings };
558
- if (enableTransition !== void 0) config.transition = enableTransition;
559
650
  if (entry.state === "closed" || entry.state === "indeterminate") {
560
651
  entry.state = "opening";
561
- if (config.transition) {
652
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
562
653
  await transition(entry.el, {
563
- start: config.stateClosing,
564
- finish: config.stateClosed
654
+ start: entry.getSetting("stateClosing"),
655
+ finish: entry.getSetting("stateClosed")
565
656
  }, {
566
- start: config.stateOpening,
567
- finish: config.stateOpened
568
- }, config.transitionDuration);
657
+ start: entry.getSetting("stateOpening"),
658
+ finish: entry.getSetting("stateOpened")
659
+ }, entry.getSetting("transitionDuration"));
569
660
  } else {
570
- entry.el.classList.add(config.stateOpened);
571
- entry.el.classList.remove(config.stateClosed);
661
+ entry.el.classList.add(entry.getSetting("stateOpened"));
662
+ entry.el.classList.remove(entry.getSetting("stateClosed"));
572
663
  }
573
664
  entry.state = "opened";
574
- if (entry.mode === "modal") updateGlobalState(true, config);
665
+ if (entry.mode === "modal") updateGlobalState(true, entry.getSetting("selectorInert"), entry.getSetting("selectorOverflow"));
575
666
  if (focus) {
576
667
  updateFocusState$1.call(this, entry);
577
668
  }
578
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
669
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "opened", {
579
670
  detail: this,
580
671
  bubbles: true
581
672
  }));
582
673
  }
583
674
  return entry;
584
675
  }
585
- async function close$2(query, enableTransition, focus = true) {
676
+ async function close$2(query, transitionOverride, focus = true) {
586
677
  const entry = getDrawer.call(this, query);
587
- const config = { ...this.settings, ...entry.settings };
588
- if (enableTransition !== void 0) config.transition = enableTransition;
589
678
  if (entry.state === "opened" || entry.state === "indeterminate") {
590
679
  entry.state = "closing";
591
680
  document.activeElement.blur();
592
- if (config.transition) {
681
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
593
682
  await transition(entry.el, {
594
- start: config.stateOpening,
595
- finish: config.stateOpened
683
+ start: entry.getSetting("stateOpening"),
684
+ finish: entry.getSetting("stateOpened")
596
685
  }, {
597
- start: config.stateClosing,
598
- finish: config.stateClosed
599
- }, config.transitionDuration);
686
+ start: entry.getSetting("stateClosing"),
687
+ finish: entry.getSetting("stateClosed")
688
+ }, entry.getSetting("transitionDuration"));
600
689
  } else {
601
- entry.el.classList.add(config.stateClosed);
602
- entry.el.classList.remove(config.stateOpened);
690
+ entry.el.classList.add(entry.getSetting("stateClosed"));
691
+ entry.el.classList.remove(entry.getSetting("stateOpened"));
603
692
  }
604
693
  entry.state = "closed";
605
- if (entry.mode === "modal") updateGlobalState(false, config);
694
+ if (entry.mode === "modal") updateGlobalState(false, entry.getSetting("selectorInert"), entry.getSetting("selectorOverflow"));
606
695
  if (focus) {
607
696
  updateFocusState$1.call(this, entry);
608
697
  }
609
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
698
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "closed", {
610
699
  detail: this,
611
700
  bubbles: true
612
701
  }));
@@ -634,7 +723,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
634
723
  async function toInline(entry) {
635
724
  entry.el.classList.remove(entry.getSetting("classModal"));
636
725
  entry.dialog.removeAttribute("aria-modal");
637
- updateGlobalState(false, { ...this.settings, ...entry.settings });
726
+ updateGlobalState(false, entry.getSetting("selectorInert"), entry.getSetting("selectorOverflow"));
638
727
  this.focusTrap.unmount();
639
728
  await applyInlineState(entry);
640
729
  entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "switchMode", {
@@ -658,13 +747,42 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
658
747
  const root = this;
659
748
  const breakpoint = new Breakpoint();
660
749
  let _mode, _state = "indeterminate";
661
- const entry = {
662
- id: el.id,
663
- el,
750
+ const entry = this.createEntry(el);
751
+ Object.assign(entry, {
664
752
  dialog: null,
665
753
  trigger: null,
666
- settings: { ...getConfig$1(el, this.settings.dataConfig), ...config },
667
754
  inlineState: "indeterminate",
755
+ open(transition2, focus) {
756
+ return open$2.call(root, this, transition2, focus);
757
+ },
758
+ close(transition2, focus) {
759
+ return close$2.call(root, this, transition2, focus);
760
+ },
761
+ toggle(transition2, focus) {
762
+ return toggle.call(root, this, transition2, focus);
763
+ },
764
+ deregister() {
765
+ return deregister$2.call(root, this);
766
+ },
767
+ mountBreakpoint() {
768
+ const value = this.breakpoint;
769
+ const handler = this.handleBreakpoint.bind(this);
770
+ breakpoint.mount(value, handler);
771
+ return this;
772
+ },
773
+ unmountBreakpoint() {
774
+ breakpoint.unmount();
775
+ return this;
776
+ },
777
+ handleBreakpoint(event) {
778
+ const bpMode = event.matches ? "inline" : "modal";
779
+ if (this.mode != bpMode) {
780
+ this.mode = bpMode;
781
+ }
782
+ return this;
783
+ }
784
+ });
785
+ Object.defineProperties(entry, Object.getOwnPropertyDescriptors({
668
786
  get breakpoint() {
669
787
  return getBreakpoint.call(root, el);
670
788
  },
@@ -695,47 +813,20 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
695
813
  this.el.classList.remove(this.getSetting("stateClosed"));
696
814
  this.el.classList.remove(this.getSetting("stateClosing"));
697
815
  }
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
816
  }
731
- };
817
+ }));
818
+ entry.applySettings(config);
819
+ entry.getDataConfig();
820
+ if (entry.getSetting("teleport")) {
821
+ entry.teleport();
822
+ }
732
823
  this.collection.push(entry);
733
824
  const dialog = el.querySelector(entry.getSetting("selectorDialog"));
734
825
  entry.dialog = dialog ? dialog : el;
735
826
  if (entry.getSetting("setTabindex")) {
736
827
  entry.dialog.setAttribute("tabindex", "-1");
737
828
  }
738
- await applyInitialState(entry);
829
+ applyInitialState(entry);
739
830
  entry.inlineState = entry.state;
740
831
  entry.mode = el.classList.contains(entry.getSetting("classModal")) ? "modal" : "inline";
741
832
  if (entry.breakpoint) {
@@ -745,16 +836,13 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
745
836
  }
746
837
  class Drawer extends Collection {
747
838
  constructor(options) {
748
- super();
839
+ super({ ...defaults$2, ...options });
749
840
  __privateAdd(this, _handleClick);
750
841
  __privateAdd(this, _handleKeydown);
751
- this.defaults = defaults$2;
752
- this.settings = { ...this.defaults, ...options };
753
842
  this.focusTrap = new FocusTrap();
754
843
  this.store = localStore(this.settings.storeKey, this.settings.store);
755
844
  __privateSet(this, _handleClick, handleClick$2.bind(this));
756
845
  __privateSet(this, _handleKeydown, handleKeydown$2.bind(this));
757
- if (this.settings.autoMount) this.mount();
758
846
  }
759
847
  get activeModal() {
760
848
  return this.collection.find((entry) => {
@@ -806,12 +894,10 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
806
894
  _handleClick = new WeakMap();
807
895
  _handleKeydown = new WeakMap();
808
896
  const defaults$1 = {
809
- autoMount: false,
810
897
  // Data attributes
811
898
  dataOpen: "modal-open",
812
899
  dataClose: "modal-close",
813
900
  dataReplace: "modal-replace",
814
- dataConfig: "modal-config",
815
901
  // Selectors
816
902
  selectorModal: ".modal",
817
903
  selectorDialog: ".modal__dialog",
@@ -828,9 +914,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
828
914
  // Feature settings
829
915
  customEventPrefix: "modal:",
830
916
  eventListeners: true,
917
+ setTabindex: true,
831
918
  teleport: null,
832
919
  teleportMethod: "append",
833
- setTabindex: true,
834
920
  transition: true,
835
921
  transitionDuration: "modal-transition-duration"
836
922
  };
@@ -880,7 +966,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
880
966
  return selector === "*" ? this.closeAll() : this.close(selector);
881
967
  }
882
968
  }
883
- if (this.active && event.target.matches(this.settings.selectorScreen) && !this.active.required) {
969
+ if (this.active && event.target.matches(this.settings.selectorScreen) && !this.active.isRequired) {
884
970
  return this.close(this.active.id);
885
971
  }
886
972
  }
@@ -912,62 +998,58 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
912
998
  }
913
999
  return this.collection;
914
1000
  }
915
- async function open$1(query, enableTransition, focus = true) {
1001
+ async function open$1(query, transitionOverride = void 0, focus = true) {
916
1002
  const entry = getModal.call(this, query);
917
- const config = { ...this.settings, ...entry.settings };
918
- if (enableTransition !== void 0) config.transition = enableTransition;
919
1003
  this.stack.moveToTop(entry);
920
1004
  if (entry.state === "closed") {
921
1005
  entry.state = "opening";
922
1006
  this.stack.add(entry);
923
- if (config.transition) {
1007
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
924
1008
  await transition(entry.el, {
925
- start: config.stateClosing,
926
- finish: config.stateClosed
1009
+ start: entry.getSetting("stateClosing"),
1010
+ finish: entry.getSetting("stateClosed")
927
1011
  }, {
928
- start: config.stateOpening,
929
- finish: config.stateOpened
930
- }, config.transitionDuration);
1012
+ start: entry.getSetting("stateOpening"),
1013
+ finish: entry.getSetting("stateOpened")
1014
+ }, entry.getSetting("transitionDuration"));
931
1015
  } else {
932
- entry.el.classList.add(config.stateOpened);
933
- entry.el.classList.remove(config.stateClosed);
1016
+ entry.el.classList.add(entry.getSetting("stateOpened"));
1017
+ entry.el.classList.remove(entry.getSetting("stateClosed"));
934
1018
  }
935
1019
  entry.state = "opened";
936
1020
  }
937
1021
  if (focus) {
938
1022
  updateFocusState.call(this);
939
1023
  }
940
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "opened", {
1024
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "opened", {
941
1025
  detail: this,
942
1026
  bubbles: true
943
1027
  }));
944
1028
  return entry;
945
1029
  }
946
- async function close$1(query, enableTransition, focus = true) {
1030
+ async function close$1(query, transitionOverride, focus = true) {
947
1031
  const entry = query ? getModal.call(this, query) : this.active;
948
1032
  if (entry && entry.state === "opened") {
949
1033
  entry.state = "closing";
950
- const config = { ...this.settings, ...entry.settings };
951
- if (enableTransition !== void 0) config.transition = enableTransition;
952
1034
  document.activeElement.blur();
953
- if (config.transition) {
1035
+ if (transitionOverride != void 0 ? transitionOverride : entry.getSetting("transition")) {
954
1036
  await transition(entry.el, {
955
- start: config.stateOpening,
956
- finish: config.stateOpened
1037
+ start: entry.getSetting("stateOpening"),
1038
+ finish: entry.getSetting("stateOpened")
957
1039
  }, {
958
- start: config.stateClosing,
959
- finish: config.stateClosed
960
- }, config.transitionDuration);
1040
+ start: entry.getSetting("stateClosing"),
1041
+ finish: entry.getSetting("stateClosed")
1042
+ }, entry.getSetting("transitionDuration"));
961
1043
  } else {
962
- entry.el.classList.add(config.stateClosed);
963
- entry.el.classList.remove(config.stateOpened);
1044
+ entry.el.classList.add(entry.getSetting("stateClosed"));
1045
+ entry.el.classList.remove(entry.getSetting("stateOpened"));
964
1046
  }
965
1047
  this.stack.remove(entry);
966
1048
  entry.state = "closed";
967
1049
  if (focus) {
968
1050
  updateFocusState.call(this);
969
1051
  }
970
- entry.el.dispatchEvent(new CustomEvent(config.customEventPrefix + "closed", {
1052
+ entry.el.dispatchEvent(new CustomEvent(entry.getSetting("customEventPrefix") + "closed", {
971
1053
  detail: this,
972
1054
  bubbles: true
973
1055
  }));
@@ -1005,16 +1087,10 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1005
1087
  async function register$1(el, config = {}) {
1006
1088
  await deregister$1.call(this, el, false);
1007
1089
  const root = this;
1008
- const entry = {
1009
- id: el.id,
1090
+ const entry = this.createEntry(el);
1091
+ Object.assign(entry, {
1010
1092
  state: "closed",
1011
- el,
1012
1093
  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
1094
  open(transition2, focus) {
1019
1095
  return open$1.call(root, this, transition2, focus);
1020
1096
  },
@@ -1026,29 +1102,15 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1026
1102
  },
1027
1103
  deregister() {
1028
1104
  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
1105
  }
1051
- };
1106
+ });
1107
+ Object.defineProperties(entry, Object.getOwnPropertyDescriptors({
1108
+ get isRequired() {
1109
+ return this.dialog.matches(this.getSetting("selectorRequired"));
1110
+ }
1111
+ }));
1112
+ entry.applySettings(config);
1113
+ entry.getDataConfig();
1052
1114
  const dialog = el.querySelector(entry.getSetting("selectorDialog"));
1053
1115
  entry.dialog = dialog ? dialog : el;
1054
1116
  entry.dialog.setAttribute("aria-modal", "true");
@@ -1062,12 +1124,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1062
1124
  entry.teleport();
1063
1125
  }
1064
1126
  this.collection.push(entry);
1065
- if (entry.el.classList.contains(this.settings.stateOpened)) {
1127
+ if (entry.el.classList.contains(entry.getSetting("stateOpened"))) {
1066
1128
  await entry.open(false);
1067
1129
  } 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);
1130
+ entry.el.classList.remove(entry.getSetting("stateOpening"));
1131
+ entry.el.classList.remove(entry.getSetting("stateClosing"));
1132
+ entry.el.classList.add(entry.getSetting("stateClosed"));
1071
1133
  }
1072
1134
  return entry;
1073
1135
  }
@@ -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) => {
@@ -1088,7 +1151,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1088
1151
  });
1089
1152
  },
1090
1153
  updateGlobalState() {
1091
- updateGlobalState(this.top, settings);
1154
+ updateGlobalState(this.top, settings.selectorInert, settings.selectorOverflow);
1092
1155
  this.updateIndex();
1093
1156
  },
1094
1157
  add(entry) {
@@ -1121,17 +1184,14 @@ 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
1192
  this.stack = stack(this.settings);
1132
1193
  __privateSet(this, _handleClick2, handleClick$1.bind(this));
1133
1194
  __privateSet(this, _handleKeydown2, handleKeydown$1.bind(this));
1134
- if (this.settings.autoMount) this.mount();
1135
1195
  }
1136
1196
  get active() {
1137
1197
  return this.stack.top;
@@ -1189,46 +1249,57 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1189
1249
  _handleClick2 = new WeakMap();
1190
1250
  _handleKeydown2 = new WeakMap();
1191
1251
  const defaults = {
1192
- autoMount: false,
1193
1252
  // Selectors
1194
1253
  selectorPopover: ".popover",
1195
1254
  selectorTooltip: ".popover_tooltip",
1196
1255
  selectorArrow: ".popover__arrow",
1197
1256
  // State classes
1198
1257
  stateActive: "is-active",
1258
+ // Custom property defaults
1259
+ placement: "bottom",
1260
+ event: "click",
1261
+ offset: 0,
1262
+ flipPadding: 0,
1263
+ shiftPadding: 0,
1264
+ arrowPadding: 0,
1265
+ toggleDelay: 0,
1199
1266
  // Feature settings
1200
1267
  eventListeners: true,
1201
- eventType: "click",
1202
- placement: "bottom",
1203
- hoverToggleDelay: 0
1268
+ teleport: null,
1269
+ teleportMethod: "append"
1204
1270
  };
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;
1271
+ function applyPositionStyle(el, x, y) {
1272
+ Object.assign(el.style, {
1273
+ left: x != null ? `${x}px` : "",
1274
+ top: y != null ? `${y}px` : ""
1275
+ });
1276
+ }
1277
+ function getDelay(popover, index2) {
1278
+ let value = popover.getSetting("toggle-delay");
1279
+ if (typeof value == "string") {
1280
+ if (value.indexOf(",") > -1) {
1281
+ value = value.split(",");
1222
1282
  }
1283
+ if (value.indexOf(" ") > -1) {
1284
+ value = value.split(" ");
1285
+ }
1286
+ }
1287
+ if (Array.isArray(value)) {
1288
+ value = value[index2];
1289
+ }
1290
+ const number = Number(value);
1291
+ if (!Number.isNaN(number)) {
1292
+ return number;
1293
+ } else {
1294
+ throw new Error(`Provided delay value is not a number: "${value}"`);
1223
1295
  }
1224
- return config;
1225
1296
  }
1226
1297
  function getPadding(value) {
1227
1298
  let padding;
1228
1299
  const array = typeof value === "string" ? value.trim().split(" ") : [value];
1229
- array.forEach(function(item, index2) {
1230
- array[index2] = parseInt(item, 10);
1231
- });
1300
+ for (let index2 = 0; index2 < array.length; index2++) {
1301
+ array[index2] = Number(array[index2]);
1302
+ }
1232
1303
  switch (array.length) {
1233
1304
  case 1:
1234
1305
  padding = array[0];
@@ -1263,29 +1334,20 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1263
1334
  }
1264
1335
  return padding;
1265
1336
  }
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"])
1337
+ function getMiddlewareOptions(popover) {
1338
+ return {
1339
+ offset: Number(popover.getSetting("offset")),
1340
+ flip: {
1341
+ padding: getPadding(popover.getSetting("flip-padding"))
1342
+ },
1343
+ shift: {
1344
+ padding: getPadding(popover.getSetting("shift-padding"))
1345
+ },
1346
+ arrow: {
1347
+ element: popover.getSetting("selectorArrow"),
1348
+ padding: getPadding(popover.getSetting("arrow-padding"))
1287
1349
  }
1288
- }];
1350
+ };
1289
1351
  }
1290
1352
  function getPopover(query) {
1291
1353
  const entry = typeof query === "string" ? this.get(query) : this.get(query.id);
@@ -1335,13 +1397,7 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1335
1397
  if (!popover.isTooltip) {
1336
1398
  popover.trigger.setAttribute("aria-expanded", "false");
1337
1399
  }
1338
- popover.popper.setOptions({
1339
- placement: popover.config["placement"],
1340
- modifiers: [
1341
- { name: "eventListeners", enabled: false },
1342
- ...getModifiers(popover.config)
1343
- ]
1344
- });
1400
+ popover.cleanup();
1345
1401
  popover.state = "closed";
1346
1402
  if (popover.trigger === this.trigger) {
1347
1403
  this.trigger = null;
@@ -1373,16 +1429,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1373
1429
  }, 1);
1374
1430
  }
1375
1431
  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
1432
  if (popover.state === "opened") {
1387
1433
  popover.close();
1388
1434
  } else {
@@ -1391,30 +1437,41 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1391
1437
  handleDocumentClick.call(this, popover);
1392
1438
  }
1393
1439
  }
1440
+ function handleTooltipClick(popover) {
1441
+ if (popover.isTooltip) {
1442
+ if (popover.toggleDelayId) {
1443
+ clearTimeout(popover.toggleDelayId);
1444
+ }
1445
+ popover.close();
1446
+ }
1447
+ }
1394
1448
  function handleMouseEnter(popover, event) {
1449
+ popover.isHovered = event;
1395
1450
  if (event.type == "focus" && !popover.trigger.matches(":focus-visible")) {
1396
1451
  return;
1397
1452
  }
1398
- const isExpanded = popover.trigger.getAttribute("aria-expanded");
1399
- if (isExpanded && isExpanded == "true") {
1400
- return;
1401
- }
1402
1453
  if (popover.toggleDelayId) {
1403
1454
  clearTimeout(popover.toggleDelayId);
1404
1455
  }
1405
- const delay = this.activeTooltip ? 0 : popover.config["toggle-delay"];
1406
- if (this.activeTooltip) this.activeTooltip.close();
1456
+ const isExpanded = popover.trigger.getAttribute("aria-expanded");
1457
+ if (isExpanded && isExpanded == "true") return;
1458
+ const delay = this.activeHover ? 0 : getDelay(popover, 0);
1459
+ if (this.activeHover) this.activeHover.close();
1407
1460
  popover.toggleDelayId = setTimeout(() => {
1408
1461
  if (popover.id) popover.open();
1409
1462
  }, delay);
1410
1463
  }
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"]);
1464
+ function handleMouseLeave(popover, event) {
1465
+ setTimeout(() => {
1466
+ popover.isHovered = event;
1467
+ if (popover.isHovered) return;
1468
+ if (popover.toggleDelayId) {
1469
+ clearTimeout(popover.toggleDelayId);
1470
+ }
1471
+ popover.toggleDelayId = setTimeout(() => {
1472
+ closeCheck.call(this, popover);
1473
+ }, getDelay(popover, 1));
1474
+ }, 1);
1418
1475
  }
1419
1476
  function handleKeydown(event) {
1420
1477
  switch (event.key) {
@@ -1451,567 +1508,1072 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
1451
1508
  }
1452
1509
  });
1453
1510
  }
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;
1488
- }
1489
- if (node.toString() !== "[object Window]") {
1490
- var ownerDocument = node.ownerDocument;
1491
- return ownerDocument ? ownerDocument.defaultView || window : window;
1492
- }
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;
1506
- }
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;
1511
+ async function deregister(obj) {
1512
+ const index2 = this.collection.findIndex((entry) => {
1513
+ return entry.id === obj.id;
1514
+ });
1515
+ if (index2 >= 0) {
1516
+ const entry = this.collection[index2];
1517
+ if (entry.state === "opened") {
1518
+ entry.close();
1518
1519
  }
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);
1524
- } else {
1525
- element.setAttribute(name2, value === true ? "" : value);
1526
- }
1520
+ entry.cleanup();
1521
+ deregisterEventListeners(entry);
1522
+ if (entry.getSetting("teleport")) {
1523
+ entry.teleportReturn();
1524
+ }
1525
+ Object.getOwnPropertyNames(entry).forEach((prop) => {
1526
+ delete entry[prop];
1527
1527
  });
1528
- });
1528
+ this.collection.splice(index2, 1);
1529
+ }
1530
+ return this.collection;
1529
1531
  }
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;
1560
- }
1561
- Object.assign(element.style, style);
1562
- Object.keys(attributes).forEach(function(attribute) {
1563
- element.removeAttribute(attribute);
1532
+ function deregisterEventListeners(entry) {
1533
+ if (entry._eventListeners) {
1534
+ entry._eventListeners.forEach((evObj) => {
1535
+ evObj.el.forEach((el) => {
1536
+ evObj.type.forEach((type) => {
1537
+ entry[el].removeEventListener(type, evObj.listener, false);
1538
+ });
1564
1539
  });
1565
1540
  });
1566
- };
1541
+ delete entry._eventListeners;
1542
+ }
1543
+ return entry;
1567
1544
  }
1568
- const applyStyles$1 = {
1569
- name: "applyStyles",
1570
- enabled: true,
1571
- phase: "write",
1572
- fn: applyStyles,
1573
- effect: effect$2,
1574
- requires: ["computeStyles"]
1545
+ const min = Math.min;
1546
+ const max = Math.max;
1547
+ const round = Math.round;
1548
+ const floor = Math.floor;
1549
+ const createCoords = (v) => ({
1550
+ x: v,
1551
+ y: v
1552
+ });
1553
+ const oppositeSideMap = {
1554
+ left: "right",
1555
+ right: "left",
1556
+ bottom: "top",
1557
+ top: "bottom"
1558
+ };
1559
+ const oppositeAlignmentMap = {
1560
+ start: "end",
1561
+ end: "start"
1575
1562
  };
1576
- function getBasePlacement(placement) {
1563
+ function clamp(start, value, end) {
1564
+ return max(start, min(value, end));
1565
+ }
1566
+ function evaluate(value, param) {
1567
+ return typeof value === "function" ? value(param) : value;
1568
+ }
1569
+ function getSide(placement) {
1577
1570
  return placement.split("-")[0];
1578
1571
  }
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;
1572
+ function getAlignment(placement) {
1573
+ return placement.split("-")[1];
1590
1574
  }
1591
- function isLayoutViewport() {
1592
- return !/^((?!chrome|android).)*safari/i.test(getUAString());
1575
+ function getOppositeAxis(axis) {
1576
+ return axis === "x" ? "y" : "x";
1593
1577
  }
1594
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1595
- if (includeScale === void 0) {
1596
- includeScale = false;
1578
+ function getAxisLength(axis) {
1579
+ return axis === "y" ? "height" : "width";
1580
+ }
1581
+ function getSideAxis(placement) {
1582
+ return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
1583
+ }
1584
+ function getAlignmentAxis(placement) {
1585
+ return getOppositeAxis(getSideAxis(placement));
1586
+ }
1587
+ function getAlignmentSides(placement, rects, rtl) {
1588
+ if (rtl === void 0) {
1589
+ rtl = false;
1590
+ }
1591
+ const alignment = getAlignment(placement);
1592
+ const alignmentAxis = getAlignmentAxis(placement);
1593
+ const length = getAxisLength(alignmentAxis);
1594
+ let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
1595
+ if (rects.reference[length] > rects.floating[length]) {
1596
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1597
+ }
1598
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1599
+ }
1600
+ function getExpandedPlacements(placement) {
1601
+ const oppositePlacement = getOppositePlacement(placement);
1602
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1603
+ }
1604
+ function getOppositeAlignmentPlacement(placement) {
1605
+ return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
1606
+ }
1607
+ function getSideList(side, isStart, rtl) {
1608
+ const lr = ["left", "right"];
1609
+ const rl = ["right", "left"];
1610
+ const tb = ["top", "bottom"];
1611
+ const bt = ["bottom", "top"];
1612
+ switch (side) {
1613
+ case "top":
1614
+ case "bottom":
1615
+ if (rtl) return isStart ? rl : lr;
1616
+ return isStart ? lr : rl;
1617
+ case "left":
1618
+ case "right":
1619
+ return isStart ? tb : bt;
1620
+ default:
1621
+ return [];
1597
1622
  }
1598
- if (isFixedStrategy === void 0) {
1599
- isFixedStrategy = false;
1623
+ }
1624
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1625
+ const alignment = getAlignment(placement);
1626
+ let list = getSideList(getSide(placement), direction === "start", rtl);
1627
+ if (alignment) {
1628
+ list = list.map((side) => side + "-" + alignment);
1629
+ if (flipAlignment) {
1630
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
1631
+ }
1600
1632
  }
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;
1633
+ return list;
1634
+ }
1635
+ function getOppositePlacement(placement) {
1636
+ return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
1637
+ }
1638
+ function expandPaddingObject(padding) {
1639
+ return {
1640
+ top: 0,
1641
+ right: 0,
1642
+ bottom: 0,
1643
+ left: 0,
1644
+ ...padding
1645
+ };
1646
+ }
1647
+ function getPaddingObject(padding) {
1648
+ return typeof padding !== "number" ? expandPaddingObject(padding) : {
1649
+ top: padding,
1650
+ right: padding,
1651
+ bottom: padding,
1652
+ left: padding
1653
+ };
1654
+ }
1655
+ function rectToClientRect(rect) {
1656
+ const {
1657
+ x,
1658
+ y,
1659
+ width,
1660
+ height
1661
+ } = rect;
1614
1662
  return {
1615
1663
  width,
1616
1664
  height,
1617
1665
  top: y,
1666
+ left: x,
1618
1667
  right: x + width,
1619
1668
  bottom: y + height,
1620
- left: x,
1621
1669
  x,
1622
1670
  y
1623
1671
  };
1624
1672
  }
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;
1673
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1674
+ let {
1675
+ reference,
1676
+ floating
1677
+ } = _ref;
1678
+ const sideAxis = getSideAxis(placement);
1679
+ const alignmentAxis = getAlignmentAxis(placement);
1680
+ const alignLength = getAxisLength(alignmentAxis);
1681
+ const side = getSide(placement);
1682
+ const isVertical = sideAxis === "y";
1683
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1684
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1685
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1686
+ let coords;
1687
+ switch (side) {
1688
+ case "top":
1689
+ coords = {
1690
+ x: commonX,
1691
+ y: reference.y - floating.height
1692
+ };
1693
+ break;
1694
+ case "bottom":
1695
+ coords = {
1696
+ x: commonX,
1697
+ y: reference.y + reference.height
1698
+ };
1699
+ break;
1700
+ case "right":
1701
+ coords = {
1702
+ x: reference.x + reference.width,
1703
+ y: commonY
1704
+ };
1705
+ break;
1706
+ case "left":
1707
+ coords = {
1708
+ x: reference.x - floating.width,
1709
+ y: commonY
1710
+ };
1711
+ break;
1712
+ default:
1713
+ coords = {
1714
+ x: reference.x,
1715
+ y: reference.y
1716
+ };
1631
1717
  }
1632
- if (Math.abs(clientRect.height - height) <= 1) {
1633
- height = clientRect.height;
1718
+ switch (getAlignment(placement)) {
1719
+ case "start":
1720
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1721
+ break;
1722
+ case "end":
1723
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1724
+ break;
1634
1725
  }
1635
- return {
1636
- x: element.offsetLeft,
1637
- y: element.offsetTop,
1638
- width,
1639
- height
1726
+ return coords;
1727
+ }
1728
+ const computePosition$1 = async (reference, floating, config) => {
1729
+ const {
1730
+ placement = "bottom",
1731
+ strategy = "absolute",
1732
+ middleware = [],
1733
+ platform: platform2
1734
+ } = config;
1735
+ const validMiddleware = middleware.filter(Boolean);
1736
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
1737
+ let rects = await platform2.getElementRects({
1738
+ reference,
1739
+ floating,
1740
+ strategy
1741
+ });
1742
+ let {
1743
+ x,
1744
+ y
1745
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1746
+ let statefulPlacement = placement;
1747
+ let middlewareData = {};
1748
+ let resetCount = 0;
1749
+ for (let i = 0; i < validMiddleware.length; i++) {
1750
+ const {
1751
+ name,
1752
+ fn
1753
+ } = validMiddleware[i];
1754
+ const {
1755
+ x: nextX,
1756
+ y: nextY,
1757
+ data,
1758
+ reset
1759
+ } = await fn({
1760
+ x,
1761
+ y,
1762
+ initialPlacement: placement,
1763
+ placement: statefulPlacement,
1764
+ strategy,
1765
+ middlewareData,
1766
+ rects,
1767
+ platform: platform2,
1768
+ elements: {
1769
+ reference,
1770
+ floating
1771
+ }
1772
+ });
1773
+ x = nextX != null ? nextX : x;
1774
+ y = nextY != null ? nextY : y;
1775
+ middlewareData = {
1776
+ ...middlewareData,
1777
+ [name]: {
1778
+ ...middlewareData[name],
1779
+ ...data
1780
+ }
1781
+ };
1782
+ if (reset && resetCount <= 50) {
1783
+ resetCount++;
1784
+ if (typeof reset === "object") {
1785
+ if (reset.placement) {
1786
+ statefulPlacement = reset.placement;
1787
+ }
1788
+ if (reset.rects) {
1789
+ rects = reset.rects === true ? await platform2.getElementRects({
1790
+ reference,
1791
+ floating,
1792
+ strategy
1793
+ }) : reset.rects;
1794
+ }
1795
+ ({
1796
+ x,
1797
+ y
1798
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1799
+ }
1800
+ i = -1;
1801
+ }
1802
+ }
1803
+ return {
1804
+ x,
1805
+ y,
1806
+ placement: statefulPlacement,
1807
+ strategy,
1808
+ middlewareData
1809
+ };
1810
+ };
1811
+ async function detectOverflow(state, options) {
1812
+ var _await$platform$isEle;
1813
+ if (options === void 0) {
1814
+ options = {};
1815
+ }
1816
+ const {
1817
+ x,
1818
+ y,
1819
+ platform: platform2,
1820
+ rects,
1821
+ elements,
1822
+ strategy
1823
+ } = state;
1824
+ const {
1825
+ boundary = "clippingAncestors",
1826
+ rootBoundary = "viewport",
1827
+ elementContext = "floating",
1828
+ altBoundary = false,
1829
+ padding = 0
1830
+ } = evaluate(options, state);
1831
+ const paddingObject = getPaddingObject(padding);
1832
+ const altContext = elementContext === "floating" ? "reference" : "floating";
1833
+ const element = elements[altBoundary ? altContext : elementContext];
1834
+ const clippingClientRect = rectToClientRect(await platform2.getClippingRect({
1835
+ 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)),
1836
+ boundary,
1837
+ rootBoundary,
1838
+ strategy
1839
+ }));
1840
+ const rect = elementContext === "floating" ? {
1841
+ x,
1842
+ y,
1843
+ width: rects.floating.width,
1844
+ height: rects.floating.height
1845
+ } : rects.reference;
1846
+ const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
1847
+ const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
1848
+ x: 1,
1849
+ y: 1
1850
+ } : {
1851
+ x: 1,
1852
+ y: 1
1853
+ };
1854
+ const elementClientRect = rectToClientRect(platform2.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
1855
+ elements,
1856
+ rect,
1857
+ offsetParent,
1858
+ strategy
1859
+ }) : rect);
1860
+ return {
1861
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1862
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1863
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1864
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1640
1865
  };
1641
1866
  }
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;
1867
+ const arrow$1 = (options) => ({
1868
+ name: "arrow",
1869
+ options,
1870
+ async fn(state) {
1871
+ const {
1872
+ x,
1873
+ y,
1874
+ placement,
1875
+ rects,
1876
+ platform: platform2,
1877
+ elements,
1878
+ middlewareData
1879
+ } = state;
1880
+ const {
1881
+ element,
1882
+ padding = 0
1883
+ } = evaluate(options, state) || {};
1884
+ if (element == null) {
1885
+ return {};
1886
+ }
1887
+ const paddingObject = getPaddingObject(padding);
1888
+ const coords = {
1889
+ x,
1890
+ y
1891
+ };
1892
+ const axis = getAlignmentAxis(placement);
1893
+ const length = getAxisLength(axis);
1894
+ const arrowDimensions = await platform2.getDimensions(element);
1895
+ const isYAxis = axis === "y";
1896
+ const minProp = isYAxis ? "top" : "left";
1897
+ const maxProp = isYAxis ? "bottom" : "right";
1898
+ const clientProp = isYAxis ? "clientHeight" : "clientWidth";
1899
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1900
+ const startDiff = coords[axis] - rects.reference[axis];
1901
+ const arrowOffsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(element));
1902
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1903
+ if (!clientSize || !await (platform2.isElement == null ? void 0 : platform2.isElement(arrowOffsetParent))) {
1904
+ clientSize = elements.floating[clientProp] || rects.floating[length];
1905
+ }
1906
+ const centerToReference = endDiff / 2 - startDiff / 2;
1907
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1908
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1909
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1910
+ const min$1 = minPadding;
1911
+ const max2 = clientSize - arrowDimensions[length] - maxPadding;
1912
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1913
+ const offset2 = clamp(min$1, center, max2);
1914
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset2 && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1915
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max2 : 0;
1916
+ return {
1917
+ [axis]: coords[axis] + alignmentOffset,
1918
+ data: {
1919
+ [axis]: offset2,
1920
+ centerOffset: center - offset2 - alignmentOffset,
1921
+ ...shouldAddOffset && {
1922
+ alignmentOffset
1923
+ }
1924
+ },
1925
+ reset: shouldAddOffset
1926
+ };
1927
+ }
1928
+ });
1929
+ const flip$1 = function(options) {
1930
+ if (options === void 0) {
1931
+ options = {};
1932
+ }
1933
+ return {
1934
+ name: "flip",
1935
+ options,
1936
+ async fn(state) {
1937
+ var _middlewareData$arrow, _middlewareData$flip;
1938
+ const {
1939
+ placement,
1940
+ middlewareData,
1941
+ rects,
1942
+ initialPlacement,
1943
+ platform: platform2,
1944
+ elements
1945
+ } = state;
1946
+ const {
1947
+ mainAxis: checkMainAxis = true,
1948
+ crossAxis: checkCrossAxis = true,
1949
+ fallbackPlacements: specifiedFallbackPlacements,
1950
+ fallbackStrategy = "bestFit",
1951
+ fallbackAxisSideDirection = "none",
1952
+ flipAlignment = true,
1953
+ ...detectOverflowOptions
1954
+ } = evaluate(options, state);
1955
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1956
+ return {};
1957
+ }
1958
+ const side = getSide(placement);
1959
+ const initialSideAxis = getSideAxis(initialPlacement);
1960
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
1961
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
1962
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1963
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
1964
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
1965
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
1966
+ }
1967
+ const placements = [initialPlacement, ...fallbackPlacements];
1968
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1969
+ const overflows = [];
1970
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1971
+ if (checkMainAxis) {
1972
+ overflows.push(overflow[side]);
1973
+ }
1974
+ if (checkCrossAxis) {
1975
+ const sides = getAlignmentSides(placement, rects, rtl);
1976
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
1651
1977
  }
1652
- next = next.parentNode || next.host;
1653
- } while (next);
1978
+ overflowsData = [...overflowsData, {
1979
+ placement,
1980
+ overflows
1981
+ }];
1982
+ if (!overflows.every((side2) => side2 <= 0)) {
1983
+ var _middlewareData$flip2, _overflowsData$filter;
1984
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
1985
+ const nextPlacement = placements[nextIndex];
1986
+ if (nextPlacement) {
1987
+ return {
1988
+ data: {
1989
+ index: nextIndex,
1990
+ overflows: overflowsData
1991
+ },
1992
+ reset: {
1993
+ placement: nextPlacement
1994
+ }
1995
+ };
1996
+ }
1997
+ 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;
1998
+ if (!resetPlacement) {
1999
+ switch (fallbackStrategy) {
2000
+ case "bestFit": {
2001
+ var _overflowsData$filter2;
2002
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d) => {
2003
+ if (hasFallbackAxisSideDirection) {
2004
+ const currentSideAxis = getSideAxis(d.placement);
2005
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
2006
+ // reading directions favoring greater width.
2007
+ currentSideAxis === "y";
2008
+ }
2009
+ return true;
2010
+ }).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];
2011
+ if (placement2) {
2012
+ resetPlacement = placement2;
2013
+ }
2014
+ break;
2015
+ }
2016
+ case "initialPlacement":
2017
+ resetPlacement = initialPlacement;
2018
+ break;
2019
+ }
2020
+ }
2021
+ if (placement !== resetPlacement) {
2022
+ return {
2023
+ reset: {
2024
+ placement: resetPlacement
2025
+ }
2026
+ };
2027
+ }
2028
+ }
2029
+ return {};
2030
+ }
2031
+ };
2032
+ };
2033
+ async function convertValueToCoords(state, options) {
2034
+ const {
2035
+ placement,
2036
+ platform: platform2,
2037
+ elements
2038
+ } = state;
2039
+ const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
2040
+ const side = getSide(placement);
2041
+ const alignment = getAlignment(placement);
2042
+ const isVertical = getSideAxis(placement) === "y";
2043
+ const mainAxisMulti = ["left", "top"].includes(side) ? -1 : 1;
2044
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
2045
+ const rawValue = evaluate(options, state);
2046
+ let {
2047
+ mainAxis,
2048
+ crossAxis,
2049
+ alignmentAxis
2050
+ } = typeof rawValue === "number" ? {
2051
+ mainAxis: rawValue,
2052
+ crossAxis: 0,
2053
+ alignmentAxis: null
2054
+ } : {
2055
+ mainAxis: rawValue.mainAxis || 0,
2056
+ crossAxis: rawValue.crossAxis || 0,
2057
+ alignmentAxis: rawValue.alignmentAxis
2058
+ };
2059
+ if (alignment && typeof alignmentAxis === "number") {
2060
+ crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
1654
2061
  }
1655
- return false;
2062
+ return isVertical ? {
2063
+ x: crossAxis * crossAxisMulti,
2064
+ y: mainAxis * mainAxisMulti
2065
+ } : {
2066
+ x: mainAxis * mainAxisMulti,
2067
+ y: crossAxis * crossAxisMulti
2068
+ };
1656
2069
  }
1657
- function getComputedStyle$1(element) {
1658
- return getWindow(element).getComputedStyle(element);
2070
+ const offset$1 = function(options) {
2071
+ if (options === void 0) {
2072
+ options = 0;
2073
+ }
2074
+ return {
2075
+ name: "offset",
2076
+ options,
2077
+ async fn(state) {
2078
+ var _middlewareData$offse, _middlewareData$arrow;
2079
+ const {
2080
+ x,
2081
+ y,
2082
+ placement,
2083
+ middlewareData
2084
+ } = state;
2085
+ const diffCoords = await convertValueToCoords(state, options);
2086
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2087
+ return {};
2088
+ }
2089
+ return {
2090
+ x: x + diffCoords.x,
2091
+ y: y + diffCoords.y,
2092
+ data: {
2093
+ ...diffCoords,
2094
+ placement
2095
+ }
2096
+ };
2097
+ }
2098
+ };
2099
+ };
2100
+ const shift$1 = function(options) {
2101
+ if (options === void 0) {
2102
+ options = {};
2103
+ }
2104
+ return {
2105
+ name: "shift",
2106
+ options,
2107
+ async fn(state) {
2108
+ const {
2109
+ x,
2110
+ y,
2111
+ placement
2112
+ } = state;
2113
+ const {
2114
+ mainAxis: checkMainAxis = true,
2115
+ crossAxis: checkCrossAxis = false,
2116
+ limiter = {
2117
+ fn: (_ref) => {
2118
+ let {
2119
+ x: x2,
2120
+ y: y2
2121
+ } = _ref;
2122
+ return {
2123
+ x: x2,
2124
+ y: y2
2125
+ };
2126
+ }
2127
+ },
2128
+ ...detectOverflowOptions
2129
+ } = evaluate(options, state);
2130
+ const coords = {
2131
+ x,
2132
+ y
2133
+ };
2134
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2135
+ const crossAxis = getSideAxis(getSide(placement));
2136
+ const mainAxis = getOppositeAxis(crossAxis);
2137
+ let mainAxisCoord = coords[mainAxis];
2138
+ let crossAxisCoord = coords[crossAxis];
2139
+ if (checkMainAxis) {
2140
+ const minSide = mainAxis === "y" ? "top" : "left";
2141
+ const maxSide = mainAxis === "y" ? "bottom" : "right";
2142
+ const min2 = mainAxisCoord + overflow[minSide];
2143
+ const max2 = mainAxisCoord - overflow[maxSide];
2144
+ mainAxisCoord = clamp(min2, mainAxisCoord, max2);
2145
+ }
2146
+ if (checkCrossAxis) {
2147
+ const minSide = crossAxis === "y" ? "top" : "left";
2148
+ const maxSide = crossAxis === "y" ? "bottom" : "right";
2149
+ const min2 = crossAxisCoord + overflow[minSide];
2150
+ const max2 = crossAxisCoord - overflow[maxSide];
2151
+ crossAxisCoord = clamp(min2, crossAxisCoord, max2);
2152
+ }
2153
+ const limitedCoords = limiter.fn({
2154
+ ...state,
2155
+ [mainAxis]: mainAxisCoord,
2156
+ [crossAxis]: crossAxisCoord
2157
+ });
2158
+ return {
2159
+ ...limitedCoords,
2160
+ data: {
2161
+ x: limitedCoords.x - x,
2162
+ y: limitedCoords.y - y,
2163
+ enabled: {
2164
+ [mainAxis]: checkMainAxis,
2165
+ [crossAxis]: checkCrossAxis
2166
+ }
2167
+ }
2168
+ };
2169
+ }
2170
+ };
2171
+ };
2172
+ const limitShift$1 = function(options) {
2173
+ if (options === void 0) {
2174
+ options = {};
2175
+ }
2176
+ return {
2177
+ options,
2178
+ fn(state) {
2179
+ const {
2180
+ x,
2181
+ y,
2182
+ placement,
2183
+ rects,
2184
+ middlewareData
2185
+ } = state;
2186
+ const {
2187
+ offset: offset2 = 0,
2188
+ mainAxis: checkMainAxis = true,
2189
+ crossAxis: checkCrossAxis = true
2190
+ } = evaluate(options, state);
2191
+ const coords = {
2192
+ x,
2193
+ y
2194
+ };
2195
+ const crossAxis = getSideAxis(placement);
2196
+ const mainAxis = getOppositeAxis(crossAxis);
2197
+ let mainAxisCoord = coords[mainAxis];
2198
+ let crossAxisCoord = coords[crossAxis];
2199
+ const rawOffset = evaluate(offset2, state);
2200
+ const computedOffset = typeof rawOffset === "number" ? {
2201
+ mainAxis: rawOffset,
2202
+ crossAxis: 0
2203
+ } : {
2204
+ mainAxis: 0,
2205
+ crossAxis: 0,
2206
+ ...rawOffset
2207
+ };
2208
+ if (checkMainAxis) {
2209
+ const len = mainAxis === "y" ? "height" : "width";
2210
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2211
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2212
+ if (mainAxisCoord < limitMin) {
2213
+ mainAxisCoord = limitMin;
2214
+ } else if (mainAxisCoord > limitMax) {
2215
+ mainAxisCoord = limitMax;
2216
+ }
2217
+ }
2218
+ if (checkCrossAxis) {
2219
+ var _middlewareData$offse, _middlewareData$offse2;
2220
+ const len = mainAxis === "y" ? "width" : "height";
2221
+ const isOriginSide = ["top", "left"].includes(getSide(placement));
2222
+ 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);
2223
+ 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);
2224
+ if (crossAxisCoord < limitMin) {
2225
+ crossAxisCoord = limitMin;
2226
+ } else if (crossAxisCoord > limitMax) {
2227
+ crossAxisCoord = limitMax;
2228
+ }
2229
+ }
2230
+ return {
2231
+ [mainAxis]: mainAxisCoord,
2232
+ [crossAxis]: crossAxisCoord
2233
+ };
2234
+ }
2235
+ };
2236
+ };
2237
+ function hasWindow() {
2238
+ return typeof window !== "undefined";
1659
2239
  }
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
- );
2240
+ function getNodeName(node) {
2241
+ if (isNode(node)) {
2242
+ return (node.nodeName || "").toLowerCase();
2243
+ }
2244
+ return "#document";
1683
2245
  }
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;
2246
+ function getWindow(node) {
2247
+ var _node$ownerDocument;
2248
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2249
+ }
2250
+ function getDocumentElement(node) {
2251
+ var _ref;
2252
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2253
+ }
2254
+ function isNode(value) {
2255
+ if (!hasWindow()) {
2256
+ return false;
1688
2257
  }
1689
- return element.offsetParent;
2258
+ return value instanceof Node || value instanceof getWindow(value).Node;
1690
2259
  }
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
- }
2260
+ function isElement(value) {
2261
+ if (!hasWindow()) {
2262
+ return false;
1699
2263
  }
1700
- var currentNode = getParentNode(element);
1701
- if (isShadowRoot(currentNode)) {
1702
- currentNode = currentNode.host;
2264
+ return value instanceof Element || value instanceof getWindow(value).Element;
2265
+ }
2266
+ function isHTMLElement(value) {
2267
+ if (!hasWindow()) {
2268
+ return false;
2269
+ }
2270
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2271
+ }
2272
+ function isShadowRoot(value) {
2273
+ if (!hasWindow() || typeof ShadowRoot === "undefined") {
2274
+ return false;
1703
2275
  }
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") {
2276
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2277
+ }
2278
+ function isOverflowElement(element) {
2279
+ const {
2280
+ overflow,
2281
+ overflowX,
2282
+ overflowY,
2283
+ display
2284
+ } = getComputedStyle$1(element);
2285
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !["inline", "contents"].includes(display);
2286
+ }
2287
+ function isTableElement(element) {
2288
+ return ["table", "td", "th"].includes(getNodeName(element));
2289
+ }
2290
+ function isTopLayer(element) {
2291
+ return [":popover-open", ":modal"].some((selector) => {
2292
+ try {
2293
+ return element.matches(selector);
2294
+ } catch (e) {
2295
+ return false;
2296
+ }
2297
+ });
2298
+ }
2299
+ function isContainingBlock(elementOrCss) {
2300
+ const webkit = isWebKit();
2301
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
2302
+ 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));
2303
+ }
2304
+ function getContainingBlock(element) {
2305
+ let currentNode = getParentNode(element);
2306
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2307
+ if (isContainingBlock(currentNode)) {
1707
2308
  return currentNode;
1708
- } else {
1709
- currentNode = currentNode.parentNode;
2309
+ } else if (isTopLayer(currentNode)) {
2310
+ return null;
1710
2311
  }
2312
+ currentNode = getParentNode(currentNode);
1711
2313
  }
1712
2314
  return null;
1713
2315
  }
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;
1724
- }
1725
- function getMainAxisFromPlacement(placement) {
1726
- return ["top", "bottom"].indexOf(placement) >= 0 ? "x" : "y";
2316
+ function isWebKit() {
2317
+ if (typeof CSS === "undefined" || !CSS.supports) return false;
2318
+ return CSS.supports("-webkit-backdrop-filter", "none");
1727
2319
  }
1728
- function within(min$1, value, max$1) {
1729
- return max(min$1, min(value, max$1));
2320
+ function isLastTraversableNode(node) {
2321
+ return ["html", "body", "#document"].includes(getNodeName(node));
1730
2322
  }
1731
- function withinMaxClamp(min2, value, max2) {
1732
- var v = within(min2, value, max2);
1733
- return v > max2 ? max2 : v;
2323
+ function getComputedStyle$1(element) {
2324
+ return getWindow(element).getComputedStyle(element);
1734
2325
  }
1735
- function getFreshSideObject() {
2326
+ function getNodeScroll(element) {
2327
+ if (isElement(element)) {
2328
+ return {
2329
+ scrollLeft: element.scrollLeft,
2330
+ scrollTop: element.scrollTop
2331
+ };
2332
+ }
1736
2333
  return {
1737
- top: 0,
1738
- right: 0,
1739
- bottom: 0,
1740
- left: 0
2334
+ scrollLeft: element.scrollX,
2335
+ scrollTop: element.scrollY
1741
2336
  };
1742
2337
  }
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
- }, {});
2338
+ function getParentNode(node) {
2339
+ if (getNodeName(node) === "html") {
2340
+ return node;
2341
+ }
2342
+ const result = (
2343
+ // Step into the shadow DOM of the parent of a slotted node.
2344
+ node.assignedSlot || // DOM Element detected.
2345
+ node.parentNode || // ShadowRoot detected.
2346
+ isShadowRoot(node) && node.host || // Fallback.
2347
+ getDocumentElement(node)
2348
+ );
2349
+ return isShadowRoot(result) ? result.host : result;
1751
2350
  }
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;
2351
+ function getNearestOverflowAncestor(node) {
2352
+ const parentNode = getParentNode(node);
2353
+ if (isLastTraversableNode(parentNode)) {
2354
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1769
2355
  }
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;
2356
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2357
+ return parentNode;
1791
2358
  }
1792
- if (typeof arrowElement === "string") {
1793
- arrowElement = state.elements.popper.querySelector(arrowElement);
1794
- if (!arrowElement) {
1795
- return;
1796
- }
2359
+ return getNearestOverflowAncestor(parentNode);
2360
+ }
2361
+ function getOverflowAncestors(node, list, traverseIframes) {
2362
+ var _node$ownerDocument2;
2363
+ if (list === void 0) {
2364
+ list = [];
1797
2365
  }
1798
- if (!contains(state.elements.popper, arrowElement)) {
1799
- return;
2366
+ if (traverseIframes === void 0) {
2367
+ traverseIframes = true;
2368
+ }
2369
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2370
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2371
+ const win = getWindow(scrollableAncestor);
2372
+ if (isBody) {
2373
+ const frameElement = getFrameElement(win);
2374
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2375
+ }
2376
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2377
+ }
2378
+ function getFrameElement(win) {
2379
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2380
+ }
2381
+ function getCssDimensions(element) {
2382
+ const css = getComputedStyle$1(element);
2383
+ let width = parseFloat(css.width) || 0;
2384
+ let height = parseFloat(css.height) || 0;
2385
+ const hasOffset = isHTMLElement(element);
2386
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2387
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2388
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2389
+ if (shouldFallback) {
2390
+ width = offsetWidth;
2391
+ height = offsetHeight;
1800
2392
  }
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
2393
  return {
1825
- x: round(x * dpr) / dpr || 0,
1826
- y: round(y * dpr) / dpr || 0
2394
+ width,
2395
+ height,
2396
+ $: shouldFallback
1827
2397
  };
1828
2398
  }
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
- }) : {
2399
+ function unwrapElement(element) {
2400
+ return !isElement(element) ? element.contextElement : element;
2401
+ }
2402
+ function getScale(element) {
2403
+ const domElement = unwrapElement(element);
2404
+ if (!isHTMLElement(domElement)) {
2405
+ return createCoords(1);
2406
+ }
2407
+ const rect = domElement.getBoundingClientRect();
2408
+ const {
2409
+ width,
2410
+ height,
2411
+ $
2412
+ } = getCssDimensions(domElement);
2413
+ let x = ($ ? round(rect.width) : rect.width) / width;
2414
+ let y = ($ ? round(rect.height) : rect.height) / height;
2415
+ if (!x || !Number.isFinite(x)) {
2416
+ x = 1;
2417
+ }
2418
+ if (!y || !Number.isFinite(y)) {
2419
+ y = 1;
2420
+ }
2421
+ return {
1837
2422
  x,
1838
2423
  y
1839
2424
  };
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";
2425
+ }
2426
+ const noOffsets = /* @__PURE__ */ createCoords(0);
2427
+ function getVisualOffsets(element) {
2428
+ const win = getWindow(element);
2429
+ if (!isWebKit() || !win.visualViewport) {
2430
+ return noOffsets;
2431
+ }
2432
+ return {
2433
+ x: win.visualViewport.offsetLeft,
2434
+ y: win.visualViewport.offsetTop
2435
+ };
2436
+ }
2437
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2438
+ if (isFixed === void 0) {
2439
+ isFixed = false;
2440
+ }
2441
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2442
+ return false;
2443
+ }
2444
+ return isFixed;
2445
+ }
2446
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2447
+ if (includeScale === void 0) {
2448
+ includeScale = false;
2449
+ }
2450
+ if (isFixedStrategy === void 0) {
2451
+ isFixedStrategy = false;
2452
+ }
2453
+ const clientRect = element.getBoundingClientRect();
2454
+ const domElement = unwrapElement(element);
2455
+ let scale = createCoords(1);
2456
+ if (includeScale) {
2457
+ if (offsetParent) {
2458
+ if (isElement(offsetParent)) {
2459
+ scale = getScale(offsetParent);
1856
2460
  }
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
- }
1877
- }
1878
- var commonStyles = Object.assign({
1879
- position
1880
- }, adaptive && unsetSides);
1881
- var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1882
- x,
1883
- y
1884
- }, getWindow(popper2)) : {
2461
+ } else {
2462
+ scale = getScale(element);
2463
+ }
2464
+ }
2465
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2466
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
2467
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
2468
+ let width = clientRect.width / scale.x;
2469
+ let height = clientRect.height / scale.y;
2470
+ if (domElement) {
2471
+ const win = getWindow(domElement);
2472
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2473
+ let currentWin = win;
2474
+ let currentIFrame = getFrameElement(currentWin);
2475
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2476
+ const iframeScale = getScale(currentIFrame);
2477
+ const iframeRect = currentIFrame.getBoundingClientRect();
2478
+ const css = getComputedStyle$1(currentIFrame);
2479
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2480
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2481
+ x *= iframeScale.x;
2482
+ y *= iframeScale.y;
2483
+ width *= iframeScale.x;
2484
+ height *= iframeScale.y;
2485
+ x += left;
2486
+ y += top;
2487
+ currentWin = getWindow(currentIFrame);
2488
+ currentIFrame = getFrameElement(currentWin);
2489
+ }
2490
+ }
2491
+ return rectToClientRect({
2492
+ width,
2493
+ height,
1885
2494
  x,
1886
2495
  y
1887
- };
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"
1906
- };
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
2496
  });
1926
2497
  }
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
- });
1946
- }
1947
- if (resize) {
1948
- window2.addEventListener("resize", instance.update, passive);
1949
- }
1950
- return function() {
1951
- if (scroll) {
1952
- scrollParents.forEach(function(scrollParent) {
1953
- scrollParent.removeEventListener("scroll", instance.update, passive);
1954
- });
2498
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2499
+ let {
2500
+ elements,
2501
+ rect,
2502
+ offsetParent,
2503
+ strategy
2504
+ } = _ref;
2505
+ const isFixed = strategy === "fixed";
2506
+ const documentElement = getDocumentElement(offsetParent);
2507
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
2508
+ if (offsetParent === documentElement || topLayer && isFixed) {
2509
+ return rect;
2510
+ }
2511
+ let scroll = {
2512
+ scrollLeft: 0,
2513
+ scrollTop: 0
2514
+ };
2515
+ let scale = createCoords(1);
2516
+ const offsets = createCoords(0);
2517
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2518
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2519
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2520
+ scroll = getNodeScroll(offsetParent);
1955
2521
  }
1956
- if (resize) {
1957
- window2.removeEventListener("resize", instance.update, passive);
2522
+ if (isHTMLElement(offsetParent)) {
2523
+ const offsetRect = getBoundingClientRect(offsetParent);
2524
+ scale = getScale(offsetParent);
2525
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2526
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1958
2527
  }
2528
+ }
2529
+ return {
2530
+ width: rect.width * scale.x,
2531
+ height: rect.height * scale.y,
2532
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2533
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
1959
2534
  };
1960
2535
  }
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
- });
2536
+ function getClientRects(element) {
2537
+ return Array.from(element.getClientRects());
1980
2538
  }
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
- });
2539
+ function getWindowScrollBarX(element, rect) {
2540
+ const leftScroll = getNodeScroll(element).scrollLeft;
2541
+ if (!rect) {
2542
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2543
+ }
2544
+ return rect.left + leftScroll;
1989
2545
  }
1990
- function getWindowScroll(node) {
1991
- var win = getWindow(node);
1992
- var scrollLeft = win.pageXOffset;
1993
- var scrollTop = win.pageYOffset;
2546
+ function getDocumentRect(element) {
2547
+ const html = getDocumentElement(element);
2548
+ const scroll = getNodeScroll(element);
2549
+ const body = element.ownerDocument.body;
2550
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2551
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2552
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2553
+ const y = -scroll.scrollTop;
2554
+ if (getComputedStyle$1(body).direction === "rtl") {
2555
+ x += max(html.clientWidth, body.clientWidth) - width;
2556
+ }
1994
2557
  return {
1995
- scrollLeft,
1996
- scrollTop
2558
+ width,
2559
+ height,
2560
+ x,
2561
+ y
1997
2562
  };
1998
2563
  }
1999
- function getWindowScrollBarX(element) {
2000
- return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
2001
- }
2002
2564
  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;
2565
+ const win = getWindow(element);
2566
+ const html = getDocumentElement(element);
2567
+ const visualViewport = win.visualViewport;
2568
+ let width = html.clientWidth;
2569
+ let height = html.clientHeight;
2570
+ let x = 0;
2571
+ let y = 0;
2010
2572
  if (visualViewport) {
2011
2573
  width = visualViewport.width;
2012
2574
  height = visualViewport.height;
2013
- var layoutViewport = isLayoutViewport();
2014
- if (layoutViewport || !layoutViewport && strategy === "fixed") {
2575
+ const visualViewportBased = isWebKit();
2576
+ if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
2015
2577
  x = visualViewport.offsetLeft;
2016
2578
  y = visualViewport.offsetTop;
2017
2579
  }
@@ -2019,22 +2581,19 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2019
2581
  return {
2020
2582
  width,
2021
2583
  height,
2022
- x: x + getWindowScrollBarX(element),
2584
+ x,
2023
2585
  y
2024
2586
  };
2025
2587
  }
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
- }
2588
+ function getInnerBoundingClientRect(element, strategy) {
2589
+ const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
2590
+ const top = clientRect.top + element.clientTop;
2591
+ const left = clientRect.left + element.clientLeft;
2592
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2593
+ const width = element.clientWidth * scale.x;
2594
+ const height = element.clientHeight * scale.y;
2595
+ const x = left * scale.x;
2596
+ const y = top * scale.y;
2038
2597
  return {
2039
2598
  width,
2040
2599
  height,
@@ -2042,794 +2601,358 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2042
2601
  y
2043
2602
  };
2044
2603
  }
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;
2604
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2605
+ let rect;
2606
+ if (clippingAncestor === "viewport") {
2607
+ rect = getViewportRect(element, strategy);
2608
+ } else if (clippingAncestor === "document") {
2609
+ rect = getDocumentRect(getDocumentElement(element));
2610
+ } else if (isElement(clippingAncestor)) {
2611
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2612
+ } else {
2613
+ const visualOffsets = getVisualOffsets(element);
2614
+ rect = {
2615
+ ...clippingAncestor,
2616
+ x: clippingAncestor.x - visualOffsets.x,
2617
+ y: clippingAncestor.y - visualOffsets.y
2618
+ };
2055
2619
  }
2056
- return getScrollParent(getParentNode(node));
2620
+ return rectToClientRect(rect);
2057
2621
  }
2058
- function listScrollParents(element, list) {
2059
- var _element$ownerDocumen;
2060
- if (list === void 0) {
2061
- list = [];
2622
+ function hasFixedPositionAncestor(element, stopNode) {
2623
+ const parentNode = getParentNode(element);
2624
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2625
+ return false;
2062
2626
  }
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
- });
2627
+ return getComputedStyle$1(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
2628
+ }
2629
+ function getClippingElementAncestors(element, cache) {
2630
+ const cachedResult = cache.get(element);
2631
+ if (cachedResult) {
2632
+ return cachedResult;
2633
+ }
2634
+ let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
2635
+ let currentContainingBlockComputedStyle = null;
2636
+ const elementIsFixed = getComputedStyle$1(element).position === "fixed";
2637
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2638
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2639
+ const computedStyle = getComputedStyle$1(currentNode);
2640
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2641
+ if (!currentNodeIsContaining && computedStyle.position === "fixed") {
2642
+ currentContainingBlockComputedStyle = null;
2643
+ }
2644
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && ["absolute", "fixed"].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2645
+ if (shouldDropCurrentNode) {
2646
+ result = result.filter((ancestor) => ancestor !== currentNode);
2647
+ } else {
2648
+ currentContainingBlockComputedStyle = computedStyle;
2649
+ }
2650
+ currentNode = getParentNode(currentNode);
2651
+ }
2652
+ cache.set(element, result);
2653
+ return result;
2106
2654
  }
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);
2655
+ function getClippingRect(_ref) {
2656
+ let {
2657
+ element,
2658
+ boundary,
2659
+ rootBoundary,
2660
+ strategy
2661
+ } = _ref;
2662
+ const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
2663
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2664
+ const firstClippingAncestor = clippingAncestors[0];
2665
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2666
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2113
2667
  accRect.top = max(rect.top, accRect.top);
2114
2668
  accRect.right = min(rect.right, accRect.right);
2115
2669
  accRect.bottom = min(rect.bottom, accRect.bottom);
2116
2670
  accRect.left = max(rect.left, accRect.left);
2117
2671
  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
- }
2672
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2351
2673
  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
2674
+ width: clippingRect.right - clippingRect.left,
2675
+ height: clippingRect.bottom - clippingRect.top,
2676
+ x: clippingRect.left,
2677
+ y: clippingRect.top
2356
2678
  };
2357
2679
  }
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
2383
- };
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
- }
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) {
2680
+ function getDimensions(element) {
2681
+ const {
2682
+ width,
2683
+ height
2684
+ } = getCssDimensions(element);
2544
2685
  return {
2545
- scrollLeft: element.scrollLeft,
2546
- scrollTop: element.scrollTop
2686
+ width,
2687
+ height
2547
2688
  };
2548
2689
  }
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 = {
2690
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2691
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2692
+ const documentElement = getDocumentElement(offsetParent);
2693
+ const isFixed = strategy === "fixed";
2694
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2695
+ let scroll = {
2571
2696
  scrollLeft: 0,
2572
2697
  scrollTop: 0
2573
2698
  };
2574
- var offsets = {
2575
- x: 0,
2576
- y: 0
2577
- };
2699
+ const offsets = createCoords(0);
2578
2700
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2579
- if (getNodeName(offsetParent) !== "body" || // https://github.com/popperjs/popper-core/issues/1078
2580
- isScrollParent(documentElement)) {
2701
+ if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
2581
2702
  scroll = getNodeScroll(offsetParent);
2582
2703
  }
2583
- if (isHTMLElement(offsetParent)) {
2584
- offsets = getBoundingClientRect(offsetParent, true);
2585
- offsets.x += offsetParent.clientLeft;
2586
- offsets.y += offsetParent.clientTop;
2704
+ if (isOffsetParentAnElement) {
2705
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2706
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2707
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2587
2708
  } else if (documentElement) {
2588
2709
  offsets.x = getWindowScrollBarX(documentElement);
2589
2710
  }
2590
2711
  }
2712
+ let htmlX = 0;
2713
+ let htmlY = 0;
2714
+ if (documentElement && !isOffsetParentAnElement && !isFixed) {
2715
+ const htmlRect = documentElement.getBoundingClientRect();
2716
+ htmlY = htmlRect.top + scroll.scrollTop;
2717
+ htmlX = htmlRect.left + scroll.scrollLeft - // RTL <body> scrollbar.
2718
+ getWindowScrollBarX(documentElement, htmlRect);
2719
+ }
2720
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlX;
2721
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlY;
2591
2722
  return {
2592
- x: rect.left + scroll.scrollLeft - offsets.x,
2593
- y: rect.top + scroll.scrollTop - offsets.y,
2723
+ x,
2724
+ y,
2594
2725
  width: rect.width,
2595
2726
  height: rect.height
2596
2727
  };
2597
2728
  }
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);
2729
+ function isStaticPositioned(element) {
2730
+ return getComputedStyle$1(element).position === "static";
2731
+ }
2732
+ function getTrueOffsetParent(element, polyfill) {
2733
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === "fixed") {
2734
+ return null;
2735
+ }
2736
+ if (polyfill) {
2737
+ return polyfill(element);
2617
2738
  }
2618
- modifiers.forEach(function(modifier) {
2619
- if (!visited.has(modifier.name)) {
2620
- sort(modifier);
2739
+ let rawOffsetParent = element.offsetParent;
2740
+ if (getDocumentElement(element) === rawOffsetParent) {
2741
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
2742
+ }
2743
+ return rawOffsetParent;
2744
+ }
2745
+ function getOffsetParent(element, polyfill) {
2746
+ const win = getWindow(element);
2747
+ if (isTopLayer(element)) {
2748
+ return win;
2749
+ }
2750
+ if (!isHTMLElement(element)) {
2751
+ let svgOffsetParent = getParentNode(element);
2752
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
2753
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
2754
+ return svgOffsetParent;
2755
+ }
2756
+ svgOffsetParent = getParentNode(svgOffsetParent);
2621
2757
  }
2622
- });
2623
- return result;
2758
+ return win;
2759
+ }
2760
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2761
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
2762
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2763
+ }
2764
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
2765
+ return win;
2766
+ }
2767
+ return offsetParent || getContainingBlock(element) || win;
2624
2768
  }
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
- });
2769
+ const getElementRects = async function(data) {
2770
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2771
+ const getDimensionsFn = this.getDimensions;
2772
+ const floatingDimensions = await getDimensionsFn(data.floating);
2773
+ return {
2774
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
2775
+ floating: {
2776
+ x: 0,
2777
+ y: 0,
2778
+ width: floatingDimensions.width,
2779
+ height: floatingDimensions.height
2643
2780
  }
2644
- return pending;
2645
2781
  };
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
2782
  };
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;
2783
+ function isRTL(element) {
2784
+ return getComputedStyle$1(element).direction === "rtl";
2785
+ }
2786
+ const platform = {
2787
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2788
+ getDocumentElement,
2789
+ getClippingRect,
2790
+ getOffsetParent,
2791
+ getElementRects,
2792
+ getClientRects,
2793
+ getDimensions,
2794
+ getScale,
2795
+ isElement,
2796
+ isRTL
2797
+ };
2798
+ function observeMove(element, onMove) {
2799
+ let io = null;
2800
+ let timeoutId;
2801
+ const root = getDocumentElement(element);
2802
+ function cleanup() {
2803
+ var _io;
2804
+ clearTimeout(timeoutId);
2805
+ (_io = io) == null || _io.disconnect();
2806
+ io = null;
2807
+ }
2808
+ function refresh(skip, threshold) {
2809
+ if (skip === void 0) {
2810
+ skip = false;
2811
+ }
2812
+ if (threshold === void 0) {
2813
+ threshold = 1;
2814
+ }
2815
+ cleanup();
2816
+ const {
2817
+ left,
2818
+ top,
2819
+ width,
2820
+ height
2821
+ } = element.getBoundingClientRect();
2822
+ if (!skip) {
2823
+ onMove();
2824
+ }
2825
+ if (!width || !height) {
2826
+ return;
2681
2827
  }
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: {}
2828
+ const insetTop = floor(top);
2829
+ const insetRight = floor(root.clientWidth - (left + width));
2830
+ const insetBottom = floor(root.clientHeight - (top + height));
2831
+ const insetLeft = floor(left);
2832
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2833
+ const options = {
2834
+ rootMargin,
2835
+ threshold: max(0, min(1, threshold)) || 1
2693
2836
  };
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;
2837
+ let isFirstUpdate = true;
2838
+ function handleObserve(entries) {
2839
+ const ratio = entries[0].intersectionRatio;
2840
+ if (ratio !== threshold) {
2841
+ if (!isFirstUpdate) {
2842
+ return refresh();
2725
2843
  }
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
- }
2844
+ if (!ratio) {
2845
+ timeoutId = setTimeout(() => {
2846
+ refresh(false, 1e-7);
2847
+ }, 1e3);
2848
+ } else {
2849
+ refresh(false, ratio);
2750
2850
  }
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
2851
  }
2764
- };
2765
- if (!areValidElements(reference2, popper2)) {
2766
- return instance;
2852
+ isFirstUpdate = false;
2767
2853
  }
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
- });
2788
- }
2789
- function cleanupModifierEffects() {
2790
- effectCleanupFns.forEach(function(fn) {
2791
- return fn();
2854
+ try {
2855
+ io = new IntersectionObserver(handleObserve, {
2856
+ ...options,
2857
+ // Handle <iframe>s
2858
+ root: root.ownerDocument
2792
2859
  });
2793
- effectCleanupFns = [];
2794
- }
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();
2860
+ } catch (e) {
2861
+ io = new IntersectionObserver(handleObserve, options);
2810
2862
  }
2811
- entry.popper.destroy();
2812
- deregisterEventListeners(entry);
2813
- Object.getOwnPropertyNames(entry).forEach((prop) => {
2814
- delete entry[prop];
2815
- });
2816
- this.collection.splice(index2, 1);
2863
+ io.observe(element);
2817
2864
  }
2818
- return this.collection;
2865
+ refresh(true);
2866
+ return cleanup;
2819
2867
  }
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);
2868
+ function autoUpdate(reference, floating, update, options) {
2869
+ if (options === void 0) {
2870
+ options = {};
2871
+ }
2872
+ const {
2873
+ ancestorScroll = true,
2874
+ ancestorResize = true,
2875
+ elementResize = typeof ResizeObserver === "function",
2876
+ layoutShift = typeof IntersectionObserver === "function",
2877
+ animationFrame = false
2878
+ } = options;
2879
+ const referenceEl = unwrapElement(reference);
2880
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
2881
+ ancestors.forEach((ancestor) => {
2882
+ ancestorScroll && ancestor.addEventListener("scroll", update, {
2883
+ passive: true
2884
+ });
2885
+ ancestorResize && ancestor.addEventListener("resize", update);
2886
+ });
2887
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2888
+ let reobserveFrame = -1;
2889
+ let resizeObserver = null;
2890
+ if (elementResize) {
2891
+ resizeObserver = new ResizeObserver((_ref) => {
2892
+ let [firstEntry] = _ref;
2893
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2894
+ resizeObserver.unobserve(floating);
2895
+ cancelAnimationFrame(reobserveFrame);
2896
+ reobserveFrame = requestAnimationFrame(() => {
2897
+ var _resizeObserver;
2898
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2826
2899
  });
2827
- });
2900
+ }
2901
+ update();
2828
2902
  });
2829
- delete entry.__eventListeners;
2830
- }
2831
- return entry;
2903
+ if (referenceEl && !animationFrame) {
2904
+ resizeObserver.observe(referenceEl);
2905
+ }
2906
+ resizeObserver.observe(floating);
2907
+ }
2908
+ let frameId;
2909
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2910
+ if (animationFrame) {
2911
+ frameLoop();
2912
+ }
2913
+ function frameLoop() {
2914
+ const nextRefRect = getBoundingClientRect(reference);
2915
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2916
+ update();
2917
+ }
2918
+ prevRefRect = nextRefRect;
2919
+ frameId = requestAnimationFrame(frameLoop);
2920
+ }
2921
+ update();
2922
+ return () => {
2923
+ var _resizeObserver2;
2924
+ ancestors.forEach((ancestor) => {
2925
+ ancestorScroll && ancestor.removeEventListener("scroll", update);
2926
+ ancestorResize && ancestor.removeEventListener("resize", update);
2927
+ });
2928
+ cleanupIo == null || cleanupIo();
2929
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2930
+ resizeObserver = null;
2931
+ if (animationFrame) {
2932
+ cancelAnimationFrame(frameId);
2933
+ }
2934
+ };
2832
2935
  }
2936
+ const offset = offset$1;
2937
+ const shift = shift$1;
2938
+ const flip = flip$1;
2939
+ const arrow = arrow$1;
2940
+ const limitShift = limitShift$1;
2941
+ const computePosition = (reference, floating, options) => {
2942
+ const cache = /* @__PURE__ */ new Map();
2943
+ const mergedOptions = {
2944
+ platform,
2945
+ ...options
2946
+ };
2947
+ const platformWithCache = {
2948
+ ...mergedOptions.platform,
2949
+ _c: cache
2950
+ };
2951
+ return computePosition$1(reference, floating, {
2952
+ ...mergedOptions,
2953
+ platform: platformWithCache
2954
+ });
2955
+ };
2833
2956
  async function open(query) {
2834
2957
  const popover = getPopover.call(this, query);
2835
2958
  popover.el.inert = false;
@@ -2837,31 +2960,56 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2837
2960
  if (!popover.isTooltip) {
2838
2961
  popover.trigger.setAttribute("aria-expanded", "true");
2839
2962
  }
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
- ]
2963
+ popover.getCustomProps();
2964
+ const middlewareOptions = getMiddlewareOptions(popover);
2965
+ const arrowEl = popover.el.querySelector(middlewareOptions.arrow.element);
2966
+ middlewareOptions.arrow.element = arrowEl ? arrowEl : void 0;
2967
+ popover.cleanup = autoUpdate(popover.trigger, popover.el, () => {
2968
+ computePosition(popover.trigger, popover.el, {
2969
+ placement: popover.getSetting("placement"),
2970
+ middleware: [
2971
+ flip(middlewareOptions.flip),
2972
+ shift({ ...middlewareOptions.shift, limiter: limitShift() }),
2973
+ offset(middlewareOptions.offset),
2974
+ arrow(middlewareOptions.arrow)
2975
+ ]
2976
+ }).then(({ x, y, placement, middlewareData }) => {
2977
+ if (!popover.el) {
2978
+ return;
2979
+ }
2980
+ applyPositionStyle(popover.el, x, y);
2981
+ if (middlewareOptions.arrow.element && middlewareData.arrow) {
2982
+ const { x: x2, y: y2 } = middlewareData.arrow;
2983
+ applyPositionStyle(middlewareOptions.arrow.element, x2, y2);
2984
+ }
2985
+ popover.el.setAttribute("data-floating-placement", placement);
2986
+ });
2847
2987
  });
2848
- popover.popper.update();
2849
2988
  popover.state = "opened";
2850
2989
  return popover;
2851
2990
  }
2852
- async function register(el, trigger) {
2853
- deregister.call(this, el);
2991
+ async function register(el, trigger, config = {}) {
2992
+ await deregister.call(this, el);
2854
2993
  const root = this;
2855
- const entry = {
2856
- id: el.id,
2994
+ const _isHovered = {
2995
+ el: false,
2996
+ trigger: false
2997
+ };
2998
+ const _customPropKeys = [
2999
+ "placement",
3000
+ "event",
3001
+ "offset",
3002
+ "flip-padding",
3003
+ "shift-padding",
3004
+ "arrow-padding",
3005
+ "toggle-delay"
3006
+ ];
3007
+ const entry = this.createEntry(el, { customPropKeys: _customPropKeys });
3008
+ Object.assign(entry, {
2857
3009
  state: "closed",
2858
- el,
2859
3010
  trigger,
2860
3011
  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";
3012
+ cleanup: () => {
2865
3013
  },
2866
3014
  open() {
2867
3015
  return open.call(root, this);
@@ -2872,7 +3020,33 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2872
3020
  deregister() {
2873
3021
  return deregister.call(root, this);
2874
3022
  }
2875
- };
3023
+ });
3024
+ Object.defineProperties(entry, Object.getOwnPropertyDescriptors({
3025
+ set isHovered(event) {
3026
+ const state = event.type == "mouseenter" ? true : event.type == "mouseleave" ? false : void 0;
3027
+ if (state == void 0) return;
3028
+ switch (event.target) {
3029
+ case this.el:
3030
+ _isHovered.el = state;
3031
+ break;
3032
+ case this.trigger:
3033
+ _isHovered.trigger = state;
3034
+ break;
3035
+ }
3036
+ },
3037
+ get isHovered() {
3038
+ return _isHovered.el || _isHovered.trigger;
3039
+ },
3040
+ get isTooltip() {
3041
+ return !!el.closest(root.settings.selectorTooltip) || el.getAttribute("role") == "tooltip";
3042
+ }
3043
+ }));
3044
+ if (entry.isTooltip) {
3045
+ entry.settings.event = "hover";
3046
+ }
3047
+ entry.applySettings(config);
3048
+ entry.getDataConfig();
3049
+ entry.getCustomProps();
2876
3050
  if (entry.isTooltip) {
2877
3051
  entry.el.setAttribute("role", "tooltip");
2878
3052
  }
@@ -2880,6 +3054,9 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2880
3054
  entry.trigger.setAttribute("aria-expanded", "false");
2881
3055
  }
2882
3056
  registerEventListeners.call(this, entry);
3057
+ if (entry.getSetting("teleport")) {
3058
+ entry.teleport();
3059
+ }
2883
3060
  this.collection.push(entry);
2884
3061
  if (entry.el.classList.contains(this.settings.stateActive)) {
2885
3062
  await entry.open();
@@ -2887,25 +3064,26 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2887
3064
  } else {
2888
3065
  entry.el.inert = true;
2889
3066
  }
2890
- entry.popper.setOptions({
2891
- placement: entry.config["placement"]
2892
- });
2893
3067
  return entry;
2894
3068
  }
2895
3069
  function registerEventListeners(entry) {
2896
- if (!entry.__eventListeners) {
2897
- const eventType = entry.isTooltip ? "hover" : entry.config["event"];
3070
+ if (!entry._eventListeners) {
3071
+ const eventType = entry.getSetting("event");
2898
3072
  if (eventType === "hover") {
2899
- entry.__eventListeners = [{
2900
- el: ["trigger"],
3073
+ entry._eventListeners = [{
3074
+ el: ["el", "trigger"],
2901
3075
  type: ["mouseenter", "focus"],
2902
3076
  listener: handleMouseEnter.bind(this, entry)
2903
3077
  }, {
2904
3078
  el: ["el", "trigger"],
2905
3079
  type: ["mouseleave", "focusout"],
2906
3080
  listener: handleMouseLeave.bind(this, entry)
3081
+ }, {
3082
+ el: ["trigger"],
3083
+ type: ["click"],
3084
+ listener: handleTooltipClick.bind(this, entry)
2907
3085
  }];
2908
- entry.__eventListeners.forEach((evObj) => {
3086
+ entry._eventListeners.forEach((evObj) => {
2909
3087
  evObj.el.forEach((el) => {
2910
3088
  evObj.type.forEach((type) => {
2911
3089
  entry[el].addEventListener(type, evObj.listener, false);
@@ -2913,12 +3091,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2913
3091
  });
2914
3092
  });
2915
3093
  } else {
2916
- entry.__eventListeners = [{
3094
+ entry._eventListeners = [{
2917
3095
  el: ["trigger"],
2918
3096
  type: ["click"],
2919
3097
  listener: handleClick.bind(this, entry)
2920
3098
  }];
2921
- entry.__eventListeners.forEach((evObj) => {
3099
+ entry._eventListeners.forEach((evObj) => {
2922
3100
  evObj.el.forEach((el) => {
2923
3101
  evObj.type.forEach((type) => {
2924
3102
  entry[el].addEventListener(type, evObj.listener, false);
@@ -2931,19 +3109,18 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2931
3109
  }
2932
3110
  class Popover extends Collection {
2933
3111
  constructor(options) {
2934
- super();
3112
+ super({ ...defaults, ...options });
2935
3113
  __privateAdd(this, _handleKeydown3);
2936
- this.defaults = defaults;
2937
- this.settings = { ...this.defaults, ...options };
2938
3114
  this.trigger = null;
2939
3115
  __privateSet(this, _handleKeydown3, handleKeydown.bind(this));
2940
- if (this.settings.autoMount) this.mount();
2941
3116
  }
2942
3117
  get active() {
2943
3118
  return this.collection.find((popover) => popover.state == "opened");
2944
3119
  }
2945
- get activeTooltip() {
2946
- return this.collection.find((popover) => popover.state == "opened" && popover.isTooltip);
3120
+ get activeHover() {
3121
+ return this.collection.find((popover) => {
3122
+ return popover.state == "opened" && popover.getSetting("event") == "hover";
3123
+ });
2947
3124
  }
2948
3125
  async mount(options) {
2949
3126
  if (options) this.settings = { ...this.settings, ...options };
@@ -2978,10 +3155,10 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
2978
3155
  }
2979
3156
  document.removeEventListener("keydown", __privateGet(this, _handleKeydown3), false);
2980
3157
  }
2981
- register(query) {
3158
+ register(query, config = {}) {
2982
3159
  const els = getPopoverElements.call(this, query);
2983
3160
  if (els.error) return Promise.reject(els.error);
2984
- return register.call(this, els.popover, els.trigger);
3161
+ return register.call(this, els.popover, els.trigger, config);
2985
3162
  }
2986
3163
  deregister(query) {
2987
3164
  let obj = this.get(query.id || query);