import { Badge } from "@repo/ui/components/badge" import { Card, CardContent, CardHeader } from "@repo/ui/components/card" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@repo/ui/components/alert-dialog" import { colors } from "@repo/ui/memory-graph/constants" import { Brain, ExternalLink, Trash2 } from "lucide-react" import { cn } from "@lib/utils" import { useState } from "react" import { formatDate, getPastelBackgroundColor, getSourceUrl, } from "../memories-utils" import { MCPIcon } from "../menu" import { analytics } from "@/lib/analytics" import type { DocumentsWithMemoriesResponseSchema } from "@repo/validation/api" import type { z } from "zod" type DocumentsResponse = z.infer type DocumentWithMemories = DocumentsResponse["documents"][0] interface NoteCardProps { document: DocumentWithMemories width: number activeMemories: Array<{ id: string; isForgotten?: boolean }> forgottenMemories: Array<{ id: string; isForgotten?: boolean }> onOpenDetails: (document: DocumentWithMemories) => void onDelete: (document: DocumentWithMemories) => void } export const NoteCard = ({ document, width, activeMemories, forgottenMemories, onOpenDetails, onDelete, }: NoteCardProps) => { const [isDialogOpen, setIsDialogOpen] = useState(false) return ( { if (!isDialogOpen) { analytics.documentCardClicked() onOpenDetails(document) } }} style={{ backgroundColor: getPastelBackgroundColor( document.id || document.title || "note", ), width: width, }} > e.stopPropagation()}> Delete Document Are you sure you want to delete this document and all its related memories? This action cannot be undone. { e.stopPropagation() }} > Cancel { e.stopPropagation() onDelete(document) }} > Delete

{document.title || "Untitled Document"}

{document.url && ( )}
{formatDate(document.createdAt)}
{document.content && (

{document.content}

)}
{activeMemories.length > 0 && ( {activeMemories.length}{" "} {activeMemories.length === 1 ? "memory" : "memories"} )} {forgottenMemories.length > 0 && ( {forgottenMemories.length} forgotten )} {document.source === "mcp" && ( MCP )}
) } NoteCard.displayName = "NoteCard"