@sprawlify/primitives 0.0.1

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 (378) hide show
  1. package/dist/anatomy.cjs +3 -0
  2. package/dist/anatomy.d.cts +2 -0
  3. package/dist/anatomy.d.mts +2 -0
  4. package/dist/anatomy.mjs +3 -0
  5. package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
  6. package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
  7. package/dist/aria-hidden.cjs +4 -0
  8. package/dist/aria-hidden.d.cts +16 -0
  9. package/dist/aria-hidden.d.mts +16 -0
  10. package/dist/aria-hidden.mjs +4 -0
  11. package/dist/auto-resize-D3qHtFy1.mjs +114 -0
  12. package/dist/auto-resize-xzlPFDyD.cjs +125 -0
  13. package/dist/auto-resize.cjs +5 -0
  14. package/dist/auto-resize.d.cts +17 -0
  15. package/dist/auto-resize.d.mts +17 -0
  16. package/dist/auto-resize.mjs +4 -0
  17. package/dist/chunk-CbDLau6x.cjs +34 -0
  18. package/dist/collection-8XqaNHs_.mjs +1279 -0
  19. package/dist/collection-DIoIDISa.cjs +1326 -0
  20. package/dist/collection.cjs +11 -0
  21. package/dist/collection.d.cts +5 -0
  22. package/dist/collection.d.mts +5 -0
  23. package/dist/collection.mjs +4 -0
  24. package/dist/color-BkAP1Tkd.d.mts +60 -0
  25. package/dist/color-VKewNv2e.d.cts +60 -0
  26. package/dist/color-utils-Cc5GVXZh.mjs +657 -0
  27. package/dist/color-utils-LER_6Zwu.cjs +680 -0
  28. package/dist/color-utils.cjs +7 -0
  29. package/dist/color-utils.d.cts +19 -0
  30. package/dist/color-utils.d.mts +19 -0
  31. package/dist/color-utils.mjs +4 -0
  32. package/dist/core-30pJjyC2.d.mts +49 -0
  33. package/dist/core-CQFbMdTl.cjs +176 -0
  34. package/dist/core-CefBjbst.d.cts +49 -0
  35. package/dist/core-DCFNMTZF.mjs +129 -0
  36. package/dist/core.cjs +12 -0
  37. package/dist/core.d.cts +3 -0
  38. package/dist/core.d.mts +3 -0
  39. package/dist/core.mjs +5 -0
  40. package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
  41. package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
  42. package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
  43. package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
  44. package/dist/create-props-BnF_vl-E.mjs +5 -0
  45. package/dist/create-props-YKy7JIKj.cjs +11 -0
  46. package/dist/data-url-C3ITPVRX.d.cts +10 -0
  47. package/dist/data-url-DLwZ9M77.d.mts +10 -0
  48. package/dist/date-utils-D2xPHa_I.cjs +738 -0
  49. package/dist/date-utils-wEa1hhpc.mjs +474 -0
  50. package/dist/date-utils.cjs +46 -0
  51. package/dist/date-utils.d.cts +101 -0
  52. package/dist/date-utils.d.mts +2 -0
  53. package/dist/date-utils.mjs +3 -0
  54. package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
  55. package/dist/defineProperty-DrXfyjd4.mjs +43 -0
  56. package/dist/dismissable-CTfKZ4OG.cjs +282 -0
  57. package/dist/dismissable-DDrx0xnH.mjs +271 -0
  58. package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
  59. package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
  60. package/dist/dismissable.cjs +7 -0
  61. package/dist/dismissable.d.cts +3 -0
  62. package/dist/dismissable.d.mts +3 -0
  63. package/dist/dismissable.mjs +6 -0
  64. package/dist/dom-query-CWZdWUGp.cjs +2141 -0
  65. package/dist/dom-query-DFCRhyj1.mjs +1374 -0
  66. package/dist/dom-query.cjs +130 -0
  67. package/dist/dom-query.d.cts +307 -0
  68. package/dist/dom-query.d.mts +307 -0
  69. package/dist/dom-query.mjs +3 -0
  70. package/dist/file-utils.cjs +220 -0
  71. package/dist/file-utils.d.cts +51 -0
  72. package/dist/file-utils.d.mts +51 -0
  73. package/dist/file-utils.mjs +210 -0
  74. package/dist/focus-trap-D-bypQEJ.mjs +485 -0
  75. package/dist/focus-trap-D4i52S9A.cjs +496 -0
  76. package/dist/focus-trap.cjs +5 -0
  77. package/dist/focus-trap.d.cts +88 -0
  78. package/dist/focus-trap.d.mts +88 -0
  79. package/dist/focus-trap.mjs +4 -0
  80. package/dist/focus-visible-DYTWdWpa.cjs +210 -0
  81. package/dist/focus-visible-irppYatv.mjs +175 -0
  82. package/dist/focus-visible.cjs +9 -0
  83. package/dist/focus-visible.d.cts +31 -0
  84. package/dist/focus-visible.d.mts +31 -0
  85. package/dist/focus-visible.mjs +4 -0
  86. package/dist/functions-BOkTDEFM.d.cts +15 -0
  87. package/dist/functions-IZtWcC8Q.d.mts +15 -0
  88. package/dist/highlight-word.cjs +100 -0
  89. package/dist/highlight-word.d.cts +24 -0
  90. package/dist/highlight-word.d.mts +24 -0
  91. package/dist/highlight-word.mjs +99 -0
  92. package/dist/hotkeys.cjs +758 -0
  93. package/dist/hotkeys.d.cts +130 -0
  94. package/dist/hotkeys.d.mts +130 -0
  95. package/dist/hotkeys.mjs +754 -0
  96. package/dist/i18n-utils.cjs +450 -0
  97. package/dist/i18n-utils.d.cts +61 -0
  98. package/dist/i18n-utils.d.mts +61 -0
  99. package/dist/i18n-utils.mjs +440 -0
  100. package/dist/index-BkzYij2j.d.mts +25 -0
  101. package/dist/index-Bqw3r34-.d.cts +1383 -0
  102. package/dist/index-C0MKXQmE.d.mts +1383 -0
  103. package/dist/index-C9-feK5c.d.cts +25 -0
  104. package/dist/index-CD5FN7kY.d.mts +114 -0
  105. package/dist/index-CJji6wHl.d.cts +15 -0
  106. package/dist/index-CNi5FkPe.d.mts +15 -0
  107. package/dist/index-D96rs8B0.d.mts +115 -0
  108. package/dist/index.cjs +0 -0
  109. package/dist/index.d.cts +1 -0
  110. package/dist/index.d.mts +1 -0
  111. package/dist/index.mjs +1 -0
  112. package/dist/interact-outside-BplxR9cR.mjs +200 -0
  113. package/dist/interact-outside-C8-oFBpB.cjs +205 -0
  114. package/dist/interact-outside.cjs +5 -0
  115. package/dist/interact-outside.d.cts +2 -0
  116. package/dist/interact-outside.d.mts +2 -0
  117. package/dist/interact-outside.mjs +5 -0
  118. package/dist/json-tree-utils.cjs +1512 -0
  119. package/dist/json-tree-utils.d.cts +117 -0
  120. package/dist/json-tree-utils.d.mts +117 -0
  121. package/dist/json-tree-utils.mjs +1463 -0
  122. package/dist/list-collection-BIMJGQjn.d.cts +61 -0
  123. package/dist/list-collection-Db3eixRU.d.mts +61 -0
  124. package/dist/live-region-CcZPGo89.cjs +52 -0
  125. package/dist/live-region-CnPh21WH.mjs +46 -0
  126. package/dist/live-region.cjs +3 -0
  127. package/dist/live-region.d.cts +2 -0
  128. package/dist/live-region.d.mts +2 -0
  129. package/dist/live-region.mjs +3 -0
  130. package/dist/machines/accordion/index.cjs +328 -0
  131. package/dist/machines/accordion/index.d.cts +83 -0
  132. package/dist/machines/accordion/index.d.mts +83 -0
  133. package/dist/machines/accordion/index.mjs +322 -0
  134. package/dist/machines/async-list/index.cjs +311 -0
  135. package/dist/machines/async-list/index.d.cts +89 -0
  136. package/dist/machines/async-list/index.d.mts +89 -0
  137. package/dist/machines/async-list/index.mjs +310 -0
  138. package/dist/machines/avatar/index.cjs +169 -0
  139. package/dist/machines/avatar/index.d.cts +63 -0
  140. package/dist/machines/avatar/index.d.mts +63 -0
  141. package/dist/machines/avatar/index.mjs +165 -0
  142. package/dist/machines/bottom-sheet/index.cjs +676 -0
  143. package/dist/machines/bottom-sheet/index.d.cts +239 -0
  144. package/dist/machines/bottom-sheet/index.d.mts +239 -0
  145. package/dist/machines/bottom-sheet/index.mjs +672 -0
  146. package/dist/machines/carousel/index.cjs +859 -0
  147. package/dist/machines/carousel/index.d.cts +146 -0
  148. package/dist/machines/carousel/index.d.mts +146 -0
  149. package/dist/machines/carousel/index.mjs +851 -0
  150. package/dist/machines/checkbox/index.cjs +316 -0
  151. package/dist/machines/checkbox/index.d.cts +81 -0
  152. package/dist/machines/checkbox/index.d.mts +81 -0
  153. package/dist/machines/checkbox/index.mjs +312 -0
  154. package/dist/machines/clipboard/index.cjs +225 -0
  155. package/dist/machines/clipboard/index.d.cts +68 -0
  156. package/dist/machines/clipboard/index.d.mts +68 -0
  157. package/dist/machines/clipboard/index.mjs +219 -0
  158. package/dist/machines/collapsible/index.cjs +362 -0
  159. package/dist/machines/collapsible/index.d.cts +82 -0
  160. package/dist/machines/collapsible/index.d.mts +82 -0
  161. package/dist/machines/collapsible/index.mjs +358 -0
  162. package/dist/machines/color-picker/index.cjs +1529 -0
  163. package/dist/machines/color-picker/index.d.cts +205 -0
  164. package/dist/machines/color-picker/index.d.mts +205 -0
  165. package/dist/machines/color-picker/index.mjs +1514 -0
  166. package/dist/machines/combobox/index.cjs +1593 -0
  167. package/dist/machines/combobox/index.d.cts +214 -0
  168. package/dist/machines/combobox/index.d.mts +214 -0
  169. package/dist/machines/combobox/index.mjs +1582 -0
  170. package/dist/machines/date-picker/index.cjs +2177 -0
  171. package/dist/machines/date-picker/index.d.cts +350 -0
  172. package/dist/machines/date-picker/index.d.mts +350 -0
  173. package/dist/machines/date-picker/index.mjs +2161 -0
  174. package/dist/machines/dialog/index.cjs +325 -0
  175. package/dist/machines/dialog/index.d.cts +80 -0
  176. package/dist/machines/dialog/index.d.mts +80 -0
  177. package/dist/machines/dialog/index.mjs +321 -0
  178. package/dist/machines/editable/index.cjs +551 -0
  179. package/dist/machines/editable/index.d.cts +114 -0
  180. package/dist/machines/editable/index.d.mts +114 -0
  181. package/dist/machines/editable/index.mjs +547 -0
  182. package/dist/machines/floating-panel/index.cjs +995 -0
  183. package/dist/machines/floating-panel/index.d.cts +147 -0
  184. package/dist/machines/floating-panel/index.d.mts +147 -0
  185. package/dist/machines/floating-panel/index.mjs +988 -0
  186. package/dist/machines/hover-card/index.cjs +383 -0
  187. package/dist/machines/hover-card/index.d.cts +69 -0
  188. package/dist/machines/hover-card/index.d.mts +69 -0
  189. package/dist/machines/hover-card/index.mjs +379 -0
  190. package/dist/machines/image-cropper/index.cjs +1995 -0
  191. package/dist/machines/image-cropper/index.d.cts +182 -0
  192. package/dist/machines/image-cropper/index.d.mts +182 -0
  193. package/dist/machines/image-cropper/index.mjs +1990 -0
  194. package/dist/machines/listbox/index.cjs +794 -0
  195. package/dist/machines/listbox/index.d.cts +168 -0
  196. package/dist/machines/listbox/index.d.mts +168 -0
  197. package/dist/machines/listbox/index.mjs +782 -0
  198. package/dist/machines/marquee/index.cjs +395 -0
  199. package/dist/machines/marquee/index.d.cts +102 -0
  200. package/dist/machines/marquee/index.d.mts +102 -0
  201. package/dist/machines/marquee/index.mjs +391 -0
  202. package/dist/machines/menu/index.cjs +1298 -0
  203. package/dist/machines/menu/index.d.cts +175 -0
  204. package/dist/machines/menu/index.d.mts +175 -0
  205. package/dist/machines/menu/index.mjs +1286 -0
  206. package/dist/machines/navigation-menu/index.cjs +861 -0
  207. package/dist/machines/navigation-menu/index.d.cts +127 -0
  208. package/dist/machines/navigation-menu/index.d.mts +127 -0
  209. package/dist/machines/navigation-menu/index.mjs +857 -0
  210. package/dist/machines/number-input/index.cjs +996 -0
  211. package/dist/machines/number-input/index.d.cts +134 -0
  212. package/dist/machines/number-input/index.d.mts +134 -0
  213. package/dist/machines/number-input/index.mjs +991 -0
  214. package/dist/machines/pagination/index.cjs +419 -0
  215. package/dist/machines/pagination/index.d.cts +139 -0
  216. package/dist/machines/pagination/index.d.mts +139 -0
  217. package/dist/machines/pagination/index.mjs +411 -0
  218. package/dist/machines/password-input/index.cjs +228 -0
  219. package/dist/machines/password-input/index.d.cts +71 -0
  220. package/dist/machines/password-input/index.d.mts +71 -0
  221. package/dist/machines/password-input/index.mjs +224 -0
  222. package/dist/machines/pin-input/index.cjs +523 -0
  223. package/dist/machines/pin-input/index.d.cts +105 -0
  224. package/dist/machines/pin-input/index.d.mts +105 -0
  225. package/dist/machines/pin-input/index.mjs +519 -0
  226. package/dist/machines/popover/index.cjs +430 -0
  227. package/dist/machines/popover/index.d.cts +88 -0
  228. package/dist/machines/popover/index.d.mts +88 -0
  229. package/dist/machines/popover/index.mjs +426 -0
  230. package/dist/machines/presence/index.cjs +192 -0
  231. package/dist/machines/presence/index.d.cts +44 -0
  232. package/dist/machines/presence/index.d.mts +44 -0
  233. package/dist/machines/presence/index.mjs +190 -0
  234. package/dist/machines/progress/index.cjs +288 -0
  235. package/dist/machines/progress/index.d.cts +96 -0
  236. package/dist/machines/progress/index.d.mts +96 -0
  237. package/dist/machines/progress/index.mjs +284 -0
  238. package/dist/machines/qr-code/index.cjs +172 -0
  239. package/dist/machines/qr-code/index.d.cts +70 -0
  240. package/dist/machines/qr-code/index.d.mts +70 -0
  241. package/dist/machines/qr-code/index.mjs +167 -0
  242. package/dist/machines/radio-group/index.cjs +436 -0
  243. package/dist/machines/radio-group/index.d.cts +106 -0
  244. package/dist/machines/radio-group/index.d.mts +106 -0
  245. package/dist/machines/radio-group/index.mjs +430 -0
  246. package/dist/machines/rating-group/index.cjs +405 -0
  247. package/dist/machines/rating-group/index.d.cts +101 -0
  248. package/dist/machines/rating-group/index.d.mts +101 -0
  249. package/dist/machines/rating-group/index.mjs +399 -0
  250. package/dist/machines/scroll-area/index.cjs +857 -0
  251. package/dist/machines/scroll-area/index.d.cts +159 -0
  252. package/dist/machines/scroll-area/index.d.mts +159 -0
  253. package/dist/machines/scroll-area/index.mjs +853 -0
  254. package/dist/machines/select/index.cjs +1165 -0
  255. package/dist/machines/select/index.d.cts +183 -0
  256. package/dist/machines/select/index.d.mts +183 -0
  257. package/dist/machines/select/index.mjs +1154 -0
  258. package/dist/machines/signature-pad/index.cjs +334 -0
  259. package/dist/machines/signature-pad/index.d.cts +108 -0
  260. package/dist/machines/signature-pad/index.d.mts +108 -0
  261. package/dist/machines/signature-pad/index.mjs +328 -0
  262. package/dist/machines/slider/index.cjs +957 -0
  263. package/dist/machines/slider/index.d.cts +149 -0
  264. package/dist/machines/slider/index.d.mts +149 -0
  265. package/dist/machines/slider/index.mjs +949 -0
  266. package/dist/machines/splitter/index.cjs +1112 -0
  267. package/dist/machines/splitter/index.d.cts +155 -0
  268. package/dist/machines/splitter/index.d.mts +155 -0
  269. package/dist/machines/splitter/index.mjs +1103 -0
  270. package/dist/machines/steps/index.cjs +289 -0
  271. package/dist/machines/steps/index.d.cts +97 -0
  272. package/dist/machines/steps/index.d.mts +97 -0
  273. package/dist/machines/steps/index.mjs +285 -0
  274. package/dist/machines/switch/index.cjs +305 -0
  275. package/dist/machines/switch/index.d.cts +80 -0
  276. package/dist/machines/switch/index.d.mts +80 -0
  277. package/dist/machines/switch/index.mjs +301 -0
  278. package/dist/machines/tabs/index.cjs +508 -0
  279. package/dist/machines/tabs/index.d.cts +111 -0
  280. package/dist/machines/tabs/index.d.mts +111 -0
  281. package/dist/machines/tabs/index.mjs +500 -0
  282. package/dist/machines/tags-input/index.cjs +1127 -0
  283. package/dist/machines/tags-input/index.d.cts +179 -0
  284. package/dist/machines/tags-input/index.d.mts +179 -0
  285. package/dist/machines/tags-input/index.mjs +1121 -0
  286. package/dist/machines/timer/index.cjs +329 -0
  287. package/dist/machines/timer/index.d.cts +98 -0
  288. package/dist/machines/timer/index.d.mts +98 -0
  289. package/dist/machines/timer/index.mjs +324 -0
  290. package/dist/machines/toast/index.cjs +1155 -0
  291. package/dist/machines/toast/index.d.cts +195 -0
  292. package/dist/machines/toast/index.d.mts +195 -0
  293. package/dist/machines/toast/index.mjs +1151 -0
  294. package/dist/machines/toggle/index.cjs +103 -0
  295. package/dist/machines/toggle/index.d.cts +46 -0
  296. package/dist/machines/toggle/index.d.mts +46 -0
  297. package/dist/machines/toggle/index.mjs +99 -0
  298. package/dist/machines/toggle-group/index.cjs +328 -0
  299. package/dist/machines/toggle-group/index.d.cts +81 -0
  300. package/dist/machines/toggle-group/index.d.mts +81 -0
  301. package/dist/machines/toggle-group/index.mjs +322 -0
  302. package/dist/machines/tooltip/index.cjs +516 -0
  303. package/dist/machines/tooltip/index.d.cts +71 -0
  304. package/dist/machines/tooltip/index.d.mts +71 -0
  305. package/dist/machines/tooltip/index.mjs +512 -0
  306. package/dist/machines/tour/index.cjs +1108 -0
  307. package/dist/machines/tour/index.d.cts +206 -0
  308. package/dist/machines/tour/index.d.mts +206 -0
  309. package/dist/machines/tour/index.mjs +1101 -0
  310. package/dist/machines/tree-view/index.cjs +1271 -0
  311. package/dist/machines/tree-view/index.d.cts +215 -0
  312. package/dist/machines/tree-view/index.d.mts +215 -0
  313. package/dist/machines/tree-view/index.mjs +1263 -0
  314. package/dist/node-BctU8GXk.d.mts +24 -0
  315. package/dist/node-CSsuPZVZ.d.cts +24 -0
  316. package/dist/popper-BPJeAtcA.mjs +349 -0
  317. package/dist/popper-D0FAW_p7.cjs +373 -0
  318. package/dist/popper.cjs +8 -0
  319. package/dist/popper.d.cts +74 -0
  320. package/dist/popper.d.mts +2 -0
  321. package/dist/popper.mjs +5 -0
  322. package/dist/raf-BnlYUlDi.d.mts +15 -0
  323. package/dist/raf-Cd2FGy0z.d.cts +15 -0
  324. package/dist/rect-utils-0ellN0a_.mjs +854 -0
  325. package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
  326. package/dist/rect-utils.cjs +51 -0
  327. package/dist/rect-utils.d.cts +198 -0
  328. package/dist/rect-utils.d.mts +198 -0
  329. package/dist/rect-utils.mjs +3 -0
  330. package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
  331. package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
  332. package/dist/remove-scroll.cjs +0 -0
  333. package/dist/remove-scroll.d.cts +1 -0
  334. package/dist/remove-scroll.d.mts +1 -0
  335. package/dist/remove-scroll.mjs +1 -0
  336. package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
  337. package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
  338. package/dist/scroll-snap.cjs +7 -0
  339. package/dist/scroll-snap.d.cts +14 -0
  340. package/dist/scroll-snap.d.mts +14 -0
  341. package/dist/scroll-snap.mjs +4 -0
  342. package/dist/selection-BIhSzkF7.d.mts +50 -0
  343. package/dist/selection-CS1GBp8e.d.cts +50 -0
  344. package/dist/store-BZcXv49B.cjs +305 -0
  345. package/dist/store-DEojWy9H.mjs +263 -0
  346. package/dist/store.cjs +9 -0
  347. package/dist/store.d.cts +26 -0
  348. package/dist/store.d.mts +26 -0
  349. package/dist/store.mjs +3 -0
  350. package/dist/stringify-state.cjs +49 -0
  351. package/dist/stringify-state.d.cts +8 -0
  352. package/dist/stringify-state.d.mts +8 -0
  353. package/dist/stringify-state.mjs +46 -0
  354. package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
  355. package/dist/tree-collection-DP_eznnI.d.cts +78 -0
  356. package/dist/typeahead-BdNwVP09.d.cts +45 -0
  357. package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
  358. package/dist/types-BivBkYg9.d.cts +57 -0
  359. package/dist/types-Bl_6JtPQ.d.mts +57 -0
  360. package/dist/types-CPUMVt7c.d.mts +54 -0
  361. package/dist/types-CT_W6HWr.d.cts +54 -0
  362. package/dist/types-DDTcG99l.d.mts +201 -0
  363. package/dist/types-DejIu60O.d.cts +201 -0
  364. package/dist/types-DiIdKZ3K.d.cts +45 -0
  365. package/dist/types-GxLIgJib.d.cts +17 -0
  366. package/dist/types.cjs +15 -0
  367. package/dist/types.d.cts +2 -0
  368. package/dist/types.d.mts +2 -0
  369. package/dist/types.mjs +14 -0
  370. package/dist/utils-BZyrxWWR.mjs +525 -0
  371. package/dist/utils-_6frwjgJ.cjs +1040 -0
  372. package/dist/utils.cjs +88 -0
  373. package/dist/utils.d.cts +144 -0
  374. package/dist/utils.d.mts +144 -0
  375. package/dist/utils.mjs +3 -0
  376. package/dist/wait-for-CMjPsqWk.d.cts +10 -0
  377. package/dist/wait-for-D2nkdD4z.d.mts +10 -0
  378. package/package.json +399 -0
@@ -0,0 +1,1374 @@
1
+ import { t as _defineProperty } from "./defineProperty-DrXfyjd4.mjs";
2
+
3
+ //#region src/shared/dom-query/caret.ts
4
+ function isCaretAtStart(input) {
5
+ if (!input) return false;
6
+ try {
7
+ return input.selectionStart === 0 && input.selectionEnd === 0;
8
+ } catch {
9
+ return input.value === "";
10
+ }
11
+ }
12
+ function setCaretToEnd(input) {
13
+ if (!input) return;
14
+ const start = input.selectionStart ?? 0;
15
+ const end = input.selectionEnd ?? 0;
16
+ if (Math.abs(end - start) !== 0) return;
17
+ if (start !== 0) return;
18
+ input.setSelectionRange(input.value.length, input.value.length);
19
+ }
20
+
21
+ //#endregion
22
+ //#region src/shared/dom-query/shared.ts
23
+ const clamp = (value) => Math.max(0, Math.min(1, value));
24
+ const wrap = (v, idx) => {
25
+ return v.map((_, index) => v[(Math.max(idx, 0) + index) % v.length]);
26
+ };
27
+ const pipe = (...fns) => (arg) => fns.reduce((acc, fn) => fn(acc), arg);
28
+ const noop = () => void 0;
29
+ const isObject = (v) => typeof v === "object" && v !== null;
30
+ const MAX_Z_INDEX = 2147483647;
31
+ const dataAttr = (guard) => guard ? "" : void 0;
32
+ const ariaAttr = (guard) => guard ? "true" : void 0;
33
+
34
+ //#endregion
35
+ //#region src/shared/dom-query/node.ts
36
+ const ELEMENT_NODE = 1;
37
+ const DOCUMENT_NODE = 9;
38
+ const DOCUMENT_FRAGMENT_NODE = 11;
39
+ const isHTMLElement = (el) => isObject(el) && el.nodeType === ELEMENT_NODE && typeof el.nodeName === "string";
40
+ const isDocument = (el) => isObject(el) && el.nodeType === DOCUMENT_NODE;
41
+ const isWindow = (el) => isObject(el) && el === el.window;
42
+ const isVisualViewport = (el) => isObject(el) && el.constructor.name === "VisualViewport";
43
+ const getNodeName = (node) => {
44
+ if (isHTMLElement(node)) return node.localName || "";
45
+ return "#document";
46
+ };
47
+ function isRootElement(node) {
48
+ return [
49
+ "html",
50
+ "body",
51
+ "#document"
52
+ ].includes(getNodeName(node));
53
+ }
54
+ const isNode = (el) => isObject(el) && el.nodeType !== void 0;
55
+ const isShadowRoot = (el) => isNode(el) && el.nodeType === DOCUMENT_FRAGMENT_NODE && "host" in el;
56
+ const isInputElement = (el) => isHTMLElement(el) && el.localName === "input";
57
+ const isAnchorElement = (el) => !!el?.matches("a[href]");
58
+ const isElementVisible = (el) => {
59
+ if (!isHTMLElement(el)) return false;
60
+ return el.offsetWidth > 0 || el.offsetHeight > 0 || el.getClientRects().length > 0;
61
+ };
62
+ function isActiveElement(element) {
63
+ if (!element) return false;
64
+ return getActiveElement(element.getRootNode()) === element;
65
+ }
66
+ const TEXTAREA_SELECT_REGEX = /(textarea|select)/;
67
+ function isEditableElement(el) {
68
+ if (el == null || !isHTMLElement(el)) return false;
69
+ try {
70
+ return isInputElement(el) && el.selectionStart != null || TEXTAREA_SELECT_REGEX.test(el.localName) || el.isContentEditable || el.getAttribute("contenteditable") === "true" || el.getAttribute("contenteditable") === "";
71
+ } catch {
72
+ return false;
73
+ }
74
+ }
75
+ function contains(parent, child) {
76
+ if (!parent || !child) return false;
77
+ if (!isHTMLElement(parent) || !isHTMLElement(child)) return false;
78
+ const rootNode = child.getRootNode?.();
79
+ if (parent === child) return true;
80
+ if (parent.contains(child)) return true;
81
+ if (rootNode && isShadowRoot(rootNode)) {
82
+ let next = child;
83
+ while (next) {
84
+ if (parent === next) return true;
85
+ next = next.parentNode || next.host;
86
+ }
87
+ }
88
+ return false;
89
+ }
90
+ function getDocument(el) {
91
+ if (isDocument(el)) return el;
92
+ if (isWindow(el)) return el.document;
93
+ return el?.ownerDocument ?? document;
94
+ }
95
+ function getDocumentElement(el) {
96
+ return getDocument(el).documentElement;
97
+ }
98
+ function getWindow(el) {
99
+ if (isShadowRoot(el)) return getWindow(el.host);
100
+ if (isDocument(el)) return el.defaultView ?? window;
101
+ if (isHTMLElement(el)) return el.ownerDocument?.defaultView ?? window;
102
+ return window;
103
+ }
104
+ function getActiveElement(rootNode) {
105
+ let activeElement = rootNode.activeElement;
106
+ while (activeElement?.shadowRoot) {
107
+ const el = activeElement.shadowRoot.activeElement;
108
+ if (!el || el === activeElement) break;
109
+ else activeElement = el;
110
+ }
111
+ return activeElement;
112
+ }
113
+ function getParentNode(node) {
114
+ if (getNodeName(node) === "html") return node;
115
+ const result = node.assignedSlot || node.parentNode || isShadowRoot(node) && node.host || getDocumentElement(node);
116
+ return isShadowRoot(result) ? result.host : result;
117
+ }
118
+ function getRootNode(node) {
119
+ let result;
120
+ try {
121
+ result = node.getRootNode({ composed: true });
122
+ if (isDocument(result) || isShadowRoot(result)) return result;
123
+ } catch {}
124
+ return node.ownerDocument ?? document;
125
+ }
126
+
127
+ //#endregion
128
+ //#region src/shared/dom-query/computed-style.ts
129
+ const styleCache = /* @__PURE__ */ new WeakMap();
130
+ function getComputedStyle(el) {
131
+ if (!styleCache.has(el)) styleCache.set(el, getWindow(el).getComputedStyle(el));
132
+ return styleCache.get(el);
133
+ }
134
+
135
+ //#endregion
136
+ //#region src/shared/dom-query/controller.ts
137
+ const INTERACTIVE_CONTAINER_ROLE = new Set([
138
+ "menu",
139
+ "listbox",
140
+ "dialog",
141
+ "grid",
142
+ "tree",
143
+ "region"
144
+ ]);
145
+ const isInteractiveContainerRole = (role) => INTERACTIVE_CONTAINER_ROLE.has(role);
146
+ const getAriaControls = (element) => element.getAttribute("aria-controls")?.split(" ") || [];
147
+ function isControlledElement(container, element) {
148
+ const visitedIds = /* @__PURE__ */ new Set();
149
+ const rootNode = getRootNode(container);
150
+ const checkElement = (searchRoot) => {
151
+ const controllingElements = searchRoot.querySelectorAll("[aria-controls]");
152
+ for (const controller of controllingElements) {
153
+ if (controller.getAttribute("aria-expanded") !== "true") continue;
154
+ const controlledIds = getAriaControls(controller);
155
+ for (const id of controlledIds) {
156
+ if (!id || visitedIds.has(id)) continue;
157
+ visitedIds.add(id);
158
+ const controlledElement = rootNode.getElementById(id);
159
+ if (controlledElement) {
160
+ const role = controlledElement.getAttribute("role");
161
+ const modal = controlledElement.getAttribute("aria-modal") === "true";
162
+ if (role && isInteractiveContainerRole(role) && !modal) {
163
+ if (controlledElement === element || controlledElement.contains(element)) return true;
164
+ if (checkElement(controlledElement)) return true;
165
+ }
166
+ }
167
+ }
168
+ }
169
+ return false;
170
+ };
171
+ return checkElement(container);
172
+ }
173
+ function findControlledElements(searchRoot, callback) {
174
+ const rootNode = getRootNode(searchRoot);
175
+ const visitedIds = /* @__PURE__ */ new Set();
176
+ const findRecursive = (root) => {
177
+ const controllingElements = root.querySelectorAll("[aria-controls]");
178
+ for (const controller of controllingElements) {
179
+ if (controller.getAttribute("aria-expanded") !== "true") continue;
180
+ const controlledIds = getAriaControls(controller);
181
+ for (const id of controlledIds) {
182
+ if (!id || visitedIds.has(id)) continue;
183
+ visitedIds.add(id);
184
+ const controlledElement = rootNode.getElementById(id);
185
+ if (controlledElement) {
186
+ const role = controlledElement.getAttribute("role");
187
+ const modal = controlledElement.getAttribute("aria-modal") === "true";
188
+ if (role && INTERACTIVE_CONTAINER_ROLE.has(role) && !modal) {
189
+ callback(controlledElement);
190
+ findRecursive(controlledElement);
191
+ }
192
+ }
193
+ }
194
+ }
195
+ };
196
+ findRecursive(searchRoot);
197
+ }
198
+ function getControlledElements(container) {
199
+ const controlledElements = /* @__PURE__ */ new Set();
200
+ findControlledElements(container, (controlledElement) => {
201
+ if (!container.contains(controlledElement)) controlledElements.add(controlledElement);
202
+ });
203
+ return Array.from(controlledElements);
204
+ }
205
+ function isInteractiveContainerElement(element) {
206
+ const role = element.getAttribute("role");
207
+ return Boolean(role && INTERACTIVE_CONTAINER_ROLE.has(role));
208
+ }
209
+ function isControllerElement(element) {
210
+ return element.hasAttribute("aria-controls") && element.getAttribute("aria-expanded") === "true";
211
+ }
212
+ function hasControllerElements(element) {
213
+ if (isControllerElement(element)) return true;
214
+ return Boolean(element.querySelector?.("[aria-controls][aria-expanded=\"true\"]"));
215
+ }
216
+ function isControlledByExpandedController(element) {
217
+ if (!element.id) return false;
218
+ const rootNode = getRootNode(element);
219
+ const escapedId = CSS.escape(element.id);
220
+ const selector = `[aria-controls~="${escapedId}"][aria-expanded="true"], [aria-controls="${escapedId}"][aria-expanded="true"]`;
221
+ const controller = rootNode.querySelector(selector);
222
+ return Boolean(controller && isInteractiveContainerElement(element));
223
+ }
224
+
225
+ //#endregion
226
+ //#region src/shared/dom-query/data-url.ts
227
+ function getDataUrl(svg, opts) {
228
+ const { type, quality = .92, background } = opts;
229
+ if (!svg) throw new Error("[sprawlify-js > getDataUrl]: Could not find the svg element");
230
+ const win = getWindow(svg);
231
+ const doc = win.document;
232
+ const svgBounds = svg.getBoundingClientRect();
233
+ const svgClone = svg.cloneNode(true);
234
+ if (!svgClone.hasAttribute("viewBox")) svgClone.setAttribute("viewBox", `0 0 ${svgBounds.width} ${svgBounds.height}`);
235
+ const source = "<?xml version=\"1.0\" standalone=\"no\"?>\r\n" + new win.XMLSerializer().serializeToString(svgClone);
236
+ const svgString = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(source);
237
+ if (type === "image/svg+xml") return Promise.resolve(svgString).then((str) => {
238
+ svgClone.remove();
239
+ return str;
240
+ });
241
+ const dpr = win.devicePixelRatio || 1;
242
+ const canvas = doc.createElement("canvas");
243
+ const image = new win.Image();
244
+ image.src = svgString;
245
+ canvas.width = svgBounds.width * dpr;
246
+ canvas.height = svgBounds.height * dpr;
247
+ const context = canvas.getContext("2d");
248
+ if (type === "image/jpeg" || background) {
249
+ context.fillStyle = background || "white";
250
+ context.fillRect(0, 0, canvas.width, canvas.height);
251
+ }
252
+ return new Promise((resolve) => {
253
+ image.onload = () => {
254
+ context?.drawImage(image, 0, 0, canvas.width, canvas.height);
255
+ resolve(canvas.toDataURL(type, quality));
256
+ svgClone.remove();
257
+ };
258
+ });
259
+ }
260
+
261
+ //#endregion
262
+ //#region src/shared/dom-query/platform.ts
263
+ const isDom = () => typeof document !== "undefined";
264
+ function getPlatform() {
265
+ return navigator.userAgentData?.platform ?? navigator.platform;
266
+ }
267
+ function getUserAgent() {
268
+ const ua$1 = navigator.userAgentData;
269
+ if (ua$1 && Array.isArray(ua$1.brands)) return ua$1.brands.map(({ brand, version }) => `${brand}/${version}`).join(" ");
270
+ return navigator.userAgent;
271
+ }
272
+ const pt = (v) => isDom() && v.test(getPlatform());
273
+ const ua = (v) => isDom() && v.test(getUserAgent());
274
+ const vn = (v) => isDom() && v.test(navigator.vendor);
275
+ const isTouchDevice = () => isDom() && !!navigator.maxTouchPoints;
276
+ const isIPhone = () => pt(/^iPhone/i);
277
+ const isIPad = () => pt(/^iPad/i) || isMac() && navigator.maxTouchPoints > 1;
278
+ const isIos = () => isIPhone() || isIPad();
279
+ const isApple = () => isMac() || isIos();
280
+ const isMac = () => pt(/^Mac/i);
281
+ const isSafari = () => isApple() && vn(/apple/i);
282
+ const isFirefox = () => ua(/Firefox/i);
283
+ const isChrome = () => ua(/Chrome/i);
284
+ const isWebKit = () => ua(/AppleWebKit/i) && !isChrome();
285
+ const isAndroid = () => ua(/Android/i);
286
+
287
+ //#endregion
288
+ //#region src/shared/dom-query/event.ts
289
+ function getBeforeInputValue(event) {
290
+ const { selectionStart, selectionEnd, value } = event.currentTarget;
291
+ const data = event.data;
292
+ return value.slice(0, selectionStart) + (data ?? "") + value.slice(selectionEnd);
293
+ }
294
+ function getComposedPath(event) {
295
+ return event.composedPath?.() ?? event.nativeEvent?.composedPath?.();
296
+ }
297
+ function getEventTarget(event) {
298
+ return getComposedPath(event)?.[0] ?? event.target;
299
+ }
300
+ function isOpeningInNewTab(event) {
301
+ const element = event.currentTarget;
302
+ if (!element) return false;
303
+ if (!element.matches("a[href], button[type='submit'], input[type='submit']")) return false;
304
+ const isMiddleClick = event.button === 1;
305
+ const isModKeyClick = isCtrlOrMetaKey(event);
306
+ return isMiddleClick || isModKeyClick;
307
+ }
308
+ function isDownloadingEvent(event) {
309
+ const element = event.currentTarget;
310
+ if (!element) return false;
311
+ const localName = element.localName;
312
+ if (!event.altKey) return false;
313
+ if (localName === "a") return true;
314
+ if (localName === "button" && element.type === "submit") return true;
315
+ if (localName === "input" && element.type === "submit") return true;
316
+ return false;
317
+ }
318
+ function isComposingEvent(event) {
319
+ return getNativeEvent(event).isComposing || event.keyCode === 229;
320
+ }
321
+ function isKeyboardClick(e) {
322
+ return e.detail === 0 || e.clientX === 0 && e.clientY === 0;
323
+ }
324
+ function isCtrlOrMetaKey(e) {
325
+ if (isMac()) return e.metaKey;
326
+ return e.ctrlKey;
327
+ }
328
+ function isPrintableKey(e) {
329
+ return e.key.length === 1 && !e.ctrlKey && !e.metaKey;
330
+ }
331
+ function isVirtualPointerEvent(e) {
332
+ return e.width === 0 && e.height === 0 || e.width === 1 && e.height === 1 && e.pressure === 0 && e.detail === 0 && e.pointerType === "mouse";
333
+ }
334
+ function isVirtualClick(e) {
335
+ if (e.pointerType === "" && e.isTrusted) return true;
336
+ if (isAndroid() && e.pointerType) return e.type === "click" && e.buttons === 1;
337
+ return e.detail === 0 && !e.pointerType;
338
+ }
339
+ const isLeftClick = (e) => e.button === 0;
340
+ const isContextMenuEvent = (e) => {
341
+ return e.button === 2 || isMac() && e.ctrlKey && e.button === 0;
342
+ };
343
+ const isModifierKey = (e) => e.ctrlKey || e.altKey || e.metaKey;
344
+ const isTouchEvent = (event) => "touches" in event && event.touches.length > 0;
345
+ const keyMap = {
346
+ Up: "ArrowUp",
347
+ Down: "ArrowDown",
348
+ Esc: "Escape",
349
+ " ": "Space",
350
+ ",": "Comma",
351
+ Left: "ArrowLeft",
352
+ Right: "ArrowRight"
353
+ };
354
+ const rtlKeyMap = {
355
+ ArrowLeft: "ArrowRight",
356
+ ArrowRight: "ArrowLeft"
357
+ };
358
+ function getEventKey(event, options = {}) {
359
+ const { dir = "ltr", orientation = "horizontal" } = options;
360
+ let key = event.key;
361
+ key = keyMap[key] ?? key;
362
+ if (dir === "rtl" && orientation === "horizontal" && key in rtlKeyMap) key = rtlKeyMap[key];
363
+ return key;
364
+ }
365
+ function getNativeEvent(event) {
366
+ return event.nativeEvent ?? event;
367
+ }
368
+ const pageKeys = new Set(["PageUp", "PageDown"]);
369
+ const arrowKeys = new Set([
370
+ "ArrowUp",
371
+ "ArrowDown",
372
+ "ArrowLeft",
373
+ "ArrowRight"
374
+ ]);
375
+ function getEventStep(event) {
376
+ if (event.ctrlKey || event.metaKey) return .1;
377
+ else return pageKeys.has(event.key) || event.shiftKey && arrowKeys.has(event.key) ? 10 : 1;
378
+ }
379
+ function getEventPoint(event, type = "client") {
380
+ const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] : event;
381
+ return {
382
+ x: point[`${type}X`],
383
+ y: point[`${type}Y`]
384
+ };
385
+ }
386
+ const addDomEvent = (target, eventName, handler, options) => {
387
+ const node = typeof target === "function" ? target() : target;
388
+ node?.addEventListener(eventName, handler, options);
389
+ return () => {
390
+ node?.removeEventListener(eventName, handler, options);
391
+ };
392
+ };
393
+ const isSelfTarget = (event) => {
394
+ const target = getComposedPath(event)?.[0] ?? event.target;
395
+ return event.currentTarget === target;
396
+ };
397
+
398
+ //#endregion
399
+ //#region src/shared/dom-query/form.ts
400
+ function getDescriptor(el, options) {
401
+ const { type = "HTMLInputElement", property = "value" } = options;
402
+ const proto = getWindow(el)[type].prototype;
403
+ return Object.getOwnPropertyDescriptor(proto, property) ?? {};
404
+ }
405
+ function getElementType(el) {
406
+ if (el.localName === "input") return "HTMLInputElement";
407
+ if (el.localName === "textarea") return "HTMLTextAreaElement";
408
+ if (el.localName === "select") return "HTMLSelectElement";
409
+ }
410
+ function setElementValue(el, value, property = "value") {
411
+ if (!el) return;
412
+ const type = getElementType(el);
413
+ if (type) getDescriptor(el, {
414
+ type,
415
+ property
416
+ }).set?.call(el, value);
417
+ el.setAttribute(property, value);
418
+ }
419
+ function setElementChecked(el, checked) {
420
+ if (!el) return;
421
+ getDescriptor(el, {
422
+ type: "HTMLInputElement",
423
+ property: "checked"
424
+ }).set?.call(el, checked);
425
+ if (checked) el.setAttribute("checked", "");
426
+ else el.removeAttribute("checked");
427
+ }
428
+ function dispatchInputValueEvent(el, options) {
429
+ const { value, bubbles = true } = options;
430
+ if (!el) return;
431
+ const win = getWindow(el);
432
+ if (!(el instanceof win.HTMLInputElement)) return;
433
+ setElementValue(el, `${value}`);
434
+ el.dispatchEvent(new win.Event("input", { bubbles }));
435
+ }
436
+ function dispatchInputCheckedEvent(el, options) {
437
+ const { checked, bubbles = true } = options;
438
+ if (!el) return;
439
+ const win = getWindow(el);
440
+ if (!(el instanceof win.HTMLInputElement)) return;
441
+ setElementChecked(el, checked);
442
+ el.dispatchEvent(new win.Event("click", { bubbles }));
443
+ }
444
+ function getClosestForm(el) {
445
+ return isFormElement(el) ? el.form : el.closest("form");
446
+ }
447
+ function isFormElement(el) {
448
+ return el.matches("textarea, input, select, button");
449
+ }
450
+ function trackFormReset(el, callback) {
451
+ if (!el) return;
452
+ const form = getClosestForm(el);
453
+ const onReset = (e) => {
454
+ if (e.defaultPrevented) return;
455
+ callback();
456
+ };
457
+ form?.addEventListener("reset", onReset, { passive: true });
458
+ return () => form?.removeEventListener("reset", onReset);
459
+ }
460
+ function trackFieldsetDisabled(el, callback) {
461
+ const fieldset = el?.closest("fieldset");
462
+ if (!fieldset) return;
463
+ callback(fieldset.disabled);
464
+ const obs = new (getWindow(fieldset)).MutationObserver(() => callback(fieldset.disabled));
465
+ obs.observe(fieldset, {
466
+ attributes: true,
467
+ attributeFilter: ["disabled"]
468
+ });
469
+ return () => obs.disconnect();
470
+ }
471
+ function trackFormControl(el, options) {
472
+ if (!el) return;
473
+ const { onFieldsetDisabledChange, onFormReset } = options;
474
+ const cleanups = [trackFormReset(el, onFormReset), trackFieldsetDisabled(el, onFieldsetDisabledChange)];
475
+ return () => cleanups.forEach((cleanup) => cleanup?.());
476
+ }
477
+
478
+ //#endregion
479
+ //#region src/shared/dom-query/tabbable.ts
480
+ const isFrame = (el) => isHTMLElement(el) && el.tagName === "IFRAME";
481
+ const NATURALLY_TABBABLE_REGEX = /^(audio|video|details)$/;
482
+ function parseTabIndex(el) {
483
+ const attr = el.getAttribute("tabindex");
484
+ if (!attr) return NaN;
485
+ return parseInt(attr, 10);
486
+ }
487
+ const hasTabIndex = (el) => !Number.isNaN(parseTabIndex(el));
488
+ const hasNegativeTabIndex = (el) => parseTabIndex(el) < 0;
489
+ function getShadowRootForNode(element, getShadowRoot) {
490
+ if (!getShadowRoot) return null;
491
+ if (getShadowRoot === true) return element.shadowRoot || null;
492
+ const result = getShadowRoot(element);
493
+ return (result === true ? element.shadowRoot : result) || null;
494
+ }
495
+ function collectElementsWithShadowDOM(elements, getShadowRoot, filterFn) {
496
+ const allElements = [...elements];
497
+ const toProcess = [...elements];
498
+ const processed = /* @__PURE__ */ new Set();
499
+ const positionMap = /* @__PURE__ */ new Map();
500
+ elements.forEach((el, i) => positionMap.set(el, i));
501
+ let processIndex = 0;
502
+ while (processIndex < toProcess.length) {
503
+ const element = toProcess[processIndex++];
504
+ if (!element || processed.has(element)) continue;
505
+ processed.add(element);
506
+ const shadowRoot = getShadowRootForNode(element, getShadowRoot);
507
+ if (shadowRoot) {
508
+ const shadowElements = Array.from(shadowRoot.querySelectorAll(focusableSelector)).filter(filterFn);
509
+ const hostIndex = positionMap.get(element);
510
+ if (hostIndex !== void 0) {
511
+ const insertPosition = hostIndex + 1;
512
+ allElements.splice(insertPosition, 0, ...shadowElements);
513
+ shadowElements.forEach((el, i) => {
514
+ positionMap.set(el, insertPosition + i);
515
+ });
516
+ for (let i = insertPosition + shadowElements.length; i < allElements.length; i++) positionMap.set(allElements[i], i);
517
+ } else {
518
+ const insertPosition = allElements.length;
519
+ allElements.push(...shadowElements);
520
+ shadowElements.forEach((el, i) => {
521
+ positionMap.set(el, insertPosition + i);
522
+ });
523
+ }
524
+ toProcess.push(...shadowElements);
525
+ }
526
+ }
527
+ return allElements;
528
+ }
529
+ const focusableSelector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false']), details > summary:first-of-type";
530
+ const getFocusables = (container, options = {}) => {
531
+ if (!container) return [];
532
+ const { includeContainer = false, getShadowRoot } = options;
533
+ const elements = Array.from(container.querySelectorAll(focusableSelector));
534
+ if ((includeContainer == true || includeContainer == "if-empty" && elements.length === 0) && isHTMLElement(container) && isFocusable(container)) elements.unshift(container);
535
+ const focusableElements = [];
536
+ for (const element of elements) {
537
+ if (!isFocusable(element)) continue;
538
+ if (isFrame(element) && element.contentDocument) {
539
+ const frameBody = element.contentDocument.body;
540
+ focusableElements.push(...getFocusables(frameBody, { getShadowRoot }));
541
+ continue;
542
+ }
543
+ focusableElements.push(element);
544
+ }
545
+ if (getShadowRoot) return collectElementsWithShadowDOM(focusableElements, getShadowRoot, isFocusable);
546
+ return focusableElements;
547
+ };
548
+ function isFocusable(element) {
549
+ if (!isHTMLElement(element) || element.closest("[inert]")) return false;
550
+ return element.matches(focusableSelector) && isElementVisible(element);
551
+ }
552
+ function getFirstFocusable(container, options = {}) {
553
+ const [first] = getFocusables(container, options);
554
+ return first || null;
555
+ }
556
+ function getTabbables(container, options = {}) {
557
+ if (!container) return [];
558
+ const { includeContainer, getShadowRoot } = options;
559
+ const elements = Array.from(container.querySelectorAll(focusableSelector));
560
+ if (includeContainer && isTabbable(container)) elements.unshift(container);
561
+ const tabbableElements = [];
562
+ for (const element of elements) {
563
+ if (!isTabbable(element)) continue;
564
+ if (isFrame(element) && element.contentDocument) {
565
+ const frameBody = element.contentDocument.body;
566
+ tabbableElements.push(...getTabbables(frameBody, { getShadowRoot }));
567
+ continue;
568
+ }
569
+ tabbableElements.push(element);
570
+ }
571
+ if (getShadowRoot) {
572
+ const allElements = collectElementsWithShadowDOM(tabbableElements, getShadowRoot, isTabbable);
573
+ if (!allElements.length && includeContainer) return elements;
574
+ return allElements;
575
+ }
576
+ if (!tabbableElements.length && includeContainer) return elements;
577
+ return tabbableElements;
578
+ }
579
+ function isTabbable(el) {
580
+ if (isHTMLElement(el) && el.tabIndex > 0) return true;
581
+ return isFocusable(el) && !hasNegativeTabIndex(el);
582
+ }
583
+ function getFirstTabbable(container, options = {}) {
584
+ const [first] = getTabbables(container, options);
585
+ return first || null;
586
+ }
587
+ function getLastTabbable(container, options = {}) {
588
+ const elements = getTabbables(container, options);
589
+ return elements[elements.length - 1] || null;
590
+ }
591
+ function getTabbableEdges(container, options = {}) {
592
+ const elements = getTabbables(container, options);
593
+ return [elements[0] || null, elements[elements.length - 1] || null];
594
+ }
595
+ function getNextTabbable(container, options = {}) {
596
+ const { current, getShadowRoot } = options;
597
+ const tabbables = getTabbables(container, { getShadowRoot });
598
+ const doc = container?.ownerDocument || document;
599
+ const currentElement = current ?? getActiveElement(doc);
600
+ if (!currentElement) return null;
601
+ return tabbables[tabbables.indexOf(currentElement) + 1] || null;
602
+ }
603
+ function getTabIndex(node) {
604
+ if (node.tabIndex < 0) {
605
+ if ((NATURALLY_TABBABLE_REGEX.test(node.localName) || isEditableElement(node)) && !hasTabIndex(node)) return 0;
606
+ }
607
+ return node.tabIndex;
608
+ }
609
+
610
+ //#endregion
611
+ //#region src/shared/dom-query/initial-focus.ts
612
+ function getInitialFocus(options) {
613
+ const { root, getInitialEl, filter, enabled = true } = options;
614
+ if (!enabled) return;
615
+ let node = null;
616
+ node || (node = typeof getInitialEl === "function" ? getInitialEl() : getInitialEl);
617
+ node || (node = root?.querySelector("[data-autofocus],[autofocus]"));
618
+ if (!node) {
619
+ const tabbables = getTabbables(root);
620
+ node = filter ? tabbables.filter(filter)[0] : tabbables[0];
621
+ }
622
+ return node || root || void 0;
623
+ }
624
+ function isValidTabEvent(event) {
625
+ const container = event.currentTarget;
626
+ if (!container) return false;
627
+ const [firstTabbable, lastTabbable] = getTabbableEdges(container);
628
+ if (isActiveElement(firstTabbable) && event.shiftKey) return false;
629
+ if (isActiveElement(lastTabbable) && !event.shiftKey) return false;
630
+ if (!firstTabbable && !lastTabbable) return false;
631
+ return true;
632
+ }
633
+
634
+ //#endregion
635
+ //#region src/shared/dom-query/raf.ts
636
+ var AnimationFrame = class AnimationFrame {
637
+ constructor() {
638
+ _defineProperty(this, "id", null);
639
+ _defineProperty(this, "fn_cleanup", void 0);
640
+ _defineProperty(this, "cleanup", () => {
641
+ this.cancel();
642
+ });
643
+ }
644
+ static create() {
645
+ return new AnimationFrame();
646
+ }
647
+ request(fn) {
648
+ this.cancel();
649
+ this.id = globalThis.requestAnimationFrame(() => {
650
+ this.id = null;
651
+ this.fn_cleanup = fn?.();
652
+ });
653
+ }
654
+ cancel() {
655
+ if (this.id !== null) {
656
+ globalThis.cancelAnimationFrame(this.id);
657
+ this.id = null;
658
+ }
659
+ this.fn_cleanup?.();
660
+ this.fn_cleanup = void 0;
661
+ }
662
+ isActive() {
663
+ return this.id !== null;
664
+ }
665
+ };
666
+ function raf(fn) {
667
+ const frame = AnimationFrame.create();
668
+ frame.request(fn);
669
+ return frame.cleanup;
670
+ }
671
+ function nextTick(fn) {
672
+ const set = /* @__PURE__ */ new Set();
673
+ function raf$1(fn$1) {
674
+ const id = globalThis.requestAnimationFrame(fn$1);
675
+ set.add(() => globalThis.cancelAnimationFrame(id));
676
+ }
677
+ raf$1(() => raf$1(fn));
678
+ return function cleanup() {
679
+ set.forEach((fn$1) => fn$1());
680
+ };
681
+ }
682
+ function queueBeforeEvent(el, type, cb) {
683
+ const cancelTimer = raf(() => {
684
+ el.removeEventListener(type, exec, true);
685
+ cb();
686
+ });
687
+ const exec = () => {
688
+ cancelTimer();
689
+ cb();
690
+ };
691
+ el.addEventListener(type, exec, {
692
+ once: true,
693
+ capture: true
694
+ });
695
+ return cancelTimer;
696
+ }
697
+
698
+ //#endregion
699
+ //#region src/shared/dom-query/mutation-observer.ts
700
+ function observeAttributesImpl(node, options) {
701
+ if (!node) return;
702
+ const { attributes, callback: fn } = options;
703
+ const obs = new (node.ownerDocument.defaultView || window).MutationObserver((changes) => {
704
+ for (const change of changes) if (change.type === "attributes" && change.attributeName && attributes.includes(change.attributeName)) fn(change);
705
+ });
706
+ obs.observe(node, {
707
+ attributes: true,
708
+ attributeFilter: attributes
709
+ });
710
+ return () => obs.disconnect();
711
+ }
712
+ function observeAttributes(nodeOrFn, options) {
713
+ const { defer } = options;
714
+ const func = defer ? raf : (v) => v();
715
+ const cleanups = [];
716
+ cleanups.push(func(() => {
717
+ const node = typeof nodeOrFn === "function" ? nodeOrFn() : nodeOrFn;
718
+ cleanups.push(observeAttributesImpl(node, options));
719
+ }));
720
+ return () => {
721
+ cleanups.forEach((fn) => fn?.());
722
+ };
723
+ }
724
+ function observeChildrenImpl(node, options) {
725
+ const { callback: fn } = options;
726
+ if (!node) return;
727
+ const obs = new (node.ownerDocument.defaultView || window).MutationObserver(fn);
728
+ obs.observe(node, {
729
+ childList: true,
730
+ subtree: true
731
+ });
732
+ return () => obs.disconnect();
733
+ }
734
+ function observeChildren(nodeOrFn, options) {
735
+ const { defer } = options;
736
+ const func = defer ? raf : (v) => v();
737
+ const cleanups = [];
738
+ cleanups.push(func(() => {
739
+ const node = typeof nodeOrFn === "function" ? nodeOrFn() : nodeOrFn;
740
+ cleanups.push(observeChildrenImpl(node, options));
741
+ }));
742
+ return () => {
743
+ cleanups.forEach((fn) => fn?.());
744
+ };
745
+ }
746
+
747
+ //#endregion
748
+ //#region src/shared/dom-query/navigate.ts
749
+ function navigate(items, current, options = {}) {
750
+ if (!current) return null;
751
+ const { orientation = "both", loop = true, dir = "ltr", key } = options;
752
+ if (!items.length || !key) return null;
753
+ const isVertical = key === "ArrowUp" || key === "ArrowDown";
754
+ const isHorizontal = key === "ArrowLeft" || key === "ArrowRight";
755
+ if (!isVertical && !isHorizontal && key !== "Home" && key !== "End") return null;
756
+ if (orientation === "vertical" && isHorizontal || orientation === "horizontal" && isVertical) return null;
757
+ if (key === "Home") return items[0] || null;
758
+ if (key === "End") return items[items.length - 1] || null;
759
+ const idx = items.indexOf(current);
760
+ if (idx === -1) return null;
761
+ let isForward;
762
+ if (orientation === "both") isForward = key === "ArrowDown" || (dir === "ltr" ? key === "ArrowRight" : key === "ArrowLeft");
763
+ else isForward = isVertical ? key === "ArrowDown" : dir === "ltr" ? key === "ArrowRight" : key === "ArrowLeft";
764
+ return items[isForward ? loop ? (idx + 1) % items.length : Math.min(idx + 1, items.length - 1) : loop ? (idx - 1 + items.length) % items.length : Math.max(0, idx - 1)] || null;
765
+ }
766
+ function clickIfLink(el) {
767
+ const click = () => {
768
+ const win = getWindow(el);
769
+ el.dispatchEvent(new win.MouseEvent("click"));
770
+ };
771
+ if (isFirefox()) queueBeforeEvent(el, "keyup", click);
772
+ else queueMicrotask(click);
773
+ }
774
+
775
+ //#endregion
776
+ //#region src/shared/dom-query/overflow.ts
777
+ function getNearestOverflowAncestor(el) {
778
+ const parentNode = getParentNode(el);
779
+ if (isRootElement(parentNode)) return getDocument(parentNode).body;
780
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) return parentNode;
781
+ return getNearestOverflowAncestor(parentNode);
782
+ }
783
+ function getOverflowAncestors(el, list = []) {
784
+ const scrollableAncestor = getNearestOverflowAncestor(el);
785
+ const isBody = scrollableAncestor === el.ownerDocument.body;
786
+ const win = getWindow(scrollableAncestor);
787
+ if (isBody) return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
788
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, []));
789
+ }
790
+ const getElementRect = (el) => {
791
+ if (isHTMLElement(el)) return el.getBoundingClientRect();
792
+ if (isVisualViewport(el)) return {
793
+ top: 0,
794
+ left: 0,
795
+ bottom: el.height,
796
+ right: el.width
797
+ };
798
+ return {
799
+ top: 0,
800
+ left: 0,
801
+ bottom: el.innerHeight,
802
+ right: el.innerWidth
803
+ };
804
+ };
805
+ function isInView(el, ancestor) {
806
+ if (!isHTMLElement(el)) return true;
807
+ const ancestorRect = getElementRect(ancestor);
808
+ const elRect = el.getBoundingClientRect();
809
+ return elRect.top >= ancestorRect.top && elRect.left >= ancestorRect.left && elRect.bottom <= ancestorRect.bottom && elRect.right <= ancestorRect.right;
810
+ }
811
+ const OVERFLOW_RE = /auto|scroll|overlay|hidden|clip/;
812
+ const nonOverflowValues = new Set(["inline", "contents"]);
813
+ function isOverflowElement(el) {
814
+ const { overflow, overflowX, overflowY, display } = getWindow(el).getComputedStyle(el);
815
+ return OVERFLOW_RE.test(overflow + overflowY + overflowX) && !nonOverflowValues.has(display);
816
+ }
817
+ function isScrollable(el) {
818
+ return el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth;
819
+ }
820
+ function scrollIntoView(el, options) {
821
+ const { rootEl, ...scrollOptions } = options || {};
822
+ if (!el || !rootEl) return;
823
+ if (!isOverflowElement(rootEl) || !isScrollable(rootEl)) return;
824
+ el.scrollIntoView(scrollOptions);
825
+ }
826
+ function getScrollPosition(element) {
827
+ if (isHTMLElement(element)) return {
828
+ scrollLeft: element.scrollLeft,
829
+ scrollTop: element.scrollTop
830
+ };
831
+ return {
832
+ scrollLeft: element.scrollX,
833
+ scrollTop: element.scrollY
834
+ };
835
+ }
836
+
837
+ //#endregion
838
+ //#region src/shared/dom-query/point.ts
839
+ function getRelativePoint(point, element) {
840
+ const { left, top, width, height } = element.getBoundingClientRect();
841
+ const offset = {
842
+ x: point.x - left,
843
+ y: point.y - top
844
+ };
845
+ const percent = {
846
+ x: clamp(offset.x / width),
847
+ y: clamp(offset.y / height)
848
+ };
849
+ function getPercentValue(options = {}) {
850
+ const { dir = "ltr", orientation = "horizontal", inverted } = options;
851
+ const invertX = typeof inverted === "object" ? inverted.x : inverted;
852
+ const invertY = typeof inverted === "object" ? inverted.y : inverted;
853
+ if (orientation === "horizontal") return dir === "rtl" || invertX ? 1 - percent.x : percent.x;
854
+ return invertY ? 1 - percent.y : percent.y;
855
+ }
856
+ return {
857
+ offset,
858
+ percent,
859
+ getPercentValue
860
+ };
861
+ }
862
+
863
+ //#endregion
864
+ //#region src/shared/dom-query/pointer-lock.ts
865
+ function requestPointerLock(doc, fn) {
866
+ const body = doc.body;
867
+ const supported = "pointerLockElement" in doc || "mozPointerLockElement" in doc;
868
+ const isLocked = () => !!doc.pointerLockElement;
869
+ function onPointerChange() {
870
+ fn?.(isLocked());
871
+ }
872
+ function onPointerError(event) {
873
+ if (isLocked()) fn?.(false);
874
+ console.error("PointerLock error occurred:", event);
875
+ doc.exitPointerLock();
876
+ }
877
+ if (!supported) return;
878
+ try {
879
+ body.requestPointerLock();
880
+ } catch {}
881
+ const cleanup = [addDomEvent(doc, "pointerlockchange", onPointerChange, false), addDomEvent(doc, "pointerlockerror", onPointerError, false)];
882
+ return () => {
883
+ cleanup.forEach((cleanup$1) => cleanup$1());
884
+ doc.exitPointerLock();
885
+ };
886
+ }
887
+
888
+ //#endregion
889
+ //#region src/shared/dom-query/text-selection.ts
890
+ let state = "default";
891
+ let userSelect = "";
892
+ const elementMap = /* @__PURE__ */ new WeakMap();
893
+ function disableTextSelectionImpl(options = {}) {
894
+ const { target, doc } = options;
895
+ const docNode = doc ?? document;
896
+ const rootEl = docNode.documentElement;
897
+ if (isIos()) {
898
+ if (state === "default") {
899
+ userSelect = rootEl.style.webkitUserSelect;
900
+ rootEl.style.webkitUserSelect = "none";
901
+ }
902
+ state = "disabled";
903
+ } else if (target) {
904
+ elementMap.set(target, target.style.userSelect);
905
+ target.style.userSelect = "none";
906
+ }
907
+ return () => restoreTextSelection({
908
+ target,
909
+ doc: docNode
910
+ });
911
+ }
912
+ function restoreTextSelection(options = {}) {
913
+ const { target, doc } = options;
914
+ const rootEl = (doc ?? document).documentElement;
915
+ if (isIos()) {
916
+ if (state !== "disabled") return;
917
+ state = "restoring";
918
+ setTimeout(() => {
919
+ nextTick(() => {
920
+ if (state === "restoring") {
921
+ if (rootEl.style.webkitUserSelect === "none") rootEl.style.webkitUserSelect = userSelect || "";
922
+ userSelect = "";
923
+ state = "default";
924
+ }
925
+ });
926
+ }, 300);
927
+ } else if (target && elementMap.has(target)) {
928
+ const prevUserSelect = elementMap.get(target);
929
+ if (target.style.userSelect === "none") target.style.userSelect = prevUserSelect ?? "";
930
+ if (target.getAttribute("style") === "") target.removeAttribute("style");
931
+ elementMap.delete(target);
932
+ }
933
+ }
934
+ function disableTextSelection(options = {}) {
935
+ const { defer, target, ...restOptions } = options;
936
+ const func = defer ? raf : (v) => v();
937
+ const cleanups = [];
938
+ cleanups.push(func(() => {
939
+ const node = typeof target === "function" ? target() : target;
940
+ cleanups.push(disableTextSelectionImpl({
941
+ ...restOptions,
942
+ target: node
943
+ }));
944
+ }));
945
+ return () => {
946
+ cleanups.forEach((fn) => fn?.());
947
+ };
948
+ }
949
+
950
+ //#endregion
951
+ //#region src/shared/dom-query/pointer-move.ts
952
+ function trackPointerMove(doc, handlers) {
953
+ const { onPointerMove, onPointerUp } = handlers;
954
+ const handleMove = (event) => {
955
+ const point = getEventPoint(event);
956
+ if (Math.sqrt(point.x ** 2 + point.y ** 2) < (event.pointerType === "touch" ? 10 : 5)) return;
957
+ if (event.pointerType === "mouse" && event.buttons === 0) {
958
+ handleUp(event);
959
+ return;
960
+ }
961
+ onPointerMove({
962
+ point,
963
+ event
964
+ });
965
+ };
966
+ const handleUp = (event) => {
967
+ onPointerUp({
968
+ point: getEventPoint(event),
969
+ event
970
+ });
971
+ };
972
+ const cleanups = [
973
+ addDomEvent(doc, "pointermove", handleMove, false),
974
+ addDomEvent(doc, "pointerup", handleUp, false),
975
+ addDomEvent(doc, "pointercancel", handleUp, false),
976
+ addDomEvent(doc, "contextmenu", handleUp, false),
977
+ disableTextSelection({ doc })
978
+ ];
979
+ return () => {
980
+ cleanups.forEach((cleanup) => cleanup());
981
+ };
982
+ }
983
+
984
+ //#endregion
985
+ //#region src/shared/dom-query/press.ts
986
+ function trackPress(options) {
987
+ const { pointerNode, keyboardNode = pointerNode, onPress, onPressStart, onPressEnd, isValidKey = (e) => e.key === "Enter" } = options;
988
+ if (!pointerNode) return noop;
989
+ const win = getWindow(pointerNode);
990
+ let removeStartListeners = noop;
991
+ let removeEndListeners = noop;
992
+ let removeAccessibleListeners = noop;
993
+ const getInfo = (event) => ({
994
+ point: getEventPoint(event),
995
+ event
996
+ });
997
+ function startPress(event) {
998
+ onPressStart?.(getInfo(event));
999
+ }
1000
+ function cancelPress(event) {
1001
+ onPressEnd?.(getInfo(event));
1002
+ }
1003
+ const startPointerPress = (startEvent) => {
1004
+ removeEndListeners();
1005
+ const endPointerPress = (endEvent) => {
1006
+ if (contains(pointerNode, getEventTarget(endEvent))) onPress?.(getInfo(endEvent));
1007
+ else onPressEnd?.(getInfo(endEvent));
1008
+ };
1009
+ removeEndListeners = pipe(addDomEvent(win, "pointerup", endPointerPress, {
1010
+ passive: !onPress,
1011
+ once: true
1012
+ }), addDomEvent(win, "pointercancel", cancelPress, {
1013
+ passive: !onPressEnd,
1014
+ once: true
1015
+ }));
1016
+ if (isActiveElement(keyboardNode) && startEvent.pointerType === "mouse") startEvent.preventDefault();
1017
+ startPress(startEvent);
1018
+ };
1019
+ removeStartListeners = pipe(addDomEvent(pointerNode, "pointerdown", startPointerPress, { passive: !onPressStart }), addDomEvent(keyboardNode, "focus", startAccessiblePress));
1020
+ function startAccessiblePress() {
1021
+ const handleKeydown = (keydownEvent) => {
1022
+ if (!isValidKey(keydownEvent)) return;
1023
+ const handleKeyup = (keyupEvent) => {
1024
+ if (!isValidKey(keyupEvent)) return;
1025
+ const info = getInfo(new win.PointerEvent("pointerup"));
1026
+ onPress?.(info);
1027
+ onPressEnd?.(info);
1028
+ };
1029
+ removeEndListeners();
1030
+ removeEndListeners = addDomEvent(keyboardNode, "keyup", handleKeyup);
1031
+ startPress(new win.PointerEvent("pointerdown"));
1032
+ };
1033
+ const handleBlur = () => {
1034
+ cancelPress(new win.PointerEvent("pointercancel"));
1035
+ };
1036
+ removeAccessibleListeners = pipe(addDomEvent(keyboardNode, "keydown", handleKeydown), addDomEvent(keyboardNode, "blur", handleBlur));
1037
+ }
1038
+ return () => {
1039
+ removeStartListeners();
1040
+ removeEndListeners();
1041
+ removeAccessibleListeners();
1042
+ };
1043
+ }
1044
+
1045
+ //#endregion
1046
+ //#region src/shared/dom-query/proxy-tab-focus.ts
1047
+ function proxyTabFocusImpl(container, options = {}) {
1048
+ const { triggerElement, onFocus, onFocusEnter, getShadowRoot } = options;
1049
+ const doc = container?.ownerDocument || document;
1050
+ const body = doc.body;
1051
+ function onKeyDown(event) {
1052
+ if (event.key !== "Tab") return;
1053
+ let elementToFocus = null;
1054
+ const [firstTabbable, lastTabbable] = getTabbableEdges(container, {
1055
+ includeContainer: true,
1056
+ getShadowRoot
1057
+ });
1058
+ const nextTabbableAfterTrigger = getNextTabbable(body, {
1059
+ current: triggerElement,
1060
+ getShadowRoot
1061
+ });
1062
+ const noTabbableElements = !firstTabbable && !lastTabbable;
1063
+ if (event.shiftKey && isActiveElement(nextTabbableAfterTrigger)) {
1064
+ onFocusEnter?.();
1065
+ elementToFocus = lastTabbable;
1066
+ } else if (event.shiftKey && (isActiveElement(firstTabbable) || noTabbableElements)) elementToFocus = triggerElement;
1067
+ else if (!event.shiftKey && isActiveElement(triggerElement)) {
1068
+ onFocusEnter?.();
1069
+ elementToFocus = firstTabbable;
1070
+ } else if (!event.shiftKey && (isActiveElement(lastTabbable) || noTabbableElements)) elementToFocus = nextTabbableAfterTrigger;
1071
+ if (!elementToFocus) return;
1072
+ event.preventDefault();
1073
+ if (typeof onFocus === "function") onFocus(elementToFocus);
1074
+ else elementToFocus.focus();
1075
+ }
1076
+ return addDomEvent(doc, "keydown", onKeyDown, true);
1077
+ }
1078
+ function proxyTabFocus(container, options) {
1079
+ const { defer, triggerElement, ...restOptions } = options;
1080
+ const func = defer ? raf : (v) => v();
1081
+ const cleanups = [];
1082
+ cleanups.push(func(() => {
1083
+ const node = typeof container === "function" ? container() : container;
1084
+ const trigger = typeof triggerElement === "function" ? triggerElement() : triggerElement;
1085
+ cleanups.push(proxyTabFocusImpl(node, {
1086
+ triggerElement: trigger,
1087
+ ...restOptions
1088
+ }));
1089
+ }));
1090
+ return () => {
1091
+ cleanups.forEach((fn) => fn?.());
1092
+ };
1093
+ }
1094
+
1095
+ //#endregion
1096
+ //#region src/shared/dom-query/query.ts
1097
+ function queryAll(root, selector) {
1098
+ return Array.from(root?.querySelectorAll(selector) ?? []);
1099
+ }
1100
+ function query(root, selector) {
1101
+ return root?.querySelector(selector) ?? null;
1102
+ }
1103
+ const defaultItemToId = (v) => v.id;
1104
+ function itemById(v, id, itemToId = defaultItemToId) {
1105
+ return v.find((item) => itemToId(item) === id);
1106
+ }
1107
+ function indexOfId(v, id, itemToId = defaultItemToId) {
1108
+ const item = itemById(v, id, itemToId);
1109
+ return item ? v.indexOf(item) : -1;
1110
+ }
1111
+ function nextById(v, id, loop = true) {
1112
+ let idx = indexOfId(v, id);
1113
+ idx = loop ? (idx + 1) % v.length : Math.min(idx + 1, v.length - 1);
1114
+ return v[idx];
1115
+ }
1116
+ function prevById(v, id, loop = true) {
1117
+ let idx = indexOfId(v, id);
1118
+ if (idx === -1) return loop ? v[v.length - 1] : null;
1119
+ idx = loop ? (idx - 1 + v.length) % v.length : Math.max(0, idx - 1);
1120
+ return v[idx];
1121
+ }
1122
+
1123
+ //#endregion
1124
+ //#region src/shared/dom-query/resize-observer.ts
1125
+ function createSharedResizeObserver(options) {
1126
+ const listeners = /* @__PURE__ */ new WeakMap();
1127
+ let observer;
1128
+ const entries = /* @__PURE__ */ new WeakMap();
1129
+ const getObserver = (win) => {
1130
+ if (observer) return observer;
1131
+ observer = new win.ResizeObserver((observedEntries) => {
1132
+ for (const entry of observedEntries) {
1133
+ entries.set(entry.target, entry);
1134
+ const elementListeners = listeners.get(entry.target);
1135
+ if (elementListeners) for (const listener of elementListeners) listener(entry);
1136
+ }
1137
+ });
1138
+ return observer;
1139
+ };
1140
+ const observe = (element, listener) => {
1141
+ let elementListeners = listeners.get(element) || /* @__PURE__ */ new Set();
1142
+ elementListeners.add(listener);
1143
+ listeners.set(element, elementListeners);
1144
+ const win = getWindow(element);
1145
+ getObserver(win).observe(element, options);
1146
+ return () => {
1147
+ const elementListeners$1 = listeners.get(element);
1148
+ if (!elementListeners$1) return;
1149
+ elementListeners$1.delete(listener);
1150
+ if (elementListeners$1.size === 0) {
1151
+ listeners.delete(element);
1152
+ getObserver(win).unobserve(element);
1153
+ }
1154
+ };
1155
+ };
1156
+ const unobserve = (element) => {
1157
+ listeners.delete(element);
1158
+ observer?.unobserve(element);
1159
+ };
1160
+ return {
1161
+ observe,
1162
+ unobserve
1163
+ };
1164
+ }
1165
+ const resizeObserverContentBox = createSharedResizeObserver({ box: "content-box" });
1166
+ const resizeObserverBorderBox = createSharedResizeObserver({ box: "border-box" });
1167
+ const resizeObserverDevicePixelContentBox = createSharedResizeObserver({ box: "device-pixel-content-box" });
1168
+
1169
+ //#endregion
1170
+ //#region src/shared/dom-query/scope.ts
1171
+ function createScope(methods) {
1172
+ const dom = {
1173
+ getRootNode: (ctx) => ctx.getRootNode?.() ?? document,
1174
+ getDoc: (ctx) => getDocument(dom.getRootNode(ctx)),
1175
+ getWin: (ctx) => dom.getDoc(ctx).defaultView ?? window,
1176
+ getActiveElement: (ctx) => getActiveElement(dom.getRootNode(ctx)),
1177
+ isActiveElement,
1178
+ getById: (ctx, id) => dom.getRootNode(ctx).getElementById(id),
1179
+ setValue: (elem, value) => {
1180
+ if (elem == null || value == null) return;
1181
+ setElementValue(elem, value.toString());
1182
+ }
1183
+ };
1184
+ return {
1185
+ ...dom,
1186
+ ...methods
1187
+ };
1188
+ }
1189
+
1190
+ //#endregion
1191
+ //#region src/shared/dom-query/searchable.ts
1192
+ const sanitize = (str) => str.split("").map((char) => {
1193
+ const code = char.charCodeAt(0);
1194
+ if (code > 0 && code < 128) return char;
1195
+ if (code >= 128 && code <= 255) return `/x${code.toString(16)}`.replace("/", "\\");
1196
+ return "";
1197
+ }).join("").trim();
1198
+ const getValueText = (el) => {
1199
+ return sanitize(el.dataset?.valuetext ?? el.textContent ?? "");
1200
+ };
1201
+ const match = (valueText, query$1) => {
1202
+ return valueText.trim().toLowerCase().startsWith(query$1.toLowerCase());
1203
+ };
1204
+ function getByText(v, text, currentId, itemToId = defaultItemToId) {
1205
+ const index = currentId ? indexOfId(v, currentId, itemToId) : -1;
1206
+ let items = currentId ? wrap(v, index) : v;
1207
+ if (text.length === 1) items = items.filter((item) => itemToId(item) !== currentId);
1208
+ return items.find((item) => match(getValueText(item), text));
1209
+ }
1210
+
1211
+ //#endregion
1212
+ //#region src/shared/dom-query/set.ts
1213
+ function setAttribute(el, attr, v) {
1214
+ const prev = el.getAttribute(attr);
1215
+ const exists = prev != null;
1216
+ el.setAttribute(attr, v);
1217
+ return () => {
1218
+ if (!exists) el.removeAttribute(attr);
1219
+ else el.setAttribute(attr, prev);
1220
+ };
1221
+ }
1222
+ function setProperty(el, prop, v) {
1223
+ const exists = prop in el;
1224
+ const prev = el[prop];
1225
+ el[prop] = v;
1226
+ return () => {
1227
+ if (!exists) delete el[prop];
1228
+ else el[prop] = prev;
1229
+ };
1230
+ }
1231
+ function setStyle(el, style) {
1232
+ if (!el) return noop;
1233
+ const prev = Object.keys(style).reduce((acc, key) => {
1234
+ acc[key] = el.style.getPropertyValue(key);
1235
+ return acc;
1236
+ }, {});
1237
+ Object.assign(el.style, style);
1238
+ return () => {
1239
+ Object.assign(el.style, prev);
1240
+ if (el.style.length === 0) el.removeAttribute("style");
1241
+ };
1242
+ }
1243
+ function setStyleProperty(el, prop, value) {
1244
+ if (!el) return noop;
1245
+ const prev = el.style.getPropertyValue(prop);
1246
+ el.style.setProperty(prop, value);
1247
+ return () => {
1248
+ el.style.setProperty(prop, prev);
1249
+ if (el.style.length === 0) el.removeAttribute("style");
1250
+ };
1251
+ }
1252
+
1253
+ //#endregion
1254
+ //#region src/shared/dom-query/typeahead.ts
1255
+ function getByTypeaheadImpl(baseItems, options) {
1256
+ const { state: state$1, activeId, key, timeout = 350, itemToId } = options;
1257
+ const search = state$1.keysSoFar + key;
1258
+ const query$1 = search.length > 1 && Array.from(search).every((char) => char === search[0]) ? search[0] : search;
1259
+ const next = getByText(baseItems.slice(), query$1, activeId, itemToId);
1260
+ function cleanup() {
1261
+ clearTimeout(state$1.timer);
1262
+ state$1.timer = -1;
1263
+ }
1264
+ function update(value) {
1265
+ state$1.keysSoFar = value;
1266
+ cleanup();
1267
+ if (value !== "") state$1.timer = +setTimeout(() => {
1268
+ update("");
1269
+ cleanup();
1270
+ }, timeout);
1271
+ }
1272
+ update(search);
1273
+ return next;
1274
+ }
1275
+ const getByTypeahead = Object.assign(getByTypeaheadImpl, {
1276
+ defaultOptions: {
1277
+ keysSoFar: "",
1278
+ timer: -1
1279
+ },
1280
+ isValidEvent: isValidTypeaheadEvent
1281
+ });
1282
+ function isValidTypeaheadEvent(event) {
1283
+ return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
1284
+ }
1285
+
1286
+ //#endregion
1287
+ //#region src/shared/dom-query/visual-viewport.ts
1288
+ function trackVisualViewport(doc, fn) {
1289
+ const win = doc?.defaultView || window;
1290
+ const onResize = () => {
1291
+ fn?.(getViewportSize(win));
1292
+ };
1293
+ onResize();
1294
+ return addDomEvent(win.visualViewport ?? win, "resize", onResize);
1295
+ }
1296
+ function getViewportSize(win) {
1297
+ return {
1298
+ width: win.visualViewport?.width || win.innerWidth,
1299
+ height: win.visualViewport?.height || win.innerHeight
1300
+ };
1301
+ }
1302
+
1303
+ //#endregion
1304
+ //#region src/shared/dom-query/visually-hidden.ts
1305
+ const visuallyHiddenStyle = {
1306
+ border: "0",
1307
+ clip: "rect(0 0 0 0)",
1308
+ height: "1px",
1309
+ margin: "-1px",
1310
+ overflow: "hidden",
1311
+ padding: "0",
1312
+ position: "absolute",
1313
+ width: "1px",
1314
+ whiteSpace: "nowrap",
1315
+ wordWrap: "normal"
1316
+ };
1317
+ function setVisuallyHidden(el) {
1318
+ Object.assign(el.style, visuallyHiddenStyle);
1319
+ }
1320
+
1321
+ //#endregion
1322
+ //#region src/shared/dom-query/wait-for.ts
1323
+ function waitForPromise(promise, controller, timeout) {
1324
+ const { signal } = controller;
1325
+ const wrappedPromise = new Promise((resolve, reject) => {
1326
+ const timeoutId = setTimeout(() => {
1327
+ reject(/* @__PURE__ */ new Error(`Timeout of ${timeout}ms exceeded`));
1328
+ }, timeout);
1329
+ signal.addEventListener("abort", () => {
1330
+ clearTimeout(timeoutId);
1331
+ reject(/* @__PURE__ */ new Error("Promise aborted"));
1332
+ });
1333
+ promise.then((result) => {
1334
+ if (!signal.aborted) {
1335
+ clearTimeout(timeoutId);
1336
+ resolve(result);
1337
+ }
1338
+ }).catch((error) => {
1339
+ if (!signal.aborted) {
1340
+ clearTimeout(timeoutId);
1341
+ reject(error);
1342
+ }
1343
+ });
1344
+ });
1345
+ const abort = () => controller.abort();
1346
+ return [wrappedPromise, abort];
1347
+ }
1348
+ function waitForElement(target, options) {
1349
+ const { timeout, rootNode } = options;
1350
+ const win = getWindow(rootNode);
1351
+ const doc = getDocument(rootNode);
1352
+ const controller = new win.AbortController();
1353
+ return waitForPromise(new Promise((resolve) => {
1354
+ const el = target();
1355
+ if (el) {
1356
+ resolve(el);
1357
+ return;
1358
+ }
1359
+ const observer = new win.MutationObserver(() => {
1360
+ const el$1 = target();
1361
+ if (el$1 && el$1.isConnected) {
1362
+ observer.disconnect();
1363
+ resolve(el$1);
1364
+ }
1365
+ });
1366
+ observer.observe(doc.body, {
1367
+ childList: true,
1368
+ subtree: true
1369
+ });
1370
+ }), controller, timeout);
1371
+ }
1372
+
1373
+ //#endregion
1374
+ export { getTabbables as $, getDocumentElement as $t, getNearestOverflowAncestor as A, isApple as At, AnimationFrame as B, isWebKit as Bt, proxyTabFocus as C, isSelfTarget as Ct, restoreTextSelection as D, getPlatform as Dt, disableTextSelection as E, isVirtualPointerEvent as Et, scrollIntoView as F, isIPhone as Ft, isValidTabEvent as G, isControlledByExpandedController as Gt, queueBeforeEvent as H, findControlledElements as Ht, clickIfLink as I, isIos as It, getFocusables as J, isInteractiveContainerElement as Jt, getFirstFocusable as K, isControlledElement as Kt, navigate as L, isMac as Lt, getScrollPosition as M, isDom as Mt, isInView as N, isFirefox as Nt, requestPointerLock as O, getUserAgent as Ot, isOverflowElement as P, isIPad as Pt, getTabbableEdges as Q, getDocument as Qt, observeAttributes as R, isSafari as Rt, queryAll as S, isPrintableKey as St, trackPointerMove as T, isVirtualClick as Tt, raf as U, getControlledElements as Ut, nextTick as V, getDataUrl as Vt, getInitialFocus as W, hasControllerElements as Wt, getNextTabbable as X, contains as Xt, getLastTabbable as Y, getComputedStyle as Yt, getTabIndex as Z, getActiveElement as Zt, indexOfId as _, ariaAttr as _n, isDownloadingEvent as _t, trackVisualViewport as a, isAnchorElement as an, setElementValue as at, prevById as b, setCaretToEnd as bn, isModifierKey as bt, setProperty as c, isElementVisible as cn, getBeforeInputValue as ct, getByText as d, isNode as dn, getEventStep as dt, getNodeName as en, isFocusable as et, createScope as f, isRootElement as fn, getEventTarget as ft, defaultItemToId as g, MAX_Z_INDEX as gn, isCtrlOrMetaKey as gt, resizeObserverDevicePixelContentBox as h, isWindow as hn, isContextMenuEvent as ht, visuallyHiddenStyle as i, isActiveElement as in, setElementChecked as it, getOverflowAncestors as j, isChrome as jt, getRelativePoint as k, isAndroid as kt, setStyle as l, isHTMLElement as ln, getEventKey as lt, resizeObserverContentBox as m, isVisualViewport as mn, isComposingEvent as mt, waitForPromise as n, getRootNode as nn, dispatchInputCheckedEvent as nt, getByTypeahead as o, isDocument as on, trackFormControl as ot, resizeObserverBorderBox as p, isShadowRoot as pn, getNativeEvent as pt, getFirstTabbable as q, isControllerElement as qt, setVisuallyHidden as r, getWindow as rn, dispatchInputValueEvent as rt, setAttribute as s, isEditableElement as sn, addDomEvent as st, waitForElement as t, getParentNode as tn, isTabbable as tt, setStyleProperty as u, isInputElement as un, getEventPoint as ut, itemById as v, dataAttr as vn, isKeyboardClick as vt, trackPress as w, isTouchEvent as wt, query as x, isOpeningInNewTab as xt, nextById as y, isCaretAtStart as yn, isLeftClick as yt, observeChildren as z, isTouchDevice as zt };