import{j as e,cF as E,cG as z,f as m,c$ as U,cI as A,cH as w,r as W,cJ as N,cK as $,cL as O,cM as q,q as G,B as v,bA as H,T as J,w as K}from"./index-7414fd54.js";import{T as L,t as D}from"./TableCell-3cadf061.js";import{T as x}from"./TableRow-34be244e.js";import{u as Q}from"./index-aa118901.js";import{T as V,a as X,b as Y}from"./TableHead-4965c3b4.js";import{c as Z}from"./createSvgIcon-76207f66.js";import{T as _}from"./TablePagination-748823c3.js";const tt=Z(e.jsx("path",{d:"M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"}));function et(t){return E("MuiTableSortLabel",t)}const ot=z("MuiTableSortLabel",["root","active","icon","iconDirectionDesc","iconDirectionAsc","directionDesc","directionAsc"]),C=ot,at=t=>{const{classes:s,direction:a,active:r}=t,n={root:["root",r&&"active",`direction${w(a)}`],icon:["icon",`iconDirection${w(a)}`]};return q(n,et,s)},st=m(U,{name:"MuiTableSortLabel",slot:"Root",overridesResolver:(t,s)=>{const{ownerState:a}=t;return[s.root,a.active&&s.active]}})(A(({theme:t})=>({cursor:"pointer",display:"inline-flex",justifyContent:"flex-start",flexDirection:"inherit",alignItems:"center","&:focus":{color:(t.vars||t).palette.text.secondary},"&:hover":{color:(t.vars||t).palette.text.secondary,[`& .${C.icon}`]:{opacity:.5}},[`&.${C.active}`]:{color:(t.vars||t).palette.text.primary,[`& .${C.icon}`]:{opacity:1,color:(t.vars||t).palette.text.secondary}}}))),rt=m("span",{name:"MuiTableSortLabel",slot:"Icon",overridesResolver:(t,s)=>{const{ownerState:a}=t;return[s.icon,s[`iconDirection${w(a.direction)}`]]}})(A(({theme:t})=>({fontSize:18,marginRight:4,marginLeft:4,opacity:0,transition:t.transitions.create(["opacity","transform"],{duration:t.transitions.duration.shorter}),userSelect:"none",variants:[{props:{direction:"desc"},style:{transform:"rotate(0deg)"}},{props:{direction:"asc"},style:{transform:"rotate(180deg)"}}]}))),nt=W.forwardRef(function(s,a){const r=N({props:s,name:"MuiTableSortLabel"}),{active:n=!1,children:g,className:f,direction:T="asc",hideSortIcon:l=!1,IconComponent:d=tt,slots:k={},slotProps:p={},...u}=r,i={...r,active:n,direction:T,hideSortIcon:l,IconComponent:d},c=at(i),b={slots:k,slotProps:p},[h,y]=$("root",{elementType:st,externalForwardedProps:b,ownerState:i,className:O(c.root,f),ref:a}),[j,o]=$("icon",{elementType:rt,externalForwardedProps:b,ownerState:i,className:c.icon});return e.jsxs(h,{disableRipple:!0,component:"span",...y,...u,children:[g,l&&!n?null:e.jsx(j,{as:d,...o})]})}),it=nt,F=m(L)(({theme:t,width:s,style:a})=>({[`&.${D.head}`]:{minWidth:s,textAlign:"start",...a==null?void 0:a.head},[`&.${D.body}`]:{textAlign:"start",BorderBottom:"0.8px solid #0000004D",...a==null?void 0:a.body}})),ct=m(x)(({theme:t})=>({"&:nth-of-type(odd)":{},"&:last-child td, &:last-child th":{}}));function gt({columns:t=[],rows:s=[],rowColor:a,getRowColor:r,getHoverColor:n,loading:g,count:f,page:T,pageSize:l,showPagination:d=!0,containerHeight:k="100%",handleSort:p,handleChangePage:u,handleChangeRowsPerPage:i,sortField:c,sortOrder:b,tableHeight:h=600}){const y=G();Q(y.breakpoints.down("sm"));const j=o=>{p&&p(o)};return e.jsxs(v,{sx:{width:"100%"},children:[e.jsx(v,{sx:{width:"100%",height:h||"calc(100vh - 400px)",overflow:"auto",position:"relative",zIndex:0},children:e.jsxs(V,{"aria-label":"responsive table",children:[e.jsx(X,{sx:{position:"sticky",top:0,zIndex:1},children:e.jsx(ct,{children:t.map(o=>e.jsx(F,{style:{minWidth:o.width,width:o.width,backgroundColor:"#FAFAFA",fontWeight:"bold"},children:o.sortable?e.jsx(it,{active:c===o.key,direction:c===o.key?b:"asc",onClick:()=>j(o.key),children:o.title}):o.title},o.key))})}),e.jsx(Y,{children:g?e.jsx(x,{children:e.jsx(L,{colSpan:t.length,align:"center",sx:{padding:5},children:e.jsx(H,{})})}):s.length?s.map((o,I)=>{const B=r?r(o):a||"#FFFFFF";return o&&e.jsx(x,{sx:{backgroundColor:B,borderBottom:"1px solid #E0E0E0",cursor:"pointer","&:hover":{backgroundColor:n?`${n(o)} !important`:"rgba(0,0,0,0.04) !important",transition:"background-color 0.2s ease","& td":{backgroundColor:"inherit !important"}}},children:Object.keys(o).map((M,S)=>{var P,R;return e.jsx(F,{component:"th",scope:"row",style:{minWidth:(P=t[S])==null?void 0:P.width,width:(R=t[S])==null?void 0:R.width,padding:"8px 8px"},children:e.jsx(J,{children:o[M]})},S)})},I)}):e.jsx(x,{children:e.jsx(L,{colSpan:t.length,align:"center",sx:{padding:5},children:"Empty Data"})})})]})}),d&&e.jsx(K,{sx:{mt:2,p:1},children:e.jsx(v,{sx:{display:"flex",justifyContent:"center"},children:e.jsx(_,{rowsPerPageOptions:[10,20,50,100],component:"div",count:f,rowsPerPage:l,page:T-1,onPageChange:u,onRowsPerPageChange:i})})})]})}export{gt as T};
