@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
1,361 lines (1,358 loc) • 54.8 kB
JavaScript
import * as l from "react";
function S(e, t) {
if (e === !1 || e === null || typeof e > "u") throw new Error(t);
}
function C(e, t) {
if (!e) {
typeof console < "u" && console.warn(t);
try {
throw new Error(t);
} catch {
}
}
}
function ie({ pathname: e = "/", search: t = "", hash: r = "" }) {
return t && t !== "?" && (e += t.charAt(0) === "?" ? t : "?" + t), r && r !== "#" && (e += r.charAt(0) === "#" ? r : "#" + r), e;
}
function W(e) {
let t = {};
if (e) {
let r = e.indexOf("#");
r >= 0 && (t.hash = e.substring(r), e = e.substring(0, r));
let n = e.indexOf("?");
n >= 0 && (t.search = e.substring(n), e = e.substring(0, n)), e && (t.pathname = e);
}
return t;
}
var qe;
qe = /* @__PURE__ */ new WeakMap();
function de(e, t, r = "/") {
return Xe(e, t, r, !1);
}
function Xe(e, t, r, n) {
let a = _((typeof t == "string" ? W(t) : t).pathname || "/", r);
if (a == null) return null;
let o = $e(e);
Qe(o);
let i = null;
for (let s = 0; i == null && s < o.length; ++s) {
let u = ut(a);
i = it(o[s], u, n);
}
return i;
}
function Ke(e, t) {
let { route: r, pathname: n, params: a } = e;
return {
id: r.id,
pathname: n,
params: a,
data: t[r.id],
loaderData: t[r.id],
handle: r.handle
};
}
function $e(e, t = [], r = [], n = "", a = !1) {
let o = (i, s, u = a, c) => {
let f = {
relativePath: c === void 0 ? i.path || "" : c,
caseSensitive: i.caseSensitive === !0,
childrenIndex: s,
route: i
};
if (f.relativePath.startsWith("/")) {
if (!f.relativePath.startsWith(n) && u) return;
S(f.relativePath.startsWith(n), `Absolute route path "${f.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`), f.relativePath = f.relativePath.slice(n.length);
}
let d = k([n, f.relativePath]), h = r.concat(f);
i.children && i.children.length > 0 && (S(i.index !== !0, `Index routes must not have child routes. Please remove all child routes from route path "${d}".`), $e(i.children, t, h, d, u)), !(i.path == null && !i.index) && t.push({
path: d,
score: ot(d, i.index),
routesMeta: h
});
};
return e.forEach((i, s) => {
if (i.path === "" || !i.path?.includes("?")) o(i, s);
else for (let u of Pe(i.path)) o(i, s, !0, u);
}), t;
}
function Pe(e) {
let t = e.split("/");
if (t.length === 0) return [];
let [r, ...n] = t, a = r.endsWith("?"), o = r.replace(/\?$/, "");
if (n.length === 0) return a ? [o, ""] : [o];
let i = Pe(n.join("/")), s = [];
return s.push(...i.map((u) => u === "" ? o : [o, u].join("/"))), a && s.push(...i), s.map((u) => e.startsWith("/") && u === "" ? "/" : u);
}
function Qe(e) {
e.sort((t, r) => t.score !== r.score ? r.score - t.score : lt(t.routesMeta.map((n) => n.childrenIndex), r.routesMeta.map((n) => n.childrenIndex)));
}
var Ze = /^:[\w-]+$/, et = 3, tt = 2, rt = 1, nt = 10, at = -2, Re = (e) => e === "*";
function ot(e, t) {
let r = e.split("/"), n = r.length;
return r.some(Re) && (n += at), t && (n += tt), r.filter((a) => !Re(a)).reduce((a, o) => a + (Ze.test(o) ? et : o === "" ? rt : nt), n);
}
function lt(e, t) {
return e.length === t.length && e.slice(0, -1).every((r, n) => r === t[n]) ? e[e.length - 1] - t[t.length - 1] : 0;
}
function it(e, t, r = !1) {
let { routesMeta: n } = e, a = {}, o = "/", i = [];
for (let s = 0; s < n.length; ++s) {
let u = n[s], c = s === n.length - 1, f = o === "/" ? t : t.slice(o.length) || "/", d = K({
path: u.relativePath,
caseSensitive: u.caseSensitive,
end: c
}, f), h = u.route;
if (!d && c && r && !n[n.length - 1].route.index && (d = K({
path: u.relativePath,
caseSensitive: u.caseSensitive,
end: !1
}, f)), !d) return null;
Object.assign(a, d.params), i.push({
params: a,
pathname: k([o, d.pathname]),
pathnameBase: mt(k([o, d.pathnameBase])),
route: h
}), d.pathnameBase !== "/" && (o = k([o, d.pathnameBase]));
}
return i;
}
function K(e, t) {
typeof e == "string" && (e = {
path: e,
caseSensitive: !1,
end: !0
});
let [r, n] = st(e.path, e.caseSensitive, e.end), a = t.match(r);
if (!a) return null;
let o = a[0], i = o.replace(/(.)\/+$/, "$1"), s = a.slice(1);
return {
params: n.reduce((u, { paramName: c, isOptional: f }, d) => {
if (c === "*") {
let y = s[d] || "";
i = o.slice(0, o.length - y.length).replace(/(.)\/+$/, "$1");
}
const h = s[d];
return f && !h ? u[c] = void 0 : u[c] = (h || "").replace(/%2F/g, "/"), u;
}, {}),
pathname: o,
pathnameBase: i,
pattern: e
};
}
function st(e, t = !1, r = !0) {
C(e === "*" || !e.endsWith("*") || e.endsWith("/*"), `Route path "${e}" will be treated as if it were "${e.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/, "/*")}".`);
let n = [], a = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (o, i, s, u, c) => {
if (n.push({
paramName: i,
isOptional: s != null
}), s) {
let f = c.charAt(u + o.length);
return f && f !== "/" ? "/([^\\/]*)" : "(?:/([^\\/]*))?";
}
return "/([^\\/]+)";
}).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
return e.endsWith("*") ? (n.push({ paramName: "*" }), a += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : r ? a += "\\/*$" : e !== "" && e !== "/" && (a += "(?:(?=\\/|$))"), [new RegExp(a, t ? void 0 : "i"), n];
}
function ut(e) {
try {
return e.split("/").map((t) => decodeURIComponent(t).replace(/\//g, "%2F")).join("/");
} catch (t) {
return C(!1, `The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`), e;
}
}
function _(e, t) {
if (t === "/") return e;
if (!e.toLowerCase().startsWith(t.toLowerCase())) return null;
let r = t.endsWith("/") ? t.length - 1 : t.length, n = e.charAt(r);
return n && n !== "/" ? null : e.slice(r) || "/";
}
var ct = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
function dt(e, t = "/") {
let { pathname: r, search: n = "", hash: a = "" } = typeof e == "string" ? W(e) : e, o;
return r ? (r = ke(r), r.startsWith("/") ? o = we(r.substring(1), "/") : o = we(r, t)) : o = t, {
pathname: o,
search: ht(n),
hash: pt(a)
};
}
function we(e, t) {
let r = Q(t).split("/");
return e.split("/").forEach((n) => {
n === ".." ? r.length > 1 && r.pop() : n !== "." && r.push(n);
}), r.length > 1 ? r.join("/") : "/";
}
function ae(e, t, r, n) {
return `Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
}
function ft(e) {
return e.filter((t, r) => r === 0 || t.route.path && t.route.path.length > 0);
}
function Le(e) {
let t = ft(e);
return t.map((r, n) => n === t.length - 1 ? r.pathname : r.pathnameBase);
}
function fe(e, t, r, n = !1) {
let a;
typeof e == "string" ? a = W(e) : (a = { ...e }, S(!a.pathname || !a.pathname.includes("?"), ae("?", "pathname", "search", a)), S(!a.pathname || !a.pathname.includes("#"), ae("#", "pathname", "hash", a)), S(!a.search || !a.search.includes("#"), ae("#", "search", "hash", a)));
let o = e === "" || a.pathname === "", i = o ? "/" : a.pathname, s;
if (i == null) s = r;
else {
let d = t.length - 1;
if (!n && i.startsWith("..")) {
let h = i.split("/");
for (; h[0] === ".."; )
h.shift(), d -= 1;
a.pathname = h.join("/");
}
s = d >= 0 ? t[d] : "/";
}
let u = dt(a, s), c = i && i !== "/" && i.endsWith("/"), f = (o || i === ".") && r.endsWith("/");
return !u.pathname.endsWith("/") && (c || f) && (u.pathname += "/"), u;
}
var ke = (e) => e.replace(/\/\/+/g, "/"), k = (e) => ke(e.join("/")), Q = (e) => e.replace(/\/+$/, ""), mt = (e) => Q(e).replace(/^\/*/, "/"), ht = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, pt = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e, yt = class {
constructor(e, t, r, n = !1) {
this.status = e, this.statusText = t || "", this.internal = n, r instanceof Error ? (this.data = r.toString(), this.error = r) : this.data = r;
}
};
function _e(e) {
return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e;
}
function gt(e) {
return k(e.map((t) => t.route.path).filter(Boolean)) || "/";
}
var Oe = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
function Te(e, t) {
let r = e;
if (typeof r != "string" || !ct.test(r)) return {
absoluteURL: void 0,
isExternal: !1,
to: r
};
let n = r, a = !1;
if (Oe) try {
let o = new URL(window.location.href), i = r.startsWith("//") ? new URL(o.protocol + r) : new URL(r), s = _(i.pathname, t);
i.origin === o.origin && s != null ? r = s + i.search + i.hash : a = !0;
} catch {
C(!1, `<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`);
}
return {
absoluteURL: n,
isExternal: a,
to: r
};
}
var Tr = Object.getOwnPropertyNames(Object.prototype).sort().join("\0"), Me = [
"POST",
"PUT",
"PATCH",
"DELETE"
], Mr = new Set(Me), vt = ["GET", ...Me], Nr = new Set(vt), F = l.createContext(null);
F.displayName = "DataRouter";
var B = l.createContext(null);
B.displayName = "DataRouterState";
var Ne = l.createContext(!1);
function Ie() {
return l.useContext(Ne);
}
var De = l.createContext({ isTransitioning: !1 });
De.displayName = "ViewTransition";
var Rt = l.createContext(/* @__PURE__ */ new Map());
Rt.displayName = "Fetchers";
var se = l.createContext(null);
se.displayName = "Await";
var b = l.createContext(null);
b.displayName = "Navigation";
var U = l.createContext(null);
U.displayName = "Location";
var T = l.createContext({
outlet: null,
matches: [],
isDataRoute: !1
});
T.displayName = "Route";
var me = l.createContext(null);
me.displayName = "RouteError";
var Fe = "REACT_ROUTER_ERROR", wt = "REDIRECT", Et = "ROUTE_ERROR_RESPONSE";
function St(e) {
if (e.startsWith(`${Fe}:${wt}:{`)) try {
let t = JSON.parse(e.slice(28));
if (typeof t == "object" && t && typeof t.status == "number" && typeof t.statusText == "string" && typeof t.location == "string" && typeof t.reloadDocument == "boolean" && typeof t.replace == "boolean") return t;
} catch {
}
}
function bt(e) {
if (e.startsWith(`${Fe}:${Et}:{`)) try {
let t = JSON.parse(e.slice(40));
if (typeof t == "object" && t && typeof t.status == "number" && typeof t.statusText == "string") return new yt(t.status, t.statusText, t.data);
} catch {
}
}
function xt(e, { relative: t } = {}) {
S(j(), "useHref() may be used only in the context of a <Router> component.");
let { basename: r, navigator: n } = l.useContext(b), { hash: a, pathname: o, search: i } = J(e, { relative: t }), s = o;
return r !== "/" && (s = o === "/" ? r : k([r, o])), n.createHref({
pathname: s,
search: i,
hash: a
});
}
function j() {
return l.useContext(U) != null;
}
function $() {
return S(j(), "useLocation() may be used only in the context of a <Router> component."), l.useContext(U).location;
}
var Ae = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
function He(e) {
l.useContext(b).static || l.useLayoutEffect(e);
}
function Ct() {
let { isDataRoute: e } = l.useContext(T);
return e ? At() : $t();
}
function $t() {
S(j(), "useNavigate() may be used only in the context of a <Router> component.");
let e = l.useContext(F), { basename: t, navigator: r } = l.useContext(b), { matches: n } = l.useContext(T), { pathname: a } = $(), o = JSON.stringify(Le(n)), i = l.useRef(!1);
return He(() => {
i.current = !0;
}), l.useCallback((s, u = {}) => {
if (C(i.current, Ae), !i.current) return;
if (typeof s == "number") {
r.go(s);
return;
}
let c = fe(s, JSON.parse(o), a, u.relative === "path");
e == null && t !== "/" && (c.pathname = c.pathname === "/" ? t : k([t, c.pathname])), (u.replace ? r.replace : r.push)(c, u.state, u);
}, [
t,
r,
o,
a,
e
]);
}
var Ir = l.createContext(null);
function J(e, { relative: t } = {}) {
let { matches: r } = l.useContext(T), { pathname: n } = $(), a = JSON.stringify(Le(r));
return l.useMemo(() => fe(e, JSON.parse(a), n, t === "path"), [
e,
a,
n,
t
]);
}
function Pt(e, t, r) {
S(j(), "useRoutes() may be used only in the context of a <Router> component.");
let { navigator: n } = l.useContext(b), { matches: a } = l.useContext(T), o = a[a.length - 1], i = o ? o.params : {}, s = o ? o.pathname : "/", u = o ? o.pathnameBase : "/", c = o && o.route;
{
let m = c && c.path || "";
Ue(s, !c || m.endsWith("*") || m.endsWith("*?"), `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${m}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
Please change the parent <Route path="${m}"> to <Route path="${m === "/" ? "*" : `${m}/*`}">.`);
}
let f = $(), d;
if (t) {
let m = typeof t == "string" ? W(t) : t;
S(u === "/" || m.pathname?.startsWith(u), `When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${m.pathname}" was given in the \`location\` prop.`), d = m;
} else d = f;
let h = d.pathname || "/", y = h;
if (u !== "/") {
let m = u.replace(/^\//, "").split("/");
y = "/" + h.replace(/^\//, "").split("/").slice(m.length).join("/");
}
let g = de(e, { pathname: y });
C(c || g != null, `No routes matched location "${d.pathname}${d.search}${d.hash}" `), C(g == null || g[g.length - 1].route.element !== void 0 || g[g.length - 1].route.Component !== void 0 || g[g.length - 1].route.lazy !== void 0, `Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);
let p = Tt(g && g.map((m) => Object.assign({}, m, {
params: Object.assign({}, i, m.params),
pathname: k([u, n.encodeLocation ? n.encodeLocation(m.pathname.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")).pathname : m.pathname]),
pathnameBase: m.pathnameBase === "/" ? u : k([u, n.encodeLocation ? n.encodeLocation(m.pathnameBase.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")).pathname : m.pathnameBase])
})), a, r);
return t && p ? /* @__PURE__ */ l.createElement(U.Provider, { value: {
location: {
pathname: "/",
search: "",
hash: "",
state: null,
key: "default",
unstable_mask: void 0,
...d
},
navigationType: "POP"
} }, p) : p;
}
function Lt() {
let e = Ft(), t = _e(e) ? `${e.status} ${e.statusText}` : e instanceof Error ? e.message : JSON.stringify(e), r = e instanceof Error ? e.stack : null, n = "rgba(200,200,200, 0.5)", a = {
padding: "0.5rem",
backgroundColor: n
}, o = {
padding: "2px 4px",
backgroundColor: n
}, i = null;
return console.error("Error handled by React Router default ErrorBoundary:", e), i = /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ l.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ l.createElement("code", { style: o }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ l.createElement("code", { style: o }, "errorElement"), " prop on your route.")), /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ l.createElement("h3", { style: { fontStyle: "italic" } }, t), r ? /* @__PURE__ */ l.createElement("pre", { style: a }, r) : null, i);
}
var kt = /* @__PURE__ */ l.createElement(Lt, null), We = class extends l.Component {
constructor(e) {
super(e), this.state = {
location: e.location,
revalidation: e.revalidation,
error: e.error
};
}
static getDerivedStateFromError(e) {
return { error: e };
}
static getDerivedStateFromProps(e, t) {
return t.location !== e.location || t.revalidation !== "idle" && e.revalidation === "idle" ? {
error: e.error,
location: e.location,
revalidation: e.revalidation
} : {
error: e.error !== void 0 ? e.error : t.error,
location: t.location,
revalidation: e.revalidation || t.revalidation
};
}
componentDidCatch(e, t) {
this.props.onError ? this.props.onError(e, t) : console.error("React Router caught the following error during render", e);
}
render() {
let e = this.state.error;
if (this.context && typeof e == "object" && e && "digest" in e && typeof e.digest == "string") {
const r = bt(e.digest);
r && (e = r);
}
let t = e !== void 0 ? /* @__PURE__ */ l.createElement(T.Provider, { value: this.props.routeContext }, /* @__PURE__ */ l.createElement(me.Provider, {
value: e,
children: this.props.component
})) : this.props.children;
return this.context ? /* @__PURE__ */ l.createElement(_t, { error: e }, t) : t;
}
};
We.contextType = Ne;
var oe = /* @__PURE__ */ new WeakMap();
function _t({ children: e, error: t }) {
let { basename: r } = l.useContext(b);
if (typeof t == "object" && t && "digest" in t && typeof t.digest == "string") {
let n = St(t.digest);
if (n) {
let a = oe.get(t);
if (a) throw a;
let o = Te(n.location, r);
if (Oe && !oe.get(t)) if (o.isExternal || n.reloadDocument) window.location.href = o.absoluteURL || o.to;
else {
const i = Promise.resolve().then(() => window.__reactRouterDataRouter.navigate(o.to, { replace: n.replace }));
throw oe.set(t, i), i;
}
return /* @__PURE__ */ l.createElement("meta", {
httpEquiv: "refresh",
content: `0;url=${o.absoluteURL || o.to}`
});
}
}
return e;
}
function Ot({ routeContext: e, match: t, children: r }) {
let n = l.useContext(F);
return n && n.static && n.staticContext && (t.route.errorElement || t.route.ErrorBoundary) && (n.staticContext._deepestRenderedBoundaryId = t.route.id), /* @__PURE__ */ l.createElement(T.Provider, { value: e }, r);
}
function Tt(e, t = [], r) {
let n = r?.state;
if (e == null) {
if (!n) return null;
if (n.errors) e = n.matches;
else if (t.length === 0 && !n.initialized && n.matches.length > 0) e = n.matches;
else return null;
}
let a = e, o = n?.errors;
if (o != null) {
let f = a.findIndex((d) => d.route.id && o?.[d.route.id] !== void 0);
S(f >= 0, `Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`), a = a.slice(0, Math.min(a.length, f + 1));
}
let i = !1, s = -1;
if (r && n) {
i = n.renderFallback;
for (let f = 0; f < a.length; f++) {
let d = a[f];
if ((d.route.HydrateFallback || d.route.hydrateFallbackElement) && (s = f), d.route.id) {
let { loaderData: h, errors: y } = n, g = d.route.loader && !h.hasOwnProperty(d.route.id) && (!y || y[d.route.id] === void 0);
if (d.route.lazy || g) {
r.isStatic && (i = !0), s >= 0 ? a = a.slice(0, s + 1) : a = [a[0]];
break;
}
}
}
}
let u = r?.onError, c = n && u ? (f, d) => {
u(f, {
location: n.location,
params: n.matches?.[0]?.params ?? {},
unstable_pattern: gt(n.matches),
errorInfo: d
});
} : void 0;
return a.reduceRight((f, d, h) => {
let y, g = !1, p = null, m = null;
n && (y = o && d.route.id ? o[d.route.id] : void 0, p = d.route.errorElement || kt, i && (s < 0 && h === 0 ? (Ue("route-fallback", !1, "No `HydrateFallback` element provided to render during initial hydration"), g = !0, m = null) : s === h && (g = !0, m = d.route.hydrateFallbackElement || null)));
let R = t.concat(a.slice(0, h + 1)), w = () => {
let v;
return y ? v = p : g ? v = m : d.route.Component ? v = /* @__PURE__ */ l.createElement(d.route.Component, null) : d.route.element ? v = d.route.element : v = f, /* @__PURE__ */ l.createElement(Ot, {
match: d,
routeContext: {
outlet: f,
matches: R,
isDataRoute: n != null
},
children: v
});
};
return n && (d.route.ErrorBoundary || d.route.errorElement || h === 0) ? /* @__PURE__ */ l.createElement(We, {
location: n.location,
revalidation: n.revalidation,
component: p,
error: y,
children: w(),
routeContext: {
outlet: null,
matches: R,
isDataRoute: !0
},
onError: c
}) : w();
}, null);
}
function he(e) {
return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function Mt(e) {
let t = l.useContext(F);
return S(t, he(e)), t;
}
function pe(e) {
let t = l.useContext(B);
return S(t, he(e)), t;
}
function Nt(e) {
let t = l.useContext(T);
return S(t, he(e)), t;
}
function ye(e) {
let t = Nt(e), r = t.matches[t.matches.length - 1];
return S(r.route.id, `${e} can only be used on routes that contain a unique "id"`), r.route.id;
}
function It() {
return ye("useRouteId");
}
function Dt() {
return pe("useNavigation").navigation;
}
function Be() {
let { matches: e, loaderData: t } = pe("useMatches");
return l.useMemo(() => e.map((r) => Ke(r, t)), [e, t]);
}
function Ft() {
let e = l.useContext(me), t = pe("useRouteError"), r = ye("useRouteError");
return e !== void 0 ? e : t.errors?.[r];
}
function At() {
let { router: e } = Mt("useNavigate"), t = ye("useNavigate"), r = l.useRef(!1);
return He(() => {
r.current = !0;
}), l.useCallback(async (n, a = {}) => {
C(r.current, Ae), r.current && (typeof n == "number" ? await e.navigate(n) : await e.navigate(n, {
fromRouteId: t,
...a
}));
}, [e, t]);
}
var Ee = {};
function Ue(e, t, r) {
!t && !Ee[e] && (Ee[e] = !0, C(!1, r));
}
var Se = {};
function Ht(e, t) {
!e && !Se[t] && (Se[t] = !0, console.warn(t));
}
var Dr = l.memo(Wt);
function Wt({ routes: e, future: t, state: r, isStatic: n, onError: a }) {
return Pt(e, void 0, {
state: r,
isStatic: n,
onError: a,
future: t
});
}
function Bt({ basename: e = "/", children: t = null, location: r, navigationType: n = "POP", navigator: a, static: o = !1, unstable_useTransitions: i }) {
S(!j(), "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");
let s = e.replace(/^\/*/, "/"), u = l.useMemo(() => ({
basename: s,
navigator: a,
static: o,
unstable_useTransitions: i,
future: {}
}), [
s,
a,
o,
i
]);
typeof r == "string" && (r = W(r));
let { pathname: c = "/", search: f = "", hash: d = "", state: h = null, key: y = "default", unstable_mask: g } = r, p = l.useMemo(() => {
let m = _(c, s);
return m == null ? null : {
location: {
pathname: m,
search: f,
hash: d,
state: h,
key: y,
unstable_mask: g
},
navigationType: n
};
}, [
s,
c,
f,
d,
h,
y,
n,
g
]);
return C(p != null, `<Router basename="${s}"> is not able to match the URL "${c}${f}${d}" because it does not start with the basename, so the <Router> won't render anything.`), p == null ? null : /* @__PURE__ */ l.createElement(b.Provider, { value: u }, /* @__PURE__ */ l.createElement(U.Provider, {
children: t,
value: p
}));
}
var Fr = class extends l.Component {
constructor(e) {
super(e), this.state = { error: null };
}
static getDerivedStateFromError(e) {
return { error: e };
}
componentDidCatch(e, t) {
this.props.onError ? this.props.onError(e, t) : console.error("<Await> caught the following error during render", e, t);
}
render() {
let { children: e, errorElement: t, resolve: r } = this.props, n = null, a = 0;
if (!(r instanceof Promise))
a = 1, n = Promise.resolve(), Object.defineProperty(n, "_tracked", { get: () => !0 }), Object.defineProperty(n, "_data", { get: () => r });
else if (this.state.error) {
a = 2;
let o = this.state.error;
n = Promise.reject().catch(() => {
}), Object.defineProperty(n, "_tracked", { get: () => !0 }), Object.defineProperty(n, "_error", { get: () => o });
} else r._tracked ? (n = r, a = "_error" in n ? 2 : "_data" in n ? 1 : 0) : (a = 0, Object.defineProperty(r, "_tracked", { get: () => !0 }), n = r.then((o) => Object.defineProperty(r, "_data", { get: () => o }), (o) => {
this.props.onError?.(o), Object.defineProperty(r, "_error", { get: () => o });
}));
if (a === 2 && !t) throw n._error;
if (a === 2) return /* @__PURE__ */ l.createElement(se.Provider, {
value: n,
children: t
});
if (a === 1) return /* @__PURE__ */ l.createElement(se.Provider, {
value: n,
children: e
});
throw n;
}
}, q = "get", X = "application/x-www-form-urlencoded";
function ee(e) {
return typeof HTMLElement < "u" && e instanceof HTMLElement;
}
function Ut(e) {
return ee(e) && e.tagName.toLowerCase() === "button";
}
function jt(e) {
return ee(e) && e.tagName.toLowerCase() === "form";
}
function Jt(e) {
return ee(e) && e.tagName.toLowerCase() === "input";
}
function zt(e) {
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
}
function Vt(e, t) {
return e.button === 0 && (!t || t === "_self") && !zt(e);
}
var Y = null;
function Yt() {
if (Y === null) try {
new FormData(document.createElement("form"), 0), Y = !1;
} catch {
Y = !0;
}
return Y;
}
var Gt = /* @__PURE__ */ new Set([
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
]);
function le(e) {
return e != null && !Gt.has(e) ? (C(!1, `"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${X}"`), null) : e;
}
function qt(e, t) {
let r, n, a, o, i;
if (jt(e)) {
let s = e.getAttribute("action");
n = s ? _(s, t) : null, r = e.getAttribute("method") || q, a = le(e.getAttribute("enctype")) || X, o = new FormData(e);
} else if (Ut(e) || Jt(e) && (e.type === "submit" || e.type === "image")) {
let s = e.form;
if (s == null) throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
let u = e.getAttribute("formaction") || s.getAttribute("action");
if (n = u ? _(u, t) : null, r = e.getAttribute("formmethod") || s.getAttribute("method") || q, a = le(e.getAttribute("formenctype")) || le(s.getAttribute("enctype")) || X, o = new FormData(s, e), !Yt()) {
let { name: c, type: f, value: d } = e;
if (f === "image") {
let h = c ? `${c}.` : "";
o.append(`${h}x`, "0"), o.append(`${h}y`, "0");
} else c && o.append(c, d);
}
} else {
if (ee(e)) throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
r = q, n = null, a = X, i = e;
}
return o && a === "text/plain" && (i = o, o = void 0), {
action: n,
method: r.toLowerCase(),
encType: a,
formData: o,
body: i
};
}
var Ar = Object.getOwnPropertyNames(Object.prototype).sort().join("\0"), Xt = {
"&": "\\u0026",
">": "\\u003e",
"<": "\\u003c",
"\u2028": "\\u2028",
"\u2029": "\\u2029"
}, Kt = /[&><\u2028\u2029]/g;
function be(e) {
return e.replace(Kt, (t) => Xt[t]);
}
function te(e, t) {
if (e === !1 || e === null || typeof e > "u") throw new Error(t);
}
function je(e, t, r, n) {
let a = typeof e == "string" ? new URL(e, typeof window > "u" ? "server://singlefetch/" : window.location.origin) : e;
return r ? a.pathname.endsWith("/") ? a.pathname = `${a.pathname}_.${n}` : a.pathname = `${a.pathname}.${n}` : a.pathname === "/" ? a.pathname = `_root.${n}` : t && _(a.pathname, t) === "/" ? a.pathname = `${Q(t)}/_root.${n}` : a.pathname = `${Q(a.pathname)}.${n}`, a;
}
async function Qt(e, t) {
if (e.id in t) return t[e.id];
try {
let r = await import(
/* @vite-ignore */
/* webpackIgnore: true */
e.module
);
return t[e.id] = r, r;
} catch (r) {
return console.error(`Error loading route module \`${e.module}\`, reloading page...`), console.error(r), window.__reactRouterContext && window.__reactRouterContext.isSpaMode, window.location.reload(), new Promise(() => {
});
}
}
function Zt(e) {
return e != null && typeof e.page == "string";
}
function er(e) {
return e == null ? !1 : e.href == null ? e.rel === "preload" && typeof e.imageSrcSet == "string" && typeof e.imageSizes == "string" : typeof e.rel == "string" && typeof e.href == "string";
}
async function tr(e, t, r) {
return ar((await Promise.all(e.map(async (n) => {
let a = t.routes[n.route.id];
if (a) {
let o = await Qt(a, r);
return o.links ? o.links() : [];
}
return [];
}))).flat(1).filter(er).filter((n) => n.rel === "stylesheet" || n.rel === "preload").map((n) => n.rel === "stylesheet" ? {
...n,
rel: "prefetch",
as: "style"
} : {
...n,
rel: "prefetch"
}));
}
function xe(e, t, r, n, a, o) {
let i = (u, c) => r[c] ? u.route.id !== r[c].route.id : !0, s = (u, c) => r[c].pathname !== u.pathname || r[c].route.path?.endsWith("*") && r[c].params["*"] !== u.params["*"];
return o === "assets" ? t.filter((u, c) => i(u, c) || s(u, c)) : o === "data" ? t.filter((u, c) => {
let f = n.routes[u.route.id];
if (!f || !f.hasLoader) return !1;
if (i(u, c) || s(u, c)) return !0;
if (u.route.shouldRevalidate) {
let d = u.route.shouldRevalidate({
currentUrl: new URL(a.pathname + a.search + a.hash, window.origin),
currentParams: r[0]?.params || {},
nextUrl: new URL(e, window.origin),
nextParams: u.params,
defaultShouldRevalidate: !0
});
if (typeof d == "boolean") return d;
}
return !0;
}) : [];
}
function Je(e, t, { includeHydrateFallback: r } = {}) {
return rr(e.map((n) => {
let a = t.routes[n.route.id];
if (!a) return [];
let o = [a.module];
return a.clientActionModule && (o = o.concat(a.clientActionModule)), a.clientLoaderModule && (o = o.concat(a.clientLoaderModule)), r && a.hydrateFallbackModule && (o = o.concat(a.hydrateFallbackModule)), a.imports && (o = o.concat(a.imports)), o;
}).flat(1));
}
function rr(e) {
return [...new Set(e)];
}
function nr(e) {
let t = {}, r = Object.keys(e).sort();
for (let n of r) t[n] = e[n];
return t;
}
function ar(e, t) {
let r = /* @__PURE__ */ new Set(), n = new Set(t);
return e.reduce((a, o) => {
if (t && !Zt(o) && o.as === "script" && o.href && n.has(o.href)) return a;
let i = JSON.stringify(nr(o));
return r.has(i) || (r.add(i), a.push({
key: i,
link: o
})), a;
}, []);
}
function or(e, t) {
return e.mode === "lazy" && t === !0;
}
function lr({ sri: e, ...t }, r) {
let n = new Set(r.state.matches.map((s) => s.route.id)), a = r.state.location.pathname.split("/").filter(Boolean), o = ["/"];
for (a.pop(); a.length > 0; )
o.push(`/${a.join("/")}`), a.pop();
o.forEach((s) => {
let u = de(r.routes, s, r.basename);
u && u.forEach((c) => n.add(c.route.id));
});
let i = [...n].reduce((s, u) => Object.assign(s, { [u]: t.routes[u] }), {});
return {
...t,
routes: i,
sri: e ? !0 : void 0
};
}
function re() {
let e = l.useContext(F);
return te(e, "You must render this element inside a <DataRouterContext.Provider> element"), e;
}
function ze() {
let e = l.useContext(B);
return te(e, "You must render this element inside a <DataRouterStateContext.Provider> element"), e;
}
var ne = l.createContext(void 0);
ne.displayName = "FrameworkContext";
function z() {
let e = l.useContext(ne);
return te(e, "You must render this element inside a <HydratedRouter> element"), e;
}
function ir(e, t) {
let r = l.useContext(ne), [n, a] = l.useState(!1), [o, i] = l.useState(!1), { onFocus: s, onBlur: u, onMouseEnter: c, onMouseLeave: f, onTouchStart: d } = t, h = l.useRef(null);
l.useEffect(() => {
if (e === "render" && i(!0), e === "viewport") {
let p = (R) => {
R.forEach((w) => {
i(w.isIntersecting);
});
}, m = new IntersectionObserver(p, { threshold: 0.5 });
return h.current && m.observe(h.current), () => {
m.disconnect();
};
}
}, [e]), l.useEffect(() => {
if (n) {
let p = setTimeout(() => {
i(!0);
}, 100);
return () => {
clearTimeout(p);
};
}
}, [n]);
let y = () => {
a(!0);
}, g = () => {
a(!1), i(!1);
};
return r ? e !== "intent" ? [
o,
h,
{}
] : [
o,
h,
{
onFocus: H(s, y),
onBlur: H(u, g),
onMouseEnter: H(c, y),
onMouseLeave: H(f, g),
onTouchStart: H(d, y)
}
] : [
!1,
h,
{}
];
}
function H(e, t) {
return (r) => {
e && e(r), r.defaultPrevented || t(r);
};
}
function sr(e, t, r) {
if (r && !Z) return [e[0]];
if (t) {
let n = e.findIndex((a) => t[a.route.id] !== void 0);
return e.slice(0, n + 1);
}
return e;
}
function ur({ page: e, ...t }) {
let r = Ie(), { router: n } = re(), a = l.useMemo(() => de(n.routes, e, n.basename), [
n.routes,
e,
n.basename
]);
return a ? r ? /* @__PURE__ */ l.createElement(dr, {
page: e,
matches: a,
...t
}) : /* @__PURE__ */ l.createElement(fr, {
page: e,
matches: a,
...t
}) : null;
}
function cr(e) {
let { manifest: t, routeModules: r } = z(), [n, a] = l.useState([]);
return l.useEffect(() => {
let o = !1;
return tr(e, t, r).then((i) => {
o || a(i);
}), () => {
o = !0;
};
}, [
e,
t,
r
]), n;
}
function dr({ page: e, matches: t, ...r }) {
let n = $(), { future: a } = z(), { basename: o } = re(), i = l.useMemo(() => {
if (e === n.pathname + n.search + n.hash) return [];
let s = je(e, o, a.unstable_trailingSlashAwareDataRequests, "rsc"), u = !1, c = [];
for (let f of t) typeof f.route.shouldRevalidate == "function" ? u = !0 : c.push(f.route.id);
return u && c.length > 0 && s.searchParams.set("_routes", c.join(",")), [s.pathname + s.search];
}, [
o,
a.unstable_trailingSlashAwareDataRequests,
e,
n,
t
]);
return /* @__PURE__ */ l.createElement(l.Fragment, null, i.map((s) => /* @__PURE__ */ l.createElement("link", {
key: s,
rel: "prefetch",
as: "fetch",
href: s,
...r
})));
}
function fr({ page: e, matches: t, ...r }) {
let n = $(), { future: a, manifest: o, routeModules: i } = z(), { basename: s } = re(), { loaderData: u, matches: c } = ze(), f = l.useMemo(() => xe(e, t, c, o, n, "data"), [
e,
t,
c,
o,
n
]), d = l.useMemo(() => xe(e, t, c, o, n, "assets"), [
e,
t,
c,
o,
n
]), h = l.useMemo(() => {
if (e === n.pathname + n.search + n.hash) return [];
let p = /* @__PURE__ */ new Set(), m = !1;
if (t.forEach((w) => {
let v = o.routes[w.route.id];
!v || !v.hasLoader || (!f.some((x) => x.route.id === w.route.id) && w.route.id in u && i[w.route.id]?.shouldRevalidate || v.hasClientLoader ? m = !0 : p.add(w.route.id));
}), p.size === 0) return [];
let R = je(e, s, a.unstable_trailingSlashAwareDataRequests, "data");
return m && p.size > 0 && R.searchParams.set("_routes", t.filter((w) => p.has(w.route.id)).map((w) => w.route.id).join(",")), [R.pathname + R.search];
}, [
s,
a.unstable_trailingSlashAwareDataRequests,
u,
n,
o,
f,
t,
e,
i
]), y = l.useMemo(() => Je(d, o), [d, o]), g = cr(d);
return /* @__PURE__ */ l.createElement(l.Fragment, null, h.map((p) => /* @__PURE__ */ l.createElement("link", {
key: p,
rel: "prefetch",
as: "fetch",
href: p,
...r
})), y.map((p) => /* @__PURE__ */ l.createElement("link", {
key: p,
rel: "modulepreload",
href: p,
...r
})), g.map(({ key: p, link: m }) => /* @__PURE__ */ l.createElement("link", {
key: p,
nonce: r.nonce,
...m,
crossOrigin: m.crossOrigin ?? r.crossOrigin
})));
}
var Z = !1;
function mr() {
Z = !0;
}
function hr(e) {
let { manifest: t, serverHandoffString: r, isSpaMode: n, renderMeta: a, routeDiscovery: o, ssr: i } = z(), { router: s, static: u, staticContext: c } = re(), { matches: f } = ze(), d = Ie(), h = or(o, i);
a && (a.didRenderScripts = !0);
let y = sr(f, null, n);
l.useEffect(() => {
mr();
}, []);
let g = l.useMemo(() => {
if (d) return null;
let R = c ? `window.__reactRouterContext = ${r};window.__reactRouterContext.stream = new ReadableStream({start(controller){window.__reactRouterContext.streamController = controller;}}).pipeThrough(new TextEncoderStream());` : " ", w = u ? `${t.hmr?.runtime ? `import ${JSON.stringify(t.hmr.runtime)};` : ""}${h ? "" : `import ${JSON.stringify(t.url)}`};
${y.map((v, x) => {
let E = `route${x}`, P = t.routes[v.route.id];
te(P, `Route ${v.route.id} not found in manifest`);
let { clientActionModule: L, clientLoaderModule: O, clientMiddlewareModule: M, hydrateFallbackModule: D, module: V } = P, A = [
...L ? [{
module: L,
varName: `${E}_clientAction`
}] : [],
...O ? [{
module: O,
varName: `${E}_clientLoader`
}] : [],
...M ? [{
module: M,
varName: `${E}_clientMiddleware`
}] : [],
...D ? [{
module: D,
varName: `${E}_HydrateFallback`
}] : [],
{
module: V,
varName: `${E}_main`
}
];
return A.length === 1 ? `import * as ${E} from ${JSON.stringify(V)};` : [A.map((I) => `import * as ${I.varName} from "${I.module}";`).join(`
`), `const ${E} = {${A.map((I) => `...${I.varName}`).join(",")}};`].join(`
`);
}).join(`
`)}
${h ? `window.__reactRouterManifest = ${JSON.stringify(lr(t, s), null, 2)};` : ""}
window.__reactRouterRouteModules = {${y.map((v, x) => `${JSON.stringify(v.route.id)}:route${x}`).join(",")}};
import(${JSON.stringify(t.entry.module)});` : " ";
return /* @__PURE__ */ l.createElement(l.Fragment, null, /* @__PURE__ */ l.createElement("script", {
...e,
suppressHydrationWarning: !0,
dangerouslySetInnerHTML: { __html: R },
type: void 0
}), /* @__PURE__ */ l.createElement("script", {
...e,
suppressHydrationWarning: !0,
dangerouslySetInnerHTML: { __html: w },
type: "module",
async: !0
}));
}, []), p = Z || d ? [] : pr(t.entry.imports.concat(Je(y, t, { includeHydrateFallback: !0 }))), m = typeof t.sri == "object" ? t.sri : {};
return Ht(!d, "The <Scripts /> element is a no-op when using RSC and can be safely removed."), Z || d ? null : /* @__PURE__ */ l.createElement(l.Fragment, null, typeof t.sri == "object" ? /* @__PURE__ */ l.createElement("script", {
...e,
"rr-importmap": "",
type: "importmap",
suppressHydrationWarning: !0,
dangerouslySetInnerHTML: { __html: JSON.stringify({ integrity: m }) }
}) : null, h ? null : /* @__PURE__ */ l.createElement("link", {
rel: "modulepreload",
href: t.url,
crossOrigin: e.crossOrigin,
integrity: m[t.url],
suppressHydrationWarning: !0
}), /* @__PURE__ */ l.createElement("link", {
rel: "modulepreload",
href: t.entry.module,
crossOrigin: e.crossOrigin,
integrity: m[t.entry.module],
suppressHydrationWarning: !0
}), p.map((R) => /* @__PURE__ */ l.createElement("link", {
key: R,
rel: "modulepreload",
href: R,
crossOrigin: e.crossOrigin,
integrity: m[R],
suppressHydrationWarning: !0
})), g);
}
function pr(e) {
return [...new Set(e)];
}
function yr(...e) {
return (t) => {
e.forEach((r) => {
typeof r == "function" ? r(t) : r != null && (r.current = t);
});
};
}
var Hr = class extends l.Component {
constructor(e) {
super(e), this.state = {
error: e.error || null,
location: e.location
};
}
static getDerivedStateFromError(e) {
return { error: e };
}
static getDerivedStateFromProps(e, t) {
return t.location !== e.location ? {
error: e.error || null,
location: e.location
} : {
error: e.error || t.error,
location: t.location
};
}
render() {
return this.state.error ? /* @__PURE__ */ l.createElement(gr, {
error: this.state.error,
isOutsideRemixApp: !0
}) : this.props.children;
}
};
function gr({ error: e, isOutsideRemixApp: t }) {
console.error(e);
let r = /* @__PURE__ */ l.createElement("script", { dangerouslySetInnerHTML: { __html: `
console.log(
"💿 Hey developer 👋. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
);
` } });
if (_e(e)) return /* @__PURE__ */ l.createElement(Ce, { title: "Unhandled Thrown Response!" }, /* @__PURE__ */ l.createElement("h1", { style: { fontSize: "24px" } }, e.status, " ", e.statusText), r);
let n;
if (e instanceof Error) n = e;
else {
let a = e == null ? "Unknown Error" : typeof e == "object" && "toString" in e ? e.toString() : JSON.stringify(e);
n = new Error(a);
}
return /* @__PURE__ */ l.createElement(Ce, {
title: "Application Error!",
isOutsideRemixApp: t
}, /* @__PURE__ */ l.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"), /* @__PURE__ */ l.createElement("pre", { style: {
padding: "2rem",
background: "hsla(10, 50%, 50%, 0.1)",
color: "red",
overflow: "auto"
} }, n.stack), r);
}
function Ce({ title: e, renderScripts: t, isOutsideRemixApp: r, children: n }) {
let { routeModules: a } = z();
return a.root?.Layout && !r ? n : /* @__PURE__ */ l.createElement("html", { lang: "en" }, /* @__PURE__ */ l.createElement("head", null, /* @__PURE__ */ l.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ l.createElement("meta", {
name: "viewport",
content: "width=device-width,initial-scale=1,viewport-fit=cover"
}), /* @__PURE__ */ l.createElement("title", null, e)), /* @__PURE__ */ l.createElement("body", null, /* @__PURE__ */ l.createElement("main", { style: {
fontFamily: "system-ui, sans-serif",
padding: "2rem"
} }, n, t ? /* @__PURE__ */ l.createElement(hr, null) : null)));
}
var vr = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
try {
vr && (window.__reactRouterVersion = "7.14.2");
} catch {
}
function Rr({ basename: e, children: t, history: r, unstable_useTransitions: n }) {
let [a, o] = l.useState({
action: r.action,
location: r.location
}), i = l.useCallback((s) => {
n === !1 ? o(s) : l.startTransition(() => o(s));
}, [n]);
return l.useLayoutEffect(() => r.listen(i), [r, i]), /* @__PURE__ */ l.createElement(Bt, {
basename: e,
children: t,
location: a.location,
navigationType: a.action,
navigator: r,
unstable_useTransitions: n
});
}
Rr.displayName = "unstable_HistoryRouter";
var Ve = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Ye = l.forwardRef(function({ onClick: t, discover: r = "render", prefetch: n = "none", relative: a, reloadDocument: o, replace: i, unstable_mask: s, state: u, target: c, to: f, preventScrollReset: d, viewTransition: h, unstable_defaultShouldRevalidate: y, ...g }, p) {
let { basename: m, navigator: R, unstable_useTransitions: w } = l.useContext(b), v = typeof f == "string" && Ve.test(f), x = Te(f, m);
f = x.to;
let E = xt(f, { relative: a }), P = $(), L = null;
if (s) {
let N = fe(s, [], P.unstable_mask ? P.unstable_mask.pathname : "/", !0);
m !== "/" && (N.pathname = N.pathname === "/" ? m : k([m, N.pathname])), L = R.createHref(N);
}
let [O, M, D] = ir(n, g), V = xr(f, {
replace: i,
unstable_mask: s,
state: u,
target: c,
preventScrollReset: d,
relative: a,
viewTransition: h,
unstable_defaultShouldRevalidate: y,
unstable_useTransitions: w
});
function A(N) {
t && t(N), N.defaultPrevented || V(N);
}
let I = !(x.isExternal || o), ve = /* @__PURE__ */ l.createElement("a", {
...g,
...D,
href: (I ? L : void 0) || x.absoluteURL || E,
onClick: I ? A : t,
ref: yr(p, M),
target: c,
"data-discover": !v && r === "render" ? "true" : void 0
});
return O && !v ? /* @__PURE__ */ l.createElement(l.Fragment, null, ve, /* @__PURE__ */ l.createElement(ur, { page: E })) : ve;
});
Ye.displayName = "Link";
var wr = l.forwardRef(function({ "aria-current": t = "page", caseSensitive: r = !1, className: n = "", end: a = !1, style: o, to: i, viewTransition: s, children: u, ...c }, f) {
let d = J(i, { relative: c.relative }), h = $(), y = l.useContext(B), { navigator: g, basename: p } = l.useContext(b), m = y != null && Or(d) && s === !0, R = g.encodeLocation ? g.encodeLocation(d).pathname : d.pathname, w = h.pathname, v = y && y.navigation && y.navigation.location ? y.navigation.location.pathname : null;
r || (w = w.toLowerCase(), v = v ? v.toLowerCase() : null, R = R.toLowerCase()), v && p && (v = _(v, p) || v);
const x = R !== "/" && R.endsWith("/") ? R.length - 1 : R.length;
let E = w === R || !a && w.startsWith(R) && w.charAt(x) === "/", P = v != null && (v === R || !a && v.startsWith(R) && v.charAt(R.length) === "/"), L = {
isActive: E,
isPending: P,
isTransitioning: m
}, O = E ? t : void 0, M;
typeof n == "function" ? M = n(L) : M = [
n,
E ? "active" : null,
P ? "pending" : null,
m ? "transitioning" : null
].filter(Boolean).join(" ");
let D = typeof o == "function" ? o(L) : o;
return /* @__PURE__ */ l.createElement(Ye, {
...c,
"aria-current": O,
className: M,
ref: f,
style: D,
to: i,
viewTransition: s
}, typeof u == "function" ? u(L) : u);
});
wr.displayName = "NavLink";
var Er = l.forwardRef(({ discover: e = "render", fetcherKey: t, navigate: r, reloadDocument: n, replace: a, state: o, method: i = q, action: s, onSubmit: u, relative: c, preventScrollReset: f, viewTransition: d, unstable_defaultShouldRevalidate: h, ...y }, g) => {
let { unstable_useTransitions: p } = l.useContext(b), m = Pr(), R = Lr(s, { relative: c }), w = i.toLowerCase() === "get" ? "get" : "post", v = typeof s == "string" && Ve.test(s), x = (E) => {
if (u && u(E), E.defaultPrevented) return;
E.preventDefault();
let P = E.nativeEvent.submitter, L = P?.getAttribute("formmethod") || i, O = () => m(P || E.currentTarget, {
fetcherKey: t,
method: L,
navigate: r,
replace: a,
state: o,
relative: c,
preventScrollReset: f,
viewTransition: d,
unstable_defaultShouldRevalidate: h
});
p && r !== !1 ? l.startTransition(() => O()) : O();
};
return /* @__PURE__ */ l.createElement("form", {
ref: g,
method: w,
action: R,
onSubmit: n ? u : x,
...y,
"data-discover": !v && e === "render" ? "true" : void 0
});
});
Er.displayName = "Form";
function Sr({ getKey: e, storageKey: t, ...r }) {
let n = l.useContext(ne), { basename: a } = l.useContext(b), o = $(), i = Be();
kr({
getKey: e,
storageKey: t
});
let s = l.useMemo(() => {
if (!n || !e) return null;
let c = ce(o, i, a, e);
return c !== o.key ? c : null;
}, []);
if (!n || n.isSpaMode) return null;
let u = ((c, f) => {
if (!window.history.state || !window.history.state.key) {
let d = Math.random().toString(32).slice(2);
window.history.replaceState({ key: d }, "");
}
try {
let d = JSON.parse(sessionStorage.getItem(c) || "{}")[f || window.history.state.key];
typeof d == "number" && window.scrollTo(0, d);
} catch (d) {
console.error(d), sessionStorage.removeItem(c);
}
}).toString();
return /* @__PURE__ */ l.createElement("script", {
...r,
suppressHydrationWarning: !0,
dangerouslySetInnerHTML: { __html: `(${u})(${be(JSON.stringify(t || ue))}, ${be(JSON.stringify(s))})` }
});
}
Sr.displayName = "ScrollRestoration";
function Ge(e) {
return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function ge(e) {
let t = l.useContext(F);
return S(t, Ge(e)), t;
}
function br(e) {
let t = l.useContext(B);
return S(t, Ge(e)), t;
}
function xr(e, { target: t, replace: r, unstable_mask: n, state: a, preventScrollReset: o, relative: i, viewTransition: s, unstable_defaultShouldRevalidate: u, unstable_useTransitions: c } = {}) {
let f = Ct(), d = $(), h = J(e, { relative: i });
return l.useCallback((y) => {
if (Vt(y, t)) {
y.preventDefault();
let g = r !== void 0 ? r : ie(d) === ie(h), p = () => f(e, {
replace: g,
unstable_mask: n,
state: a,
preventScrollReset: o,
relative: i,
viewTransition: s,
unstable_defaultShouldRevalidate: u
});
c ? l.startTransition(() => p()) : p();
}
}, [
d,
f,
h,
r,
n,
a,
t,
e,
o,
i,
s,
u,
c