"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.styleguidePrompts = void 0;
const chalk_1 = __importDefault(require("chalk"));
const LANGUAGE_REGEXP = /^(([a-z]{2}-[A-Z]{2})|([a-z]{2}))$/;
const DEFAULT_LANGUAGE = 'da-DK';
/**
 * The subset of CLI prompts for the styleguide app
 */
exports.styleguidePrompts = [
    {
        type: 'input',
        name: 'language',
        message: 'Which additional language do you want to support (en is already included and required)?',
        default: DEFAULT_LANGUAGE,
        validate: (input) => {
            if (!LANGUAGE_REGEXP.test(input)) {
                console.error(chalk_1.default.red(`\n${input} is not a valid code; you may use language identifier, for example 'en',\nor you can add country code, for example 'US'. The language code is then 'en-US'.`));
                return false;
            }
            else if (input === 'en') {
                console.error(chalk_1.default.red(`\nen is included by default. \nYou ${chalk_1.default.italic('may')} however add an en-* locale, for example 'en-UK'.`));
                return false;
            }
            return true;
        },
        when: (answers) => {
            if (answers.yes && !answers.language) {
                answers.language = DEFAULT_LANGUAGE;
            }
            return !answers.language;
        },
    },
];
