'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * Collapsible raw JSON display
 */
import { useState } from 'react';
import { HiChevronDown, HiChevronRight } from 'react-icons/hi';
import { cn } from '../../../utils/cn.js';
export function RawJsonViewer({ data, label = 'Raw JSON', default_open = false, className, }) {
    const [is_open, set_is_open] = useState(default_open);
    let json_string;
    try {
        json_string = typeof data === 'string' ? JSON.stringify(JSON.parse(data), null, 2) : JSON.stringify(data, null, 2);
    }
    catch {
        json_string = String(data);
    }
    return (_jsxs("div", { className: cn('border rounded-md', className), children: [_jsxs("button", { type: "button", onClick: () => set_is_open(!is_open), className: "flex items-center gap-2 w-full px-3 py-2 text-sm font-medium hover:bg-muted/50 transition-colors", children: [is_open ? _jsx(HiChevronDown, { className: "h-4 w-4" }) : _jsx(HiChevronRight, { className: "h-4 w-4" }), label] }), is_open && (_jsx("pre", { className: "px-3 pb-3 text-xs font-mono overflow-auto max-h-64 whitespace-pre-wrap break-words bg-muted/30", children: json_string }))] }));
}
//# sourceMappingURL=raw_json_viewer.js.map