"use strict";
/**
 * Main unified configuration interface, factory, and type guard.
 *
 * The UnifiedConfig type is the root of the entire config.yaml schema.
 * This file imports all section types from their respective schema modules.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isUnifiedConfig = exports.createEmptyUnifiedConfig = void 0;
const auth_1 = require("./auth");
const cliproxy_1 = require("./cliproxy");
const logging_1 = require("./logging");
const providers_1 = require("./providers");
const version_1 = require("./version");
const quota_1 = require("./quota");
const thinking_1 = require("./thinking");
const channels_1 = require("./channels");
const browser_1 = require("./browser");
/**
 * Create an empty unified config with defaults.
 */
function createEmptyUnifiedConfig() {
    return {
        version: version_1.UNIFIED_CONFIG_VERSION,
        default: undefined,
        accounts: {},
        profiles: {},
        cliproxy: {
            backend: 'original',
            oauth_accounts: {},
            providers: [...cliproxy_1.CLIPROXY_SUPPORTED_PROVIDERS],
            variants: {},
            logging: {
                enabled: false,
                request_log: false,
            },
            safety: { ...cliproxy_1.DEFAULT_CLIPROXY_SAFETY_CONFIG },
            auto_sync: true,
            routing: {
                strategy: 'round-robin',
                session_affinity: false,
                session_affinity_ttl: '1h',
            },
        },
        proxy: {
            port: providers_1.DEFAULT_OPENAI_COMPAT_PROXY_CONFIG.port,
            profile_ports: { ...providers_1.DEFAULT_OPENAI_COMPAT_PROXY_CONFIG.profile_ports },
            routing: {
                ...providers_1.DEFAULT_OPENAI_COMPAT_PROXY_CONFIG.routing,
            },
        },
        logging: { ...logging_1.DEFAULT_LOGGING_CONFIG },
        preferences: {
            theme: 'system',
            telemetry: false,
            auto_update: true,
        },
        websearch: {
            enabled: true,
            providers: {
                exa: {
                    enabled: false,
                    max_results: 5,
                },
                tavily: {
                    enabled: false,
                    max_results: 5,
                },
                brave: {
                    enabled: false,
                    max_results: 5,
                },
                searxng: {
                    enabled: false,
                    url: '',
                    max_results: 5,
                },
                duckduckgo: {
                    enabled: true,
                    max_results: 5,
                },
                gemini: {
                    enabled: false,
                    model: 'gemini-2.5-flash',
                    timeout: 55,
                },
                opencode: {
                    enabled: false,
                    model: 'opencode/grok-code',
                    timeout: 90,
                },
                grok: {
                    enabled: false,
                    timeout: 55,
                },
            },
        },
        global_env: {
            enabled: true,
            env: { ...providers_1.DEFAULT_GLOBAL_ENV },
        },
        copilot: { ...providers_1.DEFAULT_COPILOT_CONFIG },
        cursor: { ...providers_1.DEFAULT_CURSOR_CONFIG },
        cliproxy_server: { ...providers_1.DEFAULT_CLIPROXY_SERVER_CONFIG },
        quota_management: { ...quota_1.DEFAULT_QUOTA_MANAGEMENT_CONFIG },
        thinking: { ...thinking_1.DEFAULT_THINKING_CONFIG },
        channels: { ...channels_1.DEFAULT_OFFICIAL_CHANNELS_CONFIG },
        dashboard_auth: { ...auth_1.DEFAULT_DASHBOARD_AUTH_CONFIG },
        browser: {
            claude: { ...browser_1.DEFAULT_BROWSER_CONFIG.claude },
            codex: { ...browser_1.DEFAULT_BROWSER_CONFIG.codex },
        },
        image_analysis: { ...providers_1.DEFAULT_IMAGE_ANALYSIS_CONFIG },
    };
}
exports.createEmptyUnifiedConfig = createEmptyUnifiedConfig;
/**
 * Type guard for UnifiedConfig.
 * Relaxed validation: accepts configs with version >= 1 and any subset of sections.
 * Missing sections will be filled with defaults during merge.
 */
function isUnifiedConfig(obj) {
    if (typeof obj !== 'object' || obj === null)
        return false;
    const config = obj;
    // Only require version to be a number >= 1 (allow future versions)
    // Sections are optional - will be merged with defaults in loadOrCreateUnifiedConfig
    return typeof config.version === 'number' && config.version >= 1;
}
exports.isUnifiedConfig = isUnifiedConfig;
//# sourceMappingURL=unified-config.js.map