"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.monthHistoryResponseArraySchema = exports.monthHistoryResponseSchema = exports.monthHistoryQuerySchema = exports.optionalDate = exports.DepartmentSchema = void 0;
const zod_1 = require("zod");
const shared_dto_1 = require("../shared/shared.dto");
exports.DepartmentSchema = zod_1.z.object({
    id: zod_1.z.string(),
    name: zod_1.z.string(),
});
exports.optionalDate = zod_1.z.preprocess((value) => {
    if (value === undefined || value === null || value === '') {
        return value;
    }
    if (value instanceof Date) {
        return value;
    }
    if (typeof value === 'string') {
        return new Date(value);
    }
    return value;
}, zod_1.z
    .date()
    .transform((date) => date.toISOString())
    .optional()
    .nullable());
exports.monthHistoryQuerySchema = zod_1.z.object({
    month: zod_1.z.preprocess((value) => {
        if (value === undefined || value === null || value === '') {
            return new Date().getMonth() + 1;
        }
        const parsed = Number(value);
        return Number.isNaN(parsed) ? value : parsed;
    }, zod_1.z.number().int().min(1).max(12)),
    year: zod_1.z.preprocess((value) => {
        if (value === undefined || value === null || value === '') {
            return new Date().getFullYear();
        }
        const parsed = Number(value);
        return Number.isNaN(parsed) ? value : parsed;
    }, zod_1.z.number().int().min(1970).max(3000)),
    data_scope: zod_1.z.enum(['own', 'all']).optional(),
});
exports.monthHistoryResponseSchema = zod_1.z.object({
    id: zod_1.z.string(),
    title: zod_1.z.string(),
    content: zod_1.z.string().optional().nullable(),
    date: exports.optionalDate,
    start_date: exports.optionalDate,
    end_date: exports.optionalDate,
    departments: zod_1.z.array(exports.DepartmentSchema).nullable(),
    department: exports.DepartmentSchema.nullable(),
    status: zod_1.z.string().optional().nullable(),
    image: shared_dto_1.imageSchema.nullable(),
    name: zod_1.z.string().optional().nullable(),
    type: zod_1.z.string().optional(),
    attendance_type: zod_1.z.string().optional(),
    priority: zod_1.z.string().optional().nullable(),
    check_in: exports.optionalDate,
    check_out: exports.optionalDate,
    break_hours: zod_1.z.number().nullable(),
    total_working_hours: zod_1.z.number().nullable(),
    lunch_start: exports.optionalDate,
    lunch_end: exports.optionalDate,
    breaks: zod_1.z.array(zod_1.z.object({
        break_start: exports.optionalDate,
        break_end: exports.optionalDate,
        note: zod_1.z.string().optional().nullable(),
    })),
    note: zod_1.z.string().optional(),
});
exports.monthHistoryResponseArraySchema = zod_1.z.array(exports.monthHistoryResponseSchema);
//# sourceMappingURL=calendar.dto.js.map