@vertexvis/ui 0.0.16-canary.0 → 0.1.0-testing.0

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 (100) hide show
  1. package/dist/cjs/{auto-resize-textarea-56a57fd3.js → auto-resize-textarea-deb05359.js} +2 -14
  2. package/dist/cjs/components.cjs.js +1 -1
  3. package/dist/cjs/{draggable-popover-ee0db70b.js → draggable-popover-edf23d3a.js} +4 -9
  4. package/dist/cjs/index.cjs.js +10 -8
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/{menu-0579351b.js → menu-d1ecf43b.js} +4 -3
  7. package/dist/cjs/popover-d9ec8e10.js +1684 -0
  8. package/dist/cjs/{result-list-77ba2fa9.js → result-list-1e592c3c.js} +1 -1
  9. package/dist/cjs/{search-bar-81ca45b3.js → search-bar-bb40cfa7.js} +1 -1
  10. package/dist/cjs/slots-fb5ac359.js +29 -0
  11. package/dist/cjs/{templates-4e22ccc0.js → templates-e7b3ffbb.js} +3 -32
  12. package/dist/cjs/tooltip-31b596f5.js +2152 -0
  13. package/dist/cjs/tslib.es6-838fd860.js +68 -0
  14. package/dist/cjs/vertex-auto-resize-textarea.cjs.entry.js +2 -1
  15. package/dist/cjs/vertex-draggable-popover.cjs.entry.js +1 -1
  16. package/dist/cjs/vertex-menu.cjs.entry.js +1 -1
  17. package/dist/cjs/vertex-popover.cjs.entry.js +1 -1
  18. package/dist/cjs/vertex-result-list.cjs.entry.js +3 -2
  19. package/dist/cjs/vertex-search-bar.cjs.entry.js +3 -2
  20. package/dist/cjs/vertex-tooltip.cjs.entry.js +3 -1
  21. package/dist/collection/components/draggable-popover/draggable-popover.js +4 -9
  22. package/dist/collection/components/dropdown-menu/dropdown-menu.js +1 -1
  23. package/dist/collection/components/help-tooltip/help-tooltip.js +1 -1
  24. package/dist/collection/components/menu/menu.js +28 -4
  25. package/dist/collection/components/popover/middleware.js +26 -0
  26. package/dist/collection/components/popover/popover.css +1 -1
  27. package/dist/collection/components/popover/popover.js +147 -115
  28. package/dist/collection/components/popover/util.js +9 -0
  29. package/dist/collection/components/result-list/result-list.js +1 -1
  30. package/dist/collection/components/search-bar/search-bar.js +1 -1
  31. package/dist/collection/components/tooltip/tooltip.css +4 -0
  32. package/dist/collection/components/tooltip/tooltip.js +60 -4
  33. package/dist/collection/util/components/dom.js +10 -0
  34. package/dist/collection/util/components/slots.js +12 -0
  35. package/dist/components/components.css +1 -1
  36. package/dist/components/components.esm.js +1 -1
  37. package/dist/components/index.esm.js +1 -1
  38. package/dist/components/p-0517ca62.entry.js +1 -0
  39. package/dist/components/p-1356f525.js +1 -0
  40. package/dist/components/p-19318fee.entry.js +1 -0
  41. package/dist/components/p-41a7564c.js +1 -0
  42. package/dist/components/{p-5a93c1b6.js → p-4224c2ad.js} +1 -1
  43. package/dist/components/p-45cfd66e.entry.js +1 -0
  44. package/dist/components/{p-60ca5d84.js → p-52739247.js} +1 -1
  45. package/dist/components/p-59032668.js +1 -0
  46. package/dist/components/p-6505cdb3.js +1 -0
  47. package/dist/components/p-7b75e004.js +1 -0
  48. package/dist/components/p-9c384f6c.entry.js +1 -0
  49. package/dist/components/p-ae6a3c46.entry.js +1 -0
  50. package/dist/components/p-b2c7b113.js +1 -0
  51. package/dist/components/p-bec53c3a.js +1 -0
  52. package/dist/components/p-da0a7b57.js +1 -0
  53. package/dist/components/p-e576818b.entry.js +1 -0
  54. package/dist/components/p-e7336466.entry.js +1 -0
  55. package/dist/esm/{auto-resize-textarea-ac4b5f3b.js → auto-resize-textarea-087fecdb.js} +1 -13
  56. package/dist/esm/components.js +1 -1
  57. package/dist/esm/{draggable-popover-5f14cca5.js → draggable-popover-8ef3aec6.js} +4 -9
  58. package/dist/esm/index.js +10 -8
  59. package/dist/esm/loader.js +1 -1
  60. package/dist/esm/{menu-f35637ca.js → menu-daa7f9c9.js} +4 -3
  61. package/dist/esm/popover-67c88e4b.js +1682 -0
  62. package/dist/esm/{result-list-9c83f22a.js → result-list-36cfb08a.js} +1 -1
  63. package/dist/esm/{search-bar-600fb8d9.js → search-bar-59cc151d.js} +1 -1
  64. package/dist/esm/slots-fbb5afb3.js +26 -0
  65. package/dist/esm/{templates-51212dae.js → templates-797420bf.js} +1 -30
  66. package/dist/esm/tooltip-14b65fb5.js +2150 -0
  67. package/dist/esm/tslib.es6-99cd0de8.js +65 -0
  68. package/dist/esm/vertex-auto-resize-textarea.entry.js +2 -1
  69. package/dist/esm/vertex-draggable-popover.entry.js +1 -1
  70. package/dist/esm/vertex-menu.entry.js +1 -1
  71. package/dist/esm/vertex-popover.entry.js +1 -1
  72. package/dist/esm/vertex-result-list.entry.js +3 -2
  73. package/dist/esm/vertex-search-bar.entry.js +3 -2
  74. package/dist/esm/vertex-tooltip.entry.js +3 -1
  75. package/dist/types/components/menu/menu.d.ts +2 -1
  76. package/dist/types/components/popover/middleware.d.ts +3 -0
  77. package/dist/types/components/popover/popover.d.ts +39 -23
  78. package/dist/types/components/popover/util.d.ts +2 -0
  79. package/dist/types/components/tooltip/tooltip.d.ts +10 -0
  80. package/dist/types/components.d.ts +31 -15
  81. package/dist/types/util/components/dom.d.ts +3 -0
  82. package/dist/types/util/components/slots.d.ts +1 -0
  83. package/package.json +5 -4
  84. package/dist/cjs/popover-34e1a386.js +0 -2029
  85. package/dist/cjs/tooltip-afebbca8.js +0 -46
  86. package/dist/components/p-0ec0a007.entry.js +0 -1
  87. package/dist/components/p-4226645b.js +0 -1
  88. package/dist/components/p-58f8a354.js +0 -1
  89. package/dist/components/p-7c31f30e.js +0 -1
  90. package/dist/components/p-852be06f.js +0 -1
  91. package/dist/components/p-8764954b.js +0 -1
  92. package/dist/components/p-939391df.entry.js +0 -1
  93. package/dist/components/p-990852f6.entry.js +0 -1
  94. package/dist/components/p-a1d160cc.entry.js +0 -1
  95. package/dist/components/p-c8df41df.entry.js +0 -1
  96. package/dist/components/p-e8e6ee3f.js +0 -1
  97. package/dist/components/p-eff16591.entry.js +0 -1
  98. package/dist/components/p-f98b2ecb.entry.js +0 -1
  99. package/dist/esm/popover-4375db1b.js +0 -2027
  100. package/dist/esm/tooltip-e78d2c7a.js +0 -44
@@ -0,0 +1,1684 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-6a92256c.js');
4
+ const index$1 = require('./index-e1b40fa6.js');
5
+
6
+ /**
7
+ * Custom positioning reference element.
8
+ * @see https://floating-ui.com/docs/virtual-elements
9
+ */
10
+ const min = Math.min;
11
+ const max = Math.max;
12
+ const round = Math.round;
13
+ const floor = Math.floor;
14
+ const createCoords = v => ({
15
+ x: v,
16
+ y: v
17
+ });
18
+ const oppositeSideMap = {
19
+ left: 'right',
20
+ right: 'left',
21
+ bottom: 'top',
22
+ top: 'bottom'
23
+ };
24
+ const oppositeAlignmentMap = {
25
+ start: 'end',
26
+ end: 'start'
27
+ };
28
+ function clamp(start, value, end) {
29
+ return max(start, min(value, end));
30
+ }
31
+ function evaluate(value, param) {
32
+ return typeof value === 'function' ? value(param) : value;
33
+ }
34
+ function getSide(placement) {
35
+ return placement.split('-')[0];
36
+ }
37
+ function getAlignment(placement) {
38
+ return placement.split('-')[1];
39
+ }
40
+ function getOppositeAxis(axis) {
41
+ return axis === 'x' ? 'y' : 'x';
42
+ }
43
+ function getAxisLength(axis) {
44
+ return axis === 'y' ? 'height' : 'width';
45
+ }
46
+ function getSideAxis(placement) {
47
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
48
+ }
49
+ function getAlignmentAxis(placement) {
50
+ return getOppositeAxis(getSideAxis(placement));
51
+ }
52
+ function getAlignmentSides(placement, rects, rtl) {
53
+ if (rtl === void 0) {
54
+ rtl = false;
55
+ }
56
+ const alignment = getAlignment(placement);
57
+ const alignmentAxis = getAlignmentAxis(placement);
58
+ const length = getAxisLength(alignmentAxis);
59
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
60
+ if (rects.reference[length] > rects.floating[length]) {
61
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
62
+ }
63
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
64
+ }
65
+ function getExpandedPlacements(placement) {
66
+ const oppositePlacement = getOppositePlacement(placement);
67
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
68
+ }
69
+ function getOppositeAlignmentPlacement(placement) {
70
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
71
+ }
72
+ function getSideList(side, isStart, rtl) {
73
+ const lr = ['left', 'right'];
74
+ const rl = ['right', 'left'];
75
+ const tb = ['top', 'bottom'];
76
+ const bt = ['bottom', 'top'];
77
+ switch (side) {
78
+ case 'top':
79
+ case 'bottom':
80
+ if (rtl) return isStart ? rl : lr;
81
+ return isStart ? lr : rl;
82
+ case 'left':
83
+ case 'right':
84
+ return isStart ? tb : bt;
85
+ default:
86
+ return [];
87
+ }
88
+ }
89
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
90
+ const alignment = getAlignment(placement);
91
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
92
+ if (alignment) {
93
+ list = list.map(side => side + "-" + alignment);
94
+ if (flipAlignment) {
95
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
96
+ }
97
+ }
98
+ return list;
99
+ }
100
+ function getOppositePlacement(placement) {
101
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
102
+ }
103
+ function expandPaddingObject(padding) {
104
+ return {
105
+ top: 0,
106
+ right: 0,
107
+ bottom: 0,
108
+ left: 0,
109
+ ...padding
110
+ };
111
+ }
112
+ function getPaddingObject(padding) {
113
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
114
+ top: padding,
115
+ right: padding,
116
+ bottom: padding,
117
+ left: padding
118
+ };
119
+ }
120
+ function rectToClientRect(rect) {
121
+ const {
122
+ x,
123
+ y,
124
+ width,
125
+ height
126
+ } = rect;
127
+ return {
128
+ width,
129
+ height,
130
+ top: y,
131
+ left: x,
132
+ right: x + width,
133
+ bottom: y + height,
134
+ x,
135
+ y
136
+ };
137
+ }
138
+
139
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
140
+ let {
141
+ reference,
142
+ floating
143
+ } = _ref;
144
+ const sideAxis = getSideAxis(placement);
145
+ const alignmentAxis = getAlignmentAxis(placement);
146
+ const alignLength = getAxisLength(alignmentAxis);
147
+ const side = getSide(placement);
148
+ const isVertical = sideAxis === 'y';
149
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
150
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
151
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
152
+ let coords;
153
+ switch (side) {
154
+ case 'top':
155
+ coords = {
156
+ x: commonX,
157
+ y: reference.y - floating.height
158
+ };
159
+ break;
160
+ case 'bottom':
161
+ coords = {
162
+ x: commonX,
163
+ y: reference.y + reference.height
164
+ };
165
+ break;
166
+ case 'right':
167
+ coords = {
168
+ x: reference.x + reference.width,
169
+ y: commonY
170
+ };
171
+ break;
172
+ case 'left':
173
+ coords = {
174
+ x: reference.x - floating.width,
175
+ y: commonY
176
+ };
177
+ break;
178
+ default:
179
+ coords = {
180
+ x: reference.x,
181
+ y: reference.y
182
+ };
183
+ }
184
+ switch (getAlignment(placement)) {
185
+ case 'start':
186
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
187
+ break;
188
+ case 'end':
189
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
190
+ break;
191
+ }
192
+ return coords;
193
+ }
194
+
195
+ /**
196
+ * Computes the `x` and `y` coordinates that will place the floating element
197
+ * next to a given reference element.
198
+ *
199
+ * This export does not have any `platform` interface logic. You will need to
200
+ * write one for the platform you are using Floating UI with.
201
+ */
202
+ const computePosition$1 = async (reference, floating, config) => {
203
+ const {
204
+ placement = 'bottom',
205
+ strategy = 'absolute',
206
+ middleware = [],
207
+ platform
208
+ } = config;
209
+ const validMiddleware = middleware.filter(Boolean);
210
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
211
+ let rects = await platform.getElementRects({
212
+ reference,
213
+ floating,
214
+ strategy
215
+ });
216
+ let {
217
+ x,
218
+ y
219
+ } = computeCoordsFromPlacement(rects, placement, rtl);
220
+ let statefulPlacement = placement;
221
+ let middlewareData = {};
222
+ let resetCount = 0;
223
+ for (let i = 0; i < validMiddleware.length; i++) {
224
+ const {
225
+ name,
226
+ fn
227
+ } = validMiddleware[i];
228
+ const {
229
+ x: nextX,
230
+ y: nextY,
231
+ data,
232
+ reset
233
+ } = await fn({
234
+ x,
235
+ y,
236
+ initialPlacement: placement,
237
+ placement: statefulPlacement,
238
+ strategy,
239
+ middlewareData,
240
+ rects,
241
+ platform,
242
+ elements: {
243
+ reference,
244
+ floating
245
+ }
246
+ });
247
+ x = nextX != null ? nextX : x;
248
+ y = nextY != null ? nextY : y;
249
+ middlewareData = {
250
+ ...middlewareData,
251
+ [name]: {
252
+ ...middlewareData[name],
253
+ ...data
254
+ }
255
+ };
256
+ if (reset && resetCount <= 50) {
257
+ resetCount++;
258
+ if (typeof reset === 'object') {
259
+ if (reset.placement) {
260
+ statefulPlacement = reset.placement;
261
+ }
262
+ if (reset.rects) {
263
+ rects = reset.rects === true ? await platform.getElementRects({
264
+ reference,
265
+ floating,
266
+ strategy
267
+ }) : reset.rects;
268
+ }
269
+ ({
270
+ x,
271
+ y
272
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
273
+ }
274
+ i = -1;
275
+ }
276
+ }
277
+ return {
278
+ x,
279
+ y,
280
+ placement: statefulPlacement,
281
+ strategy,
282
+ middlewareData
283
+ };
284
+ };
285
+
286
+ /**
287
+ * Resolves with an object of overflow side offsets that determine how much the
288
+ * element is overflowing a given clipping boundary on each side.
289
+ * - positive = overflowing the boundary by that number of pixels
290
+ * - negative = how many pixels left before it will overflow
291
+ * - 0 = lies flush with the boundary
292
+ * @see https://floating-ui.com/docs/detectOverflow
293
+ */
294
+ async function detectOverflow$1(state, options) {
295
+ var _await$platform$isEle;
296
+ if (options === void 0) {
297
+ options = {};
298
+ }
299
+ const {
300
+ x,
301
+ y,
302
+ platform,
303
+ rects,
304
+ elements,
305
+ strategy
306
+ } = state;
307
+ const {
308
+ boundary = 'clippingAncestors',
309
+ rootBoundary = 'viewport',
310
+ elementContext = 'floating',
311
+ altBoundary = false,
312
+ padding = 0
313
+ } = evaluate(options, state);
314
+ const paddingObject = getPaddingObject(padding);
315
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
316
+ const element = elements[altBoundary ? altContext : elementContext];
317
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
318
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
319
+ boundary,
320
+ rootBoundary,
321
+ strategy
322
+ }));
323
+ const rect = elementContext === 'floating' ? {
324
+ x,
325
+ y,
326
+ width: rects.floating.width,
327
+ height: rects.floating.height
328
+ } : rects.reference;
329
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
330
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
331
+ x: 1,
332
+ y: 1
333
+ } : {
334
+ x: 1,
335
+ y: 1
336
+ };
337
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
338
+ elements,
339
+ rect,
340
+ offsetParent,
341
+ strategy
342
+ }) : rect);
343
+ return {
344
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
345
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
346
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
347
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
348
+ };
349
+ }
350
+
351
+ /**
352
+ * Optimizes the visibility of the floating element by flipping the `placement`
353
+ * in order to keep it in view when the preferred placement(s) will overflow the
354
+ * clipping boundary. Alternative to `autoPlacement`.
355
+ * @see https://floating-ui.com/docs/flip
356
+ */
357
+ const flip$1 = function (options) {
358
+ if (options === void 0) {
359
+ options = {};
360
+ }
361
+ return {
362
+ name: 'flip',
363
+ options,
364
+ async fn(state) {
365
+ var _middlewareData$arrow, _middlewareData$flip;
366
+ const {
367
+ placement,
368
+ middlewareData,
369
+ rects,
370
+ initialPlacement,
371
+ platform,
372
+ elements
373
+ } = state;
374
+ const {
375
+ mainAxis: checkMainAxis = true,
376
+ crossAxis: checkCrossAxis = true,
377
+ fallbackPlacements: specifiedFallbackPlacements,
378
+ fallbackStrategy = 'bestFit',
379
+ fallbackAxisSideDirection = 'none',
380
+ flipAlignment = true,
381
+ ...detectOverflowOptions
382
+ } = evaluate(options, state);
383
+
384
+ // If a reset by the arrow was caused due to an alignment offset being
385
+ // added, we should skip any logic now since `flip()` has already done its
386
+ // work.
387
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
388
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
389
+ return {};
390
+ }
391
+ const side = getSide(placement);
392
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
393
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
394
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
395
+ if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
396
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
397
+ }
398
+ const placements = [initialPlacement, ...fallbackPlacements];
399
+ const overflow = await detectOverflow$1(state, detectOverflowOptions);
400
+ const overflows = [];
401
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
402
+ if (checkMainAxis) {
403
+ overflows.push(overflow[side]);
404
+ }
405
+ if (checkCrossAxis) {
406
+ const sides = getAlignmentSides(placement, rects, rtl);
407
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
408
+ }
409
+ overflowsData = [...overflowsData, {
410
+ placement,
411
+ overflows
412
+ }];
413
+
414
+ // One or more sides is overflowing.
415
+ if (!overflows.every(side => side <= 0)) {
416
+ var _middlewareData$flip2, _overflowsData$filter;
417
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
418
+ const nextPlacement = placements[nextIndex];
419
+ if (nextPlacement) {
420
+ // Try next placement and re-run the lifecycle.
421
+ return {
422
+ data: {
423
+ index: nextIndex,
424
+ overflows: overflowsData
425
+ },
426
+ reset: {
427
+ placement: nextPlacement
428
+ }
429
+ };
430
+ }
431
+
432
+ // First, find the candidates that fit on the mainAxis side of overflow,
433
+ // then find the placement that fits the best on the main crossAxis side.
434
+ 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;
435
+
436
+ // Otherwise fallback.
437
+ if (!resetPlacement) {
438
+ switch (fallbackStrategy) {
439
+ case 'bestFit':
440
+ {
441
+ var _overflowsData$map$so;
442
+ 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];
443
+ if (placement) {
444
+ resetPlacement = placement;
445
+ }
446
+ break;
447
+ }
448
+ case 'initialPlacement':
449
+ resetPlacement = initialPlacement;
450
+ break;
451
+ }
452
+ }
453
+ if (placement !== resetPlacement) {
454
+ return {
455
+ reset: {
456
+ placement: resetPlacement
457
+ }
458
+ };
459
+ }
460
+ }
461
+ return {};
462
+ }
463
+ };
464
+ };
465
+
466
+ // For type backwards-compatibility, the `OffsetOptions` type was also
467
+ // Derivable.
468
+
469
+ async function convertValueToCoords(state, options) {
470
+ const {
471
+ placement,
472
+ platform,
473
+ elements
474
+ } = state;
475
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
476
+ const side = getSide(placement);
477
+ const alignment = getAlignment(placement);
478
+ const isVertical = getSideAxis(placement) === 'y';
479
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
480
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
481
+ const rawValue = evaluate(options, state);
482
+
483
+ // eslint-disable-next-line prefer-const
484
+ let {
485
+ mainAxis,
486
+ crossAxis,
487
+ alignmentAxis
488
+ } = typeof rawValue === 'number' ? {
489
+ mainAxis: rawValue,
490
+ crossAxis: 0,
491
+ alignmentAxis: null
492
+ } : {
493
+ mainAxis: 0,
494
+ crossAxis: 0,
495
+ alignmentAxis: null,
496
+ ...rawValue
497
+ };
498
+ if (alignment && typeof alignmentAxis === 'number') {
499
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
500
+ }
501
+ return isVertical ? {
502
+ x: crossAxis * crossAxisMulti,
503
+ y: mainAxis * mainAxisMulti
504
+ } : {
505
+ x: mainAxis * mainAxisMulti,
506
+ y: crossAxis * crossAxisMulti
507
+ };
508
+ }
509
+
510
+ /**
511
+ * Modifies the placement by translating the floating element along the
512
+ * specified axes.
513
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
514
+ * object may be passed.
515
+ * @see https://floating-ui.com/docs/offset
516
+ */
517
+ const offset$1 = function (options) {
518
+ if (options === void 0) {
519
+ options = 0;
520
+ }
521
+ return {
522
+ name: 'offset',
523
+ options,
524
+ async fn(state) {
525
+ var _middlewareData$offse, _middlewareData$arrow;
526
+ const {
527
+ x,
528
+ y,
529
+ placement,
530
+ middlewareData
531
+ } = state;
532
+ const diffCoords = await convertValueToCoords(state, options);
533
+
534
+ // If the placement is the same and the arrow caused an alignment offset
535
+ // then we don't need to change the positioning coordinates.
536
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
537
+ return {};
538
+ }
539
+ return {
540
+ x: x + diffCoords.x,
541
+ y: y + diffCoords.y,
542
+ data: {
543
+ ...diffCoords,
544
+ placement
545
+ }
546
+ };
547
+ }
548
+ };
549
+ };
550
+
551
+ /**
552
+ * Optimizes the visibility of the floating element by shifting it in order to
553
+ * keep it in view when it will overflow the clipping boundary.
554
+ * @see https://floating-ui.com/docs/shift
555
+ */
556
+ const shift$1 = function (options) {
557
+ if (options === void 0) {
558
+ options = {};
559
+ }
560
+ return {
561
+ name: 'shift',
562
+ options,
563
+ async fn(state) {
564
+ const {
565
+ x,
566
+ y,
567
+ placement
568
+ } = state;
569
+ const {
570
+ mainAxis: checkMainAxis = true,
571
+ crossAxis: checkCrossAxis = false,
572
+ limiter = {
573
+ fn: _ref => {
574
+ let {
575
+ x,
576
+ y
577
+ } = _ref;
578
+ return {
579
+ x,
580
+ y
581
+ };
582
+ }
583
+ },
584
+ ...detectOverflowOptions
585
+ } = evaluate(options, state);
586
+ const coords = {
587
+ x,
588
+ y
589
+ };
590
+ const overflow = await detectOverflow$1(state, detectOverflowOptions);
591
+ const crossAxis = getSideAxis(getSide(placement));
592
+ const mainAxis = getOppositeAxis(crossAxis);
593
+ let mainAxisCoord = coords[mainAxis];
594
+ let crossAxisCoord = coords[crossAxis];
595
+ if (checkMainAxis) {
596
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
597
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
598
+ const min = mainAxisCoord + overflow[minSide];
599
+ const max = mainAxisCoord - overflow[maxSide];
600
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
601
+ }
602
+ if (checkCrossAxis) {
603
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
604
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
605
+ const min = crossAxisCoord + overflow[minSide];
606
+ const max = crossAxisCoord - overflow[maxSide];
607
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
608
+ }
609
+ const limitedCoords = limiter.fn({
610
+ ...state,
611
+ [mainAxis]: mainAxisCoord,
612
+ [crossAxis]: crossAxisCoord
613
+ });
614
+ return {
615
+ ...limitedCoords,
616
+ data: {
617
+ x: limitedCoords.x - x,
618
+ y: limitedCoords.y - y
619
+ }
620
+ };
621
+ }
622
+ };
623
+ };
624
+
625
+ function getNodeName(node) {
626
+ if (isNode(node)) {
627
+ return (node.nodeName || '').toLowerCase();
628
+ }
629
+ // Mocked nodes in testing environments may not be instances of Node. By
630
+ // returning `#document` an infinite loop won't occur.
631
+ // https://github.com/floating-ui/floating-ui/issues/2317
632
+ return '#document';
633
+ }
634
+ function getWindow(node) {
635
+ var _node$ownerDocument;
636
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
637
+ }
638
+ function getDocumentElement(node) {
639
+ var _ref;
640
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
641
+ }
642
+ function isNode(value) {
643
+ return value instanceof Node || value instanceof getWindow(value).Node;
644
+ }
645
+ function isElement(value) {
646
+ return value instanceof Element || value instanceof getWindow(value).Element;
647
+ }
648
+ function isHTMLElement(value) {
649
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
650
+ }
651
+ function isShadowRoot(value) {
652
+ // Browsers without `ShadowRoot` support.
653
+ if (typeof ShadowRoot === 'undefined') {
654
+ return false;
655
+ }
656
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
657
+ }
658
+ function isOverflowElement(element) {
659
+ const {
660
+ overflow,
661
+ overflowX,
662
+ overflowY,
663
+ display
664
+ } = getComputedStyle(element);
665
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
666
+ }
667
+ function isTableElement(element) {
668
+ return ['table', 'td', 'th'].includes(getNodeName(element));
669
+ }
670
+ function isContainingBlock(element) {
671
+ const webkit = isWebKit();
672
+ const css = getComputedStyle(element);
673
+
674
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
675
+ return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
676
+ }
677
+ function getContainingBlock(element) {
678
+ let currentNode = getParentNode(element);
679
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
680
+ if (isContainingBlock(currentNode)) {
681
+ return currentNode;
682
+ }
683
+ currentNode = getParentNode(currentNode);
684
+ }
685
+ return null;
686
+ }
687
+ function isWebKit() {
688
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
689
+ return CSS.supports('-webkit-backdrop-filter', 'none');
690
+ }
691
+ function isLastTraversableNode(node) {
692
+ return ['html', 'body', '#document'].includes(getNodeName(node));
693
+ }
694
+ function getComputedStyle(element) {
695
+ return getWindow(element).getComputedStyle(element);
696
+ }
697
+ function getNodeScroll(element) {
698
+ if (isElement(element)) {
699
+ return {
700
+ scrollLeft: element.scrollLeft,
701
+ scrollTop: element.scrollTop
702
+ };
703
+ }
704
+ return {
705
+ scrollLeft: element.pageXOffset,
706
+ scrollTop: element.pageYOffset
707
+ };
708
+ }
709
+ function getParentNode(node) {
710
+ if (getNodeName(node) === 'html') {
711
+ return node;
712
+ }
713
+ const result =
714
+ // Step into the shadow DOM of the parent of a slotted node.
715
+ node.assignedSlot ||
716
+ // DOM Element detected.
717
+ node.parentNode ||
718
+ // ShadowRoot detected.
719
+ isShadowRoot(node) && node.host ||
720
+ // Fallback.
721
+ getDocumentElement(node);
722
+ return isShadowRoot(result) ? result.host : result;
723
+ }
724
+ function getNearestOverflowAncestor(node) {
725
+ const parentNode = getParentNode(node);
726
+ if (isLastTraversableNode(parentNode)) {
727
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
728
+ }
729
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
730
+ return parentNode;
731
+ }
732
+ return getNearestOverflowAncestor(parentNode);
733
+ }
734
+ function getOverflowAncestors(node, list, traverseIframes) {
735
+ var _node$ownerDocument2;
736
+ if (list === void 0) {
737
+ list = [];
738
+ }
739
+ if (traverseIframes === void 0) {
740
+ traverseIframes = true;
741
+ }
742
+ const scrollableAncestor = getNearestOverflowAncestor(node);
743
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
744
+ const win = getWindow(scrollableAncestor);
745
+ if (isBody) {
746
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], win.frameElement && traverseIframes ? getOverflowAncestors(win.frameElement) : []);
747
+ }
748
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
749
+ }
750
+
751
+ function getCssDimensions(element) {
752
+ const css = getComputedStyle(element);
753
+ // In testing environments, the `width` and `height` properties are empty
754
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
755
+ let width = parseFloat(css.width) || 0;
756
+ let height = parseFloat(css.height) || 0;
757
+ const hasOffset = isHTMLElement(element);
758
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
759
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
760
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
761
+ if (shouldFallback) {
762
+ width = offsetWidth;
763
+ height = offsetHeight;
764
+ }
765
+ return {
766
+ width,
767
+ height,
768
+ $: shouldFallback
769
+ };
770
+ }
771
+
772
+ function unwrapElement(element) {
773
+ return !isElement(element) ? element.contextElement : element;
774
+ }
775
+
776
+ function getScale(element) {
777
+ const domElement = unwrapElement(element);
778
+ if (!isHTMLElement(domElement)) {
779
+ return createCoords(1);
780
+ }
781
+ const rect = domElement.getBoundingClientRect();
782
+ const {
783
+ width,
784
+ height,
785
+ $
786
+ } = getCssDimensions(domElement);
787
+ let x = ($ ? round(rect.width) : rect.width) / width;
788
+ let y = ($ ? round(rect.height) : rect.height) / height;
789
+
790
+ // 0, NaN, or Infinity should always fallback to 1.
791
+
792
+ if (!x || !Number.isFinite(x)) {
793
+ x = 1;
794
+ }
795
+ if (!y || !Number.isFinite(y)) {
796
+ y = 1;
797
+ }
798
+ return {
799
+ x,
800
+ y
801
+ };
802
+ }
803
+
804
+ const noOffsets = /*#__PURE__*/createCoords(0);
805
+ function getVisualOffsets(element) {
806
+ const win = getWindow(element);
807
+ if (!isWebKit() || !win.visualViewport) {
808
+ return noOffsets;
809
+ }
810
+ return {
811
+ x: win.visualViewport.offsetLeft,
812
+ y: win.visualViewport.offsetTop
813
+ };
814
+ }
815
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
816
+ if (isFixed === void 0) {
817
+ isFixed = false;
818
+ }
819
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
820
+ return false;
821
+ }
822
+ return isFixed;
823
+ }
824
+
825
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
826
+ if (includeScale === void 0) {
827
+ includeScale = false;
828
+ }
829
+ if (isFixedStrategy === void 0) {
830
+ isFixedStrategy = false;
831
+ }
832
+ const clientRect = element.getBoundingClientRect();
833
+ const domElement = unwrapElement(element);
834
+ let scale = createCoords(1);
835
+ if (includeScale) {
836
+ if (offsetParent) {
837
+ if (isElement(offsetParent)) {
838
+ scale = getScale(offsetParent);
839
+ }
840
+ } else {
841
+ scale = getScale(element);
842
+ }
843
+ }
844
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
845
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
846
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
847
+ let width = clientRect.width / scale.x;
848
+ let height = clientRect.height / scale.y;
849
+ if (domElement) {
850
+ const win = getWindow(domElement);
851
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
852
+ let currentWin = win;
853
+ let currentIFrame = currentWin.frameElement;
854
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
855
+ const iframeScale = getScale(currentIFrame);
856
+ const iframeRect = currentIFrame.getBoundingClientRect();
857
+ const css = getComputedStyle(currentIFrame);
858
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
859
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
860
+ x *= iframeScale.x;
861
+ y *= iframeScale.y;
862
+ width *= iframeScale.x;
863
+ height *= iframeScale.y;
864
+ x += left;
865
+ y += top;
866
+ currentWin = getWindow(currentIFrame);
867
+ currentIFrame = currentWin.frameElement;
868
+ }
869
+ }
870
+ return rectToClientRect({
871
+ width,
872
+ height,
873
+ x,
874
+ y
875
+ });
876
+ }
877
+
878
+ const topLayerSelectors = [':popover-open', ':modal'];
879
+ function isTopLayer(element) {
880
+ return topLayerSelectors.some(selector => {
881
+ try {
882
+ return element.matches(selector);
883
+ } catch (e) {
884
+ return false;
885
+ }
886
+ });
887
+ }
888
+
889
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
890
+ let {
891
+ elements,
892
+ rect,
893
+ offsetParent,
894
+ strategy
895
+ } = _ref;
896
+ const isFixed = strategy === 'fixed';
897
+ const documentElement = getDocumentElement(offsetParent);
898
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
899
+ if (offsetParent === documentElement || topLayer && isFixed) {
900
+ return rect;
901
+ }
902
+ let scroll = {
903
+ scrollLeft: 0,
904
+ scrollTop: 0
905
+ };
906
+ let scale = createCoords(1);
907
+ const offsets = createCoords(0);
908
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
909
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
910
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
911
+ scroll = getNodeScroll(offsetParent);
912
+ }
913
+ if (isHTMLElement(offsetParent)) {
914
+ const offsetRect = getBoundingClientRect(offsetParent);
915
+ scale = getScale(offsetParent);
916
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
917
+ offsets.y = offsetRect.y + offsetParent.clientTop;
918
+ }
919
+ }
920
+ return {
921
+ width: rect.width * scale.x,
922
+ height: rect.height * scale.y,
923
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
924
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
925
+ };
926
+ }
927
+
928
+ function getClientRects(element) {
929
+ return Array.from(element.getClientRects());
930
+ }
931
+
932
+ function getWindowScrollBarX(element) {
933
+ // If <html> has a CSS width greater than the viewport, then this will be
934
+ // incorrect for RTL.
935
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
936
+ }
937
+
938
+ // Gets the entire size of the scrollable document area, even extending outside
939
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
940
+ function getDocumentRect(element) {
941
+ const html = getDocumentElement(element);
942
+ const scroll = getNodeScroll(element);
943
+ const body = element.ownerDocument.body;
944
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
945
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
946
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
947
+ const y = -scroll.scrollTop;
948
+ if (getComputedStyle(body).direction === 'rtl') {
949
+ x += max(html.clientWidth, body.clientWidth) - width;
950
+ }
951
+ return {
952
+ width,
953
+ height,
954
+ x,
955
+ y
956
+ };
957
+ }
958
+
959
+ function getViewportRect(element, strategy) {
960
+ const win = getWindow(element);
961
+ const html = getDocumentElement(element);
962
+ const visualViewport = win.visualViewport;
963
+ let width = html.clientWidth;
964
+ let height = html.clientHeight;
965
+ let x = 0;
966
+ let y = 0;
967
+ if (visualViewport) {
968
+ width = visualViewport.width;
969
+ height = visualViewport.height;
970
+ const visualViewportBased = isWebKit();
971
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
972
+ x = visualViewport.offsetLeft;
973
+ y = visualViewport.offsetTop;
974
+ }
975
+ }
976
+ return {
977
+ width,
978
+ height,
979
+ x,
980
+ y
981
+ };
982
+ }
983
+
984
+ // Returns the inner client rect, subtracting scrollbars if present.
985
+ function getInnerBoundingClientRect(element, strategy) {
986
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
987
+ const top = clientRect.top + element.clientTop;
988
+ const left = clientRect.left + element.clientLeft;
989
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
990
+ const width = element.clientWidth * scale.x;
991
+ const height = element.clientHeight * scale.y;
992
+ const x = left * scale.x;
993
+ const y = top * scale.y;
994
+ return {
995
+ width,
996
+ height,
997
+ x,
998
+ y
999
+ };
1000
+ }
1001
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1002
+ let rect;
1003
+ if (clippingAncestor === 'viewport') {
1004
+ rect = getViewportRect(element, strategy);
1005
+ } else if (clippingAncestor === 'document') {
1006
+ rect = getDocumentRect(getDocumentElement(element));
1007
+ } else if (isElement(clippingAncestor)) {
1008
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1009
+ } else {
1010
+ const visualOffsets = getVisualOffsets(element);
1011
+ rect = {
1012
+ ...clippingAncestor,
1013
+ x: clippingAncestor.x - visualOffsets.x,
1014
+ y: clippingAncestor.y - visualOffsets.y
1015
+ };
1016
+ }
1017
+ return rectToClientRect(rect);
1018
+ }
1019
+ function hasFixedPositionAncestor(element, stopNode) {
1020
+ const parentNode = getParentNode(element);
1021
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1022
+ return false;
1023
+ }
1024
+ return getComputedStyle(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1025
+ }
1026
+
1027
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1028
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1029
+ // of the given element up the tree.
1030
+ function getClippingElementAncestors(element, cache) {
1031
+ const cachedResult = cache.get(element);
1032
+ if (cachedResult) {
1033
+ return cachedResult;
1034
+ }
1035
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
1036
+ let currentContainingBlockComputedStyle = null;
1037
+ const elementIsFixed = getComputedStyle(element).position === 'fixed';
1038
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1039
+
1040
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1041
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1042
+ const computedStyle = getComputedStyle(currentNode);
1043
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1044
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1045
+ currentContainingBlockComputedStyle = null;
1046
+ }
1047
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1048
+ if (shouldDropCurrentNode) {
1049
+ // Drop non-containing blocks.
1050
+ result = result.filter(ancestor => ancestor !== currentNode);
1051
+ } else {
1052
+ // Record last containing block for next iteration.
1053
+ currentContainingBlockComputedStyle = computedStyle;
1054
+ }
1055
+ currentNode = getParentNode(currentNode);
1056
+ }
1057
+ cache.set(element, result);
1058
+ return result;
1059
+ }
1060
+
1061
+ // Gets the maximum area that the element is visible in due to any number of
1062
+ // clipping ancestors.
1063
+ function getClippingRect(_ref) {
1064
+ let {
1065
+ element,
1066
+ boundary,
1067
+ rootBoundary,
1068
+ strategy
1069
+ } = _ref;
1070
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1071
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1072
+ const firstClippingAncestor = clippingAncestors[0];
1073
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1074
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1075
+ accRect.top = max(rect.top, accRect.top);
1076
+ accRect.right = min(rect.right, accRect.right);
1077
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1078
+ accRect.left = max(rect.left, accRect.left);
1079
+ return accRect;
1080
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1081
+ return {
1082
+ width: clippingRect.right - clippingRect.left,
1083
+ height: clippingRect.bottom - clippingRect.top,
1084
+ x: clippingRect.left,
1085
+ y: clippingRect.top
1086
+ };
1087
+ }
1088
+
1089
+ function getDimensions(element) {
1090
+ const {
1091
+ width,
1092
+ height
1093
+ } = getCssDimensions(element);
1094
+ return {
1095
+ width,
1096
+ height
1097
+ };
1098
+ }
1099
+
1100
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1101
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1102
+ const documentElement = getDocumentElement(offsetParent);
1103
+ const isFixed = strategy === 'fixed';
1104
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1105
+ let scroll = {
1106
+ scrollLeft: 0,
1107
+ scrollTop: 0
1108
+ };
1109
+ const offsets = createCoords(0);
1110
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1111
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1112
+ scroll = getNodeScroll(offsetParent);
1113
+ }
1114
+ if (isOffsetParentAnElement) {
1115
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1116
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1117
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1118
+ } else if (documentElement) {
1119
+ offsets.x = getWindowScrollBarX(documentElement);
1120
+ }
1121
+ }
1122
+ const x = rect.left + scroll.scrollLeft - offsets.x;
1123
+ const y = rect.top + scroll.scrollTop - offsets.y;
1124
+ return {
1125
+ x,
1126
+ y,
1127
+ width: rect.width,
1128
+ height: rect.height
1129
+ };
1130
+ }
1131
+
1132
+ function isStaticPositioned(element) {
1133
+ return getComputedStyle(element).position === 'static';
1134
+ }
1135
+
1136
+ function getTrueOffsetParent(element, polyfill) {
1137
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1138
+ return null;
1139
+ }
1140
+ if (polyfill) {
1141
+ return polyfill(element);
1142
+ }
1143
+ return element.offsetParent;
1144
+ }
1145
+
1146
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1147
+ // such as table ancestors and cross browser bugs.
1148
+ function getOffsetParent(element, polyfill) {
1149
+ const win = getWindow(element);
1150
+ if (isTopLayer(element)) {
1151
+ return win;
1152
+ }
1153
+ if (!isHTMLElement(element)) {
1154
+ let svgOffsetParent = getParentNode(element);
1155
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1156
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1157
+ return svgOffsetParent;
1158
+ }
1159
+ svgOffsetParent = getParentNode(svgOffsetParent);
1160
+ }
1161
+ return win;
1162
+ }
1163
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1164
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1165
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1166
+ }
1167
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1168
+ return win;
1169
+ }
1170
+ return offsetParent || getContainingBlock(element) || win;
1171
+ }
1172
+
1173
+ const getElementRects = async function (data) {
1174
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1175
+ const getDimensionsFn = this.getDimensions;
1176
+ const floatingDimensions = await getDimensionsFn(data.floating);
1177
+ return {
1178
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1179
+ floating: {
1180
+ x: 0,
1181
+ y: 0,
1182
+ width: floatingDimensions.width,
1183
+ height: floatingDimensions.height
1184
+ }
1185
+ };
1186
+ };
1187
+
1188
+ function isRTL(element) {
1189
+ return getComputedStyle(element).direction === 'rtl';
1190
+ }
1191
+
1192
+ const platform = {
1193
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1194
+ getDocumentElement,
1195
+ getClippingRect,
1196
+ getOffsetParent,
1197
+ getElementRects,
1198
+ getClientRects,
1199
+ getDimensions,
1200
+ getScale,
1201
+ isElement,
1202
+ isRTL
1203
+ };
1204
+
1205
+ // https://samthor.au/2021/observing-dom/
1206
+ function observeMove(element, onMove) {
1207
+ let io = null;
1208
+ let timeoutId;
1209
+ const root = getDocumentElement(element);
1210
+ function cleanup() {
1211
+ var _io;
1212
+ clearTimeout(timeoutId);
1213
+ (_io = io) == null || _io.disconnect();
1214
+ io = null;
1215
+ }
1216
+ function refresh(skip, threshold) {
1217
+ if (skip === void 0) {
1218
+ skip = false;
1219
+ }
1220
+ if (threshold === void 0) {
1221
+ threshold = 1;
1222
+ }
1223
+ cleanup();
1224
+ const {
1225
+ left,
1226
+ top,
1227
+ width,
1228
+ height
1229
+ } = element.getBoundingClientRect();
1230
+ if (!skip) {
1231
+ onMove();
1232
+ }
1233
+ if (!width || !height) {
1234
+ return;
1235
+ }
1236
+ const insetTop = floor(top);
1237
+ const insetRight = floor(root.clientWidth - (left + width));
1238
+ const insetBottom = floor(root.clientHeight - (top + height));
1239
+ const insetLeft = floor(left);
1240
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
1241
+ const options = {
1242
+ rootMargin,
1243
+ threshold: max(0, min(1, threshold)) || 1
1244
+ };
1245
+ let isFirstUpdate = true;
1246
+ function handleObserve(entries) {
1247
+ const ratio = entries[0].intersectionRatio;
1248
+ if (ratio !== threshold) {
1249
+ if (!isFirstUpdate) {
1250
+ return refresh();
1251
+ }
1252
+ if (!ratio) {
1253
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
1254
+ // to prevent an infinite loop of updates.
1255
+ timeoutId = setTimeout(() => {
1256
+ refresh(false, 1e-7);
1257
+ }, 1000);
1258
+ } else {
1259
+ refresh(false, ratio);
1260
+ }
1261
+ }
1262
+ isFirstUpdate = false;
1263
+ }
1264
+
1265
+ // Older browsers don't support a `document` as the root and will throw an
1266
+ // error.
1267
+ try {
1268
+ io = new IntersectionObserver(handleObserve, {
1269
+ ...options,
1270
+ // Handle <iframe>s
1271
+ root: root.ownerDocument
1272
+ });
1273
+ } catch (e) {
1274
+ io = new IntersectionObserver(handleObserve, options);
1275
+ }
1276
+ io.observe(element);
1277
+ }
1278
+ refresh(true);
1279
+ return cleanup;
1280
+ }
1281
+
1282
+ /**
1283
+ * Automatically updates the position of the floating element when necessary.
1284
+ * Should only be called when the floating element is mounted on the DOM or
1285
+ * visible on the screen.
1286
+ * @returns cleanup function that should be invoked when the floating element is
1287
+ * removed from the DOM or hidden from the screen.
1288
+ * @see https://floating-ui.com/docs/autoUpdate
1289
+ */
1290
+ function autoUpdate(reference, floating, update, options) {
1291
+ if (options === void 0) {
1292
+ options = {};
1293
+ }
1294
+ const {
1295
+ ancestorScroll = true,
1296
+ ancestorResize = true,
1297
+ elementResize = typeof ResizeObserver === 'function',
1298
+ layoutShift = typeof IntersectionObserver === 'function',
1299
+ animationFrame = false
1300
+ } = options;
1301
+ const referenceEl = unwrapElement(reference);
1302
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
1303
+ ancestors.forEach(ancestor => {
1304
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1305
+ passive: true
1306
+ });
1307
+ ancestorResize && ancestor.addEventListener('resize', update);
1308
+ });
1309
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
1310
+ let reobserveFrame = -1;
1311
+ let resizeObserver = null;
1312
+ if (elementResize) {
1313
+ resizeObserver = new ResizeObserver(_ref => {
1314
+ let [firstEntry] = _ref;
1315
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
1316
+ // Prevent update loops when using the `size` middleware.
1317
+ // https://github.com/floating-ui/floating-ui/issues/1740
1318
+ resizeObserver.unobserve(floating);
1319
+ cancelAnimationFrame(reobserveFrame);
1320
+ reobserveFrame = requestAnimationFrame(() => {
1321
+ var _resizeObserver;
1322
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
1323
+ });
1324
+ }
1325
+ update();
1326
+ });
1327
+ if (referenceEl && !animationFrame) {
1328
+ resizeObserver.observe(referenceEl);
1329
+ }
1330
+ resizeObserver.observe(floating);
1331
+ }
1332
+ let frameId;
1333
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1334
+ if (animationFrame) {
1335
+ frameLoop();
1336
+ }
1337
+ function frameLoop() {
1338
+ const nextRefRect = getBoundingClientRect(reference);
1339
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1340
+ update();
1341
+ }
1342
+ prevRefRect = nextRefRect;
1343
+ frameId = requestAnimationFrame(frameLoop);
1344
+ }
1345
+ update();
1346
+ return () => {
1347
+ var _resizeObserver2;
1348
+ ancestors.forEach(ancestor => {
1349
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1350
+ ancestorResize && ancestor.removeEventListener('resize', update);
1351
+ });
1352
+ cleanupIo == null || cleanupIo();
1353
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
1354
+ resizeObserver = null;
1355
+ if (animationFrame) {
1356
+ cancelAnimationFrame(frameId);
1357
+ }
1358
+ };
1359
+ }
1360
+
1361
+ /**
1362
+ * Resolves with an object of overflow side offsets that determine how much the
1363
+ * element is overflowing a given clipping boundary on each side.
1364
+ * - positive = overflowing the boundary by that number of pixels
1365
+ * - negative = how many pixels left before it will overflow
1366
+ * - 0 = lies flush with the boundary
1367
+ * @see https://floating-ui.com/docs/detectOverflow
1368
+ */
1369
+ const detectOverflow = detectOverflow$1;
1370
+
1371
+ /**
1372
+ * Modifies the placement by translating the floating element along the
1373
+ * specified axes.
1374
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1375
+ * object may be passed.
1376
+ * @see https://floating-ui.com/docs/offset
1377
+ */
1378
+ const offset = offset$1;
1379
+
1380
+ /**
1381
+ * Optimizes the visibility of the floating element by shifting it in order to
1382
+ * keep it in view when it will overflow the clipping boundary.
1383
+ * @see https://floating-ui.com/docs/shift
1384
+ */
1385
+ const shift = shift$1;
1386
+
1387
+ /**
1388
+ * Optimizes the visibility of the floating element by flipping the `placement`
1389
+ * in order to keep it in view when the preferred placement(s) will overflow the
1390
+ * clipping boundary. Alternative to `autoPlacement`.
1391
+ * @see https://floating-ui.com/docs/flip
1392
+ */
1393
+ const flip = flip$1;
1394
+
1395
+ /**
1396
+ * Computes the `x` and `y` coordinates that will place the floating element
1397
+ * next to a given reference element.
1398
+ */
1399
+ const computePosition = (reference, floating, options) => {
1400
+ // This caches the expensive `getClippingElementAncestors` function so that
1401
+ // multiple lifecycle resets re-use the same result. It only lives for a
1402
+ // single call. If other functions become expensive, we can add them as well.
1403
+ const cache = new Map();
1404
+ const mergedOptions = {
1405
+ platform,
1406
+ ...options
1407
+ };
1408
+ const platformWithCache = {
1409
+ ...mergedOptions.platform,
1410
+ _c: cache
1411
+ };
1412
+ return computePosition$1(reference, floating, {
1413
+ ...mergedOptions,
1414
+ platform: platformWithCache
1415
+ });
1416
+ };
1417
+
1418
+ function getDefaultMiddleware(offsetOptions, overflowOptions, flipOptions) {
1419
+ const isMiddleware = (v) => typeof v !== 'boolean';
1420
+ return [
1421
+ offsetOptions != null ? offset(offsetOptions) : offset(4),
1422
+ overflowOptions == null && flip(flipOptions),
1423
+ shift(),
1424
+ overflowOptions != null && preventOverflow(overflowOptions),
1425
+ ].filter(isMiddleware);
1426
+ }
1427
+ function preventOverflow(overflowOptions) {
1428
+ return {
1429
+ name: 'boundaryContain',
1430
+ fn: async (state) => {
1431
+ const overflow = await detectOverflow(state, overflowOptions);
1432
+ const leftOverflow = overflow.left > 0 ? overflow.left : 0;
1433
+ const rightOverflow = overflow.right > 0 ? overflow.right : 0;
1434
+ const topOverflow = overflow.top > 0 ? overflow.top : 0;
1435
+ const bottomOverflow = overflow.bottom > 0 ? overflow.bottom : 0;
1436
+ return {
1437
+ x: state.x + leftOverflow - rightOverflow,
1438
+ y: state.y + topOverflow - bottomOverflow,
1439
+ };
1440
+ },
1441
+ };
1442
+ }
1443
+
1444
+ async function computeUpdatedPosition(referenceElement, contentElement, placement, middleware) {
1445
+ const position = await computePosition(referenceElement, contentElement, {
1446
+ placement,
1447
+ middleware,
1448
+ strategy: 'fixed',
1449
+ });
1450
+ return position;
1451
+ }
1452
+
1453
+ const popoverCss = ":host{--open-animation-name:open-scale-all;--open-animation:var(--open-animation-name) 0.1s ease-out 1;--close-animation-name:close-scale-all;--close-animation:var(--close-animation-name) 0.2s ease-in-out 1;--transform-origin:var(--none)}.open-animated{animation:var(--open-animation)}.hidden-animated{animation:var(--close-animation)}.hidden>.content{opacity:0;width:0;height:0;visibility:hidden}.hidden{pointer-events:none}.open{z-index:var(--vertex-ui-context-menu-layer)}.anchor{position:fixed}.backdrop{position:fixed;top:0;left:0;width:100vw;height:100vh;background-color:var(--backdrop-color, white);opacity:var(--backdrop-opacity, 0);z-index:var(--vertex-ui-context-menu-layer)}.popper{position:fixed}.center-bottom{transform-origin:var(--transform-origin, center bottom)}.left-bottom{transform-origin:var(--transform-origin, left bottom)}.right-bottom{transform-origin:var(--transform-origin, right bottom)}.center-top{transform-origin:var(--transform-origin, center top)}.left-top{transform-origin:var(--transform-origin, left top)}.right-top{transform-origin:var(--transform-origin, right top)}.left-center{transform-origin:var(--transform-origin, left center)}.left-top{transform-origin:var(--transform-origin, left top)}.left-bottom{transform-origin:var(--transform-origin, left bottom)}.right-center{transform-origin:var(--transform-origin, right center)}.right-top{transform-origin:var(--transform-origin, right top)}.right-bottom{transform-origin:var(--transform-origin, right bottom)}@keyframes open-fade-in{from{opacity:0}to{opacity:1}}@keyframes close-fade-out{from{visibility:visible;height:auto;width:auto;opacity:1}to{opacity:0;height:auto;width:auto}}@keyframes open-scale-all{from{opacity:0;transform:scale(0)}to{opacity:1;transform:scale(1)}}@keyframes close-scale-all{from{visibility:visible;height:auto;width:auto;opacity:1;transform:scale(1)}to{opacity:0;height:auto;width:auto;transform:scale(0)}}@keyframes open-scale-y{from{opacity:0;transform:scaleY(0)}to{opacity:1;transform:scaleY(1)}}@keyframes close-scale-y{from{visibility:visible;height:auto;width:auto;opacity:1;transform:scaleY(1)}to{opacity:0;height:auto;width:auto;transform:scaleY(0)}}@keyframes open-scale-x{from{opacity:0;transform:scaleX(0)}to{opacity:1;transform:scaleX(1)}}@keyframes close-scale-x{from{visibility:visible;height:auto;width:auto;opacity:1;transform:scaleX(1)}to{opacity:0;height:auto;width:auto;transform:scaleX(0)}}";
1454
+
1455
+ const WINDOW_RESIZE_DEBOUNCE_THRESHOLD = 200;
1456
+ const Popover = class {
1457
+ constructor(hostRef) {
1458
+ index.registerInstance(this, hostRef);
1459
+ this.dismissed = index.createEvent(this, "dismissed", 7);
1460
+ this.shouldUpdatePosition = false;
1461
+ this.middleware = [];
1462
+ this.partialWindow = window;
1463
+ this.open = false;
1464
+ this.placement = 'bottom-start';
1465
+ this.position = undefined;
1466
+ this.anchorBounds = undefined;
1467
+ this.backdrop = true;
1468
+ this.animated = false;
1469
+ this.anchorSelector = undefined;
1470
+ this.boundarySelector = undefined;
1471
+ this.resizeBehavior = 'dynamic';
1472
+ this.overflowBehavior = undefined;
1473
+ this.flipBehavior = undefined;
1474
+ this.offsetBehavior = undefined;
1475
+ this.updateOnResize = false;
1476
+ this.opened = false;
1477
+ this.computedPlacement = this.placement;
1478
+ this.updateListener = this.updateListener.bind(this);
1479
+ this.handlePositionUpdate = this.handlePositionUpdate.bind(this);
1480
+ this.handleResize = this.handleResize.bind(this);
1481
+ this.setWindow = this.setWindow.bind(this);
1482
+ }
1483
+ connectedCallback() {
1484
+ this.updatePosition(this.position);
1485
+ }
1486
+ componentDidUpdate() {
1487
+ if (this.shouldUpdatePosition) {
1488
+ this.shouldUpdatePosition = false;
1489
+ if (this.updateDispose != null) {
1490
+ this.handlePositionUpdate();
1491
+ }
1492
+ else {
1493
+ this.updateListener();
1494
+ }
1495
+ }
1496
+ }
1497
+ componentDidLoad() {
1498
+ this.updateViewport();
1499
+ this.handleMiddlewareChange();
1500
+ this.updateListener();
1501
+ if (this.resizeBehavior === 'dynamic') {
1502
+ window.addEventListener('resize', this.handleResize);
1503
+ }
1504
+ }
1505
+ disconnectedCallback() {
1506
+ this.viewportWidth = undefined;
1507
+ this.viewportHeight = undefined;
1508
+ this.opened = false;
1509
+ if (this.resizeBehavior === 'dynamic') {
1510
+ window.removeEventListener('resize', this.handleResize);
1511
+ }
1512
+ }
1513
+ updatePosition(position) {
1514
+ if (position != null) {
1515
+ this.anchorPosition =
1516
+ typeof position === 'object' ? position : JSON.parse(position);
1517
+ this.shouldUpdatePosition = true;
1518
+ }
1519
+ }
1520
+ updatePlacement() {
1521
+ this.updatePosition(this.position);
1522
+ }
1523
+ updateOpened(open) {
1524
+ if (open) {
1525
+ this.opened = true;
1526
+ }
1527
+ this.updateListener();
1528
+ }
1529
+ updateAnimated() {
1530
+ this.opened = this.open;
1531
+ }
1532
+ updateMiddleware() {
1533
+ this.handleMiddlewareChange();
1534
+ }
1535
+ /**
1536
+ * @private Used for internals or testing.
1537
+ */
1538
+ setWindow(partialWindow) {
1539
+ this.partialWindow = partialWindow;
1540
+ }
1541
+ render() {
1542
+ var _a, _b;
1543
+ return (index.h(index.Host, null, this.open && this.backdrop && (index.h("div", { class: "backdrop", onPointerDown: () => {
1544
+ this.open = false;
1545
+ this.dismissed.emit();
1546
+ } })), this.anchorPosition && (index.h("div", { ref: (element) => (this.anchorPointRef = element), class: "anchor", style: {
1547
+ left: `${((_a = this.anchorPosition) === null || _a === void 0 ? void 0 : _a.x) || 0}px`,
1548
+ top: `${((_b = this.anchorPosition) === null || _b === void 0 ? void 0 : _b.y) || 0}px`,
1549
+ } })), index.h("slot", { name: "anchor" }), index.h("div", { ref: (element) => (this.wrapperRef = element), class: index$1.classnames('popper', {
1550
+ hidden: !this.open,
1551
+ open: this.open,
1552
+ }) }, index.h("div", { class: index$1.classnames('content', {
1553
+ 'hidden-animated': !this.open && this.opened && this.animated,
1554
+ 'open-animated': this.open && this.animated,
1555
+ }, this.getTransformClass()), onAnimationEnd: () => {
1556
+ this.opened = this.open;
1557
+ } }, index.h("slot", null)))));
1558
+ }
1559
+ updateListener() {
1560
+ var _a, _b, _c, _d;
1561
+ const referenceElement = (_b = (_a = this.getSlottedAnchorElement()) !== null && _a !== void 0 ? _a : this.anchorPointRef) !== null && _b !== void 0 ? _b : this.getAnchorBoundsVirtualElement();
1562
+ if (this.open && referenceElement != null && this.wrapperRef != null) {
1563
+ (_c = this.updateDispose) === null || _c === void 0 ? void 0 : _c.call(this);
1564
+ this.updateDispose = autoUpdate(referenceElement, this.wrapperRef, this.handlePositionUpdate);
1565
+ this.handlePositionUpdate();
1566
+ }
1567
+ else {
1568
+ (_d = this.updateDispose) === null || _d === void 0 ? void 0 : _d.call(this);
1569
+ }
1570
+ }
1571
+ async handlePositionUpdate() {
1572
+ var _a, _b, _c;
1573
+ const referenceElement = (_b = (_a = this.getSlottedAnchorElement()) !== null && _a !== void 0 ? _a : this.anchorPointRef) !== null && _b !== void 0 ? _b : this.getAnchorBoundsVirtualElement();
1574
+ if (referenceElement != null && this.wrapperRef != null) {
1575
+ const position = await computeUpdatedPosition(referenceElement, this.wrapperRef, this.placement, this.middleware);
1576
+ this.computedPlacement = position.placement;
1577
+ (_c = this.wrapperRef) === null || _c === void 0 ? void 0 : _c.setAttribute('style', `left: ${position.x}px; top: ${position.y}px;`);
1578
+ }
1579
+ }
1580
+ handleMiddlewareChange() {
1581
+ var _a, _b, _c;
1582
+ const anchorSlotElement = (_a = this.getSlottedAnchorElement()) !== null && _a !== void 0 ? _a : this.getAnchorBoundsVirtualElement();
1583
+ const offset = anchorSlotElement != null ? 4 : 0;
1584
+ const boundary = this.boundarySelector != null
1585
+ ? (_b = document.querySelector(this.boundarySelector)) !== null && _b !== void 0 ? _b : undefined
1586
+ : undefined;
1587
+ this.middleware = getDefaultMiddleware((_c = this.offsetBehavior) !== null && _c !== void 0 ? _c : offset, boundary != null
1588
+ ? Object.assign({ boundary }, this.overflowBehavior) : this.overflowBehavior, this.flipBehavior);
1589
+ this.updateListener();
1590
+ }
1591
+ getSlottedAnchorElement() {
1592
+ var _a, _b, _c;
1593
+ if (this.anchorSelector != null) {
1594
+ return (((_a = this.hostElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(this.anchorSelector)) ||
1595
+ this.hostElement.querySelector(this.anchorSelector) ||
1596
+ undefined);
1597
+ }
1598
+ else {
1599
+ const anchorSlot = ((_b = this.hostElement.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('slot[name="anchor"]')) ||
1600
+ undefined;
1601
+ if (((_c = anchorSlot === null || anchorSlot === void 0 ? void 0 : anchorSlot.assignedElements) === null || _c === void 0 ? void 0 : _c.call(anchorSlot).length) || 0 > 0) {
1602
+ return anchorSlot === null || anchorSlot === void 0 ? void 0 : anchorSlot.assignedElements()[0];
1603
+ }
1604
+ }
1605
+ }
1606
+ getAnchorBoundsVirtualElement() {
1607
+ if (this.anchorBounds != null) {
1608
+ return {
1609
+ getBoundingClientRect: () => {
1610
+ return DOMRect.fromRect(this.anchorBounds);
1611
+ },
1612
+ };
1613
+ }
1614
+ }
1615
+ handleResize() {
1616
+ if (this.resizeTimeout != null) {
1617
+ clearTimeout(this.resizeTimeout);
1618
+ }
1619
+ if (this.open) {
1620
+ this.resizeTimeout = setTimeout(() => {
1621
+ this.resizeTimeout = undefined;
1622
+ if (this.anchorPosition != null &&
1623
+ this.viewportWidth != null &&
1624
+ this.viewportHeight != null) {
1625
+ const relativeWidth = this.anchorPosition.x / this.viewportWidth;
1626
+ const relativeHeight = this.anchorPosition.y / this.viewportHeight;
1627
+ this.position = {
1628
+ x: this.partialWindow.innerWidth * relativeWidth,
1629
+ y: this.partialWindow.innerHeight * relativeHeight,
1630
+ };
1631
+ }
1632
+ this.updateViewport();
1633
+ }, WINDOW_RESIZE_DEBOUNCE_THRESHOLD);
1634
+ }
1635
+ }
1636
+ updateViewport() {
1637
+ this.viewportWidth = this.partialWindow.innerWidth;
1638
+ this.viewportHeight = this.partialWindow.innerHeight;
1639
+ }
1640
+ getTransformClass() {
1641
+ if (this.animated) {
1642
+ switch (this.computedPlacement) {
1643
+ case 'top':
1644
+ return 'center-bottom';
1645
+ case 'top-start':
1646
+ return 'left-bottom';
1647
+ case 'top-end':
1648
+ return 'right-bottom';
1649
+ case 'bottom':
1650
+ return 'center-top';
1651
+ case 'bottom-start':
1652
+ return 'left-top';
1653
+ case 'bottom-end':
1654
+ return 'right-top';
1655
+ case 'right':
1656
+ return 'left-center';
1657
+ case 'right-start':
1658
+ return 'left-top';
1659
+ case 'right-end':
1660
+ return 'left-bottom';
1661
+ case 'left':
1662
+ return 'right-center';
1663
+ case 'left-start':
1664
+ return 'right-top';
1665
+ case 'left-end':
1666
+ return 'right-bottom';
1667
+ }
1668
+ }
1669
+ }
1670
+ get hostElement() { return index.getElement(this); }
1671
+ static get watchers() { return {
1672
+ "position": ["updatePosition"],
1673
+ "placement": ["updatePlacement"],
1674
+ "open": ["updateOpened"],
1675
+ "animated": ["updateAnimated"],
1676
+ "boundarySelector": ["updateMiddleware"],
1677
+ "overflowBehavior": ["updateMiddleware"],
1678
+ "flipBehavior": ["updateMiddleware"],
1679
+ "offsetBehavior": ["updateMiddleware"]
1680
+ }; }
1681
+ };
1682
+ Popover.style = popoverCss;
1683
+
1684
+ exports.Popover = Popover;