'use client' import { Dialog, DialogContent, DialogTitle, DialogDescription } from '@/components/ui/dialog' import { Button } from '@/components/ui/button' import { Columns2, GitMerge, X, ExternalLink } from 'lucide-react' import { cn } from '@/lib/utils' import { Note } from '@/lib/types' import { useLanguage } from '@/lib/i18n/LanguageProvider' interface ComparisonModalProps { isOpen: boolean onClose: () => void notes: Array> similarity?: number onMergeNotes?: (noteIds: string[]) => void } function stripHtml(html: string): string { return html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim() } function openNoteInNewTab(noteId: string) { window.open(`/home?openNote=${encodeURIComponent(noteId)}`, '_blank', 'noopener,noreferrer') } export function ComparisonModal({ isOpen, onClose, notes, similarity, onMergeNotes, }: ComparisonModalProps) { const { t } = useLanguage() const getNoteColor = (index: number) => { const colors = [ 'border-indigo-200/80 dark:border-indigo-800/80', 'border-purple-200/80 dark:border-purple-800/80', 'border-emerald-200/80 dark:border-emerald-800/80', ] return colors[index % colors.length] } const getTitleColor = (index: number) => { const colors = [ 'text-indigo-700 dark:text-indigo-300', 'text-purple-700 dark:text-purple-300', 'text-emerald-700 dark:text-emerald-300', ] return colors[index % colors.length] } const maxModalWidth = notes.length === 2 ? 'max-w-6xl' : 'max-w-7xl' const similarityPercentage = similarity ? Math.round(similarity * 100) : 0 return (
{t('memoryEcho.comparison.title')} {similarityPercentage > 0 ? t('memoryEcho.comparison.similarityInfo', { similarity: similarityPercentage }) : t('memoryEcho.comparison.subtitle')}

{t('memoryEcho.comparison.stayOnCurrentNote')}

{similarityPercentage >= 80 && (

{t('memoryEcho.comparison.highSimilarityInsight')}

)}
{notes.map((note, index) => { const title = note.title || t('memoryEcho.comparison.untitled') const plainContent = stripHtml(note.content || '') return (

{title}

{plainContent}
{note.id && (
)}
) })}
{onMergeNotes && notes.length >= 2 && ( )}
) }