@jobber/components 6.26.0 → 6.26.1

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.
Files changed (140) hide show
  1. package/dist/AnimatedPresence-es.js +4 -4
  2. package/dist/AnimatedSwitcher-es.js +4 -4
  3. package/dist/AtlantisThemeContext-es.js +6 -6
  4. package/dist/Autocomplete-es.js +27 -27
  5. package/dist/Avatar-es.js +4 -4
  6. package/dist/Banner-es.js +13 -13
  7. package/dist/BannerIcon-es.js +3 -3
  8. package/dist/Body-es.js +12 -12
  9. package/dist/Box-es.js +2 -2
  10. package/dist/Button-es.js +13 -13
  11. package/dist/ButtonDismiss-es.js +2 -2
  12. package/dist/Card-es.js +15 -15
  13. package/dist/Checkbox/index.mjs +24 -24
  14. package/dist/Chip-es.js +17 -17
  15. package/dist/ChipDismissible-es.js +7 -7
  16. package/dist/Chips/index.mjs +3 -3
  17. package/dist/Chips-es.js +13 -13
  18. package/dist/Combobox/components/ComboboxContent/index.cjs +0 -2
  19. package/dist/Combobox/components/ComboboxContent/index.mjs +0 -2
  20. package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +3 -8
  21. package/dist/Combobox/index.cjs +1 -2
  22. package/dist/Combobox/index.mjs +1 -2
  23. package/dist/Combobox-es.js +6 -6
  24. package/dist/ComboboxAction-es.js +4 -4
  25. package/dist/ComboboxActivator-es.js +3 -3
  26. package/dist/ComboboxContent-cjs.js +3745 -39
  27. package/dist/ComboboxContent-es.js +3715 -27
  28. package/dist/ComboboxContentHeader-es.js +4 -4
  29. package/dist/ComboboxContentList-es.js +13 -13
  30. package/dist/ComboboxContentSearch-es.js +5 -5
  31. package/dist/ComboboxLoadMore-es.js +2 -2
  32. package/dist/ComboboxOption-es.js +6 -6
  33. package/dist/ComboboxProvider-es.js +3 -3
  34. package/dist/ComboboxTrigger-es.js +4 -4
  35. package/dist/ConfirmationModal-es.js +4 -4
  36. package/dist/Countdown-es.js +3 -3
  37. package/dist/DataDump-es.js +7 -7
  38. package/dist/DataList/components/DataListFilters/components/DataListSort/index.cjs +1 -2
  39. package/dist/DataList/components/DataListFilters/components/DataListSort/index.mjs +1 -2
  40. package/dist/DataList/components/DataListFilters/index.cjs +2 -2
  41. package/dist/DataList/components/DataListFilters/index.mjs +2 -2
  42. package/dist/DataList-es.js +21 -21
  43. package/dist/DataList.utils-es.js +7 -7
  44. package/dist/DataListAction-es.js +9 -9
  45. package/dist/DataListActions-es.js +6 -6
  46. package/dist/DataListActionsMenu-es.js +4 -4
  47. package/dist/DataListBulkActions-es.js +3 -3
  48. package/dist/DataListContext-es.js +6 -6
  49. package/dist/DataListEmptyState-es.js +3 -3
  50. package/dist/DataListFilters-es.js +3 -3
  51. package/dist/DataListHeader-es.js +12 -12
  52. package/dist/DataListHeaderTile-es.js +9 -9
  53. package/dist/DataListItem-es.js +10 -10
  54. package/dist/DataListItemActions-es.js +3 -3
  55. package/dist/DataListItemActionsOverflow-es.js +5 -5
  56. package/dist/DataListItemClickable-es.js +8 -8
  57. package/dist/DataListItems-es.js +3 -3
  58. package/dist/DataListLayout-es.js +2 -2
  59. package/dist/DataListLayoutActions-es.js +6 -6
  60. package/dist/DataListLoadMore-es.js +8 -8
  61. package/dist/DataListLoadingState-es.js +4 -4
  62. package/dist/DataListOverflowFade-es.js +6 -6
  63. package/dist/DataListSearch-es.js +6 -6
  64. package/dist/DataListSort-es.js +6 -6
  65. package/dist/DataListSortingOptions-es.js +3 -3
  66. package/dist/DataListStatusBar-es.js +2 -2
  67. package/dist/DataListStickyHeader-es.js +2 -2
  68. package/dist/DataListTags-es.js +7 -7
  69. package/dist/DataListTotalCount-es.js +6 -6
  70. package/dist/DataTable-es.js +45 -45
  71. package/dist/DatePicker-es.js +12 -12
  72. package/dist/DayOfMonthSelect-es.js +18 -18
  73. package/dist/DescriptionList-es.js +4 -4
  74. package/dist/Disclosure-es.js +10 -10
  75. package/dist/Divider-es.js +2 -2
  76. package/dist/DrawerGrid-es.js +11 -11
  77. package/dist/Emphasis-es.js +2 -2
  78. package/dist/FeatureSwitch-es.js +17 -17
  79. package/dist/Flex-es.js +2 -2
  80. package/dist/Form-es.js +3 -3
  81. package/dist/FormField-es.js +38 -38
  82. package/dist/FormatDate-es.js +2 -2
  83. package/dist/FormatEmail-es.js +2 -2
  84. package/dist/FormatFile-es.js +23 -23
  85. package/dist/FormatRelativeDateTime-es.js +6 -6
  86. package/dist/FormatTime-es.js +2 -2
  87. package/dist/Gallery-es.js +8 -8
  88. package/dist/Glimmer-es.js +11 -11
  89. package/dist/Grid-es.js +2 -2
  90. package/dist/GridCell-es.js +2 -2
  91. package/dist/Heading-es.js +2 -2
  92. package/dist/Icon-es.js +9 -9
  93. package/dist/InlineLabel-es.js +3 -3
  94. package/dist/InputAvatar-es.js +11 -11
  95. package/dist/InputDate/index.mjs +9 -9
  96. package/dist/InputEmail-es.js +2 -2
  97. package/dist/InputFile-es.js +20 -20
  98. package/dist/InputGroup-es.js +4 -4
  99. package/dist/InputNumber-es.js +2 -2
  100. package/dist/InputPassword-es.js +2 -2
  101. package/dist/InputPhoneNumber-es.js +6 -6
  102. package/dist/InputText/index.mjs +12 -12
  103. package/dist/InputTime-es.js +2 -2
  104. package/dist/InputValidation-es.js +5 -5
  105. package/dist/InternalChipDismissible-es.js +19 -19
  106. package/dist/LightBox-es.js +31 -31
  107. package/dist/Link-es.js +2 -2
  108. package/dist/List-es.js +29 -29
  109. package/dist/Markdown-es.js +15 -15
  110. package/dist/Menu-es.js +21 -21
  111. package/dist/Modal-es.js +18 -18
  112. package/dist/MultiSelect-es.js +9 -9
  113. package/dist/Option-es.js +3 -3
  114. package/dist/Page-es.js +23 -23
  115. package/dist/Popover-es.js +7 -7
  116. package/dist/ProgressBar-es.js +5 -5
  117. package/dist/RadioGroup-es.js +9 -9
  118. package/dist/RecurringSelect-es.js +19 -19
  119. package/dist/SegmentedControl-es.js +9 -9
  120. package/dist/SideDrawer-es.js +22 -22
  121. package/dist/Spinner-es.js +2 -2
  122. package/dist/StatusIndicator-es.js +2 -2
  123. package/dist/StatusLabel-es.js +5 -5
  124. package/dist/Switch-es.js +10 -10
  125. package/dist/Tabs-es.js +14 -14
  126. package/dist/Text-es.js +2 -2
  127. package/dist/Tooltip-es.js +9 -9
  128. package/dist/Typography-es.js +2 -2
  129. package/dist/showToast-es.js +11 -11
  130. package/dist/styles.css +0 -2
  131. package/dist/useChildComponent-es.js +2 -2
  132. package/dist/useFocusTrap-es.js +2 -2
  133. package/dist/useInView-es.js +2 -2
  134. package/dist/useIsMounted-es.js +2 -2
  135. package/dist/useOnKeyDown-es.js +2 -2
  136. package/dist/useRefocusOnActivator-es.js +2 -2
  137. package/dist/useResizeObserver-es.js +3 -3
  138. package/dist/useSafeLayoutEffect-es.js +2 -2
  139. package/dist/useScrollToActive-es.js +3 -3
  140. package/package.json +3 -2
@@ -9,39 +9,3741 @@ var ComboboxContentHeader = require('./ComboboxContentHeader-cjs.js');
9
9
  var ComboboxProvider = require('./ComboboxProvider-cjs.js');
10
10
  var useRefocusOnActivator = require('./useRefocusOnActivator-cjs.js');
11
11
  var useFocusTrap = require('./useFocusTrap-cjs.js');
12
- var reactPopper = require('react-popper');
13
- var useOnKeyDown = require('./useOnKeyDown-cjs.js');
14
12
  var constants = require('./constants-cjs.js');
15
13
 
14
+ function _interopNamespaceDefault(e) {
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n.default = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
32
+ var ReactDOM__namespace = /*#__PURE__*/_interopNamespaceDefault(ReactDOM);
33
+
16
34
  var styles = {"content":"QsRc49DHSgA-","hidden":"_7Fd5XGsPpUA-","actions":"yV8-0Hs43J0-","actionPadding":"g3Gdt8jXvFk-","spinning":"dJVYYOaf04E-"};
17
35
 
18
- function useComboboxContent(open, selected) {
19
- const { shouldScroll } = React.useContext(ComboboxProvider.ComboboxContext);
20
- const optionsListRef = React.useRef(null);
21
- React.useEffect(() => {
22
- var _a;
23
- if (open && shouldScroll.current && optionsListRef.current) {
24
- const firstSelected = Array.from((_a = optionsListRef === null || optionsListRef === void 0 ? void 0 : optionsListRef.current) === null || _a === void 0 ? void 0 : _a.children).find(child => {
25
- if (child instanceof HTMLElement) {
26
- return child.dataset.selected === "true";
27
- }
28
- });
29
- scrollToFirstSelected(firstSelected, shouldScroll);
36
+ function useComboboxContent(open, selected) {
37
+ const { shouldScroll } = React.useContext(ComboboxProvider.ComboboxContext);
38
+ const optionsListRef = React.useRef(null);
39
+ React.useEffect(() => {
40
+ var _a;
41
+ if (open && shouldScroll.current && optionsListRef.current) {
42
+ const firstSelected = Array.from((_a = optionsListRef === null || optionsListRef === void 0 ? void 0 : optionsListRef.current) === null || _a === void 0 ? void 0 : _a.children).find(child => {
43
+ if (child instanceof HTMLElement) {
44
+ return child.dataset.selected === "true";
45
+ }
46
+ });
47
+ scrollToFirstSelected(firstSelected, shouldScroll);
48
+ }
49
+ }, [open, selected]);
50
+ return {
51
+ optionsListRef,
52
+ };
53
+ }
54
+ function scrollToFirstSelected(firstSelected, shouldScroll) {
55
+ if (firstSelected) {
56
+ firstSelected.scrollIntoView({
57
+ block: "nearest",
58
+ });
59
+ shouldScroll.current = false;
60
+ }
61
+ }
62
+
63
+ function hasWindow() {
64
+ return typeof window !== 'undefined';
65
+ }
66
+ function getNodeName$1(node) {
67
+ if (isNode$1(node)) {
68
+ return (node.nodeName || '').toLowerCase();
69
+ }
70
+ // Mocked nodes in testing environments may not be instances of Node. By
71
+ // returning `#document` an infinite loop won't occur.
72
+ // https://github.com/floating-ui/floating-ui/issues/2317
73
+ return '#document';
74
+ }
75
+ function getWindow$1(node) {
76
+ var _node$ownerDocument;
77
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
78
+ }
79
+ function getDocumentElement$1(node) {
80
+ var _ref;
81
+ return (_ref = (isNode$1(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
82
+ }
83
+ function isNode$1(value) {
84
+ if (!hasWindow()) {
85
+ return false;
86
+ }
87
+ return value instanceof Node || value instanceof getWindow$1(value).Node;
88
+ }
89
+ function isElement$1(value) {
90
+ if (!hasWindow()) {
91
+ return false;
92
+ }
93
+ return value instanceof Element || value instanceof getWindow$1(value).Element;
94
+ }
95
+ function isHTMLElement$1(value) {
96
+ if (!hasWindow()) {
97
+ return false;
98
+ }
99
+ return value instanceof HTMLElement || value instanceof getWindow$1(value).HTMLElement;
100
+ }
101
+ function isShadowRoot$1(value) {
102
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
103
+ return false;
104
+ }
105
+ return value instanceof ShadowRoot || value instanceof getWindow$1(value).ShadowRoot;
106
+ }
107
+ function isWebKit$1() {
108
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
109
+ return CSS.supports('-webkit-backdrop-filter', 'none');
110
+ }
111
+ function isLastTraversableNode$1(node) {
112
+ return ['html', 'body', '#document'].includes(getNodeName$1(node));
113
+ }
114
+ function getComputedStyle$1(element) {
115
+ return getWindow$1(element).getComputedStyle(element);
116
+ }
117
+ function getParentNode$1(node) {
118
+ if (getNodeName$1(node) === 'html') {
119
+ return node;
120
+ }
121
+ const result =
122
+ // Step into the shadow DOM of the parent of a slotted node.
123
+ node.assignedSlot ||
124
+ // DOM Element detected.
125
+ node.parentNode ||
126
+ // ShadowRoot detected.
127
+ isShadowRoot$1(node) && node.host ||
128
+ // Fallback.
129
+ getDocumentElement$1(node);
130
+ return isShadowRoot$1(result) ? result.host : result;
131
+ }
132
+
133
+ function contains(parent, child) {
134
+ if (!parent || !child) {
135
+ return false;
136
+ }
137
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
138
+
139
+ // First, attempt with faster native method
140
+ if (parent.contains(child)) {
141
+ return true;
142
+ }
143
+
144
+ // then fallback to custom implementation with Shadow DOM support
145
+ if (rootNode && isShadowRoot$1(rootNode)) {
146
+ let next = child;
147
+ while (next) {
148
+ if (parent === next) {
149
+ return true;
150
+ }
151
+ // @ts-ignore
152
+ next = next.parentNode || next.host;
153
+ }
154
+ }
155
+
156
+ // Give up, the result is false
157
+ return false;
158
+ }
159
+ function isReactEvent(event) {
160
+ return 'nativeEvent' in event;
161
+ }
162
+ function isRootElement(element) {
163
+ return element.matches('html,body');
164
+ }
165
+ function getDocument(node) {
166
+ return (node == null ? void 0 : node.ownerDocument) || document;
167
+ }
168
+ function isEventTargetWithin(event, node) {
169
+ if (node == null) {
170
+ return false;
171
+ }
172
+ if ('composedPath' in event) {
173
+ return event.composedPath().includes(node);
174
+ }
175
+
176
+ // TS thinks `event` is of type never as it assumes all browsers support composedPath, but browsers without shadow dom don't
177
+ const e = event;
178
+ return e.target != null && node.contains(e.target);
179
+ }
180
+ function getTarget(event) {
181
+ if ('composedPath' in event) {
182
+ return event.composedPath()[0];
183
+ }
184
+
185
+ // TS thinks `event` is of type never as it assumes all browsers support
186
+ // `composedPath()`, but browsers without shadow DOM don't.
187
+ return event.target;
188
+ }
189
+
190
+ var reactJsxRuntime_production_min = {};
191
+
192
+ /**
193
+ * @license React
194
+ * react-jsx-runtime.production.min.js
195
+ *
196
+ * Copyright (c) Facebook, Inc. and its affiliates.
197
+ *
198
+ * This source code is licensed under the MIT license found in the
199
+ * LICENSE file in the root directory of this source tree.
200
+ */
201
+
202
+ var hasRequiredReactJsxRuntime_production_min;
203
+
204
+ function requireReactJsxRuntime_production_min () {
205
+ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
206
+ hasRequiredReactJsxRuntime_production_min = 1;
207
+ var f=React,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
208
+ function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
209
+ return reactJsxRuntime_production_min;
210
+ }
211
+
212
+ var reactJsxRuntime_development = {};
213
+
214
+ /**
215
+ * @license React
216
+ * react-jsx-runtime.development.js
217
+ *
218
+ * Copyright (c) Facebook, Inc. and its affiliates.
219
+ *
220
+ * This source code is licensed under the MIT license found in the
221
+ * LICENSE file in the root directory of this source tree.
222
+ */
223
+
224
+ var hasRequiredReactJsxRuntime_development;
225
+
226
+ function requireReactJsxRuntime_development () {
227
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
228
+ hasRequiredReactJsxRuntime_development = 1;
229
+
230
+ if (process.env.NODE_ENV !== "production") {
231
+ (function() {
232
+
233
+ var React$1 = React;
234
+
235
+ // ATTENTION
236
+ // When adding new symbols to this file,
237
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
238
+ // The Symbol used to tag the ReactElement-like types.
239
+ var REACT_ELEMENT_TYPE = Symbol.for('react.element');
240
+ var REACT_PORTAL_TYPE = Symbol.for('react.portal');
241
+ var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
242
+ var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
243
+ var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
244
+ var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
245
+ var REACT_CONTEXT_TYPE = Symbol.for('react.context');
246
+ var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
247
+ var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
248
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
249
+ var REACT_MEMO_TYPE = Symbol.for('react.memo');
250
+ var REACT_LAZY_TYPE = Symbol.for('react.lazy');
251
+ var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
252
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
253
+ var FAUX_ITERATOR_SYMBOL = '@@iterator';
254
+ function getIteratorFn(maybeIterable) {
255
+ if (maybeIterable === null || typeof maybeIterable !== 'object') {
256
+ return null;
257
+ }
258
+
259
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
260
+
261
+ if (typeof maybeIterator === 'function') {
262
+ return maybeIterator;
263
+ }
264
+
265
+ return null;
266
+ }
267
+
268
+ var ReactSharedInternals = React$1.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
269
+
270
+ function error(format) {
271
+ {
272
+ {
273
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
274
+ args[_key2 - 1] = arguments[_key2];
275
+ }
276
+
277
+ printWarning('error', format, args);
278
+ }
279
+ }
280
+ }
281
+
282
+ function printWarning(level, format, args) {
283
+ // When changing this logic, you might want to also
284
+ // update consoleWithStackDev.www.js as well.
285
+ {
286
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
287
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
288
+
289
+ if (stack !== '') {
290
+ format += '%s';
291
+ args = args.concat([stack]);
292
+ } // eslint-disable-next-line react-internal/safe-string-coercion
293
+
294
+
295
+ var argsWithFormat = args.map(function (item) {
296
+ return String(item);
297
+ }); // Careful: RN currently depends on this prefix
298
+
299
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
300
+ // breaks IE9: https://github.com/facebook/react/issues/13610
301
+ // eslint-disable-next-line react-internal/no-production-logging
302
+
303
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
304
+ }
305
+ }
306
+
307
+ // -----------------------------------------------------------------------------
308
+
309
+ var enableScopeAPI = false; // Experimental Create Event Handle API.
310
+ var enableCacheElement = false;
311
+ var enableTransitionTracing = false; // No known bugs, but needs performance testing
312
+
313
+ var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
314
+ // stuff. Intended to enable React core members to more easily debug scheduling
315
+ // issues in DEV builds.
316
+
317
+ var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
318
+
319
+ var REACT_MODULE_REFERENCE;
320
+
321
+ {
322
+ REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
323
+ }
324
+
325
+ function isValidElementType(type) {
326
+ if (typeof type === 'string' || typeof type === 'function') {
327
+ return true;
328
+ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
329
+
330
+
331
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
332
+ return true;
333
+ }
334
+
335
+ if (typeof type === 'object' && type !== null) {
336
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
337
+ // types supported by any Flight configuration anywhere since
338
+ // we don't know which Flight build this will end up being used
339
+ // with.
340
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
341
+ return true;
342
+ }
343
+ }
344
+
345
+ return false;
346
+ }
347
+
348
+ function getWrappedName(outerType, innerType, wrapperName) {
349
+ var displayName = outerType.displayName;
350
+
351
+ if (displayName) {
352
+ return displayName;
353
+ }
354
+
355
+ var functionName = innerType.displayName || innerType.name || '';
356
+ return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
357
+ } // Keep in sync with react-reconciler/getComponentNameFromFiber
358
+
359
+
360
+ function getContextName(type) {
361
+ return type.displayName || 'Context';
362
+ } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
363
+
364
+
365
+ function getComponentNameFromType(type) {
366
+ if (type == null) {
367
+ // Host root, text node or just invalid type.
368
+ return null;
369
+ }
370
+
371
+ {
372
+ if (typeof type.tag === 'number') {
373
+ error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
374
+ }
375
+ }
376
+
377
+ if (typeof type === 'function') {
378
+ return type.displayName || type.name || null;
379
+ }
380
+
381
+ if (typeof type === 'string') {
382
+ return type;
383
+ }
384
+
385
+ switch (type) {
386
+ case REACT_FRAGMENT_TYPE:
387
+ return 'Fragment';
388
+
389
+ case REACT_PORTAL_TYPE:
390
+ return 'Portal';
391
+
392
+ case REACT_PROFILER_TYPE:
393
+ return 'Profiler';
394
+
395
+ case REACT_STRICT_MODE_TYPE:
396
+ return 'StrictMode';
397
+
398
+ case REACT_SUSPENSE_TYPE:
399
+ return 'Suspense';
400
+
401
+ case REACT_SUSPENSE_LIST_TYPE:
402
+ return 'SuspenseList';
403
+
404
+ }
405
+
406
+ if (typeof type === 'object') {
407
+ switch (type.$$typeof) {
408
+ case REACT_CONTEXT_TYPE:
409
+ var context = type;
410
+ return getContextName(context) + '.Consumer';
411
+
412
+ case REACT_PROVIDER_TYPE:
413
+ var provider = type;
414
+ return getContextName(provider._context) + '.Provider';
415
+
416
+ case REACT_FORWARD_REF_TYPE:
417
+ return getWrappedName(type, type.render, 'ForwardRef');
418
+
419
+ case REACT_MEMO_TYPE:
420
+ var outerName = type.displayName || null;
421
+
422
+ if (outerName !== null) {
423
+ return outerName;
424
+ }
425
+
426
+ return getComponentNameFromType(type.type) || 'Memo';
427
+
428
+ case REACT_LAZY_TYPE:
429
+ {
430
+ var lazyComponent = type;
431
+ var payload = lazyComponent._payload;
432
+ var init = lazyComponent._init;
433
+
434
+ try {
435
+ return getComponentNameFromType(init(payload));
436
+ } catch (x) {
437
+ return null;
438
+ }
439
+ }
440
+
441
+ // eslint-disable-next-line no-fallthrough
442
+ }
443
+ }
444
+
445
+ return null;
446
+ }
447
+
448
+ var assign = Object.assign;
449
+
450
+ // Helpers to patch console.logs to avoid logging during side-effect free
451
+ // replaying on render function. This currently only patches the object
452
+ // lazily which won't cover if the log function was extracted eagerly.
453
+ // We could also eagerly patch the method.
454
+ var disabledDepth = 0;
455
+ var prevLog;
456
+ var prevInfo;
457
+ var prevWarn;
458
+ var prevError;
459
+ var prevGroup;
460
+ var prevGroupCollapsed;
461
+ var prevGroupEnd;
462
+
463
+ function disabledLog() {}
464
+
465
+ disabledLog.__reactDisabledLog = true;
466
+ function disableLogs() {
467
+ {
468
+ if (disabledDepth === 0) {
469
+ /* eslint-disable react-internal/no-production-logging */
470
+ prevLog = console.log;
471
+ prevInfo = console.info;
472
+ prevWarn = console.warn;
473
+ prevError = console.error;
474
+ prevGroup = console.group;
475
+ prevGroupCollapsed = console.groupCollapsed;
476
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
477
+
478
+ var props = {
479
+ configurable: true,
480
+ enumerable: true,
481
+ value: disabledLog,
482
+ writable: true
483
+ }; // $FlowFixMe Flow thinks console is immutable.
484
+
485
+ Object.defineProperties(console, {
486
+ info: props,
487
+ log: props,
488
+ warn: props,
489
+ error: props,
490
+ group: props,
491
+ groupCollapsed: props,
492
+ groupEnd: props
493
+ });
494
+ /* eslint-enable react-internal/no-production-logging */
495
+ }
496
+
497
+ disabledDepth++;
498
+ }
499
+ }
500
+ function reenableLogs() {
501
+ {
502
+ disabledDepth--;
503
+
504
+ if (disabledDepth === 0) {
505
+ /* eslint-disable react-internal/no-production-logging */
506
+ var props = {
507
+ configurable: true,
508
+ enumerable: true,
509
+ writable: true
510
+ }; // $FlowFixMe Flow thinks console is immutable.
511
+
512
+ Object.defineProperties(console, {
513
+ log: assign({}, props, {
514
+ value: prevLog
515
+ }),
516
+ info: assign({}, props, {
517
+ value: prevInfo
518
+ }),
519
+ warn: assign({}, props, {
520
+ value: prevWarn
521
+ }),
522
+ error: assign({}, props, {
523
+ value: prevError
524
+ }),
525
+ group: assign({}, props, {
526
+ value: prevGroup
527
+ }),
528
+ groupCollapsed: assign({}, props, {
529
+ value: prevGroupCollapsed
530
+ }),
531
+ groupEnd: assign({}, props, {
532
+ value: prevGroupEnd
533
+ })
534
+ });
535
+ /* eslint-enable react-internal/no-production-logging */
536
+ }
537
+
538
+ if (disabledDepth < 0) {
539
+ error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
540
+ }
541
+ }
542
+ }
543
+
544
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
545
+ var prefix;
546
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
547
+ {
548
+ if (prefix === undefined) {
549
+ // Extract the VM specific prefix used by each line.
550
+ try {
551
+ throw Error();
552
+ } catch (x) {
553
+ var match = x.stack.trim().match(/\n( *(at )?)/);
554
+ prefix = match && match[1] || '';
555
+ }
556
+ } // We use the prefix to ensure our stacks line up with native stack frames.
557
+
558
+
559
+ return '\n' + prefix + name;
560
+ }
561
+ }
562
+ var reentry = false;
563
+ var componentFrameCache;
564
+
565
+ {
566
+ var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
567
+ componentFrameCache = new PossiblyWeakMap();
568
+ }
569
+
570
+ function describeNativeComponentFrame(fn, construct) {
571
+ // If something asked for a stack inside a fake render, it should get ignored.
572
+ if ( !fn || reentry) {
573
+ return '';
574
+ }
575
+
576
+ {
577
+ var frame = componentFrameCache.get(fn);
578
+
579
+ if (frame !== undefined) {
580
+ return frame;
581
+ }
582
+ }
583
+
584
+ var control;
585
+ reentry = true;
586
+ var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
587
+
588
+ Error.prepareStackTrace = undefined;
589
+ var previousDispatcher;
590
+
591
+ {
592
+ previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
593
+ // for warnings.
594
+
595
+ ReactCurrentDispatcher.current = null;
596
+ disableLogs();
597
+ }
598
+
599
+ try {
600
+ // This should throw.
601
+ if (construct) {
602
+ // Something should be setting the props in the constructor.
603
+ var Fake = function () {
604
+ throw Error();
605
+ }; // $FlowFixMe
606
+
607
+
608
+ Object.defineProperty(Fake.prototype, 'props', {
609
+ set: function () {
610
+ // We use a throwing setter instead of frozen or non-writable props
611
+ // because that won't throw in a non-strict mode function.
612
+ throw Error();
613
+ }
614
+ });
615
+
616
+ if (typeof Reflect === 'object' && Reflect.construct) {
617
+ // We construct a different control for this case to include any extra
618
+ // frames added by the construct call.
619
+ try {
620
+ Reflect.construct(Fake, []);
621
+ } catch (x) {
622
+ control = x;
623
+ }
624
+
625
+ Reflect.construct(fn, [], Fake);
626
+ } else {
627
+ try {
628
+ Fake.call();
629
+ } catch (x) {
630
+ control = x;
631
+ }
632
+
633
+ fn.call(Fake.prototype);
634
+ }
635
+ } else {
636
+ try {
637
+ throw Error();
638
+ } catch (x) {
639
+ control = x;
640
+ }
641
+
642
+ fn();
643
+ }
644
+ } catch (sample) {
645
+ // This is inlined manually because closure doesn't do it for us.
646
+ if (sample && control && typeof sample.stack === 'string') {
647
+ // This extracts the first frame from the sample that isn't also in the control.
648
+ // Skipping one frame that we assume is the frame that calls the two.
649
+ var sampleLines = sample.stack.split('\n');
650
+ var controlLines = control.stack.split('\n');
651
+ var s = sampleLines.length - 1;
652
+ var c = controlLines.length - 1;
653
+
654
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
655
+ // We expect at least one stack frame to be shared.
656
+ // Typically this will be the root most one. However, stack frames may be
657
+ // cut off due to maximum stack limits. In this case, one maybe cut off
658
+ // earlier than the other. We assume that the sample is longer or the same
659
+ // and there for cut off earlier. So we should find the root most frame in
660
+ // the sample somewhere in the control.
661
+ c--;
662
+ }
663
+
664
+ for (; s >= 1 && c >= 0; s--, c--) {
665
+ // Next we find the first one that isn't the same which should be the
666
+ // frame that called our sample function and the control.
667
+ if (sampleLines[s] !== controlLines[c]) {
668
+ // In V8, the first line is describing the message but other VMs don't.
669
+ // If we're about to return the first line, and the control is also on the same
670
+ // line, that's a pretty good indicator that our sample threw at same line as
671
+ // the control. I.e. before we entered the sample frame. So we ignore this result.
672
+ // This can happen if you passed a class to function component, or non-function.
673
+ if (s !== 1 || c !== 1) {
674
+ do {
675
+ s--;
676
+ c--; // We may still have similar intermediate frames from the construct call.
677
+ // The next one that isn't the same should be our match though.
678
+
679
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
680
+ // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
681
+ var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
682
+ // but we have a user-provided "displayName"
683
+ // splice it in to make the stack more readable.
684
+
685
+
686
+ if (fn.displayName && _frame.includes('<anonymous>')) {
687
+ _frame = _frame.replace('<anonymous>', fn.displayName);
688
+ }
689
+
690
+ {
691
+ if (typeof fn === 'function') {
692
+ componentFrameCache.set(fn, _frame);
693
+ }
694
+ } // Return the line we found.
695
+
696
+
697
+ return _frame;
698
+ }
699
+ } while (s >= 1 && c >= 0);
700
+ }
701
+
702
+ break;
703
+ }
704
+ }
705
+ }
706
+ } finally {
707
+ reentry = false;
708
+
709
+ {
710
+ ReactCurrentDispatcher.current = previousDispatcher;
711
+ reenableLogs();
712
+ }
713
+
714
+ Error.prepareStackTrace = previousPrepareStackTrace;
715
+ } // Fallback to just using the name if we couldn't make it throw.
716
+
717
+
718
+ var name = fn ? fn.displayName || fn.name : '';
719
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
720
+
721
+ {
722
+ if (typeof fn === 'function') {
723
+ componentFrameCache.set(fn, syntheticFrame);
724
+ }
725
+ }
726
+
727
+ return syntheticFrame;
728
+ }
729
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
730
+ {
731
+ return describeNativeComponentFrame(fn, false);
732
+ }
733
+ }
734
+
735
+ function shouldConstruct(Component) {
736
+ var prototype = Component.prototype;
737
+ return !!(prototype && prototype.isReactComponent);
738
+ }
739
+
740
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
741
+
742
+ if (type == null) {
743
+ return '';
744
+ }
745
+
746
+ if (typeof type === 'function') {
747
+ {
748
+ return describeNativeComponentFrame(type, shouldConstruct(type));
749
+ }
750
+ }
751
+
752
+ if (typeof type === 'string') {
753
+ return describeBuiltInComponentFrame(type);
754
+ }
755
+
756
+ switch (type) {
757
+ case REACT_SUSPENSE_TYPE:
758
+ return describeBuiltInComponentFrame('Suspense');
759
+
760
+ case REACT_SUSPENSE_LIST_TYPE:
761
+ return describeBuiltInComponentFrame('SuspenseList');
762
+ }
763
+
764
+ if (typeof type === 'object') {
765
+ switch (type.$$typeof) {
766
+ case REACT_FORWARD_REF_TYPE:
767
+ return describeFunctionComponentFrame(type.render);
768
+
769
+ case REACT_MEMO_TYPE:
770
+ // Memo may contain any component type so we recursively resolve it.
771
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
772
+
773
+ case REACT_LAZY_TYPE:
774
+ {
775
+ var lazyComponent = type;
776
+ var payload = lazyComponent._payload;
777
+ var init = lazyComponent._init;
778
+
779
+ try {
780
+ // Lazy may contain any component type so we recursively resolve it.
781
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
782
+ } catch (x) {}
783
+ }
784
+ }
785
+ }
786
+
787
+ return '';
788
+ }
789
+
790
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
791
+
792
+ var loggedTypeFailures = {};
793
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
794
+
795
+ function setCurrentlyValidatingElement(element) {
796
+ {
797
+ if (element) {
798
+ var owner = element._owner;
799
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
800
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
801
+ } else {
802
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
803
+ }
804
+ }
805
+ }
806
+
807
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
808
+ {
809
+ // $FlowFixMe This is okay but Flow doesn't know it.
810
+ var has = Function.call.bind(hasOwnProperty);
811
+
812
+ for (var typeSpecName in typeSpecs) {
813
+ if (has(typeSpecs, typeSpecName)) {
814
+ var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
815
+ // fail the render phase where it didn't fail before. So we log it.
816
+ // After these have been cleaned up, we'll let them throw.
817
+
818
+ try {
819
+ // This is intentionally an invariant that gets caught. It's the same
820
+ // behavior as without this statement except with a better message.
821
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
822
+ // eslint-disable-next-line react-internal/prod-error-codes
823
+ var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
824
+ err.name = 'Invariant Violation';
825
+ throw err;
826
+ }
827
+
828
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
829
+ } catch (ex) {
830
+ error$1 = ex;
831
+ }
832
+
833
+ if (error$1 && !(error$1 instanceof Error)) {
834
+ setCurrentlyValidatingElement(element);
835
+
836
+ error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
837
+
838
+ setCurrentlyValidatingElement(null);
839
+ }
840
+
841
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
842
+ // Only monitor this failure once because there tends to be a lot of the
843
+ // same error.
844
+ loggedTypeFailures[error$1.message] = true;
845
+ setCurrentlyValidatingElement(element);
846
+
847
+ error('Failed %s type: %s', location, error$1.message);
848
+
849
+ setCurrentlyValidatingElement(null);
850
+ }
851
+ }
852
+ }
853
+ }
854
+ }
855
+
856
+ var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
857
+
858
+ function isArray(a) {
859
+ return isArrayImpl(a);
860
+ }
861
+
862
+ /*
863
+ * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
864
+ * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
865
+ *
866
+ * The functions in this module will throw an easier-to-understand,
867
+ * easier-to-debug exception with a clear errors message message explaining the
868
+ * problem. (Instead of a confusing exception thrown inside the implementation
869
+ * of the `value` object).
870
+ */
871
+ // $FlowFixMe only called in DEV, so void return is not possible.
872
+ function typeName(value) {
873
+ {
874
+ // toStringTag is needed for namespaced types like Temporal.Instant
875
+ var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
876
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
877
+ return type;
878
+ }
879
+ } // $FlowFixMe only called in DEV, so void return is not possible.
880
+
881
+
882
+ function willCoercionThrow(value) {
883
+ {
884
+ try {
885
+ testStringCoercion(value);
886
+ return false;
887
+ } catch (e) {
888
+ return true;
889
+ }
890
+ }
891
+ }
892
+
893
+ function testStringCoercion(value) {
894
+ // If you ended up here by following an exception call stack, here's what's
895
+ // happened: you supplied an object or symbol value to React (as a prop, key,
896
+ // DOM attribute, CSS property, string ref, etc.) and when React tried to
897
+ // coerce it to a string using `'' + value`, an exception was thrown.
898
+ //
899
+ // The most common types that will cause this exception are `Symbol` instances
900
+ // and Temporal objects like `Temporal.Instant`. But any object that has a
901
+ // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
902
+ // exception. (Library authors do this to prevent users from using built-in
903
+ // numeric operators like `+` or comparison operators like `>=` because custom
904
+ // methods are needed to perform accurate arithmetic or comparison.)
905
+ //
906
+ // To fix the problem, coerce this object or symbol value to a string before
907
+ // passing it to React. The most reliable way is usually `String(value)`.
908
+ //
909
+ // To find which value is throwing, check the browser or debugger console.
910
+ // Before this exception was thrown, there should be `console.error` output
911
+ // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
912
+ // problem and how that type was used: key, atrribute, input value prop, etc.
913
+ // In most cases, this console output also shows the component and its
914
+ // ancestor components where the exception happened.
915
+ //
916
+ // eslint-disable-next-line react-internal/safe-string-coercion
917
+ return '' + value;
918
+ }
919
+ function checkKeyStringCoercion(value) {
920
+ {
921
+ if (willCoercionThrow(value)) {
922
+ error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
923
+
924
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
925
+ }
926
+ }
927
+ }
928
+
929
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
930
+ var RESERVED_PROPS = {
931
+ key: true,
932
+ ref: true,
933
+ __self: true,
934
+ __source: true
935
+ };
936
+ var specialPropKeyWarningShown;
937
+ var specialPropRefWarningShown;
938
+ var didWarnAboutStringRefs;
939
+
940
+ {
941
+ didWarnAboutStringRefs = {};
942
+ }
943
+
944
+ function hasValidRef(config) {
945
+ {
946
+ if (hasOwnProperty.call(config, 'ref')) {
947
+ var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
948
+
949
+ if (getter && getter.isReactWarning) {
950
+ return false;
951
+ }
952
+ }
953
+ }
954
+
955
+ return config.ref !== undefined;
956
+ }
957
+
958
+ function hasValidKey(config) {
959
+ {
960
+ if (hasOwnProperty.call(config, 'key')) {
961
+ var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
962
+
963
+ if (getter && getter.isReactWarning) {
964
+ return false;
965
+ }
966
+ }
967
+ }
968
+
969
+ return config.key !== undefined;
970
+ }
971
+
972
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
973
+ {
974
+ if (typeof config.ref === 'string' && ReactCurrentOwner.current && self && ReactCurrentOwner.current.stateNode !== self) {
975
+ var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
976
+
977
+ if (!didWarnAboutStringRefs[componentName]) {
978
+ error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
979
+
980
+ didWarnAboutStringRefs[componentName] = true;
981
+ }
982
+ }
983
+ }
984
+ }
985
+
986
+ function defineKeyPropWarningGetter(props, displayName) {
987
+ {
988
+ var warnAboutAccessingKey = function () {
989
+ if (!specialPropKeyWarningShown) {
990
+ specialPropKeyWarningShown = true;
991
+
992
+ error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
993
+ }
994
+ };
995
+
996
+ warnAboutAccessingKey.isReactWarning = true;
997
+ Object.defineProperty(props, 'key', {
998
+ get: warnAboutAccessingKey,
999
+ configurable: true
1000
+ });
1001
+ }
1002
+ }
1003
+
1004
+ function defineRefPropWarningGetter(props, displayName) {
1005
+ {
1006
+ var warnAboutAccessingRef = function () {
1007
+ if (!specialPropRefWarningShown) {
1008
+ specialPropRefWarningShown = true;
1009
+
1010
+ error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
1011
+ }
1012
+ };
1013
+
1014
+ warnAboutAccessingRef.isReactWarning = true;
1015
+ Object.defineProperty(props, 'ref', {
1016
+ get: warnAboutAccessingRef,
1017
+ configurable: true
1018
+ });
1019
+ }
1020
+ }
1021
+ /**
1022
+ * Factory method to create a new React element. This no longer adheres to
1023
+ * the class pattern, so do not use new to call it. Also, instanceof check
1024
+ * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
1025
+ * if something is a React Element.
1026
+ *
1027
+ * @param {*} type
1028
+ * @param {*} props
1029
+ * @param {*} key
1030
+ * @param {string|object} ref
1031
+ * @param {*} owner
1032
+ * @param {*} self A *temporary* helper to detect places where `this` is
1033
+ * different from the `owner` when React.createElement is called, so that we
1034
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
1035
+ * functions, and as long as `this` and owner are the same, there will be no
1036
+ * change in behavior.
1037
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
1038
+ * indicating filename, line number, and/or other information.
1039
+ * @internal
1040
+ */
1041
+
1042
+
1043
+ var ReactElement = function (type, key, ref, self, source, owner, props) {
1044
+ var element = {
1045
+ // This tag allows us to uniquely identify this as a React Element
1046
+ $$typeof: REACT_ELEMENT_TYPE,
1047
+ // Built-in properties that belong on the element
1048
+ type: type,
1049
+ key: key,
1050
+ ref: ref,
1051
+ props: props,
1052
+ // Record the component responsible for creating this element.
1053
+ _owner: owner
1054
+ };
1055
+
1056
+ {
1057
+ // The validation flag is currently mutative. We put it on
1058
+ // an external backing store so that we can freeze the whole object.
1059
+ // This can be replaced with a WeakMap once they are implemented in
1060
+ // commonly used development environments.
1061
+ element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
1062
+ // the validation flag non-enumerable (where possible, which should
1063
+ // include every environment we run tests in), so the test framework
1064
+ // ignores it.
1065
+
1066
+ Object.defineProperty(element._store, 'validated', {
1067
+ configurable: false,
1068
+ enumerable: false,
1069
+ writable: true,
1070
+ value: false
1071
+ }); // self and source are DEV only properties.
1072
+
1073
+ Object.defineProperty(element, '_self', {
1074
+ configurable: false,
1075
+ enumerable: false,
1076
+ writable: false,
1077
+ value: self
1078
+ }); // Two elements created in two different places should be considered
1079
+ // equal for testing purposes and therefore we hide it from enumeration.
1080
+
1081
+ Object.defineProperty(element, '_source', {
1082
+ configurable: false,
1083
+ enumerable: false,
1084
+ writable: false,
1085
+ value: source
1086
+ });
1087
+
1088
+ if (Object.freeze) {
1089
+ Object.freeze(element.props);
1090
+ Object.freeze(element);
1091
+ }
1092
+ }
1093
+
1094
+ return element;
1095
+ };
1096
+ /**
1097
+ * https://github.com/reactjs/rfcs/pull/107
1098
+ * @param {*} type
1099
+ * @param {object} props
1100
+ * @param {string} key
1101
+ */
1102
+
1103
+ function jsxDEV(type, config, maybeKey, source, self) {
1104
+ {
1105
+ var propName; // Reserved names are extracted
1106
+
1107
+ var props = {};
1108
+ var key = null;
1109
+ var ref = null; // Currently, key can be spread in as a prop. This causes a potential
1110
+ // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
1111
+ // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
1112
+ // but as an intermediary step, we will use jsxDEV for everything except
1113
+ // <div {...props} key="Hi" />, because we aren't currently able to tell if
1114
+ // key is explicitly declared to be undefined or not.
1115
+
1116
+ if (maybeKey !== undefined) {
1117
+ {
1118
+ checkKeyStringCoercion(maybeKey);
1119
+ }
1120
+
1121
+ key = '' + maybeKey;
1122
+ }
1123
+
1124
+ if (hasValidKey(config)) {
1125
+ {
1126
+ checkKeyStringCoercion(config.key);
1127
+ }
1128
+
1129
+ key = '' + config.key;
1130
+ }
1131
+
1132
+ if (hasValidRef(config)) {
1133
+ ref = config.ref;
1134
+ warnIfStringRefCannotBeAutoConverted(config, self);
1135
+ } // Remaining properties are added to a new props object
1136
+
1137
+
1138
+ for (propName in config) {
1139
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
1140
+ props[propName] = config[propName];
1141
+ }
1142
+ } // Resolve default props
1143
+
1144
+
1145
+ if (type && type.defaultProps) {
1146
+ var defaultProps = type.defaultProps;
1147
+
1148
+ for (propName in defaultProps) {
1149
+ if (props[propName] === undefined) {
1150
+ props[propName] = defaultProps[propName];
1151
+ }
1152
+ }
1153
+ }
1154
+
1155
+ if (key || ref) {
1156
+ var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
1157
+
1158
+ if (key) {
1159
+ defineKeyPropWarningGetter(props, displayName);
1160
+ }
1161
+
1162
+ if (ref) {
1163
+ defineRefPropWarningGetter(props, displayName);
1164
+ }
1165
+ }
1166
+
1167
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
1168
+ }
1169
+ }
1170
+
1171
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
1172
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
1173
+
1174
+ function setCurrentlyValidatingElement$1(element) {
1175
+ {
1176
+ if (element) {
1177
+ var owner = element._owner;
1178
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
1179
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
1180
+ } else {
1181
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
1182
+ }
1183
+ }
1184
+ }
1185
+
1186
+ var propTypesMisspellWarningShown;
1187
+
1188
+ {
1189
+ propTypesMisspellWarningShown = false;
1190
+ }
1191
+ /**
1192
+ * Verifies the object is a ReactElement.
1193
+ * See https://reactjs.org/docs/react-api.html#isvalidelement
1194
+ * @param {?object} object
1195
+ * @return {boolean} True if `object` is a ReactElement.
1196
+ * @final
1197
+ */
1198
+
1199
+
1200
+ function isValidElement(object) {
1201
+ {
1202
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1203
+ }
1204
+ }
1205
+
1206
+ function getDeclarationErrorAddendum() {
1207
+ {
1208
+ if (ReactCurrentOwner$1.current) {
1209
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
1210
+
1211
+ if (name) {
1212
+ return '\n\nCheck the render method of `' + name + '`.';
1213
+ }
1214
+ }
1215
+
1216
+ return '';
1217
+ }
1218
+ }
1219
+
1220
+ function getSourceInfoErrorAddendum(source) {
1221
+ {
1222
+ if (source !== undefined) {
1223
+ var fileName = source.fileName.replace(/^.*[\\\/]/, '');
1224
+ var lineNumber = source.lineNumber;
1225
+ return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
1226
+ }
1227
+
1228
+ return '';
1229
+ }
1230
+ }
1231
+ /**
1232
+ * Warn if there's no key explicitly set on dynamic arrays of children or
1233
+ * object keys are not valid. This allows us to keep track of children between
1234
+ * updates.
1235
+ */
1236
+
1237
+
1238
+ var ownerHasKeyUseWarning = {};
1239
+
1240
+ function getCurrentComponentErrorInfo(parentType) {
1241
+ {
1242
+ var info = getDeclarationErrorAddendum();
1243
+
1244
+ if (!info) {
1245
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1246
+
1247
+ if (parentName) {
1248
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1249
+ }
1250
+ }
1251
+
1252
+ return info;
1253
+ }
1254
+ }
1255
+ /**
1256
+ * Warn if the element doesn't have an explicit key assigned to it.
1257
+ * This element is in an array. The array could grow and shrink or be
1258
+ * reordered. All children that haven't already been validated are required to
1259
+ * have a "key" property assigned to it. Error statuses are cached so a warning
1260
+ * will only be shown once.
1261
+ *
1262
+ * @internal
1263
+ * @param {ReactElement} element Element that requires a key.
1264
+ * @param {*} parentType element's parent's type.
1265
+ */
1266
+
1267
+
1268
+ function validateExplicitKey(element, parentType) {
1269
+ {
1270
+ if (!element._store || element._store.validated || element.key != null) {
1271
+ return;
1272
+ }
1273
+
1274
+ element._store.validated = true;
1275
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1276
+
1277
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1278
+ return;
1279
+ }
1280
+
1281
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
1282
+ // property, it may be the creator of the child that's responsible for
1283
+ // assigning it a key.
1284
+
1285
+ var childOwner = '';
1286
+
1287
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
1288
+ // Give the component that originally created this child.
1289
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1290
+ }
1291
+
1292
+ setCurrentlyValidatingElement$1(element);
1293
+
1294
+ error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1295
+
1296
+ setCurrentlyValidatingElement$1(null);
1297
+ }
1298
+ }
1299
+ /**
1300
+ * Ensure that every element either is passed in a static location, in an
1301
+ * array with an explicit keys property defined, or in an object literal
1302
+ * with valid key property.
1303
+ *
1304
+ * @internal
1305
+ * @param {ReactNode} node Statically passed child of any type.
1306
+ * @param {*} parentType node's parent's type.
1307
+ */
1308
+
1309
+
1310
+ function validateChildKeys(node, parentType) {
1311
+ {
1312
+ if (typeof node !== 'object') {
1313
+ return;
1314
+ }
1315
+
1316
+ if (isArray(node)) {
1317
+ for (var i = 0; i < node.length; i++) {
1318
+ var child = node[i];
1319
+
1320
+ if (isValidElement(child)) {
1321
+ validateExplicitKey(child, parentType);
1322
+ }
1323
+ }
1324
+ } else if (isValidElement(node)) {
1325
+ // This element was passed in a valid location.
1326
+ if (node._store) {
1327
+ node._store.validated = true;
1328
+ }
1329
+ } else if (node) {
1330
+ var iteratorFn = getIteratorFn(node);
1331
+
1332
+ if (typeof iteratorFn === 'function') {
1333
+ // Entry iterators used to provide implicit keys,
1334
+ // but now we print a separate warning for them later.
1335
+ if (iteratorFn !== node.entries) {
1336
+ var iterator = iteratorFn.call(node);
1337
+ var step;
1338
+
1339
+ while (!(step = iterator.next()).done) {
1340
+ if (isValidElement(step.value)) {
1341
+ validateExplicitKey(step.value, parentType);
1342
+ }
1343
+ }
1344
+ }
1345
+ }
1346
+ }
1347
+ }
1348
+ }
1349
+ /**
1350
+ * Given an element, validate that its props follow the propTypes definition,
1351
+ * provided by the type.
1352
+ *
1353
+ * @param {ReactElement} element
1354
+ */
1355
+
1356
+
1357
+ function validatePropTypes(element) {
1358
+ {
1359
+ var type = element.type;
1360
+
1361
+ if (type === null || type === undefined || typeof type === 'string') {
1362
+ return;
1363
+ }
1364
+
1365
+ var propTypes;
1366
+
1367
+ if (typeof type === 'function') {
1368
+ propTypes = type.propTypes;
1369
+ } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1370
+ // Inner props are checked in the reconciler.
1371
+ type.$$typeof === REACT_MEMO_TYPE)) {
1372
+ propTypes = type.propTypes;
1373
+ } else {
1374
+ return;
1375
+ }
1376
+
1377
+ if (propTypes) {
1378
+ // Intentionally inside to avoid triggering lazy initializers:
1379
+ var name = getComponentNameFromType(type);
1380
+ checkPropTypes(propTypes, element.props, 'prop', name, element);
1381
+ } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1382
+ propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
1383
+
1384
+ var _name = getComponentNameFromType(type);
1385
+
1386
+ error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
1387
+ }
1388
+
1389
+ if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1390
+ error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1391
+ }
1392
+ }
1393
+ }
1394
+ /**
1395
+ * Given a fragment, validate that it can only be provided with fragment props
1396
+ * @param {ReactElement} fragment
1397
+ */
1398
+
1399
+
1400
+ function validateFragmentProps(fragment) {
1401
+ {
1402
+ var keys = Object.keys(fragment.props);
1403
+
1404
+ for (var i = 0; i < keys.length; i++) {
1405
+ var key = keys[i];
1406
+
1407
+ if (key !== 'children' && key !== 'key') {
1408
+ setCurrentlyValidatingElement$1(fragment);
1409
+
1410
+ error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1411
+
1412
+ setCurrentlyValidatingElement$1(null);
1413
+ break;
1414
+ }
1415
+ }
1416
+
1417
+ if (fragment.ref !== null) {
1418
+ setCurrentlyValidatingElement$1(fragment);
1419
+
1420
+ error('Invalid attribute `ref` supplied to `React.Fragment`.');
1421
+
1422
+ setCurrentlyValidatingElement$1(null);
1423
+ }
1424
+ }
1425
+ }
1426
+
1427
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1428
+ {
1429
+ var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1430
+ // succeed and there will likely be errors in render.
1431
+
1432
+ if (!validType) {
1433
+ var info = '';
1434
+
1435
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1436
+ info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
1437
+ }
1438
+
1439
+ var sourceInfo = getSourceInfoErrorAddendum(source);
1440
+
1441
+ if (sourceInfo) {
1442
+ info += sourceInfo;
1443
+ } else {
1444
+ info += getDeclarationErrorAddendum();
1445
+ }
1446
+
1447
+ var typeString;
1448
+
1449
+ if (type === null) {
1450
+ typeString = 'null';
1451
+ } else if (isArray(type)) {
1452
+ typeString = 'array';
1453
+ } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1454
+ typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
1455
+ info = ' Did you accidentally export a JSX literal instead of a component?';
1456
+ } else {
1457
+ typeString = typeof type;
1458
+ }
1459
+
1460
+ error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1461
+ }
1462
+
1463
+ var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
1464
+ // TODO: Drop this when these are no longer allowed as the type argument.
1465
+
1466
+ if (element == null) {
1467
+ return element;
1468
+ } // Skip key warning if the type isn't valid since our key validation logic
1469
+ // doesn't expect a non-string/function type and can throw confusing errors.
1470
+ // We don't want exception behavior to differ between dev and prod.
1471
+ // (Rendering will throw with a helpful message and as soon as the type is
1472
+ // fixed, the key warnings will appear.)
1473
+
1474
+
1475
+ if (validType) {
1476
+ var children = props.children;
1477
+
1478
+ if (children !== undefined) {
1479
+ if (isStaticChildren) {
1480
+ if (isArray(children)) {
1481
+ for (var i = 0; i < children.length; i++) {
1482
+ validateChildKeys(children[i], type);
1483
+ }
1484
+
1485
+ if (Object.freeze) {
1486
+ Object.freeze(children);
1487
+ }
1488
+ } else {
1489
+ error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
1490
+ }
1491
+ } else {
1492
+ validateChildKeys(children, type);
1493
+ }
1494
+ }
1495
+ }
1496
+
1497
+ if (type === REACT_FRAGMENT_TYPE) {
1498
+ validateFragmentProps(element);
1499
+ } else {
1500
+ validatePropTypes(element);
1501
+ }
1502
+
1503
+ return element;
1504
+ }
1505
+ } // These two functions exist to still get child warnings in dev
1506
+ // even with the prod transform. This means that jsxDEV is purely
1507
+ // opt-in behavior for better messages but that we won't stop
1508
+ // giving you warnings if you use production apis.
1509
+
1510
+ function jsxWithValidationStatic(type, props, key) {
1511
+ {
1512
+ return jsxWithValidation(type, props, key, true);
1513
+ }
1514
+ }
1515
+ function jsxWithValidationDynamic(type, props, key) {
1516
+ {
1517
+ return jsxWithValidation(type, props, key, false);
1518
+ }
1519
+ }
1520
+
1521
+ var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
1522
+ // for now we can ship identical prod functions
1523
+
1524
+ var jsxs = jsxWithValidationStatic ;
1525
+
1526
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1527
+ reactJsxRuntime_development.jsx = jsx;
1528
+ reactJsxRuntime_development.jsxs = jsxs;
1529
+ })();
1530
+ }
1531
+ return reactJsxRuntime_development;
1532
+ }
1533
+
1534
+ if (process.env.NODE_ENV === 'production') {
1535
+ requireReactJsxRuntime_production_min();
1536
+ } else {
1537
+ requireReactJsxRuntime_development();
1538
+ }
1539
+
1540
+ const sides = ['top', 'right', 'bottom', 'left'];
1541
+ const alignments = ['start', 'end'];
1542
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
1543
+ const min = Math.min;
1544
+ const max = Math.max;
1545
+ const round = Math.round;
1546
+ const floor = Math.floor;
1547
+ const createCoords = v => ({
1548
+ x: v,
1549
+ y: v
1550
+ });
1551
+ const oppositeSideMap = {
1552
+ left: 'right',
1553
+ right: 'left',
1554
+ bottom: 'top',
1555
+ top: 'bottom'
1556
+ };
1557
+ const oppositeAlignmentMap = {
1558
+ start: 'end',
1559
+ end: 'start'
1560
+ };
1561
+ function clamp(start, value, end) {
1562
+ return max(start, min(value, end));
1563
+ }
1564
+ function evaluate(value, param) {
1565
+ return typeof value === 'function' ? value(param) : value;
1566
+ }
1567
+ function getSide(placement) {
1568
+ return placement.split('-')[0];
1569
+ }
1570
+ function getAlignment(placement) {
1571
+ return placement.split('-')[1];
1572
+ }
1573
+ function getOppositeAxis(axis) {
1574
+ return axis === 'x' ? 'y' : 'x';
1575
+ }
1576
+ function getAxisLength(axis) {
1577
+ return axis === 'y' ? 'height' : 'width';
1578
+ }
1579
+ function getSideAxis(placement) {
1580
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
1581
+ }
1582
+ function getAlignmentAxis(placement) {
1583
+ return getOppositeAxis(getSideAxis(placement));
1584
+ }
1585
+ function getAlignmentSides(placement, rects, rtl) {
1586
+ if (rtl === void 0) {
1587
+ rtl = false;
1588
+ }
1589
+ const alignment = getAlignment(placement);
1590
+ const alignmentAxis = getAlignmentAxis(placement);
1591
+ const length = getAxisLength(alignmentAxis);
1592
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
1593
+ if (rects.reference[length] > rects.floating[length]) {
1594
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1595
+ }
1596
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1597
+ }
1598
+ function getOppositeAlignmentPlacement(placement) {
1599
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
1600
+ }
1601
+ function getOppositePlacement(placement) {
1602
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
1603
+ }
1604
+ function expandPaddingObject(padding) {
1605
+ return {
1606
+ top: 0,
1607
+ right: 0,
1608
+ bottom: 0,
1609
+ left: 0,
1610
+ ...padding
1611
+ };
1612
+ }
1613
+ function getPaddingObject(padding) {
1614
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
1615
+ top: padding,
1616
+ right: padding,
1617
+ bottom: padding,
1618
+ left: padding
1619
+ };
1620
+ }
1621
+ function rectToClientRect(rect) {
1622
+ return {
1623
+ ...rect,
1624
+ top: rect.y,
1625
+ left: rect.x,
1626
+ right: rect.x + rect.width,
1627
+ bottom: rect.y + rect.height
1628
+ };
1629
+ }
1630
+
1631
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
1632
+ let {
1633
+ reference,
1634
+ floating
1635
+ } = _ref;
1636
+ const sideAxis = getSideAxis(placement);
1637
+ const alignmentAxis = getAlignmentAxis(placement);
1638
+ const alignLength = getAxisLength(alignmentAxis);
1639
+ const side = getSide(placement);
1640
+ const isVertical = sideAxis === 'y';
1641
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
1642
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
1643
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1644
+ let coords;
1645
+ switch (side) {
1646
+ case 'top':
1647
+ coords = {
1648
+ x: commonX,
1649
+ y: reference.y - floating.height
1650
+ };
1651
+ break;
1652
+ case 'bottom':
1653
+ coords = {
1654
+ x: commonX,
1655
+ y: reference.y + reference.height
1656
+ };
1657
+ break;
1658
+ case 'right':
1659
+ coords = {
1660
+ x: reference.x + reference.width,
1661
+ y: commonY
1662
+ };
1663
+ break;
1664
+ case 'left':
1665
+ coords = {
1666
+ x: reference.x - floating.width,
1667
+ y: commonY
1668
+ };
1669
+ break;
1670
+ default:
1671
+ coords = {
1672
+ x: reference.x,
1673
+ y: reference.y
1674
+ };
1675
+ }
1676
+ switch (getAlignment(placement)) {
1677
+ case 'start':
1678
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1679
+ break;
1680
+ case 'end':
1681
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1682
+ break;
1683
+ }
1684
+ return coords;
1685
+ }
1686
+
1687
+ /**
1688
+ * Computes the `x` and `y` coordinates that will place the floating element
1689
+ * next to a reference element when it is given a certain positioning strategy.
1690
+ *
1691
+ * This export does not have any `platform` interface logic. You will need to
1692
+ * write one for the platform you are using Floating UI with.
1693
+ */
1694
+ const computePosition$1 = async (reference, floating, config) => {
1695
+ const {
1696
+ placement = 'bottom',
1697
+ strategy = 'absolute',
1698
+ middleware = [],
1699
+ platform
1700
+ } = config;
1701
+ const validMiddleware = middleware.filter(Boolean);
1702
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1703
+ let rects = await platform.getElementRects({
1704
+ reference,
1705
+ floating,
1706
+ strategy
1707
+ });
1708
+ let {
1709
+ x,
1710
+ y
1711
+ } = computeCoordsFromPlacement(rects, placement, rtl);
1712
+ let statefulPlacement = placement;
1713
+ let middlewareData = {};
1714
+ let resetCount = 0;
1715
+ for (let i = 0; i < validMiddleware.length; i++) {
1716
+ const {
1717
+ name,
1718
+ fn
1719
+ } = validMiddleware[i];
1720
+ const {
1721
+ x: nextX,
1722
+ y: nextY,
1723
+ data,
1724
+ reset
1725
+ } = await fn({
1726
+ x,
1727
+ y,
1728
+ initialPlacement: placement,
1729
+ placement: statefulPlacement,
1730
+ strategy,
1731
+ middlewareData,
1732
+ rects,
1733
+ platform,
1734
+ elements: {
1735
+ reference,
1736
+ floating
1737
+ }
1738
+ });
1739
+ x = nextX != null ? nextX : x;
1740
+ y = nextY != null ? nextY : y;
1741
+ middlewareData = {
1742
+ ...middlewareData,
1743
+ [name]: {
1744
+ ...middlewareData[name],
1745
+ ...data
1746
+ }
1747
+ };
1748
+ if (reset && resetCount <= 50) {
1749
+ resetCount++;
1750
+ if (typeof reset === 'object') {
1751
+ if (reset.placement) {
1752
+ statefulPlacement = reset.placement;
30
1753
  }
31
- }, [open, selected]);
1754
+ if (reset.rects) {
1755
+ rects = reset.rects === true ? await platform.getElementRects({
1756
+ reference,
1757
+ floating,
1758
+ strategy
1759
+ }) : reset.rects;
1760
+ }
1761
+ ({
1762
+ x,
1763
+ y
1764
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1765
+ }
1766
+ i = -1;
1767
+ continue;
1768
+ }
1769
+ }
1770
+ return {
1771
+ x,
1772
+ y,
1773
+ placement: statefulPlacement,
1774
+ strategy,
1775
+ middlewareData
1776
+ };
1777
+ };
1778
+
1779
+ /**
1780
+ * Resolves with an object of overflow side offsets that determine how much the
1781
+ * element is overflowing a given clipping boundary on each side.
1782
+ * - positive = overflowing the boundary by that number of pixels
1783
+ * - negative = how many pixels left before it will overflow
1784
+ * - 0 = lies flush with the boundary
1785
+ * @see https://floating-ui.com/docs/detectOverflow
1786
+ */
1787
+ async function detectOverflow(state, options) {
1788
+ var _await$platform$isEle;
1789
+ if (options === void 0) {
1790
+ options = {};
1791
+ }
1792
+ const {
1793
+ x,
1794
+ y,
1795
+ platform,
1796
+ rects,
1797
+ elements,
1798
+ strategy
1799
+ } = state;
1800
+ const {
1801
+ boundary = 'clippingAncestors',
1802
+ rootBoundary = 'viewport',
1803
+ elementContext = 'floating',
1804
+ altBoundary = false,
1805
+ padding = 0
1806
+ } = evaluate(options, state);
1807
+ const paddingObject = getPaddingObject(padding);
1808
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1809
+ const element = elements[altBoundary ? altContext : elementContext];
1810
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1811
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1812
+ boundary,
1813
+ rootBoundary,
1814
+ strategy
1815
+ }));
1816
+ const rect = elementContext === 'floating' ? {
1817
+ ...rects.floating,
1818
+ x,
1819
+ y
1820
+ } : rects.reference;
1821
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1822
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1823
+ x: 1,
1824
+ y: 1
1825
+ } : {
1826
+ x: 1,
1827
+ y: 1
1828
+ };
1829
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1830
+ rect,
1831
+ offsetParent,
1832
+ strategy
1833
+ }) : rect);
1834
+ return {
1835
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1836
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1837
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1838
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1839
+ };
1840
+ }
1841
+
1842
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
1843
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
1844
+ return allowedPlacementsSortedByAlignment.filter(placement => {
1845
+ if (alignment) {
1846
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
1847
+ }
1848
+ return true;
1849
+ });
1850
+ }
1851
+ /**
1852
+ * Optimizes the visibility of the floating element by choosing the placement
1853
+ * that has the most space available automatically, without needing to specify a
1854
+ * preferred placement. Alternative to `flip`.
1855
+ * @see https://floating-ui.com/docs/autoPlacement
1856
+ */
1857
+ const autoPlacement$1 = function (options) {
1858
+ if (options === void 0) {
1859
+ options = {};
1860
+ }
1861
+ return {
1862
+ name: 'autoPlacement',
1863
+ options,
1864
+ async fn(state) {
1865
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
1866
+ const {
1867
+ rects,
1868
+ middlewareData,
1869
+ placement,
1870
+ platform,
1871
+ elements
1872
+ } = state;
1873
+ const {
1874
+ crossAxis = false,
1875
+ alignment,
1876
+ allowedPlacements = placements,
1877
+ autoAlignment = true,
1878
+ ...detectOverflowOptions
1879
+ } = evaluate(options, state);
1880
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
1881
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1882
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
1883
+ const currentPlacement = placements$1[currentIndex];
1884
+ if (currentPlacement == null) {
1885
+ return {};
1886
+ }
1887
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1888
+
1889
+ // Make `computeCoords` start from the right place.
1890
+ if (placement !== currentPlacement) {
1891
+ return {
1892
+ reset: {
1893
+ placement: placements$1[0]
1894
+ }
1895
+ };
1896
+ }
1897
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
1898
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
1899
+ placement: currentPlacement,
1900
+ overflows: currentOverflows
1901
+ }];
1902
+ const nextPlacement = placements$1[currentIndex + 1];
1903
+
1904
+ // There are more placements to check.
1905
+ if (nextPlacement) {
1906
+ return {
1907
+ data: {
1908
+ index: currentIndex + 1,
1909
+ overflows: allOverflows
1910
+ },
1911
+ reset: {
1912
+ placement: nextPlacement
1913
+ }
1914
+ };
1915
+ }
1916
+ const placementsSortedByMostSpace = allOverflows.map(d => {
1917
+ const alignment = getAlignment(d.placement);
1918
+ return [d.placement, alignment && crossAxis ?
1919
+ // Check along the mainAxis and main crossAxis side.
1920
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
1921
+ // Check only the mainAxis.
1922
+ d.overflows[0], d.overflows];
1923
+ }).sort((a, b) => a[1] - b[1]);
1924
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
1925
+ // Aligned placements should not check their opposite crossAxis
1926
+ // side.
1927
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
1928
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
1929
+ if (resetPlacement !== placement) {
1930
+ return {
1931
+ data: {
1932
+ index: currentIndex + 1,
1933
+ overflows: allOverflows
1934
+ },
1935
+ reset: {
1936
+ placement: resetPlacement
1937
+ }
1938
+ };
1939
+ }
1940
+ return {};
1941
+ }
1942
+ };
1943
+ };
1944
+
1945
+ // For type backwards-compatibility, the `OffsetOptions` type was also
1946
+ // Derivable.
1947
+ async function convertValueToCoords(state, options) {
1948
+ const {
1949
+ placement,
1950
+ platform,
1951
+ elements
1952
+ } = state;
1953
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1954
+ const side = getSide(placement);
1955
+ const alignment = getAlignment(placement);
1956
+ const isVertical = getSideAxis(placement) === 'y';
1957
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1958
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1959
+ const rawValue = evaluate(options, state);
1960
+
1961
+ // eslint-disable-next-line prefer-const
1962
+ let {
1963
+ mainAxis,
1964
+ crossAxis,
1965
+ alignmentAxis
1966
+ } = typeof rawValue === 'number' ? {
1967
+ mainAxis: rawValue,
1968
+ crossAxis: 0,
1969
+ alignmentAxis: null
1970
+ } : {
1971
+ mainAxis: 0,
1972
+ crossAxis: 0,
1973
+ alignmentAxis: null,
1974
+ ...rawValue
1975
+ };
1976
+ if (alignment && typeof alignmentAxis === 'number') {
1977
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1978
+ }
1979
+ return isVertical ? {
1980
+ x: crossAxis * crossAxisMulti,
1981
+ y: mainAxis * mainAxisMulti
1982
+ } : {
1983
+ x: mainAxis * mainAxisMulti,
1984
+ y: crossAxis * crossAxisMulti
1985
+ };
1986
+ }
1987
+
1988
+ /**
1989
+ * Modifies the placement by translating the floating element along the
1990
+ * specified axes.
1991
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1992
+ * object may be passed.
1993
+ * @see https://floating-ui.com/docs/offset
1994
+ */
1995
+ const offset$1 = function (options) {
1996
+ if (options === void 0) {
1997
+ options = 0;
1998
+ }
1999
+ return {
2000
+ name: 'offset',
2001
+ options,
2002
+ async fn(state) {
2003
+ var _middlewareData$offse, _middlewareData$arrow;
2004
+ const {
2005
+ x,
2006
+ y,
2007
+ placement,
2008
+ middlewareData
2009
+ } = state;
2010
+ const diffCoords = await convertValueToCoords(state, options);
2011
+
2012
+ // If the placement is the same and the arrow caused an alignment offset
2013
+ // then we don't need to change the positioning coordinates.
2014
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2015
+ return {};
2016
+ }
2017
+ return {
2018
+ x: x + diffCoords.x,
2019
+ y: y + diffCoords.y,
2020
+ data: {
2021
+ ...diffCoords,
2022
+ placement
2023
+ }
2024
+ };
2025
+ }
2026
+ };
2027
+ };
2028
+
2029
+ /**
2030
+ * Optimizes the visibility of the floating element by shifting it in order to
2031
+ * keep it in view when it will overflow the clipping boundary.
2032
+ * @see https://floating-ui.com/docs/shift
2033
+ */
2034
+ const shift$1 = function (options) {
2035
+ if (options === void 0) {
2036
+ options = {};
2037
+ }
2038
+ return {
2039
+ name: 'shift',
2040
+ options,
2041
+ async fn(state) {
2042
+ const {
2043
+ x,
2044
+ y,
2045
+ placement
2046
+ } = state;
2047
+ const {
2048
+ mainAxis: checkMainAxis = true,
2049
+ crossAxis: checkCrossAxis = false,
2050
+ limiter = {
2051
+ fn: _ref => {
2052
+ let {
2053
+ x,
2054
+ y
2055
+ } = _ref;
2056
+ return {
2057
+ x,
2058
+ y
2059
+ };
2060
+ }
2061
+ },
2062
+ ...detectOverflowOptions
2063
+ } = evaluate(options, state);
2064
+ const coords = {
2065
+ x,
2066
+ y
2067
+ };
2068
+ const overflow = await detectOverflow(state, detectOverflowOptions);
2069
+ const crossAxis = getSideAxis(getSide(placement));
2070
+ const mainAxis = getOppositeAxis(crossAxis);
2071
+ let mainAxisCoord = coords[mainAxis];
2072
+ let crossAxisCoord = coords[crossAxis];
2073
+ if (checkMainAxis) {
2074
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
2075
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
2076
+ const min = mainAxisCoord + overflow[minSide];
2077
+ const max = mainAxisCoord - overflow[maxSide];
2078
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
2079
+ }
2080
+ if (checkCrossAxis) {
2081
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
2082
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
2083
+ const min = crossAxisCoord + overflow[minSide];
2084
+ const max = crossAxisCoord - overflow[maxSide];
2085
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
2086
+ }
2087
+ const limitedCoords = limiter.fn({
2088
+ ...state,
2089
+ [mainAxis]: mainAxisCoord,
2090
+ [crossAxis]: crossAxisCoord
2091
+ });
2092
+ return {
2093
+ ...limitedCoords,
2094
+ data: {
2095
+ x: limitedCoords.x - x,
2096
+ y: limitedCoords.y - y
2097
+ }
2098
+ };
2099
+ }
2100
+ };
2101
+ };
2102
+
2103
+ function getNodeName(node) {
2104
+ if (isNode(node)) {
2105
+ return (node.nodeName || '').toLowerCase();
2106
+ }
2107
+ // Mocked nodes in testing environments may not be instances of Node. By
2108
+ // returning `#document` an infinite loop won't occur.
2109
+ // https://github.com/floating-ui/floating-ui/issues/2317
2110
+ return '#document';
2111
+ }
2112
+ function getWindow(node) {
2113
+ var _node$ownerDocument;
2114
+ return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2115
+ }
2116
+ function getDocumentElement(node) {
2117
+ var _ref;
2118
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2119
+ }
2120
+ function isNode(value) {
2121
+ return value instanceof Node || value instanceof getWindow(value).Node;
2122
+ }
2123
+ function isElement(value) {
2124
+ return value instanceof Element || value instanceof getWindow(value).Element;
2125
+ }
2126
+ function isHTMLElement(value) {
2127
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2128
+ }
2129
+ function isShadowRoot(value) {
2130
+ // Browsers without `ShadowRoot` support.
2131
+ if (typeof ShadowRoot === 'undefined') {
2132
+ return false;
2133
+ }
2134
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2135
+ }
2136
+ function isOverflowElement(element) {
2137
+ const {
2138
+ overflow,
2139
+ overflowX,
2140
+ overflowY,
2141
+ display
2142
+ } = getComputedStyle(element);
2143
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
2144
+ }
2145
+ function isTableElement(element) {
2146
+ return ['table', 'td', 'th'].includes(getNodeName(element));
2147
+ }
2148
+ function isContainingBlock(element) {
2149
+ const webkit = isWebKit();
2150
+ const css = getComputedStyle(element);
2151
+
2152
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2153
+ 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));
2154
+ }
2155
+ function getContainingBlock(element) {
2156
+ let currentNode = getParentNode(element);
2157
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2158
+ if (isContainingBlock(currentNode)) {
2159
+ return currentNode;
2160
+ } else {
2161
+ currentNode = getParentNode(currentNode);
2162
+ }
2163
+ }
2164
+ return null;
2165
+ }
2166
+ function isWebKit() {
2167
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
2168
+ return CSS.supports('-webkit-backdrop-filter', 'none');
2169
+ }
2170
+ function isLastTraversableNode(node) {
2171
+ return ['html', 'body', '#document'].includes(getNodeName(node));
2172
+ }
2173
+ function getComputedStyle(element) {
2174
+ return getWindow(element).getComputedStyle(element);
2175
+ }
2176
+ function getNodeScroll(element) {
2177
+ if (isElement(element)) {
32
2178
  return {
33
- optionsListRef,
2179
+ scrollLeft: element.scrollLeft,
2180
+ scrollTop: element.scrollTop
34
2181
  };
2182
+ }
2183
+ return {
2184
+ scrollLeft: element.pageXOffset,
2185
+ scrollTop: element.pageYOffset
2186
+ };
35
2187
  }
36
- function scrollToFirstSelected(firstSelected, shouldScroll) {
37
- if (firstSelected) {
38
- firstSelected.scrollIntoView({
39
- block: "nearest",
2188
+ function getParentNode(node) {
2189
+ if (getNodeName(node) === 'html') {
2190
+ return node;
2191
+ }
2192
+ const result =
2193
+ // Step into the shadow DOM of the parent of a slotted node.
2194
+ node.assignedSlot ||
2195
+ // DOM Element detected.
2196
+ node.parentNode ||
2197
+ // ShadowRoot detected.
2198
+ isShadowRoot(node) && node.host ||
2199
+ // Fallback.
2200
+ getDocumentElement(node);
2201
+ return isShadowRoot(result) ? result.host : result;
2202
+ }
2203
+ function getNearestOverflowAncestor(node) {
2204
+ const parentNode = getParentNode(node);
2205
+ if (isLastTraversableNode(parentNode)) {
2206
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
2207
+ }
2208
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2209
+ return parentNode;
2210
+ }
2211
+ return getNearestOverflowAncestor(parentNode);
2212
+ }
2213
+ function getOverflowAncestors(node, list, traverseIframes) {
2214
+ var _node$ownerDocument2;
2215
+ if (list === void 0) {
2216
+ list = [];
2217
+ }
2218
+ if (traverseIframes === void 0) {
2219
+ traverseIframes = true;
2220
+ }
2221
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2222
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2223
+ const win = getWindow(scrollableAncestor);
2224
+ if (isBody) {
2225
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
2226
+ }
2227
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2228
+ }
2229
+
2230
+ function getCssDimensions(element) {
2231
+ const css = getComputedStyle(element);
2232
+ // In testing environments, the `width` and `height` properties are empty
2233
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2234
+ let width = parseFloat(css.width) || 0;
2235
+ let height = parseFloat(css.height) || 0;
2236
+ const hasOffset = isHTMLElement(element);
2237
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2238
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2239
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2240
+ if (shouldFallback) {
2241
+ width = offsetWidth;
2242
+ height = offsetHeight;
2243
+ }
2244
+ return {
2245
+ width,
2246
+ height,
2247
+ $: shouldFallback
2248
+ };
2249
+ }
2250
+
2251
+ function unwrapElement(element) {
2252
+ return !isElement(element) ? element.contextElement : element;
2253
+ }
2254
+
2255
+ function getScale(element) {
2256
+ const domElement = unwrapElement(element);
2257
+ if (!isHTMLElement(domElement)) {
2258
+ return createCoords(1);
2259
+ }
2260
+ const rect = domElement.getBoundingClientRect();
2261
+ const {
2262
+ width,
2263
+ height,
2264
+ $
2265
+ } = getCssDimensions(domElement);
2266
+ let x = ($ ? round(rect.width) : rect.width) / width;
2267
+ let y = ($ ? round(rect.height) : rect.height) / height;
2268
+
2269
+ // 0, NaN, or Infinity should always fallback to 1.
2270
+
2271
+ if (!x || !Number.isFinite(x)) {
2272
+ x = 1;
2273
+ }
2274
+ if (!y || !Number.isFinite(y)) {
2275
+ y = 1;
2276
+ }
2277
+ return {
2278
+ x,
2279
+ y
2280
+ };
2281
+ }
2282
+
2283
+ const noOffsets = /*#__PURE__*/createCoords(0);
2284
+ function getVisualOffsets(element) {
2285
+ const win = getWindow(element);
2286
+ if (!isWebKit() || !win.visualViewport) {
2287
+ return noOffsets;
2288
+ }
2289
+ return {
2290
+ x: win.visualViewport.offsetLeft,
2291
+ y: win.visualViewport.offsetTop
2292
+ };
2293
+ }
2294
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2295
+ if (isFixed === void 0) {
2296
+ isFixed = false;
2297
+ }
2298
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2299
+ return false;
2300
+ }
2301
+ return isFixed;
2302
+ }
2303
+
2304
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2305
+ if (includeScale === void 0) {
2306
+ includeScale = false;
2307
+ }
2308
+ if (isFixedStrategy === void 0) {
2309
+ isFixedStrategy = false;
2310
+ }
2311
+ const clientRect = element.getBoundingClientRect();
2312
+ const domElement = unwrapElement(element);
2313
+ let scale = createCoords(1);
2314
+ if (includeScale) {
2315
+ if (offsetParent) {
2316
+ if (isElement(offsetParent)) {
2317
+ scale = getScale(offsetParent);
2318
+ }
2319
+ } else {
2320
+ scale = getScale(element);
2321
+ }
2322
+ }
2323
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2324
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
2325
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
2326
+ let width = clientRect.width / scale.x;
2327
+ let height = clientRect.height / scale.y;
2328
+ if (domElement) {
2329
+ const win = getWindow(domElement);
2330
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2331
+ let currentIFrame = win.frameElement;
2332
+ while (currentIFrame && offsetParent && offsetWin !== win) {
2333
+ const iframeScale = getScale(currentIFrame);
2334
+ const iframeRect = currentIFrame.getBoundingClientRect();
2335
+ const css = getComputedStyle(currentIFrame);
2336
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2337
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2338
+ x *= iframeScale.x;
2339
+ y *= iframeScale.y;
2340
+ width *= iframeScale.x;
2341
+ height *= iframeScale.y;
2342
+ x += left;
2343
+ y += top;
2344
+ currentIFrame = getWindow(currentIFrame).frameElement;
2345
+ }
2346
+ }
2347
+ return rectToClientRect({
2348
+ width,
2349
+ height,
2350
+ x,
2351
+ y
2352
+ });
2353
+ }
2354
+
2355
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2356
+ let {
2357
+ rect,
2358
+ offsetParent,
2359
+ strategy
2360
+ } = _ref;
2361
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2362
+ const documentElement = getDocumentElement(offsetParent);
2363
+ if (offsetParent === documentElement) {
2364
+ return rect;
2365
+ }
2366
+ let scroll = {
2367
+ scrollLeft: 0,
2368
+ scrollTop: 0
2369
+ };
2370
+ let scale = createCoords(1);
2371
+ const offsets = createCoords(0);
2372
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
2373
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2374
+ scroll = getNodeScroll(offsetParent);
2375
+ }
2376
+ if (isHTMLElement(offsetParent)) {
2377
+ const offsetRect = getBoundingClientRect(offsetParent);
2378
+ scale = getScale(offsetParent);
2379
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2380
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2381
+ }
2382
+ }
2383
+ return {
2384
+ width: rect.width * scale.x,
2385
+ height: rect.height * scale.y,
2386
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2387
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2388
+ };
2389
+ }
2390
+
2391
+ function getClientRects(element) {
2392
+ return Array.from(element.getClientRects());
2393
+ }
2394
+
2395
+ function getWindowScrollBarX(element) {
2396
+ // If <html> has a CSS width greater than the viewport, then this will be
2397
+ // incorrect for RTL.
2398
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
2399
+ }
2400
+
2401
+ // Gets the entire size of the scrollable document area, even extending outside
2402
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2403
+ function getDocumentRect(element) {
2404
+ const html = getDocumentElement(element);
2405
+ const scroll = getNodeScroll(element);
2406
+ const body = element.ownerDocument.body;
2407
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2408
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2409
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2410
+ const y = -scroll.scrollTop;
2411
+ if (getComputedStyle(body).direction === 'rtl') {
2412
+ x += max(html.clientWidth, body.clientWidth) - width;
2413
+ }
2414
+ return {
2415
+ width,
2416
+ height,
2417
+ x,
2418
+ y
2419
+ };
2420
+ }
2421
+
2422
+ function getViewportRect(element, strategy) {
2423
+ const win = getWindow(element);
2424
+ const html = getDocumentElement(element);
2425
+ const visualViewport = win.visualViewport;
2426
+ let width = html.clientWidth;
2427
+ let height = html.clientHeight;
2428
+ let x = 0;
2429
+ let y = 0;
2430
+ if (visualViewport) {
2431
+ width = visualViewport.width;
2432
+ height = visualViewport.height;
2433
+ const visualViewportBased = isWebKit();
2434
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
2435
+ x = visualViewport.offsetLeft;
2436
+ y = visualViewport.offsetTop;
2437
+ }
2438
+ }
2439
+ return {
2440
+ width,
2441
+ height,
2442
+ x,
2443
+ y
2444
+ };
2445
+ }
2446
+
2447
+ // Returns the inner client rect, subtracting scrollbars if present.
2448
+ function getInnerBoundingClientRect(element, strategy) {
2449
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
2450
+ const top = clientRect.top + element.clientTop;
2451
+ const left = clientRect.left + element.clientLeft;
2452
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2453
+ const width = element.clientWidth * scale.x;
2454
+ const height = element.clientHeight * scale.y;
2455
+ const x = left * scale.x;
2456
+ const y = top * scale.y;
2457
+ return {
2458
+ width,
2459
+ height,
2460
+ x,
2461
+ y
2462
+ };
2463
+ }
2464
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2465
+ let rect;
2466
+ if (clippingAncestor === 'viewport') {
2467
+ rect = getViewportRect(element, strategy);
2468
+ } else if (clippingAncestor === 'document') {
2469
+ rect = getDocumentRect(getDocumentElement(element));
2470
+ } else if (isElement(clippingAncestor)) {
2471
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2472
+ } else {
2473
+ const visualOffsets = getVisualOffsets(element);
2474
+ rect = {
2475
+ ...clippingAncestor,
2476
+ x: clippingAncestor.x - visualOffsets.x,
2477
+ y: clippingAncestor.y - visualOffsets.y
2478
+ };
2479
+ }
2480
+ return rectToClientRect(rect);
2481
+ }
2482
+ function hasFixedPositionAncestor(element, stopNode) {
2483
+ const parentNode = getParentNode(element);
2484
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2485
+ return false;
2486
+ }
2487
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
2488
+ }
2489
+
2490
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
2491
+ // clipping (or hiding) child elements. This returns all clipping ancestors
2492
+ // of the given element up the tree.
2493
+ function getClippingElementAncestors(element, cache) {
2494
+ const cachedResult = cache.get(element);
2495
+ if (cachedResult) {
2496
+ return cachedResult;
2497
+ }
2498
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
2499
+ let currentContainingBlockComputedStyle = null;
2500
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
2501
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2502
+
2503
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2504
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2505
+ const computedStyle = getComputedStyle(currentNode);
2506
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2507
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
2508
+ currentContainingBlockComputedStyle = null;
2509
+ }
2510
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2511
+ if (shouldDropCurrentNode) {
2512
+ // Drop non-containing blocks.
2513
+ result = result.filter(ancestor => ancestor !== currentNode);
2514
+ } else {
2515
+ // Record last containing block for next iteration.
2516
+ currentContainingBlockComputedStyle = computedStyle;
2517
+ }
2518
+ currentNode = getParentNode(currentNode);
2519
+ }
2520
+ cache.set(element, result);
2521
+ return result;
2522
+ }
2523
+
2524
+ // Gets the maximum area that the element is visible in due to any number of
2525
+ // clipping ancestors.
2526
+ function getClippingRect(_ref) {
2527
+ let {
2528
+ element,
2529
+ boundary,
2530
+ rootBoundary,
2531
+ strategy
2532
+ } = _ref;
2533
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
2534
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2535
+ const firstClippingAncestor = clippingAncestors[0];
2536
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2537
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2538
+ accRect.top = max(rect.top, accRect.top);
2539
+ accRect.right = min(rect.right, accRect.right);
2540
+ accRect.bottom = min(rect.bottom, accRect.bottom);
2541
+ accRect.left = max(rect.left, accRect.left);
2542
+ return accRect;
2543
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2544
+ return {
2545
+ width: clippingRect.right - clippingRect.left,
2546
+ height: clippingRect.bottom - clippingRect.top,
2547
+ x: clippingRect.left,
2548
+ y: clippingRect.top
2549
+ };
2550
+ }
2551
+
2552
+ function getDimensions(element) {
2553
+ return getCssDimensions(element);
2554
+ }
2555
+
2556
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2557
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2558
+ const documentElement = getDocumentElement(offsetParent);
2559
+ const isFixed = strategy === 'fixed';
2560
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2561
+ let scroll = {
2562
+ scrollLeft: 0,
2563
+ scrollTop: 0
2564
+ };
2565
+ const offsets = createCoords(0);
2566
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2567
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2568
+ scroll = getNodeScroll(offsetParent);
2569
+ }
2570
+ if (isOffsetParentAnElement) {
2571
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2572
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2573
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2574
+ } else if (documentElement) {
2575
+ offsets.x = getWindowScrollBarX(documentElement);
2576
+ }
2577
+ }
2578
+ return {
2579
+ x: rect.left + scroll.scrollLeft - offsets.x,
2580
+ y: rect.top + scroll.scrollTop - offsets.y,
2581
+ width: rect.width,
2582
+ height: rect.height
2583
+ };
2584
+ }
2585
+
2586
+ function getTrueOffsetParent(element, polyfill) {
2587
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
2588
+ return null;
2589
+ }
2590
+ if (polyfill) {
2591
+ return polyfill(element);
2592
+ }
2593
+ return element.offsetParent;
2594
+ }
2595
+
2596
+ // Gets the closest ancestor positioned element. Handles some edge cases,
2597
+ // such as table ancestors and cross browser bugs.
2598
+ function getOffsetParent(element, polyfill) {
2599
+ const window = getWindow(element);
2600
+ if (!isHTMLElement(element)) {
2601
+ return window;
2602
+ }
2603
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2604
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
2605
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2606
+ }
2607
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
2608
+ return window;
2609
+ }
2610
+ return offsetParent || getContainingBlock(element) || window;
2611
+ }
2612
+
2613
+ const getElementRects = async function (_ref) {
2614
+ let {
2615
+ reference,
2616
+ floating,
2617
+ strategy
2618
+ } = _ref;
2619
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2620
+ const getDimensionsFn = this.getDimensions;
2621
+ return {
2622
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
2623
+ floating: {
2624
+ x: 0,
2625
+ y: 0,
2626
+ ...(await getDimensionsFn(floating))
2627
+ }
2628
+ };
2629
+ };
2630
+
2631
+ function isRTL(element) {
2632
+ return getComputedStyle(element).direction === 'rtl';
2633
+ }
2634
+
2635
+ const platform = {
2636
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2637
+ getDocumentElement,
2638
+ getClippingRect,
2639
+ getOffsetParent,
2640
+ getElementRects,
2641
+ getClientRects,
2642
+ getDimensions,
2643
+ getScale,
2644
+ isElement,
2645
+ isRTL
2646
+ };
2647
+
2648
+ // https://samthor.au/2021/observing-dom/
2649
+ function observeMove(element, onMove) {
2650
+ let io = null;
2651
+ let timeoutId;
2652
+ const root = getDocumentElement(element);
2653
+ function cleanup() {
2654
+ clearTimeout(timeoutId);
2655
+ io && io.disconnect();
2656
+ io = null;
2657
+ }
2658
+ function refresh(skip, threshold) {
2659
+ if (skip === void 0) {
2660
+ skip = false;
2661
+ }
2662
+ if (threshold === void 0) {
2663
+ threshold = 1;
2664
+ }
2665
+ cleanup();
2666
+ const {
2667
+ left,
2668
+ top,
2669
+ width,
2670
+ height
2671
+ } = element.getBoundingClientRect();
2672
+ if (!skip) {
2673
+ onMove();
2674
+ }
2675
+ if (!width || !height) {
2676
+ return;
2677
+ }
2678
+ const insetTop = floor(top);
2679
+ const insetRight = floor(root.clientWidth - (left + width));
2680
+ const insetBottom = floor(root.clientHeight - (top + height));
2681
+ const insetLeft = floor(left);
2682
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2683
+ const options = {
2684
+ rootMargin,
2685
+ threshold: max(0, min(1, threshold)) || 1
2686
+ };
2687
+ let isFirstUpdate = true;
2688
+ function handleObserve(entries) {
2689
+ const ratio = entries[0].intersectionRatio;
2690
+ if (ratio !== threshold) {
2691
+ if (!isFirstUpdate) {
2692
+ return refresh();
2693
+ }
2694
+ if (!ratio) {
2695
+ timeoutId = setTimeout(() => {
2696
+ refresh(false, 1e-7);
2697
+ }, 100);
2698
+ } else {
2699
+ refresh(false, ratio);
2700
+ }
2701
+ }
2702
+ isFirstUpdate = false;
2703
+ }
2704
+
2705
+ // Older browsers don't support a `document` as the root and will throw an
2706
+ // error.
2707
+ try {
2708
+ io = new IntersectionObserver(handleObserve, {
2709
+ ...options,
2710
+ // Handle <iframe>s
2711
+ root: root.ownerDocument
2712
+ });
2713
+ } catch (e) {
2714
+ io = new IntersectionObserver(handleObserve, options);
2715
+ }
2716
+ io.observe(element);
2717
+ }
2718
+ refresh(true);
2719
+ return cleanup;
2720
+ }
2721
+
2722
+ /**
2723
+ * Automatically updates the position of the floating element when necessary.
2724
+ * Should only be called when the floating element is mounted on the DOM or
2725
+ * visible on the screen.
2726
+ * @returns cleanup function that should be invoked when the floating element is
2727
+ * removed from the DOM or hidden from the screen.
2728
+ * @see https://floating-ui.com/docs/autoUpdate
2729
+ */
2730
+ function autoUpdate(reference, floating, update, options) {
2731
+ if (options === void 0) {
2732
+ options = {};
2733
+ }
2734
+ const {
2735
+ ancestorScroll = true,
2736
+ ancestorResize = true,
2737
+ elementResize = typeof ResizeObserver === 'function',
2738
+ layoutShift = typeof IntersectionObserver === 'function',
2739
+ animationFrame = false
2740
+ } = options;
2741
+ const referenceEl = unwrapElement(reference);
2742
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
2743
+ ancestors.forEach(ancestor => {
2744
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
2745
+ passive: true
2746
+ });
2747
+ ancestorResize && ancestor.addEventListener('resize', update);
2748
+ });
2749
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2750
+ let reobserveFrame = -1;
2751
+ let resizeObserver = null;
2752
+ if (elementResize) {
2753
+ resizeObserver = new ResizeObserver(_ref => {
2754
+ let [firstEntry] = _ref;
2755
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2756
+ // Prevent update loops when using the `size` middleware.
2757
+ // https://github.com/floating-ui/floating-ui/issues/1740
2758
+ resizeObserver.unobserve(floating);
2759
+ cancelAnimationFrame(reobserveFrame);
2760
+ reobserveFrame = requestAnimationFrame(() => {
2761
+ resizeObserver && resizeObserver.observe(floating);
40
2762
  });
41
- shouldScroll.current = false;
2763
+ }
2764
+ update();
2765
+ });
2766
+ if (referenceEl && !animationFrame) {
2767
+ resizeObserver.observe(referenceEl);
2768
+ }
2769
+ resizeObserver.observe(floating);
2770
+ }
2771
+ let frameId;
2772
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2773
+ if (animationFrame) {
2774
+ frameLoop();
2775
+ }
2776
+ function frameLoop() {
2777
+ const nextRefRect = getBoundingClientRect(reference);
2778
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2779
+ update();
2780
+ }
2781
+ prevRefRect = nextRefRect;
2782
+ frameId = requestAnimationFrame(frameLoop);
2783
+ }
2784
+ update();
2785
+ return () => {
2786
+ ancestors.forEach(ancestor => {
2787
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
2788
+ ancestorResize && ancestor.removeEventListener('resize', update);
2789
+ });
2790
+ cleanupIo && cleanupIo();
2791
+ resizeObserver && resizeObserver.disconnect();
2792
+ resizeObserver = null;
2793
+ if (animationFrame) {
2794
+ cancelAnimationFrame(frameId);
2795
+ }
2796
+ };
2797
+ }
2798
+
2799
+ /**
2800
+ * Computes the `x` and `y` coordinates that will place the floating element
2801
+ * next to a reference element when it is given a certain CSS positioning
2802
+ * strategy.
2803
+ */
2804
+ const computePosition = (reference, floating, options) => {
2805
+ // This caches the expensive `getClippingElementAncestors` function so that
2806
+ // multiple lifecycle resets re-use the same result. It only lives for a
2807
+ // single call. If other functions become expensive, we can add them as well.
2808
+ const cache = new Map();
2809
+ const mergedOptions = {
2810
+ platform,
2811
+ ...options
2812
+ };
2813
+ const platformWithCache = {
2814
+ ...mergedOptions.platform,
2815
+ _c: cache
2816
+ };
2817
+ return computePosition$1(reference, floating, {
2818
+ ...mergedOptions,
2819
+ platform: platformWithCache
2820
+ });
2821
+ };
2822
+
2823
+ var index$1 = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
2824
+
2825
+ // Fork of `fast-deep-equal` that only does the comparisons we need and compares
2826
+ // functions
2827
+ function deepEqual(a, b) {
2828
+ if (a === b) {
2829
+ return true;
2830
+ }
2831
+ if (typeof a !== typeof b) {
2832
+ return false;
2833
+ }
2834
+ if (typeof a === 'function' && a.toString() === b.toString()) {
2835
+ return true;
2836
+ }
2837
+ let length;
2838
+ let i;
2839
+ let keys;
2840
+ if (a && b && typeof a === 'object') {
2841
+ if (Array.isArray(a)) {
2842
+ length = a.length;
2843
+ if (length !== b.length) return false;
2844
+ for (i = length; i-- !== 0;) {
2845
+ if (!deepEqual(a[i], b[i])) {
2846
+ return false;
2847
+ }
2848
+ }
2849
+ return true;
2850
+ }
2851
+ keys = Object.keys(a);
2852
+ length = keys.length;
2853
+ if (length !== Object.keys(b).length) {
2854
+ return false;
2855
+ }
2856
+ for (i = length; i-- !== 0;) {
2857
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
2858
+ return false;
2859
+ }
2860
+ }
2861
+ for (i = length; i-- !== 0;) {
2862
+ const key = keys[i];
2863
+ if (key === '_owner' && a.$$typeof) {
2864
+ continue;
2865
+ }
2866
+ if (!deepEqual(a[key], b[key])) {
2867
+ return false;
2868
+ }
2869
+ }
2870
+ return true;
2871
+ }
2872
+ return a !== a && b !== b;
2873
+ }
2874
+
2875
+ function getDPR(element) {
2876
+ if (typeof window === 'undefined') {
2877
+ return 1;
2878
+ }
2879
+ const win = element.ownerDocument.defaultView || window;
2880
+ return win.devicePixelRatio || 1;
2881
+ }
2882
+
2883
+ function roundByDPR(element, value) {
2884
+ const dpr = getDPR(element);
2885
+ return Math.round(value * dpr) / dpr;
2886
+ }
2887
+
2888
+ function useLatestRef(value) {
2889
+ const ref = React__namespace.useRef(value);
2890
+ index$1(() => {
2891
+ ref.current = value;
2892
+ });
2893
+ return ref;
2894
+ }
2895
+
2896
+ /**
2897
+ * Provides data to position a floating element.
2898
+ * @see https://floating-ui.com/docs/useFloating
2899
+ */
2900
+ function useFloating$1(options) {
2901
+ if (options === void 0) {
2902
+ options = {};
2903
+ }
2904
+ const {
2905
+ placement = 'bottom',
2906
+ strategy = 'absolute',
2907
+ middleware = [],
2908
+ platform,
2909
+ elements: {
2910
+ reference: externalReference,
2911
+ floating: externalFloating
2912
+ } = {},
2913
+ transform = true,
2914
+ whileElementsMounted,
2915
+ open
2916
+ } = options;
2917
+ const [data, setData] = React__namespace.useState({
2918
+ x: 0,
2919
+ y: 0,
2920
+ strategy,
2921
+ placement,
2922
+ middlewareData: {},
2923
+ isPositioned: false
2924
+ });
2925
+ const [latestMiddleware, setLatestMiddleware] = React__namespace.useState(middleware);
2926
+ if (!deepEqual(latestMiddleware, middleware)) {
2927
+ setLatestMiddleware(middleware);
2928
+ }
2929
+ const [_reference, _setReference] = React__namespace.useState(null);
2930
+ const [_floating, _setFloating] = React__namespace.useState(null);
2931
+ const setReference = React__namespace.useCallback(node => {
2932
+ if (node !== referenceRef.current) {
2933
+ referenceRef.current = node;
2934
+ _setReference(node);
2935
+ }
2936
+ }, []);
2937
+ const setFloating = React__namespace.useCallback(node => {
2938
+ if (node !== floatingRef.current) {
2939
+ floatingRef.current = node;
2940
+ _setFloating(node);
2941
+ }
2942
+ }, []);
2943
+ const referenceEl = externalReference || _reference;
2944
+ const floatingEl = externalFloating || _floating;
2945
+ const referenceRef = React__namespace.useRef(null);
2946
+ const floatingRef = React__namespace.useRef(null);
2947
+ const dataRef = React__namespace.useRef(data);
2948
+ const hasWhileElementsMounted = whileElementsMounted != null;
2949
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2950
+ const platformRef = useLatestRef(platform);
2951
+ const openRef = useLatestRef(open);
2952
+ const update = React__namespace.useCallback(() => {
2953
+ if (!referenceRef.current || !floatingRef.current) {
2954
+ return;
2955
+ }
2956
+ const config = {
2957
+ placement,
2958
+ strategy,
2959
+ middleware: latestMiddleware
2960
+ };
2961
+ if (platformRef.current) {
2962
+ config.platform = platformRef.current;
2963
+ }
2964
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
2965
+ const fullData = {
2966
+ ...data,
2967
+ // The floating element's position may be recomputed while it's closed
2968
+ // but still mounted (such as when transitioning out). To ensure
2969
+ // `isPositioned` will be `false` initially on the next open, avoid
2970
+ // setting it to `true` when `open === false` (must be specified).
2971
+ isPositioned: openRef.current !== false
2972
+ };
2973
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2974
+ dataRef.current = fullData;
2975
+ ReactDOM__namespace.flushSync(() => {
2976
+ setData(fullData);
2977
+ });
2978
+ }
2979
+ });
2980
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2981
+ index$1(() => {
2982
+ if (open === false && dataRef.current.isPositioned) {
2983
+ dataRef.current.isPositioned = false;
2984
+ setData(data => ({
2985
+ ...data,
2986
+ isPositioned: false
2987
+ }));
2988
+ }
2989
+ }, [open]);
2990
+ const isMountedRef = React__namespace.useRef(false);
2991
+ index$1(() => {
2992
+ isMountedRef.current = true;
2993
+ return () => {
2994
+ isMountedRef.current = false;
2995
+ };
2996
+ }, []);
2997
+ index$1(() => {
2998
+ if (referenceEl) referenceRef.current = referenceEl;
2999
+ if (floatingEl) floatingRef.current = floatingEl;
3000
+ if (referenceEl && floatingEl) {
3001
+ if (whileElementsMountedRef.current) {
3002
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
3003
+ }
3004
+ update();
3005
+ }
3006
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
3007
+ const refs = React__namespace.useMemo(() => ({
3008
+ reference: referenceRef,
3009
+ floating: floatingRef,
3010
+ setReference,
3011
+ setFloating
3012
+ }), [setReference, setFloating]);
3013
+ const elements = React__namespace.useMemo(() => ({
3014
+ reference: referenceEl,
3015
+ floating: floatingEl
3016
+ }), [referenceEl, floatingEl]);
3017
+ const floatingStyles = React__namespace.useMemo(() => {
3018
+ const initialStyles = {
3019
+ position: strategy,
3020
+ left: 0,
3021
+ top: 0
3022
+ };
3023
+ if (!elements.floating) {
3024
+ return initialStyles;
3025
+ }
3026
+ const x = roundByDPR(elements.floating, data.x);
3027
+ const y = roundByDPR(elements.floating, data.y);
3028
+ if (transform) {
3029
+ return {
3030
+ ...initialStyles,
3031
+ transform: "translate(" + x + "px, " + y + "px)",
3032
+ ...(getDPR(elements.floating) >= 1.5 && {
3033
+ willChange: 'transform'
3034
+ })
3035
+ };
3036
+ }
3037
+ return {
3038
+ position: strategy,
3039
+ left: x,
3040
+ top: y
3041
+ };
3042
+ }, [strategy, transform, elements.floating, data.x, data.y]);
3043
+ return React__namespace.useMemo(() => ({
3044
+ ...data,
3045
+ update,
3046
+ refs,
3047
+ elements,
3048
+ floatingStyles
3049
+ }), [data, update, refs, elements, floatingStyles]);
3050
+ }
3051
+
3052
+ /**
3053
+ * Modifies the placement by translating the floating element along the
3054
+ * specified axes.
3055
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
3056
+ * object may be passed.
3057
+ * @see https://floating-ui.com/docs/offset
3058
+ */
3059
+ const offset = (options, deps) => ({
3060
+ ...offset$1(options),
3061
+ options: [options, deps]
3062
+ });
3063
+
3064
+ /**
3065
+ * Optimizes the visibility of the floating element by shifting it in order to
3066
+ * keep it in view when it will overflow the clipping boundary.
3067
+ * @see https://floating-ui.com/docs/shift
3068
+ */
3069
+ const shift = (options, deps) => ({
3070
+ ...shift$1(options),
3071
+ options: [options, deps]
3072
+ });
3073
+
3074
+ /**
3075
+ * Optimizes the visibility of the floating element by choosing the placement
3076
+ * that has the most space available automatically, without needing to specify a
3077
+ * preferred placement. Alternative to `flip`.
3078
+ * @see https://floating-ui.com/docs/autoPlacement
3079
+ */
3080
+ const autoPlacement = (options, deps) => ({
3081
+ ...autoPlacement$1(options),
3082
+ options: [options, deps]
3083
+ });
3084
+
3085
+ // https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
3086
+ const SafeReact = {
3087
+ ...React__namespace
3088
+ };
3089
+
3090
+ const useInsertionEffect = SafeReact.useInsertionEffect;
3091
+ const useSafeInsertionEffect = useInsertionEffect || (fn => fn());
3092
+ function useEffectEvent(callback) {
3093
+ const ref = React__namespace.useRef(() => {
3094
+ if (process.env.NODE_ENV !== "production") {
3095
+ throw new Error('Cannot call an event handler while rendering.');
3096
+ }
3097
+ });
3098
+ useSafeInsertionEffect(() => {
3099
+ ref.current = callback;
3100
+ });
3101
+ return React__namespace.useCallback(function () {
3102
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3103
+ args[_key] = arguments[_key];
3104
+ }
3105
+ return ref.current == null ? void 0 : ref.current(...args);
3106
+ }, []);
3107
+ }
3108
+
3109
+ var index = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
3110
+
3111
+ let serverHandoffComplete = false;
3112
+ let count = 0;
3113
+ const genId = () => // Ensure the id is unique with multiple independent versions of Floating UI
3114
+ // on <React 18
3115
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++;
3116
+ function useFloatingId() {
3117
+ const [id, setId] = React__namespace.useState(() => serverHandoffComplete ? genId() : undefined);
3118
+ index(() => {
3119
+ if (id == null) {
3120
+ setId(genId());
3121
+ }
3122
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3123
+ }, []);
3124
+ React__namespace.useEffect(() => {
3125
+ serverHandoffComplete = true;
3126
+ }, []);
3127
+ return id;
3128
+ }
3129
+ const useReactId = SafeReact.useId;
3130
+
3131
+ /**
3132
+ * Uses React 18's built-in `useId()` when available, or falls back to a
3133
+ * slightly less performant (requiring a double render) implementation for
3134
+ * earlier React versions.
3135
+ * @see https://floating-ui.com/docs/react-utils#useid
3136
+ */
3137
+ const useId = useReactId || useFloatingId;
3138
+
3139
+ let devMessageSet;
3140
+ if (process.env.NODE_ENV !== "production") {
3141
+ devMessageSet = /*#__PURE__*/new Set();
3142
+ }
3143
+ function error() {
3144
+ var _devMessageSet3;
3145
+ for (var _len2 = arguments.length, messages = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
3146
+ messages[_key2] = arguments[_key2];
3147
+ }
3148
+ const message = "Floating UI: " + messages.join(' ');
3149
+ if (!((_devMessageSet3 = devMessageSet) != null && _devMessageSet3.has(message))) {
3150
+ var _devMessageSet4;
3151
+ (_devMessageSet4 = devMessageSet) == null || _devMessageSet4.add(message);
3152
+ console.error(message);
3153
+ }
3154
+ }
3155
+
3156
+ function createPubSub() {
3157
+ const map = new Map();
3158
+ return {
3159
+ emit(event, data) {
3160
+ var _map$get;
3161
+ (_map$get = map.get(event)) == null || _map$get.forEach(handler => handler(data));
3162
+ },
3163
+ on(event, listener) {
3164
+ map.set(event, [...(map.get(event) || []), listener]);
3165
+ },
3166
+ off(event, listener) {
3167
+ var _map$get2;
3168
+ map.set(event, ((_map$get2 = map.get(event)) == null ? void 0 : _map$get2.filter(l => l !== listener)) || []);
3169
+ }
3170
+ };
3171
+ }
3172
+
3173
+ const FloatingNodeContext = /*#__PURE__*/React__namespace.createContext(null);
3174
+ const FloatingTreeContext = /*#__PURE__*/React__namespace.createContext(null);
3175
+
3176
+ /**
3177
+ * Returns the parent node id for nested floating elements, if available.
3178
+ * Returns `null` for top-level floating elements.
3179
+ */
3180
+ const useFloatingParentNodeId = () => {
3181
+ var _React$useContext;
3182
+ return ((_React$useContext = React__namespace.useContext(FloatingNodeContext)) == null ? void 0 : _React$useContext.id) || null;
3183
+ };
3184
+
3185
+ /**
3186
+ * Returns the nearest floating tree context, if available.
3187
+ */
3188
+ const useFloatingTree = () => React__namespace.useContext(FloatingTreeContext);
3189
+
3190
+ function createAttribute(name) {
3191
+ return "data-floating-ui-" + name;
3192
+ }
3193
+
3194
+ function getChildren(nodes, id) {
3195
+ let allChildren = nodes.filter(node => {
3196
+ var _node$context;
3197
+ return node.parentId === id && ((_node$context = node.context) == null ? void 0 : _node$context.open);
3198
+ });
3199
+ let currentChildren = allChildren;
3200
+ while (currentChildren.length) {
3201
+ currentChildren = nodes.filter(node => {
3202
+ var _currentChildren;
3203
+ return (_currentChildren = currentChildren) == null ? void 0 : _currentChildren.some(n => {
3204
+ var _node$context2;
3205
+ return node.parentId === n.id && ((_node$context2 = node.context) == null ? void 0 : _node$context2.open);
3206
+ });
3207
+ });
3208
+ allChildren = allChildren.concat(currentChildren);
3209
+ }
3210
+ return allChildren;
3211
+ }
3212
+
3213
+ const FOCUSABLE_ATTRIBUTE = 'data-floating-ui-focusable';
3214
+
3215
+ const bubbleHandlerKeys = {
3216
+ pointerdown: 'onPointerDown',
3217
+ mousedown: 'onMouseDown',
3218
+ click: 'onClick'
3219
+ };
3220
+ const captureHandlerKeys = {
3221
+ pointerdown: 'onPointerDownCapture',
3222
+ mousedown: 'onMouseDownCapture',
3223
+ click: 'onClickCapture'
3224
+ };
3225
+ const normalizeProp = normalizable => {
3226
+ var _normalizable$escapeK, _normalizable$outside;
3227
+ return {
3228
+ escapeKey: typeof normalizable === 'boolean' ? normalizable : (_normalizable$escapeK = normalizable == null ? void 0 : normalizable.escapeKey) != null ? _normalizable$escapeK : false,
3229
+ outsidePress: typeof normalizable === 'boolean' ? normalizable : (_normalizable$outside = normalizable == null ? void 0 : normalizable.outsidePress) != null ? _normalizable$outside : true
3230
+ };
3231
+ };
3232
+ /**
3233
+ * Closes the floating element when a dismissal is requested — by default, when
3234
+ * the user presses the `escape` key or outside of the floating element.
3235
+ * @see https://floating-ui.com/docs/useDismiss
3236
+ */
3237
+ function useDismiss(context, props) {
3238
+ if (props === void 0) {
3239
+ props = {};
3240
+ }
3241
+ const {
3242
+ open,
3243
+ onOpenChange,
3244
+ elements,
3245
+ dataRef
3246
+ } = context;
3247
+ const {
3248
+ enabled = true,
3249
+ escapeKey = true,
3250
+ outsidePress: unstable_outsidePress = true,
3251
+ outsidePressEvent = 'pointerdown',
3252
+ referencePress = false,
3253
+ referencePressEvent = 'pointerdown',
3254
+ ancestorScroll = false,
3255
+ bubbles,
3256
+ capture
3257
+ } = props;
3258
+ const tree = useFloatingTree();
3259
+ const outsidePressFn = useEffectEvent(typeof unstable_outsidePress === 'function' ? unstable_outsidePress : () => false);
3260
+ const outsidePress = typeof unstable_outsidePress === 'function' ? outsidePressFn : unstable_outsidePress;
3261
+ const insideReactTreeRef = React__namespace.useRef(false);
3262
+ const endedOrStartedInsideRef = React__namespace.useRef(false);
3263
+ const {
3264
+ escapeKey: escapeKeyBubbles,
3265
+ outsidePress: outsidePressBubbles
3266
+ } = normalizeProp(bubbles);
3267
+ const {
3268
+ escapeKey: escapeKeyCapture,
3269
+ outsidePress: outsidePressCapture
3270
+ } = normalizeProp(capture);
3271
+ const isComposingRef = React__namespace.useRef(false);
3272
+ const closeOnEscapeKeyDown = useEffectEvent(event => {
3273
+ var _dataRef$current$floa;
3274
+ if (!open || !enabled || !escapeKey || event.key !== 'Escape') {
3275
+ return;
3276
+ }
3277
+
3278
+ // Wait until IME is settled. Pressing `Escape` while composing should
3279
+ // close the compose menu, but not the floating element.
3280
+ if (isComposingRef.current) {
3281
+ return;
3282
+ }
3283
+ const nodeId = (_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.nodeId;
3284
+ const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
3285
+ if (!escapeKeyBubbles) {
3286
+ event.stopPropagation();
3287
+ if (children.length > 0) {
3288
+ let shouldDismiss = true;
3289
+ children.forEach(child => {
3290
+ var _child$context;
3291
+ if ((_child$context = child.context) != null && _child$context.open && !child.context.dataRef.current.__escapeKeyBubbles) {
3292
+ shouldDismiss = false;
3293
+ return;
3294
+ }
3295
+ });
3296
+ if (!shouldDismiss) {
3297
+ return;
3298
+ }
3299
+ }
3300
+ }
3301
+ onOpenChange(false, isReactEvent(event) ? event.nativeEvent : event, 'escape-key');
3302
+ });
3303
+ const closeOnEscapeKeyDownCapture = useEffectEvent(event => {
3304
+ var _getTarget2;
3305
+ const callback = () => {
3306
+ var _getTarget;
3307
+ closeOnEscapeKeyDown(event);
3308
+ (_getTarget = getTarget(event)) == null || _getTarget.removeEventListener('keydown', callback);
3309
+ };
3310
+ (_getTarget2 = getTarget(event)) == null || _getTarget2.addEventListener('keydown', callback);
3311
+ });
3312
+ const closeOnPressOutside = useEffectEvent(event => {
3313
+ var _dataRef$current$floa2;
3314
+ // Given developers can stop the propagation of the synthetic event,
3315
+ // we can only be confident with a positive value.
3316
+ const insideReactTree = insideReactTreeRef.current;
3317
+ insideReactTreeRef.current = false;
3318
+
3319
+ // When click outside is lazy (`click` event), handle dragging.
3320
+ // Don't close if:
3321
+ // - The click started inside the floating element.
3322
+ // - The click ended inside the floating element.
3323
+ const endedOrStartedInside = endedOrStartedInsideRef.current;
3324
+ endedOrStartedInsideRef.current = false;
3325
+ if (outsidePressEvent === 'click' && endedOrStartedInside) {
3326
+ return;
3327
+ }
3328
+ if (insideReactTree) {
3329
+ return;
3330
+ }
3331
+ if (typeof outsidePress === 'function' && !outsidePress(event)) {
3332
+ return;
3333
+ }
3334
+ const target = getTarget(event);
3335
+ const inertSelector = "[" + createAttribute('inert') + "]";
3336
+ const markers = getDocument(elements.floating).querySelectorAll(inertSelector);
3337
+ let targetRootAncestor = isElement$1(target) ? target : null;
3338
+ while (targetRootAncestor && !isLastTraversableNode$1(targetRootAncestor)) {
3339
+ const nextParent = getParentNode$1(targetRootAncestor);
3340
+ if (isLastTraversableNode$1(nextParent) || !isElement$1(nextParent)) {
3341
+ break;
3342
+ }
3343
+ targetRootAncestor = nextParent;
3344
+ }
3345
+
3346
+ // Check if the click occurred on a third-party element injected after the
3347
+ // floating element rendered.
3348
+ if (markers.length && isElement$1(target) && !isRootElement(target) &&
3349
+ // Clicked on a direct ancestor (e.g. FloatingOverlay).
3350
+ !contains(target, elements.floating) &&
3351
+ // If the target root element contains none of the markers, then the
3352
+ // element was injected after the floating element rendered.
3353
+ Array.from(markers).every(marker => !contains(targetRootAncestor, marker))) {
3354
+ return;
3355
+ }
3356
+
3357
+ // Check if the click occurred on the scrollbar
3358
+ if (isHTMLElement$1(target) && floating) {
3359
+ const lastTraversableNode = isLastTraversableNode$1(target);
3360
+ const style = getComputedStyle$1(target);
3361
+ const scrollRe = /auto|scroll/;
3362
+ const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
3363
+ const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
3364
+ const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
3365
+ const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
3366
+ const isRTL = style.direction === 'rtl';
3367
+
3368
+ // Check click position relative to scrollbar.
3369
+ // In some browsers it is possible to change the <body> (or window)
3370
+ // scrollbar to the left side, but is very rare and is difficult to
3371
+ // check for. Plus, for modal dialogs with backdrops, it is more
3372
+ // important that the backdrop is checked but not so much the window.
3373
+ const pressedVerticalScrollbar = canScrollY && (isRTL ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
3374
+ const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
3375
+ if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
3376
+ return;
3377
+ }
3378
+ }
3379
+ const nodeId = (_dataRef$current$floa2 = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa2.nodeId;
3380
+ const targetIsInsideChildren = tree && getChildren(tree.nodesRef.current, nodeId).some(node => {
3381
+ var _node$context;
3382
+ return isEventTargetWithin(event, (_node$context = node.context) == null ? void 0 : _node$context.elements.floating);
3383
+ });
3384
+ if (isEventTargetWithin(event, elements.floating) || isEventTargetWithin(event, elements.domReference) || targetIsInsideChildren) {
3385
+ return;
3386
+ }
3387
+ const children = tree ? getChildren(tree.nodesRef.current, nodeId) : [];
3388
+ if (children.length > 0) {
3389
+ let shouldDismiss = true;
3390
+ children.forEach(child => {
3391
+ var _child$context2;
3392
+ if ((_child$context2 = child.context) != null && _child$context2.open && !child.context.dataRef.current.__outsidePressBubbles) {
3393
+ shouldDismiss = false;
3394
+ return;
3395
+ }
3396
+ });
3397
+ if (!shouldDismiss) {
3398
+ return;
3399
+ }
3400
+ }
3401
+ onOpenChange(false, event, 'outside-press');
3402
+ });
3403
+ const closeOnPressOutsideCapture = useEffectEvent(event => {
3404
+ var _getTarget4;
3405
+ const callback = () => {
3406
+ var _getTarget3;
3407
+ closeOnPressOutside(event);
3408
+ (_getTarget3 = getTarget(event)) == null || _getTarget3.removeEventListener(outsidePressEvent, callback);
3409
+ };
3410
+ (_getTarget4 = getTarget(event)) == null || _getTarget4.addEventListener(outsidePressEvent, callback);
3411
+ });
3412
+ React__namespace.useEffect(() => {
3413
+ if (!open || !enabled) {
3414
+ return;
3415
+ }
3416
+ dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
3417
+ dataRef.current.__outsidePressBubbles = outsidePressBubbles;
3418
+ let compositionTimeout = -1;
3419
+ function onScroll(event) {
3420
+ onOpenChange(false, event, 'ancestor-scroll');
3421
+ }
3422
+ function handleCompositionStart() {
3423
+ window.clearTimeout(compositionTimeout);
3424
+ isComposingRef.current = true;
3425
+ }
3426
+ function handleCompositionEnd() {
3427
+ // Safari fires `compositionend` before `keydown`, so we need to wait
3428
+ // until the next tick to set `isComposing` to `false`.
3429
+ // https://bugs.webkit.org/show_bug.cgi?id=165004
3430
+ compositionTimeout = window.setTimeout(() => {
3431
+ isComposingRef.current = false;
3432
+ },
3433
+ // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
3434
+ // Only apply to WebKit for the test to remain 0ms.
3435
+ isWebKit$1() ? 5 : 0);
3436
+ }
3437
+ const doc = getDocument(elements.floating);
3438
+ if (escapeKey) {
3439
+ doc.addEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
3440
+ doc.addEventListener('compositionstart', handleCompositionStart);
3441
+ doc.addEventListener('compositionend', handleCompositionEnd);
3442
+ }
3443
+ outsidePress && doc.addEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
3444
+ let ancestors = [];
3445
+ if (ancestorScroll) {
3446
+ if (isElement$1(elements.domReference)) {
3447
+ ancestors = getOverflowAncestors(elements.domReference);
3448
+ }
3449
+ if (isElement$1(elements.floating)) {
3450
+ ancestors = ancestors.concat(getOverflowAncestors(elements.floating));
3451
+ }
3452
+ if (!isElement$1(elements.reference) && elements.reference && elements.reference.contextElement) {
3453
+ ancestors = ancestors.concat(getOverflowAncestors(elements.reference.contextElement));
3454
+ }
3455
+ }
3456
+
3457
+ // Ignore the visual viewport for scrolling dismissal (allow pinch-zoom)
3458
+ ancestors = ancestors.filter(ancestor => {
3459
+ var _doc$defaultView;
3460
+ return ancestor !== ((_doc$defaultView = doc.defaultView) == null ? void 0 : _doc$defaultView.visualViewport);
3461
+ });
3462
+ ancestors.forEach(ancestor => {
3463
+ ancestor.addEventListener('scroll', onScroll, {
3464
+ passive: true
3465
+ });
3466
+ });
3467
+ return () => {
3468
+ if (escapeKey) {
3469
+ doc.removeEventListener('keydown', escapeKeyCapture ? closeOnEscapeKeyDownCapture : closeOnEscapeKeyDown, escapeKeyCapture);
3470
+ doc.removeEventListener('compositionstart', handleCompositionStart);
3471
+ doc.removeEventListener('compositionend', handleCompositionEnd);
3472
+ }
3473
+ outsidePress && doc.removeEventListener(outsidePressEvent, outsidePressCapture ? closeOnPressOutsideCapture : closeOnPressOutside, outsidePressCapture);
3474
+ ancestors.forEach(ancestor => {
3475
+ ancestor.removeEventListener('scroll', onScroll);
3476
+ });
3477
+ window.clearTimeout(compositionTimeout);
3478
+ };
3479
+ }, [dataRef, elements, escapeKey, outsidePress, outsidePressEvent, open, onOpenChange, ancestorScroll, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, escapeKeyCapture, closeOnEscapeKeyDownCapture, closeOnPressOutside, outsidePressCapture, closeOnPressOutsideCapture]);
3480
+ React__namespace.useEffect(() => {
3481
+ insideReactTreeRef.current = false;
3482
+ }, [outsidePress, outsidePressEvent]);
3483
+ const reference = React__namespace.useMemo(() => ({
3484
+ onKeyDown: closeOnEscapeKeyDown,
3485
+ ...(referencePress && {
3486
+ [bubbleHandlerKeys[referencePressEvent]]: event => {
3487
+ onOpenChange(false, event.nativeEvent, 'reference-press');
3488
+ },
3489
+ ...(referencePressEvent !== 'click' && {
3490
+ onClick(event) {
3491
+ onOpenChange(false, event.nativeEvent, 'reference-press');
3492
+ }
3493
+ })
3494
+ })
3495
+ }), [closeOnEscapeKeyDown, onOpenChange, referencePress, referencePressEvent]);
3496
+ const floating = React__namespace.useMemo(() => ({
3497
+ onKeyDown: closeOnEscapeKeyDown,
3498
+ onMouseDown() {
3499
+ endedOrStartedInsideRef.current = true;
3500
+ },
3501
+ onMouseUp() {
3502
+ endedOrStartedInsideRef.current = true;
3503
+ },
3504
+ [captureHandlerKeys[outsidePressEvent]]: () => {
3505
+ insideReactTreeRef.current = true;
3506
+ }
3507
+ }), [closeOnEscapeKeyDown, outsidePressEvent]);
3508
+ return React__namespace.useMemo(() => enabled ? {
3509
+ reference,
3510
+ floating
3511
+ } : {}, [enabled, reference, floating]);
3512
+ }
3513
+
3514
+ function useFloatingRootContext(options) {
3515
+ const {
3516
+ open = false,
3517
+ onOpenChange: onOpenChangeProp,
3518
+ elements: elementsProp
3519
+ } = options;
3520
+ const floatingId = useId();
3521
+ const dataRef = React__namespace.useRef({});
3522
+ const [events] = React__namespace.useState(() => createPubSub());
3523
+ const nested = useFloatingParentNodeId() != null;
3524
+ if (process.env.NODE_ENV !== "production") {
3525
+ const optionDomReference = elementsProp.reference;
3526
+ if (optionDomReference && !isElement$1(optionDomReference)) {
3527
+ error('Cannot pass a virtual element to the `elements.reference` option,', 'as it must be a real DOM element. Use `refs.setPositionReference()`', 'instead.');
3528
+ }
3529
+ }
3530
+ const [positionReference, setPositionReference] = React__namespace.useState(elementsProp.reference);
3531
+ const onOpenChange = useEffectEvent((open, event, reason) => {
3532
+ dataRef.current.openEvent = open ? event : undefined;
3533
+ events.emit('openchange', {
3534
+ open,
3535
+ event,
3536
+ reason,
3537
+ nested
3538
+ });
3539
+ onOpenChangeProp == null || onOpenChangeProp(open, event, reason);
3540
+ });
3541
+ const refs = React__namespace.useMemo(() => ({
3542
+ setPositionReference
3543
+ }), []);
3544
+ const elements = React__namespace.useMemo(() => ({
3545
+ reference: positionReference || elementsProp.reference || null,
3546
+ floating: elementsProp.floating || null,
3547
+ domReference: elementsProp.reference
3548
+ }), [positionReference, elementsProp.reference, elementsProp.floating]);
3549
+ return React__namespace.useMemo(() => ({
3550
+ dataRef,
3551
+ open,
3552
+ onOpenChange,
3553
+ elements,
3554
+ events,
3555
+ floatingId,
3556
+ refs
3557
+ }), [open, onOpenChange, elements, events, floatingId, refs]);
3558
+ }
3559
+
3560
+ /**
3561
+ * Provides data to position a floating element and context to add interactions.
3562
+ * @see https://floating-ui.com/docs/useFloating
3563
+ */
3564
+ function useFloating(options) {
3565
+ if (options === void 0) {
3566
+ options = {};
3567
+ }
3568
+ const {
3569
+ nodeId
3570
+ } = options;
3571
+ const internalRootContext = useFloatingRootContext({
3572
+ ...options,
3573
+ elements: {
3574
+ reference: null,
3575
+ floating: null,
3576
+ ...options.elements
3577
+ }
3578
+ });
3579
+ const rootContext = options.rootContext || internalRootContext;
3580
+ const computedElements = rootContext.elements;
3581
+ const [_domReference, setDomReference] = React__namespace.useState(null);
3582
+ const [positionReference, _setPositionReference] = React__namespace.useState(null);
3583
+ const optionDomReference = computedElements == null ? void 0 : computedElements.domReference;
3584
+ const domReference = optionDomReference || _domReference;
3585
+ const domReferenceRef = React__namespace.useRef(null);
3586
+ const tree = useFloatingTree();
3587
+ index(() => {
3588
+ if (domReference) {
3589
+ domReferenceRef.current = domReference;
3590
+ }
3591
+ }, [domReference]);
3592
+ const position = useFloating$1({
3593
+ ...options,
3594
+ elements: {
3595
+ ...computedElements,
3596
+ ...(positionReference && {
3597
+ reference: positionReference
3598
+ })
3599
+ }
3600
+ });
3601
+ const setPositionReference = React__namespace.useCallback(node => {
3602
+ const computedPositionReference = isElement$1(node) ? {
3603
+ getBoundingClientRect: () => node.getBoundingClientRect(),
3604
+ contextElement: node
3605
+ } : node;
3606
+ // Store the positionReference in state if the DOM reference is specified externally via the
3607
+ // `elements.reference` option. This ensures that it won't be overridden on future renders.
3608
+ _setPositionReference(computedPositionReference);
3609
+ position.refs.setReference(computedPositionReference);
3610
+ }, [position.refs]);
3611
+ const setReference = React__namespace.useCallback(node => {
3612
+ if (isElement$1(node) || node === null) {
3613
+ domReferenceRef.current = node;
3614
+ setDomReference(node);
3615
+ }
3616
+
3617
+ // Backwards-compatibility for passing a virtual element to `reference`
3618
+ // after it has set the DOM reference.
3619
+ if (isElement$1(position.refs.reference.current) || position.refs.reference.current === null ||
3620
+ // Don't allow setting virtual elements using the old technique back to
3621
+ // `null` to support `positionReference` + an unstable `reference`
3622
+ // callback ref.
3623
+ node !== null && !isElement$1(node)) {
3624
+ position.refs.setReference(node);
42
3625
  }
3626
+ }, [position.refs]);
3627
+ const refs = React__namespace.useMemo(() => ({
3628
+ ...position.refs,
3629
+ setReference,
3630
+ setPositionReference,
3631
+ domReference: domReferenceRef
3632
+ }), [position.refs, setReference, setPositionReference]);
3633
+ const elements = React__namespace.useMemo(() => ({
3634
+ ...position.elements,
3635
+ domReference: domReference
3636
+ }), [position.elements, domReference]);
3637
+ const context = React__namespace.useMemo(() => ({
3638
+ ...position,
3639
+ ...rootContext,
3640
+ refs,
3641
+ elements,
3642
+ nodeId
3643
+ }), [position, refs, elements, nodeId, rootContext]);
3644
+ index(() => {
3645
+ rootContext.dataRef.current.floatingContext = context;
3646
+ const node = tree == null ? void 0 : tree.nodesRef.current.find(node => node.id === nodeId);
3647
+ if (node) {
3648
+ node.context = context;
3649
+ }
3650
+ });
3651
+ return React__namespace.useMemo(() => ({
3652
+ ...position,
3653
+ context,
3654
+ refs,
3655
+ elements
3656
+ }), [position, refs, elements, context]);
3657
+ }
3658
+
3659
+ const ACTIVE_KEY = 'active';
3660
+ const SELECTED_KEY = 'selected';
3661
+ function mergeProps(userProps, propsList, elementKey) {
3662
+ const map = new Map();
3663
+ const isItem = elementKey === 'item';
3664
+ let domUserProps = userProps;
3665
+ if (isItem && userProps) {
3666
+ const {
3667
+ [ACTIVE_KEY]: _,
3668
+ [SELECTED_KEY]: __,
3669
+ ...validProps
3670
+ } = userProps;
3671
+ domUserProps = validProps;
3672
+ }
3673
+ return {
3674
+ ...(elementKey === 'floating' && {
3675
+ tabIndex: -1,
3676
+ [FOCUSABLE_ATTRIBUTE]: ''
3677
+ }),
3678
+ ...domUserProps,
3679
+ ...propsList.map(value => {
3680
+ const propsOrGetProps = value ? value[elementKey] : null;
3681
+ if (typeof propsOrGetProps === 'function') {
3682
+ return userProps ? propsOrGetProps(userProps) : null;
3683
+ }
3684
+ return propsOrGetProps;
3685
+ }).concat(userProps).reduce((acc, props) => {
3686
+ if (!props) {
3687
+ return acc;
3688
+ }
3689
+ Object.entries(props).forEach(_ref => {
3690
+ let [key, value] = _ref;
3691
+ if (isItem && [ACTIVE_KEY, SELECTED_KEY].includes(key)) {
3692
+ return;
3693
+ }
3694
+ if (key.indexOf('on') === 0) {
3695
+ if (!map.has(key)) {
3696
+ map.set(key, []);
3697
+ }
3698
+ if (typeof value === 'function') {
3699
+ var _map$get;
3700
+ (_map$get = map.get(key)) == null || _map$get.push(value);
3701
+ acc[key] = function () {
3702
+ var _map$get2;
3703
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
3704
+ args[_key] = arguments[_key];
3705
+ }
3706
+ return (_map$get2 = map.get(key)) == null ? void 0 : _map$get2.map(fn => fn(...args)).find(val => val !== undefined);
3707
+ };
3708
+ }
3709
+ } else {
3710
+ acc[key] = value;
3711
+ }
3712
+ });
3713
+ return acc;
3714
+ }, {})
3715
+ };
3716
+ }
3717
+ /**
3718
+ * Merges an array of interaction hooks' props into prop getters, allowing
3719
+ * event handler functions to be composed together without overwriting one
3720
+ * another.
3721
+ * @see https://floating-ui.com/docs/useInteractions
3722
+ */
3723
+ function useInteractions(propsList) {
3724
+ if (propsList === void 0) {
3725
+ propsList = [];
3726
+ }
3727
+ const referenceDeps = propsList.map(key => key == null ? void 0 : key.reference);
3728
+ const floatingDeps = propsList.map(key => key == null ? void 0 : key.floating);
3729
+ const itemDeps = propsList.map(key => key == null ? void 0 : key.item);
3730
+ const getReferenceProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'reference'),
3731
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3732
+ referenceDeps);
3733
+ const getFloatingProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'floating'),
3734
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3735
+ floatingDeps);
3736
+ const getItemProps = React__namespace.useCallback(userProps => mergeProps(userProps, propsList, 'item'),
3737
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3738
+ itemDeps);
3739
+ return React__namespace.useMemo(() => ({
3740
+ getReferenceProps,
3741
+ getFloatingProps,
3742
+ getItemProps
3743
+ }), [getReferenceProps, getFloatingProps, getItemProps]);
43
3744
  }
44
3745
 
3746
+ const COMBOBOX_OFFSET = 8;
45
3747
  // eslint-disable-next-line max-statements
46
3748
  function useComboboxAccessibility(selectionCallback, filteredOptions, optionsListRef, open, wrapperRef) {
47
3749
  const { handleClose } = React.useContext(ComboboxProvider.ComboboxContext);
@@ -49,23 +3751,32 @@ function useComboboxAccessibility(selectionCallback, filteredOptions, optionsLis
49
3751
  const focusedIndex = React.useRef(null);
50
3752
  useRefocusOnActivator.useRefocusOnActivator_2(open);
51
3753
  const popperRef = useFocusTrap.useFocusTrap_2(open);
52
- const { styles: popperStyles, attributes, update, } = reactPopper.usePopper(wrapperRef.current, popperRef.current, {
53
- modifiers: [
54
- {
55
- name: "flip",
56
- options: {
57
- fallbackPlacements: ["top-start"],
58
- },
59
- },
3754
+ const { floatingStyles, update, context } = useFloating({
3755
+ elements: {
3756
+ reference: wrapperRef.current,
3757
+ floating: popperRef.current,
3758
+ },
3759
+ open,
3760
+ onOpenChange: openState => {
3761
+ if (!openState)
3762
+ handleClose();
3763
+ },
3764
+ middleware: [
3765
+ offset(COMBOBOX_OFFSET),
3766
+ autoPlacement({ allowedPlacements: ["bottom-start", "top-start"] }),
3767
+ shift({ padding: COMBOBOX_OFFSET }),
60
3768
  ],
61
3769
  placement: "bottom-start",
3770
+ whileElementsMounted: autoUpdate,
62
3771
  });
3772
+ const dismiss = useDismiss(context);
3773
+ const { getFloatingProps } = useInteractions([dismiss]);
63
3774
  React.useEffect(() => {
64
3775
  focusedIndex.current = null;
65
3776
  if (open) {
66
3777
  update === null || update === void 0 ? void 0 : update();
67
3778
  }
68
- }, [open, filteredOptions.length]);
3779
+ }, [open, filteredOptions.length, update]);
69
3780
  React.useEffect(() => {
70
3781
  var _a;
71
3782
  if (open) {
@@ -76,11 +3787,6 @@ function useComboboxAccessibility(selectionCallback, filteredOptions, optionsLis
76
3787
  (_a = popperRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener("keydown", handleContentKeydown);
77
3788
  };
78
3789
  }, [open, optionsListRef, filteredOptions]);
79
- useOnKeyDown.useOnKeyDown_2(() => {
80
- if (open) {
81
- handleClose();
82
- }
83
- }, "Escape");
84
3790
  function handleContentKeydown(event) {
85
3791
  var _a;
86
3792
  if (!hasOptionsVisible)
@@ -118,16 +3824,16 @@ function useComboboxAccessibility(selectionCallback, filteredOptions, optionsLis
118
3824
  }
119
3825
  return {
120
3826
  popperRef,
121
- popperStyles,
122
- attributes,
3827
+ popperStyles: floatingStyles,
3828
+ floatingProps: getFloatingProps(),
123
3829
  };
124
3830
  }
125
3831
 
126
3832
  function ComboboxContent(props) {
127
3833
  const optionsExist = props.options.length > 0;
128
3834
  const { optionsListRef } = useComboboxContent(props.open, props.selected);
129
- const { popperRef, popperStyles, attributes } = useComboboxAccessibility(props.handleSelection, props.options, optionsListRef, props.open, props.wrapperRef);
130
- const template = (React.createElement("div", Object.assign({ ref: popperRef, id: constants.COMBOBOX_MENU_ID, "data-testid": constants.COMBOBOX_MENU_ID, "data-elevation": "elevated", tabIndex: 0, className: classnames(styles.content, { [styles.hidden]: !props.open }), style: popperStyles.popper }, attributes.popper),
3835
+ const { popperRef, popperStyles, floatingProps } = useComboboxAccessibility(props.handleSelection, props.options, optionsListRef, props.open, props.wrapperRef);
3836
+ const template = (React.createElement("div", Object.assign({ ref: popperRef, id: constants.COMBOBOX_MENU_ID, "data-testid": constants.COMBOBOX_MENU_ID, "data-elevation": "elevated", tabIndex: 0, className: classnames(styles.content, { [styles.hidden]: !props.open }), style: popperStyles }, floatingProps),
131
3837
  React.createElement(ComboboxContentSearch.ComboboxContentSearch, { open: props.open, placeholder: props.subjectNoun, searchValue: props.searchValue, setSearchValue: props.setSearchValue, handleSearchChange: props.handleSearchChange }),
132
3838
  props.multiselect && (optionsExist || props.selected.length > 0) && (React.createElement(ComboboxContentHeader.ComboboxContentHeader, { hasOptionsVisible: optionsExist, subjectNoun: props.subjectNoun, selectedCount: props.selected.length, onClearAll: () => {
133
3839
  props.selectedStateSetter([]);