// SPDX-License-Identifier: Apache-2.0
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
import { ComponentTypes } from './enumerations/component-types.js';
import { DeploymentPhase } from '../../../data/schema/model/remote/deployment-phase.js';
import { ComponentStateMetadataSchema } from '../../../data/schema/model/remote/state/component-state-metadata-schema.js';
import { inject, injectable } from 'tsyringe-neo';
import { patchInject } from '../../dependency-injection/container-helper.js';
import { InjectTokens } from '../../dependency-injection/inject-tokens.js';
import { RelayNodeStateSchema } from '../../../data/schema/model/remote/state/relay-node-state-schema.js';
import { ExplorerStateSchema } from '../../../data/schema/model/remote/state/explorer-state-schema.js';
import { MirrorNodeStateSchema } from '../../../data/schema/model/remote/state/mirror-node-state-schema.js';
import { HAProxyStateSchema } from '../../../data/schema/model/remote/state/haproxy-state-schema.js';
import { EnvoyProxyStateSchema } from '../../../data/schema/model/remote/state/envoy-proxy-state-schema.js';
import { ConsensusNodeStateSchema } from '../../../data/schema/model/remote/state/consensus-node-state-schema.js';
import { BlockNodeStateSchema } from '../../../data/schema/model/remote/state/block-node-state-schema.js';
let ComponentFactory = class ComponentFactory {
    remoteConfig;
    constructor(remoteConfig) {
        this.remoteConfig = remoteConfig;
        this.remoteConfig = patchInject(remoteConfig, InjectTokens.RemoteConfigRuntimeState, this.constructor.name);
    }
    createNewRelayComponent(clusterReference, namespace, nodeIds) {
        const id = this.remoteConfig.configuration.components.getNewComponentId(ComponentTypes.RelayNodes);
        const phase = DeploymentPhase.DEPLOYED;
        const metadata = new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase);
        return new RelayNodeStateSchema(metadata, nodeIds);
    }
    createNewExplorerComponent(clusterReference, namespace) {
        const id = this.remoteConfig.configuration.components.getNewComponentId(ComponentTypes.Explorers);
        const phase = DeploymentPhase.DEPLOYED;
        const metadata = new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase);
        return new ExplorerStateSchema(metadata);
    }
    createNewMirrorNodeComponent(clusterReference, namespace) {
        const id = this.remoteConfig.configuration.components.getNewComponentId(ComponentTypes.MirrorNode);
        const phase = DeploymentPhase.DEPLOYED;
        const metadata = new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase);
        return new MirrorNodeStateSchema(metadata);
    }
    createNewHaProxyComponent(clusterReference, namespace) {
        const id = this.remoteConfig.configuration.components.getNewComponentId(ComponentTypes.HaProxy);
        const phase = DeploymentPhase.DEPLOYED;
        const metadata = new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase);
        return new HAProxyStateSchema(metadata);
    }
    createNewEnvoyProxyComponent(clusterReference, namespace) {
        const id = this.remoteConfig.configuration.components.getNewComponentId(ComponentTypes.EnvoyProxy);
        const phase = DeploymentPhase.DEPLOYED;
        const metadata = new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase);
        return new EnvoyProxyStateSchema(metadata);
    }
    createNewBlockNodeComponent(clusterReference, namespace) {
        const id = this.remoteConfig.configuration.components.getNewComponentId(ComponentTypes.BlockNode);
        const phase = DeploymentPhase.DEPLOYED;
        const metadata = new ComponentStateMetadataSchema(id, namespace.name, clusterReference, phase);
        return new BlockNodeStateSchema(metadata);
    }
    createNewConsensusNodeComponent(nodeId, clusterReference, namespace, phase, portForwardConfigs) {
        const metadata = new ComponentStateMetadataSchema(nodeId, namespace.name, clusterReference, phase, portForwardConfigs);
        return new ConsensusNodeStateSchema(metadata);
    }
    createConsensusNodeComponentsFromNodeIds(nodeIds, clusterReference, namespace, portForwardConfigs) {
        return nodeIds.map((nodeId) => this.createNewConsensusNodeComponent(nodeId, clusterReference, namespace, DeploymentPhase.REQUESTED, portForwardConfigs));
    }
};
ComponentFactory = __decorate([
    injectable(),
    __param(0, inject(InjectTokens.RemoteConfigRuntimeState)),
    __metadata("design:paramtypes", [Object])
], ComponentFactory);
export { ComponentFactory };
//# sourceMappingURL=component-factory.js.map