@anoki/fse-ui
Version:
FSE UI components library
204 lines (203 loc) • 5.23 kB
JavaScript
import { signedOffset as E, parseMillis as F, parseFloating as l, parseInteger as f, untruncateYear as w, isUndefined as Y } from "./index.es231.js";
import { weekdaysLong as v, weekdaysShort as z, monthsShort as P } from "./index.es275.js";
import y from "./index.es229.js";
import q from "./index.es239.js";
const W = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
function x(...e) {
const t = e.reduce((n, r) => n + r.source, "");
return RegExp(`^${t}$`);
}
function m(...e) {
return (t) => e.reduce(
([n, r, o], i) => {
const [d, s, c] = i(t, o);
return [{ ...n, ...d }, s || r, c];
},
[{}, null, 1]
).slice(0, 2);
}
function T(e, ...t) {
if (e == null)
return [null, null];
for (const [n, r] of t) {
const o = n.exec(e);
if (o)
return r(o);
}
return [null, null];
}
function b(...e) {
return (t, n) => {
const r = {};
let o;
for (o = 0; o < e.length; o++)
r[e[o]] = f(t[n + o]);
return [r, null, n + o];
};
}
const J = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/, G = `(?:${J.source}?(?:\\[(${W.source})\\])?)?`, M = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/, k = RegExp(`${M.source}${G}`), h = RegExp(`(?:T${k.source})?`), H = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/, _ = /(\d{4})-?W(\d\d)(?:-?(\d))?/, L = /(\d{4})-?(\d{3})/, U = b("weekYear", "weekNumber", "weekDay"), B = b("year", "ordinal"), Q = /(\d{4})-(\d\d)-(\d\d)/, C = RegExp(
`${M.source} ?(?:${J.source}|(${W.source}))?`
), j = RegExp(`(?: ${C.source})?`);
function S(e, t, n) {
const r = e[t];
return Y(r) ? n : f(r);
}
function K(e, t) {
return [{
year: S(e, t),
month: S(e, t + 1, 1),
day: S(e, t + 2, 1)
}, null, t + 3];
}
function g(e, t) {
return [{
hours: S(e, t, 0),
minutes: S(e, t + 1, 0),
seconds: S(e, t + 2, 0),
milliseconds: F(e[t + 3])
}, null, t + 4];
}
function O(e, t) {
const n = !e[t] && !e[t + 1], r = E(e[t + 1], e[t + 2]), o = n ? null : y.instance(r);
return [{}, o, t + 3];
}
function p(e, t) {
const n = e[t] ? q.create(e[t]) : null;
return [{}, n, t + 1];
}
const V = RegExp(`^T?${M.source}$`), X = /^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;
function ee(e) {
const [t, n, r, o, i, d, s, c, R] = e, A = t[0] === "-", I = c && c[0] === "-", u = (a, Z = !1) => a !== void 0 && (Z || a && A) ? -a : a;
return [
{
years: u(l(n)),
months: u(l(r)),
weeks: u(l(o)),
days: u(l(i)),
hours: u(l(d)),
minutes: u(l(s)),
seconds: u(l(c), c === "-0"),
milliseconds: u(F(R), I)
}
];
}
const te = {
GMT: 0,
EDT: -4 * 60,
EST: -5 * 60,
CDT: -5 * 60,
CST: -6 * 60,
MDT: -6 * 60,
MST: -7 * 60,
PDT: -7 * 60,
PST: -8 * 60
};
function D(e, t, n, r, o, i, d) {
const s = {
year: t.length === 2 ? w(f(t)) : f(t),
month: P.indexOf(n) + 1,
day: f(r),
hour: f(o),
minute: f(i)
};
return d && (s.second = f(d)), e && (s.weekday = e.length > 3 ? v.indexOf(e) + 1 : z.indexOf(e) + 1), s;
}
const ne = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;
function re(e) {
const [
,
t,
n,
r,
o,
i,
d,
s,
c,
R,
A,
I
] = e, u = D(t, o, r, n, i, d, s);
let a;
return c ? a = te[c] : R ? a = 0 : a = E(A, I), [u, new y(a)];
}
function oe(e) {
return e.replace(/\([^()]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
}
const se = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/, de = /^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/, ie = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
function $(e) {
const [, t, n, r, o, i, d, s] = e;
return [D(t, o, r, n, i, d, s), y.utcInstance];
}
function ce(e) {
const [, t, n, r, o, i, d, s] = e;
return [D(t, s, n, r, o, i, d), y.utcInstance];
}
const ue = x(H, h), ae = x(_, h), fe = x(L, h), le = x(k), N = m(
K,
g,
O,
p
), Se = m(
U,
g,
O,
p
), xe = m(
B,
g,
O,
p
), me = m(
g,
O,
p
);
function Me(e) {
return T(
e,
[ue, N],
[ae, Se],
[fe, xe],
[le, me]
);
}
function he(e) {
return T(oe(e), [ne, re]);
}
function De(e) {
return T(
e,
[se, $],
[de, $],
[ie, ce]
);
}
function $e(e) {
return T(e, [X, ee]);
}
const Te = m(g);
function Ee(e) {
return T(e, [V, Te]);
}
const ge = x(Q, j), Oe = x(C), pe = m(
g,
O,
p
);
function Fe(e) {
return T(
e,
[ge, N],
[Oe, pe]
);
}
export {
De as parseHTTPDate,
Me as parseISODate,
$e as parseISODuration,
Ee as parseISOTimeOnly,
he as parseRFC2822Date,
Fe as parseSQL
};
//# sourceMappingURL=index.es5.js.map