import { useMemo as d } from "react";
import { m as D, a as p } from "./constants.Ctgl3Xcy.js";
function T(t, e) {
  return new Intl.NumberFormat("en-US", {
    notation: "compact",
    compactDisplay: "short",
    maximumFractionDigits: e?.maxDecimalDigits
  }).format(t);
}
function b(t, e) {
  return d(() => {
    if (t)
      return T(t, e);
  }, [t, e]);
}
function g(t, e) {
  const n = y(t);
  let a;
  if (n.date) {
    const i = I(n.date, 2);
    a = C(i.restDateString, i.year);
  }
  if (!a || isNaN(a.getTime()))
    return /* @__PURE__ */ new Date(NaN);
  const s = a.getTime();
  let o = 0, u;
  if (n.time && (o = F(n.time), isNaN(o)))
    return /* @__PURE__ */ new Date(NaN);
  if (n.timezone) {
    if (u = x(n.timezone), isNaN(u))
      return /* @__PURE__ */ new Date(NaN);
  } else {
    const i = new Date(s + o), c = /* @__PURE__ */ new Date(0);
    return c.setFullYear(
      i.getUTCFullYear(),
      i.getUTCMonth(),
      i.getUTCDate()
    ), c.setHours(
      i.getUTCHours(),
      i.getUTCMinutes(),
      i.getUTCSeconds(),
      i.getUTCMilliseconds()
    ), c;
  }
  return new Date(s + o + u);
}
const f = {
  dateTimeDelimiter: /[T ]/,
  timeZoneDelimiter: /[Z ]/i,
  timezone: /([Z+-].*)$/
}, h = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, U = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, w = /^([+-])(\d{2})(?::?(\d{2}))?$/;
function y(t) {
  const e = {}, r = t.split(f.dateTimeDelimiter);
  let n;
  if (r.length > 2)
    return e;
  if (/:/.test(r[0]) ? n = r[0] : (e.date = r[0], n = r[1], f.timeZoneDelimiter.test(e.date) && (e.date = t.split(f.timeZoneDelimiter)[0], n = t.substr(
    e.date.length,
    t.length
  ))), n) {
    const a = f.timezone.exec(n);
    a ? (e.time = n.replace(a[1], ""), e.timezone = a[1]) : e.time = n;
  }
  return e;
}
function I(t, e) {
  const r = new RegExp(
    "^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
  ), n = t.match(r);
  if (!n) return { year: NaN, restDateString: "" };
  const a = n[1] ? parseInt(n[1]) : null, s = n[2] ? parseInt(n[2]) : null;
  return {
    year: s === null ? a : s * 100,
    restDateString: t.slice((n[1] || n[2]).length)
  };
}
function C(t, e) {
  if (e === null) return /* @__PURE__ */ new Date(NaN);
  const r = t.match(h);
  if (!r) return /* @__PURE__ */ new Date(NaN);
  const n = !!r[4], a = m(r[1]), s = m(r[2]) - 1, o = m(r[3]), u = m(r[4]), i = m(r[5]) - 1;
  if (n)
    return S(e, u, i) ? Z(e, u, i) : /* @__PURE__ */ new Date(NaN);
  {
    const c = /* @__PURE__ */ new Date(0);
    return !z(e, s, o) || !O(e, a) ? /* @__PURE__ */ new Date(NaN) : (c.setUTCFullYear(e, s, Math.max(a, o)), c);
  }
}
function m(t) {
  return t ? parseInt(t) : 1;
}
function F(t) {
  const e = t.match(U);
  if (!e) return NaN;
  const r = l(e[1]), n = l(e[2]), a = l(e[3]);
  return M(r, n, a) ? r * D + n * p + a * 1e3 : NaN;
}
function l(t) {
  return t && parseFloat(t.replace(",", ".")) || 0;
}
function x(t) {
  if (t === "Z") return 0;
  const e = t.match(w);
  if (!e) return 0;
  const r = e[1] === "+" ? -1 : 1, n = parseInt(e[2]), a = e[3] && parseInt(e[3]) || 0;
  return k(n, a) ? r * (n * D + a * p) : NaN;
}
function Z(t, e, r) {
  const n = /* @__PURE__ */ new Date(0);
  n.setUTCFullYear(t, 0, 4);
  const a = n.getUTCDay() || 7, s = (e - 1) * 7 + r + 1 - a;
  return n.setUTCDate(n.getUTCDate() + s), n;
}
const Y = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function N(t) {
  return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
}
function z(t, e, r) {
  return e >= 0 && e <= 11 && r >= 1 && r <= (Y[e] || (N(t) ? 29 : 28));
}
function O(t, e) {
  return e >= 1 && e <= (N(t) ? 366 : 365);
}
function S(t, e, r) {
  return e >= 1 && e <= 53 && r >= 0 && r <= 6;
}
function M(t, e, r) {
  return t === 24 ? e === 0 && r === 0 : r >= 0 && r < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
}
function k(t, e) {
  return e >= 0 && e <= 59;
}
function R(t) {
  return new Intl.DateTimeFormat("en-US", {
    month: "long",
    day: "numeric",
    year: "numeric"
  }).format(g(t));
}
function H(t) {
  return d(() => R(t), [t]);
}
function W(t, e = {}) {
  const r = Intl.DateTimeFormat().resolvedOptions().timeZone;
  return new Intl.DateTimeFormat("en-US", {
    month: "short",
    day: "numeric",
    year: "numeric",
    ...e.isDateOnly && {
      hour: "numeric",
      minute: "numeric"
    },
    ...e.isTimezoneDisplayed && {
      timeZone: e.timeZone || r,
      timeZoneName: "short"
    }
  }).format(t);
}
function _(t, e = {}) {
  return d(() => {
    if (t)
      return W(t, e);
  }, [t, e]);
}
export {
  R as a,
  H as b,
  W as c,
  _ as d,
  T as f,
  b as u
};
