"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildSchema = void 0;
const subschemas_1 = require("../../core/schemas/shared/subschemas");
const hubEventAttendanceType_1 = require("../enums/hubEventAttendanceType");
const hubEventCapacityType_1 = require("../enums/hubEventCapacityType");
const validations_1 = require("./validations");
/**
 * @private
 * Builds a schema for creating a new Event that enforces a startDate relative to the user's locale
 */
const buildSchema = () => {
    return {
        $async: true,
        required: ["name", "startDate", "endDate", "timeZone"],
        properties: {
            name: subschemas_1.ENTITY_NAME_SCHEMA,
            description: {
                type: "string",
            },
            _thumbnail: subschemas_1.ENTITY_IMAGE_SCHEMA,
            attendanceType: {
                type: "string",
                enum: [
                    hubEventAttendanceType_1.HubEventAttendanceType.InPerson,
                    hubEventAttendanceType_1.HubEventAttendanceType.Online,
                    hubEventAttendanceType_1.HubEventAttendanceType.Both,
                ],
                default: hubEventAttendanceType_1.HubEventAttendanceType.InPerson,
            },
            startDate: {
                type: "string",
                format: "date",
            },
            endDate: {
                type: "string",
                format: "date",
                formatMinimum: {
                    $data: "1/startDate",
                },
            },
            startTime: {
                type: "string",
            },
            endTime: {
                type: "string",
            },
            isAllDay: {
                type: "boolean",
                default: false,
            },
            timeZone: {
                type: "string",
            },
            inPersonCapacity: {
                type: "number",
            },
            inPersonCapacityType: {
                type: "string",
                enum: [hubEventCapacityType_1.HubEventCapacityType.Unlimited, hubEventCapacityType_1.HubEventCapacityType.Fixed],
                default: hubEventCapacityType_1.HubEventCapacityType.Unlimited,
            },
            location: Object.assign(Object.assign({}, subschemas_1.ENTITY_LOCATION_SCHEMA), { allOf: [
                    {
                        if: {
                            properties: { type: { enum: ["custom", "org"] } },
                        },
                        then: {
                            required: ["name"],
                        },
                    },
                ] }),
            onlineUrl: {
                type: "string",
            },
            onlineDetails: {
                type: "string",
            },
            onlineCapacity: {
                type: "number",
            },
            onlineCapacityType: {
                type: "string",
                enum: [hubEventCapacityType_1.HubEventCapacityType.Unlimited, hubEventCapacityType_1.HubEventCapacityType.Fixed],
                default: hubEventCapacityType_1.HubEventCapacityType.Unlimited,
            },
            /* This field hidden for future consideration */
            // referencedContentIds: {
            //   type: "array",
            //   maxItems: 1,
            //   items: {
            //     type: "string",
            //   },
            //   default: [],
            // },
            summary: subschemas_1.ENTITY_SUMMARY_SCHEMA,
            tags: subschemas_1.ENTITY_TAGS_SCHEMA,
            categories: subschemas_1.ENTITY_CATEGORIES_SCHEMA,
        },
        allOf: [
            validations_1.URL_VALIDATIONS_WHEN_ONLINE_OR_HYBRID,
            validations_1.TIME_VALIDATIONS_WHEN_NOT_ALL_DAY,
            validations_1.FIXED_ONLINE_ATTENDANCE_VALIDATIONS,
            validations_1.FIXED_IN_PERSON_ATTENDANCE_VALIDATIONS,
        ],
    };
};
exports.buildSchema = buildSchema;
//# sourceMappingURL=EventSchemaEdit.js.map