"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PostmarkProvider = void 0;
function __assignType(fn, args) {
    fn.__type = args;
    return fn;
}
/*@ts-ignore*/
var { __ΩScopedLogger } = require('@deepkit/logger');
const postmark_1 = require("postmark");
const app_1 = require("../../app");
class PostmarkProvider {
    constructor(config, logger) {
        this.config = config;
        this.logger = logger;
        this.postmarkClient = new postmark_1.ServerClient(this.config.POSTMARK_SECRET);
        if (!this.config.POSTMARK_SECRET) {
            throw new Error('POSTMARK_SECRET is not set');
        }
    }
    async send(message) {
        const response = await this.postmarkClient.sendEmail({
            From: message.from,
            To: message.to,
            Subject: message.subject,
            HtmlBody: message.message,
            TextBody: message.plainMessage,
            ReplyTo: message.replyTo,
            Attachments: message.attachments?.map(__assignType(attachment => ({
                Name: attachment.name,
                Content: attachment.content.toString('base64'),
                ContentType: attachment.contentType,
                ContentID: attachment.cid ?? null,
                ContentLength: attachment.content.length
            }), ['attachment', '', 'P"2!"/"']))
        });
        return response.MessageID;
    }
}
exports.PostmarkProvider = PostmarkProvider;
PostmarkProvider.__type = ['postmarkClient', function () { return new postmark_1.ServerClient(this.config.POSTMARK_SECRET); }, () => app_1.BaseAppConfig, 'config', () => __ΩScopedLogger, 'logger', 'constructor', 'PreparedMessageProperties', 'message', 'send', 'MailProvider', 'PostmarkProvider', '!3!;>"PP7#2$;n%2&;"0\'P"w(2)&`0*5"w+x"w,'];
//# sourceMappingURL=postmark.js.map