UNPKG

@konstructio/ui

Version:

A set of reusable and customizable React components built for konstruct.io

1,697 lines 98.9 kB
import { jsx as qe } from "react/jsx-runtime"; import h, { createContext as vn, useContext as Wn, useCallback as q, useRef as Se, useLayoutEffect as Sn, useState as Ce, useEffect as Nn, useMemo as Ne } from "react"; import { cn as V } from "../../utils/index.js"; import { datePickerVariants as Cn } from "./DatePicker.variants.js"; import { C as xn, a as Yn } from "../../chevron-right-DYvXLeql.js"; import '../../DatePicker.css';function Tn(e, t, r = "long") { return new Intl.DateTimeFormat("en-US", { // Enforces engine to render the time. Without the option JavaScriptCore omits it. hour: "numeric", timeZone: e, timeZoneName: r }).format(t).split(/\s/g).slice(2).join(" "); } const Pn = {}, ge = {}; function ie(e, t) { try { const n = (Pn[e] ||= new Intl.DateTimeFormat("en-US", { timeZone: e, timeZoneName: "longOffset" }).format)(t).split("GMT")[1]; return n in ge ? ge[n] : it(n, n.split(":")); } catch { if (e in ge) return ge[e]; const r = e?.match(En); return r ? it(e, r.slice(1)) : NaN; } } const En = /([+-]\d\d):?(\d\d)?/; function it(e, t) { const r = +(t[0] || 0), n = +(t[1] || 0), o = +(t[2] || 0) / 60; return ge[e] = r * 60 + n > 0 ? r * 60 + n + o : r * 60 - n - o; } class J extends Date { //#region static constructor(...t) { super(), t.length > 1 && typeof t[t.length - 1] == "string" && (this.timeZone = t.pop()), this.internal = /* @__PURE__ */ new Date(), isNaN(ie(this.timeZone, this)) ? this.setTime(NaN) : t.length ? typeof t[0] == "number" && (t.length === 1 || t.length === 2 && typeof t[1] != "number") ? this.setTime(t[0]) : typeof t[0] == "string" ? this.setTime(+new Date(t[0])) : t[0] instanceof Date ? this.setTime(+t[0]) : (this.setTime(+new Date(...t)), Mt(this), Qe(this)) : this.setTime(Date.now()); } static tz(t, ...r) { return r.length ? new J(...r, t) : new J(Date.now(), t); } //#endregion //#region time zone withTimeZone(t) { return new J(+this, t); } getTimezoneOffset() { const t = -ie(this.timeZone, this); return t > 0 ? Math.floor(t) : Math.ceil(t); } //#endregion //#region time setTime(t) { return Date.prototype.setTime.apply(this, arguments), Qe(this), +this; } //#endregion //#region date-fns integration [/* @__PURE__ */ Symbol.for("constructDateFrom")](t) { return new J(+new Date(t), this.timeZone); } //#endregion } const ct = /^(get|set)(?!UTC)/; Object.getOwnPropertyNames(Date.prototype).forEach((e) => { if (!ct.test(e)) return; const t = e.replace(ct, "$1UTC"); J.prototype[t] && (e.startsWith("get") ? J.prototype[e] = function() { return this.internal[t](); } : (J.prototype[e] = function() { return Date.prototype[t].apply(this.internal, arguments), _n(this), +this; }, J.prototype[t] = function() { return Date.prototype[t].apply(this, arguments), Qe(this), +this; })); }); function Qe(e) { e.internal.setTime(+e), e.internal.setUTCSeconds(e.internal.getUTCSeconds() - Math.round(-ie(e.timeZone, e) * 60)); } function _n(e) { Date.prototype.setFullYear.call(e, e.internal.getUTCFullYear(), e.internal.getUTCMonth(), e.internal.getUTCDate()), Date.prototype.setHours.call(e, e.internal.getUTCHours(), e.internal.getUTCMinutes(), e.internal.getUTCSeconds(), e.internal.getUTCMilliseconds()), Mt(e); } function Mt(e) { const t = ie(e.timeZone, e), r = t > 0 ? Math.floor(t) : Math.ceil(t), n = /* @__PURE__ */ new Date(+e); n.setUTCHours(n.getUTCHours() - 1); const o = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset(), i = -(/* @__PURE__ */ new Date(+n)).getTimezoneOffset(), a = o - i, s = Date.prototype.getHours.apply(e) !== e.internal.getUTCHours(); a && s && e.internal.setUTCMinutes(e.internal.getUTCMinutes() + a); const c = o - r; c && Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + c); const u = /* @__PURE__ */ new Date(+e); u.setUTCSeconds(0); const f = o > 0 ? u.getSeconds() : (u.getSeconds() - 60) % 60, l = Math.round(-(ie(e.timeZone, e) * 60)) % 60; (l || f) && (e.internal.setUTCSeconds(e.internal.getUTCSeconds() + l), Date.prototype.setUTCSeconds.call(e, Date.prototype.getUTCSeconds.call(e) + l + f)); const d = ie(e.timeZone, e), w = d > 0 ? Math.floor(d) : Math.ceil(d), N = -(/* @__PURE__ */ new Date(+e)).getTimezoneOffset() - w, k = w !== r, v = N - c; if (k && v) { Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + v); const Y = ie(e.timeZone, e), p = Y > 0 ? Math.floor(Y) : Math.ceil(Y), D = w - p; D && (e.internal.setUTCMinutes(e.internal.getUTCMinutes() + D), Date.prototype.setUTCMinutes.call(e, Date.prototype.getUTCMinutes.call(e) + D)); } } class H extends J { //#region static static tz(t, ...r) { return r.length ? new H(...r, t) : new H(Date.now(), t); } //#endregion //#region representation toISOString() { const [t, r, n] = this.tzComponents(), o = `${t}${r}:${n}`; return this.internal.toISOString().slice(0, -1) + o; } toString() { return `${this.toDateString()} ${this.toTimeString()}`; } toDateString() { const [t, r, n, o] = this.internal.toUTCString().split(" "); return `${t?.slice(0, -1)} ${n} ${r} ${o}`; } toTimeString() { const t = this.internal.toUTCString().split(" ")[4], [r, n, o] = this.tzComponents(); return `${t} GMT${r}${n}${o} (${Tn(this.timeZone, this)})`; } toLocaleString(t, r) { return Date.prototype.toLocaleString.call(this, t, { ...r, timeZone: r?.timeZone || this.timeZone }); } toLocaleDateString(t, r) { return Date.prototype.toLocaleDateString.call(this, t, { ...r, timeZone: r?.timeZone || this.timeZone }); } toLocaleTimeString(t, r) { return Date.prototype.toLocaleTimeString.call(this, t, { ...r, timeZone: r?.timeZone || this.timeZone }); } //#endregion //#region private tzComponents() { const t = this.getTimezoneOffset(), r = t > 0 ? "-" : "+", n = String(Math.floor(Math.abs(t) / 60)).padStart(2, "0"), o = String(Math.abs(t) % 60).padStart(2, "0"); return [r, n, o]; } //#endregion withTimeZone(t) { return new H(+this, t); } //#region date-fns integration [/* @__PURE__ */ Symbol.for("constructDateFrom")](t) { return new H(+new Date(t), this.timeZone); } //#endregion } const kt = 6048e5, Fn = 864e5, ut = /* @__PURE__ */ Symbol.for("constructDateFrom"); function B(e, t) { return typeof e == "function" ? e(t) : e && typeof e == "object" && ut in e ? e[ut](t) : e instanceof Date ? new e.constructor(t) : new Date(t); } function P(e, t) { return B(t || e, e); } function Dt(e, t, r) { const n = P(e, r?.in); return isNaN(t) ? B(e, NaN) : (t && n.setDate(n.getDate() + t), n); } function Ot(e, t, r) { const n = P(e, r?.in); if (isNaN(t)) return B(e, NaN); if (!t) return n; const o = n.getDate(), i = B(e, n.getTime()); i.setMonth(n.getMonth() + t + 1, 0); const a = i.getDate(); return o >= a ? i : (n.setFullYear( i.getFullYear(), i.getMonth(), o ), n); } let Bn = {}; function Me() { return Bn; } function de(e, t) { const r = Me(), n = t?.weekStartsOn ?? t?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, o = P(e, t?.in), i = o.getDay(), a = (i < n ? 7 : 0) + i - n; return o.setDate(o.getDate() - a), o.setHours(0, 0, 0, 0), o; } function we(e, t) { return de(e, { ...t, weekStartsOn: 1 }); } function vt(e, t) { const r = P(e, t?.in), n = r.getFullYear(), o = B(r, 0); o.setFullYear(n + 1, 0, 4), o.setHours(0, 0, 0, 0); const i = we(o), a = B(r, 0); a.setFullYear(n, 0, 4), a.setHours(0, 0, 0, 0); const s = we(a); return r.getTime() >= i.getTime() ? n + 1 : r.getTime() >= s.getTime() ? n : n - 1; } function lt(e) { const t = P(e), r = new Date( Date.UTC( t.getFullYear(), t.getMonth(), t.getDate(), t.getHours(), t.getMinutes(), t.getSeconds(), t.getMilliseconds() ) ); return r.setUTCFullYear(t.getFullYear()), +e - +r; } function he(e, ...t) { const r = B.bind( null, t.find((n) => typeof n == "object") ); return t.map(r); } function pe(e, t) { const r = P(e, t?.in); return r.setHours(0, 0, 0, 0), r; } function Ve(e, t, r) { const [n, o] = he( r?.in, e, t ), i = pe(n), a = pe(o), s = +i - lt(i), c = +a - lt(a); return Math.round((s - c) / Fn); } function In(e, t) { const r = vt(e, t), n = B(e, 0); return n.setFullYear(r, 0, 4), n.setHours(0, 0, 0, 0), we(n); } function Hn(e, t, r) { return Dt(e, t * 7, r); } function An(e, t, r) { return Ot(e, t * 12, r); } function qn(e, t) { let r, n = t?.in; return e.forEach((o) => { !n && typeof o == "object" && (n = B.bind(null, o)); const i = P(o, n); (!r || r < i || isNaN(+i)) && (r = i); }), B(n, r || NaN); } function jn(e, t) { let r, n = t?.in; return e.forEach((o) => { !n && typeof o == "object" && (n = B.bind(null, o)); const i = P(o, n); (!r || r > i || isNaN(+i)) && (r = i); }), B(n, r || NaN); } function Gn(e, t, r) { const [n, o] = he( r?.in, e, t ); return +pe(n) == +pe(o); } function Wt(e) { return e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]"; } function $n(e) { return !(!Wt(e) && typeof e != "number" || isNaN(+P(e))); } function St(e, t, r) { const [n, o] = he( r?.in, e, t ), i = n.getFullYear() - o.getFullYear(), a = n.getMonth() - o.getMonth(); return i * 12 + a; } function Rn(e, t) { const r = P(e, t?.in), n = r.getMonth(); return r.setFullYear(r.getFullYear(), n + 1, 0), r.setHours(23, 59, 59, 999), r; } function Nt(e, t) { const [r, n] = he(e, t.start, t.end); return { start: r, end: n }; } function zn(e, t) { const { start: r, end: n } = Nt(t?.in, e); let o = +r > +n; const i = o ? +r : +n, a = o ? n : r; a.setHours(0, 0, 0, 0), a.setDate(1); let s = 1; const c = []; for (; +a <= i; ) c.push(B(r, a)), a.setMonth(a.getMonth() + s); return o ? c.reverse() : c; } function Qn(e, t) { const r = P(e, t?.in); return r.setDate(1), r.setHours(0, 0, 0, 0), r; } function Vn(e, t) { const r = P(e, t?.in), n = r.getFullYear(); return r.setFullYear(n + 1, 0, 0), r.setHours(23, 59, 59, 999), r; } function Ct(e, t) { const r = P(e, t?.in); return r.setFullYear(r.getFullYear(), 0, 1), r.setHours(0, 0, 0, 0), r; } function Xn(e, t) { const { start: r, end: n } = Nt(t?.in, e); let o = +r > +n; const i = o ? +r : +n, a = o ? n : r; a.setHours(0, 0, 0, 0), a.setMonth(0, 1); let s = 1; const c = []; for (; +a <= i; ) c.push(B(r, a)), a.setFullYear(a.getFullYear() + s); return o ? c.reverse() : c; } function xt(e, t) { const r = Me(), n = t?.weekStartsOn ?? t?.locale?.options?.weekStartsOn ?? r.weekStartsOn ?? r.locale?.options?.weekStartsOn ?? 0, o = P(e, t?.in), i = o.getDay(), a = (i < n ? -7 : 0) + 6 - (i - n); return o.setDate(o.getDate() + a), o.setHours(23, 59, 59, 999), o; } function Un(e, t) { return xt(e, { ...t, weekStartsOn: 1 }); } const Zn = { 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" } }, Kn = (e, t, r) => { let n; const o = Zn[e]; return typeof o == "string" ? n = o : t === 1 ? n = o.one : n = o.other.replace("{{count}}", t.toString()), r?.addSuffix ? r.comparison && r.comparison > 0 ? "in " + n : n + " ago" : n; }; function je(e) { return (t = {}) => { const r = t.width ? String(t.width) : e.defaultWidth; return e.formats[r] || e.formats[e.defaultWidth]; }; } const Jn = { full: "EEEE, MMMM do, y", long: "MMMM do, y", medium: "MMM d, y", short: "MM/dd/yyyy" }, Ln = { full: "h:mm:ss a zzzz", long: "h:mm:ss a z", medium: "h:mm:ss a", short: "h:mm a" }, er = { full: "{{date}} 'at' {{time}}", long: "{{date}} 'at' {{time}}", medium: "{{date}}, {{time}}", short: "{{date}}, {{time}}" }, tr = { date: je({ formats: Jn, defaultWidth: "full" }), time: je({ formats: Ln, defaultWidth: "full" }), dateTime: je({ formats: er, defaultWidth: "full" }) }, nr = { lastWeek: "'last' eeee 'at' p", yesterday: "'yesterday at' p", today: "'today at' p", tomorrow: "'tomorrow at' p", nextWeek: "eeee 'at' p", other: "P" }, rr = (e, t, r, n) => nr[e]; function me(e) { return (t, r) => { const n = r?.context ? String(r.context) : "standalone"; let o; if (n === "formatting" && e.formattingValues) { const a = e.defaultFormattingWidth || e.defaultWidth, s = r?.width ? String(r.width) : a; o = e.formattingValues[s] || e.formattingValues[a]; } else { const a = e.defaultWidth, s = r?.width ? String(r.width) : e.defaultWidth; o = e.values[s] || e.values[a]; } const i = e.argumentCallback ? e.argumentCallback(t) : t; return o[i]; }; } const or = { narrow: ["B", "A"], abbreviated: ["BC", "AD"], wide: ["Before Christ", "Anno Domini"] }, sr = { narrow: ["1", "2", "3", "4"], abbreviated: ["Q1", "Q2", "Q3", "Q4"], wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] }, ar = { 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" ] }, ir = { 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" ] }, cr = { 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" } }, ur = { 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" } }, lr = (e, t) => { const r = Number(e), n = r % 100; if (n > 20 || n < 10) switch (n % 10) { case 1: return r + "st"; case 2: return r + "nd"; case 3: return r + "rd"; } return r + "th"; }, fr = { ordinalNumber: lr, era: me({ values: or, defaultWidth: "wide" }), quarter: me({ values: sr, defaultWidth: "wide", argumentCallback: (e) => e - 1 }), month: me({ values: ar, defaultWidth: "wide" }), day: me({ values: ir, defaultWidth: "wide" }), dayPeriod: me({ values: cr, defaultWidth: "wide", formattingValues: ur, defaultFormattingWidth: "wide" }) }; function ye(e) { return (t, r = {}) => { const n = r.width, o = n && e.matchPatterns[n] || e.matchPatterns[e.defaultMatchWidth], i = t.match(o); if (!i) return null; const a = i[0], s = n && e.parsePatterns[n] || e.parsePatterns[e.defaultParseWidth], c = Array.isArray(s) ? hr(s, (l) => l.test(a)) : ( // [TODO] -- I challenge you to fix the type dr(s, (l) => l.test(a)) ); let u; u = e.valueCallback ? e.valueCallback(c) : c, u = r.valueCallback ? ( // [TODO] -- I challenge you to fix the type r.valueCallback(u) ) : u; const f = t.slice(a.length); return { value: u, rest: f }; }; } function dr(e, t) { for (const r in e) if (Object.prototype.hasOwnProperty.call(e, r) && t(e[r])) return r; } function hr(e, t) { for (let r = 0; r < e.length; r++) if (t(e[r])) return r; } function mr(e) { return (t, r = {}) => { const n = t.match(e.matchPattern); if (!n) return null; const o = n[0], i = t.match(e.parsePattern); if (!i) return null; let a = e.valueCallback ? e.valueCallback(i[0]) : i[0]; a = r.valueCallback ? r.valueCallback(a) : a; const s = t.slice(o.length); return { value: a, rest: s }; }; } const yr = /^(\d+)(th|st|nd|rd)?/i, gr = /\d+/i, br = { 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 }, wr = { any: [/^b/i, /^(a|c)/i] }, pr = { narrow: /^[1234]/i, abbreviated: /^q[1234]/i, wide: /^[1234](th|st|nd|rd)? quarter/i }, Mr = { any: [/1/i, /2/i, /3/i, /4/i] }, kr = { 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 }, Dr = { 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 ] }, Or = { 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 }, vr = { 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] }, Wr = { 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 }, Sr = { 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 } }, Nr = { ordinalNumber: mr({ matchPattern: yr, parsePattern: gr, valueCallback: (e) => parseInt(e, 10) }), era: ye({ matchPatterns: br, defaultMatchWidth: "wide", parsePatterns: wr, defaultParseWidth: "any" }), quarter: ye({ matchPatterns: pr, defaultMatchWidth: "wide", parsePatterns: Mr, defaultParseWidth: "any", valueCallback: (e) => e + 1 }), month: ye({ matchPatterns: kr, defaultMatchWidth: "wide", parsePatterns: Dr, defaultParseWidth: "any" }), day: ye({ matchPatterns: Or, defaultMatchWidth: "wide", parsePatterns: vr, defaultParseWidth: "any" }), dayPeriod: ye({ matchPatterns: Wr, defaultMatchWidth: "any", parsePatterns: Sr, defaultParseWidth: "any" }) }, fe = { code: "en-US", formatDistance: Kn, formatLong: tr, formatRelative: rr, localize: fr, match: Nr, options: { weekStartsOn: 0, firstWeekContainsDate: 1 } }; function Cr(e, t) { const r = P(e, t?.in); return Ve(r, Ct(r)) + 1; } function Xe(e, t) { const r = P(e, t?.in), n = +we(r) - +In(r); return Math.round(n / kt) + 1; } function Yt(e, t) { const r = P(e, t?.in), n = r.getFullYear(), o = Me(), i = t?.firstWeekContainsDate ?? t?.locale?.options?.firstWeekContainsDate ?? o.firstWeekContainsDate ?? o.locale?.options?.firstWeekContainsDate ?? 1, a = B(t?.in || e, 0); a.setFullYear(n + 1, 0, i), a.setHours(0, 0, 0, 0); const s = de(a, t), c = B(t?.in || e, 0); c.setFullYear(n, 0, i), c.setHours(0, 0, 0, 0); const u = de(c, t); return +r >= +s ? n + 1 : +r >= +u ? n : n - 1; } function xr(e, t) { const r = Me(), n = t?.firstWeekContainsDate ?? t?.locale?.options?.firstWeekContainsDate ?? r.firstWeekContainsDate ?? r.locale?.options?.firstWeekContainsDate ?? 1, o = Yt(e, t), i = B(t?.in || e, 0); return i.setFullYear(o, 0, n), i.setHours(0, 0, 0, 0), de(i, t); } function Ue(e, t) { const r = P(e, t?.in), n = +de(r, t) - +xr(r, t); return Math.round(n / kt) + 1; } function T(e, t) { const r = e < 0 ? "-" : "", n = Math.abs(e).toString().padStart(t, "0"); return r + n; } const se = { // Year y(e, t) { const r = e.getFullYear(), n = r > 0 ? r : 1 - r; return T(t === "yy" ? n % 100 : n, t.length); }, // Month M(e, t) { const r = e.getMonth(); return t === "M" ? String(r + 1) : T(r + 1, 2); }, // Day of the month d(e, t) { return T(e.getDate(), t.length); }, // AM or PM a(e, t) { const r = e.getHours() / 12 >= 1 ? "pm" : "am"; switch (t) { case "a": case "aa": return r.toUpperCase(); case "aaa": return r; case "aaaaa": return r[0]; default: return r === "am" ? "a.m." : "p.m."; } }, // Hour [1-12] h(e, t) { return T(e.getHours() % 12 || 12, t.length); }, // Hour [0-23] H(e, t) { return T(e.getHours(), t.length); }, // Minute m(e, t) { return T(e.getMinutes(), t.length); }, // Second s(e, t) { return T(e.getSeconds(), t.length); }, // Fraction of second S(e, t) { const r = t.length, n = e.getMilliseconds(), o = Math.trunc( n * Math.pow(10, r - 3) ); return T(o, t.length); } }, ue = { midnight: "midnight", noon: "noon", morning: "morning", afternoon: "afternoon", evening: "evening", night: "night" }, ft = { // Era G: function(e, t, r) { const n = e.getFullYear() > 0 ? 1 : 0; switch (t) { // AD, BC case "G": case "GG": case "GGG": return r.era(n, { width: "abbreviated" }); // A, B case "GGGGG": return r.era(n, { width: "narrow" }); default: return r.era(n, { width: "wide" }); } }, // Year y: function(e, t, r) { if (t === "yo") { const n = e.getFullYear(), o = n > 0 ? n : 1 - n; return r.ordinalNumber(o, { unit: "year" }); } return se.y(e, t); }, // Local week-numbering year Y: function(e, t, r, n) { const o = Yt(e, n), i = o > 0 ? o : 1 - o; if (t === "YY") { const a = i % 100; return T(a, 2); } return t === "Yo" ? r.ordinalNumber(i, { unit: "year" }) : T(i, t.length); }, // ISO week-numbering year R: function(e, t) { const r = vt(e); return T(r, t.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(e, t) { const r = e.getFullYear(); return T(r, t.length); }, // Quarter Q: function(e, t, r) { const n = Math.ceil((e.getMonth() + 1) / 3); switch (t) { // 1, 2, 3, 4 case "Q": return String(n); // 01, 02, 03, 04 case "QQ": return T(n, 2); // 1st, 2nd, 3rd, 4th case "Qo": return r.ordinalNumber(n, { unit: "quarter" }); // Q1, Q2, Q3, Q4 case "QQQ": return r.quarter(n, { width: "abbreviated", context: "formatting" }); // 1, 2, 3, 4 (narrow quarter; could be not numerical) case "QQQQQ": return r.quarter(n, { width: "narrow", context: "formatting" }); default: return r.quarter(n, { width: "wide", context: "formatting" }); } }, // Stand-alone quarter q: function(e, t, r) { const n = Math.ceil((e.getMonth() + 1) / 3); switch (t) { // 1, 2, 3, 4 case "q": return String(n); // 01, 02, 03, 04 case "qq": return T(n, 2); // 1st, 2nd, 3rd, 4th case "qo": return r.ordinalNumber(n, { unit: "quarter" }); // Q1, Q2, Q3, Q4 case "qqq": return r.quarter(n, { width: "abbreviated", context: "standalone" }); // 1, 2, 3, 4 (narrow quarter; could be not numerical) case "qqqqq": return r.quarter(n, { width: "narrow", context: "standalone" }); default: return r.quarter(n, { width: "wide", context: "standalone" }); } }, // Month M: function(e, t, r) { const n = e.getMonth(); switch (t) { case "M": case "MM": return se.M(e, t); // 1st, 2nd, ..., 12th case "Mo": return r.ordinalNumber(n + 1, { unit: "month" }); // Jan, Feb, ..., Dec case "MMM": return r.month(n, { width: "abbreviated", context: "formatting" }); // J, F, ..., D case "MMMMM": return r.month(n, { width: "narrow", context: "formatting" }); default: return r.month(n, { width: "wide", context: "formatting" }); } }, // Stand-alone month L: function(e, t, r) { const n = e.getMonth(); switch (t) { // 1, 2, ..., 12 case "L": return String(n + 1); // 01, 02, ..., 12 case "LL": return T(n + 1, 2); // 1st, 2nd, ..., 12th case "Lo": return r.ordinalNumber(n + 1, { unit: "month" }); // Jan, Feb, ..., Dec case "LLL": return r.month(n, { width: "abbreviated", context: "standalone" }); // J, F, ..., D case "LLLLL": return r.month(n, { width: "narrow", context: "standalone" }); default: return r.month(n, { width: "wide", context: "standalone" }); } }, // Local week of year w: function(e, t, r, n) { const o = Ue(e, n); return t === "wo" ? r.ordinalNumber(o, { unit: "week" }) : T(o, t.length); }, // ISO week of year I: function(e, t, r) { const n = Xe(e); return t === "Io" ? r.ordinalNumber(n, { unit: "week" }) : T(n, t.length); }, // Day of the month d: function(e, t, r) { return t === "do" ? r.ordinalNumber(e.getDate(), { unit: "date" }) : se.d(e, t); }, // Day of year D: function(e, t, r) { const n = Cr(e); return t === "Do" ? r.ordinalNumber(n, { unit: "dayOfYear" }) : T(n, t.length); }, // Day of week E: function(e, t, r) { const n = e.getDay(); switch (t) { // Tue case "E": case "EE": case "EEE": return r.day(n, { width: "abbreviated", context: "formatting" }); // T case "EEEEE": return r.day(n, { width: "narrow", context: "formatting" }); // Tu case "EEEEEE": return r.day(n, { width: "short", context: "formatting" }); default: return r.day(n, { width: "wide", context: "formatting" }); } }, // Local day of week e: function(e, t, r, n) { const o = e.getDay(), i = (o - n.weekStartsOn + 8) % 7 || 7; switch (t) { // Numerical value (Nth day of week with current locale or weekStartsOn) case "e": return String(i); // Padded numerical value case "ee": return T(i, 2); // 1st, 2nd, ..., 7th case "eo": return r.ordinalNumber(i, { unit: "day" }); case "eee": return r.day(o, { width: "abbreviated", context: "formatting" }); // T case "eeeee": return r.day(o, { width: "narrow", context: "formatting" }); // Tu case "eeeeee": return r.day(o, { width: "short", context: "formatting" }); default: return r.day(o, { width: "wide", context: "formatting" }); } }, // Stand-alone local day of week c: function(e, t, r, n) { const o = e.getDay(), i = (o - n.weekStartsOn + 8) % 7 || 7; switch (t) { // Numerical value (same as in `e`) case "c": return String(i); // Padded numerical value case "cc": return T(i, t.length); // 1st, 2nd, ..., 7th case "co": return r.ordinalNumber(i, { unit: "day" }); case "ccc": return r.day(o, { width: "abbreviated", context: "standalone" }); // T case "ccccc": return r.day(o, { width: "narrow", context: "standalone" }); // Tu case "cccccc": return r.day(o, { width: "short", context: "standalone" }); default: return r.day(o, { width: "wide", context: "standalone" }); } }, // ISO day of week i: function(e, t, r) { const n = e.getDay(), o = n === 0 ? 7 : n; switch (t) { // 2 case "i": return String(o); // 02 case "ii": return T(o, t.length); // 2nd case "io": return r.ordinalNumber(o, { unit: "day" }); // Tue case "iii": return r.day(n, { width: "abbreviated", context: "formatting" }); // T case "iiiii": return r.day(n, { width: "narrow", context: "formatting" }); // Tu case "iiiiii": return r.day(n, { width: "short", context: "formatting" }); default: return r.day(n, { width: "wide", context: "formatting" }); } }, // AM or PM a: function(e, t, r) { const o = e.getHours() / 12 >= 1 ? "pm" : "am"; switch (t) { case "a": case "aa": return r.dayPeriod(o, { width: "abbreviated", context: "formatting" }); case "aaa": return r.dayPeriod(o, { width: "abbreviated", context: "formatting" }).toLowerCase(); case "aaaaa": return r.dayPeriod(o, { width: "narrow", context: "formatting" }); default: return r.dayPeriod(o, { width: "wide", context: "formatting" }); } }, // AM, PM, midnight, noon b: function(e, t, r) { const n = e.getHours(); let o; switch (n === 12 ? o = ue.noon : n === 0 ? o = ue.midnight : o = n / 12 >= 1 ? "pm" : "am", t) { case "b": case "bb": return r.dayPeriod(o, { width: "abbreviated", context: "formatting" }); case "bbb": return r.dayPeriod(o, { width: "abbreviated", context: "formatting" }).toLowerCase(); case "bbbbb": return r.dayPeriod(o, { width: "narrow", context: "formatting" }); default: return r.dayPeriod(o, { width: "wide", context: "formatting" }); } }, // in the morning, in the afternoon, in the evening, at night B: function(e, t, r) { const n = e.getHours(); let o; switch (n >= 17 ? o = ue.evening : n >= 12 ? o = ue.afternoon : n >= 4 ? o = ue.morning : o = ue.night, t) { case "B": case "BB": case "BBB": return r.dayPeriod(o, { width: "abbreviated", context: "formatting" }); case "BBBBB": return r.dayPeriod(o, { width: "narrow", context: "formatting" }); default: return r.dayPeriod(o, { width: "wide", context: "formatting" }); } }, // Hour [1-12] h: function(e, t, r) { if (t === "ho") { let n = e.getHours() % 12; return n === 0 && (n = 12), r.ordinalNumber(n, { unit: "hour" }); } return se.h(e, t); }, // Hour [0-23] H: function(e, t, r) { return t === "Ho" ? r.ordinalNumber(e.getHours(), { unit: "hour" }) : se.H(e, t); }, // Hour [0-11] K: function(e, t, r) { const n = e.getHours() % 12; return t === "Ko" ? r.ordinalNumber(n, { unit: "hour" }) : T(n, t.length); }, // Hour [1-24] k: function(e, t, r) { let n = e.getHours(); return n === 0 && (n = 24), t === "ko" ? r.ordinalNumber(n, { unit: "hour" }) : T(n, t.length); }, // Minute m: function(e, t, r) { return t === "mo" ? r.ordinalNumber(e.getMinutes(), { unit: "minute" }) : se.m(e, t); }, // Second s: function(e, t, r) { return t === "so" ? r.ordinalNumber(e.getSeconds(), { unit: "second" }) : se.s(e, t); }, // Fraction of second S: function(e, t) { return se.S(e, t); }, // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) X: function(e, t, r) { const n = e.getTimezoneOffset(); if (n === 0) return "Z"; switch (t) { // Hours and optional minutes case "X": return ht(n); // 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 ae(n); // Hours and minutes with `:` delimiter default: return ae(n, ":"); } }, // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) x: function(e, t, r) { const n = e.getTimezoneOffset(); switch (t) { // Hours and optional minutes case "x": return ht(n); // 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 ae(n); // Hours and minutes with `:` delimiter default: return ae(n, ":"); } }, // Timezone (GMT) O: function(e, t, r) { const n = e.getTimezoneOffset(); switch (t) { // Short case "O": case "OO": case "OOO": return "GMT" + dt(n, ":"); default: return "GMT" + ae(n, ":"); } }, // Timezone (specific non-location) z: function(e, t, r) { const n = e.getTimezoneOffset(); switch (t) { // Short case "z": case "zz": case "zzz": return "GMT" + dt(n, ":"); default: return "GMT" + ae(n, ":"); } }, // Seconds timestamp t: function(e, t, r) { const n = Math.trunc(+e / 1e3); return T(n, t.length); }, // Milliseconds timestamp T: function(e, t, r) { return T(+e, t.length); } }; function dt(e, t = "") { const r = e > 0 ? "-" : "+", n = Math.abs(e), o = Math.trunc(n / 60), i = n % 60; return i === 0 ? r + String(o) : r + String(o) + t + T(i, 2); } function ht(e, t) { return e % 60 === 0 ? (e > 0 ? "-" : "+") + T(Math.abs(e) / 60, 2) : ae(e, t); } function ae(e, t = "") { const r = e > 0 ? "-" : "+", n = Math.abs(e), o = T(Math.trunc(n / 60), 2), i = T(n % 60, 2); return r + o + t + i; } const mt = (e, t) => { switch (e) { case "P": return t.date({ width: "short" }); case "PP": return t.date({ width: "medium" }); case "PPP": return t.date({ width: "long" }); default: return t.date({ width: "full" }); } }, Tt = (e, t) => { switch (e) { case "p": return t.time({ width: "short" }); case "pp": return t.time({ width: "medium" }); case "ppp": return t.time({ width: "long" }); default: return t.time({ width: "full" }); } }, Yr = (e, t) => { const r = e.match(/(P+)(p+)?/) || [], n = r[1], o = r[2]; if (!o) return mt(e, t); let i; switch (n) { case "P": i = t.dateTime({ width: "short" }); break; case "PP": i = t.dateTime({ width: "medium" }); break; case "PPP": i = t.dateTime({ width: "long" }); break; default: i = t.dateTime({ width: "full" }); break; } return i.replace("{{date}}", mt(n, t)).replace("{{time}}", Tt(o, t)); }, Tr = { p: Tt, P: Yr }, Pr = /^D+$/, Er = /^Y+$/, _r = ["D", "DD", "YY", "YYYY"]; function Fr(e) { return Pr.test(e); } function Br(e) { return Er.test(e); } function Ir(e, t, r) { const n = Hr(e, t, r); if (console.warn(n), _r.includes(e)) throw new RangeError(n); } function Hr(e, t, r) { const n = e[0] === "Y" ? "years" : "days of the month"; return `Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`; } const Ar = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, qr = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, jr = /^'([^]*?)'?$/, Gr = /''/g, $r = /[a-zA-Z]/; function be(e, t, r) { const n = Me(), o = r?.locale ?? n.locale ?? fe, i = r?.firstWeekContainsDate ?? r?.locale?.options?.firstWeekContainsDate ?? n.firstWeekContainsDate ?? n.locale?.options?.firstWeekContainsDate ?? 1, a = r?.weekStartsOn ?? r?.locale?.options?.weekStartsOn ?? n.weekStartsOn ?? n.locale?.options?.weekStartsOn ?? 0, s = P(e, r?.in); if (!$n(s)) throw new RangeError("Invalid time value"); let c = t.match(qr).map((f) => { const l = f[0]; if (l === "p" || l === "P") { const d = Tr[l]; return d(f, o.formatLong); } return f; }).join("").match(Ar).map((f) => { if (f === "''") return { isToken: !1, value: "'" }; const l = f[0]; if (l === "'") return { isToken: !1, value: Rr(f) }; if (ft[l]) return { isToken: !0, value: f }; if (l.match($r)) throw new RangeError( "Format string contains an unescaped latin alphabet character `" + l + "`" ); return { isToken: !1, value: f }; }); o.localize.preprocessor && (c = o.localize.preprocessor(s, c)); const u = { firstWeekContainsDate: i, weekStartsOn: a, locale: o }; return c.map((f) => { if (!f.isToken) return f.value; const l = f.value; (!r?.useAdditionalWeekYearTokens && Br(l) || !r?.useAdditionalDayOfYearTokens && Fr(l)) && Ir(l, t, String(e)); const d = ft[l[0]]; return d(s, l, o.localize, u); }).join(""); } function Rr(e) { const t = e.match(jr); return t ? t[1].replace(Gr, "'") : e; } function zr(e, t) { const r = P(e, t?.in), n = r.getFullYear(), o = r.getMonth(), i = B(r, 0); return i.setFullYear(n, o + 1, 0), i.setHours(0, 0, 0, 0), i.getDate(); } function Qr(e, t) { return P(e, t?.in).getMonth(); } function Vr(e, t) { return P(e, t?.in).getFullYear(); } function Xr(e, t) { return +P(e) > +P(t); } function Ur(e, t) { return +P(e) < +P(t); } function Zr(e, t, r) { const [n, o] = he( r?.in, e, t ); return n.getFullYear() === o.getFullYear() && n.getMonth() === o.getMonth(); } function Kr(e, t, r) { const [n, o] = he( r?.in, e, t ); return n.getFullYear() === o.getFullYear(); } function Jr(e, t, r) { const n = P(e, r?.in), o = n.getFullYear(), i = n.getDate(), a = B(e, 0); a.setFullYear(o, t, 15), a.setHours(0, 0, 0, 0); const s = zr(a); return n.setMonth(t, Math.min(i, s)), n; } function Lr(e, t, r) { const n = P(e, r?.in); return isNaN(+n) ? B(e, NaN) : (n.setFullYear(t), n); } const yt = 5, eo = 4; function to(e, t) { const r = t.startOfMonth(e), n = r.getDay() > 0 ? r.getDay() : 7, o = t.addDays(e, -n + 1), i = t.addDays(o, yt * 7 - 1); return t.getMonth(e) === t.getMonth(i) ? yt : eo; } function Pt(e, t) { const r = t.startOfMonth(e), n = r.getDay(); return n === 1 ? r : n === 0 ? t.addDays(r, -6) : t.addDays(r, -1 * (n - 1)); } function no(e, t) { const r = Pt(e, t), n = to(e, t); return t.addDays(r, n * 7 - 1); } const Et = { ...fe, labels: { labelDayButton: (e, t, r, n) => { let o; n && typeof n.format == "function" ? o = n.format.bind(n) : o = (a, s) => be(a, s, { locale: fe, ...r }); let i = o(e, "PPPP"); return t.today && (i = `Today, ${i}`), t.selected && (i = `${i}, selected`), i; }, labelMonthDropdown: "Choose the Month", labelNext: "Go to the Next Month", labelPrevious: "Go to the Previous Month", labelWeekNumber: (e) => `Week ${e}`, labelYearDropdown: "Choose the Year", labelGrid: (e, t, r) => { let n; return r && typeof r.format == "function" ? n = r.format.bind(r) : n = (o, i) => be(o, i, { locale: fe, ...t }), n(e, "LLLL yyyy"); }, labelGridcell: (e, t, r, n) => { let o; n && typeof n.format == "function" ? o = n.format.bind(n) : o = (a, s) => be(a, s, { locale: fe, ...r }); let i = o(e, "PPPP"); return t?.today && (i = `Today, ${i}`), i; }, labelNav: "Navigation bar", labelWeekNumberHeader: "Week Number", labelWeekday: (e, t, r) => { let n; return r && typeof r.format == "function" ? n = r.format.bind(r) : n = (o, i) => be(o, i, { locale: fe, ...t }), n(e, "cccc"); } } }; class G { /** * Creates an instance of `DateLib`. * * @param options Configuration options for the date library. * @param overrides Custom overrides for the date library functions. */ constructor(t, r) { this.Date = Date, this.today = () => this.overrides?.today ? this.overrides.today() : this.options.timeZone ? H.tz(this.options.timeZone) : new this.Date(), this.newDate = (n, o, i) => this.overrides?.newDate ? this.overrides.newDate(n, o, i) : this.options.timeZone ? new H(n, o, i, this.options.timeZone) : new Date(n, o, i), this.addDays = (n, o) => this.overrides?.addDays ? this.overrides.addDays(n, o) : Dt(n, o), this.addMonths = (n, o) => this.overrides?.addMonths ? this.overrides.addMonths(n, o) : Ot(n, o), this.addWeeks = (n, o) => this.overrides?.addWeeks ? this.overrides.addWeeks(n, o) : Hn(n, o), this.addYears = (n, o) => this.overrides?.addYears ? this.overrides.addYears(n, o) : An(n, o), this.differenceInCalendarDays = (n, o) => this.overrides?.differenceInCalendarDays ? this.overrides.differenceInCalendarDays(n, o) : Ve(n, o), this.differenceInCalendarMonths = (n, o) => this.overrides?.differenceInCalendarMonths ? this.overrides.differenceInCalendarMonths(n, o) : St(n, o), this.eachMonthOfInterval = (n) => this.overrides?.eachMonthOfInterval ? this.overrides.eachMonthOfInterval(n) : zn(n), this.eachYearOfInterval = (n) => { const o = this.overrides?.eachYearOfInterval ? this.overrides.eachYearOfInterval(n) : Xn(n), i = new Set(o.map((s) => this.getYear(s))); if (i.size === o.length) return o; const a = []; return i.forEach((s) => { a.push(new Date(s, 0, 1)); }), a; }, this.endOfBroadcastWeek = (n) => this.overrides?.endOfBroadcastWeek ? this.overrides.endOfBroadcastWeek(n) : no(n, this), this.endOfISOWeek = (n) => this.overrides?.endOfISOWeek ? this.overrides.endOfISOWeek(n) : Un(n), this.endOfMonth = (n) => this.overrides?.endOfMonth ? this.overrides.endOfMonth(n) : Rn(n), this.endOfWeek = (n, o) => this.overrides?.endOfWeek ? this.overrides.endOfWeek(n, o) : xt(n, this.options), this.endOfYear = (n) => this.overrides?.endOfYear ? this.overrides.endOfYear(n) : Vn(n), this.format = (n, o, i) => { const a = this.overrides?.format ? this.overrides.format(n, o, this.options) : be(n, o, this.options); return this.options.numerals && this.options.numerals !== "latn" ? this.replaceDigits(a) : a; }, this.getISOWeek = (n) => this.overrides?.getISOWeek ? this.overrides.getISOWeek(n) : Xe(n), this.getMonth = (n, o) => this.overrides?.getMonth ? this.overrides.getMonth(n, this.options) : Qr(n, this.options), this.getYear = (n, o) => this.overrides?.getYear ? this.overrides.getYear(n, this.options) : Vr(n, this.options), this.getWeek = (n, o) => this.overrides?.getWeek ? this.overrides.getWeek(n, this.options) : Ue(n, this.options), this.isAfter = (n, o) => this.overrides?.isAfter ? this.overrides.isAfter(n, o) : Xr(n, o), this.isBefore = (n, o) => this.overrides?.isBefore ? this.overrides.isBefore(n, o) : Ur(n, o), this.isDate = (n) => this.overrides?.isDate ? this.overrides.isDate(n) : Wt(n), this.isSameDay = (n, o) => this.overrides?.isSameDay ? this.overrides.isSameDay(n, o) : Gn(n, o), this.isSameMonth = (n, o) => this.overrides?.isSameMonth ? this.overrides.isSameMonth(n, o) : Zr(n, o), this.isSameYear = (n, o) => this.overrides?.isSameYear ? this.overrides.isSameYear(n, o) : Kr(n, o), this.max = (n) => this.overrides?.max ? this.overrides.max(n) : qn(n), this.min = (n) => this.overrides?.min ? this.overrides.min(n) : jn(n), this.setMonth = (n, o) => this.overrides?.setMonth ? this.overrides.setMonth(n, o) : Jr(n, o), this.setYear = (n, o) => this.overrides?.setYear ? this.overrides.setYear(n, o) : Lr(n, o), this.startOfBroadcastWeek = (n, o) => this.overrides?.startOfBroadcastWeek ? this.overrides.startOfBroadcastWeek(n, this) : Pt(n, this), this.startOfDay = (n) => this.overrides?.startOfDay ? this.overrides.startOfDay(n) : pe(n), this.startOfISOWeek = (n) => this.overrides?.startOfISOWeek ? this.overrides.startOfISOWeek(n) : we(n), this.startOfMonth = (n) => this.overrides?.startOfMonth ? this.overrides.startOfMonth(n) : Qn(n), this.startOfWeek = (n, o) => this.overrides?.startOfWeek ? this.overrides.startOfWeek(n, this.options) : de(n, this.options), this.startOfYear = (n) => this.overrides?.startOfYear ? this.overrides.startOfYear(n) : Ct(n), this.options = { locale: Et, ...t }, this.overrides = r; } /** * Generates a mapping of Arabic digits (0-9) to the target numbering system * digits. * * @since 9.5.0 * @returns A record mapping Arabic digits to the target numerals. */ getDigitMap() { const { numerals: t = "latn" } = this.options, r = new Intl.NumberFormat("en-US", { numberingSystem: t }), n = {}; for (let o = 0; o < 10; o++) n[o.toString()] = r.format(o); return n; } /** * Replaces Arabic digits in a string with the target numbering system digits. * * @since 9.5.0 * @param input The string containing Arabic digits. * @returns The string with digits replaced. */ replaceDigits(t) { const r = this.getDigitMap(); return t.replace(/\d/g, (n) => r[n] || n); } /** * Formats a number using the configured numbering system. * * @since 9.5.0 * @param value The number to format. * @returns The formatted number as a string. */ formatNumber(t) { return this.replaceDigits(t.toString()); } /** * Returns the preferred ordering for month and year labels for the current * locale. */ getMonthYearOrder() { const t = this.options.locale?.code; return t && G.yearFirstLocales.has(t) ? "year-first" : "month-first"; } /** * Formats the month/year pair respecting locale conventions. * * @since 9.11.0 */ formatMonthYear(t) { const { locale: r, timeZone: n, numerals: o } = this.options, i = r?.code; if (i && G.yearFirstLocales.has(i)) try { return new Intl.DateTimeFormat(i, { month: "long", year: "numeric", timeZone: n, numberingSystem: o }).format(t); } catch { } const a = this.getMonthYearOrder() === "year-first" ? "y LLLL" : "LLLL y"; return this.format(t, a); } } G.yearFirstLocales = /* @__PURE__ */ new Set([ "eu", "hu", "ja", "ja-Hira", "ja-JP", "ko", "ko-KR", "lt", "lt-LT", "lv", "lv-LV", "mn", "mn-MN", "zh", "zh-CN", "zh-HK", "zh-TW" ]); const L = new G(); class _t { constructor(t, r, n = L) { this.date = t, this.displayMonth = r, this.outside = !!(r && !n.isSameMonth(t, r)), this.dateLib = n, this.isoDate = n.format(t, "yyyy-MM-dd"), this.displayMonthId = n.format(r, "yyyy-MM"), this.dateMonthId = n.format(t, "yyyy-MM"); } /** * Checks if this day is equal to another `CalendarDay`, considering both the * date and the displayed month. * * @param day The `CalendarDay` to compare with. * @returns `true` if the days are equal, otherwise `false`. */ isEqualTo(t) { return this.dateLib.isSameDay(t.date, this.date) && this.dateLib.isSameMonth(t.displayMonth, this.displayMonth); } } class ro { constructor(t, r) { this.date = t, this.weeks = r; } } class oo { constructor(t, r) { this.days = r, this.weekNum