import { VegaInternalTranslation } from '../translation/internal-translation-controller';
/**
 * Get a week days array
 *
 * @param {number} firstWeekDay - The first week day (0: Sunday, 1: Monday, ...)
 * @returns {number[]} - The week days array
 */
export const getWeekdays = (firstWeekDay = 0) => {
  const weekdays = [0, 1, 2, 3, 4, 5, 6];
  return weekdays.concat(weekdays).slice(firstWeekDay, firstWeekDay + 7);
};
export var WeekdayLongNames;
(function (WeekdayLongNames) {
  WeekdayLongNames["sun"] = "Sunday";
  WeekdayLongNames["mon"] = "Monday";
  WeekdayLongNames["tue"] = "Tuesday";
  WeekdayLongNames["wed"] = "Wednesday";
  WeekdayLongNames["thu"] = "Thursday";
  WeekdayLongNames["fri"] = "Friday";
  WeekdayLongNames["sat"] = "Saturday";
})(WeekdayLongNames || (WeekdayLongNames = {}));
/**
 * Get the system timezone identifier
 *
 * @returns {string} - The system timezone identifier (e.g., "America/New_York")
 */
export const getSystemTimezone = () => {
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
};
/**
 * Build an aria announcement string for date picker selection.
 * TODO: consider to implement i18n for aria announcement .
 *
 * @param {object} options - The options for building the announcement.
 * @param {'single' | 'range'} options.mode - The date picker selection mode.
 * @param {Nullable<CalendarDate>} options.startDate - The start date.
 * @param {Nullable<CalendarDate>} [options.endDate] - The end date (used in range mode).
 * @returns {string} - The aria announcement string.
 */
export const buildDatePickerAnnouncement = (options) => {
  const mode = options.mode;
  const startDate = options.startDate;
  const endDate = options.endDate;
  if (!startDate && !endDate) {
    return '';
  }
  // eslint-disable-next-line jsdoc/require-jsdoc
  const formatDate = (d) => `${d.getMonthName()} ${d.date} ${d.year}`;
  if (mode === 'single' && startDate) {
    return `${VegaInternalTranslation.t('Selected result')}: ${formatDate(startDate)}`;
  }
  if (mode === 'range') {
    const startDateLabel = VegaInternalTranslation.t('Start Date');
    const endDateLabel = VegaInternalTranslation.t('End Date');
    if (startDate && endDate) {
      return `${VegaInternalTranslation.t('Selected result')} ${startDateLabel}: ${formatDate(startDate)}. ${endDateLabel}: ${formatDate(endDate)}.`;
    }
    if (startDate) {
      return `${VegaInternalTranslation.t('Selected result')} ${startDateLabel}: ${formatDate(startDate)}.`;
    }
  }
  return '';
};
