poetry-core 0.0.2

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 (166) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/DESIGN.md +145 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +30 -0
  6. data/THIRD_PARTY_NOTICES.md +507 -0
  7. data/app/components/poetry/core/box/component.rb +82 -0
  8. data/app/components/poetry/core/component.rb +390 -0
  9. data/app/components/poetry/core/concerns/agent_tools.rb +418 -0
  10. data/app/components/poetry/core/concerns/declared_attributes.rb +267 -0
  11. data/app/components/poetry/core/concerns/introspection.rb +533 -0
  12. data/app/components/poetry/core/concerns/options.rb +262 -0
  13. data/app/components/poetry/core/concerns/parts.rb +148 -0
  14. data/app/components/poetry/core/concerns/stimulus.rb +363 -0
  15. data/app/components/poetry/core/concerns/styles.rb +323 -0
  16. data/app/components/poetry/core/style.rb +150 -0
  17. data/app/components/poetry/core/wrapper/component.rb +90 -0
  18. data/app/javascript/poetry/core/accordion_controller.js +165 -0
  19. data/app/javascript/poetry/core/action_bar_controller.js +109 -0
  20. data/app/javascript/poetry/core/autocomplete_controller.js +220 -0
  21. data/app/javascript/poetry/core/calendar_controller.js +406 -0
  22. data/app/javascript/poetry/core/carousel_controller.js +167 -0
  23. data/app/javascript/poetry/core/checkbox_group_controller.js +97 -0
  24. data/app/javascript/poetry/core/checked_controller.js +208 -0
  25. data/app/javascript/poetry/core/clipboard_text_controller.js +111 -0
  26. data/app/javascript/poetry/core/combobox_controller.js +1095 -0
  27. data/app/javascript/poetry/core/command_controller.js +510 -0
  28. data/app/javascript/poetry/core/context_menu_controller.js +204 -0
  29. data/app/javascript/poetry/core/date_field_controller.js +584 -0
  30. data/app/javascript/poetry/core/date_picker_controller.js +111 -0
  31. data/app/javascript/poetry/core/deferred_controller.js +111 -0
  32. data/app/javascript/poetry/core/dialog_controller.js +206 -0
  33. data/app/javascript/poetry/core/dismissable_controller.js +182 -0
  34. data/app/javascript/poetry/core/drawer_controller.js +365 -0
  35. data/app/javascript/poetry/core/file_input_controller.js +191 -0
  36. data/app/javascript/poetry/core/focus_scope_controller.js +162 -0
  37. data/app/javascript/poetry/core/helpers/announce.js +228 -0
  38. data/app/javascript/poetry/core/helpers/breakpoint.js +28 -0
  39. data/app/javascript/poetry/core/helpers/collection.js +18 -0
  40. data/app/javascript/poetry/core/helpers/direction.js +15 -0
  41. data/app/javascript/poetry/core/helpers/escape.js +38 -0
  42. data/app/javascript/poetry/core/helpers/filter_rank.js +104 -0
  43. data/app/javascript/poetry/core/helpers/focus_guards.js +46 -0
  44. data/app/javascript/poetry/core/helpers/hotkey.js +43 -0
  45. data/app/javascript/poetry/core/helpers/id_integrity.js +65 -0
  46. data/app/javascript/poetry/core/helpers/incomplete_date.js +328 -0
  47. data/app/javascript/poetry/core/helpers/mask.js +283 -0
  48. data/app/javascript/poetry/core/helpers/portal.js +217 -0
  49. data/app/javascript/poetry/core/helpers/presence.js +210 -0
  50. data/app/javascript/poetry/core/helpers/registration_guard.js +76 -0
  51. data/app/javascript/poetry/core/helpers/scroll_lock.js +67 -0
  52. data/app/javascript/poetry/core/helpers/scroller_geometry.js +422 -0
  53. data/app/javascript/poetry/core/helpers/state.js +80 -0
  54. data/app/javascript/poetry/core/helpers/tabbable.js +56 -0
  55. data/app/javascript/poetry/core/helpers/turbo_cache.js +21 -0
  56. data/app/javascript/poetry/core/helpers/typeahead.js +85 -0
  57. data/app/javascript/poetry/core/hotkey_controller.js +55 -0
  58. data/app/javascript/poetry/core/hover_card_controller.js +431 -0
  59. data/app/javascript/poetry/core/index.js +218 -0
  60. data/app/javascript/poetry/core/mask_controller.js +500 -0
  61. data/app/javascript/poetry/core/menu_controller.js +1050 -0
  62. data/app/javascript/poetry/core/menubar_controller.js +329 -0
  63. data/app/javascript/poetry/core/message_scroller_controller.js +930 -0
  64. data/app/javascript/poetry/core/navigation_menu_controller.js +458 -0
  65. data/app/javascript/poetry/core/number_field_controller.js +404 -0
  66. data/app/javascript/poetry/core/optimistic_form_controller.js +56 -0
  67. data/app/javascript/poetry/core/otp_controller.js +219 -0
  68. data/app/javascript/poetry/core/popover_controller.js +300 -0
  69. data/app/javascript/poetry/core/popper_controller.js +439 -0
  70. data/app/javascript/poetry/core/pressed_controller.js +74 -0
  71. data/app/javascript/poetry/core/questionnaire_controller.js +468 -0
  72. data/app/javascript/poetry/core/radio_group_controller.js +197 -0
  73. data/app/javascript/poetry/core/resizable_controller.js +202 -0
  74. data/app/javascript/poetry/core/roving_focus_controller.js +215 -0
  75. data/app/javascript/poetry/core/scroll_spy_controller.js +84 -0
  76. data/app/javascript/poetry/core/search_field_controller.js +95 -0
  77. data/app/javascript/poetry/core/select_controller.js +924 -0
  78. data/app/javascript/poetry/core/sensitive_input_controller.js +195 -0
  79. data/app/javascript/poetry/core/sheet_controller.js +24 -0
  80. data/app/javascript/poetry/core/sidebar_controller.js +272 -0
  81. data/app/javascript/poetry/core/slider_controller.js +419 -0
  82. data/app/javascript/poetry/core/state_controller.js +82 -0
  83. data/app/javascript/poetry/core/table_selection_controller.js +153 -0
  84. data/app/javascript/poetry/core/tabs_controller.js +151 -0
  85. data/app/javascript/poetry/core/tag_group_controller.js +134 -0
  86. data/app/javascript/poetry/core/toast_controller.js +228 -0
  87. data/app/javascript/poetry/core/toast_trigger_controller.js +26 -0
  88. data/app/javascript/poetry/core/toaster_controller.js +197 -0
  89. data/app/javascript/poetry/core/toggle_group_controller.js +206 -0
  90. data/app/javascript/poetry/core/tooltip_controller.js +541 -0
  91. data/app/javascript/poetry/core/tree_controller.js +265 -0
  92. data/app/javascript/poetry/core/vendor/floating_ui_core.js +1043 -0
  93. data/app/javascript/poetry/core/vendor/floating_ui_dom.js +794 -0
  94. data/app/javascript/poetry/core/vendor/floating_ui_utils.js +141 -0
  95. data/app/javascript/poetry/core/vendor/floating_ui_utils_dom.js +170 -0
  96. data/app/views/poetry/core/preview.html.erb +13 -0
  97. data/config/component_registry.yml +20 -0
  98. data/config/controllers_manifest.json +1528 -0
  99. data/config/importmap.rb +11 -0
  100. data/config/state_vocabulary.json +31 -0
  101. data/lib/active_model/type/list.rb +33 -0
  102. data/lib/active_model/type/symbol.rb +36 -0
  103. data/lib/poetry/core/check/stable_identity.rb +104 -0
  104. data/lib/poetry/core/check.rb +1445 -0
  105. data/lib/poetry/core/config.rb +286 -0
  106. data/lib/poetry/core/contrib/wrapped_helper.rb +68 -0
  107. data/lib/poetry/core/css/bem_merger.rb +45 -0
  108. data/lib/poetry/core/css/bem_reference.rb +87 -0
  109. data/lib/poetry/core/css/override_scan.rb +110 -0
  110. data/lib/poetry/core/css/resolver.rb +161 -0
  111. data/lib/poetry/core/css/safelist.rb +41 -0
  112. data/lib/poetry/core/css/tailwind_merger.rb +102 -0
  113. data/lib/poetry/core/css/template_classes.rb +102 -0
  114. data/lib/poetry/core/css/theme_coverage.rb +72 -0
  115. data/lib/poetry/core/css/var_coverage.rb +75 -0
  116. data/lib/poetry/core/css/verifier.rb +106 -0
  117. data/lib/poetry/core/design_lint.rb +720 -0
  118. data/lib/poetry/core/design_md/import.rb +250 -0
  119. data/lib/poetry/core/design_md.rb +461 -0
  120. data/lib/poetry/core/engine.rb +71 -0
  121. data/lib/poetry/core/errors.rb +53 -0
  122. data/lib/poetry/core/html/attributes.rb +667 -0
  123. data/lib/poetry/core/icons.rb +157 -0
  124. data/lib/poetry/core/llms_text.rb +354 -0
  125. data/lib/poetry/core/page_architectures.rb +304 -0
  126. data/lib/poetry/core/part_contract.rb +285 -0
  127. data/lib/poetry/core/preview/abstract.rb +121 -0
  128. data/lib/poetry/core/preview/base.rb +227 -0
  129. data/lib/poetry/core/preview/sidecarable.rb +136 -0
  130. data/lib/poetry/core/preview/template.rb +186 -0
  131. data/lib/poetry/core/recipe_items.rb +82 -0
  132. data/lib/poetry/core/registry.rb +363 -0
  133. data/lib/poetry/core/registry_address.rb +115 -0
  134. data/lib/poetry/core/registry_client.rb +217 -0
  135. data/lib/poetry/core/registry_installer.rb +234 -0
  136. data/lib/poetry/core/registry_items.rb +184 -0
  137. data/lib/poetry/core/skill_text.rb +288 -0
  138. data/lib/poetry/core/stable_id.rb +110 -0
  139. data/lib/poetry/core/stimulus/builder.rb +395 -0
  140. data/lib/poetry/core/stimulus/declarations.rb +444 -0
  141. data/lib/poetry/core/stimulus/manifest.rb +68 -0
  142. data/lib/poetry/core/stimulus/merger.rb +131 -0
  143. data/lib/poetry/core/stimulus_contract.rb +263 -0
  144. data/lib/poetry/core/tag_helper.rb +10 -0
  145. data/lib/poetry/core/template_compile.rb +74 -0
  146. data/lib/poetry/core/token_import.rb +317 -0
  147. data/lib/poetry/core/tokens/color.rb +215 -0
  148. data/lib/poetry/core/tokens/contrast_gate.rb +120 -0
  149. data/lib/poetry/core/tokens/generator.rb +211 -0
  150. data/lib/poetry/core/tokens.rb +117 -0
  151. data/lib/poetry/core/version.rb +9 -0
  152. data/lib/poetry/core.rb +52 -0
  153. data/lib/poetry-core.rb +5 -0
  154. data/tokens/aliases.css +145 -0
  155. data/tokens/tailwind-theme.css +47 -0
  156. data/tokens/tokens.css +78 -0
  157. data/tokens/tokens.dtcg.json +779 -0
  158. data/vendor/floating-ui/LICENSE +20 -0
  159. data/vendor/floating-ui/VENDORED_VERSIONS +15 -0
  160. data/vendor/shadcn-tailwind/LICENSE +21 -0
  161. data/vendor/shadcn-tailwind/VENDORED_COMMIT +1 -0
  162. data/vendor/shadcn-tailwind/tailwind.css +629 -0
  163. data/vendor/tw-animate-css/LICENSE +21 -0
  164. data/vendor/tw-animate-css/VENDORED_VERSION +1 -0
  165. data/vendor/tw-animate-css/tw-animate.css +1 -0
  166. metadata +267 -0
@@ -0,0 +1,794 @@
1
+ // Vendored from @floating-ui/dom@1.8.0 (dist/floating-ui.dom.mjs, MIT) - DO NOT EDIT.
2
+ // Import specifiers rewritten to @poetry/controllers/vendor/* so the file
3
+ // resolves via the importmap pins AND the npm exports map.
4
+ // Versions + license: vendor/floating-ui/ (repo root). Update by re-running
5
+ // the vendoring steps there against a newer npm tarball.
6
+ import { rectToClientRect, arrow as arrow$1, autoPlacement as autoPlacement$1, detectOverflow as detectOverflow$1, flip as flip$1, hide as hide$1, inline as inline$1, limitShift as limitShift$1, offset as offset$1, shift as shift$1, size as size$1, computePosition as computePosition$1 } from '@poetry/controllers/vendor/floating_ui_core';
7
+ import { round, createCoords, max, min, floor } from '@poetry/controllers/vendor/floating_ui_utils';
8
+ import { getComputedStyle as getComputedStyle$1, isHTMLElement, isElement, getWindow, isWebKit, getFrameElement, getNodeScroll, getDocumentElement, isTopLayer, getNodeName, isOverflowElement, getOverflowAncestors, getParentNode, isLastTraversableNode, isContainingBlock, isTableElement, getContainingBlock } from '@poetry/controllers/vendor/floating_ui_utils_dom';
9
+ export { getOverflowAncestors } from '@poetry/controllers/vendor/floating_ui_utils_dom';
10
+
11
+ function getCssDimensions(element) {
12
+ const css = getComputedStyle$1(element);
13
+ // In testing environments, the `width` and `height` properties are empty
14
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
15
+ let width = parseFloat(css.width) || 0;
16
+ let height = parseFloat(css.height) || 0;
17
+ const hasOffset = isHTMLElement(element);
18
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
19
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
20
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
21
+ if (shouldFallback) {
22
+ width = offsetWidth;
23
+ height = offsetHeight;
24
+ }
25
+ return {
26
+ width,
27
+ height,
28
+ $: shouldFallback
29
+ };
30
+ }
31
+
32
+ function unwrapElement(element) {
33
+ return !isElement(element) ? element.contextElement : element;
34
+ }
35
+
36
+ function getScale(element) {
37
+ const domElement = unwrapElement(element);
38
+ if (!isHTMLElement(domElement)) {
39
+ return createCoords(1);
40
+ }
41
+ const rect = domElement.getBoundingClientRect();
42
+ const {
43
+ width,
44
+ height,
45
+ $
46
+ } = getCssDimensions(domElement);
47
+ let x = ($ ? round(rect.width) : rect.width) / width;
48
+ let y = ($ ? round(rect.height) : rect.height) / height;
49
+
50
+ // 0, NaN, or Infinity should always fallback to 1.
51
+
52
+ if (!x || !Number.isFinite(x)) {
53
+ x = 1;
54
+ }
55
+ if (!y || !Number.isFinite(y)) {
56
+ y = 1;
57
+ }
58
+ return {
59
+ x,
60
+ y
61
+ };
62
+ }
63
+
64
+ const noOffsets = /*#__PURE__*/createCoords(0);
65
+ function getVisualOffsets(element) {
66
+ const win = getWindow(element);
67
+ if (!isWebKit() || !win.visualViewport) {
68
+ return noOffsets;
69
+ }
70
+ return {
71
+ x: win.visualViewport.offsetLeft,
72
+ y: win.visualViewport.offsetTop
73
+ };
74
+ }
75
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
76
+ if (isFixed === void 0) {
77
+ isFixed = false;
78
+ }
79
+ return !!floatingOffsetParent && isFixed && floatingOffsetParent === getWindow(element);
80
+ }
81
+
82
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
83
+ if (includeScale === void 0) {
84
+ includeScale = false;
85
+ }
86
+ if (isFixedStrategy === void 0) {
87
+ isFixedStrategy = false;
88
+ }
89
+ const clientRect = element.getBoundingClientRect();
90
+ const domElement = unwrapElement(element);
91
+ let scale = createCoords(1);
92
+ if (includeScale) {
93
+ if (offsetParent) {
94
+ if (isElement(offsetParent)) {
95
+ scale = getScale(offsetParent);
96
+ }
97
+ } else {
98
+ scale = getScale(element);
99
+ }
100
+ }
101
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
102
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
103
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
104
+ let width = clientRect.width / scale.x;
105
+ let height = clientRect.height / scale.y;
106
+ if (domElement && offsetParent) {
107
+ const win = getWindow(domElement);
108
+ const offsetWin = isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
109
+ let currentWin = win;
110
+ let currentIFrame = getFrameElement(currentWin);
111
+ while (currentIFrame && offsetWin !== currentWin) {
112
+ const iframeScale = getScale(currentIFrame);
113
+ const iframeRect = currentIFrame.getBoundingClientRect();
114
+ const css = getComputedStyle$1(currentIFrame);
115
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
116
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
117
+ x *= iframeScale.x;
118
+ y *= iframeScale.y;
119
+ width *= iframeScale.x;
120
+ height *= iframeScale.y;
121
+ x += left;
122
+ y += top;
123
+ currentWin = getWindow(currentIFrame);
124
+ currentIFrame = getFrameElement(currentWin);
125
+ }
126
+ }
127
+ return rectToClientRect({
128
+ width,
129
+ height,
130
+ x,
131
+ y
132
+ });
133
+ }
134
+
135
+ // If <html> has a CSS width greater than the viewport, then this will be
136
+ // incorrect for RTL.
137
+ function getWindowScrollBarX(element, rect) {
138
+ const leftScroll = getNodeScroll(element).scrollLeft;
139
+ if (!rect) {
140
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
141
+ }
142
+ return rect.left + leftScroll;
143
+ }
144
+
145
+ function getHTMLOffset(documentElement, scroll) {
146
+ const htmlRect = documentElement.getBoundingClientRect();
147
+ const x = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
148
+ const y = htmlRect.top + scroll.scrollTop;
149
+ return {
150
+ x,
151
+ y
152
+ };
153
+ }
154
+
155
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
156
+ let {
157
+ elements,
158
+ rect,
159
+ offsetParent,
160
+ strategy
161
+ } = _ref;
162
+ const isFixed = strategy === 'fixed';
163
+ const documentElement = getDocumentElement(offsetParent);
164
+ const topLayer = elements ? isTopLayer(elements.floating) : false;
165
+ if (offsetParent === documentElement || topLayer && isFixed) {
166
+ return rect;
167
+ }
168
+ let scroll = {
169
+ scrollLeft: 0,
170
+ scrollTop: 0
171
+ };
172
+ let scale = createCoords(1);
173
+ const offsets = createCoords(0);
174
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
175
+ if (isOffsetParentAnElement || !isFixed) {
176
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
177
+ scroll = getNodeScroll(offsetParent);
178
+ }
179
+ if (isOffsetParentAnElement) {
180
+ const offsetRect = getBoundingClientRect(offsetParent);
181
+ scale = getScale(offsetParent);
182
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
183
+ offsets.y = offsetRect.y + offsetParent.clientTop;
184
+ }
185
+ }
186
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
187
+ return {
188
+ width: rect.width * scale.x,
189
+ height: rect.height * scale.y,
190
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
191
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
192
+ };
193
+ }
194
+
195
+ function getClientRects(element) {
196
+ return element.getClientRects ? Array.from(element.getClientRects()) : [];
197
+ }
198
+
199
+ // Gets the entire size of the scrollable document area, even extending outside
200
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
201
+ function getDocumentRect(html) {
202
+ const scroll = getNodeScroll(html);
203
+ const body = html.ownerDocument.body;
204
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
205
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
206
+ let x = -scroll.scrollLeft + getWindowScrollBarX(html);
207
+ const y = -scroll.scrollTop;
208
+ if (getComputedStyle$1(body).direction === 'rtl') {
209
+ x += max(html.clientWidth, body.clientWidth) - width;
210
+ }
211
+ return {
212
+ width,
213
+ height,
214
+ x,
215
+ y
216
+ };
217
+ }
218
+
219
+ // Safety check: ensure the scrollbar space is reasonable in case this
220
+ // calculation is affected by unusual styles.
221
+ // Most scrollbars leave 15-18px of space.
222
+ const SCROLLBAR_MAX = 25;
223
+ function getViewportRect(element, strategy, rootBoundary) {
224
+ if (rootBoundary === void 0) {
225
+ rootBoundary = 'viewport';
226
+ }
227
+ const isLayoutViewport = rootBoundary === 'layoutViewport';
228
+ const win = getWindow(element);
229
+ const html = getDocumentElement(element);
230
+ const visualViewport = win.visualViewport;
231
+ let width = html.clientWidth;
232
+ let height = html.clientHeight;
233
+ let x = 0;
234
+ let y = 0;
235
+ if (visualViewport) {
236
+ // Client coordinates are relative to the layout viewport, except in
237
+ // WebKit with an `absolute` strategy, where they are relative to the
238
+ // visual viewport.
239
+ const layoutRelativeClientCoords = !isWebKit() || strategy === 'fixed';
240
+ if (isLayoutViewport) {
241
+ if (!layoutRelativeClientCoords) {
242
+ x = -visualViewport.offsetLeft;
243
+ y = -visualViewport.offsetTop;
244
+ }
245
+ } else {
246
+ width = visualViewport.width;
247
+ height = visualViewport.height;
248
+ if (layoutRelativeClientCoords) {
249
+ x = visualViewport.offsetLeft;
250
+ y = visualViewport.offsetTop;
251
+ }
252
+ }
253
+ }
254
+ const windowScrollbarX = getWindowScrollBarX(html);
255
+ // `scrollbar-gutter: stable` on the <html> reserves gutter space that shrinks
256
+ // the visual width but isn't reflected in `html.clientWidth`, so subtract it.
257
+ // Only the inline-end (right) gutter can hold the scrollbar; `both-edges` also
258
+ // reserves an empty inline-start gutter that clips nothing, so exclude just
259
+ // the one scrollbar-side gutter — halve the measured (two-gutter) total. A
260
+ // left-side scrollbar (`windowScrollbarX > 0`) is already handled by
261
+ // `getHTMLOffset`/`visualViewport.width`; skip it here.
262
+ if (windowScrollbarX <= 0) {
263
+ const doc = html.ownerDocument;
264
+ const body = doc.body;
265
+ const bodyStyles = getComputedStyle(body);
266
+ const bodyMarginInline = doc.compatMode === 'CSS1Compat' ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
267
+ const reservedWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
268
+ const gutter = getComputedStyle(html).scrollbarGutter === 'stable both-edges' ? reservedWidth / 2 : reservedWidth;
269
+ if (gutter <= SCROLLBAR_MAX) {
270
+ width -= gutter;
271
+ }
272
+ }
273
+ return {
274
+ width,
275
+ height,
276
+ x,
277
+ y
278
+ };
279
+ }
280
+
281
+ // Returns the inner client rect, subtracting scrollbars if present.
282
+ function getInnerBoundingClientRect(element, strategy) {
283
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
284
+ const top = clientRect.top + element.clientTop;
285
+ const left = clientRect.left + element.clientLeft;
286
+ const scale = getScale(element);
287
+ const width = element.clientWidth * scale.x;
288
+ const height = element.clientHeight * scale.y;
289
+ const x = left * scale.x;
290
+ const y = top * scale.y;
291
+ return {
292
+ width,
293
+ height,
294
+ x,
295
+ y
296
+ };
297
+ }
298
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
299
+ let rect;
300
+ if (clippingAncestor === 'viewport' || clippingAncestor === 'layoutViewport') {
301
+ rect = getViewportRect(element, strategy, clippingAncestor);
302
+ } else if (clippingAncestor === 'document') {
303
+ rect = getDocumentRect(getDocumentElement(element));
304
+ } else if (isElement(clippingAncestor)) {
305
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
306
+ } else {
307
+ const visualOffsets = getVisualOffsets(element);
308
+ rect = {
309
+ x: clippingAncestor.x - visualOffsets.x,
310
+ y: clippingAncestor.y - visualOffsets.y,
311
+ width: clippingAncestor.width,
312
+ height: clippingAncestor.height
313
+ };
314
+ }
315
+ return rectToClientRect(rect);
316
+ }
317
+
318
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
319
+ // clipping (or hiding) child elements. This returns all clipping ancestors
320
+ // of the given element up the tree.
321
+ function getClippingElementAncestors(element, cache) {
322
+ const cachedResult = cache.get(element);
323
+ if (cachedResult) {
324
+ return cachedResult;
325
+ }
326
+ let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
327
+ let lastKeptComputedStyle = null;
328
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
329
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
330
+
331
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
332
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
333
+ const computedStyle = getComputedStyle$1(currentNode);
334
+ const currentNodeIsContaining = isContainingBlock(currentNode);
335
+ // Position of the containing block chain below the current node. A fixed
336
+ // element whose containing block hasn't been found yet is a fixed chain.
337
+ const lastPosition = lastKeptComputedStyle ? lastKeptComputedStyle.position : elementIsFixed ? 'fixed' : '';
338
+
339
+ // A non-containing ancestor does not clip the element when the chain
340
+ // below it escapes it: a fixed chain escapes all ancestors up to the
341
+ // next containing block, an absolute chain escapes static ancestors.
342
+ const shouldDropCurrentNode = !currentNodeIsContaining && (lastPosition === 'fixed' || lastPosition === 'absolute' && computedStyle.position === 'static');
343
+ if (shouldDropCurrentNode) {
344
+ // Drop non-containing blocks.
345
+ result = result.filter(ancestor => ancestor !== currentNode);
346
+ } else {
347
+ // The kept node carries the chain position for the next iteration.
348
+ lastKeptComputedStyle = computedStyle;
349
+ }
350
+ currentNode = getParentNode(currentNode);
351
+ }
352
+ cache.set(element, result);
353
+ return result;
354
+ }
355
+
356
+ // Gets the maximum area that the element is visible in due to any number of
357
+ // clipping ancestors.
358
+ function getClippingRect(_ref) {
359
+ let {
360
+ element,
361
+ boundary,
362
+ rootBoundary,
363
+ strategy
364
+ } = _ref;
365
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
366
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
367
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
368
+ let top = firstRect.top;
369
+ let right = firstRect.right;
370
+ let bottom = firstRect.bottom;
371
+ let left = firstRect.left;
372
+ for (let i = 1; i < clippingAncestors.length; i++) {
373
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
374
+ top = max(rect.top, top);
375
+ right = min(rect.right, right);
376
+ bottom = min(rect.bottom, bottom);
377
+ left = max(rect.left, left);
378
+ }
379
+ return {
380
+ width: right - left,
381
+ height: bottom - top,
382
+ x: left,
383
+ y: top
384
+ };
385
+ }
386
+
387
+ function getDimensions(element) {
388
+ const {
389
+ width,
390
+ height
391
+ } = getCssDimensions(element);
392
+ return {
393
+ width,
394
+ height
395
+ };
396
+ }
397
+
398
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
399
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
400
+ const documentElement = getDocumentElement(offsetParent);
401
+ const isFixed = strategy === 'fixed';
402
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
403
+ let scroll = {
404
+ scrollLeft: 0,
405
+ scrollTop: 0
406
+ };
407
+ const offsets = createCoords(0);
408
+ if (isOffsetParentAnElement || !isFixed) {
409
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
410
+ scroll = getNodeScroll(offsetParent);
411
+ }
412
+ if (isOffsetParentAnElement) {
413
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
414
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
415
+ offsets.y = offsetRect.y + offsetParent.clientTop;
416
+ }
417
+ }
418
+
419
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
420
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
421
+ if (!isOffsetParentAnElement && documentElement) {
422
+ offsets.x = getWindowScrollBarX(documentElement);
423
+ }
424
+ const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
425
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
426
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
427
+ return {
428
+ x,
429
+ y,
430
+ width: rect.width,
431
+ height: rect.height
432
+ };
433
+ }
434
+
435
+ function isStaticPositioned(element) {
436
+ return getComputedStyle$1(element).position === 'static';
437
+ }
438
+
439
+ function getTrueOffsetParent(element, polyfill) {
440
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
441
+ return null;
442
+ }
443
+ if (polyfill) {
444
+ return polyfill(element);
445
+ }
446
+ let rawOffsetParent = element.offsetParent;
447
+
448
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
449
+ // while Chrome and Safari return the <body> element. The <body> element must
450
+ // be used to perform the correct calculations even if the <html> element is
451
+ // non-static.
452
+ if (getDocumentElement(element) === rawOffsetParent) {
453
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
454
+ }
455
+ return rawOffsetParent;
456
+ }
457
+
458
+ // Gets the closest ancestor positioned element. Handles some edge cases,
459
+ // such as table ancestors and cross browser bugs.
460
+ function getOffsetParent(element, polyfill) {
461
+ const win = getWindow(element);
462
+ if (isTopLayer(element)) {
463
+ return win;
464
+ }
465
+ if (!isHTMLElement(element)) {
466
+ let svgOffsetParent = getParentNode(element);
467
+ while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
468
+ if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
469
+ return svgOffsetParent;
470
+ }
471
+ svgOffsetParent = getParentNode(svgOffsetParent);
472
+ }
473
+ return win;
474
+ }
475
+ let offsetParent = getTrueOffsetParent(element, polyfill);
476
+ while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
477
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
478
+ }
479
+ if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
480
+ return win;
481
+ }
482
+ return offsetParent || getContainingBlock(element) || win;
483
+ }
484
+
485
+ const getElementRects = async function (data) {
486
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
487
+ const getDimensionsFn = this.getDimensions;
488
+ const floatingDimensions = await getDimensionsFn(data.floating);
489
+ return {
490
+ reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
491
+ floating: {
492
+ x: 0,
493
+ y: 0,
494
+ width: floatingDimensions.width,
495
+ height: floatingDimensions.height
496
+ }
497
+ };
498
+ };
499
+
500
+ function isRTL(element) {
501
+ return getComputedStyle$1(element).direction === 'rtl';
502
+ }
503
+
504
+ const platform = {
505
+ convertOffsetParentRelativeRectToViewportRelativeRect,
506
+ getDocumentElement,
507
+ getClippingRect,
508
+ getOffsetParent,
509
+ getElementRects,
510
+ getClientRects,
511
+ getDimensions,
512
+ getScale,
513
+ isElement,
514
+ isRTL
515
+ };
516
+
517
+ function rectsAreEqual(a, b) {
518
+ return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
519
+ }
520
+
521
+ // https://samthor.au/2021/observing-dom/
522
+ function observeMove(element, onMove, ancestorResize) {
523
+ let io = null;
524
+ let timeoutId;
525
+ const root = getDocumentElement(element);
526
+ function cleanup() {
527
+ var _io;
528
+ clearTimeout(timeoutId);
529
+ (_io = io) == null || _io.disconnect();
530
+ io = null;
531
+ }
532
+ function refresh(skip, threshold) {
533
+ if (skip === void 0) {
534
+ skip = false;
535
+ }
536
+ if (threshold === void 0) {
537
+ threshold = 1;
538
+ }
539
+ cleanup();
540
+ const elementRectForRootMargin = element.getBoundingClientRect();
541
+ const {
542
+ left,
543
+ top,
544
+ width,
545
+ height
546
+ } = elementRectForRootMargin;
547
+ if (!skip) {
548
+ onMove();
549
+ }
550
+ if (!width || !height) {
551
+ return;
552
+ }
553
+ const insetTop = floor(top);
554
+ const insetRight = floor(root.clientWidth - (left + width));
555
+ const insetBottom = floor(root.clientHeight - (top + height));
556
+ const insetLeft = floor(left);
557
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
558
+ const options = {
559
+ rootMargin,
560
+ threshold: max(0, min(1, threshold)) || 1
561
+ };
562
+ let isFirstUpdate = true;
563
+ function handleObserve(entries) {
564
+ const ratio = entries[0].intersectionRatio;
565
+
566
+ // The entry is a snapshot, so the reference may have moved since the
567
+ // intersection was computed (under performance constraints, or between
568
+ // consecutive frames of a multi-frame layout shift). The reported ratio
569
+ // and the observed area are stale in that case and cannot be trusted to
570
+ // detect subsequent movement, so refresh regardless of the ratio.
571
+ if (!rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
572
+ return refresh();
573
+ }
574
+ if (ratio !== threshold) {
575
+ if (!isFirstUpdate) {
576
+ return refresh();
577
+ }
578
+ if (!ratio) {
579
+ // If the reference is clipped in place, the ratio is 0. Throttle
580
+ // the refresh to prevent an infinite loop of updates.
581
+ timeoutId = setTimeout(() => {
582
+ refresh(false, 1e-7);
583
+ }, 1000);
584
+ } else {
585
+ refresh(false, ratio);
586
+ }
587
+ }
588
+ isFirstUpdate = false;
589
+ }
590
+
591
+ // Older browsers don't support a `document` as the root and will throw an
592
+ // error.
593
+ try {
594
+ io = new IntersectionObserver(handleObserve, {
595
+ ...options,
596
+ // Handle <iframe>s
597
+ root: root.ownerDocument
598
+ });
599
+ } catch (_e) {
600
+ io = new IntersectionObserver(handleObserve, options);
601
+ }
602
+ io.observe(element);
603
+ }
604
+ const win = getWindow(element);
605
+ // The window is a resize ancestor, so when `ancestorResize` is enabled its
606
+ // listener already runs the update on resize. Here we only need to rebuild
607
+ // the `IntersectionObserver` for the new root size, skipping a redundant
608
+ // update. When `ancestorResize` is disabled, this becomes the sole update.
609
+ const handleResize = () => refresh(ancestorResize);
610
+ win.addEventListener('resize', handleResize);
611
+ refresh(true);
612
+ return () => {
613
+ win.removeEventListener('resize', handleResize);
614
+ cleanup();
615
+ };
616
+ }
617
+
618
+ /**
619
+ * Automatically updates the position of the floating element when necessary.
620
+ * Should only be called when the floating element is mounted on the DOM or
621
+ * visible on the screen.
622
+ * @returns cleanup function that should be invoked when the floating element is
623
+ * removed from the DOM or hidden from the screen.
624
+ * @see https://floating-ui.com/docs/autoUpdate
625
+ */
626
+ function autoUpdate(reference, floating, update, options) {
627
+ if (options === void 0) {
628
+ options = {};
629
+ }
630
+ const {
631
+ ancestorScroll = true,
632
+ ancestorResize = true,
633
+ elementResize = typeof ResizeObserver === 'function',
634
+ layoutShift = typeof IntersectionObserver === 'function',
635
+ animationFrame = false
636
+ } = options;
637
+ const referenceEl = unwrapElement(reference);
638
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...(floating ? getOverflowAncestors(floating) : [])] : [];
639
+ ancestors.forEach(ancestor => {
640
+ ancestorScroll && ancestor.addEventListener('scroll', update);
641
+ ancestorResize && ancestor.addEventListener('resize', update);
642
+ });
643
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update, ancestorResize) : null;
644
+ let reobserveFrame = -1;
645
+ let resizeObserver = null;
646
+ if (elementResize) {
647
+ resizeObserver = new ResizeObserver(_ref => {
648
+ let [firstEntry] = _ref;
649
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
650
+ // Prevent update loops when using the `size` middleware.
651
+ // https://github.com/floating-ui/floating-ui/issues/1740
652
+ resizeObserver.unobserve(floating);
653
+ cancelAnimationFrame(reobserveFrame);
654
+ reobserveFrame = requestAnimationFrame(() => {
655
+ var _resizeObserver;
656
+ (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
657
+ });
658
+ }
659
+ update();
660
+ });
661
+ if (referenceEl && !animationFrame) {
662
+ resizeObserver.observe(referenceEl);
663
+ }
664
+ if (floating) {
665
+ resizeObserver.observe(floating);
666
+ }
667
+ }
668
+ let frameId;
669
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
670
+ if (animationFrame) {
671
+ frameLoop();
672
+ }
673
+ function frameLoop() {
674
+ const nextRefRect = getBoundingClientRect(reference);
675
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
676
+ update();
677
+ }
678
+ prevRefRect = nextRefRect;
679
+ frameId = requestAnimationFrame(frameLoop);
680
+ }
681
+ update();
682
+ return () => {
683
+ var _resizeObserver2;
684
+ ancestors.forEach(ancestor => {
685
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
686
+ ancestorResize && ancestor.removeEventListener('resize', update);
687
+ });
688
+ cleanupIo == null || cleanupIo();
689
+ (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
690
+ resizeObserver = null;
691
+ if (animationFrame) {
692
+ cancelAnimationFrame(frameId);
693
+ }
694
+ };
695
+ }
696
+
697
+ /**
698
+ * Resolves with an object of overflow side offsets that determine how much the
699
+ * element is overflowing a given clipping boundary on each side.
700
+ * - positive = overflowing the boundary by that number of pixels
701
+ * - negative = how many pixels left before it will overflow
702
+ * - 0 = lies flush with the boundary
703
+ * @see https://floating-ui.com/docs/detectOverflow
704
+ */
705
+ const detectOverflow = detectOverflow$1;
706
+
707
+ /**
708
+ * Modifies the placement by translating the floating element along the
709
+ * specified axes.
710
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
711
+ * object may be passed.
712
+ * @see https://floating-ui.com/docs/offset
713
+ */
714
+ const offset = offset$1;
715
+
716
+ /**
717
+ * Optimizes the visibility of the floating element by choosing the placement
718
+ * that has the most space available automatically, without needing to specify a
719
+ * preferred placement. Alternative to `flip`.
720
+ * @see https://floating-ui.com/docs/autoPlacement
721
+ */
722
+ const autoPlacement = autoPlacement$1;
723
+
724
+ /**
725
+ * Optimizes the visibility of the floating element by shifting it in order to
726
+ * keep it in view when it will overflow the clipping boundary.
727
+ * @see https://floating-ui.com/docs/shift
728
+ */
729
+ const shift = shift$1;
730
+
731
+ /**
732
+ * Optimizes the visibility of the floating element by flipping the `placement`
733
+ * in order to keep it in view when the preferred placement(s) will overflow the
734
+ * clipping boundary. Alternative to `autoPlacement`.
735
+ * @see https://floating-ui.com/docs/flip
736
+ */
737
+ const flip = flip$1;
738
+
739
+ /**
740
+ * Provides data that allows you to change the size of the floating element —
741
+ * for instance, prevent it from overflowing the clipping boundary or match the
742
+ * width of the reference element.
743
+ * @see https://floating-ui.com/docs/size
744
+ */
745
+ const size = size$1;
746
+
747
+ /**
748
+ * Provides data to hide the floating element in applicable situations, such as
749
+ * when it is not in the same clipping context as the reference element.
750
+ * @see https://floating-ui.com/docs/hide
751
+ */
752
+ const hide = hide$1;
753
+
754
+ /**
755
+ * Provides data to position an inner element of the floating element so that it
756
+ * appears centered to the reference element.
757
+ * @see https://floating-ui.com/docs/arrow
758
+ */
759
+ const arrow = arrow$1;
760
+
761
+ /**
762
+ * Provides improved positioning for inline reference elements that can span
763
+ * over multiple lines, such as hyperlinks or range selections.
764
+ * @see https://floating-ui.com/docs/inline
765
+ */
766
+ const inline = inline$1;
767
+
768
+ /**
769
+ * Built-in `limiter` that will stop `shift()` at a certain point.
770
+ */
771
+ const limitShift = limitShift$1;
772
+
773
+ /**
774
+ * Computes the `x` and `y` coordinates that will place the floating element
775
+ * next to a given reference element.
776
+ */
777
+ const computePosition = (reference, floating, options) => {
778
+ // This caches the expensive `getClippingElementAncestors` function so that
779
+ // multiple lifecycle resets re-use the same result. It only lives for a
780
+ // single call. If other functions become expensive, we can add them as well.
781
+ const cache = new Map();
782
+ const mergedOptions = options != null ? options : {};
783
+ const platformWithCache = {
784
+ ...platform,
785
+ ...mergedOptions.platform,
786
+ _c: cache
787
+ };
788
+ return computePosition$1(reference, floating, {
789
+ ...mergedOptions,
790
+ platform: platformWithCache
791
+ });
792
+ };
793
+
794
+ export { arrow, autoPlacement, autoUpdate, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, platform, shift, size };