import type { HTMLAttributes } from "react"; import { cn } from "../lib/cn.js"; /** One presentational diff line; the caller owns parsing. */ export type DiffViewLine = Readonly<{ kind: "add" | "context" | "file" | "hunk" | "remove"; text: string; }>; /** Props accepted by DiffView. */ export type DiffViewProps = { lines: readonly DiffViewLine[]; /** Lines the caller omitted, shown as a trailing note. */ hiddenLines?: number; } & Omit, "children">; const markers = { add: "+", context: " ", file: "", hunk: "@@", remove: "-", } satisfies Record; /** A compact monospace diff with add/remove/hunk/file line tones. */ export function DiffView({ lines, hiddenLines = 0, className, ...props }: DiffViewProps) { return (
      {lines.map((line, index) => (
        
          
          {line.text}
          {"\n"}
        
      ))}
      {hiddenLines > 0 ? (
        
          … {String(hiddenLines)} more lines
        
      ) : null}
    
); }