Socket
Socket
Sign inDemoInstall

@remix-run/router

Package Overview
Dependencies
Maintainers
2
Versions
216
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@remix-run/router - npm Package Compare versions

Comparing version 1.0.5-pre.1 to 1.0.5-pre.2

7

CHANGELOG.md
# `@remix-run/router`
## 1.0.5-pre.2
### Patch Changes
- Add `requestContext` support to static handler `query`/`queryRoute` ([#9696](https://github.com/remix-run/react-router/pull/9696))
- Note that the unstable API of `queryRoute(path, routeId)` has been changed to `queryRoute(path, { routeId, requestContext })`
## 1.0.5-pre.1

@@ -4,0 +11,0 @@

9

dist/router.d.ts

@@ -239,4 +239,9 @@ import type { History, Location, Path, To } from "./history";

dataRoutes: AgnosticDataRouteObject[];
query(request: Request): Promise<StaticHandlerContext | Response>;
queryRoute(request: Request, routeId?: string): Promise<any>;
query(request: Request, opts?: {
requestContext?: unknown;
}): Promise<StaticHandlerContext | Response>;
queryRoute(request: Request, opts?: {
routeId?: string;
requestContext?: unknown;
}): Promise<any>;
}

@@ -243,0 +248,0 @@ /**

/**
* @remix-run/router v1.0.5-pre.1
* @remix-run/router v1.0.5-pre.2
*

@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc.

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RemixRouter={})}(this,(function(e){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},t.apply(this,arguments)}var r;e.Action=void 0,(r=e.Action||(e.Action={})).Pop="POP",r.Push="PUSH",r.Replace="REPLACE";const a="popstate";function n(e,t){if(!1===e||null==e)throw new Error(t)}function o(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function i(e){return{usr:e.state,key:e.key}}function s(e,r,a,n){return void 0===a&&(a=null),t({pathname:"string"==typeof e?e:e.pathname,search:"",hash:""},"string"==typeof r?d(r):r,{state:a,key:r&&r.key||n||Math.random().toString(36).substr(2,8)})}function l(e){let{pathname:t="/",search:r="",hash:a=""}=e;return r&&"?"!==r&&(t+="?"===r.charAt(0)?r:"?"+r),a&&"#"!==a&&(t+="#"===a.charAt(0)?a:"#"+a),t}function d(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substr(a),e=e.substr(0,a)),e&&(t.pathname=e)}return t}function c(e){let t="undefined"!=typeof window&&void 0!==window.location&&"null"!==window.location.origin?window.location.origin:window.location.href,r="string"==typeof e?e:l(e);return n(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}function u(t,r,n,o){void 0===o&&(o={});let{window:d=document.defaultView,v5Compat:u=!1}=o,h=d.history,f=e.Action.Pop,p=null;function m(){f=e.Action.Pop,p&&p({action:f,location:g.location})}let g={get action(){return f},get location(){return t(d,h)},listen(e){if(p)throw new Error("A history only accepts one active listener");return d.addEventListener(a,m),p=e,()=>{d.removeEventListener(a,m),p=null}},createHref:e=>r(d,e),encodeLocation(e){let t=c("string"==typeof e?e:l(e));return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){f=e.Action.Push;let a=s(g.location,t,r);n&&n(a,t);let o=i(a),l=g.createHref(a);try{h.pushState(o,"",l)}catch(e){d.location.assign(l)}u&&p&&p({action:f,location:g.location})},replace:function(t,r){f=e.Action.Replace;let a=s(g.location,t,r);n&&n(a,t);let o=i(a),l=g.createHref(a);h.replaceState(o,"",l),u&&p&&p({action:f,location:g.location})},go:e=>h.go(e)};return g}let h;function f(e,r,a){return void 0===r&&(r=[]),void 0===a&&(a=new Set),e.map(((e,o)=>{let i=[...r,o],s="string"==typeof e.id?e.id:i.join("-");if(n(!0!==e.index||!e.children,"Cannot specify children on an index route"),n(!a.has(s),'Found a route id collision on id "'+s+"\". Route id's must be globally unique within Data Router usages"),a.add(s),function(e){return!0===e.index}(e)){return t({},e,{id:s})}return t({},e,{id:s,children:e.children?f(e.children,i,a):void 0})}))}function p(e,t,r){void 0===r&&(r="/");let a=E(("string"==typeof t?d(t):t).pathname||"/",r);if(null==a)return null;let n=m(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(n);let o=null;for(let e=0;null==o&&e<n.length;++e)o=w(n[e],D(a));return o}function m(e,t,r,a){return void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===a&&(a=""),e.forEach(((e,o)=>{let i={relativePath:e.path||"",caseSensitive:!0===e.caseSensitive,childrenIndex:o,route:e};i.relativePath.startsWith("/")&&(n(i.relativePath.startsWith(a),'Absolute route path "'+i.relativePath+'" nested under path "'+a+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),i.relativePath=i.relativePath.slice(a.length));let s=M([a,i.relativePath]),l=r.concat(i);e.children&&e.children.length>0&&(n(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+s+'".'),m(e.children,t,l,s)),(null!=e.path||e.index)&&t.push({path:s,score:y(s,e.index),routesMeta:l})})),t}!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(h||(h={}));const g=/^:\w+$/,v=e=>"*"===e;function y(e,t){let r=e.split("/"),a=r.length;return r.some(v)&&(a+=-2),t&&(a+=2),r.filter((e=>!v(e))).reduce(((e,t)=>e+(g.test(t)?3:""===t?1:10)),a)}function w(e,t){let{routesMeta:r}=e,a={},n="/",o=[];for(let e=0;e<r.length;++e){let i=r[e],s=e===r.length-1,l="/"===n?t:t.slice(n.length)||"/",d=b({path:i.relativePath,caseSensitive:i.caseSensitive,end:s},l);if(!d)return null;Object.assign(a,d.params);let c=i.route;o.push({params:a,pathname:M([n,d.pathname]),pathnameBase:x(M([n,d.pathnameBase])),route:c}),"/"!==d.pathnameBase&&(n=M([n,d.pathnameBase]))}return o}function b(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=function(e,t,r){void 0===t&&(t=!1);void 0===r&&(r=!0);R("*"===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 a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,((e,t)=>(a.push(t),"([^\\/]+)")));e.endsWith("*")?(a.push("*"),n+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":""!==e&&"/"!==e&&(n+="(?:(?=\\/|$))");return[new RegExp(n,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce(((e,t,r)=>{if("*"===t){let e=s[r]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(r){return R(!1,'The value for the URL param "'+t+'" will not be decoded because the string "'+e+'" is a malformed URL segment. This is probably due to a bad percent encoding ('+r+")."),e}}(s[r]||"",t),e}),{}),pathname:o,pathnameBase:i,pattern:e}}function D(e){try{return decodeURI(e)}catch(t){return R(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function E(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&"/"!==a?null:e.slice(r)||"/"}function R(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function A(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:n=""}="string"==typeof e?d(e):e,o=r?r.startsWith("/")?r:function(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)})),r.length>1?r.join("/"):"/"}(r,t):t;return{pathname:o,search:L(a),hash:T(n)}}function P(e,t,r,a){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(a)+"]. Please separate it out to the `to."+r+'` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.'}function S(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function C(e,r,a,o){let i;void 0===o&&(o=!1),"string"==typeof e?i=d(e):(i=t({},e),n(!i.pathname||!i.pathname.includes("?"),P("?","pathname","search",i)),n(!i.pathname||!i.pathname.includes("#"),P("#","pathname","hash",i)),n(!i.search||!i.search.includes("#"),P("#","search","hash",i)));let s,l=""===e||""===i.pathname,c=l?"/":i.pathname;if(o||null==c)s=a;else{let e=r.length-1;if(c.startsWith("..")){let t=c.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let u=A(i,s),h=c&&"/"!==c&&c.endsWith("/"),f=(l||"."===c)&&a.endsWith("/");return u.pathname.endsWith("/")||!h&&!f||(u.pathname+="/"),u}const M=e=>e.join("/").replace(/\/\/+/g,"/"),x=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),L=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",T=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class j extends Error{}class U{constructor(e){let t;this.pendingKeys=new Set,this.subscriber=void 0,n(e&&"object"==typeof e&&!Array.isArray(e),"defer() only accepts plain objects"),this.abortPromise=new Promise(((e,r)=>t=r)),this.controller=new AbortController;let r=()=>t(new j("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",r),this.controller.signal.addEventListener("abort",r),this.data=Object.entries(e).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:this.trackPromise(r,a)})}),{})}trackPromise(e,t){if(!(t instanceof Promise))return t;this.pendingKeys.add(e);let r=Promise.race([t,this.abortPromise]).then((t=>this.onSettle(r,e,null,t)),(t=>this.onSettle(r,e,t)));return r.catch((()=>{})),Object.defineProperty(r,"_tracked",{get:()=>!0}),r}onSettle(e,t,r,a){if(this.controller.signal.aborted&&r instanceof j)return this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r);this.pendingKeys.delete(t),this.done&&this.unlistenAbortSignal();const n=this.subscriber;return r?(Object.defineProperty(e,"_error",{get:()=>r}),n&&n(!1),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>a}),n&&n(!1),a)}subscribe(e){this.subscriber=e}cancel(){this.controller.abort(),this.pendingKeys.forEach(((e,t)=>this.pendingKeys.delete(t)));let e=this.subscriber;e&&e(!0)}async resolveData(e){let t=!1;if(!this.done){let r=()=>this.cancel();e.addEventListener("abort",r),t=await new Promise((t=>{this.subscribe((a=>{e.removeEventListener("abort",r),(a||this.done)&&t(a)}))}))}return t}get done(){return 0===this.pendingKeys.size}get unwrappedData(){return n(null!==this.data&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:O(a)})}),{})}}function O(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}class H{constructor(e,t,r,a){void 0===a&&(a=!1),this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function _(e){return e instanceof H}const q=["post","put","patch","delete"],I=new Set(q),k=["get",...q],W=new Set(k),$=new Set([301,302,303,307,308]),N=new Set([307,308]),B={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},F={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},z=!("undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement);function K(e,t,r){void 0===r&&(r=!1);let a="string"==typeof e?e:l(e);if(!t||!function(e){return null!=e&&"formData"in e}(t))return{path:a};if(t.formMethod&&!fe(t.formMethod))return{path:a,error:oe(405,{method:t.formMethod})};if(t.formMethod&&pe(t.formMethod))return{path:a,submission:{formMethod:t.formMethod,formAction:se(a),formEncType:t&&t.formEncType||"application/x-www-form-urlencoded",formData:t.formData}};let n=d(a);try{let e=Z(t.formData);r&&n.search&&ve(n.search)&&e.append("index",""),n.search="?"+e}catch(e){return{path:a,error:oe(400)}}return{path:l(n)}}function Y(e,t){let r=e;if(t){let a=e.findIndex((e=>e.route.id===t));a>=0&&(r=e.slice(0,a))}return r}function J(e,t,r,a,n,o,i,s,l,d){let c=l?Object.values(l)[0]:s?Object.values(s)[0]:null,u=Y(t,l?Object.keys(l)[0]:void 0).filter(((t,i)=>null!=t.route.loader&&(function(e,t,r){let a=!t||r.route.id!==t.route.id,n=void 0===e[r.route.id];return a||n}(e.loaderData,e.matches[i],t)||o.some((e=>e===t.route.id))||V(e.location,e.matches[i],r,a,t,n,c)))),h=[];return d&&d.forEach(((e,t)=>{let[a,o,s]=e;if(i.includes(t))h.push([t,a,o,s]);else if(n){V(a,o,r,a,o,n,c)&&h.push([t,a,o,s])}})),[u,h]}function G(e,t){let r=e.route.path;return e.pathname!==t.pathname||r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function V(e,r,a,n,o,i,s){let l=c(e),d=r.params,u=c(n),h=o.params,f=G(r,o)||l.toString()===u.toString()||l.search!==u.search||i;if(o.route.shouldRevalidate){let e=o.route.shouldRevalidate(t({currentUrl:l,currentParams:d,nextUrl:u,nextParams:h},a,{actionResult:s,defaultShouldRevalidate:f}));if("boolean"==typeof e)return e}return f}async function X(e,t,r,a,o,i,s){let d,c,u;void 0===o&&(o="/"),void 0===i&&(i=!1),void 0===s&&(s=!1);let f=new Promise(((e,t)=>u=t)),p=()=>u();t.signal.addEventListener("abort",p);try{let a=r.route[e];n(a,"Could not find the "+e+' to run on the "'+r.route.id+'" route'),c=await Promise.race([a({request:t,params:r.params}),f]),n(void 0!==c,"You defined "+("action"===e?"an action":"a loader")+' for route "'+r.route.id+"\" but didn't return anything from your `"+e+"` function. Please return a value or `null`.")}catch(e){d=h.error,c=e}finally{t.signal.removeEventListener("abort",p)}if(ue(c)){let e,u=c.status;if($.has(u)){let e=c.headers.get("Location");if(n(e,"Redirects returned/thrown from loaders/actions must have a Location header"),!(/^[a-z+]+:\/\//i.test(e)||e.startsWith("//"))){let i=C(e,S(a.slice(0,a.indexOf(r)+1)).map((e=>e.pathnameBase)),new URL(t.url).pathname);if(n(l(i),"Unable to resolve redirect location: "+e),o){let e=i.pathname;i.pathname="/"===e?o:M([o,e])}e=l(i)}if(i)throw c.headers.set("Location",e),c;return{type:h.redirect,status:u,location:e,revalidate:null!==c.headers.get("X-Remix-Revalidate")}}if(s)throw{type:d||h.data,response:c};let f=c.headers.get("Content-Type");return e=f&&f.startsWith("application/json")?await c.json():await c.text(),d===h.error?{type:d,error:new H(u,c.statusText,e),headers:c.headers}:{type:h.data,data:e,statusCode:c.status,headers:c.headers}}return d===h.error?{type:d,error:c}:c instanceof U?{type:h.deferred,deferredData:c}:{type:h.data,data:c}}function Q(e,t,r){let a=c(se(e)).toString(),n={signal:t};if(r){let{formMethod:e,formEncType:t,formData:a}=r;n.method=e.toUpperCase(),n.body="application/x-www-form-urlencoded"===t?Z(a):a}return new Request(a,n)}function Z(e){let t=new URLSearchParams;for(let[r,a]of e.entries())n("string"==typeof a,'File inputs are not supported with encType "application/x-www-form-urlencoded", please use "multipart/form-data" instead.'),t.append(r,a);return t}function ee(e,t,r,a,o){let i,s={},l=null,d=!1,c={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(n(!ce(r),"Cannot handle redirect results in processLoaderData"),de(r)){let t=ae(e,h),n=r.error;a&&(n=Object.values(a)[0],a=void 0),l=Object.assign(l||{},{[t.route.id]:n}),d||(d=!0,i=_(r.error)?r.error.status:500),r.headers&&(c[h]=r.headers)}else le(r)?(o&&o.set(h,r.deferredData),s[h]=r.deferredData.data):(s[h]=r.data,null==r.statusCode||200===r.statusCode||d||(i=r.statusCode),r.headers&&(c[h]=r.headers))})),a&&(l=a),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:c}}function te(e,r,a,o,i,s,l,d){let{loaderData:c,errors:u}=ee(r,a,o,i,d);for(let r=0;r<s.length;r++){let[a,,o]=s[r];n(void 0!==l&&void 0!==l[r],"Did not find corresponding fetcher result");let i=l[r];if(de(i)){let r=ae(e.matches,o.route.id);u&&u[r.route.id]||(u=t({},u,{[r.route.id]:i.error})),e.fetchers.delete(a)}else{if(ce(i))throw new Error("Unhandled fetcher revalidation redirect");if(le(i))throw new Error("Unhandled fetcher deferred data");{let t={state:"idle",data:i.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};e.fetchers.set(a,t)}}}return{loaderData:c,errors:u}}function re(e,r,a){let n=t({},r);return a.forEach((t=>{let a=t.route.id;void 0===r[a]&&void 0!==e[a]&&(n[a]=e[a])})),n}function ae(e,t){return(t?e.slice(0,e.findIndex((e=>e.route.id===t))+1):[...e]).reverse().find((e=>!0===e.route.hasErrorBoundary))||e[0]}function ne(e){let t=e.find((e=>e.index||!e.path||"/"===e.path))||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function oe(e,t){let{pathname:r,routeId:a,method:n,message:o}=void 0===t?{}:t,i="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(i="Bad Request",s=n&&r&&a?"You made a "+n+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"Cannot submit binary form data using GET"):403===e?(i="Forbidden",s='Route "'+a+'" does not match URL "'+r+'"'):404===e?(i="Not Found",s='No route matches URL "'+r+'"'):405===e&&(i="Method Not Allowed",n&&r&&a?s="You made a "+n.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':n&&(s='Invalid request method "'+n.toUpperCase()+'"')),new H(e||500,i,new Error(s),!0)}function ie(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(ce(r))return r}}function se(e){return l(t({},"string"==typeof e?d(e):e,{hash:""}))}function le(e){return e.type===h.deferred}function de(e){return e.type===h.error}function ce(e){return(e&&e.type)===h.redirect}function ue(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function he(e){if(!ue(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}function fe(e){return W.has(e)}function pe(e){return I.has(e)}async function me(e,t,r,a,n,o){for(let i=0;i<r.length;i++){let s=r[i],l=t[i],d=e.find((e=>e.route.id===l.route.id)),c=null!=d&&!G(d,l)&&void 0!==(o&&o[l.route.id]);le(s)&&(n||c)&&await ge(s,a,n).then((e=>{e&&(r[i]=e||r[i])}))}}async function ge(e,t,r){if(void 0===r&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:h.data,data:e.deferredData.unwrappedData}}catch(e){return{type:h.error,error:e}}return{type:h.data,data:e.deferredData.data}}}function ve(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function ye(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],handle:r.handle}}function we(e,t){let r="string"==typeof t?d(t).search:t.search;if(e[e.length-1].route.index&&ve(r||""))return e[e.length-1];let a=S(e);return a[a.length-1]}e.AbortedDeferredError=j,e.ErrorResponse=H,e.IDLE_FETCHER=F,e.IDLE_NAVIGATION=B,e.UNSAFE_convertRoutesToDataRoutes=f,e.UNSAFE_getPathContributingMatches=S,e.createBrowserHistory=function(e){return void 0===e&&(e={}),u((function(e,t){let{pathname:r,search:a,hash:n}=e.location;return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"==typeof t?t:l(t)}),null,e)},e.createHashHistory=function(e){return void 0===e&&(e={}),u((function(e,t){let{pathname:r="/",search:a="",hash:n=""}=d(e.location.hash.substr(1));return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){let r=e.document.querySelector("base"),a="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");a=-1===r?t:t.slice(0,r)}return a+"#"+("string"==typeof t?t:l(t))}),(function(e,t){o("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")}),e)},e.createMemoryHistory=function(t){void 0===t&&(t={});let r,{initialEntries:a=["/"],initialIndex:n,v5Compat:i=!1}=t;r=a.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let c=f(null==n?r.length-1:n),u=e.Action.Pop,h=null;function f(e){return Math.min(Math.max(e,0),r.length-1)}function p(){return r[c]}function m(e,t,a){void 0===t&&(t=null);let n=s(r?p().pathname:"/",e,t,a);return o("/"===n.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),n}return{get index(){return c},get action(){return u},get location(){return p()},createHref:e=>"string"==typeof e?e:l(e),encodeLocation(e){let t="string"==typeof e?d(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(t,a){u=e.Action.Push;let n=m(t,a);c+=1,r.splice(c,r.length,n),i&&h&&h({action:u,location:n})},replace(t,a){u=e.Action.Replace;let n=m(t,a);r[c]=n,i&&h&&h({action:u,location:n})},go(t){u=e.Action.Pop,c=f(c+t),h&&h({action:u,location:p()})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(r){n(r.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=f(r.routes),o=null,i=new Set,l=null,d=null,u=null,m=!1,g=p(a,r.history.location,r.basename),v=null;if(null==g){let e=oe(404,{pathname:r.history.location.pathname}),{matches:t,route:n}=ne(a);g=t,v={[n.id]:e}}let y,w,b=!g.some((e=>e.route.loader))||null!=r.hydrationData,D={historyAction:r.history.action,location:r.history.location,matches:g,initialized:b,navigation:B,restoreScrollPosition:null,preventScrollReset:!1,revalidation:"idle",loaderData:r.hydrationData&&r.hydrationData.loaderData||{},actionData:r.hydrationData&&r.hydrationData.actionData||null,errors:r.hydrationData&&r.hydrationData.errors||v,fetchers:new Map},E=e.Action.Pop,R=!1,A=!1,P=!1,S=[],C=[],M=new Map,x=0,L=-1,T=new Map,j=new Set,U=new Map,O=new Map;function H(e){D=t({},D,e),i.forEach((e=>e(D)))}function _(a,n){var o;H(t({},null!=D.actionData&&null!=D.navigation.formMethod&&"loading"===D.navigation.state&&(null==(o=D.navigation.formAction)?void 0:o.split("?")[0])===a.pathname?{}:{actionData:null},n,n.loaderData?{loaderData:re(D.loaderData,n.loaderData,n.matches||[])}:{},{historyAction:E,location:a,initialized:!0,navigation:B,revalidation:"idle",restoreScrollPosition:!D.navigation.formData&&ue(a,n.matches||D.matches),preventScrollReset:R})),A||E===e.Action.Pop||(E===e.Action.Push?r.history.push(a,a.state):E===e.Action.Replace&&r.history.replace(a,a.state)),E=e.Action.Pop,R=!1,A=!1,P=!1,S=[],C=[]}async function q(o,i,s){w&&w.abort(),w=null,E=o,A=!0===(s&&s.startUninterruptedRevalidation),function(e,t){if(l&&d&&u){let r=t.map((e=>ye(e,D.loaderData))),a=d(e,r)||e.key;l[a]=u()}}(D.location,D.matches),R=!0===(s&&s.preventScrollReset);let c=s&&s.overrideNavigation,f=p(a,i,r.basename);if(!f){let e=oe(404,{pathname:i.pathname}),{matches:t,route:r}=ne(a);return se(),void _(i,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(m=D.location,g=i,m.pathname===g.pathname&&m.search===g.search&&m.hash!==g.hash)return void _(i,{matches:f});var m,g;w=new AbortController;let v,b,T=Q(i,w.signal,s&&s.submission);if(s&&s.pendingError)b={[ae(f).route.id]:s.pendingError};else if(s&&s.submission){let r=await async function(r,a,n,o,i){let s;$(),H({navigation:t({state:"submitting",location:a},n)});let l=we(o,a);if(l.route.action){if(s=await X("action",r,l,o,y.basename),r.signal.aborted)return{shortCircuited:!0}}else s={type:h.error,error:oe(405,{method:r.method,pathname:a.pathname,routeId:l.route.id})};if(ce(s))return await k(D,s,i&&!0===i.replace),{shortCircuited:!0};if(de(s)){let t=ae(o,l.route.id);return!0!==(i&&i.replace)&&(E=e.Action.Push),{pendingActionError:{[t.route.id]:s.error}}}if(le(s))throw new Error("defer() is not supported in actions");return{pendingActionData:{[l.route.id]:s.data}}}(T,i,s.submission,f,{replace:s.replace});if(r.shortCircuited)return;v=r.pendingActionData,b=r.pendingActionError,c=t({state:"loading",location:i},s.submission),T=new Request(T.url,{signal:T.signal})}let{shortCircuited:q,loaderData:I,errors:N}=await async function(e,r,a,o,i,s,l,d){let c=o;if(!c){c={state:"loading",location:r,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0}}let[u,h]=J(D,a,i,r,P,S,C,l,d,U);if(se((e=>!(a&&a.some((t=>t.route.id===e)))||u&&u.some((t=>t.route.id===e)))),0===u.length&&0===h.length)return _(r,{matches:a,loaderData:re(D.loaderData,{},a),errors:d||null,actionData:l||null}),{shortCircuited:!0};A||(h.forEach((e=>{let[t]=e,r=D.fetchers.get(t),a={state:"loading",data:r&&r.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(t,a)})),H(t({navigation:c,actionData:l||D.actionData||null},h.length>0?{fetchers:new Map(D.fetchers)}:{})));L=++x,h.forEach((e=>{let[t]=e;return M.set(t,w)}));let{results:f,loaderResults:p,fetcherResults:m}=await W(D.matches,a,u,h,e);if(e.signal.aborted)return{shortCircuited:!0};h.forEach((e=>{let[t]=e;return M.delete(t)}));let g=ie(f);if(g)return await k(D,g,s),{shortCircuited:!0};let{loaderData:v,errors:y}=te(D,a,u,p,d,h,m,O);O.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&O.delete(t)}))})),function(){let e=[];for(let t of j){let r=D.fetchers.get(t);n(r,"Expected fetcher: "+t),"loading"===r.state&&(j.delete(t),e.push(t))}Z(e)}();let b=ee(L);return t({loaderData:v,errors:y},b||h.length>0?{fetchers:new Map(D.fetchers)}:{})}(T,i,f,c,s&&s.submission,s&&s.replace,v,b);q||(w=null,_(i,{matches:f,loaderData:I,errors:N}))}function I(e){return D.fetchers.get(e)||F}async function k(t,r,a){var o;r.revalidate&&(P=!0);let i=s(t.location,r.location);if(n(i,"Expected a location on the redirect navigation"),void 0!==(null==(o=window)?void 0:o.location)){let e=c(r.location).origin;if(window.location.origin!==e)return void(a?window.location.replace(r.location):window.location.assign(r.location))}w=null;let l=!0===a?e.Action.Replace:e.Action.Push,{formMethod:d,formAction:u,formEncType:h,formData:f}=t.navigation;N.has(r.status)&&d&&pe(d)&&h&&f?await q(l,i,{submission:{formMethod:d,formAction:r.location,formEncType:h,formData:f}}):await q(l,i,{overrideNavigation:{state:"loading",location:i,formMethod:d||void 0,formAction:u||void 0,formEncType:h||void 0,formData:f||void 0}})}async function W(e,t,r,a,n){let o=await Promise.all([...r.map((e=>X("loader",n,e,t,y.basename))),...a.map((e=>{let[,t,r,a]=e;return X("loader",Q(t,n.signal),r,a,y.basename)}))]),i=o.slice(0,r.length),s=o.slice(r.length);return await Promise.all([me(e,r,i,n.signal,!1,D.loaderData),me(e,a.map((e=>{let[,,t]=e;return t})),s,n.signal,!0)]),{results:o,loaderResults:i,fetcherResults:s}}function $(){P=!0,S.push(...se()),U.forEach(((e,t)=>{M.has(t)&&(C.push(t),V(t))}))}function Y(e,t,r){let a=ae(D.matches,t);G(e),H({errors:{[a.route.id]:r},fetchers:new Map(D.fetchers)})}function G(e){M.has(e)&&V(e),U.delete(e),T.delete(e),j.delete(e),D.fetchers.delete(e)}function V(e){let t=M.get(e);n(t,"Expected fetch controller: "+e),t.abort(),M.delete(e)}function Z(e){for(let t of e){let e={state:"idle",data:I(t).data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(t,e)}}function ee(e){let t=[];for(let[r,a]of T)if(a<e){let e=D.fetchers.get(r);n(e,"Expected fetcher: "+r),"loading"===e.state&&(V(r),T.delete(r),t.push(r))}return Z(t),t.length>0}function se(e){let t=[];return O.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),O.delete(a))})),t}function ue(e,t){if(l&&d&&u){let r=t.map((e=>ye(e,D.loaderData))),a=d(e,r)||e.key,n=l[a];if("number"==typeof n)return n}return null}return y={get basename(){return r.basename},get state(){return D},get routes(){return a},initialize:function(){return o=r.history.listen((e=>{let{action:t,location:r}=e;return q(t,r)})),D.initialized||q(e.Action.Pop,D.location),y},subscribe:function(e){return i.add(e),()=>i.delete(e)},enableScrollRestoration:function(e,t,r){if(l=e,u=t,d=r||(e=>e.key),!m&&D.navigation===B){m=!0;let e=ue(D.location,D.matches);null!=e&&H({restoreScrollPosition:e})}return()=>{l=null,u=null,d=null}},navigate:async function(a,n){if("number"==typeof a)return void r.history.go(a);let{path:o,submission:i,error:l}=K(a,n),d=s(D.location,o,n&&n.state);d=t({},d,r.history.encodeLocation(d));let c=!0===(n&&n.replace)||null!=i?e.Action.Replace:e.Action.Push,u=n&&"preventScrollReset"in n?!0===n.preventScrollReset:void 0;return await q(c,d,{submission:i,pendingError:l,preventScrollReset:u,replace:n&&n.replace})},fetch:function(e,o,i,s){if(z)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");M.has(e)&&V(e);let l=p(a,i,r.basename);if(!l)return void Y(e,o,oe(404,{pathname:i}));let{path:d,submission:c}=K(i,s,!0),u=we(l,d);c?async function(e,o,i,s,l,d){if($(),U.delete(e),!s.route.action){let t=oe(405,{method:d.formMethod,pathname:i,routeId:o});return void Y(e,o,t)}let c=D.fetchers.get(e),u=t({state:"submitting"},d,{data:c&&c.data});D.fetchers.set(e,u),H({fetchers:new Map(D.fetchers)});let h=new AbortController,f=Q(i,h.signal,d);M.set(e,h);let m=await X("action",f,s,l,y.basename);if(f.signal.aborted)return void(M.get(e)===h&&M.delete(e));if(ce(m)){M.delete(e),j.add(e);let r=t({state:"loading"},d,{data:void 0});return D.fetchers.set(e,r),H({fetchers:new Map(D.fetchers)}),k(D,m)}if(de(m))return void Y(e,o,m.error);le(m)&&n(!1,"defer() is not supported in actions");let g=D.navigation.location||D.location,v=Q(g,h.signal),b="idle"!==D.navigation.state?p(a,D.navigation.location,r.basename):D.matches;n(b,"Didn't find any matches after fetcher action");let R=++x;T.set(e,R);let A=t({state:"loading",data:m.data},d);D.fetchers.set(e,A);let[q,I]=J(D,b,d,g,P,S,C,{[s.route.id]:m.data},void 0,U);I.filter((t=>{let[r]=t;return r!==e})).forEach((e=>{let[t]=e,r=D.fetchers.get(t),a={state:"loading",data:r&&r.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(t,a),M.set(t,h)})),H({fetchers:new Map(D.fetchers)});let{results:N,loaderResults:B,fetcherResults:F}=await W(D.matches,b,q,I,v);if(h.signal.aborted)return;T.delete(e),M.delete(e),I.forEach((e=>{let[t]=e;return M.delete(t)}));let z=ie(N);if(z)return k(D,z);let{loaderData:K,errors:G}=te(D,D.matches,q,B,void 0,I,F,O),V={state:"idle",data:m.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(e,V);let Z=ee(R);"loading"===D.navigation.state&&R>L?(n(E,"Expected pending action"),w&&w.abort(),_(D.navigation.location,{matches:b,loaderData:K,errors:G,fetchers:new Map(D.fetchers)})):(H(t({errors:G,loaderData:re(D.loaderData,K,b)},Z?{fetchers:new Map(D.fetchers)}:{})),P=!1)}(e,o,d,u,l,c):(U.set(e,[d,u,l]),async function(e,t,r,a,o){let i=D.fetchers.get(e),s={state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,data:i&&i.data};D.fetchers.set(e,s),H({fetchers:new Map(D.fetchers)});let l=new AbortController,d=Q(r,l.signal);M.set(e,l);let c=await X("loader",d,a,o,y.basename);le(c)&&(c=await ge(c,d.signal,!0)||c);M.get(e)===l&&M.delete(e);if(d.signal.aborted)return;if(ce(c))return void await k(D,c);if(de(c)){let r=ae(D.matches,t);return D.fetchers.delete(e),void H({fetchers:new Map(D.fetchers),errors:{[r.route.id]:c.error}})}n(!le(c),"Unhandled fetcher deferred data");let u={state:"idle",data:c.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(e,u),H({fetchers:new Map(D.fetchers)})}(e,o,d,u,l))},revalidate:function(){$(),H({revalidation:"loading"}),"submitting"!==D.navigation.state&&("idle"!==D.navigation.state?q(E||D.historyAction,D.navigation.location,{overrideNavigation:D.navigation}):q(D.historyAction,D.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:I,deleteFetcher:G,dispose:function(){o&&o(),i.clear(),w&&w.abort(),D.fetchers.forEach(((e,t)=>G(t)))},_internalFetchControllers:M,_internalActiveDeferreds:O},y},e.defer=function(e){return new U(e)},e.generatePath=function(e,t){return void 0===t&&(t={}),e.replace(/:(\w+)/g,((e,r)=>(n(null!=t[r],'Missing ":'+r+'" param'),t[r]))).replace(/(\/?)\*/,((e,r,a,n)=>null==t["*"]?"/*"===n?"/":"":""+r+t["*"]))},e.getStaticContextFromError=function(e,r,a){return t({},r,{statusCode:500,errors:{[r._deepestRenderedBoundaryId||e[0].id]:a}})},e.getToPathname=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?d(e).pathname:e.pathname},e.invariant=n,e.isRouteErrorResponse=_,e.joinPaths=M,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,n=new Headers(a.headers);return n.has("Content-Type")||n.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:n}))},e.matchPath=b,e.matchRoutes=p,e.normalizePathname=x,e.parsePath=d,e.redirect=function(e,r){void 0===r&&(r=302);let a=r;"number"==typeof a?a={status:a}:void 0===a.status&&(a.status=302);let n=new Headers(a.headers);return n.set("Location",e),new Response(null,t({},a,{headers:n}))},e.resolvePath=A,e.resolveTo=C,e.stripBasename=E,e.unstable_createStaticHandler=function(e,r){n(e.length>0,"You must provide a non-empty routes array to unstable_createStaticHandler");let a=f(e),o=(r?r.basename:null)||"/";async function i(e,r,a,i){n(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(pe(e.method.toLowerCase())){let n=await async function(e,r,a,n){let i;if(a.route.action){if(i=await X("action",e,a,r,o,!0,n),e.signal.aborted){throw new Error((n?"queryRoute":"query")+"() call aborted")}}else{let t=oe(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:a.route.id});if(n)throw t;i={type:h.error,error:t}}if(ce(i))throw new Response(null,{status:i.status,headers:{Location:i.location}});if(le(i))throw new Error("defer() is not supported in actions");if(n){if(de(i))throw i.error;return{matches:[a],loaderData:{},actionData:{[a.route.id]:i.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(de(i)){let n=ae(r,a.route.id);return t({},await d(e,r,void 0,{[n.route.id]:i.error}),{statusCode:_(i.error)?i.error.status:500,actionData:null,actionHeaders:t({},i.headers?{[a.route.id]:i.headers}:{})})}let s=new Request(e.url,{signal:e.signal});return t({},await d(s,r),i.statusCode?{statusCode:i.statusCode}:{},{actionData:{[a.route.id]:i.data},actionHeaders:t({},i.headers?{[a.route.id]:i.headers}:{})})}(e,a,i||we(a,r),null!=i);return n}let n=await d(e,a,i);return ue(n)?n:t({},n,{actionData:null,actionHeaders:{}})}catch(e){if((s=e)&&ue(s.response)&&(s.type===h.data||h.error)){if(e.type===h.error&&!he(e.response))throw e.response;return e.response}if(he(e))return e;throw e}var s}async function d(e,r,a,n){let i=null!=a;if(i&&(null==a||!a.route.loader))throw oe(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==a?void 0:a.route.id});let s=(a?[a]:Y(r,Object.keys(n||{})[0])).filter((e=>e.route.loader));if(0===s.length)return{matches:r,loaderData:{},errors:n||null,statusCode:200,loaderHeaders:{}};let l=await Promise.all([...s.map((t=>X("loader",e,t,r,o,!0,i)))]);if(e.signal.aborted){throw new Error((i?"queryRoute":"query")+"() call aborted")}return l.forEach((e=>{le(e)&&e.deferredData.cancel()})),t({},ee(r,s,l,n),{matches:r})}return{dataRoutes:a,query:async function(e){let r=new URL(e.url),n=e.method.toLowerCase(),d=s("",l(r),null,"default"),c=p(a,d,o);if(!fe(n)&&"head"!==n){let e=oe(405,{method:n}),{matches:t,route:r}=ne(a);return{basename:o,location:d,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{}}}if(!c){let e=oe(404,{pathname:d.pathname}),{matches:t,route:r}=ne(a);return{basename:o,location:d,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{}}}let u=await i(e,d,c);return ue(u)?u:t({location:d,basename:o},u)},queryRoute:async function(e,t){let r=new URL(e.url),n=e.method.toLowerCase(),d=s("",l(r),null,"default"),c=p(a,d,o);if(!fe(n)&&"head"!==n)throw oe(405,{method:n});if(!c)throw oe(404,{pathname:d.pathname});let u=t?c.find((e=>e.route.id===t)):we(c,d);if(t&&!u)throw oe(403,{pathname:d.pathname,routeId:t});if(!u)throw oe(404,{pathname:d.pathname});let h=await i(e,d,c,u);if(ue(h))return h;let f=h.errors?Object.values(h.errors)[0]:void 0;if(void 0!==f)throw f;let m=[h.actionData,h.loaderData].find((e=>e));return Object.values(m||{})[0]}}},e.warning=R,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RemixRouter={})}(this,(function(e){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},t.apply(this,arguments)}var r;e.Action=void 0,(r=e.Action||(e.Action={})).Pop="POP",r.Push="PUSH",r.Replace="REPLACE";const a="popstate";function n(e,t){if(!1===e||null==e)throw new Error(t)}function o(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function i(e){return{usr:e.state,key:e.key}}function s(e,r,a,n){return void 0===a&&(a=null),t({pathname:"string"==typeof e?e:e.pathname,search:"",hash:""},"string"==typeof r?d(r):r,{state:a,key:r&&r.key||n||Math.random().toString(36).substr(2,8)})}function l(e){let{pathname:t="/",search:r="",hash:a=""}=e;return r&&"?"!==r&&(t+="?"===r.charAt(0)?r:"?"+r),a&&"#"!==a&&(t+="#"===a.charAt(0)?a:"#"+a),t}function d(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substr(a),e=e.substr(0,a)),e&&(t.pathname=e)}return t}function c(e){let t="undefined"!=typeof window&&void 0!==window.location&&"null"!==window.location.origin?window.location.origin:window.location.href,r="string"==typeof e?e:l(e);return n(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}function u(t,r,n,o){void 0===o&&(o={});let{window:d=document.defaultView,v5Compat:u=!1}=o,h=d.history,f=e.Action.Pop,p=null;function m(){f=e.Action.Pop,p&&p({action:f,location:g.location})}let g={get action(){return f},get location(){return t(d,h)},listen(e){if(p)throw new Error("A history only accepts one active listener");return d.addEventListener(a,m),p=e,()=>{d.removeEventListener(a,m),p=null}},createHref:e=>r(d,e),encodeLocation(e){let t=c("string"==typeof e?e:l(e));return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){f=e.Action.Push;let a=s(g.location,t,r);n&&n(a,t);let o=i(a),l=g.createHref(a);try{h.pushState(o,"",l)}catch(e){d.location.assign(l)}u&&p&&p({action:f,location:g.location})},replace:function(t,r){f=e.Action.Replace;let a=s(g.location,t,r);n&&n(a,t);let o=i(a),l=g.createHref(a);h.replaceState(o,"",l),u&&p&&p({action:f,location:g.location})},go:e=>h.go(e)};return g}let h;function f(e,r,a){return void 0===r&&(r=[]),void 0===a&&(a=new Set),e.map(((e,o)=>{let i=[...r,o],s="string"==typeof e.id?e.id:i.join("-");if(n(!0!==e.index||!e.children,"Cannot specify children on an index route"),n(!a.has(s),'Found a route id collision on id "'+s+"\". Route id's must be globally unique within Data Router usages"),a.add(s),function(e){return!0===e.index}(e)){return t({},e,{id:s})}return t({},e,{id:s,children:e.children?f(e.children,i,a):void 0})}))}function p(e,t,r){void 0===r&&(r="/");let a=E(("string"==typeof t?d(t):t).pathname||"/",r);if(null==a)return null;let n=m(e);!function(e){e.sort(((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){return e.length===t.length&&e.slice(0,-1).every(((e,r)=>e===t[r]))?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map((e=>e.childrenIndex)),t.routesMeta.map((e=>e.childrenIndex)))))}(n);let o=null;for(let e=0;null==o&&e<n.length;++e)o=w(n[e],D(a));return o}function m(e,t,r,a){return void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===a&&(a=""),e.forEach(((e,o)=>{let i={relativePath:e.path||"",caseSensitive:!0===e.caseSensitive,childrenIndex:o,route:e};i.relativePath.startsWith("/")&&(n(i.relativePath.startsWith(a),'Absolute route path "'+i.relativePath+'" nested under path "'+a+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),i.relativePath=i.relativePath.slice(a.length));let s=M([a,i.relativePath]),l=r.concat(i);e.children&&e.children.length>0&&(n(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+s+'".'),m(e.children,t,l,s)),(null!=e.path||e.index)&&t.push({path:s,score:y(s,e.index),routesMeta:l})})),t}!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(h||(h={}));const g=/^:\w+$/,v=e=>"*"===e;function y(e,t){let r=e.split("/"),a=r.length;return r.some(v)&&(a+=-2),t&&(a+=2),r.filter((e=>!v(e))).reduce(((e,t)=>e+(g.test(t)?3:""===t?1:10)),a)}function w(e,t){let{routesMeta:r}=e,a={},n="/",o=[];for(let e=0;e<r.length;++e){let i=r[e],s=e===r.length-1,l="/"===n?t:t.slice(n.length)||"/",d=b({path:i.relativePath,caseSensitive:i.caseSensitive,end:s},l);if(!d)return null;Object.assign(a,d.params);let c=i.route;o.push({params:a,pathname:M([n,d.pathname]),pathnameBase:x(M([n,d.pathnameBase])),route:c}),"/"!==d.pathnameBase&&(n=M([n,d.pathnameBase]))}return o}function b(e,t){"string"==typeof e&&(e={path:e,caseSensitive:!1,end:!0});let[r,a]=function(e,t,r){void 0===t&&(t=!1);void 0===r&&(r=!0);R("*"===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 a=[],n="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/:(\w+)/g,((e,t)=>(a.push(t),"([^\\/]+)")));e.endsWith("*")?(a.push("*"),n+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":""!==e&&"/"!==e&&(n+="(?:(?=\\/|$))");return[new RegExp(n,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let o=n[0],i=o.replace(/(.)\/+$/,"$1"),s=n.slice(1);return{params:a.reduce(((e,t,r)=>{if("*"===t){let e=s[r]||"";i=o.slice(0,o.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(r){return R(!1,'The value for the URL param "'+t+'" will not be decoded because the string "'+e+'" is a malformed URL segment. This is probably due to a bad percent encoding ('+r+")."),e}}(s[r]||"",t),e}),{}),pathname:o,pathnameBase:i,pattern:e}}function D(e){try{return decodeURI(e)}catch(t){return R(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function E(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&"/"!==a?null:e.slice(r)||"/"}function R(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function A(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:n=""}="string"==typeof e?d(e):e,o=r?r.startsWith("/")?r:function(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach((e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)})),r.length>1?r.join("/"):"/"}(r,t):t;return{pathname:o,search:L(a),hash:T(n)}}function P(e,t,r,a){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(a)+"]. Please separate it out to the `to."+r+'` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.'}function C(e){return e.filter(((e,t)=>0===t||e.route.path&&e.route.path.length>0))}function S(e,r,a,o){let i;void 0===o&&(o=!1),"string"==typeof e?i=d(e):(i=t({},e),n(!i.pathname||!i.pathname.includes("?"),P("?","pathname","search",i)),n(!i.pathname||!i.pathname.includes("#"),P("#","pathname","hash",i)),n(!i.search||!i.search.includes("#"),P("#","search","hash",i)));let s,l=""===e||""===i.pathname,c=l?"/":i.pathname;if(o||null==c)s=a;else{let e=r.length-1;if(c.startsWith("..")){let t=c.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let u=A(i,s),h=c&&"/"!==c&&c.endsWith("/"),f=(l||"."===c)&&a.endsWith("/");return u.pathname.endsWith("/")||!h&&!f||(u.pathname+="/"),u}const M=e=>e.join("/").replace(/\/\/+/g,"/"),x=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),L=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",T=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class j extends Error{}class U{constructor(e){let t;this.pendingKeys=new Set,this.subscriber=void 0,n(e&&"object"==typeof e&&!Array.isArray(e),"defer() only accepts plain objects"),this.abortPromise=new Promise(((e,r)=>t=r)),this.controller=new AbortController;let r=()=>t(new j("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",r),this.controller.signal.addEventListener("abort",r),this.data=Object.entries(e).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:this.trackPromise(r,a)})}),{})}trackPromise(e,t){if(!(t instanceof Promise))return t;this.pendingKeys.add(e);let r=Promise.race([t,this.abortPromise]).then((t=>this.onSettle(r,e,null,t)),(t=>this.onSettle(r,e,t)));return r.catch((()=>{})),Object.defineProperty(r,"_tracked",{get:()=>!0}),r}onSettle(e,t,r,a){if(this.controller.signal.aborted&&r instanceof j)return this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r);this.pendingKeys.delete(t),this.done&&this.unlistenAbortSignal();const n=this.subscriber;return r?(Object.defineProperty(e,"_error",{get:()=>r}),n&&n(!1),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>a}),n&&n(!1),a)}subscribe(e){this.subscriber=e}cancel(){this.controller.abort(),this.pendingKeys.forEach(((e,t)=>this.pendingKeys.delete(t)));let e=this.subscriber;e&&e(!0)}async resolveData(e){let t=!1;if(!this.done){let r=()=>this.cancel();e.addEventListener("abort",r),t=await new Promise((t=>{this.subscribe((a=>{e.removeEventListener("abort",r),(a||this.done)&&t(a)}))}))}return t}get done(){return 0===this.pendingKeys.size}get unwrappedData(){return n(null!==this.data&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:O(a)})}),{})}}function O(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}class H{constructor(e,t,r,a){void 0===a&&(a=!1),this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function q(e){return e instanceof H}const _=["post","put","patch","delete"],I=new Set(_),k=["get",..._],W=new Set(k),$=new Set([301,302,303,307,308]),N=new Set([307,308]),B={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},F={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},z=!("undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement);function K(e,t,r){void 0===r&&(r=!1);let a="string"==typeof e?e:l(e);if(!t||!function(e){return null!=e&&"formData"in e}(t))return{path:a};if(t.formMethod&&!fe(t.formMethod))return{path:a,error:oe(405,{method:t.formMethod})};if(t.formMethod&&pe(t.formMethod))return{path:a,submission:{formMethod:t.formMethod,formAction:se(a),formEncType:t&&t.formEncType||"application/x-www-form-urlencoded",formData:t.formData}};let n=d(a);try{let e=Z(t.formData);r&&n.search&&ve(n.search)&&e.append("index",""),n.search="?"+e}catch(e){return{path:a,error:oe(400)}}return{path:l(n)}}function Y(e,t){let r=e;if(t){let a=e.findIndex((e=>e.route.id===t));a>=0&&(r=e.slice(0,a))}return r}function J(e,t,r,a,n,o,i,s,l,d){let c=l?Object.values(l)[0]:s?Object.values(s)[0]:null,u=Y(t,l?Object.keys(l)[0]:void 0).filter(((t,i)=>null!=t.route.loader&&(function(e,t,r){let a=!t||r.route.id!==t.route.id,n=void 0===e[r.route.id];return a||n}(e.loaderData,e.matches[i],t)||o.some((e=>e===t.route.id))||V(e.location,e.matches[i],r,a,t,n,c)))),h=[];return d&&d.forEach(((e,t)=>{let[a,o,s]=e;if(i.includes(t))h.push([t,a,o,s]);else if(n){V(a,o,r,a,o,n,c)&&h.push([t,a,o,s])}})),[u,h]}function G(e,t){let r=e.route.path;return e.pathname!==t.pathname||r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function V(e,r,a,n,o,i,s){let l=c(e),d=r.params,u=c(n),h=o.params,f=G(r,o)||l.toString()===u.toString()||l.search!==u.search||i;if(o.route.shouldRevalidate){let e=o.route.shouldRevalidate(t({currentUrl:l,currentParams:d,nextUrl:u,nextParams:h},a,{actionResult:s,defaultShouldRevalidate:f}));if("boolean"==typeof e)return e}return f}async function X(e,t,r,a,o,i,s,d){let c,u,f;void 0===o&&(o="/"),void 0===i&&(i=!1),void 0===s&&(s=!1);let p=new Promise(((e,t)=>f=t)),m=()=>f();t.signal.addEventListener("abort",m);try{let a=r.route[e];n(a,"Could not find the "+e+' to run on the "'+r.route.id+'" route'),u=await Promise.race([a({request:t,params:r.params,context:d}),p]),n(void 0!==u,"You defined "+("action"===e?"an action":"a loader")+' for route "'+r.route.id+"\" but didn't return anything from your `"+e+"` function. Please return a value or `null`.")}catch(e){c=h.error,u=e}finally{t.signal.removeEventListener("abort",m)}if(ue(u)){let e,d=u.status;if($.has(d)){let e=u.headers.get("Location");if(n(e,"Redirects returned/thrown from loaders/actions must have a Location header"),!(/^[a-z+]+:\/\//i.test(e)||e.startsWith("//"))){let i=S(e,C(a.slice(0,a.indexOf(r)+1)).map((e=>e.pathnameBase)),new URL(t.url).pathname);if(n(l(i),"Unable to resolve redirect location: "+e),o){let e=i.pathname;i.pathname="/"===e?o:M([o,e])}e=l(i)}if(i)throw u.headers.set("Location",e),u;return{type:h.redirect,status:d,location:e,revalidate:null!==u.headers.get("X-Remix-Revalidate")}}if(s)throw{type:c||h.data,response:u};let f=u.headers.get("Content-Type");return e=f&&f.startsWith("application/json")?await u.json():await u.text(),c===h.error?{type:c,error:new H(d,u.statusText,e),headers:u.headers}:{type:h.data,data:e,statusCode:u.status,headers:u.headers}}return c===h.error?{type:c,error:u}:u instanceof U?{type:h.deferred,deferredData:u}:{type:h.data,data:u}}function Q(e,t,r){let a=c(se(e)).toString(),n={signal:t};if(r){let{formMethod:e,formEncType:t,formData:a}=r;n.method=e.toUpperCase(),n.body="application/x-www-form-urlencoded"===t?Z(a):a}return new Request(a,n)}function Z(e){let t=new URLSearchParams;for(let[r,a]of e.entries())n("string"==typeof a,'File inputs are not supported with encType "application/x-www-form-urlencoded", please use "multipart/form-data" instead.'),t.append(r,a);return t}function ee(e,t,r,a,o){let i,s={},l=null,d=!1,c={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(n(!ce(r),"Cannot handle redirect results in processLoaderData"),de(r)){let t=ae(e,h),n=r.error;a&&(n=Object.values(a)[0],a=void 0),l=Object.assign(l||{},{[t.route.id]:n}),d||(d=!0,i=q(r.error)?r.error.status:500),r.headers&&(c[h]=r.headers)}else le(r)?(o&&o.set(h,r.deferredData),s[h]=r.deferredData.data):(s[h]=r.data,null==r.statusCode||200===r.statusCode||d||(i=r.statusCode),r.headers&&(c[h]=r.headers))})),a&&(l=a),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:c}}function te(e,r,a,o,i,s,l,d){let{loaderData:c,errors:u}=ee(r,a,o,i,d);for(let r=0;r<s.length;r++){let[a,,o]=s[r];n(void 0!==l&&void 0!==l[r],"Did not find corresponding fetcher result");let i=l[r];if(de(i)){let r=ae(e.matches,o.route.id);u&&u[r.route.id]||(u=t({},u,{[r.route.id]:i.error})),e.fetchers.delete(a)}else{if(ce(i))throw new Error("Unhandled fetcher revalidation redirect");if(le(i))throw new Error("Unhandled fetcher deferred data");{let t={state:"idle",data:i.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};e.fetchers.set(a,t)}}}return{loaderData:c,errors:u}}function re(e,r,a){let n=t({},r);return a.forEach((t=>{let a=t.route.id;void 0===r[a]&&void 0!==e[a]&&(n[a]=e[a])})),n}function ae(e,t){return(t?e.slice(0,e.findIndex((e=>e.route.id===t))+1):[...e]).reverse().find((e=>!0===e.route.hasErrorBoundary))||e[0]}function ne(e){let t=e.find((e=>e.index||!e.path||"/"===e.path))||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function oe(e,t){let{pathname:r,routeId:a,method:n}=void 0===t?{}:t,o="Unknown Server Error",i="Unknown @remix-run/router error";return 400===e?(o="Bad Request",i=n&&r&&a?"You made a "+n+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"Cannot submit binary form data using GET"):403===e?(o="Forbidden",i='Route "'+a+'" does not match URL "'+r+'"'):404===e?(o="Not Found",i='No route matches URL "'+r+'"'):405===e&&(o="Method Not Allowed",n&&r&&a?i="You made a "+n.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':n&&(i='Invalid request method "'+n.toUpperCase()+'"')),new H(e||500,o,new Error(i),!0)}function ie(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(ce(r))return r}}function se(e){return l(t({},"string"==typeof e?d(e):e,{hash:""}))}function le(e){return e.type===h.deferred}function de(e){return e.type===h.error}function ce(e){return(e&&e.type)===h.redirect}function ue(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function he(e){if(!ue(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}function fe(e){return W.has(e)}function pe(e){return I.has(e)}async function me(e,t,r,a,n,o){for(let i=0;i<r.length;i++){let s=r[i],l=t[i],d=e.find((e=>e.route.id===l.route.id)),c=null!=d&&!G(d,l)&&void 0!==(o&&o[l.route.id]);le(s)&&(n||c)&&await ge(s,a,n).then((e=>{e&&(r[i]=e||r[i])}))}}async function ge(e,t,r){if(void 0===r&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:h.data,data:e.deferredData.unwrappedData}}catch(e){return{type:h.error,error:e}}return{type:h.data,data:e.deferredData.data}}}function ve(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function ye(e,t){let{route:r,pathname:a,params:n}=e;return{id:r.id,pathname:a,params:n,data:t[r.id],handle:r.handle}}function we(e,t){let r="string"==typeof t?d(t).search:t.search;if(e[e.length-1].route.index&&ve(r||""))return e[e.length-1];let a=C(e);return a[a.length-1]}e.AbortedDeferredError=j,e.ErrorResponse=H,e.IDLE_FETCHER=F,e.IDLE_NAVIGATION=B,e.UNSAFE_convertRoutesToDataRoutes=f,e.UNSAFE_getPathContributingMatches=C,e.createBrowserHistory=function(e){return void 0===e&&(e={}),u((function(e,t){let{pathname:r,search:a,hash:n}=e.location;return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){return"string"==typeof t?t:l(t)}),null,e)},e.createHashHistory=function(e){return void 0===e&&(e={}),u((function(e,t){let{pathname:r="/",search:a="",hash:n=""}=d(e.location.hash.substr(1));return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")}),(function(e,t){let r=e.document.querySelector("base"),a="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");a=-1===r?t:t.slice(0,r)}return a+"#"+("string"==typeof t?t:l(t))}),(function(e,t){o("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")}),e)},e.createMemoryHistory=function(t){void 0===t&&(t={});let r,{initialEntries:a=["/"],initialIndex:n,v5Compat:i=!1}=t;r=a.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let c=f(null==n?r.length-1:n),u=e.Action.Pop,h=null;function f(e){return Math.min(Math.max(e,0),r.length-1)}function p(){return r[c]}function m(e,t,a){void 0===t&&(t=null);let n=s(r?p().pathname:"/",e,t,a);return o("/"===n.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),n}return{get index(){return c},get action(){return u},get location(){return p()},createHref:e=>"string"==typeof e?e:l(e),encodeLocation(e){let t="string"==typeof e?d(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(t,a){u=e.Action.Push;let n=m(t,a);c+=1,r.splice(c,r.length,n),i&&h&&h({action:u,location:n})},replace(t,a){u=e.Action.Replace;let n=m(t,a);r[c]=n,i&&h&&h({action:u,location:n})},go(t){u=e.Action.Pop,c=f(c+t),h&&h({action:u,location:p()})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(r){n(r.routes.length>0,"You must provide a non-empty routes array to createRouter");let a=f(r.routes),o=null,i=new Set,l=null,d=null,u=null,m=!1,g=p(a,r.history.location,r.basename),v=null;if(null==g){let e=oe(404,{pathname:r.history.location.pathname}),{matches:t,route:n}=ne(a);g=t,v={[n.id]:e}}let y,w,b=!g.some((e=>e.route.loader))||null!=r.hydrationData,D={historyAction:r.history.action,location:r.history.location,matches:g,initialized:b,navigation:B,restoreScrollPosition:null,preventScrollReset:!1,revalidation:"idle",loaderData:r.hydrationData&&r.hydrationData.loaderData||{},actionData:r.hydrationData&&r.hydrationData.actionData||null,errors:r.hydrationData&&r.hydrationData.errors||v,fetchers:new Map},E=e.Action.Pop,R=!1,A=!1,P=!1,C=[],S=[],M=new Map,x=0,L=-1,T=new Map,j=new Set,U=new Map,O=new Map;function H(e){D=t({},D,e),i.forEach((e=>e(D)))}function q(a,n){var o;H(t({},null!=D.actionData&&null!=D.navigation.formMethod&&"loading"===D.navigation.state&&(null==(o=D.navigation.formAction)?void 0:o.split("?")[0])===a.pathname?{}:{actionData:null},n,n.loaderData?{loaderData:re(D.loaderData,n.loaderData,n.matches||[])}:{},{historyAction:E,location:a,initialized:!0,navigation:B,revalidation:"idle",restoreScrollPosition:!D.navigation.formData&&ue(a,n.matches||D.matches),preventScrollReset:R})),A||E===e.Action.Pop||(E===e.Action.Push?r.history.push(a,a.state):E===e.Action.Replace&&r.history.replace(a,a.state)),E=e.Action.Pop,R=!1,A=!1,P=!1,C=[],S=[]}async function _(o,i,s){w&&w.abort(),w=null,E=o,A=!0===(s&&s.startUninterruptedRevalidation),function(e,t){if(l&&d&&u){let r=t.map((e=>ye(e,D.loaderData))),a=d(e,r)||e.key;l[a]=u()}}(D.location,D.matches),R=!0===(s&&s.preventScrollReset);let c=s&&s.overrideNavigation,f=p(a,i,r.basename);if(!f){let e=oe(404,{pathname:i.pathname}),{matches:t,route:r}=ne(a);return se(),void q(i,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(m=D.location,g=i,m.pathname===g.pathname&&m.search===g.search&&m.hash!==g.hash)return void q(i,{matches:f});var m,g;w=new AbortController;let v,b,T=Q(i,w.signal,s&&s.submission);if(s&&s.pendingError)b={[ae(f).route.id]:s.pendingError};else if(s&&s.submission){let r=await async function(r,a,n,o,i){let s;$(),H({navigation:t({state:"submitting",location:a},n)});let l=we(o,a);if(l.route.action){if(s=await X("action",r,l,o,y.basename),r.signal.aborted)return{shortCircuited:!0}}else s={type:h.error,error:oe(405,{method:r.method,pathname:a.pathname,routeId:l.route.id})};if(ce(s))return await k(D,s,i&&!0===i.replace),{shortCircuited:!0};if(de(s)){let t=ae(o,l.route.id);return!0!==(i&&i.replace)&&(E=e.Action.Push),{pendingActionError:{[t.route.id]:s.error}}}if(le(s))throw new Error("defer() is not supported in actions");return{pendingActionData:{[l.route.id]:s.data}}}(T,i,s.submission,f,{replace:s.replace});if(r.shortCircuited)return;v=r.pendingActionData,b=r.pendingActionError,c=t({state:"loading",location:i},s.submission),T=new Request(T.url,{signal:T.signal})}let{shortCircuited:_,loaderData:I,errors:N}=await async function(e,r,a,o,i,s,l,d){let c=o;if(!c){c={state:"loading",location:r,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0}}let[u,h]=J(D,a,i,r,P,C,S,l,d,U);if(se((e=>!(a&&a.some((t=>t.route.id===e)))||u&&u.some((t=>t.route.id===e)))),0===u.length&&0===h.length)return q(r,{matches:a,loaderData:re(D.loaderData,{},a),errors:d||null,actionData:l||null}),{shortCircuited:!0};A||(h.forEach((e=>{let[t]=e,r=D.fetchers.get(t),a={state:"loading",data:r&&r.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(t,a)})),H(t({navigation:c,actionData:l||D.actionData||null},h.length>0?{fetchers:new Map(D.fetchers)}:{})));L=++x,h.forEach((e=>{let[t]=e;return M.set(t,w)}));let{results:f,loaderResults:p,fetcherResults:m}=await W(D.matches,a,u,h,e);if(e.signal.aborted)return{shortCircuited:!0};h.forEach((e=>{let[t]=e;return M.delete(t)}));let g=ie(f);if(g)return await k(D,g,s),{shortCircuited:!0};let{loaderData:v,errors:y}=te(D,a,u,p,d,h,m,O);O.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&O.delete(t)}))})),function(){let e=[];for(let t of j){let r=D.fetchers.get(t);n(r,"Expected fetcher: "+t),"loading"===r.state&&(j.delete(t),e.push(t))}Z(e)}();let b=ee(L);return t({loaderData:v,errors:y},b||h.length>0?{fetchers:new Map(D.fetchers)}:{})}(T,i,f,c,s&&s.submission,s&&s.replace,v,b);_||(w=null,q(i,{matches:f,loaderData:I,errors:N}))}function I(e){return D.fetchers.get(e)||F}async function k(t,r,a){var o;r.revalidate&&(P=!0);let i=s(t.location,r.location);if(n(i,"Expected a location on the redirect navigation"),void 0!==(null==(o=window)?void 0:o.location)){let e=c(r.location).origin;if(window.location.origin!==e)return void(a?window.location.replace(r.location):window.location.assign(r.location))}w=null;let l=!0===a?e.Action.Replace:e.Action.Push,{formMethod:d,formAction:u,formEncType:h,formData:f}=t.navigation;N.has(r.status)&&d&&pe(d)&&h&&f?await _(l,i,{submission:{formMethod:d,formAction:r.location,formEncType:h,formData:f}}):await _(l,i,{overrideNavigation:{state:"loading",location:i,formMethod:d||void 0,formAction:u||void 0,formEncType:h||void 0,formData:f||void 0}})}async function W(e,t,r,a,n){let o=await Promise.all([...r.map((e=>X("loader",n,e,t,y.basename))),...a.map((e=>{let[,t,r,a]=e;return X("loader",Q(t,n.signal),r,a,y.basename)}))]),i=o.slice(0,r.length),s=o.slice(r.length);return await Promise.all([me(e,r,i,n.signal,!1,D.loaderData),me(e,a.map((e=>{let[,,t]=e;return t})),s,n.signal,!0)]),{results:o,loaderResults:i,fetcherResults:s}}function $(){P=!0,C.push(...se()),U.forEach(((e,t)=>{M.has(t)&&(S.push(t),V(t))}))}function Y(e,t,r){let a=ae(D.matches,t);G(e),H({errors:{[a.route.id]:r},fetchers:new Map(D.fetchers)})}function G(e){M.has(e)&&V(e),U.delete(e),T.delete(e),j.delete(e),D.fetchers.delete(e)}function V(e){let t=M.get(e);n(t,"Expected fetch controller: "+e),t.abort(),M.delete(e)}function Z(e){for(let t of e){let e={state:"idle",data:I(t).data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(t,e)}}function ee(e){let t=[];for(let[r,a]of T)if(a<e){let e=D.fetchers.get(r);n(e,"Expected fetcher: "+r),"loading"===e.state&&(V(r),T.delete(r),t.push(r))}return Z(t),t.length>0}function se(e){let t=[];return O.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),O.delete(a))})),t}function ue(e,t){if(l&&d&&u){let r=t.map((e=>ye(e,D.loaderData))),a=d(e,r)||e.key,n=l[a];if("number"==typeof n)return n}return null}return y={get basename(){return r.basename},get state(){return D},get routes(){return a},initialize:function(){return o=r.history.listen((e=>{let{action:t,location:r}=e;return _(t,r)})),D.initialized||_(e.Action.Pop,D.location),y},subscribe:function(e){return i.add(e),()=>i.delete(e)},enableScrollRestoration:function(e,t,r){if(l=e,u=t,d=r||(e=>e.key),!m&&D.navigation===B){m=!0;let e=ue(D.location,D.matches);null!=e&&H({restoreScrollPosition:e})}return()=>{l=null,u=null,d=null}},navigate:async function(a,n){if("number"==typeof a)return void r.history.go(a);let{path:o,submission:i,error:l}=K(a,n),d=s(D.location,o,n&&n.state);d=t({},d,r.history.encodeLocation(d));let c=!0===(n&&n.replace)||null!=i?e.Action.Replace:e.Action.Push,u=n&&"preventScrollReset"in n?!0===n.preventScrollReset:void 0;return await _(c,d,{submission:i,pendingError:l,preventScrollReset:u,replace:n&&n.replace})},fetch:function(e,o,i,s){if(z)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");M.has(e)&&V(e);let l=p(a,i,r.basename);if(!l)return void Y(e,o,oe(404,{pathname:i}));let{path:d,submission:c}=K(i,s,!0),u=we(l,d);c?async function(e,o,i,s,l,d){if($(),U.delete(e),!s.route.action){let t=oe(405,{method:d.formMethod,pathname:i,routeId:o});return void Y(e,o,t)}let c=D.fetchers.get(e),u=t({state:"submitting"},d,{data:c&&c.data});D.fetchers.set(e,u),H({fetchers:new Map(D.fetchers)});let h=new AbortController,f=Q(i,h.signal,d);M.set(e,h);let m=await X("action",f,s,l,y.basename);if(f.signal.aborted)return void(M.get(e)===h&&M.delete(e));if(ce(m)){M.delete(e),j.add(e);let r=t({state:"loading"},d,{data:void 0});return D.fetchers.set(e,r),H({fetchers:new Map(D.fetchers)}),k(D,m)}if(de(m))return void Y(e,o,m.error);le(m)&&n(!1,"defer() is not supported in actions");let g=D.navigation.location||D.location,v=Q(g,h.signal),b="idle"!==D.navigation.state?p(a,D.navigation.location,r.basename):D.matches;n(b,"Didn't find any matches after fetcher action");let R=++x;T.set(e,R);let A=t({state:"loading",data:m.data},d);D.fetchers.set(e,A);let[_,I]=J(D,b,d,g,P,C,S,{[s.route.id]:m.data},void 0,U);I.filter((t=>{let[r]=t;return r!==e})).forEach((e=>{let[t]=e,r=D.fetchers.get(t),a={state:"loading",data:r&&r.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(t,a),M.set(t,h)})),H({fetchers:new Map(D.fetchers)});let{results:N,loaderResults:B,fetcherResults:F}=await W(D.matches,b,_,I,v);if(h.signal.aborted)return;T.delete(e),M.delete(e),I.forEach((e=>{let[t]=e;return M.delete(t)}));let z=ie(N);if(z)return k(D,z);let{loaderData:K,errors:G}=te(D,D.matches,_,B,void 0,I,F,O),V={state:"idle",data:m.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(e,V);let Z=ee(R);"loading"===D.navigation.state&&R>L?(n(E,"Expected pending action"),w&&w.abort(),q(D.navigation.location,{matches:b,loaderData:K,errors:G,fetchers:new Map(D.fetchers)})):(H(t({errors:G,loaderData:re(D.loaderData,K,b)},Z?{fetchers:new Map(D.fetchers)}:{})),P=!1)}(e,o,d,u,l,c):(U.set(e,[d,u,l]),async function(e,t,r,a,o){let i=D.fetchers.get(e),s={state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,data:i&&i.data};D.fetchers.set(e,s),H({fetchers:new Map(D.fetchers)});let l=new AbortController,d=Q(r,l.signal);M.set(e,l);let c=await X("loader",d,a,o,y.basename);le(c)&&(c=await ge(c,d.signal,!0)||c);M.get(e)===l&&M.delete(e);if(d.signal.aborted)return;if(ce(c))return void await k(D,c);if(de(c)){let r=ae(D.matches,t);return D.fetchers.delete(e),void H({fetchers:new Map(D.fetchers),errors:{[r.route.id]:c.error}})}n(!le(c),"Unhandled fetcher deferred data");let u={state:"idle",data:c.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0};D.fetchers.set(e,u),H({fetchers:new Map(D.fetchers)})}(e,o,d,u,l))},revalidate:function(){$(),H({revalidation:"loading"}),"submitting"!==D.navigation.state&&("idle"!==D.navigation.state?_(E||D.historyAction,D.navigation.location,{overrideNavigation:D.navigation}):_(D.historyAction,D.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:I,deleteFetcher:G,dispose:function(){o&&o(),i.clear(),w&&w.abort(),D.fetchers.forEach(((e,t)=>G(t)))},_internalFetchControllers:M,_internalActiveDeferreds:O},y},e.defer=function(e){return new U(e)},e.generatePath=function(e,t){return void 0===t&&(t={}),e.replace(/:(\w+)/g,((e,r)=>(n(null!=t[r],'Missing ":'+r+'" param'),t[r]))).replace(/(\/?)\*/,((e,r,a,n)=>null==t["*"]?"/*"===n?"/":"":""+r+t["*"]))},e.getStaticContextFromError=function(e,r,a){return t({},r,{statusCode:500,errors:{[r._deepestRenderedBoundaryId||e[0].id]:a}})},e.getToPathname=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?d(e).pathname:e.pathname},e.invariant=n,e.isRouteErrorResponse=q,e.joinPaths=M,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,n=new Headers(a.headers);return n.has("Content-Type")||n.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:n}))},e.matchPath=b,e.matchRoutes=p,e.normalizePathname=x,e.parsePath=d,e.redirect=function(e,r){void 0===r&&(r=302);let a=r;"number"==typeof a?a={status:a}:void 0===a.status&&(a.status=302);let n=new Headers(a.headers);return n.set("Location",e),new Response(null,t({},a,{headers:n}))},e.resolvePath=A,e.resolveTo=S,e.stripBasename=E,e.unstable_createStaticHandler=function(e,r){n(e.length>0,"You must provide a non-empty routes array to unstable_createStaticHandler");let a=f(e),o=(r?r.basename:null)||"/";async function i(e,r,a,i,s){n(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(pe(e.method.toLowerCase())){let n=await async function(e,r,a,n,i){let s;if(a.route.action){if(s=await X("action",e,a,r,o,!0,i,n),e.signal.aborted){throw new Error((i?"queryRoute":"query")+"() call aborted")}}else{let t=oe(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:a.route.id});if(i)throw t;s={type:h.error,error:t}}if(ce(s))throw new Response(null,{status:s.status,headers:{Location:s.location}});if(le(s))throw new Error("defer() is not supported in actions");if(i){if(de(s))throw s.error;return{matches:[a],loaderData:{},actionData:{[a.route.id]:s.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{}}}if(de(s)){let o=ae(r,a.route.id);return t({},await d(e,r,n,void 0,{[o.route.id]:s.error}),{statusCode:q(s.error)?s.error.status:500,actionData:null,actionHeaders:t({},s.headers?{[a.route.id]:s.headers}:{})})}let l=new Request(e.url,{signal:e.signal});return t({},await d(l,r,n),s.statusCode?{statusCode:s.statusCode}:{},{actionData:{[a.route.id]:s.data},actionHeaders:t({},s.headers?{[a.route.id]:s.headers}:{})})}(e,a,s||we(a,r),i,null!=s);return n}let n=await d(e,a,i,s);return ue(n)?n:t({},n,{actionData:null,actionHeaders:{}})}catch(e){if((l=e)&&ue(l.response)&&(l.type===h.data||h.error)){if(e.type===h.error&&!he(e.response))throw e.response;return e.response}if(he(e))return e;throw e}var l}async function d(e,r,a,n,i){let s=null!=n;if(s&&(null==n||!n.route.loader))throw oe(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==n?void 0:n.route.id});let l=(n?[n]:Y(r,Object.keys(i||{})[0])).filter((e=>e.route.loader));if(0===l.length)return{matches:r,loaderData:{},errors:i||null,statusCode:200,loaderHeaders:{}};let d=await Promise.all([...l.map((t=>X("loader",e,t,r,o,!0,s,a)))]);if(e.signal.aborted){throw new Error((s?"queryRoute":"query")+"() call aborted")}return d.forEach((e=>{le(e)&&e.deferredData.cancel()})),t({},ee(r,l,d,i),{matches:r})}return{dataRoutes:a,query:async function(e,r){let{requestContext:n}=void 0===r?{}:r,d=new URL(e.url),c=e.method.toLowerCase(),u=s("",l(d),null,"default"),h=p(a,u,o);if(!fe(c)&&"head"!==c){let e=oe(405,{method:c}),{matches:t,route:r}=ne(a);return{basename:o,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{}}}if(!h){let e=oe(404,{pathname:u.pathname}),{matches:t,route:r}=ne(a);return{basename:o,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{}}}let f=await i(e,u,h,n);return ue(f)?f:t({location:u,basename:o},f)},queryRoute:async function(e,t){let{routeId:r,requestContext:n}=void 0===t?{}:t,d=new URL(e.url),c=e.method.toLowerCase(),u=s("",l(d),null,"default"),h=p(a,u,o);if(!fe(c)&&"head"!==c)throw oe(405,{method:c});if(!h)throw oe(404,{pathname:u.pathname});let f=r?h.find((e=>e.route.id===r)):we(h,u);if(r&&!f)throw oe(403,{pathname:u.pathname,routeId:r});if(!f)throw oe(404,{pathname:u.pathname});let m=await i(e,u,h,n,f);if(ue(m))return m;let g=m.errors?Object.values(m.errors)[0]:void 0;if(void 0!==g)throw g;let v=[m.actionData,m.loaderData].find((e=>e));return Object.values(v||{})[0]}}},e.warning=R,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=router.umd.min.js.map

@@ -73,2 +73,3 @@ import type { Location, Path, To } from "./history";

params: Params;
context?: any;
}

@@ -75,0 +76,0 @@ /**

{
"name": "@remix-run/router",
"version": "1.0.5-pre.1",
"version": "1.0.5-pre.2",
"description": "Nested/Data-driven/Framework-agnostic Routing",

@@ -5,0 +5,0 @@ "keywords": [

@@ -91,2 +91,3 @@ import type { Location, Path, To } from "./history";

params: Params;
context?: any;
}

@@ -93,0 +94,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc