import { envVarNameFromPath } from '../env/config-env-overrides.js';
import { loadGlobalConfig, validateCliPath } from './globalConfigCore.js';
export function resolveAnthropicApiKey() {
    const envKey = process.env[envVarNameFromPath('anthropic_api_key')];
    if (envKey)
        return envKey;
    const config = loadGlobalConfig();
    return config.anthropicApiKey;
}
export function resolveOpenaiApiKey() {
    const envKey = process.env[envVarNameFromPath('openai_api_key')];
    if (envKey)
        return envKey;
    const config = loadGlobalConfig();
    return config.openaiApiKey;
}
export function resolveCodexCliPath() {
    const envPath = process.env[envVarNameFromPath('codex_cli_path')];
    if (envPath !== undefined) {
        return validateCliPath(envPath, 'TAKT_CODEX_CLI_PATH');
    }
    const config = loadGlobalConfig();
    if (config.codexCliPath === undefined) {
        return undefined;
    }
    return validateCliPath(config.codexCliPath, 'codex_cli_path');
}
export function resolveClaudeCliPath() {
    const envPath = process.env[envVarNameFromPath('claude_cli_path')];
    if (envPath !== undefined) {
        return validateCliPath(envPath, 'TAKT_CLAUDE_CLI_PATH');
    }
    const config = loadGlobalConfig();
    if (config.claudeCliPath === undefined) {
        return undefined;
    }
    return validateCliPath(config.claudeCliPath, 'claude_cli_path');
}
export function resolveCursorCliPath() {
    const envPath = process.env[envVarNameFromPath('cursor_cli_path')];
    if (envPath !== undefined) {
        return validateCliPath(envPath, 'TAKT_CURSOR_CLI_PATH');
    }
    const config = loadGlobalConfig();
    if (config.cursorCliPath === undefined) {
        return undefined;
    }
    return validateCliPath(config.cursorCliPath, 'cursor_cli_path');
}
export function resolveOpencodeApiKey() {
    const envKey = process.env[envVarNameFromPath('opencode_api_key')];
    if (envKey)
        return envKey;
    const config = loadGlobalConfig();
    return config.opencodeApiKey;
}
export function resolveCursorApiKey() {
    const envKey = process.env[envVarNameFromPath('cursor_api_key')];
    if (envKey)
        return envKey;
    const config = loadGlobalConfig();
    return config.cursorApiKey;
}
export function resolveCopilotCliPath() {
    const envPath = process.env[envVarNameFromPath('copilot_cli_path')];
    if (envPath !== undefined) {
        return validateCliPath(envPath, 'TAKT_COPILOT_CLI_PATH');
    }
    const config = loadGlobalConfig();
    if (config.copilotCliPath === undefined) {
        return undefined;
    }
    return validateCliPath(config.copilotCliPath, 'copilot_cli_path');
}
export function resolveKiroCliPath() {
    const envPath = process.env[envVarNameFromPath('kiro_cli_path')];
    if (envPath !== undefined) {
        return validateCliPath(envPath, 'TAKT_KIRO_CLI_PATH');
    }
    const config = loadGlobalConfig();
    if (config.kiroCliPath === undefined) {
        return undefined;
    }
    return validateCliPath(config.kiroCliPath, 'kiro_cli_path');
}
export function resolveCopilotGithubToken() {
    const envKey = process.env[envVarNameFromPath('copilot_github_token')];
    if (envKey)
        return envKey;
    const config = loadGlobalConfig();
    return config.copilotGithubToken;
}
export function resolveKiroApiKey() {
    const envKey = process.env[envVarNameFromPath('kiro_api_key')];
    if (envKey)
        return envKey;
    const config = loadGlobalConfig();
    if (config.kiroApiKey)
        return config.kiroApiKey;
    return process.env.KIRO_API_KEY;
}
//# sourceMappingURL=globalConfigResolvers.js.map