import{j as e,P as B,H as F,B as A,I as d}from"./index-c3f592b2.js";import{T as M,L as u,F as P,K as T}from"./LastPage-4fb40c42.js";import{K as C}from"./KeyboardArrowRight-ee7691b4.js";import{S as H}from"./componentStyles-b8fcedb5.js";import{T as L}from"./TableContainer-a7e6bb64.js";import{T as I,a as K,b as v}from"./TableHead-98885dba.js";import{a as c,T as b}from"./TableRow-974e102e.js";import{T as S}from"./TablePagination-fd957a04.js";function W(x){const n=F(),{count:r,page:t,rowsPerPage:s,onPageChange:l}=x,p=i=>{l(i,0)},g=i=>{l(i,t-1)},o=i=>{l(i,t+1)},h=i=>{l(i,Math.max(0,Math.ceil(r/s)-1))};return e.jsxs(A,{sx:{flexShrink:0,ml:2.5},children:[e.jsx(d,{onClick:p,disabled:t===0,"aria-label":"first page",children:n.direction==="rtl"?e.jsx(u,{}):e.jsx(P,{})}),e.jsx(d,{onClick:g,disabled:t===0,"aria-label":"previous page",children:n.direction==="rtl"?e.jsx(C,{}):e.jsx(T,{})}),e.jsx(d,{onClick:o,disabled:t>=Math.ceil(r/s)-1,"aria-label":"next page",children:n.direction==="rtl"?e.jsx(T,{}):e.jsx(C,{})}),e.jsx(d,{onClick:h,disabled:t>=Math.ceil(r/s)-1,"aria-label":"last page",children:n.direction==="rtl"?e.jsx(P,{}):e.jsx(u,{})})]})}function J({showPagination:x,columns:n,rows:r,count:t,page:s,pageSize:l,loading:p=!1,rowsPerPageOptions:g=[10,20,50,100],onRowClick:o,handleChangePage:h,handleChangeRowsPerPage:i,handleSort:m}){return e.jsx(L,{component:B,sx:{maxHeight:600,overflow:"auto"},children:e.jsxs(I,{sx:{minWidth:500},"aria-label":"common pagination table",stickyHeader:!0,children:[e.jsx(K,{children:e.jsx(c,{sx:{backgroundColor:"#fafafa","& .MuiTableCell-root":{backgroundColor:"#fafafa"}},children:n.map((a,f)=>e.jsx(b,{align:a.align||"center",style:{minWidth:a.width||120},onClick:()=>a.sortable&&(m==null?void 0:m(a.field||"")),sx:{cursor:a.sortable?"pointer":"default",fontWeight:"bold",fontFamily:"Poppins",border:"1px solid #e0e0e0",textAlign:a.align||"center",padding:"16px 20px",fontSize:"1rem",height:"56px",lineHeight:"1.5rem",color:"#333"},children:a.title},f))})}),e.jsx(v,{children:p?e.jsx(c,{children:e.jsx(b,{colSpan:n.length,align:"center",sx:{fontFamily:"Poppins"},children:"Loading..."})}):r.length>0?r.map((a,f)=>e.jsx(c,{hover:!0,onClick:()=>o==null?void 0:o(a),sx:{cursor:o?"pointer":"default"},children:n.map((y,j)=>{const k=y.field||Object.keys(a)[j];return e.jsx(H,{align:"center",sx:{textAlign:"center !important",fontFamily:"Poppins",padding:"8px 12px",lineHeight:2.4,"& *":{textAlign:"center !important"}},children:a[k]},j)})},f)):e.jsx(c,{children:e.jsx(b,{colSpan:n.length,align:"center",sx:{fontFamily:"Poppins"},children:"No records found"})})}),x&&e.jsx(M,{children:e.jsx(c,{children:e.jsx(S,{rowsPerPageOptions:g,colSpan:n.length,count:t,rowsPerPage:l,page:s-1,onPageChange:h,onRowsPerPageChange:i,ActionsComponent:W,sx:{fontFamily:"Poppins","& .MuiTablePagination-toolbar":{justifyContent:"flex-end"},"& .MuiTablePagination-spacer":{display:"none"}}})})})]})})}export{J as C};
