/**
 * Realtime Voice Type Definitions for NeuroLink
 *
 * All realtime/bidirectional voice types: session, config, messages,
 * event handlers, provider types, handler types, error codes, defaults,
 * and type guards.
 *
 * @module types/realtime
 */
// ============================================================================
// REALTIME ERROR CODES
// ============================================================================
/**
 * Realtime error codes
 */
export const REALTIME_ERROR_CODES = {
    CONNECTION_FAILED: "REALTIME_CONNECTION_FAILED",
    SESSION_TIMEOUT: "REALTIME_SESSION_TIMEOUT",
    PROTOCOL_ERROR: "REALTIME_PROTOCOL_ERROR",
    AUDIO_STREAM_ERROR: "REALTIME_AUDIO_STREAM_ERROR",
    PROVIDER_NOT_CONFIGURED: "REALTIME_PROVIDER_NOT_CONFIGURED",
    PROVIDER_NOT_SUPPORTED: "REALTIME_PROVIDER_NOT_SUPPORTED",
    SESSION_ALREADY_ACTIVE: "REALTIME_SESSION_ALREADY_ACTIVE",
    SESSION_NOT_ACTIVE: "REALTIME_SESSION_NOT_ACTIVE",
    INVALID_MESSAGE: "REALTIME_INVALID_MESSAGE",
};
// ============================================================================
// REALTIME DEFAULTS
// ============================================================================
/**
 * Default realtime configuration
 */
export const DEFAULT_REALTIME_CONFIG = {
    timeout: 30000,
    inputSampleRate: 24000,
    outputSampleRate: 24000,
    vadEnabled: true,
    vadThreshold: 0.5,
    turnDetection: "server_vad",
};
// ============================================================================
// REALTIME TYPE GUARDS
// ============================================================================
/**
 * Type guard for valid RealtimeConfig
 */
export function isValidRealtimeConfig(config) {
    if (!config || typeof config !== "object") {
        return false;
    }
    const conf = config;
    if (!conf.provider ||
        !["openai-realtime", "gemini-live"].includes(conf.provider)) {
        return false;
    }
    if (conf.timeout !== undefined) {
        if (typeof conf.timeout !== "number" || conf.timeout <= 0) {
            return false;
        }
    }
    if (conf.vadThreshold !== undefined) {
        if (typeof conf.vadThreshold !== "number" ||
            conf.vadThreshold < 0 ||
            conf.vadThreshold > 1) {
            return false;
        }
    }
    return true;
}
