"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const socket_1 = require("../libs/socket");
const sendWhatsAppMessageOfficialAPI_1 = __importDefault(require("./sendWhatsAppMessageOfficialAPI"));
function sendWhatsAppMessageSocket(ticket, body, quotedMsgSerializedId, number) {
    const { phoneNumberId } = ticket;
    if (phoneNumberId) {
        sendWhatsAppMessageOfficialAPI_1.default(ticket, body, quotedMsgSerializedId);
        return;
    }
    const io = socket_1.getIO();
    io.to(`session_${ticket.whatsappId.toString()}`).emit("send_message", {
        action: "create",
        msg: {
            number: number
                ? number
                : `${ticket.contact.number}@${ticket.isGroup ? "g" : "c"}.us`,
            body: body,
            quotedMessageId: quotedMsgSerializedId,
            linkPreview: false
        }
    });
}
exports.default = sendWhatsAppMessageSocket;
