Files
app/dist/assets/useSortableList-CgbuKaxB.js
2026-03-13 09:19:40 +01:00

6 lines
44 KiB
JavaScript

import{r as c,c as P,a as Oe}from"./vendor-react-BVs3cwbi.js";import{j as oe}from"./vendor-animation-0s3FMHwK.js";function wn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const et=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ye(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function vt(e){return"nodeType"in e}function B(e){var t,n;return e?ye(e)?e:vt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function pt(e){const{Document:t}=B(e);return e instanceof t}function je(e){return ye(e)?!1:e instanceof B(e).HTMLElement}function Ut(e){return e instanceof B(e).SVGElement}function xe(e){return e?ye(e)?e.document:vt(e)?pt(e)?e:je(e)||Ut(e)?e.ownerDocument:document:document:document}const Q=et?c.useLayoutEffect:c.useEffect;function bt(e){const t=c.useRef(e);return Q(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function yn(){const e=c.useRef(null),t=c.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=c.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ze(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Q(()=>{n.current!==e&&(n.current=e)},t),n}function $e(e,t){const n=c.useRef();return c.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Je(e){const t=bt(e),n=c.useRef(null),r=c.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function ut(e){const t=c.useRef();return c.useEffect(()=>{t.current=e},[e]),t.current}let st={};function Fe(e,t){return c.useMemo(()=>{if(t)return t;const n=st[e]==null?0:st[e]+1;return st[e]=n,e+"-"+n},[e,t])}function Wt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,u]of a){const d=i[l];d!=null&&(i[l]=d+e*u)}return i},{...t})}}const we=Wt(1),_e=Wt(-1);function xn(e){return"clientX"in e&&"clientY"in e}function mt(e){if(!e)return!1;const{KeyboardEvent:t}=B(e.target);return t&&e instanceof t}function Dn(e){if(!e)return!1;const{TouchEvent:t}=B(e.target);return t&&e instanceof t}function dt(e){if(Dn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return xn(e)?{x:e.clientX,y:e.clientY}:null}const Pe=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Pe.Translate.toString(e),Pe.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Ot="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Sn(e){return e.matches(Ot)?e:e.querySelector(Ot)}const Cn={display:"none"};function Rn(e){let{id:t,value:n}=e;return P.createElement("div",{id:t,style:Cn},n)}function En(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return P.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Mn(){const[e,t]=c.useState("");return{announce:c.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Ht=c.createContext(null);function In(e){const t=c.useContext(Ht);c.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function An(){const[e]=c.useState(()=>new Set),t=c.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[c.useCallback(r=>{let{type:o,event:i}=r;e.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[e]),t]}const Tn={draggable:`
To pick up a draggable item, press the space bar.
While dragging, use the arrow keys to move the item.
Press space again to drop the item in its new position, or press escape to cancel.
`},On={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Nn(e){let{announcements:t=On,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=Tn}=e;const{announce:i,announcement:s}=Mn(),a=Fe("DndLiveRegion"),[l,u]=c.useState(!1);if(c.useEffect(()=>{u(!0)},[]),In(c.useMemo(()=>({onDragStart(f){let{active:v}=f;i(t.onDragStart({active:v}))},onDragMove(f){let{active:v,over:h}=f;t.onDragMove&&i(t.onDragMove({active:v,over:h}))},onDragOver(f){let{active:v,over:h}=f;i(t.onDragOver({active:v,over:h}))},onDragEnd(f){let{active:v,over:h}=f;i(t.onDragEnd({active:v,over:h}))},onDragCancel(f){let{active:v,over:h}=f;i(t.onDragCancel({active:v,over:h}))}}),[i,t])),!l)return null;const d=P.createElement(P.Fragment,null,P.createElement(Rn,{id:r,value:o.draggable}),P.createElement(En,{id:a,announcement:s}));return n?Oe.createPortal(d,n):d}var T;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(T||(T={}));function Qe(){}function no(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function ro(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const V=Object.freeze({x:0,y:0});function Ln(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function kn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function zn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Pn(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Nt(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const oo=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Nt(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const u=Ln(Nt(l),o);i.push({id:a,data:{droppableContainer:s,value:u}})}}return i.sort(kn)};function Bn(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,u=e.width*e.height,d=s*a,f=d/(l+u-d);return Number(f.toFixed(4))}return 0}const jn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Bn(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(zn)};function $n(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Kt(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:V}function Fn(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const Xn=Fn(1);function Yn(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Un(e,t,n){const r=Yn(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),u=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=o?e.width/o:e.width,f=i?e.height/i:e.height;return{width:d,height:f,top:u,right:l+d,bottom:u+f,left:l}}const Wn={ignoreTransform:!1};function De(e,t){t===void 0&&(t=Wn);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:d}=B(e).getComputedStyle(e);u&&(n=Un(n,u,d))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function Lt(e){return De(e,{ignoreTransform:!0})}function Hn(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Kn(e,t){return t===void 0&&(t=B(e).getComputedStyle(e)),t.position==="fixed"}function Vn(e,t){t===void 0&&(t=B(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function wt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(pt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!je(o)||Ut(o)||n.includes(o))return n;const i=B(e).getComputedStyle(o);return o!==e&&Vn(o,i)&&n.push(o),Kn(o,i)?n:r(o.parentNode)}return e?r(e):n}function Vt(e){const[t]=wt(e,1);return t??null}function at(e){return!et||!e?null:ye(e)?e:vt(e)?pt(e)||e===xe(e).scrollingElement?window:je(e)?e:null:null}function qt(e){return ye(e)?e.scrollX:e.scrollLeft}function Gt(e){return ye(e)?e.scrollY:e.scrollTop}function ft(e){return{x:qt(e),y:Gt(e)}}var N;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(N||(N={}));function Jt(e){return!et||!e?!1:e===document.scrollingElement}function _t(e){const t={x:0,y:0},n=Jt(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const qn={x:.2,y:.2};function Gn(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=qn);const{isTop:u,isBottom:d,isLeft:f,isRight:v}=_t(e),h={x:0,y:0},M={x:0,y:0},g={height:t.height*o.y,width:t.width*o.x};return!u&&i<=t.top+g.height?(h.y=N.Backward,M.y=r*Math.abs((t.top+g.height-i)/g.height)):!d&&l>=t.bottom-g.height&&(h.y=N.Forward,M.y=r*Math.abs((t.bottom-g.height-l)/g.height)),!v&&a>=t.right-g.width?(h.x=N.Forward,M.x=r*Math.abs((t.right-g.width-a)/g.width)):!f&&s<=t.left+g.width&&(h.x=N.Backward,M.x=r*Math.abs((t.left+g.width-s)/g.width)),{direction:h,speed:M}}function Jn(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Qt(e){return e.reduce((t,n)=>we(t,ft(n)),V)}function _n(e){return e.reduce((t,n)=>t+qt(n),0)}function Qn(e){return e.reduce((t,n)=>t+Gt(n),0)}function Zn(e,t){if(t===void 0&&(t=De),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);Vt(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const er=[["x",["left","right"],_n],["y",["top","bottom"],Qn]];class yt{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=wt(n),o=Qt(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of er)for(const l of s)Object.defineProperty(this,l,{get:()=>{const u=a(r),d=o[i]-u;return this.rect[l]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ne{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function tr(e){const{EventTarget:t}=B(e);return e instanceof t?e:xe(e)}function ct(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var W;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(W||(W={}));function kt(e){e.preventDefault()}function nr(e){e.stopPropagation()}var D;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(D||(D={}));const Zt={start:[D.Space,D.Enter],cancel:[D.Esc],end:[D.Space,D.Enter,D.Tab]},rr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case D.Right:return{...n,x:n.x+25};case D.Left:return{...n,x:n.x-25};case D.Down:return{...n,y:n.y+25};case D.Up:return{...n,y:n.y-25}}};class en{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Ne(xe(n)),this.windowListeners=new Ne(B(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(W.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&Zn(r),n(V)}handleKeyDown(t){if(mt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=Zt,coordinateGetter:s=rr,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:V;this.referenceCoordinates||(this.referenceCoordinates=d);const f=s(t,{active:n,context:r.current,currentCoordinates:d});if(f){const v=_e(f,d),h={x:0,y:0},{scrollableAncestors:M}=r.current;for(const g of M){const p=t.code,{isTop:w,isRight:x,isLeft:b,isBottom:S,maxScroll:C,minScroll:R}=_t(g),y=Jn(g),m={x:Math.min(p===D.Right?y.right-y.width/2:y.right,Math.max(p===D.Right?y.left:y.left+y.width/2,f.x)),y:Math.min(p===D.Down?y.bottom-y.height/2:y.bottom,Math.max(p===D.Down?y.top:y.top+y.height/2,f.y))},A=p===D.Right&&!x||p===D.Left&&!b,O=p===D.Down&&!S||p===D.Up&&!w;if(A&&m.x!==f.x){const I=g.scrollLeft+v.x,H=p===D.Right&&I<=C.x||p===D.Left&&I>=R.x;if(H&&!v.y){g.scrollTo({left:I,behavior:a});return}H?h.x=g.scrollLeft-I:h.x=p===D.Right?g.scrollLeft-C.x:g.scrollLeft-R.x,h.x&&g.scrollBy({left:-h.x,behavior:a});break}else if(O&&m.y!==f.y){const I=g.scrollTop+v.y,H=p===D.Down&&I<=C.y||p===D.Up&&I>=R.y;if(H&&!v.x){g.scrollTo({top:I,behavior:a});return}H?h.y=g.scrollTop-I:h.y=p===D.Down?g.scrollTop-C.y:g.scrollTop-R.y,h.y&&g.scrollBy({top:-h.y,behavior:a});break}}this.handleMove(t,we(_e(f,this.referenceCoordinates),h))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}en.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Zt,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function zt(e){return!!(e&&"distance"in e)}function Pt(e){return!!(e&&"delay"in e)}class xt{constructor(t,n,r){var o;r===void 0&&(r=tr(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=xe(s),this.documentListeners=new Ne(this.document),this.listeners=new Ne(r),this.windowListeners=new Ne(B(s)),this.initialCoordinates=(o=dt(i))!=null?o:V,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.DragStart,kt),this.windowListeners.add(W.VisibilityChange,this.handleCancel),this.windowListeners.add(W.ContextMenu,kt),this.documentListeners.add(W.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Pt(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(zt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(W.Click,nr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(W.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=dt(t))!=null?n:V,u=_e(o,l);if(!r&&a){if(zt(a)){if(a.tolerance!=null&&ct(u,a.tolerance))return this.handleCancel();if(ct(u,a.distance))return this.handleStart()}if(Pt(a)&&ct(u,a.tolerance))return this.handleCancel();this.handlePending(a,u);return}t.cancelable&&t.preventDefault(),s(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===D.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const or={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class tn extends xt{constructor(t){const{event:n}=t,r=xe(n.target);super(t,or,r)}}tn.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const ir={move:{name:"mousemove"},end:{name:"mouseup"}};var ht;(function(e){e[e.RightClick=2]="RightClick"})(ht||(ht={}));class sr extends xt{constructor(t){super(t,ir,xe(t.event.target))}}sr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ht.RightClick?!1:(r?.({event:n}),!0)}}];const lt={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ar extends xt{constructor(t){super(t,lt)}static setup(){return window.addEventListener(lt.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(lt.move.name,t)};function t(){}}}ar.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Le;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Le||(Le={}));var Ze;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ze||(Ze={}));function cr(e){let{acceleration:t,activator:n=Le.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Ze.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:v}=e;const h=ur({delta:f,disabled:!i}),[M,g]=yn(),p=c.useRef({x:0,y:0}),w=c.useRef({x:0,y:0}),x=c.useMemo(()=>{switch(n){case Le.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Le.DraggableRect:return o}},[n,o,l]),b=c.useRef(null),S=c.useCallback(()=>{const R=b.current;if(!R)return;const y=p.current.x*w.current.x,m=p.current.y*w.current.y;R.scrollBy(y,m)},[]),C=c.useMemo(()=>a===Ze.TreeOrder?[...u].reverse():u,[a,u]);c.useEffect(()=>{if(!i||!u.length||!x){g();return}for(const R of C){if(r?.(R)===!1)continue;const y=u.indexOf(R),m=d[y];if(!m)continue;const{direction:A,speed:O}=Gn(R,m,x,t,v);for(const I of["x","y"])h[I][A[I]]||(O[I]=0,A[I]=0);if(O.x>0||O.y>0){g(),b.current=R,M(S,s),p.current=O,w.current=A;return}}p.current={x:0,y:0},w.current={x:0,y:0},g()},[t,S,r,g,i,s,JSON.stringify(x),JSON.stringify(h),M,u,C,d,JSON.stringify(v)])}const lr={x:{[N.Backward]:!1,[N.Forward]:!1},y:{[N.Backward]:!1,[N.Forward]:!1}};function ur(e){let{delta:t,disabled:n}=e;const r=ut(t);return $e(o=>{if(n||!r||!o)return lr;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[N.Backward]:o.x[N.Backward]||i.x===-1,[N.Forward]:o.x[N.Forward]||i.x===1},y:{[N.Backward]:o.y[N.Backward]||i.y===-1,[N.Forward]:o.y[N.Forward]||i.y===1}}},[n,t,r])}function dr(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return $e(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function fr(e,t){return c.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var Be;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Be||(Be={}));var gt;(function(e){e.Optimized="optimized"})(gt||(gt={}));const Bt=new Map;function hr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=c.useState(null),{frequency:a,measure:l,strategy:u}=o,d=c.useRef(e),f=p(),v=ze(f),h=c.useCallback(function(w){w===void 0&&(w=[]),!v.current&&s(x=>x===null?w:x.concat(w.filter(b=>!x.includes(b))))},[v]),M=c.useRef(null),g=$e(w=>{if(f&&!n)return Bt;if(!w||w===Bt||d.current!==e||i!=null){const x=new Map;for(let b of e){if(!b)continue;if(i&&i.length>0&&!i.includes(b.id)&&b.rect.current){x.set(b.id,b.rect.current);continue}const S=b.node.current,C=S?new yt(l(S),S):null;b.rect.current=C,C&&x.set(b.id,C)}return x}return w},[e,i,n,f,l]);return c.useEffect(()=>{d.current=e},[e]),c.useEffect(()=>{f||h()},[n,f]),c.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),c.useEffect(()=>{f||typeof a!="number"||M.current!==null||(M.current=setTimeout(()=>{h(),M.current=null},a))},[a,f,h,...r]),{droppableRects:g,measureDroppableContainers:h,measuringScheduled:i!=null};function p(){switch(u){case Be.Always:return!1;case Be.BeforeDragging:return n;default:return!n}}}function nn(e,t){return $e(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function gr(e,t){return nn(e,t)}function vr(e){let{callback:t,disabled:n}=e;const r=bt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function tt(e){let{callback:t,disabled:n}=e;const r=bt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function pr(e){return new yt(De(e),e)}function jt(e,t,n){t===void 0&&(t=pr);const[r,o]=c.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=l??n)!=null?u:null}const d=t(e);return JSON.stringify(l)===JSON.stringify(d)?l:d})}const s=vr({callback(l){if(e)for(const u of l){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(e)){i();break}}}}),a=tt({callback:i});return Q(()=>{i(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function br(e){const t=nn(e);return Kt(e,t)}const $t=[];function mr(e){const t=c.useRef(e),n=$e(r=>e?r&&r!==$t&&e&&t.current&&e.parentNode===t.current.parentNode?r:wt(e):$t,[e]);return c.useEffect(()=>{t.current=e},[e]),n}function wr(e){const[t,n]=c.useState(null),r=c.useRef(e),o=c.useCallback(i=>{const s=at(i.target);s&&n(a=>a?(a.set(s,ft(s)),new Map(a)):null)},[]);return c.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const u=at(l);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,ft(u)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const u=at(l);u?.removeEventListener("scroll",o)})}},[o,e]),c.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>we(i,s),V):Qt(e):V,[e,t])}function Ft(e,t){t===void 0&&(t=[]);const n=c.useRef(null);return c.useEffect(()=>{n.current=null},t),c.useEffect(()=>{const r=e!==V;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?_e(e,n.current):V}function yr(e){c.useEffect(()=>{if(!et)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function xr(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function rn(e){return c.useMemo(()=>e?Hn(e):null,[e])}const Xt=[];function Dr(e,t){t===void 0&&(t=De);const[n]=e,r=rn(n?B(n):null),[o,i]=c.useState(Xt);function s(){i(()=>e.length?e.map(l=>Jt(l)?r:new yt(t(l),l)):Xt)}const a=tt({callback:s});return Q(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),o}function Sr(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return je(t)?t:e}function Cr(e){let{measure:t}=e;const[n,r]=c.useState(null),o=c.useCallback(u=>{for(const{target:d}of u)if(je(d)){r(f=>{const v=t(d);return f?{...f,width:v.width,height:v.height}:v});break}},[t]),i=tt({callback:o}),s=c.useCallback(u=>{const d=Sr(u);i?.disconnect(),d&&i?.observe(d),r(d?t(d):null)},[t,i]),[a,l]=Je(s);return c.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Rr=[{sensor:tn,options:{}},{sensor:en,options:{}}],Er={current:{}},Ge={draggable:{measure:Lt},droppable:{measure:Lt,strategy:Be.WhileDragging,frequency:gt.Optimized},dragOverlay:{measure:De}};class ke extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Mr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ke,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Qe},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ge,measureDroppableContainers:Qe,windowRect:null,measuringScheduled:!1},Ir={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Qe,draggableNodes:new Map,over:null,measureDroppableContainers:Qe},nt=c.createContext(Ir),on=c.createContext(Mr);function Ar(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ke}}}function Tr(e,t){switch(t.type){case T.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case T.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case T.DragEnd:case T.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case T.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new ke(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case T.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new ke(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case T.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new ke(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Or(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=c.useContext(nt),i=ut(r),s=ut(n?.id);return c.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!mt(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:u}=a;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[l.current,u.current]){if(!d)continue;const f=Sn(d);if(f){f.focus();break}}})}},[r,t,o,s,i]),null}function Nr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Lr(e){return c.useMemo(()=>({draggable:{...Ge.draggable,...e?.draggable},droppable:{...Ge.droppable,...e?.droppable},dragOverlay:{...Ge.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function kr(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=c.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Q(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=Kt(d,r);if(s||(f.x=0),a||(f.y=0),i.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const v=Vt(u);v&&v.scrollBy({top:f.y,left:f.x})}},[t,s,a,r,n])}const sn=c.createContext({...V,scaleX:1,scaleY:1});var de;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(de||(de={}));const io=c.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:u,sensors:d=Rr,collisionDetection:f=jn,measuring:v,modifiers:h,...M}=t;const g=c.useReducer(Tr,void 0,Ar),[p,w]=g,[x,b]=An(),[S,C]=c.useState(de.Uninitialized),R=S===de.Initialized,{draggable:{active:y,nodes:m,translate:A},droppable:{containers:O}}=p,I=y!=null?m.get(y):null,H=c.useRef({initial:null,translated:null}),K=c.useMemo(()=>{var k;return y!=null?{id:y,data:(k=I?.data)!=null?k:Er,rect:H}:null},[y,I]),q=c.useRef(null),[Se,Xe]=c.useState(null),[j,Ye]=c.useState(null),Z=ze(M,Object.values(M)),Ce=Fe("DndDescribedBy",s),Ue=c.useMemo(()=>O.getEnabled(),[O]),z=Lr(v),{droppableRects:ee,measureDroppableContainers:fe,measuringScheduled:Re}=hr(Ue,{dragging:R,dependencies:[A.x,A.y],config:z.droppable}),Y=dr(m,y),We=c.useMemo(()=>j?dt(j):null,[j]),ie=mn(),te=gr(Y,z.draggable.measure);kr({activeNode:y!=null?m.get(y):null,config:ie.layoutShiftCompensation,initialRect:te,measure:z.draggable.measure});const E=jt(Y,z.draggable.measure,te),Ee=jt(Y?Y.parentElement:null),G=c.useRef({activatorEvent:null,active:null,activeNode:Y,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:m,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),he=O.getNodeFor((n=G.current.over)==null?void 0:n.id),ne=Cr({measure:z.dragOverlay.measure}),ge=(r=ne.nodeRef.current)!=null?r:Y,ve=R?(o=ne.rect)!=null?o:E:null,St=!!(ne.nodeRef.current&&ne.rect),Ct=br(St?null:E),rt=rn(ge?B(ge):null),se=mr(R?he??Y:null),He=Dr(se),Ke=Nr(h,{transform:{x:A.x-Ct.x,y:A.y-Ct.y,scaleX:1,scaleY:1},activatorEvent:j,active:K,activeNodeRect:E,containerNodeRect:Ee,draggingNodeRect:ve,over:G.current.over,overlayNodeRect:ne.rect,scrollableAncestors:se,scrollableAncestorRects:He,windowRect:rt}),Rt=We?we(We,A):null,Et=wr(se),dn=Ft(Et),fn=Ft(Et,[E]),pe=we(Ke,dn),be=ve?Xn(ve,Ke):null,Me=K&&be?f({active:K,collisionRect:be,droppableRects:ee,droppableContainers:Ue,pointerCoordinates:Rt}):null,Mt=Pn(Me,"id"),[ae,It]=c.useState(null),hn=St?Ke:we(Ke,fn),gn=$n(hn,(i=ae?.rect)!=null?i:null,E),ot=c.useRef(null),At=c.useCallback((k,$)=>{let{sensor:F,options:ce}=$;if(q.current==null)return;const U=m.get(q.current);if(!U)return;const X=k.nativeEvent,J=new F({active:q.current,activeNode:U,event:X,options:ce,context:G,onAbort(L){if(!m.get(L))return;const{onDragAbort:_}=Z.current,re={id:L};_?.(re),x({type:"onDragAbort",event:re})},onPending(L,le,_,re){if(!m.get(L))return;const{onDragPending:Ae}=Z.current,ue={id:L,constraint:le,initialCoordinates:_,offset:re};Ae?.(ue),x({type:"onDragPending",event:ue})},onStart(L){const le=q.current;if(le==null)return;const _=m.get(le);if(!_)return;const{onDragStart:re}=Z.current,Ie={activatorEvent:X,active:{id:le,data:_.data,rect:H}};Oe.unstable_batchedUpdates(()=>{re?.(Ie),C(de.Initializing),w({type:T.DragStart,initialCoordinates:L,active:le}),x({type:"onDragStart",event:Ie}),Xe(ot.current),Ye(X)})},onMove(L){w({type:T.DragMove,coordinates:L})},onEnd:me(T.DragEnd),onCancel:me(T.DragCancel)});ot.current=J;function me(L){return async function(){const{active:_,collisions:re,over:Ie,scrollAdjustedTranslate:Ae}=G.current;let ue=null;if(_&&Ae){const{cancelDrop:Te}=Z.current;ue={activatorEvent:X,active:_,collisions:re,delta:Ae,over:Ie},L===T.DragEnd&&typeof Te=="function"&&await Promise.resolve(Te(ue))&&(L=T.DragCancel)}q.current=null,Oe.unstable_batchedUpdates(()=>{w({type:L}),C(de.Uninitialized),It(null),Xe(null),Ye(null),ot.current=null;const Te=L===T.DragEnd?"onDragEnd":"onDragCancel";if(ue){const it=Z.current[Te];it?.(ue),x({type:Te,event:ue})}})}}},[m]),vn=c.useCallback((k,$)=>(F,ce)=>{const U=F.nativeEvent,X=m.get(ce);if(q.current!==null||!X||U.dndKit||U.defaultPrevented)return;const J={active:X};k(F,$.options,J)===!0&&(U.dndKit={capturedBy:$.sensor},q.current=ce,At(F,$))},[m,At]),Tt=fr(d,vn);yr(d),Q(()=>{E&&S===de.Initializing&&C(de.Initialized)},[E,S]),c.useEffect(()=>{const{onDragMove:k}=Z.current,{active:$,activatorEvent:F,collisions:ce,over:U}=G.current;if(!$||!F)return;const X={active:$,activatorEvent:F,collisions:ce,delta:{x:pe.x,y:pe.y},over:U};Oe.unstable_batchedUpdates(()=>{k?.(X),x({type:"onDragMove",event:X})})},[pe.x,pe.y]),c.useEffect(()=>{const{active:k,activatorEvent:$,collisions:F,droppableContainers:ce,scrollAdjustedTranslate:U}=G.current;if(!k||q.current==null||!$||!U)return;const{onDragOver:X}=Z.current,J=ce.get(Mt),me=J&&J.rect.current?{id:J.id,rect:J.rect.current,data:J.data,disabled:J.disabled}:null,L={active:k,activatorEvent:$,collisions:F,delta:{x:U.x,y:U.y},over:me};Oe.unstable_batchedUpdates(()=>{It(me),X?.(L),x({type:"onDragOver",event:L})})},[Mt]),Q(()=>{G.current={activatorEvent:j,active:K,activeNode:Y,collisionRect:be,collisions:Me,droppableRects:ee,draggableNodes:m,draggingNode:ge,draggingNodeRect:ve,droppableContainers:O,over:ae,scrollableAncestors:se,scrollAdjustedTranslate:pe},H.current={initial:ve,translated:be}},[K,Y,Me,be,m,ge,ve,ee,O,ae,se,pe]),cr({...ie,delta:A,draggingRect:be,pointerCoordinates:Rt,scrollableAncestors:se,scrollableAncestorRects:He});const pn=c.useMemo(()=>({active:K,activeNode:Y,activeNodeRect:E,activatorEvent:j,collisions:Me,containerNodeRect:Ee,dragOverlay:ne,draggableNodes:m,droppableContainers:O,droppableRects:ee,over:ae,measureDroppableContainers:fe,scrollableAncestors:se,scrollableAncestorRects:He,measuringConfiguration:z,measuringScheduled:Re,windowRect:rt}),[K,Y,E,j,Me,Ee,ne,m,O,ee,ae,fe,se,He,z,Re,rt]),bn=c.useMemo(()=>({activatorEvent:j,activators:Tt,active:K,activeNodeRect:E,ariaDescribedById:{draggable:Ce},dispatch:w,draggableNodes:m,over:ae,measureDroppableContainers:fe}),[j,Tt,K,E,w,Ce,m,ae,fe]);return P.createElement(Ht.Provider,{value:b},P.createElement(nt.Provider,{value:bn},P.createElement(on.Provider,{value:pn},P.createElement(sn.Provider,{value:gn},u)),P.createElement(Or,{disabled:a?.restoreFocus===!1})),P.createElement(Nn,{...a,hiddenTextDescribedById:Ce}));function mn(){const k=Se?.autoScrollEnabled===!1,$=typeof l=="object"?l.enabled===!1:l===!1,F=R&&!k&&!$;return typeof l=="object"?{...l,enabled:F}:{enabled:F}}}),zr=c.createContext(null),Yt="button",Pr="Draggable";function Br(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=Fe(Pr),{activators:s,activatorEvent:a,active:l,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:v}=c.useContext(nt),{role:h=Yt,roleDescription:M="draggable",tabIndex:g=0}=o??{},p=l?.id===t,w=c.useContext(p?sn:zr),[x,b]=Je(),[S,C]=Je(),R=xr(s,t),y=ze(n);Q(()=>(f.set(t,{id:t,key:i,node:x,activatorNode:S,data:y}),()=>{const A=f.get(t);A&&A.key===i&&f.delete(t)}),[f,t]);const m=c.useMemo(()=>({role:h,tabIndex:g,"aria-disabled":r,"aria-pressed":p&&h===Yt?!0:void 0,"aria-roledescription":M,"aria-describedby":d.draggable}),[r,h,g,p,M,d.draggable]);return{active:l,activatorEvent:a,activeNodeRect:u,attributes:m,isDragging:p,listeners:r?void 0:R,node:x,over:v,setNodeRef:b,setActivatorNodeRef:C,transform:w}}function jr(){return c.useContext(on)}const $r="Droppable",Fr={timeout:25};function Xr(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=Fe($r),{active:s,dispatch:a,over:l,measureDroppableContainers:u}=c.useContext(nt),d=c.useRef({disabled:n}),f=c.useRef(!1),v=c.useRef(null),h=c.useRef(null),{disabled:M,updateMeasurementsFor:g,timeout:p}={...Fr,...o},w=ze(g??r),x=c.useCallback(()=>{if(!f.current){f.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(w.current)?w.current:[w.current]),h.current=null},p)},[p]),b=tt({callback:x,disabled:M||!s}),S=c.useCallback((m,A)=>{b&&(A&&(b.unobserve(A),f.current=!1),m&&b.observe(m))},[b]),[C,R]=Je(S),y=ze(t);return c.useEffect(()=>{!b||!C.current||(b.disconnect(),f.current=!1,b.observe(C.current))},[C,b]),c.useEffect(()=>(a({type:T.RegisterDroppable,element:{id:r,key:i,disabled:n,node:C,rect:v,data:y}}),()=>a({type:T.UnregisterDroppable,key:i,id:r})),[r]),c.useEffect(()=>{n!==d.current.disabled&&(a({type:T.SetDroppableDisabled,id:r,key:i,disabled:n}),d.current.disabled=n)},[r,i,n,a]),{active:s,rect:v,isOver:l?.id===r,node:C,over:l,setNodeRef:R}}function Dt(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Yr(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Ve(e){return e!==null&&e>=0}function Ur(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Wr(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const an=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Dt(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},qe={scaleX:1,scaleY:1},so=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=e;const a=(t=i[n])!=null?t:r;if(!a)return null;if(o===n){const u=i[s];return u?{x:0,y:n<s?u.top+u.height-(a.top+a.height):u.top-a.top,...qe}:null}const l=Hr(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...qe}:o<n&&o>=s?{x:0,y:a.height+l,...qe}:{x:0,y:0,...qe}};function Hr(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const cn="Sortable",ln=P.createContext({activeIndex:-1,containerId:cn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:an,disabled:{draggable:!1,droppable:!1}});function ao(e){let{children:t,id:n,items:r,strategy:o=an,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:u,measureDroppableContainers:d}=jr(),f=Fe(cn,n),v=a.rect!==null,h=c.useMemo(()=>r.map(R=>typeof R=="object"&&"id"in R?R.id:R),[r]),M=s!=null,g=s?h.indexOf(s.id):-1,p=u?h.indexOf(u.id):-1,w=c.useRef(h),x=!Ur(h,w.current),b=p!==-1&&g===-1||x,S=Wr(i);Q(()=>{x&&M&&d(h)},[x,h,M,d]),c.useEffect(()=>{w.current=h},[h]);const C=c.useMemo(()=>({activeIndex:g,containerId:f,disabled:S,disableTransforms:b,items:h,overIndex:p,useDragOverlay:v,sortedRects:Yr(h,l),strategy:o}),[g,f,S.draggable,S.droppable,b,h,p,l,v,o]);return P.createElement(ln.Provider,{value:C},t)}const Kr=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Dt(n,r,o).indexOf(t)},Vr=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:u}=e;return!u||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},qr={duration:200,easing:"ease"},un="transform",Gr=Pe.Transition.toString({property:un,duration:0,easing:"linear"}),Jr={roleDescription:"sortable"};function _r(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=c.useState(null),a=c.useRef(n);return Q(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const u=De(r.current,{ignoreTransform:!0}),d={x:l.left-u.left,y:l.top-u.top,scaleX:l.width/u.width,scaleY:l.height/u.height};(d.x||d.y)&&s(d)}}n!==a.current&&(a.current=n)},[t,n,r,o]),c.useEffect(()=>{i&&s(null)},[i]),i}function Qr(e){let{animateLayoutChanges:t=Vr,attributes:n,disabled:r,data:o,getNewIndex:i=Kr,id:s,strategy:a,resizeObserverConfig:l,transition:u=qr}=e;const{items:d,containerId:f,activeIndex:v,disabled:h,disableTransforms:M,sortedRects:g,overIndex:p,useDragOverlay:w,strategy:x}=c.useContext(ln),b=Zr(r,h),S=d.indexOf(s),C=c.useMemo(()=>({sortable:{containerId:f,index:S,items:d},...o}),[f,o,S,d]),R=c.useMemo(()=>d.slice(d.indexOf(s)),[d,s]),{rect:y,node:m,isOver:A,setNodeRef:O}=Xr({id:s,data:C,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...l}}),{active:I,activatorEvent:H,activeNodeRect:K,attributes:q,setNodeRef:Se,listeners:Xe,isDragging:j,over:Ye,setActivatorNodeRef:Z,transform:Ce}=Br({id:s,data:C,attributes:{...Jr,...n},disabled:b.draggable}),Ue=wn(O,Se),z=!!I,ee=z&&!M&&Ve(v)&&Ve(p),fe=!w&&j,Re=fe&&ee?Ce:null,We=ee?Re??(a??x)({rects:g,activeNodeRect:K,activeIndex:v,overIndex:p,index:S}):null,ie=Ve(v)&&Ve(p)?i({id:s,items:d,activeIndex:v,overIndex:p}):S,te=I?.id,E=c.useRef({activeId:te,items:d,newIndex:ie,containerId:f}),Ee=d!==E.current.items,G=t({active:I,containerId:f,isDragging:j,isSorting:z,id:s,index:S,items:d,newIndex:E.current.newIndex,previousItems:E.current.items,previousContainerId:E.current.containerId,transition:u,wasDragging:E.current.activeId!=null}),he=_r({disabled:!G,index:S,node:m,rect:y});return c.useEffect(()=>{z&&E.current.newIndex!==ie&&(E.current.newIndex=ie),f!==E.current.containerId&&(E.current.containerId=f),d!==E.current.items&&(E.current.items=d)},[z,ie,f,d]),c.useEffect(()=>{if(te===E.current.activeId)return;if(te!=null&&E.current.activeId==null){E.current.activeId=te;return}const ge=setTimeout(()=>{E.current.activeId=te},50);return()=>clearTimeout(ge)},[te]),{active:I,activeIndex:v,attributes:q,data:C,rect:y,index:S,newIndex:ie,items:d,isOver:A,isSorting:z,isDragging:j,listeners:Xe,node:m,overIndex:p,over:Ye,setNodeRef:Ue,setActivatorNodeRef:Z,setDroppableNodeRef:O,setDraggableNodeRef:Se,transform:he??We,transition:ne()};function ne(){if(he||Ee&&E.current.newIndex===S)return Gr;if(!(fe&&!mt(H)||!u)&&(z||G))return Pe.Transition.toString({...u,property:un})}}function Zr(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}D.Down,D.Right,D.Up,D.Left;const co=e=>{let{transform:t}=e;return{...t,x:0}};function lo({listeners:e,attributes:t}){return oe.jsx("button",{type:"button",className:"admin-drag-handle",...t,...e,title:"Přetáhnout","aria-label":"Přetáhnout pro změnu pořadí",children:oe.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[oe.jsx("circle",{cx:"9",cy:"5",r:"1.5"}),oe.jsx("circle",{cx:"15",cy:"5",r:"1.5"}),oe.jsx("circle",{cx:"9",cy:"12",r:"1.5"}),oe.jsx("circle",{cx:"15",cy:"12",r:"1.5"}),oe.jsx("circle",{cx:"9",cy:"19",r:"1.5"}),oe.jsx("circle",{cx:"15",cy:"19",r:"1.5"})]})})}function uo({id:e,children:t,disabled:n}){const{attributes:r,listeners:o,setNodeRef:i,transform:s,transition:a,isDragging:l}=Qr({id:e,disabled:n}),u={transform:Pe.Transform.toString(s),transition:a,opacity:l?.5:1,position:"relative",zIndex:l?10:void 0,background:l?"var(--bg-secondary)":void 0};return oe.jsx("tr",{ref:i,style:u,children:typeof t=="function"?t({attributes:r,listeners:o}):t})}function fo(e,t="_key"){return{handleDragEnd:c.useCallback(r=>{const{active:o,over:i}=r;!i||o.id===i.id||e(s=>{const a=s.findIndex(u=>String(u[t])===String(o.id)),l=s.findIndex(u=>String(u[t])===String(i.id));return a===-1||l===-1?s:Dt(s,a,l)})},[e,t])}}export{io as D,en as K,tn as P,ao as S,ar as T,no as a,fo as b,oo as c,uo as d,lo as e,co as r,ro as u,so as v};