"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listRepositoryHostProviderKinds = listRepositoryHostProviderKinds;
exports.getRepositoryHostProvider = getRepositoryHostProvider;
exports.requireRepositoryHostProvider = requireRepositoryHostProvider;
const catalog_1 = require("../../i18n/catalog");
const repository_host_provider_1 = require("../gitea/repository-host-provider");
const repository_host_provider_2 = require("../gitlab/repository-host-provider");
const repository_host_provider_3 = require("../github/repository-host-provider");
const provider_errors_1 = require("../provider-errors");
const REPOSITORY_HOST_PROVIDERS = [
    repository_host_provider_3.githubRepositoryHostProvider,
    repository_host_provider_1.giteaRepositoryHostProvider,
    repository_host_provider_2.gitlabRepositoryHostProvider,
];
const REPOSITORY_HOST_PROVIDER_BY_KIND = new Map(REPOSITORY_HOST_PROVIDERS.map((provider) => [provider.kind, provider]));
function listRepositoryHostProviderKinds() {
    return [...REPOSITORY_HOST_PROVIDER_BY_KIND.keys()];
}
function getRepositoryHostProvider(kind) {
    return REPOSITORY_HOST_PROVIDER_BY_KIND.get(kind);
}
function requireRepositoryHostProvider(kind, locale = catalog_1.DEFAULT_APP_LOCALE) {
    const provider = getRepositoryHostProvider(kind);
    if (!provider) {
        throw new provider_errors_1.UnsupportedProviderError("repositoryHost", kind, locale);
    }
    return provider;
}
