@tanstack/router-core 0.0.1-beta.5 → 0.0.1-beta.50

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.
Files changed (71) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/actions.js +94 -0
  3. package/build/cjs/actions.js.map +1 -0
  4. package/build/cjs/history.js +163 -0
  5. package/build/cjs/history.js.map +1 -0
  6. package/build/cjs/{packages/router-core/src/index.js → index.js} +26 -11
  7. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  8. package/build/cjs/interop.js +175 -0
  9. package/build/cjs/interop.js.map +1 -0
  10. package/build/cjs/{packages/router-core/src/path.js → path.js} +23 -48
  11. package/build/cjs/path.js.map +1 -0
  12. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +8 -13
  13. package/build/cjs/qss.js.map +1 -0
  14. package/build/cjs/route.js +33 -0
  15. package/build/cjs/route.js.map +1 -0
  16. package/build/cjs/{packages/router-core/src/routeConfig.js → routeConfig.js} +13 -18
  17. package/build/cjs/routeConfig.js.map +1 -0
  18. package/build/cjs/routeMatch.js +237 -0
  19. package/build/cjs/routeMatch.js.map +1 -0
  20. package/build/cjs/router.js +821 -0
  21. package/build/cjs/router.js.map +1 -0
  22. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +10 -12
  23. package/build/cjs/searchParams.js.map +1 -0
  24. package/build/cjs/store.js +54 -0
  25. package/build/cjs/store.js.map +1 -0
  26. package/build/cjs/utils.js +47 -0
  27. package/build/cjs/utils.js.map +1 -0
  28. package/build/esm/index.js +1384 -2059
  29. package/build/esm/index.js.map +1 -1
  30. package/build/stats-html.html +59 -49
  31. package/build/stats-react.json +248 -193
  32. package/build/types/index.d.ts +385 -317
  33. package/build/umd/index.development.js +1486 -2142
  34. package/build/umd/index.development.js.map +1 -1
  35. package/build/umd/index.production.js +1 -1
  36. package/build/umd/index.production.js.map +1 -1
  37. package/package.json +6 -4
  38. package/src/actions.ts +157 -0
  39. package/src/frameworks.ts +2 -2
  40. package/src/history.ts +199 -0
  41. package/src/index.ts +4 -7
  42. package/src/interop.ts +169 -0
  43. package/src/link.ts +87 -44
  44. package/src/path.ts +12 -8
  45. package/src/route.ts +36 -229
  46. package/src/routeConfig.ts +99 -102
  47. package/src/routeInfo.ts +28 -25
  48. package/src/routeMatch.ts +294 -322
  49. package/src/router.ts +1047 -884
  50. package/src/store.ts +52 -0
  51. package/src/utils.ts +14 -72
  52. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  53. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  54. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  55. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  56. package/build/cjs/node_modules/history/index.js +0 -815
  57. package/build/cjs/node_modules/history/index.js.map +0 -1
  58. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  59. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  60. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  61. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  62. package/build/cjs/packages/router-core/src/route.js +0 -161
  63. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  64. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  65. package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
  66. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  67. package/build/cjs/packages/router-core/src/router.js +0 -797
  68. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  69. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  70. package/build/cjs/packages/router-core/src/utils.js +0 -118
  71. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={})}(this,(function(t){"use strict";function e(){return e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},e.apply(this,arguments)}var a;!function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"}(a||(a={}));var n="beforeunload",o="popstate";function r(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=i.location,e=t.pathname,a=t.search,n=t.hash,o=s.state||{};return[o.idx,{pathname:e,search:a,hash:n,state:o.usr||null,key:o.key||"default"}]}var f=null;i.addEventListener(o,(function(){if(f)P.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(P.length){if(null!=n){var r=g-n;r&&(f={action:t,location:o,retry:function(){M(-1*r)}},M(r))}}else R(t)}}));var m=a.Pop,v=p(),g=v[0],y=v[1],_=c(),P=c();function b(t){return"string"==typeof t?t:h(t)}function w(t,a){return void 0===a&&(a=null),e({pathname:y.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function A(t,e){return[{usr:t.state,key:t.key,idx:e},b(t)]}function x(t,e,a){return!P.length||(P.call({action:t,location:e,retry:a}),!1)}function R(t){m=t;var e=p();g=e[0],y=e[1],_.call({action:m,location:y})}function M(t){s.go(t)}null==g&&(g=0,s.replaceState(e({},s.state,{idx:g}),""));var S={get action(){return m},get location(){return y},createHref:b,push:function t(e,n){var o=a.Push,r=w(e,n);if(x(o,r,(function(){t(e,n)}))){var l=A(r,g+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}R(o)}},replace:function t(e,n){var o=a.Replace,r=w(e,n);if(x(o,r,(function(){t(e,n)}))){var i=A(r,g),l=i[0],c=i[1];s.replaceState(l,"",c),R(o)}},go:M,back:function(){M(-1)},forward:function(){M(1)},listen:function(t){return _.push(t)},block:function(t){var e=P.push(t);return 1===P.length&&i.addEventListener(n,l),function(){e(),P.length||i.removeEventListener(n,l)}}};return S}function i(t){void 0===t&&(t={});var n=t,o=n.initialEntries,r=void 0===o?["/"]:o,i=n.initialIndex,l=r.map((function(t){return e({pathname:"/",search:"",hash:"",state:null,key:u()},"string"==typeof t?d(t):t)})),p=s(null==i?l.length-1:i,0,l.length-1),f=a.Pop,m=l[p],v=c(),g=c();function y(t,a){return void 0===a&&(a=null),e({pathname:m.pathname,search:"",hash:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function _(t,e,a){return!g.length||(g.call({action:t,location:e,retry:a}),!1)}function P(t,e){f=t,m=e,v.call({action:f,location:m})}function b(t){var e=s(p+t,0,l.length-1),n=a.Pop,o=l[e];_(n,o,(function(){b(t)}))&&(p=e,P(n,o))}var w={get index(){return p},get action(){return f},get location(){return m},createHref:function(t){return"string"==typeof t?t:h(t)},push:function t(e,n){var o=a.Push,r=y(e,n);_(o,r,(function(){t(e,n)}))&&(p+=1,l.splice(p,l.length,r),P(o,r))},replace:function t(e,n){var o=a.Replace,r=y(e,n);_(o,r,(function(){t(e,n)}))&&(l[p]=r,P(o,r))},go:b,back:function(){b(-1)},forward:function(){b(1)},listen:function(t){return v.push(t)},block:function(t){return g.push(t)}};return w}function s(t,e,a){return Math.min(Math.max(t,e),a)}function l(t){t.preventDefault(),t.returnValue=""}function c(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter((function(t){return t!==e}))}},call:function(e){t.forEach((function(t){return t&&t(e)}))}}}function u(){return Math.random().toString(36).substr(2,8)}function h(t){var e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,i=void 0===r?"":r;return o&&"?"!==o&&(a+="?"===o.charAt(0)?o:"?"+o),i&&"#"!==i&&(a+="#"===i.charAt(0)?i:"#"+i),a}function d(t){var e={};if(t){var a=t.indexOf("#");a>=0&&(e.hash=t.substr(a),t=t.substr(0,a));var n=t.indexOf("?");n>=0&&(e.search=t.substr(n),t=t.substr(0,n)),t&&(e.pathname=t)}return e}function p(t,e){if(!t)throw new Error("Invariant failed")}function f(t,e){if(t===e)return t;const a=Array.isArray(t)&&Array.isArray(e);if(a||m(t)&&m(e)){const n=a?t.length:Object.keys(t).length,o=a?e:Object.keys(e),r=o.length,i=a?[]:{};let s=0;for(let n=0;n<r;n++){const r=a?n:o[n];i[r]=f(t[r],e[r]),i[r]===t[r]&&s++}return n===r&&s===n?t:i}return e}function m(t){if(!v(t))return!1;const e=t.constructor;if(void 0===e)return!0;const a=e.prototype;return!!v(a)&&!!a.hasOwnProperty("isPrototypeOf")}function v(t){return"[object Object]"===Object.prototype.toString.call(t)}function g(t){return t[t.length-1]}function y(t,e){return"function"==typeof t?t(e):t}function _(t){return P(t.filter(Boolean).join("/"))}function P(t){return t.replace(/\/{2,}/g,"/")}function b(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function w(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function A(t){return w(b(t))}function x(t,e,a){e=e.replace(new RegExp("^"+t),"/"),a=a.replace(new RegExp("^"+t),"/");let n=R(e);const o=R(a);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&n.push(t):n=[t];else if(".."===t.value){var a;n.length>1&&"/"===(null==(a=g(n))?void 0:a.value)&&n.pop(),n.pop()}else{if("."===t.value)return;n.push(t)}}));return P(_([t,...n.map((t=>t.value))]))}function R(t){if(!t)return[];const e=[];if("/"===(t=P(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const a=t.split("/").filter(Boolean);return e.push(...a.map((t=>t.startsWith("*")?{type:"wildcard",value:t}:":"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function M(t,e,a){return _(R(t).map((t=>{return"*"!==t.value||a?"param"===t.type?null!=(n=e[t.value.substring(1)])?n:"":t.value:"";var n})))}function S(t,e){const a=I(t,e);if(!e.to||a)return null!=a?a:{}}function I(t,e){var a;const n=R(t),o=R(""+(null!=(a=e.to)?a:"*")),r={};return(()=>{for(let t=0;t<Math.max(n.length,o.length);t++){const a=n[t],i=o[t],s=t===o.length-1,l=t===n.length-1;if(i){if("wildcard"===i.type)return!(null==a||!a.value)&&(r["*"]=_(n.slice(t).map((t=>t.value))),!0);if("pathname"===i.type){if("/"===i.value&&(null==a||!a.value))return!0;if(a)if(e.caseSensitive){if(i.value!==a.value)return!1}else if(i.value.toLowerCase()!==a.value.toLowerCase())return!1}if(!a)return!1;if("param"===i.type){if("/"===(null==a?void 0:a.value))return!1;a.value.startsWith(":")||(r[i.value.substring(1)]=a.value)}}if(s&&!l)return!!e.fuzzy}return!0})()?r:void 0}function L(t,e){var a,n,o,r="";for(a in t)if(void 0!==(o=t[a]))if(Array.isArray(o))for(n=0;n<o.length;n++)r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o[n]);else r&&(r+="&"),r+=encodeURIComponent(a)+"="+encodeURIComponent(o);return(e||"")+r}function E(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function C(t){for(var e,a,n={},o=t.split("&");e=o.shift();)void 0!==n[a=(e=e.split("=")).shift()]?n[a]=[].concat(n[a],E(e.shift())):n[a]=E(e.shift());return n}function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var a=arguments[e];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(t[n]=a[n])}return t},k.apply(this,arguments)}function T(t,e,a,n){const{id:o,routeId:r,path:i,fullPath:s}=t,l=n.state.actions[o]||(n.state.actions[o]={pending:[],submit:async(t,e)=>{var a;if(!u)return;const o=null==(a=null==e?void 0:e.invalidate)||a,r={submittedAt:Date.now(),status:"pending",submission:t};l.current=r,l.latest=r,l.pending.push(r),n.state=k({},n.state,{currentAction:r,latestAction:r}),n.notify();try{const e=await(null==u.options.action?void 0:u.options.action(t));return r.data=e,o&&(n.invalidateRoute({to:".",fromCurrent:!0}),await n.reload()),r.status="success",e}catch(t){console.error(t),r.error=t,r.status="error"}finally{l.pending=l.pending.filter((t=>t!==r)),n.removeActionQueue.push({action:l,actionState:r}),n.notify()}}},n.state.actions[o]),c=n.state.loaders[o]||(n.state.loaders[o]={pending:[],fetch:async t=>{if(!u)return;const e={loadedAt:Date.now(),loaderContext:t};c.current=e,c.latest=e,c.pending.push(e),n.notify();try{return await(null==u.options.loader?void 0:u.options.loader(t))}finally{c.pending=c.pending.filter((t=>t!==e)),n.notify()}}},n.state.loaders[o]);let u={routeId:o,routeRouteId:r,routePath:i,fullPath:s,options:e,router:n,childRoutes:void 0,parentRoute:a,action:l,loader:c,buildLink:t=>n.buildLink(k({},t,{from:s})),navigate:t=>n.navigate(k({},t,{from:s})),matchRoute:(t,e)=>n.matchRoute(k({},t,{from:s}),e)};return null==n.options.createRoute||n.options.createRoute({router:n,route:u}),u}function D(t){t.forEach(((e,a)=>{const n=t[a-1];n&&(e.loaderData=f(e.loaderData,k({},n.loaderData,e.routeLoaderData)))}))}const O="__root__",F=["element","errorElement","catchElement","pendingElement"];function j(t,e,a){const n=k({},e,a,{router:t,routeSearch:{},search:{},childMatches:[],status:"idle",routeLoaderData:{},loaderData:{},isPending:!1,isFetching:!1,isInvalid:!1,invalidAt:1/0,getIsInvalid:()=>{const t=Date.now();return n.isInvalid||n.invalidAt<t},__:{abortController:new AbortController,latestId:"",resolve:()=>{},notify:()=>{n.__.resolve(),n.router.notify()},startPending:()=>{var e,a;const o=null!=(e=n.options.pendingMs)?e:t.options.defaultPendingMs,r=null!=(a=n.options.pendingMinMs)?a:t.options.defaultPendingMinMs;n.__.pendingTimeout||"loading"!==n.status||void 0===o||(n.__.pendingTimeout=setTimeout((()=>{n.isPending=!0,n.__.resolve(),void 0!==r&&(n.__.pendingMinPromise=new Promise((t=>n.__.pendingMinTimeout=setTimeout(t,r))))}),o))},cancelPending:()=>{n.isPending=!1,clearTimeout(n.__.pendingTimeout),clearTimeout(n.__.pendingMinTimeout),delete n.__.pendingMinPromise},validate:()=>{var e,a;const o=null!=(e=null==(a=n.parentMatch)?void 0:a.search)?e:t.location.search;try{const t=n.routeSearch,e="object"==typeof n.options.validateSearch?n.options.validateSearch.parse:n.options.validateSearch;let a=f(t,null==e?void 0:e(o));t!==a&&(n.isInvalid=!0),n.routeSearch=a,n.search=f(o,k({},o,a))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",n.status="error",void(n.error=e)}}},cancel:()=>{var t;null==(t=n.__.abortController)||t.abort(),n.__.cancelPending()},invalidate:()=>{n.isInvalid=!0},hasLoaders:()=>!(!e.options.loader&&!F.some((t=>"function"==typeof e.options[t]))),load:async e=>{const a=Date.now(),o=null!=e&&e.preload?Math.max(null==e?void 0:e.maxAge,null==e?void 0:e.gcMaxAge):0;if(null!=e&&e.preload&&o>0){if(t.state.matches.find((t=>t.matchId===n.matchId)))return;t.matchCache[n.matchId]={gc:a+e.gcMaxAge,match:n}}if("success"===n.status&&n.getIsInvalid()||"error"===n.status||"idle"===n.status){const t=null!=e&&e.preload?null==e?void 0:e.maxAge:void 0;n.fetch({maxAge:t})}},fetch:async e=>{const a=""+Date.now()+Math.random();return n.__.latestId=a,"idle"===n.status&&(n.status="loading"),n.isInvalid=!1,n.__.loadPromise=new Promise((async o=>{n.isFetching=!0,n.__.resolve=o;const r=(async()=>{n.__.elementsPromise=(async()=>{await Promise.all(F.map((async e=>{const a=n.options[e];n.__[e]||(n.__[e]=await t.options.createElement(a))})))})(),n.__.dataPromise=Promise.resolve().then((async()=>{try{var o,r,i;if(n.options.loader){const t=await n.options.loader({params:n.params,search:n.routeSearch,signal:n.__.abortController.signal});if(a!==n.__.latestId)return n.__.loaderPromise;n.routeLoaderData=f(n.routeLoaderData,t)}n.error=void 0,n.status="success",n.updatedAt=Date.now(),n.invalidAt=n.updatedAt+(null!=(o=null!=(r=null!=(i=null==e?void 0:e.maxAge)?i:n.options.loaderMaxAge)?r:t.options.defaultLoaderMaxAge)?o:0)}catch(t){if(a!==n.__.latestId)return n.__.loaderPromise;n.error=t,n.status="error",n.updatedAt=Date.now()}}));try{if(await Promise.all([n.__.elementsPromise,n.__.dataPromise]),a!==n.__.latestId)return n.__.loaderPromise;n.__.pendingMinPromise&&(await n.__.pendingMinPromise,delete n.__.pendingMinPromise)}finally{if(a!==n.__.latestId)return n.__.loaderPromise;n.__.cancelPending(),n.isPending=!1,n.isFetching=!1,n.__.notify()}})();if(n.__.loaderPromise=r,await r,a!==n.__.latestId)return n.__.loaderPromise;delete n.__.loaderPromise})),await n.__.loadPromise}});return n.hasLoaders()||(n.status="success"),n}const N=H(JSON.parse),B=U(JSON.stringify);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let a=C(e);for(let e in a){const n=a[e];if("string"==typeof n)try{a[e]=t(n)}catch(t){}}return a}}function U(t){return e=>{(e=k({},e))&&Object.keys(e).forEach((a=>{const n=e[a];if(void 0===n||void 0===n)delete e[a];else if(n&&"object"==typeof n&&null!==n)try{e[a]=t(n)}catch(t){}}));const a=L(e).toString();return a?"?"+a:""}}var G;const z="undefined"==typeof window||!(null!=(G=window.document)&&G.createElement);t.cascadeLoaderData=D,t.cleanPath=P,t.createBrowserHistory=r,t.createHashHistory=function(t){void 0===t&&(t={});var r=t.window,i=void 0===r?document.defaultView:r,s=i.history;function p(){var t=d(i.location.hash.substr(1)),e=t.pathname,a=void 0===e?"/":e,n=t.search,o=void 0===n?"":n,r=t.hash,l=void 0===r?"":r,c=s.state||{};return[c.idx,{pathname:a,search:o,hash:l,state:c.usr||null,key:c.key||"default"}]}var f=null;function m(){if(f)b.call(f),f=null;else{var t=a.Pop,e=p(),n=e[0],o=e[1];if(b.length){if(null!=n){var r=y-n;r&&(f={action:t,location:o,retry:function(){S(-1*r)}},S(r))}}else M(t)}}i.addEventListener(o,m),i.addEventListener("hashchange",(function(){h(p()[1])!==h(_)&&m()}));var v=a.Pop,g=p(),y=g[0],_=g[1],P=c(),b=c();function w(t){return function(){var t=document.querySelector("base"),e="";if(t&&t.getAttribute("href")){var a=i.location.href,n=a.indexOf("#");e=-1===n?a:a.slice(0,n)}return e}()+"#"+("string"==typeof t?t:h(t))}function A(t,a){return void 0===a&&(a=null),e({pathname:_.pathname,hash:"",search:""},"string"==typeof t?d(t):t,{state:a,key:u()})}function x(t,e){return[{usr:t.state,key:t.key,idx:e},w(t)]}function R(t,e,a){return!b.length||(b.call({action:t,location:e,retry:a}),!1)}function M(t){v=t;var e=p();y=e[0],_=e[1],P.call({action:v,location:_})}function S(t){s.go(t)}null==y&&(y=0,s.replaceState(e({},s.state,{idx:y}),""));var I={get action(){return v},get location(){return _},createHref:w,push:function t(e,n){var o=a.Push,r=A(e,n);if(R(o,r,(function(){t(e,n)}))){var l=x(r,y+1),c=l[0],u=l[1];try{s.pushState(c,"",u)}catch(t){i.location.assign(u)}M(o)}},replace:function t(e,n){var o=a.Replace,r=A(e,n);if(R(o,r,(function(){t(e,n)}))){var i=x(r,y),l=i[0],c=i[1];s.replaceState(l,"",c),M(o)}},go:S,back:function(){S(-1)},forward:function(){S(1)},listen:function(t){return P.push(t)},block:function(t){var e=b.push(t);return 1===b.length&&i.addEventListener(n,l),function(){e(),b.length||i.removeEventListener(n,l)}}};return I},t.createMemoryHistory=i,t.createRoute=T,t.createRouteConfig=function t(e,a,n,o,r){void 0===e&&(e={}),void 0===n&&(n=!0),n&&(e.path=O),o===O&&(o="");let i=n?O:e.path;i&&"/"!==i&&(i=A(i));const s=i||e.id;let l=_([o,s]);i===O&&(i="/"),l!==O&&(l=_(["/",l]));const c=l===O?"/":w(_([r,i]));return{id:l,routeId:s,path:i,fullPath:c,options:e,children:a,createChildren:a=>t(e,a((e=>t(e,void 0,!1,l,c))),!1,o,r),addChildren:a=>t(e,a,!1,o,r),createRoute:e=>t(e,void 0,!1,l,c)}},t.createRouteMatch=j,t.createRouter=function(t){var e,a;const n=(null==t?void 0:t.history)||(z?i():r()),o=k({defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50},t,{stringifySearch:null!=(e=null==t?void 0:t.stringifySearch)?e:B,parseSearch:null!=(a=null==t?void 0:t.parseSearch)?a:N});let s={history:n,options:o,listeners:[],removeActionQueue:[],basepath:"",routeTree:void 0,routesById:{},location:void 0,allRouteInfo:void 0,navigationPromise:Promise.resolve(),resolveNavigation:()=>{},matchCache:{},state:{status:"idle",location:null,matches:[],actions:{},loaders:{},lastUpdated:Date.now(),isFetching:!1,isPreloading:!1},startedLoadingAt:Date.now(),subscribe:t=>(s.listeners.push(t),()=>{s.listeners=s.listeners.filter((e=>e!==t))}),getRoute:t=>s.routesById[t],notify:()=>{s.state=k({},s.state,{isFetching:"loading"===s.state.status||s.state.matches.some((t=>t.isFetching)),isPreloading:Object.values(s.matchCache).some((t=>t.match.isFetching&&!s.state.matches.find((e=>e.matchId===t.match.matchId))))}),D(s.state.matches),s.listeners.forEach((t=>t(s)))},mount:()=>{const t=s.__.buildLocation({to:".",search:!0,hash:!0});t.href!==s.location.href&&s.__.commitLocation(t,!0),s.loadLocation();const e=s.history.listen((t=>{console.log(t.location),s.loadLocation(s.__.parseLocation(t.location,s.location))}));return!z&&window.addEventListener&&(window.addEventListener("visibilitychange",s.onFocus,!1),window.addEventListener("focus",s.onFocus,!1)),()=>{e(),window.removeEventListener("visibilitychange",s.onFocus),window.removeEventListener("focus",s.onFocus)}},onFocus:()=>{s.loadLocation()},update:t=>{const e=(null==t?void 0:t.history)!==s.history;s.location&&!e||(null!=t&&t.history&&(s.history=t.history),s.location=s.__.parseLocation(s.history.location),s.state.location=s.location),Object.assign(s.options,t);const{basepath:a,routeConfig:n}=s.options;return s.basepath=P("/"+(null!=a?a:"")),n&&(s.routesById={},s.routeTree=s.__.buildRouteTree(n)),s},cancelMatches:()=>{var t,e;[...s.state.matches,...null!=(t=null==(e=s.state.pending)?void 0:e.matches)?t:[]].forEach((t=>{t.cancel()}))},loadLocation:async t=>{const e=Math.random();s.startedLoadingAt=e,t&&(s.location=t),s.removeActionQueue.forEach((t=>{let{action:e,actionState:a}=t;s.state.currentAction===a&&(s.state.currentAction=void 0),e.current===a&&(e.current=void 0)})),s.removeActionQueue=[],s.cancelMatches();const a=s.matchRoutes(s.location.pathname,{strictParseParams:!0});if(s.state=k({},s.state,{pending:{matches:a,location:s.location},status:"loading"}),s.notify(),await s.loadMatches(a,{withPending:!0}),s.startedLoadingAt!==e)return s.navigationPromise;const n=s.state.matches,o=[],r=[];n.forEach((t=>{a.find((e=>e.matchId===t.matchId))?r.push(t):o.push(t)}));const i=Date.now();o.forEach((t=>{var e,a,n,o;null==t.__.onExit||t.__.onExit({params:t.params,search:t.routeSearch}),"error"!==t.status||t.isFetching||(t.status="idle",t.error=void 0);const r=Math.max(null!=(e=null!=(a=t.options.loaderGcMaxAge)?a:s.options.defaultLoaderGcMaxAge)?e:0,null!=(n=null!=(o=t.options.loaderMaxAge)?o:s.options.defaultLoaderMaxAge)?n:0);r>0&&(s.matchCache[t.matchId]={gc:r==1/0?Number.MAX_SAFE_INTEGER:i+r,match:t})})),r.forEach((t=>{null==t.options.onTransition||t.options.onTransition({params:t.params,search:t.routeSearch})}));a.filter((t=>!n.find((e=>e.matchId===t.matchId)))).forEach((t=>{t.__.onExit=null==t.options.onMatch?void 0:t.options.onMatch({params:t.params,search:t.search}),delete s.matchCache[t.matchId]})),a.some((t=>"loading"===t.status))&&(s.notify(),await Promise.all(a.map((t=>t.__.loaderPromise||Promise.resolve())))),s.startedLoadingAt===e&&(s.state=k({},s.state,{location:s.location,matches:a,pending:void 0,status:"idle"}),s.notify(),s.resolveNavigation())},cleanMatchCache:()=>{const t=Date.now();Object.keys(s.matchCache).forEach((e=>{const a=s.matchCache[e];"loading"!==a.match.status&&(a.gc>0&&a.gc>t||delete s.matchCache[e])}))},loadRoute:async function(t){void 0===t&&(t=s.location);const e=s.buildNext(t),a=s.matchRoutes(e.pathname,{strictParseParams:!0});return await s.loadMatches(a),a},preloadRoute:async function(t,e){var a,n,o,r,i,l;void 0===t&&(t=s.location);const c=s.buildNext(t),u=s.matchRoutes(c.pathname,{strictParseParams:!0});return await s.loadMatches(u,{preload:!0,maxAge:null!=(a=null!=(n=null!=(o=e.maxAge)?o:s.options.defaultPreloadMaxAge)?n:s.options.defaultLoaderMaxAge)?a:0,gcMaxAge:null!=(r=null!=(i=null!=(l=e.gcMaxAge)?l:s.options.defaultPreloadGcMaxAge)?i:s.options.defaultLoaderGcMaxAge)?r:0}),u},matchRoutes:(t,e)=>{var a,n;s.cleanMatchCache();const o=[];if(!s.routeTree)return o;const r=[...s.state.matches,...null!=(a=null==(n=s.state.pending)?void 0:n.matches)?a:[]],i=async a=>{var n,l,c;const u=g(o);let h=null!=(n=null==u?void 0:u.params)?n:{};const d=null!=(l=null==s.options.filterRoutes?void 0:s.options.filterRoutes(a))?l:a;let p=[];const f=(a,n)=>(n.some((n=>{var o,r,i;if(!n.routePath&&null!=(o=n.childRoutes)&&o.length)return f([...p,n],n.childRoutes);const l=!!("/"!==n.routePath||null!=(r=n.childRoutes)&&r.length),c=S(t,{to:n.fullPath,fuzzy:l,caseSensitive:null!=(i=n.options.caseSensitive)?i:s.options.caseSensitive});if(c){let t;try{var u;t=null!=(u=null==n.options.parseParams?void 0:n.options.parseParams(c))?u:c}catch(t){if(null!=e&&e.strictParseParams)throw t}h=k({},h,t)}return c&&(p=[...a,n]),!!p.length})),!!p.length);if(f([],d),!p.length)return;p.forEach((e=>{var a;const n=M(e.routePath,h),i=M(e.routeId,h,!0),l=r.find((t=>t.matchId===i))||(null==(a=s.matchCache[i])?void 0:a.match)||j(s,e,{matchId:i,params:h,pathname:_([t,n])});o.push(l)}));const m=g(p);null!=(c=m.childRoutes)&&c.length&&i(m.childRoutes)};return i([s.routeTree]),D(o),o},loadMatches:async(t,e)=>{const a=t.map((async t=>{t.__.validate(),t.load(e),"loading"===t.status&&(null!=e&&e.withPending&&t.__.startPending(),await t.__.loadPromise)}));s.notify(),await Promise.all(a)},invalidateRoute:t=>{var e,a;const n=s.buildNext(t),o=s.matchRoutes(n.pathname).map((t=>t.matchId));[...s.state.matches,...null!=(e=null==(a=s.state.pending)?void 0:a.matches)?e:[]].forEach((t=>{o.includes(t.matchId)&&t.invalidate()}))},reload:()=>s.__.navigate({fromCurrent:!0,replace:!0,search:!0}),resolvePath:(t,e)=>x(s.basepath,t,P(e)),matchRoute:(t,e)=>{var a;t=k({},t,{to:t.to?s.resolvePath(null!=(a=t.from)?a:"",t.to):void 0});const n=s.buildNext(t);var o;return null!=e&&e.pending?!(null==(o=s.state.pending)||!o.location)&&!!S(s.state.pending.location.pathname,k({},e,{to:n.pathname})):!!S(s.state.location.pathname,k({},e,{to:n.pathname}))},navigate:async t=>{let{from:e,to:a=".",search:n,hash:o,replace:r,params:i}=t;const l=String(a),c=String(e);let u;try{new URL(""+l),u=!0}catch(t){}return p(!u),s.__.navigate({from:c,to:l,search:n,hash:o,replace:r,params:i})},buildLink:t=>{var e,a;let{from:n,to:o=".",search:r,params:i,hash:l,target:c,replace:u,activeOptions:h,preload:d,preloadMaxAge:p,preloadGcMaxAge:f,preloadDelay:m,disabled:v}=t;try{return new URL(""+o),{type:"external",href:o}}catch(t){}const g={from:n,to:o,search:r,params:i,hash:l,replace:u},y=s.buildNext(g);d=null!=(e=d)?e:s.options.defaultPreload;const _=null!=(a=null!=m?m:s.options.defaultPreloadDelay)?a:0,P=s.state.location.pathname===y.pathname,b=s.state.location.pathname.split("/"),w=y.pathname.split("/").every(((t,e)=>t===b[e])),A=s.state.location.hash===y.hash,x=null!=h&&h.exact?P:w,R=null==h||!h.includeHash||A;return{type:"internal",next:y,handleFocus:t=>{d&&s.preloadRoute(g,{maxAge:p,gcMaxAge:f})},handleClick:t=>{v||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||c&&"_self"!==c||0!==t.button||(t.preventDefault(),!P||r||l||s.invalidateRoute(g),s.__.navigate(g))},handleEnter:t=>{const e=t.target||{};if(d){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,s.preloadRoute(g,{maxAge:p,gcMaxAge:f})}),_)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:x&&R,disabled:v}},buildNext:t=>{const e=s.__.buildLocation(t),a=s.matchRoutes(e.pathname),n=a.map((t=>{var e;return null!=(e=t.options.preSearchFilters)?e:[]})).flat().filter(Boolean),o=a.map((t=>{var e;return null!=(e=t.options.postSearchFilters)?e:[]})).flat().filter(Boolean);return s.__.buildLocation(k({},t,{__preSearchFilters:n,__postSearchFilters:o}))},__:{buildRouteTree:t=>{const e=(t,a)=>t.map((t=>{const n=T(t,t.options,a,s);if(s.routesById[n.routeId])throw new Error;s.routesById[n.routeId]=n;const o=t.children;return n.childRoutes=null!=o&&o.length?e(o,n):void 0,n}));return e([t])[0]},parseLocation:(t,e)=>{var a;const n=s.options.parseSearch(t.search);return{pathname:t.pathname,searchStr:t.search,search:f(null==e?void 0:e.search,n),hash:null!=(a=t.hash.split("#").reverse()[0])?a:"",href:""+t.pathname+t.search+t.hash,state:t.state,key:t.key}},navigate:t=>{const e=s.buildNext(t);return s.__.commitLocation(e,t.replace)},buildLocation:function(t){var e,a,n,o,r,i,l,c,u;void 0===t&&(t={});const h=t.fromCurrent?s.location.pathname:null!=(e=t.from)?e:s.location.pathname;let d=x(null!=(a=s.basepath)?a:"/",h,""+(null!=(n=t.to)?n:"."));const p=s.matchRoutes(s.location.pathname,{strictParseParams:!0}),m=s.matchRoutes(d),v=k({},null==(o=g(p))?void 0:o.params);let _=!0===(null==(r=t.params)||r)?v:y(t.params,v);_&&m.map((t=>t.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},_,t(_))})),d=M(d,null!=_?_:{});const P=null!=(i=t.__preSearchFilters)&&i.length?t.__preSearchFilters.reduce(((t,e)=>e(t)),s.location.search):s.location.search,b=!0===t.search?P:t.search?null!=(l=y(t.search,P))?l:{}:null!=(c=t.__preSearchFilters)&&c.length?P:{},w=null!=(u=t.__postSearchFilters)&&u.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),b):b,A=f(s.location.search,w),R=s.options.stringifySearch(A);let S=!0===t.hash?s.location.hash:y(t.hash,s.location.hash);return S=S?"#"+S:"",{pathname:d,search:A,searchStr:R,state:s.location.state,hash:S,href:""+d+R+S,key:t.key}},commitLocation:(t,e)=>{const a=""+Date.now()+Math.random();s.navigateTimeout&&clearTimeout(s.navigateTimeout);let o="replace";e||(o="push");return s.__.parseLocation(n.location).href===t.href&&!t.key&&(o="replace"),"replace"===o?n.replace({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}):n.push({pathname:t.pathname,hash:t.hash,search:t.searchStr},{id:a}),s.navigationPromise=new Promise((t=>{const e=s.resolveNavigation;s.resolveNavigation=()=>{e(),t()}})),s.navigationPromise}}};return s.update(t),null==s.options.createRouter||s.options.createRouter(s),s},t.decode=C,t.defaultParseSearch=N,t.defaultStringifySearch=B,t.encode=L,t.functionalUpdate=y,t.interpolatePath=M,t.invariant=p,t.joinPaths=_,t.last=g,t.matchByPath=I,t.matchPathname=S,t.parsePathname=R,t.parseSearchWith=H,t.replaceEqualDeep=f,t.resolvePath=x,t.rootRouteId=O,t.stringifySearchWith=U,t.trimPath=A,t.trimPathLeft=b,t.trimPathRight=w,t.warning=function(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch(t){}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
11
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RouterCore={})}(this,(function(t){"use strict";function e(t,e){if(!t)throw new Error("Invariant failed")}const r="popstate";function a(t){let e=t.getLocation(),r=()=>{},a=new Set;const o=()=>{e=t.getLocation(),a.forEach((t=>t()))};return{get location(){return e},listen:e=>(0===a.size&&(r=t.listener(o)),a.add(e),()=>{a.delete(e),0===a.size&&r()}),push:(e,r)=>{t.pushState(e,r),o()},replace:(e,r)=>{t.replaceState(e,r),o()},go:e=>{t.go(e),o()},back:()=>{t.back(),o()},forward:()=>{t.forward(),o()}}}function o(t){const e=t?.getHref??(()=>`${window.location.pathname}${window.location.hash}${window.location.search}`),o=t?.createHref??(t=>t);return a({getLocation:()=>s(e(),history.state),listener:t=>(window.addEventListener(r,t),()=>{window.removeEventListener(r,t)}),pushState:(t,e)=>{window.history.pushState({...e,key:n()},"",o(t))},replaceState:(t,e)=>{window.history.replaceState({...e,key:n()},"",o(t))},back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t)})}function s(t,e){let r=t.indexOf("#"),a=t.indexOf("?");const o=Math.min(r,a);return{href:t,pathname:o>-1?t.substring(0,o):t,hash:r>-1?t.substring(r,a):"",search:a>-1?t.substring(a):"",state:e}}function n(){return(Math.random()+1).toString(36).substring(7)}function i(t){return t[t.length-1]}function c(t,e){return function(t){return"function"==typeof t}(t)?t(e):t}function h(t,e){return e.reduce(((e,r)=>(e[r]=t[r],e)),{})}function u(t){return l(t.filter(Boolean).join("/"))}function l(t){return t.replace(/\/{2,}/g,"/")}function d(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function f(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function p(t){return f(d(t))}function m(t,e,r){e=e.replace(new RegExp(`^${t}`),"/"),r=r.replace(new RegExp(`^${t}`),"/");let a=g(e);const o=g(r);o.forEach(((t,e)=>{if("/"===t.value)e?e===o.length-1&&a.push(t):a=[t];else if(".."===t.value)a.length>1&&"/"===i(a)?.value&&a.pop(),a.pop();else{if("."===t.value)return;a.push(t)}}));const s=u([t,...a.map((t=>t.value))]);return l(s)}function g(t){if(!t)return[];const e=[];if("/"===(t=l(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const r=t.split("/").filter(Boolean);return e.push(...r.map((t=>t.startsWith("*")?{type:"wildcard",value:t}:"$"===t.charAt(0)?{type:"param",value:t}:{type:"pathname",value:t}))),"/"===t.slice(-1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),e}function v(t,e,r){return u(g(t).map((t=>"*"!==t.value||r?"param"===t.type?e[t.value.substring(1)]??"":t.value:"")))}function y(t,e,r){const a=b(t,e,r);if(!r.to||a)return a??{}}function b(t,e,r){if(!e.startsWith(t))return;const a=g(e="/"!=t?e.substring(t.length):e),o=g(`${r.to??"*"}`),s={};let n=(()=>{for(let t=0;t<Math.max(a.length,o.length);t++){const e=a[t],n=o[t],i=t===o.length-1,c=t===a.length-1;if(n){if("wildcard"===n.type)return!!e?.value&&(s["*"]=u(a.slice(t).map((t=>t.value))),!0);if("pathname"===n.type){if("/"===n.value&&!e?.value)return!0;if(e)if(r.caseSensitive){if(n.value!==e.value)return!1}else if(n.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===n.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(s[n.value.substring(1)]=e.value)}}if(i&&!c)return!!r.fuzzy}return!0})();return n?s:void 0}function w(t,e){var r,a,o,s="";for(r in t)if(void 0!==(o=t[r]))if(Array.isArray(o))for(a=0;a<o.length;a++)s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(o[a]);else s&&(s+="&"),s+=encodeURIComponent(r)+"="+encodeURIComponent(o);return(e||"")+s}function S(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||("0"===e.charAt(0)?e:0*+e==0?+e:e))}function P(t){for(var e,r,a={},o=t.split("&");e=o.shift();)void 0!==a[r=(e=e.split("=")).shift()]?a[r]=[].concat(a[r],S(e.shift())):a[r]=S(e.shift());return a}class L{constructor(t,e,r,a,o){Object.assign(this,{...t,originalIndex:r,options:e,getRouter:()=>o,childRoutes:void 0,getParentRoute:()=>a}),o.options.createRoute?.({router:o,route:this})}}const A="__root__",_=(t={},r=[],a=!0,o,s)=>{a&&(t.path=A),o===A&&(o="");let n=a?A:t.path;n&&"/"!==n&&(n=p(n));const i=n||t.id;let c=u([o,i]);n===A&&(n="/"),c!==A&&(c=u(["/",c]));const h=c===A?"/":f(u([s,n]));return{id:c,routeId:i,path:n,fullPath:h,options:t,children:r,addChildren:e=>_(t,e,!1,o,s),createRoute:t=>_(t,void 0,!1,c,h),generate:()=>{e(!1)}}};function M(t){for(var e=arguments.length,r=Array(e>1?e-1:0),a=1;a<e;a++)r[a-1]=arguments[a];throw Error("[Immer] minified error nr: "+t+(r.length?" "+r.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function x(t){return!!t&&!!t[dt]}function E(t){var e;return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;var r=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===ft}(t)||Array.isArray(t)||!!t[lt]||!!(null===(e=t.constructor)||void 0===e?void 0:e[lt])||I(t)||F(t))}function O(t,e,r){void 0===r&&(r=!1),0===D(t)?(r?Object.keys:pt)(t).forEach((function(a){r&&"symbol"==typeof a||e(a,t[a],t)})):t.forEach((function(r,a){return e(a,r,t)}))}function D(t){var e=t[dt];return e?e.i>3?e.i-4:e.i:Array.isArray(t)?1:I(t)?2:F(t)?3:0}function R(t,e){return 2===D(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function j(t,e,r){var a=D(t);2===a?t.set(e,r):3===a?(t.delete(e),t.add(r)):t[e]=r}function I(t){return it&&t instanceof Map}function F(t){return ct&&t instanceof Set}function C(t){return t.o||t.t}function k(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var e=mt(t);delete e[dt];for(var r=pt(e),a=0;a<r.length;a++){var o=r[a],s=e[o];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(e[o]={configurable:!0,writable:!0,enumerable:s.enumerable,value:t[o]})}return Object.create(Object.getPrototypeOf(t),e)}function $(t,e){return void 0===e&&(e=!1),N(t)||x(t)||!E(t)||(D(t)>1&&(t.set=t.add=t.clear=t.delete=T),Object.freeze(t),e&&O(t,(function(t,e){return $(e,!0)}),!0)),t}function T(){M(2)}function N(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function z(t){var e=gt[t];return e||M(18,t),e}function U(){return st}function B(t,e){e&&(z("Patches"),t.u=[],t.s=[],t.v=e)}function H(t){K(t),t.p.forEach(W),t.p=null}function K(t){t===st&&(st=t.l)}function G(t){return st={p:[],l:st,h:t,m:!0,_:0}}function W(t){var e=t[dt];0===e.i||1===e.i?e.j():e.O=!0}function J(t,e){e._=e.p.length;var r=e.p[0],a=void 0!==t&&t!==r;return e.h.g||z("ES5").S(e,t,a),a?(r[dt].P&&(H(e),M(4)),E(t)&&(t=X(e,t),e.l||V(e,t)),e.u&&z("Patches").M(r[dt].t,t,e.u,e.s)):t=X(e,r,[]),H(e),e.u&&e.v(e.u,e.s),t!==ut?t:void 0}function X(t,e,r){if(N(e))return e;var a=e[dt];if(!a)return O(e,(function(o,s){return q(t,a,e,o,s,r)}),!0),e;if(a.A!==t)return e;if(!a.P)return V(t,a.t,!0),a.t;if(!a.I){a.I=!0,a.A._--;var o=4===a.i||5===a.i?a.o=k(a.k):a.o;O(3===a.i?new Set(o):o,(function(e,s){return q(t,a,o,e,s,r)})),V(t,o,!1),r&&t.u&&z("Patches").R(a,r,t.u,t.s)}return a.o}function q(t,e,r,a,o,s){if(x(o)){var n=X(t,o,s&&e&&3!==e.i&&!R(e.D,a)?s.concat(a):void 0);if(j(r,a,n),!x(n))return;t.m=!1}if(E(o)&&!N(o)){if(!t.h.F&&t._<1)return;X(t,o),e&&e.A.l||V(t,o)}}function V(t,e,r){void 0===r&&(r=!1),t.h.F&&t.m&&$(e,r)}function Q(t,e){var r=t[dt];return(r?C(r):t)[e]}function Y(t,e){if(e in t)for(var r=Object.getPrototypeOf(t);r;){var a=Object.getOwnPropertyDescriptor(r,e);if(a)return a;r=Object.getPrototypeOf(r)}}function Z(t){t.P||(t.P=!0,t.l&&Z(t.l))}function tt(t){t.o||(t.o=k(t.t))}function et(t,e,r){var a=I(e)?z("MapSet").N(e,r):F(e)?z("MapSet").T(e,r):t.g?function(t,e){var r=Array.isArray(t),a={i:r?1:0,A:e?e.A:U(),P:!1,I:!1,D:{},l:e,t:t,k:null,o:null,j:null,C:!1},o=a,s=vt;r&&(o=[a],s=yt);var n=Proxy.revocable(o,s),i=n.revoke,c=n.proxy;return a.k=c,a.j=i,c}(e,r):z("ES5").J(e,r);return(r?r.A:U()).p.push(a),a}function rt(t){return x(t)||M(22,t),function t(e){if(!E(e))return e;var r,a=e[dt],o=D(e);if(a){if(!a.P&&(a.i<4||!z("ES5").K(a)))return a.t;a.I=!0,r=at(e,o),a.I=!1}else r=at(e,o);return O(r,(function(e,o){a&&function(t,e){return 2===D(t)?t.get(e):t[e]}(a.t,e)===o||j(r,e,t(o))})),3===o?new Set(r):r}(t)}function at(t,e){switch(e){case 2:return new Map(t);case 3:return Array.from(t)}return k(t)}var ot,st,nt="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),it="undefined"!=typeof Map,ct="undefined"!=typeof Set,ht="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,ut=nt?Symbol.for("immer-nothing"):((ot={})["immer-nothing"]=!0,ot),lt=nt?Symbol.for("immer-draftable"):"__$immer_draftable",dt=nt?Symbol.for("immer-state"):"__$immer_state",ft=""+Object.prototype.constructor,pt="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,mt=Object.getOwnPropertyDescriptors||function(t){var e={};return pt(t).forEach((function(r){e[r]=Object.getOwnPropertyDescriptor(t,r)})),e},gt={},vt={get:function(t,e){if(e===dt)return t;var r=C(t);if(!R(r,e))return function(t,e,r){var a,o=Y(e,r);return o?"value"in o?o.value:null===(a=o.get)||void 0===a?void 0:a.call(t.k):void 0}(t,r,e);var a=r[e];return t.I||!E(a)?a:a===Q(t.t,e)?(tt(t),t.o[e]=et(t.A.h,a,t)):a},has:function(t,e){return e in C(t)},ownKeys:function(t){return Reflect.ownKeys(C(t))},set:function(t,e,r){var a=Y(C(t),e);if(null==a?void 0:a.set)return a.set.call(t.k,r),!0;if(!t.P){var o=Q(C(t),e),s=null==o?void 0:o[dt];if(s&&s.t===r)return t.o[e]=r,t.D[e]=!1,!0;if(function(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}(r,o)&&(void 0!==r||R(t.t,e)))return!0;tt(t),Z(t)}return t.o[e]===r&&"number"!=typeof r&&(void 0!==r||e in t.o)||(t.o[e]=r,t.D[e]=!0,!0)},deleteProperty:function(t,e){return void 0!==Q(t.t,e)||e in t.t?(t.D[e]=!1,tt(t),Z(t)):delete t.D[e],t.o&&delete t.o[e],!0},getOwnPropertyDescriptor:function(t,e){var r=C(t),a=Reflect.getOwnPropertyDescriptor(r,e);return a?{writable:!0,configurable:1!==t.i||"length"!==e,enumerable:a.enumerable,value:r[e]}:a},defineProperty:function(){M(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){M(12)}},yt={};O(vt,(function(t,e){yt[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),yt.deleteProperty=function(t,e){return yt.set.call(this,t,e,void 0)},yt.set=function(t,e,r){return vt.set.call(this,t[0],e,r,t[0])};var bt=function(){function t(t){var e=this;this.g=ht,this.F=!0,this.produce=function(t,r,a){if("function"==typeof t&&"function"!=typeof r){var o=r;r=t;var s=e;return function(t){var e=this;void 0===t&&(t=o);for(var a=arguments.length,n=Array(a>1?a-1:0),i=1;i<a;i++)n[i-1]=arguments[i];return s.produce(t,(function(t){var a;return(a=r).call.apply(a,[e,t].concat(n))}))}}var n;if("function"!=typeof r&&M(6),void 0!==a&&"function"!=typeof a&&M(7),E(t)){var i=G(e),c=et(e,t,void 0),h=!0;try{n=r(c),h=!1}finally{h?H(i):K(i)}return"undefined"!=typeof Promise&&n instanceof Promise?n.then((function(t){return B(i,a),J(t,i)}),(function(t){throw H(i),t})):(B(i,a),J(n,i))}if(!t||"object"!=typeof t){if(void 0===(n=r(t))&&(n=t),n===ut&&(n=void 0),e.F&&$(n,!0),a){var u=[],l=[];z("Patches").M(t,n,u,l),a(u,l)}return n}M(21,t)},this.produceWithPatches=function(t,r){if("function"==typeof t)return function(r){for(var a=arguments.length,o=Array(a>1?a-1:0),s=1;s<a;s++)o[s-1]=arguments[s];return e.produceWithPatches(r,(function(e){return t.apply(void 0,[e].concat(o))}))};var a,o,s=e.produce(t,r,(function(t,e){a=t,o=e}));return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(t){return[t,a,o]})):[s,a,o]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var e=t.prototype;return e.createDraft=function(t){E(t)||M(8),x(t)&&(t=rt(t));var e=G(this),r=et(this,t,void 0);return r[dt].C=!0,K(e),r},e.finishDraft=function(t,e){var r=(t&&t[dt]).A;return B(r,e),J(void 0,r)},e.setAutoFreeze=function(t){this.F=t},e.setUseProxies=function(t){t&&!ht&&M(20),this.g=t},e.applyPatches=function(t,e){var r;for(r=e.length-1;r>=0;r--){var a=e[r];if(0===a.path.length&&"replace"===a.op){t=a.value;break}}r>-1&&(e=e.slice(r+1));var o=z("Patches").$;return x(t)?o(t,e):this.produce(t,(function(t){return o(t,e)}))},t}(),wt=new bt,St=wt.produce;wt.produceWithPatches.bind(wt);var Pt=wt.setAutoFreeze.bind(wt);wt.setUseProxies.bind(wt),wt.applyPatches.bind(wt),wt.createDraft.bind(wt),wt.finishDraft.bind(wt),Pt(!1);let Lt=[],At=!1;function _t(){At||(Lt.forEach((t=>t())),Lt=[])}function Mt(t,e){const r=new Set,a={state:t,subscribe:t=>(r.add(t),()=>r.delete(t)),setState:t=>{const o=a.state;a.state=St((e=>{t(e)}))(o),e&&console.log(a.state),Lt.push((()=>r.forEach((t=>t(a.state,o))))),_t()}};return a}function xt(t){At=!0,t(),At=!1,_t()}function Et(t,e){if(t===e)return t;const r=e,a=Array.isArray(t)&&Array.isArray(r);if(a||Ot(t)&&Ot(r)){const e=a?t.length:Object.keys(t).length,o=a?r:Object.keys(r),s=o.length,n=a?[]:{};let i=0;for(let e=0;e<s;e++){const s=a?e:o[e];n[s]=Et(t[s],r[s]),n[s]===t[s]&&i++}return e===s&&i===e?t:n}return r}function Ot(t){if(!Dt(t))return!1;const e=t.constructor;if(void 0===e)return!0;const r=e.prototype;return!!Dt(r)&&!!r.hasOwnProperty("isPrototypeOf")}function Dt(t){return"[object Object]"===Object.prototype.toString.call(t)}const Rt=["component","errorComponent","pendingComponent"];class jt{abortController=new AbortController;#t="";#e=()=>{};onLoaderDataListeners=new Set;constructor(t,e,r){Object.assign(this,{route:e,router:t,matchId:r.matchId,pathname:r.pathname,params:r.params,store:Mt({routeSearch:{},search:{},status:"idle",routeLoaderData:{},loaderData:{},isFetching:!1,invalid:!1,invalidAt:1/0})}),this.__hasLoaders()||this.store.setState((t=>t.status="success"))}#r=t=>{xt((()=>{this.store.setState((e=>{e.routeLoaderData=t})),this.#a()}))};cancel=()=>{this.abortController?.abort()};load=async t=>{const e=Date.now(),r=t?.preload?Math.max(t?.maxAge,t?.gcMaxAge):0;if(t?.preload&&r>0){if(this.router.store.state.currentMatches.find((t=>t.id===this.id)))return;this.router.store.setState((r=>{r.matchCache[this.id]={gc:e+t.gcMaxAge,match:this}}))}if("success"===this.store.state.status&&this.getIsInvalid()||"error"===this.store.state.status||"idle"===this.store.state.status){const e=t?.preload?t?.maxAge:void 0;await this.fetch({maxAge:e})}};fetch=async t=>(this.__loadPromise=new Promise((async e=>{const r=""+Date.now()+Math.random();this.#t=r;const a=()=>r!==this.#t?this.__loadPromise?.then((()=>e())):void 0;let o;xt((()=>{"idle"===this.store.state.status&&this.store.setState((t=>t.status="loading")),this.store.setState((t=>t.invalid=!1))})),this.store.setState((t=>t.isFetching=!0)),this.#e=e;const s=(async()=>{await Promise.all(Rt.map((async t=>{const e=this.route.options[t];this[t]?.preload&&(this[t]=await this.router.options.loadComponent(e))})))})(),n=Promise.resolve().then((async()=>{try{if(this.route.options.loader){const t=await this.router.loadMatchData(this);if(o=a())return o;this.#r(t)}return this.store.setState((e=>{e.error=void 0,e.status="success",e.updatedAt=Date.now(),e.invalidAt=e.updatedAt+(t?.maxAge??this.route.options.loaderMaxAge??this.router.options.defaultLoaderMaxAge??0)})),this.store.state.routeLoaderData}catch(t){if(o=a())return o;throw this.store.setState((e=>{e.error=t,e.status="error",e.updatedAt=Date.now()})),t}})),i=async()=>{if(o=a())return o;this.store.setState((t=>t.isFetching=!1)),this.#e(),delete this.__loadPromise};try{await Promise.all([s,n.catch((()=>{}))]),i()}catch{i()}})),this.__loadPromise);invalidate=async()=>{this.store.setState((t=>t.invalid=!0)),this.router.store.state.currentMatches.find((t=>t.id===this.id))&&await this.load()};__hasLoaders=()=>!(!this.route.options.loader&&!Rt.some((t=>this.route.options[t]?.preload)));getIsInvalid=()=>{const t=Date.now();return this.store.state.invalid||this.store.state.invalidAt<t};#a=()=>{this.store.setState((t=>{t.loaderData=Et(t.loaderData,{...this.parentMatch?.store.state.loaderData,...t.routeLoaderData})})),this.onLoaderDataListeners.forEach((t=>t()))};__setParentMatch=t=>{!this.parentMatch&&t&&(this.parentMatch=t,this.parentMatch.__onLoaderData((()=>{this.#a()})))};__onLoaderData=t=>{this.onLoaderDataListeners.add(t)};__validate=()=>{const t=this.parentMatch?.store.state.search??this.router.store.state.latestLocation.search;try{const e=this.store.state.routeSearch;let r=("object"==typeof this.route.options.validateSearch?this.route.options.validateSearch.parse:this.route.options.validateSearch)?.(t)??{};xt((()=>{e!==r&&this.store.setState((t=>t.invalid=!0)),this.store.setState((e=>{e.routeSearch=r,e.search={...t,...r}}))})),Rt.map((async t=>{const e=this.route.options[t];"function"!=typeof this[t]&&(this[t]=e)}))}catch(t){console.error(t);const e=new Error("Invalid search params found",{cause:t});return e.code="INVALID_SEARCH_PARAMS",void this.store.setState((t=>{t.status="error",t.error=e}))}}}const It=Ct(JSON.parse),Ft=kt(JSON.stringify);function Ct(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let r=P(e);for(let e in r){const a=r[e];if("string"==typeof a)try{r[e]=t(a)}catch(t){}}return r}}function kt(t){return e=>{(e={...e})&&Object.keys(e).forEach((r=>{const a=e[r];if(void 0===a||void 0===a)delete e[r];else if(a&&"object"==typeof a&&null!==a)try{e[r]=t(a)}catch(t){}}));const r=w(e).toString();return r?`?${r}`:""}}const $t=async({router:t,routeMatch:e})=>{const r=t.buildNext({to:".",search:t=>({...t??{},__data:{matchId:e.id}})}),a=await fetch(r.href,{method:"GET",signal:e.abortController.signal});if(a.ok)return a.json();throw new Error("Failed to fetch match data")};const Tt="undefined"==typeof window||!window.document.createElement;function Nt(){return{status:"idle",latestLocation:null,currentLocation:null,currentMatches:[],loaders:{},lastUpdated:Date.now(),matchCache:{},get isFetching(){return"loading"===this.status||this.currentMatches.some((t=>t.store.state.isFetching))},get isPreloading(){return Object.values(this.matchCache).some((t=>t.match.store.state.isFetching&&!this.currentMatches.find((e=>e.id===t.match.id))))}}}t.Route=L,t.RouteMatch=jt,t.Router=class{startedLoadingAt=Date.now();resolveNavigation=()=>{};constructor(t){this.options={defaultLoaderGcMaxAge:3e5,defaultLoaderMaxAge:0,defaultPreloadMaxAge:2e3,defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??Ft,parseSearch:t?.parseSearch??It,fetchServerDataFn:t?.fetchServerDataFn??$t},this.history=this.options?.history??o(),this.store=Mt(Nt()),this.basepath="",this.update(t),this.options.createRouter?.(this)}reset=()=>{this.store.setState((t=>Object.assign(t,Nt())))};mount=()=>{if(!Tt){this.store.state.currentMatches.length||this.load();const t=this.history.listen((()=>{this.load(this.#o(this.store.state.latestLocation))})),e="visibilitychange",r="focus";return window.addEventListener&&(window.addEventListener(e,this.#s,!1),window.addEventListener(r,this.#s,!1)),()=>{t(),window.removeEventListener&&(window.removeEventListener(e,this.#s),window.removeEventListener(r,this.#s))}}return()=>{}};update=t=>{this.store.state.latestLocation||this.store.setState((t=>{t.latestLocation=this.#o(),t.currentLocation=t.latestLocation})),Object.assign(this.options,t);const{basepath:e,routeConfig:r}=this.options;return this.basepath=`/${p(e??"")??""}`,r&&(this.routesById={},this.routeTree=this.#n(r)),this};buildNext=t=>{const e=this.#i(t),r=this.matchRoutes(e.pathname),a=r.map((t=>t.route.options.preSearchFilters??[])).flat().filter(Boolean),o=r.map((t=>t.route.options.postSearchFilters??[])).flat().filter(Boolean);return this.#i({...t,__preSearchFilters:a,__postSearchFilters:o})};cancelMatches=()=>{[...this.store.state.currentMatches,...this.store.state.pendingMatches||[]].forEach((t=>{t.cancel()}))};load=async t=>{let r=Date.now();const a=r;let o;this.startedLoadingAt=a,this.cancelMatches(),xt((()=>{t&&this.store.setState((e=>{e.latestLocation=t})),o=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),this.store.setState((t=>{t.status="loading",t.pendingMatches=o,t.pendingLocation=this.store.state.latestLocation}))}));try{await this.loadMatches(o)}catch(t){console.warn(t),e(!1)}if(this.startedLoadingAt!==a)return this.navigationPromise;const s=this.store.state.currentMatches,n=[],i=[];s.forEach((t=>{o.find((e=>e.id===t.id))?i.push(t):n.push(t)}));const c=o.filter((t=>!s.find((e=>e.id===t.id))));r=Date.now(),n.forEach((t=>{t.__onExit?.({params:t.params,search:t.store.state.routeSearch}),"error"!==t.store.state.status||t.store.state.isFetching||t.store.setState((t=>{t.status="idle",t.error=void 0}));const e=Math.max(t.route.options.loaderGcMaxAge??this.options.defaultLoaderGcMaxAge??0,t.route.options.loaderMaxAge??this.options.defaultLoaderMaxAge??0);e>0&&this.store.setState((a=>{a.matchCache[t.id]={gc:e==1/0?Number.MAX_SAFE_INTEGER:r+e,match:t}}))})),i.forEach((t=>{t.route.options.onTransition?.({params:t.params,search:t.store.state.routeSearch})})),c.forEach((t=>{t.__onExit=t.route.options.onLoaded?.({params:t.params,search:t.store.state.search}),delete this.store.state.matchCache[t.id]})),this.store.setState((t=>{Object.assign(t,{status:"idle",currentLocation:this.store.state.latestLocation,currentMatches:o,pendingLocation:void 0,pendingMatches:void 0})})),this.options.onRouteChange?.(),this.resolveNavigation()};cleanMatchCache=()=>{const t=Date.now();this.store.setState((e=>{Object.keys(e.matchCache).forEach((r=>{const a=e.matchCache[r];"loading"!==a.match.store.state.status&&(a.gc>0&&a.gc>t||delete e.matchCache[r])}))}))};getRoute=t=>{const r=this.routesById[t];return e(r),r};loadRoute=async(t=this.store.state.latestLocation)=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname,{strictParseParams:!0});return await this.loadMatches(r),r};preloadRoute=async(t=this.store.state.latestLocation,e)=>{const r=this.buildNext(t),a=this.matchRoutes(r.pathname,{strictParseParams:!0});return await this.loadMatches(a,{preload:!0,maxAge:e.maxAge??this.options.defaultPreloadMaxAge??this.options.defaultLoaderMaxAge??0,gcMaxAge:e.gcMaxAge??this.options.defaultPreloadGcMaxAge??this.options.defaultLoaderGcMaxAge??0}),a};matchRoutes=(t,e)=>{const r=[];if(!this.routeTree)return r;const a=[...this.store.state.currentMatches,...this.store.state.pendingMatches??[]],o=async s=>{let n=i(r)?.params??{};const c=this.options.filterRoutes?.(s)??s;let h=[];const l=(r,a)=>(a.some((a=>{if(!a.path&&a.childRoutes?.length)return l([...h,a],a.childRoutes);const o=!("/"===a.path&&!a.childRoutes?.length),s=y(this.basepath,t,{to:a.fullPath,fuzzy:o,caseSensitive:a.options.caseSensitive??this.options.caseSensitive});if(s){let t;try{t=a.options.parseParams?.(s)??s}catch(t){if(e?.strictParseParams)throw t}n={...n,...t}}return s&&(h=[...r,a]),!!h.length})),!!h.length);if(l([],c),!h.length)return;h.forEach((t=>{const e=v(t.path,n),o=v(t.id,n,!0),s=a.find((t=>t.id===o))||this.store.state.matchCache[o]?.match||new jt(this,t,{matchId:o,params:n,pathname:u([this.basepath,e])});r.push(s)}));const d=i(h);d.childRoutes?.length&&o(d.childRoutes)};return o([this.routeTree]),function(t){t.forEach(((e,r)=>{const a=t[r-1];a&&e.__setParentMatch(a)}))}(r),r};loadMatches=async(t,e)=>{this.cleanMatchCache(),t.forEach((async t=>{t.__validate()})),await Promise.all(t.map((async t=>{try{await(t.route.options.beforeLoad?.({router:this,match:t}))}catch(r){throw e?.preload||t.route.options.onLoadError?.(r),r}})));const r=t.map((async(r,a)=>{const o=t[1],s=r.store.state.search;s.__data?.matchId&&s.__data.matchId!==r.id||(r.load(e),"success"!==r.store.state.status&&r.__loadPromise&&await r.__loadPromise,o&&await o.__loadPromise)}));await Promise.all(r)};loadMatchData=async t=>Tt||!this.options.useServerData?await(t.route.options.loader?.({params:t.params,search:t.store.state.routeSearch,signal:t.abortController.signal}))||{}:this.options.fetchServerDataFn({router:this,routeMatch:t});invalidateRoute=async t=>{const e=this.buildNext(t),r=this.matchRoutes(e.pathname).map((t=>t.id));await Promise.allSettled([...this.store.state.currentMatches,...this.store.state.pendingMatches??[]].map((async t=>{if(r.includes(t.id))return t.invalidate()})))};reload=()=>{this.navigate({fromCurrent:!0,replace:!0,search:!0})};resolvePath=(t,e)=>m(this.basepath,t,l(e));navigate=async({from:t,to:r=".",search:a,hash:o,replace:s,params:n})=>{const i=String(r),c=String(t);let h;try{new URL(`${i}`),h=!0}catch(t){}return e(!h),this.#c({from:c,to:i,search:a,hash:o,replace:s,params:n})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const r=this.buildNext(t);return e?.pending?!!this.store.state.pendingLocation&&y(this.basepath,this.store.state.pendingLocation.pathname,{...e,to:r.pathname}):y(this.basepath,this.store.state.currentLocation.pathname,{...e,to:r.pathname})};buildLink=({from:t,to:e=".",search:r,params:a,hash:o,target:s,replace:n,activeOptions:i,preload:c,preloadMaxAge:h,preloadGcMaxAge:u,preloadDelay:l,disabled:d})=>{try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const f={from:t,to:e,search:r,params:a,hash:o,replace:n},p=this.buildNext(f);c=c??this.options.defaultPreload;const m=l??this.options.defaultPreloadDelay??0,g=this.store.state.currentLocation.pathname===p.pathname,v=this.store.state.currentLocation.pathname.split("/"),y=p.pathname.split("/").every(((t,e)=>t===v[e])),b=this.store.state.currentLocation.hash===p.hash;return{type:"internal",next:p,handleFocus:t=>{c&&this.preloadRoute(f,{maxAge:h,gcMaxAge:u}).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))},handleClick:t=>{d||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||s&&"_self"!==s||0!==t.button||(t.preventDefault(),!g||r||o||this.invalidateRoute(f),this.#c(f))},handleEnter:t=>{const e=t.target||{};if(c){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(f,{maxAge:h,gcMaxAge:u}).catch((t=>{console.warn(t),console.warn("Error preloading route! ☝️")}))}),m)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},isActive:(i?.exact?g:y)&&(!i?.includeHash||b),disabled:d}};dehydrate=()=>({state:{...h(this.store.state,["latestLocation","currentLocation","status","lastUpdated"]),currentMatches:this.store.state.currentMatches.map((t=>({matchId:t.id,state:{...h(t.store.state,["status","routeLoaderData","invalidAt","invalid"])}})))},context:this.options.context});hydrate=t=>{this.store.setState((r=>{this.options.context=t.context;const a=this.matchRoutes(t.state.latestLocation.pathname,{strictParseParams:!0});a.forEach(((r,a)=>{const o=t.state.currentMatches[a];e(o&&o.matchId===r.id),Object.assign(r,o)})),a.forEach((t=>t.__validate())),Object.assign(r,{...t.state,currentMatches:a})}))};getLoader=t=>{const e=t.from||"/",r=this.getRoute(e);if(!r)return;let a=this.store.state.loaders[e]||(()=>(this.store.setState((t=>{t.loaders[e]={pending:[],fetch:async t=>{if(!r)return;const a={loadedAt:Date.now(),loaderContext:t};this.store.setState((t=>{t.loaders[e].current=a,t.loaders[e].latest=a,t.loaders[e].pending.push(a)}));try{return await(r.options.loader?.(t))}finally{this.store.setState((t=>{t.loaders[e].pending=t.loaders[e].pending.filter((t=>t!==a))}))}}}})),this.store.state.loaders[e]))();return a};#n=t=>{const e=(t,r)=>t.map(((t,a)=>{const o=t.options,s=new L(t,o,a,r,this);if(this.routesById[s.id])throw new Error;this.routesById[s.id]=s;const n=t.children;return s.childRoutes=n.length?e(n,s):void 0,s}));return e([t])[0]};#o=t=>{let{pathname:e,search:r,hash:a,state:o}=this.history.location;const s=this.options.parseSearch(r);return{pathname:e,searchStr:r,search:Et(t?.search,s),hash:a.split("#").reverse()[0]??"",href:`${e}${r}${a}`,state:o,key:o?.key||"__init__"}};#s=()=>{this.load()};#i=(t={})=>{const e=t.fromCurrent?this.store.state.latestLocation.pathname:t.from??this.store.state.latestLocation.pathname;let r=m(this.basepath??"/",e,`${t.to??"."}`);const a=this.matchRoutes(this.store.state.latestLocation.pathname,{strictParseParams:!0}),o=this.matchRoutes(r),s={...i(a)?.params};let n=!0===(t.params??!0)?s:c(t.params,s);n&&o.map((t=>t.route.options.stringifyParams)).filter(Boolean).forEach((t=>{Object.assign({},n,t(n))})),r=v(r,n??{});const h=t.__preSearchFilters?.length?t.__preSearchFilters?.reduce(((t,e)=>e(t)),this.store.state.latestLocation.search):this.store.state.latestLocation.search,u=!0===t.search?h:t.search?c(t.search,h)??{}:t.__preSearchFilters?.length?h:{},l=t.__postSearchFilters?.length?t.__postSearchFilters.reduce(((t,e)=>e(t)),u):u,d=Et(this.store.state.latestLocation.search,l),f=this.options.stringifySearch(d);let p=!0===t.hash?this.store.state.latestLocation.hash:c(t.hash,this.store.state.latestLocation.hash);return p=p?`#${p}`:"",{pathname:r,search:d,searchStr:f,state:this.store.state.latestLocation.state,hash:p,href:`${r}${f}${p}`,key:t.key}};#c=t=>{const e=this.buildNext(t),r=""+Date.now()+Math.random();this.navigateTimeout&&clearTimeout(this.navigateTimeout);let a="replace";t.replace||(a="push");this.store.state.latestLocation.href===e.href&&!e.key&&(a="replace");const o=`${e.pathname}${e.searchStr}${e.hash?`#${e.hash}`:""}`;return this.history["push"===a?"push":"replace"](o,{id:r,...e.state}),this.load(this.#o(this.store.state.latestLocation)),this.navigationPromise=new Promise((t=>{const e=this.resolveNavigation;this.resolveNavigation=()=>{e(),t()}}))}},t.batch=xt,t.cleanPath=l,t.createAction=function(t){const r=Mt({submissions:[]},t.debug);return{options:t,store:r,reset:()=>{r.setState((t=>{t.submissions=[]}))},submit:async a=>{const o={submittedAt:Date.now(),status:"pending",payload:a,invalidate:()=>{s((t=>{t.isInvalid=!0}))},getIsLatest:()=>r.state.submissions[r.state.submissions.length-1]?.submittedAt===o.submittedAt},s=t=>{r.setState((r=>{const a=r.submissions.find((t=>t.submittedAt===o.submittedAt));e(a),t(a)}))};r.setState((e=>{e.submissions.push(o),e.submissions.reverse(),e.submissions=e.submissions.slice(0,t.maxSubmissions??10),e.submissions.reverse()}));const n=async()=>{t.onEachSettled?.(o),o.getIsLatest()&&await(t.onLatestSettled?.(o))};try{const e=await(t.action?.(o.payload));return s((t=>{t.response=e})),await(t.onEachSuccess?.(o)),o.getIsLatest()&&await(t.onLatestSuccess?.(o)),await n(),s((t=>{t.status="success"})),e}catch(e){throw console.error(e),s((t=>{t.error=e})),await(t.onEachError?.(o)),o.getIsLatest()&&await(t.onLatestError?.(o)),await n(),s((t=>{t.status="error"})),e}}}},t.createBrowserHistory=o,t.createHashHistory=function(){return o({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=function(t={initialEntries:["/"]}){const e=t.initialEntries;let o=t.initialIndex??e.length-1,i={};return a({getLocation:()=>s(e[o],i),listener:t=>(window.addEventListener(r,t),()=>{window.removeEventListener(r,t)}),pushState:(t,r)=>{i={...r,key:n()},e.push(t),o++},replaceState:(t,r)=>{i={...r,key:n()},e[o]=t},back:()=>{o--},forward:()=>{o=Math.min(o+1,e.length-1)},go:t=>window.history.go(t)})},t.createRouteConfig=_,t.createStore=Mt,t.decode=P,t.defaultFetchServerDataFn=$t,t.defaultParseSearch=It,t.defaultStringifySearch=Ft,t.encode=w,t.functionalUpdate=c,t.interpolatePath=v,t.invariant=e,t.joinPaths=u,t.last=i,t.matchByPath=b,t.matchPathname=y,t.parsePathname=g,t.parseSearchWith=Ct,t.pick=h,t.replaceEqualDeep=Et,t.resolvePath=m,t.rootRouteId=A,t.stringifySearchWith=kt,t.trackDeep=function(t){const e=new Set;return JSON.stringify(t,((t,r)=>{if("function"!=typeof r){if("object"==typeof r&&null!==r){if(e.has(r))return;e.add(r)}return r}})),t},t.trimPath=p,t.trimPathLeft=d,t.trimPathRight=f,t.warning=function(t,e){if(t){"undefined"!=typeof console&&console.warn(e);try{throw new Error(e)}catch{}}return!0},Object.defineProperty(t,"__esModule",{value:!0})}));
12
12
  //# sourceMappingURL=index.production.js.map