"use strict";
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
exports.config = void 0;
const tslib_1 = require("tslib");
const path_1 = tslib_1.__importDefault(require("path"));
const enum_1 = require("@/@types/enum");
exports.config = {
    ...getPublicDomain(),
    wsPath: '/debugger-proxy',
    cachePath: path_1.default.join(__dirname, 'cache'),
    hmrStaticPath: path_1.default.join(process.env.HMRStaticPath || __dirname, 'hmr'),
    logPath: path_1.default.join(__dirname, 'log'),
    hmrPortPath: path_1.default.join(__dirname, 'cache/hmr-port.txt'),
    iWDPStartPort: ((_a = global.debugAppArgv) === null || _a === void 0 ? void 0 : _a.iWDPStartPort) || 9200,
    iWDPEndPort: ((_b = global.debugAppArgv) === null || _b === void 0 ? void 0 : _b.iWDPEndPort) || 9300,
    redis: {
        // ⚠️ redis-server 6 以下，username 需要置空
        url: `redis://:${process.env.REDIS_PWD}@${process.env.REDIS_HOST}:${process.env.REDIS_PORT}/0`,
        debugTargetTable: 'tdf:debugtargets',
        bundleTable: 'tdf:bundles',
    },
    isCluster: process.env.IS_CLUSTER === 'true',
    cos: {
        SecretId: process.env.SecretId,
        SecretKey: process.env.SecretKey,
        Bucket: process.env.Bucket,
        Region: process.env.Region,
        StorageClass: process.env.StorageClass,
    },
    staticFileStorage: process.env.StaticFileStorage || enum_1.StaticFileStorage.Local,
    aegisId: 'yxqehauSsvzBZxdRmz',
    showPerformance: false,
};
function getPublicDomain() {
    var _a, _b, _c, _d;
    const hostFromArgv = !((_a = global.debugAppArgv) === null || _a === void 0 ? void 0 : _a.host) || ((_b = global.debugAppArgv) === null || _b === void 0 ? void 0 : _b.host) === '0.0.0.0' ? 'localhost' : (_c = global.debugAppArgv) === null || _c === void 0 ? void 0 : _c.host;
    const portFromArgv = ((_d = global.debugAppArgv) === null || _d === void 0 ? void 0 : _d.port) || 38989;
    const domain = process.env.DOMAIN || `http://${hostFromArgv}:${portFromArgv}`;
    const wsDomain = domain.replace('https://', 'wss://').replace('http://', 'ws://');
    const wsProtocol = domain.startsWith('https://') ? 'wss' : 'ws';
    return { domain, wsDomain, wsProtocol };
}
