import { diffLines } from 'diff'
import { useMemo } from 'react'
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'
import { usePointerFocusRing } from '@/hooks/usePointerFocusRing'
import { cn } from '@/lib/utils'
export function DiffView(props: {
oldString: string
newString: string
filePath?: string
variant?: 'preview' | 'inline'
}) {
const variant = props.variant ?? 'preview'
const { suppressFocusRing, onTriggerPointerDown, onTriggerKeyDown, onTriggerBlur } = usePointerFocusRing()
const stats = useMemo(() => {
const oldChars = props.oldString.length
const newChars = props.newString.length
const oldLabel = `${oldChars.toLocaleString()} chars`
const newLabel = `${newChars.toLocaleString()} chars`
return { oldChars, newChars, label: `old: ${oldLabel} → new: ${newLabel}` }
}, [props.oldString.length, props.newString.length])
const title = props.filePath ? props.filePath : 'Diff'
const subtitle = props.filePath ? stats.label : `Diff • ${stats.label}`
const DiffInline = (