// SPDX-License-Identifier: Apache-2.0
import { Templates } from './templates.js';
import * as constants from './constants.js';
import { lt } from 'semver';
import * as versions from '../../version.js';
export class BlockNodesJsonWrapper {
    blockNodeComponents;
    clusters;
    versions;
    constructor(blockNodeComponents, clusters, versions) {
        this.blockNodeComponents = blockNodeComponents;
        this.clusters = clusters;
        this.versions = versions;
    }
    toJSON() {
        const blockNodeConnectionData = this.blockNodeComponents.map((blockNodeComponent) => {
            const cluster = this.clusters.find((cluster) => cluster.name === blockNodeComponent.metadata.cluster);
            const address = Templates.renderSvcFullyQualifiedDomainName(`${constants.BLOCK_NODE_RELEASE_NAME}-0`, blockNodeComponent.metadata.namespace, cluster.dnsBaseDomain);
            const useLegacyPort = lt(this.versions.blockNodeChart, versions.MINIMUM_HIERO_BLOCK_NODE_VERSION_FOR_NEW_LIVENESS_CHECK_PORT);
            const port = useLegacyPort ? constants.BLOCK_NODE_PORT_LEGACY : constants.BLOCK_NODE_PORT;
            return { address, port, priority: 1 };
        });
        const data = {
            nodes: blockNodeConnectionData,
            blockItemBatchSize: constants.BLOCK_ITEM_BATCH_SIZE,
        };
        return JSON.stringify(data);
    }
}
//# sourceMappingURL=block-nodes-json-wrapper.js.map