"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ownersResponseSchema = exports.authResponseSchema = exports.ownerResponseSchema = exports.updateOwnerSchema = exports.resendOtpSchema = exports.signinOwnerSchema = exports.createOwnerSchema = void 0;
const zod_1 = require("zod");
const shared_1 = require("../../constant/shared");
const shared_dto_1 = require("../shared/shared.dto");
exports.createOwnerSchema = zod_1.z.object({
    username: zod_1.z
        .string()
        .min(3, { message: 'Username must be at least 3 characters long' })
        .regex(/^[a-zA-Z0-9_]+$/, {
        message: 'Username can only contain letters, numbers, and underscores',
    }),
    name: zod_1.z
        .string()
        .min(3, { message: 'Name must be at least 3 characters long' }),
    email: zod_1.z.email({ message: 'Invalid email address' }),
    password: zod_1.z
        .string()
        .min(6, { message: 'Password must be at least 6 characters long' })
        .regex(/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{6,}$/, {
        message: 'Password must contain at least one letter and one number',
    }),
});
exports.signinOwnerSchema = zod_1.z
    .object({
    username: zod_1.z.string().optional(),
    email: zod_1.z.email({ message: 'Invalid email address' }).optional(),
    password: zod_1.z.string({ message: 'Password is required' }),
})
    .refine((data) => data.username || data.email, {
    message: 'Either username or email must be provided',
});
exports.resendOtpSchema = zod_1.z.object({
    email: zod_1.z.email({ message: 'Invalid email address' }),
});
exports.updateOwnerSchema = zod_1.z.object({
    username: zod_1.z
        .string()
        .min(3, { message: 'Username must be at least 3 characters long' })
        .regex(/^[a-zA-Z0-9_]+$/, {
        message: 'Username can only contain letters, numbers, and underscores',
    })
        .optional(),
    name: zod_1.z
        .string()
        .min(3, { message: 'Name must be at least 3 characters long' })
        .optional(),
    email: zod_1.z.email({ message: 'Invalid email address' }).optional(),
    phone: zod_1.z.string().optional(),
    address: zod_1.z.string().optional(),
    image: zod_1.z
        .object({
        file_name: zod_1.z.string(),
        original_name: zod_1.z.string(),
        file_size: zod_1.z.number(),
        mime_type: zod_1.z.string(),
    })
        .optional(),
});
exports.ownerResponseSchema = zod_1.z.object({
    id: zod_1.z.string().optional(),
    name: zod_1.z.string().optional(),
    username: zod_1.z.string().optional(),
    email: zod_1.z.string().optional(),
    image: shared_dto_1.imageSchema.optional(),
    address: zod_1.z
        .string()
        .transform((val) => {
        if (!val || val === shared_1.DEFAULT_VALUES.STRING)
            return '';
        return val;
    })
        .optional(),
    phone: zod_1.z
        .string()
        .transform((val) => {
        if (!val || val === shared_1.DEFAULT_VALUES.STRING)
            return '';
        return val;
    })
        .optional(),
    status: zod_1.z.string().optional(),
    created_at: zod_1.z
        .date()
        .transform((date) => date.toISOString())
        .optional(),
    updated_at: zod_1.z
        .date()
        .transform((date) => date.toISOString())
        .optional(),
    access_token: zod_1.z.string().optional(),
});
exports.authResponseSchema = zod_1.z.object({
    id: zod_1.z.string().optional(),
    name: zod_1.z.string().optional(),
    email: zod_1.z.string().optional(),
    username: zod_1.z.string().optional(),
    access_token: zod_1.z.string().optional(),
    role: zod_1.z.string().optional(),
    image: shared_dto_1.imageSchema.optional(),
    address: zod_1.z
        .string()
        .transform((val) => {
        if (!val || val === shared_1.DEFAULT_VALUES.STRING)
            return '';
        return val;
    })
        .optional(),
    phone: zod_1.z
        .string()
        .transform((val) => {
        if (!val || val === shared_1.DEFAULT_VALUES.STRING)
            return '';
        return val;
    })
        .optional(),
});
exports.ownersResponseSchema = zod_1.z.array(exports.ownerResponseSchema);
//# sourceMappingURL=owner.dto.js.map