import "./paths-B4BZAPZh.js";
import "./utils-h12D6i3s.js";
import "./theme-CvDUwCeH.js";
import "./registry-CEok6CBD.js";
import "./subsystem-CptcaHdG.js";
import "./exec-KZG5pigM.js";
import "./agent-scope-DuRxDIxP.js";
import "./model-selection-Ci1X7yz4.js";
import "./github-copilot-token-BZDGcFI5.js";
import "./boolean-BsqeuxE6.js";
import "./env-Du80aeH-.js";
import "./config-DpEIy1Iq.js";
import "./manifest-registry-DP5prNZc.js";
import "./ssrf-BT0IElaU.js";
import "./image-ops-BP1giyhy.js";
import "./message-channel-CP2gEtPf.js";
import "./normalize-DqxNnJHS.js";
import "./accounts-DOhECffI.js";
import "./bindings-OUZ-uS5k.js";
import "./logging-D3KTM1pH.js";
import "./plugins-DXhAnLR9.js";
import "./tool-images-DJNWvX-X.js";
import "./fetch-guard-ZRDg55CN.js";
import "./fetch-Dzzhxfkw.js";
import { a as jsonResult, n as createActionGate, s as readReactionParams, u as readStringParam } from "./common-DRqN8wrX.js";
import "./chunk-DLXgG-Hp.js";
import "./markdown-tables-PlwJ_Osa.js";
import "./ir-j6-6N0Xv.js";
import "./render-CXDO_kgw.js";
import "./tables-nYGLZHh5.js";
import { r as sendReactionWhatsApp } from "./outbound-BRckMs93.js";

//#region src/agents/tools/whatsapp-actions.ts
async function handleWhatsAppAction(params, cfg) {
	const action = readStringParam(params, "action", { required: true });
	const isActionEnabled = createActionGate(cfg.channels?.whatsapp?.actions);
	if (action === "react") {
		if (!isActionEnabled("reactions")) throw new Error("WhatsApp reactions are disabled.");
		const chatJid = readStringParam(params, "chatJid", { required: true });
		const messageId = readStringParam(params, "messageId", { required: true });
		const { emoji, remove, isEmpty } = readReactionParams(params, { removeErrorMessage: "Emoji is required to remove a WhatsApp reaction." });
		const participant = readStringParam(params, "participant");
		const accountId = readStringParam(params, "accountId");
		const fromMeRaw = params.fromMe;
		await sendReactionWhatsApp(chatJid, messageId, remove ? "" : emoji, {
			verbose: false,
			fromMe: typeof fromMeRaw === "boolean" ? fromMeRaw : void 0,
			participant: participant ?? void 0,
			accountId: accountId ?? void 0
		});
		if (!remove && !isEmpty) return jsonResult({
			ok: true,
			added: emoji
		});
		return jsonResult({
			ok: true,
			removed: true
		});
	}
	throw new Error(`Unsupported WhatsApp action: ${action}`);
}

//#endregion
export { handleWhatsAppAction };