import "./run-with-concurrency-CfVwrq0X.js";
import "./paths-y4sJOBPW.js";
import { L as logVerbose, z as shouldLogVerbose } from "./logger-CMXU2lzj.js";
import "./model-selection-DjJrz91i.js";
import "./github-copilot-token-y2JyCRga.js";
import "./thinking-CdZ17Ty0.js";
import "./accounts-DamnYKpP.js";
import "./plugins-DYs8UQjC.js";
import "./accounts-abwZ4kc7.js";
import "./image-ops-DLG5TgAD.js";
import "./pi-embedded-helpers-CAxK8FKs.js";
import "./chrome-DaB4Z7Zq.js";
import "./skills-C2zd3a0U.js";
import "./path-alias-guards-C5g_bJHv.js";
import "./redact-Dta3ii7t.js";
import "./errors-CaQu6hjT.js";
import "./fs-safe-BsF5hBZf.js";
import "./proxy-env-CI6twCpN.js";
import "./store-B5jLfSms.js";
import "./accounts-C4Ttr4sZ.js";
import "./paths-C5zPqp7F.js";
import "./tool-images-CqY1mINI.js";
import "./image-CYMWSjWL.js";
import { g as isAudioAttachment, i as normalizeMediaAttachments, o as resolveMediaAttachmentLocalRoots, t as runAudioTranscription } from "./audio-transcription-runner-BIsdnwet.js";
import "./fetch-Bl89e858.js";
import "./fetch-guard-CnwfXBmY.js";
import "./api-key-rotation-DhuvwSOi.js";
import "./proxy-fetch-p_6D326r.js";

//#region src/media-understanding/audio-preflight.ts
/**
* Transcribes the first audio attachment BEFORE mention checking.
* This allows voice notes to be processed in group chats with requireMention: true.
* Returns the transcript or undefined if transcription fails or no audio is found.
*/
async function transcribeFirstAudio(params) {
	const { ctx, cfg } = params;
	const audioConfig = cfg.tools?.media?.audio;
	if (!audioConfig || audioConfig.enabled === false) return;
	const attachments = normalizeMediaAttachments(ctx);
	if (!attachments || attachments.length === 0) return;
	const firstAudio = attachments.find((att) => att && isAudioAttachment(att) && !att.alreadyTranscribed);
	if (!firstAudio) return;
	if (shouldLogVerbose()) logVerbose(`audio-preflight: transcribing attachment ${firstAudio.index} for mention check`);
	try {
		const { transcript } = await runAudioTranscription({
			ctx,
			cfg,
			attachments,
			agentDir: params.agentDir,
			providers: params.providers,
			activeModel: params.activeModel,
			localPathRoots: resolveMediaAttachmentLocalRoots({
				cfg,
				ctx
			})
		});
		if (!transcript) return;
		firstAudio.alreadyTranscribed = true;
		if (shouldLogVerbose()) logVerbose(`audio-preflight: transcribed ${transcript.length} chars from attachment ${firstAudio.index}`);
		return transcript;
	} catch (err) {
		if (shouldLogVerbose()) logVerbose(`audio-preflight: transcription failed: ${String(err)}`);
		return;
	}
}

//#endregion
export { transcribeFirstAudio };