import { GATE_COMMAND_NAMES } from "./gate-commands.js";
const UPDATE_CHECK_EXEMPT_COMMANDS = Object.freeze([
    "doctor",
    "health",
    "standards-proof",
    "sync",
    "ui",
    "update",
    "version",
]);
/**
 * Register the root update check that precedes non-maintenance actions.
 * @param program - Commander program to mutate
 * @param dependencies - Update-check collaborators
 */
export function addUpdateCheckHook(program, dependencies) {
    program.hook("preAction", async (_thisCommand, actionCommand) => {
        if (isUpdateCheckExempt(actionCommand))
            return;
        if (program.opts().updateCheck === false)
            return;
        const result = await dependencies.runUpdateCheck();
        dependencies.printUpdateWarning(result);
    });
}
/**
 * Determine whether an action intentionally bypasses the root update warning.
 * @param actionCommand - Matched Commander action
 * @returns Whether the action owns a maintenance or provider-specific path
 */
function isUpdateCheckExempt(actionCommand) {
    return (actionCommand.parent?.name() === "kane" ||
        UPDATE_CHECK_EXEMPT_COMMANDS.includes(actionCommand.name()) ||
        GATE_COMMAND_NAMES.includes(actionCommand.name()));
}
//# sourceMappingURL=update-check-hook.js.map