import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{$ as t}from"./vendor-charts-iXlq6Rne.js";import{c as n}from"./api-CqQWIBIg.js";import{t as r}from"./file-text-6Qqw2k_h.js";import{t as i}from"./image-n9lAl4fW.js";import{t as a}from"./paperclip-BXWCXgka.js";import{t as o}from"./upload-CE-0Hc0c.js";import{_ as s}from"./vendor-flow-IzlrcDx6.js";import{Sn as c,rn as l}from"./index-HkVQGc9M.js";var u=e(t(),1),d=s(),f=10,p=`.pdf,.jpg,.jpeg,.png,.gif,.webp,.doc,.docx`;function m(e){return e.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp)$/)?i:r}function h(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function g({files:e,onChange:t,label:r,hint:i,accept:s=p,compact:g=!1}){let _=(0,u.useRef)(null),[v,y]=(0,u.useState)(!1),b=r=>{if(r.size>f*1024*1024){n.error(`File is larger than ${f} MB`);return}if(e.some(e=>e.file.name===r.name&&e.file.size===r.size)){n.error(`File already added`);return}t([...e,{file:r,notes:``}])},x=n=>{t(e.filter((e,t)=>t!==n))};return(0,d.jsxs)(`div`,{className:l(`space-y-2`,g&&`space-y-1.5`),children:[r&&(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,d.jsx)(a,{className:`w-3.5 h-3.5 text-[var(--color-accent)]`}),(0,d.jsx)(`label`,{className:l(`font-medium text-[var(--color-text-primary)]`,g?`text-[11px] uppercase tracking-[0.06em]`:`text-[13px]`),children:r}),e.length>0&&(0,d.jsx)(`span`,{className:`ml-auto rounded-full bg-[var(--color-accent)]/10 px-1.5 py-0.5 text-[10px] font-medium text-[var(--color-accent)]`,children:e.length})]}),e.length>0&&(0,d.jsx)(`div`,{className:`space-y-1.5`,children:e.map((e,t)=>{let n=m(e.file.name);return(0,d.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-[var(--color-border)] bg-[var(--color-surface)] p-2`,children:[(0,d.jsx)(`div`,{className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded bg-[var(--color-accent)]/10`,children:(0,d.jsx)(n,{className:`h-4 w-4 text-[var(--color-accent)]`})}),(0,d.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,d.jsx)(`p`,{className:`truncate text-[12px] font-medium text-[var(--color-text-primary)]`,children:e.file.name}),(0,d.jsx)(`p`,{className:`text-[10px] text-[var(--color-text-muted)]`,children:h(e.file.size)})]}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>x(t),className:`rounded p-1 text-[var(--color-text-muted)] hover:bg-[var(--color-error)]/10 hover:text-[var(--color-error)]`,children:(0,d.jsx)(c,{className:`h-3.5 w-3.5`})})]},`${e.file.name}-${t}`)})}),(0,d.jsx)(`input`,{ref:_,type:`file`,accept:s,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;if(t)for(let e=0;e<t.length;e++)b(t[e]);e.target.value=``}}),(0,d.jsxs)(`button`,{type:`button`,onClick:()=>_.current?.click(),onDrop:e=>{e.preventDefault(),y(!1);let t=e.dataTransfer.files;for(let e=0;e<t.length;e++)b(t[e])},onDragOver:e=>{e.preventDefault(),y(!0)},onDragLeave:()=>y(!1),className:l(`flex w-full items-center justify-center gap-2 rounded-lg border-2 border-dashed transition`,g?`p-3`:`p-4`,v?`border-[var(--color-accent)] bg-[var(--color-accent)]/5`:`border-[var(--color-border)] hover:border-[var(--color-accent)] hover:bg-[var(--color-surface-hover)]`),children:[(0,d.jsx)(o,{className:l(`text-[var(--color-text-muted)]`,g?`h-4 w-4`:`h-5 w-5`)}),(0,d.jsx)(`span`,{className:l(`text-[var(--color-text-muted)]`,g?`text-[11px]`:`text-[12px]`),children:g?`Add files`:`Click or drag to add attachments`})]}),i&&(0,d.jsx)(`p`,{className:`text-[11px] text-[var(--color-text-muted)]`,children:i})]})}export{g as t};