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