1"use strict"; 2(self["webpackChunktexttoimg_ai"] = self["webpackChunktexttoimg_ai"] || []).push([[4412],{ 3 4/***/ 7767: 5/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 6 7var react__WEBPACK_IMPORTED_MODULE_0___namespace_cache; 8/* harmony export */ __webpack_require__.d(__webpack_exports__, { 9/* harmony export */ BV: () => (/* binding */ Routes), 10/* harmony export */ Ix: () => (/* binding */ Router), 11/* harmony export */ V8: () => (/* binding */ logV6DeprecationWarnings), 12/* harmony export */ Zp: () => (/* binding */ useNavigate), 13/* harmony export */ g: () => (/* binding */ useParams), 14/* harmony export */ qh: () => (/* binding */ Route), 15/* harmony export */ sv: () => (/* binding */ Outlet), 16/* harmony export */ zy: () => (/* binding */ useLocation) 17/* harmony export */ }); 18/* unused harmony exports Await, MemoryRouter, Navigate, RouterProvider, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_mapRouteProperties, UNSAFE_useRouteId, UNSAFE_useRoutesImpl, createMemoryRouter, createRoutesFromChildren, createRoutesFromElements, renderMatches, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useMatch, useMatches, useNavigation, useNavigationType, useOutlet, useOutletContext, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes */ 19/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6540); 20/* harmony import */ var _remix_run_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5588); 21/** 22 * React Router v6.30.1 23 * 24 * Copyright (c) Remix Software Inc. 25 * 26 * This source code is licensed under the MIT license found in the 27 * LICENSE.md file in the root directory of this source tree. 28 * 29 * @license MIT 30 */ 31 32 33 34 35function _extends() { 36 _extends = Object.assign ? Object.assign.bind() : function (target) { 37 for (var i = 1; i < arguments.length; i++) { 38 var source = arguments[i]; 39 for (var key in source) { 40 if (Object.prototype.hasOwnProperty.call(source, key)) { 41 target[key] = source[key]; 42 } 43 } 44 } 45 return target; 46 }; 47 return _extends.apply(this, arguments); 48} 49 50// Create react-specific types from the agnostic types in @remix-run/router to 51// export from react-router 52const DataRouterContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); 53if (false) // removed by dead control flow 54{} 55const DataRouterStateContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); 56if (false) // removed by dead control flow 57{} 58const AwaitContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); 59if (false) // removed by dead control flow 60{} 61 62/** 63 * A Navigator is a "location changer"; it's how you get to different locations. 64 * 65 * Every history instance conforms to the Navigator interface, but the 66 * distinction is useful primarily when it comes to the low-level `<Router>` API 67 * where both the location and a navigator must be provided separately in order 68 * to avoid "tearing" that may occur in a suspense-enabled app if the action 69 * and/or location were to be read directly from the history instance. 70 */ 71 72const NavigationContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); 73if (false) // removed by dead control flow 74{} 75const LocationContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); 76if (false) // removed by dead control flow 77{} 78const RouteContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext({ 79 outlet: null, 80 matches: [], 81 isDataRoute: false 82}); 83if (false) // removed by dead control flow 84{} 85const RouteErrorContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); 86if (false) // removed by dead control flow 87{} 88 89/** 90 * Returns the full href for the given "to" value. This is useful for building 91 * custom links that are also accessible and preserve right-click behavior. 92 * 93 * @see https://reactrouter.com/v6/hooks/use-href 94 */ 95function useHref(to, _temp) { 96 let { 97 relative 98 } = _temp === void 0 ? {}
98 : _temp; 99 !useInRouterContext() ? false ? 0 : UNSAFE_invariant(false) : void 0; 100 let { 101 basename, 102 navigator 103 } = React.useContext(NavigationContext); 104 let { 105 hash, 106 pathname, 107 search 108 } = useResolvedPath(to, { 109 relative 110 }); 111 let joinedPathname = pathname; 112 113 // If we're operating within a basename, prepend it to the pathname prior 114 // to creating the href. If this is a root navigation, then just use the raw 115 // basename which allows the basename to have full control over the presence 116 // of a trailing slash on root links 117 if (basename !== "/") { 118 joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]); 119 } 120 return navigator.createHref({ 121 pathname: joinedPathname, 122 search, 123 hash 124 }); 125} 126 127/** 128 * Returns true if this component is a descendant of a `<Router>`. 129 * 130 * @see https://reactrouter.com/v6/hooks/use-in-router-context 131 */ 132function useInRouterContext() { 133 return react__WEBPACK_IMPORTED_MODULE_0__.useContext(LocationContext) != null; 134} 135 136/** 137 * Returns the current location object, which represents the current URL in web 138 * browsers. 139 * 140 * Note: If you're using this it may mean you're doing some of your own 141 * "routing" in your app, and we'd like to know what your use case is. We may 142 * be able to provide something higher-level to better suit your needs. 143 * 144 * @see https://reactrouter.com/v6/hooks/use-location 145 */ 146function useLocation() { 147 !useInRouterContext() ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 148 return react__WEBPACK_IMPORTED_MODULE_0__.useContext(LocationContext).location; 149} 150 151/** 152 * Returns the current navigation action which describes how the router came to 153 * the current location, either by a pop, push, or replace on the history stack. 154 * 155 * @see https://reactrouter.com/v6/hooks/use-navigation-type 156 */ 157function useNavigationType() { 158 return React.useContext(LocationContext).navigationType; 159} 160 161/** 162 * Returns a PathMatch object if the given pattern matches the current URL. 163 * This is useful for components that need to know "active" state, e.g. 164 * `<NavLink>`. 165 * 166 * @see https://reactrouter.com/v6/hooks/use-match 167 */ 168function useMatch(pattern) { 169 !useInRouterContext() ? false ? 0 : UNSAFE_invariant(false) : void 0; 170 let { 171 pathname 172 } = useLocation(); 173 return React.useMemo(() => matchPath(pattern, UNSAFE_decodePath(pathname)), [pathname, pattern]); 174} 175 176/** 177 * The interface for the navigate() function returned from useNavigate(). 178 */ 179 180const navigateEffectWarning = (/* unused pure expression or super */ null && ("You should call navigate() in a React.useEffect(), not when " + "your component is first rendered.")); 181 182// Mute warnings for calls to useNavigate in SSR environments 183function useIsomorphicLayoutEffect(cb) { 184 let isStatic = react__WEBPACK_IMPORTED_MODULE_0__.useContext(NavigationContext).static; 185 if (!isStatic) { 186 // We should be able to get rid of this once react 18.3 is released 187 // See: https://github.com/facebook/react/pull/26395 188 // eslint-disable-next-line react-hooks/rules-of-hooks 189 react__WEBPACK_IMPORTED_MODULE_0__.useLayoutEffect(cb); 190 } 191} 192 193/** 194 * Returns an imperative method for changing the location. Used by `<Link>`s, but 195 * may also be used by other elements to change the location. 196 * 197 * @see https://reactrouter.com/v6/hooks/use-navigate 198 */ 199function useNavigate() { 200 let { 201 isDataRoute 202 } = react__WEBPACK_IMPORTED_MODULE_0__.useContext(RouteContext); 203 // Conditional usage is OK here because the usage of a data router is static 204 // eslint-disable-next-line react-hooks/rules-of-hooks 205 return isDataRoute ? useNavigateStable() : useNavigateUnstable(); 206} 207function useNavigateUnstable() { 208 !useInRouterContext() ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 209 let dataRouterContext = react__WEBPACK_IMPORTED_MODULE_0__.useContext(DataRouterContext); 210 let { 211 basename, 212 future, 213 navigator 214 } = react__WEBPACK_IMPORTED_MODULE_0__.useContext(NavigationContext); 215 let { 216 matches 217 } = react__WEBPACK_IMPORTED_MODULE_0__.useContext(RouteContext); 218 let { 219 pathname: locationPathname 220 } = useLocation(); 221 let routePathnamesJson = JSON.stringify((0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_getResolveToMatches */ .yD)(matches, future.v7_relativeSplatPath)); 222 let activeRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(false); 223 useIsomorphicLayoutEffect(() => { 224 activeRef.current = true; 225 }); 226 let navigate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(function (to, options) { 227 if (options === void 0) { 228 options = {}; 229 } 230 false ? 0 : void 0; 231 232 // Short circuit here since if this happens on first render the navigate 233 // is useless because we haven't wired up our history listener yet 234 if (!activeRef.current) return; 235 if (typeof to === "number") { 236 navigator.go(to); 237 return; 238 } 239 let path = (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .resolveTo */ .Gh)(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path"); 240 241 // If we're operating within a basename, prepend it to the pathname prior 242 // to handing off to history (but only if we're not in a data router,
243 // otherwise it'll prepend the basename inside of the router). 244 // If this is a root navigation, then we navigate to the raw basename 245 // which allows the basename to have full control over the presence of a 246 // trailing slash on root links 247 if (dataRouterContext == null && basename !== "/") { 248 path.pathname = path.pathname === "/" ? basename : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .joinPaths */ .HS)([basename, path.pathname]); 249 } 250 (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options); 251 }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]); 252 return navigate; 253} 254const OutletContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createContext(null); 255 256/** 257 * Returns the context (if provided) for the child route at this level of the route 258 * hierarchy. 259 * @see https://reactrouter.com/v6/hooks/use-outlet-context 260 */ 261function useOutletContext() { 262 return React.useContext(OutletContext); 263} 264 265/** 266 * Returns the element for the child route at this level of the route 267 * hierarchy. Used internally by `<Outlet>` to render child routes. 268 * 269 * @see https://reactrouter.com/v6/hooks/use-outlet 270 */ 271function useOutlet(context) { 272 let outlet = react__WEBPACK_IMPORTED_MODULE_0__.useContext(RouteContext).outlet; 273 if (outlet) { 274 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(OutletContext.Provider, { 275 value: context 276 }, outlet); 277 } 278 return outlet; 279} 280 281/** 282 * Returns an object of key/value pairs of the dynamic params from the current 283 * URL that were matched by the route path. 284 * 285 * @see https://reactrouter.com/v6/hooks/use-params 286 */ 287function useParams() { 288 let { 289 matches 290 } = react__WEBPACK_IMPORTED_MODULE_0__.useContext(RouteContext); 291 let routeMatch = matches[matches.length - 1]; 292 return routeMatch ? routeMatch.params : {}; 293} 294 295/** 296 * Resolves the pathname of the given `to` value against the current location. 297 * 298 * @see https://reactrouter.com/v6/hooks/use-resolved-path 299 */ 300function useResolvedPath(to, _temp2) { 301 let { 302 relative 303 } = _temp2 === void 0 ? {} : _temp2; 304 let { 305 future 306 } = React.useContext(NavigationContext); 307 let { 308 matches 309 } = React.useContext(RouteContext); 310 let { 311 pathname: locationPathname 312 } = useLocation(); 313 let routePathnamesJson = JSON.stringify(UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath)); 314 return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]); 315} 316 317/** 318 * Returns the element of the route that matched the current location, prepared 319 * with the correct context to render the remainder of the route tree. Route 320 * elements in the tree must render an `<Outlet>` to render their child route's 321 * element. 322 * 323 * @see https://reactrouter.com/v6/hooks/use-routes 324 */ 325function useRoutes(routes, locationArg) { 326 return useRoutesImpl(routes, locationArg); 327} 328 329// Internal implementation with accept optional param for RouterProvider usage 330function useRoutesImpl(routes, locationArg, dataRouterState, future) { 331 !useInRouterContext() ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 332 let { 333 navigator 334 } = react__WEBPACK_IMPORTED_MODULE_0__.useContext(NavigationContext); 335 let { 336 matches: parentMatches 337 } = react__WEBPACK_IMPORTED_MODULE_0__.useContext(RouteContext); 338 let routeMatch = parentMatches[parentMatches.length - 1]; 339 let parentParams = routeMatch ? routeMatch.params : {}; 340 let parentPathname = routeMatch ? routeMatch.pathname : "/"; 341 let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/"; 342 let parentRoute = routeMatch && routeMatch.route; 343 if (false) // removed by dead control flow 344{} 345 let locationFromContext = useLocation(); 346 let location; 347 if (locationArg) { 348 var _parsedLocationArg$pa; 349 let parsedLocationArg = typeof locationArg === "string" ? (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .parsePath */ .Rr)(locationArg) : locationArg; 350 !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi
350)(false) : void 0; 351 location = parsedLocationArg; 352 } else { 353 location = locationFromContext; 354 } 355 let pathname = location.pathname || "/"; 356 let remainingPathname = pathname; 357 if (parentPathnameBase !== "/") { 358 // Determine the remaining pathname by removing the # of URL segments the 359 // parentPathnameBase has, instead of removing based on character count. 360 // This is because we can't guarantee that incoming/outgoing encodings/ 361 // decodings will match exactly. 362 // We decode paths before matching on a per-segment basis with 363 // decodeURIComponent(), but we re-encode pathnames via `new URL()` so they 364 // match what `window.location.pathname` would reflect. Those don't 100% 365 // align when it comes to encoded URI characters such as % and &. 366 // 367 // So we may end up with: 368 // pathname: "/descendant/a%25b/match" 369 // parentPathnameBase: "/descendant/a%b" 370 // 371 // And the direct substring removal approach won't work :/ 372 let parentSegments = parentPathnameBase.replace(/^\//, "").split("/"); 373 let segments = pathname.replace(/^\//, "").split("/"); 374 remainingPathname = "/" + segments.slice(parentSegments.length).join("/"); 375 } 376 let matches = (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .matchRoutes */ .ue)(routes, { 377 pathname: remainingPathname 378 }); 379 if (false) // removed by dead control flow 380{} 381 let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, { 382 params: Object.assign({}, parentParams, match.params), 383 pathname: (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .joinPaths */ .HS)([parentPathnameBase, 384 // Re-encode pathnames that were decoded inside matchRoutes 385 navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]), 386 pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .joinPaths */ .HS)([parentPathnameBase, 387 // Re-encode pathnames that were decoded inside matchRoutes 388 navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase]) 389 })), parentMatches, dataRouterState, future); 390 391 // When a user passes in a `locationArg`, the associated routes need to 392 // be wrapped in a new `LocationContext.Provider` in order for `useLocation` 393 // to use the scoped location instead of the global location. 394 if (locationArg && renderedMatches) { 395 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(LocationContext.Provider, { 396 value: { 397 location: _extends({ 398 pathname: "/", 399 search: "", 400 hash: "", 401 state: null, 402 key: "default" 403 }, location), 404 navigationType: _remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .Action */ .rc.Pop 405 } 406 }, renderedMatches); 407 } 408 return renderedMatches; 409} 410function DefaultErrorComponent() { 411 let error = useRouteError(); 412 let message = (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .isRouteErrorResponse */ .pX)(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error); 413 let stack = error instanceof Error ? error.stack : null; 414 let lightgrey = "rgba(200,200,200, 0.5)"; 415 let preStyles = { 416 padding: "0.5rem", 417 backgroundColor: lightgrey 418 }; 419 let codeStyles = { 420 padding: "2px 4px", 421 backgroundColor: lightgrey 422 }; 423 let devInfo = null; 424 if (false) // removed by dead control flow 425{} 426 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h2", null, "Unexpected Application Error!"), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("h3", { 427 style: { 428 fontStyle: "italic" 429 } 430 }, message), stack ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("pre", { 431 style: preStyles 432 }, stack) : null, devInfo); 433} 434const defaultErrorElement = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(DefaultErrorComponent, null); 435class RenderErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component { 436 constructor(props) { 437 super(props); 438 this.state = { 439 location: props.location, 440 revalidation: props.revalidation, 441 error: props.error 442 }; 443 } 444 static getDerivedStateFromError(error) { 445 return { 446 error: error 447 }; 448 } 449 static getDerivedStateFromProps(props, state) { 450 // When we get into an error state, the user will likely click "back" to the 451 // previous page that didn't have an error. Because this wraps the entire 452 // application, that will have no effect--the error page continues to display. 453 // This gives us a mechanism to recover from the error when the location changes. 454 // 455 // Whether we're in an error state or not, we update the location in state 456 // so that when we are in an error state, it gets reset when a new location 457 // comes in and the user recovers from the error. 458 if (state.location !== props.location || state.revalidation !== "i
458dle" && props.revalidation === "idle") { 459 return { 460 error: props.error, 461 location: props.location, 462 revalidation: props.revalidation 463 }; 464 } 465 466 // If we're not changing locations, preserve the location but still surface 467 // any new errors that may come through. We retain the existing error, we do 468 // this because the error provided from the app state may be cleared without 469 // the location changing. 470 return { 471 error: props.error !== undefined ? props.error : state.error, 472 location: state.location, 473 revalidation: props.revalidation || state.revalidation 474 }; 475 } 476 componentDidCatch(error, errorInfo) { 477 console.error("React Router caught the following error during render", error, errorInfo); 478 } 479 render() { 480 return this.state.error !== undefined ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RouteContext.Provider, { 481 value: this.props.routeContext 482 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RouteErrorContext.Provider, { 483 value: this.state.error, 484 children: this.props.component 485 })) : this.props.children; 486 } 487} 488function RenderedRoute(_ref) { 489 let { 490 routeContext, 491 match, 492 children 493 } = _ref; 494 let dataRouterContext = react__WEBPACK_IMPORTED_MODULE_0__.useContext(DataRouterContext); 495 496 // Track how deep we got in our render pass to emulate SSR componentDidCatch 497 // in a DataStaticRouter 498 if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) { 499 dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id; 500 } 501 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RouteContext.Provider, { 502 value: routeContext 503 }, children); 504} 505function _renderMatches(matches, parentMatches, dataRouterState, future) { 506 var _dataRouterState; 507 if (parentMatches === void 0) { 508 parentMatches = []; 509 } 510 if (dataRouterState === void 0) { 511 dataRouterState = null; 512 } 513 if (future === void 0) { 514 future = null; 515 } 516 if (matches == null) { 517 var _future; 518 if (!dataRouterState) { 519 return null; 520 } 521 if (dataRouterState.errors) { 522 // Don't bail if we have data router errors so we can render them in the 523 // boundary. Use the pre-matched (or shimmed) matches 524 matches = dataRouterState.matches; 525 } else if ((_future = future) != null && _future.v7_partialHydration && parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) { 526 // Don't bail if we're initializing with partial hydration and we have 527 // router matches. That means we're actively running `patchRoutesOnNavigation` 528 // so we should render down the partial matches to the appropriate 529 // `HydrateFallback`. We only do this if `parentMatches` is empty so it 530 // only impacts the root matches for `RouterProvider` and no descendant 531 // `<Routes>` 532 matches = dataRouterState.matches; 533 } else { 534 return null; 535 } 536 } 537 let renderedMatches = matches; 538 539 // If we have data errors, trim matches to the highest error boundary 540 let errors = (_dataRouterState = dataRouterState) == null ? void 0 : _dataRouterState.errors; 541 if (errors != null) { 542 let errorIndex = renderedMatches.findIndex(m => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== undefined); 543 !(errorIndex >= 0) ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 544 renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1)); 545 } 546 547 // If we're in a partial hydration mode, detect if we need to render down to 548 // a given HydrateFallback while we load the rest of the hydration data 549 let renderFallback = false; 550 let fallbackIndex = -1; 551 if (dataRouterState && future && future.v7_partialHydration) { 552 for (let i = 0; i < renderedMatches.length; i++) { 553 let match = renderedMatches[i]; 554 // Track the deepest fallback up until the first route without data 555 if (match.route.HydrateFallback || match.route.hydrateFallbackElement) { 556 fallbackIndex = i; 557 } 558 if (match.route.id) { 559 let { 560 loaderData, 561 errors 562 } = dataRouterState; 563 let needsToRunLoader = match.route.loader && loaderData[match.route.id] === undefined && (!errors || errors[match.route.id] === undefined); 564 if (match.route.lazy || needsToRunLoader) { 565 // We found the first route that's not ready to render (waiting on 566 // lazy, or has a loader that hasn't run yet). Flag that we need to 567 // render a fallback and render up until the appropriate fallback 568 renderFallback = true; 569 if (fallbackIndex >= 0) { 570 renderedMatches = renderedMatches.slice(0, fallbackIndex + 1); 571 } else { 572 renderedMatches = [renderedMatches[0]]; 573 } 574 break; 575 } 576 } 577 } 578 } 579 return renderedMatches.reduceRight((outlet, match, index) => { 580 // Only data routers handle errors/fallbacks 581 let error; 582 let shouldRenderHydrateFallback = false;
583 let errorElement = null; 584 let hydrateFallbackElement = null; 585 if (dataRouterState) { 586 error = errors && match.route.id ? errors[match.route.id] : undefined; 587 errorElement = match.route.errorElement || defaultErrorElement; 588 if (renderFallback) { 589 if (fallbackIndex < 0 && index === 0) { 590 warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration"); 591 shouldRenderHydrateFallback = true; 592 hydrateFallbackElement = null; 593 } else if (fallbackIndex === index) { 594 shouldRenderHydrateFallback = true; 595 hydrateFallbackElement = match.route.hydrateFallbackElement || null; 596 } 597 } 598 } 599 let matches = parentMatches.concat(renderedMatches.slice(0, index + 1)); 600 let getChildren = () => { 601 let children; 602 if (error) { 603 children = errorElement; 604 } else if (shouldRenderHydrateFallback) { 605 children = hydrateFallbackElement; 606 } else if (match.route.Component) { 607 // Note: This is a de-optimized path since React won't re-use the 608 // ReactElement since it's identity changes with each new 609 // React.createElement call. We keep this so folks can use 610 // `<Route Component={...}>` in `<Routes>` but generally `Component` 611 // usage is only advised in `RouterProvider` when we can convert it to 612 // `element` ahead of time. 613 children = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(match.route.Component, null); 614 } else if (match.route.element) { 615 children = match.route.element; 616 } else { 617 children = outlet; 618 } 619 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RenderedRoute, { 620 match: match, 621 routeContext: { 622 outlet, 623 matches, 624 isDataRoute: dataRouterState != null 625 }, 626 children: children 627 }); 628 }; 629 // Only wrap in an error boundary within data router usages when we have an 630 // ErrorBoundary/errorElement on this route. Otherwise let it bubble up to 631 // an ancestor ErrorBoundary/errorElement 632 return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(RenderErrorBoundary, { 633 location: dataRouterState.location, 634 revalidation: dataRouterState.revalidation, 635 component: errorElement, 636 error: error, 637 children: getChildren(), 638 routeContext: { 639 outlet: null, 640 matches, 641 isDataRoute: true 642 } 643 }) : getChildren(); 644 }, null); 645} 646var DataRouterHook = /*#__PURE__*/function (DataRouterHook) { 647 DataRouterHook["UseBlocker"] = "useBlocker"; 648 DataRouterHook["UseRevalidator"] = "useRevalidator"; 649 DataRouterHook["UseNavigateStable"] = "useNavigate"; 650 return DataRouterHook; 651}(DataRouterHook || {}); 652var DataRouterStateHook = /*#__PURE__*/function (DataRouterStateHook) { 653 DataRouterStateHook["UseBlocker"] = "useBlocker"; 654 DataRouterStateHook["UseLoaderData"] = "useLoaderData"; 655 DataRouterStateHook["UseActionData"] = "useActionData"; 656 DataRouterStateHook["UseRouteError"] = "useRouteError"; 657 DataRouterStateHook["UseNavigation"] = "useNavigation"; 658 DataRouterStateHook["UseRouteLoaderData"] = "useRouteLoaderData"; 659 DataRouterStateHook["UseMatches"] = "useMatches"; 660 DataRouterStateHook["UseRevalidator"] = "useRevalidator"; 661 DataRouterStateHook["UseNavigateStable"] = "useNavigate"; 662 DataRouterStateHook["UseRouteId"] = "useRouteId"; 663 return DataRouterStateHook; 664}(DataRouterStateHook || {}); 665function getDataRouterConsoleError(hookName) { 666 return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router."; 667} 668function useDataRouterContext(hookName) { 669 let ctx = react__WEBPACK_IMPORTED_MODULE_0__.useContext(DataRouterContext); 670 !ctx ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 671 return ctx; 672} 673function useDataRouterState(hookName) { 674 let state = react__WEBPACK_IMPORTED_MODULE_0__.useContext(DataRouterStateContext); 675 !state ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi
675)(false) : void 0; 676 return state; 677} 678function useRouteContext(hookName) { 679 let route = react__WEBPACK_IMPORTED_MODULE_0__.useContext(RouteContext); 680 !route ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 681 return route; 682} 683 684// Internal version with hookName-aware debugging 685function useCurrentRouteId(hookName) { 686 let route = useRouteContext(hookName); 687 let thisRoute = route.matches[route.matches.length - 1]; 688 !thisRoute.route.id ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 689 return thisRoute.route.id; 690} 691 692/** 693 * Returns the ID for the nearest contextual route 694 */ 695function useRouteId() { 696 return useCurrentRouteId(DataRouterStateHook.UseRouteId); 697} 698 699/** 700 * Returns the current navigation, defaulting to an "idle" navigation when 701 * no navigation is in progress 702 */ 703function useNavigation() { 704 let state = useDataRouterState(DataRouterStateHook.UseNavigation); 705 return state.navigation; 706} 707 708/** 709 * Returns a revalidate function for manually triggering revalidation, as well 710 * as the current state of any manual revalidations 711 */ 712function useRevalidator() { 713 let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator); 714 let state = useDataRouterState(DataRouterStateHook.UseRevalidator); 715 return React.useMemo(() => ({ 716 revalidate: dataRouterContext.router.revalidate, 717 state: state.revalidation 718 }), [dataRouterContext.router.revalidate, state.revalidation]); 719} 720 721/** 722 * Returns the active route matches, useful for accessing loaderData for 723 * parent/child routes or the route "handle" property 724 */ 725function useMatches() { 726 let { 727 matches, 728 loaderData 729 } = useDataRouterState(DataRouterStateHook.UseMatches); 730 return React.useMemo(() => matches.map(m => UNSAFE_convertRouteMatchToUiMatch(m, loaderData)), [matches, loaderData]); 731} 732 733/** 734 * Returns the loader data for the nearest ancestor Route loader 735 */ 736function useLoaderData() { 737 let state = useDataRouterState(DataRouterStateHook.UseLoaderData); 738 let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData); 739 if (state.errors && state.errors[routeId] != null) { 740 console.error("You cannot `useLoaderData` in an errorElement (routeId: " + routeId + ")"); 741 return undefined; 742 } 743 return state.loaderData[routeId]; 744} 745 746/** 747 * Returns the loaderData for the given routeId 748 */ 749function useRouteLoaderData(routeId) { 750 let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData); 751 return state.loaderData[routeId]; 752} 753 754/** 755 * Returns the action data for the nearest ancestor Route action 756 */ 757function useActionData() { 758 let state = useDataRouterState(DataRouterStateHook.UseActionData); 759 let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData); 760 return state.actionData ? state.actionData[routeId] : undefined; 761} 762 763/** 764 * Returns the nearest ancestor Route error, which could be a loader/action 765 * error or a render error. This is intended to be called from your 766 * ErrorBoundary/errorElement to display a proper error message. 767 */ 768function useRouteError() { 769 var _state$errors; 770 let error = react__WEBPACK_IMPORTED_MODULE_0__.useContext(RouteErrorContext); 771 let state = useDataRouterState(DataRouterStateHook.UseRouteError); 772 let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError); 773 774 // If this was a render error, we put it in a RouteError context inside 775 // of RenderErrorBoundary 776 if (error !== undefined) { 777 return error; 778 } 779 780 // Otherwise look for errors from our data router state 781 return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId]; 782} 783 784/** 785 * Returns the happy-path data from the nearest ancestor `<Await />` value 786 */ 787function useAsyncValue() { 788 let value = React.useContext(AwaitContext); 789 return value == null ? void 0 : value._data; 790} 791 792/** 793 * Returns the error from the nearest ancestor `<Await />` value 794 */ 795function useAsyncError() { 796 let value = React.useContext(AwaitContext); 797 return value == null ? void 0 : value._error; 798} 799let blockerId = 0; 800 801/** 802 * Allow the application to block navigations within the SPA and present the 803 * user a confirmation dialog to confirm the navigation. Mostly used to avoid 804 * using half-filled form data. This does not handle hard-reloads or 805 * cross-origin navigations. 806 */ 807function useBlocker(shouldBlock) { 808 let { 809 router, 810 basename 811 } = useDataRouterContext(DataRouterHook.UseBlocker); 812 let state = useDataRouterState(DataRouterStateHook.UseBlocker); 813 let [blockerKey, setBlockerKey] = React.useState(""); 814 let blockerFunction = React.useCallback(arg => { 815 if (typeof shouldBlock !== "function") { 816 return !!shouldBlock; 817 } 818 if (basename === "/") { 819 return shouldBlock(arg); 820 } 821 822 // If they provided us a function and we've got an active basename, strip 823 // it from the locations we expose to the user to match the behavior of 824 // useLocation 825 let { 826 currentLocation, 827 nextLocation, 828 historyAction 829 } = arg; 830 return shouldBlock({ 831 currentLocation: _extends({}, currentLocation, {
832 pathname: stripBasename(currentLocation.pathname, basename) || currentLocation.pathname 833 }), 834 nextLocation: _extends({}, nextLocation, { 835 pathname: stripBasename(nextLocation.pathname, basename) || nextLocation.pathname 836 }), 837 historyAction 838 }); 839 }, [basename, shouldBlock]); 840 841 // This effect is in charge of blocker key assignment and deletion (which is 842 // tightly coupled to the key) 843 React.useEffect(() => { 844 let key = String(++blockerId); 845 setBlockerKey(key); 846 return () => router.deleteBlocker(key); 847 }, [router]); 848 849 // This effect handles assigning the blockerFunction. This is to handle 850 // unstable blocker function identities, and happens only after the prior 851 // effect so we don't get an orphaned blockerFunction in the router with a 852 // key of "". Until then we just have the IDLE_BLOCKER. 853 React.useEffect(() => { 854 if (blockerKey !== "") { 855 router.getBlocker(blockerKey, blockerFunction); 856 } 857 }, [router, blockerKey, blockerFunction]); 858 859 // Prefer the blocker from `state` not `router.state` since DataRouterContext 860 // is memoized so this ensures we update on blocker state updates 861 return blockerKey && state.blockers.has(blockerKey) ? state.blockers.get(blockerKey) : IDLE_BLOCKER; 862} 863 864/** 865 * Stable version of useNavigate that is used when we are in the context of 866 * a RouterProvider. 867 */ 868function useNavigateStable() { 869 let { 870 router 871 } = useDataRouterContext(DataRouterHook.UseNavigateStable); 872 let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable); 873 let activeRef = react__WEBPACK_IMPORTED_MODULE_0__.useRef(false); 874 useIsomorphicLayoutEffect(() => { 875 activeRef.current = true; 876 }); 877 let navigate = react__WEBPACK_IMPORTED_MODULE_0__.useCallback(function (to, options) { 878 if (options === void 0) { 879 options = {}; 880 } 881 false ? 0 : void 0; 882 883 // Short circuit here since if this happens on first render the navigate 884 // is useless because we haven't wired up our router subscriber yet 885 if (!activeRef.current) return; 886 if (typeof to === "number") { 887 router.navigate(to); 888 } else { 889 router.navigate(to, _extends({ 890 fromRouteId: id 891 }, options)); 892 } 893 }, [router, id]); 894 return navigate; 895} 896const alreadyWarned$1 = {}; 897function warningOnce(key, cond, message) { 898 if (!cond && !alreadyWarned$1[key]) { 899 alreadyWarned$1[key] = true; 900 false ? 0 : void 0; 901 } 902} 903 904const alreadyWarned = {}; 905function warnOnce(key, message) { 906 if (false) // removed by dead control flow 907{} 908} 909const logDeprecation = (flag, msg, link) => warnOnce(flag, "\u26A0\uFE0F React Router Future Flag Warning: " + msg + ". " + ("You can use the `" + flag + "` future flag to opt-in early. ") + ("For more information, see " + link + ".")); 910function logV6DeprecationWarnings(renderFuture, routerFuture) { 911 if ((renderFuture == null ? void 0 : renderFuture.v7_startTransition) === undefined) { 912 logDeprecation("v7_startTransition", "React Router will begin wrapping state updates in `React.startTransition` in v7", "https://reactrouter.com/v6/upgrading/future#v7_starttransition"); 913 } 914 if ((renderFuture == null ? void 0 : renderFuture.v7_relativeSplatPath) === undefined && (!routerFuture || routerFuture.v7_relativeSplatPath === undefined)) { 915 logDeprecation("v7_relativeSplatPath", "Relative route resolution within Splat routes is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath"); 916 } 917 if (routerFuture) { 918 if (routerFuture.v7_fetcherPersist === undefined) { 919 logDeprecation("v7_fetcherPersist", "The persistence behavior of fetchers is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist"); 920 } 921 if (routerFuture.v7_normalizeFormMethod === undefined) { 922 logDeprecation("v7_normalizeFormMethod", "Casing of `formMethod` fields is being normalized to uppercase in v7", "https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod"); 923 } 924 if (routerFuture.v7_partialHydration === undefined) { 925 logDeprecation("v7_partialHydration", "`RouterProvider` hydration behavior is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_partialhydration"); 926 } 927 if (routerFuture.v7_skipActionErrorRevalidation === undefined) { 928 logDeprecation("v7_skipActionErrorRevalidation", "The revalidation behavior after 4xx/5xx `action` responses is changing in v7", "https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation"); 929 } 930 } 931} 932 933/** 934 Webpack + React 17 fails to compile on any of the following because webpack 935 complains that `startTransition` doesn't exist in `React`: 936 * import { startTransition } from "react" 937 * import * as React from from "react"; 938 "startTransition" in React ? React.startTransition(() => setState()) : setState() 939 * import * as React from from "react"; 940 "startTransition" in React ? React["startTransition"](() => setState()) : setState() 941 942 Moving it to a constant such as the following solves the Webpack/React 17 issue: 943 * import * as React from from "react"; 944 const START_TRANSITION = "startTransition"; 945 START_TRANSITION in React ? React[START_TRANSITION](() => setState()) : setState() 946
947 However, that introduces webpack/terser minification issues in production builds 948 in React 18 where minification/obfuscation ends up removing the call of 949 React.startTransition entirely from the first half of the ternary. Grabbing 950 this exported reference once up front resolves that issue. 951 952 See https://github.com/remix-run/react-router/issues/10579 953*/ 954const START_TRANSITION = "startTransition"; 955const startTransitionImpl = /*#__PURE__*/ (react__WEBPACK_IMPORTED_MODULE_0___namespace_cache || (react__WEBPACK_IMPORTED_MODULE_0___namespace_cache = __webpack_require__.t(react__WEBPACK_IMPORTED_MODULE_0__, 2)))[START_TRANSITION]; 956 957/** 958 * Given a Remix Router instance, render the appropriate UI 959 */ 960function RouterProvider(_ref) { 961 let { 962 fallbackElement, 963 router, 964 future 965 } = _ref; 966 let [state, setStateImpl] = React.useState(router.state); 967 let { 968 v7_startTransition 969 } = future || {}; 970 let setState = React.useCallback(newState => { 971 if (v7_startTransition && startTransitionImpl) { 972 startTransitionImpl(() => setStateImpl(newState)); 973 } else { 974 setStateImpl(newState); 975 } 976 }, [setStateImpl, v7_startTransition]); 977 978 // Need to use a layout effect here so we are subscribed early enough to 979 // pick up on any render-driven redirects/navigations (useEffect/<Navigate>) 980 React.useLayoutEffect(() => router.subscribe(setState), [router, setState]); 981 React.useEffect(() => { 982 false ? 0 : void 0; 983 // Only log this once on initial mount 984 // eslint-disable-next-line react-hooks/exhaustive-deps 985 }, []); 986 let navigator = React.useMemo(() => { 987 return { 988 createHref: router.createHref, 989 encodeLocation: router.encodeLocation, 990 go: n => router.navigate(n), 991 push: (to, state, opts) => router.navigate(to, { 992 state, 993 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset 994 }), 995 replace: (to, state, opts) => router.navigate(to, { 996 replace: true, 997 state, 998 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset 999 }) 1000 }; 1001 }, [router]); 1002 let basename = router.basename || "/"; 1003 let dataRouterContext = React.useMemo(() => ({ 1004 router, 1005 navigator, 1006 static: false, 1007 basename 1008 }), [router, navigator, basename]); 1009 React.useEffect(() => logV6DeprecationWarnings(future, router.future), [router, future]); 1010 1011 // The fragment and {null} here are important! We need them to keep React 18's 1012 // useId happy when we are server-rendering since we may have a <script> here 1013 // containing the hydrated server-side staticContext (from StaticRouterProvider). 1014 // useId relies on the component tree structure to generate deterministic id's 1015 // so we need to ensure it remains the same on the client even though 1016 // we don't need the <script> tag 1017 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DataRouterContext.Provider, { 1018 value: dataRouterContext 1019 }, /*#__PURE__*/React.createElement(DataRouterStateContext.Provider, { 1020 value: state 1021 }, /*#__PURE__*/React.createElement(Router, { 1022 basename: basename, 1023 location: state.location, 1024 navigationType: state.historyAction, 1025 navigator: navigator, 1026 future: { 1027 v7_relativeSplatPath: router.future.v7_relativeSplatPath 1028 } 1029 }, state.initialized || router.future.v7_partialHydration ? /*#__PURE__*/React.createElement(DataRoutes, { 1030 routes: router.routes, 1031 future: router.future, 1032 state: state 1033 }) : fallbackElement))), null); 1034} 1035function DataRoutes(_ref2) { 1036 let { 1037 routes, 1038 future, 1039 state 1040 } = _ref2; 1041 return useRoutesImpl(routes, undefined, state, future); 1042} 1043/** 1044 * A `<Router>` that stores all entries in memory. 1045 * 1046 * @see https://reactrouter.com/v6/router-components/memory-router 1047 */ 1048function MemoryRouter(_ref3) { 1049 let { 1050 basename, 1051 children, 1052 initialEntries, 1053 initialIndex, 1054 future 1055 } = _ref3; 1056 let historyRef = React.useRef(); 1057 if (historyRef.current == null) { 1058 historyRef.current = createMemoryHistory({ 1059 initialEntries, 1060 initialIndex, 1061 v5Compat: true 1062 }); 1063 } 1064 let history = historyRef.current; 1065 let [state, setStateImpl] = React.useState({ 1066 action: history.action, 1067 location: history.location 1068 }); 1069 let { 1070 v7_startTransition 1071 } = future || {}; 1072 let setState = React.useCallback(newState => { 1073 v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState); 1074 }, [setStateImpl, v7_startTransition]); 1075 React.useLayoutEffect(() => history.listen(setState), [history, setState]); 1076 React.useEffect(() => logV6DeprecationWarnings(future), [future]); 1077 return /*#__PURE__*/React.createElement(Router, { 1078 basename: basename, 1079 children: children, 1080 location: state.location, 1081 navigationType: state.action, 1082 navigator: history, 1083 future: future 1084 }); 1085} 1086/** 1087 * Changes the current location. 1088 *
1089 * Note: This API is mostly useful in React.Component subclasses that are not 1090 * able to use hooks. In functional components, we recommend you use the 1091 * `useNavigate` hook instead. 1092 * 1093 * @see https://reactrouter.com/v6/components/navigate 1094 */ 1095function Navigate(_ref4) { 1096 let { 1097 to, 1098 replace, 1099 state, 1100 relative 1101 } = _ref4; 1102 !useInRouterContext() ? false ? 0 : UNSAFE_invariant(false) : void 0; 1103 let { 1104 future, 1105 static: isStatic 1106 } = React.useContext(NavigationContext); 1107 false ? 0 : void 0; 1108 let { 1109 matches 1110 } = React.useContext(RouteContext); 1111 let { 1112 pathname: locationPathname 1113 } = useLocation(); 1114 let navigate = useNavigate(); 1115 1116 // Resolve the path outside of the effect so that when effects run twice in 1117 // StrictMode they navigate to the same place 1118 let path = resolveTo(to, UNSAFE_getResolveToMatches(matches, future.v7_relativeSplatPath), locationPathname, relative === "path"); 1119 let jsonPath = JSON.stringify(path); 1120 React.useEffect(() => navigate(JSON.parse(jsonPath), { 1121 replace, 1122 state, 1123 relative 1124 }), [navigate, jsonPath, relative, replace, state]); 1125 return null; 1126} 1127/** 1128 * Renders the child route's element, if there is one. 1129 * 1130 * @see https://reactrouter.com/v6/components/outlet 1131 */ 1132function Outlet(props) { 1133 return useOutlet(props.context); 1134} 1135/** 1136 * Declares an element that should be rendered at a certain URL path. 1137 * 1138 * @see https://reactrouter.com/v6/components/route 1139 */ 1140function Route(_props) { 1141 false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) ; 1142} 1143/** 1144 * Provides location context for the rest of the app. 1145 * 1146 * Note: You usually won't render a `<Router>` directly. Instead, you'll render a 1147 * router that is more specific to your environment such as a `<BrowserRouter>` 1148 * in web browsers or a `<StaticRouter>` for server rendering. 1149 * 1150 * @see https://reactrouter.com/v6/router-components/router 1151 */ 1152function Router(_ref5) { 1153 let { 1154 basename: basenameProp = "/", 1155 children = null, 1156 location: locationProp, 1157 navigationType = _remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .Action */ .rc.Pop, 1158 navigator, 1159 static: staticProp = false, 1160 future 1161 } = _ref5; 1162 !!useInRouterContext() ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 1163 1164 // Preserve trailing slashes on basename, so we can let the user control 1165 // the enforcement of trailing slashes throughout the app 1166 let basename = basenameProp.replace(/^\/*/, "/"); 1167 let navigationContext = react__WEBPACK_IMPORTED_MODULE_0__.useMemo(() => ({ 1168 basename, 1169 navigator, 1170 static: staticProp, 1171 future: _extends({ 1172 v7_relativeSplatPath: false 1173 }, future) 1174 }), [basename, future, navigator, staticProp]); 1175 if (typeof locationProp === "string") { 1176 locationProp = (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .parsePath */ .Rr)(locationProp); 1177 } 1178 let { 1179 pathname = "/", 1180 search = "", 1181 hash = "", 1182 state = null, 1183 key = "default" 1184 } = locationProp; 1185 let locationContext = react__WEBPACK_IMPORTED_MODULE_0__.useMemo(() => { 1186 let trailingPathname = (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .stripBasename */ .pb)(pathname, basename); 1187 if (trailingPathname == null) { 1188 return null; 1189 } 1190 return { 1191 location: { 1192 pathname: trailingPathname, 1193 search, 1194 hash, 1195 state, 1196 key 1197 }, 1198 navigationType 1199 }; 1200 }, [basename, pathname, search, hash, state, key, navigationType]); 1201 false ? 0 : void 0; 1202 if (locationContext == null) { 1203 return null; 1204 } 1205 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(NavigationContext.Provider, { 1206 value: navigationContext 1207 }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(LocationContext.Provider, { 1208 children: children, 1209 value: locationContext 1210 })); 1211} 1212/** 1213 * A container for a nested tree of `<Route>` elements that renders the branch 1214 * that best matches the current location. 1215 * 1216 * @see https://reactrouter.com/v6/components/routes 1217 */ 1218function Routes(_ref6) { 1219 let { 1220 children, 1221 location 1222 } = _ref6; 1223 return useRoutes(createRoutesFromChildren(children), location); 1224} 1225/** 1226 * Component to use for rendering lazily loaded data from returning defer() 1227 * in a loader function 1228 */ 1229function Await(_ref7) { 1230 let { 1231 children, 1232 errorElement, 1233 resolve 1234 } = _ref7; 1235 return /*#__PURE__*/React.createElement(AwaitErrorBoundary, { 1236 resolve: resolve, 1237 errorElement: errorElement 1238 }, /*#__PURE__*/React.createElement(ResolveAwait, null, children)); 1239} 1240var AwaitRenderStatus = /*#__PURE__*/function (AwaitRenderStatus) { 1241 AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending"; 1242 AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success"; 1243 AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error"; 1244 return AwaitRenderStatus; 1245}(AwaitRenderStatus || {}); 1246const neverSettledPromise = new Promise(() => {}); 1247class AwaitErrorBoundary extends react__WEBPACK_IMPORTED_MODULE_0__.Component { 1248 constructor(props) { 1249 super(props); 1250 this.state = { 1251 error: null 1252 }; 1253 } 1254 static getDerivedStateFromError(error) { 1255 return { 1256 error 1257 }; 1258 } 1259 componentDidCatch(error, errorInfo) { 1260 console.error("<Await> caught the following error during render", error, errorInfo); 1261 } 1262 render() { 1263 let { 1264 children, 1265 errorElement, 1266 resolve 1267 } = this.props; 1268 let promise = null; 1269 let status = AwaitRenderStatus.pending; 1270 if (!(resolve instanceof Promise)) { 1271 // Didn't get a promise - provide as a resolved promise 1272 status = AwaitRenderStatus.success; 1273 promise = Promise.resolve(); 1274 Object.defineProperty(promise, "_tracked", { 1275 get: () => true 1276 }); 1277 Object.defineProperty(promise, "_data", { 1278 get: () => resolve 1279 }); 1280 } else if (this.state.error) { 1281 // Caught a render error, provide it as a rejected promise 1282 status = AwaitRenderStatus.error; 1283 let renderError = this.state.error; 1284 promise = Promise.reject().catch(() => {}); // Avoid unhandled rejection warnings 1285 Object.defineProperty(promise, "_tracked", { 1286 get: () => true 1287 }); 1288 Object.defineProperty(promise, "_error", { 1289 get: () => renderError 1290 }); 1291 } else if (resolve._tracked) { 1292 // Already tracked promise - check contents 1293 promise = resolve; 1294 status = "_error" in promise ? AwaitRenderStatus.error : "_data" in promise ? AwaitRenderStatus.success : AwaitRenderStatus.pending; 1295 } else { 1296 // Raw (untracked) promise - track it 1297 status = AwaitRenderStatus.pending; 1298 Object.defineProperty(resolve, "_tracked", { 1299 get: () => true 1300 }); 1301 promise = resolve.then(data => Object.defineProperty(resolve, "_data", { 1302 get: () => data 1303 }), error => Object.defineProperty(resolve, "_error", { 1304 get: () => error 1305 })); 1306 } 1307 if (status === AwaitRenderStatus.error && promise._error instanceof _remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .AbortedDeferredError */ .tH) { 1308 // Freeze the UI by throwing a never resolved promise 1309 throw neverSettledPromise; 1310 } 1311 if (status === AwaitRenderStatus.error && !errorElement) { 1312 // No errorElement, throw to the nearest route-level error boundary 1313 throw promise._error; 1314 } 1315 if (status === AwaitRenderStatus.error) { 1316 // Render via our errorElement 1317 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(AwaitContext.Provider, { 1318 value: promise, 1319 children: errorElement 1320 }); 1321 } 1322 if (status === AwaitRenderStatus.success) { 1323 // Render children with resolved value 1324 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(AwaitContext.Provider, { 1325 value: promise, 1326 children: children 1327 }); 1328 } 1329 1330 // Throw to the suspense boundary 1331 throw promise; 1332 } 1333} 1334 1335/** 1336 * @private 1337 * Indirection to leverage useAsyncValue for a render-prop API on `<Await>` 1338 */ 1339function ResolveAwait(_ref8) { 1340 let { 1341 children 1342 } = _ref8; 1343 let data = useAsyncValue(); 1344 let toRender = typeof children === "function" ? children(data) : children; 1345 return /*#__PURE__*/React.createElement(React.Fragment, null, toRender); 1346} 1347
1348/////////////////////////////////////////////////////////////////////////////// 1349// UTILS 1350/////////////////////////////////////////////////////////////////////////////// 1351 1352/** 1353 * Creates a route config from a React "children" object, which is usually 1354 * either a `<Route>` element or an array of them. Used internally by 1355 * `<Routes>` to create a route config from its children. 1356 * 1357 * @see https://reactrouter.com/v6/utils/create-routes-from-children 1358 */ 1359function createRoutesFromChildren(children, parentPath) { 1360 if (parentPath === void 0) { 1361 parentPath = []; 1362 } 1363 let routes = []; 1364 react__WEBPACK_IMPORTED_MODULE_0__.Children.forEach(children, (element, index) => { 1365 if (! /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.isValidElement(element)) { 1366 // Ignore non-elements. This allows people to more easily inline 1367 // conditionals in their route config. 1368 return; 1369 } 1370 let treePath = [...parentPath, index]; 1371 if (element.type === react__WEBPACK_IMPORTED_MODULE_0__.Fragment) { 1372 // Transparently support React.Fragment and its children. 1373 routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath)); 1374 return; 1375 } 1376 !(element.type === Route) ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 1377 !(!element.props.index || !element.props.children) ? false ? 0 : (0,_remix_run_router__WEBPACK_IMPORTED_MODULE_1__/* .UNSAFE_invariant */ .Oi)(false) : void 0; 1378 let route = { 1379 id: element.props.id || treePath.join("-"), 1380 caseSensitive: element.props.caseSensitive, 1381 element: element.props.element, 1382 Component: element.props.Component, 1383 index: element.props.index, 1384 path: element.props.path, 1385 loader: element.props.loader, 1386 action: element.props.action, 1387 errorElement: element.props.errorElement, 1388 ErrorBoundary: element.props.ErrorBoundary, 1389 hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null, 1390 shouldRevalidate: element.props.shouldRevalidate, 1391 handle: element.props.handle, 1392 lazy: element.props.lazy 1393 }; 1394 if (element.props.children) { 1395 route.children = createRoutesFromChildren(element.props.children, treePath); 1396 } 1397 routes.push(route); 1398 }); 1399 return routes; 1400} 1401 1402/** 1403 * Renders the result of `matchRoutes()` into a React element. 1404 */ 1405function renderMatches(matches) { 1406 return _renderMatches(matches); 1407} 1408 1409function mapRouteProperties(route) { 1410 let updates = { 1411 // Note: this check also occurs in createRoutesFromChildren so update 1412 // there if you change this -- please and thank you! 1413 hasErrorBoundary: route.ErrorBoundary != null || route.errorElement != null 1414 }; 1415 if (route.Component) { 1416 if (false) // removed by dead control flow 1417{} 1418 Object.assign(updates, { 1419 element: /*#__PURE__*/React.createElement(route.Component), 1420 Component: undefined 1421 }); 1422 } 1423 if (route.HydrateFallback) { 1424 if (false) // removed by dead control flow 1425{} 1426 Object.assign(updates, { 1427 hydrateFallbackElement: /*#__PURE__*/React.createElement(route.HydrateFallback), 1428 HydrateFallback: undefined 1429 }); 1430 } 1431 if (route.ErrorBoundary) { 1432 if (false) // removed by dead control flow 1433{} 1434 Object.assign(updates, { 1435 errorElement: /*#__PURE__*/React.createElement(route.ErrorBoundary), 1436 ErrorBoundary: undefined 1437 }); 1438 } 1439 return updates; 1440} 1441function createMemoryRouter(routes, opts) { 1442 return createRouter({ 1443 basename: opts == null ? void 0 : opts.basename, 1444 future: _extends({}, opts == null ? void 0 : opts.future, { 1445 v7_prependBasename: true 1446 }), 1447 history: createMemoryHistory({ 1448 initialEntries: opts == null ? void 0 : opts.initialEntries, 1449 initialIndex: opts == null ? void 0 : opts.initialIndex 1450 }), 1451 hydrationData: opts == null ? void 0 : opts.hydrationData, 1452 routes, 1453 mapRouteProperties, 1454 dataStrategy: opts == null ? void 0 : opts.dataStrategy, 1455 patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation 1456 }).initialize(); 1457} 1458 1459 1460//# sourceMappingURL=index.js.map 1461 1462 1463/***/ }) 1464 1465}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.