the-forest/client/node_modules/react-router/dist/react-router.production.min.js

13 lines
15 KiB
JavaScript
Raw Normal View History

2024-09-17 20:35:18 -04:00
/**
* React Router v6.26.2
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
import*as e from"react";import{UNSAFE_invariant as t,joinPaths as r,matchPath as n,UNSAFE_decodePath as a,UNSAFE_getResolveToMatches as o,resolveTo as i,parsePath as l,matchRoutes as u,Action as s,UNSAFE_convertRouteMatchToUiMatch as c,stripBasename as d,IDLE_BLOCKER as p,isRouteErrorResponse as m,createMemoryHistory as h,AbortedDeferredError as f,createRouter as v}from"@remix-run/router";export{AbortedDeferredError,Action as NavigationType,createPath,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,redirectDocument,replace,resolvePath}from"@remix-run/router";const g=e.createContext(null),E=e.createContext(null),y=e.createContext(null),x=e.createContext(null),C=e.createContext(null),b=e.createContext({outlet:null,matches:[],isDataRoute:!1}),R=e.createContext(null);function S(n,{relative:a}={}){_()||t(!1);let{basename:o,navigator:i}=e.useContext(x),{hash:l,pathname:u,search:s}=A(n,{relative:a}),c=u;return"/"!==o&&(c="/"===u?o:r([o,u])),i.createHref({pathname:c,search:s,hash:l})}function _(){return null!=e.useContext(C)}function P(){return _()||t(!1),e.useContext(C).location}function U(){return e.useContext(C).navigationType}function k(r){_()||t(!1);let{pathname:o}=P();return e.useMemo((()=>n(r,a(o))),[o,r])}function D(t){e.useContext(x).static||e.useLayoutEffect(t)}function N(){let{isDataRoute:n}=e.useContext(b);return n?function(){let{router:t}=V(z.UseNavigateStable),r=Y($.UseNavigateStable),n=e.useRef(!1);return D((()=>{n.current=!0})),e.useCallback(((e,a={})=>{n.current&&("number"==typeof e?t.navigate(e):t.navigate(e,{fromRouteId:r,...a}))}),[t,r])}():function(){_()||t(!1);let n=e.useContext(g),{basename:a,future:l,navigator:u}=e.useContext(x),{matches:s}=e.useContext(b),{pathname:c}=P(),d=JSON.stringify(o(s,l.v7_relativeSplatPath)),p=e.useRef(!1);return D((()=>{p.current=!0})),e.useCallback(((e,t={})=>{if(!p.current)return;if("number"==typeof e)return void u.go(e);let o=i(e,JSON.parse(d),c,"path"===t.relative);null==n&&"/"!==a&&(o.pathname="/"===o.pathname?a:r([a,o.pathname])),(t.replace?u.replace:u.push)(o,t.state,t)}),[a,u,d,c,n])}()}const B=e.createContext(null);function F(){return e.useContext(B)}function L(t){let r=e.useContext(b).outlet;return r?e.createElement(B.Provider,{value:t},r):r}function O(){let{matches:t}=e.useContext(b),r=t[t.length-1];return r?r.params:{}}function A(t,{relative:r}={}){let{future:n}=e.useContext(x),{matches:a}=e.useContext(b),{pathname:l}=P(),u=JSON.stringify(o(a,n.v7_relativeSplatPath));return e.useMemo((()=>i(t,JSON.parse(u),l,"path"===r)),[t,u,l,r])}function j(e,t){return I(e,t)}function I(n,a,o,i){_()||t(!1);let{navigator:c}=e.useContext(x),{matches:d}=e.useContext(b),p=d[d.length-1],m=p?p.params:{};!p||p.pathname;let h=p?p.pathnameBase:"/";p&&p.route;let f,v=P();if(a){let e="string"==typeof a?l(a):a;"/"===h||e.pathname?.startsWith(h)||t(!1),f=e}else f=v;let g=f.pathname||"/",E=g;if("/"!==h){let e=h.replace(/^\//,"").split("/");E="/"+g.replace(/^\//,"").split("/").slice(e.length).join("/")}let y=u(n,{pathname:E}),R=J(y&&y.map((e=>Object.assign({},e,{params:Object.assign({},m,e.params),pathname:r([h,c.encodeLocation?c.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?h:r([h,c.encodeLocation?c.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])}))),d,o,i);return a&&R?e.createElement(C.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...f},navigationType:s.Pop}},R):R}function M(){let t=te(),r=m(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return e.createElement(e.Fragment,null,e.createElement("h2",null,"Unexpected Application Error!"),e.createElement("h3",{style:{fontStyle:"italic"}},r),n?e.createElement("pre",{style:a},n):null,null)}const T=e.createElement(M,null);class H extends e.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static g
//# sourceMappingURL=react-router.production.min.js.map