import { getTimeFormatToZone as m, userTimezone as u } from "@aplus-frontend/utils";
import l from "dayjs";
const s = (a, e = l().valueOf()) => l(m(e, a ?? u)), M = (a, e) => {
  const t = s(a, e);
  return [t.startOf("day"), t.endOf("day")];
}, w = (a, e) => {
  const t = s(a, e);
  return [
    t.startOf("day").subtract(1, "day").startOf("day"),
    t.endOf("day").subtract(1, "day").endOf("day")
  ];
}, O = (a, e) => {
  const t = s(a, e);
  return [
    t.startOf("week").startOf("day"),
    t.endOf("week").endOf("day")
  ];
}, c = (a, e) => {
  const t = s(a, e);
  return [
    t.subtract(1, "week").startOf("week").startOf("day"),
    t.subtract(1, "week").endOf("week").endOf("day")
  ];
}, h = (a, e) => {
  const t = s(a, e);
  return [
    t.startOf("month").startOf("day"),
    t.endOf("month").endOf("day")
  ];
}, i = (a, e) => {
  const t = s(a, e);
  return [
    t.subtract(1, "month").startOf("month").startOf("day"),
    t.subtract(1, "month").endOf("month").endOf("day")
  ];
}, p = (a, e) => {
  const t = s(a, e), r = t.month(), o = Math.floor(r / 3), n = t.month(o * 3).date(1).startOf("day"), d = n.add(2, "month").endOf("month").endOf("day");
  return [n, d];
}, T = (a, e) => {
  const r = s(a, e).subtract(3, "month"), o = r.month(), n = Math.floor(o / 3), d = r.clone().month(n * 3).date(1).startOf("day"), y = d.clone().add(2, "month").endOf("month").endOf("day");
  return [d, y];
}, b = (a, e) => {
  const t = s(a, e);
  return [
    t.startOf("year").startOf("day"),
    t.endOf("year").endOf("day")
  ];
}, v = (a, e) => {
  const t = s(a, e);
  return [
    t.subtract(1, "year").startOf("year").startOf("day"),
    t.subtract(1, "year").endOf("year").endOf("day")
  ];
}, f = (a, e, t) => {
  const r = s(e, t);
  return [
    r.subtract(a - 1, "day").startOf("day"),
    r.endOf("day")
  ];
}, Q = (a, e, t) => [
  {
    label: t ? t("ap.field.thisWeek") : "本周",
    value: O(a, e)
  },
  {
    label: t ? t("ap.field.lastWeek") : "上周",
    value: c(a, e)
  },
  {
    label: t ? t("ap.field.lastXDays", { day: 7 }) : "近7天",
    value: f(7, a, e)
  },
  {
    label: t ? t("ap.field.lastXDays", { day: 30 }) : "近30天",
    value: f(30, a, e)
  },
  {
    label: t ? t("ap.field.lastXDays", { day: 90 }) : "近90天",
    value: f(90, a, e)
  },
  {
    label: t ? t("ap.field.thisMonth") : "本月",
    value: h(a, e)
  },
  {
    label: t ? t("ap.field.lastMonth") : "上月",
    value: i(a, e)
  },
  {
    label: t ? t("ap.field.thisQuarter") : "本季度",
    value: p(a, e)
  },
  {
    label: t ? t("ap.field.lastQuarter") : "上季度",
    value: T(a, e)
  },
  {
    label: t ? t("ap.field.thisYear") : "本年",
    value: b(a, e)
  },
  {
    label: t ? t("ap.field.lastYear") : "去年",
    value: v(a, e)
  }
];
export {
  Q as presetsDefault,
  i as presetsGetLastMonth,
  T as presetsGetLastQuarter,
  c as presetsGetLastWeek,
  f as presetsGetLastXDays,
  v as presetsGetLastYear,
  h as presetsGetThisMonth,
  p as presetsGetThisQuarter,
  O as presetsGetThisWeek,
  b as presetsGetThisYear,
  s as presetsGetTimezoneFormat,
  M as presetsGetToday,
  w as presetsGetYesterday
};
