import{j as e,P as F,F as B,B as A,I as d}from"./index-952e178b.js";import{T as M,L as u,F as P,K as T}from"./LastPage-9979d461.js";import{K as C}from"./KeyboardArrowRight-91d2ccce.js";import{S as H}from"./componentStyles-00160cc0.js";import{T as L}from"./TableContainer-e3ecf13b.js";import{T as I,a as K,b as v}from"./TableHead-e31d41f4.js";import{a as c,T as b}from"./TableRow-6a27d7f4.js";import{T as S}from"./TablePagination-b93979a3.js";function W(x){const n=B(),{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:F,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};
