import { z } from 'zod';

// Create a new CRM tag
export const createTagSchema = z.object({
  name: z.string().trim().min(1).max(100),
  description: z.string().max(500).optional(),
  color: z.string().regex(/^#[0-9a-fA-F]{6}$/, 'Must be a hex color (e.g. #1890ff)').optional(),
  syncToListmonk: z.boolean().optional(),
});

// Update an existing CRM tag
export const updateTagSchema = z.object({
  name: z.string().trim().min(1).max(100).optional(),
  description: z.string().max(500).optional().nullable(),
  color: z.string().regex(/^#[0-9a-fA-F]{6}$/, 'Must be a hex color').optional().nullable(),
});

// Delete tag query params
export const deleteTagQuerySchema = z.object({
  removeFromContacts: z.coerce.boolean().optional(),
  deleteListmonkList: z.coerce.boolean().optional(),
});

// Bulk tag operations
export const bulkTagSchema = z.object({
  tagName: z.string().trim().min(1).max(100),
  contactIds: z.array(z.string()).min(1).max(500),
});

export type CreateTagInput = z.infer<typeof createTagSchema>;
export type UpdateTagInput = z.infer<typeof updateTagSchema>;
export type DeleteTagQuery = z.infer<typeof deleteTagQuerySchema>;
export type BulkTagInput = z.infer<typeof bulkTagSchema>;
