"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bulkImportBooksSchema = exports.bulkUpdateBooksSchema = exports.bulkDeleteBooksSchema = exports.updateBookSchema = exports.createBookSchema = void 0;
const zod_1 = require("zod");
const localBookAsset = zod_1.z
    .string()
    .regex(/^\/assets\/(?:books|uploads\/books)\/[a-zA-Z0-9%._\/-]+$/, 'Book images must be uploaded to local storage.');
exports.createBookSchema = zod_1.z.object({
    title: zod_1.z.string().min(2, 'Title is required'),
    slug: zod_1.z.string().optional(),
    isbn: zod_1.z.string().min(10, 'Valid ISBN is required'),
    sku: zod_1.z.string().min(1).optional(),
    barcode: zod_1.z.string().optional(),
    description: zod_1.z.string().min(10, 'Description is required'),
    price: zod_1.z.number().positive('Price must be greater than 0'),
    discountPrice: zod_1.z.number().optional().nullable(),
    stock: zod_1.z.number().int().nonnegative('Stock cannot be negative').default(0),
    gstRate: zod_1.z.number().min(0).max(100).optional().default(0),
    format: zod_1.z.string().default('PAPERBACK'),
    binding: zod_1.z.string().optional().nullable(),
    language: zod_1.z.string().default('ENGLISH'),
    edition: zod_1.z.string().optional(),
    weight: zod_1.z.number().optional().nullable(),
    dimensions: zod_1.z.string().optional(),
    publisherId: zod_1.z.string().optional().nullable(),
    subCategoryId: zod_1.z.string().optional().nullable(),
    authorIds: zod_1.z.array(zod_1.z.string()).optional().default([]),
    categoryIds: zod_1.z.array(zod_1.z.string()).optional().default([]),
    publicationDate: zod_1.z.string().optional().nullable(),
    pageCount: zod_1.z.number().int().optional().nullable(),
    pagesText: zod_1.z.string().optional().nullable(),
    coverImage: localBookAsset.optional(),
    imageUrls: zod_1.z.array(localBookAsset).optional().default([]),
    metaTitle: zod_1.z.string().optional(),
    metaDescription: zod_1.z.string().optional(),
    status: zod_1.z.enum(['ENABLED', 'DISABLED']).optional().default('ENABLED'),
    displayOrder: zod_1.z.number().int().nonnegative().optional().default(0),
    isNewRelease: zod_1.z.boolean().optional().default(false),
    isFeatured: zod_1.z.boolean().optional().default(false),
    isTrending: zod_1.z.boolean().optional().default(false),
    isBestseller: zod_1.z.boolean().optional().default(false),
    variants: zod_1.z.array(zod_1.z.object({
        title: zod_1.z.string().optional(),
        format: zod_1.z.enum(['HARDCOVER', 'PAPERBACK', 'EBOOK', 'AUDIOBOOK']),
        isbn: zod_1.z.string().optional().nullable(),
        sku: zod_1.z.string().optional(),
        barcode: zod_1.z.string().optional().nullable(),
        price: zod_1.z.number().positive(),
        discountPrice: zod_1.z.number().positive().optional().nullable(),
        stock: zod_1.z.number().int().nonnegative().optional().default(0),
        weight: zod_1.z.number().positive().optional().nullable(),
        dimensions: zod_1.z.string().optional().nullable(),
        coverImage: localBookAsset.optional().nullable(),
        digitalFileUrl: zod_1.z.string().optional().nullable(),
        digitalFormat: zod_1.z.enum(['PDF', 'EPUB', 'MOBI', 'AZW3', 'MP3']).optional().nullable(),
        attributes: zod_1.z.record(zod_1.z.any()).optional().nullable(),
        isDefault: zod_1.z.boolean().optional().default(false),
        isActive: zod_1.z.boolean().optional().default(true),
    })).optional(),
});
exports.updateBookSchema = exports.createBookSchema.partial();
exports.bulkDeleteBooksSchema = zod_1.z.object({
    bookIds: zod_1.z.array(zod_1.z.string()).min(1, 'At least one book ID must be provided'),
});
exports.bulkUpdateBooksSchema = zod_1.z.object({
    bookIds: zod_1.z.array(zod_1.z.string()).min(1, 'At least one book ID must be provided'),
    data: zod_1.z.object({
        price: zod_1.z.number().optional(),
        discountPrice: zod_1.z.number().optional(),
        isFeatured: zod_1.z.boolean().optional(),
        isTrending: zod_1.z.boolean().optional(),
        isBestseller: zod_1.z.boolean().optional(),
        status: zod_1.z.enum(['ENABLED', 'DISABLED']).optional(),
        displayOrder: zod_1.z.number().int().nonnegative().optional(),
        stock: zod_1.z.number().optional(),
    }),
});
exports.bulkImportBooksSchema = zod_1.z.object({
    books: zod_1.z.array(exports.createBookSchema).min(1, 'Book array cannot be empty'),
});
//# sourceMappingURL=book.validator.js.map