import { DocumentFileIcon, fileSizeText } from '@deepseek-ai/dsh-client-ui-primitives' import css from './FileCard.module.css' /** Localized strings consumed by one pending-file card. */ export interface FileCardLabels { /** Card body announcement, e.g. "Pending file {name}". */ readonly label: string /** Remove-button label. */ readonly remove: string /** Status line while the upload is in flight. */ readonly uploading: string /** Status line and retry affordance after a failed upload. */ readonly failed: string /** Retry-button label. */ readonly retry: string } /** Upload display state resolved by the owner. */ export type FileCardState = 'uploading' | 'ready' | 'error' function extensionOf(name: string): string { const dot = name.lastIndexOf('.') if (dot <= 0 || dot === name.length - 1) return '' return name.slice(dot + 1).toUpperCase().slice(0, 8) } /** One pending generic-file card: name, size or upload status, remove, retry. */ export function FileCard({ name, bytes, state, progress, labels, onRemove, onRetry, }: { name: string bytes: number state: FileCardState progress?: number labels: FileCardLabels onRemove: () => void onRetry: () => void }) { const extension = extensionOf(name) const meta = state === 'uploading' ? labels.uploading : state === 'error' ? labels.failed : [extension, fileSizeText(bytes)].filter(part => part !== '').join(' ') const retryable = state === 'error' return (