import { z } from 'zod';

// ===== 일정 유형 =====
export type CalendarScheduleType =
  | 'publicHoliday'
  | 'temporaryHoliday'
  | 'substituteHoliday'
  | 'taxDeadline'
  | 'companyEvent';

export const SCHEDULE_TYPE_OPTIONS = [
  { value: 'all', label: '전체' },
  { value: 'publicHoliday', label: '공휴일' },
  { value: 'temporaryHoliday', label: '임시휴일' },
  { value: 'substituteHoliday', label: '대체휴일' },
  { value: 'taxDeadline', label: '세무일정' },
  { value: 'companyEvent', label: '회사일정' },
] as const;

export const SCHEDULE_TYPE_LABELS: Record<CalendarScheduleType, string> = {
  publicHoliday: '공휴일',
  temporaryHoliday: '임시휴일',
  substituteHoliday: '대체휴일',
  taxDeadline: '세무일정',
  companyEvent: '회사일정',
};

export const SCHEDULE_TYPE_COLORS: Record<CalendarScheduleType, string> = {
  publicHoliday: 'red',
  temporaryHoliday: 'orange',
  substituteHoliday: 'pink',
  taxDeadline: 'green',
  companyEvent: 'blue',
};

export const SCHEDULE_TYPE_BADGE_COLORS: Record<CalendarScheduleType, string> = {
  publicHoliday: 'bg-red-100 text-red-800',
  temporaryHoliday: 'bg-orange-100 text-orange-800',
  substituteHoliday: 'bg-pink-100 text-pink-800',
  taxDeadline: 'bg-green-100 text-green-800',
  companyEvent: 'bg-blue-100 text-blue-800',
};

// ===== 일정 인터페이스 =====
export interface CalendarSchedule {
  id: string;
  name: string;
  type: CalendarScheduleType;
  startDate: string;
  endDate: string;
  days: number;
  isRecurring: boolean;
  memo: string;
}

// ===== 통계 =====
export interface CalendarStats {
  totalCount: number;
  totalHolidayDays: number;
  publicHolidayCount: number;
}

// ===== Zod 폼 스키마 =====
export const calendarScheduleFormSchema = z.object({
  name: z.string().min(1, '일정명을 입력하세요'),
  type: z.enum(
    ['publicHoliday', 'temporaryHoliday', 'substituteHoliday', 'taxDeadline', 'companyEvent'],
    { message: '유형을 선택하세요' }
  ),
  startDate: z.string().min(1, '시작일을 선택하세요'),
  endDate: z.string().min(1, '종료일을 선택하세요'),
  isRecurring: z.boolean(),
  memo: z.string(),
});

export type CalendarScheduleFormData = z.infer<typeof calendarScheduleFormSchema>;

// ===== 대량 등록 파싱 결과 =====
export interface BulkScheduleItem {
  name: string;
  type: CalendarScheduleType;
  startDate: string;
  endDate: string;
  isValid: boolean;
}
