"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listCutsSchema = exports.updateCutSchema = exports.createCutSchema = void 0;
const zod_1 = require("zod");
const client_1 = require("@prisma/client");
const geojsonValidator = zod_1.z.string().refine((val) => {
    try {
        const parsed = JSON.parse(val);
        return parsed.type === 'Polygon' || parsed.type === 'MultiPolygon';
    }
    catch {
        return false;
    }
}, { message: 'Must be valid GeoJSON with type Polygon or MultiPolygon' });
exports.createCutSchema = zod_1.z.object({
    name: zod_1.z.string().min(1, 'Name is required'),
    description: zod_1.z.string().optional(),
    color: zod_1.z.string().regex(/^#[0-9a-fA-F]{6}$/, 'Must be a hex color').default('#3388ff'),
    opacity: zod_1.z.number().min(0).max(1).default(0.3),
    category: zod_1.z.nativeEnum(client_1.CutCategory).optional(),
    isPublic: zod_1.z.boolean().optional().default(false),
    isOfficial: zod_1.z.boolean().optional().default(false),
    geojson: geojsonValidator,
    bounds: zod_1.z.string().optional(),
    showLocations: zod_1.z.boolean().optional().default(true),
    exportEnabled: zod_1.z.boolean().optional().default(true),
    assignedTo: zod_1.z.string().optional(),
});
exports.updateCutSchema = zod_1.z.object({
    name: zod_1.z.string().min(1).optional(),
    description: zod_1.z.string().nullable().optional(),
    color: zod_1.z.string().regex(/^#[0-9a-fA-F]{6}$/, 'Must be a hex color').optional(),
    opacity: zod_1.z.number().min(0).max(1).optional(),
    category: zod_1.z.nativeEnum(client_1.CutCategory).nullable().optional(),
    isPublic: zod_1.z.boolean().optional(),
    isOfficial: zod_1.z.boolean().optional(),
    geojson: geojsonValidator.optional(),
    bounds: zod_1.z.string().nullable().optional(),
    showLocations: zod_1.z.boolean().optional(),
    exportEnabled: zod_1.z.boolean().optional(),
    assignedTo: zod_1.z.string().nullable().optional(),
    lastCanvassed: zod_1.z.string().datetime().nullable().optional(),
    completionPercentage: zod_1.z.number().int().min(0).max(100).optional(),
});
exports.listCutsSchema = zod_1.z.object({
    page: zod_1.z.coerce.number().int().positive().default(1),
    limit: zod_1.z.coerce.number().int().positive().max(100).default(20),
    category: zod_1.z.nativeEnum(client_1.CutCategory).optional(),
    search: zod_1.z.string().optional(),
});
//# sourceMappingURL=cuts.schemas.js.map