@quartzds/core 1.0.0-beta.1

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