/** * JsonView — pretty-printed, syntax-highlighted JSON with a copy button. * No dependencies — a small tokenizer that hits the keys/strings/numbers/ * booleans we care about. Style-tunable via CSS variables so the palette * shifts cleanly between light and dark. */ import { useMemo, useState } from "react"; interface Props { data: unknown; maxHeight?: string; } export function JsonView({ data, maxHeight = "420px" }: Props) { const pretty = useMemo(() => JSON.stringify(data, null, 2), [data]); const [copied, setCopied] = useState(false); const onCopy = async () => { try { await navigator.clipboard.writeText(pretty); setCopied(true); setTimeout(() => setCopied(false), 1400); } catch { /* clipboard denied */ } }; return (