import "./paths-Cmq4jkLW.js";
import "./utils-CcH8KYHm.js";
import "./registry-BvTskRju.js";
import "./subsystem-D5jeWpPI.js";
import "./exec-Drj_Y0q4.js";
import "./agent-scope-B830_s1e.js";
import "./model-selection-Cu-UzQaa.js";
import "./boolean-Wzu0-e0P.js";
import "./env-L9Bekcgw.js";
import "./io-B0vHiKay.js";
import "./manifest-registry-CKXLdOam.js";
import "./config-CPJqIoc0.js";
import "./ssrf-CqwYCyyw.js";
import "./image-ops-CgU_RtSG.js";
import "./message-channel-BZ3Pmru_.js";
import "./plugins-CK8s7WRs.js";
import "./accounts-CqvejUxk.js";
import "./bindings-Rfu8UC_f.js";
import "./logging-GKUQydLE.js";
import "./tool-images-BLUAnHRr.js";
import "./fetch-guard-DvcUsuQY.js";
import "./fetch-DNpno7P_.js";
import { a as jsonResult, n as createActionGate, s as readReactionParams, u as readStringParam } from "./common-Ct4DbLC9.js";
import "./chunk-BZIV3cUY.js";
import "./markdown-tables-DJrsOaQF.js";
import "./ir-BbBSx66U.js";
import "./render-lL152pED.js";
import "./tables-CckVE7p3.js";
import { r as sendReactionWhatsApp } from "./outbound-DZbcX1OC.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 };