@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,6 +1,7 @@
1
- import { E as l } from "./ElementBase-YlTLMsGk.mjs";
2
- import { e as h } from "./positioner-D0VGxtYU.mjs";
3
- const c = `
1
+ import { E as h } from "./ElementBase-YlTLMsGk.mjs";
2
+ import { e as c } from "./positioner-D0VGxtYU.mjs";
3
+ import { s as l } from "./selector-WI8pD7YO.mjs";
4
+ const u = `
4
5
  :host {
5
6
  display: contents;
6
7
  color-scheme: light dark;
@@ -15,7 +16,7 @@ function o(s) {
15
16
  const t = s.toLowerCase();
16
17
  return t !== "false" && t !== "0" && t !== "off";
17
18
  }
18
- function u(s) {
19
+ function d(s) {
19
20
  return (/* @__PURE__ */ new Set([
20
21
  "top",
21
22
  "top-start",
@@ -31,10 +32,10 @@ function u(s) {
31
32
  "left-end"
32
33
  ])).has(s) ? s : "bottom";
33
34
  }
34
- function d(s) {
35
+ function f(s) {
35
36
  return s === "absolute" ? "absolute" : "fixed";
36
37
  }
37
- class f extends l {
38
+ class b extends h {
38
39
  constructor() {
39
40
  super(...arguments), this._positioner = null, this._observer = null;
40
41
  }
@@ -82,9 +83,9 @@ class f extends l {
82
83
  _resolveAnchor() {
83
84
  const t = this.getAttribute("anchor");
84
85
  if (t) {
85
- const i = this.getRootNode(), n = i instanceof ShadowRoot || i instanceof Document ? i.querySelector(t) : null;
86
+ const i = this.getRootNode(), n = i instanceof ShadowRoot || i instanceof Document ? l(i, t) : null;
86
87
  if (n instanceof HTMLElement) return n;
87
- const a = document.querySelector(t);
88
+ const a = l(document, t);
88
89
  if (a instanceof HTMLElement) return a;
89
90
  }
90
91
  const e = this.querySelector('[slot="anchor"]');
@@ -105,11 +106,11 @@ class f extends l {
105
106
  this._destroyPositioner();
106
107
  return;
107
108
  }
108
- this._destroyPositioner(), this._positioner = h({
109
+ this._destroyPositioner(), this._positioner = c({
109
110
  anchor: t,
110
111
  floating: e,
111
- placement: u(this.getAttribute("placement")),
112
- strategy: d(this.getAttribute("strategy")),
112
+ placement: d(this.getAttribute("placement")),
113
+ strategy: f(this.getAttribute("strategy")),
113
114
  dir: this.getAttribute("dir") === "rtl" ? "rtl" : "ltr",
114
115
  offset: r(this.getAttribute("offset"), 8),
115
116
  crossOffset: r(this.getAttribute("cross-offset"), 0),
@@ -128,13 +129,13 @@ class f extends l {
128
129
  });
129
130
  }
130
131
  render() {
131
- this.setContent(`<style>${c}</style><slot name="anchor"></slot><slot name="content"></slot><slot></slot>`);
132
+ this.setContent(`<style>${u}</style><slot name="anchor"></slot><slot name="content"></slot><slot></slot>`);
132
133
  }
133
134
  shouldRenderOnAttributeChange() {
134
135
  return !1;
135
136
  }
136
137
  }
137
- typeof customElements < "u" && !customElements.get("ui-positioner") && customElements.define("ui-positioner", f);
138
+ typeof customElements < "u" && !customElements.get("ui-positioner") && customElements.define("ui-positioner", b);
138
139
  export {
139
- f as UIPositioner
140
+ b as UIPositioner
140
141
  };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Per-frame scroll step for a pointer at `position` inside the span [start, end]: negative near
3
+ * the start, positive near the end, 0 elsewhere. The step grows linearly from 0 at the edge of the
4
+ * `zone` to `maxStep` at the very edge, and the zone never exceeds half the span.
5
+ */
6
+ export declare function edgeScrollDelta(position: number, start: number, end: number, zone?: number, maxStep?: number): number;
7
+ /** The nearest ancestor (crossing shadow roots) that scrolls vertically, or null for the page. */
8
+ export declare function findScrollParent(element: Element | null): HTMLElement | null;
9
+ //# sourceMappingURL=auto-scroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-scroll.d.ts","sourceRoot":"","sources":["../../src/primitives/auto-scroll.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,SAAK,EAAE,OAAO,SAAK,GAAG,MAAM,CAO7G;AAID,kGAAkG;AAClG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAU5E"}
@@ -0,0 +1,4 @@
1
+ export declare function isValidSelector(selector: string): boolean;
2
+ /** `root.querySelector(selector)` that yields null instead of throwing on an invalid selector. */
3
+ export declare function safeQuerySelector<T extends Element = Element>(root: ParentNode, selector: string): T | null;
4
+ //# sourceMappingURL=selector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selector.d.ts","sourceRoot":"","sources":["../../src/primitives/selector.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAazD;AAED,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,CAG3G"}
@@ -0,0 +1 @@
1
+ "use strict";let r=null,u=!0;function l(t){if(t===r)return u;let e=!0;try{document.createDocumentFragment().querySelector(t)}catch{e=!1}return r=t,u=e,e}function n(t,e){return!e||!l(e)?null:t.querySelector(e)}exports.isValidSelector=l;exports.safeQuerySelector=n;
@@ -0,0 +1,18 @@
1
+ let r = null, u = !0;
2
+ function l(t) {
3
+ if (t === r) return u;
4
+ let e = !0;
5
+ try {
6
+ document.createDocumentFragment().querySelector(t);
7
+ } catch {
8
+ e = !1;
9
+ }
10
+ return r = t, u = e, e;
11
+ }
12
+ function n(t, e) {
13
+ return !e || !l(e) ? null : t.querySelector(e);
14
+ }
15
+ export {
16
+ l as i,
17
+ n as s
18
+ };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const te=require("./ElementBase-EV6mVBUV.js"),re=1,ie=44,se=72,oe=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const te=require("./ElementBase-EV6mVBUV.js");function re(l,e,t,r=56,i=18){if(!Number.isFinite(l)||!(t>e))return 0;const s=Math.min(r,(t-e)/2);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}const ie=new Set(["auto","scroll","overlay"]);function se(l){let e=l;for(;e;){if(e=e.parentNode instanceof ShadowRoot?e.parentNode.host:e.parentNode,!(e instanceof HTMLElement))continue;if(e===e.ownerDocument.body||e===e.ownerDocument.documentElement)return null;const{overflowY:t}=e.ownerDocument.defaultView?.getComputedStyle(e)??{overflowY:""};if(ie.has(t)&&e.scrollHeight>e.clientHeight)return e}return null}const oe=1,ne=44,ae=72,le=`
2
2
  :host {
3
3
  --ui-sortable-accent: var(--ui-color-primary, #2563eb);
4
4
  --ui-sortable-surface: var(--ui-color-surface, #ffffff);
@@ -102,6 +102,20 @@
102
102
  align-items: stretch;
103
103
  }
104
104
 
105
+ /* The cards live inside one root .tree wrapper, which is a vertical grid. Without this the
106
+ lane was a flex row holding a single column, so a "horizontal" list rendered vertically. */
107
+ .list[data-orientation="horizontal"] .items > .tree {
108
+ display: flex;
109
+ flex-wrap: nowrap;
110
+ align-items: stretch;
111
+ min-inline-size: min-content;
112
+ }
113
+
114
+ .list[data-orientation="horizontal"] .items > .tree > .item-shell {
115
+ flex: 0 0 auto;
116
+ min-inline-size: min(220px, 70vw);
117
+ }
118
+
105
119
  .list[data-disabled="true"] {
106
120
  opacity: 0.68;
107
121
  }
@@ -720,86 +734,86 @@
720
734
  background: Highlight;
721
735
  }
722
736
  }
723
- `;function V(l){if(!l)return[];try{const e=JSON.parse(l);return Array.isArray(e)?e:[]}catch{return[]}}function I(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function D(l,e){return`${l}::${e??"__root__"}`}function j(l){return l?[l.listId,l.parentId??"",l.beforeId??"",l.mode].join("::"):""}function B(l,e){return j(l)===j(e)}function ne(l){if(!l||l==="none")return{x:1,y:1};const e=l.match(/^matrix3d\((.+)\)$/);if(e){const t=e[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===16&&t.every(i=>Number.isFinite(i)))return{x:t[0]||1,y:t[5]||1}}const r=l.match(/^matrix\((.+)\)$/);if(r){const t=r[1].split(",").map(i=>Number.parseFloat(i.trim()));if(t.length===6&&t.every(i=>Number.isFinite(i))){const[i,s,a,n]=t;return{x:Math.sqrt(i*i+s*s)||1,y:Math.sqrt(a*a+n*n)||1}}}return{x:1,y:1}}function ae(l){return l==="item"?"item":"handle"}function A(l){return{...l}}function de(l,e,r,t,i,s){const a=$(l),n=P(l),d=new Set,o=[],u=g=>{const S=a.get(g);!S||d.has(g)||(d.add(g),o.push(g),(n.get(D(S.listId,g))||[]).forEach(u))};t.forEach(u);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=new Map,b=new Map;i&&m.forEach((g,S)=>{v.set(g.id,f[S].id),b.set(f[S].id,g.id)}),f.forEach(g=>{const S=i?b.get(g.id):g.id,T=S?a.get(S):null;T&&(i&&(g.parentId=T.parentId&&v.has(T.parentId)&&v.get(T.parentId)||null),g.listId=r.listId)});const y=t.map(g=>v.get(g)||g),x=[..._,...f],z=P(_),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;h.splice(H,0,...y),z.set(k,h),P(f).forEach((g,S)=>{const[,T]=S.split("::");(T||"")!=="__root__"&&z.set(S,[...g])});const F=$(x);y.forEach(g=>{const S=F.get(g);S&&(S.parentId=r.parentId,S.listId=r.listId)});const M=[],O=new Set,q=(g,S)=>{(z.get(D(g,S))||[]).forEach((R,K)=>{const c=F.get(R);!c||O.has(R)||(O.add(R),c.listId=g,c.parentId=S,c.order=K,M.push(c),q(g,R))})};return e.forEach(g=>q(g.id,null)),x.forEach(g=>{O.has(g.id)||(g.parentId=null,M.push(g))}),{items:M.map(A),insertedRootIds:y}}function P(l){const e=new Map;return l.forEach(r=>{const t=D(r.listId,r.parentId),i=e.get(t);i?i.push(r.id):e.set(t,[r.id])}),e}function $(l){return new Map(l.map(e=>[e.id,e]))}function X(l){const e=new Set,r=[];return l.forEach((t,i)=>{const s=typeof t?.id=="string"&&t.id.trim()?t.id.trim():`list-${i+1}`;e.has(s)||(e.add(s),r.push({id:s,label:typeof t?.label=="string"&&t.label.trim()?t.label.trim():`List ${i+1}`,description:typeof t?.description=="string"?t.description:"",emptyLabel:typeof t?.emptyLabel=="string"&&t.emptyLabel.trim()?t.emptyLabel.trim():"Drop items here.",orientation:t?.orientation==="horizontal"?"horizontal":"vertical",disabled:!!t?.disabled,cloneOnDrag:!!t?.cloneOnDrag,accepts:Array.isArray(t?.accepts)?t.accepts.filter(a=>typeof a=="string"&&a.trim().length>0):void 0}))}),r.length?r:[{id:"default",label:"Items",description:"",emptyLabel:"Drop items here.",orientation:"vertical",disabled:!1,cloneOnDrag:!1}]}function Y(l,e){const r=new Set(l.map(o=>o.id)),t=[];e.forEach((o,u)=>{const p=typeof o?.id=="string"&&o.id.trim()?o.id.trim():"",m=typeof o?.label=="string"&&o.label.trim()?o.label.trim():"";if(!p||!m)return;const _=typeof o?.listId=="string"&&r.has(o.listId)?o.listId:l[0].id;t.push({id:p,label:m,listId:_,parentId:typeof o?.parentId=="string"&&o.parentId.trim()?o.parentId.trim():null,description:typeof o?.description=="string"?o.description:"",order:Number.isFinite(o?.order)?Number(o.order):u,disabled:!!o?.disabled,dragDisabled:!!o?.dragDisabled,cloneOnDrag:!!o?.cloneOnDrag,hidden:!!o?.hidden})});const i=new Map(t.map(o=>[o.id,o]));t.forEach(o=>{if(!o.parentId)return;const u=i.get(o.parentId);(!u||u.id===o.id||u.listId!==o.listId)&&(o.parentId=null)});const s=new Map;t.forEach(o=>{const u=D(o.listId,o.parentId),p=s.get(u);p?p.push(o):s.set(u,[o])}),s.forEach(o=>o.sort((u,p)=>u.order-p.order||u.label.localeCompare(p.label)));const a=[],n=new Set,d=(o,u)=>{(s.get(D(o,u))||[]).forEach((m,_)=>{n.has(m.id)||(n.add(m.id),m.order=_,a.push(m),d(o,m.id))})};return l.forEach(o=>d(o.id,null)),t.forEach(o=>{n.has(o.id)||(o.parentId=null,a.push(o))}),a.map(A)}function le(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,listId:e.listId,parentId:e.parentId,description:e.description,order:e.order,disabled:e.disabled,dragDisabled:e.dragDisabled,cloneOnDrag:e.cloneOnDrag,hidden:e.hidden})))}function ce(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,description:e.description,emptyLabel:e.emptyLabel,orientation:e.orientation,disabled:e.disabled,cloneOnDrag:e.cloneOnDrag,accepts:e.accepts})))}function U(l){return JSON.stringify(l)}function J(l){const e=new Map,r=l.map(t=>{const i=D(t.listId,t.parentId),s=e.get(i)??0;return e.set(i,s+1),{id:t.id,listId:t.listId,parentId:t.parentId,index:s}});return{version:re,records:r}}function W(l,e){return e?`${l.label} ${l.description}`.toLowerCase().includes(e.toLowerCase()):!0}function Q(l,e,r,t,i){const s=$(l),a=P(l),n=new Map,d=(p,m)=>{const _=[...a.get(D(p,m))||[]];return i==="label"&&_.sort((f,v)=>{const b=s.get(f),y=s.get(v);return!b||!y?0:b.label.localeCompare(y.label)}),_},o=(p,m,_)=>{const f=[];return d(p,m).forEach(v=>{const b=s.get(v);if(!b||b.hidden)return;const y=o(p,b.id);!W(b,t)&&y.length===0||(f.push({id:b.id,disabled:b.disabled}),y.length&&f.push(...y))}),f};return Array.from(new Set(l.map(p=>p.listId))).forEach(p=>{n.set(p,o(p,null))}),n}class Z extends te.ElementBase{constructor(){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)}static get observedAttributes(){return["lists","items","selection","filter-query","sort","persist-key","allow-filtered-drag","allow-nesting","drop-indicator-visibility","dropzone-style","drag-preview-size","drag-handle-mode","drag-handle-selector","custom-item-rendering","show-selection-badge","disabled"]}shouldRenderOnAttributeChange(e,r,t){return this._suppressAttributeRender?!["lists","items","selection"].includes(e):!0}attributeChangedCallback(e,r,t){if(r!==t&&this.isConnected){if(e==="selection"&&!this._suppressAttributeRender&&this._canSyncInteractiveStateInPlace()){this._syncSelectionFromAttribute(t??null),this._syncSelectionVisualState();return}if(e==="show-selection-badge"&&this._canSyncInteractiveStateInPlace()){this._syncSelectionVisualState();return}super.attributeChangedCallback(e,r,t)}}connectedCallback(){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)}disconnectedCallback(){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()}get lists(){return this._lists.map(e=>({...e}))}set lists(e){this.setAttribute("lists",JSON.stringify(e??[]))}get items(){return this._items.map(e=>({...e}))}set items(e){this.setAttribute("items",JSON.stringify(e??[]))}get selection(){return[...this._selection]}set selection(e){this.setAttribute("selection",JSON.stringify(e??[]))}get sort(){return this.getAttribute("sort")==="label"?"label":"manual"}set sort(e){!e||e==="manual"?this.removeAttribute("sort"):this.setAttribute("sort",e)}get filterQuery(){return this.getAttribute("filter-query")||""}set filterQuery(e){e?this.setAttribute("filter-query",e):this.removeAttribute("filter-query")}select(e){this._setSelection(e,"api")}clearSelection(){this._setSelection([],"api")}cancelDrag(){this._cancelDrag(!0)}focusItem(e){this._items.some(r=>r.id===e)&&(this._focusedId=e,this._pendingFocusId=e,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender())}moveSelection(e){this._syncSelectionFromAttribute(this.getAttribute("selection"));const r=this._selectedRootIds();r.length&&this._commitMove({listId:e.targetListId,parentId:e.parentId??null,beforeId:e.beforeId??null,mode:e.mode??(e.parentId?"inside":"before")},r,!!e.clone,e.source??"api")}getPersistenceSnapshot(){return J(this._items)}render(){this._syncStateFromAttributes();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=`
724
- <style>${oe}</style>
737
+ `;function K(l){if(!l)return[];try{const e=JSON.parse(l);return Array.isArray(e)?e:[]}catch{return[]}}function y(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function k(l,e){return`${l}::${e??"__root__"}`}function j(l){return l?[l.listId,l.parentId??"",l.beforeId??"",l.mode].join("::"):""}function B(l,e){return j(l)===j(e)}function de(l){if(!l||l==="none")return{x:1,y:1};const e=l.match(/^matrix3d\((.+)\)$/);if(e){const r=e[1].split(",").map(i=>Number.parseFloat(i.trim()));if(r.length===16&&r.every(i=>Number.isFinite(i)))return{x:r[0]||1,y:r[5]||1}}const t=l.match(/^matrix\((.+)\)$/);if(t){const r=t[1].split(",").map(i=>Number.parseFloat(i.trim()));if(r.length===6&&r.every(i=>Number.isFinite(i))){const[i,s,n,a]=r;return{x:Math.sqrt(i*i+s*s)||1,y:Math.sqrt(n*n+a*a)||1}}}return{x:1,y:1}}function ce(l){return l==="item"?"item":"handle"}function P(l){return{...l}}function ue(l,e,t,r,i,s){const n=T(l),a=E(l),d=new Set,o=[],u=g=>{const x=n.get(g);!x||d.has(g)||(d.add(g),o.push(g),(a.get(k(x.listId,g))||[]).forEach(u))};r.forEach(u);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=new Map,m=new Map;i&&h.forEach((g,x)=>{I.set(g.id,_[x].id),m.set(_[x].id,g.id)}),_.forEach(g=>{const x=i?m.get(g.id):g.id,M=x?n.get(x):null;M&&(i&&(g.parentId=M.parentId&&I.has(M.parentId)&&I.get(M.parentId)||null),g.listId=t.listId)});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;b.splice(R,0,...v),A.set(z,b),E(_).forEach((g,x)=>{const[,M]=x.split("::");(M||"")!=="__root__"&&A.set(x,[...g])});const O=T(D);v.forEach(g=>{const x=O.get(g);x&&(x.parentId=t.parentId,x.listId=t.listId)});const L=[],q=new Set,H=(g,x)=>{(A.get(k(g,x))||[]).forEach((C,G)=>{const p=O.get(C);!p||q.has(C)||(q.add(C),p.listId=g,p.parentId=x,p.order=G,L.push(p),H(g,C))})};return e.forEach(g=>H(g.id,null)),D.forEach(g=>{q.has(g.id)||(g.parentId=null,L.push(g))}),{items:L.map(P),insertedRootIds:v}}function E(l){const e=new Map;return l.forEach(t=>{const r=k(t.listId,t.parentId),i=e.get(r);i?i.push(t.id):e.set(r,[t.id])}),e}function T(l){return new Map(l.map(e=>[e.id,e]))}function Y(l){const e=new Set,t=[];return l.forEach((r,i)=>{const s=typeof r?.id=="string"&&r.id.trim()?r.id.trim():`list-${i+1}`;e.has(s)||(e.add(s),t.push({id:s,label:typeof r?.label=="string"&&r.label.trim()?r.label.trim():`List ${i+1}`,description:typeof r?.description=="string"?r.description:"",emptyLabel:typeof r?.emptyLabel=="string"&&r.emptyLabel.trim()?r.emptyLabel.trim():"Drop items here.",orientation:r?.orientation==="horizontal"?"horizontal":"vertical",disabled:!!r?.disabled,cloneOnDrag:!!r?.cloneOnDrag,accepts:Array.isArray(r?.accepts)?r.accepts.filter(n=>typeof n=="string"&&n.trim().length>0):void 0}))}),t.length?t:[{id:"default",label:"Items",description:"",emptyLabel:"Drop items here.",orientation:"vertical",disabled:!1,cloneOnDrag:!1}]}function U(l,e){const t=new Set(l.map(o=>o.id)),r=[];e.forEach((o,u)=>{const c=typeof o?.id=="string"&&o.id.trim()?o.id.trim():"",h=typeof o?.label=="string"&&o.label.trim()?o.label.trim():"";if(!c||!h)return;const f=typeof o?.listId=="string"&&t.has(o.listId)?o.listId:l[0].id;r.push({id:c,label:h,listId:f,parentId:typeof o?.parentId=="string"&&o.parentId.trim()?o.parentId.trim():null,description:typeof o?.description=="string"?o.description:"",order:Number.isFinite(o?.order)?Number(o.order):u,disabled:!!o?.disabled,dragDisabled:!!o?.dragDisabled,cloneOnDrag:!!o?.cloneOnDrag,hidden:!!o?.hidden})});const i=new Map(r.map(o=>[o.id,o]));r.forEach(o=>{if(!o.parentId)return;const u=i.get(o.parentId);(!u||u.id===o.id||u.listId!==o.listId)&&(o.parentId=null)});const s=new Map;r.forEach(o=>{const u=k(o.listId,o.parentId),c=s.get(u);c?c.push(o):s.set(u,[o])}),s.forEach(o=>o.sort((u,c)=>u.order-c.order||u.label.localeCompare(c.label)));const n=[],a=new Set,d=(o,u)=>{(s.get(k(o,u))||[]).forEach((h,f)=>{a.has(h.id)||(a.add(h.id),h.order=f,n.push(h),d(o,h.id))})};return l.forEach(o=>d(o.id,null)),r.forEach(o=>{a.has(o.id)||(o.parentId=null,n.push(o))}),n.map(P)}function pe(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,listId:e.listId,parentId:e.parentId,description:e.description,order:e.order,disabled:e.disabled,dragDisabled:e.dragDisabled,cloneOnDrag:e.cloneOnDrag,hidden:e.hidden})))}function he(l){return JSON.stringify(l.map(e=>({id:e.id,label:e.label,description:e.description,emptyLabel:e.emptyLabel,orientation:e.orientation,disabled:e.disabled,cloneOnDrag:e.cloneOnDrag,accepts:e.accepts})))}function X(l){return JSON.stringify(l)}function J(l){const e=new Map,t=l.map(r=>{const i=k(r.listId,r.parentId),s=e.get(i)??0;return e.set(i,s+1),{id:r.id,listId:r.listId,parentId:r.parentId,index:s}});return{version:oe,records:t}}function W(l,e){return e?`${l.label} ${l.description}`.toLowerCase().includes(e.toLowerCase()):!0}function Q(l,e,t,r,i){const s=T(l),n=E(l),a=new Map,d=(c,h)=>{const f=[...n.get(k(c,h))||[]];return i==="label"&&f.sort((_,I)=>{const m=s.get(_),v=s.get(I);return!m||!v?0:m.label.localeCompare(v.label)}),f},o=(c,h,f)=>{const _=[];return d(c,h).forEach(I=>{const m=s.get(I);if(!m||m.hidden)return;const v=o(c,m.id);!W(m,r)&&v.length===0||(_.push({id:m.id,disabled:m.disabled}),v.length&&_.push(...v))}),_};return Array.from(new Set(l.map(c=>c.listId))).forEach(c=>{a.set(c,o(c,null))}),a}class Z extends te.ElementBase{constructor(){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=()=>{this._autoScrollFrame=0;const e=this._autoScrollPoint;if(!e||!this._dragState||this._dragState.keyboard)return;const t=this.ownerDocument?.defaultView,r=se(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=re(e.y,s,n);if(a){if(r?r.scrollTop+=a:t?.scrollBy(0,a),!this._dragState.committed){const d=this._dropTargetFromPoint(e.x,e.y),o=d&&this._canDrop(d,this._dragState.movedRootIds)?d:null;this._queueDropTarget(o,performance.now())}this._autoScrollFrame=requestAnimationFrame(this._autoScrollTick)}},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)}static get observedAttributes(){return["lists","items","selection","filter-query","sort","persist-key","allow-filtered-drag","allow-nesting","drop-indicator-visibility","dropzone-style","drag-preview-size","drag-handle-mode","drag-handle-selector","custom-item-rendering","show-selection-badge","disabled"]}shouldRenderOnAttributeChange(e,t,r){return this._suppressAttributeRender?!["lists","items","selection"].includes(e):!0}attributeChangedCallback(e,t,r){if(t!==r&&this.isConnected){if(e==="selection"&&!this._suppressAttributeRender&&this._canSyncInteractiveStateInPlace()){this._syncSelectionFromAttribute(r??null),this._syncSelectionVisualState();return}if(e==="show-selection-badge"&&this._canSyncInteractiveStateInPlace()){this._syncSelectionVisualState();return}super.attributeChangedCallback(e,t,r)}}connectedCallback(){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)}disconnectedCallback(){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()}get lists(){return this._lists.map(e=>({...e}))}set lists(e){this.setAttribute("lists",JSON.stringify(e??[]))}get items(){return this._items.map(e=>({...e}))}set items(e){this.setAttribute("items",JSON.stringify(e??[]))}get selection(){return[...this._selection]}set selection(e){this.setAttribute("selection",JSON.stringify(e??[]))}get sort(){return this.getAttribute("sort")==="label"?"label":"manual"}set sort(e){!e||e==="manual"?this.removeAttribute("sort"):this.setAttribute("sort",e)}get filterQuery(){return this.getAttribute("filter-query")||""}set filterQuery(e){e?this.setAttribute("filter-query",e):this.removeAttribute("filter-query")}select(e){this._setSelection(e,"api")}clearSelection(){this._setSelection([],"api")}cancelDrag(){this._cancelDrag(!0)}focusItem(e){this._items.some(t=>t.id===e)&&(this._focusedId=e,this._pendingFocusId=e,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender())}moveSelection(e){this._syncSelectionFromAttribute(this.getAttribute("selection"));const t=this._selectedRootIds();t.length&&this._commitMove({listId:e.targetListId,parentId:e.parentId??null,beforeId:e.beforeId??null,mode:e.mode??(e.parentId?"inside":"before")},t,!!e.clone,e.source??"api")}getPersistenceSnapshot(){return J(this._items)}render(){this._syncStateFromAttributes();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=`
738
+ <style>${le}</style>
725
739
  <div
726
740
  class="root"
727
741
  part="root"
728
- data-drag-locked="${p}"
729
- data-drag-preview="${n.size||d?"true":"false"}"
730
- data-drop-indicator-visibility="${f}"
731
- data-dropzone-style="${v}"
742
+ data-drag-locked="${c}"
743
+ data-drag-preview="${a.size||d?"true":"false"}"
744
+ data-drop-indicator-visibility="${_}"
745
+ data-dropzone-style="${I}"
732
746
  >
733
747
  <div class="toolbar" part="toolbar">
734
- <div class="helper">${I(z)}</div>
748
+ <div class="helper">${y(A)}</div>
735
749
  <div class="helper selection-summary">
736
- <span class="selection-pill" part="selection-count">${m}</span>
737
- <span class="selection-text">${m===1?"item selected":"items selected"}</span>
750
+ <span class="selection-pill" part="selection-count">${h}</span>
751
+ <span class="selection-text">${h===1?"item selected":"items selected"}</span>
738
752
  </div>
739
753
  </div>
740
754
  <div class="lists" part="lists">
741
- ${this._lists.map(h=>{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(", ")}`:"";return`
755
+ ${this._lists.map(b=>{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(", ")}`:"";return`
742
756
  <section
743
757
  class="list"
744
758
  part="list"
745
- data-list-id="${I(h.id)}"
746
- data-orientation="${h.orientation}"
747
- data-disabled="${h.disabled}"
748
- aria-label="${I(h.label)}"
759
+ data-list-id="${y(b.id)}"
760
+ data-orientation="${b.orientation}"
761
+ data-disabled="${b.disabled}"
762
+ aria-label="${y(b.label)}"
749
763
  >
750
764
  <header class="list-header">
751
- <div class="list-custom-header" part="list-custom-header" data-list-header-target="${I(h.id)}"></div>
765
+ <div class="list-custom-header" part="list-custom-header" data-list-header-target="${y(b.id)}"></div>
752
766
  <div class="list-default-header">
753
767
  <div class="list-topline">
754
- <div class="list-label">${I(h.label)}</div>
755
- <span class="list-count">${E.length}</span>
768
+ <div class="list-label">${y(b.label)}</div>
769
+ <span class="list-count">${S.length}</span>
756
770
  </div>
757
- ${h.description?`<div class="list-description">${I(h.description)}</div>`:""}
758
- ${L?`<div class="list-helper">${I(L)}</div>`:""}
771
+ ${b.description?`<div class="list-description">${y(b.description)}</div>`:""}
772
+ ${$?`<div class="list-helper">${y($)}</div>`:""}
759
773
  </div>
760
774
  </header>
761
- <div class="items" role="listbox" aria-multiselectable="true">
762
- ${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({listId:h.id,parentId:null,beforeId:null,mode:"before"},"Drop here")}`}
775
+ <div class="items" role="listbox" aria-multiselectable="true" aria-label="${y(b.label)}">
776
+ ${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({listId:b.id,parentId:null,beforeId:null,mode:"before"},"Drop here")}`}
763
777
  </div>
764
778
  </section>
765
779
  `}).join("")}
766
780
  </div>
767
- <div class="sr-only" aria-live="polite" aria-atomic="true">${I(this._liveMessage)}</div>
781
+ <div class="sr-only" aria-live="polite" aria-atomic="true">${y(this._liveMessage)}</div>
768
782
  </div>
769
- `;this.setContent(k),queueMicrotask(()=>{this._restorePendingFocus(),this._applyCurrentDropTargetVisualState(),this._applyLiveMessage(),this._updatePointerDragPreview(),this._animateItemShellReflow(e)})}_syncStateFromAttributes(){const e=this.getAttribute("lists");e!==this._lastListsAttr&&(this._lastListsAttr=e,this._lists=X(V(e)));const r=this.getAttribute("items");if(r!==this._lastItemsAttr){this._lastItemsAttr=r,this._items=Y(this._lists,V(r));const i=this.getAttribute("persist-key");i&&this._hydratedPersistKey!==i&&(this._items=this._restorePersistedItems(i,this._items),this._hydratedPersistKey=i)}const t=this.getAttribute("selection");t!==this._lastSelectionAttr&&this._syncSelectionFromAttribute(t),this._focusedId||(this._focusedId=this._items.find(i=>!i.hidden)?.id||null)}_restorePersistedItems(e,r){try{const t=window.localStorage.getItem(e);if(!t)return r;const i=JSON.parse(t);if(!i||typeof i!="object"||!Array.isArray(i.records))return r;const s=new Map(i.records.map(n=>[n.id,n])),a=r.map((n,d)=>{const o=s.get(n.id);return o?{...n,listId:this._lists.some(u=>u.id===o.listId)?o.listId:n.listId,parentId:typeof o.parentId=="string"?o.parentId:null,order:Number.isFinite(o.index)?o.index:d}:{...n,order:d}});return Y(this._lists,a)}catch{return r}}_resolvedFocusedId(e){const r=new Set(Array.from(e.values()).flat().map(i=>i.id));return this._focusedId&&r.has(this._focusedId)?this._focusedId:Array.from(e.values()).flat().find(i=>!i.disabled)?.id||null}_restorePendingFocus(){const e=this._pendingFocusId||this._focusedId;if(!e)return;const r=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"'),t=this.root.querySelector(`.item[data-id="${r}"]`);t&&(document.activeElement!==t&&t.focus({preventScroll:!0}),this._pendingFocusId=null)}_escapeSelectorValue(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}_findDropzone(e){const r=this._escapeSelectorValue(e.listId),t=this._escapeSelectorValue(e.parentId??""),i=this._escapeSelectorValue(e.beforeId??""),s=this._escapeSelectorValue(e.mode);return this.root.querySelector(`.dropzone[data-list-id="${r}"][data-parent-id="${t}"][data-before-id="${i}"][data-mode="${s}"]`)}_findItemElement(e){const r=this._escapeSelectorValue(e);return this.root.querySelector(`.item[data-id="${r}"]`)}_dragHandleMode(){return ae(this.getAttribute("drag-handle-mode"))}_dropzoneStyle(){return this.getAttribute("dropzone-style")==="container"?"container":"indicator"}_usesCustomHandleSelector(){return!!this.getAttribute("drag-handle-selector")?.trim()}_dragActivatorFromPath(e){const r=e.find(a=>a instanceof HTMLElement&&!!a.getAttribute("data-drag-trigger"));if(!r)return null;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");return s?{element:r,id:s,kind:i}:null}_setDropTargetVisualState(e,r){if(!e)return;const t=this._findDropzone(e);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")}_applyCurrentDropTargetVisualState(e){this._setDropTargetVisualState(e??null,!1),this._setDropTargetVisualState(this._dragState?.dropTarget??null,!0)}_applyLiveMessage(){const e=this.root.querySelector(".sr-only[aria-live]");e&&(e.textContent=this._liveMessage)}_canSyncInteractiveStateInPlace(){return!!this.root.querySelector(".root")&&!this._dragState}_applyInteractiveStateInPlace(e){return this._canSyncInteractiveStateInPlace()?(this._syncSelectionVisualState(),e?.restoreFocus&&this._restorePendingFocus(),this._applyLiveMessage(),!0):!1}_hasCustomItemRendering(){return this.hasAttribute("custom-item-rendering")}_syncSelectionFromAttribute(e){this._lastSelectionAttr=e;const r=new Set(this._items.map(t=>t.id));this._selection=V(e).filter(t=>r.has(t)),!this._selection.length&&this._focusedId&&!r.has(this._focusedId)&&(this._focusedId=null)}_syncSelectionVisualState(){const e=new Set(this._selection),r=this.getAttribute("show-selection-badge")!=="false";this.root.querySelectorAll(".item[data-id]").forEach(s=>{const a=s.getAttribute("data-id");if(!a)return;const n=e.has(a),d=this._focusedId===a;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");const o=s.querySelector('[data-selection-badge="true"]');if(o){const u=n&&r;o.hidden=!u,o.textContent=u?"Selected":""}});const t=this.root.querySelector(".selection-pill");t&&(t.textContent=String(this._selection.length));const i=this.root.querySelector(".selection-text");i&&(i.textContent=this._selection.length===1?"item selected":"items selected")}_clearDropzoneContainerSize(e){e.style.removeProperty("--ui-sortable-dropzone-match-block-size"),e.style.removeProperty("--ui-sortable-dropzone-match-inline-size")}_dropzoneReferenceElement(e,r){if(e.mode==="inside"&&e.parentId)return this._findItemElement(e.parentId);let t=r.nextElementSibling;for(;t;){if(t instanceof HTMLElement&&t.classList.contains("item-shell"))return t.querySelector(".item[data-id]");t=t.nextElementSibling}let i=r.previousElementSibling;for(;i;){if(i instanceof HTMLElement&&i.classList.contains("item-shell"))return i.querySelector(".item[data-id]");i=i.previousElementSibling}const s=this._escapeSelectorValue(e.listId),a=this.root.querySelector(`.list[data-list-id="${s}"] .items`),n=a?.querySelector(".item[data-id]");return n||a||null}_syncDropzoneContainerSize(e,r){if(this._clearDropzoneContainerSize(e),this._dropzoneStyle()!=="container")return;const t=this._dropzoneReferenceElement(r,e);if(!t)return;const i=t.getBoundingClientRect();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`)}_ensureDragPreviewOverlay(){if(this._dragPreviewOverlay&&this._dragPreviewOverlay.isConnected)return this._dragPreviewOverlay;const e=document.createElement("div");return e.className="drag-preview-overlay",e.setAttribute("data-visible","false"),this.root.appendChild(e),this._dragPreviewOverlay=e,e}_clearPointerDragPreview(){this._dragPreviewOverlay?.setAttribute("data-visible","false"),this._dragPreviewOverlay?.style.setProperty("left","-9999px"),this._dragPreviewOverlay?.style.setProperty("top","-9999px");const e=this.root.querySelector(".root");e&&!this._dragState?.keyboard&&e.setAttribute("data-drag-preview","false")}_pointerPreviewContent(){if(!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=this._items.find(t=>t.id===e);return r?{kicker:this._dragState.clone?"Copy preview":"Drop preview",title:this._dragState.clone?`${r.label} copy`:r.label,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."}:null}_pointerPreviewSize(){if(this.getAttribute("drag-preview-size")==="compact"||!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],r=e?this._findItemElement(e):null;if(!r)return null;const t=window.getComputedStyle(r),i=ne(t.transform);return{width:r.offsetWidth*i.x,height:r.offsetHeight*i.y}}_updatePointerDragPreview(){if(!this._dragState||this._dragState.keyboard){this._clearPointerDragPreview();return}const e=this._pointerPreviewContent();if(!e){this._clearPointerDragPreview();return}const r=this.root.querySelector(".root"),i=this._dragPreviewOverlay?.getAttribute("data-visible")==="true",s=this._pointerPreviewSize();if(!this._dragState.dropTarget){i&&r&&r.setAttribute("data-drag-preview","true");return}const a=this._findDropzone(this._dragState.dropTarget);if(!a){i&&r&&r.setAttribute("data-drag-preview","true");return}const n=this._ensureDragPreviewOverlay();n.innerHTML=`
783
+ `;this.setContent(z),queueMicrotask(()=>{this._restorePendingFocus(),this._applyCurrentDropTargetVisualState(),this._applyLiveMessage(),this._updatePointerDragPreview(),this._animateItemShellReflow(e)})}_syncStateFromAttributes(){const e=this.getAttribute("lists");e!==this._lastListsAttr&&(this._lastListsAttr=e,this._lists=Y(K(e)));const t=this.getAttribute("items");if(t!==this._lastItemsAttr){this._lastItemsAttr=t,this._items=U(this._lists,K(t));const i=this.getAttribute("persist-key");i&&this._hydratedPersistKey!==i&&(this._items=this._restorePersistedItems(i,this._items),this._hydratedPersistKey=i)}const r=this.getAttribute("selection");r!==this._lastSelectionAttr&&this._syncSelectionFromAttribute(r),this._focusedId||(this._focusedId=this._items.find(i=>!i.hidden)?.id||null)}_restorePersistedItems(e,t){try{const r=window.localStorage.getItem(e);if(!r)return t;const i=JSON.parse(r);if(!i||typeof i!="object"||!Array.isArray(i.records))return t;const s=new Map(i.records.map(a=>[a.id,a])),n=t.map((a,d)=>{const o=s.get(a.id);return o?{...a,listId:this._lists.some(u=>u.id===o.listId)?o.listId:a.listId,parentId:typeof o.parentId=="string"?o.parentId:null,order:Number.isFinite(o.index)?o.index:d}:{...a,order:d}});return U(this._lists,n)}catch{return t}}_resolvedFocusedId(e){const t=new Set(Array.from(e.values()).flat().map(i=>i.id));return this._focusedId&&t.has(this._focusedId)?this._focusedId:Array.from(e.values()).flat().find(i=>!i.disabled)?.id||null}_restorePendingFocus(){const e=this._pendingFocusId||this._focusedId;if(!e)return;const t=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"'),r=this.root.querySelector(`.item[data-id="${t}"]`);r&&(document.activeElement!==r&&r.focus({preventScroll:!0}),this._pendingFocusId=null)}_escapeSelectorValue(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/"/g,'\\"')}_findDropzone(e){const t=this._escapeSelectorValue(e.listId),r=this._escapeSelectorValue(e.parentId??""),i=this._escapeSelectorValue(e.beforeId??""),s=this._escapeSelectorValue(e.mode);return this.root.querySelector(`.dropzone[data-list-id="${t}"][data-parent-id="${r}"][data-before-id="${i}"][data-mode="${s}"]`)}_findItemElement(e){const t=this._escapeSelectorValue(e);return this.root.querySelector(`.item[data-id="${t}"]`)}_dragHandleMode(){return ce(this.getAttribute("drag-handle-mode"))}_dropzoneStyle(){return this.getAttribute("dropzone-style")==="container"?"container":"indicator"}_usesCustomHandleSelector(){return!!this.getAttribute("drag-handle-selector")?.trim()}_dragActivatorFromPath(e){const t=e.find(n=>n instanceof HTMLElement&&!!n.getAttribute("data-drag-trigger"));if(!t)return null;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");return s?{element:t,id:s,kind:i}:null}_setDropTargetVisualState(e,t){if(!e)return;const r=this._findDropzone(e);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")}_applyCurrentDropTargetVisualState(e){this._setDropTargetVisualState(e??null,!1),this._setDropTargetVisualState(this._dragState?.dropTarget??null,!0)}_applyLiveMessage(){const e=this.root.querySelector(".sr-only[aria-live]");e&&(e.textContent=this._liveMessage)}_canSyncInteractiveStateInPlace(){return!!this.root.querySelector(".root")&&!this._dragState}_applyInteractiveStateInPlace(e){return this._canSyncInteractiveStateInPlace()?(this._syncSelectionVisualState(),e?.restoreFocus&&this._restorePendingFocus(),this._applyLiveMessage(),!0):!1}_hasCustomItemRendering(){return this.hasAttribute("custom-item-rendering")}_syncSelectionFromAttribute(e){this._lastSelectionAttr=e;const t=new Set(this._items.map(r=>r.id));this._selection=K(e).filter(r=>t.has(r)),!this._selection.length&&this._focusedId&&!t.has(this._focusedId)&&(this._focusedId=null)}_syncSelectionVisualState(){const e=new Set(this._selection),t=this.getAttribute("show-selection-badge")!=="false";this.root.querySelectorAll(".item[data-id]").forEach(s=>{const n=s.getAttribute("data-id");if(!n)return;const a=e.has(n),d=this._focusedId===n;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");const o=s.querySelector('[data-selection-badge="true"]');if(o){const u=a&&t;o.hidden=!u,o.textContent=u?"Selected":""}});const r=this.root.querySelector(".selection-pill");r&&(r.textContent=String(this._selection.length));const i=this.root.querySelector(".selection-text");i&&(i.textContent=this._selection.length===1?"item selected":"items selected")}_clearDropzoneContainerSize(e){e.style.removeProperty("--ui-sortable-dropzone-match-block-size"),e.style.removeProperty("--ui-sortable-dropzone-match-inline-size")}_dropzoneReferenceElement(e,t){if(e.mode==="inside"&&e.parentId)return this._findItemElement(e.parentId);let r=t.nextElementSibling;for(;r;){if(r instanceof HTMLElement&&r.classList.contains("item-shell"))return r.querySelector(".item[data-id]");r=r.nextElementSibling}let i=t.previousElementSibling;for(;i;){if(i instanceof HTMLElement&&i.classList.contains("item-shell"))return i.querySelector(".item[data-id]");i=i.previousElementSibling}const s=this._escapeSelectorValue(e.listId),n=this.root.querySelector(`.list[data-list-id="${s}"] .items`),a=n?.querySelector(".item[data-id]");return a||n||null}_syncDropzoneContainerSize(e,t){if(this._clearDropzoneContainerSize(e),this._dropzoneStyle()!=="container")return;const r=this._dropzoneReferenceElement(t,e);if(!r)return;const i=r.getBoundingClientRect();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`)}_ensureDragPreviewOverlay(){if(this._dragPreviewOverlay&&this._dragPreviewOverlay.isConnected)return this._dragPreviewOverlay;const e=document.createElement("div");return e.className="drag-preview-overlay",e.setAttribute("data-visible","false"),this.root.appendChild(e),this._dragPreviewOverlay=e,e}_clearPointerDragPreview(){this._dragPreviewOverlay?.setAttribute("data-visible","false"),this._dragPreviewOverlay?.style.setProperty("left","-9999px"),this._dragPreviewOverlay?.style.setProperty("top","-9999px");const e=this.root.querySelector(".root");e&&!this._dragState?.keyboard&&e.setAttribute("data-drag-preview","false")}_pointerPreviewContent(){if(!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],t=this._items.find(r=>r.id===e);return t?{kicker:this._dragState.clone?"Copy preview":"Drop preview",title:this._dragState.clone?`${t.label} copy`:t.label,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."}:null}_pointerPreviewSize(){if(this.getAttribute("drag-preview-size")==="compact"||!this._dragState||this._dragState.keyboard)return null;const e=this._dragState.movedRootIds[0],t=e?this._findItemElement(e):null;if(!t)return null;const r=window.getComputedStyle(t),i=de(r.transform);return{width:t.offsetWidth*i.x,height:t.offsetHeight*i.y}}_updatePointerDragPreview(){if(!this._dragState||this._dragState.keyboard){this._clearPointerDragPreview();return}const e=this._pointerPreviewContent();if(!e){this._clearPointerDragPreview();return}const t=this.root.querySelector(".root"),i=this._dragPreviewOverlay?.getAttribute("data-visible")==="true",s=this._pointerPreviewSize();if(!this._dragState.dropTarget){i&&t&&t.setAttribute("data-drag-preview","true");return}const n=this._findDropzone(this._dragState.dropTarget);if(!n){i&&t&&t.setAttribute("data-drag-preview","true");return}const a=this._ensureDragPreviewOverlay();a.innerHTML=`
770
784
  <div class="placeholder-content">
771
- <div class="placeholder-kicker">${I(e.kicker)}</div>
772
- <div class="placeholder-title">${I(e.title)}</div>
773
- <div class="placeholder-description">${I(e.description)}</div>
785
+ <div class="placeholder-kicker">${y(e.kicker)}</div>
786
+ <div class="placeholder-title">${y(e.title)}</div>
787
+ <div class="placeholder-description">${y(e.description)}</div>
774
788
  </div>
775
- `;const d=a.getBoundingClientRect();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");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(16,Math.min(d.top+(d.height-p)/2,window.innerHeight-p-16));n.style.setProperty("left",`${Math.round(m)}px`),n.style.setProperty("top",`${Math.round(_)}px`)}_setDraggingVisualState(e,r){e.forEach(t=>{const i=this._findItemElement(t);i&&(i.setAttribute("data-dragging",r?"true":"false"),i.setAttribute("aria-grabbed",r?"true":"false"),r&&i.getBoundingClientRect())})}_setDropTarget(e,r){const t=this._dragState?.dropTarget??null;if(!(!this._dragState||B(t,e))){if(this._pendingDropTarget=null,this._dragState.dropTarget=e,this._applyCurrentDropTargetVisualState(t),r?.announceLabel&&this._announce(r.announceLabel),this._dragState.keyboard){this.requestRender();return}this._updatePointerDragPreview()}}_queueDropTarget(e,r,t){if(!this._dragState)return;const i=this._dragState.dropTarget??null;if(B(i,e)){this._pendingDropTarget=null;return}if(!i&&e){this._setDropTarget(e,t);return}const s=typeof r=="number"&&Number.isFinite(r)?r:performance.now(),a=this._pendingDropTarget;if(a&&B(a.target,e)){const n=e?ie:se;s-a.startedAt>=n&&this._setDropTarget(e,a.announceLabel?{announceLabel:a.announceLabel}:t);return}this._pendingDropTarget={target:e,startedAt:s,announceLabel:t?.announceLabel}}_releaseDropTarget(e,r){if(!this._dragState)return null;if(Number.isFinite(e)&&Number.isFinite(r)){const s=this._dropTargetFromPoint(e,r);if(s&&this._canDrop(s,this._dragState.movedRootIds))return this._pendingDropTarget=null,s}const t=this._pendingDropTarget?.target??null;if(this._pendingDropTarget=null,t&&this._canDrop(t,this._dragState.movedRootIds))return t;const i=this._dragState.dropTarget??null;return i&&this._canDrop(i,this._dragState.movedRootIds)?i:null}_pathFromPoint(e,r){const t=[],i=this.root;let s=typeof i.elementFromPoint=="function"?i.elementFromPoint(e,r):this.ownerDocument?.elementFromPoint(e,r)??null;for(;s&&(s instanceof HTMLElement&&t.push(s),s!==this);){if(s instanceof ShadowRoot){s=s.host;continue}s=s.parentNode,!s&&t[t.length-1]?.getRootNode()instanceof ShadowRoot&&(s=t[t.length-1].getRootNode().host)}return t}_measureItemShellRects(){const e=new Map;return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(r=>{const t=r.getAttribute("data-item-shell");if(!t)return;const i=r.getBoundingClientRect();e.set(t,{top:i.top,left:i.left})}),e}_animateItemShellReflow(e){if(!e.size)return;const r=new Set(this._draggingIds());this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(t=>{const i=t.getAttribute("data-item-shell");if(!i||r.has(i))return;const s=e.get(i);if(!s)return;const a=t.getBoundingClientRect(),n=s.left-a.left,d=s.top-a.top;Math.abs(n)<.5&&Math.abs(d)<.5||(t.style.transition="none",t.style.transform=`translate(${n}px, ${d}px)`,t.style.willChange="transform",t.getBoundingClientRect(),requestAnimationFrame(()=>{t.style.transition="transform 180ms ease",t.style.transform="";const o=()=>{t.style.transition="",t.style.willChange="",t.removeEventListener("transitionend",o)};t.addEventListener("transitionend",o),window.setTimeout(o,220)}))})}_previewCloneSubtreeItem(e,r){const t=e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id;return{...e,id:`${t}--preview`,label:r[0]===e.id?`${e.label} copy`:e.label}}_projectedMoveResult(){return!this._dragState?.dropTarget||!this._canDrop(this._dragState.dropTarget,this._dragState.movedRootIds)?null:de(this._items,this._lists,this._dragState.dropTarget,this._dragState.movedRootIds,this._dragState.clone,(e,r)=>this._previewCloneSubtreeItem(e,r))}_renderListTree(e,r,t,i,s,a,n){const d=$(e),o=P(e),u=p=>{const m=o.get(D(r.id,p))||[],_=this.sort==="label"?[...m].sort((v,b)=>{const y=d.get(v),x=d.get(b);return!y||!x?0:y.label.localeCompare(x.label)}):m;let f="";return _.forEach(v=>{const b=d.get(v);if(!b||b.hidden)return;const y=this._renderChildBranch(b,t,i,u,s,a,n);!W(b,this.filterQuery)&&!y.includes('class="item"')||(f+=this._renderDropzone({listId:r.id,parentId:p,beforeId:v,mode:"before"},"Drop here"),f+=y)}),f+=this._renderDropzone({listId:r.id,parentId:p,beforeId:null,mode:"before"},"Drop here"),f};return`<div class="tree">${u(null)}</div>`}_renderChildBranch(e,r,t,i,s,a,n){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";return`
789
+ `;const d=n.getBoundingClientRect();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");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(16,Math.min(d.top+(d.height-c)/2,window.innerHeight-c-16));a.style.setProperty("left",`${Math.round(h)}px`),a.style.setProperty("top",`${Math.round(f)}px`)}_setDraggingVisualState(e,t){e.forEach(r=>{const i=this._findItemElement(r);i&&(i.setAttribute("data-dragging",t?"true":"false"),i.setAttribute("aria-grabbed",t?"true":"false"),t&&i.getBoundingClientRect())})}_setDropTarget(e,t){const r=this._dragState?.dropTarget??null;if(!(!this._dragState||B(r,e))){if(this._pendingDropTarget=null,this._dragState.dropTarget=e,this._applyCurrentDropTargetVisualState(r),t?.announceLabel&&this._announce(t.announceLabel),this._dragState.keyboard){this.requestRender();return}this._updatePointerDragPreview()}}_queueDropTarget(e,t,r){if(!this._dragState)return;const i=this._dragState.dropTarget??null;if(B(i,e)){this._pendingDropTarget=null;return}if(!i&&e){this._setDropTarget(e,r);return}const s=typeof t=="number"&&Number.isFinite(t)?t:performance.now(),n=this._pendingDropTarget;if(n&&B(n.target,e)){const a=e?ne:ae;s-n.startedAt>=a&&this._setDropTarget(e,n.announceLabel?{announceLabel:n.announceLabel}:r);return}this._pendingDropTarget={target:e,startedAt:s,announceLabel:r?.announceLabel}}_releaseDropTarget(e,t){if(!this._dragState)return null;if(Number.isFinite(e)&&Number.isFinite(t)){const n=this._dropTargetFromPoint(e,t);if(n&&this._canDrop(n,this._dragState.movedRootIds))return this._pendingDropTarget=null,n}const r=this._pendingDropTarget?.target??null;this._pendingDropTarget=null;const i=n=>this._pointerIsOverList(n.listId,e,t);if(r&&this._canDrop(r,this._dragState.movedRootIds)&&i(r))return r;const s=this._dragState.dropTarget??null;return s&&this._canDrop(s,this._dragState.movedRootIds)&&i(s)?s:null}_pointerIsOverList(e,t,r){if(!Number.isFinite(t)||!Number.isFinite(r))return!0;const s=Array.from(this.root.querySelectorAll(".list[data-list-id]")).find(a=>a.getAttribute("data-list-id")===e);if(!s)return!0;const n=s.getBoundingClientRect();return t>=n.left&&t<=n.right&&r>=n.top&&r<=n.bottom}_pathFromPoint(e,t){const r=[],i=this.root;let s=typeof i.elementFromPoint=="function"?i.elementFromPoint(e,t):this.ownerDocument?.elementFromPoint(e,t)??null;for(;s&&(s instanceof HTMLElement&&r.push(s),s!==this);){if(s instanceof ShadowRoot){s=s.host;continue}s=s.parentNode,!s&&r[r.length-1]?.getRootNode()instanceof ShadowRoot&&(s=r[r.length-1].getRootNode().host)}return r}_measureItemShellRects(){const e=new Map;return this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(t=>{const r=t.getAttribute("data-item-shell");if(!r)return;const i=t.getBoundingClientRect();e.set(r,{top:i.top,left:i.left})}),e}_animateItemShellReflow(e){if(!e.size)return;const t=new Set(this._draggingIds());this.root.querySelectorAll(".item-shell[data-item-shell]").forEach(r=>{const i=r.getAttribute("data-item-shell");if(!i||t.has(i))return;const s=e.get(i);if(!s)return;const n=r.getBoundingClientRect(),a=s.left-n.left,d=s.top-n.top;Math.abs(a)<.5&&Math.abs(d)<.5||(r.style.transition="none",r.style.transform=`translate(${a}px, ${d}px)`,r.style.willChange="transform",r.getBoundingClientRect(),requestAnimationFrame(()=>{r.style.transition="transform 180ms ease",r.style.transform="";const o=()=>{r.style.transition="",r.style.willChange="",r.removeEventListener("transitionend",o)};r.addEventListener("transitionend",o),window.setTimeout(o,220)}))})}_previewCloneSubtreeItem(e,t){const r=e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id;return{...e,id:`${r}--preview`,label:t[0]===e.id?`${e.label} copy`:e.label}}_projectedMoveResult(){return!this._dragState?.dropTarget||!this._canDrop(this._dragState.dropTarget,this._dragState.movedRootIds)?null:ue(this._items,this._lists,this._dragState.dropTarget,this._dragState.movedRootIds,this._dragState.clone,(e,t)=>this._previewCloneSubtreeItem(e,t))}_renderListTree(e,t,r,i,s,n,a){const d=T(e),o=E(e),u=c=>{const h=o.get(k(t.id,c))||[],f=this.sort==="label"?[...h].sort((I,m)=>{const v=d.get(I),D=d.get(m);return!v||!D?0:v.label.localeCompare(D.label)}):h;let _="";return f.forEach(I=>{const m=d.get(I);if(!m||m.hidden)return;const v=this._renderChildBranch(m,r,i,u,s,n,a);!W(m,this.filterQuery)&&!v.includes('class="item"')||(_+=this._renderDropzone({listId:t.id,parentId:c,beforeId:I,mode:"before"},"Drop here"),_+=v)}),_+=this._renderDropzone({listId:t.id,parentId:c,beforeId:null,mode:"before"},"Drop here"),_};return`<div class="tree">${u(null)}</div>`}_renderChildBranch(e,t,r,i,s,n,a){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";return`
776
790
  <div class="item-shell" data-item-shell="${d}">
777
791
  <article
778
792
  class="item${o?" item-placeholder":""}"
779
793
  part="item"
780
794
  data-id="${d}"
781
- data-drag-handle-mode="${h}"
782
- ${!o&&h==="item"?'data-drag-trigger="item"':""}
783
- data-selected="${m}"
784
- data-focused="${o?"false":r===e.id}"
785
- data-dragging="${_}"
786
- data-disabled="${f}"
787
- data-drop-inside-active="${b?"true":"false"}"
795
+ data-drag-handle-mode="${b}"
796
+ ${!o&&b==="item"?'data-drag-trigger="item"':""}
797
+ data-selected="${h}"
798
+ data-focused="${o?"false":t===e.id}"
799
+ data-dragging="${f}"
800
+ data-disabled="${_}"
801
+ data-drop-inside-active="${m?"true":"false"}"
788
802
  role="${o?"presentation":"option"}"
789
- aria-selected="${o?"false":m}"
790
- aria-disabled="${f}"
791
- aria-grabbed="${o?"false":_}"
803
+ aria-selected="${o?"false":h}"
804
+ aria-disabled="${_}"
805
+ aria-grabbed="${o?"false":f}"
792
806
  aria-hidden="${o?"true":"false"}"
793
- tabindex="${o?"-1":r===e.id?"0":"-1"}"
807
+ tabindex="${o?"-1":t===e.id?"0":"-1"}"
794
808
  >
795
809
  ${o?`
796
810
  <div class="placeholder-content">
797
- <div class="placeholder-kicker">${I(y)}</div>
798
- <div class="placeholder-title">${I(e.label)}</div>
799
- <div class="placeholder-description">${I(x)}</div>
811
+ <div class="placeholder-kicker">${y(v)}</div>
812
+ <div class="placeholder-title">${y(e.label)}</div>
813
+ <div class="placeholder-description">${y(D)}</div>
800
814
  </div>
801
815
  `:`
802
- ${E?`
816
+ ${S?`
803
817
  <button
804
818
  class="handle"
805
819
  part="handle"
@@ -808,8 +822,8 @@
808
822
  data-drag-trigger="handle"
809
823
  data-id="${d}"
810
824
  draggable="false"
811
- ${v?"disabled":""}
812
- aria-label="Drag ${I(e.label)}"
825
+ ${I?"disabled":""}
826
+ aria-label="Drag ${y(e.label)}"
813
827
  >
814
828
  <svg viewBox="0 0 16 16" aria-hidden="true" focusable="false">
815
829
  <circle cx="5" cy="4" r="1.25"></circle>
@@ -824,10 +838,10 @@
824
838
  <div class="item-content" data-action="select" data-id="${d}">
825
839
  <div class="item-custom-content" part="item-custom-content" data-item-content-target="${d}"></div>
826
840
  <div class="item-default-content">
827
- <div class="item-title">${I(e.label)}</div>
828
- ${e.description?`<div class="item-description">${I(e.description)}</div>`:""}
841
+ <div class="item-title">${y(e.label)}</div>
842
+ ${e.description?`<div class="item-description">${y(e.description)}</div>`:""}
829
843
  <div class="item-meta">
830
- <span class="item-badge selection-badge" data-selection-badge="true" ${m&&n?"":"hidden"}>${m&&n?"Selected":""}</span>
844
+ <span class="item-badge selection-badge" data-selection-badge="true" ${h&&a?"":"hidden"}>${h&&a?"Selected":""}</span>
831
845
  ${e.cloneOnDrag?'<span class="item-badge">Clone on drag</span>':""}
832
846
  ${e.dragDisabled?'<span class="item-badge">Pinned</span>':""}
833
847
  ${s?'<span class="item-badge drop-badge">Nest here</span>':""}
@@ -837,19 +851,19 @@
837
851
  `}
838
852
  </article>
839
853
  ${s&&!o?this._renderDropzone({listId:e.listId,parentId:e.id,beforeId:null,mode:"inside"},"Nest here"):""}
840
- ${p?`<div class="children">${u}</div>`:""}
854
+ ${c?`<div class="children">${u}</div>`:""}
841
855
  </div>
842
- `}_renderDropzone(e,r){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;return`
856
+ `}_renderDropzone(e,t){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;return`
843
857
  <div
844
858
  class="dropzone"
845
859
  part="dropzone"
846
- data-list-id="${I(e.listId)}"
847
- data-parent-id="${I(e.parentId??"")}"
848
- data-before-id="${I(e.beforeId??"")}"
860
+ data-list-id="${y(e.listId)}"
861
+ data-parent-id="${y(e.parentId??"")}"
862
+ data-before-id="${y(e.beforeId??"")}"
849
863
  data-mode="${e.mode}"
850
- data-active="${t?"true":"false"}"
864
+ data-active="${r?"true":"false"}"
851
865
  aria-hidden="true"
852
866
  >
853
- <span class="dropzone-label">${I(r)}</span>
867
+ <span class="dropzone-label">${y(t)}</span>
854
868
  </div>
855
- `}_onClick(e){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"));if(i&&i.kind!=="item")return;if(!s)return t&&!(e.target instanceof HTMLButtonElement),void 0;const a=s.getAttribute("data-id");if(!a)return;const n=this._items.find(o=>o.id===a);if(!n||n.disabled)return;const d=e;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()){this._syncSelectionVisualState(),this._restorePendingFocus();return}this.requestRender()}_onFocusIn(e){const t=e.composedPath().find(i=>i instanceof HTMLElement&&i.classList.contains("item"))?.getAttribute("data-id");t&&(this._focusedId=t,this._syncSelectionVisualState())}_onKeyDown(e){const r=this._visibleItemIds();if(!r.length)return;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";if(!this._dragState?.keyboard){if(e.key==="ArrowDown"&&!n||e.key==="ArrowRight"&&n){e.preventDefault(),this._moveFocusBy(r,i,1);return}if(e.key==="ArrowUp"&&!n||e.key==="ArrowLeft"&&n){e.preventDefault(),this._moveFocusBy(r,i,-1);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"){e.preventDefault(),this._setSelection(r,"keyboard"),this._announce(`${r.length} items selected.`);return}if(e.key==="Enter"){e.preventDefault(),this._setSelection([t],"keyboard");return}if(e.key===" "||e.code==="Space"){if(e.preventDefault(),this._isDragLocked()){this._announce("Dragging is disabled right now.");return}const d=this._selectedRootIds(t);if(!d.length)return;const o=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map(A),movedRootIds:d,originId:t,clone:o,keyboard:!0,dropTarget:this._initialKeyboardDropTarget(t),committed:!1};const u=d.length===1?`Lifted ${s?.label||"item"}.`:`Lifted ${d.length} items.`;this._announce(`${u} Use arrow keys to choose a destination.`),this.requestRender();return}if(e.key==="Escape"){this._setSelection([],"keyboard");return}return}if(e.key==="Escape"){e.preventDefault(),this._cancelDrag(!0);return}if(e.key==="Enter"||e.key===" "||e.code==="Space"){e.preventDefault();const d=this._dragState.dropTarget;if(!d)return;this._commitMove(d,this._dragState.movedRootIds,this._dragState.clone,"keyboard");return}if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const d=e.key==="ArrowDown"||e.key==="ArrowRight"?1:-1;this._moveKeyboardDropTarget(d)}}_moveFocusBy(e,r,t){const i=Math.max(0,Math.min(e.length-1,r+t)),s=e[i];this._focusedId=s,this._pendingFocusId=s,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender()}_onDragStart(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r?.id;if(!r||!t){e.preventDefault();return}if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(n=>n.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._selection.includes(t)||this._setSelection([t],"pointer");const a=this._itemClonesOnDrag(t);this._dragState={snapshot:this._items.map(A),movedRootIds:s,originId:t,clone:a,keyboard:!1,dropTarget:null,committed:!1},e.dataTransfer&&(e.dataTransfer.effectAllowed=a?"copyMove":"move",e.dataTransfer.setData("text/plain",s.join(",")),this._applyDragImage(e.dataTransfer,s.length)),this._announce(a?`Dragging ${s.length===1?i.label:`${s.length} items`} as a copy.`:`Dragging ${s.length===1?i.label:`${s.length} items`}.`),this.requestRender()}_onDragOver(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}e.preventDefault(),this._queueDropTarget(r,e.timeStamp),e.dataTransfer&&(e.dataTransfer.dropEffect=this._dragState.clone?"copy":"move")}_onDrop(e){if(!this._dragState||this._dragState.keyboard)return;const r=this._dropTargetFromEvent(e);!r||!this._canDrop(r,this._dragState.movedRootIds)||(e.preventDefault(),this._commitMove(r,this._dragState.movedRootIds,this._dragState.clone,"pointer"))}_onDocumentKeyDown(e){e.key==="Escape"&&(!this._dragState||this._dragState.keyboard||(e.preventDefault(),this._cancelDrag(!0)))}_onDragEnd(){!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())}_dropTargetFromEvent(e){return this._dropTargetFromPath(e.composedPath(),e.clientX,e.clientY)}_dropTargetFromPath(e,r,t){const i=e.find(h=>h instanceof HTMLElement&&h.classList.contains("dropzone"));if(i){const h={listId:i.getAttribute("data-list-id")||"",parentId:i.getAttribute("data-parent-id")||null,beforeId:i.getAttribute("data-before-id")||null,mode:i.getAttribute("data-mode")==="inside"?"inside":"before"};if(h.listId)return h}const s=e.find(h=>h instanceof HTMLElement&&h.classList.contains("item"));if(!s)return null;const a=s.getAttribute("data-id");if(!a)return null;const n=this._items.find(h=>h.id===a);if(!n)return null;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;if(v<=.34)return{listId:n.listId,parentId:n.parentId,beforeId:n.id,mode:"before"};if(b&&v>=.34&&v<=.74)return{listId:n.listId,parentId:n.id,beforeId:null,mode:"inside"};const x=P(this._items).get(D(n.listId,n.parentId))||[],z=x.indexOf(n.id),k=z>=0&&x[z+1]||null;return{listId:n.listId,parentId:n.parentId,beforeId:k,mode:"before"}}_dropTargetFromPoint(e,r){return this._dropTargetFromPath(this._pathFromPoint(e,r),e,r)}_beginPointerDrag(e,r){if(!this._pointerGesture||this._dragState)return;const t=this._items.find(i=>i.id===this._pointerGesture?.originId);t&&(this._dragState={snapshot:this._items.map(A),movedRootIds:[...this._pointerGesture.movedRootIds],originId:this._pointerGesture.originId,clone:this._pointerGesture.clone,keyboard:!1,dropTarget:null,committed:!1},this._pendingDropTarget=null,this._applyPointerPreview(e,r,this._dragState.movedRootIds.length,this._dragState.clone),this._setDraggingVisualState(this._draggingIds(),!0),this._announce(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`}.`))}_onPointerDown(e){const r=this._dragActivatorFromPath(e.composedPath()),t=r?.id;if(!r||!t)return;if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(a=>a.id===t);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}e.preventDefault();try{r.element.setPointerCapture?.(e.pointerId)}catch{}const s=this._selection.includes(t)?this._selectedRootIds(t):[t];this._pointerGesture={pointerId:e.pointerId,pointerType:e.pointerType,originId:t,movedRootIds:s,clone:this._itemClonesOnDrag(t),startX:e.clientX,startY:e.clientY,moved:!1,captureTarget:r.element}}_onPointerMove(e){if(!(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)){if(e.preventDefault(),!this._pointerGesture.moved){if(Math.hypot(e.clientX-this._pointerGesture.startX,e.clientY-this._pointerGesture.startY)<6)return;this._pointerGesture.moved=!0,this._beginPointerDrag(e.clientX,e.clientY)}if(!(!this._dragState||this._dragState.keyboard)&&(this._movePointerPreview(e.clientX,e.clientY),!this._dragState.committed)){const r=this._dropTargetFromPoint(e.clientX,e.clientY);if(!r||!this._canDrop(r,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}this._queueDropTarget(r,e.timeStamp)}}}_onPointerUp(e){if(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)return;e.preventDefault();try{this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId)}catch{}const r=this._pointerGesture;if(this._pointerGesture=null,!this._dragState||this._dragState.keyboard)return;const t=r.moved?this._releaseDropTarget(e.clientX,e.clientY):null;if(r.moved&&t){this._commitMove(t,this._dragState.movedRootIds,this._dragState.clone,"pointer");return}r.moved?this._cancelDrag(!0):(this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this.requestRender())}_onPointerCancel(e){!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId||(this._pointerGesture=null,this._dragState&&this._cancelDrag(!0))}_setSelection(e,r){const t=new Set(this._items.map(n=>n.id)),i=Array.from(new Set(e.filter(n=>t.has(n)))),s=[...this._selection];this._selection=i,this._rangeAnchorId=i[i.length-1]||null,this._focusedId=i[i.length-1]||this._focusedId;const a=U(i);if(this.getAttribute("selection")!==a){this._lastSelectionAttr=a,this._suppressAttributeRender=!0;try{i.length?this.setAttribute("selection",a):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}if(this.dispatchEvent(new CustomEvent("selection-change",{detail:{selection:[...i],previousSelection:s},bubbles:!0,composed:!0})),r!=="restore"){if(this._applyInteractiveStateInPlace({restoreFocus:!0}))return;this.requestRender()}}_toggleSelection(e){const r=this._selection.includes(e)?this._selection.filter(t=>t!==e):[...this._selection,e];this._setSelection(r,"pointer"),this._announce(`${r.length} items selected.`)}_selectRangeTo(e){const r=this._visibleItemIds(),t=this._rangeAnchorId||this._focusedId||e,i=r.indexOf(t),s=r.indexOf(e);if(i<0||s<0){this._setSelection([e],"pointer");return}const[a,n]=i<=s?[i,s]:[s,i];this._setSelection(r.slice(a,n+1),"pointer"),this._announce(`${n-a+1} items selected.`)}_visibleItemIds(){const e=Q(this._items,new Set(this._selection),new Set(this._draggingIds()),this.filterQuery,this.sort);return Array.from(e.values()).flat().filter(r=>!r.disabled).map(r=>r.id)}_selectedRootIds(e){const r=this._selection.length?[...this._selection]:e?[e]:[],t=$(this._items),i=new Set(r);return r.filter(s=>{const a=t.get(s);if(!a)return!1;let n=a.parentId;for(;n;){if(i.has(n))return!1;n=t.get(n)?.parentId??null}return!a.disabled})}_draggingIds(){if(!this._dragState)return[];const e=$(this._items),r=P(this._items),t=[],i=s=>{t.push(s);const a=e.get(s);if(!a)return;(r.get(D(a.listId,s))||[]).forEach(i)};return this._dragState.movedRootIds.forEach(i),t}_itemClonesOnDrag(e){const r=this._items.find(i=>i.id===e);return r?r.cloneOnDrag?!0:!!this._lists.find(i=>i.id===r.listId)?.cloneOnDrag:!1}_isDragLocked(){return!!(this.hasAttribute("disabled")||this.sort!=="manual"||this.filterQuery&&!this.hasAttribute("allow-filtered-drag"))}_canDrop(e,r){if(this._isDragLocked())return!1;const t=this._lists.find(o=>o.id===e.listId);if(!t||t.disabled)return!1;const i=$(this._items),s=new Set,a=P(this._items),n=o=>{s.add(o);const u=i.get(o);u&&(a.get(D(u.listId,o))||[]).forEach(n)};if(r.forEach(n),e.parentId&&s.has(e.parentId)||e.beforeId&&s.has(e.beforeId))return!1;const d=Array.from(new Set(r.map(o=>i.get(o)?.listId).filter(Boolean)));return!(t.accepts?.length&&d.some(o=>!t.accepts?.includes(o))||e.mode==="inside"&&this.getAttribute("allow-nesting")==="false")}_commitMove(e,r,t,i){if(!this._canDrop(e,r))return;const s=$(this._items),a=P(this._items),n=new Set,d=[],o=c=>{const w=s.get(c);!w||n.has(c)||(n.add(c),d.push(c),(a.get(D(w.listId,c))||[]).forEach(o))};r.forEach(o);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=new Map,v=new Map;t&&p.forEach((c,w)=>{f.set(c.id,_[w].id),v.set(_[w].id,c.id)}),_.forEach(c=>{const w=t?v.get(c.id):c.id,C=w?s.get(w):null;C&&(t&&(c.parentId=C.parentId&&f.has(C.parentId)&&f.get(C.parentId)||null),c.listId=e.listId)});const b=r.map(c=>f.get(c)||c),y=[...m,..._],x=P(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;k.splice(E,0,...b),x.set(z,k),P(_).forEach((c,w)=>{const[,C]=w.split("::");(C||"")!=="__root__"&&x.set(w,[...c])});const L=$(y);b.forEach(c=>{const w=L.get(c);w&&(w.parentId=e.parentId,w.listId=e.listId)});const F=[],M=new Set,O=(c,w)=>{(x.get(D(c,w))||[]).forEach((N,ee)=>{const G=L.get(N);!G||M.has(N)||(M.add(N),G.listId=c,G.parentId=w,G.order=ee,F.push(G),O(c,N))})};this._lists.forEach(c=>O(c.id,null)),y.forEach(c=>{M.has(c.id)||(c.parentId=null,F.push(c))}),this._dragState&&(this._dragState.committed=!0),this._items=F.map(A),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage();const q=[...b],g=[...this._selection];this._selection=q,this._focusedId=q[0]||null,this._pendingFocusId=this._focusedId,this._syncAttributesFromState();const S=J(this._items);this._persistSnapshot(S);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={items:this.items,lists:this.lists,selection:[...q],previousSelection:g,movedIds:[...b],source:i,operation:R,persistence:S};this.dispatchEvent(new CustomEvent("change",{detail:K,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("persist-request",{detail:K,bubbles:!0,composed:!0})),this._announce(this._messageForMove(R,b.length,e)),this.requestRender()}_syncAttributesFromState(){const e=ce(this._lists),r=le(this._items),t=U(this._selection);this._lastListsAttr=e,this._lastItemsAttr=r,this._lastSelectionAttr=t,this._suppressAttributeRender=!0;try{this.setAttribute("lists",e),this.setAttribute("items",r),this._selection.length?this.setAttribute("selection",t):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}_cloneSubtreeItem(e,r){const i=`copy-${this._cloneSeed++}`,a=`${e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id}--${i}`;return{...e,id:a,label:r[0]===e.id?`${e.label} copy`:e.label}}_messageForMove(e,r,t){const s=this._lists.find(a=>a.id===t.listId)?.label||t.listId;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}.`}_persistSnapshot(e){const r=this.getAttribute("persist-key");if(r)try{window.localStorage.setItem(r,JSON.stringify(e))}catch{}}_announce(e){this._liveMessage=e,this._applyLiveMessage()}_cancelDrag(e){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())}_applyDragImage(e,r){this._removeDragImage();const t=document.createElement("div");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}_removeDragImage(){this._dragImage?.remove(),this._dragImage=null}_removeDragPreviewOverlay(){this._dragPreviewOverlay?.remove(),this._dragPreviewOverlay=null}_applyPointerPreview(e,r,t,i){this._removeDragImage();const s=document.createElement("div");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)}_movePointerPreview(e,r){this._dragImage&&(this._dragImage.style.transform=`translate(${Math.round(e+14)}px, ${Math.round(r+14)}px)`)}_keyboardDropTargets(){const e=$(this._items),r=P(this._items),t=[],i=(s,a)=>{(r.get(D(s,a))||[]).forEach(d=>{const o=e.get(d);!o||o.hidden||(t.push({listId:s,parentId:a,beforeId:d,mode:"before",label:`Before ${o.label}`}),this.getAttribute("allow-nesting")!=="false"&&t.push({listId:s,parentId:d,beforeId:null,mode:"inside",label:`Nest inside ${o.label}`}),i(s,d))}),t.push({listId:s,parentId:a,beforeId:null,mode:"before",label:a?"After children":`End of ${this._lists.find(d=>d.id===s)?.label||s}`})};return this._lists.forEach(s=>i(s.id,null)),t.filter(s=>this._canDrop(s,this._dragState?.movedRootIds||[]))}_initialKeyboardDropTarget(e){const r=this._items.find(t=>t.id===e);return r?{listId:r.listId,parentId:r.parentId,beforeId:e,mode:"before"}:null}_moveKeyboardDropTarget(e){if(!this._dragState)return;const r=this._keyboardDropTargets();if(!r.length)return;const t=Math.max(0,r.findIndex(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)),i=Math.max(0,Math.min(r.length-1,t+e));this._setDropTarget(r[i],{announceLabel:r[i].label})}}typeof customElements<"u"&&!customElements.get("ui-sortable")&&customElements.define("ui-sortable",Z);exports.UISortable=Z;
869
+ `}_onClick(e){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"));if(i&&i.kind!=="item")return;if(!s)return r&&!(e.target instanceof HTMLButtonElement),void 0;const n=s.getAttribute("data-id");if(!n)return;const a=this._items.find(o=>o.id===n);if(!a||a.disabled)return;const d=e;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()){this._syncSelectionVisualState(),this._restorePendingFocus();return}this.requestRender()}_onFocusIn(e){const r=e.composedPath().find(i=>i instanceof HTMLElement&&i.classList.contains("item"))?.getAttribute("data-id");r&&(this._focusedId=r,this._syncSelectionVisualState())}_isForeignControl(e){const t=e.composedPath()[0];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"]')}_onKeyDown(e){if(this._isForeignControl(e))return;const t=this._visibleItemIds();if(!t.length)return;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";if(!this._dragState?.keyboard){if(e.key===o){e.preventDefault(),this._moveFocusBy(t,i,1);return}if(e.key===u){e.preventDefault(),this._moveFocusBy(t,i,-1);return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="a"){e.preventDefault(),this._setSelection(t,"keyboard"),this._announce(`${t.length} items selected.`);return}if(e.key==="Enter"){e.preventDefault(),this._setSelection([r],"keyboard");return}if(e.key===" "||e.code==="Space"){if(e.preventDefault(),this._isDragLocked()){this._announce("Dragging is disabled right now.");return}const c=this._selectedRootIds(r);if(!c.length)return;const h=this._itemClonesOnDrag(r);this._dragState={snapshot:this._items.map(P),movedRootIds:c,originId:r,clone:h,keyboard:!0,dropTarget:this._initialKeyboardDropTarget(r),committed:!1};const f=c.length===1?`Lifted ${s?.label||"item"}.`:`Lifted ${c.length} items.`;this._announce(`${f} Use arrow keys to choose a destination.`),this.requestRender();return}if(e.key==="Escape"){this._setSelection([],"keyboard");return}return}if(e.key==="Escape"){e.preventDefault(),this._cancelDrag(!0);return}if(e.key==="Enter"||e.key===" "||e.code==="Space"){e.preventDefault();const c=this._dragState.dropTarget;if(!c)return;this._commitMove(c,this._dragState.movedRootIds,this._dragState.clone,"keyboard");return}if(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"].includes(e.key)){e.preventDefault();const c=d?"ArrowLeft":"ArrowRight",h=e.key==="ArrowDown"||e.key===c?1:-1;this._moveKeyboardDropTarget(h)}}_isRtl(){const e=this.ownerDocument?.defaultView?.getComputedStyle(this).direction;return e?e==="rtl":this.closest("[dir]")?.getAttribute("dir")==="rtl"}_moveFocusBy(e,t,r){const i=Math.max(0,Math.min(e.length-1,t+r)),s=e[i];this._focusedId=s,this._pendingFocusId=s,!this._applyInteractiveStateInPlace({restoreFocus:!0})&&this.requestRender()}_onDragStart(e){const t=this._dragActivatorFromPath(e.composedPath()),r=t?.id;if(!t||!r){e.preventDefault();return}if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(a=>a.id===r);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}const s=this._selection.includes(r)?this._selectedRootIds(r):[r];this._selection.includes(r)||this._setSelection([r],"pointer");const n=this._itemClonesOnDrag(r);this._dragState={snapshot:this._items.map(P),movedRootIds:s,originId:r,clone:n,keyboard:!1,dropTarget:null,committed:!1},e.dataTransfer&&(e.dataTransfer.effectAllowed=n?"copyMove":"move",e.dataTransfer.setData("text/plain",s.join(",")),this._applyDragImage(e.dataTransfer,s.length)),this._announce(n?`Dragging ${s.length===1?i.label:`${s.length} items`} as a copy.`:`Dragging ${s.length===1?i.label:`${s.length} items`}.`),this.requestRender()}_onDragOver(e){if(!this._dragState||this._dragState.keyboard)return;const t=this._dropTargetFromEvent(e);if(!t||!this._canDrop(t,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}e.preventDefault(),this._queueDropTarget(t,e.timeStamp),e.dataTransfer&&(e.dataTransfer.dropEffect=this._dragState.clone?"copy":"move")}_onDrop(e){if(!this._dragState||this._dragState.keyboard)return;const t=this._dropTargetFromEvent(e);!t||!this._canDrop(t,this._dragState.movedRootIds)||(e.preventDefault(),this._commitMove(t,this._dragState.movedRootIds,this._dragState.clone,"pointer"))}_onDocumentKeyDown(e){e.key==="Escape"&&(!this._dragState||this._dragState.keyboard||(e.preventDefault(),this._cancelDrag(!0)))}_onDragEnd(){!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())}_dropTargetFromEvent(e){return this._dropTargetFromPath(e.composedPath(),e.clientX,e.clientY)}_dropTargetFromPath(e,t,r){const i=e.find(S=>S instanceof HTMLElement&&S.classList.contains("dropzone"));if(i){const S={listId:i.getAttribute("data-list-id")||"",parentId:i.getAttribute("data-parent-id")||null,beforeId:i.getAttribute("data-before-id")||null,mode:i.getAttribute("data-mode")==="inside"?"inside":"before"};if(S.listId)return S}const s=e.find(S=>S instanceof HTMLElement&&S.classList.contains("item"));if(!s){const R=e.find($=>$ instanceof HTMLElement&&$.classList.contains("list")&&$.hasAttribute("data-list-id"))?.getAttribute("data-list-id");return R?{listId:R,parentId:null,beforeId:null,mode:"before"}:null}const n=s.getAttribute("data-id");if(!n)return null;const a=this._items.find(S=>S.id===n);if(!a)return null;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;if(m<=.34)return{listId:a.listId,parentId:a.parentId,beforeId:a.id,mode:"before"};if(v&&m>=.34&&m<=.74)return{listId:a.listId,parentId:a.id,beforeId:null,mode:"inside"};const A=E(this._items).get(k(a.listId,a.parentId))||[],z=A.indexOf(a.id),b=z>=0&&A[z+1]||null;return{listId:a.listId,parentId:a.parentId,beforeId:b,mode:"before"}}_dropTargetFromPoint(e,t){return this._dropTargetFromPath(this._pathFromPoint(e,t),e,t)}_beginPointerDrag(e,t){if(!this._pointerGesture||this._dragState)return;const r=this._items.find(i=>i.id===this._pointerGesture?.originId);r&&(this._dragState={snapshot:this._items.map(P),movedRootIds:[...this._pointerGesture.movedRootIds],originId:this._pointerGesture.originId,clone:this._pointerGesture.clone,keyboard:!1,dropTarget:null,committed:!1},this._pendingDropTarget=null,this._applyPointerPreview(e,t,this._dragState.movedRootIds.length,this._dragState.clone),this._setDraggingVisualState(this._draggingIds(),!0),this._announce(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`}.`))}_onPointerDown(e){const t=this._dragActivatorFromPath(e.composedPath()),r=t?.id;if(!t||!r)return;if(this._isDragLocked()){e.preventDefault(),this._announce("Dragging is disabled right now.");return}const i=this._items.find(n=>n.id===r);if(!i||i.disabled||i.dragDisabled){e.preventDefault();return}e.preventDefault();try{t.element.setPointerCapture?.(e.pointerId)}catch{}const s=this._selection.includes(r)?this._selectedRootIds(r):[r];this._pointerGesture={pointerId:e.pointerId,pointerType:e.pointerType,originId:r,movedRootIds:s,clone:this._itemClonesOnDrag(r),startX:e.clientX,startY:e.clientY,moved:!1,captureTarget:t.element}}_onPointerMove(e){if(!(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)){if(e.preventDefault(),!this._pointerGesture.moved){if(Math.hypot(e.clientX-this._pointerGesture.startX,e.clientY-this._pointerGesture.startY)<6)return;this._pointerGesture.moved=!0,this._beginPointerDrag(e.clientX,e.clientY)}if(!(!this._dragState||this._dragState.keyboard)&&(this._movePointerPreview(e.clientX,e.clientY),this._updateAutoScroll(e.clientX,e.clientY),!this._dragState.committed)){const t=this._dropTargetFromPoint(e.clientX,e.clientY);if(!t||!this._canDrop(t,this._dragState.movedRootIds)){this._queueDropTarget(null,e.timeStamp);return}this._queueDropTarget(t,e.timeStamp)}}}_updateAutoScroll(e,t){this._autoScrollPoint={x:e,y:t},!this._autoScrollFrame&&typeof requestAnimationFrame=="function"&&(this._autoScrollFrame=requestAnimationFrame(this._autoScrollTick))}_stopAutoScroll(){this._autoScrollFrame&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(this._autoScrollFrame),this._autoScrollFrame=0,this._autoScrollPoint=null}_onPointerUp(e){if(!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId)return;e.preventDefault();try{this._pointerGesture.captureTarget?.releasePointerCapture?.(e.pointerId)}catch{}const t=this._pointerGesture;if(this._pointerGesture=null,this._stopAutoScroll(),!this._dragState||this._dragState.keyboard)return;const r=t.moved?this._releaseDropTarget(e.clientX,e.clientY):null;if(t.moved&&r){this._commitMove(r,this._dragState.movedRootIds,this._dragState.clone,"pointer");return}t.moved?this._cancelDrag(!0):(this._setDropTargetVisualState(this._dragState.dropTarget,!1),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage(),this.requestRender())}_onPointerCancel(e){!this._pointerGesture||e.pointerId!==this._pointerGesture.pointerId||(this._pointerGesture=null,this._stopAutoScroll(),this._dragState&&this._cancelDrag(!0))}_setSelection(e,t){const r=new Set(this._items.map(a=>a.id)),i=Array.from(new Set(e.filter(a=>r.has(a)))),s=[...this._selection];this._selection=i,this._rangeAnchorId=i[i.length-1]||null,this._focusedId=i[i.length-1]||this._focusedId;const n=X(i);if(this.getAttribute("selection")!==n){this._lastSelectionAttr=n,this._suppressAttributeRender=!0;try{i.length?this.setAttribute("selection",n):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}if(this.dispatchEvent(new CustomEvent("selection-change",{detail:{selection:[...i],previousSelection:s},bubbles:!0,composed:!0})),t!=="restore"){if(this._applyInteractiveStateInPlace({restoreFocus:!0}))return;this.requestRender()}}_toggleSelection(e){const t=this._selection.includes(e)?this._selection.filter(r=>r!==e):[...this._selection,e];this._setSelection(t,"pointer"),this._announce(`${t.length} items selected.`)}_selectRangeTo(e){const t=this._visibleItemIds(),r=this._rangeAnchorId||this._focusedId||e,i=t.indexOf(r),s=t.indexOf(e);if(i<0||s<0){this._setSelection([e],"pointer");return}const[n,a]=i<=s?[i,s]:[s,i];this._setSelection(t.slice(n,a+1),"pointer"),this._announce(`${a-n+1} items selected.`)}_visibleItemIds(){const e=Q(this._items,new Set(this._selection),new Set(this._draggingIds()),this.filterQuery,this.sort);return Array.from(e.values()).flat().filter(t=>!t.disabled).map(t=>t.id)}_selectedRootIds(e){const t=this._selection.length?[...this._selection]:e?[e]:[],r=T(this._items),i=new Set(t);return t.filter(s=>{const n=r.get(s);if(!n)return!1;let a=n.parentId;for(;a;){if(i.has(a))return!1;a=r.get(a)?.parentId??null}return!n.disabled})}_draggingIds(){if(!this._dragState)return[];const e=T(this._items),t=E(this._items),r=[],i=s=>{r.push(s);const n=e.get(s);if(!n)return;(t.get(k(n.listId,s))||[]).forEach(i)};return this._dragState.movedRootIds.forEach(i),r}_itemClonesOnDrag(e){const t=this._items.find(i=>i.id===e);return t?t.cloneOnDrag?!0:!!this._lists.find(i=>i.id===t.listId)?.cloneOnDrag:!1}_isDragLocked(){return!!(this.hasAttribute("disabled")||this.sort!=="manual"||this.filterQuery&&!this.hasAttribute("allow-filtered-drag"))}_canDrop(e,t){if(this._isDragLocked())return!1;const r=this._lists.find(o=>o.id===e.listId);if(!r||r.disabled)return!1;const i=T(this._items),s=new Set,n=E(this._items),a=o=>{s.add(o);const u=i.get(o);u&&(n.get(k(u.listId,o))||[]).forEach(a)};if(t.forEach(a),e.parentId&&s.has(e.parentId)||e.beforeId&&s.has(e.beforeId))return!1;const d=Array.from(new Set(t.map(o=>i.get(o)?.listId).filter(Boolean)));return!(r.accepts?.length&&d.some(o=>!r.accepts?.includes(o))||e.mode==="inside"&&this.getAttribute("allow-nesting")==="false")}_commitMove(e,t,r,i){if(!this._canDrop(e,t))return;const s=T(this._items),n=E(this._items),a=new Set,d=[],o=p=>{const w=s.get(p);!w||a.has(p)||(a.add(p),d.push(p),(n.get(k(w.listId,p))||[]).forEach(o))};t.forEach(o);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),_=new Map,I=new Map;r&&c.forEach((p,w)=>{_.set(p.id,f[w].id),I.set(f[w].id,p.id)}),f.forEach(p=>{const w=r?I.get(p.id):p.id,F=w?s.get(w):null;F&&(r&&(p.parentId=F.parentId&&_.has(F.parentId)&&_.get(F.parentId)||null),p.listId=e.listId)});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;z.splice(S,0,...m),D.set(A,z),E(f).forEach((p,w)=>{const[,F]=w.split("::");(F||"")!=="__root__"&&D.set(w,[...p])});const $=T(v);m.forEach(p=>{const w=$.get(p);w&&(w.parentId=e.parentId,w.listId=e.listId)});const O=[],L=new Set,q=(p,w)=>{(D.get(k(p,w))||[]).forEach((V,ee)=>{const N=$.get(V);!N||L.has(V)||(L.add(V),N.listId=p,N.parentId=w,N.order=ee,O.push(N),q(p,V))})};this._lists.forEach(p=>q(p.id,null)),v.forEach(p=>{L.has(p.id)||(p.parentId=null,O.push(p))}),this._dragState&&(this._dragState.committed=!0),this._items=O.map(P),this._clearPointerDragPreview(),this._dragState=null,this._removeDragImage();const H=[...m],g=[...this._selection];this._selection=H,this._focusedId=H[0]||null,this._pendingFocusId=this._focusedId,this._syncAttributesFromState();const x=J(this._items);this._persistSnapshot(x);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={items:this.items,lists:this.lists,selection:[...H],previousSelection:g,movedIds:[...m],source:i,operation:C,persistence:x};this.dispatchEvent(new CustomEvent("change",{detail:G,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("persist-request",{detail:G,bubbles:!0,composed:!0})),this._announce(this._messageForMove(C,m.length,e)),this.requestRender()}_syncAttributesFromState(){const e=he(this._lists),t=pe(this._items),r=X(this._selection);this._lastListsAttr=e,this._lastItemsAttr=t,this._lastSelectionAttr=r,this._suppressAttributeRender=!0;try{this.setAttribute("lists",e),this.setAttribute("items",t),this._selection.length?this.setAttribute("selection",r):this.removeAttribute("selection")}finally{this._suppressAttributeRender=!1}}_cloneSubtreeItem(e,t){const i=`copy-${this._cloneSeed++}`,n=`${e.id.includes("--copy-")?e.id.split("--copy-")[0]:e.id}--${i}`;return{...e,id:n,label:t[0]===e.id?`${e.label} copy`:e.label}}_messageForMove(e,t,r){const s=this._lists.find(n=>n.id===r.listId)?.label||r.listId;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}.`}_persistSnapshot(e){const t=this.getAttribute("persist-key");if(t)try{window.localStorage.setItem(t,JSON.stringify(e))}catch{}}_announce(e){this._liveMessage=e,this._applyLiveMessage()}_cancelDrag(e){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())}_applyDragImage(e,t){this._removeDragImage();const r=document.createElement("div");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}_removeDragImage(){this._dragImage?.remove(),this._dragImage=null}_removeDragPreviewOverlay(){this._dragPreviewOverlay?.remove(),this._dragPreviewOverlay=null}_applyPointerPreview(e,t,r,i){this._removeDragImage();const s=document.createElement("div");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)}_movePointerPreview(e,t){this._dragImage&&(this._dragImage.style.transform=`translate(${Math.round(e+14)}px, ${Math.round(t+14)}px)`)}_keyboardDropTargets(){const e=T(this._items),t=E(this._items),r=[],i=this.getAttribute("allow-nesting")!=="false",s=(n,a)=>{const d=t.get(k(n,a))||[];d.forEach(o=>{const u=e.get(o);!u||u.hidden||(r.push({listId:n,parentId:a,beforeId:o,mode:"before",label:`Before ${u.label}`}),i&&r.push({listId:n,parentId:o,beforeId:null,mode:"inside",label:`Nest inside ${u.label}`}),s(n,o))}),a?i&&d.length>0&&r.push({listId:n,parentId:a,beforeId:null,mode:"before",label:"After children"}):r.push({listId:n,parentId:a,beforeId:null,mode:"before",label:`End of ${this._lists.find(o=>o.id===n)?.label||n}`})};return this._lists.forEach(n=>s(n.id,null)),r.filter(n=>this._canDrop(n,this._dragState?.movedRootIds||[]))}_initialKeyboardDropTarget(e){const t=this._items.find(r=>r.id===e);return t?{listId:t.listId,parentId:t.parentId,beforeId:e,mode:"before"}:null}_moveKeyboardDropTarget(e){if(!this._dragState)return;const t=this._keyboardDropTargets();if(!t.length)return;const r=Math.max(0,t.findIndex(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)),i=Math.max(0,Math.min(t.length-1,r+e));this._setDropTarget(t[i],{announceLabel:t[i].label})}}typeof customElements<"u"&&!customElements.get("ui-sortable")&&customElements.define("ui-sortable",Z);exports.UISortable=Z;