"use client" import { Badge } from "@/ui/badge" import { Button } from "@/ui/button" import { GlassMenuEffect } from "@/ui/glass-effect" import { Brain, Calendar, ExternalLink, FileText, Hash, X } from "lucide-react" import { motion } from "motion/react" import { memo } from "react" import { GoogleDocs, GoogleDrive, GoogleSheets, GoogleSlides, MicrosoftExcel, MicrosoftOneNote, MicrosoftPowerpoint, MicrosoftWord, NotionDoc, OneDrive, PDF, } from "@/assets/icons" import { HeadingH3Bold } from "@/ui/heading" import type { DocumentWithMemories, MemoryEntry } from "@/types" import type { NodeDetailPanelProps } from "@/types" import * as styles from "./node-detail-panel.css" const formatDocumentType = (type: string) => { // Special case for PDF if (type.toLowerCase() === "pdf") return "PDF" // Replace underscores with spaces and capitalize each word return type .split("_") .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(" ") } const getDocumentIcon = (type: string) => { const iconProps = { className: "w-5 h-5 text-slate-300" } switch (type) { 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 default: { /*@ts-ignore */ } return } } export const NodeDetailPanel = memo(function NodeDetailPanel({ node, onClose, variant = "console", }: NodeDetailPanelProps) { if (!node) return null const isDocument = node.type === "document" const data = node.data return ( {/* Glass effect background */}
{isDocument ? ( getDocumentIcon((data as DocumentWithMemories).type ?? "") ) : ( // @ts-ignore )} {isDocument ? "Document" : "Memory"}
{isDocument ? ( <>
Title

{(data as DocumentWithMemories).title || "Untitled Document"}

{(data as DocumentWithMemories).summary && (
Summary

{(data as DocumentWithMemories).summary}

)}
Type

{formatDocumentType( (data as DocumentWithMemories).type ?? "", )}

Memory Count

{(data as DocumentWithMemories).memoryEntries.length} memories

{((data as DocumentWithMemories).url || (data as DocumentWithMemories).customId) && ( )} ) : ( <>
Memory

{(data as MemoryEntry).memory}

{(data as MemoryEntry).isForgotten && ( Forgotten )} {(data as MemoryEntry).forgetAfter && (

Expires:{" "} {(data as MemoryEntry).forgetAfter ? new Date( (data as MemoryEntry).forgetAfter!, ).toLocaleDateString() : ""}{" "} {"forgetReason" in data && (data as any).forgetReason ? `- ${(data as any).forgetReason}` : null}

)}
Space

{(data as MemoryEntry).spaceId || "Default"}

)}
{/* @ts-ignore */} {new Date(data.createdAt).toLocaleDateString()} {/* @ts-ignore */} {node.id}
) }) NodeDetailPanel.displayName = "NodeDetailPanel"