import "./paths-CyR9Pa1R.js";
import "./registry-B3v_dMjW.js";
import "./agent-scope-BqZ_plxe.js";
import "./subsystem-12Cr1qkN.js";
import "./workspace-0LqR5k0Z.js";
import "./normalize-dSQPMpIn.js";
import "./accounts-CFuwD11R.js";
import "./boolean-mcn6kL0s.js";
import "./command-format-CReWasli.js";
import "./bindings-DF9JL0Dp.js";
import "./plugins-B_DoE566.js";
import "./image-ops-Ds8rFspc.js";
import "./model-auth-4zgXZMu1.js";
import "./github-copilot-token-CLyVfX-X.js";
import "./message-channel-BQffYho-.js";
import "./config-CudTJ53Z.js";
import "./manifest-registry-RbxxyxZX.js";
import "./tool-images-CNP8ODZw.js";
import { i as jsonResult, l as readStringParam, o as readReactionParams, t as createActionGate } from "./common-CjWZrR6c.js";
import "./chunk-CpOZVBxY.js";
import "./markdown-tables-BcAgYnfB.js";
import "./fetch-yK5YruMA.js";
import "./ir-DOfUbqBd.js";
import "./render-flG67HhW.js";
import "./tables-BlrNiWn5.js";
import { r as sendReactionWhatsApp } from "./outbound-CkvgSeLz.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 };