@tanstack/router-core 0.0.1-beta.2 → 0.0.1-beta.201

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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/build/cjs/defer.js +39 -0
  3. package/build/cjs/defer.js.map +1 -0
  4. package/build/cjs/fileRoute.js +29 -0
  5. package/build/cjs/fileRoute.js.map +1 -0
  6. package/build/cjs/index.js +89 -0
  7. package/build/cjs/{packages/router-core/src/index.js.map → index.js.map} +1 -1
  8. package/build/cjs/{packages/router-core/src/path.js → path.js} +45 -56
  9. package/build/cjs/path.js.map +1 -0
  10. package/build/cjs/{packages/router-core/src/qss.js → qss.js} +10 -15
  11. package/build/cjs/qss.js.map +1 -0
  12. package/build/cjs/route.js +114 -0
  13. package/build/cjs/route.js.map +1 -0
  14. package/build/cjs/router.js +1277 -0
  15. package/build/cjs/router.js.map +1 -0
  16. package/build/cjs/scroll-restoration.js +139 -0
  17. package/build/cjs/scroll-restoration.js.map +1 -0
  18. package/build/cjs/{packages/router-core/src/searchParams.js → searchParams.js} +32 -19
  19. package/build/cjs/searchParams.js.map +1 -0
  20. package/build/cjs/utils.js +132 -0
  21. package/build/cjs/utils.js.map +1 -0
  22. package/build/esm/index.js +1565 -2106
  23. package/build/esm/index.js.map +1 -1
  24. package/build/stats-html.html +59 -49
  25. package/build/stats-react.json +219 -241
  26. package/build/types/defer.d.ts +19 -0
  27. package/build/types/fileRoute.d.ts +35 -0
  28. package/build/types/index.d.ts +13 -611
  29. package/build/types/link.d.ts +96 -0
  30. package/build/types/path.d.ts +16 -0
  31. package/build/types/qss.d.ts +2 -0
  32. package/build/types/route.d.ts +261 -0
  33. package/build/types/routeInfo.d.ts +22 -0
  34. package/build/types/router.d.ts +265 -0
  35. package/build/types/scroll-restoration.d.ts +6 -0
  36. package/build/types/searchParams.d.ts +5 -0
  37. package/build/types/utils.d.ts +51 -0
  38. package/build/umd/index.development.js +1917 -2070
  39. package/build/umd/index.development.js.map +1 -1
  40. package/build/umd/index.production.js +23 -2
  41. package/build/umd/index.production.js.map +1 -1
  42. package/package.json +13 -7
  43. package/src/defer.ts +55 -0
  44. package/src/fileRoute.ts +156 -0
  45. package/src/index.ts +5 -11
  46. package/src/link.ts +149 -123
  47. package/src/path.ts +37 -17
  48. package/src/qss.ts +1 -1
  49. package/src/route.ts +861 -231
  50. package/src/routeInfo.ts +47 -205
  51. package/src/router.ts +1818 -952
  52. package/src/scroll-restoration.ts +179 -0
  53. package/src/searchParams.ts +31 -9
  54. package/src/utils.ts +106 -43
  55. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -33
  56. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  57. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js +0 -33
  58. package/build/cjs/node_modules/@babel/runtime/helpers/esm/extends.js.map +0 -1
  59. package/build/cjs/node_modules/history/index.js +0 -815
  60. package/build/cjs/node_modules/history/index.js.map +0 -1
  61. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +0 -30
  62. package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +0 -1
  63. package/build/cjs/packages/router-core/src/index.js +0 -58
  64. package/build/cjs/packages/router-core/src/path.js.map +0 -1
  65. package/build/cjs/packages/router-core/src/qss.js.map +0 -1
  66. package/build/cjs/packages/router-core/src/route.js +0 -161
  67. package/build/cjs/packages/router-core/src/route.js.map +0 -1
  68. package/build/cjs/packages/router-core/src/routeConfig.js +0 -69
  69. package/build/cjs/packages/router-core/src/routeConfig.js.map +0 -1
  70. package/build/cjs/packages/router-core/src/routeMatch.js +0 -266
  71. package/build/cjs/packages/router-core/src/routeMatch.js.map +0 -1
  72. package/build/cjs/packages/router-core/src/router.js +0 -789
  73. package/build/cjs/packages/router-core/src/router.js.map +0 -1
  74. package/build/cjs/packages/router-core/src/searchParams.js.map +0 -1
  75. package/build/cjs/packages/router-core/src/utils.js +0 -118
  76. package/build/cjs/packages/router-core/src/utils.js.map +0 -1
  77. package/src/frameworks.ts +0 -12
  78. package/src/routeConfig.ts +0 -495
  79. package/src/routeMatch.ts +0 -374
@@ -1,5 +1,5 @@
1
1
  /**
2
- * router-core
2
+ * @tanstack/router-core/src/index.ts
3
3
  *
4
4
  * Copyright (c) TanStack
5
5
  *
@@ -8,5 +8,26 @@
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==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=Boolean("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:{},loaderData:{},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=n.listen((t=>{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=>{Object.assign(s.options,t);const{basepath:e,routeConfig:a}=s.options;return s.basepath=P("/"+(null!=e?e:"")),a&&(s.routesById={},s.routeTree=s.__.buildRouteTree(a)),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(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.location=s.__.parseLocation(n.location),s.state.location=s.location,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";
12
+ /**
13
+ * @tanstack/history/src/index.ts
14
+ *
15
+ * Copyright (c) TanStack
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE.md file in the root directory of this source tree.
19
+ *
20
+ * @license MIT
21
+ */const e="pushstate",s="popstate",o="beforeunload",r=t=>(t.preventDefault(),t.returnValue=""),a=()=>{removeEventListener(o,r,{capture:!0})};function n(t){let e=t.getLocation(),s=new Set,n=[],c=[];const h=()=>{e=t.getLocation(),s.forEach((t=>t()))},d=()=>{if(n.length)n[0]?.(d,(()=>{n=[],a()}));else{for(;c.length;)c.shift()?.();h()}},l=t=>{c.push(t),d()};return{get location(){return e},subscribe:t=>(s.add(t),()=>{s.delete(t)}),push:(e,s)=>{s=i(s),l((()=>{t.pushState(e,s,h)}))},replace:(e,s)=>{s=i(s),l((()=>{t.replaceState(e,s,h)}))},go:e=>{l((()=>{t.go(e)}))},back:()=>{l((()=>{t.back()}))},forward:()=>{l((()=>{t.forward()}))},createHref:e=>t.createHref(e),block:t=>(n.push(t),1===n.length&&addEventListener(o,r,{capture:!0}),()=>{n=n.filter((e=>e!==t)),n.length||a()}),flush:()=>t.flush?.(),destroy:()=>t.destroy?.(),update:h}}function i(t){return t||(t={}),t.key=l(),t}function c(t){const o=t?.getHref??(()=>`${window.location.pathname}${window.location.search}${window.location.hash}`),r=t?.createHref??(t=>t);let a=d(o(),window.history.state);let i,c,h=!0;const l=()=>{h=!1,(()=>{i&&(window.history[i.isPush?"pushState":"replaceState"](i.state,"",i.href),i=void 0,c=void 0)})(),h=!0},u=(t,e,s,o)=>{const n=r(e);a=d(n,s),i={href:n,state:s,isPush:i?.isPush||"push"===t},o(),c||(c=Promise.resolve().then((()=>l())))},p=()=>{a=d(o(),window.history.state),y.update()};var f=window.history.pushState,m=window.history.replaceState;const y=n({getLocation:()=>a,pushState:(t,e,s)=>u("push",t,e,s),replaceState:(t,e,s)=>u("replace",t,e,s),back:()=>window.history.back(),forward:()=>window.history.forward(),go:t=>window.history.go(t),createHref:t=>r(t),flush:l,destroy:()=>{window.history.pushState=f,window.history.replaceState=m,window.removeEventListener(e,p),window.removeEventListener(s,p)}});return window.addEventListener(e,p),window.addEventListener(s,p),window.history.pushState=function(){let t=f.apply(window.history,arguments);return h&&y.update(),t},window.history.replaceState=function(){let t=m.apply(window.history,arguments);return h&&y.update(),t},y}function h(t={initialEntries:["/"]}){const e=t.initialEntries;let s=t.initialIndex??e.length-1,o={key:l()};return n({getLocation:()=>d(e[s],o),pushState:(t,r)=>{o=r,e.push(t),s++},replaceState:(t,r)=>{o=r,e[s]=t},back:()=>{s--},forward:()=>{s=Math.min(s+1,e.length-1)},go:t=>window.history.go(t),createHref:t=>t})}function d(t,e){let s=t.indexOf("#"),o=t.indexOf("?");return{href:t,pathname:t.substring(0,s>0?o>0?Math.min(s,o):s:o>0?o:t.length),hash:s>-1?t.substring(s):"",search:o>-1?t.slice(o,-1===s?void 0:s):"",state:e||{}}}function l(){return(Math.random()+1).toString(36).substring(7)}function u(t,e){if(!t)throw new Error("Invariant failed")}function p(t){return t[t.length-1]}function f(t,e){return"function"==typeof t?t(e):t}function m(t,e){return e.reduce(((e,s)=>(e[s]=t[s],e)),{})}function y(t,e){if(t===e)return t;const s=e,o=Array.isArray(t)&&Array.isArray(s);if(o||g(t)&&g(s)){const e=o?t.length:Object.keys(t).length,r=o?s:Object.keys(s),a=r.length,n=o?[]:{};let i=0;for(let e=0;e<a;e++){const a=o?e:r[e];n[a]=y(t[a],s[a]),n[a]===t[a]&&i++}return e===a&&i===e?t:n}return s}function g(t){if(!w(t))return!1;const e=t.constructor;if(void 0===e)return!0;const s=e.prototype;return!!w(s)&&!!s.hasOwnProperty("isPrototypeOf")}function w(t){return"[object Object]"===Object.prototype.toString.call(t)}function v(t,e){return t===e||typeof t==typeof e&&(g(t)&&g(e)?!Object.keys(e).some((s=>!v(t[s],e[s]))):!(!Array.isArray(t)||!Array.isArray(e))&&(t.length===e.length&&t.every(((t,s)=>v(t,e[s])))))}function _(t){return b(t.filter(Boolean).join("/"))}function b(t){return t.replace(/\/{2,}/g,"/")}function S(t){return"/"===t?t:t.replace(/^\/{1,}/,"")}function R(t){return"/"===t?t:t.replace(/\/{1,}$/,"")}function I(t){return R(S(t))}function M(t,e,s){e=e.replace(new RegExp(`^${t}`),"/"),s=s.replace(new RegExp(`^${t}`),"/");let o=x(e);const r=x(s);r.forEach(((t,e)=>{if("/"===t.value)e?e===r.length-1&&o.push(t):o=[t];else if(".."===t.value)o.length>1&&"/"===p(o)?.value&&o.pop(),o.pop();else{if("."===t.value)return;o.push(t)}}));return b(_([t,...o.map((t=>t.value))]))}function x(t){if(!t)return[];const e=[];if("/"===(t=b(t)).slice(0,1)&&(t=t.substring(1),e.push({type:"pathname",value:"/"})),!t)return e;const s=t.split("/").filter(Boolean);return e.push(...s.map((t=>"$"===t||"*"===t?{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 E(t,e,s=!1){return _(x(t).map((t=>{if("wildcard"===t.type){const o=e[t.value];return s?`${t.value}${o??""}`:o}return"param"===t.type?e[t.value.substring(1)]??"":t.value})))}function L(t,e,s){const o=P(t,e,s);if(!s.to||o)return o??{}}function P(t,e,s){e="/"!=t?e.substring(t.length):e;const o=`${s.to??"$"}`,r=x(e),a=x(o);e.startsWith("/")||r.unshift({type:"pathname",value:"/"}),o.startsWith("/")||a.unshift({type:"pathname",value:"/"});const n={};return(()=>{for(let t=0;t<Math.max(r.length,a.length);t++){const e=r[t],o=a[t],i=t>=r.length-1,c=t>=a.length-1;if(o){if("wildcard"===o.type)return!!e?.value&&(n["*"]=_(r.slice(t).map((t=>t.value))),!0);if("pathname"===o.type){if("/"===o.value&&!e?.value)return!0;if(e)if(s.caseSensitive){if(o.value!==e.value)return!1}else if(o.value.toLowerCase()!==e.value.toLowerCase())return!1}if(!e)return!1;if("param"===o.type){if("/"===e?.value)return!1;"$"!==e.value.charAt(0)&&(n[o.value.substring(1)]=e.value)}}if(!i&&c)return!!s.fuzzy}return!0})()?n:void 0}function A(t,e){var s,o,r,a="";for(s in t)if(void 0!==(r=t[s]))if(Array.isArray(r))for(o=0;o<r.length;o++)a&&(a+="&"),a+=encodeURIComponent(s)+"="+encodeURIComponent(r[o]);else a&&(a+="&"),a+=encodeURIComponent(s)+"="+encodeURIComponent(r);return(e||"")+a}function O(t){if(!t)return"";var e=decodeURIComponent(t);return"false"!==e&&("true"===e||(0*+e==0&&+e+""===e?+e:e))}function D(t){for(var e,s,o={},r=t.split("&");e=r.shift();)void 0!==o[s=(e=e.split("=")).shift()]?o[s]=[].concat(o[s],O(e.shift())):o[s]=O(e.shift());return o}const B="__root__";class C{constructor(t){this.options=t||{},this.isRoot=!t?.getParentRoute,C.__onInit(this)}init=t=>{this.originalIndex=t.originalIndex,this.router=t.router;const e=this.options,s=!e?.path&&!e?.id;this.parentRoute=this.options?.getParentRoute?.(),s?this.path=B:u(this.parentRoute);let o=s?B:e.path;o&&"/"!==o&&(o=I(o));const r=e?.id||o;let a=s?B:_([this.parentRoute.id===B?"":this.parentRoute.id,r]);o===B&&(o="/"),a!==B&&(a=_(["/",a]));const n=a===B?"/":_([this.parentRoute.fullPath,o]);this.path=o,this.id=a,this.fullPath=n,this.to=n};addChildren=t=>(this.children=t,this);update=t=>(Object.assign(this.options,t),this);static __onInit=t=>{}}class $ extends C{constructor(t){super(t)}}
22
+ /**
23
+ * @tanstack/store/src/index.ts
24
+ *
25
+ * Copyright (c) TanStack
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE.md file in the root directory of this source tree.
29
+ *
30
+ * @license MIT
31
+ */
32
+ class k{listeners=new Set;_batching=!1;_flushing=0;_nextPriority=null;constructor(t,e){this.state=t,this.options=e}subscribe=t=>{this.listeners.add(t);const e=this.options?.onSubscribe?.(t,this);return()=>{this.listeners.delete(t),e?.()}};setState=(t,e)=>{const s=this.state;this.state=this.options?.updateFn?this.options.updateFn(s)(t):t(s);const o=e?.priority??this.options?.defaultPriority??"high";null===this._nextPriority||"high"===this._nextPriority?this._nextPriority=o:this._nextPriority=this.options?.defaultPriority??"high",this.options?.onUpdate?.({priority:this._nextPriority}),this._flush()};_flush=()=>{if(this._batching)return;const t=++this._flushing;this.listeners.forEach((e=>{this._flushing===t&&e({priority:this._nextPriority??"high"})}))};batch=t=>{if(this._batching)return t();this._batching=!0,t(),this._batching=!1,this._flush()}}const T=H(JSON.parse),j=F(JSON.stringify,JSON.parse);function H(t){return e=>{"?"===e.substring(0,1)&&(e=e.substring(1));let s=D(e);for(let e in s){const o=s[e];if("string"==typeof o)try{s[e]=t(o)}catch(t){}}return s}}function F(t,e){return s=>{(s={...s})&&Object.keys(s).forEach((o=>{const r=s[o];void 0===r||void 0===r?delete s[o]:s[o]=function(s){if("object"==typeof s&&null!==s)try{return t(s)}catch(t){}else if("string"==typeof s&&"function"==typeof e)try{return e(s),t(s)}catch(t){}return s}(r)}));const o=A(s).toString();return o?`?${o}`:""}}const N=["component","errorComponent","pendingComponent"],K="visibilitychange",U="focus",Y="Error preloading route! ☝️";const J="undefined"==typeof window||!window.document.createElement;function W(){return{status:"idle",isFetching:!1,resolvedLocation:null,location:null,matchesById:{},matchIds:[],pendingMatchIds:[],matches:[],pendingMatches:[],renderedMatchIds:[],renderedMatches:[],lastUpdated:Date.now()}}function X(t){return!!t?.isRedirect}class z extends Error{}class q extends Error{}function V(t,e){const s=Date.now();return!!t.invalid||(e?.preload?!(t.preloadMaxAge<0)&&t.updatedAt+t.preloadMaxAge<s:!(t.maxAge<0)&&t.updatedAt+t.maxAge<s)}const G="window",Q="___";let Z,tt={},et=!1;const st="undefined"!=typeof window&&window.sessionStorage,ot=t=>t.state.key;t.FileRoute=class{constructor(t){this.path=t}createRoute=t=>{const e=new C(t);return e.isRoot=!1,e}},t.PathParamError=q,t.RootRoute=$,t.Route=C,t.Router=class{#t;resetNextScroll=!1;tempLocationKey=`${Math.round(1e7*Math.random())}`;constructor(t){this.options={defaultPreloadDelay:50,context:void 0,...t,stringifySearch:t?.stringifySearch??j,parseSearch:t?.parseSearch??T},this.__store=new k(W(),{onUpdate:()=>{const t=this.state,e=this.__store.state,s=t.matchesById!==e.matchesById;let o,r;if(s||(o=t.matchIds.length!==e.matchIds.length||t.matchIds.some(((t,s)=>t!==e.matchIds[s])),r=t.pendingMatchIds.length!==e.pendingMatchIds.length||t.pendingMatchIds.some(((t,s)=>t!==e.pendingMatchIds[s]))),(s||o)&&(e.matches=e.matchIds.map((t=>e.matchesById[t]))),(s||r)&&(e.pendingMatches=e.pendingMatchIds.map((t=>e.matchesById[t]))),s||o||r){const t=e.pendingMatches.some((t=>!!this.getRoute(t.routeId)?.options.pendingComponent));e.renderedMatchIds=t?e.pendingMatchIds:e.matchIds,e.renderedMatches=e.renderedMatchIds.map((t=>e.matchesById[t]))}e.isFetching=[...e.matches,...e.pendingMatches].some((t=>t.isFetching)),this.state=e},defaultPriority:"low"}),this.state=this.__store.state,this.update(t);const e=this.buildLocation({search:!0,params:!0,hash:!0,state:!0});this.state.location.href!==e.href&&this.#e({...e,replace:!0})}subscribers=new Set;subscribe=(t,e)=>{const s={eventType:t,fn:e};return this.subscribers.add(s),()=>{this.subscribers.delete(s)}};#s=t=>{this.subscribers.forEach((e=>{e.eventType===t.type&&e.fn(t)}))};reset=()=>{this.__store.setState((t=>Object.assign(t,W())))};mount=()=>("undefined"!=typeof window&&window.addEventListener&&(window.addEventListener(K,this.#o,!1),window.addEventListener(U,this.#o,!1)),this.safeLoad(),()=>{"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener(K,this.#o),window.removeEventListener(U,this.#o))});#o=()=>{(this.options.reloadOnWindowFocus??1)&&this.invalidate({__fromFocus:!0})};update=t=>{if(this.options={...this.options,...t,context:{...this.options.context,...t?.context}},!this.history||this.options.history&&this.options.history!==this.history){this.#t&&this.#t(),this.history=this.options.history??(J?h():c());const t=this.#r();this.__store.setState((e=>({...e,resolvedLocation:t,location:t}))),this.#t=this.history.subscribe((()=>{this.safeLoad({next:this.#r(this.state.location)})}))}const{basepath:e,routeTree:s}=this.options;return this.basepath=`/${I(e??"")??""}`,s&&s!==this.routeTree&&this.#a(s),this};cancelMatches=()=>{this.state.matches.forEach((t=>{this.cancelMatch(t.id)}))};cancelMatch=t=>{this.getRouteMatch(t)?.abortController?.abort()};safeLoad=async t=>{try{return this.load(t)}catch(t){}};latestLoadPromise=Promise.resolve();load=async t=>{const e=new Promise((async(s,o)=>{const r=this.state.resolvedLocation,a=!(!t?.next||r.href===t.next.href);let n;const i=()=>this.latestLoadPromise!==e?this.latestLoadPromise:void 0;let c;this.#s({type:"onBeforeLoad",from:r,to:t?.next??this.state.location,pathChanged:a}),this.__store.batch((()=>{t?.next&&this.__store.setState((e=>({...e,location:t.next}))),c=this.matchRoutes(this.state.location.pathname,this.state.location.search,{throwOnError:t?.throwOnError,debug:!0}),this.__store.setState((t=>({...t,status:"pending",pendingMatchIds:c.map((t=>t.id)),matchesById:this.#n(t.matchesById,c)})))}));try{try{await this.loadMatches(c.map((t=>t.id)))}catch(t){}if(n=i())return n;const t=this.state.matchIds.filter((t=>!this.state.pendingMatchIds.includes(t))),e=this.state.pendingMatchIds.filter((t=>!this.state.matchIds.includes(t))),o=this.state.matchIds.filter((t=>this.state.pendingMatchIds.includes(t)));this.__store.setState((t=>({...t,status:"idle",resolvedLocation:t.location,matchIds:t.pendingMatchIds,pendingMatchIds:[]}))),[[t,"onLeave"],[e,"onEnter"],[o,"onTransition"]].forEach((([t,e])=>{t.forEach((t=>{const s=this.getRouteMatch(t);this.getRoute(s.routeId).options[e]?.(s)}))})),this.#s({type:"onLoad",from:r,to:this.state.location,pathChanged:a}),s()}catch(t){if(n=i())return n;o(t)}}));return this.latestLoadPromise=e,this.latestLoadPromise.then((()=>{this.cleanMatches()})),this.latestLoadPromise};#n=(t,e)=>{let s={...t};return e.forEach((t=>{s[t.id]||(s[t.id]=t),s[t.id]={...s[t.id],...t}})),s};getRoute=t=>{const e=this.routesById[t];return u(e),e};preloadRoute=async(t=this.state.location)=>{let e=this.buildLocation(t);const s=this.matchRoutes(e.pathname,e.search,{throwOnError:!0});return this.__store.setState((t=>({...t,matchesById:this.#n(t.matchesById,s)}))),await this.loadMatches(s.map((t=>t.id)),{preload:!0,maxAge:t.maxAge}),[p(s),s]};cleanMatches=()=>{const t=Date.now(),e=Object.values(this.state.matchesById).filter((e=>{const s=this.getRoute(e.routeId);return!(this.state.matchIds.includes(e.id)||this.state.pendingMatchIds.includes(e.id)||e.preloadMaxAge>-1&&!(e.updatedAt+e.preloadMaxAge<t)||s.options.gcMaxAge&&!(e.updatedAt+s.options.gcMaxAge<t))})).map((t=>t.id));e.length&&this.__store.setState((t=>{const s={...t.matchesById};return e.forEach((t=>{delete s[t]})),{...t,matchesById:s}}))};matchRoutes=(t,e,s)=>{let o={},r=this.flatRoutes.find((e=>{const s=L(this.basepath,R(t),{to:e.fullPath,caseSensitive:e.options.caseSensitive??this.options.caseSensitive});return!!s&&(o=s,!0)}))||this.routesById.__root__,a=[r];for(;r?.parentRoute;)r=r.parentRoute,r&&a.unshift(r);const n=a.map((t=>{let e;if(t.options.parseParams)try{const e=t.options.parseParams(o);Object.assign(o,e)}catch(t){if(e=new q(t.message,{cause:t}),s?.throwOnError)throw e;return e}})),i=a.map(((t,s)=>{const r=E(t.path,o),a=t.options.loaderContext?t.options.loaderContext({search:e}):void 0,i=JSON.stringify([E(t.id,o,!0),a].filter((t=>void 0!==t)),((e,s)=>("function"==typeof s&&(console.info(t),u(!1)),"object"==typeof s&&null!==s?Object.fromEntries(Object.keys(s).sort().map((t=>[t,s[t]]))):s))),c=this.getRouteMatch(i);if(c)return{...c};const h=!(!t.options.loader&&!N.some((e=>t.options[e]?.preload)));return{id:i,loaderContext:a,routeId:t.id,params:o,pathname:_([this.basepath,r]),updatedAt:Date.now(),maxAge:-1,preloadMaxAge:-1,routeSearch:{},search:{},status:h?"pending":"success",isFetching:!1,invalid:!1,error:void 0,paramsError:n[s],searchError:void 0,loaderData:void 0,loadPromise:Promise.resolve(),context:void 0,abortController:new AbortController,fetchedAt:0}}));return i.forEach(((t,o)=>{const r=i[o-1],a=this.getRoute(t.routeId),n=(()=>{const o={search:r?.search??e,routeSearch:r?.routeSearch??e};try{let e=("object"==typeof a.options.validateSearch?a.options.validateSearch.parse:a.options.validateSearch)?.(o.search)??{},s={...o.search,...e};return e=y(t.routeSearch,e),s=y(t.search,s),{routeSearch:e,search:s,searchDidChange:t.routeSearch!==e}}catch(e){if(t.searchError=new z(e.message,{cause:e}),s?.throwOnError)throw t.searchError;return o}})();Object.assign(t,n)})),i};loadMatches=async(t,e)=>{const s=()=>t.map((t=>this.getRouteMatch(t)));let o;e?.preload||s().forEach((t=>{this.setRouteMatch(t.id,(e=>({...e,routeSearch:t.routeSearch,search:t.search,context:t.context,error:t.error,paramsError:t.paramsError,searchError:t.searchError,params:t.params,preloadMaxAge:0})))}));try{for(const[t,r]of s().entries()){const a=s()[t-1],n=this.getRoute(r.routeId),i=(e,s)=>{if(e.routerCode=s,o=o??t,X(e))throw e;try{n.options.onError?.(e)}catch(t){if(e=t,X(t))throw t}this.setRouteMatch(r.id,(t=>({...t,error:e,status:"error",updatedAt:Date.now()})))};r.paramsError&&i(r.paramsError,"PARSE_PARAMS"),r.searchError&&i(r.searchError,"VALIDATE_SEARCH");let c=!1;const h=a?.context??this?.options.context??{};try{const t=await(n.options.beforeLoad?.({abortController:r.abortController,params:r.params,preload:!!e?.preload,context:{...h,...r.loaderContext}}))??{},s={...h,...r.loaderContext,...t};this.setRouteMatch(r.id,(t=>({...t,context:y(t.context,s)})))}catch(t){i(t,"BEFORE_LOAD"),c=!0}if(c)break}}catch(t){if(X(t))return void(e?.preload||this.navigate(t));throw t}const r=s().slice(0,o),a=[];r.forEach(((t,s)=>{a.push((async()=>{const o=a[s-1],r=this.getRoute(t.routeId);if(t.isFetching||"success"===t.status&&!V(t,{preload:e?.preload}))return this.getRouteMatch(t.id)?.loadPromise;const n=Date.now(),i=()=>{const e=this.getRouteMatch(t.id);return e&&e.fetchedAt!==n?e.loadPromise:void 0},c=t=>!!X(t)&&(e?.preload||this.navigate(t),!0),h=async()=>{let s;try{const a=Promise.all(N.map((async t=>{const e=r.options[t];e?.preload&&await e.preload()}))),n=r.options.loader?.({params:t.params,preload:!!e?.preload,parentMatchPromise:o,abortController:t.abortController,context:t.context}),[c,h]=await Promise.all([a,n]);if(s=i())return await s;this.setRouteMatchData(t.id,(()=>h),e)}catch(e){if(s=i())return await s;if(c(e))return;try{r.options.onError?.(e)}catch(t){if(e=t,c(t))return}this.setRouteMatch(t.id,(t=>({...t,error:e,status:"error",isFetching:!1,updatedAt:Date.now()})))}};let d;this.__store.batch((()=>{this.setRouteMatch(t.id,(t=>({...t,isFetching:!0,fetchedAt:n,invalid:!1}))),d=h(),this.setRouteMatch(t.id,(t=>({...t,loadPromise:d})))})),await d})())})),await Promise.all(a)};resolvePath=(t,e)=>M(this.basepath,t,b(e));navigate=async({from:t,to:e="",...s})=>{const o=String(e),r=void 0===t?t:String(t);let a;try{new URL(`${o}`),a=!0}catch(t){}return u(!a),this.#i({...s,from:r,to:o})};matchRoute=(t,e)=>{t={...t,to:t.to?this.resolvePath(t.from??"",t.to):void 0};const s=this.buildLocation(t);if(e?.pending&&"pending"!==this.state.status)return!1;const o=e?.pending?this.state.location:this.state.resolvedLocation;if(!o)return!1;const r=L(this.basepath,o.pathname,{...e,to:s.pathname});return!!r&&(e?.includeSearch??1?!!v(o.search,s.search)&&r:r)};buildLink=t=>{const{to:e,preload:s,preloadDelay:o,activeOptions:r,disabled:a,target:n,replace:i,resetScroll:c}=t;try{return new URL(`${e}`),{type:"external",href:e}}catch(t){}const h=t,d=this.buildLocation(h),l=s??this.options.defaultPreload,u=o??this.options.defaultPreloadDelay??0,p=this.state.location.pathname.split("/"),f=d.pathname.split("/").every(((t,e)=>t===p[e])),m=r?.exact?this.state.location.pathname===d.pathname:f,y=!r?.includeHash||this.state.location.hash===d.hash,g=!(r?.includeSearch??1)||v(this.state.location.search,d.search);return{type:"internal",next:d,handleFocus:t=>{l&&this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))},handleClick:t=>{a||function(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}(t)||t.defaultPrevented||n&&"_self"!==n||0!==t.button||(t.preventDefault(),this.#e({...d,replace:i,resetScroll:c}))},handleEnter:t=>{const e=t.target||{};if(l){if(e.preloadTimeout)return;e.preloadTimeout=setTimeout((()=>{e.preloadTimeout=null,this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))}),u)}},handleLeave:t=>{const e=t.target||{};e.preloadTimeout&&(clearTimeout(e.preloadTimeout),e.preloadTimeout=null)},handleTouchStart:t=>{this.preloadRoute(h).catch((t=>{console.warn(t),console.warn(Y)}))},isActive:m&&y&&g,disabled:a}};dehydrate=()=>({state:{matchIds:this.state.matchIds,dehydratedMatches:this.state.matches.map((t=>m(t,["fetchedAt","invalid","preloadMaxAge","maxAge","id","loaderData","status","updatedAt"])))}});hydrate=async t=>{let e=t;"undefined"!=typeof document&&(e=window.__TSR_DEHYDRATED__),u(e);const s=e;this.dehydratedData=s.payload,this.options.hydrate?.(s.payload);const o=s.router.state;let r=this.matchRoutes(this.state.location.pathname,this.state.location.search).map((t=>{const e=o.dehydratedMatches.find((e=>e.id===t.id));return u(e,t.id),e?{...t,...e}:t}));this.__store.setState((t=>({...t,matchIds:o.matchIds,matches:r,matchesById:this.#n(t.matchesById,r)})))};injectedHtml=[];injectHtml=async t=>{this.injectedHtml.push(t)};dehydrateData=(t,e)=>{if("undefined"==typeof document){const s="string"==typeof t?t:JSON.stringify(t);return this.injectHtml((async()=>{const t=`__TSR_DEHYDRATED__${s}`,o="function"==typeof e?await e():e;return`<script id='${t}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${r=s,r.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/"/g,'\\"')}"] = ${JSON.stringify(o)}\n ;(() => {\n var el = document.getElementById('${t}')\n el.parentElement.removeChild(el)\n })()\n <\/script>`;var r})),()=>this.hydrateData(t)}return()=>{}};hydrateData=t=>{if("undefined"!=typeof document){const e="string"==typeof t?t:JSON.stringify(t);return window[`__TSR_DEHYDRATED__${e}`]}};#a=t=>{this.routeTree=t,this.routesById={},this.routesByPath={},this.flatRoutes=[];const e=t=>{t.forEach(((t,s)=>{t.init({originalIndex:s,router:this});if(u(!this.routesById[t.id],String(t.id)),this.routesById[t.id]=t,!t.isRoot&&t.path){const e=R(t.fullPath);this.routesByPath[e]&&!t.fullPath.endsWith("/")||(this.routesByPath[e]=t)}const o=t.children;o?.length&&e(o)}))};e([t]),this.flatRoutes=Object.values(this.routesByPath).map(((t,e)=>{const s=I(t.fullPath),o=x(s);for(;o.length>1&&"/"===o[0]?.value;)o.shift();const r=o.map((t=>"param"===t.type?.5:"wildcard"===t.type?.25:1));return{child:t,trimmed:s,parsed:o,index:e,score:r}})).sort(((t,e)=>{let s="/"===t.trimmed?1:"/"===e.trimmed?-1:0;if(0!==s)return s;const o=Math.min(t.score.length,e.score.length);if(t.score.length!==e.score.length)return e.score.length-t.score.length;for(let s=0;s<o;s++)if(t.score[s]!==e.score[s])return e.score[s]-t.score[s];for(let s=0;s<o;s++)if(t.parsed[s].value!==e.parsed[s].value)return t.parsed[s].value>e.parsed[s].value?1:-1;return t.trimmed!==e.trimmed?t.trimmed>e.trimmed?1:-1:t.index-e.index})).map(((t,e)=>(t.child.rank=e,t.child)))};#r=t=>{const e=({pathname:e,search:s,hash:o,state:r})=>{const a=this.options.parseSearch(s);return{pathname:e,searchStr:s,search:y(t?.search,a),hash:o.split("#").reverse()[0]??"",href:`${e}${s}${o}`,state:y(t?.state,r)}},s=e(this.history.location);let{__tempLocation:o,__tempKey:r}=s.state;if(o&&(!r||r===this.tempLocationKey)){const t=e(o);return t.state.key=s.state.key,delete t.state.__tempLocation,{...t,maskedLocation:s}}return s};buildLocation=(t={})=>{const e=(t={},e)=>{const s=this.state.location,o=t.from??s.pathname;let r=M(this.basepath??"/",o,`${t.to??""}`);const a={...p(this.matchRoutes(o,s.search))?.params};let n=!0===(t.params??!0)?a:f(t.params,a);n&&e?.map((t=>this.getRoute(t.routeId).options.stringifyParams)).filter(Boolean).forEach((t=>{n={...n,...t(n)}})),r=E(r,n??{});const i=e?.map((t=>this.getRoute(t.routeId).options.preSearchFilters??[])).flat().filter(Boolean)??[],c=e?.map((t=>this.getRoute(t.routeId).options.postSearchFilters??[])).flat().filter(Boolean)??[],h=i?.length?i?.reduce(((t,e)=>e(t)),s.search):s.search,d=!0===t.search?h:t.search?f(t.search,h)??{}:i?.length?h:{},l=c?.length?c.reduce(((t,e)=>e(t)),d):d,u=y(s.search,l),m=this.options.stringifySearch(u),g=!0===t.hash?s.hash:t.hash?f(t.hash,s.hash):s.hash,w=g?`#${g}`:"";let v=!0===t.state?s.state:t.state?f(t.state,s.state):s.state;return v=y(s.state,v),{pathname:r,search:u,searchStr:m,state:v,hash:g,href:this.history.createHref(`${r}${m}${w}`),unmaskOnReload:t.unmaskOnReload}},s=(t={},s)=>{let o=e(t),r=s?e(s):void 0;if(!r){let t={},a=this.options.routeMasks?.find((e=>{const s=L(this.basepath,o.pathname,{to:e.from,fuzzy:!1});return!!s&&(t=s,!0)}));a&&(a={...a,from:E(a.from,t)},r=e(s=a))}const a=this.matchRoutes(o.pathname,o.search),n=r?this.matchRoutes(r.pathname,r.search):void 0,i=r?e(s,n):void 0,c=e(t,a);return i&&(c.maskedLocation=i),c};return t.mask?s(t,{...m(t,["from"]),...t.mask}):s(t)};#i=({replace:t,resetScroll:e,...s}={})=>{const o=this.buildLocation(s);return this.#e({...o,replace:t,resetScroll:e})};#e=async t=>{this.navigateTimeout&&clearTimeout(this.navigateTimeout);if(this.state.location.href===t.href&&!t.replace)return;let{maskedLocation:e,...s}=t;return e&&(s={...e,state:{...e.state,__tempKey:void 0,__tempLocation:{...s,search:s.searchStr,state:{...s.state,__tempKey:void 0,__tempLocation:void 0,key:void 0}}}},(s.unmaskOnReload??this.options.unmaskOnReload)&&(s.state.__tempKey=this.tempLocationKey)),this.history[t.replace?"replace":"push"](s.href,s.state),this.resetNextScroll=t.resetScroll??!0,this.latestLoadPromise};getRouteMatch=t=>this.state.matchesById[t];setRouteMatch=(t,e)=>{this.__store.setState((s=>s.matchesById[t]?{...s,matchesById:{...s.matchesById,[t]:e(s.matchesById[t])}}:s))};setRouteMatchData=(t,e,s)=>{const o=this.getRouteMatch(t);if(!o)return;const r=this.getRoute(o.routeId),a=s?.updatedAt??Date.now(),n=s?.maxAge??r.options.preloadMaxAge??this.options.defaultPreloadMaxAge??5e3,i=s?.maxAge??r.options.maxAge??this.options.defaultMaxAge??-1;this.setRouteMatch(t,(t=>({...t,error:void 0,status:"success",isFetching:!1,updatedAt:a,loaderData:f(e,t.loaderData),preloadMaxAge:n,maxAge:i})))};invalidate=async t=>{if(t?.matchId){this.setRouteMatch(t.matchId,(t=>({...t,invalid:!0})));const e=this.state.matches.findIndex((e=>e.id===t.matchId)),s=this.state.matches[e+1];if(s)return this.invalidate({matchId:s.id,reload:!1,__fromFocus:t.__fromFocus})}else this.__store.batch((()=>{Object.values(this.state.matchesById).forEach((e=>{const s=this.getRoute(e.routeId);(!t?.__fromFocus||(s.options.reloadOnWindowFocus??!0))&&this.setRouteMatch(e.id,(t=>({...t,invalid:!0})))}))}));if(t?.reload??1)return this.load()}},t.RouterContext=class{constructor(){}createRootRoute=t=>new $(t)},t.SearchParamError=z,t.cleanPath=b,t.componentTypes=N,t.createBrowserHistory=c,t.createHashHistory=function(){return c({getHref:()=>window.location.hash.substring(1),createHref:t=>`#${t}`})},t.createMemoryHistory=h,t.createRouteMask=function(t){return t},t.decode=D,t.defaultParseSearch=T,t.defaultStringifySearch=j,t.defer=function(t){const e=t;if(!e.__deferredState){e.__deferredState={uid:Math.random().toString(36).slice(2),status:"pending"};const t=e.__deferredState;e.then((e=>{t.status="success",t.data=e})).catch((e=>{t.status="error",t.error=e}))}return e},t.encode=A,t.functionalUpdate=f,t.interpolatePath=E,t.invariant=u,t.isDehydratedDeferred=function(t){return"object"==typeof t&&null!==t&&!(t instanceof Promise)&&!t.then&&"__deferredState"in t},t.isMatchInvalid=V,t.isPlainObject=g,t.isRedirect=X,t.joinPaths=_,t.last=p,t.lazyFn=function(t,e){return async(...s)=>(await t())[e||"default"](...s)},t.matchByPath=P,t.matchPathname=L,t.parsePathname=x,t.parseSearchWith=H,t.partialDeepEqual=v,t.pick=m,t.redirect=function(t){return t.isRedirect=!0,t},t.replaceEqualDeep=y,t.resolvePath=M,t.restoreScrollPositions=function(t,e){if(et){if(!t.resetNextScroll)return;et=!1;const s=(e?.getKey||ot)(t.state.location);let o=!1;for(const t in Z.current){const e=Z.current[t],[r,a]=t.split(Q);if(r===s)if(a===G)o=!0,window.scrollTo(e.scrollX,e.scrollY);else if(a){const t=document.querySelector(a);t&&(t.scrollLeft=e.scrollX,t.scrollTop=e.scrollY)}}o||window.scrollTo(0,0)}},t.rootRouteId=B,t.stringifySearchWith=F,t.trimPath=I,t.trimPathLeft=S,t.trimPathRight=R,t.warning=function(t,e){},t.watchScrollPositions=function(t,e){const s=e?.getKey||ot;st&&(Z||(Z=(()=>{const t="tsr-scroll-restoration-v1",e=JSON.parse(window.sessionStorage.getItem(t)||"{}");return{current:e,set:(s,o)=>{e[s]=o,window.sessionStorage.setItem(t,JSON.stringify(Z))}}})()));const{history:o}=window;o.scrollRestoration&&(o.scrollRestoration="manual");const r=e=>{const o=s(t.state.resolvedLocation);tt[o]||(tt[o]=new WeakSet);const r=tt[o];if(r.has(e.target))return;r.add(e.target);const n=[o,e.target===document||e.target===window?G:a(e.target)].join(Q);Z.current[n]||Z.set(n,{scrollX:NaN,scrollY:NaN})},a=t=>{let e,s=[];for(;e=t.parentNode;)s.unshift(`${t.tagName}:nth-child(${[].indexOf.call(e.children,t)+1})`),t=e;return`${s.join(" > ")}`.toLowerCase()};"undefined"!=typeof document&&document.addEventListener("scroll",r,!0);const n=t.subscribe("onBeforeLoad",(t=>{t.pathChanged&&(t=>{const e=s(t);for(const t in Z.current){const s=Z.current[t],[o,r]=t.split(Q);if(e===o){if(r===G)s.scrollX=window.scrollX||0,s.scrollY=window.scrollY||0;else if(r){const t=document.querySelector(r);s.scrollX=t?.scrollLeft||0,s.scrollY=t?.scrollTop||0}Z.set(t,s)}}})(t.from)})),i=t.subscribe("onLoad",(t=>{t.pathChanged&&(et=!0)}));return()=>{document.removeEventListener("scroll",r),n(),i()}},Object.defineProperty(t,"__esModule",{value:!0})}));
12
33
  //# sourceMappingURL=index.production.js.map