import {
    FileArchive,
    FileAudio,
    FileImage,
    FileQuestion,
    FileSpreadsheet,
    FileText,
    FileVideo,
    type LucideProps,
} from "lucide-react";

interface FileIconProps extends LucideProps {
    contentType: string;
    className?: string;
}

export function FileIcon({ contentType, className, ...props }: FileIconProps) {
    const commonProps = { className: className ?? "h-5 w-5", ...props };

    if (contentType.startsWith("image/")) {
        return <FileImage {...commonProps} />;
    }
    if (contentType.startsWith("audio/")) {
        return <FileAudio {...commonProps} />;
    }
    if (contentType.startsWith("video/")) {
        return <FileVideo {...commonProps} />;
    }
    if (contentType === "application/pdf") {
        return <FileText {...commonProps} />;
    }
    if (
        contentType.startsWith("application/vnd.ms-excel") ||
        contentType.startsWith(
            "application/vnd.openxmlformats-officedocument.spreadsheetml",
        )
    ) {
        return <FileSpreadsheet {...commonProps} />; // Could use a specific Excel icon if available/desired
    }
    if (
        contentType.startsWith("application/msword") ||
        contentType.startsWith(
            "application/vnd.openxmlformats-officedocument.wordprocessingml",
        )
    ) {
        return <FileText {...commonProps} />;
    }
    if (
        contentType.startsWith("application/vnd.ms-powerpoint") ||
        contentType.startsWith(
            "application/vnd.openxmlformats-officedocument.presentationml",
        )
    ) {
        return <FileText {...commonProps} />;
    }
    if (
        contentType === "application/zip" ||
        contentType === "application/x-rar-compressed" ||
        contentType === "application/x-7z-compressed" ||
        contentType === "application/gzip" ||
        contentType === "application/x-tar"
    ) {
        return <FileArchive {...commonProps} />;
    }
    if (contentType.startsWith("text/")) {
        return <FileText {...commonProps} />;
    }
    return <FileQuestion {...commonProps} />; // Default for unknown types
}
