import type { ReactNode } from "react"; function JsonString({ value }: { value: string }) { return "{value}"; } function JsonValue({ value, indent }: { value: unknown; indent: number }): ReactNode { const pad = indent * 0.5; if (value === null) { return null; } if (typeof value === "boolean") { return {value ? "true" : "false"}; } if (typeof value === "number") { return {String(value)}; } if (typeof value === "string") { return ; } if (Array.isArray(value)) { if (value.length === 0) { return []; } return ( {"["}
{value.map((item, index) => ( {index < value.length - 1 ? "," : ""} ))} {"]"}
); } if (typeof value === "object") { const entries = Object.entries(value as Record); if (entries.length === 0) { return {"{}"}; } return ( {"{"}
{entries.map(([key, child], index) => ( "{key}" : {index < entries.length - 1 ? "," : ""} ))} {"}"}
); } return {String(value)}; } export function tryParseJsonObject(raw: string): unknown | null { const trimmed = raw.trim(); if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) { return null; } try { return JSON.parse(trimmed) as unknown; } catch { return null; } } export function JsonLogBody({ raw }: { raw: string }) { const parsed = tryParseJsonObject(raw); if (parsed === null) { return {raw}; } return (
); }