import{j as e,K as r}from"./vendor-tanstack-DE4ALVGD.js";import{S as h,a as j,b as f,c as p,e as l,b9 as P,aZ as S,ba as C,bb as o,cE as v,bc as D,bd as N,cF as T}from"./index-CNL5pSma.js";import{T as b,a as w,b as c,c as z,d as M,e as d}from"./table-CyGcvvjD.js";function k({table:n,onPrefetchPage:i}){return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"rounded-md border overflow-hidden",children:e.jsxs(b,{children:[e.jsx(w,{children:n.getHeaderGroups().map(a=>e.jsx(c,{children:a.headers.map(s=>e.jsx(z,{style:{...s.column.columnDef.maxSize&&{maxWidth:`${s.column.columnDef.maxSize}px`},...s.column.columnDef.size&&{width:`${s.column.columnDef.size}px`}},children:s.isPlaceholder?null:r(s.column.columnDef.header,s.getContext())},s.id))},a.id))}),e.jsx(M,{children:n.getRowModel().rows?.length?n.getRowModel().rows.map(a=>e.jsx(c,{"data-state":a.getIsSelected()&&"selected",children:a.getVisibleCells().map(s=>e.jsx(d,{style:{...s.column.columnDef.maxSize&&{maxWidth:`${s.column.columnDef.maxSize}px`},...s.column.columnDef.size&&{width:`${s.column.columnDef.size}px`}},children:r(s.column.columnDef.cell,s.getContext())},s.id))},a.id)):e.jsx(c,{children:e.jsx(d,{colSpan:n.getAllColumns().length,className:"h-24 text-center",children:"No results."})})})]})}),e.jsxs("div",{className:"flex flex-row justify-between items-center",children:[e.jsx(E,{table:n}),e.jsx(I,{table:n,onPrefetchPage:i})]})]})}function E({table:n}){return e.jsxs("div",{className:"flex flex-row items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"whitespace-nowrap",children:"Items per page"}),e.jsxs(h,{value:n.getState().pagination.pageSize.toString(),onValueChange:i=>{n.setPageSize(Number(i))},children:[e.jsx(j,{"aria-label":"Items per page",children:e.jsx(f,{placeholder:"Theme"})}),e.jsxs(p,{children:[e.jsx(l,{value:"5",children:"5"}),e.jsx(l,{value:"10",children:"10"}),e.jsx(l,{value:"25",children:"25"}),e.jsx(l,{value:"50",children:"50"})]})]})]})}function I({table:n,className:i,onPrefetchPage:a}){const s=n.getPageCount(),t=Math.min(Math.ceil(n.getState().pagination.pageIndex+1),s),x=()=>{t>1&&a?.(1)},m=()=>{t>1&&a?.(t-1)},u=()=>{t<s&&a?.(t+1)},g=()=>{t<s&&a?.(s)};return e.jsx(P,{className:S("justify-end",i),children:e.jsxs(C,{children:[e.jsxs(o,{children:[e.jsx(v,{onClick:()=>n.firstPage(),onMouseEnter:x,disabled:!n.getCanPreviousPage()}),e.jsx(D,{onClick:()=>n.previousPage(),onMouseEnter:m,disabled:!n.getCanPreviousPage()})]}),e.jsxs(o,{className:"text-sm",children:["Page ",t," of ",s]}),e.jsx(o,{children:e.jsx(N,{onClick:()=>n.nextPage(),onMouseEnter:u,disabled:!n.getCanNextPage()})}),e.jsx(o,{children:e.jsx(T,{onClick:()=>n.lastPage(),onMouseEnter:g,disabled:!n.getCanNextPage()})})]})})}export{k as D};
//# sourceMappingURL=data-table-DDT7Ownu.js.map
