import { MCPIcon } from "@/components/menu" import { colors } from "@repo/ui/memory-graph/constants" import { GoogleDocs, MicrosoftWord, NotionDoc, GoogleDrive, GoogleSheets, GoogleSlides, OneDrive, MicrosoftOneNote, MicrosoftPowerpoint, MicrosoftExcel, } from "@ui/assets/icons" import { Globe } from "lucide-react" import { useState } from "react" const getFaviconUrl = (url: string): string => { try { const domain = new URL(url).hostname return `https://www.google.com/s2/favicons?domain=${domain}&sz=32` } catch { return "" } } const FaviconIcon = ({ url, className, iconProps, }: { url: string className: string iconProps: { className: string; style: { color: string } } }) => { const [hasError, setHasError] = useState(false) const faviconUrl = getFaviconUrl(url) if (hasError || !faviconUrl) { return } return ( Website favicon setHasError(true)} /> ) } const PDFIcon = ({ className }: { className: string }) => { return ( PDF Icon ) } const YouTubeIcon = ({ className }: { className: string }) => { return ( YouTube Icon ) } const TextDocumentIcon = ({ className }: { className: string }) => { return ( Text Document Icon ) } export const getDocumentIcon = ( type: string, className: string, source?: string, url?: string, ) => { const iconProps = { className, style: { color: colors.text.muted }, } if (source === "mcp") { return } if (url?.includes("youtube.com") || url?.includes("youtu.be")) { return } if ( type === "webpage" || type === "url" || (url && (type === "unknown" || !type)) ) { if (url) { return ( ) } return } switch (type) { case "tweet": return 𝕏 case "google_doc": return case "google_sheet": return case "google_slide": return case "google_drive": return case "notion": case "notion_doc": return case "word": case "microsoft_word": return case "excel": case "microsoft_excel": return case "powerpoint": case "microsoft_powerpoint": return case "onenote": case "microsoft_onenote": return case "onedrive": return case "pdf": return case "youtube": case "video": return default: return } }