"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION_MANAGER_SUBCOMMANDS = void 0;
exports.createDeferredVersionCommandContract = createDeferredVersionCommandContract;
exports.createNetworkApprovalRequiredContract = createNetworkApprovalRequiredContract;
exports.toVersionCommandContractData = toVersionCommandContractData;
exports.renderVersionCommandContract = renderVersionCommandContract;
const errors_1 = require("../errors");
const output_1 = require("../output");
exports.VERSION_MANAGER_SUBCOMMANDS = [
    "install",
    "list",
    "use",
    "pin",
    "current",
    "uninstall",
    "doctor",
    "check",
    "alias"
];
function createDeferredVersionCommandContract(options) {
    return {
        command: options.command,
        operation: options.operation,
        state: "deferred",
        exitCode: errors_1.RuntimeExitCode.ERROR,
        summary: options.summary ?? "This version-manager operation is declared but not implemented in this phase.",
        details: options.details ?? [
            "The command surface is reserved for the Day Shift version manager.",
            "The implementation is deferred to a later version-manager phase."
        ],
        recovery: options.recovery ?? [
            "Use existing Day Shift commands for current workflows.",
            "Continue with the planned version-manager install, selection, or diagnostics phase before relying on this operation."
        ],
        noWrite: true,
        networkAttempted: options.networkAttempted ?? false
    };
}
function createNetworkApprovalRequiredContract() {
    return {
        command: "version check",
        operation: "check",
        state: "requires-network-approval",
        exitCode: errors_1.RuntimeExitCode.USAGE,
        summary: "Version availability checks require explicit --network approval.",
        details: [
            "Normal version-manager operations must stay offline-capable.",
            "Rerun with --network only when a Day Shift-owned availability check is intended."
        ],
        recovery: [
            "Run day-shift version check --network after explicit approval.",
            "Use local installed-version state for offline workflows."
        ],
        noWrite: true,
        networkAttempted: false
    };
}
function toVersionCommandContractData(contract) {
    return {
        command: contract.command,
        operation: contract.operation,
        state: contract.state,
        exit_code: contract.exitCode,
        summary: contract.summary,
        details: contract.details,
        recovery: contract.recovery,
        no_write: contract.noWrite,
        network_attempted: contract.networkAttempted
    };
}
function renderVersionCommandContract(contract, _format) {
    return [
        (0, output_1.renderTerminalSection)({
            heading: "Day Shift version manager",
            headingStyle: "title",
            fields: [
                { label: "Command", value: contract.command },
                { label: "Operation", value: contract.operation },
                { label: "State", value: contract.state },
                { label: "Network attempted", value: contract.networkAttempted },
                { label: "Exit code", value: contract.exitCode }
            ],
            lines: [contract.summary]
        }),
        (0, output_1.renderTerminalCompactList)({
            heading: "Details",
            headingStyle: "section",
            entries: contract.details.map((line) => ({ label: line }))
        }),
        (0, output_1.renderTerminalCompactList)({
            heading: "Recovery",
            headingStyle: "section",
            entries: contract.recovery.map((line) => ({ label: line }))
        }),
        (0, output_1.renderTerminalBoundary)({
            kind: "no-write-failure",
            reason: contract.state
        })
    ].join("\n\n");
}
