import{j as t,p as g,a8 as M,S as f,o as v,a6 as P}from"./vendor-mui-CBBEb17G.js";import{e as p,go as b,c$ as j,w as L,bI as _,gt as $,bF as V,I as S,aP as X,gX as q,bc as H,fI as K,al as W}from"./index-IP_FWtso.js";import{u as h}from"./selectSupplementInsuranceList-ChcGDXE8.js";import{a as n}from"./vendor-react-BBazpZul.js";import"./vendor-utils-BveVE6Uf.js";import{R as Y}from"./reportServiceGroup-C9CvvBB7.js";const re=()=>{const{userType:i}=p(e=>e.user),{state:{insuranceId:o},setField:c}=h(),{insurancesSelectList:l}=p(e=>e.data),a=l==null?void 0:l.map(e=>({value:`${e.id}`,label:`${e.id} - ${e.title}`}));return t.jsxs(g,{display:"flex",flexDirection:"column",mt:0,gap:1,children:[t.jsx(b,{className:+i===j.accountant?"!bg-[#b0d8e7]":"",children:"انتخاب بیمه"}),t.jsx(L,{selectOption:a||[],value:(a==null?void 0:a.find(e=>e.value===(o==null?void 0:o.toString())))||null,onChange:e=>c("insuranceId",e!=null&&e.value?+e.value:void 0),label:"انتخاب بیمه"})]})},oe=()=>{const{userType:i}=p(e=>e.user),{state:{supplementaryInsuranceId:o},setField:c}=h(),{supplementaryInsurancesSelectList:l}=p(e=>e.data),a=(l==null?void 0:l.map(e=>({label:e.title,value:e.id.toString()})))||[];return t.jsxs(g,{display:"flex",flexDirection:"column",mt:0,gap:1,children:[t.jsx(b,{className:+i===j.accountant?"!bg-[#b0d8e7]":"",children:"بیمه تکمیلی"}),t.jsx(L,{selectOption:a,label:"انتخاب بیمه تکمیلی",value:a.find(e=>e.value===(o==null?void 0:o.toString()))||null,onChange:e=>c("supplementaryInsuranceId",e!=null&&e.value?+(e==null?void 0:e.value):void 0)})]})},J=({serviceId:i,isCheck:o})=>{const{state:{serviceIdList:c},setField:l}=h(),a=e=>{if(e&&l("serviceIdList",[...c,i]),!e){const d=c.findIndex(m=>m===i);if(d<0)return;l("serviceIdList",_.toUpdate(c,d))}};return t.jsx(M,{checked:o,onChange:(e,d)=>a(d),inputProps:{"aria-label":"controlled"},className:"!ml-1",style:{width:"10px",height:"10px",transform:"scale(0.9)"}})},Q=W(P)`
  .MuiTypography-root {
    font-size: 0.8rem;
  }
`,ne=()=>{const{userType:i}=p(s=>s.user),{state:{serviceIdList:o,doctorId:c},setField:l}=h(),[a,e]=n.useState([]),[d,m]=n.useState(""),[R,I]=n.useState(!1),[C,A]=n.useState([]),[x,G]=n.useState(),[y,D]=n.useState(null),T=n.useRef(null),{getReportServiceGroupAsync:F}=$(),{GetCenterServicesSelectList:z}=K(),w=async()=>{const{data:s}=await F({});s&&A(s)},E=async()=>{const{data:s}=await z({query:d});if(!s)return;const u=s.map(r=>({label:r.title,value:r.serviceDetailId.toString()}));e(u)};n.useEffect(()=>{w(),l("serviceIdList",[])},[]),n.useEffect(()=>{if(!x)return;const s=x.map(r=>+r.value),u=C.filter(r=>s.includes(r.id)).flatMap(r=>r.services).map(r=>r.serviceDetailId);l("serviceIdList",u)},[x]),n.useEffect(()=>{y&&clearTimeout(y);const s=setTimeout(()=>E(),1500);D(s)},[c,d]);const N=()=>{if(!a)return;const s=a.map(u=>+u.value);l("serviceIdList",s)},k=()=>{l("serviceIdList",[]),m("")},B=()=>{I(!1),w()},O=({index:s,style:u})=>{const r=a[s];return t.jsx(t.Fragment,{children:t.jsx(f,{paddingX:2,paddingY:"3px",borderBottom:"1px solid rgba(0,0,0,0.3)",className:"whitespace-nowrap",style:u,children:t.jsx(Q,{control:t.jsx(J,{serviceId:+r.value,isCheck:o.some(U=>U===+r.value)}),label:t.jsx(H,{title:r.label,maxLengthValue:35})})})})};return t.jsxs(g,{display:"flex",flexDirection:"column",gap:1,className:"!w-[245px] mobile:!w-auto",children:[t.jsx(b,{className:+i===j.accountant?"!bg-[#b0d8e7]":"",children:"انتخاب خدمت"}),t.jsxs(f,{direction:"row",justifyContent:"space-between",children:[t.jsx(V,{label:"گروه خدمات گزارش",selectOption:C.map(s=>({label:s.title,value:s.id.toString()})),value:x,onChange:s=>G(s),fullWidth:!0}),t.jsx(v,{onClick:()=>I(!0),color:"success",children:t.jsx(S.AddBox,{fontSize:"small"})})]}),t.jsxs(f,{direction:"row",justifyContent:"space-between",children:[t.jsx(v,{onClick:N,color:"primary",children:t.jsx(S.DoneAll,{fontSize:"small"})}),t.jsx(v,{onClick:k,color:"error",children:t.jsx(S.CloseIcon,{fontSize:"small"})}),t.jsx(X,{placeholder:"جستجو . . .",value:d,onChange:s=>m(s)})]}),t.jsx(f,{height:200,borderRadius:"5px",fontSize:"0.8rem",position:"relative",border:"1px solid rgba(0,0,0,0.3)",overflow:"hidden",children:t.jsx(q,{ref:T,height:200,itemCount:(a==null?void 0:a.length)??0,itemSize:34,itemData:a,width:"100%",style:{position:"absolute",top:0,left:0,zIndex:20,direction:"rtl",scrollbarWidth:"none"},children:O})}),R&&t.jsx(Y,{onClose:B})]})};export{re as S,oe as a,ne as b};
