const jt = 6e4, Gt = 36e5, Lt = 1e3, x = /* @__PURE__ */ Symbol.for("constructDateFrom");
function l(t, e) {
  return typeof t == "function" ? t(e) : t && typeof t == "object" && x in t ? t[x](e) : t instanceof Date ? new t.constructor(e) : new Date(e);
}
function h(t, e) {
  return l(e || t, t);
}
function Bt(t, e, n) {
  const r = h(t, n?.in);
  return isNaN(e) ? l(n?.in || t, NaN) : (e && r.setDate(r.getDate() + e), r);
}
let N = {};
function O() {
  return N;
}
function M(t, e) {
  const n = O(), r = e?.weekStartsOn ?? e?.locale?.options?.weekStartsOn ?? n.weekStartsOn ?? n.locale?.options?.weekStartsOn ?? 0, a = h(t, e?.in), o = a.getDay(), i = (o < r ? 7 : 0) + o - r;
  return a.setDate(a.getDate() - i), a.setHours(0, 0, 0, 0), a;
}
function P(t, e) {
  return M(t, { ...e, weekStartsOn: 1 });
}
function E(t, e) {
  const n = h(t, e?.in), r = n.getFullYear(), a = l(n, 0);
  a.setFullYear(r + 1, 0, 4), a.setHours(0, 0, 0, 0);
  const o = P(a), i = l(n, 0);
  i.setFullYear(r, 0, 4), i.setHours(0, 0, 0, 0);
  const u = P(i);
  return n.getTime() >= o.getTime() ? r + 1 : n.getTime() >= u.getTime() ? r : r - 1;
}
function W(t) {
  const e = h(t), n = new Date(
    Date.UTC(
      e.getFullYear(),
      e.getMonth(),
      e.getDate(),
      e.getHours(),
      e.getMinutes(),
      e.getSeconds(),
      e.getMilliseconds()
    )
  );
  return n.setUTCFullYear(e.getFullYear()), +t - +n;
}
function H(t, ...e) {
  const n = l.bind(
    null,
    t || e.find((r) => typeof r == "object")
  );
  return e.map(n);
}
function v(t, e) {
  const n = h(t, e?.in);
  return n.setHours(0, 0, 0, 0), n;
}
function Q(t, e, n) {
  const [r, a] = H(
    n?.in,
    t,
    e
  ), o = v(r), i = v(a), u = +o - W(o), f = +i - W(i);
  return Math.round((u - f) / 864e5);
}
function _(t, e) {
  const n = E(t, e), r = l(t, 0);
  return r.setFullYear(n, 0, 4), r.setHours(0, 0, 0, 0), P(r);
}
function X(t) {
  return t instanceof Date || typeof t == "object" && Object.prototype.toString.call(t) === "[object Date]";
}
function j(t) {
  return !(!X(t) && typeof t != "number" || isNaN(+h(t)));
}
function G(t, e) {
  const n = h(t, e?.in);
  return n.setFullYear(n.getFullYear(), 0, 1), n.setHours(0, 0, 0, 0), n;
}
const L = {
  lessThanXSeconds: {
    one: "less than a second",
    other: "less than {{count}} seconds"
  },
  xSeconds: {
    one: "1 second",
    other: "{{count}} seconds"
  },
  halfAMinute: "half a minute",
  lessThanXMinutes: {
    one: "less than a minute",
    other: "less than {{count}} minutes"
  },
  xMinutes: {
    one: "1 minute",
    other: "{{count}} minutes"
  },
  aboutXHours: {
    one: "about 1 hour",
    other: "about {{count}} hours"
  },
  xHours: {
    one: "1 hour",
    other: "{{count}} hours"
  },
  xDays: {
    one: "1 day",
    other: "{{count}} days"
  },
  aboutXWeeks: {
    one: "about 1 week",
    other: "about {{count}} weeks"
  },
  xWeeks: {
    one: "1 week",
    other: "{{count}} weeks"
  },
  aboutXMonths: {
    one: "about 1 month",
    other: "about {{count}} months"
  },
  xMonths: {
    one: "1 month",
    other: "{{count}} months"
  },
  aboutXYears: {
    one: "about 1 year",
    other: "about {{count}} years"
  },
  xYears: {
    one: "1 year",
    other: "{{count}} years"
  },
  overXYears: {
    one: "over 1 year",
    other: "over {{count}} years"
  },
  almostXYears: {
    one: "almost 1 year",
    other: "almost {{count}} years"
  }
}, B = (t, e, n) => {
  let r;
  const a = L[t];
  return typeof a == "string" ? r = a : e === 1 ? r = a.one : r = a.other.replace("{{count}}", e.toString()), n?.addSuffix ? n.comparison && n.comparison > 0 ? "in " + r : r + " ago" : r;
};
function D(t) {
  return (e = {}) => {
    const n = e.width ? String(e.width) : t.defaultWidth;
    return t.formats[n] || t.formats[t.defaultWidth];
  };
}
const I = {
  full: "EEEE, MMMM do, y",
  long: "MMMM do, y",
  medium: "MMM d, y",
  short: "MM/dd/yyyy"
}, A = {
  full: "h:mm:ss a zzzz",
  long: "h:mm:ss a z",
  medium: "h:mm:ss a",
  short: "h:mm a"
}, R = {
  full: "{{date}} 'at' {{time}}",
  long: "{{date}} 'at' {{time}}",
  medium: "{{date}}, {{time}}",
  short: "{{date}}, {{time}}"
}, V = {
  date: D({
    formats: I,
    defaultWidth: "full"
  }),
  time: D({
    formats: A,
    defaultWidth: "full"
  }),
  dateTime: D({
    formats: R,
    defaultWidth: "full"
  })
}, J = {
  lastWeek: "'last' eeee 'at' p",
  yesterday: "'yesterday at' p",
  today: "'today at' p",
  tomorrow: "'tomorrow at' p",
  nextWeek: "eeee 'at' p",
  other: "P"
}, $ = (t, e, n, r) => J[t];
function b(t) {
  return (e, n) => {
    const r = n?.context ? String(n.context) : "standalone";
    let a;
    if (r === "formatting" && t.formattingValues) {
      const i = t.defaultFormattingWidth || t.defaultWidth, u = n?.width ? String(n.width) : i;
      a = t.formattingValues[u] || t.formattingValues[i];
    } else {
      const i = t.defaultWidth, u = n?.width ? String(n.width) : t.defaultWidth;
      a = t.values[u] || t.values[i];
    }
    const o = t.argumentCallback ? t.argumentCallback(e) : e;
    return a[o];
  };
}
const z = {
  narrow: ["B", "A"],
  abbreviated: ["BC", "AD"],
  wide: ["Before Christ", "Anno Domini"]
}, U = {
  narrow: ["1", "2", "3", "4"],
  abbreviated: ["Q1", "Q2", "Q3", "Q4"],
  wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
}, K = {
  narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
  abbreviated: [
    "Jan",
    "Feb",
    "Mar",
    "Apr",
    "May",
    "Jun",
    "Jul",
    "Aug",
    "Sep",
    "Oct",
    "Nov",
    "Dec"
  ],
  wide: [
    "January",
    "February",
    "March",
    "April",
    "May",
    "June",
    "July",
    "August",
    "September",
    "October",
    "November",
    "December"
  ]
}, Z = {
  narrow: ["S", "M", "T", "W", "T", "F", "S"],
  short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
  abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
  wide: [
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
  ]
}, tt = {
  narrow: {
    am: "a",
    pm: "p",
    midnight: "mi",
    noon: "n",
    morning: "morning",
    afternoon: "afternoon",
    evening: "evening",
    night: "night"
  },
  abbreviated: {
    am: "AM",
    pm: "PM",
    midnight: "midnight",
    noon: "noon",
    morning: "morning",
    afternoon: "afternoon",
    evening: "evening",
    night: "night"
  },
  wide: {
    am: "a.m.",
    pm: "p.m.",
    midnight: "midnight",
    noon: "noon",
    morning: "morning",
    afternoon: "afternoon",
    evening: "evening",
    night: "night"
  }
}, et = {
  narrow: {
    am: "a",
    pm: "p",
    midnight: "mi",
    noon: "n",
    morning: "in the morning",
    afternoon: "in the afternoon",
    evening: "in the evening",
    night: "at night"
  },
  abbreviated: {
    am: "AM",
    pm: "PM",
    midnight: "midnight",
    noon: "noon",
    morning: "in the morning",
    afternoon: "in the afternoon",
    evening: "in the evening",
    night: "at night"
  },
  wide: {
    am: "a.m.",
    pm: "p.m.",
    midnight: "midnight",
    noon: "noon",
    morning: "in the morning",
    afternoon: "in the afternoon",
    evening: "in the evening",
    night: "at night"
  }
}, nt = (t, e) => {
  const n = Number(t), r = n % 100;
  if (r > 20 || r < 10)
    switch (r % 10) {
      case 1:
        return n + "st";
      case 2:
        return n + "nd";
      case 3:
        return n + "rd";
    }
  return n + "th";
}, rt = {
  ordinalNumber: nt,
  era: b({
    values: z,
    defaultWidth: "wide"
  }),
  quarter: b({
    values: U,
    defaultWidth: "wide",
    argumentCallback: (t) => t - 1
  }),
  month: b({
    values: K,
    defaultWidth: "wide"
  }),
  day: b({
    values: Z,
    defaultWidth: "wide"
  }),
  dayPeriod: b({
    values: tt,
    defaultWidth: "wide",
    formattingValues: et,
    defaultFormattingWidth: "wide"
  })
};
function p(t) {
  return (e, n = {}) => {
    const r = n.width, a = r && t.matchPatterns[r] || t.matchPatterns[t.defaultMatchWidth], o = e.match(a);
    if (!o)
      return null;
    const i = o[0], u = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], f = Array.isArray(u) ? ot(u, (c) => c.test(i)) : (
      // [TODO] -- I challenge you to fix the type
      at(u, (c) => c.test(i))
    );
    let m;
    m = t.valueCallback ? t.valueCallback(f) : f, m = n.valueCallback ? (
      // [TODO] -- I challenge you to fix the type
      n.valueCallback(m)
    ) : m;
    const d = e.slice(i.length);
    return { value: m, rest: d };
  };
}
function at(t, e) {
  for (const n in t)
    if (Object.prototype.hasOwnProperty.call(t, n) && e(t[n]))
      return n;
}
function ot(t, e) {
  for (let n = 0; n < t.length; n++)
    if (e(t[n]))
      return n;
}
function it(t) {
  return (e, n = {}) => {
    const r = e.match(t.matchPattern);
    if (!r) return null;
    const a = r[0], o = e.match(t.parsePattern);
    if (!o) return null;
    let i = t.valueCallback ? t.valueCallback(o[0]) : o[0];
    i = n.valueCallback ? n.valueCallback(i) : i;
    const u = e.slice(a.length);
    return { value: i, rest: u };
  };
}
const st = /^(\d+)(th|st|nd|rd)?/i, ut = /\d+/i, ct = {
  narrow: /^(b|a)/i,
  abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
  wide: /^(before christ|before common era|anno domini|common era)/i
}, dt = {
  any: [/^b/i, /^(a|c)/i]
}, ft = {
  narrow: /^[1234]/i,
  abbreviated: /^q[1234]/i,
  wide: /^[1234](th|st|nd|rd)? quarter/i
}, ht = {
  any: [/1/i, /2/i, /3/i, /4/i]
}, mt = {
  narrow: /^[jfmasond]/i,
  abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
  wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
}, lt = {
  narrow: [
    /^j/i,
    /^f/i,
    /^m/i,
    /^a/i,
    /^m/i,
    /^j/i,
    /^j/i,
    /^a/i,
    /^s/i,
    /^o/i,
    /^n/i,
    /^d/i
  ],
  any: [
    /^ja/i,
    /^f/i,
    /^mar/i,
    /^ap/i,
    /^may/i,
    /^jun/i,
    /^jul/i,
    /^au/i,
    /^s/i,
    /^o/i,
    /^n/i,
    /^d/i
  ]
}, gt = {
  narrow: /^[smtwf]/i,
  short: /^(su|mo|tu|we|th|fr|sa)/i,
  abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
  wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
}, wt = {
  narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
  any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
}, yt = {
  narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
  any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
}, bt = {
  any: {
    am: /^a/i,
    pm: /^p/i,
    midnight: /^mi/i,
    noon: /^no/i,
    morning: /morning/i,
    afternoon: /afternoon/i,
    evening: /evening/i,
    night: /night/i
  }
}, pt = {
  ordinalNumber: it({
    matchPattern: st,
    parsePattern: ut,
    valueCallback: (t) => parseInt(t, 10)
  }),
  era: p({
    matchPatterns: ct,
    defaultMatchWidth: "wide",
    parsePatterns: dt,
    defaultParseWidth: "any"
  }),
  quarter: p({
    matchPatterns: ft,
    defaultMatchWidth: "wide",
    parsePatterns: ht,
    defaultParseWidth: "any",
    valueCallback: (t) => t + 1
  }),
  month: p({
    matchPatterns: mt,
    defaultMatchWidth: "wide",
    parsePatterns: lt,
    defaultParseWidth: "any"
  }),
  day: p({
    matchPatterns: gt,
    defaultMatchWidth: "wide",
    parsePatterns: wt,
    defaultParseWidth: "any"
  }),
  dayPeriod: p({
    matchPatterns: yt,
    defaultMatchWidth: "any",
    parsePatterns: bt,
    defaultParseWidth: "any"
  })
}, Mt = {
  code: "en-US",
  formatDistance: B,
  formatLong: V,
  formatRelative: $,
  localize: rt,
  match: pt,
  options: {
    weekStartsOn: 0,
    firstWeekContainsDate: 1
  }
};
function Pt(t, e) {
  const n = h(t, e?.in);
  return Q(n, G(n)) + 1;
}
function Ot(t, e) {
  const n = h(t, e?.in), r = +P(n) - +_(n);
  return Math.round(r / 6048e5) + 1;
}
function C(t, e) {
  const n = h(t, e?.in), r = n.getFullYear(), a = O(), o = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? a.firstWeekContainsDate ?? a.locale?.options?.firstWeekContainsDate ?? 1, i = l(e?.in || t, 0);
  i.setFullYear(r + 1, 0, o), i.setHours(0, 0, 0, 0);
  const u = M(i, e), f = l(e?.in || t, 0);
  f.setFullYear(r, 0, o), f.setHours(0, 0, 0, 0);
  const m = M(f, e);
  return +n >= +u ? r + 1 : +n >= +m ? r : r - 1;
}
function kt(t, e) {
  const n = O(), r = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? n.firstWeekContainsDate ?? n.locale?.options?.firstWeekContainsDate ?? 1, a = C(t, e), o = l(e?.in || t, 0);
  return o.setFullYear(a, 0, r), o.setHours(0, 0, 0, 0), M(o, e);
}
function Dt(t, e) {
  const n = h(t, e?.in), r = +M(n, e) - +kt(n, e);
  return Math.round(r / 6048e5) + 1;
}
function s(t, e) {
  const n = t < 0 ? "-" : "", r = Math.abs(t).toString().padStart(e, "0");
  return n + r;
}
const g = {
  // Year
  y(t, e) {
    const n = t.getFullYear(), r = n > 0 ? n : 1 - n;
    return s(e === "yy" ? r % 100 : r, e.length);
  },
  // Month
  M(t, e) {
    const n = t.getMonth();
    return e === "M" ? String(n + 1) : s(n + 1, 2);
  },
  // Day of the month
  d(t, e) {
    return s(t.getDate(), e.length);
  },
  // AM or PM
  a(t, e) {
    const n = t.getHours() / 12 >= 1 ? "pm" : "am";
    switch (e) {
      case "a":
      case "aa":
        return n.toUpperCase();
      case "aaa":
        return n;
      case "aaaaa":
        return n[0];
      default:
        return n === "am" ? "a.m." : "p.m.";
    }
  },
  // Hour [1-12]
  h(t, e) {
    return s(t.getHours() % 12 || 12, e.length);
  },
  // Hour [0-23]
  H(t, e) {
    return s(t.getHours(), e.length);
  },
  // Minute
  m(t, e) {
    return s(t.getMinutes(), e.length);
  },
  // Second
  s(t, e) {
    return s(t.getSeconds(), e.length);
  },
  // Fraction of second
  S(t, e) {
    const n = e.length, r = t.getMilliseconds(), a = Math.trunc(
      r * Math.pow(10, n - 3)
    );
    return s(a, e.length);
  }
}, y = {
  midnight: "midnight",
  noon: "noon",
  morning: "morning",
  afternoon: "afternoon",
  evening: "evening",
  night: "night"
}, S = {
  // Era
  G: function(t, e, n) {
    const r = t.getFullYear() > 0 ? 1 : 0;
    switch (e) {
      // AD, BC
      case "G":
      case "GG":
      case "GGG":
        return n.era(r, { width: "abbreviated" });
      // A, B
      case "GGGGG":
        return n.era(r, { width: "narrow" });
      default:
        return n.era(r, { width: "wide" });
    }
  },
  // Year
  y: function(t, e, n) {
    if (e === "yo") {
      const r = t.getFullYear(), a = r > 0 ? r : 1 - r;
      return n.ordinalNumber(a, { unit: "year" });
    }
    return g.y(t, e);
  },
  // Local week-numbering year
  Y: function(t, e, n, r) {
    const a = C(t, r), o = a > 0 ? a : 1 - a;
    if (e === "YY") {
      const i = o % 100;
      return s(i, 2);
    }
    return e === "Yo" ? n.ordinalNumber(o, { unit: "year" }) : s(o, e.length);
  },
  // ISO week-numbering year
  R: function(t, e) {
    const n = E(t);
    return s(n, e.length);
  },
  // Extended year. This is a single number designating the year of this calendar system.
  // The main difference between `y` and `u` localizers are B.C. years:
  // | Year | `y` | `u` |
  // |------|-----|-----|
  // | AC 1 |   1 |   1 |
  // | BC 1 |   1 |   0 |
  // | BC 2 |   2 |  -1 |
  // Also `yy` always returns the last two digits of a year,
  // while `uu` pads single digit years to 2 characters and returns other years unchanged.
  u: function(t, e) {
    const n = t.getFullYear();
    return s(n, e.length);
  },
  // Quarter
  Q: function(t, e, n) {
    const r = Math.ceil((t.getMonth() + 1) / 3);
    switch (e) {
      // 1, 2, 3, 4
      case "Q":
        return String(r);
      // 01, 02, 03, 04
      case "QQ":
        return s(r, 2);
      // 1st, 2nd, 3rd, 4th
      case "Qo":
        return n.ordinalNumber(r, { unit: "quarter" });
      // Q1, Q2, Q3, Q4
      case "QQQ":
        return n.quarter(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "QQQQQ":
        return n.quarter(r, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return n.quarter(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Stand-alone quarter
  q: function(t, e, n) {
    const r = Math.ceil((t.getMonth() + 1) / 3);
    switch (e) {
      // 1, 2, 3, 4
      case "q":
        return String(r);
      // 01, 02, 03, 04
      case "qq":
        return s(r, 2);
      // 1st, 2nd, 3rd, 4th
      case "qo":
        return n.ordinalNumber(r, { unit: "quarter" });
      // Q1, Q2, Q3, Q4
      case "qqq":
        return n.quarter(r, {
          width: "abbreviated",
          context: "standalone"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "qqqqq":
        return n.quarter(r, {
          width: "narrow",
          context: "standalone"
        });
      default:
        return n.quarter(r, {
          width: "wide",
          context: "standalone"
        });
    }
  },
  // Month
  M: function(t, e, n) {
    const r = t.getMonth();
    switch (e) {
      case "M":
      case "MM":
        return g.M(t, e);
      // 1st, 2nd, ..., 12th
      case "Mo":
        return n.ordinalNumber(r + 1, { unit: "month" });
      // Jan, Feb, ..., Dec
      case "MMM":
        return n.month(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // J, F, ..., D
      case "MMMMM":
        return n.month(r, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return n.month(r, { width: "wide", context: "formatting" });
    }
  },
  // Stand-alone month
  L: function(t, e, n) {
    const r = t.getMonth();
    switch (e) {
      // 1, 2, ..., 12
      case "L":
        return String(r + 1);
      // 01, 02, ..., 12
      case "LL":
        return s(r + 1, 2);
      // 1st, 2nd, ..., 12th
      case "Lo":
        return n.ordinalNumber(r + 1, { unit: "month" });
      // Jan, Feb, ..., Dec
      case "LLL":
        return n.month(r, {
          width: "abbreviated",
          context: "standalone"
        });
      // J, F, ..., D
      case "LLLLL":
        return n.month(r, {
          width: "narrow",
          context: "standalone"
        });
      default:
        return n.month(r, { width: "wide", context: "standalone" });
    }
  },
  // Local week of year
  w: function(t, e, n, r) {
    const a = Dt(t, r);
    return e === "wo" ? n.ordinalNumber(a, { unit: "week" }) : s(a, e.length);
  },
  // ISO week of year
  I: function(t, e, n) {
    const r = Ot(t);
    return e === "Io" ? n.ordinalNumber(r, { unit: "week" }) : s(r, e.length);
  },
  // Day of the month
  d: function(t, e, n) {
    return e === "do" ? n.ordinalNumber(t.getDate(), { unit: "date" }) : g.d(t, e);
  },
  // Day of year
  D: function(t, e, n) {
    const r = Pt(t);
    return e === "Do" ? n.ordinalNumber(r, { unit: "dayOfYear" }) : s(r, e.length);
  },
  // Day of week
  E: function(t, e, n) {
    const r = t.getDay();
    switch (e) {
      // Tue
      case "E":
      case "EE":
      case "EEE":
        return n.day(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "EEEEE":
        return n.day(r, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "EEEEEE":
        return n.day(r, {
          width: "short",
          context: "formatting"
        });
      default:
        return n.day(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Local day of week
  e: function(t, e, n, r) {
    const a = t.getDay(), o = (a - r.weekStartsOn + 8) % 7 || 7;
    switch (e) {
      // Numerical value (Nth day of week with current locale or weekStartsOn)
      case "e":
        return String(o);
      // Padded numerical value
      case "ee":
        return s(o, 2);
      // 1st, 2nd, ..., 7th
      case "eo":
        return n.ordinalNumber(o, { unit: "day" });
      case "eee":
        return n.day(a, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "eeeee":
        return n.day(a, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "eeeeee":
        return n.day(a, {
          width: "short",
          context: "formatting"
        });
      default:
        return n.day(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Stand-alone local day of week
  c: function(t, e, n, r) {
    const a = t.getDay(), o = (a - r.weekStartsOn + 8) % 7 || 7;
    switch (e) {
      // Numerical value (same as in `e`)
      case "c":
        return String(o);
      // Padded numerical value
      case "cc":
        return s(o, e.length);
      // 1st, 2nd, ..., 7th
      case "co":
        return n.ordinalNumber(o, { unit: "day" });
      case "ccc":
        return n.day(a, {
          width: "abbreviated",
          context: "standalone"
        });
      // T
      case "ccccc":
        return n.day(a, {
          width: "narrow",
          context: "standalone"
        });
      // Tu
      case "cccccc":
        return n.day(a, {
          width: "short",
          context: "standalone"
        });
      default:
        return n.day(a, {
          width: "wide",
          context: "standalone"
        });
    }
  },
  // ISO day of week
  i: function(t, e, n) {
    const r = t.getDay(), a = r === 0 ? 7 : r;
    switch (e) {
      // 2
      case "i":
        return String(a);
      // 02
      case "ii":
        return s(a, e.length);
      // 2nd
      case "io":
        return n.ordinalNumber(a, { unit: "day" });
      // Tue
      case "iii":
        return n.day(r, {
          width: "abbreviated",
          context: "formatting"
        });
      // T
      case "iiiii":
        return n.day(r, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "iiiiii":
        return n.day(r, {
          width: "short",
          context: "formatting"
        });
      default:
        return n.day(r, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // AM or PM
  a: function(t, e, n) {
    const a = t.getHours() / 12 >= 1 ? "pm" : "am";
    switch (e) {
      case "a":
      case "aa":
        return n.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "aaa":
        return n.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        }).toLowerCase();
      case "aaaaa":
        return n.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return n.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // AM, PM, midnight, noon
  b: function(t, e, n) {
    const r = t.getHours();
    let a;
    switch (r === 12 ? a = y.noon : r === 0 ? a = y.midnight : a = r / 12 >= 1 ? "pm" : "am", e) {
      case "b":
      case "bb":
        return n.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "bbb":
        return n.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        }).toLowerCase();
      case "bbbbb":
        return n.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return n.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // in the morning, in the afternoon, in the evening, at night
  B: function(t, e, n) {
    const r = t.getHours();
    let a;
    switch (r >= 17 ? a = y.evening : r >= 12 ? a = y.afternoon : r >= 4 ? a = y.morning : a = y.night, e) {
      case "B":
      case "BB":
      case "BBB":
        return n.dayPeriod(a, {
          width: "abbreviated",
          context: "formatting"
        });
      case "BBBBB":
        return n.dayPeriod(a, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return n.dayPeriod(a, {
          width: "wide",
          context: "formatting"
        });
    }
  },
  // Hour [1-12]
  h: function(t, e, n) {
    if (e === "ho") {
      let r = t.getHours() % 12;
      return r === 0 && (r = 12), n.ordinalNumber(r, { unit: "hour" });
    }
    return g.h(t, e);
  },
  // Hour [0-23]
  H: function(t, e, n) {
    return e === "Ho" ? n.ordinalNumber(t.getHours(), { unit: "hour" }) : g.H(t, e);
  },
  // Hour [0-11]
  K: function(t, e, n) {
    const r = t.getHours() % 12;
    return e === "Ko" ? n.ordinalNumber(r, { unit: "hour" }) : s(r, e.length);
  },
  // Hour [1-24]
  k: function(t, e, n) {
    let r = t.getHours();
    return r === 0 && (r = 24), e === "ko" ? n.ordinalNumber(r, { unit: "hour" }) : s(r, e.length);
  },
  // Minute
  m: function(t, e, n) {
    return e === "mo" ? n.ordinalNumber(t.getMinutes(), { unit: "minute" }) : g.m(t, e);
  },
  // Second
  s: function(t, e, n) {
    return e === "so" ? n.ordinalNumber(t.getSeconds(), { unit: "second" }) : g.s(t, e);
  },
  // Fraction of second
  S: function(t, e) {
    return g.S(t, e);
  },
  // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
  X: function(t, e, n) {
    const r = t.getTimezoneOffset();
    if (r === 0)
      return "Z";
    switch (e) {
      // Hours and optional minutes
      case "X":
        return T(r);
      // Hours, minutes and optional seconds without `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `XX`
      case "XXXX":
      case "XX":
        return w(r);
      // Hours and minutes with `:` delimiter
      default:
        return w(r, ":");
    }
  },
  // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
  x: function(t, e, n) {
    const r = t.getTimezoneOffset();
    switch (e) {
      // Hours and optional minutes
      case "x":
        return T(r);
      // Hours, minutes and optional seconds without `:` delimiter
      // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
      // so this token always has the same output as `xx`
      case "xxxx":
      case "xx":
        return w(r);
      // Hours and minutes with `:` delimiter
      default:
        return w(r, ":");
    }
  },
  // Timezone (GMT)
  O: function(t, e, n) {
    const r = t.getTimezoneOffset();
    switch (e) {
      // Short
      case "O":
      case "OO":
      case "OOO":
        return "GMT" + Y(r, ":");
      default:
        return "GMT" + w(r, ":");
    }
  },
  // Timezone (specific non-location)
  z: function(t, e, n) {
    const r = t.getTimezoneOffset();
    switch (e) {
      // Short
      case "z":
      case "zz":
      case "zzz":
        return "GMT" + Y(r, ":");
      default:
        return "GMT" + w(r, ":");
    }
  },
  // Seconds timestamp
  t: function(t, e, n) {
    const r = Math.trunc(+t / 1e3);
    return s(r, e.length);
  },
  // Milliseconds timestamp
  T: function(t, e, n) {
    return s(+t, e.length);
  }
};
function Y(t, e = "") {
  const n = t > 0 ? "-" : "+", r = Math.abs(t), a = Math.trunc(r / 60), o = r % 60;
  return o === 0 ? n + String(a) : n + String(a) + e + s(o, 2);
}
function T(t, e) {
  return t % 60 === 0 ? (t > 0 ? "-" : "+") + s(Math.abs(t) / 60, 2) : w(t, e);
}
function w(t, e = "") {
  const n = t > 0 ? "-" : "+", r = Math.abs(t), a = s(Math.trunc(r / 60), 2), o = s(r % 60, 2);
  return n + a + e + o;
}
const F = (t, e) => {
  switch (t) {
    case "P":
      return e.date({ width: "short" });
    case "PP":
      return e.date({ width: "medium" });
    case "PPP":
      return e.date({ width: "long" });
    default:
      return e.date({ width: "full" });
  }
}, q = (t, e) => {
  switch (t) {
    case "p":
      return e.time({ width: "short" });
    case "pp":
      return e.time({ width: "medium" });
    case "ppp":
      return e.time({ width: "long" });
    default:
      return e.time({ width: "full" });
  }
}, xt = (t, e) => {
  const n = t.match(/(P+)(p+)?/) || [], r = n[1], a = n[2];
  if (!a)
    return F(t, e);
  let o;
  switch (r) {
    case "P":
      o = e.dateTime({ width: "short" });
      break;
    case "PP":
      o = e.dateTime({ width: "medium" });
      break;
    case "PPP":
      o = e.dateTime({ width: "long" });
      break;
    default:
      o = e.dateTime({ width: "full" });
      break;
  }
  return o.replace("{{date}}", F(r, e)).replace("{{time}}", q(a, e));
}, Wt = {
  p: q,
  P: xt
}, vt = /^D+$/, St = /^Y+$/, Yt = ["D", "DD", "YY", "YYYY"];
function Tt(t) {
  return vt.test(t);
}
function Ft(t) {
  return St.test(t);
}
function Et(t, e, n) {
  const r = Ct(t, e, n);
  if (console.warn(r), Yt.includes(t)) throw new RangeError(r);
}
function Ct(t, e, n) {
  const r = t[0] === "Y" ? "years" : "days of the month";
  return `Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
}
const qt = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Nt = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Ht = /^'([^]*?)'?$/, Qt = /''/g, _t = /[a-zA-Z]/;
function It(t, e, n) {
  const r = O(), a = n?.locale ?? r.locale ?? Mt, o = n?.firstWeekContainsDate ?? n?.locale?.options?.firstWeekContainsDate ?? r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, i = n?.weekStartsOn ?? n?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, u = h(t, n?.in);
  if (!j(u))
    throw new RangeError("Invalid time value");
  let f = e.match(Nt).map((d) => {
    const c = d[0];
    if (c === "p" || c === "P") {
      const k = Wt[c];
      return k(d, a.formatLong);
    }
    return d;
  }).join("").match(qt).map((d) => {
    if (d === "''")
      return { isToken: !1, value: "'" };
    const c = d[0];
    if (c === "'")
      return { isToken: !1, value: Xt(d) };
    if (S[c])
      return { isToken: !0, value: d };
    if (c.match(_t))
      throw new RangeError(
        "Format string contains an unescaped latin alphabet character `" + c + "`"
      );
    return { isToken: !1, value: d };
  });
  a.localize.preprocessor && (f = a.localize.preprocessor(u, f));
  const m = {
    firstWeekContainsDate: o,
    weekStartsOn: i,
    locale: a
  };
  return f.map((d) => {
    if (!d.isToken) return d.value;
    const c = d.value;
    (!n?.useAdditionalWeekYearTokens && Ft(c) || !n?.useAdditionalDayOfYearTokens && Tt(c)) && Et(c, e, String(t));
    const k = S[c[0]];
    return k(u, c, a.localize, m);
  }).join("");
}
function Xt(t) {
  const e = t.match(Ht);
  return e ? e[1].replace(Qt, "'") : t;
}
export {
  b as A,
  p as B,
  it as C,
  pt as D,
  rt as E,
  $ as F,
  B as G,
  jt as a,
  Lt as b,
  l as c,
  C as d,
  Mt as e,
  P as f,
  O as g,
  Dt as h,
  Ot as i,
  Bt as j,
  W as k,
  Wt as l,
  Gt as m,
  Ft as n,
  Tt as o,
  It as p,
  j as q,
  H as r,
  M as s,
  h as t,
  v as u,
  Q as v,
  Et as w,
  X as x,
  G as y,
  D as z
};
//# sourceMappingURL=format-DpkYPs7O.mjs.map
