import { z } from "zod";

export const HolidayCalendarScopeSchema = z.enum(["COUNTRY", "STATE", "CITY"]);

export const CreateHolidayCalendarSchema = z.object({
  name: z.string().min(1).max(120),
  scopeType: HolidayCalendarScopeSchema,
  countryId: z.string(),
  stateCode: z.string().trim().min(1).max(16).optional(),
  metroCityId: z.string().optional(),
  isActive: z.boolean().optional(),
  priority: z.number().int().min(-100).max(100).optional(),
});

export const UpdateHolidayCalendarSchema = z.object({
  name: z.string().min(1).max(120).optional(),
  stateCode: z.string().trim().min(1).max(16).nullable().optional(),
  metroCityId: z.string().nullable().optional(),
  isActive: z.boolean().optional(),
  priority: z.number().int().min(-100).max(100).optional(),
});

export const CreateHolidayCalendarEntrySchema = z.object({
  holidayCalendarId: z.string(),
  date: z.coerce.date(),
  name: z.string().min(1).max(120),
  isRecurringAnnual: z.boolean().optional(),
  source: z.string().max(120).optional(),
});

export const UpdateHolidayCalendarEntrySchema = z.object({
  date: z.coerce.date().optional(),
  name: z.string().min(1).max(120).optional(),
  isRecurringAnnual: z.boolean().optional(),
  source: z.string().max(120).nullable().optional(),
});

export const PreviewResolvedHolidaysSchema = z.object({
  countryId: z.string(),
  stateCode: z.string().trim().min(1).max(16).optional(),
  metroCityId: z.string().optional(),
  year: z.number().int().min(2000).max(2100),
});

export type HolidayCalendarScopeInput = z.infer<typeof HolidayCalendarScopeSchema>;
export type CreateHolidayCalendarInput = z.infer<typeof CreateHolidayCalendarSchema>;
export type UpdateHolidayCalendarInput = z.infer<typeof UpdateHolidayCalendarSchema>;
export type CreateHolidayCalendarEntryInput = z.infer<typeof CreateHolidayCalendarEntrySchema>;
export type UpdateHolidayCalendarEntryInput = z.infer<typeof UpdateHolidayCalendarEntrySchema>;
export type PreviewResolvedHolidaysInput = z.infer<typeof PreviewResolvedHolidaysSchema>;
