import { resolveAssemblyAiApiKey, resolveDeepgramApiKey, resolveElevenLabsApiKey, resolveFalApiKey, resolveGeminiApiKey, resolveGroqApiKey, resolveOpenAiTranscriptionApiKey, } from "../../transcription/whisper/provider-setup.js";
export const REMOTE_MEDIA_MAX_BYTES_ENV = "SUMMARIZE_REMOTE_MEDIA_MAX_BYTES";
function normalizeKey(raw) {
    const trimmed = typeof raw === "string" ? raw.trim() : "";
    return trimmed.length > 0 ? trimmed : null;
}
export function normalizeRemoteMediaMaxBytes(raw) {
    if (raw == null)
        return null;
    const parsed = typeof raw === "number" ? raw : Number(raw.trim());
    return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
}
export function resolveTranscriptionConfig(input) {
    const fromObject = input.transcription ?? null;
    const env = fromObject?.env ?? input.env;
    return {
        env,
        groqApiKey: resolveGroqApiKey({
            env,
            groqApiKey: fromObject?.groqApiKey ?? input.groqApiKey,
        }),
        assemblyaiApiKey: resolveAssemblyAiApiKey({
            env,
            assemblyaiApiKey: fromObject?.assemblyaiApiKey ?? input.assemblyaiApiKey,
        }),
        deepgramApiKey: resolveDeepgramApiKey({
            env,
            deepgramApiKey: fromObject?.deepgramApiKey ?? input.deepgramApiKey,
        }),
        elevenlabsApiKey: resolveElevenLabsApiKey({
            env,
            elevenlabsApiKey: fromObject?.elevenlabsApiKey ?? input.elevenlabsApiKey,
        }),
        geminiApiKey: resolveGeminiApiKey({
            env,
            geminiApiKey: fromObject?.geminiApiKey ?? input.geminiApiKey,
        }),
        openaiApiKey: resolveOpenAiTranscriptionApiKey({
            env,
            openaiApiKey: fromObject?.openaiApiKey ?? input.openaiApiKey,
        }),
        falApiKey: resolveFalApiKey({
            env,
            falApiKey: fromObject?.falApiKey ?? input.falApiKey,
        }),
        geminiModel: normalizeKey(fromObject?.geminiModel ?? input.geminiModel),
        remoteMediaMaxBytes: normalizeRemoteMediaMaxBytes(fromObject?.remoteMediaMaxBytes ??
            input.remoteMediaMaxBytes ??
            env?.[REMOTE_MEDIA_MAX_BYTES_ENV]),
    };
}
//# sourceMappingURL=transcription-config.js.map