"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.htmlToPdf = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const config_1 = require("./config");
const zod_1 = require("zod");
const htmlToPdf_1 = require("../../../../../src/utils/htmlToPdf");
exports.htmlToPdf = {
    key: 'htmlToPdf',
    title: 'HTML to PDF',
    description: 'Convert an HTML string to a PDF base64 string, to be uploaded or sent in a future action',
    category: extensions_core_1.Category.DATA,
    fields: config_1.fields,
    dataPoints: config_1.dataPoints,
    previewable: true,
    onEvent: async ({ payload, onComplete }) => {
        const { fields: { htmlString, options }, } = (0, extensions_core_1.validate)({
            schema: zod_1.z.object({
                fields: config_1.FieldsValidationSchema,
            }),
            payload,
        });
        const base64Pdf = await (0, htmlToPdf_1.htmlToBase64Pdf)(htmlString, options);
        await onComplete({
            data_points: {
                base64Pdf,
            },
        });
    },
};
//# sourceMappingURL=htmlToPdf.js.map