proto-float-wc 0.1.0 → 0.1.84

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 (52) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +5 -0
  2. package/dist/cjs/index-B_zXFQfG.js +1383 -0
  3. package/dist/cjs/loader.cjs.js +5 -5
  4. package/dist/cjs/proto-float-wc.cjs.js +15 -13
  5. package/dist/cjs/proto-floater-demo.cjs.entry.js +1586 -0
  6. package/dist/collection/collection-manifest.json +3 -4
  7. package/dist/collection/components/proto-floater-demo/proto-floater-demo.css +27 -24
  8. package/dist/collection/components/proto-floater-demo/proto-floater-demo.js +134 -11
  9. package/dist/components/index.d.ts +2 -0
  10. package/dist/components/index.js +1 -1
  11. package/dist/components/proto-floater-demo.js +1 -53
  12. package/dist/esm/app-globals-DQuL1Twl.js +3 -0
  13. package/dist/esm/index-DN_GSREz.js +1377 -0
  14. package/dist/esm/loader.js +6 -4
  15. package/dist/esm/proto-float-wc.js +15 -12
  16. package/dist/esm/proto-floater-demo.entry.js +1584 -0
  17. package/dist/proto-float-wc/p-44c23264.entry.js +1 -0
  18. package/dist/proto-float-wc/p-DN_GSREz.js +2 -0
  19. package/dist/proto-float-wc/p-DQuL1Twl.js +1 -0
  20. package/dist/proto-float-wc/proto-float-wc.esm.js +1 -1
  21. package/dist/types/components/proto-floater-demo/proto-floater-demo.d.ts +20 -2
  22. package/dist/types/components.d.ts +21 -20
  23. package/dist/types/stencil-public-runtime.d.ts +199 -18
  24. package/loader/cdn.js +1 -3
  25. package/loader/index.cjs.js +1 -3
  26. package/loader/index.d.ts +3 -0
  27. package/loader/index.es2017.js +1 -3
  28. package/loader/index.js +1 -3
  29. package/package.json +24 -19
  30. package/dist/cjs/index-95c398a6.js +0 -1762
  31. package/dist/cjs/proto-floater-demo_2.cjs.entry.js +0 -146
  32. package/dist/collection/components/proto-floater-demo/proto-360.js +0 -10
  33. package/dist/collection/components/proto-player/proto-player.css +0 -60
  34. package/dist/collection/components/proto-player/proto-player.js +0 -166
  35. package/dist/collection/utils/index.js +0 -1
  36. package/dist/collection/utils/types.js +0 -1
  37. package/dist/components/proto-player.d.ts +0 -11
  38. package/dist/components/proto-player.js +0 -138
  39. package/dist/esm/index-6a814d4f.js +0 -1736
  40. package/dist/esm/polyfills/core-js.js +0 -11
  41. package/dist/esm/polyfills/dom.js +0 -79
  42. package/dist/esm/polyfills/es5-html-element.js +0 -1
  43. package/dist/esm/polyfills/index.js +0 -34
  44. package/dist/esm/polyfills/system.js +0 -6
  45. package/dist/esm/proto-floater-demo_2.entry.js +0 -141
  46. package/dist/proto-float-wc/p-5ef8cd91.js +0 -2
  47. package/dist/proto-float-wc/p-e4a96884.entry.js +0 -1
  48. package/dist/types/components/proto-floater-demo/proto-360.d.ts +0 -5
  49. package/dist/types/components/proto-player/proto-player.d.ts +0 -24
  50. package/dist/types/utils/index.d.ts +0 -1
  51. package/dist/types/utils/types.d.ts +0 -8
  52. package/loader/package.json +0 -11
@@ -0,0 +1,1584 @@
1
+ import { r as registerInstance, h } from './index-DN_GSREz.js';
2
+
3
+ /**
4
+ * Custom positioning reference element.
5
+ * @see https://floating-ui.com/docs/virtual-elements
6
+ */
7
+
8
+ const min = Math.min;
9
+ const max = Math.max;
10
+ const round = Math.round;
11
+ const createCoords = v => ({
12
+ x: v,
13
+ y: v
14
+ });
15
+ const oppositeSideMap = {
16
+ left: 'right',
17
+ right: 'left',
18
+ bottom: 'top',
19
+ top: 'bottom'
20
+ };
21
+ const oppositeAlignmentMap = {
22
+ start: 'end',
23
+ end: 'start'
24
+ };
25
+ function clamp(start, value, end) {
26
+ return max(start, min(value, end));
27
+ }
28
+ function evaluate(value, param) {
29
+ return typeof value === 'function' ? value(param) : value;
30
+ }
31
+ function getSide(placement) {
32
+ return placement.split('-')[0];
33
+ }
34
+ function getAlignment(placement) {
35
+ return placement.split('-')[1];
36
+ }
37
+ function getOppositeAxis(axis) {
38
+ return axis === 'x' ? 'y' : 'x';
39
+ }
40
+ function getAxisLength(axis) {
41
+ return axis === 'y' ? 'height' : 'width';
42
+ }
43
+ const yAxisSides = /*#__PURE__*/new Set(['top', 'bottom']);
44
+ function getSideAxis(placement) {
45
+ return yAxisSides.has(getSide(placement)) ? 'y' : 'x';
46
+ }
47
+ function getAlignmentAxis(placement) {
48
+ return getOppositeAxis(getSideAxis(placement));
49
+ }
50
+ function getAlignmentSides(placement, rects, rtl) {
51
+ if (rtl === void 0) {
52
+ rtl = false;
53
+ }
54
+ const alignment = getAlignment(placement);
55
+ const alignmentAxis = getAlignmentAxis(placement);
56
+ const length = getAxisLength(alignmentAxis);
57
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
58
+ if (rects.reference[length] > rects.floating[length]) {
59
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
60
+ }
61
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
62
+ }
63
+ function getExpandedPlacements(placement) {
64
+ const oppositePlacement = getOppositePlacement(placement);
65
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
66
+ }
67
+ function getOppositeAlignmentPlacement(placement) {
68
+ return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
69
+ }
70
+ const lrPlacement = ['left', 'right'];
71
+ const rlPlacement = ['right', 'left'];
72
+ const tbPlacement = ['top', 'bottom'];
73
+ const btPlacement = ['bottom', 'top'];
74
+ function getSideList(side, isStart, rtl) {
75
+ switch (side) {
76
+ case 'top':
77
+ case 'bottom':
78
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
79
+ return isStart ? lrPlacement : rlPlacement;
80
+ case 'left':
81
+ case 'right':
82
+ return isStart ? tbPlacement : btPlacement;
83
+ default:
84
+ return [];
85
+ }
86
+ }
87
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
88
+ const alignment = getAlignment(placement);
89
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
90
+ if (alignment) {
91
+ list = list.map(side => side + "-" + alignment);
92
+ if (flipAlignment) {
93
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
94
+ }
95
+ }
96
+ return list;
97
+ }
98
+ function getOppositePlacement(placement) {
99
+ return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
100
+ }
101
+ function expandPaddingObject(padding) {
102
+ return {
103
+ top: 0,
104
+ right: 0,
105
+ bottom: 0,
106
+ left: 0,
107
+ ...padding
108
+ };
109
+ }
110
+ function getPaddingObject(padding) {
111
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
112
+ top: padding,
113
+ right: padding,
114
+ bottom: padding,
115
+ left: padding
116
+ };
117
+ }
118
+ function rectToClientRect(rect) {
119
+ const {
120
+ x,
121
+ y,
122
+ width,
123
+ height
124
+ } = rect;
125
+ return {
126
+ width,
127
+ height,
128
+ top: y,
129
+ left: x,
130
+ right: x + width,
131
+ bottom: y + height,
132
+ x,
133
+ y
134
+ };
135
+ }
136
+
137
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
138
+ let {
139
+ reference,
140
+ floating
141
+ } = _ref;
142
+ const sideAxis = getSideAxis(placement);
143
+ const alignmentAxis = getAlignmentAxis(placement);
144
+ const alignLength = getAxisLength(alignmentAxis);
145
+ const side = getSide(placement);
146
+ const isVertical = sideAxis === 'y';
147
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
148
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
149
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
150
+ let coords;
151
+ switch (side) {
152
+ case 'top':
153
+ coords = {
154
+ x: commonX,
155
+ y: reference.y - floating.height
156
+ };
157
+ break;
158
+ case 'bottom':
159
+ coords = {
160
+ x: commonX,
161
+ y: reference.y + reference.height
162
+ };
163
+ break;
164
+ case 'right':
165
+ coords = {
166
+ x: reference.x + reference.width,
167
+ y: commonY
168
+ };
169
+ break;
170
+ case 'left':
171
+ coords = {
172
+ x: reference.x - floating.width,
173
+ y: commonY
174
+ };
175
+ break;
176
+ default:
177
+ coords = {
178
+ x: reference.x,
179
+ y: reference.y
180
+ };
181
+ }
182
+ switch (getAlignment(placement)) {
183
+ case 'start':
184
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
185
+ break;
186
+ case 'end':
187
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
188
+ break;
189
+ }
190
+ return coords;
191
+ }
192
+
193
+ /**
194
+ * Resolves with an object of overflow side offsets that determine how much the
195
+ * element is overflowing a given clipping boundary on each side.
196
+ * - positive = overflowing the boundary by that number of pixels
197
+ * - negative = how many pixels left before it will overflow
198
+ * - 0 = lies flush with the boundary
199
+ * @see https://floating-ui.com/docs/detectOverflow
200
+ */
201
+ async function detectOverflow(state, options) {
202
+ var _await$platform$isEle;
203
+ if (options === void 0) {
204
+ options = {};
205
+ }
206
+ const {
207
+ x,
208
+ y,
209
+ platform,
210
+ rects,
211
+ elements,
212
+ strategy
213
+ } = state;
214
+ const {
215
+ boundary = 'clippingAncestors',
216
+ rootBoundary = 'viewport',
217
+ elementContext = 'floating',
218
+ altBoundary = false,
219
+ padding = 0
220
+ } = evaluate(options, state);
221
+ const paddingObject = getPaddingObject(padding);
222
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
223
+ const element = elements[altBoundary ? altContext : elementContext];
224
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
225
+ 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))),
226
+ boundary,
227
+ rootBoundary,
228
+ strategy
229
+ }));
230
+ const rect = elementContext === 'floating' ? {
231
+ x,
232
+ y,
233
+ width: rects.floating.width,
234
+ height: rects.floating.height
235
+ } : rects.reference;
236
+ const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
237
+ const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
238
+ x: 1,
239
+ y: 1
240
+ } : {
241
+ x: 1,
242
+ y: 1
243
+ };
244
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
245
+ elements,
246
+ rect,
247
+ offsetParent,
248
+ strategy
249
+ }) : rect);
250
+ return {
251
+ top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
252
+ bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
253
+ left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
254
+ right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
255
+ };
256
+ }
257
+
258
+ /**
259
+ * Computes the `x` and `y` coordinates that will place the floating element
260
+ * next to a given reference element.
261
+ *
262
+ * This export does not have any `platform` interface logic. You will need to
263
+ * write one for the platform you are using Floating UI with.
264
+ */
265
+ const computePosition$1 = async (reference, floating, config) => {
266
+ const {
267
+ placement = 'bottom',
268
+ strategy = 'absolute',
269
+ middleware = [],
270
+ platform
271
+ } = config;
272
+ const validMiddleware = middleware.filter(Boolean);
273
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
274
+ let rects = await platform.getElementRects({
275
+ reference,
276
+ floating,
277
+ strategy
278
+ });
279
+ let {
280
+ x,
281
+ y
282
+ } = computeCoordsFromPlacement(rects, placement, rtl);
283
+ let statefulPlacement = placement;
284
+ let middlewareData = {};
285
+ let resetCount = 0;
286
+ for (let i = 0; i < validMiddleware.length; i++) {
287
+ var _platform$detectOverf;
288
+ const {
289
+ name,
290
+ fn
291
+ } = validMiddleware[i];
292
+ const {
293
+ x: nextX,
294
+ y: nextY,
295
+ data,
296
+ reset
297
+ } = await fn({
298
+ x,
299
+ y,
300
+ initialPlacement: placement,
301
+ placement: statefulPlacement,
302
+ strategy,
303
+ middlewareData,
304
+ rects,
305
+ platform: {
306
+ ...platform,
307
+ detectOverflow: (_platform$detectOverf = platform.detectOverflow) != null ? _platform$detectOverf : detectOverflow
308
+ },
309
+ elements: {
310
+ reference,
311
+ floating
312
+ }
313
+ });
314
+ x = nextX != null ? nextX : x;
315
+ y = nextY != null ? nextY : y;
316
+ middlewareData = {
317
+ ...middlewareData,
318
+ [name]: {
319
+ ...middlewareData[name],
320
+ ...data
321
+ }
322
+ };
323
+ if (reset && resetCount <= 50) {
324
+ resetCount++;
325
+ if (typeof reset === 'object') {
326
+ if (reset.placement) {
327
+ statefulPlacement = reset.placement;
328
+ }
329
+ if (reset.rects) {
330
+ rects = reset.rects === true ? await platform.getElementRects({
331
+ reference,
332
+ floating,
333
+ strategy
334
+ }) : reset.rects;
335
+ }
336
+ ({
337
+ x,
338
+ y
339
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
340
+ }
341
+ i = -1;
342
+ }
343
+ }
344
+ return {
345
+ x,
346
+ y,
347
+ placement: statefulPlacement,
348
+ strategy,
349
+ middlewareData
350
+ };
351
+ };
352
+
353
+ /**
354
+ * Provides data to position an inner element of the floating element so that it
355
+ * appears centered to the reference element.
356
+ * @see https://floating-ui.com/docs/arrow
357
+ */
358
+ const arrow$1 = options => ({
359
+ name: 'arrow',
360
+ options,
361
+ async fn(state) {
362
+ const {
363
+ x,
364
+ y,
365
+ placement,
366
+ rects,
367
+ platform,
368
+ elements,
369
+ middlewareData
370
+ } = state;
371
+ // Since `element` is required, we don't Partial<> the type.
372
+ const {
373
+ element,
374
+ padding = 0
375
+ } = evaluate(options, state) || {};
376
+ if (element == null) {
377
+ return {};
378
+ }
379
+ const paddingObject = getPaddingObject(padding);
380
+ const coords = {
381
+ x,
382
+ y
383
+ };
384
+ const axis = getAlignmentAxis(placement);
385
+ const length = getAxisLength(axis);
386
+ const arrowDimensions = await platform.getDimensions(element);
387
+ const isYAxis = axis === 'y';
388
+ const minProp = isYAxis ? 'top' : 'left';
389
+ const maxProp = isYAxis ? 'bottom' : 'right';
390
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
391
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
392
+ const startDiff = coords[axis] - rects.reference[axis];
393
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
394
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
395
+
396
+ // DOM platform can return `window` as the `offsetParent`.
397
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
398
+ clientSize = elements.floating[clientProp] || rects.floating[length];
399
+ }
400
+ const centerToReference = endDiff / 2 - startDiff / 2;
401
+
402
+ // If the padding is large enough that it causes the arrow to no longer be
403
+ // centered, modify the padding so that it is centered.
404
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
405
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
406
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
407
+
408
+ // Make sure the arrow doesn't overflow the floating element if the center
409
+ // point is outside the floating element's bounds.
410
+ const min$1 = minPadding;
411
+ const max = clientSize - arrowDimensions[length] - maxPadding;
412
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
413
+ const offset = clamp(min$1, center, max);
414
+
415
+ // If the reference is small enough that the arrow's padding causes it to
416
+ // to point to nothing for an aligned placement, adjust the offset of the
417
+ // floating element itself. To ensure `shift()` continues to take action,
418
+ // a single reset is performed when this is true.
419
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
420
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
421
+ return {
422
+ [axis]: coords[axis] + alignmentOffset,
423
+ data: {
424
+ [axis]: offset,
425
+ centerOffset: center - offset - alignmentOffset,
426
+ ...(shouldAddOffset && {
427
+ alignmentOffset
428
+ })
429
+ },
430
+ reset: shouldAddOffset
431
+ };
432
+ }
433
+ });
434
+
435
+ /**
436
+ * Optimizes the visibility of the floating element by flipping the `placement`
437
+ * in order to keep it in view when the preferred placement(s) will overflow the
438
+ * clipping boundary. Alternative to `autoPlacement`.
439
+ * @see https://floating-ui.com/docs/flip
440
+ */
441
+ const flip$1 = function (options) {
442
+ if (options === void 0) {
443
+ options = {};
444
+ }
445
+ return {
446
+ name: 'flip',
447
+ options,
448
+ async fn(state) {
449
+ var _middlewareData$arrow, _middlewareData$flip;
450
+ const {
451
+ placement,
452
+ middlewareData,
453
+ rects,
454
+ initialPlacement,
455
+ platform,
456
+ elements
457
+ } = state;
458
+ const {
459
+ mainAxis: checkMainAxis = true,
460
+ crossAxis: checkCrossAxis = true,
461
+ fallbackPlacements: specifiedFallbackPlacements,
462
+ fallbackStrategy = 'bestFit',
463
+ fallbackAxisSideDirection = 'none',
464
+ flipAlignment = true,
465
+ ...detectOverflowOptions
466
+ } = evaluate(options, state);
467
+
468
+ // If a reset by the arrow was caused due to an alignment offset being
469
+ // added, we should skip any logic now since `flip()` has already done its
470
+ // work.
471
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
472
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
473
+ return {};
474
+ }
475
+ const side = getSide(placement);
476
+ const initialSideAxis = getSideAxis(initialPlacement);
477
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
478
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
479
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
480
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
481
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
482
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
483
+ }
484
+ const placements = [initialPlacement, ...fallbackPlacements];
485
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
486
+ const overflows = [];
487
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
488
+ if (checkMainAxis) {
489
+ overflows.push(overflow[side]);
490
+ }
491
+ if (checkCrossAxis) {
492
+ const sides = getAlignmentSides(placement, rects, rtl);
493
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
494
+ }
495
+ overflowsData = [...overflowsData, {
496
+ placement,
497
+ overflows
498
+ }];
499
+
500
+ // One or more sides is overflowing.
501
+ if (!overflows.every(side => side <= 0)) {
502
+ var _middlewareData$flip2, _overflowsData$filter;
503
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
504
+ const nextPlacement = placements[nextIndex];
505
+ if (nextPlacement) {
506
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
507
+ if (!ignoreCrossAxisOverflow ||
508
+ // We leave the current main axis only if every placement on that axis
509
+ // overflows the main axis.
510
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
511
+ // Try next placement and re-run the lifecycle.
512
+ return {
513
+ data: {
514
+ index: nextIndex,
515
+ overflows: overflowsData
516
+ },
517
+ reset: {
518
+ placement: nextPlacement
519
+ }
520
+ };
521
+ }
522
+ }
523
+
524
+ // First, find the candidates that fit on the mainAxis side of overflow,
525
+ // then find the placement that fits the best on the main crossAxis side.
526
+ 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;
527
+
528
+ // Otherwise fallback.
529
+ if (!resetPlacement) {
530
+ switch (fallbackStrategy) {
531
+ case 'bestFit':
532
+ {
533
+ var _overflowsData$filter2;
534
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
535
+ if (hasFallbackAxisSideDirection) {
536
+ const currentSideAxis = getSideAxis(d.placement);
537
+ return currentSideAxis === initialSideAxis ||
538
+ // Create a bias to the `y` side axis due to horizontal
539
+ // reading directions favoring greater width.
540
+ currentSideAxis === 'y';
541
+ }
542
+ return true;
543
+ }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
544
+ if (placement) {
545
+ resetPlacement = placement;
546
+ }
547
+ break;
548
+ }
549
+ case 'initialPlacement':
550
+ resetPlacement = initialPlacement;
551
+ break;
552
+ }
553
+ }
554
+ if (placement !== resetPlacement) {
555
+ return {
556
+ reset: {
557
+ placement: resetPlacement
558
+ }
559
+ };
560
+ }
561
+ }
562
+ return {};
563
+ }
564
+ };
565
+ };
566
+
567
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
568
+
569
+ // For type backwards-compatibility, the `OffsetOptions` type was also
570
+ // Derivable.
571
+
572
+ async function convertValueToCoords(state, options) {
573
+ const {
574
+ placement,
575
+ platform,
576
+ elements
577
+ } = state;
578
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
579
+ const side = getSide(placement);
580
+ const alignment = getAlignment(placement);
581
+ const isVertical = getSideAxis(placement) === 'y';
582
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
583
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
584
+ const rawValue = evaluate(options, state);
585
+
586
+ // eslint-disable-next-line prefer-const
587
+ let {
588
+ mainAxis,
589
+ crossAxis,
590
+ alignmentAxis
591
+ } = typeof rawValue === 'number' ? {
592
+ mainAxis: rawValue,
593
+ crossAxis: 0,
594
+ alignmentAxis: null
595
+ } : {
596
+ mainAxis: rawValue.mainAxis || 0,
597
+ crossAxis: rawValue.crossAxis || 0,
598
+ alignmentAxis: rawValue.alignmentAxis
599
+ };
600
+ if (alignment && typeof alignmentAxis === 'number') {
601
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
602
+ }
603
+ return isVertical ? {
604
+ x: crossAxis * crossAxisMulti,
605
+ y: mainAxis * mainAxisMulti
606
+ } : {
607
+ x: mainAxis * mainAxisMulti,
608
+ y: crossAxis * crossAxisMulti
609
+ };
610
+ }
611
+
612
+ /**
613
+ * Modifies the placement by translating the floating element along the
614
+ * specified axes.
615
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
616
+ * object may be passed.
617
+ * @see https://floating-ui.com/docs/offset
618
+ */
619
+ const offset$1 = function (options) {
620
+ if (options === void 0) {
621
+ options = 0;
622
+ }
623
+ return {
624
+ name: 'offset',
625
+ options,
626
+ async fn(state) {
627
+ var _middlewareData$offse, _middlewareData$arrow;
628
+ const {
629
+ x,
630
+ y,
631
+ placement,
632
+ middlewareData
633
+ } = state;
634
+ const diffCoords = await convertValueToCoords(state, options);
635
+
636
+ // If the placement is the same and the arrow caused an alignment offset
637
+ // then we don't need to change the positioning coordinates.
638
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
639
+ return {};
640
+ }
641
+ return {
642
+ x: x + diffCoords.x,
643
+ y: y + diffCoords.y,
644
+ data: {
645
+ ...diffCoords,
646
+ placement
647
+ }
648
+ };
649
+ }
650
+ };
651
+ };
652
+
653
+ /**
654
+ * Optimizes the visibility of the floating element by shifting it in order to
655
+ * keep it in view when it will overflow the clipping boundary.
656
+ * @see https://floating-ui.com/docs/shift
657
+ */
658
+ const shift$1 = function (options) {
659
+ if (options === void 0) {
660
+ options = {};
661
+ }
662
+ return {
663
+ name: 'shift',
664
+ options,
665
+ async fn(state) {
666
+ const {
667
+ x,
668
+ y,
669
+ placement,
670
+ platform
671
+ } = state;
672
+ const {
673
+ mainAxis: checkMainAxis = true,
674
+ crossAxis: checkCrossAxis = false,
675
+ limiter = {
676
+ fn: _ref => {
677
+ let {
678
+ x,
679
+ y
680
+ } = _ref;
681
+ return {
682
+ x,
683
+ y
684
+ };
685
+ }
686
+ },
687
+ ...detectOverflowOptions
688
+ } = evaluate(options, state);
689
+ const coords = {
690
+ x,
691
+ y
692
+ };
693
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
694
+ const crossAxis = getSideAxis(getSide(placement));
695
+ const mainAxis = getOppositeAxis(crossAxis);
696
+ let mainAxisCoord = coords[mainAxis];
697
+ let crossAxisCoord = coords[crossAxis];
698
+ if (checkMainAxis) {
699
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
700
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
701
+ const min = mainAxisCoord + overflow[minSide];
702
+ const max = mainAxisCoord - overflow[maxSide];
703
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
704
+ }
705
+ if (checkCrossAxis) {
706
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
707
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
708
+ const min = crossAxisCoord + overflow[minSide];
709
+ const max = crossAxisCoord - overflow[maxSide];
710
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
711
+ }
712
+ const limitedCoords = limiter.fn({
713
+ ...state,
714
+ [mainAxis]: mainAxisCoord,
715
+ [crossAxis]: crossAxisCoord
716
+ });
717
+ return {
718
+ ...limitedCoords,
719
+ data: {
720
+ x: limitedCoords.x - x,
721
+ y: limitedCoords.y - y,
722
+ enabled: {
723
+ [mainAxis]: checkMainAxis,
724
+ [crossAxis]: checkCrossAxis
725
+ }
726
+ }
727
+ };
728
+ }
729
+ };
730
+ };
731
+
732
+ function hasWindow() {
733
+ return typeof window !== 'undefined';
734
+ }
735
+ function getNodeName(node) {
736
+ if (isNode(node)) {
737
+ return (node.nodeName || '').toLowerCase();
738
+ }
739
+ // Mocked nodes in testing environments may not be instances of Node. By
740
+ // returning `#document` an infinite loop won't occur.
741
+ // https://github.com/floating-ui/floating-ui/issues/2317
742
+ return '#document';
743
+ }
744
+ function getWindow(node) {
745
+ var _node$ownerDocument;
746
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
747
+ }
748
+ function getDocumentElement(node) {
749
+ var _ref;
750
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
751
+ }
752
+ function isNode(value) {
753
+ if (!hasWindow()) {
754
+ return false;
755
+ }
756
+ return value instanceof Node || value instanceof getWindow(value).Node;
757
+ }
758
+ function isElement(value) {
759
+ if (!hasWindow()) {
760
+ return false;
761
+ }
762
+ return value instanceof Element || value instanceof getWindow(value).Element;
763
+ }
764
+ function isHTMLElement(value) {
765
+ if (!hasWindow()) {
766
+ return false;
767
+ }
768
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
769
+ }
770
+ function isShadowRoot(value) {
771
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
772
+ return false;
773
+ }
774
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
775
+ }
776
+ const invalidOverflowDisplayValues = /*#__PURE__*/new Set(['inline', 'contents']);
777
+ function isOverflowElement(element) {
778
+ const {
779
+ overflow,
780
+ overflowX,
781
+ overflowY,
782
+ display
783
+ } = getComputedStyle$1(element);
784
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
785
+ }
786
+ const tableElements = /*#__PURE__*/new Set(['table', 'td', 'th']);
787
+ function isTableElement(element) {
788
+ return tableElements.has(getNodeName(element));
789
+ }
790
+ const topLayerSelectors = [':popover-open', ':modal'];
791
+ function isTopLayer(element) {
792
+ return topLayerSelectors.some(selector => {
793
+ try {
794
+ return element.matches(selector);
795
+ } catch (_e) {
796
+ return false;
797
+ }
798
+ });
799
+ }
800
+ const transformProperties = ['transform', 'translate', 'scale', 'rotate', 'perspective'];
801
+ const willChangeValues = ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'];
802
+ const containValues = ['paint', 'layout', 'strict', 'content'];
803
+ function isContainingBlock(elementOrCss) {
804
+ const webkit = isWebKit();
805
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
806
+
807
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
808
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
809
+ return transformProperties.some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || willChangeValues.some(value => (css.willChange || '').includes(value)) || containValues.some(value => (css.contain || '').includes(value));
810
+ }
811
+ function getContainingBlock(element) {
812
+ let currentNode = getParentNode(element);
813
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
814
+ if (isContainingBlock(currentNode)) {
815
+ return currentNode;
816
+ } else if (isTopLayer(currentNode)) {
817
+ return null;
818
+ }
819
+ currentNode = getParentNode(currentNode);
820
+ }
821
+ return null;
822
+ }
823
+ function isWebKit() {
824
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
825
+ return CSS.supports('-webkit-backdrop-filter', 'none');
826
+ }
827
+ const lastTraversableNodeNames = /*#__PURE__*/new Set(['html', 'body', '#document']);
828
+ function isLastTraversableNode(node) {
829
+ return lastTraversableNodeNames.has(getNodeName(node));
830
+ }
831
+ function getComputedStyle$1(element) {
832
+ return getWindow(element).getComputedStyle(element);
833
+ }
834
+ function getNodeScroll(element) {
835
+ if (isElement(element)) {
836
+ return {
837
+ scrollLeft: element.scrollLeft,
838
+ scrollTop: element.scrollTop
839
+ };
840
+ }
841
+ return {
842
+ scrollLeft: element.scrollX,
843
+ scrollTop: element.scrollY
844
+ };
845
+ }
846
+ function getParentNode(node) {
847
+ if (getNodeName(node) === 'html') {
848
+ return node;
849
+ }
850
+ const result =
851
+ // Step into the shadow DOM of the parent of a slotted node.
852
+ node.assignedSlot ||
853
+ // DOM Element detected.
854
+ node.parentNode ||
855
+ // ShadowRoot detected.
856
+ isShadowRoot(node) && node.host ||
857
+ // Fallback.
858
+ getDocumentElement(node);
859
+ return isShadowRoot(result) ? result.host : result;
860
+ }
861
+ function getNearestOverflowAncestor(node) {
862
+ const parentNode = getParentNode(node);
863
+ if (isLastTraversableNode(parentNode)) {
864
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
865
+ }
866
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
867
+ return parentNode;
868
+ }
869
+ return getNearestOverflowAncestor(parentNode);
870
+ }
871
+ function getOverflowAncestors(node, list, traverseIframes) {
872
+ var _node$ownerDocument2;
873
+ if (list === void 0) {
874
+ list = [];
875
+ }
876
+ const scrollableAncestor = getNearestOverflowAncestor(node);
877
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
878
+ const win = getWindow(scrollableAncestor);
879
+ if (isBody) {
880
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], []);
881
+ }
882
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, []));
883
+ }
884
+ function getFrameElement(win) {
885
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
886
+ }
887
+
888
+ function getCssDimensions(element) {
889
+ const css = getComputedStyle$1(element);
890
+ // In testing environments, the `width` and `height` properties are empty
891
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
892
+ let width = parseFloat(css.width) || 0;
893
+ let height = parseFloat(css.height) || 0;
894
+ const hasOffset = isHTMLElement(element);
895
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
896
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
897
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
898
+ if (shouldFallback) {
899
+ width = offsetWidth;
900
+ height = offsetHeight;
901
+ }
902
+ return {
903
+ width,
904
+ height,
905
+ $: shouldFallback
906
+ };
907
+ }
908
+
909
+ function unwrapElement(element) {
910
+ return !isElement(element) ? element.contextElement : element;
911
+ }
912
+
913
+ function getScale(element) {
914
+ const domElement = unwrapElement(element);
915
+ if (!isHTMLElement(domElement)) {
916
+ return createCoords(1);
917
+ }
918
+ const rect = domElement.getBoundingClientRect();
919
+ const {
920
+ width,
921
+ height,
922
+ $
923
+ } = getCssDimensions(domElement);
924
+ let x = ($ ? round(rect.width) : rect.width) / width;
925
+ let y = ($ ? round(rect.height) : rect.height) / height;
926
+
927
+ // 0, NaN, or Infinity should always fallback to 1.
928
+
929
+ if (!x || !Number.isFinite(x)) {
930
+ x = 1;
931
+ }
932
+ if (!y || !Number.isFinite(y)) {
933
+ y = 1;
934
+ }
935
+ return {
936
+ x,
937
+ y
938
+ };
939
+ }
940
+
941
+ const noOffsets = /*#__PURE__*/createCoords(0);
942
+ function getVisualOffsets(element) {
943
+ const win = getWindow(element);
944
+ if (!isWebKit() || !win.visualViewport) {
945
+ return noOffsets;
946
+ }
947
+ return {
948
+ x: win.visualViewport.offsetLeft,
949
+ y: win.visualViewport.offsetTop
950
+ };
951
+ }
952
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
953
+ if (isFixed === void 0) {
954
+ isFixed = false;
955
+ }
956
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
957
+ return false;
958
+ }
959
+ return isFixed;
960
+ }
961
+
962
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
963
+ if (includeScale === void 0) {
964
+ includeScale = false;
965
+ }
966
+ if (isFixedStrategy === void 0) {
967
+ isFixedStrategy = false;
968
+ }
969
+ const clientRect = element.getBoundingClientRect();
970
+ const domElement = unwrapElement(element);
971
+ let scale = createCoords(1);
972
+ if (includeScale) {
973
+ if (offsetParent) {
974
+ if (isElement(offsetParent)) {
975
+ scale = getScale(offsetParent);
976
+ }
977
+ } else {
978
+ scale = getScale(element);
979
+ }
980
+ }
981
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
982
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
983
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
984
+ let width = clientRect.width / scale.x;
985
+ let height = clientRect.height / scale.y;
986
+ if (domElement) {
987
+ const win = getWindow(domElement);
988
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
989
+ let currentWin = win;
990
+ let currentIFrame = getFrameElement(currentWin);
991
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
992
+ const iframeScale = getScale(currentIFrame);
993
+ const iframeRect = currentIFrame.getBoundingClientRect();
994
+ const css = getComputedStyle$1(currentIFrame);
995
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
996
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
997
+ x *= iframeScale.x;
998
+ y *= iframeScale.y;
999
+ width *= iframeScale.x;
1000
+ height *= iframeScale.y;
1001
+ x += left;
1002
+ y += top;
1003
+ currentWin = getWindow(currentIFrame);
1004
+ currentIFrame = getFrameElement(currentWin);
1005
+ }
1006
+ }
1007
+ return rectToClientRect({
1008
+ width,
1009
+ height,
1010
+ x,
1011
+ y
1012
+ });
1013
+ }
1014
+
1015
+ // If <html> has a CSS width greater than the viewport, then this will be
1016
+ // incorrect for RTL.
1017
+ function getWindowScrollBarX(element, rect) {
1018
+ const leftScroll = getNodeScroll(element).scrollLeft;
1019
+ if (!rect) {
1020
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
1021
+ }
1022
+ return rect.left + leftScroll;
1023
+ }
1024
+
1025
+ function getHTMLOffset(documentElement, scroll) {
1026
+ const htmlRect = documentElement.getBoundingClientRect();
1027
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
1028
+ const y = htmlRect.top + scroll.scrollTop;
1029
+ return {
1030
+ x,
1031
+ y
1032
+ };
1033
+ }
1034
+
1035
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1036
+ let {
1037
+ elements,
1038
+ rect,
1039
+ offsetParent,
1040
+ strategy
1041
+ } = _ref;
1042
+ const isFixed = strategy === 'fixed';
1043
+ const documentElement = getDocumentElement(offsetParent);
1044
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
1045
+ if (offsetParent === documentElement || topLayer && isFixed) {
1046
+ return rect;
1047
+ }
1048
+ let scroll = {
1049
+ scrollLeft: 0,
1050
+ scrollTop: 0
1051
+ };
1052
+ let scale = createCoords(1);
1053
+ const offsets = createCoords(0);
1054
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1055
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1056
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1057
+ scroll = getNodeScroll(offsetParent);
1058
+ }
1059
+ if (isHTMLElement(offsetParent)) {
1060
+ const offsetRect = getBoundingClientRect(offsetParent);
1061
+ scale = getScale(offsetParent);
1062
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1063
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1064
+ }
1065
+ }
1066
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1067
+ return {
1068
+ width: rect.width * scale.x,
1069
+ height: rect.height * scale.y,
1070
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
1071
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
1072
+ };
1073
+ }
1074
+
1075
+ function getClientRects(element) {
1076
+ return Array.from(element.getClientRects());
1077
+ }
1078
+
1079
+ // Gets the entire size of the scrollable document area, even extending outside
1080
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1081
+ function getDocumentRect(element) {
1082
+ const html = getDocumentElement(element);
1083
+ const scroll = getNodeScroll(element);
1084
+ const body = element.ownerDocument.body;
1085
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1086
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1087
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1088
+ const y = -scroll.scrollTop;
1089
+ if (getComputedStyle$1(body).direction === 'rtl') {
1090
+ x += max(html.clientWidth, body.clientWidth) - width;
1091
+ }
1092
+ return {
1093
+ width,
1094
+ height,
1095
+ x,
1096
+ y
1097
+ };
1098
+ }
1099
+
1100
+ // Safety check: ensure the scrollbar space is reasonable in case this
1101
+ // calculation is affected by unusual styles.
1102
+ // Most scrollbars leave 15-18px of space.
1103
+ const SCROLLBAR_MAX = 25;
1104
+ function getViewportRect(element, strategy) {
1105
+ const win = getWindow(element);
1106
+ const html = getDocumentElement(element);
1107
+ const visualViewport = win.visualViewport;
1108
+ let width = html.clientWidth;
1109
+ let height = html.clientHeight;
1110
+ let x = 0;
1111
+ let y = 0;
1112
+ if (visualViewport) {
1113
+ width = visualViewport.width;
1114
+ height = visualViewport.height;
1115
+ const visualViewportBased = isWebKit();
1116
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1117
+ x = visualViewport.offsetLeft;
1118
+ y = visualViewport.offsetTop;
1119
+ }
1120
+ }
1121
+ const windowScrollbarX = getWindowScrollBarX(html);
1122
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1123
+ // visual width of the <html> but this is not considered in the size
1124
+ // of `html.clientWidth`.
1125
+ if (windowScrollbarX <= 0) {
1126
+ const doc = html.ownerDocument;
1127
+ const body = doc.body;
1128
+ const bodyStyles = getComputedStyle(body);
1129
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1130
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1131
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1132
+ width -= clippingStableScrollbarWidth;
1133
+ }
1134
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1135
+ // If the <body> scrollbar is on the left, the width needs to be extended
1136
+ // by the scrollbar amount so there isn't extra space on the right.
1137
+ width += windowScrollbarX;
1138
+ }
1139
+ return {
1140
+ width,
1141
+ height,
1142
+ x,
1143
+ y
1144
+ };
1145
+ }
1146
+
1147
+ const absoluteOrFixed = /*#__PURE__*/new Set(['absolute', 'fixed']);
1148
+ // Returns the inner client rect, subtracting scrollbars if present.
1149
+ function getInnerBoundingClientRect(element, strategy) {
1150
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1151
+ const top = clientRect.top + element.clientTop;
1152
+ const left = clientRect.left + element.clientLeft;
1153
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1154
+ const width = element.clientWidth * scale.x;
1155
+ const height = element.clientHeight * scale.y;
1156
+ const x = left * scale.x;
1157
+ const y = top * scale.y;
1158
+ return {
1159
+ width,
1160
+ height,
1161
+ x,
1162
+ y
1163
+ };
1164
+ }
1165
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1166
+ let rect;
1167
+ if (clippingAncestor === 'viewport') {
1168
+ rect = getViewportRect(element, strategy);
1169
+ } else if (clippingAncestor === 'document') {
1170
+ rect = getDocumentRect(getDocumentElement(element));
1171
+ } else if (isElement(clippingAncestor)) {
1172
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1173
+ } else {
1174
+ const visualOffsets = getVisualOffsets(element);
1175
+ rect = {
1176
+ x: clippingAncestor.x - visualOffsets.x,
1177
+ y: clippingAncestor.y - visualOffsets.y,
1178
+ width: clippingAncestor.width,
1179
+ height: clippingAncestor.height
1180
+ };
1181
+ }
1182
+ return rectToClientRect(rect);
1183
+ }
1184
+ function hasFixedPositionAncestor(element, stopNode) {
1185
+ const parentNode = getParentNode(element);
1186
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1187
+ return false;
1188
+ }
1189
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1190
+ }
1191
+
1192
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1193
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1194
+ // of the given element up the tree.
1195
+ function getClippingElementAncestors(element, cache) {
1196
+ const cachedResult = cache.get(element);
1197
+ if (cachedResult) {
1198
+ return cachedResult;
1199
+ }
1200
+ let result = getOverflowAncestors(element, []).filter(el => isElement(el) && getNodeName(el) !== 'body');
1201
+ let currentContainingBlockComputedStyle = null;
1202
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1203
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1204
+
1205
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1206
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1207
+ const computedStyle = getComputedStyle$1(currentNode);
1208
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1209
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1210
+ currentContainingBlockComputedStyle = null;
1211
+ }
1212
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1213
+ if (shouldDropCurrentNode) {
1214
+ // Drop non-containing blocks.
1215
+ result = result.filter(ancestor => ancestor !== currentNode);
1216
+ } else {
1217
+ // Record last containing block for next iteration.
1218
+ currentContainingBlockComputedStyle = computedStyle;
1219
+ }
1220
+ currentNode = getParentNode(currentNode);
1221
+ }
1222
+ cache.set(element, result);
1223
+ return result;
1224
+ }
1225
+
1226
+ // Gets the maximum area that the element is visible in due to any number of
1227
+ // clipping ancestors.
1228
+ function getClippingRect(_ref) {
1229
+ let {
1230
+ element,
1231
+ boundary,
1232
+ rootBoundary,
1233
+ strategy
1234
+ } = _ref;
1235
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1236
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1237
+ const firstClippingAncestor = clippingAncestors[0];
1238
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1239
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1240
+ accRect.top = max(rect.top, accRect.top);
1241
+ accRect.right = min(rect.right, accRect.right);
1242
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1243
+ accRect.left = max(rect.left, accRect.left);
1244
+ return accRect;
1245
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1246
+ return {
1247
+ width: clippingRect.right - clippingRect.left,
1248
+ height: clippingRect.bottom - clippingRect.top,
1249
+ x: clippingRect.left,
1250
+ y: clippingRect.top
1251
+ };
1252
+ }
1253
+
1254
+ function getDimensions(element) {
1255
+ const {
1256
+ width,
1257
+ height
1258
+ } = getCssDimensions(element);
1259
+ return {
1260
+ width,
1261
+ height
1262
+ };
1263
+ }
1264
+
1265
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1266
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1267
+ const documentElement = getDocumentElement(offsetParent);
1268
+ const isFixed = strategy === 'fixed';
1269
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1270
+ let scroll = {
1271
+ scrollLeft: 0,
1272
+ scrollTop: 0
1273
+ };
1274
+ const offsets = createCoords(0);
1275
+
1276
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1277
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1278
+ function setLeftRTLScrollbarOffset() {
1279
+ offsets.x = getWindowScrollBarX(documentElement);
1280
+ }
1281
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1282
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1283
+ scroll = getNodeScroll(offsetParent);
1284
+ }
1285
+ if (isOffsetParentAnElement) {
1286
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1287
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1288
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1289
+ } else if (documentElement) {
1290
+ setLeftRTLScrollbarOffset();
1291
+ }
1292
+ }
1293
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1294
+ setLeftRTLScrollbarOffset();
1295
+ }
1296
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1297
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1298
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1299
+ return {
1300
+ x,
1301
+ y,
1302
+ width: rect.width,
1303
+ height: rect.height
1304
+ };
1305
+ }
1306
+
1307
+ function isStaticPositioned(element) {
1308
+ return getComputedStyle$1(element).position === 'static';
1309
+ }
1310
+
1311
+ function getTrueOffsetParent(element, polyfill) {
1312
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1313
+ return null;
1314
+ }
1315
+ if (polyfill) {
1316
+ return polyfill(element);
1317
+ }
1318
+ let rawOffsetParent = element.offsetParent;
1319
+
1320
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1321
+ // while Chrome and Safari return the <body> element. The <body> element must
1322
+ // be used to perform the correct calculations even if the <html> element is
1323
+ // non-static.
1324
+ if (getDocumentElement(element) === rawOffsetParent) {
1325
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1326
+ }
1327
+ return rawOffsetParent;
1328
+ }
1329
+
1330
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1331
+ // such as table ancestors and cross browser bugs.
1332
+ function getOffsetParent(element, polyfill) {
1333
+ const win = getWindow(element);
1334
+ if (isTopLayer(element)) {
1335
+ return win;
1336
+ }
1337
+ if (!isHTMLElement(element)) {
1338
+ let svgOffsetParent = getParentNode(element);
1339
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1340
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1341
+ return svgOffsetParent;
1342
+ }
1343
+ svgOffsetParent = getParentNode(svgOffsetParent);
1344
+ }
1345
+ return win;
1346
+ }
1347
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1348
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1349
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1350
+ }
1351
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1352
+ return win;
1353
+ }
1354
+ return offsetParent || getContainingBlock(element) || win;
1355
+ }
1356
+
1357
+ const getElementRects = async function (data) {
1358
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1359
+ const getDimensionsFn = this.getDimensions;
1360
+ const floatingDimensions = await getDimensionsFn(data.floating);
1361
+ return {
1362
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1363
+ floating: {
1364
+ x: 0,
1365
+ y: 0,
1366
+ width: floatingDimensions.width,
1367
+ height: floatingDimensions.height
1368
+ }
1369
+ };
1370
+ };
1371
+
1372
+ function isRTL(element) {
1373
+ return getComputedStyle$1(element).direction === 'rtl';
1374
+ }
1375
+
1376
+ const platform = {
1377
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1378
+ getDocumentElement,
1379
+ getClippingRect,
1380
+ getOffsetParent,
1381
+ getElementRects,
1382
+ getClientRects,
1383
+ getDimensions,
1384
+ getScale,
1385
+ isElement,
1386
+ isRTL
1387
+ };
1388
+
1389
+ /**
1390
+ * Modifies the placement by translating the floating element along the
1391
+ * specified axes.
1392
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1393
+ * object may be passed.
1394
+ * @see https://floating-ui.com/docs/offset
1395
+ */
1396
+ const offset = offset$1;
1397
+
1398
+ /**
1399
+ * Optimizes the visibility of the floating element by shifting it in order to
1400
+ * keep it in view when it will overflow the clipping boundary.
1401
+ * @see https://floating-ui.com/docs/shift
1402
+ */
1403
+ const shift = shift$1;
1404
+
1405
+ /**
1406
+ * Optimizes the visibility of the floating element by flipping the `placement`
1407
+ * in order to keep it in view when the preferred placement(s) will overflow the
1408
+ * clipping boundary. Alternative to `autoPlacement`.
1409
+ * @see https://floating-ui.com/docs/flip
1410
+ */
1411
+ const flip = flip$1;
1412
+
1413
+ /**
1414
+ * Provides data to position an inner element of the floating element so that it
1415
+ * appears centered to the reference element.
1416
+ * @see https://floating-ui.com/docs/arrow
1417
+ */
1418
+ const arrow = arrow$1;
1419
+
1420
+ /**
1421
+ * Computes the `x` and `y` coordinates that will place the floating element
1422
+ * next to a given reference element.
1423
+ */
1424
+ const computePosition = (reference, floating, options) => {
1425
+ // This caches the expensive `getClippingElementAncestors` function so that
1426
+ // multiple lifecycle resets re-use the same result. It only lives for a
1427
+ // single call. If other functions become expensive, we can add them as well.
1428
+ const cache = new Map();
1429
+ const mergedOptions = {
1430
+ platform,
1431
+ ...options
1432
+ };
1433
+ const platformWithCache = {
1434
+ ...mergedOptions.platform,
1435
+ _c: cache
1436
+ };
1437
+ return computePosition$1(reference, floating, {
1438
+ ...mergedOptions,
1439
+ platform: platformWithCache
1440
+ });
1441
+ };
1442
+
1443
+ const urlAlphabet =
1444
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
1445
+
1446
+ /* @ts-self-types="./index.d.ts" */
1447
+ let nanoid = (size = 21) => {
1448
+ let id = '';
1449
+ let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)));
1450
+ while (size--) {
1451
+ id += urlAlphabet[bytes[size] & 63];
1452
+ }
1453
+ return id
1454
+ };
1455
+
1456
+ const protoFloaterDemoCss = () => `#root{--clrs-navy:#001f3f;--clrs-blue:#0074d9;--clrs-aqua:#7fdbff;--clrs-teal:#39cccc;--clrs-olive:#3d9970;--clrs-green:#2ecc40;--clrs-lime:#01ff70;--clrs-yellow:#ffdc00;--clrs-orange:#ff851b;--clrs-red:#ff4136;--clrs-maroon:#85144b;--clrs-fuchsia:#f012be;--clrs-purple:#b10dc9;--clrs-black:#111111;--clrs-gray:#aaaaaa;--clrs-silver:#dddddd;--clrs-bada55:#bada55;--clrs-slate:#708090;--clrs-slate4:#4e5964;--clrs-white:#ffffff}#target{width:24px;height:24px;line-height:24px;text-align:center;border-radius:12px;background:var(--clrs-blue);font-weight:bold;font-size:120%;color:var(--clrs-white);cursor:pointer}#tooltip{display:none;position:absolute;min-height:18px;background:var(--clrs-navy);color:var(--clrs-white);font-weight:bold;padding:5px;padding-right:10px;padding-left:10px;border-radius:4px;font-size:90%;pointer-events:none}#arrow{position:absolute;background:var(--clrs-navy);width:8px;height:8px;transform:rotate(45deg)}#content{display:none;border:none}`;
1457
+
1458
+ const CHECK = 'Checking...';
1459
+ const FAILED = 'Content Failed to Load...';
1460
+ const ProtoFloaterDemo = class {
1461
+ constructor(hostRef) {
1462
+ registerInstance(this, hostRef);
1463
+ this.vin = undefined;
1464
+ this.snapshot = undefined;
1465
+ this.label = CHECK;
1466
+ this.failed = true;
1467
+ this.loaded = false;
1468
+ this.time = undefined;
1469
+ this.eventBus = window['eventBus'];
1470
+ this.message = undefined;
1471
+ this.nanoId = nanoid();
1472
+ this.messageHandler = event => {
1473
+ const { origin, data } = event;
1474
+ const { targetId } = data;
1475
+ console.log('-- messageHandler:', data, origin);
1476
+ if (origin !== 'http://localhost:3000')
1477
+ return;
1478
+ if (targetId !== this.nanoId)
1479
+ return;
1480
+ if (this.message === undefined) {
1481
+ if (data.type && data.type === 'resize-iframe') {
1482
+ this.iframe.style.width = data.payload.width + 'px';
1483
+ this.iframe.style.height = data.payload.height + 'px';
1484
+ this.iframe.style.display = 'block';
1485
+ this.loaded = true;
1486
+ this.label = '';
1487
+ this.message = data;
1488
+ const { vin, snapshot } = this;
1489
+ const payload = {
1490
+ targetId: this.nanoId,
1491
+ type: 'data-payload',
1492
+ payload: { vin, snapshot },
1493
+ };
1494
+ if (this.iframe) {
1495
+ this.iframe.contentWindow.postMessage(payload, '*');
1496
+ }
1497
+ this.update();
1498
+ }
1499
+ }
1500
+ else {
1501
+ this.hideTooltip();
1502
+ }
1503
+ };
1504
+ this.register = () => {
1505
+ this.eventBus.emit('activate', this.nanoId);
1506
+ window.addEventListener('message', this.messageHandler, false);
1507
+ };
1508
+ this.unregister = () => {
1509
+ window.removeEventListener('message', this.messageHandler);
1510
+ };
1511
+ this.update = () => {
1512
+ const { target, tooltip, arrowEl } = this;
1513
+ computePosition(target, tooltip, {
1514
+ placement: 'right',
1515
+ middleware: [offset(6), flip(), shift({ padding: 5 }), arrow({ element: arrowEl })],
1516
+ }).then(({ x, y, placement, middlewareData }) => {
1517
+ Object.assign(tooltip.style, {
1518
+ left: `${x}px`,
1519
+ top: `${y}px`,
1520
+ });
1521
+ // Accessing the data
1522
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
1523
+ const staticSide = {
1524
+ top: 'bottom',
1525
+ right: 'left',
1526
+ bottom: 'top',
1527
+ left: 'right',
1528
+ }[placement.split('-')[0]];
1529
+ Object.assign(arrowEl.style, {
1530
+ left: arrowX != null ? `${arrowX}px` : '',
1531
+ top: arrowY != null ? `${arrowY}px` : '',
1532
+ right: '',
1533
+ bottom: '',
1534
+ [staticSide]: '-4px',
1535
+ });
1536
+ });
1537
+ };
1538
+ this.onIframeLoad = _event => {
1539
+ this.update();
1540
+ setTimeout(() => {
1541
+ if (!this.loaded) {
1542
+ this.label = FAILED;
1543
+ }
1544
+ }, 3000);
1545
+ };
1546
+ this.hideTooltip = () => {
1547
+ this.iframe.style.display = '';
1548
+ this.tooltip.style.display = '';
1549
+ this.message = undefined;
1550
+ this.unregister();
1551
+ };
1552
+ this.showTooltip = () => {
1553
+ this.register();
1554
+ this.loaded = false;
1555
+ this.label = CHECK;
1556
+ this.loaded = false;
1557
+ this.time = Date.now();
1558
+ this.tooltip.style.display = 'block';
1559
+ this.update();
1560
+ };
1561
+ this.clickHandler = () => {
1562
+ const visible = this.tooltip.style.display === 'block';
1563
+ visible ? this.hideTooltip() : this.showTooltip();
1564
+ };
1565
+ }
1566
+ componentDidLoad() {
1567
+ this.eventBus.on('activate', nanoId => {
1568
+ if (this.nanoId !== nanoId) {
1569
+ const visible = this.tooltip.style.display === 'block';
1570
+ if (this.message !== undefined || visible) {
1571
+ this.hideTooltip();
1572
+ }
1573
+ }
1574
+ });
1575
+ this.update();
1576
+ }
1577
+ render() {
1578
+ const url = `http://localhost:3000/demo_iframe.html?q=${this.time}&nid=${this.nanoId}`;
1579
+ return (h("div", { key: '1da684903d9253b204641b4184bc5e1f79326405', id: "root" }, h("div", { key: '84665f15de5991870ad2a16f42f1984789f4631f', id: "target", ref: el => (this.target = el), onClick: () => this.clickHandler() }, "i"), h("div", { key: '178c42dc946b455c8873e06d481a93d095a2e752', id: "tooltip", role: "tooltip", ref: el => (this.tooltip = el) }, h("div", { key: '75921e81ce12a64df3500d1492b6d782ff2881e3' }, this.label), this.time ? (h("iframe", { id: "content", src: url, ref: el => (this.iframe = el), onLoad: ev => this.onIframeLoad(ev) })) : (''), h("div", { key: '99722c505d254559b6a89a3d173c0925b12e53be', id: "arrow", ref: el => (this.arrowEl = el) }))));
1580
+ }
1581
+ };
1582
+ ProtoFloaterDemo.style = protoFloaterDemoCss();
1583
+
1584
+ export { ProtoFloaterDemo as proto_floater_demo };