import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { ApprovalGateCard } from "./ApprovalGateCard.js";
import { useApprovals } from "../hooks/useApprovals.js";
export function PendingGatePanel(props) {
    const gates = props.gates ?? useApprovals(props.state, "pending", 20);
    const visibleGates = currentSessionPendingGates(gates, props.sessionStartedAtMs);
    if (visibleGates.length === 0)
        return null;
    const currentGate = visibleGates[0];
    if (!currentGate)
        return null;
    return (_jsxs(Box, { flexDirection: "column", paddingX: 1, marginTop: 1, children: [_jsx(ApprovalGateCard, { gate: currentGate, projectPath: props.projectPath, selectedDecisionIndex: props.selectedDecisionIndex }), visibleGates.length > 1 ? (_jsx(Box, { paddingLeft: 1, children: _jsx(Text, { color: "gray", children: pendingGateQueueHint(visibleGates.length - 1) }) })) : null] }));
}
export function currentSessionPendingGates(gates, sessionStartedAtMs) {
    if (sessionStartedAtMs === undefined)
        return gates;
    return gates.filter((gate) => gate.createdAtMs >= sessionStartedAtMs);
}
export function pendingGateQueueHint(count) {
    return `${count} more current-session request(s) are queued. Finish the highlighted request first.`;
}
