import{a as v,r as x,j as t,C as k,c as i}from"./index-CUDottTv.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const S=v("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function D({columns:l,data:o,onRowClick:d,selectedIndex:c,className:p,emptyMessage:f="No data",defaultSort:g,footer:u}){const[y,h]=x.useState(null),[n,j]=x.useState(g??null),m=x.useMemo(()=>n?[...o].sort((e,r)=>{const s=e[n.key],a=r[n.key];if(s==null&&a==null)return 0;if(s==null)return 1;if(a==null)return-1;const b=typeof s=="number"&&typeof a=="number"?s-a:String(s).localeCompare(String(a));return n.direction==="asc"?b:-b}):o,[o,n]),N=e=>{j(r=>(r==null?void 0:r.key)===e?r.direction==="asc"?{key:e,direction:"desc"}:null:{key:e,direction:"asc"})};return t.jsxs("div",{className:i("flex flex-col overflow-hidden",p),children:[t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsxs("table",{className:"w-full border-collapse",children:[t.jsx("thead",{className:"sticky top-0 z-10",children:t.jsx("tr",{className:"bg-bg-surface border-b border-border-strong",children:l.map(e=>t.jsx("th",{style:e.width?{width:e.width}:void 0,className:i("h-9 px-3.5 text-[11px] font-semibold text-text-muted uppercase tracking-wider",e.align==="right"?"text-right":e.align==="center"?"text-center":"text-left",e.sortable!==!1&&"cursor-pointer select-none hover:text-text-secondary transition-colors"),onClick:()=>e.sortable!==!1&&N(e.key),children:t.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.header,(n==null?void 0:n.key)===e.key&&(n.direction==="asc"?t.jsx(S,{size:12,className:"text-text-secondary"}):t.jsx(k,{size:12,className:"text-text-secondary"}))]})},e.key))})}),t.jsx("tbody",{children:m.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:l.length,className:"h-32 text-center text-[13px] text-text-muted",children:f})}):m.map((e,r)=>t.jsx("tr",{onClick:()=>d==null?void 0:d(e,r),onMouseEnter:()=>h(r),onMouseLeave:()=>h(null),className:i("border-b border-border-muted transition-colors",d&&"cursor-pointer",c===r&&"bg-bg-active",y===r&&c!==r&&"bg-bg-hover"),children:l.map(s=>t.jsx("td",{className:i("h-10 px-3.5 text-[13px] text-text-secondary",s.align==="right"&&"text-right",s.align==="center"&&"text-center",s.mono&&"font-mono text-[12px] tabular-nums"),children:s.render?s.render(e):String(e[s.key]??"")},s.key))},r))})]})}),u&&t.jsx("div",{className:"flex items-center justify-between px-3.5 py-2 border-t border-border-muted text-[11px] text-text-muted bg-bg-surface shrink-0",children:u})]})}export{D};
