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