'use client'; import { motion } from 'motion/react'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import FileTypeIcon from './FileTypeIcon'; import Badge from './Badge'; import { ChatMessage } from '@/lib/kb-data'; interface SourceCardProps { name: string; type: string; } function SourceCard({ name, type }: SourceCardProps) { const isFileType = ['PDF', 'DOC', 'DOCX', 'EXCEL', 'XLS', 'XLSX', 'CSV'].includes( type.toUpperCase() ); const getBadgeColor = (): 'danger' | 'success' | 'info' | 'purple' | 'neutral' => { switch (type.toUpperCase()) { case 'PDF': return 'danger'; case 'EXCEL': case 'XLS': return 'success'; case 'DOCX': return 'info'; case 'Q&A': return 'purple'; default: return 'neutral'; } }; return (
{children}
), strong: ({ children }) => ( {children} ), em: ({ children }) => {children}, a: ({ href, children }) => ( {children} ), ul: ({ children }) => ({children}), code: ({ className, children, ...props }) => { const isBlock = className?.startsWith('language-'); if (isBlock) { return (
{children}
);
}
return (
{children}
);
},
pre: ({ children }) => (
{children}
),
table: ({ children }) => (