"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.prompter = void 0;
const isEnabled_1 = __importDefault(require("./utils/isEnabled"));
const parseArgs_1 = __importDefault(require("./utils/parseArgs"));
const questionConfig_1 = require("./utils/questionConfig");
const runInteractiveQuestions_1 = __importDefault(require("./utils/runInteractiveQuestions"));
const setBranch_1 = __importDefault(require("./utils/setBranch"));
const setCommit_1 = require("./utils/setCommit");
const setState_1 = __importDefault(require("./utils/setState"));
const prompter = (cz, commit) => {
    const run = () => __awaiter(void 0, void 0, void 0, function* () {
        const { cliAnswers, cliOptions, passThroughParams } = (0, parseArgs_1.default)();
        const state = (0, setState_1.default)(cliOptions);
        yield (0, isEnabled_1.default)(state);
        const options = {
            cliAnswers,
            cliOptions,
            passThroughParams,
            state,
        };
        switch (cliOptions.mode) {
            case questionConfig_1.TYPE_BRANCH:
                yield (0, runInteractiveQuestions_1.default)(state, cliAnswers, cliOptions);
                return (0, setBranch_1.default)(options);
                break;
            case questionConfig_1.TYPE_COMMIT:
            default: {
                yield (0, runInteractiveQuestions_1.default)(state, cliAnswers, cliOptions);
                const message = (0, setCommit_1.getCommitMessage)(state);
                return commit(message);
                break;
            }
        }
    });
    run();
};
exports.prompter = prompter;
//# sourceMappingURL=cz.js.map