"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getServicePort = exports.DEFAULT_PROXY_HEALTHCHECK_PORT_HOST_MACHINE = exports.DEFAULT_PROXY_HEALTHCHECK_PORT = exports.DEFAULT_PROXY_INGRESS_PORT = exports.defaultNoDebugTunnelOptions = exports.TUNNEL_BUNDLE_DIRECTORY = exports.defaultDebugStartingPort = void 0;
const tslib_1 = require("tslib");
const path_1 = tslib_1.__importDefault(require("path"));
const shared_1 = require("../shared");
exports.defaultDebugStartingPort = 9229;
exports.TUNNEL_BUNDLE_DIRECTORY = path_1.default.join(shared_1.FORGE_DIRECTORY, 'tunnel-output');
exports.defaultNoDebugTunnelOptions = {
    debug: false,
    debugStartingPort: exports.defaultDebugStartingPort
};
exports.DEFAULT_PROXY_INGRESS_PORT = 7071;
exports.DEFAULT_PROXY_HEALTHCHECK_PORT = 7073;
exports.DEFAULT_PROXY_HEALTHCHECK_PORT_HOST_MACHINE = 7011;
async function getServicePort(services, serviceKey) {
    if (!serviceKey || !services || services.length === 0)
        return undefined;
    const defaultPort = services[0].tunnel?.port ?? exports.DEFAULT_PROXY_INGRESS_PORT;
    const index = services.findIndex((service) => service.key === serviceKey);
    if (index > -1) {
        return services[index].tunnel?.port ?? defaultPort + index;
    }
}
exports.getServicePort = getServicePort;
