@editora/ui-core 0.1.20 → 0.1.21

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.
@@ -1,5 +1,21 @@
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);
@@ -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);
@@ -731,10 +761,10 @@ function V(l) {
731
761
  return [];
732
762
  }
733
763
  }
734
- function I(l) {
764
+ function y(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)), f = i ? c.map(P) : c.filter((g) => !d.has(g.id)), _ = i ? h.map((g) => s(g, o)) : h.map(P), I = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
814
+ i && h.forEach((g, x) => {
815
+ I.set(g.id, _[x].id), m.set(_[x].id, g.id);
816
+ }), _.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 && I.has(M.parentId) && I.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) => I.get(g) || g), D = [...f, ..._], A = E(f), z = k(t.listId, t.parentId), b = [...A.get(z) || []], S = t.beforeId ? b.indexOf(t.beforeId) : b.length, R = S >= 0 ? S : b.length;
821
+ b.splice(R, 0, ...v), A.set(z, b), E(_).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,16 +874,16 @@ 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,
856
- listId: _,
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 f = typeof o?.listId == "string" && t.has(o.listId) ? o.listId : l[0].id;
883
+ r.push({
884
+ id: c,
885
+ label: h,
886
+ listId: f,
857
887
  parentId: typeof o?.parentId == "string" && o.parentId.trim() ? o.parentId.trim() : null,
858
888
  description: typeof o?.description == "string" ? o.description : "",
859
889
  order: Number.isFinite(o?.order) ? Number(o.order) : u,
@@ -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, f) => {
909
+ a.has(h.id) || (a.add(h.id), h.order = f, 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);
939
- }), _;
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));
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 f = [...n.get(k(c, h)) || []];
966
+ return i === "label" && f.sort((_, I) => {
967
+ const m = s.get(_), v = s.get(I);
968
+ return !m || !v ? 0 : m.label.localeCompare(v.label);
950
969
  }), f;
970
+ }, o = (c, h, f) => {
971
+ const _ = [];
972
+ return d(c, h).forEach((I) => {
973
+ const m = s.get(I);
974
+ if (!m || m.hidden) return;
975
+ const v = o(c, m.id);
976
+ !W(m, r) && v.length === 0 || (_.push({
977
+ id: m.id,
978
+ disabled: m.disabled
979
+ }), v.length && _.push(...v));
980
+ }), _;
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, f = this.getAttribute("allow-nesting") !== "false", _ = this.getAttribute("drop-indicator-visibility") === "always" ? "always" : "active", I = 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="${_}"
1109
+ data-dropzone-style="${I}"
1068
1110
  >
1069
1111
  <div class="toolbar" part="toolbar">
1070
- <div class="helper">${I(z)}</div>
1112
+ <div class="helper">${y(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((b) => {
1120
+ const S = o.get(b.id) || [], R = S.length ? this._renderListTree(n, b, u, t, f, a, m) : "", $ = b.disabled ? "This list is read-only." : b.cloneOnDrag ? "Dragging from this list creates a copy." : b.accepts?.length ? `Accepts drops from: ${b.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="${y(b.id)}"
1126
+ data-orientation="${b.orientation}"
1127
+ data-disabled="${b.disabled}"
1128
+ aria-label="${y(b.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="${y(b.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">${y(b.label)}</div>
1135
+ <span class="list-count">${S.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
+ ${b.description ? `<div class="list-description">${y(b.description)}</div>` : ""}
1138
+ ${$ ? `<div class="list-helper">${y($)}</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="listbox" aria-multiselectable="true" aria-label="${y(b.label)}">
1142
+ ${R || `<div class="list-custom-empty" part="list-custom-empty" data-list-empty-target="${y(b.id)}"></div><div class="empty">${y(b.emptyLabel)}</div>${this._renderDropzone({
1143
+ listId: b.id,
1102
1144
  parentId: null,
1103
1145
  beforeId: null,
1104
1146
  mode: "before"
@@ -1108,70 +1150,70 @@ class ce extends ee {
1108
1150
  `;
1109
1151
  }).join("")}
1110
1152
  </div>
1111
- <div class="sr-only" aria-live="polite" aria-atomic="true">${I(this._liveMessage)}</div>
1153
+ <div class="sr-only" aria-live="polite" aria-atomic="true">${y(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
- <div class="placeholder-kicker">${I(e.kicker)}</div>
1312
- <div class="placeholder-title">${I(e.title)}</div>
1313
- <div class="placeholder-description">${I(e.description)}</div>
1353
+ <div class="placeholder-kicker">${y(e.kicker)}</div>
1354
+ <div class="placeholder-title">${y(e.title)}</div>
1355
+ <div class="placeholder-description">${y(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)), f = 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(f)}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"), i.setAttribute("aria-grabbed", 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,154 +1390,163 @@ 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)) || [], f = this.sort === "label" ? [...h].sort((I, m) => {
1489
+ const v = d.get(I), D = d.get(m);
1490
+ return !v || !D ? 0 : v.label.localeCompare(D.label);
1491
+ }) : h;
1492
+ let _ = "";
1493
+ return f.forEach((I) => {
1494
+ const m = d.get(I);
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"') || (_ += this._renderDropzone({
1506
+ listId: t.id,
1507
+ parentId: c,
1508
+ beforeId: I,
1458
1509
  mode: "before"
1459
- }, "Drop here"), f += y);
1460
- }), f += this._renderDropzone({
1461
- listId: r.id,
1462
- parentId: p,
1510
+ }, "Drop here"), _ += v);
1511
+ }), _ += this._renderDropzone({
1512
+ listId: t.id,
1513
+ parentId: c,
1463
1514
  beforeId: null,
1464
1515
  mode: "before"
1465
- }, "Drop here"), f;
1516
+ }, "Drop here"), _;
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 = y(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), f = o ? !1 : r.has(e.id), _ = e.disabled, I = _ || 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(), b = z ? "custom" : A, S = !z && A === "handle";
1471
1522
  return `
1472
1523
  <div class="item-shell" data-item-shell="${d}">
1473
1524
  <article
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}"
1481
- data-dragging="${_}"
1482
- data-disabled="${f}"
1483
- data-drop-inside-active="${b ? "true" : "false"}"
1528
+ data-drag-handle-mode="${b}"
1529
+ ${!o && b === "item" ? 'data-drag-trigger="item"' : ""}
1530
+ data-selected="${h}"
1531
+ data-focused="${o ? "false" : t === e.id}"
1532
+ data-dragging="${f}"
1533
+ data-disabled="${_}"
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="${_}"
1538
+ aria-grabbed="${o ? "false" : f}"
1488
1539
  aria-hidden="${o ? "true" : "false"}"
1489
- tabindex="${o ? "-1" : r === e.id ? "0" : "-1"}"
1540
+ tabindex="${o ? "-1" : t === e.id ? "0" : "-1"}"
1490
1541
  >
1491
1542
  ${o ? `
1492
1543
  <div class="placeholder-content">
1493
- <div class="placeholder-kicker">${I(y)}</div>
1494
- <div class="placeholder-title">${I(e.label)}</div>
1495
- <div class="placeholder-description">${I(x)}</div>
1544
+ <div class="placeholder-kicker">${y(v)}</div>
1545
+ <div class="placeholder-title">${y(e.label)}</div>
1546
+ <div class="placeholder-description">${y(D)}</div>
1496
1547
  </div>
1497
1548
  ` : `
1498
- ${E ? `
1549
+ ${S ? `
1499
1550
  <button
1500
1551
  class="handle"
1501
1552
  part="handle"
@@ -1504,8 +1555,8 @@ class ce extends ee {
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
+ ${I ? "disabled" : ""}
1559
+ aria-label="Drag ${y(e.label)}"
1509
1560
  >
1510
1561
  <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
1511
1562
  <circle cx="5" cy="4" r="1.25"></circle>
@@ -1520,10 +1571,10 @@ class ce extends ee {
1520
1571
  <div class="item-content" data-action="select" data-id="${d}">
1521
1572
  <div class="item-custom-content" part="item-custom-content" data-item-content-target="${d}"></div>
1522
1573
  <div class="item-default-content">
1523
- <div class="item-title">${I(e.label)}</div>
1524
- ${e.description ? `<div class="item-description">${I(e.description)}</div>` : ""}
1574
+ <div class="item-title">${y(e.label)}</div>
1575
+ ${e.description ? `<div class="item-description">${y(e.description)}</div>` : ""}
1525
1576
  <div class="item-meta">
1526
- <span class="item-badge selection-badge" data-selection-badge="true" ${m && n ? "" : "hidden"}>${m && n ? "Selected" : ""}</span>
1577
+ <span class="item-badge selection-badge" data-selection-badge="true" ${h && a ? "" : "hidden"}>${h && a ? "Selected" : ""}</span>
1527
1578
  ${e.cloneOnDrag ? '<span class="item-badge">Clone on drag</span>' : ""}
1528
1579
  ${e.dragDisabled ? '<span class="item-badge">Pinned</span>' : ""}
1529
1580
  ${s ? '<span class="item-badge drop-badge">Nest here</span>' : ""}
@@ -1538,66 +1589,74 @@ class ce extends ee {
1538
1589
  beforeId: null,
1539
1590
  mode: "inside"
1540
1591
  }, "Nest here") : ""}
1541
- ${p ? `<div class="children">${u}</div>` : ""}
1592
+ ${c ? `<div class="children">${u}</div>` : ""}
1542
1593
  </div>
1543
1594
  `;
1544
1595
  }
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;
1596
+ _renderDropzone(e, t) {
1597
+ 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
1598
  return `
1548
1599
  <div
1549
1600
  class="dropzone"
1550
1601
  part="dropzone"
1551
- data-list-id="${I(e.listId)}"
1552
- data-parent-id="${I(e.parentId ?? "")}"
1553
- data-before-id="${I(e.beforeId ?? "")}"
1602
+ data-list-id="${y(e.listId)}"
1603
+ data-parent-id="${y(e.parentId ?? "")}"
1604
+ data-before-id="${y(e.beforeId ?? "")}"
1554
1605
  data-mode="${e.mode}"
1555
- data-active="${t ? "true" : "false"}"
1606
+ data-active="${r ? "true" : "false"}"
1556
1607
  aria-hidden="true"
1557
1608
  >
1558
- <span class="dropzone-label">${I(r)}</span>
1609
+ <span class="dropzone-label">${y(t)}</span>
1559
1610
  </div>
1560
1611
  `;
1561
1612
  }
1562
1613
  _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"));
1614
+ 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
1615
  if (i && i.kind !== "item") return;
1565
1616
  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;
1617
+ return r && !(e.target instanceof HTMLButtonElement), void 0;
1618
+ const n = s.getAttribute("data-id");
1619
+ if (!n) return;
1620
+ const a = this._items.find((o) => o.id === n);
1621
+ if (!a || a.disabled) return;
1571
1622
  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()) {
1623
+ 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
1624
  this._syncSelectionVisualState(), this._restorePendingFocus();
1574
1625
  return;
1575
1626
  }
1576
1627
  this.requestRender();
1577
1628
  }
1578
1629
  _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());
1630
+ const r = e.composedPath().find((i) => i instanceof HTMLElement && i.classList.contains("item"))?.getAttribute("data-id");
1631
+ r && (this._focusedId = r, this._syncSelectionVisualState());
1632
+ }
1633
+ // Keys typed into a control that lives inside an item (an <input> or <button> in a custom card)
1634
+ // belong to that control: swallowing Space/Enter/arrows there made it impossible to type a space
1635
+ // or press the button from the keyboard. The drag handle is part of the item, not a foreign control.
1636
+ _isForeignControl(e) {
1637
+ const t = e.composedPath()[0];
1638
+ 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
1639
  }
1582
1640
  _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";
1641
+ if (this._isForeignControl(e)) return;
1642
+ const t = this._visibleItemIds();
1643
+ if (!t.length) return;
1644
+ 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
1645
  if (!this._dragState?.keyboard) {
1587
- if (e.key === "ArrowDown" && !n || e.key === "ArrowRight" && n) {
1588
- e.preventDefault(), this._moveFocusBy(r, i, 1);
1646
+ if (e.key === o) {
1647
+ e.preventDefault(), this._moveFocusBy(t, i, 1);
1589
1648
  return;
1590
1649
  }
1591
- if (e.key === "ArrowUp" && !n || e.key === "ArrowLeft" && n) {
1592
- e.preventDefault(), this._moveFocusBy(r, i, -1);
1650
+ if (e.key === u) {
1651
+ e.preventDefault(), this._moveFocusBy(t, i, -1);
1593
1652
  return;
1594
1653
  }
1595
1654
  if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "a") {
1596
- e.preventDefault(), this._setSelection(r, "keyboard"), this._announce(`${r.length} items selected.`);
1655
+ e.preventDefault(), this._setSelection(t, "keyboard"), this._announce(`${t.length} items selected.`);
1597
1656
  return;
1598
1657
  }
1599
1658
  if (e.key === "Enter") {
1600
- e.preventDefault(), this._setSelection([t], "keyboard");
1659
+ e.preventDefault(), this._setSelection([r], "keyboard");
1601
1660
  return;
1602
1661
  }
1603
1662
  if (e.key === " " || e.code === "Space") {
@@ -1605,20 +1664,20 @@ class ce extends ee {
1605
1664
  this._announce("Dragging is disabled right now.");
1606
1665
  return;
1607
1666
  }
1608
- const d = this._selectedRootIds(t);
1609
- if (!d.length) return;
1610
- const o = this._itemClonesOnDrag(t);
1667
+ const c = this._selectedRootIds(r);
1668
+ if (!c.length) return;
1669
+ const h = this._itemClonesOnDrag(r);
1611
1670
  this._dragState = {
1612
- snapshot: this._items.map(A),
1613
- movedRootIds: d,
1614
- originId: t,
1615
- clone: o,
1671
+ snapshot: this._items.map(P),
1672
+ movedRootIds: c,
1673
+ originId: r,
1674
+ clone: h,
1616
1675
  keyboard: !0,
1617
- dropTarget: this._initialKeyboardDropTarget(t),
1676
+ dropTarget: this._initialKeyboardDropTarget(r),
1618
1677
  committed: !1
1619
1678
  };
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();
1679
+ const f = c.length === 1 ? `Lifted ${s?.label || "item"}.` : `Lifted ${c.length} items.`;
1680
+ this._announce(`${f} Use arrow keys to choose a destination.`), this.requestRender();
1622
1681
  return;
1623
1682
  }
1624
1683
  if (e.key === "Escape") {
@@ -1633,24 +1692,28 @@ class ce extends ee {
1633
1692
  }
1634
1693
  if (e.key === "Enter" || e.key === " " || e.code === "Space") {
1635
1694
  e.preventDefault();
1636
- const d = this._dragState.dropTarget;
1637
- if (!d) return;
1638
- this._commitMove(d, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
1695
+ const c = this._dragState.dropTarget;
1696
+ if (!c) return;
1697
+ this._commitMove(c, this._dragState.movedRootIds, this._dragState.clone, "keyboard");
1639
1698
  return;
1640
1699
  }
1641
1700
  if (["ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"].includes(e.key)) {
1642
1701
  e.preventDefault();
1643
- const d = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : -1;
1644
- this._moveKeyboardDropTarget(d);
1702
+ const c = d ? "ArrowLeft" : "ArrowRight", h = e.key === "ArrowDown" || e.key === c ? 1 : -1;
1703
+ this._moveKeyboardDropTarget(h);
1645
1704
  }
1646
1705
  }
1647
- _moveFocusBy(e, r, t) {
1648
- const i = Math.max(0, Math.min(e.length - 1, r + t)), s = e[i];
1706
+ _isRtl() {
1707
+ const e = this.ownerDocument?.defaultView?.getComputedStyle(this).direction;
1708
+ return e ? e === "rtl" : this.closest("[dir]")?.getAttribute("dir") === "rtl";
1709
+ }
1710
+ _moveFocusBy(e, t, r) {
1711
+ const i = Math.max(0, Math.min(e.length - 1, t + r)), s = e[i];
1649
1712
  this._focusedId = s, this._pendingFocusId = s, !this._applyInteractiveStateInPlace({ restoreFocus: !0 }) && this.requestRender();
1650
1713
  }
1651
1714
  _onDragStart(e) {
1652
- const r = this._dragActivatorFromPath(e.composedPath()), t = r?.id;
1653
- if (!r || !t) {
1715
+ const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
1716
+ if (!t || !r) {
1654
1717
  e.preventDefault();
1655
1718
  return;
1656
1719
  }
@@ -1658,97 +1721,102 @@ class ce extends ee {
1658
1721
  e.preventDefault(), this._announce("Dragging is disabled right now.");
1659
1722
  return;
1660
1723
  }
1661
- const i = this._items.find((n) => n.id === t);
1724
+ const i = this._items.find((a) => a.id === r);
1662
1725
  if (!i || i.disabled || i.dragDisabled) {
1663
1726
  e.preventDefault();
1664
1727
  return;
1665
1728
  }
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);
1729
+ const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
1730
+ this._selection.includes(r) || this._setSelection([r], "pointer");
1731
+ const n = this._itemClonesOnDrag(r);
1669
1732
  this._dragState = {
1670
- snapshot: this._items.map(A),
1733
+ snapshot: this._items.map(P),
1671
1734
  movedRootIds: s,
1672
- originId: t,
1673
- clone: a,
1735
+ originId: r,
1736
+ clone: n,
1674
1737
  keyboard: !1,
1675
1738
  dropTarget: null,
1676
1739
  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`}.`
1740
+ }, e.dataTransfer && (e.dataTransfer.effectAllowed = n ? "copyMove" : "move", e.dataTransfer.setData("text/plain", s.join(",")), this._applyDragImage(e.dataTransfer, s.length)), this._announce(
1741
+ n ? `Dragging ${s.length === 1 ? i.label : `${s.length} items`} as a copy.` : `Dragging ${s.length === 1 ? i.label : `${s.length} items`}.`
1679
1742
  ), this.requestRender();
1680
1743
  }
1681
1744
  _onDragOver(e) {
1682
1745
  if (!this._dragState || this._dragState.keyboard) return;
1683
- const r = this._dropTargetFromEvent(e);
1684
- if (!r || !this._canDrop(r, this._dragState.movedRootIds)) {
1746
+ const t = this._dropTargetFromEvent(e);
1747
+ if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
1685
1748
  this._queueDropTarget(null, e.timeStamp);
1686
1749
  return;
1687
1750
  }
1688
- e.preventDefault(), this._queueDropTarget(r, e.timeStamp), e.dataTransfer && (e.dataTransfer.dropEffect = this._dragState.clone ? "copy" : "move");
1751
+ e.preventDefault(), this._queueDropTarget(t, e.timeStamp), e.dataTransfer && (e.dataTransfer.dropEffect = this._dragState.clone ? "copy" : "move");
1689
1752
  }
1690
1753
  _onDrop(e) {
1691
1754
  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"));
1755
+ const t = this._dropTargetFromEvent(e);
1756
+ !t || !this._canDrop(t, this._dragState.movedRootIds) || (e.preventDefault(), this._commitMove(t, this._dragState.movedRootIds, this._dragState.clone, "pointer"));
1694
1757
  }
1695
1758
  _onDocumentKeyDown(e) {
1696
1759
  e.key === "Escape" && (!this._dragState || this._dragState.keyboard || (e.preventDefault(), this._cancelDrag(!0)));
1697
1760
  }
1698
1761
  _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());
1762
+ !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
1763
  }
1701
1764
  _dropTargetFromEvent(e) {
1702
1765
  return this._dropTargetFromPath(e.composedPath(), e.clientX, e.clientY);
1703
1766
  }
1704
- _dropTargetFromPath(e, r, t) {
1705
- const i = e.find((h) => h instanceof HTMLElement && h.classList.contains("dropzone"));
1767
+ _dropTargetFromPath(e, t, r) {
1768
+ const i = e.find((S) => S instanceof HTMLElement && S.classList.contains("dropzone"));
1706
1769
  if (i) {
1707
- const h = {
1770
+ const S = {
1708
1771
  listId: i.getAttribute("data-list-id") || "",
1709
1772
  parentId: i.getAttribute("data-parent-id") || null,
1710
1773
  beforeId: i.getAttribute("data-before-id") || null,
1711
1774
  mode: i.getAttribute("data-mode") === "inside" ? "inside" : "before"
1712
1775
  };
1713
- if (h.listId) return h;
1776
+ if (S.listId) return S;
1714
1777
  }
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);
1778
+ const s = e.find((S) => S instanceof HTMLElement && S.classList.contains("item"));
1779
+ if (!s) {
1780
+ const R = e.find(
1781
+ ($) => $ instanceof HTMLElement && $.classList.contains("list") && $.hasAttribute("data-list-id")
1782
+ )?.getAttribute("data-list-id");
1783
+ return R ? { listId: R, parentId: null, beforeId: null, mode: "before" } : null;
1784
+ }
1785
+ const n = s.getAttribute("data-id");
1720
1786
  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)
1787
+ const a = this._items.find((S) => S.id === n);
1788
+ if (!a) return null;
1789
+ const d = this._lists.find((S) => S.id === a.listId), o = s.getBoundingClientRect(), u = d?.orientation === "horizontal", c = u ? o.left : o.top, h = u ? o.right : o.bottom, f = u ? t : r, _ = Math.max(1, h - c), I = (f - c) / _, m = u && this._isRtl() ? 1 - I : I, v = this.getAttribute("allow-nesting") !== "false" && !a.disabled;
1790
+ if (m <= 0.34)
1723
1791
  return {
1724
- listId: n.listId,
1725
- parentId: n.parentId,
1726
- beforeId: n.id,
1792
+ listId: a.listId,
1793
+ parentId: a.parentId,
1794
+ beforeId: a.id,
1727
1795
  mode: "before"
1728
1796
  };
1729
- if (b && v >= 0.34 && v <= 0.74)
1797
+ if (v && m >= 0.34 && m <= 0.74)
1730
1798
  return {
1731
- listId: n.listId,
1732
- parentId: n.id,
1799
+ listId: a.listId,
1800
+ parentId: a.id,
1733
1801
  beforeId: null,
1734
1802
  mode: "inside"
1735
1803
  };
1736
- const x = $(this._items).get(D(n.listId, n.parentId)) || [], z = x.indexOf(n.id), k = z >= 0 && x[z + 1] || null;
1804
+ const A = E(this._items).get(k(a.listId, a.parentId)) || [], z = A.indexOf(a.id), b = z >= 0 && A[z + 1] || null;
1737
1805
  return {
1738
- listId: n.listId,
1739
- parentId: n.parentId,
1740
- beforeId: k,
1806
+ listId: a.listId,
1807
+ parentId: a.parentId,
1808
+ beforeId: b,
1741
1809
  mode: "before"
1742
1810
  };
1743
1811
  }
1744
- _dropTargetFromPoint(e, r) {
1745
- return this._dropTargetFromPath(this._pathFromPoint(e, r), e, r);
1812
+ _dropTargetFromPoint(e, t) {
1813
+ return this._dropTargetFromPath(this._pathFromPoint(e, t), e, t);
1746
1814
  }
1747
- _beginPointerDrag(e, r) {
1815
+ _beginPointerDrag(e, t) {
1748
1816
  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),
1817
+ const r = this._items.find((i) => i.id === this._pointerGesture?.originId);
1818
+ r && (this._dragState = {
1819
+ snapshot: this._items.map(P),
1752
1820
  movedRootIds: [...this._pointerGesture.movedRootIds],
1753
1821
  originId: this._pointerGesture.originId,
1754
1822
  clone: this._pointerGesture.clone,
@@ -1757,41 +1825,41 @@ class ce extends ee {
1757
1825
  committed: !1
1758
1826
  }, this._pendingDropTarget = null, this._applyPointerPreview(
1759
1827
  e,
1760
- r,
1828
+ t,
1761
1829
  this._dragState.movedRootIds.length,
1762
1830
  this._dragState.clone
1763
1831
  ), 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`}.`
1832
+ 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
1833
  ));
1766
1834
  }
1767
1835
  _onPointerDown(e) {
1768
- const r = this._dragActivatorFromPath(e.composedPath()), t = r?.id;
1769
- if (!r || !t) return;
1836
+ const t = this._dragActivatorFromPath(e.composedPath()), r = t?.id;
1837
+ if (!t || !r) return;
1770
1838
  if (this._isDragLocked()) {
1771
1839
  e.preventDefault(), this._announce("Dragging is disabled right now.");
1772
1840
  return;
1773
1841
  }
1774
- const i = this._items.find((a) => a.id === t);
1842
+ const i = this._items.find((n) => n.id === r);
1775
1843
  if (!i || i.disabled || i.dragDisabled) {
1776
1844
  e.preventDefault();
1777
1845
  return;
1778
1846
  }
1779
1847
  e.preventDefault();
1780
1848
  try {
1781
- r.element.setPointerCapture?.(e.pointerId);
1849
+ t.element.setPointerCapture?.(e.pointerId);
1782
1850
  } catch {
1783
1851
  }
1784
- const s = this._selection.includes(t) ? this._selectedRootIds(t) : [t];
1852
+ const s = this._selection.includes(r) ? this._selectedRootIds(r) : [r];
1785
1853
  this._pointerGesture = {
1786
1854
  pointerId: e.pointerId,
1787
1855
  pointerType: e.pointerType,
1788
- originId: t,
1856
+ originId: r,
1789
1857
  movedRootIds: s,
1790
- clone: this._itemClonesOnDrag(t),
1858
+ clone: this._itemClonesOnDrag(r),
1791
1859
  startX: e.clientX,
1792
1860
  startY: e.clientY,
1793
1861
  moved: !1,
1794
- captureTarget: r.element
1862
+ captureTarget: t.element
1795
1863
  };
1796
1864
  }
1797
1865
  _onPointerMove(e) {
@@ -1800,16 +1868,24 @@ class ce extends ee {
1800
1868
  if (Math.hypot(e.clientX - this._pointerGesture.startX, e.clientY - this._pointerGesture.startY) < 6) return;
1801
1869
  this._pointerGesture.moved = !0, this._beginPointerDrag(e.clientX, e.clientY);
1802
1870
  }
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)) {
1871
+ if (!(!this._dragState || this._dragState.keyboard) && (this._movePointerPreview(e.clientX, e.clientY), this._updateAutoScroll(e.clientX, e.clientY), !this._dragState.committed)) {
1872
+ const t = this._dropTargetFromPoint(e.clientX, e.clientY);
1873
+ if (!t || !this._canDrop(t, this._dragState.movedRootIds)) {
1806
1874
  this._queueDropTarget(null, e.timeStamp);
1807
1875
  return;
1808
1876
  }
1809
- this._queueDropTarget(r, e.timeStamp);
1877
+ this._queueDropTarget(t, e.timeStamp);
1810
1878
  }
1811
1879
  }
1812
1880
  }
1881
+ // Holding a dragged card near the top or bottom edge scrolls the page (or the nearest scrolling
1882
+ // container), so lists and positions that are off screen can be reached with the pointer.
1883
+ _updateAutoScroll(e, t) {
1884
+ this._autoScrollPoint = { x: e, y: t }, !this._autoScrollFrame && typeof requestAnimationFrame == "function" && (this._autoScrollFrame = requestAnimationFrame(this._autoScrollTick));
1885
+ }
1886
+ _stopAutoScroll() {
1887
+ this._autoScrollFrame && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(this._autoScrollFrame), this._autoScrollFrame = 0, this._autoScrollPoint = null;
1888
+ }
1813
1889
  _onPointerUp(e) {
1814
1890
  if (!this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId) return;
1815
1891
  e.preventDefault();
@@ -1817,26 +1893,26 @@ class ce extends ee {
1817
1893
  this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId);
1818
1894
  } catch {
1819
1895
  }
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");
1896
+ const t = this._pointerGesture;
1897
+ if (this._pointerGesture = null, this._stopAutoScroll(), !this._dragState || this._dragState.keyboard) return;
1898
+ const r = t.moved ? this._releaseDropTarget(e.clientX, e.clientY) : null;
1899
+ if (t.moved && r) {
1900
+ this._commitMove(r, this._dragState.movedRootIds, this._dragState.clone, "pointer");
1825
1901
  return;
1826
1902
  }
1827
- r.moved ? this._cancelDrag(!0) : (this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this.requestRender());
1903
+ t.moved ? this._cancelDrag(!0) : (this._setDropTargetVisualState(this._dragState.dropTarget, !1), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage(), this.requestRender());
1828
1904
  }
1829
1905
  _onPointerCancel(e) {
1830
- !this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._dragState && this._cancelDrag(!0));
1906
+ !this._pointerGesture || e.pointerId !== this._pointerGesture.pointerId || (this._pointerGesture = null, this._stopAutoScroll(), this._dragState && this._cancelDrag(!0));
1831
1907
  }
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];
1908
+ _setSelection(e, t) {
1909
+ 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
1910
  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;
1911
+ const n = X(i);
1912
+ if (this.getAttribute("selection") !== n) {
1913
+ this._lastSelectionAttr = n, this._suppressAttributeRender = !0;
1838
1914
  try {
1839
- i.length ? this.setAttribute("selection", a) : this.removeAttribute("selection");
1915
+ i.length ? this.setAttribute("selection", n) : this.removeAttribute("selection");
1840
1916
  } finally {
1841
1917
  this._suppressAttributeRender = !1;
1842
1918
  }
@@ -1848,154 +1924,154 @@ class ce extends ee {
1848
1924
  },
1849
1925
  bubbles: !0,
1850
1926
  composed: !0
1851
- })), r !== "restore") {
1927
+ })), t !== "restore") {
1852
1928
  if (this._applyInteractiveStateInPlace({ restoreFocus: !0 })) return;
1853
1929
  this.requestRender();
1854
1930
  }
1855
1931
  }
1856
1932
  _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.`);
1933
+ const t = this._selection.includes(e) ? this._selection.filter((r) => r !== e) : [...this._selection, e];
1934
+ this._setSelection(t, "pointer"), this._announce(`${t.length} items selected.`);
1859
1935
  }
1860
1936
  _selectRangeTo(e) {
1861
- const r = this._visibleItemIds(), t = this._rangeAnchorId || this._focusedId || e, i = r.indexOf(t), s = r.indexOf(e);
1937
+ const t = this._visibleItemIds(), r = this._rangeAnchorId || this._focusedId || e, i = t.indexOf(r), s = t.indexOf(e);
1862
1938
  if (i < 0 || s < 0) {
1863
1939
  this._setSelection([e], "pointer");
1864
1940
  return;
1865
1941
  }
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.`);
1942
+ const [n, a] = i <= s ? [i, s] : [s, i];
1943
+ this._setSelection(t.slice(n, a + 1), "pointer"), this._announce(`${a - n + 1} items selected.`);
1868
1944
  }
1869
1945
  _visibleItemIds() {
1870
1946
  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);
1947
+ return Array.from(e.values()).flat().filter((t) => !t.disabled).map((t) => t.id);
1872
1948
  }
1873
1949
  _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;
1950
+ const t = this._selection.length ? [...this._selection] : e ? [e] : [], r = T(this._items), i = new Set(t);
1951
+ return t.filter((s) => {
1952
+ const n = r.get(s);
1953
+ if (!n) return !1;
1954
+ let a = n.parentId;
1955
+ for (; a; ) {
1956
+ if (i.has(a)) return !1;
1957
+ a = r.get(a)?.parentId ?? null;
1882
1958
  }
1883
- return !a.disabled;
1959
+ return !n.disabled;
1884
1960
  });
1885
1961
  }
1886
1962
  _draggingIds() {
1887
1963
  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);
1964
+ const e = T(this._items), t = E(this._items), r = [], i = (s) => {
1965
+ r.push(s);
1966
+ const n = e.get(s);
1967
+ if (!n) return;
1968
+ (t.get(k(n.listId, s)) || []).forEach(i);
1893
1969
  };
1894
- return this._dragState.movedRootIds.forEach(i), t;
1970
+ return this._dragState.movedRootIds.forEach(i), r;
1895
1971
  }
1896
1972
  _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;
1973
+ const t = this._items.find((i) => i.id === e);
1974
+ return t ? t.cloneOnDrag ? !0 : !!this._lists.find((i) => i.id === t.listId)?.cloneOnDrag : !1;
1899
1975
  }
1900
1976
  _isDragLocked() {
1901
1977
  return !!(this.hasAttribute("disabled") || this.sort !== "manual" || this.filterQuery && !this.hasAttribute("allow-filtered-drag"));
1902
1978
  }
1903
- _canDrop(e, r) {
1979
+ _canDrop(e, t) {
1904
1980
  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) => {
1981
+ const r = this._lists.find((o) => o.id === e.listId);
1982
+ if (!r || r.disabled) return !1;
1983
+ const i = T(this._items), s = /* @__PURE__ */ new Set(), n = E(this._items), a = (o) => {
1908
1984
  s.add(o);
1909
1985
  const u = i.get(o);
1910
- u && (a.get(D(u.listId, o)) || []).forEach(n);
1986
+ u && (n.get(k(u.listId, o)) || []).forEach(a);
1911
1987
  };
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));
1988
+ if (t.forEach(a), e.parentId && s.has(e.parentId) || e.beforeId && s.has(e.beforeId)) return !1;
1989
+ const d = Array.from(new Set(t.map((o) => i.get(o)?.listId).filter(Boolean)));
1990
+ return !(r.accepts?.length && d.some((o) => !r.accepts?.includes(o)) || e.mode === "inside" && this.getAttribute("allow-nesting") === "false");
1991
+ }
1992
+ _commitMove(e, t, r, i) {
1993
+ if (!this._canDrop(e, t)) return;
1994
+ const s = T(this._items), n = E(this._items), a = /* @__PURE__ */ new Set(), d = [], o = (p) => {
1995
+ const w = s.get(p);
1996
+ !w || a.has(p) || (a.add(p), d.push(p), (n.get(k(w.listId, p)) || []).forEach(o));
1921
1997
  };
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);
1998
+ t.forEach(o);
1999
+ 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)), f = r ? c.map((p) => this._cloneSubtreeItem(p, d)) : c.map(P), _ = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
2000
+ r && c.forEach((p, w) => {
2001
+ _.set(p.id, f[w].id), I.set(f[w].id, p.id);
2002
+ }), f.forEach((p) => {
2003
+ const w = r ? I.get(p.id) : p.id, F = w ? s.get(w) : null;
2004
+ F && (r && (p.parentId = F.parentId && _.has(F.parentId) && _.get(F.parentId) || null), p.listId = e.listId);
1929
2005
  });
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]);
2006
+ const m = t.map((p) => _.get(p) || p), v = [...h, ...f], D = E(h), A = k(e.listId, e.parentId), z = [...D.get(A) || []], b = e.beforeId ? z.indexOf(e.beforeId) : z.length, S = b >= 0 ? b : z.length;
2007
+ z.splice(S, 0, ...m), D.set(A, z), E(f).forEach((p, w) => {
2008
+ const [, F] = w.split("::");
2009
+ (F || "") !== "__root__" && D.set(w, [...p]);
1934
2010
  });
1935
- const L = P(y);
1936
- b.forEach((c) => {
1937
- const w = L.get(c);
2011
+ const $ = T(v);
2012
+ m.forEach((p) => {
2013
+ const w = $.get(p);
1938
2014
  w && (w.parentId = e.parentId, w.listId = e.listId);
1939
2015
  });
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));
2016
+ const O = [], L = /* @__PURE__ */ new Set(), q = (p, w) => {
2017
+ (D.get(k(p, w)) || []).forEach((V, Z) => {
2018
+ const N = $.get(V);
2019
+ !N || L.has(V) || (L.add(V), N.listId = p, N.parentId = w, N.order = Z, O.push(N), q(p, V));
1944
2020
  });
1945
2021
  };
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 = {
2022
+ this._lists.forEach((p) => q(p.id, null)), v.forEach((p) => {
2023
+ L.has(p.id) || (p.parentId = null, O.push(p));
2024
+ }), this._dragState && (this._dragState.committed = !0), this._items = O.map(P), this._clearPointerDragPreview(), this._dragState = null, this._removeDragImage();
2025
+ const H = [...m], g = [...this._selection];
2026
+ this._selection = H, this._focusedId = H[0] || null, this._pendingFocusId = this._focusedId, this._syncAttributesFromState();
2027
+ const x = J(this._items);
2028
+ this._persistSnapshot(x);
2029
+ 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
2030
  items: this.items,
1955
2031
  lists: this.lists,
1956
- selection: [...q],
2032
+ selection: [...H],
1957
2033
  previousSelection: g,
1958
- movedIds: [...b],
2034
+ movedIds: [...m],
1959
2035
  source: i,
1960
- operation: R,
1961
- persistence: S
2036
+ operation: C,
2037
+ persistence: x
1962
2038
  };
1963
2039
  this.dispatchEvent(new CustomEvent("change", {
1964
- detail: K,
2040
+ detail: G,
1965
2041
  bubbles: !0,
1966
2042
  composed: !0
1967
2043
  })), this.dispatchEvent(new CustomEvent("persist-request", {
1968
- detail: K,
2044
+ detail: G,
1969
2045
  bubbles: !0,
1970
2046
  composed: !0
1971
- })), this._announce(this._messageForMove(R, b.length, e)), this.requestRender();
2047
+ })), this._announce(this._messageForMove(C, m.length, e)), this.requestRender();
1972
2048
  }
1973
2049
  _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;
2050
+ const e = pe(this._lists), t = ue(this._items), r = X(this._selection);
2051
+ this._lastListsAttr = e, this._lastItemsAttr = t, this._lastSelectionAttr = r, this._suppressAttributeRender = !0;
1976
2052
  try {
1977
- this.setAttribute("lists", e), this.setAttribute("items", r), this._selection.length ? this.setAttribute("selection", t) : this.removeAttribute("selection");
2053
+ this.setAttribute("lists", e), this.setAttribute("items", t), this._selection.length ? this.setAttribute("selection", r) : this.removeAttribute("selection");
1978
2054
  } finally {
1979
2055
  this._suppressAttributeRender = !1;
1980
2056
  }
1981
2057
  }
1982
- _cloneSubtreeItem(e, r) {
1983
- const i = `copy-${this._cloneSeed++}`, a = `${e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id}--${i}`;
2058
+ _cloneSubtreeItem(e, t) {
2059
+ const i = `copy-${this._cloneSeed++}`, n = `${e.id.includes("--copy-") ? e.id.split("--copy-")[0] : e.id}--${i}`;
1984
2060
  return {
1985
2061
  ...e,
1986
- id: a,
1987
- label: r[0] === e.id ? `${e.label} copy` : e.label
2062
+ id: n,
2063
+ label: t[0] === e.id ? `${e.label} copy` : e.label
1988
2064
  };
1989
2065
  }
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}.`;
2066
+ _messageForMove(e, t, r) {
2067
+ const s = this._lists.find((n) => n.id === r.listId)?.label || r.listId;
2068
+ 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
2069
  }
1994
2070
  _persistSnapshot(e) {
1995
- const r = this.getAttribute("persist-key");
1996
- if (r)
2071
+ const t = this.getAttribute("persist-key");
2072
+ if (t)
1997
2073
  try {
1998
- window.localStorage.setItem(r, JSON.stringify(e));
2074
+ window.localStorage.setItem(t, JSON.stringify(e));
1999
2075
  } catch {
2000
2076
  }
2001
2077
  }
@@ -2003,12 +2079,12 @@ class ce extends ee {
2003
2079
  this._liveMessage = e, this._applyLiveMessage();
2004
2080
  }
2005
2081
  _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());
2082
+ 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
2083
  }
2008
- _applyDragImage(e, r) {
2084
+ _applyDragImage(e, t) {
2009
2085
  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;
2086
+ const r = document.createElement("div");
2087
+ 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
2088
  }
2013
2089
  _removeDragImage() {
2014
2090
  this._dragImage?.remove(), this._dragImage = null;
@@ -2016,61 +2092,68 @@ class ce extends ee {
2016
2092
  _removeDragPreviewOverlay() {
2017
2093
  this._dragPreviewOverlay?.remove(), this._dragPreviewOverlay = null;
2018
2094
  }
2019
- _applyPointerPreview(e, r, t, i) {
2095
+ _applyPointerPreview(e, t, r, i) {
2020
2096
  this._removeDragImage();
2021
2097
  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);
2098
+ 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
2099
  }
2024
- _movePointerPreview(e, r) {
2025
- this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(r + 14)}px)`);
2100
+ _movePointerPreview(e, t) {
2101
+ this._dragImage && (this._dragImage.style.transform = `translate(${Math.round(e + 14)}px, ${Math.round(t + 14)}px)`);
2026
2102
  }
2027
2103
  _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,
2104
+ const e = T(this._items), t = E(this._items), r = [], i = this.getAttribute("allow-nesting") !== "false", s = (n, a) => {
2105
+ const d = t.get(k(n, a)) || [];
2106
+ d.forEach((o) => {
2107
+ const u = e.get(o);
2108
+ !u || u.hidden || (r.push({
2109
+ listId: n,
2033
2110
  parentId: a,
2034
- beforeId: d,
2111
+ beforeId: o,
2035
2112
  mode: "before",
2036
- label: `Before ${o.label}`
2037
- }), this.getAttribute("allow-nesting") !== "false" && t.push({
2038
- listId: s,
2039
- parentId: d,
2113
+ label: `Before ${u.label}`
2114
+ }), i && r.push({
2115
+ listId: n,
2116
+ parentId: o,
2040
2117
  beforeId: null,
2041
2118
  mode: "inside",
2042
- label: `Nest inside ${o.label}`
2043
- }), i(s, d));
2044
- }), t.push({
2045
- listId: s,
2119
+ label: `Nest inside ${u.label}`
2120
+ }), s(n, o));
2121
+ }), a ? i && d.length > 0 && r.push({
2122
+ listId: n,
2123
+ parentId: a,
2124
+ beforeId: null,
2125
+ mode: "before",
2126
+ label: "After children"
2127
+ }) : r.push({
2128
+ listId: n,
2046
2129
  parentId: a,
2047
2130
  beforeId: null,
2048
2131
  mode: "before",
2049
- label: a ? "After children" : `End of ${this._lists.find((d) => d.id === s)?.label || s}`
2132
+ label: `End of ${this._lists.find((o) => o.id === n)?.label || n}`
2050
2133
  });
2051
2134
  };
2052
- return this._lists.forEach((s) => i(s.id, null)), t.filter((s) => this._canDrop(s, this._dragState?.movedRootIds || []));
2135
+ return this._lists.forEach((n) => s(n.id, null)), r.filter((n) => this._canDrop(n, this._dragState?.movedRootIds || []));
2053
2136
  }
2054
2137
  _initialKeyboardDropTarget(e) {
2055
- const r = this._items.find((t) => t.id === e);
2056
- return r ? {
2057
- listId: r.listId,
2058
- parentId: r.parentId,
2138
+ const t = this._items.find((r) => r.id === e);
2139
+ return t ? {
2140
+ listId: t.listId,
2141
+ parentId: t.parentId,
2059
2142
  beforeId: e,
2060
2143
  mode: "before"
2061
2144
  } : null;
2062
2145
  }
2063
2146
  _moveKeyboardDropTarget(e) {
2064
2147
  if (!this._dragState) return;
2065
- const r = this._keyboardDropTargets();
2066
- if (!r.length) return;
2067
- const t = Math.max(0, r.findIndex(
2148
+ const t = this._keyboardDropTargets();
2149
+ if (!t.length) return;
2150
+ const r = Math.max(0, t.findIndex(
2068
2151
  (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 });
2152
+ )), i = Math.max(0, Math.min(t.length - 1, r + e));
2153
+ this._setDropTarget(t[i], { announceLabel: t[i].label });
2071
2154
  }
2072
2155
  }
2073
- typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable", ce);
2156
+ typeof customElements < "u" && !customElements.get("ui-sortable") && customElements.define("ui-sortable", he);
2074
2157
  export {
2075
- ce as UISortable
2158
+ he as UISortable
2076
2159
  };