import * as Lucide from '@lucide/svelte';

/**
 * Returns a Lucide icon component based on the provided file extension.
 * @param extension The file extension (e.g., 'pdf', 'jpg').
 * @returns The Lucide icon component.
 */
export function file_extension_icon_lucide(
    extension: string | undefined | null
): any {
    const ext = extension?.toLowerCase() || '';

    const icon_map: Record<string, any> = {
        pdf: Lucide.FileText,
        doc: Lucide.FileText,
        docx: Lucide.FileText,
        txt: Lucide.FileText,
        rtf: Lucide.FileText,

        xls: Lucide.FileSpreadsheet,
        xlsx: Lucide.FileSpreadsheet,
        csv: Lucide.FileSpreadsheet,

        png: Lucide.FileImage,
        jpg: Lucide.FileImage,
        jpeg: Lucide.FileImage,
        gif: Lucide.FileImage,
        webp: Lucide.FileImage,
        bmp: Lucide.FileImage,
        svg: Lucide.FileImage,

        mp3: Lucide.FileAudio,
        wav: Lucide.FileAudio,
        m4a: Lucide.FileAudio,
        flac: Lucide.FileAudio,
        aac: Lucide.FileAudio,
        aif: Lucide.FileAudio,
        aiff: Lucide.FileAudio,

        mp4: Lucide.FileVideo,
        mkv: Lucide.FileVideo,
        mov: Lucide.FileVideo,
        avi: Lucide.FileVideo,
        '3gp': Lucide.FileVideo,

        ppt: Lucide.Presentation,
        pptx: Lucide.Presentation,
        key: Lucide.Presentation,
        odp: Lucide.Presentation,

        zip: Lucide.FileArchive,
        '7z': Lucide.FileArchive,
        rar: Lucide.FileArchive,
        tar: Lucide.FileArchive,
        gz: Lucide.FileArchive,

        json: Lucide.FileJson,

        html: Lucide.FileCode,
        htm: Lucide.FileCode,
        js: Lucide.FileCode,
        ts: Lucide.FileCode,
        css: Lucide.FileCode,
        php: Lucide.FileCode
    };

    return icon_map[ext] || Lucide.File;
}
