import{j as r,S as j,p as w,Y as x,Z as S,$ as C,U as s,V as n,a0 as N}from"./vendor-mui-CBBEb17G.js";import{u as k}from"./index-5ex8CyJt.js";import{dP as v}from"./index-IP_FWtso.js";import{a as m}from"./vendor-react-BBazpZul.js";import"./vendor-utils-BveVE6Uf.js";import"./index-BkhbTDKf.js";import"./vendor-charts-tGnAgELZ.js";const F=()=>{var d,h,p;const{states:{reportData:f,loading:i}}=k(),l=f,[o,c]=m.useState(1),u=()=>{if(l!=null&&l.headers.some(e=>e.children.some(t=>{var a;return(a=t.children)==null?void 0:a.length}))){c(3);return}if(l!=null&&l.headers.some(e=>e.children.length>0)){c(2);return}c(1)},g=e=>e.children.length?1:o,b=e=>{let t=0;for(let a of e.children){if(!a.children.length){t+=1;continue}t+=a.children.length}return t};return m.useEffect(()=>{l&&u()},[l]),r.jsx(r.Fragment,{children:l?r.jsxs(j,{spacing:1,children:[r.jsx("h1",{className:"w-full text-center text-slate-700",children:l.title}),r.jsxs(w,{className:"!relative h-[75vh]  border rounded-lg",children:[i&&r.jsx(v,{}),r.jsx(x,{className:" !absolute top-0 bottom-0 left-0 right-0 !w-full !mb-[5px] overflow-auto rounded-lg",children:r.jsxs(S,{size:"small",stickyHeader:!0,children:[r.jsxs(C,{children:[r.jsxs(s,{children:[r.jsx(n,{width:120,align:"center",variant:"head",className:"!px-1 !bg-blue-500 !text-white border",rowSpan:o,children:"پزشک"}),(d=l.headers)==null?void 0:d.map(e=>r.jsx(n,{width:e.width||`${e.children.length??150}`,align:"center",variant:"head",className:"!px-1  border",colSpan:b(e),rowSpan:g(e),sx:{minWidth:150*(e.children.length||1),backgroundColor:e.backgroundColor??"#3b6df6",color:e.color??"#ffffff"},children:e.title},e.title))]}),r.jsx(s,{className:"sticky top-[38px]",children:(h=l.headers)==null?void 0:h.flatMap(e=>e.children).map(e=>r.jsx(n,{width:e.width,align:"center",variant:"head",className:"!px-1  border",sx:{backgroundColor:e.backgroundColor??"#475569",color:e.color??"#ffffff"},colSpan:e.children.length||1,rowSpan:e.children.length?1:2,children:e.title},e.title))}),o===3&&r.jsx(s,{className:"sticky top-[76px]",children:(p=l.headers)==null?void 0:p.flatMap(e=>e.children).flatMap(e=>e.children).map((e,t)=>r.jsx(n,{width:e==null?void 0:e.width,align:"center",variant:"head",className:"!px-1  border",sx:{backgroundColor:(e==null?void 0:e.backgroundColor)??"#475569",color:(e==null?void 0:e.color)??"#ffffff"},children:e.title},e.title))})]}),r.jsx(N,{children:l.list?r.jsx(r.Fragment,{children:l.list.map(e=>r.jsx(s,{className:"cursor-pointer odd:bg-white even:bg-slate-100",children:Object.entries(e).map(([t,a])=>r.jsx(n,{className:"!px-1 border",variant:"body",align:"center",children:a},t))},Object.values(e)[0]))}):r.jsx(s,{children:r.jsx(n,{colSpan:7,align:"center",children:i?"در حال دریافت اطلاعات ...":"موردی جهت نمایش وجود ندارد"})})})]})})]})]}):r.jsx("h2",{className:"w-full p-8 text-center text-slate-700",children:"داده ای برای نمایش وجود ندارد"})})};export{F as default};
