import React, { useState } from 'react'; import { Globe, FileText, Copy, Check, ExternalLink } from 'lucide-react'; import type { Source } from '../../types'; interface SourceCardProps { source: Source; } export const SourceCard: React.FC = ({ source }) => { const [copied, setCopied] = useState(false); const [expanded, setExpanded] = useState(false); const handleCopy = async () => { await navigator.clipboard.writeText(source.content); setCopied(true); setTimeout(() => setCopied(false), 2000); }; const getIcon = () => { return source.type === 'web' ? ( ) : ( ); }; const getTypeLabel = () => { return source.type === 'web' ? 'Web' : 'Document'; }; const formatReference = (ref: string) => { if (ref.startsWith('http')) { try { const url = new URL(ref); return url.hostname + url.pathname; } catch { return ref; } } return ref; }; return (
setExpanded(!expanded)} className="p-3 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors" >
{getIcon()}
{source.title} {getTypeLabel()}

{formatReference(source.reference)}

{expanded && (

{source.content}

)}
); };