/**
 * CronEditor type definitions
 * @countermeasure/web-components/form/cron-editor
 */

export type CronField = 'minute' | 'hour' | 'day' | 'month' | 'weekday'
export type CronFieldMode = 'every' | 'specific' | 'range' | 'interval'

export interface CronFieldConfig {
  /** Field selection mode (every/specific/range/interval). */
  mode: CronFieldMode
  /** Selected values when `mode` is `'specific'`. */
  specific?: number[]
  /** Range start when `mode` is `'range'`. */
  rangeStart?: number
  /** Range end when `mode` is `'range'`. */
  rangeEnd?: number
  /** Step interval when `mode` is `'interval'`. */
  interval?: number
  /** Starting offset for `'interval'` mode. */
  intervalStart?: number
}

export interface CronConfig {
  /** Container element (or selector) the editor is mounted into. */
  container: HTMLElement | string
  /**
   * Initial cron expression (5-field standard format).
   * @default '* * * * *'
   */
  value?: string
  /**
   * Show the human-readable expression preview.
   * @default true
   */
  showPreview?: boolean
  /**
   * Show the upcoming next-run timestamps list.
   * @default false
   */
  showNextRuns?: boolean
  /**
   * Number of upcoming runs to display when `showNextRuns` is enabled.
   * @default 5
   */
  nextRunCount?: number
  /** Additional CSS class names. */
  className?: string
  /** Called whenever the cron expression changes. */
  onChange?: (expression: string) => void
}

export interface ParsedCron {
  minute: CronFieldConfig
  hour: CronFieldConfig
  day: CronFieldConfig
  month: CronFieldConfig
  weekday: CronFieldConfig
}
