import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import { DiffPatchBlock } from './DiffPatchBlock.js';
const INLINE_DIFF_MAX_VISIBLE_LINES = 80;
const approvalStatusColors = {
    approved: 'green',
    denied: 'red',
    requested: 'yellow',
};
const editActionLabels = {
    create: 'created',
    delete: 'deleted',
    replace: 'edited',
    update: 'edited',
};
// Owns cli-v2 presentation for persisted turn activity blocks. The activity
// facts come from core/API metadata; this component only chooses terminal
// labels, colors, and inline diff limits.
export function ConversationTurnActivityBlock({ expanded, item, }) {
    return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Text, { children: [_jsx(Text, { color: "cyan", children: "Agent tool activities" }), _jsxs(Text, { dimColor: true, children: [" \u00B7 ", formatActivityCount(item.activities.length)] }), _jsx(Text, { dimColor: true, children: expanded ? ' · /a to collapse' : ' · /a to expand' })] }), expanded ? (_jsx(Box, { flexDirection: "column", marginTop: 1, paddingLeft: 2, children: item.activities.map((activity) => (_jsx(ActivityBlock, { activity: activity }, activity.id))) })) : null] }));
}
function ActivityBlock({ activity }) {
    if (activity.type === 'approval') {
        return _jsx(ApprovalActivityBlock, { activity: activity });
    }
    return _jsx(EditDiffActivityBlock, { activity: activity });
}
function ApprovalActivityBlock({ activity }) {
    if (activity.type !== 'approval') {
        return null;
    }
    return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { children: [_jsx(Text, { bold: true, children: "Approval" }), _jsx(Text, { dimColor: true, children: " \u00B7 " }), _jsx(Text, { color: approvalStatusColors[activity.status], children: activity.status }), _jsx(ActivityStep, { step: activity.step })] }), _jsxs(Text, { children: [_jsx(Text, { dimColor: true, children: "tool " }), _jsx(Text, { children: activity.tool })] }), _jsx(Text, { children: activity.summary }), activity.command ? (_jsxs(Text, { children: [_jsx(Text, { dimColor: true, children: "command " }), _jsx(Text, { children: activity.command })] })) : null, activity.reason ? _jsx(Text, { dimColor: true, children: activity.reason }) : null] }));
}
function EditDiffActivityBlock({ activity }) {
    if (activity.type !== 'edit_diff') {
        return null;
    }
    return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { children: [_jsx(Text, { bold: true, children: "Edit diff" }), _jsx(Text, { dimColor: true, children: " \u00B7 " }), _jsx(Text, { color: "cyan", children: activity.path }), _jsx(Text, { dimColor: true, children: formatEditMeta(activity.action) }), _jsx(ActivityStep, { step: activity.step })] }), _jsx(DiffPatchBlock, { id: activity.id, maxVisibleLines: INLINE_DIFF_MAX_VISIBLE_LINES, patch: activity.patch ?? '', truncated: activity.truncated })] }));
}
function formatActivityCount(count) {
    return count === 1 ? '1 item' : `${count} items`;
}
function ActivityStep({ step }) {
    return typeof step === 'number' ? _jsxs(Text, { dimColor: true, children: [" \u00B7 step ", step] }) : null;
}
function formatEditMeta(action) {
    if (!action) {
        return '';
    }
    return ` · ${editActionLabels[action] ?? action}`;
}
//# sourceMappingURL=ConversationTurnActivityBlock.js.map