'use client' import { useTranslation } from 'react-i18next' import { Bookmark, ChevronRight, MessageSquare, Search, BookOpen, Video, FileQuestion, Calculator, FileText, Bot, } from 'lucide-react' import FavoriteContent from '@/components/notebook/NotebookFavoriteContent' import { FAVORITE_LABELS, favoriteKind } from '@/lib/favorite-content' export default function NoteFavoriteBlock({ title, markdown, sourceUrl, type, summary, metadata, expanded, onExpanded, onActivate, }: { title: string markdown: string sourceUrl: string type: string summary: string metadata: string expanded: boolean onExpanded: (open: boolean) => void onActivate?: () => void }) { const { t } = useTranslation() let meta: Record = {} try { const value = JSON.parse(metadata) if (value && typeof value === 'object' && !Array.isArray(value)) meta = value } catch { /* Legacy clips have no structured metadata. */ } const kind = favoriteKind(type, meta) const Icon = ( { chat: MessageSquare, tutorbot: Bot, research: Search, reading: BookOpen, video_learning: Video, question: FileQuestion, solve: Calculator, co_writer: FileText, } as Record )[kind] || Bookmark return (
{ onActivate?.() event.stopPropagation() }} onClick={event => event.stopPropagation()} > {expanded && (
)}
{sourceUrl && ( {t('Return to source')} )}
) }