import u from "dayjs";
import { merge as f } from "lodash-unified";
import { ref as m, computed as D } from "vue";
import "../../config-provider/index.mjs";
import { presetsDefault as l } from "../../utils/data-range-persets.mjs";
import { useLocale as h } from "../../config-provider/hooks/use-locale.mjs";
const W = (t) => {
  const a = m(u().valueOf()), { t: s } = h();
  return {
    presets: D(() => {
      if (t.presets === !0)
        return l(
          t?.timezone?.value,
          a.value,
          s
        )?.filter(({ value: e }) => e.every(
          (r) => t.disabledDate ? !t.disabledDate(r) : !0
        ));
      if (typeof t.presets == "object" && !Array.isArray(t.presets)) {
        const e = f(
          {},
          {
            thisWeek: !0,
            lastWeek: !0,
            last7Days: !0,
            last30Days: !0,
            last90Days: !0,
            thisMonth: !0,
            lastMonth: !0,
            thisQuarter: !0,
            lastQuarter: !0,
            thisYear: !0,
            lastYear: !0
          },
          t.presets
        ), r = [
          e.thisWeek,
          e.lastWeek,
          e.last7Days,
          e.last30Days,
          e.last90Days,
          e.thisMonth,
          e.lastMonth,
          e.thisQuarter,
          e.lastQuarter,
          e.thisYear,
          e.lastYear
        ];
        return l(
          t?.timezone?.value,
          a.value,
          s
        )?.filter(({ value: i }, n) => i.every(
          (o) => t.disabledDate ? !t.disabledDate(o) : !0
        ) && r[n]);
      } else
        return t?.presets?.map?.((e) => ({
          label: e.label,
          value: e?.value?.filter((r) => r !== null)
        }));
    }),
    changeCurrentDate: () => {
      a.value = u().valueOf();
    }
  };
};
export {
  W as useDefaultPresets
};
