"use strict"; // @ts-check var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = grabHostNames; const https_1 = __importDefault(require("https")); const http_1 = __importDefault(require("http")); /** * # Grab Names For Query */ function grabHostNames(param) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const finalEnv = (param === null || param === void 0 ? void 0 : param.env) ? Object.assign(Object.assign({}, process.env), param.env) : process.env; const scheme = ((_a = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _a === void 0 ? void 0 : _a.scheme) || finalEnv["DSQL_HTTP_SCHEME"]; const localHost = ((_b = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _b === void 0 ? void 0 : _b.isLocalhost) ? "localhost" : finalEnv["DSQL_LOCAL_HOST"]; const localHostPort = ((_c = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _c === void 0 ? void 0 : _c.localhostPort) || finalEnv["DSQL_LOCAL_HOST_PORT"]; const remoteHost = (param === null || param === void 0 ? void 0 : param.useDefault) ? undefined : ((_d = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _d === void 0 ? void 0 : _d.remoteHost) ? (_e = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _e === void 0 ? void 0 : _e.remoteHost : ((_f = finalEnv["DSQL_API_REMOTE_HOST"]) === null || _f === void 0 ? void 0 : _f.match(/.*\..*/)) ? finalEnv["DSQL_API_REMOTE_HOST"] : undefined; const remoteHostPort = (param === null || param === void 0 ? void 0 : param.useDefault) ? undefined : ((_g = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _g === void 0 ? void 0 : _g.remoteHostPort) ? (_h = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _h === void 0 ? void 0 : _h.remoteHostPort : ((_j = finalEnv["DSQL_API_REMOTE_HOST_PORT"]) === null || _j === void 0 ? void 0 : _j.match(/./)) ? finalEnv["DSQL_API_REMOTE_HOST_PORT"] : undefined; return { host: remoteHost || localHost || "www.datasquirel.com", port: remoteHostPort || localHostPort || 443, scheme: (scheme === null || scheme === void 0 ? void 0 : scheme.match(/^http$/i)) ? http_1.default : https_1.default, user_id: (param === null || param === void 0 ? void 0 : param.userId) || String(finalEnv["DSQL_API_USER_ID"] || 0), apiKey: ((_k = param === null || param === void 0 ? void 0 : param.apiConnectionConfig) === null || _k === void 0 ? void 0 : _k.apiKey) || process.env.DSQL_FULL_ACCESS_API_KEY || process.env.DSQL_API_KEY || process.env.DSQL_READ_ONLY_API_KEY, }; }