mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
4 lines
33 KiB
JavaScript
4 lines
33 KiB
JavaScript
/*! LICENSE: lib-router.a0df4de158.js.LICENSE.txt */
|
|
"use strict";(self.rspackChunkwebsite=self.rspackChunkwebsite||[]).push([["9535"],{7099(e,t,n){n.d(t,{Kd:()=>ek,Zp:()=>Y,zy:()=>H});var r,a=n(6540),o="popstate";function i(e){return"object"==typeof e&&null!=e&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function l(e,t){if(!1===e||null==e)throw Error(t)}function u(e,t){if(!e){"u">typeof console&&console.warn(t);try{throw Error(t)}catch(e){}}}function s(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function c(e,t,n=null,r,a){return{pathname:"string"==typeof e?e:e.pathname,search:"",hash:"",..."string"==typeof t?p(t):t,state:n,key:t&&t.key||r||Math.random().toString(36).substring(2,10),unstable_mask:a}}function h({pathname:e="/",search:t="",hash:n=""}){return t&&"?"!==t&&(e+="?"===t.charAt(0)?t:"?"+t),n&&"#"!==n&&(e+="#"===n.charAt(0)?n:"#"+n),e}function p(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function d(e,t=!1){let n="http://localhost";"u">typeof window&&(n="null"!==window.location.origin?window.location.origin:window.location.href),l(n,"No window.location.(origin|href) available to create URL");let r="string"==typeof e?e:h(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function m(e,t,n="/"){return function(e,t,n,r){let a=v(("string"==typeof t?p(t):t).pathname||"/",n);if(null==a)return null;let o=function e(t,n=[],r=[],a="",o=!1){let i=(t,i,u=o,s)=>{var c,h;let p,d,m={relativePath:void 0===s?t.path||"":s,caseSensitive:!0===t.caseSensitive,childrenIndex:i,route:t};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(a)&&u)return;l(m.relativePath.startsWith(a),`Absolute route path "${m.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(a.length)}let y=C([a,m.relativePath]),v=r.concat(m);t.children&&t.children.length>0&&(l(!0!==t.index,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),e(t.children,n,v,y,u)),(null!=t.path||t.index)&&n.push({path:y,score:(c=y,h=t.index,d=(p=c.split("/")).length,p.some(g)&&(d+=-2),h&&(d+=2),p.filter(e=>!g(e)).reduce((e,t)=>e+(f.test(t)?3:""===t?1:10),d)),routesMeta:v})};return t.forEach((e,t)=>{if(""!==e.path&&e.path?.includes("?"))for(let n of function e(t){let n=t.split("/");if(0===n.length)return[];let[r,...a]=n,o=r.endsWith("?"),i=r.replace(/\?$/,"");if(0===a.length)return o?[i,""]:[i];let l=e(a.join("/")),u=[];return u.push(...l.map(e=>""===e?i:[i,e].join("/"))),o&&u.push(...l),u.map(e=>t.startsWith("/")&&""===e?"/":e)}(e.path))i(e,t,!0,n);else i(e,t)}),n}(e);o.sort((e,t)=>{var n,r;return e.score!==t.score?t.score-e.score:(n=e.routesMeta.map(e=>e.childrenIndex),r=t.routesMeta.map(e=>e.childrenIndex),n.length===r.length&&n.slice(0,-1).every((e,t)=>e===r[t])?n[n.length-1]-r[r.length-1]:0)});let i=null;for(let e=0;null==i&&e<o.length;++e){let t=function(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return u(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}(a);i=function(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",i=[];for(let e=0;e<r.length;++e){let l=r[e],u=e===r.length-1,s="/"===o?t:t.slice(o.length)||"/",c=y({path:l.relativePath,caseSensitive:l.caseSensitive,end:u},s),h=l.route;if(!c&&u&&n&&!r[r.length-1].route.index&&(c=y({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},s)),!c)return null;Object.assign(a,c.params),i.push({params:a,pathname:C([o,c.pathname]),pathnameBase:$(C([o,c.pathnameBase])),route:h}),"/"!==c.pathnameBase&&(o=C([o,c.pathnameBase]))}return i}(o[e],t,r)}return i}(e,t,n,!1)}new WeakMap;var f=/^:[\w-]+$/,g=e=>"*"===e;function y(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=function(e,t=!1,n=!0){u("*"===e||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(e,t,n,a,o)=>{if(r.push({paramName:t,isOptional:null!=n}),n){let t=o.charAt(a+e.length);return t&&"/"!==t?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":""!==e&&"/"!==e&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}(e.path,e.caseSensitive,e.end),a=t.match(n);if(!a)return null;let o=a[0],i=o.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if("*"===t){let e=l[r]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}let a=l[r];return n&&!a?e[t]=void 0:e[t]=(a||"").replace(/%2F/g,"/"),e},{}),pathname:o,pathnameBase:i,pattern:e}}function v(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&"/"!==r?null:e.slice(n)||"/"}var w=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function b(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(e=>{".."===e?n.length>1&&n.pop():"."!==e&&n.push(e)}),n.length>1?n.join("/"):"/"}function R(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function x(e){let t=e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function E(e,t,n,r=!1){let a,o;"string"==typeof e?a=p(e):(l(!(a={...e}).pathname||!a.pathname.includes("?"),R("?","pathname","search",a)),l(!a.pathname||!a.pathname.includes("#"),R("#","pathname","hash",a)),l(!a.search||!a.search.includes("#"),R("#","search","hash",a)));let i=""===e||""===a.pathname,u=i?"/":a.pathname;if(null==u)o=n;else{let e=t.length-1;if(!r&&u.startsWith("..")){let t=u.split("/");for(;".."===t[0];)t.shift(),e-=1;a.pathname=t.join("/")}o=e>=0?t[e]:"/"}let s=function(e,t="/"){let{pathname:n,search:r="",hash:a=""}="string"==typeof e?p(e):e;return{pathname:n?(n=n.replace(/\/\/+/g,"/")).startsWith("/")?b(n.substring(1),"/"):b(n,t):t,search:S(r),hash:k(a)}}(a,o),c=u&&"/"!==u&&u.endsWith("/"),h=(i||"."===u)&&n.endsWith("/");return!s.pathname.endsWith("/")&&(c||h)&&(s.pathname+="/"),s}var C=e=>e.join("/").replace(/\/\/+/g,"/"),$=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),S=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",k=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"",L=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function P(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}var O="u">typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function T(e,t){let n=e;if("string"!=typeof n||!w.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(O)try{let e=new URL(window.location.href),r=new URL(n.startsWith("//")?e.protocol+n:n),o=v(r.pathname,t);r.origin===e.origin&&null!=o?n=o+r.search+r.hash:a=!0}catch(e){u(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Symbol("Uninstrumented"),Object.getOwnPropertyNames(Object.prototype).sort().join("\0"),Symbol("ResetLoaderData");var N=a.createContext(null);N.displayName="DataRouter";var _=a.createContext(null);_.displayName="DataRouterState";var A=a.createContext(!1);function W(){return a.useContext(A)}var M=a.createContext({isTransitioning:!1});M.displayName="ViewTransition",a.createContext(new Map).displayName="Fetchers",a.createContext(null).displayName="Await";var F=a.createContext(null);F.displayName="Navigation";var j=a.createContext(null);j.displayName="Location";var D=a.createContext({outlet:null,matches:[],isDataRoute:!1});D.displayName="Route";var U=a.createContext(null);U.displayName="RouteError";var B="REACT_ROUTER_ERROR";function I(){return null!=a.useContext(j)}function H(){return l(I(),"useLocation() may be used only in the context of a <Router> component."),a.useContext(j).location}var z="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function J(e){a.useContext(F).static||a.useLayoutEffect(e)}function Y(){let{isDataRoute:e}=a.useContext(D);return e?function(){let e,{router:t}=(l(e=a.useContext(N),Q("useNavigate")),e),n=et("useNavigate"),r=a.useRef(!1);return J(()=>{r.current=!0}),a.useCallback(async(e,a={})=>{u(r.current,z),r.current&&("number"==typeof e?await t.navigate(e):await t.navigate(e,{fromRouteId:n,...a}))},[t,n])}():function(){l(I(),"useNavigate() may be used only in the context of a <Router> component.");let e=a.useContext(N),{basename:t,navigator:n}=a.useContext(F),{matches:r}=a.useContext(D),{pathname:o}=H(),i=JSON.stringify(x(r)),s=a.useRef(!1);return J(()=>{s.current=!0}),a.useCallback((r,a={})=>{if(u(s.current,z),!s.current)return;if("number"==typeof r)return void n.go(r);let l=E(r,JSON.parse(i),o,"path"===a.relative);null==e&&"/"!==t&&(l.pathname="/"===l.pathname?t:C([t,l.pathname])),(a.replace?n.replace:n.push)(l,a.state,a)},[t,n,i,o,e])}()}function q(e,{relative:t}={}){let{matches:n}=a.useContext(D),{pathname:r}=H(),o=JSON.stringify(x(n));return a.useMemo(()=>E(e,JSON.parse(o),r,"path"===t),[e,o,r,t])}a.createContext(null);var K=a.createElement(function(){let e,t,n,r=(e=a.useContext(U),t=ee("useRouteError"),n=et("useRouteError"),void 0!==e?e:t.errors?.[n]),o=P(r)?`${r.status} ${r.statusText}`:r instanceof Error?r.message:JSON.stringify(r),i=r instanceof Error?r.stack:null,l="rgba(200,200,200, 0.5)",u={padding:"2px 4px",backgroundColor:l},s=null;return console.error("Error handled by React Router default ErrorBoundary:",r),s=a.createElement(a.Fragment,null,a.createElement("p",null,"💿 Hey developer 👋"),a.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",a.createElement("code",{style:u},"ErrorBoundary")," or"," ",a.createElement("code",{style:u},"errorElement")," prop on your route.")),a.createElement(a.Fragment,null,a.createElement("h2",null,"Unexpected Application Error!"),a.createElement("h3",{style:{fontStyle:"italic"}},o),i?a.createElement("pre",{style:{padding:"0.5rem",backgroundColor:l}},i):null,s)},null),V=class extends a.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||"idle"!==t.revalidation&&"idle"===e.revalidation?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:void 0!==e.error?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&"object"==typeof e&&e&&"digest"in e&&"string"==typeof e.digest){let t=function(e){if(e.startsWith(`${B}:ROUTE_ERROR_RESPONSE:{`))try{let t=JSON.parse(e.slice(40));if("object"==typeof t&&t&&"number"==typeof t.status&&"string"==typeof t.statusText)return new L(t.status,t.statusText,t.data)}catch{}}(e.digest);t&&(e=t)}let t=void 0!==e?a.createElement(D.Provider,{value:this.props.routeContext},a.createElement(U.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?a.createElement(Z,{error:e},t):t}};V.contextType=A;var X=new WeakMap;function Z({children:e,error:t}){let{basename:n}=a.useContext(F);if("object"==typeof t&&t&&"digest"in t&&"string"==typeof t.digest){let e=function(e){if(e.startsWith(`${B}:REDIRECT:{`))try{let t=JSON.parse(e.slice(28));if("object"==typeof t&&t&&"number"==typeof t.status&&"string"==typeof t.statusText&&"string"==typeof t.location&&"boolean"==typeof t.reloadDocument&&"boolean"==typeof t.replace)return t}catch{}}(t.digest);if(e){let r=X.get(t);if(r)throw r;let o=T(e.location,n);if(O&&!X.get(t))if(o.isExternal||e.reloadDocument)window.location.href=o.absoluteURL||o.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:e.replace}));throw X.set(t,n),n}return a.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function G({routeContext:e,match:t,children:n}){let r=a.useContext(N);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),a.createElement(D.Provider,{value:e},n)}function Q(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function ee(e){let t=a.useContext(_);return l(t,Q(e)),t}function et(e){let t,n=(l(t=a.useContext(D),Q(e)),t),r=n.matches[n.matches.length-1];return l(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}var en={};function er(e,t,n){t||en[e]||(en[e]=!0,u(!1,n))}function ea({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:i=!1,unstable_useTransitions:s}){l(!I(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),h=a.useMemo(()=>({basename:c,navigator:o,static:i,unstable_useTransitions:s,future:{}}),[c,o,i,s]);"string"==typeof n&&(n=p(n));let{pathname:d="/",search:m="",hash:f="",state:g=null,key:y="default",unstable_mask:w}=n,b=a.useMemo(()=>{let e=v(d,c);return null==e?null:{location:{pathname:e,search:m,hash:f,state:g,key:y,unstable_mask:w},navigationType:r}},[c,d,m,f,g,y,r,w]);return(u(null!=b,`<Router basename="${c}"> is not able to match the URL "${d}${m}${f}" because it does not start with the basename, so the <Router> won't render anything.`),null==b)?null:a.createElement(F.Provider,{value:h},a.createElement(j.Provider,{children:t,value:b}))}(r||(r=n.t(a,2))).useOptimistic,a.memo(function({routes:e,future:t,state:n,isStatic:r,onError:o}){return function(e,t,n){let r;l(I(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=a.useContext(F),{matches:i}=a.useContext(D),s=i[i.length-1],c=s?s.params:{},h=s?s.pathname:"/",d=s?s.pathnameBase:"/",f=s&&s.route;{let e=f&&f.path||"";er(h,!f||e.endsWith("*")||e.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
|
|
Please change the parent <Route path="${e}"> to <Route path="${"/"===e?"*":`${e}/*`}">.`)}let g=H();if(t){let e="string"==typeof t?p(t):t;l("/"===d||e.pathname?.startsWith(d),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${e.pathname}" was given in the \`location\` prop.`),r=e}else r=g;let y=r.pathname||"/",v=y;if("/"!==d){let e=d.replace(/^\//,"").split("/");v="/"+y.replace(/^\//,"").split("/").slice(e.length).join("/")}let w=m(e,{pathname:v});u(f||null!=w,`No routes matched location "${r.pathname}${r.search}${r.hash}" `),u(null==w||void 0!==w[w.length-1].route.element||void 0!==w[w.length-1].route.Component||void 0!==w[w.length-1].route.lazy,`Matched leaf route at location "${r.pathname}${r.search}${r.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=function(e,t=[],n){let r=n?.state;if(null==e){if(!r)return null;if(r.errors)e=r.matches;else{if(0!==t.length||r.initialized||!(r.matches.length>0))return null;e=r.matches}}let o=e,i=r?.errors;if(null!=i){let e=o.findIndex(e=>e.route.id&&i?.[e.route.id]!==void 0);l(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,e+1))}let u=!1,s=-1;if(n&&r){u=r.renderFallback;for(let e=0;e<o.length;e++){let t=o[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||void 0===a[t.route.id]);if(t.route.lazy||i){n.isStatic&&(u=!0),o=s>=0?o.slice(0,s+1):[o[0]];break}}}}let c=n?.onError,h=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:r.matches.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/",errorInfo:t})}:void 0;return o.reduceRight((e,n,l)=>{let c,p=!1,d=null,m=null;r&&(c=i&&n.route.id?i[n.route.id]:void 0,d=n.route.errorElement||K,u&&(s<0&&0===l?(er("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),p=!0,m=null):s===l&&(p=!0,m=n.route.hydrateFallbackElement||null)));let f=t.concat(o.slice(0,l+1)),g=()=>{let t;return t=c?d:p?m:n.route.Component?a.createElement(n.route.Component,null):n.route.element?n.route.element:e,a.createElement(G,{match:n,routeContext:{outlet:e,matches:f,isDataRoute:null!=r},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||0===l)?a.createElement(V,{location:r.location,revalidation:r.revalidation,component:d,error:c,children:g(),routeContext:{outlet:null,matches:f,isDataRoute:!0},onError:h}):g()},null)}(w&&w.map(e=>Object.assign({},e,{params:Object.assign({},c,e.params),pathname:C([d,o.encodeLocation?o.encodeLocation(e.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathname]),pathnameBase:"/"===e.pathnameBase?d:C([d,o.encodeLocation?o.encodeLocation(e.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:e.pathnameBase])})),i,n);return t&&b?a.createElement(j.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...r},navigationType:"POP"}},b):b}(e,void 0,{state:n,isStatic:r,onError:o,future:t})}),a.Component;var eo="get",ei="application/x-www-form-urlencoded";function el(e){return"u">typeof HTMLElement&&e instanceof HTMLElement}var eu=null,es=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ec(e){return null==e||es.has(e)?e:(u(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ei}"`),null)}Object.getOwnPropertyNames(Object.prototype).sort().join("\0"),"u">typeof window&&window;function eh(e,t){if(!1===e||null==e)throw Error(t)}function ep(e,t,n,r){let a="string"==typeof e?new URL(e,"u"<typeof window?"server://singlefetch/":window.location.origin):e;return n?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${r}`:a.pathname=`${a.pathname}.${r}`:"/"===a.pathname?a.pathname=`_root.${r}`:t&&"/"===v(a.pathname,t)?a.pathname=`${t.replace(/\/$/,"")}/_root.${r}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${r}`,a}async function ed(e,t){if(e.id in t)return t[e.id];try{let n=await import(e.module);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function em(e){return null!=e&&(null==e.href?"preload"===e.rel&&"string"==typeof e.imageSrcSet&&"string"==typeof e.imageSizes:"string"==typeof e.rel&&"string"==typeof e.href)}async function ef(e,t,n){var r;let a,o;return r=(await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await ed(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(em).filter(e=>"stylesheet"===e.rel||"preload"===e.rel).map(e=>"stylesheet"===e.rel?{...e,rel:"prefetch",as:"style"}:{...e,rel:"prefetch"}),a=new Set,o=new Set(void 0),r.reduce((e,t)=>{!1;let n=JSON.stringify(function(e){let t={};for(let n of Object.keys(e).sort())t[n]=e[n];return t}(t));return a.has(n)||(a.add(n),e.push({key:n,link:t})),e},[])}function eg(e,t,n,r,a,o){let i=(e,t)=>!n[t]||e.route.id!==n[t].route.id,l=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith("*")&&n[t].params["*"]!==e.params["*"];return"assets"===o?t.filter((e,t)=>i(e,t)||l(e,t)):"data"===o?t.filter((t,o)=>{let u=r.routes[t.route.id];if(!u||!u.hasLoader)return!1;if(i(t,o)||l(t,o))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if("boolean"==typeof r)return r}return!0}):[]}function ey(e,t,{includeHydrateFallback:n}={}){return[...new Set(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let a=[r.module];return r.clientActionModule&&(a=a.concat(r.clientActionModule)),r.clientLoaderModule&&(a=a.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(a=a.concat(r.hydrateFallbackModule)),r.imports&&(a=a.concat(r.imports)),a}).flat(1))]}function ev(){let e=a.useContext(N);return eh(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function ew(){let e=a.useContext(_);return eh(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}Symbol("SingleFetchRedirect");var eb=a.createContext(void 0);function eR(){let e=a.useContext(eb);return eh(e,"You must render this element inside a <HydratedRouter> element"),e}function ex(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function eE({page:e,...t}){let n=W(),{router:r}=ev(),o=a.useMemo(()=>m(r.routes,e,r.basename),[r.routes,e,r.basename]);return o?n?a.createElement(eC,{page:e,matches:o,...t}):a.createElement(e$,{page:e,matches:o,...t}):null}function eC({page:e,matches:t,...n}){let r=H(),{future:o}=eR(),{basename:i}=ev(),l=a.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=ep(e,i,o.unstable_trailingSlashAwareDataRequests,"rsc"),a=!1,l=[];for(let e of t)"function"==typeof e.route.shouldRevalidate?a=!0:l.push(e.route.id);return a&&l.length>0&&n.searchParams.set("_routes",l.join(",")),[n.pathname+n.search]},[i,o.unstable_trailingSlashAwareDataRequests,e,r,t]);return a.createElement(a.Fragment,null,l.map(e=>a.createElement("link",{key:e,rel:"prefetch",as:"fetch",href:e,...n})))}function e$({page:e,matches:t,...n}){let r=H(),{future:o,manifest:i,routeModules:l}=eR(),{basename:u}=ev(),{loaderData:s,matches:c}=ew(),h=a.useMemo(()=>eg(e,t,c,i,r,"data"),[e,t,c,i,r]),p=a.useMemo(()=>eg(e,t,c,i,r,"assets"),[e,t,c,i,r]),d=a.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,a=!1;if(t.forEach(e=>{let t=i.routes[e.route.id];t&&t.hasLoader&&(!h.some(t=>t.route.id===e.route.id)&&e.route.id in s&&l[e.route.id]?.shouldRevalidate||t.hasClientLoader?a=!0:n.add(e.route.id))}),0===n.size)return[];let c=ep(e,u,o.unstable_trailingSlashAwareDataRequests,"data");return a&&n.size>0&&c.searchParams.set("_routes",t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(",")),[c.pathname+c.search]},[u,o.unstable_trailingSlashAwareDataRequests,s,r,i,h,t,e,l]),m=a.useMemo(()=>ey(p,i),[p,i]),f=function(e){let{manifest:t,routeModules:n}=eR(),[r,o]=a.useState([]);return a.useEffect(()=>{let r=!1;return ef(e,t,n).then(e=>{r||o(e)}),()=>{r=!0}},[e,t,n]),r}(p);return a.createElement(a.Fragment,null,d.map(e=>a.createElement("link",{key:e,rel:"prefetch",as:"fetch",href:e,...n})),m.map(e=>a.createElement("link",{key:e,rel:"modulepreload",href:e,...n})),f.map(({key:e,link:t})=>a.createElement("link",{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}eb.displayName="FrameworkContext";a.Component;var eS="u">typeof window&&void 0!==window.document&&void 0!==window.document.createElement;try{eS&&(window.__reactRouterVersion="7.14.0")}catch(e){}function ek({basename:e,children:t,unstable_useTransitions:n,window:r}){let l=a.useRef();null==l.current&&(l.current=function(e={}){return function(e,t,n={}){let{window:r=document.defaultView,v5Compat:a=!1}=n,l=r.history,u="POP",h=null,p=m();function m(){return(l.state||{idx:null}).idx}function f(){u="POP";let e=m(),t=null==e?null:e-p;p=e,h&&h({action:u,location:g.location,delta:t})}null==p&&(p=0,l.replaceState({...l.state,idx:p},""));let g={get action(){return u},get location(){return e(r,l)},listen(e){if(h)throw Error("A history only accepts one active listener");return r.addEventListener(o,f),h=e,()=>{r.removeEventListener(o,f),h=null}},createHref:e=>t(r,e),createURL:function(e){return d(e)},encodeLocation(e){let t=d(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){u="PUSH";let n=i(e)?e:c(g.location,e,t);let o=s(n,p=m()+1),d=g.createHref(n.unstable_mask||n);try{l.pushState(o,"",d)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;r.location.assign(d)}a&&h&&h({action:u,location:g.location,delta:1})},replace:function(e,t){u="REPLACE";let n=i(e)?e:c(g.location,e,t);let r=s(n,p=m()),o=g.createHref(n.unstable_mask||n);l.replaceState(r,"",o),a&&h&&h({action:u,location:g.location,delta:0})},go:e=>l.go(e)};return g}(function(e,t){let n=t.state?.masked,{pathname:r,search:a,hash:o}=n||e.location;return c("",{pathname:r,search:a,hash:o},t.state&&t.state.usr||null,t.state&&t.state.key||"default",n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)},function(e,t){return"string"==typeof t?t:h(t)},e)}({window:r,v5Compat:!0}));let u=l.current,[p,m]=a.useState({action:u.action,location:u.location}),f=a.useCallback(e=>{!1===n?m(e):a.startTransition(()=>m(e))},[n]);return a.useLayoutEffect(()=>u.listen(f),[u,f]),a.createElement(ea,{basename:e,children:t,location:p.location,navigationType:p.action,navigator:u,unstable_useTransitions:n})}var eL=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,eP=a.forwardRef(function({onClick:e,discover:t="render",prefetch:n="none",relative:r,reloadDocument:o,replace:i,unstable_mask:u,state:s,target:c,to:p,preventScrollReset:d,viewTransition:m,unstable_defaultShouldRevalidate:f,...g},y){let{basename:v,navigator:w,unstable_useTransitions:b}=a.useContext(F),R="string"==typeof p&&eL.test(p),x=T(p,v),$=function(e,{relative:t}={}){l(I(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=a.useContext(F),{hash:o,pathname:i,search:u}=q(e,{relative:t}),s=i;return"/"!==n&&(s="/"===i?n:C([n,i])),r.createHref({pathname:s,search:u,hash:o})}(p=x.to,{relative:r}),S=H(),k=null;if(u){let e=E(u,[],S.unstable_mask?S.unstable_mask.pathname:"/",!0);"/"!==v&&(e.pathname="/"===e.pathname?v:C([v,e.pathname])),k=w.createHref(e)}let[L,P,O]=function(e,t){let n=a.useContext(eb),[r,o]=a.useState(!1),[i,l]=a.useState(!1),{onFocus:u,onBlur:s,onMouseEnter:c,onMouseLeave:h,onTouchStart:p}=t,d=a.useRef(null);a.useEffect(()=>{if("render"===e&&l(!0),"viewport"===e){let e=new IntersectionObserver(e=>{e.forEach(e=>{l(e.isIntersecting)})},{threshold:.5});return d.current&&e.observe(d.current),()=>{e.disconnect()}}},[e]),a.useEffect(()=>{if(r){let e=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(e)}}},[r]);let m=()=>{o(!0)},f=()=>{o(!1),l(!1)};return n?"intent"!==e?[i,d,{}]:[i,d,{onFocus:ex(u,m),onBlur:ex(s,f),onMouseEnter:ex(c,m),onMouseLeave:ex(h,f),onTouchStart:ex(p,m)}]:[!1,d,{}]}(n,g),N=function(e,{target:t,replace:n,unstable_mask:r,state:o,preventScrollReset:i,relative:l,viewTransition:u,unstable_defaultShouldRevalidate:s,unstable_useTransitions:c}={}){let p=Y(),d=H(),m=q(e,{relative:l});return a.useCallback(f=>{if(0===f.button&&(!t||"_self"===t)&&!(f.metaKey||f.altKey||f.ctrlKey||f.shiftKey)){f.preventDefault();let t=void 0!==n?n:h(d)===h(m),g=()=>p(e,{replace:t,unstable_mask:r,state:o,preventScrollReset:i,relative:l,viewTransition:u,unstable_defaultShouldRevalidate:s});c?a.startTransition(()=>g()):g()}},[d,p,m,n,r,o,t,e,i,l,u,s,c])}(p,{replace:i,unstable_mask:u,state:s,target:c,preventScrollReset:d,relative:r,viewTransition:m,unstable_defaultShouldRevalidate:f,unstable_useTransitions:b}),_=!(x.isExternal||o),A=a.createElement("a",{...g,...O,href:(_?k:void 0)||x.absoluteURL||$,onClick:_?function(t){e&&e(t),t.defaultPrevented||N(t)}:e,ref:function(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}(y,P),target:c,"data-discover":R||"render"!==t?void 0:"true"});return L&&!R?a.createElement(a.Fragment,null,A,a.createElement(eE,{page:$})):A});eP.displayName="Link",a.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:n="",end:r=!1,style:o,to:i,viewTransition:u,children:s,...c},h){let p,d=q(i,{relative:c.relative}),m=H(),f=a.useContext(_),{navigator:g,basename:w}=a.useContext(F),b=null!=f&&function(e,{relative:t}={}){let n=a.useContext(M);l(null!=n,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=eO("useViewTransitionState"),o=q(e,{relative:t});if(!n.isTransitioning)return!1;let i=v(n.currentLocation.pathname,r)||n.currentLocation.pathname,u=v(n.nextLocation.pathname,r)||n.nextLocation.pathname;return null!=y(o.pathname,u)||null!=y(o.pathname,i)}(d)&&!0===u,R=g.encodeLocation?g.encodeLocation(d).pathname:d.pathname,x=m.pathname,E=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(x=x.toLowerCase(),E=E?E.toLowerCase():null,R=R.toLowerCase()),E&&w&&(E=v(E,w)||E);let C="/"!==R&&R.endsWith("/")?R.length-1:R.length,$=x===R||!r&&x.startsWith(R)&&"/"===x.charAt(C),S=null!=E&&(E===R||!r&&E.startsWith(R)&&"/"===E.charAt(R.length)),k={isActive:$,isPending:S,isTransitioning:b},L=$?e:void 0;p="function"==typeof n?n(k):[n,$?"active":null,S?"pending":null,b?"transitioning":null].filter(Boolean).join(" ");let P="function"==typeof o?o(k):o;return a.createElement(eP,{...c,"aria-current":L,className:p,ref:h,style:P,to:i,viewTransition:u},"function"==typeof s?s(k):s)}).displayName="NavLink",a.forwardRef(({discover:e="render",fetcherKey:t,navigate:n,reloadDocument:r,replace:o,state:i,method:u=eo,action:s,onSubmit:c,relative:p,preventScrollReset:d,viewTransition:m,unstable_defaultShouldRevalidate:f,...g},y)=>{let{unstable_useTransitions:w}=a.useContext(F),b=function(){let{router:e}=eO("useSubmit"),{basename:t}=a.useContext(F),n=et("useRouteId"),r=e.fetch,o=e.navigate;return a.useCallback(async(e,a={})=>{let{action:i,method:l,encType:u,formData:s,body:c}=function(e,t){let n,r,a,o,i;if(el(e)&&"form"===e.tagName.toLowerCase()){let i=e.getAttribute("action");r=i?v(i,t):null,n=e.getAttribute("method")||eo,a=ec(e.getAttribute("enctype"))||ei,o=new FormData(e)}else if(el(e)&&"button"===e.tagName.toLowerCase()||el(e)&&"input"===e.tagName.toLowerCase()&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=e.getAttribute("formaction")||i.getAttribute("action");if(r=l?v(l,t):null,n=e.getAttribute("formmethod")||i.getAttribute("method")||eo,a=ec(e.getAttribute("formenctype"))||ec(i.getAttribute("enctype"))||ei,o=new FormData(i,e),!function(){if(null===eu)try{new FormData(document.createElement("form"),0),eu=!1}catch(e){eu=!0}return eu}()){let{name:t,type:n,value:r}=e;if("image"===n){let e=t?`${t}.`:"";o.append(`${e}x`,"0"),o.append(`${e}y`,"0")}else t&&o.append(t,r)}}else if(el(e))throw Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');else n=eo,r=null,a=ei,i=e;return o&&"text/plain"===a&&(i=o,o=void 0),{action:r,method:n.toLowerCase(),encType:a,formData:o,body:i}}(e,t);if(!1===a.navigate){let e=a.fetcherKey||`__${String(++eT)}__`;await r(e,n,a.action||i,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:s,body:c,formMethod:a.method||l,formEncType:a.encType||u,flushSync:a.flushSync})}else await o(a.action||i,{unstable_defaultShouldRevalidate:a.unstable_defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:s,body:c,formMethod:a.method||l,formEncType:a.encType||u,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,o,t,n])}(),R=function(e,{relative:t}={}){let{basename:n}=a.useContext(F),r=a.useContext(D);l(r,"useFormAction must be used inside a RouteContext");let[o]=r.matches.slice(-1),i={...q(e||".",{relative:t})},u=H();if(null==e){i.search=u.search;let e=new URLSearchParams(i.search),t=e.getAll("index");if(t.some(e=>""===e)){e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let n=e.toString();i.search=n?`?${n}`:""}}return(!e||"."===e)&&o.route.index&&(i.search=i.search?i.search.replace(/^\?/,"?index&"):"?index"),"/"!==n&&(i.pathname="/"===i.pathname?n:C([n,i.pathname])),h(i)}(s,{relative:p}),x="get"===u.toLowerCase()?"get":"post",E="string"==typeof s&&eL.test(s);return a.createElement("form",{ref:y,method:x,action:R,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,l=r?.getAttribute("formmethod")||u,s=()=>b(r||e.currentTarget,{fetcherKey:t,method:l,navigate:n,replace:o,state:i,relative:p,preventScrollReset:d,viewTransition:m,unstable_defaultShouldRevalidate:f});w&&!1!==n?a.startTransition(()=>s()):s()},...g,"data-discover":E||"render"!==e?void 0:"true"})}).displayName="Form";function eO(e){var t;let n=a.useContext(N);return l(n,(t=e,`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`)),n}var eT=0}}]); |