/**
 * Upload dropzone + progress indicator for FileTextbox panels.
 */
'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useRef } from 'react';
import { cn } from '../../utils/cn.js';
import { HiCloudUpload } from 'react-icons/hi';
export function FileUploadZone({ file_accept, upload_progress, uploading_files, on_files }) {
    const file_input_ref = useRef(null);
    return (_jsxs("div", { children: [uploading_files.length > 0 && (_jsx("div", { className: "flex flex-col mb-1.5", children: uploading_files.map((uf, i) => (_jsxs("div", { className: "flex items-center gap-1.5 px-1.5 py-0.5 rounded", children: [uf.status === 'uploading' ? (_jsxs("svg", { className: "h-2.5 w-2.5 flex-shrink-0 text-blue-500 animate-spin", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] })) : (_jsx(HiCloudUpload, { className: "h-2.5 w-2.5 flex-shrink-0 text-green-600" })), _jsx("span", { className: "text-xs text-muted-foreground/60 truncate", children: uf.name })] }, `uploading_${i}`))) })), _jsxs("div", { children: [upload_progress ? (_jsxs("div", { className: "w-full py-1 rounded border border-dashed border-primary/40 bg-primary/5", children: [_jsxs("div", { className: "flex items-center justify-center gap-2 text-[11px] text-primary mb-0.5", children: [_jsxs("svg", { className: "h-3 w-3 animate-spin", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), _jsxs("span", { children: ["Uploading ", upload_progress.current, "/", upload_progress.total, ' — ', _jsx("span", { className: "truncate inline-block max-w-[200px] align-bottom", children: upload_progress.file_name })] })] }), _jsx("div", { className: "mx-3 h-0.5 rounded-full bg-primary/20 overflow-hidden", children: _jsx("div", { className: "h-full bg-primary rounded-full transition-all duration-300", style: { width: `${(upload_progress.current / upload_progress.total) * 100}%` } }) })] })) : (_jsxs("button", { type: "button", onClick: () => file_input_ref.current?.click(), className: cn('w-full flex items-center justify-center gap-1.5 py-1.5 rounded-md border border-dashed', 'border-violet-300/60 text-xs text-violet-400 bg-white/40', 'hover:border-violet-400/70 hover:text-violet-500 hover:bg-white/70 transition-all'), children: [_jsx(HiCloudUpload, { className: "h-3.5 w-3.5" }), "Drop files or click to upload"] })), _jsx("input", { ref: file_input_ref, type: "file", multiple: true, accept: file_accept, className: "hidden", onChange: (e) => { if (e.target.files?.length)
                            on_files(e.target.files); e.target.value = ''; } })] })] }));
}
//# sourceMappingURL=file_upload_zone.js.map