"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.filterOffboardingCaseSchema = exports.calculateFinalSettlementSchema = exports.submitExitInterviewSchema = exports.createExitInterviewTemplateSchema = exports.updateEquipmentReturnSchema = exports.addEquipmentReturnSchema = exports.updateOffboardingTaskSchema = exports.createOffboardingTaskSchema = exports.updateOffboardingCaseSchema = exports.createOffboardingCaseSchema = exports.createOffboardingTemplateSchema = exports.settlementStatusSchema = exports.offboardingReasonSchema = exports.offboardingCaseStatusSchema = exports.taskStatusEnumSchema = exports.priorityEnumSchema = exports.taskOwnerTypeEnumSchema = void 0;
const zod_1 = require("zod");
const optionalString = zod_1.z.preprocess((val) => {
    if (typeof val === 'string' && val.trim() === '')
        return undefined;
    return val;
}, zod_1.z.string().trim().optional());
const optionalDate = zod_1.z.preprocess((val) => {
    if (val === null || val === undefined || val === '')
        return undefined;
    return val;
}, zod_1.z.coerce.date().optional());
exports.taskOwnerTypeEnumSchema = zod_1.z.enum(['hr', 'it', 'manager', 'employee', 'finance']);
exports.priorityEnumSchema = zod_1.z.enum(['low', 'medium', 'high', 'critical']);
exports.taskStatusEnumSchema = zod_1.z.enum(['pending', 'in_progress', 'completed', 'skipped']);
exports.offboardingCaseStatusSchema = zod_1.z.enum([
    'initiated',
    'in_progress',
    'pending_clearance',
    'pending_settlement',
    'ready_to_close',
    'completed',
    'cancelled',
]);
exports.offboardingReasonSchema = zod_1.z.enum(['resignation', 'termination', 'retirement', 'contract_end', 'other']);
exports.settlementStatusSchema = zod_1.z.enum([
    'draft',
    'calculated',
    'under_review',
    'approved',
    'included_in_payroll',
    'paid',
    'cancelled',
]);
exports.createOffboardingTemplateSchema = zod_1.z.object({
    title: zod_1.z.string().min(2),
    description: optionalString,
    is_active: zod_1.z.boolean().optional().default(true),
    tasks: zod_1.z.array(zod_1.z.object({
        title: zod_1.z.string().min(2),
        description: optionalString,
        owner_type: exports.taskOwnerTypeEnumSchema.default('hr'),
        priority: exports.priorityEnumSchema.default('medium'),
        relative_due_days: zod_1.z.number().int().default(7),
        order_index: zod_1.z.number().int().default(0),
    })).optional(),
});
exports.createOffboardingCaseSchema = zod_1.z.object({
    member_id: zod_1.z.string().min(1),
    template_id: optionalString,
    reason: exports.offboardingReasonSchema.default('resignation'),
    last_working_date: optionalDate,
    notice_period_days: zod_1.z.number().int().min(0).default(30),
    notes: optionalString,
});
exports.updateOffboardingCaseSchema = zod_1.z.object({
    status: exports.offboardingCaseStatusSchema.optional(),
    last_working_date: optionalDate,
    notice_period_days: zod_1.z.number().int().optional(),
    notes: optionalString,
});
exports.createOffboardingTaskSchema = zod_1.z.object({
    title: zod_1.z.string().min(2),
    description: optionalString,
    owner_type: exports.taskOwnerTypeEnumSchema.default('hr'),
    assigned_member_id: optionalString,
    due_date: optionalDate,
    priority: exports.priorityEnumSchema.default('medium'),
    order_index: zod_1.z.number().int().default(0),
    notes: optionalString,
});
exports.updateOffboardingTaskSchema = zod_1.z.object({
    title: optionalString,
    description: optionalString,
    owner_type: exports.taskOwnerTypeEnumSchema,
    assigned_member_id: optionalString,
    due_date: optionalDate,
    priority: exports.priorityEnumSchema,
    status: exports.taskStatusEnumSchema,
    notes: optionalString,
});
exports.addEquipmentReturnSchema = zod_1.z.object({
    item_name: zod_1.z.string().min(2),
    item_type: zod_1.z.string().default('hardware'),
    serial_number: optionalString,
    condition: zod_1.z.string().default('good'),
    notes: optionalString,
});
exports.updateEquipmentReturnSchema = zod_1.z.object({
    condition: zod_1.z.string().optional(),
    returned_at: optionalDate,
    notes: optionalString,
});
exports.createExitInterviewTemplateSchema = zod_1.z.object({
    title: zod_1.z.string().min(2),
    description: optionalString,
    is_active: zod_1.z.boolean().optional().default(true),
    questions: zod_1.z.array(zod_1.z.object({
        id: zod_1.z.string(),
        question: zod_1.z.string(),
        type: zod_1.z.enum(['text', 'long_text', 'single_choice', 'multiple_choice', 'rating']),
        options: zod_1.z.array(zod_1.z.string()).optional(),
        required: zod_1.z.boolean().optional(),
    })),
});
exports.submitExitInterviewSchema = zod_1.z.object({
    responses: zod_1.z.record(zod_1.z.string(), zod_1.z.any()),
    notes: optionalString,
});
exports.calculateFinalSettlementSchema = zod_1.z.object({
    gross_salary: zod_1.z.number().optional(),
    unused_leave_days: zod_1.z.number().optional(),
    daily_leave_rate: zod_1.z.number().optional(),
    severance_amount: zod_1.z.number().optional(),
    notice_pay_adjustment: zod_1.z.number().optional(),
    deductions_amount: zod_1.z.number().optional(),
    notes: optionalString,
});
exports.filterOffboardingCaseSchema = zod_1.z.object({
    page: zod_1.z.preprocess((val) => Number(val) || 1, zod_1.z.number().int().min(1).default(1)),
    limit: zod_1.z.preprocess((val) => Number(val) || 10, zod_1.z.number().int().min(1).max(100).default(10)),
    search: optionalString,
    status: exports.offboardingCaseStatusSchema.optional(),
    member_id: optionalString,
});
//# sourceMappingURL=offboarding.dto.js.map