import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { StatusBadge } from "../design/StatusBadge.js";
import { truncateCells } from "../design/textLayout.js";
export function McpParsingWarnings(props) {
    const model = mcpParsingWarningsModel(props.warnings);
    if (!model.visible)
        return null;
    const width = props.width ?? 96;
    return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { bold: true, color: "yellow", children: model.title }), model.warnings.map((warning, index) => (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(StatusBadge, { label: warning.severity, tone: warning.severity === "error" ? "error" : "warning" }), _jsxs(Text, { color: "gray", children: [" ", truncateCells(warning.message, Math.max(16, width - 12))] })] }), warning.suggestion ? (_jsx(Text, { color: "gray", children: truncateCells(`  -> ${warning.suggestion}`, Math.max(16, width - 4)) })) : null] }, `${warning.severity}-${index}`)))] }));
}
export function mcpParsingWarningsModel(warnings) {
    return {
        visible: warnings.length > 0,
        title: "MCP configuration warnings",
        warnings: warnings.map((warning) => ({
            severity: warning.severity,
            message: compact(warning.message),
            suggestion: warning.suggestion ? compact(warning.suggestion) : undefined,
        })),
    };
}
function compact(value) {
    return value.replace(/\s+/g, " ").trim();
}
