"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.collectSpecStatus = collectSpecStatus;
exports.getRequestedSpecStatuses = getRequestedSpecStatuses;
const errors_1 = require("../../lib/errors");
const spec_registry_1 = require("../../lib/spec-registry");
function collectSpecStatus(value, previous) {
    previous.push(value);
    return previous;
}
function getRequestedSpecStatuses(commandInstance) {
    const requestedStatuses = commandInstance.opts?.().status;
    if (!Array.isArray(requestedStatuses)) {
        return [];
    }
    const blankStatusIndex = requestedStatuses.findIndex((status) => String(status).trim().length === 0);
    if (blankStatusIndex >= 0) {
        throw (0, errors_1.createUsageError)("Spec lifecycle status must be a non-empty value.", [`Received an empty --status value at position ${blankStatusIndex + 1}.`]);
    }
    return (0, spec_registry_1.normalizeSpecRegistryStatuses)(requestedStatuses);
}
