"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CliProvidersModule = void 0;
const common_1 = require("@nestjs/common");
const cli_credential_provider_service_1 = require("./lib/cli-credential-provider.service");
const ip_detection_1 = require("./lib/utils/ip-detection");
const cli_firewall_repository_1 = require("./lib/repositories/cli-firewall.repository");
const cli_vnet_repository_1 = require("./lib/repositories/cli-vnet.repository");
const vnet_provisioning_service_1 = require("./lib/services/vnet-provisioning.service");
const api_client_1 = require("./lib/api-client");
const config_storage_1 = require("./lib/config-storage");
const provider_core_module_1 = require("../../src/modules/providers/provider-core.module");
const common_module_1 = require("../../src/modules/common/common.module");
const hetzner_provider_module_1 = require("../../src/modules/providers/implementations/hetzner/hetzner-provider.module");
const scaleway_provider_module_1 = require("../../src/modules/providers/implementations/scaleway/scaleway-provider.module");
const provider_factory_1 = require("../../src/modules/providers/core/factories/provider.factory");
const firewall_provider_factory_1 = require("../../src/modules/providers/core/factories/firewall-provider.factory");
const dns_provider_factory_1 = require("../../src/modules/providers/core/factories/dns-provider.factory");
const cloud_provider_enum_1 = require("../../src/modules/providers/enums/cloud-provider.enum");
const dns_provider_enum_1 = require("../../src/modules/providers/enums/dns-provider.enum");
const hetzner_provider_service_1 = require("../../src/modules/providers/services/hetzner-provider.service");
const hetzner_firewall_service_1 = require("../../src/modules/providers/services/hetzner-firewall.service");
const hetzner_dns_service_1 = require("../../src/modules/providers/services/hetzner-dns.service");
const scaleway_provider_service_1 = require("../../src/modules/providers/implementations/scaleway/scaleway-provider.service");
const scaleway_firewall_service_1 = require("../../src/modules/providers/implementations/scaleway/scaleway-firewall.service");
const scaleway_dns_service_1 = require("../../src/modules/providers/implementations/scaleway/scaleway-dns.service");
const hetzner_bootstrap_seeder_service_1 = require("../../src/modules/providers/implementations/hetzner/hetzner-bootstrap-seeder.service");
const scaleway_bootstrap_seeder_service_1 = require("../../src/modules/providers/implementations/scaleway/scaleway-bootstrap-seeder.service");
const tokens_1 = require("../../src/modules/providers/core/tokens");
let CliProvidersModule = class CliProvidersModule {
};
exports.CliProvidersModule = CliProvidersModule;
exports.CliProvidersModule = CliProvidersModule = __decorate([
    (0, common_1.Global)(),
    (0, common_1.Module)({
        imports: [
            provider_core_module_1.ProviderCoreModule,
            common_module_1.CommonModule,
            hetzner_provider_module_1.HetznerProviderModule,
            scaleway_provider_module_1.ScalewayProviderModule,
        ],
        providers: [
            cli_credential_provider_service_1.CliCredentialProviderService,
            {
                provide: 'ICredentialProvider',
                useExisting: cli_credential_provider_service_1.CliCredentialProviderService,
            },
            {
                provide: provider_factory_1.ProviderFactory,
                useFactory: (hetzner, scaleway) => new provider_factory_1.ProviderFactory([
                    { provider: cloud_provider_enum_1.CloudProvider.HETZNER, service: hetzner },
                    { provider: cloud_provider_enum_1.CloudProvider.SCALEWAY, service: scaleway },
                ]),
                inject: [hetzner_provider_service_1.HetznerProviderService, scaleway_provider_service_1.ScalewayProviderService],
            },
            {
                provide: firewall_provider_factory_1.FirewallProviderFactory,
                useFactory: (hetzner, scaleway) => new firewall_provider_factory_1.FirewallProviderFactory([
                    { provider: cloud_provider_enum_1.CloudProvider.HETZNER, service: hetzner },
                    { provider: cloud_provider_enum_1.CloudProvider.SCALEWAY, service: scaleway },
                ]),
                inject: [hetzner_firewall_service_1.HetznerFirewallService, scaleway_firewall_service_1.ScalewayFirewallService],
            },
            {
                provide: dns_provider_factory_1.DnsProviderFactory,
                useFactory: (hetzner, scaleway) => new dns_provider_factory_1.DnsProviderFactory([
                    { provider: dns_provider_enum_1.DnsProvider.HETZNER, service: hetzner },
                    { provider: dns_provider_enum_1.DnsProvider.SCALEWAY, service: scaleway },
                ]),
                inject: [hetzner_dns_service_1.HetznerDnsService, scaleway_dns_service_1.ScalewayDnsService],
            },
            {
                provide: tokens_1.PROVIDER_BOOTSTRAP_SEEDER_REGISTRY,
                useFactory: (hetzner, scaleway) => [
                    { provider: cloud_provider_enum_1.CloudProvider.HETZNER, service: hetzner },
                    { provider: cloud_provider_enum_1.CloudProvider.SCALEWAY, service: scaleway },
                ],
                inject: [hetzner_bootstrap_seeder_service_1.HetznerBootstrapSeeder, scaleway_bootstrap_seeder_service_1.ScalewayBootstrapSeeder],
            },
            {
                provide: api_client_1.ApiClient,
                useFactory: () => {
                    const configStorage = new config_storage_1.ConfigStorage();
                    return new api_client_1.ApiClient({
                        baseUrl: configStorage.getApiUrl() ?? '',
                        apiKey: configStorage.getApiKey(),
                    });
                },
            },
            ip_detection_1.IpDetectionService,
            cli_firewall_repository_1.CliFirewallRepository,
            cli_vnet_repository_1.CliVnetRepository,
            vnet_provisioning_service_1.VnetProvisioningService,
        ],
        exports: [
            provider_core_module_1.ProviderCoreModule,
            cli_credential_provider_service_1.CliCredentialProviderService,
            'ICredentialProvider',
            hetzner_provider_module_1.HetznerProviderModule,
            scaleway_provider_module_1.ScalewayProviderModule,
            provider_factory_1.ProviderFactory,
            firewall_provider_factory_1.FirewallProviderFactory,
            dns_provider_factory_1.DnsProviderFactory,
            tokens_1.PROVIDER_BOOTSTRAP_SEEDER_REGISTRY,
            api_client_1.ApiClient,
            ip_detection_1.IpDetectionService,
            cli_firewall_repository_1.CliFirewallRepository,
            cli_vnet_repository_1.CliVnetRepository,
            vnet_provisioning_service_1.VnetProvisioningService,
        ],
    })
], CliProvidersModule);
