'use strict';

const z = require('zod');

const PrioritySchema = z.z.enum(["LOW", "MEDIUM", "HIGH", "URGENT"]);
const boardDateFields = {
  createdAt: z.z.coerce.date().optional(),
  updatedAt: z.z.coerce.date().optional()
};
const boardCoreFields = {
  name: z.z.string().min(1, "Name is required"),
  slug: z.z.string().min(1, "Slug is required"),
  description: z.z.string().optional(),
  ownerId: z.z.string().optional(),
  organizationId: z.z.string().optional()
};
const BoardDomainSchema = z.z.object({
  id: z.z.string().optional(),
  ...boardCoreFields,
  ...boardDateFields
});
const createBoardSchema = BoardDomainSchema.extend({
  slug: BoardDomainSchema.shape.slug.optional()
}).omit({ id: true });
const updateBoardSchema = BoardDomainSchema.extend({
  id: z.z.string()
}).partial().required({ id: true });
const columnDateFields = {
  createdAt: z.z.coerce.date().optional(),
  updatedAt: z.z.coerce.date().optional()
};
const columnCoreFields = {
  title: z.z.string().min(1, "Title is required"),
  order: z.z.number().int().min(0).optional().default(0),
  boardId: z.z.string().min(1, "Board ID is required")
};
const ColumnDomainSchema = z.z.object({
  id: z.z.string().optional(),
  ...columnCoreFields,
  ...columnDateFields
});
const createColumnSchema = ColumnDomainSchema.omit({ id: true });
const updateColumnSchema = ColumnDomainSchema.extend({
  id: z.z.string()
}).partial().required({ id: true });
const taskDateFields = {
  completedAt: z.z.coerce.date().optional(),
  createdAt: z.z.coerce.date().optional(),
  updatedAt: z.z.coerce.date().optional()
};
const taskCoreFields = {
  title: z.z.string().min(1, "Title is required"),
  description: z.z.string().optional(),
  priority: PrioritySchema.optional().default("MEDIUM"),
  order: z.z.number().int().min(0).optional().default(0),
  columnId: z.z.string().min(1, "Column ID is required"),
  assigneeId: z.z.string().optional().nullable(),
  isArchived: z.z.boolean().optional().default(false)
};
const TaskDomainSchema = z.z.object({
  id: z.z.string().optional(),
  ...taskCoreFields,
  ...taskDateFields
});
const createTaskSchema = TaskDomainSchema.omit({ id: true });
const updateTaskSchema = TaskDomainSchema.extend({
  id: z.z.string()
}).partial().required({ id: true });
const BoardListQuerySchema = z.z.object({
  slug: z.z.string().optional(),
  ownerId: z.z.string().optional(),
  organizationId: z.z.string().optional(),
  offset: z.z.coerce.number().int().min(0).optional(),
  limit: z.z.coerce.number().int().min(1).max(100).optional()
});
z.z.object({
  boardId: z.z.string().optional()
});
z.z.object({
  columnId: z.z.string().optional(),
  assigneeId: z.z.string().optional(),
  priority: PrioritySchema.optional(),
  isArchived: z.z.string().optional().transform((val) => {
    if (val === void 0) return void 0;
    if (val === "true") return true;
    if (val === "false") return false;
    return void 0;
  })
});
const reorderColumnsSchema = z.z.object({
  boardId: z.z.string().min(1, "Board ID is required"),
  columnIds: z.z.array(z.z.string()).min(1, "Column IDs are required")
});
const reorderTasksSchema = z.z.object({
  columnId: z.z.string().min(1, "Column ID is required"),
  taskIds: z.z.array(z.z.string()).min(1, "Task IDs are required")
});
const moveTaskSchema = z.z.object({
  taskId: z.z.string().min(1, "Task ID is required"),
  targetColumnId: z.z.string().min(1, "Target column ID is required"),
  targetOrder: z.z.number().int().min(0)
});

exports.BoardDomainSchema = BoardDomainSchema;
exports.BoardListQuerySchema = BoardListQuerySchema;
exports.ColumnDomainSchema = ColumnDomainSchema;
exports.PrioritySchema = PrioritySchema;
exports.TaskDomainSchema = TaskDomainSchema;
exports.createBoardSchema = createBoardSchema;
exports.createColumnSchema = createColumnSchema;
exports.createTaskSchema = createTaskSchema;
exports.moveTaskSchema = moveTaskSchema;
exports.reorderColumnsSchema = reorderColumnsSchema;
exports.reorderTasksSchema = reorderTasksSchema;
exports.updateBoardSchema = updateBoardSchema;
exports.updateColumnSchema = updateColumnSchema;
exports.updateTaskSchema = updateTaskSchema;
