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