"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FieldsSchema = exports.dataPoints = exports.fields = void 0;
const zod_1 = require("zod");
const extensions_core_1 = require("@awell-health/extensions-core");
const libphonenumber_js_1 = require("libphonenumber-js");
const lodash_1 = require("lodash");
const format_1 = __importDefault(require("date-fns/format"));
exports.fields = {
    broadcastName: {
        id: 'broadcastName',
        label: 'Broadcast Name',
        type: extensions_core_1.FieldType.STRING,
        required: true,
        description: 'The name of the broadcast.',
    },
    phoneNumber: {
        id: 'phoneNumber',
        label: 'Phone Number',
        type: extensions_core_1.FieldType.STRING,
        stringType: extensions_core_1.StringType.PHONE,
        required: true,
        description: 'The primary phone number of the recipient. Must be a valid North American Numbering Plan (NANP) phone number.',
    },
    textMessage: {
        id: 'textMessage',
        label: 'Text Message',
        type: extensions_core_1.FieldType.TEXT,
        required: true,
        description: 'The text of the message for a text type broadcast. The max length is based on the setting in your account.',
    },
    textNumberID: {
        id: 'textNumberID',
        label: 'Text Number ID',
        type: extensions_core_1.FieldType.NUMERIC,
        required: false,
        description: 'The ID of the text number your messages will be sent from. If omitted, the default text number on your account will be used.',
    },
    startDate: {
        id: 'startDate',
        label: 'Start Date',
        type: extensions_core_1.FieldType.DATE,
        required: false,
        description: 'The time the broadcast should start. Will default to start immediately. If provided must be a datetime as ISO 8601 string and time to send the message in UTC',
    },
};
exports.dataPoints = {
    broadcastId: {
        key: 'broadcastId',
        valueType: 'number',
    },
    broadcastStatus: {
        key: 'broadcastStatus',
        valueType: 'string',
    },
    uriBroadcastDetails: {
        key: 'uriBroadcastDetails',
        valueType: 'string',
    },
    broadcastStatusCategory: {
        key: 'broadcastStatusCategory',
        valueType: 'string',
    },
    broadcastStartDate: {
        key: 'broadcastStartDate',
        valueType: 'string',
    },
};
exports.FieldsSchema = zod_1.z.object({
    broadcastName: zod_1.z.string(),
    phoneNumber: zod_1.z.string().transform((phone) => {
        const parsedNumber = (0, libphonenumber_js_1.parsePhoneNumber)(phone);
        return parsedNumber.format('NATIONAL'); // Returns "(XXX) XXX-XXXX" NANP format
    }),
    textMessage: zod_1.z.string(),
    textNumberID: zod_1.z.number().optional(),
    startDate: extensions_core_1.DateTimeSchema.optional().transform((date) => {
        if ((0, lodash_1.isNil)(date) || date === '')
            return undefined;
        // format is required: 2/1/2020 1:15PM',
        return (0, format_1.default)(new Date(date), 'M/d/yyyy h:mmaa');
    }),
});
//# sourceMappingURL=config.js.map