"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.messageSchema = exports.jsonMessage = void 0;
const translate_1 = require("../../i18n/translate");
const zod_1 = __importDefault(require("zod"));
const prisma_schema_1 = require("../../../types/prisma-schema/index.js");
const whatsappMessageSchema = zod_1.default.object({
    id: zod_1.default.string(),
    from: zod_1.default.string().optional(),
    to: zod_1.default.string().optional(),
    timestamp: zod_1.default.coerce.number(),
});
const textMessageSchema = whatsappMessageSchema.merge(zod_1.default.object({
    text: zod_1.default.object({
        body: zod_1.default.string(),
    }),
}));
const templateMessageSchema = whatsappMessageSchema.merge(zod_1.default.object({
    templateName: zod_1.default.string(),
}));
exports.jsonMessage = zod_1.default.discriminatedUnion('type', [
    textMessageSchema.extend({ type: zod_1.default.literal('text') }),
    templateMessageSchema.extend({ type: zod_1.default.literal('template') }),
]);
exports.messageSchema = zod_1.default.object({
    id: zod_1.default.string().uuid({
        message: (0, translate_1.translate)('model.message.id.uuid'),
    }),
    wamId: zod_1.default.string(),
    message: exports.jsonMessage,
    state: zod_1.default.nativeEnum(prisma_schema_1.MessageState),
    created_at: zod_1.default.date(),
    updated_at: zod_1.default.date(),
});
//# sourceMappingURL=message.dto.js.map