import "./run-with-concurrency-Dfxzp5Ct.js";
import "./accounts-Buhd1uPu.js";
import "./paths-CljwcxR8.js";
import "./github-copilot-token-C8q4hDIm.js";
import "./config-CuXlFsZ1.js";
import { L as logVerbose, z as shouldLogVerbose } from "./logger-CxTRqqI6.js";
import "./thinking-dgOPzhlh.js";
import "./image-ops-CtTMGCIB.js";
import "./pi-embedded-helpers-D6oj1T9n.js";
import "./plugins-BT3un3YG.js";
import "./accounts-M8PD56qZ.js";
import "./accounts-r2yU_SWh.js";
import "./paths-D7qK4fQ2.js";
import "./redact-D4S-I3NR.js";
import "./errors-qNrP7yKK.js";
import "./path-alias-guards-Cv32sFCP.js";
import "./fs-safe-7BUz7YI2.js";
import "./ssrf-HbQppIPC.js";
import "./fetch-guard-C_n0fo7E.js";
import "./local-roots-D2pnTw2s.js";
import "./tool-images-_mEE-YSY.js";
import { f as isAudioAttachment, i as normalizeMediaAttachments, o as resolveMediaAttachmentLocalRoots, t as runAudioTranscription } from "./audio-transcription-runner-B7v3DcXL.js";
import "./skills-DCiNEE9-.js";
import "./chrome-vjWWGf2R.js";
import "./store-VIxTzwhj.js";
import "./image-DsuA5mox.js";
import "./api-key-rotation-DyTc0uyL.js";
import "./proxy-fetch-BG_O0d-A.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 };