"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.COMMAND_AVAILABILITY_TOKENS = void 0;
exports.hasCommanderActionHandler = hasCommanderActionHandler;
exports.isCallableCommandDescriptor = isCallableCommandDescriptor;
exports.evaluateCommandExecutableEligibility = evaluateCommandExecutableEligibility;
exports.COMMAND_AVAILABILITY_TOKENS = [
    "callable",
    "reserved",
    "planned",
    "deprecated"
];
/**
 * Commander does not currently expose a public action-handler inspector. Keep
 * the private-property dependency isolated here so an upstream change has one
 * tested repair point.
 */
function hasCommanderActionHandler(commandNode) {
    return typeof commandNode?._actionHandler === "function";
}
function isCallableCommandDescriptor(descriptor) {
    return descriptor?.availability === "callable";
}
function evaluateCommandExecutableEligibility(descriptor, runtimeActionHandler) {
    const descriptorDeclaredCallable = isCallableCommandDescriptor(descriptor);
    if (descriptor === null || descriptor === undefined) {
        return Object.freeze({
            availability: null,
            descriptorDeclaredCallable: false,
            runtimeActionHandler,
            executable: false,
            reason: "missing-descriptor"
        });
    }
    if (!descriptorDeclaredCallable) {
        return Object.freeze({
            availability: descriptor.availability,
            descriptorDeclaredCallable: false,
            runtimeActionHandler,
            executable: false,
            reason: "descriptor-noncallable"
        });
    }
    return Object.freeze({
        availability: descriptor.availability,
        descriptorDeclaredCallable: true,
        runtimeActionHandler,
        executable: runtimeActionHandler,
        reason: runtimeActionHandler ? "executable-intersection" : "missing-action-handler"
    });
}
