import { isChinese as checkIsChinese, getDayjsLocale } from "./localeUtils";
var LABELS_ZH = {
  today: '今天',
  yesterday: '昨天',
  tomorrow: '明天'
};
var LABELS_EN = {
  today: 'Today',
  yesterday: 'Yesterday',
  tomorrow: 'Tomorrow'
};

/**
 * 判断日期相对于参考日期是今天、昨天还是明天
 *
 * @param date 要展示的日期
 * @param reference 参考日期（通常为「当前」dayjs()）
 * @returns 'today' | 'yesterday' | 'tomorrow' | null
 *
 * @example
 * getRelativeDay(dayjs(), dayjs())           // => 'today'
 * getRelativeDay(dayjs().add(1,'day'), dayjs()) // => 'tomorrow'
 * getRelativeDay(dayjs().subtract(1,'day'), dayjs()) // => 'yesterday'
 */
export function getRelativeDay(date, reference) {
  var d = date.startOf('day');
  var r = reference.startOf('day');
  var diff = d.diff(r, 'day');
  if (diff === 0) return 'today';
  if (diff === 1) return 'tomorrow';
  if (diff === -1) return 'yesterday';
  return null;
}

/**
 * 根据 locale 返回相对日期的展示文案
 * 未传 locale 时使用 getDayjsLocale()（与 locales.getLocale 同源）
 *
 * @param day 'today' | 'yesterday' | 'tomorrow'
 * @param locale dayjs locale，如 'zh-cn'、'en'
 * @returns 如 '今天'、'Today'
 */
export function getRelativeDayLabel(day, locale) {
  var resolvedLocale = locale !== null && locale !== void 0 ? locale : getDayjsLocale();
  var isZh = checkIsChinese(resolvedLocale);
  return isZh ? LABELS_ZH[day] : LABELS_EN[day];
}