import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{$ as t}from"./vendor-charts-iXlq6Rne.js";import{t as n}from"./createLucideIcon-CPi6oOk3.js";import{t as r}from"./Pagination-CXRYv0dn.js";import{_ as i}from"./vendor-flow-IzlrcDx6.js";import{Mn as a,Rn as o,rn as s}from"./index-HkVQGc9M.js";import{t as c}from"./EmptyState-CsLvB2WD.js";import{n as l}from"./Skeleton-BPr2yo9M.js";import{a as u,i as d,n as f,o as p,t as m}from"./vendor-table-C04d_sgN.js";import{t as h}from"./SearchBar-D5BrJnJ9.js";var g=n(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),_=n(`arrow-up-down`,[[`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`}]]),v=n(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),y=e(t(),1),b=i();function x({columns:e,data:t,isLoading:n=!1,isFetching:i=!1,searchable:x=!0,searchPlaceholder:S=`Search...`,totalItems:C,currentPage:w=1,pageSize:T=20,totalPages:E=1,onPageChange:D,onPageSizeChange:O,onSearch:k,emptyTitle:A=`No results found`,emptyDescription:j=`Try adjusting your search or filters.`,emptyActionLabel:M,onEmptyAction:N,toolbar:P,className:F,onRowClick:I}){let[L,R]=(0,y.useState)([]),[z,B]=(0,y.useState)(``),V=!!k,H=f({data:t,columns:e,state:{sorting:L,...V?{}:{globalFilter:z}},onSortingChange:R,onGlobalFilterChange:B,getCoreRowModel:d(),getSortedRowModel:p(),...V?{}:{getFilteredRowModel:u()}}),U=e=>{B(e),k?.(e)},W=C??t.length,G=D&&W>0;return(0,b.jsxs)(`div`,{className:s(`flex flex-col bg-[var(--color-surface)] rounded-[var(--radius-card)] border border-[var(--color-border)] shadow-[var(--shadow-sm)] overflow-hidden`,F),children:[(x||P)&&(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-3 border-b border-[var(--color-border)] flex-shrink-0`,children:[x&&(0,b.jsx)(h,{placeholder:S,value:z,onChange:U,className:`w-64`}),P&&(0,b.jsx)(`div`,{className:`flex items-center gap-2`,children:P})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto relative`,children:[i&&!n&&(0,b.jsx)(`div`,{className:`absolute inset-0 z-10 bg-[var(--color-surface)]/60 flex items-center justify-center pointer-events-none`,children:(0,b.jsx)(o,{className:`w-5 h-5 text-[var(--color-primary)] animate-spin`})}),(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 z-10`,children:H.getHeaderGroups().map(e=>(0,b.jsx)(`tr`,{className:`border-b border-[var(--color-border)]`,children:e.headers.map(e=>(0,b.jsx)(`th`,{className:s(`h-10 px-5 text-left text-[11px] font-semibold uppercase tracking-[0.06em] text-[var(--color-text-muted)]`,`bg-[var(--color-background)]`,e.column.getCanSort()&&`cursor-pointer select-none hover:text-[var(--color-text-secondary)] transition-colors`),onClick:e.column.getToggleSortingHandler(),"aria-sort":e.column.getIsSorted()===`asc`?`ascending`:e.column.getIsSorted()===`desc`?`descending`:e.column.getCanSort()?`none`:void 0,children:(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.isPlaceholder?null:m(e.column.columnDef.header,e.getContext()),e.column.getCanSort()&&(0,b.jsx)(`span`,{className:`text-[var(--color-text-muted)]`,children:e.column.getIsSorted()===`asc`?(0,b.jsx)(v,{className:`w-3 h-3`}):e.column.getIsSorted()===`desc`?(0,b.jsx)(g,{className:`w-3 h-3`}):(0,b.jsx)(_,{className:`w-3 h-3 opacity-30`})})]})},e.id))},e.id))}),(0,b.jsx)(`tbody`,{children:n?Array.from({length:5},(t,n)=>(0,b.jsx)(l,{columns:e.length},n)):H.getRowModel().rows.length>0?H.getRowModel().rows.map(e=>(0,b.jsx)(`tr`,{className:s(`border-b border-[var(--color-border-light)] last:border-0 hover:bg-[var(--color-accent-soft)]/50 dark:hover:bg-white/[0.04] transition-colors`,I&&`cursor-pointer`),onClick:I?t=>{t.target.closest(`button, a, input, select, label`)||I(e.original)}:void 0,children:e.getVisibleCells().map(e=>(0,b.jsx)(`td`,{className:`px-5 py-3 text-[13px] text-[var(--color-text-secondary)]`,children:m(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:e.length,children:(0,b.jsx)(c,{icon:a,title:A,description:j,actionLabel:M,onAction:N})})})})]})]}),G&&(0,b.jsx)(`div`,{className:s(`px-5 border-t border-[var(--color-border)] flex-shrink-0`,i&&`pointer-events-none opacity-60`),children:(0,b.jsx)(r,{currentPage:w,totalPages:E,totalItems:W,pageSize:T,onPageChange:D,onPageSizeChange:O})})]})}export{x as t};