react-router 6.0.2 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export type { Location, Path, To, NavigationType };
11
11
  * to avoid "tearing" that may occur in a suspense-enabled app if the action
12
12
  * and/or location were to be read directly from the history instance.
13
13
  */
14
- export declare type Navigator = Omit<History, "action" | "location" | "back" | "forward" | "listen" | "block">;
14
+ export declare type Navigator = Pick<History, "go" | "push" | "replace" | "createHref">;
15
15
  interface NavigationContextObject {
16
16
  basename: string;
17
17
  navigator: Navigator;
@@ -56,13 +56,14 @@ export interface NavigateProps {
56
56
  */
57
57
  export declare function Navigate({ to, replace, state }: NavigateProps): null;
58
58
  export interface OutletProps {
59
+ context?: unknown;
59
60
  }
60
61
  /**
61
62
  * Renders the child route's element, if there is one.
62
63
  *
63
64
  * @see https://reactrouter.com/docs/en/v6/api#outlet
64
65
  */
65
- export declare function Outlet(_props: OutletProps): React.ReactElement | null;
66
+ export declare function Outlet(props: OutletProps): React.ReactElement | null;
66
67
  export interface RouteProps {
67
68
  caseSensitive?: boolean;
68
69
  children?: React.ReactNode;
@@ -144,6 +145,11 @@ export declare function useInRouterContext(): boolean;
144
145
  * @see https://reactrouter.com/docs/en/v6/api#uselocation
145
146
  */
146
147
  export declare function useLocation(): Location;
148
+ declare type ParamParseFailed = {
149
+ failed: true;
150
+ };
151
+ declare type ParamParseSegment<Segment extends string> = Segment extends `${infer LeftSegment}/${infer RightSegment}` ? ParamParseSegment<LeftSegment> extends infer LeftResult ? ParamParseSegment<RightSegment> extends infer RightResult ? LeftResult extends string ? RightResult extends string ? LeftResult | RightResult : LeftResult : RightResult extends string ? RightResult : ParamParseFailed : ParamParseFailed : ParamParseSegment<RightSegment> extends infer RightResult ? RightResult extends string ? RightResult : ParamParseFailed : ParamParseFailed : Segment extends `:${infer Remaining}` ? Remaining : ParamParseFailed;
152
+ declare type ParamParseKey<Segment extends string> = ParamParseSegment<Segment> extends string ? ParamParseSegment<Segment> : string;
147
153
  /**
148
154
  * Returns the current navigation action which describes how the router came to
149
155
  * the current location, either by a pop, push, or replace on the history stack.
@@ -158,7 +164,7 @@ export declare function useNavigationType(): NavigationType;
158
164
  *
159
165
  * @see https://reactrouter.com/docs/en/v6/api#usematch
160
166
  */
161
- export declare function useMatch<ParamKey extends string = string>(pattern: PathPattern | string): PathMatch<ParamKey> | null;
167
+ export declare function useMatch<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null;
162
168
  /**
163
169
  * The interface for the navigate() function returned from useNavigate().
164
170
  */
@@ -177,20 +183,28 @@ export interface NavigateOptions {
177
183
  * @see https://reactrouter.com/docs/en/v6/api#usenavigate
178
184
  */
179
185
  export declare function useNavigate(): NavigateFunction;
186
+ /**
187
+ * Returns the context (if provided) for the child route at this level of the route
188
+ * hierarchy.
189
+ * @see https://reactrouter.com/docs/en/v6/api#useoutletcontext
190
+ */
191
+ export declare function useOutletContext<Context = unknown>(): Context;
180
192
  /**
181
193
  * Returns the element for the child route at this level of the route
182
194
  * hierarchy. Used internally by <Outlet> to render child routes.
183
195
  *
184
196
  * @see https://reactrouter.com/docs/en/v6/api#useoutlet
185
197
  */
186
- export declare function useOutlet(): React.ReactElement | null;
198
+ export declare function useOutlet(context?: unknown): React.ReactElement | null;
187
199
  /**
188
200
  * Returns an object of key/value pairs of the dynamic params from the current
189
201
  * URL that were matched by the route path.
190
202
  *
191
203
  * @see https://reactrouter.com/docs/en/v6/api#useparams
192
204
  */
193
- export declare function useParams<Key extends string = string>(): Readonly<Params<Key>>;
205
+ export declare function useParams<ParamsOrKey extends string | Record<string, string | undefined> = string>(): Readonly<[
206
+ ParamsOrKey
207
+ ] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>>;
194
208
  /**
195
209
  * Resolves the pathname of the given `to` value against the current location.
196
210
  *
@@ -271,13 +285,13 @@ export declare function renderMatches(matches: RouteMatch[] | null): React.React
271
285
  /**
272
286
  * A PathPattern is used to match on some portion of a URL pathname.
273
287
  */
274
- export interface PathPattern {
288
+ export interface PathPattern<Path extends string = string> {
275
289
  /**
276
290
  * A string to match against a URL pathname. May contain `:id`-style segments
277
291
  * to indicate placeholders for dynamic parameters. May also end with `/*` to
278
292
  * indicate matching the rest of the URL pathname.
279
293
  */
280
- path: string;
294
+ path: Path;
281
295
  /**
282
296
  * Should be `true` if the static portions of the `path` should be matched in
283
297
  * the same case.
@@ -315,7 +329,7 @@ export interface PathMatch<ParamKey extends string = string> {
315
329
  *
316
330
  * @see https://reactrouter.com/docs/en/v6/api#matchpath
317
331
  */
318
- export declare function matchPath<ParamKey extends string = string>(pattern: PathPattern | string, pathname: string): PathMatch<ParamKey> | null;
332
+ export declare function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(pattern: PathPattern<Path> | Path, pathname: string): PathMatch<ParamKey> | null;
319
333
  /**
320
334
  * Returns a resolved path object relative to the given pathname.
321
335
  *
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v6.0.2
2
+ * React Router v6.1.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -147,8 +147,8 @@ function Navigate(_ref2) {
147
147
  *
148
148
  * @see https://reactrouter.com/docs/en/v6/api#outlet
149
149
  */
150
- function Outlet(_props) {
151
- return useOutlet();
150
+ function Outlet(props) {
151
+ return useOutlet(props.context);
152
152
  }
153
153
 
154
154
  /**
@@ -305,13 +305,13 @@ function useLocation() {
305
305
  "useLocation() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
306
306
  return useContext(LocationContext).location;
307
307
  }
308
+
308
309
  /**
309
310
  * Returns the current navigation action which describes how the router came to
310
311
  * the current location, either by a pop, push, or replace on the history stack.
311
312
  *
312
313
  * @see https://reactrouter.com/docs/en/v6/api#usenavigationtype
313
314
  */
314
-
315
315
  function useNavigationType() {
316
316
  return useContext(LocationContext).navigationType;
317
317
  }
@@ -327,7 +327,10 @@ function useMatch(pattern) {
327
327
  !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
328
328
  // router loaded. We can help them understand how to avoid that.
329
329
  "useMatch() may be used only in the context of a <Router> component.") : invariant(false) : void 0;
330
- return matchPath(pattern, useLocation().pathname);
330
+ let {
331
+ pathname
332
+ } = useLocation();
333
+ return useMemo(() => matchPath(pattern, pathname), [pathname, pattern]);
331
334
  }
332
335
  /**
333
336
  * The interface for the navigate() function returned from useNavigate().
@@ -381,6 +384,16 @@ function useNavigate() {
381
384
  }, [basename, navigator, routePathnamesJson, locationPathname]);
382
385
  return navigate;
383
386
  }
387
+ const OutletContext = /*#__PURE__*/createContext(null);
388
+ /**
389
+ * Returns the context (if provided) for the child route at this level of the route
390
+ * hierarchy.
391
+ * @see https://reactrouter.com/docs/en/v6/api#useoutletcontext
392
+ */
393
+
394
+ function useOutletContext() {
395
+ return useContext(OutletContext);
396
+ }
384
397
  /**
385
398
  * Returns the element for the child route at this level of the route
386
399
  * hierarchy. Used internally by <Outlet> to render child routes.
@@ -388,8 +401,11 @@ function useNavigate() {
388
401
  * @see https://reactrouter.com/docs/en/v6/api#useoutlet
389
402
  */
390
403
 
391
- function useOutlet() {
392
- return useContext(RouteContext).outlet;
404
+ function useOutlet(context) {
405
+ let outlet = useContext(RouteContext).outlet;
406
+ return /*#__PURE__*/createElement(OutletContext.Provider, {
407
+ value: context
408
+ }, outlet);
393
409
  }
394
410
  /**
395
411
  * Returns an object of key/value pairs of the dynamic params from the current
@@ -465,7 +481,7 @@ function useRoutes(routes, locationArg) {
465
481
  // );
466
482
  // }
467
483
  let parentPath = parentRoute && parentRoute.path || "";
468
- warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "You rendered descendant <Routes> (or called `useRoutes()`) at " + ("\"" + parentPathname + "\" (under <Route path=\"" + parentPath + "\">) 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.\n\n" + ("Please change the parent <Route path=\"" + parentPath + "\"> to <Route ") + ("path=\"" + parentPath + "/*\">."));
484
+ warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "You rendered descendant <Routes> (or called `useRoutes()`) at " + ("\"" + parentPathname + "\" (under <Route path=\"" + parentPath + "\">) 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.\n\n" + ("Please change the parent <Route path=\"" + parentPath + "\"> to <Route ") + ("path=\"" + (parentPath === "/" ? "*" : parentPath + "/*") + "\">."));
469
485
  }
470
486
 
471
487
  let locationFromContext = useLocation();
@@ -585,7 +601,7 @@ function matchRoutes(routes, locationArg, basename) {
585
601
  let matches = null;
586
602
 
587
603
  for (let i = 0; matches == null && i < branches.length; ++i) {
588
- matches = matchRouteBranch(branches[i], routes, pathname);
604
+ matches = matchRouteBranch(branches[i], pathname);
589
605
  }
590
606
 
591
607
  return matches;
@@ -608,7 +624,8 @@ function flattenRoutes(routes, branches, parentsMeta, parentPath) {
608
624
  let meta = {
609
625
  relativePath: route.path || "",
610
626
  caseSensitive: route.caseSensitive === true,
611
- childrenIndex: index
627
+ childrenIndex: index,
628
+ route
612
629
  };
613
630
 
614
631
  if (meta.relativePath.startsWith("/")) {
@@ -681,9 +698,7 @@ function compareIndexes(a, b) {
681
698
  0;
682
699
  }
683
700
 
684
- function matchRouteBranch(branch, // TODO: attach original route object inside routesMeta so we don't need this arg
685
- routesArg, pathname) {
686
- let routes = routesArg;
701
+ function matchRouteBranch(branch, pathname) {
687
702
  let {
688
703
  routesMeta
689
704
  } = branch;
@@ -702,7 +717,7 @@ routesArg, pathname) {
702
717
  }, remainingPathname);
703
718
  if (!match) return null;
704
719
  Object.assign(matchedParams, match.params);
705
- let route = routes[meta.childrenIndex];
720
+ let route = meta.route;
706
721
  matches.push({
707
722
  params: matchedParams,
708
723
  pathname: joinPaths([matchedPathname, match.pathname]),
@@ -713,8 +728,6 @@ routesArg, pathname) {
713
728
  if (match.pathnameBase !== "/") {
714
729
  matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
715
730
  }
716
-
717
- routes = route.children;
718
731
  }
719
732
 
720
733
  return matches;
@@ -814,10 +827,10 @@ function compilePath(path, caseSensitive, end) {
814
827
  : "(?:\\/(.+)|\\/*)$"; // Don't include the / in params["*"]
815
828
  } else {
816
829
  regexpSource += end ? "\\/*$" // When matching to the end, ignore trailing slashes
817
- : // Otherwise, at least match a word boundary. This restricts parent
818
- // routes to matching only their own words and nothing more, e.g. parent
830
+ : // Otherwise, match a word boundary or a proceeding /. The word boundary restricts
831
+ // parent routes to matching only their own words and nothing more, e.g. parent
819
832
  // route "/home" should not match "/home2".
820
- "(?:\\b|$)";
833
+ "(?:\\b|\\/|$)";
821
834
  }
822
835
 
823
836
  let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
@@ -945,5 +958,5 @@ const normalizeSearch = search => !search || search === "?" ? "" : search.starts
945
958
 
946
959
  const normalizeHash = hash => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash; ///////////////////////////////////////////////////////////////////////////////
947
960
 
948
- export { MemoryRouter, Navigate, Outlet, Route, Router, Routes, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createRoutesFromChildren, generatePath, matchPath, matchRoutes, renderMatches, resolvePath, useHref, useInRouterContext, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useRoutes };
961
+ export { MemoryRouter, Navigate, Outlet, Route, Router, Routes, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, createRoutesFromChildren, generatePath, matchPath, matchRoutes, renderMatches, resolvePath, useHref, useInRouterContext, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes };
949
962
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../packages/react-router/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type {\n History,\n InitialEntry,\n Location,\n MemoryHistory,\n Path,\n To\n} from \"history\";\nimport {\n Action as NavigationType,\n createMemoryHistory,\n parsePath\n} from \"history\";\n\nexport type { Location, Path, To, NavigationType };\n\nfunction invariant(cond: any, message: string): asserts cond {\n if (!cond) throw new Error(message);\n}\n\nfunction warning(cond: any, message: string): void {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging React Router!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nconst alreadyWarned: Record<string, boolean> = {};\nfunction warningOnce(key: string, cond: boolean, message: string) {\n if (!cond && !alreadyWarned[key]) {\n alreadyWarned[key] = true;\n warning(false, message);\n }\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// CONTEXT\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * A Navigator is a \"location changer\"; it's how you get to different locations.\n *\n * Every history instance conforms to the Navigator interface, but the\n * distinction is useful primarily when it comes to the low-level <Router> API\n * where both the location and a navigator must be provided separately in order\n * to avoid \"tearing\" that may occur in a suspense-enabled app if the action\n * and/or location were to be read directly from the history instance.\n */\nexport type Navigator = Omit<\n History,\n \"action\" | \"location\" | \"back\" | \"forward\" | \"listen\" | \"block\"\n>;\n\ninterface NavigationContextObject {\n basename: string;\n navigator: Navigator;\n static: boolean;\n}\n\nconst NavigationContext = React.createContext<NavigationContextObject>(null!);\n\nif (__DEV__) {\n NavigationContext.displayName = \"Navigation\";\n}\n\ninterface LocationContextObject {\n location: Location;\n navigationType: NavigationType;\n}\n\nconst LocationContext = React.createContext<LocationContextObject>(null!);\n\nif (__DEV__) {\n LocationContext.displayName = \"Location\";\n}\n\ninterface RouteContextObject {\n outlet: React.ReactElement | null;\n matches: RouteMatch[];\n}\n\nconst RouteContext = React.createContext<RouteContextObject>({\n outlet: null,\n matches: []\n});\n\nif (__DEV__) {\n RouteContext.displayName = \"Route\";\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// COMPONENTS\n///////////////////////////////////////////////////////////////////////////////\n\nexport interface MemoryRouterProps {\n basename?: string;\n children?: React.ReactNode;\n initialEntries?: InitialEntry[];\n initialIndex?: number;\n}\n\n/**\n * A <Router> that stores all entries in memory.\n *\n * @see https://reactrouter.com/docs/en/v6/api#memoryrouter\n */\nexport function MemoryRouter({\n basename,\n children,\n initialEntries,\n initialIndex\n}: MemoryRouterProps): React.ReactElement {\n let historyRef = React.useRef<MemoryHistory>();\n if (historyRef.current == null) {\n historyRef.current = createMemoryHistory({ initialEntries, initialIndex });\n }\n\n let history = historyRef.current;\n let [state, setState] = React.useState({\n action: history.action,\n location: history.location\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nexport interface NavigateProps {\n to: To;\n replace?: boolean;\n state?: any;\n}\n\n/**\n * Changes the current location.\n *\n * Note: This API is mostly useful in React.Component subclasses that are not\n * able to use hooks. In functional components, we recommend you use the\n * `useNavigate` hook instead.\n *\n * @see https://reactrouter.com/docs/en/v6/api#navigate\n */\nexport function Navigate({ to, replace, state }: NavigateProps): null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of\n // the router loaded. We can help them understand how to avoid that.\n `<Navigate> may be used only in the context of a <Router> component.`\n );\n\n warning(\n !React.useContext(NavigationContext).static,\n `<Navigate> must not be used on the initial render in a <StaticRouter>. ` +\n `This is a no-op, but you should modify your code so the <Navigate> is ` +\n `only ever rendered in response to some user interaction or state change.`\n );\n\n let navigate = useNavigate();\n React.useEffect(() => {\n navigate(to, { replace, state });\n });\n\n return null;\n}\n\nexport interface OutletProps {}\n\n/**\n * Renders the child route's element, if there is one.\n *\n * @see https://reactrouter.com/docs/en/v6/api#outlet\n */\nexport function Outlet(_props: OutletProps): React.ReactElement | null {\n return useOutlet();\n}\n\nexport interface RouteProps {\n caseSensitive?: boolean;\n children?: React.ReactNode;\n element?: React.ReactElement | null;\n index?: boolean;\n path?: string;\n}\n\nexport interface PathRouteProps {\n caseSensitive?: boolean;\n children?: React.ReactNode;\n element?: React.ReactElement | null;\n index?: false;\n path: string;\n}\n\nexport interface LayoutRouteProps {\n children?: React.ReactNode;\n element?: React.ReactElement | null;\n}\n\nexport interface IndexRouteProps {\n element?: React.ReactElement | null;\n index: true;\n}\n\n/**\n * Declares an element that should be rendered at a certain URL path.\n *\n * @see https://reactrouter.com/docs/en/v6/api#route\n */\nexport function Route(\n _props: PathRouteProps | LayoutRouteProps | IndexRouteProps\n): React.ReactElement | null {\n invariant(\n false,\n `A <Route> is only ever to be used as the child of <Routes> element, ` +\n `never rendered directly. Please wrap your <Route> in a <Routes>.`\n );\n}\n\nexport interface RouterProps {\n basename?: string;\n children?: React.ReactNode;\n location: Partial<Location> | string;\n navigationType?: NavigationType;\n navigator: Navigator;\n static?: boolean;\n}\n\n/**\n * Provides location context for the rest of the app.\n *\n * Note: You usually won't render a <Router> directly. Instead, you'll render a\n * router that is more specific to your environment such as a <BrowserRouter>\n * in web browsers or a <StaticRouter> for server rendering.\n *\n * @see https://reactrouter.com/docs/en/v6/api#router\n */\nexport function Router({\n basename: basenameProp = \"/\",\n children = null,\n location: locationProp,\n navigationType = NavigationType.Pop,\n navigator,\n static: staticProp = false\n}: RouterProps): React.ReactElement | null {\n invariant(\n !useInRouterContext(),\n `You cannot render a <Router> inside another <Router>.` +\n ` You should never have more than one in your app.`\n );\n\n let basename = normalizePathname(basenameProp);\n let navigationContext = React.useMemo(\n () => ({ basename, navigator, static: staticProp }),\n [basename, navigator, staticProp]\n );\n\n if (typeof locationProp === \"string\") {\n locationProp = parsePath(locationProp);\n }\n\n let {\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n state = null,\n key = \"default\"\n } = locationProp;\n\n let location = React.useMemo(() => {\n let trailingPathname = stripBasename(pathname, basename);\n\n if (trailingPathname == null) {\n return null;\n }\n\n return {\n pathname: trailingPathname,\n search,\n hash,\n state,\n key\n };\n }, [basename, pathname, search, hash, state, key]);\n\n warning(\n location != null,\n `<Router basename=\"${basename}\"> is not able to match the URL ` +\n `\"${pathname}${search}${hash}\" because it does not start with the ` +\n `basename, so the <Router> won't render anything.`\n );\n\n if (location == null) {\n return null;\n }\n\n return (\n <NavigationContext.Provider value={navigationContext}>\n <LocationContext.Provider\n children={children}\n value={{ location, navigationType }}\n />\n </NavigationContext.Provider>\n );\n}\n\nexport interface RoutesProps {\n children?: React.ReactNode;\n location?: Partial<Location> | string;\n}\n\n/**\n * A container for a nested tree of <Route> elements that renders the branch\n * that best matches the current location.\n *\n * @see https://reactrouter.com/docs/en/v6/api#routes\n */\nexport function Routes({\n children,\n location\n}: RoutesProps): React.ReactElement | null {\n return useRoutes(createRoutesFromChildren(children), location);\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// HOOKS\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * Returns the full href for the given \"to\" value. This is useful for building\n * custom links that are also accessible and preserve right-click behavior.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usehref\n */\nexport function useHref(to: To): string {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useHref() may be used only in the context of a <Router> component.`\n );\n\n let { basename, navigator } = React.useContext(NavigationContext);\n let { hash, pathname, search } = useResolvedPath(to);\n\n let joinedPathname = pathname;\n if (basename !== \"/\") {\n let toPathname = getToPathname(to);\n let endsWithSlash = toPathname != null && toPathname.endsWith(\"/\");\n joinedPathname =\n pathname === \"/\"\n ? basename + (endsWithSlash ? \"/\" : \"\")\n : joinPaths([basename, pathname]);\n }\n\n return navigator.createHref({ pathname: joinedPathname, search, hash });\n}\n\n/**\n * Returns true if this component is a descendant of a <Router>.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useinroutercontext\n */\nexport function useInRouterContext(): boolean {\n return React.useContext(LocationContext) != null;\n}\n\n/**\n * Returns the current location object, which represents the current URL in web\n * browsers.\n *\n * Note: If you're using this it may mean you're doing some of your own\n * \"routing\" in your app, and we'd like to know what your use case is. We may\n * be able to provide something higher-level to better suit your needs.\n *\n * @see https://reactrouter.com/docs/en/v6/api#uselocation\n */\nexport function useLocation(): Location {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useLocation() may be used only in the context of a <Router> component.`\n );\n\n return React.useContext(LocationContext).location;\n}\n\n/**\n * Returns the current navigation action which describes how the router came to\n * the current location, either by a pop, push, or replace on the history stack.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usenavigationtype\n */\nexport function useNavigationType(): NavigationType {\n return React.useContext(LocationContext).navigationType;\n}\n\n/**\n * Returns true if the URL for the given \"to\" value matches the current URL.\n * This is useful for components that need to know \"active\" state, e.g.\n * <NavLink>.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usematch\n */\nexport function useMatch<ParamKey extends string = string>(\n pattern: PathPattern | string\n): PathMatch<ParamKey> | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useMatch() may be used only in the context of a <Router> component.`\n );\n\n return matchPath(pattern, useLocation().pathname);\n}\n\n/**\n * The interface for the navigate() function returned from useNavigate().\n */\nexport interface NavigateFunction {\n (to: To, options?: NavigateOptions): void;\n (delta: number): void;\n}\n\nexport interface NavigateOptions {\n replace?: boolean;\n state?: any;\n}\n\n/**\n * Returns an imperative method for changing the location. Used by <Link>s, but\n * may also be used by other elements to change the location.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usenavigate\n */\nexport function useNavigate(): NavigateFunction {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useNavigate() may be used only in the context of a <Router> component.`\n );\n\n let { basename, navigator } = React.useContext(NavigationContext);\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n matches.map(match => match.pathnameBase)\n );\n\n let activeRef = React.useRef(false);\n React.useEffect(() => {\n activeRef.current = true;\n });\n\n let navigate: NavigateFunction = React.useCallback(\n (to: To | number, options: { replace?: boolean; state?: any } = {}) => {\n warning(\n activeRef.current,\n `You should call navigate() in a React.useEffect(), not when ` +\n `your component is first rendered.`\n );\n\n if (!activeRef.current) return;\n\n if (typeof to === \"number\") {\n navigator.go(to);\n return;\n }\n\n let path = resolveTo(\n to,\n JSON.parse(routePathnamesJson),\n locationPathname\n );\n\n if (basename !== \"/\") {\n path.pathname = joinPaths([basename, path.pathname]);\n }\n\n (!!options.replace ? navigator.replace : navigator.push)(\n path,\n options.state\n );\n },\n [basename, navigator, routePathnamesJson, locationPathname]\n );\n\n return navigate;\n}\n\n/**\n * Returns the element for the child route at this level of the route\n * hierarchy. Used internally by <Outlet> to render child routes.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useoutlet\n */\nexport function useOutlet(): React.ReactElement | null {\n return React.useContext(RouteContext).outlet;\n}\n\n/**\n * Returns an object of key/value pairs of the dynamic params from the current\n * URL that were matched by the route path.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useparams\n */\nexport function useParams<Key extends string = string>(): Readonly<\n Params<Key>\n> {\n let { matches } = React.useContext(RouteContext);\n let routeMatch = matches[matches.length - 1];\n return routeMatch ? (routeMatch.params as any) : {};\n}\n\n/**\n * Resolves the pathname of the given `to` value against the current location.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useresolvedpath\n */\nexport function useResolvedPath(to: To): Path {\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n matches.map(match => match.pathnameBase)\n );\n\n return React.useMemo(\n () => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname),\n [to, routePathnamesJson, locationPathname]\n );\n}\n\n/**\n * Returns the element of the route that matched the current location, prepared\n * with the correct context to render the remainder of the route tree. Route\n * elements in the tree must render an <Outlet> to render their child route's\n * element.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useroutes\n */\nexport function useRoutes(\n routes: RouteObject[],\n locationArg?: Partial<Location> | string\n): React.ReactElement | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useRoutes() may be used only in the context of a <Router> component.`\n );\n\n let { matches: parentMatches } = React.useContext(RouteContext);\n let routeMatch = parentMatches[parentMatches.length - 1];\n let parentParams = routeMatch ? routeMatch.params : {};\n let parentPathname = routeMatch ? routeMatch.pathname : \"/\";\n let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : \"/\";\n let parentRoute = routeMatch && routeMatch.route;\n\n if (__DEV__) {\n // You won't get a warning about 2 different <Routes> under a <Route>\n // without a trailing *, but this is a best-effort warning anyway since we\n // cannot even give the warning unless they land at the parent route.\n //\n // Example:\n //\n // <Routes>\n // {/* This route path MUST end with /* because otherwise\n // it will never match /blog/post/123 */}\n // <Route path=\"blog\" element={<Blog />} />\n // <Route path=\"blog/feed\" element={<BlogFeed />} />\n // </Routes>\n //\n // function Blog() {\n // return (\n // <Routes>\n // <Route path=\"post/:id\" element={<Post />} />\n // </Routes>\n // );\n // }\n let parentPath = (parentRoute && parentRoute.path) || \"\";\n warningOnce(\n parentPathname,\n !parentRoute || parentPath.endsWith(\"*\"),\n `You rendered descendant <Routes> (or called \\`useRoutes()\\`) at ` +\n `\"${parentPathname}\" (under <Route path=\"${parentPath}\">) but the ` +\n `parent route path has no trailing \"*\". This means if you navigate ` +\n `deeper, the parent won't match anymore and therefore the child ` +\n `routes will never render.\\n\\n` +\n `Please change the parent <Route path=\"${parentPath}\"> to <Route ` +\n `path=\"${parentPath}/*\">.`\n );\n }\n\n let locationFromContext = useLocation();\n\n let location;\n if (locationArg) {\n let parsedLocationArg =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n invariant(\n parentPathnameBase === \"/\" ||\n parsedLocationArg.pathname?.startsWith(parentPathnameBase),\n `When overriding the location using \\`<Routes location>\\` or \\`useRoutes(routes, location)\\`, ` +\n `the location pathname must begin with the portion of the URL pathname that was ` +\n `matched by all parent routes. The current pathname base is \"${parentPathnameBase}\" ` +\n `but pathname \"${parsedLocationArg.pathname}\" was given in the \\`location\\` prop.`\n );\n\n location = parsedLocationArg;\n } else {\n location = locationFromContext;\n }\n\n let pathname = location.pathname || \"/\";\n let remainingPathname =\n parentPathnameBase === \"/\"\n ? pathname\n : pathname.slice(parentPathnameBase.length) || \"/\";\n let matches = matchRoutes(routes, { pathname: remainingPathname });\n\n if (__DEV__) {\n warning(\n parentRoute || matches != null,\n `No routes matched location \"${location.pathname}${location.search}${location.hash}\" `\n );\n\n warning(\n matches == null ||\n matches[matches.length - 1].route.element !== undefined,\n `Matched leaf route at location \"${location.pathname}${location.search}${location.hash}\" does not have an element. ` +\n `This means it will render an <Outlet /> with a null value by default resulting in an \"empty\" page.`\n );\n }\n\n return _renderMatches(\n matches &&\n matches.map(match =>\n Object.assign({}, match, {\n params: Object.assign({}, parentParams, match.params),\n pathname: joinPaths([parentPathnameBase, match.pathname]),\n pathnameBase:\n match.pathnameBase === \"/\"\n ? parentPathnameBase\n : joinPaths([parentPathnameBase, match.pathnameBase])\n })\n ),\n parentMatches\n );\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// UTILS\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * Creates a route config from a React \"children\" object, which is usually\n * either a `<Route>` element or an array of them. Used internally by\n * `<Routes>` to create a route config from its children.\n *\n * @see https://reactrouter.com/docs/en/v6/api#createroutesfromchildren\n */\nexport function createRoutesFromChildren(\n children: React.ReactNode\n): RouteObject[] {\n let routes: RouteObject[] = [];\n\n React.Children.forEach(children, element => {\n if (!React.isValidElement(element)) {\n // Ignore non-elements. This allows people to more easily inline\n // conditionals in their route config.\n return;\n }\n\n if (element.type === React.Fragment) {\n // Transparently support React.Fragment and its children.\n routes.push.apply(\n routes,\n createRoutesFromChildren(element.props.children)\n );\n return;\n }\n\n invariant(\n element.type === Route,\n `[${\n typeof element.type === \"string\" ? element.type : element.type.name\n }] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`\n );\n\n let route: RouteObject = {\n caseSensitive: element.props.caseSensitive,\n element: element.props.element,\n index: element.props.index,\n path: element.props.path\n };\n\n if (element.props.children) {\n route.children = createRoutesFromChildren(element.props.children);\n }\n\n routes.push(route);\n });\n\n return routes;\n}\n\n/**\n * The parameters that were parsed from the URL path.\n */\nexport type Params<Key extends string = string> = {\n readonly [key in Key]: string | undefined;\n};\n\n/**\n * A route object represents a logical route, with (optionally) its child\n * routes organized in a tree-like structure.\n */\nexport interface RouteObject {\n caseSensitive?: boolean;\n children?: RouteObject[];\n element?: React.ReactNode;\n index?: boolean;\n path?: string;\n}\n\n/**\n * Returns a path with params interpolated.\n *\n * @see https://reactrouter.com/docs/en/v6/api#generatepath\n */\nexport function generatePath(path: string, params: Params = {}): string {\n return path\n .replace(/:(\\w+)/g, (_, key) => {\n invariant(params[key] != null, `Missing \":${key}\" param`);\n return params[key]!;\n })\n .replace(/\\/*\\*$/, _ =>\n params[\"*\"] == null ? \"\" : params[\"*\"].replace(/^\\/*/, \"/\")\n );\n}\n\n/**\n * A RouteMatch contains info about how a route matched a URL.\n */\nexport interface RouteMatch<ParamKey extends string = string> {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params<ParamKey>;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The route object that was used to match.\n */\n route: RouteObject;\n}\n\n/**\n * Matches the given routes to a location and returns the match data.\n *\n * @see https://reactrouter.com/docs/en/v6/api#matchroutes\n */\nexport function matchRoutes(\n routes: RouteObject[],\n locationArg: Partial<Location> | string,\n basename = \"/\"\n): RouteMatch[] | null {\n let location =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n let pathname = stripBasename(location.pathname || \"/\", basename);\n\n if (pathname == null) {\n return null;\n }\n\n let branches = flattenRoutes(routes);\n rankRouteBranches(branches);\n\n let matches = null;\n for (let i = 0; matches == null && i < branches.length; ++i) {\n matches = matchRouteBranch(branches[i], routes, pathname);\n }\n\n return matches;\n}\n\ninterface RouteMeta {\n relativePath: string;\n caseSensitive: boolean;\n childrenIndex: number;\n}\n\ninterface RouteBranch {\n path: string;\n score: number;\n routesMeta: RouteMeta[];\n}\n\nfunction flattenRoutes(\n routes: RouteObject[],\n branches: RouteBranch[] = [],\n parentsMeta: RouteMeta[] = [],\n parentPath = \"\"\n): RouteBranch[] {\n routes.forEach((route, index) => {\n let meta: RouteMeta = {\n relativePath: route.path || \"\",\n caseSensitive: route.caseSensitive === true,\n childrenIndex: index\n };\n\n if (meta.relativePath.startsWith(\"/\")) {\n invariant(\n meta.relativePath.startsWith(parentPath),\n `Absolute route path \"${meta.relativePath}\" nested under path ` +\n `\"${parentPath}\" is not valid. An absolute child route path ` +\n `must start with the combined path of all its parent routes.`\n );\n\n meta.relativePath = meta.relativePath.slice(parentPath.length);\n }\n\n let path = joinPaths([parentPath, meta.relativePath]);\n let routesMeta = parentsMeta.concat(meta);\n\n // Add the children before adding this route to the array so we traverse the\n // route tree depth-first and child routes appear before their parents in\n // the \"flattened\" version.\n if (route.children && route.children.length > 0) {\n invariant(\n route.index !== true,\n `Index routes must not have child routes. Please remove ` +\n `all child routes from route path \"${path}\".`\n );\n\n flattenRoutes(route.children, branches, routesMeta, path);\n }\n\n // Routes without a path shouldn't ever match by themselves unless they are\n // index routes, so don't add them to the list of possible branches.\n if (route.path == null && !route.index) {\n return;\n }\n\n branches.push({ path, score: computeScore(path, route.index), routesMeta });\n });\n\n return branches;\n}\n\nfunction rankRouteBranches(branches: RouteBranch[]): void {\n branches.sort((a, b) =>\n a.score !== b.score\n ? b.score - a.score // Higher score first\n : compareIndexes(\n a.routesMeta.map(meta => meta.childrenIndex),\n b.routesMeta.map(meta => meta.childrenIndex)\n )\n );\n}\n\nconst paramRe = /^:\\w+$/;\nconst dynamicSegmentValue = 3;\nconst indexRouteValue = 2;\nconst emptySegmentValue = 1;\nconst staticSegmentValue = 10;\nconst splatPenalty = -2;\nconst isSplat = (s: string) => s === \"*\";\n\nfunction computeScore(path: string, index: boolean | undefined): number {\n let segments = path.split(\"/\");\n let initialScore = segments.length;\n if (segments.some(isSplat)) {\n initialScore += splatPenalty;\n }\n\n if (index) {\n initialScore += indexRouteValue;\n }\n\n return segments\n .filter(s => !isSplat(s))\n .reduce(\n (score, segment) =>\n score +\n (paramRe.test(segment)\n ? dynamicSegmentValue\n : segment === \"\"\n ? emptySegmentValue\n : staticSegmentValue),\n initialScore\n );\n}\n\nfunction compareIndexes(a: number[], b: number[]): number {\n let siblings =\n a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);\n\n return siblings\n ? // If two routes are siblings, we should try to match the earlier sibling\n // first. This allows people to have fine-grained control over the matching\n // behavior by simply putting routes with identical paths in the order they\n // want them tried.\n a[a.length - 1] - b[b.length - 1]\n : // Otherwise, it doesn't really make sense to rank non-siblings by index,\n // so they sort equally.\n 0;\n}\n\nfunction matchRouteBranch<ParamKey extends string = string>(\n branch: RouteBranch,\n // TODO: attach original route object inside routesMeta so we don't need this arg\n routesArg: RouteObject[],\n pathname: string\n): RouteMatch<ParamKey>[] | null {\n let routes = routesArg;\n let { routesMeta } = branch;\n\n let matchedParams = {};\n let matchedPathname = \"/\";\n let matches: RouteMatch[] = [];\n for (let i = 0; i < routesMeta.length; ++i) {\n let meta = routesMeta[i];\n let end = i === routesMeta.length - 1;\n let remainingPathname =\n matchedPathname === \"/\"\n ? pathname\n : pathname.slice(matchedPathname.length) || \"/\";\n let match = matchPath(\n { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },\n remainingPathname\n );\n\n if (!match) return null;\n\n Object.assign(matchedParams, match.params);\n\n let route = routes[meta.childrenIndex];\n\n matches.push({\n params: matchedParams,\n pathname: joinPaths([matchedPathname, match.pathname]),\n pathnameBase: joinPaths([matchedPathname, match.pathnameBase]),\n route\n });\n\n if (match.pathnameBase !== \"/\") {\n matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);\n }\n\n routes = route.children!;\n }\n\n return matches;\n}\n\n/**\n * Renders the result of `matchRoutes()` into a React element.\n */\nexport function renderMatches(\n matches: RouteMatch[] | null\n): React.ReactElement | null {\n return _renderMatches(matches);\n}\n\nfunction _renderMatches(\n matches: RouteMatch[] | null,\n parentMatches: RouteMatch[] = []\n): React.ReactElement | null {\n if (matches == null) return null;\n\n return matches.reduceRight((outlet, match, index) => {\n return (\n <RouteContext.Provider\n children={\n match.route.element !== undefined ? match.route.element : <Outlet />\n }\n value={{\n outlet,\n matches: parentMatches.concat(matches.slice(0, index + 1))\n }}\n />\n );\n }, null as React.ReactElement | null);\n}\n\n/**\n * A PathPattern is used to match on some portion of a URL pathname.\n */\nexport interface PathPattern {\n /**\n * A string to match against a URL pathname. May contain `:id`-style segments\n * to indicate placeholders for dynamic parameters. May also end with `/*` to\n * indicate matching the rest of the URL pathname.\n */\n path: string;\n /**\n * Should be `true` if the static portions of the `path` should be matched in\n * the same case.\n */\n caseSensitive?: boolean;\n /**\n * Should be `true` if this pattern should match the entire URL pathname.\n */\n end?: boolean;\n}\n\n/**\n * A PathMatch contains info about how a PathPattern matched on a URL pathname.\n */\nexport interface PathMatch<ParamKey extends string = string> {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params<ParamKey>;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The pattern that was used to match.\n */\n pattern: PathPattern;\n}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * Performs pattern matching on a URL pathname and returns information about\n * the match.\n *\n * @see https://reactrouter.com/docs/en/v6/api#matchpath\n */\nexport function matchPath<ParamKey extends string = string>(\n pattern: PathPattern | string,\n pathname: string\n): PathMatch<ParamKey> | null {\n if (typeof pattern === \"string\") {\n pattern = { path: pattern, caseSensitive: false, end: true };\n }\n\n let [matcher, paramNames] = compilePath(\n pattern.path,\n pattern.caseSensitive,\n pattern.end\n );\n\n let match = pathname.match(matcher);\n if (!match) return null;\n\n let matchedPathname = match[0];\n let pathnameBase = matchedPathname.replace(/(.)\\/+$/, \"$1\");\n let captureGroups = match.slice(1);\n let params: Params = paramNames.reduce<Mutable<Params>>(\n (memo, paramName, index) => {\n // We need to compute the pathnameBase here using the raw splat value\n // instead of using params[\"*\"] later because it will be decoded then\n if (paramName === \"*\") {\n let splatValue = captureGroups[index] || \"\";\n pathnameBase = matchedPathname\n .slice(0, matchedPathname.length - splatValue.length)\n .replace(/(.)\\/+$/, \"$1\");\n }\n\n memo[paramName] = safelyDecodeURIComponent(\n captureGroups[index] || \"\",\n paramName\n );\n return memo;\n },\n {}\n );\n\n return {\n params,\n pathname: matchedPathname,\n pathnameBase,\n pattern\n };\n}\n\nfunction compilePath(\n path: string,\n caseSensitive = false,\n end = true\n): [RegExp, string[]] {\n warning(\n path === \"*\" || !path.endsWith(\"*\") || path.endsWith(\"/*\"),\n `Route path \"${path}\" will be treated as if it were ` +\n `\"${path.replace(/\\*$/, \"/*\")}\" because the \\`*\\` character must ` +\n `always follow a \\`/\\` in the pattern. To get rid of this warning, ` +\n `please change the route path to \"${path.replace(/\\*$/, \"/*\")}\".`\n );\n\n let paramNames: string[] = [];\n let regexpSource =\n \"^\" +\n path\n .replace(/\\/*\\*?$/, \"\") // Ignore trailing / and /*, we'll handle it below\n .replace(/^\\/*/, \"/\") // Make sure it has a leading /\n .replace(/[\\\\.*+^$?{}|()[\\]]/g, \"\\\\$&\") // Escape special regex chars\n .replace(/:(\\w+)/g, (_: string, paramName: string) => {\n paramNames.push(paramName);\n return \"([^\\\\/]+)\";\n });\n\n if (path.endsWith(\"*\")) {\n paramNames.push(\"*\");\n regexpSource +=\n path === \"*\" || path === \"/*\"\n ? \"(.*)$\" // Already matched the initial /, just match the rest\n : \"(?:\\\\/(.+)|\\\\/*)$\"; // Don't include the / in params[\"*\"]\n } else {\n regexpSource += end\n ? \"\\\\/*$\" // When matching to the end, ignore trailing slashes\n : // Otherwise, at least match a word boundary. This restricts parent\n // routes to matching only their own words and nothing more, e.g. parent\n // route \"/home\" should not match \"/home2\".\n \"(?:\\\\b|$)\";\n }\n\n let matcher = new RegExp(regexpSource, caseSensitive ? undefined : \"i\");\n\n return [matcher, paramNames];\n}\n\nfunction safelyDecodeURIComponent(value: string, paramName: string) {\n try {\n return decodeURIComponent(value);\n } catch (error) {\n warning(\n false,\n `The value for the URL param \"${paramName}\" will not be decoded because` +\n ` the string \"${value}\" is a malformed URL segment. This is probably` +\n ` due to a bad percent encoding (${error}).`\n );\n\n return value;\n }\n}\n\n/**\n * Returns a resolved path object relative to the given pathname.\n *\n * @see https://reactrouter.com/docs/en/v6/api#resolvepath\n */\nexport function resolvePath(to: To, fromPathname = \"/\"): Path {\n let {\n pathname: toPathname,\n search = \"\",\n hash = \"\"\n } = typeof to === \"string\" ? parsePath(to) : to;\n\n let pathname = toPathname\n ? toPathname.startsWith(\"/\")\n ? toPathname\n : resolvePathname(toPathname, fromPathname)\n : fromPathname;\n\n return {\n pathname,\n search: normalizeSearch(search),\n hash: normalizeHash(hash)\n };\n}\n\nfunction resolvePathname(relativePath: string, fromPathname: string): string {\n let segments = fromPathname.replace(/\\/+$/, \"\").split(\"/\");\n let relativeSegments = relativePath.split(\"/\");\n\n relativeSegments.forEach(segment => {\n if (segment === \"..\") {\n // Keep the root \"\" segment so the pathname starts at /\n if (segments.length > 1) segments.pop();\n } else if (segment !== \".\") {\n segments.push(segment);\n }\n });\n\n return segments.length > 1 ? segments.join(\"/\") : \"/\";\n}\n\nfunction resolveTo(\n toArg: To,\n routePathnames: string[],\n locationPathname: string\n): Path {\n let to = typeof toArg === \"string\" ? parsePath(toArg) : toArg;\n let toPathname = toArg === \"\" || to.pathname === \"\" ? \"/\" : to.pathname;\n\n // If a pathname is explicitly provided in `to`, it should be relative to the\n // route context. This is explained in `Note on `<Link to>` values` in our\n // migration guide from v5 as a means of disambiguation between `to` values\n // that begin with `/` and those that do not. However, this is problematic for\n // `to` values that do not provide a pathname. `to` can simply be a search or\n // hash string, in which case we should assume that the navigation is relative\n // to the current location's pathname and *not* the route pathname.\n let from: string;\n if (toPathname == null) {\n from = locationPathname;\n } else {\n let routePathnameIndex = routePathnames.length - 1;\n\n if (toPathname.startsWith(\"..\")) {\n let toSegments = toPathname.split(\"/\");\n\n // Each leading .. segment means \"go up one route\" instead of \"go up one\n // URL segment\". This is a key difference from how <a href> works and a\n // major reason we call this a \"to\" value instead of a \"href\".\n while (toSegments[0] === \"..\") {\n toSegments.shift();\n routePathnameIndex -= 1;\n }\n\n to.pathname = toSegments.join(\"/\");\n }\n\n // If there are more \"..\" segments than parent routes, resolve relative to\n // the root / URL.\n from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : \"/\";\n }\n\n let path = resolvePath(to, from);\n\n // Ensure the pathname has a trailing slash if the original to value had one.\n if (\n toPathname &&\n toPathname !== \"/\" &&\n toPathname.endsWith(\"/\") &&\n !path.pathname.endsWith(\"/\")\n ) {\n path.pathname += \"/\";\n }\n\n return path;\n}\n\nfunction getToPathname(to: To): string | undefined {\n // Empty strings should be treated the same as / paths\n return to === \"\" || (to as Path).pathname === \"\"\n ? \"/\"\n : typeof to === \"string\"\n ? parsePath(to).pathname\n : to.pathname;\n}\n\nfunction stripBasename(pathname: string, basename: string): string | null {\n if (basename === \"/\") return pathname;\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return null;\n }\n\n let nextChar = pathname.charAt(basename.length);\n if (nextChar && nextChar !== \"/\") {\n // pathname does not start with basename/\n return null;\n }\n\n return pathname.slice(basename.length) || \"/\";\n}\n\nconst joinPaths = (paths: string[]): string =>\n paths.join(\"/\").replace(/\\/\\/+/g, \"/\");\n\nconst normalizePathname = (pathname: string): string =>\n pathname.replace(/\\/+$/, \"\").replace(/^\\/*/, \"/\");\n\nconst normalizeSearch = (search: string): string =>\n !search || search === \"?\"\n ? \"\"\n : search.startsWith(\"?\")\n ? search\n : \"?\" + search;\n\nconst normalizeHash = (hash: string): string =>\n !hash || hash === \"#\" ? \"\" : hash.startsWith(\"#\") ? hash : \"#\" + hash;\n\n///////////////////////////////////////////////////////////////////////////////\n// DANGER! PLEASE READ ME!\n// We provide these exports as an escape hatch in the event that you need any\n// routing data that we don't provide an explicit API for. With that said, we\n// want to cover your use case if we can, so if you feel the need to use these\n// we want to hear from you. Let us know what you're building and we'll do our\n// best to make sure we can support you!\n//\n// We consider these exports an implementation detail and do not guarantee\n// against any breaking changes, regardless of the semver release. Use with\n// extreme caution and only if you understand the consequences. Godspeed.\n///////////////////////////////////////////////////////////////////////////////\n\n/** @internal */\nexport {\n NavigationContext as UNSAFE_NavigationContext,\n LocationContext as UNSAFE_LocationContext,\n RouteContext as UNSAFE_RouteContext\n};\n"],"names":["invariant","cond","message","Error","warning","console","warn","e","alreadyWarned","warningOnce","key","NavigationContext","React","displayName","LocationContext","RouteContext","outlet","matches","MemoryRouter","basename","children","initialEntries","initialIndex","historyRef","current","createMemoryHistory","history","state","setState","action","location","listen","React.createElement","Navigate","to","replace","useInRouterContext","static","navigate","useNavigate","Outlet","_props","useOutlet","Route","Router","basenameProp","locationProp","navigationType","NavigationType","Pop","navigator","staticProp","normalizePathname","navigationContext","parsePath","pathname","search","hash","trailingPathname","stripBasename","Routes","useRoutes","createRoutesFromChildren","useHref","useResolvedPath","joinedPathname","toPathname","getToPathname","endsWithSlash","endsWith","joinPaths","createHref","useLocation","useNavigationType","useMatch","pattern","matchPath","locationPathname","routePathnamesJson","JSON","stringify","map","match","pathnameBase","activeRef","options","go","path","resolveTo","parse","push","useParams","routeMatch","length","params","routes","locationArg","parentMatches","parentParams","parentPathname","parentPathnameBase","parentRoute","route","parentPath","locationFromContext","parsedLocationArg","startsWith","remainingPathname","slice","matchRoutes","element","undefined","_renderMatches","Object","assign","forEach","type","apply","props","name","caseSensitive","index","generatePath","_","branches","flattenRoutes","rankRouteBranches","i","matchRouteBranch","parentsMeta","meta","relativePath","childrenIndex","routesMeta","concat","score","computeScore","sort","a","b","compareIndexes","paramRe","dynamicSegmentValue","indexRouteValue","emptySegmentValue","staticSegmentValue","splatPenalty","isSplat","s","segments","split","initialScore","some","filter","reduce","segment","test","siblings","every","n","branch","routesArg","matchedParams","matchedPathname","end","renderMatches","reduceRight","matcher","paramNames","compilePath","captureGroups","memo","paramName","splatValue","safelyDecodeURIComponent","regexpSource","RegExp","value","decodeURIComponent","error","resolvePath","fromPathname","resolvePathname","normalizeSearch","normalizeHash","relativeSegments","pop","join","toArg","routePathnames","from","routePathnameIndex","toSegments","shift","toLowerCase","nextChar","charAt","paths"],"mappings":";;;;;;;;;;;;;AAiBA,SAASA,SAAT,CAAmBC,IAAnB,EAA8BC,OAA9B,EAA6D;AAC3D,MAAI,CAACD,IAAL,EAAW,MAAM,IAAIE,KAAJ,CAAUD,OAAV,CAAN;AACZ;;AAED,SAASE,OAAT,CAAiBH,IAAjB,EAA4BC,OAA5B,EAAmD;AACjD,MAAI,CAACD,IAAL,EAAW;AACT;AACA,QAAI,OAAOI,OAAP,KAAmB,WAAvB,EAAoCA,OAAO,CAACC,IAAR,CAAaJ,OAAb;;AAEpC,QAAI;AACF;AACA;AACA;AACA;AACA;AACA,YAAM,IAAIC,KAAJ,CAAUD,OAAV,CAAN,CANE;AAQH,KARD,CAQE,OAAOK,CAAP,EAAU;AACb;AACF;;AAED,MAAMC,aAAsC,GAAG,EAA/C;;AACA,SAASC,WAAT,CAAqBC,GAArB,EAAkCT,IAAlC,EAAiDC,OAAjD,EAAkE;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Af;;AACA,MAAIsG,QAAQ,IAAIA,QAAQ,KAAK,GAA7B,EAAkC;AAChC;AACA,WAAO,IAAP;AACD;;AAED,SAAO5I,QAAQ,CAACqD,KAAT,CAAezF,QAAQ,CAAC0E,MAAxB,KAAmC,GAA1C;AACD;;AAED,MAAMvB,SAAS,GAAI+H,KAAD,IAChBA,KAAK,CAACV,IAAN,CAAW,GAAX,EAAgBxJ,OAAhB,CAAwB,QAAxB,EAAkC,GAAlC,CADF;;AAGA,MAAMiB,iBAAiB,GAAIG,QAAD,IACxBA,QAAQ,CAACpB,OAAT,CAAiB,MAAjB,EAAyB,EAAzB,EAA6BA,OAA7B,CAAqC,MAArC,EAA6C,GAA7C,CADF;;AAGA,MAAMoJ,eAAe,GAAI/H,MAAD,IACtB,CAACA,MAAD,IAAWA,MAAM,KAAK,GAAtB,GACI,EADJ,GAEIA,MAAM,CAACkD,UAAP,CAAkB,GAAlB,IACAlD,MADA,GAEA,MAAMA,MALZ;;AAOA,MAAMgI,aAAa,GAAI/H,IAAD,IACpB,CAACA,IAAD,IAASA,IAAI,KAAK,GAAlB,GAAwB,EAAxB,GAA6BA,IAAI,CAACiD,UAAL,CAAgB,GAAhB,IAAuBjD,IAAvB,GAA8B,MAAMA,IADnE;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../packages/react-router/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type {\n History,\n InitialEntry,\n Location,\n MemoryHistory,\n Path,\n To\n} from \"history\";\nimport {\n Action as NavigationType,\n createMemoryHistory,\n parsePath\n} from \"history\";\n\nexport type { Location, Path, To, NavigationType };\n\nfunction invariant(cond: any, message: string): asserts cond {\n if (!cond) throw new Error(message);\n}\n\nfunction warning(cond: any, message: string): void {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging React Router!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nconst alreadyWarned: Record<string, boolean> = {};\nfunction warningOnce(key: string, cond: boolean, message: string) {\n if (!cond && !alreadyWarned[key]) {\n alreadyWarned[key] = true;\n warning(false, message);\n }\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// CONTEXT\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * A Navigator is a \"location changer\"; it's how you get to different locations.\n *\n * Every history instance conforms to the Navigator interface, but the\n * distinction is useful primarily when it comes to the low-level <Router> API\n * where both the location and a navigator must be provided separately in order\n * to avoid \"tearing\" that may occur in a suspense-enabled app if the action\n * and/or location were to be read directly from the history instance.\n */\nexport type Navigator = Pick<History, \"go\" | \"push\" | \"replace\" | \"createHref\">;\n\ninterface NavigationContextObject {\n basename: string;\n navigator: Navigator;\n static: boolean;\n}\n\nconst NavigationContext = React.createContext<NavigationContextObject>(null!);\n\nif (__DEV__) {\n NavigationContext.displayName = \"Navigation\";\n}\n\ninterface LocationContextObject {\n location: Location;\n navigationType: NavigationType;\n}\n\nconst LocationContext = React.createContext<LocationContextObject>(null!);\n\nif (__DEV__) {\n LocationContext.displayName = \"Location\";\n}\n\ninterface RouteContextObject {\n outlet: React.ReactElement | null;\n matches: RouteMatch[];\n}\n\nconst RouteContext = React.createContext<RouteContextObject>({\n outlet: null,\n matches: []\n});\n\nif (__DEV__) {\n RouteContext.displayName = \"Route\";\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// COMPONENTS\n///////////////////////////////////////////////////////////////////////////////\n\nexport interface MemoryRouterProps {\n basename?: string;\n children?: React.ReactNode;\n initialEntries?: InitialEntry[];\n initialIndex?: number;\n}\n\n/**\n * A <Router> that stores all entries in memory.\n *\n * @see https://reactrouter.com/docs/en/v6/api#memoryrouter\n */\nexport function MemoryRouter({\n basename,\n children,\n initialEntries,\n initialIndex\n}: MemoryRouterProps): React.ReactElement {\n let historyRef = React.useRef<MemoryHistory>();\n if (historyRef.current == null) {\n historyRef.current = createMemoryHistory({ initialEntries, initialIndex });\n }\n\n let history = historyRef.current;\n let [state, setState] = React.useState({\n action: history.action,\n location: history.location\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nexport interface NavigateProps {\n to: To;\n replace?: boolean;\n state?: any;\n}\n\n/**\n * Changes the current location.\n *\n * Note: This API is mostly useful in React.Component subclasses that are not\n * able to use hooks. In functional components, we recommend you use the\n * `useNavigate` hook instead.\n *\n * @see https://reactrouter.com/docs/en/v6/api#navigate\n */\nexport function Navigate({ to, replace, state }: NavigateProps): null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of\n // the router loaded. We can help them understand how to avoid that.\n `<Navigate> may be used only in the context of a <Router> component.`\n );\n\n warning(\n !React.useContext(NavigationContext).static,\n `<Navigate> must not be used on the initial render in a <StaticRouter>. ` +\n `This is a no-op, but you should modify your code so the <Navigate> is ` +\n `only ever rendered in response to some user interaction or state change.`\n );\n\n let navigate = useNavigate();\n React.useEffect(() => {\n navigate(to, { replace, state });\n });\n\n return null;\n}\n\nexport interface OutletProps {\n context?: unknown;\n}\n\n/**\n * Renders the child route's element, if there is one.\n *\n * @see https://reactrouter.com/docs/en/v6/api#outlet\n */\nexport function Outlet(props: OutletProps): React.ReactElement | null {\n return useOutlet(props.context);\n}\n\nexport interface RouteProps {\n caseSensitive?: boolean;\n children?: React.ReactNode;\n element?: React.ReactElement | null;\n index?: boolean;\n path?: string;\n}\n\nexport interface PathRouteProps {\n caseSensitive?: boolean;\n children?: React.ReactNode;\n element?: React.ReactElement | null;\n index?: false;\n path: string;\n}\n\nexport interface LayoutRouteProps {\n children?: React.ReactNode;\n element?: React.ReactElement | null;\n}\n\nexport interface IndexRouteProps {\n element?: React.ReactElement | null;\n index: true;\n}\n\n/**\n * Declares an element that should be rendered at a certain URL path.\n *\n * @see https://reactrouter.com/docs/en/v6/api#route\n */\nexport function Route(\n _props: PathRouteProps | LayoutRouteProps | IndexRouteProps\n): React.ReactElement | null {\n invariant(\n false,\n `A <Route> is only ever to be used as the child of <Routes> element, ` +\n `never rendered directly. Please wrap your <Route> in a <Routes>.`\n );\n}\n\nexport interface RouterProps {\n basename?: string;\n children?: React.ReactNode;\n location: Partial<Location> | string;\n navigationType?: NavigationType;\n navigator: Navigator;\n static?: boolean;\n}\n\n/**\n * Provides location context for the rest of the app.\n *\n * Note: You usually won't render a <Router> directly. Instead, you'll render a\n * router that is more specific to your environment such as a <BrowserRouter>\n * in web browsers or a <StaticRouter> for server rendering.\n *\n * @see https://reactrouter.com/docs/en/v6/api#router\n */\nexport function Router({\n basename: basenameProp = \"/\",\n children = null,\n location: locationProp,\n navigationType = NavigationType.Pop,\n navigator,\n static: staticProp = false\n}: RouterProps): React.ReactElement | null {\n invariant(\n !useInRouterContext(),\n `You cannot render a <Router> inside another <Router>.` +\n ` You should never have more than one in your app.`\n );\n\n let basename = normalizePathname(basenameProp);\n let navigationContext = React.useMemo(\n () => ({ basename, navigator, static: staticProp }),\n [basename, navigator, staticProp]\n );\n\n if (typeof locationProp === \"string\") {\n locationProp = parsePath(locationProp);\n }\n\n let {\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n state = null,\n key = \"default\"\n } = locationProp;\n\n let location = React.useMemo(() => {\n let trailingPathname = stripBasename(pathname, basename);\n\n if (trailingPathname == null) {\n return null;\n }\n\n return {\n pathname: trailingPathname,\n search,\n hash,\n state,\n key\n };\n }, [basename, pathname, search, hash, state, key]);\n\n warning(\n location != null,\n `<Router basename=\"${basename}\"> is not able to match the URL ` +\n `\"${pathname}${search}${hash}\" because it does not start with the ` +\n `basename, so the <Router> won't render anything.`\n );\n\n if (location == null) {\n return null;\n }\n\n return (\n <NavigationContext.Provider value={navigationContext}>\n <LocationContext.Provider\n children={children}\n value={{ location, navigationType }}\n />\n </NavigationContext.Provider>\n );\n}\n\nexport interface RoutesProps {\n children?: React.ReactNode;\n location?: Partial<Location> | string;\n}\n\n/**\n * A container for a nested tree of <Route> elements that renders the branch\n * that best matches the current location.\n *\n * @see https://reactrouter.com/docs/en/v6/api#routes\n */\nexport function Routes({\n children,\n location\n}: RoutesProps): React.ReactElement | null {\n return useRoutes(createRoutesFromChildren(children), location);\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// HOOKS\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * Returns the full href for the given \"to\" value. This is useful for building\n * custom links that are also accessible and preserve right-click behavior.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usehref\n */\nexport function useHref(to: To): string {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useHref() may be used only in the context of a <Router> component.`\n );\n\n let { basename, navigator } = React.useContext(NavigationContext);\n let { hash, pathname, search } = useResolvedPath(to);\n\n let joinedPathname = pathname;\n if (basename !== \"/\") {\n let toPathname = getToPathname(to);\n let endsWithSlash = toPathname != null && toPathname.endsWith(\"/\");\n joinedPathname =\n pathname === \"/\"\n ? basename + (endsWithSlash ? \"/\" : \"\")\n : joinPaths([basename, pathname]);\n }\n\n return navigator.createHref({ pathname: joinedPathname, search, hash });\n}\n\n/**\n * Returns true if this component is a descendant of a <Router>.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useinroutercontext\n */\nexport function useInRouterContext(): boolean {\n return React.useContext(LocationContext) != null;\n}\n\n/**\n * Returns the current location object, which represents the current URL in web\n * browsers.\n *\n * Note: If you're using this it may mean you're doing some of your own\n * \"routing\" in your app, and we'd like to know what your use case is. We may\n * be able to provide something higher-level to better suit your needs.\n *\n * @see https://reactrouter.com/docs/en/v6/api#uselocation\n */\nexport function useLocation(): Location {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useLocation() may be used only in the context of a <Router> component.`\n );\n\n return React.useContext(LocationContext).location;\n}\n\ntype ParamParseFailed = { failed: true };\n\ntype ParamParseSegment<Segment extends string> =\n // Check here if there exists a forward slash in the string.\n Segment extends `${infer LeftSegment}/${infer RightSegment}`\n ? // If there is a forward slash, then attempt to parse each side of the\n // forward slash.\n ParamParseSegment<LeftSegment> extends infer LeftResult\n ? ParamParseSegment<RightSegment> extends infer RightResult\n ? LeftResult extends string\n ? // If the left side is successfully parsed as a param, then check if\n // the right side can be successfully parsed as well. If both sides\n // can be parsed, then the result is a union of the two sides\n // (read: \"foo\" | \"bar\").\n RightResult extends string\n ? LeftResult | RightResult\n : LeftResult\n : // If the left side is not successfully parsed as a param, then check\n // if only the right side can be successfully parse as a param. If it\n // can, then the result is just right, else it's a failure.\n RightResult extends string\n ? RightResult\n : ParamParseFailed\n : ParamParseFailed\n : // If the left side didn't parse into a param, then just check the right\n // side.\n ParamParseSegment<RightSegment> extends infer RightResult\n ? RightResult extends string\n ? RightResult\n : ParamParseFailed\n : ParamParseFailed\n : // If there's no forward slash, then check if this segment starts with a\n // colon. If it does, then this is a dynamic segment, so the result is\n // just the remainder of the string. Otherwise, it's a failure.\n Segment extends `:${infer Remaining}`\n ? Remaining\n : ParamParseFailed;\n\n// Attempt to parse the given string segment. If it fails, then just return the\n// plain string type as a default fallback. Otherwise return the union of the\n// parsed string literals that were referenced as dynamic segments in the route.\ntype ParamParseKey<Segment extends string> =\n ParamParseSegment<Segment> extends string\n ? ParamParseSegment<Segment>\n : string;\n\n/**\n * Returns the current navigation action which describes how the router came to\n * the current location, either by a pop, push, or replace on the history stack.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usenavigationtype\n */\nexport function useNavigationType(): NavigationType {\n return React.useContext(LocationContext).navigationType;\n}\n\n/**\n * Returns true if the URL for the given \"to\" value matches the current URL.\n * This is useful for components that need to know \"active\" state, e.g.\n * <NavLink>.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usematch\n */\nexport function useMatch<\n ParamKey extends ParamParseKey<Path>,\n Path extends string\n>(pattern: PathPattern<Path> | Path): PathMatch<ParamKey> | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useMatch() may be used only in the context of a <Router> component.`\n );\n\n let { pathname } = useLocation();\n return React.useMemo(\n () => matchPath<ParamKey, Path>(pattern, pathname),\n [pathname, pattern]\n );\n}\n\n/**\n * The interface for the navigate() function returned from useNavigate().\n */\nexport interface NavigateFunction {\n (to: To, options?: NavigateOptions): void;\n (delta: number): void;\n}\n\nexport interface NavigateOptions {\n replace?: boolean;\n state?: any;\n}\n\n/**\n * Returns an imperative method for changing the location. Used by <Link>s, but\n * may also be used by other elements to change the location.\n *\n * @see https://reactrouter.com/docs/en/v6/api#usenavigate\n */\nexport function useNavigate(): NavigateFunction {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useNavigate() may be used only in the context of a <Router> component.`\n );\n\n let { basename, navigator } = React.useContext(NavigationContext);\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n matches.map(match => match.pathnameBase)\n );\n\n let activeRef = React.useRef(false);\n React.useEffect(() => {\n activeRef.current = true;\n });\n\n let navigate: NavigateFunction = React.useCallback(\n (to: To | number, options: NavigateOptions = {}) => {\n warning(\n activeRef.current,\n `You should call navigate() in a React.useEffect(), not when ` +\n `your component is first rendered.`\n );\n\n if (!activeRef.current) return;\n\n if (typeof to === \"number\") {\n navigator.go(to);\n return;\n }\n\n let path = resolveTo(\n to,\n JSON.parse(routePathnamesJson),\n locationPathname\n );\n\n if (basename !== \"/\") {\n path.pathname = joinPaths([basename, path.pathname]);\n }\n\n (!!options.replace ? navigator.replace : navigator.push)(\n path,\n options.state\n );\n },\n [basename, navigator, routePathnamesJson, locationPathname]\n );\n\n return navigate;\n}\n\nconst OutletContext = React.createContext<unknown>(null);\n\n/**\n * Returns the context (if provided) for the child route at this level of the route\n * hierarchy.\n * @see https://reactrouter.com/docs/en/v6/api#useoutletcontext\n */\nexport function useOutletContext<Context = unknown>(): Context {\n return React.useContext(OutletContext) as Context;\n}\n\n/**\n * Returns the element for the child route at this level of the route\n * hierarchy. Used internally by <Outlet> to render child routes.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useoutlet\n */\nexport function useOutlet(context?: unknown): React.ReactElement | null {\n let outlet = React.useContext(RouteContext).outlet;\n return (\n <OutletContext.Provider value={context}>{outlet}</OutletContext.Provider>\n );\n}\n\n/**\n * Returns an object of key/value pairs of the dynamic params from the current\n * URL that were matched by the route path.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useparams\n */\nexport function useParams<\n ParamsOrKey extends string | Record<string, string | undefined> = string\n>(): Readonly<\n [ParamsOrKey] extends [string] ? Params<ParamsOrKey> : Partial<ParamsOrKey>\n> {\n let { matches } = React.useContext(RouteContext);\n let routeMatch = matches[matches.length - 1];\n return routeMatch ? (routeMatch.params as any) : {};\n}\n\n/**\n * Resolves the pathname of the given `to` value against the current location.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useresolvedpath\n */\nexport function useResolvedPath(to: To): Path {\n let { matches } = React.useContext(RouteContext);\n let { pathname: locationPathname } = useLocation();\n\n let routePathnamesJson = JSON.stringify(\n matches.map(match => match.pathnameBase)\n );\n\n return React.useMemo(\n () => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname),\n [to, routePathnamesJson, locationPathname]\n );\n}\n\n/**\n * Returns the element of the route that matched the current location, prepared\n * with the correct context to render the remainder of the route tree. Route\n * elements in the tree must render an <Outlet> to render their child route's\n * element.\n *\n * @see https://reactrouter.com/docs/en/v6/api#useroutes\n */\nexport function useRoutes(\n routes: RouteObject[],\n locationArg?: Partial<Location> | string\n): React.ReactElement | null {\n invariant(\n useInRouterContext(),\n // TODO: This error is probably because they somehow have 2 versions of the\n // router loaded. We can help them understand how to avoid that.\n `useRoutes() may be used only in the context of a <Router> component.`\n );\n\n let { matches: parentMatches } = React.useContext(RouteContext);\n let routeMatch = parentMatches[parentMatches.length - 1];\n let parentParams = routeMatch ? routeMatch.params : {};\n let parentPathname = routeMatch ? routeMatch.pathname : \"/\";\n let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : \"/\";\n let parentRoute = routeMatch && routeMatch.route;\n\n if (__DEV__) {\n // You won't get a warning about 2 different <Routes> under a <Route>\n // without a trailing *, but this is a best-effort warning anyway since we\n // cannot even give the warning unless they land at the parent route.\n //\n // Example:\n //\n // <Routes>\n // {/* This route path MUST end with /* because otherwise\n // it will never match /blog/post/123 */}\n // <Route path=\"blog\" element={<Blog />} />\n // <Route path=\"blog/feed\" element={<BlogFeed />} />\n // </Routes>\n //\n // function Blog() {\n // return (\n // <Routes>\n // <Route path=\"post/:id\" element={<Post />} />\n // </Routes>\n // );\n // }\n let parentPath = (parentRoute && parentRoute.path) || \"\";\n warningOnce(\n parentPathname,\n !parentRoute || parentPath.endsWith(\"*\"),\n `You rendered descendant <Routes> (or called \\`useRoutes()\\`) at ` +\n `\"${parentPathname}\" (under <Route path=\"${parentPath}\">) but the ` +\n `parent route path has no trailing \"*\". This means if you navigate ` +\n `deeper, the parent won't match anymore and therefore the child ` +\n `routes will never render.\\n\\n` +\n `Please change the parent <Route path=\"${parentPath}\"> to <Route ` +\n `path=\"${parentPath === \"/\" ? \"*\" : `${parentPath}/*`}\">.`\n );\n }\n\n let locationFromContext = useLocation();\n\n let location;\n if (locationArg) {\n let parsedLocationArg =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n invariant(\n parentPathnameBase === \"/\" ||\n parsedLocationArg.pathname?.startsWith(parentPathnameBase),\n `When overriding the location using \\`<Routes location>\\` or \\`useRoutes(routes, location)\\`, ` +\n `the location pathname must begin with the portion of the URL pathname that was ` +\n `matched by all parent routes. The current pathname base is \"${parentPathnameBase}\" ` +\n `but pathname \"${parsedLocationArg.pathname}\" was given in the \\`location\\` prop.`\n );\n\n location = parsedLocationArg;\n } else {\n location = locationFromContext;\n }\n\n let pathname = location.pathname || \"/\";\n let remainingPathname =\n parentPathnameBase === \"/\"\n ? pathname\n : pathname.slice(parentPathnameBase.length) || \"/\";\n let matches = matchRoutes(routes, { pathname: remainingPathname });\n\n if (__DEV__) {\n warning(\n parentRoute || matches != null,\n `No routes matched location \"${location.pathname}${location.search}${location.hash}\" `\n );\n\n warning(\n matches == null ||\n matches[matches.length - 1].route.element !== undefined,\n `Matched leaf route at location \"${location.pathname}${location.search}${location.hash}\" does not have an element. ` +\n `This means it will render an <Outlet /> with a null value by default resulting in an \"empty\" page.`\n );\n }\n\n return _renderMatches(\n matches &&\n matches.map(match =>\n Object.assign({}, match, {\n params: Object.assign({}, parentParams, match.params),\n pathname: joinPaths([parentPathnameBase, match.pathname]),\n pathnameBase:\n match.pathnameBase === \"/\"\n ? parentPathnameBase\n : joinPaths([parentPathnameBase, match.pathnameBase])\n })\n ),\n parentMatches\n );\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// UTILS\n///////////////////////////////////////////////////////////////////////////////\n\n/**\n * Creates a route config from a React \"children\" object, which is usually\n * either a `<Route>` element or an array of them. Used internally by\n * `<Routes>` to create a route config from its children.\n *\n * @see https://reactrouter.com/docs/en/v6/api#createroutesfromchildren\n */\nexport function createRoutesFromChildren(\n children: React.ReactNode\n): RouteObject[] {\n let routes: RouteObject[] = [];\n\n React.Children.forEach(children, element => {\n if (!React.isValidElement(element)) {\n // Ignore non-elements. This allows people to more easily inline\n // conditionals in their route config.\n return;\n }\n\n if (element.type === React.Fragment) {\n // Transparently support React.Fragment and its children.\n routes.push.apply(\n routes,\n createRoutesFromChildren(element.props.children)\n );\n return;\n }\n\n invariant(\n element.type === Route,\n `[${\n typeof element.type === \"string\" ? element.type : element.type.name\n }] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`\n );\n\n let route: RouteObject = {\n caseSensitive: element.props.caseSensitive,\n element: element.props.element,\n index: element.props.index,\n path: element.props.path\n };\n\n if (element.props.children) {\n route.children = createRoutesFromChildren(element.props.children);\n }\n\n routes.push(route);\n });\n\n return routes;\n}\n\n/**\n * The parameters that were parsed from the URL path.\n */\nexport type Params<Key extends string = string> = {\n readonly [key in Key]: string | undefined;\n};\n\n/**\n * A route object represents a logical route, with (optionally) its child\n * routes organized in a tree-like structure.\n */\nexport interface RouteObject {\n caseSensitive?: boolean;\n children?: RouteObject[];\n element?: React.ReactNode;\n index?: boolean;\n path?: string;\n}\n\n/**\n * Returns a path with params interpolated.\n *\n * @see https://reactrouter.com/docs/en/v6/api#generatepath\n */\nexport function generatePath(path: string, params: Params = {}): string {\n return path\n .replace(/:(\\w+)/g, (_, key) => {\n invariant(params[key] != null, `Missing \":${key}\" param`);\n return params[key]!;\n })\n .replace(/\\/*\\*$/, _ =>\n params[\"*\"] == null ? \"\" : params[\"*\"].replace(/^\\/*/, \"/\")\n );\n}\n\n/**\n * A RouteMatch contains info about how a route matched a URL.\n */\nexport interface RouteMatch<ParamKey extends string = string> {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params<ParamKey>;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The route object that was used to match.\n */\n route: RouteObject;\n}\n\n/**\n * Matches the given routes to a location and returns the match data.\n *\n * @see https://reactrouter.com/docs/en/v6/api#matchroutes\n */\nexport function matchRoutes(\n routes: RouteObject[],\n locationArg: Partial<Location> | string,\n basename = \"/\"\n): RouteMatch[] | null {\n let location =\n typeof locationArg === \"string\" ? parsePath(locationArg) : locationArg;\n\n let pathname = stripBasename(location.pathname || \"/\", basename);\n\n if (pathname == null) {\n return null;\n }\n\n let branches = flattenRoutes(routes);\n rankRouteBranches(branches);\n\n let matches = null;\n for (let i = 0; matches == null && i < branches.length; ++i) {\n matches = matchRouteBranch(branches[i], pathname);\n }\n\n return matches;\n}\n\ninterface RouteMeta {\n relativePath: string;\n caseSensitive: boolean;\n childrenIndex: number;\n route: RouteObject;\n}\n\ninterface RouteBranch {\n path: string;\n score: number;\n routesMeta: RouteMeta[];\n}\n\nfunction flattenRoutes(\n routes: RouteObject[],\n branches: RouteBranch[] = [],\n parentsMeta: RouteMeta[] = [],\n parentPath = \"\"\n): RouteBranch[] {\n routes.forEach((route, index) => {\n let meta: RouteMeta = {\n relativePath: route.path || \"\",\n caseSensitive: route.caseSensitive === true,\n childrenIndex: index,\n route\n };\n\n if (meta.relativePath.startsWith(\"/\")) {\n invariant(\n meta.relativePath.startsWith(parentPath),\n `Absolute route path \"${meta.relativePath}\" nested under path ` +\n `\"${parentPath}\" is not valid. An absolute child route path ` +\n `must start with the combined path of all its parent routes.`\n );\n\n meta.relativePath = meta.relativePath.slice(parentPath.length);\n }\n\n let path = joinPaths([parentPath, meta.relativePath]);\n let routesMeta = parentsMeta.concat(meta);\n\n // Add the children before adding this route to the array so we traverse the\n // route tree depth-first and child routes appear before their parents in\n // the \"flattened\" version.\n if (route.children && route.children.length > 0) {\n invariant(\n route.index !== true,\n `Index routes must not have child routes. Please remove ` +\n `all child routes from route path \"${path}\".`\n );\n\n flattenRoutes(route.children, branches, routesMeta, path);\n }\n\n // Routes without a path shouldn't ever match by themselves unless they are\n // index routes, so don't add them to the list of possible branches.\n if (route.path == null && !route.index) {\n return;\n }\n\n branches.push({ path, score: computeScore(path, route.index), routesMeta });\n });\n\n return branches;\n}\n\nfunction rankRouteBranches(branches: RouteBranch[]): void {\n branches.sort((a, b) =>\n a.score !== b.score\n ? b.score - a.score // Higher score first\n : compareIndexes(\n a.routesMeta.map(meta => meta.childrenIndex),\n b.routesMeta.map(meta => meta.childrenIndex)\n )\n );\n}\n\nconst paramRe = /^:\\w+$/;\nconst dynamicSegmentValue = 3;\nconst indexRouteValue = 2;\nconst emptySegmentValue = 1;\nconst staticSegmentValue = 10;\nconst splatPenalty = -2;\nconst isSplat = (s: string) => s === \"*\";\n\nfunction computeScore(path: string, index: boolean | undefined): number {\n let segments = path.split(\"/\");\n let initialScore = segments.length;\n if (segments.some(isSplat)) {\n initialScore += splatPenalty;\n }\n\n if (index) {\n initialScore += indexRouteValue;\n }\n\n return segments\n .filter(s => !isSplat(s))\n .reduce(\n (score, segment) =>\n score +\n (paramRe.test(segment)\n ? dynamicSegmentValue\n : segment === \"\"\n ? emptySegmentValue\n : staticSegmentValue),\n initialScore\n );\n}\n\nfunction compareIndexes(a: number[], b: number[]): number {\n let siblings =\n a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);\n\n return siblings\n ? // If two routes are siblings, we should try to match the earlier sibling\n // first. This allows people to have fine-grained control over the matching\n // behavior by simply putting routes with identical paths in the order they\n // want them tried.\n a[a.length - 1] - b[b.length - 1]\n : // Otherwise, it doesn't really make sense to rank non-siblings by index,\n // so they sort equally.\n 0;\n}\n\nfunction matchRouteBranch<ParamKey extends string = string>(\n branch: RouteBranch,\n pathname: string\n): RouteMatch<ParamKey>[] | null {\n let { routesMeta } = branch;\n\n let matchedParams = {};\n let matchedPathname = \"/\";\n let matches: RouteMatch[] = [];\n for (let i = 0; i < routesMeta.length; ++i) {\n let meta = routesMeta[i];\n let end = i === routesMeta.length - 1;\n let remainingPathname =\n matchedPathname === \"/\"\n ? pathname\n : pathname.slice(matchedPathname.length) || \"/\";\n let match = matchPath(\n { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },\n remainingPathname\n );\n\n if (!match) return null;\n\n Object.assign(matchedParams, match.params);\n\n let route = meta.route;\n\n matches.push({\n params: matchedParams,\n pathname: joinPaths([matchedPathname, match.pathname]),\n pathnameBase: joinPaths([matchedPathname, match.pathnameBase]),\n route\n });\n\n if (match.pathnameBase !== \"/\") {\n matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);\n }\n }\n\n return matches;\n}\n\n/**\n * Renders the result of `matchRoutes()` into a React element.\n */\nexport function renderMatches(\n matches: RouteMatch[] | null\n): React.ReactElement | null {\n return _renderMatches(matches);\n}\n\nfunction _renderMatches(\n matches: RouteMatch[] | null,\n parentMatches: RouteMatch[] = []\n): React.ReactElement | null {\n if (matches == null) return null;\n\n return matches.reduceRight((outlet, match, index) => {\n return (\n <RouteContext.Provider\n children={\n match.route.element !== undefined ? match.route.element : <Outlet />\n }\n value={{\n outlet,\n matches: parentMatches.concat(matches.slice(0, index + 1))\n }}\n />\n );\n }, null as React.ReactElement | null);\n}\n\n/**\n * A PathPattern is used to match on some portion of a URL pathname.\n */\nexport interface PathPattern<Path extends string = string> {\n /**\n * A string to match against a URL pathname. May contain `:id`-style segments\n * to indicate placeholders for dynamic parameters. May also end with `/*` to\n * indicate matching the rest of the URL pathname.\n */\n path: Path;\n /**\n * Should be `true` if the static portions of the `path` should be matched in\n * the same case.\n */\n caseSensitive?: boolean;\n /**\n * Should be `true` if this pattern should match the entire URL pathname.\n */\n end?: boolean;\n}\n\n/**\n * A PathMatch contains info about how a PathPattern matched on a URL pathname.\n */\nexport interface PathMatch<ParamKey extends string = string> {\n /**\n * The names and values of dynamic parameters in the URL.\n */\n params: Params<ParamKey>;\n /**\n * The portion of the URL pathname that was matched.\n */\n pathname: string;\n /**\n * The portion of the URL pathname that was matched before child routes.\n */\n pathnameBase: string;\n /**\n * The pattern that was used to match.\n */\n pattern: PathPattern;\n}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\n/**\n * Performs pattern matching on a URL pathname and returns information about\n * the match.\n *\n * @see https://reactrouter.com/docs/en/v6/api#matchpath\n */\nexport function matchPath<\n ParamKey extends ParamParseKey<Path>,\n Path extends string\n>(\n pattern: PathPattern<Path> | Path,\n pathname: string\n): PathMatch<ParamKey> | null {\n if (typeof pattern === \"string\") {\n pattern = { path: pattern, caseSensitive: false, end: true };\n }\n\n let [matcher, paramNames] = compilePath(\n pattern.path,\n pattern.caseSensitive,\n pattern.end\n );\n\n let match = pathname.match(matcher);\n if (!match) return null;\n\n let matchedPathname = match[0];\n let pathnameBase = matchedPathname.replace(/(.)\\/+$/, \"$1\");\n let captureGroups = match.slice(1);\n let params: Params = paramNames.reduce<Mutable<Params>>(\n (memo, paramName, index) => {\n // We need to compute the pathnameBase here using the raw splat value\n // instead of using params[\"*\"] later because it will be decoded then\n if (paramName === \"*\") {\n let splatValue = captureGroups[index] || \"\";\n pathnameBase = matchedPathname\n .slice(0, matchedPathname.length - splatValue.length)\n .replace(/(.)\\/+$/, \"$1\");\n }\n\n memo[paramName] = safelyDecodeURIComponent(\n captureGroups[index] || \"\",\n paramName\n );\n return memo;\n },\n {}\n );\n\n return {\n params,\n pathname: matchedPathname,\n pathnameBase,\n pattern\n };\n}\n\nfunction compilePath(\n path: string,\n caseSensitive = false,\n end = true\n): [RegExp, string[]] {\n warning(\n path === \"*\" || !path.endsWith(\"*\") || path.endsWith(\"/*\"),\n `Route path \"${path}\" will be treated as if it were ` +\n `\"${path.replace(/\\*$/, \"/*\")}\" because the \\`*\\` character must ` +\n `always follow a \\`/\\` in the pattern. To get rid of this warning, ` +\n `please change the route path to \"${path.replace(/\\*$/, \"/*\")}\".`\n );\n\n let paramNames: string[] = [];\n let regexpSource =\n \"^\" +\n path\n .replace(/\\/*\\*?$/, \"\") // Ignore trailing / and /*, we'll handle it below\n .replace(/^\\/*/, \"/\") // Make sure it has a leading /\n .replace(/[\\\\.*+^$?{}|()[\\]]/g, \"\\\\$&\") // Escape special regex chars\n .replace(/:(\\w+)/g, (_: string, paramName: string) => {\n paramNames.push(paramName);\n return \"([^\\\\/]+)\";\n });\n\n if (path.endsWith(\"*\")) {\n paramNames.push(\"*\");\n regexpSource +=\n path === \"*\" || path === \"/*\"\n ? \"(.*)$\" // Already matched the initial /, just match the rest\n : \"(?:\\\\/(.+)|\\\\/*)$\"; // Don't include the / in params[\"*\"]\n } else {\n regexpSource += end\n ? \"\\\\/*$\" // When matching to the end, ignore trailing slashes\n : // Otherwise, match a word boundary or a proceeding /. The word boundary restricts\n // parent routes to matching only their own words and nothing more, e.g. parent\n // route \"/home\" should not match \"/home2\".\n \"(?:\\\\b|\\\\/|$)\";\n }\n\n let matcher = new RegExp(regexpSource, caseSensitive ? undefined : \"i\");\n\n return [matcher, paramNames];\n}\n\nfunction safelyDecodeURIComponent(value: string, paramName: string) {\n try {\n return decodeURIComponent(value);\n } catch (error) {\n warning(\n false,\n `The value for the URL param \"${paramName}\" will not be decoded because` +\n ` the string \"${value}\" is a malformed URL segment. This is probably` +\n ` due to a bad percent encoding (${error}).`\n );\n\n return value;\n }\n}\n\n/**\n * Returns a resolved path object relative to the given pathname.\n *\n * @see https://reactrouter.com/docs/en/v6/api#resolvepath\n */\nexport function resolvePath(to: To, fromPathname = \"/\"): Path {\n let {\n pathname: toPathname,\n search = \"\",\n hash = \"\"\n } = typeof to === \"string\" ? parsePath(to) : to;\n\n let pathname = toPathname\n ? toPathname.startsWith(\"/\")\n ? toPathname\n : resolvePathname(toPathname, fromPathname)\n : fromPathname;\n\n return {\n pathname,\n search: normalizeSearch(search),\n hash: normalizeHash(hash)\n };\n}\n\nfunction resolvePathname(relativePath: string, fromPathname: string): string {\n let segments = fromPathname.replace(/\\/+$/, \"\").split(\"/\");\n let relativeSegments = relativePath.split(\"/\");\n\n relativeSegments.forEach(segment => {\n if (segment === \"..\") {\n // Keep the root \"\" segment so the pathname starts at /\n if (segments.length > 1) segments.pop();\n } else if (segment !== \".\") {\n segments.push(segment);\n }\n });\n\n return segments.length > 1 ? segments.join(\"/\") : \"/\";\n}\n\nfunction resolveTo(\n toArg: To,\n routePathnames: string[],\n locationPathname: string\n): Path {\n let to = typeof toArg === \"string\" ? parsePath(toArg) : toArg;\n let toPathname = toArg === \"\" || to.pathname === \"\" ? \"/\" : to.pathname;\n\n // If a pathname is explicitly provided in `to`, it should be relative to the\n // route context. This is explained in `Note on `<Link to>` values` in our\n // migration guide from v5 as a means of disambiguation between `to` values\n // that begin with `/` and those that do not. However, this is problematic for\n // `to` values that do not provide a pathname. `to` can simply be a search or\n // hash string, in which case we should assume that the navigation is relative\n // to the current location's pathname and *not* the route pathname.\n let from: string;\n if (toPathname == null) {\n from = locationPathname;\n } else {\n let routePathnameIndex = routePathnames.length - 1;\n\n if (toPathname.startsWith(\"..\")) {\n let toSegments = toPathname.split(\"/\");\n\n // Each leading .. segment means \"go up one route\" instead of \"go up one\n // URL segment\". This is a key difference from how <a href> works and a\n // major reason we call this a \"to\" value instead of a \"href\".\n while (toSegments[0] === \"..\") {\n toSegments.shift();\n routePathnameIndex -= 1;\n }\n\n to.pathname = toSegments.join(\"/\");\n }\n\n // If there are more \"..\" segments than parent routes, resolve relative to\n // the root / URL.\n from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : \"/\";\n }\n\n let path = resolvePath(to, from);\n\n // Ensure the pathname has a trailing slash if the original to value had one.\n if (\n toPathname &&\n toPathname !== \"/\" &&\n toPathname.endsWith(\"/\") &&\n !path.pathname.endsWith(\"/\")\n ) {\n path.pathname += \"/\";\n }\n\n return path;\n}\n\nfunction getToPathname(to: To): string | undefined {\n // Empty strings should be treated the same as / paths\n return to === \"\" || (to as Path).pathname === \"\"\n ? \"/\"\n : typeof to === \"string\"\n ? parsePath(to).pathname\n : to.pathname;\n}\n\nfunction stripBasename(pathname: string, basename: string): string | null {\n if (basename === \"/\") return pathname;\n\n if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {\n return null;\n }\n\n let nextChar = pathname.charAt(basename.length);\n if (nextChar && nextChar !== \"/\") {\n // pathname does not start with basename/\n return null;\n }\n\n return pathname.slice(basename.length) || \"/\";\n}\n\nconst joinPaths = (paths: string[]): string =>\n paths.join(\"/\").replace(/\\/\\/+/g, \"/\");\n\nconst normalizePathname = (pathname: string): string =>\n pathname.replace(/\\/+$/, \"\").replace(/^\\/*/, \"/\");\n\nconst normalizeSearch = (search: string): string =>\n !search || search === \"?\"\n ? \"\"\n : search.startsWith(\"?\")\n ? search\n : \"?\" + search;\n\nconst normalizeHash = (hash: string): string =>\n !hash || hash === \"#\" ? \"\" : hash.startsWith(\"#\") ? hash : \"#\" + hash;\n\n///////////////////////////////////////////////////////////////////////////////\n// DANGER! PLEASE READ ME!\n// We provide these exports as an escape hatch in the event that you need any\n// routing data that we don't provide an explicit API for. With that said, we\n// want to cover your use case if we can, so if you feel the need to use these\n// we want to hear from you. Let us know what you're building and we'll do our\n// best to make sure we can support you!\n//\n// We consider these exports an implementation detail and do not guarantee\n// against any breaking changes, regardless of the semver release. Use with\n// extreme caution and only if you understand the consequences. Godspeed.\n///////////////////////////////////////////////////////////////////////////////\n\n/** @internal */\nexport {\n NavigationContext as UNSAFE_NavigationContext,\n LocationContext as UNSAFE_LocationContext,\n RouteContext as UNSAFE_RouteContext\n};\n"],"names":["invariant","cond","message","Error","warning","console","warn","e","alreadyWarned","warningOnce","key","NavigationContext","React","displayName","LocationContext","RouteContext","outlet","matches","MemoryRouter","basename","children","initialEntries","initialIndex","historyRef","current","createMemoryHistory","history","state","setState","action","location","listen","React.createElement","Navigate","to","replace","useInRouterContext","static","navigate","useNavigate","Outlet","props","useOutlet","context","Route","_props","Router","basenameProp","locationProp","navigationType","NavigationType","Pop","navigator","staticProp","normalizePathname","navigationContext","parsePath","pathname","search","hash","trailingPathname","stripBasename","Routes","useRoutes","createRoutesFromChildren","useHref","useResolvedPath","joinedPathname","toPathname","getToPathname","endsWithSlash","endsWith","joinPaths","createHref","useLocation","useNavigationType","useMatch","pattern","matchPath","locationPathname","routePathnamesJson","JSON","stringify","map","match","pathnameBase","activeRef","options","go","path","resolveTo","parse","push","OutletContext","useOutletContext","useParams","routeMatch","length","params","routes","locationArg","parentMatches","parentParams","parentPathname","parentPathnameBase","parentRoute","route","parentPath","locationFromContext","parsedLocationArg","startsWith","remainingPathname","slice","matchRoutes","element","undefined","_renderMatches","Object","assign","forEach","type","apply","name","caseSensitive","index","generatePath","_","branches","flattenRoutes","rankRouteBranches","i","matchRouteBranch","parentsMeta","meta","relativePath","childrenIndex","routesMeta","concat","score","computeScore","sort","a","b","compareIndexes","paramRe","dynamicSegmentValue","indexRouteValue","emptySegmentValue","staticSegmentValue","splatPenalty","isSplat","s","segments","split","initialScore","some","filter","reduce","segment","test","siblings","every","n","branch","matchedParams","matchedPathname","end","renderMatches","reduceRight","matcher","paramNames","compilePath","captureGroups","memo","paramName","splatValue","safelyDecodeURIComponent","regexpSource","RegExp","value","decodeURIComponent","error","resolvePath","fromPathname","resolvePathname","normalizeSearch","normalizeHash","relativeSegments","pop","join","toArg","routePathnames","from","routePathnameIndex","toSegments","shift","toLowerCase","nextChar","charAt","paths"],"mappings":";;;;;;;;;;;;;AAiBA,SAASA,SAAT,CAAmBC,IAAnB,EAA8BC,OAA9B,EAA6D;AAC3D,MAAI,CAACD,IAAL,EAAW,MAAM,IAAIE,KAAJ,CAAUD,OAAV,CAAN;AACZ;;AAED,SAASE,OAAT,CAAiBH,IAAjB,EAA4BC,OAA5B,EAAmD;AACjD,MAAI,CAACD,IAAL,EAAW;AACT;AACA,QAAI,OAAOI,OAAP,KAAmB,WAAvB,EAAoCA,OAAO,CAACC,IAAR,CAAaJ,OAAb;;AAEpC,QAAI;AACF;AACA;AACA;AACA;AACA;AACA,YAAM,IAAIC,KAAJ,CAAUD,OAAV,CAAN,CANE;AAQH,KARD,CAQE,OAAOK,CAAP,EAAU;AACb;AACF;;AAED,MAAMC,aAAsC,GAAG,EAA/C;;AACA,SAASC,WAAT,CAAqBC,GAArB,EAAkCT,IAAlC,EAAiDC,OAAjD,EAAkE;AAChE,MAAI,CAACD,IAAD,IAAS,CAACO,aAAa,CAACE,GAAD,CAA3B,EAAkC;AAChCF,IAAAA,aAAa,CAACE,GAAD,CAAb,GAAqB,IAArB;AACA,4CAAAN,OAAO,CAAC,KAAD,EAAQF,OAAR,CAAP;AACD;AACF;AAGD;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;MASMS,iBAAiB,gBAAGC,aAAA,CAA6C,IAA7C;;AAE1B,2CAAa;AACXD,EAAAA,iBAAiB,CAACE,WAAlB,GAAgC,YAAhC;AACD;;MAOKC,eAAe,gBAAGF,aAAA,CAA2C,IAA3C;;AAExB,2CAAa;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