import inquirer from "inquirer";
import chalk from "chalk";
import { BACK_SIGNAL } from "../../utils/prompts.js";
export const validateRequired = (msg) => (v) => v.trim().length > 0 ? true : msg;
export const validateScore = (v) => {
    const num = Number(v);
    return num >= 0 && num <= 100 ? true : "Enter 0-100";
};
export const validateColonPair = (msg) => (v) => {
    const parts = v.split(":");
    return parts.length === 2 && parts[0].length > 0 && parts[1].length > 0
        ? true
        : msg;
};
export function backChoice() {
    return { name: chalk.dim("← Back"), value: BACK_SIGNAL };
}
export async function promptList(message, choices) {
    const { answer } = await inquirer.prompt([
        {
            type: "list",
            name: "answer",
            message,
            choices: [...choices, new inquirer.Separator(" "), backChoice()],
            loop: false,
        },
    ]);
    return answer === BACK_SIGNAL ? null : answer;
}
//# sourceMappingURL=shared.js.map