import { FileText, Table2, Image as ImageIcon } from 'lucide-react' import type { Source } from '../types' interface SourceBadgesProps { sources: Source[] onBadgeClick?: (chunkId: number) => void } function SourceIcon({ type }: { type: string }) { switch (type) { case 'table': return case 'figure': return default: return } } export function SourceBadges({ sources, onBadgeClick }: SourceBadgesProps) { if (sources.length === 0) return null // Deduplicate by source_file + page const unique = sources.reduce((acc, s) => { const exists = acc.some( (a) => a.source_file === s.source_file && a.page === s.page && a.chunk_type === s.chunk_type ) if (!exists) acc.push(s) return acc }, []) return ( {unique.map((s) => ( onBadgeClick?.(s.chunk_id)} title={`${s.source_file} — ${s.section || `Page ${s.page + 1}`}`} > {s.source_file} {s.section ? s.section : `p.${s.page + 1}`} ))} ) }