import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { formatCost, formatLatency, formatSessionTokens, formatSpeed, getModelHint, shortenMiddle } from "../format.js";
import { modePermissionLabel } from "../modes.js";
export function Header(props) {
    const modelHint = getModelHint(props.model);
    const stateColor = workStateColor(props.workState);
    const hostLabel = props.provider === "ollama" ? props.activeHost?.host.deviceName ?? "ollama" : `${props.provider} api`;
    return (_jsxs(Box, { borderStyle: "round", borderColor: stateColor, flexDirection: "column", marginBottom: 1, paddingX: 1, children: [_jsxs(Box, { justifyContent: "space-between", children: [_jsxs(Text, { color: "cyan", bold: true, children: ["PatchPilot ", _jsx(Text, { color: "gray", children: "agent workspace" })] }), _jsx(Text, { color: stateColor, children: formatWorkState(props.workState) })] }), _jsxs(Text, { color: modelHint.color, wrap: "truncate", children: [props.provider, "/", shortenMiddle(props.model, 34), " ", _jsx(Text, { color: "gray", children: "on" }), " ", shortenMiddle(hostLabel, 20), " ", _jsx(Text, { color: "gray", children: "mode" }), " ", _jsx(Text, { color: modeColor(props.agentMode), children: formatMode(props.agentMode) }), " ", _jsx(Text, { color: "gray", children: "write" }), " ", _jsx(Text, { color: permissionColor(props.agentMode, props.allowWrite), children: modePermissionLabel(props.agentMode, "write", props) }), " ", _jsx(Text, { color: "gray", children: "shell" }), " ", _jsx(Text, { color: permissionColor(props.agentMode, props.allowShell), children: modePermissionLabel(props.agentMode, "shell", props) })] }), _jsxs(Text, { color: "gray", wrap: "truncate", children: [shortenMiddle(props.status, 58), "  ", formatSessionTokens(props.sessionTelemetry), "  ", formatCost(props.sessionTelemetry.estimatedCostUsd), "  ", formatSpeed(props.telemetry), " ", formatLatency(props.telemetry)] })] }));
}
function formatMode(agentMode) {
    return agentMode === "bypass" ? "build+bypass" : agentMode;
}
function modeColor(agentMode) {
    if (agentMode === "bypass") {
        return "red";
    }
    return agentMode === "build" ? "yellow" : "green";
}
function permissionColor(agentMode, enabled = false) {
    if (enabled || agentMode === "bypass") {
        return "red";
    }
    return agentMode === "build" ? "yellow" : "gray";
}
function formatWorkState(workState) {
    return workState.replace(/_/g, " ");
}
function workStateColor(workState) {
    if (workState === "error") {
        return "red";
    }
    if (workState === "waiting_approval" || workState === "editing" || workState === "verifying") {
        return "yellow";
    }
    if (workState === "done" || workState === "idle") {
        return "green";
    }
    return "cyan";
}
//# sourceMappingURL=Header.js.map