import{j as e,B as d,T as p,I as c,eb as m,ec as x}from"./index-952e178b.js";import{A as f}from"./Avatar-d2c68597.js";import{T as h}from"./Tooltip-2222bd7e.js";import{T as b}from"./TableContainer-e3ecf13b.js";import{T as j,a as u,b as w}from"./TableHead-e31d41f4.js";import{a as n,T as l}from"./TableRow-6a27d7f4.js";const v=({documents:i,height:o="300px"})=>{const a=[{title:"Attachments",width:200},{title:"",width:80}],s=i.map(r=>{const t=decodeURIComponent(r.file.split("/").pop()||"document");return{file:e.jsxs(d,{display:"flex",alignItems:"center",children:[e.jsx(f,{variant:"square",src:"/static/pdf-icon.png",sx:{width:40,height:40,mr:2}}),e.jsx(p,{variant:"body2",color:"primary",component:"a",href:r.file,target:"_blank",rel:"noopener noreferrer",sx:{textDecoration:"underline",wordBreak:"break-word",whiteSpace:"normal"},children:t})]}),actions:e.jsxs(d,{display:"flex",justifyContent:"flex-end",children:[e.jsx(h,{title:"View",children:e.jsx(c,{size:"small",color:"success",component:"a",href:r.file,target:"_blank",rel:"noopener noreferrer",children:e.jsx(m,{})})}),e.jsx(h,{title:"Download",children:e.jsx(c,{size:"small",color:"primary",onClick:()=>g(r.file),children:e.jsx(x,{})})})]})}});return e.jsx(b,{sx:{height:300,pb:5,overflowY:"auto",border:r=>`1px solid ${r.palette.grey[400]}`,borderRadius:"5px","&::-webkit-scrollbar":{width:8,height:8},"&::-webkit-scrollbar-thumb":{backgroundColor:r=>r.palette.grey[300],borderRadius:"5px"}},children:e.jsxs(j,{size:"medium",width:"100%",children:[e.jsx(u,{children:e.jsx(n,{children:a.map((r,t)=>e.jsx(l,{width:r.width,sx:{backgroundColor:"#f5f6fa"},children:r.title},t))})}),e.jsx(w,{children:s.length?s.map((r,t)=>e.jsxs(n,{children:[e.jsx(l,{children:r.file}),e.jsx(l,{children:r.actions})]},t)):e.jsx(n,{children:e.jsx(l,{colSpan:a.length,align:"center",sx:{p:5},children:"No Documents"})})})]})})};function g(i){const o=document.createElement("a");o.href=i,o.download=i.split("/").pop()||"file",document.body.appendChild(o),o.click(),document.body.removeChild(o)}export{v as D};
