1import { Download, FileSpreadsheet, FileText, Image as ImageIcon, Share2 } from 'lucide-react';2import type { Artifact } from '@/lib/types';3import { downloadFile, shareFile } from '@/lib/api';45const icon = (t: string) => (t === 'xlsx' ? FileSpreadsheet : t === 'image' ? ImageIcon : FileText);67export function ArtifactChips({ artifacts }: { artifacts?: Artifact[] }) {8 const list = (artifacts || []).filter((a) => a.file_id && a.type !== 'quiz' && a.type !== 'sources');9 if (!list.length) return null;10 const canShare = typeof navigator !== 'undefined' && !!navigator.share;11 return (12 <div className="flex flex-wrap gap-2">13 {list.map((a) => {14 const Icon = icon(a.type);15 return (16 <div key={a.file_id} className="inline-flex items-center rounded-xl border border-neutral-line bg-white overflow-hidden">17 <button onClick={() => downloadFile(a.file_id!, a.filename || 'fichier')} className="inline-flex items-center gap-2 px-3 min-h-[44px] text-sm hover:bg-neutral-surface">18 <Icon size={16} className="text-uqo-blue" /> <span className="max-w-[200px] truncate">{a.filename}</span> <Download size={14} className="text-neutral-muted" />19 </button>20 {canShare && (21 <button onClick={() => shareFile(a.file_id!, a.filename || 'fichier')} className="px-3 min-h-[44px] border-l border-neutral-line hover:bg-neutral-surface" aria-label="Partager">22 <Share2 size={14} className="text-neutral-muted" />23 </button>24 )}25 </div>26 );27 })}28 </div>29 );30}31