import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * File column component for data form fields
 * Shows a unified file icon: grey FaFileUpload when no files, blue FaFileAlt + count badge when files exist.
 * Matches the hazo_data_forms FileManagerButton visual pattern.
 */
import { useState } from 'react';
import { FaFileUpload, FaFileAlt } from 'react-icons/fa';
import { cn } from '../../../utils/cn.js';
const ICON_SIZE = 18;
const ICON_COLOR_DEFAULT = '#9ca3af'; // grey-400
const ICON_COLOR_WITH_FILES = '#0ea5e9'; // sky-500
const ICON_COLOR_HOVER = '#0284c7'; // sky-600
const BADGE_BG = '#0ea5e9'; // sky-500
const BADGE_TEXT = '#ffffff';
export function DataFormFileColumn({ doc_links, field_uploads, on_doc_link_click, on_upload_click, upload_enabled, mode, }) {
    const [is_hovered, set_is_hovered] = useState(false);
    const doc_count = doc_links?.length ?? 0;
    const upload_count = field_uploads?.length ?? 0;
    const total_count = doc_count + upload_count;
    const has_files = total_count > 0;
    if (!has_files && !upload_enabled)
        return null;
    // Determine click handler: use doc_link handler if available, otherwise upload handler
    const handle_click = has_files
        ? (on_doc_link_click || on_upload_click)
        : on_upload_click;
    // Icon logic: FaFileAlt (blue) when files exist, FaFileUpload (grey) when empty
    const IconComponent = has_files ? FaFileAlt : FaFileUpload;
    const icon_color = is_hovered
        ? ICON_COLOR_HOVER
        : has_files
            ? ICON_COLOR_WITH_FILES
            : ICON_COLOR_DEFAULT;
    const tooltip = has_files
        ? `${total_count} file${total_count !== 1 ? 's' : ''} attached`
        : 'Upload file';
    // In view mode with no files, show nothing
    if (mode === 'view' && !has_files)
        return null;
    return (_jsx("div", { className: cn('cls_data_form_file_col', 'flex items-center shrink-0 ml-1'), children: _jsxs("button", { type: "button", onClick: handle_click, onMouseEnter: () => set_is_hovered(true), onMouseLeave: () => set_is_hovered(false), disabled: !handle_click, className: cn('cls_file_manager_btn relative p-1 rounded transition-colors', handle_click ? 'cursor-pointer' : 'opacity-50 cursor-not-allowed'), style: is_hovered && handle_click ? { backgroundColor: 'rgba(0,0,0,0.06)' } : undefined, "aria-label": tooltip, title: tooltip, children: [_jsx(IconComponent, { size: ICON_SIZE, color: icon_color, className: "transition-colors" }), total_count > 0 && (_jsx("span", { className: "cls_file_count_badge absolute -top-1 -right-1 min-w-[16px] h-[16px] flex items-center justify-center rounded-full text-[10px] font-bold", style: {
                        backgroundColor: BADGE_BG,
                        color: BADGE_TEXT,
                    }, children: total_count > 9 ? '9+' : total_count }))] }) }));
}
//# sourceMappingURL=data_form_file_column.js.map