export type AttachmentSourceType = 'image' | 'audio' | 'video' | 'document' export type DocumentIconType = | 'pdf' | 'doc' | 'xls' | 'csv' | 'ppt' | 'zip' | 'text' | 'markdown' | 'generic' const DOCUMENT_ICON_PATTERNS: Array<[RegExp, DocumentIconType]> = [ [/pdf/, 'pdf'], [/wordprocessingml|msword|\.doc/, 'doc'], [/spreadsheetml|ms-excel|\.xls/, 'xls'], [/csv/, 'csv'], [/presentationml|ms-powerpoint|\.ppt/, 'ppt'], [/zip|x-rar|x-7z|x-tar|x-gzip/, 'zip'], [/plain|rtf/, 'text'], [/markdown/, 'markdown'], ] export function getSourceType(mimeType: string): AttachmentSourceType { if (mimeType.startsWith('video/')) return 'video' if (mimeType.startsWith('audio/')) return 'audio' if (mimeType.startsWith('image/')) return 'image' return 'document' } export function getDocumentIconType(mimeType: string): DocumentIconType { const match = DOCUMENT_ICON_PATTERNS.find(([pattern]) => pattern.test(mimeType) ) return match ? match[1] : 'generic' }