import { jsxs as J, jsx as Y } from "react/jsx-runtime";
import { forwardRef as S, useState as B, useEffect as ee, useRef as te, useLayoutEffect as re } from "react";
import { T as ne } from "./text-field-PKAaXO1N.mjs";
import { c as se } from "./bind-CU-R61T-.mjs";
import { g as A, t as D, c as m, m as oe, a as ae, b as ie, d as ce, s as R, f as $, h as ue, i as le, j as z, k as V, e as de, l as F, n as fe, w as G, o as we, p as he, q as pe } from "./format-DpkYPs7O.mjs";
function ye() {
  return Object.assign({}, A());
}
function xe(n, e) {
  const r = D(n, e?.in).getDay();
  return r === 0 ? 7 : r;
}
function be(n, e) {
  const r = me(e) ? new e(0) : m(e, 0);
  return r.setFullYear(n.getFullYear(), n.getMonth(), n.getDate()), r.setHours(
    n.getHours(),
    n.getMinutes(),
    n.getSeconds(),
    n.getMilliseconds()
  ), r;
}
function me(n) {
  return typeof n == "function" && n.prototype?.constructor === n;
}
const Te = 10;
class Z {
  subPriority = 0;
  validate(e, r) {
    return !0;
  }
}
class ge extends Z {
  constructor(e, r, t, s, o) {
    super(), this.value = e, this.validateValue = r, this.setValue = t, this.priority = s, o && (this.subPriority = o);
  }
  validate(e, r) {
    return this.validateValue(e, this.value, r);
  }
  set(e, r, t) {
    return this.setValue(e, r, this.value, t);
  }
}
class De extends Z {
  priority = Te;
  subPriority = -1;
  constructor(e, r) {
    super(), this.context = e || ((t) => m(r, t));
  }
  set(e, r) {
    return r.timestampIsSet ? e : m(e, be(e, this.context));
  }
}
class c {
  run(e, r, t, s) {
    const o = this.parse(e, r, t, s);
    return o ? {
      setter: new ge(
        o.value,
        this.validate,
        this.set,
        this.priority,
        this.subPriority
      ),
      rest: o.rest
    } : null;
  }
  validate(e, r, t) {
    return !0;
  }
}
class _e extends c {
  priority = 140;
  parse(e, r, t) {
    switch (r) {
      // AD, BC
      case "G":
      case "GG":
      case "GGG":
        return t.era(e, { width: "abbreviated" }) || t.era(e, { width: "narrow" });
      // A, B
      case "GGGGG":
        return t.era(e, { width: "narrow" });
      default:
        return t.era(e, { width: "wide" }) || t.era(e, { width: "abbreviated" }) || t.era(e, { width: "narrow" });
    }
  }
  set(e, r, t) {
    return r.era = t, e.setFullYear(t, 0, 1), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = ["R", "u", "t", "T"];
}
const f = {
  month: /^(1[0-2]|0?\d)/,
  // 0 to 12
  date: /^(3[0-1]|[0-2]?\d)/,
  // 0 to 31
  dayOfYear: /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,
  // 0 to 366
  week: /^(5[0-3]|[0-4]?\d)/,
  // 0 to 53
  hour23h: /^(2[0-3]|[0-1]?\d)/,
  // 0 to 23
  hour24h: /^(2[0-4]|[0-1]?\d)/,
  // 0 to 24
  hour11h: /^(1[0-1]|0?\d)/,
  // 0 to 11
  hour12h: /^(1[0-2]|0?\d)/,
  // 0 to 12
  minute: /^[0-5]?\d/,
  // 0 to 59
  second: /^[0-5]?\d/,
  // 0 to 59
  singleDigit: /^\d/,
  // 0 to 9
  twoDigits: /^\d{1,2}/,
  // 0 to 99
  threeDigits: /^\d{1,3}/,
  // 0 to 999
  fourDigits: /^\d{1,4}/,
  // 0 to 9999
  anyDigitsSigned: /^-?\d+/,
  singleDigitSigned: /^-?\d/,
  // 0 to 9, -0 to -9
  twoDigitsSigned: /^-?\d{1,2}/,
  // 0 to 99, -0 to -99
  threeDigitsSigned: /^-?\d{1,3}/,
  // 0 to 999, -0 to -999
  fourDigitsSigned: /^-?\d{1,4}/
  // 0 to 9999, -0 to -9999
}, x = {
  basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/,
  basic: /^([+-])(\d{2})(\d{2})|Z/,
  basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,
  extended: /^([+-])(\d{2}):(\d{2})|Z/,
  extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/
};
function w(n, e) {
  return n && {
    value: e(n.value),
    rest: n.rest
  };
}
function u(n, e) {
  const r = e.match(n);
  return r ? {
    value: parseInt(r[0], 10),
    rest: e.slice(r[0].length)
  } : null;
}
function b(n, e) {
  const r = e.match(n);
  if (!r)
    return null;
  if (r[0] === "Z")
    return {
      value: 0,
      rest: e.slice(1)
    };
  const t = r[1] === "+" ? 1 : -1, s = r[2] ? parseInt(r[2], 10) : 0, o = r[3] ? parseInt(r[3], 10) : 0, l = r[5] ? parseInt(r[5], 10) : 0;
  return {
    value: t * (s * oe + o * ae + l * ie),
    rest: e.slice(r[0].length)
  };
}
function K(n) {
  return u(f.anyDigitsSigned, n);
}
function d(n, e) {
  switch (n) {
    case 1:
      return u(f.singleDigit, e);
    case 2:
      return u(f.twoDigits, e);
    case 3:
      return u(f.threeDigits, e);
    case 4:
      return u(f.fourDigits, e);
    default:
      return u(new RegExp("^\\d{1," + n + "}"), e);
  }
}
function O(n, e) {
  switch (n) {
    case 1:
      return u(f.singleDigitSigned, e);
    case 2:
      return u(f.twoDigitsSigned, e);
    case 3:
      return u(f.threeDigitsSigned, e);
    case 4:
      return u(f.fourDigitsSigned, e);
    default:
      return u(new RegExp("^-?\\d{1," + n + "}"), e);
  }
}
function N(n) {
  switch (n) {
    case "morning":
      return 4;
    case "evening":
      return 17;
    case "pm":
    case "noon":
    case "afternoon":
      return 12;
    default:
      return 0;
  }
}
function j(n, e) {
  const r = e > 0, t = r ? e : 1 - e;
  let s;
  if (t <= 50)
    s = n || 100;
  else {
    const o = t + 50, l = Math.trunc(o / 100) * 100, y = n >= o % 100;
    s = n + l - (y ? 100 : 0);
  }
  return r ? s : 1 - s;
}
function U(n) {
  return n % 400 === 0 || n % 4 === 0 && n % 100 !== 0;
}
class ke extends c {
  priority = 130;
  incompatibleTokens = ["Y", "R", "u", "w", "I", "i", "e", "c", "t", "T"];
  parse(e, r, t) {
    const s = (o) => ({
      year: o,
      isTwoDigitYear: r === "yy"
    });
    switch (r) {
      case "y":
        return w(d(4, e), s);
      case "yo":
        return w(
          t.ordinalNumber(e, {
            unit: "year"
          }),
          s
        );
      default:
        return w(d(r.length, e), s);
    }
  }
  validate(e, r) {
    return r.isTwoDigitYear || r.year > 0;
  }
  set(e, r, t) {
    const s = e.getFullYear();
    if (t.isTwoDigitYear) {
      const l = j(
        t.year,
        s
      );
      return e.setFullYear(l, 0, 1), e.setHours(0, 0, 0, 0), e;
    }
    const o = !("era" in r) || r.era === 1 ? t.year : 1 - t.year;
    return e.setFullYear(o, 0, 1), e.setHours(0, 0, 0, 0), e;
  }
}
class Pe extends c {
  priority = 130;
  parse(e, r, t) {
    const s = (o) => ({
      year: o,
      isTwoDigitYear: r === "YY"
    });
    switch (r) {
      case "Y":
        return w(d(4, e), s);
      case "Yo":
        return w(
          t.ordinalNumber(e, {
            unit: "year"
          }),
          s
        );
      default:
        return w(d(r.length, e), s);
    }
  }
  validate(e, r) {
    return r.isTwoDigitYear || r.year > 0;
  }
  set(e, r, t, s) {
    const o = ce(e, s);
    if (t.isTwoDigitYear) {
      const y = j(
        t.year,
        o
      );
      return e.setFullYear(
        y,
        0,
        s.firstWeekContainsDate
      ), e.setHours(0, 0, 0, 0), R(e, s);
    }
    const l = !("era" in r) || r.era === 1 ? t.year : 1 - t.year;
    return e.setFullYear(l, 0, s.firstWeekContainsDate), e.setHours(0, 0, 0, 0), R(e, s);
  }
  incompatibleTokens = [
    "y",
    "R",
    "u",
    "Q",
    "q",
    "M",
    "L",
    "I",
    "d",
    "D",
    "i",
    "t",
    "T"
  ];
}
class Me extends c {
  priority = 130;
  parse(e, r) {
    return O(r === "R" ? 4 : r.length, e);
  }
  set(e, r, t) {
    const s = m(e, 0);
    return s.setFullYear(t, 0, 4), s.setHours(0, 0, 0, 0), $(s);
  }
  incompatibleTokens = [
    "G",
    "y",
    "Y",
    "u",
    "Q",
    "q",
    "M",
    "L",
    "w",
    "d",
    "D",
    "e",
    "c",
    "t",
    "T"
  ];
}
class Ye extends c {
  priority = 130;
  parse(e, r) {
    return O(r === "u" ? 4 : r.length, e);
  }
  set(e, r, t) {
    return e.setFullYear(t, 0, 1), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = ["G", "y", "Y", "R", "w", "I", "i", "e", "c", "t", "T"];
}
class Oe extends c {
  priority = 120;
  parse(e, r, t) {
    switch (r) {
      // 1, 2, 3, 4
      case "Q":
      case "QQ":
        return d(r.length, e);
      // 1st, 2nd, 3rd, 4th
      case "Qo":
        return t.ordinalNumber(e, { unit: "quarter" });
      // Q1, Q2, Q3, Q4
      case "QQQ":
        return t.quarter(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.quarter(e, {
          width: "narrow",
          context: "formatting"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "QQQQQ":
        return t.quarter(e, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return t.quarter(e, {
          width: "wide",
          context: "formatting"
        }) || t.quarter(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.quarter(e, {
          width: "narrow",
          context: "formatting"
        });
    }
  }
  validate(e, r) {
    return r >= 1 && r <= 4;
  }
  set(e, r, t) {
    return e.setMonth((t - 1) * 3, 1), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "Y",
    "R",
    "q",
    "M",
    "L",
    "w",
    "I",
    "d",
    "D",
    "i",
    "e",
    "c",
    "t",
    "T"
  ];
}
class Ee extends c {
  priority = 120;
  parse(e, r, t) {
    switch (r) {
      // 1, 2, 3, 4
      case "q":
      case "qq":
        return d(r.length, e);
      // 1st, 2nd, 3rd, 4th
      case "qo":
        return t.ordinalNumber(e, { unit: "quarter" });
      // Q1, Q2, Q3, Q4
      case "qqq":
        return t.quarter(e, {
          width: "abbreviated",
          context: "standalone"
        }) || t.quarter(e, {
          width: "narrow",
          context: "standalone"
        });
      // 1, 2, 3, 4 (narrow quarter; could be not numerical)
      case "qqqqq":
        return t.quarter(e, {
          width: "narrow",
          context: "standalone"
        });
      default:
        return t.quarter(e, {
          width: "wide",
          context: "standalone"
        }) || t.quarter(e, {
          width: "abbreviated",
          context: "standalone"
        }) || t.quarter(e, {
          width: "narrow",
          context: "standalone"
        });
    }
  }
  validate(e, r) {
    return r >= 1 && r <= 4;
  }
  set(e, r, t) {
    return e.setMonth((t - 1) * 3, 1), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "Y",
    "R",
    "Q",
    "M",
    "L",
    "w",
    "I",
    "d",
    "D",
    "i",
    "e",
    "c",
    "t",
    "T"
  ];
}
class He extends c {
  incompatibleTokens = [
    "Y",
    "R",
    "q",
    "Q",
    "L",
    "w",
    "I",
    "D",
    "i",
    "e",
    "c",
    "t",
    "T"
  ];
  priority = 110;
  parse(e, r, t) {
    const s = (o) => o - 1;
    switch (r) {
      // 1, 2, ..., 12
      case "M":
        return w(
          u(f.month, e),
          s
        );
      // 01, 02, ..., 12
      case "MM":
        return w(d(2, e), s);
      // 1st, 2nd, ..., 12th
      case "Mo":
        return w(
          t.ordinalNumber(e, {
            unit: "month"
          }),
          s
        );
      // Jan, Feb, ..., Dec
      case "MMM":
        return t.month(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.month(e, { width: "narrow", context: "formatting" });
      // J, F, ..., D
      case "MMMMM":
        return t.month(e, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return t.month(e, { width: "wide", context: "formatting" }) || t.month(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.month(e, { width: "narrow", context: "formatting" });
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 11;
  }
  set(e, r, t) {
    return e.setMonth(t, 1), e.setHours(0, 0, 0, 0), e;
  }
}
class Ie extends c {
  priority = 110;
  parse(e, r, t) {
    const s = (o) => o - 1;
    switch (r) {
      // 1, 2, ..., 12
      case "L":
        return w(
          u(f.month, e),
          s
        );
      // 01, 02, ..., 12
      case "LL":
        return w(d(2, e), s);
      // 1st, 2nd, ..., 12th
      case "Lo":
        return w(
          t.ordinalNumber(e, {
            unit: "month"
          }),
          s
        );
      // Jan, Feb, ..., Dec
      case "LLL":
        return t.month(e, {
          width: "abbreviated",
          context: "standalone"
        }) || t.month(e, { width: "narrow", context: "standalone" });
      // J, F, ..., D
      case "LLLLL":
        return t.month(e, {
          width: "narrow",
          context: "standalone"
        });
      default:
        return t.month(e, { width: "wide", context: "standalone" }) || t.month(e, {
          width: "abbreviated",
          context: "standalone"
        }) || t.month(e, { width: "narrow", context: "standalone" });
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 11;
  }
  set(e, r, t) {
    return e.setMonth(t, 1), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "Y",
    "R",
    "q",
    "Q",
    "M",
    "w",
    "I",
    "D",
    "i",
    "e",
    "c",
    "t",
    "T"
  ];
}
function qe(n, e, r) {
  const t = D(n, r?.in), s = ue(t, r) - e;
  return t.setDate(t.getDate() - s * 7), D(t, r?.in);
}
class Le extends c {
  priority = 100;
  parse(e, r, t) {
    switch (r) {
      case "w":
        return u(f.week, e);
      case "wo":
        return t.ordinalNumber(e, { unit: "week" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 1 && r <= 53;
  }
  set(e, r, t, s) {
    return R(qe(e, t, s), s);
  }
  incompatibleTokens = [
    "y",
    "R",
    "u",
    "q",
    "Q",
    "M",
    "L",
    "I",
    "d",
    "D",
    "i",
    "t",
    "T"
  ];
}
function ve(n, e, r) {
  const t = D(n, r?.in), s = le(t, r) - e;
  return t.setDate(t.getDate() - s * 7), t;
}
class Re extends c {
  priority = 100;
  parse(e, r, t) {
    switch (r) {
      case "I":
        return u(f.week, e);
      case "Io":
        return t.ordinalNumber(e, { unit: "week" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 1 && r <= 53;
  }
  set(e, r, t) {
    return $(ve(e, t));
  }
  incompatibleTokens = [
    "y",
    "Y",
    "u",
    "q",
    "Q",
    "M",
    "L",
    "w",
    "d",
    "D",
    "e",
    "c",
    "t",
    "T"
  ];
}
const Ne = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Qe = [
  31,
  29,
  31,
  30,
  31,
  30,
  31,
  31,
  30,
  31,
  30,
  31
];
class Ce extends c {
  priority = 90;
  subPriority = 1;
  parse(e, r, t) {
    switch (r) {
      case "d":
        return u(f.date, e);
      case "do":
        return t.ordinalNumber(e, { unit: "date" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    const t = e.getFullYear(), s = U(t), o = e.getMonth();
    return s ? r >= 1 && r <= Qe[o] : r >= 1 && r <= Ne[o];
  }
  set(e, r, t) {
    return e.setDate(t), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "Y",
    "R",
    "q",
    "Q",
    "w",
    "I",
    "D",
    "i",
    "e",
    "c",
    "t",
    "T"
  ];
}
class We extends c {
  priority = 90;
  subpriority = 1;
  parse(e, r, t) {
    switch (r) {
      case "D":
      case "DD":
        return u(f.dayOfYear, e);
      case "Do":
        return t.ordinalNumber(e, { unit: "date" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    const t = e.getFullYear();
    return U(t) ? r >= 1 && r <= 366 : r >= 1 && r <= 365;
  }
  set(e, r, t) {
    return e.setMonth(0, t), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "Y",
    "R",
    "q",
    "Q",
    "M",
    "L",
    "w",
    "I",
    "d",
    "E",
    "i",
    "e",
    "c",
    "t",
    "T"
  ];
}
function Q(n, e, r) {
  const t = A(), s = r?.weekStartsOn ?? r?.locale?.options?.weekStartsOn ?? t.weekStartsOn ?? t.locale?.options?.weekStartsOn ?? 0, o = D(n, r?.in), l = o.getDay(), _ = (e % 7 + 7) % 7, p = 7 - s, g = e < 0 || e > 6 ? e - (l + p) % 7 : (_ + p) % 7 - (l + p) % 7;
  return z(o, g, r);
}
class Be extends c {
  priority = 90;
  parse(e, r, t) {
    switch (r) {
      // Tue
      case "E":
      case "EE":
      case "EEE":
        return t.day(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.day(e, { width: "short", context: "formatting" }) || t.day(e, { width: "narrow", context: "formatting" });
      // T
      case "EEEEE":
        return t.day(e, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "EEEEEE":
        return t.day(e, { width: "short", context: "formatting" }) || t.day(e, { width: "narrow", context: "formatting" });
      default:
        return t.day(e, { width: "wide", context: "formatting" }) || t.day(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.day(e, { width: "short", context: "formatting" }) || t.day(e, { width: "narrow", context: "formatting" });
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 6;
  }
  set(e, r, t, s) {
    return e = Q(e, t, s), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = ["D", "i", "e", "c", "t", "T"];
}
class Fe extends c {
  priority = 90;
  parse(e, r, t, s) {
    const o = (l) => {
      const y = Math.floor((l - 1) / 7) * 7;
      return (l + s.weekStartsOn + 6) % 7 + y;
    };
    switch (r) {
      // 3
      case "e":
      case "ee":
        return w(d(r.length, e), o);
      // 3rd
      case "eo":
        return w(
          t.ordinalNumber(e, {
            unit: "day"
          }),
          o
        );
      // Tue
      case "eee":
        return t.day(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.day(e, { width: "short", context: "formatting" }) || t.day(e, { width: "narrow", context: "formatting" });
      // T
      case "eeeee":
        return t.day(e, {
          width: "narrow",
          context: "formatting"
        });
      // Tu
      case "eeeeee":
        return t.day(e, { width: "short", context: "formatting" }) || t.day(e, { width: "narrow", context: "formatting" });
      default:
        return t.day(e, { width: "wide", context: "formatting" }) || t.day(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.day(e, { width: "short", context: "formatting" }) || t.day(e, { width: "narrow", context: "formatting" });
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 6;
  }
  set(e, r, t, s) {
    return e = Q(e, t, s), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "y",
    "R",
    "u",
    "q",
    "Q",
    "M",
    "L",
    "I",
    "d",
    "D",
    "E",
    "i",
    "c",
    "t",
    "T"
  ];
}
class Ge extends c {
  priority = 90;
  parse(e, r, t, s) {
    const o = (l) => {
      const y = Math.floor((l - 1) / 7) * 7;
      return (l + s.weekStartsOn + 6) % 7 + y;
    };
    switch (r) {
      // 3
      case "c":
      case "cc":
        return w(d(r.length, e), o);
      // 3rd
      case "co":
        return w(
          t.ordinalNumber(e, {
            unit: "day"
          }),
          o
        );
      // Tue
      case "ccc":
        return t.day(e, {
          width: "abbreviated",
          context: "standalone"
        }) || t.day(e, { width: "short", context: "standalone" }) || t.day(e, { width: "narrow", context: "standalone" });
      // T
      case "ccccc":
        return t.day(e, {
          width: "narrow",
          context: "standalone"
        });
      // Tu
      case "cccccc":
        return t.day(e, { width: "short", context: "standalone" }) || t.day(e, { width: "narrow", context: "standalone" });
      default:
        return t.day(e, { width: "wide", context: "standalone" }) || t.day(e, {
          width: "abbreviated",
          context: "standalone"
        }) || t.day(e, { width: "short", context: "standalone" }) || t.day(e, { width: "narrow", context: "standalone" });
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 6;
  }
  set(e, r, t, s) {
    return e = Q(e, t, s), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "y",
    "R",
    "u",
    "q",
    "Q",
    "M",
    "L",
    "I",
    "d",
    "D",
    "E",
    "i",
    "e",
    "t",
    "T"
  ];
}
function Xe(n, e, r) {
  const t = D(n, r?.in), s = xe(t, r), o = e - s;
  return z(t, o, r);
}
class Ae extends c {
  priority = 90;
  parse(e, r, t) {
    const s = (o) => o === 0 ? 7 : o;
    switch (r) {
      // 2
      case "i":
      case "ii":
        return d(r.length, e);
      // 2nd
      case "io":
        return t.ordinalNumber(e, { unit: "day" });
      // Tue
      case "iii":
        return w(
          t.day(e, {
            width: "abbreviated",
            context: "formatting"
          }) || t.day(e, {
            width: "short",
            context: "formatting"
          }) || t.day(e, {
            width: "narrow",
            context: "formatting"
          }),
          s
        );
      // T
      case "iiiii":
        return w(
          t.day(e, {
            width: "narrow",
            context: "formatting"
          }),
          s
        );
      // Tu
      case "iiiiii":
        return w(
          t.day(e, {
            width: "short",
            context: "formatting"
          }) || t.day(e, {
            width: "narrow",
            context: "formatting"
          }),
          s
        );
      default:
        return w(
          t.day(e, {
            width: "wide",
            context: "formatting"
          }) || t.day(e, {
            width: "abbreviated",
            context: "formatting"
          }) || t.day(e, {
            width: "short",
            context: "formatting"
          }) || t.day(e, {
            width: "narrow",
            context: "formatting"
          }),
          s
        );
    }
  }
  validate(e, r) {
    return r >= 1 && r <= 7;
  }
  set(e, r, t) {
    return e = Xe(e, t), e.setHours(0, 0, 0, 0), e;
  }
  incompatibleTokens = [
    "y",
    "Y",
    "u",
    "q",
    "Q",
    "M",
    "L",
    "w",
    "d",
    "D",
    "E",
    "e",
    "c",
    "t",
    "T"
  ];
}
class $e extends c {
  priority = 80;
  parse(e, r, t) {
    switch (r) {
      case "a":
      case "aa":
      case "aaa":
        return t.dayPeriod(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
      case "aaaaa":
        return t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return t.dayPeriod(e, {
          width: "wide",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
    }
  }
  set(e, r, t) {
    return e.setHours(N(t), 0, 0, 0), e;
  }
  incompatibleTokens = ["b", "B", "H", "k", "t", "T"];
}
class ze extends c {
  priority = 80;
  parse(e, r, t) {
    switch (r) {
      case "b":
      case "bb":
      case "bbb":
        return t.dayPeriod(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
      case "bbbbb":
        return t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return t.dayPeriod(e, {
          width: "wide",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
    }
  }
  set(e, r, t) {
    return e.setHours(N(t), 0, 0, 0), e;
  }
  incompatibleTokens = ["a", "B", "H", "k", "t", "T"];
}
class Ve extends c {
  priority = 80;
  parse(e, r, t) {
    switch (r) {
      case "B":
      case "BB":
      case "BBB":
        return t.dayPeriod(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
      case "BBBBB":
        return t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
      default:
        return t.dayPeriod(e, {
          width: "wide",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "abbreviated",
          context: "formatting"
        }) || t.dayPeriod(e, {
          width: "narrow",
          context: "formatting"
        });
    }
  }
  set(e, r, t) {
    return e.setHours(N(t), 0, 0, 0), e;
  }
  incompatibleTokens = ["a", "b", "t", "T"];
}
class Ze extends c {
  priority = 70;
  parse(e, r, t) {
    switch (r) {
      case "h":
        return u(f.hour12h, e);
      case "ho":
        return t.ordinalNumber(e, { unit: "hour" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 1 && r <= 12;
  }
  set(e, r, t) {
    const s = e.getHours() >= 12;
    return s && t < 12 ? e.setHours(t + 12, 0, 0, 0) : !s && t === 12 ? e.setHours(0, 0, 0, 0) : e.setHours(t, 0, 0, 0), e;
  }
  incompatibleTokens = ["H", "K", "k", "t", "T"];
}
class Ke extends c {
  priority = 70;
  parse(e, r, t) {
    switch (r) {
      case "H":
        return u(f.hour23h, e);
      case "Ho":
        return t.ordinalNumber(e, { unit: "hour" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 23;
  }
  set(e, r, t) {
    return e.setHours(t, 0, 0, 0), e;
  }
  incompatibleTokens = ["a", "b", "h", "K", "k", "t", "T"];
}
class je extends c {
  priority = 70;
  parse(e, r, t) {
    switch (r) {
      case "K":
        return u(f.hour11h, e);
      case "Ko":
        return t.ordinalNumber(e, { unit: "hour" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 11;
  }
  set(e, r, t) {
    return e.getHours() >= 12 && t < 12 ? e.setHours(t + 12, 0, 0, 0) : e.setHours(t, 0, 0, 0), e;
  }
  incompatibleTokens = ["h", "H", "k", "t", "T"];
}
class Ue extends c {
  priority = 70;
  parse(e, r, t) {
    switch (r) {
      case "k":
        return u(f.hour24h, e);
      case "ko":
        return t.ordinalNumber(e, { unit: "hour" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 1 && r <= 24;
  }
  set(e, r, t) {
    const s = t <= 24 ? t % 24 : t;
    return e.setHours(s, 0, 0, 0), e;
  }
  incompatibleTokens = ["a", "b", "h", "H", "K", "t", "T"];
}
class Je extends c {
  priority = 60;
  parse(e, r, t) {
    switch (r) {
      case "m":
        return u(f.minute, e);
      case "mo":
        return t.ordinalNumber(e, { unit: "minute" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 59;
  }
  set(e, r, t) {
    return e.setMinutes(t, 0, 0), e;
  }
  incompatibleTokens = ["t", "T"];
}
class Se extends c {
  priority = 50;
  parse(e, r, t) {
    switch (r) {
      case "s":
        return u(f.second, e);
      case "so":
        return t.ordinalNumber(e, { unit: "second" });
      default:
        return d(r.length, e);
    }
  }
  validate(e, r) {
    return r >= 0 && r <= 59;
  }
  set(e, r, t) {
    return e.setSeconds(t, 0), e;
  }
  incompatibleTokens = ["t", "T"];
}
class et extends c {
  priority = 30;
  parse(e, r) {
    const t = (s) => Math.trunc(s * Math.pow(10, -r.length + 3));
    return w(d(r.length, e), t);
  }
  set(e, r, t) {
    return e.setMilliseconds(t), e;
  }
  incompatibleTokens = ["t", "T"];
}
class tt extends c {
  priority = 10;
  parse(e, r) {
    switch (r) {
      case "X":
        return b(
          x.basicOptionalMinutes,
          e
        );
      case "XX":
        return b(x.basic, e);
      case "XXXX":
        return b(
          x.basicOptionalSeconds,
          e
        );
      case "XXXXX":
        return b(
          x.extendedOptionalSeconds,
          e
        );
      default:
        return b(x.extended, e);
    }
  }
  set(e, r, t) {
    return r.timestampIsSet ? e : m(
      e,
      e.getTime() - V(e) - t
    );
  }
  incompatibleTokens = ["t", "T", "x"];
}
class rt extends c {
  priority = 10;
  parse(e, r) {
    switch (r) {
      case "x":
        return b(
          x.basicOptionalMinutes,
          e
        );
      case "xx":
        return b(x.basic, e);
      case "xxxx":
        return b(
          x.basicOptionalSeconds,
          e
        );
      case "xxxxx":
        return b(
          x.extendedOptionalSeconds,
          e
        );
      default:
        return b(x.extended, e);
    }
  }
  set(e, r, t) {
    return r.timestampIsSet ? e : m(
      e,
      e.getTime() - V(e) - t
    );
  }
  incompatibleTokens = ["t", "T", "X"];
}
class nt extends c {
  priority = 40;
  parse(e) {
    return K(e);
  }
  set(e, r, t) {
    return [m(e, t * 1e3), { timestampIsSet: !0 }];
  }
  incompatibleTokens = "*";
}
class st extends c {
  priority = 20;
  parse(e) {
    return K(e);
  }
  set(e, r, t) {
    return [m(e, t), { timestampIsSet: !0 }];
  }
  incompatibleTokens = "*";
}
const ot = {
  G: new _e(),
  y: new ke(),
  Y: new Pe(),
  R: new Me(),
  u: new Ye(),
  Q: new Oe(),
  q: new Ee(),
  M: new He(),
  L: new Ie(),
  w: new Le(),
  I: new Re(),
  d: new Ce(),
  D: new We(),
  E: new Be(),
  e: new Fe(),
  c: new Ge(),
  i: new Ae(),
  a: new $e(),
  b: new ze(),
  B: new Ve(),
  h: new Ze(),
  H: new Ke(),
  K: new je(),
  k: new Ue(),
  m: new Je(),
  s: new Se(),
  S: new et(),
  X: new tt(),
  x: new rt(),
  t: new nt(),
  T: new st()
}, at = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, it = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, ct = /^'([^]*?)'?$/, ut = /''/g, lt = /\S/, dt = /[a-zA-Z]/;
function ft(n, e, r, t) {
  const s = () => m(r, NaN), o = ye(), l = o.locale ?? de, y = o.firstWeekContainsDate ?? o.locale?.options?.firstWeekContainsDate ?? 1, _ = o.weekStartsOn ?? o.locale?.options?.weekStartsOn ?? 0, p = {
    firstWeekContainsDate: y,
    weekStartsOn: _,
    locale: l
  }, g = [new De(t?.in, r)], E = e.match(it).map((a) => {
    const i = a[0];
    if (i in F) {
      const h = F[i];
      return h(a, l.formatLong);
    }
    return a;
  }).join("").match(at), k = [];
  for (let a of E) {
    fe(a) && G(a, e, n), we(a) && G(a, e, n);
    const i = a[0], h = ot[i];
    if (h) {
      const { incompatibleTokens: P } = h;
      if (Array.isArray(P)) {
        const C = k.find(
          (W) => P.includes(W.token) || W.token === i
        );
        if (C)
          throw new RangeError(
            `The format string mustn't contain \`${C.fullToken}\` and \`${a}\` at the same time`
          );
      } else if (h.incompatibleTokens === "*" && k.length > 0)
        throw new RangeError(
          `The format string mustn't contain \`${a}\` and any other token at the same time`
        );
      k.push({ token: i, fullToken: a });
      const I = h.run(
        n,
        a,
        l.match,
        p
      );
      if (!I)
        return s();
      g.push(I.setter), n = I.rest;
    } else {
      if (i.match(dt))
        throw new RangeError(
          "Format string contains an unescaped latin alphabet character `" + i + "`"
        );
      if (a === "''" ? a = "'" : i === "'" && (a = wt(a)), n.indexOf(a) === 0)
        n = n.slice(a.length);
      else
        return s();
    }
  }
  if (n.length > 0 && lt.test(n))
    return s();
  const H = g.map((a) => a.priority).sort((a, i) => i - a).filter((a, i, h) => h.indexOf(a) === i).map(
    (a) => g.filter((i) => i.priority === a).sort((i, h) => h.subPriority - i.subPriority)
  ).map((a) => a[0]);
  let T = D(r, t?.in);
  if (isNaN(+T)) return s();
  const M = {};
  for (const a of H) {
    if (!a.validate(T, p))
      return s();
    const i = a.set(T, M, p);
    Array.isArray(i) ? (T = i[0], Object.assign(M, i[1])) : T = i;
  }
  return T;
}
function wt(n) {
  return n.match(ct)[1].replace(ut, "'");
}
const ht = {
  "purpur-date-field__container": "_purpur-date-field__container_ci2f4_1",
  "purpur-date-field__overlay": "_purpur-date-field__overlay_ci2f4_5",
  "purpur-date-field__start-adornment": "_purpur-date-field__start-adornment_ci2f4_16"
}, pt = (n) => ft(n, "yyyy-MM-dd", /* @__PURE__ */ new Date()), X = (n) => n ? he(n, "yyyy-MM-dd") : "", yt = (...n) => {
  const e = n.filter(Boolean);
  return e.length <= 1 ? e[0] || null : (r) => {
    for (const t of e)
      typeof t == "function" ? t(r) : t && (t.current = r);
  };
}, q = se.bind(ht), L = "purpur-date-field", v = "YYYY-MM-DD", xt = S(
  ({ id: n, value: e, label: r, onChange: t, startAdornment: s, ...o }, l) => {
    const [y, _] = B(X(e));
    ee(() => {
      _(e ? X(e) : "");
    }, [e]);
    const p = te(null), g = yt(l, p), [E, k] = B({});
    re(() => {
      if (p.current) {
        const a = window.document.querySelector(
          `label[for="${p.current.id}"]`
        ), i = a ? a.offsetHeight + 4 : 0, h = window.getComputedStyle(p.current);
        k({
          position: "absolute",
          top: p.current.offsetTop + i,
          left: p.current.offsetLeft,
          padding: h.padding,
          width: p.current.offsetWidth,
          height: p.current.offsetHeight
        });
      }
    }, [y, r, p]);
    const H = (a) => {
      if (a.length === 0 && t?.(void 0), a.length !== v.length)
        return;
      const i = pt(a);
      pe(i) && t?.(i);
    }, T = (a) => {
      const i = a.target.value.replace(/\D/g, "");
      let h = "";
      i.length > 0 && (h += i.slice(0, 4)), i.length > 4 && (h += "-" + i.slice(4, 6)), i.length > 6 && (h += "-" + i.slice(6, 8)), _(h), H(a.target.value);
    }, M = () => v.split("").map((i, h) => {
      const P = y[h];
      return /* @__PURE__ */ Y(
        "span",
        {
          style: {
            color: P ? "transparent" : "var(--purpur-color-text-weak)"
          },
          children: P || i
        },
        h
      );
    });
    return /* @__PURE__ */ J("div", { className: q(`${L}__container`), children: [
      /* @__PURE__ */ Y(
        ne,
        {
          ...o,
          startAdornment: s && /* @__PURE__ */ Y("span", { className: q(`${L}__start-adornment`), children: s }, n),
          ref: g,
          value: y,
          onChange: T,
          type: "text",
          maxLength: v.length,
          inputMode: "numeric",
          label: r
        }
      ),
      /* @__PURE__ */ Y("div", { role: "presentation", style: E, className: q(`${L}__overlay`), children: M() })
    ] });
  }
);
xt.displayName = "DateField";
export {
  xt as D
};
//# sourceMappingURL=date-field-D_6iP2fC.mjs.map
