import{a as n,j as l}from"./vendor-query-B2UbickB.js";import{aG as D}from"./vendor-icons-CrrAvF2g.js";function v(r,c){const p=c.split(",").map(e=>e.trim());for(const e of p)if(e.startsWith(".")&&r.name.toLowerCase().endsWith(e.toLowerCase())||e===r.type||e.endsWith("/*")&&r.type.startsWith(e.slice(0,-1)))return!0;return!1}function j({onDrop:r,children:c,label:p="Drop files here",accept:e,disabled:i}){const[u,f]=n.useState(!1),s=n.useRef(0),d=n.useCallback(t=>{t.preventDefault(),t.stopPropagation(),s.current++,i||f(!0)},[i]),g=n.useCallback(t=>{t.preventDefault(),t.stopPropagation(),s.current--,s.current<=0&&(s.current=0,f(!1))},[]),x=n.useCallback(t=>{t.preventDefault(),t.stopPropagation()},[]),h=n.useCallback(t=>{if(t.preventDefault(),t.stopPropagation(),s.current=0,f(!1),i)return;const o=Array.from(t.dataTransfer.files);if(console.debug("[DropZone] dropped files:",o.map(a=>({name:a.name,type:a.type,size:a.size}))),e){const a=o.filter(m=>v(m,e));console.debug("[DropZone] after accept filter:",a.length,"of",o.length),a.length?r(a):console.warn("[DropZone] no files matched accept pattern:",e)}else o.length&&r(o)},[r,e,i]);return l.jsxs("div",{className:"relative",onDragEnter:d,onDragLeave:g,onDragOver:x,onDrop:h,children:[c,u&&l.jsx("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center transition-opacity pointer-events-none",style:{background:"rgba(var(--color-surface-rgb, 255 255 255) / 0.85)"},children:l.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 py-5 rounded-xl border border-dashed border-text-quaternary/40",children:[l.jsx(D,{className:"w-8 h-8 text-text-tertiary"}),l.jsx("p",{className:"text-xs text-text-secondary",children:p})]})})]})}export{j as D};
//# sourceMappingURL=DropZone-BkfRoUcm.js.map
