@raphy-js/dom 0.0.0-stage → 1.0.0-dev.88

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 (175) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +187 -2
  3. package/dist/DOMBlueprintMaterializer-C-icNhvm.cjs +1 -0
  4. package/dist/DOMBlueprintMaterializer-CxzM_TX5.js +201 -0
  5. package/dist/FullDOMOperations-BOlf0_0L.js +2781 -0
  6. package/dist/FullDOMOperations-Dschwj33.cjs +1 -0
  7. package/dist/api/renderer.d.ts +12 -0
  8. package/dist/applicationIdentity-CHbuUlsE.cjs +1 -0
  9. package/dist/applicationIdentity-DjVgpsQq.js +11 -0
  10. package/dist/bind-BEmkQdaL.cjs +1 -0
  11. package/dist/bind-OakIMWpC.js +52 -0
  12. package/dist/binding/DOMValueWriter.d.ts +59 -0
  13. package/dist/binding/materializeComponentProps.d.ts +38 -0
  14. package/dist/binding/mountDOMBinding.d.ts +9 -0
  15. package/dist/binding/mountDOMProps.d.ts +22 -0
  16. package/dist/capture.cjs +1 -0
  17. package/dist/capture.d.ts +7 -0
  18. package/dist/capture.js +166 -0
  19. package/dist/channels-Bs8GHVWn.cjs +1 -0
  20. package/dist/channels-DqAQt-NH.js +33 -0
  21. package/dist/compact/hydration.cjs +1 -0
  22. package/dist/compact/hydration.d.ts +9 -0
  23. package/dist/compact/hydration.js +12 -0
  24. package/dist/compact/index.d.ts +19 -0
  25. package/dist/compact/targetRuntime.d.ts +1 -0
  26. package/dist/compact.cjs +1 -0
  27. package/dist/compact.js +34 -0
  28. package/dist/contracts/freezeGeneratedContract.d.ts +5 -0
  29. package/dist/contracts/manifest.json +25 -0
  30. package/dist/contracts/node.cjs +1 -0
  31. package/dist/contracts/node.contract.json +36889 -0
  32. package/dist/contracts/node.d.ts +6 -0
  33. package/dist/contracts/node.js +19 -0
  34. package/dist/contracts/stylesheet.cjs +1 -0
  35. package/dist/contracts/stylesheet.contract.json +11887 -0
  36. package/dist/contracts/stylesheet.d.ts +6 -0
  37. package/dist/contracts/stylesheet.js +22 -0
  38. package/dist/createDOMDataEventInput-B82pnIav.cjs +1 -0
  39. package/dist/createDOMDataEventInput-BDX50jhu.js +3010 -0
  40. package/dist/createDOMNodeRuntime-BHcsbeO1.cjs +1 -0
  41. package/dist/createDOMNodeRuntime-DIKOUQP7.js +3006 -0
  42. package/dist/createHydrationRenderer-C7srF-66.js +289 -0
  43. package/dist/createHydrationRenderer-DKybWTj4.cjs +1 -0
  44. package/dist/elementRef-D8Ir8tXA.cjs +1 -0
  45. package/dist/elementRef-YPBBElV9.js +32 -0
  46. package/dist/event/DOMEventHub.d.ts +303 -0
  47. package/dist/freezeGeneratedContract-0EZt85o4.js +10 -0
  48. package/dist/freezeGeneratedContract-g_Op1hGY.cjs +1 -0
  49. package/dist/hydration/HydrationEvents.d.ts +20 -0
  50. package/dist/hydration/HydrationSession.d.ts +107 -0
  51. package/dist/hydration/HydrationStream.d.ts +30 -0
  52. package/dist/hydration/activateHydration.d.ts +2 -0
  53. package/dist/hydration/createHydrationRenderer.d.ts +25 -0
  54. package/dist/hydration/index.d.ts +8 -0
  55. package/dist/hydration.cjs +1 -0
  56. package/dist/hydration.js +12 -0
  57. package/dist/index.cjs +1 -0
  58. package/dist/index.d.ts +22 -0
  59. package/dist/index.js +24 -0
  60. package/dist/interaction/clipboard.d.ts +2 -0
  61. package/dist/interaction/contextAction.d.ts +3 -0
  62. package/dist/interaction/contracts/node.cjs +1 -0
  63. package/dist/interaction/contracts/node.d.ts +15 -0
  64. package/dist/interaction/contracts/node.js +60 -0
  65. package/dist/interaction/dragDrop.d.ts +13 -0
  66. package/dist/interaction/focus.d.ts +4 -0
  67. package/dist/interaction/geometry.d.ts +39 -0
  68. package/dist/interaction/hover.d.ts +4 -0
  69. package/dist/interaction/index.d.ts +2 -0
  70. package/dist/interaction/interaction.d.ts +4 -0
  71. package/dist/interaction/internal/DOMInputModality.d.ts +20 -0
  72. package/dist/interaction/internal/DOMInteraction.types.d.ts +29 -0
  73. package/dist/interaction/internal/applicationIdentity.d.ts +3 -0
  74. package/dist/interaction/internal/dragDataTransfer.d.ts +4 -0
  75. package/dist/interaction/internal/solvePosition.d.ts +5 -0
  76. package/dist/interaction/keyboard.d.ts +3 -0
  77. package/dist/interaction/move.d.ts +3 -0
  78. package/dist/interaction/nativeDragDrop.d.ts +18 -0
  79. package/dist/interaction/outside.d.ts +3 -0
  80. package/dist/interaction/press.d.ts +3 -0
  81. package/dist/interaction/profile.cjs +1 -0
  82. package/dist/interaction/profile.d.ts +2 -0
  83. package/dist/interaction/profile.js +48 -0
  84. package/dist/interaction/rovingFocus.d.ts +4 -0
  85. package/dist/interaction/runtime.d.ts +7 -0
  86. package/dist/interaction/textEditing.d.ts +4 -0
  87. package/dist/interaction.cjs +1 -0
  88. package/dist/interaction.js +1603 -0
  89. package/dist/internal/dev.d.ts +20 -0
  90. package/dist/motion/channels.d.ts +5 -0
  91. package/dist/motion/index.d.ts +8 -0
  92. package/dist/motion-scroll/index.d.ts +19 -0
  93. package/dist/motion-scroll.cjs +1 -0
  94. package/dist/motion-scroll.js +169 -0
  95. package/dist/motion.cjs +1 -0
  96. package/dist/motion.js +187 -0
  97. package/dist/operations.cjs +1 -0
  98. package/dist/operations.d.ts +3 -0
  99. package/dist/operations.js +10 -0
  100. package/dist/profile/DOMProfile.d.ts +4 -0
  101. package/dist/profile/index.d.ts +1 -0
  102. package/dist/profile.cjs +1 -0
  103. package/dist/profile.js +23 -0
  104. package/dist/renderer/DOMEffectScope.d.ts +13 -0
  105. package/dist/renderer/DOMPresentation.d.ts +8 -0
  106. package/dist/renderer/DOMRenderer.d.ts +35 -0
  107. package/dist/renderer/DOMRenderer.types.d.ts +12 -0
  108. package/dist/renderer/DOMRendererExtension.types.d.ts +33 -0
  109. package/dist/renderer/DOMRuntimeProfile.d.ts +15 -0
  110. package/dist/renderer/DOMTargetRuntime.d.ts +1 -0
  111. package/dist/renderer/createDOMTargetRuntime.d.ts +3 -0
  112. package/dist/renderer/installAuxiliaryViews.d.ts +8 -0
  113. package/dist/renderer/installDOMRendererExtensions.d.ts +10 -0
  114. package/dist/renderer/resolveDOMMountTarget.d.ts +7 -0
  115. package/dist/renderer-4Wbid5nE.js +30 -0
  116. package/dist/renderer-DHK3lLG-.cjs +1 -0
  117. package/dist/resolveDOMMountTarget-C75JWc5x.cjs +1 -0
  118. package/dist/resolveDOMMountTarget-D944H05N.js +19 -0
  119. package/dist/runtime.cjs +1 -0
  120. package/dist/runtime.d.ts +21 -0
  121. package/dist/runtime.js +25 -0
  122. package/dist/serialization.cjs +1 -0
  123. package/dist/serialization.d.ts +4 -0
  124. package/dist/serialization.js +118 -0
  125. package/dist/stylesheet/DOMStyleManager.d.ts +95 -0
  126. package/dist/stylesheet/DOMStyleReferenceName.d.ts +2 -0
  127. package/dist/stylesheet/DOMStylesheetRuntime.d.ts +25 -0
  128. package/dist/stylesheet/acquireInstanceStylesheets.d.ts +4 -0
  129. package/dist/stylesheet/scopeDOMSelector.d.ts +2 -0
  130. package/dist/stylesheet/serializeDOMStyleValue.d.ts +3 -0
  131. package/dist/targetRuntime-C67QmOgE.cjs +1 -0
  132. package/dist/targetRuntime-C_OdmS5w.js +5 -0
  133. package/dist/template/AdvancedDOMMaterializer.d.ts +14 -0
  134. package/dist/template/AsyncDOMMaterializer.d.ts +4 -0
  135. package/dist/template/BoundaryDOMMaterializer.d.ts +10 -0
  136. package/dist/template/DOMHostPlan.d.ts +4 -0
  137. package/dist/template/DOMNode.types.d.ts +192 -0
  138. package/dist/template/DOMNodeRuntime.d.ts +1 -0
  139. package/dist/template/binding/DOMBinding.types.d.ts +44 -0
  140. package/dist/template/binding/bind.d.ts +16 -0
  141. package/dist/template/blueprint/DOMBlueprintAddressing.d.ts +23 -0
  142. package/dist/template/blueprint/DOMBlueprintMaterializer.d.ts +3 -0
  143. package/dist/template/blueprint/DOMBlueprintMaterializer.types.d.ts +15 -0
  144. package/dist/template/blueprint/DOMHostBlueprint.d.ts +102 -0
  145. package/dist/template/blueprint/DOMHostBlueprintCache.d.ts +86 -0
  146. package/dist/template/blueprint/createDOMDataEventInput.d.ts +5 -0
  147. package/dist/template/blueprint/mountDOMHostBlueprint.d.ts +45 -0
  148. package/dist/template/createDOMNodeRuntime.d.ts +3 -0
  149. package/dist/template/each/mountEach.d.ts +5 -0
  150. package/dist/template/each/mountPureEach.d.ts +22 -0
  151. package/dist/template/error/DOMInvocation.d.ts +58 -0
  152. package/dist/template/error/DOMOperationError.d.ts +25 -0
  153. package/dist/template/html/DOMRawHtmlNode.types.d.ts +21 -0
  154. package/dist/template/html/rawHtml.d.ts +5 -0
  155. package/dist/template/keep-alive/DOMKeepAliveNode.types.d.ts +10 -0
  156. package/dist/template/keep-alive/keepAlive.d.ts +4 -0
  157. package/dist/template/mount/DOMMountTransaction.d.ts +63 -0
  158. package/dist/template/mountNode.d.ts +173 -0
  159. package/dist/template/normalizeChildren.d.ts +5 -0
  160. package/dist/template/operations/DOMOperations.d.ts +56 -0
  161. package/dist/template/operations/FullDOMOperations.d.ts +6 -0
  162. package/dist/template/page/DOMHead.d.ts +7 -0
  163. package/dist/template/page/PageNodePlan.d.ts +31 -0
  164. package/dist/template/ref/DOMElementRef.types.d.ts +7 -0
  165. package/dist/template/ref/componentRefGuard.d.ts +6 -0
  166. package/dist/template/ref/elementRef.d.ts +9 -0
  167. package/dist/template/structural/range/DOMRange.d.ts +145 -0
  168. package/dist/template/teleport/DOMTeleportNode.types.d.ts +8 -0
  169. package/dist/template/teleport/teleport.d.ts +4 -0
  170. package/dist/template/transition/DOMTransitionCoordinator.d.ts +32 -0
  171. package/dist/template/transition/DOMTransitionNode.types.d.ts +30 -0
  172. package/dist/template/transition/transition.d.ts +4 -0
  173. package/dist/template/value/DOMValueDescriptor.types.d.ts +34 -0
  174. package/dist/template/value/valueDescriptors.d.ts +13 -0
  175. package/package.json +157 -4
@@ -0,0 +1,1603 @@
1
+ import { requireTargetCapability as Ae } from "@raphy-js/core";
2
+ import { NATIVE_DRAG_DROP_CAPABILITY as ke, GEOMETRY_CAPABILITY as Ne, POSITIONING_CAPABILITY as Pe, SCROLL_CAPABILITY as Le, FOCUS_CAPABILITY as Fe, FOCUS_NAVIGATION_CAPABILITY as Ge, ROVING_FOCUS_CAPABILITY as Ye, PRESS_CAPABILITY as Ve, HOVER_CAPABILITY as ce, KEYBOARD_CAPABILITY as Be, CONTEXT_ACTION_CAPABILITY as We, MOVE_CAPABILITY as He, OUTSIDE_CAPABILITY as Ke, TEXT_EDITING_CAPABILITY as qe, DRAG_DROP_CAPABILITY as $e, INPUT_MODALITY_CAPABILITY as Ue, CLIPBOARD_CAPABILITY as Xe } from "@raphy-js/interaction";
3
+ import { GEOMETRY_CAPABILITY as Ze } from "@raphy-js/interaction/geometry";
4
+ import { containsHoverBridge as Je } from "@raphy-js/interaction/hover";
5
+ import { r as le } from "./applicationIdentity-DjVgpsQq.js";
6
+ import { r as Qe } from "./renderer-4Wbid5nE.js";
7
+ import { r as et } from "./resolveDOMMountTarget-D944H05N.js";
8
+ function tt(t, e) {
9
+ return Object.freeze({
10
+ async readText() {
11
+ e();
12
+ const r = ue(t);
13
+ if ("status" in r)
14
+ return r;
15
+ try {
16
+ return Object.freeze({
17
+ status: "success",
18
+ value: await r.clipboard.readText()
19
+ });
20
+ } catch (i) {
21
+ return fe(i);
22
+ }
23
+ },
24
+ async writeText(r) {
25
+ e();
26
+ const i = ue(t);
27
+ if ("status" in i)
28
+ return i;
29
+ try {
30
+ return await i.clipboard.writeText(r), Object.freeze({ status: "success", value: void 0 });
31
+ } catch (o) {
32
+ return fe(o);
33
+ }
34
+ }
35
+ });
36
+ }
37
+ function ue(t) {
38
+ const e = t.defaultView;
39
+ if (e?.isSecureContext === !1 || rt(t.location))
40
+ return Object.freeze({ status: "insecure" });
41
+ const r = e?.navigator.clipboard;
42
+ return r === void 0 ? Object.freeze({ status: "unavailable" }) : { clipboard: r };
43
+ }
44
+ function rt(t) {
45
+ return t === null || t.protocol !== "http:" ? !1 : t.hostname !== "localhost" && t.hostname !== "127.0.0.1" && t.hostname !== "[::1]";
46
+ }
47
+ function fe(t) {
48
+ const e = typeof t == "object" && t !== null ? Reflect.get(t, "name") : void 0;
49
+ return Object.freeze({ error: t, status: e === "NotAllowedError" || e === "SecurityError" ? "denied" : "failed" });
50
+ }
51
+ function B(t) {
52
+ const e = t;
53
+ return Object.freeze({
54
+ alt: e.altKey === !0,
55
+ control: e.ctrlKey === !0,
56
+ meta: e.metaKey === !0,
57
+ shift: e.shiftKey === !0
58
+ });
59
+ }
60
+ function L(t) {
61
+ const e = t;
62
+ return typeof e.clientX == "number" && typeof e.clientY == "number" ? Object.freeze({ x: e.clientX, y: e.clientY }) : void 0;
63
+ }
64
+ function W(t) {
65
+ const e = Reflect.get(t, "pointerType");
66
+ return typeof e == "string" && e.length > 0 ? e : t.type.startsWith("touch") ? "touch" : "mouse";
67
+ }
68
+ function k(t, e, r, i) {
69
+ t.size === 0 && r?.(), t.add(e);
70
+ let o = !0;
71
+ return () => {
72
+ o && (o = !1, t.delete(e), t.size === 0 && i?.());
73
+ };
74
+ }
75
+ function E(t, e) {
76
+ for (const r of [...t])
77
+ r(e);
78
+ }
79
+ function M(...t) {
80
+ let e = !0;
81
+ return () => {
82
+ if (!e)
83
+ return;
84
+ e = !1;
85
+ const r = [];
86
+ for (let i = t.length - 1; i >= 0; i--)
87
+ try {
88
+ t[i]();
89
+ } catch (o) {
90
+ r.push(o);
91
+ }
92
+ if (r.length === 1)
93
+ throw r[0];
94
+ if (r.length > 1)
95
+ throw new AggregateError(r, "[RaphyDOMInteraction] Listener cleanup failed.");
96
+ };
97
+ }
98
+ function C(t, e, r, i, o = !1) {
99
+ const n = /* @__PURE__ */ new WeakSet(), c = (a) => {
100
+ n.has(a) || (n.add(a), i(a));
101
+ }, s = t.listen(e, r, c, o);
102
+ try {
103
+ return M(s, t.listenBoundaries(r, c, o));
104
+ } catch (a) {
105
+ throw s(), a;
106
+ }
107
+ }
108
+ function it(t, e) {
109
+ const r = /* @__PURE__ */ new Set();
110
+ let i, o = !1;
111
+ const n = (s, a) => {
112
+ if (t.matches(':disabled, [aria-disabled="true"]') || t.closest("[inert], [hidden]") !== null)
113
+ return;
114
+ const u = a === "pointer" ? L(s) : void 0;
115
+ if (u !== void 0 && (!Number.isFinite(u.x) || !Number.isFinite(u.y)))
116
+ throw new TypeError("[RaphyDOMInteraction] Context action coordinates must be finite.");
117
+ e.modality.set(a), E(r, Object.freeze({ source: a, point: u, modifiers: B(s), preventDefault: () => s.preventDefault() }));
118
+ }, c = () => {
119
+ const s = [];
120
+ try {
121
+ s.push(e.events.listen(t, "contextmenu", (a) => {
122
+ if (!a.defaultPrevented && !o) {
123
+ const u = Reflect.get(a, "button");
124
+ n(a, u === 2 || u === 0 && B(a).control ? "pointer" : "keyboard");
125
+ }
126
+ })), s.push(e.events.listen(t, "compositionstart", () => {
127
+ o = !0;
128
+ })), s.push(e.events.listen(t, "compositionend", () => {
129
+ o = !1;
130
+ })), s.push(e.events.listen(t, "keydown", (a) => {
131
+ const u = Reflect.get(a, "key"), l = B(a);
132
+ !o && Reflect.get(a, "isComposing") !== !0 && Reflect.get(a, "keyCode") !== 229 && !a.defaultPrevented && !l.alt && !l.control && !l.meta && (u === "ContextMenu" || u === "F10" && l.shift) && n(a, "keyboard");
133
+ })), i = M(...s);
134
+ } catch (a) {
135
+ try {
136
+ M(...s)();
137
+ } catch (u) {
138
+ throw new AggregateError([a, u], "[RaphyDOMInteraction] Context action setup and rollback failed.");
139
+ }
140
+ throw a;
141
+ }
142
+ };
143
+ return Object.freeze({
144
+ subscribe(s) {
145
+ return e.assertActive(), k(r, s, c, () => {
146
+ i?.(), i = void 0, o = !1;
147
+ });
148
+ }
149
+ });
150
+ }
151
+ function Re(t, e) {
152
+ const r = [];
153
+ if (typeof t == "object" && t !== null) {
154
+ const i = Reflect.get(t, "types"), o = Reflect.get(t, "getData");
155
+ if (typeof o == "function" && i !== null && typeof i == "object")
156
+ for (const n of Array.from(i))
157
+ n !== e && r.push([n, String(Reflect.apply(o, t, [n]))]);
158
+ }
159
+ return Object.freeze({ formats: Object.freeze(Object.fromEntries(r)) });
160
+ }
161
+ function De(t, e) {
162
+ if (typeof t != "object" || t === null)
163
+ return;
164
+ const r = Reflect.get(t, "setData");
165
+ if (typeof r == "function")
166
+ for (const [i, o] of Object.entries(e.formats))
167
+ Reflect.apply(r, t, [i, o]);
168
+ }
169
+ class nt {
170
+ _records = /* @__PURE__ */ new WeakMap();
171
+ _services;
172
+ constructor(e) {
173
+ this._services = e;
174
+ }
175
+ capability(e, r) {
176
+ let i = this._records.get(e);
177
+ if (i === void 0)
178
+ i = {
179
+ element: e,
180
+ listeners: /* @__PURE__ */ new Set(),
181
+ reference: r
182
+ }, this._records.set(e, i);
183
+ else if (i.reference !== r)
184
+ throw new Error("[RaphyDOMInteraction] One DOM target is assigned to multiple live TargetRefs.");
185
+ return Object.freeze({
186
+ start: (o) => this._start(i, o),
187
+ subscribeDrop: (o) => this._subscribeDrop(i, o)
188
+ });
189
+ }
190
+ _subscribeDrop(e, r) {
191
+ return this._services.assertActive(), k(e.listeners, r, () => {
192
+ e.cleanup = M(
193
+ this._services.events.listen(e.element, "dragover", (i) => i.preventDefault()),
194
+ this._services.events.listen(e.element, "drop", (i) => {
195
+ i.preventDefault();
196
+ const o = Re(Reflect.get(i, "dataTransfer"));
197
+ E(e.listeners, Object.freeze({ data: o, source: null }));
198
+ })
199
+ );
200
+ }, () => {
201
+ e.cleanup?.(), e.cleanup = void 0;
202
+ });
203
+ }
204
+ _start(e, r) {
205
+ this._services.assertActive();
206
+ const i = /* @__PURE__ */ new Set();
207
+ let o = this._resolveRecordAt(r.point), n = !0, c;
208
+ const s = new Promise((d) => {
209
+ c = d;
210
+ }), a = e.element.getAttribute("draggable");
211
+ e.element.setAttribute("draggable", "true");
212
+ let u = () => {
213
+ }, l = () => {
214
+ };
215
+ const f = (d, m = r.point) => {
216
+ d === o && m === void 0 || (o = d, E(i, Object.freeze({
217
+ over: d?.reference ?? null,
218
+ point: m
219
+ })));
220
+ }, h = (d) => {
221
+ n && (n = !1, l(), a === null ? e.element.removeAttribute("draggable") : e.element.setAttribute("draggable", a), i.clear(), u(), c(d));
222
+ }, O = () => {
223
+ if (!n)
224
+ return;
225
+ const d = o;
226
+ d !== void 0 && E(d.listeners, Object.freeze({
227
+ data: r.data,
228
+ source: e.reference
229
+ })), h(Object.freeze({
230
+ dropTarget: d?.reference ?? null,
231
+ status: "dropped"
232
+ }));
233
+ };
234
+ l = M(
235
+ C(this._services.events, this._services.document, "pointermove", (d) => {
236
+ const m = L(d);
237
+ f(this._resolveRecordAt(m), m);
238
+ }, { capture: !0 }),
239
+ C(this._services.events, this._services.document, "pointerup", O, { capture: !0 }),
240
+ C(this._services.events, this._services.document, "focusin", (d) => {
241
+ r.source === "keyboard" && f(this._resolveRecord(d.target));
242
+ }, { capture: !0 }),
243
+ C(this._services.events, this._services.document, "keydown", (d) => {
244
+ const m = Reflect.get(d, "key");
245
+ m === "Escape" ? h(Object.freeze({ status: "cancelled" })) : r.source === "keyboard" && (m === "Enter" || m === " ") && (d.preventDefault(), O());
246
+ }, { capture: !0 }),
247
+ this._services.events.listen(e.element, "dragstart", (d) => {
248
+ De(Reflect.get(d, "dataTransfer"), r.data);
249
+ }),
250
+ this._services.events.listen(e.element, "dragend", (d) => {
251
+ const m = Reflect.get(Reflect.get(d, "dataTransfer"), "dropEffect");
252
+ n && (m === "none" ? h(Object.freeze({ status: "cancelled" })) : O());
253
+ })
254
+ );
255
+ const g = Object.freeze({
256
+ cancel: () => h(Object.freeze({ status: "cancelled" })),
257
+ drop: O,
258
+ finished: s,
259
+ subscribe(d) {
260
+ if (!n)
261
+ throw new Error("[RaphyDOMInteraction] Drag session is finished.");
262
+ return k(i, d);
263
+ }
264
+ });
265
+ return u = this._services.registerSession(g), o !== void 0 && f(o, r.point), g;
266
+ }
267
+ _resolveRecordAt(e) {
268
+ const r = Reflect.get(this._services.document, "elementFromPoint");
269
+ return e === void 0 || typeof r != "function" ? void 0 : this._resolveRecord(Reflect.apply(
270
+ r,
271
+ this._services.document,
272
+ [e.x, e.y]
273
+ ));
274
+ }
275
+ _resolveRecord(e) {
276
+ let r = e !== null && Reflect.get(e, "nodeType") === 1 ? e : null;
277
+ for (; r !== null; ) {
278
+ const i = this._records.get(r);
279
+ if (i !== void 0)
280
+ return i;
281
+ const o = r.getRootNode();
282
+ r = r.parentElement ?? (o.nodeType === 11 && "host" in o ? o.host : null);
283
+ }
284
+ }
285
+ }
286
+ function ot(t, e) {
287
+ const r = /* @__PURE__ */ new Set();
288
+ let i;
289
+ const o = () => {
290
+ e.assertActive();
291
+ const s = re(t);
292
+ return Object.freeze({
293
+ focused: s,
294
+ focusVisible: s && at(t, e.modality.get())
295
+ });
296
+ }, n = () => E(r, o()), c = () => {
297
+ i = M(
298
+ e.events.listen(t, "focus", n, { capture: !0 }),
299
+ e.events.listen(t, "blur", n, { capture: !0 }),
300
+ e.modality.subscribe(() => {
301
+ re(t) && n();
302
+ })
303
+ );
304
+ };
305
+ return Object.freeze({
306
+ blur() {
307
+ e.assertActive();
308
+ const s = Reflect.get(t, "blur");
309
+ typeof s == "function" && Reflect.apply(s, t, []);
310
+ },
311
+ focus(s) {
312
+ e.assertActive(), Ie(t, s);
313
+ },
314
+ getState: o,
315
+ subscribe(s) {
316
+ return e.assertActive(), k(r, s, c, () => {
317
+ i?.(), i = void 0;
318
+ });
319
+ }
320
+ });
321
+ }
322
+ function st(t, e) {
323
+ const r = (i, o, n = {}) => {
324
+ e.assertActive();
325
+ const c = ct(t);
326
+ if (c.length === 0)
327
+ return !1;
328
+ let s;
329
+ if (o !== void 0)
330
+ s = o === "first" ? c[0] : c.at(-1);
331
+ else {
332
+ const a = dt(n.from?.current, t.ownerDocument) ?? de(t.ownerDocument), u = a === null ? -1 : c.indexOf(a), l = u + i;
333
+ l >= 0 && l < c.length ? s = c[l] : (n.wrap === !0 || u < 0) && (s = i === 1 ? c[0] : c.at(-1));
334
+ }
335
+ return s === void 0 ? !1 : (Ie(s, { preventScroll: n.preventScroll }), re(s));
336
+ };
337
+ return Object.freeze({
338
+ containsFocus() {
339
+ e.assertActive();
340
+ const i = de(t.ownerDocument);
341
+ return i !== null && ft(t, i);
342
+ },
343
+ focusFirst: (i) => r(1, "first", i),
344
+ focusLast: (i) => r(-1, "last", i),
345
+ focusNext: (i) => r(1, void 0, i),
346
+ focusPrevious: (i) => r(-1, void 0, i)
347
+ });
348
+ }
349
+ function Ie(t, e = {}) {
350
+ const r = Reflect.get(t, "focus");
351
+ if (typeof r == "function" && (Reflect.apply(r, t, [{ preventScroll: e.preventScroll === !0 }]), e.selectText === !0)) {
352
+ const i = Reflect.get(t, "select");
353
+ typeof i == "function" && Reflect.apply(i, t, []);
354
+ }
355
+ }
356
+ function at(t, e) {
357
+ try {
358
+ return t.matches(":focus-visible");
359
+ } catch {
360
+ return e === "keyboard";
361
+ }
362
+ }
363
+ function re(t) {
364
+ const e = Te(t.ownerDocument);
365
+ return e === t ? !0 : e?.getAttribute("aria-activedescendant") === t.id && t.id.length > 0;
366
+ }
367
+ function de(t) {
368
+ const e = Te(t);
369
+ if (e === null)
370
+ return null;
371
+ const r = e.getAttribute("aria-activedescendant");
372
+ return r === null ? e : t.getElementById(r) ?? e;
373
+ }
374
+ function Te(t) {
375
+ let e = t.activeElement;
376
+ for (; e?.shadowRoot?.activeElement !== null && e?.shadowRoot?.activeElement !== void 0; )
377
+ e = e.shadowRoot.activeElement;
378
+ return e;
379
+ }
380
+ function ct(t) {
381
+ const e = [];
382
+ let r = 0;
383
+ const i = (o) => {
384
+ for (const n of Array.from(o.children))
385
+ lt(n) ? e.push({ element: n, order: r++, tabIndex: Me(n) }) : r++, n.shadowRoot !== null && i(n.shadowRoot), i(n);
386
+ };
387
+ return i(t), e.sort((o, n) => {
388
+ const c = o.tabIndex > 0, s = n.tabIndex > 0;
389
+ return c !== s ? c ? -1 : 1 : c && o.tabIndex !== n.tabIndex ? o.tabIndex - n.tabIndex : o.order - n.order;
390
+ }).map((o) => o.element);
391
+ }
392
+ function lt(t) {
393
+ if (Me(t) < 0 || t.hasAttribute("disabled") || t.getAttribute("aria-disabled") === "true" || ut(t))
394
+ return !1;
395
+ const e = t.ownerDocument.defaultView;
396
+ if (e !== null) {
397
+ const r = e.getComputedStyle(t);
398
+ if (r.display === "none" || r.visibility === "hidden")
399
+ return !1;
400
+ }
401
+ return typeof Reflect.get(t, "focus") == "function";
402
+ }
403
+ function Me(t) {
404
+ const e = Reflect.get(t, "tabIndex");
405
+ return typeof e == "number" ? e : -1;
406
+ }
407
+ function ut(t) {
408
+ let e = t;
409
+ for (; e !== null; ) {
410
+ if (e.hasAttribute("hidden") || e.hasAttribute("inert") || e.getAttribute("aria-hidden") === "true")
411
+ return !0;
412
+ const r = e.getRootNode();
413
+ e = e.parentElement ?? (Se(r) ? r.host : null);
414
+ }
415
+ return !1;
416
+ }
417
+ function ft(t, e) {
418
+ let r = e;
419
+ for (; r !== null; ) {
420
+ if (r === t)
421
+ return !0;
422
+ const i = r.getRootNode();
423
+ r = r.parentElement ?? (Se(i) ? i.host : null);
424
+ }
425
+ return !1;
426
+ }
427
+ function Se(t) {
428
+ return t.nodeType === 11 && "host" in t;
429
+ }
430
+ function dt(t, e) {
431
+ return t != null && Reflect.get(t, "nodeType") === 1 && Reflect.get(t, "ownerDocument") === e ? t : null;
432
+ }
433
+ function ht(t, e, r, i, o, n, c, s = []) {
434
+ for (const w of [t, e, r, ...s])
435
+ if (![w.x, w.y, w.width, w.height].every(Number.isFinite) || w.width < 0 || w.height < 0)
436
+ throw new TypeError("[RaphyDOM] Position rectangles must be finite with non-negative sizes.");
437
+ if (!Number.isFinite(o) || !Number.isFinite(n) || n < 0)
438
+ throw new TypeError("[RaphyDOM] Position offset must be finite and padding non-negative.");
439
+ const [a, u] = i.split("-");
440
+ if (!["top", "bottom", "left", "right"].includes(a) || u !== void 0 && u !== "start" && u !== "end" || i !== `${a}${u === void 0 ? "" : `-${u}`}`)
441
+ throw new TypeError("[RaphyDOM] Invalid overlay placement.");
442
+ const l = a === "left" || a === "right", f = l ? e.width : e.height, h = {
443
+ top: t.y - r.y - n - o,
444
+ bottom: r.y + r.height - n - t.y - t.height - o,
445
+ left: t.x - r.x - n - o,
446
+ right: r.x + r.width - n - t.x - t.width - o
447
+ }, O = { top: "bottom", bottom: "top", left: "right", right: "left" }, g = h[a] < f && h[O[a]] > h[a] ? O[a] : a, d = l ? t.y : t.x, m = l ? t.height : t.width, v = l ? e.height : e.width, A = u === void 0 ? d + (m - v) / 2 : (u === "start" ? l || !c : !l && c) ? d : d + m - v, R = g === "left" ? t.x - e.width - o : g === "right" ? t.x + t.width + o : A, y = g === "top" ? t.y - e.height - o : g === "bottom" ? t.y + t.height + o : A, b = (w, I, N, j) => Math.max(I + n, Math.min(w, I + N - n - j)), p = Object.freeze({
448
+ x: b(R, r.x, r.width, e.width),
449
+ y: b(y, r.y, r.height, e.height),
450
+ placement: `${g}${u === void 0 ? "" : `-${u}`}`,
451
+ availableWidth: Math.max(0, l ? h[g] : r.width - 2 * n),
452
+ availableHeight: Math.max(0, l ? r.height - 2 * n : h[g])
453
+ }), D = s.filter((w) => w.width > 0 && w.height > 0);
454
+ if (!D.length || z(p.x, p.y) === 0)
455
+ return p;
456
+ let F = p, x = z(p.x, p.y);
457
+ const _ = [g, O[g], ...l ? ["top", "bottom"] : ["right", "left"]];
458
+ for (const w of _) {
459
+ const I = w === "left" || w === "right", N = I ? t.y : t.x, j = I ? t.height : t.width, ne = I ? e.height : e.width, Z = u === void 0 ? N + (j - ne) / 2 : (u === "start" ? I || !c : !I && c) ? N : N + j - ne, q = w === "top" ? t.y - e.height - o : w === "bottom" ? t.y + t.height + o : w === "left" ? t.x - e.width - o : t.x + t.width + o, ze = I ? [Z, r.y + n, r.y + r.height - n - e.height, ...D.flatMap((S) => [S.y - e.height - n, S.y + S.height + n])] : [Z, r.x + n, r.x + r.width - n - e.width, ...D.flatMap((S) => [S.x - e.width - n, S.x + S.width + n])], je = [q, ...D.map((S) => w === "top" ? S.y - e.height - n : w === "bottom" ? S.y + S.height + n : w === "left" ? S.x - e.width - n : S.x + S.width + n)].filter((S) => w === "top" || w === "left" ? S <= q : S >= q);
460
+ let J, oe = 1 / 0;
461
+ for (const S of new Set(je))
462
+ for (const Q of new Set(ze)) {
463
+ const $ = b(I ? S : Q, r.x, r.width, e.width), U = b(I ? Q : S, r.y, r.height, e.height), H = z($, U), se = Math.abs(S - q) + Math.abs(Q - Z);
464
+ if (H !== 0 && H >= x || H === 0 && se >= oe)
465
+ continue;
466
+ const ae = Object.freeze({
467
+ x: $,
468
+ y: U,
469
+ placement: `${w}${u === void 0 ? "" : `-${u}`}`,
470
+ availableWidth: Math.max(0, Math.min(r.width - 2 * n, w === "left" ? $ + e.width - r.x - n : w === "right" ? r.x + r.width - n - $ : r.width - 2 * n)),
471
+ availableHeight: Math.max(0, Math.min(r.height - 2 * n, w === "top" ? U + e.height - r.y - n : w === "bottom" ? r.y + r.height - n - U : r.height - 2 * n))
472
+ });
473
+ H === 0 ? (J = ae, oe = se) : (F = ae, x = H);
474
+ }
475
+ if (J)
476
+ return J;
477
+ }
478
+ return F;
479
+ function z(w, I) {
480
+ return D.reduce((N, j) => N + Math.max(0, Math.min(w + e.width, j.x + j.width + n) - Math.max(w, j.x - n)) * Math.max(0, Math.min(I + e.height, j.y + j.height + n) - Math.max(I, j.y - n)), 0);
481
+ }
482
+ }
483
+ class pt {
484
+ _elements = /* @__PURE__ */ new WeakMap();
485
+ _geometry = /* @__PURE__ */ new WeakMap();
486
+ _services;
487
+ /**
488
+ * Использует lifecycle и event facade существующего Interaction extension.
489
+ */
490
+ constructor(e) {
491
+ this._services = e;
492
+ }
493
+ /**
494
+ * Измеряет target; observation создаётся только по отдельному запросу.
495
+ */
496
+ geometry(e) {
497
+ const r = this._geometry.get(e);
498
+ if (r)
499
+ return r;
500
+ const i = Object.freeze({
501
+ measure: () => (this._services.assertActive(), V(e)),
502
+ observe: (o) => this._observe([e], () => o(V(e)))
503
+ });
504
+ return this._elements.set(i, e), this._geometry.set(e, i), i;
505
+ }
506
+ /**
507
+ * Возвращает координаты fixed-surface, не изменяя её inline styles.
508
+ */
509
+ positioning(e) {
510
+ return Object.freeze({
511
+ observe: (r, i) => {
512
+ const o = "current" in r.anchor ? this._resolve(r.anchor) : void 0, n = o ? void 0 : r.anchor, c = r.boundary ? this._resolve(r.boundary) : void 0, s = [...new Set((r.avoid ?? []).map((a) => this._resolve(a)))];
513
+ if (s.includes(e))
514
+ throw new TypeError("[RaphyDOM] A positioned surface cannot avoid itself.");
515
+ return this._observe([e, ...o ? [o] : [], ...c ? [c] : [], ...s], () => {
516
+ const a = this._view(), u = a.visualViewport, l = c ? V(c) : {
517
+ x: u?.offsetLeft ?? 0,
518
+ y: u?.offsetTop ?? 0,
519
+ width: u?.width ?? a.innerWidth,
520
+ height: u?.height ?? a.innerHeight
521
+ }, f = o ? V(o) : { ...n, width: 0, height: 0 };
522
+ i(ht(f, V(e), l, r.placement ?? "bottom", r.offset ?? 8, r.padding ?? 8, o ? a.getComputedStyle(o).direction === "rtl" : !1, s.map(V)));
523
+ }, s);
524
+ }
525
+ });
526
+ }
527
+ /**
528
+ * Сохраняет native viewport и нормализует отрицательные RTL scroll offsets.
529
+ */
530
+ scrolling(e) {
531
+ const r = () => {
532
+ this._services.assertActive();
533
+ const i = this._view().getComputedStyle(e).direction === "rtl";
534
+ return Object.freeze({
535
+ direction: i ? "rtl" : "ltr",
536
+ x: i ? -e.scrollLeft : e.scrollLeft,
537
+ y: e.scrollTop,
538
+ width: e.scrollWidth,
539
+ height: e.scrollHeight,
540
+ viewportWidth: e.clientWidth,
541
+ viewportHeight: e.clientHeight
542
+ });
543
+ };
544
+ return Object.freeze({
545
+ read: r,
546
+ scrollTo: (i) => {
547
+ const o = r(), n = i.x ?? o.x, c = i.y ?? o.y;
548
+ if (!Number.isFinite(n) || !Number.isFinite(c))
549
+ throw new TypeError("[RaphyDOM] Scroll offsets must be finite.");
550
+ const s = this._view().getComputedStyle(e).direction === "rtl";
551
+ e.scrollTo({ left: s ? -n : n, top: c, behavior: i.behavior ?? "instant" });
552
+ },
553
+ observe: (i) => this._observe([e], () => i(r()))
554
+ });
555
+ }
556
+ /**
557
+ * Отклоняет чужой application ref даже при совпадении document.
558
+ */
559
+ _resolve(e) {
560
+ this._services.assertActive();
561
+ const r = Ae(e, Ze), i = this._elements.get(r);
562
+ if (!i)
563
+ throw new Error("[RaphyDOM] Position anchor/boundary/avoid target belongs to another application.");
564
+ return i;
565
+ }
566
+ /**
567
+ * Удерживает одну observation session до close/dispose; initial delivery синхронная.
568
+ */
569
+ _observe(e, r, i = []) {
570
+ this._services.assertActive();
571
+ const o = this._view();
572
+ if (typeof o.requestAnimationFrame != "function")
573
+ throw new TypeError("[RaphyDOM] Geometry observation requires requestAnimationFrame.");
574
+ const n = o.ResizeObserver;
575
+ if (!n)
576
+ throw new Error("[RaphyDOM] Geometry observation requires ResizeObserver.");
577
+ const c = o.MutationObserver;
578
+ if (i.length && !c)
579
+ throw new Error("[RaphyDOM] Obstacle positioning requires MutationObserver.");
580
+ let s = !0, a, u, l = () => {
581
+ };
582
+ const f = () => {
583
+ if (s) {
584
+ s = !1, a !== void 0 && o.cancelAnimationFrame(a);
585
+ try {
586
+ u();
587
+ } finally {
588
+ l();
589
+ }
590
+ }
591
+ }, h = () => {
592
+ s && a === void 0 && (a = o.requestAnimationFrame(() => {
593
+ if (a = void 0, s)
594
+ try {
595
+ r();
596
+ } catch (d) {
597
+ throw f(), d;
598
+ }
599
+ }));
600
+ }, O = new n(h), g = [() => O.disconnect()];
601
+ try {
602
+ for (const d of new Set(e))
603
+ O.observe(d);
604
+ if (i.length && c) {
605
+ const d = new c(h);
606
+ g.push(() => d.disconnect());
607
+ for (const m of i)
608
+ d.observe(m, { attributes: !0, attributeFilter: ["style", "class", "hidden"] });
609
+ }
610
+ if (g.push(C(this._services.events, this._services.document, "scroll", h, { capture: !0, passive: !0 })), g.push(this._services.events.listen(o, "resize", h, { passive: !0 })), o.visualViewport)
611
+ for (const d of ["scroll", "resize"])
612
+ o.visualViewport.addEventListener(d, h, { passive: !0 }), g.push(() => o.visualViewport.removeEventListener(d, h));
613
+ return u = M(...g), l = this._services.registerSession({ cancel: f }), r(), f;
614
+ } catch (d) {
615
+ throw u = M(...g), f(), d;
616
+ }
617
+ }
618
+ /**
619
+ * Не подменяет отсутствующий browsing context глобальным window.
620
+ */
621
+ _view() {
622
+ const e = this._services.document.defaultView;
623
+ if (!e)
624
+ throw new Error("[RaphyDOM] Geometry requires a document with a browsing context.");
625
+ return e;
626
+ }
627
+ }
628
+ function V(t) {
629
+ const e = t.getBoundingClientRect();
630
+ return Object.freeze({ x: e.x, y: e.y, width: e.width, height: e.height });
631
+ }
632
+ function vt(t, e, r) {
633
+ const i = /* @__PURE__ */ new Set();
634
+ let o = !1, n;
635
+ const c = (a, u) => {
636
+ const l = W(u);
637
+ l === "touch" || l === "mouse" && e.modality.recentTouch() || a === o || (o = a, E(i, Object.freeze({
638
+ hovered: o,
639
+ point: L(u),
640
+ pointerType: l
641
+ })));
642
+ }, s = () => {
643
+ n = M(
644
+ e.events.listen(t, "pointerover", (a) => {
645
+ he(t, a) || c(!0, a);
646
+ }),
647
+ e.events.listen(t, "pointerout", (a) => {
648
+ he(t, a) || c(!1, a);
649
+ })
650
+ );
651
+ };
652
+ return Object.freeze({
653
+ get() {
654
+ return e.assertActive(), o;
655
+ },
656
+ subscribe(a) {
657
+ return e.assertActive(), k(i, a, s, () => {
658
+ o = !1, n?.(), n = void 0;
659
+ });
660
+ },
661
+ subscribeRegion(a, u) {
662
+ return e.assertActive(), bt(t, e, a, u, r);
663
+ }
664
+ });
665
+ }
666
+ function he(t, e) {
667
+ const r = Reflect.get(e, "relatedTarget");
668
+ return r !== null && typeof r == "object" && Reflect.get(r, "nodeType") === 1 && t.contains(r);
669
+ }
670
+ function bt(t, e, r, i, o) {
671
+ const n = (i.boundaries ?? []).map(o), c = [t, ...n], s = [];
672
+ let a = !0, u = !1, l, f;
673
+ const h = (v) => v.isConnected && v.getClientRects().length > 0 && v.closest('[hidden], [inert], [disabled], [aria-disabled="true"]') === null && e.document.defaultView?.getComputedStyle(v).visibility !== "hidden", O = (v) => {
674
+ const T = h(t) ? t.getBoundingClientRect() : void 0;
675
+ for (const A of c) {
676
+ if (!h(A))
677
+ continue;
678
+ const R = A.getBoundingClientRect();
679
+ if (v.x >= R.left && v.x <= R.right && v.y >= R.top && v.y <= R.bottom || i.bridge && A !== t && T && Je(v, T, R))
680
+ return !0;
681
+ }
682
+ return !1;
683
+ }, g = () => {
684
+ if (!a)
685
+ return;
686
+ a = !1;
687
+ const v = l;
688
+ l = void 0, M(...s, () => v?.())();
689
+ }, d = (v, T) => {
690
+ if (!(!a || v === u)) {
691
+ if (u = v, !v)
692
+ l?.(), l = void 0;
693
+ else {
694
+ const A = [];
695
+ try {
696
+ const R = (b) => {
697
+ const p = W(b);
698
+ if (p === "touch" || p === "mouse" && e.modality.recentTouch())
699
+ return;
700
+ const D = L(b);
701
+ D && (f = { hovered: !0, point: D, pointerType: p }, d(O(D), f));
702
+ }, y = () => {
703
+ f?.point && d(O(f.point), f);
704
+ };
705
+ A.push(C(e.events, e.document, "pointermove", R, { capture: !0, passive: !0 })), A.push(C(e.events, e.document, "scroll", y, { capture: !0, passive: !0 })), e.document.defaultView && (A.push(e.events.listen(e.document.defaultView, "resize", y, { passive: !0 })), A.push(e.events.listen(e.document.defaultView, "blur", () => d(!1, f ?? T)))), l = M(...A);
706
+ } catch (R) {
707
+ try {
708
+ M(...A)();
709
+ } catch (y) {
710
+ throw new AggregateError([R, y], "Hover tracking setup and cleanup failed.");
711
+ }
712
+ throw R;
713
+ }
714
+ }
715
+ r(Object.freeze({ ...T, hovered: v }));
716
+ }
717
+ }, m = (v, T) => {
718
+ const A = W(v);
719
+ if (A === "touch" || A === "mouse" && e.modality.recentTouch())
720
+ return;
721
+ const R = L(v);
722
+ f = { hovered: T, point: R, pointerType: A };
723
+ const y = Reflect.get(v, "relatedTarget");
724
+ d(T || y !== null && R !== void 0 && O(R), f);
725
+ };
726
+ try {
727
+ for (const v of c)
728
+ s.push(e.events.listen(v, "pointerover", (T) => m(T, !0))), s.push(e.events.listen(v, "pointerout", (T) => m(T, !1)));
729
+ s.push(e.registerSession({ cancel: g }));
730
+ } catch (v) {
731
+ try {
732
+ g();
733
+ } catch (T) {
734
+ throw new AggregateError([v, T], "Hover region setup and cleanup failed.");
735
+ }
736
+ throw v;
737
+ }
738
+ return g;
739
+ }
740
+ const gt = 800, yt = 500;
741
+ class wt {
742
+ _listeners = /* @__PURE__ */ new Set();
743
+ _disposeListeners;
744
+ _now;
745
+ _disposed = !1;
746
+ _lastKeyboardAt = Number.NEGATIVE_INFINITY;
747
+ _lastTouchAt = Number.NEGATIVE_INFINITY;
748
+ _value = "unknown";
749
+ capability;
750
+ constructor(e, r) {
751
+ const i = () => e.defaultView?.performance?.now() ?? Date.now();
752
+ this._now = i, this._disposeListeners = M(
753
+ C(r, e, "pointerdown", (o) => {
754
+ const n = W(o);
755
+ n === "touch" ? (this._lastTouchAt = i(), this.set("touch")) : n === "mouse" && this.recentTouch() || this.set("pointer");
756
+ }, { capture: !0, passive: !0 }),
757
+ C(r, e, "touchstart", () => {
758
+ this._lastTouchAt = i(), this.set("touch");
759
+ }, { capture: !0, passive: !0 }),
760
+ C(r, e, "mousedown", () => {
761
+ this.recentTouch() || this.set("pointer");
762
+ }, { capture: !0, passive: !0 }),
763
+ C(r, e, "keydown", () => {
764
+ this._lastKeyboardAt = i(), this.set("keyboard");
765
+ }, { capture: !0 }),
766
+ C(r, e, "click", (o) => {
767
+ Reflect.get(o, "detail") === 0 && i() - this._lastKeyboardAt > yt && this.set("virtual");
768
+ }, { capture: !0 })
769
+ ), this.capability = Object.freeze({
770
+ get: () => this.get(),
771
+ subscribe: (o) => this.subscribe(o)
772
+ });
773
+ }
774
+ get = () => this._value;
775
+ recentTouch = () => this._now() - this._lastTouchAt <= gt;
776
+ set = (e) => {
777
+ this._disposed || e === this._value || (this._value = e, E(this._listeners, e));
778
+ };
779
+ subscribe = (e) => {
780
+ if (this._disposed)
781
+ throw new Error("[RaphyDOMInteraction] Input modality is disposed.");
782
+ return k(this._listeners, e);
783
+ };
784
+ dispose() {
785
+ this._disposed || (this._disposed = !0, this._listeners.clear(), this._disposeListeners());
786
+ }
787
+ }
788
+ function mt(t, e) {
789
+ const r = /* @__PURE__ */ new Set();
790
+ let i, o = !1;
791
+ const n = (s, a) => {
792
+ const u = pe(a, "key"), l = pe(a, "code"), f = o || Reflect.get(a, "isComposing") === !0 || Reflect.get(a, "keyCode") === 229;
793
+ E(r, Object.freeze({
794
+ code: l,
795
+ composing: f,
796
+ get defaultPrevented() {
797
+ return a.defaultPrevented;
798
+ },
799
+ key: u,
800
+ modifiers: B(a),
801
+ phase: s,
802
+ preventDefault: () => a.preventDefault(),
803
+ repeat: Reflect.get(a, "repeat") === !0
804
+ }));
805
+ }, c = () => {
806
+ i = M(
807
+ e.events.listen(t, "compositionstart", () => {
808
+ o = !0;
809
+ }),
810
+ e.events.listen(t, "compositionend", () => {
811
+ o = !1;
812
+ }),
813
+ e.events.listen(t, "keydown", (s) => {
814
+ e.modality.set("keyboard"), n("down", s);
815
+ }),
816
+ e.events.listen(t, "keyup", (s) => n("up", s))
817
+ );
818
+ };
819
+ return Object.freeze({
820
+ subscribe(s) {
821
+ return e.assertActive(), k(r, s, c, () => {
822
+ o = !1, i?.(), i = void 0;
823
+ });
824
+ }
825
+ });
826
+ }
827
+ function pe(t, e) {
828
+ const r = Reflect.get(t, e);
829
+ return typeof r == "string" ? r : "";
830
+ }
831
+ function _t(t, e) {
832
+ return Object.freeze({
833
+ start: (r) => Ot(t, e, r)
834
+ });
835
+ }
836
+ function Ot(t, e, r = {}) {
837
+ e.assertActive();
838
+ const i = /* @__PURE__ */ new Set(), o = r.axis ?? "both";
839
+ let n = r.pointerId, c = r.origin, s = c ?? Object.freeze({ x: 0, y: 0 }), a = !0, u, l;
840
+ const f = e.document.defaultView;
841
+ if (r.updates === "frame" && (!f?.requestAnimationFrame || !f.cancelAnimationFrame))
842
+ throw new TypeError("[RaphyDOMInteraction] Frame updates require requestAnimationFrame.");
843
+ const h = () => {
844
+ u !== void 0 && (f.cancelAnimationFrame(u), u = void 0);
845
+ const y = l;
846
+ l = void 0, y !== void 0 && E(i, y);
847
+ };
848
+ let O;
849
+ const g = new Promise((y) => {
850
+ O = y;
851
+ });
852
+ n !== void 0 && ee(t, "setPointerCapture", n);
853
+ let d = () => {
854
+ }, m = () => {
855
+ };
856
+ const v = (y) => {
857
+ a && (y.status === "finished" && (h(), !a) || (u !== void 0 && (f.cancelAnimationFrame(u), u = void 0), l = void 0, a = !1, m(), n !== void 0 && ee(t, "releasePointerCapture", n), i.clear(), d(), O(y)));
858
+ }, T = (y) => {
859
+ const b = ve(y, "pointerId");
860
+ if (n !== void 0 && b !== n)
861
+ return;
862
+ n === void 0 && b !== void 0 && (n = b, ee(t, "setPointerCapture", n));
863
+ const p = L(y);
864
+ if (p === void 0)
865
+ return;
866
+ c ??= p, s = p;
867
+ const D = Object.freeze({
868
+ delta: Object.freeze({
869
+ x: o === "y" ? 0 : p.x - c.x,
870
+ y: o === "x" ? 0 : p.y - c.y
871
+ }),
872
+ point: p
873
+ });
874
+ r.updates === "frame" ? (l = D, u ??= f.requestAnimationFrame(h)) : E(i, D);
875
+ }, A = (y) => n === void 0 || ve(y, "pointerId") === n;
876
+ m = M(
877
+ C(e.events, e.document, "pointermove", T, { capture: !0 }),
878
+ C(e.events, e.document, "pointerup", (y) => {
879
+ if (A(y)) {
880
+ const b = L(y) ?? s;
881
+ v(Object.freeze({ point: b, status: "finished" }));
882
+ }
883
+ }, { capture: !0 }),
884
+ C(e.events, e.document, "pointercancel", (y) => {
885
+ A(y) && v(Object.freeze({ status: "cancelled" }));
886
+ }, { capture: !0 }),
887
+ C(e.events, e.document, "keydown", (y) => {
888
+ Reflect.get(y, "key") === "Escape" && v(Object.freeze({ status: "cancelled" }));
889
+ }, { capture: !0 })
890
+ );
891
+ const R = Object.freeze({
892
+ cancel: () => v(Object.freeze({ status: "cancelled" })),
893
+ finished: g,
894
+ subscribe(y) {
895
+ if (!a)
896
+ throw new Error("[RaphyDOMInteraction] Move session is finished.");
897
+ return k(i, y);
898
+ }
899
+ });
900
+ return d = e.registerSession(R), R;
901
+ }
902
+ function ee(t, e, r) {
903
+ const i = Reflect.get(t, e);
904
+ if (typeof i == "function")
905
+ try {
906
+ Reflect.apply(i, t, [r]);
907
+ } catch {
908
+ }
909
+ }
910
+ function ve(t, e) {
911
+ const r = Reflect.get(t, e);
912
+ return typeof r == "number" ? r : void 0;
913
+ }
914
+ const G = "application/x-raphy-native-source", ie = ["none", "copy", "link", "move"], Ee = [...ie, "copyLink", "copyMove", "linkMove", "all", "uninitialized"];
915
+ function At(t) {
916
+ const e = t.replace(/[A-Z]/g, (r) => r.toLowerCase());
917
+ return e === "text" ? "text/plain" : e === "url" ? "text/uri-list" : e;
918
+ }
919
+ function Rt(t) {
920
+ return {
921
+ point: L(t),
922
+ modifiers: B(t),
923
+ effect: ie.includes(t.dataTransfer?.dropEffect) ? t.dataTransfer.dropEffect : "none",
924
+ effectAllowed: Ee.includes(t.dataTransfer?.effectAllowed) ? t.dataTransfer.effectAllowed : "none"
925
+ };
926
+ }
927
+ class Dt {
928
+ _records = /* @__PURE__ */ new WeakMap();
929
+ _services;
930
+ _active;
931
+ _cancelledNonce;
932
+ _endGenerations = /* @__PURE__ */ new WeakMap();
933
+ _generation = 0;
934
+ constructor(e) {
935
+ this._services = e;
936
+ }
937
+ capability(e, r) {
938
+ let i = this._records.get(e);
939
+ if (!i)
940
+ i = { element: e, reference: r, listeners: /* @__PURE__ */ new Set() }, this._records.set(e, i);
941
+ else if (i.reference !== r)
942
+ throw new Error("[RaphyDOMInteraction] One native drag target has multiple live TargetRefs.");
943
+ return Object.freeze({ subscribe: (o) => this._subscribe(i, o) });
944
+ }
945
+ _subscribe(e, r) {
946
+ if (this._services.assertActive(), typeof r != "function")
947
+ throw new TypeError("[RaphyDOMInteraction] Native drag listener must be callable.");
948
+ const i = k(e.listeners, r, () => {
949
+ const n = [];
950
+ try {
951
+ for (const c of ["dragstart", "dragenter", "dragover", "dragleave", "drop"])
952
+ n.push(this._services.events.listen(e.element, c, (s) => this._dispatch(e, s)));
953
+ n.push(C(this._services.events, this._services.document, "dragend", (c) => {
954
+ let s = this._endGenerations.get(c);
955
+ s === void 0 && (s = this._generation, this._endGenerations.set(c, s));
956
+ const a = e.overGeneration !== void 0 && e.overGeneration <= s, u = this._recordAt(c.composedPath()[0] ?? c.target) === e && (e.lastSourceGeneration ?? -1) <= s;
957
+ (a || u) && this._dispatch(e, c);
958
+ })), e.cleanup = M(...n);
959
+ } catch (c) {
960
+ throw M(...n)(), c;
961
+ }
962
+ }, () => {
963
+ const n = e.cleanup;
964
+ e.cleanup = void 0;
965
+ try {
966
+ n?.();
967
+ } finally {
968
+ try {
969
+ this._active?.record === e && (this._cancelledNonce = this._active.nonce, this._revoke(this._active, !1));
970
+ } finally {
971
+ e.lastSource = void 0, e.lastSourceGeneration = void 0, e.overGeneration = void 0;
972
+ }
973
+ }
974
+ });
975
+ let o;
976
+ try {
977
+ o = this._services.registerSession({ cancel: i });
978
+ } catch (n) {
979
+ throw i(), n;
980
+ }
981
+ return M(o, i);
982
+ }
983
+ _recordAt(e) {
984
+ const r = e !== null && typeof e == "object" && "nodeType" in e ? e : null;
985
+ let i = r?.nodeType === 1 ? r : r?.parentElement ?? null;
986
+ for (; i; ) {
987
+ const o = this._records.get(i);
988
+ if (o?.listeners.size)
989
+ return o;
990
+ const n = i.getRootNode();
991
+ i = i.parentElement ?? (n.nodeType === 11 && "host" in n ? n.host : null);
992
+ }
993
+ }
994
+ _revoke(e, r, i = !1) {
995
+ if (!(!e || this._active !== e)) {
996
+ this._active = void 0, this._generation++;
997
+ try {
998
+ e.unregister();
999
+ } finally {
1000
+ !i && e.record.lastSource === e.source && (e.record.lastSource = void 0, e.record.lastSourceGeneration = void 0);
1001
+ }
1002
+ r && E(e.record.listeners, Object.freeze({ ...e.metadata, phase: "cancel", source: e.source, effect: "none" }));
1003
+ }
1004
+ }
1005
+ _dispatch(e, r) {
1006
+ const i = r.composedPath();
1007
+ if (r.type !== "dragend" && this._recordAt(i[0] ?? r.target) !== e || r.type === "dragleave" && this._recordAt(r.relatedTarget) === e)
1008
+ return;
1009
+ const o = this._active;
1010
+ let n = this._generation, c = !0, s = !1, a = null;
1011
+ const u = () => {
1012
+ if (this._services.assertActive(), !c || !e.cleanup || n !== this._generation)
1013
+ throw new Error("[RaphyDOMInteraction] Native drag callback has expired.");
1014
+ }, l = () => {
1015
+ u(), r.preventDefault();
1016
+ }, f = (h) => {
1017
+ if (u(), !ie.includes(h) || !a)
1018
+ throw new TypeError("[RaphyDOMInteraction] Native drop needs a valid effect and DataTransfer.");
1019
+ a.dropEffect = h, r.preventDefault();
1020
+ };
1021
+ try {
1022
+ a = r.dataTransfer;
1023
+ const h = Rt(r), O = o && Array.from(a?.types ?? []).includes(G) ? o.source : null;
1024
+ if (r.type === "dragstart") {
1025
+ u(), n += o ? 1 : 0, this._revoke(o, !0), u(), n = ++this._generation;
1026
+ const g = (d, m) => {
1027
+ if (u(), s || !a || typeof a.setData != "function" || !Ee.includes(m) || !d || !d.formats || typeof d.formats != "object" || Array.isArray(d.formats))
1028
+ throw new TypeError("[RaphyDOMInteraction] Native drag needs one synchronous data writer and valid effects/formats.");
1029
+ const v = Object.entries(d.formats).map(([p, D]) => [At(p), D]);
1030
+ if (v.some(([p, D]) => !p.trim() || p === G || typeof D != "string"))
1031
+ throw new TypeError("[RaphyDOMInteraction] Native drag formats must contain named strings.");
1032
+ u(), s = !0;
1033
+ const T = this._services.document.defaultView.crypto.getRandomValues(new Uint32Array(4)).join("-"), A = Object.freeze({ formats: Object.freeze(Object.fromEntries(v)) });
1034
+ De(a, A), a.setData(G, T), a.effectAllowed = m, u();
1035
+ const R = Object.freeze({ reference: e.reference, identity: Object.freeze({}) });
1036
+ let y;
1037
+ const b = this._services.registerSession({ cancel: () => this._revoke(y, !1) });
1038
+ try {
1039
+ u(), y = { record: e, source: R, data: A, nonce: T, generation: n, metadata: { ...h, effectAllowed: m }, unregister: b }, this._active = y, this._cancelledNonce = void 0, e.lastSource = R, e.lastSourceGeneration = n;
1040
+ } catch (p) {
1041
+ throw b(), p;
1042
+ }
1043
+ return R;
1044
+ };
1045
+ E(e.listeners, Object.freeze({ ...h, phase: "start", source: e.reference, write: g, preventDefault: l })), r.defaultPrevented && this._active?.generation === n && this._revoke(this._active, !0);
1046
+ } else if (r.type === "dragenter" || r.type === "dragover")
1047
+ u(), e.overGeneration = n, E(e.listeners, Object.freeze({ ...h, phase: "over", source: O, formats: Object.freeze(Array.from(a?.types ?? []).filter((g) => g !== G)), accept: f, preventDefault: l }));
1048
+ else if (r.type === "drop") {
1049
+ if (e.overGeneration = void 0, this._cancelledNonce !== void 0 && typeof a?.getData == "function" && a.getData(G) === this._cancelledNonce) {
1050
+ f("none"), E(e.listeners, Object.freeze({ ...h, phase: "cancel", source: null, effect: "none" }));
1051
+ return;
1052
+ }
1053
+ const g = o && typeof a?.getData == "function" && a.getData(G) === o.nonce ? o.source : null, d = g ? o.data : Re(a, G);
1054
+ E(e.listeners, Object.freeze({ ...h, phase: "drop", source: g, data: d, accept: f, preventDefault: l })), this._revoke(o, !1, !0);
1055
+ } else if (r.type === "dragend") {
1056
+ u();
1057
+ const g = e.lastSource ?? null;
1058
+ e.lastSource = void 0, e.lastSourceGeneration = void 0, e.overGeneration = void 0, o?.source === g && this._revoke(o, !1), E(e.listeners, Object.freeze({ ...h, phase: "end", source: g }));
1059
+ } else
1060
+ e.overGeneration = void 0, E(e.listeners, Object.freeze({ ...h, phase: "leave", source: O }));
1061
+ } catch (h) {
1062
+ throw r.preventDefault(), (this._active?.generation === n || this._active === o) && this._revoke(this._active, !1), h;
1063
+ } finally {
1064
+ c = !1;
1065
+ }
1066
+ }
1067
+ }
1068
+ function It(t, e) {
1069
+ return Object.freeze({
1070
+ subscribe(r, i = {}) {
1071
+ e.assertActive();
1072
+ const o = [];
1073
+ return i.pointer !== !1 && o.push(C(e.events, e.document, "pointerdown", (n) => {
1074
+ be(t, i, n) || r(Object.freeze({ kind: "pointer", source: "pointer" }));
1075
+ }, { capture: !0 })), i.focus !== !1 && o.push(C(e.events, e.document, "focusin", (n) => {
1076
+ be(t, i, n) || r(Object.freeze({
1077
+ kind: "focus",
1078
+ source: Tt(e.modality.get())
1079
+ }));
1080
+ }, { capture: !0 })), M(...o);
1081
+ }
1082
+ });
1083
+ }
1084
+ function be(t, e, r) {
1085
+ const i = [t];
1086
+ for (const n of e.boundaries ?? [])
1087
+ n.current !== null && i.push(n.current);
1088
+ const o = typeof r.composedPath == "function" ? r.composedPath() : [];
1089
+ for (const n of i)
1090
+ if (o.includes(n) || Reflect.get(n, "nodeType") === 1 && r.target !== null && typeof r.target == "object" && Reflect.get(r.target, "nodeType") !== void 0 && n.contains(r.target))
1091
+ return !0;
1092
+ return !1;
1093
+ }
1094
+ function Tt(t) {
1095
+ return t === "keyboard" || t === "virtual" ? t : t === "pointer" || t === "touch" ? "pointer" : "programmatic";
1096
+ }
1097
+ const Mt = 700;
1098
+ function St(t, e) {
1099
+ const r = /* @__PURE__ */ new Set();
1100
+ let i, o, n, c = Number.NEGATIVE_INFINITY;
1101
+ const s = (l, f, h) => {
1102
+ r.size !== 0 && E(r, Object.freeze({
1103
+ ...h === void 0 ? {} : {
1104
+ button: Y(h, "button"),
1105
+ pointerId: f === "pointer" ? Y(h, "pointerId") : void 0,
1106
+ point: L(h),
1107
+ pointerType: f === "pointer" ? W(h) : void 0
1108
+ },
1109
+ modifiers: h === void 0 ? Object.freeze({ alt: !1, control: !1, meta: !1, shift: !1 }) : B(h),
1110
+ phase: l,
1111
+ source: f
1112
+ }));
1113
+ }, a = (l) => {
1114
+ (o !== void 0 || n !== void 0) && s("cancel", o !== void 0 ? "pointer" : "keyboard", l), o = void 0, n = void 0;
1115
+ }, u = () => {
1116
+ i = M(
1117
+ e.events.listen(t, "pointerdown", (l) => {
1118
+ X(t) || Y(l, "button") !== 0 || (o = Y(l, "pointerId") ?? 1, e.modality.set(W(l) === "touch" ? "touch" : "pointer"), s("start", "pointer", l));
1119
+ }),
1120
+ e.events.listen(t, "pointerup", (l) => {
1121
+ const f = Y(l, "pointerId") ?? 1;
1122
+ o === f && (o = void 0, s("press", "pointer", l), s("end", "pointer", l));
1123
+ }),
1124
+ e.events.listen(t, "pointercancel", (l) => {
1125
+ const f = Y(l, "pointerId") ?? 1;
1126
+ o === f && (o = void 0, s("cancel", "pointer", l));
1127
+ }),
1128
+ e.events.listen(t, "keydown", (l) => {
1129
+ const f = ge(l, "key");
1130
+ X(t) || n !== void 0 || Et(l, "repeat") || f !== "Enter" && f !== " " || (n = f, e.modality.set("keyboard"), f === " " && l.preventDefault(), s("start", "keyboard", l));
1131
+ }),
1132
+ e.events.listen(t, "keyup", (l) => {
1133
+ const f = ge(l, "key");
1134
+ n === f && (n = void 0, c = l.timeStamp, s("press", "keyboard", l), s("end", "keyboard", l));
1135
+ }),
1136
+ e.events.listen(t, "click", (l) => {
1137
+ X(t) || n !== void 0 || Y(l, "detail") !== 0 || l.timeStamp - c <= Mt || (e.modality.set("virtual"), s("start", "virtual", l), s("press", "virtual", l), s("end", "virtual", l));
1138
+ }),
1139
+ e.events.listen(t, "blur", (l) => {
1140
+ n !== void 0 && a(l);
1141
+ }, { capture: !0 })
1142
+ );
1143
+ };
1144
+ return Object.freeze({
1145
+ press(l = {}) {
1146
+ if (e.assertActive(), X(t))
1147
+ return;
1148
+ const f = l.source ?? "programmatic";
1149
+ f === "virtual" && e.modality.set("virtual"), s("start", f), s("press", f), s("end", f);
1150
+ },
1151
+ subscribe(l) {
1152
+ return e.assertActive(), k(r, l, u, () => {
1153
+ a(), i?.(), i = void 0;
1154
+ });
1155
+ }
1156
+ });
1157
+ }
1158
+ function X(t) {
1159
+ return t.hasAttribute("disabled") || t.getAttribute("aria-disabled") === "true";
1160
+ }
1161
+ function Y(t, e) {
1162
+ const r = Reflect.get(t, e);
1163
+ return typeof r == "number" ? r : void 0;
1164
+ }
1165
+ function ge(t, e) {
1166
+ const r = Reflect.get(t, e);
1167
+ return typeof r == "string" ? r : void 0;
1168
+ }
1169
+ function Et(t, e) {
1170
+ return Reflect.get(t, e) === !0;
1171
+ }
1172
+ function xt(t, e, r, i) {
1173
+ return Object.freeze({
1174
+ start(o = {}) {
1175
+ e.assertActive();
1176
+ const n = o.orientation ?? "horizontal";
1177
+ if (n !== "horizontal" && n !== "vertical")
1178
+ throw new TypeError("[RaphyDOMInteraction] Invalid roving focus orientation.");
1179
+ if (i.has(t))
1180
+ throw new Error("[RaphyDOMInteraction] Roving focus is already active for this target.");
1181
+ const c = t.ownerDocument.defaultView?.MutationObserver;
1182
+ if (c === void 0)
1183
+ throw new Error("[RaphyDOMInteraction] Roving focus requires MutationObserver.");
1184
+ const s = /* @__PURE__ */ new Map();
1185
+ let a = [], u, l = !0, f = /* @__PURE__ */ new Set();
1186
+ const h = [], O = () => M(...h)();
1187
+ let g;
1188
+ const d = (b, p) => {
1189
+ b.getAttribute("tabindex") === p.applied && (p.original === null ? b.removeAttribute("tabindex") : b.setAttribute("tabindex", p.original));
1190
+ }, m = () => {
1191
+ if (!l)
1192
+ return;
1193
+ const b = [], p = /* @__PURE__ */ new Set([t]), D = (x) => {
1194
+ for (const _ of Array.from(x.children)) {
1195
+ const z = _.getAttribute("data-r-app");
1196
+ if (i.has(_) || z !== null && z !== r)
1197
+ continue;
1198
+ const w = _.getAttribute("tabindex");
1199
+ let I = s.get(_);
1200
+ I !== void 0 && w !== I.applied && (I.original = w, I.index = Number(Reflect.get(_, "tabIndex")));
1201
+ const N = I?.index ?? Number(Reflect.get(_, "tabIndex")), j = t.ownerDocument.defaultView.getComputedStyle(_);
1202
+ j.display === "none" || j.visibility === "hidden" || _.matches('[hidden], [inert], [aria-hidden="true"]') || (N >= 0 && !_.matches(":disabled") && _.getAttribute("aria-disabled") !== "true" && typeof Reflect.get(_, "focus") == "function" && (I === void 0 && (I = { original: w, index: N, applied: void 0 }, s.set(_, I)), b.push(_)), _.shadowRoot !== null && (p.add(_.shadowRoot), D(_.shadowRoot)), D(_));
1203
+ }
1204
+ };
1205
+ D(t);
1206
+ const F = new Set(b);
1207
+ for (const [x, _] of s)
1208
+ F.has(x) || (d(x, _), s.delete(x));
1209
+ a = b, (u === void 0 || !a.includes(u)) && (u = a[0]);
1210
+ for (const x of a) {
1211
+ const _ = x === u ? "0" : "-1", z = s.get(x);
1212
+ z.applied = _, x.getAttribute("tabindex") !== _ && x.setAttribute("tabindex", _);
1213
+ }
1214
+ if (p.size !== f.size || [...p].some((x) => !f.has(x))) {
1215
+ g.disconnect();
1216
+ for (const x of p)
1217
+ g.observe(x, { childList: !0, subtree: !0, attributes: !0, attributeFilter: ["tabindex", "disabled", "aria-disabled", "hidden", "inert", "aria-hidden", "style", "class", "data-r-app"] });
1218
+ f = p;
1219
+ }
1220
+ };
1221
+ g = new c(m);
1222
+ const v = (b) => [...a].reverse().find((p) => b.composedPath().includes(p)), T = (b) => {
1223
+ m();
1224
+ const p = v(b);
1225
+ p !== void 0 && (u = p, m());
1226
+ }, A = (b) => {
1227
+ const p = b.relatedTarget;
1228
+ (p === null || typeof Reflect.get(p, "nodeType") != "number" || !t.contains(p)) && (u = a[0], m());
1229
+ }, R = (b) => {
1230
+ const p = b;
1231
+ if (p.defaultPrevented || p.isComposing || p.altKey || p.ctrlKey || p.metaKey || p.shiftKey)
1232
+ return;
1233
+ m();
1234
+ const D = v(b);
1235
+ if (D === void 0 || D.matches('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="slider"], [role="spinbutton"]'))
1236
+ return;
1237
+ const F = t.ownerDocument.defaultView.getComputedStyle(t).direction === "rtl", x = n === "vertical" ? "ArrowDown" : F ? "ArrowLeft" : "ArrowRight", _ = n === "vertical" ? "ArrowUp" : F ? "ArrowRight" : "ArrowLeft";
1238
+ let z = p.key === "Home" ? 0 : p.key === "End" ? a.length - 1 : p.key === x ? a.indexOf(D) + 1 : p.key === _ ? a.indexOf(D) - 1 : -2;
1239
+ if (z === -2)
1240
+ return;
1241
+ if (z < 0 || z >= a.length) {
1242
+ if (o.loop === !1)
1243
+ return;
1244
+ z = z < 0 ? a.length - 1 : 0;
1245
+ }
1246
+ const w = a[z];
1247
+ u = w, m(), p.preventDefault(), Reflect.apply(Reflect.get(w, "focus"), w, [{ preventScroll: !0 }]);
1248
+ }, y = () => {
1249
+ if (l) {
1250
+ l = !1, g.disconnect(), i.delete(t);
1251
+ try {
1252
+ O();
1253
+ } finally {
1254
+ for (const [b, p] of s)
1255
+ d(b, p);
1256
+ s.clear(), a = [], f.clear(), u = void 0;
1257
+ for (const b of i.values())
1258
+ b();
1259
+ }
1260
+ }
1261
+ };
1262
+ i.set(t, m);
1263
+ try {
1264
+ h.push(e.events.listen(t, "focusin", T)), h.push(e.events.listen(t, "focusout", A)), h.push(e.events.listen(t, "keydown", R)), h.push(e.registerSession({ cancel: y })), m();
1265
+ for (const b of i.values())
1266
+ b();
1267
+ } catch (b) {
1268
+ throw y(), b;
1269
+ }
1270
+ return y;
1271
+ }
1272
+ });
1273
+ }
1274
+ const Ct = 4;
1275
+ function zt(t) {
1276
+ if (K(t))
1277
+ try {
1278
+ return typeof Reflect.get(t, "selectionStart") == "number";
1279
+ } catch {
1280
+ return !1;
1281
+ }
1282
+ return kt(t);
1283
+ }
1284
+ function jt(t, e) {
1285
+ const r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
1286
+ let o, n, c = !1;
1287
+ const s = () => (e.assertActive(), Object.freeze({
1288
+ composing: c,
1289
+ selection: ye(t),
1290
+ value: te(t)
1291
+ })), a = () => E(r, s()), u = () => {
1292
+ n = M(
1293
+ e.events.listen(t, "compositionstart", () => {
1294
+ c = !0, a();
1295
+ }),
1296
+ e.events.listen(t, "compositionend", () => {
1297
+ c = !1, a();
1298
+ }),
1299
+ e.events.listen(t, "input", a),
1300
+ e.events.listen(t, "select", a),
1301
+ e.events.listen(t.ownerDocument, "selectionchange", () => {
1302
+ xe(t) && a();
1303
+ })
1304
+ );
1305
+ };
1306
+ return Object.freeze({
1307
+ getState: s,
1308
+ replaceSelection(l) {
1309
+ if (e.assertActive(), K(t)) {
1310
+ const f = ye(t), h = Reflect.get(t, "setRangeText");
1311
+ if (typeof h == "function")
1312
+ Reflect.apply(h, t, [l, f.start, f.end, "end"]);
1313
+ else {
1314
+ const O = te(t);
1315
+ Reflect.set(t, "value", `${O.slice(0, f.start)}${l}${O.slice(f.end)}`), we(t, {
1316
+ direction: "none",
1317
+ end: f.start + l.length,
1318
+ start: f.start + l.length
1319
+ });
1320
+ }
1321
+ } else
1322
+ Lt(t, l);
1323
+ Gt(t, l), a();
1324
+ },
1325
+ setSelection(l) {
1326
+ e.assertActive();
1327
+ const f = Ft(l, te(t).length);
1328
+ K(t) ? we(t, f) : Pt(t, f), a();
1329
+ },
1330
+ subscribe(l) {
1331
+ return e.assertActive(), k(r, l, u, () => {
1332
+ c = !1, n?.(), n = void 0;
1333
+ });
1334
+ },
1335
+ subscribePaste(l) {
1336
+ return e.assertActive(), k(i, l, () => {
1337
+ o = e.events.listen(t, "paste", (f) => {
1338
+ const h = f.clipboardData;
1339
+ h != null && E(i, Object.freeze({
1340
+ text: h.getData("text/plain"),
1341
+ state: s(),
1342
+ get defaultPrevented() {
1343
+ return f.defaultPrevented;
1344
+ },
1345
+ preventDefault: () => f.preventDefault()
1346
+ }));
1347
+ });
1348
+ }, () => {
1349
+ o?.(), o = void 0;
1350
+ });
1351
+ }
1352
+ });
1353
+ }
1354
+ function K(t) {
1355
+ const e = t.localName;
1356
+ return e === "input" || e === "textarea";
1357
+ }
1358
+ function kt(t) {
1359
+ return Reflect.get(t, "isContentEditable") === !0 || t.getAttribute("contenteditable") === "" || t.getAttribute("contenteditable") === "true";
1360
+ }
1361
+ function te(t) {
1362
+ return K(t) ? String(Reflect.get(t, "value") ?? "") : t.textContent ?? "";
1363
+ }
1364
+ function ye(t) {
1365
+ if (K(t)) {
1366
+ const e = Number(Reflect.get(t, "selectionStart") ?? 0), r = Number(Reflect.get(t, "selectionEnd") ?? e), i = Ce(Reflect.get(t, "selectionDirection"));
1367
+ return Object.freeze({ direction: i, end: r, start: e });
1368
+ }
1369
+ return Nt(t);
1370
+ }
1371
+ function we(t, e) {
1372
+ const r = Reflect.get(t, "setSelectionRange");
1373
+ typeof r == "function" && Reflect.apply(r, t, [e.start, e.end, e.direction]);
1374
+ }
1375
+ function Nt(t) {
1376
+ const e = t.ownerDocument.getSelection();
1377
+ if (e === null || e.anchorNode === null || e.focusNode === null || !t.contains(e.anchorNode) || !t.contains(e.focusNode))
1378
+ return Object.freeze({ direction: "none", end: 0, start: 0 });
1379
+ const r = me(t, e.anchorNode, e.anchorOffset), i = me(t, e.focusNode, e.focusOffset);
1380
+ return Object.freeze({
1381
+ direction: r === i ? "none" : r < i ? "forward" : "backward",
1382
+ end: Math.max(r, i),
1383
+ start: Math.min(r, i)
1384
+ });
1385
+ }
1386
+ function Pt(t, e) {
1387
+ const r = t.ownerDocument, i = r.getSelection();
1388
+ if (i === null)
1389
+ return;
1390
+ const o = _e(t, e.start), n = _e(t, e.end), c = r.createRange();
1391
+ c.setStart(o.node, o.offset), c.setEnd(n.node, n.offset), i.removeAllRanges(), i.addRange(c), e.direction === "backward" && typeof i.extend == "function" && (i.collapse(n.node, n.offset), i.extend(o.node, o.offset));
1392
+ }
1393
+ function Lt(t, e) {
1394
+ const r = t.ownerDocument, i = r.getSelection();
1395
+ if (i === null || i.rangeCount === 0 || !xe(t)) {
1396
+ t.append(r.createTextNode(e));
1397
+ return;
1398
+ }
1399
+ const o = i.getRangeAt(0);
1400
+ o.deleteContents();
1401
+ const n = r.createTextNode(e);
1402
+ o.insertNode(n), o.setStartAfter(n), o.collapse(!0), i.removeAllRanges(), i.addRange(o);
1403
+ }
1404
+ function me(t, e, r) {
1405
+ const i = t.ownerDocument.createRange();
1406
+ i.selectNodeContents(t);
1407
+ try {
1408
+ i.setEnd(e, r);
1409
+ } catch {
1410
+ return 0;
1411
+ }
1412
+ return i.toString().length;
1413
+ }
1414
+ function _e(t, e) {
1415
+ const i = t.ownerDocument.createTreeWalker(t, Ct);
1416
+ let o = Math.max(0, e), n = i.nextNode();
1417
+ for (; n !== null; ) {
1418
+ const c = n.data.length;
1419
+ if (o <= c)
1420
+ return { node: n, offset: o };
1421
+ o -= c, n = i.nextNode();
1422
+ }
1423
+ return { node: t, offset: t.childNodes.length };
1424
+ }
1425
+ function xe(t) {
1426
+ const e = t.ownerDocument.getSelection();
1427
+ return e?.anchorNode !== null && e?.anchorNode !== void 0 && t.contains(e.anchorNode);
1428
+ }
1429
+ function Ft(t, e) {
1430
+ const r = Math.max(0, Math.min(e, Math.trunc(t.start))), i = Math.max(r, Math.min(e, Math.trunc(t.end)));
1431
+ return Object.freeze({
1432
+ direction: Ce(t.direction),
1433
+ end: i,
1434
+ start: r
1435
+ });
1436
+ }
1437
+ function Ce(t) {
1438
+ return t === "forward" || t === "backward" ? t : "none";
1439
+ }
1440
+ function Gt(t, e) {
1441
+ const r = t.ownerDocument.defaultView;
1442
+ let i;
1443
+ try {
1444
+ i = new (r?.InputEvent ?? Event)("input", {
1445
+ bubbles: !0,
1446
+ composed: !0,
1447
+ data: e,
1448
+ inputType: "insertText"
1449
+ });
1450
+ } catch {
1451
+ i = t.ownerDocument.createEvent("Event"), i.initEvent("input", !0, !1);
1452
+ }
1453
+ t.dispatchEvent(i);
1454
+ }
1455
+ const Yt = "@raphy-js/dom/interaction";
1456
+ class Vt {
1457
+ _dragDrop;
1458
+ _focus = /* @__PURE__ */ new WeakMap();
1459
+ _focusNavigation = /* @__PURE__ */ new WeakMap();
1460
+ _rovingFocus = /* @__PURE__ */ new WeakMap();
1461
+ _rovingGroups = /* @__PURE__ */ new Map();
1462
+ _hover = /* @__PURE__ */ new WeakMap();
1463
+ _keyboard = /* @__PURE__ */ new WeakMap();
1464
+ _contextAction = /* @__PURE__ */ new WeakMap();
1465
+ _modality;
1466
+ _move = /* @__PURE__ */ new WeakMap();
1467
+ _outside = /* @__PURE__ */ new WeakMap();
1468
+ _press = /* @__PURE__ */ new WeakMap();
1469
+ _sessions = /* @__PURE__ */ new Set();
1470
+ _textEditing = /* @__PURE__ */ new WeakMap();
1471
+ _disposed = !1;
1472
+ constructor(e) {
1473
+ this._modality = new wt(e.document, e.events);
1474
+ const r = Object.freeze({
1475
+ assertActive: () => this._assertActive(),
1476
+ document: e.document,
1477
+ events: e.events,
1478
+ modality: this._modality,
1479
+ registerSession: (c) => this._registerSession(c)
1480
+ });
1481
+ this._dragDrop = new nt(r);
1482
+ const i = new Dt(r);
1483
+ e.capabilities.provide(ke, (c, s) => {
1484
+ const a = Oe(c, e.document);
1485
+ return a === void 0 ? void 0 : i.capability(a, s);
1486
+ });
1487
+ const o = new pt(r), n = (c) => Oe(c, e.document);
1488
+ e.capabilities.provide(Ne, (c, s) => {
1489
+ const a = n(c);
1490
+ if (a !== void 0)
1491
+ return le(s, e.applicationId), o.geometry(a);
1492
+ }), e.capabilities.provide(Pe, (c) => {
1493
+ const s = n(c);
1494
+ return s === void 0 ? void 0 : o.positioning(s);
1495
+ }), e.capabilities.provide(Le, (c, s) => {
1496
+ const a = n(c);
1497
+ if (a !== void 0)
1498
+ return le(s, e.applicationId), o.scrolling(a);
1499
+ }), e.capabilities.provide(Fe, (c) => {
1500
+ const s = n(c);
1501
+ return s === void 0 || typeof Reflect.get(s, "focus") != "function" ? void 0 : P(this._focus, s, () => ot(s, r));
1502
+ }), e.capabilities.provide(Ge, (c) => {
1503
+ const s = n(c);
1504
+ return s === void 0 ? void 0 : P(this._focusNavigation, s, () => st(s, r));
1505
+ }), e.capabilities.provide(Ye, (c) => {
1506
+ const s = n(c);
1507
+ return s === void 0 ? void 0 : P(this._rovingFocus, s, () => xt(s, r, e.applicationId, this._rovingGroups));
1508
+ }), e.capabilities.provide(Ve, (c) => {
1509
+ const s = n(c);
1510
+ return s === void 0 ? void 0 : P(this._press, s, () => St(s, r));
1511
+ }), e.capabilities.provide(ce, (c) => {
1512
+ const s = n(c);
1513
+ return s === void 0 ? void 0 : P(this._hover, s, () => vt(s, r, (a) => {
1514
+ const u = Ae(a, ce), l = a.current === null ? void 0 : n(a.current);
1515
+ if (l === void 0 || this._hover.get(l) !== u)
1516
+ throw new Error("[RaphyDOM] Hover boundary belongs to another application.");
1517
+ return l;
1518
+ }));
1519
+ }), e.capabilities.provide(Be, (c) => {
1520
+ const s = n(c);
1521
+ return s === void 0 ? void 0 : P(this._keyboard, s, () => mt(s, r));
1522
+ }), e.capabilities.provide(We, (c) => {
1523
+ const s = n(c);
1524
+ return s === void 0 ? void 0 : P(this._contextAction, s, () => it(s, r));
1525
+ }), e.capabilities.provide(He, (c) => {
1526
+ const s = n(c);
1527
+ return s === void 0 ? void 0 : P(this._move, s, () => _t(s, r));
1528
+ }), e.capabilities.provide(Ke, (c) => {
1529
+ const s = n(c);
1530
+ return s === void 0 ? void 0 : P(this._outside, s, () => It(s, r));
1531
+ }), e.capabilities.provide(qe, (c) => {
1532
+ const s = n(c);
1533
+ return s === void 0 || !zt(s) ? void 0 : P(this._textEditing, s, () => jt(s, r));
1534
+ }), e.capabilities.provide($e, (c, s) => {
1535
+ const a = n(c);
1536
+ return a === void 0 ? void 0 : this._dragDrop.capability(a, s);
1537
+ }), e.capabilities.provide(Ue, this._modality.capability), e.capabilities.provide(
1538
+ Xe,
1539
+ tt(e.document, () => this._assertActive())
1540
+ );
1541
+ }
1542
+ dispose() {
1543
+ if (this._disposed)
1544
+ return;
1545
+ this._disposed = !0;
1546
+ const e = [];
1547
+ for (const r of [...this._sessions])
1548
+ try {
1549
+ r.cancel();
1550
+ } catch (i) {
1551
+ e.push(i);
1552
+ }
1553
+ this._sessions.clear();
1554
+ try {
1555
+ this._modality.dispose();
1556
+ } catch (r) {
1557
+ e.push(r);
1558
+ }
1559
+ if (e.length === 1)
1560
+ throw e[0];
1561
+ if (e.length > 1)
1562
+ throw new AggregateError(e, "[RaphyDOMInteraction] Adapter cleanup failed.");
1563
+ }
1564
+ _assertActive() {
1565
+ if (this._disposed)
1566
+ throw new Error("[RaphyDOMInteraction] Adapter is disposed.");
1567
+ }
1568
+ _registerSession(e) {
1569
+ this._assertActive(), this._sessions.add(e);
1570
+ let r = !0;
1571
+ return () => {
1572
+ r && (r = !1, this._sessions.delete(e));
1573
+ };
1574
+ }
1575
+ }
1576
+ function Bt() {
1577
+ return Object.freeze({
1578
+ id: Yt,
1579
+ install: (t) => new Vt(t)
1580
+ });
1581
+ }
1582
+ function Oe(t, e) {
1583
+ return Reflect.get(t, "nodeType") === 1 && Reflect.get(t, "ownerDocument") === e ? t : void 0;
1584
+ }
1585
+ function P(t, e, r) {
1586
+ const i = t.get(e);
1587
+ if (i !== void 0)
1588
+ return i;
1589
+ const o = r();
1590
+ return t.set(e, o), o;
1591
+ }
1592
+ const Jt = /* @__PURE__ */ Object.freeze({
1593
+ createRenderer: (t) => Qe({
1594
+ extensions: [Bt()],
1595
+ target: et(t)
1596
+ }),
1597
+ id: "@raphy-js/dom/interaction"
1598
+ });
1599
+ export {
1600
+ Yt as DOM_INTERACTION_EXTENSION_ID,
1601
+ Jt as RAPHY_DOM_INTERACTION_RUNTIME_ADAPTER,
1602
+ Bt as interaction
1603
+ };