@yoopta/themes-shadcn 6.0.0-beta.12 → 6.0.0-beta.14

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 (108) hide show
  1. package/dist/accordion.js.map +1 -0
  2. package/dist/blockquote.js.map +1 -0
  3. package/dist/callout.js.map +1 -0
  4. package/dist/carousel.js.map +1 -0
  5. package/dist/chunks/Combination-2202c874.js +1080 -0
  6. package/dist/chunks/Combination-2202c874.js.map +1 -0
  7. package/dist/chunks/_tslib-514d60fe.js +67 -0
  8. package/dist/chunks/_tslib-514d60fe.js.map +1 -0
  9. package/dist/chunks/arrow-right-cc37c75c.js +30 -0
  10. package/dist/chunks/arrow-right-cc37c75c.js.map +1 -0
  11. package/dist/chunks/button-f9af7cb3.js +76 -0
  12. package/dist/chunks/button-f9af7cb3.js.map +1 -0
  13. package/dist/chunks/card-29720641.js +38 -0
  14. package/dist/chunks/card-29720641.js.map +1 -0
  15. package/dist/chunks/check-530fff0e.js +14 -0
  16. package/dist/chunks/check-530fff0e.js.map +1 -0
  17. package/dist/chunks/chevron-down-544d1acd.js +16 -0
  18. package/dist/chunks/chevron-down-544d1acd.js.map +1 -0
  19. package/dist/chunks/chevron-up-053cba03.js +14 -0
  20. package/dist/chunks/chevron-up-053cba03.js.map +1 -0
  21. package/dist/chunks/code-2ff9cc0c.js +17 -0
  22. package/dist/chunks/code-2ff9cc0c.js.map +1 -0
  23. package/dist/chunks/createLucideIcon-02eb7854.js +95 -0
  24. package/dist/chunks/createLucideIcon-02eb7854.js.map +1 -0
  25. package/dist/chunks/dropdown-menu-ac777fdc.js +1165 -0
  26. package/dist/chunks/dropdown-menu-ac777fdc.js.map +1 -0
  27. package/dist/chunks/external-link-43895ded.js +18 -0
  28. package/dist/chunks/external-link-43895ded.js.map +1 -0
  29. package/dist/chunks/file-text-99674d8d.js +20 -0
  30. package/dist/chunks/file-text-99674d8d.js.map +1 -0
  31. package/dist/chunks/hover-card-134f053d.js +257 -0
  32. package/dist/chunks/hover-card-134f053d.js.map +1 -0
  33. package/dist/chunks/index-056b596e.js +16 -0
  34. package/dist/chunks/index-056b596e.js.map +1 -0
  35. package/dist/chunks/index-35823769.js +222 -0
  36. package/dist/chunks/index-35823769.js.map +1 -0
  37. package/dist/chunks/index-41c4abc4.js +3805 -0
  38. package/dist/chunks/index-41c4abc4.js.map +1 -0
  39. package/dist/chunks/index-454935af.js +71 -0
  40. package/dist/chunks/index-454935af.js.map +1 -0
  41. package/dist/chunks/index-ae9b48d5.js +12 -0
  42. package/dist/chunks/index-ae9b48d5.js.map +1 -0
  43. package/dist/chunks/index-b8a83ba5.js +335 -0
  44. package/dist/chunks/index-b8a83ba5.js.map +1 -0
  45. package/dist/chunks/index-b8f2908d.js +40 -0
  46. package/dist/chunks/index-b8f2908d.js.map +1 -0
  47. package/dist/chunks/index-c655a86f.js +7 -0
  48. package/dist/chunks/index-c655a86f.js.map +1 -0
  49. package/dist/chunks/index-c90e54a4.js +190 -0
  50. package/dist/chunks/index-c90e54a4.js.map +1 -0
  51. package/dist/chunks/index-cf5f0d71.js +2907 -0
  52. package/dist/chunks/index-cf5f0d71.js.map +1 -0
  53. package/dist/chunks/index-d9171717.js +13 -0
  54. package/dist/chunks/index-d9171717.js.map +1 -0
  55. package/dist/chunks/index-dd0fd848.js +70 -0
  56. package/dist/chunks/index-dd0fd848.js.map +1 -0
  57. package/dist/chunks/input-5608c2c9.js +13 -0
  58. package/dist/chunks/input-5608c2c9.js.map +1 -0
  59. package/dist/chunks/label-c9152e49.js +168 -0
  60. package/dist/chunks/label-c9152e49.js.map +1 -0
  61. package/dist/chunks/language-select-bdc50f20.js +44 -0
  62. package/dist/chunks/language-select-bdc50f20.js.map +1 -0
  63. package/dist/chunks/play-1a34ad05.js +16 -0
  64. package/dist/chunks/play-1a34ad05.js.map +1 -0
  65. package/dist/chunks/plus-fcea2532.js +17 -0
  66. package/dist/chunks/plus-fcea2532.js.map +1 -0
  67. package/dist/chunks/popover-ef29b0ac.js +300 -0
  68. package/dist/chunks/popover-ef29b0ac.js.map +1 -0
  69. package/dist/chunks/scroll-area-17d8c584.js +726 -0
  70. package/dist/chunks/scroll-area-17d8c584.js.map +1 -0
  71. package/dist/chunks/select-98610101.js +1213 -0
  72. package/dist/chunks/select-98610101.js.map +1 -0
  73. package/dist/chunks/separator-9e6aa45b.js +172 -0
  74. package/dist/chunks/separator-9e6aa45b.js.map +1 -0
  75. package/dist/chunks/sparkles-8922a4af.js +26 -0
  76. package/dist/chunks/sparkles-8922a4af.js.map +1 -0
  77. package/dist/chunks/style-inject.es-746bb8ed.js +29 -0
  78. package/dist/chunks/style-inject.es-746bb8ed.js.map +1 -0
  79. package/dist/chunks/tabs-9cfbd3cc.js +204 -0
  80. package/dist/chunks/tabs-9cfbd3cc.js.map +1 -0
  81. package/dist/chunks/tooltip-f1e02ae0.js +800 -0
  82. package/dist/chunks/tooltip-f1e02ae0.js.map +1 -0
  83. package/dist/chunks/trash-2-be728dd2.js +20 -0
  84. package/dist/chunks/trash-2-be728dd2.js.map +1 -0
  85. package/dist/chunks/upload-0f56ec3e.js +44 -0
  86. package/dist/chunks/upload-0f56ec3e.js.map +1 -0
  87. package/dist/chunks/utils-131071a4.js +2500 -0
  88. package/dist/chunks/utils-131071a4.js.map +1 -0
  89. package/dist/chunks/x-2f6cf742.js +17 -0
  90. package/dist/chunks/x-2f6cf742.js.map +1 -0
  91. package/dist/code-group.js.map +1 -0
  92. package/dist/code.js.map +1 -0
  93. package/dist/divider.js.map +1 -0
  94. package/dist/embed.js.map +1 -0
  95. package/dist/file.js.map +1 -0
  96. package/dist/headings.js.map +1 -0
  97. package/dist/image.js.map +1 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/link.js.map +1 -0
  100. package/dist/lists.js.map +1 -0
  101. package/dist/mention.js.map +1 -0
  102. package/dist/paragraph.js.map +1 -0
  103. package/dist/steps.js.map +1 -0
  104. package/dist/table-of-contents.js.map +1 -0
  105. package/dist/table.js.map +1 -0
  106. package/dist/tabs.js.map +1 -0
  107. package/dist/video.js.map +1 -0
  108. package/package.json +2 -2
@@ -0,0 +1,2907 @@
1
+ import * as React from 'react';
2
+ import { useLayoutEffect } from 'react';
3
+ import { P as Primitive, a as composeEventHandlers, d as dispatchDiscreteCustomEvent, u as useLayoutEffect2, c as createContextScope } from './index-b8a83ba5.js';
4
+ import { u as useComposedRefs } from './index-b8f2908d.js';
5
+ import { u as useCallbackRef } from './index-d9171717.js';
6
+ import { jsx } from 'react/jsx-runtime';
7
+ import * as ReactDOM from 'react-dom';
8
+ import ReactDOM__default from 'react-dom';
9
+
10
+ // packages/react/use-escape-keydown/src/use-escape-keydown.tsx
11
+ function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis?.document) {
12
+ const onEscapeKeyDown = useCallbackRef(onEscapeKeyDownProp);
13
+ React.useEffect(() => {
14
+ const handleKeyDown = (event) => {
15
+ if (event.key === "Escape") {
16
+ onEscapeKeyDown(event);
17
+ }
18
+ };
19
+ ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
20
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
21
+ }, [onEscapeKeyDown, ownerDocument]);
22
+ }
23
+
24
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
25
+ var CONTEXT_UPDATE = "dismissableLayer.update";
26
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
27
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
28
+ var originalBodyPointerEvents;
29
+ var DismissableLayerContext = React.createContext({
30
+ layers: /* @__PURE__ */ new Set(),
31
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
32
+ branches: /* @__PURE__ */ new Set()
33
+ });
34
+ var DismissableLayer = React.forwardRef(
35
+ (props, forwardedRef) => {
36
+ const {
37
+ disableOutsidePointerEvents = false,
38
+ onEscapeKeyDown,
39
+ onPointerDownOutside,
40
+ onFocusOutside,
41
+ onInteractOutside,
42
+ onDismiss,
43
+ ...layerProps
44
+ } = props;
45
+ const context = React.useContext(DismissableLayerContext);
46
+ const [node, setNode] = React.useState(null);
47
+ const ownerDocument = node?.ownerDocument ?? globalThis?.document;
48
+ const [, force] = React.useState({});
49
+ const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
50
+ const layers = Array.from(context.layers);
51
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
52
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
53
+ const index = node ? layers.indexOf(node) : -1;
54
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
55
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
56
+ const pointerDownOutside = usePointerDownOutside((event) => {
57
+ const target = event.target;
58
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
59
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
60
+ onPointerDownOutside?.(event);
61
+ onInteractOutside?.(event);
62
+ if (!event.defaultPrevented) onDismiss?.();
63
+ }, ownerDocument);
64
+ const focusOutside = useFocusOutside((event) => {
65
+ const target = event.target;
66
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
67
+ if (isFocusInBranch) return;
68
+ onFocusOutside?.(event);
69
+ onInteractOutside?.(event);
70
+ if (!event.defaultPrevented) onDismiss?.();
71
+ }, ownerDocument);
72
+ useEscapeKeydown((event) => {
73
+ const isHighestLayer = index === context.layers.size - 1;
74
+ if (!isHighestLayer) return;
75
+ onEscapeKeyDown?.(event);
76
+ if (!event.defaultPrevented && onDismiss) {
77
+ event.preventDefault();
78
+ onDismiss();
79
+ }
80
+ }, ownerDocument);
81
+ React.useEffect(() => {
82
+ if (!node) return;
83
+ if (disableOutsidePointerEvents) {
84
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
85
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
86
+ ownerDocument.body.style.pointerEvents = "none";
87
+ }
88
+ context.layersWithOutsidePointerEventsDisabled.add(node);
89
+ }
90
+ context.layers.add(node);
91
+ dispatchUpdate();
92
+ return () => {
93
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
94
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
95
+ }
96
+ };
97
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
98
+ React.useEffect(() => {
99
+ return () => {
100
+ if (!node) return;
101
+ context.layers.delete(node);
102
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
103
+ dispatchUpdate();
104
+ };
105
+ }, [node, context]);
106
+ React.useEffect(() => {
107
+ const handleUpdate = () => force({});
108
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
109
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
110
+ }, []);
111
+ return /* @__PURE__ */ jsx(
112
+ Primitive.div,
113
+ {
114
+ ...layerProps,
115
+ ref: composedRefs,
116
+ style: {
117
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
118
+ ...props.style
119
+ },
120
+ onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
121
+ onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
122
+ onPointerDownCapture: composeEventHandlers(
123
+ props.onPointerDownCapture,
124
+ pointerDownOutside.onPointerDownCapture
125
+ )
126
+ }
127
+ );
128
+ }
129
+ );
130
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
131
+ var BRANCH_NAME = "DismissableLayerBranch";
132
+ var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
133
+ const context = React.useContext(DismissableLayerContext);
134
+ const ref = React.useRef(null);
135
+ const composedRefs = useComposedRefs(forwardedRef, ref);
136
+ React.useEffect(() => {
137
+ const node = ref.current;
138
+ if (node) {
139
+ context.branches.add(node);
140
+ return () => {
141
+ context.branches.delete(node);
142
+ };
143
+ }
144
+ }, [context.branches]);
145
+ return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
146
+ });
147
+ DismissableLayerBranch.displayName = BRANCH_NAME;
148
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
149
+ const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
150
+ const isPointerInsideReactTreeRef = React.useRef(false);
151
+ const handleClickRef = React.useRef(() => {
152
+ });
153
+ React.useEffect(() => {
154
+ const handlePointerDown = (event) => {
155
+ if (event.target && !isPointerInsideReactTreeRef.current) {
156
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
157
+ handleAndDispatchCustomEvent(
158
+ POINTER_DOWN_OUTSIDE,
159
+ handlePointerDownOutside,
160
+ eventDetail,
161
+ { discrete: true }
162
+ );
163
+ };
164
+ const eventDetail = { originalEvent: event };
165
+ if (event.pointerType === "touch") {
166
+ ownerDocument.removeEventListener("click", handleClickRef.current);
167
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
168
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
169
+ } else {
170
+ handleAndDispatchPointerDownOutsideEvent2();
171
+ }
172
+ } else {
173
+ ownerDocument.removeEventListener("click", handleClickRef.current);
174
+ }
175
+ isPointerInsideReactTreeRef.current = false;
176
+ };
177
+ const timerId = window.setTimeout(() => {
178
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
179
+ }, 0);
180
+ return () => {
181
+ window.clearTimeout(timerId);
182
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
183
+ ownerDocument.removeEventListener("click", handleClickRef.current);
184
+ };
185
+ }, [ownerDocument, handlePointerDownOutside]);
186
+ return {
187
+ // ensures we check React component tree (not just DOM tree)
188
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
189
+ };
190
+ }
191
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
192
+ const handleFocusOutside = useCallbackRef(onFocusOutside);
193
+ const isFocusInsideReactTreeRef = React.useRef(false);
194
+ React.useEffect(() => {
195
+ const handleFocus = (event) => {
196
+ if (event.target && !isFocusInsideReactTreeRef.current) {
197
+ const eventDetail = { originalEvent: event };
198
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
199
+ discrete: false
200
+ });
201
+ }
202
+ };
203
+ ownerDocument.addEventListener("focusin", handleFocus);
204
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
205
+ }, [ownerDocument, handleFocusOutside]);
206
+ return {
207
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
208
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
209
+ };
210
+ }
211
+ function dispatchUpdate() {
212
+ const event = new CustomEvent(CONTEXT_UPDATE);
213
+ document.dispatchEvent(event);
214
+ }
215
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
216
+ const target = detail.originalEvent.target;
217
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
218
+ if (handler) target.addEventListener(name, handler, { once: true });
219
+ if (discrete) {
220
+ dispatchDiscreteCustomEvent(target, event);
221
+ } else {
222
+ target.dispatchEvent(event);
223
+ }
224
+ }
225
+
226
+ /**
227
+ * Custom positioning reference element.
228
+ * @see https://floating-ui.com/docs/virtual-elements
229
+ */
230
+
231
+ const sides = ['top', 'right', 'bottom', 'left'];
232
+ const min = Math.min;
233
+ const max = Math.max;
234
+ const round = Math.round;
235
+ const floor = Math.floor;
236
+ const createCoords = v => ({
237
+ x: v,
238
+ y: v
239
+ });
240
+ const oppositeSideMap = {
241
+ left: 'right',
242
+ right: 'left',
243
+ bottom: 'top',
244
+ top: 'bottom'
245
+ };
246
+ const oppositeAlignmentMap = {
247
+ start: 'end',
248
+ end: 'start'
249
+ };
250
+ function clamp(start, value, end) {
251
+ return max(start, min(value, end));
252
+ }
253
+ function evaluate(value, param) {
254
+ return typeof value === 'function' ? value(param) : value;
255
+ }
256
+ function getSide(placement) {
257
+ return placement.split('-')[0];
258
+ }
259
+ function getAlignment(placement) {
260
+ return placement.split('-')[1];
261
+ }
262
+ function getOppositeAxis(axis) {
263
+ return axis === 'x' ? 'y' : 'x';
264
+ }
265
+ function getAxisLength(axis) {
266
+ return axis === 'y' ? 'height' : 'width';
267
+ }
268
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
269
+ function getSideAxis(placement) {
270
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
271
+ }
272
+ function getAlignmentAxis(placement) {
273
+ return getOppositeAxis(getSideAxis(placement));
274
+ }
275
+ function getAlignmentSides(placement, rects, rtl) {
276
+ if (rtl === void 0) {
277
+ rtl = false;
278
+ }
279
+ const alignment = getAlignment(placement);
280
+ const alignmentAxis = getAlignmentAxis(placement);
281
+ const length = getAxisLength(alignmentAxis);
282
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
283
+ if (rects.reference[length] > rects.floating[length]) {
284
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
285
+ }
286
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
287
+ }
288
+ function getExpandedPlacements(placement) {
289
+ const oppositePlacement = getOppositePlacement(placement);
290
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
291
+ }
292
+ function getOppositeAlignmentPlacement(placement) {
293
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
294
+ }
295
+ const lrPlacement = ['left', 'right'];
296
+ const rlPlacement = ['right', 'left'];
297
+ const tbPlacement = ['top', 'bottom'];
298
+ const btPlacement = ['bottom', 'top'];
299
+ function getSideList(side, isStart, rtl) {
300
+ switch (side) {
301
+ case 'top':
302
+ case 'bottom':
303
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
304
+ return isStart ? lrPlacement : rlPlacement;
305
+ case 'left':
306
+ case 'right':
307
+ return isStart ? tbPlacement : btPlacement;
308
+ default:
309
+ return [];
310
+ }
311
+ }
312
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
313
+ const alignment = getAlignment(placement);
314
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
315
+ if (alignment) {
316
+ list = list.map(side => side + "-" + alignment);
317
+ if (flipAlignment) {
318
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
319
+ }
320
+ }
321
+ return list;
322
+ }
323
+ function getOppositePlacement(placement) {
324
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
325
+ }
326
+ function expandPaddingObject(padding) {
327
+ return {
328
+ top: 0,
329
+ right: 0,
330
+ bottom: 0,
331
+ left: 0,
332
+ ...padding
333
+ };
334
+ }
335
+ function getPaddingObject(padding) {
336
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
337
+ top: padding,
338
+ right: padding,
339
+ bottom: padding,
340
+ left: padding
341
+ };
342
+ }
343
+ function rectToClientRect(rect) {
344
+ const {
345
+ x,
346
+ y,
347
+ width,
348
+ height
349
+ } = rect;
350
+ return {
351
+ width,
352
+ height,
353
+ top: y,
354
+ left: x,
355
+ right: x + width,
356
+ bottom: y + height,
357
+ x,
358
+ y
359
+ };
360
+ }
361
+
362
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
363
+ let {
364
+ reference,
365
+ floating
366
+ } = _ref;
367
+ const sideAxis = getSideAxis(placement);
368
+ const alignmentAxis = getAlignmentAxis(placement);
369
+ const alignLength = getAxisLength(alignmentAxis);
370
+ const side = getSide(placement);
371
+ const isVertical = sideAxis === 'y';
372
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
373
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
374
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
375
+ let coords;
376
+ switch (side) {
377
+ case 'top':
378
+ coords = {
379
+ x: commonX,
380
+ y: reference.y - floating.height
381
+ };
382
+ break;
383
+ case 'bottom':
384
+ coords = {
385
+ x: commonX,
386
+ y: reference.y + reference.height
387
+ };
388
+ break;
389
+ case 'right':
390
+ coords = {
391
+ x: reference.x + reference.width,
392
+ y: commonY
393
+ };
394
+ break;
395
+ case 'left':
396
+ coords = {
397
+ x: reference.x - floating.width,
398
+ y: commonY
399
+ };
400
+ break;
401
+ default:
402
+ coords = {
403
+ x: reference.x,
404
+ y: reference.y
405
+ };
406
+ }
407
+ switch (getAlignment(placement)) {
408
+ case 'start':
409
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
410
+ break;
411
+ case 'end':
412
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
413
+ break;
414
+ }
415
+ return coords;
416
+ }
417
+
418
+ /**
419
+ * Computes the `x` and `y` coordinates that will place the floating element
420
+ * next to a given reference element.
421
+ *
422
+ * This export does not have any `platform` interface logic. You will need to
423
+ * write one for the platform you are using Floating UI with.
424
+ */
425
+ const computePosition$1 = async (reference, floating, config) => {
426
+ const {
427
+ placement = 'bottom',
428
+ strategy = 'absolute',
429
+ middleware = [],
430
+ platform
431
+ } = config;
432
+ const validMiddleware = middleware.filter(Boolean);
433
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
434
+ let rects = await platform.getElementRects({
435
+ reference,
436
+ floating,
437
+ strategy
438
+ });
439
+ let {
440
+ x,
441
+ y
442
+ } = computeCoordsFromPlacement(rects, placement, rtl);
443
+ let statefulPlacement = placement;
444
+ let middlewareData = {};
445
+ let resetCount = 0;
446
+ for (let i = 0; i < validMiddleware.length; i++) {
447
+ const {
448
+ name,
449
+ fn
450
+ } = validMiddleware[i];
451
+ const {
452
+ x: nextX,
453
+ y: nextY,
454
+ data,
455
+ reset
456
+ } = await fn({
457
+ x,
458
+ y,
459
+ initialPlacement: placement,
460
+ placement: statefulPlacement,
461
+ strategy,
462
+ middlewareData,
463
+ rects,
464
+ platform,
465
+ elements: {
466
+ reference,
467
+ floating
468
+ }
469
+ });
470
+ x = nextX != null ? nextX : x;
471
+ y = nextY != null ? nextY : y;
472
+ middlewareData = {
473
+ ...middlewareData,
474
+ [name]: {
475
+ ...middlewareData[name],
476
+ ...data
477
+ }
478
+ };
479
+ if (reset && resetCount <= 50) {
480
+ resetCount++;
481
+ if (typeof reset === 'object') {
482
+ if (reset.placement) {
483
+ statefulPlacement = reset.placement;
484
+ }
485
+ if (reset.rects) {
486
+ rects = reset.rects === true ? await platform.getElementRects({
487
+ reference,
488
+ floating,
489
+ strategy
490
+ }) : reset.rects;
491
+ }
492
+ ({
493
+ x,
494
+ y
495
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
496
+ }
497
+ i = -1;
498
+ }
499
+ }
500
+ return {
501
+ x,
502
+ y,
503
+ placement: statefulPlacement,
504
+ strategy,
505
+ middlewareData
506
+ };
507
+ };
508
+
509
+ /**
510
+ * Resolves with an object of overflow side offsets that determine how much the
511
+ * element is overflowing a given clipping boundary on each side.
512
+ * - positive = overflowing the boundary by that number of pixels
513
+ * - negative = how many pixels left before it will overflow
514
+ * - 0 = lies flush with the boundary
515
+ * @see https://floating-ui.com/docs/detectOverflow
516
+ */
517
+ async function detectOverflow(state, options) {
518
+ var _await$platform$isEle;
519
+ if (options === void 0) {
520
+ options = {};
521
+ }
522
+ const {
523
+ x,
524
+ y,
525
+ platform,
526
+ rects,
527
+ elements,
528
+ strategy
529
+ } = state;
530
+ const {
531
+ boundary = 'clippingAncestors',
532
+ rootBoundary = 'viewport',
533
+ elementContext = 'floating',
534
+ altBoundary = false,
535
+ padding = 0
536
+ } = evaluate(options, state);
537
+ const paddingObject = getPaddingObject(padding);
538
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
539
+ const element = elements[altBoundary ? altContext : elementContext];
540
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
541
+ 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))),
542
+ boundary,
543
+ rootBoundary,
544
+ strategy
545
+ }));
546
+ const rect = elementContext === 'floating' ? {
547
+ x,
548
+ y,
549
+ width: rects.floating.width,
550
+ height: rects.floating.height
551
+ } : rects.reference;
552
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
553
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
554
+ x: 1,
555
+ y: 1
556
+ } : {
557
+ x: 1,
558
+ y: 1
559
+ };
560
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
561
+ elements,
562
+ rect,
563
+ offsetParent,
564
+ strategy
565
+ }) : rect);
566
+ return {
567
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
568
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
569
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
570
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
571
+ };
572
+ }
573
+
574
+ /**
575
+ * Provides data to position an inner element of the floating element so that it
576
+ * appears centered to the reference element.
577
+ * @see https://floating-ui.com/docs/arrow
578
+ */
579
+ const arrow$3 = options => ({
580
+ name: 'arrow',
581
+ options,
582
+ async fn(state) {
583
+ const {
584
+ x,
585
+ y,
586
+ placement,
587
+ rects,
588
+ platform,
589
+ elements,
590
+ middlewareData
591
+ } = state;
592
+ // Since `element` is required, we don't Partial<> the type.
593
+ const {
594
+ element,
595
+ padding = 0
596
+ } = evaluate(options, state) || {};
597
+ if (element == null) {
598
+ return {};
599
+ }
600
+ const paddingObject = getPaddingObject(padding);
601
+ const coords = {
602
+ x,
603
+ y
604
+ };
605
+ const axis = getAlignmentAxis(placement);
606
+ const length = getAxisLength(axis);
607
+ const arrowDimensions = await platform.getDimensions(element);
608
+ const isYAxis = axis === 'y';
609
+ const minProp = isYAxis ? 'top' : 'left';
610
+ const maxProp = isYAxis ? 'bottom' : 'right';
611
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
612
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
613
+ const startDiff = coords[axis] - rects.reference[axis];
614
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
615
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
616
+
617
+ // DOM platform can return `window` as the `offsetParent`.
618
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
619
+ clientSize = elements.floating[clientProp] || rects.floating[length];
620
+ }
621
+ const centerToReference = endDiff / 2 - startDiff / 2;
622
+
623
+ // If the padding is large enough that it causes the arrow to no longer be
624
+ // centered, modify the padding so that it is centered.
625
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
626
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
627
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
628
+
629
+ // Make sure the arrow doesn't overflow the floating element if the center
630
+ // point is outside the floating element's bounds.
631
+ const min$1 = minPadding;
632
+ const max = clientSize - arrowDimensions[length] - maxPadding;
633
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
634
+ const offset = clamp(min$1, center, max);
635
+
636
+ // If the reference is small enough that the arrow's padding causes it to
637
+ // to point to nothing for an aligned placement, adjust the offset of the
638
+ // floating element itself. To ensure `shift()` continues to take action,
639
+ // a single reset is performed when this is true.
640
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
641
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
642
+ return {
643
+ [axis]: coords[axis] + alignmentOffset,
644
+ data: {
645
+ [axis]: offset,
646
+ centerOffset: center - offset - alignmentOffset,
647
+ ...(shouldAddOffset && {
648
+ alignmentOffset
649
+ })
650
+ },
651
+ reset: shouldAddOffset
652
+ };
653
+ }
654
+ });
655
+
656
+ /**
657
+ * Optimizes the visibility of the floating element by flipping the `placement`
658
+ * in order to keep it in view when the preferred placement(s) will overflow the
659
+ * clipping boundary. Alternative to `autoPlacement`.
660
+ * @see https://floating-ui.com/docs/flip
661
+ */
662
+ const flip$2 = function (options) {
663
+ if (options === void 0) {
664
+ options = {};
665
+ }
666
+ return {
667
+ name: 'flip',
668
+ options,
669
+ async fn(state) {
670
+ var _middlewareData$arrow, _middlewareData$flip;
671
+ const {
672
+ placement,
673
+ middlewareData,
674
+ rects,
675
+ initialPlacement,
676
+ platform,
677
+ elements
678
+ } = state;
679
+ const {
680
+ mainAxis: checkMainAxis = true,
681
+ crossAxis: checkCrossAxis = true,
682
+ fallbackPlacements: specifiedFallbackPlacements,
683
+ fallbackStrategy = 'bestFit',
684
+ fallbackAxisSideDirection = 'none',
685
+ flipAlignment = true,
686
+ ...detectOverflowOptions
687
+ } = evaluate(options, state);
688
+
689
+ // If a reset by the arrow was caused due to an alignment offset being
690
+ // added, we should skip any logic now since `flip()` has already done its
691
+ // work.
692
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
693
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
694
+ return {};
695
+ }
696
+ const side = getSide(placement);
697
+ const initialSideAxis = getSideAxis(initialPlacement);
698
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
699
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
700
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
701
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
702
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
703
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
704
+ }
705
+ const placements = [initialPlacement, ...fallbackPlacements];
706
+ const overflow = await detectOverflow(state, detectOverflowOptions);
707
+ const overflows = [];
708
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
709
+ if (checkMainAxis) {
710
+ overflows.push(overflow[side]);
711
+ }
712
+ if (checkCrossAxis) {
713
+ const sides = getAlignmentSides(placement, rects, rtl);
714
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
715
+ }
716
+ overflowsData = [...overflowsData, {
717
+ placement,
718
+ overflows
719
+ }];
720
+
721
+ // One or more sides is overflowing.
722
+ if (!overflows.every(side => side <= 0)) {
723
+ var _middlewareData$flip2, _overflowsData$filter;
724
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
725
+ const nextPlacement = placements[nextIndex];
726
+ if (nextPlacement) {
727
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
728
+ if (!ignoreCrossAxisOverflow ||
729
+ // We leave the current main axis only if every placement on that axis
730
+ // overflows the main axis.
731
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
732
+ // Try next placement and re-run the lifecycle.
733
+ return {
734
+ data: {
735
+ index: nextIndex,
736
+ overflows: overflowsData
737
+ },
738
+ reset: {
739
+ placement: nextPlacement
740
+ }
741
+ };
742
+ }
743
+ }
744
+
745
+ // First, find the candidates that fit on the mainAxis side of overflow,
746
+ // then find the placement that fits the best on the main crossAxis side.
747
+ let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
748
+
749
+ // Otherwise fallback.
750
+ if (!resetPlacement) {
751
+ switch (fallbackStrategy) {
752
+ case 'bestFit':
753
+ {
754
+ var _overflowsData$filter2;
755
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
756
+ if (hasFallbackAxisSideDirection) {
757
+ const currentSideAxis = getSideAxis(d.placement);
758
+ return currentSideAxis === initialSideAxis ||
759
+ // Create a bias to the `y` side axis due to horizontal
760
+ // reading directions favoring greater width.
761
+ currentSideAxis === 'y';
762
+ }
763
+ return true;
764
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
765
+ if (placement) {
766
+ resetPlacement = placement;
767
+ }
768
+ break;
769
+ }
770
+ case 'initialPlacement':
771
+ resetPlacement = initialPlacement;
772
+ break;
773
+ }
774
+ }
775
+ if (placement !== resetPlacement) {
776
+ return {
777
+ reset: {
778
+ placement: resetPlacement
779
+ }
780
+ };
781
+ }
782
+ }
783
+ return {};
784
+ }
785
+ };
786
+ };
787
+
788
+ function getSideOffsets(overflow, rect) {
789
+ return {
790
+ top: overflow.top - rect.height,
791
+ right: overflow.right - rect.width,
792
+ bottom: overflow.bottom - rect.height,
793
+ left: overflow.left - rect.width
794
+ };
795
+ }
796
+ function isAnySideFullyClipped(overflow) {
797
+ return sides.some(side => overflow[side] >= 0);
798
+ }
799
+ /**
800
+ * Provides data to hide the floating element in applicable situations, such as
801
+ * when it is not in the same clipping context as the reference element.
802
+ * @see https://floating-ui.com/docs/hide
803
+ */
804
+ const hide$2 = function (options) {
805
+ if (options === void 0) {
806
+ options = {};
807
+ }
808
+ return {
809
+ name: 'hide',
810
+ options,
811
+ async fn(state) {
812
+ const {
813
+ rects
814
+ } = state;
815
+ const {
816
+ strategy = 'referenceHidden',
817
+ ...detectOverflowOptions
818
+ } = evaluate(options, state);
819
+ switch (strategy) {
820
+ case 'referenceHidden':
821
+ {
822
+ const overflow = await detectOverflow(state, {
823
+ ...detectOverflowOptions,
824
+ elementContext: 'reference'
825
+ });
826
+ const offsets = getSideOffsets(overflow, rects.reference);
827
+ return {
828
+ data: {
829
+ referenceHiddenOffsets: offsets,
830
+ referenceHidden: isAnySideFullyClipped(offsets)
831
+ }
832
+ };
833
+ }
834
+ case 'escaped':
835
+ {
836
+ const overflow = await detectOverflow(state, {
837
+ ...detectOverflowOptions,
838
+ altBoundary: true
839
+ });
840
+ const offsets = getSideOffsets(overflow, rects.floating);
841
+ return {
842
+ data: {
843
+ escapedOffsets: offsets,
844
+ escaped: isAnySideFullyClipped(offsets)
845
+ }
846
+ };
847
+ }
848
+ default:
849
+ {
850
+ return {};
851
+ }
852
+ }
853
+ }
854
+ };
855
+ };
856
+
857
+ function getBoundingRect(rects) {
858
+ const minX = min(...rects.map(rect => rect.left));
859
+ const minY = min(...rects.map(rect => rect.top));
860
+ const maxX = max(...rects.map(rect => rect.right));
861
+ const maxY = max(...rects.map(rect => rect.bottom));
862
+ return {
863
+ x: minX,
864
+ y: minY,
865
+ width: maxX - minX,
866
+ height: maxY - minY
867
+ };
868
+ }
869
+ function getRectsByLine(rects) {
870
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
871
+ const groups = [];
872
+ let prevRect = null;
873
+ for (let i = 0; i < sortedRects.length; i++) {
874
+ const rect = sortedRects[i];
875
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
876
+ groups.push([rect]);
877
+ } else {
878
+ groups[groups.length - 1].push(rect);
879
+ }
880
+ prevRect = rect;
881
+ }
882
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
883
+ }
884
+ /**
885
+ * Provides improved positioning for inline reference elements that can span
886
+ * over multiple lines, such as hyperlinks or range selections.
887
+ * @see https://floating-ui.com/docs/inline
888
+ */
889
+ const inline$2 = function (options) {
890
+ if (options === void 0) {
891
+ options = {};
892
+ }
893
+ return {
894
+ name: 'inline',
895
+ options,
896
+ async fn(state) {
897
+ const {
898
+ placement,
899
+ elements,
900
+ rects,
901
+ platform,
902
+ strategy
903
+ } = state;
904
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
905
+ // ClientRect's bounds, despite the event listener being triggered. A
906
+ // padding of 2 seems to handle this issue.
907
+ const {
908
+ padding = 2,
909
+ x,
910
+ y
911
+ } = evaluate(options, state);
912
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
913
+ const clientRects = getRectsByLine(nativeClientRects);
914
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
915
+ const paddingObject = getPaddingObject(padding);
916
+ function getBoundingClientRect() {
917
+ // There are two rects and they are disjoined.
918
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
919
+ // Find the first rect in which the point is fully inside.
920
+ return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
921
+ }
922
+
923
+ // There are 2 or more connected rects.
924
+ if (clientRects.length >= 2) {
925
+ if (getSideAxis(placement) === 'y') {
926
+ const firstRect = clientRects[0];
927
+ const lastRect = clientRects[clientRects.length - 1];
928
+ const isTop = getSide(placement) === 'top';
929
+ const top = firstRect.top;
930
+ const bottom = lastRect.bottom;
931
+ const left = isTop ? firstRect.left : lastRect.left;
932
+ const right = isTop ? firstRect.right : lastRect.right;
933
+ const width = right - left;
934
+ const height = bottom - top;
935
+ return {
936
+ top,
937
+ bottom,
938
+ left,
939
+ right,
940
+ width,
941
+ height,
942
+ x: left,
943
+ y: top
944
+ };
945
+ }
946
+ const isLeftSide = getSide(placement) === 'left';
947
+ const maxRight = max(...clientRects.map(rect => rect.right));
948
+ const minLeft = min(...clientRects.map(rect => rect.left));
949
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
950
+ const top = measureRects[0].top;
951
+ const bottom = measureRects[measureRects.length - 1].bottom;
952
+ const left = minLeft;
953
+ const right = maxRight;
954
+ const width = right - left;
955
+ const height = bottom - top;
956
+ return {
957
+ top,
958
+ bottom,
959
+ left,
960
+ right,
961
+ width,
962
+ height,
963
+ x: left,
964
+ y: top
965
+ };
966
+ }
967
+ return fallback;
968
+ }
969
+ const resetRects = await platform.getElementRects({
970
+ reference: {
971
+ getBoundingClientRect
972
+ },
973
+ floating: elements.floating,
974
+ strategy
975
+ });
976
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
977
+ return {
978
+ reset: {
979
+ rects: resetRects
980
+ }
981
+ };
982
+ }
983
+ return {};
984
+ }
985
+ };
986
+ };
987
+
988
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
989
+
990
+ // For type backwards-compatibility, the `OffsetOptions` type was also
991
+ // Derivable.
992
+
993
+ async function convertValueToCoords(state, options) {
994
+ const {
995
+ placement,
996
+ platform,
997
+ elements
998
+ } = state;
999
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1000
+ const side = getSide(placement);
1001
+ const alignment = getAlignment(placement);
1002
+ const isVertical = getSideAxis(placement) === 'y';
1003
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
1004
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1005
+ const rawValue = evaluate(options, state);
1006
+
1007
+ // eslint-disable-next-line prefer-const
1008
+ let {
1009
+ mainAxis,
1010
+ crossAxis,
1011
+ alignmentAxis
1012
+ } = typeof rawValue === 'number' ? {
1013
+ mainAxis: rawValue,
1014
+ crossAxis: 0,
1015
+ alignmentAxis: null
1016
+ } : {
1017
+ mainAxis: rawValue.mainAxis || 0,
1018
+ crossAxis: rawValue.crossAxis || 0,
1019
+ alignmentAxis: rawValue.alignmentAxis
1020
+ };
1021
+ if (alignment && typeof alignmentAxis === 'number') {
1022
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1023
+ }
1024
+ return isVertical ? {
1025
+ x: crossAxis * crossAxisMulti,
1026
+ y: mainAxis * mainAxisMulti
1027
+ } : {
1028
+ x: mainAxis * mainAxisMulti,
1029
+ y: crossAxis * crossAxisMulti
1030
+ };
1031
+ }
1032
+
1033
+ /**
1034
+ * Modifies the placement by translating the floating element along the
1035
+ * specified axes.
1036
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1037
+ * object may be passed.
1038
+ * @see https://floating-ui.com/docs/offset
1039
+ */
1040
+ const offset$2 = function (options) {
1041
+ if (options === void 0) {
1042
+ options = 0;
1043
+ }
1044
+ return {
1045
+ name: 'offset',
1046
+ options,
1047
+ async fn(state) {
1048
+ var _middlewareData$offse, _middlewareData$arrow;
1049
+ const {
1050
+ x,
1051
+ y,
1052
+ placement,
1053
+ middlewareData
1054
+ } = state;
1055
+ const diffCoords = await convertValueToCoords(state, options);
1056
+
1057
+ // If the placement is the same and the arrow caused an alignment offset
1058
+ // then we don't need to change the positioning coordinates.
1059
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
1060
+ return {};
1061
+ }
1062
+ return {
1063
+ x: x + diffCoords.x,
1064
+ y: y + diffCoords.y,
1065
+ data: {
1066
+ ...diffCoords,
1067
+ placement
1068
+ }
1069
+ };
1070
+ }
1071
+ };
1072
+ };
1073
+
1074
+ /**
1075
+ * Optimizes the visibility of the floating element by shifting it in order to
1076
+ * keep it in view when it will overflow the clipping boundary.
1077
+ * @see https://floating-ui.com/docs/shift
1078
+ */
1079
+ const shift$2 = function (options) {
1080
+ if (options === void 0) {
1081
+ options = {};
1082
+ }
1083
+ return {
1084
+ name: 'shift',
1085
+ options,
1086
+ async fn(state) {
1087
+ const {
1088
+ x,
1089
+ y,
1090
+ placement
1091
+ } = state;
1092
+ const {
1093
+ mainAxis: checkMainAxis = true,
1094
+ crossAxis: checkCrossAxis = false,
1095
+ limiter = {
1096
+ fn: _ref => {
1097
+ let {
1098
+ x,
1099
+ y
1100
+ } = _ref;
1101
+ return {
1102
+ x,
1103
+ y
1104
+ };
1105
+ }
1106
+ },
1107
+ ...detectOverflowOptions
1108
+ } = evaluate(options, state);
1109
+ const coords = {
1110
+ x,
1111
+ y
1112
+ };
1113
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1114
+ const crossAxis = getSideAxis(getSide(placement));
1115
+ const mainAxis = getOppositeAxis(crossAxis);
1116
+ let mainAxisCoord = coords[mainAxis];
1117
+ let crossAxisCoord = coords[crossAxis];
1118
+ if (checkMainAxis) {
1119
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
1120
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
1121
+ const min = mainAxisCoord + overflow[minSide];
1122
+ const max = mainAxisCoord - overflow[maxSide];
1123
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
1124
+ }
1125
+ if (checkCrossAxis) {
1126
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
1127
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1128
+ const min = crossAxisCoord + overflow[minSide];
1129
+ const max = crossAxisCoord - overflow[maxSide];
1130
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
1131
+ }
1132
+ const limitedCoords = limiter.fn({
1133
+ ...state,
1134
+ [mainAxis]: mainAxisCoord,
1135
+ [crossAxis]: crossAxisCoord
1136
+ });
1137
+ return {
1138
+ ...limitedCoords,
1139
+ data: {
1140
+ x: limitedCoords.x - x,
1141
+ y: limitedCoords.y - y,
1142
+ enabled: {
1143
+ [mainAxis]: checkMainAxis,
1144
+ [crossAxis]: checkCrossAxis
1145
+ }
1146
+ }
1147
+ };
1148
+ }
1149
+ };
1150
+ };
1151
+ /**
1152
+ * Built-in `limiter` that will stop `shift()` at a certain point.
1153
+ */
1154
+ const limitShift$2 = function (options) {
1155
+ if (options === void 0) {
1156
+ options = {};
1157
+ }
1158
+ return {
1159
+ options,
1160
+ fn(state) {
1161
+ const {
1162
+ x,
1163
+ y,
1164
+ placement,
1165
+ rects,
1166
+ middlewareData
1167
+ } = state;
1168
+ const {
1169
+ offset = 0,
1170
+ mainAxis: checkMainAxis = true,
1171
+ crossAxis: checkCrossAxis = true
1172
+ } = evaluate(options, state);
1173
+ const coords = {
1174
+ x,
1175
+ y
1176
+ };
1177
+ const crossAxis = getSideAxis(placement);
1178
+ const mainAxis = getOppositeAxis(crossAxis);
1179
+ let mainAxisCoord = coords[mainAxis];
1180
+ let crossAxisCoord = coords[crossAxis];
1181
+ const rawOffset = evaluate(offset, state);
1182
+ const computedOffset = typeof rawOffset === 'number' ? {
1183
+ mainAxis: rawOffset,
1184
+ crossAxis: 0
1185
+ } : {
1186
+ mainAxis: 0,
1187
+ crossAxis: 0,
1188
+ ...rawOffset
1189
+ };
1190
+ if (checkMainAxis) {
1191
+ const len = mainAxis === 'y' ? 'height' : 'width';
1192
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1193
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1194
+ if (mainAxisCoord < limitMin) {
1195
+ mainAxisCoord = limitMin;
1196
+ } else if (mainAxisCoord > limitMax) {
1197
+ mainAxisCoord = limitMax;
1198
+ }
1199
+ }
1200
+ if (checkCrossAxis) {
1201
+ var _middlewareData$offse, _middlewareData$offse2;
1202
+ const len = mainAxis === 'y' ? 'width' : 'height';
1203
+ const isOriginSide = originSides.has(getSide(placement));
1204
+ const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
1205
+ const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
1206
+ if (crossAxisCoord < limitMin) {
1207
+ crossAxisCoord = limitMin;
1208
+ } else if (crossAxisCoord > limitMax) {
1209
+ crossAxisCoord = limitMax;
1210
+ }
1211
+ }
1212
+ return {
1213
+ [mainAxis]: mainAxisCoord,
1214
+ [crossAxis]: crossAxisCoord
1215
+ };
1216
+ }
1217
+ };
1218
+ };
1219
+
1220
+ /**
1221
+ * Provides data that allows you to change the size of the floating element —
1222
+ * for instance, prevent it from overflowing the clipping boundary or match the
1223
+ * width of the reference element.
1224
+ * @see https://floating-ui.com/docs/size
1225
+ */
1226
+ const size$2 = function (options) {
1227
+ if (options === void 0) {
1228
+ options = {};
1229
+ }
1230
+ return {
1231
+ name: 'size',
1232
+ options,
1233
+ async fn(state) {
1234
+ var _state$middlewareData, _state$middlewareData2;
1235
+ const {
1236
+ placement,
1237
+ rects,
1238
+ platform,
1239
+ elements
1240
+ } = state;
1241
+ const {
1242
+ apply = () => {},
1243
+ ...detectOverflowOptions
1244
+ } = evaluate(options, state);
1245
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1246
+ const side = getSide(placement);
1247
+ const alignment = getAlignment(placement);
1248
+ const isYAxis = getSideAxis(placement) === 'y';
1249
+ const {
1250
+ width,
1251
+ height
1252
+ } = rects.floating;
1253
+ let heightSide;
1254
+ let widthSide;
1255
+ if (side === 'top' || side === 'bottom') {
1256
+ heightSide = side;
1257
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
1258
+ } else {
1259
+ widthSide = side;
1260
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
1261
+ }
1262
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
1263
+ const maximumClippingWidth = width - overflow.left - overflow.right;
1264
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1265
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1266
+ const noShift = !state.middlewareData.shift;
1267
+ let availableHeight = overflowAvailableHeight;
1268
+ let availableWidth = overflowAvailableWidth;
1269
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1270
+ availableWidth = maximumClippingWidth;
1271
+ }
1272
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1273
+ availableHeight = maximumClippingHeight;
1274
+ }
1275
+ if (noShift && !alignment) {
1276
+ const xMin = max(overflow.left, 0);
1277
+ const xMax = max(overflow.right, 0);
1278
+ const yMin = max(overflow.top, 0);
1279
+ const yMax = max(overflow.bottom, 0);
1280
+ if (isYAxis) {
1281
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1282
+ } else {
1283
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1284
+ }
1285
+ }
1286
+ await apply({
1287
+ ...state,
1288
+ availableWidth,
1289
+ availableHeight
1290
+ });
1291
+ const nextDimensions = await platform.getDimensions(elements.floating);
1292
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1293
+ return {
1294
+ reset: {
1295
+ rects: true
1296
+ }
1297
+ };
1298
+ }
1299
+ return {};
1300
+ }
1301
+ };
1302
+ };
1303
+
1304
+ function hasWindow() {
1305
+ return typeof window !== 'undefined';
1306
+ }
1307
+ function getNodeName(node) {
1308
+ if (isNode(node)) {
1309
+ return (node.nodeName || '').toLowerCase();
1310
+ }
1311
+ // Mocked nodes in testing environments may not be instances of Node. By
1312
+ // returning `#document` an infinite loop won't occur.
1313
+ // https://github.com/floating-ui/floating-ui/issues/2317
1314
+ return '#document';
1315
+ }
1316
+ function getWindow(node) {
1317
+ var _node$ownerDocument;
1318
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1319
+ }
1320
+ function getDocumentElement(node) {
1321
+ var _ref;
1322
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1323
+ }
1324
+ function isNode(value) {
1325
+ if (!hasWindow()) {
1326
+ return false;
1327
+ }
1328
+ return value instanceof Node || value instanceof getWindow(value).Node;
1329
+ }
1330
+ function isElement(value) {
1331
+ if (!hasWindow()) {
1332
+ return false;
1333
+ }
1334
+ return value instanceof Element || value instanceof getWindow(value).Element;
1335
+ }
1336
+ function isHTMLElement(value) {
1337
+ if (!hasWindow()) {
1338
+ return false;
1339
+ }
1340
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1341
+ }
1342
+ function isShadowRoot(value) {
1343
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1344
+ return false;
1345
+ }
1346
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1347
+ }
1348
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
1349
+ function isOverflowElement(element) {
1350
+ const {
1351
+ overflow,
1352
+ overflowX,
1353
+ overflowY,
1354
+ display
1355
+ } = getComputedStyle$1(element);
1356
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
1357
+ }
1358
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
1359
+ function isTableElement(element) {
1360
+ return tableElements.has(getNodeName(element));
1361
+ }
1362
+ const topLayerSelectors = [':popover-open', ':modal'];
1363
+ function isTopLayer(element) {
1364
+ return topLayerSelectors.some(selector => {
1365
+ try {
1366
+ return element.matches(selector);
1367
+ } catch (_e) {
1368
+ return false;
1369
+ }
1370
+ });
1371
+ }
1372
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
1373
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
1374
+ const containValues = ['paint', 'layout', 'strict', 'content'];
1375
+ function isContainingBlock(elementOrCss) {
1376
+ const webkit = isWebKit();
1377
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
1378
+
1379
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1380
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
1381
+ return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
1382
+ }
1383
+ function getContainingBlock(element) {
1384
+ let currentNode = getParentNode(element);
1385
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1386
+ if (isContainingBlock(currentNode)) {
1387
+ return currentNode;
1388
+ } else if (isTopLayer(currentNode)) {
1389
+ return null;
1390
+ }
1391
+ currentNode = getParentNode(currentNode);
1392
+ }
1393
+ return null;
1394
+ }
1395
+ function isWebKit() {
1396
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1397
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1398
+ }
1399
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
1400
+ function isLastTraversableNode(node) {
1401
+ return lastTraversableNodeNames.has(getNodeName(node));
1402
+ }
1403
+ function getComputedStyle$1(element) {
1404
+ return getWindow(element).getComputedStyle(element);
1405
+ }
1406
+ function getNodeScroll(element) {
1407
+ if (isElement(element)) {
1408
+ return {
1409
+ scrollLeft: element.scrollLeft,
1410
+ scrollTop: element.scrollTop
1411
+ };
1412
+ }
1413
+ return {
1414
+ scrollLeft: element.scrollX,
1415
+ scrollTop: element.scrollY
1416
+ };
1417
+ }
1418
+ function getParentNode(node) {
1419
+ if (getNodeName(node) === 'html') {
1420
+ return node;
1421
+ }
1422
+ const result =
1423
+ // Step into the shadow DOM of the parent of a slotted node.
1424
+ node.assignedSlot ||
1425
+ // DOM Element detected.
1426
+ node.parentNode ||
1427
+ // ShadowRoot detected.
1428
+ isShadowRoot(node) && node.host ||
1429
+ // Fallback.
1430
+ getDocumentElement(node);
1431
+ return isShadowRoot(result) ? result.host : result;
1432
+ }
1433
+ function getNearestOverflowAncestor(node) {
1434
+ const parentNode = getParentNode(node);
1435
+ if (isLastTraversableNode(parentNode)) {
1436
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1437
+ }
1438
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1439
+ return parentNode;
1440
+ }
1441
+ return getNearestOverflowAncestor(parentNode);
1442
+ }
1443
+ function getOverflowAncestors(node, list, traverseIframes) {
1444
+ var _node$ownerDocument2;
1445
+ if (list === void 0) {
1446
+ list = [];
1447
+ }
1448
+ if (traverseIframes === void 0) {
1449
+ traverseIframes = true;
1450
+ }
1451
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1452
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1453
+ const win = getWindow(scrollableAncestor);
1454
+ if (isBody) {
1455
+ const frameElement = getFrameElement(win);
1456
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1457
+ }
1458
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1459
+ }
1460
+ function getFrameElement(win) {
1461
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1462
+ }
1463
+
1464
+ function getCssDimensions(element) {
1465
+ const css = getComputedStyle$1(element);
1466
+ // In testing environments, the `width` and `height` properties are empty
1467
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1468
+ let width = parseFloat(css.width) || 0;
1469
+ let height = parseFloat(css.height) || 0;
1470
+ const hasOffset = isHTMLElement(element);
1471
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1472
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1473
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1474
+ if (shouldFallback) {
1475
+ width = offsetWidth;
1476
+ height = offsetHeight;
1477
+ }
1478
+ return {
1479
+ width,
1480
+ height,
1481
+ $: shouldFallback
1482
+ };
1483
+ }
1484
+
1485
+ function unwrapElement(element) {
1486
+ return !isElement(element) ? element.contextElement : element;
1487
+ }
1488
+
1489
+ function getScale(element) {
1490
+ const domElement = unwrapElement(element);
1491
+ if (!isHTMLElement(domElement)) {
1492
+ return createCoords(1);
1493
+ }
1494
+ const rect = domElement.getBoundingClientRect();
1495
+ const {
1496
+ width,
1497
+ height,
1498
+ $
1499
+ } = getCssDimensions(domElement);
1500
+ let x = ($ ? round(rect.width) : rect.width) / width;
1501
+ let y = ($ ? round(rect.height) : rect.height) / height;
1502
+
1503
+ // 0, NaN, or Infinity should always fallback to 1.
1504
+
1505
+ if (!x || !Number.isFinite(x)) {
1506
+ x = 1;
1507
+ }
1508
+ if (!y || !Number.isFinite(y)) {
1509
+ y = 1;
1510
+ }
1511
+ return {
1512
+ x,
1513
+ y
1514
+ };
1515
+ }
1516
+
1517
+ const noOffsets = /*#__PURE__*/createCoords(0);
1518
+ function getVisualOffsets(element) {
1519
+ const win = getWindow(element);
1520
+ if (!isWebKit() || !win.visualViewport) {
1521
+ return noOffsets;
1522
+ }
1523
+ return {
1524
+ x: win.visualViewport.offsetLeft,
1525
+ y: win.visualViewport.offsetTop
1526
+ };
1527
+ }
1528
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1529
+ if (isFixed === void 0) {
1530
+ isFixed = false;
1531
+ }
1532
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1533
+ return false;
1534
+ }
1535
+ return isFixed;
1536
+ }
1537
+
1538
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1539
+ if (includeScale === void 0) {
1540
+ includeScale = false;
1541
+ }
1542
+ if (isFixedStrategy === void 0) {
1543
+ isFixedStrategy = false;
1544
+ }
1545
+ const clientRect = element.getBoundingClientRect();
1546
+ const domElement = unwrapElement(element);
1547
+ let scale = createCoords(1);
1548
+ if (includeScale) {
1549
+ if (offsetParent) {
1550
+ if (isElement(offsetParent)) {
1551
+ scale = getScale(offsetParent);
1552
+ }
1553
+ } else {
1554
+ scale = getScale(element);
1555
+ }
1556
+ }
1557
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1558
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1559
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1560
+ let width = clientRect.width / scale.x;
1561
+ let height = clientRect.height / scale.y;
1562
+ if (domElement) {
1563
+ const win = getWindow(domElement);
1564
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1565
+ let currentWin = win;
1566
+ let currentIFrame = getFrameElement(currentWin);
1567
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1568
+ const iframeScale = getScale(currentIFrame);
1569
+ const iframeRect = currentIFrame.getBoundingClientRect();
1570
+ const css = getComputedStyle$1(currentIFrame);
1571
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1572
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1573
+ x *= iframeScale.x;
1574
+ y *= iframeScale.y;
1575
+ width *= iframeScale.x;
1576
+ height *= iframeScale.y;
1577
+ x += left;
1578
+ y += top;
1579
+ currentWin = getWindow(currentIFrame);
1580
+ currentIFrame = getFrameElement(currentWin);
1581
+ }
1582
+ }
1583
+ return rectToClientRect({
1584
+ width,
1585
+ height,
1586
+ x,
1587
+ y
1588
+ });
1589
+ }
1590
+
1591
+ // If <html> has a CSS width greater than the viewport, then this will be
1592
+ // incorrect for RTL.
1593
+ function getWindowScrollBarX(element, rect) {
1594
+ const leftScroll = getNodeScroll(element).scrollLeft;
1595
+ if (!rect) {
1596
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1597
+ }
1598
+ return rect.left + leftScroll;
1599
+ }
1600
+
1601
+ function getHTMLOffset(documentElement, scroll) {
1602
+ const htmlRect = documentElement.getBoundingClientRect();
1603
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1604
+ const y = htmlRect.top + scroll.scrollTop;
1605
+ return {
1606
+ x,
1607
+ y
1608
+ };
1609
+ }
1610
+
1611
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1612
+ let {
1613
+ elements,
1614
+ rect,
1615
+ offsetParent,
1616
+ strategy
1617
+ } = _ref;
1618
+ const isFixed = strategy === 'fixed';
1619
+ const documentElement = getDocumentElement(offsetParent);
1620
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1621
+ if (offsetParent === documentElement || topLayer && isFixed) {
1622
+ return rect;
1623
+ }
1624
+ let scroll = {
1625
+ scrollLeft: 0,
1626
+ scrollTop: 0
1627
+ };
1628
+ let scale = createCoords(1);
1629
+ const offsets = createCoords(0);
1630
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1631
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1632
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1633
+ scroll = getNodeScroll(offsetParent);
1634
+ }
1635
+ if (isHTMLElement(offsetParent)) {
1636
+ const offsetRect = getBoundingClientRect(offsetParent);
1637
+ scale = getScale(offsetParent);
1638
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1639
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1640
+ }
1641
+ }
1642
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1643
+ return {
1644
+ width: rect.width * scale.x,
1645
+ height: rect.height * scale.y,
1646
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1647
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1648
+ };
1649
+ }
1650
+
1651
+ function getClientRects(element) {
1652
+ return Array.from(element.getClientRects());
1653
+ }
1654
+
1655
+ // Gets the entire size of the scrollable document area, even extending outside
1656
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1657
+ function getDocumentRect(element) {
1658
+ const html = getDocumentElement(element);
1659
+ const scroll = getNodeScroll(element);
1660
+ const body = element.ownerDocument.body;
1661
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1662
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1663
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1664
+ const y = -scroll.scrollTop;
1665
+ if (getComputedStyle$1(body).direction === 'rtl') {
1666
+ x += max(html.clientWidth, body.clientWidth) - width;
1667
+ }
1668
+ return {
1669
+ width,
1670
+ height,
1671
+ x,
1672
+ y
1673
+ };
1674
+ }
1675
+
1676
+ // Safety check: ensure the scrollbar space is reasonable in case this
1677
+ // calculation is affected by unusual styles.
1678
+ // Most scrollbars leave 15-18px of space.
1679
+ const SCROLLBAR_MAX = 25;
1680
+ function getViewportRect(element, strategy) {
1681
+ const win = getWindow(element);
1682
+ const html = getDocumentElement(element);
1683
+ const visualViewport = win.visualViewport;
1684
+ let width = html.clientWidth;
1685
+ let height = html.clientHeight;
1686
+ let x = 0;
1687
+ let y = 0;
1688
+ if (visualViewport) {
1689
+ width = visualViewport.width;
1690
+ height = visualViewport.height;
1691
+ const visualViewportBased = isWebKit();
1692
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1693
+ x = visualViewport.offsetLeft;
1694
+ y = visualViewport.offsetTop;
1695
+ }
1696
+ }
1697
+ const windowScrollbarX = getWindowScrollBarX(html);
1698
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1699
+ // visual width of the <html> but this is not considered in the size
1700
+ // of `html.clientWidth`.
1701
+ if (windowScrollbarX <= 0) {
1702
+ const doc = html.ownerDocument;
1703
+ const body = doc.body;
1704
+ const bodyStyles = getComputedStyle(body);
1705
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1706
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1707
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1708
+ width -= clippingStableScrollbarWidth;
1709
+ }
1710
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1711
+ // If the <body> scrollbar is on the left, the width needs to be extended
1712
+ // by the scrollbar amount so there isn't extra space on the right.
1713
+ width += windowScrollbarX;
1714
+ }
1715
+ return {
1716
+ width,
1717
+ height,
1718
+ x,
1719
+ y
1720
+ };
1721
+ }
1722
+
1723
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1724
+ // Returns the inner client rect, subtracting scrollbars if present.
1725
+ function getInnerBoundingClientRect(element, strategy) {
1726
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1727
+ const top = clientRect.top + element.clientTop;
1728
+ const left = clientRect.left + element.clientLeft;
1729
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1730
+ const width = element.clientWidth * scale.x;
1731
+ const height = element.clientHeight * scale.y;
1732
+ const x = left * scale.x;
1733
+ const y = top * scale.y;
1734
+ return {
1735
+ width,
1736
+ height,
1737
+ x,
1738
+ y
1739
+ };
1740
+ }
1741
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1742
+ let rect;
1743
+ if (clippingAncestor === 'viewport') {
1744
+ rect = getViewportRect(element, strategy);
1745
+ } else if (clippingAncestor === 'document') {
1746
+ rect = getDocumentRect(getDocumentElement(element));
1747
+ } else if (isElement(clippingAncestor)) {
1748
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1749
+ } else {
1750
+ const visualOffsets = getVisualOffsets(element);
1751
+ rect = {
1752
+ x: clippingAncestor.x - visualOffsets.x,
1753
+ y: clippingAncestor.y - visualOffsets.y,
1754
+ width: clippingAncestor.width,
1755
+ height: clippingAncestor.height
1756
+ };
1757
+ }
1758
+ return rectToClientRect(rect);
1759
+ }
1760
+ function hasFixedPositionAncestor(element, stopNode) {
1761
+ const parentNode = getParentNode(element);
1762
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1763
+ return false;
1764
+ }
1765
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1766
+ }
1767
+
1768
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1769
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1770
+ // of the given element up the tree.
1771
+ function getClippingElementAncestors(element, cache) {
1772
+ const cachedResult = cache.get(element);
1773
+ if (cachedResult) {
1774
+ return cachedResult;
1775
+ }
1776
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1777
+ let currentContainingBlockComputedStyle = null;
1778
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1779
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1780
+
1781
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1782
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1783
+ const computedStyle = getComputedStyle$1(currentNode);
1784
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1785
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1786
+ currentContainingBlockComputedStyle = null;
1787
+ }
1788
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1789
+ if (shouldDropCurrentNode) {
1790
+ // Drop non-containing blocks.
1791
+ result = result.filter(ancestor => ancestor !== currentNode);
1792
+ } else {
1793
+ // Record last containing block for next iteration.
1794
+ currentContainingBlockComputedStyle = computedStyle;
1795
+ }
1796
+ currentNode = getParentNode(currentNode);
1797
+ }
1798
+ cache.set(element, result);
1799
+ return result;
1800
+ }
1801
+
1802
+ // Gets the maximum area that the element is visible in due to any number of
1803
+ // clipping ancestors.
1804
+ function getClippingRect(_ref) {
1805
+ let {
1806
+ element,
1807
+ boundary,
1808
+ rootBoundary,
1809
+ strategy
1810
+ } = _ref;
1811
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1812
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1813
+ const firstClippingAncestor = clippingAncestors[0];
1814
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1815
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1816
+ accRect.top = max(rect.top, accRect.top);
1817
+ accRect.right = min(rect.right, accRect.right);
1818
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1819
+ accRect.left = max(rect.left, accRect.left);
1820
+ return accRect;
1821
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1822
+ return {
1823
+ width: clippingRect.right - clippingRect.left,
1824
+ height: clippingRect.bottom - clippingRect.top,
1825
+ x: clippingRect.left,
1826
+ y: clippingRect.top
1827
+ };
1828
+ }
1829
+
1830
+ function getDimensions(element) {
1831
+ const {
1832
+ width,
1833
+ height
1834
+ } = getCssDimensions(element);
1835
+ return {
1836
+ width,
1837
+ height
1838
+ };
1839
+ }
1840
+
1841
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1842
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1843
+ const documentElement = getDocumentElement(offsetParent);
1844
+ const isFixed = strategy === 'fixed';
1845
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1846
+ let scroll = {
1847
+ scrollLeft: 0,
1848
+ scrollTop: 0
1849
+ };
1850
+ const offsets = createCoords(0);
1851
+
1852
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1853
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1854
+ function setLeftRTLScrollbarOffset() {
1855
+ offsets.x = getWindowScrollBarX(documentElement);
1856
+ }
1857
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1858
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1859
+ scroll = getNodeScroll(offsetParent);
1860
+ }
1861
+ if (isOffsetParentAnElement) {
1862
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1863
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1864
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1865
+ } else if (documentElement) {
1866
+ setLeftRTLScrollbarOffset();
1867
+ }
1868
+ }
1869
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1870
+ setLeftRTLScrollbarOffset();
1871
+ }
1872
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1873
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1874
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1875
+ return {
1876
+ x,
1877
+ y,
1878
+ width: rect.width,
1879
+ height: rect.height
1880
+ };
1881
+ }
1882
+
1883
+ function isStaticPositioned(element) {
1884
+ return getComputedStyle$1(element).position === 'static';
1885
+ }
1886
+
1887
+ function getTrueOffsetParent(element, polyfill) {
1888
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1889
+ return null;
1890
+ }
1891
+ if (polyfill) {
1892
+ return polyfill(element);
1893
+ }
1894
+ let rawOffsetParent = element.offsetParent;
1895
+
1896
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1897
+ // while Chrome and Safari return the <body> element. The <body> element must
1898
+ // be used to perform the correct calculations even if the <html> element is
1899
+ // non-static.
1900
+ if (getDocumentElement(element) === rawOffsetParent) {
1901
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1902
+ }
1903
+ return rawOffsetParent;
1904
+ }
1905
+
1906
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1907
+ // such as table ancestors and cross browser bugs.
1908
+ function getOffsetParent(element, polyfill) {
1909
+ const win = getWindow(element);
1910
+ if (isTopLayer(element)) {
1911
+ return win;
1912
+ }
1913
+ if (!isHTMLElement(element)) {
1914
+ let svgOffsetParent = getParentNode(element);
1915
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1916
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1917
+ return svgOffsetParent;
1918
+ }
1919
+ svgOffsetParent = getParentNode(svgOffsetParent);
1920
+ }
1921
+ return win;
1922
+ }
1923
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1924
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1925
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1926
+ }
1927
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1928
+ return win;
1929
+ }
1930
+ return offsetParent || getContainingBlock(element) || win;
1931
+ }
1932
+
1933
+ const getElementRects = async function (data) {
1934
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1935
+ const getDimensionsFn = this.getDimensions;
1936
+ const floatingDimensions = await getDimensionsFn(data.floating);
1937
+ return {
1938
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1939
+ floating: {
1940
+ x: 0,
1941
+ y: 0,
1942
+ width: floatingDimensions.width,
1943
+ height: floatingDimensions.height
1944
+ }
1945
+ };
1946
+ };
1947
+
1948
+ function isRTL(element) {
1949
+ return getComputedStyle$1(element).direction === 'rtl';
1950
+ }
1951
+
1952
+ const platform = {
1953
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1954
+ getDocumentElement,
1955
+ getClippingRect,
1956
+ getOffsetParent,
1957
+ getElementRects,
1958
+ getClientRects,
1959
+ getDimensions,
1960
+ getScale,
1961
+ isElement,
1962
+ isRTL
1963
+ };
1964
+
1965
+ function rectsAreEqual(a, b) {
1966
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
1967
+ }
1968
+
1969
+ // https://samthor.au/2021/observing-dom/
1970
+ function observeMove(element, onMove) {
1971
+ let io = null;
1972
+ let timeoutId;
1973
+ const root = getDocumentElement(element);
1974
+ function cleanup() {
1975
+ var _io;
1976
+ clearTimeout(timeoutId);
1977
+ (_io = io) == null || _io.disconnect();
1978
+ io = null;
1979
+ }
1980
+ function refresh(skip, threshold) {
1981
+ if (skip === void 0) {
1982
+ skip = false;
1983
+ }
1984
+ if (threshold === void 0) {
1985
+ threshold = 1;
1986
+ }
1987
+ cleanup();
1988
+ const elementRectForRootMargin = element.getBoundingClientRect();
1989
+ const {
1990
+ left,
1991
+ top,
1992
+ width,
1993
+ height
1994
+ } = elementRectForRootMargin;
1995
+ if (!skip) {
1996
+ onMove();
1997
+ }
1998
+ if (!width || !height) {
1999
+ return;
2000
+ }
2001
+ const insetTop = floor(top);
2002
+ const insetRight = floor(root.clientWidth - (left + width));
2003
+ const insetBottom = floor(root.clientHeight - (top + height));
2004
+ const insetLeft = floor(left);
2005
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2006
+ const options = {
2007
+ rootMargin,
2008
+ threshold: max(0, min(1, threshold)) || 1
2009
+ };
2010
+ let isFirstUpdate = true;
2011
+ function handleObserve(entries) {
2012
+ const ratio = entries[0].intersectionRatio;
2013
+ if (ratio !== threshold) {
2014
+ if (!isFirstUpdate) {
2015
+ return refresh();
2016
+ }
2017
+ if (!ratio) {
2018
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
2019
+ // to prevent an infinite loop of updates.
2020
+ timeoutId = setTimeout(() => {
2021
+ refresh(false, 1e-7);
2022
+ }, 1000);
2023
+ } else {
2024
+ refresh(false, ratio);
2025
+ }
2026
+ }
2027
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
2028
+ // It's possible that even though the ratio is reported as 1, the
2029
+ // element is not actually fully within the IntersectionObserver's root
2030
+ // area anymore. This can happen under performance constraints. This may
2031
+ // be a bug in the browser's IntersectionObserver implementation. To
2032
+ // work around this, we compare the element's bounding rect now with
2033
+ // what it was at the time we created the IntersectionObserver. If they
2034
+ // are not equal then the element moved, so we refresh.
2035
+ refresh();
2036
+ }
2037
+ isFirstUpdate = false;
2038
+ }
2039
+
2040
+ // Older browsers don't support a `document` as the root and will throw an
2041
+ // error.
2042
+ try {
2043
+ io = new IntersectionObserver(handleObserve, {
2044
+ ...options,
2045
+ // Handle <iframe>s
2046
+ root: root.ownerDocument
2047
+ });
2048
+ } catch (_e) {
2049
+ io = new IntersectionObserver(handleObserve, options);
2050
+ }
2051
+ io.observe(element);
2052
+ }
2053
+ refresh(true);
2054
+ return cleanup;
2055
+ }
2056
+
2057
+ /**
2058
+ * Automatically updates the position of the floating element when necessary.
2059
+ * Should only be called when the floating element is mounted on the DOM or
2060
+ * visible on the screen.
2061
+ * @returns cleanup function that should be invoked when the floating element is
2062
+ * removed from the DOM or hidden from the screen.
2063
+ * @see https://floating-ui.com/docs/autoUpdate
2064
+ */
2065
+ function autoUpdate(reference, floating, update, options) {
2066
+ if (options === void 0) {
2067
+ options = {};
2068
+ }
2069
+ const {
2070
+ ancestorScroll = true,
2071
+ ancestorResize = true,
2072
+ elementResize = typeof ResizeObserver === 'function',
2073
+ layoutShift = typeof IntersectionObserver === 'function',
2074
+ animationFrame = false
2075
+ } = options;
2076
+ const referenceEl = unwrapElement(reference);
2077
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
2078
+ ancestors.forEach(ancestor => {
2079
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
2080
+ passive: true
2081
+ });
2082
+ ancestorResize && ancestor.addEventListener('resize', update);
2083
+ });
2084
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2085
+ let reobserveFrame = -1;
2086
+ let resizeObserver = null;
2087
+ if (elementResize) {
2088
+ resizeObserver = new ResizeObserver(_ref => {
2089
+ let [firstEntry] = _ref;
2090
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2091
+ // Prevent update loops when using the `size` middleware.
2092
+ // https://github.com/floating-ui/floating-ui/issues/1740
2093
+ resizeObserver.unobserve(floating);
2094
+ cancelAnimationFrame(reobserveFrame);
2095
+ reobserveFrame = requestAnimationFrame(() => {
2096
+ var _resizeObserver;
2097
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
2098
+ });
2099
+ }
2100
+ update();
2101
+ });
2102
+ if (referenceEl && !animationFrame) {
2103
+ resizeObserver.observe(referenceEl);
2104
+ }
2105
+ resizeObserver.observe(floating);
2106
+ }
2107
+ let frameId;
2108
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2109
+ if (animationFrame) {
2110
+ frameLoop();
2111
+ }
2112
+ function frameLoop() {
2113
+ const nextRefRect = getBoundingClientRect(reference);
2114
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
2115
+ update();
2116
+ }
2117
+ prevRefRect = nextRefRect;
2118
+ frameId = requestAnimationFrame(frameLoop);
2119
+ }
2120
+ update();
2121
+ return () => {
2122
+ var _resizeObserver2;
2123
+ ancestors.forEach(ancestor => {
2124
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
2125
+ ancestorResize && ancestor.removeEventListener('resize', update);
2126
+ });
2127
+ cleanupIo == null || cleanupIo();
2128
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
2129
+ resizeObserver = null;
2130
+ if (animationFrame) {
2131
+ cancelAnimationFrame(frameId);
2132
+ }
2133
+ };
2134
+ }
2135
+
2136
+ /**
2137
+ * Modifies the placement by translating the floating element along the
2138
+ * specified axes.
2139
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2140
+ * object may be passed.
2141
+ * @see https://floating-ui.com/docs/offset
2142
+ */
2143
+ const offset$1 = offset$2;
2144
+
2145
+ /**
2146
+ * Optimizes the visibility of the floating element by shifting it in order to
2147
+ * keep it in view when it will overflow the clipping boundary.
2148
+ * @see https://floating-ui.com/docs/shift
2149
+ */
2150
+ const shift$1 = shift$2;
2151
+
2152
+ /**
2153
+ * Optimizes the visibility of the floating element by flipping the `placement`
2154
+ * in order to keep it in view when the preferred placement(s) will overflow the
2155
+ * clipping boundary. Alternative to `autoPlacement`.
2156
+ * @see https://floating-ui.com/docs/flip
2157
+ */
2158
+ const flip$1 = flip$2;
2159
+
2160
+ /**
2161
+ * Provides data that allows you to change the size of the floating element —
2162
+ * for instance, prevent it from overflowing the clipping boundary or match the
2163
+ * width of the reference element.
2164
+ * @see https://floating-ui.com/docs/size
2165
+ */
2166
+ const size$1 = size$2;
2167
+
2168
+ /**
2169
+ * Provides data to hide the floating element in applicable situations, such as
2170
+ * when it is not in the same clipping context as the reference element.
2171
+ * @see https://floating-ui.com/docs/hide
2172
+ */
2173
+ const hide$1 = hide$2;
2174
+
2175
+ /**
2176
+ * Provides data to position an inner element of the floating element so that it
2177
+ * appears centered to the reference element.
2178
+ * @see https://floating-ui.com/docs/arrow
2179
+ */
2180
+ const arrow$2 = arrow$3;
2181
+
2182
+ /**
2183
+ * Provides improved positioning for inline reference elements that can span
2184
+ * over multiple lines, such as hyperlinks or range selections.
2185
+ * @see https://floating-ui.com/docs/inline
2186
+ */
2187
+ const inline$1 = inline$2;
2188
+
2189
+ /**
2190
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2191
+ */
2192
+ const limitShift$1 = limitShift$2;
2193
+
2194
+ /**
2195
+ * Computes the `x` and `y` coordinates that will place the floating element
2196
+ * next to a given reference element.
2197
+ */
2198
+ const computePosition = (reference, floating, options) => {
2199
+ // This caches the expensive `getClippingElementAncestors` function so that
2200
+ // multiple lifecycle resets re-use the same result. It only lives for a
2201
+ // single call. If other functions become expensive, we can add them as well.
2202
+ const cache = new Map();
2203
+ const mergedOptions = {
2204
+ platform,
2205
+ ...options
2206
+ };
2207
+ const platformWithCache = {
2208
+ ...mergedOptions.platform,
2209
+ _c: cache
2210
+ };
2211
+ return computePosition$1(reference, floating, {
2212
+ ...mergedOptions,
2213
+ platform: platformWithCache
2214
+ });
2215
+ };
2216
+
2217
+ var isClient = typeof document !== 'undefined';
2218
+
2219
+ var noop = function noop() {};
2220
+ var index = isClient ? useLayoutEffect : noop;
2221
+
2222
+ // Fork of `fast-deep-equal` that only does the comparisons we need and compares
2223
+ // functions
2224
+ function deepEqual(a, b) {
2225
+ if (a === b) {
2226
+ return true;
2227
+ }
2228
+ if (typeof a !== typeof b) {
2229
+ return false;
2230
+ }
2231
+ if (typeof a === 'function' && a.toString() === b.toString()) {
2232
+ return true;
2233
+ }
2234
+ let length;
2235
+ let i;
2236
+ let keys;
2237
+ if (a && b && typeof a === 'object') {
2238
+ if (Array.isArray(a)) {
2239
+ length = a.length;
2240
+ if (length !== b.length) return false;
2241
+ for (i = length; i-- !== 0;) {
2242
+ if (!deepEqual(a[i], b[i])) {
2243
+ return false;
2244
+ }
2245
+ }
2246
+ return true;
2247
+ }
2248
+ keys = Object.keys(a);
2249
+ length = keys.length;
2250
+ if (length !== Object.keys(b).length) {
2251
+ return false;
2252
+ }
2253
+ for (i = length; i-- !== 0;) {
2254
+ if (!{}.hasOwnProperty.call(b, keys[i])) {
2255
+ return false;
2256
+ }
2257
+ }
2258
+ for (i = length; i-- !== 0;) {
2259
+ const key = keys[i];
2260
+ if (key === '_owner' && a.$$typeof) {
2261
+ continue;
2262
+ }
2263
+ if (!deepEqual(a[key], b[key])) {
2264
+ return false;
2265
+ }
2266
+ }
2267
+ return true;
2268
+ }
2269
+ return a !== a && b !== b;
2270
+ }
2271
+
2272
+ function getDPR(element) {
2273
+ if (typeof window === 'undefined') {
2274
+ return 1;
2275
+ }
2276
+ const win = element.ownerDocument.defaultView || window;
2277
+ return win.devicePixelRatio || 1;
2278
+ }
2279
+
2280
+ function roundByDPR(element, value) {
2281
+ const dpr = getDPR(element);
2282
+ return Math.round(value * dpr) / dpr;
2283
+ }
2284
+
2285
+ function useLatestRef(value) {
2286
+ const ref = React.useRef(value);
2287
+ index(() => {
2288
+ ref.current = value;
2289
+ });
2290
+ return ref;
2291
+ }
2292
+
2293
+ /**
2294
+ * Provides data to position a floating element.
2295
+ * @see https://floating-ui.com/docs/useFloating
2296
+ */
2297
+ function useFloating(options) {
2298
+ if (options === void 0) {
2299
+ options = {};
2300
+ }
2301
+ const {
2302
+ placement = 'bottom',
2303
+ strategy = 'absolute',
2304
+ middleware = [],
2305
+ platform,
2306
+ elements: {
2307
+ reference: externalReference,
2308
+ floating: externalFloating
2309
+ } = {},
2310
+ transform = true,
2311
+ whileElementsMounted,
2312
+ open
2313
+ } = options;
2314
+ const [data, setData] = React.useState({
2315
+ x: 0,
2316
+ y: 0,
2317
+ strategy,
2318
+ placement,
2319
+ middlewareData: {},
2320
+ isPositioned: false
2321
+ });
2322
+ const [latestMiddleware, setLatestMiddleware] = React.useState(middleware);
2323
+ if (!deepEqual(latestMiddleware, middleware)) {
2324
+ setLatestMiddleware(middleware);
2325
+ }
2326
+ const [_reference, _setReference] = React.useState(null);
2327
+ const [_floating, _setFloating] = React.useState(null);
2328
+ const setReference = React.useCallback(node => {
2329
+ if (node !== referenceRef.current) {
2330
+ referenceRef.current = node;
2331
+ _setReference(node);
2332
+ }
2333
+ }, []);
2334
+ const setFloating = React.useCallback(node => {
2335
+ if (node !== floatingRef.current) {
2336
+ floatingRef.current = node;
2337
+ _setFloating(node);
2338
+ }
2339
+ }, []);
2340
+ const referenceEl = externalReference || _reference;
2341
+ const floatingEl = externalFloating || _floating;
2342
+ const referenceRef = React.useRef(null);
2343
+ const floatingRef = React.useRef(null);
2344
+ const dataRef = React.useRef(data);
2345
+ const hasWhileElementsMounted = whileElementsMounted != null;
2346
+ const whileElementsMountedRef = useLatestRef(whileElementsMounted);
2347
+ const platformRef = useLatestRef(platform);
2348
+ const openRef = useLatestRef(open);
2349
+ const update = React.useCallback(() => {
2350
+ if (!referenceRef.current || !floatingRef.current) {
2351
+ return;
2352
+ }
2353
+ const config = {
2354
+ placement,
2355
+ strategy,
2356
+ middleware: latestMiddleware
2357
+ };
2358
+ if (platformRef.current) {
2359
+ config.platform = platformRef.current;
2360
+ }
2361
+ computePosition(referenceRef.current, floatingRef.current, config).then(data => {
2362
+ const fullData = {
2363
+ ...data,
2364
+ // The floating element's position may be recomputed while it's closed
2365
+ // but still mounted (such as when transitioning out). To ensure
2366
+ // `isPositioned` will be `false` initially on the next open, avoid
2367
+ // setting it to `true` when `open === false` (must be specified).
2368
+ isPositioned: openRef.current !== false
2369
+ };
2370
+ if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
2371
+ dataRef.current = fullData;
2372
+ ReactDOM.flushSync(() => {
2373
+ setData(fullData);
2374
+ });
2375
+ }
2376
+ });
2377
+ }, [latestMiddleware, placement, strategy, platformRef, openRef]);
2378
+ index(() => {
2379
+ if (open === false && dataRef.current.isPositioned) {
2380
+ dataRef.current.isPositioned = false;
2381
+ setData(data => ({
2382
+ ...data,
2383
+ isPositioned: false
2384
+ }));
2385
+ }
2386
+ }, [open]);
2387
+ const isMountedRef = React.useRef(false);
2388
+ index(() => {
2389
+ isMountedRef.current = true;
2390
+ return () => {
2391
+ isMountedRef.current = false;
2392
+ };
2393
+ }, []);
2394
+ index(() => {
2395
+ if (referenceEl) referenceRef.current = referenceEl;
2396
+ if (floatingEl) floatingRef.current = floatingEl;
2397
+ if (referenceEl && floatingEl) {
2398
+ if (whileElementsMountedRef.current) {
2399
+ return whileElementsMountedRef.current(referenceEl, floatingEl, update);
2400
+ }
2401
+ update();
2402
+ }
2403
+ }, [referenceEl, floatingEl, update, whileElementsMountedRef, hasWhileElementsMounted]);
2404
+ const refs = React.useMemo(() => ({
2405
+ reference: referenceRef,
2406
+ floating: floatingRef,
2407
+ setReference,
2408
+ setFloating
2409
+ }), [setReference, setFloating]);
2410
+ const elements = React.useMemo(() => ({
2411
+ reference: referenceEl,
2412
+ floating: floatingEl
2413
+ }), [referenceEl, floatingEl]);
2414
+ const floatingStyles = React.useMemo(() => {
2415
+ const initialStyles = {
2416
+ position: strategy,
2417
+ left: 0,
2418
+ top: 0
2419
+ };
2420
+ if (!elements.floating) {
2421
+ return initialStyles;
2422
+ }
2423
+ const x = roundByDPR(elements.floating, data.x);
2424
+ const y = roundByDPR(elements.floating, data.y);
2425
+ if (transform) {
2426
+ return {
2427
+ ...initialStyles,
2428
+ transform: "translate(" + x + "px, " + y + "px)",
2429
+ ...(getDPR(elements.floating) >= 1.5 && {
2430
+ willChange: 'transform'
2431
+ })
2432
+ };
2433
+ }
2434
+ return {
2435
+ position: strategy,
2436
+ left: x,
2437
+ top: y
2438
+ };
2439
+ }, [strategy, transform, elements.floating, data.x, data.y]);
2440
+ return React.useMemo(() => ({
2441
+ ...data,
2442
+ update,
2443
+ refs,
2444
+ elements,
2445
+ floatingStyles
2446
+ }), [data, update, refs, elements, floatingStyles]);
2447
+ }
2448
+
2449
+ /**
2450
+ * Provides data to position an inner element of the floating element so that it
2451
+ * appears centered to the reference element.
2452
+ * This wraps the core `arrow` middleware to allow React refs as the element.
2453
+ * @see https://floating-ui.com/docs/arrow
2454
+ */
2455
+ const arrow$1 = options => {
2456
+ function isRef(value) {
2457
+ return {}.hasOwnProperty.call(value, 'current');
2458
+ }
2459
+ return {
2460
+ name: 'arrow',
2461
+ options,
2462
+ fn(state) {
2463
+ const {
2464
+ element,
2465
+ padding
2466
+ } = typeof options === 'function' ? options(state) : options;
2467
+ if (element && isRef(element)) {
2468
+ if (element.current != null) {
2469
+ return arrow$2({
2470
+ element: element.current,
2471
+ padding
2472
+ }).fn(state);
2473
+ }
2474
+ return {};
2475
+ }
2476
+ if (element) {
2477
+ return arrow$2({
2478
+ element,
2479
+ padding
2480
+ }).fn(state);
2481
+ }
2482
+ return {};
2483
+ }
2484
+ };
2485
+ };
2486
+
2487
+ /**
2488
+ * Modifies the placement by translating the floating element along the
2489
+ * specified axes.
2490
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2491
+ * object may be passed.
2492
+ * @see https://floating-ui.com/docs/offset
2493
+ */
2494
+ const offset = (options, deps) => ({
2495
+ ...offset$1(options),
2496
+ options: [options, deps]
2497
+ });
2498
+
2499
+ /**
2500
+ * Optimizes the visibility of the floating element by shifting it in order to
2501
+ * keep it in view when it will overflow the clipping boundary.
2502
+ * @see https://floating-ui.com/docs/shift
2503
+ */
2504
+ const shift = (options, deps) => ({
2505
+ ...shift$1(options),
2506
+ options: [options, deps]
2507
+ });
2508
+
2509
+ /**
2510
+ * Built-in `limiter` that will stop `shift()` at a certain point.
2511
+ */
2512
+ const limitShift = (options, deps) => ({
2513
+ ...limitShift$1(options),
2514
+ options: [options, deps]
2515
+ });
2516
+
2517
+ /**
2518
+ * Optimizes the visibility of the floating element by flipping the `placement`
2519
+ * in order to keep it in view when the preferred placement(s) will overflow the
2520
+ * clipping boundary. Alternative to `autoPlacement`.
2521
+ * @see https://floating-ui.com/docs/flip
2522
+ */
2523
+ const flip = (options, deps) => ({
2524
+ ...flip$1(options),
2525
+ options: [options, deps]
2526
+ });
2527
+
2528
+ /**
2529
+ * Provides data that allows you to change the size of the floating element —
2530
+ * for instance, prevent it from overflowing the clipping boundary or match the
2531
+ * width of the reference element.
2532
+ * @see https://floating-ui.com/docs/size
2533
+ */
2534
+ const size = (options, deps) => ({
2535
+ ...size$1(options),
2536
+ options: [options, deps]
2537
+ });
2538
+
2539
+ /**
2540
+ * Provides data to hide the floating element in applicable situations, such as
2541
+ * when it is not in the same clipping context as the reference element.
2542
+ * @see https://floating-ui.com/docs/hide
2543
+ */
2544
+ const hide = (options, deps) => ({
2545
+ ...hide$1(options),
2546
+ options: [options, deps]
2547
+ });
2548
+
2549
+ /**
2550
+ * Provides improved positioning for inline reference elements that can span
2551
+ * over multiple lines, such as hyperlinks or range selections.
2552
+ * @see https://floating-ui.com/docs/inline
2553
+ */
2554
+ const inline = (options, deps) => ({
2555
+ ...inline$1(options),
2556
+ options: [options, deps]
2557
+ });
2558
+
2559
+ /**
2560
+ * Provides data to position an inner element of the floating element so that it
2561
+ * appears centered to the reference element.
2562
+ * This wraps the core `arrow` middleware to allow React refs as the element.
2563
+ * @see https://floating-ui.com/docs/arrow
2564
+ */
2565
+ const arrow = (options, deps) => ({
2566
+ ...arrow$1(options),
2567
+ options: [options, deps]
2568
+ });
2569
+
2570
+ // src/arrow.tsx
2571
+ var NAME = "Arrow";
2572
+ var Arrow$1 = React.forwardRef((props, forwardedRef) => {
2573
+ const { children, width = 10, height = 5, ...arrowProps } = props;
2574
+ return /* @__PURE__ */ jsx(
2575
+ Primitive.svg,
2576
+ {
2577
+ ...arrowProps,
2578
+ ref: forwardedRef,
2579
+ width,
2580
+ height,
2581
+ viewBox: "0 0 30 10",
2582
+ preserveAspectRatio: "none",
2583
+ children: props.asChild ? children : /* @__PURE__ */ jsx("polygon", { points: "0,0 30,0 15,10" })
2584
+ }
2585
+ );
2586
+ });
2587
+ Arrow$1.displayName = NAME;
2588
+ var Root = Arrow$1;
2589
+
2590
+ // packages/react/use-size/src/use-size.tsx
2591
+ function useSize(element) {
2592
+ const [size, setSize] = React.useState(void 0);
2593
+ useLayoutEffect2(() => {
2594
+ if (element) {
2595
+ setSize({ width: element.offsetWidth, height: element.offsetHeight });
2596
+ const resizeObserver = new ResizeObserver((entries) => {
2597
+ if (!Array.isArray(entries)) {
2598
+ return;
2599
+ }
2600
+ if (!entries.length) {
2601
+ return;
2602
+ }
2603
+ const entry = entries[0];
2604
+ let width;
2605
+ let height;
2606
+ if ("borderBoxSize" in entry) {
2607
+ const borderSizeEntry = entry["borderBoxSize"];
2608
+ const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
2609
+ width = borderSize["inlineSize"];
2610
+ height = borderSize["blockSize"];
2611
+ } else {
2612
+ width = element.offsetWidth;
2613
+ height = element.offsetHeight;
2614
+ }
2615
+ setSize({ width, height });
2616
+ });
2617
+ resizeObserver.observe(element, { box: "border-box" });
2618
+ return () => resizeObserver.unobserve(element);
2619
+ } else {
2620
+ setSize(void 0);
2621
+ }
2622
+ }, [element]);
2623
+ return size;
2624
+ }
2625
+
2626
+ var POPPER_NAME = "Popper";
2627
+ var [createPopperContext, createPopperScope] = createContextScope(POPPER_NAME);
2628
+ var [PopperProvider, usePopperContext] = createPopperContext(POPPER_NAME);
2629
+ var Popper = (props) => {
2630
+ const { __scopePopper, children } = props;
2631
+ const [anchor, setAnchor] = React.useState(null);
2632
+ return /* @__PURE__ */ jsx(PopperProvider, { scope: __scopePopper, anchor, onAnchorChange: setAnchor, children });
2633
+ };
2634
+ Popper.displayName = POPPER_NAME;
2635
+ var ANCHOR_NAME = "PopperAnchor";
2636
+ var PopperAnchor = React.forwardRef(
2637
+ (props, forwardedRef) => {
2638
+ const { __scopePopper, virtualRef, ...anchorProps } = props;
2639
+ const context = usePopperContext(ANCHOR_NAME, __scopePopper);
2640
+ const ref = React.useRef(null);
2641
+ const composedRefs = useComposedRefs(forwardedRef, ref);
2642
+ const anchorRef = React.useRef(null);
2643
+ React.useEffect(() => {
2644
+ const previousAnchor = anchorRef.current;
2645
+ anchorRef.current = virtualRef?.current || ref.current;
2646
+ if (previousAnchor !== anchorRef.current) {
2647
+ context.onAnchorChange(anchorRef.current);
2648
+ }
2649
+ });
2650
+ return virtualRef ? null : /* @__PURE__ */ jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
2651
+ }
2652
+ );
2653
+ PopperAnchor.displayName = ANCHOR_NAME;
2654
+ var CONTENT_NAME = "PopperContent";
2655
+ var [PopperContentProvider, useContentContext] = createPopperContext(CONTENT_NAME);
2656
+ var PopperContent = React.forwardRef(
2657
+ (props, forwardedRef) => {
2658
+ const {
2659
+ __scopePopper,
2660
+ side = "bottom",
2661
+ sideOffset = 0,
2662
+ align = "center",
2663
+ alignOffset = 0,
2664
+ arrowPadding = 0,
2665
+ avoidCollisions = true,
2666
+ collisionBoundary = [],
2667
+ collisionPadding: collisionPaddingProp = 0,
2668
+ sticky = "partial",
2669
+ hideWhenDetached = false,
2670
+ updatePositionStrategy = "optimized",
2671
+ onPlaced,
2672
+ ...contentProps
2673
+ } = props;
2674
+ const context = usePopperContext(CONTENT_NAME, __scopePopper);
2675
+ const [content, setContent] = React.useState(null);
2676
+ const composedRefs = useComposedRefs(forwardedRef, (node) => setContent(node));
2677
+ const [arrow$1, setArrow] = React.useState(null);
2678
+ const arrowSize = useSize(arrow$1);
2679
+ const arrowWidth = arrowSize?.width ?? 0;
2680
+ const arrowHeight = arrowSize?.height ?? 0;
2681
+ const desiredPlacement = side + (align !== "center" ? "-" + align : "");
2682
+ const collisionPadding = typeof collisionPaddingProp === "number" ? collisionPaddingProp : { top: 0, right: 0, bottom: 0, left: 0, ...collisionPaddingProp };
2683
+ const boundary = Array.isArray(collisionBoundary) ? collisionBoundary : [collisionBoundary];
2684
+ const hasExplicitBoundaries = boundary.length > 0;
2685
+ const detectOverflowOptions = {
2686
+ padding: collisionPadding,
2687
+ boundary: boundary.filter(isNotNull),
2688
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
2689
+ altBoundary: hasExplicitBoundaries
2690
+ };
2691
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = useFloating({
2692
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
2693
+ strategy: "fixed",
2694
+ placement: desiredPlacement,
2695
+ whileElementsMounted: (...args) => {
2696
+ const cleanup = autoUpdate(...args, {
2697
+ animationFrame: updatePositionStrategy === "always"
2698
+ });
2699
+ return cleanup;
2700
+ },
2701
+ elements: {
2702
+ reference: context.anchor
2703
+ },
2704
+ middleware: [
2705
+ offset({ mainAxis: sideOffset + arrowHeight, alignmentAxis: alignOffset }),
2706
+ avoidCollisions && shift({
2707
+ mainAxis: true,
2708
+ crossAxis: false,
2709
+ limiter: sticky === "partial" ? limitShift() : void 0,
2710
+ ...detectOverflowOptions
2711
+ }),
2712
+ avoidCollisions && flip({ ...detectOverflowOptions }),
2713
+ size({
2714
+ ...detectOverflowOptions,
2715
+ apply: ({ elements, rects, availableWidth, availableHeight }) => {
2716
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
2717
+ const contentStyle = elements.floating.style;
2718
+ contentStyle.setProperty("--radix-popper-available-width", `${availableWidth}px`);
2719
+ contentStyle.setProperty("--radix-popper-available-height", `${availableHeight}px`);
2720
+ contentStyle.setProperty("--radix-popper-anchor-width", `${anchorWidth}px`);
2721
+ contentStyle.setProperty("--radix-popper-anchor-height", `${anchorHeight}px`);
2722
+ }
2723
+ }),
2724
+ arrow$1 && arrow({ element: arrow$1, padding: arrowPadding }),
2725
+ transformOrigin({ arrowWidth, arrowHeight }),
2726
+ hideWhenDetached && hide({ strategy: "referenceHidden", ...detectOverflowOptions })
2727
+ ]
2728
+ });
2729
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
2730
+ const handlePlaced = useCallbackRef(onPlaced);
2731
+ useLayoutEffect2(() => {
2732
+ if (isPositioned) {
2733
+ handlePlaced?.();
2734
+ }
2735
+ }, [isPositioned, handlePlaced]);
2736
+ const arrowX = middlewareData.arrow?.x;
2737
+ const arrowY = middlewareData.arrow?.y;
2738
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
2739
+ const [contentZIndex, setContentZIndex] = React.useState();
2740
+ useLayoutEffect2(() => {
2741
+ if (content) setContentZIndex(window.getComputedStyle(content).zIndex);
2742
+ }, [content]);
2743
+ return /* @__PURE__ */ jsx(
2744
+ "div",
2745
+ {
2746
+ ref: refs.setFloating,
2747
+ "data-radix-popper-content-wrapper": "",
2748
+ style: {
2749
+ ...floatingStyles,
2750
+ transform: isPositioned ? floatingStyles.transform : "translate(0, -200%)",
2751
+ // keep off the page when measuring
2752
+ minWidth: "max-content",
2753
+ zIndex: contentZIndex,
2754
+ ["--radix-popper-transform-origin"]: [
2755
+ middlewareData.transformOrigin?.x,
2756
+ middlewareData.transformOrigin?.y
2757
+ ].join(" "),
2758
+ // hide the content if using the hide middleware and should be hidden
2759
+ // set visibility to hidden and disable pointer events so the UI behaves
2760
+ // as if the PopperContent isn't there at all
2761
+ ...middlewareData.hide?.referenceHidden && {
2762
+ visibility: "hidden",
2763
+ pointerEvents: "none"
2764
+ }
2765
+ },
2766
+ dir: props.dir,
2767
+ children: /* @__PURE__ */ jsx(
2768
+ PopperContentProvider,
2769
+ {
2770
+ scope: __scopePopper,
2771
+ placedSide,
2772
+ onArrowChange: setArrow,
2773
+ arrowX,
2774
+ arrowY,
2775
+ shouldHideArrow: cannotCenterArrow,
2776
+ children: /* @__PURE__ */ jsx(
2777
+ Primitive.div,
2778
+ {
2779
+ "data-side": placedSide,
2780
+ "data-align": placedAlign,
2781
+ ...contentProps,
2782
+ ref: composedRefs,
2783
+ style: {
2784
+ ...contentProps.style,
2785
+ // if the PopperContent hasn't been placed yet (not all measurements done)
2786
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
2787
+ animation: !isPositioned ? "none" : void 0
2788
+ }
2789
+ }
2790
+ )
2791
+ }
2792
+ )
2793
+ }
2794
+ );
2795
+ }
2796
+ );
2797
+ PopperContent.displayName = CONTENT_NAME;
2798
+ var ARROW_NAME = "PopperArrow";
2799
+ var OPPOSITE_SIDE = {
2800
+ top: "bottom",
2801
+ right: "left",
2802
+ bottom: "top",
2803
+ left: "right"
2804
+ };
2805
+ var PopperArrow = React.forwardRef(function PopperArrow2(props, forwardedRef) {
2806
+ const { __scopePopper, ...arrowProps } = props;
2807
+ const contentContext = useContentContext(ARROW_NAME, __scopePopper);
2808
+ const baseSide = OPPOSITE_SIDE[contentContext.placedSide];
2809
+ return (
2810
+ // we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
2811
+ // doesn't report size as we'd expect on SVG elements.
2812
+ // it reports their bounding box which is effectively the largest path inside the SVG.
2813
+ /* @__PURE__ */ jsx(
2814
+ "span",
2815
+ {
2816
+ ref: contentContext.onArrowChange,
2817
+ style: {
2818
+ position: "absolute",
2819
+ left: contentContext.arrowX,
2820
+ top: contentContext.arrowY,
2821
+ [baseSide]: 0,
2822
+ transformOrigin: {
2823
+ top: "",
2824
+ right: "0 0",
2825
+ bottom: "center 0",
2826
+ left: "100% 0"
2827
+ }[contentContext.placedSide],
2828
+ transform: {
2829
+ top: "translateY(100%)",
2830
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
2831
+ bottom: `rotate(180deg)`,
2832
+ left: "translateY(50%) rotate(-90deg) translateX(50%)"
2833
+ }[contentContext.placedSide],
2834
+ visibility: contentContext.shouldHideArrow ? "hidden" : void 0
2835
+ },
2836
+ children: /* @__PURE__ */ jsx(
2837
+ Root,
2838
+ {
2839
+ ...arrowProps,
2840
+ ref: forwardedRef,
2841
+ style: {
2842
+ ...arrowProps.style,
2843
+ // ensures the element can be measured correctly (mostly for if SVG)
2844
+ display: "block"
2845
+ }
2846
+ }
2847
+ )
2848
+ }
2849
+ )
2850
+ );
2851
+ });
2852
+ PopperArrow.displayName = ARROW_NAME;
2853
+ function isNotNull(value) {
2854
+ return value !== null;
2855
+ }
2856
+ var transformOrigin = (options) => ({
2857
+ name: "transformOrigin",
2858
+ options,
2859
+ fn(data) {
2860
+ const { placement, rects, middlewareData } = data;
2861
+ const cannotCenterArrow = middlewareData.arrow?.centerOffset !== 0;
2862
+ const isArrowHidden = cannotCenterArrow;
2863
+ const arrowWidth = isArrowHidden ? 0 : options.arrowWidth;
2864
+ const arrowHeight = isArrowHidden ? 0 : options.arrowHeight;
2865
+ const [placedSide, placedAlign] = getSideAndAlignFromPlacement(placement);
2866
+ const noArrowAlign = { start: "0%", center: "50%", end: "100%" }[placedAlign];
2867
+ const arrowXCenter = (middlewareData.arrow?.x ?? 0) + arrowWidth / 2;
2868
+ const arrowYCenter = (middlewareData.arrow?.y ?? 0) + arrowHeight / 2;
2869
+ let x = "";
2870
+ let y = "";
2871
+ if (placedSide === "bottom") {
2872
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2873
+ y = `${-arrowHeight}px`;
2874
+ } else if (placedSide === "top") {
2875
+ x = isArrowHidden ? noArrowAlign : `${arrowXCenter}px`;
2876
+ y = `${rects.floating.height + arrowHeight}px`;
2877
+ } else if (placedSide === "right") {
2878
+ x = `${-arrowHeight}px`;
2879
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2880
+ } else if (placedSide === "left") {
2881
+ x = `${rects.floating.width + arrowHeight}px`;
2882
+ y = isArrowHidden ? noArrowAlign : `${arrowYCenter}px`;
2883
+ }
2884
+ return { data: { x, y } };
2885
+ }
2886
+ });
2887
+ function getSideAndAlignFromPlacement(placement) {
2888
+ const [side, align = "center"] = placement.split("-");
2889
+ return [side, align];
2890
+ }
2891
+ var Root2 = Popper;
2892
+ var Anchor = PopperAnchor;
2893
+ var Content = PopperContent;
2894
+ var Arrow = PopperArrow;
2895
+
2896
+ var PORTAL_NAME = "Portal";
2897
+ var Portal = React.forwardRef((props, forwardedRef) => {
2898
+ const { container: containerProp, ...portalProps } = props;
2899
+ const [mounted, setMounted] = React.useState(false);
2900
+ useLayoutEffect2(() => setMounted(true), []);
2901
+ const container = containerProp || mounted && globalThis?.document?.body;
2902
+ return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
2903
+ });
2904
+ Portal.displayName = PORTAL_NAME;
2905
+
2906
+ export { Anchor as A, Content as C, DismissableLayer as D, Portal as P, Root2 as R, autoUpdate as a, Arrow as b, createPopperScope as c, useFloating as d, isElement as e, flip as f, inline as i, offset as o, shift as s, useSize as u };
2907
+ //# sourceMappingURL=index-cf5f0d71.js.map