import { d as n } from "./global-loader-CbmVhJAK.js";
var f = /* @__PURE__ */ ((r) => (r.Year = "YEAR", r.Month = "MONTH", r.Week = "WEEK", r.Day = "DAY", r))(f || {});
function T(r, e = 100, t = !1) {
  let a = null;
  const l = (...c) => {
    const s = () => {
      a = null, t !== !0 && r.apply(this, c);
    };
    a !== null ? clearTimeout(a) : t === !0 && r.apply(this, c), a = setTimeout(s, e);
  };
  return l.cancel = () => {
    a !== null && clearTimeout(a);
  }, l;
}
function M() {
  return [...Array(12).keys()].map((r) => n().month(r).format("MMM"));
}
function w(r, e, t = "") {
  switch (r.type) {
    case f.Day:
      return e("report.schedule.everyDay");
    case f.Week: {
      let a = `${e("report.schedule.everyWeek")} `;
      const l = [
        e("report.days.sunday"),
        e("report.days.monday"),
        e("report.days.tuesday"),
        e("report.days.wednesday"),
        e("report.days.thursday"),
        e("report.days.friday"),
        e("report.days.saturday")
      ];
      if (r.days)
        for (let c = 0; c < r.days.length; c++)
          a = a + l[r.days[c]] + (c !== r.days.length - 1 ? "," : "");
      return a;
    }
    case f.Month: {
      let a = `${e("report.schedule.everyMonth")} `;
      return r.days && (a = a + r.days.join(",")), a;
    }
    case f.Year: {
      if (!r.months && !r.days)
        return e("report.schedule.customDate");
      let a = `${e("report.schedule.everyYear")} `;
      if (r.months) {
        const l = M();
        a = a + r.months.map((c) => l[c - 1]).join(",");
      }
      return r.months && r.days && (a = a + ` ${e("report.common.and")} `), r.days && (a = a + r.days.join(",")), a;
    }
    default:
      return t;
  }
}
function $(r = {
  startDate: null,
  endDate: null,
  locale: "en-US"
}) {
  if (!r.startDate || !r.endDate)
    return "No comparison";
  let e = n().subtract(1, "day").endOf("day"), t = n().endOf("day");
  return r.startDate && (e = n(r.startDate).locale(r.locale)), r.endDate && (t = n(r.endDate).locale(r.locale)), e.format("YYYY") !== t.format("YYYY") ? `${e.format("DD MMM YYYY")} - ${t.format("DD MMM YYYY")}` : `${e.format("DD MMM")} - ${t.format("DD MMM YYYY")}`;
}
const x = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), A = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), _ = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), P = /[^\p{L}\d]+/giu, D = "$1\0$2", Y = "";
function E(r) {
  let e = r.trim();
  e = e.replace(x, D).replace(A, D), e = e.replace(P, "\0");
  let t = 0, a = e.length;
  for (; e.charAt(t) === "\0"; )
    t++;
  if (t === a)
    return [];
  for (; e.charAt(a - 1) === "\0"; )
    a--;
  return e.slice(t, a).split(/\0/g);
}
function R(r) {
  const e = E(r);
  for (let t = 0; t < e.length; t++) {
    const a = e[t], l = _.exec(a);
    if (l) {
      const c = l.index + (l[1] ?? l[2]).length;
      e.splice(t, 1, a.slice(0, c), a.slice(c));
    }
  }
  return e;
}
function S(r, e) {
  const [t, a, l] = i(r, e), c = y(e == null ? void 0 : e.locale), s = h(e == null ? void 0 : e.locale), u = e != null && e.mergeAmbiguousCharacters ? m(c, s) : g(c, s);
  return t + a.map(u).join((e == null ? void 0 : e.delimiter) ?? "") + l;
}
function U(r, e) {
  const [t, a, l] = i(r, e), c = y(e == null ? void 0 : e.locale), s = h(e == null ? void 0 : e.locale);
  return t + a.map(m(c, s)).join((e == null ? void 0 : e.delimiter) ?? " ") + l;
}
function F(r, e) {
  const [t, a, l] = i(r, e), c = y(e == null ? void 0 : e.locale), s = h(e == null ? void 0 : e.locale), u = m(c, s);
  return t + a.map((d, L) => L === 0 ? u(d) : c(d)).join((e == null ? void 0 : e.delimiter) ?? " ") + l;
}
function y(r) {
  return r === !1 ? (e) => e.toLowerCase() : (e) => e.toLocaleLowerCase(r);
}
function h(r) {
  return r === !1 ? (e) => e.toUpperCase() : (e) => e.toLocaleUpperCase(r);
}
function m(r, e) {
  return (t) => `${e(t[0])}${r(t.slice(1))}`;
}
function g(r, e) {
  return (t, a) => {
    const l = t[0];
    return (a > 0 && l >= "0" && l <= "9" ? "_" + l : e(l)) + r(t.slice(1));
  };
}
function i(r, e = {}) {
  const t = e.split ?? (e.separateNumbers ? R : E), a = e.prefixCharacters ?? Y, l = e.suffixCharacters ?? Y;
  let c = 0, s = r.length;
  for (; c < r.length; ) {
    const u = r.charAt(c);
    if (!a.includes(u))
      break;
    c++;
  }
  for (; s > c; ) {
    const u = s - 1, d = r.charAt(u);
    if (!l.includes(d))
      break;
    s = u;
  }
  return [
    r.slice(0, c),
    t(r.slice(c, s)),
    r.slice(s)
  ];
}
export {
  f as C,
  w as a,
  $ as b,
  U as c,
  T as d,
  M as g,
  S as p,
  F as s
};
