/**
 * German federal states (Bundesländer) for regional holiday support.
 */
export interface Bundesland {
  code: string;
  name: string;
}

export const BUNDESLAENDER: Bundesland[] = [
  { code: 'BW', name: 'Baden-Württemberg' },
  { code: 'BY', name: 'Bayern' },
  { code: 'BE', name: 'Berlin' },
  { code: 'BB', name: 'Brandenburg' },
  { code: 'HB', name: 'Bremen' },
  { code: 'HH', name: 'Hamburg' },
  { code: 'HE', name: 'Hessen' },
  { code: 'MV', name: 'Mecklenburg-Vorpommern' },
  { code: 'NI', name: 'Niedersachsen' },
  { code: 'NW', name: 'Nordrhein-Westfalen' },
  { code: 'RP', name: 'Rheinland-Pfalz' },
  { code: 'SL', name: 'Saarland' },
  { code: 'SN', name: 'Sachsen' },
  { code: 'ST', name: 'Sachsen-Anhalt' },
  { code: 'SH', name: 'Schleswig-Holstein' },
  { code: 'TH', name: 'Thüringen' },
];

export type HolidayCalculationType = 'fixed' | 'easter_relative';

/**
 * Holiday entity from the database
 */
export interface Holiday {
  zh_id: number;
  zh_name: string;
  zh_description?: string;
  zh_month?: number; // 1-12 for fixed dates
  zh_day?: number; // 1-31 for fixed dates
  zh_calculation_type: HolidayCalculationType;
  zh_easter_offset?: number; // Days offset from Easter (e.g., -2 for Good Friday)
  zh_bundesland?: string | null; // null = national, code = regional
  zh_priority: number; // 150 for national, 140 for regional
  zh_active: boolean;
  created_at: string;
  updated_at: string;
  date_for_year?: string; // Calculated date for specific year (YYYY-MM-DD)
  date_current_year?: string; // Calculated date for current year
  date_next_year?: string; // Calculated date for next year
}

/**
 * Holiday with calculated date information for a specific year
 */
export interface HolidayForYear {
  holiday: Holiday;
  date: string; // YYYY-MM-DD
  day_of_week: string; // e.g., "Monday"
  is_national: boolean;
  bundesland_name?: string;
}

/**
 * Response from getHolidaysForYear endpoint
 */
export interface HolidaysForYearResponse {
  year: number;
  bundesland?: string | null;
  bundesland_name?: string | null;
  holidays: Record<string, HolidayForYear>; // Key is YYYY-MM-DD date string
  count: number;
}

/**
 * Response from getHolidaysForDepartment endpoint
 */
export interface HolidaysForDepartmentResponse {
  year: number;
  department: {
    id: number;
    name: string;
    bundesland?: string | null;
    bundesland_name?: string | null;
  };
  holidays: Record<string, HolidayForYear>;
  count: number;
}

/**
 * Response from getUpcomingHolidays endpoint
 */
export interface UpcomingHolidaysResponse {
  ber_id: number;
  upcoming_holidays: Record<string, HolidayForYear>;
  count: number;
}

/**
 * Response from checkHoliday endpoint
 */
export interface CheckHolidayResponse {
  date: string;
  day_of_week: string;
  is_holiday: boolean;
  holiday_name?: string | null;
  is_working_day: boolean;
}

/**
 * Holiday statistics
 */
export interface HolidayStatistics {
  total: number;
  national: number;
  regional: number;
}

/**
 * Response from getStatistics endpoint
 */
export interface HolidayStatisticsResponse {
  bundesland?: string | null;
  bundesland_name?: string | null;
  statistics: HolidayStatistics;
}

/**
 * Form data for creating/updating holidays
 */
export interface HolidayFormData {
  zh_name: string;
  zh_description?: string;
  zh_calculation_type: HolidayCalculationType;
  zh_month?: number;
  zh_day?: number;
  zh_easter_offset?: number;
  zh_bundesland?: string | null;
  zh_priority?: number;
  zh_active?: boolean;
}

/**
 * Holiday info displayed in shift template
 */
export interface HolidayInfo {
  id: number;
  name: string;
  date: string; // Formatted date like "01.01" or "Easter +1"
  bundesland?: string | null;
  calculation_type: HolidayCalculationType;
}

/**
 * Validation errors for holiday form
 */
export interface HolidayValidationErrors {
  zh_name?: string[];
  zh_description?: string[];
  zh_calculation_type?: string[];
  zh_month?: string[];
  zh_day?: string[];
  zh_easter_offset?: string[];
  zh_bundesland?: string[];
  zh_priority?: string[];
  zh_active?: string[];
}
