import{j as r,B as a,T as x,cB as z,I as k,aK as B,R as L,ee as R}from"./index-e0c07a84.js";import{C as A}from"./index.esm-79617ba5.js";import"./componentStyles-5432a72d.js";import{A as I}from"./Avatar-acb20b85.js";import{a as f}from"./TextField-23174150.js";const E=({removeDocument:l,file:o,attachments:t,setAttachments:m})=>{function u(){const d=o!=null&&o.id?t==null?void 0:t.map(n=>n.id==o.id?{...n,dodelete:!0}:n):t==null?void 0:t.filter(n=>(n==null?void 0:n.uuid)!=(o==null?void 0:o.uuid));m(d)}const c=o.path||(o.file?decodeURIComponent(o.file.split("/").pop()||"document"):"document"),i=o.preview||o.file;return r.jsxs(a,{id:o.name,sx:{border:"1px solid",borderColor:"divider",borderRadius:"6px",p:"12px",display:"flex"},children:[r.jsxs(a,{sx:{display:"flex",alignItems:"center",gap:"12px",width:"100%"},component:"a",target:"_blank",href:i,children:[i?r.jsx(I,{variant:"rounded",sx:{height:"48px",width:"48px",bgcolor:"grey",objectFit:"cover"},alt:c,src:i}):r.jsx(x,{component:"span",sx:{display:"flex",alignItems:"center",justifyContent:"center",color:"primary.main",fontWeight:600,borderRadius:"6px",height:"48px",width:"48px",bgcolor:"#3e60d51a"},children:r.jsx(z,{})}),r.jsxs(a,{children:[r.jsx(x,{sx:{fontWeight:600,color:"grey.700",wordBreak:"break-word",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:c}),r.jsx(x,{component:"p",color:"grey.700",children:o.formattedSize})]})]}),!l&&r.jsx(k,{sx:{marginLeft:"auto",my:"auto"},children:r.jsx(B,{size:18,onClick:()=>u()})})]})},K=({control:l,name:o,showPreview:t=!0,icon:m,text:u,iconSize:c,selectedFiles:i,handleAcceptedFiles:d,removeFile:n,required:O,label:W,height:U="95px"})=>{var h;return r.jsxs(r.Fragment,{children:[r.jsx(A,{name:o,control:l,rules:{required:"File upload is required.",validate:e=>e.length>0?!0:"Please upload at least one file."},render:({field:e,fieldState:s})=>{var p,g,j,b,y,v;return r.jsxs(a,{children:[r.jsxs(L,{variant:"contained",component:"label",startIcon:r.jsx(R,{size:16}),size:"large",sx:{mt:3,backgroundColor:"#5B3959",color:"#fff","&:hover":{backgroundColor:"#4a2e48"}},children:[W,r.jsx("input",{type:"file",hidden:!0,multiple:!0,onChange:w=>{if(w.target.files){const C=Array.from(w.target.files);d&&d(C,()=>{}),e.onChange(C)}}})]}),((p=s.error)==null?void 0:p.message)&&r.jsx(f,{error:s.error!=null,sx:{mt:1},children:(g=s.error)==null?void 0:g.message}),Array.isArray(s.error)&&((b=(j=s.error)==null?void 0:j[0])==null?void 0:b.message)&&r.jsx(f,{error:s.error!=null,sx:{mt:1},children:(v=(y=s.error)==null?void 0:y[0])==null?void 0:v.message})]})}}),t&&Array.isArray(i)&&(i==null?void 0:i.length)>0&&r.jsx(a,{sx:{mt:1},children:(h=i||[])==null?void 0:h.map((e,s)=>{const p=e.name.substr(e.name.lastIndexOf(".")+1);return r.jsxs(a,{sx:{border:"1px solid",borderColor:"divider",borderRadius:"6px",p:"12px",width:"100%",display:"flex",mb:s<i.length-1?1:0},children:[r.jsxs(a,{sx:{display:"flex",alignItems:"center",gap:"12px"},children:[e.preview?r.jsx(I,{variant:"rounded",sx:{height:"48px",minWidth:"48px",bgcolor:"white",objectFit:"cover"},alt:e.name,src:e.preview}):r.jsx(x,{component:"span",sx:{display:"flex",alignItems:"center",justifyContent:"center",color:"primary.main",fontWeight:600,borderRadius:"6px",height:"48px",width:"48px",bgcolor:"#3e60d51a"},children:p.toUpperCase()}),r.jsxs(a,{children:[r.jsx(x,{sx:{fontWeight:600,color:"grey.700",overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical"},children:e.name}),r.jsx(x,{component:"p",color:"grey.700",children:e.formattedSize})]})]}),r.jsx(k,{sx:{marginLeft:"auto",my:"auto"},children:r.jsx(B,{size:18,onClick:()=>n&&n(e)})})]},s)})})]})};export{K as F,E as H};
