@editora/ui-core 0.1.20 → 0.1.22

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 (290) hide show
  1. package/dist/accordion.cjs.js +3 -3
  2. package/dist/accordion.esm.js +3 -3
  3. package/dist/alert-dialog.cjs.js +32 -32
  4. package/dist/alert-dialog.esm.js +95 -75
  5. package/dist/alert.cjs.js +6 -6
  6. package/dist/alert.esm.js +6 -6
  7. package/dist/animated-list.cjs.js +4 -4
  8. package/dist/animated-list.esm.js +4 -4
  9. package/dist/animated-text.cjs.js +4 -4
  10. package/dist/animated-text.esm.js +4 -4
  11. package/dist/app-header.cjs.js +3 -3
  12. package/dist/app-header.esm.js +3 -3
  13. package/dist/aspect-ratio.cjs.js +3 -3
  14. package/dist/aspect-ratio.esm.js +3 -3
  15. package/dist/avatar.cjs.js +14 -14
  16. package/dist/avatar.esm.js +31 -29
  17. package/dist/badge.cjs.js +4 -4
  18. package/dist/badge.esm.js +4 -4
  19. package/dist/block-controls.cjs.js +4 -4
  20. package/dist/block-controls.esm.js +4 -4
  21. package/dist/box.cjs.js +2 -2
  22. package/dist/box.esm.js +2 -2
  23. package/dist/breadcrumb.cjs.js +5 -5
  24. package/dist/breadcrumb.esm.js +5 -5
  25. package/dist/button.cjs.js +1 -1
  26. package/dist/button.esm.js +1 -1
  27. package/dist/{calendar-DLY4acgn.mjs → calendar-DbxYRdlv.mjs} +227 -183
  28. package/dist/{calendar-Dkof-FTK.js → calendar-Qa-cFOp3.js} +74 -35
  29. package/dist/calendar.cjs.js +1 -1
  30. package/dist/calendar.esm.js +1 -1
  31. package/dist/card.cjs.js +8 -8
  32. package/dist/card.esm.js +63 -20
  33. package/dist/chart.cjs.js +4 -4
  34. package/dist/chart.esm.js +6 -6
  35. package/dist/checkbox.cjs.js +2 -2
  36. package/dist/checkbox.esm.js +2 -2
  37. package/dist/collapsible.cjs.js +7 -7
  38. package/dist/collapsible.esm.js +7 -7
  39. package/dist/collection.cjs.js +1 -1
  40. package/dist/collection.esm.js +27 -23
  41. package/dist/color-picker.cjs.js +34 -14
  42. package/dist/color-picker.esm.js +89 -67
  43. package/dist/combobox.cjs.js +29 -27
  44. package/dist/combobox.esm.js +51 -45
  45. package/dist/command.cjs.js +2 -2
  46. package/dist/command.esm.js +2 -2
  47. package/dist/components/ui-alert-dialog.d.ts +1 -0
  48. package/dist/components/ui-alert-dialog.d.ts.map +1 -1
  49. package/dist/components/ui-avatar.d.ts +1 -0
  50. package/dist/components/ui-avatar.d.ts.map +1 -1
  51. package/dist/components/ui-button.d.ts +1 -0
  52. package/dist/components/ui-button.d.ts.map +1 -1
  53. package/dist/components/ui-calendar.d.ts.map +1 -1
  54. package/dist/components/ui-card.d.ts +3 -0
  55. package/dist/components/ui-card.d.ts.map +1 -1
  56. package/dist/components/ui-checkbox.d.ts.map +1 -1
  57. package/dist/components/ui-collection.d.ts.map +1 -1
  58. package/dist/components/ui-color-picker.d.ts.map +1 -1
  59. package/dist/components/ui-combobox.d.ts.map +1 -1
  60. package/dist/components/ui-data-table.d.ts.map +1 -1
  61. package/dist/components/ui-date-field.d.ts.map +1 -1
  62. package/dist/components/ui-date-picker.d.ts.map +1 -1
  63. package/dist/components/ui-date-range-picker.d.ts.map +1 -1
  64. package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
  65. package/dist/components/ui-date-time-picker.d.ts.map +1 -1
  66. package/dist/components/ui-dock.d.ts +1 -0
  67. package/dist/components/ui-dock.d.ts.map +1 -1
  68. package/dist/components/ui-drawer.d.ts.map +1 -1
  69. package/dist/components/ui-dropdown.d.ts.map +1 -1
  70. package/dist/components/ui-field.d.ts.map +1 -1
  71. package/dist/components/ui-file-upload.d.ts.map +1 -1
  72. package/dist/components/ui-gantt.d.ts.map +1 -1
  73. package/dist/components/ui-input.d.ts.map +1 -1
  74. package/dist/components/ui-menu.d.ts.map +1 -1
  75. package/dist/components/ui-multi-select.d.ts.map +1 -1
  76. package/dist/components/ui-number-field.d.ts.map +1 -1
  77. package/dist/components/ui-password-field.d.ts.map +1 -1
  78. package/dist/components/ui-pin-input.d.ts +1 -0
  79. package/dist/components/ui-pin-input.d.ts.map +1 -1
  80. package/dist/components/ui-placement-grid.d.ts.map +1 -1
  81. package/dist/components/ui-portal.d.ts.map +1 -1
  82. package/dist/components/ui-positioner.d.ts.map +1 -1
  83. package/dist/components/ui-progress.d.ts.map +1 -1
  84. package/dist/components/ui-radio.d.ts.map +1 -1
  85. package/dist/components/ui-rating.d.ts +1 -0
  86. package/dist/components/ui-rating.d.ts.map +1 -1
  87. package/dist/components/ui-select.d.ts.map +1 -1
  88. package/dist/components/ui-sortable.d.ts +8 -0
  89. package/dist/components/ui-sortable.d.ts.map +1 -1
  90. package/dist/components/ui-switch.d.ts.map +1 -1
  91. package/dist/components/ui-table.d.ts.map +1 -1
  92. package/dist/components/ui-tabs.d.ts +1 -0
  93. package/dist/components/ui-tabs.d.ts.map +1 -1
  94. package/dist/components/ui-tags-input.d.ts +1 -0
  95. package/dist/components/ui-tags-input.d.ts.map +1 -1
  96. package/dist/components/ui-textarea.d.ts.map +1 -1
  97. package/dist/components/ui-time-field.d.ts.map +1 -1
  98. package/dist/components/ui-toggle-group.d.ts.map +1 -1
  99. package/dist/components/ui-toggle.d.ts.map +1 -1
  100. package/dist/components/ui-tree.d.ts.map +1 -1
  101. package/dist/components/ui-wizard.d.ts.map +1 -1
  102. package/dist/context-menu.cjs.js +3 -3
  103. package/dist/context-menu.esm.js +4 -4
  104. package/dist/control-name-BmoI1m3a.js +1 -0
  105. package/dist/control-name-Bpj7F34X.mjs +48 -0
  106. package/dist/data-table.cjs.js +5 -2
  107. package/dist/data-table.esm.js +145 -142
  108. package/dist/date-field.cjs.js +5 -5
  109. package/dist/date-field.esm.js +34 -31
  110. package/dist/date-picker.cjs.js +16 -16
  111. package/dist/date-picker.esm.js +48 -44
  112. package/dist/date-range-picker.cjs.js +5 -5
  113. package/dist/date-range-picker.esm.js +120 -118
  114. package/dist/date-range-time-picker.cjs.js +22 -22
  115. package/dist/date-range-time-picker.esm.js +88 -84
  116. package/dist/date-time-picker.cjs.js +26 -26
  117. package/dist/date-time-picker.esm.js +105 -101
  118. package/dist/{date-time-utils-Dmost5Ee.js → date-time-utils-BzfTpeU-.js} +1 -1
  119. package/dist/{date-time-utils-y1N2gvG2.mjs → date-time-utils-Cps2aSu2.mjs} +1 -1
  120. package/dist/description.cjs.js +3 -3
  121. package/dist/description.esm.js +3 -3
  122. package/dist/dialog.cjs.js +2 -2
  123. package/dist/dialog.esm.js +2 -2
  124. package/dist/dock.cjs.js +12 -12
  125. package/dist/dock.esm.js +72 -74
  126. package/dist/drawer.cjs.js +19 -19
  127. package/dist/drawer.esm.js +58 -58
  128. package/dist/dropdown.cjs.js +13 -13
  129. package/dist/dropdown.esm.js +49 -48
  130. package/dist/empty-state.cjs.js +3 -3
  131. package/dist/empty-state.esm.js +3 -3
  132. package/dist/field-error.cjs.js +1 -1
  133. package/dist/field-error.esm.js +1 -1
  134. package/dist/field.cjs.js +12 -12
  135. package/dist/field.esm.js +84 -75
  136. package/dist/fieldset.cjs.js +4 -4
  137. package/dist/fieldset.esm.js +4 -4
  138. package/dist/file-upload.cjs.js +3 -3
  139. package/dist/file-upload.esm.js +5 -3
  140. package/dist/floating-toolbar.cjs.js +8 -8
  141. package/dist/floating-toolbar.esm.js +9 -9
  142. package/dist/form.cjs.js +11 -11
  143. package/dist/form.esm.js +11 -11
  144. package/dist/gantt.cjs.js +43 -32
  145. package/dist/gantt.esm.js +99 -88
  146. package/dist/icon-cloud.cjs.js +3 -3
  147. package/dist/icon-cloud.esm.js +3 -3
  148. package/dist/icon.cjs.js +1 -1
  149. package/dist/icon.esm.js +1 -1
  150. package/dist/index.cjs.js +1 -1
  151. package/dist/index.esm.js +121 -118
  152. package/dist/inline-edit.cjs.js +1 -1
  153. package/dist/inline-edit.esm.js +1 -1
  154. package/dist/input.cjs.js +14 -14
  155. package/dist/input.esm.js +39 -32
  156. package/dist/label.cjs.js +3 -3
  157. package/dist/label.esm.js +3 -3
  158. package/dist/{listbox-B6QgECax.js → listbox-CTpRpuF7.js} +1 -1
  159. package/dist/{listbox-DJamVeFj.mjs → listbox-hMVOhKHC.mjs} +1 -1
  160. package/dist/listbox.cjs.js +1 -1
  161. package/dist/listbox.esm.js +1 -1
  162. package/dist/marquee.cjs.js +3 -3
  163. package/dist/marquee.esm.js +3 -3
  164. package/dist/{menu-item-styles-CbNUEwP2.js → menu-item-styles-B4onAr4C.js} +3 -3
  165. package/dist/{menu-item-styles-CZiPwPwl.mjs → menu-item-styles-IGSFLAHu.mjs} +3 -3
  166. package/dist/menu.cjs.js +7 -7
  167. package/dist/menu.esm.js +29 -28
  168. package/dist/menubar.cjs.js +1 -1
  169. package/dist/menubar.esm.js +2 -2
  170. package/dist/meter.cjs.js +1 -1
  171. package/dist/meter.esm.js +1 -1
  172. package/dist/multi-select.cjs.js +18 -18
  173. package/dist/multi-select.esm.js +82 -66
  174. package/dist/navigation-menu.cjs.js +1 -1
  175. package/dist/navigation-menu.esm.js +1 -1
  176. package/dist/number-field.cjs.js +11 -13
  177. package/dist/number-field.esm.js +29 -27
  178. package/dist/number-ticker.cjs.js +4 -4
  179. package/dist/number-ticker.esm.js +4 -4
  180. package/dist/odometer.cjs.js +2 -2
  181. package/dist/odometer.esm.js +2 -2
  182. package/dist/orbiter.cjs.js +3 -3
  183. package/dist/orbiter.esm.js +3 -3
  184. package/dist/pagination.cjs.js +1 -1
  185. package/dist/pagination.esm.js +1 -1
  186. package/dist/password-field.cjs.js +23 -23
  187. package/dist/password-field.esm.js +48 -47
  188. package/dist/pin-input.cjs.js +8 -6
  189. package/dist/pin-input.esm.js +21 -15
  190. package/dist/placement-grid.cjs.js +4 -4
  191. package/dist/placement-grid.esm.js +58 -58
  192. package/dist/plugin-panel.cjs.js +1 -1
  193. package/dist/plugin-panel.esm.js +1 -1
  194. package/dist/popover.cjs.js +5 -5
  195. package/dist/popover.esm.js +4 -4
  196. package/dist/portal.cjs.js +3 -3
  197. package/dist/portal.esm.js +11 -10
  198. package/dist/positioner.cjs.js +2 -2
  199. package/dist/positioner.esm.js +15 -14
  200. package/dist/primitives/auto-scroll.d.ts +9 -0
  201. package/dist/primitives/auto-scroll.d.ts.map +1 -0
  202. package/dist/primitives/control-name.d.ts +30 -0
  203. package/dist/primitives/control-name.d.ts.map +1 -0
  204. package/dist/primitives/selector.d.ts +4 -0
  205. package/dist/primitives/selector.d.ts.map +1 -0
  206. package/dist/primitives/trigger.d.ts +2 -0
  207. package/dist/primitives/trigger.d.ts.map +1 -0
  208. package/dist/progress.cjs.js +4 -4
  209. package/dist/progress.esm.js +20 -18
  210. package/dist/quick-actions.cjs.js +3 -3
  211. package/dist/quick-actions.esm.js +3 -3
  212. package/dist/radio-group.cjs.js +1 -1
  213. package/dist/radio-group.esm.js +1 -1
  214. package/dist/radio.cjs.js +2 -2
  215. package/dist/radio.esm.js +2 -2
  216. package/dist/rating.cjs.js +17 -16
  217. package/dist/rating.esm.js +91 -92
  218. package/dist/{runtime-D1gFh1fS.mjs → runtime-CFnK53iC.mjs} +133 -94
  219. package/dist/runtime-DwE-tizc.js +1 -0
  220. package/dist/runtime.cjs.js +1 -1
  221. package/dist/runtime.d.ts +1 -1
  222. package/dist/runtime.d.ts.map +1 -1
  223. package/dist/runtime.esm.js +29 -26
  224. package/dist/select.cjs.js +20 -19
  225. package/dist/select.esm.js +36 -32
  226. package/dist/selection-popup.cjs.js +2 -2
  227. package/dist/selection-popup.esm.js +2 -2
  228. package/dist/selector-BvAh35ve.js +1 -0
  229. package/dist/selector-WI8pD7YO.mjs +18 -0
  230. package/dist/separator.cjs.js +7 -7
  231. package/dist/separator.esm.js +7 -7
  232. package/dist/sidebar.cjs.js +7 -7
  233. package/dist/sidebar.esm.js +7 -7
  234. package/dist/skeleton.cjs.js +7 -7
  235. package/dist/skeleton.esm.js +7 -7
  236. package/dist/slider.cjs.js +3 -3
  237. package/dist/slider.esm.js +3 -3
  238. package/dist/slot.cjs.js +3 -3
  239. package/dist/slot.esm.js +3 -3
  240. package/dist/sortable.cjs.js +61 -48
  241. package/dist/sortable.esm.js +636 -554
  242. package/dist/spinning-text.cjs.js +3 -3
  243. package/dist/spinning-text.esm.js +3 -3
  244. package/dist/split-button.cjs.js +1 -1
  245. package/dist/split-button.esm.js +1 -1
  246. package/dist/stepper.cjs.js +1 -1
  247. package/dist/stepper.esm.js +1 -1
  248. package/dist/switch.cjs.js +10 -12
  249. package/dist/switch.esm.js +10 -12
  250. package/dist/table.cjs.js +9 -6
  251. package/dist/table.esm.js +46 -43
  252. package/dist/tabs.cjs.js +22 -23
  253. package/dist/tabs.esm.js +116 -112
  254. package/dist/tags-input.cjs.js +9 -9
  255. package/dist/tags-input.esm.js +32 -25
  256. package/dist/textarea.cjs.js +13 -13
  257. package/dist/textarea.esm.js +46 -31
  258. package/dist/theme.d.ts +18 -0
  259. package/dist/theme.d.ts.map +1 -1
  260. package/dist/time-field.cjs.js +5 -5
  261. package/dist/time-field.esm.js +21 -18
  262. package/dist/time-picker.cjs.js +4 -4
  263. package/dist/time-picker.esm.js +5 -5
  264. package/dist/timeline.cjs.js +2 -2
  265. package/dist/timeline.esm.js +4 -4
  266. package/dist/toast.cjs.js +6 -6
  267. package/dist/toast.esm.js +13 -13
  268. package/dist/toggle-group.cjs.js +5 -6
  269. package/dist/toggle-group.esm.js +63 -60
  270. package/dist/toggle.cjs.js +18 -18
  271. package/dist/toggle.esm.js +32 -31
  272. package/dist/tooltip.cjs.js +4 -4
  273. package/dist/tooltip.esm.js +4 -4
  274. package/dist/transfer-list.cjs.js +32 -32
  275. package/dist/transfer-list.esm.js +57 -57
  276. package/dist/tree-7qbVnpGp.js +39 -0
  277. package/dist/{tree-B3kE8ESs.mjs → tree-Deoft-kO.mjs} +34 -33
  278. package/dist/tree.cjs.js +1 -1
  279. package/dist/tree.esm.js +1 -1
  280. package/dist/trigger-BjnxLCeQ.mjs +9 -0
  281. package/dist/trigger-DkPsKxsP.js +1 -0
  282. package/dist/{ui-button-rXQOS9QJ.js → ui-button-BInsgSbr.js} +27 -26
  283. package/dist/{ui-button-Q0GNNWKC.mjs → ui-button-rfiuUnUD.mjs} +65 -48
  284. package/dist/{ui-icon-YI6lyuqU.mjs → ui-icon-BSi_GtqO.mjs} +2 -2
  285. package/dist/{ui-icon-BzVNC_lr.js → ui-icon-Bvt9oIIR.js} +5 -5
  286. package/dist/wizard.cjs.js +12 -13
  287. package/dist/wizard.esm.js +17 -15
  288. package/package.json +1 -1
  289. package/dist/runtime-CTaOSmBj.js +0 -1
  290. package/dist/tree-Dx_kv_ih.js +0 -39
@@ -1,12 +1,28 @@
1
1
  import { E as ee } from "./ElementBase-YlTLMsGk.mjs";
2
- const te = 1, re = 44, ie = 72, se = `
2
+ function te(l, e, t, r = 56, i = 18) {
3
+ if (!Number.isFinite(l) || !(t > e)) return 0;
4
+ const s = Math.min(r, (t - e) / 2);
5
+ return s <= 0 ? 0 : l < e + s ? -Math.ceil(i * Math.min(1, (e + s - l) / s)) : l > t - s ? Math.ceil(i * Math.min(1, (l - (t - s)) / s)) : 0;
6
+ }
7
+ const re = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
8
+ function ie(l) {
9
+ let e = l;
10
+ for (; e; ) {
11
+ if (e = e.parentNode instanceof ShadowRoot ? e.parentNode.host : e.parentNode, !(e instanceof HTMLElement)) continue;
12
+ if (e === e.ownerDocument.body || e === e.ownerDocument.documentElement) return null;
13
+ const { overflowY: t } = e.ownerDocument.defaultView?.getComputedStyle(e) ?? { overflowY: "" };
14
+ if (re.has(t) && e.scrollHeight > e.clientHeight) return e;
15
+ }
16
+ return null;
17
+ }
18
+ const se = 1, oe = 44, ne = 72, ae = `
3
19
  :host {
4
20
  --ui-sortable-accent: var(--ui-color-primary, #2563eb);
5
21
  --ui-sortable-surface: var(--ui-color-surface, #ffffff);
6
22
  --ui-sortable-surface-muted: color-mix(in srgb, var(--ui-sortable-surface) 92%, #eff6ff);
7
23
  --ui-sortable-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 76%, transparent);
8
24
  --ui-sortable-text: var(--ui-color-text, #0f172a);
9
- --ui-sortable-muted: var(--ui-color-muted, #64748b);
25
+ --ui-sortable-muted: var(--ui-color-muted, #526175);
10
26
  --ui-sortable-shadow:
11
27
  0 1px 3px rgba(15, 23, 42, 0.06),
12
28
  0 16px 34px rgba(15, 23, 42, 0.08);
@@ -103,6 +119,20 @@ const te = 1, re = 44, ie = 72, se = `
103
119
  align-items: stretch;
104
120
  }
105
121
 
122
+ /* The cards live inside one root .tree wrapper, which is a vertical grid. Without this the
123
+ lane was a flex row holding a single column, so a "horizontal" list rendered vertically. */
124
+ .list[data-orientation="horizontal"] .items > .tree {
125
+ display: flex;
126
+ flex-wrap: nowrap;
127
+ align-items: stretch;
128
+ min-inline-size: min-content;
129
+ }
130
+
131
+ .list[data-orientation="horizontal"] .items > .tree > .item-shell {
132
+ flex: 0 0 auto;
133
+ min-inline-size: min(220px, 70vw);
134
+ }
135
+
106
136
  .list[data-disabled="true"] {
107
137
  opacity: 0.68;
108
138
  }
@@ -722,7 +752,7 @@ const te = 1, re = 44, ie = 72, se = `
722
752
  }
723
753
  }
724
754
  `;
725
- function V(l) {
755
+ function K(l) {
726
756
  if (!l) return [];
727
757
  try {
728
758
  const e = JSON.parse(l);
@@ -734,7 +764,7 @@ function V(l) {
734
764
  function I(l) {
735
765
  return l.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
736
766
  }
737
- function D(l, e) {
767
+ function k(l, e) {
738
768
  return `${l}::${e ?? "__root__"}`;
739
769
  }
740
770
  function j(l) {
@@ -743,98 +773,98 @@ function j(l) {
743
773
  function B(l, e) {
744
774
  return j(l) === j(e);
745
775
  }
746
- function oe(l) {
776
+ function le(l) {
747
777
  if (!l || l === "none")
748
778
  return { x: 1, y: 1 };
749
779
  const e = l.match(/^matrix3d\((.+)\)$/);
750
780
  if (e) {
751
- const t = e[1].split(",").map((i) => Number.parseFloat(i.trim()));
752
- if (t.length === 16 && t.every((i) => Number.isFinite(i)))
781
+ const r = e[1].split(",").map((i) => Number.parseFloat(i.trim()));
782
+ if (r.length === 16 && r.every((i) => Number.isFinite(i)))
753
783
  return {
754
- x: t[0] || 1,
755
- y: t[5] || 1
784
+ x: r[0] || 1,
785
+ y: r[5] || 1
756
786
  };
757
787
  }
758
- const r = l.match(/^matrix\((.+)\)$/);
759
- if (r) {
760
- const t = r[1].split(",").map((i) => Number.parseFloat(i.trim()));
761
- if (t.length === 6 && t.every((i) => Number.isFinite(i))) {
762
- const [i, s, a, n] = t;
788
+ const t = l.match(/^matrix\((.+)\)$/);
789
+ if (t) {
790
+ const r = t[1].split(",").map((i) => Number.parseFloat(i.trim()));
791
+ if (r.length === 6 && r.every((i) => Number.isFinite(i))) {
792
+ const [i, s, n, a] = r;
763
793
  return {
764
794
  x: Math.sqrt(i * i + s * s) || 1,
765
- y: Math.sqrt(a * a + n * n) || 1
795
+ y: Math.sqrt(n * n + a * a) || 1
766
796
  };
767
797
  }
768
798
  }
769
799
  return { x: 1, y: 1 };
770
800
  }
771
- function ne(l) {
801
+ function de(l) {
772
802
  return l === "item" ? "item" : "handle";
773
803
  }
774
- function A(l) {
804
+ function P(l) {
775
805
  return { ...l };
776
806
  }
777
- function ae(l, e, r, t, i, s) {
778
- const a = P(l), n = $(l), d = /* @__PURE__ */ new Set(), o = [], u = (g) => {
779
- const S = a.get(g);
780
- !S || d.has(g) || (d.add(g), o.push(g), (n.get(D(S.listId, g)) || []).forEach(u));
807
+ function ce(l, e, t, r, i, s) {
808
+ const n = T(l), a = E(l), d = /* @__PURE__ */ new Set(), o = [], u = (g) => {
809
+ const x = n.get(g);
810
+ !x || d.has(g) || (d.add(g), o.push(g), (a.get(k(x.listId, g)) || []).forEach(u));
781
811
  };
782
- t.forEach(u);
783
- const p = l.map(A), m = p.filter((g) => d.has(g.id)), _ = i ? p.map(A) : p.filter((g) => !d.has(g.id)), f = i ? m.map((g) => s(g, o)) : m.map(A), v = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
784
- i && m.forEach((g, S) => {
785
- v.set(g.id, f[S].id), b.set(f[S].id, g.id);
786
- }), f.forEach((g) => {
787
- const S = i ? b.get(g.id) : g.id, T = S ? a.get(S) : null;
788
- T && (i && (g.parentId = T.parentId && v.has(T.parentId) && v.get(T.parentId) || null), g.listId = r.listId);
812
+ r.forEach(u);
813
+ const c = l.map(P), h = c.filter((g) => d.has(g.id)), _ = i ? c.map(P) : c.filter((g) => !d.has(g.id)), b = i ? h.map((g) => s(g, o)) : h.map(P), S = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
814
+ i && h.forEach((g, x) => {
815
+ S.set(g.id, b[x].id), m.set(b[x].id, g.id);
816
+ }), b.forEach((g) => {
817
+ const x = i ? m.get(g.id) : g.id, M = x ? n.get(x) : null;
818
+ M && (i && (g.parentId = M.parentId && S.has(M.parentId) && S.get(M.parentId) || null), g.listId = t.listId);
789
819
  });
790
- const y = t.map((g) => v.get(g) || g), x = [..._, ...f], z = $(_), k = D(r.listId, r.parentId), h = [...z.get(k) || []], E = r.beforeId ? h.indexOf(r.beforeId) : h.length, H = E >= 0 ? E : h.length;
791
- h.splice(H, 0, ...y), z.set(k, h), $(f).forEach((g, S) => {
792
- const [, T] = S.split("::");
793
- (T || "") !== "__root__" && z.set(S, [...g]);
820
+ const v = r.map((g) => S.get(g) || g), D = [..._, ...b], A = E(_), z = k(t.listId, t.parentId), f = [...A.get(z) || []], y = t.beforeId ? f.indexOf(t.beforeId) : f.length, R = y >= 0 ? y : f.length;
821
+ f.splice(R, 0, ...v), A.set(z, f), E(b).forEach((g, x) => {
822
+ const [, M] = x.split("::");
823
+ (M || "") !== "__root__" && A.set(x, [...g]);
794
824
  });
795
- const F = P(x);
796
- y.forEach((g) => {
797
- const S = F.get(g);
798
- S && (S.parentId = r.parentId, S.listId = r.listId);
825
+ const O = T(D);
826
+ v.forEach((g) => {
827
+ const x = O.get(g);
828
+ x && (x.parentId = t.parentId, x.listId = t.listId);
799
829
  });
800
- const M = [], O = /* @__PURE__ */ new Set(), q = (g, S) => {
801
- (z.get(D(g, S)) || []).forEach((R, K) => {
802
- const c = F.get(R);
803
- !c || O.has(R) || (O.add(R), c.listId = g, c.parentId = S, c.order = K, M.push(c), q(g, R));
830
+ const L = [], q = /* @__PURE__ */ new Set(), H = (g, x) => {
831
+ (A.get(k(g, x)) || []).forEach((C, G) => {
832
+ const p = O.get(C);
833
+ !p || q.has(C) || (q.add(C), p.listId = g, p.parentId = x, p.order = G, L.push(p), H(g, C));
804
834
  });
805
835
  };
806
- return e.forEach((g) => q(g.id, null)), x.forEach((g) => {
807
- O.has(g.id) || (g.parentId = null, M.push(g));
836
+ return e.forEach((g) => H(g.id, null)), D.forEach((g) => {
837
+ q.has(g.id) || (g.parentId = null, L.push(g));
808
838
  }), {
809
- items: M.map(A),
810
- insertedRootIds: y
839
+ items: L.map(P),
840
+ insertedRootIds: v
811
841
  };
812
842
  }
813
- function $(l) {
843
+ function E(l) {
814
844
  const e = /* @__PURE__ */ new Map();
815
- return l.forEach((r) => {
816
- const t = D(r.listId, r.parentId), i = e.get(t);
817
- i ? i.push(r.id) : e.set(t, [r.id]);
845
+ return l.forEach((t) => {
846
+ const r = k(t.listId, t.parentId), i = e.get(r);
847
+ i ? i.push(t.id) : e.set(r, [t.id]);
818
848
  }), e;
819
849
  }
820
- function P(l) {
850
+ function T(l) {
821
851
  return new Map(l.map((e) => [e.id, e]));
822
852
  }
823
- function X(l) {
824
- const e = /* @__PURE__ */ new Set(), r = [];
825
- return l.forEach((t, i) => {
826
- const s = typeof t?.id == "string" && t.id.trim() ? t.id.trim() : `list-${i + 1}`;
827
- e.has(s) || (e.add(s), r.push({
853
+ function Y(l) {
854
+ const e = /* @__PURE__ */ new Set(), t = [];
855
+ return l.forEach((r, i) => {
856
+ const s = typeof r?.id == "string" && r.id.trim() ? r.id.trim() : `list-${i + 1}`;
857
+ e.has(s) || (e.add(s), t.push({
828
858
  id: s,
829
- label: typeof t?.label == "string" && t.label.trim() ? t.label.trim() : `List ${i + 1}`,
830
- description: typeof t?.description == "string" ? t.description : "",
831
- emptyLabel: typeof t?.emptyLabel == "string" && t.emptyLabel.trim() ? t.emptyLabel.trim() : "Drop items here.",
832
- orientation: t?.orientation === "horizontal" ? "horizontal" : "vertical",
833
- disabled: !!t?.disabled,
834
- cloneOnDrag: !!t?.cloneOnDrag,
835
- accepts: Array.isArray(t?.accepts) ? t.accepts.filter((a) => typeof a == "string" && a.trim().length > 0) : void 0
859
+ label: typeof r?.label == "string" && r.label.trim() ? r.label.trim() : `List ${i + 1}`,
860
+ description: typeof r?.description == "string" ? r.description : "",
861
+ emptyLabel: typeof r?.emptyLabel == "string" && r.emptyLabel.trim() ? r.emptyLabel.trim() : "Drop items here.",
862
+ orientation: r?.orientation === "horizontal" ? "horizontal" : "vertical",
863
+ disabled: !!r?.disabled,
864
+ cloneOnDrag: !!r?.cloneOnDrag,
865
+ accepts: Array.isArray(r?.accepts) ? r.accepts.filter((n) => typeof n == "string" && n.trim().length > 0) : void 0
836
866
  }));
837
- }), r.length ? r : [{
867
+ }), t.length ? t : [{
838
868
  id: "default",
839
869
  label: "Items",
840
870
  description: "",
@@ -844,15 +874,15 @@ function X(l) {
844
874
  cloneOnDrag: !1
845
875
  }];
846
876
  }
847
- function Y(l, e) {
848
- const r = new Set(l.map((o) => o.id)), t = [];
877
+ function U(l, e) {
878
+ const t = new Set(l.map((o) => o.id)), r = [];
849
879
  e.forEach((o, u) => {
850
- const p = typeof o?.id == "string" && o.id.trim() ? o.id.trim() : "", m = typeof o?.label == "string" && o.label.trim() ? o.label.trim() : "";
851
- if (!p || !m) return;
852
- const _ = typeof o?.listId == "string" && r.has(o.listId) ? o.listId : l[0].id;
853
- t.push({
854
- id: p,
855
- label: m,
880
+ const c = typeof o?.id == "string" && o.id.trim() ? o.id.trim() : "", h = typeof o?.label == "string" && o.label.trim() ? o.label.trim() : "";
881
+ if (!c || !h) return;
882
+ const _ = typeof o?.listId == "string" && t.has(o.listId) ? o.listId : l[0].id;
883
+ r.push({
884
+ id: c,
885
+ label: h,
856
886
  listId: _,
857
887
  parentId: typeof o?.parentId == "string" && o.parentId.trim() ? o.parentId.trim() : null,
858
888
  description: typeof o?.description == "string" ? o.description : "",
@@ -863,27 +893,27 @@ function Y(l, e) {
863
893
  hidden: !!o?.hidden
864
894
  });
865
895
  });
866
- const i = new Map(t.map((o) => [o.id, o]));
867
- t.forEach((o) => {
896
+ const i = new Map(r.map((o) => [o.id, o]));
897
+ r.forEach((o) => {
868
898
  if (!o.parentId) return;
869
899
  const u = i.get(o.parentId);
870
900
  (!u || u.id === o.id || u.listId !== o.listId) && (o.parentId = null);
871
901
  });
872
902
  const s = /* @__PURE__ */ new Map();
873
- t.forEach((o) => {
874
- const u = D(o.listId, o.parentId), p = s.get(u);
875
- p ? p.push(o) : s.set(u, [o]);
876
- }), s.forEach((o) => o.sort((u, p) => u.order - p.order || u.label.localeCompare(p.label)));
877
- const a = [], n = /* @__PURE__ */ new Set(), d = (o, u) => {
878
- (s.get(D(o, u)) || []).forEach((m, _) => {
879
- n.has(m.id) || (n.add(m.id), m.order = _, a.push(m), d(o, m.id));
903
+ r.forEach((o) => {
904
+ const u = k(o.listId, o.parentId), c = s.get(u);
905
+ c ? c.push(o) : s.set(u, [o]);
906
+ }), s.forEach((o) => o.sort((u, c) => u.order - c.order || u.label.localeCompare(c.label)));
907
+ const n = [], a = /* @__PURE__ */ new Set(), d = (o, u) => {
908
+ (s.get(k(o, u)) || []).forEach((h, _) => {
909
+ a.has(h.id) || (a.add(h.id), h.order = _, n.push(h), d(o, h.id));
880
910
  });
881
911
  };
882
- return l.forEach((o) => d(o.id, null)), t.forEach((o) => {
883
- n.has(o.id) || (o.parentId = null, a.push(o));
884
- }), a.map(A);
912
+ return l.forEach((o) => d(o.id, null)), r.forEach((o) => {
913
+ a.has(o.id) || (o.parentId = null, n.push(o));
914
+ }), n.map(P);
885
915
  }
886
- function de(l) {
916
+ function ue(l) {
887
917
  return JSON.stringify(l.map((e) => ({
888
918
  id: e.id,
889
919
  label: e.label,
@@ -897,7 +927,7 @@ function de(l) {
897
927
  hidden: e.hidden
898
928
  })));
899
929
  }
900
- function le(l) {
930
+ function pe(l) {
901
931
  return JSON.stringify(l.map((e) => ({
902
932
  id: e.id,
903
933
  label: e.label,
@@ -909,53 +939,65 @@ function le(l) {
909
939
  accepts: e.accepts
910
940
  })));
911
941
  }
912
- function U(l) {
942
+ function X(l) {
913
943
  return JSON.stringify(l);
914
944
  }
915
945
  function J(l) {
916
- const e = /* @__PURE__ */ new Map(), r = l.map((t) => {
917
- const i = D(t.listId, t.parentId), s = e.get(i) ?? 0;
946
+ const e = /* @__PURE__ */ new Map(), t = l.map((r) => {
947
+ const i = k(r.listId, r.parentId), s = e.get(i) ?? 0;
918
948
  return e.set(i, s + 1), {
919
- id: t.id,
920
- listId: t.listId,
921
- parentId: t.parentId,
949
+ id: r.id,
950
+ listId: r.listId,
951
+ parentId: r.parentId,
922
952
  index: s
923
953
  };
924
954
  });
925
955
  return {
926
- version: te,
927
- records: r
956
+ version: se,
957
+ records: t
928
958
  };
929
959
  }
930
960
  function W(l, e) {
931
961
  return e ? `${l.label} ${l.description}`.toLowerCase().includes(e.toLowerCase()) : !0;
932
962
  }
933
- function Q(l, e, r, t, i) {
934
- const s = P(l), a = $(l), n = /* @__PURE__ */ new Map(), d = (p, m) => {
935
- const _ = [...a.get(D(p, m)) || []];
936
- return i === "label" && _.sort((f, v) => {
937
- const b = s.get(f), y = s.get(v);
938
- return !b || !y ? 0 : b.label.localeCompare(y.label);
963
+ function Q(l, e, t, r, i) {
964
+ const s = T(l), n = E(l), a = /* @__PURE__ */ new Map(), d = (c, h) => {
965
+ const _ = [...n.get(k(c, h)) || []];
966
+ return i === "label" && _.sort((b, S) => {
967
+ const m = s.get(b), v = s.get(S);
968
+ return !m || !v ? 0 : m.label.localeCompare(v.label);
939
969
  }), _;
940
- }, o = (p, m, _) => {
941
- const f = [];
942
- return d(p, m).forEach((v) => {
943
- const b = s.get(v);
944
- if (!b || b.hidden) return;
945
- const y = o(p, b.id);
946
- !W(b, t) && y.length === 0 || (f.push({
947
- id: b.id,
948
- disabled: b.disabled
949
- }), y.length && f.push(...y));
950
- }), f;
970
+ }, o = (c, h, _) => {
971
+ const b = [];
972
+ return d(c, h).forEach((S) => {
973
+ const m = s.get(S);
974
+ if (!m || m.hidden) return;
975
+ const v = o(c, m.id);
976
+ !W(m, r) && v.length === 0 || (b.push({
977
+ id: m.id,
978
+ disabled: m.disabled
979
+ }), v.length && b.push(...v));
980
+ }), b;
951
981
  };
952
- return Array.from(new Set(l.map((p) => p.listId))).forEach((p) => {
953
- n.set(p, o(p, null));
954
- }), n;
982
+ return Array.from(new Set(l.map((c) => c.listId))).forEach((c) => {
983
+ a.set(c, o(c, null));
984
+ }), a;
955
985
  }
956
- class ce extends ee {
986
+ class he extends ee {
957
987
  constructor() {
958
- super(), this._lists = X([]), this._items = [], this._selection = [], this._focusedId = null, this._rangeAnchorId = null, this._dragState = null, this._liveMessage = "Sortable list ready.", this._lastListsAttr = null, this._lastItemsAttr = null, this._lastSelectionAttr = null, this._hydratedPersistKey = null, this._cloneSeed = 1, this._dragImage = null, this._dragPreviewOverlay = null, this._pendingFocusId = null, this._pointerGesture = null, this._pendingDropTarget = null, this._suppressAttributeRender = !1, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onDragStart = this._onDragStart.bind(this), this._onDragOver = this._onDragOver.bind(this), this._onDrop = this._onDrop.bind(this), this._onDragEnd = this._onDragEnd.bind(this), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerCancel = this._onPointerCancel.bind(this), this._onFocusIn = this._onFocusIn.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this);
988
+ super(), this._lists = Y([]), this._items = [], this._selection = [], this._focusedId = null, this._rangeAnchorId = null, this._dragState = null, this._liveMessage = "Sortable list ready.", this._lastListsAttr = null, this._lastItemsAttr = null, this._lastSelectionAttr = null, this._hydratedPersistKey = null, this._cloneSeed = 1, this._dragImage = null, this._dragPreviewOverlay = null, this._pendingFocusId = null, this._pointerGesture = null, this._pendingDropTarget = null, this._suppressAttributeRender = !1, this._autoScrollFrame = 0, this._autoScrollPoint = null, this._autoScrollTick = () => {
989
+ this._autoScrollFrame = 0;
990
+ const e = this._autoScrollPoint;
991
+ if (!e || !this._dragState || this._dragState.keyboard) return;
992
+ const t = this.ownerDocument?.defaultView, r = ie(this), i = r ? r.getBoundingClientRect() : null, s = Math.max(0, i ? i.top : 0), n = Math.min(t?.innerHeight ?? 0, i ? i.bottom : 1 / 0), a = te(e.y, s, n);
993
+ if (a) {
994
+ if (r ? r.scrollTop += a : t?.scrollBy(0, a), !this._dragState.committed) {
995
+ const d = this._dropTargetFromPoint(e.x, e.y), o = d && this._canDrop(d, this._dragState.movedRootIds) ? d : null;
996
+ this._queueDropTarget(o, performance.now());
997
+ }
998
+ this._autoScrollFrame = requestAnimationFrame(this._autoScrollTick);
999
+ }
1000
+ }, this._onClick = this._onClick.bind(this), this._onKeyDown = this._onKeyDown.bind(this), this._onDragStart = this._onDragStart.bind(this), this._onDragOver = this._onDragOver.bind(this), this._onDrop = this._onDrop.bind(this), this._onDragEnd = this._onDragEnd.bind(this), this._onPointerDown = this._onPointerDown.bind(this), this._onPointerMove = this._onPointerMove.bind(this), this._onPointerUp = this._onPointerUp.bind(this), this._onPointerCancel = this._onPointerCancel.bind(this), this._onFocusIn = this._onFocusIn.bind(this), this._onDocumentKeyDown = this._onDocumentKeyDown.bind(this);
959
1001
  }
960
1002
  static get observedAttributes() {
961
1003
  return [
@@ -977,27 +1019,27 @@ class ce extends ee {
977
1019
  "disabled"
978
1020
  ];
979
1021
  }
980
- shouldRenderOnAttributeChange(e, r, t) {
1022
+ shouldRenderOnAttributeChange(e, t, r) {
981
1023
  return this._suppressAttributeRender ? !["lists", "items", "selection"].includes(e) : !0;
982
1024
  }
983
- attributeChangedCallback(e, r, t) {
984
- if (r !== t && this.isConnected) {
1025
+ attributeChangedCallback(e, t, r) {
1026
+ if (t !== r && this.isConnected) {
985
1027
  if (e === "selection" && !this._suppressAttributeRender && this._canSyncInteractiveStateInPlace()) {
986
- this._syncSelectionFromAttribute(t ?? null), this._syncSelectionVisualState();
1028
+ this._syncSelectionFromAttribute(r ?? null), this._syncSelectionVisualState();
987
1029
  return;
988
1030
  }
989
1031
  if (e === "show-selection-badge" && this._canSyncInteractiveStateInPlace()) {
990
1032
  this._syncSelectionVisualState();
991
1033
  return;
992
1034
  }
993
- super.attributeChangedCallback(e, r, t);
1035
+ super.attributeChangedCallback(e, t, r);
994
1036
  }
995
1037
  }
996
1038
  connectedCallback() {
997
1039
  super.connectedCallback(), this.root.addEventListener("click", this._onClick), this.root.addEventListener("keydown", this._onKeyDown), this.root.addEventListener("dragstart", this._onDragStart), this.root.addEventListener("dragover", this._onDragOver), this.root.addEventListener("drop", this._onDrop), this.root.addEventListener("dragend", this._onDragEnd), this.root.addEventListener("pointerdown", this._onPointerDown), this.root.addEventListener("focusin", this._onFocusIn), this.ownerDocument?.addEventListener("keydown", this._onDocumentKeyDown, !0), this.ownerDocument?.addEventListener("pointermove", this._onPointerMove, !0), this.ownerDocument?.addEventListener("pointerup", this._onPointerUp, !0), this.ownerDocument?.addEventListener("pointercancel", this._onPointerCancel, !0);
998
1040
  }
999
1041
  disconnectedCallback() {
1000
- this.root.removeEventListener("click", this._onClick), this.root.removeEventListener("keydown", this._onKeyDown), this.root.removeEventListener("dragstart", this._onDragStart), this.root.removeEventListener("dragover", this._onDragOver), this.root.removeEventListener("drop", this._onDrop), this.root.removeEventListener("dragend", this._onDragEnd), this.root.removeEventListener("pointerdown", this._onPointerDown), this.root.removeEventListener("focusin", this._onFocusIn), this.ownerDocument?.removeEventListener("keydown", this._onDocumentKeyDown, !0), this.ownerDocument?.removeEventListener("pointermove", this._onPointerMove, !0), this.ownerDocument?.removeEventListener("pointerup", this._onPointerUp, !0), this.ownerDocument?.removeEventListener("pointercancel", this._onPointerCancel, !0), this._removeDragPreviewOverlay(), this._removeDragImage(), super.disconnectedCallback();
1042
+ this.root.removeEventListener("click", this._onClick), this.root.removeEventListener("keydown", this._onKeyDown), this.root.removeEventListener("dragstart", this._onDragStart), this.root.removeEventListener("dragover", this._onDragOver), this.root.removeEventListener("drop", this._onDrop), this.root.removeEventListener("dragend", this._onDragEnd), this.root.removeEventListener("pointerdown", this._onPointerDown), this.root.removeEventListener("focusin", this._onFocusIn), this.ownerDocument?.removeEventListener("keydown", this._onDocumentKeyDown, !0), this.ownerDocument?.removeEventListener("pointermove", this._onPointerMove, !0), this.ownerDocument?.removeEventListener("pointerup", this._onPointerUp, !0), this.ownerDocument?.removeEventListener("pointercancel", this._onPointerCancel, !0), this._stopAutoScroll(), this._removeDragPreviewOverlay(), this._removeDragImage(), super.disconnectedCallback();
1001
1043
  }
1002
1044
  get lists() {
1003
1045
  return this._lists.map((e) => ({ ...e }));
@@ -1039,66 +1081,66 @@ class ce extends ee {
1039
1081
  this._cancelDrag(!0);
1040
1082
  }
1041
1083
  focusItem(e) {
1042
- this._items.some((r) => r.id === e) && (this._focusedId = e, this._pendingFocusId = e, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender());
1084
+ this._items.some((t) => t.id === e) && (this._focusedId = e, this._pendingFocusId = e, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender());
1043
1085
  }
1044
1086
  moveSelection(e) {
1045
1087
  this._syncSelectionFromAttribute(this.getAttribute("selection"));
1046
- const r = this._selectedRootIds();
1047
- r.length && this._commitMove({
1088
+ const t = this._selectedRootIds();
1089
+ t.length && this._commitMove({
1048
1090
  listId: e.targetListId,
1049
1091
  parentId: e.parentId ?? null,
1050
1092
  beforeId: e.beforeId ?? null,
1051
1093
  mode: e.mode ?? (e.parentId ? "inside" : "before")
1052
- }, r, !!e.clone, e.source ?? "api");
1094
+ }, t, !!e.clone, e.source ?? "api");
1053
1095
  }
1054
1096
  getPersistenceSnapshot() {
1055
1097
  return J(this._items);
1056
1098
  }
1057
1099
  render() {
1058
1100
  this._syncStateFromAttributes();
1059
- const e = this._measureItemShellRects(), r = new Set(this._draggingIds()), t = new Set(this._selection), s = !!this._dragState?.keyboard ? this._projectedMoveResult() : null, a = s?.items || this._items, n = new Set(s?.insertedRootIds || []), d = !!this._dragState && !this._dragState.keyboard && !!this._dragState.dropTarget, o = Q(a, t, r, this.filterQuery, this.sort), u = this._resolvedFocusedId(o), p = this._isDragLocked(), m = this._selection.length, _ = this.getAttribute("allow-nesting") !== "false", f = this.getAttribute("drop-indicator-visibility") === "always" ? "always" : "active", v = this._dropzoneStyle(), b = this.getAttribute("show-selection-badge") !== "false", y = this._dragHandleMode(), x = this._usesCustomHandleSelector(), z = p ? this.sort === "label" ? "Dragging is paused while alphabetical sorting is active." : this.filterQuery && !this.hasAttribute("allow-filtered-drag") ? "Dragging is paused while the list is filtered." : "Dragging is currently disabled." : this._dragState?.keyboard ? "Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel." : y === "item" ? "Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering." : x ? "Use your custom drag handle element, or press Space on a focused item to start keyboard reordering." : "Use the handle to drag, or press Space on a focused item to start keyboard reordering.", k = `
1060
- <style>${se}</style>
1101
+ const e = this._measureItemShellRects(), t = new Set(this._draggingIds()), r = new Set(this._selection), s = !!this._dragState?.keyboard ? this._projectedMoveResult() : null, n = s?.items || this._items, a = new Set(s?.insertedRootIds || []), d = !!this._dragState && !this._dragState.keyboard && !!this._dragState.dropTarget, o = Q(n, r, t, this.filterQuery, this.sort), u = this._resolvedFocusedId(o), c = this._isDragLocked(), h = this._selection.length, _ = this.getAttribute("allow-nesting") !== "false", b = this.getAttribute("drop-indicator-visibility") === "always" ? "always" : "active", S = this._dropzoneStyle(), m = this.getAttribute("show-selection-badge") !== "false", v = this._dragHandleMode(), D = this._usesCustomHandleSelector(), A = c ? this.sort === "label" ? "Dragging is paused while alphabetical sorting is active." : this.filterQuery && !this.hasAttribute("allow-filtered-drag") ? "Dragging is paused while the list is filtered." : "Dragging is currently disabled." : this._dragState?.keyboard ? "Keyboard drag active. Use arrow keys to choose a drop target, Space or Enter to drop, and Escape to cancel." : v === "item" ? "Drag from anywhere on an item, or press Space on a focused item to start keyboard reordering." : D ? "Use your custom drag handle element, or press Space on a focused item to start keyboard reordering." : "Use the handle to drag, or press Space on a focused item to start keyboard reordering.", z = `
1102
+ <style>${ae}</style>
1061
1103
  <div
1062
1104
  class="root"
1063
1105
  part="root"
1064
- data-drag-locked="${p}"
1065
- data-drag-preview="${n.size || d ? "true" : "false"}"
1066
- data-drop-indicator-visibility="${f}"
1067
- data-dropzone-style="${v}"
1106
+ data-drag-locked="${c}"
1107
+ data-drag-preview="${a.size || d ? "true" : "false"}"
1108
+ data-drop-indicator-visibility="${b}"
1109
+ data-dropzone-style="${S}"
1068
1110
  >
1069
1111
  <div class="toolbar" part="toolbar">
1070
- <div class="helper">${I(z)}</div>
1112
+ <div class="helper" id="ui-sortable-helper">${I(A)}</div>
1071
1113
  <div class="helper selection-summary">
1072
- <span class="selection-pill" part="selection-count">${m}</span>
1073
- <span class="selection-text">${m === 1 ? "item selected" : "items selected"}</span>
1114
+ <span class="selection-pill" part="selection-count">${h}</span>
1115
+ <span class="selection-text">${h === 1 ? "item selected" : "items selected"}</span>
1074
1116
  </div>
1075
1117
  </div>
1076
1118
  <div class="lists" part="lists">
1077
- ${this._lists.map((h) => {
1078
- const E = o.get(h.id) || [], H = E.length ? this._renderListTree(a, h, u, r, _, n, b) : "", L = h.disabled ? "This list is read-only." : h.cloneOnDrag ? "Dragging from this list creates a copy." : h.accepts?.length ? `Accepts drops from: ${h.accepts.join(", ")}` : "";
1119
+ ${this._lists.map((f) => {
1120
+ const y = o.get(f.id) || [], R = y.length ? this._renderListTree(n, f, u, t, _, a, m) : "", $ = f.disabled ? "This list is read-only." : f.cloneOnDrag ? "Dragging from this list creates a copy." : f.accepts?.length ? `Accepts drops from: ${f.accepts.join(", ")}` : "";
1079
1121
  return `
1080
1122
  <section
1081
1123
  class="list"
1082
1124
  part="list"
1083
- data-list-id="${I(h.id)}"
1084
- data-orientation="${h.orientation}"
1085
- data-disabled="${h.disabled}"
1086
- aria-label="${I(h.label)}"
1125
+ data-list-id="${I(f.id)}"
1126
+ data-orientation="${f.orientation}"
1127
+ data-disabled="${f.disabled}"
1128
+ aria-label="${I(f.label)}"
1087
1129
  >
1088
1130
  <header class="list-header">
1089
- <div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(h.id)}"></div>
1131
+ <div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(f.id)}"></div>
1090
1132
  <div class="list-default-header">
1091
1133
  <div class="list-topline">
1092
- <div class="list-label">${I(h.label)}</div>
1093
- <span class="list-count">${E.length}</span>
1134
+ <div class="list-label">${I(f.label)}</div>
1135
+ <span class="list-count">${y.length}</span>
1094
1136
  </div>
1095
- ${h.description ? `<div class="list-description">${I(h.description)}</div>` : ""}
1096
- ${L ? `<div class="list-helper">${I(L)}</div>` : ""}
1137
+ ${f.description ? `<div class="list-description">${I(f.description)}</div>` : ""}
1138
+ ${$ ? `<div class="list-helper">${I($)}</div>` : ""}
1097
1139
  </div>
1098
1140
  </header>
1099
- <div class="items" role="listbox" aria-multiselectable="true">
1100
- ${H || `<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${I(h.id)}"></div><div class="empty">${I(h.emptyLabel)}</div>${this._renderDropzone({
1101
- listId: h.id,
1141
+ <div class="items" role="${y.length ? "listbox" : "group"}" ${y.length ? 'aria-multiselectable="true"' : ""} aria-label="${I(f.label)}" aria-describedby="ui-sortable-helper">
1142
+ ${R || `<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${I(f.id)}"></div><div class="empty">${I(f.emptyLabel)}</div>${this._renderDropzone({
1143
+ listId: f.id,
1102
1144
  parentId: null,
1103
1145
  beforeId: null,
1104
1146
  mode: "before"
@@ -1111,67 +1153,67 @@ class ce extends ee {
1111
1153
  <div class="sr-only" aria-live="polite" aria-atomic="true">${I(this._liveMessage)}</div>
1112
1154
  </div>
1113
1155
  `;
1114
- this.setContent(k), queueMicrotask(() => {
1156
+ this.setContent(z), queueMicrotask(() => {
1115
1157
  this._restorePendingFocus(), this._applyCurrentDropTargetVisualState(), this._applyLiveMessage(), this._updatePointerDragPreview(), this._animateItemShellReflow(e);
1116
1158
  });
1117
1159
  }
1118
1160
  _syncStateFromAttributes() {
1119
1161
  const e = this.getAttribute("lists");
1120
- e !== this._lastListsAttr && (this._lastListsAttr = e, this._lists = X(V(e)));
1121
- const r = this.getAttribute("items");
1122
- if (r !== this._lastItemsAttr) {
1123
- this._lastItemsAttr = r, this._items = Y(this._lists, V(r));
1162
+ e !== this._lastListsAttr && (this._lastListsAttr = e, this._lists = Y(K(e)));
1163
+ const t = this.getAttribute("items");
1164
+ if (t !== this._lastItemsAttr) {
1165
+ this._lastItemsAttr = t, this._items = U(this._lists, K(t));
1124
1166
  const i = this.getAttribute("persist-key");
1125
1167
  i && this._hydratedPersistKey !== i && (this._items = this._restorePersistedItems(i, this._items), this._hydratedPersistKey = i);
1126
1168
  }
1127
- const t = this.getAttribute("selection");
1128
- t !== this._lastSelectionAttr && this._syncSelectionFromAttribute(t), this._focusedId || (this._focusedId = this._items.find((i) => !i.hidden)?.id || null);
1169
+ const r = this.getAttribute("selection");
1170
+ r !== this._lastSelectionAttr && this._syncSelectionFromAttribute(r), this._focusedId || (this._focusedId = this._items.find((i) => !i.hidden)?.id || null);
1129
1171
  }
1130
- _restorePersistedItems(e, r) {
1172
+ _restorePersistedItems(e, t) {
1131
1173
  try {
1132
- const t = window.localStorage.getItem(e);
1133
- if (!t) return r;
1134
- const i = JSON.parse(t);
1135
- if (!i || typeof i != "object" || !Array.isArray(i.records)) return r;
1136
- const s = new Map(i.records.map((n) => [n.id, n])), a = r.map((n, d) => {
1137
- const o = s.get(n.id);
1174
+ const r = window.localStorage.getItem(e);
1175
+ if (!r) return t;
1176
+ const i = JSON.parse(r);
1177
+ if (!i || typeof i != "object" || !Array.isArray(i.records)) return t;
1178
+ const s = new Map(i.records.map((a) => [a.id, a])), n = t.map((a, d) => {
1179
+ const o = s.get(a.id);
1138
1180
  return o ? {
1139
- ...n,
1140
- listId: this._lists.some((u) => u.id === o.listId) ? o.listId : n.listId,
1181
+ ...a,
1182
+ listId: this._lists.some((u) => u.id === o.listId) ? o.listId : a.listId,
1141
1183
  parentId: typeof o.parentId == "string" ? o.parentId : null,
1142
1184
  order: Number.isFinite(o.index) ? o.index : d
1143
- } : { ...n, order: d };
1185
+ } : { ...a, order: d };
1144
1186
  });
1145
- return Y(this._lists, a);
1187
+ return U(this._lists, n);
1146
1188
  } catch {
1147
- return r;
1189
+ return t;
1148
1190
  }
1149
1191
  }
1150
1192
  _resolvedFocusedId(e) {
1151
- const r = new Set(Array.from(e.values()).flat().map((i) => i.id));
1152
- return this._focusedId && r.has(this._focusedId) ? this._focusedId : Array.from(e.values()).flat().find((i) => !i.disabled)?.id || null;
1193
+ const t = new Set(Array.from(e.values()).flat().map((i) => i.id));
1194
+ return this._focusedId && t.has(this._focusedId) ? this._focusedId : Array.from(e.values()).flat().find((i) => !i.disabled)?.id || null;
1153
1195
  }
1154
1196
  _restorePendingFocus() {
1155
1197
  const e = this._pendingFocusId || this._focusedId;
1156
1198
  if (!e) return;
1157
- const r = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"'), t = this.root.querySelector(`.item[data-id="${r}"]`);
1158
- t && (document.activeElement !== t && t.focus({ preventScroll: !0 }), this._pendingFocusId = null);
1199
+ const t = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"'), r = this.root.querySelector(`.item[data-id="${t}"]`);
1200
+ r && (document.activeElement !== r && r.focus({ preventScroll: !0 }), this._pendingFocusId = null);
1159
1201
  }
1160
1202
  _escapeSelectorValue(e) {
1161
1203
  return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/"/g, '\\"');
1162
1204
  }
1163
1205
  _findDropzone(e) {
1164
- const r = this._escapeSelectorValue(e.listId), t = this._escapeSelectorValue(e.parentId ?? ""), i = this._escapeSelectorValue(e.beforeId ?? ""), s = this._escapeSelectorValue(e.mode);
1206
+ const t = this._escapeSelectorValue(e.listId), r = this._escapeSelectorValue(e.parentId ?? ""), i = this._escapeSelectorValue(e.beforeId ?? ""), s = this._escapeSelectorValue(e.mode);
1165
1207
  return this.root.querySelector(
1166
- `.dropzone[data-list-id="${r}"][data-parent-id="${t}"][data-before-id="${i}"][data-mode="${s}"]`
1208
+ `.dropzone[data-list-id="${t}"][data-parent-id="${r}"][data-before-id="${i}"][data-mode="${s}"]`
1167
1209
  );
1168
1210
  }
1169
1211
  _findItemElement(e) {
1170
- const r = this._escapeSelectorValue(e);
1171
- return this.root.querySelector(`.item[data-id="${r}"]`);
1212
+ const t = this._escapeSelectorValue(e);
1213
+ return this.root.querySelector(`.item[data-id="${t}"]`);
1172
1214
  }
1173
1215
  _dragHandleMode() {
1174
- return ne(this.getAttribute("drag-handle-mode"));
1216
+ return de(this.getAttribute("drag-handle-mode"));
1175
1217
  }
1176
1218
  _dropzoneStyle() {
1177
1219
  return this.getAttribute("dropzone-style") === "container" ? "container" : "indicator";
@@ -1180,15 +1222,15 @@ class ce extends ee {
1180
1222
  return !!this.getAttribute("drag-handle-selector")?.trim();
1181
1223
  }
1182
1224
  _dragActivatorFromPath(e) {
1183
- const r = e.find((a) => a instanceof HTMLElement && !!a.getAttribute("data-drag-trigger"));
1184
- if (!r) return null;
1185
- const t = r.getAttribute("data-drag-trigger"), i = t === "item" ? "item" : t === "custom" ? "custom" : "handle", s = r.getAttribute("data-id") || r.closest(".item[data-id]")?.getAttribute("data-id");
1186
- return s ? { element: r, id: s, kind: i } : null;
1225
+ const t = e.find((n) => n instanceof HTMLElement && !!n.getAttribute("data-drag-trigger"));
1226
+ if (!t) return null;
1227
+ const r = t.getAttribute("data-drag-trigger"), i = r === "item" ? "item" : r === "custom" ? "custom" : "handle", s = t.getAttribute("data-id") || t.closest(".item[data-id]")?.getAttribute("data-id");
1228
+ return s ? { element: t, id: s, kind: i } : null;
1187
1229
  }
1188
- _setDropTargetVisualState(e, r) {
1230
+ _setDropTargetVisualState(e, t) {
1189
1231
  if (!e) return;
1190
- const t = this._findDropzone(e);
1191
- t && (t.setAttribute("data-active", r ? "true" : "false"), r ? this._syncDropzoneContainerSize(t, e) : this._clearDropzoneContainerSize(t)), e.mode === "inside" && e.parentId && this._findItemElement(e.parentId)?.setAttribute("data-drop-inside-active", r ? "true" : "false");
1232
+ const r = this._findDropzone(e);
1233
+ r && (r.setAttribute("data-active", t ? "true" : "false"), t ? this._syncDropzoneContainerSize(r, e) : this._clearDropzoneContainerSize(r)), e.mode === "inside" && e.parentId && this._findItemElement(e.parentId)?.setAttribute("data-drop-inside-active", t ? "true" : "false");
1192
1234
  }
1193
1235
  _applyCurrentDropTargetVisualState(e) {
1194
1236
  this._setDropTargetVisualState(e ?? null, !1), this._setDropTargetVisualState(this._dragState?.dropTarget ?? null, !0);
@@ -1208,52 +1250,52 @@ class ce extends ee {
1208
1250
  }
1209
1251
  _syncSelectionFromAttribute(e) {
1210
1252
  this._lastSelectionAttr = e;
1211
- const r = new Set(this._items.map((t) => t.id));
1212
- this._selection = V(e).filter((t) => r.has(t)), !this._selection.length && this._focusedId && !r.has(this._focusedId) && (this._focusedId = null);
1253
+ const t = new Set(this._items.map((r) => r.id));
1254
+ this._selection = K(e).filter((r) => t.has(r)), !this._selection.length && this._focusedId && !t.has(this._focusedId) && (this._focusedId = null);
1213
1255
  }
1214
1256
  _syncSelectionVisualState() {
1215
- const e = new Set(this._selection), r = this.getAttribute("show-selection-badge") !== "false";
1257
+ const e = new Set(this._selection), t = this.getAttribute("show-selection-badge") !== "false";
1216
1258
  this.root.querySelectorAll(".item[data-id]").forEach((s) => {
1217
- const a = s.getAttribute("data-id");
1218
- if (!a) return;
1219
- const n = e.has(a), d = this._focusedId === a;
1220
- s.setAttribute("data-selected", n ? "true" : "false"), s.setAttribute("aria-selected", n ? "true" : "false"), s.setAttribute("data-focused", d ? "true" : "false"), s.setAttribute("tabindex", d ? "0" : "-1");
1259
+ const n = s.getAttribute("data-id");
1260
+ if (!n) return;
1261
+ const a = e.has(n), d = this._focusedId === n;
1262
+ s.setAttribute("data-selected", a ? "true" : "false"), s.setAttribute("aria-selected", a ? "true" : "false"), s.setAttribute("data-focused", d ? "true" : "false"), s.setAttribute("tabindex", d ? "0" : "-1");
1221
1263
  const o = s.querySelector('[data-selection-badge="true"]');
1222
1264
  if (o) {
1223
- const u = n && r;
1265
+ const u = a && t;
1224
1266
  o.hidden = !u, o.textContent = u ? "Selected" : "";
1225
1267
  }
1226
1268
  });
1227
- const t = this.root.querySelector(".selection-pill");
1228
- t && (t.textContent = String(this._selection.length));
1269
+ const r = this.root.querySelector(".selection-pill");
1270
+ r && (r.textContent = String(this._selection.length));
1229
1271
  const i = this.root.querySelector(".selection-text");
1230
1272
  i && (i.textContent = this._selection.length === 1 ? "item selected" : "items selected");
1231
1273
  }
1232
1274
  _clearDropzoneContainerSize(e) {
1233
1275
  e.style.removeProperty("--ui-sortable-dropzone-match-block-size"), e.style.removeProperty("--ui-sortable-dropzone-match-inline-size");
1234
1276
  }
1235
- _dropzoneReferenceElement(e, r) {
1277
+ _dropzoneReferenceElement(e, t) {
1236
1278
  if (e.mode === "inside" && e.parentId) return this._findItemElement(e.parentId);
1237
- let t = r.nextElementSibling;
1238
- for (; t; ) {
1239
- if (t instanceof HTMLElement && t.classList.contains("item-shell"))
1240
- return t.querySelector(".item[data-id]");
1241
- t = t.nextElementSibling;
1279
+ let r = t.nextElementSibling;
1280
+ for (; r; ) {
1281
+ if (r instanceof HTMLElement && r.classList.contains("item-shell"))
1282
+ return r.querySelector(".item[data-id]");
1283
+ r = r.nextElementSibling;
1242
1284
  }
1243
- let i = r.previousElementSibling;
1285
+ let i = t.previousElementSibling;
1244
1286
  for (; i; ) {
1245
1287
  if (i instanceof HTMLElement && i.classList.contains("item-shell"))
1246
1288
  return i.querySelector(".item[data-id]");
1247
1289
  i = i.previousElementSibling;
1248
1290
  }
1249
- const s = this._escapeSelectorValue(e.listId), a = this.root.querySelector(`.list[data-list-id="${s}"] .items`), n = a?.querySelector(".item[data-id]");
1250
- return n || a || null;
1291
+ const s = this._escapeSelectorValue(e.listId), n = this.root.querySelector(`.list[data-list-id="${s}"] .items`), a = n?.querySelector(".item[data-id]");
1292
+ return a || n || null;
1251
1293
  }
1252
- _syncDropzoneContainerSize(e, r) {
1294
+ _syncDropzoneContainerSize(e, t) {
1253
1295
  if (this._clearDropzoneContainerSize(e), this._dropzoneStyle() !== "container") return;
1254
- const t = this._dropzoneReferenceElement(r, e);
1255
- if (!t) return;
1256
- const i = t.getBoundingClientRect();
1296
+ const r = this._dropzoneReferenceElement(t, e);
1297
+ if (!r) return;
1298
+ const i = r.getBoundingClientRect();
1257
1299
  e.style.setProperty("--ui-sortable-dropzone-match-block-size", `${Math.max(76, Math.round(i.height))}px`), e.style.setProperty("--ui-sortable-dropzone-match-inline-size", `${Math.max(180, Math.round(i.width))}px`);
1258
1300
  }
1259
1301
  _ensureDragPreviewOverlay() {
@@ -1268,21 +1310,21 @@ class ce extends ee {
1268
1310
  }
1269
1311
  _pointerPreviewContent() {
1270
1312
  if (!this._dragState || this._dragState.keyboard) return null;
1271
- const e = this._dragState.movedRootIds[0], r = this._items.find((t) => t.id === e);
1272
- return r ? {
1313
+ const e = this._dragState.movedRootIds[0], t = this._items.find((r) => r.id === e);
1314
+ return t ? {
1273
1315
  kicker: this._dragState.clone ? "Copy preview" : "Drop preview",
1274
- title: this._dragState.clone ? `${r.label} copy` : r.label,
1316
+ title: this._dragState.clone ? `${t.label} copy` : t.label,
1275
1317
  description: this._dragState.clone ? "Release to add a copy here." : this._dragState.movedRootIds.length > 1 ? "Release to place this selection here." : "Release to place this item here."
1276
1318
  } : null;
1277
1319
  }
1278
1320
  _pointerPreviewSize() {
1279
1321
  if (this.getAttribute("drag-preview-size") === "compact" || !this._dragState || this._dragState.keyboard) return null;
1280
- const e = this._dragState.movedRootIds[0], r = e ? this._findItemElement(e) : null;
1281
- if (!r) return null;
1282
- const t = window.getComputedStyle(r), i = oe(t.transform);
1322
+ const e = this._dragState.movedRootIds[0], t = e ? this._findItemElement(e) : null;
1323
+ if (!t) return null;
1324
+ const r = window.getComputedStyle(t), i = le(r.transform);
1283
1325
  return {
1284
- width: r.offsetWidth * i.x,
1285
- height: r.offsetHeight * i.y
1326
+ width: t.offsetWidth * i.x,
1327
+ height: t.offsetHeight * i.y
1286
1328
  };
1287
1329
  }
1288
1330
  _updatePointerDragPreview() {
@@ -1295,52 +1337,52 @@ class ce extends ee {
1295
1337
  this._clearPointerDragPreview();
1296
1338
  return;
1297
1339
  }
1298
- const r = this.root.querySelector(".root"), i = this._dragPreviewOverlay?.getAttribute("data-visible") === "true", s = this._pointerPreviewSize();
1340
+ const t = this.root.querySelector(".root"), i = this._dragPreviewOverlay?.getAttribute("data-visible") === "true", s = this._pointerPreviewSize();
1299
1341
  if (!this._dragState.dropTarget) {
1300
- i && r && r.setAttribute("data-drag-preview", "true");
1342
+ i && t && t.setAttribute("data-drag-preview", "true");
1301
1343
  return;
1302
1344
  }
1303
- const a = this._findDropzone(this._dragState.dropTarget);
1304
- if (!a) {
1305
- i && r && r.setAttribute("data-drag-preview", "true");
1345
+ const n = this._findDropzone(this._dragState.dropTarget);
1346
+ if (!n) {
1347
+ i && t && t.setAttribute("data-drag-preview", "true");
1306
1348
  return;
1307
1349
  }
1308
- const n = this._ensureDragPreviewOverlay();
1309
- n.innerHTML = `
1350
+ const a = this._ensureDragPreviewOverlay();
1351
+ a.innerHTML = `
1310
1352
  <div class="placeholder-content">
1311
1353
  <div class="placeholder-kicker">${I(e.kicker)}</div>
1312
1354
  <div class="placeholder-title">${I(e.title)}</div>
1313
1355
  <div class="placeholder-description">${I(e.description)}</div>
1314
1356
  </div>
1315
1357
  `;
1316
- const d = a.getBoundingClientRect();
1317
- r && r.setAttribute("data-drag-preview", "true"), n.style.setProperty("left", "-9999px"), n.style.setProperty("top", "-9999px"), s ? (n.style.setProperty("inline-size", `${s.width}px`), n.style.setProperty("block-size", `${s.height}px`)) : (n.style.removeProperty("inline-size"), n.style.removeProperty("block-size")), n.setAttribute("data-visible", "true");
1318
- const o = n.getBoundingClientRect(), u = s?.width ?? o.width, p = s?.height ?? o.height, m = Math.max(16, Math.min(d.left, window.innerWidth - u - 16)), _ = Math.max(
1358
+ const d = n.getBoundingClientRect();
1359
+ t && t.setAttribute("data-drag-preview", "true"), a.style.setProperty("left", "-9999px"), a.style.setProperty("top", "-9999px"), s ? (a.style.setProperty("inline-size", `${s.width}px`), a.style.setProperty("block-size", `${s.height}px`)) : (a.style.removeProperty("inline-size"), a.style.removeProperty("block-size")), a.setAttribute("data-visible", "true");
1360
+ const o = a.getBoundingClientRect(), u = s?.width ?? o.width, c = s?.height ?? o.height, h = Math.max(16, Math.min(d.left, window.innerWidth - u - 16)), _ = Math.max(
1319
1361
  16,
1320
1362
  Math.min(
1321
- d.top + (d.height - p) / 2,
1322
- window.innerHeight - p - 16
1363
+ d.top + (d.height - c) / 2,
1364
+ window.innerHeight - c - 16
1323
1365
  )
1324
1366
  );
1325
- n.style.setProperty("left", `${Math.round(m)}px`), n.style.setProperty("top", `${Math.round(_)}px`);
1367
+ a.style.setProperty("left", `${Math.round(h)}px`), a.style.setProperty("top", `${Math.round(_)}px`);
1326
1368
  }
1327
- _setDraggingVisualState(e, r) {
1328
- e.forEach((t) => {
1329
- const i = this._findItemElement(t);
1330
- i && (i.setAttribute("data-dragging", r ? "true" : "false"), i.setAttribute("aria-grabbed", r ? "true" : "false"), r && i.getBoundingClientRect());
1369
+ _setDraggingVisualState(e, t) {
1370
+ e.forEach((r) => {
1371
+ const i = this._findItemElement(r);
1372
+ i && (i.setAttribute("data-dragging", t ? "true" : "false"), t && i.getBoundingClientRect());
1331
1373
  });
1332
1374
  }
1333
- _setDropTarget(e, r) {
1334
- const t = this._dragState?.dropTarget ?? null;
1335
- if (!(!this._dragState || B(t, e))) {
1336
- if (this._pendingDropTarget = null, this._dragState.dropTarget = e, this._applyCurrentDropTargetVisualState(t), r?.announceLabel && this._announce(r.announceLabel), this._dragState.keyboard) {
1375
+ _setDropTarget(e, t) {
1376
+ const r = this._dragState?.dropTarget ?? null;
1377
+ if (!(!this._dragState || B(r, e))) {
1378
+ if (this._pendingDropTarget = null, this._dragState.dropTarget = e, this._applyCurrentDropTargetVisualState(r), t?.announceLabel && this._announce(t.announceLabel), this._dragState.keyboard) {
1337
1379
  this.requestRender();
1338
1380
  return;
1339
1381
  }
1340
1382
  this._updatePointerDragPreview();
1341
1383
  }
1342
1384
  }
1343
- _queueDropTarget(e, r, t) {
1385
+ _queueDropTarget(e, t, r) {
1344
1386
  if (!this._dragState) return;
1345
1387
  const i = this._dragState.dropTarget ?? null;
1346
1388
  if (B(i, e)) {
@@ -1348,164 +1390,172 @@ class ce extends ee {
1348
1390
  return;
1349
1391
  }
1350
1392
  if (!i && e) {
1351
- this._setDropTarget(e, t);
1393
+ this._setDropTarget(e, r);
1352
1394
  return;
1353
1395
  }
1354
- const s = typeof r == "number" && Number.isFinite(r) ? r : performance.now(), a = this._pendingDropTarget;
1355
- if (a && B(a.target, e)) {
1356
- const n = e ? re : ie;
1357
- s - a.startedAt >= n && this._setDropTarget(e, a.announceLabel ? { announceLabel: a.announceLabel } : t);
1396
+ const s = typeof t == "number" && Number.isFinite(t) ? t : performance.now(), n = this._pendingDropTarget;
1397
+ if (n && B(n.target, e)) {
1398
+ const a = e ? oe : ne;
1399
+ s - n.startedAt >= a && this._setDropTarget(e, n.announceLabel ? { announceLabel: n.announceLabel } : r);
1358
1400
  return;
1359
1401
  }
1360
1402
  this._pendingDropTarget = {
1361
1403
  target: e,
1362
1404
  startedAt: s,
1363
- announceLabel: t?.announceLabel
1405
+ announceLabel: r?.announceLabel
1364
1406
  };
1365
1407
  }
1366
- _releaseDropTarget(e, r) {
1408
+ _releaseDropTarget(e, t) {
1367
1409
  if (!this._dragState) return null;
1368
- if (Number.isFinite(e) && Number.isFinite(r)) {
1369
- const s = this._dropTargetFromPoint(e, r);
1370
- if (s && this._canDrop(s, this._dragState.movedRootIds))
1371
- return this._pendingDropTarget = null, s;
1410
+ if (Number.isFinite(e) && Number.isFinite(t)) {
1411
+ const n = this._dropTargetFromPoint(e, t);
1412
+ if (n && this._canDrop(n, this._dragState.movedRootIds))
1413
+ return this._pendingDropTarget = null, n;
1372
1414
  }
1373
- const t = this._pendingDropTarget?.target ?? null;
1374
- if (this._pendingDropTarget = null, t && this._canDrop(t, this._dragState.movedRootIds)) return t;
1375
- const i = this._dragState.dropTarget ?? null;
1376
- return i && this._canDrop(i, this._dragState.movedRootIds) ? i : null;
1377
- }
1378
- _pathFromPoint(e, r) {
1379
- const t = [], i = this.root;
1380
- let s = typeof i.elementFromPoint == "function" ? i.elementFromPoint(e, r) : this.ownerDocument?.elementFromPoint(e, r) ?? null;
1381
- for (; s && (s instanceof HTMLElement && t.push(s), s !== this); ) {
1415
+ const r = this._pendingDropTarget?.target ?? null;
1416
+ this._pendingDropTarget = null;
1417
+ const i = (n) => this._pointerIsOverList(n.listId, e, t);
1418
+ if (r && this._canDrop(r, this._dragState.movedRootIds) && i(r)) return r;
1419
+ const s = this._dragState.dropTarget ?? null;
1420
+ return s && this._canDrop(s, this._dragState.movedRootIds) && i(s) ? s : null;
1421
+ }
1422
+ _pointerIsOverList(e, t, r) {
1423
+ if (!Number.isFinite(t) || !Number.isFinite(r)) return !0;
1424
+ const s = Array.from(this.root.querySelectorAll(".list[data-list-id]")).find((a) => a.getAttribute("data-list-id") === e);
1425
+ if (!s) return !0;
1426
+ const n = s.getBoundingClientRect();
1427
+ return t >= n.left && t <= n.right && r >= n.top && r <= n.bottom;
1428
+ }
1429
+ _pathFromPoint(e, t) {
1430
+ const r = [], i = this.root;
1431
+ let s = typeof i.elementFromPoint == "function" ? i.elementFromPoint(e, t) : this.ownerDocument?.elementFromPoint(e, t) ?? null;
1432
+ for (; s && (s instanceof HTMLElement && r.push(s), s !== this); ) {
1382
1433
  if (s instanceof ShadowRoot) {
1383
1434
  s = s.host;
1384
1435
  continue;
1385
1436
  }
1386
- s = s.parentNode, !s && t[t.length - 1]?.getRootNode() instanceof ShadowRoot && (s = t[t.length - 1].getRootNode().host);
1437
+ s = s.parentNode, !s && r[r.length - 1]?.getRootNode() instanceof ShadowRoot && (s = r[r.length - 1].getRootNode().host);
1387
1438
  }
1388
- return t;
1439
+ return r;
1389
1440
  }
1390
1441
  _measureItemShellRects() {
1391
1442
  const e = /* @__PURE__ */ new Map();
1392
- return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((r) => {
1393
- const t = r.getAttribute("data-item-shell");
1394
- if (!t) return;
1395
- const i = r.getBoundingClientRect();
1396
- e.set(t, { top: i.top, left: i.left });
1443
+ return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((t) => {
1444
+ const r = t.getAttribute("data-item-shell");
1445
+ if (!r) return;
1446
+ const i = t.getBoundingClientRect();
1447
+ e.set(r, { top: i.top, left: i.left });
1397
1448
  }), e;
1398
1449
  }
1399
1450
  _animateItemShellReflow(e) {
1400
1451
  if (!e.size) return;
1401
- const r = new Set(this._draggingIds());
1402
- this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((t) => {
1403
- const i = t.getAttribute("data-item-shell");
1404
- if (!i || r.has(i)) return;
1452
+ const t = new Set(this._draggingIds());
1453
+ this.root.querySelectorAll(".item-shell[data-item-shell]").forEach((r) => {
1454
+ const i = r.getAttribute("data-item-shell");
1455
+ if (!i || t.has(i)) return;
1405
1456
  const s = e.get(i);
1406
1457
  if (!s) return;
1407
- const a = t.getBoundingClientRect(), n = s.left - a.left, d = s.top - a.top;
1408
- Math.abs(n) < 0.5 && Math.abs(d) < 0.5 || (t.style.transition = "none", t.style.transform = `translate(${n}px, ${d}px)`, t.style.willChange = "transform", t.getBoundingClientRect(), requestAnimationFrame(() => {
1409
- t.style.transition = "transform 180ms ease", t.style.transform = "";
1458
+ const n = r.getBoundingClientRect(), a = s.left - n.left, d = s.top - n.top;
1459
+ Math.abs(a) < 0.5 && Math.abs(d) < 0.5 || (r.style.transition = "none", r.style.transform = `translate(${a}px, ${d}px)`, r.style.willChange = "transform", r.getBoundingClientRect(), requestAnimationFrame(() => {
1460
+ r.style.transition = "transform 180ms ease", r.style.transform = "";
1410
1461
  const o = () => {
1411
- t.style.transition = "", t.style.willChange = "", t.removeEventListener("transitionend", o);
1462
+ r.style.transition = "", r.style.willChange = "", r.removeEventListener("transitionend", o);
1412
1463
  };
1413
- t.addEventListener("transitionend", o), window.setTimeout(o, 220);
1464
+ r.addEventListener("transitionend", o), window.setTimeout(o, 220);
1414
1465
  }));
1415
1466
  });
1416
1467
  }
1417
- _previewCloneSubtreeItem(e, r) {
1418
- const t = e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id;
1468
+ _previewCloneSubtreeItem(e, t) {
1469
+ const r = e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id;
1419
1470
  return {
1420
1471
  ...e,
1421
- id: `${t}--preview`,
1422
- label: r[0] === e.id ? `${e.label} copy` : e.label
1472
+ id: `${r}--preview`,
1473
+ label: t[0] === e.id ? `${e.label} copy` : e.label
1423
1474
  };
1424
1475
  }
1425
1476
  _projectedMoveResult() {
1426
- return !this._dragState?.dropTarget || !this._canDrop(this._dragState.dropTarget, this._dragState.movedRootIds) ? null : ae(
1477
+ return !this._dragState?.dropTarget || !this._canDrop(this._dragState.dropTarget, this._dragState.movedRootIds) ? null : ce(
1427
1478
  this._items,
1428
1479
  this._lists,
1429
1480
  this._dragState.dropTarget,
1430
1481
  this._dragState.movedRootIds,
1431
1482
  this._dragState.clone,
1432
- (e, r) => this._previewCloneSubtreeItem(e, r)
1483
+ (e, t) => this._previewCloneSubtreeItem(e, t)
1433
1484
  );
1434
1485
  }
1435
- _renderListTree(e, r, t, i, s, a, n) {
1436
- const d = P(e), o = $(e), u = (p) => {
1437
- const m = o.get(D(r.id, p)) || [], _ = this.sort === "label" ? [...m].sort((v, b) => {
1438
- const y = d.get(v), x = d.get(b);
1439
- return !y || !x ? 0 : y.label.localeCompare(x.label);
1440
- }) : m;
1441
- let f = "";
1442
- return _.forEach((v) => {
1443
- const b = d.get(v);
1444
- if (!b || b.hidden) return;
1445
- const y = this._renderChildBranch(
1446
- b,
1447
- t,
1486
+ _renderListTree(e, t, r, i, s, n, a) {
1487
+ const d = T(e), o = E(e), u = (c) => {
1488
+ const h = o.get(k(t.id, c)) || [], _ = this.sort === "label" ? [...h].sort((S, m) => {
1489
+ const v = d.get(S), D = d.get(m);
1490
+ return !v || !D ? 0 : v.label.localeCompare(D.label);
1491
+ }) : h;
1492
+ let b = "";
1493
+ return _.forEach((S) => {
1494
+ const m = d.get(S);
1495
+ if (!m || m.hidden) return;
1496
+ const v = this._renderChildBranch(
1497
+ m,
1498
+ r,
1448
1499
  i,
1449
1500
  u,
1450
1501
  s,
1451
- a,
1452
- n
1502
+ n,
1503
+ a
1453
1504
  );
1454
- !W(b, this.filterQuery) && !y.includes('class="item"') || (f += this._renderDropzone({
1455
- listId: r.id,
1456
- parentId: p,
1457
- beforeId: v,
1505
+ !W(m, this.filterQuery) && !v.includes('class="item"') || (b += this._renderDropzone({
1506
+ listId: t.id,
1507
+ parentId: c,
1508
+ beforeId: S,
1458
1509
  mode: "before"
1459
- }, "Drop here"), f += y);
1460
- }), f += this._renderDropzone({
1461
- listId: r.id,
1462
- parentId: p,
1510
+ }, "Drop here"), b += v);
1511
+ }), b += this._renderDropzone({
1512
+ listId: t.id,
1513
+ parentId: c,
1463
1514
  beforeId: null,
1464
1515
  mode: "before"
1465
- }, "Drop here"), f;
1516
+ }, "Drop here"), b;
1466
1517
  };
1467
1518
  return `<div class="tree">${u(null)}</div>`;
1468
1519
  }
1469
- _renderChildBranch(e, r, t, i, s, a, n) {
1470
- const d = I(e.id), o = a.has(e.id), u = o ? "" : i(e.id), p = u.includes('class="item"'), m = o ? !1 : this._selection.includes(e.id), _ = o ? !1 : t.has(e.id), f = e.disabled, v = f || e.dragDisabled || this._isDragLocked(), b = this._dragState?.dropTarget?.mode === "inside" && this._dragState.dropTarget.parentId === e.id, y = this._dragState?.clone ? "Copy preview" : "Drop preview", x = this._dragState?.clone ? "Release to add a copy here." : this._dragState && this._dragState.movedRootIds.length > 1 ? "Release to place this selection here." : "Release to place this item here.", z = this._dragHandleMode(), k = this._usesCustomHandleSelector(), h = k ? "custom" : z, E = !k && z === "handle";
1520
+ _renderChildBranch(e, t, r, i, s, n, a) {
1521
+ const d = I(e.id), o = n.has(e.id), u = o ? "" : i(e.id), c = u.includes('class="item"'), h = o ? !1 : this._selection.includes(e.id), _ = o ? !1 : r.has(e.id), b = e.disabled, S = b || e.dragDisabled || this._isDragLocked(), m = this._dragState?.dropTarget?.mode === "inside" && this._dragState.dropTarget.parentId === e.id, v = this._dragState?.clone ? "Copy preview" : "Drop preview", D = this._dragState?.clone ? "Release to add a copy here." : this._dragState && this._dragState.movedRootIds.length > 1 ? "Release to place this selection here." : "Release to place this item here.", A = this._dragHandleMode(), z = this._usesCustomHandleSelector(), f = z ? "custom" : A, y = !z && A === "handle";
1471
1522
  return `
1472
1523
  <div class="item-shell" data-item-shell="${d}">
1473
- <article
1524
+ <div
1474
1525
  class="item${o ? " item-placeholder" : ""}"
1475
1526
  part="item"
1476
1527
  data-id="${d}"
1477
- data-drag-handle-mode="${h}"
1478
- ${!o && h === "item" ? 'data-drag-trigger="item"' : ""}
1479
- data-selected="${m}"
1480
- data-focused="${o ? "false" : r === e.id}"
1528
+ data-drag-handle-mode="${f}"
1529
+ ${!o && f === "item" ? 'data-drag-trigger="item"' : ""}
1530
+ data-selected="${h}"
1531
+ data-focused="${o ? "false" : t === e.id}"
1481
1532
  data-dragging="${_}"
1482
- data-disabled="${f}"
1483
- data-drop-inside-active="${b ? "true" : "false"}"
1533
+ data-disabled="${b}"
1534
+ data-drop-inside-active="${m ? "true" : "false"}"
1484
1535
  role="${o ? "presentation" : "option"}"
1485
- aria-selected="${o ? "false" : m}"
1486
- aria-disabled="${f}"
1487
- aria-grabbed="${o ? "false" : _}"
1536
+ aria-selected="${o ? "false" : h}"
1537
+ aria-disabled="${b}"
1488
1538
  aria-hidden="${o ? "true" : "false"}"
1489
- tabindex="${o ? "-1" : r === e.id ? "0" : "-1"}"
1539
+ tabindex="${o ? "-1" : t === e.id ? "0" : "-1"}"
1490
1540
  >
1491
1541
  ${o ? `
1492
1542
  <div class="placeholder-content">
1493
- <div class="placeholder-kicker">${I(y)}</div>
1543
+ <div class="placeholder-kicker">${I(v)}</div>
1494
1544
  <div class="placeholder-title">${I(e.label)}</div>
1495
- <div class="placeholder-description">${I(x)}</div>
1545
+ <div class="placeholder-description">${I(D)}</div>
1496
1546
  </div>
1497
1547
  ` : `
1498
- ${E ? `
1499
- <button
1548
+ ${y ? `
1549
+ <span
1500
1550
  class="handle"
1501
1551
  part="handle"
1502
- type="button"
1552
+ role="presentation"
1553
+ aria-hidden="true"
1503
1554
  data-action="handle"
1504
1555
  data-drag-trigger="handle"
1505
1556
  data-id="${d}"
1506
1557
  draggable="false"
1507
- ${v ? "disabled" : ""}
1508
- aria-label="Drag ${I(e.label)}"
1558
+ ${S ? "disabled" : ""}
1509
1559
  >
1510
1560
  <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
1511
1561
  <circle cx="5" cy="4" r="1.25"></circle>
@@ -1515,7 +1565,7 @@ class ce extends ee {
1515
1565
  <circle cx="5" cy="12" r="1.25"></circle>
1516
1566
  <circle cx="11" cy="12" r="1.25"></circle>
1517
1567
  </svg>
1518
- </button>
1568
+ </span>
1519
1569
  ` : ""}
1520
1570
  <div class="item-content" data-action="select" data-id="${d}">
1521
1571
  <div class="item-custom-content" part="item-custom-content" data-item-content-target="${d}"></div>
@@ -1523,7 +1573,7 @@ class ce extends ee {
1523
1573
  <div class="item-title">${I(e.label)}</div>
1524
1574
  ${e.description ? `<div class="item-description">${I(e.description)}</div>` : ""}
1525
1575
  <div class="item-meta">
1526
- <span class="item-badge selection-badge" data-selection-badge="true" ${m && n ? "" : "hidden"}>${m && n ? "Selected" : ""}</span>
1576
+ <span class="item-badge selection-badge" data-selection-badge="true" ${h && a ? "" : "hidden"}>${h && a ? "Selected" : ""}</span>
1527
1577
  ${e.cloneOnDrag ? '<span class="item-badge">Clone on drag</span>' : ""}
1528
1578
  ${e.dragDisabled ? '<span class="item-badge">Pinned</span>' : ""}
1529
1579
  ${s ? '<span class="item-badge drop-badge">Nest here</span>' : ""}
@@ -1531,19 +1581,19 @@ class ce extends ee {
1531
1581
  </div>
1532
1582
  </div>
1533
1583
  `}
1534
- </article>
1584
+ </div>
1535
1585
  ${s && !o ? this._renderDropzone({
1536
1586
  listId: e.listId,
1537
1587
  parentId: e.id,
1538
1588
  beforeId: null,
1539
1589
  mode: "inside"
1540
1590
  }, "Nest here") : ""}
1541
- ${p ? `<div class="children">${u}</div>` : ""}
1591
+ ${c ? `<div class="children">${u}</div>` : ""}
1542
1592
  </div>
1543
1593
  `;
1544
1594
  }
1545
- _renderDropzone(e, r) {
1546
- const t = this._dragState?.dropTarget && this._dragState.dropTarget.listId === e.listId && this._dragState.dropTarget.parentId === e.parentId && this._dragState.dropTarget.beforeId === e.beforeId && this._dragState.dropTarget.mode === e.mode;
1595
+ _renderDropzone(e, t) {
1596
+ const r = this._dragState?.dropTarget && this._dragState.dropTarget.listId === e.listId && this._dragState.dropTarget.parentId === e.parentId && this._dragState.dropTarget.beforeId === e.beforeId && this._dragState.dropTarget.mode === e.mode;
1547
1597
  return `
1548
1598
  <div
1549
1599
  class="dropzone"
@@ -1552,52 +1602,60 @@ class ce extends ee {
1552
1602
  data-parent-id="${I(e.parentId ?? "")}"
1553
1603
  data-before-id="${I(e.beforeId ?? "")}"
1554
1604
  data-mode="${e.mode}"
1555
- data-active="${t ? "true" : "false"}"
1605
+ data-active="${r ? "true" : "false"}"
1556
1606
  aria-hidden="true"
1557
1607
  >
1558
- <span class="dropzone-label">${I(r)}</span>
1608
+ <span class="dropzone-label">${I(t)}</span>
1559
1609
  </div>
1560
1610
  `;
1561
1611
  }
1562
1612
  _onClick(e) {
1563
- const r = e.composedPath(), t = r.find((o) => o instanceof HTMLElement && o.classList?.contains("toolbar")), i = this._dragActivatorFromPath(r), s = r.find((o) => o instanceof HTMLElement && o.classList.contains("item"));
1613
+ const t = e.composedPath(), r = t.find((o) => o instanceof HTMLElement && o.classList?.contains("toolbar")), i = this._dragActivatorFromPath(t), s = t.find((o) => o instanceof HTMLElement && o.classList.contains("item"));
1564
1614
  if (i && i.kind !== "item") return;
1565
1615
  if (!s)
1566
- return t && !(e.target instanceof HTMLButtonElement), void 0;
1567
- const a = s.getAttribute("data-id");
1568
- if (!a) return;
1569
- const n = this._items.find((o) => o.id === a);
1570
- if (!n || n.disabled) return;
1616
+ return r && !(e.target instanceof HTMLButtonElement), void 0;
1617
+ const n = s.getAttribute("data-id");
1618
+ if (!n) return;
1619
+ const a = this._items.find((o) => o.id === n);
1620
+ if (!a || a.disabled) return;
1571
1621
  const d = e;
1572
- if (d.shiftKey ? this._selectRangeTo(a) : d.metaKey || d.ctrlKey ? this._toggleSelection(a) : this._setSelection([a], "pointer"), this._focusedId = a, this._rangeAnchorId = a, this._pendingFocusId = a, this._hasCustomItemRendering()) {
1622
+ if (d.shiftKey ? this._selectRangeTo(n) : d.metaKey || d.ctrlKey ? this._toggleSelection(n) : this._setSelection([n], "pointer"), this._focusedId = n, this._rangeAnchorId = n, this._pendingFocusId = n, this._hasCustomItemRendering()) {
1573
1623
  this._syncSelectionVisualState(), this._restorePendingFocus();
1574
1624
  return;
1575
1625
  }
1576
1626
  this.requestRender();
1577
1627
  }
1578
1628
  _onFocusIn(e) {
1579
- const t = e.composedPath().find((i) => i instanceof HTMLElement && i.classList.contains("item"))?.getAttribute("data-id");
1580
- t && (this._focusedId = t, this._syncSelectionVisualState());
1629
+ const r = e.composedPath().find((i) => i instanceof HTMLElement && i.classList.contains("item"))?.getAttribute("data-id");
1630
+ r && (this._focusedId = r, this._syncSelectionVisualState());
1631
+ }
1632
+ // Keys typed into a control that lives inside an item (an <input> or <button> in a custom card)
1633
+ // belong to that control: swallowing Space/Enter/arrows there made it impossible to type a space
1634
+ // or press the button from the keyboard. The drag handle is part of the item, not a foreign control.
1635
+ _isForeignControl(e) {
1636
+ const t = e.composedPath()[0];
1637
+ return !(t instanceof HTMLElement) || t.classList.contains("handle") || t.classList.contains("item") ? !1 : t.isContentEditable || t.matches('input, textarea, select, button, summary, a[href], [role="button"], [role="textbox"], [role="combobox"]');
1581
1638
  }
1582
1639
  _onKeyDown(e) {
1583
- const r = this._visibleItemIds();
1584
- if (!r.length) return;
1585
- const t = this._focusedId && r.includes(this._focusedId) ? this._focusedId : r[0], i = r.indexOf(t), s = this._items.find((d) => d.id === t), n = (s ? this._lists.find((d) => d.id === s.listId) : null)?.orientation === "horizontal";
1640
+ if (this._isForeignControl(e)) return;
1641
+ const t = this._visibleItemIds();
1642
+ if (!t.length) return;
1643
+ const r = this._focusedId && t.includes(this._focusedId) ? this._focusedId : t[0], i = t.indexOf(r), s = this._items.find((c) => c.id === r), a = (s ? this._lists.find((c) => c.id === s.listId) : null)?.orientation === "horizontal", d = this._isRtl(), o = a ? d ? "ArrowLeft" : "ArrowRight" : "ArrowDown", u = a ? d ? "ArrowRight" : "ArrowLeft" : "ArrowUp";
1586
1644
  if (!this._dragState?.keyboard) {
1587
- if (e.key === "ArrowDown" && !n || e.key === "ArrowRight" && n) {
1588
- e.preventDefault(), this._moveFocusBy(r, i, 1);
1645
+ if (e.key === o) {
1646
+ e.preventDefault(), this._moveFocusBy(t, i, 1);
1589
1647
  return;
1590
1648
  }
1591
- if (e.key === "ArrowUp" && !n || e.key === "ArrowLeft" && n) {
1592
- e.preventDefault(), this._moveFocusBy(r, i, -1);
1649
+ if (e.key === u) {
1650
+ e.preventDefault(), this._moveFocusBy(t, i, -1);
1593
1651
  return;
1594
1652
  }
1595
1653
  if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
1596
- e.preventDefault(), this._setSelection(r, "keyboard"), this._announce(`${r.length} items selected.`);
1654
+ e.preventDefault(), this._setSelection(t, "keyboard"), this._announce(`${t.length} items selected.`);
1597
1655
  return;
1598
1656
  }
1599
1657
  if (e.key === "Enter") {
1600
- e.preventDefault(), this._setSelection([t], "keyboard");
1658
+ e.preventDefault(), this._setSelection([r], "keyboard");
1601
1659
  return;
1602
1660
  }
1603
1661
  if (e.key === " " || e.code === "Space") {
@@ -1605,20 +1663,20 @@ class ce extends ee {
1605
1663
  this._announce("Dragging is disabled right now.");
1606
1664
  return;
1607
1665
  }
1608
- const d = this._selectedRootIds(t);
1609
- if (!d.length) return;
1610
- const o = this._itemClonesOnDrag(t);
1666
+ const c = this._selectedRootIds(r);
1667
+ if (!c.length) return;
1668
+ const h = this._itemClonesOnDrag(r);
1611
1669
  this._dragState = {
1612
- snapshot: this._items.map(A),
1613
- movedRootIds: d,
1614
- originId: t,
1615
- clone: o,
1670
+ snapshot: this._items.map(P),
1671
+ movedRootIds: c,
1672
+ originId: r,
1673
+ clone: h,
1616
1674
  keyboard: !0,
1617
- dropTarget: this._initialKeyboardDropTarget(t),
1675
+ dropTarget: this._initialKeyboardDropTarget(r),
1618
1676
  committed: !1
1619
1677
  };
1620
- const u = d.length === 1 ? `Lifted ${s?.label || "item"}.` : `Lifted ${d.length} items.`;
1621
- this._announce(`${u} Use arrow keys to choose a destination.`), this.requestRender();
1678
+ const _ = c.length === 1 ? `Lifted ${s?.label || "item"}.` : `Lifted ${c.length} items.`;
1679
+ this._announce(`${_} Use arrow keys to choose a destination.`), this.requestRender();
1622
1680
  return;
1623
1681
  }
1624
1682
  if (e.key === "Escape") {
@@ -1633,24 +1691,28 @@ class ce extends ee {
1633
1691
  }
1634
1692
  if (e.key === "Enter" || e.key === " " || e.code === "Space") {
1635
1693
  e.preventDefault();
1636
- const d = this._dragState.dropTarget;
1637
- if (!d) return;
1638
- this._commitMove(d, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
1694
+ const c = this._dragState.dropTarget;
1695
+ if (!c) return;
1696
+ this._commitMove(c, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
1639
1697
  return;
1640
1698
  }
1641
1699
  if (["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(e.key)) {
1642
1700
  e.preventDefault();
1643
- const d = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : -1;
1644
- this._moveKeyboardDropTarget(d);
1701
+ const c = d ? "ArrowLeft" : "ArrowRight", h = e.key === "ArrowDown" || e.key === c ? 1 : -1;
1702
+ this._moveKeyboardDropTarget(h);
1645
1703
  }
1646
1704
  }
1647
- _moveFocusBy(e, r, t) {
1648
- const i = Math.max(0, Math.min(e.length - 1, r + t)), s = e[i];
1705
+ _isRtl() {
1706
+ const e = this.ownerDocument?.defaultView?.getComputedStyle(this).direction;
1707
+ return e ? e === "rtl" : this.closest("[dir]")?.getAttribute("dir") === "rtl";
1708
+ }
1709
+ _moveFocusBy(e, t, r) {
1710
+ const i = Math.max(0, Math.min(e.length - 1, t + r)), s = e[i];
1649
1711
  this._focusedId = s, this._pendingFocusId = s, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender();
1650
1712
  }
1651
1713
  _onDragStart(e) {
1652
- const r = this._dragActivatorFromPath(e.composedPath()), t = r?.id;
1653
- if (!r || !t) {
1714
+ const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
1715
+ if (!t || !r) {
1654
1716
  e.preventDefault();
1655
1717
  return;
1656
1718
  }
@@ -1658,97 +1720,102 @@ class ce extends ee {
1658
1720
  e.preventDefault(), this._announce("Dragging is disabled right now.");
1659
1721
  return;
1660
1722
  }
1661
- const i = this._items.find((n) => n.id === t);
1723
+ const i = this._items.find((a) => a.id === r);
1662
1724
  if (!i || i.disabled || i.dragDisabled) {
1663
1725
  e.preventDefault();
1664
1726
  return;
1665
1727
  }
1666
- const s = this._selection.includes(t) ? this._selectedRootIds(t) : [t];
1667
- this._selection.includes(t) || this._setSelection([t], "pointer");
1668
- const a = this._itemClonesOnDrag(t);
1728
+ const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
1729
+ this._selection.includes(r) || this._setSelection([r], "pointer");
1730
+ const n = this._itemClonesOnDrag(r);
1669
1731
  this._dragState = {
1670
- snapshot: this._items.map(A),
1732
+ snapshot: this._items.map(P),
1671
1733
  movedRootIds: s,
1672
- originId: t,
1673
- clone: a,
1734
+ originId: r,
1735
+ clone: n,
1674
1736
  keyboard: !1,
1675
1737
  dropTarget: null,
1676
1738
  committed: !1
1677
- }, e.dataTransfer && (e.dataTransfer.effectAllowed = a ? "copyMove" : "move", e.dataTransfer.setData("text/plain", s.join(",")), this._applyDragImage(e.dataTransfer, s.length)), this._announce(
1678
- a ? `Dragging ${s.length === 1 ? i.label : `${s.length} items`} as a copy.` : `Dragging ${s.length === 1 ? i.label : `${s.length} items`}.`
1739
+ }, e.dataTransfer && (e.dataTransfer.effectAllowed = n ? "copyMove" : "move", e.dataTransfer.setData("text/plain", s.join(",")), this._applyDragImage(e.dataTransfer, s.length)), this._announce(
1740
+ n ? `Dragging ${s.length === 1 ? i.label : `${s.length} items`} as a copy.` : `Dragging ${s.length === 1 ? i.label : `${s.length} items`}.`
1679
1741
  ), this.requestRender();
1680
1742
  }
1681
1743
  _onDragOver(e) {
1682
1744
  if (!this._dragState || this._dragState.keyboard) return;
1683
- const r = this._dropTargetFromEvent(e);
1684
- if (!r || !this._canDrop(r, this._dragState.movedRootIds)) {
1745
+ const t = this._dropTargetFromEvent(e);
1746
+ if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
1685
1747
  this._queueDropTarget(null, e.timeStamp);
1686
1748
  return;
1687
1749
  }
1688
- e.preventDefault(), this._queueDropTarget(r, e.timeStamp), e.dataTransfer && (e.dataTransfer.dropEffect = this._dragState.clone ? "copy" : "move");
1750
+ e.preventDefault(), this._queueDropTarget(t, e.timeStamp), e.dataTransfer && (e.dataTransfer.dropEffect = this._dragState.clone ? "copy" : "move");
1689
1751
  }
1690
1752
  _onDrop(e) {
1691
1753
  if (!this._dragState || this._dragState.keyboard) return;
1692
- const r = this._dropTargetFromEvent(e);
1693
- !r || !this._canDrop(r, this._dragState.movedRootIds) || (e.preventDefault(), this._commitMove(r, this._dragState.movedRootIds, this._dragState.clone, "pointer"));
1754
+ const t = this._dropTargetFromEvent(e);
1755
+ !t || !this._canDrop(t, this._dragState.movedRootIds) || (e.preventDefault(), this._commitMove(t, this._dragState.movedRootIds, this._dragState.clone, "pointer"));
1694
1756
  }
1695
1757
  _onDocumentKeyDown(e) {
1696
1758
  e.key === "Escape" && (!this._dragState || this._dragState.keyboard || (e.preventDefault(), this._cancelDrag(!0)));
1697
1759
  }
1698
1760
  _onDragEnd() {
1699
- !this._dragState || this._dragState.keyboard || this._dragState.committed || (this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this._announce("Drag cancelled."), this.requestRender());
1761
+ !this._dragState || this._dragState.keyboard || this._dragState.committed || (this._setDraggingVisualState(this._draggingIds(), !1), this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this._announce("Drag cancelled."), this.requestRender());
1700
1762
  }
1701
1763
  _dropTargetFromEvent(e) {
1702
1764
  return this._dropTargetFromPath(e.composedPath(), e.clientX, e.clientY);
1703
1765
  }
1704
- _dropTargetFromPath(e, r, t) {
1705
- const i = e.find((h) => h instanceof HTMLElement && h.classList.contains("dropzone"));
1766
+ _dropTargetFromPath(e, t, r) {
1767
+ const i = e.find((y) => y instanceof HTMLElement && y.classList.contains("dropzone"));
1706
1768
  if (i) {
1707
- const h = {
1769
+ const y = {
1708
1770
  listId: i.getAttribute("data-list-id") || "",
1709
1771
  parentId: i.getAttribute("data-parent-id") || null,
1710
1772
  beforeId: i.getAttribute("data-before-id") || null,
1711
1773
  mode: i.getAttribute("data-mode") === "inside" ? "inside" : "before"
1712
1774
  };
1713
- if (h.listId) return h;
1775
+ if (y.listId) return y;
1714
1776
  }
1715
- const s = e.find((h) => h instanceof HTMLElement && h.classList.contains("item"));
1716
- if (!s) return null;
1717
- const a = s.getAttribute("data-id");
1718
- if (!a) return null;
1719
- const n = this._items.find((h) => h.id === a);
1777
+ const s = e.find((y) => y instanceof HTMLElement && y.classList.contains("item"));
1778
+ if (!s) {
1779
+ const R = e.find(
1780
+ ($) => $ instanceof HTMLElement && $.classList.contains("list") && $.hasAttribute("data-list-id")
1781
+ )?.getAttribute("data-list-id");
1782
+ return R ? { listId: R, parentId: null, beforeId: null, mode: "before" } : null;
1783
+ }
1784
+ const n = s.getAttribute("data-id");
1720
1785
  if (!n) return null;
1721
- const d = this._lists.find((h) => h.id === n.listId), o = s.getBoundingClientRect(), u = d?.orientation === "horizontal", p = u ? o.left : o.top, m = u ? o.right : o.bottom, _ = u ? r : t, f = Math.max(1, m - p), v = (_ - p) / f, b = this.getAttribute("allow-nesting") !== "false" && !n.disabled;
1722
- if (v <= 0.34)
1786
+ const a = this._items.find((y) => y.id === n);
1787
+ if (!a) return null;
1788
+ const d = this._lists.find((y) => y.id === a.listId), o = s.getBoundingClientRect(), u = d?.orientation === "horizontal", c = u ? o.left : o.top, h = u ? o.right : o.bottom, _ = u ? t : r, b = Math.max(1, h - c), S = (_ - c) / b, m = u && this._isRtl() ? 1 - S : S, v = this.getAttribute("allow-nesting") !== "false" && !a.disabled;
1789
+ if (m <= 0.34)
1723
1790
  return {
1724
- listId: n.listId,
1725
- parentId: n.parentId,
1726
- beforeId: n.id,
1791
+ listId: a.listId,
1792
+ parentId: a.parentId,
1793
+ beforeId: a.id,
1727
1794
  mode: "before"
1728
1795
  };
1729
- if (b && v >= 0.34 && v <= 0.74)
1796
+ if (v && m >= 0.34 && m <= 0.74)
1730
1797
  return {
1731
- listId: n.listId,
1732
- parentId: n.id,
1798
+ listId: a.listId,
1799
+ parentId: a.id,
1733
1800
  beforeId: null,
1734
1801
  mode: "inside"
1735
1802
  };
1736
- const x = $(this._items).get(D(n.listId, n.parentId)) || [], z = x.indexOf(n.id), k = z >= 0 && x[z + 1] || null;
1803
+ const A = E(this._items).get(k(a.listId, a.parentId)) || [], z = A.indexOf(a.id), f = z >= 0 && A[z + 1] || null;
1737
1804
  return {
1738
- listId: n.listId,
1739
- parentId: n.parentId,
1740
- beforeId: k,
1805
+ listId: a.listId,
1806
+ parentId: a.parentId,
1807
+ beforeId: f,
1741
1808
  mode: "before"
1742
1809
  };
1743
1810
  }
1744
- _dropTargetFromPoint(e, r) {
1745
- return this._dropTargetFromPath(this._pathFromPoint(e, r), e, r);
1811
+ _dropTargetFromPoint(e, t) {
1812
+ return this._dropTargetFromPath(this._pathFromPoint(e, t), e, t);
1746
1813
  }
1747
- _beginPointerDrag(e, r) {
1814
+ _beginPointerDrag(e, t) {
1748
1815
  if (!this._pointerGesture || this._dragState) return;
1749
- const t = this._items.find((i) => i.id === this._pointerGesture?.originId);
1750
- t && (this._dragState = {
1751
- snapshot: this._items.map(A),
1816
+ const r = this._items.find((i) => i.id === this._pointerGesture?.originId);
1817
+ r && (this._dragState = {
1818
+ snapshot: this._items.map(P),
1752
1819
  movedRootIds: [...this._pointerGesture.movedRootIds],
1753
1820
  originId: this._pointerGesture.originId,
1754
1821
  clone: this._pointerGesture.clone,
@@ -1757,41 +1824,41 @@ class ce extends ee {
1757
1824
  committed: !1
1758
1825
  }, this._pendingDropTarget = null, this._applyPointerPreview(
1759
1826
  e,
1760
- r,
1827
+ t,
1761
1828
  this._dragState.movedRootIds.length,
1762
1829
  this._dragState.clone
1763
1830
  ), this._setDraggingVisualState(this._draggingIds(), !0), this._announce(
1764
- this._dragState.clone ? `Dragging ${this._dragState.movedRootIds.length === 1 ? t.label : `${this._dragState.movedRootIds.length} items`} as a copy.` : `Dragging ${this._dragState.movedRootIds.length === 1 ? t.label : `${this._dragState.movedRootIds.length} items`}.`
1831
+ this._dragState.clone ? `Dragging ${this._dragState.movedRootIds.length === 1 ? r.label : `${this._dragState.movedRootIds.length} items`} as a copy.` : `Dragging ${this._dragState.movedRootIds.length === 1 ? r.label : `${this._dragState.movedRootIds.length} items`}.`
1765
1832
  ));
1766
1833
  }
1767
1834
  _onPointerDown(e) {
1768
- const r = this._dragActivatorFromPath(e.composedPath()), t = r?.id;
1769
- if (!r || !t) return;
1835
+ const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
1836
+ if (!t || !r) return;
1770
1837
  if (this._isDragLocked()) {
1771
1838
  e.preventDefault(), this._announce("Dragging is disabled right now.");
1772
1839
  return;
1773
1840
  }
1774
- const i = this._items.find((a) => a.id === t);
1841
+ const i = this._items.find((n) => n.id === r);
1775
1842
  if (!i || i.disabled || i.dragDisabled) {
1776
1843
  e.preventDefault();
1777
1844
  return;
1778
1845
  }
1779
1846
  e.preventDefault();
1780
1847
  try {
1781
- r.element.setPointerCapture?.(e.pointerId);
1848
+ t.element.setPointerCapture?.(e.pointerId);
1782
1849
  } catch {
1783
1850
  }
1784
- const s = this._selection.includes(t) ? this._selectedRootIds(t) : [t];
1851
+ const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
1785
1852
  this._pointerGesture = {
1786
1853
  pointerId: e.pointerId,
1787
1854
  pointerType: e.pointerType,
1788
- originId: t,
1855
+ originId: r,
1789
1856
  movedRootIds: s,
1790
- clone: this._itemClonesOnDrag(t),
1857
+ clone: this._itemClonesOnDrag(r),
1791
1858
  startX: e.clientX,
1792
1859
  startY: e.clientY,
1793
1860
  moved: !1,
1794
- captureTarget: r.element
1861
+ captureTarget: t.element
1795
1862
  };
1796
1863
  }
1797
1864
  _onPointerMove(e) {
@@ -1800,16 +1867,24 @@ class ce extends ee {
1800
1867
  if (Math.hypot(e.clientX - this._pointerGesture.startX, e.clientY - this._pointerGesture.startY) < 6) return;
1801
1868
  this._pointerGesture.moved = !0, this._beginPointerDrag(e.clientX, e.clientY);
1802
1869
  }
1803
- if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), !this._dragState.committed)) {
1804
- const r = this._dropTargetFromPoint(e.clientX, e.clientY);
1805
- if (!r || !this._canDrop(r, this._dragState.movedRootIds)) {
1870
+ if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), this._updateAutoScroll(e.clientX, e.clientY), !this._dragState.committed)) {
1871
+ const t = this._dropTargetFromPoint(e.clientX, e.clientY);
1872
+ if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
1806
1873
  this._queueDropTarget(null, e.timeStamp);
1807
1874
  return;
1808
1875
  }
1809
- this._queueDropTarget(r, e.timeStamp);
1876
+ this._queueDropTarget(t, e.timeStamp);
1810
1877
  }
1811
1878
  }
1812
1879
  }
1880
+ // Holding a dragged card near the top or bottom edge scrolls the page (or the nearest scrolling
1881
+ // container), so lists and positions that are off screen can be reached with the pointer.
1882
+ _updateAutoScroll(e, t) {
1883
+ this._autoScrollPoint = { x: e, y: t }, !this._autoScrollFrame && typeof requestAnimationFrame == "function" && (this._autoScrollFrame = requestAnimationFrame(this._autoScrollTick));
1884
+ }
1885
+ _stopAutoScroll() {
1886
+ this._autoScrollFrame && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(this._autoScrollFrame), this._autoScrollFrame = 0, this._autoScrollPoint = null;
1887
+ }
1813
1888
  _onPointerUp(e) {
1814
1889
  if (!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId) return;
1815
1890
  e.preventDefault();
@@ -1817,26 +1892,26 @@ class ce extends ee {
1817
1892
  this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId);
1818
1893
  } catch {
1819
1894
  }
1820
- const r = this._pointerGesture;
1821
- if (this._pointerGesture = null, !this._dragState || this._dragState.keyboard) return;
1822
- const t = r.moved ? this._releaseDropTarget(e.clientX, e.clientY) : null;
1823
- if (r.moved && t) {
1824
- this._commitMove(t, this._dragState.movedRootIds, this._dragState.clone, "pointer");
1895
+ const t = this._pointerGesture;
1896
+ if (this._pointerGesture = null, this._stopAutoScroll(), !this._dragState || this._dragState.keyboard) return;
1897
+ const r = t.moved ? this._releaseDropTarget(e.clientX, e.clientY) : null;
1898
+ if (t.moved && r) {
1899
+ this._commitMove(r, this._dragState.movedRootIds, this._dragState.clone, "pointer");
1825
1900
  return;
1826
1901
  }
1827
- r.moved ? this._cancelDrag(!0) : (this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this.requestRender());
1902
+ t.moved ? this._cancelDrag(!0) : (this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this.requestRender());
1828
1903
  }
1829
1904
  _onPointerCancel(e) {
1830
- !this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._dragState && this._cancelDrag(!0));
1905
+ !this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._stopAutoScroll(), this._dragState && this._cancelDrag(!0));
1831
1906
  }
1832
- _setSelection(e, r) {
1833
- const t = new Set(this._items.map((n) => n.id)), i = Array.from(new Set(e.filter((n) => t.has(n)))), s = [...this._selection];
1907
+ _setSelection(e, t) {
1908
+ const r = new Set(this._items.map((a) => a.id)), i = Array.from(new Set(e.filter((a) => r.has(a)))), s = [...this._selection];
1834
1909
  this._selection = i, this._rangeAnchorId = i[i.length - 1] || null, this._focusedId = i[i.length - 1] || this._focusedId;
1835
- const a = U(i);
1836
- if (this.getAttribute("selection") !== a) {
1837
- this._lastSelectionAttr = a, this._suppressAttributeRender = !0;
1910
+ const n = X(i);
1911
+ if (this.getAttribute("selection") !== n) {
1912
+ this._lastSelectionAttr = n, this._suppressAttributeRender = !0;
1838
1913
  try {
1839
- i.length ? this.setAttribute("selection", a) : this.removeAttribute("selection");
1914
+ i.length ? this.setAttribute("selection", n) : this.removeAttribute("selection");
1840
1915
  } finally {
1841
1916
  this._suppressAttributeRender = !1;
1842
1917
  }
@@ -1848,154 +1923,154 @@ class ce extends ee {
1848
1923
  },
1849
1924
  bubbles: !0,
1850
1925
  composed: !0
1851
- })), r !== "restore") {
1926
+ })), t !== "restore") {
1852
1927
  if (this._applyInteractiveStateInPlace({ restoreFocus: !0 })) return;
1853
1928
  this.requestRender();
1854
1929
  }
1855
1930
  }
1856
1931
  _toggleSelection(e) {
1857
- const r = this._selection.includes(e) ? this._selection.filter((t) => t !== e) : [...this._selection, e];
1858
- this._setSelection(r, "pointer"), this._announce(`${r.length} items selected.`);
1932
+ const t = this._selection.includes(e) ? this._selection.filter((r) => r !== e) : [...this._selection, e];
1933
+ this._setSelection(t, "pointer"), this._announce(`${t.length} items selected.`);
1859
1934
  }
1860
1935
  _selectRangeTo(e) {
1861
- const r = this._visibleItemIds(), t = this._rangeAnchorId || this._focusedId || e, i = r.indexOf(t), s = r.indexOf(e);
1936
+ const t = this._visibleItemIds(), r = this._rangeAnchorId || this._focusedId || e, i = t.indexOf(r), s = t.indexOf(e);
1862
1937
  if (i < 0 || s < 0) {
1863
1938
  this._setSelection([e], "pointer");
1864
1939
  return;
1865
1940
  }
1866
- const [a, n] = i <= s ? [i, s] : [s, i];
1867
- this._setSelection(r.slice(a, n + 1), "pointer"), this._announce(`${n - a + 1} items selected.`);
1941
+ const [n, a] = i <= s ? [i, s] : [s, i];
1942
+ this._setSelection(t.slice(n, a + 1), "pointer"), this._announce(`${a - n + 1} items selected.`);
1868
1943
  }
1869
1944
  _visibleItemIds() {
1870
1945
  const e = Q(this._items, new Set(this._selection), new Set(this._draggingIds()), this.filterQuery, this.sort);
1871
- return Array.from(e.values()).flat().filter((r) => !r.disabled).map((r) => r.id);
1946
+ return Array.from(e.values()).flat().filter((t) => !t.disabled).map((t) => t.id);
1872
1947
  }
1873
1948
  _selectedRootIds(e) {
1874
- const r = this._selection.length ? [...this._selection] : e ? [e] : [], t = P(this._items), i = new Set(r);
1875
- return r.filter((s) => {
1876
- const a = t.get(s);
1877
- if (!a) return !1;
1878
- let n = a.parentId;
1879
- for (; n; ) {
1880
- if (i.has(n)) return !1;
1881
- n = t.get(n)?.parentId ?? null;
1949
+ const t = this._selection.length ? [...this._selection] : e ? [e] : [], r = T(this._items), i = new Set(t);
1950
+ return t.filter((s) => {
1951
+ const n = r.get(s);
1952
+ if (!n) return !1;
1953
+ let a = n.parentId;
1954
+ for (; a; ) {
1955
+ if (i.has(a)) return !1;
1956
+ a = r.get(a)?.parentId ?? null;
1882
1957
  }
1883
- return !a.disabled;
1958
+ return !n.disabled;
1884
1959
  });
1885
1960
  }
1886
1961
  _draggingIds() {
1887
1962
  if (!this._dragState) return [];
1888
- const e = P(this._items), r = $(this._items), t = [], i = (s) => {
1889
- t.push(s);
1890
- const a = e.get(s);
1891
- if (!a) return;
1892
- (r.get(D(a.listId, s)) || []).forEach(i);
1963
+ const e = T(this._items), t = E(this._items), r = [], i = (s) => {
1964
+ r.push(s);
1965
+ const n = e.get(s);
1966
+ if (!n) return;
1967
+ (t.get(k(n.listId, s)) || []).forEach(i);
1893
1968
  };
1894
- return this._dragState.movedRootIds.forEach(i), t;
1969
+ return this._dragState.movedRootIds.forEach(i), r;
1895
1970
  }
1896
1971
  _itemClonesOnDrag(e) {
1897
- const r = this._items.find((i) => i.id === e);
1898
- return r ? r.cloneOnDrag ? !0 : !!this._lists.find((i) => i.id === r.listId)?.cloneOnDrag : !1;
1972
+ const t = this._items.find((i) => i.id === e);
1973
+ return t ? t.cloneOnDrag ? !0 : !!this._lists.find((i) => i.id === t.listId)?.cloneOnDrag : !1;
1899
1974
  }
1900
1975
  _isDragLocked() {
1901
1976
  return !!(this.hasAttribute("disabled") || this.sort !== "manual" || this.filterQuery && !this.hasAttribute("allow-filtered-drag"));
1902
1977
  }
1903
- _canDrop(e, r) {
1978
+ _canDrop(e, t) {
1904
1979
  if (this._isDragLocked()) return !1;
1905
- const t = this._lists.find((o) => o.id === e.listId);
1906
- if (!t || t.disabled) return !1;
1907
- const i = P(this._items), s = /* @__PURE__ */ new Set(), a = $(this._items), n = (o) => {
1980
+ const r = this._lists.find((o) => o.id === e.listId);
1981
+ if (!r || r.disabled) return !1;
1982
+ const i = T(this._items), s = /* @__PURE__ */ new Set(), n = E(this._items), a = (o) => {
1908
1983
  s.add(o);
1909
1984
  const u = i.get(o);
1910
- u && (a.get(D(u.listId, o)) || []).forEach(n);
1985
+ u && (n.get(k(u.listId, o)) || []).forEach(a);
1911
1986
  };
1912
- if (r.forEach(n), e.parentId && s.has(e.parentId) || e.beforeId && s.has(e.beforeId)) return !1;
1913
- const d = Array.from(new Set(r.map((o) => i.get(o)?.listId).filter(Boolean)));
1914
- return !(t.accepts?.length && d.some((o) => !t.accepts?.includes(o)) || e.mode === "inside" && this.getAttribute("allow-nesting") === "false");
1915
- }
1916
- _commitMove(e, r, t, i) {
1917
- if (!this._canDrop(e, r)) return;
1918
- const s = P(this._items), a = $(this._items), n = /* @__PURE__ */ new Set(), d = [], o = (c) => {
1919
- const w = s.get(c);
1920
- !w || n.has(c) || (n.add(c), d.push(c), (a.get(D(w.listId, c)) || []).forEach(o));
1987
+ if (t.forEach(a), e.parentId && s.has(e.parentId) || e.beforeId && s.has(e.beforeId)) return !1;
1988
+ const d = Array.from(new Set(t.map((o) => i.get(o)?.listId).filter(Boolean)));
1989
+ return !(r.accepts?.length && d.some((o) => !r.accepts?.includes(o)) || e.mode === "inside" && this.getAttribute("allow-nesting") === "false");
1990
+ }
1991
+ _commitMove(e, t, r, i) {
1992
+ if (!this._canDrop(e, t)) return;
1993
+ const s = T(this._items), n = E(this._items), a = /* @__PURE__ */ new Set(), d = [], o = (p) => {
1994
+ const w = s.get(p);
1995
+ !w || a.has(p) || (a.add(p), d.push(p), (n.get(k(w.listId, p)) || []).forEach(o));
1921
1996
  };
1922
- r.forEach(o);
1923
- const u = this._items.map(A), p = u.filter((c) => n.has(c.id)), m = t ? u.map(A) : u.filter((c) => !n.has(c.id)), _ = t ? p.map((c) => this._cloneSubtreeItem(c, d)) : p.map(A), f = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
1924
- t && p.forEach((c, w) => {
1925
- f.set(c.id, _[w].id), v.set(_[w].id, c.id);
1926
- }), _.forEach((c) => {
1927
- const w = t ? v.get(c.id) : c.id, C = w ? s.get(w) : null;
1928
- C && (t && (c.parentId = C.parentId && f.has(C.parentId) && f.get(C.parentId) || null), c.listId = e.listId);
1997
+ t.forEach(o);
1998
+ const u = this._items.map(P), c = u.filter((p) => a.has(p.id)), h = r ? u.map(P) : u.filter((p) => !a.has(p.id)), _ = r ? c.map((p) => this._cloneSubtreeItem(p, d)) : c.map(P), b = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
1999
+ r && c.forEach((p, w) => {
2000
+ b.set(p.id, _[w].id), S.set(_[w].id, p.id);
2001
+ }), _.forEach((p) => {
2002
+ const w = r ? S.get(p.id) : p.id, F = w ? s.get(w) : null;
2003
+ F && (r && (p.parentId = F.parentId && b.has(F.parentId) && b.get(F.parentId) || null), p.listId = e.listId);
1929
2004
  });
1930
- const b = r.map((c) => f.get(c) || c), y = [...m, ..._], x = $(m), z = D(e.listId, e.parentId), k = [...x.get(z) || []], h = e.beforeId ? k.indexOf(e.beforeId) : k.length, E = h >= 0 ? h : k.length;
1931
- k.splice(E, 0, ...b), x.set(z, k), $(_).forEach((c, w) => {
1932
- const [, C] = w.split("::");
1933
- (C || "") !== "__root__" && x.set(w, [...c]);
2005
+ const m = t.map((p) => b.get(p) || p), v = [...h, ..._], D = E(h), A = k(e.listId, e.parentId), z = [...D.get(A) || []], f = e.beforeId ? z.indexOf(e.beforeId) : z.length, y = f >= 0 ? f : z.length;
2006
+ z.splice(y, 0, ...m), D.set(A, z), E(_).forEach((p, w) => {
2007
+ const [, F] = w.split("::");
2008
+ (F || "") !== "__root__" && D.set(w, [...p]);
1934
2009
  });
1935
- const L = P(y);
1936
- b.forEach((c) => {
1937
- const w = L.get(c);
2010
+ const $ = T(v);
2011
+ m.forEach((p) => {
2012
+ const w = $.get(p);
1938
2013
  w && (w.parentId = e.parentId, w.listId = e.listId);
1939
2014
  });
1940
- const F = [], M = /* @__PURE__ */ new Set(), O = (c, w) => {
1941
- (x.get(D(c, w)) || []).forEach((N, Z) => {
1942
- const G = L.get(N);
1943
- !G || M.has(N) || (M.add(N), G.listId = c, G.parentId = w, G.order = Z, F.push(G), O(c, N));
2015
+ const O = [], L = /* @__PURE__ */ new Set(), q = (p, w) => {
2016
+ (D.get(k(p, w)) || []).forEach((V, Z) => {
2017
+ const N = $.get(V);
2018
+ !N || L.has(V) || (L.add(V), N.listId = p, N.parentId = w, N.order = Z, O.push(N), q(p, V));
1944
2019
  });
1945
2020
  };
1946
- this._lists.forEach((c) => O(c.id, null)), y.forEach((c) => {
1947
- M.has(c.id) || (c.parentId = null, F.push(c));
1948
- }), this._dragState && (this._dragState.committed = !0), this._items = F.map(A), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage();
1949
- const q = [...b], g = [...this._selection];
1950
- this._selection = q, this._focusedId = q[0] || null, this._pendingFocusId = this._focusedId, this._syncAttributesFromState();
1951
- const S = J(this._items);
1952
- this._persistSnapshot(S);
1953
- const T = r.map((c) => s.get(c)).filter((c) => !!c), R = t ? "clone" : e.mode === "inside" ? "nest" : T.some((c) => c.listId !== e.listId) ? "transfer" : "reorder", K = {
2021
+ this._lists.forEach((p) => q(p.id, null)), v.forEach((p) => {
2022
+ L.has(p.id) || (p.parentId = null, O.push(p));
2023
+ }), this._dragState && (this._dragState.committed = !0), this._items = O.map(P), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage();
2024
+ const H = [...m], g = [...this._selection];
2025
+ this._selection = H, this._focusedId = H[0] || null, this._pendingFocusId = this._focusedId, this._syncAttributesFromState();
2026
+ const x = J(this._items);
2027
+ this._persistSnapshot(x);
2028
+ const M = t.map((p) => s.get(p)).filter((p) => !!p), C = r ? "clone" : e.mode === "inside" ? "nest" : M.some((p) => p.listId !== e.listId) ? "transfer" : "reorder", G = {
1954
2029
  items: this.items,
1955
2030
  lists: this.lists,
1956
- selection: [...q],
2031
+ selection: [...H],
1957
2032
  previousSelection: g,
1958
- movedIds: [...b],
2033
+ movedIds: [...m],
1959
2034
  source: i,
1960
- operation: R,
1961
- persistence: S
2035
+ operation: C,
2036
+ persistence: x
1962
2037
  };
1963
2038
  this.dispatchEvent(new CustomEvent("change", {
1964
- detail: K,
2039
+ detail: G,
1965
2040
  bubbles: !0,
1966
2041
  composed: !0
1967
2042
  })), this.dispatchEvent(new CustomEvent("persist-request", {
1968
- detail: K,
2043
+ detail: G,
1969
2044
  bubbles: !0,
1970
2045
  composed: !0
1971
- })), this._announce(this._messageForMove(R, b.length, e)), this.requestRender();
2046
+ })), this._announce(this._messageForMove(C, m.length, e)), this.requestRender();
1972
2047
  }
1973
2048
  _syncAttributesFromState() {
1974
- const e = le(this._lists), r = de(this._items), t = U(this._selection);
1975
- this._lastListsAttr = e, this._lastItemsAttr = r, this._lastSelectionAttr = t, this._suppressAttributeRender = !0;
2049
+ const e = pe(this._lists), t = ue(this._items), r = X(this._selection);
2050
+ this._lastListsAttr = e, this._lastItemsAttr = t, this._lastSelectionAttr = r, this._suppressAttributeRender = !0;
1976
2051
  try {
1977
- this.setAttribute("lists", e), this.setAttribute("items", r), this._selection.length ? this.setAttribute("selection", t) : this.removeAttribute("selection");
2052
+ this.setAttribute("lists", e), this.setAttribute("items", t), this._selection.length ? this.setAttribute("selection", r) : this.removeAttribute("selection");
1978
2053
  } finally {
1979
2054
  this._suppressAttributeRender = !1;
1980
2055
  }
1981
2056
  }
1982
- _cloneSubtreeItem(e, r) {
1983
- const i = `copy-${this._cloneSeed++}`, a = `${e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id}--${i}`;
2057
+ _cloneSubtreeItem(e, t) {
2058
+ const i = `copy-${this._cloneSeed++}`, n = `${e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id}--${i}`;
1984
2059
  return {
1985
2060
  ...e,
1986
- id: a,
1987
- label: r[0] === e.id ? `${e.label} copy` : e.label
2061
+ id: n,
2062
+ label: t[0] === e.id ? `${e.label} copy` : e.label
1988
2063
  };
1989
2064
  }
1990
- _messageForMove(e, r, t) {
1991
- const s = this._lists.find((a) => a.id === t.listId)?.label || t.listId;
1992
- return e === "clone" ? `${r === 1 ? "Item copied" : `${r} items copied`} into ${s}.` : e === "nest" ? `${r === 1 ? "Item nested" : `${r} items nested`} in ${s}.` : e === "transfer" ? `${r === 1 ? "Item moved" : `${r} items moved`} to ${s}.` : `${r === 1 ? "Item reordered" : `${r} items reordered`} in ${s}.`;
2065
+ _messageForMove(e, t, r) {
2066
+ const s = this._lists.find((n) => n.id === r.listId)?.label || r.listId;
2067
+ return e === "clone" ? `${t === 1 ? "Item copied" : `${t} items copied`} into ${s}.` : e === "nest" ? `${t === 1 ? "Item nested" : `${t} items nested`} in ${s}.` : e === "transfer" ? `${t === 1 ? "Item moved" : `${t} items moved`} to ${s}.` : `${t === 1 ? "Item reordered" : `${t} items reordered`} in ${s}.`;
1993
2068
  }
1994
2069
  _persistSnapshot(e) {
1995
- const r = this.getAttribute("persist-key");
1996
- if (r)
2070
+ const t = this.getAttribute("persist-key");
2071
+ if (t)
1997
2072
  try {
1998
- window.localStorage.setItem(r, JSON.stringify(e));
2073
+ window.localStorage.setItem(t, JSON.stringify(e));
1999
2074
  } catch {
2000
2075
  }
2001
2076
  }
@@ -2003,12 +2078,12 @@ class ce extends ee {
2003
2078
  this._liveMessage = e, this._applyLiveMessage();
2004
2079
  }
2005
2080
  _cancelDrag(e) {
2006
- this._dragState && (this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._items = this._dragState.snapshot.map(A), this._dragState = null, this._pointerGesture = null, this._removeDragImage(), e && this._announce("Drag cancelled."), this._syncAttributesFromState(), this.requestRender());
2081
+ this._stopAutoScroll(), this._dragState && (this._setDraggingVisualState(this._draggingIds(), !1), this._pendingDropTarget = null, this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._items = this._dragState.snapshot.map(P), this._dragState = null, this._pointerGesture = null, this._removeDragImage(), e && this._announce("Drag cancelled."), this._syncAttributesFromState(), this.requestRender());
2007
2082
  }
2008
- _applyDragImage(e, r) {
2083
+ _applyDragImage(e, t) {
2009
2084
  this._removeDragImage();
2010
- const t = document.createElement("div");
2011
- t.textContent = r === 1 ? "Dragging item" : `Dragging ${r} items`, t.style.position = "fixed", t.style.top = "-999px", t.style.left = "-999px", t.style.padding = "8px 12px", t.style.borderRadius = "999px", t.style.background = "rgba(15, 23, 42, 0.92)", t.style.color = "#f8fafc", t.style.font = "600 12px/1 Inter, sans-serif", t.style.pointerEvents = "none", document.body.appendChild(t), e.setDragImage(t, 12, 12), this._dragImage = t;
2085
+ const r = document.createElement("div");
2086
+ r.textContent = t === 1 ? "Dragging item" : `Dragging ${t} items`, r.style.position = "fixed", r.style.top = "-999px", r.style.left = "-999px", r.style.padding = "8px 12px", r.style.borderRadius = "999px", r.style.background = "rgba(15, 23, 42, 0.92)", r.style.color = "#f8fafc", r.style.font = "600 12px/1 Inter, sans-serif", r.style.pointerEvents = "none", document.body.appendChild(r), e.setDragImage(r, 12, 12), this._dragImage = r;
2012
2087
  }
2013
2088
  _removeDragImage() {
2014
2089
  this._dragImage?.remove(), this._dragImage = null;
@@ -2016,61 +2091,68 @@ class ce extends ee {
2016
2091
  _removeDragPreviewOverlay() {
2017
2092
  this._dragPreviewOverlay?.remove(), this._dragPreviewOverlay = null;
2018
2093
  }
2019
- _applyPointerPreview(e, r, t, i) {
2094
+ _applyPointerPreview(e, t, r, i) {
2020
2095
  this._removeDragImage();
2021
2096
  const s = document.createElement("div");
2022
- s.textContent = i ? t === 1 ? "Copying item" : `Copying ${t} items` : t === 1 ? "Moving item" : `Moving ${t} items`, s.style.position = "fixed", s.style.top = "0", s.style.left = "0", s.style.zIndex = "2147483647", s.style.padding = "8px 12px", s.style.borderRadius = "999px", s.style.background = "rgba(15, 23, 42, 0.92)", s.style.color = "#f8fafc", s.style.font = "600 12px/1 Inter, sans-serif", s.style.pointerEvents = "none", s.style.boxShadow = "0 12px 28px rgba(15, 23, 42, 0.22)", document.body.appendChild(s), this._dragImage = s, this._movePointerPreview(e, r);
2097
+ s.textContent = i ? r === 1 ? "Copying item" : `Copying ${r} items` : r === 1 ? "Moving item" : `Moving ${r} items`, s.style.position = "fixed", s.style.top = "0", s.style.left = "0", s.style.zIndex = "2147483647", s.style.padding = "8px 12px", s.style.borderRadius = "999px", s.style.background = "rgba(15, 23, 42, 0.92)", s.style.color = "#f8fafc", s.style.font = "600 12px/1 Inter, sans-serif", s.style.pointerEvents = "none", s.style.boxShadow = "0 12px 28px rgba(15, 23, 42, 0.22)", document.body.appendChild(s), this._dragImage = s, this._movePointerPreview(e, t);
2023
2098
  }
2024
- _movePointerPreview(e, r) {
2025
- this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(r + 14)}px)`);
2099
+ _movePointerPreview(e, t) {
2100
+ this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(t + 14)}px)`);
2026
2101
  }
2027
2102
  _keyboardDropTargets() {
2028
- const e = P(this._items), r = $(this._items), t = [], i = (s, a) => {
2029
- (r.get(D(s, a)) || []).forEach((d) => {
2030
- const o = e.get(d);
2031
- !o || o.hidden || (t.push({
2032
- listId: s,
2103
+ const e = T(this._items), t = E(this._items), r = [], i = this.getAttribute("allow-nesting") !== "false", s = (n, a) => {
2104
+ const d = t.get(k(n, a)) || [];
2105
+ d.forEach((o) => {
2106
+ const u = e.get(o);
2107
+ !u || u.hidden || (r.push({
2108
+ listId: n,
2033
2109
  parentId: a,
2034
- beforeId: d,
2110
+ beforeId: o,
2035
2111
  mode: "before",
2036
- label: `Before ${o.label}`
2037
- }), this.getAttribute("allow-nesting") !== "false" && t.push({
2038
- listId: s,
2039
- parentId: d,
2112
+ label: `Before ${u.label}`
2113
+ }), i && r.push({
2114
+ listId: n,
2115
+ parentId: o,
2040
2116
  beforeId: null,
2041
2117
  mode: "inside",
2042
- label: `Nest inside ${o.label}`
2043
- }), i(s, d));
2044
- }), t.push({
2045
- listId: s,
2118
+ label: `Nest inside ${u.label}`
2119
+ }), s(n, o));
2120
+ }), a ? i && d.length > 0 && r.push({
2121
+ listId: n,
2122
+ parentId: a,
2123
+ beforeId: null,
2124
+ mode: "before",
2125
+ label: "After children"
2126
+ }) : r.push({
2127
+ listId: n,
2046
2128
  parentId: a,
2047
2129
  beforeId: null,
2048
2130
  mode: "before",
2049
- label: a ? "After children" : `End of ${this._lists.find((d) => d.id === s)?.label || s}`
2131
+ label: `End of ${this._lists.find((o) => o.id === n)?.label || n}`
2050
2132
  });
2051
2133
  };
2052
- return this._lists.forEach((s) => i(s.id, null)), t.filter((s) => this._canDrop(s, this._dragState?.movedRootIds || []));
2134
+ return this._lists.forEach((n) => s(n.id, null)), r.filter((n) => this._canDrop(n, this._dragState?.movedRootIds || []));
2053
2135
  }
2054
2136
  _initialKeyboardDropTarget(e) {
2055
- const r = this._items.find((t) => t.id === e);
2056
- return r ? {
2057
- listId: r.listId,
2058
- parentId: r.parentId,
2137
+ const t = this._items.find((r) => r.id === e);
2138
+ return t ? {
2139
+ listId: t.listId,
2140
+ parentId: t.parentId,
2059
2141
  beforeId: e,
2060
2142
  mode: "before"
2061
2143
  } : null;
2062
2144
  }
2063
2145
  _moveKeyboardDropTarget(e) {
2064
2146
  if (!this._dragState) return;
2065
- const r = this._keyboardDropTargets();
2066
- if (!r.length) return;
2067
- const t = Math.max(0, r.findIndex(
2147
+ const t = this._keyboardDropTargets();
2148
+ if (!t.length) return;
2149
+ const r = Math.max(0, t.findIndex(
2068
2150
  (s) => s.listId === this._dragState?.dropTarget?.listId && s.parentId === this._dragState?.dropTarget?.parentId && s.beforeId === this._dragState?.dropTarget?.beforeId && s.mode === this._dragState?.dropTarget?.mode
2069
- )), i = Math.max(0, Math.min(r.length - 1, t + e));
2070
- this._setDropTarget(r[i], { announceLabel: r[i].label });
2151
+ )), i = Math.max(0, Math.min(t.length - 1, r + e));
2152
+ this._setDropTarget(t[i], { announceLabel: t[i].label });
2071
2153
  }
2072
2154
  }
2073
- typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable", ce);
2155
+ typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable", he);
2074
2156
  export {
2075
- ce as UISortable
2157
+ he as UISortable
2076
2158
  };