"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),g=require("react"),l=require("@mui/material/Box"),N=require("@mui/material/Typography"),m=require("./units-CDpdlN1W.cjs"),I=require("@mui/material/Tooltip"),B=require("@mui/material/Chip"),x=require("./Icon-CKdIOrjZ.cjs"),p=require("@mui/material/Checkbox"),h={bytes:e=>m.convertByteUnits({from:e}),sum:e=>{let t=0;if(Array.isArray(e))for(const r of e)t+=Number(r);return typeof e=="string"&&e.split(",").forEach(r=>{t+=Number(r)}),typeof e=="number"&&(t+=e),t.toString()},count:e=>Array.isArray(e)?e.length.toString():typeof e=="string"?e.split(",").length.toString():typeof e=="number"?e.toString():"",avg:e=>{let t=0,r=0;if(Array.isArray(e))for(const i of e)t+=Number(i),r++;return(t/r).toString()},max:e=>{let t=0;if(Array.isArray(e))for(const r of e)t=Math.max(t,Number(r));return t.toString()},min:e=>{let t=Number.MAX_VALUE;if(Array.isArray(e))for(const r of e)t=Math.min(t,Number(r));return typeof e=="string"&&e.split(",").forEach(r=>{t=Math.min(t,Number(r))}),typeof e=="number"&&(t=Math.min(t,e)),t.toString()}},y=e=>{switch(e){case"success":return"success";case"warning":return"warning";case"danger":case"error":return"error";case"primary":return"primary";case"neutral":return"inherit";default:return}},T=({value:e,...t})=>{const r=g.useMemo(()=>{const s=new Date(e);return!e||isNaN(s.getTime())?"0s":m.formatTimeDifference(s)},[e]),[i,a]=g.useState(r);return g.useEffect(()=>{const s=new Date(e);if(isNaN(s.getTime()))return;const u=setInterval(()=>{a(m.formatTimeDifference(s))},1e3);return()=>{clearInterval(u)}},[e,r]),n.jsx(C,{value:i,...t})},C=({align:e,value:t,color:r,colorMap:i,startDecorator:a,endDecorator:s,formatter:c,children:u})=>{const d=()=>{if(i){const f=i[t]??i["*"]??void 0;return y(f)}return y(r)},o=()=>{switch(e){case"left":return"flex-start";case"right":return"flex-end";case"center":return"center";default:return"flex-start"}};return n.jsx(l,{display:"flex",flex:1,justifyContent:o(),alignItems:"center",sx:{overflowY:"hidden",overflowX:"scroll",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:u??n.jsxs(l,{display:"flex",alignItems:"center",gap:.5,children:[a,n.jsx(N,{variant:"caption",color:d(),noWrap:!0,children:c&&h[c]?h[c](t):`${t}`}),s]})})},b=({formatter:e,...t})=>e?.toLowerCase()==="age"?n.jsx(T,{...t}):n.jsx(C,{...t,formatter:e?.toLowerCase()});b.displayName="TextCell";const q={success:"var(--ov-success-default)",warning:"var(--ov-warning-default)",danger:"var(--ov-danger-default)",primary:"var(--ov-accent)",neutral:"var(--ov-fg-muted)"},j=({align:e,values:t,colorMap:r,hoverMenu:i,hoverMenuDelay:a})=>{const s=o=>q[r[o]??"neutral"],c=()=>{switch(e){case"left":return"flex-start";case"right":return"flex-end";case"center":return"center";case"justify":return"space-between";default:return"flex-start"}},u=a??200,d=({color:o})=>n.jsx(l,{sx:{borderRadius:"2px",width:12,height:12,minWidth:12,minHeight:12,bgcolor:o}});return n.jsx(l,{display:"flex",flex:1,justifyContent:c(),alignItems:"center",gap:.25,children:t.map((o,f)=>i?n.jsx(I,{title:i(o),enterDelay:u,slotProps:{tooltip:{sx:{p:1,border:"1px solid var(--ov-border-default)",bgcolor:"var(--ov-bg-surface-overlay)",color:"var(--ov-fg-default)"}}},children:n.jsx(d,{color:s(o)})},`badge-${f}`):n.jsx(d,{color:s(o)},`badge-${f}`))})};j.displayName="BadgesCell";const v=e=>{switch(e){case"success":return"success";case"warning":return"warning";case"danger":return"error";case"primary":return"primary";case"neutral":return"default";default:return"default"}},R=e=>e==="outlined"?"outlined":"filled",w=({align:e,value:t,color:r,colorMap:i,startDecorator:a,endDecorator:s,variant:c})=>{const u=()=>i?i[t]||"neutral":r??"neutral",d=()=>{switch(e){case"left":return"flex-start";case"right":return"flex-end";case"center":return"center";default:return"flex-start"}},o=typeof a=="string"?n.jsx(x.Icon,{name:a,size:16}):a,f=typeof s=="string"?n.jsx(x.Icon,{name:s,size:16}):s;return n.jsx(l,{display:"flex",flex:1,justifyContent:d(),alignItems:"center",children:n.jsx(B,{size:"small",color:v(u()),variant:R(c),sx:{borderRadius:"4px"},icon:o,label:f?n.jsxs(l,{display:"flex",alignItems:"center",gap:.5,children:[t,f]}):t})})};w.displayName="ChipCell";const S=({table:e})=>n.jsx(l,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",maxWidth:24},children:n.jsx(p,{size:"small",checked:e.getIsAllPageRowsSelected(),onChange:t=>{e.toggleAllPageRowsSelected(t.target.checked)},"aria-label":"Select all rows"})});S.displayName="SelectBoxHeader";const A=({row:e})=>n.jsx(l,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",maxWidth:24},children:n.jsx(p,{size:"small",checked:e.getIsSelected(),onChange:t=>{e.toggleSelected(t.target.checked)},"aria-label":"Select row"})});A.displayName="SelectBoxRow";exports.BadgesCell=j;exports.ChipCell=w;exports.SelectBoxHeader=S;exports.SelectBoxRow=A;exports.TextCell=b;
