import{j as a,p as c,B as u}from"./vendor-mui-CBBEb17G.js";import{a as f}from"./vendor-react-BBazpZul.js";import{e as v,fv as N,fw as y,fx as B,J as E,d3 as U}from"./index-IP_FWtso.js";import"./vendor-utils-BveVE6Uf.js";const P=({disabled:i=!1,picture:s,setPicture:d,showSelectLabel:x})=>{var m;const{appSetting:t}=v(e=>e.data),l=((m=t==null?void 0:t.fileUploadSetting)==null?void 0:m.Profile)||null,[r,o]=f.useState(null),g=async e=>{if(!e||!l)return;const{isValid:b,errorMessage:w}=B(l,e[0]);if(!b)return E.error(w);for(let n=0;n<e.length;n++){let p=(await U().toBase64(e[n])).replace("data:image/jpeg;base64,","").replace("data:image/png;base64,","");d(p),o("data:image/png;base64,"+p)}},j=()=>{d(""),o(null)};f.useEffect(()=>{s&&o("data:image/png;base64,"+s)},[s]);const h=(l==null?void 0:l.validExtensions.map(e=>`image/${e}`).join(", ").trim())||"image/*";return a.jsxs(c,{className:"add-patient-upload w-full p-4 rounded-3xl flex flex-col items-center justify-center shadow-lg h-[80%]",children:[a.jsx(c,{className:"w-36 h-36 rounded-full shadow-lg border mb-8 bg-slate-100",children:r&&a.jsx("img",{className:"w-full h-full rounded-full object-cover",src:r,alt:"uploadedImage"})}),a.jsxs(c,{className:"w-full flex justify-center",children:[a.jsxs(u,{disabled:i,variant:"contained",component:"label",children:[a.jsx(N,{}),x?a.jsx("div",{className:"mx-1 !text-[0.8rem]",children:" انتخاب تصویر "}):"",a.jsx("input",{onChange:e=>{g(e.target.files)},hidden:!0,accept:h,type:"file"})]}),r?a.jsx(u,{disabled:i,onClick:j,variant:"contained",color:"error",className:"!mr-2 !py-2",children:a.jsx(y,{})}):null]})]})};export{P as A};
