@remix-run/router 1.6.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/dist/history.d.ts +6 -6
- package/dist/router.cjs.js +378 -234
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +69 -41
- package/dist/router.js +365 -229
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +378 -234
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +54 -28
- package/package.json +1 -1
- package/router.ts +501 -277
- package/utils.ts +44 -20
package/dist/router.umd.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.
|
|
2
|
+
* @remix-run/router v1.7.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
!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 o(e,t){if(!1===e||null==e)throw new Error(t)}function n(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function i(e,t){return{usr:e.state,key:e.key,idx:t}}function s(e,r,a,o){return void 0===a&&(a=null),t({pathname:"string"==typeof e?e:e.pathname,search:"",hash:""},"string"==typeof r?c(r):r,{state:a,key:r&&r.key||o||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 c(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 d(r,n,c,d){void 0===d&&(d={});let{window:u=document.defaultView,v5Compat:h=!1}=d,f=u.history,p=e.Action.Pop,m=null,v=y();function y(){return(f.state||{idx:null}).idx}function g(){p=e.Action.Pop;let t=y(),r=null==t?null:t-v;v=t,m&&m({action:p,location:w.location,delta:r})}function b(e){let t="null"!==u.location.origin?u.location.origin:u.location.href,r="string"==typeof e?e:l(e);return o(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==v&&(v=0,f.replaceState(t({},f.state,{idx:v}),""));let w={get action(){return p},get location(){return r(u,f)},listen(e){if(m)throw new Error("A history only accepts one active listener");return u.addEventListener(a,g),m=e,()=>{u.removeEventListener(a,g),m=null}},createHref:e=>n(u,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){p=e.Action.Push;let a=s(w.location,t,r);c&&c(a,t),v=y()+1;let o=i(a,v),n=w.createHref(a);try{f.pushState(o,"",n)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;u.location.assign(n)}h&&m&&m({action:p,location:w.location,delta:1})},replace:function(t,r){p=e.Action.Replace;let a=s(w.location,t,r);c&&c(a,t),v=y();let o=i(a,v),n=w.createHref(a);f.replaceState(o,"",n),h&&m&&m({action:p,location:w.location,delta:0})},go:e=>f.go(e)};return w}let u;!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(u||(u={}));const h=new Set(["lazy","caseSensitive","path","id","index","children"]);function f(e,r,a,n){return void 0===a&&(a=[]),void 0===n&&(n={}),e.map(((e,i)=>{let s=[...a,i],l="string"==typeof e.id?e.id:s.join("-");if(o(!0!==e.index||!e.children,"Cannot specify children on an index route"),o(!n[l],'Found a route id collision on id "'+l+"\". Route id's must be globally unique within Data Router usages"),function(e){return!0===e.index}(e)){let a=t({},e,r(e),{id:l});return n[l]=a,a}{let a=t({},e,r(e),{id:l,children:void 0});return n[l]=a,e.children&&(a.children=f(e.children,r,s,n)),a}}))}function p(e,t,r){void 0===r&&(r="/");let a=R(("string"==typeof t?c(t):t).pathname||"/",r);if(null==a)return null;let o=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)))))}(o);let n=null;for(let e=0;null==n&&e<o.length;++e)n=w(o[e],E(a));return n}function m(e,t,r,a){void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===a&&(a="");let n=(e,n,i)=>{let s={relativePath:void 0===i?e.path||"":i,caseSensitive:!0===e.caseSensitive,childrenIndex:n,route:e};s.relativePath.startsWith("/")&&(o(s.relativePath.startsWith(a),'Absolute route path "'+s.relativePath+'" nested under path "'+a+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),s.relativePath=s.relativePath.slice(a.length));let l=L([a,s.relativePath]),c=r.concat(s);e.children&&e.children.length>0&&(o(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),m(e.children,t,c,l)),(null!=e.path||e.index)&&t.push({path:l,score:b(l,e.index),routesMeta:c})};return e.forEach(((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let r of v(e.path))n(e,t,r);else n(e,t)})),t}function v(e){let t=e.split("/");if(0===t.length)return[];let[r,...a]=t,o=r.endsWith("?"),n=r.replace(/\?$/,"");if(0===a.length)return o?[n,""]:[n];let i=v(a.join("/")),s=[];return s.push(...i.map((e=>""===e?n:[n,e].join("/")))),o&&s.push(...i),s.map((t=>e.startsWith("/")&&""===t?"/":t))}const y=/^:\w+$/,g=e=>"*"===e;function b(e,t){let r=e.split("/"),a=r.length;return r.some(g)&&(a+=-2),t&&(a+=2),r.filter((e=>!g(e))).reduce(((e,t)=>e+(y.test(t)?3:""===t?1:10)),a)}function w(e,t){let{routesMeta:r}=e,a={},o="/",n=[];for(let e=0;e<r.length;++e){let i=r[e],s=e===r.length-1,l="/"===o?t:t.slice(o.length)||"/",c=D({path:i.relativePath,caseSensitive:i.caseSensitive,end:s},l);if(!c)return null;Object.assign(a,c.params);let d=i.route;n.push({params:a,pathname:L([o,c.pathname]),pathnameBase:k(L([o,c.pathnameBase])),route:d}),"/"!==c.pathnameBase&&(o=L([o,c.pathnameBase]))}return n}function D(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);n("*"===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=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,((e,t)=>(a.push(t),"/([^\\/]+)")));e.endsWith("*")?(a.push("*"),o+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?o+="\\/*$":""!==e&&"/"!==e&&(o+="(?:(?=\\/|$))");return[new RegExp(o,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),o=t.match(r);if(!o)return null;let i=o[0],s=i.replace(/(.)\/+$/,"$1"),l=o.slice(1);return{params:a.reduce(((e,t,r)=>{if("*"===t){let e=l[r]||"";s=i.slice(0,i.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(r){return n(!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}}(l[r]||"",t),e}),{}),pathname:i,pathnameBase:s,pattern:e}}function E(e){try{return decodeURI(e)}catch(t){return n(!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 R(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 A(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:o=""}="string"==typeof e?c(e):e,n=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:n,search:x(a),hash:C(o)}}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 M(e,r,a,n){let i;void 0===n&&(n=!1),"string"==typeof e?i=c(e):(i=t({},e),o(!i.pathname||!i.pathname.includes("?"),P("?","pathname","search",i)),o(!i.pathname||!i.pathname.includes("#"),P("#","pathname","hash",i)),o(!i.search||!i.search.includes("#"),P("#","search","hash",i)));let s,l=""===e||""===i.pathname,d=l?"/":i.pathname;if(n||null==d)s=a;else{let e=r.length-1;if(d.startsWith("..")){let t=d.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let u=A(i,s),h=d&&"/"!==d&&d.endsWith("/"),f=(l||"."===d)&&a.endsWith("/");return u.pathname.endsWith("/")||!h&&!f||(u.pathname+="/"),u}const L=e=>e.join("/").replace(/\/\/+/g,"/"),k=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),x=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",C=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class U extends Error{}class j{constructor(e,t){let r;this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],o(e&&"object"==typeof e&&!Array.isArray(e),"defer() only accepts plain objects"),this.abortPromise=new Promise(((e,t)=>r=t)),this.controller=new AbortController;let a=()=>r(new U("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",a),this.controller.signal.addEventListener("abort",a),this.data=Object.entries(e).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:this.trackPromise(r,a)})}),{}),this.done&&this.unlistenAbortSignal(),this.init=t}trackPromise(e,t){if(!(t instanceof Promise))return t;this.deferredKeys.push(e),this.pendingKeysSet.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){return this.controller.signal.aborted&&r instanceof U?(this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r)):(this.pendingKeysSet.delete(t),this.done&&this.unlistenAbortSignal(),r?(Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>a}),this.emit(!1,t),a))}emit(e,t){this.subscribers.forEach((r=>r(e,t)))}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}cancel(){this.controller.abort(),this.pendingKeysSet.forEach(((e,t)=>this.pendingKeysSet.delete(t))),this.emit(!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.pendingKeysSet.size}get unwrappedData(){return o(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]:_(a)})}),{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function _(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}class O{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 T(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}const I=["post","put","patch","delete"],F=new Set(I),z=["get",...I],H=new Set(z),B=new Set([301,302,303,307,308]),q=new Set([307,308]),N={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},$={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},W={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},K=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Y=e=>({hasErrorBoundary:Boolean(e.hasErrorBoundary)});const J=Symbol("deferred");function V(e,t,r,a,o,n,i){let s,c;if(null!=n&&"path"!==i){s=[];for(let e of t)if(s.push(e),e.route.id===n){c=e;break}}else s=t,c=t[t.length-1];let d=M(o||".",S(s).map((e=>e.pathnameBase)),R(e.pathname,r)||e.pathname,"path"===i);return null==o&&(d.search=e.search,d.hash=e.hash),null!=o&&""!==o&&"."!==o||!c||!c.route.index||Re(d.search)||(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),a&&"/"!==r&&(d.pathname="/"===d.pathname?r:L([r,d.pathname])),l(d)}function G(e,t,r,a){if(!a||!function(e){return null!=e&&"formData"in e}(a))return{path:r};if(a.formMethod&&!be(a.formMethod))return{path:r,error:de(405,{method:a.formMethod})};let o;if(a.formData){let t=a.formMethod||"get";if(o={formMethod:e?t.toUpperCase():t.toLowerCase(),formAction:he(r),formEncType:a&&a.formEncType||"application/x-www-form-urlencoded",formData:a.formData},we(o.formMethod))return{path:r,submission:o}}let n=c(r),i=oe(a.formData);return t&&n.search&&Re(n.search)&&i.append("index",""),n.search="?"+i,{path:l(n),submission:o}}function X(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 Q(e,r,a,o,n,i,s,l,c,d,u,h,f){let m=f?Object.values(f)[0]:h?Object.values(h)[0]:void 0,v=e.createURL(r.location),y=e.createURL(n),g=f?Object.keys(f)[0]:void 0,b=X(a,g).filter(((e,a)=>{if(e.route.lazy)return!0;if(null==e.route.loader)return!1;if(function(e,t,r){let a=!t||r.route.id!==t.route.id,o=void 0===e[r.route.id];return a||o}(r.loaderData,r.matches[a],e)||s.some((t=>t===e.route.id)))return!0;let n=r.matches[a],l=e;return ee(e,t({currentUrl:v,currentParams:n.params,nextUrl:y,nextParams:l.params},o,{actionResult:m,defaultShouldRevalidate:i||v.pathname+v.search===y.pathname+y.search||v.search!==y.search||Z(n,l)}))})),w=[];return c.forEach(((e,n)=>{if(!a.some((t=>t.route.id===e.routeId)))return;let s=p(d,e.path,u);if(!s)return void w.push({key:n,routeId:e.routeId,path:e.path,matches:null,match:null,controller:null});let c=Pe(s,e.path);(l.includes(n)||ee(c,t({currentUrl:v,currentParams:r.matches[r.matches.length-1].params,nextUrl:y,nextParams:a[a.length-1].params},o,{actionResult:m,defaultShouldRevalidate:i})))&&w.push({key:n,routeId:e.routeId,path:e.path,matches:s,match:c,controller:new AbortController})})),[b,w]}function Z(e,t){let r=e.route.path;return e.pathname!==t.pathname||null!=r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function ee(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}async function te(e,r,a){if(!e.lazy)return;let i=await e.lazy();if(!e.lazy)return;let s=a[e.id];o(s,"No route found in manifest");let l={};for(let e in i){let t=void 0!==s[e]&&"hasErrorBoundary"!==e;n(!t,'Route "'+s.id+'" has a static property "'+e+'" defined but its lazy function is also returning a value for this property. The lazy route property "'+e+'" will be ignored.'),t||h.has(e)||(l[e]=i[e])}Object.assign(s,l),Object.assign(s,t({},r(s),{lazy:void 0}))}async function re(e,t,r,a,n,i,s,l,c,d){let h,f,p;void 0===l&&(l=!1),void 0===c&&(c=!1);let m=e=>{let a,o=new Promise(((e,t)=>a=t));return p=()=>a(),t.signal.addEventListener("abort",p),Promise.race([e({request:t,params:r.params,context:d}),o])};try{let a=r.route[e];if(r.route.lazy)if(a){f=(await Promise.all([m(a),te(r.route,i,n)]))[0]}else{if(await te(r.route,i,n),a=r.route[e],!a){if("action"===e){let e=new URL(t.url),a=e.pathname+e.search;throw de(405,{method:t.method,pathname:a,routeId:r.route.id})}return{type:u.data,data:void 0}}f=await m(a)}else{if(!a){let e=new URL(t.url);throw de(404,{pathname:e.pathname+e.search})}f=await m(a)}o(void 0!==f,"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){h=u.error,f=e}finally{p&&t.signal.removeEventListener("abort",p)}if(ye(f)){let e,n=f.status;if(B.has(n)){let e=f.headers.get("Location");if(o(e,"Redirects returned/thrown from loaders/actions must have a Location header"),K.test(e)){if(!l){let r=new URL(t.url),a=e.startsWith("//")?new URL(r.protocol+e):new URL(e),o=null!=R(a.pathname,s);a.origin===r.origin&&o&&(e=a.pathname+a.search+a.hash)}}else e=V(new URL(t.url),a.slice(0,a.indexOf(r)+1),s,!0,e);if(l)throw f.headers.set("Location",e),f;return{type:u.redirect,status:n,location:e,revalidate:null!==f.headers.get("X-Remix-Revalidate")}}if(c)throw{type:h||u.data,response:f};let i=f.headers.get("Content-Type");return e=i&&/\bapplication\/json\b/.test(i)?await f.json():await f.text(),h===u.error?{type:h,error:new O(n,f.statusText,e),headers:f.headers}:{type:u.data,data:e,statusCode:f.status,headers:f.headers}}return h===u.error?{type:h,error:f}:ve(f)?{type:u.deferred,deferredData:f,statusCode:null==(v=f.init)?void 0:v.status,headers:(null==(y=f.init)?void 0:y.headers)&&new Headers(f.init.headers)}:{type:u.data,data:f};var v,y}function ae(e,t,r,a){let o=e.createURL(he(t)).toString(),n={signal:r};if(a&&we(a.formMethod)){let{formMethod:e,formEncType:t,formData:r}=a;n.method=e.toUpperCase(),n.body="application/x-www-form-urlencoded"===t?oe(r):r}return new Request(o,n)}function oe(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,a instanceof File?a.name:a);return t}function ne(e,t,r,a,n){let i,s={},l=null,c=!1,d={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(o(!me(r),"Cannot handle redirect results in processLoaderData"),pe(r)){let t=le(e,h),o=r.error;a&&(o=Object.values(a)[0],a=void 0),l=l||{},null==l[t.route.id]&&(l[t.route.id]=o),s[h]=void 0,c||(c=!0,i=T(r.error)?r.error.status:500),r.headers&&(d[h]=r.headers)}else fe(r)?(n.set(h,r.deferredData),s[h]=r.deferredData.data):s[h]=r.data,null==r.statusCode||200===r.statusCode||c||(i=r.statusCode),r.headers&&(d[h]=r.headers)})),a&&(l=a,s[Object.keys(a)[0]]=void 0),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:d}}function ie(e,r,a,n,i,s,l,c){let{loaderData:d,errors:u}=ne(r,a,n,i,c);for(let r=0;r<s.length;r++){let{key:a,match:n,controller:i}=s[r];o(void 0!==l&&void 0!==l[r],"Did not find corresponding fetcher result");let c=l[r];if(!i||!i.signal.aborted)if(pe(c)){let r=le(e.matches,null==n?void 0:n.route.id);u&&u[r.route.id]||(u=t({},u,{[r.route.id]:c.error})),e.fetchers.delete(a)}else if(me(c))o(!1,"Unhandled fetcher revalidation redirect");else if(fe(c))o(!1,"Unhandled fetcher deferred data");else{let t={state:"idle",data:c.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};e.fetchers.set(a,t)}}return{loaderData:d,errors:u}}function se(e,r,a,o){let n=t({},r);for(let t of a){let a=t.route.id;if(r.hasOwnProperty(a)?void 0!==r[a]&&(n[a]=r[a]):void 0!==e[a]&&t.route.loader&&(n[a]=e[a]),o&&o.hasOwnProperty(a))break}return n}function le(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 ce(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 de(e,t){let{pathname:r,routeId:a,method:o,type:n}=void 0===t?{}:t,i="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(i="Bad Request",o&&r&&a?s="You made a "+o+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"defer-action"===n&&(s="defer() is not supported in actions")):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",o&&r&&a?s="You made a "+o.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':o&&(s='Invalid request method "'+o.toUpperCase()+'"')),new O(e||500,i,new Error(s),!0)}function ue(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(me(r))return r}}function he(e){return l(t({},"string"==typeof e?c(e):e,{hash:""}))}function fe(e){return e.type===u.deferred}function pe(e){return e.type===u.error}function me(e){return(e&&e.type)===u.redirect}function ve(e){let t=e;return t&&"object"==typeof t&&"object"==typeof t.data&&"function"==typeof t.subscribe&&"function"==typeof t.cancel&&"function"==typeof t.resolveData}function ye(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function ge(e){if(!ye(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}function be(e){return H.has(e.toLowerCase())}function we(e){return F.has(e.toLowerCase())}async function De(e,t,r,a,n,i){for(let s=0;s<r.length;s++){let l=r[s],c=t[s];if(!c)continue;let d=e.find((e=>e.route.id===c.route.id)),u=null!=d&&!Z(d,c)&&void 0!==(i&&i[c.route.id]);if(fe(l)&&(n||u)){let e=a[s];o(e,"Expected an AbortSignal for revalidating fetcher deferred result"),await Ee(l,e,n).then((e=>{e&&(r[s]=e||r[s])}))}}}async function Ee(e,t,r){if(void 0===r&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:u.data,data:e.deferredData.unwrappedData}}catch(e){return{type:u.error,error:e}}return{type:u.data,data:e.deferredData.data}}}function Re(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function Ae(e,t){let{route:r,pathname:a,params:o}=e;return{id:r.id,pathname:a,params:o,data:t[r.id],handle:r.handle}}function Pe(e,t){let r="string"==typeof t?c(t).search:t.search;if(e[e.length-1].route.index&&Re(r||""))return e[e.length-1];let a=S(e);return a[a.length-1]}e.AbortedDeferredError=U,e.ErrorResponse=O,e.IDLE_BLOCKER=W,e.IDLE_FETCHER=$,e.IDLE_NAVIGATION=N,e.UNSAFE_DEFERRED_SYMBOL=J,e.UNSAFE_DeferredData=j,e.UNSAFE_convertRoutesToDataRoutes=f,e.UNSAFE_getPathContributingMatches=S,e.UNSAFE_invariant=o,e.UNSAFE_warning=n,e.createBrowserHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r,search:a,hash:o}=e.location;return s("",{pathname:r,search:a,hash:o},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={}),d((function(e,t){let{pathname:r="/",search:a="",hash:o=""}=c(e.location.hash.substr(1));return s("",{pathname:r,search:a,hash:o},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){n("/"===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:o,v5Compat:i=!1}=t;r=a.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let d=f(null==o?r.length-1:o),u=e.Action.Pop,h=null;function f(e){return Math.min(Math.max(e,0),r.length-1)}function p(){return r[d]}function m(e,t,a){void 0===t&&(t=null);let o=s(r?p().pathname:"/",e,t,a);return n("/"===o.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),o}function v(e){return"string"==typeof e?e:l(e)}return{get index(){return d},get action(){return u},get location(){return p()},createHref:v,createURL:e=>new URL(v(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?c(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(t,a){u=e.Action.Push;let o=m(t,a);d+=1,r.splice(d,r.length,o),i&&h&&h({action:u,location:o,delta:1})},replace(t,a){u=e.Action.Replace;let o=m(t,a);r[d]=o,i&&h&&h({action:u,location:o,delta:0})},go(t){u=e.Action.Pop;let a=f(d+t),o=r[a];d=a,h&&h({action:u,location:o,delta:t})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(r){const a=r.window?r.window:"undefined"!=typeof window?window:void 0,i=void 0!==a&&void 0!==a.document&&void 0!==a.document.createElement,l=!i;let c;if(o(r.routes.length>0,"You must provide a non-empty routes array to createRouter"),r.mapRouteProperties)c=r.mapRouteProperties;else if(r.detectErrorBoundary){let e=r.detectErrorBoundary;c=t=>({hasErrorBoundary:e(t)})}else c=Y;let d,h={},m=f(r.routes,c,void 0,h),v=r.basename||"/",y=t({v7_normalizeFormMethod:!1,v7_prependBasename:!1},r.future),g=null,b=new Set,w=null,D=null,E=null,A=null!=r.hydrationData,P=p(m,r.history.location,v),S=null;if(null==P){let e=de(404,{pathname:r.history.location.pathname}),{matches:t,route:a}=ce(m);P=t,S={[a.id]:e}}let M,L,k=!(P.some((e=>e.route.lazy))||P.some((e=>e.route.loader))&&null==r.hydrationData),x={historyAction:r.history.action,location:r.history.location,matches:P,initialized:k,navigation:N,restoreScrollPosition:null==r.hydrationData&&null,preventScrollReset:!1,revalidation:"idle",loaderData:r.hydrationData&&r.hydrationData.loaderData||{},actionData:r.hydrationData&&r.hydrationData.actionData||null,errors:r.hydrationData&&r.hydrationData.errors||S,fetchers:new Map,blockers:new Map},C=e.Action.Pop,U=!1,j=!1,_=!1,O=[],T=[],I=new Map,F=0,z=-1,H=new Map,B=new Set,J=new Map,X=new Map,Z=new Map,ee=!1;function te(e){x=t({},x,e),b.forEach((e=>e(x)))}function oe(a,o){var n,i;let s,l=null!=x.actionData&&null!=x.navigation.formMethod&&we(x.navigation.formMethod)&&"loading"===x.navigation.state&&!0!==(null==(n=a.state)?void 0:n._isRedirect);s=o.actionData?Object.keys(o.actionData).length>0?o.actionData:null:l?x.actionData:null;let c=o.loaderData?se(x.loaderData,o.loaderData,o.matches||[],o.errors):x.loaderData;for(let[e]of Z)xe(e);let u=!0===U||null!=x.navigation.formMethod&&we(x.navigation.formMethod)&&!0!==(null==(i=a.state)?void 0:i._isRedirect);d&&(m=d,d=void 0),te(t({},o,{actionData:s,loaderData:c,historyAction:C,location:a,initialized:!0,navigation:N,revalidation:"idle",restoreScrollPosition:_e(a,o.matches||x.matches),preventScrollReset:u,blockers:new Map(x.blockers)})),j||C===e.Action.Pop||(C===e.Action.Push?r.history.push(a,a.state):C===e.Action.Replace&&r.history.replace(a,a.state)),C=e.Action.Pop,U=!1,j=!1,_=!1,O=[],T=[]}async function ne(a,o,n){L&&L.abort(),L=null,C=a,j=!0===(n&&n.startUninterruptedRevalidation),function(e,t){if(w&&D&&E){let r=t.map((e=>Ae(e,x.loaderData))),a=D(e,r)||e.key;w[a]=E()}}(x.location,x.matches),U=!0===(n&&n.preventScrollReset);let i=d||m,s=n&&n.overrideNavigation,l=p(i,o,v);if(!l){let e=de(404,{pathname:o.pathname}),{matches:t,route:r}=ce(i);return je(),void oe(o,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(x.initialized&&!_&&function(e,t){if(e.pathname!==t.pathname||e.search!==t.search)return!1;if(""===e.hash)return""!==t.hash;if(e.hash===t.hash)return!0;if(""!==t.hash)return!0;return!1}(x.location,o)&&!(n&&n.submission&&we(n.submission.formMethod)))return void oe(o,{matches:l});L=new AbortController;let f,y,g=ae(r.history,o,L.signal,n&&n.submission);if(n&&n.pendingError)y={[le(l).route.id]:n.pendingError};else if(n&&n.submission&&we(n.submission.formMethod)){let r=await async function(r,a,o,n,i){let s;ge(),te({navigation:t({state:"submitting",location:a},o)});let l=Pe(n,a);if(l.route.action||l.route.lazy){if(s=await re("action",r,l,n,h,c,v),r.signal.aborted)return{shortCircuited:!0}}else s={type:u.error,error:de(405,{method:r.method,pathname:a.pathname,routeId:l.route.id})};if(me(s)){let e;return e=i&&null!=i.replace?i.replace:s.location===x.location.pathname+x.location.search,await ve(x,s,{submission:o,replace:e}),{shortCircuited:!0}}if(pe(s)){let t=le(n,l.route.id);return!0!==(i&&i.replace)&&(C=e.Action.Push),{pendingActionData:{},pendingActionError:{[t.route.id]:s.error}}}if(fe(s))throw de(400,{type:"defer-action"});return{pendingActionData:{[l.route.id]:s.data}}}(g,o,n.submission,l,{replace:n.replace});if(r.shortCircuited)return;f=r.pendingActionData,y=r.pendingActionError,s=t({state:"loading",location:o},n.submission),g=new Request(g.url,{signal:g.signal})}let{shortCircuited:b,loaderData:R,errors:A}=await async function(e,a,o,n,i,s,l,c,u){let h=n;if(!h){h=t({state:"loading",location:a,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},i)}let f=i||s?i||s:h.formMethod&&h.formAction&&h.formData&&h.formEncType?{formMethod:h.formMethod,formAction:h.formAction,formData:h.formData,formEncType:h.formEncType}:void 0,p=d||m,[y,g]=Q(r.history,x,o,f,a,_,O,T,J,p,v,c,u);if(je((e=>!(o&&o.some((t=>t.route.id===e)))||y&&y.some((t=>t.route.id===e)))),0===y.length&&0===g.length){let e=Le();return oe(a,t({matches:o,loaderData:{},errors:u||null},c?{actionData:c}:{},e?{fetchers:new Map(x.fetchers)}:{})),{shortCircuited:!0}}if(!j){g.forEach((e=>{let t=x.fetchers.get(e.key),r={state:"loading",data:t&&t.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};x.fetchers.set(e.key,r)}));let e=c||x.actionData;te(t({navigation:h},e?0===Object.keys(e).length?{actionData:null}:{actionData:e}:{},g.length>0?{fetchers:new Map(x.fetchers)}:{}))}z=++F,g.forEach((e=>{e.controller&&I.set(e.key,e.controller)}));let b=()=>g.forEach((e=>Se(e.key)));L&&L.signal.addEventListener("abort",b);let{results:w,loaderResults:D,fetcherResults:E}=await ye(x.matches,o,y,g,e);if(e.signal.aborted)return{shortCircuited:!0};L&&L.signal.removeEventListener("abort",b);g.forEach((e=>I.delete(e.key)));let R=ue(w);if(R)return await ve(x,R,{replace:l}),{shortCircuited:!0};let{loaderData:A,errors:P}=ie(x,o,y,D,u,g,E,X);X.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&X.delete(t)}))}));let S=Le(),M=ke(z),k=S||M||g.length>0;return t({loaderData:A,errors:P},k?{fetchers:new Map(x.fetchers)}:{})}(g,o,l,s,n&&n.submission,n&&n.fetcherSubmission,n&&n.replace,f,y);b||(L=null,oe(o,t({matches:l},f?{actionData:f}:{},{loaderData:R,errors:A})))}function he(e){return x.fetchers.get(e)||$}async function ve(n,l,c){let{submission:d,replace:u,isFetchActionRedirect:h}=void 0===c?{}:c;l.revalidate&&(_=!0);let f=s(n.location,l.location,t({_isRedirect:!0},h?{_isFetchActionRedirect:!0}:{}));if(o(f,"Expected a location on the redirect navigation"),K.test(l.location)&&i){let e=r.history.createURL(l.location),t=null==R(e.pathname,v);if(a.location.origin!==e.origin||t)return void(u?a.location.replace(l.location):a.location.assign(l.location))}L=null;let p=!0===u?e.Action.Replace:e.Action.Push,{formMethod:m,formAction:y,formEncType:g,formData:b}=n.navigation;!d&&m&&y&&b&&g&&(d={formMethod:m,formAction:y,formEncType:g,formData:b}),q.has(l.status)&&d&&we(d.formMethod)?await ne(p,f,{submission:t({},d,{formAction:l.location}),preventScrollReset:U}):h?await ne(p,f,{overrideNavigation:{state:"loading",location:f,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},fetcherSubmission:d,preventScrollReset:U}):await ne(p,f,{overrideNavigation:{state:"loading",location:f,formMethod:d?d.formMethod:void 0,formAction:d?d.formAction:void 0,formEncType:d?d.formEncType:void 0,formData:d?d.formData:void 0},preventScrollReset:U})}async function ye(e,t,a,o,n){let i=await Promise.all([...a.map((e=>re("loader",n,e,t,h,c,v))),...o.map((e=>{if(e.matches&&e.match&&e.controller)return re("loader",ae(r.history,e.path,e.controller.signal),e.match,e.matches,h,c,v);return{type:u.error,error:de(404,{pathname:e.path})}}))]),s=i.slice(0,a.length),l=i.slice(a.length);return await Promise.all([De(e,a,s,s.map((()=>n.signal)),!1,x.loaderData),De(e,o.map((e=>e.match)),l,o.map((e=>e.controller?e.controller.signal:null)),!0)]),{results:i,loaderResults:s,fetcherResults:l}}function ge(){_=!0,O.push(...je()),J.forEach(((e,t)=>{I.has(t)&&(T.push(t),Se(t))}))}function be(e,t,r){let a=le(x.matches,t);Re(e),te({errors:{[a.route.id]:r},fetchers:new Map(x.fetchers)})}function Re(e){let t=x.fetchers.get(e);!I.has(e)||t&&"loading"===t.state&&H.has(e)||Se(e),J.delete(e),H.delete(e),B.delete(e),x.fetchers.delete(e)}function Se(e){let t=I.get(e);o(t,"Expected fetch controller: "+e),t.abort(),I.delete(e)}function Me(e){for(let t of e){let e={state:"idle",data:he(t).data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};x.fetchers.set(t,e)}}function Le(){let e=[],t=!1;for(let r of B){let a=x.fetchers.get(r);o(a,"Expected fetcher: "+r),"loading"===a.state&&(B.delete(r),e.push(r),t=!0)}return Me(e),t}function ke(e){let t=[];for(let[r,a]of H)if(a<e){let e=x.fetchers.get(r);o(e,"Expected fetcher: "+r),"loading"===e.state&&(Se(r),H.delete(r),t.push(r))}return Me(t),t.length>0}function xe(e){x.blockers.delete(e),Z.delete(e)}function Ce(e,t){let r=x.blockers.get(e)||W;o("unblocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"proceeding"===t.state||"blocked"===r.state&&"unblocked"===t.state||"proceeding"===r.state&&"unblocked"===t.state,"Invalid blocker state transition: "+r.state+" -> "+t.state),x.blockers.set(e,t),te({blockers:new Map(x.blockers)})}function Ue(e){let{currentLocation:t,nextLocation:r,historyAction:a}=e;if(0===Z.size)return;Z.size>1&&n(!1,"A router only supports one blocker at a time");let o=Array.from(Z.entries()),[i,s]=o[o.length-1],l=x.blockers.get(i);return l&&"proceeding"===l.state?void 0:s({currentLocation:t,nextLocation:r,historyAction:a})?i:void 0}function je(e){let t=[];return X.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),X.delete(a))})),t}function _e(e,t){if(w&&D&&E){let r=t.map((e=>Ae(e,x.loaderData))),a=D(e,r)||e.key,o=w[a];if("number"==typeof o)return o}return null}return M={get basename(){return v},get state(){return x},get routes(){return m},initialize:function(){return g=r.history.listen((e=>{let{action:t,location:a,delta:o}=e;if(ee)return void(ee=!1);n(0===Z.size||null!=o,"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 i=Ue({currentLocation:x.location,nextLocation:a,historyAction:t});return i&&null!=o?(ee=!0,r.history.go(-1*o),void Ce(i,{state:"blocked",location:a,proceed(){Ce(i,{state:"proceeding",proceed:void 0,reset:void 0,location:a}),r.history.go(o)},reset(){xe(i),te({blockers:new Map(M.state.blockers)})}})):ne(t,a)})),x.initialized||ne(e.Action.Pop,x.location),M},subscribe:function(e){return b.add(e),()=>b.delete(e)},enableScrollRestoration:function(e,t,r){if(w=e,E=t,D=r||(e=>e.key),!A&&x.navigation===N){A=!0;let e=_e(x.location,x.matches);null!=e&&te({restoreScrollPosition:e})}return()=>{w=null,E=null,D=null}},navigate:async function a(o,n){if("number"==typeof o)return void r.history.go(o);let i=V(x.location,x.matches,v,y.v7_prependBasename,o,null==n?void 0:n.fromRouteId,null==n?void 0:n.relative),{path:l,submission:c,error:d}=G(y.v7_normalizeFormMethod,!1,i,n),u=x.location,h=s(x.location,l,n&&n.state);h=t({},h,r.history.encodeLocation(h));let f=n&&null!=n.replace?n.replace:void 0,p=e.Action.Push;!0===f?p=e.Action.Replace:!1===f||null!=c&&we(c.formMethod)&&c.formAction===x.location.pathname+x.location.search&&(p=e.Action.Replace);let m=n&&"preventScrollReset"in n?!0===n.preventScrollReset:void 0,g=Ue({currentLocation:u,nextLocation:h,historyAction:p});if(!g)return await ne(p,h,{submission:c,pendingError:d,preventScrollReset:m,replace:n&&n.replace});Ce(g,{state:"blocked",location:h,proceed(){Ce(g,{state:"proceeding",proceed:void 0,reset:void 0,location:h}),a(o,n)},reset(){xe(g),te({blockers:new Map(x.blockers)})}})},fetch:function(e,a,n,i){if(l)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.");I.has(e)&&Se(e);let s=d||m,u=V(x.location,x.matches,v,y.v7_prependBasename,n,a,null==i?void 0:i.relative),f=p(s,u,v);if(!f)return void be(e,a,de(404,{pathname:u}));let{path:g,submission:b}=G(y.v7_normalizeFormMethod,!0,u,i),w=Pe(f,g);U=!0===(i&&i.preventScrollReset),b&&we(b.formMethod)?async function(e,a,n,i,s,l){if(ge(),J.delete(e),!i.route.action&&!i.route.lazy){let t=de(405,{method:l.formMethod,pathname:n,routeId:a});return void be(e,a,t)}let u=x.fetchers.get(e),f=t({state:"submitting"},l,{data:u&&u.data," _hasFetcherDoneAnything ":!0});x.fetchers.set(e,f),te({fetchers:new Map(x.fetchers)});let y=new AbortController,g=ae(r.history,n,y.signal,l);I.set(e,y);let b=await re("action",g,i,s,h,c,v);if(g.signal.aborted)return void(I.get(e)===y&&I.delete(e));if(me(b)){I.delete(e),B.add(e);let r=t({state:"loading"},l,{data:void 0," _hasFetcherDoneAnything ":!0});return x.fetchers.set(e,r),te({fetchers:new Map(x.fetchers)}),ve(x,b,{submission:l,isFetchActionRedirect:!0})}if(pe(b))return void be(e,a,b.error);if(fe(b))throw de(400,{type:"defer-action"});let w=x.navigation.location||x.location,D=ae(r.history,w,y.signal),E=d||m,R="idle"!==x.navigation.state?p(E,x.navigation.location,v):x.matches;o(R,"Didn't find any matches after fetcher action");let A=++F;H.set(e,A);let P=t({state:"loading",data:b.data},l,{" _hasFetcherDoneAnything ":!0});x.fetchers.set(e,P);let[S,M]=Q(r.history,x,R,l,w,_,O,T,J,E,v,{[i.route.id]:b.data},void 0);M.filter((t=>t.key!==e)).forEach((e=>{let t=e.key,r=x.fetchers.get(t),a={state:"loading",data:r&&r.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};x.fetchers.set(t,a),e.controller&&I.set(t,e.controller)})),te({fetchers:new Map(x.fetchers)});let k=()=>M.forEach((e=>Se(e.key)));y.signal.addEventListener("abort",k);let{results:U,loaderResults:j,fetcherResults:q}=await ye(x.matches,R,S,M,D);if(y.signal.aborted)return;y.signal.removeEventListener("abort",k),H.delete(e),I.delete(e),M.forEach((e=>I.delete(e.key)));let N=ue(U);if(N)return ve(x,N);let{loaderData:$,errors:W}=ie(x,x.matches,S,j,void 0,M,q,X);if(x.fetchers.has(e)){let t={state:"idle",data:b.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};x.fetchers.set(e,t)}let K=ke(A);"loading"===x.navigation.state&&A>z?(o(C,"Expected pending action"),L&&L.abort(),oe(x.navigation.location,{matches:R,loaderData:$,errors:W,fetchers:new Map(x.fetchers)})):(te(t({errors:W,loaderData:se(x.loaderData,$,R,W)},K||M.length>0?{fetchers:new Map(x.fetchers)}:{})),_=!1)}(e,a,g,w,f,b):(J.set(e,{routeId:a,path:g}),async function(e,a,n,i,s,l){let d=x.fetchers.get(e),u=t({state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0},l,{data:d&&d.data," _hasFetcherDoneAnything ":!0});x.fetchers.set(e,u),te({fetchers:new Map(x.fetchers)});let f=new AbortController,p=ae(r.history,n,f.signal);I.set(e,f);let m=await re("loader",p,i,s,h,c,v);fe(m)&&(m=await Ee(m,p.signal,!0)||m);I.get(e)===f&&I.delete(e);if(p.signal.aborted)return;if(me(m))return B.add(e),void await ve(x,m);if(pe(m)){let t=le(x.matches,a);return x.fetchers.delete(e),void te({fetchers:new Map(x.fetchers),errors:{[t.route.id]:m.error}})}o(!fe(m),"Unhandled fetcher deferred data");let y={state:"idle",data:m.data,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0," _hasFetcherDoneAnything ":!0};x.fetchers.set(e,y),te({fetchers:new Map(x.fetchers)})}(e,a,g,w,f,b))},revalidate:function(){ge(),te({revalidation:"loading"}),"submitting"!==x.navigation.state&&("idle"!==x.navigation.state?ne(C||x.historyAction,x.navigation.location,{overrideNavigation:x.navigation}):ne(x.historyAction,x.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:he,deleteFetcher:Re,dispose:function(){g&&g(),b.clear(),L&&L.abort(),x.fetchers.forEach(((e,t)=>Re(t))),x.blockers.forEach(((e,t)=>xe(t)))},getBlocker:function(e,t){let r=x.blockers.get(e)||W;return Z.get(e)!==t&&Z.set(e,t),r},deleteBlocker:xe,_internalFetchControllers:I,_internalActiveDeferreds:X,_internalSetRoutes:function(e){h={},d=f(e,c,void 0,h)}},M},e.createStaticHandler=function(e,r){o(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let a,n={},i=(r?r.basename:null)||"/";if(null!=r&&r.mapRouteProperties)a=r.mapRouteProperties;else if(null!=r&&r.detectErrorBoundary){let e=r.detectErrorBoundary;a=t=>({hasErrorBoundary:e(t)})}else a=Y;let c=f(e,a,void 0,n);async function d(e,r,s,l,c){o(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(we(e.method.toLowerCase())){let o=await async function(e,r,o,s,l){let c;if(o.route.action||o.route.lazy){if(c=await re("action",e,o,r,n,a,i,!0,l,s),e.signal.aborted){throw new Error((l?"queryRoute":"query")+"() call aborted")}}else{let t=de(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:o.route.id});if(l)throw t;c={type:u.error,error:t}}if(me(c))throw new Response(null,{status:c.status,headers:{Location:c.location}});if(fe(c)){let e=de(400,{type:"defer-action"});if(l)throw e;c={type:u.error,error:e}}if(l){if(pe(c))throw c.error;return{matches:[o],loaderData:{},actionData:{[o.route.id]:c.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(pe(c)){let a=le(r,o.route.id);return t({},await h(e,r,s,void 0,{[a.route.id]:c.error}),{statusCode:T(c.error)?c.error.status:500,actionData:null,actionHeaders:t({},c.headers?{[o.route.id]:c.headers}:{})})}let d=new Request(e.url,{headers:e.headers,redirect:e.redirect,signal:e.signal});return t({},await h(d,r,s),c.statusCode?{statusCode:c.statusCode}:{},{actionData:{[o.route.id]:c.data},actionHeaders:t({},c.headers?{[o.route.id]:c.headers}:{})})}(e,s,c||Pe(s,r),l,null!=c);return o}let o=await h(e,s,l,c);return ye(o)?o:t({},o,{actionData:null,actionHeaders:{}})}catch(e){if((d=e)&&ye(d.response)&&(d.type===u.data||u.error)){if(e.type===u.error&&!ge(e.response))throw e.response;return e.response}if(ge(e))return e;throw e}var d}async function h(e,r,o,s,l){let c=null!=s;if(c&&(null==s||!s.route.loader)&&(null==s||!s.route.lazy))throw de(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==s?void 0:s.route.id});let d=(s?[s]:X(r,Object.keys(l||{})[0])).filter((e=>e.route.loader||e.route.lazy));if(0===d.length)return{matches:r,loaderData:r.reduce(((e,t)=>Object.assign(e,{[t.route.id]:null})),{}),errors:l||null,statusCode:200,loaderHeaders:{},activeDeferreds:null};let u=await Promise.all([...d.map((t=>re("loader",e,t,r,n,a,i,!0,c,o)))]);if(e.signal.aborted){throw new Error((c?"queryRoute":"query")+"() call aborted")}let h=new Map,f=ne(r,d,u,l,h),p=new Set(d.map((e=>e.route.id)));return r.forEach((e=>{p.has(e.route.id)||(f.loaderData[e.route.id]=null)})),t({},f,{matches:r,activeDeferreds:h.size>0?Object.fromEntries(h.entries()):null})}return{dataRoutes:c,query:async function(e,r){let{requestContext:a}=void 0===r?{}:r,o=new URL(e.url),n=e.method,u=s("",l(o),null,"default"),h=p(c,u,i);if(!be(n)&&"HEAD"!==n){let e=de(405,{method:n}),{matches:t,route:r}=ce(c);return{basename:i,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(!h){let e=de(404,{pathname:u.pathname}),{matches:t,route:r}=ce(c);return{basename:i,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let f=await d(e,u,h,a);return ye(f)?f:t({location:u,basename:i},f)},queryRoute:async function(e,t){let{routeId:r,requestContext:a}=void 0===t?{}:t,o=new URL(e.url),n=e.method,u=s("",l(o),null,"default"),h=p(c,u,i);if(!be(n)&&"HEAD"!==n&&"OPTIONS"!==n)throw de(405,{method:n});if(!h)throw de(404,{pathname:u.pathname});let f=r?h.find((e=>e.route.id===r)):Pe(h,u);if(r&&!f)throw de(403,{pathname:u.pathname,routeId:r});if(!f)throw de(404,{pathname:u.pathname});let m=await d(e,u,h,a,f);if(ye(m))return m;let v=m.errors?Object.values(m.errors)[0]:void 0;if(void 0!==v)throw v;if(m.actionData)return Object.values(m.actionData)[0];if(m.loaderData){var y;let e=Object.values(m.loaderData)[0];return null!=(y=m.activeDeferreds)&&y[f.route.id]&&(e[J]=m.activeDeferreds[f.route.id]),e}}}},e.defer=function(e,t){return void 0===t&&(t={}),new j(e,"number"==typeof t?{status:t}:t)},e.generatePath=function(e,t){void 0===t&&(t={});let r=e;return r.endsWith("*")&&"*"!==r&&!r.endsWith("/*")&&(n(!1,'Route path "'+r+'" will be treated as if it were "'+r.replace(/\*$/,"/*")+'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "'+r.replace(/\*$/,"/*")+'".'),r=r.replace(/\*$/,"/*")),(r.startsWith("/")?"/":"")+r.split(/\/+/).map(((e,r,a)=>{if(r===a.length-1&&"*"===e){return t["*"]}const n=e.match(/^:(\w+)(\??)$/);if(n){const[,e,r]=n;let a=t[e];return"?"===r?null==a?"":a:(null==a&&o(!1,'Missing ":'+e+'" param'),a)}return e.replace(/\?$/g,"")})).filter((e=>!!e)).join("/")},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?c(e).pathname:e.pathname},e.isDeferredData=ve,e.isRouteErrorResponse=T,e.joinPaths=L,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,o=new Headers(a.headers);return o.has("Content-Type")||o.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:o}))},e.matchPath=D,e.matchRoutes=p,e.normalizePathname=k,e.parsePath=c,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 o=new Headers(a.headers);return o.set("Location",e),new Response(null,t({},a,{headers:o}))},e.resolvePath=A,e.resolveTo=M,e.stripBasename=R,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
11
|
+
!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 o(e,t){if(!1===e||null==e)throw new Error(t)}function n(e,t){if(!e){"undefined"!=typeof console&&console.warn(t);try{throw new Error(t)}catch(e){}}}function i(e,t){return{usr:e.state,key:e.key,idx:t}}function s(e,r,a,o){return void 0===a&&(a=null),t({pathname:"string"==typeof e?e:e.pathname,search:"",hash:""},"string"==typeof r?c(r):r,{state:a,key:r&&r.key||o||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 c(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 d(r,n,c,d){void 0===d&&(d={});let{window:u=document.defaultView,v5Compat:h=!1}=d,f=u.history,p=e.Action.Pop,m=null,y=v();function v(){return(f.state||{idx:null}).idx}function g(){p=e.Action.Pop;let t=v(),r=null==t?null:t-y;y=t,m&&m({action:p,location:w.location,delta:r})}function b(e){let t="null"!==u.location.origin?u.location.origin:u.location.href,r="string"==typeof e?e:l(e);return o(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==y&&(y=0,f.replaceState(t({},f.state,{idx:y}),""));let w={get action(){return p},get location(){return r(u,f)},listen(e){if(m)throw new Error("A history only accepts one active listener");return u.addEventListener(a,g),m=e,()=>{u.removeEventListener(a,g),m=null}},createHref:e=>n(u,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(t,r){p=e.Action.Push;let a=s(w.location,t,r);c&&c(a,t),y=v()+1;let o=i(a,y),n=w.createHref(a);try{f.pushState(o,"",n)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;u.location.assign(n)}h&&m&&m({action:p,location:w.location,delta:1})},replace:function(t,r){p=e.Action.Replace;let a=s(w.location,t,r);c&&c(a,t),y=v();let o=i(a,y),n=w.createHref(a);f.replaceState(o,"",n),h&&m&&m({action:p,location:w.location,delta:0})},go:e=>f.go(e)};return w}let u;!function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"}(u||(u={}));const h=new Set(["lazy","caseSensitive","path","id","index","children"]);function f(e,r,a,n){return void 0===a&&(a=[]),void 0===n&&(n={}),e.map(((e,i)=>{let s=[...a,i],l="string"==typeof e.id?e.id:s.join("-");if(o(!0!==e.index||!e.children,"Cannot specify children on an index route"),o(!n[l],'Found a route id collision on id "'+l+"\". Route id's must be globally unique within Data Router usages"),function(e){return!0===e.index}(e)){let a=t({},e,r(e),{id:l});return n[l]=a,a}{let a=t({},e,r(e),{id:l,children:void 0});return n[l]=a,e.children&&(a.children=f(e.children,r,s,n)),a}}))}function p(e,t,r){void 0===r&&(r="/");let a=E(("string"==typeof t?c(t):t).pathname||"/",r);if(null==a)return null;let o=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)))))}(o);let n=null;for(let e=0;null==n&&e<o.length;++e)n=w(o[e],R(a));return n}function m(e,t,r,a){void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===a&&(a="");let n=(e,n,i)=>{let s={relativePath:void 0===i?e.path||"":i,caseSensitive:!0===e.caseSensitive,childrenIndex:n,route:e};s.relativePath.startsWith("/")&&(o(s.relativePath.startsWith(a),'Absolute route path "'+s.relativePath+'" nested under path "'+a+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),s.relativePath=s.relativePath.slice(a.length));let l=M([a,s.relativePath]),c=r.concat(s);e.children&&e.children.length>0&&(o(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),m(e.children,t,c,l)),(null!=e.path||e.index)&&t.push({path:l,score:b(l,e.index),routesMeta:c})};return e.forEach(((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let r of y(e.path))n(e,t,r);else n(e,t)})),t}function y(e){let t=e.split("/");if(0===t.length)return[];let[r,...a]=t,o=r.endsWith("?"),n=r.replace(/\?$/,"");if(0===a.length)return o?[n,""]:[n];let i=y(a.join("/")),s=[];return s.push(...i.map((e=>""===e?n:[n,e].join("/")))),o&&s.push(...i),s.map((t=>e.startsWith("/")&&""===t?"/":t))}const v=/^:\w+$/,g=e=>"*"===e;function b(e,t){let r=e.split("/"),a=r.length;return r.some(g)&&(a+=-2),t&&(a+=2),r.filter((e=>!g(e))).reduce(((e,t)=>e+(v.test(t)?3:""===t?1:10)),a)}function w(e,t){let{routesMeta:r}=e,a={},o="/",n=[];for(let e=0;e<r.length;++e){let i=r[e],s=e===r.length-1,l="/"===o?t:t.slice(o.length)||"/",c=D({path:i.relativePath,caseSensitive:i.caseSensitive,end:s},l);if(!c)return null;Object.assign(a,c.params);let d=i.route;n.push({params:a,pathname:M([o,c.pathname]),pathnameBase:L(M([o,c.pathnameBase])),route:d}),"/"!==c.pathnameBase&&(o=M([o,c.pathnameBase]))}return n}function D(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);n("*"===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=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^$?{}|()[\]]/g,"\\$&").replace(/\/:(\w+)/g,((e,t)=>(a.push(t),"/([^\\/]+)")));e.endsWith("*")?(a.push("*"),o+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?o+="\\/*$":""!==e&&"/"!==e&&(o+="(?:(?=\\/|$))");return[new RegExp(o,t?void 0:"i"),a]}(e.path,e.caseSensitive,e.end),o=t.match(r);if(!o)return null;let i=o[0],s=i.replace(/(.)\/+$/,"$1"),l=o.slice(1);return{params:a.reduce(((e,t,r)=>{if("*"===t){let e=l[r]||"";s=i.slice(0,i.length-e.length).replace(/(.)\/+$/,"$1")}return e[t]=function(e,t){try{return decodeURIComponent(e)}catch(r){return n(!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}}(l[r]||"",t),e}),{}),pathname:i,pathnameBase:s,pattern:e}}function R(e){try{return decodeURI(e)}catch(t){return n(!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 A(e,t){void 0===t&&(t="/");let{pathname:r,search:a="",hash:o=""}="string"==typeof e?c(e):e,n=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:n,search:j(a),hash:k(o)}}function x(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 P(e,r,a,n){let i;void 0===n&&(n=!1),"string"==typeof e?i=c(e):(i=t({},e),o(!i.pathname||!i.pathname.includes("?"),x("?","pathname","search",i)),o(!i.pathname||!i.pathname.includes("#"),x("#","pathname","hash",i)),o(!i.search||!i.search.includes("#"),x("#","search","hash",i)));let s,l=""===e||""===i.pathname,d=l?"/":i.pathname;if(n||null==d)s=a;else{let e=r.length-1;if(d.startsWith("..")){let t=d.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let u=A(i,s),h=d&&"/"!==d&&d.endsWith("/"),f=(l||"."===d)&&a.endsWith("/");return u.pathname.endsWith("/")||!h&&!f||(u.pathname+="/"),u}const M=e=>e.join("/").replace(/\/\/+/g,"/"),L=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),j=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",k=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class C extends Error{}class U{constructor(e,t){let r;this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],o(e&&"object"==typeof e&&!Array.isArray(e),"defer() only accepts plain objects"),this.abortPromise=new Promise(((e,t)=>r=t)),this.controller=new AbortController;let a=()=>r(new C("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",a),this.controller.signal.addEventListener("abort",a),this.data=Object.entries(e).reduce(((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:this.trackPromise(r,a)})}),{}),this.done&&this.unlistenAbortSignal(),this.init=t}trackPromise(e,t){if(!(t instanceof Promise))return t;this.deferredKeys.push(e),this.pendingKeysSet.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){return this.controller.signal.aborted&&r instanceof C?(this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r)):(this.pendingKeysSet.delete(t),this.done&&this.unlistenAbortSignal(),r?(Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>a}),this.emit(!1,t),a))}emit(e,t){this.subscribers.forEach((r=>r(e,t)))}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}cancel(){this.controller.abort(),this.pendingKeysSet.forEach(((e,t)=>this.pendingKeysSet.delete(t))),this.emit(!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.pendingKeysSet.size}get unwrappedData(){return o(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]:T(a)})}),{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function T(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}class O{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 null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}const I=["post","put","patch","delete"],q=new Set(I),z=["get",...I],F=new Set(z),H=new Set([301,302,303,307,308]),B=new Set([307,308]),N={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},$={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},W={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},K=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Y=e=>({hasErrorBoundary:Boolean(e.hasErrorBoundary)});const J=Symbol("deferred");function V(e,t,r,a,o,n,i){let s,c;if(null!=n&&"path"!==i){s=[];for(let e of t)if(s.push(e),e.route.id===n){c=e;break}}else s=t,c=t[t.length-1];let d=P(o||".",S(s).map((e=>e.pathnameBase)),E(e.pathname,r)||e.pathname,"path"===i);return null==o&&(d.search=e.search,d.hash=e.hash),null!=o&&""!==o&&"."!==o||!c||!c.route.index||Ae(d.search)||(d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index"),a&&"/"!==r&&(d.pathname="/"===d.pathname?r:M([r,d.pathname])),l(d)}function G(e,t,r,a){if(!a||!function(e){return null!=e&&("formData"in e&&null!=e.formData||"body"in e&&void 0!==e.body)}(a))return{path:r};if(a.formMethod&&!we(a.formMethod))return{path:r,error:ue(405,{method:a.formMethod})};let n,i,s=()=>({path:r,error:ue(400,{type:"invalid-body"})}),d=a.formMethod||"get",u=e?d.toUpperCase():d.toLowerCase(),h=fe(r);if(void 0!==a.body){if("text/plain"===a.formEncType){if(!De(u))return s();let e="string"==typeof a.body?a.body:a.body instanceof FormData||a.body instanceof URLSearchParams?Array.from(a.body.entries()).reduce(((e,t)=>{let[r,a]=t;return""+e+r+"="+a+"\n"}),""):String(a.body);return{path:r,submission:{formMethod:u,formAction:h,formEncType:a.formEncType,formData:void 0,json:void 0,text:e}}}if("application/json"===a.formEncType){if(!De(u))return s();try{let e="string"==typeof a.body?JSON.parse(a.body):a.body;return{path:r,submission:{formMethod:u,formAction:h,formEncType:a.formEncType,formData:void 0,json:e,text:void 0}}}catch(e){return s()}}}if(o("function"==typeof FormData,"FormData is not available in this environment"),a.formData)n=oe(a.formData),i=a.formData;else if(a.body instanceof FormData)n=oe(a.body),i=a.body;else if(a.body instanceof URLSearchParams)n=a.body,i=ne(n);else if(null==a.body)n=new URLSearchParams,i=new FormData;else try{n=new URLSearchParams(a.body),i=ne(n)}catch(e){return s()}let f={formMethod:u,formAction:h,formEncType:a&&a.formEncType||"application/x-www-form-urlencoded",formData:i,json:void 0,text:void 0};if(De(f.formMethod))return{path:r,submission:f};let p=c(r);return t&&p.search&&Ae(p.search)&&n.append("index",""),p.search="?"+n,{path:l(p),submission:f}}function X(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 Q(e,r,a,o,n,i,s,l,c,d,u,h,f,m){let y=m?Object.values(m)[0]:f?Object.values(f)[0]:void 0,v=e.createURL(r.location),g=e.createURL(n),b=m?Object.keys(m)[0]:void 0,w=X(a,b).filter(((e,a)=>{if(e.route.lazy)return!0;if(null==e.route.loader)return!1;if(function(e,t,r){let a=!t||r.route.id!==t.route.id,o=void 0===e[r.route.id];return a||o}(r.loaderData,r.matches[a],e)||s.some((t=>t===e.route.id)))return!0;let n=r.matches[a],l=e;return ee(e,t({currentUrl:v,currentParams:n.params,nextUrl:g,nextParams:l.params},o,{actionResult:y,defaultShouldRevalidate:i||v.pathname+v.search===g.pathname+g.search||v.search!==g.search||Z(n,l)}))})),D=[];return c.forEach(((e,n)=>{if(!a.some((t=>t.route.id===e.routeId)))return;let s=p(u,e.path,h);if(!s)return void D.push({key:n,routeId:e.routeId,path:e.path,matches:null,match:null,controller:null});let c=r.fetchers.get(n),f=c&&"idle"!==c.state&&void 0===c.data&&!d.has(n),m=xe(s,e.path);(l.includes(n)||f||ee(m,t({currentUrl:v,currentParams:r.matches[r.matches.length-1].params,nextUrl:g,nextParams:a[a.length-1].params},o,{actionResult:y,defaultShouldRevalidate:i})))&&D.push({key:n,routeId:e.routeId,path:e.path,matches:s,match:m,controller:new AbortController})})),[w,D]}function Z(e,t){let r=e.route.path;return e.pathname!==t.pathname||null!=r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function ee(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}async function te(e,r,a){if(!e.lazy)return;let i=await e.lazy();if(!e.lazy)return;let s=a[e.id];o(s,"No route found in manifest");let l={};for(let e in i){let t=void 0!==s[e]&&"hasErrorBoundary"!==e;n(!t,'Route "'+s.id+'" has a static property "'+e+'" defined but its lazy function is also returning a value for this property. The lazy route property "'+e+'" will be ignored.'),t||h.has(e)||(l[e]=i[e])}Object.assign(s,l),Object.assign(s,t({},r(s),{lazy:void 0}))}async function re(e,t,r,a,n,i,s,l){let c,d,h;void 0===l&&(l={});let f=e=>{let a,o=new Promise(((e,t)=>a=t));return h=()=>a(),t.signal.addEventListener("abort",h),Promise.race([e({request:t,params:r.params,context:l.requestContext}),o])};try{let a=r.route[e];if(r.route.lazy)if(a){d=(await Promise.all([f(a),te(r.route,i,n)]))[0]}else{if(await te(r.route,i,n),a=r.route[e],!a){if("action"===e){let e=new URL(t.url),a=e.pathname+e.search;throw ue(405,{method:t.method,pathname:a,routeId:r.route.id})}return{type:u.data,data:void 0}}d=await f(a)}else{if(!a){let e=new URL(t.url);throw ue(404,{pathname:e.pathname+e.search})}d=await f(a)}o(void 0!==d,"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=u.error,d=e}finally{h&&t.signal.removeEventListener("abort",h)}if(ge(d)){let e,n=d.status;if(H.has(n)){let e=d.headers.get("Location");if(o(e,"Redirects returned/thrown from loaders/actions must have a Location header"),K.test(e)){if(!l.isStaticRequest){let r=new URL(t.url),a=e.startsWith("//")?new URL(r.protocol+e):new URL(e),o=null!=E(a.pathname,s);a.origin===r.origin&&o&&(e=a.pathname+a.search+a.hash)}}else e=V(new URL(t.url),a.slice(0,a.indexOf(r)+1),s,!0,e);if(l.isStaticRequest)throw d.headers.set("Location",e),d;return{type:u.redirect,status:n,location:e,revalidate:null!==d.headers.get("X-Remix-Revalidate")}}if(l.isRouteRequest)throw{type:c||u.data,response:d};let i=d.headers.get("Content-Type");return e=i&&/\bapplication\/json\b/.test(i)?await d.json():await d.text(),c===u.error?{type:c,error:new O(n,d.statusText,e),headers:d.headers}:{type:u.data,data:e,statusCode:d.status,headers:d.headers}}return c===u.error?{type:c,error:d}:ve(d)?{type:u.deferred,deferredData:d,statusCode:null==(p=d.init)?void 0:p.status,headers:(null==(m=d.init)?void 0:m.headers)&&new Headers(d.init.headers)}:{type:u.data,data:d};var p,m}function ae(e,t,r,a){let o=e.createURL(fe(t)).toString(),n={signal:r};if(a&&De(a.formMethod)){let{formMethod:e,formEncType:t}=a;n.method=e.toUpperCase(),"application/json"===t?(n.headers=new Headers({"Content-Type":t}),n.body=JSON.stringify(a.json)):"text/plain"===t?n.body=a.text:"application/x-www-form-urlencoded"===t&&a.formData?n.body=oe(a.formData):n.body=a.formData}return new Request(o,n)}function oe(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,"string"==typeof a?a:a.name);return t}function ne(e){let t=new FormData;for(let[r,a]of e.entries())t.append(r,a);return t}function ie(e,t,r,a,n){let i,s={},l=null,c=!1,d={};return r.forEach(((r,u)=>{let h=t[u].route.id;if(o(!ye(r),"Cannot handle redirect results in processLoaderData"),me(r)){let t=ce(e,h),o=r.error;a&&(o=Object.values(a)[0],a=void 0),l=l||{},null==l[t.route.id]&&(l[t.route.id]=o),s[h]=void 0,c||(c=!0,i=_(r.error)?r.error.status:500),r.headers&&(d[h]=r.headers)}else pe(r)?(n.set(h,r.deferredData),s[h]=r.deferredData.data):s[h]=r.data,null==r.statusCode||200===r.statusCode||c||(i=r.statusCode),r.headers&&(d[h]=r.headers)})),a&&(l=a,s[Object.keys(a)[0]]=void 0),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:d}}function se(e,r,a,n,i,s,l,c){let{loaderData:d,errors:u}=ie(r,a,n,i,c);for(let r=0;r<s.length;r++){let{key:a,match:n,controller:i}=s[r];o(void 0!==l&&void 0!==l[r],"Did not find corresponding fetcher result");let c=l[r];if(!i||!i.signal.aborted)if(me(c)){let r=ce(e.matches,null==n?void 0:n.route.id);u&&u[r.route.id]||(u=t({},u,{[r.route.id]:c.error})),e.fetchers.delete(a)}else if(ye(c))o(!1,"Unhandled fetcher revalidation redirect");else if(pe(c))o(!1,"Unhandled fetcher deferred data");else{let t=je(c.data);e.fetchers.set(a,t)}}return{loaderData:d,errors:u}}function le(e,r,a,o){let n=t({},r);for(let t of a){let a=t.route.id;if(r.hasOwnProperty(a)?void 0!==r[a]&&(n[a]=r[a]):void 0!==e[a]&&t.route.loader&&(n[a]=e[a]),o&&o.hasOwnProperty(a))break}return n}function ce(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 de(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 ue(e,t){let{pathname:r,routeId:a,method:o,type:n}=void 0===t?{}:t,i="Unknown Server Error",s="Unknown @remix-run/router error";return 400===e?(i="Bad Request",o&&r&&a?s="You made a "+o+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"defer-action"===n?s="defer() is not supported in actions":"invalid-body"===n&&(s="Unable to encode submission body")):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",o&&r&&a?s="You made a "+o.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':o&&(s='Invalid request method "'+o.toUpperCase()+'"')),new O(e||500,i,new Error(s),!0)}function he(e){for(let t=e.length-1;t>=0;t--){let r=e[t];if(ye(r))return r}}function fe(e){return l(t({},"string"==typeof e?c(e):e,{hash:""}))}function pe(e){return e.type===u.deferred}function me(e){return e.type===u.error}function ye(e){return(e&&e.type)===u.redirect}function ve(e){let t=e;return t&&"object"==typeof t&&"object"==typeof t.data&&"function"==typeof t.subscribe&&"function"==typeof t.cancel&&"function"==typeof t.resolveData}function ge(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function be(e){if(!ge(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}function we(e){return F.has(e.toLowerCase())}function De(e){return q.has(e.toLowerCase())}async function Re(e,t,r,a,n,i){for(let s=0;s<r.length;s++){let l=r[s],c=t[s];if(!c)continue;let d=e.find((e=>e.route.id===c.route.id)),u=null!=d&&!Z(d,c)&&void 0!==(i&&i[c.route.id]);if(pe(l)&&(n||u)){let e=a[s];o(e,"Expected an AbortSignal for revalidating fetcher deferred result"),await Ee(l,e,n).then((e=>{e&&(r[s]=e||r[s])}))}}}async function Ee(e,t,r){if(void 0===r&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:u.data,data:e.deferredData.unwrappedData}}catch(e){return{type:u.error,error:e}}return{type:u.data,data:e.deferredData.data}}}function Ae(e){return new URLSearchParams(e).getAll("index").some((e=>""===e))}function xe(e,t){let r="string"==typeof t?c(t).search:t.search;if(e[e.length-1].route.index&&Ae(r||""))return e[e.length-1];let a=S(e);return a[a.length-1]}function Se(e){let{formMethod:t,formAction:r,formEncType:a,text:o,formData:n,json:i}=e;if(t&&r&&a)return null!=o?{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:void 0,text:o}:null!=n?{formMethod:t,formAction:r,formEncType:a,formData:n,json:void 0,text:void 0}:void 0!==i?{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:i,text:void 0}:void 0}function Pe(e,t){if(t){return{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}return{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Me(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function Le(e,t){if(e){return{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t," _hasFetcherDoneAnything ":!0}}return{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t," _hasFetcherDoneAnything ":!0}}function je(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e," _hasFetcherDoneAnything ":!0}}e.AbortedDeferredError=C,e.ErrorResponse=O,e.IDLE_BLOCKER=W,e.IDLE_FETCHER=$,e.IDLE_NAVIGATION=N,e.UNSAFE_DEFERRED_SYMBOL=J,e.UNSAFE_DeferredData=U,e.UNSAFE_convertRoutesToDataRoutes=f,e.UNSAFE_getPathContributingMatches=S,e.UNSAFE_invariant=o,e.UNSAFE_warning=n,e.createBrowserHistory=function(e){return void 0===e&&(e={}),d((function(e,t){let{pathname:r,search:a,hash:o}=e.location;return s("",{pathname:r,search:a,hash:o},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={}),d((function(e,t){let{pathname:r="/",search:a="",hash:o=""}=c(e.location.hash.substr(1));return s("",{pathname:r,search:a,hash:o},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){n("/"===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:o,v5Compat:i=!1}=t;r=a.map(((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0)));let d=f(null==o?r.length-1:o),u=e.Action.Pop,h=null;function f(e){return Math.min(Math.max(e,0),r.length-1)}function p(){return r[d]}function m(e,t,a){void 0===t&&(t=null);let o=s(r?p().pathname:"/",e,t,a);return n("/"===o.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),o}function y(e){return"string"==typeof e?e:l(e)}return{get index(){return d},get action(){return u},get location(){return p()},createHref:y,createURL:e=>new URL(y(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?c(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(t,a){u=e.Action.Push;let o=m(t,a);d+=1,r.splice(d,r.length,o),i&&h&&h({action:u,location:o,delta:1})},replace(t,a){u=e.Action.Replace;let o=m(t,a);r[d]=o,i&&h&&h({action:u,location:o,delta:0})},go(t){u=e.Action.Pop;let a=f(d+t),o=r[a];d=a,h&&h({action:u,location:o,delta:t})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(r){const a=r.window?r.window:"undefined"!=typeof window?window:void 0,i=void 0!==a&&void 0!==a.document&&void 0!==a.document.createElement,l=!i;let c;if(o(r.routes.length>0,"You must provide a non-empty routes array to createRouter"),r.mapRouteProperties)c=r.mapRouteProperties;else if(r.detectErrorBoundary){let e=r.detectErrorBoundary;c=t=>({hasErrorBoundary:e(t)})}else c=Y;let d,h={},m=f(r.routes,c,void 0,h),y=r.basename||"/",v=t({v7_normalizeFormMethod:!1,v7_prependBasename:!1},r.future),g=null,b=new Set,w=null,D=null,R=null,A=null!=r.hydrationData,x=p(m,r.history.location,y),S=null;if(null==x){let e=ue(404,{pathname:r.history.location.pathname}),{matches:t,route:a}=de(m);x=t,S={[a.id]:e}}let P,M,L=!(x.some((e=>e.route.lazy))||x.some((e=>e.route.loader))&&null==r.hydrationData),j={historyAction:r.history.action,location:r.history.location,matches:x,initialized:L,navigation:N,restoreScrollPosition:null==r.hydrationData&&null,preventScrollReset:!1,revalidation:"idle",loaderData:r.hydrationData&&r.hydrationData.loaderData||{},actionData:r.hydrationData&&r.hydrationData.actionData||null,errors:r.hydrationData&&r.hydrationData.errors||S,fetchers:new Map,blockers:new Map},k=e.Action.Pop,C=!1,U=!1,T=!1,O=[],_=[],I=new Map,q=0,z=-1,F=new Map,H=new Set,J=new Map,X=new Map,Z=new Map,ee=!1;function te(e){j=t({},j,e),b.forEach((e=>e(j)))}function oe(a,o){var n,i;let s,l=null!=j.actionData&&null!=j.navigation.formMethod&&De(j.navigation.formMethod)&&"loading"===j.navigation.state&&!0!==(null==(n=a.state)?void 0:n._isRedirect);s=o.actionData?Object.keys(o.actionData).length>0?o.actionData:null:l?j.actionData:null;let c=o.loaderData?le(j.loaderData,o.loaderData,o.matches||[],o.errors):j.loaderData,u=new Map;Z.clear();let h=!0===C||null!=j.navigation.formMethod&&De(j.navigation.formMethod)&&!0!==(null==(i=a.state)?void 0:i._isRedirect);d&&(m=d,d=void 0),U||k===e.Action.Pop||(k===e.Action.Push?r.history.push(a,a.state):k===e.Action.Replace&&r.history.replace(a,a.state)),te(t({},o,{actionData:s,loaderData:c,historyAction:k,location:a,initialized:!0,navigation:N,revalidation:"idle",restoreScrollPosition:ze(a,o.matches||j.matches),preventScrollReset:h,blockers:u})),k=e.Action.Pop,C=!1,U=!1,T=!1,O=[],_=[]}async function ne(a,o,n){M&&M.abort(),M=null,k=a,U=!0===(n&&n.startUninterruptedRevalidation),function(e,t){if(w&&R){let r=qe(e,t);w[r]=R()}}(j.location,j.matches),C=!0===(n&&n.preventScrollReset);let i=d||m,s=n&&n.overrideNavigation,l=p(i,o,y);if(!l){let e=ue(404,{pathname:o.pathname}),{matches:t,route:r}=de(i);return Ie(),void oe(o,{matches:t,loaderData:{},errors:{[r.id]:e}})}if(j.initialized&&!T&&function(e,t){if(e.pathname!==t.pathname||e.search!==t.search)return!1;if(""===e.hash)return""!==t.hash;if(e.hash===t.hash)return!0;if(""!==t.hash)return!0;return!1}(j.location,o)&&!(n&&n.submission&&De(n.submission.formMethod)))return void oe(o,{matches:l});M=new AbortController;let f,v,g=ae(r.history,o,M.signal,n&&n.submission);if(n&&n.pendingError)v={[ce(l).route.id]:n.pendingError};else if(n&&n.submission&&De(n.submission.formMethod)){let t=await async function(t,r,a,o,n){void 0===n&&(n={});let i;ge(),te({navigation:Me(r,a)});let s=xe(o,r);if(s.route.action||s.route.lazy){if(i=await re("action",t,s,o,h,c,y),t.signal.aborted)return{shortCircuited:!0}}else i={type:u.error,error:ue(405,{method:t.method,pathname:r.pathname,routeId:s.route.id})};if(ye(i)){let e;return e=n&&null!=n.replace?n.replace:i.location===j.location.pathname+j.location.search,await fe(j,i,{submission:a,replace:e}),{shortCircuited:!0}}if(me(i)){let t=ce(o,s.route.id);return!0!==(n&&n.replace)&&(k=e.Action.Push),{pendingActionData:{},pendingActionError:{[t.route.id]:i.error}}}if(pe(i))throw ue(400,{type:"defer-action"});return{pendingActionData:{[s.route.id]:i.data}}}(g,o,n.submission,l,{replace:n.replace});if(t.shortCircuited)return;f=t.pendingActionData,v=t.pendingActionError,s=Pe(o,n.submission),g=new Request(g.url,{signal:g.signal})}let{shortCircuited:b,loaderData:D,errors:E}=await async function(e,a,o,n,i,s,l,c,u){let h=n||Pe(a,i),f=i||s||Se(h),p=d||m,[v,g]=Q(r.history,j,o,f,a,T,O,_,J,H,p,y,c,u);if(Ie((e=>!(o&&o.some((t=>t.route.id===e)))||v&&v.some((t=>t.route.id===e)))),0===v.length&&0===g.length){let e=Ce();return oe(a,t({matches:o,loaderData:{},errors:u||null},c?{actionData:c}:{},e?{fetchers:new Map(j.fetchers)}:{})),{shortCircuited:!0}}if(!U){g.forEach((e=>{let t=j.fetchers.get(e.key),r=Le(void 0,t?t.data:void 0);j.fetchers.set(e.key,r)}));let e=c||j.actionData;te(t({navigation:h},e?0===Object.keys(e).length?{actionData:null}:{actionData:e}:{},g.length>0?{fetchers:new Map(j.fetchers)}:{}))}z=++q,g.forEach((e=>{I.has(e.key)&&Ae(e.key),e.controller&&I.set(e.key,e.controller)}));let b=()=>g.forEach((e=>Ae(e.key)));M&&M.signal.addEventListener("abort",b);let{results:w,loaderResults:D,fetcherResults:R}=await ve(j.matches,o,v,g,e);if(e.signal.aborted)return{shortCircuited:!0};M&&M.signal.removeEventListener("abort",b);g.forEach((e=>I.delete(e.key)));let E=he(w);if(E)return await fe(j,E,{replace:l}),{shortCircuited:!0};let{loaderData:A,errors:x}=se(j,o,v,D,u,g,R,X);X.forEach(((e,t)=>{e.subscribe((r=>{(r||e.done)&&X.delete(t)}))}));let S=Ce(),P=Ue(z),L=S||P||g.length>0;return t({loaderData:A,errors:x},L?{fetchers:new Map(j.fetchers)}:{})}(g,o,l,s,n&&n.submission,n&&n.fetcherSubmission,n&&n.replace,f,v);b||(M=null,oe(o,t({matches:l},f?{actionData:f}:{},{loaderData:D,errors:E})))}function ie(e){return j.fetchers.get(e)||$}async function fe(n,l,c){let{submission:d,replace:u,isFetchActionRedirect:h}=void 0===c?{}:c;l.revalidate&&(T=!0);let f=s(n.location,l.location,t({_isRedirect:!0},h?{_isFetchActionRedirect:!0}:{}));if(o(f,"Expected a location on the redirect navigation"),K.test(l.location)&&i){let e=r.history.createURL(l.location),t=null==E(e.pathname,y);if(a.location.origin!==e.origin||t)return void(u?a.location.replace(l.location):a.location.assign(l.location))}M=null;let p=!0===u?e.Action.Replace:e.Action.Push,m=d||Se(n.navigation);if(B.has(l.status)&&m&&De(m.formMethod))await ne(p,f,{submission:t({},m,{formAction:l.location}),preventScrollReset:C});else if(h)await ne(p,f,{overrideNavigation:Pe(f),fetcherSubmission:m,preventScrollReset:C});else{let e=Pe(f,m);await ne(p,f,{overrideNavigation:e,preventScrollReset:C})}}async function ve(e,t,a,o,n){let i=await Promise.all([...a.map((e=>re("loader",n,e,t,h,c,y))),...o.map((e=>{if(e.matches&&e.match&&e.controller)return re("loader",ae(r.history,e.path,e.controller.signal),e.match,e.matches,h,c,y);return{type:u.error,error:ue(404,{pathname:e.path})}}))]),s=i.slice(0,a.length),l=i.slice(a.length);return await Promise.all([Re(e,a,s,s.map((()=>n.signal)),!1,j.loaderData),Re(e,o.map((e=>e.match)),l,o.map((e=>e.controller?e.controller.signal:null)),!0)]),{results:i,loaderResults:s,fetcherResults:l}}function ge(){T=!0,O.push(...Ie()),J.forEach(((e,t)=>{I.has(t)&&(_.push(t),Ae(t))}))}function be(e,t,r){let a=ce(j.matches,t);we(e),te({errors:{[a.route.id]:r},fetchers:new Map(j.fetchers)})}function we(e){let t=j.fetchers.get(e);!I.has(e)||t&&"loading"===t.state&&F.has(e)||Ae(e),J.delete(e),F.delete(e),H.delete(e),j.fetchers.delete(e)}function Ae(e){let t=I.get(e);o(t,"Expected fetch controller: "+e),t.abort(),I.delete(e)}function ke(e){for(let t of e){let e=je(ie(t).data);j.fetchers.set(t,e)}}function Ce(){let e=[],t=!1;for(let r of H){let a=j.fetchers.get(r);o(a,"Expected fetcher: "+r),"loading"===a.state&&(H.delete(r),e.push(r),t=!0)}return ke(e),t}function Ue(e){let t=[];for(let[r,a]of F)if(a<e){let e=j.fetchers.get(r);o(e,"Expected fetcher: "+r),"loading"===e.state&&(Ae(r),F.delete(r),t.push(r))}return ke(t),t.length>0}function Te(e){j.blockers.delete(e),Z.delete(e)}function Oe(e,t){let r=j.blockers.get(e)||W;o("unblocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"proceeding"===t.state||"blocked"===r.state&&"unblocked"===t.state||"proceeding"===r.state&&"unblocked"===t.state,"Invalid blocker state transition: "+r.state+" -> "+t.state);let a=new Map(j.blockers);a.set(e,t),te({blockers:a})}function _e(e){let{currentLocation:t,nextLocation:r,historyAction:a}=e;if(0===Z.size)return;Z.size>1&&n(!1,"A router only supports one blocker at a time");let o=Array.from(Z.entries()),[i,s]=o[o.length-1],l=j.blockers.get(i);return l&&"proceeding"===l.state?void 0:s({currentLocation:t,nextLocation:r,historyAction:a})?i:void 0}function Ie(e){let t=[];return X.forEach(((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),X.delete(a))})),t}function qe(e,t){if(D){return D(e,t.map((e=>function(e,t){let{route:r,pathname:a,params:o}=e;return{id:r.id,pathname:a,params:o,data:t[r.id],handle:r.handle}}(e,j.loaderData))))||e.key}return e.key}function ze(e,t){if(w){let r=qe(e,t),a=w[r];if("number"==typeof a)return a}return null}return P={get basename(){return y},get state(){return j},get routes(){return m},initialize:function(){return g=r.history.listen((e=>{let{action:t,location:a,delta:o}=e;if(ee)return void(ee=!1);n(0===Z.size||null!=o,"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 i=_e({currentLocation:j.location,nextLocation:a,historyAction:t});return i&&null!=o?(ee=!0,r.history.go(-1*o),void Oe(i,{state:"blocked",location:a,proceed(){Oe(i,{state:"proceeding",proceed:void 0,reset:void 0,location:a}),r.history.go(o)},reset(){let e=new Map(j.blockers);e.set(i,W),te({blockers:e})}})):ne(t,a)})),j.initialized||ne(e.Action.Pop,j.location),P},subscribe:function(e){return b.add(e),()=>b.delete(e)},enableScrollRestoration:function(e,t,r){if(w=e,R=t,D=r||null,!A&&j.navigation===N){A=!0;let e=ze(j.location,j.matches);null!=e&&te({restoreScrollPosition:e})}return()=>{w=null,R=null,D=null}},navigate:async function a(o,n){if("number"==typeof o)return void r.history.go(o);let i=V(j.location,j.matches,y,v.v7_prependBasename,o,null==n?void 0:n.fromRouteId,null==n?void 0:n.relative),{path:l,submission:c,error:d}=G(v.v7_normalizeFormMethod,!1,i,n),u=j.location,h=s(j.location,l,n&&n.state);h=t({},h,r.history.encodeLocation(h));let f=n&&null!=n.replace?n.replace:void 0,p=e.Action.Push;!0===f?p=e.Action.Replace:!1===f||null!=c&&De(c.formMethod)&&c.formAction===j.location.pathname+j.location.search&&(p=e.Action.Replace);let m=n&&"preventScrollReset"in n?!0===n.preventScrollReset:void 0,g=_e({currentLocation:u,nextLocation:h,historyAction:p});if(!g)return await ne(p,h,{submission:c,pendingError:d,preventScrollReset:m,replace:n&&n.replace});Oe(g,{state:"blocked",location:h,proceed(){Oe(g,{state:"proceeding",proceed:void 0,reset:void 0,location:h}),a(o,n)},reset(){let e=new Map(j.blockers);e.set(g,W),te({blockers:e})}})},fetch:function(e,a,n,i){if(l)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.");I.has(e)&&Ae(e);let s=d||m,u=V(j.location,j.matches,y,v.v7_prependBasename,n,a,null==i?void 0:i.relative),f=p(s,u,y);if(!f)return void be(e,a,ue(404,{pathname:u}));let{path:g,submission:b,error:w}=G(v.v7_normalizeFormMethod,!0,u,i);if(w)return void be(e,a,w);let D=xe(f,g);C=!0===(i&&i.preventScrollReset),b&&De(b.formMethod)?async function(e,a,n,i,s,l){if(ge(),J.delete(e),!i.route.action&&!i.route.lazy){let t=ue(405,{method:l.formMethod,pathname:n,routeId:a});return void be(e,a,t)}let u=j.fetchers.get(e),f=function(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0," _hasFetcherDoneAnything ":!0}}(l,u);j.fetchers.set(e,f),te({fetchers:new Map(j.fetchers)});let v=new AbortController,g=ae(r.history,n,v.signal,l);I.set(e,v);let b=await re("action",g,i,s,h,c,y);if(g.signal.aborted)return void(I.get(e)===v&&I.delete(e));if(ye(b)){I.delete(e),H.add(e);let t=Le(l);return j.fetchers.set(e,t),te({fetchers:new Map(j.fetchers)}),fe(j,b,{submission:l,isFetchActionRedirect:!0})}if(me(b))return void be(e,a,b.error);if(pe(b))throw ue(400,{type:"defer-action"});let w=j.navigation.location||j.location,D=ae(r.history,w,v.signal),R=d||m,E="idle"!==j.navigation.state?p(R,j.navigation.location,y):j.matches;o(E,"Didn't find any matches after fetcher action");let A=++q;F.set(e,A);let x=Le(l,b.data);j.fetchers.set(e,x);let[S,P]=Q(r.history,j,E,l,w,T,O,_,J,H,R,y,{[i.route.id]:b.data},void 0);P.filter((t=>t.key!==e)).forEach((e=>{let t=e.key,r=j.fetchers.get(t),a=Le(void 0,r?r.data:void 0);j.fetchers.set(t,a),I.has(t)&&Ae(t),e.controller&&I.set(t,e.controller)})),te({fetchers:new Map(j.fetchers)});let L=()=>P.forEach((e=>Ae(e.key)));v.signal.addEventListener("abort",L);let{results:C,loaderResults:U,fetcherResults:B}=await ve(j.matches,E,S,P,D);if(v.signal.aborted)return;v.signal.removeEventListener("abort",L),F.delete(e),I.delete(e),P.forEach((e=>I.delete(e.key)));let N=he(C);if(N)return fe(j,N);let{loaderData:$,errors:W}=se(j,j.matches,S,U,void 0,P,B,X);if(j.fetchers.has(e)){let t=je(b.data);j.fetchers.set(e,t)}let K=Ue(A);"loading"===j.navigation.state&&A>z?(o(k,"Expected pending action"),M&&M.abort(),oe(j.navigation.location,{matches:E,loaderData:$,errors:W,fetchers:new Map(j.fetchers)})):(te(t({errors:W,loaderData:le(j.loaderData,$,E,W)},K||P.length>0?{fetchers:new Map(j.fetchers)}:{})),T=!1)}(e,a,g,D,f,b):(J.set(e,{routeId:a,path:g}),async function(e,t,a,n,i,s){let l=j.fetchers.get(e),d=Le(s,l?l.data:void 0);j.fetchers.set(e,d),te({fetchers:new Map(j.fetchers)});let u=new AbortController,f=ae(r.history,a,u.signal);I.set(e,u);let p=await re("loader",f,n,i,h,c,y);pe(p)&&(p=await Ee(p,f.signal,!0)||p);I.get(e)===u&&I.delete(e);if(f.signal.aborted)return;if(ye(p))return H.add(e),void await fe(j,p);if(me(p)){let r=ce(j.matches,t);return j.fetchers.delete(e),void te({fetchers:new Map(j.fetchers),errors:{[r.route.id]:p.error}})}o(!pe(p),"Unhandled fetcher deferred data");let m=je(p.data);j.fetchers.set(e,m),te({fetchers:new Map(j.fetchers)})}(e,a,g,D,f,b))},revalidate:function(){ge(),te({revalidation:"loading"}),"submitting"!==j.navigation.state&&("idle"!==j.navigation.state?ne(k||j.historyAction,j.navigation.location,{overrideNavigation:j.navigation}):ne(j.historyAction,j.location,{startUninterruptedRevalidation:!0}))},createHref:e=>r.history.createHref(e),encodeLocation:e=>r.history.encodeLocation(e),getFetcher:ie,deleteFetcher:we,dispose:function(){g&&g(),b.clear(),M&&M.abort(),j.fetchers.forEach(((e,t)=>we(t))),j.blockers.forEach(((e,t)=>Te(t)))},getBlocker:function(e,t){let r=j.blockers.get(e)||W;return Z.get(e)!==t&&Z.set(e,t),r},deleteBlocker:Te,_internalFetchControllers:I,_internalActiveDeferreds:X,_internalSetRoutes:function(e){h={},d=f(e,c,void 0,h)}},P},e.createStaticHandler=function(e,r){o(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let a,n={},i=(r?r.basename:null)||"/";if(null!=r&&r.mapRouteProperties)a=r.mapRouteProperties;else if(null!=r&&r.detectErrorBoundary){let e=r.detectErrorBoundary;a=t=>({hasErrorBoundary:e(t)})}else a=Y;let c=f(e,a,void 0,n);async function d(e,r,s,l,c){o(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(De(e.method.toLowerCase())){let o=await async function(e,r,o,s,l){let c;if(o.route.action||o.route.lazy){if(c=await re("action",e,o,r,n,a,i,{isStaticRequest:!0,isRouteRequest:l,requestContext:s}),e.signal.aborted){throw new Error((l?"queryRoute":"query")+"() call aborted")}}else{let t=ue(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:o.route.id});if(l)throw t;c={type:u.error,error:t}}if(ye(c))throw new Response(null,{status:c.status,headers:{Location:c.location}});if(pe(c)){let e=ue(400,{type:"defer-action"});if(l)throw e;c={type:u.error,error:e}}if(l){if(me(c))throw c.error;return{matches:[o],loaderData:{},actionData:{[o.route.id]:c.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(me(c)){let a=ce(r,o.route.id);return t({},await h(e,r,s,void 0,{[a.route.id]:c.error}),{statusCode:_(c.error)?c.error.status:500,actionData:null,actionHeaders:t({},c.headers?{[o.route.id]:c.headers}:{})})}let d=new Request(e.url,{headers:e.headers,redirect:e.redirect,signal:e.signal});return t({},await h(d,r,s),c.statusCode?{statusCode:c.statusCode}:{},{actionData:{[o.route.id]:c.data},actionHeaders:t({},c.headers?{[o.route.id]:c.headers}:{})})}(e,s,c||xe(s,r),l,null!=c);return o}let o=await h(e,s,l,c);return ge(o)?o:t({},o,{actionData:null,actionHeaders:{}})}catch(e){if((d=e)&&ge(d.response)&&(d.type===u.data||u.error)){if(e.type===u.error&&!be(e.response))throw e.response;return e.response}if(be(e))return e;throw e}var d}async function h(e,r,o,s,l){let c=null!=s;if(c&&(null==s||!s.route.loader)&&(null==s||!s.route.lazy))throw ue(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==s?void 0:s.route.id});let d=(s?[s]:X(r,Object.keys(l||{})[0])).filter((e=>e.route.loader||e.route.lazy));if(0===d.length)return{matches:r,loaderData:r.reduce(((e,t)=>Object.assign(e,{[t.route.id]:null})),{}),errors:l||null,statusCode:200,loaderHeaders:{},activeDeferreds:null};let u=await Promise.all([...d.map((t=>re("loader",e,t,r,n,a,i,{isStaticRequest:!0,isRouteRequest:c,requestContext:o})))]);if(e.signal.aborted){throw new Error((c?"queryRoute":"query")+"() call aborted")}let h=new Map,f=ie(r,d,u,l,h),p=new Set(d.map((e=>e.route.id)));return r.forEach((e=>{p.has(e.route.id)||(f.loaderData[e.route.id]=null)})),t({},f,{matches:r,activeDeferreds:h.size>0?Object.fromEntries(h.entries()):null})}return{dataRoutes:c,query:async function(e,r){let{requestContext:a}=void 0===r?{}:r,o=new URL(e.url),n=e.method,u=s("",l(o),null,"default"),h=p(c,u,i);if(!we(n)&&"HEAD"!==n){let e=ue(405,{method:n}),{matches:t,route:r}=de(c);return{basename:i,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(!h){let e=ue(404,{pathname:u.pathname}),{matches:t,route:r}=de(c);return{basename:i,location:u,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let f=await d(e,u,h,a);return ge(f)?f:t({location:u,basename:i},f)},queryRoute:async function(e,t){let{routeId:r,requestContext:a}=void 0===t?{}:t,o=new URL(e.url),n=e.method,u=s("",l(o),null,"default"),h=p(c,u,i);if(!we(n)&&"HEAD"!==n&&"OPTIONS"!==n)throw ue(405,{method:n});if(!h)throw ue(404,{pathname:u.pathname});let f=r?h.find((e=>e.route.id===r)):xe(h,u);if(r&&!f)throw ue(403,{pathname:u.pathname,routeId:r});if(!f)throw ue(404,{pathname:u.pathname});let m=await d(e,u,h,a,f);if(ge(m))return m;let y=m.errors?Object.values(m.errors)[0]:void 0;if(void 0!==y)throw y;if(m.actionData)return Object.values(m.actionData)[0];if(m.loaderData){var v;let e=Object.values(m.loaderData)[0];return null!=(v=m.activeDeferreds)&&v[f.route.id]&&(e[J]=m.activeDeferreds[f.route.id]),e}}}},e.defer=function(e,t){return void 0===t&&(t={}),new U(e,"number"==typeof t?{status:t}:t)},e.generatePath=function(e,t){void 0===t&&(t={});let r=e;r.endsWith("*")&&"*"!==r&&!r.endsWith("/*")&&(n(!1,'Route path "'+r+'" will be treated as if it were "'+r.replace(/\*$/,"/*")+'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "'+r.replace(/\*$/,"/*")+'".'),r=r.replace(/\*$/,"/*"));const a=r.startsWith("/")?"/":"",i=e=>null==e?"":"string"==typeof e?e:String(e);return a+r.split(/\/+/).map(((e,r,a)=>{if(r===a.length-1&&"*"===e){return i(t["*"])}const n=e.match(/^:(\w+)(\??)$/);if(n){const[,e,r]=n;let a=t[e];return o("?"===r||null!=a,'Missing ":'+e+'" param'),i(a)}return e.replace(/\?$/g,"")})).filter((e=>!!e)).join("/")},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?c(e).pathname:e.pathname},e.isDeferredData=ve,e.isRouteErrorResponse=_,e.joinPaths=M,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,o=new Headers(a.headers);return o.has("Content-Type")||o.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:o}))},e.matchPath=D,e.matchRoutes=p,e.normalizePathname=L,e.parsePath=c,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 o=new Headers(a.headers);return o.set("Location",e),new Response(null,t({},a,{headers:o}))},e.resolvePath=A,e.resolveTo=P,e.stripBasename=E,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
12
12
|
//# sourceMappingURL=router.umd.min.js.map
|