bromcom-ui-next 0.1.4 → 0.1.5

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 (170) hide show
  1. package/dist/bromcom-ui/bromcom-ui.css +1 -1
  2. package/dist/bromcom-ui/bromcom-ui.esm.js +1 -1
  3. package/dist/bromcom-ui/bromcom-ui.esm.js.map +1 -1
  4. package/dist/bromcom-ui/{p-1d86c1cf.entry.js → p-2bbd3c52.entry.js} +2 -2
  5. package/dist/bromcom-ui/{p-1d86c1cf.entry.js.map → p-2bbd3c52.entry.js.map} +1 -1
  6. package/dist/bromcom-ui/p-2f1d87a7.entry.js +2 -0
  7. package/dist/bromcom-ui/p-2f1d87a7.entry.js.map +1 -0
  8. package/dist/bromcom-ui/{p-1b11150b.entry.js → p-4f402148.entry.js} +2 -2
  9. package/dist/bromcom-ui/{p-1b11150b.entry.js.map → p-4f402148.entry.js.map} +1 -1
  10. package/dist/bromcom-ui/p-53f21d16.entry.js +2 -0
  11. package/dist/bromcom-ui/{p-dcea8d62.entry.js.map → p-53f21d16.entry.js.map} +1 -1
  12. package/dist/bromcom-ui/{p-04f6d730.entry.js → p-5737e7de.entry.js} +2 -2
  13. package/dist/bromcom-ui/{p-04f6d730.entry.js.map → p-5737e7de.entry.js.map} +1 -1
  14. package/dist/bromcom-ui/{p-5d0838e9.entry.js → p-5bee2e76.entry.js} +2 -2
  15. package/dist/bromcom-ui/{p-5d0838e9.entry.js.map → p-5bee2e76.entry.js.map} +1 -1
  16. package/dist/bromcom-ui/p-63cb0933.entry.js +2 -0
  17. package/dist/bromcom-ui/p-63cb0933.entry.js.map +1 -0
  18. package/dist/bromcom-ui/{p-a590f793.entry.js → p-6abaf96f.entry.js} +2 -2
  19. package/dist/bromcom-ui/{p-a590f793.entry.js.map → p-6abaf96f.entry.js.map} +1 -1
  20. package/dist/bromcom-ui/{p-cd437280.entry.js → p-7a1bf6a6.entry.js} +2 -2
  21. package/dist/bromcom-ui/{p-cd437280.entry.js.map → p-7a1bf6a6.entry.js.map} +1 -1
  22. package/dist/bromcom-ui/{p-3b607038.entry.js → p-e08b23ff.entry.js} +2 -2
  23. package/dist/bromcom-ui/{p-3b607038.entry.js.map → p-e08b23ff.entry.js.map} +1 -1
  24. package/dist/bromcom-ui/p-f0ece968.entry.js +2 -0
  25. package/dist/bromcom-ui/p-f0ece968.entry.js.map +1 -0
  26. package/dist/bromcom-ui/{p-ebed10d5.entry.js → p-f9eeafa7.entry.js} +2 -2
  27. package/dist/bromcom-ui/{p-ebed10d5.entry.js.map → p-f9eeafa7.entry.js.map} +1 -1
  28. package/dist/bromcom-ui/styles/theme-variables.ts +369 -0
  29. package/dist/bromcom-ui/styles/themes/index.css +1 -0
  30. package/dist/bromcom-ui/styles/themes/library/default.css +73 -0
  31. package/dist/bromcom-ui/styles/variables/box-shadow.css +15 -0
  32. package/dist/bromcom-ui/styles/variables/colors-dark.css +314 -0
  33. package/dist/bromcom-ui/styles/variables/colors-light.css +325 -0
  34. package/dist/bromcom-ui/styles/variables/font-size-rem.css +33 -0
  35. package/dist/bromcom-ui/styles/variables/font-size.css +33 -0
  36. package/dist/bromcom-ui/styles/variables/index.css +6 -0
  37. package/dist/cjs/bcm-accordion-group.cjs.entry.js +1 -1
  38. package/dist/cjs/bcm-accordion-group.cjs.entry.js.map +1 -1
  39. package/dist/cjs/bcm-accordion.cjs.entry.js +1 -1
  40. package/dist/cjs/bcm-accordion.cjs.entry.js.map +1 -1
  41. package/dist/cjs/bcm-alert.cjs.entry.js +1 -1
  42. package/dist/cjs/bcm-alert.cjs.entry.js.map +1 -1
  43. package/dist/cjs/bcm-avatar_4.cjs.entry.js +4 -4
  44. package/dist/cjs/bcm-avatar_4.cjs.entry.js.map +1 -1
  45. package/dist/cjs/bcm-chip.cjs.entry.js +1 -1
  46. package/dist/cjs/bcm-chip.cjs.entry.js.map +1 -1
  47. package/dist/cjs/bcm-divider.cjs.entry.js +1 -1
  48. package/dist/cjs/bcm-divider.cjs.entry.js.map +1 -1
  49. package/dist/cjs/bcm-dropdown-item.cjs.entry.js +63 -0
  50. package/dist/cjs/bcm-dropdown-item.cjs.entry.js.map +1 -0
  51. package/dist/cjs/bcm-dropdown.cjs.entry.js +56 -0
  52. package/dist/cjs/bcm-dropdown.cjs.entry.js.map +1 -0
  53. package/dist/cjs/bcm-input.cjs.entry.js +3 -3
  54. package/dist/cjs/bcm-input.cjs.entry.js.map +1 -1
  55. package/dist/cjs/bcm-linked.cjs.entry.js +1981 -0
  56. package/dist/cjs/bcm-linked.cjs.entry.js.map +1 -0
  57. package/dist/cjs/bcm-text.cjs.entry.js +2 -2
  58. package/dist/cjs/bcm-text.cjs.entry.js.map +1 -1
  59. package/dist/cjs/bcm-textarea.cjs.entry.js +4 -4
  60. package/dist/cjs/bcm-textarea.cjs.entry.js.map +1 -1
  61. package/dist/cjs/bromcom-ui.cjs.js +1 -1
  62. package/dist/cjs/loader.cjs.js +1 -1
  63. package/dist/collection/collection-manifest.json +3 -0
  64. package/dist/collection/components/accordion/accordion.css +1 -1
  65. package/dist/collection/components/accordion-group/accordion-group.css +1 -1
  66. package/dist/collection/components/alert/alert.css +1 -1
  67. package/dist/collection/components/avatar/avatar.css +1 -1
  68. package/dist/collection/components/badge/badge.css +1 -1
  69. package/dist/collection/components/basic-badge/basic-badge.css +1 -1
  70. package/dist/collection/components/button/button.css +1 -1
  71. package/dist/collection/components/chip/chip.css +1 -1
  72. package/dist/collection/components/divider/divider.css +1 -1
  73. package/dist/collection/components/dropdown/dropdown.component.js +110 -0
  74. package/dist/collection/components/dropdown/dropdown.component.js.map +1 -0
  75. package/dist/collection/components/dropdown/dropdown.css +1 -0
  76. package/dist/collection/components/dropdown-item/dropdown-item.component.js +198 -0
  77. package/dist/collection/components/dropdown-item/dropdown-item.component.js.map +1 -0
  78. package/dist/collection/components/dropdown-item/dropdown-item.css +1 -0
  79. package/dist/collection/components/input/input.component.js +2 -2
  80. package/dist/collection/components/input/input.css +1 -1
  81. package/dist/collection/components/linked/linked.component.js +140 -0
  82. package/dist/collection/components/linked/linked.component.js.map +1 -0
  83. package/dist/collection/components/linked/linked.css +1 -0
  84. package/dist/collection/components/text/text.component.js +1 -1
  85. package/dist/collection/components/text/text.css +1 -1
  86. package/dist/collection/components/textarea/textarea.component.js +3 -3
  87. package/dist/collection/components/textarea/textarea.css +1 -1
  88. package/dist/collection/styles/theme-variables.js +15 -0
  89. package/dist/collection/styles/theme-variables.js.map +1 -1
  90. package/dist/collection/styles/theme-variables.ts +369 -0
  91. package/dist/collection/styles/themes/index.css +1 -0
  92. package/dist/collection/styles/themes/library/default.css +73 -0
  93. package/dist/collection/styles/variables/box-shadow.css +15 -0
  94. package/dist/collection/styles/variables/colors-dark.css +314 -0
  95. package/dist/collection/styles/variables/colors-light.css +325 -0
  96. package/dist/collection/styles/variables/font-size-rem.css +33 -0
  97. package/dist/collection/styles/variables/font-size.css +33 -0
  98. package/dist/collection/styles/variables/index.css +6 -0
  99. package/dist/components/bcm-accordion-group.js +1 -1
  100. package/dist/components/bcm-accordion-group.js.map +1 -1
  101. package/dist/components/bcm-accordion.js +1 -1
  102. package/dist/components/bcm-accordion.js.map +1 -1
  103. package/dist/components/bcm-alert.js +1 -1
  104. package/dist/components/bcm-alert.js.map +1 -1
  105. package/dist/components/bcm-avatar.js +2 -2
  106. package/dist/components/bcm-avatar.js.map +1 -1
  107. package/dist/components/bcm-badge.js +1 -1
  108. package/dist/components/bcm-basic-badge.js +1 -1
  109. package/dist/components/bcm-basic-badge.js.map +1 -1
  110. package/dist/components/bcm-button.js +1 -327
  111. package/dist/components/bcm-button.js.map +1 -1
  112. package/dist/components/bcm-chip.js +1 -1
  113. package/dist/components/bcm-chip.js.map +1 -1
  114. package/dist/components/bcm-divider.js +1 -1
  115. package/dist/components/bcm-divider.js.map +1 -1
  116. package/dist/components/bcm-dropdown-item.d.ts +11 -0
  117. package/dist/components/bcm-dropdown-item.js +85 -0
  118. package/dist/components/bcm-dropdown-item.js.map +1 -0
  119. package/dist/components/bcm-dropdown.d.ts +11 -0
  120. package/dist/components/bcm-dropdown.js +87 -0
  121. package/dist/components/bcm-dropdown.js.map +1 -0
  122. package/dist/components/bcm-input.js +3 -3
  123. package/dist/components/bcm-input.js.map +1 -1
  124. package/dist/components/bcm-linked.d.ts +11 -0
  125. package/dist/components/bcm-linked.js +8 -0
  126. package/dist/components/bcm-linked.js.map +1 -0
  127. package/dist/components/bcm-text.js +2 -2
  128. package/dist/components/bcm-text.js.map +1 -1
  129. package/dist/components/bcm-textarea.js +4 -4
  130. package/dist/components/bcm-textarea.js.map +1 -1
  131. package/dist/components/p-0063a3d9.js +331 -0
  132. package/dist/components/p-0063a3d9.js.map +1 -0
  133. package/dist/components/p-613ee92d.js +1997 -0
  134. package/dist/components/p-613ee92d.js.map +1 -0
  135. package/dist/components/{p-39637e05.js → p-e918f815.js} +2 -2
  136. package/dist/components/{p-39637e05.js.map → p-e918f815.js.map} +1 -1
  137. package/dist/esm/bcm-accordion-group.entry.js +1 -1
  138. package/dist/esm/bcm-accordion-group.entry.js.map +1 -1
  139. package/dist/esm/bcm-accordion.entry.js +1 -1
  140. package/dist/esm/bcm-accordion.entry.js.map +1 -1
  141. package/dist/esm/bcm-alert.entry.js +1 -1
  142. package/dist/esm/bcm-alert.entry.js.map +1 -1
  143. package/dist/esm/bcm-avatar_4.entry.js +4 -4
  144. package/dist/esm/bcm-avatar_4.entry.js.map +1 -1
  145. package/dist/esm/bcm-chip.entry.js +1 -1
  146. package/dist/esm/bcm-chip.entry.js.map +1 -1
  147. package/dist/esm/bcm-divider.entry.js +1 -1
  148. package/dist/esm/bcm-divider.entry.js.map +1 -1
  149. package/dist/esm/bcm-dropdown-item.entry.js +59 -0
  150. package/dist/esm/bcm-dropdown-item.entry.js.map +1 -0
  151. package/dist/esm/bcm-dropdown.entry.js +52 -0
  152. package/dist/esm/bcm-dropdown.entry.js.map +1 -0
  153. package/dist/esm/bcm-input.entry.js +3 -3
  154. package/dist/esm/bcm-input.entry.js.map +1 -1
  155. package/dist/esm/bcm-linked.entry.js +1977 -0
  156. package/dist/esm/bcm-linked.entry.js.map +1 -0
  157. package/dist/esm/bcm-text.entry.js +2 -2
  158. package/dist/esm/bcm-text.entry.js.map +1 -1
  159. package/dist/esm/bcm-textarea.entry.js +4 -4
  160. package/dist/esm/bcm-textarea.entry.js.map +1 -1
  161. package/dist/esm/bromcom-ui.js +1 -1
  162. package/dist/esm/loader.js +1 -1
  163. package/dist/tailwind.config.js +32 -0
  164. package/dist/types/components/dropdown/dropdown.component.d.ts +14 -0
  165. package/dist/types/components/dropdown-item/dropdown-item.component.d.ts +14 -0
  166. package/dist/types/components/linked/linked.component.d.ts +16 -0
  167. package/dist/types/components.d.ts +89 -0
  168. package/dist/types/styles/theme-variables.d.ts +15 -0
  169. package/package.json +2 -1
  170. package/dist/bromcom-ui/p-dcea8d62.entry.js +0 -2
@@ -0,0 +1,1977 @@
1
+ import { r as registerInstance, h, g as getElement } from './index-27cc1bac.js';
2
+
3
+ /**
4
+ * Custom positioning reference element.
5
+ * @see https://floating-ui.com/docs/virtual-elements
6
+ */
7
+
8
+ const sides = ['top', 'right', 'bottom', 'left'];
9
+ const alignments = ['start', 'end'];
10
+ const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
11
+ const min = Math.min;
12
+ const max = Math.max;
13
+ const round = Math.round;
14
+ const createCoords = v => ({
15
+ x: v,
16
+ y: v
17
+ });
18
+ const oppositeSideMap = {
19
+ left: 'right',
20
+ right: 'left',
21
+ bottom: 'top',
22
+ top: 'bottom'
23
+ };
24
+ const oppositeAlignmentMap = {
25
+ start: 'end',
26
+ end: 'start'
27
+ };
28
+ function clamp(start, value, end) {
29
+ return max(start, min(value, end));
30
+ }
31
+ function evaluate(value, param) {
32
+ return typeof value === 'function' ? value(param) : value;
33
+ }
34
+ function getSide(placement) {
35
+ return placement.split('-')[0];
36
+ }
37
+ function getAlignment(placement) {
38
+ return placement.split('-')[1];
39
+ }
40
+ function getOppositeAxis(axis) {
41
+ return axis === 'x' ? 'y' : 'x';
42
+ }
43
+ function getAxisLength(axis) {
44
+ return axis === 'y' ? 'height' : 'width';
45
+ }
46
+ function getSideAxis(placement) {
47
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
48
+ }
49
+ function getAlignmentAxis(placement) {
50
+ return getOppositeAxis(getSideAxis(placement));
51
+ }
52
+ function getAlignmentSides(placement, rects, rtl) {
53
+ if (rtl === void 0) {
54
+ rtl = false;
55
+ }
56
+ const alignment = getAlignment(placement);
57
+ const alignmentAxis = getAlignmentAxis(placement);
58
+ const length = getAxisLength(alignmentAxis);
59
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
60
+ if (rects.reference[length] > rects.floating[length]) {
61
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
62
+ }
63
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
64
+ }
65
+ function getExpandedPlacements(placement) {
66
+ const oppositePlacement = getOppositePlacement(placement);
67
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
68
+ }
69
+ function getOppositeAlignmentPlacement(placement) {
70
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
71
+ }
72
+ function getSideList(side, isStart, rtl) {
73
+ const lr = ['left', 'right'];
74
+ const rl = ['right', 'left'];
75
+ const tb = ['top', 'bottom'];
76
+ const bt = ['bottom', 'top'];
77
+ switch (side) {
78
+ case 'top':
79
+ case 'bottom':
80
+ if (rtl) return isStart ? rl : lr;
81
+ return isStart ? lr : rl;
82
+ case 'left':
83
+ case 'right':
84
+ return isStart ? tb : bt;
85
+ default:
86
+ return [];
87
+ }
88
+ }
89
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
90
+ const alignment = getAlignment(placement);
91
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
92
+ if (alignment) {
93
+ list = list.map(side => side + "-" + alignment);
94
+ if (flipAlignment) {
95
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
96
+ }
97
+ }
98
+ return list;
99
+ }
100
+ function getOppositePlacement(placement) {
101
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
102
+ }
103
+ function expandPaddingObject(padding) {
104
+ return {
105
+ top: 0,
106
+ right: 0,
107
+ bottom: 0,
108
+ left: 0,
109
+ ...padding
110
+ };
111
+ }
112
+ function getPaddingObject(padding) {
113
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
114
+ top: padding,
115
+ right: padding,
116
+ bottom: padding,
117
+ left: padding
118
+ };
119
+ }
120
+ function rectToClientRect(rect) {
121
+ const {
122
+ x,
123
+ y,
124
+ width,
125
+ height
126
+ } = rect;
127
+ return {
128
+ width,
129
+ height,
130
+ top: y,
131
+ left: x,
132
+ right: x + width,
133
+ bottom: y + height,
134
+ x,
135
+ y
136
+ };
137
+ }
138
+
139
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
140
+ let {
141
+ reference,
142
+ floating
143
+ } = _ref;
144
+ const sideAxis = getSideAxis(placement);
145
+ const alignmentAxis = getAlignmentAxis(placement);
146
+ const alignLength = getAxisLength(alignmentAxis);
147
+ const side = getSide(placement);
148
+ const isVertical = sideAxis === 'y';
149
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
150
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
151
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
152
+ let coords;
153
+ switch (side) {
154
+ case 'top':
155
+ coords = {
156
+ x: commonX,
157
+ y: reference.y - floating.height
158
+ };
159
+ break;
160
+ case 'bottom':
161
+ coords = {
162
+ x: commonX,
163
+ y: reference.y + reference.height
164
+ };
165
+ break;
166
+ case 'right':
167
+ coords = {
168
+ x: reference.x + reference.width,
169
+ y: commonY
170
+ };
171
+ break;
172
+ case 'left':
173
+ coords = {
174
+ x: reference.x - floating.width,
175
+ y: commonY
176
+ };
177
+ break;
178
+ default:
179
+ coords = {
180
+ x: reference.x,
181
+ y: reference.y
182
+ };
183
+ }
184
+ switch (getAlignment(placement)) {
185
+ case 'start':
186
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
187
+ break;
188
+ case 'end':
189
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
190
+ break;
191
+ }
192
+ return coords;
193
+ }
194
+
195
+ /**
196
+ * Computes the `x` and `y` coordinates that will place the floating element
197
+ * next to a given reference element.
198
+ *
199
+ * This export does not have any `platform` interface logic. You will need to
200
+ * write one for the platform you are using Floating UI with.
201
+ */
202
+ const computePosition$1 = async (reference, floating, config) => {
203
+ const {
204
+ placement = 'bottom',
205
+ strategy = 'absolute',
206
+ middleware = [],
207
+ platform
208
+ } = config;
209
+ const validMiddleware = middleware.filter(Boolean);
210
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
211
+ let rects = await platform.getElementRects({
212
+ reference,
213
+ floating,
214
+ strategy
215
+ });
216
+ let {
217
+ x,
218
+ y
219
+ } = computeCoordsFromPlacement(rects, placement, rtl);
220
+ let statefulPlacement = placement;
221
+ let middlewareData = {};
222
+ let resetCount = 0;
223
+ for (let i = 0; i < validMiddleware.length; i++) {
224
+ const {
225
+ name,
226
+ fn
227
+ } = validMiddleware[i];
228
+ const {
229
+ x: nextX,
230
+ y: nextY,
231
+ data,
232
+ reset
233
+ } = await fn({
234
+ x,
235
+ y,
236
+ initialPlacement: placement,
237
+ placement: statefulPlacement,
238
+ strategy,
239
+ middlewareData,
240
+ rects,
241
+ platform,
242
+ elements: {
243
+ reference,
244
+ floating
245
+ }
246
+ });
247
+ x = nextX != null ? nextX : x;
248
+ y = nextY != null ? nextY : y;
249
+ middlewareData = {
250
+ ...middlewareData,
251
+ [name]: {
252
+ ...middlewareData[name],
253
+ ...data
254
+ }
255
+ };
256
+ if (reset && resetCount <= 50) {
257
+ resetCount++;
258
+ if (typeof reset === 'object') {
259
+ if (reset.placement) {
260
+ statefulPlacement = reset.placement;
261
+ }
262
+ if (reset.rects) {
263
+ rects = reset.rects === true ? await platform.getElementRects({
264
+ reference,
265
+ floating,
266
+ strategy
267
+ }) : reset.rects;
268
+ }
269
+ ({
270
+ x,
271
+ y
272
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
273
+ }
274
+ i = -1;
275
+ }
276
+ }
277
+ return {
278
+ x,
279
+ y,
280
+ placement: statefulPlacement,
281
+ strategy,
282
+ middlewareData
283
+ };
284
+ };
285
+
286
+ /**
287
+ * Resolves with an object of overflow side offsets that determine how much the
288
+ * element is overflowing a given clipping boundary on each side.
289
+ * - positive = overflowing the boundary by that number of pixels
290
+ * - negative = how many pixels left before it will overflow
291
+ * - 0 = lies flush with the boundary
292
+ * @see https://floating-ui.com/docs/detectOverflow
293
+ */
294
+ async function detectOverflow(state, options) {
295
+ var _await$platform$isEle;
296
+ if (options === void 0) {
297
+ options = {};
298
+ }
299
+ const {
300
+ x,
301
+ y,
302
+ platform,
303
+ rects,
304
+ elements,
305
+ strategy
306
+ } = state;
307
+ const {
308
+ boundary = 'clippingAncestors',
309
+ rootBoundary = 'viewport',
310
+ elementContext = 'floating',
311
+ altBoundary = false,
312
+ padding = 0
313
+ } = evaluate(options, state);
314
+ const paddingObject = getPaddingObject(padding);
315
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
316
+ const element = elements[altBoundary ? altContext : elementContext];
317
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
318
+ 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))),
319
+ boundary,
320
+ rootBoundary,
321
+ strategy
322
+ }));
323
+ const rect = elementContext === 'floating' ? {
324
+ x,
325
+ y,
326
+ width: rects.floating.width,
327
+ height: rects.floating.height
328
+ } : rects.reference;
329
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
330
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
331
+ x: 1,
332
+ y: 1
333
+ } : {
334
+ x: 1,
335
+ y: 1
336
+ };
337
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
338
+ elements,
339
+ rect,
340
+ offsetParent,
341
+ strategy
342
+ }) : rect);
343
+ return {
344
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
345
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
346
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
347
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
348
+ };
349
+ }
350
+
351
+ /**
352
+ * Provides data to position an inner element of the floating element so that it
353
+ * appears centered to the reference element.
354
+ * @see https://floating-ui.com/docs/arrow
355
+ */
356
+ const arrow = options => ({
357
+ name: 'arrow',
358
+ options,
359
+ async fn(state) {
360
+ const {
361
+ x,
362
+ y,
363
+ placement,
364
+ rects,
365
+ platform,
366
+ elements,
367
+ middlewareData
368
+ } = state;
369
+ // Since `element` is required, we don't Partial<> the type.
370
+ const {
371
+ element,
372
+ padding = 0
373
+ } = evaluate(options, state) || {};
374
+ if (element == null) {
375
+ return {};
376
+ }
377
+ const paddingObject = getPaddingObject(padding);
378
+ const coords = {
379
+ x,
380
+ y
381
+ };
382
+ const axis = getAlignmentAxis(placement);
383
+ const length = getAxisLength(axis);
384
+ const arrowDimensions = await platform.getDimensions(element);
385
+ const isYAxis = axis === 'y';
386
+ const minProp = isYAxis ? 'top' : 'left';
387
+ const maxProp = isYAxis ? 'bottom' : 'right';
388
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
389
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
390
+ const startDiff = coords[axis] - rects.reference[axis];
391
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
392
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
393
+
394
+ // DOM platform can return `window` as the `offsetParent`.
395
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
396
+ clientSize = elements.floating[clientProp] || rects.floating[length];
397
+ }
398
+ const centerToReference = endDiff / 2 - startDiff / 2;
399
+
400
+ // If the padding is large enough that it causes the arrow to no longer be
401
+ // centered, modify the padding so that it is centered.
402
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
403
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
404
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
405
+
406
+ // Make sure the arrow doesn't overflow the floating element if the center
407
+ // point is outside the floating element's bounds.
408
+ const min$1 = minPadding;
409
+ const max = clientSize - arrowDimensions[length] - maxPadding;
410
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
411
+ const offset = clamp(min$1, center, max);
412
+
413
+ // If the reference is small enough that the arrow's padding causes it to
414
+ // to point to nothing for an aligned placement, adjust the offset of the
415
+ // floating element itself. To ensure `shift()` continues to take action,
416
+ // a single reset is performed when this is true.
417
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
418
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
419
+ return {
420
+ [axis]: coords[axis] + alignmentOffset,
421
+ data: {
422
+ [axis]: offset,
423
+ centerOffset: center - offset - alignmentOffset,
424
+ ...(shouldAddOffset && {
425
+ alignmentOffset
426
+ })
427
+ },
428
+ reset: shouldAddOffset
429
+ };
430
+ }
431
+ });
432
+
433
+ function getPlacementList(alignment, autoAlignment, allowedPlacements) {
434
+ const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
435
+ return allowedPlacementsSortedByAlignment.filter(placement => {
436
+ if (alignment) {
437
+ return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
438
+ }
439
+ return true;
440
+ });
441
+ }
442
+ /**
443
+ * Optimizes the visibility of the floating element by choosing the placement
444
+ * that has the most space available automatically, without needing to specify a
445
+ * preferred placement. Alternative to `flip`.
446
+ * @see https://floating-ui.com/docs/autoPlacement
447
+ */
448
+ const autoPlacement = function (options) {
449
+ if (options === void 0) {
450
+ options = {};
451
+ }
452
+ return {
453
+ name: 'autoPlacement',
454
+ options,
455
+ async fn(state) {
456
+ var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
457
+ const {
458
+ rects,
459
+ middlewareData,
460
+ placement,
461
+ platform,
462
+ elements
463
+ } = state;
464
+ const {
465
+ crossAxis = false,
466
+ alignment,
467
+ allowedPlacements = placements,
468
+ autoAlignment = true,
469
+ ...detectOverflowOptions
470
+ } = evaluate(options, state);
471
+ const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
472
+ const overflow = await detectOverflow(state, detectOverflowOptions);
473
+ const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
474
+ const currentPlacement = placements$1[currentIndex];
475
+ if (currentPlacement == null) {
476
+ return {};
477
+ }
478
+ const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
479
+
480
+ // Make `computeCoords` start from the right place.
481
+ if (placement !== currentPlacement) {
482
+ return {
483
+ reset: {
484
+ placement: placements$1[0]
485
+ }
486
+ };
487
+ }
488
+ const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
489
+ const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
490
+ placement: currentPlacement,
491
+ overflows: currentOverflows
492
+ }];
493
+ const nextPlacement = placements$1[currentIndex + 1];
494
+
495
+ // There are more placements to check.
496
+ if (nextPlacement) {
497
+ return {
498
+ data: {
499
+ index: currentIndex + 1,
500
+ overflows: allOverflows
501
+ },
502
+ reset: {
503
+ placement: nextPlacement
504
+ }
505
+ };
506
+ }
507
+ const placementsSortedByMostSpace = allOverflows.map(d => {
508
+ const alignment = getAlignment(d.placement);
509
+ return [d.placement, alignment && crossAxis ?
510
+ // Check along the mainAxis and main crossAxis side.
511
+ d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
512
+ // Check only the mainAxis.
513
+ d.overflows[0], d.overflows];
514
+ }).sort((a, b) => a[1] - b[1]);
515
+ const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
516
+ // Aligned placements should not check their opposite crossAxis
517
+ // side.
518
+ getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
519
+ const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
520
+ if (resetPlacement !== placement) {
521
+ return {
522
+ data: {
523
+ index: currentIndex + 1,
524
+ overflows: allOverflows
525
+ },
526
+ reset: {
527
+ placement: resetPlacement
528
+ }
529
+ };
530
+ }
531
+ return {};
532
+ }
533
+ };
534
+ };
535
+
536
+ /**
537
+ * Optimizes the visibility of the floating element by flipping the `placement`
538
+ * in order to keep it in view when the preferred placement(s) will overflow the
539
+ * clipping boundary. Alternative to `autoPlacement`.
540
+ * @see https://floating-ui.com/docs/flip
541
+ */
542
+ const flip$1 = function (options) {
543
+ if (options === void 0) {
544
+ options = {};
545
+ }
546
+ return {
547
+ name: 'flip',
548
+ options,
549
+ async fn(state) {
550
+ var _middlewareData$arrow, _middlewareData$flip;
551
+ const {
552
+ placement,
553
+ middlewareData,
554
+ rects,
555
+ initialPlacement,
556
+ platform,
557
+ elements
558
+ } = state;
559
+ const {
560
+ mainAxis: checkMainAxis = true,
561
+ crossAxis: checkCrossAxis = true,
562
+ fallbackPlacements: specifiedFallbackPlacements,
563
+ fallbackStrategy = 'bestFit',
564
+ fallbackAxisSideDirection = 'none',
565
+ flipAlignment = true,
566
+ ...detectOverflowOptions
567
+ } = evaluate(options, state);
568
+
569
+ // If a reset by the arrow was caused due to an alignment offset being
570
+ // added, we should skip any logic now since `flip()` has already done its
571
+ // work.
572
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
573
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
574
+ return {};
575
+ }
576
+ const side = getSide(placement);
577
+ const initialSideAxis = getSideAxis(initialPlacement);
578
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
579
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
580
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
581
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
582
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
583
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
584
+ }
585
+ const placements = [initialPlacement, ...fallbackPlacements];
586
+ const overflow = await detectOverflow(state, detectOverflowOptions);
587
+ const overflows = [];
588
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
589
+ if (checkMainAxis) {
590
+ overflows.push(overflow[side]);
591
+ }
592
+ if (checkCrossAxis) {
593
+ const sides = getAlignmentSides(placement, rects, rtl);
594
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
595
+ }
596
+ overflowsData = [...overflowsData, {
597
+ placement,
598
+ overflows
599
+ }];
600
+
601
+ // One or more sides is overflowing.
602
+ if (!overflows.every(side => side <= 0)) {
603
+ var _middlewareData$flip2, _overflowsData$filter;
604
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
605
+ const nextPlacement = placements[nextIndex];
606
+ if (nextPlacement) {
607
+ // Try next placement and re-run the lifecycle.
608
+ return {
609
+ data: {
610
+ index: nextIndex,
611
+ overflows: overflowsData
612
+ },
613
+ reset: {
614
+ placement: nextPlacement
615
+ }
616
+ };
617
+ }
618
+
619
+ // First, find the candidates that fit on the mainAxis side of overflow,
620
+ // then find the placement that fits the best on the main crossAxis side.
621
+ 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;
622
+
623
+ // Otherwise fallback.
624
+ if (!resetPlacement) {
625
+ switch (fallbackStrategy) {
626
+ case 'bestFit':
627
+ {
628
+ var _overflowsData$filter2;
629
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
630
+ if (hasFallbackAxisSideDirection) {
631
+ const currentSideAxis = getSideAxis(d.placement);
632
+ return currentSideAxis === initialSideAxis ||
633
+ // Create a bias to the `y` side axis due to horizontal
634
+ // reading directions favoring greater width.
635
+ currentSideAxis === 'y';
636
+ }
637
+ return true;
638
+ }).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];
639
+ if (placement) {
640
+ resetPlacement = placement;
641
+ }
642
+ break;
643
+ }
644
+ case 'initialPlacement':
645
+ resetPlacement = initialPlacement;
646
+ break;
647
+ }
648
+ }
649
+ if (placement !== resetPlacement) {
650
+ return {
651
+ reset: {
652
+ placement: resetPlacement
653
+ }
654
+ };
655
+ }
656
+ }
657
+ return {};
658
+ }
659
+ };
660
+ };
661
+
662
+ function getSideOffsets(overflow, rect) {
663
+ return {
664
+ top: overflow.top - rect.height,
665
+ right: overflow.right - rect.width,
666
+ bottom: overflow.bottom - rect.height,
667
+ left: overflow.left - rect.width
668
+ };
669
+ }
670
+ function isAnySideFullyClipped(overflow) {
671
+ return sides.some(side => overflow[side] >= 0);
672
+ }
673
+ /**
674
+ * Provides data to hide the floating element in applicable situations, such as
675
+ * when it is not in the same clipping context as the reference element.
676
+ * @see https://floating-ui.com/docs/hide
677
+ */
678
+ const hide = function (options) {
679
+ if (options === void 0) {
680
+ options = {};
681
+ }
682
+ return {
683
+ name: 'hide',
684
+ options,
685
+ async fn(state) {
686
+ const {
687
+ rects
688
+ } = state;
689
+ const {
690
+ strategy = 'referenceHidden',
691
+ ...detectOverflowOptions
692
+ } = evaluate(options, state);
693
+ switch (strategy) {
694
+ case 'referenceHidden':
695
+ {
696
+ const overflow = await detectOverflow(state, {
697
+ ...detectOverflowOptions,
698
+ elementContext: 'reference'
699
+ });
700
+ const offsets = getSideOffsets(overflow, rects.reference);
701
+ return {
702
+ data: {
703
+ referenceHiddenOffsets: offsets,
704
+ referenceHidden: isAnySideFullyClipped(offsets)
705
+ }
706
+ };
707
+ }
708
+ case 'escaped':
709
+ {
710
+ const overflow = await detectOverflow(state, {
711
+ ...detectOverflowOptions,
712
+ altBoundary: true
713
+ });
714
+ const offsets = getSideOffsets(overflow, rects.floating);
715
+ return {
716
+ data: {
717
+ escapedOffsets: offsets,
718
+ escaped: isAnySideFullyClipped(offsets)
719
+ }
720
+ };
721
+ }
722
+ default:
723
+ {
724
+ return {};
725
+ }
726
+ }
727
+ }
728
+ };
729
+ };
730
+
731
+ function getBoundingRect(rects) {
732
+ const minX = min(...rects.map(rect => rect.left));
733
+ const minY = min(...rects.map(rect => rect.top));
734
+ const maxX = max(...rects.map(rect => rect.right));
735
+ const maxY = max(...rects.map(rect => rect.bottom));
736
+ return {
737
+ x: minX,
738
+ y: minY,
739
+ width: maxX - minX,
740
+ height: maxY - minY
741
+ };
742
+ }
743
+ function getRectsByLine(rects) {
744
+ const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
745
+ const groups = [];
746
+ let prevRect = null;
747
+ for (let i = 0; i < sortedRects.length; i++) {
748
+ const rect = sortedRects[i];
749
+ if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
750
+ groups.push([rect]);
751
+ } else {
752
+ groups[groups.length - 1].push(rect);
753
+ }
754
+ prevRect = rect;
755
+ }
756
+ return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
757
+ }
758
+ /**
759
+ * Provides improved positioning for inline reference elements that can span
760
+ * over multiple lines, such as hyperlinks or range selections.
761
+ * @see https://floating-ui.com/docs/inline
762
+ */
763
+ const inline = function (options) {
764
+ if (options === void 0) {
765
+ options = {};
766
+ }
767
+ return {
768
+ name: 'inline',
769
+ options,
770
+ async fn(state) {
771
+ const {
772
+ placement,
773
+ elements,
774
+ rects,
775
+ platform,
776
+ strategy
777
+ } = state;
778
+ // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
779
+ // ClientRect's bounds, despite the event listener being triggered. A
780
+ // padding of 2 seems to handle this issue.
781
+ const {
782
+ padding = 2,
783
+ x,
784
+ y
785
+ } = evaluate(options, state);
786
+ const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
787
+ const clientRects = getRectsByLine(nativeClientRects);
788
+ const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
789
+ const paddingObject = getPaddingObject(padding);
790
+ function getBoundingClientRect() {
791
+ // There are two rects and they are disjoined.
792
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
793
+ // Find the first rect in which the point is fully inside.
794
+ 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;
795
+ }
796
+
797
+ // There are 2 or more connected rects.
798
+ if (clientRects.length >= 2) {
799
+ if (getSideAxis(placement) === 'y') {
800
+ const firstRect = clientRects[0];
801
+ const lastRect = clientRects[clientRects.length - 1];
802
+ const isTop = getSide(placement) === 'top';
803
+ const top = firstRect.top;
804
+ const bottom = lastRect.bottom;
805
+ const left = isTop ? firstRect.left : lastRect.left;
806
+ const right = isTop ? firstRect.right : lastRect.right;
807
+ const width = right - left;
808
+ const height = bottom - top;
809
+ return {
810
+ top,
811
+ bottom,
812
+ left,
813
+ right,
814
+ width,
815
+ height,
816
+ x: left,
817
+ y: top
818
+ };
819
+ }
820
+ const isLeftSide = getSide(placement) === 'left';
821
+ const maxRight = max(...clientRects.map(rect => rect.right));
822
+ const minLeft = min(...clientRects.map(rect => rect.left));
823
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
824
+ const top = measureRects[0].top;
825
+ const bottom = measureRects[measureRects.length - 1].bottom;
826
+ const left = minLeft;
827
+ const right = maxRight;
828
+ const width = right - left;
829
+ const height = bottom - top;
830
+ return {
831
+ top,
832
+ bottom,
833
+ left,
834
+ right,
835
+ width,
836
+ height,
837
+ x: left,
838
+ y: top
839
+ };
840
+ }
841
+ return fallback;
842
+ }
843
+ const resetRects = await platform.getElementRects({
844
+ reference: {
845
+ getBoundingClientRect
846
+ },
847
+ floating: elements.floating,
848
+ strategy
849
+ });
850
+ 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) {
851
+ return {
852
+ reset: {
853
+ rects: resetRects
854
+ }
855
+ };
856
+ }
857
+ return {};
858
+ }
859
+ };
860
+ };
861
+
862
+ // For type backwards-compatibility, the `OffsetOptions` type was also
863
+ // Derivable.
864
+
865
+ async function convertValueToCoords(state, options) {
866
+ const {
867
+ placement,
868
+ platform,
869
+ elements
870
+ } = state;
871
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
872
+ const side = getSide(placement);
873
+ const alignment = getAlignment(placement);
874
+ const isVertical = getSideAxis(placement) === 'y';
875
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
876
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
877
+ const rawValue = evaluate(options, state);
878
+
879
+ // eslint-disable-next-line prefer-const
880
+ let {
881
+ mainAxis,
882
+ crossAxis,
883
+ alignmentAxis
884
+ } = typeof rawValue === 'number' ? {
885
+ mainAxis: rawValue,
886
+ crossAxis: 0,
887
+ alignmentAxis: null
888
+ } : {
889
+ mainAxis: rawValue.mainAxis || 0,
890
+ crossAxis: rawValue.crossAxis || 0,
891
+ alignmentAxis: rawValue.alignmentAxis
892
+ };
893
+ if (alignment && typeof alignmentAxis === 'number') {
894
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
895
+ }
896
+ return isVertical ? {
897
+ x: crossAxis * crossAxisMulti,
898
+ y: mainAxis * mainAxisMulti
899
+ } : {
900
+ x: mainAxis * mainAxisMulti,
901
+ y: crossAxis * crossAxisMulti
902
+ };
903
+ }
904
+
905
+ /**
906
+ * Modifies the placement by translating the floating element along the
907
+ * specified axes.
908
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
909
+ * object may be passed.
910
+ * @see https://floating-ui.com/docs/offset
911
+ */
912
+ const offset$1 = function (options) {
913
+ if (options === void 0) {
914
+ options = 0;
915
+ }
916
+ return {
917
+ name: 'offset',
918
+ options,
919
+ async fn(state) {
920
+ var _middlewareData$offse, _middlewareData$arrow;
921
+ const {
922
+ x,
923
+ y,
924
+ placement,
925
+ middlewareData
926
+ } = state;
927
+ const diffCoords = await convertValueToCoords(state, options);
928
+
929
+ // If the placement is the same and the arrow caused an alignment offset
930
+ // then we don't need to change the positioning coordinates.
931
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
932
+ return {};
933
+ }
934
+ return {
935
+ x: x + diffCoords.x,
936
+ y: y + diffCoords.y,
937
+ data: {
938
+ ...diffCoords,
939
+ placement
940
+ }
941
+ };
942
+ }
943
+ };
944
+ };
945
+
946
+ /**
947
+ * Optimizes the visibility of the floating element by shifting it in order to
948
+ * keep it in view when it will overflow the clipping boundary.
949
+ * @see https://floating-ui.com/docs/shift
950
+ */
951
+ const shift$1 = function (options) {
952
+ if (options === void 0) {
953
+ options = {};
954
+ }
955
+ return {
956
+ name: 'shift',
957
+ options,
958
+ async fn(state) {
959
+ const {
960
+ x,
961
+ y,
962
+ placement
963
+ } = state;
964
+ const {
965
+ mainAxis: checkMainAxis = true,
966
+ crossAxis: checkCrossAxis = false,
967
+ limiter = {
968
+ fn: _ref => {
969
+ let {
970
+ x,
971
+ y
972
+ } = _ref;
973
+ return {
974
+ x,
975
+ y
976
+ };
977
+ }
978
+ },
979
+ ...detectOverflowOptions
980
+ } = evaluate(options, state);
981
+ const coords = {
982
+ x,
983
+ y
984
+ };
985
+ const overflow = await detectOverflow(state, detectOverflowOptions);
986
+ const crossAxis = getSideAxis(getSide(placement));
987
+ const mainAxis = getOppositeAxis(crossAxis);
988
+ let mainAxisCoord = coords[mainAxis];
989
+ let crossAxisCoord = coords[crossAxis];
990
+ if (checkMainAxis) {
991
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
992
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
993
+ const min = mainAxisCoord + overflow[minSide];
994
+ const max = mainAxisCoord - overflow[maxSide];
995
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
996
+ }
997
+ if (checkCrossAxis) {
998
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
999
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
1000
+ const min = crossAxisCoord + overflow[minSide];
1001
+ const max = crossAxisCoord - overflow[maxSide];
1002
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
1003
+ }
1004
+ const limitedCoords = limiter.fn({
1005
+ ...state,
1006
+ [mainAxis]: mainAxisCoord,
1007
+ [crossAxis]: crossAxisCoord
1008
+ });
1009
+ return {
1010
+ ...limitedCoords,
1011
+ data: {
1012
+ x: limitedCoords.x - x,
1013
+ y: limitedCoords.y - y,
1014
+ enabled: {
1015
+ [mainAxis]: checkMainAxis,
1016
+ [crossAxis]: checkCrossAxis
1017
+ }
1018
+ }
1019
+ };
1020
+ }
1021
+ };
1022
+ };
1023
+ /**
1024
+ * Built-in `limiter` that will stop `shift()` at a certain point.
1025
+ */
1026
+ const limitShift = function (options) {
1027
+ if (options === void 0) {
1028
+ options = {};
1029
+ }
1030
+ return {
1031
+ options,
1032
+ fn(state) {
1033
+ const {
1034
+ x,
1035
+ y,
1036
+ placement,
1037
+ rects,
1038
+ middlewareData
1039
+ } = state;
1040
+ const {
1041
+ offset = 0,
1042
+ mainAxis: checkMainAxis = true,
1043
+ crossAxis: checkCrossAxis = true
1044
+ } = evaluate(options, state);
1045
+ const coords = {
1046
+ x,
1047
+ y
1048
+ };
1049
+ const crossAxis = getSideAxis(placement);
1050
+ const mainAxis = getOppositeAxis(crossAxis);
1051
+ let mainAxisCoord = coords[mainAxis];
1052
+ let crossAxisCoord = coords[crossAxis];
1053
+ const rawOffset = evaluate(offset, state);
1054
+ const computedOffset = typeof rawOffset === 'number' ? {
1055
+ mainAxis: rawOffset,
1056
+ crossAxis: 0
1057
+ } : {
1058
+ mainAxis: 0,
1059
+ crossAxis: 0,
1060
+ ...rawOffset
1061
+ };
1062
+ if (checkMainAxis) {
1063
+ const len = mainAxis === 'y' ? 'height' : 'width';
1064
+ const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
1065
+ const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
1066
+ if (mainAxisCoord < limitMin) {
1067
+ mainAxisCoord = limitMin;
1068
+ } else if (mainAxisCoord > limitMax) {
1069
+ mainAxisCoord = limitMax;
1070
+ }
1071
+ }
1072
+ if (checkCrossAxis) {
1073
+ var _middlewareData$offse, _middlewareData$offse2;
1074
+ const len = mainAxis === 'y' ? 'width' : 'height';
1075
+ const isOriginSide = ['top', 'left'].includes(getSide(placement));
1076
+ 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);
1077
+ 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);
1078
+ if (crossAxisCoord < limitMin) {
1079
+ crossAxisCoord = limitMin;
1080
+ } else if (crossAxisCoord > limitMax) {
1081
+ crossAxisCoord = limitMax;
1082
+ }
1083
+ }
1084
+ return {
1085
+ [mainAxis]: mainAxisCoord,
1086
+ [crossAxis]: crossAxisCoord
1087
+ };
1088
+ }
1089
+ };
1090
+ };
1091
+
1092
+ /**
1093
+ * Provides data that allows you to change the size of the floating element —
1094
+ * for instance, prevent it from overflowing the clipping boundary or match the
1095
+ * width of the reference element.
1096
+ * @see https://floating-ui.com/docs/size
1097
+ */
1098
+ const size = function (options) {
1099
+ if (options === void 0) {
1100
+ options = {};
1101
+ }
1102
+ return {
1103
+ name: 'size',
1104
+ options,
1105
+ async fn(state) {
1106
+ var _state$middlewareData, _state$middlewareData2;
1107
+ const {
1108
+ placement,
1109
+ rects,
1110
+ platform,
1111
+ elements
1112
+ } = state;
1113
+ const {
1114
+ apply = () => {},
1115
+ ...detectOverflowOptions
1116
+ } = evaluate(options, state);
1117
+ const overflow = await detectOverflow(state, detectOverflowOptions);
1118
+ const side = getSide(placement);
1119
+ const alignment = getAlignment(placement);
1120
+ const isYAxis = getSideAxis(placement) === 'y';
1121
+ const {
1122
+ width,
1123
+ height
1124
+ } = rects.floating;
1125
+ let heightSide;
1126
+ let widthSide;
1127
+ if (side === 'top' || side === 'bottom') {
1128
+ heightSide = side;
1129
+ widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
1130
+ } else {
1131
+ widthSide = side;
1132
+ heightSide = alignment === 'end' ? 'top' : 'bottom';
1133
+ }
1134
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
1135
+ const maximumClippingWidth = width - overflow.left - overflow.right;
1136
+ const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
1137
+ const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
1138
+ const noShift = !state.middlewareData.shift;
1139
+ let availableHeight = overflowAvailableHeight;
1140
+ let availableWidth = overflowAvailableWidth;
1141
+ if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
1142
+ availableWidth = maximumClippingWidth;
1143
+ }
1144
+ if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
1145
+ availableHeight = maximumClippingHeight;
1146
+ }
1147
+ if (noShift && !alignment) {
1148
+ const xMin = max(overflow.left, 0);
1149
+ const xMax = max(overflow.right, 0);
1150
+ const yMin = max(overflow.top, 0);
1151
+ const yMax = max(overflow.bottom, 0);
1152
+ if (isYAxis) {
1153
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1154
+ } else {
1155
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1156
+ }
1157
+ }
1158
+ await apply({
1159
+ ...state,
1160
+ availableWidth,
1161
+ availableHeight
1162
+ });
1163
+ const nextDimensions = await platform.getDimensions(elements.floating);
1164
+ if (width !== nextDimensions.width || height !== nextDimensions.height) {
1165
+ return {
1166
+ reset: {
1167
+ rects: true
1168
+ }
1169
+ };
1170
+ }
1171
+ return {};
1172
+ }
1173
+ };
1174
+ };
1175
+
1176
+ function hasWindow() {
1177
+ return typeof window !== 'undefined';
1178
+ }
1179
+ function getNodeName(node) {
1180
+ if (isNode(node)) {
1181
+ return (node.nodeName || '').toLowerCase();
1182
+ }
1183
+ // Mocked nodes in testing environments may not be instances of Node. By
1184
+ // returning `#document` an infinite loop won't occur.
1185
+ // https://github.com/floating-ui/floating-ui/issues/2317
1186
+ return '#document';
1187
+ }
1188
+ function getWindow(node) {
1189
+ var _node$ownerDocument;
1190
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1191
+ }
1192
+ function getDocumentElement(node) {
1193
+ var _ref;
1194
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
1195
+ }
1196
+ function isNode(value) {
1197
+ if (!hasWindow()) {
1198
+ return false;
1199
+ }
1200
+ return value instanceof Node || value instanceof getWindow(value).Node;
1201
+ }
1202
+ function isElement(value) {
1203
+ if (!hasWindow()) {
1204
+ return false;
1205
+ }
1206
+ return value instanceof Element || value instanceof getWindow(value).Element;
1207
+ }
1208
+ function isHTMLElement(value) {
1209
+ if (!hasWindow()) {
1210
+ return false;
1211
+ }
1212
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
1213
+ }
1214
+ function isShadowRoot(value) {
1215
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
1216
+ return false;
1217
+ }
1218
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
1219
+ }
1220
+ function isOverflowElement(element) {
1221
+ const {
1222
+ overflow,
1223
+ overflowX,
1224
+ overflowY,
1225
+ display
1226
+ } = getComputedStyle(element);
1227
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1228
+ }
1229
+ function isTableElement(element) {
1230
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1231
+ }
1232
+ function isTopLayer(element) {
1233
+ return [':popover-open', ':modal'].some(selector => {
1234
+ try {
1235
+ return element.matches(selector);
1236
+ } catch (e) {
1237
+ return false;
1238
+ }
1239
+ });
1240
+ }
1241
+ function isContainingBlock(elementOrCss) {
1242
+ const webkit = isWebKit();
1243
+ const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;
1244
+
1245
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1246
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
1247
+ return ['transform', 'translate', 'scale', 'rotate', 'perspective'].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) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
1248
+ }
1249
+ function getContainingBlock(element) {
1250
+ let currentNode = getParentNode(element);
1251
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
1252
+ if (isContainingBlock(currentNode)) {
1253
+ return currentNode;
1254
+ } else if (isTopLayer(currentNode)) {
1255
+ return null;
1256
+ }
1257
+ currentNode = getParentNode(currentNode);
1258
+ }
1259
+ return null;
1260
+ }
1261
+ function isWebKit() {
1262
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
1263
+ return CSS.supports('-webkit-backdrop-filter', 'none');
1264
+ }
1265
+ function isLastTraversableNode(node) {
1266
+ return ['html', 'body', '#document'].includes(getNodeName(node));
1267
+ }
1268
+ function getComputedStyle(element) {
1269
+ return getWindow(element).getComputedStyle(element);
1270
+ }
1271
+ function getNodeScroll(element) {
1272
+ if (isElement(element)) {
1273
+ return {
1274
+ scrollLeft: element.scrollLeft,
1275
+ scrollTop: element.scrollTop
1276
+ };
1277
+ }
1278
+ return {
1279
+ scrollLeft: element.scrollX,
1280
+ scrollTop: element.scrollY
1281
+ };
1282
+ }
1283
+ function getParentNode(node) {
1284
+ if (getNodeName(node) === 'html') {
1285
+ return node;
1286
+ }
1287
+ const result =
1288
+ // Step into the shadow DOM of the parent of a slotted node.
1289
+ node.assignedSlot ||
1290
+ // DOM Element detected.
1291
+ node.parentNode ||
1292
+ // ShadowRoot detected.
1293
+ isShadowRoot(node) && node.host ||
1294
+ // Fallback.
1295
+ getDocumentElement(node);
1296
+ return isShadowRoot(result) ? result.host : result;
1297
+ }
1298
+ function getNearestOverflowAncestor(node) {
1299
+ const parentNode = getParentNode(node);
1300
+ if (isLastTraversableNode(parentNode)) {
1301
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
1302
+ }
1303
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1304
+ return parentNode;
1305
+ }
1306
+ return getNearestOverflowAncestor(parentNode);
1307
+ }
1308
+ function getOverflowAncestors(node, list, traverseIframes) {
1309
+ var _node$ownerDocument2;
1310
+ if (list === void 0) {
1311
+ list = [];
1312
+ }
1313
+ if (traverseIframes === void 0) {
1314
+ traverseIframes = true;
1315
+ }
1316
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1317
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
1318
+ const win = getWindow(scrollableAncestor);
1319
+ if (isBody) {
1320
+ const frameElement = getFrameElement(win);
1321
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
1322
+ }
1323
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
1324
+ }
1325
+ function getFrameElement(win) {
1326
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
1327
+ }
1328
+
1329
+ function getCssDimensions(element) {
1330
+ const css = getComputedStyle(element);
1331
+ // In testing environments, the `width` and `height` properties are empty
1332
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
1333
+ let width = parseFloat(css.width) || 0;
1334
+ let height = parseFloat(css.height) || 0;
1335
+ const hasOffset = isHTMLElement(element);
1336
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
1337
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
1338
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
1339
+ if (shouldFallback) {
1340
+ width = offsetWidth;
1341
+ height = offsetHeight;
1342
+ }
1343
+ return {
1344
+ width,
1345
+ height,
1346
+ $: shouldFallback
1347
+ };
1348
+ }
1349
+
1350
+ function unwrapElement(element) {
1351
+ return !isElement(element) ? element.contextElement : element;
1352
+ }
1353
+
1354
+ function getScale(element) {
1355
+ const domElement = unwrapElement(element);
1356
+ if (!isHTMLElement(domElement)) {
1357
+ return createCoords(1);
1358
+ }
1359
+ const rect = domElement.getBoundingClientRect();
1360
+ const {
1361
+ width,
1362
+ height,
1363
+ $
1364
+ } = getCssDimensions(domElement);
1365
+ let x = ($ ? round(rect.width) : rect.width) / width;
1366
+ let y = ($ ? round(rect.height) : rect.height) / height;
1367
+
1368
+ // 0, NaN, or Infinity should always fallback to 1.
1369
+
1370
+ if (!x || !Number.isFinite(x)) {
1371
+ x = 1;
1372
+ }
1373
+ if (!y || !Number.isFinite(y)) {
1374
+ y = 1;
1375
+ }
1376
+ return {
1377
+ x,
1378
+ y
1379
+ };
1380
+ }
1381
+
1382
+ const noOffsets = /*#__PURE__*/createCoords(0);
1383
+ function getVisualOffsets(element) {
1384
+ const win = getWindow(element);
1385
+ if (!isWebKit() || !win.visualViewport) {
1386
+ return noOffsets;
1387
+ }
1388
+ return {
1389
+ x: win.visualViewport.offsetLeft,
1390
+ y: win.visualViewport.offsetTop
1391
+ };
1392
+ }
1393
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
1394
+ if (isFixed === void 0) {
1395
+ isFixed = false;
1396
+ }
1397
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
1398
+ return false;
1399
+ }
1400
+ return isFixed;
1401
+ }
1402
+
1403
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
1404
+ if (includeScale === void 0) {
1405
+ includeScale = false;
1406
+ }
1407
+ if (isFixedStrategy === void 0) {
1408
+ isFixedStrategy = false;
1409
+ }
1410
+ const clientRect = element.getBoundingClientRect();
1411
+ const domElement = unwrapElement(element);
1412
+ let scale = createCoords(1);
1413
+ if (includeScale) {
1414
+ if (offsetParent) {
1415
+ if (isElement(offsetParent)) {
1416
+ scale = getScale(offsetParent);
1417
+ }
1418
+ } else {
1419
+ scale = getScale(element);
1420
+ }
1421
+ }
1422
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
1423
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
1424
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
1425
+ let width = clientRect.width / scale.x;
1426
+ let height = clientRect.height / scale.y;
1427
+ if (domElement) {
1428
+ const win = getWindow(domElement);
1429
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
1430
+ let currentWin = win;
1431
+ let currentIFrame = getFrameElement(currentWin);
1432
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
1433
+ const iframeScale = getScale(currentIFrame);
1434
+ const iframeRect = currentIFrame.getBoundingClientRect();
1435
+ const css = getComputedStyle(currentIFrame);
1436
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
1437
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
1438
+ x *= iframeScale.x;
1439
+ y *= iframeScale.y;
1440
+ width *= iframeScale.x;
1441
+ height *= iframeScale.y;
1442
+ x += left;
1443
+ y += top;
1444
+ currentWin = getWindow(currentIFrame);
1445
+ currentIFrame = getFrameElement(currentWin);
1446
+ }
1447
+ }
1448
+ return rectToClientRect({
1449
+ width,
1450
+ height,
1451
+ x,
1452
+ y
1453
+ });
1454
+ }
1455
+
1456
+ // If <html> has a CSS width greater than the viewport, then this will be
1457
+ // incorrect for RTL.
1458
+ function getWindowScrollBarX(element, rect) {
1459
+ const leftScroll = getNodeScroll(element).scrollLeft;
1460
+ if (!rect) {
1461
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1462
+ }
1463
+ return rect.left + leftScroll;
1464
+ }
1465
+
1466
+ function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
1467
+ if (ignoreScrollbarX === void 0) {
1468
+ ignoreScrollbarX = false;
1469
+ }
1470
+ const htmlRect = documentElement.getBoundingClientRect();
1471
+ const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
1472
+ // RTL <body> scrollbar.
1473
+ getWindowScrollBarX(documentElement, htmlRect));
1474
+ const y = htmlRect.top + scroll.scrollTop;
1475
+ return {
1476
+ x,
1477
+ y
1478
+ };
1479
+ }
1480
+
1481
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1482
+ let {
1483
+ elements,
1484
+ rect,
1485
+ offsetParent,
1486
+ strategy
1487
+ } = _ref;
1488
+ const isFixed = strategy === 'fixed';
1489
+ const documentElement = getDocumentElement(offsetParent);
1490
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1491
+ if (offsetParent === documentElement || topLayer && isFixed) {
1492
+ return rect;
1493
+ }
1494
+ let scroll = {
1495
+ scrollLeft: 0,
1496
+ scrollTop: 0
1497
+ };
1498
+ let scale = createCoords(1);
1499
+ const offsets = createCoords(0);
1500
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1501
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1502
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1503
+ scroll = getNodeScroll(offsetParent);
1504
+ }
1505
+ if (isHTMLElement(offsetParent)) {
1506
+ const offsetRect = getBoundingClientRect(offsetParent);
1507
+ scale = getScale(offsetParent);
1508
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1509
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1510
+ }
1511
+ }
1512
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
1513
+ return {
1514
+ width: rect.width * scale.x,
1515
+ height: rect.height * scale.y,
1516
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1517
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1518
+ };
1519
+ }
1520
+
1521
+ function getClientRects(element) {
1522
+ return Array.from(element.getClientRects());
1523
+ }
1524
+
1525
+ // Gets the entire size of the scrollable document area, even extending outside
1526
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1527
+ function getDocumentRect(element) {
1528
+ const html = getDocumentElement(element);
1529
+ const scroll = getNodeScroll(element);
1530
+ const body = element.ownerDocument.body;
1531
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1532
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1533
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1534
+ const y = -scroll.scrollTop;
1535
+ if (getComputedStyle(body).direction === 'rtl') {
1536
+ x += max(html.clientWidth, body.clientWidth) - width;
1537
+ }
1538
+ return {
1539
+ width,
1540
+ height,
1541
+ x,
1542
+ y
1543
+ };
1544
+ }
1545
+
1546
+ function getViewportRect(element, strategy) {
1547
+ const win = getWindow(element);
1548
+ const html = getDocumentElement(element);
1549
+ const visualViewport = win.visualViewport;
1550
+ let width = html.clientWidth;
1551
+ let height = html.clientHeight;
1552
+ let x = 0;
1553
+ let y = 0;
1554
+ if (visualViewport) {
1555
+ width = visualViewport.width;
1556
+ height = visualViewport.height;
1557
+ const visualViewportBased = isWebKit();
1558
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1559
+ x = visualViewport.offsetLeft;
1560
+ y = visualViewport.offsetTop;
1561
+ }
1562
+ }
1563
+ return {
1564
+ width,
1565
+ height,
1566
+ x,
1567
+ y
1568
+ };
1569
+ }
1570
+
1571
+ // Returns the inner client rect, subtracting scrollbars if present.
1572
+ function getInnerBoundingClientRect(element, strategy) {
1573
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1574
+ const top = clientRect.top + element.clientTop;
1575
+ const left = clientRect.left + element.clientLeft;
1576
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1577
+ const width = element.clientWidth * scale.x;
1578
+ const height = element.clientHeight * scale.y;
1579
+ const x = left * scale.x;
1580
+ const y = top * scale.y;
1581
+ return {
1582
+ width,
1583
+ height,
1584
+ x,
1585
+ y
1586
+ };
1587
+ }
1588
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1589
+ let rect;
1590
+ if (clippingAncestor === 'viewport') {
1591
+ rect = getViewportRect(element, strategy);
1592
+ } else if (clippingAncestor === 'document') {
1593
+ rect = getDocumentRect(getDocumentElement(element));
1594
+ } else if (isElement(clippingAncestor)) {
1595
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1596
+ } else {
1597
+ const visualOffsets = getVisualOffsets(element);
1598
+ rect = {
1599
+ x: clippingAncestor.x - visualOffsets.x,
1600
+ y: clippingAncestor.y - visualOffsets.y,
1601
+ width: clippingAncestor.width,
1602
+ height: clippingAncestor.height
1603
+ };
1604
+ }
1605
+ return rectToClientRect(rect);
1606
+ }
1607
+ function hasFixedPositionAncestor(element, stopNode) {
1608
+ const parentNode = getParentNode(element);
1609
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1610
+ return false;
1611
+ }
1612
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1613
+ }
1614
+
1615
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1616
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1617
+ // of the given element up the tree.
1618
+ function getClippingElementAncestors(element, cache) {
1619
+ const cachedResult = cache.get(element);
1620
+ if (cachedResult) {
1621
+ return cachedResult;
1622
+ }
1623
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1624
+ let currentContainingBlockComputedStyle = null;
1625
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1626
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1627
+
1628
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1629
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1630
+ const computedStyle = getComputedStyle(currentNode);
1631
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1632
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1633
+ currentContainingBlockComputedStyle = null;
1634
+ }
1635
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1636
+ if (shouldDropCurrentNode) {
1637
+ // Drop non-containing blocks.
1638
+ result = result.filter(ancestor => ancestor !== currentNode);
1639
+ } else {
1640
+ // Record last containing block for next iteration.
1641
+ currentContainingBlockComputedStyle = computedStyle;
1642
+ }
1643
+ currentNode = getParentNode(currentNode);
1644
+ }
1645
+ cache.set(element, result);
1646
+ return result;
1647
+ }
1648
+
1649
+ // Gets the maximum area that the element is visible in due to any number of
1650
+ // clipping ancestors.
1651
+ function getClippingRect(_ref) {
1652
+ let {
1653
+ element,
1654
+ boundary,
1655
+ rootBoundary,
1656
+ strategy
1657
+ } = _ref;
1658
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1659
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1660
+ const firstClippingAncestor = clippingAncestors[0];
1661
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1662
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1663
+ accRect.top = max(rect.top, accRect.top);
1664
+ accRect.right = min(rect.right, accRect.right);
1665
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1666
+ accRect.left = max(rect.left, accRect.left);
1667
+ return accRect;
1668
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1669
+ return {
1670
+ width: clippingRect.right - clippingRect.left,
1671
+ height: clippingRect.bottom - clippingRect.top,
1672
+ x: clippingRect.left,
1673
+ y: clippingRect.top
1674
+ };
1675
+ }
1676
+
1677
+ function getDimensions(element) {
1678
+ const {
1679
+ width,
1680
+ height
1681
+ } = getCssDimensions(element);
1682
+ return {
1683
+ width,
1684
+ height
1685
+ };
1686
+ }
1687
+
1688
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1689
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1690
+ const documentElement = getDocumentElement(offsetParent);
1691
+ const isFixed = strategy === 'fixed';
1692
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1693
+ let scroll = {
1694
+ scrollLeft: 0,
1695
+ scrollTop: 0
1696
+ };
1697
+ const offsets = createCoords(0);
1698
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1699
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1700
+ scroll = getNodeScroll(offsetParent);
1701
+ }
1702
+ if (isOffsetParentAnElement) {
1703
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1704
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1705
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1706
+ } else if (documentElement) {
1707
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1708
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1709
+ offsets.x = getWindowScrollBarX(documentElement);
1710
+ }
1711
+ }
1712
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1713
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1714
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1715
+ return {
1716
+ x,
1717
+ y,
1718
+ width: rect.width,
1719
+ height: rect.height
1720
+ };
1721
+ }
1722
+
1723
+ function isStaticPositioned(element) {
1724
+ return getComputedStyle(element).position === 'static';
1725
+ }
1726
+
1727
+ function getTrueOffsetParent(element, polyfill) {
1728
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1729
+ return null;
1730
+ }
1731
+ if (polyfill) {
1732
+ return polyfill(element);
1733
+ }
1734
+ let rawOffsetParent = element.offsetParent;
1735
+
1736
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1737
+ // while Chrome and Safari return the <body> element. The <body> element must
1738
+ // be used to perform the correct calculations even if the <html> element is
1739
+ // non-static.
1740
+ if (getDocumentElement(element) === rawOffsetParent) {
1741
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1742
+ }
1743
+ return rawOffsetParent;
1744
+ }
1745
+
1746
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1747
+ // such as table ancestors and cross browser bugs.
1748
+ function getOffsetParent(element, polyfill) {
1749
+ const win = getWindow(element);
1750
+ if (isTopLayer(element)) {
1751
+ return win;
1752
+ }
1753
+ if (!isHTMLElement(element)) {
1754
+ let svgOffsetParent = getParentNode(element);
1755
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1756
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1757
+ return svgOffsetParent;
1758
+ }
1759
+ svgOffsetParent = getParentNode(svgOffsetParent);
1760
+ }
1761
+ return win;
1762
+ }
1763
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1764
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1765
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1766
+ }
1767
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1768
+ return win;
1769
+ }
1770
+ return offsetParent || getContainingBlock(element) || win;
1771
+ }
1772
+
1773
+ const getElementRects = async function (data) {
1774
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1775
+ const getDimensionsFn = this.getDimensions;
1776
+ const floatingDimensions = await getDimensionsFn(data.floating);
1777
+ return {
1778
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1779
+ floating: {
1780
+ x: 0,
1781
+ y: 0,
1782
+ width: floatingDimensions.width,
1783
+ height: floatingDimensions.height
1784
+ }
1785
+ };
1786
+ };
1787
+
1788
+ function isRTL(element) {
1789
+ return getComputedStyle(element).direction === 'rtl';
1790
+ }
1791
+
1792
+ const platform = {
1793
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1794
+ getDocumentElement,
1795
+ getClippingRect,
1796
+ getOffsetParent,
1797
+ getElementRects,
1798
+ getClientRects,
1799
+ getDimensions,
1800
+ getScale,
1801
+ isElement,
1802
+ isRTL
1803
+ };
1804
+
1805
+ /**
1806
+ * Modifies the placement by translating the floating element along the
1807
+ * specified axes.
1808
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1809
+ * object may be passed.
1810
+ * @see https://floating-ui.com/docs/offset
1811
+ */
1812
+ const offset = offset$1;
1813
+
1814
+ /**
1815
+ * Optimizes the visibility of the floating element by choosing the placement
1816
+ * that has the most space available automatically, without needing to specify a
1817
+ * preferred placement. Alternative to `flip`.
1818
+ * @see https://floating-ui.com/docs/autoPlacement
1819
+ */
1820
+ autoPlacement;
1821
+
1822
+ /**
1823
+ * Optimizes the visibility of the floating element by shifting it in order to
1824
+ * keep it in view when it will overflow the clipping boundary.
1825
+ * @see https://floating-ui.com/docs/shift
1826
+ */
1827
+ const shift = shift$1;
1828
+
1829
+ /**
1830
+ * Optimizes the visibility of the floating element by flipping the `placement`
1831
+ * in order to keep it in view when the preferred placement(s) will overflow the
1832
+ * clipping boundary. Alternative to `autoPlacement`.
1833
+ * @see https://floating-ui.com/docs/flip
1834
+ */
1835
+ const flip = flip$1;
1836
+
1837
+ /**
1838
+ * Provides data that allows you to change the size of the floating element —
1839
+ * for instance, prevent it from overflowing the clipping boundary or match the
1840
+ * width of the reference element.
1841
+ * @see https://floating-ui.com/docs/size
1842
+ */
1843
+ size;
1844
+
1845
+ /**
1846
+ * Provides data to hide the floating element in applicable situations, such as
1847
+ * when it is not in the same clipping context as the reference element.
1848
+ * @see https://floating-ui.com/docs/hide
1849
+ */
1850
+ hide;
1851
+
1852
+ /**
1853
+ * Provides data to position an inner element of the floating element so that it
1854
+ * appears centered to the reference element.
1855
+ * @see https://floating-ui.com/docs/arrow
1856
+ */
1857
+ arrow;
1858
+
1859
+ /**
1860
+ * Provides improved positioning for inline reference elements that can span
1861
+ * over multiple lines, such as hyperlinks or range selections.
1862
+ * @see https://floating-ui.com/docs/inline
1863
+ */
1864
+ inline;
1865
+
1866
+ /**
1867
+ * Built-in `limiter` that will stop `shift()` at a certain point.
1868
+ */
1869
+ limitShift;
1870
+
1871
+ /**
1872
+ * Computes the `x` and `y` coordinates that will place the floating element
1873
+ * next to a given reference element.
1874
+ */
1875
+ const computePosition = (reference, floating, options) => {
1876
+ // This caches the expensive `getClippingElementAncestors` function so that
1877
+ // multiple lifecycle resets re-use the same result. It only lives for a
1878
+ // single call. If other functions become expensive, we can add them as well.
1879
+ const cache = new Map();
1880
+ const mergedOptions = {
1881
+ platform,
1882
+ ...options
1883
+ };
1884
+ const platformWithCache = {
1885
+ ...mergedOptions.platform,
1886
+ _c: cache
1887
+ };
1888
+ return computePosition$1(reference, floating, {
1889
+ ...mergedOptions,
1890
+ platform: platformWithCache
1891
+ });
1892
+ };
1893
+
1894
+ const linkedCss = ".contents{display:contents}:host{display:contents;width:100%}.static{position:static}.flex{display:flex}.max-h-\\[--dropdown-box-max-height\\]{max-height:var(--dropdown-box-max-height)}.w-full{width:100%}.min-w-\\[--dropdown-box-min-weight\\]{min-width:var(--dropdown-box-min-weight)}.max-w-\\[--dropdown-box-max-weight\\]{max-width:var(--dropdown-box-max-weight)}.flex-col{flex-direction:column}.items-center{align-items:center}.rounded-lg{border-radius:.5rem}.bg-\\[--dropdown-box-background-color\\]{background-color:var(--dropdown-box-background-color)}.py-1\\.5{padding-bottom:.375rem;padding-top:.375rem}.shadow{--tw-shadow:var(--bcm-ui-box-shadow-default);--tw-shadow-colored:var(--bcm-ui-box-shadow-default)}.shadow,.shadow-3{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.shadow-3{--tw-shadow:var(--bcm-ui-box-shadow-3);--tw-shadow-colored:var(--bcm-ui-box-shadow-3)}.outline{outline-style:solid}.absolute{position:absolute}.z-\\[1000\\]{z-index:1000}.block{display:block}.min-w-max{min-width:max-content}";
1895
+ const BcmLinkedStyle0 = linkedCss;
1896
+
1897
+ const BcmLinked = class {
1898
+ constructor(hostRef) {
1899
+ registerInstance(this, hostRef);
1900
+ this.isVisible = false;
1901
+ }
1902
+ componentDidLoad() {
1903
+ requestAnimationFrame(() => {
1904
+ this.targetEl = this.targetElement || (this.targetId ? document.getElementById(this.targetId) : null);
1905
+ this.floatingEl = this.host.shadowRoot.querySelector('.floating-content');
1906
+ if (this.targetEl) {
1907
+ this.targetEl.addEventListener('click', (e) => {
1908
+ e.stopPropagation();
1909
+ this.toggle();
1910
+ });
1911
+ const handleClickOutside = (e) => {
1912
+ var _a, _b;
1913
+ const target = e.target;
1914
+ if (!((_a = this.floatingEl) === null || _a === void 0 ? void 0 : _a.contains(target)) &&
1915
+ !((_b = this.targetEl) === null || _b === void 0 ? void 0 : _b.contains(target)) &&
1916
+ !this.host.contains(target)) {
1917
+ this.hide();
1918
+ }
1919
+ };
1920
+ document.addEventListener('click', handleClickOutside);
1921
+ this.host['_handleClickOutside'] = handleClickOutside;
1922
+ }
1923
+ });
1924
+ }
1925
+ async updatePosition() {
1926
+ if (!this.targetEl || !this.floatingEl)
1927
+ return;
1928
+ const { x, y } = await computePosition(this.targetEl, this.floatingEl, {
1929
+ placement: 'bottom-start',
1930
+ middleware: [
1931
+ offset(2),
1932
+ flip({
1933
+ fallbackPlacements: ['top-start'],
1934
+ }),
1935
+ shift({ padding: 8 }),
1936
+ ],
1937
+ });
1938
+ Object.assign(this.floatingEl.style, {
1939
+ left: `${x}px`,
1940
+ top: `${y}px`,
1941
+ });
1942
+ }
1943
+ show() {
1944
+ this.isVisible = true;
1945
+ this.updatePosition();
1946
+ }
1947
+ hide() {
1948
+ this.isVisible = false;
1949
+ }
1950
+ toggle() {
1951
+ this.isVisible = !this.isVisible;
1952
+ if (this.isVisible) {
1953
+ this.updatePosition();
1954
+ }
1955
+ }
1956
+ render() {
1957
+ return (h("div", { key: 'e720bc0f9d7ed637a8c8150474dd30f1926dbe91', class: "floating-content z-[1000] flex min-w-max", style: {
1958
+ display: this.isVisible ? 'block' : 'none',
1959
+ position: 'absolute',
1960
+ top: "0px",
1961
+ left: "0px",
1962
+ } }, h("slot", { key: '5d01d04876f4f09e9977e3b1f3d02394fc57163f' })));
1963
+ }
1964
+ disconnectedCallback() {
1965
+ if (this.targetEl) {
1966
+ this.targetEl.removeEventListener('mouseenter', () => this.show());
1967
+ this.targetEl.removeEventListener('mouseleave', () => this.hide());
1968
+ this.targetEl.removeEventListener('click', () => this.toggle());
1969
+ }
1970
+ }
1971
+ get host() { return getElement(this); }
1972
+ };
1973
+ BcmLinked.style = BcmLinkedStyle0;
1974
+
1975
+ export { BcmLinked as bcm_linked };
1976
+
1977
+ //# sourceMappingURL=bcm-linked.entry.js.map