"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseCatalogArgs = parseCatalogArgs;
const catalog_1 = require("../../i18n/catalog");
function parseCatalogArgs(args, locale = catalog_1.DEFAULT_APP_LOCALE) {
    const [action, ...rest] = args;
    if (!action) {
        throw new Error((0, catalog_1.translate)(locale, "cli.parser.catalog.usage"));
    }
    switch (action) {
        case "topics":
            return parseCatalogTopicsArgs(rest, locale);
        default:
            throw new Error((0, catalog_1.translate)(locale, "cli.parser.catalog.unknownCommand", { action }));
    }
}
function parseCatalogTopicsArgs(args, locale) {
    const [action, ...rest] = args;
    if (!action) {
        throw new Error((0, catalog_1.translate)(locale, "cli.parser.catalog.topics.usage"));
    }
    switch (action) {
        case "list":
            return parseCatalogTopicsListArgs(rest, locale);
        default:
            throw new Error((0, catalog_1.translate)(locale, "cli.parser.catalog.topics.unknownCommand", {
                action,
            }));
    }
}
function parseCatalogTopicsListArgs(args, locale) {
    for (const token of args) {
        throw new Error((0, catalog_1.translate)(locale, "cli.parser.catalog.topics.list.unknownOption", {
            token,
        }));
    }
    return { action: "topics", topicsAction: "list" };
}
