import "./paths-Ci0O5IXU.js";
import { a as logVerbose, c as shouldLogVerbose } from "./globals-o4Hkf2nH.js";
import "./utils-DXDZXfi2.js";
import "./thinking-Fqckw03T.js";
import "./agent-scope-BUcFoOez.js";
import "./subsystem-CocLsF9M.js";
import "./core-root-D_XTmw6_.js";
import "./logger-B4_TThxB.js";
import "./exec-Bvzmovpq.js";
import "./model-selection-YEFtLNSF.js";
import "./registry-CZfQ-snX.js";
import "./github-copilot-token-DqwKrrmK.js";
import "./boolean-C6Pbt2Ue.js";
import "./env-D3eA4r2n.js";
import "./manifest-registry-CqRtX07d.js";
import "./dock-B9SrGH_K.js";
import "./message-channel-B7if8_Ss.js";
import "./plugins-DPuCvyAr.js";
import "./sessions-CxtmRBrc.js";
import { d as isAudioAttachment, i as normalizeMediaAttachments, o as resolveMediaAttachmentLocalRoots, t as runAudioTranscription } from "./audio-transcription-runner-BmYM79ae.js";
import "./image-C5KyeETN.js";
import "./models-config-B8Hasdzn.js";
import "./pi-embedded-helpers-M3RkS711.js";
import "./sandbox-C1_DWCsa.js";
import "./tool-catalog-7XRC3klR.js";
import "./chrome-BBVmc3Se.js";
import "./tailscale-BxdRBeK_.js";
import "./tailnet-DONkFGUG.js";
import "./ws-DQm2qOSB.js";
import "./auth-BfvQ8QYP.js";
import "./server-context-Ba0Dvxyt.js";
import "./frontmatter-wvk5Gwyc.js";
import "./skills-BgSP_JFk.js";
import "./path-alias-guards-Cjml85oF.js";
import "./paths-CI0-x9aa.js";
import "./redact-Nl4LWTUL.js";
import "./errors-D2aogITB.js";
import "./fs-safe-4KkU2jy0.js";
import "./proxy-env-QR3xvEvF.js";
import "./image-ops-BMK3YDnH.js";
import "./store-wnkoDS0q.js";
import "./ports-BJ314ngw.js";
import "./trash-C57Djqhz.js";
import "./server-middleware-Db5VJPvz.js";
import "./accounts--YCaC3h2.js";
import "./accounts-DIXxXacs.js";
import "./logging-w5jq5901.js";
import "./accounts-Cy5Z48cS.js";
import "./paths-DyjDYWsu.js";
import "./chat-envelope-DjXKeY_Z.js";
import "./tool-images-BdgJAeDm.js";
import "./tool-display-DtW9AC9y.js";
import "./fetch-guard-BXj181Wi.js";
import "./api-key-rotation-kSZ_8x6S.js";
import "./local-roots-lI8oP7YT.js";
import "./model-catalog-CrylEG4v.js";
import "./proxy-fetch-1Erku4sd.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 };