"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.attendanceValidationSettingsResponseSchema = exports.updateAttendanceValidationSettingsSchema = exports.workDaySchedulesListResponseSchema = exports.workDayScheduleResponseSchema = exports.updateWorkDaySchedulesSchema = exports.singleWorkDayScheduleSchema = exports.leavePolicyResponseSchema = exports.workScheduleResponseSchema = exports.companyInfoResponseSchema = exports.updataLeavePolicySchema = exports.updateCompanyInfoSchema = exports.updateWorkScheduleSchema = void 0;
const zod_1 = __importDefault(require("zod"));
const timezone_util_1 = require("../../common/timezone/timezone.util");
const shared_dto_1 = require("../shared/shared.dto");
const optionalDate = zod_1.default.preprocess((value) => {
    if (value === null || value === undefined || value === '')
        return undefined;
    return value;
}, zod_1.default.coerce.date().optional());
const timezoneSchema = zod_1.default
    .string()
    .min(1)
    .refine((value) => (0, timezone_util_1.isValidIanaTimezone)(value), {
    message: 'Timezone must be a valid IANA timezone identifier',
});
exports.updateWorkScheduleSchema = zod_1.default.object({
    working_days: zod_1.default
        .array(zod_1.default.enum([
        'monday',
        'tuesday',
        'wednesday',
        'thursday',
        'friday',
        'saturday',
        'sunday',
    ]))
        .optional(),
    working_days_per_week: zod_1.default.number().optional(),
    working_hours_per_day: zod_1.default.number().optional(),
    office_start_time: optionalDate,
    office_end_time: optionalDate,
    half_day_min_time: zod_1.default.number().optional(),
    half_day_max_time: zod_1.default.number().optional(),
    timezone: timezoneSchema.optional(),
    monthly_correction_limit: zod_1.default.number().int().min(0).max(31).optional(),
});
exports.updateCompanyInfoSchema = zod_1.default.object({
    name: zod_1.default.string().optional(),
    company_code: zod_1.default.string().optional(),
    email: zod_1.default.string().email().optional(),
    phone: zod_1.default.string().optional(),
    address: zod_1.default.string().optional(),
    website: zod_1.default.string().optional(),
    logo: shared_dto_1.imageSchema.optional(),
    description: zod_1.default.string().optional(),
    founded_at: optionalDate,
    industry: zod_1.default.string().optional(),
});
exports.updataLeavePolicySchema = zod_1.default.object({
    annual_leave_days: zod_1.default.number().optional(),
    sick_leave_days: zod_1.default.number().optional(),
    casual_leave_days: zod_1.default.number().optional(),
    maternity_leave_days: zod_1.default.number().optional(),
    paternity_leave_days: zod_1.default.number().optional(),
    personal_leave_days: zod_1.default.number().optional(),
    compensatory_leave_days: zod_1.default.number().optional(),
    unpaid_leave_days: zod_1.default.number().optional(),
});
exports.companyInfoResponseSchema = zod_1.default.object({
    id: zod_1.default.string().optional(),
    name: shared_dto_1.defaultTransformSchema,
    company_code: shared_dto_1.defaultTransformSchema,
    email: shared_dto_1.defaultTransformSchema,
    phone: shared_dto_1.defaultTransformSchema,
    address: shared_dto_1.defaultTransformSchema,
    website: shared_dto_1.defaultTransformSchema,
    logo: shared_dto_1.imageSchema.nullable().optional(),
    description: shared_dto_1.defaultTransformSchema,
    founded_at: optionalDate,
    industry: shared_dto_1.defaultTransformSchema,
});
exports.workScheduleResponseSchema = zod_1.default.object({
    id: zod_1.default.string().optional(),
    working_days: zod_1.default.array(zod_1.default.enum([
        'monday',
        'tuesday',
        'wednesday',
        'thursday',
        'friday',
        'saturday',
        'sunday',
    ])),
    working_days_per_week: zod_1.default.number(),
    working_hours_per_day: zod_1.default.number(),
    office_start_time: optionalDate,
    office_end_time: optionalDate,
    half_day_min_time: zod_1.default.number().optional(),
    half_day_max_time: zod_1.default.number().optional(),
    timezone: timezoneSchema.optional(),
    monthly_correction_limit: zod_1.default.number().int().min(0).default(2),
});
exports.leavePolicyResponseSchema = zod_1.default.object({
    id: zod_1.default.string().optional(),
    annual_leave_days: zod_1.default.number(),
    sick_leave_days: zod_1.default.number(),
    casual_leave_days: zod_1.default.number(),
    maternity_leave_days: zod_1.default.number(),
    paternity_leave_days: zod_1.default.number(),
    personal_leave_days: zod_1.default.number(),
    compensatory_leave_days: zod_1.default.number(),
    unpaid_leave_days: zod_1.default.number(),
});
const timeStringSchema = zod_1.default
    .string()
    .regex(/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/, 'Time must be in HH:mm format');
exports.singleWorkDayScheduleSchema = zod_1.default.object({
    id: zod_1.default.string().uuid().optional(),
    day_of_week: zod_1.default.number().int().min(0).max(6),
    is_active: zod_1.default.boolean(),
    start_time: timeStringSchema.default('09:00'),
    end_time: timeStringSchema.default('17:00'),
    break_start: timeStringSchema.nullable().optional(),
    break_end: timeStringSchema.nullable().optional(),
    grace_period_minutes: zod_1.default.number().int().min(0).max(180).default(15),
});
exports.updateWorkDaySchedulesSchema = zod_1.default.object({
    schedules: zod_1.default.array(exports.singleWorkDayScheduleSchema).min(1).max(7),
});
exports.workDayScheduleResponseSchema = zod_1.default.object({
    id: zod_1.default.string().uuid(),
    owner_id: zod_1.default.string(),
    day_of_week: zod_1.default.number(),
    is_active: zod_1.default.boolean(),
    start_time: zod_1.default.string(),
    end_time: zod_1.default.string(),
    break_start: zod_1.default.string().nullable(),
    break_end: zod_1.default.string().nullable(),
    grace_period_minutes: zod_1.default.number(),
});
exports.workDaySchedulesListResponseSchema = zod_1.default.array(exports.workDayScheduleResponseSchema);
exports.updateAttendanceValidationSettingsSchema = zod_1.default.object({
    enforce_ip_whitelist: zod_1.default.boolean().optional(),
    enforce_location: zod_1.default.boolean().optional(),
    location_name: zod_1.default.string().trim().min(1).optional(),
    latitude: zod_1.default.number().nullable().optional(),
    longitude: zod_1.default.number().nullable().optional(),
    radius_meters: zod_1.default.number().int().min(10).max(10000).optional(),
});
exports.attendanceValidationSettingsResponseSchema = zod_1.default.object({
    id: zod_1.default.string().uuid().optional(),
    owner_id: zod_1.default.string().optional(),
    enforce_ip_whitelist: zod_1.default.boolean(),
    enforce_location: zod_1.default.boolean(),
    location_name: zod_1.default.string(),
    latitude: zod_1.default
        .union([zod_1.default.number(), zod_1.default.string()])
        .transform((val) => val === null || val === undefined ? null : Number(val))
        .nullable()
        .optional(),
    longitude: zod_1.default
        .union([zod_1.default.number(), zod_1.default.string()])
        .transform((val) => val === null || val === undefined ? null : Number(val))
        .nullable()
        .optional(),
    radius_meters: zod_1.default.number(),
    created_at: optionalDate,
    updated_at: optionalDate,
});
//# sourceMappingURL=configurations.dto.js.map