@itcase/ui 1.0.95 → 1.0.97

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 (53) hide show
  1. package/dist/components/Button.js +1 -1
  2. package/dist/components/Checkbox.js +11 -6
  3. package/dist/components/Chips.js +6 -2
  4. package/dist/components/Choice.js +25 -12
  5. package/dist/components/DadataHintField.js +1 -1
  6. package/dist/components/DatePicker.js +7755 -8894
  7. package/dist/components/FormField.js +3 -3
  8. package/dist/components/Grid.js +3 -1
  9. package/dist/components/Group.js +9 -1
  10. package/dist/components/Input.js +6 -1
  11. package/dist/components/InputPassword.js +6 -1
  12. package/dist/components/Label.js +2 -0
  13. package/dist/components/RadioButton.js +12 -7
  14. package/dist/components/Segmented.js +22 -6
  15. package/dist/components/Select.js +8520 -46
  16. package/dist/components/Swiper.js +23 -13
  17. package/dist/components/Tab.js +5 -4
  18. package/dist/components/Text.js +13 -1
  19. package/dist/components/Textarea.js +6 -1
  20. package/dist/components/Title.js +11 -3
  21. package/dist/css/components/Cell/Cell.css +0 -1
  22. package/dist/css/components/Chips/Chips.css +7 -7
  23. package/dist/css/components/DatePicker/DatePicker.css +33 -84
  24. package/dist/css/components/Grid/Grid.css +8 -0
  25. package/dist/css/components/Label/Label.css +0 -1
  26. package/dist/css/components/Select/Select.css +0 -1
  27. package/dist/css/components/Select/css/__menu/select__menu.css +0 -1
  28. package/dist/css/components/Swiper/Swiper.css +4 -4
  29. package/dist/css/components/Tab/Tab.css +3 -1
  30. package/dist/css/styles/align/align_vertical.css +4 -4
  31. package/dist/css/styles/border-color/border-color.css +1 -2
  32. package/dist/css/styles/border-color/border-color_hover.css +22 -0
  33. package/dist/css/styles/fill/fill.css +2 -4
  34. package/dist/css/styles/fill/fill_active.css +2 -2
  35. package/dist/css/styles/fill/fill_disabled.css +2 -2
  36. package/dist/css/styles/fill/fill_hover.css +2 -2
  37. package/dist/css/styles/fill-gradient/fill-gradient.css +1 -1
  38. package/dist/css/styles/hover/hover-fill-color.css +1 -1
  39. package/dist/css/styles/hover/hover-item-color.css +1 -1
  40. package/dist/css/styles/hover/hover-text-color.css +1 -1
  41. package/dist/css/styles/mediaqueries.css +0 -14
  42. package/dist/css/styles/text-color/text-color.css +2 -3
  43. package/dist/css/styles/text-color/text-color_active.css +1 -1
  44. package/dist/css/styles/text-color/text-color_hover.css +23 -0
  45. package/dist/css/styles/text-gradient/text-gradient.css +0 -3
  46. package/dist/floating-ui.dom-D_Zct5p2.js +1401 -0
  47. package/package.json +26 -26
  48. package/dist/SelectContainer-umrbJtB5.js +0 -8728
  49. package/dist/css/styles/border-color-hover/border-color-hover.css +0 -21
  50. package/dist/css/styles/text-color-hover/text-color-hover.css +0 -21
  51. package/dist/defineProperty-ujK-k7aM.js +0 -166
  52. /package/dist/{_commonjsHelpers-rI13D0F7.js → _commonjsHelpers-CFO10eej.js} +0 -0
  53. /package/dist/css/styles/{border-color-focus/border-color-focus.css → border-color/border-color_focus.css} +0 -0
@@ -0,0 +1,1401 @@
1
+ 'use strict';
2
+
3
+ function getNodeName(node) {
4
+ if (isNode(node)) {
5
+ return (node.nodeName || '').toLowerCase();
6
+ }
7
+ // Mocked nodes in testing environments may not be instances of Node. By
8
+ // returning `#document` an infinite loop won't occur.
9
+ // https://github.com/floating-ui/floating-ui/issues/2317
10
+ return '#document';
11
+ }
12
+ function getWindow(node) {
13
+ var _node$ownerDocument;
14
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
15
+ }
16
+ function getDocumentElement(node) {
17
+ var _ref;
18
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
19
+ }
20
+ function isNode(value) {
21
+ return value instanceof Node || value instanceof getWindow(value).Node;
22
+ }
23
+ function isElement(value) {
24
+ return value instanceof Element || value instanceof getWindow(value).Element;
25
+ }
26
+ function isHTMLElement(value) {
27
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
28
+ }
29
+ function isShadowRoot(value) {
30
+ // Browsers without `ShadowRoot` support.
31
+ if (typeof ShadowRoot === 'undefined') {
32
+ return false;
33
+ }
34
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
35
+ }
36
+ function isOverflowElement(element) {
37
+ const {
38
+ overflow,
39
+ overflowX,
40
+ overflowY,
41
+ display
42
+ } = getComputedStyle(element);
43
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
44
+ }
45
+ function isTableElement(element) {
46
+ return ['table', 'td', 'th'].includes(getNodeName(element));
47
+ }
48
+ function isContainingBlock(element) {
49
+ const webkit = isWebKit();
50
+ const css = getComputedStyle(element);
51
+
52
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
53
+ return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
54
+ }
55
+ function getContainingBlock(element) {
56
+ let currentNode = getParentNode(element);
57
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
58
+ if (isContainingBlock(currentNode)) {
59
+ return currentNode;
60
+ } else {
61
+ currentNode = getParentNode(currentNode);
62
+ }
63
+ }
64
+ return null;
65
+ }
66
+ function isWebKit() {
67
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
68
+ return CSS.supports('-webkit-backdrop-filter', 'none');
69
+ }
70
+ function isLastTraversableNode(node) {
71
+ return ['html', 'body', '#document'].includes(getNodeName(node));
72
+ }
73
+ function getComputedStyle(element) {
74
+ return getWindow(element).getComputedStyle(element);
75
+ }
76
+ function getNodeScroll(element) {
77
+ if (isElement(element)) {
78
+ return {
79
+ scrollLeft: element.scrollLeft,
80
+ scrollTop: element.scrollTop
81
+ };
82
+ }
83
+ return {
84
+ scrollLeft: element.pageXOffset,
85
+ scrollTop: element.pageYOffset
86
+ };
87
+ }
88
+ function getParentNode(node) {
89
+ if (getNodeName(node) === 'html') {
90
+ return node;
91
+ }
92
+ const result =
93
+ // Step into the shadow DOM of the parent of a slotted node.
94
+ node.assignedSlot ||
95
+ // DOM Element detected.
96
+ node.parentNode ||
97
+ // ShadowRoot detected.
98
+ isShadowRoot(node) && node.host ||
99
+ // Fallback.
100
+ getDocumentElement(node);
101
+ return isShadowRoot(result) ? result.host : result;
102
+ }
103
+ function getNearestOverflowAncestor(node) {
104
+ const parentNode = getParentNode(node);
105
+ if (isLastTraversableNode(parentNode)) {
106
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
107
+ }
108
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
109
+ return parentNode;
110
+ }
111
+ return getNearestOverflowAncestor(parentNode);
112
+ }
113
+ function getOverflowAncestors(node, list, traverseIframes) {
114
+ var _node$ownerDocument2;
115
+ if (list === void 0) {
116
+ list = [];
117
+ }
118
+ if (traverseIframes === void 0) {
119
+ traverseIframes = true;
120
+ }
121
+ const scrollableAncestor = getNearestOverflowAncestor(node);
122
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
123
+ const win = getWindow(scrollableAncestor);
124
+ if (isBody) {
125
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
126
+ }
127
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
128
+ }
129
+
130
+ /**
131
+ * Custom positioning reference element.
132
+ * @see https://floating-ui.com/docs/virtual-elements
133
+ */
134
+
135
+ const min = Math.min;
136
+ const max = Math.max;
137
+ const round = Math.round;
138
+ const floor = Math.floor;
139
+ const createCoords = v => ({
140
+ x: v,
141
+ y: v
142
+ });
143
+ const oppositeSideMap = {
144
+ left: 'right',
145
+ right: 'left',
146
+ bottom: 'top',
147
+ top: 'bottom'
148
+ };
149
+ const oppositeAlignmentMap = {
150
+ start: 'end',
151
+ end: 'start'
152
+ };
153
+ function clamp(start, value, end) {
154
+ return max(start, min(value, end));
155
+ }
156
+ function evaluate(value, param) {
157
+ return typeof value === 'function' ? value(param) : value;
158
+ }
159
+ function getSide(placement) {
160
+ return placement.split('-')[0];
161
+ }
162
+ function getAlignment(placement) {
163
+ return placement.split('-')[1];
164
+ }
165
+ function getOppositeAxis(axis) {
166
+ return axis === 'x' ? 'y' : 'x';
167
+ }
168
+ function getAxisLength(axis) {
169
+ return axis === 'y' ? 'height' : 'width';
170
+ }
171
+ function getSideAxis(placement) {
172
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
173
+ }
174
+ function getAlignmentAxis(placement) {
175
+ return getOppositeAxis(getSideAxis(placement));
176
+ }
177
+ function getAlignmentSides(placement, rects, rtl) {
178
+ if (rtl === void 0) {
179
+ rtl = false;
180
+ }
181
+ const alignment = getAlignment(placement);
182
+ const alignmentAxis = getAlignmentAxis(placement);
183
+ const length = getAxisLength(alignmentAxis);
184
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
185
+ if (rects.reference[length] > rects.floating[length]) {
186
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
187
+ }
188
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
189
+ }
190
+ function getExpandedPlacements(placement) {
191
+ const oppositePlacement = getOppositePlacement(placement);
192
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
193
+ }
194
+ function getOppositeAlignmentPlacement(placement) {
195
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
196
+ }
197
+ function getSideList(side, isStart, rtl) {
198
+ const lr = ['left', 'right'];
199
+ const rl = ['right', 'left'];
200
+ const tb = ['top', 'bottom'];
201
+ const bt = ['bottom', 'top'];
202
+ switch (side) {
203
+ case 'top':
204
+ case 'bottom':
205
+ if (rtl) return isStart ? rl : lr;
206
+ return isStart ? lr : rl;
207
+ case 'left':
208
+ case 'right':
209
+ return isStart ? tb : bt;
210
+ default:
211
+ return [];
212
+ }
213
+ }
214
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
215
+ const alignment = getAlignment(placement);
216
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
217
+ if (alignment) {
218
+ list = list.map(side => side + "-" + alignment);
219
+ if (flipAlignment) {
220
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
221
+ }
222
+ }
223
+ return list;
224
+ }
225
+ function getOppositePlacement(placement) {
226
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
227
+ }
228
+ function expandPaddingObject(padding) {
229
+ return {
230
+ top: 0,
231
+ right: 0,
232
+ bottom: 0,
233
+ left: 0,
234
+ ...padding
235
+ };
236
+ }
237
+ function getPaddingObject(padding) {
238
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
239
+ top: padding,
240
+ right: padding,
241
+ bottom: padding,
242
+ left: padding
243
+ };
244
+ }
245
+ function rectToClientRect(rect) {
246
+ return {
247
+ ...rect,
248
+ top: rect.y,
249
+ left: rect.x,
250
+ right: rect.x + rect.width,
251
+ bottom: rect.y + rect.height
252
+ };
253
+ }
254
+
255
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
256
+ let {
257
+ reference,
258
+ floating
259
+ } = _ref;
260
+ const sideAxis = getSideAxis(placement);
261
+ const alignmentAxis = getAlignmentAxis(placement);
262
+ const alignLength = getAxisLength(alignmentAxis);
263
+ const side = getSide(placement);
264
+ const isVertical = sideAxis === 'y';
265
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
266
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
267
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
268
+ let coords;
269
+ switch (side) {
270
+ case 'top':
271
+ coords = {
272
+ x: commonX,
273
+ y: reference.y - floating.height
274
+ };
275
+ break;
276
+ case 'bottom':
277
+ coords = {
278
+ x: commonX,
279
+ y: reference.y + reference.height
280
+ };
281
+ break;
282
+ case 'right':
283
+ coords = {
284
+ x: reference.x + reference.width,
285
+ y: commonY
286
+ };
287
+ break;
288
+ case 'left':
289
+ coords = {
290
+ x: reference.x - floating.width,
291
+ y: commonY
292
+ };
293
+ break;
294
+ default:
295
+ coords = {
296
+ x: reference.x,
297
+ y: reference.y
298
+ };
299
+ }
300
+ switch (getAlignment(placement)) {
301
+ case 'start':
302
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
303
+ break;
304
+ case 'end':
305
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
306
+ break;
307
+ }
308
+ return coords;
309
+ }
310
+
311
+ /**
312
+ * Computes the `x` and `y` coordinates that will place the floating element
313
+ * next to a given reference element.
314
+ *
315
+ * This export does not have any `platform` interface logic. You will need to
316
+ * write one for the platform you are using Floating UI with.
317
+ */
318
+ const computePosition$1 = async (reference, floating, config) => {
319
+ const {
320
+ placement = 'bottom',
321
+ strategy = 'absolute',
322
+ middleware = [],
323
+ platform
324
+ } = config;
325
+ const validMiddleware = middleware.filter(Boolean);
326
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
327
+ let rects = await platform.getElementRects({
328
+ reference,
329
+ floating,
330
+ strategy
331
+ });
332
+ let {
333
+ x,
334
+ y
335
+ } = computeCoordsFromPlacement(rects, placement, rtl);
336
+ let statefulPlacement = placement;
337
+ let middlewareData = {};
338
+ let resetCount = 0;
339
+ for (let i = 0; i < validMiddleware.length; i++) {
340
+ const {
341
+ name,
342
+ fn
343
+ } = validMiddleware[i];
344
+ const {
345
+ x: nextX,
346
+ y: nextY,
347
+ data,
348
+ reset
349
+ } = await fn({
350
+ x,
351
+ y,
352
+ initialPlacement: placement,
353
+ placement: statefulPlacement,
354
+ strategy,
355
+ middlewareData,
356
+ rects,
357
+ platform,
358
+ elements: {
359
+ reference,
360
+ floating
361
+ }
362
+ });
363
+ x = nextX != null ? nextX : x;
364
+ y = nextY != null ? nextY : y;
365
+ middlewareData = {
366
+ ...middlewareData,
367
+ [name]: {
368
+ ...middlewareData[name],
369
+ ...data
370
+ }
371
+ };
372
+ if (reset && resetCount <= 50) {
373
+ resetCount++;
374
+ if (typeof reset === 'object') {
375
+ if (reset.placement) {
376
+ statefulPlacement = reset.placement;
377
+ }
378
+ if (reset.rects) {
379
+ rects = reset.rects === true ? await platform.getElementRects({
380
+ reference,
381
+ floating,
382
+ strategy
383
+ }) : reset.rects;
384
+ }
385
+ ({
386
+ x,
387
+ y
388
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
389
+ }
390
+ i = -1;
391
+ }
392
+ }
393
+ return {
394
+ x,
395
+ y,
396
+ placement: statefulPlacement,
397
+ strategy,
398
+ middlewareData
399
+ };
400
+ };
401
+
402
+ /**
403
+ * Resolves with an object of overflow side offsets that determine how much the
404
+ * element is overflowing a given clipping boundary on each side.
405
+ * - positive = overflowing the boundary by that number of pixels
406
+ * - negative = how many pixels left before it will overflow
407
+ * - 0 = lies flush with the boundary
408
+ * @see https://floating-ui.com/docs/detectOverflow
409
+ */
410
+ async function detectOverflow(state, options) {
411
+ var _await$platform$isEle;
412
+ if (options === void 0) {
413
+ options = {};
414
+ }
415
+ const {
416
+ x,
417
+ y,
418
+ platform,
419
+ rects,
420
+ elements,
421
+ strategy
422
+ } = state;
423
+ const {
424
+ boundary = 'clippingAncestors',
425
+ rootBoundary = 'viewport',
426
+ elementContext = 'floating',
427
+ altBoundary = false,
428
+ padding = 0
429
+ } = evaluate(options, state);
430
+ const paddingObject = getPaddingObject(padding);
431
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
432
+ const element = elements[altBoundary ? altContext : elementContext];
433
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
434
+ 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))),
435
+ boundary,
436
+ rootBoundary,
437
+ strategy
438
+ }));
439
+ const rect = elementContext === 'floating' ? {
440
+ ...rects.floating,
441
+ x,
442
+ y
443
+ } : rects.reference;
444
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
445
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
446
+ x: 1,
447
+ y: 1
448
+ } : {
449
+ x: 1,
450
+ y: 1
451
+ };
452
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
453
+ elements,
454
+ rect,
455
+ offsetParent,
456
+ strategy
457
+ }) : rect);
458
+ return {
459
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
460
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
461
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
462
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
463
+ };
464
+ }
465
+
466
+ /**
467
+ * Provides data to position an inner element of the floating element so that it
468
+ * appears centered to the reference element.
469
+ * @see https://floating-ui.com/docs/arrow
470
+ */
471
+ const arrow$1 = options => ({
472
+ name: 'arrow',
473
+ options,
474
+ async fn(state) {
475
+ const {
476
+ x,
477
+ y,
478
+ placement,
479
+ rects,
480
+ platform,
481
+ elements,
482
+ middlewareData
483
+ } = state;
484
+ // Since `element` is required, we don't Partial<> the type.
485
+ const {
486
+ element,
487
+ padding = 0
488
+ } = evaluate(options, state) || {};
489
+ if (element == null) {
490
+ return {};
491
+ }
492
+ const paddingObject = getPaddingObject(padding);
493
+ const coords = {
494
+ x,
495
+ y
496
+ };
497
+ const axis = getAlignmentAxis(placement);
498
+ const length = getAxisLength(axis);
499
+ const arrowDimensions = await platform.getDimensions(element);
500
+ const isYAxis = axis === 'y';
501
+ const minProp = isYAxis ? 'top' : 'left';
502
+ const maxProp = isYAxis ? 'bottom' : 'right';
503
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
504
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
505
+ const startDiff = coords[axis] - rects.reference[axis];
506
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
507
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
508
+
509
+ // DOM platform can return `window` as the `offsetParent`.
510
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
511
+ clientSize = elements.floating[clientProp] || rects.floating[length];
512
+ }
513
+ const centerToReference = endDiff / 2 - startDiff / 2;
514
+
515
+ // If the padding is large enough that it causes the arrow to no longer be
516
+ // centered, modify the padding so that it is centered.
517
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
518
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
519
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
520
+
521
+ // Make sure the arrow doesn't overflow the floating element if the center
522
+ // point is outside the floating element's bounds.
523
+ const min$1 = minPadding;
524
+ const max = clientSize - arrowDimensions[length] - maxPadding;
525
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
526
+ const offset = clamp(min$1, center, max);
527
+
528
+ // If the reference is small enough that the arrow's padding causes it to
529
+ // to point to nothing for an aligned placement, adjust the offset of the
530
+ // floating element itself. To ensure `shift()` continues to take action,
531
+ // a single reset is performed when this is true.
532
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
533
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
534
+ return {
535
+ [axis]: coords[axis] + alignmentOffset,
536
+ data: {
537
+ [axis]: offset,
538
+ centerOffset: center - offset - alignmentOffset,
539
+ ...(shouldAddOffset && {
540
+ alignmentOffset
541
+ })
542
+ },
543
+ reset: shouldAddOffset
544
+ };
545
+ }
546
+ });
547
+
548
+ /**
549
+ * Optimizes the visibility of the floating element by flipping the `placement`
550
+ * in order to keep it in view when the preferred placement(s) will overflow the
551
+ * clipping boundary. Alternative to `autoPlacement`.
552
+ * @see https://floating-ui.com/docs/flip
553
+ */
554
+ const flip$1 = function (options) {
555
+ if (options === void 0) {
556
+ options = {};
557
+ }
558
+ return {
559
+ name: 'flip',
560
+ options,
561
+ async fn(state) {
562
+ var _middlewareData$arrow, _middlewareData$flip;
563
+ const {
564
+ placement,
565
+ middlewareData,
566
+ rects,
567
+ initialPlacement,
568
+ platform,
569
+ elements
570
+ } = state;
571
+ const {
572
+ mainAxis: checkMainAxis = true,
573
+ crossAxis: checkCrossAxis = true,
574
+ fallbackPlacements: specifiedFallbackPlacements,
575
+ fallbackStrategy = 'bestFit',
576
+ fallbackAxisSideDirection = 'none',
577
+ flipAlignment = true,
578
+ ...detectOverflowOptions
579
+ } = evaluate(options, state);
580
+
581
+ // If a reset by the arrow was caused due to an alignment offset being
582
+ // added, we should skip any logic now since `flip()` has already done its
583
+ // work.
584
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
585
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
586
+ return {};
587
+ }
588
+ const side = getSide(placement);
589
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
590
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
591
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
592
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
593
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
594
+ }
595
+ const placements = [initialPlacement, ...fallbackPlacements];
596
+ const overflow = await detectOverflow(state, detectOverflowOptions);
597
+ const overflows = [];
598
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
599
+ if (checkMainAxis) {
600
+ overflows.push(overflow[side]);
601
+ }
602
+ if (checkCrossAxis) {
603
+ const sides = getAlignmentSides(placement, rects, rtl);
604
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
605
+ }
606
+ overflowsData = [...overflowsData, {
607
+ placement,
608
+ overflows
609
+ }];
610
+
611
+ // One or more sides is overflowing.
612
+ if (!overflows.every(side => side <= 0)) {
613
+ var _middlewareData$flip2, _overflowsData$filter;
614
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
615
+ const nextPlacement = placements[nextIndex];
616
+ if (nextPlacement) {
617
+ // Try next placement and re-run the lifecycle.
618
+ return {
619
+ data: {
620
+ index: nextIndex,
621
+ overflows: overflowsData
622
+ },
623
+ reset: {
624
+ placement: nextPlacement
625
+ }
626
+ };
627
+ }
628
+
629
+ // First, find the candidates that fit on the mainAxis side of overflow,
630
+ // then find the placement that fits the best on the main crossAxis side.
631
+ 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;
632
+
633
+ // Otherwise fallback.
634
+ if (!resetPlacement) {
635
+ switch (fallbackStrategy) {
636
+ case 'bestFit':
637
+ {
638
+ var _overflowsData$map$so;
639
+ const placement = (_overflowsData$map$so = overflowsData.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$map$so[0];
640
+ if (placement) {
641
+ resetPlacement = placement;
642
+ }
643
+ break;
644
+ }
645
+ case 'initialPlacement':
646
+ resetPlacement = initialPlacement;
647
+ break;
648
+ }
649
+ }
650
+ if (placement !== resetPlacement) {
651
+ return {
652
+ reset: {
653
+ placement: resetPlacement
654
+ }
655
+ };
656
+ }
657
+ }
658
+ return {};
659
+ }
660
+ };
661
+ };
662
+
663
+ // For type backwards-compatibility, the `OffsetOptions` type was also
664
+ // Derivable.
665
+
666
+ async function convertValueToCoords(state, options) {
667
+ const {
668
+ placement,
669
+ platform,
670
+ elements
671
+ } = state;
672
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
673
+ const side = getSide(placement);
674
+ const alignment = getAlignment(placement);
675
+ const isVertical = getSideAxis(placement) === 'y';
676
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
677
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
678
+ const rawValue = evaluate(options, state);
679
+ let {
680
+ mainAxis,
681
+ crossAxis,
682
+ alignmentAxis
683
+ } = typeof rawValue === 'number' ? {
684
+ mainAxis: rawValue,
685
+ crossAxis: 0,
686
+ alignmentAxis: null
687
+ } : {
688
+ mainAxis: 0,
689
+ crossAxis: 0,
690
+ alignmentAxis: null,
691
+ ...rawValue
692
+ };
693
+ if (alignment && typeof alignmentAxis === 'number') {
694
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
695
+ }
696
+ return isVertical ? {
697
+ x: crossAxis * crossAxisMulti,
698
+ y: mainAxis * mainAxisMulti
699
+ } : {
700
+ x: mainAxis * mainAxisMulti,
701
+ y: crossAxis * crossAxisMulti
702
+ };
703
+ }
704
+
705
+ /**
706
+ * Modifies the placement by translating the floating element along the
707
+ * specified axes.
708
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
709
+ * object may be passed.
710
+ * @see https://floating-ui.com/docs/offset
711
+ */
712
+ const offset = function (options) {
713
+ if (options === void 0) {
714
+ options = 0;
715
+ }
716
+ return {
717
+ name: 'offset',
718
+ options,
719
+ async fn(state) {
720
+ var _middlewareData$offse, _middlewareData$arrow;
721
+ const {
722
+ x,
723
+ y,
724
+ placement,
725
+ middlewareData
726
+ } = state;
727
+ const diffCoords = await convertValueToCoords(state, options);
728
+
729
+ // If the placement is the same and the arrow caused an alignment offset
730
+ // then we don't need to change the positioning coordinates.
731
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
732
+ return {};
733
+ }
734
+ return {
735
+ x: x + diffCoords.x,
736
+ y: y + diffCoords.y,
737
+ data: {
738
+ ...diffCoords,
739
+ placement
740
+ }
741
+ };
742
+ }
743
+ };
744
+ };
745
+
746
+ function getCssDimensions(element) {
747
+ const css = getComputedStyle(element);
748
+ // In testing environments, the `width` and `height` properties are empty
749
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
750
+ let width = parseFloat(css.width) || 0;
751
+ let height = parseFloat(css.height) || 0;
752
+ const hasOffset = isHTMLElement(element);
753
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
754
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
755
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
756
+ if (shouldFallback) {
757
+ width = offsetWidth;
758
+ height = offsetHeight;
759
+ }
760
+ return {
761
+ width,
762
+ height,
763
+ $: shouldFallback
764
+ };
765
+ }
766
+
767
+ function unwrapElement(element) {
768
+ return !isElement(element) ? element.contextElement : element;
769
+ }
770
+
771
+ function getScale(element) {
772
+ const domElement = unwrapElement(element);
773
+ if (!isHTMLElement(domElement)) {
774
+ return createCoords(1);
775
+ }
776
+ const rect = domElement.getBoundingClientRect();
777
+ const {
778
+ width,
779
+ height,
780
+ $
781
+ } = getCssDimensions(domElement);
782
+ let x = ($ ? round(rect.width) : rect.width) / width;
783
+ let y = ($ ? round(rect.height) : rect.height) / height;
784
+
785
+ // 0, NaN, or Infinity should always fallback to 1.
786
+
787
+ if (!x || !Number.isFinite(x)) {
788
+ x = 1;
789
+ }
790
+ if (!y || !Number.isFinite(y)) {
791
+ y = 1;
792
+ }
793
+ return {
794
+ x,
795
+ y
796
+ };
797
+ }
798
+
799
+ const noOffsets = /*#__PURE__*/createCoords(0);
800
+ function getVisualOffsets(element) {
801
+ const win = getWindow(element);
802
+ if (!isWebKit() || !win.visualViewport) {
803
+ return noOffsets;
804
+ }
805
+ return {
806
+ x: win.visualViewport.offsetLeft,
807
+ y: win.visualViewport.offsetTop
808
+ };
809
+ }
810
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
811
+ if (isFixed === void 0) {
812
+ isFixed = false;
813
+ }
814
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
815
+ return false;
816
+ }
817
+ return isFixed;
818
+ }
819
+
820
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
821
+ if (includeScale === void 0) {
822
+ includeScale = false;
823
+ }
824
+ if (isFixedStrategy === void 0) {
825
+ isFixedStrategy = false;
826
+ }
827
+ const clientRect = element.getBoundingClientRect();
828
+ const domElement = unwrapElement(element);
829
+ let scale = createCoords(1);
830
+ if (includeScale) {
831
+ if (offsetParent) {
832
+ if (isElement(offsetParent)) {
833
+ scale = getScale(offsetParent);
834
+ }
835
+ } else {
836
+ scale = getScale(element);
837
+ }
838
+ }
839
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
840
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
841
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
842
+ let width = clientRect.width / scale.x;
843
+ let height = clientRect.height / scale.y;
844
+ if (domElement) {
845
+ const win = getWindow(domElement);
846
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
847
+ let currentIFrame = win.frameElement;
848
+ while (currentIFrame && offsetParent && offsetWin !== win) {
849
+ const iframeScale = getScale(currentIFrame);
850
+ const iframeRect = currentIFrame.getBoundingClientRect();
851
+ const css = getComputedStyle(currentIFrame);
852
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
853
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
854
+ x *= iframeScale.x;
855
+ y *= iframeScale.y;
856
+ width *= iframeScale.x;
857
+ height *= iframeScale.y;
858
+ x += left;
859
+ y += top;
860
+ currentIFrame = getWindow(currentIFrame).frameElement;
861
+ }
862
+ }
863
+ return rectToClientRect({
864
+ width,
865
+ height,
866
+ x,
867
+ y
868
+ });
869
+ }
870
+
871
+ const topLayerSelectors = [':popover-open', ':modal'];
872
+ function topLayer(floating) {
873
+ let isTopLayer = false;
874
+ let x = 0;
875
+ let y = 0;
876
+ function setIsTopLayer(selector) {
877
+ try {
878
+ isTopLayer = isTopLayer || floating.matches(selector);
879
+ } catch (e) {}
880
+ }
881
+ topLayerSelectors.forEach(selector => {
882
+ setIsTopLayer(selector);
883
+ });
884
+ if (isTopLayer) {
885
+ const containingBlock = getContainingBlock(floating);
886
+ if (containingBlock) {
887
+ const rect = containingBlock.getBoundingClientRect();
888
+ x = rect.x;
889
+ y = rect.y;
890
+ }
891
+ }
892
+ return [isTopLayer, x, y];
893
+ }
894
+
895
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
896
+ let {
897
+ elements,
898
+ rect,
899
+ offsetParent,
900
+ strategy
901
+ } = _ref;
902
+ const documentElement = getDocumentElement(offsetParent);
903
+ const [isTopLayer] = elements ? topLayer(elements.floating) : [false];
904
+ if (offsetParent === documentElement || isTopLayer) {
905
+ return rect;
906
+ }
907
+ let scroll = {
908
+ scrollLeft: 0,
909
+ scrollTop: 0
910
+ };
911
+ let scale = createCoords(1);
912
+ const offsets = createCoords(0);
913
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
914
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
915
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
916
+ scroll = getNodeScroll(offsetParent);
917
+ }
918
+ if (isHTMLElement(offsetParent)) {
919
+ const offsetRect = getBoundingClientRect(offsetParent);
920
+ scale = getScale(offsetParent);
921
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
922
+ offsets.y = offsetRect.y + offsetParent.clientTop;
923
+ }
924
+ }
925
+ return {
926
+ width: rect.width * scale.x,
927
+ height: rect.height * scale.y,
928
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
929
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
930
+ };
931
+ }
932
+
933
+ function getClientRects(element) {
934
+ return Array.from(element.getClientRects());
935
+ }
936
+
937
+ function getWindowScrollBarX(element) {
938
+ // If <html> has a CSS width greater than the viewport, then this will be
939
+ // incorrect for RTL.
940
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
941
+ }
942
+
943
+ // Gets the entire size of the scrollable document area, even extending outside
944
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
945
+ function getDocumentRect(element) {
946
+ const html = getDocumentElement(element);
947
+ const scroll = getNodeScroll(element);
948
+ const body = element.ownerDocument.body;
949
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
950
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
951
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
952
+ const y = -scroll.scrollTop;
953
+ if (getComputedStyle(body).direction === 'rtl') {
954
+ x += max(html.clientWidth, body.clientWidth) - width;
955
+ }
956
+ return {
957
+ width,
958
+ height,
959
+ x,
960
+ y
961
+ };
962
+ }
963
+
964
+ function getViewportRect(element, strategy) {
965
+ const win = getWindow(element);
966
+ const html = getDocumentElement(element);
967
+ const visualViewport = win.visualViewport;
968
+ let width = html.clientWidth;
969
+ let height = html.clientHeight;
970
+ let x = 0;
971
+ let y = 0;
972
+ if (visualViewport) {
973
+ width = visualViewport.width;
974
+ height = visualViewport.height;
975
+ const visualViewportBased = isWebKit();
976
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
977
+ x = visualViewport.offsetLeft;
978
+ y = visualViewport.offsetTop;
979
+ }
980
+ }
981
+ return {
982
+ width,
983
+ height,
984
+ x,
985
+ y
986
+ };
987
+ }
988
+
989
+ // Returns the inner client rect, subtracting scrollbars if present.
990
+ function getInnerBoundingClientRect(element, strategy) {
991
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
992
+ const top = clientRect.top + element.clientTop;
993
+ const left = clientRect.left + element.clientLeft;
994
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
995
+ const width = element.clientWidth * scale.x;
996
+ const height = element.clientHeight * scale.y;
997
+ const x = left * scale.x;
998
+ const y = top * scale.y;
999
+ return {
1000
+ width,
1001
+ height,
1002
+ x,
1003
+ y
1004
+ };
1005
+ }
1006
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1007
+ let rect;
1008
+ if (clippingAncestor === 'viewport') {
1009
+ rect = getViewportRect(element, strategy);
1010
+ } else if (clippingAncestor === 'document') {
1011
+ rect = getDocumentRect(getDocumentElement(element));
1012
+ } else if (isElement(clippingAncestor)) {
1013
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1014
+ } else {
1015
+ const visualOffsets = getVisualOffsets(element);
1016
+ rect = {
1017
+ ...clippingAncestor,
1018
+ x: clippingAncestor.x - visualOffsets.x,
1019
+ y: clippingAncestor.y - visualOffsets.y
1020
+ };
1021
+ }
1022
+ return rectToClientRect(rect);
1023
+ }
1024
+ function hasFixedPositionAncestor(element, stopNode) {
1025
+ const parentNode = getParentNode(element);
1026
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1027
+ return false;
1028
+ }
1029
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1030
+ }
1031
+
1032
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1033
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1034
+ // of the given element up the tree.
1035
+ function getClippingElementAncestors(element, cache) {
1036
+ const cachedResult = cache.get(element);
1037
+ if (cachedResult) {
1038
+ return cachedResult;
1039
+ }
1040
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1041
+ let currentContainingBlockComputedStyle = null;
1042
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1043
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1044
+
1045
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1046
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1047
+ const computedStyle = getComputedStyle(currentNode);
1048
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1049
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1050
+ currentContainingBlockComputedStyle = null;
1051
+ }
1052
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1053
+ if (shouldDropCurrentNode) {
1054
+ // Drop non-containing blocks.
1055
+ result = result.filter(ancestor => ancestor !== currentNode);
1056
+ } else {
1057
+ // Record last containing block for next iteration.
1058
+ currentContainingBlockComputedStyle = computedStyle;
1059
+ }
1060
+ currentNode = getParentNode(currentNode);
1061
+ }
1062
+ cache.set(element, result);
1063
+ return result;
1064
+ }
1065
+
1066
+ // Gets the maximum area that the element is visible in due to any number of
1067
+ // clipping ancestors.
1068
+ function getClippingRect(_ref) {
1069
+ let {
1070
+ element,
1071
+ boundary,
1072
+ rootBoundary,
1073
+ strategy
1074
+ } = _ref;
1075
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
1076
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1077
+ const firstClippingAncestor = clippingAncestors[0];
1078
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1079
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1080
+ accRect.top = max(rect.top, accRect.top);
1081
+ accRect.right = min(rect.right, accRect.right);
1082
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1083
+ accRect.left = max(rect.left, accRect.left);
1084
+ return accRect;
1085
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1086
+ return {
1087
+ width: clippingRect.right - clippingRect.left,
1088
+ height: clippingRect.bottom - clippingRect.top,
1089
+ x: clippingRect.left,
1090
+ y: clippingRect.top
1091
+ };
1092
+ }
1093
+
1094
+ function getDimensions(element) {
1095
+ const {
1096
+ width,
1097
+ height
1098
+ } = getCssDimensions(element);
1099
+ return {
1100
+ width,
1101
+ height
1102
+ };
1103
+ }
1104
+
1105
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy, floating) {
1106
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1107
+ const documentElement = getDocumentElement(offsetParent);
1108
+ const isFixed = strategy === 'fixed';
1109
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1110
+ let scroll = {
1111
+ scrollLeft: 0,
1112
+ scrollTop: 0
1113
+ };
1114
+ const offsets = createCoords(0);
1115
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1116
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1117
+ scroll = getNodeScroll(offsetParent);
1118
+ }
1119
+ if (isOffsetParentAnElement) {
1120
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1121
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1122
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1123
+ } else if (documentElement) {
1124
+ offsets.x = getWindowScrollBarX(documentElement);
1125
+ }
1126
+ }
1127
+ let x = rect.left + scroll.scrollLeft - offsets.x;
1128
+ let y = rect.top + scroll.scrollTop - offsets.y;
1129
+ const [isTopLayer, topLayerX, topLayerY] = topLayer(floating);
1130
+ if (isTopLayer) {
1131
+ x += topLayerX;
1132
+ y += topLayerY;
1133
+ if (isOffsetParentAnElement) {
1134
+ x += offsetParent.clientLeft;
1135
+ y += offsetParent.clientTop;
1136
+ }
1137
+ }
1138
+ return {
1139
+ x,
1140
+ y,
1141
+ width: rect.width,
1142
+ height: rect.height
1143
+ };
1144
+ }
1145
+
1146
+ function getTrueOffsetParent(element, polyfill) {
1147
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1148
+ return null;
1149
+ }
1150
+ if (polyfill) {
1151
+ return polyfill(element);
1152
+ }
1153
+ return element.offsetParent;
1154
+ }
1155
+
1156
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1157
+ // such as table ancestors and cross browser bugs.
1158
+ function getOffsetParent(element, polyfill) {
1159
+ const window = getWindow(element);
1160
+ if (!isHTMLElement(element)) {
1161
+ return window;
1162
+ }
1163
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1164
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1165
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1166
+ }
1167
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1168
+ return window;
1169
+ }
1170
+ return offsetParent || getContainingBlock(element) || window;
1171
+ }
1172
+
1173
+ const getElementRects = async function (data) {
1174
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1175
+ const getDimensionsFn = this.getDimensions;
1176
+ return {
1177
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy, data.floating),
1178
+ floating: {
1179
+ x: 0,
1180
+ y: 0,
1181
+ ...(await getDimensionsFn(data.floating))
1182
+ }
1183
+ };
1184
+ };
1185
+
1186
+ function isRTL(element) {
1187
+ return getComputedStyle(element).direction === 'rtl';
1188
+ }
1189
+
1190
+ const platform = {
1191
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1192
+ getDocumentElement,
1193
+ getClippingRect,
1194
+ getOffsetParent,
1195
+ getElementRects,
1196
+ getClientRects,
1197
+ getDimensions,
1198
+ getScale,
1199
+ isElement,
1200
+ isRTL
1201
+ };
1202
+
1203
+ // https://samthor.au/2021/observing-dom/
1204
+ function observeMove(element, onMove) {
1205
+ let io = null;
1206
+ let timeoutId;
1207
+ const root = getDocumentElement(element);
1208
+ function cleanup() {
1209
+ var _io;
1210
+ clearTimeout(timeoutId);
1211
+ (_io = io) == null || _io.disconnect();
1212
+ io = null;
1213
+ }
1214
+ function refresh(skip, threshold) {
1215
+ if (skip === void 0) {
1216
+ skip = false;
1217
+ }
1218
+ if (threshold === void 0) {
1219
+ threshold = 1;
1220
+ }
1221
+ cleanup();
1222
+ const {
1223
+ left,
1224
+ top,
1225
+ width,
1226
+ height
1227
+ } = element.getBoundingClientRect();
1228
+ if (!skip) {
1229
+ onMove();
1230
+ }
1231
+ if (!width || !height) {
1232
+ return;
1233
+ }
1234
+ const insetTop = floor(top);
1235
+ const insetRight = floor(root.clientWidth - (left + width));
1236
+ const insetBottom = floor(root.clientHeight - (top + height));
1237
+ const insetLeft = floor(left);
1238
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1239
+ const options = {
1240
+ rootMargin,
1241
+ threshold: max(0, min(1, threshold)) || 1
1242
+ };
1243
+ let isFirstUpdate = true;
1244
+ function handleObserve(entries) {
1245
+ const ratio = entries[0].intersectionRatio;
1246
+ if (ratio !== threshold) {
1247
+ if (!isFirstUpdate) {
1248
+ return refresh();
1249
+ }
1250
+ if (!ratio) {
1251
+ timeoutId = setTimeout(() => {
1252
+ refresh(false, 1e-7);
1253
+ }, 100);
1254
+ } else {
1255
+ refresh(false, ratio);
1256
+ }
1257
+ }
1258
+ isFirstUpdate = false;
1259
+ }
1260
+
1261
+ // Older browsers don't support a `document` as the root and will throw an
1262
+ // error.
1263
+ try {
1264
+ io = new IntersectionObserver(handleObserve, {
1265
+ ...options,
1266
+ // Handle <iframe>s
1267
+ root: root.ownerDocument
1268
+ });
1269
+ } catch (e) {
1270
+ io = new IntersectionObserver(handleObserve, options);
1271
+ }
1272
+ io.observe(element);
1273
+ }
1274
+ refresh(true);
1275
+ return cleanup;
1276
+ }
1277
+
1278
+ /**
1279
+ * Automatically updates the position of the floating element when necessary.
1280
+ * Should only be called when the floating element is mounted on the DOM or
1281
+ * visible on the screen.
1282
+ * @returns cleanup function that should be invoked when the floating element is
1283
+ * removed from the DOM or hidden from the screen.
1284
+ * @see https://floating-ui.com/docs/autoUpdate
1285
+ */
1286
+ function autoUpdate(reference, floating, update, options) {
1287
+ if (options === void 0) {
1288
+ options = {};
1289
+ }
1290
+ const {
1291
+ ancestorScroll = true,
1292
+ ancestorResize = true,
1293
+ elementResize = typeof ResizeObserver === 'function',
1294
+ layoutShift = typeof IntersectionObserver === 'function',
1295
+ animationFrame = false
1296
+ } = options;
1297
+ const referenceEl = unwrapElement(reference);
1298
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1299
+ ancestors.forEach(ancestor => {
1300
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1301
+ passive: true
1302
+ });
1303
+ ancestorResize && ancestor.addEventListener('resize', update);
1304
+ });
1305
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1306
+ let reobserveFrame = -1;
1307
+ let resizeObserver = null;
1308
+ if (elementResize) {
1309
+ resizeObserver = new ResizeObserver(_ref => {
1310
+ let [firstEntry] = _ref;
1311
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1312
+ // Prevent update loops when using the `size` middleware.
1313
+ // https://github.com/floating-ui/floating-ui/issues/1740
1314
+ resizeObserver.unobserve(floating);
1315
+ cancelAnimationFrame(reobserveFrame);
1316
+ reobserveFrame = requestAnimationFrame(() => {
1317
+ var _resizeObserver;
1318
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1319
+ });
1320
+ }
1321
+ update();
1322
+ });
1323
+ if (referenceEl && !animationFrame) {
1324
+ resizeObserver.observe(referenceEl);
1325
+ }
1326
+ resizeObserver.observe(floating);
1327
+ }
1328
+ let frameId;
1329
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1330
+ if (animationFrame) {
1331
+ frameLoop();
1332
+ }
1333
+ function frameLoop() {
1334
+ const nextRefRect = getBoundingClientRect(reference);
1335
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1336
+ update();
1337
+ }
1338
+ prevRefRect = nextRefRect;
1339
+ frameId = requestAnimationFrame(frameLoop);
1340
+ }
1341
+ update();
1342
+ return () => {
1343
+ var _resizeObserver2;
1344
+ ancestors.forEach(ancestor => {
1345
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1346
+ ancestorResize && ancestor.removeEventListener('resize', update);
1347
+ });
1348
+ cleanupIo == null || cleanupIo();
1349
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1350
+ resizeObserver = null;
1351
+ if (animationFrame) {
1352
+ cancelAnimationFrame(frameId);
1353
+ }
1354
+ };
1355
+ }
1356
+
1357
+ /**
1358
+ * Optimizes the visibility of the floating element by flipping the `placement`
1359
+ * in order to keep it in view when the preferred placement(s) will overflow the
1360
+ * clipping boundary. Alternative to `autoPlacement`.
1361
+ * @see https://floating-ui.com/docs/flip
1362
+ */
1363
+ const flip = flip$1;
1364
+
1365
+ /**
1366
+ * Provides data to position an inner element of the floating element so that it
1367
+ * appears centered to the reference element.
1368
+ * @see https://floating-ui.com/docs/arrow
1369
+ */
1370
+ const arrow = arrow$1;
1371
+
1372
+ /**
1373
+ * Computes the `x` and `y` coordinates that will place the floating element
1374
+ * next to a given reference element.
1375
+ */
1376
+ const computePosition = (reference, floating, options) => {
1377
+ // This caches the expensive `getClippingElementAncestors` function so that
1378
+ // multiple lifecycle resets re-use the same result. It only lives for a
1379
+ // single call. If other functions become expensive, we can add them as well.
1380
+ const cache = new Map();
1381
+ const mergedOptions = {
1382
+ platform,
1383
+ ...options
1384
+ };
1385
+ const platformWithCache = {
1386
+ ...mergedOptions.platform,
1387
+ _c: cache
1388
+ };
1389
+ return computePosition$1(reference, floating, {
1390
+ ...mergedOptions,
1391
+ platform: platformWithCache
1392
+ });
1393
+ };
1394
+
1395
+ exports.arrow = arrow;
1396
+ exports.autoUpdate = autoUpdate;
1397
+ exports.computePosition = computePosition;
1398
+ exports.flip = flip;
1399
+ exports.isElement = isElement;
1400
+ exports.offset = offset;
1401
+ exports.platform = platform;