@mdspl/mds-shared-ui 0.1.5 → 0.1.6

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.
package/dist/index.cjs CHANGED
@@ -7,4 +7,4 @@ React keys must be passed directly to JSX without using spread:
7
7
  To pick up a draggable item, press the space bar.
8
8
  While dragging, use the arrow keys to move the item.
9
9
  Press space again to drop the item in its new position, or press escape to cancel.
10
- `},Vr={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 Br(e){let{announcements:t=Vr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=$r}=e;const{announce:s,announcement:i}=Lr(),a=Ke("DndLiveRegion"),[f,d]=c.useState(!1);if(c.useEffect(()=>{d(!0)},[]),Pr(c.useMemo(()=>({onDragStart(v){let{active:b}=v;s(t.onDragStart({active:b}))},onDragMove(v){let{active:b,over:u}=v;t.onDragMove&&s(t.onDragMove({active:b,over:u}))},onDragOver(v){let{active:b,over:u}=v;s(t.onDragOver({active:b,over:u}))},onDragEnd(v){let{active:b,over:u}=v;s(t.onDragEnd({active:b,over:u}))},onDragCancel(v){let{active:b,over:u}=v;s(t.onDragCancel({active:b,over:u}))}}),[s,t])),!f)return null;const h=c.createElement(c.Fragment,null,c.createElement(Mr,{id:r,value:o.draggable}),c.createElement(Nr,{id:a,announcement:i}));return n?Be.createPortal(h,n):h}var $;(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"})($||($={}));function dt(){}function Fr(e,t){return c.useMemo(()=>({sensor:e,options:{}}),[e,t])}function Hr(){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 oe=Object.freeze({x:0,y:0});function Wr(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Ur(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Yr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Gr(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function vn(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 An=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=vn(t,t.left,t.top),s=[];for(const i of r){const{id:a}=i,f=n.get(a);if(f){const d=Wr(vn(f),o);s.push({id:a,data:{droppableContainer:i,value:d}})}}return s.sort(Ur)};function qr(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),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,a=s-n;if(r<o&&n<s){const f=t.width*t.height,d=e.width*e.height,h=i*a,v=h/(f+d-h);return Number(v.toFixed(4))}return 0}const Xr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,a=n.get(i);if(a){const f=qr(a,t);f>0&&o.push({id:i,data:{droppableContainer:s,value:f}})}}return o.sort(Yr)};function Jr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Mn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:oe}function Kr(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,a)=>({...i,top:i.top+e*a.y,bottom:i.bottom+e*a.y,left:i.left+e*a.x,right:i.right+e*a.x}),{...n})}}const Zr=Kr(1);function Qr(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 eo(e,t,n){const r=Qr(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,f=e.left-i-(1-o)*parseFloat(n),d=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),h=o?e.width/o:e.width,v=s?e.height/s:e.height;return{width:h,height:v,top:d,right:f+h,bottom:d+v,left:f}}const to={ignoreTransform:!1};function Ae(e,t){t===void 0&&(t=to);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:d,transformOrigin:h}=q(e).getComputedStyle(e);d&&(n=eo(n,d,h))}const{top:r,left:o,width:s,height:i,bottom:a,right:f}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:f}}function gn(e){return Ae(e,{ignoreTransform:!0})}function no(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function ro(e,t){return t===void 0&&(t=q(e).getComputedStyle(e)),t.position==="fixed"}function oo(e,t){t===void 0&&(t=q(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const s=t[o];return typeof s=="string"?n.test(s):!1})}function Ft(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if($t(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Xe(o)||jn(o)||n.includes(o))return n;const s=q(e).getComputedStyle(o);return o!==e&&oo(o,s)&&n.push(o),ro(o,s)?n:r(o.parentNode)}return e?r(e):n}function Nn(e){const[t]=Ft(e,1);return t??null}function Tt(e){return!ht||!e?null:ke(e)?e:zt(e)?$t(e)||e===Ie(e).scrollingElement?window:Xe(e)?e:null:null}function Ln(e){return ke(e)?e.scrollX:e.scrollLeft}function Pn(e){return ke(e)?e.scrollY:e.scrollTop}function Nt(e){return{x:Ln(e),y:Pn(e)}}var V;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(V||(V={}));function zn(e){return!ht||!e?!1:e===document.scrollingElement}function $n(e){const t={x:0,y:0},n=zn(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,s=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:a,maxScroll:r,minScroll:t}}const so={x:.2,y:.2};function io(e,t,n,r,o){let{top:s,left:i,right:a,bottom:f}=n;r===void 0&&(r=10),o===void 0&&(o=so);const{isTop:d,isBottom:h,isLeft:v,isRight:b}=$n(e),u={x:0,y:0},x={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!d&&s<=t.top+m.height?(u.y=V.Backward,x.y=r*Math.abs((t.top+m.height-s)/m.height)):!h&&f>=t.bottom-m.height&&(u.y=V.Forward,x.y=r*Math.abs((t.bottom-m.height-f)/m.height)),!b&&a>=t.right-m.width?(u.x=V.Forward,x.x=r*Math.abs((t.right-m.width-a)/m.width)):!v&&i<=t.left+m.width&&(u.x=V.Backward,x.x=r*Math.abs((t.left+m.width-i)/m.width)),{direction:u,speed:x}}function ao(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}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 Vn(e){return e.reduce((t,n)=>Oe(t,Nt(n)),oe)}function co(e){return e.reduce((t,n)=>t+Ln(n),0)}function lo(e){return e.reduce((t,n)=>t+Pn(n),0)}function uo(e,t){if(t===void 0&&(t=Ae),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);Nn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const fo=[["x",["left","right"],co],["y",["top","bottom"],lo]];class Ht{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=Ft(n),o=Vn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,a]of fo)for(const f of i)Object.defineProperty(this,f,{get:()=>{const d=a(r),h=o[s]-d;return this.rect[f]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Fe{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 ho(e){const{EventTarget:t}=q(e);return e instanceof t?e:Ie(e)}function _t(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 re;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(re||(re={}));function pn(e){e.preventDefault()}function vo(e){e.stopPropagation()}var I;(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"})(I||(I={}));const Bn={start:[I.Space,I.Enter],cancel:[I.Esc],end:[I.Space,I.Enter,I.Tab]},go=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case I.Right:return{...n,x:n.x+25};case I.Left:return{...n,x:n.x-25};case I.Down:return{...n,y:n.y+25};case I.Up:return{...n,y:n.y-25}}};class Fn{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 Fe(Ie(n)),this.windowListeners=new Fe(q(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(re.Resize,this.handleCancel),this.windowListeners.add(re.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(re.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&uo(r),n(oe)}handleKeyDown(t){if(Bt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=Bn,coordinateGetter:i=go,scrollBehavior:a="smooth"}=o,{code:f}=t;if(s.end.includes(f)){this.handleEnd(t);return}if(s.cancel.includes(f)){this.handleCancel(t);return}const{collisionRect:d}=r.current,h=d?{x:d.left,y:d.top}:oe;this.referenceCoordinates||(this.referenceCoordinates=h);const v=i(t,{active:n,context:r.current,currentCoordinates:h});if(v){const b=ut(v,h),u={x:0,y:0},{scrollableAncestors:x}=r.current;for(const m of x){const y=t.code,{isTop:w,isRight:E,isLeft:D,isBottom:_,maxScroll:j,minScroll:C}=$n(m),R=ao(m),O={x:Math.min(y===I.Right?R.right-R.width/2:R.right,Math.max(y===I.Right?R.left:R.left+R.width/2,v.x)),y:Math.min(y===I.Down?R.bottom-R.height/2:R.bottom,Math.max(y===I.Down?R.top:R.top+R.height/2,v.y))},L=y===I.Right&&!E||y===I.Left&&!D,z=y===I.Down&&!_||y===I.Up&&!w;if(L&&O.x!==v.x){const N=m.scrollLeft+b.x,U=y===I.Right&&N<=j.x||y===I.Left&&N>=C.x;if(U&&!b.y){m.scrollTo({left:N,behavior:a});return}U?u.x=m.scrollLeft-N:u.x=y===I.Right?m.scrollLeft-j.x:m.scrollLeft-C.x,u.x&&m.scrollBy({left:-u.x,behavior:a});break}else if(z&&O.y!==v.y){const N=m.scrollTop+b.y,U=y===I.Down&&N<=j.y||y===I.Up&&N>=C.y;if(U&&!b.x){m.scrollTo({top:N,behavior:a});return}U?u.y=m.scrollTop-N:u.y=y===I.Down?m.scrollTop-j.y:m.scrollTop-C.y,u.y&&m.scrollBy({top:-u.y,behavior:a});break}}this.handleMove(t,Oe(ut(v,this.referenceCoordinates),u))}}}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()}}Fn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Bn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const a=s.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function bn(e){return!!(e&&"distance"in e)}function mn(e){return!!(e&&"delay"in e)}class Wt{constructor(t,n,r){var o;r===void 0&&(r=ho(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:s}=t,{target:i}=s;this.props=t,this.events=n,this.document=Ie(i),this.documentListeners=new Fe(this.document),this.listeners=new Fe(r),this.windowListeners=new Fe(q(i)),this.initialCoordinates=(o=Mt(s))!=null?o:oe,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(re.Resize,this.handleCancel),this.windowListeners.add(re.DragStart,pn),this.windowListeners.add(re.VisibilityChange,this.handleCancel),this.windowListeners.add(re.ContextMenu,pn),this.documentListeners.add(re.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(mn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(bn(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(re.Click,vo,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(re.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:a}}=s;if(!o)return;const f=(n=Mt(t))!=null?n:oe,d=ut(o,f);if(!r&&a){if(bn(a)){if(a.tolerance!=null&&_t(d,a.tolerance))return this.handleCancel();if(_t(d,a.distance))return this.handleStart()}if(mn(a)&&_t(d,a.tolerance))return this.handleCancel();this.handlePending(a,d);return}t.cancelable&&t.preventDefault(),i(f)}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===I.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const po={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ut extends Wt{constructor(t){const{event:n}=t,r=Ie(n.target);super(t,po,r)}}Ut.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 bo={move:{name:"mousemove"},end:{name:"mouseup"}};var Lt;(function(e){e[e.RightClick=2]="RightClick"})(Lt||(Lt={}));class mo extends Wt{constructor(t){super(t,bo,Ie(t.event.target))}}mo.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Lt.RightClick?!1:(r?.({event:n}),!0)}}];const Ot={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class xo extends Wt{constructor(t){super(t,Ot)}static setup(){return window.addEventListener(Ot.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ot.move.name,t)};function t(){}}}xo.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 He;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(He||(He={}));var ft;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ft||(ft={}));function yo(e){let{acceleration:t,activator:n=He.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:a=ft.TreeOrder,pointerCoordinates:f,scrollableAncestors:d,scrollableAncestorRects:h,delta:v,threshold:b}=e;const u=So({delta:v,disabled:!s}),[x,m]=Or(),y=c.useRef({x:0,y:0}),w=c.useRef({x:0,y:0}),E=c.useMemo(()=>{switch(n){case He.Pointer:return f?{top:f.y,bottom:f.y,left:f.x,right:f.x}:null;case He.DraggableRect:return o}},[n,o,f]),D=c.useRef(null),_=c.useCallback(()=>{const C=D.current;if(!C)return;const R=y.current.x*w.current.x,O=y.current.y*w.current.y;C.scrollBy(R,O)},[]),j=c.useMemo(()=>a===ft.TreeOrder?[...d].reverse():d,[a,d]);c.useEffect(()=>{if(!s||!d.length||!E){m();return}for(const C of j){if(r?.(C)===!1)continue;const R=d.indexOf(C),O=h[R];if(!O)continue;const{direction:L,speed:z}=io(C,O,E,t,b);for(const N of["x","y"])u[N][L[N]]||(z[N]=0,L[N]=0);if(z.x>0||z.y>0){m(),D.current=C,x(_,i),y.current=z,w.current=L;return}}y.current={x:0,y:0},w.current={x:0,y:0},m()},[t,_,r,m,s,i,JSON.stringify(E),JSON.stringify(u),x,d,j,h,JSON.stringify(b)])}const wo={x:{[V.Backward]:!1,[V.Forward]:!1},y:{[V.Backward]:!1,[V.Forward]:!1}};function So(e){let{delta:t,disabled:n}=e;const r=At(t);return Je(o=>{if(n||!r||!o)return wo;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[V.Backward]:o.x[V.Backward]||s.x===-1,[V.Forward]:o.x[V.Forward]||s.x===1},y:{[V.Backward]:o.y[V.Backward]||s.y===-1,[V.Forward]:o.y[V.Forward]||s.y===1}}},[n,t,r])}function Co(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Je(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Ro(e,t){return c.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,s=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...s]},[]),[e,t])}var Ye;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ye||(Ye={}));var Pt;(function(e){e.Optimized="optimized"})(Pt||(Pt={}));const xn=new Map;function Eo(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=c.useState(null),{frequency:a,measure:f,strategy:d}=o,h=c.useRef(e),v=y(),b=Ue(v),u=c.useCallback(function(w){w===void 0&&(w=[]),!b.current&&i(E=>E===null?w:E.concat(w.filter(D=>!E.includes(D))))},[b]),x=c.useRef(null),m=Je(w=>{if(v&&!n)return xn;if(!w||w===xn||h.current!==e||s!=null){const E=new Map;for(let D of e){if(!D)continue;if(s&&s.length>0&&!s.includes(D.id)&&D.rect.current){E.set(D.id,D.rect.current);continue}const _=D.node.current,j=_?new Ht(f(_),_):null;D.rect.current=j,j&&E.set(D.id,j)}return E}return w},[e,s,n,v,f]);return c.useEffect(()=>{h.current=e},[e]),c.useEffect(()=>{v||u()},[n,v]),c.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),c.useEffect(()=>{v||typeof a!="number"||x.current!==null||(x.current=setTimeout(()=>{u(),x.current=null},a))},[a,v,u,...r]),{droppableRects:m,measureDroppableContainers:u,measuringScheduled:s!=null};function y(){switch(d){case Ye.Always:return!1;case Ye.BeforeDragging:return n;default:return!n}}}function Hn(e,t){return Je(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Do(e,t){return Hn(e,t)}function To(e){let{callback:t,disabled:n}=e;const r=Vt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function vt(e){let{callback:t,disabled:n}=e;const r=Vt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function _o(e){return new Ht(Ae(e),e)}function yn(e,t,n){t===void 0&&(t=_o);const[r,o]=c.useState(null);function s(){o(f=>{if(!e)return null;if(e.isConnected===!1){var d;return(d=f??n)!=null?d:null}const h=t(e);return JSON.stringify(f)===JSON.stringify(h)?f:h})}const i=To({callback(f){if(e)for(const d of f){const{type:h,target:v}=d;if(h==="childList"&&v instanceof HTMLElement&&v.contains(e)){s();break}}}}),a=vt({callback:s});return le(()=>{s(),e?(a?.observe(e),i?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),i?.disconnect())},[e]),r}function Oo(e){const t=Hn(e);return Mn(e,t)}const wn=[];function jo(e){const t=c.useRef(e),n=Je(r=>e?r&&r!==wn&&e&&t.current&&e.parentNode===t.current.parentNode?r:Ft(e):wn,[e]);return c.useEffect(()=>{t.current=e},[e]),n}function ko(e){const[t,n]=c.useState(null),r=c.useRef(e),o=c.useCallback(s=>{const i=Tt(s.target);i&&n(a=>a?(a.set(i,Nt(i)),new Map(a)):null)},[]);return c.useEffect(()=>{const s=r.current;if(e!==s){i(s);const a=e.map(f=>{const d=Tt(f);return d?(d.addEventListener("scroll",o,{passive:!0}),[d,Nt(d)]):null}).filter(f=>f!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(s)};function i(a){a.forEach(f=>{const d=Tt(f);d?.removeEventListener("scroll",o)})}},[o,e]),c.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>Oe(s,i),oe):Vn(e):oe,[e,t])}function Sn(e,t){t===void 0&&(t=[]);const n=c.useRef(null);return c.useEffect(()=>{n.current=null},t),c.useEffect(()=>{const r=e!==oe;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ut(e,n.current):oe}function Io(e){c.useEffect(()=>{if(!ht)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 Ao(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function Wn(e){return c.useMemo(()=>e?no(e):null,[e])}const Cn=[];function Mo(e,t){t===void 0&&(t=Ae);const[n]=e,r=Wn(n?q(n):null),[o,s]=c.useState(Cn);function i(){s(()=>e.length?e.map(f=>zn(f)?r:new Ht(t(f),f)):Cn)}const a=vt({callback:i});return le(()=>{a?.disconnect(),i(),e.forEach(f=>a?.observe(f))},[e]),o}function No(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Xe(t)?t:e}function Lo(e){let{measure:t}=e;const[n,r]=c.useState(null),o=c.useCallback(d=>{for(const{target:h}of d)if(Xe(h)){r(v=>{const b=t(h);return v?{...v,width:b.width,height:b.height}:b});break}},[t]),s=vt({callback:o}),i=c.useCallback(d=>{const h=No(d);s?.disconnect(),h&&s?.observe(h),r(h?t(h):null)},[t,s]),[a,f]=lt(i);return c.useMemo(()=>({nodeRef:a,rect:n,setRef:f}),[n,a,f])}const Po=[{sensor:Ut,options:{}},{sensor:Fn,options:{}}],zo={current:{}},at={draggable:{measure:gn},droppable:{measure:gn,strategy:Ye.WhileDragging,frequency:Pt.Optimized},dragOverlay:{measure:Ae}};class We 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 $o={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new We,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:dt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:at,measureDroppableContainers:dt,windowRect:null,measuringScheduled:!1},Vo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:dt,draggableNodes:new Map,over:null,measureDroppableContainers:dt},gt=c.createContext(Vo),Un=c.createContext($o);function Bo(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new We}}}function Fo(e,t){switch(t.type){case $.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case $.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 $.DragEnd:case $.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new We(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case $.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new We(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case $.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new We(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function Ho(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=c.useContext(gt),s=At(r),i=At(n?.id);return c.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!Bt(s)||document.activeElement===s.target)return;const a=o.get(i);if(!a)return;const{activatorNode:f,node:d}=a;if(!f.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[f.current,d.current]){if(!h)continue;const v=Ir(h);if(v){v.focus();break}}})}},[r,t,o,i,s]),null}function Wo(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function Uo(e){return c.useMemo(()=>({draggable:{...at.draggable,...e?.draggable},droppable:{...at.droppable,...e?.droppable},dragOverlay:{...at.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Yo(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=c.useRef(!1),{x:i,y:a}=typeof o=="boolean"?{x:o,y:o}:o;le(()=>{if(!i&&!a||!t){s.current=!1;return}if(s.current||!r)return;const d=t?.node.current;if(!d||d.isConnected===!1)return;const h=n(d),v=Mn(h,r);if(i||(v.x=0),a||(v.y=0),s.current=!0,Math.abs(v.x)>0||Math.abs(v.y)>0){const b=Nn(d);b&&b.scrollBy({top:v.y,left:v.x})}},[t,i,a,r,n])}const Yn=c.createContext({...oe,scaleX:1,scaleY:1});var ye;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ye||(ye={}));const Gn=c.memo(function(t){var n,r,o,s;let{id:i,accessibility:a,autoScroll:f=!0,children:d,sensors:h=Po,collisionDetection:v=Xr,measuring:b,modifiers:u,...x}=t;const m=c.useReducer(Fo,void 0,Bo),[y,w]=m,[E,D]=zr(),[_,j]=c.useState(ye.Uninitialized),C=_===ye.Initialized,{draggable:{active:R,nodes:O,translate:L},droppable:{containers:z}}=y,N=R!=null?O.get(R):null,U=c.useRef({initial:null,translated:null}),G=c.useMemo(()=>{var W;return R!=null?{id:R,data:(W=N?.data)!=null?W:zo,rect:U}:null},[R,N]),ee=c.useRef(null),[ue,we]=c.useState(null),[F,Se]=c.useState(null),te=Ue(x,Object.values(x)),ve=Ke("DndDescribedBy",i),p=c.useMemo(()=>z.getEnabled(),[z]),S=Uo(b),{droppableRects:k,measureDroppableContainers:M,measuringScheduled:se}=Eo(p,{dragging:C,dependencies:[L.x,L.y],config:S.droppable}),H=Co(O,R),P=c.useMemo(()=>F?Mt(F):null,[F]),Y=fr(),X=Do(H,S.draggable.measure);Yo({activeNode:R!=null?O.get(R):null,config:Y.layoutShiftCompensation,initialRect:X,measure:S.draggable.measure});const A=yn(H,S.draggable.measure,X),Me=yn(H?H.parentElement:null),ie=c.useRef({activatorEvent:null,active:null,activeNode:H,collisionRect:null,collisions:null,droppableRects:k,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:z,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ce=z.getNodeFor((n=ie.current.over)==null?void 0:n.id),de=Lo({measure:S.dragOverlay.measure}),Re=(r=de.nodeRef.current)!=null?r:H,Ee=C?(o=de.rect)!=null?o:A:null,Gt=!!(de.nodeRef.current&&de.rect),qt=Oo(Gt?null:A),mt=Wn(Re?q(Re):null),ge=jo(C?Ce??H:null),Ze=Mo(ge),Qe=Wo(u,{transform:{x:L.x-qt.x,y:L.y-qt.y,scaleX:1,scaleY:1},activatorEvent:F,active:G,activeNodeRect:A,containerNodeRect:Me,draggingNodeRect:Ee,over:ie.current.over,overlayNodeRect:de.rect,scrollableAncestors:ge,scrollableAncestorRects:Ze,windowRect:mt}),Xt=P?Oe(P,L):null,Jt=ko(ge),sr=Sn(Jt),ir=Sn(Jt,[A]),De=Oe(Qe,sr),Te=Ee?Zr(Ee,Qe):null,Ne=G&&Te?v({active:G,collisionRect:Te,droppableRects:k,droppableContainers:p,pointerCoordinates:Xt}):null,Kt=Gr(Ne,"id"),[pe,Zt]=c.useState(null),ar=Gt?Qe:Oe(Qe,ir),cr=Jr(ar,(s=pe?.rect)!=null?s:null,A),xt=c.useRef(null),Qt=c.useCallback((W,J)=>{let{sensor:K,options:be}=J;if(ee.current==null)return;const ne=O.get(ee.current);if(!ne)return;const Z=W.nativeEvent,ae=new K({active:ee.current,activeNode:ne,event:Z,options:be,context:ie,onAbort(B){if(!O.get(B))return;const{onDragAbort:ce}=te.current,fe={id:B};ce?.(fe),E({type:"onDragAbort",event:fe})},onPending(B,me,ce,fe){if(!O.get(B))return;const{onDragPending:Pe}=te.current,xe={id:B,constraint:me,initialCoordinates:ce,offset:fe};Pe?.(xe),E({type:"onDragPending",event:xe})},onStart(B){const me=ee.current;if(me==null)return;const ce=O.get(me);if(!ce)return;const{onDragStart:fe}=te.current,Le={activatorEvent:Z,active:{id:me,data:ce.data,rect:U}};Be.unstable_batchedUpdates(()=>{fe?.(Le),j(ye.Initializing),w({type:$.DragStart,initialCoordinates:B,active:me}),E({type:"onDragStart",event:Le}),we(xt.current),Se(Z)})},onMove(B){w({type:$.DragMove,coordinates:B})},onEnd:_e($.DragEnd),onCancel:_e($.DragCancel)});xt.current=ae;function _e(B){return async function(){const{active:ce,collisions:fe,over:Le,scrollAdjustedTranslate:Pe}=ie.current;let xe=null;if(ce&&Pe){const{cancelDrop:ze}=te.current;xe={activatorEvent:Z,active:ce,collisions:fe,delta:Pe,over:Le},B===$.DragEnd&&typeof ze=="function"&&await Promise.resolve(ze(xe))&&(B=$.DragCancel)}ee.current=null,Be.unstable_batchedUpdates(()=>{w({type:B}),j(ye.Uninitialized),Zt(null),we(null),Se(null),xt.current=null;const ze=B===$.DragEnd?"onDragEnd":"onDragCancel";if(xe){const yt=te.current[ze];yt?.(xe),E({type:ze,event:xe})}})}}},[O]),lr=c.useCallback((W,J)=>(K,be)=>{const ne=K.nativeEvent,Z=O.get(be);if(ee.current!==null||!Z||ne.dndKit||ne.defaultPrevented)return;const ae={active:Z};W(K,J.options,ae)===!0&&(ne.dndKit={capturedBy:J.sensor},ee.current=be,Qt(K,J))},[O,Qt]),en=Ro(h,lr);Io(h),le(()=>{A&&_===ye.Initializing&&j(ye.Initialized)},[A,_]),c.useEffect(()=>{const{onDragMove:W}=te.current,{active:J,activatorEvent:K,collisions:be,over:ne}=ie.current;if(!J||!K)return;const Z={active:J,activatorEvent:K,collisions:be,delta:{x:De.x,y:De.y},over:ne};Be.unstable_batchedUpdates(()=>{W?.(Z),E({type:"onDragMove",event:Z})})},[De.x,De.y]),c.useEffect(()=>{const{active:W,activatorEvent:J,collisions:K,droppableContainers:be,scrollAdjustedTranslate:ne}=ie.current;if(!W||ee.current==null||!J||!ne)return;const{onDragOver:Z}=te.current,ae=be.get(Kt),_e=ae&&ae.rect.current?{id:ae.id,rect:ae.rect.current,data:ae.data,disabled:ae.disabled}:null,B={active:W,activatorEvent:J,collisions:K,delta:{x:ne.x,y:ne.y},over:_e};Be.unstable_batchedUpdates(()=>{Zt(_e),Z?.(B),E({type:"onDragOver",event:B})})},[Kt]),le(()=>{ie.current={activatorEvent:F,active:G,activeNode:H,collisionRect:Te,collisions:Ne,droppableRects:k,draggableNodes:O,draggingNode:Re,draggingNodeRect:Ee,droppableContainers:z,over:pe,scrollableAncestors:ge,scrollAdjustedTranslate:De},U.current={initial:Ee,translated:Te}},[G,H,Ne,Te,O,Re,Ee,k,z,pe,ge,De]),yo({...Y,delta:L,draggingRect:Te,pointerCoordinates:Xt,scrollableAncestors:ge,scrollableAncestorRects:Ze});const ur=c.useMemo(()=>({active:G,activeNode:H,activeNodeRect:A,activatorEvent:F,collisions:Ne,containerNodeRect:Me,dragOverlay:de,draggableNodes:O,droppableContainers:z,droppableRects:k,over:pe,measureDroppableContainers:M,scrollableAncestors:ge,scrollableAncestorRects:Ze,measuringConfiguration:S,measuringScheduled:se,windowRect:mt}),[G,H,A,F,Ne,Me,de,O,z,k,pe,M,ge,Ze,S,se,mt]),dr=c.useMemo(()=>({activatorEvent:F,activators:en,active:G,activeNodeRect:A,ariaDescribedById:{draggable:ve},dispatch:w,draggableNodes:O,over:pe,measureDroppableContainers:M}),[F,en,G,A,w,ve,O,pe,M]);return c.createElement(In.Provider,{value:D},c.createElement(gt.Provider,{value:dr},c.createElement(Un.Provider,{value:ur},c.createElement(Yn.Provider,{value:cr},d)),c.createElement(Ho,{disabled:a?.restoreFocus===!1})),c.createElement(Br,{...a,hiddenTextDescribedById:ve}));function fr(){const W=ue?.autoScrollEnabled===!1,J=typeof f=="object"?f.enabled===!1:f===!1,K=C&&!W&&!J;return typeof f=="object"?{...f,enabled:K}:{enabled:K}}}),Go=c.createContext(null),Rn="button",qo="Draggable";function Xo(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=Ke(qo),{activators:i,activatorEvent:a,active:f,activeNodeRect:d,ariaDescribedById:h,draggableNodes:v,over:b}=c.useContext(gt),{role:u=Rn,roleDescription:x="draggable",tabIndex:m=0}=o??{},y=f?.id===t,w=c.useContext(y?Yn:Go),[E,D]=lt(),[_,j]=lt(),C=Ao(i,t),R=Ue(n);le(()=>(v.set(t,{id:t,key:s,node:E,activatorNode:_,data:R}),()=>{const L=v.get(t);L&&L.key===s&&v.delete(t)}),[v,t]);const O=c.useMemo(()=>({role:u,tabIndex:m,"aria-disabled":r,"aria-pressed":y&&u===Rn?!0:void 0,"aria-roledescription":x,"aria-describedby":h.draggable}),[r,u,m,y,x,h.draggable]);return{active:f,activatorEvent:a,activeNodeRect:d,attributes:O,isDragging:y,listeners:r?void 0:C,node:E,over:b,setNodeRef:D,setActivatorNodeRef:j,transform:w}}function Jo(){return c.useContext(Un)}const Ko="Droppable",Zo={timeout:25};function Qo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=Ke(Ko),{active:i,dispatch:a,over:f,measureDroppableContainers:d}=c.useContext(gt),h=c.useRef({disabled:n}),v=c.useRef(!1),b=c.useRef(null),u=c.useRef(null),{disabled:x,updateMeasurementsFor:m,timeout:y}={...Zo,...o},w=Ue(m??r),E=c.useCallback(()=>{if(!v.current){v.current=!0;return}u.current!=null&&clearTimeout(u.current),u.current=setTimeout(()=>{d(Array.isArray(w.current)?w.current:[w.current]),u.current=null},y)},[y]),D=vt({callback:E,disabled:x||!i}),_=c.useCallback((O,L)=>{D&&(L&&(D.unobserve(L),v.current=!1),O&&D.observe(O))},[D]),[j,C]=lt(_),R=Ue(t);return c.useEffect(()=>{!D||!j.current||(D.disconnect(),v.current=!1,D.observe(j.current))},[j,D]),c.useEffect(()=>(a({type:$.RegisterDroppable,element:{id:r,key:s,disabled:n,node:j,rect:b,data:R}}),()=>a({type:$.UnregisterDroppable,key:s,id:r})),[r]),c.useEffect(()=>{n!==h.current.disabled&&(a({type:$.SetDroppableDisabled,id:r,key:s,disabled:n}),h.current.disabled=n)},[r,s,n,a]),{active:i,rect:b,isOver:f?.id===r,node:j,over:f,setNodeRef:C}}function pt(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function es(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function ot(e){return e!==null&&e>=0}function ts(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 ns(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const st={scaleX:1,scaleY:1},rs=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:s,index:i}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const f=os(n,i,o);if(i===o){const d=n[s];return d?{x:o<s?d.left+d.width-(a.left+a.width):d.left-a.left,y:0,...st}:null}return i>o&&i<=s?{x:-a.width-f,y:0,...st}:i<o&&i>=s?{x:a.width+f,y:0,...st}:{x:0,y:0,...st}};function os(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return!r||!o&&!s?0:n<t?o?r.left-(o.left+o.width):s.left-(r.left+r.width):s?s.left-(r.left+r.width):r.left-(o.left+o.width)}const qn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=pt(t,r,n),i=t[o],a=s[o];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}},it={scaleX:1,scaleY:1},ss=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const a=(t=s[n])!=null?t:r;if(!a)return null;if(o===n){const d=s[i];return d?{x:0,y:n<i?d.top+d.height-(a.top+a.height):d.top-a.top,...it}:null}const f=is(s,o,n);return o>n&&o<=i?{x:0,y:-a.height-f,...it}:o<n&&o>=i?{x:0,y:a.height+f,...it}:{x:0,y:0,...it}};function is(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const Xn="Sortable",Jn=c.createContext({activeIndex:-1,containerId:Xn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:qn,disabled:{draggable:!1,droppable:!1}});function Kn(e){let{children:t,id:n,items:r,strategy:o=qn,disabled:s=!1}=e;const{active:i,dragOverlay:a,droppableRects:f,over:d,measureDroppableContainers:h}=Jo(),v=Ke(Xn,n),b=a.rect!==null,u=c.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=i!=null,m=i?u.indexOf(i.id):-1,y=d?u.indexOf(d.id):-1,w=c.useRef(u),E=!ts(u,w.current),D=y!==-1&&m===-1||E,_=ns(s);le(()=>{E&&x&&h(u)},[E,u,x,h]),c.useEffect(()=>{w.current=u},[u]);const j=c.useMemo(()=>({activeIndex:m,containerId:v,disabled:_,disableTransforms:D,items:u,overIndex:y,useDragOverlay:b,sortedRects:es(u,f),strategy:o}),[m,v,_.draggable,_.droppable,D,u,y,f,b,o]);return c.createElement(Jn.Provider,{value:j},t)}const as=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return pt(n,r,o).indexOf(t)},cs=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:f,transition:d}=e;return!d||!r||a!==s&&o===i?!1:n?!0:i!==o&&t===f},ls={duration:200,easing:"ease"},Zn="transform",us=je.Transition.toString({property:Zn,duration:0,easing:"linear"}),ds={roleDescription:"sortable"};function fs(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=c.useState(null),a=c.useRef(n);return le(()=>{if(!t&&n!==a.current&&r.current){const f=o.current;if(f){const d=Ae(r.current,{ignoreTransform:!0}),h={x:f.left-d.left,y:f.top-d.top,scaleX:f.width/d.width,scaleY:f.height/d.height};(h.x||h.y)&&i(h)}}n!==a.current&&(a.current=n)},[t,n,r,o]),c.useEffect(()=>{s&&i(null)},[s]),s}function Qn(e){let{animateLayoutChanges:t=cs,attributes:n,disabled:r,data:o,getNewIndex:s=as,id:i,strategy:a,resizeObserverConfig:f,transition:d=ls}=e;const{items:h,containerId:v,activeIndex:b,disabled:u,disableTransforms:x,sortedRects:m,overIndex:y,useDragOverlay:w,strategy:E}=c.useContext(Jn),D=hs(r,u),_=h.indexOf(i),j=c.useMemo(()=>({sortable:{containerId:v,index:_,items:h},...o}),[v,o,_,h]),C=c.useMemo(()=>h.slice(h.indexOf(i)),[h,i]),{rect:R,node:O,isOver:L,setNodeRef:z}=Qo({id:i,data:j,disabled:D.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...f}}),{active:N,activatorEvent:U,activeNodeRect:G,attributes:ee,setNodeRef:ue,listeners:we,isDragging:F,over:Se,setActivatorNodeRef:te,transform:ve}=Xo({id:i,data:j,attributes:{...ds,...n},disabled:D.draggable}),p=_r(z,ue),S=!!N,k=S&&!x&&ot(b)&&ot(y),M=!w&&F,se=M&&k?ve:null,P=k?se??(a??E)({rects:m,activeNodeRect:G,activeIndex:b,overIndex:y,index:_}):null,Y=ot(b)&&ot(y)?s({id:i,items:h,activeIndex:b,overIndex:y}):_,X=N?.id,A=c.useRef({activeId:X,items:h,newIndex:Y,containerId:v}),Me=h!==A.current.items,ie=t({active:N,containerId:v,isDragging:F,isSorting:S,id:i,index:_,items:h,newIndex:A.current.newIndex,previousItems:A.current.items,previousContainerId:A.current.containerId,transition:d,wasDragging:A.current.activeId!=null}),Ce=fs({disabled:!ie,index:_,node:O,rect:R});return c.useEffect(()=>{S&&A.current.newIndex!==Y&&(A.current.newIndex=Y),v!==A.current.containerId&&(A.current.containerId=v),h!==A.current.items&&(A.current.items=h)},[S,Y,v,h]),c.useEffect(()=>{if(X===A.current.activeId)return;if(X!=null&&A.current.activeId==null){A.current.activeId=X;return}const Re=setTimeout(()=>{A.current.activeId=X},50);return()=>clearTimeout(Re)},[X]),{active:N,activeIndex:b,attributes:ee,data:j,rect:R,index:_,newIndex:Y,items:h,isOver:L,isSorting:S,isDragging:F,listeners:we,node:O,overIndex:y,over:Se,setNodeRef:p,setActivatorNodeRef:te,setDroppableNodeRef:z,setDraggableNodeRef:ue,transform:Ce??P,transition:de()};function de(){if(Ce||Me&&A.current.newIndex===_)return us;if(!(M&&!Bt(U)||!d)&&(S||ie))return je.Transition.toString({...d,property:Zn})}}function hs(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}}I.Down,I.Right,I.Up,I.Left;const vs=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),gs=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),En=e=>{const t=gs(e);return t.charAt(0).toUpperCase()+t.slice(1)},er=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),ps=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var bs={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ms=c.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},f)=>c.createElement("svg",{ref:f,...bs,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:er("lucide",o),...!s&&!ps(a)&&{"aria-hidden":"true"},...a},[...i.map(([d,h])=>c.createElement(d,h)),...Array.isArray(s)?s:[s]]));const Q=(e,t)=>{const n=c.forwardRef(({className:r,...o},s)=>c.createElement(ms,{ref:s,iconNode:t,className:er(`lucide-${vs(En(e))}`,`lucide-${e}`,r),...o}));return n.displayName=En(e),n};const xs=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ys=Q("arrow-down",xs);const ws=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ss=Q("arrow-up-down",ws);const Cs=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Rs=Q("arrow-up",Cs);const Es=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Ds=Q("bookmark",Es);const Ts=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_s=Q("chevron-left",Ts);const Os=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],js=Q("chevron-right",Os);const ks=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Is=Q("columns-2",ks);const As=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],Ms=Q("delete",As);const Ns=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Ls=Q("ellipsis",Ns);const Ps=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],zs=Q("funnel",Ps);const $s=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Vs=Q("grip-vertical",$s);const Bs=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Fs=Q("pen",Bs);const Hs=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ws=Q("settings",Hs);function T(e){return c.forwardRef((t,n)=>{const{children:r,...o}=t;return l.jsx(e,{ref:n,...o,children:r})})}const he=new On({sortColumn:null,sortDirection:"asc",visibility:{},columnOrder:[],data:[],sortableColumns:[]});function tr(e,t){const n=e[0]??{},o=(t&&t.length?t:Object.keys(n).map(s=>({id:s,label:s}))).filter(s=>n.hasOwnProperty(s.id));he.setState(s=>({...s,data:e,columnOrder:o,visibility:o.reduce((i,a)=>({...i,[a.id]:!0}),{}),sortableColumns:o.map(i=>({id:i.id,label:i.label,sortable:!0}))}))}const Us=T(g.Menu.Trigger),Ys=T(g.Menu.Positioner),Gs=T(g.Menu.Content),qs=T(g.Menu.Item),Xs=T(g.Checkbox.Label),Js=T(g.Checkbox.HiddenInput),Ks=T(g.Checkbox.Control);function Zs({visibility:e,onToggle:t}){const{sortableColumns:n}=qe(he);return l.jsxs(g.Menu.Root,{closeOnSelect:!1,children:[l.jsx(Us,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Toggle columns",variant:"outline",size:"sm",ml:"1",children:l.jsx(Is,{size:18})})}),l.jsx(g.Portal,{children:l.jsx(Ys,{children:l.jsx(Gs,{minW:"220px",children:n.map(r=>{const o=!!e[r.id];return l.jsx(qs,{value:r.id,closeOnSelect:!1,children:l.jsxs(g.Checkbox.Root,{checked:o,onCheckedChange:()=>t(r.id),children:[l.jsx(Js,{}),l.jsx(Ks,{}),l.jsx(Xs,{children:r.label})]})},r.id)})})})})]})}const Qs=e=>{he.setState(t=>({...t,columnOrder:e}))},ei=e=>{he.setState(t=>({...t,visibility:{...t.visibility,[e]:!t.visibility[e]}}))};function ti(e){he.setState(t=>t.sortColumn===e?{...t,sortDirection:t.sortDirection==="asc"?"desc":"asc"}:{...t,sortColumn:e,sortDirection:"asc"})}function ni({id:e,children:t,onClick:n,cursor:r,borderRight:o,borderRightColor:s}){const{setNodeRef:i,attributes:a,listeners:f,transform:d,transition:h}=Qn({id:e});return l.jsx(g.Table.ColumnHeader,{ref:i,onClick:n,w:e==="id"?"80px":void 0,style:{transform:je.Transform.toString(d),transition:h,cursor:r,borderRight:o,borderRightColor:s},...a,children:l.jsxs(g.HStack,{justify:"space-between",children:[t,l.jsx("span",{...f,children:l.jsx(Vs,{size:12})})]})})}function ri(){const{columnOrder:e,visibility:t,sortColumn:n,sortDirection:r,sortableColumns:o}=qe(he),s=e.map(a=>o.find(f=>f.id===a.id)).filter(a=>a!==void 0).filter(a=>t[a.id]),i=a=>{const{active:f,over:d}=a;if(!d||f.id===d.id)return;const h=e.findIndex(u=>u.id===f.id),v=e.findIndex(u=>u.id===d.id),b=pt(e,h,v);Qs(b)};return l.jsx(g.Table.Header,{background:"gray.100",position:"sticky",top:0,p:"0",children:l.jsx(Gn,{collisionDetection:An,onDragEnd:i,children:l.jsx(Kn,{items:e.map(a=>a.id),strategy:rs,children:l.jsxs(g.Table.Row,{height:"28px",children:[s.map((a,f)=>{const d=n===a?.id;return l.jsx(ni,{id:a?.id,onClick:()=>a?.sortable&&ti(a?.id),cursor:a?.sortable?"pointer":"default",borderRight:"2px solid #dcdcdc",children:l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,userSelect:"none"},children:[a?.label,a?.sortable&&(d?r==="asc"?l.jsx(Rs,{size:14}):l.jsx(ys,{size:14}):l.jsx(Ss,{size:14,opacity:.4}))]})},a?.id)}),l.jsx(g.Table.ColumnHeader,{borderRight:"2px solid #dcdcdc",children:"Actions"}),l.jsx(g.Table.ColumnHeader,{boxSize:"0.5",children:l.jsx(Zs,{visibility:t,onToggle:ei})})]})})})})}const Dn=g.createListCollection({items:[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}]}),oi=T(g.Select.Positioner),si=T(g.Select.Content),ii=T(g.Select.Item),ai=T(g.Pagination.PrevTrigger),ci=T(g.Pagination.NextTrigger),li=T(g.Select.HiddenSelect),ui=T(g.Select.Control),di=T(g.Select.Trigger),fi=T(g.Select.ValueText),hi=T(g.Select.IndicatorGroup),vi=T(g.Select.Indicator);function gi({totalCount:e,pageSize:t,currentPage:n,onPageChange:r,onPageSizeChange:o,siblingCount:s=2}){return l.jsx(g.Box,{width:"100%",children:l.jsxs(g.HStack,{justify:"space-between",mx:"auto",flexWrap:"wrap",children:[l.jsxs(g.HStack,{children:[l.jsx(g.Text,{fontSize:"sm",color:"gray.600",_dark:{color:"gray.400"},children:"Rows per page:"}),l.jsxs(g.Select.Root,{collection:Dn,size:"sm",width:"60px",onValueChange:i=>o&&o(Number(i.items[0].value)),value:[String(t)],children:[l.jsx(li,{}),l.jsxs(ui,{children:[l.jsx(di,{children:l.jsx(fi,{placeholder:""})}),l.jsx(hi,{children:l.jsx(vi,{})})]}),l.jsx(g.Portal,{children:l.jsx(oi,{children:l.jsx(si,{children:Dn.items.map(i=>l.jsxs(ii,{item:i.value,children:[i.label,l.jsx(g.Select.ItemIndicator,{})]},i.value))})})})]})]}),l.jsx(g.Pagination.Root,{count:e,pageSize:t,page:n,siblingCount:s,onPageChange:i=>r&&r(i.page),children:l.jsxs(g.ButtonGroup,{size:"sm",variant:"ghost",children:[l.jsx(ai,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Previous page",children:l.jsx(_s,{size:18})})}),l.jsx(g.Pagination.Items,{render:i=>l.jsx(g.IconButton,{variant:i.type==="page"&&i.value===n?"outline":"ghost","aria-current":i.type==="page"&&i.value===n?"page":void 0,children:i.type==="page"?i.value:"…"},i.value??i.type)}),l.jsx(ci,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Next page",children:l.jsx(js,{size:18})})})]})})]})})}const pi=T(g.Menu.Item),bi=T(g.Menu.Content),mi=T(g.Menu.Positioner),xi=T(g.Menu.Trigger);function yi({data:e=[],actions:t=[]}){const{columnOrder:n,visibility:r}=qe(he);return l.jsx(g.Table.Body,{children:e.map(o=>l.jsxs(g.Table.Row,{children:[n.filter(s=>r[s.id]).map(s=>l.jsx(g.Table.Cell,{children:o[s.id]},s.id)),l.jsx(g.Table.Cell,{textAlign:"center",display:"flex",gap:2,children:l.jsxs(g.Menu.Root,{children:[l.jsx(xi,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Open",variant:"ghost",size:"sm",children:l.jsx(Ls,{size:16})})}),l.jsx(g.Portal,{children:l.jsx(mi,{children:l.jsx(bi,{children:t.map(s=>l.jsxs(pi,{onClick:()=>s.onClick(o),colorScheme:s.colorScheme,value:s.label,children:[s.icon,s.label]},s.label))})})})]})})]},o.id))})}function wi({data:e=[],headers:t=[],loading:n=!1,emptyMessage:r="No data",actions:o,page:s=0,pageSize:i=10,onPageChange:a,onPageSizeChange:f,density:d="sm"}){c.useMemo(()=>{tr(e,t)},[e]);const{sortColumn:h,sortDirection:v,data:b}=qe(he),u=c.useMemo(()=>{const x=[...b];h&&x.sort((y,w)=>v==="asc"?String(y[h]).localeCompare(String(w[h])):String(w[h]).localeCompare(String(y[h])));const m=(s-1)*i;return x.slice(m,m+i)},[s,i,h,v]);return l.jsxs(g.Box,{h:"100%",display:"flex",flexDirection:"column",p:2,pt:2,minHeight:0,children:[l.jsx(g.Box,{flex:"1",minHeight:0,overflow:"auto",children:n?l.jsx(g.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:"Loading..."}):u.length===0?l.jsx(g.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:r}):l.jsxs(g.Table.Root,{variant:"outline",w:"100%",size:d,children:[l.jsx(ri,{}),l.jsx(yi,{data:u,actions:o})]})}),l.jsx(g.Box,{mt:.5,children:l.jsx(gi,{totalCount:e.length,pageSize:i,currentPage:s,onPageChange:a,onPageSizeChange:x=>{f&&f(x),s>1&&a&&a(1)}})})]})}const nr=e=>`FILTER_PRESETS_${e??"default"}`;function Si(e){try{return JSON.parse(localStorage.getItem(nr(e))||"[]")}catch{return[]}}const Ge=new On({}),bt=e=>{const t=Ge.state[e];if(t)return t;const n=Si(e);return Ge.setState(r=>({...r,[e]:n})),n},Yt=(e,t)=>{Ge.setState(n=>({...n,[e]:t})),localStorage.setItem(nr(e),JSON.stringify(t))},rr=(e,t)=>{const n=bt(e).filter(r=>r.id!==t);Yt(e,n)},or=(e,t)=>{const n=[t,...bt(e)];Yt(e,n)},Ci=T(g.Checkbox.Root),Ri=T(g.Checkbox.HiddenInput),Ei=T(g.Checkbox.Control),Di=T(g.Slider.Root),Ti=T(g.Slider.Track),_i=T(g.Slider.Range),Oi=T(g.Slider.Thumbs),ji=T(g.Slider.Control),ki=({filter:e,onVisibilityChange:t,onSizeChange:n})=>{const{attributes:r,listeners:o,setNodeRef:s,transform:i,transition:a}=Qn({id:e.id}),f={transform:je.Transform.toString(i),transition:a,cursor:"grab"};return l.jsxs(g.VStack,{ref:s,style:f,align:"stretch",border:"1px solid",borderColor:"gray.200",rounded:"md",p:3,mb:3,...r,...o,children:[l.jsx(g.Text,{fontWeight:"bold",children:e.label}),l.jsxs(g.HStack,{justify:"space-between",children:[l.jsx(g.Text,{fontSize:"sm",children:"Visible"}),l.jsxs(Ci,{checked:e.visible,onCheckedChange:d=>t&&t(e.id,!!d),size:"sm",children:[l.jsx(Ri,{}),l.jsx(Ei,{})]})]}),l.jsxs(g.VStack,{align:"stretch",gap:1,children:[l.jsx(g.Text,{fontSize:"sm",children:"Size"}),l.jsx(Di,{width:"200px",min:1,max:5,step:.5,value:[e.size??1],onChange:d=>n&&n(e.id,d[0]),children:l.jsxs(ji,{children:[l.jsx(Ti,{children:l.jsx(_i,{})}),l.jsx(Oi,{})]})})]})]})},Ii=T(g.Drawer.Root),Ai=T(g.Drawer.Trigger),Mi=T(g.Drawer.Backdrop),Ni=T(g.Drawer.Positioner),Li=T(g.Drawer.Content),Pi=T(g.Drawer.Header),zi=T(g.Drawer.Title),$i=T(g.Drawer.Body),Vi=T(g.Drawer.Footer),Bi=T(g.Drawer.CloseTrigger),Fi=T(g.Tabs.Root),Hi=T(g.Tabs.List),jt=T(g.Tabs.Trigger),kt=T(g.Tabs.Content),Wi=({filterDrawerSize:e="sm",onVisibilityChange:t,onSizeChange:n,onClear:r,filters:o,pageKey:s="default",currentFilters:i={},onLoadPreset:a,activePresetName:f,onReorder:d})=>{const v=qe(Ge)[s]??bt(s),b=()=>{const u=prompt("Preset name?");u&&or(s,{id:crypto.randomUUID(),name:u,date:new Date().toISOString(),filters:i})};return l.jsx(g.HStack,{wrap:"wrap",children:l.jsxs(Ii,{size:e,children:[l.jsx(Ai,{asChild:!0,children:l.jsxs(g.IconButton,{"aria-label":"Open filters",variant:"outline",size:"xs",ml:2,p:2,children:[l.jsx(zs,{size:16}),"Filters"]})}),l.jsxs(g.Portal,{children:[l.jsx(Mi,{}),l.jsx(Ni,{children:l.jsxs(Li,{children:[l.jsx(Pi,{children:l.jsx(zi,{children:"Filters"})}),l.jsx($i,{overflowY:"auto",pt:1,children:l.jsxs(Fi,{defaultValue:"view",children:[l.jsxs(Hi,{mb:4,children:[l.jsxs(jt,{value:"view",children:[l.jsx(Fs,{size:16}),"Edit"]}),l.jsxs(jt,{value:"settings",children:[l.jsx(Ws,{size:16}),"Settings"]}),l.jsxs(jt,{value:"presets",children:[l.jsx(Ds,{size:16}),"Presets"]})]}),l.jsx(kt,{value:"view",children:o.filter(u=>u.visible).map(u=>l.jsxs(g.VStack,{align:"stretch",border:"1px solid",borderColor:"gray.200",rounded:"md",p:3,mb:3,children:[l.jsx(g.Text,{fontWeight:"bold",children:u.label}),u.customComponent]},u.id))}),l.jsx(kt,{value:"settings",children:l.jsx(Gn,{sensors:Hr(Fr(Ut)),collisionDetection:An,onDragEnd:({active:u,over:x})=>{if(!x||u.id===x.id)return;const m=o.findIndex(E=>E.id===u.id),y=o.findIndex(E=>E.id===x.id),w=pt(o,m,y);console.log(w),d?.(w)},children:l.jsx(Kn,{items:o.map(u=>u.id),strategy:ss,children:o.map(u=>l.jsx(ki,{filter:u,onVisibilityChange:t,onSizeChange:n},u.id))})})}),l.jsx(kt,{value:"presets",children:l.jsxs(g.VStack,{align:"stretch",mb:3,children:[l.jsx(g.Button,{size:"sm",colorScheme:"blue",onClick:b,children:"Save Current Filters"}),v.length===0&&l.jsx(g.Text,{fontSize:"xs",color:"gray.500",children:"No presets saved yet."}),v.map(u=>l.jsxs(g.HStack,{justify:"space-between",border:"1px solid",borderColor:f===u.name?"blue.300":"gray.200",rounded:"md",p:2,children:[l.jsxs(g.VStack,{align:"start",gap:0,children:[l.jsx(g.Text,{fontWeight:"bold",fontSize:"sm",children:u.name}),l.jsx(g.Text,{fontSize:"xs",color:"gray.500",children:new Date(u.date).toLocaleDateString()})]}),l.jsxs(g.HStack,{children:[l.jsx(g.Button,{size:"xs",variant:"ghost",onClick:()=>a?.(u.filters,u.name),children:"Load"}),l.jsx(g.IconButton,{size:"xs","aria-label":"Delete preset",variant:"ghost",onClick:()=>rr(s,u.id),children:l.jsx(Ms,{size:14})})]})]},u.id))]})})]})}),l.jsxs(Vi,{justify:"space-between",children:[l.jsx(g.Button,{size:"sm",variant:"ghost",colorScheme:"red",onClick:()=>r&&r(),children:"Clear All"}),l.jsx(Bi,{asChild:!0,children:l.jsx(g.CloseButton,{})})]})]})})]})]})})},Ui=({title:e,filters:t,onVisibilityChange:n,onReorder:r,onSizeChange:o,onClear:s,maxToolbarUnits:i,pageKey:a,currentFilters:f,onLoadPreset:d,activePresetName:h,filterDrawerSize:v="sm"})=>l.jsxs(g.HStack,{wrap:"wrap",pl:2,pr:2,width:"100%",justify:"space-between",children:[e,l.jsxs(g.HStack,{children:[t.length>0&&t.filter(b=>b.visible).map(b=>l.jsx(g.HStack,{children:b.customComponent},b.id)),l.jsx(Wi,{filterDrawerSize:v,onVisibilityChange:n?(b,u)=>n(b,u):void 0,onReorder:r,onSizeChange:o?(b,u)=>o(b,u):void 0,onClear:s,maxToolbarUnits:i,pageKey:a,filters:t,currentFilters:f,onLoadPreset:d,activePresetName:h})]})]}),Yi=(e,t)=>{localStorage.setItem(`FILTER_ORDER_${e}`,JSON.stringify(t))},Gi=e=>{try{return JSON.parse(localStorage.getItem(`FILTER_ORDER_${e}`)||"[]")}catch{return[]}};exports.DataTable=wi;exports.Filters=Ui;exports.addPreset=or;exports.deletePreset=rr;exports.getPresets=bt;exports.loadOrder=Gi;exports.presetStore=Ge;exports.saveOrder=Yi;exports.savePresets=Yt;exports.setData=tr;exports.tableStore=he;exports.withChildren=T;
10
+ `},Vr={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 Br(e){let{announcements:t=Vr,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=$r}=e;const{announce:s,announcement:i}=Lr(),a=Ke("DndLiveRegion"),[f,d]=c.useState(!1);if(c.useEffect(()=>{d(!0)},[]),Pr(c.useMemo(()=>({onDragStart(v){let{active:b}=v;s(t.onDragStart({active:b}))},onDragMove(v){let{active:b,over:u}=v;t.onDragMove&&s(t.onDragMove({active:b,over:u}))},onDragOver(v){let{active:b,over:u}=v;s(t.onDragOver({active:b,over:u}))},onDragEnd(v){let{active:b,over:u}=v;s(t.onDragEnd({active:b,over:u}))},onDragCancel(v){let{active:b,over:u}=v;s(t.onDragCancel({active:b,over:u}))}}),[s,t])),!f)return null;const h=c.createElement(c.Fragment,null,c.createElement(Mr,{id:r,value:o.draggable}),c.createElement(Nr,{id:a,announcement:i}));return n?Be.createPortal(h,n):h}var $;(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"})($||($={}));function dt(){}function Fr(e,t){return c.useMemo(()=>({sensor:e,options:{}}),[e,t])}function Hr(){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 oe=Object.freeze({x:0,y:0});function Wr(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Ur(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Yr(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Gr(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function vn(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 An=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=vn(t,t.left,t.top),s=[];for(const i of r){const{id:a}=i,f=n.get(a);if(f){const d=Wr(vn(f),o);s.push({id:a,data:{droppableContainer:i,value:d}})}}return s.sort(Ur)};function qr(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),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,a=s-n;if(r<o&&n<s){const f=t.width*t.height,d=e.width*e.height,h=i*a,v=h/(f+d-h);return Number(v.toFixed(4))}return 0}const Xr=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:i}=s,a=n.get(i);if(a){const f=qr(a,t);f>0&&o.push({id:i,data:{droppableContainer:s,value:f}})}}return o.sort(Yr)};function Jr(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Mn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:oe}function Kr(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),s=1;s<r;s++)o[s-1]=arguments[s];return o.reduce((i,a)=>({...i,top:i.top+e*a.y,bottom:i.bottom+e*a.y,left:i.left+e*a.x,right:i.right+e*a.x}),{...n})}}const Zr=Kr(1);function Qr(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 eo(e,t,n){const r=Qr(t);if(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,f=e.left-i-(1-o)*parseFloat(n),d=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),h=o?e.width/o:e.width,v=s?e.height/s:e.height;return{width:h,height:v,top:d,right:f+h,bottom:d+v,left:f}}const to={ignoreTransform:!1};function Ae(e,t){t===void 0&&(t=to);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:d,transformOrigin:h}=q(e).getComputedStyle(e);d&&(n=eo(n,d,h))}const{top:r,left:o,width:s,height:i,bottom:a,right:f}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:f}}function gn(e){return Ae(e,{ignoreTransform:!0})}function no(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function ro(e,t){return t===void 0&&(t=q(e).getComputedStyle(e)),t.position==="fixed"}function oo(e,t){t===void 0&&(t=q(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const s=t[o];return typeof s=="string"?n.test(s):!1})}function Ft(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if($t(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Xe(o)||jn(o)||n.includes(o))return n;const s=q(e).getComputedStyle(o);return o!==e&&oo(o,s)&&n.push(o),ro(o,s)?n:r(o.parentNode)}return e?r(e):n}function Nn(e){const[t]=Ft(e,1);return t??null}function Tt(e){return!ht||!e?null:ke(e)?e:zt(e)?$t(e)||e===Ie(e).scrollingElement?window:Xe(e)?e:null:null}function Ln(e){return ke(e)?e.scrollX:e.scrollLeft}function Pn(e){return ke(e)?e.scrollY:e.scrollTop}function Nt(e){return{x:Ln(e),y:Pn(e)}}var V;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(V||(V={}));function zn(e){return!ht||!e?!1:e===document.scrollingElement}function $n(e){const t={x:0,y:0},n=zn(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,s=e.scrollLeft<=t.x,i=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:s,isBottom:i,isRight:a,maxScroll:r,minScroll:t}}const so={x:.2,y:.2};function io(e,t,n,r,o){let{top:s,left:i,right:a,bottom:f}=n;r===void 0&&(r=10),o===void 0&&(o=so);const{isTop:d,isBottom:h,isLeft:v,isRight:b}=$n(e),u={x:0,y:0},x={x:0,y:0},m={height:t.height*o.y,width:t.width*o.x};return!d&&s<=t.top+m.height?(u.y=V.Backward,x.y=r*Math.abs((t.top+m.height-s)/m.height)):!h&&f>=t.bottom-m.height&&(u.y=V.Forward,x.y=r*Math.abs((t.bottom-m.height-f)/m.height)),!b&&a>=t.right-m.width?(u.x=V.Forward,x.x=r*Math.abs((t.right-m.width-a)/m.width)):!v&&i<=t.left+m.width&&(u.x=V.Backward,x.x=r*Math.abs((t.left+m.width-i)/m.width)),{direction:u,speed:x}}function ao(e){if(e===document.scrollingElement){const{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}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 Vn(e){return e.reduce((t,n)=>Oe(t,Nt(n)),oe)}function co(e){return e.reduce((t,n)=>t+Ln(n),0)}function lo(e){return e.reduce((t,n)=>t+Pn(n),0)}function uo(e,t){if(t===void 0&&(t=Ae),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);Nn(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const fo=[["x",["left","right"],co],["y",["top","bottom"],lo]];class Ht{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=Ft(n),o=Vn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[s,i,a]of fo)for(const f of i)Object.defineProperty(this,f,{get:()=>{const d=a(r),h=o[s]-d;return this.rect[f]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Fe{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 ho(e){const{EventTarget:t}=q(e);return e instanceof t?e:Ie(e)}function _t(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 re;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(re||(re={}));function pn(e){e.preventDefault()}function vo(e){e.stopPropagation()}var I;(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"})(I||(I={}));const Bn={start:[I.Space,I.Enter],cancel:[I.Esc],end:[I.Space,I.Enter,I.Tab]},go=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case I.Right:return{...n,x:n.x+25};case I.Left:return{...n,x:n.x-25};case I.Down:return{...n,y:n.y+25};case I.Up:return{...n,y:n.y-25}}};class Fn{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 Fe(Ie(n)),this.windowListeners=new Fe(q(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(re.Resize,this.handleCancel),this.windowListeners.add(re.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(re.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&uo(r),n(oe)}handleKeyDown(t){if(Bt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:s=Bn,coordinateGetter:i=go,scrollBehavior:a="smooth"}=o,{code:f}=t;if(s.end.includes(f)){this.handleEnd(t);return}if(s.cancel.includes(f)){this.handleCancel(t);return}const{collisionRect:d}=r.current,h=d?{x:d.left,y:d.top}:oe;this.referenceCoordinates||(this.referenceCoordinates=h);const v=i(t,{active:n,context:r.current,currentCoordinates:h});if(v){const b=ut(v,h),u={x:0,y:0},{scrollableAncestors:x}=r.current;for(const m of x){const y=t.code,{isTop:w,isRight:E,isLeft:D,isBottom:_,maxScroll:j,minScroll:C}=$n(m),R=ao(m),O={x:Math.min(y===I.Right?R.right-R.width/2:R.right,Math.max(y===I.Right?R.left:R.left+R.width/2,v.x)),y:Math.min(y===I.Down?R.bottom-R.height/2:R.bottom,Math.max(y===I.Down?R.top:R.top+R.height/2,v.y))},L=y===I.Right&&!E||y===I.Left&&!D,z=y===I.Down&&!_||y===I.Up&&!w;if(L&&O.x!==v.x){const N=m.scrollLeft+b.x,U=y===I.Right&&N<=j.x||y===I.Left&&N>=C.x;if(U&&!b.y){m.scrollTo({left:N,behavior:a});return}U?u.x=m.scrollLeft-N:u.x=y===I.Right?m.scrollLeft-j.x:m.scrollLeft-C.x,u.x&&m.scrollBy({left:-u.x,behavior:a});break}else if(z&&O.y!==v.y){const N=m.scrollTop+b.y,U=y===I.Down&&N<=j.y||y===I.Up&&N>=C.y;if(U&&!b.x){m.scrollTo({top:N,behavior:a});return}U?u.y=m.scrollTop-N:u.y=y===I.Down?m.scrollTop-j.y:m.scrollTop-C.y,u.y&&m.scrollBy({top:-u.y,behavior:a});break}}this.handleMove(t,Oe(ut(v,this.referenceCoordinates),u))}}}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()}}Fn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Bn,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const a=s.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function bn(e){return!!(e&&"distance"in e)}function mn(e){return!!(e&&"delay"in e)}class Wt{constructor(t,n,r){var o;r===void 0&&(r=ho(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:s}=t,{target:i}=s;this.props=t,this.events=n,this.document=Ie(i),this.documentListeners=new Fe(this.document),this.listeners=new Fe(r),this.windowListeners=new Fe(q(i)),this.initialCoordinates=(o=Mt(s))!=null?o:oe,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(re.Resize,this.handleCancel),this.windowListeners.add(re.DragStart,pn),this.windowListeners.add(re.VisibilityChange,this.handleCancel),this.windowListeners.add(re.ContextMenu,pn),this.documentListeners.add(re.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(mn(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(bn(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(re.Click,vo,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(re.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:s}=this,{onMove:i,options:{activationConstraint:a}}=s;if(!o)return;const f=(n=Mt(t))!=null?n:oe,d=ut(o,f);if(!r&&a){if(bn(a)){if(a.tolerance!=null&&_t(d,a.tolerance))return this.handleCancel();if(_t(d,a.distance))return this.handleStart()}if(mn(a)&&_t(d,a.tolerance))return this.handleCancel();this.handlePending(a,d);return}t.cancelable&&t.preventDefault(),i(f)}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===I.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const po={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Ut extends Wt{constructor(t){const{event:n}=t,r=Ie(n.target);super(t,po,r)}}Ut.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 bo={move:{name:"mousemove"},end:{name:"mouseup"}};var Lt;(function(e){e[e.RightClick=2]="RightClick"})(Lt||(Lt={}));class mo extends Wt{constructor(t){super(t,bo,Ie(t.event.target))}}mo.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Lt.RightClick?!1:(r?.({event:n}),!0)}}];const Ot={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class xo extends Wt{constructor(t){super(t,Ot)}static setup(){return window.addEventListener(Ot.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ot.move.name,t)};function t(){}}}xo.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 He;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(He||(He={}));var ft;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(ft||(ft={}));function yo(e){let{acceleration:t,activator:n=He.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:a=ft.TreeOrder,pointerCoordinates:f,scrollableAncestors:d,scrollableAncestorRects:h,delta:v,threshold:b}=e;const u=So({delta:v,disabled:!s}),[x,m]=Or(),y=c.useRef({x:0,y:0}),w=c.useRef({x:0,y:0}),E=c.useMemo(()=>{switch(n){case He.Pointer:return f?{top:f.y,bottom:f.y,left:f.x,right:f.x}:null;case He.DraggableRect:return o}},[n,o,f]),D=c.useRef(null),_=c.useCallback(()=>{const C=D.current;if(!C)return;const R=y.current.x*w.current.x,O=y.current.y*w.current.y;C.scrollBy(R,O)},[]),j=c.useMemo(()=>a===ft.TreeOrder?[...d].reverse():d,[a,d]);c.useEffect(()=>{if(!s||!d.length||!E){m();return}for(const C of j){if(r?.(C)===!1)continue;const R=d.indexOf(C),O=h[R];if(!O)continue;const{direction:L,speed:z}=io(C,O,E,t,b);for(const N of["x","y"])u[N][L[N]]||(z[N]=0,L[N]=0);if(z.x>0||z.y>0){m(),D.current=C,x(_,i),y.current=z,w.current=L;return}}y.current={x:0,y:0},w.current={x:0,y:0},m()},[t,_,r,m,s,i,JSON.stringify(E),JSON.stringify(u),x,d,j,h,JSON.stringify(b)])}const wo={x:{[V.Backward]:!1,[V.Forward]:!1},y:{[V.Backward]:!1,[V.Forward]:!1}};function So(e){let{delta:t,disabled:n}=e;const r=At(t);return Je(o=>{if(n||!r||!o)return wo;const s={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[V.Backward]:o.x[V.Backward]||s.x===-1,[V.Forward]:o.x[V.Forward]||s.x===1},y:{[V.Backward]:o.y[V.Backward]||s.y===-1,[V.Forward]:o.y[V.Forward]||s.y===1}}},[n,t,r])}function Co(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Je(o=>{var s;return t==null?null:(s=r??o)!=null?s:null},[r,t])}function Ro(e,t){return c.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,s=o.activators.map(i=>({eventName:i.eventName,handler:t(i.handler,r)}));return[...n,...s]},[]),[e,t])}var Ye;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Ye||(Ye={}));var Pt;(function(e){e.Optimized="optimized"})(Pt||(Pt={}));const xn=new Map;function Eo(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=c.useState(null),{frequency:a,measure:f,strategy:d}=o,h=c.useRef(e),v=y(),b=Ue(v),u=c.useCallback(function(w){w===void 0&&(w=[]),!b.current&&i(E=>E===null?w:E.concat(w.filter(D=>!E.includes(D))))},[b]),x=c.useRef(null),m=Je(w=>{if(v&&!n)return xn;if(!w||w===xn||h.current!==e||s!=null){const E=new Map;for(let D of e){if(!D)continue;if(s&&s.length>0&&!s.includes(D.id)&&D.rect.current){E.set(D.id,D.rect.current);continue}const _=D.node.current,j=_?new Ht(f(_),_):null;D.rect.current=j,j&&E.set(D.id,j)}return E}return w},[e,s,n,v,f]);return c.useEffect(()=>{h.current=e},[e]),c.useEffect(()=>{v||u()},[n,v]),c.useEffect(()=>{s&&s.length>0&&i(null)},[JSON.stringify(s)]),c.useEffect(()=>{v||typeof a!="number"||x.current!==null||(x.current=setTimeout(()=>{u(),x.current=null},a))},[a,v,u,...r]),{droppableRects:m,measureDroppableContainers:u,measuringScheduled:s!=null};function y(){switch(d){case Ye.Always:return!1;case Ye.BeforeDragging:return n;default:return!n}}}function Hn(e,t){return Je(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Do(e,t){return Hn(e,t)}function To(e){let{callback:t,disabled:n}=e;const r=Vt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function vt(e){let{callback:t,disabled:n}=e;const r=Vt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function _o(e){return new Ht(Ae(e),e)}function yn(e,t,n){t===void 0&&(t=_o);const[r,o]=c.useState(null);function s(){o(f=>{if(!e)return null;if(e.isConnected===!1){var d;return(d=f??n)!=null?d:null}const h=t(e);return JSON.stringify(f)===JSON.stringify(h)?f:h})}const i=To({callback(f){if(e)for(const d of f){const{type:h,target:v}=d;if(h==="childList"&&v instanceof HTMLElement&&v.contains(e)){s();break}}}}),a=vt({callback:s});return le(()=>{s(),e?(a?.observe(e),i?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),i?.disconnect())},[e]),r}function Oo(e){const t=Hn(e);return Mn(e,t)}const wn=[];function jo(e){const t=c.useRef(e),n=Je(r=>e?r&&r!==wn&&e&&t.current&&e.parentNode===t.current.parentNode?r:Ft(e):wn,[e]);return c.useEffect(()=>{t.current=e},[e]),n}function ko(e){const[t,n]=c.useState(null),r=c.useRef(e),o=c.useCallback(s=>{const i=Tt(s.target);i&&n(a=>a?(a.set(i,Nt(i)),new Map(a)):null)},[]);return c.useEffect(()=>{const s=r.current;if(e!==s){i(s);const a=e.map(f=>{const d=Tt(f);return d?(d.addEventListener("scroll",o,{passive:!0}),[d,Nt(d)]):null}).filter(f=>f!=null);n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(s)};function i(a){a.forEach(f=>{const d=Tt(f);d?.removeEventListener("scroll",o)})}},[o,e]),c.useMemo(()=>e.length?t?Array.from(t.values()).reduce((s,i)=>Oe(s,i),oe):Vn(e):oe,[e,t])}function Sn(e,t){t===void 0&&(t=[]);const n=c.useRef(null);return c.useEffect(()=>{n.current=null},t),c.useEffect(()=>{const r=e!==oe;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ut(e,n.current):oe}function Io(e){c.useEffect(()=>{if(!ht)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 Ao(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:s}=r;return n[o]=i=>{s(i,t)},n},{}),[e,t])}function Wn(e){return c.useMemo(()=>e?no(e):null,[e])}const Cn=[];function Mo(e,t){t===void 0&&(t=Ae);const[n]=e,r=Wn(n?q(n):null),[o,s]=c.useState(Cn);function i(){s(()=>e.length?e.map(f=>zn(f)?r:new Ht(t(f),f)):Cn)}const a=vt({callback:i});return le(()=>{a?.disconnect(),i(),e.forEach(f=>a?.observe(f))},[e]),o}function No(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Xe(t)?t:e}function Lo(e){let{measure:t}=e;const[n,r]=c.useState(null),o=c.useCallback(d=>{for(const{target:h}of d)if(Xe(h)){r(v=>{const b=t(h);return v?{...v,width:b.width,height:b.height}:b});break}},[t]),s=vt({callback:o}),i=c.useCallback(d=>{const h=No(d);s?.disconnect(),h&&s?.observe(h),r(h?t(h):null)},[t,s]),[a,f]=lt(i);return c.useMemo(()=>({nodeRef:a,rect:n,setRef:f}),[n,a,f])}const Po=[{sensor:Ut,options:{}},{sensor:Fn,options:{}}],zo={current:{}},at={draggable:{measure:gn},droppable:{measure:gn,strategy:Ye.WhileDragging,frequency:Pt.Optimized},dragOverlay:{measure:Ae}};class We 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 $o={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new We,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:dt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:at,measureDroppableContainers:dt,windowRect:null,measuringScheduled:!1},Vo={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:dt,draggableNodes:new Map,over:null,measureDroppableContainers:dt},gt=c.createContext(Vo),Un=c.createContext($o);function Bo(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new We}}}function Fo(e,t){switch(t.type){case $.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case $.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 $.DragEnd:case $.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case $.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new We(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case $.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new We(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case $.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new We(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function Ho(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=c.useContext(gt),s=At(r),i=At(n?.id);return c.useEffect(()=>{if(!t&&!r&&s&&i!=null){if(!Bt(s)||document.activeElement===s.target)return;const a=o.get(i);if(!a)return;const{activatorNode:f,node:d}=a;if(!f.current&&!d.current)return;requestAnimationFrame(()=>{for(const h of[f.current,d.current]){if(!h)continue;const v=Ir(h);if(v){v.focus();break}}})}},[r,t,o,i,s]),null}function Wo(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,s)=>s({transform:o,...r}),n):n}function Uo(e){return c.useMemo(()=>({draggable:{...at.draggable,...e?.draggable},droppable:{...at.droppable,...e?.droppable},dragOverlay:{...at.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Yo(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=c.useRef(!1),{x:i,y:a}=typeof o=="boolean"?{x:o,y:o}:o;le(()=>{if(!i&&!a||!t){s.current=!1;return}if(s.current||!r)return;const d=t?.node.current;if(!d||d.isConnected===!1)return;const h=n(d),v=Mn(h,r);if(i||(v.x=0),a||(v.y=0),s.current=!0,Math.abs(v.x)>0||Math.abs(v.y)>0){const b=Nn(d);b&&b.scrollBy({top:v.y,left:v.x})}},[t,i,a,r,n])}const Yn=c.createContext({...oe,scaleX:1,scaleY:1});var ye;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ye||(ye={}));const Gn=c.memo(function(t){var n,r,o,s;let{id:i,accessibility:a,autoScroll:f=!0,children:d,sensors:h=Po,collisionDetection:v=Xr,measuring:b,modifiers:u,...x}=t;const m=c.useReducer(Fo,void 0,Bo),[y,w]=m,[E,D]=zr(),[_,j]=c.useState(ye.Uninitialized),C=_===ye.Initialized,{draggable:{active:R,nodes:O,translate:L},droppable:{containers:z}}=y,N=R!=null?O.get(R):null,U=c.useRef({initial:null,translated:null}),G=c.useMemo(()=>{var W;return R!=null?{id:R,data:(W=N?.data)!=null?W:zo,rect:U}:null},[R,N]),ee=c.useRef(null),[ue,we]=c.useState(null),[F,Se]=c.useState(null),te=Ue(x,Object.values(x)),ve=Ke("DndDescribedBy",i),p=c.useMemo(()=>z.getEnabled(),[z]),S=Uo(b),{droppableRects:k,measureDroppableContainers:M,measuringScheduled:se}=Eo(p,{dragging:C,dependencies:[L.x,L.y],config:S.droppable}),H=Co(O,R),P=c.useMemo(()=>F?Mt(F):null,[F]),Y=fr(),X=Do(H,S.draggable.measure);Yo({activeNode:R!=null?O.get(R):null,config:Y.layoutShiftCompensation,initialRect:X,measure:S.draggable.measure});const A=yn(H,S.draggable.measure,X),Me=yn(H?H.parentElement:null),ie=c.useRef({activatorEvent:null,active:null,activeNode:H,collisionRect:null,collisions:null,droppableRects:k,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:z,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ce=z.getNodeFor((n=ie.current.over)==null?void 0:n.id),de=Lo({measure:S.dragOverlay.measure}),Re=(r=de.nodeRef.current)!=null?r:H,Ee=C?(o=de.rect)!=null?o:A:null,Gt=!!(de.nodeRef.current&&de.rect),qt=Oo(Gt?null:A),mt=Wn(Re?q(Re):null),ge=jo(C?Ce??H:null),Ze=Mo(ge),Qe=Wo(u,{transform:{x:L.x-qt.x,y:L.y-qt.y,scaleX:1,scaleY:1},activatorEvent:F,active:G,activeNodeRect:A,containerNodeRect:Me,draggingNodeRect:Ee,over:ie.current.over,overlayNodeRect:de.rect,scrollableAncestors:ge,scrollableAncestorRects:Ze,windowRect:mt}),Xt=P?Oe(P,L):null,Jt=ko(ge),sr=Sn(Jt),ir=Sn(Jt,[A]),De=Oe(Qe,sr),Te=Ee?Zr(Ee,Qe):null,Ne=G&&Te?v({active:G,collisionRect:Te,droppableRects:k,droppableContainers:p,pointerCoordinates:Xt}):null,Kt=Gr(Ne,"id"),[pe,Zt]=c.useState(null),ar=Gt?Qe:Oe(Qe,ir),cr=Jr(ar,(s=pe?.rect)!=null?s:null,A),xt=c.useRef(null),Qt=c.useCallback((W,J)=>{let{sensor:K,options:be}=J;if(ee.current==null)return;const ne=O.get(ee.current);if(!ne)return;const Z=W.nativeEvent,ae=new K({active:ee.current,activeNode:ne,event:Z,options:be,context:ie,onAbort(B){if(!O.get(B))return;const{onDragAbort:ce}=te.current,fe={id:B};ce?.(fe),E({type:"onDragAbort",event:fe})},onPending(B,me,ce,fe){if(!O.get(B))return;const{onDragPending:Pe}=te.current,xe={id:B,constraint:me,initialCoordinates:ce,offset:fe};Pe?.(xe),E({type:"onDragPending",event:xe})},onStart(B){const me=ee.current;if(me==null)return;const ce=O.get(me);if(!ce)return;const{onDragStart:fe}=te.current,Le={activatorEvent:Z,active:{id:me,data:ce.data,rect:U}};Be.unstable_batchedUpdates(()=>{fe?.(Le),j(ye.Initializing),w({type:$.DragStart,initialCoordinates:B,active:me}),E({type:"onDragStart",event:Le}),we(xt.current),Se(Z)})},onMove(B){w({type:$.DragMove,coordinates:B})},onEnd:_e($.DragEnd),onCancel:_e($.DragCancel)});xt.current=ae;function _e(B){return async function(){const{active:ce,collisions:fe,over:Le,scrollAdjustedTranslate:Pe}=ie.current;let xe=null;if(ce&&Pe){const{cancelDrop:ze}=te.current;xe={activatorEvent:Z,active:ce,collisions:fe,delta:Pe,over:Le},B===$.DragEnd&&typeof ze=="function"&&await Promise.resolve(ze(xe))&&(B=$.DragCancel)}ee.current=null,Be.unstable_batchedUpdates(()=>{w({type:B}),j(ye.Uninitialized),Zt(null),we(null),Se(null),xt.current=null;const ze=B===$.DragEnd?"onDragEnd":"onDragCancel";if(xe){const yt=te.current[ze];yt?.(xe),E({type:ze,event:xe})}})}}},[O]),lr=c.useCallback((W,J)=>(K,be)=>{const ne=K.nativeEvent,Z=O.get(be);if(ee.current!==null||!Z||ne.dndKit||ne.defaultPrevented)return;const ae={active:Z};W(K,J.options,ae)===!0&&(ne.dndKit={capturedBy:J.sensor},ee.current=be,Qt(K,J))},[O,Qt]),en=Ro(h,lr);Io(h),le(()=>{A&&_===ye.Initializing&&j(ye.Initialized)},[A,_]),c.useEffect(()=>{const{onDragMove:W}=te.current,{active:J,activatorEvent:K,collisions:be,over:ne}=ie.current;if(!J||!K)return;const Z={active:J,activatorEvent:K,collisions:be,delta:{x:De.x,y:De.y},over:ne};Be.unstable_batchedUpdates(()=>{W?.(Z),E({type:"onDragMove",event:Z})})},[De.x,De.y]),c.useEffect(()=>{const{active:W,activatorEvent:J,collisions:K,droppableContainers:be,scrollAdjustedTranslate:ne}=ie.current;if(!W||ee.current==null||!J||!ne)return;const{onDragOver:Z}=te.current,ae=be.get(Kt),_e=ae&&ae.rect.current?{id:ae.id,rect:ae.rect.current,data:ae.data,disabled:ae.disabled}:null,B={active:W,activatorEvent:J,collisions:K,delta:{x:ne.x,y:ne.y},over:_e};Be.unstable_batchedUpdates(()=>{Zt(_e),Z?.(B),E({type:"onDragOver",event:B})})},[Kt]),le(()=>{ie.current={activatorEvent:F,active:G,activeNode:H,collisionRect:Te,collisions:Ne,droppableRects:k,draggableNodes:O,draggingNode:Re,draggingNodeRect:Ee,droppableContainers:z,over:pe,scrollableAncestors:ge,scrollAdjustedTranslate:De},U.current={initial:Ee,translated:Te}},[G,H,Ne,Te,O,Re,Ee,k,z,pe,ge,De]),yo({...Y,delta:L,draggingRect:Te,pointerCoordinates:Xt,scrollableAncestors:ge,scrollableAncestorRects:Ze});const ur=c.useMemo(()=>({active:G,activeNode:H,activeNodeRect:A,activatorEvent:F,collisions:Ne,containerNodeRect:Me,dragOverlay:de,draggableNodes:O,droppableContainers:z,droppableRects:k,over:pe,measureDroppableContainers:M,scrollableAncestors:ge,scrollableAncestorRects:Ze,measuringConfiguration:S,measuringScheduled:se,windowRect:mt}),[G,H,A,F,Ne,Me,de,O,z,k,pe,M,ge,Ze,S,se,mt]),dr=c.useMemo(()=>({activatorEvent:F,activators:en,active:G,activeNodeRect:A,ariaDescribedById:{draggable:ve},dispatch:w,draggableNodes:O,over:pe,measureDroppableContainers:M}),[F,en,G,A,w,ve,O,pe,M]);return c.createElement(In.Provider,{value:D},c.createElement(gt.Provider,{value:dr},c.createElement(Un.Provider,{value:ur},c.createElement(Yn.Provider,{value:cr},d)),c.createElement(Ho,{disabled:a?.restoreFocus===!1})),c.createElement(Br,{...a,hiddenTextDescribedById:ve}));function fr(){const W=ue?.autoScrollEnabled===!1,J=typeof f=="object"?f.enabled===!1:f===!1,K=C&&!W&&!J;return typeof f=="object"?{...f,enabled:K}:{enabled:K}}}),Go=c.createContext(null),Rn="button",qo="Draggable";function Xo(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=Ke(qo),{activators:i,activatorEvent:a,active:f,activeNodeRect:d,ariaDescribedById:h,draggableNodes:v,over:b}=c.useContext(gt),{role:u=Rn,roleDescription:x="draggable",tabIndex:m=0}=o??{},y=f?.id===t,w=c.useContext(y?Yn:Go),[E,D]=lt(),[_,j]=lt(),C=Ao(i,t),R=Ue(n);le(()=>(v.set(t,{id:t,key:s,node:E,activatorNode:_,data:R}),()=>{const L=v.get(t);L&&L.key===s&&v.delete(t)}),[v,t]);const O=c.useMemo(()=>({role:u,tabIndex:m,"aria-disabled":r,"aria-pressed":y&&u===Rn?!0:void 0,"aria-roledescription":x,"aria-describedby":h.draggable}),[r,u,m,y,x,h.draggable]);return{active:f,activatorEvent:a,activeNodeRect:d,attributes:O,isDragging:y,listeners:r?void 0:C,node:E,over:b,setNodeRef:D,setActivatorNodeRef:j,transform:w}}function Jo(){return c.useContext(Un)}const Ko="Droppable",Zo={timeout:25};function Qo(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=Ke(Ko),{active:i,dispatch:a,over:f,measureDroppableContainers:d}=c.useContext(gt),h=c.useRef({disabled:n}),v=c.useRef(!1),b=c.useRef(null),u=c.useRef(null),{disabled:x,updateMeasurementsFor:m,timeout:y}={...Zo,...o},w=Ue(m??r),E=c.useCallback(()=>{if(!v.current){v.current=!0;return}u.current!=null&&clearTimeout(u.current),u.current=setTimeout(()=>{d(Array.isArray(w.current)?w.current:[w.current]),u.current=null},y)},[y]),D=vt({callback:E,disabled:x||!i}),_=c.useCallback((O,L)=>{D&&(L&&(D.unobserve(L),v.current=!1),O&&D.observe(O))},[D]),[j,C]=lt(_),R=Ue(t);return c.useEffect(()=>{!D||!j.current||(D.disconnect(),v.current=!1,D.observe(j.current))},[j,D]),c.useEffect(()=>(a({type:$.RegisterDroppable,element:{id:r,key:s,disabled:n,node:j,rect:b,data:R}}),()=>a({type:$.UnregisterDroppable,key:s,id:r})),[r]),c.useEffect(()=>{n!==h.current.disabled&&(a({type:$.SetDroppableDisabled,id:r,key:s,disabled:n}),h.current.disabled=n)},[r,s,n,a]),{active:i,rect:b,isOver:f?.id===r,node:j,over:f,setNodeRef:C}}function pt(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function es(e,t){return e.reduce((n,r,o)=>{const s=t.get(r);return s&&(n[o]=s),n},Array(e.length))}function ot(e){return e!==null&&e>=0}function ts(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 ns(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const st={scaleX:1,scaleY:1},rs=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:s,index:i}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const f=os(n,i,o);if(i===o){const d=n[s];return d?{x:o<s?d.left+d.width-(a.left+a.width):d.left-a.left,y:0,...st}:null}return i>o&&i<=s?{x:-a.width-f,y:0,...st}:i<o&&i>=s?{x:a.width+f,y:0,...st}:{x:0,y:0,...st}};function os(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return!r||!o&&!s?0:n<t?o?r.left-(o.left+o.width):s.left-(r.left+r.width):s?s.left-(r.left+r.width):r.left-(o.left+o.width)}const qn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=pt(t,r,n),i=t[o],a=s[o];return!a||!i?null:{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}},it={scaleX:1,scaleY:1},ss=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const a=(t=s[n])!=null?t:r;if(!a)return null;if(o===n){const d=s[i];return d?{x:0,y:n<i?d.top+d.height-(a.top+a.height):d.top-a.top,...it}:null}const f=is(s,o,n);return o>n&&o<=i?{x:0,y:-a.height-f,...it}:o<n&&o>=i?{x:0,y:a.height+f,...it}:{x:0,y:0,...it}};function is(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];return r?n<t?o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0:s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const Xn="Sortable",Jn=c.createContext({activeIndex:-1,containerId:Xn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:qn,disabled:{draggable:!1,droppable:!1}});function Kn(e){let{children:t,id:n,items:r,strategy:o=qn,disabled:s=!1}=e;const{active:i,dragOverlay:a,droppableRects:f,over:d,measureDroppableContainers:h}=Jo(),v=Ke(Xn,n),b=a.rect!==null,u=c.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=i!=null,m=i?u.indexOf(i.id):-1,y=d?u.indexOf(d.id):-1,w=c.useRef(u),E=!ts(u,w.current),D=y!==-1&&m===-1||E,_=ns(s);le(()=>{E&&x&&h(u)},[E,u,x,h]),c.useEffect(()=>{w.current=u},[u]);const j=c.useMemo(()=>({activeIndex:m,containerId:v,disabled:_,disableTransforms:D,items:u,overIndex:y,useDragOverlay:b,sortedRects:es(u,f),strategy:o}),[m,v,_.draggable,_.droppable,D,u,y,f,b,o]);return c.createElement(Jn.Provider,{value:j},t)}const as=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return pt(n,r,o).indexOf(t)},cs=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:f,transition:d}=e;return!d||!r||a!==s&&o===i?!1:n?!0:i!==o&&t===f},ls={duration:200,easing:"ease"},Zn="transform",us=je.Transition.toString({property:Zn,duration:0,easing:"linear"}),ds={roleDescription:"sortable"};function fs(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=c.useState(null),a=c.useRef(n);return le(()=>{if(!t&&n!==a.current&&r.current){const f=o.current;if(f){const d=Ae(r.current,{ignoreTransform:!0}),h={x:f.left-d.left,y:f.top-d.top,scaleX:f.width/d.width,scaleY:f.height/d.height};(h.x||h.y)&&i(h)}}n!==a.current&&(a.current=n)},[t,n,r,o]),c.useEffect(()=>{s&&i(null)},[s]),s}function Qn(e){let{animateLayoutChanges:t=cs,attributes:n,disabled:r,data:o,getNewIndex:s=as,id:i,strategy:a,resizeObserverConfig:f,transition:d=ls}=e;const{items:h,containerId:v,activeIndex:b,disabled:u,disableTransforms:x,sortedRects:m,overIndex:y,useDragOverlay:w,strategy:E}=c.useContext(Jn),D=hs(r,u),_=h.indexOf(i),j=c.useMemo(()=>({sortable:{containerId:v,index:_,items:h},...o}),[v,o,_,h]),C=c.useMemo(()=>h.slice(h.indexOf(i)),[h,i]),{rect:R,node:O,isOver:L,setNodeRef:z}=Qo({id:i,data:j,disabled:D.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...f}}),{active:N,activatorEvent:U,activeNodeRect:G,attributes:ee,setNodeRef:ue,listeners:we,isDragging:F,over:Se,setActivatorNodeRef:te,transform:ve}=Xo({id:i,data:j,attributes:{...ds,...n},disabled:D.draggable}),p=_r(z,ue),S=!!N,k=S&&!x&&ot(b)&&ot(y),M=!w&&F,se=M&&k?ve:null,P=k?se??(a??E)({rects:m,activeNodeRect:G,activeIndex:b,overIndex:y,index:_}):null,Y=ot(b)&&ot(y)?s({id:i,items:h,activeIndex:b,overIndex:y}):_,X=N?.id,A=c.useRef({activeId:X,items:h,newIndex:Y,containerId:v}),Me=h!==A.current.items,ie=t({active:N,containerId:v,isDragging:F,isSorting:S,id:i,index:_,items:h,newIndex:A.current.newIndex,previousItems:A.current.items,previousContainerId:A.current.containerId,transition:d,wasDragging:A.current.activeId!=null}),Ce=fs({disabled:!ie,index:_,node:O,rect:R});return c.useEffect(()=>{S&&A.current.newIndex!==Y&&(A.current.newIndex=Y),v!==A.current.containerId&&(A.current.containerId=v),h!==A.current.items&&(A.current.items=h)},[S,Y,v,h]),c.useEffect(()=>{if(X===A.current.activeId)return;if(X!=null&&A.current.activeId==null){A.current.activeId=X;return}const Re=setTimeout(()=>{A.current.activeId=X},50);return()=>clearTimeout(Re)},[X]),{active:N,activeIndex:b,attributes:ee,data:j,rect:R,index:_,newIndex:Y,items:h,isOver:L,isSorting:S,isDragging:F,listeners:we,node:O,overIndex:y,over:Se,setNodeRef:p,setActivatorNodeRef:te,setDroppableNodeRef:z,setDraggableNodeRef:ue,transform:Ce??P,transition:de()};function de(){if(Ce||Me&&A.current.newIndex===_)return us;if(!(M&&!Bt(U)||!d)&&(S||ie))return je.Transition.toString({...d,property:Zn})}}function hs(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}}I.Down,I.Right,I.Up,I.Left;const vs=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),gs=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),En=e=>{const t=gs(e);return t.charAt(0).toUpperCase()+t.slice(1)},er=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),ps=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var bs={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ms=c.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},f)=>c.createElement("svg",{ref:f,...bs,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:er("lucide",o),...!s&&!ps(a)&&{"aria-hidden":"true"},...a},[...i.map(([d,h])=>c.createElement(d,h)),...Array.isArray(s)?s:[s]]));const Q=(e,t)=>{const n=c.forwardRef(({className:r,...o},s)=>c.createElement(ms,{ref:s,iconNode:t,className:er(`lucide-${vs(En(e))}`,`lucide-${e}`,r),...o}));return n.displayName=En(e),n};const xs=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],ys=Q("arrow-down",xs);const ws=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ss=Q("arrow-up-down",ws);const Cs=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Rs=Q("arrow-up",Cs);const Es=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Ds=Q("bookmark",Es);const Ts=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],_s=Q("chevron-left",Ts);const Os=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],js=Q("chevron-right",Os);const ks=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Is=Q("columns-2",ks);const As=[["path",{d:"M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",key:"1yo7s0"}],["path",{d:"m12 9 6 6",key:"anjzzh"}],["path",{d:"m18 9-6 6",key:"1fp51s"}]],Ms=Q("delete",As);const Ns=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],Ls=Q("ellipsis",Ns);const Ps=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],zs=Q("funnel",Ps);const $s=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Vs=Q("grip-vertical",$s);const Bs=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],Fs=Q("pen",Bs);const Hs=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ws=Q("settings",Hs);function T(e){return c.forwardRef((t,n)=>{const{children:r,...o}=t;return l.jsx(e,{ref:n,...o,children:r})})}const he=new On({sortColumn:null,sortDirection:"asc",visibility:{},columnOrder:[],data:[],sortableColumns:[]});function tr(e,t){const n=e[0]??{},o=(t&&t.length?t:Object.keys(n).map(s=>({id:s,label:s}))).filter(s=>n.hasOwnProperty(s.id));he.setState(s=>({...s,data:e,columnOrder:o,visibility:o.reduce((i,a)=>({...i,[a.id]:!0}),{}),sortableColumns:o.map(i=>({id:i.id,label:i.label,sortable:!0}))}))}const Us=T(g.Menu.Trigger),Ys=T(g.Menu.Positioner),Gs=T(g.Menu.Content),qs=T(g.Menu.Item),Xs=T(g.Checkbox.Label),Js=T(g.Checkbox.HiddenInput),Ks=T(g.Checkbox.Control);function Zs({visibility:e,onToggle:t}){const{sortableColumns:n}=qe(he);return l.jsxs(g.Menu.Root,{closeOnSelect:!1,children:[l.jsx(Us,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Toggle columns",variant:"outline",size:"sm",ml:"1",children:l.jsx(Is,{size:18})})}),l.jsx(g.Portal,{children:l.jsx(Ys,{children:l.jsx(Gs,{minW:"220px",children:n.map(r=>{const o=!!e[r.id];return l.jsx(qs,{value:r.id,closeOnSelect:!1,children:l.jsxs(g.Checkbox.Root,{checked:o,onCheckedChange:()=>t(r.id),children:[l.jsx(Js,{}),l.jsx(Ks,{}),l.jsx(Xs,{children:r.label})]})},r.id)})})})})]})}const Qs=e=>{he.setState(t=>({...t,columnOrder:e}))},ei=e=>{he.setState(t=>({...t,visibility:{...t.visibility,[e]:!t.visibility[e]}}))};function ti(e){he.setState(t=>t.sortColumn===e?{...t,sortDirection:t.sortDirection==="asc"?"desc":"asc"}:{...t,sortColumn:e,sortDirection:"asc"})}function ni({id:e,children:t,onClick:n,cursor:r,borderRight:o,borderRightColor:s}){const{setNodeRef:i,attributes:a,listeners:f,transform:d,transition:h}=Qn({id:e});return l.jsx(g.Table.ColumnHeader,{ref:i,onClick:n,w:e==="id"?"80px":void 0,style:{transform:je.Transform.toString(d),transition:h,cursor:r,borderRight:o,borderRightColor:s},...a,children:l.jsxs(g.HStack,{justify:"space-between",children:[t,l.jsx("span",{...f,children:l.jsx(Vs,{size:12})})]})})}function ri(){const{columnOrder:e,visibility:t,sortColumn:n,sortDirection:r,sortableColumns:o}=qe(he),s=e.map(a=>o.find(f=>f.id===a.id)).filter(a=>a!==void 0).filter(a=>t[a.id]),i=a=>{const{active:f,over:d}=a;if(!d||f.id===d.id)return;const h=e.findIndex(u=>u.id===f.id),v=e.findIndex(u=>u.id===d.id),b=pt(e,h,v);Qs(b)};return l.jsx(g.Table.Header,{background:"gray.100",position:"sticky",top:0,p:"0",children:l.jsx(Gn,{collisionDetection:An,onDragEnd:i,children:l.jsx(Kn,{items:e.map(a=>a.id),strategy:rs,children:l.jsxs(g.Table.Row,{height:"28px",children:[s.map((a,f)=>{const d=n===a?.id;return l.jsx(ni,{id:a?.id,onClick:()=>a?.sortable&&ti(a?.id),cursor:a?.sortable?"pointer":"default",borderRight:"2px solid #dcdcdc",children:l.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,userSelect:"none"},children:[a?.label,a?.sortable&&(d?r==="asc"?l.jsx(Rs,{size:14}):l.jsx(ys,{size:14}):l.jsx(Ss,{size:14,opacity:.4}))]})},a?.id)}),l.jsx(g.Table.ColumnHeader,{borderRight:"2px solid #dcdcdc",children:"Actions"}),l.jsx(g.Table.ColumnHeader,{boxSize:"0.5",children:l.jsx(Zs,{visibility:t,onToggle:ei})})]})})})})}const Dn=g.createListCollection({items:[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}]}),oi=T(g.Select.Positioner),si=T(g.Select.Content),ii=T(g.Select.Item),ai=T(g.Pagination.PrevTrigger),ci=T(g.Pagination.NextTrigger),li=T(g.Select.HiddenSelect),ui=T(g.Select.Control),di=T(g.Select.Trigger),fi=T(g.Select.ValueText),hi=T(g.Select.IndicatorGroup),vi=T(g.Select.Indicator);function gi({totalCount:e,pageSize:t,currentPage:n,onPageChange:r,onPageSizeChange:o,siblingCount:s=2}){return l.jsx(g.Box,{width:"100%",children:l.jsxs(g.HStack,{justify:"space-between",mx:"auto",flexWrap:"wrap",children:[l.jsxs(g.HStack,{children:[l.jsx(g.Text,{fontSize:"sm",color:"gray.600",_dark:{color:"gray.400"},children:"Rows per page:"}),l.jsxs(g.Select.Root,{collection:Dn,size:"sm",width:"60px",onValueChange:i=>o&&o(Number(i.items[0].value)),value:[String(t)],children:[l.jsx(li,{}),l.jsxs(ui,{children:[l.jsx(di,{children:l.jsx(fi,{placeholder:""})}),l.jsx(hi,{children:l.jsx(vi,{})})]}),l.jsx(g.Portal,{children:l.jsx(oi,{children:l.jsx(si,{children:Dn.items.map(i=>l.jsxs(ii,{item:i.value,children:[i.label,l.jsx(g.Select.ItemIndicator,{})]},i.value))})})})]})]}),l.jsx(g.Pagination.Root,{count:e,pageSize:t,page:n,siblingCount:s,onPageChange:i=>r&&r(i.page),children:l.jsxs(g.ButtonGroup,{size:"sm",variant:"ghost",children:[l.jsx(ai,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Previous page",children:l.jsx(_s,{size:18})})}),l.jsx(g.Pagination.Items,{render:i=>l.jsx(g.IconButton,{variant:i.type==="page"&&i.value===n?"outline":"ghost","aria-current":i.type==="page"&&i.value===n?"page":void 0,children:i.type==="page"?i.value:"…"},i.value??i.type)}),l.jsx(ci,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Next page",children:l.jsx(js,{size:18})})})]})})]})})}const pi=T(g.Menu.Item),bi=T(g.Menu.Content),mi=T(g.Menu.Positioner),xi=T(g.Menu.Trigger);function yi({data:e=[],actions:t=[]}){const{columnOrder:n,visibility:r}=qe(he);return l.jsx(g.Table.Body,{children:e.map(o=>l.jsxs(g.Table.Row,{children:[n.filter(s=>r[s.id]).map(s=>l.jsx(g.Table.Cell,{children:o[s.id]},s.id)),l.jsx(g.Table.Cell,{textAlign:"center",display:"flex",gap:2,children:l.jsxs(g.Menu.Root,{children:[l.jsx(xi,{asChild:!0,children:l.jsx(g.IconButton,{"aria-label":"Open",variant:"ghost",size:"sm",children:l.jsx(Ls,{size:16})})}),l.jsx(g.Portal,{children:l.jsx(mi,{children:l.jsx(bi,{children:t.map(s=>l.jsxs(pi,{onClick:()=>s.onClick(o),colorScheme:s.colorScheme,value:s.label,children:[s.icon,s.label]},s.label))})})})]})})]},o.id))})}function wi({data:e=[],headers:t=[],loading:n=!1,emptyMessage:r="No data",actions:o,page:s=1,pageSize:i=10,onPageChange:a,onPageSizeChange:f,density:d="sm"}){c.useEffect(()=>{tr(e,t)},[e]);const{sortColumn:h,sortDirection:v,data:b}=qe(he),u=c.useMemo(()=>{const x=[...b];h&&x.sort((y,w)=>v==="asc"?String(y[h]).localeCompare(String(w[h])):String(w[h]).localeCompare(String(y[h])));const m=(s-1)*i;return x.slice(m,m+i)},[s,i,h,v,b]);return l.jsxs(g.Box,{h:"100%",display:"flex",flexDirection:"column",p:2,pt:2,minHeight:0,children:[l.jsx(g.Box,{flex:"1",minHeight:0,overflow:"auto",children:n?l.jsx(g.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:"Loading..."}):u.length===0?l.jsx(g.Box,{display:"flex",alignItems:"center",justifyContent:"center",h:"100%",color:"gray.500",children:r}):l.jsxs(g.Table.Root,{variant:"outline",w:"100%",size:d,children:[l.jsx(ri,{}),l.jsx(yi,{data:u,actions:o})]})}),l.jsx(g.Box,{mt:.5,children:l.jsx(gi,{totalCount:e.length,pageSize:i,currentPage:s,onPageChange:a,onPageSizeChange:x=>{f&&f(x),s>1&&a&&a(1)}})})]})}const nr=e=>`FILTER_PRESETS_${e??"default"}`;function Si(e){try{return JSON.parse(localStorage.getItem(nr(e))||"[]")}catch{return[]}}const Ge=new On({}),bt=e=>{const t=Ge.state[e];if(t)return t;const n=Si(e);return Ge.setState(r=>({...r,[e]:n})),n},Yt=(e,t)=>{Ge.setState(n=>({...n,[e]:t})),localStorage.setItem(nr(e),JSON.stringify(t))},rr=(e,t)=>{const n=bt(e).filter(r=>r.id!==t);Yt(e,n)},or=(e,t)=>{const n=[t,...bt(e)];Yt(e,n)},Ci=T(g.Checkbox.Root),Ri=T(g.Checkbox.HiddenInput),Ei=T(g.Checkbox.Control),Di=T(g.Slider.Root),Ti=T(g.Slider.Track),_i=T(g.Slider.Range),Oi=T(g.Slider.Thumbs),ji=T(g.Slider.Control),ki=({filter:e,onVisibilityChange:t,onSizeChange:n})=>{const{attributes:r,listeners:o,setNodeRef:s,transform:i,transition:a}=Qn({id:e.id}),f={transform:je.Transform.toString(i),transition:a,cursor:"grab"};return l.jsxs(g.VStack,{ref:s,style:f,align:"stretch",border:"1px solid",borderColor:"gray.200",rounded:"md",p:3,mb:3,...r,...o,children:[l.jsx(g.Text,{fontWeight:"bold",children:e.label}),l.jsxs(g.HStack,{justify:"space-between",children:[l.jsx(g.Text,{fontSize:"sm",children:"Visible"}),l.jsxs(Ci,{checked:e.visible,onCheckedChange:d=>t&&t(e.id,!!d),size:"sm",children:[l.jsx(Ri,{}),l.jsx(Ei,{})]})]}),l.jsxs(g.VStack,{align:"stretch",gap:1,children:[l.jsx(g.Text,{fontSize:"sm",children:"Size"}),l.jsx(Di,{width:"200px",min:1,max:5,step:.5,value:[e.size??1],onChange:d=>n&&n(e.id,d[0]),children:l.jsxs(ji,{children:[l.jsx(Ti,{children:l.jsx(_i,{})}),l.jsx(Oi,{})]})})]})]})},Ii=T(g.Drawer.Root),Ai=T(g.Drawer.Trigger),Mi=T(g.Drawer.Backdrop),Ni=T(g.Drawer.Positioner),Li=T(g.Drawer.Content),Pi=T(g.Drawer.Header),zi=T(g.Drawer.Title),$i=T(g.Drawer.Body),Vi=T(g.Drawer.Footer),Bi=T(g.Drawer.CloseTrigger),Fi=T(g.Tabs.Root),Hi=T(g.Tabs.List),jt=T(g.Tabs.Trigger),kt=T(g.Tabs.Content),Wi=({filterDrawerSize:e="sm",onVisibilityChange:t,onSizeChange:n,onClear:r,filters:o,pageKey:s="default",currentFilters:i={},onLoadPreset:a,activePresetName:f,onReorder:d})=>{const v=qe(Ge)[s]??bt(s),b=()=>{const u=prompt("Preset name?");u&&or(s,{id:crypto.randomUUID(),name:u,date:new Date().toISOString(),filters:i})};return l.jsx(g.HStack,{wrap:"wrap",children:l.jsxs(Ii,{size:e,children:[l.jsx(Ai,{asChild:!0,children:l.jsxs(g.IconButton,{"aria-label":"Open filters",variant:"outline",size:"xs",ml:2,p:2,children:[l.jsx(zs,{size:16}),"Filters"]})}),l.jsxs(g.Portal,{children:[l.jsx(Mi,{}),l.jsx(Ni,{children:l.jsxs(Li,{children:[l.jsx(Pi,{children:l.jsx(zi,{children:"Filters"})}),l.jsx($i,{overflowY:"auto",pt:1,children:l.jsxs(Fi,{defaultValue:"view",children:[l.jsxs(Hi,{mb:4,children:[l.jsxs(jt,{value:"view",children:[l.jsx(Fs,{size:16}),"Edit"]}),l.jsxs(jt,{value:"settings",children:[l.jsx(Ws,{size:16}),"Settings"]}),l.jsxs(jt,{value:"presets",children:[l.jsx(Ds,{size:16}),"Presets"]})]}),l.jsx(kt,{value:"view",children:o.filter(u=>u.visible).map(u=>l.jsxs(g.VStack,{align:"stretch",border:"1px solid",borderColor:"gray.200",rounded:"md",p:3,mb:3,children:[l.jsx(g.Text,{fontWeight:"bold",children:u.label}),u.customComponent]},u.id))}),l.jsx(kt,{value:"settings",children:l.jsx(Gn,{sensors:Hr(Fr(Ut)),collisionDetection:An,onDragEnd:({active:u,over:x})=>{if(!x||u.id===x.id)return;const m=o.findIndex(E=>E.id===u.id),y=o.findIndex(E=>E.id===x.id),w=pt(o,m,y);console.log(w),d?.(w)},children:l.jsx(Kn,{items:o.map(u=>u.id),strategy:ss,children:o.map(u=>l.jsx(ki,{filter:u,onVisibilityChange:t,onSizeChange:n},u.id))})})}),l.jsx(kt,{value:"presets",children:l.jsxs(g.VStack,{align:"stretch",mb:3,children:[l.jsx(g.Button,{size:"sm",colorScheme:"blue",onClick:b,children:"Save Current Filters"}),v.length===0&&l.jsx(g.Text,{fontSize:"xs",color:"gray.500",children:"No presets saved yet."}),v.map(u=>l.jsxs(g.HStack,{justify:"space-between",border:"1px solid",borderColor:f===u.name?"blue.300":"gray.200",rounded:"md",p:2,children:[l.jsxs(g.VStack,{align:"start",gap:0,children:[l.jsx(g.Text,{fontWeight:"bold",fontSize:"sm",children:u.name}),l.jsx(g.Text,{fontSize:"xs",color:"gray.500",children:new Date(u.date).toLocaleDateString()})]}),l.jsxs(g.HStack,{children:[l.jsx(g.Button,{size:"xs",variant:"ghost",onClick:()=>a?.(u.filters,u.name),children:"Load"}),l.jsx(g.IconButton,{size:"xs","aria-label":"Delete preset",variant:"ghost",onClick:()=>rr(s,u.id),children:l.jsx(Ms,{size:14})})]})]},u.id))]})})]})}),l.jsxs(Vi,{justify:"space-between",children:[l.jsx(g.Button,{size:"sm",variant:"ghost",colorScheme:"red",onClick:()=>r&&r(),children:"Clear All"}),l.jsx(Bi,{asChild:!0,children:l.jsx(g.CloseButton,{})})]})]})})]})]})})},Ui=({title:e,filters:t,onVisibilityChange:n,onReorder:r,onSizeChange:o,onClear:s,maxToolbarUnits:i,pageKey:a,currentFilters:f,onLoadPreset:d,activePresetName:h,filterDrawerSize:v="sm"})=>l.jsxs(g.HStack,{wrap:"wrap",pl:2,pr:2,width:"100%",justify:"space-between",children:[e,l.jsxs(g.HStack,{children:[t.length>0&&t.filter(b=>b.visible).map(b=>l.jsx(g.HStack,{children:b.customComponent},b.id)),l.jsx(Wi,{filterDrawerSize:v,onVisibilityChange:n?(b,u)=>n(b,u):void 0,onReorder:r,onSizeChange:o?(b,u)=>o(b,u):void 0,onClear:s,maxToolbarUnits:i,pageKey:a,filters:t,currentFilters:f,onLoadPreset:d,activePresetName:h})]})]}),Yi=(e,t)=>{localStorage.setItem(`FILTER_ORDER_${e}`,JSON.stringify(t))},Gi=e=>{try{return JSON.parse(localStorage.getItem(`FILTER_ORDER_${e}`)||"[]")}catch{return[]}};exports.DataTable=wi;exports.Filters=Ui;exports.addPreset=or;exports.deletePreset=rr;exports.getPresets=bt;exports.loadOrder=Gi;exports.presetStore=Ge;exports.saveOrder=Yi;exports.savePresets=Yt;exports.setData=tr;exports.tableStore=he;exports.withChildren=T;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import F, { useLayoutEffect as kr, useEffect as L, useRef as M, useMemo as A, useCallback as G, useState as ne, createContext as at, memo as Nr, useReducer as Lr, useContext as Ne, forwardRef as sn, createElement as Zt } from "react";
1
+ import F, { useLayoutEffect as kr, useEffect as N, useRef as M, useMemo as k, useCallback as G, useState as ne, createContext as at, memo as Nr, useReducer as Lr, useContext as Ne, forwardRef as sn, createElement as Zt } from "react";
2
2
  import { Menu as be, Checkbox as Le, IconButton as ke, Portal as It, Table as ve, HStack as ge, createListCollection as Mr, Select as le, Pagination as Ct, Box as Be, Text as Te, ButtonGroup as Pr, Slider as lt, VStack as tt, Drawer as me, Tabs as At, Button as Vt, CloseButton as zr } from "@chakra-ui/react";
3
3
  import { unstable_batchedUpdates as gt, createPortal as $r } from "react-dom";
4
4
  var pt = { exports: {} }, Qe = {};
@@ -31,7 +31,7 @@ function Fr() {
31
31
  function e(v) {
32
32
  if (v == null) return null;
33
33
  if (typeof v == "function")
34
- return v.$$typeof === N ? null : v.displayName || v.name || null;
34
+ return v.$$typeof === L ? null : v.displayName || v.name || null;
35
35
  if (typeof v == "string") return v;
36
36
  switch (v) {
37
37
  case m:
@@ -83,11 +83,11 @@ function Fr() {
83
83
  }
84
84
  if (y) {
85
85
  y = console;
86
- var T = y.error, k = typeof Symbol == "function" && Symbol.toStringTag && v[Symbol.toStringTag] || v.constructor.name || "Object";
86
+ var T = y.error, A = typeof Symbol == "function" && Symbol.toStringTag && v[Symbol.toStringTag] || v.constructor.name || "Object";
87
87
  return T.call(
88
88
  y,
89
89
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
90
- k
90
+ A
91
91
  ), t(v);
92
92
  }
93
93
  }
@@ -134,14 +134,14 @@ function Fr() {
134
134
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
135
135
  )), v = this.props.ref, v !== void 0 ? v : null;
136
136
  }
137
- function u(v, y, T, k, ue, Y) {
137
+ function u(v, y, T, A, ue, Y) {
138
138
  var z = T.ref;
139
139
  return v = {
140
140
  $$typeof: b,
141
141
  type: v,
142
142
  key: y,
143
143
  props: T,
144
- _owner: k
144
+ _owner: A
145
145
  }, (z !== void 0 ? z : null) !== null ? Object.defineProperty(v, "ref", {
146
146
  enumerable: !1,
147
147
  get: d
@@ -167,13 +167,13 @@ function Fr() {
167
167
  value: Y
168
168
  }), Object.freeze && (Object.freeze(v.props), Object.freeze(v)), v;
169
169
  }
170
- function f(v, y, T, k, ue, Y) {
170
+ function f(v, y, T, A, ue, Y) {
171
171
  var z = y.children;
172
172
  if (z !== void 0)
173
- if (k)
173
+ if (A)
174
174
  if (oe(z)) {
175
- for (k = 0; k < z.length; k++)
176
- h(z[k]);
175
+ for (A = 0; A < z.length; A++)
176
+ h(z[A]);
177
177
  Object.freeze && Object.freeze(z);
178
178
  } else
179
179
  console.error(
@@ -185,18 +185,18 @@ function Fr() {
185
185
  var q = Object.keys(y).filter(function(I) {
186
186
  return I !== "key";
187
187
  });
188
- k = 0 < q.length ? "{key: someKey, " + q.join(": ..., ") + ": ...}" : "{key: someKey}", Se[z + k] || (q = 0 < q.length ? "{" + q.join(": ..., ") + ": ...}" : "{}", console.error(
188
+ A = 0 < q.length ? "{key: someKey, " + q.join(": ..., ") + ": ...}" : "{key: someKey}", Se[z + A] || (q = 0 < q.length ? "{" + q.join(": ..., ") + ": ...}" : "{}", console.error(
189
189
  `A props object containing a "key" prop is being spread into JSX:
190
190
  let props = %s;
191
191
  <%s {...props} />
192
192
  React keys must be passed directly to JSX without using spread:
193
193
  let props = %s;
194
194
  <%s key={someKey} {...props} />`,
195
- k,
195
+ A,
196
196
  z,
197
197
  q,
198
198
  z
199
- ), Se[z + k] = !0);
199
+ ), Se[z + A] = !0);
200
200
  }
201
201
  if (z = null, T !== void 0 && (n(T), z = "" + T), s(y) && (n(y.key), z = "" + y.key), "key" in y) {
202
202
  T = {};
@@ -221,7 +221,7 @@ React keys must be passed directly to JSX without using spread:
221
221
  function g(v) {
222
222
  return typeof v == "object" && v !== null && v.$$typeof === b;
223
223
  }
224
- var c = F, b = /* @__PURE__ */ Symbol.for("react.transitional.element"), p = /* @__PURE__ */ Symbol.for("react.portal"), m = /* @__PURE__ */ Symbol.for("react.fragment"), x = /* @__PURE__ */ Symbol.for("react.strict_mode"), R = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), D = /* @__PURE__ */ Symbol.for("react.context"), O = /* @__PURE__ */ Symbol.for("react.forward_ref"), w = /* @__PURE__ */ Symbol.for("react.suspense"), S = /* @__PURE__ */ Symbol.for("react.suspense_list"), _ = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), $ = /* @__PURE__ */ Symbol.for("react.activity"), N = /* @__PURE__ */ Symbol.for("react.client.reference"), X = c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, oe = Array.isArray, xe = console.createTask ? console.createTask : function() {
224
+ var c = F, b = /* @__PURE__ */ Symbol.for("react.transitional.element"), p = /* @__PURE__ */ Symbol.for("react.portal"), m = /* @__PURE__ */ Symbol.for("react.fragment"), x = /* @__PURE__ */ Symbol.for("react.strict_mode"), R = /* @__PURE__ */ Symbol.for("react.profiler"), C = /* @__PURE__ */ Symbol.for("react.consumer"), D = /* @__PURE__ */ Symbol.for("react.context"), O = /* @__PURE__ */ Symbol.for("react.forward_ref"), w = /* @__PURE__ */ Symbol.for("react.suspense"), S = /* @__PURE__ */ Symbol.for("react.suspense_list"), _ = /* @__PURE__ */ Symbol.for("react.memo"), P = /* @__PURE__ */ Symbol.for("react.lazy"), $ = /* @__PURE__ */ Symbol.for("react.activity"), L = /* @__PURE__ */ Symbol.for("react.client.reference"), X = c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, oe = Array.isArray, xe = console.createTask ? console.createTask : function() {
225
225
  return null;
226
226
  };
227
227
  c = {
@@ -234,24 +234,24 @@ React keys must be passed directly to JSX without using spread:
234
234
  i
235
235
  )(), ie = xe(r(i)), Se = {};
236
236
  et.Fragment = m, et.jsx = function(v, y, T) {
237
- var k = 1e4 > X.recentlyCreatedOwnerStacks++;
237
+ var A = 1e4 > X.recentlyCreatedOwnerStacks++;
238
238
  return f(
239
239
  v,
240
240
  y,
241
241
  T,
242
242
  !1,
243
- k ? Error("react-stack-top-frame") : Ae,
244
- k ? xe(r(v)) : ie
243
+ A ? Error("react-stack-top-frame") : Ae,
244
+ A ? xe(r(v)) : ie
245
245
  );
246
246
  }, et.jsxs = function(v, y, T) {
247
- var k = 1e4 > X.recentlyCreatedOwnerStacks++;
247
+ var A = 1e4 > X.recentlyCreatedOwnerStacks++;
248
248
  return f(
249
249
  v,
250
250
  y,
251
251
  T,
252
252
  !0,
253
- k ? Error("react-stack-top-frame") : Ae,
254
- k ? xe(r(v)) : ie
253
+ A ? Error("react-stack-top-frame") : Ae,
254
+ A ? xe(r(v)) : ie
255
255
  );
256
256
  };
257
257
  })()), et;
@@ -592,7 +592,7 @@ function Nn(e) {
592
592
  function to() {
593
593
  for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
594
594
  t[n] = arguments[n];
595
- return A(
595
+ return k(
596
596
  () => (r) => {
597
597
  t.forEach((o) => o(r));
598
598
  },
@@ -628,7 +628,7 @@ function Zn(e) {
628
628
  function Ue(e) {
629
629
  return e ? Ye(e) ? e.document : an(e) ? ln(e) ? e : ut(e) || Zn(e) ? e.ownerDocument : document : document : document;
630
630
  }
631
- const pe = kt ? kr : L;
631
+ const pe = kt ? kr : N;
632
632
  function cn(e) {
633
633
  const t = M(e);
634
634
  return pe(() => {
@@ -656,7 +656,7 @@ function it(e, t) {
656
656
  }
657
657
  function dt(e, t) {
658
658
  const n = M();
659
- return A(
659
+ return k(
660
660
  () => {
661
661
  const r = e(n.current);
662
662
  return n.current = r, r;
@@ -677,13 +677,13 @@ function Dt(e) {
677
677
  }
678
678
  function en(e) {
679
679
  const t = M();
680
- return L(() => {
680
+ return N(() => {
681
681
  t.current = e;
682
682
  }, [e]), t.current;
683
683
  }
684
684
  let Ut = {};
685
685
  function ft(e, t) {
686
- return A(() => {
686
+ return k(() => {
687
687
  if (t)
688
688
  return t;
689
689
  const n = Ut[e] == null ? 0 : Ut[e] + 1;
@@ -849,7 +849,7 @@ function co() {
849
849
  const er = /* @__PURE__ */ at(null);
850
850
  function uo(e) {
851
851
  const t = Ne(er);
852
- L(() => {
852
+ N(() => {
853
853
  if (!t)
854
854
  throw new Error("useDndMonitor must be used within a children of <DndContext>");
855
855
  return t(e);
@@ -913,9 +913,9 @@ function go(e) {
913
913
  announce: i,
914
914
  announcement: s
915
915
  } = co(), a = ft("DndLiveRegion"), [d, u] = ne(!1);
916
- if (L(() => {
916
+ if (N(() => {
917
917
  u(!0);
918
- }, []), uo(A(() => ({
918
+ }, []), uo(k(() => ({
919
919
  onDragStart(h) {
920
920
  let {
921
921
  active: g
@@ -982,7 +982,7 @@ var V;
982
982
  function Ot() {
983
983
  }
984
984
  function po(e, t) {
985
- return A(
985
+ return k(
986
986
  () => ({
987
987
  sensor: e,
988
988
  options: {}
@@ -994,7 +994,7 @@ function po(e, t) {
994
994
  function bo() {
995
995
  for (var e = arguments.length, t = new Array(e), n = 0; n < e; n++)
996
996
  t[n] = arguments[n];
997
- return A(
997
+ return k(
998
998
  () => [...t].filter((r) => r != null),
999
999
  // eslint-disable-next-line react-hooks/exhaustive-deps
1000
1000
  [...t]
@@ -1536,29 +1536,29 @@ class ur {
1536
1536
  y: Math.min(m === j.Down ? S.bottom - S.height / 2 : S.bottom, Math.max(m === j.Down ? S.top : S.top + S.height / 2, h.y))
1537
1537
  }, P = m === j.Right && !R || m === j.Left && !C, $ = m === j.Down && !D || m === j.Up && !x;
1538
1538
  if (P && _.x !== h.x) {
1539
- const N = p.scrollLeft + g.x, X = m === j.Right && N <= O.x || m === j.Left && N >= w.x;
1539
+ const L = p.scrollLeft + g.x, X = m === j.Right && L <= O.x || m === j.Left && L >= w.x;
1540
1540
  if (X && !g.y) {
1541
1541
  p.scrollTo({
1542
- left: N,
1542
+ left: L,
1543
1543
  behavior: a
1544
1544
  });
1545
1545
  return;
1546
1546
  }
1547
- X ? c.x = p.scrollLeft - N : c.x = m === j.Right ? p.scrollLeft - O.x : p.scrollLeft - w.x, c.x && p.scrollBy({
1547
+ X ? c.x = p.scrollLeft - L : c.x = m === j.Right ? p.scrollLeft - O.x : p.scrollLeft - w.x, c.x && p.scrollBy({
1548
1548
  left: -c.x,
1549
1549
  behavior: a
1550
1550
  });
1551
1551
  break;
1552
1552
  } else if ($ && _.y !== h.y) {
1553
- const N = p.scrollTop + g.y, X = m === j.Down && N <= O.y || m === j.Up && N >= w.y;
1553
+ const L = p.scrollTop + g.y, X = m === j.Down && L <= O.y || m === j.Up && L >= w.y;
1554
1554
  if (X && !g.x) {
1555
1555
  p.scrollTo({
1556
- top: N,
1556
+ top: L,
1557
1557
  behavior: a
1558
1558
  });
1559
1559
  return;
1560
1560
  }
1561
- X ? c.y = p.scrollTop - N : c.y = m === j.Down ? p.scrollTop - O.y : p.scrollTop - w.y, c.y && p.scrollBy({
1561
+ X ? c.y = p.scrollTop - L : c.y = m === j.Down ? p.scrollTop - O.y : p.scrollTop - w.y, c.y && p.scrollBy({
1562
1562
  top: -c.y,
1563
1563
  behavior: a
1564
1564
  });
@@ -1866,7 +1866,7 @@ function Go(e) {
1866
1866
  }), x = M({
1867
1867
  x: 0,
1868
1868
  y: 0
1869
- }), R = A(() => {
1869
+ }), R = k(() => {
1870
1870
  switch (n) {
1871
1871
  case rt.Pointer:
1872
1872
  return d ? {
@@ -1884,8 +1884,8 @@ function Go(e) {
1884
1884
  return;
1885
1885
  const S = m.current.x * x.current.x, _ = m.current.y * x.current.y;
1886
1886
  w.scrollBy(S, _);
1887
- }, []), O = A(() => a === Tt.TreeOrder ? [...u].reverse() : u, [a, u]);
1888
- L(
1887
+ }, []), O = k(() => a === Tt.TreeOrder ? [...u].reverse() : u, [a, u]);
1888
+ N(
1889
1889
  () => {
1890
1890
  if (!i || !u.length || !R) {
1891
1891
  p();
@@ -1901,8 +1901,8 @@ function Go(e) {
1901
1901
  direction: P,
1902
1902
  speed: $
1903
1903
  } = No(w, _, R, t, g);
1904
- for (const N of ["x", "y"])
1905
- c[N][P[N]] || ($[N] = 0, P[N] = 0);
1904
+ for (const L of ["x", "y"])
1905
+ c[L][P[L]] || ($[L] = 0, P[L] = 0);
1906
1906
  if ($.x > 0 || $.y > 0) {
1907
1907
  p(), C.current = w, b(D, s), m.current = $, x.current = P;
1908
1908
  return;
@@ -1980,7 +1980,7 @@ function Jo(e, t) {
1980
1980
  }, [r, t]);
1981
1981
  }
1982
1982
  function Ko(e, t) {
1983
- return A(() => e.reduce((n, r) => {
1983
+ return k(() => e.reduce((n, r) => {
1984
1984
  const {
1985
1985
  sensor: o
1986
1986
  } = r, i = o.activators.map((s) => ({
@@ -2030,21 +2030,21 @@ function Zo(e, t) {
2030
2030
  }
2031
2031
  return x;
2032
2032
  }, [e, i, n, h, d]);
2033
- return L(() => {
2033
+ return N(() => {
2034
2034
  f.current = e;
2035
- }, [e]), L(
2035
+ }, [e]), N(
2036
2036
  () => {
2037
2037
  h || c();
2038
2038
  },
2039
2039
  // eslint-disable-next-line react-hooks/exhaustive-deps
2040
2040
  [n, h]
2041
- ), L(
2041
+ ), N(
2042
2042
  () => {
2043
2043
  i && i.length > 0 && s(null);
2044
2044
  },
2045
2045
  //eslint-disable-next-line react-hooks/exhaustive-deps
2046
2046
  [JSON.stringify(i)]
2047
- ), L(
2047
+ ), N(
2048
2048
  () => {
2049
2049
  h || typeof a != "number" || b.current !== null || (b.current = setTimeout(() => {
2050
2050
  c(), b.current = null;
@@ -2079,7 +2079,7 @@ function ei(e) {
2079
2079
  callback: t,
2080
2080
  disabled: n
2081
2081
  } = e;
2082
- const r = cn(t), o = A(() => {
2082
+ const r = cn(t), o = k(() => {
2083
2083
  if (n || typeof window > "u" || typeof window.MutationObserver > "u")
2084
2084
  return;
2085
2085
  const {
@@ -2087,14 +2087,14 @@ function ei(e) {
2087
2087
  } = window;
2088
2088
  return new i(r);
2089
2089
  }, [r, n]);
2090
- return L(() => () => o?.disconnect(), [o]), o;
2090
+ return N(() => () => o?.disconnect(), [o]), o;
2091
2091
  }
2092
2092
  function Nt(e) {
2093
2093
  let {
2094
2094
  callback: t,
2095
2095
  disabled: n
2096
2096
  } = e;
2097
- const r = cn(t), o = A(
2097
+ const r = cn(t), o = k(
2098
2098
  () => {
2099
2099
  if (n || typeof window > "u" || typeof window.ResizeObserver > "u")
2100
2100
  return;
@@ -2106,7 +2106,7 @@ function Nt(e) {
2106
2106
  // eslint-disable-next-line react-hooks/exhaustive-deps
2107
2107
  [n]
2108
2108
  );
2109
- return L(() => () => o?.disconnect(), [o]), o;
2109
+ return N(() => () => o?.disconnect(), [o]), o;
2110
2110
  }
2111
2111
  function ti(e) {
2112
2112
  return new fn(Ge(e), e);
@@ -2157,7 +2157,7 @@ function ni(e) {
2157
2157
  const Wn = [];
2158
2158
  function ri(e) {
2159
2159
  const t = M(e), n = dt((r) => e ? r && r !== Wn && e && t.current && e.parentNode === t.current.parentNode ? r : dn(e) : Wn, [e]);
2160
- return L(() => {
2160
+ return N(() => {
2161
2161
  t.current = e;
2162
2162
  }, [e]), n;
2163
2163
  }
@@ -2166,7 +2166,7 @@ function oi(e) {
2166
2166
  const s = Gt(i.target);
2167
2167
  s && n((a) => a ? (a.set(s, nn(s)), new Map(a)) : null);
2168
2168
  }, []);
2169
- return L(() => {
2169
+ return N(() => {
2170
2170
  const i = r.current;
2171
2171
  if (e !== i) {
2172
2172
  s(i);
@@ -2187,24 +2187,24 @@ function oi(e) {
2187
2187
  u?.removeEventListener("scroll", o);
2188
2188
  });
2189
2189
  }
2190
- }, [o, e]), A(() => e.length ? t ? Array.from(t.values()).reduce((i, s) => We(i, s), ce) : lr(e) : ce, [e, t]);
2190
+ }, [o, e]), k(() => e.length ? t ? Array.from(t.values()).reduce((i, s) => We(i, s), ce) : lr(e) : ce, [e, t]);
2191
2191
  }
2192
2192
  function Hn(e, t) {
2193
2193
  t === void 0 && (t = []);
2194
2194
  const n = M(null);
2195
- return L(
2195
+ return N(
2196
2196
  () => {
2197
2197
  n.current = null;
2198
2198
  },
2199
2199
  // eslint-disable-next-line react-hooks/exhaustive-deps
2200
2200
  t
2201
- ), L(() => {
2201
+ ), N(() => {
2202
2202
  const r = e !== ce;
2203
2203
  r && !n.current && (n.current = e), !r && n.current && (n.current = null);
2204
2204
  }, [e]), n.current ? _t(e, n.current) : ce;
2205
2205
  }
2206
2206
  function ii(e) {
2207
- L(
2207
+ N(
2208
2208
  () => {
2209
2209
  if (!kt)
2210
2210
  return;
@@ -2230,7 +2230,7 @@ function ii(e) {
2230
2230
  );
2231
2231
  }
2232
2232
  function si(e, t) {
2233
- return A(() => e.reduce((n, r) => {
2233
+ return k(() => e.reduce((n, r) => {
2234
2234
  let {
2235
2235
  eventName: o,
2236
2236
  handler: i
@@ -2241,7 +2241,7 @@ function si(e, t) {
2241
2241
  }, {}), [e, t]);
2242
2242
  }
2243
2243
  function fr(e) {
2244
- return A(() => e ? jo(e) : null, [e]);
2244
+ return k(() => e ? jo(e) : null, [e]);
2245
2245
  }
2246
2246
  const Yn = [];
2247
2247
  function ai(e, t) {
@@ -2290,7 +2290,7 @@ function ci(e) {
2290
2290
  const f = li(u);
2291
2291
  i?.disconnect(), f && i?.observe(f), r(f ? t(f) : null);
2292
2292
  }, [t, i]), [a, d] = Dt(s);
2293
- return A(() => ({
2293
+ return k(() => ({
2294
2294
  nodeRef: a,
2295
2295
  rect: n,
2296
2296
  setRef: d
@@ -2496,7 +2496,7 @@ function pi(e) {
2496
2496
  activatorEvent: r,
2497
2497
  draggableNodes: o
2498
2498
  } = Ne(Lt), i = en(r), s = en(n?.id);
2499
- return L(() => {
2499
+ return N(() => {
2500
2500
  if (!t && !r && i && s != null) {
2501
2501
  if (!un(i) || document.activeElement === i.target)
2502
2502
  return;
@@ -2534,7 +2534,7 @@ function bi(e, t) {
2534
2534
  }), n) : n;
2535
2535
  }
2536
2536
  function mi(e) {
2537
- return A(
2537
+ return k(
2538
2538
  () => ({
2539
2539
  draggable: {
2540
2540
  ...Rt.draggable,
@@ -2618,26 +2618,26 @@ const gr = /* @__PURE__ */ Nr(function(t) {
2618
2618
  droppable: {
2619
2619
  containers: $
2620
2620
  }
2621
- } = m, N = S != null ? _.get(S) : null, X = M({
2621
+ } = m, L = S != null ? _.get(S) : null, X = M({
2622
2622
  initial: null,
2623
2623
  translated: null
2624
- }), J = A(() => {
2624
+ }), J = k(() => {
2625
2625
  var U;
2626
2626
  return S != null ? {
2627
2627
  id: S,
2628
2628
  // It's possible for the active node to unmount while dragging
2629
- data: (U = N?.data) != null ? U : di,
2629
+ data: (U = L?.data) != null ? U : di,
2630
2630
  rect: X
2631
2631
  } : null;
2632
- }, [S, N]), oe = M(null), [xe, Ie] = ne(null), [H, Ae] = ne(null), ie = it(b, Object.values(b)), Se = ft("DndDescribedBy", s), v = A(() => $.getEnabled(), [$]), y = mi(g), {
2632
+ }, [S, L]), oe = M(null), [xe, Ie] = ne(null), [H, Ae] = ne(null), ie = it(b, Object.values(b)), Se = ft("DndDescribedBy", s), v = k(() => $.getEnabled(), [$]), y = mi(g), {
2633
2633
  droppableRects: T,
2634
- measureDroppableContainers: k,
2634
+ measureDroppableContainers: A,
2635
2635
  measuringScheduled: ue
2636
2636
  } = Zo(v, {
2637
2637
  dragging: w,
2638
2638
  dependencies: [P.x, P.y],
2639
2639
  config: y.droppable
2640
- }), Y = Jo(_, S), z = A(() => H ? tn(H) : null, [H]), q = Ar(), Z = Qo(Y, y.draggable.measure);
2640
+ }), Y = Jo(_, S), z = k(() => H ? tn(H) : null, [H]), q = Ar(), Z = Qo(Y, y.draggable.measure);
2641
2641
  xi({
2642
2642
  activeNode: S != null ? _.get(S) : null,
2643
2643
  config: q.layoutShiftCompensation,
@@ -2826,7 +2826,7 @@ const gr = /* @__PURE__ */ Nr(function(t) {
2826
2826
  }, [_, Sn]), Rn = Ko(f, Tr);
2827
2827
  ii(f), pe(() => {
2828
2828
  I && D === Oe.Initializing && O(Oe.Initialized);
2829
- }, [I, D]), L(
2829
+ }, [I, D]), N(
2830
2830
  () => {
2831
2831
  const {
2832
2832
  onDragMove: U
@@ -2857,7 +2857,7 @@ const gr = /* @__PURE__ */ Nr(function(t) {
2857
2857
  },
2858
2858
  // eslint-disable-next-line react-hooks/exhaustive-deps
2859
2859
  [$e.x, $e.y]
2860
- ), L(
2860
+ ), N(
2861
2861
  () => {
2862
2862
  const {
2863
2863
  active: U,
@@ -2921,7 +2921,7 @@ const gr = /* @__PURE__ */ Nr(function(t) {
2921
2921
  scrollableAncestors: Re,
2922
2922
  scrollableAncestorRects: ht
2923
2923
  });
2924
- const jr = A(() => ({
2924
+ const jr = k(() => ({
2925
2925
  active: J,
2926
2926
  activeNode: Y,
2927
2927
  activeNodeRect: I,
@@ -2933,13 +2933,13 @@ const gr = /* @__PURE__ */ Nr(function(t) {
2933
2933
  droppableContainers: $,
2934
2934
  droppableRects: T,
2935
2935
  over: Ce,
2936
- measureDroppableContainers: k,
2936
+ measureDroppableContainers: A,
2937
2937
  scrollableAncestors: Re,
2938
2938
  scrollableAncestorRects: ht,
2939
2939
  measuringConfiguration: y,
2940
2940
  measuringScheduled: ue,
2941
2941
  windowRect: Pt
2942
- }), [J, Y, I, H, qe, Xe, ye, _, $, T, Ce, k, Re, ht, y, ue, Pt]), Ir = A(() => ({
2942
+ }), [J, Y, I, H, qe, Xe, ye, _, $, T, Ce, A, Re, ht, y, ue, Pt]), Ir = k(() => ({
2943
2943
  activatorEvent: H,
2944
2944
  activators: Rn,
2945
2945
  active: J,
@@ -2950,8 +2950,8 @@ const gr = /* @__PURE__ */ Nr(function(t) {
2950
2950
  dispatch: x,
2951
2951
  draggableNodes: _,
2952
2952
  over: Ce,
2953
- measureDroppableContainers: k
2954
- }), [H, Rn, J, I, x, Se, _, Ce, k]);
2953
+ measureDroppableContainers: A
2954
+ }), [H, Rn, J, I, x, Se, _, Ce, A]);
2955
2955
  return F.createElement(er.Provider, {
2956
2956
  value: C
2957
2957
  }, F.createElement(Lt.Provider, {
@@ -3010,7 +3010,7 @@ function Si(e) {
3010
3010
  // eslint-disable-next-line react-hooks/exhaustive-deps
3011
3011
  [h, t]
3012
3012
  );
3013
- const _ = A(() => ({
3013
+ const _ = k(() => ({
3014
3014
  role: c,
3015
3015
  tabIndex: p,
3016
3016
  "aria-disabled": r,
@@ -3077,9 +3077,9 @@ function Di(e) {
3077
3077
  }), D = G((_, P) => {
3078
3078
  C && (P && (C.unobserve(P), h.current = !1), _ && C.observe(_));
3079
3079
  }, [C]), [O, w] = Dt(D), S = it(t);
3080
- return L(() => {
3080
+ return N(() => {
3081
3081
  !C || !O.current || (C.disconnect(), h.current = !1, C.observe(O.current));
3082
- }, [O, C]), L(
3082
+ }, [O, C]), N(
3083
3083
  () => (a({
3084
3084
  type: V.RegisterDroppable,
3085
3085
  element: {
@@ -3097,7 +3097,7 @@ function Di(e) {
3097
3097
  })),
3098
3098
  // eslint-disable-next-line react-hooks/exhaustive-deps
3099
3099
  [r]
3100
- ), L(() => {
3100
+ ), N(() => {
3101
3101
  n !== f.current.disabled && (a({
3102
3102
  type: V.SetDroppableDisabled,
3103
3103
  id: r,
@@ -3268,13 +3268,13 @@ function xr(e) {
3268
3268
  droppableRects: d,
3269
3269
  over: u,
3270
3270
  measureDroppableContainers: f
3271
- } = Ri(), h = ft(br, n), g = a.rect !== null, c = A(() => r.map((w) => typeof w == "object" && "id" in w ? w.id : w), [r]), b = s != null, p = s ? c.indexOf(s.id) : -1, m = u ? c.indexOf(u.id) : -1, x = M(c), R = !Oi(c, x.current), C = m !== -1 && p === -1 || R, D = Ti(i);
3271
+ } = Ri(), h = ft(br, n), g = a.rect !== null, c = k(() => r.map((w) => typeof w == "object" && "id" in w ? w.id : w), [r]), b = s != null, p = s ? c.indexOf(s.id) : -1, m = u ? c.indexOf(u.id) : -1, x = M(c), R = !Oi(c, x.current), C = m !== -1 && p === -1 || R, D = Ti(i);
3272
3272
  pe(() => {
3273
3273
  R && b && f(c);
3274
- }, [R, c, b, f]), L(() => {
3274
+ }, [R, c, b, f]), N(() => {
3275
3275
  x.current = c;
3276
3276
  }, [c]);
3277
- const O = A(
3277
+ const O = k(
3278
3278
  () => ({
3279
3279
  activeIndex: p,
3280
3280
  containerId: h,
@@ -3348,7 +3348,7 @@ function $i(e) {
3348
3348
  }
3349
3349
  }
3350
3350
  n !== a.current && (a.current = n);
3351
- }, [t, n, r, o]), L(() => {
3351
+ }, [t, n, r, o]), N(() => {
3352
3352
  i && s(null);
3353
3353
  }, [i]), i;
3354
3354
  }
@@ -3374,14 +3374,14 @@ function wr(e) {
3374
3374
  overIndex: m,
3375
3375
  useDragOverlay: x,
3376
3376
  strategy: R
3377
- } = Ne(mr), C = Vi(r, c), D = f.indexOf(s), O = A(() => ({
3377
+ } = Ne(mr), C = Vi(r, c), D = f.indexOf(s), O = k(() => ({
3378
3378
  sortable: {
3379
3379
  containerId: h,
3380
3380
  index: D,
3381
3381
  items: f
3382
3382
  },
3383
3383
  ...o
3384
- }), [h, o, D, f]), w = A(() => f.slice(f.indexOf(s)), [f, s]), {
3384
+ }), [h, o, D, f]), w = k(() => f.slice(f.indexOf(s)), [f, s]), {
3385
3385
  rect: S,
3386
3386
  node: _,
3387
3387
  isOver: P,
@@ -3395,7 +3395,7 @@ function wr(e) {
3395
3395
  ...d
3396
3396
  }
3397
3397
  }), {
3398
- active: N,
3398
+ active: L,
3399
3399
  activatorEvent: X,
3400
3400
  activeNodeRect: J,
3401
3401
  attributes: oe,
@@ -3413,7 +3413,7 @@ function wr(e) {
3413
3413
  ...n
3414
3414
  },
3415
3415
  disabled: C.draggable
3416
- }), v = to($, xe), y = !!N, T = y && !b && yt(g) && yt(m), k = !x && H, ue = k && T ? Se : null, z = T ? ue ?? (a ?? R)({
3416
+ }), v = to($, xe), y = !!L, T = y && !b && yt(g) && yt(m), A = !x && H, ue = A && T ? Se : null, z = T ? ue ?? (a ?? R)({
3417
3417
  rects: p,
3418
3418
  activeNodeRect: J,
3419
3419
  activeIndex: g,
@@ -3424,13 +3424,13 @@ function wr(e) {
3424
3424
  items: f,
3425
3425
  activeIndex: g,
3426
3426
  overIndex: m
3427
- }) : D, Z = N?.id, I = M({
3427
+ }) : D, Z = L?.id, I = M({
3428
3428
  activeId: Z,
3429
3429
  items: f,
3430
3430
  newIndex: q,
3431
3431
  containerId: h
3432
3432
  }), Xe = f !== I.current.items, de = t({
3433
- active: N,
3433
+ active: L,
3434
3434
  containerId: h,
3435
3435
  isDragging: H,
3436
3436
  isSorting: y,
@@ -3448,9 +3448,9 @@ function wr(e) {
3448
3448
  node: _,
3449
3449
  rect: S
3450
3450
  });
3451
- return L(() => {
3451
+ return N(() => {
3452
3452
  y && I.current.newIndex !== q && (I.current.newIndex = q), h !== I.current.containerId && (I.current.containerId = h), f !== I.current.items && (I.current.items = f);
3453
- }, [y, q, h, f]), L(() => {
3453
+ }, [y, q, h, f]), N(() => {
3454
3454
  if (Z === I.current.activeId)
3455
3455
  return;
3456
3456
  if (Z != null && I.current.activeId == null) {
@@ -3462,7 +3462,7 @@ function wr(e) {
3462
3462
  }, 50);
3463
3463
  return () => clearTimeout(Pe);
3464
3464
  }, [Z]), {
3465
- active: N,
3465
+ active: L,
3466
3466
  activeIndex: g,
3467
3467
  attributes: oe,
3468
3468
  data: O,
@@ -3491,7 +3491,7 @@ function wr(e) {
3491
3491
  Xe && I.current.newIndex === D
3492
3492
  )
3493
3493
  return Pi;
3494
- if (!(k && !un(X) || !u) && (y || de))
3494
+ if (!(A && !un(X) || !u) && (y || de))
3495
3495
  return He.Transition.toString({
3496
3496
  ...u,
3497
3497
  property: yr
@@ -3902,23 +3902,23 @@ function Ra({
3902
3902
  loading: n = !1,
3903
3903
  emptyMessage: r = "No data",
3904
3904
  actions: o,
3905
- page: i = 0,
3905
+ page: i = 1,
3906
3906
  pageSize: s = 10,
3907
3907
  onPageChange: a,
3908
3908
  onPageSizeChange: d,
3909
3909
  density: u = "sm"
3910
3910
  }) {
3911
- A(() => {
3911
+ N(() => {
3912
3912
  ms(e, t);
3913
3913
  }, [e]);
3914
- const { sortColumn: f, sortDirection: h, data: g } = ct(je), c = A(() => {
3914
+ const { sortColumn: f, sortDirection: h, data: g } = ct(je), c = k(() => {
3915
3915
  const b = [...g];
3916
3916
  f && b.sort(
3917
3917
  (m, x) => h === "asc" ? String(m[f]).localeCompare(String(x[f])) : String(x[f]).localeCompare(String(m[f]))
3918
3918
  );
3919
3919
  const p = (i - 1) * s;
3920
3920
  return b.slice(p, p + s);
3921
- }, [i, s, f, h]);
3921
+ }, [i, s, f, h, g]);
3922
3922
  return /* @__PURE__ */ l.jsxs(Be, { h: "100%", display: "flex", flexDirection: "column", p: 2, pt: 2, minHeight: 0, children: [
3923
3923
  /* @__PURE__ */ l.jsx(Be, { flex: "1", minHeight: 0, overflow: "auto", children: n ? /* @__PURE__ */ l.jsx(Be, { display: "flex", alignItems: "center", justifyContent: "center", h: "100%", color: "gray.500", children: "Loading..." }) : c.length === 0 ? /* @__PURE__ */ l.jsx(Be, { display: "flex", alignItems: "center", justifyContent: "center", h: "100%", color: "gray.500", children: r }) : /* @__PURE__ */ l.jsxs(ve.Root, { variant: "outline", w: "100%", size: u, children: [
3924
3924
  /* @__PURE__ */ l.jsx(Is, {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdspl/mds-shared-ui",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Chakra UI v3 DataTable with sorting, pagination, column visibility & drag reorder",
5
5
  "author": "magadh",
6
6
  "license": "MIT",