'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState } from 'react';
import { ToolChip } from './tool-chip.js';
import { summarizeToolDetail } from './detect.js';
/**
 * Collapsed-by-default tool bubble. Clicking the chip expands a
 * pretty-printed view of the tool's input payload and — when a
 * paired Output was captured by the caller — the tool's stdout or
 * contents response in the same card.
 */
export function GenericToolBubble({ name, detail, parsed, outputBody }) {
    const [expanded, setExpanded] = useState(false);
    const summary = summarizeToolDetail(parsed, detail);
    const inputBody = parsed ? JSON.stringify(parsed, null, 2) : detail;
    const hasOutput = typeof outputBody === 'string' && outputBody.length > 0;
    return (_jsxs("div", { className: "inline-flex max-w-full flex-col", children: [_jsx(ToolChip, { name: name, summary: expanded ? null : summary, expanded: expanded, onToggle: () => setExpanded((v) => !v) }), expanded ? (_jsxs("div", { className: "border-border/60 bg-background/40 divide-border/40 flex max-w-full flex-col divide-y overflow-hidden rounded-md rounded-tl-none border", children: [inputBody ? (_jsxs("section", { className: "flex flex-col", children: [hasOutput ? (_jsx("span", { className: "text-muted-foreground/70 bg-muted/40 px-3 py-0.5 text-[9px] font-semibold tracking-wide uppercase", children: "Input" })) : null, _jsx("pre", { className: "text-foreground/70 max-w-full overflow-hidden px-3 py-2 font-mono text-[10px] leading-relaxed break-words whitespace-pre-wrap", children: inputBody })] })) : null, hasOutput ? (_jsxs("section", { className: "flex flex-col", children: [_jsx("span", { className: "text-muted-foreground/70 bg-muted/40 px-3 py-0.5 text-[9px] font-semibold tracking-wide uppercase", children: "Output" }), _jsx("pre", { className: "text-foreground/70 max-w-full overflow-hidden px-3 py-2 font-mono text-[10px] leading-relaxed break-words whitespace-pre-wrap", children: outputBody })] })) : null] })) : null] }));
}
