import "./paths-D7t4DWPT.js";
import "./registry-BAroooHo.js";
import "./agent-scope-vwdi_iPU.js";
import "./subsystem-CT4qQN_5.js";
import "./workspace-BfiC270B.js";
import "./plugins-CKverisB.js";
import "./accounts-D_f61n_2.js";
import "./boolean-B8-BqKGQ.js";
import "./command-format-B1Qy0nEy.js";
import "./bindings-B2zCGVlh.js";
import "./fetch-zQFnmTQp.js";
import "./model-auth-JizwQYrQ.js";
import "./message-channel-B2_fQxU-.js";
import "./config-CuIQfnYC.js";
import "./tool-images-CN0uVQmf.js";
import { i as jsonResult, l as readStringParam, o as readReactionParams, t as createActionGate } from "./common-Cq4cGI7g.js";
import "./chunk-DURdKVm7.js";
import "./markdown-tables-CpPOBj_4.js";
import "./ir-CrIjysE5.js";
import "./render-BDQg502o.js";
import "./tables-JCssucvN.js";
import { r as sendReactionWhatsApp } from "./outbound-CydZkY2D.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 };