@threadlabs/looma 0.1.15 → 0.1.17

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 (123) hide show
  1. package/dist/{chunk-SVINNT3E.js → chunk-OY4D3W4U.js} +29 -29
  2. package/dist/{chunk-G53JEAQK.js → chunk-SZJQ3NPX.js} +6 -3
  3. package/dist/chunk-YHXJC5M5.js +341 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/looma.cjs.js +1 -1
  6. package/dist/cjs/{manager-BOpVXb92.js → manager-C9j3HZay.js} +5 -2
  7. package/dist/cjs/positioning-i0WrCAdF.js +384 -0
  8. package/dist/cjs/ui-affordance-scope.cjs.entry.js +3 -113
  9. package/dist/cjs/ui-context-menu.cjs.entry.js +40 -5
  10. package/dist/cjs/ui-dialog.cjs.entry.js +1 -1
  11. package/dist/cjs/ui-menu.cjs.entry.js +83 -2
  12. package/dist/cjs/ui-popover.cjs.entry.js +43 -3
  13. package/dist/cjs/ui-toast-region.cjs.entry.js +17 -2
  14. package/dist/cjs/ui-tooltip.cjs.entry.js +95 -27
  15. package/dist/cjs/ui-tree-item.cjs.entry.js +1 -1
  16. package/dist/collection/components/ui-context-menu/ui-context-menu.css +17 -4
  17. package/dist/collection/components/ui-context-menu/ui-context-menu.js +38 -3
  18. package/dist/collection/components/ui-menu/ui-menu.css +39 -0
  19. package/dist/collection/components/ui-menu/ui-menu.js +128 -1
  20. package/dist/collection/components/ui-popover/ui-popover.css +31 -0
  21. package/dist/collection/components/ui-popover/ui-popover.js +87 -1
  22. package/dist/collection/components/ui-toast-region/ui-toast-region.css +6 -0
  23. package/dist/collection/components/ui-toast-region/ui-toast-region.js +16 -1
  24. package/dist/collection/components/ui-tooltip/ui-tooltip.css +20 -0
  25. package/dist/collection/components/ui-tooltip/ui-tooltip.js +160 -25
  26. package/dist/collection/components/ui-tree-item/ui-tree-item.css +10 -6
  27. package/dist/collection/input-modality.js +24 -0
  28. package/dist/collection/overlay/manager.js +5 -2
  29. package/dist/collection/overlay/positioning.js +246 -0
  30. package/dist/components/p-CEYIKqYc.js +1 -0
  31. package/dist/components/p-DOulVJT7.js +1 -0
  32. package/dist/components/p-PM9a74r7.js +1 -0
  33. package/dist/components/ui-affordance-scope.js +1 -1
  34. package/dist/components/ui-context-menu.js +1 -1
  35. package/dist/components/ui-dialog.js +1 -1
  36. package/dist/components/ui-menu.js +1 -1
  37. package/dist/components/ui-popover.js +1 -1
  38. package/dist/components/ui-toast-region.js +1 -1
  39. package/dist/components/ui-tooltip.js +1 -1
  40. package/dist/components/ui-tree-item.js +1 -1
  41. package/dist/esm/loader.js +1 -1
  42. package/dist/esm/looma.js +1 -1
  43. package/dist/esm/{manager-CR7f2MQC.js → manager-PM9a74r7.js} +5 -2
  44. package/dist/esm/positioning-Bu0dmLBE.js +379 -0
  45. package/dist/esm/ui-affordance-scope.entry.js +1 -111
  46. package/dist/esm/ui-context-menu.entry.js +40 -5
  47. package/dist/esm/ui-dialog.entry.js +1 -1
  48. package/dist/esm/ui-menu.entry.js +83 -2
  49. package/dist/esm/ui-popover.entry.js +43 -3
  50. package/dist/esm/ui-toast-region.entry.js +17 -2
  51. package/dist/esm/ui-tooltip.entry.js +95 -27
  52. package/dist/esm/ui-tree-item.entry.js +1 -1
  53. package/dist/index.cjs +776 -59
  54. package/dist/index.d.cts +44 -1
  55. package/dist/index.d.ts +44 -1
  56. package/dist/index.js +235 -4
  57. package/dist/looma/looma.esm.js +1 -1
  58. package/dist/looma/{p-c6721aba.entry.js → p-11083743.entry.js} +1 -1
  59. package/dist/looma/p-1674cda4.entry.js +1 -0
  60. package/dist/looma/p-2e6f791e.entry.js +1 -0
  61. package/dist/looma/p-54c41576.entry.js +1 -0
  62. package/dist/looma/p-9194a99d.entry.js +1 -0
  63. package/dist/looma/p-Bu0dmLBE.js +1 -0
  64. package/dist/looma/p-PM9a74r7.js +1 -0
  65. package/dist/looma/p-ba01f45d.entry.js +1 -0
  66. package/dist/looma/p-caa8fc7b.entry.js +1 -0
  67. package/dist/looma/{p-ef9ca2ed.entry.js → p-d01960c2.entry.js} +2 -2
  68. package/dist/types/components/ui-context-menu/ui-context-menu.d.ts +3 -0
  69. package/dist/types/components/ui-menu/ui-menu.d.ts +13 -0
  70. package/dist/types/components/ui-popover/ui-popover.d.ts +9 -0
  71. package/dist/types/components/ui-toast-region/ui-toast-region.d.ts +2 -0
  72. package/dist/types/components/ui-tooltip/ui-tooltip.d.ts +16 -1
  73. package/dist/types/components.d.ts +71 -0
  74. package/dist/types/input-modality.d.ts +6 -0
  75. package/dist/types/overlay/manager.d.ts +3 -0
  76. package/dist/types/overlay/positioning.d.ts +33 -0
  77. package/dist/ui-affordance-scope.entry-X7DTKJGL.js +54 -0
  78. package/dist/{ui-avatar-group.entry-DQDP325O.js → ui-avatar-group.entry-MC34FKAN.js} +1 -1
  79. package/dist/{ui-avatar.entry-WYIDMOFE.js → ui-avatar.entry-OKRQWTQV.js} +1 -1
  80. package/dist/{ui-badge.entry-VGHXPEDT.js → ui-badge.entry-RI7JB7KV.js} +1 -1
  81. package/dist/{ui-button.entry-LKPLOJ22.js → ui-button.entry-PFO5TTPN.js} +1 -1
  82. package/dist/{ui-checkbox.entry-J74HEA22.js → ui-checkbox.entry-UHFWVISP.js} +1 -1
  83. package/dist/{ui-context-menu.entry-MQM2FCLI.js → ui-context-menu.entry-AIXB6U5D.js} +40 -6
  84. package/dist/{ui-dialog.entry-DQMMDO4Z.js → ui-dialog.entry-LPREQH2T.js} +2 -2
  85. package/dist/{ui-disclosure.entry-ONF7UZDC.js → ui-disclosure.entry-7XCUIYVZ.js} +1 -1
  86. package/dist/{ui-floating-action-button.entry-FKTGVC5T.js → ui-floating-action-button.entry-5PNIMUAW.js} +1 -1
  87. package/dist/{ui-form-field.entry-M3ISWQNU.js → ui-form-field.entry-77YW46SM.js} +1 -1
  88. package/dist/{ui-icon-button.entry-AWFIQUHM.js → ui-icon-button.entry-4AD6ALPQ.js} +1 -1
  89. package/dist/{ui-input.entry-JZ6RETMT.js → ui-input.entry-E7E6QDTV.js} +1 -1
  90. package/dist/{ui-menu-item.entry-5MFR5LFL.js → ui-menu-item.entry-H3HFLUB6.js} +1 -1
  91. package/dist/ui-menu.entry-UAKZU4HG.js +184 -0
  92. package/dist/{ui-popover.entry-ELCMKO6Y.js → ui-popover.entry-GVQKX26B.js} +46 -4
  93. package/dist/{ui-radio-group.entry-RJHUPPEM.js → ui-radio-group.entry-MNSR6UEE.js} +1 -1
  94. package/dist/{ui-radio.entry-3VRDPOY4.js → ui-radio.entry-6D4WTI5E.js} +1 -1
  95. package/dist/{ui-search-result-row.entry-J34YPAV7.js → ui-search-result-row.entry-J2TILUH2.js} +1 -1
  96. package/dist/{ui-search-shell.entry-IJ4UUP27.js → ui-search-shell.entry-FSWHEZQF.js} +1 -1
  97. package/dist/{ui-select.entry-C6YD3HQ5.js → ui-select.entry-JRCYYNNW.js} +1 -1
  98. package/dist/{ui-switch.entry-UZDF5QTI.js → ui-switch.entry-YZWMNRP2.js} +1 -1
  99. package/dist/{ui-tabs.entry-YRAKWOMR.js → ui-tabs.entry-F2Y344JY.js} +1 -1
  100. package/dist/{ui-textarea.entry-JLDKFT3K.js → ui-textarea.entry-3EZCUUAK.js} +1 -1
  101. package/dist/{ui-toast-region.entry-GC7C7KXF.js → ui-toast-region.entry-BTV4AW3I.js} +20 -3
  102. package/dist/ui-tooltip.entry-U644CF5U.js +214 -0
  103. package/dist/{ui-top-bar.entry-5W5UA5KV.js → ui-top-bar.entry-FGGOREQR.js} +1 -1
  104. package/dist/{ui-tree-item.entry-3LM7IXIK.js → ui-tree-item.entry-XVMHEONY.js} +2 -2
  105. package/dist/{ui-tree.entry-X4FU42A6.js → ui-tree.entry-4R7DYGAM.js} +1 -1
  106. package/editor.css +3 -4
  107. package/package.json +1 -1
  108. package/tokens.css +14 -2
  109. package/vue/{chunk-IITL6UBR.js → chunk-5KWCMTXB.js} +3 -0
  110. package/vue/editor/index.js +63 -52
  111. package/vue/index.js +1 -1
  112. package/dist/components/p-CR7f2MQC.js +0 -1
  113. package/dist/components/p-QiwSQmKJ.js +0 -1
  114. package/dist/looma/p-2ae73d5b.entry.js +0 -1
  115. package/dist/looma/p-3ac2e0d4.entry.js +0 -1
  116. package/dist/looma/p-65c25c94.entry.js +0 -1
  117. package/dist/looma/p-8c09c724.entry.js +0 -1
  118. package/dist/looma/p-95cd639d.entry.js +0 -1
  119. package/dist/looma/p-96f73d07.entry.js +0 -1
  120. package/dist/looma/p-CR7f2MQC.js +0 -1
  121. package/dist/ui-affordance-scope.entry-PFP2TDKO.js +0 -145
  122. package/dist/ui-menu.entry-IOEIDATQ.js +0 -98
  123. package/dist/ui-tooltip.entry-F26XDTYX.js +0 -145
package/dist/index.cjs CHANGED
@@ -24,11 +24,243 @@ var __copyProps = (to, from, except, desc) => {
24
24
  };
25
25
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
26
 
27
- // dist/esm/ui-affordance-scope.entry.js
28
- var ui_affordance_scope_entry_exports = {};
29
- __export(ui_affordance_scope_entry_exports, {
30
- ui_affordance_scope: () => UIAffordanceScope
31
- });
27
+ // dist/esm/positioning-Bu0dmLBE.js
28
+ function bindAnchorName(anchor, name) {
29
+ const binding = anchorBindings.get(anchor) ?? {
30
+ original: anchor.style.getPropertyValue("anchor-name"),
31
+ names: /* @__PURE__ */ new Set()
32
+ };
33
+ binding.names.add(name);
34
+ anchorBindings.set(anchor, binding);
35
+ const values = [binding.original, ...binding.names].filter(Boolean);
36
+ anchor.style.setProperty("anchor-name", values.join(", "));
37
+ }
38
+ function unbindAnchorName(anchor, name) {
39
+ const binding = anchorBindings.get(anchor);
40
+ if (!binding)
41
+ return;
42
+ binding.names.delete(name);
43
+ if (binding.names.size) {
44
+ const values = [binding.original, ...binding.names].filter(Boolean);
45
+ anchor.style.setProperty("anchor-name", values.join(", "));
46
+ return;
47
+ }
48
+ if (binding.original)
49
+ anchor.style.setProperty("anchor-name", binding.original);
50
+ else
51
+ anchor.style.removeProperty("anchor-name");
52
+ anchorBindings.delete(anchor);
53
+ }
54
+ function supportsAnchorPositioning(owner) {
55
+ const css = owner.CSS;
56
+ return typeof css?.supports === "function" && css.supports("anchor-name: --ui-anchor-test") && css.supports("position-anchor: --ui-anchor-test") && css.supports("top: anchor(bottom)");
57
+ }
58
+ function topLayerOpen(surface) {
59
+ try {
60
+ return surface.matches(":popover-open");
61
+ } catch {
62
+ return !surface.hidden;
63
+ }
64
+ }
65
+ function showInTopLayer(surface) {
66
+ surface.setAttribute("popover", "manual");
67
+ surface.hidden = false;
68
+ if (typeof surface.showPopover === "function" && !topLayerOpen(surface)) {
69
+ try {
70
+ surface.showPopover();
71
+ } catch {
72
+ }
73
+ }
74
+ }
75
+ function hideFromTopLayer(surface) {
76
+ if (typeof surface.hidePopover === "function" && topLayerOpen(surface)) {
77
+ try {
78
+ surface.hidePopover();
79
+ } catch {
80
+ }
81
+ }
82
+ surface.hidden = true;
83
+ }
84
+ function createViewportSurface(surface) {
85
+ surface.setAttribute("popover", "manual");
86
+ surface.dataset.uiPositioning = "viewport";
87
+ return {
88
+ show() {
89
+ showInTopLayer(surface);
90
+ },
91
+ hide() {
92
+ hideFromTopLayer(surface);
93
+ },
94
+ destroy() {
95
+ hideFromTopLayer(surface);
96
+ }
97
+ };
98
+ }
99
+ function fallbackPosition(surface, anchor, placement, gap, viewportGap) {
100
+ const owner = surface.ownerDocument.defaultView ?? window;
101
+ const viewport = getVisualViewportRect(owner);
102
+ const rect = surface.getBoundingClientRect();
103
+ const preferTop = placement.startsWith("top");
104
+ const preferEnd = placement.endsWith("end");
105
+ const spaceBelow = viewport.bottom - anchor.bottom - viewportGap;
106
+ const spaceAbove = anchor.top - viewport.top - viewportGap;
107
+ const useTop = preferTop ? !(spaceAbove < rect.height + gap && spaceBelow > spaceAbove) : spaceBelow < rect.height + gap && spaceAbove > spaceBelow;
108
+ const unclampedTop = useTop ? anchor.top - rect.height - gap : anchor.bottom + gap;
109
+ const unclampedLeft = preferEnd ? anchor.right - rect.width : anchor.left;
110
+ const shifted = clampRectToViewport({
111
+ left: unclampedLeft,
112
+ top: unclampedTop,
113
+ width: rect.width,
114
+ height: rect.height
115
+ }, viewport, viewportGap);
116
+ surface.style.left = `${Math.round(unclampedLeft + shifted.x)}px`;
117
+ surface.style.top = `${Math.round(unclampedTop + shifted.y)}px`;
118
+ surface.style.right = "auto";
119
+ surface.style.bottom = "auto";
120
+ }
121
+ function createAnchoredSurface(surface, options = {}) {
122
+ const owner = surface.ownerDocument.defaultView ?? window;
123
+ const placement = options.placement ?? "bottom-start";
124
+ const gap = Math.max(0, options.gap ?? 4);
125
+ const viewportGap = Math.max(0, options.viewportGap ?? 8);
126
+ const nativeAnchor = supportsAnchorPositioning(owner);
127
+ const anchorName = `--ui-anchor-${++anchorSequence}`;
128
+ let anchor = options.anchor ?? null;
129
+ let point = null;
130
+ let open = false;
131
+ let frame = null;
132
+ let listenerAbort = null;
133
+ surface.setAttribute("popover", "manual");
134
+ surface.dataset.uiPositioning = nativeAnchor ? "anchor" : "fallback";
135
+ surface.style.position = "fixed";
136
+ surface.style.margin = "0";
137
+ const bindAnchor = (next) => {
138
+ if (anchor)
139
+ unbindAnchorName(anchor, anchorName);
140
+ anchor = next;
141
+ if (!anchor) {
142
+ surface.style.removeProperty("position-anchor");
143
+ return;
144
+ }
145
+ bindAnchorName(anchor, anchorName);
146
+ surface.style.setProperty("position-anchor", anchorName);
147
+ };
148
+ const positionNative = () => {
149
+ const blockEnd = placement.startsWith("bottom");
150
+ const inlineEnd = placement.endsWith("end");
151
+ surface.style.top = blockEnd ? `calc(anchor(bottom) + ${gap}px)` : "auto";
152
+ surface.style.bottom = blockEnd ? "auto" : `calc(anchor(top) + ${gap}px)`;
153
+ surface.style.left = inlineEnd ? "auto" : "anchor(left)";
154
+ surface.style.right = inlineEnd ? "anchor(right)" : "auto";
155
+ surface.style.setProperty("position-try-fallbacks", "flip-block, flip-inline");
156
+ };
157
+ const position = () => {
158
+ frame = null;
159
+ if (!open)
160
+ return;
161
+ if (point) {
162
+ fallbackPosition(surface, {
163
+ left: point.x,
164
+ right: point.x,
165
+ top: point.y,
166
+ bottom: point.y
167
+ }, "bottom-start", gap, viewportGap);
168
+ return;
169
+ }
170
+ if (!anchor)
171
+ return;
172
+ if (nativeAnchor)
173
+ positionNative();
174
+ else
175
+ fallbackPosition(surface, anchor.getBoundingClientRect(), placement, gap, viewportGap);
176
+ };
177
+ const schedule = () => {
178
+ if (!open || frame !== null)
179
+ return;
180
+ frame = owner.requestAnimationFrame(position);
181
+ };
182
+ const syncFallbackListeners = () => {
183
+ const needsListeners = open && (point !== null || !nativeAnchor);
184
+ if (!needsListeners) {
185
+ listenerAbort?.abort();
186
+ listenerAbort = null;
187
+ return;
188
+ }
189
+ if (listenerAbort)
190
+ return;
191
+ listenerAbort = new AbortController();
192
+ const signal = listenerAbort.signal;
193
+ owner.addEventListener("resize", schedule, { passive: true, signal });
194
+ owner.addEventListener("scroll", schedule, { passive: true, capture: true, signal });
195
+ owner.visualViewport?.addEventListener("resize", schedule, { passive: true, signal });
196
+ owner.visualViewport?.addEventListener("scroll", schedule, { passive: true, signal });
197
+ };
198
+ bindAnchor(anchor);
199
+ return {
200
+ setAnchor(next) {
201
+ point = null;
202
+ bindAnchor(next);
203
+ syncFallbackListeners();
204
+ schedule();
205
+ },
206
+ show() {
207
+ point = null;
208
+ open = true;
209
+ syncFallbackListeners();
210
+ showInTopLayer(surface);
211
+ position();
212
+ },
213
+ showAtPoint(nextPoint) {
214
+ point = nextPoint;
215
+ open = true;
216
+ syncFallbackListeners();
217
+ showInTopLayer(surface);
218
+ position();
219
+ },
220
+ hide() {
221
+ open = false;
222
+ point = null;
223
+ syncFallbackListeners();
224
+ if (frame !== null)
225
+ owner.cancelAnimationFrame(frame);
226
+ frame = null;
227
+ hideFromTopLayer(surface);
228
+ },
229
+ refresh: schedule,
230
+ destroy() {
231
+ open = false;
232
+ listenerAbort?.abort();
233
+ listenerAbort = null;
234
+ if (frame !== null)
235
+ owner.cancelAnimationFrame(frame);
236
+ frame = null;
237
+ hideFromTopLayer(surface);
238
+ bindAnchor(null);
239
+ }
240
+ };
241
+ }
242
+ function getVisualViewportRect(owner = window) {
243
+ const viewport = owner.visualViewport;
244
+ const left = viewport?.offsetLeft ?? 0;
245
+ const top = viewport?.offsetTop ?? 0;
246
+ const width = viewport?.width ?? owner.innerWidth;
247
+ const height = viewport?.height ?? owner.innerHeight;
248
+ return {
249
+ left,
250
+ top,
251
+ right: left + width,
252
+ bottom: top + height,
253
+ width,
254
+ height
255
+ };
256
+ }
257
+ function clampRectToViewport(rect, viewport = getVisualViewportRect(), gutter = 0) {
258
+ const availableWidth = Math.max(0, viewport.width - gutter * 2);
259
+ const availableHeight = Math.max(0, viewport.height - gutter * 2);
260
+ const targetLeft = rect.width > availableWidth ? viewport.left + gutter : Math.min(Math.max(rect.left, viewport.left + gutter), viewport.right - gutter - rect.width);
261
+ const targetTop = rect.height > availableHeight ? viewport.top + gutter : Math.min(Math.max(rect.top, viewport.top + gutter), viewport.bottom - gutter - rect.height);
262
+ return { x: targetLeft - rect.left, y: targetTop - rect.top };
263
+ }
32
264
  function distanceFromPointToRect(point, rect) {
33
265
  const dx = Math.max(rect.left - point.x, 0, point.x - rect.right);
34
266
  const dy = Math.max(rect.top - point.y, 0, point.y - rect.bottom);
@@ -123,11 +355,25 @@ function createProximityCoordinator(scope, options = {}) {
123
355
  }
124
356
  };
125
357
  }
126
- var DEFAULT_AFFORDANCE_NEAR_RADIUS, uiAffordanceScopeCss, UIAffordanceScope;
358
+ var DEFAULT_AFFORDANCE_NEAR_RADIUS, anchorSequence, anchorBindings;
359
+ var init_positioning_Bu0dmLBE = __esm({
360
+ "dist/esm/positioning-Bu0dmLBE.js"() {
361
+ DEFAULT_AFFORDANCE_NEAR_RADIUS = 16;
362
+ anchorSequence = 0;
363
+ anchorBindings = /* @__PURE__ */ new WeakMap();
364
+ }
365
+ });
366
+
367
+ // dist/esm/ui-affordance-scope.entry.js
368
+ var ui_affordance_scope_entry_exports = {};
369
+ __export(ui_affordance_scope_entry_exports, {
370
+ ui_affordance_scope: () => UIAffordanceScope
371
+ });
372
+ var uiAffordanceScopeCss, UIAffordanceScope;
127
373
  var init_ui_affordance_scope_entry = __esm({
128
374
  "dist/esm/ui-affordance-scope.entry.js"() {
129
375
  init_index_CEeiinfk();
130
- DEFAULT_AFFORDANCE_NEAR_RADIUS = 16;
376
+ init_positioning_Bu0dmLBE();
131
377
  uiAffordanceScopeCss = () => `:host{display:contents;--ui-affordance-scope-engaged:0}:host([data-ui-interaction='engaged']){--ui-affordance-scope-engaged:1}`;
132
378
  UIAffordanceScope = class {
133
379
  constructor(hostRef) {
@@ -496,7 +742,7 @@ var init_ui_checkbox_entry = __esm({
496
742
  }
497
743
  });
498
744
 
499
- // dist/esm/manager-CR7f2MQC.js
745
+ // dist/esm/manager-PM9a74r7.js
500
746
  function syncScrollLock() {
501
747
  if (typeof document === "undefined") {
502
748
  return;
@@ -525,8 +771,11 @@ function handleLightDismiss(event) {
525
771
  return;
526
772
  }
527
773
  const target = event.target;
528
- if (target instanceof Node && top.element.contains(target)) {
529
- return;
774
+ if (target instanceof Node) {
775
+ if (top.element.contains(target))
776
+ return;
777
+ if (top.relatedElements?.some((element) => element.contains(target)))
778
+ return;
530
779
  }
531
780
  requestTopOverlayClose("light-dismiss", "pointer");
532
781
  }
@@ -581,8 +830,8 @@ function requestTopOverlayClose(reason, trigger) {
581
830
  return true;
582
831
  }
583
832
  var stack, scrollLockAttribute, modalCount, listenersAttached;
584
- var init_manager_CR7f2MQC = __esm({
585
- "dist/esm/manager-CR7f2MQC.js"() {
833
+ var init_manager_PM9a74r7 = __esm({
834
+ "dist/esm/manager-PM9a74r7.js"() {
586
835
  stack = [];
587
836
  scrollLockAttribute = "data-ui-scroll-lock";
588
837
  modalCount = 0;
@@ -599,9 +848,10 @@ var uiContextMenuCss, UIContextMenu;
599
848
  var init_ui_context_menu_entry = __esm({
600
849
  "dist/esm/ui-context-menu.entry.js"() {
601
850
  init_index_CEeiinfk();
602
- init_manager_CR7f2MQC();
851
+ init_manager_PM9a74r7();
603
852
  init_events_JwSoedEO();
604
- uiContextMenuCss = () => `:host{display:contents}.menu{position:fixed;z-index:var(--ui-z-overlay, 1000);min-width:12rem}.menu[data-open]{display:block}.menu:not([data-open]){display:none !important}`;
853
+ init_positioning_Bu0dmLBE();
854
+ uiContextMenuCss = () => `:host{display:contents}.menu{position:fixed;inset:auto;margin:0;z-index:var(--ui-z-overlay, 1000);min-width:12rem;opacity:0;transform:translateY(-4px) scale(0.99);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease), transform var(--ui-motion-fast) var(--ui-motion-ease), display var(--ui-motion-fast) allow-discrete, overlay var(--ui-motion-fast) allow-discrete}.menu:popover-open{opacity:1;transform:translateY(0) scale(1)}@starting-style{.menu:popover-open{opacity:0;transform:translateY(-4px) scale(0.99)}}.menu[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){.menu{transition:none}}`;
605
855
  UIContextMenu = class {
606
856
  constructor(hostRef) {
607
857
  registerInstance(this, hostRef);
@@ -621,6 +871,8 @@ var init_ui_context_menu_entry = __esm({
621
871
  contextTarget = null;
622
872
  pointerX = 0;
623
873
  pointerY = 0;
874
+ pointPositioned = false;
875
+ surface = null;
624
876
  syncFromProp() {
625
877
  this.internalOpen = this.open;
626
878
  }
@@ -631,6 +883,11 @@ var init_ui_context_menu_entry = __esm({
631
883
  syncOverlay() {
632
884
  this.syncTriggerState();
633
885
  if (this.internalOpen) {
886
+ if (this.pointPositioned) {
887
+ this.surface?.showAtPoint({ x: this.pointerX, y: this.pointerY });
888
+ } else {
889
+ this.surface?.show();
890
+ }
634
891
  openOverlay({
635
892
  id: this.overlayId,
636
893
  modal: false,
@@ -639,6 +896,7 @@ var init_ui_context_menu_entry = __esm({
639
896
  requestClose: (reason, trigger) => this.closeMenu(reason, trigger)
640
897
  });
641
898
  } else {
899
+ this.surface?.hide();
642
900
  closeOverlay(this.overlayId);
643
901
  }
644
902
  }
@@ -647,18 +905,33 @@ var init_ui_context_menu_entry = __esm({
647
905
  this.internalOpen = this.internalOpen || this.defaultOpen;
648
906
  this.resolveTargets();
649
907
  this.attachTargetListeners();
908
+ this.setupSurface();
650
909
  this.syncTriggerState();
651
910
  this.syncOverlay();
652
911
  }
653
912
  componentDidUpdate() {
654
913
  this.resolveTargets();
655
914
  this.attachTargetListeners();
915
+ if (!this.pointPositioned)
916
+ this.surface?.setAnchor(this.trigger);
656
917
  this.syncTriggerState();
657
918
  }
658
919
  disconnectedCallback() {
659
920
  this.detachTargetListeners();
921
+ this.surface?.destroy();
922
+ this.surface = null;
660
923
  closeOverlay(this.overlayId);
661
924
  }
925
+ setupSurface() {
926
+ const menu = this.host.shadowRoot?.querySelector(".menu");
927
+ if (!menu)
928
+ return;
929
+ this.surface?.destroy();
930
+ this.surface = createAnchoredSurface(menu, {
931
+ anchor: this.trigger,
932
+ placement: "bottom-start"
933
+ });
934
+ }
662
935
  resolveTargets() {
663
936
  const previousTrigger = this.trigger;
664
937
  const previousContextTarget = this.contextTarget;
@@ -698,6 +971,8 @@ var init_ui_context_menu_entry = __esm({
698
971
  openMenu(x, y, trigger) {
699
972
  this.pointerX = x;
700
973
  this.pointerY = y;
974
+ this.pointPositioned = true;
975
+ this.surface?.showAtPoint({ x, y });
701
976
  this.internalOpen = true;
702
977
  dispatchDetail(this.host, "open", {
703
978
  open: true,
@@ -709,8 +984,14 @@ var init_ui_context_menu_entry = __esm({
709
984
  openFromTrigger(trigger) {
710
985
  if (!this.trigger)
711
986
  return;
712
- const rect = this.trigger.getBoundingClientRect();
713
- this.openMenu(rect.left, rect.bottom, trigger);
987
+ this.pointPositioned = false;
988
+ this.internalOpen = true;
989
+ dispatchDetail(this.host, "open", {
990
+ open: true,
991
+ reason: "action",
992
+ trigger
993
+ });
994
+ this.focusFirstItem();
714
995
  }
715
996
  closeMenu(reason, trigger, returnFocus = true) {
716
997
  if (!this.internalOpen)
@@ -776,7 +1057,7 @@ var init_ui_context_menu_entry = __esm({
776
1057
  this.closeMenu("action", "pointer");
777
1058
  };
778
1059
  render() {
779
- return h(Host, { key: "79fbca2c89f1d1fd1f4796ad88d2a599e811a3f9", "data-open": this.internalOpen ? "" : void 0, onKeyDown: this.onKeydown, onClick: this.onItemClick }, h("slot", { key: "9308cadfa155930e3e46dfb4a69a847ae388958b", name: "trigger" }), h("div", { key: "16cfba2b32444ac9e3cac1f040f81f17fd5db23c", class: "menu", "data-open": this.internalOpen ? "" : void 0, style: { left: `${this.pointerX}px`, top: `${this.pointerY}px` } }, h("ui-menu", { key: "59f18e0df3bb1fe85efa8eeca00b336bbde47c70", open: this.internalOpen }, h("slot", { key: "5bdbb7773c9c1ae43ec2e05fca9558482815e28a" }))));
1060
+ return h(Host, { key: "aee76fad23434fb3cdaf885c698f62237c2a9468", "data-open": this.internalOpen ? "" : void 0, onKeyDown: this.onKeydown, onClick: this.onItemClick }, h("slot", { key: "da047f870b7a93f1acbba5fa1628b5cb66139d99", name: "trigger" }), h("div", { key: "388a473ac7fb626a20d0feda14f0d8dd16f6ab94", class: "menu", "data-open": this.internalOpen ? "" : void 0 }, h("ui-menu", { key: "67ca5c05ff40d2dd1d5f17a8634636503f98c02d", open: this.internalOpen }, h("slot", { key: "b7c7dfac4342afa1df67459e94de7ac7dca4a251" }))));
780
1061
  }
781
1062
  static get watchers() {
782
1063
  return {
@@ -805,7 +1086,7 @@ var uiDialogCss, UIDialog;
805
1086
  var init_ui_dialog_entry = __esm({
806
1087
  "dist/esm/ui-dialog.entry.js"() {
807
1088
  init_index_CEeiinfk();
808
- init_manager_CR7f2MQC();
1089
+ init_manager_PM9a74r7();
809
1090
  init_events_JwSoedEO();
810
1091
  uiDialogCss = () => `:host{display:block}:host:not([data-open]){display:none}:host dialog{--ui-dialog-duration:var(--ui-motion-base);--ui-dialog-viewport-gap:var(--ui-space-4, 1rem);position:fixed;inset:0;inline-size:min( calc(100% - (var(--ui-dialog-viewport-gap) * 2)), var(--ui-dialog-max-width, 440px) );max-inline-size:none;max-block-size:calc(100dvh - (var(--ui-dialog-viewport-gap) * 2));margin:auto;padding:var(--ui-space-4);overflow:auto;background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-dialog);box-shadow:var(--ui-shadow-dialog);visibility:hidden;pointer-events:none;opacity:0;transform:scale(0.96);transition:opacity var(--ui-dialog-duration) var(--ui-motion-ease), transform var(--ui-dialog-duration) var(--ui-motion-ease), visibility var(--ui-dialog-duration), display var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete, overlay var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete}:host dialog[open]{visibility:visible;pointer-events:auto;opacity:1;transform:scale(1);animation:ui-dialog-enter var(--ui-dialog-duration) var(--ui-motion-ease)}@keyframes ui-dialog-enter{from{opacity:0;transform:scale(0.96)}}:host dialog::backdrop{background-color:transparent;transition:background-color var(--ui-dialog-duration) var(--ui-motion-ease), display var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete, overlay var(--ui-dialog-duration) var(--ui-motion-ease) allow-discrete}:host dialog[open]::backdrop{background-color:var(--ui-overlay-backdrop);animation:ui-dialog-backdrop-enter var(--ui-dialog-duration) var(--ui-motion-ease)}@keyframes ui-dialog-backdrop-enter{from{background-color:transparent}}`;
811
1092
  UIDialog = class {
@@ -1289,7 +1570,9 @@ var init_ui_menu_entry = __esm({
1289
1570
  "dist/esm/ui-menu.entry.js"() {
1290
1571
  init_index_CEeiinfk();
1291
1572
  init_events_JwSoedEO();
1292
- uiMenuCss = () => `:host{--ui-menu-viewport-gap:var(--ui-space-2, 0.5rem);display:flex;flex-direction:column;inline-size:max-content;min-inline-size:min(12rem, calc(100vw - (var(--ui-menu-viewport-gap) * 2)));max-inline-size:calc(100vw - (var(--ui-menu-viewport-gap) * 2));padding:var(--ui-space-1);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg)}::slotted(ui-menu-item){display:block;width:100%;padding:var(--ui-space-2) var(--ui-space-3);text-align:left;background:none;border:none;border-radius:var(--ui-radius-2);color:var(--ui-text-primary);font-size:var(--ui-font-size-md);font-weight:var(--ui-font-medium, 500);cursor:pointer;transition:background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease)}::slotted(ui-menu-item:hover:not([aria-disabled='true']):not([disabled])){background:var(--ui-surface-subtle)}::slotted(ui-menu-item[aria-disabled='true']),::slotted(ui-menu-item[disabled]){opacity:0.6;cursor:not-allowed}`;
1573
+ init_manager_PM9a74r7();
1574
+ init_positioning_Bu0dmLBE();
1575
+ uiMenuCss = () => `:host{--ui-menu-viewport-gap:var(--ui-space-2, 0.5rem);display:flex;flex-direction:column;inline-size:max-content;min-inline-size:min(12rem, calc(100vw - (var(--ui-menu-viewport-gap) * 2)));max-inline-size:calc(100vw - (var(--ui-menu-viewport-gap) * 2));padding:var(--ui-space-1);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg)}:host(:not([data-open])){display:none}:host([popover]){position:fixed;inset:auto;margin:0;overflow:auto;max-block-size:calc(100dvh - (var(--ui-menu-viewport-gap) * 2));opacity:0;transform:translateY(-4px) scale(0.99);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease), transform var(--ui-motion-fast) var(--ui-motion-ease), display var(--ui-motion-fast) allow-discrete, overlay var(--ui-motion-fast) allow-discrete}:host([popover]:popover-open){opacity:1;transform:translateY(0) scale(1)}@starting-style{:host([popover]:popover-open){opacity:0;transform:translateY(-4px) scale(0.99)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host([popover]){transition:none}}::slotted(ui-menu-item){display:block;width:100%;padding:var(--ui-space-2) var(--ui-space-3);text-align:left;background:none;border:none;border-radius:var(--ui-radius-2);color:var(--ui-text-primary);font-size:var(--ui-font-size-md);font-weight:var(--ui-font-medium, 500);cursor:pointer;transition:background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease)}::slotted(ui-menu-item:hover:not([aria-disabled='true']):not([disabled])){background:var(--ui-surface-subtle)}::slotted(ui-menu-item[aria-disabled='true']),::slotted(ui-menu-item[disabled]){opacity:0.6;cursor:not-allowed}`;
1293
1576
  UIMenu = class {
1294
1577
  constructor(hostRef) {
1295
1578
  registerInstance(this, hostRef);
@@ -1299,19 +1582,83 @@ var init_ui_menu_entry = __esm({
1299
1582
  }
1300
1583
  open = false;
1301
1584
  defaultOpen = false;
1585
+ /** Id of the control that anchors this menu in the top layer. */
1586
+ for;
1587
+ /** Preferred placement; Looma flips and shifts when space is constrained. */
1588
+ placement = "bottom-start";
1302
1589
  internalOpen = false;
1590
+ overlayId = `ui-menu-${Math.random().toString(36).slice(2, 11)}`;
1591
+ anchor = null;
1592
+ surface = null;
1303
1593
  syncFromProp() {
1304
1594
  this.internalOpen = this.open;
1305
1595
  }
1596
+ resetSurface() {
1597
+ this.setupSurface();
1598
+ this.syncSurface();
1599
+ }
1600
+ syncSurface() {
1601
+ this.syncAnchorState();
1602
+ if (!this.surface)
1603
+ return;
1604
+ if (this.internalOpen) {
1605
+ this.surface.show();
1606
+ openOverlay({
1607
+ id: this.overlayId,
1608
+ modal: false,
1609
+ element: this.host,
1610
+ relatedElements: this.anchor ? [this.anchor] : void 0,
1611
+ dismissible: true,
1612
+ requestClose: (reason, trigger) => this.closeMenu(reason, trigger)
1613
+ });
1614
+ } else {
1615
+ this.surface.hide();
1616
+ closeOverlay(this.overlayId);
1617
+ }
1618
+ }
1306
1619
  componentDidLoad() {
1307
1620
  this.syncFromProp();
1308
1621
  this.internalOpen = this.internalOpen || this.defaultOpen;
1309
1622
  this.host.addEventListener("click", this.onItemClick);
1310
1623
  this.host.addEventListener("keydown", this.onKeydown);
1624
+ this.setupSurface();
1625
+ this.syncSurface();
1311
1626
  }
1312
1627
  disconnectedCallback() {
1313
1628
  this.host.removeEventListener("click", this.onItemClick);
1314
1629
  this.host.removeEventListener("keydown", this.onKeydown);
1630
+ this.surface?.destroy();
1631
+ this.surface = null;
1632
+ closeOverlay(this.overlayId);
1633
+ }
1634
+ setupSurface() {
1635
+ this.surface?.destroy();
1636
+ this.surface = null;
1637
+ this.anchor = this.for ? this.host.ownerDocument.getElementById(this.for) : null;
1638
+ if (!this.anchor)
1639
+ return;
1640
+ this.surface = createAnchoredSurface(this.host, {
1641
+ anchor: this.anchor,
1642
+ placement: this.placement
1643
+ });
1644
+ }
1645
+ syncAnchorState() {
1646
+ if (!this.anchor)
1647
+ return;
1648
+ this.anchor.setAttribute("aria-haspopup", "menu");
1649
+ this.anchor.setAttribute("aria-expanded", this.internalOpen ? "true" : "false");
1650
+ }
1651
+ closeMenu(reason, trigger) {
1652
+ if (!this.internalOpen)
1653
+ return;
1654
+ this.internalOpen = false;
1655
+ dispatchDetail(this.host, "close", {
1656
+ open: false,
1657
+ reason,
1658
+ trigger
1659
+ });
1660
+ if (reason === "escape")
1661
+ this.anchor?.focus();
1315
1662
  }
1316
1663
  getItems() {
1317
1664
  return Array.from(this.host.querySelectorAll("ui-menu-item"));
@@ -1335,6 +1682,11 @@ var init_ui_menu_entry = __esm({
1335
1682
  this.internalOpen = false;
1336
1683
  };
1337
1684
  onKeydown = (e) => {
1685
+ if (e.key === "Escape") {
1686
+ e.preventDefault();
1687
+ requestTopOverlayClose("escape", "keyboard");
1688
+ return;
1689
+ }
1338
1690
  const items = this.getItems().filter((i) => !this.isItemDisabled(i));
1339
1691
  if (items.length === 0)
1340
1692
  return;
@@ -1361,12 +1713,21 @@ var init_ui_menu_entry = __esm({
1361
1713
  }
1362
1714
  };
1363
1715
  render() {
1364
- return h(Host, { key: "5e463cbbce272c6b6132a839b818deef3e39a532", role: "menu", "aria-orientation": "vertical", "data-open": this.internalOpen ? "" : void 0 }, h("slot", { key: "feea6a21d41a7b27a6270814bcf0b3f3ded394a1" }));
1716
+ return h(Host, { key: "06ad0750df843cb874bd4f257d8567157c855493", role: "menu", "aria-orientation": "vertical", "data-open": this.internalOpen ? "" : void 0 }, h("slot", { key: "50118ac749a2747ca06f4d483499c4cd20125a89" }));
1365
1717
  }
1366
1718
  static get watchers() {
1367
1719
  return {
1368
1720
  "open": [{
1369
1721
  "syncFromProp": 0
1722
+ }],
1723
+ "for": [{
1724
+ "resetSurface": 0
1725
+ }],
1726
+ "placement": [{
1727
+ "resetSurface": 0
1728
+ }],
1729
+ "internalOpen": [{
1730
+ "syncSurface": 0
1370
1731
  }]
1371
1732
  };
1372
1733
  }
@@ -1384,9 +1745,10 @@ var uiPopoverCss, UIPopover;
1384
1745
  var init_ui_popover_entry = __esm({
1385
1746
  "dist/esm/ui-popover.entry.js"() {
1386
1747
  init_index_CEeiinfk();
1387
- init_manager_CR7f2MQC();
1748
+ init_manager_PM9a74r7();
1388
1749
  init_events_JwSoedEO();
1389
- uiPopoverCss = () => `:host{--ui-popover-viewport-gap:var(--ui-space-2, 0.5rem);padding:var(--ui-space-3);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg);max-inline-size:min( 20rem, calc(100vw - (var(--ui-popover-viewport-gap) * 2)) );max-block-size:calc(100dvh - (var(--ui-popover-viewport-gap) * 2));overflow:auto}`;
1750
+ init_positioning_Bu0dmLBE();
1751
+ uiPopoverCss = () => `:host{--ui-popover-viewport-gap:var(--ui-space-2, 0.5rem);padding:var(--ui-space-3);background:var(--ui-surface-elevated);border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);box-shadow:var(--ui-shadow-lg);max-inline-size:min( 20rem, calc(100vw - (var(--ui-popover-viewport-gap) * 2)) );max-block-size:calc(100dvh - (var(--ui-popover-viewport-gap) * 2));overflow:auto}:host(:not([data-open])){display:none}:host([popover]){position:fixed;inset:auto;margin:0;opacity:0;transform:translateY(-4px) scale(0.99);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease), transform var(--ui-motion-fast) var(--ui-motion-ease), display var(--ui-motion-fast) allow-discrete, overlay var(--ui-motion-fast) allow-discrete}:host([popover]:popover-open){opacity:1;transform:translateY(0) scale(1)}@starting-style{:host([popover]:popover-open){opacity:0;transform:translateY(-4px) scale(0.99)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host([popover]){transition:none}}`;
1390
1752
  UIPopover = class {
1391
1753
  constructor(hostRef) {
1392
1754
  registerInstance(this, hostRef);
@@ -1396,8 +1758,13 @@ var init_ui_popover_entry = __esm({
1396
1758
  }
1397
1759
  open = false;
1398
1760
  defaultOpen = false;
1761
+ /** Optional id of the element this popover follows in the top layer. */
1762
+ for;
1763
+ placement = "bottom-start";
1399
1764
  internalOpen = false;
1400
1765
  overlayId = `ui-popover-${Math.random().toString(36).slice(2, 11)}`;
1766
+ anchor = null;
1767
+ surface = null;
1401
1768
  syncFromProp() {
1402
1769
  this.internalOpen = this.open;
1403
1770
  }
@@ -1417,12 +1784,37 @@ var init_ui_popover_entry = __esm({
1417
1784
  });
1418
1785
  }
1419
1786
  }
1787
+ resetSurface() {
1788
+ this.setupSurface();
1789
+ this.syncSurface();
1790
+ }
1791
+ setupSurface() {
1792
+ this.surface?.destroy();
1793
+ this.surface = null;
1794
+ this.anchor = this.for ? this.host.ownerDocument.getElementById(this.for) : null;
1795
+ if (!this.anchor)
1796
+ return;
1797
+ this.surface = createAnchoredSurface(this.host, {
1798
+ anchor: this.anchor,
1799
+ placement: this.placement
1800
+ });
1801
+ }
1802
+ syncSurface() {
1803
+ if (!this.surface)
1804
+ return;
1805
+ if (this.internalOpen)
1806
+ this.surface.show();
1807
+ else
1808
+ this.surface.hide();
1809
+ }
1420
1810
  syncOverlay() {
1811
+ this.syncSurface();
1421
1812
  if (this.internalOpen) {
1422
1813
  openOverlay({
1423
1814
  id: this.overlayId,
1424
1815
  modal: false,
1425
1816
  element: this.host,
1817
+ relatedElements: this.anchor ? [this.anchor] : void 0,
1426
1818
  dismissible: true,
1427
1819
  requestClose: (reason, trigger) => this.handleRequestClose(reason, trigger)
1428
1820
  });
@@ -1434,10 +1826,13 @@ var init_ui_popover_entry = __esm({
1434
1826
  this.syncFromProp();
1435
1827
  this.internalOpen = this.internalOpen || this.defaultOpen;
1436
1828
  this.host.addEventListener("keydown", this.onKeydown);
1829
+ this.setupSurface();
1437
1830
  this.syncOverlay();
1438
1831
  }
1439
1832
  disconnectedCallback() {
1440
1833
  this.host.removeEventListener("keydown", this.onKeydown);
1834
+ this.surface?.destroy();
1835
+ this.surface = null;
1441
1836
  closeOverlay(this.overlayId);
1442
1837
  }
1443
1838
  componentDidUpdate() {
@@ -1457,7 +1852,7 @@ var init_ui_popover_entry = __esm({
1457
1852
  }
1458
1853
  };
1459
1854
  render() {
1460
- return h(Host, { key: "67e7f52220db9d997fb11b686d6abcbdf9557a8d", "data-open": this.internalOpen ? "" : void 0, onKeyDown: this.onKeydown }, h("slot", { key: "d7c1fa2ab75994fe0a7dd63f8289754c7754c30f" }));
1855
+ return h(Host, { key: "8e45be54147ff8f76a0d5e7fd875c3f4cf5ac40a", "data-open": this.internalOpen ? "" : void 0, onKeyDown: this.onKeydown }, h("slot", { key: "3141729cd32c8dcdaec1fbd763eb034242563c8f" }));
1461
1856
  }
1462
1857
  static get watchers() {
1463
1858
  return {
@@ -1466,6 +1861,12 @@ var init_ui_popover_entry = __esm({
1466
1861
  }],
1467
1862
  "internalOpen": [{
1468
1863
  "onOpenChange": 0
1864
+ }],
1865
+ "for": [{
1866
+ "resetSurface": 0
1867
+ }],
1868
+ "placement": [{
1869
+ "resetSurface": 0
1469
1870
  }]
1470
1871
  };
1471
1872
  }
@@ -2234,7 +2635,8 @@ var init_ui_toast_region_entry = __esm({
2234
2635
  "dist/esm/ui-toast-region.entry.js"() {
2235
2636
  init_index_CEeiinfk();
2236
2637
  init_events_JwSoedEO();
2237
- uiToastRegionCss = () => `:host{position:fixed;top:calc(var(--ui-space-4) + env(safe-area-inset-top));left:50%;transform:translateX(-50%);z-index:9999;display:grid;gap:var(--ui-space-2);inline-size:min(24rem, calc(100vw - (var(--ui-space-4) * 2)));max-inline-size:100%;pointer-events:none}:host>*{pointer-events:auto}::slotted([data-ui-toast]){display:grid;grid-template-columns:1fr auto;gap:var(--ui-space-2);align-items:start;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);padding:var(--ui-space-3) var(--ui-space-4);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-lg);animation:ui-toast-enter 0.25s var(--ui-motion-ease) forwards}@keyframes ui-toast-enter{from{opacity:0;transform:translateY(-0.5rem)}to{opacity:1;transform:translateY(0)}}::slotted([data-ui-toast][aria-hidden='true']){display:none}::slotted([data-ui-toast-dismiss]){border:0;background:transparent;color:var(--ui-text-secondary);cursor:pointer;font:inherit}`;
2638
+ init_positioning_Bu0dmLBE();
2639
+ uiToastRegionCss = () => `:host{position:fixed;top:calc(var(--ui-space-4) + env(safe-area-inset-top));left:50%;transform:translateX(-50%);z-index:9999;display:grid;gap:var(--ui-space-2);inline-size:min(24rem, calc(100vw - (var(--ui-space-4) * 2)));max-inline-size:100%;pointer-events:none}:host([popover]){right:auto;bottom:auto;margin:0}:host>*{pointer-events:auto}::slotted([data-ui-toast]){display:grid;grid-template-columns:1fr auto;gap:var(--ui-space-2);align-items:start;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-3);padding:var(--ui-space-3) var(--ui-space-4);background:var(--ui-surface-elevated);color:var(--ui-text-primary);box-shadow:var(--ui-shadow-lg);animation:ui-toast-enter 0.25s var(--ui-motion-ease) forwards}@keyframes ui-toast-enter{from{opacity:0;transform:translateY(-0.5rem)}to{opacity:1;transform:translateY(0)}}::slotted([data-ui-toast][aria-hidden='true']){display:none}::slotted([data-ui-toast-dismiss]){border:0;background:transparent;color:var(--ui-text-secondary);cursor:pointer;font:inherit}`;
2238
2640
  UIToastRegion = class {
2239
2641
  constructor(hostRef) {
2240
2642
  registerInstance(this, hostRef);
@@ -2244,15 +2646,26 @@ var init_ui_toast_region_entry = __esm({
2244
2646
  }
2245
2647
  open = true;
2246
2648
  internalOpen = true;
2649
+ surface = null;
2247
2650
  syncFromProp() {
2248
2651
  this.internalOpen = this.open;
2249
2652
  }
2653
+ syncSurface() {
2654
+ if (this.internalOpen)
2655
+ this.surface?.show();
2656
+ else
2657
+ this.surface?.hide();
2658
+ }
2250
2659
  componentDidLoad() {
2660
+ this.surface = createViewportSurface(this.host);
2251
2661
  this.syncFromProp();
2662
+ this.syncSurface();
2252
2663
  this.host.addEventListener("click", this.onClick);
2253
2664
  }
2254
2665
  disconnectedCallback() {
2255
2666
  this.host.removeEventListener("click", this.onClick);
2667
+ this.surface?.destroy();
2668
+ this.surface = null;
2256
2669
  }
2257
2670
  getToasts() {
2258
2671
  return Array.from(this.host.querySelectorAll("[data-ui-toast]"));
@@ -2286,12 +2699,15 @@ var init_ui_toast_region_entry = __esm({
2286
2699
  }
2287
2700
  };
2288
2701
  render() {
2289
- return h(Host, { key: "0edcce54864ba991b092d004d3b45cf697b9c3ac", role: "region", "aria-label": "Notifications", "data-open": this.internalOpen ? "" : void 0 }, h("slot", { key: "2e30794a05b018fb55c4313c8e17f7262ecee7da" }));
2702
+ return h(Host, { key: "693e24016ec0881a4d619a489f1b655feee41784", role: "region", "aria-label": "Notifications", "data-open": this.internalOpen ? "" : void 0 }, h("slot", { key: "e666b2a73a5d7eb8dd607df3d1c5135b78cf3775" }));
2290
2703
  }
2291
2704
  static get watchers() {
2292
2705
  return {
2293
2706
  "open": [{
2294
2707
  "syncFromProp": 0
2708
+ }],
2709
+ "internalOpen": [{
2710
+ "syncSurface": 0
2295
2711
  }]
2296
2712
  };
2297
2713
  }
@@ -2309,9 +2725,10 @@ var uiTooltipCss, UITooltip;
2309
2725
  var init_ui_tooltip_entry = __esm({
2310
2726
  "dist/esm/ui-tooltip.entry.js"() {
2311
2727
  init_index_CEeiinfk();
2312
- init_manager_CR7f2MQC();
2728
+ init_manager_PM9a74r7();
2313
2729
  init_events_JwSoedEO();
2314
- uiTooltipCss = () => `:host{display:inline-block;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);padding:var(--ui-space-2) var(--ui-space-3);font-size:var(--ui-font-size-sm);box-shadow:var(--ui-shadow-md)}:host([hidden]){display:none !important}`;
2730
+ init_positioning_Bu0dmLBE();
2731
+ uiTooltipCss = () => `:host{position:fixed;inset:auto;margin:0;display:inline-block;border:1px solid var(--ui-border-default);border-radius:var(--ui-radius-2);background:var(--ui-surface-elevated);color:var(--ui-text-primary);padding:var(--ui-space-2) var(--ui-space-3);font-size:var(--ui-font-size-sm);box-shadow:var(--ui-shadow-md);opacity:0;transform:translateY(4px);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease), transform var(--ui-motion-fast) var(--ui-motion-ease), display var(--ui-motion-fast) allow-discrete, overlay var(--ui-motion-fast) allow-discrete}:host(:popover-open){opacity:1;transform:translateY(0)}@starting-style{:host(:popover-open){opacity:0;transform:translateY(4px)}}:host([hidden]){display:none !important}@media (prefers-reduced-motion: reduce){:host{transition:none}}`;
2315
2732
  UITooltip = class {
2316
2733
  constructor(hostRef) {
2317
2734
  registerInstance(this, hostRef);
@@ -2322,49 +2739,76 @@ var init_ui_tooltip_entry = __esm({
2322
2739
  for = "";
2323
2740
  open = false;
2324
2741
  defaultOpen = false;
2742
+ placement = "top-start";
2743
+ /** Pointer hover intent delay in milliseconds. Keyboard focus is immediate. */
2744
+ showDelay = 500;
2745
+ /** Pointer leave grace period in milliseconds. */
2746
+ hideDelay = 100;
2325
2747
  internalOpen = false;
2326
2748
  overlayId = `ui-tooltip-${Math.random().toString(36).slice(2, 11)}`;
2327
2749
  trigger = null;
2750
+ surface = null;
2751
+ showTimer = null;
2752
+ hideTimer = null;
2328
2753
  syncFromProp() {
2754
+ this.clearTimers();
2329
2755
  this.internalOpen = this.open;
2330
2756
  }
2757
+ resetSurface() {
2758
+ this.syncTrigger();
2759
+ this.setupSurface();
2760
+ this.syncOverlay();
2761
+ }
2331
2762
  syncOverlay() {
2332
2763
  if (this.internalOpen) {
2764
+ this.surface?.show();
2333
2765
  openOverlay({
2334
2766
  id: this.overlayId,
2335
2767
  modal: false,
2336
2768
  element: this.host,
2769
+ relatedElements: this.trigger ? [this.trigger] : void 0,
2337
2770
  dismissible: true,
2338
2771
  requestClose: (reason, trigger) => this.handleRequestClose(reason, trigger)
2339
2772
  });
2340
2773
  } else {
2774
+ this.surface?.hide();
2341
2775
  closeOverlay(this.overlayId);
2342
2776
  }
2343
2777
  }
2344
2778
  componentDidLoad() {
2345
2779
  this.syncFromProp();
2346
2780
  this.internalOpen = this.internalOpen || this.defaultOpen;
2347
- this.resolveTrigger();
2348
- this.attachTriggerListeners();
2781
+ this.syncTrigger();
2782
+ this.setupSurface();
2349
2783
  this.host.addEventListener("keydown", this.onKeydown);
2350
2784
  this.syncOverlay();
2351
2785
  }
2352
2786
  componentDidUpdate() {
2353
- this.resolveTrigger();
2354
- this.attachTriggerListeners();
2355
- this.syncOverlay();
2787
+ this.syncTrigger();
2356
2788
  }
2357
2789
  disconnectedCallback() {
2790
+ this.clearTimers();
2358
2791
  this.detachTriggerListeners();
2792
+ this.surface?.destroy();
2793
+ this.surface = null;
2359
2794
  this.host.removeEventListener("keydown", this.onKeydown);
2360
2795
  closeOverlay(this.overlayId);
2361
2796
  }
2362
- resolveTrigger() {
2363
- if (this.for) {
2364
- this.trigger = document.getElementById(this.for);
2365
- } else {
2366
- this.trigger = this.host.previousElementSibling;
2367
- }
2797
+ syncTrigger() {
2798
+ const next = this.for ? this.host.ownerDocument.getElementById(this.for) : this.host.previousElementSibling;
2799
+ if (next === this.trigger)
2800
+ return;
2801
+ this.detachTriggerListeners();
2802
+ this.trigger = next;
2803
+ this.attachTriggerListeners();
2804
+ this.surface?.setAnchor(next);
2805
+ }
2806
+ setupSurface() {
2807
+ this.surface?.destroy();
2808
+ this.surface = createAnchoredSurface(this.host, {
2809
+ anchor: this.trigger,
2810
+ placement: this.placement
2811
+ });
2368
2812
  }
2369
2813
  attachTriggerListeners() {
2370
2814
  this.detachTriggerListeners();
@@ -2383,31 +2827,64 @@ var init_ui_tooltip_entry = __esm({
2383
2827
  this.trigger.removeEventListener("focusin", this.onTriggerFocusIn);
2384
2828
  this.trigger.removeEventListener("focusout", this.onTriggerFocusOut);
2385
2829
  }
2830
+ clearShowTimer() {
2831
+ if (this.showTimer === null)
2832
+ return;
2833
+ clearTimeout(this.showTimer);
2834
+ this.showTimer = null;
2835
+ }
2836
+ clearHideTimer() {
2837
+ if (this.hideTimer === null)
2838
+ return;
2839
+ clearTimeout(this.hideTimer);
2840
+ this.hideTimer = null;
2841
+ }
2842
+ clearTimers() {
2843
+ this.clearShowTimer();
2844
+ this.clearHideTimer();
2845
+ }
2846
+ setInteractionOpen(nextOpen, trigger) {
2847
+ if (this.internalOpen === nextOpen)
2848
+ return;
2849
+ this.internalOpen = nextOpen;
2850
+ dispatchDetail(this.host, nextOpen ? "open" : "close", {
2851
+ open: nextOpen,
2852
+ reason: "action",
2853
+ trigger
2854
+ });
2855
+ }
2386
2856
  onTriggerEnter = () => {
2387
- this.internalOpen = true;
2388
- dispatchDetail(this.host, "open", { open: true, reason: "action", trigger: "pointer" });
2389
- this.syncOverlay();
2857
+ this.clearHideTimer();
2858
+ if (this.internalOpen || this.showTimer !== null)
2859
+ return;
2860
+ this.showTimer = setTimeout(() => {
2861
+ this.showTimer = null;
2862
+ this.setInteractionOpen(true, "pointer");
2863
+ }, Math.max(0, this.showDelay));
2390
2864
  };
2391
2865
  onTriggerLeave = () => {
2392
- this.internalOpen = false;
2393
- dispatchDetail(this.host, "close", { open: false, reason: "action", trigger: "pointer" });
2394
- this.syncOverlay();
2866
+ this.clearShowTimer();
2867
+ if (!this.internalOpen || this.hideTimer !== null)
2868
+ return;
2869
+ this.hideTimer = setTimeout(() => {
2870
+ this.hideTimer = null;
2871
+ this.setInteractionOpen(false, "pointer");
2872
+ }, Math.max(0, this.hideDelay));
2395
2873
  };
2396
2874
  onTriggerFocusIn = () => {
2397
- this.internalOpen = true;
2398
- dispatchDetail(this.host, "open", { open: true, reason: "action", trigger: "keyboard" });
2399
- this.syncOverlay();
2875
+ this.clearTimers();
2876
+ this.setInteractionOpen(true, "keyboard");
2400
2877
  };
2401
2878
  onTriggerFocusOut = (e) => {
2402
2879
  const related = e.relatedTarget;
2403
2880
  if (related && this.host.contains(related))
2404
2881
  return;
2405
- this.internalOpen = false;
2406
- dispatchDetail(this.host, "close", { open: false, reason: "action", trigger: "keyboard" });
2407
- this.syncOverlay();
2882
+ this.clearTimers();
2883
+ this.setInteractionOpen(false, "keyboard");
2408
2884
  };
2409
2885
  handleRequestClose(reason, trigger) {
2410
2886
  if (reason === "escape") {
2887
+ this.clearTimers();
2411
2888
  this.internalOpen = false;
2412
2889
  dispatchDetail(this.host, "close", {
2413
2890
  open: false,
@@ -2423,13 +2900,19 @@ var init_ui_tooltip_entry = __esm({
2423
2900
  }
2424
2901
  };
2425
2902
  render() {
2426
- return h(Host, { key: "64b5f4e7a56cbf5560edc6d7118022a49d5e2786", role: "tooltip", hidden: !this.internalOpen, "data-open": this.internalOpen ? "" : void 0, onKeyDown: this.onKeydown }, h("slot", { key: "cf6f96689021a42a01b782f0e1d0730b5a9aa1f8" }));
2903
+ return h(Host, { key: "4c3890a7371508ede06a5b370d1cec32db25280f", role: "tooltip", hidden: !this.internalOpen, "data-open": this.internalOpen ? "" : void 0, onKeyDown: this.onKeydown }, h("slot", { key: "2e3bcd0dc69b0c3e3376d73dc4efc82e4f4cfaaa" }));
2427
2904
  }
2428
2905
  static get watchers() {
2429
2906
  return {
2430
2907
  "open": [{
2431
2908
  "syncFromProp": 0
2432
2909
  }],
2910
+ "for": [{
2911
+ "resetSurface": 0
2912
+ }],
2913
+ "placement": [{
2914
+ "resetSurface": 0
2915
+ }],
2433
2916
  "internalOpen": [{
2434
2917
  "syncOverlay": 0
2435
2918
  }]
@@ -2775,7 +3258,7 @@ var init_ui_tree_item_entry = __esm({
2775
3258
  underline: Underline,
2776
3259
  undo: Undo2
2777
3260
  };
2778
- uiTreeItemCss = () => `:host{--ui-tree-indent:16px;--ui-tree-row-min-height:44px;--ui-tree-drop-color:var(--ui-accent-solid);position:relative;display:block;min-inline-size:0;margin-inline-start:calc(var(--ui-tree-item-depth, 0) * var(--ui-tree-indent))}.row{position:relative;display:grid;grid-template-columns:20px auto minmax(0, 1fr) auto;align-items:center;min-block-size:var(--ui-tree-row-min-height);min-inline-size:0;border-radius:var(--ui-radius-md);color:var(--ui-text-secondary);transition:background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease), opacity var(--ui-motion-fast) var(--ui-motion-ease), box-shadow var(--ui-motion-fast) var(--ui-motion-ease)}.row:hover,:host([data-selected]) .row,.row:focus-within{color:var(--ui-text-primary);background:var(--ui-surface-muted)}:host([data-disabled]) .row{opacity:0.55}:host([data-dragging]) .row{opacity:0.42}:host(:focus){outline:none}:host(:focus-visible) .row{box-shadow:0 0 0 2px var(--ui-focus-ring)}:host([data-drop-position='inside']) .row{background:var(--ui-accent-subtle);box-shadow:inset 0 0 0 1px var(--ui-tree-drop-color)}.disclosure,.disclosure-spacer{grid-column:1;grid-row:1;inline-size:20px;block-size:28px}.disclosure{display:grid;place-items:center;padding:0;color:var(--ui-text-muted);background:transparent;border:0;border-radius:var(--ui-radius-sm);cursor:pointer}.disclosure:hover{color:var(--ui-text-primary);background:var(--ui-surface-elevated)}.disclosure-icon{display:block;inline-size:14px;block-size:14px;transform:rotate(-90deg);transition:transform var(--ui-motion-fast) var(--ui-motion-ease)}.disclosure-icon--expanded{transform:rotate(0deg)}.disclosure-icon :is(svg),.drag-handle :is(svg){display:block;inline-size:100%;block-size:100%}.leading{display:none}.leading:has(*){display:inline-grid;place-items:center;grid-column:2;grid-row:1;inline-size:16px;block-size:16px;margin-inline-start:var(--ui-space-1)}.label{grid-column:3;grid-row:1;min-inline-size:0;padding:var(--ui-space-1) var(--ui-space-2)}.actions{grid-column:4;grid-row:1;display:inline-flex;align-items:center;min-inline-size:0}.drag-handle{position:absolute;z-index:2;inset-block-start:50%;inset-inline-start:-22px;inline-size:20px;block-size:32px;display:grid;place-items:center;padding:7px 3px;color:var(--ui-text-muted);background:var(--ui-surface-elevated);border:1px solid transparent;border-radius:var(--ui-radius-sm);cursor:grab;opacity:0;pointer-events:none;transform:translateY(-50%);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease)}.row:hover .drag-handle,.drag-handle:focus-visible,:host([data-dragging]) .drag-handle{opacity:1;pointer-events:auto}.drag-handle:active{cursor:grabbing}.drop-indicator{position:absolute;z-index:3;inset-inline:1px;display:none;block-size:2px;border-radius:999px;background:var(--ui-tree-drop-color);pointer-events:none}.drop-indicator::before,.drop-indicator::after{content:'';position:absolute;inset-block-start:50%;inline-size:7px;block-size:7px;border:2px solid var(--ui-tree-drop-color);border-radius:999px;background:var(--ui-surface-elevated);transform:translateY(-50%)}.drop-indicator::before{inset-inline-start:-1px}.drop-indicator::after{inset-inline-end:-1px}:host([data-drop-position='before']) .drop-indicator{display:block;inset-block-start:-1px}:host([data-drop-position='after']) .drop-indicator{display:block;inset-block-end:-1px}.children[hidden]{display:none}@media (hover: none), (pointer: coarse){.drag-handle{display:none}}@media (prefers-reduced-motion: reduce){.row,.disclosure-icon,.drag-handle{transition:none}}`;
3261
+ uiTreeItemCss = () => `:host{--ui-tree-indent:16px;--ui-tree-row-min-height:32px;--ui-tree-drop-color:var(--ui-accent-solid);position:relative;display:block;min-inline-size:0;margin-inline-start:calc(var(--ui-tree-item-depth, 0) * var(--ui-tree-indent))}.row{position:relative;display:grid;grid-template-columns:20px auto minmax(0, 1fr) auto;align-items:center;min-block-size:var(--ui-tree-row-min-height);min-inline-size:0;font-size:var(--ui-tree-font-size, var(--ui-font-size-ui, 0.9375rem));border-radius:var(--ui-radius-md);color:var(--ui-text-secondary);transition:background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease), opacity var(--ui-motion-fast) var(--ui-motion-ease), box-shadow var(--ui-motion-fast) var(--ui-motion-ease), min-block-size var(--ui-motion-base) var(--ui-motion-ease)}.row:hover,:host([data-selected]) .row,.row:focus-within{color:var(--ui-text-primary);background:var(--ui-surface-muted)}:host([data-disabled]) .row{opacity:0.55}:host([data-dragging]) .row{opacity:0.42}:host(:focus){outline:none}:host(:focus-visible) .row{box-shadow:0 0 0 2px var(--ui-focus-ring)}:host([data-drop-position='inside']) .row{background:var(--ui-accent-subtle);box-shadow:inset 0 0 0 1px var(--ui-tree-drop-color)}.disclosure,.disclosure-spacer{grid-column:1;grid-row:1;inline-size:20px;block-size:28px}.disclosure{display:grid;place-items:center;padding:0;color:var(--ui-text-muted);background:transparent;border:0;border-radius:var(--ui-radius-sm);cursor:pointer}.disclosure:hover{color:var(--ui-text-primary);background:var(--ui-surface-elevated)}.disclosure-icon{display:block;inline-size:14px;block-size:14px;transform:rotate(-90deg);transition:transform var(--ui-motion-fast) var(--ui-motion-ease)}.disclosure-icon--expanded{transform:rotate(0deg)}.disclosure-icon :is(svg),.drag-handle :is(svg){display:block;inline-size:100%;block-size:100%}.leading{display:none}.leading:has(*){display:inline-grid;place-items:center;grid-column:2;grid-row:1;inline-size:16px;block-size:16px;margin-inline-start:var(--ui-space-1)}.label{grid-column:3;grid-row:1;min-inline-size:0;padding:var(--ui-space-1) var(--ui-space-2)}.actions{grid-column:4;grid-row:1;display:inline-flex;align-items:center;min-inline-size:0}.drag-handle{position:absolute;z-index:2;inset-block-start:50%;inset-inline-start:-22px;inline-size:20px;block-size:32px;display:grid;place-items:center;padding:7px 3px;color:var(--ui-text-muted);background:var(--ui-surface-elevated);border:1px solid transparent;border-radius:var(--ui-radius-sm);cursor:grab;opacity:0;pointer-events:none;transform:translateY(-50%);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease)}.row:hover .drag-handle,.drag-handle:focus-visible,:host([data-dragging]) .drag-handle{opacity:1;pointer-events:auto}.drag-handle:active{cursor:grabbing}.drop-indicator{position:absolute;z-index:3;inset-inline:1px;display:none;block-size:2px;border-radius:999px;background:var(--ui-tree-drop-color);pointer-events:none}.drop-indicator::before,.drop-indicator::after{content:'';position:absolute;inset-block-start:50%;inline-size:7px;block-size:7px;border:2px solid var(--ui-tree-drop-color);border-radius:999px;background:var(--ui-surface-elevated);transform:translateY(-50%)}.drop-indicator::before{inset-inline-start:-1px}.drop-indicator::after{inset-inline-end:-1px}:host([data-drop-position='before']) .drop-indicator{display:block;inset-block-start:-1px}:host([data-drop-position='after']) .drop-indicator{display:block;inset-block-end:-1px}.children[hidden]{display:none}:host-context(html[data-ui-input-modality='touch']){--ui-tree-row-min-height:44px}:host-context(html[data-ui-input-modality='touch']) .drag-handle{display:none}@media (prefers-reduced-motion: reduce){.row,.disclosure-icon,.drag-handle{transition:none}}`;
2779
3262
  UITreeItem = class {
2780
3263
  constructor(hostRef) {
2781
3264
  registerInstance(this, hostRef);
@@ -4695,14 +5178,17 @@ var index_exports = {};
4695
5178
  __export(index_exports, {
4696
5179
  DEFAULT_AFFORDANCE_NEAR_RADIUS: () => DEFAULT_AFFORDANCE_NEAR_RADIUS2,
4697
5180
  LOOMA_ICONS: () => LOOMA_ICONS2,
4698
- clampRectToViewport: () => clampRectToViewport,
5181
+ clampRectToViewport: () => clampRectToViewport2,
4699
5182
  classifyDropPosition: () => classifyDropPosition2,
4700
5183
  closeOverlay: () => closeOverlay2,
5184
+ createAnchoredSurface: () => createAnchoredSurface2,
4701
5185
  createHoverIntent: () => createHoverIntent2,
4702
5186
  createProximityCoordinator: () => createProximityCoordinator2,
5187
+ createViewportSurface: () => createViewportSurface2,
4703
5188
  distanceFromPointToRect: () => distanceFromPointToRect2,
4704
5189
  getTopOverlay: () => getTopOverlay2,
4705
- getVisualViewportRect: () => getVisualViewportRect,
5190
+ getVisualViewportRect: () => getVisualViewportRect2,
5191
+ initializeInputModality: () => initializeInputModality,
4706
5192
  isTopOverlay: () => isTopOverlay,
4707
5193
  loomaIconMarkup: () => loomaIconMarkup2,
4708
5194
  openOverlay: () => openOverlay2,
@@ -4723,7 +5209,7 @@ var globalScripts = () => {
4723
5209
  var defineCustomElements = async (win2, options) => {
4724
5210
  if (typeof window === "undefined") return void 0;
4725
5211
  await globalScripts();
4726
- return bootstrapLazy([["ui-context-menu", [[769, "ui-context-menu", { "open": [4], "defaultOpen": [4, "default-open"], "for": [1], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "for": [{ "syncTarget": 0 }], "internalOpen": [{ "syncOverlay": 0 }] }]]], ["ui-affordance-scope", [[769, "ui-affordance-scope", { "nearRadius": [514, "near-radius"] }, null, { "nearRadius": [{ "connectCoordinator": 0 }] }]]], ["ui-avatar", [[513, "ui-avatar", { "src": [1], "alt": [1], "name": [1], "fallback": [1], "hasImage": [32] }, null, { "src": [{ "watchSrc": 0 }] }]]], ["ui-avatar-group", [[769, "ui-avatar-group", { "max": [2], "label": [1], "overflowCount": [32] }, null, { "max": [{ "syncOverflow": 0 }] }]]], ["ui-badge", [[769, "ui-badge", { "variant": [1], "tone": [1] }]]], ["ui-button", [[769, "ui-button", { "variant": [1], "size": [1], "disabled": [4] }, null, { "variant": [{ "syncToButton": 0 }], "size": [{ "syncToButton": 0 }], "disabled": [{ "syncToButton": 0 }] }]]], ["ui-checkbox", [[769, "ui-checkbox", { "checked": [4], "defaultChecked": [4, "default-checked"], "disabled": [4], "indeterminate": [4], "required": [4], "value": [1], "internalChecked": [32] }, null, { "checked": [{ "syncFromProp": 0 }], "internalChecked": [{ "syncToInput": 0 }], "indeterminate": [{ "syncToInput": 0 }], "disabled": [{ "syncToInput": 0 }], "required": [{ "syncToInput": 0 }] }]]], ["ui-dialog", [[769, "ui-dialog", { "open": [4], "defaultOpen": [4, "default-open"], "modal": [4], "dismissible": [4], "label": [1], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "syncOpen": 0 }] }]]], ["ui-disclosure", [[769, "ui-disclosure", { "open": [4], "defaultOpen": [4, "default-open"], "disabled": [4], "internalOpen": [32], "contentId": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "syncState": 0 }] }]]], ["ui-floating-action-button", [[769, "ui-floating-action-button", { "disabled": [516], "mobileOnly": [516, "mobile-only"], "label": [1] }]]], ["ui-form-field", [[769, "ui-form-field", { "invalid": [4], "disabled": [4], "required": [4] }]]], ["ui-icon-button", [[769, "ui-icon-button", { "disabled": [516], "label": [1], "size": [513], "variant": [513], "anticipatory": [516] }]]], ["ui-input", [[769, "ui-input", { "value": [1], "defaultValue": [1, "default-value"], "disabled": [4], "invalid": [4], "readOnly": [4, "readonly"], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToInput": 0 }], "defaultValue": [{ "syncToInput": 0 }], "disabled": [{ "syncToInput": 0 }], "invalid": [{ "syncToInput": 0 }], "readOnly": [{ "syncToInput": 0 }] }]]], ["ui-menu-item", [[769, "ui-menu-item", { "disabled": [516], "value": [1] }]]], ["ui-popover", [[769, "ui-popover", { "open": [4], "defaultOpen": [4, "default-open"], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "onOpenChange": 0 }] }]]], ["ui-radio", [[769, "ui-radio", { "checked": [4], "defaultChecked": [4, "default-checked"], "disabled": [4], "name": [1], "required": [4], "value": [1] }, null, { "checked": [{ "syncToInput": 0 }], "disabled": [{ "syncToInput": 0 }], "name": [{ "syncToInput": 0 }], "required": [{ "syncToInput": 0 }], "value": [{ "syncToInput": 0 }] }]]], ["ui-radio-group", [[769, "ui-radio-group", { "value": [1], "name": [1], "orientation": [1], "disabled": [4], "required": [4], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToRadios": 0 }], "name": [{ "syncToRadios": 0 }], "orientation": [{ "syncToRadios": 0 }], "disabled": [{ "syncToRadios": 0 }] }]]], ["ui-search-result-row", [[769, "ui-search-result-row", { "disabled": [516], "selected": [516], "hasLeading": [32], "hasMeta": [32], "hasExcerpt": [32], "hasTrailing": [32] }]]], ["ui-search-shell", [[769, "ui-search-shell", { "hasStatus": [32], "hasFooter": [32] }]]], ["ui-select", [[769, "ui-select", { "value": [1], "defaultValue": [1, "default-value"], "disabled": [4], "invalid": [4], "required": [4], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToSelect": 0 }], "defaultValue": [{ "syncToSelect": 0 }], "disabled": [{ "syncToSelect": 0 }], "invalid": [{ "syncToSelect": 0 }], "required": [{ "syncToSelect": 0 }] }]]], ["ui-switch", [[769, "ui-switch", { "checked": [4], "defaultChecked": [4, "default-checked"], "disabled": [4], "required": [4], "value": [1], "internalChecked": [32] }, null, { "checked": [{ "syncFromProp": 0 }] }]]], ["ui-tabs", [[769, "ui-tabs", { "value": [1], "defaultValue": [1, "default-value"], "orientation": [1], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncState": 0 }], "orientation": [{ "syncState": 0 }] }]]], ["ui-textarea", [[769, "ui-textarea", { "value": [1], "defaultValue": [1, "default-value"], "disabled": [4], "invalid": [4], "readOnly": [4, "readonly"], "rows": [2], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToTextarea": 0 }], "defaultValue": [{ "syncToTextarea": 0 }], "disabled": [{ "syncToTextarea": 0 }], "invalid": [{ "syncToTextarea": 0 }], "readOnly": [{ "syncToTextarea": 0 }], "rows": [{ "syncToTextarea": 0 }] }]]], ["ui-toast-region", [[769, "ui-toast-region", { "open": [4], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }] }]]], ["ui-tooltip", [[769, "ui-tooltip", { "for": [1], "open": [4], "defaultOpen": [4, "default-open"], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "syncOverlay": 0 }] }]]], ["ui-top-bar", [[769, "ui-top-bar", { "hasLeading": [32], "hasSearch": [32], "hasActions": [32] }]]], ["ui-tree", [[769, "ui-tree", { "label": [1], "hoverExpandDelay": [2, "hover-expand-delay"] }]]], ["ui-tree-item", [[769, "ui-tree-item", { "itemId": [1, "item-id"], "label": [1], "depth": [2], "container": [4], "sortable": [4], "dragType": [1, "drag-type"], "dropScope": [1, "drop-scope"], "accepts": [1], "expanded": [4], "defaultExpanded": [4, "default-expanded"], "selected": [4], "disabled": [4], "internalExpanded": [32] }, null, { "expanded": [{ "syncExpandedFromProp": 0 }] }]]], ["ui-menu", [[769, "ui-menu", { "open": [4], "defaultOpen": [4, "default-open"], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }] }]]]], options);
5212
+ return bootstrapLazy([["ui-context-menu", [[769, "ui-context-menu", { "open": [4], "defaultOpen": [4, "default-open"], "for": [1], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "for": [{ "syncTarget": 0 }], "internalOpen": [{ "syncOverlay": 0 }] }]]], ["ui-affordance-scope", [[769, "ui-affordance-scope", { "nearRadius": [514, "near-radius"] }, null, { "nearRadius": [{ "connectCoordinator": 0 }] }]]], ["ui-avatar", [[513, "ui-avatar", { "src": [1], "alt": [1], "name": [1], "fallback": [1], "hasImage": [32] }, null, { "src": [{ "watchSrc": 0 }] }]]], ["ui-avatar-group", [[769, "ui-avatar-group", { "max": [2], "label": [1], "overflowCount": [32] }, null, { "max": [{ "syncOverflow": 0 }] }]]], ["ui-badge", [[769, "ui-badge", { "variant": [1], "tone": [1] }]]], ["ui-button", [[769, "ui-button", { "variant": [1], "size": [1], "disabled": [4] }, null, { "variant": [{ "syncToButton": 0 }], "size": [{ "syncToButton": 0 }], "disabled": [{ "syncToButton": 0 }] }]]], ["ui-checkbox", [[769, "ui-checkbox", { "checked": [4], "defaultChecked": [4, "default-checked"], "disabled": [4], "indeterminate": [4], "required": [4], "value": [1], "internalChecked": [32] }, null, { "checked": [{ "syncFromProp": 0 }], "internalChecked": [{ "syncToInput": 0 }], "indeterminate": [{ "syncToInput": 0 }], "disabled": [{ "syncToInput": 0 }], "required": [{ "syncToInput": 0 }] }]]], ["ui-dialog", [[769, "ui-dialog", { "open": [4], "defaultOpen": [4, "default-open"], "modal": [4], "dismissible": [4], "label": [1], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "syncOpen": 0 }] }]]], ["ui-disclosure", [[769, "ui-disclosure", { "open": [4], "defaultOpen": [4, "default-open"], "disabled": [4], "internalOpen": [32], "contentId": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "syncState": 0 }] }]]], ["ui-floating-action-button", [[769, "ui-floating-action-button", { "disabled": [516], "mobileOnly": [516, "mobile-only"], "label": [1] }]]], ["ui-form-field", [[769, "ui-form-field", { "invalid": [4], "disabled": [4], "required": [4] }]]], ["ui-icon-button", [[769, "ui-icon-button", { "disabled": [516], "label": [1], "size": [513], "variant": [513], "anticipatory": [516] }]]], ["ui-input", [[769, "ui-input", { "value": [1], "defaultValue": [1, "default-value"], "disabled": [4], "invalid": [4], "readOnly": [4, "readonly"], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToInput": 0 }], "defaultValue": [{ "syncToInput": 0 }], "disabled": [{ "syncToInput": 0 }], "invalid": [{ "syncToInput": 0 }], "readOnly": [{ "syncToInput": 0 }] }]]], ["ui-menu-item", [[769, "ui-menu-item", { "disabled": [516], "value": [1] }]]], ["ui-popover", [[769, "ui-popover", { "open": [4], "defaultOpen": [4, "default-open"], "for": [1], "placement": [1], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "onOpenChange": 0 }], "for": [{ "resetSurface": 0 }], "placement": [{ "resetSurface": 0 }] }]]], ["ui-radio", [[769, "ui-radio", { "checked": [4], "defaultChecked": [4, "default-checked"], "disabled": [4], "name": [1], "required": [4], "value": [1] }, null, { "checked": [{ "syncToInput": 0 }], "disabled": [{ "syncToInput": 0 }], "name": [{ "syncToInput": 0 }], "required": [{ "syncToInput": 0 }], "value": [{ "syncToInput": 0 }] }]]], ["ui-radio-group", [[769, "ui-radio-group", { "value": [1], "name": [1], "orientation": [1], "disabled": [4], "required": [4], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToRadios": 0 }], "name": [{ "syncToRadios": 0 }], "orientation": [{ "syncToRadios": 0 }], "disabled": [{ "syncToRadios": 0 }] }]]], ["ui-search-result-row", [[769, "ui-search-result-row", { "disabled": [516], "selected": [516], "hasLeading": [32], "hasMeta": [32], "hasExcerpt": [32], "hasTrailing": [32] }]]], ["ui-search-shell", [[769, "ui-search-shell", { "hasStatus": [32], "hasFooter": [32] }]]], ["ui-select", [[769, "ui-select", { "value": [1], "defaultValue": [1, "default-value"], "disabled": [4], "invalid": [4], "required": [4], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToSelect": 0 }], "defaultValue": [{ "syncToSelect": 0 }], "disabled": [{ "syncToSelect": 0 }], "invalid": [{ "syncToSelect": 0 }], "required": [{ "syncToSelect": 0 }] }]]], ["ui-switch", [[769, "ui-switch", { "checked": [4], "defaultChecked": [4, "default-checked"], "disabled": [4], "required": [4], "value": [1], "internalChecked": [32] }, null, { "checked": [{ "syncFromProp": 0 }] }]]], ["ui-tabs", [[769, "ui-tabs", { "value": [1], "defaultValue": [1, "default-value"], "orientation": [1], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncState": 0 }], "orientation": [{ "syncState": 0 }] }]]], ["ui-textarea", [[769, "ui-textarea", { "value": [1], "defaultValue": [1, "default-value"], "disabled": [4], "invalid": [4], "readOnly": [4, "readonly"], "rows": [2], "internalValue": [32] }, null, { "value": [{ "syncFromProp": 0 }], "internalValue": [{ "syncToTextarea": 0 }], "defaultValue": [{ "syncToTextarea": 0 }], "disabled": [{ "syncToTextarea": 0 }], "invalid": [{ "syncToTextarea": 0 }], "readOnly": [{ "syncToTextarea": 0 }], "rows": [{ "syncToTextarea": 0 }] }]]], ["ui-toast-region", [[769, "ui-toast-region", { "open": [4], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "internalOpen": [{ "syncSurface": 0 }] }]]], ["ui-tooltip", [[769, "ui-tooltip", { "for": [1], "open": [4], "defaultOpen": [4, "default-open"], "placement": [1], "showDelay": [2, "show-delay"], "hideDelay": [2, "hide-delay"], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "for": [{ "resetSurface": 0 }], "placement": [{ "resetSurface": 0 }], "internalOpen": [{ "syncOverlay": 0 }] }]]], ["ui-top-bar", [[769, "ui-top-bar", { "hasLeading": [32], "hasSearch": [32], "hasActions": [32] }]]], ["ui-tree", [[769, "ui-tree", { "label": [1], "hoverExpandDelay": [2, "hover-expand-delay"] }]]], ["ui-tree-item", [[769, "ui-tree-item", { "itemId": [1, "item-id"], "label": [1], "depth": [2], "container": [4], "sortable": [4], "dragType": [1, "drag-type"], "dropScope": [1, "drop-scope"], "accepts": [1], "expanded": [4], "defaultExpanded": [4, "default-expanded"], "selected": [4], "disabled": [4], "internalExpanded": [32] }, null, { "expanded": [{ "syncExpandedFromProp": 0 }] }]]], ["ui-menu", [[769, "ui-menu", { "open": [4], "defaultOpen": [4, "default-open"], "for": [1], "placement": [1], "internalOpen": [32] }, null, { "open": [{ "syncFromProp": 0 }], "for": [{ "resetSurface": 0 }], "placement": [{ "resetSurface": 0 }], "internalOpen": [{ "syncSurface": 0 }] }]]]], options);
4727
5213
  };
4728
5214
 
4729
5215
  // loader/index.js
@@ -4739,6 +5225,24 @@ var defineCustomElements = async (win2, options) => {
4739
5225
  }
4740
5226
  })();
4741
5227
 
5228
+ // src/input-modality.ts
5229
+ var initializedDocuments = /* @__PURE__ */ new WeakSet();
5230
+ function initializeInputModality(owner = document) {
5231
+ if (initializedDocuments.has(owner)) return;
5232
+ initializedDocuments.add(owner);
5233
+ const markTouch = () => {
5234
+ if (owner.documentElement.getAttribute("data-ui-input-modality") === "touch") return;
5235
+ owner.documentElement.setAttribute("data-ui-input-modality", "touch");
5236
+ owner.dispatchEvent(new CustomEvent("ui-input-modality-change", {
5237
+ detail: { modality: "touch" }
5238
+ }));
5239
+ };
5240
+ owner.addEventListener("pointerdown", (event) => {
5241
+ if (event.pointerType === "touch") markTouch();
5242
+ }, { capture: true, passive: true });
5243
+ owner.addEventListener("touchstart", markTouch, { capture: true, passive: true });
5244
+ }
5245
+
4742
5246
  // src/overlay/manager.ts
4743
5247
  var stack2 = [];
4744
5248
  var scrollLockAttribute2 = "data-ui-scroll-lock";
@@ -4772,8 +5276,9 @@ function handleLightDismiss2(event) {
4772
5276
  return;
4773
5277
  }
4774
5278
  const target = event.target;
4775
- if (target instanceof Node && top.element.contains(target)) {
4776
- return;
5279
+ if (target instanceof Node) {
5280
+ if (top.element.contains(target)) return;
5281
+ if (top.relatedElements?.some((element) => element.contains(target))) return;
4777
5282
  }
4778
5283
  requestTopOverlayClose2("light-dismiss", "pointer");
4779
5284
  }
@@ -4833,7 +5338,215 @@ function requestTopOverlayClose2(reason, trigger) {
4833
5338
 
4834
5339
  // src/overlay/positioning.ts
4835
5340
  var DEFAULT_AFFORDANCE_NEAR_RADIUS2 = 16;
4836
- function getVisualViewportRect(owner = window) {
5341
+ var anchorSequence2 = 0;
5342
+ var anchorBindings2 = /* @__PURE__ */ new WeakMap();
5343
+ function bindAnchorName2(anchor, name) {
5344
+ const binding = anchorBindings2.get(anchor) ?? {
5345
+ original: anchor.style.getPropertyValue("anchor-name"),
5346
+ names: /* @__PURE__ */ new Set()
5347
+ };
5348
+ binding.names.add(name);
5349
+ anchorBindings2.set(anchor, binding);
5350
+ const values = [binding.original, ...binding.names].filter(Boolean);
5351
+ anchor.style.setProperty("anchor-name", values.join(", "));
5352
+ }
5353
+ function unbindAnchorName2(anchor, name) {
5354
+ const binding = anchorBindings2.get(anchor);
5355
+ if (!binding) return;
5356
+ binding.names.delete(name);
5357
+ if (binding.names.size) {
5358
+ const values = [binding.original, ...binding.names].filter(Boolean);
5359
+ anchor.style.setProperty("anchor-name", values.join(", "));
5360
+ return;
5361
+ }
5362
+ if (binding.original) anchor.style.setProperty("anchor-name", binding.original);
5363
+ else anchor.style.removeProperty("anchor-name");
5364
+ anchorBindings2.delete(anchor);
5365
+ }
5366
+ function supportsAnchorPositioning2(owner) {
5367
+ const css = owner.CSS;
5368
+ return typeof css?.supports === "function" && css.supports("anchor-name: --ui-anchor-test") && css.supports("position-anchor: --ui-anchor-test") && css.supports("top: anchor(bottom)");
5369
+ }
5370
+ function topLayerOpen2(surface) {
5371
+ try {
5372
+ return surface.matches(":popover-open");
5373
+ } catch {
5374
+ return !surface.hidden;
5375
+ }
5376
+ }
5377
+ function showInTopLayer2(surface) {
5378
+ surface.setAttribute("popover", "manual");
5379
+ surface.hidden = false;
5380
+ if (typeof surface.showPopover === "function" && !topLayerOpen2(surface)) {
5381
+ try {
5382
+ surface.showPopover();
5383
+ } catch {
5384
+ }
5385
+ }
5386
+ }
5387
+ function hideFromTopLayer2(surface) {
5388
+ if (typeof surface.hidePopover === "function" && topLayerOpen2(surface)) {
5389
+ try {
5390
+ surface.hidePopover();
5391
+ } catch {
5392
+ }
5393
+ }
5394
+ surface.hidden = true;
5395
+ }
5396
+ function createViewportSurface2(surface) {
5397
+ surface.setAttribute("popover", "manual");
5398
+ surface.dataset.uiPositioning = "viewport";
5399
+ return {
5400
+ show() {
5401
+ showInTopLayer2(surface);
5402
+ },
5403
+ hide() {
5404
+ hideFromTopLayer2(surface);
5405
+ },
5406
+ destroy() {
5407
+ hideFromTopLayer2(surface);
5408
+ }
5409
+ };
5410
+ }
5411
+ function fallbackPosition2(surface, anchor, placement, gap, viewportGap) {
5412
+ const owner = surface.ownerDocument.defaultView ?? window;
5413
+ const viewport = getVisualViewportRect2(owner);
5414
+ const rect = surface.getBoundingClientRect();
5415
+ const preferTop = placement.startsWith("top");
5416
+ const preferEnd = placement.endsWith("end");
5417
+ const spaceBelow = viewport.bottom - anchor.bottom - viewportGap;
5418
+ const spaceAbove = anchor.top - viewport.top - viewportGap;
5419
+ const useTop = preferTop ? !(spaceAbove < rect.height + gap && spaceBelow > spaceAbove) : spaceBelow < rect.height + gap && spaceAbove > spaceBelow;
5420
+ const unclampedTop = useTop ? anchor.top - rect.height - gap : anchor.bottom + gap;
5421
+ const unclampedLeft = preferEnd ? anchor.right - rect.width : anchor.left;
5422
+ const shifted = clampRectToViewport2({
5423
+ left: unclampedLeft,
5424
+ top: unclampedTop,
5425
+ right: unclampedLeft + rect.width,
5426
+ bottom: unclampedTop + rect.height,
5427
+ width: rect.width,
5428
+ height: rect.height
5429
+ }, viewport, viewportGap);
5430
+ surface.style.left = `${Math.round(unclampedLeft + shifted.x)}px`;
5431
+ surface.style.top = `${Math.round(unclampedTop + shifted.y)}px`;
5432
+ surface.style.right = "auto";
5433
+ surface.style.bottom = "auto";
5434
+ }
5435
+ function createAnchoredSurface2(surface, options = {}) {
5436
+ const owner = surface.ownerDocument.defaultView ?? window;
5437
+ const placement = options.placement ?? "bottom-start";
5438
+ const gap = Math.max(0, options.gap ?? 4);
5439
+ const viewportGap = Math.max(0, options.viewportGap ?? 8);
5440
+ const nativeAnchor = supportsAnchorPositioning2(owner);
5441
+ const anchorName = `--ui-anchor-${++anchorSequence2}`;
5442
+ let anchor = options.anchor ?? null;
5443
+ let point = null;
5444
+ let open = false;
5445
+ let frame = null;
5446
+ let listenerAbort = null;
5447
+ surface.setAttribute("popover", "manual");
5448
+ surface.dataset.uiPositioning = nativeAnchor ? "anchor" : "fallback";
5449
+ surface.style.position = "fixed";
5450
+ surface.style.margin = "0";
5451
+ const bindAnchor = (next) => {
5452
+ if (anchor) unbindAnchorName2(anchor, anchorName);
5453
+ anchor = next;
5454
+ if (!anchor) {
5455
+ surface.style.removeProperty("position-anchor");
5456
+ return;
5457
+ }
5458
+ bindAnchorName2(anchor, anchorName);
5459
+ surface.style.setProperty("position-anchor", anchorName);
5460
+ };
5461
+ const positionNative = () => {
5462
+ const blockEnd = placement.startsWith("bottom");
5463
+ const inlineEnd = placement.endsWith("end");
5464
+ surface.style.top = blockEnd ? `calc(anchor(bottom) + ${gap}px)` : "auto";
5465
+ surface.style.bottom = blockEnd ? "auto" : `calc(anchor(top) + ${gap}px)`;
5466
+ surface.style.left = inlineEnd ? "auto" : "anchor(left)";
5467
+ surface.style.right = inlineEnd ? "anchor(right)" : "auto";
5468
+ surface.style.setProperty("position-try-fallbacks", "flip-block, flip-inline");
5469
+ };
5470
+ const position = () => {
5471
+ frame = null;
5472
+ if (!open) return;
5473
+ if (point) {
5474
+ fallbackPosition2(surface, {
5475
+ left: point.x,
5476
+ right: point.x,
5477
+ top: point.y,
5478
+ bottom: point.y,
5479
+ width: 0,
5480
+ height: 0
5481
+ }, "bottom-start", gap, viewportGap);
5482
+ return;
5483
+ }
5484
+ if (!anchor) return;
5485
+ if (nativeAnchor) positionNative();
5486
+ else fallbackPosition2(surface, anchor.getBoundingClientRect(), placement, gap, viewportGap);
5487
+ };
5488
+ const schedule = () => {
5489
+ if (!open || frame !== null) return;
5490
+ frame = owner.requestAnimationFrame(position);
5491
+ };
5492
+ const syncFallbackListeners = () => {
5493
+ const needsListeners = open && (point !== null || !nativeAnchor);
5494
+ if (!needsListeners) {
5495
+ listenerAbort?.abort();
5496
+ listenerAbort = null;
5497
+ return;
5498
+ }
5499
+ if (listenerAbort) return;
5500
+ listenerAbort = new AbortController();
5501
+ const signal = listenerAbort.signal;
5502
+ owner.addEventListener("resize", schedule, { passive: true, signal });
5503
+ owner.addEventListener("scroll", schedule, { passive: true, capture: true, signal });
5504
+ owner.visualViewport?.addEventListener("resize", schedule, { passive: true, signal });
5505
+ owner.visualViewport?.addEventListener("scroll", schedule, { passive: true, signal });
5506
+ };
5507
+ bindAnchor(anchor);
5508
+ return {
5509
+ setAnchor(next) {
5510
+ point = null;
5511
+ bindAnchor(next);
5512
+ syncFallbackListeners();
5513
+ schedule();
5514
+ },
5515
+ show() {
5516
+ point = null;
5517
+ open = true;
5518
+ syncFallbackListeners();
5519
+ showInTopLayer2(surface);
5520
+ position();
5521
+ },
5522
+ showAtPoint(nextPoint) {
5523
+ point = nextPoint;
5524
+ open = true;
5525
+ syncFallbackListeners();
5526
+ showInTopLayer2(surface);
5527
+ position();
5528
+ },
5529
+ hide() {
5530
+ open = false;
5531
+ point = null;
5532
+ syncFallbackListeners();
5533
+ if (frame !== null) owner.cancelAnimationFrame(frame);
5534
+ frame = null;
5535
+ hideFromTopLayer2(surface);
5536
+ },
5537
+ refresh: schedule,
5538
+ destroy() {
5539
+ open = false;
5540
+ listenerAbort?.abort();
5541
+ listenerAbort = null;
5542
+ if (frame !== null) owner.cancelAnimationFrame(frame);
5543
+ frame = null;
5544
+ hideFromTopLayer2(surface);
5545
+ bindAnchor(null);
5546
+ }
5547
+ };
5548
+ }
5549
+ function getVisualViewportRect2(owner = window) {
4837
5550
  const viewport = owner.visualViewport;
4838
5551
  const left = viewport?.offsetLeft ?? 0;
4839
5552
  const top = viewport?.offsetTop ?? 0;
@@ -4848,7 +5561,7 @@ function getVisualViewportRect(owner = window) {
4848
5561
  height
4849
5562
  };
4850
5563
  }
4851
- function clampRectToViewport(rect, viewport = getVisualViewportRect(), gutter = 0) {
5564
+ function clampRectToViewport2(rect, viewport = getVisualViewportRect2(), gutter = 0) {
4852
5565
  const availableWidth = Math.max(0, viewport.width - gutter * 2);
4853
5566
  const availableHeight = Math.max(0, viewport.height - gutter * 2);
4854
5567
  const targetLeft = rect.width > availableWidth ? viewport.left + gutter : Math.min(
@@ -5056,6 +5769,7 @@ function createHoverIntent2(delay, onIntent) {
5056
5769
  }
5057
5770
 
5058
5771
  // index.ts
5772
+ if (typeof document !== "undefined") initializeInputModality(document);
5059
5773
  defineCustomElements();
5060
5774
  // Annotate the CommonJS export names for ESM import in node:
5061
5775
  0 && (module.exports = {
@@ -5064,11 +5778,14 @@ defineCustomElements();
5064
5778
  clampRectToViewport,
5065
5779
  classifyDropPosition,
5066
5780
  closeOverlay,
5781
+ createAnchoredSurface,
5067
5782
  createHoverIntent,
5068
5783
  createProximityCoordinator,
5784
+ createViewportSurface,
5069
5785
  distanceFromPointToRect,
5070
5786
  getTopOverlay,
5071
5787
  getVisualViewportRect,
5788
+ initializeInputModality,
5072
5789
  isTopOverlay,
5073
5790
  loomaIconMarkup,
5074
5791
  openOverlay,