import { InjectionToken } from '@angular/core';
import { subYears, addYears } from 'date-fns';
import { DateValue } from './types';

/**
 * Injection token for the default minimum date value in the datepicker.
 * Uses date-fns subYears to calculate a default date 4 years in the past.
 *
 * @type {InjectionToken<DateValue | undefined>}
 */
export const UI_DATEPICKER_DEFAULT_MIN = new InjectionToken<
  DateValue | undefined
>('UI_DATEPICKER_DEFAULT_MIN', {
  providedIn: 'root',
  factory: () => subYears(new Date(), 4), // Default to January 1, 2022
});

/**
 * Injection token for the default maximum date value in the datepicker.
 * Uses date-fns addYears to calculate a default date 1 year in the future.
 *
 * @type {InjectionToken<DateValue | undefined>}
 */
export const UI_DATEPICKER_DEFAULT_MAX = new InjectionToken<
  DateValue | undefined
>('UI_DATEPICKER_DEFAULT_MAX', {
  providedIn: 'root',
  factory: () => addYears(new Date(), 1), // No default max date
});
