"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockerError = exports.BlockerGate = void 0;
const chalk_1 = __importDefault(require("chalk"));
const QuestionGraphEngine_1 = require("./QuestionGraphEngine");
class BlockerGate {
    constructor(engine) {
        this.engine = engine || new QuestionGraphEngine_1.QuestionGraphEngine();
    }
    async requireUnblocked(context = "execution") {
        await this.engine.load();
        if (!this.engine.isCompilationBlocked())
            return;
        const blockers = this.engine.getBlockers();
        console.error(chalk_1.default.red.bold(`\n❌ COMPILATION BLOCKED: ${context} cannot proceed`));
        console.error(chalk_1.default.yellow(`   ${blockers.length} blocking question(s) must be answered first.`));
        console.error();
        for (const q of blockers) {
            console.error(`  ${chalk_1.default.red("✗")} ${chalk_1.default.bold(q.text)}`);
            if (q.context) {
                console.error(`    ${chalk_1.default.dim(q.context)}`);
            }
            if (q.options && q.options.length > 0) {
                console.error(`    ${chalk_1.default.dim("Options:")} ${q.options.map(o => o.label).join(", ")}`);
            }
            console.error(`    ${chalk_1.default.dim("Answer with:")} mycontext questions:answer ${q.id} <value>`);
        }
        console.error();
        throw new BlockerError(`${blockers.length} blocking question(s) must be answered before ${context}`);
    }
}
exports.BlockerGate = BlockerGate;
class BlockerError extends Error {
    constructor(message) {
        super(message);
        this.name = "BlockerError";
    }
}
exports.BlockerError = BlockerError;
//# sourceMappingURL=BlockerGate.js.map