"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildCodexHomeAuthEnvironment = buildCodexHomeAuthEnvironment;
exports.buildCodexEnvVarAuthEnvironment = buildCodexEnvVarAuthEnvironment;
const definitions_1 = require("./definitions");
const CODEX_HOME_ENV_VAR = "CODEX_HOME";
const CODEX_API_KEY_ENV_VARS = [
    definitions_1.CODEX_API_KEY_ENV_VAR_NAME,
    "CODEX_API_KEY",
];
const CODEX_ENV_VAR_AUTH_ENV_VARS = [
    CODEX_HOME_ENV_VAR,
    "CODEX_API_KEY",
];
function buildCodexHomeAuthEnvironment(baseEnv, codexHomePath) {
    const env = {
        ...baseEnv,
    };
    env[CODEX_HOME_ENV_VAR] = codexHomePath;
    for (const envVarName of CODEX_API_KEY_ENV_VARS) {
        delete env[envVarName];
    }
    return env;
}
function buildCodexEnvVarAuthEnvironment(baseEnv, envVarName, value) {
    const env = {
        ...baseEnv,
        [envVarName]: value,
    };
    for (const envVarName of CODEX_ENV_VAR_AUTH_ENV_VARS) {
        delete env[envVarName];
    }
    return env;
}
