UNPKG

stone-kit

Version:
891 lines (889 loc) • 30.7 kB
import * as s from "react"; /** * @remix-run/router v1.19.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ function D() { return D = Object.assign ? Object.assign.bind() : function(e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]); } return e; }, D.apply(this, arguments); } var R; (function(e) { e.Pop = "POP", e.Push = "PUSH", e.Replace = "REPLACE"; })(R || (R = {})); const z = "popstate"; function Ye(e) { e === void 0 && (e = {}); function t(r, a) { let { pathname: o, search: l, hash: u } = r.location; return W( "", { pathname: o, search: l, hash: u }, // state defaults to `null` because `window.history.state` does a.state && a.state.usr || null, a.state && a.state.key || "default" ); } function n(r, a) { return typeof a == "string" ? a : G(a); } return se(t, n, null, e); } function f(e, t) { if (e === !1 || e === null || typeof e > "u") throw new Error(t); } function b(e, t) { if (!e) { typeof console < "u" && console.warn(t); try { throw new Error(t); } catch { } } } function ie() { return Math.random().toString(36).substr(2, 8); } function A(e, t) { return { usr: e.state, key: e.key, idx: t }; } function W(e, t, n, r) { return n === void 0 && (n = null), D({ pathname: typeof e == "string" ? e : e.pathname, search: "", hash: "" }, typeof t == "string" ? O(t) : t, { state: n, // TODO: This could be cleaned up. push/replace should probably just take // full Locations now and avoid the need to run through this flow at all // But that's a pretty big refactor to the current test suite so going to // keep as is for the time being and just let any incoming keys take precedence key: t && t.key || r || ie() }); } function G(e) { let { pathname: t = "/", search: n = "", hash: r = "" } = e; return n && n !== "?" && (t += n.charAt(0) === "?" ? n : "?" + n), r && r !== "#" && (t += r.charAt(0) === "#" ? r : "#" + r), t; } function O(e) { let t = {}; if (e) { let n = e.indexOf("#"); n >= 0 && (t.hash = e.substr(n), e = e.substr(0, n)); let r = e.indexOf("?"); r >= 0 && (t.search = e.substr(r), e = e.substr(0, r)), e && (t.pathname = e); } return t; } function se(e, t, n, r) { r === void 0 && (r = {}); let { window: a = document.defaultView, v5Compat: o = !1 } = r, l = a.history, u = R.Pop, i = null, d = h(); d == null && (d = 0, l.replaceState(D({}, l.state, { idx: d }), "")); function h() { return (l.state || { idx: null }).idx; } function c() { u = R.Pop; let p = h(), E = p == null ? null : p - d; d = p, i && i({ action: u, location: g.location, delta: E }); } function m(p, E) { u = R.Push; let v = W(g.location, p, E); d = h() + 1; let N = A(v, d), L = g.createHref(v); try { l.pushState(N, "", L); } catch (I) { if (I instanceof DOMException && I.name === "DataCloneError") throw I; a.location.assign(L); } o && i && i({ action: u, location: g.location, delta: 1 }); } function x(p, E) { u = R.Replace; let v = W(g.location, p, E); d = h(); let N = A(v, d), L = g.createHref(v); l.replaceState(N, "", L), o && i && i({ action: u, location: g.location, delta: 0 }); } function y(p) { let E = a.location.origin !== "null" ? a.location.origin : a.location.href, v = typeof p == "string" ? p : G(p); return v = v.replace(/ $/, "%20"), f(E, "No window.location.(origin|href) available to create URL for href: " + v), new URL(v, E); } let g = { get action() { return u; }, get location() { return e(a, l); }, listen(p) { if (i) throw new Error("A history only accepts one active listener"); return a.addEventListener(z, c), i = p, () => { a.removeEventListener(z, c), i = null; }; }, createHref(p) { return t(a, p); }, createURL: y, encodeLocation(p) { let E = y(p); return { pathname: E.pathname, search: E.search, hash: E.hash }; }, push: m, replace: x, go(p) { return l.go(p); } }; return g; } var J; (function(e) { e.data = "data", e.deferred = "deferred", e.redirect = "redirect", e.error = "error"; })(J || (J = {})); function ue(e, t, n) { return n === void 0 && (n = "/"), ce(e, t, n, !1); } function ce(e, t, n, r) { let a = typeof t == "string" ? O(t) : t, o = Q(a.pathname || "/", n); if (o == null) return null; let l = K(e); de(l); let u = null; for (let i = 0; u == null && i < l.length; ++i) { let d = Re(o); u = xe(l[i], d, r); } return u; } function K(e, t, n, r) { t === void 0 && (t = []), n === void 0 && (n = []), r === void 0 && (r = ""); let a = (o, l, u) => { let i = { relativePath: u === void 0 ? o.path || "" : u, caseSensitive: o.caseSensitive === !0, childrenIndex: l, route: o }; i.relativePath.startsWith("/") && (f(i.relativePath.startsWith(r), 'Absolute route path "' + i.relativePath + '" nested under path ' + ('"' + r + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes."), i.relativePath = i.relativePath.slice(r.length)); let d = C([r, i.relativePath]), h = n.concat(i); o.children && o.children.length > 0 && (f( // Our types know better, but runtime JS may not! // @ts-expect-error o.index !== !0, "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + d + '".') ), K(o.children, t, h, d)), !(o.path == null && !o.index) && t.push({ path: d, score: Ee(d, o.index), routesMeta: h }); }; return e.forEach((o, l) => { var u; if (o.path === "" || !((u = o.path) != null && u.includes("?"))) a(o, l); else for (let i of X(o.path)) a(o, l, i); }), t; } function X(e) { let t = e.split("/"); if (t.length === 0) return []; let [n, ...r] = t, a = n.endsWith("?"), o = n.replace(/\?$/, ""); if (r.length === 0) return a ? [o, ""] : [o]; let l = X(r.join("/")), u = []; return u.push(...l.map((i) => i === "" ? o : [o, i].join("/"))), a && u.push(...l), u.map((i) => e.startsWith("/") && i === "" ? "/" : i); } function de(e) { e.sort((t, n) => t.score !== n.score ? n.score - t.score : ye(t.routesMeta.map((r) => r.childrenIndex), n.routesMeta.map((r) => r.childrenIndex))); } const he = /^:[\w-]+$/, pe = 3, fe = 2, me = 1, ve = 10, ge = -2, H = (e) => e === "*"; function Ee(e, t) { let n = e.split("/"), r = n.length; return n.some(H) && (r += ge), t && (r += fe), n.filter((a) => !H(a)).reduce((a, o) => a + (he.test(o) ? pe : o === "" ? me : ve), r); } function ye(e, t) { return e.length === t.length && e.slice(0, -1).every((r, a) => r === t[a]) ? ( // If two routes are siblings, we should try to match the earlier sibling // first. This allows people to have fine-grained control over the matching // behavior by simply putting routes with identical paths in the order they // want them tried. e[e.length - 1] - t[t.length - 1] ) : ( // Otherwise, it doesn't really make sense to rank non-siblings by index, // so they sort equally. 0 ); } function xe(e, t, n) { let { routesMeta: r } = e, a = {}, o = "/", l = []; for (let u = 0; u < r.length; ++u) { let i = r[u], d = u === r.length - 1, h = o === "/" ? t : t.slice(o.length) || "/", c = Y({ path: i.relativePath, caseSensitive: i.caseSensitive, end: d }, h), m = i.route; if (!c && d && n && !r[r.length - 1].route.index && (c = Y({ path: i.relativePath, caseSensitive: i.caseSensitive, end: !1 }, h)), !c) return null; Object.assign(a, c.params), l.push({ // TODO: Can this as be avoided? params: a, pathname: C([o, c.pathname]), pathnameBase: we(C([o, c.pathnameBase])), route: m }), c.pathnameBase !== "/" && (o = C([o, c.pathnameBase])); } return l; } function Y(e, t) { typeof e == "string" && (e = { path: e, caseSensitive: !1, end: !0 }); let [n, r] = Ne(e.path, e.caseSensitive, e.end), a = t.match(n); if (!a) return null; let o = a[0], l = o.replace(/(.)\/+$/, "$1"), u = a.slice(1); return { params: r.reduce((d, h, c) => { let { paramName: m, isOptional: x } = h; if (m === "*") { let g = u[c] || ""; l = o.slice(0, o.length - g.length).replace(/(.)\/+$/, "$1"); } const y = u[c]; return x && !y ? d[m] = void 0 : d[m] = (y || "").replace(/%2F/g, "/"), d; }, {}), pathname: o, pathnameBase: l, pattern: e }; } function Ne(e, t, n) { t === void 0 && (t = !1), n === void 0 && (n = !0), b(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 r = [], a = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (l, u, i) => (r.push({ paramName: u, isOptional: i != null }), i ? "/?([^\\/]+)?" : "/([^\\/]+)")); return e.endsWith("*") ? (r.push({ paramName: "*" }), a += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : n ? a += "\\/*$" : e !== "" && e !== "/" && (a += "(?:(?=\\/|$))"), [new RegExp(a, t ? void 0 : "i"), r]; } function Re(e) { try { return e.split("/").map((t) => decodeURIComponent(t).replace(/\//g, "%2F")).join("/"); } catch (t) { return b(!1, 'The URL path "' + e + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + t + ").")), e; } } function Q(e, t) { if (t === "/") return e; if (!e.toLowerCase().startsWith(t.toLowerCase())) return null; let n = t.endsWith("/") ? t.length - 1 : t.length, r = e.charAt(n); return r && r !== "/" ? null : e.slice(n) || "/"; } function Ce(e, t) { t === void 0 && (t = "/"); let { pathname: n, search: r = "", hash: a = "" } = typeof e == "string" ? O(e) : e; return { pathname: n ? n.startsWith("/") ? n : be(n, t) : t, search: Oe(r), hash: De(a) }; } function be(e, t) { let n = t.replace(/\/+$/, "").split("/"); return e.split("/").forEach((a) => { a === ".." ? n.length > 1 && n.pop() : a !== "." && n.push(a); }), n.length > 1 ? n.join("/") : "/"; } function j(e, t, n, r) { return "Cannot include a '" + e + "' character in a manually specified " + ("`to." + t + "` field [" + JSON.stringify(r) + "]. Please separate it out to the ") + ("`to." + n + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.'; } function Pe(e) { return e.filter((t, n) => n === 0 || t.route.path && t.route.path.length > 0); } function Z(e, t) { let n = Pe(e); return t ? n.map((r, a) => a === n.length - 1 ? r.pathname : r.pathnameBase) : n.map((r) => r.pathnameBase); } function ee(e, t, n, r) { r === void 0 && (r = !1); let a; typeof e == "string" ? a = O(e) : (a = D({}, e), f(!a.pathname || !a.pathname.includes("?"), j("?", "pathname", "search", a)), f(!a.pathname || !a.pathname.includes("#"), j("#", "pathname", "hash", a)), f(!a.search || !a.search.includes("#"), j("#", "search", "hash", a))); let o = e === "" || a.pathname === "", l = o ? "/" : a.pathname, u; if (l == null) u = n; else { let c = t.length - 1; if (!r && l.startsWith("..")) { let m = l.split("/"); for (; m[0] === ".."; ) m.shift(), c -= 1; a.pathname = m.join("/"); } u = c >= 0 ? t[c] : "/"; } let i = Ce(a, u), d = l && l !== "/" && l.endsWith("/"), h = (o || l === ".") && n.endsWith("/"); return !i.pathname.endsWith("/") && (d || h) && (i.pathname += "/"), i; } const C = (e) => e.join("/").replace(/\/\/+/g, "/"), we = (e) => e.replace(/\/+$/, "").replace(/^\/*/, "/"), Oe = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, De = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e; function _e(e) { return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e; } const te = ["post", "put", "patch", "delete"]; new Set(te); const Ve = ["get", ...te]; new Set(Ve); /** * React Router v6.26.0 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ function _() { return _ = Object.assign ? Object.assign.bind() : function(e) { for (var t = 1; t < arguments.length; t++) { var n = arguments[t]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]); } return e; }, _.apply(this, arguments); } const U = /* @__PURE__ */ s.createContext(null); process.env.NODE_ENV !== "production" && (U.displayName = "DataRouter"); const ne = /* @__PURE__ */ s.createContext(null); process.env.NODE_ENV !== "production" && (ne.displayName = "DataRouterState"); const Be = /* @__PURE__ */ s.createContext(null); process.env.NODE_ENV !== "production" && (Be.displayName = "Await"); const w = /* @__PURE__ */ s.createContext(null); process.env.NODE_ENV !== "production" && (w.displayName = "Navigation"); const B = /* @__PURE__ */ s.createContext(null); process.env.NODE_ENV !== "production" && (B.displayName = "Location"); const P = /* @__PURE__ */ s.createContext({ outlet: null, matches: [], isDataRoute: !1 }); process.env.NODE_ENV !== "production" && (P.displayName = "Route"); const M = /* @__PURE__ */ s.createContext(null); process.env.NODE_ENV !== "production" && (M.displayName = "RouteError"); function qe(e, t) { let { relative: n } = t === void 0 ? {} : t; S() || (process.env.NODE_ENV !== "production" ? f( !1, // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useHref() may be used only in the context of a <Router> component." ) : f(!1)); let { basename: r, navigator: a } = s.useContext(w), { hash: o, pathname: l, search: u } = Le(e, { relative: n }), i = l; return r !== "/" && (i = l === "/" ? r : C([r, l])), a.createHref({ pathname: i, search: u, hash: o }); } function S() { return s.useContext(B) != null; } function F() { return S() || (process.env.NODE_ENV !== "production" ? f( !1, // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useLocation() may be used only in the context of a <Router> component." ) : f(!1)), s.useContext(B).location; } const re = "You should call navigate() in a React.useEffect(), not when your component is first rendered."; function ae(e) { s.useContext(w).static || s.useLayoutEffect(e); } function Ge() { let { isDataRoute: e } = s.useContext(P); return e ? Je() : Se(); } function Se() { S() || (process.env.NODE_ENV !== "production" ? f( !1, // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useNavigate() may be used only in the context of a <Router> component." ) : f(!1)); let e = s.useContext(U), { basename: t, future: n, navigator: r } = s.useContext(w), { matches: a } = s.useContext(P), { pathname: o } = F(), l = JSON.stringify(Z(a, n.v7_relativeSplatPath)), u = s.useRef(!1); return ae(() => { u.current = !0; }), s.useCallback(function(d, h) { if (h === void 0 && (h = {}), process.env.NODE_ENV !== "production" && b(u.current, re), !u.current) return; if (typeof d == "number") { r.go(d); return; } let c = ee(d, JSON.parse(l), o, h.relative === "path"); e == null && t !== "/" && (c.pathname = c.pathname === "/" ? t : C([t, c.pathname])), (h.replace ? r.replace : r.push)(c, h.state, h); }, [t, r, l, o, e]); } function Le(e, t) { let { relative: n } = t === void 0 ? {} : t, { future: r } = s.useContext(w), { matches: a } = s.useContext(P), { pathname: o } = F(), l = JSON.stringify(Z(a, r.v7_relativeSplatPath)); return s.useMemo(() => ee(e, JSON.parse(l), o, n === "path"), [e, l, o, n]); } function Ue(e, t) { return Ie(e, t); } function Ie(e, t, n, r) { S() || (process.env.NODE_ENV !== "production" ? f( !1, // TODO: This error is probably because they somehow have 2 versions of the // router loaded. We can help them understand how to avoid that. "useRoutes() may be used only in the context of a <Router> component." ) : f(!1)); let { navigator: a } = s.useContext(w), { matches: o } = s.useContext(P), l = o[o.length - 1], u = l ? l.params : {}, i = l ? l.pathname : "/", d = l ? l.pathnameBase : "/", h = l && l.route; if (process.env.NODE_ENV !== "production") { let v = h && h.path || ""; le(i, !h || v.endsWith("*"), "You rendered descendant <Routes> (or called `useRoutes()`) at " + ('"' + i + '" (under <Route path="' + v + '">) 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="' + v + '"> to <Route ') + ('path="' + (v === "/" ? "*" : v + "/*") + '">.')); } let c = F(), m; if (t) { var x; let v = typeof t == "string" ? O(t) : t; d === "/" || (x = v.pathname) != null && x.startsWith(d) || (process.env.NODE_ENV !== "production" ? f(!1, "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 "' + d + '" ') + ('but pathname "' + v.pathname + '" was given in the `location` prop.')) : f(!1)), m = v; } else m = c; let y = m.pathname || "/", g = y; if (d !== "/") { let v = d.replace(/^\//, "").split("/"); g = "/" + y.replace(/^\//, "").split("/").slice(v.length).join("/"); } let p = ue(e, { pathname: g }); process.env.NODE_ENV !== "production" && (process.env.NODE_ENV !== "production" && b(h || p != null, 'No routes matched location "' + m.pathname + m.search + m.hash + '" '), process.env.NODE_ENV !== "production" && b(p == null || p[p.length - 1].route.element !== void 0 || p[p.length - 1].route.Component !== void 0 || p[p.length - 1].route.lazy !== void 0, 'Matched leaf route at location "' + m.pathname + m.search + m.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 E = Fe(p && p.map((v) => Object.assign({}, v, { params: Object.assign({}, u, v.params), pathname: C([ d, // Re-encode pathnames that were decoded inside matchRoutes a.encodeLocation ? a.encodeLocation(v.pathname).pathname : v.pathname ]), pathnameBase: v.pathnameBase === "/" ? d : C([ d, // Re-encode pathnames that were decoded inside matchRoutes a.encodeLocation ? a.encodeLocation(v.pathnameBase).pathname : v.pathnameBase ]) })), o, n, r); return t && E ? /* @__PURE__ */ s.createElement(B.Provider, { value: { location: _({ pathname: "/", search: "", hash: "", state: null, key: "default" }, m), navigationType: R.Pop } }, E) : E; } function je() { let e = Ae(), t = _e(e) ? e.status + " " + e.statusText : e instanceof Error ? e.message : JSON.stringify(e), n = e instanceof Error ? e.stack : null, r = "rgba(200,200,200, 0.5)", a = { padding: "0.5rem", backgroundColor: r }, o = { padding: "2px 4px", backgroundColor: r }, l = null; return process.env.NODE_ENV !== "production" && (console.error("Error handled by React Router default ErrorBoundary:", e), l = /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ s.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ s.createElement("code", { style: o }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ s.createElement("code", { style: o }, "errorElement"), " prop on your route."))), /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ s.createElement("h3", { style: { fontStyle: "italic" } }, t), n ? /* @__PURE__ */ s.createElement("pre", { style: a }, n) : null, l); } const We = /* @__PURE__ */ s.createElement(je, null); class $e extends s.Component { constructor(t) { super(t), this.state = { location: t.location, revalidation: t.revalidation, error: t.error }; } static getDerivedStateFromError(t) { return { error: t }; } static getDerivedStateFromProps(t, n) { return n.location !== t.location || n.revalidation !== "idle" && t.revalidation === "idle" ? { error: t.error, location: t.location, revalidation: t.revalidation } : { error: t.error !== void 0 ? t.error : n.error, location: n.location, revalidation: t.revalidation || n.revalidation }; } componentDidCatch(t, n) { console.error("React Router caught the following error during render", t, n); } render() { return this.state.error !== void 0 ? /* @__PURE__ */ s.createElement(P.Provider, { value: this.props.routeContext }, /* @__PURE__ */ s.createElement(M.Provider, { value: this.state.error, children: this.props.component })) : this.props.children; } } function Me(e) { let { routeContext: t, match: n, children: r } = e, a = s.useContext(U); return a && a.static && a.staticContext && (n.route.errorElement || n.route.ErrorBoundary) && (a.staticContext._deepestRenderedBoundaryId = n.route.id), /* @__PURE__ */ s.createElement(P.Provider, { value: t }, r); } function Fe(e, t, n, r) { var a; if (t === void 0 && (t = []), n === void 0 && (n = null), r === void 0 && (r = null), e == null) { var o; if (!n) return null; if (n.errors) e = n.matches; else if ((o = r) != null && o.v7_partialHydration && t.length === 0 && !n.initialized && n.matches.length > 0) e = n.matches; else return null; } let l = e, u = (a = n) == null ? void 0 : a.errors; if (u != null) { let h = l.findIndex((c) => c.route.id && (u == null ? void 0 : u[c.route.id]) !== void 0); h >= 0 || (process.env.NODE_ENV !== "production" ? f(!1, "Could not find a matching route for errors on route IDs: " + Object.keys(u).join(",")) : f(!1)), l = l.slice(0, Math.min(l.length, h + 1)); } let i = !1, d = -1; if (n && r && r.v7_partialHydration) for (let h = 0; h < l.length; h++) { let c = l[h]; if ((c.route.HydrateFallback || c.route.hydrateFallbackElement) && (d = h), c.route.id) { let { loaderData: m, errors: x } = n, y = c.route.loader && m[c.route.id] === void 0 && (!x || x[c.route.id] === void 0); if (c.route.lazy || y) { i = !0, d >= 0 ? l = l.slice(0, d + 1) : l = [l[0]]; break; } } } return l.reduceRight((h, c, m) => { let x, y = !1, g = null, p = null; n && (x = u && c.route.id ? u[c.route.id] : void 0, g = c.route.errorElement || We, i && (d < 0 && m === 0 ? (le("route-fallback", !1, "No `HydrateFallback` element provided to render during initial hydration"), y = !0, p = null) : d === m && (y = !0, p = c.route.hydrateFallbackElement || null))); let E = t.concat(l.slice(0, m + 1)), v = () => { let N; return x ? N = g : y ? N = p : c.route.Component ? N = /* @__PURE__ */ s.createElement(c.route.Component, null) : c.route.element ? N = c.route.element : N = h, /* @__PURE__ */ s.createElement(Me, { match: c, routeContext: { outlet: h, matches: E, isDataRoute: n != null }, children: N }); }; return n && (c.route.ErrorBoundary || c.route.errorElement || m === 0) ? /* @__PURE__ */ s.createElement($e, { location: n.location, revalidation: n.revalidation, component: g, error: x, children: v(), routeContext: { outlet: null, matches: E, isDataRoute: !0 } }) : v(); }, null); } var oe = /* @__PURE__ */ function(e) { return e.UseBlocker = "useBlocker", e.UseRevalidator = "useRevalidator", e.UseNavigateStable = "useNavigate", e; }(oe || {}), V = /* @__PURE__ */ function(e) { return e.UseBlocker = "useBlocker", e.UseLoaderData = "useLoaderData", e.UseActionData = "useActionData", e.UseRouteError = "useRouteError", e.UseNavigation = "useNavigation", e.UseRouteLoaderData = "useRouteLoaderData", e.UseMatches = "useMatches", e.UseRevalidator = "useRevalidator", e.UseNavigateStable = "useNavigate", e.UseRouteId = "useRouteId", e; }(V || {}); function k(e) { return e + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router."; } function ke(e) { let t = s.useContext(U); return t || (process.env.NODE_ENV !== "production" ? f(!1, k(e)) : f(!1)), t; } function Te(e) { let t = s.useContext(ne); return t || (process.env.NODE_ENV !== "production" ? f(!1, k(e)) : f(!1)), t; } function ze(e) { let t = s.useContext(P); return t || (process.env.NODE_ENV !== "production" ? f(!1, k(e)) : f(!1)), t; } function T(e) { let t = ze(e), n = t.matches[t.matches.length - 1]; return n.route.id || (process.env.NODE_ENV !== "production" ? f(!1, e + ' can only be used on routes that contain a unique "id"') : f(!1)), n.route.id; } function Ke() { return T(V.UseRouteId); } function Ae() { var e; let t = s.useContext(M), n = Te(V.UseRouteError), r = T(V.UseRouteError); return t !== void 0 ? t : (e = n.errors) == null ? void 0 : e[r]; } function Je() { let { router: e } = ke(oe.UseNavigateStable), t = T(V.UseNavigateStable), n = s.useRef(!1); return ae(() => { n.current = !0; }), s.useCallback(function(a, o) { o === void 0 && (o = {}), process.env.NODE_ENV !== "production" && b(n.current, re), n.current && (typeof a == "number" ? e.navigate(a) : e.navigate(a, _({ fromRouteId: t }, o))); }, [e, t]); } const q = {}; function le(e, t, n) { !t && !q[e] && (q[e] = !0, process.env.NODE_ENV !== "production" && b(!1, n)); } function He(e) { process.env.NODE_ENV !== "production" ? f(!1, "A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.") : f(!1); } function Xe(e) { let { basename: t = "/", children: n = null, location: r, navigationType: a = R.Pop, navigator: o, static: l = !1, future: u } = e; S() && (process.env.NODE_ENV !== "production" ? f(!1, "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.") : f(!1)); let i = t.replace(/^\/*/, "/"), d = s.useMemo(() => ({ basename: i, navigator: o, static: l, future: _({ v7_relativeSplatPath: !1 }, u) }), [i, u, o, l]); typeof r == "string" && (r = O(r)); let { pathname: h = "/", search: c = "", hash: m = "", state: x = null, key: y = "default" } = r, g = s.useMemo(() => { let p = Q(h, i); return p == null ? null : { location: { pathname: p, search: c, hash: m, state: x, key: y }, navigationType: a }; }, [i, h, c, m, x, y, a]); return process.env.NODE_ENV !== "production" && b(g != null, '<Router basename="' + i + '"> is not able to match the URL ' + ('"' + h + c + m + '" because it does not start with the ') + "basename, so the <Router> won't render anything."), g == null ? null : /* @__PURE__ */ s.createElement(w.Provider, { value: d }, /* @__PURE__ */ s.createElement(B.Provider, { children: n, value: g })); } function Qe(e) { let { children: t, location: n } = e; return Ue($(t), n); } new Promise(() => { }); function $(e, t) { t === void 0 && (t = []); let n = []; return s.Children.forEach(e, (r, a) => { if (!/* @__PURE__ */ s.isValidElement(r)) return; let o = [...t, a]; if (r.type === s.Fragment) { n.push.apply(n, $(r.props.children, o)); return; } r.type !== He && (process.env.NODE_ENV !== "production" ? f(!1, "[" + (typeof r.type == "string" ? r.type : r.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : f(!1)), !r.props.index || !r.props.children || (process.env.NODE_ENV !== "production" ? f(!1, "An index route cannot have child routes.") : f(!1)); let l = { id: r.props.id || o.join("-"), caseSensitive: r.props.caseSensitive, element: r.props.element, Component: r.props.Component, index: r.props.index, path: r.props.path, loader: r.props.loader, action: r.props.action, errorElement: r.props.errorElement, ErrorBoundary: r.props.ErrorBoundary, hasErrorBoundary: r.props.ErrorBoundary != null || r.props.errorElement != null, shouldRevalidate: r.props.shouldRevalidate, handle: r.props.handle, lazy: r.props.lazy }; r.props.children && (l.children = $(r.props.children, o)), n.push(l); }), n; } export { ne as D, w as N, Qe as R, He as a, Xe as b, Ye as c, Le as d, F as e, Ge as f, G as g, Ke as h, P as i, f as j, C as k, U as l, Y as m, Q as s, qe as u, b as w };