import{s as e}from"./utils-CXcsdpX-.js";import{t}from"./plus-CuMPbIyn.js";import{Oo as n,Ra as r,_o as i,za as a}from"./index-CvTTLloU.js";import{a as o,i as s,n as c,t as l}from"./card-CCLQVS9k.js";import{t as u}from"./badge-CL1e8lO_.js";var d=e();function f({title:e,icon:f,data:p,columns:m,totalCount:h=0,page:g=1,onPageChange:_,search:v=``,onSearchChange:y,isLoading:b,onAdd:x,addLabel:S=`Add`,emptyIcon:C,emptyMessage:w=`No data found`,renderActions:T,headerExtra:E,action:D}){let O=Math.ceil(h/20),k=m.length+1+ +!!T;return(0,d.jsxs)(l,{className:`p-0 overflow-hidden flex flex-col w-full max-w-full`,style:{maxHeight:`calc(100vh - 220px)`},children:[(0,d.jsx)(s,{className:`px-4 py-3 border-b shrink-0`,children:(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[f,(0,d.jsx)(o,{className:`text-base`,children:e}),(0,d.jsx)(u,{variant:`secondary`,className:`ml-1`,children:h||p.length})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,y&&(0,d.jsxs)(`div`,{className:`relative w-48`,children:[(0,d.jsx)(i,{className:`absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,d.jsx)(r,{placeholder:`Search ${e.toLowerCase()}...`,value:v,onChange:e=>{y?.(e.target.value),_?.(1)},className:`pl-8 h-8 text-sm`})]}),x&&(0,d.jsxs)(a,{onClick:x,size:`sm`,children:[(0,d.jsx)(t,{className:`mr-2 size-4`}),S]}),D]})]})}),(0,d.jsx)(c,{className:`p-0 flex-1 overflow-auto min-h-0`,children:b?(0,d.jsx)(`div`,{className:`flex h-64 items-center justify-center`,children:(0,d.jsx)(n,{className:`size-8 animate-spin text-muted-foreground`})}):(0,d.jsxs)(`table`,{className:`w-full text-sm border-collapse`,children:[(0,d.jsx)(`thead`,{className:`bg-blue-50 dark:bg-blue-950/30 sticky top-0 z-10`,children:(0,d.jsxs)(`tr`,{className:`border-b`,children:[(0,d.jsx)(`th`,{className:`text-left px-2 py-2 text-[11px] font-bold text-[#1a3c6e] dark:text-[#4a7ab5] uppercase tracking-wider w-[40px]`,children:`#`}),m.map(e=>(0,d.jsx)(`th`,{className:`px-2 py-2 text-[11px] font-bold text-[#1a3c6e] dark:text-[#4a7ab5] uppercase tracking-wider whitespace-nowrap text-left ${e.className||``}`,children:e.label},e.key)),T&&(0,d.jsx)(`th`,{className:`px-2 py-2 text-center text-[11px] font-bold text-[#1a3c6e] dark:text-[#4a7ab5] uppercase tracking-wider`,children:`Actions`})]})}),(0,d.jsx)(`tbody`,{children:p.length===0?(0,d.jsx)(`tr`,{children:(0,d.jsx)(`td`,{colSpan:k,className:`text-center py-12 text-muted-foreground`,children:(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[C,(0,d.jsx)(`span`,{children:w})]})})}):p.map((e,t)=>(0,d.jsxs)(`tr`,{className:`border-b last:border-b-0 hover:bg-muted/30 transition-colors`,children:[(0,d.jsx)(`td`,{className:`px-2 py-1.5 text-muted-foreground text-xs`,children:t+1}),m.map(t=>(0,d.jsx)(`td`,{className:`px-2 py-1.5 text-sm ${t.className||``}`,children:t.render?t.render(e):String(e[t.key]??``)},t.key)),T&&(0,d.jsx)(`td`,{className:`px-2 py-1.5 text-center`,children:(0,d.jsx)(`div`,{className:`flex items-center justify-end gap-0.5`,children:T(e)})})]},e.id))})]})}),O>1&&_&&(0,d.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-between border-t px-3 py-2 bg-muted/20`,children:[(0,d.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,g,` of `,O]}),(0,d.jsxs)(`div`,{className:`flex gap-2`,children:[(0,d.jsx)(a,{variant:`outline`,size:`sm`,disabled:g<=1,onClick:()=>_(g-1),children:`Previous`}),(0,d.jsx)(a,{variant:`outline`,size:`sm`,disabled:g>=O,onClick:()=>_(g+1),children:`Next`})]})]})]})}export{f as t};