From e8a7bd757e1279d272bf3e6abeba316671b67cbd Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Wed, 1 Apr 2026 21:55:30 -0700 Subject: [PATCH] Fix login route collision after SPA cutover Move the browser sign-in page off the backend /auth namespace so direct navigation works, update Rust and frontend redirects to /login, and add tests that lock the split between SPA login UI and backend OAuth endpoints. --- apps/fabro-web/app/api.ts | 2 +- apps/fabro-web/app/router.test.tsx | 28 +++++++++++++++++++ apps/fabro-web/app/router.tsx | 2 +- apps/fabro-web/app/routes/redirect-home.tsx | 2 +- apps/fabro-web/app/routes/setup-complete.tsx | 2 +- .../{entry-qx60vskn.js => entry-acc7dzjg.js} | 6 ++-- ...-qx60vskn.js.map => entry-acc7dzjg.js.map} | 12 ++++---- apps/fabro-web/dist/index.html | 2 +- apps/fabro-web/tsconfig.json | 2 +- lib/crates/fabro-server/src/server.rs | 25 +++++++++++++++++ lib/crates/fabro-server/src/web_auth.rs | 6 ++-- 11 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 apps/fabro-web/app/router.test.tsx rename apps/fabro-web/dist/assets/{entry-qx60vskn.js => entry-acc7dzjg.js} (97%) rename apps/fabro-web/dist/assets/{entry-qx60vskn.js.map => entry-acc7dzjg.js.map} (99%) diff --git a/apps/fabro-web/app/api.ts b/apps/fabro-web/app/api.ts index a212eb500..9d0293b4c 100644 --- a/apps/fabro-web/app/api.ts +++ b/apps/fabro-web/app/api.ts @@ -12,7 +12,7 @@ export async function apiFetch(path: string, options?: ApiOptions): Promise { + const path = route.index + ? prefix || "/" + : route.path + ? route.path.startsWith("/") + ? route.path + : `${prefix}/${route.path}`.replace(/\/+/g, "/") + : prefix; + + const childPaths = route.children ? collectPaths(route.children, path) : []; + return route.path || route.index ? [path, ...childPaths] : childPaths; + }); +} + +describe("browser router", () => { + test("uses /login for the sign-in page instead of the backend auth namespace", () => { + const paths = collectPaths(routes); + + expect(paths).toContain("/login"); + expect(paths).not.toContain("/auth/login"); + }); +}); diff --git a/apps/fabro-web/app/router.tsx b/apps/fabro-web/app/router.tsx index 3bc054161..7d2fce45f 100644 --- a/apps/fabro-web/app/router.tsx +++ b/apps/fabro-web/app/router.tsx @@ -90,7 +90,7 @@ export const routes: RouteObject[] = [ indexRoute(RedirectHome), route("setup", Setup), route("setup/complete", SetupComplete), - route("auth/login", AuthLogin), + route("login", AuthLogin), { loader: appShellLoader, Component: withRouteModule({ diff --git a/apps/fabro-web/app/routes/redirect-home.tsx b/apps/fabro-web/app/routes/redirect-home.tsx index db04044a8..1a372ec02 100644 --- a/apps/fabro-web/app/routes/redirect-home.tsx +++ b/apps/fabro-web/app/routes/redirect-home.tsx @@ -11,7 +11,7 @@ export async function loader() { await getAuthMe(); } catch (error) { if (error instanceof Response && error.status === 401) { - return redirect("/auth/login"); + return redirect("/login"); } throw error; } diff --git a/apps/fabro-web/app/routes/setup-complete.tsx b/apps/fabro-web/app/routes/setup-complete.tsx index 038b735f8..6bd6fd83f 100644 --- a/apps/fabro-web/app/routes/setup-complete.tsx +++ b/apps/fabro-web/app/routes/setup-complete.tsx @@ -107,7 +107,7 @@ export default function SetupComplete() { Authentication is ready.

Continue to sign in diff --git a/apps/fabro-web/dist/assets/entry-qx60vskn.js b/apps/fabro-web/dist/assets/entry-acc7dzjg.js similarity index 97% rename from apps/fabro-web/dist/assets/entry-qx60vskn.js rename to apps/fabro-web/dist/assets/entry-acc7dzjg.js index 073b99c32..9c9e28546 100644 --- a/apps/fabro-web/dist/assets/entry-qx60vskn.js +++ b/apps/fabro-web/dist/assets/entry-acc7dzjg.js @@ -240,7 +240,7 @@ React keys must be passed directly to JSX without using spread: <%s key={someKey} {...props} />`,$0,G0,F1,G0),R0[G0+$0]=!0)}if(G0=null,M0!==void 0&&(Q(M0),G0=""+M0),$(q0)&&(Q(q0.key),G0=""+q0.key),"key"in q0){M0={};for(var u1 in q0)u1!=="key"&&(M0[u1]=q0[u1])}else M0=q0;return G0&&W(M0,typeof D==="function"?D.displayName||D.name||"Unknown":D),H(D,G0,M0,q(),c0,L1)}function R(D){F(D)?D._store&&(D._store.validated=1):typeof D==="object"&&D!==null&&D.$$typeof===c&&(D._payload.status==="fulfilled"?F(D._payload.value)&&D._payload.value._store&&(D._payload.value._store.validated=1):D._store&&(D._store.validated=1))}function F(D){return typeof D==="object"&&D!==null&&D.$$typeof===A}var A=Symbol.for("react.transitional.element"),v=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),b=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),c=Symbol.for("react.lazy"),Y0=Symbol.for("react.activity"),k=Symbol.for("react.client.reference"),t=Ew.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B0=Object.prototype.hasOwnProperty,U0=Array.isArray,H0=console.createTask?console.createTask:function(){return null};Ew={react_stack_bottom_frame:function(D){return D()}};var s,X0={},K0=Ew.react_stack_bottom_frame.bind(Ew,B)(),e=H0(X(B)),R0={};O70.Fragment=C,O70.jsx=function(D,q0,M0){var $0=1e4>t.recentlyCreatedOwnerStacks++;return N(D,q0,M0,!1,$0?Error("react-stack-top-frame"):K0,$0?H0(X(D)):e)},O70.jsxs=function(D,q0,M0){var $0=1e4>t.recentlyCreatedOwnerStacks++;return N(D,q0,M0,!0,$0?Error("react-stack-top-frame"):K0,$0?H0(X(D)):e)}})()});var vg=E(l(),1),Cg=E(fy(),1);var Q4=E(l(),1),g0=E(l(),1),X1=E(l(),1),EF=E(l(),1),mu=E(l(),1),q5=E(l(),1),Jr=E(l(),1),Qr=E(l(),1),Xr=E(l(),1),h0=E(l(),1),nu=E(l(),1),wu=(Z)=>{throw TypeError(Z)},Bp=(Z,Y,Q)=>Y.has(Z)||wu("Cannot "+Q),UF=(Z,Y,Q)=>(Bp(Z,Y,"read from private field"),Q?Q.call(Z):Y.get(Z)),Up=(Z,Y,Q)=>Y.has(Z)?wu("Cannot add the same private member more than once"):Y instanceof WeakSet?Y.add(Z):Y.set(Z,Q);var Vy="popstate";function Ju(Z={}){function Y(X,q){let{pathname:B,search:$,hash:W}=X.location;return MB("",{pathname:B,search:$,hash:W},q.state&&q.state.usr||null,q.state&&q.state.key||"default")}function Q(X,q){return typeof q==="string"?q:y3(q)}return Wp(Y,Q,null,Z)}function K1(Z,Y){if(Z===!1||Z===null||typeof Z>"u")throw Error(Y)}function i5(Z,Y){if(!Z){if(typeof console<"u")console.warn(Y);try{throw Error(Y)}catch(Q){}}}function $p(){return Math.random().toString(36).substring(2,10)}function Ty(Z,Y){return{usr:Z.state,key:Z.key,idx:Y}}function MB(Z,Y,Q=null,X){return{pathname:typeof Z==="string"?Z:Z.pathname,search:"",hash:"",...typeof Y==="string"?F6(Y):Y,state:Q,key:Y&&Y.key||X||$p()}}function y3({pathname:Z="/",search:Y="",hash:Q=""}){if(Y&&Y!=="?")Z+=Y.charAt(0)==="?"?Y:"?"+Y;if(Q&&Q!=="#")Z+=Q.charAt(0)==="#"?Q:"#"+Q;return Z}function F6(Z){let Y={};if(Z){let Q=Z.indexOf("#");if(Q>=0)Y.hash=Z.substring(Q),Z=Z.substring(0,Q);let X=Z.indexOf("?");if(X>=0)Y.search=Z.substring(X),Z=Z.substring(0,X);if(Z)Y.pathname=Z}return Y}function Wp(Z,Y,Q,X={}){let{window:q=document.defaultView,v5Compat:B=!1}=X,$=q.history,W="POP",M=null,H=N();if(H==null)H=0,$.replaceState({...$.state,idx:H},"");function N(){return($.state||{idx:null}).idx}function R(){W="POP";let f=N(),P=f==null?null:f-H;if(H=f,M)M({action:W,location:C.location,delta:P})}function F(f,P){W="PUSH";let L=MB(C.location,f,P);if(Q)Q(L,f);H=N()+1;let b=Ty(L,H),u=C.createHref(L);try{$.pushState(b,"",u)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;q.location.assign(u)}if(B&&M)M({action:W,location:C.location,delta:1})}function A(f,P){W="REPLACE";let L=MB(C.location,f,P);if(Q)Q(L,f);H=N();let b=Ty(L,H),u=C.createHref(L);if($.replaceState(b,"",u),B&&M)M({action:W,location:C.location,delta:0})}function v(f){return Qu(f)}let C={get action(){return W},get location(){return Z(q,$)},listen(f){if(M)throw Error("A history only accepts one active listener");return q.addEventListener(Vy,R),M=f,()=>{q.removeEventListener(Vy,R),M=null}},createHref(f){return Y(q,f)},createURL:v,encodeLocation(f){let P=v(f);return{pathname:P.pathname,search:P.search,hash:P.hash}},push:F,replace:A,go(f){return $.go(f)}};return C}function Qu(Z,Y=!1){let Q="http://localhost";if(typeof window<"u")Q=window.location.origin!=="null"?window.location.origin:window.location.href;K1(Q,"No window.location.(origin|href) available to create URL");let X=typeof Z==="string"?Z:y3(Z);if(X=X.replace(/ $/,"%20"),!Y&&X.startsWith("//"))X=Q+X;return new URL(X,Q)}var $B,GF=class{constructor(Z){if(Up(this,$B,new Map),Z)for(let[Y,Q]of Z)this.set(Y,Q)}get(Z){if(UF(this,$B).has(Z))return UF(this,$B).get(Z);if(Z.defaultValue!==void 0)return Z.defaultValue;throw Error("No value found for context")}set(Z,Y){UF(this,$B).set(Z,Y)}};$B=new WeakMap;var Kp=new Set(["lazy","caseSensitive","path","id","index","children"]);function Mp(Z){return Kp.has(Z)}var Gp=new Set(["lazy","caseSensitive","path","id","index","middleware","children"]);function Hp(Z){return Gp.has(Z)}function Np(Z){return Z.index===!0}function GB(Z,Y,Q=[],X={},q=!1){return Z.map((B,$)=>{let W=[...Q,String($)],M=typeof B.id==="string"?B.id:W.join("-");if(K1(B.index!==!0||!B.children,"Cannot specify children on an index route"),K1(q||!X[M],`Found a route id collision on id "${M}". Route id's must be globally unique within Data Router usages`),Np(B)){let H={...B,id:M};return X[M]=yy(H,Y(H)),H}else{let H={...B,id:M,children:void 0};if(X[M]=yy(H,Y(H)),B.children)H.children=GB(B.children,Y,W,X,q);return H}})}function yy(Z,Y){return Object.assign(Z,{...Y,...typeof Y.lazy==="object"&&Y.lazy!=null?{lazy:{...Z.lazy,...Y.lazy}}:{}})}function H8(Z,Y,Q="/"){return WB(Z,Y,Q,!1)}function WB(Z,Y,Q,X){let q=typeof Y==="string"?F6(Y):Y,B=b4(q.pathname||"/",Q);if(B==null)return null;let $=zu(Z);Rp($);let W=null;for(let M=0;W==null&&M<$.length;++M){let H=Vp(B);W=bp($[M],H,X)}return W}function Xu(Z,Y){let{route:Q,pathname:X,params:q}=Z;return{id:Q.id,pathname:X,params:q,data:Y[Q.id],loaderData:Y[Q.id],handle:Q.handle}}function zu(Z,Y=[],Q=[],X="",q=!1){let B=($,W,M=q,H)=>{let N={relativePath:H===void 0?$.path||"":H,caseSensitive:$.caseSensitive===!0,childrenIndex:W,route:$};if(N.relativePath.startsWith("/")){if(!N.relativePath.startsWith(X)&&M)return;K1(N.relativePath.startsWith(X),`Absolute route path "${N.relativePath}" nested under path "${X}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),N.relativePath=N.relativePath.slice(X.length)}let R=O6([X,N.relativePath]),F=Q.concat(N);if($.children&&$.children.length>0)K1($.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${R}".`),zu($.children,Y,F,R,M);if($.path==null&&!$.index)return;Y.push({path:R,score:Lp(R,$.index),routesMeta:F})};return Z.forEach(($,W)=>{if($.path===""||!$.path?.includes("?"))B($,W);else for(let M of qu($.path))B($,W,!0,M)}),Y}function qu(Z){let Y=Z.split("/");if(Y.length===0)return[];let[Q,...X]=Y,q=Q.endsWith("?"),B=Q.replace(/\?$/,"");if(X.length===0)return q?[B,""]:[B];let $=qu(X.join("/")),W=[];if(W.push(...$.map((M)=>M===""?B:[B,M].join("/"))),q)W.push(...$);return W.map((M)=>Z.startsWith("/")&&M===""?"/":M)}function Rp(Z){Z.sort((Y,Q)=>Y.score!==Q.score?Q.score-Y.score:Pp(Y.routesMeta.map((X)=>X.childrenIndex),Q.routesMeta.map((X)=>X.childrenIndex)))}var Op=/^:[\w-]+$/,Fp=3,Ap=2,_p=1,vp=10,Cp=-2,uy=(Z)=>Z==="*";function Lp(Z,Y){let Q=Z.split("/"),X=Q.length;if(Q.some(uy))X+=Cp;if(Y)X+=Ap;return Q.filter((q)=>!uy(q)).reduce((q,B)=>q+(Op.test(B)?Fp:B===""?_p:vp),X)}function Pp(Z,Y){return Z.length===Y.length&&Z.slice(0,-1).every((X,q)=>X===Y[q])?Z[Z.length-1]-Y[Y.length-1]:0}function bp(Z,Y,Q=!1){let{routesMeta:X}=Z,q={},B="/",$=[];for(let W=0;W{if(N==="*"){let v=W[F]||"";$=B.slice(0,B.length-v.length).replace(/(.)\/+$/,"$1")}let A=W[F];if(R&&!A)H[N]=void 0;else H[N]=(A||"").replace(/%2F/g,"/");return H},{}),pathname:B,pathnameBase:$,pattern:Z}}function fp(Z,Y=!1,Q=!0){i5(Z==="*"||!Z.endsWith("*")||Z.endsWith("/*"),`Route path "${Z}" will be treated as if it were "${Z.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${Z.replace(/\*$/,"/*")}".`);let X=[],q="^"+Z.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,($,W,M)=>{return X.push({paramName:W,isOptional:M!=null}),M?"/?([^\\/]+)?":"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");if(Z.endsWith("*"))X.push({paramName:"*"}),q+=Z==="*"||Z==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$";else if(Q)q+="\\/*$";else if(Z!==""&&Z!=="/")q+="(?:(?=\\/|$))";return[new RegExp(q,Y?void 0:"i"),X]}function Vp(Z){try{return Z.split("/").map((Y)=>decodeURIComponent(Y).replace(/\//g,"%2F")).join("/")}catch(Y){return i5(!1,`The URL path "${Z}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${Y}).`),Z}}function b4(Z,Y){if(Y==="/")return Z;if(!Z.toLowerCase().startsWith(Y.toLowerCase()))return null;let Q=Y.endsWith("/")?Y.length-1:Y.length,X=Z.charAt(Q);if(X&&X!=="/")return null;return Z.slice(Q)||"/"}function Tp({basename:Z,pathname:Y}){return Y==="/"?Z:O6([Z,Y])}var Bu=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,fK=(Z)=>Bu.test(Z);function Uu(Z,Y="/"){let{pathname:Q,search:X="",hash:q=""}=typeof Z==="string"?F6(Z):Z,B;if(Q)if(fK(Q))B=Q;else{if(Q.includes("//")){let $=Q;Q=Q.replace(/\/\/+/g,"/"),i5(!1,`Pathnames cannot have embedded double slashes - normalizing ${$} -> ${Q}`)}if(Q.startsWith("/"))B=Sy(Q.substring(1),"/");else B=Sy(Q,Y)}else B=Y;return{pathname:B,search:up(X),hash:Sp(q)}}function Sy(Z,Y){let Q=Y.replace(/\/+$/,"").split("/");return Z.split("/").forEach((q)=>{if(q===".."){if(Q.length>1)Q.pop()}else if(q!==".")Q.push(q)}),Q.length>1?Q.join("/"):"/"}function $F(Z,Y,Q,X){return`Cannot include a '${Z}' character in a manually specified \`to.${Y}\` field [${JSON.stringify(X)}]. Please separate it out to the \`to.${Q}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function $u(Z){return Z.filter((Y,Q)=>Q===0||Y.route.path&&Y.route.path.length>0)}function _F(Z){let Y=$u(Z);return Y.map((Q,X)=>X===Y.length-1?Q.pathname:Q.pathnameBase)}function vF(Z,Y,Q,X=!1){let q;if(typeof Z==="string")q=F6(Z);else q={...Z},K1(!q.pathname||!q.pathname.includes("?"),$F("?","pathname","search",q)),K1(!q.pathname||!q.pathname.includes("#"),$F("#","pathname","hash",q)),K1(!q.search||!q.search.includes("#"),$F("#","search","hash",q));let B=Z===""||q.pathname==="",$=B?"/":q.pathname,W;if($==null)W=Q;else{let R=Y.length-1;if(!X&&$.startsWith("..")){let F=$.split("/");while(F[0]==="..")F.shift(),R-=1;q.pathname=F.join("/")}W=R>=0?Y[R]:"/"}let M=Uu(q,W),H=$&&$!=="/"&&$.endsWith("/"),N=(B||$===".")&&Q.endsWith("/");if(!M.pathname.endsWith("/")&&(H||N))M.pathname+="/";return M}var O6=(Z)=>Z.join("/").replace(/\/\/+/g,"/"),yp=(Z)=>Z.replace(/\/+$/,"").replace(/^\/*/,"/"),up=(Z)=>!Z||Z==="?"?"":Z.startsWith("?")?Z:"?"+Z,Sp=(Z)=>!Z||Z==="#"?"":Z.startsWith("#")?Z:"#"+Z;var NB=(Z,Y=302)=>{let Q=Y;if(typeof Q==="number")Q={status:Q};else if(typeof Q.status>"u")Q.status=302;let X=new Headers(Q.headers);return X.set("Location",Z),new Response(null,{...Q,headers:X})};var eJ=class{constructor(Z,Y,Q,X=!1){if(this.status=Z,this.statusText=Y||"",this.internal=X,Q instanceof Error)this.data=Q.toString(),this.error=Q;else this.data=Q}};function HZ(Z){return Z!=null&&typeof Z.status==="number"&&typeof Z.statusText==="string"&&typeof Z.internal==="boolean"&&"data"in Z}function RB(Z){return Z.map((Y)=>Y.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Wu=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ku(Z,Y){let Q=Z;if(typeof Q!=="string"||!Bu.test(Q))return{absoluteURL:void 0,isExternal:!1,to:Q};let X=Q,q=!1;if(Wu)try{let B=new URL(window.location.href),$=Q.startsWith("//")?new URL(B.protocol+Q):new URL(Q),W=b4($.pathname,Y);if($.origin===B.origin&&W!=null)Q=W+$.search+$.hash;else q=!0}catch(B){i5(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:X,isExternal:q,to:Q}}var GZ=Symbol("Uninstrumented");function xp(Z,Y){let Q={lazy:[],"lazy.loader":[],"lazy.action":[],"lazy.middleware":[],middleware:[],loader:[],action:[]};Z.forEach((q)=>q({id:Y.id,index:Y.index,path:Y.path,instrument(B){let $=Object.keys(Q);for(let W of $)if(B[W])Q[W].push(B[W])}}));let X={};if(typeof Y.lazy==="function"&&Q.lazy.length>0){let q=sJ(Q.lazy,Y.lazy,()=>{return});if(q)X.lazy=q}if(typeof Y.lazy==="object"){let q=Y.lazy;["middleware","loader","action"].forEach((B)=>{let $=q[B],W=Q[`lazy.${B}`];if(typeof $==="function"&&W.length>0){let M=sJ(W,$,()=>{return});if(M)X.lazy=Object.assign(X.lazy||{},{[B]:M})}})}if(["loader","action"].forEach((q)=>{let B=Y[q];if(typeof B==="function"&&Q[q].length>0){let $=B[GZ]??B,W=sJ(Q[q],$,(...M)=>xy(M[0]));if(W){if(q==="loader"&&$.hydrate===!0)W.hydrate=!0;W[GZ]=$,X[q]=W}}}),Y.middleware&&Y.middleware.length>0&&Q.middleware.length>0)X.middleware=Y.middleware.map((q)=>{let B=q[GZ]??q,$=sJ(Q.middleware,B,(...W)=>xy(W[0]));if($)return $[GZ]=B,$;return q});return X}function Ep(Z,Y){let Q={navigate:[],fetch:[]};if(Y.forEach((X)=>X({instrument(q){let B=Object.keys(q);for(let $ of B)if(q[$])Q[$].push(q[$])}})),Q.navigate.length>0){let X=Z.navigate[GZ]??Z.navigate,q=sJ(Q.navigate,X,(...B)=>{let[$,W]=B;return{to:typeof $==="number"||typeof $==="string"?$:$?y3($):".",...Ey(Z,W??{})}});if(q)q[GZ]=X,Z.navigate=q}if(Q.fetch.length>0){let X=Z.fetch[GZ]??Z.fetch,q=sJ(Q.fetch,X,(...B)=>{let[$,,W,M]=B;return{href:W??".",fetcherKey:$,...Ey(Z,M??{})}});if(q)q[GZ]=X,Z.fetch=q}return Z}function sJ(Z,Y,Q){if(Z.length===0)return null;return async(...X)=>{let q=await Mu(Z,Q(...X),()=>Y(...X),Z.length-1);if(q.type==="error")throw q.value;return q.value}}async function Mu(Z,Y,Q,X){let q=Z[X],B;if(!q)try{B={type:"success",value:await Q()}}catch($){B={type:"error",value:$}}else{let $=void 0,W=async()=>{if($)console.error("You cannot call instrumented handlers more than once");else $=Mu(Z,Y,Q,X-1);if(B=await $,K1(B,"Expected a result"),B.type==="error"&&B.value instanceof Error)return{status:"error",error:B.value};return{status:"success",error:void 0}};try{await q(W,Y)}catch(M){console.error("An instrumentation function threw an error:",M)}if(!$)await W();await $}if(B)return B;return{type:"error",value:Error("No result assigned in instrumentation chain.")}}function xy(Z){let{request:Y,context:Q,params:X,unstable_pattern:q}=Z;return{request:Ip(Y),params:{...X},unstable_pattern:q,context:Dp(Q)}}function Ey(Z,Y){return{currentUrl:y3(Z.state.location),..."formMethod"in Y?{formMethod:Y.formMethod}:{},..."formEncType"in Y?{formEncType:Y.formEncType}:{},..."formData"in Y?{formData:Y.formData}:{},..."body"in Y?{body:Y.body}:{}}}function Ip(Z){return{method:Z.method,url:Z.url,headers:{get:(...Y)=>Z.headers.get(...Y)}}}function Dp(Z){if(mp(Z)){let Y={...Z};return Object.freeze(Y),Y}else return{get:(Y)=>Z.get(Y)}}var kp=Object.getOwnPropertyNames(Object.prototype).sort().join("\x00");function mp(Z){if(Z===null||typeof Z!=="object")return!1;let Y=Object.getPrototypeOf(Z);return Y===Object.prototype||Y===null||Object.getOwnPropertyNames(Y).sort().join("\x00")===kp}var Gu=["POST","PUT","PATCH","DELETE"],jp=new Set(Gu),gp=["GET",...Gu],hp=new Set(gp),Hu=new Set([301,302,303,307,308]),cp=new Set([307,308]),CK={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},CF={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},iJ={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},dp=(Z)=>({hasErrorBoundary:Boolean(Z.hasErrorBoundary)}),Nu="remix-router-transitions",Ru=Symbol("ResetLoaderData");function Ou(Z){let Y=Z.window?Z.window:typeof window<"u"?window:void 0,Q=typeof Y<"u"&&typeof Y.document<"u"&&typeof Y.document.createElement<"u";K1(Z.routes.length>0,"You must provide a non-empty routes array to createRouter");let X=Z.hydrationRouteProperties||[],q=Z.mapRouteProperties||dp,B=q;if(Z.unstable_instrumentations){let m=Z.unstable_instrumentations;B=(i)=>{return{...q(i),...xp(m.map((Z0)=>Z0.route).filter(Boolean),i)}}}let $={},W=GB(Z.routes,B,void 0,$),M,H=Z.basename||"/";if(!H.startsWith("/"))H=`/${H}`;let N=Z.dataStrategy||ip,R={...Z.future},F=null,A=new Set,v=null,C=null,f=null,P=Z.hydrationData!=null,L=H8(W,Z.history.location,H),b=!1,u=null,I;if(L==null&&!Z.patchRoutesOnNavigation){let m=t4(404,{pathname:Z.history.location.pathname}),{matches:i,route:Z0}=FK(W);I=!0,L=i,u={[Z0.id]:m}}else{if(L&&!Z.hydrationData){if(L5(L,W,Z.history.location.pathname).active)L=null}if(!L){I=!1,L=[];let m=L5(null,W,Z.history.location.pathname);if(m.active&&m.matches)b=!0,L=m.matches}else if(L.some((m)=>m.route.lazy))I=!1;else if(!L.some((m)=>LF(m.route)))I=!0;else{let m=Z.hydrationData?Z.hydrationData.loaderData:null,i=Z.hydrationData?Z.hydrationData.errors:null;if(i){let Z0=L.findIndex((N0)=>i[N0.route.id]!==void 0);I=L.slice(0,Z0+1).every((N0)=>!NF(N0.route,m,i))}else I=L.every((Z0)=>!NF(Z0.route,m,i))}}let d,S={historyAction:Z.history.action,location:Z.history.location,matches:L,initialized:I,navigation:CK,restoreScrollPosition:Z.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:Z.hydrationData&&Z.hydrationData.loaderData||{},actionData:Z.hydrationData&&Z.hydrationData.actionData||null,errors:Z.hydrationData&&Z.hydrationData.errors||u,fetchers:new Map,blockers:new Map},c="POP",Y0=null,k=!1,t,B0=!1,U0=new Map,H0=null,s=!1,X0=!1,K0=new Set,e=new Map,R0=0,D=-1,q0=new Map,M0=new Set,$0=new Map,c0=new Map,L1=new Set,G0=new Map,F1=void 0,u1=null;function J5(){if(F=Z.history.listen(({action:m,location:i,delta:Z0})=>{if(F1){F1(),F1=void 0;return}i5(G0.size===0||Z0!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let N0=e0({currentLocation:S.location,nextLocation:i,historyAction:m});if(N0&&Z0!=null){let A0=new Promise((m0)=>{F1=m0});Z.history.go(Z0*-1),I0(N0,{state:"blocked",location:i,proceed(){I0(N0,{state:"proceeding",proceed:void 0,reset:void 0,location:i}),A0.then(()=>Z.history.go(Z0))},reset(){let m0=new Map(S.blockers);m0.set(N0,iJ),n1({blockers:m0})}}),Y0?.resolve(),Y0=null;return}return G1(m,i)}),Q){Kl(Y,U0);let m=()=>Ml(Y,U0);Y.addEventListener("pagehide",m),H0=()=>Y.removeEventListener("pagehide",m)}if(!S.initialized)G1("POP",S.location,{initialHydration:!0});return d}function a1(){if(F)F();if(H0)H0();A.clear(),t&&t.abort(),S.fetchers.forEach((m,i)=>s7(i)),S.blockers.forEach((m,i)=>L0(i))}function T0(m){return A.add(m),()=>A.delete(m)}function n1(m,i={}){if(m.matches)m.matches=m.matches.map((A0)=>{let m0=$[A0.route.id],S0=A0.route;if(S0.element!==m0.element||S0.errorElement!==m0.errorElement||S0.hydrateFallbackElement!==m0.hydrateFallbackElement)return{...A0,route:m0};return A0});S={...S,...m};let Z0=[],N0=[];S.fetchers.forEach((A0,m0)=>{if(A0.state==="idle")if(L1.has(m0))Z0.push(m0);else N0.push(m0)}),L1.forEach((A0)=>{if(!S.fetchers.has(A0)&&!e.has(A0))Z0.push(A0)}),[...A].forEach((A0)=>A0(S,{deletedFetchers:Z0,newErrors:m.errors??null,viewTransitionOpts:i.viewTransitionOpts,flushSync:i.flushSync===!0})),Z0.forEach((A0)=>s7(A0)),N0.forEach((A0)=>S.fetchers.delete(A0))}function Q2(m,i,{flushSync:Z0}={}){let N0=S.actionData!=null&&S.navigation.formMethod!=null&&C7(S.navigation.formMethod)&&S.navigation.state==="loading"&&m.state?._isRedirect!==!0,A0;if(i.actionData)if(Object.keys(i.actionData).length>0)A0=i.actionData;else A0=null;else if(N0)A0=S.actionData;else A0=null;let m0=i.loaderData?py(S.loaderData,i.loaderData,i.matches||[],i.errors):S.loaderData,S0=S.blockers;if(S0.size>0)S0=new Map(S0),S0.forEach((Z1,l0)=>S0.set(l0,iJ));let E0=s?!1:K5(m,i.matches||S.matches),p0=k===!0||S.navigation.formMethod!=null&&C7(S.navigation.formMethod)&&m.state?._isRedirect!==!0;if(M)W=M,M=void 0;if(s);else if(c==="POP");else if(c==="PUSH")Z.history.push(m,m.state);else if(c==="REPLACE")Z.history.replace(m,m.state);let a0;if(c==="POP"){let Z1=U0.get(S.location.pathname);if(Z1&&Z1.has(m.pathname))a0={currentLocation:S.location,nextLocation:m};else if(U0.has(m.pathname))a0={currentLocation:m,nextLocation:S.location}}else if(B0){let Z1=U0.get(S.location.pathname);if(Z1)Z1.add(m.pathname);else Z1=new Set([m.pathname]),U0.set(S.location.pathname,Z1);a0={currentLocation:S.location,nextLocation:m}}n1({...i,actionData:A0,loaderData:m0,historyAction:c,location:m,initialized:!0,navigation:CK,revalidation:"idle",restoreScrollPosition:E0,preventScrollReset:p0,blockers:S0},{viewTransitionOpts:a0,flushSync:Z0===!0}),c="POP",k=!1,B0=!1,s=!1,X0=!1,Y0?.resolve(),Y0=null,u1?.resolve(),u1=null}async function X2(m,i){if(Y0?.resolve(),Y0=null,typeof m==="number"){if(!Y0)Y0=iy();let o1=Y0.promise;return Z.history.go(m),o1}let Z0=HF(S.location,S.matches,H,m,i?.fromRouteId,i?.relative),{path:N0,submission:A0,error:m0}=Iy(!1,Z0,i),S0=S.location,E0=MB(S.location,N0,i&&i.state);E0={...E0,...Z.history.encodeLocation(E0)};let p0=i&&i.replace!=null?i.replace:void 0,a0="PUSH";if(p0===!0)a0="REPLACE";else if(p0===!1);else if(A0!=null&&C7(A0.formMethod)&&A0.formAction===S.location.pathname+S.location.search)a0="REPLACE";let Z1=i&&"preventScrollReset"in i?i.preventScrollReset===!0:void 0,l0=(i&&i.flushSync)===!0,i1=e0({currentLocation:S0,nextLocation:E0,historyAction:a0});if(i1){I0(i1,{state:"blocked",location:E0,proceed(){I0(i1,{state:"proceeding",proceed:void 0,reset:void 0,location:E0}),X2(m,i)},reset(){let o1=new Map(S.blockers);o1.set(i1,iJ),n1({blockers:o1})}});return}await G1(a0,E0,{submission:A0,pendingError:m0,preventScrollReset:Z1,replace:i&&i.replace,enableViewTransition:i&&i.viewTransition,flushSync:l0,callSiteDefaultShouldRevalidate:i&&i.unstable_defaultShouldRevalidate})}function v5(){if(!u1)u1=iy();w7(),n1({revalidation:"loading"});let m=u1.promise;if(S.navigation.state==="submitting")return m;if(S.navigation.state==="idle")return G1(S.historyAction,S.location,{startUninterruptedRevalidation:!0}),m;return G1(c||S.historyAction,S.navigation.location,{overrideNavigation:S.navigation,enableViewTransition:B0===!0}),m}async function G1(m,i,Z0){t&&t.abort(),t=null,c=m,s=(Z0&&Z0.startUninterruptedRevalidation)===!0,C5(S.location,S.matches),k=(Z0&&Z0.preventScrollReset)===!0,B0=(Z0&&Z0.enableViewTransition)===!0;let N0=M||W,A0=Z0&&Z0.overrideNavigation,m0=Z0?.initialHydration&&S.matches&&S.matches.length>0&&!b?S.matches:H8(N0,i,H),S0=(Z0&&Z0.flushSync)===!0;if(m0&&S.initialized&&!X0&&wl(S.location,i)&&!(Z0&&Z0.submission&&C7(Z0.submission.formMethod))){Q2(i,{matches:m0},{flushSync:S0});return}let E0=L5(m0,N0,i.pathname);if(E0.active&&E0.matches)m0=E0.matches;if(!m0){let{error:q2,notFoundMatches:c2,route:Q5}=k0(i.pathname);Q2(i,{matches:c2,loaderData:{},errors:{[Q5.id]:q2}},{flushSync:S0});return}t=new AbortController;let p0=oJ(Z.history,i,t.signal,Z0&&Z0.submission),a0=Z.getContext?await Z.getContext():new GF,Z1;if(Z0&&Z0.pendingError)Z1=[MZ(m0).route.id,{type:"error",error:Z0.pendingError}];else if(Z0&&Z0.submission&&C7(Z0.submission.formMethod)){let q2=await g3(p0,i,Z0.submission,m0,a0,E0.active,Z0&&Z0.initialHydration===!0,{replace:Z0.replace,flushSync:S0});if(q2.shortCircuited)return;if(q2.pendingActionResult){let[c2,Q5]=q2.pendingActionResult;if(P4(Q5)&&HZ(Q5.error)&&Q5.error.status===404){t=null,Q2(i,{matches:q2.matches,loaderData:{},errors:{[c2]:Q5.error}});return}}m0=q2.matches||m0,Z1=q2.pendingActionResult,A0=WF(i,Z0.submission),S0=!1,E0.active=!1,p0=oJ(Z.history,p0.url,p0.signal)}let{shortCircuited:l0,matches:i1,loaderData:o1,errors:c5}=await B1(p0,i,m0,a0,E0.active,A0,Z0&&Z0.submission,Z0&&Z0.fetcherSubmission,Z0&&Z0.replace,Z0&&Z0.initialHydration===!0,S0,Z1,Z0&&Z0.callSiteDefaultShouldRevalidate);if(l0)return;t=null,Q2(i,{matches:i1||m0,...ly(Z1),loaderData:o1,errors:c5})}async function g3(m,i,Z0,N0,A0,m0,S0,E0={}){w7();let p0=$l(i,Z0);if(n1({navigation:p0},{flushSync:E0.flushSync===!0}),m0){let l0=await z2(N0,i.pathname,m.signal);if(l0.type==="aborted")return{shortCircuited:!0};else if(l0.type==="error"){if(l0.partialMatches.length===0){let{matches:o1,route:c5}=FK(W);return{matches:o1,pendingActionResult:[c5.id,{type:"error",error:l0.error}]}}let i1=MZ(l0.partialMatches).route.id;return{matches:l0.partialMatches,pendingActionResult:[i1,{type:"error",error:l0.error}]}}else if(!l0.matches){let{notFoundMatches:i1,error:o1,route:c5}=k0(i.pathname);return{matches:i1,pendingActionResult:[c5.id,{type:"error",error:o1}]}}else N0=l0.matches}let a0,Z1=LK(N0,i);if(!Z1.route.action&&!Z1.route.lazy)a0={type:"error",error:t4(405,{method:m.method,pathname:i.pathname,routeId:Z1.route.id})};else{let l0=tJ(B,$,m,N0,Z1,S0?[]:X,A0),i1=await H3(m,l0,A0,null);if(a0=i1[Z1.route.id],!a0){for(let o1 of N0)if(i1[o1.route.id]){a0=i1[o1.route.id];break}}if(m.signal.aborted)return{shortCircuited:!0}}if(EY(a0)){let l0;if(E0&&E0.replace!=null)l0=E0.replace;else l0=hy(a0.response.headers.get("Location"),new URL(m.url),H,Z.history)===S.location.pathname+S.location.search;return await g2(m,a0,!0,{submission:Z0,replace:l0}),{shortCircuited:!0}}if(P4(a0)){let l0=MZ(N0,Z1.route.id);if((E0&&E0.replace)!==!0)c="PUSH";return{matches:N0,pendingActionResult:[l0.route.id,a0,Z1.route.id]}}return{matches:N0,pendingActionResult:[Z1.route.id,a0]}}async function B1(m,i,Z0,N0,A0,m0,S0,E0,p0,a0,Z1,l0,i1){let o1=m0||WF(i,S0),c5=S0||E0||ay(o1),q2=!s&&!a0;if(A0){if(q2){let N2=B4(l0);n1({navigation:o1,...N2!==void 0?{actionData:N2}:{}},{flushSync:Z1})}let S1=await z2(Z0,i.pathname,m.signal);if(S1.type==="aborted")return{shortCircuited:!0};else if(S1.type==="error"){if(S1.partialMatches.length===0){let{matches:P9,route:h6}=FK(W);return{matches:P9,loaderData:{},errors:{[h6.id]:S1.error}}}let N2=MZ(S1.partialMatches).route.id;return{matches:S1.partialMatches,loaderData:{},errors:{[N2]:S1.error}}}else if(!S1.matches){let{error:N2,notFoundMatches:P9,route:h6}=k0(i.pathname);return{matches:P9,loaderData:{},errors:{[h6.id]:N2}}}else Z0=S1.matches}let c2=M||W,{dsMatches:Q5,revalidatingFetchers:T7}=Dy(m,N0,B,$,Z.history,S,Z0,c5,i,a0?[]:X,a0===!0,X0,K0,L1,$0,M0,c2,H,Z.patchRoutesOnNavigation!=null,l0,i1);if(D=++R0,!Z.dataStrategy&&!Q5.some((S1)=>S1.shouldLoad)&&!Q5.some((S1)=>S1.route.middleware&&S1.route.middleware.length>0)&&T7.length===0){let S1=y();return Q2(i,{matches:Z0,loaderData:{},errors:l0&&P4(l0[1])?{[l0[0]]:l0[1].error}:null,...ly(l0),...S1?{fetchers:new Map(S.fetchers)}:{}},{flushSync:Z1}),{shortCircuited:!0}}if(q2){let S1={};if(!A0){S1.navigation=o1;let N2=B4(l0);if(N2!==void 0)S1.actionData=N2}if(T7.length>0)S1.fetchers=j1(T7);n1(S1,{flushSync:Z1})}T7.forEach((S1)=>{if(J7(S1.key),S1.controller)e.set(S1.key,S1.controller)});let h3=()=>T7.forEach((S1)=>J7(S1.key));if(t)t.signal.addEventListener("abort",h3);let{loaderResults:T2,fetcherResults:y7}=await N3(Q5,T7,m,N0);if(m.signal.aborted)return{shortCircuited:!0};if(t)t.signal.removeEventListener("abort",h3);T7.forEach((S1)=>e.delete(S1.key));let d2=AK(T2);if(d2)return await g2(m,d2.result,!0,{replace:p0}),{shortCircuited:!0};if(d2=AK(y7),d2)return M0.add(d2.key),await g2(m,d2.result,!0,{replace:p0}),{shortCircuited:!0};let{loaderData:aw,errors:O3}=dy(S,Z0,T2,l0,T7,y7);if(a0&&S.errors)O3={...S.errors,...O3};let k4=y(),L9=o(D),c3=k4||L9||T7.length>0;return{matches:Z0,loaderData:aw,errors:O3,...c3?{fetchers:new Map(S.fetchers)}:{}}}function B4(m){if(m&&!P4(m[1]))return{[m[0]]:m[1].data};else if(S.actionData)if(Object.keys(S.actionData).length===0)return null;else return S.actionData}function j1(m){return m.forEach((i)=>{let Z0=S.fetchers.get(i.key),N0=BB(void 0,Z0?Z0.data:void 0);S.fetchers.set(i.key,N0)}),new Map(S.fetchers)}async function G3(m,i,Z0,N0){J7(m);let A0=(N0&&N0.flushSync)===!0,m0=M||W,S0=HF(S.location,S.matches,H,Z0,i,N0?.relative),E0=H8(m0,S0,H),p0=L5(E0,m0,S0);if(p0.active&&p0.matches)E0=p0.matches;if(!E0){H2(m,i,t4(404,{pathname:S0}),{flushSync:A0});return}let{path:a0,submission:Z1,error:l0}=Iy(!0,S0,N0);if(l0){H2(m,i,l0,{flushSync:A0});return}let i1=Z.getContext?await Z.getContext():new GF,o1=(N0&&N0.preventScrollReset)===!0;if(Z1&&C7(Z1.formMethod)){await Y7(m,i,a0,E0,i1,p0.active,A0,o1,Z1,N0&&N0.unstable_defaultShouldRevalidate);return}$0.set(m,{routeId:i,path:a0}),await I4(m,i,a0,E0,i1,p0.active,A0,o1,Z1)}async function Y7(m,i,Z0,N0,A0,m0,S0,E0,p0,a0){w7(),$0.delete(m);let Z1=S.fetchers.get(m);E5(m,Wl(p0,Z1),{flushSync:S0});let l0=new AbortController,i1=oJ(Z.history,Z0,l0.signal,p0);if(m0){let I5=await z2(N0,new URL(i1.url).pathname,i1.signal,m);if(I5.type==="aborted")return;else if(I5.type==="error"){H2(m,i,I5.error,{flushSync:S0});return}else if(!I5.matches){H2(m,i,t4(404,{pathname:Z0}),{flushSync:S0});return}else N0=I5.matches}let o1=LK(N0,Z0);if(!o1.route.action&&!o1.route.lazy){let I5=t4(405,{method:p0.formMethod,pathname:Z0,routeId:i});H2(m,i,I5,{flushSync:S0});return}e.set(m,l0);let c5=R0,q2=tJ(B,$,i1,N0,o1,X,A0),c2=await H3(i1,q2,A0,m),Q5=c2[o1.route.id];if(!Q5){for(let I5 of q2)if(c2[I5.route.id]){Q5=c2[I5.route.id];break}}if(i1.signal.aborted){if(e.get(m)===l0)e.delete(m);return}if(L1.has(m)){if(EY(Q5)||P4(Q5)){E5(m,G8(void 0));return}}else{if(EY(Q5))if(e.delete(m),D>c5){E5(m,G8(void 0));return}else return M0.add(m),E5(m,BB(p0)),g2(i1,Q5,!1,{fetcherSubmission:p0,preventScrollReset:E0});if(P4(Q5)){H2(m,i,Q5.error);return}}let T7=S.navigation.location||S.location,h3=oJ(Z.history,T7,l0.signal),T2=M||W,y7=S.navigation.state!=="idle"?H8(T2,S.navigation.location,H):S.matches;K1(y7,"Didn't find any matches after fetcher action");let d2=++R0;q0.set(m,d2);let aw=BB(p0,Q5.data);S.fetchers.set(m,aw);let{dsMatches:O3,revalidatingFetchers:k4}=Dy(h3,A0,B,$,Z.history,S,y7,p0,T7,X,!1,X0,K0,L1,$0,M0,T2,H,Z.patchRoutesOnNavigation!=null,[o1.route.id,Q5],a0);k4.filter((I5)=>I5.key!==m).forEach((I5)=>{let b9=I5.key,iw=S.fetchers.get(b9),q$=BB(void 0,iw?iw.data:void 0);if(S.fetchers.set(b9,q$),J7(b9),I5.controller)e.set(b9,I5.controller)}),n1({fetchers:new Map(S.fetchers)});let L9=()=>k4.forEach((I5)=>J7(I5.key));l0.signal.addEventListener("abort",L9);let{loaderResults:c3,fetcherResults:S1}=await N3(O3,k4,h3,A0);if(l0.signal.aborted)return;if(l0.signal.removeEventListener("abort",L9),q0.delete(m),e.delete(m),k4.forEach((I5)=>e.delete(I5.key)),S.fetchers.has(m)){let I5=G8(Q5.data);S.fetchers.set(m,I5)}let N2=AK(c3);if(N2)return g2(h3,N2.result,!1,{preventScrollReset:E0});if(N2=AK(S1),N2)return M0.add(N2.key),g2(h3,N2.result,!1,{preventScrollReset:E0});let{loaderData:P9,errors:h6}=dy(S,y7,c3,void 0,k4,S1);if(o(d2),S.navigation.state==="loading"&&d2>D)K1(c,"Expected pending action"),t&&t.abort(),Q2(S.navigation.location,{matches:y7,loaderData:P9,errors:h6,fetchers:new Map(S.fetchers)});else n1({errors:h6,loaderData:py(S.loaderData,P9,y7,h6),fetchers:new Map(S.fetchers)}),X0=!1}async function I4(m,i,Z0,N0,A0,m0,S0,E0,p0){let a0=S.fetchers.get(m);E5(m,BB(p0,a0?a0.data:void 0),{flushSync:S0});let Z1=new AbortController,l0=oJ(Z.history,Z0,Z1.signal);if(m0){let Q5=await z2(N0,new URL(l0.url).pathname,l0.signal,m);if(Q5.type==="aborted")return;else if(Q5.type==="error"){H2(m,i,Q5.error,{flushSync:S0});return}else if(!Q5.matches){H2(m,i,t4(404,{pathname:Z0}),{flushSync:S0});return}else N0=Q5.matches}let i1=LK(N0,Z0);e.set(m,Z1);let o1=R0,c5=tJ(B,$,l0,N0,i1,X,A0),c2=(await H3(l0,c5,A0,m))[i1.route.id];if(e.get(m)===Z1)e.delete(m);if(l0.signal.aborted)return;if(L1.has(m)){E5(m,G8(void 0));return}if(EY(c2))if(D>o1){E5(m,G8(void 0));return}else{M0.add(m),await g2(l0,c2,!1,{preventScrollReset:E0});return}if(P4(c2)){H2(m,i,c2.error);return}E5(m,G8(c2.data))}async function g2(m,i,Z0,{submission:N0,fetcherSubmission:A0,preventScrollReset:m0,replace:S0}={}){if(!Z0)Y0?.resolve(),Y0=null;if(i.response.headers.has("X-Remix-Revalidate"))X0=!0;let E0=i.response.headers.get("Location");K1(E0,"Expected a Location header on the redirect Response"),E0=hy(E0,new URL(m.url),H,Z.history);let p0=MB(S.location,E0,{_isRedirect:!0});if(Q){let c5=!1;if(i.response.headers.has("X-Remix-Reload-Document"))c5=!0;else if(fK(E0)){let q2=Qu(E0,!0);c5=q2.origin!==Y.location.origin||b4(q2.pathname,H)==null}if(c5){if(S0)Y.location.replace(E0);else Y.location.assign(E0);return}}t=null;let a0=S0===!0||i.response.headers.has("X-Remix-Replace")?"REPLACE":"PUSH",{formMethod:Z1,formAction:l0,formEncType:i1}=S.navigation;if(!N0&&!A0&&Z1&&l0&&i1)N0=ay(S.navigation);let o1=N0||A0;if(cp.has(i.response.status)&&o1&&C7(o1.formMethod))await G1(a0,p0,{submission:{...o1,formAction:E0},preventScrollReset:m0||k,enableViewTransition:Z0?B0:void 0});else{let c5=WF(p0,N0);await G1(a0,p0,{overrideNavigation:c5,fetcherSubmission:A0,preventScrollReset:m0||k,enableViewTransition:Z0?B0:void 0})}}async function H3(m,i,Z0,N0){let A0,m0={};try{A0=await sp(N,m,i,N0,Z0,!1)}catch(S0){return i.filter((E0)=>E0.shouldLoad).forEach((E0)=>{m0[E0.route.id]={type:"error",error:S0}}),m0}if(m.signal.aborted)return m0;if(!C7(m.method))for(let S0 of i){if(A0[S0.route.id]?.type==="error")break;if(!A0.hasOwnProperty(S0.route.id)&&!S.loaderData.hasOwnProperty(S0.route.id)&&(!S.errors||!S.errors.hasOwnProperty(S0.route.id))&&S0.shouldCallHandler())A0[S0.route.id]={type:"error",result:Error(`No result returned from dataStrategy for route ${S0.route.id}`)}}for(let[S0,E0]of Object.entries(A0))if(zl(E0)){let p0=E0.result;m0[S0]={type:"redirect",response:Zl(p0,m,S0,i,H)}}else m0[S0]=await ep(E0);return m0}async function N3(m,i,Z0,N0){let A0=H3(Z0,m,N0,null),m0=Promise.all(i.map(async(p0)=>{if(p0.matches&&p0.match&&p0.request&&p0.controller){let Z1=(await H3(p0.request,p0.matches,N0,p0.key))[p0.match.route.id];return{[p0.key]:Z1}}else return Promise.resolve({[p0.key]:{type:"error",error:t4(404,{pathname:p0.path})}})})),S0=await A0,E0=(await m0).reduce((p0,a0)=>Object.assign(p0,a0),{});return{loaderResults:S0,fetcherResults:E0}}function w7(){X0=!0,$0.forEach((m,i)=>{if(e.has(i))K0.add(i);J7(i)})}function E5(m,i,Z0={}){S.fetchers.set(m,i),n1({fetchers:new Map(S.fetchers)},{flushSync:(Z0&&Z0.flushSync)===!0})}function H2(m,i,Z0,N0={}){let A0=MZ(S.matches,i);s7(m),n1({errors:{[A0.route.id]:Z0},fetchers:new Map(S.fetchers)},{flushSync:(N0&&N0.flushSync)===!0})}function U4(m){if(c0.set(m,(c0.get(m)||0)+1),L1.has(m))L1.delete(m);return S.fetchers.get(m)||CF}function h2(m,i){J7(m,i?.reason),E5(m,G8(null))}function s7(m){let i=S.fetchers.get(m);if(e.has(m)&&!(i&&i.state==="loading"&&q0.has(m)))J7(m);$0.delete(m),q0.delete(m),M0.delete(m),L1.delete(m),K0.delete(m),S.fetchers.delete(m)}function R3(m){let i=(c0.get(m)||0)-1;if(i<=0)c0.delete(m),L1.add(m);else c0.set(m,i);n1({fetchers:new Map(S.fetchers)})}function J7(m,i){let Z0=e.get(m);if(Z0)Z0.abort(i),e.delete(m)}function f7(m){for(let i of m){let Z0=U4(i),N0=G8(Z0.data);S.fetchers.set(i,N0)}}function y(){let m=[],i=!1;for(let Z0 of M0){let N0=S.fetchers.get(Z0);if(K1(N0,`Expected fetcher: ${Z0}`),N0.state==="loading")M0.delete(Z0),m.push(Z0),i=!0}return f7(m),i}function o(m){let i=[];for(let[Z0,N0]of q0)if(N00}function O0(m,i){let Z0=S.blockers.get(m)||iJ;if(G0.get(m)!==i)G0.set(m,i);return Z0}function L0(m){S.blockers.delete(m),G0.delete(m)}function I0(m,i){let Z0=S.blockers.get(m)||iJ;K1(Z0.state==="unblocked"&&i.state==="blocked"||Z0.state==="blocked"&&i.state==="blocked"||Z0.state==="blocked"&&i.state==="proceeding"||Z0.state==="blocked"&&i.state==="unblocked"||Z0.state==="proceeding"&&i.state==="unblocked",`Invalid blocker state transition: ${Z0.state} -> ${i.state}`);let N0=new Map(S.blockers);N0.set(m,i),n1({blockers:N0})}function e0({currentLocation:m,nextLocation:i,historyAction:Z0}){if(G0.size===0)return;if(G0.size>1)i5(!1,"A router only supports one blocker at a time");let N0=Array.from(G0.entries()),[A0,m0]=N0[N0.length-1],S0=S.blockers.get(A0);if(S0&&S0.state==="proceeding")return;if(m0({currentLocation:m,nextLocation:i,historyAction:Z0}))return A0}function k0(m){let i=t4(404,{pathname:m}),Z0=M||W,{matches:N0,route:A0}=FK(Z0);return{notFoundMatches:N0,route:A0,error:i}}function J1(m,i,Z0){if(v=m,f=i,C=Z0||null,!P&&S.navigation===CK){P=!0;let N0=K5(S.location,S.matches);if(N0!=null)n1({restoreScrollPosition:N0})}return()=>{v=null,f=null,C=null}}function u0(m,i){if(C)return C(m,i.map((N0)=>Xu(N0,S.loaderData)))||m.key;return m.key}function C5(m,i){if(v&&f){let Z0=u0(m,i);v[Z0]=f()}}function K5(m,i){if(v){let Z0=u0(m,i),N0=v[Z0];if(typeof N0==="number")return N0}return null}function L5(m,i,Z0){if(Z.patchRoutesOnNavigation){if(!m)return{active:!0,matches:WB(i,Z0,H,!0)||[]};else if(Object.keys(m[0].params).length>0)return{active:!0,matches:WB(i,Z0,H,!0)}}return{active:!1,matches:null}}async function z2(m,i,Z0,N0){if(!Z.patchRoutesOnNavigation)return{type:"success",matches:m};let A0=m;while(!0){let m0=M==null,S0=M||W,E0=$;try{await Z.patchRoutesOnNavigation({signal:Z0,path:i,matches:A0,fetcherKey:N0,patch:(Z1,l0)=>{if(Z0.aborted)return;ky(Z1,l0,S0,E0,B,!1)}})}catch(Z1){return{type:"error",error:Z1,partialMatches:A0}}finally{if(m0&&!Z0.aborted)W=[...W]}if(Z0.aborted)return{type:"aborted"};let p0=H8(S0,i,H),a0=null;if(p0){if(Object.keys(p0[0].params).length===0)return{type:"success",matches:p0};else if(a0=WB(S0,i,H,!0),!(a0&&A0.lengthZ0.route.id===i[N0].route.id)}function h5(m){$={},M=GB(m,B,void 0,$)}function V7(m,i,Z0=!1){let N0=M==null;if(ky(m,i,M||W,$,B,Z0),N0)W=[...W],n1({})}if(d={get basename(){return H},get future(){return R},get state(){return S},get routes(){return W},get window(){return Y},initialize:J5,subscribe:T0,enableScrollRestoration:J1,navigate:X2,fetch:G3,revalidate:v5,createHref:(m)=>Z.history.createHref(m),encodeLocation:(m)=>Z.history.encodeLocation(m),getFetcher:U4,resetFetcher:h2,deleteFetcher:R3,dispose:a1,getBlocker:O0,deleteBlocker:L0,patchRoutes:V7,_internalFetchControllers:e,_internalSetRoutes:h5,_internalSetStateDoNotUseOrYouWillBreakYourApp(m){n1(m)}},Z.unstable_instrumentations)d=Ep(d,Z.unstable_instrumentations.map((m)=>m.router).filter(Boolean));return d}function pp(Z){return Z!=null&&(("formData"in Z)&&Z.formData!=null||("body"in Z)&&Z.body!==void 0)}function HF(Z,Y,Q,X,q,B){let $,W;if(q){$=[];for(let H of Y)if($.push(H),H.route.id===q){W=H;break}}else $=Y,W=Y[Y.length-1];let M=vF(X?X:".",_F($),b4(Z.pathname,Q)||Z.pathname,B==="path");if(X==null)M.search=Z.search,M.hash=Z.hash;if((X==null||X===""||X===".")&&W){let H=bF(M.search);if(W.route.index&&!H)M.search=M.search?M.search.replace(/^\?/,"?index&"):"?index";else if(!W.route.index&&H){let N=new URLSearchParams(M.search),R=N.getAll("index");N.delete("index"),R.filter((A)=>A).forEach((A)=>N.append("index",A));let F=N.toString();M.search=F?`?${F}`:""}}if(Q!=="/")M.pathname=Tp({basename:Q,pathname:M.pathname});return y3(M)}function Iy(Z,Y,Q){if(!Q||!pp(Q))return{path:Y};if(Q.formMethod&&!Ul(Q.formMethod))return{path:Y,error:t4(405,{method:Q.formMethod})};let X=()=>({path:Y,error:t4(400,{type:"invalid-body"})}),B=(Q.formMethod||"get").toUpperCase(),$=Lu(Y);if(Q.body!==void 0){if(Q.formEncType==="text/plain"){if(!C7(B))return X();let R=typeof Q.body==="string"?Q.body:Q.body instanceof FormData||Q.body instanceof URLSearchParams?Array.from(Q.body.entries()).reduce((F,[A,v])=>`${F}${A}=${v} `,""):String(Q.body);return{path:Y,submission:{formMethod:B,formAction:$,formEncType:Q.formEncType,formData:void 0,json:void 0,text:R}}}else if(Q.formEncType==="application/json"){if(!C7(B))return X();try{let R=typeof Q.body==="string"?JSON.parse(Q.body):Q.body;return{path:Y,submission:{formMethod:B,formAction:$,formEncType:Q.formEncType,formData:void 0,json:R,text:void 0}}}catch(R){return X()}}}K1(typeof FormData==="function","FormData is not available in this environment");let W,M;if(Q.formData)W=OF(Q.formData),M=Q.formData;else if(Q.body instanceof FormData)W=OF(Q.body),M=Q.body;else if(Q.body instanceof URLSearchParams)W=Q.body,M=cy(W);else if(Q.body==null)W=new URLSearchParams,M=new FormData;else try{W=new URLSearchParams(Q.body),M=cy(W)}catch(R){return X()}let H={formMethod:B,formAction:$,formEncType:Q&&Q.formEncType||"application/x-www-form-urlencoded",formData:M,json:void 0,text:void 0};if(C7(H.formMethod))return{path:Y,submission:H};let N=F6(Y);if(Z&&N.search&&bF(N.search))W.append("index","");return N.search=`?${W}`,{path:y3(N),submission:H}}function Dy(Z,Y,Q,X,q,B,$,W,M,H,N,R,F,A,v,C,f,P,L,b,u){let I=b?P4(b[1])?b[1].error:b[1].data:void 0,d=q.createURL(B.location),S=q.createURL(M),c;if(N&&B.errors){let s=Object.keys(B.errors)[0];c=$.findIndex((X0)=>X0.route.id===s)}else if(b&&P4(b[1])){let s=b[0];c=$.findIndex((X0)=>X0.route.id===s)-1}let Y0=b?b[1].statusCode:void 0,k=Y0&&Y0>=400,t={currentUrl:d,currentParams:B.matches[0]?.params||{},nextUrl:S,nextParams:$[0].params,...W,actionResult:I,actionStatus:Y0},B0=RB($),U0=$.map((s,X0)=>{let{route:K0}=s,e=null;if(c!=null&&X0>c)e=!1;else if(K0.lazy)e=!0;else if(!LF(K0))e=!1;else if(N)e=NF(K0,B.loaderData,B.errors);else if(lp(B.loaderData,B.matches[X0],s))e=!0;if(e!==null)return RF(Q,X,Z,B0,s,H,Y,e);let R0=!1;if(typeof u==="boolean")R0=u;else if(k)R0=!1;else if(R)R0=!0;else if(d.pathname+d.search===S.pathname+S.search)R0=!0;else if(d.search!==S.search)R0=!0;else if(rp(B.matches[X0],s))R0=!0;let D={...t,defaultShouldRevalidate:R0},q0=KB(s,D);return RF(Q,X,Z,B0,s,H,Y,q0,D,u)}),H0=[];return v.forEach((s,X0)=>{if(N||!$.some((c0)=>c0.route.id===s.routeId)||A.has(X0))return;let K0=B.fetchers.get(X0),e=K0&&K0.state!=="idle"&&K0.data===void 0,R0=H8(f,s.path,P);if(!R0){if(L&&e)return;H0.push({key:X0,routeId:s.routeId,path:s.path,matches:null,match:null,request:null,controller:null});return}if(C.has(X0))return;let D=LK(R0,s.path),q0=new AbortController,M0=oJ(q,s.path,q0.signal),$0=null;if(F.has(X0))F.delete(X0),$0=tJ(Q,X,M0,R0,D,H,Y);else if(e){if(R)$0=tJ(Q,X,M0,R0,D,H,Y)}else{let c0;if(typeof u==="boolean")c0=u;else if(k)c0=!1;else c0=R;let L1={...t,defaultShouldRevalidate:c0};if(KB(D,L1))$0=tJ(Q,X,M0,R0,D,H,Y,L1)}if($0)H0.push({key:X0,routeId:s.routeId,path:s.path,matches:$0,match:D,request:M0,controller:q0})}),{dsMatches:U0,revalidatingFetchers:H0}}function LF(Z){return Z.loader!=null||Z.middleware!=null&&Z.middleware.length>0}function NF(Z,Y,Q){if(Z.lazy)return!0;if(!LF(Z))return!1;let X=Y!=null&&Z.id in Y,q=Q!=null&&Q[Z.id]!==void 0;if(!X&&q)return!1;if(typeof Z.loader==="function"&&Z.loader.hydrate===!0)return!0;return!X&&!q}function lp(Z,Y,Q){let X=!Y||Q.route.id!==Y.route.id,q=!Z.hasOwnProperty(Q.route.id);return X||q}function rp(Z,Y){let Q=Z.route.path;return Z.pathname!==Y.pathname||Q!=null&&Q.endsWith("*")&&Z.params["*"]!==Y.params["*"]}function KB(Z,Y){if(Z.route.shouldRevalidate){let Q=Z.route.shouldRevalidate(Y);if(typeof Q==="boolean")return Q}return Y.defaultShouldRevalidate}function ky(Z,Y,Q,X,q,B){let $;if(Z){let H=X[Z];if(K1(H,`No route found to patch children into: routeId = ${Z}`),!H.children)H.children=[];$=H.children}else $=Q;let W=[],M=[];if(Y.forEach((H)=>{let N=$.find((R)=>Fu(H,R));if(N)M.push({existingRoute:N,newRoute:H});else W.push(H)}),W.length>0){let H=GB(W,q,[Z||"_","patch",String($?.length||"0")],X);$.push(...H)}if(B&&M.length>0)for(let H=0;HY.children?.some((q)=>Fu(Q,q)))}var my=new WeakMap,Au=({key:Z,route:Y,manifest:Q,mapRouteProperties:X})=>{let q=Q[Y.id];if(K1(q,"No route found in manifest"),!q.lazy||typeof q.lazy!=="object")return;let B=q.lazy[Z];if(!B)return;let $=my.get(q);if(!$)$={},my.set(q,$);let W=$[Z];if(W)return W;let M=(async()=>{let H=Mp(Z),R=q[Z]!==void 0&&Z!=="hasErrorBoundary";if(H)i5(!H,"Route property "+Z+" is not a supported lazy route property. This property will be ignored."),$[Z]=Promise.resolve();else if(R)i5(!1,`Route "${q.id}" has a static property "${Z}" defined. The lazy property will be ignored.`);else{let F=await B();if(F!=null)Object.assign(q,{[Z]:F}),Object.assign(q,X(q))}if(typeof q.lazy==="object"){if(q.lazy[Z]=void 0,Object.values(q.lazy).every((F)=>F===void 0))q.lazy=void 0}})();return $[Z]=M,M},jy=new WeakMap;function ap(Z,Y,Q,X,q){let B=Q[Z.id];if(K1(B,"No route found in manifest"),!Z.lazy)return{lazyRoutePromise:void 0,lazyHandlerPromise:void 0};if(typeof Z.lazy==="function"){let N=jy.get(B);if(N)return{lazyRoutePromise:N,lazyHandlerPromise:N};let R=(async()=>{K1(typeof Z.lazy==="function","No lazy route function found");let F=await Z.lazy(),A={};for(let v in F){let C=F[v];if(C===void 0)continue;let f=Hp(v),L=B[v]!==void 0&&v!=="hasErrorBoundary";if(f)i5(!f,"Route property "+v+" is not a supported property to be returned from a lazy route function. This property will be ignored.");else if(L)i5(!L,`Route "${B.id}" has a static property "${v}" defined but its lazy function is also returning a value for this property. The lazy route property "${v}" will be ignored.`);else A[v]=C}Object.assign(B,A),Object.assign(B,{...X(B),lazy:void 0})})();return jy.set(B,R),R.catch(()=>{}),{lazyRoutePromise:R,lazyHandlerPromise:R}}let $=Object.keys(Z.lazy),W=[],M=void 0;for(let N of $){if(q&&q.includes(N))continue;let R=Au({key:N,route:Z,manifest:Q,mapRouteProperties:X});if(R){if(W.push(R),N===Y)M=R}}let H=W.length>0?Promise.all(W).then(()=>{}):void 0;return H?.catch(()=>{}),M?.catch(()=>{}),{lazyRoutePromise:H,lazyHandlerPromise:M}}async function gy(Z){let Y=Z.matches.filter((q)=>q.shouldLoad),Q={};return(await Promise.all(Y.map((q)=>q.resolve()))).forEach((q,B)=>{Q[Y[B].route.id]=q}),Q}async function ip(Z){if(!Z.matches.some((Y)=>Y.route.middleware))return gy(Z);return _u(Z,()=>gy(Z))}function _u(Z,Y){return op(Z,Y,(X)=>{if(Bl(X))throw X;return X},Ql,Q);function Q(X,q,B){if(B)return Promise.resolve(Object.assign(B.value,{[q]:{type:"error",result:X}}));else{let{matches:$}=Z,W=Math.min(Math.max($.findIndex((H)=>H.route.id===q),0),Math.max($.findIndex((H)=>H.shouldCallHandler()),0)),M=MZ($,$[W].route.id).route.id;return Promise.resolve({[M]:{type:"error",result:X}})}}}async function op(Z,Y,Q,X,q){let{matches:B,request:$,params:W,context:M,unstable_pattern:H}=Z,N=B.flatMap((F)=>F.route.middleware?F.route.middleware.map((A)=>[F.route.id,A]):[]);return await vu({request:$,params:W,context:M,unstable_pattern:H},N,Y,Q,X,q)}async function vu(Z,Y,Q,X,q,B,$=0){let{request:W}=Z;if(W.signal.aborted)throw W.signal.reason??Error(`Request aborted: ${W.method} ${W.url}`);let M=Y[$];if(!M)return await Q();let[H,N]=M,R,F=async()=>{if(R)throw Error("You may only call `next()` once per middleware");try{return R={value:await vu(Z,Y,Q,X,q,B,$+1)},R.value}catch(A){return R={value:await B(A,H,R)},R.value}};try{let A=await N(Z,F),v=A!=null?X(A):void 0;if(q(v))return v;else if(R)return v??R.value;else return R={value:await F()},R.value}catch(A){return await B(A,H,R)}}function Cu(Z,Y,Q,X,q){let B=Au({key:"middleware",route:X.route,manifest:Y,mapRouteProperties:Z}),$=ap(X.route,C7(Q.method)?"action":"loader",Y,Z,q);return{middleware:B,route:$.lazyRoutePromise,handler:$.lazyHandlerPromise}}function RF(Z,Y,Q,X,q,B,$,W,M=null,H){let N=!1,R=Cu(Z,Y,Q,q,B);return{...q,_lazyPromises:R,shouldLoad:W,shouldRevalidateArgs:M,shouldCallHandler(F){if(N=!0,!M)return W;if(typeof H==="boolean")return KB(q,{...M,defaultShouldRevalidate:H});if(typeof F==="boolean")return KB(q,{...M,defaultShouldRevalidate:F});return KB(q,M)},resolve(F){let{lazy:A,loader:v,middleware:C}=q.route,f=N||W||F&&!C7(Q.method)&&(A||v),P=C&&C.length>0&&!v&&!A;if(f&&(C7(Q.method)||!P))return tp({request:Q,unstable_pattern:X,match:q,lazyHandlerPromise:R?.handler,lazyRoutePromise:R?.route,handlerOverride:F,scopedContext:$});return Promise.resolve({type:"data",result:void 0})}}}function tJ(Z,Y,Q,X,q,B,$,W=null){return X.map((M)=>{if(M.route.id!==q.route.id)return{...M,shouldLoad:!1,shouldRevalidateArgs:W,shouldCallHandler:()=>!1,_lazyPromises:Cu(Z,Y,Q,M,B),resolve:()=>Promise.resolve({type:"data",result:void 0})};return RF(Z,Y,Q,RB(X),M,B,$,!0,W)})}async function sp(Z,Y,Q,X,q,B){if(Q.some((H)=>H._lazyPromises?.middleware))await Promise.all(Q.map((H)=>H._lazyPromises?.middleware));let $={request:Y,unstable_pattern:RB(Q),params:Q[0].params,context:q,matches:Q},M=await Z({...$,fetcherKey:X,runClientMiddleware:B?()=>{throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`")}:(H)=>{let N=$;return _u(N,()=>{return H({...N,fetcherKey:X,runClientMiddleware:()=>{throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler")}})})}});try{await Promise.all(Q.flatMap((H)=>[H._lazyPromises?.handler,H._lazyPromises?.route]))}catch(H){}return M}async function tp({request:Z,unstable_pattern:Y,match:Q,lazyHandlerPromise:X,lazyRoutePromise:q,handlerOverride:B,scopedContext:$}){let W,M,H=C7(Z.method),N=H?"action":"loader",R=(F)=>{let A,v=new Promise((P,L)=>A=L);M=()=>A(),Z.signal.addEventListener("abort",M);let C=(P)=>{if(typeof F!=="function")return Promise.reject(Error(`You cannot call the handler for a route which defines a boolean "${N}" [routeId: ${Q.route.id}]`));return F({request:Z,unstable_pattern:Y,params:Q.params,context:$},...P!==void 0?[P]:[])},f=(async()=>{try{return{type:"data",result:await(B?B((L)=>C(L)):C())}}catch(P){return{type:"error",result:P}}})();return Promise.race([f,v])};try{let F=H?Q.route.action:Q.route.loader;if(X||q)if(F){let A,[v]=await Promise.all([R(F).catch((C)=>{A=C}),X,q]);if(A!==void 0)throw A;W=v}else{await X;let A=H?Q.route.action:Q.route.loader;if(A)[W]=await Promise.all([R(A),q]);else if(N==="action"){let v=new URL(Z.url),C=v.pathname+v.search;throw t4(405,{method:Z.method,pathname:C,routeId:Q.route.id})}else return{type:"data",result:void 0}}else if(!F){let A=new URL(Z.url),v=A.pathname+A.search;throw t4(404,{pathname:v})}else W=await R(F)}catch(F){return{type:"error",result:F}}finally{if(M)Z.signal.removeEventListener("abort",M)}return W}async function np(Z){let Y=Z.headers.get("Content-Type");if(Y&&/\bapplication\/json\b/.test(Y))return Z.body==null?null:Z.json();return Z.text()}async function ep(Z){let{result:Y,type:Q}=Z;if(PF(Y)){let X;try{X=await np(Y)}catch(q){return{type:"error",error:q}}if(Q==="error")return{type:"error",error:new eJ(Y.status,Y.statusText,X),statusCode:Y.status,headers:Y.headers};return{type:"data",data:X,statusCode:Y.status,headers:Y.headers}}if(Q==="error"){if(ry(Y)){if(Y.data instanceof Error)return{type:"error",error:Y.data,statusCode:Y.init?.status,headers:Y.init?.headers?new Headers(Y.init.headers):void 0};return{type:"error",error:Jl(Y),statusCode:HZ(Y)?Y.status:void 0,headers:Y.init?.headers?new Headers(Y.init.headers):void 0}}return{type:"error",error:Y,statusCode:HZ(Y)?Y.status:void 0}}if(ry(Y))return{type:"data",data:Y.data,statusCode:Y.init?.status,headers:Y.init?.headers?new Headers(Y.init.headers):void 0};return{type:"data",data:Y}}function Zl(Z,Y,Q,X,q){let B=Z.headers.get("Location");if(K1(B,"Redirects returned/thrown from loaders/actions must have a Location header"),!fK(B)){let $=X.slice(0,X.findIndex((W)=>W.route.id===Q)+1);B=HF(new URL(Y.url),$,q,B),Z.headers.set("Location",B)}return Z}function hy(Z,Y,Q,X){let q=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(fK(Z)){let B=Z,$=B.startsWith("//")?new URL(Y.protocol+B):new URL(B);if(q.includes($.protocol))throw Error("Invalid redirect location");let W=b4($.pathname,Q)!=null;if($.origin===Y.origin&&W)return $.pathname+$.search+$.hash}try{let B=X.createURL(Z);if(q.includes(B.protocol))throw Error("Invalid redirect location")}catch(B){}return Z}function oJ(Z,Y,Q,X){let q=Z.createURL(Lu(Y)).toString(),B={signal:Q};if(X&&C7(X.formMethod)){let{formMethod:$,formEncType:W}=X;if(B.method=$.toUpperCase(),W==="application/json")B.headers=new Headers({"Content-Type":W}),B.body=JSON.stringify(X.json);else if(W==="text/plain")B.body=X.text;else if(W==="application/x-www-form-urlencoded"&&X.formData)B.body=OF(X.formData);else B.body=X.formData}return new Request(q,B)}function OF(Z){let Y=new URLSearchParams;for(let[Q,X]of Z.entries())Y.append(Q,typeof X==="string"?X:X.name);return Y}function cy(Z){let Y=new FormData;for(let[Q,X]of Z.entries())Y.append(Q,X);return Y}function Yl(Z,Y,Q,X=!1,q=!1){let B={},$=null,W,M=!1,H={},N=Q&&P4(Q[1])?Q[1].error:void 0;if(Z.forEach((R)=>{if(!(R.route.id in Y))return;let F=R.route.id,A=Y[F];if(K1(!EY(A),"Cannot handle redirect results in processLoaderData"),P4(A)){let v=A.error;if(N!==void 0)v=N,N=void 0;if($=$||{},q)$[F]=v;else{let C=MZ(Z,F);if($[C.route.id]==null)$[C.route.id]=v}if(!X)B[F]=Ru;if(!M)M=!0,W=HZ(A.error)?A.error.status:500;if(A.headers)H[F]=A.headers}else{if(B[F]=A.data,A.statusCode&&A.statusCode!==200&&!M)W=A.statusCode;if(A.headers)H[F]=A.headers}}),N!==void 0&&Q){if($={[Q[0]]:N},Q[2])B[Q[2]]=void 0}return{loaderData:B,errors:$,statusCode:W||200,loaderHeaders:H}}function dy(Z,Y,Q,X,q,B){let{loaderData:$,errors:W}=Yl(Y,Q,X);return q.filter((M)=>!M.matches||M.matches.some((H)=>H.shouldLoad)).forEach((M)=>{let{key:H,match:N,controller:R}=M;if(R&&R.signal.aborted)return;let F=B[H];if(K1(F,"Did not find corresponding fetcher result"),P4(F)){let A=MZ(Z.matches,N?.route.id);if(!(W&&W[A.route.id]))W={...W,[A.route.id]:F.error};Z.fetchers.delete(H)}else if(EY(F))K1(!1,"Unhandled fetcher revalidation redirect");else{let A=G8(F.data);Z.fetchers.set(H,A)}}),{loaderData:$,errors:W}}function py(Z,Y,Q,X){let q=Object.entries(Y).filter(([,B])=>B!==Ru).reduce((B,[$,W])=>{return B[$]=W,B},{});for(let B of Q){let $=B.route.id;if(!Y.hasOwnProperty($)&&Z.hasOwnProperty($)&&B.route.loader)q[$]=Z[$];if(X&&X.hasOwnProperty($))break}return q}function ly(Z){if(!Z)return{};return P4(Z[1])?{actionData:{}}:{actionData:{[Z[0]]:Z[1].data}}}function MZ(Z,Y){return(Y?Z.slice(0,Z.findIndex((X)=>X.route.id===Y)+1):[...Z]).reverse().find((X)=>X.route.hasErrorBoundary===!0)||Z[0]}function FK(Z){let Y=Z.length===1?Z[0]:Z.find((Q)=>Q.index||!Q.path||Q.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:Y}],route:Y}}function t4(Z,{pathname:Y,routeId:Q,method:X,type:q,message:B}={}){let $="Unknown Server Error",W="Unknown @remix-run/router error";if(Z===400){if($="Bad Request",X&&Y&&Q)W=`You made a ${X} request to "${Y}" but did not provide a \`loader\` for route "${Q}", so there is no way to handle the request.`;else if(q==="invalid-body")W="Unable to encode submission body"}else if(Z===403)$="Forbidden",W=`Route "${Q}" does not match URL "${Y}"`;else if(Z===404)$="Not Found",W=`No route matches URL "${Y}"`;else if(Z===405){if($="Method Not Allowed",X&&Y&&Q)W=`You made a ${X.toUpperCase()} request to "${Y}" but did not provide an \`action\` for route "${Q}", so there is no way to handle the request.`;else if(X)W=`Invalid request method "${X.toUpperCase()}"`}return new eJ(Z||500,$,Error(W),!0)}function AK(Z){let Y=Object.entries(Z);for(let Q=Y.length-1;Q>=0;Q--){let[X,q]=Y[Q];if(EY(q))return{key:X,result:q}}}function Lu(Z){let Y=typeof Z==="string"?F6(Z):Z;return y3({...Y,hash:""})}function wl(Z,Y){if(Z.pathname!==Y.pathname||Z.search!==Y.search)return!1;if(Z.hash==="")return Y.hash!=="";else if(Z.hash===Y.hash)return!0;else if(Y.hash!=="")return!0;return!1}function Jl(Z){return new eJ(Z.init?.status??500,Z.init?.statusText??"Internal Server Error",Z.data)}function Ql(Z){return Z!=null&&typeof Z==="object"&&Object.entries(Z).every(([Y,Q])=>typeof Y==="string"&&Xl(Q))}function Xl(Z){return Z!=null&&typeof Z==="object"&&"type"in Z&&"result"in Z&&(Z.type==="data"||Z.type==="error")}function zl(Z){return PF(Z.result)&&Hu.has(Z.result.status)}function P4(Z){return Z.type==="error"}function EY(Z){return(Z&&Z.type)==="redirect"}function ry(Z){return typeof Z==="object"&&Z!=null&&"type"in Z&&"data"in Z&&"init"in Z&&Z.type==="DataWithResponseInit"}function PF(Z){return Z!=null&&typeof Z.status==="number"&&typeof Z.statusText==="string"&&typeof Z.headers==="object"&&typeof Z.body<"u"}function ql(Z){return Hu.has(Z)}function Bl(Z){return PF(Z)&&ql(Z.status)&&Z.headers.has("Location")}function Ul(Z){return hp.has(Z.toUpperCase())}function C7(Z){return jp.has(Z.toUpperCase())}function bF(Z){return new URLSearchParams(Z).getAll("index").some((Y)=>Y==="")}function LK(Z,Y){let Q=typeof Y==="string"?F6(Y).search:Y.search;if(Z[Z.length-1].route.index&&bF(Q||""))return Z[Z.length-1];let X=$u(Z);return X[X.length-1]}function ay(Z){let{formMethod:Y,formAction:Q,formEncType:X,text:q,formData:B,json:$}=Z;if(!Y||!Q||!X)return;if(q!=null)return{formMethod:Y,formAction:Q,formEncType:X,formData:void 0,json:void 0,text:q};else if(B!=null)return{formMethod:Y,formAction:Q,formEncType:X,formData:B,json:void 0,text:void 0};else if($!==void 0)return{formMethod:Y,formAction:Q,formEncType:X,formData:void 0,json:$,text:void 0}}function WF(Z,Y){if(Y)return{state:"loading",location:Z,formMethod:Y.formMethod,formAction:Y.formAction,formEncType:Y.formEncType,formData:Y.formData,json:Y.json,text:Y.text};else return{state:"loading",location:Z,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function $l(Z,Y){return{state:"submitting",location:Z,formMethod:Y.formMethod,formAction:Y.formAction,formEncType:Y.formEncType,formData:Y.formData,json:Y.json,text:Y.text}}function BB(Z,Y){if(Z)return{state:"loading",formMethod:Z.formMethod,formAction:Z.formAction,formEncType:Z.formEncType,formData:Z.formData,json:Z.json,text:Z.text,data:Y};else return{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:Y}}function Wl(Z,Y){return{state:"submitting",formMethod:Z.formMethod,formAction:Z.formAction,formEncType:Z.formEncType,formData:Z.formData,json:Z.json,text:Z.text,data:Y?Y.data:void 0}}function G8(Z){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:Z}}function Kl(Z,Y){try{let Q=Z.sessionStorage.getItem(Nu);if(Q){let X=JSON.parse(Q);for(let[q,B]of Object.entries(X||{}))if(B&&Array.isArray(B))Y.set(q,new Set(B||[]))}}catch(Q){}}function Ml(Z,Y){if(Y.size>0){let Q={};for(let[X,q]of Y)Q[X]=[...q];try{Z.sessionStorage.setItem(Nu,JSON.stringify(Q))}catch(X){i5(!1,`Failed to save applied view transitions in sessionStorage (${X}).`)}}}function iy(){let Z,Y,Q=new Promise((X,q)=>{Z=async(B)=>{X(B);try{await Q}catch($){}},Y=async(B)=>{q(B);try{await Q}catch($){}}});return{promise:Q,resolve:Z,reject:Y}}var NZ=Q4.createContext(null);NZ.displayName="DataRouter";var IY=Q4.createContext(null);IY.displayName="DataRouterState";var Pu=Q4.createContext(!1);function Gl(){return Q4.useContext(Pu)}var VK=Q4.createContext({isTransitioning:!1});VK.displayName="ViewTransition";var TK=Q4.createContext(new Map);TK.displayName="Fetchers";var Hl=Q4.createContext(null);Hl.displayName="Await";var g7=Q4.createContext(null);g7.displayName="Navigation";var ZQ=Q4.createContext(null);ZQ.displayName="Location";var f4=Q4.createContext({outlet:null,matches:[],isDataRoute:!1});f4.displayName="Route";var fF=Q4.createContext(null);fF.displayName="RouteError";var nJ=!0,bu="REACT_ROUTER_ERROR",Nl="REDIRECT",Rl="ROUTE_ERROR_RESPONSE";function Ol(Z){if(Z.startsWith(`${bu}:${Nl}:{`))try{let Y=JSON.parse(Z.slice(28));if(typeof Y==="object"&&Y&&typeof Y.status==="number"&&typeof Y.statusText==="string"&&typeof Y.location==="string"&&typeof Y.reloadDocument==="boolean"&&typeof Y.replace==="boolean")return Y}catch{}}function Fl(Z){if(Z.startsWith(`${bu}:${Rl}:{`))try{let Y=JSON.parse(Z.slice(40));if(typeof Y==="object"&&Y&&typeof Y.status==="number"&&typeof Y.statusText==="string")return new eJ(Y.status,Y.statusText,Y.data)}catch{}}function fu(Z,{relative:Y}={}){K1(YQ(),"useHref() may be used only in the context of a component.");let{basename:Q,navigator:X}=g0.useContext(g7),{hash:q,pathname:B,search:$}=wQ(Z,{relative:Y}),W=B;if(Q!=="/")W=B==="/"?Q:O6([Q,B]);return X.createHref({pathname:W,search:$,hash:q})}function YQ(){return g0.useContext(ZQ)!=null}function o2(){return K1(YQ(),"useLocation() may be used only in the context of a component."),g0.useContext(ZQ).location}var Vu="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Tu(Z){if(!g0.useContext(g7).static)g0.useLayoutEffect(Z)}function X4(){let{isDataRoute:Z}=g0.useContext(f4);return Z?yl():Al()}function Al(){K1(YQ(),"useNavigate() may be used only in the context of a component.");let Z=g0.useContext(NZ),{basename:Y,navigator:Q}=g0.useContext(g7),{matches:X}=g0.useContext(f4),{pathname:q}=o2(),B=JSON.stringify(_F(X)),$=g0.useRef(!1);return Tu(()=>{$.current=!0}),g0.useCallback((M,H={})=>{if(i5($.current,Vu),!$.current)return;if(typeof M==="number"){Q.go(M);return}let N=vF(M,JSON.parse(B),q,H.relative==="path");if(Z==null&&Y!=="/")N.pathname=N.pathname==="/"?Y:O6([Y,N.pathname]);(H.replace?Q.replace:Q.push)(N,H.state,H)},[Y,Q,B,q,Z])}var _l=g0.createContext(null);function yu(Z){let Y=g0.useContext(f4).outlet;return g0.useMemo(()=>Y&&g0.createElement(_l.Provider,{value:Z},Y),[Y,Z])}function h7(){let{matches:Z}=g0.useContext(f4),Y=Z[Z.length-1];return Y?Y.params:{}}function wQ(Z,{relative:Y}={}){let{matches:Q}=g0.useContext(f4),{pathname:X}=o2(),q=JSON.stringify(_F(Q));return g0.useMemo(()=>vF(Z,JSON.parse(q),X,Y==="path"),[Z,q,X,Y])}function vl(Z,Y,Q,X,q){K1(YQ(),"useRoutes() may be used only in the context of a component.");let{navigator:B}=g0.useContext(g7),{matches:$}=g0.useContext(f4),W=$[$.length-1],M=W?W.params:{},H=W?W.pathname:"/",N=W?W.pathnameBase:"/",R=W&&W.route;if(nJ){let L=R&&R.path||"";Iu(H,!R||L.endsWith("*")||L.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${H}" (under ) 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 to .`)}let F=o2(),A;if(Y){let L=typeof Y==="string"?F6(Y):Y;K1(N==="/"||L.pathname?.startsWith(N),`When overriding the location using \`\` 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 "${N}" but pathname "${L.pathname}" was given in the \`location\` prop.`),A=L}else A=F;let v=A.pathname||"/",C=v;if(N!=="/"){let L=N.replace(/^\//,"").split("/");C="/"+v.replace(/^\//,"").split("/").slice(L.length).join("/")}let f=H8(Z,{pathname:C});if(nJ)i5(R||f!=null,`No routes matched location "${A.pathname}${A.search}${A.hash}" `),i5(f==null||f[f.length-1].route.element!==void 0||f[f.length-1].route.Component!==void 0||f[f.length-1].route.lazy!==void 0,`Matched leaf route at location "${A.pathname}${A.search}${A.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let P=fl(f&&f.map((L)=>Object.assign({},L,{params:Object.assign({},M,L.params),pathname:O6([N,B.encodeLocation?B.encodeLocation(L.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:L.pathname]),pathnameBase:L.pathnameBase==="/"?N:O6([N,B.encodeLocation?B.encodeLocation(L.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:L.pathnameBase])})),$,Q,X,q);if(Y&&P)return g0.createElement(ZQ.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...A},navigationType:"POP"}},P);return P}function Cl(){let Z=Eu(),Y=HZ(Z)?`${Z.status} ${Z.statusText}`:Z instanceof Error?Z.message:JSON.stringify(Z),Q=Z instanceof Error?Z.stack:null,X="rgba(200,200,200, 0.5)",q={padding:"0.5rem",backgroundColor:X},B={padding:"2px 4px",backgroundColor:X},$=null;if(nJ)console.error("Error handled by React Router default ErrorBoundary:",Z),$=g0.createElement(g0.Fragment,null,g0.createElement("p",null,"\uD83D\uDCBF Hey developer \uD83D\uDC4B"),g0.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",g0.createElement("code",{style:B},"ErrorBoundary")," or"," ",g0.createElement("code",{style:B},"errorElement")," prop on your route."));return g0.createElement(g0.Fragment,null,g0.createElement("h2",null,"Unexpected Application Error!"),g0.createElement("h3",{style:{fontStyle:"italic"}},Y),Q?g0.createElement("pre",{style:q},Q):null,$)}var Ll=g0.createElement(Cl,null),uu=class extends g0.Component{constructor(Z){super(Z);this.state={location:Z.location,revalidation:Z.revalidation,error:Z.error}}static getDerivedStateFromError(Z){return{error:Z}}static getDerivedStateFromProps(Z,Y){if(Y.location!==Z.location||Y.revalidation!=="idle"&&Z.revalidation==="idle")return{error:Z.error,location:Z.location,revalidation:Z.revalidation};return{error:Z.error!==void 0?Z.error:Y.error,location:Y.location,revalidation:Z.revalidation||Y.revalidation}}componentDidCatch(Z,Y){if(this.props.onError)this.props.onError(Z,Y);else console.error("React Router caught the following error during render",Z)}render(){let Z=this.state.error;if(this.context&&typeof Z==="object"&&Z&&"digest"in Z&&typeof Z.digest==="string"){let Q=Fl(Z.digest);if(Q)Z=Q}let Y=Z!==void 0?g0.createElement(f4.Provider,{value:this.props.routeContext},g0.createElement(fF.Provider,{value:Z,children:this.props.component})):this.props.children;if(this.context)return g0.createElement(Pl,{error:Z},Y);return Y}};uu.contextType=Pu;var KF=new WeakMap;function Pl({children:Z,error:Y}){let{basename:Q}=g0.useContext(g7);if(typeof Y==="object"&&Y&&"digest"in Y&&typeof Y.digest==="string"){let X=Ol(Y.digest);if(X){let q=KF.get(Y);if(q)throw q;let B=Ku(X.location,Q);if(Wu&&!KF.get(Y))if(B.isExternal||X.reloadDocument)window.location.href=B.absoluteURL||B.to;else{let $=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(B.to,{replace:X.replace}));throw KF.set(Y,$),$}return g0.createElement("meta",{httpEquiv:"refresh",content:`0;url=${B.absoluteURL||B.to}`})}}return Z}function bl({routeContext:Z,match:Y,children:Q}){let X=g0.useContext(NZ);if(X&&X.static&&X.staticContext&&(Y.route.errorElement||Y.route.ErrorBoundary))X.staticContext._deepestRenderedBoundaryId=Y.route.id;return g0.createElement(f4.Provider,{value:Z},Q)}function fl(Z,Y=[],Q=null,X=null,q=null){if(Z==null){if(!Q)return null;if(Q.errors)Z=Q.matches;else if(Y.length===0&&!Q.initialized&&Q.matches.length>0)Z=Q.matches;else return null}let B=Z,$=Q?.errors;if($!=null){let N=B.findIndex((R)=>R.route.id&&$?.[R.route.id]!==void 0);K1(N>=0,`Could not find a matching route for errors on route IDs: ${Object.keys($).join(",")}`),B=B.slice(0,Math.min(B.length,N+1))}let W=!1,M=-1;if(Q)for(let N=0;N=0)B=B.slice(0,M+1);else B=[B[0]];break}}}let H=Q&&X?(N,R)=>{X(N,{location:Q.location,params:Q.matches?.[0]?.params??{},unstable_pattern:RB(Q.matches),errorInfo:R})}:void 0;return B.reduceRight((N,R,F)=>{let A,v=!1,C=null,f=null;if(Q){if(A=$&&R.route.id?$[R.route.id]:void 0,C=R.route.errorElement||Ll,W){if(M<0&&F===0)Iu("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,f=null;else if(M===F)v=!0,f=R.route.hydrateFallbackElement||null}}let P=Y.concat(B.slice(0,F+1)),L=()=>{let b;if(A)b=C;else if(v)b=f;else if(R.route.Component)b=g0.createElement(R.route.Component,null);else if(R.route.element)b=R.route.element;else b=N;return g0.createElement(bl,{match:R,routeContext:{outlet:N,matches:P,isDataRoute:Q!=null},children:b})};return Q&&(R.route.ErrorBoundary||R.route.errorElement||F===0)?g0.createElement(uu,{location:Q.location,revalidation:Q.revalidation,component:C,error:A,children:L(),routeContext:{outlet:null,matches:P,isDataRoute:!0},onError:H}):L()},null)}function VF(Z){return`${Z} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Su(Z){let Y=g0.useContext(NZ);return K1(Y,VF(Z)),Y}function JQ(Z){let Y=g0.useContext(IY);return K1(Y,VF(Z)),Y}function Vl(Z){let Y=g0.useContext(f4);return K1(Y,VF(Z)),Y}function OB(Z){let Y=Vl(Z),Q=Y.matches[Y.matches.length-1];return K1(Q.route.id,`${Z} can only be used on routes that contain a unique "id"`),Q.route.id}function Tl(){return OB("useRouteId")}function xu(){return JQ("useNavigation").navigation}function TF(){let Z=Su("useRevalidator"),Y=JQ("useRevalidator"),Q=g0.useCallback(async()=>{await Z.router.revalidate()},[Z.router]);return g0.useMemo(()=>({revalidate:Q,state:Y.revalidation}),[Q,Y.revalidation])}function FB(){let{matches:Z,loaderData:Y}=JQ("useMatches");return g0.useMemo(()=>Z.map((Q)=>Xu(Q,Y)),[Z,Y])}function yF(){let Z=JQ("useLoaderData"),Y=OB("useLoaderData");return Z.loaderData[Y]}function uF(){let Z=JQ("useActionData"),Y=OB("useLoaderData");return Z.actionData?Z.actionData[Y]:void 0}function Eu(){let Z=g0.useContext(fF),Y=JQ("useRouteError"),Q=OB("useRouteError");if(Z!==void 0)return Z;return Y.errors?.[Q]}function yl(){let{router:Z}=Su("useNavigate"),Y=OB("useNavigate"),Q=g0.useRef(!1);return Tu(()=>{Q.current=!0}),g0.useCallback(async(q,B={})=>{if(i5(Q.current,Vu),!Q.current)return;if(typeof q==="number")await Z.navigate(q);else await Z.navigate(q,{fromRouteId:Y,...B})},[Z,Y])}var oy={};function Iu(Z,Y,Q){if(!Y&&!oy[Z])oy[Z]=!0,i5(!1,Q)}var sy={};function ty(Z,Y){if(!Z&&!sy[Y])sy[Y]=!0,console.warn(Y)}var ul="useOptimistic",ny=X1[ul],Sl=()=>{return};function xl(Z){if(ny)return ny(Z);else return[Z,Sl]}function Du(Z){let Y={hasErrorBoundary:Z.hasErrorBoundary||Z.ErrorBoundary!=null||Z.errorElement!=null};if(Z.Component){if(nJ){if(Z.element)i5(!1,"You should not include both `Component` and `element` on your route - `Component` will be used.")}Object.assign(Y,{element:X1.createElement(Z.Component),Component:void 0})}if(Z.HydrateFallback){if(nJ){if(Z.hydrateFallbackElement)i5(!1,"You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used.")}Object.assign(Y,{hydrateFallbackElement:X1.createElement(Z.HydrateFallback),HydrateFallback:void 0})}if(Z.ErrorBoundary){if(nJ){if(Z.errorElement)i5(!1,"You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used.")}Object.assign(Y,{errorElement:X1.createElement(Z.ErrorBoundary),ErrorBoundary:void 0})}return Y}var ku=["HydrateFallback","hydrateFallbackElement"];var El=class{constructor(){this.status="pending",this.promise=new Promise((Z,Y)=>{this.resolve=(Q)=>{if(this.status==="pending")this.status="resolved",Z(Q)},this.reject=(Q)=>{if(this.status==="pending")this.status="rejected",Y(Q)}})}};function SF({router:Z,flushSync:Y,onError:Q,unstable_useTransitions:X}){X=Gl()||X;let[B,$]=X1.useState(Z.state),[W,M]=xl(B),[H,N]=X1.useState(),[R,F]=X1.useState({isTransitioning:!1}),[A,v]=X1.useState(),[C,f]=X1.useState(),[P,L]=X1.useState(),b=X1.useRef(new Map),u=X1.useCallback((c,{deletedFetchers:Y0,newErrors:k,flushSync:t,viewTransitionOpts:B0})=>{if(k&&Q)Object.values(k).forEach((H0)=>Q(H0,{location:c.location,params:c.matches[0]?.params??{},unstable_pattern:RB(c.matches)}));c.fetchers.forEach((H0,s)=>{if(H0.data!==void 0)b.current.set(s,H0.data)}),Y0.forEach((H0)=>b.current.delete(H0)),ty(t===!1||Y!=null,'You provided the `flushSync` option to a router update, but you are not using the `` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from "react-router/dom"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.');let U0=Z.window!=null&&Z.window.document!=null&&typeof Z.window.document.startViewTransition==="function";if(ty(B0==null||U0,"You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."),!B0||!U0){if(Y&&t)Y(()=>$(c));else if(X===!1)$(c);else X1.startTransition(()=>{if(X===!0)M((H0)=>ey(H0,c));$(c)});return}if(Y&&t){Y(()=>{if(C)A?.resolve(),C.skipTransition();F({isTransitioning:!0,flushSync:!0,currentLocation:B0.currentLocation,nextLocation:B0.nextLocation})});let H0=Z.window.document.startViewTransition(()=>{Y(()=>$(c))});H0.finished.finally(()=>{Y(()=>{v(void 0),f(void 0),N(void 0),F({isTransitioning:!1})})}),Y(()=>f(H0));return}if(C)A?.resolve(),C.skipTransition(),L({state:c,currentLocation:B0.currentLocation,nextLocation:B0.nextLocation});else N(c),F({isTransitioning:!0,flushSync:!1,currentLocation:B0.currentLocation,nextLocation:B0.nextLocation})},[Z.window,Y,C,A,X,M,Q]);X1.useLayoutEffect(()=>Z.subscribe(u),[Z,u]),X1.useEffect(()=>{if(R.isTransitioning&&!R.flushSync)v(new El)},[R]),X1.useEffect(()=>{if(A&&H&&Z.window){let c=H,Y0=A.promise,k=Z.window.document.startViewTransition(async()=>{if(X===!1)$(c);else X1.startTransition(()=>{if(X===!0)M((t)=>ey(t,c));$(c)});await Y0});k.finished.finally(()=>{v(void 0),f(void 0),N(void 0),F({isTransitioning:!1})}),f(k)}},[H,A,Z.window,X,M]),X1.useEffect(()=>{if(A&&H&&W.location.key===H.location.key)A.resolve()},[A,C,W.location,H]),X1.useEffect(()=>{if(!R.isTransitioning&&P)N(P.state),F({isTransitioning:!0,flushSync:!1,currentLocation:P.currentLocation,nextLocation:P.nextLocation}),L(void 0)},[R.isTransitioning,P]);let I=X1.useMemo(()=>{return{createHref:Z.createHref,encodeLocation:Z.encodeLocation,go:(c)=>Z.navigate(c),push:(c,Y0,k)=>Z.navigate(c,{state:Y0,preventScrollReset:k?.preventScrollReset}),replace:(c,Y0,k)=>Z.navigate(c,{replace:!0,state:Y0,preventScrollReset:k?.preventScrollReset})}},[Z]),d=Z.basename||"/",S=X1.useMemo(()=>({router:Z,navigator:I,static:!1,basename:d,onError:Q}),[Z,I,d,Q]);return X1.createElement(X1.Fragment,null,X1.createElement(NZ.Provider,{value:S},X1.createElement(IY.Provider,{value:W},X1.createElement(TK.Provider,{value:b.current},X1.createElement(VK.Provider,{value:R},X1.createElement(xF,{basename:d,location:W.location,navigationType:W.historyAction,navigator:I,unstable_useTransitions:X},X1.createElement(Il,{routes:Z.routes,future:Z.future,state:W,onError:Q})))))),null)}function ey(Z,Y){return{...Z,navigation:Y.navigation.state!=="idle"?Y.navigation:Z.navigation,revalidation:Y.revalidation!=="idle"?Y.revalidation:Z.revalidation,actionData:Y.navigation.state!=="submitting"?Y.actionData:Z.actionData,fetchers:Y.fetchers}}var Il=X1.memo(Dl);function Dl({routes:Z,future:Y,state:Q,onError:X}){return vl(Z,void 0,Q,X,Y)}function u3(Z){return yu(Z.context)}function xF({basename:Z="/",children:Y=null,location:Q,navigationType:X="POP",navigator:q,static:B=!1,unstable_useTransitions:$}){K1(!YQ(),"You cannot render a inside another . You should never have more than one in your app.");let W=Z.replace(/^\/*/,"/"),M=X1.useMemo(()=>({basename:W,navigator:q,static:B,unstable_useTransitions:$,future:{}}),[W,q,B,$]);if(typeof Q==="string")Q=F6(Q);let{pathname:H="/",search:N="",hash:R="",state:F=null,key:A="default"}=Q,v=X1.useMemo(()=>{let C=b4(H,W);if(C==null)return null;return{location:{pathname:C,search:N,hash:R,state:F,key:A},navigationType:X}},[W,H,N,R,F,A,X]);if(i5(v!=null,` is not able to match the URL "${H}${N}${R}" because it does not start with the basename, so the won't render anything.`),v==null)return null;return X1.createElement(g7.Provider,{value:M},X1.createElement(ZQ.Provider,{children:Y,value:v}))}var PK="get",bK="application/x-www-form-urlencoded";function yK(Z){return typeof HTMLElement<"u"&&Z instanceof HTMLElement}function kl(Z){return yK(Z)&&Z.tagName.toLowerCase()==="button"}function ml(Z){return yK(Z)&&Z.tagName.toLowerCase()==="form"}function jl(Z){return yK(Z)&&Z.tagName.toLowerCase()==="input"}function gl(Z){return!!(Z.metaKey||Z.altKey||Z.ctrlKey||Z.shiftKey)}function hl(Z,Y){return Z.button===0&&(!Y||Y==="_self")&&!gl(Z)}var _K=null;function cl(){if(_K===null)try{new FormData(document.createElement("form"),0),_K=!1}catch(Z){_K=!0}return _K}var dl=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function MF(Z){if(Z!=null&&!dl.has(Z))return i5(!1,`"${Z}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${bK}"`),null;return Z}function pl(Z,Y){let Q,X,q,B,$;if(ml(Z)){let W=Z.getAttribute("action");X=W?b4(W,Y):null,Q=Z.getAttribute("method")||PK,q=MF(Z.getAttribute("enctype"))||bK,B=new FormData(Z)}else if(kl(Z)||jl(Z)&&(Z.type==="submit"||Z.type==="image")){let W=Z.form;if(W==null)throw Error('Cannot submit a