function O(e, t) {
  const n = $(t);
  return "formatToParts" in n ? y(n, e) : F(n, e);
}
const U = {
  year: 0,
  month: 1,
  day: 2,
  hour: 3,
  minute: 4,
  second: 5
};
function y(e, t) {
  try {
    const n = e.formatToParts(t), r = [];
    for (let a = 0; a < n.length; a++) {
      const i = U[n[a].type];
      i !== void 0 && (r[i] = parseInt(n[a].value, 10));
    }
    return r;
  } catch (n) {
    if (n instanceof RangeError)
      return [NaN];
    throw n;
  }
}
function F(e, t) {
  const n = e.format(t), r = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);
  return [
    parseInt(r[3], 10),
    parseInt(r[1], 10),
    parseInt(r[2], 10),
    parseInt(r[4], 10),
    parseInt(r[5], 10),
    parseInt(r[6], 10)
  ];
}
const f = {}, Y = new Intl.DateTimeFormat("en-US", {
  hourCycle: "h23",
  timeZone: "America/New_York",
  year: "numeric",
  month: "2-digit",
  day: "2-digit",
  hour: "2-digit",
  minute: "2-digit",
  second: "2-digit"
}).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z")), _ = Y === "06/25/2014, 00:00:00" || Y === "‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";
function $(e) {
  return f[e] || (f[e] = _ ? new Intl.DateTimeFormat("en-US", {
    hourCycle: "h23",
    timeZone: e,
    year: "numeric",
    month: "numeric",
    day: "2-digit",
    hour: "2-digit",
    minute: "2-digit",
    second: "2-digit"
  }) : new Intl.DateTimeFormat("en-US", {
    hour12: !1,
    timeZone: e,
    year: "numeric",
    month: "numeric",
    day: "2-digit",
    hour: "2-digit",
    minute: "2-digit",
    second: "2-digit"
  })), f[e];
}
function x(e, t, n, r, a, i, s) {
  const u = /* @__PURE__ */ new Date(0);
  return u.setUTCFullYear(e, t, n), u.setUTCHours(r, a, i, s), u;
}
const m = 36e5, b = 6e4, D = {
  timezoneZ: /^(Z)$/,
  timezoneHH: /^([+-]\d{2})$/,
  timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
};
function A(e, t, n) {
  if (!e)
    return 0;
  let r = D.timezoneZ.exec(e);
  if (r)
    return 0;
  let a, i;
  if (r = D.timezoneHH.exec(e), r)
    return a = parseInt(r[1], 10), T(a) ? -(a * m) : NaN;
  if (r = D.timezoneHHMM.exec(e), r) {
    a = parseInt(r[2], 10);
    const s = parseInt(r[3], 10);
    return T(a, s) ? (i = Math.abs(a) * m + s * b, r[1] === "+" ? -i : i) : NaN;
  }
  if (Z(e)) {
    t = new Date(t || Date.now());
    const s = n ? t : L(t), u = p(s, e);
    return -(n ? u : S(t, u, e));
  }
  return NaN;
}
function L(e) {
  return x(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds());
}
function p(e, t) {
  const n = O(e, t), r = x(n[0], n[1] - 1, n[2], n[3] % 24, n[4], n[5], 0).getTime();
  let a = e.getTime();
  const i = a % 1e3;
  return a -= i >= 0 ? i : 1e3 + i, r - a;
}
function S(e, t, n) {
  let a = e.getTime() - t;
  const i = p(new Date(a), n);
  if (t === i)
    return t;
  a -= i - t;
  const s = p(new Date(a), n);
  return i === s ? i : Math.max(i, s);
}
function T(e, t) {
  return -23 <= e && e <= 23 && (t == null || 0 <= t && t <= 59);
}
const I = {};
function Z(e) {
  if (I[e])
    return !0;
  try {
    return new Intl.DateTimeFormat(void 0, { timeZone: e }), I[e] = !0, !0;
  } catch {
    return !1;
  }
}
function w(e) {
  const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()));
  return t.setUTCFullYear(e.getFullYear()), +e - +t;
}
const E = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/, d = 36e5, M = 6e4, z = 2, o = {
  dateTimePattern: /^([0-9W+-]+)(T| )(.*)/,
  datePattern: /^([0-9W+-]+)(.*)/,
  // year tokens
  YY: /^(\d{2})$/,
  YYY: [
    /^([+-]\d{2})$/,
    // 0 additional digits
    /^([+-]\d{3})$/,
    // 1 additional digit
    /^([+-]\d{4})$/
    // 2 additional digits
  ],
  YYYY: /^(\d{4})/,
  YYYYY: [
    /^([+-]\d{4})/,
    // 0 additional digits
    /^([+-]\d{5})/,
    // 1 additional digit
    /^([+-]\d{6})/
    // 2 additional digits
  ],
  // date tokens
  MM: /^-(\d{2})$/,
  DDD: /^-?(\d{3})$/,
  MMDD: /^-?(\d{2})-?(\d{2})$/,
  Www: /^-?W(\d{2})$/,
  WwwD: /^-?W(\d{2})-?(\d{1})$/,
  HH: /^(\d{2}([.,]\d*)?)$/,
  HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
  HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
  // time zone tokens (to identify the presence of a tz)
  timeZone: E
};
function q(e, t = {}) {
  if (arguments.length < 1)
    throw new TypeError("1 argument required, but only " + arguments.length + " present");
  if (e === null)
    return /* @__PURE__ */ new Date(NaN);
  const n = t.additionalDigits == null ? z : Number(t.additionalDigits);
  if (n !== 2 && n !== 1 && n !== 0)
    throw new RangeError("additionalDigits must be 0, 1 or 2");
  if (e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]")
    return new Date(e.getTime());
  if (typeof e == "number" || Object.prototype.toString.call(e) === "[object Number]")
    return new Date(e);
  if (Object.prototype.toString.call(e) !== "[object String]")
    return /* @__PURE__ */ new Date(NaN);
  const r = W(e), { year: a, restDateString: i } = k(r.date, n), s = P(i, a);
  if (s === null || isNaN(s.getTime()))
    return /* @__PURE__ */ new Date(NaN);
  if (s) {
    const u = s.getTime();
    let c = 0, l;
    if (r.time && (c = v(r.time), c === null || isNaN(c)))
      return /* @__PURE__ */ new Date(NaN);
    if (r.timeZone || t.timeZone) {
      if (l = A(r.timeZone || t.timeZone, new Date(u + c)), isNaN(l))
        return /* @__PURE__ */ new Date(NaN);
    } else
      l = w(new Date(u + c)), l = w(new Date(u + c + l));
    return new Date(u + c + l);
  } else
    return /* @__PURE__ */ new Date(NaN);
}
function W(e) {
  const t = {};
  let n = o.dateTimePattern.exec(e), r;
  if (n ? (t.date = n[1], r = n[3]) : (n = o.datePattern.exec(e), n ? (t.date = n[1], r = n[2]) : (t.date = null, r = e)), r) {
    const a = o.timeZone.exec(r);
    a ? (t.time = r.replace(a[1], ""), t.timeZone = a[1].trim()) : t.time = r;
  }
  return t;
}
function k(e, t) {
  if (e) {
    const n = o.YYY[t], r = o.YYYYY[t];
    let a = o.YYYY.exec(e) || r.exec(e);
    if (a) {
      const i = a[1];
      return {
        year: parseInt(i, 10),
        restDateString: e.slice(i.length)
      };
    }
    if (a = o.YY.exec(e) || n.exec(e), a) {
      const i = a[1];
      return {
        year: parseInt(i, 10) * 100,
        restDateString: e.slice(i.length)
      };
    }
  }
  return {
    year: null
  };
}
function P(e, t) {
  if (t === null)
    return null;
  let n, r, a;
  if (!e || !e.length)
    return n = /* @__PURE__ */ new Date(0), n.setUTCFullYear(t), n;
  let i = o.MM.exec(e);
  if (i)
    return n = /* @__PURE__ */ new Date(0), r = parseInt(i[1], 10) - 1, h(t, r) ? (n.setUTCFullYear(t, r), n) : /* @__PURE__ */ new Date(NaN);
  if (i = o.DDD.exec(e), i) {
    n = /* @__PURE__ */ new Date(0);
    const s = parseInt(i[1], 10);
    return G(t, s) ? (n.setUTCFullYear(t, 0, s), n) : /* @__PURE__ */ new Date(NaN);
  }
  if (i = o.MMDD.exec(e), i) {
    n = /* @__PURE__ */ new Date(0), r = parseInt(i[1], 10) - 1;
    const s = parseInt(i[2], 10);
    return h(t, r, s) ? (n.setUTCFullYear(t, r, s), n) : /* @__PURE__ */ new Date(NaN);
  }
  if (i = o.Www.exec(e), i)
    return a = parseInt(i[1], 10) - 1, H(a) ? g(t, a) : /* @__PURE__ */ new Date(NaN);
  if (i = o.WwwD.exec(e), i) {
    a = parseInt(i[1], 10) - 1;
    const s = parseInt(i[2], 10) - 1;
    return H(a, s) ? g(t, a, s) : /* @__PURE__ */ new Date(NaN);
  }
  return null;
}
function v(e) {
  let t, n, r = o.HH.exec(e);
  if (r)
    return t = parseFloat(r[1].replace(",", ".")), N(t) ? t % 24 * d : NaN;
  if (r = o.HHMM.exec(e), r)
    return t = parseInt(r[1], 10), n = parseFloat(r[2].replace(",", ".")), N(t, n) ? t % 24 * d + n * M : NaN;
  if (r = o.HHMMSS.exec(e), r) {
    t = parseInt(r[1], 10), n = parseInt(r[2], 10);
    const a = parseFloat(r[3].replace(",", "."));
    return N(t, n, a) ? t % 24 * d + n * M + a * 1e3 : NaN;
  }
  return null;
}
function g(e, t, n) {
  t = t || 0, n = n || 0;
  const r = /* @__PURE__ */ new Date(0);
  r.setUTCFullYear(e, 0, 4);
  const a = r.getUTCDay() || 7, i = t * 7 + n + 1 - a;
  return r.setUTCDate(r.getUTCDate() + i), r;
}
const j = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], R = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
function C(e) {
  return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
}
function h(e, t, n) {
  if (t < 0 || t > 11)
    return !1;
  if (n != null) {
    if (n < 1)
      return !1;
    const r = C(e);
    if (r && n > R[t] || !r && n > j[t])
      return !1;
  }
  return !0;
}
function G(e, t) {
  if (t < 1)
    return !1;
  const n = C(e);
  return !(n && t > 366 || !n && t > 365);
}
function H(e, t) {
  return !(e < 0 || e > 52 || t != null && (t < 0 || t > 6));
}
function N(e, t, n) {
  return !(e < 0 || e >= 25 || t != null && (t < 0 || t >= 60) || n != null && (n < 0 || n >= 60));
}
export {
  q as a,
  A as b,
  x as n,
  E as t
};
