"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deviceChangeRequestListSchema = exports.deviceChangeRequestResponseSchema = exports.teacherDeviceResponseSchema = exports.deviceChangeFilterSchema = exports.reviewDeviceChangeSchema = exports.requestDeviceChangeSchema = void 0;
const zod_1 = require("zod");
const shared_dto_1 = require("../shared/shared.dto");
const optionalString = zod_1.z.preprocess((value) => {
    if (typeof value === 'string' && value.trim() === '')
        return undefined;
    return value;
}, zod_1.z.string().trim().optional());
exports.requestDeviceChangeSchema = zod_1.z.object({
    device_id: zod_1.z.string().min(1, 'Device ID/fingerprint is required').trim(),
    device_name: optionalString,
    reason: zod_1.z.string().min(1, 'Reason for device change is required').trim(),
});
exports.reviewDeviceChangeSchema = zod_1.z.object({
    status: zod_1.z.enum(['approved', 'rejected'], {
        message: 'Status must be approved or rejected',
    }),
    admin_note: optionalString,
});
exports.deviceChangeFilterSchema = zod_1.z.object({
    status: zod_1.z.enum(['pending', 'approved', 'rejected', 'all']).optional(),
    member_id: zod_1.z.string().uuid().optional(),
});
exports.teacherDeviceResponseSchema = zod_1.z.object({
    id: zod_1.z.string().uuid(),
    member_id: zod_1.z.string().uuid(),
    device_id: zod_1.z.string(),
    device_name: shared_dto_1.nullableDefaultTransformSchema,
    last_ip: shared_dto_1.nullableDefaultTransformSchema,
    bound_at: shared_dto_1.dateTransformSchema,
    last_active_at: zod_1.z
        .date()
        .nullable()
        .transform((d) => (d ? d.toISOString() : null))
        .optional(),
    member: zod_1.z
        .object({
        id: zod_1.z.string().uuid(),
        first_name: zod_1.z.string(),
        last_name: shared_dto_1.defaultTransformSchema,
        employee_id: zod_1.z.string(),
        work_email: zod_1.z.string().optional(),
    })
        .optional(),
    created_at: shared_dto_1.dateTransformSchema,
    updated_at: shared_dto_1.dateTransformSchema,
});
exports.deviceChangeRequestResponseSchema = zod_1.z.object({
    id: zod_1.z.string().uuid(),
    member_id: zod_1.z.string().uuid(),
    owner_id: zod_1.z.string(),
    old_device_id: zod_1.z.string(),
    new_device_id: zod_1.z.string(),
    new_device_name: shared_dto_1.nullableDefaultTransformSchema,
    reason: shared_dto_1.nullableDefaultTransformSchema,
    status: zod_1.z.enum(['pending', 'approved', 'rejected']),
    reviewed_by_id: shared_dto_1.nullableDefaultTransformSchema,
    reviewed_at: zod_1.z
        .date()
        .nullable()
        .transform((d) => (d ? d.toISOString() : null))
        .optional(),
    admin_note: shared_dto_1.nullableDefaultTransformSchema,
    member: zod_1.z
        .object({
        id: zod_1.z.string().uuid(),
        first_name: zod_1.z.string(),
        last_name: shared_dto_1.defaultTransformSchema,
        employee_id: zod_1.z.string(),
        work_email: zod_1.z.string().optional(),
    })
        .optional(),
    created_at: shared_dto_1.dateTransformSchema,
    updated_at: shared_dto_1.dateTransformSchema,
});
exports.deviceChangeRequestListSchema = zod_1.z.array(exports.deviceChangeRequestResponseSchema);
//# sourceMappingURL=devices.dto.js.map