@lmvz-ds/components 0.33.0 → 0.35.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 (174) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/cjs/async.util-BQ60l-WC.js +20 -0
  3. package/cjs/{ds.constants-CKeXfK-s.js → ds.constants-C6eKRAEu.js} +5 -1
  4. package/cjs/{element.util-Cq4y-_iX.js → element.util-Dbyc8yUG.js} +35 -0
  5. package/cjs/index.cjs.js +3 -1
  6. package/cjs/{list-keyboard-controller-StN6Yn8W.js → list-keyboard-controller-Dm5S_l0D.js} +1 -1
  7. package/cjs/lmvz-action-list.cjs.entry.js +11 -4
  8. package/cjs/lmvz-button-group.cjs.entry.js +3 -3
  9. package/cjs/lmvz-button_2.cjs.entry.js +3 -3
  10. package/cjs/lmvz-card.cjs.entry.js +1 -1
  11. package/cjs/lmvz-checkbox.cjs.entry.js +1 -1
  12. package/cjs/lmvz-chip.cjs.entry.js +2 -2
  13. package/cjs/lmvz-components.cjs.js +1 -1
  14. package/cjs/lmvz-header_2.cjs.entry.js +3 -3
  15. package/cjs/lmvz-input.cjs.entry.js +3 -2
  16. package/cjs/lmvz-link.cjs.entry.js +2 -2
  17. package/cjs/lmvz-menuitem.cjs.entry.js +1 -1
  18. package/cjs/lmvz-message.cjs.entry.js +1 -1
  19. package/cjs/lmvz-modal.cjs.entry.js +2 -2
  20. package/cjs/lmvz-popover.cjs.entry.js +1570 -0
  21. package/cjs/lmvz-radio.cjs.entry.js +2 -2
  22. package/cjs/lmvz-select.cjs.entry.js +2 -2
  23. package/cjs/lmvz-snackbar.cjs.entry.js +2 -2
  24. package/cjs/lmvz-spinner.cjs.entry.js +1 -1
  25. package/cjs/lmvz-tab.cjs.entry.js +2 -2
  26. package/cjs/lmvz-tabs.cjs.entry.js +4 -4
  27. package/cjs/lmvz-toggle.cjs.entry.js +4 -3
  28. package/cjs/loader.cjs.js +1 -1
  29. package/cjs/{stencil.util-DzvzXSwk.js → stencil.util-DxdYjVoH.js} +2 -10
  30. package/collection/api/ds.constants.js +3 -1
  31. package/collection/collection-manifest.json +1 -0
  32. package/collection/components/lmvz-action-list/lmvz-action-list.css +151 -39
  33. package/collection/components/lmvz-action-list/lmvz-action-list.js +9 -1
  34. package/collection/components/lmvz-button/lmvz-button.css +15 -19
  35. package/collection/components/lmvz-button/lmvz-button.js +1 -1
  36. package/collection/components/lmvz-button-group/lmvz-button-group.css +1 -2
  37. package/collection/components/lmvz-card/lmvz-card.css +20 -23
  38. package/collection/components/lmvz-checkbox/lmvz-checkbox.css +9 -12
  39. package/collection/components/lmvz-chip/lmvz-chip.css +20 -20
  40. package/collection/components/lmvz-header/lmvz-header.css +3 -3
  41. package/collection/components/lmvz-icon/lmvz-icon.css +1 -1
  42. package/collection/components/lmvz-input/lmvz-input.css +3 -3
  43. package/collection/components/lmvz-link/lmvz-link.css +6 -4
  44. package/collection/components/lmvz-menuitem/lmvz-menuitem.css +1 -2
  45. package/collection/components/lmvz-message/lmvz-message.css +5 -5
  46. package/collection/components/lmvz-modal/lmvz-modal.css +6 -7
  47. package/collection/components/lmvz-popover/lmvz-popover.css +46 -0
  48. package/collection/components/lmvz-popover/lmvz-popover.js +470 -0
  49. package/collection/components/lmvz-radio/lmvz-radio.css +10 -12
  50. package/collection/components/lmvz-radio/lmvz-radio.js +1 -1
  51. package/collection/components/lmvz-select/lmvz-select.css +5 -5
  52. package/collection/components/lmvz-select/lmvz-select.js +1 -1
  53. package/collection/components/lmvz-snackbar/lmvz-snackbar.css +13 -13
  54. package/collection/components/lmvz-snackbar/lmvz-snackbar.js +1 -1
  55. package/collection/components/lmvz-spinner/lmvz-spinner.js +1 -1
  56. package/collection/components/lmvz-tab/lmvz-tab.css +9 -9
  57. package/collection/components/lmvz-tab/lmvz-tab.js +1 -1
  58. package/collection/components/lmvz-tabs/lmvz-tabs.css +2 -2
  59. package/collection/components/lmvz-tabs/lmvz-tabs.js +1 -1
  60. package/collection/components/lmvz-toggle/lmvz-toggle.css +4 -5
  61. package/collection/components/lmvz-toggle/lmvz-toggle.js +1 -1
  62. package/collection/integration/header-integration/header-integration.js +1 -1
  63. package/collection/utils/async/async.util.js +6 -0
  64. package/collection/utils/element/element.util.js +33 -0
  65. package/components/index.d.ts +2 -0
  66. package/components/index.d.ts.bak +2 -0
  67. package/components/index.js +1 -1
  68. package/components/lmvz-action-list.js +1 -1
  69. package/components/lmvz-button-group.js +1 -1
  70. package/components/lmvz-button.js +1 -1
  71. package/components/lmvz-card.js +1 -1
  72. package/components/lmvz-checkbox.js +1 -1
  73. package/components/lmvz-chip.js +1 -1
  74. package/components/lmvz-header.js +1 -1
  75. package/components/lmvz-icon.js +1 -1
  76. package/components/lmvz-input.js +1 -1
  77. package/components/lmvz-link.js +1 -1
  78. package/components/lmvz-menuitem.js +1 -1
  79. package/components/lmvz-message.js +1 -1
  80. package/components/lmvz-modal.js +1 -1
  81. package/components/lmvz-popover.d.ts +11 -0
  82. package/components/lmvz-popover.d.ts.bak +11 -0
  83. package/components/lmvz-popover.js +1 -0
  84. package/components/lmvz-radio.js +1 -1
  85. package/components/lmvz-select.js +1 -1
  86. package/components/lmvz-snackbar.js +1 -1
  87. package/components/lmvz-spinner.js +1 -1
  88. package/components/lmvz-tab.js +1 -1
  89. package/components/lmvz-tabs.js +1 -1
  90. package/components/lmvz-toggle.js +1 -1
  91. package/components/p-0ctLESas.js +1 -0
  92. package/components/p-BhSTYZC6.js +1 -0
  93. package/components/{p-CxfT9IA1.js → p-CK3Ixl1K.js} +1 -1
  94. package/components/{p-B4m1n4et.js → p-D-2gj6LP.js} +1 -1
  95. package/components/{p-Rf10bzJY.js → p-D7S1WiEC.js} +1 -1
  96. package/components/p-D9nUtvTm.js +1 -0
  97. package/components/{p-De-xQqdU.js → p-DbIm98qX.js} +1 -1
  98. package/components/p-JtkmlmeY.js +1 -0
  99. package/esm/async.util-D9nUtvTm.js +17 -0
  100. package/esm/{ds.constants-DuEtnKRj.js → ds.constants-0ctLESas.js} +4 -2
  101. package/esm/{element.util-CxfT9IA1.js → element.util-B0eCxdyI.js} +34 -1
  102. package/esm/index.js +1 -1
  103. package/esm/{list-keyboard-controller-BKa9Kd2t.js → list-keyboard-controller-tle6IRkv.js} +1 -1
  104. package/esm/lmvz-action-list.entry.js +11 -4
  105. package/esm/lmvz-button-group.entry.js +3 -3
  106. package/esm/lmvz-button_2.entry.js +3 -3
  107. package/esm/lmvz-card.entry.js +1 -1
  108. package/esm/lmvz-checkbox.entry.js +1 -1
  109. package/esm/lmvz-chip.entry.js +2 -2
  110. package/esm/lmvz-components.js +1 -1
  111. package/esm/lmvz-header_2.entry.js +3 -3
  112. package/esm/lmvz-input.entry.js +3 -2
  113. package/esm/lmvz-link.entry.js +2 -2
  114. package/esm/lmvz-menuitem.entry.js +1 -1
  115. package/esm/lmvz-message.entry.js +1 -1
  116. package/esm/lmvz-modal.entry.js +2 -2
  117. package/esm/lmvz-popover.entry.js +1568 -0
  118. package/esm/lmvz-radio.entry.js +2 -2
  119. package/esm/lmvz-select.entry.js +2 -2
  120. package/esm/lmvz-snackbar.entry.js +2 -2
  121. package/esm/lmvz-spinner.entry.js +1 -1
  122. package/esm/lmvz-tab.entry.js +2 -2
  123. package/esm/lmvz-tabs.entry.js +4 -4
  124. package/esm/lmvz-toggle.entry.js +4 -3
  125. package/esm/loader.js +1 -1
  126. package/esm/{stencil.util-CJRqhXjK.js → stencil.util-wGFRYLwZ.js} +1 -9
  127. package/hydrate/index.js +1660 -33
  128. package/hydrate/index.mjs +1660 -33
  129. package/lmvz-components/index.esm.js +1 -1
  130. package/lmvz-components/lmvz-components.esm.js +1 -1
  131. package/lmvz-components/{p-47824515.entry.js → p-0c05f24b.entry.js} +1 -1
  132. package/lmvz-components/p-0ctLESas.js +1 -0
  133. package/lmvz-components/{p-8be4dbb7.entry.js → p-1d2c11ea.entry.js} +1 -1
  134. package/lmvz-components/{p-3da087f4.entry.js → p-49e98627.entry.js} +1 -1
  135. package/lmvz-components/p-4c68d21a.entry.js +1 -0
  136. package/lmvz-components/p-50063516.entry.js +1 -0
  137. package/lmvz-components/{p-24125bcf.entry.js → p-5bbbcfc0.entry.js} +1 -1
  138. package/lmvz-components/p-76be3fc9.entry.js +1 -0
  139. package/lmvz-components/{p-703b10b5.entry.js → p-854f1c72.entry.js} +1 -1
  140. package/lmvz-components/p-886e42c7.entry.js +1 -0
  141. package/lmvz-components/{p-6140866f.entry.js → p-8fb4c347.entry.js} +1 -1
  142. package/lmvz-components/p-9f8fd077.entry.js +1 -0
  143. package/lmvz-components/{p-CxfT9IA1.js → p-B0eCxdyI.js} +1 -1
  144. package/lmvz-components/p-BhSTYZC6.js +1 -0
  145. package/lmvz-components/p-D9nUtvTm.js +1 -0
  146. package/lmvz-components/{p-B4m1n4et.js → p-DuLiExhX.js} +1 -1
  147. package/lmvz-components/{p-b4aa0978.entry.js → p-a4ef8e55.entry.js} +1 -1
  148. package/lmvz-components/p-bc237ab7.entry.js +1 -0
  149. package/lmvz-components/{p-3a644b99.entry.js → p-c082390b.entry.js} +1 -1
  150. package/lmvz-components/{p-b79af711.entry.js → p-c2544495.entry.js} +1 -1
  151. package/lmvz-components/p-c494bf8f.entry.js +1 -0
  152. package/lmvz-components/{p-48a7b033.entry.js → p-c87e2281.entry.js} +1 -1
  153. package/lmvz-components/{p-00ccaea4.entry.js → p-cb75c951.entry.js} +1 -1
  154. package/lmvz-components/{p-44781f01.entry.js → p-e0432f54.entry.js} +1 -1
  155. package/lmvz-components/{p-25a78ead.entry.js → p-ecbd9e93.entry.js} +1 -1
  156. package/manifest.json +386 -3
  157. package/package.json +5 -1
  158. package/types/api/ds.constants.d.ts +3 -1
  159. package/types/api/ds.types.d.ts +7 -0
  160. package/types/components/lmvz-popover/lmvz-popover.d.ts +37 -0
  161. package/types/components.d.ts +108 -1
  162. package/types/utils/async/async.util.d.ts +3 -0
  163. package/types/utils/element/element.util.d.ts +2 -0
  164. package/components/p-Bld_XR3X.js +0 -1
  165. package/components/p-CJRqhXjK.js +0 -1
  166. package/components/p-DuEtnKRj.js +0 -1
  167. package/lmvz-components/p-4072b2fb.entry.js +0 -1
  168. package/lmvz-components/p-8c7d9eaf.entry.js +0 -1
  169. package/lmvz-components/p-92d02c56.entry.js +0 -1
  170. package/lmvz-components/p-933e6033.entry.js +0 -1
  171. package/lmvz-components/p-CJRqhXjK.js +0 -1
  172. package/lmvz-components/p-DuEtnKRj.js +0 -1
  173. package/lmvz-components/p-d9619a4f.entry.js +0 -1
  174. package/lmvz-components/p-e1758128.entry.js +0 -1
@@ -0,0 +1,1568 @@
1
+ import { r as registerInstance, c as createEvent, g as getElement, h, H as Host } from './index-BPeerEwm.js';
2
+ import { i as isAriaValidationEnabled } from './aria-loader-BfH06m7H.js';
3
+ import { w as waitFrame } from './async.util-D9nUtvTm.js';
4
+ import { g as getDeepActiveElement, w as walkShadowDOMUntil, k as isInteractiveElement, h as canReceiveFocus } from './element.util-B0eCxdyI.js';
5
+
6
+ /**
7
+ * Custom positioning reference element.
8
+ * @see https://floating-ui.com/docs/virtual-elements
9
+ */
10
+
11
+ const min = Math.min;
12
+ const max = Math.max;
13
+ const round = Math.round;
14
+ const createCoords = v => ({
15
+ x: v,
16
+ y: v
17
+ });
18
+ const oppositeSideMap = {
19
+ left: 'right',
20
+ right: 'left',
21
+ bottom: 'top',
22
+ top: 'bottom'
23
+ };
24
+ function clamp(start, value, end) {
25
+ return max(start, min(value, end));
26
+ }
27
+ function evaluate(value, param) {
28
+ return typeof value === 'function' ? value(param) : value;
29
+ }
30
+ function getSide(placement) {
31
+ return placement.split('-')[0];
32
+ }
33
+ function getAlignment(placement) {
34
+ return placement.split('-')[1];
35
+ }
36
+ function getOppositeAxis(axis) {
37
+ return axis === 'x' ? 'y' : 'x';
38
+ }
39
+ function getAxisLength(axis) {
40
+ return axis === 'y' ? 'height' : 'width';
41
+ }
42
+ function getSideAxis(placement) {
43
+ const firstChar = placement[0];
44
+ return firstChar === 't' || firstChar === 'b' ? 'y' : 'x';
45
+ }
46
+ function getAlignmentAxis(placement) {
47
+ return getOppositeAxis(getSideAxis(placement));
48
+ }
49
+ function getAlignmentSides(placement, rects, rtl) {
50
+ if (rtl === void 0) {
51
+ rtl = false;
52
+ }
53
+ const alignment = getAlignment(placement);
54
+ const alignmentAxis = getAlignmentAxis(placement);
55
+ const length = getAxisLength(alignmentAxis);
56
+ let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
57
+ if (rects.reference[length] > rects.floating[length]) {
58
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
59
+ }
60
+ return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
61
+ }
62
+ function getExpandedPlacements(placement) {
63
+ const oppositePlacement = getOppositePlacement(placement);
64
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
65
+ }
66
+ function getOppositeAlignmentPlacement(placement) {
67
+ return placement.includes('start') ? placement.replace('start', 'end') : placement.replace('end', 'start');
68
+ }
69
+ const lrPlacement = ['left', 'right'];
70
+ const rlPlacement = ['right', 'left'];
71
+ const tbPlacement = ['top', 'bottom'];
72
+ const btPlacement = ['bottom', 'top'];
73
+ function getSideList(side, isStart, rtl) {
74
+ switch (side) {
75
+ case 'top':
76
+ case 'bottom':
77
+ if (rtl) return isStart ? rlPlacement : lrPlacement;
78
+ return isStart ? lrPlacement : rlPlacement;
79
+ case 'left':
80
+ case 'right':
81
+ return isStart ? tbPlacement : btPlacement;
82
+ default:
83
+ return [];
84
+ }
85
+ }
86
+ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
87
+ const alignment = getAlignment(placement);
88
+ let list = getSideList(getSide(placement), direction === 'start', rtl);
89
+ if (alignment) {
90
+ list = list.map(side => side + "-" + alignment);
91
+ if (flipAlignment) {
92
+ list = list.concat(list.map(getOppositeAlignmentPlacement));
93
+ }
94
+ }
95
+ return list;
96
+ }
97
+ function getOppositePlacement(placement) {
98
+ const side = getSide(placement);
99
+ return oppositeSideMap[side] + placement.slice(side.length);
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
+ // Maximum number of resets that can occur before bailing to avoid infinite reset loops.
259
+ const MAX_RESET_COUNT = 50;
260
+
261
+ /**
262
+ * Computes the `x` and `y` coordinates that will place the floating element
263
+ * next to a given reference element.
264
+ *
265
+ * This export does not have any `platform` interface logic. You will need to
266
+ * write one for the platform you are using Floating UI with.
267
+ */
268
+ const computePosition$1 = async (reference, floating, config) => {
269
+ const {
270
+ placement = 'bottom',
271
+ strategy = 'absolute',
272
+ middleware = [],
273
+ platform
274
+ } = config;
275
+ const platformWithDetectOverflow = platform.detectOverflow ? platform : {
276
+ ...platform,
277
+ detectOverflow
278
+ };
279
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
280
+ let rects = await platform.getElementRects({
281
+ reference,
282
+ floating,
283
+ strategy
284
+ });
285
+ let {
286
+ x,
287
+ y
288
+ } = computeCoordsFromPlacement(rects, placement, rtl);
289
+ let statefulPlacement = placement;
290
+ let resetCount = 0;
291
+ const middlewareData = {};
292
+ for (let i = 0; i < middleware.length; i++) {
293
+ const currentMiddleware = middleware[i];
294
+ if (!currentMiddleware) {
295
+ continue;
296
+ }
297
+ const {
298
+ name,
299
+ fn
300
+ } = currentMiddleware;
301
+ const {
302
+ x: nextX,
303
+ y: nextY,
304
+ data,
305
+ reset
306
+ } = await fn({
307
+ x,
308
+ y,
309
+ initialPlacement: placement,
310
+ placement: statefulPlacement,
311
+ strategy,
312
+ middlewareData,
313
+ rects,
314
+ platform: platformWithDetectOverflow,
315
+ elements: {
316
+ reference,
317
+ floating
318
+ }
319
+ });
320
+ x = nextX != null ? nextX : x;
321
+ y = nextY != null ? nextY : y;
322
+ middlewareData[name] = {
323
+ ...middlewareData[name],
324
+ ...data
325
+ };
326
+ if (reset && resetCount < MAX_RESET_COUNT) {
327
+ resetCount++;
328
+ if (typeof reset === 'object') {
329
+ if (reset.placement) {
330
+ statefulPlacement = reset.placement;
331
+ }
332
+ if (reset.rects) {
333
+ rects = reset.rects === true ? await platform.getElementRects({
334
+ reference,
335
+ floating,
336
+ strategy
337
+ }) : reset.rects;
338
+ }
339
+ ({
340
+ x,
341
+ y
342
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
343
+ }
344
+ i = -1;
345
+ }
346
+ }
347
+ return {
348
+ x,
349
+ y,
350
+ placement: statefulPlacement,
351
+ strategy,
352
+ middlewareData
353
+ };
354
+ };
355
+
356
+ /**
357
+ * Optimizes the visibility of the floating element by flipping the `placement`
358
+ * in order to keep it in view when the preferred placement(s) will overflow the
359
+ * clipping boundary. Alternative to `autoPlacement`.
360
+ * @see https://floating-ui.com/docs/flip
361
+ */
362
+ const flip$1 = function (options) {
363
+ if (options === void 0) {
364
+ options = {};
365
+ }
366
+ return {
367
+ name: 'flip',
368
+ options,
369
+ async fn(state) {
370
+ var _middlewareData$arrow, _middlewareData$flip;
371
+ const {
372
+ placement,
373
+ middlewareData,
374
+ rects,
375
+ initialPlacement,
376
+ platform,
377
+ elements
378
+ } = state;
379
+ const {
380
+ mainAxis: checkMainAxis = true,
381
+ crossAxis: checkCrossAxis = true,
382
+ fallbackPlacements: specifiedFallbackPlacements,
383
+ fallbackStrategy = 'bestFit',
384
+ fallbackAxisSideDirection = 'none',
385
+ flipAlignment = true,
386
+ ...detectOverflowOptions
387
+ } = evaluate(options, state);
388
+
389
+ // If a reset by the arrow was caused due to an alignment offset being
390
+ // added, we should skip any logic now since `flip()` has already done its
391
+ // work.
392
+ // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
393
+ if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
394
+ return {};
395
+ }
396
+ const side = getSide(placement);
397
+ const initialSideAxis = getSideAxis(initialPlacement);
398
+ const isBasePlacement = getSide(initialPlacement) === initialPlacement;
399
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
400
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
401
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
402
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
403
+ fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
404
+ }
405
+ const placements = [initialPlacement, ...fallbackPlacements];
406
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
407
+ const overflows = [];
408
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
409
+ if (checkMainAxis) {
410
+ overflows.push(overflow[side]);
411
+ }
412
+ if (checkCrossAxis) {
413
+ const sides = getAlignmentSides(placement, rects, rtl);
414
+ overflows.push(overflow[sides[0]], overflow[sides[1]]);
415
+ }
416
+ overflowsData = [...overflowsData, {
417
+ placement,
418
+ overflows
419
+ }];
420
+
421
+ // One or more sides is overflowing.
422
+ if (!overflows.every(side => side <= 0)) {
423
+ var _middlewareData$flip2, _overflowsData$filter;
424
+ const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
425
+ const nextPlacement = placements[nextIndex];
426
+ if (nextPlacement) {
427
+ const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
428
+ if (!ignoreCrossAxisOverflow ||
429
+ // We leave the current main axis only if every placement on that axis
430
+ // overflows the main axis.
431
+ overflowsData.every(d => getSideAxis(d.placement) === initialSideAxis ? d.overflows[0] > 0 : true)) {
432
+ // Try next placement and re-run the lifecycle.
433
+ return {
434
+ data: {
435
+ index: nextIndex,
436
+ overflows: overflowsData
437
+ },
438
+ reset: {
439
+ placement: nextPlacement
440
+ }
441
+ };
442
+ }
443
+ }
444
+
445
+ // First, find the candidates that fit on the mainAxis side of overflow,
446
+ // then find the placement that fits the best on the main crossAxis side.
447
+ 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;
448
+
449
+ // Otherwise fallback.
450
+ if (!resetPlacement) {
451
+ switch (fallbackStrategy) {
452
+ case 'bestFit':
453
+ {
454
+ var _overflowsData$filter2;
455
+ const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
456
+ if (hasFallbackAxisSideDirection) {
457
+ const currentSideAxis = getSideAxis(d.placement);
458
+ return currentSideAxis === initialSideAxis ||
459
+ // Create a bias to the `y` side axis due to horizontal
460
+ // reading directions favoring greater width.
461
+ currentSideAxis === 'y';
462
+ }
463
+ return true;
464
+ }).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];
465
+ if (placement) {
466
+ resetPlacement = placement;
467
+ }
468
+ break;
469
+ }
470
+ case 'initialPlacement':
471
+ resetPlacement = initialPlacement;
472
+ break;
473
+ }
474
+ }
475
+ if (placement !== resetPlacement) {
476
+ return {
477
+ reset: {
478
+ placement: resetPlacement
479
+ }
480
+ };
481
+ }
482
+ }
483
+ return {};
484
+ }
485
+ };
486
+ };
487
+
488
+ const originSides = /*#__PURE__*/new Set(['left', 'top']);
489
+
490
+ // For type backwards-compatibility, the `OffsetOptions` type was also
491
+ // Derivable.
492
+
493
+ async function convertValueToCoords(state, options) {
494
+ const {
495
+ placement,
496
+ platform,
497
+ elements
498
+ } = state;
499
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
500
+ const side = getSide(placement);
501
+ const alignment = getAlignment(placement);
502
+ const isVertical = getSideAxis(placement) === 'y';
503
+ const mainAxisMulti = originSides.has(side) ? -1 : 1;
504
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
505
+ const rawValue = evaluate(options, state);
506
+
507
+ // eslint-disable-next-line prefer-const
508
+ let {
509
+ mainAxis,
510
+ crossAxis,
511
+ alignmentAxis
512
+ } = typeof rawValue === 'number' ? {
513
+ mainAxis: rawValue,
514
+ crossAxis: 0,
515
+ alignmentAxis: null
516
+ } : {
517
+ mainAxis: rawValue.mainAxis || 0,
518
+ crossAxis: rawValue.crossAxis || 0,
519
+ alignmentAxis: rawValue.alignmentAxis
520
+ };
521
+ if (alignment && typeof alignmentAxis === 'number') {
522
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
523
+ }
524
+ return isVertical ? {
525
+ x: crossAxis * crossAxisMulti,
526
+ y: mainAxis * mainAxisMulti
527
+ } : {
528
+ x: mainAxis * mainAxisMulti,
529
+ y: crossAxis * crossAxisMulti
530
+ };
531
+ }
532
+
533
+ /**
534
+ * Modifies the placement by translating the floating element along the
535
+ * specified axes.
536
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
537
+ * object may be passed.
538
+ * @see https://floating-ui.com/docs/offset
539
+ */
540
+ const offset$1 = function (options) {
541
+ if (options === void 0) {
542
+ options = 0;
543
+ }
544
+ return {
545
+ name: 'offset',
546
+ options,
547
+ async fn(state) {
548
+ var _middlewareData$offse, _middlewareData$arrow;
549
+ const {
550
+ x,
551
+ y,
552
+ placement,
553
+ middlewareData
554
+ } = state;
555
+ const diffCoords = await convertValueToCoords(state, options);
556
+
557
+ // If the placement is the same and the arrow caused an alignment offset
558
+ // then we don't need to change the positioning coordinates.
559
+ if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
560
+ return {};
561
+ }
562
+ return {
563
+ x: x + diffCoords.x,
564
+ y: y + diffCoords.y,
565
+ data: {
566
+ ...diffCoords,
567
+ placement
568
+ }
569
+ };
570
+ }
571
+ };
572
+ };
573
+
574
+ /**
575
+ * Optimizes the visibility of the floating element by shifting it in order to
576
+ * keep it in view when it will overflow the clipping boundary.
577
+ * @see https://floating-ui.com/docs/shift
578
+ */
579
+ const shift$1 = function (options) {
580
+ if (options === void 0) {
581
+ options = {};
582
+ }
583
+ return {
584
+ name: 'shift',
585
+ options,
586
+ async fn(state) {
587
+ const {
588
+ x,
589
+ y,
590
+ placement,
591
+ platform
592
+ } = state;
593
+ const {
594
+ mainAxis: checkMainAxis = true,
595
+ crossAxis: checkCrossAxis = false,
596
+ limiter = {
597
+ fn: _ref => {
598
+ let {
599
+ x,
600
+ y
601
+ } = _ref;
602
+ return {
603
+ x,
604
+ y
605
+ };
606
+ }
607
+ },
608
+ ...detectOverflowOptions
609
+ } = evaluate(options, state);
610
+ const coords = {
611
+ x,
612
+ y
613
+ };
614
+ const overflow = await platform.detectOverflow(state, detectOverflowOptions);
615
+ const crossAxis = getSideAxis(getSide(placement));
616
+ const mainAxis = getOppositeAxis(crossAxis);
617
+ let mainAxisCoord = coords[mainAxis];
618
+ let crossAxisCoord = coords[crossAxis];
619
+ if (checkMainAxis) {
620
+ const minSide = mainAxis === 'y' ? 'top' : 'left';
621
+ const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
622
+ const min = mainAxisCoord + overflow[minSide];
623
+ const max = mainAxisCoord - overflow[maxSide];
624
+ mainAxisCoord = clamp(min, mainAxisCoord, max);
625
+ }
626
+ if (checkCrossAxis) {
627
+ const minSide = crossAxis === 'y' ? 'top' : 'left';
628
+ const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
629
+ const min = crossAxisCoord + overflow[minSide];
630
+ const max = crossAxisCoord - overflow[maxSide];
631
+ crossAxisCoord = clamp(min, crossAxisCoord, max);
632
+ }
633
+ const limitedCoords = limiter.fn({
634
+ ...state,
635
+ [mainAxis]: mainAxisCoord,
636
+ [crossAxis]: crossAxisCoord
637
+ });
638
+ return {
639
+ ...limitedCoords,
640
+ data: {
641
+ x: limitedCoords.x - x,
642
+ y: limitedCoords.y - y,
643
+ enabled: {
644
+ [mainAxis]: checkMainAxis,
645
+ [crossAxis]: checkCrossAxis
646
+ }
647
+ }
648
+ };
649
+ }
650
+ };
651
+ };
652
+
653
+ function hasWindow() {
654
+ return typeof window !== 'undefined';
655
+ }
656
+ function getNodeName(node) {
657
+ if (isNode(node)) {
658
+ return (node.nodeName || '').toLowerCase();
659
+ }
660
+ // Mocked nodes in testing environments may not be instances of Node. By
661
+ // returning `#document` an infinite loop won't occur.
662
+ // https://github.com/floating-ui/floating-ui/issues/2317
663
+ return '#document';
664
+ }
665
+ function getWindow(node) {
666
+ var _node$ownerDocument;
667
+ return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
668
+ }
669
+ function getDocumentElement(node) {
670
+ var _ref;
671
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
672
+ }
673
+ function isNode(value) {
674
+ if (!hasWindow()) {
675
+ return false;
676
+ }
677
+ return value instanceof Node || value instanceof getWindow(value).Node;
678
+ }
679
+ function isElement(value) {
680
+ if (!hasWindow()) {
681
+ return false;
682
+ }
683
+ return value instanceof Element || value instanceof getWindow(value).Element;
684
+ }
685
+ function isHTMLElement(value) {
686
+ if (!hasWindow()) {
687
+ return false;
688
+ }
689
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
690
+ }
691
+ function isShadowRoot(value) {
692
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
693
+ return false;
694
+ }
695
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
696
+ }
697
+ function isOverflowElement(element) {
698
+ const {
699
+ overflow,
700
+ overflowX,
701
+ overflowY,
702
+ display
703
+ } = getComputedStyle$1(element);
704
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';
705
+ }
706
+ function isTableElement(element) {
707
+ return /^(table|td|th)$/.test(getNodeName(element));
708
+ }
709
+ function isTopLayer(element) {
710
+ try {
711
+ if (element.matches(':popover-open')) {
712
+ return true;
713
+ }
714
+ } catch (_e) {
715
+ // no-op
716
+ }
717
+ try {
718
+ return element.matches(':modal');
719
+ } catch (_e) {
720
+ return false;
721
+ }
722
+ }
723
+ const willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
724
+ const containRe = /paint|layout|strict|content/;
725
+ const isNotNone = value => !!value && value !== 'none';
726
+ let isWebKitValue;
727
+ function isContainingBlock(elementOrCss) {
728
+ const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
729
+
730
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
731
+ // https://drafts.csswg.org/css-transforms-2/#individual-transforms
732
+ return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');
733
+ }
734
+ function getContainingBlock(element) {
735
+ let currentNode = getParentNode(element);
736
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
737
+ if (isContainingBlock(currentNode)) {
738
+ return currentNode;
739
+ } else if (isTopLayer(currentNode)) {
740
+ return null;
741
+ }
742
+ currentNode = getParentNode(currentNode);
743
+ }
744
+ return null;
745
+ }
746
+ function isWebKit() {
747
+ if (isWebKitValue == null) {
748
+ isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');
749
+ }
750
+ return isWebKitValue;
751
+ }
752
+ function isLastTraversableNode(node) {
753
+ return /^(html|body|#document)$/.test(getNodeName(node));
754
+ }
755
+ function getComputedStyle$1(element) {
756
+ return getWindow(element).getComputedStyle(element);
757
+ }
758
+ function getNodeScroll(element) {
759
+ if (isElement(element)) {
760
+ return {
761
+ scrollLeft: element.scrollLeft,
762
+ scrollTop: element.scrollTop
763
+ };
764
+ }
765
+ return {
766
+ scrollLeft: element.scrollX,
767
+ scrollTop: element.scrollY
768
+ };
769
+ }
770
+ function getParentNode(node) {
771
+ if (getNodeName(node) === 'html') {
772
+ return node;
773
+ }
774
+ const result =
775
+ // Step into the shadow DOM of the parent of a slotted node.
776
+ node.assignedSlot ||
777
+ // DOM Element detected.
778
+ node.parentNode ||
779
+ // ShadowRoot detected.
780
+ isShadowRoot(node) && node.host ||
781
+ // Fallback.
782
+ getDocumentElement(node);
783
+ return isShadowRoot(result) ? result.host : result;
784
+ }
785
+ function getNearestOverflowAncestor(node) {
786
+ const parentNode = getParentNode(node);
787
+ if (isLastTraversableNode(parentNode)) {
788
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
789
+ }
790
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
791
+ return parentNode;
792
+ }
793
+ return getNearestOverflowAncestor(parentNode);
794
+ }
795
+ function getOverflowAncestors(node, list, traverseIframes) {
796
+ var _node$ownerDocument2;
797
+ if (list === void 0) {
798
+ list = [];
799
+ }
800
+ const scrollableAncestor = getNearestOverflowAncestor(node);
801
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
802
+ const win = getWindow(scrollableAncestor);
803
+ if (isBody) {
804
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], []);
805
+ } else {
806
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, []));
807
+ }
808
+ }
809
+ function getFrameElement(win) {
810
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
811
+ }
812
+
813
+ function getCssDimensions(element) {
814
+ const css = getComputedStyle$1(element);
815
+ // In testing environments, the `width` and `height` properties are empty
816
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
817
+ let width = parseFloat(css.width) || 0;
818
+ let height = parseFloat(css.height) || 0;
819
+ const hasOffset = isHTMLElement(element);
820
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
821
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
822
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
823
+ if (shouldFallback) {
824
+ width = offsetWidth;
825
+ height = offsetHeight;
826
+ }
827
+ return {
828
+ width,
829
+ height,
830
+ $: shouldFallback
831
+ };
832
+ }
833
+
834
+ function unwrapElement(element) {
835
+ return !isElement(element) ? element.contextElement : element;
836
+ }
837
+
838
+ function getScale(element) {
839
+ const domElement = unwrapElement(element);
840
+ if (!isHTMLElement(domElement)) {
841
+ return createCoords(1);
842
+ }
843
+ const rect = domElement.getBoundingClientRect();
844
+ const {
845
+ width,
846
+ height,
847
+ $
848
+ } = getCssDimensions(domElement);
849
+ let x = ($ ? round(rect.width) : rect.width) / width;
850
+ let y = ($ ? round(rect.height) : rect.height) / height;
851
+
852
+ // 0, NaN, or Infinity should always fallback to 1.
853
+
854
+ if (!x || !Number.isFinite(x)) {
855
+ x = 1;
856
+ }
857
+ if (!y || !Number.isFinite(y)) {
858
+ y = 1;
859
+ }
860
+ return {
861
+ x,
862
+ y
863
+ };
864
+ }
865
+
866
+ const noOffsets = /*#__PURE__*/createCoords(0);
867
+ function getVisualOffsets(element) {
868
+ const win = getWindow(element);
869
+ if (!isWebKit() || !win.visualViewport) {
870
+ return noOffsets;
871
+ }
872
+ return {
873
+ x: win.visualViewport.offsetLeft,
874
+ y: win.visualViewport.offsetTop
875
+ };
876
+ }
877
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
878
+ if (isFixed === void 0) {
879
+ isFixed = false;
880
+ }
881
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
882
+ return false;
883
+ }
884
+ return isFixed;
885
+ }
886
+
887
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
888
+ if (includeScale === void 0) {
889
+ includeScale = false;
890
+ }
891
+ if (isFixedStrategy === void 0) {
892
+ isFixedStrategy = false;
893
+ }
894
+ const clientRect = element.getBoundingClientRect();
895
+ const domElement = unwrapElement(element);
896
+ let scale = createCoords(1);
897
+ if (includeScale) {
898
+ if (offsetParent) {
899
+ if (isElement(offsetParent)) {
900
+ scale = getScale(offsetParent);
901
+ }
902
+ } else {
903
+ scale = getScale(element);
904
+ }
905
+ }
906
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
907
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
908
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
909
+ let width = clientRect.width / scale.x;
910
+ let height = clientRect.height / scale.y;
911
+ if (domElement) {
912
+ const win = getWindow(domElement);
913
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
914
+ let currentWin = win;
915
+ let currentIFrame = getFrameElement(currentWin);
916
+ while (currentIFrame && offsetParent && offsetWin !== currentWin) {
917
+ const iframeScale = getScale(currentIFrame);
918
+ const iframeRect = currentIFrame.getBoundingClientRect();
919
+ const css = getComputedStyle$1(currentIFrame);
920
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
921
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
922
+ x *= iframeScale.x;
923
+ y *= iframeScale.y;
924
+ width *= iframeScale.x;
925
+ height *= iframeScale.y;
926
+ x += left;
927
+ y += top;
928
+ currentWin = getWindow(currentIFrame);
929
+ currentIFrame = getFrameElement(currentWin);
930
+ }
931
+ }
932
+ return rectToClientRect({
933
+ width,
934
+ height,
935
+ x,
936
+ y
937
+ });
938
+ }
939
+
940
+ // If <html> has a CSS width greater than the viewport, then this will be
941
+ // incorrect for RTL.
942
+ function getWindowScrollBarX(element, rect) {
943
+ const leftScroll = getNodeScroll(element).scrollLeft;
944
+ if (!rect) {
945
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
946
+ }
947
+ return rect.left + leftScroll;
948
+ }
949
+
950
+ function getHTMLOffset(documentElement, scroll) {
951
+ const htmlRect = documentElement.getBoundingClientRect();
952
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
953
+ const y = htmlRect.top + scroll.scrollTop;
954
+ return {
955
+ x,
956
+ y
957
+ };
958
+ }
959
+
960
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
961
+ let {
962
+ elements,
963
+ rect,
964
+ offsetParent,
965
+ strategy
966
+ } = _ref;
967
+ const isFixed = strategy === 'fixed';
968
+ const documentElement = getDocumentElement(offsetParent);
969
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
970
+ if (offsetParent === documentElement || topLayer && isFixed) {
971
+ return rect;
972
+ }
973
+ let scroll = {
974
+ scrollLeft: 0,
975
+ scrollTop: 0
976
+ };
977
+ let scale = createCoords(1);
978
+ const offsets = createCoords(0);
979
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
980
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
981
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
982
+ scroll = getNodeScroll(offsetParent);
983
+ }
984
+ if (isOffsetParentAnElement) {
985
+ const offsetRect = getBoundingClientRect(offsetParent);
986
+ scale = getScale(offsetParent);
987
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
988
+ offsets.y = offsetRect.y + offsetParent.clientTop;
989
+ }
990
+ }
991
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
992
+ return {
993
+ width: rect.width * scale.x,
994
+ height: rect.height * scale.y,
995
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
996
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
997
+ };
998
+ }
999
+
1000
+ function getClientRects(element) {
1001
+ return Array.from(element.getClientRects());
1002
+ }
1003
+
1004
+ // Gets the entire size of the scrollable document area, even extending outside
1005
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
1006
+ function getDocumentRect(element) {
1007
+ const html = getDocumentElement(element);
1008
+ const scroll = getNodeScroll(element);
1009
+ const body = element.ownerDocument.body;
1010
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
1011
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
1012
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1013
+ const y = -scroll.scrollTop;
1014
+ if (getComputedStyle$1(body).direction === 'rtl') {
1015
+ x += max(html.clientWidth, body.clientWidth) - width;
1016
+ }
1017
+ return {
1018
+ width,
1019
+ height,
1020
+ x,
1021
+ y
1022
+ };
1023
+ }
1024
+
1025
+ // Safety check: ensure the scrollbar space is reasonable in case this
1026
+ // calculation is affected by unusual styles.
1027
+ // Most scrollbars leave 15-18px of space.
1028
+ const SCROLLBAR_MAX = 25;
1029
+ function getViewportRect(element, strategy) {
1030
+ const win = getWindow(element);
1031
+ const html = getDocumentElement(element);
1032
+ const visualViewport = win.visualViewport;
1033
+ let width = html.clientWidth;
1034
+ let height = html.clientHeight;
1035
+ let x = 0;
1036
+ let y = 0;
1037
+ if (visualViewport) {
1038
+ width = visualViewport.width;
1039
+ height = visualViewport.height;
1040
+ const visualViewportBased = isWebKit();
1041
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
1042
+ x = visualViewport.offsetLeft;
1043
+ y = visualViewport.offsetTop;
1044
+ }
1045
+ }
1046
+ const windowScrollbarX = getWindowScrollBarX(html);
1047
+ // <html> `overflow: hidden` + `scrollbar-gutter: stable` reduces the
1048
+ // visual width of the <html> but this is not considered in the size
1049
+ // of `html.clientWidth`.
1050
+ if (windowScrollbarX <= 0) {
1051
+ const doc = html.ownerDocument;
1052
+ const body = doc.body;
1053
+ const bodyStyles = getComputedStyle(body);
1054
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
1055
+ const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
1056
+ if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
1057
+ width -= clippingStableScrollbarWidth;
1058
+ }
1059
+ } else if (windowScrollbarX <= SCROLLBAR_MAX) {
1060
+ // If the <body> scrollbar is on the left, the width needs to be extended
1061
+ // by the scrollbar amount so there isn't extra space on the right.
1062
+ width += windowScrollbarX;
1063
+ }
1064
+ return {
1065
+ width,
1066
+ height,
1067
+ x,
1068
+ y
1069
+ };
1070
+ }
1071
+
1072
+ // Returns the inner client rect, subtracting scrollbars if present.
1073
+ function getInnerBoundingClientRect(element, strategy) {
1074
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
1075
+ const top = clientRect.top + element.clientTop;
1076
+ const left = clientRect.left + element.clientLeft;
1077
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
1078
+ const width = element.clientWidth * scale.x;
1079
+ const height = element.clientHeight * scale.y;
1080
+ const x = left * scale.x;
1081
+ const y = top * scale.y;
1082
+ return {
1083
+ width,
1084
+ height,
1085
+ x,
1086
+ y
1087
+ };
1088
+ }
1089
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
1090
+ let rect;
1091
+ if (clippingAncestor === 'viewport') {
1092
+ rect = getViewportRect(element, strategy);
1093
+ } else if (clippingAncestor === 'document') {
1094
+ rect = getDocumentRect(getDocumentElement(element));
1095
+ } else if (isElement(clippingAncestor)) {
1096
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
1097
+ } else {
1098
+ const visualOffsets = getVisualOffsets(element);
1099
+ rect = {
1100
+ x: clippingAncestor.x - visualOffsets.x,
1101
+ y: clippingAncestor.y - visualOffsets.y,
1102
+ width: clippingAncestor.width,
1103
+ height: clippingAncestor.height
1104
+ };
1105
+ }
1106
+ return rectToClientRect(rect);
1107
+ }
1108
+ function hasFixedPositionAncestor(element, stopNode) {
1109
+ const parentNode = getParentNode(element);
1110
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
1111
+ return false;
1112
+ }
1113
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
1114
+ }
1115
+
1116
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
1117
+ // clipping (or hiding) child elements. This returns all clipping ancestors
1118
+ // of the given element up the tree.
1119
+ function getClippingElementAncestors(element, cache) {
1120
+ const cachedResult = cache.get(element);
1121
+ if (cachedResult) {
1122
+ return cachedResult;
1123
+ }
1124
+ let result = getOverflowAncestors(element, []).filter(el => isElement(el) && getNodeName(el) !== 'body');
1125
+ let currentContainingBlockComputedStyle = null;
1126
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
1127
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
1128
+
1129
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1130
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
1131
+ const computedStyle = getComputedStyle$1(currentNode);
1132
+ const currentNodeIsContaining = isContainingBlock(currentNode);
1133
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
1134
+ currentContainingBlockComputedStyle = null;
1135
+ }
1136
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === 'absolute' || currentContainingBlockComputedStyle.position === 'fixed') || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
1137
+ if (shouldDropCurrentNode) {
1138
+ // Drop non-containing blocks.
1139
+ result = result.filter(ancestor => ancestor !== currentNode);
1140
+ } else {
1141
+ // Record last containing block for next iteration.
1142
+ currentContainingBlockComputedStyle = computedStyle;
1143
+ }
1144
+ currentNode = getParentNode(currentNode);
1145
+ }
1146
+ cache.set(element, result);
1147
+ return result;
1148
+ }
1149
+
1150
+ // Gets the maximum area that the element is visible in due to any number of
1151
+ // clipping ancestors.
1152
+ function getClippingRect(_ref) {
1153
+ let {
1154
+ element,
1155
+ boundary,
1156
+ rootBoundary,
1157
+ strategy
1158
+ } = _ref;
1159
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
1160
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
1161
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
1162
+ let top = firstRect.top;
1163
+ let right = firstRect.right;
1164
+ let bottom = firstRect.bottom;
1165
+ let left = firstRect.left;
1166
+ for (let i = 1; i < clippingAncestors.length; i++) {
1167
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
1168
+ top = max(rect.top, top);
1169
+ right = min(rect.right, right);
1170
+ bottom = min(rect.bottom, bottom);
1171
+ left = max(rect.left, left);
1172
+ }
1173
+ return {
1174
+ width: right - left,
1175
+ height: bottom - top,
1176
+ x: left,
1177
+ y: top
1178
+ };
1179
+ }
1180
+
1181
+ function getDimensions(element) {
1182
+ const {
1183
+ width,
1184
+ height
1185
+ } = getCssDimensions(element);
1186
+ return {
1187
+ width,
1188
+ height
1189
+ };
1190
+ }
1191
+
1192
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1193
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1194
+ const documentElement = getDocumentElement(offsetParent);
1195
+ const isFixed = strategy === 'fixed';
1196
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
1197
+ let scroll = {
1198
+ scrollLeft: 0,
1199
+ scrollTop: 0
1200
+ };
1201
+ const offsets = createCoords(0);
1202
+
1203
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
1204
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
1205
+ function setLeftRTLScrollbarOffset() {
1206
+ offsets.x = getWindowScrollBarX(documentElement);
1207
+ }
1208
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
1209
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1210
+ scroll = getNodeScroll(offsetParent);
1211
+ }
1212
+ if (isOffsetParentAnElement) {
1213
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
1214
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1215
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1216
+ } else if (documentElement) {
1217
+ setLeftRTLScrollbarOffset();
1218
+ }
1219
+ }
1220
+ if (isFixed && !isOffsetParentAnElement && documentElement) {
1221
+ setLeftRTLScrollbarOffset();
1222
+ }
1223
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
1224
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
1225
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
1226
+ return {
1227
+ x,
1228
+ y,
1229
+ width: rect.width,
1230
+ height: rect.height
1231
+ };
1232
+ }
1233
+
1234
+ function isStaticPositioned(element) {
1235
+ return getComputedStyle$1(element).position === 'static';
1236
+ }
1237
+
1238
+ function getTrueOffsetParent(element, polyfill) {
1239
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1240
+ return null;
1241
+ }
1242
+ if (polyfill) {
1243
+ return polyfill(element);
1244
+ }
1245
+ let rawOffsetParent = element.offsetParent;
1246
+
1247
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
1248
+ // while Chrome and Safari return the <body> element. The <body> element must
1249
+ // be used to perform the correct calculations even if the <html> element is
1250
+ // non-static.
1251
+ if (getDocumentElement(element) === rawOffsetParent) {
1252
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
1253
+ }
1254
+ return rawOffsetParent;
1255
+ }
1256
+
1257
+ // Gets the closest ancestor positioned element. Handles some edge cases,
1258
+ // such as table ancestors and cross browser bugs.
1259
+ function getOffsetParent(element, polyfill) {
1260
+ const win = getWindow(element);
1261
+ if (isTopLayer(element)) {
1262
+ return win;
1263
+ }
1264
+ if (!isHTMLElement(element)) {
1265
+ let svgOffsetParent = getParentNode(element);
1266
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
1267
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
1268
+ return svgOffsetParent;
1269
+ }
1270
+ svgOffsetParent = getParentNode(svgOffsetParent);
1271
+ }
1272
+ return win;
1273
+ }
1274
+ let offsetParent = getTrueOffsetParent(element, polyfill);
1275
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
1276
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
1277
+ }
1278
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
1279
+ return win;
1280
+ }
1281
+ return offsetParent || getContainingBlock(element) || win;
1282
+ }
1283
+
1284
+ const getElementRects = async function (data) {
1285
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
1286
+ const getDimensionsFn = this.getDimensions;
1287
+ const floatingDimensions = await getDimensionsFn(data.floating);
1288
+ return {
1289
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
1290
+ floating: {
1291
+ x: 0,
1292
+ y: 0,
1293
+ width: floatingDimensions.width,
1294
+ height: floatingDimensions.height
1295
+ }
1296
+ };
1297
+ };
1298
+
1299
+ function isRTL(element) {
1300
+ return getComputedStyle$1(element).direction === 'rtl';
1301
+ }
1302
+
1303
+ const platform = {
1304
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1305
+ getDocumentElement,
1306
+ getClippingRect,
1307
+ getOffsetParent,
1308
+ getElementRects,
1309
+ getClientRects,
1310
+ getDimensions,
1311
+ getScale,
1312
+ isElement,
1313
+ isRTL
1314
+ };
1315
+
1316
+ /**
1317
+ * Modifies the placement by translating the floating element along the
1318
+ * specified axes.
1319
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
1320
+ * object may be passed.
1321
+ * @see https://floating-ui.com/docs/offset
1322
+ */
1323
+ const offset = offset$1;
1324
+
1325
+ /**
1326
+ * Optimizes the visibility of the floating element by shifting it in order to
1327
+ * keep it in view when it will overflow the clipping boundary.
1328
+ * @see https://floating-ui.com/docs/shift
1329
+ */
1330
+ const shift = shift$1;
1331
+
1332
+ /**
1333
+ * Optimizes the visibility of the floating element by flipping the `placement`
1334
+ * in order to keep it in view when the preferred placement(s) will overflow the
1335
+ * clipping boundary. Alternative to `autoPlacement`.
1336
+ * @see https://floating-ui.com/docs/flip
1337
+ */
1338
+ const flip = flip$1;
1339
+
1340
+ /**
1341
+ * Computes the `x` and `y` coordinates that will place the floating element
1342
+ * next to a given reference element.
1343
+ */
1344
+ const computePosition = (reference, floating, options) => {
1345
+ // This caches the expensive `getClippingElementAncestors` function so that
1346
+ // multiple lifecycle resets re-use the same result. It only lives for a
1347
+ // single call. If other functions become expensive, we can add them as well.
1348
+ const cache = new Map();
1349
+ const mergedOptions = {
1350
+ platform,
1351
+ ...options
1352
+ };
1353
+ const platformWithCache = {
1354
+ ...mergedOptions.platform,
1355
+ _c: cache
1356
+ };
1357
+ return computePosition$1(reference, floating, {
1358
+ ...mergedOptions,
1359
+ platform: platformWithCache
1360
+ });
1361
+ };
1362
+
1363
+ const lmvzPopoverCss = () => `@layer lmvz-ds.reset,lmvz-ds.theme,lmvz-ds.components,lmvz-ds.overrides; @layer lmvz-ds.components{.lmvz-wrapper-card-sm,.lmvz-wrapper-card-md,.lmvz-wrapper-card-lg{background:var(--lmvz-semantic-color-surface-primary, #ffffff);box-shadow:var(--lmvz-ds-shadow-l3-default-strong, 0 2px 32px 0 rgba(120, 120, 128, 0.11))}.lmvz-wrapper-card-sm{padding:var(--lmvz-component-wrapper-sm-padding-y, clamp(0.75rem, 0.69rem + 0.26vw, 1rem)) var(--lmvz-component-wrapper-sm-padding-x, clamp(0.75rem, 0.69rem + 0.26vw, 1rem));border-radius:var(--lmvz-component-wrapper-sm-border-radius, 14px)}.lmvz-wrapper-card-md{padding:var(--lmvz-component-wrapper-md-padding-y, clamp(1rem, 0.88rem + 0.52vw, 1.5rem)) var(--lmvz-component-wrapper-md-padding-x, clamp(1rem, 0.88rem + 0.52vw, 1.5rem));border-radius:var(--lmvz-component-wrapper-md-border-radius, 18px)}.lmvz-wrapper-card-lg{padding:var(--lmvz-component-wrapper-lg-padding-y, clamp(2.25rem, 2.19rem + 0.26vw, 2.5rem)) var(--lmvz-component-wrapper-lg-padding-x, clamp(1.5rem, 1.14rem + 1.55vw, 3rem));border-radius:var(--lmvz-component-wrapper-lg-border-radius, 18px)}}:host{--lmvz-popover-z-index-internal:var(--lmvz-popover-z-index, 1);display:contents;.container{position:absolute;top:-9999999999px;left:-9999999999px;max-width:var(--lmvz-popover-max-width, none);max-height:var(--lmvz-popover-max-height, none);z-index:var(--lmvz-popover-z-index-internal);overflow:auto;box-sizing:border-box}}:host(:not([open])) .container{display:none}`;
1364
+
1365
+ const LmvzPopover = class {
1366
+ constructor(hostRef) {
1367
+ registerInstance(this, hostRef);
1368
+ this.lmvzOpen = createEvent(this, "lmvzOpen", 7);
1369
+ this.lmvzClose = createEvent(this, "lmvzClose", 7);
1370
+ this.lmvzCancel = createEvent(this, "lmvzCancel", 7);
1371
+ }
1372
+ get el() { return getElement(this); }
1373
+ closureController = new AbortController();
1374
+ containerEl;
1375
+ slotEl;
1376
+ previouslyFocusedElement = null;
1377
+ open = false;
1378
+ anchor;
1379
+ placement = 'bottom-start';
1380
+ size = 'sm';
1381
+ autoFocus = true;
1382
+ label;
1383
+ lmvzOpen;
1384
+ lmvzClose;
1385
+ lmvzCancel;
1386
+ async show() {
1387
+ this.open = true;
1388
+ }
1389
+ async hide() {
1390
+ this.triggerClose();
1391
+ }
1392
+ async toggle() {
1393
+ if (this.open) {
1394
+ await this.hide();
1395
+ }
1396
+ else {
1397
+ await this.show();
1398
+ }
1399
+ }
1400
+ componentDidLoad() {
1401
+ autoAssignId(this.el);
1402
+ validatePopoverAria(this.el, this.label, this.anchor, this.resolveAnchor());
1403
+ }
1404
+ handleOpenChange(isOpen) {
1405
+ if (isOpen) {
1406
+ this.onOpen();
1407
+ }
1408
+ else {
1409
+ this.onClose();
1410
+ }
1411
+ }
1412
+ handleAnchorChange() {
1413
+ if (this.open) {
1414
+ this.updatePosition();
1415
+ }
1416
+ }
1417
+ disconnectedCallback() {
1418
+ this.removeCloseHandlers();
1419
+ }
1420
+ resolveAnchor() {
1421
+ if (!this.anchor)
1422
+ return null;
1423
+ if (typeof this.anchor === 'string') {
1424
+ return document.getElementById(this.anchor);
1425
+ }
1426
+ return this.anchor;
1427
+ }
1428
+ async updatePosition() {
1429
+ const anchorEl = this.resolveAnchor();
1430
+ const container = this.containerEl;
1431
+ if (!anchorEl || !container)
1432
+ return;
1433
+ const placement = toFloatingUiPlacement(this.placement);
1434
+ const { x, y } = await computePosition(anchorEl, container, {
1435
+ placement,
1436
+ middleware: [offset(4), flip(), shift({ padding: 8 })],
1437
+ });
1438
+ container.style.left = `${x}px`;
1439
+ container.style.top = `${y}px`;
1440
+ }
1441
+ async onOpen() {
1442
+ this.previouslyFocusedElement = getDeepActiveElement(document);
1443
+ this.setupCloseHandlers();
1444
+ console.log('onOpen');
1445
+ await waitFrame();
1446
+ await this.updatePosition();
1447
+ autoAssignId(this.el);
1448
+ this.applyAnchorAriaOpen();
1449
+ this.lmvzOpen.emit();
1450
+ await waitFrame();
1451
+ if (this.autoFocus) {
1452
+ this.focusFirst();
1453
+ }
1454
+ }
1455
+ onClose() {
1456
+ this.removeCloseHandlers();
1457
+ this.applyAnchorAriaClose();
1458
+ this.restoreFocus();
1459
+ this.lmvzClose.emit();
1460
+ }
1461
+ applyAnchorAriaOpen() {
1462
+ const anchorEl = this.resolveAnchor();
1463
+ if (!anchorEl)
1464
+ return;
1465
+ if (!anchorEl.hasAttribute('aria-haspopup')) {
1466
+ anchorEl.setAttribute('aria-haspopup', 'dialog');
1467
+ }
1468
+ anchorEl.setAttribute('aria-expanded', 'true');
1469
+ anchorEl.setAttribute('aria-controls', this.el.getAttribute('id'));
1470
+ }
1471
+ applyAnchorAriaClose() {
1472
+ const anchorEl = this.resolveAnchor();
1473
+ if (!anchorEl)
1474
+ return;
1475
+ anchorEl.setAttribute('aria-expanded', 'false');
1476
+ }
1477
+ focusFirst() {
1478
+ const { slotEl } = this;
1479
+ if (!slotEl)
1480
+ return;
1481
+ const assigned = slotEl.assignedElements({ flatten: true });
1482
+ for (const el of assigned) {
1483
+ const focusable = walkShadowDOMUntil(el, canReceiveFocus);
1484
+ if (focusable) {
1485
+ focusable.focus();
1486
+ return;
1487
+ }
1488
+ }
1489
+ }
1490
+ restoreFocus() {
1491
+ const el = this.previouslyFocusedElement;
1492
+ if (el?.isConnected) {
1493
+ el.focus();
1494
+ }
1495
+ this.previouslyFocusedElement = null;
1496
+ }
1497
+ triggerClose() {
1498
+ const event = this.lmvzCancel.emit();
1499
+ if (!event.defaultPrevented) {
1500
+ this.open = false;
1501
+ }
1502
+ }
1503
+ setupCloseHandlers() {
1504
+ const options = { signal: this.closureController.signal };
1505
+ document.addEventListener('mousedown', (event) => {
1506
+ if (!this.open)
1507
+ return;
1508
+ if (this.el.contains(event.target))
1509
+ return;
1510
+ this.triggerClose();
1511
+ }, options);
1512
+ document.addEventListener('keydown', (event) => {
1513
+ if (!this.open)
1514
+ return;
1515
+ if (event.key !== 'Escape')
1516
+ return;
1517
+ this.triggerClose();
1518
+ }, options);
1519
+ }
1520
+ removeCloseHandlers() {
1521
+ this.closureController.abort();
1522
+ }
1523
+ render() {
1524
+ return (h(Host, { key: '3dd462a66f17c1617e44787107379d9e4d8ca321' }, h("div", { key: '27106bc8f3169eb07e0d671635074ddb53feb652', role: "dialog", part: "container", class: `container lmvz-wrapper-card-${this.size}`, "aria-label": this.label || undefined, ref: (el) => (this.containerEl = el) }, h("slot", { key: '3401e621d999a225aeb7cb23fa4f5412544a6dab', ref: (el) => (this.slotEl = el) }))));
1525
+ }
1526
+ static get watchers() { return {
1527
+ "open": [{
1528
+ "handleOpenChange": 0
1529
+ }],
1530
+ "anchor": [{
1531
+ "handleAnchorChange": 0
1532
+ }]
1533
+ }; }
1534
+ };
1535
+ let popoverIdCounter = 0;
1536
+ function autoAssignId(hostEl) {
1537
+ if (!hostEl.getAttribute('id')) {
1538
+ hostEl.setAttribute('id', `lmvz-popover-${popoverIdCounter++}`);
1539
+ }
1540
+ }
1541
+ function toFloatingUiPlacement(placement) {
1542
+ if (placement === 'start')
1543
+ return 'left';
1544
+ if (placement === 'end')
1545
+ return 'right';
1546
+ return placement;
1547
+ }
1548
+ function validatePopoverAria(hostEl, label, anchorProp, anchorEl) {
1549
+ if (!isAriaValidationEnabled())
1550
+ return;
1551
+ const hasAriaLabel = !!label;
1552
+ const hasAriaLabelledBy = hostEl.hasAttribute('aria-labelledby');
1553
+ if (!hasAriaLabel && !hasAriaLabelledBy) {
1554
+ console.warn('[lmvz-popover] Host element has no accessible label. Provide a `label` prop or an `aria-labelledby` attribute pointing to a valid element.');
1555
+ }
1556
+ if (!anchorProp)
1557
+ return;
1558
+ if (!anchorEl) {
1559
+ console.warn('[lmvz-popover] Anchor prop is set but resolved to null. Ensure the anchor element exists in the DOM when the component loads.');
1560
+ return;
1561
+ }
1562
+ if (!isInteractiveElement(anchorEl)) {
1563
+ console.warn('[lmvz-popover] Anchor element is not interactive. Ensure the anchor is a button, link, input, select, textarea, has a `tabindex` attribute, or has an ARIA role that implies interactivity (button, link, menuitem, option, combobox, listbox, checkbox, radio, switch, tab).');
1564
+ }
1565
+ }
1566
+ LmvzPopover.style = lmvzPopoverCss();
1567
+
1568
+ export { LmvzPopover as lmvz_popover };